]> xenbits.xensource.com Git - people/hx242/xen.git/commitdiff
x86: slim down hypercall handling when !PV32
authorJan Beulich <jbeulich@suse.com>
Thu, 15 Apr 2021 11:35:32 +0000 (13:35 +0200)
committerJan Beulich <jbeulich@suse.com>
Thu, 15 Apr 2021 11:35:32 +0000 (13:35 +0200)
In such a build various of the compat handlers aren't needed. Don't
reference them from the hypercall table, and compile out those which
aren't needed for HVM. Also compile out switch_compat(), which has no
purpose in such a build.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Wei Liu <wl@xen.org>
12 files changed:
xen/arch/x86/Makefile
xen/arch/x86/hvm/hypercall.c
xen/arch/x86/mm.c
xen/arch/x86/pv/callback.c
xen/arch/x86/pv/descriptor-tables.c
xen/arch/x86/pv/domain.c
xen/arch/x86/pv/hypercall.c
xen/arch/x86/pv/iret.c
xen/arch/x86/pv/shim.c
xen/include/asm-x86/compat.h
xen/include/asm-x86/hypercall.h
xen/include/xen/compat.h

index b6567c4127df7eb7e1b4271fc3184395878cee82..399ee508c2adc5891a903dc70b2a184e9dda5432 100644 (file)
@@ -17,7 +17,8 @@ obj-bin-y += bzimage.init.o
 obj-bin-y += clear_page.o
 obj-bin-y += copy_page.o
 obj-y += cpuid.o
-obj-$(CONFIG_PV) += compat.o x86_64/compat.o
+obj-$(CONFIG_PV) += compat.o
+obj-$(CONFIG_PV32) += x86_64/compat.o
 obj-$(CONFIG_KEXEC) += crash.o
 obj-$(CONFIG_GDBSX) += debug.o
 obj-y += delay.o
index b084afcbcef578cee8a7b944d002effe8f09c672..2d27fcbd2c5d30640e03df9397ec95d1e7814c0a 100644 (file)
@@ -121,7 +121,9 @@ static long hvm_physdev_op(int cmd, XEN_GUEST_HANDLE_PARAM(void) arg)
 
 #define do_arch_1             paging_domctl_continuation
 
-static const hypercall_table_t hvm_hypercall_table[] = {
+static const struct {
+    hypercall_fn_t *native, *compat;
+} hvm_hypercall_table[] = {
     HVM_CALL(memory_op),
 #ifdef CONFIG_GRANT_TABLE
     HVM_CALL(grant_table_op),
index 69d04ad809c0f340ba1d9cefd2d434303a84d2ea..b7a10bbdd401cbc2ebb1f9f1d2440613b6003bab 100644 (file)
@@ -4512,7 +4512,9 @@ long do_update_va_mapping_otherdomain(unsigned long va, u64 val64,
 
     return rc;
 }
+#endif /* CONFIG_PV */
 
+#ifdef CONFIG_PV32
 int compat_update_va_mapping(unsigned int va, uint32_t lo, uint32_t hi,
                              unsigned int flags)
 {
@@ -4547,7 +4549,7 @@ int compat_update_va_mapping_otherdomain(unsigned int va,
 
     return rc;
 }
-#endif /* CONFIG_PV */
+#endif /* CONFIG_PV32 */
 
 typedef struct e820entry e820entry_t;
 DEFINE_XEN_GUEST_HANDLE(e820entry_t);
index 97242cd3d48c5154fd8c00468e3cf03d74f7f462..42a6aa0831b70fa529f78cdf8daf83d8b058fd84 100644 (file)
 #include <xen/event.h>
 #include <xen/hypercall.h>
 #include <xen/guest_access.h>
-#include <compat/callback.h>
-#include <compat/nmi.h>
 
 #include <asm/shared.h>
 
 #include <public/callback.h>
+#include <public/nmi.h>
 
 static int register_guest_nmi_callback(unsigned long address)
 {
@@ -203,6 +202,11 @@ long do_set_callbacks(unsigned long event_address,
     return 0;
 }
 
+#ifdef CONFIG_PV32
+
+#include <compat/callback.h>
+#include <compat/nmi.h>
+
 static long compat_register_guest_callback(struct compat_callback_register *reg)
 {
     long ret = 0;
@@ -343,6 +347,8 @@ long compat_set_callbacks(unsigned long event_selector,
     return 0;
 }
 
+#endif /* CONFIG_PV32 */
+
 long do_set_trap_table(XEN_GUEST_HANDLE_PARAM(const_trap_info_t) traps)
 {
     struct trap_info cur;
@@ -388,6 +394,7 @@ long do_set_trap_table(XEN_GUEST_HANDLE_PARAM(const_trap_info_t) traps)
     return rc;
 }
 
+#ifdef CONFIG_PV32
 int compat_set_trap_table(XEN_GUEST_HANDLE(trap_info_compat_t) traps)
 {
     struct vcpu *curr = current;
@@ -429,6 +436,7 @@ int compat_set_trap_table(XEN_GUEST_HANDLE(trap_info_compat_t) traps)
 
     return rc;
 }
+#endif
 
 long do_nmi_op(unsigned int cmd, XEN_GUEST_HANDLE_PARAM(void) arg)
 {
@@ -455,6 +463,7 @@ long do_nmi_op(unsigned int cmd, XEN_GUEST_HANDLE_PARAM(void) arg)
     return rc;
 }
 
+#ifdef CONFIG_PV32
 int compat_nmi_op(unsigned int cmd, XEN_GUEST_HANDLE_PARAM(void) arg)
 {
     struct compat_nmi_callback cb;
@@ -479,6 +488,7 @@ int compat_nmi_op(unsigned int cmd, XEN_GUEST_HANDLE_PARAM(void) arg)
 
     return rc;
 }
+#endif
 
 /*
  * Local variables:
index 39c1a2311a471fcd11d39c4afe2a38430de4af33..5e847044009b698810c574784a7ef3dc0b18f9a4 100644 (file)
@@ -149,6 +149,8 @@ long do_set_gdt(XEN_GUEST_HANDLE_PARAM(xen_ulong_t) frame_list,
     return ret;
 }
 
+#ifdef CONFIG_PV32
+
 int compat_set_gdt(XEN_GUEST_HANDLE_PARAM(uint) frame_list,
                    unsigned int entries)
 {
@@ -185,6 +187,18 @@ int compat_set_gdt(XEN_GUEST_HANDLE_PARAM(uint) frame_list,
     return ret;
 }
 
+int compat_update_descriptor(uint32_t pa_lo, uint32_t pa_hi,
+                             uint32_t desc_lo, uint32_t desc_hi)
+{
+    seg_desc_t d;
+
+    d.raw = ((uint64_t)desc_hi << 32) | desc_lo;
+
+    return do_update_descriptor(pa_lo | ((uint64_t)pa_hi << 32), d);
+}
+
+#endif /* CONFIG_PV32 */
+
 static bool check_descriptor(const struct domain *dom, seg_desc_t *d)
 {
     unsigned int a = d->a, b = d->b, cs, dpl;
@@ -334,16 +348,6 @@ long do_update_descriptor(uint64_t gaddr, seg_desc_t d)
     return ret;
 }
 
-int compat_update_descriptor(uint32_t pa_lo, uint32_t pa_hi,
-                             uint32_t desc_lo, uint32_t desc_hi)
-{
-    seg_desc_t d;
-
-    d.raw = ((uint64_t)desc_hi << 32) | desc_lo;
-
-    return do_update_descriptor(pa_lo | ((uint64_t)pa_hi << 32), d);
-}
-
 /*
  * Local variables:
  * mode: C
index 23d60091435d400b009e9f97918f80b9c1b33301..f1cb92585e78da68bd6200242d3a6d4f65b1cb72 100644 (file)
@@ -212,6 +212,7 @@ unsigned long pv_make_cr4(const struct vcpu *v)
     return cr4;
 }
 
+#ifdef CONFIG_PV32
 int switch_compat(struct domain *d)
 {
     struct vcpu *v;
@@ -256,6 +257,7 @@ int switch_compat(struct domain *d)
 
     return rc;
 }
+#endif
 
 static int pv_create_gdt_ldt_l1tab(struct vcpu *v)
 {
index 20795b4b57d691be18da8805413db58fdf726f2d..5d02eebc8d8b4e7961ac255f0f33a0e5d4fb03c8 100644 (file)
 #include <xen/trace.h>
 #include <irq_vectors.h>
 
+#ifdef CONFIG_PV32
 #define HYPERCALL(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 }
+#else
+#define HYPERCALL(x)                                                \
+    [ __HYPERVISOR_ ## x ] = { (hypercall_fn_t *) do_ ## x }
+#define COMPAT_CALL(x) HYPERCALL(x)
+#endif
 
 #define do_arch_1             paging_domctl_continuation
 
@@ -176,6 +182,7 @@ void pv_hypercall(struct cpu_user_regs *regs)
         }
 #endif
     }
+#ifdef CONFIG_PV32
     else
     {
         unsigned int ebx = regs->ebx;
@@ -225,6 +232,7 @@ void pv_hypercall(struct cpu_user_regs *regs)
         }
 #endif
     }
+#endif /* CONFIG_PV32 */
 
     /*
      * PV guests use SYSCALL or INT $0x82 to make a hypercall, both of which
@@ -255,7 +263,7 @@ enum mc_disposition arch_do_multicall_call(struct mc_state *state)
         else
             call->result = -ENOSYS;
     }
-#ifdef CONFIG_COMPAT
+#ifdef CONFIG_PV32
     else
     {
         struct compat_multicall_entry *call = &state->compat_call;
index b508dc17b7984545e6f35cd318b277aa6dfd80ce..29a2f7cc452b75bb4b58625108279b66e3dd70e3 100644 (file)
@@ -104,6 +104,7 @@ unsigned long do_iret(void)
     return 0;
 }
 
+#ifdef CONFIG_PV32
 unsigned int compat_iret(void)
 {
     struct cpu_user_regs *regs = guest_cpu_user_regs();
@@ -223,6 +224,7 @@ unsigned int compat_iret(void)
      */
     return regs->eax;
 }
+#endif
 
 /*
  * Local variables:
index b4e83e077891b72aa1d934a4c0b9a6d86feda44f..92cb1adeed4da122f5cd466d3459dc0dd941233d 100644 (file)
@@ -255,13 +255,17 @@ void __init pv_shim_setup_dom(struct domain *d, l4_pgentry_t *l4start,
      */
     rw_pv_hypercall_table = __va(__pa(pv_hypercall_table));
     rw_pv_hypercall_table[__HYPERVISOR_event_channel_op].native =
-        rw_pv_hypercall_table[__HYPERVISOR_event_channel_op].compat =
         (hypercall_fn_t *)pv_shim_event_channel_op;
-
     rw_pv_hypercall_table[__HYPERVISOR_grant_table_op].native =
-        rw_pv_hypercall_table[__HYPERVISOR_grant_table_op].compat =
         (hypercall_fn_t *)pv_shim_grant_table_op;
 
+#ifdef CONFIG_PV32
+    rw_pv_hypercall_table[__HYPERVISOR_event_channel_op].compat =
+        (hypercall_fn_t *)pv_shim_event_channel_op;
+    rw_pv_hypercall_table[__HYPERVISOR_grant_table_op].compat =
+        (hypercall_fn_t *)pv_shim_grant_table_op;
+#endif
+
     guest = d;
 
     /*
index f9df74ece884df6e65fdbf48eba2cff95c949caf..0c8719f9b01a68336dc0242080ecdb416760972f 100644 (file)
@@ -6,3 +6,11 @@
 
 typedef uint32_t compat_ptr_t;
 typedef unsigned long full_ptr_t;
+
+struct domain;
+#ifdef CONFIG_PV32
+int switch_compat(struct domain *);
+#else
+#include <xen/errno.h>
+static inline int switch_compat(struct domain *d) { return -EOPNOTSUPP; }
+#endif
index 1cd804646479aa7345011cd234ab23fb0bfd0e84..686f3a3803d4e9a5bc1ad5ba9141fc2484e0be9b 100644 (file)
@@ -16,7 +16,10 @@ typedef unsigned long hypercall_fn_t(
     unsigned long, unsigned long, unsigned long);
 
 typedef struct {
-    hypercall_fn_t *native, *compat;
+    hypercall_fn_t *native;
+#ifdef CONFIG_PV32
+    hypercall_fn_t *compat;
+#endif
 } hypercall_table_t;
 
 typedef struct {
index 895e2ff68d134f99f0b25a49ff651d50f49547dc..91db0429635cc2e60e635f6a96ded20cee09716b 100644 (file)
@@ -227,9 +227,6 @@ void xlat_start_info(struct start_info *, enum XLAT_start_info_console);
 struct vcpu_runstate_info;
 void xlat_vcpu_runstate_info(struct vcpu_runstate_info *);
 
-struct domain;
-int switch_compat(struct domain *);
-
 #else
 
 #define compat_handle_is_null(hnd) 0