Skip to contentSkip to conversation

32-on-64 compatibility header generation

RFC PATCH In review Jan Beulich 1 participant 1 message Oct 4, 2006

lore
Share & tools
lore
#0 lore raw

RFC PATCH 4/17 32-on-64 compatibility header generation

.. plus using a few hypercalls that don't need argument translation

xen/Makefile +2 -0
Index: 2006-10-04/xen/Makefile
===================================================================
@@ -47,6 +47,7 @@ _debug:
 .PHONY: _clean
 _clean: delete-unfresh-files
 	$(MAKE) -C tools clean
+	$(MAKE) -f $(BASEDIR)/Rules.mk -C include clean
 	$(MAKE) -f $(BASEDIR)/Rules.mk -C common clean
 	$(MAKE) -f $(BASEDIR)/Rules.mk -C drivers clean
 	$(MAKE) -f $(BASEDIR)/Rules.mk -C acm clean
@@ -68,6 +69,7 @@ $(TARGET): delete-unfresh-files
 	$(MAKE) -f $(BASEDIR)/Rules.mk include/xen/compile.h
 	$(MAKE) -f $(BASEDIR)/Rules.mk include/xen/acm_policy.h
 	[ -e include/asm ] || ln -sf asm-$(TARGET_ARCH) include/asm
+	$(MAKE) -f $(BASEDIR)/Rules.mk -C include
 	$(MAKE) -f $(BASEDIR)/Rules.mk -C arch/$(TARGET_ARCH) asm-offsets.s
 	$(MAKE) -f $(BASEDIR)/Rules.mk include/asm-$(TARGET_ARCH)/asm-offsets.h
 	$(MAKE) -f $(BASEDIR)/Rules.mk -C arch/$(TARGET_ARCH) $(TARGET)
xen/Rules.mk +1 -0
Index: 2006-10-04/xen/Rules.mk
===================================================================
@@ -32,6 +32,7 @@ TARGET := $(BASEDIR)/xen
 
 HDRS := $(wildcard $(BASEDIR)/include/xen/*.h)
 HDRS += $(wildcard $(BASEDIR)/include/public/*.h)
+HDRS += $(wildcard $(BASEDIR)/include/compat/*.h)
 HDRS += $(wildcard $(BASEDIR)/include/asm-$(TARGET_ARCH)/*.h)
 HDRS += $(wildcard $(BASEDIR)/include/asm-$(TARGET_ARCH)/$(TARGET_SUBARCH)/*.h)
 
xen/arch/x86/x86_64/compat/entry.S +14 -23
Index: 2006-10-04/xen/arch/x86/x86_64/compat/entry.S
===================================================================
@@ -281,28 +281,19 @@ CFIX14:
 #define compat_set_trap_table domain_crash_synchronous
 #define compat_mmu_update domain_crash_synchronous
 #define compat_set_gdt domain_crash_synchronous
-#define compat_stack_switch domain_crash_synchronous
-#define compat_fpu_taskswitch domain_crash_synchronous
-#define compat_arch_sched_op_compat domain_crash_synchronous
 #define compat_platform_op domain_crash_synchronous
-#define compat_set_debugreg domain_crash_synchronous
-#define compat_get_debugreg domain_crash_synchronous
 #define compat_update_descriptor domain_crash_synchronous
 #define compat_memory_op domain_crash_synchronous
 #define compat_multicall domain_crash_synchronous
 #define compat_update_va_mapping domain_crash_synchronous
 #define compat_set_timer_op domain_crash_synchronous
 #define compat_event_channel_op_compat domain_crash_synchronous
-#define compat_xen_version domain_crash_synchronous
-#define compat_console_io domain_crash_synchronous
 #define compat_physdev_op_compat domain_crash_synchronous
 #define compat_grant_table_op domain_crash_synchronous
-#define compat_vm_assist domain_crash_synchronous
 #define compat_update_va_mapping_otherdomain domain_crash_synchronous
 #define compat_vcpu_op domain_crash_synchronous
 #define compat_mmuext_op domain_crash_synchronous
 #define compat_acm_op domain_crash_synchronous
-#define compat_nmi_op domain_crash_synchronous
 #define compat_arch_sched_op domain_crash_synchronous
 #define compat_xenoprof_op domain_crash_synchronous
 #define compat_event_channel_op domain_crash_synchronous
@@ -314,29 +305,29 @@ ENTRY(compat_hypercall_table)
         .quad compat_set_trap_table     /*  0 */
         .quad compat_mmu_update
         .quad compat_set_gdt
-        .quad compat_stack_switch
+        .quad do_stack_switch
         .quad compat_set_callbacks
-        .quad compat_fpu_taskswitch     /*  5 */
-        .quad compat_arch_sched_op_compat
+        .quad do_fpu_taskswitch         /*  5 */
+        .quad do_arch_sched_op_compat
         .quad compat_platform_op
-        .quad compat_set_debugreg
-        .quad compat_get_debugreg
+        .quad do_set_debugreg
+        .quad do_get_debugreg
         .quad compat_update_descriptor  /* 10 */
-        .quad do_ni_hypercall
+        .quad compat_ni_hypercall
         .quad compat_memory_op
         .quad compat_multicall
         .quad compat_update_va_mapping
         .quad compat_set_timer_op       /* 15 */
         .quad compat_event_channel_op_compat
         .quad compat_xen_version
-        .quad compat_console_io
+        .quad do_console_io
         .quad compat_physdev_op_compat
         .quad compat_grant_table_op     /* 20 */
         .quad compat_vm_assist
         .quad compat_update_va_mapping_otherdomain
         .quad compat_iret
         .quad compat_vcpu_op
-        .quad do_ni_hypercall           /* 25 */
+        .quad compat_ni_hypercall       /* 25 */
         .quad compat_mmuext_op
         .quad compat_acm_op
         .quad compat_nmi_op
@@ -345,11 +336,11 @@ ENTRY(compat_hypercall_table)
         .quad compat_xenoprof_op
         .quad compat_event_channel_op
         .quad compat_physdev_op
-        .quad do_ni_hypercall
+        .quad compat_ni_hypercall
         .quad compat_sysctl             /* 35 */
         .quad compat_domctl
         .rept NR_hypercalls-((.-compat_hypercall_table)/8)
-        .quad do_ni_hypercall
+        .quad compat_ni_hypercall
         .endr
 
 ENTRY(compat_hypercall_args_table)
@@ -364,7 +355,7 @@ ENTRY(compat_hypercall_args_table)
         .byte 2 /* compat_set_debugreg      */
         .byte 1 /* compat_get_debugreg      */
         .byte 4 /* compat_update_descriptor */  /* 10 */
-        .byte 0 /* do_ni_hypercall          */
+        .byte 0 /* compat_ni_hypercall      */
         .byte 2 /* compat_memory_op         */
         .byte 2 /* compat_multicall         */
         .byte 4 /* compat_update_va_mapping */
@@ -378,7 +369,7 @@ ENTRY(compat_hypercall_args_table)
         .byte 5 /* compat_update_va_mapping_otherdomain */
         .byte 0 /* compat_iret              */
         .byte 3 /* compat_vcpu_op           */
-        .byte 0 /* do_ni_hypercall          */  /* 25 */
+        .byte 0 /* compat_ni_hypercall      */  /* 25 */
         .byte 4 /* compat_mmuext_op         */
         .byte 1 /* compat_acm_op            */
         .byte 2 /* compat_nmi_op            */
@@ -387,9 +378,9 @@ ENTRY(compat_hypercall_args_table)
         .byte 2 /* compat_xenoprof_op       */
         .byte 2 /* compat_event_channel_op  */
         .byte 2 /* compat_physdev_op        */
-        .byte 0 /* do_ni_hypercall          */
+        .byte 0 /* compat_ni_hypercall      */
         .byte 1 /* compat_sysctl            */  /* 35 */
         .byte 1 /* compat_domctl            */
         .rept NR_hypercalls-(.-compat_hypercall_args_table)
-        .byte 0 /* do_ni_hypercall          */
+        .byte 0 /* compat_ni_hypercall      */
         .endr
xen/arch/x86/x86_64/compat/traps.c +0 -19
Index: 2006-10-04/xen/arch/x86/x86_64/compat/traps.c
===================================================================
@@ -1,25 +1,6 @@
 #ifdef CONFIG_COMPAT
 
-#if 0 /* XXX */
 #include <compat/callback.h>
-#else
-struct compat_xen_callback {
-    unsigned int cs;
-    unsigned int eip;
-};
-typedef struct compat_xen_callback xen_callback_compat_t;
-
-struct compat_callback_register {
-    uint16_t type;
-    uint16_t flags;
-    xen_callback_compat_t address;
-};
-
-struct compat_callback_unregister {
-    uint16_t type;
-    uint16_t _unused;
-};
-#endif
 
 void compat_show_guest_stack(struct cpu_user_regs *regs, int debug_stack_lines)
 {
xen/common/Makefile +2 -0
Index: 2006-10-04/xen/common/Makefile
===================================================================
@@ -30,5 +30,7 @@ obj-y += xmalloc.o
 obj-$(perfc)       += perfc.o
 obj-$(crash_debug) += gdbstub.o
 
+subdir-$(CONFIG_COMPAT) += compat
+
 # Object file contains changeset and compiler information.
 version.o: $(BASEDIR)/include/xen/compile.h
xen/common/compat/Makefile new file +4 -0
Index: 2006-10-04/xen/common/compat/Makefile
===================================================================
@@ -0,0 +1,4 @@
+obj-y += kernel.o
+
+# extra dependencies
+kernel.o:	../kernel.c
xen/common/compat/kernel.c new file +56 -0

56 lines not on this page · raw message

xen/common/kernel.c +15 -4
Index: 2006-10-04/xen/common/kernel.c
===================================================================
@@ -11,11 +11,14 @@
 #include <xen/version.h>
 #include <xen/sched.h>
 #include <xen/shadow.h>
+#include <xen/nmi.h>
 #include <xen/guest_access.h>
 #include <asm/current.h>
 #include <public/nmi.h>
 #include <public/version.h>
 
+#ifndef COMPAT
+
 int tainted;
 
 char *cmdline_parse(char *cmdline)
@@ -120,11 +123,15 @@ void add_taint(unsigned flag)
     tainted |= flag;
 }
 
+# define DO(fn) long do_##fn
+
+#endif
+
 /*
  * Simple hypercalls.
  */
 
-long do_xen_version(int cmd, XEN_GUEST_HANDLE(void) arg)
+DO(xen_version)(int cmd, XEN_GUEST_HANDLE(void) arg)
 {
     switch ( cmd )
     {
@@ -234,6 +241,8 @@ long do_xen_version(int cmd, XEN_GUEST_H
     return -ENOSYS;
 }
 
+#ifndef COMPAT
+
 long register_guest_nmi_callback(unsigned long address)
 {
     struct vcpu *v = current;
@@ -264,7 +273,9 @@ long unregister_guest_nmi_callback(void)
     return 0;
 }
 
-long do_nmi_op(unsigned int cmd, XEN_GUEST_HANDLE(void) arg)
+#endif
+
+DO(nmi_op)(unsigned int cmd, XEN_GUEST_HANDLE(void) arg)
 {
     struct xennmi_callback cb;
     long rc = 0;
@@ -288,12 +299,12 @@ long do_nmi_op(unsigned int cmd, XEN_GUE
     return rc;
 }
 
-long do_vm_assist(unsigned int cmd, unsigned int type)
+DO(vm_assist)(unsigned int cmd, unsigned int type)
 {
     return vm_assist(current->domain, cmd, type);
 }
 
-long do_ni_hypercall(void)
+DO(ni_hypercall)(void)
 {
     /* No-op hypercall. */
     return -ENOSYS;
xen/include/Makefile new file +57 -0

57 lines not on this page · raw message

xen/include/asm-x86/compat.h new file +6 -0
Index: 2006-10-04/xen/include/asm-x86/compat.h
===================================================================
@@ -0,0 +1,6 @@
+/******************************************************************************
+ * compat.h
+ */
+
+typedef uint32_t compat_ptr_t;
+typedef unsigned long full_ptr_t;
xen/include/asm-x86/x86_64/uaccess.h +13 -0
Index: 2006-10-04/xen/include/asm-x86/x86_64/uaccess.h
===================================================================
@@ -15,6 +15,19 @@
 
 #define array_access_ok(addr, count, size) (__addr_ok(addr))
 
+#ifdef CONFIG_COMPAT
+
+#define __compat_addr_ok(addr) \
+    ((unsigned long)(addr) < HYPERVISOR_COMPAT_VIRT_START)
+
+#define compat_access_ok(addr, size) __compat_addr_ok((addr) + (size))
+
+#define compat_array_access_ok(addr,count,size) \
+    (likely((count) < (~0U / (size))) && \
+     compat_access_ok(addr, (count) * (size)))
+
+#endif
+
 #define __put_user_size(x,ptr,size,retval,errret)			\
 do {									\
 	retval = 0;							\
xen/include/xen/compat.h new file +152 -0

152 lines not on this page · raw message