From owner-svn-src-head@FreeBSD.ORG Thu Oct 30 23:12:56 2014 Return-Path: Delivered-To: svn-src-head@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 025D75C8; Thu, 30 Oct 2014 23:12:56 +0000 (UTC) Received: from mail.ambrisko.com (mail.ambrisko.com [70.91.206.90]) by mx1.freebsd.org (Postfix) with ESMTP id B73FCB5; Thu, 30 Oct 2014 23:12:55 +0000 (UTC) X-Ambrisko-Me: Yes Received: from server2.ambrisko.com (HELO internal.ambrisko.com) ([192.168.1.2]) by ironport.ambrisko.com with ESMTP; 30 Oct 2014 16:16:32 -0700 Received: from ambrisko.com (localhost [127.0.0.1]) by internal.ambrisko.com (8.14.4/8.14.4) with ESMTP id s9UNCrpG051590; Thu, 30 Oct 2014 16:12:53 -0700 (PDT) (envelope-from ambrisko@ambrisko.com) Received: (from ambrisko@localhost) by ambrisko.com (8.14.4/8.14.4/Submit) id s9UNCrW1051589; Thu, 30 Oct 2014 16:12:53 -0700 (PDT) (envelope-from ambrisko) Date: Thu, 30 Oct 2014 16:12:53 -0700 From: Doug Ambrisko To: Nathan Whitehorn Subject: Re: svn commit: r273865 - in head: sbin/fsck_msdosfs sys/boot/amd64/boot1.efi Message-ID: <20141030231253.GA50728@ambrisko.com> References: <201410301552.s9UFq1WV098951@svn.freebsd.org> <5452B940.1090609@freebsd.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5452B940.1090609@freebsd.org> User-Agent: Mutt/1.4.2.3i Cc: svn-src-head@freebsd.org, Doug Ambrisko , svn-src-all@freebsd.org, src-committers@freebsd.org X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.18-1 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, 30 Oct 2014 23:12:56 -0000 On Thu, Oct 30, 2014 at 03:18:40PM -0700, Nathan Whitehorn wrote: | You may want to change the generation of boot1.efifat to have a 4096 | byte sector size. We also need to find out if all EFI BIOSes can deal | with 4096-byte FAT filesystems on 512-byte disks. Yes, there is more work in general to make this fully working. Atleast this give people a starting point. It looks like we should be able to test this with Qemu since it takes a physical sector size as an argument. Hopefully makefs can learn to do FAT32 and avoid these issues. Bruce's comments are good and I'll take a look his suggested changes. Right now I'm trying to figure out why UEFI PXE is hanging after the first file is looked up on some machines. Thanks, Doug A. | On 10/30/14 08:52, Doug Ambrisko wrote: | >Author: ambrisko | >Date: Thu Oct 30 15:52:01 2014 | >New Revision: 273865 | >URL: https://svnweb.freebsd.org/changeset/base/273865 | > | >Log: | > Make UEFI booting of 4Kn disks work: | > - convert boot1.efi to corrrectly calculate the lba for what | > the | > media reports and convert the size based on what FreeBSD uses. | > The existing code would use the 512 byte lba and convert the | > size using 4K byte size. | > - make fsck_msdosfs read the boot block as 4K so the read | > doesn't | > fail on a 4Kn drive since FreeBSD will error out parition reads | > of a block. Make the bpbBytesPerSec check a multiple of 512 since | > it can be 512 or 4K depending on the disk. This allows fsck to | > pass checking the EFI partition on a 4Kn disk. | > | > To create the EFI file system I used: | > newfs_msdos -F 32 -S 4096 -c 1 -m 0xf8 | > This works for booting 512 and 4Kn disks. | > | > Caveat is that loader.efi cannot read the 4Kn EFI partition. This isn't | > critical right now since boot1.efi will read loader.efi from the ufs | > partition. It looks like loader.efi can be fixed via making some of the | > 512 bytes reads more flexible. loader.efi doesn't have trouble reading | > the ufs partition. This is probably a simple fix. | > | > I now have FreeBSD installed on a system with 4Kn drives and tested the | > same code works on 512. | > | > MFC after: 1 week | > | >Modified: | > head/sbin/fsck_msdosfs/boot.c | > head/sbin/fsck_msdosfs/dosfs.h | > head/sys/boot/amd64/boot1.efi/boot1.c | > | >Modified: head/sbin/fsck_msdosfs/boot.c | >============================================================================== | >--- head/sbin/fsck_msdosfs/boot.c Thu Oct 30 15:41:25 2014 (r273864) | >+++ head/sbin/fsck_msdosfs/boot.c Thu Oct 30 15:52:01 2014 (r273865) | >@@ -181,7 +181,7 @@ readboot(int dosfs, struct bootblock *bo | > boot->bpbResSectors + boot->bpbFATs * boot->FATsecs - | > CLUST_FIRST * boot->bpbSecPerClust; | > | >- if (boot->bpbBytesPerSec % DOSBOOTBLOCKSIZE != 0) { | >+ if (boot->bpbBytesPerSec % DOSBOOTBLOCKSIZE_REAL != 0) { | > pfatal("Invalid sector size: %u", boot->bpbBytesPerSec); | > return FSFATAL; | > } | > | >Modified: head/sbin/fsck_msdosfs/dosfs.h | >============================================================================== | >--- head/sbin/fsck_msdosfs/dosfs.h Thu Oct 30 15:41:25 2014 (r273864) | >+++ head/sbin/fsck_msdosfs/dosfs.h Thu Oct 30 15:52:01 2014 (r273865) | >@@ -30,7 +30,9 @@ | > #ifndef DOSFS_H | > #define DOSFS_H | > | >-#define DOSBOOTBLOCKSIZE 512 | >+/* support 4Kn disk reads */ | >+#define DOSBOOTBLOCKSIZE_REAL 512 | >+#define DOSBOOTBLOCKSIZE 4096 | > | > typedef u_int32_t cl_t; /* type holding a cluster number */ | > | > | >Modified: head/sys/boot/amd64/boot1.efi/boot1.c | >============================================================================== | >--- head/sys/boot/amd64/boot1.efi/boot1.c Thu Oct 30 15:41:25 2014 | >(r273864) | >+++ head/sys/boot/amd64/boot1.efi/boot1.c Thu Oct 30 15:52:01 2014 | >(r273865) | >@@ -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); | >