public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Andrew Fish" <afish@apple.com>
To: devel@edk2.groups.io, wei6.xu@intel.com
Cc: Laszlo Ersek <lersek@redhat.com>,
	Mike Kinney <michael.d.kinney@intel.com>
Subject: Re: [edk2-devel] Question about the Protective MBR in RedHat/Ubuntu
Date: Wed, 24 Apr 2019 09:07:19 -0700	[thread overview]
Message-ID: <2F4FB4C7-8C2F-4B16-B89B-A4FE72BD5318@apple.com> (raw)
In-Reply-To: <59B8EAB3797CDB4091332F0685A110ED50D6B722@SHSMSX104.ccr.corp.intel.com>

[-- Attachment #1: Type: text/plain, Size: 2042 bytes --]

The intent of the protective MBR was to prevent tools that did not understand GPT to not think a GPT disk was blank. 20 years ago that made a lot of sense, today it is kind of an obsolete concept.

The protective MBR was never intended to identify the disk as GPT, but it seems it got used as a short cut to not have to read a variable number of blocks from the disk to validate the GPT header. 

>From a practical sense the DXE Partition driver uses this algorithm to validate the Protective MBR. It would be a good idea for the PEI code to do the same thing. 

https://github.com/tianocore/edk2/blob/master/MdeModulePkg/Universal/Disk/PartitionDxe/Gpt.c

  //
  // Verify that the Protective MBR is valid
  //
  for (Index = 0; Index < MAX_MBR_PARTITIONS; Index++) {
    if (ProtectiveMbr->Partition[Index].BootIndicator == 0x00 &&
        ProtectiveMbr->Partition[Index].OSIndicator == PMBR_GPT_PARTITION &&
        UNPACK_UINT32 (ProtectiveMbr->Partition[Index].StartingLBA) == 1
        ) {
      break;
    }
  }
  if (Index == MAX_MBR_PARTITIONS) {
    goto Done;
  }

I'd also point out that that ATA-6 specification obsoleted CHS addressing in 2002 and I think the 0x200 has to do with the sector size of 512 bytes, which is also kind of an obsolete concept. So I'm not sure what the 0x100 is about in your example?

Thanks,

Andrew Fish

> On Apr 24, 2019, at 4:36 AM, Xu, Wei6 <wei6.xu@intel.com> wrote:
> 
> Hi,
>  
> I have a question about protective MBR. Thanks a lot for your time.
> Why is the StartingCHS of protective MBR partition record set to 0x000100 in RedHat / Ubuntu? While UEFI spec defines it as 0x000200.
>  
> Problem Statement:
> I met a problem when trying to use FatPei to fetch a file on the GPT partition of RedHat/Ubuntu in TCB.
> FatPei has a check about Partition Record of protective MBR: StartingCHS should to 0x000200.
> But I find the StartingCHS in both RedHat and Ubuntu is 0x000100, so that the check fails.
>  
> According to UEFI spec, StartingCHS should be 0x000200.  
>  
> <image001.png>
> 


[-- Attachment #2: Type: text/html, Size: 18878 bytes --]

  reply	other threads:[~2019-04-24 16:07 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-24 11:36 [edk2-devel] Question about the Protective MBR in RedHat/Ubuntu wei6.xu
2019-04-24 16:07 ` Andrew Fish [this message]
2019-04-25  1:40   ` chao.b.zhang
2019-04-25  1:59     ` Andrew Fish
2019-04-24 18:11 ` Laszlo Ersek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2F4FB4C7-8C2F-4B16-B89B-A4FE72BD5318@apple.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox