Jan Beulich
2006-Oct-30 13:35 UTC
[Xen-devel] [PATCH] linux: use CONFIG_XEN_COMPAT_030002 where possible
Signed-off-by: Jan Beulich <jbeulich@novell.com> Index: head-2006-10-16/arch/i386/mm/hypervisor.c ==================================================================--- head-2006-10-16.orig/arch/i386/mm/hypervisor.c +++ head-2006-10-16/arch/i386/mm/hypervisor.c @@ -325,6 +325,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 (unlikely(rc == -ENOSYS)) { /* Compatibility when XENMEM_exchange is unsupported. */ if (HYPERVISOR_memory_op(XENMEM_decrease_reservation, @@ -341,6 +342,7 @@ int xen_create_contiguous_region( BUG(); } } +#endif /* 3. Map the new extent in place of old pages. */ for (i = 0; i < (1UL<<order); i++) { @@ -419,6 +421,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 (unlikely(rc == -ENOSYS)) { /* Compatibility when XENMEM_exchange is unsupported. */ if (HYPERVISOR_memory_op(XENMEM_decrease_reservation, @@ -429,6 +432,7 @@ void xen_destroy_contiguous_region(unsig BUG(); success = 1; } +#endif /* 4. Map new pages in place of old pages. */ for (i = 0; i < (1UL<<order); i++) { Index: head-2006-10-16/arch/x86_64/kernel/e820-xen.c ==================================================================--- head-2006-10-16.orig/arch/x86_64/kernel/e820-xen.c +++ head-2006-10-16/arch/x86_64/kernel/e820-xen.c @@ -584,11 +584,14 @@ void __init setup_memory_region(void) */ struct e820entry map[E820MAX]; +#ifdef CONFIG_XEN_COMPAT_030002 memmap.nr_entries = E820MAX; set_xen_guest_handle(memmap.buffer, map); rc = HYPERVISOR_memory_op(XENMEM_memory_map, &memmap); - if ( rc == -ENOSYS ) { + if ( rc == -ENOSYS ) +#endif + { memmap.nr_entries = 1; map[0].addr = 0ULL; map[0].size = xen_start_info->nr_pages << PAGE_SHIFT; Index: head-2006-10-16/drivers/xen/balloon/balloon.c ==================================================================--- head-2006-10-16.orig/drivers/xen/balloon/balloon.c +++ head-2006-10-16/drivers/xen/balloon/balloon.c @@ -519,6 +519,8 @@ static int dealloc_pte_fn( set_pte_at(&init_mm, addr, pte, __pte_ma(0)); set_phys_to_machine(__pa(addr) >> PAGE_SHIFT, INVALID_P2M_ENTRY); ret = HYPERVISOR_memory_op(XENMEM_decrease_reservation, &reservation); + if (ret == -ENOSYS) + return ret; BUG_ON(ret != 1); return 0; } Index: head-2006-10-16/include/asm-i386/mach-xen/asm/hypercall.h ==================================================================--- head-2006-10-16.orig/include/asm-i386/mach-xen/asm/hypercall.h +++ head-2006-10-16/include/asm-i386/mach-xen/asm/hypercall.h @@ -260,6 +260,8 @@ HYPERVISOR_event_channel_op( int cmd, void *arg) { int rc = _hypercall2(int, event_channel_op, cmd, arg); + +#ifdef CONFIG_XEN_COMPAT_030002 if (unlikely(rc == -ENOSYS)) { struct evtchn_op op; op.cmd = cmd; @@ -267,6 +269,8 @@ HYPERVISOR_event_channel_op( rc = _hypercall1(int, event_channel_op_compat, &op); memcpy(arg, &op.u, sizeof(op.u)); } +#endif + return rc; } @@ -296,6 +300,8 @@ HYPERVISOR_physdev_op( int cmd, void *arg) { int rc = _hypercall2(int, physdev_op, cmd, arg); + +#ifdef CONFIG_XEN_COMPAT_030002 if (unlikely(rc == -ENOSYS)) { struct physdev_op op; op.cmd = cmd; @@ -303,6 +309,8 @@ HYPERVISOR_physdev_op( rc = _hypercall1(int, physdev_op_compat, &op); memcpy(arg, &op.u, sizeof(op.u)); } +#endif + return rc; } @@ -350,9 +358,11 @@ HYPERVISOR_suspend( int rc = _hypercall3(int, sched_op, SCHEDOP_shutdown, &sched_shutdown, srec); +#ifdef CONFIG_XEN_COMPAT_030002 if (rc == -ENOSYS) rc = _hypercall3(int, sched_op_compat, SCHEDOP_shutdown, SHUTDOWN_suspend, srec); +#endif return rc; } Index: head-2006-10-16/include/asm-i386/mach-xen/asm/hypervisor.h ==================================================================--- head-2006-10-16.orig/include/asm-i386/mach-xen/asm/hypervisor.h +++ head-2006-10-16/include/asm-i386/mach-xen/asm/hypervisor.h @@ -131,8 +131,10 @@ HYPERVISOR_yield( { int rc = HYPERVISOR_sched_op(SCHEDOP_yield, NULL); +#ifdef CONFIG_XEN_COMPAT_030002 if (rc == -ENOSYS) rc = HYPERVISOR_sched_op_compat(SCHEDOP_yield, 0); +#endif return rc; } @@ -143,8 +145,10 @@ HYPERVISOR_block( { int rc = HYPERVISOR_sched_op(SCHEDOP_block, NULL); +#ifdef CONFIG_XEN_COMPAT_030002 if (rc == -ENOSYS) rc = HYPERVISOR_sched_op_compat(SCHEDOP_block, 0); +#endif return rc; } @@ -159,8 +163,10 @@ HYPERVISOR_shutdown( int rc = HYPERVISOR_sched_op(SCHEDOP_shutdown, &sched_shutdown); +#ifdef CONFIG_XEN_COMPAT_030002 if (rc == -ENOSYS) rc = HYPERVISOR_sched_op_compat(SCHEDOP_shutdown, reason); +#endif return rc; } @@ -177,8 +183,10 @@ HYPERVISOR_poll( set_xen_guest_handle(sched_poll.ports, ports); rc = HYPERVISOR_sched_op(SCHEDOP_poll, &sched_poll); +#ifdef CONFIG_XEN_COMPAT_030002 if (rc == -ENOSYS) rc = HYPERVISOR_sched_op_compat(SCHEDOP_yield, 0); +#endif return rc; } Index: head-2006-10-16/include/asm-i386/mach-xen/setup_arch_post.h ==================================================================--- head-2006-10-16.orig/include/asm-i386/mach-xen/setup_arch_post.h +++ head-2006-10-16/include/asm-i386/mach-xen/setup_arch_post.h @@ -19,11 +19,14 @@ char * __init machine_specific_memory_se */ struct e820entry map[E820MAX]; +#ifdef CONFIG_XEN_COMPAT_030002 memmap.nr_entries = E820MAX; set_xen_guest_handle(memmap.buffer, map); rc = HYPERVISOR_memory_op(XENMEM_memory_map, &memmap); - if ( rc == -ENOSYS ) { + if ( rc == -ENOSYS ) +#endif + { memmap.nr_entries = 1; map[0].addr = 0ULL; map[0].size = PFN_PHYS(xen_start_info->nr_pages); @@ -72,19 +75,23 @@ 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 (ret == -ENOSYS) ret = HYPERVISOR_set_callbacks( event.address.cs, event.address.eip, failsafe.address.cs, failsafe.address.eip); +#endif BUG_ON(ret); ret = HYPERVISOR_callback_op(CALLBACKOP_register, &nmi_cb); +#ifdef CONFIG_XEN_COMPAT_030002 if (ret == -ENOSYS) { struct xennmi_callback cb; cb.handler_address = nmi_cb.address.eip; HYPERVISOR_nmi_op(XENNMI_register_callback, &cb); } +#endif if (HYPERVISOR_xen_version(XENVER_platform_parameters, &pp) == 0) Index: head-2006-10-16/include/asm-x86_64/mach-xen/asm/hypercall.h ==================================================================--- head-2006-10-16.orig/include/asm-x86_64/mach-xen/asm/hypercall.h +++ head-2006-10-16/include/asm-x86_64/mach-xen/asm/hypercall.h @@ -258,6 +258,8 @@ HYPERVISOR_event_channel_op( int cmd, void *arg) { int rc = _hypercall2(int, event_channel_op, cmd, arg); + +#ifdef CONFIG_XEN_COMPAT_030002 if (unlikely(rc == -ENOSYS)) { struct evtchn_op op; op.cmd = cmd; @@ -265,6 +267,8 @@ HYPERVISOR_event_channel_op( rc = _hypercall1(int, event_channel_op_compat, &op); memcpy(arg, &op.u, sizeof(op.u)); } +#endif + return rc; } @@ -294,6 +298,8 @@ HYPERVISOR_physdev_op( int cmd, void *arg) { int rc = _hypercall2(int, physdev_op, cmd, arg); + +#ifdef CONFIG_XEN_COMPAT_030002 if (unlikely(rc == -ENOSYS)) { struct physdev_op op; op.cmd = cmd; @@ -301,6 +307,8 @@ HYPERVISOR_physdev_op( rc = _hypercall1(int, physdev_op_compat, &op); memcpy(arg, &op.u, sizeof(op.u)); } +#endif + return rc; } @@ -351,9 +359,11 @@ HYPERVISOR_suspend( int rc = _hypercall3(int, sched_op, SCHEDOP_shutdown, &sched_shutdown, srec); +#ifdef CONFIG_XEN_COMPAT_030002 if (rc == -ENOSYS) rc = _hypercall3(int, sched_op_compat, SCHEDOP_shutdown, SHUTDOWN_suspend, srec); +#endif return rc; } Index: head-2006-10-16/include/asm-x86_64/mach-xen/setup_arch_post.h ==================================================================--- head-2006-10-16.orig/include/asm-x86_64/mach-xen/setup_arch_post.h +++ head-2006-10-16/include/asm-x86_64/mach-xen/setup_arch_post.h @@ -39,20 +39,24 @@ 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 (ret == -ENOSYS) ret = HYPERVISOR_set_callbacks( event.address, failsafe.address, syscall.address); +#endif BUG_ON(ret); #ifdef CONFIG_X86_LOCAL_APIC ret = HYPERVISOR_callback_op(CALLBACKOP_register, &nmi_cb); +#ifdef CONFIG_XEN_COMPAT_030002 if (ret == -ENOSYS) { struct xennmi_callback cb; cb.handler_address = nmi_cb.address; HYPERVISOR_nmi_op(XENNMI_register_callback, &cb); } +#endif #endif } _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel