Skip to content

Commit

Permalink
UefiCpuPkg/MtrrLib: MtrrLibIsMtrrSupported always return FALSE in TD-…
Browse files Browse the repository at this point in the history
…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.
[email protected]/. 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 <[email protected]>
Cc: Rahul Kumar <[email protected]>
Cc: Gerd Hoffmann <[email protected]>
Cc: Jiaxin Wu <[email protected]>
Cc: Jiewen Yao <[email protected]>
Cc: Binbin Wu <[email protected]>
Signed-off-by: Min Xu <[email protected]>
  • Loading branch information
mxu9 authored and mergify[bot] committed Sep 20, 2024
1 parent ff8a7d1 commit 3a3b12c
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions UefiCpuPkg/Library/MtrrLib/MtrrLib.c
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,13 @@ MtrrLibIsMtrrSupported (
CPUID_VERSION_INFO_EDX Edx;
MSR_IA32_MTRRCAP_REGISTER MtrrCap;

//
// MTRR is not supported in TD-Guest.
//
if (TdIsEnabled ()) {
return FALSE;
}

//
// Check CPUID(1).EDX[12] for MTRR capability
//
Expand Down

0 comments on commit 3a3b12c

Please sign in to comment.