[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH v6 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 <aisaila@xxxxxxxxxxxxxxx> --- Changes since V5: - Check the return value of hvm_save_cpu_msrs_one() --- xen/arch/x86/hvm/hvm.c | 60 ++++++++++++++++++++++++++++---------------------- 1 file changed, 34 insertions(+), 26 deletions(-) diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c index e8ecabf..7e90bf2 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,8 @@ 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; - } + if ( hvm_save_cpu_msrs_one(v, ctxt) == -ENXIO ) + return -ENXIO; if ( hvm_funcs.save_msr ) hvm_funcs.save_msr(v, ctxt); -- 2.7.4 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxxxxxxxxx https://lists.xenproject.org/mailman/listinfo/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |