Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 4 Aug 2018 01:54:22 -0700
From:      Xin Li <delphij@delphij.net>
To:        Cy Schubert <cy@FreeBSD.org>, src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org, tsoome@freebsd.org
Subject:   Re: svn commit: r337271 - head/stand/i386/libi386
Message-ID:  <87cc3ae5-cbef-0d04-071e-cb7f7a410ce8@delphij.net>
In-Reply-To: <201808031911.w73JB0WK025164@repo.freebsd.org>
References:  <201808031911.w73JB0WK025164@repo.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
This is an OpenPGP/MIME signed message (RFC 4880 and 3156)
--sLvrY7cl1RRdAnsYccFihl14kpNsTv5Fa
Content-Type: multipart/mixed; boundary="ZGRV3EdwnFbod01qzj7SedSQINKX01EmT";
 protected-headers="v1"
From: Xin Li <delphij@delphij.net>
Reply-To: d@delphij.net
To: Cy Schubert <cy@FreeBSD.org>, src-committers@freebsd.org,
 svn-src-all@freebsd.org, svn-src-head@freebsd.org, tsoome@freebsd.org
Message-ID: <87cc3ae5-cbef-0d04-071e-cb7f7a410ce8@delphij.net>
Subject: Re: svn commit: r337271 - head/stand/i386/libi386
References: <201808031911.w73JB0WK025164@repo.freebsd.org>
In-Reply-To: <201808031911.w73JB0WK025164@repo.freebsd.org>

--ZGRV3EdwnFbod01qzj7SedSQINKX01EmT
Content-Type: text/plain; charset=utf-8
Content-Language: en-US
Content-Transfer-Encoding: quoted-printable

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
>=20
> 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.
>  =20
>   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 repor=
ted
>   by int 13h 48h.
>  =20
>   This was tested on all three of my Mediasonic HD3-U2B PATA to USB
>   enclosures.
>  =20
>   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.
>  =20
>   Reviewed by:	tsoome@
>   Differential Revision:	https://reviews.freebsd.org/D16577
>=20
> Modified:
>   head/stand/i386/libi386/biosdisk.c
>=20
> 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	(r33727=
0)
> +++ head/stand/i386/libi386/biosdisk.c	Fri Aug  3 19:11:00 2018	(r33727=
1)
> @@ -275,7 +275,7 @@ bd_int13probe(struct bdinfo *bd)
> =20
>  		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;
> =20
>  		ret =3D 1;
>=20

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, function
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 makes
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.

Cheers,


--ZGRV3EdwnFbod01qzj7SedSQINKX01EmT--

--sLvrY7cl1RRdAnsYccFihl14kpNsTv5Fa
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: OpenPGP digital signature
Content-Disposition: attachment; filename="signature.asc"

-----BEGIN PGP SIGNATURE-----

iQIcBAEBCgAGBQJbZWnAAAoJEJW2GBstM+nstZkQAImlL2dAeCmOkNZ903AKK1pa
YuDbZowlg3P+GC3OtWjHVzf4YDbWY1JQUS0IGqfmOUIAX/2J/MaQGZl9hk2kbc9p
6aJtt6a3H7PVVX8qyzi27eNrwUpZhaI4DA7aXE3i3ZeeUtHvlN0L1xOqT9x8vpcH
qAn7XHFaR841PvhgGoySx/T6EGKIRHy9la8+6TVoIyZJbJ7QTVg6jgxA0swa3Kow
ZWCj0ANQEG2beNHdUmqZqSGaVLPtGW9AGxLkxGc79a0WfYgk0BJkH40OVnucx+3v
M9sFN0RBCsQVzIuwIEkq1PFbLLR3k61jqSGO9ctj3+1AxvXgQnpM/QPF+Mse51HE
0xN/EMw/ZI7xZySaycX+alpSxMWEXA5TBDBJ9UsnNhLt6J/E1LrNXKDTyjE2jNyw
JMLNVpq1Lwm3wa6RrWrRVL//7GNphrksy3IHBHq+LtVa//BNrO/EfRIn+4SijbFn
k9WFgXXouUvEl1zBH3DYzCYH08YdIjo1PjhZTSAdaJn8DT/VsFnOuuYDUgNEE11K
fc69d+xG2AhhfQL1AYjKFcMfKQEuf+J9csbP3HjZfeltsiTLAuAcZq0A9dK/hTjW
yd55Pm+3xqOALh6+OR4s47PlxPFWn5pFlKiSxJPhIwDgLmxmrA4Ao0as7/VjF+pD
DLlqJzgYRP41sfPEXM6j
=6FnU
-----END PGP SIGNATURE-----

--sLvrY7cl1RRdAnsYccFihl14kpNsTv5Fa--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?87cc3ae5-cbef-0d04-071e-cb7f7a410ce8>