From nobody Tue Feb 10 05:44:22 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+98678+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+98678+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1673957800; cv=none; d=zohomail.com; s=zohoarc; b=LM3/QRIgPZdNI4tkXnV1nP4Opcinjw3pUJJJvAt0kdb49FieDUfYKtbnewP9Z8YjSu/T2SqGIqCv6soG8ynweR0XVSvSR5bUly2hkI1imex4sogmylre/u3BacozKo/QnbuJuPGKuQehVG863kkkCswcwm2JCKiooy3D0XTtpYw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1673957800; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=UVfsK+sMntz644enEmUT2OOL8IlCXoKiQ+rEPmfDm84=; b=DxaHUs4xpIV88MzDM2Z4IDs6wrF46w7YmoE93pMm7hb0pWGWXPucTVonCpV6zaAcgNPaxh9TTofeB89Qf2RxCMuhCvvuh9+H+7BZXKSikPOYc9HYIUkzkZuiYeZl09Jxn9mSwdte0588e6+sHofLxL5zUo9SiVPEaP7O7MKA604= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+98678+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1673957800080662.1279257535924; Tue, 17 Jan 2023 04:16:40 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id arAeYY1788612xp5BPL3SYEr; Tue, 17 Jan 2023 04:16:39 -0800 X-Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.groups.io with SMTP id smtpd.web10.194535.1673957798911350131 for ; Tue, 17 Jan 2023 04:16:39 -0800 X-Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-591-3CXc4kqeN1mHpBv0FR2gkA-1; Tue, 17 Jan 2023 07:16:35 -0500 X-MC-Unique: 3CXc4kqeN1mHpBv0FR2gkA-1 X-Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C281A2A59566; Tue, 17 Jan 2023 12:16:34 +0000 (UTC) X-Received: from sirius.home.kraxel.org (unknown [10.39.192.124]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8B5B32026D4B; Tue, 17 Jan 2023 12:16:34 +0000 (UTC) X-Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 047091801ABE; Tue, 17 Jan 2023 13:16:30 +0100 (CET) From: "Gerd Hoffmann" To: devel@edk2.groups.io Cc: Jiewen Yao , Oliver Steffen , =?UTF-8?q?L=C3=A1szl=C3=B3=20=C3=89rsek?= , Ard Biesheuvel , Pawel Polawski , Jordan Justen , Gerd Hoffmann Subject: [edk2-devel] [PATCH v4 4/5] OvmfPkg/PlatformInitLib: Add PlatformReservationConflictCB Date: Tue, 17 Jan 2023 13:16:28 +0100 Message-Id: <20230117121629.2149112-5-kraxel@redhat.com> In-Reply-To: <20230117121629.2149112-1-kraxel@redhat.com> References: <20230117121629.2149112-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,kraxel@redhat.com X-Gm-Message-State: tuN0JCSU6o6OGHuitewKANInx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1673957799; bh=wLzfvU3dLz3KbKkupbM3hkGO360b5kNoUg/9aI6vJQg=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=WwJH/oe1279R4IgcC6rSeARWS+ILWEcn5tLClBZt4XMth4XYo509j7+EpS8KsYjPOWu zvrIJfgx09rfMTTaPrwoOKthmoHFlBToyC5IjEZ47AdQ35kjZWrCo2ML3qgjCSICPehX1 cRBF0AwrjZc5gYmpIfomPv0hT2QIbLJzWzQ= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1673957800705100018 Content-Type: text/plain; charset="utf-8"; x-default="true" 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=3D4251 Signed-off-by: Gerd Hoffmann Reviewed-by: Laszlo Ersek --- 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 ( } } =20 +/** + 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 =3D MAX ( + E820Entry->BaseAddr, + PlatformInfoHob->PcdPciMmio64Base + ); + IntersectionEnd =3D MIN ( + E820Entry->BaseAddr + E820Entry->Length, + PlatformInfoHob->PcdPciMmio64Base + + PlatformInfoHob->PcdPciMmio64Size + ); + + if (IntersectionBase >=3D IntersectionEnd) { + return; // no overlap + } + + NewBase =3D E820Entry->BaseAddr - PlatformInfoHob->PcdPciMmio64Size; + NewBase =3D NewBase & ~(PlatformInfoHob->PcdPciMmio64Size - 1); + + DEBUG (( + DEBUG_INFO, + "%a: move mmio: 0x%Lx =3D> %Lx\n", + __FUNCTION__, + PlatformInfoHob->PcdPciMmio64Base, + NewBase + )); + PlatformInfoHob->PcdPciMmio64Base =3D 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__, Mmi= oSpace, RShiftU64 (MmioSpace, 30))); PlatformInfoHob->PcdPciMmio64Size =3D MmioSpace; PlatformInfoHob->PcdPciMmio64Base =3D AddrSpace - MmioSpace; + PlatformScanE820 (PlatformReservationConflictCB, PlatformInfoHob); } else { DEBUG ((DEBUG_INFO, "%a: using classic mmio window\n", __func__)); } --=20 2.39.0 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#98678): https://edk2.groups.io/g/devel/message/98678 Mute This Topic: https://groups.io/mt/96328407/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-