From owner-svn-src-head@freebsd.org Thu Sep 1 06:35:14 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 8F524BCD4BA; Thu, 1 Sep 2016 06:35:14 +0000 (UTC) (envelope-from tsoome@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 485FA19A; Thu, 1 Sep 2016 06:35:14 +0000 (UTC) (envelope-from tsoome@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u816ZD82025341; Thu, 1 Sep 2016 06:35:13 GMT (envelope-from tsoome@FreeBSD.org) Received: (from tsoome@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u816ZDlc025340; Thu, 1 Sep 2016 06:35:13 GMT (envelope-from tsoome@FreeBSD.org) Message-Id: <201609010635.u816ZDlc025340@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: tsoome set sender to tsoome@FreeBSD.org using -f From: Toomas Soome Date: Thu, 1 Sep 2016 06:35:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r305178 - head/sys/boot/i386/libi386 X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.22 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: Thu, 01 Sep 2016 06:35:14 -0000 Author: tsoome Date: Thu Sep 1 06:35:13 2016 New Revision: 305178 URL: https://svnweb.freebsd.org/changeset/base/305178 Log: bd_int13probe() should check extended info if sector info is bad In some Dell systems and usb stick combinations, it is found that int13 AH=08 is reporting back bad sector information, preventing the boot. This update is allowing bd_int13probe() to use extended info call to build disk properties. It also can happen the total sectors count from extended info may be wrong, in such case, the CHS data is used to calculate total sectors. Reviewed by: allanjude Approved by: allanjude (mentor) Differential Revision: https://reviews.freebsd.org/D7718 Modified: head/sys/boot/i386/libi386/biosdisk.c Modified: head/sys/boot/i386/libi386/biosdisk.c ============================================================================== --- head/sys/boot/i386/libi386/biosdisk.c Thu Sep 1 06:32:35 2016 (r305177) +++ head/sys/boot/i386/libi386/biosdisk.c Thu Sep 1 06:35:13 2016 (r305178) @@ -244,6 +244,7 @@ static int bd_int13probe(struct bdinfo *bd) { struct edd_params params; + int ret = 1; /* assume success */ v86.ctl = V86_FLAGS; v86.addr = 0x13; @@ -251,11 +252,14 @@ bd_int13probe(struct bdinfo *bd) v86.edx = bd->bd_unit; v86int(); + /* Don't error out if we get bad sector number, try EDD as well */ if (V86_CY(v86.efl) || /* carry set */ - (v86.ecx & 0x3f) == 0 || /* absurd sector number */ (v86.edx & 0xff) <= (unsigned)(bd->bd_unit & 0x7f)) /* unit # bad */ return (0); /* skip device */ + if ((v86.ecx & 0x3f) == 0) /* absurd sector number */ + ret = 0; /* set error */ + /* Convert max cyl # -> # of cylinders */ bd->bd_cyl = ((v86.ecx & 0xc0) << 2) + ((v86.ecx & 0xff00) >> 8) + 1; /* Convert max head # -> # of heads */ @@ -280,7 +284,8 @@ bd_int13probe(struct bdinfo *bd) if (V86_CY(v86.efl) || /* carry set */ (v86.ebx & 0xffff) != 0xaa55 || /* signature */ (v86.ecx & EDD_INTERFACE_FIXED_DISK) == 0) - return (1); + return (ret); /* return code from int13 AH=08 */ + /* EDD supported */ bd->bd_flags |= BD_MODEEDD1; if ((v86.eax & 0xff00) >= 0x3000) @@ -295,12 +300,22 @@ bd_int13probe(struct bdinfo *bd) v86.esi = VTOPOFF(¶ms); v86int(); if (!V86_CY(v86.efl)) { - bd->bd_sectors = params.sectors; + uint64_t total; + + if (params.sectors != 0) + bd->bd_sectors = params.sectors; + + total = (uint64_t)params.cylinders * + params.heads * params.sectors_per_track; + if (bd->bd_sectors < total) + bd->bd_sectors = total; + bd->bd_sectorsize = params.sector_size; + ret = 1; } DEBUG("unit 0x%x flags %x, sectors %llu, sectorsize %u", bd->bd_unit, bd->bd_flags, bd->bd_sectors, bd->bd_sectorsize); - return (1); + return (ret); } /*