linux: check hypercall return status
PATCH 1/1 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 <[email protected]>
arch/i386/kernel/cpu/mtrr/main-xen.c +2 -1
@@ -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;
arch/i386/kernel/fixup.c +4 -4
@@ -46,8 +46,8 @@ fastcall void do_fixup_4gb_segment(strucif (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(strucstatic 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);
arch/i386/kernel/io_apic-xen.c +2 -2
@@ -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(vstruct 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 ; }
arch/x86_64/kernel/io_apic-xen.c +1 -1
@@ -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)
arch/i386/kernel/ioport-xen.c +2 -1
@@ -81,7 +81,8 @@ asmlinkage long sys_ioperm(unsigned longset_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);
arch/x86_64/kernel/ioport-xen.c +3 -2
@@ -60,7 +60,8 @@ asmlinkage long sys_ioperm(unsigned longset_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 ; }
arch/i386/kernel/process-xen.c +6 -4
@@ -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.
arch/x86_64/kernel/process-xen.c +10 -7
@@ -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.
arch/i386/kernel/quirks-xen.c +1 -1
@@ -33,7 +33,7 @@ static void __devinit quirk_intel_irqbalprintk (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*/
arch/x86_64/kernel/setup64-xen.c +3 -1
@@ -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 ;
arch/i386/kernel/setup-xen.c +5 -4
@@ -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 ()) {
arch/x86_64/kernel/setup-xen.c +3 -3
@@ -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
arch/i386/kernel/time-xen.c +33 -9
78 lines not on this page · raw message
arch/i386/kernel/traps-xen.c +5 -1
@@ -1166,7 +1166,11 @@ static __cpuinitdata trap_info_t trap_tavoid __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) {/*
arch/x86_64/kernel/traps-xen.c +1 -3
@@ -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.
arch/x86_64/mm/init-xen.c +6 -4
@@ -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 ;
arch/i386/oprofile/xenoprof.c +2 -2
@@ -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)); } }
drivers/xen/core/evtchn.c +7 -5
@@ -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 irif (!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 ; }
drivers/xen/core/machine_kexec.c +2 -2
@@ -155,7 +155,7 @@ void xen_machine_kexec_unload(struct kimmemset (&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 kimmemset (&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" ); }
drivers/xen/core/machine_reboot.c +6 -4
@@ -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 );
drivers/xen/netback/netback.c +16 -10
@@ -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 longbreak ; } -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 longif (!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;
drivers/xen/netfront/netfront.c +8 -3
@@ -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); } }
drivers/xen/xenoprof/xenoprofile.c +7 -5
@@ -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 )); } }
include/asm-i386/mach-xen/asm/desc.h +3 -1
@@ -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 }
include/asm-x86_64/mach-xen/asm/desc.h +3 -1
@@ -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
include/asm-i386/mach-xen/asm/hypercall.h +32 -30
250 lines not on this page · raw message
include/asm-x86_64/mach-xen/asm/hypercall.h +33 -31
258 lines not on this page · raw message
include/asm-i386/mach-xen/asm/hypervisor.h +7 -8
@@ -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) {
include/asm-i386/mach-xen/asm/processor.h +6 -4
@@ -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 */
include/asm-x86_64/mach-xen/asm/processor.h +4 -2
@@ -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 ;
include/xen/evtchn.h +1 -1
@@ -126,7 +126,7 @@ static inline void clear_evtchn(int portstatic 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)); }/*
include/xen/hypercall.h +6 -1
@@ -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__ */