Skip to content

Commit 18b5b14

Browse files
Lee, Chun-Yimergify[bot]
authored andcommitted
OvmfPkg/IncompatiblePciDeviceSupportDxe: Ignore OptionRom in Sev guest
Reference: https://bugzilla.tianocore.org/show_bug.cgi?id=4031 This patch is similar to the c477b27 patch for Td guest. Host VMM may inject OptionRom which is untrusted in Sev guest. So PCI OptionRom needs to be ignored if it is Sev guest. According to "Table 20. ACPI 2.0 & 3.0 QWORD Address Space Descriptor Usage" PI spec 1.7, type-specific flags can be set to 0 when Address Translation Offset == 6 to skip device option ROM. Without this patch, Sev guest may shows invalid MMIO opcode error as following: Invalid MMIO opcode (F6) ASSERT /home/abuild/rpmbuild/BUILD/edk2-edk2-stable202202/OvmfPkg/Library/VmgExitLib/VmgExitVcHandler.c(1041): ((BOOLEAN)(0==1)) The OptionRom must be disabled both on Td and Sev guests, so we direct use CcProbe(). Signed-off-by: "Lee, Chun-Yi" <jlee@suse.com> Reviewed-by: Gerd Hoffmann <kraxel@redhat.com>
1 parent f7da805 commit 18b5b14

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

OvmfPkg/IncompatiblePciDeviceSupportDxe/IncompatiblePciDeviceSupport.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include <Library/MemoryAllocationLib.h>
1919
#include <Library/PcdLib.h>
2020
#include <Library/UefiBootServicesTableLib.h>
21+
#include <Library/CcProbeLib.h>
2122

2223
#include <Protocol/IncompatiblePciDeviceSupport.h>
2324
#include <Protocol/LegacyBios.h>
@@ -264,7 +265,7 @@ CheckDevice (
264265
//
265266
// In Td guest OptionRom is not allowed.
266267
//
267-
if (TdIsEnabled ()) {
268+
if (CcProbe ()) {
268269
Length += sizeof mOptionRomConfiguration;
269270
}
270271

@@ -286,7 +287,7 @@ CheckDevice (
286287
CopyMem (Ptr, &mMmio64Configuration, sizeof mMmio64Configuration);
287288
Length = sizeof mMmio64Configuration;
288289

289-
if (TdIsEnabled ()) {
290+
if (CcProbe ()) {
290291
CopyMem (Ptr + Length, &mOptionRomConfiguration, sizeof mOptionRomConfiguration);
291292
Length += sizeof mOptionRomConfiguration;
292293
}

OvmfPkg/IncompatiblePciDeviceSupportDxe/IncompatiblePciDeviceSupport.inf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
OvmfPkg/OvmfPkg.dec
2525

2626
[LibraryClasses]
27+
CcProbeLib
2728
DebugLib
2829
MemoryAllocationLib
2930
PcdLib

0 commit comments

Comments
 (0)