From patchwork Tue Sep 6 10:12:56 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Cooper X-Patchwork-Id: 9316323 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 F0C6A601C0 for ; Tue, 6 Sep 2016 10:15:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E0BA528B77 for ; Tue, 6 Sep 2016 10:15:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D592828C36; Tue, 6 Sep 2016 10:15:34 +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 0E7BA28B77 for ; Tue, 6 Sep 2016 10:15:32 +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 1bhDNN-0005jB-Sv; Tue, 06 Sep 2016 10:13:09 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bhDNM-0005fS-Ee for xen-devel@lists.xen.org; Tue, 06 Sep 2016 10:13:08 +0000 Received: from [85.158.137.68] by server-1.bemta-3.messagelabs.com id 3F/1A-17152-3B69EC75; Tue, 06 Sep 2016 10:13:07 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFupjkeJIrShJLcpLzFFi42JxWrohUnfztHP hBjNuSFgs+biYxYHR4+ju30wBjFGsmXlJ+RUJrBmrFzsVPHOs2PfuI0sD4w/NLkZODgkBf4lX FzuYQWw2AX2J3S8+MYHYIgLqEqc7LrJ2MXJwMAvoSqz6qQESFhZwlbh/vpkNxGYRUJHYcfs3W DmvgKfE2vmzmCBGykmcP/4TbCSngJfEsb5HYLYQUM2GF60sELaaxLX+S+wQvYISJ2c+AYszC0 hIHHzxghlkrYQAt8TfbvsJjHyzkFTNQlK1gJFpFaNGcWpRWWqRrpGZXlJRZnpGSW5iZo6uoYG xXm5qcXFiempOYlKxXnJ+7iZGYDjVMzAw7mBs2Ot3iFGSg0lJlFct8Fy4EF9SfkplRmJxRnxR aU5q8SFGGQ4OJQneeVOBcoJFqempFWmZOcDAhklLcPAoifAGgKR5iwsSc4sz0yFSpxgVpcR5i 0ASAiCJjNI8uDZYNF1ilJUS5mVkYGAQ4ilILcrNLEGVf8UozsGoJMw7AWQKT2ZeCdz0V0CLmY AWr9t9GmRxSSJCSqqB0SGO15xp+bXGv2zMZtrOBlN75zcd3/4zO6p/YeC6pJcvRARfpRrqGjH mTdTnvPfXlyH939Wrncdq6qRSVwQ/0d94u8t4r+bxL5FMW++Ff1f6yv5yhsmMdWekV7La5hxX u31ye1dPd0nM7fDDh33n7f0y54yEqwqz9ak1Rst/F+1XlNgYkOCwVImlOCPRUIu5qDgRAEGbf NqhAgAA X-Env-Sender: prvs=05022f6da=Andrew.Cooper3@citrix.com X-Msg-Ref: server-14.tower-31.messagelabs.com!1473156785!59187427!1 X-Originating-IP: [66.165.176.89] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni44OSA9PiAyMDMwMDc=\n, received_headers: No Received headers X-StarScan-Received: X-StarScan-Version: 8.84; banners=-,-,- X-VirusChecked: Checked Received: (qmail 1848 invoked from network); 6 Sep 2016 10:13:06 -0000 Received: from smtp.citrix.com (HELO SMTP.CITRIX.COM) (66.165.176.89) by server-14.tower-31.messagelabs.com with RC4-SHA encrypted SMTP; 6 Sep 2016 10:13:06 -0000 X-IronPort-AV: E=Sophos;i="5.30,291,1470700800"; d="scan'208";a="376488457" From: Andrew Cooper To: Xen-devel Date: Tue, 6 Sep 2016 11:12:56 +0100 Message-ID: <1473156779-11759-7-git-send-email-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1473156779-11759-1-git-send-email-andrew.cooper3@citrix.com> References: <1473156779-11759-1-git-send-email-andrew.cooper3@citrix.com> MIME-Version: 1.0 X-DLP: MIA1 Cc: Andrew Cooper Subject: [Xen-devel] [PATCH v2 6/9] xen/multicall: Rework arch multicall handling 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 The x86 multicall handling was previously some very hairy inline assembly, and is hard to follow and maintain. Replace the existing do_multicall_call() with arch_do_multicall_call(). The x86 side needs to handle both compat and non-compat calls, so pass the full multicall state, rather than just the multicall_entry sub-structure. On the ARM side, alter the prototype to match, but there is no resulting functional change. On the x86 side, the implementation is now in plain C. This allows the removal of both asm/multicall.h header files. Signed-off-by: Andrew Cooper Acked-by: Julien Grall Reviewed-by: Jan Beulich --- xen/arch/arm/traps.c | 3 +- xen/arch/x86/hypercall.c | 28 ++++++++++++++++ xen/common/multicall.c | 2 +- xen/include/asm-arm/multicall.h | 14 -------- xen/include/asm-x86/multicall.h | 72 ----------------------------------------- xen/include/xen/multicall.h | 3 +- 6 files changed, 33 insertions(+), 89 deletions(-) delete mode 100644 xen/include/asm-arm/multicall.h delete mode 100644 xen/include/asm-x86/multicall.h diff --git a/xen/arch/arm/traps.c b/xen/arch/arm/traps.c index 683bcb2..9353ee7 100644 --- a/xen/arch/arm/traps.c +++ b/xen/arch/arm/traps.c @@ -1516,8 +1516,9 @@ static bool_t check_multicall_32bit_clean(struct multicall_entry *multi) return true; } -void do_multicall_call(struct multicall_entry *multi) +void arch_do_multicall_call(struct mc_state *state) { + struct multicall_entry *multi = &state->call; arm_hypercall_fn_t call = NULL; if ( multi->op >= ARRAY_SIZE(arm_hypercall_table) ) diff --git a/xen/arch/x86/hypercall.c b/xen/arch/x86/hypercall.c index faff260..b814c0b 100644 --- a/xen/arch/x86/hypercall.c +++ b/xen/arch/x86/hypercall.c @@ -340,6 +340,34 @@ void pv_hypercall(struct cpu_user_regs *regs) perfc_incr(hypercalls); } +void arch_do_multicall_call(struct mc_state *state) +{ + if ( !is_pv_32bit_vcpu(current) ) + { + struct multicall_entry *call = &state->call; + + if ( (call->op < NR_hypercalls) && hypercall_table[call->op] ) + call->result = hypercall_table[call->op]( + call->args[0], call->args[1], call->args[2], + call->args[3], call->args[4], call->args[5]); + else + call->result = -ENOSYS; + } +#ifdef CONFIG_COMPAT + else + { + 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]( + call->args[0], call->args[1], call->args[2], + call->args[3], call->args[4], call->args[5]); + else + call->result = -ENOSYS; + } +#endif +} + /* * Local variables: * mode: C diff --git a/xen/common/multicall.c b/xen/common/multicall.c index 21661ee..524c9bf 100644 --- a/xen/common/multicall.c +++ b/xen/common/multicall.c @@ -63,7 +63,7 @@ do_multicall( trace_multicall_call(&mcs->call); - do_multicall_call(&mcs->call); + arch_do_multicall_call(mcs); #ifndef NDEBUG { diff --git a/xen/include/asm-arm/multicall.h b/xen/include/asm-arm/multicall.h deleted file mode 100644 index b959262..0000000 --- a/xen/include/asm-arm/multicall.h +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef __ASM_ARM_MULTICALL_H__ -#define __ASM_ARM_MULTICALL_H__ - -extern void do_multicall_call(struct multicall_entry *call); - -#endif /* __ASM_ARM_MULTICALL_H__ */ -/* - * Local variables: - * mode: C - * c-file-style: "BSD" - * c-basic-offset: 4 - * indent-tabs-mode: nil - * End: - */ diff --git a/xen/include/asm-x86/multicall.h b/xen/include/asm-x86/multicall.h deleted file mode 100644 index fcd0ea5..0000000 --- a/xen/include/asm-x86/multicall.h +++ /dev/null @@ -1,72 +0,0 @@ -/****************************************************************************** - * asm-x86/multicall.h - */ - -#ifndef __ASM_X86_MULTICALL_H__ -#define __ASM_X86_MULTICALL_H__ - -#include - -#define do_multicall_call(_call) \ - do { \ - __asm__ __volatile__ ( \ - " movq %c1(%0),%%rax; " \ - " leaq hypercall_table(%%rip),%%rdi; " \ - " cmpq $("STR(NR_hypercalls)"),%%rax; " \ - " jae 2f; " \ - " movq (%%rdi,%%rax,8),%%rax; " \ - " movq %c2+0*%c3(%0),%%rdi; " \ - " movq %c2+1*%c3(%0),%%rsi; " \ - " movq %c2+2*%c3(%0),%%rdx; " \ - " movq %c2+3*%c3(%0),%%rcx; " \ - " movq %c2+4*%c3(%0),%%r8; " \ - " movq %c2+5*%c3(%0),%%r9; " \ - " callq *%%rax; " \ - "1: movq %%rax,%c4(%0)\n" \ - ".section .fixup,\"ax\"\n" \ - "2: movq %5,%%rax\n" \ - " jmp 1b\n" \ - ".previous\n" \ - : \ - : "b" (_call), \ - "i" (offsetof(__typeof__(*_call), op)), \ - "i" (offsetof(__typeof__(*_call), args)), \ - "i" (sizeof(*(_call)->args)), \ - "i" (offsetof(__typeof__(*_call), result)), \ - "i" (-ENOSYS) \ - /* all the caller-saves registers */ \ - : "rax", "rcx", "rdx", "rsi", "rdi", \ - "r8", "r9", "r10", "r11" ); \ - } while ( 0 ) - -#define compat_multicall_call(_call) \ - __asm__ __volatile__ ( \ - " movl %c1(%0),%%eax; " \ - " leaq compat_hypercall_table(%%rip),%%rdi; "\ - " cmpl $("STR(NR_hypercalls)"),%%eax; " \ - " jae 2f; " \ - " movq (%%rdi,%%rax,8),%%rax; " \ - " movl %c2+0*%c3(%0),%%edi; " \ - " movl %c2+1*%c3(%0),%%esi; " \ - " movl %c2+2*%c3(%0),%%edx; " \ - " movl %c2+3*%c3(%0),%%ecx; " \ - " movl %c2+4*%c3(%0),%%r8d; " \ - " movl %c2+5*%c3(%0),%%r9d; " \ - " callq *%%rax; " \ - "1: movl %%eax,%c4(%0)\n" \ - ".section .fixup,\"ax\"\n" \ - "2: movl %5,%%eax\n" \ - " jmp 1b\n" \ - ".previous\n" \ - : \ - : "b" (_call), \ - "i" (offsetof(__typeof__(*_call), op)), \ - "i" (offsetof(__typeof__(*_call), args)), \ - "i" (sizeof(*(_call)->args)), \ - "i" (offsetof(__typeof__(*_call), result)), \ - "i" (-ENOSYS) \ - /* all the caller-saves registers */ \ - : "rax", "rcx", "rdx", "rsi", "rdi", \ - "r8", "r9", "r10", "r11" ) \ - -#endif /* __ASM_X86_MULTICALL_H__ */ diff --git a/xen/include/xen/multicall.h b/xen/include/xen/multicall.h index 0e8d8bb..fff15eb 100644 --- a/xen/include/xen/multicall.h +++ b/xen/include/xen/multicall.h @@ -6,7 +6,6 @@ #define __XEN_MULTICALL_H__ #include -#include #ifdef CONFIG_COMPAT #include #endif @@ -25,4 +24,6 @@ struct mc_state { }; }; +void arch_do_multicall_call(struct mc_state *mc); + #endif /* __XEN_MULTICALL_H__ */