Enhanced SMT Protection (ESMTP) adds two VMSA fields that carry an SEV-SNP vCPU's co-residency policy. VCPU_ID identifies the vCPU within the guest and VCPU_SIBLING_MASK selects which of its peers it may share a physical core with. Two ESMTP vCPUs of the same guest are legal siblings when their VCPU_SIBLING_MASK values match and their VCPU_IDs agree outside that mask.
Add both fields to struct sev_es_save_area so that the guest can populate them in the AP VMSAs it builds and the hypervisor can populate them in the VMSAs it builds. Refer to the AMD64 APM Vol 2, section "AMD64 Enhanced SMT Protection". Reviewed-by: Tom Lendacky <[email protected]> Signed-off-by: Pratik R. Sampat <[email protected]> --- v4..v5: * Move the VCPU_ID/VCPU_SIBLING_MASK VMSA definitions out of the KVM host patch so that the guest side builds on its own. --- arch/x86/include/asm/svm.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/arch/x86/include/asm/svm.h b/arch/x86/include/asm/svm.h index 83fd49b26a4b..aceb405449a5 100644 --- a/arch/x86/include/asm/svm.h +++ b/arch/x86/include/asm/svm.h @@ -486,6 +486,11 @@ struct sev_es_save_area { u8 fpreg_x87[80]; u8 fpreg_xmm[256]; u8 fpreg_ymm[256]; + u8 reserved_0x670[560]; + + /* Enhanced SMT Protection */ + u32 vcpu_id; + u32 vcpu_sibling_mask; } __packed; struct ghcb_save_area { @@ -558,7 +563,7 @@ struct vmcb { #define EXPECTED_VMCB_SAVE_AREA_SIZE 744 #define EXPECTED_GHCB_SAVE_AREA_SIZE 1032 -#define EXPECTED_SEV_ES_SAVE_AREA_SIZE 1648 +#define EXPECTED_SEV_ES_SAVE_AREA_SIZE 2216 #define EXPECTED_VMCB_CONTROL_AREA_SIZE 1024 #define EXPECTED_GHCB_SIZE PAGE_SIZE @@ -593,6 +598,7 @@ static inline void __unused_size_checks(void) BUILD_BUG_RESERVED_OFFSET(sev_es_save_area, 0x320); BUILD_BUG_RESERVED_OFFSET(sev_es_save_area, 0x380); BUILD_BUG_RESERVED_OFFSET(sev_es_save_area, 0x3f0); + BUILD_BUG_RESERVED_OFFSET(sev_es_save_area, 0x670); BUILD_BUG_RESERVED_OFFSET(ghcb_save_area, 0x0); BUILD_BUG_RESERVED_OFFSET(ghcb_save_area, 0xcc); -- 2.43.0
