[kvm-unit-tests PATCH 14/16] x86/sev: Use X86_PROPERTY_SEV_C_BIT to get the AMD SEV C-bit location
Sean Christopherson
seanjc at google.com
Thu May 29 15:19:27 PDT 2025
Use X86_PROPERTY_SEV_C_BIT instead of open coding equivalent functionality,
and delete the overly-verbose CPUID_FN_ENCRYPT_MEM_CAPAB macro.
Signed-off-by: Sean Christopherson <seanjc at google.com>
---
lib/x86/amd_sev.c | 10 +---------
lib/x86/amd_sev.h | 6 ------
2 files changed, 1 insertion(+), 15 deletions(-)
diff --git a/lib/x86/amd_sev.c b/lib/x86/amd_sev.c
index 4e89c84c..416e4423 100644
--- a/lib/x86/amd_sev.c
+++ b/lib/x86/amd_sev.c
@@ -33,19 +33,11 @@ bool amd_sev_enabled(void)
efi_status_t setup_amd_sev(void)
{
- struct cpuid cpuid_out;
-
if (!amd_sev_enabled()) {
return EFI_UNSUPPORTED;
}
- /*
- * Extract C-Bit position from ebx[5:0]
- * AMD64 Architecture Programmer's Manual Volume 3
- * - Section " Function 8000_001Fh - Encrypted Memory Capabilities"
- */
- cpuid_out = cpuid(CPUID_FN_ENCRYPT_MEM_CAPAB);
- amd_sev_c_bit_pos = (unsigned short)(cpuid_out.b & 0x3f);
+ amd_sev_c_bit_pos = this_cpu_property(X86_PROPERTY_SEV_C_BIT);
return EFI_SUCCESS;
}
diff --git a/lib/x86/amd_sev.h b/lib/x86/amd_sev.h
index defcda75..daa33a05 100644
--- a/lib/x86/amd_sev.h
+++ b/lib/x86/amd_sev.h
@@ -19,12 +19,6 @@
#include "asm/page.h"
#include "efi.h"
-/*
- * AMD Programmer's Manual Volume 3
- * - Section "Function 8000_001Fh - Encrypted Memory Capabilities"
- */
-#define CPUID_FN_ENCRYPT_MEM_CAPAB 0x8000001f
-
/*
* AMD Programmer's Manual Volume 2
* - Section "SEV_STATUS MSR"
--
2.49.0.1204.g71687c7c1d-goog
More information about the kvm-riscv
mailing list