From 76fda1def3d1baea3b01ae697687ff478d2d1b42 Mon Sep 17 00:00:00 2001 From: Min Xu Date: Tue, 19 Apr 2022 08:26:28 +0800 Subject: OvmfPkg: Call CcProbe in SecMain.c instead of TsIsEnabled BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3902 TdIsEnabled() uses the CPUID instruction. At this point, exception handling is not established and a CPUID instruction will generate a #VC and cause the booting guest to crash. CcProbe() checks Ovmf work area to return the guest type. So call of CcProbe() instead of TdIsEnabled() to fix the above issue. Cc: James Bottomley Cc: Jiewen Yao Cc: Gerd Hoffmann Cc: Brijesh Singh Cc: Erdem Aktas Cc: Tom Lendacky Reviewed-by: Jiewen Yao Reviewed-by: Tom Lendacky Signed-off-by: Min Xu --- OvmfPkg/IntelTdx/Sec/SecMain.c | 6 +++--- OvmfPkg/IntelTdx/Sec/SecMain.inf | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'OvmfPkg/IntelTdx/Sec') diff --git a/OvmfPkg/IntelTdx/Sec/SecMain.c b/OvmfPkg/IntelTdx/Sec/SecMain.c index 26d56be..ab01ec9 100644 --- a/OvmfPkg/IntelTdx/Sec/SecMain.c +++ b/OvmfPkg/IntelTdx/Sec/SecMain.c @@ -25,7 +25,7 @@ #include #include #include - +#include #include #define SEC_IDT_ENTRY_COUNT 34 @@ -61,7 +61,7 @@ SecCoreStartupWithStack ( UINT32 Index; volatile UINT8 *Table; - if (TdIsEnabled ()) { + if (CcProbe () == CcGuestTypeIntelTdx) { // // For Td guests, the memory map info is in TdHobLib. It should be processed // first so that the memory is accepted. Otherwise access to the unaccepted @@ -119,7 +119,7 @@ SecCoreStartupWithStack ( // AsmWriteIdtr (&IdtDescriptor); - if (TdIsEnabled ()) { + if (CcProbe () == CcGuestTypeIntelTdx) { // // InitializeCpuExceptionHandlers () should be called in Td guests so that // #VE exceptions can be handled correctly. diff --git a/OvmfPkg/IntelTdx/Sec/SecMain.inf b/OvmfPkg/IntelTdx/Sec/SecMain.inf index df2e749..9cf1249 100644 --- a/OvmfPkg/IntelTdx/Sec/SecMain.inf +++ b/OvmfPkg/IntelTdx/Sec/SecMain.inf @@ -49,6 +49,7 @@ CpuExceptionHandlerLib PeilessStartupLib PlatformInitLib + CcProbeLib [Pcd] gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPageTablesBase -- cgit v1.1