From mboxrd@z Thu Jan  1 00:00:00 1970
Received: from mga12.intel.com (mga12.intel.com [192.55.52.136])
 by mx.groups.io with SMTP id smtpd.web12.9445.1597214340836311162
 for <devel@edk2.groups.io>;
 Tue, 11 Aug 2020 23:39:00 -0700
Authentication-Results: mx.groups.io;
 dkim=pass header.i=@intel.onmicrosoft.com header.s=selector2-intel-onmicrosoft-com header.b=pfOHNSgE;
 spf=pass (domain: intel.com, ip: 192.55.52.136, mailfrom: hao.a.wu@intel.com)
IronPort-SDR: b+G5vXous0o/+x/xkNBVH+y3+6CUgNZ/mNpiGh3qSLxqK+qu5NPUiiQfFSoH+/amTk1fZwZMvJ
 BL9rMCTCkCMw==
X-IronPort-AV: E=McAfee;i="6000,8403,9710"; a="133424940"
X-IronPort-AV: E=Sophos;i="5.76,303,1592895600"; 
   d="scan'208";a="133424940"
X-Amp-Result: SKIPPED(no attachment in message)
X-Amp-File-Uploaded: False
Received: from fmsmga008.fm.intel.com ([10.253.24.58])
  by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Aug 2020 23:38:59 -0700
IronPort-SDR: iA1Ss5QastNCxXS6b2eNa+PLHouuEnWR7twzFEiGOb2/UU2AKTdoMTk5nqyWXXPaeroaNEKNCM
 AwZTSXdK9acg==
X-ExtLoop1: 1
X-IronPort-AV: E=Sophos;i="5.76,303,1592895600"; 
   d="scan'208";a="277768634"
Received: from fmsmsx603-2.cps.intel.com (HELO fmsmsx603.amr.corp.intel.com) ([10.18.84.213])
  by fmsmga008.fm.intel.com with ESMTP; 11 Aug 2020 23:38:59 -0700
Received: from fmsmsx603.amr.corp.intel.com (10.18.126.83) by
 fmsmsx603.amr.corp.intel.com (10.18.126.83) with Microsoft SMTP Server
 (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id
 15.1.1713.5; Tue, 11 Aug 2020 23:38:59 -0700
Received: from fmsmsx123.amr.corp.intel.com (10.18.125.38) by
 fmsmsx603.amr.corp.intel.com (10.18.126.83) with Microsoft SMTP Server
 (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.1713.5
 via Frontend Transport; Tue, 11 Aug 2020 23:38:59 -0700
Received: from FMSEDG002.ED.cps.intel.com (10.1.192.134) by
 fmsmsx123.amr.corp.intel.com (10.18.125.38) with Microsoft SMTP Server (TLS)
 id 14.3.439.0; Tue, 11 Aug 2020 23:38:58 -0700
Received: from NAM12-BN8-obe.outbound.protection.outlook.com (104.47.55.168)
 by edgegateway.intel.com (192.55.55.69) with Microsoft SMTP Server (TLS) id
 14.3.439.0; Tue, 11 Aug 2020 23:38:58 -0700
ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none;
 b=ePIJeBp4Wy8BlPZcZYdbHEqnCdVCLiPQaAQwk2bDdka9sRChmx1vd+KctiZboFcDqn5Cg29kqT/UjrU5AmjbB7OeYqXQHa1bXSSN2mz8rPYCw9Krwqc1cxnWTsSd3Got7HKO8m1D/uxUb6jCjN5VMETLmcvlnvIrI1qs7t39J9dzuNLZ8QPT9vSftEWnLsQAZ686BwAYrHUfef1U7q01g8HO9TFOYOi9dXW+5k/+on3ubEMBvxx0Nvb2BZlZmpkC7uMqqAVHVfGJAh+BA63sWDwz1DnugRHnSKx0zBLeOoAEmAfpJMXJRScXyeJyBpFVY0oEbs0nGxDz76cZbssRqQ==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com;
 s=arcselector9901;
 h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck;
 bh=EmDY3lQzrisiIfy2pOPPf6jqpXoJ3fTmAVR17b87P1o=;
 b=nBUd31QOzb9EWieWwlU99CiCK6ac0PxGo2asu1dwqMo4Du+spUct/lCY1zYwlDTeNcsKxZ6oV+88Pag1THTp6XE/ut/9O/YYXUaowSY9IHhszugtU2Hs/5yTIg1qr4G8Y9dJtQOq83gGsoexhdeWJwmEfHRznmfrclBSwzmXt9w7RbqHEPq4bvGSGBCzdmFJXpfBNgWZOV4bTlX3rO1QAPvo3moJv6+wga1l9p1uYQxIymKvUcrcS7kE1u/ofVfavLZ+t28Tii38zbo/tcTS9Wz21poJvpepAn6G07ZocwPTuSbEn8zCBtM69GQFZcCXue0TQ/MHyjClvehoZBEIJw==
ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass
 smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com;
 dkim=pass header.d=intel.com; arc=none
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com;
 s=selector2-intel-onmicrosoft-com;
 h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck;
 bh=EmDY3lQzrisiIfy2pOPPf6jqpXoJ3fTmAVR17b87P1o=;
 b=pfOHNSgEIWGANfxuKy86tSvSaeomVbYWrUKbwB3Jer7sjElj2QKNtucvdGTMcHcrF1pwgBYoCF39B5RhbmSuU2jgo7dQxKpUhgy3BIIv80jyk8j/LxprTUMtS13pLW/mBydJD3smutWECX8qt1R0+Y/H7r2DD4dDux0q565bqtE=
Received: from DM6PR11MB3673.namprd11.prod.outlook.com (2603:10b6:5:145::26)
 by DM6PR11MB2618.namprd11.prod.outlook.com (2603:10b6:5:c0::30) with
 Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3261.15; Wed, 12 Aug
 2020 06:38:56 +0000
Received: from DM6PR11MB3673.namprd11.prod.outlook.com
 ([fe80::5111:3ecb:21f:eeb6]) by DM6PR11MB3673.namprd11.prod.outlook.com
 ([fe80::5111:3ecb:21f:eeb6%7]) with mapi id 15.20.3283.015; Wed, 12 Aug 2020
 06:38:56 +0000
From: "Wu, Hao A" <hao.a.wu@intel.com>
To: "devel@edk2.groups.io" <devel@edk2.groups.io>, "Gao, Zhichao"
	<zhichao.gao@intel.com>
CC: "Wang, Jian J" <jian.j.wang@intel.com>, "Ni, Ray" <ray.ni@intel.com>,
	"Gary Lin" <glin@suse.com>, Andrew Fish <afish@apple.com>
Subject: Re: [edk2-devel] [PATCH V2 2/3] MdeModulePkg/PartitionDxe: Revert changes for the special MBR
Thread-Topic: [edk2-devel] [PATCH V2 2/3] MdeModulePkg/PartitionDxe: Revert
 changes for the special MBR
Thread-Index: AQHWcEbwrVwqgD+tCEGOWdqexV9QV6k0BeUw
Date: Wed, 12 Aug 2020 06:38:56 +0000
Message-ID: <DM6PR11MB3673818C8A5D59BD360DB26ACA420@DM6PR11MB3673.namprd11.prod.outlook.com>
References: <20200812012124.18220-1-zhichao.gao@intel.com>
 <20200812012124.18220-3-zhichao.gao@intel.com>
In-Reply-To: <20200812012124.18220-3-zhichao.gao@intel.com>
Accept-Language: en-US, zh-CN
X-MS-Has-Attach: 
X-MS-TNEF-Correlator: 
dlp-product: dlpe-windows
dlp-reaction: no-action
dlp-version: 11.5.1.3
authentication-results: edk2.groups.io; dkim=none (message not signed)
 header.d=none;edk2.groups.io; dmarc=none action=none header.from=intel.com;
x-originating-ip: [192.198.147.218]
x-ms-publictraffictype: Email
x-ms-office365-filtering-correlation-id: 5ff3ad91-f9bf-408d-b37b-08d83e8a6359
x-ms-traffictypediagnostic: DM6PR11MB2618:
x-ld-processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtAddr
x-ms-exchange-transport-forked: True
x-microsoft-antispam-prvs: <DM6PR11MB261884CCA00256268B972806CA420@DM6PR11MB2618.namprd11.prod.outlook.com>
x-ms-oob-tlc-oobclassifiers: OLM:8273;
x-ms-exchange-senderadcheck: 1
x-microsoft-antispam: BCL:0;
x-microsoft-antispam-message-info: 33K7o97YcyZQheltNu8G7C3MHDi35aHr5kf3zBFluTVlHg8GGP6bcQF+OctnsZ9s27yRfxDSbLSJ+OTwRCK7eBSgbEAE3IDmRNQXZ49nbJDpTSV2EjQ6Sico6IEXAn9Dh6H2xz3Zyi3scx1gQIQ3eWxK5oalv8vocy3QgNN/1MWHrxLXAtj2KLGxSPYnsMIWm7zSVewODJ5YfeHan2W3nT6nECtzHPR8OOvvnf9ZttD+aLCjhhQd4cBrv5IYCTo3FAjzMMEjZGb+CSTMoSu5bY7RWj+epQpnEKESAGNhpbTjnO+RyHUnWAIyOBAmi7GxJw4zvD5yXJ5nAMsmOUX3xlx1d6gUZK3Tjz9gopmjkClrntbRy6T9pleAlD2dRJ2wrwCaBJC8czIdXXJxvJRolzvcVNn2Gsn1U64YHJYVlAFVLRJcNj6n1rHG5giMs/FylVOooHywpTFQbNwDD40Y4w==
x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR11MB3673.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:(4636009)(396003)(366004)(39860400002)(346002)(376002)(136003)(8936002)(33656002)(66556008)(53546011)(52536014)(64756008)(4326008)(76116006)(66446008)(6636002)(26005)(186003)(8676002)(66476007)(5660300002)(6506007)(66946007)(2906002)(478600001)(86362001)(54906003)(966005)(71200400001)(316002)(9686003)(83380400001)(55016002)(110136005)(7696005)(562404015);DIR:OUT;SFP:1102;
x-ms-exchange-antispam-messagedata: So1K5tSO/tLcR2hReQGB0V7/4pVPHqDEykgNlutv4Xo3mEp1mfEs/ZkqqRaE3Dv8ywSifrfr2uk+4m/WIuwb9j3WS6g4Tt/bcvpvGxF0OWDblfKa2RDjnqSOZYISqhAjm1Hcd9vWV3QPMeQ60RxW4iCsE/gVcDTWxXhOf8IMjGhcwriiv7EOtaOpBai96LXJLHiuz7SPVuPX1Yj7QiSiqSoJENNTkNTXeNfKpqhoCJPcRq4SRycU1OgXj//UbtJZXgrGL46sKMUJTS/MIhvZA/Qvs2ja+XOSoIgjNSjUpwG43g5xiMDysJ31Fkkxwh7IeGth8YCSf3d0e33B/Cw7iJsyT43DFWr4gYKHoRGjn8TxjpmOQjsCEptldcTDhPxyslj9cUzuvrr7o6vLff7pYSUaT7ncfYbTAFfXz3ZJuLOdxjWeinaRvwYsmJAq9Ktk0Pt5LOsaIu8vJaQ79Us46ndVSkE2pGtsvP7m1PFYmmttuSwnrzH4A/xq6/FU1yDwl058JNgCVlmCnokzFfCNEm52oRtjPY1elp3C0WlEPVh52k9dvJNTeHJkOiHUgwWScmbixXI5oLn4M6dkaSZARzqp6S8VejV7F/o1J9f0cWeVujeLFPIYTZ0nyoX8RimSCRr8klmrlu13AbzrNnc/Vw==
MIME-Version: 1.0
X-MS-Exchange-CrossTenant-AuthAs: Internal
X-MS-Exchange-CrossTenant-AuthSource: DM6PR11MB3673.namprd11.prod.outlook.com
X-MS-Exchange-CrossTenant-Network-Message-Id: 5ff3ad91-f9bf-408d-b37b-08d83e8a6359
X-MS-Exchange-CrossTenant-originalarrivaltime: 12 Aug 2020 06:38:56.5387
 (UTC)
X-MS-Exchange-CrossTenant-fromentityheader: Hosted
X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d
X-MS-Exchange-CrossTenant-mailboxtype: HOSTED
X-MS-Exchange-CrossTenant-userprincipalname: Vb77WZGY8GsMxY4zqO1M3Mj18CYVgnQ4tM4VvJ55cABBCgT0xIWmbb8hx5j/mBasHw+KkCw8IjmmfzgM4G6FlQ==
X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR11MB2618
Return-Path: hao.a.wu@intel.com
X-OriginatorOrg: intel.com
Content-Language: en-US
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

> -----Original Message-----
> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Gao,
> Zhichao
> Sent: Wednesday, August 12, 2020 9:21 AM
> To: devel@edk2.groups.io
> Cc: Wang, Jian J <jian.j.wang@intel.com>; Wu, Hao A
> <hao.a.wu@intel.com>; Ni, Ray <ray.ni@intel.com>; Gary Lin
> <glin@suse.com>; Andrew Fish <afish@apple.com>
> Subject: [edk2-devel] [PATCH V2 2/3] MdeModulePkg/PartitionDxe: Revert
> changes for the special MBR
>=20
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D2823
>=20
> Revert "MdeModulePkg/PartitionDxe: Skip the MBR that add for CD-ROM"
>=20
> Follow the spec definition, the ISO 9660 (and UDF) would be checked befo=
re
> the MBR. So it is not required to skip such MBR talbe that contian the e=
ntire
> block device.


Reviewed-by: Hao A Wu <hao.a.wu@intel.com>

Best Regards,
Hao Wu


>=20
> Cc: Jian J Wang <jian.j.wang@intel.com>
> Cc: Hao A Wu <hao.a.wu@intel.com>
> Cc: Ray Ni <ray.ni@intel.com>
> Cc: Gary Lin <glin@suse.com>
> Cc: Andrew Fish <afish@apple.com>
> Signed-off-by: Zhichao Gao <zhichao.gao@intel.com>
> ---
>  .../Universal/Disk/PartitionDxe/Mbr.c         | 37 +++----------------
>  1 file changed, 6 insertions(+), 31 deletions(-)
>=20
> 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 =3D FALSE;
>    for (Index1 =3D 0; Index1 < MAX_MBR_PARTITIONS; Index1++) {
> -    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. s=
tart 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 f=
or
> compatibility reasons with Windows.
> -      // Linux  kernel  ignores MBR table if contains partition which s=
tarts at
> sector 0.
> -      // Skip it because we don't have the partition check for UDF(El T=
orito
> compatible).
> -      // It would continue to do the whole disk check in the UDF routin=
e.
> -      //
> -      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 =3D=3D 0x00 || SizeInLBA =3D=
=
=3D 0) {
> +    if (Mbr->Partition[Index1].OSIndicator =3D=3D 0x00 || UNPACK_UINT32
> + (Mbr->Partition[Index1].SizeInLBA) =3D=3D 0) {
>        continue;
>      }
>=20
>      MbrValid    =3D TRUE;
> -    EndingLBA   =3D StartingLBA + SizeInLBA - 1;
> +    StartingLBA =3D UNPACK_UINT32 (Mbr->Partition[Index1].StartingLBA);
> +    EndingLBA   =3D StartingLBA + UNPACK_UINT32 (Mbr-
> >Partition[Index1].SizeInLBA) - 1;
>      if (EndingLBA > LastLba) {
>        //
>        // Compatibility Errata:
> @@ -99,15 +77,12 @@ PartitionValidMbr (
>      }
>=20
>      for (Index2 =3D Index1 + 1; Index2 < MAX_MBR_PARTITIONS; Index2++) =
{
> -      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) {
> +      if (Mbr->Partition[Index2].OSIndicator =3D=3D 0x00 || UNPACK_UINT=
32
> + (Mbr->Partition[Index2].SizeInLBA) =3D=3D 0) {
>          continue;
>        }
>=20
> -      NewEndingLBA =3D StartingLBA + SizeInLBA - 1;
> -      if (NewEndingLBA >=3D StartingLBA && StartingLBA <=3D EndingLBA) =
{
> +      NewEndingLBA =3D UNPACK_UINT32 (Mbr->Partition[Index2].StartingLB=
A)
> + UNPACK_UINT32 (Mbr->Partition[Index2].SizeInLBA) - 1;
> +      if (NewEndingLBA >=3D StartingLBA && UNPACK_UINT32
> + (Mbr->Partition[Index2].StartingLBA) <=3D EndingLBA) {
>          //
>          // This region overlaps with the Index1'th region
>          //
> --
> 2.21.0.windows.1
>=20
>=20
>=20