[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH] linux: check hypercall return status
Not doing so is almost always a mistake, potentially resulting in debugging of problems being much more difficult. As usual, written and tested on 2.6.24-rc8 and made apply to the 2.6.18 tree without further testing. Signed-off-by: Jan Beulich <jbeulich@xxxxxxxxxx> Index: head-2008-01-21/arch/i386/kernel/cpu/mtrr/main-xen.c =================================================================== --- head-2008-01-21.orig/arch/i386/kernel/cpu/mtrr/main-xen.c 2008-01-21 13:10:43.000000000 +0100 +++ head-2008-01-21/arch/i386/kernel/cpu/mtrr/main-xen.c 2008-01-21 13:31:43.000000000 +0100 @@ -18,7 +18,8 @@ void generic_get_mtrr(unsigned int reg, op.cmd = XENPF_read_memtype; op.u.read_memtype.reg = reg; - (void)HYPERVISOR_platform_op(&op); + if (unlikely(HYPERVISOR_platform_op(&op))) + memset(&op.u.read_memtype, 0, sizeof(op.u.read_memtype)); *size = op.u.read_memtype.nr_mfns; *base = op.u.read_memtype.mfn; Index: head-2008-01-21/arch/i386/kernel/fixup.c =================================================================== --- head-2008-01-21.orig/arch/i386/kernel/fixup.c 2007-06-12 13:12:48.000000000 +0200 +++ head-2008-01-21/arch/i386/kernel/fixup.c 2008-01-21 13:31:43.000000000 +0100 @@ -46,8 +46,8 @@ fastcall void do_fixup_4gb_segment(struc if (current->tgid == 1) return; - HYPERVISOR_vm_assist( - VMASST_CMD_disable, VMASST_TYPE_4gb_segments_notify); + VOID(HYPERVISOR_vm_assist(VMASST_CMD_disable, + VMASST_TYPE_4gb_segments_notify)); if (test_and_set_bit(0, &printed)) return; @@ -81,8 +81,8 @@ fastcall void do_fixup_4gb_segment(struc static int __init fixup_init(void) { - HYPERVISOR_vm_assist( - VMASST_CMD_enable, VMASST_TYPE_4gb_segments_notify); + WARN_ON(HYPERVISOR_vm_assist(VMASST_CMD_enable, + VMASST_TYPE_4gb_segments_notify)); return 0; } __initcall(fixup_init); Index: head-2008-01-21/arch/i386/kernel/io_apic-xen.c =================================================================== --- head-2008-01-21.orig/arch/i386/kernel/io_apic-xen.c 2008-01-21 13:30:21.000000000 +0100 +++ head-2008-01-21/arch/i386/kernel/io_apic-xen.c 2008-01-21 13:31:43.000000000 +0100 @@ -154,7 +154,7 @@ static inline void io_apic_write(unsigne apic_op.apic_physbase = mp_ioapics[apic].mpc_apicaddr; apic_op.reg = reg; apic_op.value = value; - HYPERVISOR_physdev_op(PHYSDEVOP_apic_write, &apic_op); + WARN_ON(HYPERVISOR_physdev_op(PHYSDEVOP_apic_write, &apic_op)); } #define io_apic_read(a,r) xen_io_apic_read(a,r) @@ -2425,7 +2425,7 @@ static int __init io_apic_bug_finalize(v struct xen_platform_op op = { .cmd = XENPF_platform_quirk }; op.u.platform_quirk.quirk_id = sis_apic_bug ? QUIRK_IOAPIC_BAD_REGSEL : QUIRK_IOAPIC_GOOD_REGSEL; - HYPERVISOR_platform_op(&op); + VOID(HYPERVISOR_platform_op(&op)); } return 0; } Index: head-2008-01-21/arch/x86_64/kernel/io_apic-xen.c =================================================================== --- head-2008-01-21.orig/arch/x86_64/kernel/io_apic-xen.c 2008-01-21 13:30:21.000000000 +0100 +++ head-2008-01-21/arch/x86_64/kernel/io_apic-xen.c 2008-01-21 13:31:43.000000000 +0100 @@ -161,7 +161,7 @@ static inline void io_apic_write(unsigne apic_op.apic_physbase = mp_ioapics[apic].mpc_apicaddr; apic_op.reg = reg; apic_op.value = value; - HYPERVISOR_physdev_op(PHYSDEVOP_apic_write, &apic_op); + WARN_ON(HYPERVISOR_physdev_op(PHYSDEVOP_apic_write, &apic_op)); } #define io_apic_read(a,r) xen_io_apic_read(a,r) Index: head-2008-01-21/arch/i386/kernel/ioport-xen.c =================================================================== --- head-2008-01-21.orig/arch/i386/kernel/ioport-xen.c 2008-01-21 13:13:02.000000000 +0100 +++ head-2008-01-21/arch/i386/kernel/ioport-xen.c 2008-01-21 13:31:43.000000000 +0100 @@ -81,7 +81,8 @@ asmlinkage long sys_ioperm(unsigned long set_xen_guest_handle(set_iobitmap.bitmap, (char *)bitmap); set_iobitmap.nr_ports = IO_BITMAP_BITS; - HYPERVISOR_physdev_op(PHYSDEVOP_set_iobitmap, &set_iobitmap); + WARN_ON(HYPERVISOR_physdev_op(PHYSDEVOP_set_iobitmap, + &set_iobitmap)); } set_bitmap(t->io_bitmap_ptr, from, num, !turn_on); Index: head-2008-01-21/arch/x86_64/kernel/ioport-xen.c =================================================================== --- head-2008-01-21.orig/arch/x86_64/kernel/ioport-xen.c 2008-01-21 13:13:02.000000000 +0100 +++ head-2008-01-21/arch/x86_64/kernel/ioport-xen.c 2008-01-21 13:31:43.000000000 +0100 @@ -60,7 +60,8 @@ asmlinkage long sys_ioperm(unsigned long set_xen_guest_handle(set_iobitmap.bitmap, (char *)bitmap); set_iobitmap.nr_ports = IO_BITMAP_BITS; - HYPERVISOR_physdev_op(PHYSDEVOP_set_iobitmap, &set_iobitmap); + WARN_ON(HYPERVISOR_physdev_op(PHYSDEVOP_set_iobitmap, + &set_iobitmap)); } set_bitmap(t->io_bitmap_ptr, from, num, !turn_on); @@ -92,7 +93,7 @@ asmlinkage long sys_iopl(unsigned int ne /* Force the change at ring 0. */ set_iopl.iopl = (new_iopl == 0) ? 1 : new_iopl; - HYPERVISOR_physdev_op(PHYSDEVOP_set_iopl, &set_iopl); + WARN_ON(HYPERVISOR_physdev_op(PHYSDEVOP_set_iopl, &set_iopl)); return 0; } Index: head-2008-01-21/arch/i386/kernel/process-xen.c =================================================================== --- head-2008-01-21.orig/arch/i386/kernel/process-xen.c 2008-01-21 13:29:49.000000000 +0100 +++ head-2008-01-21/arch/i386/kernel/process-xen.c 2008-01-21 13:31:43.000000000 +0100 @@ -139,8 +139,7 @@ static inline void play_dead(void) idle_task_exit(); local_irq_disable(); cpu_clear(smp_processor_id(), cpu_initialized); - preempt_enable_no_resched(); - HYPERVISOR_vcpu_op(VCPUOP_down, smp_processor_id(), NULL); + xen_halt(); cpu_bringup(); } #else @@ -356,7 +355,8 @@ void exit_thread(void) struct thread_struct *t = &tsk->thread; struct physdev_set_iobitmap set_iobitmap; memset(&set_iobitmap, 0, sizeof(set_iobitmap)); - HYPERVISOR_physdev_op(PHYSDEVOP_set_iobitmap, &set_iobitmap); + WARN_ON(HYPERVISOR_physdev_op(PHYSDEVOP_set_iobitmap, + &set_iobitmap)); kfree(t->io_bitmap_ptr); t->io_bitmap_ptr = NULL; clear_thread_flag(TIF_IO_BITMAP); @@ -670,7 +670,9 @@ struct task_struct fastcall * __switch_t mcl++; } - (void)HYPERVISOR_multicall(_mcl, mcl - _mcl); + BUG_ON(mcl > _mcl + ARRAY_SIZE(_mcl)); + if (unlikely(HYPERVISOR_multicall_check(_mcl, mcl - _mcl, NULL))) + BUG(); /* * Restore %fs and %gs if needed. Index: head-2008-01-21/arch/x86_64/kernel/process-xen.c =================================================================== --- head-2008-01-21.orig/arch/x86_64/kernel/process-xen.c 2008-01-21 13:29:49.000000000 +0100 +++ head-2008-01-21/arch/x86_64/kernel/process-xen.c 2008-01-21 13:31:43.000000000 +0100 @@ -144,8 +144,7 @@ static inline void play_dead(void) idle_task_exit(); local_irq_disable(); cpu_clear(smp_processor_id(), cpu_initialized); - preempt_enable_no_resched(); - HYPERVISOR_vcpu_op(VCPUOP_down, smp_processor_id(), NULL); + xen_halt(); cpu_bringup(); } #else @@ -349,7 +348,8 @@ void exit_thread(void) put_cpu(); #endif #ifdef CONFIG_XEN - HYPERVISOR_physdev_op(PHYSDEVOP_set_iobitmap, &iobmp_op); + WARN_ON(HYPERVISOR_physdev_op(PHYSDEVOP_set_iobitmap, + &iobmp_op)); #endif t->io_bitmap_max = 0; } @@ -357,7 +357,7 @@ void exit_thread(void) void load_gs_index(unsigned gs) { - HYPERVISOR_set_segment_base(SEGBASE_GS_USER_SEL, gs); + WARN_ON(HYPERVISOR_set_segment_base(SEGBASE_GS_USER_SEL, gs)); } void flush_thread(void) @@ -608,7 +608,10 @@ __switch_to(struct task_struct *prev_p, mcl++; } - (void)HYPERVISOR_multicall(_mcl, mcl - _mcl); + BUG_ON(mcl > _mcl + ARRAY_SIZE(_mcl)); + if (unlikely(HYPERVISOR_multicall_check(_mcl, mcl - _mcl, NULL))) + BUG(); + /* * Switch DS and ES. * This won't pick up thread selector changes, but I guess that is ok. @@ -626,13 +629,13 @@ __switch_to(struct task_struct *prev_p, loadsegment(fs, next->fsindex); if (next->fs) - HYPERVISOR_set_segment_base(SEGBASE_FS, next->fs); + WARN_ON(HYPERVISOR_set_segment_base(SEGBASE_FS, next->fs)); if (unlikely(next->gsindex)) load_gs_index(next->gsindex); if (next->gs) - HYPERVISOR_set_segment_base(SEGBASE_GS_USER, next->gs); + WARN_ON(HYPERVISOR_set_segment_base(SEGBASE_GS_USER, next->gs)); /* * Switch the PDA context. Index: head-2008-01-21/arch/i386/kernel/quirks-xen.c =================================================================== --- head-2008-01-21.orig/arch/i386/kernel/quirks-xen.c 2008-01-21 13:13:02.000000000 +0100 +++ head-2008-01-21/arch/i386/kernel/quirks-xen.c 2008-01-21 13:31:43.000000000 +0100 @@ -33,7 +33,7 @@ static void __devinit quirk_intel_irqbal printk(KERN_INFO "Disabling irq balancing and affinity\n"); op.cmd = XENPF_platform_quirk; op.u.platform_quirk.quirk_id = QUIRK_NOIRQBALANCING; - (void)HYPERVISOR_platform_op(&op); + WARN_ON(HYPERVISOR_platform_op(&op)); } /* put back the original value for config space*/ Index: head-2008-01-21/arch/x86_64/kernel/setup64-xen.c =================================================================== --- head-2008-01-21.orig/arch/x86_64/kernel/setup64-xen.c 2008-01-21 13:13:02.000000000 +0100 +++ head-2008-01-21/arch/x86_64/kernel/setup64-xen.c 2008-01-21 13:31:43.000000000 +0100 @@ -176,7 +176,9 @@ void pda_init(int cpu) #ifndef CONFIG_XEN wrmsrl(MSR_GS_BASE, pda); #else - HYPERVISOR_set_segment_base(SEGBASE_GS_KERNEL, (unsigned long)pda); + if (HYPERVISOR_set_segment_base(SEGBASE_GS_KERNEL, + (unsigned long)pda)) + BUG(); #endif pda->cpunumber = cpu; pda->irqcount = -1; Index: head-2008-01-21/arch/i386/kernel/setup-xen.c =================================================================== --- head-2008-01-21.orig/arch/i386/kernel/setup-xen.c 2007-12-11 11:44:33.000000000 +0100 +++ head-2008-01-21/arch/i386/kernel/setup-xen.c 2008-01-21 13:31:43.000000000 +0100 @@ -1598,9 +1598,10 @@ void __init setup_arch(char **cmdline_p) /* Register a call for panic conditions. */ atomic_notifier_chain_register(&panic_notifier_list, &xen_panic_block); - HYPERVISOR_vm_assist(VMASST_CMD_enable, VMASST_TYPE_4gb_segments); - HYPERVISOR_vm_assist(VMASST_CMD_enable, - VMASST_TYPE_writable_pagetables); + WARN_ON(HYPERVISOR_vm_assist(VMASST_CMD_enable, + VMASST_TYPE_4gb_segments)); + WARN_ON(HYPERVISOR_vm_assist(VMASST_CMD_enable, + VMASST_TYPE_writable_pagetables)); memcpy(&boot_cpu_data, &new_cpu_data, sizeof(new_cpu_data)); early_cpu_init(); @@ -1828,7 +1829,7 @@ void __init setup_arch(char **cmdline_p) efi_map_memmap(); set_iopl.iopl = 1; - HYPERVISOR_physdev_op(PHYSDEVOP_set_iopl, &set_iopl); + WARN_ON(HYPERVISOR_physdev_op(PHYSDEVOP_set_iopl, &set_iopl)); #ifdef CONFIG_ACPI if (!is_initial_xendomain()) { Index: head-2008-01-21/arch/x86_64/kernel/setup-xen.c =================================================================== --- head-2008-01-21.orig/arch/x86_64/kernel/setup-xen.c 2007-12-11 11:44:33.000000000 +0100 +++ head-2008-01-21/arch/x86_64/kernel/setup-xen.c 2008-01-21 13:31:43.000000000 +0100 @@ -346,8 +346,8 @@ void __init setup_arch(char **cmdline_p) copy_edid(); - HYPERVISOR_vm_assist(VMASST_CMD_enable, - VMASST_TYPE_writable_pagetables); + WARN_ON(HYPERVISOR_vm_assist(VMASST_CMD_enable, + VMASST_TYPE_writable_pagetables)); ARCH_SETUP #else @@ -684,7 +684,7 @@ void __init setup_arch(char **cmdline_p) struct physdev_set_iopl set_iopl; set_iopl.iopl = 1; - HYPERVISOR_physdev_op(PHYSDEVOP_set_iopl, &set_iopl); + WARN_ON(HYPERVISOR_physdev_op(PHYSDEVOP_set_iopl, &set_iopl)); if (is_initial_xendomain()) { #ifdef CONFIG_VT Index: head-2008-01-21/arch/i386/kernel/time-xen.c =================================================================== --- head-2008-01-21.orig/arch/i386/kernel/time-xen.c 2008-01-21 13:13:02.000000000 +0100 +++ head-2008-01-21/arch/i386/kernel/time-xen.c 2008-01-21 13:31:43.000000000 +0100 @@ -504,7 +504,7 @@ static void sync_xen_wallclock(unsigned op.u.settime.secs = sec; op.u.settime.nsecs = nsec; op.u.settime.system_time = processed_system_time; - HYPERVISOR_platform_op(&op); + WARN_ON(HYPERVISOR_platform_op(&op)); update_wallclock(); @@ -914,8 +914,16 @@ void __init time_init(void) } #endif - HYPERVISOR_vcpu_op(VCPUOP_set_periodic_timer, 0, - &xen_set_periodic_tick); + switch (HYPERVISOR_vcpu_op(VCPUOP_set_periodic_timer, 0, + &xen_set_periodic_tick)) { + case 0: +#if CONFIG_XEN_COMPAT <= 0x030004 + case -ENOSYS: +#endif + break; + default: + BUG(); + } get_time_values_from_xen(0); @@ -1020,7 +1028,7 @@ EXPORT_SYMBOL(xen_safe_halt); void halt(void) { if (irqs_disabled()) - HYPERVISOR_vcpu_op(VCPUOP_down, smp_processor_id(), NULL); + VOID(HYPERVISOR_vcpu_op(VCPUOP_down, smp_processor_id(), NULL)); } EXPORT_SYMBOL(halt); @@ -1032,8 +1040,16 @@ void time_resume(void) init_cpu_khz(); for_each_online_cpu(cpu) { - HYPERVISOR_vcpu_op(VCPUOP_set_periodic_timer, cpu, - &xen_set_periodic_tick); + switch (HYPERVISOR_vcpu_op(VCPUOP_set_periodic_timer, cpu, + &xen_set_periodic_tick)) { + case 0: +#if CONFIG_XEN_COMPAT <= 0x030004 + case -ENOSYS: +#endif + break; + default: + BUG(); + } get_time_values_from_xen(cpu); per_cpu(processed_system_time, cpu) = per_cpu(shadow_time, 0).system_timestamp; @@ -1054,8 +1070,16 @@ int __cpuinit local_setup_timer(unsigned BUG_ON(cpu == 0); - HYPERVISOR_vcpu_op(VCPUOP_set_periodic_timer, cpu, - &xen_set_periodic_tick); + switch (HYPERVISOR_vcpu_op(VCPUOP_set_periodic_timer, cpu, + &xen_set_periodic_tick)) { + case 0: +#if CONFIG_XEN_COMPAT <= 0x030004 + case -ENOSYS: +#endif + break; + default: + BUG(); + } do { seq = read_seqbegin(&xtime_lock); @@ -1103,7 +1127,7 @@ static int time_cpufreq_notifier(struct op.u.change_freq.flags = 0; op.u.change_freq.cpu = freq->cpu; op.u.change_freq.freq = (u64)freq->new * 1000; - HYPERVISOR_platform_op(&op); + WARN_ON(HYPERVISOR_platform_op(&op)); return 0; } Index: head-2008-01-21/arch/i386/kernel/traps-xen.c =================================================================== --- head-2008-01-21.orig/arch/i386/kernel/traps-xen.c 2008-01-21 13:30:30.000000000 +0100 +++ head-2008-01-21/arch/i386/kernel/traps-xen.c 2008-01-21 13:31:43.000000000 +0100 @@ -1166,7 +1166,11 @@ static __cpuinitdata trap_info_t trap_ta void __init trap_init(void) { - HYPERVISOR_set_trap_table(trap_table); + int ret; + + ret = HYPERVISOR_set_trap_table(trap_table); + if (ret) + printk("HYPERVISOR_set_trap_table failed: error %d\n", ret); if (cpu_has_fxsr) { /* Index: head-2008-01-21/arch/x86_64/kernel/traps-xen.c =================================================================== --- head-2008-01-21.orig/arch/x86_64/kernel/traps-xen.c 2008-01-21 13:30:30.000000000 +0100 +++ head-2008-01-21/arch/x86_64/kernel/traps-xen.c 2008-01-21 13:31:43.000000000 +0100 @@ -1193,10 +1193,8 @@ void __init trap_init(void) int ret; ret = HYPERVISOR_set_trap_table(trap_table); - if (ret) - printk("HYPERVISOR_set_trap_table faild: error %d\n", - ret); + printk("HYPERVISOR_set_trap_table failed: error %d\n", ret); /* * Should be a barrier for any external CPU state. Index: head-2008-01-21/arch/x86_64/mm/init-xen.c =================================================================== --- head-2008-01-21.orig/arch/x86_64/mm/init-xen.c 2008-01-21 13:30:30.000000000 +0100 +++ head-2008-01-21/arch/x86_64/mm/init-xen.c 2008-01-21 13:31:43.000000000 +0100 @@ -641,7 +641,8 @@ static void __init extend_init_mapping(u /* Kill mapping of low 1MB. */ while (va < (unsigned long)&_text) { - HYPERVISOR_update_va_mapping(va, __pte_ma(0), 0); + if (HYPERVISOR_update_va_mapping(va, __pte_ma(0), 0)) + BUG(); va += PAGE_SIZE; } @@ -674,7 +675,8 @@ static void __init extend_init_mapping(u pmd = (pmd_t *)&page[pmd_index(va)]; if (pmd_none(*pmd)) break; - HYPERVISOR_update_va_mapping(va, __pte_ma(0), 0); + if (HYPERVISOR_update_va_mapping(va, __pte_ma(0), 0)) + BUG(); va += PAGE_SIZE; } } @@ -727,8 +729,8 @@ static void __init xen_finish_init_mappi start = PAGE_ALIGN((unsigned long)_end); end = __START_KERNEL_map + (table_end << PAGE_SHIFT); for (; start < end; start += PAGE_SIZE) - WARN_ON(HYPERVISOR_update_va_mapping( - start, __pte_ma(0), 0)); + if (HYPERVISOR_update_va_mapping(start, __pte_ma(0), 0)) + BUG(); /* Allocate pte's for initial fixmaps from 'start_pfn' allocator. */ table_end = ~0UL; Index: head-2008-01-21/arch/i386/oprofile/xenoprof.c =================================================================== --- head-2008-01-21.orig/arch/i386/oprofile/xenoprof.c 2007-06-12 13:12:49.000000000 +0200 +++ head-2008-01-21/arch/i386/oprofile/xenoprof.c 2008-01-21 13:31:43.000000000 +0100 @@ -52,8 +52,8 @@ void xenoprof_arch_counter(void) counter.kernel = (uint32_t)counter_config[i].kernel; counter.user = (uint32_t)counter_config[i].user; counter.unit_mask = (uint64_t)counter_config[i].unit_mask; - HYPERVISOR_xenoprof_op(XENOPROF_counter, - &counter); + WARN_ON(HYPERVISOR_xenoprof_op(XENOPROF_counter, + &counter)); } } Index: head-2008-01-21/drivers/xen/core/evtchn.c =================================================================== --- head-2008-01-21.orig/drivers/xen/core/evtchn.c 2008-01-21 13:10:16.000000000 +0100 +++ head-2008-01-21/drivers/xen/core/evtchn.c 2008-01-21 13:31:43.000000000 +0100 @@ -215,7 +215,7 @@ static inline void exit_idle(void) {} */ void force_evtchn_callback(void) { - (void)HYPERVISOR_xen_version(0, NULL); + VOID(HYPERVISOR_xen_version(0, NULL)); } /* Not a GPL symbol: used in ubiquitous macros, so too restrictive. */ EXPORT_SYMBOL(force_evtchn_callback); @@ -741,14 +741,15 @@ static inline void pirq_unmask_notify(in { struct physdev_eoi eoi = { .irq = pirq }; if (unlikely(test_bit(pirq, pirq_needs_eoi))) - (void)HYPERVISOR_physdev_op(PHYSDEVOP_eoi, &eoi); + VOID(HYPERVISOR_physdev_op(PHYSDEVOP_eoi, &eoi)); } static inline void pirq_query_unmask(int pirq) { struct physdev_irq_status_query irq_status; irq_status.irq = pirq; - (void)HYPERVISOR_physdev_op(PHYSDEVOP_irq_status_query, &irq_status); + if (HYPERVISOR_physdev_op(PHYSDEVOP_irq_status_query, &irq_status)) + irq_status.flags = 0; clear_bit(pirq, pirq_needs_eoi); if (irq_status.flags & XENIRQSTAT_needs_eoi) set_bit(pirq, pirq_needs_eoi); @@ -868,7 +869,8 @@ int irq_ignore_unhandled(unsigned int ir if (!is_running_on_xen()) return 0; - (void)HYPERVISOR_physdev_op(PHYSDEVOP_irq_status_query, &irq_status); + if (HYPERVISOR_physdev_op(PHYSDEVOP_irq_status_query, &irq_status)) + return 0; return !!(irq_status.flags & XENIRQSTAT_shared); } @@ -905,7 +907,7 @@ void unmask_evtchn(int port) /* Slow path (hypercall) if this is a non-local port. */ if (unlikely(cpu != cpu_from_evtchn(port))) { struct evtchn_unmask unmask = { .port = port }; - (void)HYPERVISOR_event_channel_op(EVTCHNOP_unmask, &unmask); + VOID(HYPERVISOR_event_channel_op(EVTCHNOP_unmask, &unmask)); return; } Index: head-2008-01-21/drivers/xen/core/machine_kexec.c =================================================================== --- head-2008-01-21.orig/drivers/xen/core/machine_kexec.c 2008-01-21 13:13:02.000000000 +0100 +++ head-2008-01-21/drivers/xen/core/machine_kexec.c 2008-01-21 13:31:43.000000000 +0100 @@ -155,7 +155,7 @@ void xen_machine_kexec_unload(struct kim memset(&xkl, 0, sizeof(xkl)); xkl.type = image->type; - HYPERVISOR_kexec_op(KEXEC_CMD_kexec_unload, &xkl); + WARN_ON(HYPERVISOR_kexec_op(KEXEC_CMD_kexec_unload, &xkl)); } /* @@ -172,7 +172,7 @@ NORET_TYPE void machine_kexec(struct kim memset(&xke, 0, sizeof(xke)); xke.type = image->type; - HYPERVISOR_kexec_op(KEXEC_CMD_kexec, &xke); + VOID(HYPERVISOR_kexec_op(KEXEC_CMD_kexec, &xke)); panic("KEXEC_CMD_kexec hypercall should not return\n"); } Index: head-2008-01-21/drivers/xen/core/machine_reboot.c =================================================================== --- head-2008-01-21.orig/drivers/xen/core/machine_reboot.c 2007-12-18 11:39:35.000000000 +0100 +++ head-2008-01-21/drivers/xen/core/machine_reboot.c 2008-01-21 13:31:43.000000000 +0100 @@ -61,8 +61,8 @@ EXPORT_SYMBOL(machine_power_off); static void pre_suspend(void) { HYPERVISOR_shared_info = (shared_info_t *)empty_zero_page; - HYPERVISOR_update_va_mapping(fix_to_virt(FIX_SHARED_INFO), - __pte_ma(0), 0); + WARN_ON(HYPERVISOR_update_va_mapping(fix_to_virt(FIX_SHARED_INFO), + __pte_ma(0), 0)); xen_start_info->store_mfn = mfn_to_pfn(xen_start_info->store_mfn); xen_start_info->console.domU.mfn = @@ -89,8 +89,10 @@ static void post_suspend(int suspend_can } shinfo_mfn = xen_start_info->shared_info >> PAGE_SHIFT; - HYPERVISOR_update_va_mapping(fix_to_virt(FIX_SHARED_INFO), - pfn_pte_ma(shinfo_mfn, PAGE_KERNEL), 0); + if (HYPERVISOR_update_va_mapping(fix_to_virt(FIX_SHARED_INFO), + pfn_pte_ma(shinfo_mfn, PAGE_KERNEL), + 0)) + BUG(); HYPERVISOR_shared_info = (shared_info_t *)fix_to_virt(FIX_SHARED_INFO); memset(empty_zero_page, 0, PAGE_SIZE); Index: head-2008-01-21/drivers/xen/netback/netback.c =================================================================== --- head-2008-01-21.orig/drivers/xen/netback/netback.c 2008-01-21 13:13:02.000000000 +0100 +++ head-2008-01-21/drivers/xen/netback/netback.c 2008-01-21 13:31:43.000000000 +0100 @@ -142,14 +142,16 @@ static int check_mfn(int nr) .extent_order = 0, .domid = DOMID_SELF }; + int rc; if (likely(alloc_index >= nr)) return 0; set_xen_guest_handle(reservation.extent_start, mfn_list + alloc_index); reservation.nr_extents = MAX_MFN_ALLOC - alloc_index; - alloc_index += HYPERVISOR_memory_op(XENMEM_increase_reservation, - &reservation); + rc = HYPERVISOR_memory_op(XENMEM_increase_reservation, &reservation); + if (likely(rc > 0)) + alloc_index += rc; return alloc_index >= nr ? 0 : -ENOMEM; } @@ -349,7 +351,7 @@ int xen_network_done(void) struct netrx_pending_operations { unsigned trans_prod, trans_cons; - unsigned mmu_prod, mmu_cons; + unsigned mmu_prod, mmu_mcl; unsigned mcl_prod, mcl_cons; unsigned copy_prod, copy_cons; unsigned meta_prod, meta_cons; @@ -605,8 +607,12 @@ static void net_rx_action(unsigned long break; } - if (npo.mcl_prod && - !xen_feature(XENFEAT_auto_translated_physmap)) { + BUG_ON(npo.meta_prod > ARRAY_SIZE(meta)); + + npo.mmu_mcl = npo.mcl_prod; + if (npo.mcl_prod) { + BUG_ON(!xen_feature(XENFEAT_auto_translated_physmap)); + BUG_ON(npo.mmu_prod > ARRAY_SIZE(rx_mmu)); mcl = npo.mcl + npo.mcl_prod++; BUG_ON(mcl[-1].op != __HYPERVISOR_update_va_mapping); @@ -620,6 +626,7 @@ static void net_rx_action(unsigned long } if (npo.trans_prod) { + BUG_ON(npo.trans_prod > ARRAY_SIZE(grant_trans_op)); mcl = npo.mcl + npo.mcl_prod++; mcl->op = __HYPERVISOR_grant_table_op; mcl->args[0] = GNTTABOP_transfer; @@ -628,6 +635,7 @@ static void net_rx_action(unsigned long } if (npo.copy_prod) { + BUG_ON(npo.copy_prod > ARRAY_SIZE(grant_copy_op)); mcl = npo.mcl + npo.mcl_prod++; mcl->op = __HYPERVISOR_grant_table_op; mcl->args[0] = GNTTABOP_copy; @@ -639,14 +647,12 @@ static void net_rx_action(unsigned long if (!npo.mcl_prod) return; - BUG_ON(npo.copy_prod > NET_RX_RING_SIZE); - BUG_ON(npo.mmu_prod > NET_RX_RING_SIZE); - BUG_ON(npo.trans_prod > NET_RX_RING_SIZE); - BUG_ON(npo.mcl_prod > NET_RX_RING_SIZE+3); - BUG_ON(npo.meta_prod > NET_RX_RING_SIZE); + BUG_ON(npo.mcl_prod > ARRAY_SIZE(rx_mcl)); ret = HYPERVISOR_multicall(npo.mcl, npo.mcl_prod); BUG_ON(ret != 0); + /* The mmu_machphys_update() must not fail. */ + BUG_ON(npo.mmu_mcl && npo.mcl[npo.mmu_mcl].result != 0); while ((skb = __skb_dequeue(&rxq)) != NULL) { nr_frags = *(int *)skb->cb; Index: head-2008-01-21/drivers/xen/netfront/netfront.c =================================================================== --- head-2008-01-21.orig/drivers/xen/netfront/netfront.c 2008-01-21 13:13:02.000000000 +0100 +++ head-2008-01-21/drivers/xen/netfront/netfront.c 2008-01-21 13:31:43.000000000 +0100 @@ -840,11 +840,14 @@ no_skb: /* Zap PTEs and give away pages in one big * multicall. */ - (void)HYPERVISOR_multicall(np->rx_mcl, i+1); + if (unlikely(HYPERVISOR_multicall(np->rx_mcl, i+1))) + BUG(); /* Check return status of HYPERVISOR_memory_op(). */ if (unlikely(np->rx_mcl[i].result != i)) panic("Unable to reduce memory reservation\n"); + while (i--) + BUG_ON(np->rx_mcl[i].result); } else { if (HYPERVISOR_memory_op(XENMEM_decrease_reservation, &reservation) != i) @@ -1446,8 +1449,10 @@ err: mcl->args[1] = pages_flipped; mcl->args[2] = 0; mcl->args[3] = DOMID_SELF; - (void)HYPERVISOR_multicall(np->rx_mcl, - pages_flipped + 1); + err = HYPERVISOR_multicall_check(np->rx_mcl, + pages_flipped + 1, + NULL); + BUG_ON(err); } } Index: head-2008-01-21/drivers/xen/xenoprof/xenoprofile.c =================================================================== --- head-2008-01-21.orig/drivers/xen/xenoprof/xenoprofile.c 2008-01-21 13:10:27.000000000 +0100 +++ head-2008-01-21/drivers/xen/xenoprof/xenoprofile.c 2008-01-21 13:31:43.000000000 +0100 @@ -346,10 +346,11 @@ static void xenoprof_shutdown(void) { xenoprof_enabled = 0; - HYPERVISOR_xenoprof_op(XENOPROF_disable_virq, NULL); + WARN_ON(HYPERVISOR_xenoprof_op(XENOPROF_disable_virq, NULL)); if (xenoprof_is_primary) { - HYPERVISOR_xenoprof_op(XENOPROF_release_counters, NULL); + WARN_ON(HYPERVISOR_xenoprof_op(XENOPROF_release_counters, + NULL)); active_defined = 0; } @@ -376,7 +377,7 @@ static int xenoprof_start(void) static void xenoprof_stop(void) { if (xenoprof_is_primary) - HYPERVISOR_xenoprof_op(XENOPROF_stop, NULL); + WARN_ON(HYPERVISOR_xenoprof_op(XENOPROF_stop, NULL)); xenoprof_arch_stop(); } @@ -419,7 +420,8 @@ static int xenoprof_set_active(int * act out: if (ret) - HYPERVISOR_xenoprof_op(XENOPROF_reset_active_list, NULL); + WARN_ON(HYPERVISOR_xenoprof_op(XENOPROF_reset_active_list, + NULL)); active_defined = !ret; return ret; } @@ -539,6 +541,6 @@ void xenoprofile_exit(void) xenoprof_arch_unmap_shared_buffer(&shared_buffer); if (xenoprof_is_primary) { unmap_passive_list(); - HYPERVISOR_xenoprof_op(XENOPROF_shutdown, NULL); + WARN_ON(HYPERVISOR_xenoprof_op(XENOPROF_shutdown, NULL)); } } Index: head-2008-01-21/include/asm-i386/mach-xen/asm/desc.h =================================================================== --- head-2008-01-21.orig/include/asm-i386/mach-xen/asm/desc.h 2008-01-21 13:10:27.000000000 +0100 +++ head-2008-01-21/include/asm-i386/mach-xen/asm/desc.h 2008-01-21 13:31:43.000000000 +0100 @@ -100,7 +100,9 @@ extern int write_ldt_entry(void *ldt, static inline void load_TLS(struct thread_struct *t, unsigned int cpu) { -#define C(i) HYPERVISOR_update_descriptor(virt_to_machine(&get_cpu_gdt_table(cpu)[GDT_ENTRY_TLS_MIN + i]), *(u64 *)&t->tls_array[i]) +#define C(i) if (HYPERVISOR_update_descriptor(virt_to_machine(&get_cpu_gdt_table(cpu)[GDT_ENTRY_TLS_MIN + i]), \ + *(u64 *)&t->tls_array[i])) \ + BUG(); C(0); C(1); C(2); #undef C } Index: head-2008-01-21/include/asm-x86_64/mach-xen/asm/desc.h =================================================================== --- head-2008-01-21.orig/include/asm-x86_64/mach-xen/asm/desc.h 2008-01-21 13:13:02.000000000 +0100 +++ head-2008-01-21/include/asm-x86_64/mach-xen/asm/desc.h 2008-01-21 13:31:43.000000000 +0100 @@ -220,7 +220,9 @@ static inline void load_TLS(struct threa gdt[2] = t->tls_array[2]; #endif #define C(i) \ - HYPERVISOR_update_descriptor(virt_to_machine(&cpu_gdt(cpu)[GDT_ENTRY_TLS_MIN + i]), t->tls_array[i]) + if (HYPERVISOR_update_descriptor(virt_to_machine(&cpu_gdt(cpu)[GDT_ENTRY_TLS_MIN + i]), \ + t->tls_array[i])) \ + BUG(); C(0); C(1); C(2); #undef C Index: head-2008-01-21/include/asm-i386/mach-xen/asm/hypercall.h =================================================================== --- head-2008-01-21.orig/include/asm-i386/mach-xen/asm/hypercall.h 2008-01-21 11:15:26.000000000 +0100 +++ head-2008-01-21/include/asm-i386/mach-xen/asm/hypercall.h 2008-01-21 13:31:43.000000000 +0100 @@ -123,14 +123,14 @@ (type)__res; \ }) -static inline int +static inline int __must_check HYPERVISOR_set_trap_table( const trap_info_t *table) { return _hypercall1(int, set_trap_table, table); } -static inline int +static inline int __must_check HYPERVISOR_mmu_update( mmu_update_t *req, unsigned int count, unsigned int *success_count, domid_t domid) @@ -138,7 +138,7 @@ HYPERVISOR_mmu_update( return _hypercall4(int, mmu_update, req, count, success_count, domid); } -static inline int +static inline int __must_check HYPERVISOR_mmuext_op( struct mmuext_op *op, unsigned int count, unsigned int *success_count, domid_t domid) @@ -146,21 +146,21 @@ HYPERVISOR_mmuext_op( return _hypercall4(int, mmuext_op, op, count, success_count, domid); } -static inline int +static inline int __must_check HYPERVISOR_set_gdt( unsigned long *frame_list, unsigned int entries) { return _hypercall2(int, set_gdt, frame_list, entries); } -static inline int +static inline int __must_check HYPERVISOR_stack_switch( unsigned long ss, unsigned long esp) { return _hypercall2(int, stack_switch, ss, esp); } -static inline int +static inline int __must_check HYPERVISOR_set_callbacks( unsigned long event_selector, unsigned long event_address, unsigned long failsafe_selector, unsigned long failsafe_address) @@ -177,21 +177,21 @@ HYPERVISOR_fpu_taskswitch( return _hypercall1(int, fpu_taskswitch, set); } -static inline int +static inline int __must_check HYPERVISOR_sched_op_compat( int cmd, unsigned long arg) { return _hypercall2(int, sched_op_compat, cmd, arg); } -static inline int +static inline int __must_check HYPERVISOR_sched_op( int cmd, void *arg) { return _hypercall2(int, sched_op, cmd, arg); } -static inline long +static inline long __must_check HYPERVISOR_set_timer_op( u64 timeout) { @@ -200,7 +200,7 @@ HYPERVISOR_set_timer_op( return _hypercall2(long, set_timer_op, timeout_lo, timeout_hi); } -static inline int +static inline int __must_check HYPERVISOR_platform_op( struct xen_platform_op *platform_op) { @@ -208,42 +208,42 @@ HYPERVISOR_platform_op( return _hypercall1(int, platform_op, platform_op); } -static inline int +static inline int __must_check HYPERVISOR_set_debugreg( unsigned int reg, unsigned long value) { return _hypercall2(int, set_debugreg, reg, value); } -static inline unsigned long +static inline unsigned long __must_check HYPERVISOR_get_debugreg( unsigned int reg) { return _hypercall1(unsigned long, get_debugreg, reg); } -static inline int +static inline int __must_check HYPERVISOR_update_descriptor( u64 ma, u64 desc) { return _hypercall4(int, update_descriptor, ma, ma>>32, desc, desc>>32); } -static inline int +static inline int __must_check HYPERVISOR_memory_op( unsigned int cmd, void *arg) { return _hypercall2(int, memory_op, cmd, arg); } -static inline int +static inline int __must_check HYPERVISOR_multicall( multicall_entry_t *call_list, unsigned int nr_calls) { return _hypercall2(int, multicall, call_list, nr_calls); } -static inline int +static inline int __must_check HYPERVISOR_update_va_mapping( unsigned long va, pte_t new_val, unsigned long flags) { @@ -255,7 +255,7 @@ HYPERVISOR_update_va_mapping( new_val.pte_low, pte_hi, flags); } -static inline int +static inline int __must_check HYPERVISOR_event_channel_op( int cmd, void *arg) { @@ -274,28 +274,28 @@ HYPERVISOR_event_channel_op( return rc; } -static inline int +static inline int __must_check HYPERVISOR_acm_op( int cmd, void *arg) { return _hypercall2(int, acm_op, cmd, arg); } -static inline int +static inline int __must_check HYPERVISOR_xen_version( int cmd, void *arg) { return _hypercall2(int, xen_version, cmd, arg); } -static inline int +static inline int __must_check HYPERVISOR_console_io( int cmd, unsigned int count, char *str) { return _hypercall3(int, console_io, cmd, count, str); } -static inline int +static inline int __must_check HYPERVISOR_physdev_op( int cmd, void *arg) { @@ -314,14 +314,14 @@ HYPERVISOR_physdev_op( return rc; } -static inline int +static inline int __must_check HYPERVISOR_grant_table_op( unsigned int cmd, void *uop, unsigned int count) { return _hypercall3(int, grant_table_op, cmd, uop, count); } -static inline int +static inline int __must_check HYPERVISOR_update_va_mapping_otherdomain( unsigned long va, pte_t new_val, unsigned long flags, domid_t domid) { @@ -333,21 +333,21 @@ HYPERVISOR_update_va_mapping_otherdomain new_val.pte_low, pte_hi, flags, domid); } -static inline int +static inline int __must_check HYPERVISOR_vm_assist( unsigned int cmd, unsigned int type) { return _hypercall2(int, vm_assist, cmd, type); } -static inline int +static inline int __must_check HYPERVISOR_vcpu_op( int cmd, unsigned int vcpuid, void *extra_args) { return _hypercall3(int, vcpu_op, cmd, vcpuid, extra_args); } -static inline int +static inline int __must_check HYPERVISOR_suspend( unsigned long srec) { @@ -367,15 +367,17 @@ HYPERVISOR_suspend( return rc; } +#if CONFIG_XEN_COMPAT <= 0x030002 static inline int HYPERVISOR_nmi_op( unsigned long op, void *arg) { return _hypercall2(int, nmi_op, op, arg); } +#endif #ifndef CONFIG_XEN -static inline unsigned long +static inline unsigned long __must_check HYPERVISOR_hvm_op( int op, void *arg) { @@ -383,21 +385,21 @@ HYPERVISOR_hvm_op( } #endif -static inline int +static inline int __must_check HYPERVISOR_callback_op( int cmd, const void *arg) { return _hypercall2(int, callback_op, cmd, arg); } -static inline int +static inline int __must_check HYPERVISOR_xenoprof_op( int op, void *arg) { return _hypercall2(int, xenoprof_op, op, arg); } -static inline int +static inline int __must_check HYPERVISOR_kexec_op( unsigned long op, void *args) { Index: head-2008-01-21/include/asm-x86_64/mach-xen/asm/hypercall.h =================================================================== --- head-2008-01-21.orig/include/asm-x86_64/mach-xen/asm/hypercall.h 2008-01-21 11:15:27.000000000 +0100 +++ head-2008-01-21/include/asm-x86_64/mach-xen/asm/hypercall.h 2008-01-21 13:31:43.000000000 +0100 @@ -129,14 +129,14 @@ (type)__res; \ }) -static inline int +static inline int __must_check HYPERVISOR_set_trap_table( const trap_info_t *table) { return _hypercall1(int, set_trap_table, table); } -static inline int +static inline int __must_check HYPERVISOR_mmu_update( mmu_update_t *req, unsigned int count, unsigned int *success_count, domid_t domid) @@ -144,7 +144,7 @@ HYPERVISOR_mmu_update( return _hypercall4(int, mmu_update, req, count, success_count, domid); } -static inline int +static inline int __must_check HYPERVISOR_mmuext_op( struct mmuext_op *op, unsigned int count, unsigned int *success_count, domid_t domid) @@ -152,21 +152,21 @@ HYPERVISOR_mmuext_op( return _hypercall4(int, mmuext_op, op, count, success_count, domid); } -static inline int +static inline int __must_check HYPERVISOR_set_gdt( unsigned long *frame_list, unsigned int entries) { return _hypercall2(int, set_gdt, frame_list, entries); } -static inline int +static inline int __must_check HYPERVISOR_stack_switch( unsigned long ss, unsigned long esp) { return _hypercall2(int, stack_switch, ss, esp); } -static inline int +static inline int __must_check HYPERVISOR_set_callbacks( unsigned long event_address, unsigned long failsafe_address, unsigned long syscall_address) @@ -182,28 +182,28 @@ HYPERVISOR_fpu_taskswitch( return _hypercall1(int, fpu_taskswitch, set); } -static inline int +static inline int __must_check HYPERVISOR_sched_op_compat( int cmd, unsigned long arg) { return _hypercall2(int, sched_op_compat, cmd, arg); } -static inline int +static inline int __must_check HYPERVISOR_sched_op( int cmd, void *arg) { return _hypercall2(int, sched_op, cmd, arg); } -static inline long +static inline long __must_check HYPERVISOR_set_timer_op( u64 timeout) { return _hypercall1(long, set_timer_op, timeout); } -static inline int +static inline int __must_check HYPERVISOR_platform_op( struct xen_platform_op *platform_op) { @@ -211,49 +211,49 @@ HYPERVISOR_platform_op( return _hypercall1(int, platform_op, platform_op); } -static inline int +static inline int __must_check HYPERVISOR_set_debugreg( unsigned int reg, unsigned long value) { return _hypercall2(int, set_debugreg, reg, value); } -static inline unsigned long +static inline unsigned long __must_check HYPERVISOR_get_debugreg( unsigned int reg) { return _hypercall1(unsigned long, get_debugreg, reg); } -static inline int +static inline int __must_check HYPERVISOR_update_descriptor( unsigned long ma, unsigned long word) { return _hypercall2(int, update_descriptor, ma, word); } -static inline int +static inline int __must_check HYPERVISOR_memory_op( unsigned int cmd, void *arg) { return _hypercall2(int, memory_op, cmd, arg); } -static inline int +static inline int __must_check HYPERVISOR_multicall( multicall_entry_t *call_list, unsigned int nr_calls) { return _hypercall2(int, multicall, call_list, nr_calls); } -static inline int +static inline int __must_check HYPERVISOR_update_va_mapping( unsigned long va, pte_t new_val, unsigned long flags) { return _hypercall3(int, update_va_mapping, va, new_val.pte, flags); } -static inline int +static inline int __must_check HYPERVISOR_event_channel_op( int cmd, void *arg) { @@ -272,28 +272,28 @@ HYPERVISOR_event_channel_op( return rc; } -static inline int +static inline int __must_check HYPERVISOR_acm_op( int cmd, void *arg) { return _hypercall2(int, acm_op, cmd, arg); } -static inline int +static inline int __must_check HYPERVISOR_xen_version( int cmd, void *arg) { return _hypercall2(int, xen_version, cmd, arg); } -static inline int +static inline int __must_check HYPERVISOR_console_io( int cmd, unsigned int count, char *str) { return _hypercall3(int, console_io, cmd, count, str); } -static inline int +static inline int __must_check HYPERVISOR_physdev_op( int cmd, void *arg) { @@ -312,14 +312,14 @@ HYPERVISOR_physdev_op( return rc; } -static inline int +static inline int __must_check HYPERVISOR_grant_table_op( unsigned int cmd, void *uop, unsigned int count) { return _hypercall3(int, grant_table_op, cmd, uop, count); } -static inline int +static inline int __must_check HYPERVISOR_update_va_mapping_otherdomain( unsigned long va, pte_t new_val, unsigned long flags, domid_t domid) { @@ -327,28 +327,28 @@ HYPERVISOR_update_va_mapping_otherdomain new_val.pte, flags, domid); } -static inline int +static inline int __must_check HYPERVISOR_vm_assist( unsigned int cmd, unsigned int type) { return _hypercall2(int, vm_assist, cmd, type); } -static inline int +static inline int __must_check HYPERVISOR_vcpu_op( int cmd, unsigned int vcpuid, void *extra_args) { return _hypercall3(int, vcpu_op, cmd, vcpuid, extra_args); } -static inline int +static inline int __must_check HYPERVISOR_set_segment_base( int reg, unsigned long value) { return _hypercall2(int, set_segment_base, reg, value); } -static inline int +static inline int __must_check HYPERVISOR_suspend( unsigned long srec) { @@ -368,15 +368,17 @@ HYPERVISOR_suspend( return rc; } +#if CONFIG_XEN_COMPAT <= 0x030002 static inline int HYPERVISOR_nmi_op( unsigned long op, void *arg) { return _hypercall2(int, nmi_op, op, arg); } +#endif #ifndef CONFIG_XEN -static inline unsigned long +static inline unsigned long __must_check HYPERVISOR_hvm_op( int op, void *arg) { @@ -384,21 +386,21 @@ HYPERVISOR_hvm_op( } #endif -static inline int +static inline int __must_check HYPERVISOR_callback_op( int cmd, const void *arg) { return _hypercall2(int, callback_op, cmd, arg); } -static inline int +static inline int __must_check HYPERVISOR_xenoprof_op( int op, void *arg) { return _hypercall2(int, xenoprof_op, op, arg); } -static inline int +static inline int __must_check HYPERVISOR_kexec_op( unsigned long op, void *args) { Index: head-2008-01-21/include/asm-i386/mach-xen/asm/hypervisor.h =================================================================== --- head-2008-01-21.orig/include/asm-i386/mach-xen/asm/hypervisor.h 2008-01-21 13:07:09.000000000 +0100 +++ head-2008-01-21/include/asm-i386/mach-xen/asm/hypervisor.h 2008-01-21 13:31:43.000000000 +0100 @@ -166,7 +166,7 @@ HYPERVISOR_block( return rc; } -static inline int +static inline void __noreturn HYPERVISOR_shutdown( unsigned int reason) { @@ -174,17 +174,16 @@ HYPERVISOR_shutdown( .reason = reason }; - int rc = HYPERVISOR_sched_op(SCHEDOP_shutdown, &sched_shutdown); - + VOID(HYPERVISOR_sched_op(SCHEDOP_shutdown, &sched_shutdown)); #if CONFIG_XEN_COMPAT <= 0x030002 - if (rc == -ENOSYS) - rc = HYPERVISOR_sched_op_compat(SCHEDOP_shutdown, reason); + VOID(HYPERVISOR_sched_op_compat(SCHEDOP_shutdown, reason)); #endif - - return rc; + /* Don't recurse needlessly. */ + BUG_ON(reason != SHUTDOWN_crash); + for(;;); } -static inline int +static inline int __must_check HYPERVISOR_poll( evtchn_port_t *ports, unsigned int nr_ports, u64 timeout) { Index: head-2008-01-21/include/asm-i386/mach-xen/asm/processor.h =================================================================== --- head-2008-01-21.orig/include/asm-i386/mach-xen/asm/processor.h 2008-01-21 13:13:02.000000000 +0100 +++ head-2008-01-21/include/asm-i386/mach-xen/asm/processor.h 2008-01-21 13:31:43.000000000 +0100 @@ -516,8 +516,10 @@ static inline void __load_esp0(struct t #define load_esp0(tss, thread) \ __load_esp0(tss, thread) #else -#define load_esp0(tss, thread) \ - HYPERVISOR_stack_switch(__KERNEL_DS, (thread)->esp0) +#define load_esp0(tss, thread) do { \ + if (HYPERVISOR_stack_switch(__KERNEL_DS, (thread)->esp0)) \ + BUG(); \ +} while (0) #endif #define start_thread(regs, new_eip, new_esp) do { \ @@ -528,7 +530,7 @@ static inline void __load_esp0(struct t #define get_debugreg(var, register) \ (var) = HYPERVISOR_get_debugreg((register)) #define set_debugreg(value, register) \ - HYPERVISOR_set_debugreg((register), (value)) + WARN_ON(HYPERVISOR_set_debugreg((register), (value))) /* * Set IOPL bits in EFLAGS from given mask @@ -540,7 +542,7 @@ static inline void set_iopl_mask(uns /* Force the change at ring 0. */ set_iopl.iopl = (mask == 0) ? 1 : (mask >> 12) & 3; - HYPERVISOR_physdev_op(PHYSDEVOP_set_iopl, &set_iopl); + WARN_ON(HYPERVISOR_physdev_op(PHYSDEVOP_set_iopl, &set_iopl)); } /* Forward declaration, a strange C thing */ Index: head-2008-01-21/include/asm-x86_64/mach-xen/asm/processor.h =================================================================== --- head-2008-01-21.orig/include/asm-x86_64/mach-xen/asm/processor.h 2008-01-21 13:13:02.000000000 +0100 +++ head-2008-01-21/include/asm-x86_64/mach-xen/asm/processor.h 2008-01-21 13:31:43.000000000 +0100 @@ -284,8 +284,10 @@ struct thread_struct { #define get_debugreg(var, register) \ var = HYPERVISOR_get_debugreg(register) -#define set_debugreg(value, register) \ - HYPERVISOR_set_debugreg(register, value) +#define set_debugreg(value, register) do { \ + if (HYPERVISOR_set_debugreg(register, value)) \ + BUG(); \ +} while (0) struct task_struct; struct mm_struct; Index: head-2008-01-21/include/xen/evtchn.h =================================================================== --- head-2008-01-21.orig/include/xen/evtchn.h 2008-01-21 13:01:17.000000000 +0100 +++ head-2008-01-21/include/xen/evtchn.h 2008-01-21 13:31:43.000000000 +0100 @@ -126,7 +126,7 @@ static inline void clear_evtchn(int port static inline void notify_remote_via_evtchn(int port) { struct evtchn_send send = { .port = port }; - (void)HYPERVISOR_event_channel_op(EVTCHNOP_send, &send); + VOID(HYPERVISOR_event_channel_op(EVTCHNOP_send, &send)); } /* Index: head-2008-01-21/include/xen/hypercall.h =================================================================== --- head-2008-01-21.orig/include/xen/hypercall.h 2008-01-21 11:15:27.000000000 +0100 +++ head-2008-01-21/include/xen/hypercall.h 2008-01-21 13:31:43.000000000 +0100 @@ -3,7 +3,7 @@ #include <asm/hypercall.h> -static inline int +static inline int __must_check HYPERVISOR_multicall_check( multicall_entry_t *call_list, unsigned int nr_calls, const unsigned long *rc_list) @@ -22,4 +22,9 @@ HYPERVISOR_multicall_check( return 0; } +/* A construct to ignore the return value of hypercall wrappers in a few + * exceptional cases (simply casting the function result to void doesn't + * avoid the compiler warning): */ +#define VOID(expr) ((void)((expr)?:0)) + #endif /* __XEN_HYPERCALL_H__ */ _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |