clean up MSR save/restore code
v2 cover clean up MSR save/restore code
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 | 68 ---------------------------------- xen/arch/x86/msr.c | 34 ++++++++++++++++- xen/arch/x86/pv/emul-priv-op.c | 2 +- xen/include/asm-x86/hvm/hvm.h | 4 -- xen/include/asm-x86/hvm/vcpu.h | 1 - xen/include/asm-x86/msr.h | 7 +++- 8 files changed, 54 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 v2 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: 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]>
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 | 19 ------------------- xen/arch/x86/msr.c | 16 +++++++++++++++- xen/arch/x86/pv/emul-priv-op.c | 2 +- xen/include/asm-x86/msr.h | 2 +- 5 files changed, 19 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 +0 -19
@@ -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;
xen/arch/x86/msr.c +15 -1
@@ -115,7 +115,7 @@ int init_vcpu_msr_policy(struct vcpu *v)return 0 ; } -int guest_rdmsr (const struct vcpu *v,uint32_t msr,uint64_t *val) +int guest_rdmsr (struct vcpu *v,uint32_t msr,uint64_t *val) {const struct vcpu *curr = current;const struct domain *d = v->domain;
@@ -158,6 +158,13 @@ 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 ( !is_hvm_domain (d) || !cp->feat.mpx || + !hvm_get_guest_bndcfgs (v, val) ) + goto gp_fault; + +break ; + case 0x40000000 ... 0x400001ff:if (is_viridian_domain (d) ) {
@@ -319,6 +326,13 @@ 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 ( !is_hvm_domain (d) || !cp->feat.mpx || + !hvm_set_guest_bndcfgs (v, val) ) + goto gp_fault; + +break ; + case 0x40000000 ... 0x400001ff:if (is_viridian_domain (d) ) {
xen/arch/x86/pv/emul-priv-op.c +1 -1
@@ -819,7 +819,7 @@ static inline bool is_cpufreq_controller(const struct domain *d)static int read_msr (unsigned int reg,uint64_t *val,struct x86_emulate_ctxt *ctxt) { -const struct vcpu *curr = current; +struct vcpu *curr = current;const struct domain *currd = curr->domain;bool vpmu_msr = false;int ret;
xen/include/asm-x86/msr.h +1 -1
@@ -328,7 +328,7 @@ int init_vcpu_msr_policy(struct vcpu *v);* These functions are also used by the migration logic, so need to cope with * being used outside of v's context. */ -int guest_rdmsr (const struct vcpu *v,uint32_t msr,uint64_t *val); +int guest_rdmsr (struct vcpu *v,uint32_t msr,uint64_t *val);int guest_wrmsr (struct vcpu *v,uint32_t msr,uint64_t val);#endif /* !__ASSEMBLY__ */
Signature · 7 lines
2.20.1 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH v2 1/4] x86: stop handling MSR_IA32_BNDCFGS save/restore in implementation code
Quoted 3 lines
Quoted 1 line
Quoted 1 line · On 11.03.19 at 19:09, <[email protected]> wrote:
v2:
- Addressed comments from Jan by largely removing hunks
I think you've removed more than I was expecting, but I'm fine this way.
Quoted 15 lines
xen/arch/x86/msr.c +7
-0@@ -158,6 +158,13 @@ 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 ( !is_hvm_domain (d) || !cp->feat.mpx || + !hvm_get_guest_bndcfgs (v, val) ) + goto gp_fault; + +break ; + case 0x40000000 ... 0x400001ff:if (is_viridian_domain (d) ) {
xen/arch/x86/msr.c int guest_wrmsr(struct vcpu *v, uint32_t msr, uint64_t val) · line 332
Quoted 7 lines
xen/arch/x86/msr.c +4
-0@@ -319,6 +326,13 @@ 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 ( !is_hvm_domain (d) || !cp->feat.mpx || + !hvm_set_guest_bndcfgs (v, val) ) + goto gp_fault;
In both cases the is_hvm_*() check looks to be redundant, as for PV guests cp->feat.mpx can't be set. Personally I'd prefer this to be an ASSERT() instead, but I'd listen to Andrew (as the main author of this code) saying otherwise.
xen/include/asm-x86/msr.h int init_vcpu_msr_policy(struct vcpu *v); · line 331
Quoted 8 lines
xen/include/asm-x86/msr.h +1
-1@@ -328,7 +328,7 @@ int init_vcpu_msr_policy(struct vcpu *v);* These functions are also used by the migration logic, so need to cope with * being used outside of v's context. */ -int guest_rdmsr (const struct vcpu *v,uint32_t msr,uint64_t *val); +int guest_rdmsr (struct vcpu *v,uint32_t msr,uint64_t *val);
I find this pretty undesirable, and I'd like to at least put out for discussion a means how to avoid it: Any entity being passed a const struct vcpu *cv can get hold of a non-const one by doing
struct vcpu *v = cv->domain->vcpu[cv->vcpu_id];
Of course this shouldn't be used arbitrarily, but to hide an implementation detail like that of vmx_vmcs_enter() I think this could be justified. Thoughts?
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH v2 1/4] x86: stop handling MSR_IA32_BNDCFGS save/restore in implementation code
Quoted 34 lines
-----Original Message-----
From: Xen-devel [mailto:[email protected]] On Behalf Of Jan Beulich
Sent: 13 March 2019 15:55
To: Andrew Cooper <[email protected]>; Paul Durrant <[email protected]>
Cc: xen-devel <[email protected]>; Kevin Tian <[email protected]>; Wei Liu <[email protected]>; Jun Nakajima <[email protected]>; Roger Pau Monne <[email protected]>
Subject: Re: [Xen-devel] [PATCH v2 1/4] x86: stop handlingMSR_IA32_BNDCFGSsave/restore in implementation codeQuoted 3 lines
Quoted 1 line
Quoted 1 line · On 11.03.19 at 19:09, <[email protected]> wrote:
v2:
- Addressed comments from Jan by largely removing hunksI think you've removed more than I was expecting, but I'm fine this way.
Quoted 18 lines
xen/arch/x86/msr.c +7
-0@@ -158,6 +158,13 @@ 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 ( !is_hvm_domain (d) || !cp->feat.mpx || + !hvm_get_guest_bndcfgs (v, val) ) + goto gp_fault; + +break ; + case 0x40000000 ... 0x400001ff:if (is_viridian_domain (d) ) {@@ -319,6 +326,13 @@ int guest_wrmsr(struct vcpu *v, uint32_t msr, uint64_t val) ret =guest_wrmsr_x2apic (v, msr, val);break ;
Quoted 9 lines
xen/arch/x86/msr.c int guest_wrmsr(struct vcpu *v, uint32_t msr, uint64_t val) · line 332
Quoted 4 lines
xen/arch/x86/msr.c +4
-0+case MSR_IA32_BNDCFGS : +if ( !is_hvm_domain (d) || !cp->feat.mpx || + !hvm_set_guest_bndcfgs (v, val) ) + goto gp_fault;In both cases the is_hvm_*() check looks to be redundant, as for PV guests
cp->feat.mpxcan't be set. Personally I'd prefer this to be anASSERT()instead, but I'd listen to Andrew (as the main author of this code) saying otherwise.
I'm ok with an ASSERT but I'll check with Andrew as you suggest.
Quoted 15 lines
xen/include/asm-x86/msr.h int init_vcpu_msr_policy(struct vcpu *v); · line 331
Quoted 9 lines
xen/include/asm-x86/msr.h +1
-1@@ -328,7 +328,7 @@ int init_vcpu_msr_policy(struct vcpu *v);* These functions are also used by the migration logic, so need to cope with * being used outside of v's context. */ -int guest_rdmsr (const struct vcpu *v,uint32_t msr,uint64_t *val); +int guest_rdmsr (struct vcpu *v,uint32_t msr,uint64_t *val);I find this pretty undesirable, and I'd like to at least put out for discussion a means how to avoid it: Any entity being passed a const struct vcpu *cv can get hold of a non-const one by doing
Quoted 2 lines
struct vcpu *v = cv->domain->vcpu[cv->vcpu_id];
Looks kind of odd, but of course it will certainly work.
Quoted 4 lines
Of course this shouldn't be used arbitrarily, but to hide an implementation detail like that of
vmx_vmcs_enter()I think this could be justified. Thoughts?
I guess the question is at what level to do this? Probably in the hvm code rather than in the vmx code.
Paul
Quoted 8 lines
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH v2 1/4] x86: stop handling MSR_IA32_BNDCFGS save/restore in implementation code
Quoted 24 lines
Quoted 19 lines
Quoted 1 line · On 13.03.19 at 17:05, <[email protected]> wrote:
From: Xen-devel [mailto:[email protected]] On Behalf Of Jan Beulich
Sent: 13 March 2019 15:55xen/include/asm-x86/msr.h int init_vcpu_msr_policy(struct vcpu *v); · line 331
Quoted 9 lines
Quoted 1 line
Quoted 1 line · On 11.03.19 at 19:09, <[email protected]> wrote:
xen/include/asm-x86/msr.h +1
-1@@ -328,7 +328,7 @@ int init_vcpu_msr_policy(struct vcpu *v);* These functions are also used by the migration logic, so need to cope with * being used outside of v's context. */ -int guest_rdmsr (const struct vcpu *v,uint32_t msr,uint64_t *val); +int guest_rdmsr (struct vcpu *v,uint32_t msr,uint64_t *val);I find this pretty undesirable, and I'd like to at least put out for discussion a means how to avoid it: Any entity being passed a const struct vcpu *cv can get hold of a non-const one by doing
Quoted 2 lines
struct vcpu *v = cv->domain->vcpu[cv->vcpu_id];Looks kind of odd, but of course it will certainly work.
Quoted 7 lines
Quoted 4 lines
Of course this shouldn't be used arbitrarily, but to hide an implementation detail like that of
vmx_vmcs_enter()I think this could be justified. Thoughts?I guess the question is at what level to do this? Probably in the hvm code rather than in the vmx code.
I think it should be in VMX code, as that's where the vmx_vmcs_enter() oddity lives.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH v2 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 v2 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
@@ -165,6 +165,13 @@ int guest_rdmsr(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) ) {
@@ -333,6 +340,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 v2 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: Jan Beulich <[email protected]>
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
Re: [PATCH v2 4/4] x86: remove defunct init/load/save_msr() hvm_funcs
Quoted 5 lines
Quoted 1 line
Quoted 1 line · On 11.03.19 at 19:09, <[email protected]> wrote:
These
hvm_funcsare no longer required since no MSR values are saved or restored by implementation-specific code.Signed-off-by Paul Durrant <[email protected]>
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel