From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by mx.groups.io with SMTP id smtpd.web10.11620.1594692264862677249 for ; Mon, 13 Jul 2020 19:04:25 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 192.55.52.43, mailfrom: ray.ni@intel.com) IronPort-SDR: lLHY0UFrvi+djxLICUIb01HmT+u8gF/BQM+0G8ENDpWmRIKvvQ3ynF050qQS8ACRzHcLcVU6Fu kKnCJo7tqQUw== X-IronPort-AV: E=McAfee;i="6000,8403,9681"; a="233630518" X-IronPort-AV: E=Sophos;i="5.75,349,1589266800"; d="scan'208";a="233630518" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Jul 2020 19:04:24 -0700 IronPort-SDR: xdGMUSfn3iwQncLyPtgzurx0mvRpb3R12W1tE84RF9A4GP8YO9k/fTPKJ0I8XSahJ/rb1kHIPB ZJA5jRmQNP7w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,349,1589266800"; d="scan'208";a="299387739" Received: from fmsmsx606.amr.corp.intel.com ([10.18.126.86]) by orsmga002.jf.intel.com with ESMTP; 13 Jul 2020 19:04:23 -0700 Received: from fmsmsx606.amr.corp.intel.com (10.18.126.86) by fmsmsx606.amr.corp.intel.com (10.18.126.86) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Mon, 13 Jul 2020 19:04:23 -0700 Received: from shsmsx103.ccr.corp.intel.com (10.239.4.69) by fmsmsx606.amr.corp.intel.com (10.18.126.86) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.1713.5 via Frontend Transport; Mon, 13 Jul 2020 19:04:23 -0700 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.135]) by SHSMSX103.ccr.corp.intel.com ([169.254.4.22]) with mapi id 14.03.0439.000; Tue, 14 Jul 2020 10:04:20 +0800 From: "Ni, Ray" To: "Gao, Zhichao" , "devel@edk2.groups.io" CC: "Wu, Hao A" Subject: Re: [PATCH V3 2/3] MdeModulePkg/PartitionDxe: Skip the MBR that add for CD-ROM Thread-Topic: [PATCH V3 2/3] MdeModulePkg/PartitionDxe: Skip the MBR that add for CD-ROM Thread-Index: AQHWWX1kN/Ygt5HZ/UmeaY+WKz0gc6kGUqPg Date: Tue, 14 Jul 2020 02:04:19 +0000 Deferred-Delivery: Tue, 14 Jul 2020 02:03:00 +0000 Message-ID: <734D49CCEBEEF84792F5B80ED585239D5C612C2C@SHSMSX104.ccr.corp.intel.com> References: <20200714012259.30504-1-zhichao.gao@intel.com> <20200714012259.30504-3-zhichao.gao@intel.com> In-Reply-To: <20200714012259.30504-3-zhichao.gao@intel.com> Accept-Language: en-US, zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Return-Path: ray.ni@intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Ray Ni > -----Original Message----- > From: Gao, Zhichao > Sent: Tuesday, July 14, 2020 9:23 AM > To: devel@edk2.groups.io > Cc: Wu, Hao A ; Ni, Ray > Subject: [PATCH V3 2/3] MdeModulePkg/PartitionDxe: Skip the MBR that add > for CD-ROM >=20 > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D2823 >=20 > Refer to > http://manpages.ubuntu.com/manpages/bionic/man8/mkudffs.8.html. > Some Linux ISOs may have the MBR table for compatibility reasons > for Windows. The MBR tale would contain the partition entry with > start LBA0 and whole media size. There are two methods to check > the filesystem in the CD-ROM: > 1. MBR partition check (Windows) > 2. Whole disk check (MAC OS) >=20 > UEFI doesn't have the MBR check for UDF and Eltorito. But it may > pass the MBR check for such table and fail to detect the filesystem > of UDF. Skip the MBR check if the MBR is added for Windows > compatiblity so that the partition driver can continue UDF and > ElTorito check. >=20 > Cc: Hao A Wu > Cc: Ray Ni > Signed-off-by: Zhichao Gao > --- > .../Universal/Disk/PartitionDxe/Mbr.c | 37 ++++++++++++++++--- > 1 file changed, 31 insertions(+), 6 deletions(-) >=20 > diff --git a/MdeModulePkg/Universal/Disk/PartitionDxe/Mbr.c > b/MdeModulePkg/Universal/Disk/PartitionDxe/Mbr.c > index f0c92aa09a..3830af1ea7 100644 > --- a/MdeModulePkg/Universal/Disk/PartitionDxe/Mbr.c > +++ b/MdeModulePkg/Universal/Disk/PartitionDxe/Mbr.c > @@ -39,6 +39,7 @@ PartitionValidMbr ( > UINT32 StartingLBA; > UINT32 EndingLBA; > UINT32 NewEndingLBA; > + UINT32 SizeInLBA; > INTN Index1; > INTN Index2; > BOOLEAN MbrValid; > @@ -51,13 +52,34 @@ PartitionValidMbr ( > // > MbrValid =3D FALSE; > for (Index1 =3D 0; Index1 < MAX_MBR_PARTITIONS; Index1++) { > - if (Mbr->Partition[Index1].OSIndicator =3D=3D 0x00 || UNPACK_UINT32 = (Mbr- > >Partition[Index1].SizeInLBA) =3D=3D 0) { > + StartingLBA =3D UNPACK_UINT32 (Mbr->Partition[Index1].StartingLBA); > + SizeInLBA =3D UNPACK_UINT32 (Mbr->Partition[Index1].SizeInLBA); > + > + // > + // If the MBR with partition entry covering the ENTIRE disk, i.e. st= art at > LBA0 > + // with whole disk size, we treat it as an invalid MBR partition. > + // > + if ((StartingLBA =3D=3D 0) && > + (SizeInLBA =3D=3D (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 fo= r > compatibility reasons with Windows. > + // Linux kernel ignores MBR table if contains partition which st= arts at > sector 0. > + // Skip it because we don't have the partition check for UDF(El To= rito > compatible). > + // It would continue to do the whole disk check in the UDF routine= . > + // > + DEBUG ((DEBUG_INFO, "PartitionValidMbr: MBR table has partition en= try > covering the ENTIRE disk. Don't treat it as a valid MBR.\n")); > + > + return FALSE; > + } > + > + if (Mbr->Partition[Index1].OSIndicator =3D=3D 0x00 || SizeInLBA =3D= =3D 0) { > continue; > } >=20 > MbrValid =3D TRUE; > - StartingLBA =3D UNPACK_UINT32 (Mbr->Partition[Index1].StartingLBA); > - EndingLBA =3D StartingLBA + UNPACK_UINT32 (Mbr- > >Partition[Index1].SizeInLBA) - 1; > + EndingLBA =3D StartingLBA + SizeInLBA - 1; > if (EndingLBA > LastLba) { > // > // Compatibility Errata: > @@ -77,12 +99,15 @@ PartitionValidMbr ( > } >=20 > for (Index2 =3D Index1 + 1; Index2 < MAX_MBR_PARTITIONS; Index2++) { > - if (Mbr->Partition[Index2].OSIndicator =3D=3D 0x00 || UNPACK_UINT3= 2 (Mbr- > >Partition[Index2].SizeInLBA) =3D=3D 0) { > + StartingLBA =3D UNPACK_UINT32 (Mbr->Partition[Index2].StartingLBA)= ; > + SizeInLBA =3D UNPACK_UINT32 (Mbr->Partition[Index2].SizeInLBA); > + > + if (Mbr->Partition[Index2].OSIndicator =3D=3D 0x00 || SizeInLBA = =3D=3D 0) { > continue; > } >=20 > - NewEndingLBA =3D UNPACK_UINT32 (Mbr->Partition[Index2].StartingLBA= ) + > UNPACK_UINT32 (Mbr->Partition[Index2].SizeInLBA) - 1; > - if (NewEndingLBA >=3D StartingLBA && UNPACK_UINT32 (Mbr- > >Partition[Index2].StartingLBA) <=3D EndingLBA) { > + NewEndingLBA =3D StartingLBA + SizeInLBA - 1; > + if (NewEndingLBA >=3D StartingLBA && StartingLBA <=3D EndingLBA) { > // > // This region overlaps with the Index1'th region > // > -- > 2.21.0.windows.1