public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] disk: part_efi: add support for the Alternate GPT
@ 2014-04-29 22:31 Steve Rae
  2014-05-05 10:50 ` Przemyslaw Marczak
  0 siblings, 1 reply; 8+ messages in thread
From: Steve Rae @ 2014-04-29 22:31 UTC (permalink / raw)
  To: u-boot

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

Signed-off-by: Steve Rae <srae@broadcom.com>
---

 disk/part_efi.c | 20 ++++++++++++++++++--
 1 file changed, 18 insertions(+), 2 deletions(-)

diff --git a/disk/part_efi.c b/disk/part_efi.c
index 216a292..ad899fa 100644
--- a/disk/part_efi.c
+++ b/disk/part_efi.c
@@ -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) ||
-- 
1.8.5

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [U-Boot] [PATCH] disk: part_efi: add support for the Alternate GPT
  2014-04-29 22:31 [U-Boot] [PATCH] disk: part_efi: add support for the Alternate GPT Steve Rae
@ 2014-05-05 10:50 ` Przemyslaw Marczak
  2014-05-05 16:12   ` Steve Rae
  0 siblings, 1 reply; 8+ messages in thread
From: Przemyslaw Marczak @ 2014-05-05 10:50 UTC (permalink / raw)
  To: u-boot

Hello Steve,

On 04/30/2014 12:31 AM, Steve Rae wrote:
> Check the Alternate GPT table if the Primary GPT table is invalid.
>
> Signed-off-by: Steve Rae <srae@broadcom.com>
> ---
>
>   disk/part_efi.c | 20 ++++++++++++++++++--
>   1 file changed, 18 insertions(+), 2 deletions(-)
>
> diff --git a/disk/part_efi.c b/disk/part_efi.c
> index 216a292..ad899fa 100644
> --- a/disk/part_efi.c
> +++ b/disk/part_efi.c
> @@ -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) ||
>

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,
-- 
Przemyslaw Marczak
Samsung R&D Institute Poland
Samsung Electronics
p.marczak at samsung.com

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [U-Boot] [PATCH] disk: part_efi: add support for the Alternate GPT
  2014-05-05 10:50 ` Przemyslaw Marczak
@ 2014-05-05 16:12   ` Steve Rae
  2014-05-05 18:26     ` Steve Rae
  0 siblings, 1 reply; 8+ messages in thread
From: Steve Rae @ 2014-05-05 16:12 UTC (permalink / raw)
  To: u-boot


On 14-05-05 03:50 AM, Przemyslaw Marczak wrote:
> Hello Steve,
>
> On 04/30/2014 12:31 AM, Steve Rae wrote:
>> Check the Alternate GPT table if the Primary GPT table is invalid.
>>
>> Signed-off-by: Steve Rae <srae@broadcom.com>
>> ---
>>
>>   disk/part_efi.c | 20 ++++++++++++++++++--
>>   1 file changed, 18 insertions(+), 2 deletions(-)
>>
>> diff --git a/disk/part_efi.c b/disk/part_efi.c
>> index 216a292..ad899fa 100644
>> --- a/disk/part_efi.c
>> +++ b/disk/part_efi.c
>> @@ -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) ||
>>
>
> 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,
Agree -- maybe I can find time to work on a "gpt restore" in the near 
future....
Thanks, Steve

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [U-Boot] [PATCH] disk: part_efi: add support for the Alternate GPT
  2014-05-05 16:12   ` Steve Rae
@ 2014-05-05 18:26     ` Steve Rae
  2014-05-05 18:43       ` Tom Rini
  0 siblings, 1 reply; 8+ messages in thread
From: Steve Rae @ 2014-05-05 18:26 UTC (permalink / raw)
  To: u-boot

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

On 14-05-05 09:12 AM, Steve Rae wrote:
>
> On 14-05-05 03:50 AM, Przemyslaw Marczak wrote:
>> Hello Steve,
>>
>> On 04/30/2014 12:31 AM, Steve Rae wrote:
>>> Check the Alternate GPT table if the Primary GPT table is invalid.
>>>
>>> Signed-off-by: Steve Rae <srae@broadcom.com>
>>> ---
>>>
>>>   disk/part_efi.c | 20 ++++++++++++++++++--
>>>   1 file changed, 18 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/disk/part_efi.c b/disk/part_efi.c
>>> index 216a292..ad899fa 100644
>>> --- a/disk/part_efi.c
>>> +++ b/disk/part_efi.c
>>> @@ -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) ||
>>>
>>
>> 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,
> 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
>
>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [U-Boot] [PATCH] disk: part_efi: add support for the Alternate GPT
  2014-05-05 18:26     ` Steve Rae
@ 2014-05-05 18:43       ` Tom Rini
  2014-05-05 19:22         ` Steve Rae
  0 siblings, 1 reply; 8+ messages in thread
From: Tom Rini @ 2014-05-05 18:43 UTC (permalink / raw)
  To: u-boot

On Mon, May 05, 2014 at 11:26:44AM -0700, Steve Rae wrote:

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

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

-- 
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>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [U-Boot] [PATCH] disk: part_efi: add support for the Alternate GPT
  2014-05-05 18:43       ` Tom Rini
@ 2014-05-05 19:22         ` Steve Rae
  2014-05-05 19:41           ` Tom Rini
  0 siblings, 1 reply; 8+ messages in thread
From: Steve Rae @ 2014-05-05 19:22 UTC (permalink / raw)
  To: u-boot


On 14-05-05 11:43 AM, Tom Rini wrote:
> On Mon, May 05, 2014 at 11:26:44AM -0700, Steve Rae wrote:
>
>> 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")....

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [U-Boot] [PATCH] disk: part_efi: add support for the Alternate GPT
  2014-05-05 19:22         ` Steve Rae
@ 2014-05-05 19:41           ` Tom Rini
  2014-05-05 19:54             ` Steve Rae
  0 siblings, 1 reply; 8+ messages in thread
From: Tom Rini @ 2014-05-05 19:41 UTC (permalink / raw)
  To: u-boot

On Mon, May 05, 2014 at 12:22:18PM -0700, Steve Rae wrote:
> 
> On 14-05-05 11:43 AM, Tom Rini wrote:
> >On Mon, May 05, 2014 at 11:26:44AM -0700, Steve Rae wrote:
> >
> >>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")....

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

-- 
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>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [U-Boot] [PATCH] disk: part_efi: add support for the Alternate GPT
  2014-05-05 19:41           ` Tom Rini
@ 2014-05-05 19:54             ` Steve Rae
  0 siblings, 0 replies; 8+ messages in thread
From: Steve Rae @ 2014-05-05 19:54 UTC (permalink / raw)
  To: u-boot


On 14-05-05 12:41 PM, Tom Rini wrote:
> On Mon, May 05, 2014 at 12:22:18PM -0700, Steve Rae wrote:
>> On 14-05-05 11:43 AM, Tom Rini wrote:
>>> On Mon, May 05, 2014 at 11:26:44AM -0700, Steve Rae wrote:
>>>
>>>> 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")....
> I would go with backup GPT and update the README.gpt too please.
>
OK (v3 coming...)

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2014-05-05 19:54 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-04-29 22:31 [U-Boot] [PATCH] disk: part_efi: add support for the Alternate GPT Steve Rae
2014-05-05 10:50 ` Przemyslaw Marczak
2014-05-05 16:12   ` Steve Rae
2014-05-05 18:26     ` Steve Rae
2014-05-05 18:43       ` Tom Rini
2014-05-05 19:22         ` Steve Rae
2014-05-05 19:41           ` Tom Rini
2014-05-05 19:54             ` Steve Rae

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