[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen master] x86/viridan: Clean up Viridian MSR infrastructure
commit 229b94878717e22c0f228625bbcddd53f7d8654d Author: Andrew Cooper <andrew.cooper3@xxxxxxxxxx> AuthorDate: Wed Sep 20 17:33:59 2017 +0000 Commit: Andrew Cooper <andrew.cooper3@xxxxxxxxxx> CommitDate: Mon Sep 24 16:25:37 2018 +0100 x86/viridan: Clean up Viridian MSR infrastructure Rename the functions to guest_{rd,wr}msr_viridian() for consistency, and because the _regs() suffix isn't very appropriate. Update them to take a vcpu pointer rather than presuming that they act on current, which is safe for all implemented operations, and switch their return ABI to use X86EMUL_*. The default cases no longer need to deal with MSRs out of the Viridian range, but drop the printks to debug builds only and identify the value attempting to be written. Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx> Reviewed-by: Paul Durrant <paul.durrant@xxxxxxxxxx> Reviewed-by: Sergey Dyasli <sergey.dyasli@xxxxxxxxxx> Acked-by: Jan Beulich <jbeulich@xxxxxxxx> --- xen/arch/x86/hvm/viridian.c | 46 ++++++++++++++------------------------ xen/arch/x86/msr.c | 6 ++--- xen/include/asm-x86/hvm/viridian.h | 11 ++------- 3 files changed, 21 insertions(+), 42 deletions(-) diff --git a/xen/arch/x86/hvm/viridian.c b/xen/arch/x86/hvm/viridian.c index d7ab94bbab..f42b1f063e 100644 --- a/xen/arch/x86/hvm/viridian.c +++ b/xen/arch/x86/hvm/viridian.c @@ -88,9 +88,6 @@ #define HV_X64_MSR_CRASH_P4 0x40000104 #define HV_X64_MSR_CRASH_CTL 0x40000105 -#define VIRIDIAN_MSR_MIN HV_X64_MSR_GUEST_OS_ID -#define VIRIDIAN_MSR_MAX HV_X64_MSR_CRASH_CTL - /* Viridian Hypercall Status Codes. */ #define HV_STATUS_SUCCESS 0x0000 #define HV_STATUS_INVALID_HYPERCALL_CODE 0x0002 @@ -554,13 +551,11 @@ static void update_reference_tsc(struct domain *d, bool_t initialize) put_page_and_type(page); } -int wrmsr_viridian_regs(uint32_t idx, uint64_t val) +int guest_wrmsr_viridian(struct vcpu *v, uint32_t idx, uint64_t val) { - struct vcpu *v = current; struct domain *d = v->domain; - if ( !is_viridian_domain(d) ) - return 0; + ASSERT(is_viridian_domain(d)); switch ( idx ) { @@ -615,7 +610,7 @@ int wrmsr_viridian_regs(uint32_t idx, uint64_t val) case HV_X64_MSR_REFERENCE_TSC: if ( !(viridian_feature_mask(d) & HVMPV_reference_tsc) ) - return 0; + return X86EMUL_EXCEPTION; perfc_incr(mshv_wrmsr_tsc_msr); d->arch.hvm.viridian.reference_tsc.raw = val; @@ -659,14 +654,12 @@ int wrmsr_viridian_regs(uint32_t idx, uint64_t val) } default: - if ( idx >= VIRIDIAN_MSR_MIN && idx <= VIRIDIAN_MSR_MAX ) - gprintk(XENLOG_WARNING, "write to unimplemented MSR %#x\n", - idx); - - return 0; + gdprintk(XENLOG_INFO, + "Write %016"PRIx64" to unimplemented MSR %#x\n", val, idx); + return X86EMUL_EXCEPTION; } - return 1; + return X86EMUL_OKAY; } static int64_t raw_trc_val(struct domain *d) @@ -702,13 +695,11 @@ void viridian_time_ref_count_thaw(struct domain *d) trc->off = (int64_t)trc->val - raw_trc_val(d); } -int rdmsr_viridian_regs(uint32_t idx, uint64_t *val) +int guest_rdmsr_viridian(const struct vcpu *v, uint32_t idx, uint64_t *val) { - struct vcpu *v = current; struct domain *d = v->domain; - - if ( !is_viridian_domain(d) ) - return 0; + + ASSERT(is_viridian_domain(d)); switch ( idx ) { @@ -729,7 +720,7 @@ int rdmsr_viridian_regs(uint32_t idx, uint64_t *val) case HV_X64_MSR_TSC_FREQUENCY: if ( viridian_feature_mask(d) & HVMPV_no_freq ) - return 0; + return X86EMUL_EXCEPTION; perfc_incr(mshv_rdmsr_tsc_frequency); *val = (uint64_t)d->arch.tsc_khz * 1000ull; @@ -737,7 +728,7 @@ int rdmsr_viridian_regs(uint32_t idx, uint64_t *val) case HV_X64_MSR_APIC_FREQUENCY: if ( viridian_feature_mask(d) & HVMPV_no_freq ) - return 0; + return X86EMUL_EXCEPTION; perfc_incr(mshv_rdmsr_apic_frequency); *val = 1000000000ull / APIC_BUS_CYCLE_NS; @@ -761,7 +752,7 @@ int rdmsr_viridian_regs(uint32_t idx, uint64_t *val) case HV_X64_MSR_REFERENCE_TSC: if ( !(viridian_feature_mask(d) & HVMPV_reference_tsc) ) - return 0; + return X86EMUL_EXCEPTION; perfc_incr(mshv_rdmsr_tsc_msr); *val = d->arch.hvm.viridian.reference_tsc.raw; @@ -774,7 +765,7 @@ int rdmsr_viridian_regs(uint32_t idx, uint64_t *val) trc = &d->arch.hvm.viridian.time_ref_count; if ( !(viridian_feature_mask(d) & HVMPV_time_ref_count) ) - return 0; + return X86EMUL_EXCEPTION; if ( !test_and_set_bit(_TRC_accessed, &trc->flags) ) printk(XENLOG_G_INFO "d%d: VIRIDIAN MSR_TIME_REF_COUNT: accessed\n", @@ -808,14 +799,11 @@ int rdmsr_viridian_regs(uint32_t idx, uint64_t *val) } default: - if ( idx >= VIRIDIAN_MSR_MIN && idx <= VIRIDIAN_MSR_MAX ) - gprintk(XENLOG_WARNING, "read from unimplemented MSR %#x\n", - idx); - - return 0; + gdprintk(XENLOG_INFO, "Read from unimplemented MSR %#x\n", idx); + return X86EMUL_EXCEPTION; } - return 1; + return X86EMUL_OKAY; } void viridian_vcpu_deinit(struct vcpu *v) diff --git a/xen/arch/x86/msr.c b/xen/arch/x86/msr.c index 6fe3ad7a16..5b2887d543 100644 --- a/xen/arch/x86/msr.c +++ b/xen/arch/x86/msr.c @@ -150,8 +150,7 @@ int guest_rdmsr(const struct vcpu *v, uint32_t msr, uint64_t *val) case 0x40000000 ... 0x400001ff: if ( is_viridian_domain(d) ) { - ret = (rdmsr_viridian_regs(msr, val) - ? X86EMUL_OKAY : X86EMUL_EXCEPTION); + ret = guest_rdmsr_viridian(v, msr, val); break; } @@ -278,8 +277,7 @@ int guest_wrmsr(struct vcpu *v, uint32_t msr, uint64_t val) case 0x40000000 ... 0x400001ff: if ( is_viridian_domain(d) ) { - ret = (wrmsr_viridian_regs(msr, val) - ? X86EMUL_OKAY : X86EMUL_EXCEPTION); + ret = guest_wrmsr_viridian(v, msr, val); break; } diff --git a/xen/include/asm-x86/hvm/viridian.h b/xen/include/asm-x86/hvm/viridian.h index 4cbd133720..071fb445bb 100644 --- a/xen/include/asm-x86/hvm/viridian.h +++ b/xen/include/asm-x86/hvm/viridian.h @@ -101,15 +101,8 @@ struct viridian_domain void cpuid_viridian_leaves(const struct vcpu *v, uint32_t leaf, uint32_t subleaf, struct cpuid_leaf *res); -int -wrmsr_viridian_regs( - uint32_t idx, - uint64_t val); - -int -rdmsr_viridian_regs( - uint32_t idx, - uint64_t *val); +int guest_wrmsr_viridian(struct vcpu *v, uint32_t idx, uint64_t val); +int guest_rdmsr_viridian(const struct vcpu *v, uint32_t idx, uint64_t *val); int viridian_hypercall(struct cpu_user_regs *regs); -- generated by git-patchbot for /home/xen/git/xen.git#master _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxxxxxxxxx https://lists.xenproject.org/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |