mirror of
https://github.com/acidanthera/audk.git
synced 2025-04-08 17:05:09 +02:00
MdePkg: Probe Cc guest in BaseIoLibIntrinsicSev
BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3902 Bad IO performance in SEC phase is observed after TDX features was introduced. (after commit b6b2de884864 - "MdePkg: Support mmio for Tdx guest in BaseIoLibIntrinsic"). This is because IsTdxGuest() will be called in each MMIO operation. It is trying to cache the result of the probe in the efi data segment. However, that doesn't work in SEC, because the data segment is read only (so the write seems to succeed but a read will always return the original value), leading to us calling TdIsEnabled() check for every mmio we do, which is causing the slowdown because it's very expensive. This patch is to call CcProbe instead of TdIsEnabled in IsTdxGuest. Null instance of CcProbe always returns CCGuestTypeNonEncrypted. Its OvmfPkg version returns the guest type in Ovmf work area. Cc: Michael D Kinney <michael.d.kinney@intel.com> Cc: Liming Gao <gaoliming@byosoft.com.cn> Cc: Zhiguang Liu <zhiguang.liu@intel.com> Cc: James Bottomley <jejb@linux.ibm.com> Cc: James Bottomley <James.Bottomley@HansenPartnership.com> Cc: Jiewen Yao <jiewen.yao@intel.com> Cc: Gerd Hoffmann <kraxel@redhat.com> Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn> Reviewed-by: Jiewen Yao <jiewen.yao@intel.com> Reviewed-by: Tom Lendacky <thomas.lendacky@amd.com> Signed-off-by: Min Xu <min.m.xu@intel.com>
This commit is contained in:
parent
2a7e1e890d
commit
7012cb73c4
@ -55,6 +55,7 @@
|
||||
DebugLib
|
||||
BaseLib
|
||||
RegisterFilterLib
|
||||
CcProbeLib
|
||||
|
||||
[LibraryClasses.X64]
|
||||
TdxLib
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include <Include/IndustryStandard/Tdx.h>
|
||||
#include <Library/TdxLib.h>
|
||||
#include <Register/Intel/Cpuid.h>
|
||||
#include <Library/CcProbeLib.h>
|
||||
#include "IoLibTdx.h"
|
||||
|
||||
// Size of TDVMCALL Access, including IO and MMIO
|
||||
@ -22,9 +23,6 @@
|
||||
#define TDVMCALL_ACCESS_READ 0
|
||||
#define TDVMCALL_ACCESS_WRITE 1
|
||||
|
||||
BOOLEAN mTdxEnabled = FALSE;
|
||||
BOOLEAN mTdxProbed = FALSE;
|
||||
|
||||
/**
|
||||
Check if it is Tdx guest.
|
||||
|
||||
@ -38,14 +36,7 @@ IsTdxGuest (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
if (mTdxProbed) {
|
||||
return mTdxEnabled;
|
||||
}
|
||||
|
||||
mTdxEnabled = TdIsEnabled ();
|
||||
mTdxProbed = TRUE;
|
||||
|
||||
return mTdxEnabled;
|
||||
return CcProbe () == CcGuestTypeIntelTdx;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user