[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH for-next v3 16/22] x86/traps: move callback_op code
No functional change. Signed-off-by: Wei Liu <wei.liu2@xxxxxxxxxx> --- xen/arch/x86/pv/traps.c | 148 +++++++++++++++++++++++++++++++++++++++++++ xen/arch/x86/x86_64/traps.c | 149 -------------------------------------------- 2 files changed, 148 insertions(+), 149 deletions(-) diff --git a/xen/arch/x86/pv/traps.c b/xen/arch/x86/pv/traps.c index cb9b3b1425..7cdec77618 100644 --- a/xen/arch/x86/pv/traps.c +++ b/xen/arch/x86/pv/traps.c @@ -31,6 +31,8 @@ #include <asm/shared.h> #include <asm/traps.h> +#include <public/callback.h> + void do_entry_int82(struct cpu_user_regs *regs) { if ( unlikely(untrusted_msi) ) @@ -432,6 +434,152 @@ void init_int80_direct_trap(struct vcpu *v) tb->flags = TBF_EXCEPTION | (TI_GET_IF(ti) ? TBF_INTERRUPT : 0); } +static long register_guest_callback(struct callback_register *reg) +{ + long ret = 0; + struct vcpu *v = current; + + if ( !is_canonical_address(reg->address) ) + return -EINVAL; + + switch ( reg->type ) + { + case CALLBACKTYPE_event: + v->arch.pv_vcpu.event_callback_eip = reg->address; + break; + + case CALLBACKTYPE_failsafe: + v->arch.pv_vcpu.failsafe_callback_eip = reg->address; + if ( reg->flags & CALLBACKF_mask_events ) + set_bit(_VGCF_failsafe_disables_events, + &v->arch.vgc_flags); + else + clear_bit(_VGCF_failsafe_disables_events, + &v->arch.vgc_flags); + break; + + case CALLBACKTYPE_syscall: + v->arch.pv_vcpu.syscall_callback_eip = reg->address; + if ( reg->flags & CALLBACKF_mask_events ) + set_bit(_VGCF_syscall_disables_events, + &v->arch.vgc_flags); + else + clear_bit(_VGCF_syscall_disables_events, + &v->arch.vgc_flags); + break; + + case CALLBACKTYPE_syscall32: + v->arch.pv_vcpu.syscall32_callback_eip = reg->address; + v->arch.pv_vcpu.syscall32_disables_events = + !!(reg->flags & CALLBACKF_mask_events); + break; + + case CALLBACKTYPE_sysenter: + v->arch.pv_vcpu.sysenter_callback_eip = reg->address; + v->arch.pv_vcpu.sysenter_disables_events = + !!(reg->flags & CALLBACKF_mask_events); + break; + + case CALLBACKTYPE_nmi: + ret = register_guest_nmi_callback(reg->address); + break; + + default: + ret = -ENOSYS; + break; + } + + return ret; +} + +static long unregister_guest_callback(struct callback_unregister *unreg) +{ + long ret; + + switch ( unreg->type ) + { + case CALLBACKTYPE_event: + case CALLBACKTYPE_failsafe: + case CALLBACKTYPE_syscall: + case CALLBACKTYPE_syscall32: + case CALLBACKTYPE_sysenter: + ret = -EINVAL; + break; + + case CALLBACKTYPE_nmi: + ret = unregister_guest_nmi_callback(); + break; + + default: + ret = -ENOSYS; + break; + } + + return ret; +} + +long do_callback_op(int cmd, XEN_GUEST_HANDLE_PARAM(const_void) arg) +{ + long ret; + + switch ( cmd ) + { + case CALLBACKOP_register: + { + struct callback_register reg; + + ret = -EFAULT; + if ( copy_from_guest(®, arg, 1) ) + break; + + ret = register_guest_callback(®); + } + break; + + case CALLBACKOP_unregister: + { + struct callback_unregister unreg; + + ret = -EFAULT; + if ( copy_from_guest(&unreg, arg, 1) ) + break; + + ret = unregister_guest_callback(&unreg); + } + break; + + default: + ret = -ENOSYS; + break; + } + + return ret; +} + +long do_set_callbacks(unsigned long event_address, + unsigned long failsafe_address, + unsigned long syscall_address) +{ + struct callback_register event = { + .type = CALLBACKTYPE_event, + .address = event_address, + }; + struct callback_register failsafe = { + .type = CALLBACKTYPE_failsafe, + .address = failsafe_address, + }; + struct callback_register syscall = { + .type = CALLBACKTYPE_syscall, + .address = syscall_address, + }; + + register_guest_callback(&event); + register_guest_callback(&failsafe); + register_guest_callback(&syscall); + + return 0; +} + /* * Local variables: * mode: C diff --git a/xen/arch/x86/x86_64/traps.c b/xen/arch/x86/x86_64/traps.c index a4ea09b1ac..db2037509e 100644 --- a/xen/arch/x86/x86_64/traps.c +++ b/xen/arch/x86/x86_64/traps.c @@ -23,8 +23,6 @@ #include <asm/shared.h> #include <asm/hvm/hvm.h> #include <asm/hvm/support.h> -#include <public/callback.h> - static void print_xen_info(void) { @@ -336,153 +334,6 @@ void subarch_percpu_traps_init(void) wrmsrl(MSR_SYSCALL_MASK, XEN_SYSCALL_MASK); } -static long register_guest_callback(struct callback_register *reg) -{ - long ret = 0; - struct vcpu *v = current; - - if ( !is_canonical_address(reg->address) ) - return -EINVAL; - - switch ( reg->type ) - { - case CALLBACKTYPE_event: - v->arch.pv_vcpu.event_callback_eip = reg->address; - break; - - case CALLBACKTYPE_failsafe: - v->arch.pv_vcpu.failsafe_callback_eip = reg->address; - if ( reg->flags & CALLBACKF_mask_events ) - set_bit(_VGCF_failsafe_disables_events, - &v->arch.vgc_flags); - else - clear_bit(_VGCF_failsafe_disables_events, - &v->arch.vgc_flags); - break; - - case CALLBACKTYPE_syscall: - v->arch.pv_vcpu.syscall_callback_eip = reg->address; - if ( reg->flags & CALLBACKF_mask_events ) - set_bit(_VGCF_syscall_disables_events, - &v->arch.vgc_flags); - else - clear_bit(_VGCF_syscall_disables_events, - &v->arch.vgc_flags); - break; - - case CALLBACKTYPE_syscall32: - v->arch.pv_vcpu.syscall32_callback_eip = reg->address; - v->arch.pv_vcpu.syscall32_disables_events = - !!(reg->flags & CALLBACKF_mask_events); - break; - - case CALLBACKTYPE_sysenter: - v->arch.pv_vcpu.sysenter_callback_eip = reg->address; - v->arch.pv_vcpu.sysenter_disables_events = - !!(reg->flags & CALLBACKF_mask_events); - break; - - case CALLBACKTYPE_nmi: - ret = register_guest_nmi_callback(reg->address); - break; - - default: - ret = -ENOSYS; - break; - } - - return ret; -} - -static long unregister_guest_callback(struct callback_unregister *unreg) -{ - long ret; - - switch ( unreg->type ) - { - case CALLBACKTYPE_event: - case CALLBACKTYPE_failsafe: - case CALLBACKTYPE_syscall: - case CALLBACKTYPE_syscall32: - case CALLBACKTYPE_sysenter: - ret = -EINVAL; - break; - - case CALLBACKTYPE_nmi: - ret = unregister_guest_nmi_callback(); - break; - - default: - ret = -ENOSYS; - break; - } - - return ret; -} - - -long do_callback_op(int cmd, XEN_GUEST_HANDLE_PARAM(const_void) arg) -{ - long ret; - - switch ( cmd ) - { - case CALLBACKOP_register: - { - struct callback_register reg; - - ret = -EFAULT; - if ( copy_from_guest(®, arg, 1) ) - break; - - ret = register_guest_callback(®); - } - break; - - case CALLBACKOP_unregister: - { - struct callback_unregister unreg; - - ret = -EFAULT; - if ( copy_from_guest(&unreg, arg, 1) ) - break; - - ret = unregister_guest_callback(&unreg); - } - break; - - default: - ret = -ENOSYS; - break; - } - - return ret; -} - -long do_set_callbacks(unsigned long event_address, - unsigned long failsafe_address, - unsigned long syscall_address) -{ - struct callback_register event = { - .type = CALLBACKTYPE_event, - .address = event_address, - }; - struct callback_register failsafe = { - .type = CALLBACKTYPE_failsafe, - .address = failsafe_address, - }; - struct callback_register syscall = { - .type = CALLBACKTYPE_syscall, - .address = syscall_address, - }; - - register_guest_callback(&event); - register_guest_callback(&failsafe); - register_guest_callback(&syscall); - - return 0; -} - static void hypercall_page_initialise_ring3_kernel(void *hypercall_page) { char *p; -- 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 |