Index: 2006-08-16/xen/Makefile =================================================================== --- 2006-08-16.orig/xen/Makefile 2006-08-25 15:32:05.000000000 +0200 +++ 2006-08-16/xen/Makefile 2006-08-25 15:33:32.000000000 +0200 @@ -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) Index: 2006-08-16/xen/Rules.mk =================================================================== --- 2006-08-16.orig/xen/Rules.mk 2006-08-25 15:32:05.000000000 +0200 +++ 2006-08-16/xen/Rules.mk 2006-08-25 15:33:32.000000000 +0200 @@ -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) Index: 2006-08-16/xen/arch/x86/x86_64/compat/entry.S =================================================================== --- 2006-08-16.orig/xen/arch/x86/x86_64/compat/entry.S 2006-08-25 15:32:49.000000000 +0200 +++ 2006-08-16/xen/arch/x86/x86_64/compat/entry.S 2006-08-25 15:33:32.000000000 +0200 @@ -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 Index: 2006-08-16/xen/arch/x86/x86_64/compat/traps.c =================================================================== --- 2006-08-16.orig/xen/arch/x86/x86_64/compat/traps.c 2006-08-25 15:32:49.000000000 +0200 +++ 2006-08-16/xen/arch/x86/x86_64/compat/traps.c 2006-08-25 15:33:32.000000000 +0200 @@ -1,25 +1,6 @@ #ifdef CONFIG_COMPAT -#if 0 /* XXX */ #include -#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) { Index: 2006-08-16/xen/common/Makefile =================================================================== --- 2006-08-16.orig/xen/common/Makefile 2006-08-25 15:32:05.000000000 +0200 +++ 2006-08-16/xen/common/Makefile 2006-08-25 15:33:32.000000000 +0200 @@ -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 Index: 2006-08-16/xen/common/compat/Makefile =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 +++ 2006-08-16/xen/common/compat/Makefile 2006-08-25 15:33:32.000000000 +0200 @@ -0,0 +1 @@ +obj-y += kernel.o Index: 2006-08-16/xen/common/compat/kernel.c =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 +++ 2006-08-16/xen/common/compat/kernel.c 2006-08-25 15:33:32.000000000 +0200 @@ -0,0 +1,53 @@ +/****************************************************************************** + * kernel.c + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define xen_extraversion compat_extraversion +#define xen_extraversion_t compat_extraversion_t + +#define xen_compile_info compat_compile_info +#define xen_compile_info_t compat_compile_info_t + +CHECK(capabilities_info_t); + +#define xen_platform_parameters compat_platform_parameters +#define xen_platform_parameters_t compat_platform_parameters_t +#undef HYPERVISOR_VIRT_START +#define HYPERVISOR_VIRT_START HYPERVISOR_COMPAT_VIRT_START + +#define xen_changeset_info compat_changeset_info +#define xen_changeset_info_t compat_changeset_info_t + +#define xen_feature_info compat_feature_info +#define xen_feature_info_t compat_feature_info_t + +CHECK(domain_handle_t); + +#define xennmi_callback compat_nmi_callback +#define xennmi_callback_t compat_nmi_callback_t + +#include "../kernel.c" + +/* + * Local variables: + * mode: C + * c-set-style: "BSD" + * c-basic-offset: 4 + * tab-width: 4 + * indent-tabs-mode: nil + * End: + */ Index: 2006-08-16/xen/common/kernel.c =================================================================== --- 2006-08-16.orig/xen/common/kernel.c 2006-08-25 15:32:05.000000000 +0200 +++ 2006-08-16/xen/common/kernel.c 2006-08-25 15:33:32.000000000 +0200 @@ -11,11 +11,14 @@ #include #include #include +#include #include #include #include #include +#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_H return -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_GUE return 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; Index: 2006-08-16/xen/include/Makefile =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 +++ 2006-08-16/xen/include/Makefile 2006-08-25 15:33:32.000000000 +0200 @@ -0,0 +1,53 @@ +ifneq ($(CONFIG_COMPAT),) + +headers-y := $(shell find public -name '*.h' -not -name '*-*' | sed 's,^public,compat,') +headers-$(CONFIG_X86) += compat/arch-x86_32.h + +cppflags-y := -include public/xen-compat.h +cppflags-$(CONFIG_X86) += -m32 + +# 8-byte types are 4-byte aligned on x86_32 ... +prefix-$(CONFIG_X86) := \#pragma pack(push, 4) +suffix-$(CONFIG_X86) := \#pragma pack(pop) + +endif + +.PHONY: all +all: $(headers-y) + +compat/%.h: compat/%.i Makefile + id=_$$(echo $@ | sed 'y,abcdefghijklmnopqrstuvwxyz-/.,ABCDEFGHIJKLMNOPQRSTUVWXYZ___,'); \ + echo "#ifndef $$id" >$@.new; \ + echo "#define $$id" >>$@.new; \ + echo "#include " >>$@.new; \ + $(if $(filter-out compat/arch-%.h,$@),echo "#include <$(patsubst compat/%,public/%,$@)>" >>$@.new;) \ + $(if $(prefix-y),echo "$(prefix-y)" >>$@.new;) \ + grep -v '^# [[:digit:]]' $< | \ + sed -e 's,__InClUdE__,#include,' \ + -e 's,"xen-compat.h",,' \ + -e 's,\(struct\|union\|enum\)[[:space:]]*\(xen_\?\)\?\([[:alpha:]_]\),\1 compat_\3,g' \ + -e 's,_t\([^[:alnum:]_]\|$$\),_compat_t\1,g' \ + -e 's,\(8\|16\|32\|64\)_compat_t\([^[:alnum:]_]\|$$\),\1_t\2,g' \ + -e 's,\(^\|[^[:alnum:]_]\)xen_\?\([[:alnum:]_]*\)_compat_t\([^[:alnum:]_]\|$$\),\1compat_\2_t\3,g' \ + -e 's,\(^\|[^[:alnum:]_]\)XEN_\?,\1COMPAT_,' \ + -e 's,\(^\|[^[:alnum:]_]\)Xen_\?,\1Compat_,' \ + -e 's,\(^\|[^[:alnum:]]\)long\([^[:alnum:]]\|$$\),\1int\2,g' | \ + uniq >>$@.new; \ + $(if $(suffix-y),echo "$(suffix-y)" >>$@.new;) \ + echo "#endif /* $$id */" >>$@.new + mv -f $@.new $@ + +compat/%.i: compat/%.c Makefile + $(CPP) $(CFLAGS) $(cppflags-y) -o $@ $< + +compat/%.c: public/%.h Makefile + mkdir -p $(@D) + grep -v 'DEFINE_XEN_GUEST_HANDLE(long)' $< | \ + sed -e 's,^[[:space:]]*#[[:space:]]*include[[:space:]]\+,__InClUdE__ ,' \ + -e 's,^[[:space:]]*#[[:space:]]*define[[:space:]]\+\([[:upper:]_]*_GUEST_HANDLE\),#define HIDE_\1,' \ + -e 's,^[[:space:]]*#[[:space:]]*define[[:space:]]\+\([[:lower:]_]*_guest_handle\),#define hide_\1,' \ + -e 's,XEN_GUEST_HANDLE,COMPAT_HANDLE,g' \ + >$@ + +clean:: + rm -rf compat Index: 2006-08-16/xen/include/asm-x86/compat.h =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 +++ 2006-08-16/xen/include/asm-x86/compat.h 2006-08-25 15:33:32.000000000 +0200 @@ -0,0 +1,6 @@ +/****************************************************************************** + * compat.h + */ + +typedef uint32_t compat_ptr_t; +typedef unsigned long full_ptr_t; Index: 2006-08-16/xen/include/xen/compat.h =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 +++ 2006-08-16/xen/include/xen/compat.h 2006-08-25 15:33:32.000000000 +0200 @@ -0,0 +1,40 @@ +/****************************************************************************** + * compat.h + */ + +#ifndef __XEN_COMPAT_H__ +#define __XEN_COMPAT_H__ + +#include + +#ifdef CONFIG_COMPAT + +#include +#include +#include + +#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__ */