> -----Original Message----- > From: Alexandru Isaila [mailto:[email protected]] > Sent: 29 May 2018 15:59 > To: [email protected] > Cc: Ian Jackson <[email protected]>; Wei Liu <[email protected]>; > [email protected]; Andrew Cooper <[email protected]>; Paul > Durrant <[email protected]>; Alexandru Isaila > <[email protected]> > Subject: [PATCH v5 5/8] x86/hvm: Introduce hvm_save_cpu_msrs_one func > > This is used to save data from a single instance. > > Signed-off-by: Alexandru Isaila <[email protected]> > --- > xen/arch/x86/hvm/hvm.c | 59 ++++++++++++++++++++++++++++----------- > ----------- > 1 file changed, 33 insertions(+), 26 deletions(-) > > diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c > index e8ecabf..4a22283 100644 > --- a/xen/arch/x86/hvm/hvm.c > +++ b/xen/arch/x86/hvm/hvm.c > @@ -1354,6 +1354,38 @@ static const uint32_t msrs_to_send[] = { > }; > static unsigned int __read_mostly msr_count_max = > ARRAY_SIZE(msrs_to_send); > > +static int hvm_save_cpu_msrs_one(struct vcpu *v, struct hvm_msr *ctxt) > +{ > + unsigned int i; > + > + for ( i = 0; i < ARRAY_SIZE(msrs_to_send); ++i ) > + { > + uint64_t val; > + int rc = guest_rdmsr(v, msrs_to_send[i], &val); > + > + /* > + * It is the programmers responsibility to ensure that > + * msrs_to_send[] contain generally-read/write MSRs. > + * X86EMUL_EXCEPTION here implies a missing feature, and that the > + * guest doesn't have access to the MSR. > + */ > + if ( rc == X86EMUL_EXCEPTION ) > + continue; > + > + if ( rc != X86EMUL_OKAY ) > + { > + ASSERT_UNREACHABLE(); > + return -ENXIO; > + } > + > + if ( !val ) > + continue; /* Skip empty MSRs. */ > + ctxt->msr[ctxt->count].index = msrs_to_send[i]; > + ctxt->msr[ctxt->count++].val = val; > + } > + return 0; > +} > + > static int hvm_save_cpu_msrs(struct domain *d, hvm_domain_context_t > *h) > { > struct vcpu *v; > @@ -1370,32 +1402,7 @@ static int hvm_save_cpu_msrs(struct domain *d, > hvm_domain_context_t *h) > ctxt = (struct hvm_msr *)&h->data[h->cur]; > ctxt->count = 0; > > - for ( i = 0; i < ARRAY_SIZE(msrs_to_send); ++i ) > - { > - uint64_t val; > - int rc = guest_rdmsr(v, msrs_to_send[i], &val); > - > - /* > - * It is the programmers responsibility to ensure that > - * msrs_to_send[] contain generally-read/write MSRs. > - * X86EMUL_EXCEPTION here implies a missing feature, and that the > - * guest doesn't have access to the MSR. > - */ > - if ( rc == X86EMUL_EXCEPTION ) > - continue; > - > - if ( rc != X86EMUL_OKAY ) > - { > - ASSERT_UNREACHABLE(); > - return -ENXIO; > - } > - > - if ( !val ) > - continue; /* Skip empty MSRs. */ > - > - ctxt->msr[ctxt->count].index = msrs_to_send[i]; > - ctxt->msr[ctxt->count++].val = val; > - } > + hvm_save_cpu_msrs_one(v, ctxt);
No check for the return value here means you're not going to propagate a potential -ENXIO. Paul > > if ( hvm_funcs.save_msr ) > hvm_funcs.save_msr(v, ctxt); > -- > 2.7.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
