From patchwork Mon Aug 14 15:46:28 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Liu X-Patchwork-Id: 9899505 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 23F5F602CA for ; Mon, 14 Aug 2017 15:48:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 15C4828414 for ; Mon, 14 Aug 2017 15:48:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0A56228500; Mon, 14 Aug 2017 15:48:44 +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 6608728455 for ; Mon, 14 Aug 2017 15:48:43 +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 1dhHZa-00052A-Fq; Mon, 14 Aug 2017 15:46:34 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dhHZZ-000524-J9 for xen-devel@lists.xenproject.org; Mon, 14 Aug 2017 15:46:33 +0000 Received: from [85.158.137.68] by server-4.bemta-3.messagelabs.com id B1/02-04533-8D5C1995; Mon, 14 Aug 2017 15:46:32 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrJLMWRWlGSWpSXmKPExsXitHRDpO6NoxM jDTo/y1p83zKZyYHR4/CHKywBjFGsmXlJ+RUJrBmr3n5iLlijUvHxyCPWBsZt0l2MnBwSAv4S Vx40s4DYbALKEj87e9lAbBEBPYmmA88Zuxi5OJgFDjJKTLw5k6mLkYNDWMBZYtOtepAaFgFVi RkPIXp5BSwkXn55xggxU15iV9tFVhBbSEBBomP6MSaIGkGJkzOfgNUzC0hIHHzxgnkCI/csJK lZSFILGJlWMWoUpxaVpRbpGpnoJRVlpmeU5CZm5ugaGhjr5aYWFyemp+YkJhXrJefnbmIEBkM 9AwPjDsZXx/0OMUpyMCmJ8ib49EYK8SXlp1RmJBZnxBeV5qQWH2KU4eBQkuDNOTIxUkiwKDU9 tSItMwcYljBpCQ4eJRHepyBp3uKCxNzizHSI1ClGXY5XE/5/YxJiycvPS5US590FUiQAUpRRm gc3AhYjlxhlpYR5GRkYGIR4ClKLcjNLUOVfMYpzMCoJ8x4AmcKTmVcCt+kV0BFMQEf0gdzPW1 ySiJCSamAs2JZT8ChD+++qP9KzVpRwvt3wfvJxDns75dg9+R94syX8r1R6zfr47GDa693ipjb pKib7vX7cmmAqsUdjnkHRkwxD7ZNfp/xXaOBV6V+7oZk1lk9JvuCTX+reiMWS+ywkajlXNrke k3bym/1tsfAMUc9bMaeUtXVyO4IeJ99OXTX5f1Ku5lwlluKMREMt5qLiRABi88dHjAIAAA== X-Env-Sender: prvs=392ec1398=wei.liu2@citrix.com X-Msg-Ref: server-7.tower-31.messagelabs.com!1502725590!102403091!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: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 48367 invoked from network); 14 Aug 2017 15:46:32 -0000 Received: from smtp.citrix.com (HELO SMTP.CITRIX.COM) (66.165.176.89) by server-7.tower-31.messagelabs.com with RC4-SHA encrypted SMTP; 14 Aug 2017 15:46:32 -0000 X-IronPort-AV: E=Sophos;i="5.41,373,1498521600"; d="scan'208";a="435424982" From: Wei Liu To: Xen-devel Date: Mon, 14 Aug 2017 16:46:28 +0100 Message-ID: <20170814154628.11769-1-wei.liu2@citrix.com> X-Mailer: git-send-email 2.11.0 MIME-Version: 1.0 Cc: Andrew Cooper , Julien Grall , Stefano Stabellini , Wei Liu , Jan Beulich Subject: [Xen-devel] [PATCH] xen: lift hypercall_cancel_continuation to sched.h 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 function is the same on both x86 and arm. Lift it to sched.h to save a function call, make it take a pointer to vcpu to avoid resolving current every time it gets called. Take the chance to change its callers to only use one current in code. Signed-off-by: Wei Liu Acked-by: Julien Grall Reviewed-by: Jan Beulich --- Cc: Jan Beulich Cc: Andrew Cooper Cc: Stefano Stabellini Cc: Julien Grall --- xen/arch/arm/domain.c | 5 ----- xen/arch/x86/hypercall.c | 5 ----- xen/arch/x86/x86_64/compat/mm.c | 5 +++-- xen/common/multicall.c | 7 ++++--- xen/include/xen/sched.h | 6 +++++- 5 files changed, 12 insertions(+), 16 deletions(-) diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c index 2dc8b0ab5a..eeebbdb39a 100644 --- a/xen/arch/arm/domain.c +++ b/xen/arch/arm/domain.c @@ -365,11 +365,6 @@ void sync_vcpu_execstate(struct vcpu *v) __arg; \ }) -void hypercall_cancel_continuation(void) -{ - current->hcall_preempted = false; -} - unsigned long hypercall_create_continuation( unsigned int op, const char *format, ...) { diff --git a/xen/arch/x86/hypercall.c b/xen/arch/x86/hypercall.c index e30181817a..90e88c1d2c 100644 --- a/xen/arch/x86/hypercall.c +++ b/xen/arch/x86/hypercall.c @@ -86,11 +86,6 @@ const hypercall_args_t hypercall_args_table[NR_hypercalls] = __arg; \ }) -void hypercall_cancel_continuation(void) -{ - current->hcall_preempted = false; -} - unsigned long hypercall_create_continuation( unsigned int op, const char *format, ...) { diff --git a/xen/arch/x86/x86_64/compat/mm.c b/xen/arch/x86/x86_64/compat/mm.c index b737af1888..f3fc07c3a9 100644 --- a/xen/arch/x86/x86_64/compat/mm.c +++ b/xen/arch/x86/x86_64/compat/mm.c @@ -53,6 +53,7 @@ int compat_arch_memory_op(unsigned long cmd, XEN_GUEST_HANDLE_PARAM(void) arg) compat_pfn_t mfn; unsigned int i; int rc = 0; + struct vcpu *curr = current; switch ( cmd ) { @@ -124,7 +125,7 @@ int compat_arch_memory_op(unsigned long cmd, XEN_GUEST_HANDLE_PARAM(void) arg) if ( __copy_to_guest(arg, &cmp, 1) ) { if ( rc == __HYPERVISOR_memory_op ) - hypercall_cancel_continuation(); + hypercall_cancel_continuation(curr); rc = -EFAULT; } @@ -133,7 +134,7 @@ int compat_arch_memory_op(unsigned long cmd, XEN_GUEST_HANDLE_PARAM(void) arg) case XENMEM_machphys_mapping: { - struct domain *d = current->domain; + struct domain *d = curr->domain; struct compat_machphys_mapping mapping = { .v_start = MACH2PHYS_COMPAT_VIRT_START(d), .v_end = MACH2PHYS_COMPAT_VIRT_END, diff --git a/xen/common/multicall.c b/xen/common/multicall.c index 7cbf857048..c7af4e0156 100644 --- a/xen/common/multicall.c +++ b/xen/common/multicall.c @@ -36,7 +36,8 @@ ret_t do_multicall( XEN_GUEST_HANDLE_PARAM(multicall_entry_t) call_list, uint32_t nr_calls) { - struct mc_state *mcs = ¤t->mc_state; + struct vcpu *curr = current; + struct mc_state *mcs = &curr->mc_state; uint32_t i; int rc = 0; enum mc_disposition disp = mc_continue; @@ -86,7 +87,7 @@ do_multicall( else if ( unlikely(__copy_field_to_guest(call_list, &mcs->call, result)) ) rc = -EFAULT; - else if ( current->hcall_preempted ) + else if ( curr->hcall_preempted ) { /* Translate sub-call continuation to guest layout */ xlat_multicall_entry(mcs); @@ -95,7 +96,7 @@ do_multicall( if ( likely(!__copy_to_guest(call_list, &mcs->call, 1)) ) goto preempted; else - hypercall_cancel_continuation(); + hypercall_cancel_continuation(curr); rc = -EFAULT; } else diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h index 6673b27d88..4b239452c8 100644 --- a/xen/include/xen/sched.h +++ b/xen/include/xen/sched.h @@ -705,7 +705,11 @@ extern void (*dead_idle) (void); */ unsigned long hypercall_create_continuation( unsigned int op, const char *format, ...); -void hypercall_cancel_continuation(void); + +static inline void hypercall_cancel_continuation(struct vcpu *v) +{ + v->hcall_preempted = false; +} /* * For long-running operations that must be in hypercall context, check