From: Andrew Cooper Date: Tue, 14 Feb 2017 18:21:22 +0000 (+0000) Subject: x86/hypercall: Make the HVM hcall_64bit boolean common X-Git-Tag: archive/raspbian/4.11.1-1+rpi1~1^2~66^2~2761 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=bb84ffc56ec14766f33a002a61fd97a62b6b17cd;p=xen.git x86/hypercall: Make the HVM hcall_64bit boolean common HVM guests currently make use of arch.hvm_vcpu.hcall_64bit to track the ABI of the hypercall in use. The rest of Xen deals in terms of the comat ABI or not, so rename the boolean and make it common, guared by CONFIG_COMPAT to avoid bloat if a compat ABI is not wanted/needed. Set hcall_compat uniformly for PV guests as well as HVM guests. This removes the remaining piece of guest-type-specific knowledge from hypercall_create_continuation(), allowing it to operate only in terms of the hypercall ABI in use. Signed-off-by: Andrew Cooper Reviewed-by: Jan Beulich --- diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c index 4ffd94b317..694d2dc71a 100644 --- a/xen/arch/x86/domain.c +++ b/xen/arch/x86/domain.c @@ -2225,9 +2225,7 @@ unsigned long hypercall_create_continuation( regs->rax = op; - if ( is_pv_vcpu(curr) ? - !is_pv_32bit_vcpu(curr) : - curr->arch.hvm_vcpu.hcall_64bit ) + if ( !curr->hcall_compat ) { for ( i = 0; *p != '\0'; i++ ) { diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c index 3f5c4bfdd6..6621d629a5 100644 --- a/xen/arch/x86/hvm/hvm.c +++ b/xen/arch/x86/hvm/hvm.c @@ -3253,8 +3253,7 @@ unsigned long copy_to_user_hvm(void *to, const void *from, unsigned int len) { int rc; - if ( !current->arch.hvm_vcpu.hcall_64bit && - is_compat_arg_xlat_range(to, len) ) + if ( current->hcall_compat && is_compat_arg_xlat_range(to, len) ) { memcpy(to, from, len); return 0; @@ -3268,8 +3267,7 @@ unsigned long clear_user_hvm(void *to, unsigned int len) { int rc; - if ( !current->arch.hvm_vcpu.hcall_64bit && - is_compat_arg_xlat_range(to, len) ) + if ( current->hcall_compat && is_compat_arg_xlat_range(to, len) ) { memset(to, 0x00, len); return 0; @@ -3283,8 +3281,7 @@ unsigned long copy_from_user_hvm(void *to, const void *from, unsigned len) { int rc; - if ( !current->arch.hvm_vcpu.hcall_64bit && - is_compat_arg_xlat_range(from, len) ) + if ( current->hcall_compat && is_compat_arg_xlat_range(from, len) ) { memcpy(to, from, len); return 0; diff --git a/xen/arch/x86/hvm/hypercall.c b/xen/arch/x86/hvm/hypercall.c index fe7802b107..0f7c310d28 100644 --- a/xen/arch/x86/hvm/hypercall.c +++ b/xen/arch/x86/hvm/hypercall.c @@ -35,7 +35,7 @@ static long hvm_memory_op(int cmd, XEN_GUEST_HANDLE_PARAM(void) arg) return -ENOSYS; } - if ( curr->arch.hvm_vcpu.hcall_64bit ) + if ( !curr->hcall_compat ) rc = do_memory_op(cmd, arg); else rc = compat_memory_op(cmd, arg); @@ -65,7 +65,7 @@ static long hvm_grant_table_op( return -ENOSYS; } - if ( current->arch.hvm_vcpu.hcall_64bit ) + if ( !current->hcall_compat ) return do_grant_table_op(cmd, uop, count); else return compat_grant_table_op(cmd, uop, count); @@ -89,7 +89,7 @@ static long hvm_physdev_op(int cmd, XEN_GUEST_HANDLE_PARAM(void) arg) break; } - if ( curr->arch.hvm_vcpu.hcall_64bit ) + if ( !curr->hcall_compat ) return do_physdev_op(cmd, arg); else return compat_physdev_op(cmd, arg); @@ -203,12 +203,9 @@ int hvm_hypercall(struct cpu_user_regs *regs) } #endif - curr->arch.hvm_vcpu.hcall_64bit = 1; regs->rax = hvm_hypercall_table[eax].native(rdi, rsi, rdx, r10, r8, r9); - curr->arch.hvm_vcpu.hcall_64bit = 0; - #ifndef NDEBUG if ( !curr->hcall_preempted ) { @@ -250,8 +247,10 @@ int hvm_hypercall(struct cpu_user_regs *regs) } #endif + curr->hcall_compat = true; regs->rax = hvm_hypercall_table[eax].compat(ebx, ecx, edx, esi, edi, ebp); + curr->hcall_compat = false; #ifndef NDEBUG if ( !curr->hcall_preempted ) diff --git a/xen/arch/x86/hypercall.c b/xen/arch/x86/hypercall.c index 945afa0e01..c0718f8b5f 100644 --- a/xen/arch/x86/hypercall.c +++ b/xen/arch/x86/hypercall.c @@ -234,7 +234,9 @@ void pv_hypercall(struct cpu_user_regs *regs) __trace_hypercall(TRC_PV_HYPERCALL_V2, eax, args); } + curr->hcall_compat = true; regs->_eax = pv_hypercall_table[eax].compat(ebx, ecx, edx, esi, edi, ebp); + curr->hcall_compat = false; #ifndef NDEBUG if ( !curr->hcall_preempted ) diff --git a/xen/include/asm-x86/hvm/vcpu.h b/xen/include/asm-x86/hvm/vcpu.h index 6d5553d4db..6c54773f1c 100644 --- a/xen/include/asm-x86/hvm/vcpu.h +++ b/xen/include/asm-x86/hvm/vcpu.h @@ -166,8 +166,6 @@ struct hvm_vcpu { bool debug_state_latch; bool single_step; - bool hcall_64bit; - struct hvm_vcpu_asid n1asid; u32 msr_tsc_aux; diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h index 1b1c26abeb..0929c0b910 100644 --- a/xen/include/xen/sched.h +++ b/xen/include/xen/sched.h @@ -205,6 +205,10 @@ struct vcpu /* A hypercall has been preempted. */ bool hcall_preempted; +#ifdef CONFIG_COMPAT + /* A hypercall is using the compat ABI? */ + bool hcall_compat; +#endif /*