x86_64: generate compatibility headers from public ones
RFC PATCH 3/4 x86_64: generate compatibility headers from public ones
This introduces
- a mechanism to translate the public headers into compatibility variants
- the first few compatibility hypercall clones making use of these
Signed-off-by Jan Beulich <[email protected]>
xen/Makefile +2 -0
@@ -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
@@ -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 +8 -11
@@ -273,16 +273,13 @@ CFIX13: #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
@@ -300,7 +297,7 @@ ENTRY(compat_hypercall_table) .quad compat_set_debugreg .quad compat_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
@@ -314,7 +311,7 @@ ENTRY(compat_hypercall_table) .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
@@ -323,9 +320,9 @@ 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 .rept NR_hypercalls-((.-compat_hypercall_table)/8) - .quad do_ni_hypercall + .quad compat_ni_hypercall .endr ENTRY(compat_hypercall_args_table)
@@ -340,7 +337,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 */
@@ -354,7 +351,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 */
@@ -363,7 +360,7 @@ 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 */ .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
@@ -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
@@ -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 +1 -0
@@ -0,0 +1 @@ +obj-y += kernel.o
xen/common/compat/kernel.c new file +53 -0
53 lines not on this page · raw message
xen/common/kernel.c +16 -4
@@ -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,16 @@ void add_taint(unsigned flag) tainted |= flag; } +# define COMPAT (fn) long do_##fn +# define NATIVE + +#endif +/* * Simple hypercalls. */ -long do_xen_version (int cmd,XEN_GUEST_HANDLE (void ) arg) +COMPAT (xen_version)(int cmd,XEN_GUEST_HANDLE (void ) arg) {switch ( cmd ) {
@@ -234,6 +242,8 @@ long do_xen_version(int cmd, XEN_GUEST_Hreturn -ENOSYS ; } +#ifdef NATIVE +long register_guest_nmi_callback (unsigned long address) {struct vcpu *v = current;
@@ -264,7 +274,9 @@ long unregister_guest_nmi_callback(void) return 0; } -long do_nmi_op (unsigned int cmd,XEN_GUEST_HANDLE (void ) arg) +#endif + +COMPAT (nmi_op)(unsigned int cmd,XEN_GUEST_HANDLE (void ) arg) {struct xennmi_callback cb;long rc =0 ;
@@ -288,12 +300,12 @@ long do_nmi_op(unsigned int cmd, XEN_GUEreturn rc; } -long do_vm_assist (unsigned int cmd,unsigned int type) +COMPAT (vm_assist)(unsigned int cmd,unsigned int type) {return vm_assist (current->domain, cmd, type); } -long do_ni_hypercall (void ) +COMPAT (ni_hypercall)(void ) {/* No-op hypercall. */ return -ENOSYS ;
xen/include/Makefile new file +53 -0
53 lines not on this page · raw message
xen/include/asm-x86/compat.h new file +6 -0
@@ -0,0 +1,6 @@ +/****************************************************************************** +* compat.h +*/ + +typedef uint32_t compat_ptr_t ; +typedef unsigned long full_ptr_t ;
xen/include/xen/compat.h new file +40 -0
@@ -0,0 +1,40 @@ +/****************************************************************************** +* compat.h +*/ + +#ifndef __XEN_COMPAT_H__ +#define __XEN_COMPAT_H__ + +#include <xen/config.h> + +#ifdef CONFIG_COMPAT + +#include <xen/types.h> +#include <asm/compat.h> +#include <compat/xlat.h> + +#define __DEFINE_COMPAT_HANDLE (name, type) \ + typedef struct { compat_ptr_t ptr; } __compat_handle_ ## name; \ + static inline type *get_compat_ ## name(__compat_handle_ ## name hndl) \ + { \ + return (type *)(full_ptr_t)hndl.ptr; \ + } \ + typedef void __compat_ignore_ ## name + +#define DEFINE_COMPAT_HANDLE (name) __DEFINE_COMPAT_HANDLE(name, name) +#define COMPAT_HANDLE (name) __compat_handle_ ## name + +#define COMPAT (fn) int compat_##fn + +#define CHECK (name) \ + typedef int __check_ ## name[(xen_ ## name *)0 == (compat_ ## name *)0] + +/* In-place translation functons: */ +struct start_info ; +void xlat_start_info (struct start_info *,enum XLAT_start_info_console ); +struct dom0_vga_console_info ; +size_t xlat_dom0_vga_console_info (struct dom0_vga_console_info *); + +#endif + +#endif /* __XEN_COMPAT_H__ */
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel