From: "Jan Beulich" Subject: [PATCH] linux: check hypercall return status Date: Mon, 21 Jan 2008 15:14:09 +0000 Message-ID: <4794C4D1.76E4.0078.0@novell.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Return-path: Content-Disposition: inline List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org 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 Index: head-2008-01-21/arch/i386/kernel/cpu/mtrr/main-xen.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- 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,=20 =20 op.cmd =3D XENPF_read_memtype; op.u.read_memtype.reg =3D reg; - (void)HYPERVISOR_platform_op(&op); + if (unlikely(HYPERVISOR_platform_op(&op))) + memset(&op.u.read_memtype, 0, sizeof(op.u.read_memtype)); =20 *size =3D op.u.read_memtype.nr_mfns; *base =3D op.u.read_memtype.mfn; Index: head-2008-01-21/arch/i386/kernel/fixup.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- 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.0000000= 00 +0100 @@ -46,8 +46,8 @@ fastcall void do_fixup_4gb_segment(struc if (current->tgid =3D=3D 1) return; =20 - HYPERVISOR_vm_assist( - VMASST_CMD_disable, VMASST_TYPE_4gb_segments_notify); + VOID(HYPERVISOR_vm_assist(VMASST_CMD_disable, + VMASST_TYPE_4gb_segments_notify)); =20 if (test_and_set_bit(0, &printed)) return; @@ -81,8 +81,8 @@ fastcall void do_fixup_4gb_segment(struc =20 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 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- 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 =3D mp_ioapics[apic].mpc_apicaddr; apic_op.reg =3D reg; apic_op.value =3D value; - HYPERVISOR_physdev_op(PHYSDEVOP_apic_write, &apic_op); + WARN_ON(HYPERVISOR_physdev_op(PHYSDEVOP_apic_write, &apic_op)); } =20 #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 =3D { .cmd =3D XENPF_platform_qui= rk }; op.u.platform_quirk.quirk_id =3D 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 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- 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 =3D mp_ioapics[apic].mpc_apicaddr; apic_op.reg =3D reg; apic_op.value =3D value; - HYPERVISOR_physdev_op(PHYSDEVOP_apic_write, &apic_op); + WARN_ON(HYPERVISOR_physdev_op(PHYSDEVOP_apic_write, &apic_op)); } =20 #define io_apic_read(a,r) xen_io_apic_read(a,r) Index: head-2008-01-21/arch/i386/kernel/ioport-xen.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- 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 =20 set_xen_guest_handle(set_iobitmap.bitmap, (char *)bitmap); set_iobitmap.nr_ports =3D IO_BITMAP_BITS; - HYPERVISOR_physdev_op(PHYSDEVOP_set_iobitmap, &set_iobitmap= ); + WARN_ON(HYPERVISOR_physdev_op(PHYSDEVOP_set_iobitmap, + &set_iobitmap)); } =20 set_bitmap(t->io_bitmap_ptr, from, num, !turn_on); Index: head-2008-01-21/arch/x86_64/kernel/ioport-xen.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- 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 =20 set_xen_guest_handle(set_iobitmap.bitmap, (char *)bitmap); set_iobitmap.nr_ports =3D IO_BITMAP_BITS; - HYPERVISOR_physdev_op(PHYSDEVOP_set_iobitmap, &set_iobitmap= ); + WARN_ON(HYPERVISOR_physdev_op(PHYSDEVOP_set_iobitmap, + &set_iobitmap)); } =20 set_bitmap(t->io_bitmap_ptr, from, num, !turn_on); @@ -92,7 +93,7 @@ asmlinkage long sys_iopl(unsigned int ne =20 /* Force the change at ring 0. */ set_iopl.iopl =3D (new_iopl =3D=3D 0) ? 1 : new_iopl; - HYPERVISOR_physdev_op(PHYSDEVOP_set_iopl, &set_iopl); + WARN_ON(HYPERVISOR_physdev_op(PHYSDEVOP_set_iopl, &set_iopl)); =20 return 0; } Index: head-2008-01-21/arch/i386/kernel/process-xen.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- 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 =3D &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 =3D NULL; clear_thread_flag(TIF_IO_BITMAP); @@ -670,7 +670,9 @@ struct task_struct fastcall * __switch_t mcl++; } =20 - (void)HYPERVISOR_multicall(_mcl, mcl - _mcl); + BUG_ON(mcl > _mcl + ARRAY_SIZE(_mcl)); + if (unlikely(HYPERVISOR_multicall_check(_mcl, mcl - _mcl, NULL))) + BUG(); =20 /* * Restore %fs and %gs if needed. Index: head-2008-01-21/arch/x86_64/kernel/process-xen.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- 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 =3D 0; } @@ -357,7 +357,7 @@ void exit_thread(void) =20 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)); } =20 void flush_thread(void) @@ -608,7 +608,10 @@ __switch_to(struct task_struct *prev_p,=20 mcl++; } =20 - (void)HYPERVISOR_multicall(_mcl, mcl - _mcl); + BUG_ON(mcl > _mcl + ARRAY_SIZE(_mcl)); + if (unlikely(HYPERVISOR_multicall_check(_mcl, mcl - _mcl, NULL))) + BUG(); + /*=20 * 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,=20 loadsegment(fs, next->fsindex); =20 if (next->fs) - HYPERVISOR_set_segment_base(SEGBASE_FS, next->fs);=20 + WARN_ON(HYPERVISOR_set_segment_base(SEGBASE_FS, next->fs));= =09 if (unlikely(next->gsindex)) load_gs_index(next->gsindex); =20 if (next->gs) - HYPERVISOR_set_segment_base(SEGBASE_GS_USER, next->gs);=20 + WARN_ON(HYPERVISOR_set_segment_base(SEGBASE_GS_USER, = next->gs)); =20 /*=20 * Switch the PDA context. Index: head-2008-01-21/arch/i386/kernel/quirks-xen.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- 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 =3D XENPF_platform_quirk; op.u.platform_quirk.quirk_id =3D QUIRK_NOIRQBALANCING; - (void)HYPERVISOR_platform_op(&op); + WARN_ON(HYPERVISOR_platform_op(&op)); } =20 /* put back the original value for config space*/ Index: head-2008-01-21/arch/x86_64/kernel/setup64-xen.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- 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 =3D cpu;=20 pda->irqcount =3D -1; Index: head-2008-01-21/arch/i386/kernel/setup-xen.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- 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_blo= ck); =20 - 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)); =20 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(); =20 set_iopl.iopl =3D 1; - HYPERVISOR_physdev_op(PHYSDEVOP_set_iopl, &set_iopl); + WARN_ON(HYPERVISOR_physdev_op(PHYSDEVOP_set_iopl, &set_iopl)); =20 #ifdef CONFIG_ACPI if (!is_initial_xendomain()) { Index: head-2008-01-21/arch/x86_64/kernel/setup-xen.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- 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) =20 copy_edid(); =20 - HYPERVISOR_vm_assist(VMASST_CMD_enable, - VMASST_TYPE_writable_pagetables); + WARN_ON(HYPERVISOR_vm_assist(VMASST_CMD_enable, + VMASST_TYPE_writable_pagetables)); =20 ARCH_SETUP #else @@ -684,7 +684,7 @@ void __init setup_arch(char **cmdline_p) struct physdev_set_iopl set_iopl; =20 set_iopl.iopl =3D 1; - HYPERVISOR_physdev_op(PHYSDEVOP_set_iopl, &set_iopl); + WARN_ON(HYPERVISOR_physdev_op(PHYSDEVOP_set_iopl, = &set_iopl)); =20 if (is_initial_xendomain()) { #ifdef CONFIG_VT Index: head-2008-01-21/arch/i386/kernel/time-xen.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- 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.0000000= 00 +0100 @@ -504,7 +504,7 @@ static void sync_xen_wallclock(unsigned=20 op.u.settime.secs =3D sec; op.u.settime.nsecs =3D nsec; op.u.settime.system_time =3D processed_system_time; - HYPERVISOR_platform_op(&op); + WARN_ON(HYPERVISOR_platform_op(&op)); =20 update_wallclock(); =20 @@ -914,8 +914,16 @@ void __init time_init(void) } #endif =20 - 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 <=3D 0x030004 + case -ENOSYS: +#endif + break; + default: + BUG(); + } =20 get_time_values_from_xen(0); =20 @@ -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); =20 @@ -1032,8 +1040,16 @@ void time_resume(void) init_cpu_khz(); =20 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 <=3D 0x030004 + case -ENOSYS: +#endif + break; + default: + BUG(); + } get_time_values_from_xen(cpu); per_cpu(processed_system_time, cpu) =3D per_cpu(shadow_time, 0).system_timestamp; @@ -1054,8 +1070,16 @@ int __cpuinit local_setup_timer(unsigned =20 BUG_ON(cpu =3D=3D 0); =20 - 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 <=3D 0x030004 + case -ENOSYS: +#endif + break; + default: + BUG(); + } =20 do { seq =3D read_seqbegin(&xtime_lock); @@ -1103,7 +1127,7 @@ static int time_cpufreq_notifier(struct=20 op.u.change_freq.flags =3D 0; op.u.change_freq.cpu =3D freq->cpu; op.u.change_freq.freq =3D (u64)freq->new * 1000; - HYPERVISOR_platform_op(&op); + WARN_ON(HYPERVISOR_platform_op(&op)); =20 return 0; } Index: head-2008-01-21/arch/i386/kernel/traps-xen.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- 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 =20 void __init trap_init(void) { - HYPERVISOR_set_trap_table(trap_table); + int ret; + + ret =3D HYPERVISOR_set_trap_table(trap_table); + if (ret) + printk("HYPERVISOR_set_trap_table failed: error %d\n", = ret); =20 if (cpu_has_fxsr) { /* Index: head-2008-01-21/arch/x86_64/kernel/traps-xen.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- 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; =20 ret =3D HYPERVISOR_set_trap_table(trap_table); - =20 if (ret)=20 - printk("HYPERVISOR_set_trap_table faild: error %d\n", - ret); + printk("HYPERVISOR_set_trap_table failed: error %d\n", = ret); =20 /* * Should be a barrier for any external CPU state. Index: head-2008-01-21/arch/x86_64/mm/init-xen.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- 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.0000000= 00 +0100 @@ -641,7 +641,8 @@ static void __init extend_init_mapping(u =20 /* 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 +=3D PAGE_SIZE; } =20 @@ -674,7 +675,8 @@ static void __init extend_init_mapping(u pmd =3D (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 +=3D PAGE_SIZE; } } @@ -727,8 +729,8 @@ static void __init xen_finish_init_mappi start =3D PAGE_ALIGN((unsigned long)_end); end =3D __START_KERNEL_map + (table_end << PAGE_SHIFT); for (; start < end; start +=3D PAGE_SIZE) - WARN_ON(HYPERVISOR_update_va_mapping( - start, __pte_ma(0), 0)); + if (HYPERVISOR_update_va_mapping(start, __pte_ma(0), 0)) + BUG(); =20 /* Allocate pte's for initial fixmaps from 'start_pfn' allocator. = */ table_end =3D ~0UL; Index: head-2008-01-21/arch/i386/oprofile/xenoprof.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- 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 =3D (uint32_t)counter_config[i].kernel; counter.user =3D (uint32_t)counter_config[i].user; counter.unit_mask =3D (uint64_t)counter_config[i].unit_mask= ; - HYPERVISOR_xenoprof_op(XENOPROF_counter,=20 - &counter); + WARN_ON(HYPERVISOR_xenoprof_op(XENOPROF_counter, + &counter)); } } =20 Index: head-2008-01-21/drivers/xen/core/evtchn.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- 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.0000000= 00 +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 =3D { .irq =3D pirq }; if (unlikely(test_bit(pirq, pirq_needs_eoi))) - (void)HYPERVISOR_physdev_op(PHYSDEVOP_eoi, &eoi); + VOID(HYPERVISOR_physdev_op(PHYSDEVOP_eoi, &eoi)); } =20 static inline void pirq_query_unmask(int pirq) { struct physdev_irq_status_query irq_status; irq_status.irq =3D pirq; - (void)HYPERVISOR_physdev_op(PHYSDEVOP_irq_status_query, &irq_status= ); + if (HYPERVISOR_physdev_op(PHYSDEVOP_irq_status_query, &irq_status))= + irq_status.flags =3D 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; =20 - (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); } =20 @@ -905,7 +907,7 @@ void unmask_evtchn(int port) /* Slow path (hypercall) if this is a non-local port. */ if (unlikely(cpu !=3D cpu_from_evtchn(port))) { struct evtchn_unmask unmask =3D { .port =3D port }; - (void)HYPERVISOR_event_channel_op(EVTCHNOP_unmask, = &unmask); + VOID(HYPERVISOR_event_channel_op(EVTCHNOP_unmask, = &unmask)); return; } =20 Index: head-2008-01-21/drivers/xen/core/machine_kexec.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- 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 =20 memset(&xkl, 0, sizeof(xkl)); xkl.type =3D image->type; - HYPERVISOR_kexec_op(KEXEC_CMD_kexec_unload, &xkl); + WARN_ON(HYPERVISOR_kexec_op(KEXEC_CMD_kexec_unload, &xkl)); } =20 /* @@ -172,7 +172,7 @@ NORET_TYPE void machine_kexec(struct kim =20 memset(&xke, 0, sizeof(xke)); xke.type =3D 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"); } =20 Index: head-2008-01-21/drivers/xen/core/machine_reboot.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- 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 =3D (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)); =20 xen_start_info->store_mfn =3D mfn_to_pfn(xen_start_info->store_mfn)= ; xen_start_info->console.domU.mfn =3D @@ -89,8 +89,10 @@ static void post_suspend(int suspend_can } =20 shinfo_mfn =3D 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 =3D (shared_info_t *)fix_to_virt(FIX_SHARED_= INFO); =20 memset(empty_zero_page, 0, PAGE_SIZE); Index: head-2008-01-21/drivers/xen/netback/netback.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- 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 =3D 0, .domid =3D DOMID_SELF }; + int rc; =20 if (likely(alloc_index >=3D nr)) return 0; =20 set_xen_guest_handle(reservation.extent_start, mfn_list + = alloc_index); reservation.nr_extents =3D MAX_MFN_ALLOC - alloc_index; - alloc_index +=3D HYPERVISOR_memory_op(XENMEM_increase_reservation, - &reservation); + rc =3D HYPERVISOR_memory_op(XENMEM_increase_reservation, &reservati= on); + if (likely(rc > 0)) + alloc_index +=3D rc; =20 return alloc_index >=3D nr ? 0 : -ENOMEM; } @@ -349,7 +351,7 @@ int xen_network_done(void) =20 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=20 break; } =20 - if (npo.mcl_prod && - !xen_feature(XENFEAT_auto_translated_physmap)) { + BUG_ON(npo.meta_prod > ARRAY_SIZE(meta)); + + npo.mmu_mcl =3D 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 =3D npo.mcl + npo.mcl_prod++; =20 BUG_ON(mcl[-1].op !=3D __HYPERVISOR_update_va_mapping); @@ -620,6 +626,7 @@ static void net_rx_action(unsigned long=20 } =20 if (npo.trans_prod) { + BUG_ON(npo.trans_prod > ARRAY_SIZE(grant_trans_op)); mcl =3D npo.mcl + npo.mcl_prod++; mcl->op =3D __HYPERVISOR_grant_table_op; mcl->args[0] =3D GNTTABOP_transfer; @@ -628,6 +635,7 @@ static void net_rx_action(unsigned long=20 } =20 if (npo.copy_prod) { + BUG_ON(npo.copy_prod > ARRAY_SIZE(grant_copy_op)); mcl =3D npo.mcl + npo.mcl_prod++; mcl->op =3D __HYPERVISOR_grant_table_op; mcl->args[0] =3D GNTTABOP_copy; @@ -639,14 +647,12 @@ static void net_rx_action(unsigned long=20 if (!npo.mcl_prod) return; =20 - 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)); =20 ret =3D HYPERVISOR_multicall(npo.mcl, npo.mcl_prod); BUG_ON(ret !=3D 0); + /* The mmu_machphys_update() must not fail. */ + BUG_ON(npo.mmu_mcl && npo.mcl[npo.mmu_mcl].result !=3D 0); =20 while ((skb =3D __skb_dequeue(&rxq)) !=3D NULL) { nr_frags =3D *(int *)skb->cb; Index: head-2008-01-21/drivers/xen/netfront/netfront.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- 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: =20 /* 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(); =20 /* Check return status of HYPERVISOR_memory_op(). = */ if (unlikely(np->rx_mcl[i].result !=3D i)) panic("Unable to reduce memory reservation\= n"); + while (i--) + BUG_ON(np->rx_mcl[i].result); } else { if (HYPERVISOR_memory_op(XENMEM_decrease_reservatio= n, &reservation) !=3D i) @@ -1446,8 +1449,10 @@ err:=09 mcl->args[1] =3D pages_flipped; mcl->args[2] =3D 0; mcl->args[3] =3D DOMID_SELF; - (void)HYPERVISOR_multicall(np->rx_mcl, - pages_flipped + 1); + err =3D HYPERVISOR_multicall_check(np->rx_mcl, + pages_flipped + = 1, + NULL); + BUG_ON(err); } } =20 Index: head-2008-01-21/drivers/xen/xenoprof/xenoprofile.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- 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 =3D 0; =20 - HYPERVISOR_xenoprof_op(XENOPROF_disable_virq, NULL); + WARN_ON(HYPERVISOR_xenoprof_op(XENOPROF_disable_virq, NULL)); =20 if (xenoprof_is_primary) { - HYPERVISOR_xenoprof_op(XENOPROF_release_counters, NULL); + WARN_ON(HYPERVISOR_xenoprof_op(XENOPROF_release_counters, + NULL)); active_defined =3D 0; } =20 @@ -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(); } =20 @@ -419,7 +420,8 @@ static int xenoprof_set_active(int * act =20 out: if (ret) - HYPERVISOR_xenoprof_op(XENOPROF_reset_active_list, NULL); + WARN_ON(HYPERVISOR_xenoprof_op(XENOPROF_reset_active_list, + NULL)); active_defined =3D !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 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- 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, =20 static inline void load_TLS(struct thread_struct *t, unsigned int cpu) { -#define C(i) HYPERVISOR_update_descriptor(virt_to_machine(&get_cpu_gdt_tab= le(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 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- 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] =3D t->tls_array[2]; #endif #define C(i) \ - HYPERVISOR_update_descriptor(virt_to_machine(&cpu_gdt(cpu)[GDT_ENTR= Y_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(); =20 C(0); C(1); C(2); #undef C Index: head-2008-01-21/include/asm-i386/mach-xen/asm/hypercall.h =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- 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; \ }) =20 -static inline int +static inline int __must_check HYPERVISOR_set_trap_table( const trap_info_t *table) { return _hypercall1(int, set_trap_table, table); } =20 -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); } =20 -static inline int +static inline int __must_check HYPERVISOR_mmuext_op( struct mmuext_op *op, unsigned int count, unsigned int *success_cou= nt, domid_t domid) @@ -146,21 +146,21 @@ HYPERVISOR_mmuext_op( return _hypercall4(int, mmuext_op, op, count, success_count, = domid); } =20 -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); } =20 -static inline int +static inline int __must_check HYPERVISOR_stack_switch( unsigned long ss, unsigned long esp) { return _hypercall2(int, stack_switch, ss, esp); } =20 -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); } =20 -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); } =20 -static inline int +static inline int __must_check HYPERVISOR_sched_op( int cmd, void *arg) { return _hypercall2(int, sched_op, cmd, arg); } =20 -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); } =20 -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); } =20 -static inline int +static inline int __must_check HYPERVISOR_set_debugreg( unsigned int reg, unsigned long value) { return _hypercall2(int, set_debugreg, reg, value); } =20 -static inline unsigned long +static inline unsigned long __must_check HYPERVISOR_get_debugreg( unsigned int reg) { return _hypercall1(unsigned long, get_debugreg, reg); } =20 -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); } =20 -static inline int +static inline int __must_check HYPERVISOR_memory_op( unsigned int cmd, void *arg) { return _hypercall2(int, memory_op, cmd, arg); } =20 -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); } =20 -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); } =20 -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; } =20 -static inline int +static inline int __must_check HYPERVISOR_acm_op( int cmd, void *arg) { return _hypercall2(int, acm_op, cmd, arg); } =20 -static inline int +static inline int __must_check HYPERVISOR_xen_version( int cmd, void *arg) { return _hypercall2(int, xen_version, cmd, arg); } =20 -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); } =20 -static inline int +static inline int __must_check HYPERVISOR_physdev_op( int cmd, void *arg) { @@ -314,14 +314,14 @@ HYPERVISOR_physdev_op( return rc; } =20 -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); } =20 -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); } =20 -static inline int +static inline int __must_check HYPERVISOR_vm_assist( unsigned int cmd, unsigned int type) { return _hypercall2(int, vm_assist, cmd, type); } =20 -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); } =20 -static inline int +static inline int __must_check HYPERVISOR_suspend( unsigned long srec) { @@ -367,15 +367,17 @@ HYPERVISOR_suspend( return rc; } =20 +#if CONFIG_XEN_COMPAT <=3D 0x030002 static inline int HYPERVISOR_nmi_op( unsigned long op, void *arg) { return _hypercall2(int, nmi_op, op, arg); } +#endif =20 #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 =20 -static inline int +static inline int __must_check HYPERVISOR_callback_op( int cmd, const void *arg) { return _hypercall2(int, callback_op, cmd, arg); } =20 -static inline int +static inline int __must_check HYPERVISOR_xenoprof_op( int op, void *arg) { return _hypercall2(int, xenoprof_op, op, arg); } =20 -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 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- 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; \ }) =20 -static inline int +static inline int __must_check HYPERVISOR_set_trap_table( const trap_info_t *table) { return _hypercall1(int, set_trap_table, table); } =20 -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); } =20 -static inline int +static inline int __must_check HYPERVISOR_mmuext_op( struct mmuext_op *op, unsigned int count, unsigned int *success_cou= nt, domid_t domid) @@ -152,21 +152,21 @@ HYPERVISOR_mmuext_op( return _hypercall4(int, mmuext_op, op, count, success_count, = domid); } =20 -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); } =20 -static inline int +static inline int __must_check HYPERVISOR_stack_switch( unsigned long ss, unsigned long esp) { return _hypercall2(int, stack_switch, ss, esp); } =20 -static inline int +static inline int __must_check HYPERVISOR_set_callbacks( unsigned long event_address, unsigned long failsafe_address,=20 unsigned long syscall_address) @@ -182,28 +182,28 @@ HYPERVISOR_fpu_taskswitch( return _hypercall1(int, fpu_taskswitch, set); } =20 -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); } =20 -static inline int +static inline int __must_check HYPERVISOR_sched_op( int cmd, void *arg) { return _hypercall2(int, sched_op, cmd, arg); } =20 -static inline long +static inline long __must_check HYPERVISOR_set_timer_op( u64 timeout) { return _hypercall1(long, set_timer_op, timeout); } =20 -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); } =20 -static inline int +static inline int __must_check HYPERVISOR_set_debugreg( unsigned int reg, unsigned long value) { return _hypercall2(int, set_debugreg, reg, value); } =20 -static inline unsigned long +static inline unsigned long __must_check HYPERVISOR_get_debugreg( unsigned int reg) { return _hypercall1(unsigned long, get_debugreg, reg); } =20 -static inline int +static inline int __must_check HYPERVISOR_update_descriptor( unsigned long ma, unsigned long word) { return _hypercall2(int, update_descriptor, ma, word); } =20 -static inline int +static inline int __must_check HYPERVISOR_memory_op( unsigned int cmd, void *arg) { return _hypercall2(int, memory_op, cmd, arg); } =20 -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); } =20 -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); } =20 -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; } =20 -static inline int +static inline int __must_check HYPERVISOR_acm_op( int cmd, void *arg) { return _hypercall2(int, acm_op, cmd, arg); } =20 -static inline int +static inline int __must_check HYPERVISOR_xen_version( int cmd, void *arg) { return _hypercall2(int, xen_version, cmd, arg); } =20 -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); } =20 -static inline int +static inline int __must_check HYPERVISOR_physdev_op( int cmd, void *arg) { @@ -312,14 +312,14 @@ HYPERVISOR_physdev_op( return rc; } =20 -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); } =20 -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); } =20 -static inline int +static inline int __must_check HYPERVISOR_vm_assist( unsigned int cmd, unsigned int type) { return _hypercall2(int, vm_assist, cmd, type); } =20 -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); } =20 -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); } =20 -static inline int +static inline int __must_check HYPERVISOR_suspend( unsigned long srec) { @@ -368,15 +368,17 @@ HYPERVISOR_suspend( return rc; } =20 +#if CONFIG_XEN_COMPAT <=3D 0x030002 static inline int HYPERVISOR_nmi_op( unsigned long op, void *arg) { return _hypercall2(int, nmi_op, op, arg); } +#endif =20 #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 =20 -static inline int +static inline int __must_check HYPERVISOR_callback_op( int cmd, const void *arg) { return _hypercall2(int, callback_op, cmd, arg); } =20 -static inline int +static inline int __must_check HYPERVISOR_xenoprof_op( int op, void *arg) { return _hypercall2(int, xenoprof_op, op, arg); } =20 -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 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- 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; } =20 -static inline int +static inline void __noreturn HYPERVISOR_shutdown( unsigned int reason) { @@ -174,17 +174,16 @@ HYPERVISOR_shutdown( .reason =3D reason }; =20 - int rc =3D HYPERVISOR_sched_op(SCHEDOP_shutdown, &sched_shutdown); - + VOID(HYPERVISOR_sched_op(SCHEDOP_shutdown, &sched_shutdown)); #if CONFIG_XEN_COMPAT <=3D 0x030002 - if (rc =3D=3D -ENOSYS) - rc =3D 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 !=3D SHUTDOWN_crash); + for(;;); } =20 -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 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- 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 =20 #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) =3D HYPERVISOR_get_debugreg((register)) #define set_debugreg(value, register) \ - HYPERVISOR_set_debugreg((register), (value)) + WARN_ON(HYPERVISOR_set_debugreg((register), (value))) =20 /* * Set IOPL bits in EFLAGS from given mask @@ -540,7 +542,7 @@ static inline void set_iopl_mask(uns =20 /* Force the change at ring 0. */ set_iopl.iopl =3D (mask =3D=3D 0) ? 1 : (mask >> 12) & 3; - HYPERVISOR_physdev_op(PHYSDEVOP_set_iopl, &set_iopl); + WARN_ON(HYPERVISOR_physdev_op(PHYSDEVOP_set_iopl, &set_iopl)); } =20 /* Forward declaration, a strange C thing */ Index: head-2008-01-21/include/asm-x86_64/mach-xen/asm/processor.h =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- 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 { =20 #define get_debugreg(var, register) \ var =3D 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) =20 struct task_struct; struct mm_struct; Index: head-2008-01-21/include/xen/evtchn.h =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- head-2008-01-21.orig/include/xen/evtchn.h 2008-01-21 13:01:17.0000000= 00 +0100 +++ head-2008-01-21/include/xen/evtchn.h 2008-01-21 13:31:43.0000000= 00 +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 =3D { .port =3D port }; - (void)HYPERVISOR_event_channel_op(EVTCHNOP_send, &send); + VOID(HYPERVISOR_event_channel_op(EVTCHNOP_send, &send)); } =20 /* Index: head-2008-01-21/include/xen/hypercall.h =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- 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.0000000= 00 +0100 @@ -3,7 +3,7 @@ =20 #include =20 -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; } =20 +/* 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__ */