Date: Fri, 15 Nov 2019 20:43:40 +0000 (UTC) From: Toomas Soome <tsoome@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r354746 - head/stand/common Message-ID: <201911152043.xAFKheii065688@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: tsoome Date: Fri Nov 15 20:43:39 2019 New Revision: 354746 URL: https://svnweb.freebsd.org/changeset/base/354746 Log: loader: add support for hybrid PMBR for GPT partition table Note hybrid table is nor really UEFI specification compliant. Sample hybrid partition table: > ::mbr Format: unknown Signature: 0xaa55 (valid) UniqueMBRDiskSignature: 0 PART TYPE ACTIVE STARTCHS ENDCHS SECTOR NUMSECT 0 EFI_PMBR:0xee 0 1023/254/63 1023/254/63 1 409639 1 0xff 0 1023/254/63 1023/254/63 409640 978508408 2 FDISK_EXT_WIN:0xc 0 1023/254/63 1023/254/63 978918048 31250000 3 0xff 0 1023/254/63 1023/254/63 1010168048 32 > Modified: head/stand/common/part.c Modified: head/stand/common/part.c ============================================================================== --- head/stand/common/part.c Fri Nov 15 19:03:02 2019 (r354745) +++ head/stand/common/part.c Fri Nov 15 20:43:39 2019 (r354746) @@ -647,7 +647,7 @@ ptable_open(void *dev, uint64_t sectors, uint16_t sect struct dos_partition *dp; struct ptable *table; uint8_t *buf; - int i, count; + int i; #ifdef LOADER_MBR_SUPPORT struct pentry *entry; uint32_t start, end; @@ -709,28 +709,23 @@ ptable_open(void *dev, uint64_t sectors, uint16_t sect } /* Check that we have PMBR. Also do some validation. */ dp = (struct dos_partition *)(buf + DOSPARTOFF); - for (i = 0, count = 0; i < NDOSPART; i++) { + /* + * In mac we can have PMBR partition in hybrid MBR; + * that is, MBR partition which has DOSPTYP_PMBR entry defined as + * start sector 1. After DOSPTYP_PMBR, there may be other partitions. + * UEFI compliant PMBR has no other partitions. + */ + for (i = 0; i < NDOSPART; i++) { if (dp[i].dp_flag != 0 && dp[i].dp_flag != 0x80) { DPRINTF("invalid partition flag %x", dp[i].dp_flag); goto out; } #ifdef LOADER_GPT_SUPPORT - if (dp[i].dp_typ == DOSPTYP_PMBR) { + if (dp[i].dp_typ == DOSPTYP_PMBR && dp[i].dp_start == 1) { table->type = PTABLE_GPT; DPRINTF("PMBR detected"); } #endif - if (dp[i].dp_typ != 0) - count++; - } - /* Do we have some invalid values? */ - if (table->type == PTABLE_GPT && count > 1) { - if (dp[1].dp_typ != DOSPTYP_HFS) { - table->type = PTABLE_NONE; - DPRINTF("Incorrect PMBR, ignore it"); - } else { - DPRINTF("Bootcamp detected"); - } } #ifdef LOADER_GPT_SUPPORT if (table->type == PTABLE_GPT) {
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201911152043.xAFKheii065688>