xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Xen-devel <xen-devel@lists.xen.org>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>,
	Julien Grall <julien.grall@arm.com>,
	Stefano Stabellini <sstabellini@kernel.org>,
	Jan Beulich <JBeulich@suse.com>
Subject: [PATCH 6/9] xen/multicall: Rework arch multicall handling
Date: Mon, 18 Jul 2016 10:51:42 +0100	[thread overview]
Message-ID: <1468835505-7278-7-git-send-email-andrew.cooper3@citrix.com> (raw)
In-Reply-To: <1468835505-7278-1-git-send-email-andrew.cooper3@citrix.com>

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 <andrew.cooper3@citrix.com>
---
CC: Jan Beulich <JBeulich@suse.com>
CC: Stefano Stabellini <sstabellini@kernel.org>
CC: Julien Grall <julien.grall@arm.com>
---
 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 a2eb1da..d75a0a2 100644
--- a/xen/arch/arm/traps.c
+++ b/xen/arch/arm/traps.c
@@ -1515,8 +1515,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 86c097a..892012d 100644
--- a/xen/arch/x86/hypercall.c
+++ b/xen/arch/x86/hypercall.c
@@ -338,6 +338,34 @@ long pv_hypercall(struct cpu_user_regs *regs)
     return ret;
 }
 
+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 <xen/errno.h>
-
-#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 <xen/percpu.h>
-#include <asm/multicall.h>
 #ifdef CONFIG_COMPAT
 #include <compat/xen.h>
 #endif
@@ -25,4 +24,6 @@ struct mc_state {
     };
 };
 
+void arch_do_multicall_call(struct mc_state *mc);
+
 #endif /* __XEN_MULTICALL_H__ */
-- 
2.1.4


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

  parent reply	other threads:[~2016-07-18  9:51 UTC|newest]

Thread overview: 48+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-18  9:51 [PATCH 0/9] x86: Move the pv hypercall into C Andrew Cooper
2016-07-18  9:51 ` [PATCH 1/9] x86/hypercall: Move some of the hvm hypercall infrastructure into hypercall.h Andrew Cooper
2016-08-02 12:50   ` Jan Beulich
2016-08-02 13:14     ` Andrew Cooper
2016-08-02 13:28       ` Jan Beulich
2016-08-02 14:04         ` Julien Grall
2016-08-02 14:17           ` Jan Beulich
2016-08-02 14:26             ` Julien Grall
2016-08-02 14:54               ` Jan Beulich
2016-08-02 14:59                 ` Andrew Cooper
2016-08-02 15:05                   ` Jan Beulich
2016-08-02 18:43                     ` Stefano Stabellini
2016-08-03  8:53                       ` Jan Beulich
2016-08-03 10:55                         ` Julien Grall
2016-08-03 18:20                           ` Stefano Stabellini
2016-08-04 11:27                             ` Julien Grall
2016-07-18  9:51 ` [PATCH 2/9] x86/pv: Support do_set_segment_base() for compat guests Andrew Cooper
2016-08-02 12:52   ` Jan Beulich
2016-08-02 13:25     ` Andrew Cooper
2016-08-02 13:31       ` Jan Beulich
2016-08-02 13:39         ` Andrew Cooper
2016-08-02 13:47           ` Jan Beulich
2016-07-18  9:51 ` [PATCH 3/9] x86/hypercall: Move the hypercall arg tables into C Andrew Cooper
2016-08-02 12:59   ` Jan Beulich
2016-07-18  9:51 ` [PATCH 4/9] x86/pv: Implement pv_hypercall() in C Andrew Cooper
2016-08-02 13:12   ` Jan Beulich
2016-08-02 14:06     ` Andrew Cooper
2016-08-02 14:19       ` Jan Beulich
2016-08-11 11:57     ` Andrew Cooper
2016-08-11 12:20       ` Jan Beulich
2016-07-18  9:51 ` [PATCH 5/9] x86/hypercall: Move the hypercall tables into C Andrew Cooper
2016-08-02 13:23   ` Jan Beulich
2016-08-02 13:30     ` Andrew Cooper
2016-08-02 13:40       ` Jan Beulich
2016-08-11 12:00         ` Andrew Cooper
2016-07-18  9:51 ` Andrew Cooper [this message]
2016-07-20 12:35   ` [PATCH 6/9] xen/multicall: Rework arch multicall handling Julien Grall
2016-08-03 15:02   ` Jan Beulich
2016-08-03 15:12     ` Andrew Cooper
2016-07-18  9:51 ` [PATCH 7/9] x86/pv: Merge the pv hypercall tables Andrew Cooper
2016-08-03 15:07   ` Jan Beulich
2016-08-11 12:36     ` Andrew Cooper
2016-07-18  9:51 ` [PATCH 8/9] x86/hypercall: Merge the hypercall arg tables Andrew Cooper
2016-08-03 15:12   ` Jan Beulich
2016-08-03 15:15     ` Andrew Cooper
2016-08-03 15:28       ` Jan Beulich
2016-07-18  9:51 ` [PATCH 9/9] x86/hypercall: Reduce the size of the hypercall tables Andrew Cooper
2016-08-03 15:17   ` Jan Beulich

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1468835505-7278-7-git-send-email-andrew.cooper3@citrix.com \
    --to=andrew.cooper3@citrix.com \
    --cc=JBeulich@suse.com \
    --cc=julien.grall@arm.com \
    --cc=sstabellini@kernel.org \
    --cc=xen-devel@lists.xen.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).