From: "Laszlo Ersek" <lersek@redhat.com>
To: Gerd Hoffmann <kraxel@redhat.com>, devel@edk2.groups.io
Cc: Jiewen Yao <jiewen.yao@intel.com>,
Oliver Steffen <osteffen@redhat.com>,
Ard Biesheuvel <ardb+tianocore@kernel.org>,
Pawel Polawski <ppolawsk@redhat.com>,
Jordan Justen <jordan.l.justen@intel.com>
Subject: Re: [PATCH v4 4/5] OvmfPkg/PlatformInitLib: Add PlatformReservationConflictCB
Date: Tue, 17 Jan 2023 16:05:40 +0100 [thread overview]
Message-ID: <9cea31ea-eeb2-cdee-8df1-807b7592d196@redhat.com> (raw)
In-Reply-To: <20230117121629.2149112-5-kraxel@redhat.com>
On 1/17/23 13:16, Gerd Hoffmann wrote:
> Add PlatformReservationConflictCB() callback function for use with
> PlatformScanE820(). It checks whenever the 64bit PCI MMIO window
> overlaps with a reservation from qemu. If so move down the MMIO window
> to resolve the conflict.
>
> Write any actions done (moving mmio window) to the firmware log with
> INFO loglevel.
>
> This happens on (virtual) AMD machines with 1TB address space,
> because the AMD IOMMU uses an address window just below 1TB.
>
> Bugzilla: https://bugzilla.tianocore.org/show_bug.cgi?id=4251
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
> ---
> OvmfPkg/Library/PlatformInitLib/MemDetect.c | 45 +++++++++++++++++++++
> 1 file changed, 45 insertions(+)
>
> diff --git a/OvmfPkg/Library/PlatformInitLib/MemDetect.c b/OvmfPkg/Library/PlatformInitLib/MemDetect.c
> index c626fc49cf6c..1ce692e77ecb 100644
> --- a/OvmfPkg/Library/PlatformInitLib/MemDetect.c
> +++ b/OvmfPkg/Library/PlatformInitLib/MemDetect.c
> @@ -213,6 +213,50 @@ PlatformAddHobCB (
> }
> }
>
> +/**
> + Check whenever the 64bit PCI MMIO window overlaps with a reservation
> + from qemu. If so move down the MMIO window to resolve the conflict.
> +
> + This happens on (virtual) AMD machines with 1TB address space,
> + because the AMD IOMMU uses an address window just below 1TB.
> +**/
> +STATIC VOID
> +PlatformReservationConflictCB (
> + IN EFI_E820_ENTRY64 *E820Entry,
> + IN OUT EFI_HOB_PLATFORM_INFO *PlatformInfoHob
> + )
> +{
> + UINT64 IntersectionBase;
> + UINT64 IntersectionEnd;
> + UINT64 NewBase;
> +
> + IntersectionBase = MAX (
> + E820Entry->BaseAddr,
> + PlatformInfoHob->PcdPciMmio64Base
> + );
> + IntersectionEnd = MIN (
> + E820Entry->BaseAddr + E820Entry->Length,
> + PlatformInfoHob->PcdPciMmio64Base +
> + PlatformInfoHob->PcdPciMmio64Size
> + );
> +
> + if (IntersectionBase >= IntersectionEnd) {
> + return; // no overlap
> + }
> +
> + NewBase = E820Entry->BaseAddr - PlatformInfoHob->PcdPciMmio64Size;
> + NewBase = NewBase & ~(PlatformInfoHob->PcdPciMmio64Size - 1);
> +
> + DEBUG ((
> + DEBUG_INFO,
> + "%a: move mmio: 0x%Lx => %Lx\n",
> + __FUNCTION__,
> + PlatformInfoHob->PcdPciMmio64Base,
> + NewBase
> + ));
> + PlatformInfoHob->PcdPciMmio64Base = NewBase;
> +}
> +
> /**
> Iterate over the entries in QEMU's fw_cfg E820 RAM map, call the
> passed callback for each entry.
> @@ -650,6 +694,7 @@ PlatformDynamicMmioWindow (
> DEBUG ((DEBUG_INFO, "%a: MMIO Space 0x%Lx (%Ld GB)\n", __func__, MmioSpace, RShiftU64 (MmioSpace, 30)));
> PlatformInfoHob->PcdPciMmio64Size = MmioSpace;
> PlatformInfoHob->PcdPciMmio64Base = AddrSpace - MmioSpace;
> + PlatformScanE820 (PlatformReservationConflictCB, PlatformInfoHob);
> } else {
> DEBUG ((DEBUG_INFO, "%a: using classic mmio window\n", __func__));
> }
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
next prev parent reply other threads:[~2023-01-17 15:09 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-17 12:16 [PATCH v4 0/5] OvmfPkg: check 64bit mmio window for resource conflicts Gerd Hoffmann
2023-01-17 12:16 ` [PATCH v4 1/5] OvmfPkg/PlatformInitLib: Add PlatformScanE820 and GetFirstNonAddressCB Gerd Hoffmann
2023-01-17 14:30 ` Laszlo Ersek
2023-01-17 14:46 ` Laszlo Ersek
2023-01-17 14:48 ` [edk2-devel] " Ard Biesheuvel
2023-01-17 12:16 ` [PATCH v4 2/5] OvmfPkg/PlatformInitLib: Add PlatformGetLowMemoryCB Gerd Hoffmann
2023-01-17 14:45 ` Laszlo Ersek
2023-01-17 12:16 ` [PATCH v4 3/5] OvmfPkg/PlatformInitLib: Add PlatformAddHobCB Gerd Hoffmann
2023-01-17 15:00 ` Laszlo Ersek
2023-01-17 15:06 ` Ard Biesheuvel
2023-01-17 16:04 ` Ard Biesheuvel
2023-01-24 22:33 ` [edk2-devel] " Lendacky, Thomas
2023-01-25 9:11 ` Gerd Hoffmann
2023-01-25 15:35 ` Lendacky, Thomas
2023-01-25 16:32 ` Lendacky, Thomas
2023-01-30 15:23 ` Laszlo Ersek
2023-01-30 15:24 ` Laszlo Ersek
2023-01-17 12:16 ` [PATCH v4 4/5] OvmfPkg/PlatformInitLib: Add PlatformReservationConflictCB Gerd Hoffmann
2023-01-17 15:05 ` Laszlo Ersek [this message]
2023-01-17 12:16 ` [PATCH v4 5/5] OvmfPkg/PlatformInitLib: reorder PlatformQemuUc32BaseInitialization Gerd Hoffmann
2023-01-17 14:49 ` Laszlo Ersek
2023-01-17 16:38 ` [edk2-devel] [PATCH v4 0/5] OvmfPkg: check 64bit mmio window for resource conflicts Ard Biesheuvel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=9cea31ea-eeb2-cdee-8df1-807b7592d196@redhat.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox