summaryrefslogtreecommitdiffstats
path: root/UefiCpuPkg/Library
diff options
context:
space:
mode:
authorMin M Xu <min.m.xu@intel.com>2024-09-09 13:33:51 +0800
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2024-09-20 02:24:06 +0000
commit3a3b12cbdae2e89b0e365eb01c378891d0d9037c (patch)
tree3b9be0a24f54028c0292fdc1ab93140c48557bf0 /UefiCpuPkg/Library
parentff8a7d101f7d892dea96254bc1309c1a7c502e02 (diff)
downloadedk2-3a3b12cbdae2e89b0e365eb01c378891d0d9037c.tar.gz
edk2-3a3b12cbdae2e89b0e365eb01c378891d0d9037c.tar.bz2
edk2-3a3b12cbdae2e89b0e365eb01c378891d0d9037c.zip
UefiCpuPkg/MtrrLib: MtrrLibIsMtrrSupported always return FALSE in TD-Guest
Currently, TDX exposes MTRR CPUID bit to TDX VM. So based on the CPUID, the guest software components (OVMF/TDVF and guest kernel) will access MTRR MSRs. One problem for guest to use of MTRR is the change of MTRR setting needs to set CR0.CD=1, which will case #VE for TDX. For Linux kernel, there is a mechanism called SW defined MTRR introduced by the patch https://lore.kernel.org/all/20230502120931. 20719-4-jgross@suse.com/. If this is integrated for TDX guest, then Linux kernel will not access any MTRR MSRs. So we update MtrrLibIsMtrrSupported() to always return false for TD-Guest, then TDVF will not access MTRR MSRs at all. Cc: Ray Ni <ray.ni@intel.com> Cc: Rahul Kumar <rahul1.kumar@intel.com> Cc: Gerd Hoffmann <kraxel@redhat.com> Cc: Jiaxin Wu <jiaxin.wu@intel.com> Cc: Jiewen Yao <jiewen.yao@intel.com> Cc: Binbin Wu <binbin.wu@intel.com> Signed-off-by: Min Xu <min.m.xu@intel.com>
Diffstat (limited to 'UefiCpuPkg/Library')
-rw-r--r--UefiCpuPkg/Library/MtrrLib/MtrrLib.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/UefiCpuPkg/Library/MtrrLib/MtrrLib.c b/UefiCpuPkg/Library/MtrrLib/MtrrLib.c
index 4d4b52a4c3..61af77d9de 100644
--- a/UefiCpuPkg/Library/MtrrLib/MtrrLib.c
+++ b/UefiCpuPkg/Library/MtrrLib/MtrrLib.c
@@ -162,6 +162,13 @@ MtrrLibIsMtrrSupported (
MSR_IA32_MTRRCAP_REGISTER MtrrCap;
//
+ // MTRR is not supported in TD-Guest.
+ //
+ if (TdIsEnabled ()) {
+ return FALSE;
+ }
+
+ //
// Check CPUID(1).EDX[12] for MTRR capability
//
AsmCpuid (CPUID_VERSION_INFO, NULL, NULL, NULL, &Edx.Uint32);