MdePkg/BaseLib: Add support for the XGETBV instruction

BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=2198

Under SEV-ES, a CPUID instruction requires the current value of the XCR0
register. In order to retrieve that value, the XGETBV instruction needs
to be executed.

Provide the necessary support to execute the XGETBV instruction.

Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com>
Regression-tested-by: Laszlo Ersek <lersek@redhat.com>
This commit is contained in:
Tom Lendacky
2020-08-12 15:21:35 -05:00
committed by mergify[bot]
parent b098f5e9e9
commit 9b3ca509ab
4 changed files with 84 additions and 0 deletions

View File

@@ -7831,6 +7831,23 @@ AsmLfence (
VOID
);
/**
Executes a XGETBV instruction
Executes a XGETBV instruction. This function is only available on IA-32 and
x64.
@param[in] Index Extended control register index
@return The current value of the extended control register
**/
UINT64
EFIAPI
AsmXGetBv (
IN UINT32 Index
);
/**
Patch the immediate operand of an IA32 or X64 instruction such that the byte,
word, dword or qword operand is encoded at the end of the instruction's