All of lore.kernel.org
 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 3/9] x86/hypercall: Move the hypercall arg tables into C
Date: Mon, 18 Jul 2016 10:51:39 +0100	[thread overview]
Message-ID: <1468835505-7278-4-git-send-email-andrew.cooper3@citrix.com> (raw)
In-Reply-To: <1468835505-7278-1-git-send-email-andrew.cooper3@citrix.com>

Editing (and indeed, finding) the hypercall args tables can be tricky,
especially towards the end where .rept's are used to maintain the correct
layout.

Move this all into C, and let the compiler do the hard work.  As 0 is the
default value, drop all explicit 0's.

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
CC: Jan Beulich <JBeulich@suse.com>
---
 xen/arch/x86/Makefile              |   1 +
 xen/arch/x86/hypercall.c           | 123 +++++++++++++++++++++++++++++++++++++
 xen/arch/x86/x86_64/compat/entry.S |  51 ---------------
 xen/arch/x86/x86_64/entry.S        |  51 ---------------
 4 files changed, 124 insertions(+), 102 deletions(-)
 create mode 100644 xen/arch/x86/hypercall.c

diff --git a/xen/arch/x86/Makefile b/xen/arch/x86/Makefile
index b18f033..6dab907 100644
--- a/xen/arch/x86/Makefile
+++ b/xen/arch/x86/Makefile
@@ -28,6 +28,7 @@ obj-y += e820.o
 obj-y += extable.o
 obj-y += flushtlb.o
 obj-$(CONFIG_CRASH_DEBUG) += gdbstub.o
+obj-y += hypercall.o
 obj-y += i387.o
 obj-y += i8259.o
 obj-y += io_apic.o
diff --git a/xen/arch/x86/hypercall.c b/xen/arch/x86/hypercall.c
new file mode 100644
index 0000000..4b42f86
--- /dev/null
+++ b/xen/arch/x86/hypercall.c
@@ -0,0 +1,123 @@
+/******************************************************************************
+ * arch/x86/hypercall.c
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Copyright (c) 2015,2016 Citrix Systems Ltd.
+ */
+
+#include <xen/hypercall.h>
+
+#define ARGS(x, n)                              \
+    [ __HYPERVISOR_ ## x ] = (n)
+
+const uint8_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),
+    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),
+    ARGS(memory_op, 2),
+    ARGS(multicall, 2),
+    ARGS(update_va_mapping, 3),
+    ARGS(set_timer_op, 1),
+    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),
+    ARGS(vcpu_op, 3),
+    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),
+};
+
+#undef ARGS
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * tab-width: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
+
diff --git a/xen/arch/x86/x86_64/compat/entry.S b/xen/arch/x86/x86_64/compat/entry.S
index 89673c4..1a8e085 100644
--- a/xen/arch/x86/x86_64/compat/entry.S
+++ b/xen/arch/x86/x86_64/compat/entry.S
@@ -477,54 +477,3 @@ ENTRY(compat_hypercall_table)
         .rept NR_hypercalls-((.-compat_hypercall_table)/8)
         .quad compat_ni_hypercall
         .endr
-
-ENTRY(compat_hypercall_args_table)
-        .byte 1 /* compat_set_trap_table    */  /*  0 */
-        .byte 4 /* compat_mmu_update        */
-        .byte 2 /* compat_set_gdt           */
-        .byte 2 /* compat_stack_switch      */
-        .byte 4 /* compat_set_callbacks     */
-        .byte 1 /* compat_fpu_taskswitch    */  /*  5 */
-        .byte 2 /* compat_sched_op_compat   */
-        .byte 1 /* compat_platform_op       */
-        .byte 2 /* compat_set_debugreg      */
-        .byte 1 /* compat_get_debugreg      */
-        .byte 4 /* compat_update_descriptor */  /* 10 */
-        .byte 0 /* compat_ni_hypercall      */
-        .byte 2 /* compat_memory_op         */
-        .byte 2 /* compat_multicall         */
-        .byte 4 /* compat_update_va_mapping */
-        .byte 2 /* compat_set_timer_op      */  /* 15 */
-        .byte 1 /* compat_event_channel_op_compat */
-        .byte 2 /* compat_xen_version       */
-        .byte 3 /* compat_console_io        */
-        .byte 1 /* compat_physdev_op_compat */
-        .byte 3 /* compat_grant_table_op    */  /* 20 */
-        .byte 2 /* compat_vm_assist         */
-        .byte 5 /* compat_update_va_mapping_otherdomain */
-        .byte 0 /* compat_iret              */
-        .byte 3 /* compat_vcpu_op           */
-        .byte 0 /* compat_ni_hypercall      */  /* 25 */
-        .byte 4 /* compat_mmuext_op         */
-        .byte 1 /* do_xsm_op                */
-        .byte 2 /* compat_nmi_op            */
-        .byte 2 /* compat_sched_op          */
-        .byte 2 /* compat_callback_op       */  /* 30 */
-        .byte 2 /* compat_xenoprof_op       */
-        .byte 2 /* compat_event_channel_op  */
-        .byte 2 /* compat_physdev_op        */
-        .byte 2 /* do_hvm_op                */
-        .byte 1 /* do_sysctl                */  /* 35 */
-        .byte 1 /* do_domctl                */
-        .byte 2 /* compat_kexec_op          */
-        .byte 1 /* do_tmem_op               */
-        .byte 0 /* reserved for XenClient   */
-        .byte 2 /* do_xenpmu_op             */  /* 40 */
-        .rept __HYPERVISOR_arch_0-(.-compat_hypercall_args_table)
-        .byte 0 /* compat_ni_hypercall      */
-        .endr
-        .byte 1 /* do_mca                   */
-        .byte 1 /* paging_domctl_continuation      */
-        .rept NR_hypercalls-(.-compat_hypercall_args_table)
-        .byte 0 /* compat_ni_hypercall      */
-        .endr
diff --git a/xen/arch/x86/x86_64/entry.S b/xen/arch/x86/x86_64/entry.S
index ad8c64c..5c6606b 100644
--- a/xen/arch/x86/x86_64/entry.S
+++ b/xen/arch/x86/x86_64/entry.S
@@ -801,57 +801,6 @@ ENTRY(hypercall_table)
         .quad do_ni_hypercall
         .endr
 
-ENTRY(hypercall_args_table)
-        .byte 1 /* do_set_trap_table    */  /*  0 */
-        .byte 4 /* do_mmu_update        */
-        .byte 2 /* do_set_gdt           */
-        .byte 2 /* do_stack_switch      */
-        .byte 3 /* do_set_callbacks     */
-        .byte 1 /* do_fpu_taskswitch    */  /*  5 */
-        .byte 2 /* do_sched_op_compat   */
-        .byte 1 /* do_platform_op       */
-        .byte 2 /* do_set_debugreg      */
-        .byte 1 /* do_get_debugreg      */
-        .byte 2 /* do_update_descriptor */  /* 10 */
-        .byte 0 /* do_ni_hypercall      */
-        .byte 2 /* do_memory_op         */
-        .byte 2 /* do_multicall         */
-        .byte 3 /* do_update_va_mapping */
-        .byte 1 /* do_set_timer_op      */  /* 15 */
-        .byte 1 /* do_event_channel_op_compat */
-        .byte 2 /* do_xen_version       */
-        .byte 3 /* do_console_io        */
-        .byte 1 /* do_physdev_op_compat */
-        .byte 3 /* do_grant_table_op    */  /* 20 */
-        .byte 2 /* do_vm_assist         */
-        .byte 4 /* do_update_va_mapping_otherdomain */
-        .byte 0 /* do_iret              */
-        .byte 3 /* do_vcpu_op           */
-        .byte 2 /* do_set_segment_base  */  /* 25 */
-        .byte 4 /* do_mmuext_op         */
-        .byte 1 /* do_xsm_op            */
-        .byte 2 /* do_nmi_op            */
-        .byte 2 /* do_sched_op          */
-        .byte 2 /* do_callback_op       */  /* 30 */
-        .byte 2 /* do_xenoprof_op       */
-        .byte 2 /* do_event_channel_op  */
-        .byte 2 /* do_physdev_op        */
-        .byte 2 /* do_hvm_op            */
-        .byte 1 /* do_sysctl            */  /* 35 */
-        .byte 1 /* do_domctl            */
-        .byte 2 /* do_kexec             */
-        .byte 1 /* do_tmem_op           */
-        .byte 0 /* reserved for XenClient */
-        .byte 2 /* do_xenpmu_op         */  /* 40 */
-        .rept __HYPERVISOR_arch_0-(.-hypercall_args_table)
-        .byte 0 /* do_ni_hypercall      */
-        .endr
-        .byte 1 /* do_mca               */  /* 48 */
-        .byte 1 /* paging_domctl_continuation */
-        .rept NR_hypercalls-(.-hypercall_args_table)
-        .byte 0 /* do_ni_hypercall      */
-        .endr
-
 /* Table of automatically generated entry points.  One per vector. */
         .section .init.rodata, "a", @progbits
 GLOBAL(autogen_entrypoints)
-- 
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 ` Andrew Cooper [this message]
2016-08-02 12:59   ` [PATCH 3/9] x86/hypercall: Move the hypercall arg tables into C 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 ` [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-4-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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.