mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] partitions: efi: Fix position of alternate gpt when writing
@ 2025-02-11  9:34 Sascha Hauer
  0 siblings, 0 replies; only message in thread
From: Sascha Hauer @ 2025-02-11  9:34 UTC (permalink / raw)
  To: Barebox List

The primary GPT has a pointer to the alternate GPT. Set this pointer
correctly when writing the partition table.

When the GPT originally has been created on the device, the alternate GPT
should be at the end of the device already. However, when the GPT was
created on an image which was then written to the disk, the alternate GPT
might be at the end of the image instead of the device. In this case
the alternate GPT changes its position during a partition write, so we
have to adjust the pointer from the primary to the alternate GPT
accordingly.

Reported-by: Ulrich Ölmann <u.oelmann@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 common/partitions/efi.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/common/partitions/efi.c b/common/partitions/efi.c
index 6caa391983..5736b6033b 100644
--- a/common/partitions/efi.c
+++ b/common/partitions/efi.c
@@ -758,6 +758,7 @@ static __maybe_unused int efi_partition_write(struct partition_desc *pd)
 		le32_to_cpu(gpt->sizeof_partition_entry);
 
 	gpt->my_lba = cpu_to_le64(1);
+	gpt->alternate_lba = cpu_to_le64(last_lba(blk));
 	gpt->partition_entry_array_crc32 = cpu_to_le32(efi_crc32(
 			(const unsigned char *)epd->ptes, count));
 	gpt->header_crc32 = 0;
-- 
2.39.5




^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2025-02-11  9:36 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-02-11  9:34 [PATCH] partitions: efi: Fix position of alternate gpt when writing Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox