From patchwork Mon Jul 18 09:51:43 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Cooper X-Patchwork-Id: 9234331 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 380C6607FF for ; Mon, 18 Jul 2016 09:55:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1F9D5228C8 for ; Mon, 18 Jul 2016 09:55:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1471226B41; Mon, 18 Jul 2016 09:55:27 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 258F526538 for ; Mon, 18 Jul 2016 09:55:26 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bP5Du-00076s-TR; Mon, 18 Jul 2016 09:52:26 +0000 Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bP5Dt-00075D-3Y for xen-devel@lists.xen.org; Mon, 18 Jul 2016 09:52:25 +0000 Received: from [193.109.254.147] by server-12.bemta-14.messagelabs.com id 62/9A-31201-8D6AC875; Mon, 18 Jul 2016 09:52:24 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFuphkeJIrShJLcpLzFFi42JxWrrBXvf6sp5 wg7VrzS2WfFzM4sDocXT3b6YAxijWzLyk/IoE1ozjr++yFrSqV6zff5K5gfGdbBcjJ4eEgL/E 6pfbmEBsNgF9id0vPoHZIgLqEqc7LrJ2MXJwMAv4SRx64AsSFhawkrjee5INJMwioCrxYK0qS JhXwEPiw/Kj7BAT5STOH//JDFLCKeApMbtfHMQUAir5+F4RpEJIQE3iWv8ldohOQYmTM5+wgN jMAhISB1+8YIaYwi1x+/RU5gmMfLOQlM1CUraAkWkVo3pxalFZapGuhV5SUWZ6RkluYmaOrqG hiV5uanFxYnpqTmJSsV5yfu4mRmAoMQDBDsaNk5wPMUpyMCmJ8lot6AkX4kvKT6nMSCzOiC8q zUktPsQow8GhJME7eSlQTrAoNT21Ii0zBxjUMGkJDh4lEV4bkDRvcUFibnFmOkTqFKOilDhvO 0hCACSRUZoH1waLpEuMslLCvIxAhwjxFKQW5WaWoMq/YhTnYFQS5m0FmcKTmVcCN/0V0GImoM UGqt0gi0sSEVJSDYwrVR6EmN+cf/PYf7++Gc6WSjuSJDlCLhxXWtl7yPG7qXXVbHtmH9OWrLl as0p1TzDuTudg2eFwvYDpqOZKk9/TL+vevBn89ezc4ijBzcbuWsrK03R3G18TYp9+89Cjo7GH q+OkjmmozLc+8NjravH1m+KPFk5hX/ulguXVE9MQcY4DvzoqLKSVWIozEg21mIuKEwEP1xY9n wIAAA== X-Env-Sender: prvs=0008e1294=Andrew.Cooper3@citrix.com X-Msg-Ref: server-13.tower-27.messagelabs.com!1468835539!54516342!5 X-Originating-IP: [66.165.176.63] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni42MyA9PiAzMDYwNDg=\n, received_headers: No Received headers X-StarScan-Received: X-StarScan-Version: 8.77; banners=-,-,- X-VirusChecked: Checked Received: (qmail 55320 invoked from network); 18 Jul 2016 09:52:23 -0000 Received: from smtp02.citrix.com (HELO SMTP02.CITRIX.COM) (66.165.176.63) by server-13.tower-27.messagelabs.com with RC4-SHA encrypted SMTP; 18 Jul 2016 09:52:23 -0000 X-IronPort-AV: E=Sophos;i="5.28,383,1464652800"; d="scan'208";a="373756599" From: Andrew Cooper To: Xen-devel Date: Mon, 18 Jul 2016 10:51:43 +0100 Message-ID: <1468835505-7278-8-git-send-email-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1468835505-7278-1-git-send-email-andrew.cooper3@citrix.com> References: <1468835505-7278-1-git-send-email-andrew.cooper3@citrix.com> MIME-Version: 1.0 X-DLP: MIA2 Cc: Andrew Cooper , Jan Beulich Subject: [Xen-devel] [PATCH 7/9] x86/pv: Merge the pv hypercall tables X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP For the same reason as c/s 33a231e3f "x86/HVM: fold hypercall tables", this removes the risk of accidentally updating only one of the tables. Signed-off-by: Andrew Cooper Reviewed-by: Jan Beulich --- CC: Jan Beulich --- xen/arch/x86/hypercall.c | 75 +++++++++--------------------------------------- 1 file changed, 13 insertions(+), 62 deletions(-) diff --git a/xen/arch/x86/hypercall.c b/xen/arch/x86/hypercall.c index 892012d..b9bd58d 100644 --- a/xen/arch/x86/hypercall.c +++ b/xen/arch/x86/hypercall.c @@ -114,64 +114,15 @@ const uint8_t compat_hypercall_args_table[NR_hypercalls] = #undef ARGS #define HYPERCALL(x) \ - [ __HYPERVISOR_ ## x ] = (hypercall_fn_t *) do_ ## x + [ __HYPERVISOR_ ## x ] = { (hypercall_fn_t *) do_ ## x, \ + (hypercall_fn_t *) do_ ## x } +#define COMPAT_CALL(x) \ + [ __HYPERVISOR_ ## x ] = { (hypercall_fn_t *) do_ ## x, \ + (hypercall_fn_t *) compat_ ## x } #define do_arch_1 paging_domctl_continuation -hypercall_fn_t *const hypercall_table[NR_hypercalls] = { - HYPERCALL(set_trap_table), - HYPERCALL(mmu_update), - HYPERCALL(set_gdt), - HYPERCALL(stack_switch), - HYPERCALL(set_callbacks), - HYPERCALL(fpu_taskswitch), - HYPERCALL(sched_op_compat), - HYPERCALL(platform_op), - HYPERCALL(set_debugreg), - HYPERCALL(get_debugreg), - HYPERCALL(update_descriptor), - HYPERCALL(memory_op), - HYPERCALL(multicall), - HYPERCALL(update_va_mapping), - HYPERCALL(set_timer_op), - HYPERCALL(event_channel_op_compat), - HYPERCALL(xen_version), - HYPERCALL(console_io), - HYPERCALL(physdev_op_compat), - HYPERCALL(grant_table_op), - HYPERCALL(vm_assist), - HYPERCALL(update_va_mapping_otherdomain), - HYPERCALL(iret), - HYPERCALL(vcpu_op), - HYPERCALL(set_segment_base), - HYPERCALL(mmuext_op), - HYPERCALL(xsm_op), - HYPERCALL(nmi_op), - HYPERCALL(sched_op), - HYPERCALL(callback_op), -#ifdef CONFIG_XENOPROF - HYPERCALL(xenoprof_op), -#endif - HYPERCALL(event_channel_op), - HYPERCALL(physdev_op), - HYPERCALL(hvm_op), - HYPERCALL(sysctl), - HYPERCALL(domctl), -#ifdef CONFIG_KEXEC - HYPERCALL(kexec_op), -#endif -#ifdef CONFIG_TMEM - HYPERCALL(tmem_op), -#endif - HYPERCALL(xenpmu_op), - HYPERCALL(mca), - HYPERCALL(arch_1), -}; - -#define COMPAT_CALL(x) \ - [ __HYPERVISOR_ ## x ] = (hypercall_fn_t *) compat_ ## x - -hypercall_fn_t *const compat_hypercall_table[NR_hypercalls] = { +static const hypercall_table_t pv_hypercall_table[NR_hypercalls] = { COMPAT_CALL(set_trap_table), HYPERCALL(mmu_update), COMPAT_CALL(set_gdt), @@ -236,7 +187,7 @@ long pv_hypercall(struct cpu_user_regs *regs) ASSERT(curr->arch.flags & TF_kernel_mode); - if ( (eax >= NR_hypercalls) || !hypercall_table[eax] ) + if ( (eax >= NR_hypercalls) || !pv_hypercall_table[eax].native ) return -ENOSYS; if ( !is_pv_32bit_vcpu(curr) ) @@ -267,7 +218,7 @@ long pv_hypercall(struct cpu_user_regs *regs) __trace_hypercall(TRC_PV_HYPERCALL_V2, eax, args); } - ret = hypercall_table[eax](rdi, rsi, rdx, r10, r8, r9); + ret = pv_hypercall_table[eax].native(rdi, rsi, rdx, r10, r8, r9); #ifndef NDEBUG if ( regs->rip == old_rip ) @@ -314,7 +265,7 @@ long pv_hypercall(struct cpu_user_regs *regs) __trace_hypercall(TRC_PV_HYPERCALL_V2, eax, args); } - ret = compat_hypercall_table[eax](ebx, ecx, edx, esi, edi, ebp); + ret = pv_hypercall_table[eax].compat(ebx, ecx, edx, esi, edi, ebp); #ifndef NDEBUG if ( regs->rip == old_rip ) @@ -344,8 +295,8 @@ void arch_do_multicall_call(struct mc_state *state) { struct multicall_entry *call = &state->call; - if ( (call->op < NR_hypercalls) && hypercall_table[call->op] ) - call->result = hypercall_table[call->op]( + if ( (call->op < NR_hypercalls) && pv_hypercall_table[call->op].native ) + call->result = pv_hypercall_table[call->op].native( call->args[0], call->args[1], call->args[2], call->args[3], call->args[4], call->args[5]); else @@ -356,8 +307,8 @@ void arch_do_multicall_call(struct mc_state *state) { struct compat_multicall_entry *call = &state->compat_call; - if ( (call->op < NR_hypercalls) && compat_hypercall_table[call->op] ) - call->result = compat_hypercall_table[call->op]( + if ( (call->op < NR_hypercalls) && pv_hypercall_table[call->op].compat ) + call->result = pv_hypercall_table[call->op].compat( call->args[0], call->args[1], call->args[2], call->args[3], call->args[4], call->args[5]); else