From owner-freebsd-hackers@FreeBSD.ORG Fri Jan 28 19:14:46 2011 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id AF1B41065673; Fri, 28 Jan 2011 19:14:46 +0000 (UTC) (envelope-from mdf356@gmail.com) Received: from mail-wy0-f182.google.com (mail-wy0-f182.google.com [74.125.82.182]) by mx1.freebsd.org (Postfix) with ESMTP id 1FA078FC08; Fri, 28 Jan 2011 19:14:45 +0000 (UTC) Received: by wyf19 with SMTP id 19so3621135wyf.13 for ; Fri, 28 Jan 2011 11:14:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=/Vo9PlTDqO3Jkz77D3ajECRZ7TNjSBUPf46R+P5ZtV0=; b=oxhn4E7O7RqF+hF93m0wCOz7kAsGUekZ9H7MVut9/Xc9zsFWksHmISFpjghNT2Lsk9 A5Y2g13vK3aqfDCdTFRk5gRtrqTWrxUp0oykHaQnyCq8dlzBhbcyvGUs9bD0r1tCSPBh vq7cHFq4Y7PUrxquPsKIDEbCOJbyV0OZmwoaM= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=dOyjLogE06M0Hmm8012PvqRzIIxgGJaJcNphrnjSsGhSAaSM9Ojaf50E35uQ+BKdIj PXcPwqSson5612E1KJKKY3q2G9EG0XljBfAysYJfZXnE44qbjdIO63gAtHYPFOAHiUDh bc9sO8KpSf63wwTjC4VwYAdq/JWQczNk9qyOI= MIME-Version: 1.0 Received: by 10.216.153.147 with SMTP id f19mr8238796wek.40.1296242085080; Fri, 28 Jan 2011 11:14:45 -0800 (PST) Received: by 10.216.62.203 with HTTP; Fri, 28 Jan 2011 11:14:45 -0800 (PST) In-Reply-To: <201101281400.01840.jhb@freebsd.org> References: <201101281400.01840.jhb@freebsd.org> Date: Fri, 28 Jan 2011 11:14:45 -0800 Message-ID: From: Matthew Fleming To: John Baldwin Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: freebsd-hackers@freebsd.org Subject: Re: Divide-by-zero in loader X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 28 Jan 2011 19:14:46 -0000 On Fri, Jan 28, 2011 at 11:00 AM, John Baldwin wrote: > On Friday, January 28, 2011 12:41:08 pm Matthew Fleming wrote: >> I spent a few days chasing down a bug and I'm wondering if a loader >> change would be appropriate. >> >> So we have these new front-panel LCDs, and like everything these days >> it's a SoC. =A0Normally it presents to FreeBSD as a USB communications >> device (ucom), but when the SoC is sitting in its own boot loader, it >> presents as storage (umass). =A0If the box is rebooted in this state, >> the reboot gets into /boot/loader and then reboots itself. =A0(It took a >> few days just to figure out I was getting into /boot/loader, since the >> only prompt I could definitively stop at was boot2). >> >> Anyways, I eventually debugged it to the device somehow presenting >> itself to /boot/loader with a geometry of 1024/256/0, and since od_sec >> is 0 that causes a divide-by-zero error in bd_io() while the loader is >> trying to figure out if this is GPT or MBR formatted. =A0We're still >> trying to figure out why the loader sees this incorrect geometry. >> >> But meanwhile, this patch fixes the issue, and I wonder if it would be >> a useful safety-belt for other devices where an incorrect geometry can >> be seen? > > That's probably fine. =A0A sector count of zero is invalid for CHS. =A0Ho= wever, > probably we should not even be using C/H/S at all if the device claims to > support EDD. =A0We already use raw LBAs if it supports EDD, and we should > probably just ignore C/H/S altogether if it supports EDD. This is all almost entirely outside my knowledge, but at the moment bd_eddprobe() requres a geometry of 1023/255/63 before it attempts to check if EDD can be used. Is that check incorrect? In my specific case I know there's no bootable stuff on this disk; the earlier layers bypassed it correctly without a problem. Thanks, matthew