From owner-svn-src-all@freebsd.org Sat Aug 4 11:11:46 2018 Return-Path: Delivered-To: svn-src-all@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 AE31A1066752 for ; Sat, 4 Aug 2018 11:11:46 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: from mail-io0-x243.google.com (mail-io0-x243.google.com [IPv6:2607:f8b0:4001:c06::243]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 32E7F700A5 for ; Sat, 4 Aug 2018 11:11:46 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: by mail-io0-x243.google.com with SMTP id z20-v6so7188185iol.0 for ; Sat, 04 Aug 2018 04:11:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=3z2HHJ5UnGqCaLWPIKLfdssqD6nFSRfG50+C16+kUIE=; b=YvCAF3SdX9dCjukanIo6w8tCr7DDnGo5JNYwn7i4vXHjBxuEWAKDuvSagjG1Fev9Wm 7BThI7JFaOgQTLy/QVgRETjgKcxUk3Xcau7iaG95ulf1Q2sgsybHQUDWNm6M9CUQG7rC igKrpBaYD1i4X6WewDG/ly92HyJuKrDgaRgMsboyRbA797cRkvRAqVqkxrs1SqIaxFmX q5W8ExY4UGmjfHJMxxUcLpwG9C6FaHbjelNYBefiJg/2qV66YU+ZLht7PEumy/hH0oo8 i5MfNCYFhrHcy4yNQpo89dYDoeKKPeadwMokewueL8Dh7gcZowlFpylr4hDLWuDJ4Nve vBhQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=3z2HHJ5UnGqCaLWPIKLfdssqD6nFSRfG50+C16+kUIE=; b=Vxo6FuEId6iI46OKo1vWo3e/f0tVctogJCm0u6Sjnke12n65MoVSq+m2ococdwsPP6 1LlRQ5sdCdWD4aLXSUdg5cwb0qGxRvQw9Ziq9QQYydXdza2kmfu/34AerNaBgVPIfW/P 1s5Kp/W9sqWxEHZrJgXIRXvhcg9NoltgoDamF4/KOen6a1hgLFQ4DnqwPJo1L1awl68v R4D6bdBWz66J8lK5tds9kiD3ABQcpTiYRgGc08v1oKb3lB7xhx9f+1u9UUbTohE2zp+q LwgDfy3GX7l4Rgl7ZNLEo5iJoBPnccfDG4rPCTR4t1uKxpcRHKCW2PtWdNt3KtIScPYo /WHg== X-Gm-Message-State: AOUpUlH4/NKtzAK5hg2Pojk4WzA4cyeuWVN4HbBuHYQ7X8fEmodu+uUg kumyNG1i7jacDS5uLaCu20eonFDkPLE1FTXebLL0n5lJaY4= X-Google-Smtp-Source: AA+uWPzvNeIiPrZnV8tMGj9ugQI7hH9GimAjL/0uS1+gKoVb8k/cHh5iT3s41cxId6R4fF6unSl02lkGl5FRNmID0Os= X-Received: by 2002:a6b:d004:: with SMTP id x4-v6mr8822133ioa.299.1533381105397; Sat, 04 Aug 2018 04:11:45 -0700 (PDT) MIME-Version: 1.0 References: <201808031911.w73JB0WK025164@repo.freebsd.org> <87cc3ae5-cbef-0d04-071e-cb7f7a410ce8@delphij.net> <7212F80A-9BA8-4D64-AB66-B8FA9F08409F@me.com> In-Reply-To: <7212F80A-9BA8-4D64-AB66-B8FA9F08409F@me.com> From: Warner Losh Date: Sat, 4 Aug 2018 12:11:34 +0100 Message-ID: Subject: Re: svn commit: r337271 - head/stand/i386/libi386 To: Toomas Soome Cc: Xin LI , Cy Schubert , src-committers , svn-src-all@freebsd.org, svn-src-head@freebsd.org, tsoome@freebsd.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.27 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 04 Aug 2018 11:11:46 -0000 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 >