Skip to contentSkip to conversation

disk: part_efi: add support for the Alternate GPT

PATCH New Steve Rae 3 participants 8 messages Apr 29, 2014 – May 5, 2014

lore
Share & tools
lore

Steve Rae

author
#0 lore raw

PATCH 1/1 disk: part_efi: add support for the Alternate GPT

Check the Alternate GPT table if the Primary GPT table is invalid.

---

 disk/part_efi.c | 20 ++++++++++++++++++--
 1 file changed, 18 insertions(+), 2 deletions(-)
disk/part_efi.c +18 -2
index 216a292..ad899fa 100644
@@ -93,7 +93,15 @@ void print_part_efi(block_dev_desc_t * dev_desc)
 	if (is_gpt_valid(dev_desc, GPT_PRIMARY_PARTITION_TABLE_LBA,
 			 gpt_head, &gpt_pte) != 1) {
 		printf("%s: *** ERROR: Invalid GPT ***\n", __func__);
-		return;
+		if (is_gpt_valid(dev_desc, (dev_desc->lba - 1),
+				 gpt_head, &gpt_pte) != 1) {
+			printf("%s: *** ERROR: Invalid Alternate GPT ***\n",
+			       __func__);
+			return;
+		} else {
+			printf("%s: ***        Using Alternate GPT ***\n",
+			       __func__);
+		}
 	}
 
 	debug("%s: gpt-entry at %p\n", __func__, gpt_pte);
@@ -142,7 +150,15 @@ int get_partition_info_efi(block_dev_desc_t * dev_desc, int part,
 	if (is_gpt_valid(dev_desc, GPT_PRIMARY_PARTITION_TABLE_LBA,
 			gpt_head, &gpt_pte) != 1) {
 		printf("%s: *** ERROR: Invalid GPT ***\n", __func__);
-		return -1;
+		if (is_gpt_valid(dev_desc, (dev_desc->lba - 1),
+				 gpt_head, &gpt_pte) != 1) {
+			printf("%s: *** ERROR: Invalid Alternate GPT ***\n",
+			       __func__);
+			return -1;
+		} else {
+			printf("%s: ***        Using Alternate GPT ***\n",
+			       __func__);
+		}
 	}
 
 	if (part > le32_to_cpu(gpt_head->num_partition_entries) ||
Signature · 1 line
1.8.5
#1 lore raw

PATCH 1/1 disk: part_efi: add support for the Alternate GPT

Hello Steve,

Quoted 37 lines · Steve Rae

Check the Alternate GPT table if the Primary GPT table is invalid.

---

  disk/part_efi.c | 20 ++++++++++++++++++--
  1 file changed, 18 insertions(+), 2 deletions(-)
disk/part_efi.c +11 -2
index 216a292..ad899fa 100644
@@ -93,7 +93,15 @@ void print_part_efi(block_dev_desc_t * dev_desc)
  	if (is_gpt_valid(dev_desc, GPT_PRIMARY_PARTITION_TABLE_LBA,
  			 gpt_head, &gpt_pte) != 1) {
  		printf("%s: *** ERROR: Invalid GPT ***\n", __func__);
-		return;
+		if (is_gpt_valid(dev_desc, (dev_desc->lba - 1),
+				 gpt_head, &gpt_pte) != 1) {
+			printf("%s: *** ERROR: Invalid Alternate GPT ***\n",
+			       __func__);
+			return;
+		} else {
+			printf("%s: ***        Using Alternate GPT ***\n",
+			       __func__);
+		}
  	}
 
  	debug("%s: gpt-entry at %p\n", __func__, gpt_pte);
@@ -142,7 +150,15 @@ int get_partition_info_efi(block_dev_desc_t * dev_desc, int part,
  	if (is_gpt_valid(dev_desc, GPT_PRIMARY_PARTITION_TABLE_LBA,
  			gpt_head, &gpt_pte) != 1) {
  		printf("%s: *** ERROR: Invalid GPT ***\n", __func__);
-		return -1;
+		if (is_gpt_valid(dev_desc, (dev_desc->lba - 1),
+				 gpt_head, &gpt_pte) != 1) {

disk/part_efi.c int get_partition_info_efi(block_dev_desc_t * dev_desc, int part, · line 164

Quoted 10 lines
disk/part_efi.c +7 -0
+			printf("%s: *** ERROR: Invalid Alternate GPT ***\n",
+			       __func__);
+			return -1;
+		} else {
+			printf("%s: ***        Using Alternate GPT ***\n",
+			       __func__);
+		}
  	}
 
  	if (part > le32_to_cpu(gpt_head->num_partition_entries) ||

This looks ok, we can still use u-boot filesystem commands after gpt header block corruption, but the gpt is still...corrupted.

Maybe we need additional gpt subcommand for restore gpt in case when backup of gpt header is valid?

Actually we have only "gpt write" command but it needs proper environment variables. So I think that "gpt restore" is welcome.

Thank you,

Signature · 4 lines
Przemyslaw Marczak
Samsung R&D Institute Poland
Samsung Electronics
p.marczak at samsung.com
author
#2 lore raw

PATCH 1/1 disk: part_efi: add support for the Alternate GPT

Quoted 55 lines · Przemyslaw Marczak

Hello Steve,

Quoted 46 lines · Steve Rae

Check the Alternate GPT table if the Primary GPT table is invalid.

---

  disk/part_efi.c | 20 ++++++++++++++++++--
  1 file changed, 18 insertions(+), 2 deletions(-)
disk/part_efi.c +18 -2
index 216a292..ad899fa 100644
@@ -93,7 +93,15 @@ void print_part_efi(block_dev_desc_t * dev_desc)
      if (is_gpt_valid(dev_desc, GPT_PRIMARY_PARTITION_TABLE_LBA,
               gpt_head, &gpt_pte) != 1) {
          printf("%s: *** ERROR: Invalid GPT ***\n", __func__);
-        return;
+        if (is_gpt_valid(dev_desc, (dev_desc->lba - 1),
+                 gpt_head, &gpt_pte) != 1) {
+            printf("%s: *** ERROR: Invalid Alternate GPT ***\n",
+                   __func__);
+            return;
+        } else {
+            printf("%s: ***        Using Alternate GPT ***\n",
+                   __func__);
+        }
      }
 
      debug("%s: gpt-entry at %p\n", __func__, gpt_pte);
@@ -142,7 +150,15 @@ int get_partition_info_efi(block_dev_desc_t * 
 dev_desc, int part,
      if (is_gpt_valid(dev_desc, GPT_PRIMARY_PARTITION_TABLE_LBA,
              gpt_head, &gpt_pte) != 1) {
          printf("%s: *** ERROR: Invalid GPT ***\n", __func__);
-        return -1;
+        if (is_gpt_valid(dev_desc, (dev_desc->lba - 1),
+                 gpt_head, &gpt_pte) != 1) {
+            printf("%s: *** ERROR: Invalid Alternate GPT ***\n",
+                   __func__);
+            return -1;
+        } else {
+            printf("%s: ***        Using Alternate GPT ***\n",
+                   __func__);
+        }
      }
 
Quoted 2 lines
      if (part > le32_to_cpu(gpt_head->num_partition_entries) ||

This looks ok, we can still use u-boot filesystem commands after gpt header block corruption, but the gpt is still...corrupted.

Quoted 7 lines

Maybe we need additional gpt subcommand for restore gpt in case when backup of gpt header is valid?

Actually we have only "gpt write" command but it needs proper environment variables. So I think that "gpt restore" is welcome.

Thank you,

Agree -- maybe I can find time to work on a "gpt restore" in the near future....
Thanks, Steve

author
#3 lore raw

PATCH 1/1 disk: part_efi: add support for the Alternate GPT

Hmmm - perhaps "Secondary" would be more accurate wording than "Alternate" (v2 coming...)

Quoted 73 lines · Steve Rae
Quoted 55 lines · Przemyslaw Marczak

Hello Steve,

Quoted 46 lines · Steve Rae

Check the Alternate GPT table if the Primary GPT table is invalid.

---

  disk/part_efi.c | 20 ++++++++++++++++++--
  1 file changed, 18 insertions(+), 2 deletions(-)
disk/part_efi.c +18 -2
index 216a292..ad899fa 100644
@@ -93,7 +93,15 @@ void print_part_efi(block_dev_desc_t * dev_desc)
      if (is_gpt_valid(dev_desc, GPT_PRIMARY_PARTITION_TABLE_LBA,
               gpt_head, &gpt_pte) != 1) {
          printf("%s: *** ERROR: Invalid GPT ***\n", __func__);
-        return;
+        if (is_gpt_valid(dev_desc, (dev_desc->lba - 1),
+                 gpt_head, &gpt_pte) != 1) {
+            printf("%s: *** ERROR: Invalid Alternate GPT ***\n",
+                   __func__);
+            return;
+        } else {
+            printf("%s: ***        Using Alternate GPT ***\n",
+                   __func__);
+        }
      }
 
      debug("%s: gpt-entry at %p\n", __func__, gpt_pte);
@@ -142,7 +150,15 @@ int get_partition_info_efi(block_dev_desc_t * 
 dev_desc, int part,
      if (is_gpt_valid(dev_desc, GPT_PRIMARY_PARTITION_TABLE_LBA,
              gpt_head, &gpt_pte) != 1) {
          printf("%s: *** ERROR: Invalid GPT ***\n", __func__);
-        return -1;
+        if (is_gpt_valid(dev_desc, (dev_desc->lba - 1),
+                 gpt_head, &gpt_pte) != 1) {
+            printf("%s: *** ERROR: Invalid Alternate GPT ***\n",
+                   __func__);
+            return -1;
+        } else {
+            printf("%s: ***        Using Alternate GPT ***\n",
+                   __func__);
+        }
      }
 
Quoted 2 lines
      if (part > le32_to_cpu(gpt_head->num_partition_entries) ||

This looks ok, we can still use u-boot filesystem commands after gpt header block corruption, but the gpt is still...corrupted.

Quoted 7 lines

Maybe we need additional gpt subcommand for restore gpt in case when backup of gpt header is valid?

Actually we have only "gpt write" command but it needs proper environment variables. So I think that "gpt restore" is welcome.

Thank you,

Agree -- maybe I can find time to work on a "gpt restore" in the near future....
Thanks, Steve
_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

#4 lore raw

PATCH 1/1 disk: part_efi: add support for the Alternate GPT

Quoted 2 lines · Steve Rae

Hmmm - perhaps "Secondary" would be more accurate wording than "Alternate" (v2 coming...)

Is there any "official" name for this in the GPT spec?

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20140505/47f33830/attachment.pgp>
author
#5 lore raw

PATCH 1/1 disk: part_efi: add support for the Alternate GPT

Quoted 6 lines · Tom Rini
Quoted 2 lines · Steve Rae

Hmmm - perhaps "Secondary" would be more accurate wording than "Alternate" (v2 coming...)

Is there any "official" name for this in the GPT spec?

I proposed "Secondary" because it matched "doc/README.gpt"; and it is often called "secondary GPT" (for example:
http://en.wikipedia.org/wiki/GUID_Partition_Table)
However, the UEFI Specifaction (Version 2.3.1, Errata A) calls it "backup GPT" 18 times, and "alternate GPT" once (and never calls it "secondary GPT")....

#6 lore raw

PATCH 1/1 disk: part_efi: add support for the Alternate GPT

Quoted 6 lines · Steve Rae
Quoted 4 lines · Tom Rini
Quoted 2 lines · Steve Rae

Hmmm - perhaps "Secondary" would be more accurate wording than "Alternate" (v2 coming...)

Quoted 8 lines
Quoted 2 lines

Is there any "official" name for this in the GPT spec?

I proposed "Secondary" because it matched "doc/README.gpt"; and it is often called "secondary GPT" (for example:
http://en.wikipedia.org/wiki/GUID_Partition_Table)
However, the UEFI Specifaction (Version 2.3.1, Errata A) calls it "backup GPT" 18 times, and "alternate GPT" once (and never calls it "secondary GPT")....

I would go with backup GPT and update the README.gpt too please.

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20140505/95ca13eb/attachment.pgp>
author
#7 lore raw

PATCH 1/1 disk: part_efi: add support for the Alternate GPT

Quoted 8 lines · Tom Rini
Quoted 7 lines · Steve Rae
Quoted 6 lines · Tom Rini
Quoted 2 lines · Steve Rae

Hmmm - perhaps "Secondary" would be more accurate wording than "Alternate" (v2 coming...)

Is there any "official" name for this in the GPT spec?

Quoted 8 lines
Quoted 6 lines

I proposed "Secondary" because it matched "doc/README.gpt"; and it is often called "secondary GPT" (for example:
http://en.wikipedia.org/wiki/GUID_Partition_Table)
However, the UEFI Specifaction (Version 2.3.1, Errata A) calls it "backup GPT" 18 times, and "alternate GPT" once (and never calls it "secondary GPT")....

I would go with backup GPT and update the README.gpt too please.

OK (v3 coming...)