[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH v2 06/18] x86/traps: move PV hypercall handlers to pv/traps.c
The following handlers are moved: 1. do_set_trap_table 2. do_set_debugreg 3. do_get_debugreg 4. do_fpu_taskswitch No functional change. Signed-off-by: Wei Liu <wei.liu2@xxxxxxxxxx> --- xen/arch/x86/pv/traps.c | 97 +++++++++++++++++++++++++++++++++++++++++++++++++ xen/arch/x86/traps.c | 94 ----------------------------------------------- 2 files changed, 97 insertions(+), 94 deletions(-) diff --git a/xen/arch/x86/pv/traps.c b/xen/arch/x86/pv/traps.c index 51125a8d86..350e7a1da4 100644 --- a/xen/arch/x86/pv/traps.c +++ b/xen/arch/x86/pv/traps.c @@ -19,9 +19,13 @@ * Copyright (c) 2017 Citrix Systems Ltd. */ +#include <xen/event.h> +#include <xen/guest_access.h> #include <xen/hypercall.h> +#include <xen/sched.h> #include <asm/apic.h> +#include <asm/debugreg.h> void do_entry_int82(struct cpu_user_regs *regs) { @@ -31,6 +35,99 @@ void do_entry_int82(struct cpu_user_regs *regs) pv_hypercall(regs); } +long do_fpu_taskswitch(int set) +{ + struct vcpu *v = current; + + if ( set ) + { + v->arch.pv_vcpu.ctrlreg[0] |= X86_CR0_TS; + stts(); + } + else + { + v->arch.pv_vcpu.ctrlreg[0] &= ~X86_CR0_TS; + if ( v->fpu_dirtied ) + clts(); + } + + return 0; +} + +long do_set_trap_table(XEN_GUEST_HANDLE_PARAM(const_trap_info_t) traps) +{ + struct trap_info cur; + struct vcpu *curr = current; + struct trap_info *dst = curr->arch.pv_vcpu.trap_ctxt; + long rc = 0; + + /* If no table is presented then clear the entire virtual IDT. */ + if ( guest_handle_is_null(traps) ) + { + memset(dst, 0, NR_VECTORS * sizeof(*dst)); + init_int80_direct_trap(curr); + return 0; + } + + for ( ; ; ) + { + if ( copy_from_guest(&cur, traps, 1) ) + { + rc = -EFAULT; + break; + } + + if ( cur.address == 0 ) + break; + + if ( !is_canonical_address(cur.address) ) + return -EINVAL; + + fixup_guest_code_selector(curr->domain, cur.cs); + + memcpy(&dst[cur.vector], &cur, sizeof(cur)); + + if ( cur.vector == 0x80 ) + init_int80_direct_trap(curr); + + guest_handle_add_offset(traps, 1); + + if ( hypercall_preempt_check() ) + { + rc = hypercall_create_continuation( + __HYPERVISOR_set_trap_table, "h", traps); + break; + } + } + + return rc; +} + +long do_set_debugreg(int reg, unsigned long value) +{ + return set_debugreg(current, reg, value); +} + +unsigned long do_get_debugreg(int reg) +{ + struct vcpu *curr = current; + + switch ( reg ) + { + case 0 ... 3: + case 6: + return curr->arch.debugreg[reg]; + case 7: + return (curr->arch.debugreg[7] | + curr->arch.debugreg[5]); + case 4 ... 5: + return ((curr->arch.pv_vcpu.ctrlreg[4] & X86_CR4_DE) ? + curr->arch.debugreg[reg + 2] : 0); + } + + return -EINVAL; +} + /* * Local variables: * mode: C diff --git a/xen/arch/x86/traps.c b/xen/arch/x86/traps.c index a076de2be4..9e0b321f08 100644 --- a/xen/arch/x86/traps.c +++ b/xen/arch/x86/traps.c @@ -1474,25 +1474,6 @@ void __init do_early_page_fault(struct cpu_user_regs *regs) } } -long do_fpu_taskswitch(int set) -{ - struct vcpu *v = current; - - if ( set ) - { - v->arch.pv_vcpu.ctrlreg[0] |= X86_CR0_TS; - stts(); - } - else - { - v->arch.pv_vcpu.ctrlreg[0] &= ~X86_CR0_TS; - if ( v->fpu_dirtied ) - clts(); - } - - return 0; -} - void do_general_protection(struct cpu_user_regs *regs) { struct vcpu *v = current; @@ -2111,56 +2092,6 @@ int send_guest_trap(struct domain *d, uint16_t vcpuid, unsigned int trap_nr) return -EIO; } - -long do_set_trap_table(XEN_GUEST_HANDLE_PARAM(const_trap_info_t) traps) -{ - struct trap_info cur; - struct vcpu *curr = current; - struct trap_info *dst = curr->arch.pv_vcpu.trap_ctxt; - long rc = 0; - - /* If no table is presented then clear the entire virtual IDT. */ - if ( guest_handle_is_null(traps) ) - { - memset(dst, 0, NR_VECTORS * sizeof(*dst)); - init_int80_direct_trap(curr); - return 0; - } - - for ( ; ; ) - { - if ( copy_from_guest(&cur, traps, 1) ) - { - rc = -EFAULT; - break; - } - - if ( cur.address == 0 ) - break; - - if ( !is_canonical_address(cur.address) ) - return -EINVAL; - - fixup_guest_code_selector(curr->domain, cur.cs); - - memcpy(&dst[cur.vector], &cur, sizeof(cur)); - - if ( cur.vector == 0x80 ) - init_int80_direct_trap(curr); - - guest_handle_add_offset(traps, 1); - - if ( hypercall_preempt_check() ) - { - rc = hypercall_create_continuation( - __HYPERVISOR_set_trap_table, "h", traps); - break; - } - } - - return rc; -} - void activate_debugregs(const struct vcpu *curr) { ASSERT(curr == current); @@ -2284,31 +2215,6 @@ long set_debugreg(struct vcpu *v, unsigned int reg, unsigned long value) return 0; } -long do_set_debugreg(int reg, unsigned long value) -{ - return set_debugreg(current, reg, value); -} - -unsigned long do_get_debugreg(int reg) -{ - struct vcpu *curr = current; - - switch ( reg ) - { - case 0 ... 3: - case 6: - return curr->arch.debugreg[reg]; - case 7: - return (curr->arch.debugreg[7] | - curr->arch.debugreg[5]); - case 4 ... 5: - return ((curr->arch.pv_vcpu.ctrlreg[4] & X86_CR4_DE) ? - curr->arch.debugreg[reg + 2] : 0); - } - - return -EINVAL; -} - void asm_domain_crash_synchronous(unsigned long addr) { /* -- 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 |