From owner-svn-src-stable-12@freebsd.org Mon Nov 18 16:40:04 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 7056B1C3EFB; Mon, 18 Nov 2019 16:40:04 +0000 (UTC) (envelope-from tsoome@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 47Gvnc0TMsz4G4C; Mon, 18 Nov 2019 16:40:04 +0000 (UTC) (envelope-from tsoome@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id CF3502CB27; Mon, 18 Nov 2019 16:40:03 +0000 (UTC) (envelope-from tsoome@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id xAIGe3J7075558; Mon, 18 Nov 2019 16:40:03 GMT (envelope-from tsoome@FreeBSD.org) Received: (from tsoome@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xAIGe3hF075557; Mon, 18 Nov 2019 16:40:03 GMT (envelope-from tsoome@FreeBSD.org) Message-Id: <201911181640.xAIGe3hF075557@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: tsoome set sender to tsoome@FreeBSD.org using -f From: Toomas Soome Date: Mon, 18 Nov 2019 16:40:03 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r354818 - stable/12/stand/common X-SVN-Group: stable-12 X-SVN-Commit-Author: tsoome X-SVN-Commit-Paths: stable/12/stand/common X-SVN-Commit-Revision: 354818 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 Nov 2019 16:40:04 -0000 Author: tsoome Date: Mon Nov 18 16:40:03 2019 New Revision: 354818 URL: https://svnweb.freebsd.org/changeset/base/354818 Log: MFC r354746: 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: stable/12/stand/common/part.c Directory Properties: stable/12/ (props changed) Modified: stable/12/stand/common/part.c ============================================================================== --- stable/12/stand/common/part.c Mon Nov 18 16:37:21 2019 (r354817) +++ stable/12/stand/common/part.c Mon Nov 18 16:40:03 2019 (r354818) @@ -651,7 +651,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; @@ -713,28 +713,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) {