[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH v2 07/18] x86/traps: move pv_inject_event to pv/traps.c
No functional change. Signed-off-by: Wei Liu <wei.liu2@xxxxxxxxxx> --- xen/arch/x86/pv/traps.c | 63 +++++++++++++++++++++++++++++++++++++++++++++++++ xen/arch/x86/traps.c | 59 --------------------------------------------- 2 files changed, 63 insertions(+), 59 deletions(-) diff --git a/xen/arch/x86/pv/traps.c b/xen/arch/x86/pv/traps.c index 350e7a1da4..9de5798e58 100644 --- a/xen/arch/x86/pv/traps.c +++ b/xen/arch/x86/pv/traps.c @@ -23,9 +23,13 @@ #include <xen/guest_access.h> #include <xen/hypercall.h> #include <xen/sched.h> +#include <xen/lib.h> +#include <xen/trace.h> #include <asm/apic.h> #include <asm/debugreg.h> +#include <asm/shared.h> +#include <asm/traps.h> void do_entry_int82(struct cpu_user_regs *regs) { @@ -128,6 +132,65 @@ unsigned long do_get_debugreg(int reg) return -EINVAL; } +void pv_inject_event(const struct x86_event *event) +{ + struct vcpu *v = current; + struct cpu_user_regs *regs = guest_cpu_user_regs(); + struct trap_bounce *tb; + const struct trap_info *ti; + const uint8_t vector = event->vector; + const bool use_error_code = + ((vector < 32) && (TRAP_HAVE_EC & (1u << vector))); + unsigned int error_code = event->error_code; + + ASSERT(vector == event->vector); /* Confirm no truncation. */ + if ( use_error_code ) + ASSERT(error_code != X86_EVENT_NO_EC); + else + ASSERT(error_code == X86_EVENT_NO_EC); + + tb = &v->arch.pv_vcpu.trap_bounce; + ti = &v->arch.pv_vcpu.trap_ctxt[vector]; + + tb->flags = TBF_EXCEPTION; + tb->cs = ti->cs; + tb->eip = ti->address; + + if ( vector == TRAP_page_fault ) + { + v->arch.pv_vcpu.ctrlreg[2] = event->cr2; + arch_set_cr2(v, event->cr2); + + /* Re-set error_code.user flag appropriately for the guest. */ + error_code &= ~PFEC_user_mode; + if ( !guest_kernel_mode(v, regs) ) + error_code |= PFEC_user_mode; + + trace_pv_page_fault(event->cr2, error_code); + } + else + trace_pv_trap(vector, regs->rip, use_error_code, error_code); + + if ( use_error_code ) + { + tb->flags |= TBF_EXCEPTION_ERRCODE; + tb->error_code = error_code; + } + + if ( TI_GET_IF(ti) ) + tb->flags |= TBF_INTERRUPT; + + if ( unlikely(null_trap_bounce(v, tb)) ) + { + gprintk(XENLOG_WARNING, + "Unhandled %s fault/trap [#%d, ec=%04x]\n", + trapstr(vector), vector, error_code); + + if ( vector == TRAP_page_fault ) + show_page_walk(event->cr2); + } +} + /* * Local variables: * mode: C diff --git a/xen/arch/x86/traps.c b/xen/arch/x86/traps.c index 9e0b321f08..c38a8a1171 100644 --- a/xen/arch/x86/traps.c +++ b/xen/arch/x86/traps.c @@ -626,65 +626,6 @@ void fatal_trap(const struct cpu_user_regs *regs, bool_t show_remote) (regs->eflags & X86_EFLAGS_IF) ? "" : ", IN INTERRUPT CONTEXT"); } -void pv_inject_event(const struct x86_event *event) -{ - struct vcpu *v = current; - struct cpu_user_regs *regs = guest_cpu_user_regs(); - struct trap_bounce *tb; - const struct trap_info *ti; - const uint8_t vector = event->vector; - const bool use_error_code = - ((vector < 32) && (TRAP_HAVE_EC & (1u << vector))); - unsigned int error_code = event->error_code; - - ASSERT(vector == event->vector); /* Confirm no truncation. */ - if ( use_error_code ) - ASSERT(error_code != X86_EVENT_NO_EC); - else - ASSERT(error_code == X86_EVENT_NO_EC); - - tb = &v->arch.pv_vcpu.trap_bounce; - ti = &v->arch.pv_vcpu.trap_ctxt[vector]; - - tb->flags = TBF_EXCEPTION; - tb->cs = ti->cs; - tb->eip = ti->address; - - if ( vector == TRAP_page_fault ) - { - v->arch.pv_vcpu.ctrlreg[2] = event->cr2; - arch_set_cr2(v, event->cr2); - - /* Re-set error_code.user flag appropriately for the guest. */ - error_code &= ~PFEC_user_mode; - if ( !guest_kernel_mode(v, regs) ) - error_code |= PFEC_user_mode; - - trace_pv_page_fault(event->cr2, error_code); - } - else - trace_pv_trap(vector, regs->rip, use_error_code, error_code); - - if ( use_error_code ) - { - tb->flags |= TBF_EXCEPTION_ERRCODE; - tb->error_code = error_code; - } - - if ( TI_GET_IF(ti) ) - tb->flags |= TBF_INTERRUPT; - - if ( unlikely(null_trap_bounce(v, tb)) ) - { - gprintk(XENLOG_WARNING, - "Unhandled %s fault/trap [#%d, ec=%04x]\n", - trapstr(vector), vector, error_code); - - if ( vector == TRAP_page_fault ) - show_page_walk(event->cr2); - } -} - /* * Called from asm to set up the MCE trapbounce info. * Returns 0 if no callback is set up, else 1. -- 2.11.0 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx https://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |