From owner-svn-src-head@freebsd.org Sat Aug 4 14:26:40 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 99C4B106CF56; Sat, 4 Aug 2018 14:26:40 +0000 (UTC) (envelope-from cy.schubert@cschubert.com) Received: from smtp-out-so.shaw.ca (smtp-out-so.shaw.ca [64.59.136.137]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "Client", Issuer "CA" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id E0E0E79B7E; Sat, 4 Aug 2018 14:26:39 +0000 (UTC) (envelope-from cy.schubert@cschubert.com) Received: from spqr.komquats.com ([70.67.125.17]) by shaw.ca with ESMTPA id lxVlf8gBgwyxUlxVmf58mc; Sat, 04 Aug 2018 08:26:32 -0600 X-Authority-Analysis: v=2.3 cv=NPJhBHyg c=1 sm=1 tr=0 a=VFtTW3WuZNDh6VkGe7fA3g==:117 a=VFtTW3WuZNDh6VkGe7fA3g==:17 a=kj9zAlcOel0A:10 a=dapMudl6Dx4A:10 a=xfDLHkLGAAAA:8 a=HHGDD-5mAAAA:8 a=SWg00rOMAAAA:8 a=6I5d2MoRAAAA:8 a=YxBL1-UpAAAA:8 a=NxvbkCmBGjDIeVatmJsA:9 a=XYqoIGHLEpixj2xu:21 a=Ca4R-PxvlJ3HifTr:21 a=CjuIK1q_8ugA:10 a=IfaqVvZgccqrtc8gcwf2:22 a=nWvTgx2JuP7DHgfbJPXu:22 a=IjZwj45LgO3ly-622nXo:22 a=Ia-lj3WSrqcvXOmTRaiG:22 Received: from slippy.cwsent.com (slippy [10.1.1.91]) by spqr.komquats.com (Postfix) with ESMTPS id BFE0519AD; Sat, 4 Aug 2018 07:26:46 -0700 (PDT) Received: from slippy.cwsent.com (localhost [127.0.0.1]) by slippy.cwsent.com (8.15.2/8.15.2) with ESMTP id w74EQS1X028532; Sat, 4 Aug 2018 07:26:28 -0700 (PDT) (envelope-from Cy.Schubert@cschubert.com) Received: from slippy (cy@localhost) by slippy.cwsent.com (8.15.2/8.15.2/Submit) with ESMTP id w74EQSHd028096; Sat, 4 Aug 2018 07:26:28 -0700 (PDT) (envelope-from Cy.Schubert@cschubert.com) Message-Id: <201808041426.w74EQSHd028096@slippy.cwsent.com> X-Authentication-Warning: slippy.cwsent.com: cy owned process doing -bs X-Mailer: exmh version 2.8.0 04/21/2012 with nmh-1.7.1 Reply-to: Cy Schubert From: Cy Schubert X-os: FreeBSD X-Sender: cy@cwsent.com X-URL: http://www.cschubert.com/ To: Warner Losh cc: Toomas Soome , Xin LI , Cy Schubert , src-committers , svn-src-all@freebsd.org, svn-src-head@freebsd.org, tsoome@freebsd.org Subject: Re: svn commit: r337271 - head/stand/i386/libi386 In-Reply-To: Message from Warner Losh of "Sat, 04 Aug 2018 12:11:34 +0100." Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Sat, 04 Aug 2018 07:26:28 -0700 X-CMAE-Envelope: MS4wfCXOyzuaLNyy0nDHS20Z6I7QZUbFvFVN6Er6i/SM2Or5MewQv6At9gDT6IOLxkUXWLF9eKNYpRDVD89N8DpblGFETFUfG0+nrX8o4AWrGvddXiwWNHdn AHEFnCMkvG6OfFsnfaJgu7PG+RB43zyieRUzQrEeHtN4r4e0biTklCnmHBttrLWeULJj6zix24xnn9GVJ/nEgobrcsQpDnOJwDoqqtDnRORTgTq2Nkfd7VM1 31OkRzbZW9FjtaVZ5ija3sgpHI0wE0OC5wSr84ot3lCwNPBXB8FLNphXCl4r0u3fUydFotZwoWs+hZ/kHYSiCQselKMqphAH0w8r26xnI04= X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 04 Aug 2018 14:26:40 -0000 In message , Warner Losh writes: > --00000000000017c64d05729a1cbf > Content-Type: text/plain; charset="UTF-8" > Content-Transfer-Encoding: quoted-printable > > On Sat, Aug 4, 2018, 11:58 AM Toomas Soome wrote: > > > > > > > > On 4 Aug 2018, at 11:54, Xin Li wrote: > > > > > > Hi, Cy, > > > > > > On 8/3/18 12:11, Cy Schubert wrote: > > >> Author: cy > > >> Date: Fri Aug 3 19:11:00 2018 > > >> New Revision: 337271 > > >> URL: https://svnweb.freebsd.org/changeset/base/337271 > > >> > > >> Log: > > >> Some drives report a geometry that is inconsisetent with the total > > >> number of sectors reported through the BIOS. Cylinders * heads * > > >> sectors may not necessarily be equal to the total number of sectors > > >> reported through int13h function 48h. > > >> > > >> An example of this is when a Mediasonic HD3-U2B PATA to USB enclosure > > >> with a 80 GB disk is attached. Loader hangs at line 506 of > > >> stand/i386/libi386/biosdisk.c while attempting to read sectors beyond > > >> the end of the disk, sector 156906855. I discovered that the Mediason= > ic > > >> enclosure was reporting the disk with 9767 cylinders, 255 heads, 63 > > >> sectors/track. That's 156906855 sectors. However camcontrol and > > >> Windows 10 both report report the disk having 156301488 sectors, not > > >> the calculated value. At line 280 biosdisk.c sets the sectors to the > > >> higher of either bd->bd_sectors or the total calculated at line 276 > > >> (156906855) instead of the lower and correct value of 156301488 > > reported > > >> by int 13h 48h. > > >> > > >> This was tested on all three of my Mediasonic HD3-U2B PATA to USB > > >> enclosures. > > >> > > >> Instead of using the higher of bd_sectors (returned by int13h) or the > > >> calculated value, this patch uses the lower and safer of the values. > > >> > > >> Reviewed by: tsoome@ > > >> Differential Revision: https://reviews.freebsd.org/D16577 > > >> > > >> Modified: > > >> head/stand/i386/libi386/biosdisk.c > > >> > > >> Modified: head/stand/i386/libi386/biosdisk.c > > >> > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= > =3D=3D=3D=3D > > >> --- head/stand/i386/libi386/biosdisk.c Fri Aug 3 18:52:51 2018 > > (r337270) > > >> +++ head/stand/i386/libi386/biosdisk.c Fri Aug 3 19:11:00 2018 > > (r337271) > > >> @@ -275,7 +275,7 @@ bd_int13probe(struct bdinfo *bd) > > >> > > >> total =3D (uint64_t)params.cylinders * > > >> params.heads * params.sectors_per_track; > > >> - if (bd->bd_sectors < total) > > >> + if (bd->bd_sectors > total) > > >> bd->bd_sectors =3D total; > > >> > > >> ret =3D 1; > > >> > > > > > > This broke loader on my system, but I think your reasoning was valid so > > > I took a deeper look and discovered that on my system, INT 13h, functio= > n > > > 48h would give zeros in EDD parameters' CHS fields. With that, the > > > calculated CHS based total would be 0, and your change would cause > > > bd_sectors be zeroed. > > > > > > Could you please let me know if https://reviews.freebsd.org/D16588 make= > s > > > sense to you? (I'm not 100% certain if I have followed the code). It > > > allowed my Asrock C2750D4I based board to boot from ZFS. > > > > > > > I have in mind something a bit different for some time, but haven=E2=80= > =99t had > > chance to complete it because I have no =E2=80=9Cweird=E2=80=9D systems t= > o validate the > > idea:D I=E2=80=99ll try to get a bit of time and post an phabricator soon= > . > > > > I think the phab looks good, but I am only on my phone so can't say so > there... > > Warner It looks good. The only case that hasn't been considered so far is if bd_sectors is arbitrarily low but not zero and the calculated value is the correct one. -- Cheers, Cy Schubert FreeBSD UNIX: Web: http://www.FreeBSD.org The need of the many outweighs the greed of the few.