clean up MSR save/restore code
v4 cover clean up MSR save/restore code
*** BLURB HERE ***
Paul Durrant (4):
x86: stop handling MSR_IA32_BNDCFGS save/restore in implementation
code
x86: move the saved value of MSR_IA32_XSS into struct vcpu_msrs
x86: stop handling MSR_IA32_XSS save/restore in implementation code
x86: remove defunct init/load/save_msr() hvm_funcs
xen/arch/x86/domain.c | 2 +- xen/arch/x86/hvm/hvm.c | 58 ++++++--------------------- xen/arch/x86/hvm/vmx/vmx.c | 73 ++-------------------------------- xen/arch/x86/msr.c | 38 ++++++++++++++++++ xen/include/asm-x86/hvm/hvm.h | 8 +--- xen/include/asm-x86/hvm/vcpu.h | 1 - xen/include/asm-x86/msr.h | 5 +++ 7 files changed, 63 insertions(+), 122 deletions(-)
---
v2:
- Drop patches #2 and #6 of the v1 series
Signature · 7 lines
2.20.1 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH v4 1/4 x86: stop handling MSR_IA32_BNDCFGS save/restore in implementation code
Saving and restoring the value of this MSR is currently handled by implementation-specific code despite it being architectural. This patch moves handling of accesses to this MSR from hvm.c into the msr.c, thus allowing the common MSR save/restore code to handle it.
NOTE: Because vmx_get/set_guest_bndcfgs() call vmx_vmcs_enter(), the
struct vcpu pointer passed in, and hence the vcpu pointer passed to guest_rdmsr() cannot be const.
---
Cc: Kevin Tian <[email protected]>
Cc: Jan Beulich <[email protected]>
Cc: Andrew Cooper <[email protected]>
Cc: Wei Liu <[email protected]>
Cc: "Roger Pau Monné" <[email protected]>
Cc: Jun Nakajima <[email protected]>
v4:
- Cosmetic re-arrangements and an additional ASSERT requested by Jan
v3:
- Address further comments from Jan
- Dropped Kevin's R-b because of change to vmx.c
v2:
- Addressed comments from Jan by largely removing hunks
- Keeping Kevin's R-b since remaining hunks in vmx.c are as before
--- xen/arch/x86/hvm/hvm.c | 14 ++------------ xen/arch/x86/hvm/vmx/vmx.c | 24 ++++-------------------- xen/arch/x86/msr.c | 20 ++++++++++++++++++++ xen/include/asm-x86/hvm/hvm.h | 4 ++-- 4 files changed, 28 insertions(+), 34 deletions(-)
xen/arch/x86/hvm/hvm.c +2 -12
@@ -1303,6 +1303,7 @@ static int hvm_load_cpu_xsave_states(struct domain *d, hvm_domain_context_t *h)static const uint32_t msrs_to_send[] = {MSR_SPEC_CTRL ,MSR_INTEL_MISC_FEATURES_ENABLES , +MSR_IA32_BNDCFGS ,MSR_AMD64_DR0_ADDRESS_MASK ,MSR_AMD64_DR1_ADDRESS_MASK ,MSR_AMD64_DR2_ADDRESS_MASK ,
@@ -1440,6 +1441,7 @@ static int hvm_load_cpu_msrs(struct domain *d, hvm_domain_context_t *h)case MSR_SPEC_CTRL :case MSR_INTEL_MISC_FEATURES_ENABLES : +case MSR_IA32_BNDCFGS :case MSR_AMD64_DR0_ADDRESS_MASK : case MSR_AMD64_DR1_ADDRESS_MASK ... MSR_AMD64_DR3_ADDRESS_MASK: rc =guest_wrmsr (v, ctxt->msr[i].index, ctxt->msr[i].val);
@@ -3467,12 +3469,6 @@ int hvm_msr_read_intercept(unsigned int msr, uint64_t *msr_content) *msr_content = v->arch.hvm.msr_xss;break ; -case MSR_IA32_BNDCFGS : -if ( !d->arch.cpuid->feat.mpx || - !hvm_get_guest_bndcfgs (v, msr_content) ) - goto gp_fault; -break ; -case MSR_K8_ENABLE_C1E :case MSR_AMD64_NB_CFG :/*
@@ -3619,12 +3615,6 @@ int hvm_msr_write_intercept(unsigned int msr, uint64_t msr_content, v->arch.hvm.msr_xss = msr_content;break ; -case MSR_IA32_BNDCFGS : -if ( !d->arch.cpuid->feat.mpx || - !hvm_set_guest_bndcfgs (v, msr_content) ) - goto gp_fault; -break ; -case MSR_AMD64_NB_CFG :/* ignore the write */ break ;
xen/arch/x86/hvm/vmx/vmx.c +4 -20
@@ -805,17 +805,6 @@ static unsigned int __init vmx_init_msr(void)static void vmx_save_msr (struct vcpu *v,struct hvm_msr *ctxt) { -vmx_vmcs_enter (v); - -if ( cpu_has_mpx && cpu_has_vmx_mpx ) - { -__vmread (GUEST_BNDCFGS , &ctxt->msr[ctxt->count].val); -if ( ctxt->msr[ctxt->count].val ) - ctxt->msr[ctxt->count++].index =MSR_IA32_BNDCFGS ; - } - -vmx_vmcs_exit (v); -if ( cpu_has_xsaves && cpu_has_vmx_xsaves ) { ctxt->msr[ctxt->count].val = v->arch.hvm.msr_xss;
@@ -835,14 +824,6 @@ static int vmx_load_msr(struct vcpu *v, struct hvm_msr *ctxt) {switch ( ctxt->msr[i].index ) { -case MSR_IA32_BNDCFGS : -if ( cpu_has_mpx && cpu_has_vmx_mpx && -is_canonical_address (ctxt->msr[i].val) && - !(ctxt->msr[i].val &IA32_BNDCFGS_RESERVED ) ) -__vmwrite (GUEST_BNDCFGS , ctxt->msr[i].val); -else if ( ctxt->msr[i].val ) - err = -ENXIO ; -break ;case MSR_IA32_XSS :if ( cpu_has_xsaves && cpu_has_vmx_xsaves ) v->arch.hvm.msr_xss = ctxt->msr[i].val;
@@ -1215,8 +1196,11 @@ static bool vmx_set_guest_bndcfgs(struct vcpu *v, u64 val)return true; } -static bool vmx_get_guest_bndcfgs (struct vcpu *v,u64 *val) +static bool vmx_get_guest_bndcfgs (const struct vcpu *cv,u64 *val) { +/* Get a non-const pointer for vmx_vmcs_enter() */ +struct vcpu *v = cv->domain->vcpu[cv->vcpu_id]; +ASSERT (cpu_has_mpx && cpu_has_vmx_mpx);vmx_vmcs_enter (v);
xen/arch/x86/msr.c +20 -0
@@ -160,6 +160,16 @@ int guest_rdmsr(const struct vcpu *v, uint32_t msr, uint64_t *val) ret =guest_rdmsr_x2apic (v, msr, val);break ; +case MSR_IA32_BNDCFGS : +if ( !cp->feat.mpx ) + goto gp_fault; + +ASSERT (is_hvm_domain (d)); +if (!hvm_get_guest_bndcfgs (v, val) ) + goto gp_fault; + +break ; + case 0x40000000 ... 0x400001ff:if (is_viridian_domain (d) ) {
@@ -323,6 +333,16 @@ int guest_wrmsr(struct vcpu *v, uint32_t msr, uint64_t val) ret =guest_wrmsr_x2apic (v, msr, val);break ; +case MSR_IA32_BNDCFGS : +if ( !cp->feat.mpx ) + goto gp_fault; + +ASSERT (is_hvm_domain (d)); +if ( !hvm_set_guest_bndcfgs (v, val) ) + goto gp_fault; + +break ; + case 0x40000000 ... 0x400001ff:if (is_viridian_domain (d) ) {
xen/include/asm-x86/hvm/hvm.h +2 -2
@@ -149,7 +149,7 @@ struct hvm_function_table {int (*get_guest_pat)(struct vcpu *v,u64 *);int (*set_guest_pat)(struct vcpu *v,u64 ); -bool (*get_guest_bndcfgs)(struct vcpu *v,u64 *); +bool (*get_guest_bndcfgs)(const struct vcpu *v,u64 *);bool (*set_guest_bndcfgs)(struct vcpu *v,u64 );void (*set_tsc_offset)(struct vcpu *v,u64 offset,u64 at_tsc);
@@ -448,7 +448,7 @@ static inline unsigned long hvm_get_shadow_gs_base(struct vcpu *v)return hvm_funcs.get_shadow_gs_base (v); } -static inline bool hvm_get_guest_bndcfgs (struct vcpu *v,u64 *val) +static inline bool hvm_get_guest_bndcfgs (const struct vcpu *v,u64 *val) {return hvm_funcs.get_guest_bndcfgs && hvm_funcs.get_guest_bndcfgs (v, val);
Signature · 7 lines
2.20.1 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH v4 1/4] x86: stop handling MSR_IA32_BNDCFGS save/restore in implementation code
Quoted 11 lines
Quoted 1 line
Quoted 1 line · On 14.03.19 at 14:51, <[email protected]> wrote:
Saving and restoring the value of this MSR is currently handled by implementation-specific code despite it being architectural. This patch moves handling of accesses to this MSR from
hvm.cinto themsr.c, thus allowing the common MSR save/restore code to handle it.NOTE: Because vmx_get/set_guest_bndcfgs() call
vmx_vmcs_enter(), the
struct vcpu pointer passed in, and hence the vcpu pointer passed toguest_rdmsr()cannot be const.Signed-off-by Paul Durrant <[email protected]>
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH v4 1/4] x86: stop handling MSR_IA32_BNDCFGS save/restore in implementation code
In reply to Paul DurrantQuoted 19 lines
Quoted 1 line
Quoted 1 line · On 14.03.19 at 14:51, <[email protected]> wrote:
Saving and restoring the value of this MSR is currently handled by implementation-specific code despite it being architectural. This patch moves handling of accesses to this MSR from
hvm.cinto themsr.c, thus allowing the common MSR save/restore code to handle it.NOTE: Because vmx_get/set_guest_bndcfgs() call
vmx_vmcs_enter(), the
struct vcpu pointer passed in, and hence the vcpu pointer passed toguest_rdmsr()cannot be const.Signed-off-by Paul Durrant <[email protected]>---
Cc: Kevin Tian <[email protected]>
Cc: Jan Beulich <[email protected]>
Cc: Andrew Cooper <[email protected]>
Cc: Wei Liu <[email protected]>
Cc: "Roger Pau Monné" <[email protected]>
Cc: Jun Nakajima <[email protected]>
Quoted 6 lines
v4:
- Cosmetic re-arrangements and an additional ASSERT requested by Janv3:
- Address further comments from Jan
- Dropped Kevin's R-b because of change tovmx.c
Kevin,
you may not have noticed the above.
Thanks, Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Tian, Kevin
Reviewed-byRe: [PATCH v4 1/4] x86: stop handling MSR_IA32_BNDCFGS save/restore in implementation code
Quoted 25 lines
From: Jan Beulich [mailto:[email protected]]
Sent: Friday, April 5, 2019 7:30 PMQuoted 22 lines
Quoted 1 line
Quoted 1 line · On 14.03.19 at 14:51, <[email protected]> wrote:
Saving and restoring the value of this MSR is currently handled by implementation-specific code despite it being architectural. This patch moves handling of accesses to this MSR from
hvm.cinto themsr.c, thus allowing the common MSR save/restore code to handle it.NOTE: Because vmx_get/set_guest_bndcfgs() call
vmx_vmcs_enter(), the
struct vcpu pointer passed in, and hence the vcpu pointer passed toguest_rdmsr()cannot be const.Signed-off-by Paul Durrant <[email protected]>---
Cc: Kevin Tian <[email protected]>
Cc: Jan Beulich <[email protected]>
Cc: Andrew Cooper <[email protected]>
Cc: Wei Liu <[email protected]>
Cc: "Roger Pau Monné" <[email protected]>
Cc: Jun Nakajima <[email protected]>v4:
- Cosmetic re-arrangements and an additional ASSERT requested by Jan
Quoted 8 lines
Quoted 3 lines
v3:
- Address further comments from Jan
- Dropped Kevin's R-b because of change tovmx.cKevin,
you may not have noticed the above.
yes indeed. Thanks for remind!
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH v4 1/4] x86: stop handling MSR_IA32_BNDCFGS save/restore in implementation code
In reply to Paul Durrantxen/arch/x86/hvm/vmx/vmx.c static bool vmx_set_guest_bndcfgs(struct vcpu *v, u64 val) · line 1203
Quoted 10 lines · Paul Durrant
xen/arch/x86/hvm/vmx/vmx.c +4
-1@@ -1215,8 +1196,11 @@ static bool vmx_set_guest_bndcfgs(struct vcpu *v, u64 val)return true; } -static bool vmx_get_guest_bndcfgs (struct vcpu *v,u64 *val) +static bool vmx_get_guest_bndcfgs (const struct vcpu *cv,u64 *val) { +/* Get a non-const pointer for vmx_vmcs_enter() */ +struct vcpu *v = cv->domain->vcpu[cv->vcpu_id]; +
I'm sorry not having got around to reviewing this series in a timely fashion, but I am going to specifically nack de-consting games like this. There is now vcpu state corruption when the MSR is accessed remotely - this hook *must* remain a mutable vcpu pointer.
There are also multiple other functional issues and regressions introduced by this series. I'm trying to put together a patch to fix all of the fallout, but I also might revert the series wholesale depending on the eventual complexity.
~Andrew
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH v4 1/4] x86: stop handling MSR_IA32_BNDCFGS save/restore in implementation code
Quoted 6 lines
Quoted 1 line
Quoted 1 line · On 09.04.19 at 16:38, <[email protected]> wrote:
Quoted 4 lines · Paul Durrant
xen/arch/x86/hvm/vmx/vmx.c +0
-0@@ -1215,8 +1196,11 @@ static bool vmx_set_guest_bndcfgs(struct vcpu *v, u64 val)return true; }
Quoted 11 lines
xen/arch/x86/hvm/vmx/vmx.c static bool vmx_set_guest_bndcfgs(struct vcpu *v, u64 val) · line 1203
Quoted 6 lines
xen/arch/x86/hvm/vmx/vmx.c +4
-1-static bool vmx_get_guest_bndcfgs (struct vcpu *v,u64 *val) +static bool vmx_get_guest_bndcfgs (const struct vcpu *cv,u64 *val) { +/* Get a non-const pointer for vmx_vmcs_enter() */ +struct vcpu *v = cv->domain->vcpu[cv->vcpu_id]; +I'm sorry not having got around to reviewing this series in a timely fashion, but I am going to specifically nack de-consting games like this. There is now vcpu state corruption when the MSR is accessed remotely - this hook *must* remain a mutable vcpu pointer.
Would you mind enlightening me how / what vCPU state corruption this is causing? There's no change in what struct vcpu instance is being acted upon, after all.
Quoted 4 lines
There are also multiple other functional issues and regressions introduced by this series. I'm trying to put together a patch to fix all of the fallout, but I also might revert the series wholesale depending on the eventual complexity.
I'm sorry for not spotting any of them; I'm curious to learn what I've missed.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH v4 2/4 x86: move the saved value of MSR_IA32_XSS into struct vcpu_msrs
In reply to Paul DurrantCurrently the value is saved directly in struct hvm_vcpu. This patch simply co-locates it with other saved MSR values. No functional change.
---
Cc: Andrew Cooper <[email protected]>
Cc: Wei Liu <[email protected]>
Cc: "Roger Pau Monné" <[email protected]>
Cc: Jun Nakajima <[email protected]>
--- xen/arch/x86/domain.c | 2 +- xen/arch/x86/hvm/hvm.c | 4 ++-- xen/arch/x86/hvm/vmx/vmx.c | 4 ++-- xen/include/asm-x86/hvm/vcpu.h | 1 - xen/include/asm-x86/msr.h | 5 +++++ 5 files changed, 10 insertions(+), 6 deletions(-)
xen/arch/x86/domain.c +1 -1
@@ -1653,7 +1653,7 @@ static void __context_switch(void)BUG ();if ( cpu_has_xsaves &&is_hvm_vcpu (n) ) -set_msr_xss (n->arch.hvm.msr_xss); +set_msr_xss (n->arch.msrs->xss.raw); }vcpu_restore_fpu_nonlazy (n, false); nd->arch.ctxt_switch->to (n);
xen/arch/x86/hvm/hvm.c +2 -2
@@ -3466,7 +3466,7 @@ int hvm_msr_read_intercept(unsigned int msr, uint64_t *msr_content)case MSR_IA32_XSS :if ( !d->arch.cpuid->xstate.xsaves ) goto gp_fault; - *msr_content = v->arch.hvm.msr_xss; + *msr_content = v->arch.msrs->xss.raw;break ;case MSR_K8_ENABLE_C1E :
@@ -3612,7 +3612,7 @@ int hvm_msr_write_intercept(unsigned int msr, uint64_t msr_content,/* No XSS features currently supported for guests. */ if ( !d->arch.cpuid->xstate.xsaves || msr_content !=0 ) goto gp_fault; - v->arch.hvm.msr_xss = msr_content; + v->arch.msrs->xss.raw = msr_content;break ;case MSR_AMD64_NB_CFG :
xen/arch/x86/hvm/vmx/vmx.c +2 -2
@@ -807,7 +807,7 @@ static void vmx_save_msr(struct vcpu *v, struct hvm_msr *ctxt) {if ( cpu_has_xsaves && cpu_has_vmx_xsaves ) { - ctxt->msr[ctxt->count].val = v->arch.hvm.msr_xss; + ctxt->msr[ctxt->count].val = v->arch.msrs->xss.raw;if ( ctxt->msr[ctxt->count].val ) ctxt->msr[ctxt->count++].index =MSR_IA32_XSS ; }
@@ -826,7 +826,7 @@ static int vmx_load_msr(struct vcpu *v, struct hvm_msr *ctxt) {case MSR_IA32_XSS :if ( cpu_has_xsaves && cpu_has_vmx_xsaves ) - v->arch.hvm.msr_xss = ctxt->msr[i].val; + v->arch.msrs->xss.raw = ctxt->msr[i].val;else err = -ENXIO ;break ;
xen/include/asm-x86/hvm/vcpu.h +0 -1
@@ -176,7 +176,6 @@ struct hvm_vcpu {struct hvm_vcpu_asid n1asid;u64 msr_tsc_adjust; -u64 msr_xss;union {struct vmx_vcpu vmx;
xen/include/asm-x86/msr.h +5 -0
@@ -313,6 +313,11 @@ struct vcpu_msrs* values here may be stale in current context. */ uint32_t dr_mask[4 ]; + +/* 0x00000da0 - MSR_IA32_XSS */ +struct { +uint64_t raw; + } xss; };void init_guest_msr_policy (void );
Signature · 7 lines
2.20.1 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH v4 3/4 x86: stop handling MSR_IA32_XSS save/restore in implementation code
In reply to Paul DurrantSaving and restoring the value of this MSR is currently handled by implementation-specific code despite it being architectural. This patch moves handling of accesses to this MSR from hvm.c into the msr.c, thus allowing the common MSR save/restore code to handle it.
This patch also adds proper checks of CPUID policy in the new get/set code.
NOTE: MSR_IA32_XSS is the last MSR to be saved and restored by
implementation-specific code. This patch therefore removes the (VMX) definitions and of the init_msr(), save_msr() and load_msr() hvm_funcs, as they are no longer necessary. The declarations of and calls to those hvm_funcs will be cleaned up by a subsequent patch.
---
Cc: Andrew Cooper <[email protected]>
Cc: Wei Liu <[email protected]>
Cc: "Roger Pau Monné" <[email protected]>
Cc: Jun Nakajima <[email protected]>
--- xen/arch/x86/hvm/hvm.c | 15 ++---------- xen/arch/x86/hvm/vmx/vmx.c | 49 -------------------------------------- xen/arch/x86/msr.c | 18 ++++++++++++++ 3 files changed, 20 insertions(+), 62 deletions(-)
xen/arch/x86/hvm/hvm.c +2 -13
@@ -1304,6 +1304,7 @@ static const uint32_t msrs_to_send[] = {MSR_SPEC_CTRL ,MSR_INTEL_MISC_FEATURES_ENABLES ,MSR_IA32_BNDCFGS , +MSR_IA32_XSS ,MSR_AMD64_DR0_ADDRESS_MASK ,MSR_AMD64_DR1_ADDRESS_MASK , MSR_AMD64_DR2_ADDRESS_MASK,
@@ -1442,6 +1443,7 @@ static int hvm_load_cpu_msrs(struct domain *d, hvm_domain_context_t *h)case MSR_SPEC_CTRL :case MSR_INTEL_MISC_FEATURES_ENABLES :case MSR_IA32_BNDCFGS : +case MSR_IA32_XSS :case MSR_AMD64_DR0_ADDRESS_MASK : case MSR_AMD64_DR1_ADDRESS_MASK ... MSR_AMD64_DR3_ADDRESS_MASK: rc =guest_wrmsr (v, ctxt->msr[i].index, ctxt->msr[i].val);
@@ -3463,12 +3465,6 @@ int hvm_msr_read_intercept(unsigned int msr, uint64_t *msr_content) MTRRcap_VCNT))];break ; -case MSR_IA32_XSS : -if ( !d->arch.cpuid->xstate.xsaves ) - goto gp_fault; - *msr_content = v->arch.msrs->xss.raw; -break ; -case MSR_K8_ENABLE_C1E :case MSR_AMD64_NB_CFG :/*
@@ -3608,13 +3604,6 @@ int hvm_msr_write_intercept(unsigned int msr, uint64_t msr_content, goto gp_fault;break ; -case MSR_IA32_XSS : -/* No XSS features currently supported for guests. */ -if ( !d->arch.cpuid->xstate.xsaves || msr_content !=0 ) - goto gp_fault; - v->arch.msrs->xss.raw = msr_content; -break ; -case MSR_AMD64_NB_CFG :/* ignore the write */ break ;
xen/arch/x86/hvm/vmx/vmx.c +0 -49
61 lines not on this page · raw message
xen/arch/x86/msr.c +18 -0
@@ -170,6 +170,13 @@ int guest_rdmsr(const struct vcpu *v, uint32_t msr, uint64_t *val)break ; +case MSR_IA32_XSS : +if ( !cp->xstate.xsaves ) + goto gp_fault; + + *val = msrs->xss.raw; +break ; + case 0x40000000 ... 0x400001ff:if (is_viridian_domain (d) ) {
@@ -343,6 +350,17 @@ int guest_wrmsr(struct vcpu *v, uint32_t msr, uint64_t val)break ; +case MSR_IA32_XSS : +if ( !cp->xstate.xsaves ) + goto gp_fault; + +/* No XSS features currently supported for guests */ +if ( val !=0 ) + goto gp_fault; + + msrs->xss.raw = val; +break ; + case 0x40000000 ... 0x400001ff:if (is_viridian_domain (d) ) {
Signature · 7 lines
2.20.1 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH v4 4/4 x86: remove defunct init/load/save_msr() hvm_funcs
In reply to Paul DurrantThese hvm_funcs are no longer required since no MSR values are saved or restored by implementation-specific code.
---
Cc: Andrew Cooper <[email protected]>
Cc: Wei Liu <[email protected]>
Cc: "Roger Pau Monné" <[email protected]>
v2:
- Re-instate err check on loop in hvm_load_cpu_msrs()
--- xen/arch/x86/hvm/hvm.c | 29 +++++++++-------------------- xen/include/asm-x86/hvm/hvm.h | 4 ---- 2 files changed, 9 insertions(+), 24 deletions(-)
xen/arch/x86/hvm/hvm.c +9 -20
@@ -1310,7 +1310,6 @@ static const uint32_t msrs_to_send[] = {MSR_AMD64_DR2_ADDRESS_MASK , MSR_AMD64_DR3_ADDRESS_MASK, }; -static unsigned int __read_mostly msr_count_max =ARRAY_SIZE (msrs_to_send);static int hvm_save_cpu_msrs (struct vcpu *v,hvm_domain_context_t *h) {
@@ -1320,7 +1319,7 @@ static int hvm_save_cpu_msrs(struct vcpu *v, hvm_domain_context_t *h)int err; err =_hvm_init_entry (h,CPU_MSR_CODE , v->vcpu_id, -HVM_CPU_MSR_SIZE (msr_count_max)); +HVM_CPU_MSR_SIZE (ARRAY_SIZE (msrs_to_send)));if ( err )return err; ctxt = (struct hvm_msr *)&h->data[h->cur];
@@ -1353,10 +1352,7 @@ static int hvm_save_cpu_msrs(struct vcpu *v, hvm_domain_context_t *h) ctxt->msr[ctxt->count++].val = val; } -if ( hvm_funcs.save_msr ) - hvm_funcs.save_msr (v, ctxt); - -ASSERT (ctxt->count <= msr_count_max); +ASSERT (ctxt->count <=ARRAY_SIZE (msrs_to_send));for ( i =0 ; i < ctxt->count; ++i ) ctxt->msr[i]._rsvd =0 ;
@@ -1431,9 +1427,6 @@ static int hvm_load_cpu_msrs(struct domain *d, hvm_domain_context_t *h)return -EOPNOTSUPP ;/* Checking finished */ -if ( hvm_funcs.load_msr ) - err = hvm_funcs.load_msr (v, ctxt); -for ( i =0 ; !err && i < ctxt->count; ++i ) { switch ( ctxt->msr[i].index )
@@ -1475,17 +1468,13 @@ static int __init hvm_register_CPU_save_and_restore(void)sizeof (struct hvm_save_descriptor ), HVMSR_PER_VCPU); -if ( hvm_funcs.init_msr ) - msr_count_max += hvm_funcs.init_msr (); - -if ( msr_count_max ) -hvm_register_savevm (CPU_MSR_CODE , -"CPU_MSR" , - hvm_save_cpu_msrs, - hvm_load_cpu_msrs, -HVM_CPU_MSR_SIZE (msr_count_max) + -sizeof (struct hvm_save_descriptor ), -HVMSR_PER_VCPU ); +hvm_register_savevm (CPU_MSR_CODE , +"CPU_MSR" , + hvm_save_cpu_msrs, + hvm_load_cpu_msrs, +HVM_CPU_MSR_SIZE (ARRAY_SIZE (msrs_to_send)) + +sizeof (struct hvm_save_descriptor ), +HVMSR_PER_VCPU );return 0 ; }
xen/include/asm-x86/hvm/hvm.h +0 -4
@@ -115,10 +115,6 @@ struct hvm_function_table {void (*save_cpu_ctxt)(struct vcpu *v,struct hvm_hw_cpu *ctxt);int (*load_cpu_ctxt)(struct vcpu *v,struct hvm_hw_cpu *ctxt); -unsigned int (*init_msr)(void ); -void (*save_msr)(struct vcpu *,struct hvm_msr *); -int (*load_msr)(struct vcpu *,struct hvm_msr *); -/* Examine specifics of the guest state. */ unsigned int (*get_interrupt_shadow)(struct vcpu *v);void (*set_interrupt_shadow)(struct vcpu *v,unsigned int intr_shadow);
Signature · 7 lines
2.20.1 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel