From 1dccbd1a382aa57719e4e0432b3bd6a03a888507 Mon Sep 17 00:00:00 2001 From: "Czajkowski, Maciej" Date: Sat, 10 Sep 2022 02:10:55 +0800 Subject: [PATCH] MdeModulePkg/AhciPei: Fix MMIO base assignment REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4041 There is a mistake in getting MMIO base using PciDevicePpi that can lead to the data corruption. Cc: Hao A Wu Cc: Ray Ni Signed-off-by: Maciej Czajkowski Reviewed-by: Hao A Wu --- MdeModulePkg/Bus/Ata/AhciPei/AhciPei.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/MdeModulePkg/Bus/Ata/AhciPei/AhciPei.c b/MdeModulePkg/Bus/Ata/AhciPei/AhciPei.c index 98dd732a40..e33d863d2a 100644 --- a/MdeModulePkg/Bus/Ata/AhciPei/AhciPei.c +++ b/MdeModulePkg/Bus/Ata/AhciPei/AhciPei.c @@ -405,7 +405,7 @@ AtaAhciInitPrivateDataFromPciDevice ( { EFI_STATUS Status; PCI_TYPE00 PciData; - UINTN MmioBase; + UINT32 MmioBase; EFI_DEVICE_PATH_PROTOCOL *DevicePath; UINTN DevicePathLength; UINT64 EnabledPciAttributes; @@ -454,13 +454,15 @@ AtaAhciInitPrivateDataFromPciDevice ( &PciDevice->PciIo, EfiPciIoWidthUint32, 0x24, - sizeof (UINTN), + 1, &MmioBase ); if (EFI_ERROR (Status)) { return EFI_UNSUPPORTED; } + MmioBase &= 0xFFFFFFF0; + DevicePathLength = GetDevicePathSize (PciDevice->DevicePath); DevicePath = PciDevice->DevicePath;