|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH v5 6/7] X86: MSR_IA32_BNDCFGS save/restore
From 9534eea44291058592904c9b4cd198f4ca12d10b Mon Sep 17 00:00:00 2001
From: Liu Jinsong <jinsong.liu@xxxxxxxxx>
Date: Wed, 4 Dec 2013 05:42:13 +0800
Subject: [PATCH v5 6/7] X86: MSR_IA32_BNDCFGS save/restore
Signed-off-by: Liu Jinsong <jinsong.liu@xxxxxxxxx>
---
xen/arch/x86/hvm/vmx/vmx.c | 44 +++++++++++++++++++++++++++----
xen/include/asm-x86/hvm/vmx/vmcs.h | 2 +
xen/include/public/arch-x86/hvm/save.h | 1 +
3 files changed, 41 insertions(+), 6 deletions(-)
diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c
index bac19f3..94ee359 100644
--- a/xen/arch/x86/hvm/vmx/vmx.c
+++ b/xen/arch/x86/hvm/vmx/vmx.c
@@ -580,19 +580,51 @@ static int vmx_load_vmcs_ctxt(struct vcpu *v, struct
hvm_hw_cpu *ctxt)
return 0;
}
-/* Temporarily NULL, could be added in the future */
static void vmx_save_msr(struct vcpu *v, struct hvm_msr *ctxt)
{
+ unsigned int b;
+
+ vmx_vmcs_enter(v);
+
+ /* save MSR_IA32_BNDCFGS */
+ hvm_cpuid(7, NULL, &b, NULL, NULL);
+ if ( b & cpufeat_mask(X86_FEATURE_MPX) )
+ {
+ ctxt->msr[ctxt->count].index = MSR_IA32_BNDCFGS;
+ __vmread(GUEST_BNDCFGS, &ctxt->msr[ctxt->count++].val);
+ }
+
+ vmx_vmcs_exit(v);
}
-/*
- * Temporarily NULL, could be added in the future:
- * For msr load fail, or msr not found, return error;
- * For msr load success, return 0;
- */
static int vmx_load_msr(struct vcpu *v, struct hvm_msr *ctxt)
{
+ unsigned int i, b;
+
+ vmx_vmcs_enter(v);
+
+ for ( i = 0; i < ctxt->count; i++ )
+ {
+ switch ( ctxt->msr[i].index )
+ {
+ case MSR_IA32_BNDCFGS:
+ hvm_cpuid(7, NULL, &b, NULL, NULL);
+ if ( !(b & cpufeat_mask(X86_FEATURE_MPX)) )
+ goto fail;
+ __vmwrite(GUEST_BNDCFGS, ctxt->msr[i].val);
+ break;
+ /* msr not found */
+ default:
+ goto fail;
+ }
+ }
+
+ vmx_vmcs_exit(v);
return 0;
+
+fail:
+ vmx_vmcs_exit(v);
+ return -EINVAL;
}
static void vmx_fpu_enter(struct vcpu *v)
diff --git a/xen/include/asm-x86/hvm/vmx/vmcs.h
b/xen/include/asm-x86/hvm/vmx/vmcs.h
index 75cd653..45dcfa1 100644
--- a/xen/include/asm-x86/hvm/vmx/vmcs.h
+++ b/xen/include/asm-x86/hvm/vmx/vmcs.h
@@ -367,6 +367,8 @@ enum vmcs_field {
GUEST_PDPTR2_HIGH = 0x0000280f,
GUEST_PDPTR3 = 0x00002810,
GUEST_PDPTR3_HIGH = 0x00002811,
+ GUEST_BNDCFGS = 0x00002812,
+ GUEST_BNDCFGS_HIGH = 0x00002813,
HOST_PAT = 0x00002c00,
HOST_PAT_HIGH = 0x00002c01,
HOST_EFER = 0x00002c02,
diff --git a/xen/include/public/arch-x86/hvm/save.h
b/xen/include/public/arch-x86/hvm/save.h
index e440eb5..9ed9b59 100644
--- a/xen/include/public/arch-x86/hvm/save.h
+++ b/xen/include/public/arch-x86/hvm/save.h
@@ -593,6 +593,7 @@ struct hvm_tsc_adjust {
DECLARE_HVM_SAVE_TYPE(TSC_ADJUST, 19, struct hvm_tsc_adjust);
enum {
+ HVM_MSR_BNDCFGS,
HVM_MSR_COUNT,
};
--
1.7.1
Attachment:
0006-X86-MSR_IA32_BNDCFGS-save-restore.patch _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |