ia64/xen-unstable

changeset 9389:b2828004f131

merge xen-unstable.hg
author awilliam@xenbuild.aw
date Wed Mar 22 09:12:48 2006 -0700 (2006-03-22)
parents 695aa28b7cb1 ecb99d1ce57d
children 11325d1c412c
files
line diff
     1.1 --- a/linux-2.6-xen-sparse/arch/i386/mm/hypervisor.c	Wed Mar 22 08:57:48 2006 -0700
     1.2 +++ b/linux-2.6-xen-sparse/arch/i386/mm/hypervisor.c	Wed Mar 22 09:12:48 2006 -0700
     1.3 @@ -5,8 +5,11 @@
     1.4   * 
     1.5   * Copyright (c) 2002-2004, K A Fraser
     1.6   * 
     1.7 - * This file may be distributed separately from the Linux kernel, or
     1.8 - * incorporated into other software packages, subject to the following license:
     1.9 + * This program is free software; you can redistribute it and/or
    1.10 + * modify it under the terms of the GNU General Public License version 2
    1.11 + * as published by the Free Software Foundation; or, when distributed
    1.12 + * separately from the Linux kernel or incorporated into other
    1.13 + * software packages, subject to the following license:
    1.14   * 
    1.15   * Permission is hereby granted, free of charge, to any person obtaining a copy
    1.16   * of this source file (the "Software"), to deal in the Software without
     2.1 --- a/linux-2.6-xen-sparse/arch/i386/mm/init-xen.c	Wed Mar 22 08:57:48 2006 -0700
     2.2 +++ b/linux-2.6-xen-sparse/arch/i386/mm/init-xen.c	Wed Mar 22 09:12:48 2006 -0700
     2.3 @@ -29,6 +29,8 @@
     2.4  #include <linux/efi.h>
     2.5  #include <linux/memory_hotplug.h>
     2.6  #include <linux/initrd.h>
     2.7 +#include <linux/dma-mapping.h>
     2.8 +#include <linux/scatterlist.h>
     2.9  
    2.10  #include <asm/processor.h>
    2.11  #include <asm/system.h>
    2.12 @@ -42,11 +44,7 @@
    2.13  #include <asm/tlbflush.h>
    2.14  #include <asm/sections.h>
    2.15  #include <asm/hypervisor.h>
    2.16 -#if defined(CONFIG_SWIOTLB)
    2.17 -#include <linux/dma-mapping.h>
    2.18 -#include <asm/scatterlist.h>
    2.19  #include <asm/swiotlb.h>
    2.20 -#endif
    2.21  
    2.22  extern unsigned long *contiguous_bitmap;
    2.23  
     3.1 --- a/linux-2.6-xen-sparse/arch/x86_64/kernel/setup-xen.c	Wed Mar 22 08:57:48 2006 -0700
     3.2 +++ b/linux-2.6-xen-sparse/arch/x86_64/kernel/setup-xen.c	Wed Mar 22 09:12:48 2006 -0700
     3.3 @@ -93,6 +93,11 @@ EXPORT_SYMBOL(hypercall_page);
     3.4  /* Allows setting of maximum possible memory size  */
     3.5  unsigned long xen_override_max_pfn;
     3.6  
     3.7 +static int xen_panic_event(struct notifier_block *, unsigned long, void *);
     3.8 +static struct notifier_block xen_panic_block = {
     3.9 +	xen_panic_event, NULL, 0 /* try to go last */
    3.10 +};
    3.11 +
    3.12  unsigned long *phys_to_machine_mapping;
    3.13  unsigned long *pfn_to_mfn_frame_list_list, *pfn_to_mfn_frame_list[512];
    3.14  
    3.15 @@ -634,6 +639,9 @@ void __init setup_arch(char **cmdline_p)
    3.16  	unsigned long kernel_end;
    3.17  
    3.18  #ifdef CONFIG_XEN
    3.19 +	/* Register a call for panic conditions. */
    3.20 +	notifier_chain_register(&panic_notifier_list, &xen_panic_block);
    3.21 +
    3.22   	ROOT_DEV = MKDEV(RAMDISK_MAJOR,0); 
    3.23  	kernel_end = 0;		/* dummy */
    3.24   	screen_info = SCREEN_INFO;
    3.25 @@ -989,6 +997,17 @@ void __init setup_arch(char **cmdline_p)
    3.26  #endif /* !CONFIG_XEN */
    3.27  }
    3.28  
    3.29 +#ifdef CONFIG_XEN
    3.30 +static int
    3.31 +xen_panic_event(struct notifier_block *this, unsigned long event, void *ptr)
    3.32 +{
    3.33 +	HYPERVISOR_sched_op(SCHEDOP_shutdown, SHUTDOWN_crash);
    3.34 +	/* we're never actually going to get here... */
    3.35 +	return NOTIFY_DONE;
    3.36 +}
    3.37 +#endif /* !CONFIG_XEN */
    3.38 +
    3.39 +
    3.40  static int __cpuinit get_model_name(struct cpuinfo_x86 *c)
    3.41  {
    3.42  	unsigned int *v;
     4.1 --- a/linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c	Wed Mar 22 08:57:48 2006 -0700
     4.2 +++ b/linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c	Wed Mar 22 09:12:48 2006 -0700
     4.3 @@ -7,8 +7,11 @@
     4.4   * Copyright (c) 2003-2004, M Williamson, K Fraser
     4.5   * Copyright (c) 2005 Dan M. Smith, IBM Corporation
     4.6   * 
     4.7 - * This file may be distributed separately from the Linux kernel, or
     4.8 - * incorporated into other software packages, subject to the following license:
     4.9 + * This program is free software; you can redistribute it and/or
    4.10 + * modify it under the terms of the GNU General Public License version 2
    4.11 + * as published by the Free Software Foundation; or, when distributed
    4.12 + * separately from the Linux kernel or incorporated into other
    4.13 + * software packages, subject to the following license:
    4.14   * 
    4.15   * Permission is hereby granted, free of charge, to any person obtaining a copy
    4.16   * of this source file (the "Software"), to deal in the Software without
    4.17 @@ -572,9 +575,11 @@ void balloon_dealloc_empty_page_range(
    4.18  	schedule_work(&balloon_worker);
    4.19  }
    4.20  
    4.21 -EXPORT_SYMBOL(balloon_update_driver_allowance);
    4.22 -EXPORT_SYMBOL(balloon_alloc_empty_page_range);
    4.23 -EXPORT_SYMBOL(balloon_dealloc_empty_page_range);
    4.24 +EXPORT_SYMBOL_GPL(balloon_update_driver_allowance);
    4.25 +EXPORT_SYMBOL_GPL(balloon_alloc_empty_page_range);
    4.26 +EXPORT_SYMBOL_GPL(balloon_dealloc_empty_page_range);
    4.27 +
    4.28 +MODULE_LICENSE("Dual BSD/GPL");
    4.29  
    4.30  /*
    4.31   * Local variables:
     5.1 --- a/linux-2.6-xen-sparse/drivers/xen/blkback/blkback.c	Wed Mar 22 08:57:48 2006 -0700
     5.2 +++ b/linux-2.6-xen-sparse/drivers/xen/blkback/blkback.c	Wed Mar 22 09:12:48 2006 -0700
     5.3 @@ -9,6 +9,30 @@
     5.4   * 
     5.5   * Copyright (c) 2003-2004, Keir Fraser & Steve Hand
     5.6   * Copyright (c) 2005, Christopher Clark
     5.7 + * 
     5.8 + * This program is free software; you can redistribute it and/or
     5.9 + * modify it under the terms of the GNU General Public License version 2
    5.10 + * as published by the Free Software Foundation; or, when distributed
    5.11 + * separately from the Linux kernel or incorporated into other
    5.12 + * software packages, subject to the following license:
    5.13 + * 
    5.14 + * Permission is hereby granted, free of charge, to any person obtaining a copy
    5.15 + * of this source file (the "Software"), to deal in the Software without
    5.16 + * restriction, including without limitation the rights to use, copy, modify,
    5.17 + * merge, publish, distribute, sublicense, and/or sell copies of the Software,
    5.18 + * and to permit persons to whom the Software is furnished to do so, subject to
    5.19 + * the following conditions:
    5.20 + * 
    5.21 + * The above copyright notice and this permission notice shall be included in
    5.22 + * all copies or substantial portions of the Software.
    5.23 + * 
    5.24 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    5.25 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    5.26 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    5.27 + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    5.28 + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
    5.29 + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
    5.30 + * IN THE SOFTWARE.
    5.31   */
    5.32  
    5.33  #include <linux/spinlock.h>
     6.1 --- a/linux-2.6-xen-sparse/drivers/xen/blkback/common.h	Wed Mar 22 08:57:48 2006 -0700
     6.2 +++ b/linux-2.6-xen-sparse/drivers/xen/blkback/common.h	Wed Mar 22 09:12:48 2006 -0700
     6.3 @@ -1,3 +1,28 @@
     6.4 +/* 
     6.5 + * This program is free software; you can redistribute it and/or
     6.6 + * modify it under the terms of the GNU General Public License version 2
     6.7 + * as published by the Free Software Foundation; or, when distributed
     6.8 + * separately from the Linux kernel or incorporated into other
     6.9 + * software packages, subject to the following license:
    6.10 + * 
    6.11 + * Permission is hereby granted, free of charge, to any person obtaining a copy
    6.12 + * of this source file (the "Software"), to deal in the Software without
    6.13 + * restriction, including without limitation the rights to use, copy, modify,
    6.14 + * merge, publish, distribute, sublicense, and/or sell copies of the Software,
    6.15 + * and to permit persons to whom the Software is furnished to do so, subject to
    6.16 + * the following conditions:
    6.17 + * 
    6.18 + * The above copyright notice and this permission notice shall be included in
    6.19 + * all copies or substantial portions of the Software.
    6.20 + * 
    6.21 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    6.22 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    6.23 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    6.24 + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    6.25 + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
    6.26 + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
    6.27 + * IN THE SOFTWARE.
    6.28 + */
    6.29  
    6.30  #ifndef __BLKIF__BACKEND__COMMON_H__
    6.31  #define __BLKIF__BACKEND__COMMON_H__
     7.1 --- a/linux-2.6-xen-sparse/drivers/xen/blkback/interface.c	Wed Mar 22 08:57:48 2006 -0700
     7.2 +++ b/linux-2.6-xen-sparse/drivers/xen/blkback/interface.c	Wed Mar 22 09:12:48 2006 -0700
     7.3 @@ -4,6 +4,30 @@
     7.4   * Block-device interface management.
     7.5   * 
     7.6   * Copyright (c) 2004, Keir Fraser
     7.7 + * 
     7.8 + * This program is free software; you can redistribute it and/or
     7.9 + * modify it under the terms of the GNU General Public License version 2
    7.10 + * as published by the Free Software Foundation; or, when distributed
    7.11 + * separately from the Linux kernel or incorporated into other
    7.12 + * software packages, subject to the following license:
    7.13 + * 
    7.14 + * Permission is hereby granted, free of charge, to any person obtaining a copy
    7.15 + * of this source file (the "Software"), to deal in the Software without
    7.16 + * restriction, including without limitation the rights to use, copy, modify,
    7.17 + * merge, publish, distribute, sublicense, and/or sell copies of the Software,
    7.18 + * and to permit persons to whom the Software is furnished to do so, subject to
    7.19 + * the following conditions:
    7.20 + * 
    7.21 + * The above copyright notice and this permission notice shall be included in
    7.22 + * all copies or substantial portions of the Software.
    7.23 + * 
    7.24 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    7.25 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    7.26 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    7.27 + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    7.28 + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
    7.29 + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
    7.30 + * IN THE SOFTWARE.
    7.31   */
    7.32  
    7.33  #include "common.h"
     8.1 --- a/linux-2.6-xen-sparse/drivers/xen/blkback/vbd.c	Wed Mar 22 08:57:48 2006 -0700
     8.2 +++ b/linux-2.6-xen-sparse/drivers/xen/blkback/vbd.c	Wed Mar 22 09:12:48 2006 -0700
     8.3 @@ -4,6 +4,30 @@
     8.4   * Routines for managing virtual block devices (VBDs).
     8.5   * 
     8.6   * Copyright (c) 2003-2005, Keir Fraser & Steve Hand
     8.7 + * 
     8.8 + * This program is free software; you can redistribute it and/or
     8.9 + * modify it under the terms of the GNU General Public License version 2
    8.10 + * as published by the Free Software Foundation; or, when distributed
    8.11 + * separately from the Linux kernel or incorporated into other
    8.12 + * software packages, subject to the following license:
    8.13 + * 
    8.14 + * Permission is hereby granted, free of charge, to any person obtaining a copy
    8.15 + * of this source file (the "Software"), to deal in the Software without
    8.16 + * restriction, including without limitation the rights to use, copy, modify,
    8.17 + * merge, publish, distribute, sublicense, and/or sell copies of the Software,
    8.18 + * and to permit persons to whom the Software is furnished to do so, subject to
    8.19 + * the following conditions:
    8.20 + * 
    8.21 + * The above copyright notice and this permission notice shall be included in
    8.22 + * all copies or substantial portions of the Software.
    8.23 + * 
    8.24 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    8.25 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    8.26 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    8.27 + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    8.28 + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
    8.29 + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
    8.30 + * IN THE SOFTWARE.
    8.31   */
    8.32  
    8.33  #include "common.h"
     9.1 --- a/linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c	Wed Mar 22 08:57:48 2006 -0700
     9.2 +++ b/linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c	Wed Mar 22 09:12:48 2006 -0700
     9.3 @@ -810,7 +810,6 @@ module_exit(xlblk_exit);
     9.4  
     9.5  MODULE_LICENSE("Dual BSD/GPL");
     9.6  
     9.7 -
     9.8  /*
     9.9   * Local variables:
    9.10   *  c-file-style: "linux"
    10.1 --- a/linux-2.6-xen-sparse/drivers/xen/blkfront/block.h	Wed Mar 22 08:57:48 2006 -0700
    10.2 +++ b/linux-2.6-xen-sparse/drivers/xen/blkfront/block.h	Wed Mar 22 09:12:48 2006 -0700
    10.3 @@ -7,8 +7,11 @@
    10.4   * Modifications by Mark A. Williamson are (c) Intel Research Cambridge
    10.5   * Copyright (c) 2004-2005, Christian Limpach
    10.6   * 
    10.7 - * This file may be distributed separately from the Linux kernel, or
    10.8 - * incorporated into other software packages, subject to the following license:
    10.9 + * This program is free software; you can redistribute it and/or
   10.10 + * modify it under the terms of the GNU General Public License version 2
   10.11 + * as published by the Free Software Foundation; or, when distributed
   10.12 + * separately from the Linux kernel or incorporated into other
   10.13 + * software packages, subject to the following license:
   10.14   * 
   10.15   * Permission is hereby granted, free of charge, to any person obtaining a copy
   10.16   * of this source file (the "Software"), to deal in the Software without
    11.1 --- a/linux-2.6-xen-sparse/drivers/xen/blkfront/vbd.c	Wed Mar 22 08:57:48 2006 -0700
    11.2 +++ b/linux-2.6-xen-sparse/drivers/xen/blkfront/vbd.c	Wed Mar 22 09:12:48 2006 -0700
    11.3 @@ -7,8 +7,11 @@
    11.4   * Modifications by Mark A. Williamson are (c) Intel Research Cambridge
    11.5   * Copyright (c) 2004-2005, Christian Limpach
    11.6   * 
    11.7 - * This file may be distributed separately from the Linux kernel, or
    11.8 - * incorporated into other software packages, subject to the following license:
    11.9 + * This program is free software; you can redistribute it and/or
   11.10 + * modify it under the terms of the GNU General Public License version 2
   11.11 + * as published by the Free Software Foundation; or, when distributed
   11.12 + * separately from the Linux kernel or incorporated into other
   11.13 + * software packages, subject to the following license:
   11.14   * 
   11.15   * Permission is hereby granted, free of charge, to any person obtaining a copy
   11.16   * of this source file (the "Software"), to deal in the Software without
    12.1 --- a/linux-2.6-xen-sparse/drivers/xen/console/console.c	Wed Mar 22 08:57:48 2006 -0700
    12.2 +++ b/linux-2.6-xen-sparse/drivers/xen/console/console.c	Wed Mar 22 09:12:48 2006 -0700
    12.3 @@ -5,8 +5,11 @@
    12.4   * 
    12.5   * Copyright (c) 2002-2004, K A Fraser.
    12.6   * 
    12.7 - * This file may be distributed separately from the Linux kernel, or
    12.8 - * incorporated into other software packages, subject to the following license:
    12.9 + * This program is free software; you can redistribute it and/or
   12.10 + * modify it under the terms of the GNU General Public License version 2
   12.11 + * as published by the Free Software Foundation; or, when distributed
   12.12 + * separately from the Linux kernel or incorporated into other
   12.13 + * software packages, subject to the following license:
   12.14   * 
   12.15   * Permission is hereby granted, free of charge, to any person obtaining a copy
   12.16   * of this source file (the "Software"), to deal in the Software without
   12.17 @@ -632,6 +635,8 @@ static int __init xencons_init(void)
   12.18  
   12.19  module_init(xencons_init);
   12.20  
   12.21 +MODULE_LICENSE("Dual BSD/GPL");
   12.22 +
   12.23  /*
   12.24   * Local variables:
   12.25   *  c-file-style: "linux"
    13.1 --- a/linux-2.6-xen-sparse/drivers/xen/console/xencons_ring.c	Wed Mar 22 08:57:48 2006 -0700
    13.2 +++ b/linux-2.6-xen-sparse/drivers/xen/console/xencons_ring.c	Wed Mar 22 09:12:48 2006 -0700
    13.3 @@ -1,3 +1,29 @@
    13.4 +/* 
    13.5 + * This program is free software; you can redistribute it and/or
    13.6 + * modify it under the terms of the GNU General Public License version 2
    13.7 + * as published by the Free Software Foundation; or, when distributed
    13.8 + * separately from the Linux kernel or incorporated into other
    13.9 + * software packages, subject to the following license:
   13.10 + * 
   13.11 + * Permission is hereby granted, free of charge, to any person obtaining a copy
   13.12 + * of this source file (the "Software"), to deal in the Software without
   13.13 + * restriction, including without limitation the rights to use, copy, modify,
   13.14 + * merge, publish, distribute, sublicense, and/or sell copies of the Software,
   13.15 + * and to permit persons to whom the Software is furnished to do so, subject to
   13.16 + * the following conditions:
   13.17 + * 
   13.18 + * The above copyright notice and this permission notice shall be included in
   13.19 + * all copies or substantial portions of the Software.
   13.20 + * 
   13.21 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   13.22 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   13.23 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
   13.24 + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
   13.25 + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
   13.26 + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
   13.27 + * IN THE SOFTWARE.
   13.28 + */
   13.29 +
   13.30  #include <linux/version.h>
   13.31  #include <linux/module.h>
   13.32  #include <linux/errno.h>
    14.1 --- a/linux-2.6-xen-sparse/drivers/xen/core/evtchn.c	Wed Mar 22 08:57:48 2006 -0700
    14.2 +++ b/linux-2.6-xen-sparse/drivers/xen/core/evtchn.c	Wed Mar 22 09:12:48 2006 -0700
    14.3 @@ -5,8 +5,11 @@
    14.4   * 
    14.5   * Copyright (c) 2002-2005, K A Fraser
    14.6   * 
    14.7 - * This file may be distributed separately from the Linux kernel, or
    14.8 - * incorporated into other software packages, subject to the following license:
    14.9 + * This program is free software; you can redistribute it and/or
   14.10 + * modify it under the terms of the GNU General Public License version 2
   14.11 + * as published by the Free Software Foundation; or, when distributed
   14.12 + * separately from the Linux kernel or incorporated into other
   14.13 + * software packages, subject to the following license:
   14.14   * 
   14.15   * Permission is hereby granted, free of charge, to any person obtaining a copy
   14.16   * of this source file (the "Software"), to deal in the Software without
   14.17 @@ -147,7 +150,7 @@ void force_evtchn_callback(void)
   14.18  {
   14.19  	(void)HYPERVISOR_xen_version(0, NULL);
   14.20  }
   14.21 -EXPORT_SYMBOL(force_evtchn_callback);
   14.22 +EXPORT_SYMBOL_GPL(force_evtchn_callback);
   14.23  
   14.24  /* NB. Interrupts are disabled on entry. */
   14.25  asmlinkage void evtchn_do_upcall(struct pt_regs *regs)
   14.26 @@ -323,7 +326,7 @@ int bind_evtchn_to_irqhandler(
   14.27  
   14.28  	return irq;
   14.29  }
   14.30 -EXPORT_SYMBOL(bind_evtchn_to_irqhandler);
   14.31 +EXPORT_SYMBOL_GPL(bind_evtchn_to_irqhandler);
   14.32  
   14.33  int bind_virq_to_irqhandler(
   14.34  	unsigned int virq,
   14.35 @@ -345,7 +348,7 @@ int bind_virq_to_irqhandler(
   14.36  
   14.37  	return irq;
   14.38  }
   14.39 -EXPORT_SYMBOL(bind_virq_to_irqhandler);
   14.40 +EXPORT_SYMBOL_GPL(bind_virq_to_irqhandler);
   14.41  
   14.42  int bind_ipi_to_irqhandler(
   14.43  	unsigned int ipi,
   14.44 @@ -367,14 +370,14 @@ int bind_ipi_to_irqhandler(
   14.45  
   14.46  	return irq;
   14.47  }
   14.48 -EXPORT_SYMBOL(bind_ipi_to_irqhandler);
   14.49 +EXPORT_SYMBOL_GPL(bind_ipi_to_irqhandler);
   14.50  
   14.51  void unbind_from_irqhandler(unsigned int irq, void *dev_id)
   14.52  {
   14.53  	free_irq(irq, dev_id);
   14.54  	unbind_from_irq(irq);
   14.55  }
   14.56 -EXPORT_SYMBOL(unbind_from_irqhandler);
   14.57 +EXPORT_SYMBOL_GPL(unbind_from_irqhandler);
   14.58  
   14.59  #ifdef CONFIG_SMP
   14.60  static void do_nothing_function(void *ign)
   14.61 @@ -639,14 +642,14 @@ void notify_remote_via_irq(int irq)
   14.62  	if (VALID_EVTCHN(evtchn))
   14.63  		notify_remote_via_evtchn(evtchn);
   14.64  }
   14.65 -EXPORT_SYMBOL(notify_remote_via_irq);
   14.66 +EXPORT_SYMBOL_GPL(notify_remote_via_irq);
   14.67  
   14.68  void mask_evtchn(int port)
   14.69  {
   14.70  	shared_info_t *s = HYPERVISOR_shared_info;
   14.71  	synch_set_bit(port, &s->evtchn_mask[0]);
   14.72  }
   14.73 -EXPORT_SYMBOL(mask_evtchn);
   14.74 +EXPORT_SYMBOL_GPL(mask_evtchn);
   14.75  
   14.76  void unmask_evtchn(int port)
   14.77  {
   14.78 @@ -677,7 +680,7 @@ void unmask_evtchn(int port)
   14.79  			force_evtchn_callback();
   14.80  	}
   14.81  }
   14.82 -EXPORT_SYMBOL(unmask_evtchn);
   14.83 +EXPORT_SYMBOL_GPL(unmask_evtchn);
   14.84  
   14.85  void irq_resume(void)
   14.86  {
    15.1 --- a/linux-2.6-xen-sparse/drivers/xen/core/features.c	Wed Mar 22 08:57:48 2006 -0700
    15.2 +++ b/linux-2.6-xen-sparse/drivers/xen/core/features.c	Wed Mar 22 09:12:48 2006 -0700
    15.3 @@ -12,7 +12,7 @@
    15.4  #include <xen/features.h>
    15.5  
    15.6  u8 xen_features[XENFEAT_NR_SUBMAPS * 32] __read_mostly;
    15.7 -EXPORT_SYMBOL(xen_features);
    15.8 +EXPORT_SYMBOL_GPL(xen_features);
    15.9  
   15.10  void setup_xen_features(void)
   15.11  {
    16.1 --- a/linux-2.6-xen-sparse/drivers/xen/core/gnttab.c	Wed Mar 22 08:57:48 2006 -0700
    16.2 +++ b/linux-2.6-xen-sparse/drivers/xen/core/gnttab.c	Wed Mar 22 09:12:48 2006 -0700
    16.3 @@ -6,8 +6,11 @@
    16.4   * Copyright (c) 2005, Christopher Clark
    16.5   * Copyright (c) 2004-2005, K A Fraser
    16.6   * 
    16.7 - * This file may be distributed separately from the Linux kernel, or
    16.8 - * incorporated into other software packages, subject to the following license:
    16.9 + * This program is free software; you can redistribute it and/or
   16.10 + * modify it under the terms of the GNU General Public License version 2
   16.11 + * as published by the Free Software Foundation; or, when distributed
   16.12 + * separately from the Linux kernel or incorporated into other
   16.13 + * software packages, subject to the following license:
   16.14   * 
   16.15   * Permission is hereby granted, free of charge, to any person obtaining a copy
   16.16   * of this source file (the "Software"), to deal in the Software without
   16.17 @@ -52,21 +55,21 @@
   16.18  	printk(KERN_WARNING "xen_grant: " fmt, ##args)
   16.19  
   16.20  
   16.21 -EXPORT_SYMBOL(gnttab_grant_foreign_access);
   16.22 -EXPORT_SYMBOL(gnttab_end_foreign_access_ref);
   16.23 -EXPORT_SYMBOL(gnttab_end_foreign_access);
   16.24 -EXPORT_SYMBOL(gnttab_query_foreign_access);
   16.25 -EXPORT_SYMBOL(gnttab_grant_foreign_transfer);
   16.26 -EXPORT_SYMBOL(gnttab_end_foreign_transfer_ref);
   16.27 -EXPORT_SYMBOL(gnttab_end_foreign_transfer);
   16.28 -EXPORT_SYMBOL(gnttab_alloc_grant_references);
   16.29 -EXPORT_SYMBOL(gnttab_free_grant_references);
   16.30 -EXPORT_SYMBOL(gnttab_free_grant_reference);
   16.31 -EXPORT_SYMBOL(gnttab_claim_grant_reference);
   16.32 -EXPORT_SYMBOL(gnttab_release_grant_reference);
   16.33 -EXPORT_SYMBOL(gnttab_request_free_callback);
   16.34 -EXPORT_SYMBOL(gnttab_grant_foreign_access_ref);
   16.35 -EXPORT_SYMBOL(gnttab_grant_foreign_transfer_ref);
   16.36 +EXPORT_SYMBOL_GPL(gnttab_grant_foreign_access);
   16.37 +EXPORT_SYMBOL_GPL(gnttab_end_foreign_access_ref);
   16.38 +EXPORT_SYMBOL_GPL(gnttab_end_foreign_access);
   16.39 +EXPORT_SYMBOL_GPL(gnttab_query_foreign_access);
   16.40 +EXPORT_SYMBOL_GPL(gnttab_grant_foreign_transfer);
   16.41 +EXPORT_SYMBOL_GPL(gnttab_end_foreign_transfer_ref);
   16.42 +EXPORT_SYMBOL_GPL(gnttab_end_foreign_transfer);
   16.43 +EXPORT_SYMBOL_GPL(gnttab_alloc_grant_references);
   16.44 +EXPORT_SYMBOL_GPL(gnttab_free_grant_references);
   16.45 +EXPORT_SYMBOL_GPL(gnttab_free_grant_reference);
   16.46 +EXPORT_SYMBOL_GPL(gnttab_claim_grant_reference);
   16.47 +EXPORT_SYMBOL_GPL(gnttab_release_grant_reference);
   16.48 +EXPORT_SYMBOL_GPL(gnttab_request_free_callback);
   16.49 +EXPORT_SYMBOL_GPL(gnttab_grant_foreign_access_ref);
   16.50 +EXPORT_SYMBOL_GPL(gnttab_grant_foreign_transfer_ref);
   16.51  
   16.52  /* External tools reserve first few grant table entries. */
   16.53  #define NR_RESERVED_ENTRIES 8
    17.1 --- a/linux-2.6-xen-sparse/drivers/xen/core/reboot.c	Wed Mar 22 08:57:48 2006 -0700
    17.2 +++ b/linux-2.6-xen-sparse/drivers/xen/core/reboot.c	Wed Mar 22 09:12:48 2006 -0700
    17.3 @@ -122,7 +122,7 @@ static int __do_suspend(void *ignore)
    17.4  	lock_cpu_hotplug();
    17.5  #ifdef CONFIG_SMP
    17.6  	/*
    17.7 -	 * Take all other CPUs offline. We hold the hotplug semaphore to
    17.8 +	 * Take all other CPUs offline. We hold the hotplug mutex to
    17.9  	 * avoid other processes bringing up CPUs under our feet.
   17.10  	 */
   17.11  	cpus_clear(prev_online_cpus);
    18.1 --- a/linux-2.6-xen-sparse/drivers/xen/core/xen_sysfs.c	Wed Mar 22 08:57:48 2006 -0700
    18.2 +++ b/linux-2.6-xen-sparse/drivers/xen/core/xen_sysfs.c	Wed Mar 22 09:12:48 2006 -0700
    18.3 @@ -12,6 +12,7 @@
    18.4  #include <linux/module.h>
    18.5  #include <linux/init.h>
    18.6  #include <asm/hypervisor.h>
    18.7 +#include <xen/features.h>
    18.8  #include <xen/hypervisor_sysfs.h>
    18.9  
   18.10  MODULE_LICENSE("GPL");
    19.1 --- a/linux-2.6-xen-sparse/drivers/xen/evtchn/evtchn.c	Wed Mar 22 08:57:48 2006 -0700
    19.2 +++ b/linux-2.6-xen-sparse/drivers/xen/evtchn/evtchn.c	Wed Mar 22 09:12:48 2006 -0700
    19.3 @@ -6,8 +6,11 @@
    19.4   * Copyright (c) 2004-2005, K A Fraser
    19.5   * Multi-process extensions Copyright (c) 2004, Steven Smith
    19.6   * 
    19.7 - * This file may be distributed separately from the Linux kernel, or
    19.8 - * incorporated into other software packages, subject to the following license:
    19.9 + * This program is free software; you can redistribute it and/or
   19.10 + * modify it under the terms of the GNU General Public License version 2
   19.11 + * as published by the Free Software Foundation; or, when distributed
   19.12 + * separately from the Linux kernel or incorporated into other
   19.13 + * software packages, subject to the following license:
   19.14   * 
   19.15   * Permission is hereby granted, free of charge, to any person obtaining a copy
   19.16   * of this source file (the "Software"), to deal in the Software without
   19.17 @@ -448,6 +451,8 @@ static void evtchn_cleanup(void)
   19.18  module_init(evtchn_init);
   19.19  module_exit(evtchn_cleanup);
   19.20  
   19.21 +MODULE_LICENSE("Dual BSD/GPL");
   19.22 +
   19.23  /*
   19.24   * Local variables:
   19.25   *  c-file-style: "linux"
    20.1 --- a/linux-2.6-xen-sparse/drivers/xen/net_driver_util.c	Wed Mar 22 08:57:48 2006 -0700
    20.2 +++ b/linux-2.6-xen-sparse/drivers/xen/net_driver_util.c	Wed Mar 22 09:12:48 2006 -0700
    20.3 @@ -4,9 +4,11 @@
    20.4   *
    20.5   * Copyright (c) 2005 XenSource Ltd.
    20.6   * 
    20.7 - * This file may be distributed separately from the Linux kernel, or
    20.8 - * incorporated into other software packages, subject to the following
    20.9 - * license:
   20.10 + * This program is free software; you can redistribute it and/or
   20.11 + * modify it under the terms of the GNU General Public License version 2
   20.12 + * as published by the Free Software Foundation; or, when distributed
   20.13 + * separately from the Linux kernel or incorporated into other
   20.14 + * software packages, subject to the following license:
   20.15   * 
   20.16   * Permission is hereby granted, free of charge, to any person obtaining a
   20.17   * copy of this source file (the "Software"), to deal in the Software without
   20.18 @@ -27,7 +29,6 @@
   20.19   * DEALINGS IN THE SOFTWARE.
   20.20   */
   20.21  
   20.22 -
   20.23  #include <linux/if_ether.h>
   20.24  #include <linux/err.h>
   20.25  #include <linux/module.h>
   20.26 @@ -54,7 +55,7 @@ int xen_net_read_mac(struct xenbus_devic
   20.27  	kfree(macstr);
   20.28  	return 0;
   20.29  }
   20.30 -EXPORT_SYMBOL(xen_net_read_mac);
   20.31 +EXPORT_SYMBOL_GPL(xen_net_read_mac);
   20.32  
   20.33  /*
   20.34   * Local variables:
    21.1 --- a/linux-2.6-xen-sparse/drivers/xen/netback/common.h	Wed Mar 22 08:57:48 2006 -0700
    21.2 +++ b/linux-2.6-xen-sparse/drivers/xen/netback/common.h	Wed Mar 22 09:12:48 2006 -0700
    21.3 @@ -1,5 +1,29 @@
    21.4  /******************************************************************************
    21.5   * arch/xen/drivers/netif/backend/common.h
    21.6 + * 
    21.7 + * This program is free software; you can redistribute it and/or
    21.8 + * modify it under the terms of the GNU General Public License version 2
    21.9 + * as published by the Free Software Foundation; or, when distributed
   21.10 + * separately from the Linux kernel or incorporated into other
   21.11 + * software packages, subject to the following license:
   21.12 + * 
   21.13 + * Permission is hereby granted, free of charge, to any person obtaining a copy
   21.14 + * of this source file (the "Software"), to deal in the Software without
   21.15 + * restriction, including without limitation the rights to use, copy, modify,
   21.16 + * merge, publish, distribute, sublicense, and/or sell copies of the Software,
   21.17 + * and to permit persons to whom the Software is furnished to do so, subject to
   21.18 + * the following conditions:
   21.19 + * 
   21.20 + * The above copyright notice and this permission notice shall be included in
   21.21 + * all copies or substantial portions of the Software.
   21.22 + * 
   21.23 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   21.24 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   21.25 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
   21.26 + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
   21.27 + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
   21.28 + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
   21.29 + * IN THE SOFTWARE.
   21.30   */
   21.31  
   21.32  #ifndef __NETIF__BACKEND__COMMON_H__
    22.1 --- a/linux-2.6-xen-sparse/drivers/xen/netback/interface.c	Wed Mar 22 08:57:48 2006 -0700
    22.2 +++ b/linux-2.6-xen-sparse/drivers/xen/netback/interface.c	Wed Mar 22 09:12:48 2006 -0700
    22.3 @@ -4,6 +4,30 @@
    22.4   * Network-device interface management.
    22.5   * 
    22.6   * Copyright (c) 2004-2005, Keir Fraser
    22.7 + * 
    22.8 + * This program is free software; you can redistribute it and/or
    22.9 + * modify it under the terms of the GNU General Public License version 2
   22.10 + * as published by the Free Software Foundation; or, when distributed
   22.11 + * separately from the Linux kernel or incorporated into other
   22.12 + * software packages, subject to the following license:
   22.13 + * 
   22.14 + * Permission is hereby granted, free of charge, to any person obtaining a copy
   22.15 + * of this source file (the "Software"), to deal in the Software without
   22.16 + * restriction, including without limitation the rights to use, copy, modify,
   22.17 + * merge, publish, distribute, sublicense, and/or sell copies of the Software,
   22.18 + * and to permit persons to whom the Software is furnished to do so, subject to
   22.19 + * the following conditions:
   22.20 + * 
   22.21 + * The above copyright notice and this permission notice shall be included in
   22.22 + * all copies or substantial portions of the Software.
   22.23 + * 
   22.24 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   22.25 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   22.26 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
   22.27 + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
   22.28 + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
   22.29 + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
   22.30 + * IN THE SOFTWARE.
   22.31   */
   22.32  
   22.33  #include "common.h"
    23.1 --- a/linux-2.6-xen-sparse/drivers/xen/netback/loopback.c	Wed Mar 22 08:57:48 2006 -0700
    23.2 +++ b/linux-2.6-xen-sparse/drivers/xen/netback/loopback.c	Wed Mar 22 09:12:48 2006 -0700
    23.3 @@ -19,6 +19,30 @@
    23.4   * (to avoid confusing the Etherbridge).
    23.5   * 
    23.6   * Copyright (c) 2005 K A Fraser
    23.7 + * 
    23.8 + * This program is free software; you can redistribute it and/or
    23.9 + * modify it under the terms of the GNU General Public License version 2
   23.10 + * as published by the Free Software Foundation; or, when distributed
   23.11 + * separately from the Linux kernel or incorporated into other
   23.12 + * software packages, subject to the following license:
   23.13 + * 
   23.14 + * Permission is hereby granted, free of charge, to any person obtaining a copy
   23.15 + * of this source file (the "Software"), to deal in the Software without
   23.16 + * restriction, including without limitation the rights to use, copy, modify,
   23.17 + * merge, publish, distribute, sublicense, and/or sell copies of the Software,
   23.18 + * and to permit persons to whom the Software is furnished to do so, subject to
   23.19 + * the following conditions:
   23.20 + * 
   23.21 + * The above copyright notice and this permission notice shall be included in
   23.22 + * all copies or substantial portions of the Software.
   23.23 + * 
   23.24 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   23.25 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   23.26 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
   23.27 + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
   23.28 + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
   23.29 + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
   23.30 + * IN THE SOFTWARE.
   23.31   */
   23.32  
   23.33  #include <linux/config.h>
    24.1 --- a/linux-2.6-xen-sparse/drivers/xen/netback/netback.c	Wed Mar 22 08:57:48 2006 -0700
    24.2 +++ b/linux-2.6-xen-sparse/drivers/xen/netback/netback.c	Wed Mar 22 09:12:48 2006 -0700
    24.3 @@ -8,6 +8,30 @@
    24.4   *  drivers/xen/netfront/netfront.c
    24.5   * 
    24.6   * Copyright (c) 2002-2005, K A Fraser
    24.7 + * 
    24.8 + * This program is free software; you can redistribute it and/or
    24.9 + * modify it under the terms of the GNU General Public License version 2
   24.10 + * as published by the Free Software Foundation; or, when distributed
   24.11 + * separately from the Linux kernel or incorporated into other
   24.12 + * software packages, subject to the following license:
   24.13 + * 
   24.14 + * Permission is hereby granted, free of charge, to any person obtaining a copy
   24.15 + * of this source file (the "Software"), to deal in the Software without
   24.16 + * restriction, including without limitation the rights to use, copy, modify,
   24.17 + * merge, publish, distribute, sublicense, and/or sell copies of the Software,
   24.18 + * and to permit persons to whom the Software is furnished to do so, subject to
   24.19 + * the following conditions:
   24.20 + * 
   24.21 + * The above copyright notice and this permission notice shall be included in
   24.22 + * all copies or substantial portions of the Software.
   24.23 + * 
   24.24 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   24.25 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   24.26 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
   24.27 + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
   24.28 + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
   24.29 + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
   24.30 + * IN THE SOFTWARE.
   24.31   */
   24.32  
   24.33  #include "common.h"
    25.1 --- a/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c	Wed Mar 22 08:57:48 2006 -0700
    25.2 +++ b/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c	Wed Mar 22 09:12:48 2006 -0700
    25.3 @@ -68,9 +68,6 @@
    25.4  #define NET_TX_RING_SIZE __RING_SIZE((netif_tx_sring_t *)0, PAGE_SIZE)
    25.5  #define NET_RX_RING_SIZE __RING_SIZE((netif_rx_sring_t *)0, PAGE_SIZE)
    25.6  
    25.7 -#ifndef __GFP_NOWARN
    25.8 -#define __GFP_NOWARN 0
    25.9 -#endif
   25.10  #define alloc_xen_skb(_l) __dev_alloc_skb((_l), GFP_ATOMIC|__GFP_NOWARN)
   25.11  
   25.12  #define init_skb_shinfo(_skb)                         \
    26.1 --- a/linux-2.6-xen-sparse/drivers/xen/tpmfront/tpmfront.c	Wed Mar 22 08:57:48 2006 -0700
    26.2 +++ b/linux-2.6-xen-sparse/drivers/xen/tpmfront/tpmfront.c	Wed Mar 22 09:12:48 2006 -0700
    26.3 @@ -8,9 +8,12 @@
    26.4   *
    26.5   * Copyright (c) 2002-2004, K A Fraser
    26.6   *
    26.7 - * This file may be distributed separately from the Linux kernel, or
    26.8 - * incorporated into other software packages, subject to the following license:
    26.9 - *
   26.10 + * This program is free software; you can redistribute it and/or
   26.11 + * modify it under the terms of the GNU General Public License version 2
   26.12 + * as published by the Free Software Foundation; or, when distributed
   26.13 + * separately from the Linux kernel or incorporated into other
   26.14 + * software packages, subject to the following license:
   26.15 + * 
   26.16   * Permission is hereby granted, free of charge, to any person obtaining a copy
   26.17   * of this source file (the "Software"), to deal in the Software without
   26.18   * restriction, including without limitation the rights to use, copy, modify,
   26.19 @@ -40,8 +43,7 @@
   26.20  #include <linux/init.h>
   26.21  #include <xen/tpmfe.h>
   26.22  #include <linux/err.h>
   26.23 -
   26.24 -#include <asm/semaphore.h>
   26.25 +#include <linux/mutex.h>
   26.26  #include <asm/io.h>
   26.27  #include <xen/evtchn.h>
   26.28  #include <xen/interface/grant_table.h>
   26.29 @@ -150,8 +152,8 @@ static inline void tpm_private_free(void
   26.30  
   26.31  **************************************************************/
   26.32  
   26.33 -static DECLARE_MUTEX(upperlayer_lock);
   26.34 -static DECLARE_MUTEX(suspend_lock);
   26.35 +static DEFINE_MUTEX(upperlayer_lock);
   26.36 +static DEFINE_MUTEX(suspend_lock);
   26.37  static struct tpmfe_device *upperlayer_tpmfe;
   26.38  
   26.39  /*
   26.40 @@ -161,9 +163,9 @@ int tpm_fe_send(struct tpm_private *tp, 
   26.41  {
   26.42  	int sent;
   26.43  
   26.44 -	down(&suspend_lock);
   26.45 +	mutex_lock(&suspend_lock);
   26.46  	sent = tpm_xmit(tp, buf, count, 0, ptr);
   26.47 -	up(&suspend_lock);
   26.48 +	mutex_unlock(&suspend_lock);
   26.49  
   26.50  	return sent;
   26.51  }
   26.52 @@ -176,7 +178,7 @@ int tpm_fe_register_receiver(struct tpmf
   26.53  {
   26.54  	int rc = 0;
   26.55  
   26.56 -	down(&upperlayer_lock);
   26.57 +	mutex_lock(&upperlayer_lock);
   26.58  	if (NULL == upperlayer_tpmfe) {
   26.59  		upperlayer_tpmfe = tpmfe_dev;
   26.60  		tpmfe_dev->max_tx_size = TPMIF_TX_RING_SIZE * PAGE_SIZE;
   26.61 @@ -187,7 +189,7 @@ int tpm_fe_register_receiver(struct tpmf
   26.62  	} else {
   26.63  		rc = -EBUSY;
   26.64  	}
   26.65 -	up(&upperlayer_lock);
   26.66 +	mutex_unlock(&upperlayer_lock);
   26.67  	return rc;
   26.68  }
   26.69  EXPORT_SYMBOL(tpm_fe_register_receiver);
   26.70 @@ -197,9 +199,9 @@ EXPORT_SYMBOL(tpm_fe_register_receiver);
   26.71   */
   26.72  void tpm_fe_unregister_receiver(void)
   26.73  {
   26.74 -	down(&upperlayer_lock);
   26.75 +	mutex_lock(&upperlayer_lock);
   26.76  	upperlayer_tpmfe = NULL;
   26.77 -	up(&upperlayer_lock);
   26.78 +	mutex_unlock(&upperlayer_lock);
   26.79  }
   26.80  EXPORT_SYMBOL(tpm_fe_unregister_receiver);
   26.81  
   26.82 @@ -212,12 +214,12 @@ static int tpm_fe_send_upperlayer(const 
   26.83  {
   26.84  	int rc = 0;
   26.85  
   26.86 -	down(&upperlayer_lock);
   26.87 +	mutex_lock(&upperlayer_lock);
   26.88  
   26.89  	if (upperlayer_tpmfe && upperlayer_tpmfe->receive)
   26.90  		rc = upperlayer_tpmfe->receive(buf, count, ptr);
   26.91  
   26.92 -	up(&upperlayer_lock);
   26.93 +	mutex_unlock(&upperlayer_lock);
   26.94  	return rc;
   26.95  }
   26.96  
   26.97 @@ -412,7 +414,7 @@ tpmfront_suspend(struct xenbus_device *d
   26.98  	u32 ctr;
   26.99  
  26.100  	/* lock, so no app can send */
  26.101 -	down(&suspend_lock);
  26.102 +	mutex_lock(&suspend_lock);
  26.103  	tp->is_suspended = 1;
  26.104  
  26.105  	for (ctr = 0; atomic_read(&tp->tx_busy) && ctr <= 25; ctr++) {
  26.106 @@ -644,7 +646,7 @@ static void tpmif_notify_upperlayer(stru
  26.107  	 * Notify upper layer about the state of the connection
  26.108  	 * to the BE.
  26.109  	 */
  26.110 -	down(&upperlayer_lock);
  26.111 +	mutex_lock(&upperlayer_lock);
  26.112  
  26.113  	if (upperlayer_tpmfe != NULL) {
  26.114  		if (tp->is_connected) {
  26.115 @@ -653,7 +655,7 @@ static void tpmif_notify_upperlayer(stru
  26.116  			upperlayer_tpmfe->status(0);
  26.117  		}
  26.118  	}
  26.119 -	up(&upperlayer_lock);
  26.120 +	mutex_unlock(&upperlayer_lock);
  26.121  }
  26.122  
  26.123  
  26.124 @@ -662,21 +664,21 @@ static void tpmif_set_connected_state(st
  26.125  	/*
  26.126  	 * Don't notify upper layer if we are in suspend mode and
  26.127  	 * should disconnect - assumption is that we will resume
  26.128 -	 * The semaphore keeps apps from sending.
  26.129 +	 * The mutex keeps apps from sending.
  26.130  	 */
  26.131  	if (is_connected == 0 && tp->is_suspended == 1) {
  26.132  		return;
  26.133  	}
  26.134  
  26.135  	/*
  26.136 -	 * Unlock the semaphore if we are connected again
  26.137 +	 * Unlock the mutex if we are connected again
  26.138  	 * after being suspended - now resuming.
  26.139  	 * This also removes the suspend state.
  26.140  	 */
  26.141  	if (is_connected == 1 && tp->is_suspended == 1) {
  26.142  		tp->is_suspended = 0;
  26.143  		/* unlock, so apps can resume sending */
  26.144 -		up(&suspend_lock);
  26.145 +		mutex_unlock(&suspend_lock);
  26.146  	}
  26.147  
  26.148  	if (is_connected != tp->is_connected) {
    27.1 --- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_client.c	Wed Mar 22 08:57:48 2006 -0700
    27.2 +++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_client.c	Wed Mar 22 09:12:48 2006 -0700
    27.3 @@ -5,8 +5,11 @@
    27.4   *
    27.5   * Copyright (C) 2005 XenSource Ltd
    27.6   * 
    27.7 - * This file may be distributed separately from the Linux kernel, or
    27.8 - * incorporated into other software packages, subject to the following license:
    27.9 + * This program is free software; you can redistribute it and/or
   27.10 + * modify it under the terms of the GNU General Public License version 2
   27.11 + * as published by the Free Software Foundation; or, when distributed
   27.12 + * separately from the Linux kernel or incorporated into other
   27.13 + * software packages, subject to the following license:
   27.14   * 
   27.15   * Permission is hereby granted, free of charge, to any person obtaining a copy
   27.16   * of this source file (the "Software"), to deal in the Software without
   27.17 @@ -58,7 +61,7 @@ int xenbus_watch_path(struct xenbus_devi
   27.18  
   27.19  	return err;
   27.20  }
   27.21 -EXPORT_SYMBOL(xenbus_watch_path);
   27.22 +EXPORT_SYMBOL_GPL(xenbus_watch_path);
   27.23  
   27.24  
   27.25  int xenbus_watch_path2(struct xenbus_device *dev, const char *path,
   27.26 @@ -78,7 +81,7 @@ int xenbus_watch_path2(struct xenbus_dev
   27.27  		kfree(state);
   27.28  	return err;
   27.29  }
   27.30 -EXPORT_SYMBOL(xenbus_watch_path2);
   27.31 +EXPORT_SYMBOL_GPL(xenbus_watch_path2);
   27.32  
   27.33  
   27.34  int xenbus_switch_state(struct xenbus_device *dev,
   27.35 @@ -115,7 +118,7 @@ int xenbus_switch_state(struct xenbus_de
   27.36  
   27.37  	return 0;
   27.38  }
   27.39 -EXPORT_SYMBOL(xenbus_switch_state);
   27.40 +EXPORT_SYMBOL_GPL(xenbus_switch_state);
   27.41  
   27.42  
   27.43  /**
   27.44 @@ -178,7 +181,7 @@ void xenbus_dev_error(struct xenbus_devi
   27.45  	_dev_error(dev, err, fmt, ap);
   27.46  	va_end(ap);
   27.47  }
   27.48 -EXPORT_SYMBOL(xenbus_dev_error);
   27.49 +EXPORT_SYMBOL_GPL(xenbus_dev_error);
   27.50  
   27.51  
   27.52  void xenbus_dev_fatal(struct xenbus_device *dev, int err, const char *fmt,
   27.53 @@ -192,7 +195,7 @@ void xenbus_dev_fatal(struct xenbus_devi
   27.54  
   27.55  	xenbus_switch_state(dev, XBT_NULL, XenbusStateClosing);
   27.56  }
   27.57 -EXPORT_SYMBOL(xenbus_dev_fatal);
   27.58 +EXPORT_SYMBOL_GPL(xenbus_dev_fatal);
   27.59  
   27.60  
   27.61  int xenbus_grant_ring(struct xenbus_device *dev, unsigned long ring_mfn)
   27.62 @@ -202,7 +205,7 @@ int xenbus_grant_ring(struct xenbus_devi
   27.63  		xenbus_dev_fatal(dev, err, "granting access to ring page");
   27.64  	return err;
   27.65  }
   27.66 -EXPORT_SYMBOL(xenbus_grant_ring);
   27.67 +EXPORT_SYMBOL_GPL(xenbus_grant_ring);
   27.68  
   27.69  
   27.70  int xenbus_alloc_evtchn(struct xenbus_device *dev, int *port)
   27.71 @@ -219,7 +222,7 @@ int xenbus_alloc_evtchn(struct xenbus_de
   27.72  		*port = op.u.alloc_unbound.port;
   27.73  	return err;
   27.74  }
   27.75 -EXPORT_SYMBOL(xenbus_alloc_evtchn);
   27.76 +EXPORT_SYMBOL_GPL(xenbus_alloc_evtchn);
   27.77  
   27.78  
   27.79  int xenbus_bind_evtchn(struct xenbus_device *dev, int remote_port, int *port)
   27.80 @@ -238,7 +241,7 @@ int xenbus_bind_evtchn(struct xenbus_dev
   27.81  		*port = op.u.bind_interdomain.local_port;
   27.82  	return err;
   27.83  }
   27.84 -EXPORT_SYMBOL(xenbus_bind_evtchn);
   27.85 +EXPORT_SYMBOL_GPL(xenbus_bind_evtchn);
   27.86  
   27.87  
   27.88  int xenbus_free_evtchn(struct xenbus_device *dev, int port)
   27.89 @@ -290,7 +293,7 @@ int xenbus_map_ring_valloc(struct xenbus
   27.90  	*vaddr = area->addr;
   27.91  	return 0;
   27.92  }
   27.93 -EXPORT_SYMBOL(xenbus_map_ring_valloc);
   27.94 +EXPORT_SYMBOL_GPL(xenbus_map_ring_valloc);
   27.95  
   27.96  
   27.97  int xenbus_map_ring(struct xenbus_device *dev, int gnt_ref,
   27.98 @@ -314,7 +317,7 @@ int xenbus_map_ring(struct xenbus_device
   27.99  
  27.100  	return op.status;
  27.101  }
  27.102 -EXPORT_SYMBOL(xenbus_map_ring);
  27.103 +EXPORT_SYMBOL_GPL(xenbus_map_ring);
  27.104  
  27.105  
  27.106  /* Based on Rusty Russell's skeleton driver's unmap_page */
  27.107 @@ -359,7 +362,7 @@ int xenbus_unmap_ring_vfree(struct xenbu
  27.108  
  27.109  	return op.status;
  27.110  }
  27.111 -EXPORT_SYMBOL(xenbus_unmap_ring_vfree);
  27.112 +EXPORT_SYMBOL_GPL(xenbus_unmap_ring_vfree);
  27.113  
  27.114  
  27.115  int xenbus_unmap_ring(struct xenbus_device *dev,
  27.116 @@ -379,7 +382,7 @@ int xenbus_unmap_ring(struct xenbus_devi
  27.117  
  27.118  	return op.status;
  27.119  }
  27.120 -EXPORT_SYMBOL(xenbus_unmap_ring);
  27.121 +EXPORT_SYMBOL_GPL(xenbus_unmap_ring);
  27.122  
  27.123  
  27.124  XenbusState xenbus_read_driver_state(const char *path)
  27.125 @@ -391,7 +394,7 @@ XenbusState xenbus_read_driver_state(con
  27.126  
  27.127  	return result;
  27.128  }
  27.129 -EXPORT_SYMBOL(xenbus_read_driver_state);
  27.130 +EXPORT_SYMBOL_GPL(xenbus_read_driver_state);
  27.131  
  27.132  
  27.133  /*
    28.1 --- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_comms.c	Wed Mar 22 08:57:48 2006 -0700
    28.2 +++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_comms.c	Wed Mar 22 09:12:48 2006 -0700
    28.3 @@ -5,8 +5,11 @@
    28.4   *
    28.5   * Copyright (C) 2005 Rusty Russell, IBM Corporation
    28.6   * 
    28.7 - * This file may be distributed separately from the Linux kernel, or
    28.8 - * incorporated into other software packages, subject to the following license:
    28.9 + * This program is free software; you can redistribute it and/or
   28.10 + * modify it under the terms of the GNU General Public License version 2
   28.11 + * as published by the Free Software Foundation; or, when distributed
   28.12 + * separately from the Linux kernel or incorporated into other
   28.13 + * software packages, subject to the following license:
   28.14   * 
   28.15   * Permission is hereby granted, free of charge, to any person obtaining a copy
   28.16   * of this source file (the "Software"), to deal in the Software without
    29.1 --- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_comms.h	Wed Mar 22 08:57:48 2006 -0700
    29.2 +++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_comms.h	Wed Mar 22 09:12:48 2006 -0700
    29.3 @@ -3,8 +3,11 @@
    29.4   * 
    29.5   * Copyright (C) 2005 Rusty Russell, IBM Corporation
    29.6   *
    29.7 - * This file may be distributed separately from the Linux kernel, or
    29.8 - * incorporated into other software packages, subject to the following license:
    29.9 + * This program is free software; you can redistribute it and/or
   29.10 + * modify it under the terms of the GNU General Public License version 2
   29.11 + * as published by the Free Software Foundation; or, when distributed
   29.12 + * separately from the Linux kernel or incorporated into other
   29.13 + * software packages, subject to the following license:
   29.14   * 
   29.15   * Permission is hereby granted, free of charge, to any person obtaining a copy
   29.16   * of this source file (the "Software"), to deal in the Software without
    30.1 --- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_dev.c	Wed Mar 22 08:57:48 2006 -0700
    30.2 +++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_dev.c	Wed Mar 22 09:12:48 2006 -0700
    30.3 @@ -7,8 +7,11 @@
    30.4   * Copyright (c) 2005, Christian Limpach
    30.5   * Copyright (c) 2005, Rusty Russell, IBM Corporation
    30.6   * 
    30.7 - * This file may be distributed separately from the Linux kernel, or
    30.8 - * incorporated into other software packages, subject to the following license:
    30.9 + * This program is free software; you can redistribute it and/or
   30.10 + * modify it under the terms of the GNU General Public License version 2
   30.11 + * as published by the Free Software Foundation; or, when distributed
   30.12 + * separately from the Linux kernel or incorporated into other
   30.13 + * software packages, subject to the following license:
   30.14   * 
   30.15   * Permission is hereby granted, free of charge, to any person obtaining a copy
   30.16   * of this source file (the "Software"), to deal in the Software without
    31.1 --- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c	Wed Mar 22 08:57:48 2006 -0700
    31.2 +++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c	Wed Mar 22 09:12:48 2006 -0700
    31.3 @@ -5,8 +5,11 @@
    31.4   * Copyright (C) 2005 Mike Wray, Hewlett-Packard
    31.5   * Copyright (C) 2005 XenSource Ltd
    31.6   * 
    31.7 - * This file may be distributed separately from the Linux kernel, or
    31.8 - * incorporated into other software packages, subject to the following license:
    31.9 + * This program is free software; you can redistribute it and/or
   31.10 + * modify it under the terms of the GNU General Public License version 2
   31.11 + * as published by the Free Software Foundation; or, when distributed
   31.12 + * separately from the Linux kernel or incorporated into other
   31.13 + * software packages, subject to the following license:
   31.14   * 
   31.15   * Permission is hereby granted, free of charge, to any person obtaining a copy
   31.16   * of this source file (the "Software"), to deal in the Software without
   31.17 @@ -49,9 +52,7 @@
   31.18  
   31.19  #include "xenbus_comms.h"
   31.20  
   31.21 -extern struct semaphore xenwatch_mutex;
   31.22 -
   31.23 -#define streq(a, b) (strcmp((a), (b)) == 0)
   31.24 +extern struct mutex xenwatch_mutex;
   31.25  
   31.26  static struct notifier_block *xenstore_chain;
   31.27  
   31.28 @@ -59,8 +60,8 @@ static struct notifier_block *xenstore_c
   31.29  static const struct xenbus_device_id *
   31.30  match_device(const struct xenbus_device_id *arr, struct xenbus_device *dev)
   31.31  {
   31.32 -	for (; !streq(arr->devicetype, ""); arr++) {
   31.33 -		if (streq(arr->devicetype, dev->devicetype))
   31.34 +	for (; *arr->devicetype != '\0'; arr++) {
   31.35 +		if (!strcmp(arr->devicetype, dev->devicetype))
   31.36  			return arr;
   31.37  	}
   31.38  	return NULL;
   31.39 @@ -106,6 +107,23 @@ static int frontend_bus_id(char bus_id[B
   31.40  }
   31.41  
   31.42  
   31.43 +static void free_otherend_details(struct xenbus_device *dev)
   31.44 +{
   31.45 +	kfree(dev->otherend);
   31.46 +	dev->otherend = NULL;
   31.47 +}
   31.48 +
   31.49 +
   31.50 +static void free_otherend_watch(struct xenbus_device *dev)
   31.51 +{
   31.52 +	if (dev->otherend_watch.node) {
   31.53 +		unregister_xenbus_watch(&dev->otherend_watch);
   31.54 +		kfree(dev->otherend_watch.node);
   31.55 +		dev->otherend_watch.node = NULL;
   31.56 +	}
   31.57 +}
   31.58 +
   31.59 +
   31.60  static int read_otherend_details(struct xenbus_device *xendev,
   31.61  				 char *id_node, char *path_node)
   31.62  {
   31.63 @@ -123,8 +141,7 @@ static int read_otherend_details(struct 
   31.64  	    !xenbus_exists(XBT_NULL, xendev->otherend, "")) {
   31.65  		xenbus_dev_fatal(xendev, -ENOENT, "missing other end from %s",
   31.66  				 xendev->nodename);
   31.67 -		kfree(xendev->otherend);
   31.68 -		xendev->otherend = NULL;
   31.69 +		free_otherend_details(xendev);
   31.70  		return -ENOENT;
   31.71  	}
   31.72  
   31.73 @@ -144,23 +161,6 @@ static int read_frontend_details(struct 
   31.74  }
   31.75  
   31.76  
   31.77 -static void free_otherend_details(struct xenbus_device *dev)
   31.78 -{
   31.79 -	kfree(dev->otherend);
   31.80 -	dev->otherend = NULL;
   31.81 -}
   31.82 -
   31.83 -
   31.84 -static void free_otherend_watch(struct xenbus_device *dev)
   31.85 -{
   31.86 -	if (dev->otherend_watch.node) {
   31.87 -		unregister_xenbus_watch(&dev->otherend_watch);
   31.88 -		kfree(dev->otherend_watch.node);
   31.89 -		dev->otherend_watch.node = NULL;
   31.90 -	}
   31.91 -}
   31.92 -
   31.93 -
   31.94  /* Bus type for frontend drivers. */
   31.95  static int xenbus_probe_frontend(const char *type, const char *name);
   31.96  static struct xen_bus_type xenbus_frontend = {
   31.97 @@ -396,9 +396,9 @@ static int xenbus_register_driver_common
   31.98  	drv->driver.probe = xenbus_dev_probe;
   31.99  	drv->driver.remove = xenbus_dev_remove;
  31.100  
  31.101 -	down(&xenwatch_mutex);
  31.102 +	mutex_lock(&xenwatch_mutex);
  31.103  	ret = driver_register(&drv->driver);
  31.104 -	up(&xenwatch_mutex);
  31.105 +	mutex_unlock(&xenwatch_mutex);
  31.106  	return ret;
  31.107  }
  31.108  
  31.109 @@ -408,7 +408,7 @@ int xenbus_register_frontend(struct xenb
  31.110  
  31.111  	return xenbus_register_driver_common(drv, &xenbus_frontend);
  31.112  }
  31.113 -EXPORT_SYMBOL(xenbus_register_frontend);
  31.114 +EXPORT_SYMBOL_GPL(xenbus_register_frontend);
  31.115  
  31.116  int xenbus_register_backend(struct xenbus_driver *drv)
  31.117  {
  31.118 @@ -416,13 +416,13 @@ int xenbus_register_backend(struct xenbu
  31.119  
  31.120  	return xenbus_register_driver_common(drv, &xenbus_backend);
  31.121  }
  31.122 -EXPORT_SYMBOL(xenbus_register_backend);
  31.123 +EXPORT_SYMBOL_GPL(xenbus_register_backend);
  31.124  
  31.125  void xenbus_unregister_driver(struct xenbus_driver *drv)
  31.126  {
  31.127  	driver_unregister(&drv->driver);
  31.128  }
  31.129 -EXPORT_SYMBOL(xenbus_unregister_driver);
  31.130 +EXPORT_SYMBOL_GPL(xenbus_unregister_driver);
  31.131  
  31.132  struct xb_find_info
  31.133  {
  31.134 @@ -435,7 +435,7 @@ static int cmp_dev(struct device *dev, v
  31.135  	struct xenbus_device *xendev = to_xenbus_device(dev);
  31.136  	struct xb_find_info *info = data;
  31.137  
  31.138 -	if (streq(xendev->nodename, info->nodename)) {
  31.139 +	if (!strcmp(xendev->nodename, info->nodename)) {
  31.140  		info->dev = xendev;
  31.141  		get_device(dev);
  31.142  		return 1;
  31.143 @@ -487,15 +487,10 @@ static void xenbus_cleanup_devices(const
  31.144  	} while (info.dev);
  31.145  }
  31.146  
  31.147 -static void xenbus_dev_free(struct xenbus_device *xendev)
  31.148 -{
  31.149 -	kfree(xendev);
  31.150 -}
  31.151 -
  31.152  static void xenbus_dev_release(struct device *dev)
  31.153  {
  31.154  	if (dev)
  31.155 -		xenbus_dev_free(to_xenbus_device(dev));
  31.156 +		kfree(to_xenbus_device(dev));
  31.157  }
  31.158  
  31.159  /* Simplified asprintf. */
  31.160 @@ -584,7 +579,7 @@ static int xenbus_probe_node(struct xen_
  31.161  
  31.162  	return 0;
  31.163  fail:
  31.164 -	xenbus_dev_free(xendev);
  31.165 +	kfree(xendev);
  31.166  	return err;
  31.167  }
  31.168  
  31.169 @@ -845,7 +840,7 @@ void xenbus_suspend(void)
  31.170  	bus_for_each_dev(&xenbus_backend.bus, NULL, NULL, suspend_dev);
  31.171  	xs_suspend();
  31.172  }
  31.173 -EXPORT_SYMBOL(xenbus_suspend);
  31.174 +EXPORT_SYMBOL_GPL(xenbus_suspend);
  31.175  
  31.176  void xenbus_resume(void)
  31.177  {
  31.178 @@ -854,7 +849,7 @@ void xenbus_resume(void)
  31.179  	bus_for_each_dev(&xenbus_frontend.bus, NULL, NULL, resume_dev);
  31.180  	bus_for_each_dev(&xenbus_backend.bus, NULL, NULL, resume_dev);
  31.181  }
  31.182 -EXPORT_SYMBOL(xenbus_resume);
  31.183 +EXPORT_SYMBOL_GPL(xenbus_resume);
  31.184  
  31.185  
  31.186  /* A flag to determine if xenstored is 'ready' (i.e. has started) */
  31.187 @@ -872,13 +867,13 @@ int register_xenstore_notifier(struct no
  31.188  
  31.189  	return ret;
  31.190  }
  31.191 -EXPORT_SYMBOL(register_xenstore_notifier);
  31.192 +EXPORT_SYMBOL_GPL(register_xenstore_notifier);
  31.193  
  31.194  void unregister_xenstore_notifier(struct notifier_block *nb)
  31.195  {
  31.196  	notifier_chain_unregister(&xenstore_chain, nb);
  31.197  }
  31.198 -EXPORT_SYMBOL(unregister_xenstore_notifier);
  31.199 +EXPORT_SYMBOL_GPL(unregister_xenstore_notifier);
  31.200  
  31.201  
  31.202  static int all_devices_ready_(struct device *dev, void *data)
  31.203 @@ -1019,10 +1014,6 @@ static int __init xenbus_probe_init(void
  31.204  		if (!page)
  31.205  			return -ENOMEM;
  31.206  
  31.207 -		/* We don't refcnt properly, so set reserved on page.
  31.208 -		 * (this allocation is permanent) */
  31.209 -		SetPageReserved(virt_to_page(page));
  31.210 -
  31.211  		xen_start_info->store_mfn =
  31.212  			pfn_to_mfn(virt_to_phys((void *)page) >>
  31.213  				   PAGE_SHIFT);
    32.1 --- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_xs.c	Wed Mar 22 08:57:48 2006 -0700
    32.2 +++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_xs.c	Wed Mar 22 09:12:48 2006 -0700
    32.3 @@ -6,8 +6,11 @@
    32.4   *
    32.5   * Copyright (C) 2005 Rusty Russell, IBM Corporation
    32.6   * 
    32.7 - * This file may be distributed separately from the Linux kernel, or
    32.8 - * incorporated into other software packages, subject to the following license:
    32.9 + * This program is free software; you can redistribute it and/or
   32.10 + * modify it under the terms of the GNU General Public License version 2
   32.11 + * as published by the Free Software Foundation; or, when distributed
   32.12 + * separately from the Linux kernel or incorporated into other
   32.13 + * software packages, subject to the following license:
   32.14   * 
   32.15   * Permission is hereby granted, free of charge, to any person obtaining a copy
   32.16   * of this source file (the "Software"), to deal in the Software without
   32.17 @@ -38,14 +41,13 @@
   32.18  #include <linux/slab.h>
   32.19  #include <linux/fcntl.h>
   32.20  #include <linux/kthread.h>
   32.21 +#include <linux/rwsem.h>
   32.22  #include <xen/xenbus.h>
   32.23  #include "xenbus_comms.h"
   32.24  
   32.25  /* xenbus_probe.c */
   32.26  extern char *kasprintf(const char *fmt, ...);
   32.27  
   32.28 -#define streq(a, b) (strcmp((a), (b)) == 0)
   32.29 -
   32.30  struct xs_stored_msg {
   32.31  	struct list_head list;
   32.32  
   32.33 @@ -73,7 +75,7 @@ struct xs_handle {
   32.34  	wait_queue_head_t reply_waitq;
   32.35  
   32.36  	/* One request at a time. */
   32.37 -	struct semaphore request_mutex;
   32.38 +	struct mutex request_mutex;
   32.39  
   32.40  	/* Protect transactions against save/restore. */
   32.41  	struct rw_semaphore suspend_mutex;
   32.42 @@ -96,14 +98,14 @@ static DEFINE_SPINLOCK(watch_events_lock
   32.43   * carrying out work.
   32.44   */
   32.45  static pid_t xenwatch_pid;
   32.46 -/* static */ DECLARE_MUTEX(xenwatch_mutex);
   32.47 +/* static */ DEFINE_MUTEX(xenwatch_mutex);
   32.48  static DECLARE_WAIT_QUEUE_HEAD(watch_events_waitq);
   32.49  
   32.50  static int get_error(const char *errorstring)
   32.51  {
   32.52  	unsigned int i;
   32.53  
   32.54 -	for (i = 0; !streq(errorstring, xsd_errors[i].errstring); i++) {
   32.55 +	for (i = 0; strcmp(errorstring, xsd_errors[i].errstring) != 0; i++) {
   32.56  		if (i == ARRAY_SIZE(xsd_errors) - 1) {
   32.57  			printk(KERN_WARNING
   32.58  			       "XENBUS xen store gave: unknown error %s",
   32.59 @@ -153,12 +155,12 @@ void xenbus_debug_write(const char *str,
   32.60  	msg.type = XS_DEBUG;
   32.61  	msg.len = sizeof("print") + count + 1;
   32.62  
   32.63 -	down(&xs_state.request_mutex);
   32.64 +	mutex_lock(&xs_state.request_mutex);
   32.65  	xb_write(&msg, sizeof(msg));
   32.66  	xb_write("print", sizeof("print"));
   32.67  	xb_write(str, count);
   32.68  	xb_write("", 1);
   32.69 -	up(&xs_state.request_mutex);
   32.70 +	mutex_unlock(&xs_state.request_mutex);
   32.71  }
   32.72  
   32.73  void *xenbus_dev_request_and_reply(struct xsd_sockmsg *msg)
   32.74 @@ -170,7 +172,7 @@ void *xenbus_dev_request_and_reply(struc
   32.75  	if (req_msg.type == XS_TRANSACTION_START)
   32.76  		down_read(&xs_state.suspend_mutex);
   32.77  
   32.78 -	down(&xs_state.request_mutex);
   32.79 +	mutex_lock(&xs_state.request_mutex);
   32.80  
   32.81  	err = xb_write(msg, sizeof(*msg) + msg->len);
   32.82  	if (err) {
   32.83 @@ -179,7 +181,7 @@ void *xenbus_dev_request_and_reply(struc
   32.84  	} else
   32.85  		ret = read_reply(&msg->type, &msg->len);
   32.86  
   32.87 -	up(&xs_state.request_mutex);
   32.88 +	mutex_unlock(&xs_state.request_mutex);
   32.89  
   32.90  	if ((msg->type == XS_TRANSACTION_END) ||
   32.91  	    ((req_msg.type == XS_TRANSACTION_START) &&
   32.92 @@ -208,25 +210,25 @@ static void *xs_talkv(xenbus_transaction
   32.93  	for (i = 0; i < num_vecs; i++)
   32.94  		msg.len += iovec[i].iov_len;
   32.95  
   32.96 -	down(&xs_state.request_mutex);
   32.97 +	mutex_lock(&xs_state.request_mutex);
   32.98  
   32.99  	err = xb_write(&msg, sizeof(msg));
  32.100  	if (err) {
  32.101 -		up(&xs_state.request_mutex);
  32.102 +		mutex_unlock(&xs_state.request_mutex);
  32.103  		return ERR_PTR(err);
  32.104  	}
  32.105  
  32.106  	for (i = 0; i < num_vecs; i++) {
  32.107  		err = xb_write(iovec[i].iov_base, iovec[i].iov_len);;
  32.108  		if (err) {
  32.109 -			up(&xs_state.request_mutex);
  32.110 +			mutex_unlock(&xs_state.request_mutex);
  32.111  			return ERR_PTR(err);
  32.112  		}
  32.113  	}
  32.114  
  32.115  	ret = read_reply(&msg.type, len);
  32.116  
  32.117 -	up(&xs_state.request_mutex);
  32.118 +	mutex_unlock(&xs_state.request_mutex);
  32.119  
  32.120  	if (IS_ERR(ret))
  32.121  		return ret;
  32.122 @@ -333,7 +335,7 @@ char **xenbus_directory(xenbus_transacti
  32.123  
  32.124  	return split(strings, len, num);
  32.125  }
  32.126 -EXPORT_SYMBOL(xenbus_directory);
  32.127 +EXPORT_SYMBOL_GPL(xenbus_directory);
  32.128  
  32.129  /* Check if a path exists. Return 1 if it does. */
  32.130  int xenbus_exists(xenbus_transaction_t t,
  32.131 @@ -348,7 +350,7 @@ int xenbus_exists(xenbus_transaction_t t
  32.132  	kfree(d);
  32.133  	return 1;
  32.134  }
  32.135 -EXPORT_SYMBOL(xenbus_exists);
  32.136 +EXPORT_SYMBOL_GPL(xenbus_exists);
  32.137  
  32.138  /* Get the value of a single file.
  32.139   * Returns a kmalloced value: call free() on it after use.
  32.140 @@ -368,7 +370,7 @@ void *xenbus_read(xenbus_transaction_t t
  32.141  	kfree(path);
  32.142  	return ret;
  32.143  }
  32.144 -EXPORT_SYMBOL(xenbus_read);
  32.145 +EXPORT_SYMBOL_GPL(xenbus_read);
  32.146  
  32.147  /* Write the value of a single file.
  32.148   * Returns -err on failure.
  32.149 @@ -393,7 +395,7 @@ int xenbus_write(xenbus_transaction_t t,
  32.150  	kfree(path);
  32.151  	return ret;
  32.152  }
  32.153 -EXPORT_SYMBOL(xenbus_write);
  32.154 +EXPORT_SYMBOL_GPL(xenbus_write);
  32.155  
  32.156  /* Create a new directory. */
  32.157  int xenbus_mkdir(xenbus_transaction_t t,
  32.158 @@ -410,7 +412,7 @@ int xenbus_mkdir(xenbus_transaction_t t,
  32.159  	kfree(path);
  32.160  	return ret;
  32.161  }
  32.162 -EXPORT_SYMBOL(xenbus_mkdir);
  32.163 +EXPORT_SYMBOL_GPL(xenbus_mkdir);
  32.164  
  32.165  /* Destroy a file or directory (directories must be empty). */
  32.166  int xenbus_rm(xenbus_transaction_t t, const char *dir, const char *node)
  32.167 @@ -426,7 +428,7 @@ int xenbus_rm(xenbus_transaction_t t, co
  32.168  	kfree(path);
  32.169  	return ret;
  32.170  }
  32.171 -EXPORT_SYMBOL(xenbus_rm);
  32.172 +EXPORT_SYMBOL_GPL(xenbus_rm);
  32.173  
  32.174  /* Start a transaction: changes by others will not be seen during this
  32.175   * transaction, and changes will not be visible to others until end.
  32.176 @@ -447,7 +449,7 @@ int xenbus_transaction_start(xenbus_tran
  32.177  	kfree(id_str);
  32.178  	return 0;
  32.179  }
  32.180 -EXPORT_SYMBOL(xenbus_transaction_start);
  32.181 +EXPORT_SYMBOL_GPL(xenbus_transaction_start);
  32.182  
  32.183  /* End a transaction.
  32.184   * If abandon is true, transaction is discarded instead of committed.
  32.185 @@ -468,7 +470,7 @@ int xenbus_transaction_end(xenbus_transa
  32.186  
  32.187  	return err;
  32.188  }
  32.189 -EXPORT_SYMBOL(xenbus_transaction_end);
  32.190 +EXPORT_SYMBOL_GPL(xenbus_transaction_end);
  32.191  
  32.192  /* Single read and scanf: returns -errno or num scanned. */
  32.193  int xenbus_scanf(xenbus_transaction_t t,
  32.194 @@ -491,7 +493,7 @@ int xenbus_scanf(xenbus_transaction_t t,
  32.195  		return -ERANGE;
  32.196  	return ret;
  32.197  }
  32.198 -EXPORT_SYMBOL(xenbus_scanf);
  32.199 +EXPORT_SYMBOL_GPL(xenbus_scanf);
  32.200  
  32.201  /* Single printf and write: returns -errno or 0. */
  32.202  int xenbus_printf(xenbus_transaction_t t,
  32.203 @@ -517,7 +519,7 @@ int xenbus_printf(xenbus_transaction_t t
  32.204  
  32.205  	return ret;
  32.206  }
  32.207 -EXPORT_SYMBOL(xenbus_printf);
  32.208 +EXPORT_SYMBOL_GPL(xenbus_printf);
  32.209  
  32.210  /* Takes tuples of names, scanf-style args, and void **, NULL terminated. */
  32.211  int xenbus_gather(xenbus_transaction_t t, const char *dir, ...)
  32.212 @@ -547,7 +549,7 @@ int xenbus_gather(xenbus_transaction_t t
  32.213  	va_end(ap);
  32.214  	return ret;
  32.215  }
  32.216 -EXPORT_SYMBOL(xenbus_gather);
  32.217 +EXPORT_SYMBOL_GPL(xenbus_gather);
  32.218  
  32.219  static int xs_watch(const char *path, const char *token)
  32.220  {
  32.221 @@ -617,7 +619,7 @@ int register_xenbus_watch(struct xenbus_
  32.222  
  32.223  	return err;
  32.224  }
  32.225 -EXPORT_SYMBOL(register_xenbus_watch);
  32.226 +EXPORT_SYMBOL_GPL(register_xenbus_watch);
  32.227  
  32.228  void unregister_xenbus_watch(struct xenbus_watch *watch)
  32.229  {
  32.230 @@ -655,16 +657,16 @@ void unregister_xenbus_watch(struct xenb
  32.231  
  32.232  	/* Flush any currently-executing callback, unless we are it. :-) */
  32.233  	if (current->pid != xenwatch_pid) {
  32.234 -		down(&xenwatch_mutex);
  32.235 -		up(&xenwatch_mutex);
  32.236 +		mutex_lock(&xenwatch_mutex);
  32.237 +		mutex_unlock(&xenwatch_mutex);
  32.238  	}
  32.239  }
  32.240 -EXPORT_SYMBOL(unregister_xenbus_watch);
  32.241 +EXPORT_SYMBOL_GPL(unregister_xenbus_watch);
  32.242  
  32.243  void xs_suspend(void)
  32.244  {
  32.245  	down_write(&xs_state.suspend_mutex);
  32.246 -	down(&xs_state.request_mutex);
  32.247 +	mutex_lock(&xs_state.request_mutex);
  32.248  }
  32.249  
  32.250  void xs_resume(void)
  32.251 @@ -672,7 +674,7 @@ void xs_resume(void)
  32.252  	struct xenbus_watch *watch;
  32.253  	char token[sizeof(watch) * 2 + 1];
  32.254  
  32.255 -	up(&xs_state.request_mutex);
  32.256 +	mutex_unlock(&xs_state.request_mutex);
  32.257  
  32.258  	/* No need for watches_lock: the suspend_mutex is sufficient. */
  32.259  	list_for_each_entry(watch, &watches, list) {
  32.260 @@ -695,7 +697,7 @@ static int xenwatch_thread(void *unused)
  32.261  		if (kthread_should_stop())
  32.262  			break;
  32.263  
  32.264 -		down(&xenwatch_mutex);
  32.265 +		mutex_lock(&xenwatch_mutex);
  32.266  
  32.267  		spin_lock(&watch_events_lock);
  32.268  		ent = watch_events.next;
  32.269 @@ -713,7 +715,7 @@ static int xenwatch_thread(void *unused)
  32.270  			kfree(msg);
  32.271  		}
  32.272  
  32.273 -		up(&xenwatch_mutex);
  32.274 +		mutex_unlock(&xenwatch_mutex);
  32.275  	}
  32.276  
  32.277  	return 0;
  32.278 @@ -806,7 +808,7 @@ int xs_init(void)
  32.279  	spin_lock_init(&xs_state.reply_lock);
  32.280  	init_waitqueue_head(&xs_state.reply_waitq);
  32.281  
  32.282 -	init_MUTEX(&xs_state.request_mutex);
  32.283 +	mutex_init(&xs_state.request_mutex);
  32.284  	init_rwsem(&xs_state.suspend_mutex);
  32.285  
  32.286  	/* Initialize the shared memory rings to talk to xenstored */
    33.1 --- a/linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/hypercall.h	Wed Mar 22 08:57:48 2006 -0700
    33.2 +++ b/linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/hypercall.h	Wed Mar 22 09:12:48 2006 -0700
    33.3 @@ -5,8 +5,11 @@
    33.4   * 
    33.5   * Copyright (c) 2002-2004, K A Fraser
    33.6   * 
    33.7 - * This file may be distributed separately from the Linux kernel, or
    33.8 - * incorporated into other software packages, subject to the following license:
    33.9 + * This program is free software; you can redistribute it and/or
   33.10 + * modify it under the terms of the GNU General Public License version 2
   33.11 + * as published by the Free Software Foundation; or, when distributed
   33.12 + * separately from the Linux kernel or incorporated into other
   33.13 + * software packages, subject to the following license:
   33.14   * 
   33.15   * Permission is hereby granted, free of charge, to any person obtaining a copy
   33.16   * of this source file (the "Software"), to deal in the Software without
    34.1 --- a/linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/hypervisor.h	Wed Mar 22 08:57:48 2006 -0700
    34.2 +++ b/linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/hypervisor.h	Wed Mar 22 09:12:48 2006 -0700
    34.3 @@ -5,8 +5,11 @@
    34.4   * 
    34.5   * Copyright (c) 2002-2004, K A Fraser
    34.6   * 
    34.7 - * This file may be distributed separately from the Linux kernel, or
    34.8 - * incorporated into other software packages, subject to the following license:
    34.9 + * This program is free software; you can redistribute it and/or
   34.10 + * modify it under the terms of the GNU General Public License version 2
   34.11 + * as published by the Free Software Foundation; or, when distributed
   34.12 + * separately from the Linux kernel or incorporated into other
   34.13 + * software packages, subject to the following license:
   34.14   * 
   34.15   * Permission is hereby granted, free of charge, to any person obtaining a copy
   34.16   * of this source file (the "Software"), to deal in the Software without
    35.1 --- a/linux-2.6-xen-sparse/include/asm-ia64/hypercall.h	Wed Mar 22 08:57:48 2006 -0700
    35.2 +++ b/linux-2.6-xen-sparse/include/asm-ia64/hypercall.h	Wed Mar 22 09:12:48 2006 -0700
    35.3 @@ -5,8 +5,11 @@
    35.4   * 
    35.5   * Copyright (c) 2002-2004, K A Fraser
    35.6   * 
    35.7 - * This file may be distributed separately from the Linux kernel, or
    35.8 - * incorporated into other software packages, subject to the following license:
    35.9 + * This program is free software; you can redistribute it and/or
   35.10 + * modify it under the terms of the GNU General Public License version 2
   35.11 + * as published by the Free Software Foundation; or, when distributed
   35.12 + * separately from the Linux kernel or incorporated into other
   35.13 + * software packages, subject to the following license:
   35.14   * 
   35.15   * Permission is hereby granted, free of charge, to any person obtaining a copy
   35.16   * of this source file (the "Software"), to deal in the Software without
    36.1 --- a/linux-2.6-xen-sparse/include/asm-ia64/hypervisor.h	Wed Mar 22 08:57:48 2006 -0700
    36.2 +++ b/linux-2.6-xen-sparse/include/asm-ia64/hypervisor.h	Wed Mar 22 09:12:48 2006 -0700
    36.3 @@ -5,8 +5,11 @@
    36.4   * 
    36.5   * Copyright (c) 2002-2004, K A Fraser
    36.6   * 
    36.7 - * This file may be distributed separately from the Linux kernel, or
    36.8 - * incorporated into other software packages, subject to the following license:
    36.9 + * This program is free software; you can redistribute it and/or
   36.10 + * modify it under the terms of the GNU General Public License version 2
   36.11 + * as published by the Free Software Foundation; or, when distributed
   36.12 + * separately from the Linux kernel or incorporated into other
   36.13 + * software packages, subject to the following license:
   36.14   * 
   36.15   * Permission is hereby granted, free of charge, to any person obtaining a copy
   36.16   * of this source file (the "Software"), to deal in the Software without
    37.1 --- a/linux-2.6-xen-sparse/include/asm-x86_64/mach-xen/asm/hypercall.h	Wed Mar 22 08:57:48 2006 -0700
    37.2 +++ b/linux-2.6-xen-sparse/include/asm-x86_64/mach-xen/asm/hypercall.h	Wed Mar 22 09:12:48 2006 -0700
    37.3 @@ -9,8 +9,11 @@
    37.4   *   Benjamin Liu <benjamin.liu@intel.com>
    37.5   *   Jun Nakajima <jun.nakajima@intel.com>
    37.6   * 
    37.7 - * This file may be distributed separately from the Linux kernel, or
    37.8 - * incorporated into other software packages, subject to the following license:
    37.9 + * This program is free software; you can redistribute it and/or
   37.10 + * modify it under the terms of the GNU General Public License version 2
   37.11 + * as published by the Free Software Foundation; or, when distributed
   37.12 + * separately from the Linux kernel or incorporated into other
   37.13 + * software packages, subject to the following license:
   37.14   * 
   37.15   * Permission is hereby granted, free of charge, to any person obtaining a copy
   37.16   * of this source file (the "Software"), to deal in the Software without
    38.1 --- a/linux-2.6-xen-sparse/include/xen/balloon.h	Wed Mar 22 08:57:48 2006 -0700
    38.2 +++ b/linux-2.6-xen-sparse/include/xen/balloon.h	Wed Mar 22 09:12:48 2006 -0700
    38.3 @@ -6,8 +6,11 @@
    38.4   * Copyright (c) 2003, B Dragovic
    38.5   * Copyright (c) 2003-2004, M Williamson, K Fraser
    38.6   * 
    38.7 - * This file may be distributed separately from the Linux kernel, or
    38.8 - * incorporated into other software packages, subject to the following license:
    38.9 + * This program is free software; you can redistribute it and/or
   38.10 + * modify it under the terms of the GNU General Public License version 2
   38.11 + * as published by the Free Software Foundation; or, when distributed
   38.12 + * separately from the Linux kernel or incorporated into other
   38.13 + * software packages, subject to the following license:
   38.14   * 
   38.15   * Permission is hereby granted, free of charge, to any person obtaining a copy
   38.16   * of this source file (the "Software"), to deal in the Software without
    39.1 --- a/linux-2.6-xen-sparse/include/xen/evtchn.h	Wed Mar 22 08:57:48 2006 -0700
    39.2 +++ b/linux-2.6-xen-sparse/include/xen/evtchn.h	Wed Mar 22 09:12:48 2006 -0700
    39.3 @@ -6,8 +6,11 @@
    39.4   * 
    39.5   * Copyright (c) 2004-2005, K A Fraser
    39.6   * 
    39.7 - * This file may be distributed separately from the Linux kernel, or
    39.8 - * incorporated into other software packages, subject to the following license:
    39.9 + * This program is free software; you can redistribute it and/or
   39.10 + * modify it under the terms of the GNU General Public License version 2
   39.11 + * as published by the Free Software Foundation; or, when distributed
   39.12 + * separately from the Linux kernel or incorporated into other
   39.13 + * software packages, subject to the following license:
   39.14   * 
   39.15   * Permission is hereby granted, free of charge, to any person obtaining a copy
   39.16   * of this source file (the "Software"), to deal in the Software without
    40.1 --- a/linux-2.6-xen-sparse/include/xen/gnttab.h	Wed Mar 22 08:57:48 2006 -0700
    40.2 +++ b/linux-2.6-xen-sparse/include/xen/gnttab.h	Wed Mar 22 09:12:48 2006 -0700
    40.3 @@ -9,8 +9,11 @@
    40.4   * Copyright (c) 2004-2005, K A Fraser
    40.5   * Copyright (c) 2005, Christopher Clark
    40.6   * 
    40.7 - * This file may be distributed separately from the Linux kernel, or
    40.8 - * incorporated into other software packages, subject to the following license:
    40.9 + * This program is free software; you can redistribute it and/or
   40.10 + * modify it under the terms of the GNU General Public License version 2
   40.11 + * as published by the Free Software Foundation; or, when distributed
   40.12 + * separately from the Linux kernel or incorporated into other
   40.13 + * software packages, subject to the following license:
   40.14   * 
   40.15   * Permission is hereby granted, free of charge, to any person obtaining a copy
   40.16   * of this source file (the "Software"), to deal in the Software without
    41.1 --- a/linux-2.6-xen-sparse/include/xen/net_driver_util.h	Wed Mar 22 08:57:48 2006 -0700
    41.2 +++ b/linux-2.6-xen-sparse/include/xen/net_driver_util.h	Wed Mar 22 09:12:48 2006 -0700
    41.3 @@ -4,9 +4,11 @@
    41.4   *
    41.5   * Copyright (c) 2005 XenSource Ltd.
    41.6   * 
    41.7 - * This file may be distributed separately from the Linux kernel, or
    41.8 - * incorporated into other software packages, subject to the following
    41.9 - * license:
   41.10 + * This program is free software; you can redistribute it and/or
   41.11 + * modify it under the terms of the GNU General Public License version 2
   41.12 + * as published by the Free Software Foundation; or, when distributed
   41.13 + * separately from the Linux kernel or incorporated into other
   41.14 + * software packages, subject to the following license:
   41.15   * 
   41.16   * Permission is hereby granted, free of charge, to any person obtaining a
   41.17   * copy of this source file (the "Software"), to deal in the Software without
    42.1 --- a/linux-2.6-xen-sparse/include/xen/public/evtchn.h	Wed Mar 22 08:57:48 2006 -0700
    42.2 +++ b/linux-2.6-xen-sparse/include/xen/public/evtchn.h	Wed Mar 22 09:12:48 2006 -0700
    42.3 @@ -5,8 +5,11 @@
    42.4   * 
    42.5   * Copyright (c) 2003-2005, K A Fraser
    42.6   * 
    42.7 - * This file may be distributed separately from the Linux kernel, or
    42.8 - * incorporated into other software packages, subject to the following license:
    42.9 + * This program is free software; you can redistribute it and/or
   42.10 + * modify it under the terms of the GNU General Public License version 2
   42.11 + * as published by the Free Software Foundation; or, when distributed
   42.12 + * separately from the Linux kernel or incorporated into other
   42.13 + * software packages, subject to the following license:
   42.14   * 
   42.15   * Permission is hereby granted, free of charge, to any person obtaining a copy
   42.16   * of this source file (the "Software"), to deal in the Software without
    43.1 --- a/linux-2.6-xen-sparse/include/xen/public/privcmd.h	Wed Mar 22 08:57:48 2006 -0700
    43.2 +++ b/linux-2.6-xen-sparse/include/xen/public/privcmd.h	Wed Mar 22 09:12:48 2006 -0700
    43.3 @@ -5,8 +5,11 @@
    43.4   * 
    43.5   * Copyright (c) 2003-2005, K A Fraser
    43.6   * 
    43.7 - * This file may be distributed separately from the Linux kernel, or
    43.8 - * incorporated into other software packages, subject to the following license:
    43.9 + * This program is free software; you can redistribute it and/or
   43.10 + * modify it under the terms of the GNU General Public License version 2
   43.11 + * as published by the Free Software Foundation; or, when distributed
   43.12 + * separately from the Linux kernel or incorporated into other
   43.13 + * software packages, subject to the following license:
   43.14   * 
   43.15   * Permission is hereby granted, free of charge, to any person obtaining a copy
   43.16   * of this source file (the "Software"), to deal in the Software without
    44.1 --- a/linux-2.6-xen-sparse/include/xen/xenbus.h	Wed Mar 22 08:57:48 2006 -0700
    44.2 +++ b/linux-2.6-xen-sparse/include/xen/xenbus.h	Wed Mar 22 09:12:48 2006 -0700
    44.3 @@ -6,8 +6,11 @@
    44.4   * Copyright (C) 2005 Rusty Russell, IBM Corporation
    44.5   * Copyright (C) 2005 XenSource Ltd.
    44.6   * 
    44.7 - * This file may be distributed separately from the Linux kernel, or
    44.8 - * incorporated into other software packages, subject to the following license:
    44.9 + * This program is free software; you can redistribute it and/or
   44.10 + * modify it under the terms of the GNU General Public License version 2
   44.11 + * as published by the Free Software Foundation; or, when distributed
   44.12 + * separately from the Linux kernel or incorporated into other
   44.13 + * software packages, subject to the following license:
   44.14   * 
   44.15   * Permission is hereby granted, free of charge, to any person obtaining a copy
   44.16   * of this source file (the "Software"), to deal in the Software without
   44.17 @@ -33,7 +36,7 @@
   44.18  
   44.19  #include <linux/device.h>
   44.20  #include <linux/notifier.h>
   44.21 -#include <asm/semaphore.h>
   44.22 +#include <linux/mutex.h>
   44.23  #include <xen/interface/xen.h>
   44.24  #include <xen/interface/grant_table.h>
   44.25  #include <xen/interface/io/xenbus.h>
    45.1 --- a/tools/examples/Makefile	Wed Mar 22 08:57:48 2006 -0700
    45.2 +++ b/tools/examples/Makefile	Wed Mar 22 09:12:48 2006 -0700
    45.3 @@ -38,8 +38,8 @@ XEN_HOTPLUG_SCRIPTS = xen-backend.agent
    45.4  UDEV_RULES_DIR = /etc/udev
    45.5  UDEV_RULES = xen-backend.rules
    45.6  
    45.7 -DI = $(shell readlink -f $(DISTDIR))
    45.8 -DE = $(shell readlink -f $(DESTDIR))
    45.9 +DI = $(if $(DISTDIR),$(shell readlink -f $(DISTDIR)),)
   45.10 +DE = $(if $(DESTDIR),$(shell readlink -f $(DESTDIR)),)
   45.11  ifeq ($(findstring $(DI),$(DE)),$(DI))
   45.12  HOTPLUGS=install-hotplug install-udev
   45.13  else
    46.1 --- a/tools/examples/xmexample.hvm	Wed Mar 22 08:57:48 2006 -0700
    46.2 +++ b/tools/examples/xmexample.hvm	Wed Mar 22 09:12:48 2006 -0700
    46.3 @@ -129,6 +129,9 @@ vncviewer=1
    46.4  # no graphics, use serial port
    46.5  #nographic=0
    46.6  
    46.7 +#----------------------------------------------------------------------------
    46.8 +# enable stdvga, default = 0 (use cirrus logic device model)
    46.9 +stdvga=0
   46.10  
   46.11  #-----------------------------------------------------------------------------
   46.12  #   serial port re-direct to pty deivce, /dev/pts/n 
    47.1 --- a/tools/firmware/vmxassist/machine.h	Wed Mar 22 08:57:48 2006 -0700
    47.2 +++ b/tools/firmware/vmxassist/machine.h	Wed Mar 22 09:12:48 2006 -0700
    47.3 @@ -37,10 +37,11 @@
    47.4  #define CR4_PVI		(1 << 1)
    47.5  #define CR4_PSE		(1 << 4)
    47.6  
    47.7 +#define EFLAGS_ZF	(1 << 6)
    47.8  #define EFLAGS_TF	(1 << 8)
    47.9  #define EFLAGS_IF	(1 << 9)
   47.10  #define EFLAGS_DF	(1 << 10)
   47.11 -#define EFLAGS_IOPL (3 << 12)
   47.12 +#define EFLAGS_IOPL	(3 << 12)
   47.13  #define EFLAGS_VM	((1 << 17) | EFLAGS_IOPL)
   47.14  #define EFLAGS_VIF	(1 << 19)
   47.15  #define EFLAGS_VIP	(1 << 20)
    48.1 --- a/tools/firmware/vmxassist/util.c	Wed Mar 22 08:57:48 2006 -0700
    48.2 +++ b/tools/firmware/vmxassist/util.c	Wed Mar 22 09:12:48 2006 -0700
    48.3 @@ -48,7 +48,8 @@ dump_regs(struct regs *regs)
    48.4  		printf("trapno %8x errno  %8x\n", regs->trapno, regs->errno);
    48.5  
    48.6  	printf("cr0    %8lx cr2    %8x cr3    %8lx cr4    %8lx\n",
    48.7 -		oldctx.cr0, get_cr2(), oldctx.cr3, oldctx.cr4);
    48.8 +		(long)oldctx.cr0, get_cr2(),
    48.9 +		(long)oldctx.cr3, (long)oldctx.cr4);
   48.10  }
   48.11  
   48.12  #ifdef DEBUG
   48.13 @@ -104,15 +105,25 @@ print_e820_map(struct e820entry *map, in
   48.14  }
   48.15  
   48.16  void
   48.17 -dump_dtr(unsigned long base, unsigned long limit)
   48.18 +dump_dtr(unsigned long addr, unsigned long size)
   48.19  {
   48.20  	unsigned long long entry;
   48.21 +	unsigned long base, limit;
   48.22  	int i;
   48.23  
   48.24 -	for (i = 0; i < limit; i += 8) {
   48.25 -		entry = ((unsigned long long *) base)[i >> 3];
   48.26 -		printf("[0x%x] = 0x%08x%08x\n", i,
   48.27 -			(unsigned)(entry >> 32), (unsigned)(entry));
   48.28 +	for (i = 0; i < size; i += 8) {
   48.29 +		entry = ((unsigned long long *) addr)[i >> 3];
   48.30 +		base = (((entry >> (56-24)) & 0xFF000000) |
   48.31 +			((entry >> (32-16)) & 0x00FF0000) |
   48.32 +			((entry >> (   16)) & 0x0000FFFF));
   48.33 +		limit = (((entry >> (48-16)) & 0x000F0000) |
   48.34 +		         ((entry           ) & 0x0000FFFF));
   48.35 +		if (entry & (1ULL << (23+32))) /* G */
   48.36 +			limit = (limit << 12) | 0xFFF;
   48.37 +
   48.38 +		printf("[0x%x] = 0x%08x%08x, base 0x%lx, limit 0x%lx\n", i,
   48.39 +			(unsigned)(entry >> 32), (unsigned)(entry),
   48.40 +			base, limit);
   48.41  	}
   48.42  }
   48.43  
   48.44 @@ -120,18 +131,19 @@ void
   48.45  dump_vmx_context(struct vmx_assist_context *c)
   48.46  {
   48.47  	printf("eip 0x%lx, esp 0x%lx, eflags 0x%lx\n",
   48.48 -		c->eip, c->esp, c->eflags);
   48.49 +		(long) c->eip, (long) c->esp, (long) c->eflags);
   48.50  
   48.51 -	printf("cr0 0x%lx, cr3 0x%lx, cr4 0x%lx\n", c->cr0, c->cr3, c->cr4);
   48.52 +	printf("cr0 0x%lx, cr3 0x%lx, cr4 0x%lx\n",
   48.53 +		(long)c->cr0, (long)c->cr3, (long)c->cr4);
   48.54  
   48.55  	printf("idtr: limit 0x%lx, base 0x%lx\n",
   48.56 -		c->idtr_limit, c->idtr_base);
   48.57 +		(long)c->idtr_limit, (long)c->idtr_base);
   48.58  
   48.59  	printf("gdtr: limit 0x%lx, base 0x%lx\n",
   48.60 -		c->gdtr_limit, c->gdtr_base);
   48.61 +		(long)c->gdtr_limit, (long)c->gdtr_base);
   48.62  
   48.63  	printf("cs: sel 0x%lx, limit 0x%lx, base 0x%lx\n",
   48.64 -		c->cs_sel, c->cs_limit, c->cs_base);
   48.65 +		(long)c->cs_sel, (long)c->cs_limit, (long)c->cs_base);
   48.66  	printf("\ttype %d, s %d, dpl %d, p %d, avl %d, ops %d, g %d, nul %d\n",
   48.67  		c->cs_arbytes.fields.seg_type,
   48.68  		c->cs_arbytes.fields.s,
   48.69 @@ -143,7 +155,7 @@ dump_vmx_context(struct vmx_assist_conte
   48.70  		c->cs_arbytes.fields.null_bit);
   48.71  
   48.72  	printf("ds: sel 0x%lx, limit 0x%lx, base 0x%lx\n",
   48.73 -		c->ds_sel, c->ds_limit, c->ds_base);
   48.74 +		(long)c->ds_sel, (long)c->ds_limit, (long)c->ds_base);
   48.75  	printf("\ttype %d, s %d, dpl %d, p %d, avl %d, ops %d, g %d, nul %d\n",
   48.76  		c->ds_arbytes.fields.seg_type,
   48.77  		c->ds_arbytes.fields.s,
   48.78 @@ -155,7 +167,7 @@ dump_vmx_context(struct vmx_assist_conte
   48.79  		c->ds_arbytes.fields.null_bit);
   48.80  
   48.81  	printf("es: sel 0x%lx, limit 0x%lx, base 0x%lx\n",
   48.82 -		c->es_sel, c->es_limit, c->es_base);
   48.83 +		(long)c->es_sel, (long)c->es_limit, (long)c->es_base);
   48.84  	printf("\ttype %d, s %d, dpl %d, p %d, avl %d, ops %d, g %d, nul %d\n",
   48.85  		c->es_arbytes.fields.seg_type,
   48.86  		c->es_arbytes.fields.s,
   48.87 @@ -167,7 +179,7 @@ dump_vmx_context(struct vmx_assist_conte
   48.88  		c->es_arbytes.fields.null_bit);
   48.89  
   48.90  	printf("ss: sel 0x%lx, limit 0x%lx, base 0x%lx\n",
   48.91 -		c->ss_sel, c->ss_limit, c->ss_base);
   48.92 +		(long)c->ss_sel, (long)c->ss_limit, (long)c->ss_base);
   48.93  	printf("\ttype %d, s %d, dpl %d, p %d, avl %d, ops %d, g %d, nul %d\n",
   48.94  		c->ss_arbytes.fields.seg_type,
   48.95  		c->ss_arbytes.fields.s,
   48.96 @@ -179,7 +191,7 @@ dump_vmx_context(struct vmx_assist_conte
   48.97  		c->ss_arbytes.fields.null_bit);
   48.98  
   48.99  	printf("fs: sel 0x%lx, limit 0x%lx, base 0x%lx\n",
  48.100 -		c->fs_sel, c->fs_limit, c->fs_base);
  48.101 +		(long)c->fs_sel, (long)c->fs_limit, (long)c->fs_base);
  48.102  	printf("\ttype %d, s %d, dpl %d, p %d, avl %d, ops %d, g %d, nul %d\n",
  48.103  		c->fs_arbytes.fields.seg_type,
  48.104  		c->fs_arbytes.fields.s,
  48.105 @@ -191,7 +203,7 @@ dump_vmx_context(struct vmx_assist_conte
  48.106  		c->fs_arbytes.fields.null_bit);
  48.107  
  48.108  	printf("gs: sel 0x%lx, limit 0x%lx, base 0x%lx\n",
  48.109 -		c->gs_sel, c->gs_limit, c->gs_base);
  48.110 +		(long)c->gs_sel, (long)c->gs_limit, (long)c->gs_base);
  48.111  	printf("\ttype %d, s %d, dpl %d, p %d, avl %d, ops %d, g %d, nul %d\n",
  48.112  		c->gs_arbytes.fields.seg_type,
  48.113  		c->gs_arbytes.fields.s,
  48.114 @@ -203,7 +215,7 @@ dump_vmx_context(struct vmx_assist_conte
  48.115  		c->gs_arbytes.fields.null_bit);
  48.116  
  48.117  	printf("tr: sel 0x%lx, limit 0x%lx, base 0x%lx\n",
  48.118 -		c->tr_sel, c->tr_limit, c->tr_base);
  48.119 +		(long)c->tr_sel, (long)c->tr_limit, (long)c->tr_base);
  48.120  	printf("\ttype %d, s %d, dpl %d, p %d, avl %d, ops %d, g %d, nul %d\n",
  48.121  		c->tr_arbytes.fields.seg_type,
  48.122  		c->tr_arbytes.fields.s,
  48.123 @@ -215,7 +227,7 @@ dump_vmx_context(struct vmx_assist_conte
  48.124  		c->tr_arbytes.fields.null_bit);
  48.125  
  48.126  	printf("ldtr: sel 0x%lx, limit 0x%lx, base 0x%lx\n",
  48.127 -		c->ldtr_sel, c->ldtr_limit, c->ldtr_base);
  48.128 +		(long)c->ldtr_sel, (long)c->ldtr_limit, (long)c->ldtr_base);
  48.129  	printf("\ttype %d, s %d, dpl %d, p %d, avl %d, ops %d, g %d, nul %d\n",
  48.130  		c->ldtr_arbytes.fields.seg_type,
  48.131  		c->ldtr_arbytes.fields.s,
  48.132 @@ -226,7 +238,8 @@ dump_vmx_context(struct vmx_assist_conte
  48.133  		c->ldtr_arbytes.fields.g,
  48.134  		c->ldtr_arbytes.fields.null_bit);
  48.135  
  48.136 -	printf("GDTR <0x%lx,0x%lx>:\n", c->gdtr_base,  c->gdtr_limit);
  48.137 +	printf("GDTR <0x%lx,0x%lx>:\n",
  48.138 +		(long)c->gdtr_base, (long)c->gdtr_limit);
  48.139  	dump_dtr(c->gdtr_base, c->gdtr_limit);
  48.140  }
  48.141  #endif /* DEBUG */
    49.1 --- a/tools/firmware/vmxassist/vm86.c	Wed Mar 22 08:57:48 2006 -0700
    49.2 +++ b/tools/firmware/vmxassist/vm86.c	Wed Mar 22 09:12:48 2006 -0700
    49.3 @@ -3,7 +3,7 @@
    49.4   * little work as possible. 
    49.5   *
    49.6   * Leendert van Doorn, leendert@watson.ibm.com
    49.7 - * Copyright (c) 2005, International Business Machines Corporation.
    49.8 + * Copyright (c) 2005-2006, International Business Machines Corporation.
    49.9   *
   49.10   * This program is free software; you can redistribute it and/or modify it
   49.11   * under the terms and conditions of the GNU General Public License,
   49.12 @@ -35,7 +35,7 @@
   49.13  #define	SEG_GS		0x0080
   49.14  
   49.15  unsigned prev_eip = 0;
   49.16 -enum vm86_mode mode;
   49.17 +enum vm86_mode mode = 0;
   49.18  
   49.19  #ifdef DEBUG
   49.20  int traceset = 0;
   49.21 @@ -46,24 +46,21 @@ char *states[] = {
   49.22  	"<VM86_PROTECTED_TO_REAL>",
   49.23  	"<VM86_PROTECTED>"
   49.24  };
   49.25 +
   49.26 +static char *rnames[] = { "ax", "cx", "dx", "bx", "sp", "bp", "si", "di" };
   49.27  #endif /* DEBUG */
   49.28  
   49.29 -
   49.30  unsigned
   49.31  address(struct regs *regs, unsigned seg, unsigned off)
   49.32  {
   49.33  	unsigned long long entry;
   49.34  	unsigned addr;
   49.35  
   49.36 -	/* real mode: segment is part of the address */
   49.37 -	if (mode == VM86_REAL || mode == VM86_REAL_TO_PROTECTED)
   49.38 -		return ((seg & 0xFFFF) << 4) + off;
   49.39 +	if (seg == 0)
   49.40 +		return off;
   49.41  
   49.42 -	/* protected mode: use seg as index into gdt */
   49.43 -	if (seg > oldctx.gdtr_limit) {
   49.44 -		printf("address: Invalid segment descriptor (0x%x)\n", seg);
   49.45 -		return 0;
   49.46 -	}
   49.47 +	if (seg > oldctx.gdtr_limit)
   49.48 +		return ((seg & 0xFFFF) << 4) + off;
   49.49  
   49.50  	entry = ((unsigned long long *) oldctx.gdtr_base)[seg >> 3];
   49.51  	addr = (((entry >> (56-24)) & 0xFF000000) |
   49.52 @@ -198,7 +195,7 @@ fetch8(struct regs *regs)
   49.53  }
   49.54  
   49.55  unsigned
   49.56 -getreg(struct regs *regs, int r)
   49.57 +getreg32(struct regs *regs, int r)
   49.58  {
   49.59  	switch (r & 7) {
   49.60  	case 0: return regs->eax;
   49.61 @@ -213,8 +210,30 @@ getreg(struct regs *regs, int r)
   49.62  	return ~0;
   49.63  }
   49.64  
   49.65 +unsigned
   49.66 +getreg16(struct regs *regs, int r)
   49.67 +{
   49.68 +	return MASK16(getreg32(regs, r));
   49.69 +}
   49.70 +
   49.71 +unsigned
   49.72 +getreg8(struct regs *regs, int r)
   49.73 +{
   49.74 +	switch (r & 7) {
   49.75 +	case 0: return regs->eax & 0xFF; /* al */
   49.76 +	case 1: return regs->ecx & 0xFF; /* cl */
   49.77 +	case 2: return regs->edx & 0xFF; /* dl */
   49.78 +	case 3: return regs->ebx & 0xFF; /* bl */
   49.79 +	case 4: return (regs->esp >> 8) & 0xFF; /* ah */
   49.80 +	case 5: return (regs->ebp >> 8) & 0xFF; /* ch */
   49.81 +	case 6: return (regs->esi >> 8) & 0xFF; /* dh */
   49.82 +	case 7: return (regs->edi >> 8) & 0xFF; /* bh */
   49.83 +	}
   49.84 +	return ~0;
   49.85 +}
   49.86 +
   49.87  void
   49.88 -setreg(struct regs *regs, int r, unsigned v)
   49.89 +setreg32(struct regs *regs, int r, unsigned v)
   49.90  {
   49.91  	switch (r & 7) {
   49.92  	case 0: regs->eax = v; break;
   49.93 @@ -228,15 +247,31 @@ setreg(struct regs *regs, int r, unsigne
   49.94  	}
   49.95  }
   49.96  
   49.97 -/*
   49.98 - * Operand (modrm) decode
   49.99 - */
  49.100 +void
  49.101 +setreg16(struct regs *regs, int r, unsigned v)
  49.102 +{
  49.103 +	setreg32(regs, r, (getreg32(regs, r) & ~0xFFFF) | MASK16(v));
  49.104 +}
  49.105 +
  49.106 +void
  49.107 +setreg8(struct regs *regs, int r, unsigned v)
  49.108 +{
  49.109 +	v &= 0xFF;
  49.110 +	switch (r & 7) {
  49.111 +	case 0: regs->eax = (regs->eax & ~0xFF) | v; break;
  49.112 +	case 1: regs->ecx = (regs->ecx & ~0xFF) | v; break;
  49.113 +	case 2: regs->edx = (regs->edx & ~0xFF) | v; break;
  49.114 +	case 3: regs->ebx = (regs->ebx & ~0xFF) | v; break;
  49.115 +	case 4: regs->esp = (regs->esp & ~0xFF00) | (v << 8); break;
  49.116 +	case 5: regs->ebp = (regs->ebp & ~0xFF00) | (v << 8); break;
  49.117 +	case 6: regs->esi = (regs->esi & ~0xFF00) | (v << 8); break;
  49.118 +	case 7: regs->edi = (regs->edi & ~0xFF00) | (v << 8); break;
  49.119 +	}
  49.120 +}
  49.121 +
  49.122  unsigned
  49.123 -operand(unsigned prefix, struct regs *regs, unsigned modrm)
  49.124 +segment(unsigned prefix, struct regs *regs, unsigned seg)
  49.125  {
  49.126 -	int mod, disp = 0, seg;
  49.127 -
  49.128 -	seg = regs->vds;
  49.129  	if (prefix & SEG_ES)
  49.130  		seg = regs->ves;
  49.131  	if (prefix & SEG_DS)
  49.132 @@ -249,6 +284,47 @@ operand(unsigned prefix, struct regs *re
  49.133  		seg = regs->fs;
  49.134  	if (prefix & SEG_GS)
  49.135  		seg = regs->gs;
  49.136 +	return seg;
  49.137 +}
  49.138 +
  49.139 +unsigned
  49.140 +sib(struct regs *regs, int mod, unsigned byte)
  49.141 +{
  49.142 +	unsigned scale = (byte >> 6) & 3;
  49.143 +	int index = (byte >> 3) & 7;
  49.144 +	int base = byte & 7;
  49.145 +	unsigned addr = 0;
  49.146 +
  49.147 +	switch (mod) {
  49.148 +	case 0:
  49.149 +		if (base == 5)
  49.150 +			addr = fetch32(regs);
  49.151 +		else
  49.152 +			addr = getreg32(regs, base);
  49.153 +		break;
  49.154 +	case 1:
  49.155 +		addr = getreg32(regs, base) + (char) fetch8(regs);
  49.156 +		break;
  49.157 +	case 2:
  49.158 +		addr = getreg32(regs, base) + fetch32(regs);
  49.159 +		break;
  49.160 +	}
  49.161 +
  49.162 +	if (index != 4)
  49.163 +		addr += getreg32(regs, index) << scale;
  49.164 +
  49.165 +	return addr;
  49.166 +}
  49.167 +
  49.168 +/*
  49.169 + * Operand (modrm) decode
  49.170 + */
  49.171 +unsigned
  49.172 +operand(unsigned prefix, struct regs *regs, unsigned modrm)
  49.173 +{
  49.174 +	int mod, disp = 0, seg;
  49.175 +
  49.176 +	seg = segment(prefix, regs, regs->vds);
  49.177  
  49.178  	if (prefix & ADDR32) { /* 32-bit addressing */
  49.179  		switch ((mod = (modrm >> 6) & 3)) {
  49.180 @@ -258,7 +334,8 @@ operand(unsigned prefix, struct regs *re
  49.181  			case 1: return address(regs, seg, regs->ecx);
  49.182  			case 2: return address(regs, seg, regs->edx);
  49.183  			case 3: return address(regs, seg, regs->ebx);
  49.184 -			case 4: panic("No SIB decode (yet)");
  49.185 +			case 4: return address(regs, seg,
  49.186 +					       sib(regs, mod, fetch8(regs)));
  49.187  			case 5: return address(regs, seg, fetch32(regs));
  49.188  			case 6: return address(regs, seg, regs->esi);
  49.189  			case 7: return address(regs, seg, regs->edi);
  49.190 @@ -277,14 +354,15 @@ operand(unsigned prefix, struct regs *re
  49.191  			case 1: return address(regs, seg, regs->ecx + disp);
  49.192  			case 2: return address(regs, seg, regs->edx + disp);
  49.193  			case 3: return address(regs, seg, regs->ebx + disp);
  49.194 -			case 4: panic("No SIB decode (yet)");
  49.195 +			case 4: return address(regs, seg,
  49.196 +					       sib(regs, mod, fetch8(regs)));
  49.197  			case 5: return address(regs, seg, regs->ebp + disp);
  49.198  			case 6: return address(regs, seg, regs->esi + disp);
  49.199  			case 7: return address(regs, seg, regs->edi + disp);
  49.200  			}
  49.201  			break;
  49.202  		case 3:
  49.203 -			return getreg(regs, modrm);
  49.204 +			return getreg32(regs, modrm);
  49.205  		}
  49.206  	} else { /* 16-bit addressing */
  49.207  		switch ((mod = (modrm >> 6) & 3)) {
  49.208 @@ -330,7 +408,7 @@ operand(unsigned prefix, struct regs *re
  49.209  			}
  49.210  			break;
  49.211  		case 3:
  49.212 -			return MASK16(getreg(regs, modrm));
  49.213 +			return getreg16(regs, modrm);
  49.214  		}
  49.215  	}
  49.216  
  49.217 @@ -400,6 +478,72 @@ lmsw(struct regs *regs, unsigned prefix,
  49.218  }
  49.219  
  49.220  /*
  49.221 + * We need to handle moves that address memory beyond the 64KB segment
  49.222 + * limit that VM8086 mode enforces.
  49.223 + */
  49.224 +int
  49.225 +movr(struct regs *regs, unsigned prefix, unsigned opc)
  49.226 +{
  49.227 +	unsigned eip = regs->eip - 1;
  49.228 +	unsigned modrm = fetch8(regs);
  49.229 +	unsigned addr = operand(prefix, regs, modrm);
  49.230 +	unsigned val, r = (modrm >> 3) & 7;
  49.231 +
  49.232 +	if ((modrm & 0xC0) == 0xC0) /* no registers */
  49.233 +		return 0;
  49.234 +
  49.235 +	switch (opc) {
  49.236 +	case 0x88: /* addr32 mov r8, r/m8 */
  49.237 +		val = getreg8(regs, r);
  49.238 +		TRACE((regs, regs->eip - eip,
  49.239 +			"movb %%e%s, *0x%x", rnames[r], addr));
  49.240 +		write8(addr, val);
  49.241 +		break;
  49.242 +
  49.243 +	case 0x8A: /* addr32 mov r/m8, r8 */
  49.244 +		TRACE((regs, regs->eip - eip,
  49.245 +			"movb *0x%x, %%%s", addr, rnames[r]));
  49.246 +		setreg8(regs, r, read8(addr));
  49.247 +		break;
  49.248 +
  49.249 +	case 0x89: /* addr32 mov r16, r/m16 */
  49.250 +		val = getreg32(regs, r);
  49.251 +		if (prefix & DATA32) {
  49.252 +			TRACE((regs, regs->eip - eip,
  49.253 +				"movl %%e%s, *0x%x", rnames[r], addr));
  49.254 +			write32(addr, val);
  49.255 +		} else {
  49.256 +			TRACE((regs, regs->eip - eip,
  49.257 +				"movw %%%s, *0x%x", rnames[r], addr));
  49.258 +			write16(addr, MASK16(val));
  49.259 +		}
  49.260 +		break;
  49.261 +
  49.262 +	case 0x8B: /* addr32 mov r/m16, r16 */
  49.263 +		if (prefix & DATA32) {
  49.264 +			TRACE((regs, regs->eip - eip,
  49.265 +				"movl *0x%x, %%e%s", addr, rnames[r]));
  49.266 +			setreg32(regs, r, read32(addr));
  49.267 +		} else {
  49.268 +			TRACE((regs, regs->eip - eip,
  49.269 +				"movw *0x%x, %%%s", addr, rnames[r]));
  49.270 +			setreg16(regs, r, read16(addr));
  49.271 +		}
  49.272 +		break;
  49.273 +
  49.274 +	case 0xC6: /* addr32 movb $imm, r/m8 */
  49.275 +		if ((modrm >> 3) & 7)
  49.276 +			return 0;
  49.277 +		val = fetch8(regs);
  49.278 +		write8(addr, val);
  49.279 +		TRACE((regs, regs->eip - eip, "movb $0x%x, *0x%x",
  49.280 +							val, addr));
  49.281 +		break;
  49.282 +	}
  49.283 +	return 1;
  49.284 +}
  49.285 +
  49.286 +/*
  49.287   * Move to and from a control register.
  49.288   */
  49.289  int
  49.290 @@ -418,21 +562,21 @@ movcr(struct regs *regs, unsigned prefix
  49.291  		switch (cr) {
  49.292  		case 0:
  49.293  #ifndef TEST
  49.294 -			setreg(regs, modrm,
  49.295 +			setreg32(regs, modrm,
  49.296  				oldctx.cr0 & ~(CR0_PE | CR0_NE));
  49.297  #else
  49.298 -			setreg(regs, modrm,
  49.299 +			setreg32(regs, modrm,
  49.300  				oldctx.cr0 & ~(CR0_PE | CR0_NE | CR0_PG));
  49.301  #endif
  49.302  			break;
  49.303  		case 2:
  49.304 -			setreg(regs, modrm, get_cr2());
  49.305 +			setreg32(regs, modrm, get_cr2());
  49.306  			break;
  49.307  		case 3:
  49.308 -			setreg(regs, modrm, oldctx.cr3);
  49.309 +			setreg32(regs, modrm, oldctx.cr3);
  49.310  			break;
  49.311  		case 4:
  49.312 -			setreg(regs, modrm, oldctx.cr4);
  49.313 +			setreg32(regs, modrm, oldctx.cr4);
  49.314  			break;
  49.315  		}
  49.316  		break;
  49.317 @@ -440,19 +584,20 @@ movcr(struct regs *regs, unsigned prefix
  49.318  		TRACE((regs, regs->eip - eip, "movl %%eax, %%cr%d", cr));
  49.319  		switch (cr) {
  49.320  		case 0:
  49.321 -			oldctx.cr0 = getreg(regs, modrm) | (CR0_PE | CR0_NE);
  49.322 +			oldctx.cr0 = getreg32(regs, modrm) | (CR0_PE | CR0_NE);
  49.323  #ifdef TEST
  49.324  			oldctx.cr0 |= CR0_PG;
  49.325  #endif
  49.326 -			if (getreg(regs, modrm) & CR0_PE)
  49.327 +			if (getreg32(regs, modrm) & CR0_PE)
  49.328  				set_mode(regs, VM86_REAL_TO_PROTECTED);
  49.329 -
  49.330 +			else
  49.331 +				set_mode(regs, VM86_REAL);
  49.332  			break;
  49.333  		case 3:
  49.334 -			oldctx.cr3 = getreg(regs, modrm);
  49.335 +			oldctx.cr3 = getreg32(regs, modrm);
  49.336  			break;
  49.337  		case 4:
  49.338 -			oldctx.cr4 = getreg(regs, modrm);
  49.339 +			oldctx.cr4 = getreg32(regs, modrm);
  49.340  			break;
  49.341  		}
  49.342  		break;
  49.343 @@ -461,6 +606,118 @@ movcr(struct regs *regs, unsigned prefix
  49.344  	return 1;
  49.345  }
  49.346  
  49.347 +static inline void set_eflags_ZF(unsigned mask, unsigned v1, struct regs *regs)
  49.348 +{
  49.349 +	if ((v1 & mask) == 0)
  49.350 +		regs->eflags |= EFLAGS_ZF;
  49.351 +	else
  49.352 +		regs->eflags &= ~EFLAGS_ZF;
  49.353 +}
  49.354 +
  49.355 +/*
  49.356 + * We need to handle cmp opcodes that address memory beyond the 64KB
  49.357 + * segment limit that VM8086 mode enforces.
  49.358 + */
  49.359 +int
  49.360 +cmp(struct regs *regs, unsigned prefix, unsigned opc)
  49.361 +{
  49.362 +	unsigned eip = regs->eip - 1;
  49.363 +	unsigned modrm = fetch8(regs);
  49.364 +	unsigned addr = operand(prefix, regs, modrm);
  49.365 +	unsigned diff, val, r = (modrm >> 3) & 7;
  49.366 +
  49.367 +	if ((modrm & 0xC0) == 0xC0) /* no registers */
  49.368 +		return 0;
  49.369 +
  49.370 +	switch (opc) {
  49.371 +	case 0x39: /* addr32 cmp r16, r/m16 */
  49.372 +		val = getreg32(regs, r);
  49.373 +		if (prefix & DATA32) {
  49.374 +			diff = read32(addr) - val;
  49.375 +			set_eflags_ZF(~0, diff, regs);
  49.376 +
  49.377 +			TRACE((regs, regs->eip - eip,
  49.378 +				"cmp %%e%s, *0x%x (0x%x)",
  49.379 +				rnames[r], addr, diff));
  49.380 +		} else {
  49.381 +			diff = read16(addr) - val;
  49.382 +			set_eflags_ZF(0xFFFF, diff, regs);
  49.383 +
  49.384 +			TRACE((regs, regs->eip - eip,
  49.385 +				"cmp %%%s, *0x%x (0x%x)",
  49.386 +				rnames[r], addr, diff));
  49.387 +		}
  49.388 +		break;
  49.389 +
  49.390 +	/* other cmp opcodes ... */
  49.391 +	}
  49.392 +	return 1;
  49.393 +}
  49.394 +
  49.395 +/*
  49.396 + * We need to handle test opcodes that address memory beyond the 64KB
  49.397 + * segment limit that VM8086 mode enforces.
  49.398 + */
  49.399 +int
  49.400 +test(struct regs *regs, unsigned prefix, unsigned opc)
  49.401 +{
  49.402 +	unsigned eip = regs->eip - 1;
  49.403 +	unsigned modrm = fetch8(regs);
  49.404 +	unsigned addr = operand(prefix, regs, modrm);
  49.405 +	unsigned val, diff;
  49.406 +
  49.407 +	if ((modrm & 0xC0) == 0xC0) /* no registers */
  49.408 +		return 0;
  49.409 +
  49.410 +	switch (opc) {
  49.411 +	case 0xF6: /* testb $imm, r/m8 */
  49.412 +		if ((modrm >> 3) & 7)
  49.413 +			return 0;
  49.414 +		val = fetch8(regs);
  49.415 +		diff = read8(addr) & val;
  49.416 +		set_eflags_ZF(0xFF, diff, regs);
  49.417 +
  49.418 +		TRACE((regs, regs->eip - eip, "testb $0x%x, *0x%x (0x%x)",
  49.419 +							val, addr, diff));
  49.420 +		break;
  49.421 +
  49.422 +	/* other test opcodes ... */
  49.423 +	}
  49.424 +
  49.425 +	return 1;
  49.426 +}
  49.427 +
  49.428 +/*
  49.429 + * We need to handle pop opcodes that address memory beyond the 64KB
  49.430 + * segment limit that VM8086 mode enforces.
  49.431 + */
  49.432 +int
  49.433 +pop(struct regs *regs, unsigned prefix, unsigned opc)
  49.434 +{
  49.435 +	unsigned eip = regs->eip - 1;
  49.436 +	unsigned modrm = fetch8(regs);
  49.437 +	unsigned addr = operand(prefix, regs, modrm);
  49.438 +
  49.439 +	if ((modrm & 0xC0) == 0xC0) /* no registers */
  49.440 +		return 0;
  49.441 +
  49.442 +	switch (opc) {
  49.443 +	case 0x8F: /* pop r/m16 */
  49.444 +		if ((modrm >> 3) & 7)
  49.445 +			return 0;
  49.446 +		if (prefix & DATA32)
  49.447 +			write32(addr, pop32(regs));
  49.448 +		else
  49.449 +			write16(addr, pop16(regs));
  49.450 +		TRACE((regs, regs->eip - eip, "pop *0x%x", addr));
  49.451 +		break;
  49.452 +
  49.453 +	/* other pop opcodes ... */
  49.454 +	}
  49.455 +
  49.456 +	return 1;
  49.457 +}
  49.458 +
  49.459  /*
  49.460   * Emulate a segment load in protected mode
  49.461   */
  49.462 @@ -473,17 +730,16 @@ load_seg(unsigned long sel, uint32_t *ba
  49.463  	if (sel > oldctx.gdtr_limit)
  49.464  		return 0;
  49.465  
  49.466 -    if (sel == 0) {
  49.467 -        arbytes->fields.null_bit = 1;
  49.468 -        return 1;
  49.469 -    }
  49.470 +	if (sel == 0) {
  49.471 +		arbytes->fields.null_bit = 1;
  49.472 +		return 1;
  49.473 +	}
  49.474  
  49.475  	entry =  ((unsigned long long *) oldctx.gdtr_base)[sel >> 3];
  49.476  
  49.477 -    /* Check the P bit fisrt*/
  49.478 -    if (!((entry >> (15+32)) & 0x1) && sel != 0) {
  49.479 -        return 0;
  49.480 -    }
  49.481 +	/* Check the P bit first */
  49.482 +	if (!((entry >> (15+32)) & 0x1) && sel != 0)
  49.483 +		return 0;
  49.484  
  49.485  	*base =  (((entry >> (56-24)) & 0xFF000000) |
  49.486  		  ((entry >> (32-16)) & 0x00FF0000) |
  49.487 @@ -530,42 +786,47 @@ protected_mode(struct regs *regs)
  49.488  	if (load_seg(regs->ves, &oldctx.es_base,
  49.489  				&oldctx.es_limit, &oldctx.es_arbytes))
  49.490  		oldctx.es_sel = regs->ves;
  49.491 -    else {
  49.492 -        load_seg(0, &oldctx.es_base,&oldctx.es_limit, &oldctx.es_arbytes);
  49.493 -        oldctx.es_sel = 0;
  49.494 -    }
  49.495 +	else {
  49.496 +		load_seg(0, &oldctx.es_base,
  49.497 +			    &oldctx.es_limit, &oldctx.es_arbytes);
  49.498 +		oldctx.es_sel = 0;
  49.499 +	}
  49.500  
  49.501  	if (load_seg(regs->uss, &oldctx.ss_base,
  49.502  				&oldctx.ss_limit, &oldctx.ss_arbytes))
  49.503  		oldctx.ss_sel = regs->uss;
  49.504 -    else {
  49.505 -        load_seg(0, &oldctx.ss_base, &oldctx.ss_limit, &oldctx.ss_arbytes);
  49.506 -        oldctx.ss_sel = 0;
  49.507 -    }
  49.508 +	else {
  49.509 +		load_seg(0, &oldctx.ss_base,
  49.510 +			    &oldctx.ss_limit, &oldctx.ss_arbytes);
  49.511 +		oldctx.ss_sel = 0;
  49.512 +	}
  49.513  
  49.514  	if (load_seg(regs->vds, &oldctx.ds_base,
  49.515  				&oldctx.ds_limit, &oldctx.ds_arbytes))
  49.516  		oldctx.ds_sel = regs->vds;
  49.517 -    else {
  49.518 -        load_seg(0, &oldctx.ds_base, &oldctx.ds_limit, &oldctx.ds_arbytes);
  49.519 -        oldctx.ds_sel = 0;
  49.520 -    }
  49.521 +	else {
  49.522 +		load_seg(0, &oldctx.ds_base,
  49.523 +			    &oldctx.ds_limit, &oldctx.ds_arbytes);
  49.524 +		oldctx.ds_sel = 0;
  49.525 +	}
  49.526  
  49.527  	if (load_seg(regs->vfs, &oldctx.fs_base,
  49.528  				&oldctx.fs_limit, &oldctx.fs_arbytes))
  49.529  		oldctx.fs_sel = regs->vfs;
  49.530 -    else {
  49.531 -        load_seg(0, &oldctx.fs_base, &oldctx.fs_limit, &oldctx.fs_arbytes);
  49.532 -        oldctx.fs_sel = 0;
  49.533 -    }
  49.534 +	else {
  49.535 +		load_seg(0, &oldctx.fs_base,
  49.536 +			    &oldctx.fs_limit, &oldctx.fs_arbytes);
  49.537 +		oldctx.fs_sel = 0;
  49.538 +	}
  49.539  
  49.540  	if (load_seg(regs->vgs, &oldctx.gs_base,
  49.541  				&oldctx.gs_limit, &oldctx.gs_arbytes))
  49.542  		oldctx.gs_sel = regs->vgs;
  49.543 -    else {
  49.544 -        load_seg(0, &oldctx.gs_base, &oldctx.gs_limit, &oldctx.gs_arbytes);
  49.545 -        oldctx.gs_sel = 0;
  49.546 -    }
  49.547 +	else {
  49.548 +		load_seg(0, &oldctx.gs_base,
  49.549 +			    &oldctx.gs_limit, &oldctx.gs_arbytes);
  49.550 +		oldctx.gs_sel = 0;
  49.551 +	}
  49.552  
  49.553  	/* initialize jump environment to warp back to protected mode */
  49.554  	regs->cs = CODE_SELECTOR;
  49.555 @@ -618,22 +879,24 @@ real_mode(struct regs *regs)
  49.556  
  49.557  /*
  49.558   * This is the smarts of the emulator and handles the mode transitions. The
  49.559 - * emulator handles 4 different modes. 1) VM86_REAL: emulated real-mode, Just
  49.560 - * handle those instructions that are not supported under VM8086.
  49.561 - * 2) VM86_REAL_TO_PROTECTED: going from real-mode to protected mode. In this
  49.562 - * we single step through the instructions until we reload the new %cs (some
  49.563 - * OSes do a lot of computations before reloading %cs). 2) VM86_PROTECTED_TO_REAL
  49.564 - * when we are going from protected to real mode. In this case we emulate the
  49.565 - * instructions by hand. Finally, 4) VM86_PROTECTED when we transitioned to
  49.566 - * protected mode and we should abandon the emulator. No instructions are
  49.567 - * emulated when in VM86_PROTECTED mode.
  49.568 + * emulator handles 4 different modes. 1) VM86_REAL: emulated real-mode,
  49.569 + * Just handle those instructions that are not supported under VM8086.
  49.570 + * 2) VM86_REAL_TO_PROTECTED: going from real-mode to protected mode. In
  49.571 + * this we single step through the instructions until we reload the
  49.572 + * new %cs (some OSes do a lot of computations before reloading %cs). 2)
  49.573 + * VM86_PROTECTED_TO_REAL when we are going from protected to real mode. In
  49.574 + * this case we emulate the instructions by hand. Finally, 4) VM86_PROTECTED
  49.575 + * when we transitioned to protected mode and we should abandon the
  49.576 + * emulator. No instructions are emulated when in VM86_PROTECTED mode.
  49.577   */
  49.578  void
  49.579  set_mode(struct regs *regs, enum vm86_mode newmode)
  49.580  {
  49.581  	switch (newmode) {
  49.582  	case VM86_REAL:
  49.583 -		if (mode == VM86_PROTECTED_TO_REAL) {
  49.584 +		if ((mode == VM86_PROTECTED_TO_REAL) ||
  49.585 +		    (mode == VM86_REAL_TO_PROTECTED)) {
  49.586 +			regs->eflags &= ~EFLAGS_TF;
  49.587  			real_mode(regs);
  49.588  			break;
  49.589  		} else if (mode == VM86_REAL) {
  49.590 @@ -653,10 +916,11 @@ set_mode(struct regs *regs, enum vm86_mo
  49.591  		break;
  49.592  
  49.593  	case VM86_PROTECTED_TO_REAL:
  49.594 -		if (mode == VM86_PROTECTED)
  49.595 +		if (mode == VM86_PROTECTED) {
  49.596  			break;
  49.597 -		else
  49.598 +		} else
  49.599  			panic("unexpected protected-to-real mode transition");
  49.600 +		break;
  49.601  
  49.602  	case VM86_PROTECTED:
  49.603  		if (mode == VM86_REAL_TO_PROTECTED) {
  49.604 @@ -887,6 +1151,16 @@ opcode(struct regs *regs)
  49.605  			prefix |= SEG_SS;
  49.606  			continue;
  49.607  
  49.608 +		case 0x39: /* addr32 cmp r16, r/m16 */
  49.609 +		case 0x3B: /* addr32 cmp r/m16, r16 */
  49.610 +			if (mode != VM86_REAL && mode != VM86_REAL_TO_PROTECTED)
  49.611 +				goto invalid;
  49.612 +                        if ((prefix & ADDR32) == 0)
  49.613 +                                goto invalid;
  49.614 +                        if (!cmp(regs, prefix, opc))
  49.615 +                                goto invalid;
  49.616 +                        return OPC_EMULATED;
  49.617 +
  49.618  		case 0x3E:
  49.619  			TRACE((regs, regs->eip - eip, "%%ds:"));
  49.620  			prefix |= SEG_DS;
  49.621 @@ -912,6 +1186,33 @@ opcode(struct regs *regs)
  49.622  			prefix |= ADDR32;
  49.623  			continue;
  49.624  
  49.625 +		case 0x88: /* addr32 mov r8, r/m8 */
  49.626 +		case 0x8A: /* addr32 mov r/m8, r8 */
  49.627 +			if (mode != VM86_REAL && mode != VM86_REAL_TO_PROTECTED)
  49.628 +				goto invalid;
  49.629 +                        if ((prefix & ADDR32) == 0)
  49.630 +                                goto invalid;
  49.631 +                        if (!movr(regs, prefix, opc))
  49.632 +                                goto invalid;
  49.633 +                        return OPC_EMULATED;
  49.634 +
  49.635 +		case 0x89: /* addr32 mov r16, r/m16 */
  49.636 +		case 0x8B: /* addr32 mov r/m16, r16 */
  49.637 +			if (mode != VM86_REAL && mode != VM86_REAL_TO_PROTECTED)
  49.638 +				goto invalid;
  49.639 +                        if ((prefix & ADDR32) == 0)
  49.640 +                                goto invalid;
  49.641 +                        if (!movr(regs, prefix, opc))
  49.642 +                                goto invalid;
  49.643 +                        return OPC_EMULATED;
  49.644 +
  49.645 +		case 0x8F: /* addr32 pop r/m16 */
  49.646 +                        if ((prefix & ADDR32) == 0)
  49.647 +                                goto invalid;
  49.648 +                        if (!pop(regs, prefix, opc))
  49.649 +                                goto invalid;
  49.650 +                        return OPC_EMULATED;
  49.651 +
  49.652  		case 0x90: /* nop */
  49.653  			TRACE((regs, regs->eip - eip, "nop"));
  49.654  			return OPC_EMULATED;
  49.655 @@ -924,7 +1225,7 @@ opcode(struct regs *regs)
  49.656  				push16(regs, regs->eflags & ~EFLAGS_VM);
  49.657  			return OPC_EMULATED;
  49.658  
  49.659 -		case 0x9D:	/* popf */
  49.660 +		case 0x9D: /* popf */
  49.661  			TRACE((regs, regs->eip - eip, "popf"));
  49.662  			if (prefix & DATA32)
  49.663  				regs->eflags = pop32(regs);
  49.664 @@ -934,7 +1235,14 @@ opcode(struct regs *regs)
  49.665  			regs->eflags |= EFLAGS_VM;
  49.666  			return OPC_EMULATED;
  49.667  
  49.668 -		case 0xCB:	/* retl */
  49.669 +		case 0xC6: /* addr32 movb $imm, r/m8 */
  49.670 +                        if ((prefix & ADDR32) == 0)
  49.671 +                                goto invalid;
  49.672 +                        if (!movr(regs, prefix, opc))
  49.673 +                                goto invalid;
  49.674 +			return OPC_EMULATED;
  49.675 +
  49.676 +		case 0xCB: /* retl */
  49.677  			if ((mode == VM86_REAL_TO_PROTECTED) ||
  49.678  			    (mode == VM86_PROTECTED_TO_REAL)) {
  49.679  				retl(regs, prefix);
  49.680 @@ -942,12 +1250,12 @@ opcode(struct regs *regs)
  49.681  			}
  49.682  			goto invalid;
  49.683  
  49.684 -		case 0xCD:	/* int $n */
  49.685 +		case 0xCD: /* int $n */
  49.686  			TRACE((regs, regs->eip - eip, "int"));
  49.687  			interrupt(regs, fetch8(regs));
  49.688  			return OPC_EMULATED;
  49.689  
  49.690 -		case 0xCF:	/* iret */
  49.691 +		case 0xCF: /* iret */
  49.692  			if (prefix & DATA32) {
  49.693  				TRACE((regs, regs->eip - eip, "data32 iretd"));
  49.694  				regs->eip = pop32(regs);
  49.695 @@ -962,17 +1270,17 @@ opcode(struct regs *regs)
  49.696  			}
  49.697  			return OPC_EMULATED;
  49.698  
  49.699 -		case 0xE4:	/* inb al, port */
  49.700 +		case 0xE4: /* inb al, port */
  49.701  			if (!inbyte(regs, prefix, opc))
  49.702  				goto invalid;
  49.703  			return OPC_EMULATED;
  49.704  
  49.705 -		case 0xE6:	/* outb port, al */
  49.706 +		case 0xE6: /* outb port, al */
  49.707  			if (!outbyte(regs, prefix, opc))
  49.708  				goto invalid;
  49.709  			return OPC_EMULATED;
  49.710  
  49.711 -		case 0xEA: 	/* jmpl */
  49.712 +		case 0xEA: /* jmpl */
  49.713  			if ((mode == VM86_REAL_TO_PROTECTED) ||
  49.714  			    (mode == VM86_PROTECTED_TO_REAL)) {
  49.715  				jmpl(regs, prefix);
  49.716 @@ -980,7 +1288,7 @@ opcode(struct regs *regs)
  49.717  			}
  49.718  			goto invalid;
  49.719  
  49.720 -		case 0xEB:	/* short jump */
  49.721 +		case 0xEB: /* short jump */
  49.722  			if ((mode == VM86_REAL_TO_PROTECTED) ||
  49.723  			    (mode == VM86_PROTECTED_TO_REAL)) {
  49.724  				disp = (char) fetch8(regs);
  49.725 @@ -990,26 +1298,33 @@ opcode(struct regs *regs)
  49.726  			}
  49.727  			goto invalid;
  49.728  
  49.729 -		case 0xEC:	/* inb al, (%dx) */
  49.730 +		case 0xEC: /* inb al, (%dx) */
  49.731  			if (!inbyte(regs, prefix, opc))
  49.732  				goto invalid;
  49.733  			return OPC_EMULATED;
  49.734  
  49.735 -		case 0xEE:	/* outb (%dx), al */
  49.736 +		case 0xEE: /* outb (%dx), al */
  49.737  			if (!outbyte(regs, prefix, opc))
  49.738  				goto invalid;
  49.739  			return OPC_EMULATED;
  49.740  
  49.741 -		case 0xF0:	/* lock */
  49.742 +		case 0xF0: /* lock */
  49.743  			TRACE((regs, regs->eip - eip, "lock"));
  49.744  			continue;
  49.745  
  49.746 -		case 0xFA:	/* cli */
  49.747 +		case 0xF6: /* addr32 testb $imm, r/m8 */
  49.748 +                        if ((prefix & ADDR32) == 0)
  49.749 +                                goto invalid;
  49.750 +                        if (!test(regs, prefix, opc))
  49.751 +                                goto invalid;
  49.752 +			return OPC_EMULATED;
  49.753 +
  49.754 +		case 0xFA: /* cli */
  49.755  			TRACE((regs, regs->eip - eip, "cli"));
  49.756  			regs->eflags &= ~EFLAGS_IF;
  49.757  			return OPC_EMULATED;
  49.758  
  49.759 -		case 0xFB:	/* sti */
  49.760 +		case 0xFB: /* sti */
  49.761  			TRACE((regs, regs->eip - eip, "sti"));
  49.762  			regs->eflags |= EFLAGS_IF;
  49.763  			return OPC_EMULATED;
  49.764 @@ -1021,6 +1336,7 @@ opcode(struct regs *regs)
  49.765  
  49.766  invalid:
  49.767  	regs->eip = eip;
  49.768 +	TRACE((regs, regs->eip - eip, "opc 0x%x", opc));
  49.769  	return OPC_INVALID;
  49.770  }
  49.771  
  49.772 @@ -1087,4 +1403,3 @@ trap(int trapno, int errno, struct regs 
  49.773  		halt();
  49.774  	}
  49.775  }
  49.776 -
    50.1 --- a/tools/xm-test/tests/vtpm/vtpm_utils.py	Wed Mar 22 08:57:48 2006 -0700
    50.2 +++ b/tools/xm-test/tests/vtpm/vtpm_utils.py	Wed Mar 22 09:12:48 2006 -0700
    50.3 @@ -8,7 +8,7 @@ from XmTestLib import *
    50.4  if ENABLE_HVM_SUPPORT:
    50.5      SKIP("vtpm tests not supported for HVM domains")
    50.6  
    50.7 -if not os.path.isfile("/dev/tpm0"):
    50.8 +if not os.path.exists("/dev/tpm0"):
    50.9      SKIP("This machine has no hardware TPM; cannot run this test")
   50.10  
   50.11  status, output = traceCommand("ps aux | grep vtpm_manager | grep -v grep")
    51.1 --- a/xen/arch/x86/hvm/svm/intr.c	Wed Mar 22 08:57:48 2006 -0700
    51.2 +++ b/xen/arch/x86/hvm/svm/intr.c	Wed Mar 22 09:12:48 2006 -0700
    51.3 @@ -58,6 +58,7 @@ static inline int svm_inject_extint(stru
    51.4      intr.fields.intr_masking = 1;
    51.5      intr.fields.vector = trap;
    51.6      intr.fields.prio = 0xF;
    51.7 +    intr.fields.ign_tpr = 1;
    51.8      vmcb->vintr = intr;
    51.9  //  printf( "IRQ = %d\n", trap );
   51.10      return 0;
   51.11 @@ -160,18 +161,21 @@ asmlinkage void svm_intr_assist(void)
   51.12      }
   51.13      /* Now let's check for newer interrrupts  */
   51.14      else {
   51.15 -        /* Interrput pending at the PIC? */
   51.16 -        hvm_pic_assist(v);
   51.17  
   51.18 -        if (vpit->pending_intr_nr) {
   51.19 -            pic_set_irq(pic, 0, 0);
   51.20 -            pic_set_irq(pic, 0, 1);
   51.21 -        }
   51.22 +      if ( v->vcpu_id == 0 )
   51.23 +         hvm_pic_assist(v);
   51.24  
   51.25 -        if (plat->interrupt_request) {
   51.26 -            intr_vector = cpu_get_interrupt(v, &intr_type);
   51.27 -            plat->interrupt_request = 0;
   51.28 -        }
   51.29 +      /* Before we deal with PIT interrupts, let's check
   51.30 +         for interrupts set by the device model.
   51.31 +      */
   51.32 +      if ( cpu_has_pending_irq(v) ) {
   51.33 +           intr_vector = cpu_get_interrupt(v, &intr_type);
   51.34 +      }
   51.35 +      else  if ( (v->vcpu_id == 0) && vpit->pending_intr_nr ) {
   51.36 +          pic_set_irq(pic, 0, 0);
   51.37 +          pic_set_irq(pic, 0, 1);
   51.38 +          intr_vector = cpu_get_interrupt(v, &intr_type);
   51.39 +      }
   51.40      }
   51.41  
   51.42      /* have we got an interrupt to inject? */
    52.1 --- a/xen/arch/x86/hvm/svm/svm.c	Wed Mar 22 08:57:48 2006 -0700
    52.2 +++ b/xen/arch/x86/hvm/svm/svm.c	Wed Mar 22 09:12:48 2006 -0700
    52.3 @@ -1243,20 +1243,19 @@ static void svm_io_instruction(struct vc
    52.4                  "svm_io_instruction: port 0x%lx real %d, eip=%lx:%lx, "
    52.5                  "exit_qualification = %lx",
    52.6                  (unsigned long) port, real, cs, eip, (unsigned long)info.bytes);
    52.7 -
    52.8 -    /* 
    52.9 -     * On SVM, the RIP of the intruction following the IN/OUT is saved in
   52.10 -     * ExitInfo2
   52.11 -     */
   52.12 -    vmcb->rip = vmcb->exitinfo2;
   52.13 -
   52.14      /* string instruction */
   52.15      if (info.fields.str)
   52.16      { 
   52.17          unsigned long addr, count = 1;
   52.18          int sign = regs->eflags & EF_DF ? -1 : 1;
   52.19  
   52.20 +        /* Need the original rip, here. */
   52.21          addr = svm_get_io_address(vmcb, regs, dir, real);
   52.22 +        /* 
   52.23 +         * On SVM, the RIP of the intruction following the IN/OUT is saved in
   52.24 +         * ExitInfo2
   52.25 +         */
   52.26 +        vmcb->rip = vmcb->exitinfo2;
   52.27  
   52.28          /* "rep" prefix */
   52.29          if (info.fields.rep) 
   52.30 @@ -1295,6 +1294,12 @@ static void svm_io_instruction(struct vc
   52.31      } 
   52.32      else 
   52.33      {
   52.34 +        /* 
   52.35 +         * On SVM, the RIP of the intruction following the IN/OUT is saved in
   52.36 +         * ExitInfo2
   52.37 +         */
   52.38 +        vmcb->rip = vmcb->exitinfo2;
   52.39 +
   52.40          if (port == 0xe9 && dir == IOREQ_WRITE && size == 1) 
   52.41              hvm_print_line(v, regs->eax); /* guest debug output */
   52.42      
   52.43 @@ -1772,6 +1777,10 @@ static inline void svm_vmexit_do_hlt(str
   52.44  
   52.45      __update_guest_eip(vmcb, 1);
   52.46  
   52.47 +    /* check for interrupt not handled or new interrupt */
   52.48 +    if ( vmcb->vintr.fields.irq || cpu_has_pending_irq(v) )
   52.49 +       return; 
   52.50 +
   52.51      if ( !v->vcpu_id )
   52.52          next_pit = get_pit_scheduled(v, vpit);
   52.53      next_wakeup = get_apictime_scheduled(v);
   52.54 @@ -1779,9 +1788,7 @@ static inline void svm_vmexit_do_hlt(str
   52.55          next_wakeup = next_pit;
   52.56      if ( next_wakeup != - 1 )
   52.57          set_timer(&current->arch.hvm_svm.hlt_timer, next_wakeup);
   52.58 -/* temporary workaround for 8828/8822 evtchn patches causing SVM failure.
   52.59      hvm_safe_block();
   52.60 -*/
   52.61  }
   52.62  
   52.63  
   52.64 @@ -2407,6 +2414,15 @@ asmlinkage void svm_vmexit_handler(struc
   52.65          do_nmi(&regs, 0);
   52.66          break;
   52.67  
   52.68 +    case VMEXIT_SMI:
   52.69 +        /*
   52.70 +         * For asynchronous SMI's, we just need to allow global interrupts 
   52.71 +         * so that the SMI is taken properly in the context of the host.  The
   52.72 +         * standard code does a STGI after the VMEXIT which should accomplish 
   52.73 +         * this task.  Continue as normal and restart the guest.
   52.74 +         */
   52.75 +        break;
   52.76 +
   52.77  #ifdef XEN_DEBUGGER
   52.78      case VMEXIT_EXCEPTION_BP:
   52.79          svm_debug_save_cpu_user_regs(&regs);
    53.1 --- a/xen/arch/x86/hvm/svm/vmcb.c	Wed Mar 22 08:57:48 2006 -0700
    53.2 +++ b/xen/arch/x86/hvm/svm/vmcb.c	Wed Mar 22 09:12:48 2006 -0700
    53.3 @@ -123,7 +123,7 @@ static int construct_vmcb_controls(struc
    53.4            GENERAL1_INTERCEPT_RDTSC         | GENERAL1_INTERCEPT_PUSHF      |
    53.5            GENERAL1_INTERCEPT_SWINT         | GENERAL1_INTERCEPT_POPF       | 
    53.6            GENERAL1_INTERCEPT_IRET          | GENERAL1_INTERCEPT_PAUSE      |
    53.7 -          GENERAL1_INTERCEPT_TASK_SWITCH
    53.8 +          GENERAL1_INTERCEPT_TASK_SWITCH   | GENERAL1_INTERCEPT_SMI
    53.9          );
   53.10  
   53.11      /* turn on the general 2 intercepts */