[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20190522070101.7636-9-weijiang.yang@intel.com>
Date: Wed, 22 May 2019 15:01:01 +0800
From: Yang Weijiang <weijiang.yang@...el.com>
To: pbonzini@...hat.com, sean.j.christopherson@...el.com,
mst@...hat.com, rkrcmar@...hat.com, jmattson@...gle.com,
linux-kernel@...r.kernel.org, kvm@...r.kernel.org,
yu-cheng.yu@...el.com
Cc: weijiang.yang@...el.com
Subject: [PATCH v5 8/8] KVM: x86: Add user-space access interface for CET MSRs
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@...el.com>
---
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
Powered by blists - more mailing lists