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>,
	Jan Beulich <JBeulich@suse.com>
Subject: [PATCH 8/9] x86/hypercall: Merge the hypercall arg tables
Date: Mon, 18 Jul 2016 10:51:44 +0100	[thread overview]
Message-ID: <1468835505-7278-9-git-send-email-andrew.cooper3@citrix.com> (raw)
In-Reply-To: <1468835505-7278-1-git-send-email-andrew.cooper3@citrix.com>

For the same reason as c/s 33a231e3f "x86/HVM: fold hypercall tables" and
(TODO - changeset) "x86/pv: Merge the pv hypercall tables", this removes the
risk of accidentally updating only one of the tables.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
CC: Jan Beulich <JBeulich@suse.com>
---
 xen/arch/x86/hvm/hvm.c          |  8 ++---
 xen/arch/x86/hypercall.c        | 70 +++++++++--------------------------------
 xen/include/asm-x86/hypercall.h |  7 +++--
 3 files changed, 24 insertions(+), 61 deletions(-)

diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c
index 0966bd3..198fe34 100644
--- a/xen/arch/x86/hvm/hvm.c
+++ b/xen/arch/x86/hvm/hvm.c
@@ -4175,7 +4175,7 @@ int hvm_do_hypercall(struct cpu_user_regs *regs)
 
 #ifndef NDEBUG
         /* Deliberately corrupt parameter regs not used by this hypercall. */
-        switch ( hypercall_args_table[eax] )
+        switch ( hypercall_args_table[eax].native )
         {
         case 0: rdi = 0xdeadbeefdeadf00dUL;
         case 1: rsi = 0xdeadbeefdeadf00dUL;
@@ -4196,7 +4196,7 @@ int hvm_do_hypercall(struct cpu_user_regs *regs)
         if ( !curr->arch.hvm_vcpu.hcall_preempted )
         {
             /* Deliberately corrupt parameter regs used by this hypercall. */
-            switch ( hypercall_args_table[eax] )
+            switch ( hypercall_args_table[eax].native )
             {
             case 6: regs->r9  = 0xdeadbeefdeadf00dUL;
             case 5: regs->r8  = 0xdeadbeefdeadf00dUL;
@@ -4222,7 +4222,7 @@ int hvm_do_hypercall(struct cpu_user_regs *regs)
 
 #ifndef NDEBUG
         /* Deliberately corrupt parameter regs not used by this hypercall. */
-        switch ( compat_hypercall_args_table[eax] )
+        switch ( hypercall_args_table[eax].compat )
         {
         case 0: ebx = 0xdeadf00d;
         case 1: ecx = 0xdeadf00d;
@@ -4240,7 +4240,7 @@ int hvm_do_hypercall(struct cpu_user_regs *regs)
         if ( !curr->arch.hvm_vcpu.hcall_preempted )
         {
             /* Deliberately corrupt parameter regs used by this hypercall. */
-            switch ( compat_hypercall_args_table[eax] )
+            switch ( hypercall_args_table[eax].compat )
             {
             case 6: regs->ebp = 0xdeadf00d;
             case 5: regs->edi = 0xdeadf00d;
diff --git a/xen/arch/x86/hypercall.c b/xen/arch/x86/hypercall.c
index b9bd58d..373bedf 100644
--- a/xen/arch/x86/hypercall.c
+++ b/xen/arch/x86/hypercall.c
@@ -22,77 +22,36 @@
 #include <xen/trace.h>
 
 #define ARGS(x, n)                              \
-    [ __HYPERVISOR_ ## x ] = (n)
+    [ __HYPERVISOR_ ## x ] = { n, n }
+#define COMP(x, n, c)                           \
+    [ __HYPERVISOR_ ## x ] = { n, c }
 
-const uint8_t hypercall_args_table[NR_hypercalls] =
+const hypercall_args_t hypercall_args_table[NR_hypercalls] =
 {
     ARGS(set_trap_table, 1),
     ARGS(mmu_update, 4),
     ARGS(set_gdt, 2),
     ARGS(stack_switch, 2),
-    ARGS(set_callbacks, 3),
+    COMP(set_callbacks, 3, 4),
     ARGS(fpu_taskswitch, 1),
     ARGS(sched_op_compat, 2),
     ARGS(platform_op, 1),
     ARGS(set_debugreg, 2),
     ARGS(get_debugreg, 1),
-    ARGS(update_descriptor, 2),
+    COMP(update_descriptor, 2, 4),
     ARGS(memory_op, 2),
     ARGS(multicall, 2),
-    ARGS(update_va_mapping, 3),
-    ARGS(set_timer_op, 1),
+    COMP(update_va_mapping, 3, 4),
+    COMP(set_timer_op, 1, 2),
     ARGS(event_channel_op_compat, 1),
     ARGS(xen_version, 2),
     ARGS(console_io, 3),
     ARGS(physdev_op_compat, 1),
     ARGS(grant_table_op, 3),
     ARGS(vm_assist, 2),
-    ARGS(update_va_mapping_otherdomain, 4),
-    ARGS(vcpu_op, 3),
-    ARGS(set_segment_base, 2),
-    ARGS(mmuext_op, 4),
-    ARGS(xsm_op, 1),
-    ARGS(nmi_op, 2),
-    ARGS(sched_op, 2),
-    ARGS(callback_op, 2),
-    ARGS(xenoprof_op, 2),
-    ARGS(event_channel_op, 2),
-    ARGS(physdev_op, 2),
-    ARGS(hvm_op, 2),
-    ARGS(sysctl, 1),
-    ARGS(domctl, 1),
-    ARGS(kexec_op, 2),
-    ARGS(tmem_op, 1),
-    ARGS(xenpmu_op, 2),
-    ARGS(mca, 1),
-    ARGS(arch_1, 1),
-};
-
-const uint8_t compat_hypercall_args_table[NR_hypercalls] =
-{
-    ARGS(set_trap_table, 1),
-    ARGS(mmu_update, 4),
-    ARGS(set_gdt, 2),
-    ARGS(stack_switch, 2),
-    ARGS(set_callbacks, 4),
-    ARGS(fpu_taskswitch, 1),
-    ARGS(sched_op_compat, 2),
-    ARGS(platform_op, 1),
-    ARGS(set_debugreg, 2),
-    ARGS(get_debugreg, 1),
-    ARGS(update_descriptor, 4),
-    ARGS(memory_op, 2),
-    ARGS(multicall, 2),
-    ARGS(update_va_mapping, 4),
-    ARGS(set_timer_op, 2),
-    ARGS(event_channel_op_compat, 1),
-    ARGS(xen_version, 2),
-    ARGS(console_io, 3),
-    ARGS(physdev_op_compat, 1),
-    ARGS(grant_table_op, 3),
-    ARGS(vm_assist, 2),
-    ARGS(update_va_mapping_otherdomain, 5),
+    COMP(update_va_mapping_otherdomain, 4, 5),
     ARGS(vcpu_op, 3),
+    COMP(set_segment_base, 2, 0),
     ARGS(mmuext_op, 4),
     ARGS(xsm_op, 1),
     ARGS(nmi_op, 2),
@@ -111,6 +70,7 @@ const uint8_t compat_hypercall_args_table[NR_hypercalls] =
     ARGS(arch_1, 1),
 };
 
+#undef COMP
 #undef ARGS
 
 #define HYPERCALL(x)                                                \
@@ -201,7 +161,7 @@ long pv_hypercall(struct cpu_user_regs *regs)
 
 #ifndef NDEBUG
         /* Deliberately corrupt parameter regs not used by this hypercall. */
-        switch ( hypercall_args_table[eax] )
+        switch ( hypercall_args_table[eax].native )
         {
         case 0: rdi = 0xdeadbeefdeadf00dUL;
         case 1: rsi = 0xdeadbeefdeadf00dUL;
@@ -224,7 +184,7 @@ long pv_hypercall(struct cpu_user_regs *regs)
         if ( regs->rip == old_rip )
         {
             /* Deliberately corrupt parameter regs used by this hypercall. */
-            switch ( hypercall_args_table[eax] )
+            switch ( hypercall_args_table[eax].native )
             {
             case 6: regs->r9  = 0xdeadbeefdeadf00dUL;
             case 5: regs->r8  = 0xdeadbeefdeadf00dUL;
@@ -247,7 +207,7 @@ long pv_hypercall(struct cpu_user_regs *regs)
 
 #ifndef NDEBUG
         /* Deliberately corrupt parameter regs not used by this hypercall. */
-        switch ( compat_hypercall_args_table[eax] )
+        switch ( hypercall_args_table[eax].compat )
         {
         case 0: ebx = 0xdeadf00d;
         case 1: ecx = 0xdeadf00d;
@@ -271,7 +231,7 @@ long pv_hypercall(struct cpu_user_regs *regs)
         if ( regs->rip == old_rip )
         {
             /* Deliberately corrupt parameter regs used by this hypercall. */
-            switch ( compat_hypercall_args_table[eax] )
+            switch ( hypercall_args_table[eax].compat )
             {
             case 6: regs->ebp = 0xdeadf00d;
             case 5: regs->edi = 0xdeadf00d;
diff --git a/xen/include/asm-x86/hypercall.h b/xen/include/asm-x86/hypercall.h
index c00de2b..c59aa69 100644
--- a/xen/include/asm-x86/hypercall.h
+++ b/xen/include/asm-x86/hypercall.h
@@ -19,8 +19,11 @@ typedef struct {
     hypercall_fn_t *native, *compat;
 } hypercall_table_t;
 
-extern const uint8_t hypercall_args_table[NR_hypercalls],
-  compat_hypercall_args_table[NR_hypercalls];
+typedef struct {
+    uint8_t native, compat;
+} hypercall_args_t;
+
+extern const hypercall_args_t hypercall_args_table[NR_hypercalls];
 
 /*
  * Both do_mmuext_op() and do_mmu_update():
-- 
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 ` [PATCH 6/9] xen/multicall: Rework arch multicall handling Andrew Cooper
2016-07-20 12:35   ` 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 ` Andrew Cooper [this message]
2016-08-03 15:12   ` [PATCH 8/9] x86/hypercall: Merge the hypercall arg tables 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-9-git-send-email-andrew.cooper3@citrix.com \
    --to=andrew.cooper3@citrix.com \
    --cc=JBeulich@suse.com \
    --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).