From mboxrd@z Thu Jan 1 00:00:00 1970 From: Heinrich Schuchardt Date: Tue, 9 Mar 2021 18:15:43 +0100 Subject: [PATCH] disk: gpt: verify alternate LBA points to last usable LBA In-Reply-To: References: <20210308160712.75779-1-stefan.herbrechtsmeier-oss@weidmueller.com> Message-ID: <6bf8b5e2-d2eb-0e5d-88bf-b090eda3b63d@gmx.de> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On 09.03.21 17:24, Stefan Herbrechtsmeier wrote: > Hi Heinrich, > > Am 08.03.2021 um 18:38 schrieb Heinrich Schuchardt: >> On 08.03.21 17:07, Stefan Herbrechtsmeier wrote: >>> From: Stefan Herbrechtsmeier >>> >>> The gpt command require the GPT backup header at the standard location >>> at the end of the device.Check the alternate LBA value before reading >>> the GPT backup header from the last usable LBA of the device. >> >> If there is a bug in the gpt command, please, fix it instead of >> introducing constraints that don't exist in the UEFI specification. >> >> The UEFI specification has: >> >> "The backup GPT Partition Entry Array must be located after the Last >> Usable LBA and end before the backup GPT Header." > > "If the primary GPT is invalid, the backup GPT is used instead and it is > located on the last logical block on the disk." [UEFI specification 2.8, > S. 120] Thank you for pointing me to this sentence which I missed. Reviewed-by: Heinrich Schuchardt > > "Note that UEFI standard requires the backup header at the end of the > device and partitioning tools can automatically relocate the header to > follow the standard." [sfdisk man page, --relocate, gpt-bak-mini] > > What should U-Boot do? I have a patch to use the backup GPT header if > only the header itself is valid but I don't know if this behavior is > correct. > > Regards, > ? Stefan