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.11595.1594692385655021871 for ; Mon, 13 Jul 2020 19:06:25 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 192.55.52.136, mailfrom: ray.ni@intel.com) IronPort-SDR: yHGzM3RRQz3Lowo+2PWEbDj14gaonG55gS5xDDMug31KyGbnT+3fuKb9F5Dj33pDkbVfUA4rEM LUlq7KEY7kPw== X-IronPort-AV: E=McAfee;i="6000,8403,9681"; a="128344035" X-IronPort-AV: E=Sophos;i="5.75,349,1589266800"; d="scan'208";a="128344035" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Jul 2020 19:06:24 -0700 IronPort-SDR: lid+02b05vqmtoPumcIwtk3hnXxwsrzmmFZu4smNNEMu5aIWxOE2hbXW+wl60EQco/OWB8FMLC mDZFCIfGoxjw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,349,1589266800"; d="scan'208";a="317568337" Received: from fmsmsx105.amr.corp.intel.com ([10.18.124.203]) by fmsmga002.fm.intel.com with ESMTP; 13 Jul 2020 19:06:24 -0700 Received: from fmsmsx101.amr.corp.intel.com (10.18.124.199) by FMSMSX105.amr.corp.intel.com (10.18.124.203) with Microsoft SMTP Server (TLS) id 14.3.439.0; Mon, 13 Jul 2020 19:06:23 -0700 Received: from shsmsx101.ccr.corp.intel.com (10.239.4.153) by fmsmsx101.amr.corp.intel.com (10.18.124.199) with Microsoft SMTP Server (TLS) id 14.3.439.0; Mon, 13 Jul 2020 19:06:23 -0700 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.135]) by SHSMSX101.ccr.corp.intel.com ([169.254.1.22]) with mapi id 14.03.0439.000; Tue, 14 Jul 2020 10:06:20 +0800 From: "Ni, Ray" To: "Gao, Zhichao" , "devel@edk2.groups.io" CC: "Wu, Hao A" Subject: Re: [PATCH V3 1/3] MdeModulePkg/PartitionDxe: Correct the MBR last block value Thread-Topic: [PATCH V3 1/3] MdeModulePkg/PartitionDxe: Correct the MBR last block value Thread-Index: AQHWWX1U5bTHH8fMoE2qJIUd8a+zyKkGUy8g Date: Tue, 14 Jul 2020 02:06:19 +0000 Deferred-Delivery: Tue, 14 Jul 2020 02:05:00 +0000 Message-ID: <734D49CCEBEEF84792F5B80ED585239D5C612C56@SHSMSX104.ccr.corp.intel.com> References: <20200714012259.30504-1-zhichao.gao@intel.com> <20200714012259.30504-2-zhichao.gao@intel.com> In-Reply-To: <20200714012259.30504-2-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 1/3] MdeModulePkg/PartitionDxe: Correct the MBR last > block value >=20 > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D2823 >=20 > PartitionValidMbr function's second parameter should be the > last sector of the device. For MBR partition, the block size is > sector size, i.e. 512 bytes. The original value is media block > last LBA which is counted by the media block size. And media > block size is not always 512 bytes, it may be larger which would > cause the MBR boundary check incorrect. The boundary check is > based on the partition entry start LBA and size of LBA which > are both counted by the sector number (512 bytes). >=20 > Cc: Hao A Wu > Cc: Ray Ni > Signed-off-by: Zhichao Gao > --- > MdeModulePkg/Universal/Disk/PartitionDxe/Mbr.c | 13 ++++++++----- > 1 file changed, 8 insertions(+), 5 deletions(-) >=20 > diff --git a/MdeModulePkg/Universal/Disk/PartitionDxe/Mbr.c > b/MdeModulePkg/Universal/Disk/PartitionDxe/Mbr.c > index dac451a144..f0c92aa09a 100644 > --- a/MdeModulePkg/Universal/Disk/PartitionDxe/Mbr.c > +++ b/MdeModulePkg/Universal/Disk/PartitionDxe/Mbr.c > @@ -135,14 +135,17 @@ PartitionInstallMbrChildHandles ( > EFI_DEVICE_PATH_PROTOCOL *LastDevicePathNode; > UINT32 BlockSize; > UINT32 MediaId; > - EFI_LBA LastBlock; > + EFI_LBA LastSector; > EFI_PARTITION_INFO_PROTOCOL PartitionInfo; >=20 > Found =3D EFI_NOT_FOUND; >=20 > - BlockSize =3D BlockIo->Media->BlockSize; > - MediaId =3D BlockIo->Media->MediaId; > - LastBlock =3D BlockIo->Media->LastBlock; > + BlockSize =3D BlockIo->Media->BlockSize; > + MediaId =3D BlockIo->Media->MediaId; > + LastSector =3D DivU64x32 ( > + MultU64x32 (BlockIo->Media->LastBlock + 1, BlockSize), > + MBR_SIZE > + ) - 1; >=20 > // > // Ensure the block size can hold the MBR > @@ -167,7 +170,7 @@ PartitionInstallMbrChildHandles ( > Found =3D Status; > goto Done; > } > - if (!PartitionValidMbr (Mbr, LastBlock)) { > + if (!PartitionValidMbr (Mbr, LastSector)) { > goto Done; > } > // > -- > 2.21.0.windows.1