There're two different places storing Guest CET states, the states managed with XSAVES/XRSTORS, as restored/saved in previous patch, can be read/write directly from/to the MSRs. For those stored in VMCS fields, they're access via vmcs_read/ vmcs_write. Signed-off-by: Yang Weijiang <weijiang.yang@xxxxxxxxx> --- arch/x86/include/asm/msr-index.h | 2 ++ arch/x86/kvm/vmx/vmx.c | 43 ++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/arch/x86/include/asm/msr-index.h b/arch/x86/include/asm/msr-index.h index dc0a67c1ed80..53a4ef337846 100644 --- a/arch/x86/include/asm/msr-index.h +++ b/arch/x86/include/asm/msr-index.h @@ -827,6 +827,8 @@ #define MSR_IA32_U_CET 0x6a0 /* user mode cet setting */ #define MSR_IA32_S_CET 0x6a2 /* kernel mode cet setting */ #define MSR_IA32_PL0_SSP 0x6a4 /* kernel shstk pointer */ +#define MSR_IA32_PL1_SSP 0x6a5 /* ring 1 shstk pointer */ +#define MSR_IA32_PL2_SSP 0x6a6 /* ring 2 shstk pointer */ #define MSR_IA32_PL3_SSP 0x6a7 /* user shstk pointer */ #define MSR_IA32_INT_SSP_TAB 0x6a8 /* exception shstk table */ diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c index dec6bda20235..233f58af3878 100644 --- a/arch/x86/kvm/vmx/vmx.c +++ b/arch/x86/kvm/vmx/vmx.c @@ -1777,6 +1777,27 @@ static int vmx_get_msr(struct kvm_vcpu *vcpu, struct msr_data *msr_info) else msr_info->data = vmx->pt_desc.guest.addr_a[index / 2]; break; + case MSR_IA32_S_CET: + msr_info->data = vmcs_readl(GUEST_S_CET); + break; + case MSR_IA32_U_CET: + rdmsrl(MSR_IA32_U_CET, msr_info->data); + break; + case MSR_IA32_INT_SSP_TAB: + msr_info->data = vmcs_readl(GUEST_INTR_SSP_TABLE); + break; + case MSR_IA32_PL0_SSP: + rdmsrl(MSR_IA32_PL0_SSP, msr_info->data); + break; + case MSR_IA32_PL1_SSP: + rdmsrl(MSR_IA32_PL1_SSP, msr_info->data); + break; + case MSR_IA32_PL2_SSP: + rdmsrl(MSR_IA32_PL2_SSP, msr_info->data); + break; + case MSR_IA32_PL3_SSP: + rdmsrl(MSR_IA32_PL3_SSP, msr_info->data); + break; case MSR_TSC_AUX: if (!msr_info->host_initiated && !guest_cpuid_has(vcpu, X86_FEATURE_RDTSCP)) @@ -2012,6 +2033,28 @@ static int vmx_set_msr(struct kvm_vcpu *vcpu, struct msr_data *msr_info) else vmx->pt_desc.guest.addr_a[index / 2] = data; break; + case MSR_IA32_S_CET: + vmcs_writel(GUEST_S_CET, data); + break; + case MSR_IA32_U_CET: + wrmsrl(MSR_IA32_U_CET, data); + break; + case MSR_IA32_INT_SSP_TAB: + vmcs_writel(GUEST_INTR_SSP_TABLE, data); + break; + case MSR_IA32_PL0_SSP: + wrmsrl(MSR_IA32_PL0_SSP, data); + break; + case MSR_IA32_PL1_SSP: + wrmsrl(MSR_IA32_PL1_SSP, data); + break; + case MSR_IA32_PL2_SSP: + wrmsrl(MSR_IA32_PL2_SSP, data); + break; + case MSR_IA32_PL3_SSP: + wrmsrl(MSR_IA32_PL3_SSP, data); + break; + case MSR_TSC_AUX: if (!msr_info->host_initiated && !guest_cpuid_has(vcpu, X86_FEATURE_RDTSCP)) -- 2.17.2