OvmfPkg/CcExitLib: Use the proper register when filtering MSRs

The MsrExit() routine uses an incorrect register to check for the CAA MSR.
Instead of checking RCX, the input register for RDMSR/WRMSR that holds the
MSR value, it is checking RAX, which results in failure to detect the CAA
MSR request. The check should only be checking the lower 32-bits of the
register (ECX), too.

Change the check in MsrExit() to check the MSR value contained in ECX.

Fixes: 47001ab989 ("Ovmfpkg/CcExitLib: Provide SVSM discovery support")
Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com>
This commit is contained in:
Tom Lendacky 2025-04-25 12:49:52 -05:00 committed by mergify[bot]
parent 956ef6cd8b
commit 856bdc8eec

View file

@ -701,6 +701,7 @@ MsrExit (
MSR_SVSM_CAA_REGISTER Msr;
UINT64 ExitInfo1;
UINT64 Status;
UINT32 EcxIn;
ExitInfo1 = 0;
@ -708,7 +709,8 @@ MsrExit (
// The SVSM CAA MSR is a software implemented MSR and not supported
// by the hardware, handle it directly.
//
if (Regs->Rax == MSR_SVSM_CAA) {
EcxIn = (UINT32)(UINTN)Regs->Rcx;
if (EcxIn == MSR_SVSM_CAA) {
// Writes to the SVSM CAA MSR are ignored
if (*(InstructionData->OpCodes + 1) == 0x30) {
return 0;