[edk2-devel] [PATCH 3/3] MdeModulePkg/PartitionDxe: Fix the incorrect LBA size in child hander

Gao, Zhichao posted 3 patches 5 years, 6 months ago
There is a newer version of this series
[edk2-devel] [PATCH 3/3] MdeModulePkg/PartitionDxe: Fix the incorrect LBA size in child hander
Posted by Gao, Zhichao 5 years, 6 months ago
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2843

PartitionInstallChildHandle's parameters Start and End is counted
by the BlockSize, but in the implementation it uses the parent
device's BlockSize to calculate the new Start, End and LastBlock.
It would cause the driver report incorrect block scope and the file
system would fail to be found with right block scope.
So correct it to the right value.

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>
---
 MdeModulePkg/Universal/Disk/PartitionDxe/Partition.c | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)

diff --git a/MdeModulePkg/Universal/Disk/PartitionDxe/Partition.c b/MdeModulePkg/Universal/Disk/PartitionDxe/Partition.c
index 473e091320..f10ce7c65b 100644
--- a/MdeModulePkg/Universal/Disk/PartitionDxe/Partition.c
+++ b/MdeModulePkg/Universal/Disk/PartitionDxe/Partition.c
@@ -1149,8 +1149,8 @@ PartitionInstallChildHandle (
 
   Private->Signature        = PARTITION_PRIVATE_DATA_SIGNATURE;
 
-  Private->Start            = MultU64x32 (Start, ParentBlockIo->Media->BlockSize);
-  Private->End              = MultU64x32 (End + 1, ParentBlockIo->Media->BlockSize);
+  Private->Start            = MultU64x32 (Start, BlockSize);
+  Private->End              = MultU64x32 (End + 1, BlockSize);
 
   Private->BlockSize        = BlockSize;
   Private->ParentBlockIo    = ParentBlockIo;
@@ -1187,13 +1187,7 @@ PartitionInstallChildHandle (
 
   Private->Media.IoAlign   = 0;
   Private->Media.LogicalPartition = TRUE;
-  Private->Media.LastBlock = DivU64x32 (
-                               MultU64x32 (
-                                 End - Start + 1,
-                                 ParentBlockIo->Media->BlockSize
-                                 ),
-                                BlockSize
-                               ) - 1;
+  Private->Media.LastBlock = End - Start;
 
   Private->Media.BlockSize = (UINT32) BlockSize;
 
-- 
2.21.0.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#63954): https://edk2.groups.io/g/devel/message/63954
Mute This Topic: https://groups.io/mt/76121501/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-

Re: [edk2-devel] [PATCH 3/3] MdeModulePkg/PartitionDxe: Fix the incorrect LBA size in child hander
Posted by Ni, Ray 5 years, 6 months ago
Reviewed-by: Ray Ni <ray.ni@intel.com>

> -----Original Message-----
> From: Gao, Zhichao <zhichao.gao@intel.com>
> Sent: Tuesday, August 11, 2020 2:43 PM
> 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: [PATCH 3/3] MdeModulePkg/PartitionDxe: Fix the incorrect LBA size in child hander
> 
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2843
> 
> PartitionInstallChildHandle's parameters Start and End is counted
> by the BlockSize, but in the implementation it uses the parent
> device's BlockSize to calculate the new Start, End and LastBlock.
> It would cause the driver report incorrect block scope and the file
> system would fail to be found with right block scope.
> So correct it to the right value.
> 
> 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>
> ---
>  MdeModulePkg/Universal/Disk/PartitionDxe/Partition.c | 12 +++---------
>  1 file changed, 3 insertions(+), 9 deletions(-)
> 
> diff --git a/MdeModulePkg/Universal/Disk/PartitionDxe/Partition.c
> b/MdeModulePkg/Universal/Disk/PartitionDxe/Partition.c
> index 473e091320..f10ce7c65b 100644
> --- a/MdeModulePkg/Universal/Disk/PartitionDxe/Partition.c
> +++ b/MdeModulePkg/Universal/Disk/PartitionDxe/Partition.c
> @@ -1149,8 +1149,8 @@ PartitionInstallChildHandle (
> 
>    Private->Signature        = PARTITION_PRIVATE_DATA_SIGNATURE;
> 
> -  Private->Start            = MultU64x32 (Start, ParentBlockIo->Media->BlockSize);
> -  Private->End              = MultU64x32 (End + 1, ParentBlockIo->Media->BlockSize);
> +  Private->Start            = MultU64x32 (Start, BlockSize);
> +  Private->End              = MultU64x32 (End + 1, BlockSize);
> 
>    Private->BlockSize        = BlockSize;
>    Private->ParentBlockIo    = ParentBlockIo;
> @@ -1187,13 +1187,7 @@ PartitionInstallChildHandle (
> 
>    Private->Media.IoAlign   = 0;
>    Private->Media.LogicalPartition = TRUE;
> -  Private->Media.LastBlock = DivU64x32 (
> -                               MultU64x32 (
> -                                 End - Start + 1,
> -                                 ParentBlockIo->Media->BlockSize
> -                                 ),
> -                                BlockSize
> -                               ) - 1;
> +  Private->Media.LastBlock = End - Start;
> 
>    Private->Media.BlockSize = (UINT32) BlockSize;
> 
> --
> 2.21.0.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#63975): https://edk2.groups.io/g/devel/message/63975
Mute This Topic: https://groups.io/mt/76121501/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-