[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH 3/3] x86/pv: Minor tweaks to {, compat_}register_guest_callback()
* Being internal functions, use int rather than long for the return value * Factor out pv_vcpu into a local variable. Reduces code volume, and removes some split lines. Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx> --- CC: Jan Beulich <JBeulich@xxxxxxxx> CC: Wei Liu <wei.liu2@xxxxxxxxxx> CC: Roger Pau Monné <roger.pau@xxxxxxxxxx> --- xen/arch/x86/pv/callback.c | 48 ++++++++++++++++++++++------------------------ 1 file changed, 23 insertions(+), 25 deletions(-) diff --git a/xen/arch/x86/pv/callback.c b/xen/arch/x86/pv/callback.c index 866c835..362197b 100644 --- a/xen/arch/x86/pv/callback.c +++ b/xen/arch/x86/pv/callback.c @@ -71,10 +71,11 @@ static void unregister_guest_nmi_callback(void) memset(t, 0, sizeof(*t)); } -static long register_guest_callback(struct callback_register *reg) +static int register_guest_callback(struct callback_register *reg) { - long ret = 0; struct vcpu *curr = current; + struct pv_vcpu *pv = &curr->arch.pv_vcpu; + int ret = 0; if ( !is_canonical_address(reg->address) ) return -EINVAL; @@ -82,11 +83,11 @@ static long register_guest_callback(struct callback_register *reg) switch ( reg->type ) { case CALLBACKTYPE_event: - curr->arch.pv_vcpu.event_callback_eip = reg->address; + pv->event_callback_eip = reg->address; break; case CALLBACKTYPE_failsafe: - curr->arch.pv_vcpu.failsafe_callback_eip = reg->address; + pv->failsafe_callback_eip = reg->address; if ( reg->flags & CALLBACKF_mask_events ) curr->arch.vgc_flags |= VGCF_failsafe_disables_events; else @@ -94,7 +95,7 @@ static long register_guest_callback(struct callback_register *reg) break; case CALLBACKTYPE_syscall: - curr->arch.pv_vcpu.syscall_callback_eip = reg->address; + pv->syscall_callback_eip = reg->address; if ( reg->flags & CALLBACKF_mask_events ) curr->arch.vgc_flags |= VGCF_syscall_disables_events; else @@ -102,15 +103,13 @@ static long register_guest_callback(struct callback_register *reg) break; case CALLBACKTYPE_syscall32: - curr->arch.pv_vcpu.syscall32_callback_eip = reg->address; - curr->arch.pv_vcpu.syscall32_disables_events = - !!(reg->flags & CALLBACKF_mask_events); + pv->syscall32_callback_eip = reg->address; + pv->syscall32_disables_events = reg->flags & CALLBACKF_mask_events; break; case CALLBACKTYPE_sysenter: - curr->arch.pv_vcpu.sysenter_callback_eip = reg->address; - curr->arch.pv_vcpu.sysenter_disables_events = - !!(reg->flags & CALLBACKF_mask_events); + pv->sysenter_callback_eip = reg->address; + pv->sysenter_disables_events = reg->flags & CALLBACKF_mask_events; break; case CALLBACKTYPE_nmi: @@ -214,23 +213,24 @@ long do_set_callbacks(unsigned long event_address, return 0; } -static long compat_register_guest_callback(struct compat_callback_register *reg) +static int compat_register_guest_callback(struct compat_callback_register *reg) { - long ret = 0; struct vcpu *curr = current; + struct pv_vcpu *pv = &curr->arch.pv_vcpu; + int ret = 0; fixup_guest_code_selector(curr->domain, reg->address.cs); switch ( reg->type ) { case CALLBACKTYPE_event: - curr->arch.pv_vcpu.event_callback_cs = reg->address.cs; - curr->arch.pv_vcpu.event_callback_eip = reg->address.eip; + pv->event_callback_cs = reg->address.cs; + pv->event_callback_eip = reg->address.eip; break; case CALLBACKTYPE_failsafe: - curr->arch.pv_vcpu.failsafe_callback_cs = reg->address.cs; - curr->arch.pv_vcpu.failsafe_callback_eip = reg->address.eip; + pv->failsafe_callback_cs = reg->address.cs; + pv->failsafe_callback_eip = reg->address.eip; if ( reg->flags & CALLBACKF_mask_events ) curr->arch.vgc_flags |= VGCF_failsafe_disables_events; else @@ -238,17 +238,15 @@ static long compat_register_guest_callback(struct compat_callback_register *reg) break; case CALLBACKTYPE_syscall32: - curr->arch.pv_vcpu.syscall32_callback_cs = reg->address.cs; - curr->arch.pv_vcpu.syscall32_callback_eip = reg->address.eip; - curr->arch.pv_vcpu.syscall32_disables_events = - (reg->flags & CALLBACKF_mask_events) != 0; + pv->syscall32_callback_cs = reg->address.cs; + pv->syscall32_callback_eip = reg->address.eip; + pv->syscall32_disables_events = reg->flags & CALLBACKF_mask_events; break; case CALLBACKTYPE_sysenter: - curr->arch.pv_vcpu.sysenter_callback_cs = reg->address.cs; - curr->arch.pv_vcpu.sysenter_callback_eip = reg->address.eip; - curr->arch.pv_vcpu.sysenter_disables_events = - (reg->flags & CALLBACKF_mask_events) != 0; + pv->sysenter_callback_cs = reg->address.cs; + pv->sysenter_callback_eip = reg->address.eip; + pv->sysenter_disables_events = reg->flags & CALLBACKF_mask_events; break; case CALLBACKTYPE_nmi: -- 2.1.4 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxxxxxxxxx https://lists.xenproject.org/mailman/listinfo/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |