[edk2-devel] [PATCH v2 3/4] OvmfPkg/PlatformInitLib: dynamic mmio window size

joeyli via groups.io jlee=suse.com at groups.io
Wed Mar 15 08:54:58 UTC 2023


Hi Gerd, 

I got a page-fault in CpuIo2Dxe.dll when using edk2-stable202211 ovmf with qemu-kvm:

!!!! X64 Exception Type - 0E(#PF - Page-Fault)  CPU Apic ID - 00000000 !!!!
ExceptionData - 000000000000000B  I:0 R:1 U:0 W:1 P:1 PK:0 SS:0 SGX:0
RIP  - 000000007F2CB5E8, CS  - 0000000000000038, RFLAGS - 0000000000010246
RAX  - 0000000000000000, RCX - 0000000000000001, RDX - 000000007F2CC5D0
RBX  - 0000038280000014, RSP - 000000007FF04710, RBP - 000000007FF04790
RSI  - 0000000000000000, RDI - 0000000000000000
R8   - 000000007FF04938, R9  - 0000000000000001, R10 - 0000000000000001
R11  - 0000000000000000, R12 - 000000007FF04938, R13 - 0000000000000001
R14  - 0000000000000001, R15 - 000000007F2CC3EC
DS   - 0000000000000030, ES  - 0000000000000030, FS  - 0000000000000030
GS   - 0000000000000030, SS  - 0000000000000030
CR0  - 0000000080010033, CR2 - 0000038280000014, CR3 - 000000007FC01000
CR4  - 0000000000000668, CR8 - 0000000000000000
DR0  - 0000000000000000, DR1 - 0000000000000000, DR2 - 0000000000000000
DR3  - 0000000000000000, DR6 - 00000000FFFF0FF0, DR7 - 0000000000000400
GDTR - 000000007F9DC000 0000000000000047, LDTR - 0000000000000000
IDTR - 000000007F2CD018 0000000000000FFF,   TR - 0000000000000000
FXSAVE_STATE - 000000007FF04370
!!!! Find image based on IP(0x7F2CB5E8) /home/joeyli/source_code-git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/UefiCpuPkg/CpuIo2Dxe/CpuIo2Dxe/DEBUG/CpuIo2Dxe.dll (ImageBase=000000007F2CA000, EntryPoint=000000007F2CBDE8) !!!!

After reverted this ecb778d0ac62 patch, the page-fault is gone. And
edk2-stable202311 can also reproduce this CpuIo2Dxe.dll page-fault.

I have filed a edk2 bug against this situation:

Bug 4373 - Got Page-Fault in CpuIo2Dxe.dll when using edk2-stable202211 ovmf with qemi-kvm
https://bugzilla.tianocore.org/show_bug.cgi?id=4373

Do you have any idea?

Thanks a lot!
Joey Lee

On Tue, Oct 04, 2022 at 03:47:27PM +0200, Gerd Hoffmann via groups.io wrote:
> In case we have a reliable PhysMemAddressWidth use that to dynamically
> size the 64bit address window.  Allocate 1/8 of the physical address
> space and place the window at the upper end of the address space.
> 
> Signed-off-by: Gerd Hoffmann <kraxel at redhat.com>
> ---
>  OvmfPkg/Library/PlatformInitLib/MemDetect.c | 28 +++++++++++++++++++++
>  1 file changed, 28 insertions(+)
> 
> diff --git a/OvmfPkg/Library/PlatformInitLib/MemDetect.c b/OvmfPkg/Library/PlatformInitLib/MemDetect.c
> index 16ecbfadc30c..ae217d0242ed 100644
> --- a/OvmfPkg/Library/PlatformInitLib/MemDetect.c
> +++ b/OvmfPkg/Library/PlatformInitLib/MemDetect.c
> @@ -604,6 +604,33 @@ PlatformAddressWidthFromCpuid (
>    }
>  }
>  
> +VOID
> +EFIAPI
> +PlatformDynamicMmioWindow (
> +  IN OUT EFI_HOB_PLATFORM_INFO  *PlatformInfoHob
> +  )
> +{
> +  UINT64  AddrSpace, MmioSpace;
> +
> +  AddrSpace = LShiftU64 (1, PlatformInfoHob->PhysMemAddressWidth);
> +  MmioSpace = LShiftU64 (1, PlatformInfoHob->PhysMemAddressWidth - 3);
> +
> +  if ((PlatformInfoHob->PcdPciMmio64Size < MmioSpace) &&
> +      (PlatformInfoHob->PcdPciMmio64Base + MmioSpace < AddrSpace))
> +  {
> +    DEBUG ((DEBUG_INFO, "%a: using dynamic mmio window\n", __func__));
> +    DEBUG ((DEBUG_INFO, "%a:   Addr Space 0x%Lx (%Ld GB)\n", __func__, AddrSpace, RShiftU64 (AddrSpace, 30)));
> +    DEBUG ((DEBUG_INFO, "%a:   MMIO Space 0x%Lx (%Ld GB)\n", __func__, MmioSpace, RShiftU64 (MmioSpace, 30)));
> +    PlatformInfoHob->PcdPciMmio64Size = MmioSpace;
> +    PlatformInfoHob->PcdPciMmio64Base = AddrSpace - MmioSpace;
> +  } else {
> +    DEBUG ((DEBUG_INFO, "%a: using classic mmio window\n", __func__));
> +  }
> +
> +  DEBUG ((DEBUG_INFO, "%a:   Pci64 Base 0x%Lx\n", __func__, PlatformInfoHob->PcdPciMmio64Base));
> +  DEBUG ((DEBUG_INFO, "%a:   Pci64 Size 0x%Lx\n", __func__, PlatformInfoHob->PcdPciMmio64Size));
> +}
> +
>  /**
>    Iterate over the PCI host bridges resources information optionally provided
>    in fw-cfg and find the highest address contained in the PCI MMIO windows. If
> @@ -765,6 +792,7 @@ PlatformAddressWidthInitialization (
>    if (PlatformInfoHob->PhysMemAddressWidth != 0) {
>      // physical address width is known
>      PlatformInfoHob->FirstNonAddress = FirstNonAddress;
> +    PlatformDynamicMmioWindow (PlatformInfoHob);
>      return;
>    }
>  
> -- 
> 2.37.3
> 
> 
> 
> 
> 


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#101212): https://edk2.groups.io/g/devel/message/101212
Mute This Topic: https://groups.io/mt/94113626/1813853
Group Owner: devel+owner at edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [edk2-devel-archive at redhat.com]
-=-=-=-=-=-=-=-=-=-=-=-




More information about the edk2-devel-archive mailing list