From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga01.intel.com (mga01.intel.com []) by mx.groups.io with SMTP id smtpd.web10.6027.1597195289387869314 for ; Tue, 11 Aug 2020 18:21:31 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=fail (domain: intel.com, ip: , mailfrom: zhichao.gao@intel.com) IronPort-SDR: Z+2ZaVlqhmhDV0lOzsuJ1+R6lbW53YXzjP+esB3GC036fSGynlfsrupGAPOf+AkiAlCAoWvows baff9si/TNww== X-IronPort-AV: E=McAfee;i="6000,8403,9710"; a="171908232" X-IronPort-AV: E=Sophos;i="5.76,302,1592895600"; d="scan'208";a="171908232" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Aug 2020 18:21:31 -0700 IronPort-SDR: gIAnRgABSHBDrH9KzEQAI4tkOngkV+ntFWbdUciC3a08rRUqDjBiOeBfROmDIDiSE36Z0utnzp MsyJM9m24Czw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,302,1592895600"; d="scan'208";a="494868732" Received: from fieedk001.ccr.corp.intel.com ([10.239.153.108]) by fmsmga006.fm.intel.com with ESMTP; 11 Aug 2020 18:21:30 -0700 From: "Gao, Zhichao" To: devel@edk2.groups.io Cc: Jian J Wang , Hao A Wu , Ray Ni , Gary Lin , Andrew Fish Subject: [PATCH V2 2/3] MdeModulePkg/PartitionDxe: Revert changes for the special MBR Date: Wed, 12 Aug 2020 09:21:23 +0800 Message-Id: <20200812012124.18220-3-zhichao.gao@intel.com> X-Mailer: git-send-email 2.21.0.windows.1 In-Reply-To: <20200812012124.18220-1-zhichao.gao@intel.com> References: <20200812012124.18220-1-zhichao.gao@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2823 Revert "MdeModulePkg/PartitionDxe: Skip the MBR that add for CD-ROM" Follow the spec definition, the ISO 9660 (and UDF) would be checked before the MBR. So it is not required to skip such MBR talbe that contian the entire block device. Cc: Jian J Wang Cc: Hao A Wu Cc: Ray Ni Cc: Gary Lin Cc: Andrew Fish Signed-off-by: Zhichao Gao --- .../Universal/Disk/PartitionDxe/Mbr.c | 37 +++---------------- 1 file changed, 6 insertions(+), 31 deletions(-) diff --git a/MdeModulePkg/Universal/Disk/PartitionDxe/Mbr.c b/MdeModulePkg/Universal/Disk/PartitionDxe/Mbr.c index 3830af1ea7..f0c92aa09a 100644 --- a/MdeModulePkg/Universal/Disk/PartitionDxe/Mbr.c +++ b/MdeModulePkg/Universal/Disk/PartitionDxe/Mbr.c @@ -39,7 +39,6 @@ PartitionValidMbr ( UINT32 StartingLBA; UINT32 EndingLBA; UINT32 NewEndingLBA; - UINT32 SizeInLBA; INTN Index1; INTN Index2; BOOLEAN MbrValid; @@ -52,34 +51,13 @@ PartitionValidMbr ( // MbrValid = FALSE; for (Index1 = 0; Index1 < MAX_MBR_PARTITIONS; Index1++) { - StartingLBA = UNPACK_UINT32 (Mbr->Partition[Index1].StartingLBA); - SizeInLBA = UNPACK_UINT32 (Mbr->Partition[Index1].SizeInLBA); - - // - // If the MBR with partition entry covering the ENTIRE disk, i.e. start at LBA0 - // with whole disk size, we treat it as an invalid MBR partition. - // - if ((StartingLBA == 0) && - (SizeInLBA == (LastLba + 1))) { - // - // Refer to the http://manpages.ubuntu.com/manpages/bionic/man8/mkudffs.8.html - // "WHOLE DISK VS PARTITION" - // Some linux ISOs may put the MBR table in the first 512 bytes for compatibility reasons with Windows. - // Linux kernel ignores MBR table if contains partition which starts at sector 0. - // Skip it because we don't have the partition check for UDF(El Torito compatible). - // It would continue to do the whole disk check in the UDF routine. - // - DEBUG ((DEBUG_INFO, "PartitionValidMbr: MBR table has partition entry covering the ENTIRE disk. Don't treat it as a valid MBR.\n")); - - return FALSE; - } - - if (Mbr->Partition[Index1].OSIndicator == 0x00 || SizeInLBA == 0) { + if (Mbr->Partition[Index1].OSIndicator == 0x00 || UNPACK_UINT32 (Mbr->Partition[Index1].SizeInLBA) == 0) { continue; } MbrValid = TRUE; - EndingLBA = StartingLBA + SizeInLBA - 1; + StartingLBA = UNPACK_UINT32 (Mbr->Partition[Index1].StartingLBA); + EndingLBA = StartingLBA + UNPACK_UINT32 (Mbr->Partition[Index1].SizeInLBA) - 1; if (EndingLBA > LastLba) { // // Compatibility Errata: @@ -99,15 +77,12 @@ PartitionValidMbr ( } for (Index2 = Index1 + 1; Index2 < MAX_MBR_PARTITIONS; Index2++) { - StartingLBA = UNPACK_UINT32 (Mbr->Partition[Index2].StartingLBA); - SizeInLBA = UNPACK_UINT32 (Mbr->Partition[Index2].SizeInLBA); - - if (Mbr->Partition[Index2].OSIndicator == 0x00 || SizeInLBA == 0) { + if (Mbr->Partition[Index2].OSIndicator == 0x00 || UNPACK_UINT32 (Mbr->Partition[Index2].SizeInLBA) == 0) { continue; } - NewEndingLBA = StartingLBA + SizeInLBA - 1; - if (NewEndingLBA >= StartingLBA && StartingLBA <= EndingLBA) { + NewEndingLBA = UNPACK_UINT32 (Mbr->Partition[Index2].StartingLBA) + UNPACK_UINT32 (Mbr->Partition[Index2].SizeInLBA) - 1; + if (NewEndingLBA >= StartingLBA && UNPACK_UINT32 (Mbr->Partition[Index2].StartingLBA) <= EndingLBA) { // // This region overlaps with the Index1'th region // -- 2.21.0.windows.1