Jan Beulich
2007-Apr-04 14:16 UTC
[Xen-devel] [PATCH] linux: make compatibility config options more scalable
Signed-off-by: Jan Beulich <jbeulich@novell.com> Index: head-2007-03-19/arch/i386/kernel/head-xen.S ==================================================================--- head-2007-03-19.orig/arch/i386/kernel/head-xen.S 2007-04-02 12:34:10.000000000 +0200 +++ head-2007-03-19/arch/i386/kernel/head-xen.S 2007-03-26 14:48:20.000000000 +0200 @@ -142,7 +142,7 @@ ENTRY(cpu_gdt_table) .quad 0x0000000000000000 /* 0xf0 - unused */ .quad 0x0000000000000000 /* 0xf8 - GDT entry 31: double-fault TSS */ -#ifdef CONFIG_XEN_COMPAT_030002 +#if CONFIG_XEN_COMPAT <= 0x030002 /* * __xen_guest information */ @@ -180,18 +180,18 @@ ENTRY(cpu_gdt_table) #endif .ascii ",LOADER=generic" .byte 0 -#endif /* CONFIG_XEN_COMPAT_030002 */ +#endif /* CONFIG_XEN_COMPAT <= 0x030002 */ ELFNOTE(Xen, XEN_ELFNOTE_GUEST_OS, .asciz, "linux") ELFNOTE(Xen, XEN_ELFNOTE_GUEST_VERSION, .asciz, "2.6") ELFNOTE(Xen, XEN_ELFNOTE_XEN_VERSION, .asciz, "xen-3.0") ELFNOTE(Xen, XEN_ELFNOTE_VIRT_BASE, .long, __PAGE_OFFSET) -#ifdef CONFIG_XEN_COMPAT_030002 +#if CONFIG_XEN_COMPAT <= 0x030002 ELFNOTE(Xen, XEN_ELFNOTE_PADDR_OFFSET, .long, __PAGE_OFFSET) #else ELFNOTE(Xen, XEN_ELFNOTE_PADDR_OFFSET, .long, 0) -#endif /* !CONFIG_XEN_COMPAT_030002 */ +#endif ELFNOTE(Xen, XEN_ELFNOTE_ENTRY, .long, startup_32) ELFNOTE(Xen, XEN_ELFNOTE_HYPERCALL_PAGE, .long, hypercall_page) ELFNOTE(Xen, XEN_ELFNOTE_HV_START_LOW, .long, HYPERVISOR_VIRT_START) Index: head-2007-03-19/arch/i386/kernel/time-xen.c ==================================================================--- head-2007-03-19.orig/arch/i386/kernel/time-xen.c 2007-04-02 12:34:10.000000000 +0200 +++ head-2007-03-19/arch/i386/kernel/time-xen.c 2007-04-02 12:34:20.000000000 +0200 @@ -1010,7 +1010,7 @@ static void stop_hz_timer(void) singleshot.timeout_abs_ns = jiffies_to_st(j); singleshot.flags = 0; rc = HYPERVISOR_vcpu_op(VCPUOP_set_singleshot_timer, cpu, &singleshot); -#ifdef CONFIG_XEN_COMPAT_030004 +#if CONFIG_XEN_COMPAT <= 0x030004 if (rc) { BUG_ON(rc != -ENOSYS); rc = HYPERVISOR_set_timer_op(singleshot.timeout_abs_ns); Index: head-2007-03-19/arch/i386/mach-xen/setup.c ==================================================================--- head-2007-03-19.orig/arch/i386/mach-xen/setup.c 2007-04-02 12:34:10.000000000 +0200 +++ head-2007-03-19/arch/i386/mach-xen/setup.c 2007-03-26 14:48:20.000000000 +0200 @@ -114,7 +114,7 @@ void __init machine_specific_arch_setup( ret = HYPERVISOR_callback_op(CALLBACKOP_register, &event); if (ret == 0) ret = HYPERVISOR_callback_op(CALLBACKOP_register, &failsafe); -#ifdef CONFIG_XEN_COMPAT_030002 +#if CONFIG_XEN_COMPAT <= 0x030002 if (ret == -ENOSYS) ret = HYPERVISOR_set_callbacks( event.address.cs, event.address.eip, @@ -123,7 +123,7 @@ void __init machine_specific_arch_setup( BUG_ON(ret); ret = HYPERVISOR_callback_op(CALLBACKOP_register, &nmi_cb); -#ifdef CONFIG_XEN_COMPAT_030002 +#if CONFIG_XEN_COMPAT <= 0x030002 if (ret == -ENOSYS) { static struct xennmi_callback __initdata cb = { .handler_address = (unsigned long)nmi Index: head-2007-03-19/arch/i386/mm/hypervisor.c ==================================================================--- head-2007-03-19.orig/arch/i386/mm/hypervisor.c 2007-04-02 12:34:10.000000000 +0200 +++ head-2007-03-19/arch/i386/mm/hypervisor.c 2007-03-26 14:48:20.000000000 +0200 @@ -312,7 +312,7 @@ int xen_create_contiguous_region( success = (exchange.nr_exchanged == (1UL << order)); BUG_ON(!success && ((exchange.nr_exchanged != 0) || (rc == 0))); BUG_ON(success && (rc != 0)); -#ifdef CONFIG_XEN_COMPAT_030002 +#if CONFIG_XEN_COMPAT <= 0x030002 if (unlikely(rc == -ENOSYS)) { /* Compatibility when XENMEM_exchange is unsupported. */ if (HYPERVISOR_memory_op(XENMEM_decrease_reservation, @@ -408,7 +408,7 @@ void xen_destroy_contiguous_region(unsig success = (exchange.nr_exchanged == 1); BUG_ON(!success && ((exchange.nr_exchanged != 0) || (rc == 0))); BUG_ON(success && (rc != 0)); -#ifdef CONFIG_XEN_COMPAT_030002 +#if CONFIG_XEN_COMPAT <= 0x030002 if (unlikely(rc == -ENOSYS)) { /* Compatibility when XENMEM_exchange is unsupported. */ if (HYPERVISOR_memory_op(XENMEM_decrease_reservation, Index: head-2007-03-19/arch/x86_64/kernel/head-xen.S ==================================================================--- head-2007-03-19.orig/arch/x86_64/kernel/head-xen.S 2007-04-02 12:34:10.000000000 +0200 +++ head-2007-03-19/arch/x86_64/kernel/head-xen.S 2007-03-26 17:11:36.000000000 +0200 @@ -155,7 +155,7 @@ gdt_end: ENTRY(empty_zero_page) .skip PAGE_SIZE -#ifdef CONFIG_XEN_COMPAT_030002 +#if CONFIG_XEN_COMPAT <= 0x030002 /* * __xen_guest information */ @@ -187,17 +187,17 @@ ENTRY(empty_zero_page) .ascii "|supervisor_mode_kernel" .ascii ",LOADER=generic" .byte 0 -#endif /* CONFIG_XEN_COMPAT_030002 */ +#endif /* CONFIG_XEN_COMPAT <= 0x030002 */ ELFNOTE(Xen, XEN_ELFNOTE_GUEST_OS, .asciz, "linux") ELFNOTE(Xen, XEN_ELFNOTE_GUEST_VERSION, .asciz, "2.6") ELFNOTE(Xen, XEN_ELFNOTE_XEN_VERSION, .asciz, "xen-3.0") ELFNOTE(Xen, XEN_ELFNOTE_VIRT_BASE, .quad, __START_KERNEL_map) -#ifdef CONFIG_XEN_COMPAT_030002 +#if CONFIG_XEN_COMPAT <= 0x030002 ELFNOTE(Xen, XEN_ELFNOTE_PADDR_OFFSET, .quad, __START_KERNEL_map) #else ELFNOTE(Xen, XEN_ELFNOTE_PADDR_OFFSET, .quad, 0) -#endif /* !CONFIG_XEN_COMPAT_030002 */ +#endif ELFNOTE(Xen, XEN_ELFNOTE_ENTRY, .quad, startup_64) ELFNOTE(Xen, XEN_ELFNOTE_HYPERCALL_PAGE, .quad, hypercall_page) ELFNOTE(Xen, XEN_ELFNOTE_L1_MFN_VALID, .quad, _PAGE_PRESENT,_PAGE_PRESENT) Index: head-2007-03-19/arch/x86_64/mm/init-xen.c ==================================================================--- head-2007-03-19.orig/arch/x86_64/mm/init-xen.c 2007-04-02 12:34:10.000000000 +0200 +++ head-2007-03-19/arch/x86_64/mm/init-xen.c 2007-03-26 17:11:31.000000000 +0200 @@ -54,7 +54,7 @@ struct dma_mapping_ops* dma_ops; EXPORT_SYMBOL(dma_ops); -#ifdef CONFIG_XEN_COMPAT_030002 +#if CONFIG_XEN_COMPAT <= 0x030002 unsigned int __kernel_page_user; EXPORT_SYMBOL(__kernel_page_user); #endif @@ -551,7 +551,7 @@ void __init xen_init_pt(void) addr = page[pud_index(__START_KERNEL_map)]; addr_to_page(addr, page); -#ifdef CONFIG_XEN_COMPAT_030002 +#if CONFIG_XEN_COMPAT <= 0x030002 /* On Xen 3.0.2 and older we may need to explicitly specify _PAGE_USER in kernel PTEs. We check that here. */ if (HYPERVISOR_xen_version(XENVER_version, NULL) <= 0x30000) { Index: head-2007-03-19/drivers/xen/Kconfig ==================================================================--- head-2007-03-19.orig/drivers/xen/Kconfig 2007-04-02 12:34:10.000000000 +0200 +++ head-2007-03-19/drivers/xen/Kconfig 2007-03-26 14:48:20.000000000 +0200 @@ -235,13 +235,12 @@ choice endchoice -config XEN_COMPAT_030002 - bool - default XEN_COMPAT_030002_AND_LATER - -config XEN_COMPAT_030004 - bool - default XEN_COMPAT_030002_AND_LATER || XEN_COMPAT_030004_AND_LATER +config XEN_COMPAT + hex + default 0xffffff if XEN_COMPAT_LATEST_ONLY + default 0x030004 if XEN_COMPAT_030004_AND_LATER + default 0x030002 if XEN_COMPAT_030002_AND_LATER + default 0 endmenu Index: head-2007-03-19/include/asm-i386/mach-xen/asm/hypercall.h ==================================================================--- head-2007-03-19.orig/include/asm-i386/mach-xen/asm/hypercall.h 2007-04-02 12:34:10.000000000 +0200 +++ head-2007-03-19/include/asm-i386/mach-xen/asm/hypercall.h 2007-03-26 14:48:20.000000000 +0200 @@ -261,7 +261,7 @@ HYPERVISOR_event_channel_op( { int rc = _hypercall2(int, event_channel_op, cmd, arg); -#ifdef CONFIG_XEN_COMPAT_030002 +#if CONFIG_XEN_COMPAT <= 0x030002 if (unlikely(rc == -ENOSYS)) { struct evtchn_op op; op.cmd = cmd; @@ -301,7 +301,7 @@ HYPERVISOR_physdev_op( { int rc = _hypercall2(int, physdev_op, cmd, arg); -#ifdef CONFIG_XEN_COMPAT_030002 +#if CONFIG_XEN_COMPAT <= 0x030002 if (unlikely(rc == -ENOSYS)) { struct physdev_op op; op.cmd = cmd; @@ -358,7 +358,7 @@ HYPERVISOR_suspend( int rc = _hypercall3(int, sched_op, SCHEDOP_shutdown, &sched_shutdown, srec); -#ifdef CONFIG_XEN_COMPAT_030002 +#if CONFIG_XEN_COMPAT <= 0x030002 if (rc == -ENOSYS) rc = _hypercall3(int, sched_op_compat, SCHEDOP_shutdown, SHUTDOWN_suspend, srec); Index: head-2007-03-19/include/asm-i386/mach-xen/asm/hypervisor.h ==================================================================--- head-2007-03-19.orig/include/asm-i386/mach-xen/asm/hypervisor.h 2007-04-02 12:34:10.000000000 +0200 +++ head-2007-03-19/include/asm-i386/mach-xen/asm/hypervisor.h 2007-03-26 14:48:20.000000000 +0200 @@ -140,7 +140,7 @@ HYPERVISOR_yield( { int rc = HYPERVISOR_sched_op(SCHEDOP_yield, NULL); -#ifdef CONFIG_XEN_COMPAT_030002 +#if CONFIG_XEN_COMPAT <= 0x030002 if (rc == -ENOSYS) rc = HYPERVISOR_sched_op_compat(SCHEDOP_yield, 0); #endif @@ -154,7 +154,7 @@ HYPERVISOR_block( { int rc = HYPERVISOR_sched_op(SCHEDOP_block, NULL); -#ifdef CONFIG_XEN_COMPAT_030002 +#if CONFIG_XEN_COMPAT <= 0x030002 if (rc == -ENOSYS) rc = HYPERVISOR_sched_op_compat(SCHEDOP_block, 0); #endif @@ -172,7 +172,7 @@ HYPERVISOR_shutdown( int rc = HYPERVISOR_sched_op(SCHEDOP_shutdown, &sched_shutdown); -#ifdef CONFIG_XEN_COMPAT_030002 +#if CONFIG_XEN_COMPAT <= 0x030002 if (rc == -ENOSYS) rc = HYPERVISOR_sched_op_compat(SCHEDOP_shutdown, reason); #endif @@ -192,7 +192,7 @@ HYPERVISOR_poll( set_xen_guest_handle(sched_poll.ports, ports); rc = HYPERVISOR_sched_op(SCHEDOP_poll, &sched_poll); -#ifdef CONFIG_XEN_COMPAT_030002 +#if CONFIG_XEN_COMPAT <= 0x030002 if (rc == -ENOSYS) rc = HYPERVISOR_sched_op_compat(SCHEDOP_yield, 0); #endif Index: head-2007-03-19/include/asm-i386/mach-xen/asm/page.h ==================================================================--- head-2007-03-19.orig/include/asm-i386/mach-xen/asm/page.h 2007-04-02 12:34:10.000000000 +0200 +++ head-2007-03-19/include/asm-i386/mach-xen/asm/page.h 2007-03-26 14:48:20.000000000 +0200 @@ -108,7 +108,7 @@ static inline unsigned long long pte_val static inline unsigned long long pmd_val(pmd_t x) { unsigned long long ret = x.pmd; -#ifdef CONFIG_XEN_COMPAT_030002 +#if CONFIG_XEN_COMPAT <= 0x030002 if (ret) ret = pte_machine_to_phys(ret) | _PAGE_PRESENT; #else if (ret & _PAGE_PRESENT) ret = pte_machine_to_phys(ret); @@ -140,7 +140,7 @@ typedef struct { unsigned long pgprot; } static inline unsigned long pgd_val(pgd_t x) { unsigned long ret = x.pgd; -#ifdef CONFIG_XEN_COMPAT_030002 +#if CONFIG_XEN_COMPAT <= 0x030002 if (ret) ret = machine_to_phys(ret) | _PAGE_PRESENT; #else if (ret & _PAGE_PRESENT) ret = machine_to_phys(ret); @@ -203,10 +203,10 @@ extern int page_is_ram(unsigned long pag #endif #define __KERNEL_START (__PAGE_OFFSET + __PHYSICAL_START) -#ifdef CONFIG_XEN_COMPAT_030002 +#if CONFIG_XEN_COMPAT <= 0x030002 #undef LOAD_OFFSET #define LOAD_OFFSET 0 -#endif /* CONFIG_XEN_COMPAT_030002 */ +#endif #define PAGE_OFFSET ((unsigned long)__PAGE_OFFSET) #define VMALLOC_RESERVE ((unsigned long)__VMALLOC_RESERVE) Index: head-2007-03-19/include/asm-x86_64/mach-xen/asm/hypercall.h ==================================================================--- head-2007-03-19.orig/include/asm-x86_64/mach-xen/asm/hypercall.h 2007-04-02 12:34:10.000000000 +0200 +++ head-2007-03-19/include/asm-x86_64/mach-xen/asm/hypercall.h 2007-03-26 14:48:20.000000000 +0200 @@ -259,7 +259,7 @@ HYPERVISOR_event_channel_op( { int rc = _hypercall2(int, event_channel_op, cmd, arg); -#ifdef CONFIG_XEN_COMPAT_030002 +#if CONFIG_XEN_COMPAT <= 0x030002 if (unlikely(rc == -ENOSYS)) { struct evtchn_op op; op.cmd = cmd; @@ -299,7 +299,7 @@ HYPERVISOR_physdev_op( { int rc = _hypercall2(int, physdev_op, cmd, arg); -#ifdef CONFIG_XEN_COMPAT_030002 +#if CONFIG_XEN_COMPAT <= 0x030002 if (unlikely(rc == -ENOSYS)) { struct physdev_op op; op.cmd = cmd; @@ -359,7 +359,7 @@ HYPERVISOR_suspend( int rc = _hypercall3(int, sched_op, SCHEDOP_shutdown, &sched_shutdown, srec); -#ifdef CONFIG_XEN_COMPAT_030002 +#if CONFIG_XEN_COMPAT <= 0x030002 if (rc == -ENOSYS) rc = _hypercall3(int, sched_op_compat, SCHEDOP_shutdown, SHUTDOWN_suspend, srec); Index: head-2007-03-19/include/asm-x86_64/mach-xen/asm/page.h ==================================================================--- head-2007-03-19.orig/include/asm-x86_64/mach-xen/asm/page.h 2007-04-02 12:34:10.000000000 +0200 +++ head-2007-03-19/include/asm-x86_64/mach-xen/asm/page.h 2007-03-26 14:48:20.000000000 +0200 @@ -110,7 +110,7 @@ typedef struct { unsigned long pgprot; } static inline unsigned long pmd_val(pmd_t x) { unsigned long ret = x.pmd; -#ifdef CONFIG_XEN_COMPAT_030002 +#if CONFIG_XEN_COMPAT <= 0x030002 if (ret) ret = pte_machine_to_phys(ret) | _PAGE_PRESENT; #else if (ret & _PAGE_PRESENT) ret = pte_machine_to_phys(ret); @@ -172,10 +172,10 @@ static inline pgd_t __pgd(unsigned long #define __PAGE_OFFSET 0xffff880000000000 #endif /* !__ASSEMBLY__ */ -#ifdef CONFIG_XEN_COMPAT_030002 +#if CONFIG_XEN_COMPAT <= 0x030002 #undef LOAD_OFFSET #define LOAD_OFFSET 0 -#endif /* CONFIG_XEN_COMPAT_030002 */ +#endif /* to align the pointer to the (next) page boundary */ #define PAGE_ALIGN(addr) (((addr)+PAGE_SIZE-1)&PAGE_MASK) Index: head-2007-03-19/include/asm-x86_64/mach-xen/asm/pgtable.h ==================================================================--- head-2007-03-19.orig/include/asm-x86_64/mach-xen/asm/pgtable.h 2007-04-02 12:34:10.000000000 +0200 +++ head-2007-03-19/include/asm-x86_64/mach-xen/asm/pgtable.h 2007-03-26 17:12:07.000000000 +0200 @@ -205,7 +205,7 @@ static inline void pgd_clear (pgd_t * pg #define _PAGE_PROTNONE 0x080 /* If not present */ #define _PAGE_NX (1UL<<_PAGE_BIT_NX) -#ifdef CONFIG_XEN_COMPAT_030002 +#if CONFIG_XEN_COMPAT <= 0x030002 extern unsigned int __kernel_page_user; #else #define __kernel_page_user 0 Index: head-2007-03-19/include/asm-x86_64/mach-xen/setup_arch_post.h ==================================================================--- head-2007-03-19.orig/include/asm-x86_64/mach-xen/setup_arch_post.h 2007-04-02 12:34:10.000000000 +0200 +++ head-2007-03-19/include/asm-x86_64/mach-xen/setup_arch_post.h 2007-03-26 14:48:20.000000000 +0200 @@ -39,7 +39,7 @@ static void __init machine_specific_arch ret = HYPERVISOR_callback_op(CALLBACKOP_register, &failsafe); if (ret == 0) ret = HYPERVISOR_callback_op(CALLBACKOP_register, &syscall); -#ifdef CONFIG_XEN_COMPAT_030002 +#if CONFIG_XEN_COMPAT <= 0x030002 if (ret == -ENOSYS) ret = HYPERVISOR_set_callbacks( event.address, @@ -50,7 +50,7 @@ static void __init machine_specific_arch #ifdef CONFIG_X86_LOCAL_APIC ret = HYPERVISOR_callback_op(CALLBACKOP_register, &nmi_cb); -#ifdef CONFIG_XEN_COMPAT_030002 +#if CONFIG_XEN_COMPAT <= 0x030002 if (ret == -ENOSYS) { static struct xennmi_callback __initdata cb = { .handler_address = (unsigned long)nmi _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel