diff mbox

[7/9] x86/pv: Merge the pv hypercall tables

Message ID 1468835505-7278-8-git-send-email-andrew.cooper3@citrix.com (mailing list archive)
State New, archived
Headers show

Commit Message

Andrew Cooper July 18, 2016, 9:51 a.m. UTC
For the same reason as c/s 33a231e3f "x86/HVM: fold 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/hypercall.c | 75 +++++++++---------------------------------------
 1 file changed, 13 insertions(+), 62 deletions(-)

Comments

Jan Beulich Aug. 3, 2016, 3:07 p.m. UTC | #1
>>> On 18.07.16 at 11:51, <andrew.cooper3@citrix.com> wrote:
> For the same reason as c/s 33a231e3f "x86/HVM: fold hypercall tables", this
> removes the risk of accidentally updating only one of the tables.
> 
> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>

Reviewed-by: Jan Beulich <jbeulich@suse.com>

But having come here I still can't see why this can't be folded with
patch 5 without also folding in patch 6. Anyway - as long as they're
going to get committed without too big of a time gap in between,
the final result is what matters most.

Jan
Andrew Cooper Aug. 11, 2016, 12:36 p.m. UTC | #2
On 03/08/16 16:07, Jan Beulich wrote:
>>>> On 18.07.16 at 11:51, <andrew.cooper3@citrix.com> wrote:
>> For the same reason as c/s 33a231e3f "x86/HVM: fold hypercall tables", this
>> removes the risk of accidentally updating only one of the tables.
>>
>> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
> Reviewed-by: Jan Beulich <jbeulich@suse.com>
>
> But having come here I still can't see why this can't be folded with
> patch 5 without also folding in patch 6. Anyway - as long as they're
> going to get committed without too big of a time gap in between,
> the final result is what matters most.

References to hypercall_table and compat_hypercall_table are buried in
the multicall inline assembler.

Folding the tables first involves complicated changes, just to be taken
out one patch later.

The risk of accidentally breaking bisectability is greater than the
downside of splitting the patches up a bit.  (Either way, they will be
committed together.)

~Andrew
diff mbox

Patch

diff --git a/xen/arch/x86/hypercall.c b/xen/arch/x86/hypercall.c
index 892012d..b9bd58d 100644
--- a/xen/arch/x86/hypercall.c
+++ b/xen/arch/x86/hypercall.c
@@ -114,64 +114,15 @@  const uint8_t compat_hypercall_args_table[NR_hypercalls] =
 #undef ARGS
 
 #define HYPERCALL(x)                                                \
-    [ __HYPERVISOR_ ## x ] = (hypercall_fn_t *) do_ ## x
+    [ __HYPERVISOR_ ## x ] = { (hypercall_fn_t *) do_ ## x,         \
+                               (hypercall_fn_t *) do_ ## x }
+#define COMPAT_CALL(x)                                              \
+    [ __HYPERVISOR_ ## x ] = { (hypercall_fn_t *) do_ ## x,         \
+                               (hypercall_fn_t *) compat_ ## x }
 
 #define do_arch_1             paging_domctl_continuation
 
-hypercall_fn_t *const hypercall_table[NR_hypercalls] = {
-    HYPERCALL(set_trap_table),
-    HYPERCALL(mmu_update),
-    HYPERCALL(set_gdt),
-    HYPERCALL(stack_switch),
-    HYPERCALL(set_callbacks),
-    HYPERCALL(fpu_taskswitch),
-    HYPERCALL(sched_op_compat),
-    HYPERCALL(platform_op),
-    HYPERCALL(set_debugreg),
-    HYPERCALL(get_debugreg),
-    HYPERCALL(update_descriptor),
-    HYPERCALL(memory_op),
-    HYPERCALL(multicall),
-    HYPERCALL(update_va_mapping),
-    HYPERCALL(set_timer_op),
-    HYPERCALL(event_channel_op_compat),
-    HYPERCALL(xen_version),
-    HYPERCALL(console_io),
-    HYPERCALL(physdev_op_compat),
-    HYPERCALL(grant_table_op),
-    HYPERCALL(vm_assist),
-    HYPERCALL(update_va_mapping_otherdomain),
-    HYPERCALL(iret),
-    HYPERCALL(vcpu_op),
-    HYPERCALL(set_segment_base),
-    HYPERCALL(mmuext_op),
-    HYPERCALL(xsm_op),
-    HYPERCALL(nmi_op),
-    HYPERCALL(sched_op),
-    HYPERCALL(callback_op),
-#ifdef CONFIG_XENOPROF
-    HYPERCALL(xenoprof_op),
-#endif
-    HYPERCALL(event_channel_op),
-    HYPERCALL(physdev_op),
-    HYPERCALL(hvm_op),
-    HYPERCALL(sysctl),
-    HYPERCALL(domctl),
-#ifdef CONFIG_KEXEC
-    HYPERCALL(kexec_op),
-#endif
-#ifdef CONFIG_TMEM
-    HYPERCALL(tmem_op),
-#endif
-    HYPERCALL(xenpmu_op),
-    HYPERCALL(mca),
-    HYPERCALL(arch_1),
-};
-
-#define COMPAT_CALL(x)                                              \
-    [ __HYPERVISOR_ ## x ] = (hypercall_fn_t *) compat_ ## x
-
-hypercall_fn_t *const compat_hypercall_table[NR_hypercalls] = {
+static const hypercall_table_t pv_hypercall_table[NR_hypercalls] = {
     COMPAT_CALL(set_trap_table),
     HYPERCALL(mmu_update),
     COMPAT_CALL(set_gdt),
@@ -236,7 +187,7 @@  long pv_hypercall(struct cpu_user_regs *regs)
 
     ASSERT(curr->arch.flags & TF_kernel_mode);
 
-    if ( (eax >= NR_hypercalls) || !hypercall_table[eax] )
+    if ( (eax >= NR_hypercalls) || !pv_hypercall_table[eax].native )
          return -ENOSYS;
 
     if ( !is_pv_32bit_vcpu(curr) )
@@ -267,7 +218,7 @@  long pv_hypercall(struct cpu_user_regs *regs)
             __trace_hypercall(TRC_PV_HYPERCALL_V2, eax, args);
         }
 
-        ret = hypercall_table[eax](rdi, rsi, rdx, r10, r8, r9);
+        ret = pv_hypercall_table[eax].native(rdi, rsi, rdx, r10, r8, r9);
 
 #ifndef NDEBUG
         if ( regs->rip == old_rip )
@@ -314,7 +265,7 @@  long pv_hypercall(struct cpu_user_regs *regs)
             __trace_hypercall(TRC_PV_HYPERCALL_V2, eax, args);
         }
 
-        ret = compat_hypercall_table[eax](ebx, ecx, edx, esi, edi, ebp);
+        ret = pv_hypercall_table[eax].compat(ebx, ecx, edx, esi, edi, ebp);
 
 #ifndef NDEBUG
         if ( regs->rip == old_rip )
@@ -344,8 +295,8 @@  void arch_do_multicall_call(struct mc_state *state)
     {
         struct multicall_entry *call = &state->call;
 
-        if ( (call->op < NR_hypercalls) && hypercall_table[call->op] )
-            call->result = hypercall_table[call->op](
+        if ( (call->op < NR_hypercalls) && pv_hypercall_table[call->op].native )
+            call->result = pv_hypercall_table[call->op].native(
                 call->args[0], call->args[1], call->args[2],
                 call->args[3], call->args[4], call->args[5]);
         else
@@ -356,8 +307,8 @@  void arch_do_multicall_call(struct mc_state *state)
     {
         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](
+        if ( (call->op < NR_hypercalls) && pv_hypercall_table[call->op].compat )
+            call->result = pv_hypercall_table[call->op].compat(
                 call->args[0], call->args[1], call->args[2],
                 call->args[3], call->args[4], call->args[5]);
         else