From owner-svn-src-stable@FreeBSD.ORG Tue Feb 24 22:11:08 2015 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 2C373816; Tue, 24 Feb 2015 22:11:08 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::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 1207E131; Tue, 24 Feb 2015 22:11:08 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t1OMB7EP064821; Tue, 24 Feb 2015 22:11:07 GMT (envelope-from emaste@FreeBSD.org) Received: (from emaste@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t1OMB7nk064820; Tue, 24 Feb 2015 22:11:07 GMT (envelope-from emaste@FreeBSD.org) Message-Id: <201502242211.t1OMB7nk064820@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: emaste set sender to emaste@FreeBSD.org using -f From: Ed Maste Date: Tue, 24 Feb 2015 22:11:07 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r279254 - stable/10/sys/boot/amd64/boot1.efi X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Feb 2015 22:11:08 -0000 Author: emaste Date: Tue Feb 24 22:11:07 2015 New Revision: 279254 URL: https://svnweb.freebsd.org/changeset/base/279254 Log: MFC part of r273865: fix boot1.efi for block size != 512 r273865 is part of the work for supporting 4Kn drives, but it turns out the underlying bug can actually cause corruption of the UEFI system table in any case where block size is not 512. Relevant portion of the original commit message: convert boot1.efi to corrrectly calculate the lba for what the media reports and convert the size based on what FreeBSD uses. existing code would use the 512 byte lba and convert the using 4K byte size. PR: 197881 Reviewed by: Chris Ruffin Modified: stable/10/sys/boot/amd64/boot1.efi/boot1.c Modified: stable/10/sys/boot/amd64/boot1.efi/boot1.c ============================================================================== --- stable/10/sys/boot/amd64/boot1.efi/boot1.c Tue Feb 24 22:07:42 2015 (r279253) +++ stable/10/sys/boot/amd64/boot1.efi/boot1.c Tue Feb 24 22:11:07 2015 (r279254) @@ -168,9 +168,12 @@ static int dskread(void *buf, u_int64_t lba, int nblk) { EFI_STATUS status; + int size; + lba = lba / (bootdev->Media->BlockSize / DEV_BSIZE); + size = nblk * DEV_BSIZE; status = bootdev->ReadBlocks(bootdev, bootdev->Media->MediaId, lba, - nblk * bootdev->Media->BlockSize, buf); + size, buf); if (EFI_ERROR(status)) return (-1);