diff --git a/xen/arch/x86/pv/hypercall.c b/xen/arch/x86/pv/hypercall.c index 9765e674cf..3579ba905c 100644 --- a/xen/arch/x86/pv/hypercall.c +++ b/xen/arch/x86/pv/hypercall.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include @@ -109,15 +110,15 @@ const pv_hypercall_table_t pv_hypercall_table[] = { #undef COMPAT_CALL #undef HYPERCALL -void pv_hypercall(struct cpu_user_regs *regs) +/* Forced inline to cause 'compat' to be evaluated at compile time. */ +static void always_inline +_pv_hypercall(struct cpu_user_regs *regs, bool compat) { struct vcpu *curr = current; - unsigned long eax; + unsigned long eax = compat ? regs->eax : regs->rax; ASSERT(guest_kernel_mode(curr, regs)); - eax = is_pv_32bit_vcpu(curr) ? regs->eax : regs->rax; - BUILD_BUG_ON(ARRAY_SIZE(pv_hypercall_table) > ARRAY_SIZE(hypercall_args_table)); @@ -137,7 +138,7 @@ void pv_hypercall(struct cpu_user_regs *regs) curr->hcall_preempted = false; - if ( !is_pv_32bit_vcpu(curr) ) + if ( !compat ) { unsigned long rdi = regs->rdi; unsigned long rsi = regs->rsi; @@ -348,8 +349,21 @@ void pv_ring1_init_hypercall_page(void *p) *(u8 *)(p+ 7) = 0xc3; /* ret */ } } + +void do_entry_int82(struct cpu_user_regs *regs) +{ + if ( unlikely(untrusted_msi) ) + check_for_unexpected_msi((uint8_t)regs->entry_vector); + + _pv_hypercall(regs, true /* compat */); +} #endif +void pv_hypercall(struct cpu_user_regs *regs) +{ + _pv_hypercall(regs, false /* native */); +} + /* * Local variables: * mode: C diff --git a/xen/arch/x86/pv/traps.c b/xen/arch/x86/pv/traps.c index 764773c021..1e05a9f1cd 100644 --- a/xen/arch/x86/pv/traps.c +++ b/xen/arch/x86/pv/traps.c @@ -24,22 +24,11 @@ #include #include -#include #include #include #include #include -#ifdef CONFIG_PV32 -void do_entry_int82(struct cpu_user_regs *regs) -{ - if ( unlikely(untrusted_msi) ) - check_for_unexpected_msi((uint8_t)regs->entry_vector); - - pv_hypercall(regs); -} -#endif - void pv_inject_event(const struct x86_event *event) { struct vcpu *curr = current;