[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH] x86/traps: Move guest_{rd,wr}msr_xen() into msr.c
They are out of place in traps.c, and only have a single caller each. Make them static inside msr.c. No functional change. Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx> --- CC: Jan Beulich <JBeulich@xxxxxxxx> CC: Roger Pau Monné <roger.pau@xxxxxxxxxx> --- xen/arch/x86/include/asm/processor.h | 3 -- xen/arch/x86/msr.c | 73 ++++++++++++++++++++++++++++ xen/arch/x86/traps.c | 73 ---------------------------- 3 files changed, 73 insertions(+), 76 deletions(-) diff --git a/xen/arch/x86/include/asm/processor.h b/xen/arch/x86/include/asm/processor.h index 4f176bc575ef..6bc88b031761 100644 --- a/xen/arch/x86/include/asm/processor.h +++ b/xen/arch/x86/include/asm/processor.h @@ -472,9 +472,6 @@ struct stubs { DECLARE_PER_CPU(struct stubs, stubs); unsigned long alloc_stub_page(unsigned int cpu, unsigned long *mfn); -int guest_rdmsr_xen(const struct vcpu *v, uint32_t idx, uint64_t *val); -int guest_wrmsr_xen(struct vcpu *v, uint32_t idx, uint64_t val); - static inline uint8_t get_cpu_family(uint32_t raw, uint8_t *model, uint8_t *stepping) { diff --git a/xen/arch/x86/msr.c b/xen/arch/x86/msr.c index 2244571939ee..a12503608c16 100644 --- a/xen/arch/x86/msr.c +++ b/xen/arch/x86/msr.c @@ -18,6 +18,7 @@ #include <asm/hvm/nestedhvm.h> #include <asm/hvm/viridian.h> #include <asm/msr.h> +#include <asm/p2m.h> #include <asm/pv/domain.h> #include <asm/setup.h> #include <asm/xstate.h> @@ -40,6 +41,78 @@ int init_vcpu_msr_policy(struct vcpu *v) return 0; } +static int guest_rdmsr_xen(const struct vcpu *v, uint32_t idx, uint64_t *val) +{ + const struct domain *d = v->domain; + /* Optionally shift out of the way of Viridian architectural MSRs. */ + uint32_t base = is_viridian_domain(d) ? 0x40000200 : 0x40000000; + + switch ( idx - base ) + { + case 0: /* Write hypercall page MSR. Read as zero. */ + *val = 0; + return X86EMUL_OKAY; + } + + return X86EMUL_EXCEPTION; +} + +static int guest_wrmsr_xen(struct vcpu *v, uint32_t idx, uint64_t val) +{ + struct domain *d = v->domain; + /* Optionally shift out of the way of Viridian architectural MSRs. */ + uint32_t base = is_viridian_domain(d) ? 0x40000200 : 0x40000000; + + switch ( idx - base ) + { + case 0: /* Write hypercall page */ + { + void *hypercall_page; + unsigned long gmfn = val >> PAGE_SHIFT; + unsigned int page_index = val & (PAGE_SIZE - 1); + struct page_info *page; + p2m_type_t t; + + if ( page_index > 0 ) + { + gdprintk(XENLOG_WARNING, + "wrmsr hypercall page index %#x unsupported\n", + page_index); + return X86EMUL_EXCEPTION; + } + + page = get_page_from_gfn(d, gmfn, &t, P2M_ALLOC); + + if ( !page || !get_page_type(page, PGT_writable_page) ) + { + if ( page ) + put_page(page); + + if ( p2m_is_paging(t) ) + { + p2m_mem_paging_populate(d, _gfn(gmfn)); + return X86EMUL_RETRY; + } + + gdprintk(XENLOG_WARNING, + "Bad GMFN %lx (MFN %#"PRI_mfn") to MSR %08x\n", + gmfn, mfn_x(page ? page_to_mfn(page) : INVALID_MFN), base); + return X86EMUL_EXCEPTION; + } + + hypercall_page = __map_domain_page(page); + init_hypercall_page(d, hypercall_page); + unmap_domain_page(hypercall_page); + + put_page_and_type(page); + return X86EMUL_OKAY; + } + + default: + return X86EMUL_EXCEPTION; + } +} + int guest_rdmsr(struct vcpu *v, uint32_t msr, uint64_t *val) { const struct vcpu *curr = current; diff --git a/xen/arch/x86/traps.c b/xen/arch/x86/traps.c index 91af814badf7..be2bc59f0347 100644 --- a/xen/arch/x86/traps.c +++ b/xen/arch/x86/traps.c @@ -64,7 +64,6 @@ #include <asm/mc146818rtc.h> #include <asm/hpet.h> #include <asm/vpmu.h> -#include <public/hvm/params.h> #include <asm/cpuid.h> #include <xsm/xsm.h> #include <asm/irq-vectors.h> @@ -979,78 +978,6 @@ void asmlinkage do_trap(struct cpu_user_regs *regs) fatal_trap(regs, false); } -int guest_rdmsr_xen(const struct vcpu *v, uint32_t idx, uint64_t *val) -{ - const struct domain *d = v->domain; - /* Optionally shift out of the way of Viridian architectural MSRs. */ - uint32_t base = is_viridian_domain(d) ? 0x40000200 : 0x40000000; - - switch ( idx - base ) - { - case 0: /* Write hypercall page MSR. Read as zero. */ - *val = 0; - return X86EMUL_OKAY; - } - - return X86EMUL_EXCEPTION; -} - -int guest_wrmsr_xen(struct vcpu *v, uint32_t idx, uint64_t val) -{ - struct domain *d = v->domain; - /* Optionally shift out of the way of Viridian architectural MSRs. */ - uint32_t base = is_viridian_domain(d) ? 0x40000200 : 0x40000000; - - switch ( idx - base ) - { - case 0: /* Write hypercall page */ - { - void *hypercall_page; - unsigned long gmfn = val >> PAGE_SHIFT; - unsigned int page_index = val & (PAGE_SIZE - 1); - struct page_info *page; - p2m_type_t t; - - if ( page_index > 0 ) - { - gdprintk(XENLOG_WARNING, - "wrmsr hypercall page index %#x unsupported\n", - page_index); - return X86EMUL_EXCEPTION; - } - - page = get_page_from_gfn(d, gmfn, &t, P2M_ALLOC); - - if ( !page || !get_page_type(page, PGT_writable_page) ) - { - if ( page ) - put_page(page); - - if ( p2m_is_paging(t) ) - { - p2m_mem_paging_populate(d, _gfn(gmfn)); - return X86EMUL_RETRY; - } - - gdprintk(XENLOG_WARNING, - "Bad GMFN %lx (MFN %#"PRI_mfn") to MSR %08x\n", - gmfn, mfn_x(page ? page_to_mfn(page) : INVALID_MFN), base); - return X86EMUL_EXCEPTION; - } - - hypercall_page = __map_domain_page(page); - init_hypercall_page(d, hypercall_page); - unmap_domain_page(hypercall_page); - - put_page_and_type(page); - return X86EMUL_OKAY; - } - - default: - return X86EMUL_EXCEPTION; - } -} - void asmlinkage do_invalid_op(struct cpu_user_regs *regs) { u8 bug_insn[2]; -- 2.39.5
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |