ia64/xen-unstable

changeset 9374:a9f5cf43451f

merge
author awilliam@xenbuild.aw
date Tue Mar 21 11:19:11 2006 -0700 (2006-03-21)
parents f163677f8767 5e5e56b5e751
children 369bdeb29606
files patches/linux-2.6.16-rc5/i386-mach-io-check-nmi.patch patches/linux-2.6.16-rc5/net-csum.patch patches/linux-2.6.16-rc5/pmd-shared.patch patches/linux-2.6.16-rc5/smp-alts.patch xen/include/asm-ia64/linux-null/asm-generic/pci-dma-compat.h xen/include/asm-ia64/linux-null/asm/scatterlist.h xen/include/xen/irq.h
line diff
     1.1 --- a/.hgignore	Tue Mar 21 09:55:44 2006 -0700
     1.2 +++ b/.hgignore	Tue Mar 21 11:19:11 2006 -0700
     1.3 @@ -13,6 +13,7 @@
     1.4  .*\.flc$
     1.5  .*\.orig$
     1.6  .*\.rej$
     1.7 +.*/a\.out$
     1.8  ^[^/]*\.bz2$
     1.9  ^TAGS$
    1.10  ^dist/.*$
     2.1 --- a/buildconfigs/Rules.mk	Tue Mar 21 09:55:44 2006 -0700
     2.2 +++ b/buildconfigs/Rules.mk	Tue Mar 21 11:19:11 2006 -0700
     2.3 @@ -70,7 +70,7 @@ pristine-%/.valid-pristine: %.tar.bz2
     2.4  	rm -rf tmp-pristine-$* $(@D)
     2.5  	mkdir -p tmp-pristine-$*
     2.6  	tar -C tmp-pristine-$* -jxf $<
     2.7 -	-@rm tmp-pristine-$*/pax_global_header
     2.8 +	-@rm -f tmp-pristine-$*/pax_global_header
     2.9  	mv tmp-pristine-$*/* $(@D)
    2.10  	@rm -rf tmp-pristine-$*
    2.11  	touch $(@D)/.hgskip
     3.1 --- a/buildconfigs/linux-defconfig_xen0_x86_32	Tue Mar 21 09:55:44 2006 -0700
     3.2 +++ b/buildconfigs/linux-defconfig_xen0_x86_32	Tue Mar 21 11:19:11 2006 -0700
     3.3 @@ -1328,6 +1328,7 @@ CONFIG_XEN_NETDEV_FRONTEND=y
     3.4  # CONFIG_XEN_TPMDEV_FRONTEND is not set
     3.5  CONFIG_XEN_SCRUB_PAGES=y
     3.6  CONFIG_XEN_DISABLE_SERIAL=y
     3.7 +CONFIG_XEN_SYSFS=y
     3.8  CONFIG_HAVE_ARCH_ALLOC_SKB=y
     3.9  CONFIG_HAVE_ARCH_DEV_ALLOC_SKB=y
    3.10  
     4.1 --- a/buildconfigs/linux-defconfig_xen0_x86_64	Tue Mar 21 09:55:44 2006 -0700
     4.2 +++ b/buildconfigs/linux-defconfig_xen0_x86_64	Tue Mar 21 11:19:11 2006 -0700
     4.3 @@ -1253,6 +1253,7 @@ CONFIG_XEN_NETDEV_FRONTEND=y
     4.4  # CONFIG_XEN_TPMDEV_FRONTEND is not set
     4.5  CONFIG_XEN_SCRUB_PAGES=y
     4.6  CONFIG_XEN_DISABLE_SERIAL=y
     4.7 +CONFIG_XEN_SYSFS=y
     4.8  CONFIG_HAVE_ARCH_ALLOC_SKB=y
     4.9  CONFIG_HAVE_ARCH_DEV_ALLOC_SKB=y
    4.10  
     5.1 --- a/buildconfigs/linux-defconfig_xenU_x86_32	Tue Mar 21 09:55:44 2006 -0700
     5.2 +++ b/buildconfigs/linux-defconfig_xenU_x86_32	Tue Mar 21 11:19:11 2006 -0700
     5.3 @@ -868,6 +868,7 @@ CONFIG_XEN_NETDEV_FRONTEND=y
     5.4  # CONFIG_XEN_TPMDEV_FRONTEND is not set
     5.5  CONFIG_XEN_SCRUB_PAGES=y
     5.6  CONFIG_XEN_DISABLE_SERIAL=y
     5.7 +CONFIG_XEN_SYSFS=y
     5.8  CONFIG_HAVE_ARCH_ALLOC_SKB=y
     5.9  CONFIG_HAVE_ARCH_DEV_ALLOC_SKB=y
    5.10  
     6.1 --- a/buildconfigs/linux-defconfig_xenU_x86_64	Tue Mar 21 09:55:44 2006 -0700
     6.2 +++ b/buildconfigs/linux-defconfig_xenU_x86_64	Tue Mar 21 11:19:11 2006 -0700
     6.3 @@ -1144,6 +1144,7 @@ CONFIG_XEN_NETDEV_FRONTEND=y
     6.4  # CONFIG_XEN_TPMDEV_FRONTEND is not set
     6.5  CONFIG_XEN_SCRUB_PAGES=y
     6.6  CONFIG_XEN_DISABLE_SERIAL=y
     6.7 +CONFIG_XEN_SYSFS=y
     6.8  CONFIG_HAVE_ARCH_ALLOC_SKB=y
     6.9  CONFIG_HAVE_ARCH_DEV_ALLOC_SKB=y
    6.10  
     7.1 --- a/buildconfigs/linux-defconfig_xen_x86_32	Tue Mar 21 09:55:44 2006 -0700
     7.2 +++ b/buildconfigs/linux-defconfig_xen_x86_32	Tue Mar 21 11:19:11 2006 -0700
     7.3 @@ -2994,6 +2994,7 @@ CONFIG_XEN_NETDEV_FRONTEND=y
     7.4  # CONFIG_XEN_TPMDEV_FRONTEND is not set
     7.5  CONFIG_XEN_SCRUB_PAGES=y
     7.6  CONFIG_XEN_DISABLE_SERIAL=y
     7.7 +CONFIG_XEN_SYSFS=m
     7.8  CONFIG_HAVE_ARCH_ALLOC_SKB=y
     7.9  CONFIG_HAVE_ARCH_DEV_ALLOC_SKB=y
    7.10  
     8.1 --- a/buildconfigs/linux-defconfig_xen_x86_64	Tue Mar 21 09:55:44 2006 -0700
     8.2 +++ b/buildconfigs/linux-defconfig_xen_x86_64	Tue Mar 21 11:19:11 2006 -0700
     8.3 @@ -2665,6 +2665,7 @@ CONFIG_XEN_NETDEV_FRONTEND=y
     8.4  # CONFIG_XEN_TPMDEV_FRONTEND is not set
     8.5  CONFIG_XEN_SCRUB_PAGES=y
     8.6  CONFIG_XEN_DISABLE_SERIAL=y
     8.7 +CONFIG_XEN_SYSFS=m
     8.8  CONFIG_HAVE_ARCH_ALLOC_SKB=y
     8.9  CONFIG_HAVE_ARCH_DEV_ALLOC_SKB=y
    8.10  
     9.1 --- a/buildconfigs/mk.linux-2.6-xen	Tue Mar 21 09:55:44 2006 -0700
     9.2 +++ b/buildconfigs/mk.linux-2.6-xen	Tue Mar 21 11:19:11 2006 -0700
     9.3 @@ -2,9 +2,8 @@
     9.4  OS           = linux
     9.5  
     9.6  LINUX_SERIES = 2.6
     9.7 -LINUX_VER    = 2.6.16-rc5
     9.8 -LINUX_SRCS = linux-2.6.15.tar.bz2 patch-2.6.16-rc5.bz2
     9.9 -LINUX_PDIR = linux-$(LINUX_VER)
    9.10 +LINUX_VER    = 2.6.16
    9.11 +LINUX_SRCS = linux-2.6.16.tar.bz2
    9.12  
    9.13  EXTRAVERSION ?= xen
    9.14  
    9.15 @@ -23,20 +22,6 @@ build: $(LINUX_DIR)/include/linux/autoco
    9.16  	$(MAKE) -C $(LINUX_DIR) ARCH=$(LINUX_ARCH) INSTALL_PATH=$(DESTDIR) vmlinuz
    9.17  	$(MAKE) -C $(LINUX_DIR) ARCH=$(LINUX_ARCH) INSTALL_PATH=$(DESTDIR) install
    9.18  
    9.19 -pristine-$(LINUX_PDIR)/.valid-srcs: $(LINUX_SRCS)
    9.20 -	rm -rf tmp-pristine-$(LINUX_PDIR) $(@D)
    9.21 -	mkdir -p tmp-pristine-$(LINUX_PDIR)
    9.22 -	tar -C tmp-pristine-$(LINUX_PDIR) -jxf $<
    9.23 -	-@rm tmp-pristine-$(LINUX_PDIR)/pax_global_header
    9.24 -	mv tmp-pristine-$(LINUX_PDIR)/* $(@D)
    9.25 -	@rm -rf tmp-pristine-$(LINUX_PDIR)
    9.26 -	bzcat $(wordlist 2,$(words $^),$^) | patch -d $(@D) -p1
    9.27 -	touch $(@D)/.hgskip
    9.28 -	touch $@
    9.29 -
    9.30 -pristine-linux-%.16-rc5/.valid-pristine: pristine-$(LINUX_PDIR)/.valid-srcs
    9.31 -	touch $@ # update timestamp to avoid rebuild
    9.32 -
    9.33  $(LINUX_DIR)/include/linux/autoconf.h: ref-$(OS)-$(LINUX_VER)/.valid-ref
    9.34  	rm -rf $(LINUX_DIR)
    9.35  	cp -al $(<D) $(LINUX_DIR)
    10.1 --- a/linux-2.6-xen-sparse/arch/i386/kernel/Makefile	Tue Mar 21 09:55:44 2006 -0700
    10.2 +++ b/linux-2.6-xen-sparse/arch/i386/kernel/Makefile	Tue Mar 21 11:19:11 2006 -0700
    10.3 @@ -11,7 +11,7 @@ obj-y	:= process.o semaphore.o signal.o 
    10.4  
    10.5  obj-y				+= cpu/
    10.6  obj-y				+= timers/
    10.7 -obj-$(CONFIG_ACPI)		+= acpi/
    10.8 +obj-y				+= acpi/
    10.9  obj-$(CONFIG_X86_BIOS_REBOOT)	+= reboot.o
   10.10  obj-$(CONFIG_MCA)		+= mca.o
   10.11  obj-$(CONFIG_X86_MSR)		+= msr.o
    11.1 --- a/linux-2.6-xen-sparse/arch/i386/kernel/acpi/Makefile	Tue Mar 21 09:55:44 2006 -0700
    11.2 +++ b/linux-2.6-xen-sparse/arch/i386/kernel/acpi/Makefile	Tue Mar 21 11:19:11 2006 -0700
    11.3 @@ -1,4 +1,4 @@
    11.4 -obj-y				:= boot.o
    11.5 +obj-$(CONFIG_ACPI)		+= boot.o
    11.6  obj-$(CONFIG_X86_IO_APIC)	+= earlyquirk.o
    11.7  obj-$(CONFIG_ACPI_SLEEP)	+= sleep.o wakeup.o
    11.8  
    12.1 --- a/linux-2.6-xen-sparse/arch/i386/kernel/acpi/boot-xen.c	Tue Mar 21 09:55:44 2006 -0700
    12.2 +++ b/linux-2.6-xen-sparse/arch/i386/kernel/acpi/boot-xen.c	Tue Mar 21 11:19:11 2006 -0700
    12.3 @@ -44,6 +44,9 @@ extern void __init clustered_apic_check(
    12.4  extern int gsi_irq_sharing(int gsi);
    12.5  #include <asm/proto.h>
    12.6  
    12.7 +static inline int acpi_madt_oem_check(char *oem_id, char *oem_table_id) { return 0; }
    12.8 +
    12.9 +
   12.10  #else				/* X86 */
   12.11  
   12.12  #ifdef	CONFIG_X86_LOCAL_APIC
   12.13 @@ -1111,9 +1114,6 @@ int __init acpi_boot_table_init(void)
   12.14  		disable_acpi();
   12.15  		return error;
   12.16  	}
   12.17 -#ifdef __i386__
   12.18 -	check_acpi_pci();
   12.19 -#endif
   12.20  
   12.21  	acpi_table_parse(ACPI_BOOT, acpi_parse_sbf);
   12.22  
    13.1 --- a/linux-2.6-xen-sparse/arch/i386/kernel/cpu/common-xen.c	Tue Mar 21 09:55:44 2006 -0700
    13.2 +++ b/linux-2.6-xen-sparse/arch/i386/kernel/cpu/common-xen.c	Tue Mar 21 11:19:11 2006 -0700
    13.3 @@ -283,10 +283,10 @@ void __devinit generic_identify(struct c
    13.4  			c->x86_capability[4] = excap;
    13.5  			c->x86 = (tfms >> 8) & 15;
    13.6  			c->x86_model = (tfms >> 4) & 15;
    13.7 -			if (c->x86 == 0xf) {
    13.8 +			if (c->x86 == 0xf)
    13.9  				c->x86 += (tfms >> 20) & 0xff;
   13.10 +			if (c->x86 >= 0x6)
   13.11  				c->x86_model += ((tfms >> 16) & 0xF) << 4;
   13.12 -			} 
   13.13  			c->x86_mask = tfms & 15;
   13.14  		} else {
   13.15  			/* Have CPUID level 0 only - unheard of */
    14.1 --- a/linux-2.6-xen-sparse/arch/i386/kernel/io_apic-xen.c	Tue Mar 21 09:55:44 2006 -0700
    14.2 +++ b/linux-2.6-xen-sparse/arch/i386/kernel/io_apic-xen.c	Tue Mar 21 11:19:11 2006 -0700
    14.3 @@ -93,6 +93,8 @@ static struct { int pin, apic; } ioapic_
    14.4  
    14.5  static DEFINE_SPINLOCK(ioapic_lock);
    14.6  
    14.7 +int timer_over_8254 __initdata = 1;
    14.8 +
    14.9  /*
   14.10   *	Is the SiS APIC rmw bug present ?
   14.11   *	-1 = don't know, 0 = no, 1 = yes
   14.12 @@ -2329,7 +2331,8 @@ static inline void check_timer(void)
   14.13  	apic_write_around(APIC_LVT0, APIC_LVT_MASKED | APIC_DM_EXTINT);
   14.14  	init_8259A(1);
   14.15  	timer_ack = 1;
   14.16 -	enable_8259A_irq(0);
   14.17 +	if (timer_over_8254 > 0)
   14.18 +		enable_8259A_irq(0);
   14.19  
   14.20  	pin1  = find_isa_irq_pin(0, mp_INT);
   14.21  	apic1 = find_isa_irq_apic(0, mp_INT);
   14.22 @@ -2459,6 +2462,20 @@ void __init setup_IO_APIC(void)
   14.23  		print_IO_APIC();
   14.24  }
   14.25  
   14.26 +static int __init setup_disable_8254_timer(char *s)
   14.27 +{
   14.28 +	timer_over_8254 = -1;
   14.29 +	return 1;
   14.30 +}
   14.31 +static int __init setup_enable_8254_timer(char *s)
   14.32 +{
   14.33 +	timer_over_8254 = 2;
   14.34 +	return 1;
   14.35 +}
   14.36 +
   14.37 +__setup("disable_8254_timer", setup_disable_8254_timer);
   14.38 +__setup("enable_8254_timer", setup_enable_8254_timer);
   14.39 +
   14.40  /*
   14.41   *	Called after all the initialization is done. If we didnt find any
   14.42   *	APIC bugs then we can allow the modify fast path
    15.1 --- a/linux-2.6-xen-sparse/arch/i386/kernel/microcode-xen.c	Tue Mar 21 09:55:44 2006 -0700
    15.2 +++ b/linux-2.6-xen-sparse/arch/i386/kernel/microcode-xen.c	Tue Mar 21 11:19:11 2006 -0700
    15.3 @@ -25,6 +25,7 @@
    15.4  #include <linux/kernel.h>
    15.5  #include <linux/init.h>
    15.6  #include <linux/sched.h>
    15.7 +#include <linux/cpumask.h>
    15.8  #include <linux/module.h>
    15.9  #include <linux/slab.h>
   15.10  #include <linux/vmalloc.h>
    16.1 --- a/linux-2.6-xen-sparse/arch/i386/kernel/setup-xen.c	Tue Mar 21 09:55:44 2006 -0700
    16.2 +++ b/linux-2.6-xen-sparse/arch/i386/kernel/setup-xen.c	Tue Mar 21 11:19:11 2006 -0700
    16.3 @@ -1819,6 +1819,10 @@ void __init setup_arch(char **cmdline_p)
    16.4  	op.u.set_iopl.iopl = 1;
    16.5  	HYPERVISOR_physdev_op(&op);
    16.6  
    16.7 +#ifdef CONFIG_X86_IO_APIC
    16.8 +	check_acpi_pci();	/* Checks more than just ACPI actually */
    16.9 +#endif
   16.10 +
   16.11  #ifdef CONFIG_ACPI
   16.12  	if (!(xen_start_info->flags & SIF_INITDOMAIN)) {
   16.13  		printk(KERN_INFO "ACPI in unprivileged domain disabled\n");
    17.1 --- a/linux-2.6-xen-sparse/arch/i386/kernel/smpboot.c	Tue Mar 21 09:55:44 2006 -0700
    17.2 +++ b/linux-2.6-xen-sparse/arch/i386/kernel/smpboot.c	Tue Mar 21 11:19:11 2006 -0700
    17.3 @@ -1029,6 +1029,16 @@ int __devinit smp_prepare_cpu(int cpu)
    17.4  	int	apicid, ret;
    17.5  
    17.6  	lock_cpu_hotplug();
    17.7 +
    17.8 +	/*
    17.9 +	 * On x86, CPU0 is never offlined.  Trying to bring up an
   17.10 +	 * already-booted CPU will hang.  So check for that case.
   17.11 +	 */
   17.12 +	if (cpu_online(cpu)) {
   17.13 +		ret = -EINVAL;
   17.14 +		goto exit;
   17.15 +	}
   17.16 +
   17.17  	apicid = x86_cpu_to_apicid[cpu];
   17.18  	if (apicid == BAD_APICID) {
   17.19  		ret = -ENODEV;
    18.1 --- a/linux-2.6-xen-sparse/arch/i386/kernel/time-xen.c	Tue Mar 21 09:55:44 2006 -0700
    18.2 +++ b/linux-2.6-xen-sparse/arch/i386/kernel/time-xen.c	Tue Mar 21 11:19:11 2006 -0700
    18.3 @@ -157,8 +157,8 @@ static int __init __independent_wallcloc
    18.4  }
    18.5  __setup("independent_wallclock", __independent_wallclock);
    18.6  
    18.7 -/* Permitted clock jitter, in usecs, beyond which a warning will be printed. */
    18.8 -static unsigned long permitted_clock_jitter = 10000UL;
    18.9 +/* Permitted clock jitter, in nsecs, beyond which a warning will be printed. */
   18.10 +static unsigned long permitted_clock_jitter = 10000000UL; /* 10ms */
   18.11  static int __init __permitted_clock_jitter(char *str)
   18.12  {
   18.13  	permitted_clock_jitter = simple_strtoul(str, NULL, 0);
   18.14 @@ -840,9 +840,9 @@ static int timer_resume(struct sys_devic
   18.15  	write_seqlock_irqsave(&xtime_lock, flags);
   18.16  	xtime.tv_sec = sec;
   18.17  	xtime.tv_nsec = 0;
   18.18 +	jiffies_64 += sleep_length;
   18.19 +	wall_jiffies += sleep_length;
   18.20  	write_sequnlock_irqrestore(&xtime_lock, flags);
   18.21 -	jiffies += sleep_length;
   18.22 -	wall_jiffies += sleep_length;
   18.23  	if (last_timer->resume)
   18.24  		last_timer->resume();
   18.25  	cur_timer = last_timer;
    19.1 --- a/linux-2.6-xen-sparse/arch/i386/mm/init-xen.c	Tue Mar 21 09:55:44 2006 -0700
    19.2 +++ b/linux-2.6-xen-sparse/arch/i386/mm/init-xen.c	Tue Mar 21 11:19:11 2006 -0700
    19.3 @@ -42,6 +42,11 @@
    19.4  #include <asm/tlbflush.h>
    19.5  #include <asm/sections.h>
    19.6  #include <asm/hypervisor.h>
    19.7 +#if defined(CONFIG_SWIOTLB)
    19.8 +#include <linux/dma-mapping.h>
    19.9 +#include <asm/scatterlist.h>
   19.10 +#include <asm/swiotlb.h>
   19.11 +#endif
   19.12  
   19.13  extern unsigned long *contiguous_bitmap;
   19.14  
    20.1 --- a/linux-2.6-xen-sparse/arch/x86_64/kernel/entry-xen.S	Tue Mar 21 09:55:44 2006 -0700
    20.2 +++ b/linux-2.6-xen-sparse/arch/x86_64/kernel/entry-xen.S	Tue Mar 21 11:19:11 2006 -0700
    20.3 @@ -818,7 +818,7 @@ 11:	movb $0, EVENT_MASK(%rdi)
    20.4  	jmp  error_exit
    20.5  
    20.6  #ifdef CONFIG_X86_LOCAL_APIC
    20.7 -ENTRY(nmi)
    20.8 +KPROBE_ENTRY(nmi)
    20.9  	zeroentry do_nmi_callback
   20.10  ENTRY(do_nmi_callback)
   20.11          addq $8, %rsp
   20.12 @@ -828,6 +828,7 @@ ENTRY(do_nmi_callback)
   20.13          XEN_BLOCK_EVENTS(%rsi)
   20.14          GET_THREAD_INFO(%rcx)
   20.15          jmp  retint_restore_args
   20.16 +	.previous .text
   20.17  #endif
   20.18  
   20.19          ALIGN
    21.1 --- a/linux-2.6-xen-sparse/drivers/char/tty_io.c	Tue Mar 21 09:55:44 2006 -0700
    21.2 +++ b/linux-2.6-xen-sparse/drivers/char/tty_io.c	Tue Mar 21 11:19:11 2006 -0700
    21.3 @@ -305,7 +305,7 @@ static struct tty_buffer *tty_buffer_fin
    21.4  			t->commit = 0;
    21.5  			t->read = 0;
    21.6  			/* DEBUG ONLY */
    21.7 -			memset(t->data, '*', size);
    21.8 +/*			memset(t->data, '*', size); */
    21.9  /* 			printk("Flip recycle %p\n", t); */
   21.10  			return t;
   21.11  		}
    22.1 --- a/linux-2.6-xen-sparse/drivers/xen/Kconfig	Tue Mar 21 09:55:44 2006 -0700
    22.2 +++ b/linux-2.6-xen-sparse/drivers/xen/Kconfig	Tue Mar 21 11:19:11 2006 -0700
    22.3 @@ -189,6 +189,14 @@ config XEN_DISABLE_SERIAL
    22.4  	  Disable serial port drivers, allowing the Xen console driver
    22.5  	  to provide a serial console at ttyS0.
    22.6  
    22.7 +config XEN_SYSFS
    22.8 +	tristate "Export Xen attributes in sysfs"
    22.9 +	depends on XEN
   22.10 +	depends on SYSFS
   22.11 +	default y
   22.12 +	help
   22.13 +		Xen hypervisor attributes will show up under /sys/hypervisor/.
   22.14 +
   22.15  endmenu
   22.16  
   22.17  config HAVE_ARCH_ALLOC_SKB
    23.1 --- a/linux-2.6-xen-sparse/drivers/xen/core/Makefile	Tue Mar 21 09:55:44 2006 -0700
    23.2 +++ b/linux-2.6-xen-sparse/drivers/xen/core/Makefile	Tue Mar 21 11:19:11 2006 -0700
    23.3 @@ -7,3 +7,5 @@ obj-y   := evtchn.o reboot.o gnttab.o fe
    23.4  obj-$(CONFIG_PROC_FS) += xen_proc.o
    23.5  obj-$(CONFIG_NET)     += skbuff.o
    23.6  obj-$(CONFIG_SMP)     += smpboot.o
    23.7 +obj-$(CONFIG_SYSFS)   += hypervisor_sysfs.o
    23.8 +obj-$(CONFIG_XEN_SYSFS) += xen_sysfs.o
    24.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    24.2 +++ b/linux-2.6-xen-sparse/drivers/xen/core/hypervisor_sysfs.c	Tue Mar 21 11:19:11 2006 -0700
    24.3 @@ -0,0 +1,57 @@
    24.4 +/*
    24.5 + *  copyright (c) 2006 IBM Corporation
    24.6 + *  Authored by: Mike D. Day <ncmike@us.ibm.com>
    24.7 + *
    24.8 + *  This program is free software; you can redistribute it and/or modify
    24.9 + *  it under the terms of the GNU General Public License version 2 as
   24.10 + *  published by the Free Software Foundation.
   24.11 + */
   24.12 +
   24.13 +#include <linux/config.h>
   24.14 +#include <linux/kernel.h>
   24.15 +#include <linux/module.h>
   24.16 +#include <linux/kobject.h>
   24.17 +#include <xen/hypervisor_sysfs.h>
   24.18 +
   24.19 +decl_subsys(hypervisor, NULL, NULL);
   24.20 +
   24.21 +static ssize_t hyp_sysfs_show(struct kobject *kobj,
   24.22 +			      struct attribute *attr,
   24.23 +			      char *buffer)
   24.24 +{
   24.25 +	struct hyp_sysfs_attr *hyp_attr;
   24.26 +	hyp_attr = container_of(attr, struct hyp_sysfs_attr, attr);
   24.27 +	if (hyp_attr->show)
   24.28 +		return hyp_attr->show(hyp_attr, buffer);
   24.29 +	return 0;
   24.30 +}
   24.31 +
   24.32 +static ssize_t hyp_sysfs_store(struct kobject *kobj,
   24.33 +			       struct attribute *attr,
   24.34 +			       const char *buffer,
   24.35 +			       size_t len)
   24.36 +{
   24.37 +	struct hyp_sysfs_attr *hyp_attr;
   24.38 +	hyp_attr = container_of(attr, struct hyp_sysfs_attr, attr);
   24.39 +	if (hyp_attr->store)
   24.40 +		return hyp_attr->store(hyp_attr, buffer, len);
   24.41 +	return 0;
   24.42 +}
   24.43 +
   24.44 +struct sysfs_ops hyp_sysfs_ops = {
   24.45 +	.show = hyp_sysfs_show,
   24.46 +	.store = hyp_sysfs_store,
   24.47 +};
   24.48 +
   24.49 +static struct kobj_type hyp_sysfs_kobj_type = {
   24.50 +	.sysfs_ops = &hyp_sysfs_ops,
   24.51 +};
   24.52 +
   24.53 +static int __init hypervisor_subsys_init(void)
   24.54 +{
   24.55 +	hypervisor_subsys.kset.kobj.ktype = &hyp_sysfs_kobj_type;
   24.56 +	return subsystem_register(&hypervisor_subsys);
   24.57 +}
   24.58 +
   24.59 +device_initcall(hypervisor_subsys_init);
   24.60 +EXPORT_SYMBOL_GPL(hypervisor_subsys);
    25.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    25.2 +++ b/linux-2.6-xen-sparse/drivers/xen/core/xen_sysfs.c	Tue Mar 21 11:19:11 2006 -0700
    25.3 @@ -0,0 +1,310 @@
    25.4 +/*
    25.5 + *  copyright (c) 2006 IBM Corporation
    25.6 + *  Authored by: Mike D. Day <ncmike@us.ibm.com>
    25.7 + *
    25.8 + *  This program is free software; you can redistribute it and/or modify
    25.9 + *  it under the terms of the GNU General Public License version 2 as
   25.10 + *  published by the Free Software Foundation.
   25.11 + */
   25.12 +
   25.13 +#include <linux/config.h>
   25.14 +#include <linux/kernel.h>
   25.15 +#include <linux/module.h>
   25.16 +#include <linux/init.h>
   25.17 +#include <asm/hypervisor.h>
   25.18 +#include <xen/hypervisor_sysfs.h>
   25.19 +
   25.20 +MODULE_LICENSE("GPL");
   25.21 +MODULE_AUTHOR("Mike D. Day <ncmike@us.ibm.com>");
   25.22 +
   25.23 +static ssize_t type_show(struct hyp_sysfs_attr *attr, char *buffer)
   25.24 +{
   25.25 +	return sprintf(buffer, "xen\n");
   25.26 +}
   25.27 +
   25.28 +HYPERVISOR_ATTR_RO(type);
   25.29 +
   25.30 +static int __init xen_sysfs_type_init(void)
   25.31 +{
   25.32 +	return sysfs_create_file(&hypervisor_subsys.kset.kobj, &type_attr.attr);
   25.33 +}
   25.34 +
   25.35 +static void xen_sysfs_type_destroy(void)
   25.36 +{
   25.37 +	sysfs_remove_file(&hypervisor_subsys.kset.kobj, &type_attr.attr);
   25.38 +}
   25.39 +
   25.40 +/* xen version attributes */
   25.41 +static ssize_t major_show(struct hyp_sysfs_attr *attr, char *buffer)
   25.42 +{
   25.43 +	int version = HYPERVISOR_xen_version(XENVER_version, NULL);
   25.44 +	if (version)
   25.45 +		return sprintf(buffer, "%d\n", version >> 16);
   25.46 +	return -ENODEV;
   25.47 +}
   25.48 +
   25.49 +HYPERVISOR_ATTR_RO(major);
   25.50 +
   25.51 +static ssize_t minor_show(struct hyp_sysfs_attr *attr, char *buffer)
   25.52 +{
   25.53 +	int version = HYPERVISOR_xen_version(XENVER_version, NULL);
   25.54 +	if (version)
   25.55 +		return sprintf(buffer, "%d\n", version & 0xff);
   25.56 +	return -ENODEV;
   25.57 +}
   25.58 +
   25.59 +HYPERVISOR_ATTR_RO(minor);
   25.60 +
   25.61 +static ssize_t extra_show(struct hyp_sysfs_attr *attr, char *buffer)
   25.62 +{
   25.63 +	int ret;
   25.64 +	char *extra = kmalloc(XEN_EXTRAVERSION_LEN, GFP_KERNEL);
   25.65 +	if (extra) {
   25.66 +		ret = HYPERVISOR_xen_version(XENVER_extraversion, extra);
   25.67 +		if (!ret)
   25.68 +			return sprintf(buffer, "%s\n", extra);
   25.69 +		kfree(extra);
   25.70 +	} else
   25.71 +		ret = -ENOMEM;
   25.72 +	return ret;
   25.73 +}
   25.74 +
   25.75 +HYPERVISOR_ATTR_RO(extra);
   25.76 +
   25.77 +static struct attribute *version_attrs[] = {
   25.78 +	&major_attr.attr,
   25.79 +	&minor_attr.attr,
   25.80 +	&extra_attr.attr,
   25.81 +	NULL
   25.82 +};
   25.83 +
   25.84 +static struct attribute_group version_group = {
   25.85 +	.name = "version",
   25.86 +	.attrs = version_attrs,
   25.87 +};
   25.88 +
   25.89 +static int __init xen_sysfs_version_init(void)
   25.90 +{
   25.91 +	return sysfs_create_group(&hypervisor_subsys.kset.kobj, &version_group);
   25.92 +}
   25.93 +
   25.94 +static void xen_sysfs_version_destroy(void)
   25.95 +{
   25.96 +	sysfs_remove_group(&hypervisor_subsys.kset.kobj, &version_group);
   25.97 +}
   25.98 +
   25.99 +/* xen compilation attributes */
  25.100 +
  25.101 +static ssize_t compiler_show(struct hyp_sysfs_attr *attr, char *buffer)
  25.102 +{
  25.103 +	int ret;
  25.104 +	struct xen_compile_info *info =
  25.105 +	    kmalloc(sizeof(struct xen_compile_info), GFP_KERNEL);
  25.106 +	if (info) {
  25.107 +		ret = HYPERVISOR_xen_version(XENVER_compile_info, info);
  25.108 +		if (!ret)
  25.109 +			ret = sprintf(buffer, "%s\n", info->compiler);
  25.110 +		kfree(info);
  25.111 +	} else
  25.112 +		ret = -ENOMEM;
  25.113 +
  25.114 +	return ret;
  25.115 +}
  25.116 +
  25.117 +HYPERVISOR_ATTR_RO(compiler);
  25.118 +
  25.119 +static ssize_t compiled_by_show(struct hyp_sysfs_attr *attr, char *buffer)
  25.120 +{
  25.121 +	int ret;
  25.122 +	struct xen_compile_info *info;
  25.123 +
  25.124 +	info = kmalloc(sizeof(struct xen_compile_info), GFP_KERNEL);
  25.125 +	if (info) {
  25.126 +		ret = HYPERVISOR_xen_version(XENVER_compile_info, info);
  25.127 +		if (!ret)
  25.128 +			ret = sprintf(buffer, "%s\n", info->compile_by);
  25.129 +		kfree(info);
  25.130 +	} else
  25.131 +		ret = -ENOMEM;
  25.132 +	return ret;
  25.133 +}
  25.134 +
  25.135 +HYPERVISOR_ATTR_RO(compiled_by);
  25.136 +
  25.137 +static ssize_t compile_date_show(struct hyp_sysfs_attr *attr, char *buffer)
  25.138 +{
  25.139 +	int ret;
  25.140 +	struct xen_compile_info *info;
  25.141 +
  25.142 +	info = kmalloc(sizeof(struct xen_compile_info), GFP_KERNEL);
  25.143 +	if (info) {
  25.144 +		ret = HYPERVISOR_xen_version(XENVER_compile_info, info);
  25.145 +		if (!ret)
  25.146 +			ret = sprintf(buffer, "%s\n", info->compile_date);
  25.147 +		kfree(info);
  25.148 +	} else
  25.149 +		ret = -ENOMEM;
  25.150 +	return ret;
  25.151 +}
  25.152 +
  25.153 +HYPERVISOR_ATTR_RO(compile_date);
  25.154 +
  25.155 +static struct attribute *xen_compile_attrs[] = {
  25.156 +	&compiler_attr.attr,
  25.157 +	&compiled_by_attr.attr,
  25.158 +	&compile_date_attr.attr,
  25.159 +	NULL
  25.160 +};
  25.161 +
  25.162 +static struct attribute_group xen_compilation_group = {
  25.163 +	.name = "compilation",
  25.164 +	.attrs = xen_compile_attrs,
  25.165 +};
  25.166 +
  25.167 +int __init static xen_compilation_init(void)
  25.168 +{
  25.169 +	return sysfs_create_group(&hypervisor_subsys.kset.kobj,
  25.170 +				  &xen_compilation_group);
  25.171 +}
  25.172 +
  25.173 +static void xen_compilation_destroy(void)
  25.174 +{
  25.175 +	sysfs_remove_group(&hypervisor_subsys.kset.kobj,
  25.176 +			   &xen_compilation_group);
  25.177 +}
  25.178 +
  25.179 +/* xen properties info */
  25.180 +
  25.181 +static ssize_t capabilities_show(struct hyp_sysfs_attr *attr, char *buffer)
  25.182 +{
  25.183 +	int ret;
  25.184 +	char *caps = kmalloc(XEN_CAPABILITIES_INFO_LEN, GFP_KERNEL);
  25.185 +	if (caps) {
  25.186 +		ret = HYPERVISOR_xen_version(XENVER_capabilities, caps);
  25.187 +		if (!ret)
  25.188 +			ret = sprintf(buffer, "%s\n", caps);
  25.189 +		kfree(caps);
  25.190 +	} else
  25.191 +		ret = -ENOMEM;
  25.192 +	return ret;
  25.193 +}
  25.194 +
  25.195 +HYPERVISOR_ATTR_RO(capabilities);
  25.196 +
  25.197 +static ssize_t changeset_show(struct hyp_sysfs_attr *attr, char *buffer)
  25.198 +{
  25.199 +	int ret;
  25.200 +	char *cset = kmalloc(XEN_CHANGESET_INFO_LEN, GFP_KERNEL);
  25.201 +	if (cset) {
  25.202 +		ret = HYPERVISOR_xen_version(XENVER_changeset, cset);
  25.203 +		if (!ret)
  25.204 +			ret = sprintf(buffer, "%s\n", cset);
  25.205 +		kfree(cset);
  25.206 +	} else
  25.207 +		ret = -ENOMEM;
  25.208 +	return ret;
  25.209 +}
  25.210 +
  25.211 +HYPERVISOR_ATTR_RO(changeset);
  25.212 +
  25.213 +static ssize_t virtual_start_show(struct hyp_sysfs_attr *attr, char *buffer)
  25.214 +{
  25.215 +	int ret;
  25.216 +	struct xen_platform_parameters *parms =
  25.217 +	    kmalloc(sizeof(struct xen_platform_parameters), GFP_KERNEL);
  25.218 +	if (parms) {
  25.219 +		ret = HYPERVISOR_xen_version(XENVER_platform_parameters, parms);
  25.220 +		if (!ret)
  25.221 +			ret = sprintf(buffer, "%lx\n", parms->virt_start);
  25.222 +		kfree(parms);
  25.223 +	} else
  25.224 +		ret = -ENOMEM;
  25.225 +	return ret;
  25.226 +}
  25.227 +
  25.228 +HYPERVISOR_ATTR_RO(virtual_start);
  25.229 +
  25.230 +/* eventually there will be several more features to export */
  25.231 +static ssize_t xen_feature_show(int index, char *buffer)
  25.232 +{
  25.233 +	int ret;
  25.234 +
  25.235 +	struct xen_feature_info *info =
  25.236 +	    kmalloc(sizeof(struct xen_feature_info), GFP_KERNEL);
  25.237 +	if (info) {
  25.238 +		info->submap_idx = index;
  25.239 +		ret = HYPERVISOR_xen_version(XENVER_get_features, info);
  25.240 +		if (!ret)
  25.241 +			ret = sprintf(buffer, "%d\n", info->submap);
  25.242 +		kfree(info);
  25.243 +	} else
  25.244 +		ret = -ENOMEM;
  25.245 +	return ret;
  25.246 +}
  25.247 +
  25.248 +static ssize_t writable_pt_show(struct hyp_sysfs_attr *attr, char *buffer)
  25.249 +{
  25.250 +	return xen_feature_show(XENFEAT_writable_page_tables, buffer);
  25.251 +}
  25.252 +
  25.253 +HYPERVISOR_ATTR_RO(writable_pt);
  25.254 +
  25.255 +static struct attribute *xen_properties_attrs[] = {
  25.256 +	&capabilities_attr.attr,
  25.257 +	&changeset_attr.attr,
  25.258 +	&virtual_start_attr.attr,
  25.259 +	&writable_pt_attr.attr,
  25.260 +	NULL
  25.261 +};
  25.262 +
  25.263 +static struct attribute_group xen_properties_group = {
  25.264 +	.name = "properties",
  25.265 +	.attrs = xen_properties_attrs,
  25.266 +};
  25.267 +
  25.268 +static int __init xen_properties_init(void)
  25.269 +{
  25.270 +	return sysfs_create_group(&hypervisor_subsys.kset.kobj,
  25.271 +				  &xen_properties_group);
  25.272 +}
  25.273 +
  25.274 +static void xen_properties_destroy(void)
  25.275 +{
  25.276 +	sysfs_remove_group(&hypervisor_subsys.kset.kobj, &xen_properties_group);
  25.277 +}
  25.278 +
  25.279 +static int __init hyper_sysfs_init(void)
  25.280 +{
  25.281 +	int ret = xen_sysfs_type_init();
  25.282 +	if (ret)
  25.283 +		goto out;
  25.284 +	ret = xen_sysfs_version_init();
  25.285 +	if (ret)
  25.286 +		goto version_out;
  25.287 +	ret = xen_compilation_init();
  25.288 +	if (ret)
  25.289 +		goto comp_out;
  25.290 +	ret = xen_properties_init();
  25.291 +	if (!ret)
  25.292 +		goto out;
  25.293 +
  25.294 +	xen_compilation_destroy();
  25.295 +comp_out:
  25.296 +	xen_sysfs_version_destroy();
  25.297 +version_out:
  25.298 +	xen_sysfs_type_destroy();
  25.299 +out:
  25.300 +	return ret;
  25.301 +}
  25.302 +
  25.303 +static void hyper_sysfs_exit(void)
  25.304 +{
  25.305 +	xen_properties_destroy();
  25.306 +	xen_compilation_destroy();
  25.307 +	xen_sysfs_version_destroy();
  25.308 +	xen_sysfs_type_destroy();
  25.309 +
  25.310 +}
  25.311 +
  25.312 +module_init(hyper_sysfs_init);
  25.313 +module_exit(hyper_sysfs_exit);
    26.1 --- a/linux-2.6-xen-sparse/drivers/xen/netback/xenbus.c	Tue Mar 21 09:55:44 2006 -0700
    26.2 +++ b/linux-2.6-xen-sparse/drivers/xen/netback/xenbus.c	Tue Mar 21 11:19:11 2006 -0700
    26.3 @@ -213,7 +213,8 @@ static void frontend_changed(struct xenb
    26.4  		break;
    26.5  
    26.6  	case XenbusStateClosed:
    26.7 -		kobject_uevent(&dev->dev.kobj, KOBJ_OFFLINE);
    26.8 +		if (be->netif != NULL)
    26.9 +			kobject_uevent(&dev->dev.kobj, KOBJ_OFFLINE);
   26.10  		device_unregister(&dev->dev);
   26.11  		break;
   26.12  
    27.1 --- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_dev.c	Tue Mar 21 09:55:44 2006 -0700
    27.2 +++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_dev.c	Tue Mar 21 11:19:11 2006 -0700
    27.3 @@ -36,6 +36,7 @@
    27.4  #include <linux/notifier.h>
    27.5  #include <linux/wait.h>
    27.6  #include <linux/fs.h>
    27.7 +#include <linux/poll.h>
    27.8  
    27.9  #include "xenbus_comms.h"
   27.10  
   27.11 @@ -207,11 +208,22 @@ static int xenbus_dev_release(struct ino
   27.12  	return 0;
   27.13  }
   27.14  
   27.15 +static unsigned int xenbus_dev_poll(struct file *file, poll_table *wait)
   27.16 +{
   27.17 +	struct xenbus_dev_data *u = file->private_data;
   27.18 +
   27.19 +	poll_wait(file, &u->read_waitq, wait);
   27.20 +	if (u->read_cons != u->read_prod)
   27.21 +		return POLLIN | POLLRDNORM;
   27.22 +	return 0;
   27.23 +}
   27.24 +
   27.25  static struct file_operations xenbus_dev_file_ops = {
   27.26  	.read = xenbus_dev_read,
   27.27  	.write = xenbus_dev_write,
   27.28  	.open = xenbus_dev_open,
   27.29  	.release = xenbus_dev_release,
   27.30 +	.poll = xenbus_dev_poll,
   27.31  };
   27.32  
   27.33  static int __init
    28.1 --- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c	Tue Mar 21 09:55:44 2006 -0700
    28.2 +++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c	Tue Mar 21 11:19:11 2006 -0700
    28.3 @@ -1049,6 +1049,8 @@ static int __init xenbus_probe_init(void
    28.4  		if (xsd_port_intf)
    28.5  			xsd_port_intf->read_proc = xsd_port_read;
    28.6  	}
    28.7 +	else
    28.8 +		xenstored_ready = 1;
    28.9  
   28.10  	/* Initialize the interface to xenstore. */
   28.11  	err = xs_init();
   28.12 @@ -1058,10 +1060,8 @@ static int __init xenbus_probe_init(void
   28.13  		return err;
   28.14  	}
   28.15  
   28.16 -	if (!dom0) {
   28.17 -		xenstored_ready = 1;
   28.18 +	if (!dom0)
   28.19  		xenbus_probe(NULL);
   28.20 -	}
   28.21  
   28.22  	return 0;
   28.23  }
    29.1 --- a/linux-2.6-xen-sparse/include/asm-i386/apic.h	Tue Mar 21 09:55:44 2006 -0700
    29.2 +++ b/linux-2.6-xen-sparse/include/asm-i386/apic.h	Tue Mar 21 11:19:11 2006 -0700
    29.3 @@ -139,6 +139,8 @@ void switch_ipi_to_APIC_timer(void *cpum
    29.4  #define ARCH_APICTIMER_STOPS_ON_C3	1
    29.5  #endif
    29.6  
    29.7 +extern int timer_over_8254;
    29.8 +
    29.9  #else /* !CONFIG_X86_LOCAL_APIC */
   29.10  static inline void lapic_shutdown(void) { }
   29.11  
    30.1 --- a/linux-2.6-xen-sparse/include/linux/gfp.h	Tue Mar 21 09:55:44 2006 -0700
    30.2 +++ b/linux-2.6-xen-sparse/include/linux/gfp.h	Tue Mar 21 11:19:11 2006 -0700
    30.3 @@ -161,9 +161,9 @@ extern void FASTCALL(free_cold_page(stru
    30.4  
    30.5  void page_alloc_init(void);
    30.6  #ifdef CONFIG_NUMA
    30.7 -void drain_remote_pages(void);
    30.8 +void drain_node_pages(int node);
    30.9  #else
   30.10 -static inline void drain_remote_pages(void) { };
   30.11 +static inline void drain_node_pages(int node) { };
   30.12  #endif
   30.13  
   30.14  #endif /* __LINUX_GFP_H */
    31.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    31.2 +++ b/linux-2.6-xen-sparse/include/xen/hypervisor_sysfs.h	Tue Mar 21 11:19:11 2006 -0700
    31.3 @@ -0,0 +1,32 @@
    31.4 +/*
    31.5 + *  copyright (c) 2006 IBM Corporation
    31.6 + *  Authored by: Mike D. Day <ncmike@us.ibm.com>
    31.7 + *
    31.8 + *  This program is free software; you can redistribute it and/or modify
    31.9 + *  it under the terms of the GNU General Public License version 2 as
   31.10 + *  published by the Free Software Foundation.
   31.11 + */
   31.12 +
   31.13 +#ifndef _HYP_SYSFS_H_
   31.14 +#define _HYP_SYSFS_H_
   31.15 +
   31.16 +#include <linux/kobject.h>
   31.17 +#include <linux/sysfs.h>
   31.18 +
   31.19 +#define HYPERVISOR_ATTR_RO(_name) \
   31.20 +static struct hyp_sysfs_attr  _name##_attr = __ATTR_RO(_name)
   31.21 +
   31.22 +#define HYPERVISOR_ATTR_RW(_name) \
   31.23 +static struct hyp_sysfs_attr _name##_attr = \
   31.24 +	__ATTR(_name, 0644, _name##_show, _name##_store)
   31.25 +
   31.26 +extern struct subsystem hypervisor_subsys;
   31.27 +
   31.28 +struct hyp_sysfs_attr {
   31.29 +	struct attribute attr;
   31.30 +	ssize_t (*show)(struct hyp_sysfs_attr *, char *);
   31.31 +	ssize_t (*store)(struct hyp_sysfs_attr *, const char *, size_t);
   31.32 +	void *hyp_attr_data;
   31.33 +};
   31.34 +
   31.35 +#endif /* _HYP_SYSFS_H_ */
    32.1 --- a/linux-2.6-xen-sparse/mm/memory.c	Tue Mar 21 09:55:44 2006 -0700
    32.2 +++ b/linux-2.6-xen-sparse/mm/memory.c	Tue Mar 21 11:19:11 2006 -0700
    32.3 @@ -624,11 +624,12 @@ static unsigned long zap_pte_range(struc
    32.4  			(*zap_work)--;
    32.5  			continue;
    32.6  		}
    32.7 +
    32.8 +		(*zap_work) -= PAGE_SIZE;
    32.9 +
   32.10  		if (pte_present(ptent)) {
   32.11  			struct page *page;
   32.12  
   32.13 -			(*zap_work) -= PAGE_SIZE;
   32.14 -
   32.15  			page = vm_normal_page(vma, addr, ptent);
   32.16  			if (unlikely(details) && page) {
   32.17  				/*
    33.1 --- a/linux-2.6-xen-sparse/mm/page_alloc.c	Tue Mar 21 09:55:44 2006 -0700
    33.2 +++ b/linux-2.6-xen-sparse/mm/page_alloc.c	Tue Mar 21 11:19:11 2006 -0700
    33.3 @@ -591,21 +591,20 @@ static int rmqueue_bulk(struct zone *zon
    33.4  }
    33.5  
    33.6  #ifdef CONFIG_NUMA
    33.7 -/* Called from the slab reaper to drain remote pagesets */
    33.8 -void drain_remote_pages(void)
    33.9 +/*
   33.10 + * Called from the slab reaper to drain pagesets on a particular node that
   33.11 + * belong to the currently executing processor.
   33.12 + */
   33.13 +void drain_node_pages(int nodeid)
   33.14  {
   33.15 -	struct zone *zone;
   33.16 -	int i;
   33.17 +	int i, z;
   33.18  	unsigned long flags;
   33.19  
   33.20  	local_irq_save(flags);
   33.21 -	for_each_zone(zone) {
   33.22 +	for (z = 0; z < MAX_NR_ZONES; z++) {
   33.23 +		struct zone *zone = NODE_DATA(nodeid)->node_zones + z;
   33.24  		struct per_cpu_pageset *pset;
   33.25  
   33.26 -		/* Do not drain local pagesets */
   33.27 -		if (zone->zone_pgdat->node_id == numa_node_id())
   33.28 -			continue;
   33.29 -
   33.30  		pset = zone_pcp(zone, smp_processor_id());
   33.31  		for (i = 0; i < ARRAY_SIZE(pset->pcp); i++) {
   33.32  			struct per_cpu_pages *pcp;
    34.1 --- a/patches/linux-2.6.16-rc5/i386-mach-io-check-nmi.patch	Tue Mar 21 09:55:44 2006 -0700
    34.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    34.3 @@ -1,45 +0,0 @@
    34.4 -diff -pruN ../pristine-linux-2.6.16-rc5/arch/i386/kernel/traps.c ./arch/i386/kernel/traps.c
    34.5 ---- ../pristine-linux-2.6.16-rc5/arch/i386/kernel/traps.c	2006-02-27 15:46:58.000000000 +0000
    34.6 -+++ ./arch/i386/kernel/traps.c	2006-02-27 15:55:23.000000000 +0000
    34.7 -@@ -567,18 +567,11 @@ static void mem_parity_error(unsigned ch
    34.8 - 
    34.9 - static void io_check_error(unsigned char reason, struct pt_regs * regs)
   34.10 - {
   34.11 --	unsigned long i;
   34.12 --
   34.13 - 	printk(KERN_EMERG "NMI: IOCK error (debug interrupt?)\n");
   34.14 - 	show_registers(regs);
   34.15 - 
   34.16 - 	/* Re-enable the IOCK line, wait for a few seconds */
   34.17 --	reason = (reason & 0xf) | 8;
   34.18 --	outb(reason, 0x61);
   34.19 --	i = 2000;
   34.20 --	while (--i) udelay(1000);
   34.21 --	reason &= ~8;
   34.22 --	outb(reason, 0x61);
   34.23 -+	clear_io_check_error(reason);
   34.24 - }
   34.25 - 
   34.26 - static void unknown_nmi_error(unsigned char reason, struct pt_regs * regs)
   34.27 -diff -pruN ../pristine-linux-2.6.16-rc5/include/asm-i386/mach-default/mach_traps.h ./include/asm-i386/mach-default/mach_traps.h
   34.28 ---- ../pristine-linux-2.6.16-rc5/include/asm-i386/mach-default/mach_traps.h	2006-01-03 03:21:10.000000000 +0000
   34.29 -+++ ./include/asm-i386/mach-default/mach_traps.h	2006-02-27 15:55:23.000000000 +0000
   34.30 -@@ -15,6 +15,18 @@ static inline void clear_mem_error(unsig
   34.31 - 	outb(reason, 0x61);
   34.32 - }
   34.33 - 
   34.34 -+static inline void clear_io_check_error(unsigned char reason)
   34.35 -+{
   34.36 -+	unsigned long i;
   34.37 -+
   34.38 -+	reason = (reason & 0xf) | 8;
   34.39 -+	outb(reason, 0x61);
   34.40 -+	i = 2000;
   34.41 -+	while (--i) udelay(1000);
   34.42 -+	reason &= ~8;
   34.43 -+	outb(reason, 0x61);
   34.44 -+}
   34.45 -+
   34.46 - static inline unsigned char get_nmi_reason(void)
   34.47 - {
   34.48 - 	return inb(0x61);
    35.1 --- a/patches/linux-2.6.16-rc5/net-csum.patch	Tue Mar 21 09:55:44 2006 -0700
    35.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    35.3 @@ -1,41 +0,0 @@
    35.4 -diff -pruN ../pristine-linux-2.6.16-rc5/net/ipv4/netfilter/ip_nat_proto_tcp.c ./net/ipv4/netfilter/ip_nat_proto_tcp.c
    35.5 ---- ../pristine-linux-2.6.16-rc5/net/ipv4/netfilter/ip_nat_proto_tcp.c	2006-02-27 15:47:38.000000000 +0000
    35.6 -+++ ./net/ipv4/netfilter/ip_nat_proto_tcp.c	2006-02-27 15:55:25.000000000 +0000
    35.7 -@@ -129,10 +129,14 @@ tcp_manip_pkt(struct sk_buff **pskb,
    35.8 - 	if (hdrsize < sizeof(*hdr))
    35.9 - 		return 1;
   35.10 - 
   35.11 --	hdr->check = ip_nat_cheat_check(~oldip, newip,
   35.12 -+	if ((*pskb)->proto_csum_blank) {
   35.13 -+		hdr->check = ip_nat_cheat_check(oldip, ~newip, hdr->check);
   35.14 -+	} else {
   35.15 -+		hdr->check = ip_nat_cheat_check(~oldip, newip,
   35.16 - 					ip_nat_cheat_check(oldport ^ 0xFFFF,
   35.17 - 							   newport,
   35.18 - 							   hdr->check));
   35.19 -+	}
   35.20 - 	return 1;
   35.21 - }
   35.22 - 
   35.23 -diff -pruN ../pristine-linux-2.6.16-rc5/net/ipv4/netfilter/ip_nat_proto_udp.c ./net/ipv4/netfilter/ip_nat_proto_udp.c
   35.24 ---- ../pristine-linux-2.6.16-rc5/net/ipv4/netfilter/ip_nat_proto_udp.c	2006-02-27 15:47:38.000000000 +0000
   35.25 -+++ ./net/ipv4/netfilter/ip_nat_proto_udp.c	2006-02-27 15:55:25.000000000 +0000
   35.26 -@@ -113,11 +113,16 @@ udp_manip_pkt(struct sk_buff **pskb,
   35.27 - 		newport = tuple->dst.u.udp.port;
   35.28 - 		portptr = &hdr->dest;
   35.29 - 	}
   35.30 --	if (hdr->check) /* 0 is a special case meaning no checksum */
   35.31 --		hdr->check = ip_nat_cheat_check(~oldip, newip,
   35.32 -+	if (hdr->check) { /* 0 is a special case meaning no checksum */
   35.33 -+		if ((*pskb)->proto_csum_blank) {
   35.34 -+			hdr->check = ip_nat_cheat_check(oldip, ~newip, hdr->check);
   35.35 -+		} else {
   35.36 -+			hdr->check = ip_nat_cheat_check(~oldip, newip,
   35.37 - 					ip_nat_cheat_check(*portptr ^ 0xFFFF,
   35.38 - 							   newport,
   35.39 - 							   hdr->check));
   35.40 -+		}
   35.41 -+	}
   35.42 - 	*portptr = newport;
   35.43 - 	return 1;
   35.44 - }
    36.1 --- a/patches/linux-2.6.16-rc5/pmd-shared.patch	Tue Mar 21 09:55:44 2006 -0700
    36.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    36.3 @@ -1,111 +0,0 @@
    36.4 -diff -pruN ../pristine-linux-2.6.16-rc5/arch/i386/mm/pageattr.c ./arch/i386/mm/pageattr.c
    36.5 ---- ../pristine-linux-2.6.16-rc5/arch/i386/mm/pageattr.c	2006-02-27 15:46:58.000000000 +0000
    36.6 -+++ ./arch/i386/mm/pageattr.c	2006-02-27 15:55:31.000000000 +0000
    36.7 -@@ -78,7 +78,7 @@ static void set_pmd_pte(pte_t *kpte, uns
    36.8 - 	unsigned long flags;
    36.9 - 
   36.10 - 	set_pte_atomic(kpte, pte); 	/* change init_mm */
   36.11 --	if (PTRS_PER_PMD > 1)
   36.12 -+	if (HAVE_SHARED_KERNEL_PMD)
   36.13 - 		return;
   36.14 - 
   36.15 - 	spin_lock_irqsave(&pgd_lock, flags);
   36.16 -diff -pruN ../pristine-linux-2.6.16-rc5/arch/i386/mm/pgtable.c ./arch/i386/mm/pgtable.c
   36.17 ---- ../pristine-linux-2.6.16-rc5/arch/i386/mm/pgtable.c	2006-01-03 03:21:10.000000000 +0000
   36.18 -+++ ./arch/i386/mm/pgtable.c	2006-02-27 15:55:31.000000000 +0000
   36.19 -@@ -215,9 +215,10 @@ void pgd_ctor(void *pgd, kmem_cache_t *c
   36.20 - 		spin_lock_irqsave(&pgd_lock, flags);
   36.21 - 	}
   36.22 - 
   36.23 --	clone_pgd_range((pgd_t *)pgd + USER_PTRS_PER_PGD,
   36.24 --			swapper_pg_dir + USER_PTRS_PER_PGD,
   36.25 --			KERNEL_PGD_PTRS);
   36.26 -+	if (PTRS_PER_PMD == 1 || HAVE_SHARED_KERNEL_PMD)
   36.27 -+		clone_pgd_range((pgd_t *)pgd + USER_PTRS_PER_PGD,
   36.28 -+				swapper_pg_dir + USER_PTRS_PER_PGD,
   36.29 -+				KERNEL_PGD_PTRS);
   36.30 - 	if (PTRS_PER_PMD > 1)
   36.31 - 		return;
   36.32 - 
   36.33 -@@ -249,6 +250,30 @@ pgd_t *pgd_alloc(struct mm_struct *mm)
   36.34 - 			goto out_oom;
   36.35 - 		set_pgd(&pgd[i], __pgd(1 + __pa(pmd)));
   36.36 - 	}
   36.37 -+
   36.38 -+	if (!HAVE_SHARED_KERNEL_PMD) {
   36.39 -+		unsigned long flags;
   36.40 -+
   36.41 -+		for (i = USER_PTRS_PER_PGD; i < PTRS_PER_PGD; i++) {
   36.42 -+			pmd_t *pmd = kmem_cache_alloc(pmd_cache, GFP_KERNEL);
   36.43 -+			if (!pmd)
   36.44 -+				goto out_oom;
   36.45 -+			set_pgd(&pgd[USER_PTRS_PER_PGD], __pgd(1 + __pa(pmd)));
   36.46 -+		}
   36.47 -+
   36.48 -+		spin_lock_irqsave(&pgd_lock, flags);
   36.49 -+		for (i = USER_PTRS_PER_PGD; i < PTRS_PER_PGD; i++) {
   36.50 -+			unsigned long v = (unsigned long)i << PGDIR_SHIFT;
   36.51 -+			pgd_t *kpgd = pgd_offset_k(v);
   36.52 -+			pud_t *kpud = pud_offset(kpgd, v);
   36.53 -+			pmd_t *kpmd = pmd_offset(kpud, v);
   36.54 -+			pmd_t *pmd = (void *)__va(pgd_val(pgd[i])-1);
   36.55 -+			memcpy(pmd, kpmd, PAGE_SIZE);
   36.56 -+		}
   36.57 -+		pgd_list_add(pgd);
   36.58 -+		spin_unlock_irqrestore(&pgd_lock, flags);
   36.59 -+	}
   36.60 -+
   36.61 - 	return pgd;
   36.62 - 
   36.63 - out_oom:
   36.64 -@@ -263,9 +288,23 @@ void pgd_free(pgd_t *pgd)
   36.65 - 	int i;
   36.66 - 
   36.67 - 	/* in the PAE case user pgd entries are overwritten before usage */
   36.68 --	if (PTRS_PER_PMD > 1)
   36.69 --		for (i = 0; i < USER_PTRS_PER_PGD; ++i)
   36.70 --			kmem_cache_free(pmd_cache, (void *)__va(pgd_val(pgd[i])-1));
   36.71 -+	if (PTRS_PER_PMD > 1) {
   36.72 -+		for (i = 0; i < USER_PTRS_PER_PGD; ++i) {
   36.73 -+			pmd_t *pmd = (void *)__va(pgd_val(pgd[i])-1);
   36.74 -+			kmem_cache_free(pmd_cache, pmd);
   36.75 -+		}
   36.76 -+		if (!HAVE_SHARED_KERNEL_PMD) {
   36.77 -+			unsigned long flags;
   36.78 -+			spin_lock_irqsave(&pgd_lock, flags);
   36.79 -+			pgd_list_del(pgd);
   36.80 -+			spin_unlock_irqrestore(&pgd_lock, flags);
   36.81 -+			for (i = USER_PTRS_PER_PGD; i < PTRS_PER_PGD; i++) {
   36.82 -+				pmd_t *pmd = (void *)__va(pgd_val(pgd[i])-1);
   36.83 -+				memset(pmd, 0, PTRS_PER_PMD*sizeof(pmd_t));
   36.84 -+				kmem_cache_free(pmd_cache, pmd);
   36.85 -+			}
   36.86 -+		}
   36.87 -+	}
   36.88 - 	/* in the non-PAE case, free_pgtables() clears user pgd entries */
   36.89 - 	kmem_cache_free(pgd_cache, pgd);
   36.90 - }
   36.91 -diff -pruN ../pristine-linux-2.6.16-rc5/include/asm-i386/pgtable-2level-defs.h ./include/asm-i386/pgtable-2level-defs.h
   36.92 ---- ../pristine-linux-2.6.16-rc5/include/asm-i386/pgtable-2level-defs.h	2006-01-03 03:21:10.000000000 +0000
   36.93 -+++ ./include/asm-i386/pgtable-2level-defs.h	2006-02-27 15:55:31.000000000 +0000
   36.94 -@@ -1,6 +1,8 @@
   36.95 - #ifndef _I386_PGTABLE_2LEVEL_DEFS_H
   36.96 - #define _I386_PGTABLE_2LEVEL_DEFS_H
   36.97 - 
   36.98 -+#define HAVE_SHARED_KERNEL_PMD 0
   36.99 -+
  36.100 - /*
  36.101 -  * traditional i386 two-level paging structure:
  36.102 -  */
  36.103 -diff -pruN ../pristine-linux-2.6.16-rc5/include/asm-i386/pgtable-3level-defs.h ./include/asm-i386/pgtable-3level-defs.h
  36.104 ---- ../pristine-linux-2.6.16-rc5/include/asm-i386/pgtable-3level-defs.h	2006-01-03 03:21:10.000000000 +0000
  36.105 -+++ ./include/asm-i386/pgtable-3level-defs.h	2006-02-27 15:55:31.000000000 +0000
  36.106 -@@ -1,6 +1,8 @@
  36.107 - #ifndef _I386_PGTABLE_3LEVEL_DEFS_H
  36.108 - #define _I386_PGTABLE_3LEVEL_DEFS_H
  36.109 - 
  36.110 -+#define HAVE_SHARED_KERNEL_PMD 1
  36.111 -+
  36.112 - /*
  36.113 -  * PGDIR_SHIFT determines what a top-level page table entry can map
  36.114 -  */
    37.1 --- a/patches/linux-2.6.16-rc5/smp-alts.patch	Tue Mar 21 09:55:44 2006 -0700
    37.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    37.3 @@ -1,591 +0,0 @@
    37.4 -diff -pruN ../pristine-linux-2.6.16-rc5/arch/i386/Kconfig ./arch/i386/Kconfig
    37.5 ---- ../pristine-linux-2.6.16-rc5/arch/i386/Kconfig	2006-02-27 15:46:58.000000000 +0000
    37.6 -+++ ./arch/i386/Kconfig	2006-02-27 15:55:34.000000000 +0000
    37.7 -@@ -202,6 +202,19 @@ config SMP
    37.8 - 
    37.9 - 	  If you don't know what to do here, say N.
   37.10 - 
   37.11 -+config SMP_ALTERNATIVES
   37.12 -+	bool "SMP alternatives support (EXPERIMENTAL)"
   37.13 -+	depends on SMP && EXPERIMENTAL
   37.14 -+	help
   37.15 -+	  Try to reduce the overhead of running an SMP kernel on a uniprocessor
   37.16 -+	  host slightly by replacing certain key instruction sequences
   37.17 -+	  according to whether we currently have more than one CPU available.
   37.18 -+	  This should provide a noticeable boost to performance when
   37.19 -+	  running SMP kernels on UP machines, and have negligible impact
   37.20 -+	  when running on an true SMP host.
   37.21 -+
   37.22 -+          If unsure, say N.
   37.23 -+	  
   37.24 - config NR_CPUS
   37.25 - 	int "Maximum number of CPUs (2-255)"
   37.26 - 	range 2 255
   37.27 -diff -pruN ../pristine-linux-2.6.16-rc5/arch/i386/kernel/Makefile ./arch/i386/kernel/Makefile
   37.28 ---- ../pristine-linux-2.6.16-rc5/arch/i386/kernel/Makefile	2006-02-27 15:46:58.000000000 +0000
   37.29 -+++ ./arch/i386/kernel/Makefile	2006-02-27 15:55:34.000000000 +0000
   37.30 -@@ -37,6 +37,7 @@ obj-$(CONFIG_EFI) 		+= efi.o efi_stub.o
   37.31 - obj-$(CONFIG_DOUBLEFAULT) 	+= doublefault.o
   37.32 - obj-$(CONFIG_VM86)		+= vm86.o
   37.33 - obj-$(CONFIG_EARLY_PRINTK)	+= early_printk.o
   37.34 -+obj-$(CONFIG_SMP_ALTERNATIVES)  += smpalts.o
   37.35 - 
   37.36 - EXTRA_AFLAGS   := -traditional
   37.37 - 
   37.38 -diff -pruN ../pristine-linux-2.6.16-rc5/arch/i386/kernel/smpalts.c ./arch/i386/kernel/smpalts.c
   37.39 ---- ../pristine-linux-2.6.16-rc5/arch/i386/kernel/smpalts.c	1970-01-01 01:00:00.000000000 +0100
   37.40 -+++ ./arch/i386/kernel/smpalts.c	2006-02-27 15:55:34.000000000 +0000
   37.41 -@@ -0,0 +1,85 @@
   37.42 -+#include <linux/kernel.h>
   37.43 -+#include <asm/system.h>
   37.44 -+#include <asm/smp_alt.h>
   37.45 -+#include <asm/processor.h>
   37.46 -+#include <asm/string.h>
   37.47 -+
   37.48 -+struct smp_replacement_record {
   37.49 -+	unsigned char targ_size;
   37.50 -+	unsigned char smp1_size;
   37.51 -+	unsigned char smp2_size;
   37.52 -+	unsigned char up_size;
   37.53 -+	unsigned char feature;
   37.54 -+	unsigned char data[0];
   37.55 -+};
   37.56 -+
   37.57 -+struct smp_alternative_record {
   37.58 -+	void *targ_start;
   37.59 -+	struct smp_replacement_record *repl;
   37.60 -+};
   37.61 -+
   37.62 -+extern struct smp_alternative_record __start_smp_alternatives_table,
   37.63 -+  __stop_smp_alternatives_table;
   37.64 -+extern unsigned long __init_begin, __init_end;
   37.65 -+
   37.66 -+void prepare_for_smp(void)
   37.67 -+{
   37.68 -+	struct smp_alternative_record *r;
   37.69 -+	printk(KERN_INFO "Enabling SMP...\n");
   37.70 -+	for (r = &__start_smp_alternatives_table;
   37.71 -+	     r != &__stop_smp_alternatives_table;
   37.72 -+	     r++) {
   37.73 -+		BUG_ON(r->repl->targ_size < r->repl->smp1_size);
   37.74 -+		BUG_ON(r->repl->targ_size < r->repl->smp2_size);
   37.75 -+		BUG_ON(r->repl->targ_size < r->repl->up_size);
   37.76 -+               if (system_state == SYSTEM_RUNNING &&
   37.77 -+                   r->targ_start >= (void *)&__init_begin &&
   37.78 -+                   r->targ_start < (void *)&__init_end)
   37.79 -+                       continue;
   37.80 -+		if (r->repl->feature != (unsigned char)-1 &&
   37.81 -+		    boot_cpu_has(r->repl->feature)) {
   37.82 -+			memcpy(r->targ_start,
   37.83 -+			       r->repl->data + r->repl->smp1_size,
   37.84 -+			       r->repl->smp2_size);
   37.85 -+			memset(r->targ_start + r->repl->smp2_size,
   37.86 -+			       0x90,
   37.87 -+			       r->repl->targ_size - r->repl->smp2_size);
   37.88 -+		} else {
   37.89 -+			memcpy(r->targ_start,
   37.90 -+			       r->repl->data,
   37.91 -+			       r->repl->smp1_size);
   37.92 -+			memset(r->targ_start + r->repl->smp1_size,
   37.93 -+			       0x90,
   37.94 -+			       r->repl->targ_size - r->repl->smp1_size);
   37.95 -+		}
   37.96 -+	}
   37.97 -+	/* Paranoia */
   37.98 -+	asm volatile ("jmp 1f\n1:");
   37.99 -+	mb();
  37.100 -+}
  37.101 -+
  37.102 -+void unprepare_for_smp(void)
  37.103 -+{
  37.104 -+	struct smp_alternative_record *r;
  37.105 -+	printk(KERN_INFO "Disabling SMP...\n");
  37.106 -+	for (r = &__start_smp_alternatives_table;
  37.107 -+	     r != &__stop_smp_alternatives_table;
  37.108 -+	     r++) {
  37.109 -+		BUG_ON(r->repl->targ_size < r->repl->smp1_size);
  37.110 -+		BUG_ON(r->repl->targ_size < r->repl->smp2_size);
  37.111 -+		BUG_ON(r->repl->targ_size < r->repl->up_size);
  37.112 -+               if (system_state == SYSTEM_RUNNING &&
  37.113 -+                   r->targ_start >= (void *)&__init_begin &&
  37.114 -+                   r->targ_start < (void *)&__init_end)
  37.115 -+                       continue;
  37.116 -+		memcpy(r->targ_start,
  37.117 -+		       r->repl->data + r->repl->smp1_size + r->repl->smp2_size,
  37.118 -+		       r->repl->up_size);
  37.119 -+		memset(r->targ_start + r->repl->up_size,
  37.120 -+		       0x90,
  37.121 -+		       r->repl->targ_size - r->repl->up_size);
  37.122 -+	}
  37.123 -+	/* Paranoia */
  37.124 -+	asm volatile ("jmp 1f\n1:");
  37.125 -+	mb();
  37.126 -+}
  37.127 -diff -pruN ../pristine-linux-2.6.16-rc5/arch/i386/kernel/smpboot.c ./arch/i386/kernel/smpboot.c
  37.128 ---- ../pristine-linux-2.6.16-rc5/arch/i386/kernel/smpboot.c	2006-02-27 15:46:58.000000000 +0000
  37.129 -+++ ./arch/i386/kernel/smpboot.c	2006-02-27 15:55:34.000000000 +0000
  37.130 -@@ -1208,6 +1208,11 @@ static void __init smp_boot_cpus(unsigne
  37.131 - 		if (max_cpus <= cpucount+1)
  37.132 - 			continue;
  37.133 - 
  37.134 -+#ifdef CONFIG_SMP_ALTERNATIVES
  37.135 -+		if (kicked == 1)
  37.136 -+			prepare_for_smp();
  37.137 -+#endif
  37.138 -+
  37.139 - 		if (((cpu = alloc_cpu_id()) <= 0) || do_boot_cpu(apicid, cpu))
  37.140 - 			printk("CPU #%d not responding - cannot use it.\n",
  37.141 - 								apicid);
  37.142 -@@ -1386,6 +1391,11 @@ int __devinit __cpu_up(unsigned int cpu)
  37.143 - 		return -EIO;
  37.144 - 	}
  37.145 - 
  37.146 -+#ifdef CONFIG_SMP_ALTERNATIVES
  37.147 -+	if (num_online_cpus() == 1)
  37.148 -+		prepare_for_smp();
  37.149 -+#endif
  37.150 -+
  37.151 - 	local_irq_enable();
  37.152 - 	per_cpu(cpu_state, cpu) = CPU_UP_PREPARE;
  37.153 - 	/* Unleash the CPU! */
  37.154 -diff -pruN ../pristine-linux-2.6.16-rc5/arch/i386/kernel/vmlinux.lds.S ./arch/i386/kernel/vmlinux.lds.S
  37.155 ---- ../pristine-linux-2.6.16-rc5/arch/i386/kernel/vmlinux.lds.S	2006-01-03 03:21:10.000000000 +0000
  37.156 -+++ ./arch/i386/kernel/vmlinux.lds.S	2006-02-27 15:55:34.000000000 +0000
  37.157 -@@ -34,6 +34,13 @@ SECTIONS
  37.158 -   __ex_table : AT(ADDR(__ex_table) - LOAD_OFFSET) { *(__ex_table) }
  37.159 -   __stop___ex_table = .;
  37.160 - 
  37.161 -+  . = ALIGN(16);
  37.162 -+  __start_smp_alternatives_table = .;
  37.163 -+  __smp_alternatives : { *(__smp_alternatives) }
  37.164 -+  __stop_smp_alternatives_table = .;
  37.165 -+
  37.166 -+  __smp_replacements : { *(__smp_replacements) }
  37.167 -+
  37.168 -   RODATA
  37.169 - 
  37.170 -   /* writeable */
  37.171 -diff -pruN ../pristine-linux-2.6.16-rc5/include/asm-i386/atomic.h ./include/asm-i386/atomic.h
  37.172 ---- ../pristine-linux-2.6.16-rc5/include/asm-i386/atomic.h	2006-02-27 15:47:25.000000000 +0000
  37.173 -+++ ./include/asm-i386/atomic.h	2006-02-27 15:55:34.000000000 +0000
  37.174 -@@ -4,18 +4,13 @@
  37.175 - #include <linux/config.h>
  37.176 - #include <linux/compiler.h>
  37.177 - #include <asm/processor.h>
  37.178 -+#include <asm/smp_alt.h>
  37.179 - 
  37.180 - /*
  37.181 -  * Atomic operations that C can't guarantee us.  Useful for
  37.182 -  * resource counting etc..
  37.183 -  */
  37.184 - 
  37.185 --#ifdef CONFIG_SMP
  37.186 --#define LOCK "lock ; "
  37.187 --#else
  37.188 --#define LOCK ""
  37.189 --#endif
  37.190 --
  37.191 - /*
  37.192 -  * Make sure gcc doesn't try to be clever and move things around
  37.193 -  * on us. We need to use _exactly_ the address the user gave us,
  37.194 -diff -pruN ../pristine-linux-2.6.16-rc5/include/asm-i386/bitops.h ./include/asm-i386/bitops.h
  37.195 ---- ../pristine-linux-2.6.16-rc5/include/asm-i386/bitops.h	2006-02-27 15:47:25.000000000 +0000
  37.196 -+++ ./include/asm-i386/bitops.h	2006-02-27 15:55:34.000000000 +0000
  37.197 -@@ -7,6 +7,7 @@
  37.198 - 
  37.199 - #include <linux/config.h>
  37.200 - #include <linux/compiler.h>
  37.201 -+#include <asm/smp_alt.h>
  37.202 - 
  37.203 - /*
  37.204 -  * These have to be done with inline assembly: that way the bit-setting
  37.205 -@@ -16,12 +17,6 @@
  37.206 -  * bit 0 is the LSB of addr; bit 32 is the LSB of (addr+1).
  37.207 -  */
  37.208 - 
  37.209 --#ifdef CONFIG_SMP
  37.210 --#define LOCK_PREFIX "lock ; "
  37.211 --#else
  37.212 --#define LOCK_PREFIX ""
  37.213 --#endif
  37.214 --
  37.215 - #define ADDR (*(volatile long *) addr)
  37.216 - 
  37.217 - /**
  37.218 -@@ -41,7 +36,7 @@
  37.219 -  */
  37.220 - static inline void set_bit(int nr, volatile unsigned long * addr)
  37.221 - {
  37.222 --	__asm__ __volatile__( LOCK_PREFIX
  37.223 -+	__asm__ __volatile__( LOCK
  37.224 - 		"btsl %1,%0"
  37.225 - 		:"+m" (ADDR)
  37.226 - 		:"Ir" (nr));
  37.227 -@@ -76,7 +71,7 @@ static inline void __set_bit(int nr, vol
  37.228 -  */
  37.229 - static inline void clear_bit(int nr, volatile unsigned long * addr)
  37.230 - {
  37.231 --	__asm__ __volatile__( LOCK_PREFIX
  37.232 -+	__asm__ __volatile__( LOCK
  37.233 - 		"btrl %1,%0"
  37.234 - 		:"+m" (ADDR)
  37.235 - 		:"Ir" (nr));
  37.236 -@@ -121,7 +116,7 @@ static inline void __change_bit(int nr, 
  37.237 -  */
  37.238 - static inline void change_bit(int nr, volatile unsigned long * addr)
  37.239 - {
  37.240 --	__asm__ __volatile__( LOCK_PREFIX
  37.241 -+	__asm__ __volatile__( LOCK
  37.242 - 		"btcl %1,%0"
  37.243 - 		:"+m" (ADDR)
  37.244 - 		:"Ir" (nr));
  37.245 -@@ -140,7 +135,7 @@ static inline int test_and_set_bit(int n
  37.246 - {
  37.247 - 	int oldbit;
  37.248 - 
  37.249 --	__asm__ __volatile__( LOCK_PREFIX
  37.250 -+	__asm__ __volatile__( LOCK
  37.251 - 		"btsl %2,%1\n\tsbbl %0,%0"
  37.252 - 		:"=r" (oldbit),"+m" (ADDR)
  37.253 - 		:"Ir" (nr) : "memory");
  37.254 -@@ -180,7 +175,7 @@ static inline int test_and_clear_bit(int
  37.255 - {
  37.256 - 	int oldbit;
  37.257 - 
  37.258 --	__asm__ __volatile__( LOCK_PREFIX
  37.259 -+	__asm__ __volatile__( LOCK
  37.260 - 		"btrl %2,%1\n\tsbbl %0,%0"
  37.261 - 		:"=r" (oldbit),"+m" (ADDR)
  37.262 - 		:"Ir" (nr) : "memory");
  37.263 -@@ -231,7 +226,7 @@ static inline int test_and_change_bit(in
  37.264 - {
  37.265 - 	int oldbit;
  37.266 - 
  37.267 --	__asm__ __volatile__( LOCK_PREFIX
  37.268 -+	__asm__ __volatile__( LOCK
  37.269 - 		"btcl %2,%1\n\tsbbl %0,%0"
  37.270 - 		:"=r" (oldbit),"+m" (ADDR)
  37.271 - 		:"Ir" (nr) : "memory");
  37.272 -diff -pruN ../pristine-linux-2.6.16-rc5/include/asm-i386/futex.h ./include/asm-i386/futex.h
  37.273 ---- ../pristine-linux-2.6.16-rc5/include/asm-i386/futex.h	2006-02-27 15:47:25.000000000 +0000
  37.274 -+++ ./include/asm-i386/futex.h	2006-02-27 15:55:34.000000000 +0000
  37.275 -@@ -28,7 +28,7 @@
  37.276 - "1:	movl	%2, %0\n\
  37.277 - 	movl	%0, %3\n"					\
  37.278 - 	insn "\n"						\
  37.279 --"2:	" LOCK_PREFIX "cmpxchgl %3, %2\n\
  37.280 -+"2:	" LOCK "cmpxchgl %3, %2\n\
  37.281 - 	jnz	1b\n\
  37.282 - 3:	.section .fixup,\"ax\"\n\
  37.283 - 4:	mov	%5, %1\n\
  37.284 -@@ -68,7 +68,7 @@ futex_atomic_op_inuser (int encoded_op, 
  37.285 - #endif
  37.286 - 		switch (op) {
  37.287 - 		case FUTEX_OP_ADD:
  37.288 --			__futex_atomic_op1(LOCK_PREFIX "xaddl %0, %2", ret,
  37.289 -+			__futex_atomic_op1(LOCK "xaddl %0, %2", ret,
  37.290 - 					   oldval, uaddr, oparg);
  37.291 - 			break;
  37.292 - 		case FUTEX_OP_OR:
  37.293 -diff -pruN ../pristine-linux-2.6.16-rc5/include/asm-i386/rwsem.h ./include/asm-i386/rwsem.h
  37.294 ---- ../pristine-linux-2.6.16-rc5/include/asm-i386/rwsem.h	2006-01-03 03:21:10.000000000 +0000
  37.295 -+++ ./include/asm-i386/rwsem.h	2006-02-27 15:55:34.000000000 +0000
  37.296 -@@ -40,6 +40,7 @@
  37.297 - 
  37.298 - #include <linux/list.h>
  37.299 - #include <linux/spinlock.h>
  37.300 -+#include <asm/smp_alt.h>
  37.301 - 
  37.302 - struct rwsem_waiter;
  37.303 - 
  37.304 -@@ -99,7 +100,7 @@ static inline void __down_read(struct rw
  37.305 - {
  37.306 - 	__asm__ __volatile__(
  37.307 - 		"# beginning down_read\n\t"
  37.308 --LOCK_PREFIX	"  incl      (%%eax)\n\t" /* adds 0x00000001, returns the old value */
  37.309 -+LOCK	        "  incl      (%%eax)\n\t" /* adds 0x00000001, returns the old value */
  37.310 - 		"  js        2f\n\t" /* jump if we weren't granted the lock */
  37.311 - 		"1:\n\t"
  37.312 - 		LOCK_SECTION_START("")
  37.313 -@@ -130,7 +131,7 @@ static inline int __down_read_trylock(st
  37.314 - 		"  movl	     %1,%2\n\t"
  37.315 - 		"  addl      %3,%2\n\t"
  37.316 - 		"  jle	     2f\n\t"
  37.317 --LOCK_PREFIX	"  cmpxchgl  %2,%0\n\t"
  37.318 -+LOCK	        "  cmpxchgl  %2,%0\n\t"
  37.319 - 		"  jnz	     1b\n\t"
  37.320 - 		"2:\n\t"
  37.321 - 		"# ending __down_read_trylock\n\t"
  37.322 -@@ -150,7 +151,7 @@ static inline void __down_write(struct r
  37.323 - 	tmp = RWSEM_ACTIVE_WRITE_BIAS;
  37.324 - 	__asm__ __volatile__(
  37.325 - 		"# beginning down_write\n\t"
  37.326 --LOCK_PREFIX	"  xadd      %%edx,(%%eax)\n\t" /* subtract 0x0000ffff, returns the old value */
  37.327 -+LOCK	        "  xadd      %%edx,(%%eax)\n\t" /* subtract 0x0000ffff, returns the old value */
  37.328 - 		"  testl     %%edx,%%edx\n\t" /* was the count 0 before? */
  37.329 - 		"  jnz       2f\n\t" /* jump if we weren't granted the lock */
  37.330 - 		"1:\n\t"
  37.331 -@@ -188,7 +189,7 @@ static inline void __up_read(struct rw_s
  37.332 - 	__s32 tmp = -RWSEM_ACTIVE_READ_BIAS;
  37.333 - 	__asm__ __volatile__(
  37.334 - 		"# beginning __up_read\n\t"
  37.335 --LOCK_PREFIX	"  xadd      %%edx,(%%eax)\n\t" /* subtracts 1, returns the old value */
  37.336 -+LOCK	        "  xadd      %%edx,(%%eax)\n\t" /* subtracts 1, returns the old value */
  37.337 - 		"  js        2f\n\t" /* jump if the lock is being waited upon */
  37.338 - 		"1:\n\t"
  37.339 - 		LOCK_SECTION_START("")
  37.340 -@@ -214,7 +215,7 @@ static inline void __up_write(struct rw_
  37.341 - 	__asm__ __volatile__(
  37.342 - 		"# beginning __up_write\n\t"
  37.343 - 		"  movl      %2,%%edx\n\t"
  37.344 --LOCK_PREFIX	"  xaddl     %%edx,(%%eax)\n\t" /* tries to transition 0xffff0001 -> 0x00000000 */
  37.345 -+LOCK	        "  xaddl     %%edx,(%%eax)\n\t" /* tries to transition 0xffff0001 -> 0x00000000 */
  37.346 - 		"  jnz       2f\n\t" /* jump if the lock is being waited upon */
  37.347 - 		"1:\n\t"
  37.348 - 		LOCK_SECTION_START("")
  37.349 -@@ -239,7 +240,7 @@ static inline void __downgrade_write(str
  37.350 - {
  37.351 - 	__asm__ __volatile__(
  37.352 - 		"# beginning __downgrade_write\n\t"
  37.353 --LOCK_PREFIX	"  addl      %2,(%%eax)\n\t" /* transitions 0xZZZZ0001 -> 0xYYYY0001 */
  37.354 -+LOCK	        "  addl      %2,(%%eax)\n\t" /* transitions 0xZZZZ0001 -> 0xYYYY0001 */
  37.355 - 		"  js        2f\n\t" /* jump if the lock is being waited upon */
  37.356 - 		"1:\n\t"
  37.357 - 		LOCK_SECTION_START("")
  37.358 -@@ -263,7 +264,7 @@ LOCK_PREFIX	"  addl      %2,(%%eax)\n\t"
  37.359 - static inline void rwsem_atomic_add(int delta, struct rw_semaphore *sem)
  37.360 - {
  37.361 - 	__asm__ __volatile__(
  37.362 --LOCK_PREFIX	"addl %1,%0"
  37.363 -+LOCK	          "addl %1,%0"
  37.364 - 		: "=m"(sem->count)
  37.365 - 		: "ir"(delta), "m"(sem->count));
  37.366 - }
  37.367 -@@ -276,7 +277,7 @@ static inline int rwsem_atomic_update(in
  37.368 - 	int tmp = delta;
  37.369 - 
  37.370 - 	__asm__ __volatile__(
  37.371 --LOCK_PREFIX	"xadd %0,(%2)"
  37.372 -+LOCK  	          "xadd %0,(%2)"
  37.373 - 		: "+r"(tmp), "=m"(sem->count)
  37.374 - 		: "r"(sem), "m"(sem->count)
  37.375 - 		: "memory");
  37.376 -diff -pruN ../pristine-linux-2.6.16-rc5/include/asm-i386/smp_alt.h ./include/asm-i386/smp_alt.h
  37.377 ---- ../pristine-linux-2.6.16-rc5/include/asm-i386/smp_alt.h	1970-01-01 01:00:00.000000000 +0100
  37.378 -+++ ./include/asm-i386/smp_alt.h	2006-02-27 15:55:34.000000000 +0000
  37.379 -@@ -0,0 +1,32 @@
  37.380 -+#ifndef __ASM_SMP_ALT_H__
  37.381 -+#define __ASM_SMP_ALT_H__
  37.382 -+
  37.383 -+#include <linux/config.h>
  37.384 -+
  37.385 -+#ifdef CONFIG_SMP
  37.386 -+#if defined(CONFIG_SMP_ALTERNATIVES) && !defined(MODULE)
  37.387 -+#define LOCK \
  37.388 -+        "6677: nop\n" \
  37.389 -+	".section __smp_alternatives,\"a\"\n" \
  37.390 -+	".long 6677b\n" \
  37.391 -+	".long 6678f\n" \
  37.392 -+	".previous\n" \
  37.393 -+	".section __smp_replacements,\"a\"\n" \
  37.394 -+	"6678: .byte 1\n" \
  37.395 -+	".byte 1\n" \
  37.396 -+	".byte 0\n" \
  37.397 -+        ".byte 1\n" \
  37.398 -+	".byte -1\n" \
  37.399 -+	"lock\n" \
  37.400 -+	"nop\n" \
  37.401 -+	".previous\n"
  37.402 -+void prepare_for_smp(void);
  37.403 -+void unprepare_for_smp(void);
  37.404 -+#else
  37.405 -+#define LOCK "lock ; "
  37.406 -+#endif
  37.407 -+#else
  37.408 -+#define LOCK ""
  37.409 -+#endif
  37.410 -+
  37.411 -+#endif /* __ASM_SMP_ALT_H__ */
  37.412 -diff -pruN ../pristine-linux-2.6.16-rc5/include/asm-i386/spinlock.h ./include/asm-i386/spinlock.h
  37.413 ---- ../pristine-linux-2.6.16-rc5/include/asm-i386/spinlock.h	2006-01-03 03:21:10.000000000 +0000
  37.414 -+++ ./include/asm-i386/spinlock.h	2006-02-27 15:55:34.000000000 +0000
  37.415 -@@ -6,6 +6,7 @@
  37.416 - #include <asm/page.h>
  37.417 - #include <linux/config.h>
  37.418 - #include <linux/compiler.h>
  37.419 -+#include <asm/smp_alt.h>
  37.420 - 
  37.421 - /*
  37.422 -  * Your basic SMP spinlocks, allowing only a single CPU anywhere
  37.423 -@@ -23,7 +24,8 @@
  37.424 - 
  37.425 - #define __raw_spin_lock_string \
  37.426 - 	"\n1:\t" \
  37.427 --	"lock ; decb %0\n\t" \
  37.428 -+	LOCK \
  37.429 -+	"decb %0\n\t" \
  37.430 - 	"jns 3f\n" \
  37.431 - 	"2:\t" \
  37.432 - 	"rep;nop\n\t" \
  37.433 -@@ -34,7 +36,8 @@
  37.434 - 
  37.435 - #define __raw_spin_lock_string_flags \
  37.436 - 	"\n1:\t" \
  37.437 --	"lock ; decb %0\n\t" \
  37.438 -+	LOCK \
  37.439 -+	"decb %0\n\t" \
  37.440 - 	"jns 4f\n\t" \
  37.441 - 	"2:\t" \
  37.442 - 	"testl $0x200, %1\n\t" \
  37.443 -@@ -65,10 +68,34 @@ static inline void __raw_spin_lock_flags
  37.444 - static inline int __raw_spin_trylock(raw_spinlock_t *lock)
  37.445 - {
  37.446 - 	char oldval;
  37.447 -+#ifdef CONFIG_SMP_ALTERNATIVES
  37.448 - 	__asm__ __volatile__(
  37.449 --		"xchgb %b0,%1"
  37.450 -+		"1:movb %1,%b0\n"
  37.451 -+		"movb $0,%1\n"
  37.452 -+		"2:"
  37.453 -+		".section __smp_alternatives,\"a\"\n"
  37.454 -+		".long 1b\n"
  37.455 -+		".long 3f\n"
  37.456 -+		".previous\n"
  37.457 -+		".section __smp_replacements,\"a\"\n"
  37.458 -+		"3: .byte 2b - 1b\n"
  37.459 -+		".byte 5f-4f\n"
  37.460 -+		".byte 0\n"
  37.461 -+		".byte 6f-5f\n"
  37.462 -+		".byte -1\n"
  37.463 -+		"4: xchgb %b0,%1\n"
  37.464 -+		"5: movb %1,%b0\n"
  37.465 -+		"movb $0,%1\n"
  37.466 -+		"6:\n"
  37.467 -+		".previous\n"
  37.468 - 		:"=q" (oldval), "=m" (lock->slock)
  37.469 - 		:"0" (0) : "memory");
  37.470 -+#else
  37.471 -+	__asm__ __volatile__(
  37.472 -+		"xchgb %b0,%1\n"
  37.473 -+		:"=q" (oldval), "=m" (lock->slock)
  37.474 -+		:"0" (0) : "memory");
  37.475 -+#endif
  37.476 - 	return oldval > 0;
  37.477 - }
  37.478 - 
  37.479 -@@ -178,12 +205,12 @@ static inline int __raw_write_trylock(ra
  37.480 - 
  37.481 - static inline void __raw_read_unlock(raw_rwlock_t *rw)
  37.482 - {
  37.483 --	asm volatile("lock ; incl %0" :"=m" (rw->lock) : : "memory");
  37.484 -+	asm volatile(LOCK "incl %0" :"=m" (rw->lock) : : "memory");
  37.485 - }
  37.486 - 
  37.487 - static inline void __raw_write_unlock(raw_rwlock_t *rw)
  37.488 - {
  37.489 --	asm volatile("lock ; addl $" RW_LOCK_BIAS_STR ", %0"
  37.490 -+	asm volatile(LOCK "addl $" RW_LOCK_BIAS_STR ", %0"
  37.491 - 				 : "=m" (rw->lock) : : "memory");
  37.492 - }
  37.493 - 
  37.494 -diff -pruN ../pristine-linux-2.6.16-rc5/include/asm-i386/system.h ./include/asm-i386/system.h
  37.495 ---- ../pristine-linux-2.6.16-rc5/include/asm-i386/system.h	2006-02-27 15:47:25.000000000 +0000
  37.496 -+++ ./include/asm-i386/system.h	2006-02-27 15:55:34.000000000 +0000
  37.497 -@@ -5,7 +5,7 @@
  37.498 - #include <linux/kernel.h>
  37.499 - #include <asm/segment.h>
  37.500 - #include <asm/cpufeature.h>
  37.501 --#include <linux/bitops.h> /* for LOCK_PREFIX */
  37.502 -+#include <asm/smp_alt.h>
  37.503 - 
  37.504 - #ifdef __KERNEL__
  37.505 - 
  37.506 -@@ -271,19 +271,19 @@ static inline unsigned long __cmpxchg(vo
  37.507 - 	unsigned long prev;
  37.508 - 	switch (size) {
  37.509 - 	case 1:
  37.510 --		__asm__ __volatile__(LOCK_PREFIX "cmpxchgb %b1,%2"
  37.511 -+		__asm__ __volatile__(LOCK "cmpxchgb %b1,%2"
  37.512 - 				     : "=a"(prev)
  37.513 - 				     : "q"(new), "m"(*__xg(ptr)), "0"(old)
  37.514 - 				     : "memory");
  37.515 - 		return prev;
  37.516 - 	case 2:
  37.517 --		__asm__ __volatile__(LOCK_PREFIX "cmpxchgw %w1,%2"
  37.518 -+		__asm__ __volatile__(LOCK "cmpxchgw %w1,%2"
  37.519 - 				     : "=a"(prev)
  37.520 - 				     : "r"(new), "m"(*__xg(ptr)), "0"(old)
  37.521 - 				     : "memory");
  37.522 - 		return prev;
  37.523 - 	case 4:
  37.524 --		__asm__ __volatile__(LOCK_PREFIX "cmpxchgl %1,%2"
  37.525 -+		__asm__ __volatile__(LOCK "cmpxchgl %1,%2"
  37.526 - 				     : "=a"(prev)
  37.527 - 				     : "r"(new), "m"(*__xg(ptr)), "0"(old)
  37.528 - 				     : "memory");
  37.529 -@@ -336,7 +336,7 @@ static inline unsigned long long __cmpxc
  37.530 - 				      unsigned long long new)
  37.531 - {
  37.532 - 	unsigned long long prev;
  37.533 --	__asm__ __volatile__(LOCK_PREFIX "cmpxchg8b %3"
  37.534 -+	__asm__ __volatile__(LOCK "cmpxchg8b %3"
  37.535 - 			     : "=A"(prev)
  37.536 - 			     : "b"((unsigned long)new),
  37.537 - 			       "c"((unsigned long)(new >> 32)),
  37.538 -@@ -503,11 +503,55 @@ struct alt_instr { 
  37.539 - #endif
  37.540 - 
  37.541 - #ifdef CONFIG_SMP
  37.542 -+#if defined(CONFIG_SMP_ALTERNATIVES) && !defined(MODULE)
  37.543 -+#define smp_alt_mb(instr)                                           \
  37.544 -+__asm__ __volatile__("6667:\nnop\nnop\nnop\nnop\nnop\nnop\n6668:\n" \
  37.545 -+		     ".section __smp_alternatives,\"a\"\n"          \
  37.546 -+		     ".long 6667b\n"                                \
  37.547 -+                     ".long 6673f\n"                                \
  37.548 -+		     ".previous\n"                                  \
  37.549 -+		     ".section __smp_replacements,\"a\"\n"          \
  37.550 -+		     "6673:.byte 6668b-6667b\n"                     \
  37.551 -+		     ".byte 6670f-6669f\n"                          \
  37.552 -+		     ".byte 6671f-6670f\n"                          \
  37.553 -+                     ".byte 0\n"                                    \
  37.554 -+		     ".byte %c0\n"                                  \
  37.555 -+		     "6669:lock;addl $0,0(%%esp)\n"                 \
  37.556 -+		     "6670:" instr "\n"                             \
  37.557 -+		     "6671:\n"                                      \
  37.558 -+		     ".previous\n"                                  \
  37.559 -+		     :                                              \
  37.560 -+		     : "i" (X86_FEATURE_XMM2)                       \
  37.561 -+		     : "memory")
  37.562 -+#define smp_rmb() smp_alt_mb("lfence")
  37.563 -+#define smp_mb()  smp_alt_mb("mfence")
  37.564 -+#define set_mb(var, value) do {                                     \
  37.565 -+unsigned long __set_mb_temp;                                        \
  37.566 -+__asm__ __volatile__("6667:movl %1, %0\n6668:\n"                    \
  37.567 -+		     ".section __smp_alternatives,\"a\"\n"          \
  37.568 -+		     ".long 6667b\n"                                \
  37.569 -+		     ".long 6673f\n"                                \
  37.570 -+		     ".previous\n"                                  \
  37.571 -+		     ".section __smp_replacements,\"a\"\n"          \
  37.572 -+		     "6673: .byte 6668b-6667b\n"                    \
  37.573 -+		     ".byte 6670f-6669f\n"                          \
  37.574 -+		     ".byte 0\n"                                    \
  37.575 -+		     ".byte 6671f-6670f\n"                          \
  37.576 -+		     ".byte -1\n"                                   \
  37.577 -+		     "6669: xchg %1, %0\n"                          \
  37.578 -+		     "6670:movl %1, %0\n"                           \
  37.579 -+		     "6671:\n"                                      \
  37.580 -+		     ".previous\n"                                  \
  37.581 -+		     : "=m" (var), "=r" (__set_mb_temp)             \
  37.582 -+		     : "1" (value)                                  \
  37.583 -+		     : "memory"); } while (0)
  37.584 -+#else
  37.585 - #define smp_mb()	mb()
  37.586 - #define smp_rmb()	rmb()
  37.587 -+#define set_mb(var, value) do { (void) xchg(&var, value); } while (0)
  37.588 -+#endif
  37.589 - #define smp_wmb()	wmb()
  37.590 - #define smp_read_barrier_depends()	read_barrier_depends()
  37.591 --#define set_mb(var, value) do { (void) xchg(&var, value); } while (0)
  37.592 - #else
  37.593 - #define smp_mb()	barrier()
  37.594 - #define smp_rmb()	barrier()
    38.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    38.2 +++ b/patches/linux-2.6.16/i386-mach-io-check-nmi.patch	Tue Mar 21 11:19:11 2006 -0700
    38.3 @@ -0,0 +1,45 @@
    38.4 +diff -pruN ../pristine-linux-2.6.16/arch/i386/kernel/traps.c ./arch/i386/kernel/traps.c
    38.5 +--- ../pristine-linux-2.6.16/arch/i386/kernel/traps.c	2006-03-20 05:53:29.000000000 +0000
    38.6 ++++ ./arch/i386/kernel/traps.c	2006-03-20 19:38:17.000000000 +0000
    38.7 +@@ -567,18 +567,11 @@ static void mem_parity_error(unsigned ch
    38.8 + 
    38.9 + static void io_check_error(unsigned char reason, struct pt_regs * regs)
   38.10 + {
   38.11 +-	unsigned long i;
   38.12 +-
   38.13 + 	printk(KERN_EMERG "NMI: IOCK error (debug interrupt?)\n");
   38.14 + 	show_registers(regs);
   38.15 + 
   38.16 + 	/* Re-enable the IOCK line, wait for a few seconds */
   38.17 +-	reason = (reason & 0xf) | 8;
   38.18 +-	outb(reason, 0x61);
   38.19 +-	i = 2000;
   38.20 +-	while (--i) udelay(1000);
   38.21 +-	reason &= ~8;
   38.22 +-	outb(reason, 0x61);
   38.23 ++	clear_io_check_error(reason);
   38.24 + }
   38.25 + 
   38.26 + static void unknown_nmi_error(unsigned char reason, struct pt_regs * regs)
   38.27 +diff -pruN ../pristine-linux-2.6.16/include/asm-i386/mach-default/mach_traps.h ./include/asm-i386/mach-default/mach_traps.h
   38.28 +--- ../pristine-linux-2.6.16/include/asm-i386/mach-default/mach_traps.h	2006-03-20 05:53:29.000000000 +0000
   38.29 ++++ ./include/asm-i386/mach-default/mach_traps.h	2006-03-20 19:38:17.000000000 +0000
   38.30 +@@ -15,6 +15,18 @@ static inline void clear_mem_error(unsig
   38.31 + 	outb(reason, 0x61);
   38.32 + }
   38.33 + 
   38.34 ++static inline void clear_io_check_error(unsigned char reason)
   38.35 ++{
   38.36 ++	unsigned long i;
   38.37 ++
   38.38 ++	reason = (reason & 0xf) | 8;
   38.39 ++	outb(reason, 0x61);
   38.40 ++	i = 2000;
   38.41 ++	while (--i) udelay(1000);
   38.42 ++	reason &= ~8;
   38.43 ++	outb(reason, 0x61);
   38.44 ++}
   38.45 ++
   38.46 + static inline unsigned char get_nmi_reason(void)
   38.47 + {
   38.48 + 	return inb(0x61);
    39.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    39.2 +++ b/patches/linux-2.6.16/net-csum.patch	Tue Mar 21 11:19:11 2006 -0700
    39.3 @@ -0,0 +1,41 @@
    39.4 +diff -pruN ../pristine-linux-2.6.16/net/ipv4/netfilter/ip_nat_proto_tcp.c ./net/ipv4/netfilter/ip_nat_proto_tcp.c
    39.5 +--- ../pristine-linux-2.6.16/net/ipv4/netfilter/ip_nat_proto_tcp.c	2006-03-20 05:53:29.000000000 +0000
    39.6 ++++ ./net/ipv4/netfilter/ip_nat_proto_tcp.c	2006-03-20 19:38:19.000000000 +0000
    39.7 +@@ -129,10 +129,14 @@ tcp_manip_pkt(struct sk_buff **pskb,
    39.8 + 	if (hdrsize < sizeof(*hdr))
    39.9 + 		return 1;
   39.10 + 
   39.11 +-	hdr->check = ip_nat_cheat_check(~oldip, newip,
   39.12 ++	if ((*pskb)->proto_csum_blank) {
   39.13 ++		hdr->check = ip_nat_cheat_check(oldip, ~newip, hdr->check);
   39.14 ++	} else {
   39.15 ++		hdr->check = ip_nat_cheat_check(~oldip, newip,
   39.16 + 					ip_nat_cheat_check(oldport ^ 0xFFFF,
   39.17 + 							   newport,
   39.18 + 							   hdr->check));
   39.19 ++	}
   39.20 + 	return 1;
   39.21 + }
   39.22 + 
   39.23 +diff -pruN ../pristine-linux-2.6.16/net/ipv4/netfilter/ip_nat_proto_udp.c ./net/ipv4/netfilter/ip_nat_proto_udp.c
   39.24 +--- ../pristine-linux-2.6.16/net/ipv4/netfilter/ip_nat_proto_udp.c	2006-03-20 05:53:29.000000000 +0000
   39.25 ++++ ./net/ipv4/netfilter/ip_nat_proto_udp.c	2006-03-20 19:38:19.000000000 +0000
   39.26 +@@ -113,11 +113,16 @@ udp_manip_pkt(struct sk_buff **pskb,
   39.27 + 		newport = tuple->dst.u.udp.port;
   39.28 + 		portptr = &hdr->dest;
   39.29 + 	}
   39.30 +-	if (hdr->check) /* 0 is a special case meaning no checksum */
   39.31 +-		hdr->check = ip_nat_cheat_check(~oldip, newip,
   39.32 ++	if (hdr->check) { /* 0 is a special case meaning no checksum */
   39.33 ++		if ((*pskb)->proto_csum_blank) {
   39.34 ++			hdr->check = ip_nat_cheat_check(oldip, ~newip, hdr->check);
   39.35 ++		} else {
   39.36 ++			hdr->check = ip_nat_cheat_check(~oldip, newip,
   39.37 + 					ip_nat_cheat_check(*portptr ^ 0xFFFF,
   39.38 + 							   newport,
   39.39 + 							   hdr->check));
   39.40 ++		}
   39.41 ++	}
   39.42 + 	*portptr = newport;
   39.43 + 	return 1;
   39.44 + }
    40.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    40.2 +++ b/patches/linux-2.6.16/pmd-shared.patch	Tue Mar 21 11:19:11 2006 -0700
    40.3 @@ -0,0 +1,111 @@
    40.4 +diff -pruN ../pristine-linux-2.6.16/arch/i386/mm/pageattr.c ./arch/i386/mm/pageattr.c
    40.5 +--- ../pristine-linux-2.6.16/arch/i386/mm/pageattr.c	2006-03-20 05:53:29.000000000 +0000
    40.6 ++++ ./arch/i386/mm/pageattr.c	2006-03-20 19:38:23.000000000 +0000
    40.7 +@@ -78,7 +78,7 @@ static void set_pmd_pte(pte_t *kpte, uns
    40.8 + 	unsigned long flags;
    40.9 + 
   40.10 + 	set_pte_atomic(kpte, pte); 	/* change init_mm */
   40.11 +-	if (PTRS_PER_PMD > 1)
   40.12 ++	if (HAVE_SHARED_KERNEL_PMD)
   40.13 + 		return;
   40.14 + 
   40.15 + 	spin_lock_irqsave(&pgd_lock, flags);
   40.16 +diff -pruN ../pristine-linux-2.6.16/arch/i386/mm/pgtable.c ./arch/i386/mm/pgtable.c
   40.17 +--- ../pristine-linux-2.6.16/arch/i386/mm/pgtable.c	2006-03-20 05:53:29.000000000 +0000
   40.18 ++++ ./arch/i386/mm/pgtable.c	2006-03-20 19:38:23.000000000 +0000
   40.19 +@@ -215,9 +215,10 @@ void pgd_ctor(void *pgd, kmem_cache_t *c
   40.20 + 		spin_lock_irqsave(&pgd_lock, flags);
   40.21 + 	}
   40.22 + 
   40.23 +-	clone_pgd_range((pgd_t *)pgd + USER_PTRS_PER_PGD,
   40.24 +-			swapper_pg_dir + USER_PTRS_PER_PGD,
   40.25 +-			KERNEL_PGD_PTRS);
   40.26 ++	if (PTRS_PER_PMD == 1 || HAVE_SHARED_KERNEL_PMD)
   40.27 ++		clone_pgd_range((pgd_t *)pgd + USER_PTRS_PER_PGD,
   40.28 ++				swapper_pg_dir + USER_PTRS_PER_PGD,
   40.29 ++				KERNEL_PGD_PTRS);
   40.30 + 	if (PTRS_PER_PMD > 1)
   40.31 + 		return;
   40.32 + 
   40.33 +@@ -249,6 +250,30 @@ pgd_t *pgd_alloc(struct mm_struct *mm)
   40.34 + 			goto out_oom;
   40.35 + 		set_pgd(&pgd[i], __pgd(1 + __pa(pmd)));
   40.36 + 	}
   40.37 ++
   40.38 ++	if (!HAVE_SHARED_KERNEL_PMD) {
   40.39 ++		unsigned long flags;
   40.40 ++
   40.41 ++		for (i = USER_PTRS_PER_PGD; i < PTRS_PER_PGD; i++) {
   40.42 ++			pmd_t *pmd = kmem_cache_alloc(pmd_cache, GFP_KERNEL);
   40.43 ++			if (!pmd)
   40.44 ++				goto out_oom;
   40.45 ++			set_pgd(&pgd[USER_PTRS_PER_PGD], __pgd(1 + __pa(pmd)));
   40.46 ++		}
   40.47 ++
   40.48 ++		spin_lock_irqsave(&pgd_lock, flags);
   40.49 ++		for (i = USER_PTRS_PER_PGD; i < PTRS_PER_PGD; i++) {
   40.50 ++			unsigned long v = (unsigned long)i << PGDIR_SHIFT;
   40.51 ++			pgd_t *kpgd = pgd_offset_k(v);
   40.52 ++			pud_t *kpud = pud_offset(kpgd, v);
   40.53 ++			pmd_t *kpmd = pmd_offset(kpud, v);
   40.54 ++			pmd_t *pmd = (void *)__va(pgd_val(pgd[i])-1);
   40.55 ++			memcpy(pmd, kpmd, PAGE_SIZE);
   40.56 ++		}
   40.57 ++		pgd_list_add(pgd);
   40.58 ++		spin_unlock_irqrestore(&pgd_lock, flags);
   40.59 ++	}
   40.60 ++
   40.61 + 	return pgd;
   40.62 + 
   40.63 + out_oom:
   40.64 +@@ -263,9 +288,23 @@ void pgd_free(pgd_t *pgd)
   40.65 + 	int i;
   40.66 + 
   40.67 + 	/* in the PAE case user pgd entries are overwritten before usage */
   40.68 +-	if (PTRS_PER_PMD > 1)
   40.69 +-		for (i = 0; i < USER_PTRS_PER_PGD; ++i)
   40.70 +-			kmem_cache_free(pmd_cache, (void *)__va(pgd_val(pgd[i])-1));
   40.71 ++	if (PTRS_PER_PMD > 1) {
   40.72 ++		for (i = 0; i < USER_PTRS_PER_PGD; ++i) {
   40.73 ++			pmd_t *pmd = (void *)__va(pgd_val(pgd[i])-1);
   40.74 ++			kmem_cache_free(pmd_cache, pmd);
   40.75 ++		}
   40.76 ++		if (!HAVE_SHARED_KERNEL_PMD) {
   40.77 ++			unsigned long flags;
   40.78 ++			spin_lock_irqsave(&pgd_lock, flags);
   40.79 ++			pgd_list_del(pgd);
   40.80 ++			spin_unlock_irqrestore(&pgd_lock, flags);
   40.81 ++			for (i = USER_PTRS_PER_PGD; i < PTRS_PER_PGD; i++) {
   40.82 ++				pmd_t *pmd = (void *)__va(pgd_val(pgd[i])-1);
   40.83 ++				memset(pmd, 0, PTRS_PER_PMD*sizeof(pmd_t));
   40.84 ++				kmem_cache_free(pmd_cache, pmd);
   40.85 ++			}
   40.86 ++		}
   40.87 ++	}
   40.88 + 	/* in the non-PAE case, free_pgtables() clears user pgd entries */
   40.89 + 	kmem_cache_free(pgd_cache, pgd);
   40.90 + }
   40.91 +diff -pruN ../pristine-linux-2.6.16/include/asm-i386/pgtable-2level-defs.h ./include/asm-i386/pgtable-2level-defs.h
   40.92 +--- ../pristine-linux-2.6.16/include/asm-i386/pgtable-2level-defs.h	2006-03-20 05:53:29.000000000 +0000
   40.93 ++++ ./include/asm-i386/pgtable-2level-defs.h	2006-03-20 19:38:23.000000000 +0000
   40.94 +@@ -1,6 +1,8 @@
   40.95 + #ifndef _I386_PGTABLE_2LEVEL_DEFS_H
   40.96 + #define _I386_PGTABLE_2LEVEL_DEFS_H
   40.97 + 
   40.98 ++#define HAVE_SHARED_KERNEL_PMD 0
   40.99 ++
  40.100 + /*
  40.101 +  * traditional i386 two-level paging structure:
  40.102 +  */
  40.103 +diff -pruN ../pristine-linux-2.6.16/include/asm-i386/pgtable-3level-defs.h ./include/asm-i386/pgtable-3level-defs.h
  40.104 +--- ../pristine-linux-2.6.16/include/asm-i386/pgtable-3level-defs.h	2006-03-20 05:53:29.000000000 +0000
  40.105 ++++ ./include/asm-i386/pgtable-3level-defs.h	2006-03-20 19:38:23.000000000 +0000
  40.106 +@@ -1,6 +1,8 @@
  40.107 + #ifndef _I386_PGTABLE_3LEVEL_DEFS_H
  40.108 + #define _I386_PGTABLE_3LEVEL_DEFS_H
  40.109 + 
  40.110 ++#define HAVE_SHARED_KERNEL_PMD 1
  40.111 ++
  40.112 + /*
  40.113 +  * PGDIR_SHIFT determines what a top-level page table entry can map
  40.114 +  */
    41.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    41.2 +++ b/patches/linux-2.6.16/smp-alts.patch	Tue Mar 21 11:19:11 2006 -0700
    41.3 @@ -0,0 +1,591 @@
    41.4 +diff -pruN ../pristine-linux-2.6.16/arch/i386/Kconfig ./arch/i386/Kconfig
    41.5 +--- ../pristine-linux-2.6.16/arch/i386/Kconfig	2006-03-20 05:53:29.000000000 +0000
    41.6 ++++ ./arch/i386/Kconfig	2006-03-20 19:38:27.000000000 +0000
    41.7 +@@ -202,6 +202,19 @@ config SMP
    41.8 + 
    41.9 + 	  If you don't know what to do here, say N.
   41.10 + 
   41.11 ++config SMP_ALTERNATIVES
   41.12 ++	bool "SMP alternatives support (EXPERIMENTAL)"
   41.13 ++	depends on SMP && EXPERIMENTAL
   41.14 ++	help
   41.15 ++	  Try to reduce the overhead of running an SMP kernel on a uniprocessor
   41.16 ++	  host slightly by replacing certain key instruction sequences
   41.17 ++	  according to whether we currently have more than one CPU available.
   41.18 ++	  This should provide a noticeable boost to performance when
   41.19 ++	  running SMP kernels on UP machines, and have negligible impact
   41.20 ++	  when running on an true SMP host.
   41.21 ++
   41.22 ++          If unsure, say N.
   41.23 ++	  
   41.24 + config NR_CPUS
   41.25 + 	int "Maximum number of CPUs (2-255)"
   41.26 + 	range 2 255
   41.27 +diff -pruN ../pristine-linux-2.6.16/arch/i386/kernel/Makefile ./arch/i386/kernel/Makefile
   41.28 +--- ../pristine-linux-2.6.16/arch/i386/kernel/Makefile	2006-03-20 05:53:29.000000000 +0000
   41.29 ++++ ./arch/i386/kernel/Makefile	2006-03-20 19:38:27.000000000 +0000
   41.30 +@@ -37,6 +37,7 @@ obj-$(CONFIG_EFI) 		+= efi.o efi_stub.o
   41.31 + obj-$(CONFIG_DOUBLEFAULT) 	+= doublefault.o
   41.32 + obj-$(CONFIG_VM86)		+= vm86.o
   41.33 + obj-$(CONFIG_EARLY_PRINTK)	+= early_printk.o
   41.34 ++obj-$(CONFIG_SMP_ALTERNATIVES)  += smpalts.o
   41.35 + 
   41.36 + EXTRA_AFLAGS   := -traditional
   41.37 + 
   41.38 +diff -pruN ../pristine-linux-2.6.16/arch/i386/kernel/smpalts.c ./arch/i386/kernel/smpalts.c
   41.39 +--- ../pristine-linux-2.6.16/arch/i386/kernel/smpalts.c	1970-01-01 01:00:00.000000000 +0100
   41.40 ++++ ./arch/i386/kernel/smpalts.c	2006-03-20 19:38:27.000000000 +0000
   41.41 +@@ -0,0 +1,85 @@
   41.42 ++#include <linux/kernel.h>
   41.43 ++#include <asm/system.h>
   41.44 ++#include <asm/smp_alt.h>
   41.45 ++#include <asm/processor.h>
   41.46 ++#include <asm/string.h>
   41.47 ++
   41.48 ++struct smp_replacement_record {
   41.49 ++	unsigned char targ_size;
   41.50 ++	unsigned char smp1_size;
   41.51 ++	unsigned char smp2_size;
   41.52 ++	unsigned char up_size;
   41.53 ++	unsigned char feature;
   41.54 ++	unsigned char data[0];
   41.55 ++};
   41.56 ++
   41.57 ++struct smp_alternative_record {
   41.58 ++	void *targ_start;
   41.59 ++	struct smp_replacement_record *repl;
   41.60 ++};
   41.61 ++
   41.62 ++extern struct smp_alternative_record __start_smp_alternatives_table,
   41.63 ++  __stop_smp_alternatives_table;
   41.64 ++extern unsigned long __init_begin, __init_end;
   41.65 ++
   41.66 ++void prepare_for_smp(void)
   41.67 ++{
   41.68 ++	struct smp_alternative_record *r;
   41.69 ++	printk(KERN_INFO "Enabling SMP...\n");
   41.70 ++	for (r = &__start_smp_alternatives_table;
   41.71 ++	     r != &__stop_smp_alternatives_table;
   41.72 ++	     r++) {
   41.73 ++		BUG_ON(r->repl->targ_size < r->repl->smp1_size);
   41.74 ++		BUG_ON(r->repl->targ_size < r->repl->smp2_size);
   41.75 ++		BUG_ON(r->repl->targ_size < r->repl->up_size);
   41.76 ++               if (system_state == SYSTEM_RUNNING &&
   41.77 ++                   r->targ_start >= (void *)&__init_begin &&
   41.78 ++                   r->targ_start < (void *)&__init_end)
   41.79 ++                       continue;
   41.80 ++		if (r->repl->feature != (unsigned char)-1 &&
   41.81 ++		    boot_cpu_has(r->repl->feature)) {
   41.82 ++			memcpy(r->targ_start,
   41.83 ++			       r->repl->data + r->repl->smp1_size,
   41.84 ++			       r->repl->smp2_size);
   41.85 ++			memset(r->targ_start + r->repl->smp2_size,
   41.86 ++			       0x90,
   41.87 ++			       r->repl->targ_size - r->repl->smp2_size);
   41.88 ++		} else {
   41.89 ++			memcpy(r->targ_start,
   41.90 ++			       r->repl->data,
   41.91 ++			       r->repl->smp1_size);
   41.92 ++			memset(r->targ_start + r->repl->smp1_size,
   41.93 ++			       0x90,
   41.94 ++			       r->repl->targ_size - r->repl->smp1_size);
   41.95 ++		}
   41.96 ++	}
   41.97 ++	/* Paranoia */
   41.98 ++	asm volatile ("jmp 1f\n1:");
   41.99 ++	mb();
  41.100 ++}
  41.101 ++
  41.102 ++void unprepare_for_smp(void)
  41.103 ++{
  41.104 ++	struct smp_alternative_record *r;
  41.105 ++	printk(KERN_INFO "Disabling SMP...\n");
  41.106 ++	for (r = &__start_smp_alternatives_table;
  41.107 ++	     r != &__stop_smp_alternatives_table;
  41.108 ++	     r++) {
  41.109 ++		BUG_ON(r->repl->targ_size < r->repl->smp1_size);
  41.110 ++		BUG_ON(r->repl->targ_size < r->repl->smp2_size);
  41.111 ++		BUG_ON(r->repl->targ_size < r->repl->up_size);
  41.112 ++               if (system_state == SYSTEM_RUNNING &&
  41.113 ++                   r->targ_start >= (void *)&__init_begin &&
  41.114 ++                   r->targ_start < (void *)&__init_end)
  41.115 ++                       continue;
  41.116 ++		memcpy(r->targ_start,
  41.117 ++		       r->repl->data + r->repl->smp1_size + r->repl->smp2_size,
  41.118 ++		       r->repl->up_size);
  41.119 ++		memset(r->targ_start + r->repl->up_size,
  41.120 ++		       0x90,
  41.121 ++		       r->repl->targ_size - r->repl->up_size);
  41.122 ++	}
  41.123 ++	/* Paranoia */
  41.124 ++	asm volatile ("jmp 1f\n1:");
  41.125 ++	mb();
  41.126 ++}
  41.127 +diff -pruN ../pristine-linux-2.6.16/arch/i386/kernel/smpboot.c ./arch/i386/kernel/smpboot.c
  41.128 +--- ../pristine-linux-2.6.16/arch/i386/kernel/smpboot.c	2006-03-20 05:53:29.000000000 +0000
  41.129 ++++ ./arch/i386/kernel/smpboot.c	2006-03-20 19:38:27.000000000 +0000
  41.130 +@@ -1218,6 +1218,11 @@ static void __init smp_boot_cpus(unsigne
  41.131 + 		if (max_cpus <= cpucount+1)
  41.132 + 			continue;
  41.133 + 
  41.134 ++#ifdef CONFIG_SMP_ALTERNATIVES
  41.135 ++		if (kicked == 1)
  41.136 ++			prepare_for_smp();
  41.137 ++#endif
  41.138 ++
  41.139 + 		if (((cpu = alloc_cpu_id()) <= 0) || do_boot_cpu(apicid, cpu))
  41.140 + 			printk("CPU #%d not responding - cannot use it.\n",
  41.141 + 								apicid);
  41.142 +@@ -1396,6 +1401,11 @@ int __devinit __cpu_up(unsigned int cpu)
  41.143 + 		return -EIO;
  41.144 + 	}
  41.145 + 
  41.146 ++#ifdef CONFIG_SMP_ALTERNATIVES
  41.147 ++	if (num_online_cpus() == 1)
  41.148 ++		prepare_for_smp();
  41.149 ++#endif
  41.150 ++
  41.151 + 	local_irq_enable();
  41.152 + 	per_cpu(cpu_state, cpu) = CPU_UP_PREPARE;
  41.153 + 	/* Unleash the CPU! */
  41.154 +diff -pruN ../pristine-linux-2.6.16/arch/i386/kernel/vmlinux.lds.S ./arch/i386/kernel/vmlinux.lds.S
  41.155 +--- ../pristine-linux-2.6.16/arch/i386/kernel/vmlinux.lds.S	2006-03-20 05:53:29.000000000 +0000
  41.156 ++++ ./arch/i386/kernel/vmlinux.lds.S	2006-03-20 19:38:27.000000000 +0000
  41.157 +@@ -34,6 +34,13 @@ SECTIONS
  41.158 +   __ex_table : AT(ADDR(__ex_table) - LOAD_OFFSET) { *(__ex_table) }
  41.159 +   __stop___ex_table = .;
  41.160 + 
  41.161 ++  . = ALIGN(16);
  41.162 ++  __start_smp_alternatives_table = .;
  41.163 ++  __smp_alternatives : { *(__smp_alternatives) }
  41.164 ++  __stop_smp_alternatives_table = .;
  41.165 ++
  41.166 ++  __smp_replacements : { *(__smp_replacements) }
  41.167 ++
  41.168 +   RODATA
  41.169 + 
  41.170 +   /* writeable */
  41.171 +diff -pruN ../pristine-linux-2.6.16/include/asm-i386/atomic.h ./include/asm-i386/atomic.h
  41.172 +--- ../pristine-linux-2.6.16/include/asm-i386/atomic.h	2006-03-20 05:53:29.000000000 +0000
  41.173 ++++ ./include/asm-i386/atomic.h	2006-03-20 19:38:27.000000000 +0000
  41.174 +@@ -4,18 +4,13 @@
  41.175 + #include <linux/config.h>
  41.176 + #include <linux/compiler.h>
  41.177 + #include <asm/processor.h>
  41.178 ++#include <asm/smp_alt.h>
  41.179 + 
  41.180 + /*
  41.181 +  * Atomic operations that C can't guarantee us.  Useful for
  41.182 +  * resource counting etc..
  41.183 +  */
  41.184 + 
  41.185 +-#ifdef CONFIG_SMP
  41.186 +-#define LOCK "lock ; "
  41.187 +-#else
  41.188 +-#define LOCK ""
  41.189 +-#endif
  41.190 +-
  41.191 + /*
  41.192 +  * Make sure gcc doesn't try to be clever and move things around
  41.193 +  * on us. We need to use _exactly_ the address the user gave us,
  41.194 +diff -pruN ../pristine-linux-2.6.16/include/asm-i386/bitops.h ./include/asm-i386/bitops.h
  41.195 +--- ../pristine-linux-2.6.16/include/asm-i386/bitops.h	2006-03-20 05:53:29.000000000 +0000
  41.196 ++++ ./include/asm-i386/bitops.h	2006-03-20 19:38:27.000000000 +0000
  41.197 +@@ -7,6 +7,7 @@
  41.198 + 
  41.199 + #include <linux/config.h>
  41.200 + #include <linux/compiler.h>
  41.201 ++#include <asm/smp_alt.h>
  41.202 + 
  41.203 + /*
  41.204 +  * These have to be done with inline assembly: that way the bit-setting
  41.205 +@@ -16,12 +17,6 @@
  41.206 +  * bit 0 is the LSB of addr; bit 32 is the LSB of (addr+1).
  41.207 +  */
  41.208 + 
  41.209 +-#ifdef CONFIG_SMP
  41.210 +-#define LOCK_PREFIX "lock ; "
  41.211 +-#else
  41.212 +-#define LOCK_PREFIX ""
  41.213 +-#endif
  41.214 +-
  41.215 + #define ADDR (*(volatile long *) addr)
  41.216 + 
  41.217 + /**
  41.218 +@@ -41,7 +36,7 @@
  41.219 +  */
  41.220 + static inline void set_bit(int nr, volatile unsigned long * addr)
  41.221 + {
  41.222 +-	__asm__ __volatile__( LOCK_PREFIX
  41.223 ++	__asm__ __volatile__( LOCK
  41.224 + 		"btsl %1,%0"
  41.225 + 		:"+m" (ADDR)
  41.226 + 		:"Ir" (nr));
  41.227 +@@ -76,7 +71,7 @@ static inline void __set_bit(int nr, vol
  41.228 +  */
  41.229 + static inline void clear_bit(int nr, volatile unsigned long * addr)
  41.230 + {
  41.231 +-	__asm__ __volatile__( LOCK_PREFIX
  41.232 ++	__asm__ __volatile__( LOCK
  41.233 + 		"btrl %1,%0"
  41.234 + 		:"+m" (ADDR)
  41.235 + 		:"Ir" (nr));
  41.236 +@@ -121,7 +116,7 @@ static inline void __change_bit(int nr, 
  41.237 +  */
  41.238 + static inline void change_bit(int nr, volatile unsigned long * addr)
  41.239 + {
  41.240 +-	__asm__ __volatile__( LOCK_PREFIX
  41.241 ++	__asm__ __volatile__( LOCK
  41.242 + 		"btcl %1,%0"
  41.243 + 		:"+m" (ADDR)
  41.244 + 		:"Ir" (nr));
  41.245 +@@ -140,7 +135,7 @@ static inline int test_and_set_bit(int n
  41.246 + {
  41.247 + 	int oldbit;
  41.248 + 
  41.249 +-	__asm__ __volatile__( LOCK_PREFIX
  41.250 ++	__asm__ __volatile__( LOCK
  41.251 + 		"btsl %2,%1\n\tsbbl %0,%0"
  41.252 + 		:"=r" (oldbit),"+m" (ADDR)
  41.253 + 		:"Ir" (nr) : "memory");
  41.254 +@@ -180,7 +175,7 @@ static inline int test_and_clear_bit(int
  41.255 + {
  41.256 + 	int oldbit;
  41.257 + 
  41.258 +-	__asm__ __volatile__( LOCK_PREFIX
  41.259 ++	__asm__ __volatile__( LOCK
  41.260 + 		"btrl %2,%1\n\tsbbl %0,%0"
  41.261 + 		:"=r" (oldbit),"+m" (ADDR)
  41.262 + 		:"Ir" (nr) : "memory");
  41.263 +@@ -231,7 +226,7 @@ static inline int test_and_change_bit(in
  41.264 + {
  41.265 + 	int oldbit;
  41.266 + 
  41.267 +-	__asm__ __volatile__( LOCK_PREFIX
  41.268 ++	__asm__ __volatile__( LOCK
  41.269 + 		"btcl %2,%1\n\tsbbl %0,%0"
  41.270 + 		:"=r" (oldbit),"+m" (ADDR)
  41.271 + 		:"Ir" (nr) : "memory");
  41.272 +diff -pruN ../pristine-linux-2.6.16/include/asm-i386/futex.h ./include/asm-i386/futex.h
  41.273 +--- ../pristine-linux-2.6.16/include/asm-i386/futex.h	2006-03-20 05:53:29.000000000 +0000
  41.274 ++++ ./include/asm-i386/futex.h	2006-03-20 19:38:27.000000000 +0000
  41.275 +@@ -28,7 +28,7 @@
  41.276 + "1:	movl	%2, %0\n\
  41.277 + 	movl	%0, %3\n"					\
  41.278 + 	insn "\n"						\
  41.279 +-"2:	" LOCK_PREFIX "cmpxchgl %3, %2\n\
  41.280 ++"2:	" LOCK "cmpxchgl %3, %2\n\
  41.281 + 	jnz	1b\n\
  41.282 + 3:	.section .fixup,\"ax\"\n\
  41.283 + 4:	mov	%5, %1\n\
  41.284 +@@ -68,7 +68,7 @@ futex_atomic_op_inuser (int encoded_op, 
  41.285 + #endif
  41.286 + 		switch (op) {
  41.287 + 		case FUTEX_OP_ADD:
  41.288 +-			__futex_atomic_op1(LOCK_PREFIX "xaddl %0, %2", ret,
  41.289 ++			__futex_atomic_op1(LOCK "xaddl %0, %2", ret,
  41.290 + 					   oldval, uaddr, oparg);
  41.291 + 			break;
  41.292 + 		case FUTEX_OP_OR:
  41.293 +diff -pruN ../pristine-linux-2.6.16/include/asm-i386/rwsem.h ./include/asm-i386/rwsem.h
  41.294 +--- ../pristine-linux-2.6.16/include/asm-i386/rwsem.h	2006-03-20 05:53:29.000000000 +0000
  41.295 ++++ ./include/asm-i386/rwsem.h	2006-03-20 19:38:27.000000000 +0000
  41.296 +@@ -40,6 +40,7 @@
  41.297 + 
  41.298 + #include <linux/list.h>
  41.299 + #include <linux/spinlock.h>
  41.300 ++#include <asm/smp_alt.h>
  41.301 + 
  41.302 + struct rwsem_waiter;
  41.303 + 
  41.304 +@@ -99,7 +100,7 @@ static inline void __down_read(struct rw
  41.305 + {
  41.306 + 	__asm__ __volatile__(
  41.307 + 		"# beginning down_read\n\t"
  41.308 +-LOCK_PREFIX	"  incl      (%%eax)\n\t" /* adds 0x00000001, returns the old value */
  41.309 ++LOCK	        "  incl      (%%eax)\n\t" /* adds 0x00000001, returns the old value */
  41.310 + 		"  js        2f\n\t" /* jump if we weren't granted the lock */
  41.311 + 		"1:\n\t"
  41.312 + 		LOCK_SECTION_START("")
  41.313 +@@ -130,7 +131,7 @@ static inline int __down_read_trylock(st
  41.314 + 		"  movl	     %1,%2\n\t"
  41.315 + 		"  addl      %3,%2\n\t"
  41.316 + 		"  jle	     2f\n\t"
  41.317 +-LOCK_PREFIX	"  cmpxchgl  %2,%0\n\t"
  41.318 ++LOCK	        "  cmpxchgl  %2,%0\n\t"
  41.319 + 		"  jnz	     1b\n\t"
  41.320 + 		"2:\n\t"
  41.321 + 		"# ending __down_read_trylock\n\t"
  41.322 +@@ -150,7 +151,7 @@ static inline void __down_write(struct r
  41.323 + 	tmp = RWSEM_ACTIVE_WRITE_BIAS;
  41.324 + 	__asm__ __volatile__(
  41.325 + 		"# beginning down_write\n\t"
  41.326 +-LOCK_PREFIX	"  xadd      %%edx,(%%eax)\n\t" /* subtract 0x0000ffff, returns the old value */
  41.327 ++LOCK	        "  xadd      %%edx,(%%eax)\n\t" /* subtract 0x0000ffff, returns the old value */
  41.328 + 		"  testl     %%edx,%%edx\n\t" /* was the count 0 before? */
  41.329 + 		"  jnz       2f\n\t" /* jump if we weren't granted the lock */
  41.330 + 		"1:\n\t"
  41.331 +@@ -188,7 +189,7 @@ static inline void __up_read(struct rw_s
  41.332 + 	__s32 tmp = -RWSEM_ACTIVE_READ_BIAS;
  41.333 + 	__asm__ __volatile__(
  41.334 + 		"# beginning __up_read\n\t"
  41.335 +-LOCK_PREFIX	"  xadd      %%edx,(%%eax)\n\t" /* subtracts 1, returns the old value */
  41.336 ++LOCK	        "  xadd      %%edx,(%%eax)\n\t" /* subtracts 1, returns the old value */
  41.337 + 		"  js        2f\n\t" /* jump if the lock is being waited upon */
  41.338 + 		"1:\n\t"
  41.339 + 		LOCK_SECTION_START("")
  41.340 +@@ -214,7 +215,7 @@ static inline void __up_write(struct rw_
  41.341 + 	__asm__ __volatile__(
  41.342 + 		"# beginning __up_write\n\t"
  41.343 + 		"  movl      %2,%%edx\n\t"
  41.344 +-LOCK_PREFIX	"  xaddl     %%edx,(%%eax)\n\t" /* tries to transition 0xffff0001 -> 0x00000000 */
  41.345 ++LOCK	        "  xaddl     %%edx,(%%eax)\n\t" /* tries to transition 0xffff0001 -> 0x00000000 */
  41.346 + 		"  jnz       2f\n\t" /* jump if the lock is being waited upon */
  41.347 + 		"1:\n\t"
  41.348 + 		LOCK_SECTION_START("")
  41.349 +@@ -239,7 +240,7 @@ static inline void __downgrade_write(str
  41.350 + {
  41.351 + 	__asm__ __volatile__(
  41.352 + 		"# beginning __downgrade_write\n\t"
  41.353 +-LOCK_PREFIX	"  addl      %2,(%%eax)\n\t" /* transitions 0xZZZZ0001 -> 0xYYYY0001 */
  41.354 ++LOCK	        "  addl      %2,(%%eax)\n\t" /* transitions 0xZZZZ0001 -> 0xYYYY0001 */
  41.355 + 		"  js        2f\n\t" /* jump if the lock is being waited upon */
  41.356 + 		"1:\n\t"
  41.357 + 		LOCK_SECTION_START("")
  41.358 +@@ -263,7 +264,7 @@ LOCK_PREFIX	"  addl      %2,(%%eax)\n\t"
  41.359 + static inline void rwsem_atomic_add(int delta, struct rw_semaphore *sem)
  41.360 + {
  41.361 + 	__asm__ __volatile__(
  41.362 +-LOCK_PREFIX	"addl %1,%0"
  41.363 ++LOCK	          "addl %1,%0"
  41.364 + 		: "=m"(sem->count)
  41.365 + 		: "ir"(delta), "m"(sem->count));
  41.366 + }
  41.367 +@@ -276,7 +277,7 @@ static inline int rwsem_atomic_update(in
  41.368 + 	int tmp = delta;
  41.369 + 
  41.370 + 	__asm__ __volatile__(
  41.371 +-LOCK_PREFIX	"xadd %0,(%2)"
  41.372 ++LOCK  	          "xadd %0,(%2)"
  41.373 + 		: "+r"(tmp), "=m"(sem->count)
  41.374 + 		: "r"(sem), "m"(sem->count)
  41.375 + 		: "memory");
  41.376 +diff -pruN ../pristine-linux-2.6.16/include/asm-i386/smp_alt.h ./include/asm-i386/smp_alt.h
  41.377 +--- ../pristine-linux-2.6.16/include/asm-i386/smp_alt.h	1970-01-01 01:00:00.000000000 +0100
  41.378 ++++ ./include/asm-i386/smp_alt.h	2006-03-20 19:38:27.000000000 +0000
  41.379 +@@ -0,0 +1,32 @@
  41.380 ++#ifndef __ASM_SMP_ALT_H__
  41.381 ++#define __ASM_SMP_ALT_H__
  41.382 ++
  41.383 ++#include <linux/config.h>
  41.384 ++
  41.385 ++#ifdef CONFIG_SMP
  41.386 ++#if defined(CONFIG_SMP_ALTERNATIVES) && !defined(MODULE)
  41.387 ++#define LOCK \
  41.388 ++        "6677: nop\n" \
  41.389 ++	".section __smp_alternatives,\"a\"\n" \
  41.390 ++	".long 6677b\n" \
  41.391 ++	".long 6678f\n" \
  41.392 ++	".previous\n" \
  41.393 ++	".section __smp_replacements,\"a\"\n" \
  41.394 ++	"6678: .byte 1\n" \
  41.395 ++	".byte 1\n" \
  41.396 ++	".byte 0\n" \
  41.397 ++        ".byte 1\n" \
  41.398 ++	".byte -1\n" \
  41.399 ++	"lock\n" \
  41.400 ++	"nop\n" \
  41.401 ++	".previous\n"
  41.402 ++void prepare_for_smp(void);
  41.403 ++void unprepare_for_smp(void);
  41.404 ++#else
  41.405 ++#define LOCK "lock ; "
  41.406 ++#endif
  41.407 ++#else
  41.408 ++#define LOCK ""
  41.409 ++#endif
  41.410 ++
  41.411 ++#endif /* __ASM_SMP_ALT_H__ */
  41.412 +diff -pruN ../pristine-linux-2.6.16/include/asm-i386/spinlock.h ./include/asm-i386/spinlock.h
  41.413 +--- ../pristine-linux-2.6.16/include/asm-i386/spinlock.h	2006-03-20 05:53:29.000000000 +0000
  41.414 ++++ ./include/asm-i386/spinlock.h	2006-03-20 19:38:27.000000000 +0000
  41.415 +@@ -6,6 +6,7 @@
  41.416 + #include <asm/page.h>
  41.417 + #include <linux/config.h>
  41.418 + #include <linux/compiler.h>
  41.419 ++#include <asm/smp_alt.h>
  41.420 + 
  41.421 + /*
  41.422 +  * Your basic SMP spinlocks, allowing only a single CPU anywhere
  41.423 +@@ -23,7 +24,8 @@
  41.424 + 
  41.425 + #define __raw_spin_lock_string \
  41.426 + 	"\n1:\t" \
  41.427 +-	"lock ; decb %0\n\t" \
  41.428 ++	LOCK \
  41.429 ++	"decb %0\n\t" \
  41.430 + 	"jns 3f\n" \
  41.431 + 	"2:\t" \
  41.432 + 	"rep;nop\n\t" \
  41.433 +@@ -34,7 +36,8 @@
  41.434 + 
  41.435 + #define __raw_spin_lock_string_flags \
  41.436 + 	"\n1:\t" \
  41.437 +-	"lock ; decb %0\n\t" \
  41.438 ++	LOCK \
  41.439 ++	"decb %0\n\t" \
  41.440 + 	"jns 4f\n\t" \
  41.441 + 	"2:\t" \
  41.442 + 	"testl $0x200, %1\n\t" \
  41.443 +@@ -65,10 +68,34 @@ static inline void __raw_spin_lock_flags
  41.444 + static inline int __raw_spin_trylock(raw_spinlock_t *lock)
  41.445 + {
  41.446 + 	char oldval;
  41.447 ++#ifdef CONFIG_SMP_ALTERNATIVES
  41.448 + 	__asm__ __volatile__(
  41.449 +-		"xchgb %b0,%1"
  41.450 ++		"1:movb %1,%b0\n"
  41.451 ++		"movb $0,%1\n"
  41.452 ++		"2:"
  41.453 ++		".section __smp_alternatives,\"a\"\n"
  41.454 ++		".long 1b\n"
  41.455 ++		".long 3f\n"
  41.456 ++		".previous\n"
  41.457 ++		".section __smp_replacements,\"a\"\n"
  41.458 ++		"3: .byte 2b - 1b\n"
  41.459 ++		".byte 5f-4f\n"
  41.460 ++		".byte 0\n"
  41.461 ++		".byte 6f-5f\n"
  41.462 ++		".byte -1\n"
  41.463 ++		"4: xchgb %b0,%1\n"
  41.464 ++		"5: movb %1,%b0\n"
  41.465 ++		"movb $0,%1\n"
  41.466 ++		"6:\n"
  41.467 ++		".previous\n"
  41.468 + 		:"=q" (oldval), "=m" (lock->slock)
  41.469 + 		:"0" (0) : "memory");
  41.470 ++#else
  41.471 ++	__asm__ __volatile__(
  41.472 ++		"xchgb %b0,%1\n"
  41.473 ++		:"=q" (oldval), "=m" (lock->slock)
  41.474 ++		:"0" (0) : "memory");
  41.475 ++#endif
  41.476 + 	return oldval > 0;
  41.477 + }
  41.478 + 
  41.479 +@@ -178,12 +205,12 @@ static inline int __raw_write_trylock(ra
  41.480 + 
  41.481 + static inline void __raw_read_unlock(raw_rwlock_t *rw)
  41.482 + {
  41.483 +-	asm volatile("lock ; incl %0" :"=m" (rw->lock) : : "memory");
  41.484 ++	asm volatile(LOCK "incl %0" :"=m" (rw->lock) : : "memory");
  41.485 + }
  41.486 + 
  41.487 + static inline void __raw_write_unlock(raw_rwlock_t *rw)
  41.488 + {
  41.489 +-	asm volatile("lock ; addl $" RW_LOCK_BIAS_STR ", %0"
  41.490 ++	asm volatile(LOCK "addl $" RW_LOCK_BIAS_STR ", %0"
  41.491 + 				 : "=m" (rw->lock) : : "memory");
  41.492 + }
  41.493 + 
  41.494 +diff -pruN ../pristine-linux-2.6.16/include/asm-i386/system.h ./include/asm-i386/system.h
  41.495 +--- ../pristine-linux-2.6.16/include/asm-i386/system.h	2006-03-20 05:53:29.000000000 +0000
  41.496 ++++ ./include/asm-i386/system.h	2006-03-20 19:38:27.000000000 +0000
  41.497 +@@ -5,7 +5,7 @@
  41.498 + #include <linux/kernel.h>
  41.499 + #include <asm/segment.h>
  41.500 + #include <asm/cpufeature.h>
  41.501 +-#include <linux/bitops.h> /* for LOCK_PREFIX */
  41.502 ++#include <asm/smp_alt.h>
  41.503 + 
  41.504 + #ifdef __KERNEL__
  41.505 + 
  41.506 +@@ -271,19 +271,19 @@ static inline unsigned long __cmpxchg(vo
  41.507 + 	unsigned long prev;
  41.508 + 	switch (size) {
  41.509 + 	case 1:
  41.510 +-		__asm__ __volatile__(LOCK_PREFIX "cmpxchgb %b1,%2"
  41.511 ++		__asm__ __volatile__(LOCK "cmpxchgb %b1,%2"
  41.512 + 				     : "=a"(prev)
  41.513 + 				     : "q"(new), "m"(*__xg(ptr)), "0"(old)
  41.514 + 				     : "memory");
  41.515 + 		return prev;
  41.516 + 	case 2:
  41.517 +-		__asm__ __volatile__(LOCK_PREFIX "cmpxchgw %w1,%2"
  41.518 ++		__asm__ __volatile__(LOCK "cmpxchgw %w1,%2"
  41.519 + 				     : "=a"(prev)
  41.520 + 				     : "r"(new), "m"(*__xg(ptr)), "0"(old)
  41.521 + 				     : "memory");
  41.522 + 		return prev;
  41.523 + 	case 4:
  41.524 +-		__asm__ __volatile__(LOCK_PREFIX "cmpxchgl %1,%2"
  41.525 ++		__asm__ __volatile__(LOCK "cmpxchgl %1,%2"
  41.526 + 				     : "=a"(prev)
  41.527 + 				     : "r"(new), "m"(*__xg(ptr)), "0"(old)
  41.528 + 				     : "memory");
  41.529 +@@ -336,7 +336,7 @@ static inline unsigned long long __cmpxc
  41.530 + 				      unsigned long long new)
  41.531 + {
  41.532 + 	unsigned long long prev;
  41.533 +-	__asm__ __volatile__(LOCK_PREFIX "cmpxchg8b %3"
  41.534 ++	__asm__ __volatile__(LOCK "cmpxchg8b %3"
  41.535 + 			     : "=A"(prev)
  41.536 + 			     : "b"((unsigned long)new),
  41.537 + 			       "c"((unsigned long)(new >> 32)),
  41.538 +@@ -503,11 +503,55 @@ struct alt_instr { 
  41.539 + #endif
  41.540 + 
  41.541 + #ifdef CONFIG_SMP
  41.542 ++#if defined(CONFIG_SMP_ALTERNATIVES) && !defined(MODULE)
  41.543 ++#define smp_alt_mb(instr)                                           \
  41.544 ++__asm__ __volatile__("6667:\nnop\nnop\nnop\nnop\nnop\nnop\n6668:\n" \
  41.545 ++		     ".section __smp_alternatives,\"a\"\n"          \
  41.546 ++		     ".long 6667b\n"                                \
  41.547 ++                     ".long 6673f\n"                                \
  41.548 ++		     ".previous\n"                                  \
  41.549 ++		     ".section __smp_replacements,\"a\"\n"          \
  41.550 ++		     "6673:.byte 6668b-6667b\n"                     \
  41.551 ++		     ".byte 6670f-6669f\n"                          \
  41.552 ++		     ".byte 6671f-6670f\n"                          \
  41.553 ++                     ".byte 0\n"                                    \
  41.554 ++		     ".byte %c0\n"                                  \
  41.555 ++		     "6669:lock;addl $0,0(%%esp)\n"                 \
  41.556 ++		     "6670:" instr "\n"                             \
  41.557 ++		     "6671:\n"                                      \
  41.558 ++		     ".previous\n"                                  \
  41.559 ++		     :                                              \
  41.560 ++		     : "i" (X86_FEATURE_XMM2)                       \
  41.561 ++		     : "memory")
  41.562 ++#define smp_rmb() smp_alt_mb("lfence")
  41.563 ++#define smp_mb()  smp_alt_mb("mfence")
  41.564 ++#define set_mb(var, value) do {                                     \
  41.565 ++unsigned long __set_mb_temp;                                        \
  41.566 ++__asm__ __volatile__("6667:movl %1, %0\n6668:\n"                    \
  41.567 ++		     ".section __smp_alternatives,\"a\"\n"          \
  41.568 ++		     ".long 6667b\n"                                \
  41.569 ++		     ".long 6673f\n"                                \
  41.570 ++		     ".previous\n"                                  \
  41.571 ++		     ".section __smp_replacements,\"a\"\n"          \
  41.572 ++		     "6673: .byte 6668b-6667b\n"                    \
  41.573 ++		     ".byte 6670f-6669f\n"                          \
  41.574 ++		     ".byte 0\n"                                    \
  41.575 ++		     ".byte 6671f-6670f\n"                          \
  41.576 ++		     ".byte -1\n"                                   \
  41.577 ++		     "6669: xchg %1, %0\n"                          \
  41.578 ++		     "6670:movl %1, %0\n"                           \
  41.579 ++		     "6671:\n"                                      \
  41.580 ++		     ".previous\n"                                  \
  41.581 ++		     : "=m" (var), "=r" (__set_mb_temp)             \
  41.582 ++		     : "1" (value)                                  \
  41.583 ++		     : "memory"); } while (0)
  41.584 ++#else
  41.585 + #define smp_mb()	mb()
  41.586 + #define smp_rmb()	rmb()
  41.587 ++#define set_mb(var, value) do { (void) xchg(&var, value); } while (0)
  41.588 ++#endif
  41.589 + #define smp_wmb()	wmb()
  41.590 + #define smp_read_barrier_depends()	read_barrier_depends()
  41.591 +-#define set_mb(var, value) do { (void) xchg(&var, value); } while (0)
  41.592 + #else
  41.593 + #define smp_mb()	barrier()
  41.594 + #define smp_rmb()	barrier()
    42.1 --- a/tools/console/client/main.c	Tue Mar 21 09:55:44 2006 -0700
    42.2 +++ b/tools/console/client/main.c	Tue Mar 21 11:19:11 2006 -0700
    42.3 @@ -242,7 +242,7 @@ int main(int argc, char **argv)
    42.4  
    42.5  	now = time(0);
    42.6  	while (str_pty == NULL && (now + 5) > time(0)) {
    42.7 -		struct timeval tv = { 0, 500 };
    42.8 +		struct timeval tv = { 0, 250000 };
    42.9  		select(0, NULL, NULL, NULL, &tv); /* pause briefly */
   42.10  
   42.11  		str_pty = xs_read(xs, XBT_NULL, path, &len);
    43.1 --- a/tools/firmware/rombios/apmbios.S	Tue Mar 21 09:55:44 2006 -0700
    43.2 +++ b/tools/firmware/rombios/apmbios.S	Tue Mar 21 11:19:11 2006 -0700
    43.3 @@ -217,14 +217,22 @@ APMSYM(03):
    43.4  ; APM interface disconnect
    43.5  APMSYM(04):
    43.6    cmp al, #0x04
    43.7 +  jne APMSYM(05)
    43.8 +  jmp APMSYM(ok)
    43.9 +
   43.10 +;-----------------
   43.11 +; APM cpu idle
   43.12 +APMSYM(05):
   43.13 +  cmp al, #0x05
   43.14    jne APMSYM(07)
   43.15 +  hlt
   43.16    jmp APMSYM(ok)
   43.17  
   43.18  ;-----------------
   43.19  ; APM Set Power State
   43.20  APMSYM(07):
   43.21    cmp al, #0x07
   43.22 -  jne APMSYM(0a)
   43.23 +  jne APMSYM(08)
   43.24    
   43.25    cmp bx, #1
   43.26    jne APMSYM(ok)
   43.27 @@ -268,6 +276,14 @@ APMSYM(07_standby):
   43.28    jmp APMSYM(ok)
   43.29  
   43.30  ;-----------------
   43.31 +; APM Enable / Disable
   43.32 +APMSYM(08):
   43.33 +  cmp al, #0x08
   43.34 +  jne APMSYM(0a)
   43.35 +
   43.36 +  jmp APMSYM(ok)
   43.37 +
   43.38 +;-----------------
   43.39  ; Get Power Status
   43.40  APMSYM(0a):
   43.41    cmp al, #0x0a
   43.42 @@ -297,7 +313,7 @@ APMSYM(0b):
   43.43  ; APM Driver Version
   43.44  APMSYM(0e):
   43.45    cmp al, #0x0e
   43.46 -  jne APMSYM(unimplemented)
   43.47 +  jne APMSYM(0f)
   43.48    
   43.49    mov ah, #1
   43.50    mov al, #2
   43.51 @@ -305,6 +321,25 @@ APMSYM(0e):
   43.52    jmp APMSYM(ok)
   43.53  
   43.54  ;-----------------
   43.55 +; APM Engage / Disengage
   43.56 +APMSYM(0f):
   43.57 +  cmp al, #0x0f
   43.58 +  jne APMSYM(10)
   43.59 +
   43.60 +  jmp APMSYM(ok)
   43.61 +
   43.62 +;-----------------
   43.63 +; APM Get Capabilities
   43.64 +APMSYM(10):
   43.65 +  cmp al, #0x10
   43.66 +  jne APMSYM(unimplemented)
   43.67 +
   43.68 +  mov bl, #0
   43.69 +  mov cx, #0
   43.70 +
   43.71 +  jmp APMSYM(ok)
   43.72 +
   43.73 +;-----------------
   43.74  APMSYM(ok):
   43.75    popf
   43.76    clc
    44.1 --- a/tools/firmware/rombios/rombios.c	Tue Mar 21 09:55:44 2006 -0700
    44.2 +++ b/tools/firmware/rombios/rombios.c	Tue Mar 21 11:19:11 2006 -0700
    44.3 @@ -149,7 +149,7 @@
    44.4  #define BX_SUPPORT_FLOPPY 1
    44.5  #define BX_FLOPPY_ON_CNT 37   /* 2 seconds */
    44.6  #define BX_PCIBIOS       1
    44.7 -#define BX_APM           0
    44.8 +#define BX_APM           1
    44.9  
   44.10  #define BX_USE_ATADRV    1
   44.11  #define BX_ELTORITO_BOOT 1
    45.1 --- a/tools/ioemu/hw/pcnet.h	Tue Mar 21 09:55:44 2006 -0700
    45.2 +++ b/tools/ioemu/hw/pcnet.h	Tue Mar 21 11:19:11 2006 -0700
    45.3 @@ -225,9 +225,11 @@ static inline void pcnet_tmd_load(PCNetS
    45.4          ((uint32_t *)tmd)[3] = 0;
    45.5      }
    45.6      else
    45.7 -    if (BCR_SWSTYLE(s) != 3)
    45.8 -        cpu_physical_memory_read(addr, (void *)tmd, 16);
    45.9 -    else {
   45.10 +    if (BCR_SWSTYLE(s) != 3) {
   45.11 +        ((uint32_t *)tmd)[2] = 0;
   45.12 +        cpu_physical_memory_read(addr+4, (void *)&tmd->tmd1, 4);
   45.13 +        cpu_physical_memory_read(addr, (void *)&tmd->tmd0, 4);
   45.14 +    } else {
   45.15          uint32_t xda[4];
   45.16          cpu_physical_memory_read(addr,
   45.17                  (void *)&xda[0], sizeof(xda));
   45.18 @@ -253,9 +255,10 @@ static inline void pcnet_tmd_store(PCNet
   45.19          cpu_physical_memory_set_dirty(addr+7);
   45.20      }
   45.21      else {
   45.22 -        if (BCR_SWSTYLE(s) != 3)
   45.23 -            cpu_physical_memory_write(addr, (void *)tmd, 16);
   45.24 -        else {
   45.25 +        if (BCR_SWSTYLE(s) != 3) {
   45.26 +            cpu_physical_memory_write(addr+8, (void *)&tmd->tmd2, 4);
   45.27 +            cpu_physical_memory_write(addr+4, (void *)&tmd->tmd1, 4);
   45.28 +        } else {
   45.29              uint32_t xda[4];
   45.30              xda[0] = ((uint32_t *)tmd)[2];
   45.31              xda[1] = ((uint32_t *)tmd)[1];
   45.32 @@ -282,9 +285,11 @@ static inline void pcnet_rmd_load(PCNetS
   45.33          ((uint32_t *)rmd)[3] = 0;
   45.34      }
   45.35      else
   45.36 -    if (BCR_SWSTYLE(s) != 3)
   45.37 -        cpu_physical_memory_read(addr, (void *)rmd, 16);
   45.38 -    else {
   45.39 +    if (BCR_SWSTYLE(s) != 3) {
   45.40 +        rmd->rmd2.zeros = 0;
   45.41 +        cpu_physical_memory_read(addr+4, (void *)&rmd->rmd1, 4);
   45.42 +        cpu_physical_memory_read(addr, (void *)&rmd->rmd0, 4);
   45.43 +    } else {
   45.44          uint32_t rda[4];
   45.45          cpu_physical_memory_read(addr,
   45.46                  (void *)&rda[0], sizeof(rda));
   45.47 @@ -310,9 +315,10 @@ static inline void pcnet_rmd_store(PCNet
   45.48          cpu_physical_memory_set_dirty(addr+7);
   45.49      }
   45.50      else {
   45.51 -        if (BCR_SWSTYLE(s) != 3)
   45.52 -            cpu_physical_memory_write(addr, (void *)rmd, 16);
   45.53 -        else {
   45.54 +        if (BCR_SWSTYLE(s) != 3) {
   45.55 +            cpu_physical_memory_write(addr+8, (void *)&rmd->rmd2, 4);
   45.56 +            cpu_physical_memory_write(addr+4, (void *)&rmd->rmd1, 4);
   45.57 +        } else {
   45.58              uint32_t rda[4];
   45.59              rda[0] = ((uint32_t *)rmd)[2];
   45.60              rda[1] = ((uint32_t *)rmd)[1];
   45.61 @@ -339,8 +345,7 @@ static inline void pcnet_rmd_store(PCNet
   45.62  #define CHECK_RMD(ADDR,RES) do {                \
   45.63      struct pcnet_RMD rmd;                       \
   45.64      RMDLOAD(&rmd,(ADDR));                       \
   45.65 -    (RES) |= (rmd.rmd1.ones != 15)              \
   45.66 -          || (rmd.rmd2.zeros != 0);             \
   45.67 +    (RES) |= (rmd.rmd1.ones != 15);             \
   45.68  } while (0)
   45.69  
   45.70  #define CHECK_TMD(ADDR,RES) do {                \
    46.1 --- a/tools/libxc/xc_hvm_build.c	Tue Mar 21 09:55:44 2006 -0700
    46.2 +++ b/tools/libxc/xc_hvm_build.c	Tue Mar 21 11:19:11 2006 -0700
    46.3 @@ -51,7 +51,7 @@ loadelfimage(
    46.4      char *elfbase, int xch, uint32_t dom, unsigned long *parray,
    46.5      struct domain_setup_info *dsi);
    46.6  
    46.7 -static unsigned char build_e820map(void *e820_page, unsigned long mem_size)
    46.8 +static unsigned char build_e820map(void *e820_page, unsigned long long mem_size)
    46.9  {
   46.10      struct e820entry *e820entry =
   46.11          (struct e820entry *)(((unsigned char *)e820_page) + E820_MAP_OFFSET);
   46.12 @@ -81,24 +81,24 @@ static unsigned char build_e820map(void 
   46.13  #define STATIC_PAGES    2       /* for ioreq_t and store_mfn */
   46.14      /* Most of the ram goes here */
   46.15      e820entry[nr_map].addr = 0x100000;
   46.16 -    e820entry[nr_map].size = mem_size - 0x100000 - STATIC_PAGES*PAGE_SIZE;
   46.17 +    e820entry[nr_map].size = mem_size - 0x100000 - STATIC_PAGES * PAGE_SIZE;
   46.18      e820entry[nr_map].type = E820_RAM;
   46.19      nr_map++;
   46.20  
   46.21      /* Statically allocated special pages */
   46.22  
   46.23 +    /* For xenstore */
   46.24 +    e820entry[nr_map].addr = mem_size - 2 * PAGE_SIZE;
   46.25 +    e820entry[nr_map].size = PAGE_SIZE;
   46.26 +    e820entry[nr_map].type = E820_XENSTORE;
   46.27 +    nr_map++;
   46.28 +
   46.29      /* Shared ioreq_t page */
   46.30      e820entry[nr_map].addr = mem_size - PAGE_SIZE;
   46.31      e820entry[nr_map].size = PAGE_SIZE;
   46.32      e820entry[nr_map].type = E820_SHARED_PAGE;
   46.33      nr_map++;
   46.34  
   46.35 -    /* For xenstore */
   46.36 -    e820entry[nr_map].addr = mem_size - 2*PAGE_SIZE;
   46.37 -    e820entry[nr_map].size = PAGE_SIZE;
   46.38 -    e820entry[nr_map].type = E820_XENSTORE;
   46.39 -    nr_map++;
   46.40 -
   46.41      e820entry[nr_map].addr = mem_size;
   46.42      e820entry[nr_map].size = 0x3 * PAGE_SIZE;
   46.43      e820entry[nr_map].type = E820_NVS;
   46.44 @@ -117,8 +117,7 @@ static unsigned char build_e820map(void 
   46.45      return (*(((unsigned char *)e820_page) + E820_MAP_NR_OFFSET) = nr_map);
   46.46  }
   46.47  
   46.48 -static void
   46.49 -set_hvm_info_checksum(struct hvm_info_table *t)
   46.50 +static void set_hvm_info_checksum(struct hvm_info_table *t)
   46.51  {
   46.52      uint8_t *ptr = (uint8_t *)t, sum = 0;
   46.53      unsigned int i;
   46.54 @@ -142,19 +141,16 @@ static int set_hvm_info(int xc_handle, u
   46.55      char *va_map;
   46.56      struct hvm_info_table *va_hvm;
   46.57  
   46.58 -
   46.59 -    va_map = xc_map_foreign_range(
   46.60 -        xc_handle,
   46.61 -        dom,
   46.62 -        PAGE_SIZE,
   46.63 -        PROT_READ|PROT_WRITE,
   46.64 -        pfn_list[HVM_INFO_PFN]);
   46.65 +    va_map = xc_map_foreign_range(xc_handle, dom, PAGE_SIZE,
   46.66 +                                  PROT_READ | PROT_WRITE,
   46.67 +                                  pfn_list[HVM_INFO_PFN]);
   46.68  
   46.69      if ( va_map == NULL )
   46.70          return -1;
   46.71  
   46.72      va_hvm = (struct hvm_info_table *)(va_map + HVM_INFO_OFFSET);
   46.73      memset(va_hvm, 0, sizeof(*va_hvm));
   46.74 +
   46.75      strncpy(va_hvm->signature, "HVM INFO", 8);
   46.76      va_hvm->length       = sizeof(struct hvm_info_table);
   46.77      va_hvm->acpi_enabled = acpi;
   46.78 @@ -183,58 +179,59 @@ static int setup_guest(int xc_handle,
   46.79                         unsigned long *store_mfn)
   46.80  {
   46.81      unsigned long *page_array = NULL;
   46.82 +    unsigned long count, i;
   46.83 +    unsigned long long ptr;
   46.84 +    xc_mmu_t *mmu = NULL;
   46.85  
   46.86 -    unsigned long count, i;
   46.87      shared_info_t *shared_info;
   46.88      void *e820_page;
   46.89      unsigned char e820_map_nr;
   46.90 -    xc_mmu_t *mmu = NULL;
   46.91 -    int rc;
   46.92  
   46.93      struct domain_setup_info dsi;
   46.94 -    unsigned long v_end;
   46.95 +    unsigned long long v_end;
   46.96  
   46.97      unsigned long shared_page_frame = 0;
   46.98      shared_iopage_t *sp;
   46.99  
  46.100      memset(&dsi, 0, sizeof(struct domain_setup_info));
  46.101  
  46.102 -    if ( (rc = parseelfimage(image, image_size, &dsi)) != 0 )
  46.103 +    if ( (parseelfimage(image, image_size, &dsi)) != 0 )
  46.104          goto error_out;
  46.105  
  46.106 -    if ( (dsi.v_start & (PAGE_SIZE-1)) != 0 )
  46.107 +    if ( (dsi.v_kernstart & (PAGE_SIZE - 1)) != 0 )
  46.108      {
  46.109          PERROR("Guest OS must load to a page boundary.\n");
  46.110          goto error_out;
  46.111      }
  46.112  
  46.113      /* memsize is in megabytes */
  46.114 -    v_end              = (unsigned long)memsize << 20;
  46.115 +    v_end = (unsigned long long)memsize << 20;
  46.116  
  46.117      printf("VIRTUAL MEMORY ARRANGEMENT:\n"
  46.118 -           " Loaded HVM loader: %08lx->%08lx\n"
  46.119 -           " TOTAL:         %08lx->%08lx\n",
  46.120 +           "  Loaded HVM loader:    %08lx->%08lx\n"
  46.121 +           "  TOTAL:                %08lx->%016llx\n",
  46.122             dsi.v_kernstart, dsi.v_kernend,
  46.123             dsi.v_start, v_end);
  46.124 -    printf(" ENTRY ADDRESS: %08lx\n", dsi.v_kernentry);
  46.125 +    printf("  ENTRY ADDRESS:        %08lx\n", dsi.v_kernentry);
  46.126  
  46.127 -    if ( (v_end - dsi.v_start) > (nr_pages * PAGE_SIZE) )
  46.128 +    if ( (v_end - dsi.v_start) > ((unsigned long long)nr_pages << PAGE_SHIFT) )
  46.129      {
  46.130 -        ERROR("Initial guest OS requires too much space\n"
  46.131 -               "(%luMB is greater than %luMB limit)\n",
  46.132 -               (v_end-dsi.v_start)>>20, (nr_pages<<PAGE_SHIFT)>>20);
  46.133 +        PERROR("Initial guest OS requires too much space: "
  46.134 +               "(%lluMB is greater than %lluMB limit)\n",
  46.135 +               (unsigned long long)(v_end - dsi.v_start) >> 20,
  46.136 +               ((unsigned long long)nr_pages << PAGE_SHIFT) >> 20);
  46.137          goto error_out;
  46.138      }
  46.139  
  46.140      if ( (page_array = malloc(nr_pages * sizeof(unsigned long))) == NULL )
  46.141      {
  46.142 -        PERROR("Could not allocate memory");
  46.143 +        PERROR("Could not allocate memory.\n");
  46.144          goto error_out;
  46.145      }
  46.146  
  46.147      if ( xc_get_pfn_list(xc_handle, dom, page_array, nr_pages) != nr_pages )
  46.148      {
  46.149 -        PERROR("Could not get the page frame list");
  46.150 +        PERROR("Could not get the page frame list.\n");
  46.151          goto error_out;
  46.152      }
  46.153  
  46.154 @@ -246,20 +243,21 @@ static int setup_guest(int xc_handle,
  46.155      /* Write the machine->phys table entries. */
  46.156      for ( count = 0; count < nr_pages; count++ )
  46.157      {
  46.158 +        ptr = (unsigned long long)page_array[count] << PAGE_SHIFT;
  46.159          if ( xc_add_mmu_update(xc_handle, mmu,
  46.160 -                               (page_array[count] << PAGE_SHIFT) |
  46.161 -                               MMU_MACHPHYS_UPDATE, count) )
  46.162 +                               ptr | MMU_MACHPHYS_UPDATE, count) )
  46.163              goto error_out;
  46.164      }
  46.165  
  46.166 -    if ( set_hvm_info(xc_handle, dom, page_array, vcpus, pae, acpi, apic) ) {
  46.167 -        fprintf(stderr, "Couldn't set hvm info for HVM guest.\n");
  46.168 +    if ( set_hvm_info(xc_handle, dom, page_array, vcpus, pae, acpi, apic) )
  46.169 +    {
  46.170 +        ERROR("Couldn't set hvm info for HVM guest.\n");
  46.171          goto error_out;
  46.172      }
  46.173  
  46.174      if ( (e820_page = xc_map_foreign_range(
  46.175 -         xc_handle, dom, PAGE_SIZE, PROT_READ|PROT_WRITE,
  46.176 -         page_array[E820_MAP_PAGE >> PAGE_SHIFT])) == 0 )
  46.177 +              xc_handle, dom, PAGE_SIZE, PROT_READ | PROT_WRITE,
  46.178 +              page_array[E820_MAP_PAGE >> PAGE_SHIFT])) == 0 )
  46.179          goto error_out;
  46.180      memset(e820_page, 0, PAGE_SIZE);
  46.181      e820_map_nr = build_e820map(e820_page, v_end);
  46.182 @@ -267,8 +265,8 @@ static int setup_guest(int xc_handle,
  46.183  
  46.184      /* shared_info page starts its life empty. */
  46.185      if ( (shared_info = xc_map_foreign_range(
  46.186 -         xc_handle, dom, PAGE_SIZE, PROT_READ|PROT_WRITE,
  46.187 -         shared_info_frame)) == 0 )
  46.188 +              xc_handle, dom, PAGE_SIZE, PROT_READ | PROT_WRITE,
  46.189 +              shared_info_frame)) == 0 )
  46.190          goto error_out;
  46.191      memset(shared_info, 0, sizeof(shared_info_t));
  46.192      /* Mask all upcalls... */
  46.193 @@ -279,8 +277,8 @@ static int setup_guest(int xc_handle,
  46.194      /* Populate the event channel port in the shared page */
  46.195      shared_page_frame = page_array[(v_end >> PAGE_SHIFT) - 1];
  46.196      if ( (sp = (shared_iopage_t *) xc_map_foreign_range(
  46.197 -         xc_handle, dom, PAGE_SIZE, PROT_READ|PROT_WRITE,
  46.198 -         shared_page_frame)) == 0 )
  46.199 +              xc_handle, dom, PAGE_SIZE, PROT_READ | PROT_WRITE,
  46.200 +              shared_page_frame)) == 0 )
  46.201          goto error_out;
  46.202      memset(sp, 0, PAGE_SIZE);
  46.203  
  46.204 @@ -290,7 +288,7 @@ static int setup_guest(int xc_handle,
  46.205  
  46.206          vp_eport = xc_evtchn_alloc_unbound(xc_handle, dom, 0);
  46.207          if ( vp_eport < 0 ) {
  46.208 -            fprintf(stderr, "Couldn't get unbound port from VMX guest.\n");
  46.209 +            PERROR("Couldn't get unbound port from VMX guest.\n");
  46.210              goto error_out;
  46.211          }
  46.212          sp->vcpu_iodata[i].vp_eport = vp_eport;
    47.1 --- a/tools/libxc/xc_ptrace.c	Tue Mar 21 09:55:44 2006 -0700
    47.2 +++ b/tools/libxc/xc_ptrace.c	Tue Mar 21 11:19:11 2006 -0700
    47.3 @@ -251,35 +251,39 @@ map_domain_va(
    47.4      if (fetch_regs(xc_handle, cpu, NULL))
    47.5          return NULL;
    47.6  
    47.7 -    if ( ctxt[cpu].ctrlreg[3] != cr3_phys[cpu] )
    47.8 -    {
    47.9 -        cr3_phys[cpu] = ctxt[cpu].ctrlreg[3];
   47.10 -        if ( cr3_virt[cpu] )
   47.11 -            munmap(cr3_virt[cpu], PAGE_SIZE);
   47.12 -        cr3_virt[cpu] = xc_map_foreign_range(
   47.13 -            xc_handle, current_domid, PAGE_SIZE, PROT_READ,
   47.14 -            cr3_phys[cpu] >> PAGE_SHIFT);
   47.15 -        if ( cr3_virt[cpu] == NULL )
   47.16 +    if (paging_enabled(&ctxt[cpu])) {
   47.17 +       if ( ctxt[cpu].ctrlreg[3] != cr3_phys[cpu] )
   47.18 +        {
   47.19 +            cr3_phys[cpu] = ctxt[cpu].ctrlreg[3];
   47.20 +            if ( cr3_virt[cpu] )
   47.21 +                munmap(cr3_virt[cpu], PAGE_SIZE);
   47.22 +            cr3_virt[cpu] = xc_map_foreign_range(
   47.23 +                xc_handle, current_domid, PAGE_SIZE, PROT_READ,
   47.24 +                cr3_phys[cpu] >> PAGE_SHIFT);
   47.25 +            if ( cr3_virt[cpu] == NULL )
   47.26 +                return NULL;
   47.27 +        }
   47.28 +        if ( (pde = cr3_virt[cpu][vtopdi(va)]) == 0 )
   47.29              return NULL;
   47.30 +        if ( (ctxt[cpu].flags & VGCF_HVM_GUEST) && paging_enabled(&ctxt[cpu]) )
   47.31 +            pde = page_array[pde >> PAGE_SHIFT] << PAGE_SHIFT;
   47.32 +        if ( pde != pde_phys[cpu] )
   47.33 +        {
   47.34 +            pde_phys[cpu] = pde;
   47.35 +            if ( pde_virt[cpu] )
   47.36 +                munmap(pde_virt[cpu], PAGE_SIZE);
   47.37 +            pde_virt[cpu] = xc_map_foreign_range(
   47.38 +                xc_handle, current_domid, PAGE_SIZE, PROT_READ,
   47.39 +                pde_phys[cpu] >> PAGE_SHIFT);
   47.40 +            if ( pde_virt[cpu] == NULL )
   47.41 +                return NULL;
   47.42 +        }
   47.43 +        if ( (page = pde_virt[cpu][vtopti(va)]) == 0 )
   47.44 +            return NULL;
   47.45 +    } else {
   47.46 +        page = va;
   47.47      }
   47.48 -    if ( (pde = cr3_virt[cpu][vtopdi(va)]) == 0 )
   47.49 -        return NULL;
   47.50 -    if ( (ctxt[cpu].flags & VGCF_HVM_GUEST) && paging_enabled(&ctxt[cpu]) )
   47.51 -        pde = page_array[pde >> PAGE_SHIFT] << PAGE_SHIFT;
   47.52 -    if ( pde != pde_phys[cpu] )
   47.53 -    {
   47.54 -        pde_phys[cpu] = pde;
   47.55 -        if ( pde_virt[cpu] )
   47.56 -            munmap(pde_virt[cpu], PAGE_SIZE);
   47.57 -        pde_virt[cpu] = xc_map_foreign_range(
   47.58 -            xc_handle, current_domid, PAGE_SIZE, PROT_READ,
   47.59 -            pde_phys[cpu] >> PAGE_SHIFT);
   47.60 -        if ( pde_virt[cpu] == NULL )
   47.61 -            return NULL;
   47.62 -    }
   47.63 -    if ( (page = pde_virt[cpu][vtopti(va)]) == 0 )
   47.64 -        return NULL;
   47.65 -    if ( (ctxt[cpu].flags & VGCF_HVM_GUEST) && paging_enabled(&ctxt[cpu]) )
   47.66 +    if (ctxt[cpu].flags & VGCF_HVM_GUEST)
   47.67          page = page_array[page >> PAGE_SHIFT] << PAGE_SHIFT;
   47.68      if ( (page != page_phys[cpu]) || (perm != prev_perm[cpu]) )
   47.69      {
    48.1 --- a/tools/python/xen/xend/XendDomainInfo.py	Tue Mar 21 09:55:44 2006 -0700
    48.2 +++ b/tools/python/xen/xend/XendDomainInfo.py	Tue Mar 21 11:19:11 2006 -0700
    48.3 @@ -24,6 +24,7 @@ Author: Mike Wray <mike.wray@hp.com>
    48.4  
    48.5  """
    48.6  
    48.7 +import errno
    48.8  import logging
    48.9  import string
   48.10  import time
   48.11 @@ -893,7 +894,7 @@ class XendDomainInfo:
   48.12                  self.domid, timeout)
   48.13              threading.Timer(timeout, self.refreshShutdown).start()
   48.14  
   48.15 -        return 1
   48.16 +        return True
   48.17  
   48.18  
   48.19      def shutdown(self, reason):
   48.20 @@ -1246,30 +1247,34 @@ class XendDomainInfo:
   48.21          """Cleanup domain resources; release devices.  Idempotent.  Nothrow
   48.22          guarantee."""
   48.23  
   48.24 -        self.unwatchShutdown()
   48.25 +        self.refresh_shutdown_lock.acquire()
   48.26 +        try:
   48.27 +            self.unwatchShutdown()
   48.28  
   48.29 -        self.release_devices()
   48.30 +            self.release_devices()
   48.31  
   48.32 -        if self.image:
   48.33 -            try:
   48.34 -                self.image.destroy()
   48.35 -            except:
   48.36 -                log.exception(
   48.37 -                    "XendDomainInfo.cleanup: image.destroy() failed.")
   48.38 -            self.image = None
   48.39 +            if self.image:
   48.40 +                try:
   48.41 +                    self.image.destroy()
   48.42 +                except:
   48.43 +                    log.exception(
   48.44 +                        "XendDomainInfo.cleanup: image.destroy() failed.")
   48.45 +                self.image = None
   48.46  
   48.47 -        try:
   48.48 -            self.removeDom()
   48.49 -        except:
   48.50 -            log.exception("Removing domain path failed.")
   48.51 +            try:
   48.52 +                self.removeDom()
   48.53 +            except:
   48.54 +                log.exception("Removing domain path failed.")
   48.55  
   48.56 -        try:
   48.57 -            if not self.info['name'].startswith(ZOMBIE_PREFIX):
   48.58 -                self.info['name'] = ZOMBIE_PREFIX + self.info['name']
   48.59 -        except:
   48.60 -            log.exception("Renaming Zombie failed.")
   48.61 +            try:
   48.62 +                if not self.info['name'].startswith(ZOMBIE_PREFIX):
   48.63 +                    self.info['name'] = ZOMBIE_PREFIX + self.info['name']
   48.64 +            except:
   48.65 +                log.exception("Renaming Zombie failed.")
   48.66  
   48.67 -        self.state_set(STATE_DOM_SHUTDOWN)
   48.68 +            self.state_set(STATE_DOM_SHUTDOWN)
   48.69 +        finally:
   48.70 +            self.refresh_shutdown_lock.release()
   48.71  
   48.72  
   48.73      def cleanupVm(self):
   48.74 @@ -1301,7 +1306,8 @@ class XendDomainInfo:
   48.75  
   48.76      def unwatchShutdown(self):
   48.77          """Remove the watch on the domain's control/shutdown node, if any.
   48.78 -        Idempotent.  Nothrow guarantee."""
   48.79 +        Idempotent.  Nothrow guarantee.  Expects to be protected by the
   48.80 +        refresh_shutdown_lock."""
   48.81  
   48.82          try:
   48.83              try:
    49.1 --- a/tools/python/xen/xm/create.py	Tue Mar 21 09:55:44 2006 -0700
    49.2 +++ b/tools/python/xen/xm/create.py	Tue Mar 21 11:19:11 2006 -0700
    49.3 @@ -14,7 +14,7 @@
    49.4  #============================================================================
    49.5  # Copyright (C) 2004, 2005 Mike Wray <mike.wray@hp.com>
    49.6  # Copyright (C) 2005 Nguyen Anh Quynh <aquynh@gmail.com>
    49.7 -# Copyright (C) 2005 XenSource Ltd
    49.8 +# Copyright (C) 2005-2006 XenSource Ltd
    49.9  #============================================================================
   49.10  
   49.11  """Domain creation.
   49.12 @@ -28,8 +28,6 @@ import commands
   49.13  import time
   49.14  import re
   49.15  
   49.16 -import xen.lowlevel.xc
   49.17 -
   49.18  from xen.xend import sxp
   49.19  from xen.xend import PrettyPrint
   49.20  from xen.xend.XendClient import server, XendError
   49.21 @@ -91,10 +89,6 @@ gopts.opt('config', short='F', val='FILE
   49.22            SXP configurations can be hand-written or generated from Python configuration
   49.23            scripts, using the -n (dryrun) option to print the configuration.""")
   49.24  
   49.25 -gopts.opt('load', short='L', val='FILE',
   49.26 -          fn=set_value, default=None,
   49.27 -          use='Domain saved state to load.')
   49.28 -
   49.29  gopts.opt('dryrun', short='n',
   49.30            fn=set_true, default=0,
   49.31            use="""Dry run - print the configuration but don't create the domain.
   49.32 @@ -819,11 +813,7 @@ def make_domain(opts, config):
   49.33      """
   49.34  
   49.35      try:
   49.36 -        if opts.vals.load:
   49.37 -            filename = os.path.abspath(opts.vals.load)
   49.38 -            dominfo = server.xend_domain_restore(filename, config)
   49.39 -        else:
   49.40 -            dominfo = server.xend_domain_create(config)
   49.41 +        dominfo = server.xend_domain_create(config)
   49.42      except XendError, ex:
   49.43          import signal
   49.44          if vncpid:
    50.1 --- a/tools/xm-test/lib/XmTestLib/XenDomain.py	Tue Mar 21 09:55:44 2006 -0700
    50.2 +++ b/tools/xm-test/lib/XmTestLib/XenDomain.py	Tue Mar 21 11:19:11 2006 -0700
    50.3 @@ -74,7 +74,7 @@ HVMDefaults =      {"memory"       : 64,
    50.4                      "vcpus"        : 1,
    50.5                      "acpi"         : 0,
    50.6                      "apic"         : 0,
    50.7 -                    "disk"         : ["file:%s/disk.img,ioemu:%s,w" %
    50.8 +                    "disk"         : ["file:%s/disk.img,ioemu:%s,w!" %
    50.9                                     (getRdPath(), BLOCK_ROOT_DEV)],
   50.10                      "kernel"       : "/usr/lib/xen/boot/hvmloader",
   50.11                      "builder"      : "hvm",
   50.12 @@ -251,9 +251,6 @@ class XmTestDomain(XenDomain):
   50.13          if ENABLE_HVM_SUPPORT:
   50.14              waitForBoot()
   50.15  
   50.16 -    def startNow(self):
   50.17 -        XenDomain.start(self)
   50.18 -
   50.19      def minSafeMem(self):
   50.20          return 16
   50.21  
    51.1 --- a/tools/xm-test/lib/XmTestReport/Report.py	Tue Mar 21 09:55:44 2006 -0700
    51.2 +++ b/tools/xm-test/lib/XmTestReport/Report.py	Tue Mar 21 11:19:11 2006 -0700
    51.3 @@ -32,11 +32,7 @@ import xml.dom.minidom
    51.4  import httplib
    51.5  import urllib
    51.6  import re
    51.7 -
    51.8 -#REPORT_HOST = "xmtest-dev.dague.org"
    51.9 -REPORT_HOST = "xmtest.dague.org"
   51.10 -REPORT_URL  = "/cgi-bin/report-results";
   51.11 -VIEW_URL = "cgi-bin/display?view=single&testid="
   51.12 +from urlparse import urlparse
   51.13  
   51.14  class XmTestReport:
   51.15  
   51.16 @@ -88,8 +84,11 @@ def encodeForm(fieldList):
   51.17  
   51.18      return 'multipart/form-data; boundary=%s' % boundary, textBody
   51.19  
   51.20 -def postResults(results):
   51.21 -    conn = httplib.HTTPConnection(REPORT_HOST)
   51.22 +def postResults(report_server, results):
   51.23 +    if not re.match('http://', report_server):
   51.24 +	report_server = 'http://'+report_server
   51.25 +    (report_host,report_url) = urlparse(report_server)[1:3]
   51.26 +    conn = httplib.HTTPConnection(report_host)
   51.27  
   51.28      type, body = encodeForm({"log" : results})
   51.29  
   51.30 @@ -100,22 +99,17 @@ def postResults(results):
   51.31      # print "%s\n" % type
   51.32      # print headers
   51.33      
   51.34 -    conn.request("POST", REPORT_URL, body, headers)
   51.35 +    conn.request("POST", report_url, body, headers)
   51.36      
   51.37      resp = conn.getresponse()
   51.38      data = resp.read()
   51.39  
   51.40      if resp.status == 200:
   51.41          print >>sys.stderr, "Your results have been submitted successfully!"
   51.42 -        match = re.match("^id=([0-9]+)$", data.split("\n")[1])
   51.43 -        if match:
   51.44 -            id = match.group(1)
   51.45 -            print >>sys.stderr, "See your report at:"
   51.46 -            print >>sys.stderr, "http://%s/%s%s" % (REPORT_HOST, VIEW_URL, id)
   51.47      else:
   51.48          print >>sys.stderr, "Unable to submit results:"
   51.49 -        print >>sys.stderr, "[http://%s%s] said %i: %s" % (REPORT_HOST,
   51.50 -                                                           REPORT_URL,
   51.51 +        print >>sys.stderr, "[http://%s%s] said %i: %s" % (report_host,
   51.52 +                                                           report_url,
   51.53                                                             resp.status,
   51.54                                                             resp.reason)
   51.55          print >>sys.stderr, data
   51.56 @@ -133,7 +127,9 @@ if __name__ == "__main__":
   51.57      dump = False
   51.58      files = []
   51.59  
   51.60 -    for a in sys.argv[1:]:
   51.61 +    report_server = sys.argv[1]
   51.62 +
   51.63 +    for a in sys.argv[2:]:
   51.64          if a == "-d":
   51.65              submit = False
   51.66              dump = True
   51.67 @@ -156,5 +152,5 @@ if __name__ == "__main__":
   51.68          print xmlout
   51.69  
   51.70      if submit:
   51.71 -        postResults(xmlout)
   51.72 +        postResults(report_server, xmlout)
   51.73      
    52.1 --- a/tools/xm-test/ramdisk/Makefile.am	Tue Mar 21 09:55:44 2006 -0700
    52.2 +++ b/tools/xm-test/ramdisk/Makefile.am	Tue Mar 21 11:19:11 2006 -0700
    52.3 @@ -14,6 +14,8 @@ HVM_SCRIPT = bin/create_disk_image
    52.4  XMTEST_MAJ_VER = $(shell echo @PACKAGE_VERSION@ | perl -pe 's/(\d+)\.(\d+)\.\d+/\1.\2/')
    52.5  XMTEST_VER_IMG = initrd-$(XMTEST_MAJ_VER).img
    52.6  
    52.7 +EXTRA_ROOT_DIRS = sys
    52.8 +
    52.9  if HVM
   52.10  all: initrd.img disk.img
   52.11  else
   52.12 @@ -36,7 +38,8 @@ endif
   52.13  
   52.14  $(XMTEST_VER_IMG): $(BR_IMG)
   52.15  	chmod a+x skel/etc/init.d/rcS
   52.16 -	(cd skel; tar cf - .) | (cd $(BR_SRC)/$(BR_ROOT); tar xvf -)
   52.17 +	(cd skel; mkdir -p $(EXTRA_ROOT_DIRS); tar cf - .) \
   52.18 +		| (cd $(BR_SRC)/$(BR_ROOT); tar xvf -)
   52.19  	cd $(BR_SRC) && make
   52.20  	cp $(BR_IMG) initrd-$(XMTEST_MAJ_VER).img
   52.21  
    53.1 --- a/tools/xm-test/ramdisk/skel/etc/init.d/rcS	Tue Mar 21 09:55:44 2006 -0700
    53.2 +++ b/tools/xm-test/ramdisk/skel/etc/init.d/rcS	Tue Mar 21 11:19:11 2006 -0700
    53.3 @@ -2,3 +2,7 @@
    53.4  
    53.5  mount -a
    53.6  
    53.7 +# If we're running 2.6, make sure /sys is mounted
    53.8 +if uname -r | grep -q '^2.6'; then
    53.9 +	mount -t sysfs none /sys
   53.10 +fi
    54.1 --- a/tools/xm-test/runtest.sh	Tue Mar 21 09:55:44 2006 -0700
    54.2 +++ b/tools/xm-test/runtest.sh	Tue Mar 21 11:19:11 2006 -0700
    54.3 @@ -13,7 +13,9 @@ usage() {
    54.4      echo "  -b          : do not ask any questions (batch mode)"
    54.5      echo "  -g          : run a group test set"
    54.6      echo "  -e <email>  : set email address for report"
    54.7 +    echo "  -r <url>    : url of test results repository to use"
    54.8      echo "  -s <report> : just submit report <report>"
    54.9 +    echo "  -u          : unsafe -- do not run the sanity checks before starting"
   54.10      echo "  -h | --help : show this help"
   54.11  }
   54.12  
   54.13 @@ -22,7 +24,7 @@ submit_report() {
   54.14  
   54.15      reportfile=$1
   54.16  
   54.17 -    ./lib/XmTestReport/Report.py $reportfile
   54.18 +    ./lib/XmTestReport/Report.py $reportserver $reportfile
   54.19  }
   54.20  
   54.21  # Generate XML result report from output file
   54.22 @@ -189,8 +191,10 @@ EOF
   54.23  # Defaults
   54.24  MAXFAIL=10
   54.25  report=yes
   54.26 +reportserver=${xmtest_repo:-'http://xmtest.dague.org/cgi-bin/report-results'}
   54.27  batch=no
   54.28  run=yes
   54.29 +unsafe=no
   54.30  GROUPENTERED=default
   54.31  
   54.32  # Resolve options
   54.33 @@ -218,9 +222,18 @@ while [ $# -gt 0 ]
   54.34               exit 1
   54.35            fi
   54.36  	  ;;
   54.37 +      -r)
   54.38 +	  shift
   54.39 +	  reportserver=$1
   54.40 +	  ;;
   54.41        -s)
   54.42  	  run=no
   54.43  	  ;;
   54.44 +      -u)
   54.45 +	  echo "(Unsafe mode)"
   54.46 +	  unsafe=yes
   54.47 +	  report=no
   54.48 +	  ;;
   54.49        -h|--help)
   54.50            usage
   54.51            exit 0
   54.52 @@ -264,15 +277,25 @@ if [ ! -f contact_info ]; then
   54.53      fi
   54.54  fi
   54.55  
   54.56 +if [ "$GROUPENTERED" != "default" ]; then
   54.57 +   report=no;
   54.58 +fi
   54.59 +
   54.60  if [ "$run" != "no" ]; then
   54.61 -    runnable_tests
   54.62 -    make_environment_report $OSREPORTTEMP $PROGREPORTTEMP
   54.63 +    if [ "$unsafe" = "no" ]; then
   54.64 +      runnable_tests
   54.65 +    fi
   54.66 +    rm -f $REPORT"*"
   54.67 +    if [ "$unsafe" = "no" ]; then
   54.68 +      make_environment_report $OSREPORTTEMP $PROGREPORTTEMP
   54.69 +    fi
   54.70      run_tests $GROUPENTERED $OUTPUT
   54.71      make_text_reports $PASSFAIL $FAILURES $OUTPUT $TXTREPORT
   54.72 -    make_result_report $OUTPUT $RESULTREPORTTEMP
   54.73 -    cat $OSREPORTTEMP $PROGREPORTTEMP $RESULTREPORTTEMP > $XMLREPORT
   54.74 -    rm $OSREPORTTEMP $PROGREPORTTEMP $RESULTREPORTTEMP
   54.75 -
   54.76 +    if [ "$unsafe" = "no" ]; then
   54.77 +      make_result_report $OUTPUT $RESULTREPORTTEMP
   54.78 +      cat $OSREPORTTEMP $PROGREPORTTEMP $RESULTREPORTTEMP > $XMLREPORT
   54.79 +      rm $OSREPORTTEMP $PROGREPORTTEMP $RESULTREPORTTEMP
   54.80 +    fi
   54.81  fi
   54.82  
   54.83  if [ "$report" = "yes" ]; then
    55.1 --- a/tools/xm-test/tests/create/10_create_fastdestroy.py	Tue Mar 21 09:55:44 2006 -0700
    55.2 +++ b/tools/xm-test/tests/create/10_create_fastdestroy.py	Tue Mar 21 11:19:11 2006 -0700
    55.3 @@ -28,7 +28,7 @@ i = 0
    55.4  for i in range(0,50):
    55.5      domain = XmTestDomain("testdomain")
    55.6      try:
    55.7 -        domain.startNow()
    55.8 +        domain.start()
    55.9      except DomainError,e:
   55.10          print "Failed: " + e.extra
   55.11          NSPerror = check_for_NSP_error(e.extra)
    56.1 --- a/tools/xm-test/tests/destroy/07_destroy_stale_pos.py	Tue Mar 21 09:55:44 2006 -0700
    56.2 +++ b/tools/xm-test/tests/destroy/07_destroy_stale_pos.py	Tue Mar 21 11:19:11 2006 -0700
    56.3 @@ -101,29 +101,24 @@ def test_sysrq(name):
    56.4      if not re.search("[Ee]rror", output):
    56.5          FAIL("sysrq failed to report error after destroy!")
    56.6  
    56.7 -def runTests(tests, wait):
    56.8 +def runTests(tests):
    56.9      for test in tests:
   56.10          domain = XmTestDomain()
   56.11  
   56.12          # Create a domain
   56.13  
   56.14          try:
   56.15 -            if wait:
   56.16 -                domain.start()
   56.17 -            else:
   56.18 -                domain.startNow()
   56.19 +            domain.start()
   56.20          except DomainError, e:
   56.21              FAIL(str(e))
   56.22  
   56.23 -
   56.24 -        if wait:
   56.25 -            # Attach a console and make sure it's live
   56.26 -            try:
   56.27 -                console = XmConsole(domain.getName())
   56.28 -                console.sendInput("foo")
   56.29 -                console.runCmd("ls")
   56.30 -            except ConsoleError, e:
   56.31 -                FAIL(str(e))
   56.32 +        # Attach a console and make sure it's live
   56.33 +        try:
   56.34 +            console = XmConsole(domain.getName())
   56.35 +            console.sendInput("foo")
   56.36 +            console.runCmd("ls")
   56.37 +        except ConsoleError, e:
   56.38 +            FAIL(str(e))
   56.39  
   56.40          # Destroy it
   56.41                  
   56.42 @@ -137,9 +132,5 @@ tests = [test_mem_set, test_pause, test_
   56.43           test_block_list, test_shutdown, test_domid, test_domname]
   56.44  
   56.45  if verbose:
   56.46 -    print "Running stale tests (nice mode)"
   56.47 -runTests(tests, True)
   56.48 -
   56.49 -if verbose:
   56.50 -    print "Running stale tests (mean mode)"
   56.51 -runTests(tests, False)
   56.52 +    print "Running stale tests"
   56.53 +runTests(tests)
    57.1 --- a/tools/xm-test/tests/vcpu-pin/01_vcpu-pin_basic_pos.py	Tue Mar 21 09:55:44 2006 -0700
    57.2 +++ b/tools/xm-test/tests/vcpu-pin/01_vcpu-pin_basic_pos.py	Tue Mar 21 11:19:11 2006 -0700
    57.3 @@ -46,3 +46,5 @@ cpu = getVcpuInfo(domain.getName())[0]
    57.4  
    57.5  if cpu != 1:
    57.6      FAIL("failed to switch VCPU 0 to CPU 1")
    57.7 +
    57.8 +domain.stop()
    58.1 --- a/tools/xm-test/tests/vtpm/01_vtpm-list_pos.py	Tue Mar 21 09:55:44 2006 -0700
    58.2 +++ b/tools/xm-test/tests/vtpm/01_vtpm-list_pos.py	Tue Mar 21 11:19:11 2006 -0700
    58.3 @@ -1,21 +1,16 @@
    58.4  #!/usr/bin/python
    58.5  
    58.6  # Copyright (C) International Business Machines Corp., 2006
    58.7 -# Author: Stefan Berger <stefanb@us.ibm.com)
    58.8 +# Author: Stefan Berger <stefanb@us.ibm.com>
    58.9  
   58.10  # Positive Test: create domain with virtual TPM attached at build time,
   58.11  #                verify list
   58.12  
   58.13  
   58.14  from XmTestLib import *
   58.15 -
   58.16 -def vtpm_cleanup(domName):
   58.17 -	# Since this is only a temporary domain I clean up the domain from the
   58.18 -	# virtual TPM directory
   58.19 -	traceCommand("/etc/xen/scripts/vtpm-delete %s" % domName)
   58.20 -
   58.21 -if ENABLE_HVM_SUPPORT:
   58.22 -    SKIP("vtpm-list not supported for HVM domains")
   58.23 +from vtpm_utils import *
   58.24 +import commands
   58.25 +import os
   58.26  
   58.27  config = {"vtpm":"instance=1,backend=0"}
   58.28  domain = XmTestDomain(extraConfig=config)
    59.1 --- a/tools/xm-test/tests/vtpm/02_vtpm-cat_pcrs.py	Tue Mar 21 09:55:44 2006 -0700
    59.2 +++ b/tools/xm-test/tests/vtpm/02_vtpm-cat_pcrs.py	Tue Mar 21 11:19:11 2006 -0700
    59.3 @@ -1,30 +1,17 @@
    59.4  #!/usr/bin/python
    59.5  
    59.6  # Copyright (C) International Business Machines Corp., 2006
    59.7 -# Author: Stefan Berger <stefanb@us.ibm.com)
    59.8 +# Author: Stefan Berger <stefanb@us.ibm.com>
    59.9  
   59.10  # Positive Test: create domain with virtual TPM attached at build time,
   59.11  #                check list of pcrs
   59.12  
   59.13  from XmTestLib import *
   59.14 -
   59.15 -def vtpm_cleanup(domName):
   59.16 -	# Since this is only a temporary domain I clean up the domain from the
   59.17 -	# virtual TPM directory
   59.18 -	traceCommand("/etc/xen/scripts/vtpm-delete %s" % domName)
   59.19 -
   59.20 -if ENABLE_HVM_SUPPORT:
   59.21 -    SKIP("vtpm-list not supported for HVM domains")
   59.22 +from vtpm_utils import *
   59.23 +import commands
   59.24 +import os
   59.25 +import os.path
   59.26  
   59.27 -status, output = traceCommand("ls /dev/tpm0")
   59.28 -if re.search("No such file or directory",output):
   59.29 -    SKIP("This machine has no hardware TPM; cannot run this test")
   59.30 -
   59.31 -status, output = traceCommand("ps aux | grep vtpm_manager | grep -v grep")
   59.32 -if output == "":
   59.33 -    FAIL("virtual TPM manager must be started to run this test")
   59.34 -
   59.35 -# vtpm manager has been detected
   59.36  config = {"vtpm":"instance=1,backend=0"}
   59.37  domain = XmTestDomain(extraConfig=config)
   59.38  
   59.39 @@ -46,21 +33,11 @@ except ConsoleError, e:
   59.40  
   59.41  try:
   59.42      console.sendInput("input")
   59.43 -    run = console.runCmd("ls /sys")
   59.44  except ConsoleError, e:
   59.45      saveLog(console.getHistory())
   59.46      vtpm_cleanup(domName)
   59.47      FAIL(str(e))
   59.48  
   59.49 -if re.search("No such file",run["output"]):
   59.50 -    try:
   59.51 -        run = console.runCmd("mkdir /sys")
   59.52 -        run = console.runCmd("mount -t sysfs /sys /sys")
   59.53 -    except ConsoleError, e:
   59.54 -        saveLog(console.getHistory())
   59.55 -        vtpm_cleanup(domName)
   59.56 -        FAIL(str(e))
   59.57 -
   59.58  try:
   59.59      run = console.runCmd("cat /sys/devices/platform/tpm_vtpm/pcrs")
   59.60  except ConsoleError, e:
    60.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    60.2 +++ b/tools/xm-test/tests/vtpm/03_vtpm-susp_res.py	Tue Mar 21 11:19:11 2006 -0700
    60.3 @@ -0,0 +1,105 @@
    60.4 +#!/usr/bin/python
    60.5 +
    60.6 +# Copyright (C) International Business Machines Corp., 2006
    60.7 +# Author: Stefan Berger <stefanb@us.ibm.com>
    60.8 +
    60.9 +# Positive Test: create domain with virtual TPM attached at build time,
   60.10 +#                check list of pcrs; suspend and resume the domain and
   60.11 +#                check list of pcrs again
   60.12 +
   60.13 +from XmTestLib import *
   60.14 +from vtpm_utils import *
   60.15 +import commands
   60.16 +import os
   60.17 +import os.path
   60.18 +
   60.19 +config = {"vtpm":"instance=1,backend=0"}
   60.20 +domain = XmTestDomain(extraConfig=config)
   60.21 +
   60.22 +try:
   60.23 +    domain.start()
   60.24 +except DomainError, e:
   60.25 +    if verbose:
   60.26 +        print e.extra
   60.27 +    vtpm_cleanup(domain.getName())
   60.28 +    FAIL("Unable to create domain")
   60.29 +
   60.30 +domName = domain.getName()
   60.31 +
   60.32 +try:
   60.33 +    console = XmConsole(domain.getName())
   60.34 +except ConsoleError, e:
   60.35 +    vtpm_cleanup(domName)
   60.36 +    FAIL(str(e))
   60.37 +
   60.38 +try:
   60.39 +    console.sendInput("input")
   60.40 +except ConsoleError, e:
   60.41 +    saveLog(console.getHistory())
   60.42 +    vtpm_cleanup(domName)
   60.43 +    FAIL(str(e))
   60.44 +
   60.45 +try:
   60.46 +    run = console.runCmd("cat /sys/devices/platform/tpm_vtpm/pcrs")
   60.47 +except ConsoleError, e:
   60.48 +    saveLog(console.getHistory())
   60.49 +    vtpm_cleanup(domName)
   60.50 +    FAIL(str(e))
   60.51 +
   60.52 +if re.search("No such file",run["output"]):
   60.53 +    FAIL("TPM frontend support not compiled into (domU?) kernel")
   60.54 +
   60.55 +console.closeConsole()
   60.56 +
   60.57 +try:
   60.58 +    status, ouptut = traceCommand("xm save %s %s.save" %
   60.59 +                                  (domName, domName),
   60.60 +                                  timeout=30)
   60.61 +except TimeoutError, e:
   60.62 +    saveLog(console.getHistory())
   60.63 +    vtpm_cleanup(domName)
   60.64 +    FAIL(str(e))
   60.65 +
   60.66 +if status != 0:
   60.67 +    saveLog(console.getHistory())
   60.68 +    vtpm_cleanup(domName)
   60.69 +    FAIL("xm save did not succeed")
   60.70 +
   60.71 +try:
   60.72 +    status, ouptut = traceCommand("xm restore %s.save" %
   60.73 +                                  (domName),
   60.74 +                                  timeout=30)
   60.75 +except TimeoutError, e:
   60.76 +    os.remove("%s.save" % domName)
   60.77 +    saveLog(console.getHistory())
   60.78 +    vtpm_cleanup(domName)
   60.79 +    FAIL(str(e))
   60.80 +
   60.81 +os.remove("%s.save" % domName)
   60.82 +
   60.83 +if status != 0:
   60.84 +    saveLog(console.getHistory())
   60.85 +    vtpm_cleanup(domName)
   60.86 +    FAIL("xm restore did not succeed")
   60.87 +
   60.88 +try:
   60.89 +    console = XmConsole(domain.getName())
   60.90 +except ConsoleError, e:
   60.91 +    vtpm_cleanup(domName)
   60.92 +    FAIL(str(e))
   60.93 +
   60.94 +try:
   60.95 +    run = console.runCmd("cat /sys/devices/platform/tpm_vtpm/pcrs")
   60.96 +except ConsoleError, e:
   60.97 +    saveLog(console.getHistory())
   60.98 +    vtpm_cleanup(domName)
   60.99 +    FAIL(str(e))
  60.100 +
  60.101 +console.closeConsole()
  60.102 +
  60.103 +domain.stop()
  60.104 +
  60.105 +vtpm_cleanup(domName)
  60.106 +
  60.107 +if not re.search("PCR-00:",run["output"]):
  60.108 +	FAIL("Virtual TPM is not working correctly on /dev/vtpm on backend side")
    61.1 --- a/tools/xm-test/tests/vtpm/Makefile.am	Tue Mar 21 09:55:44 2006 -0700
    61.2 +++ b/tools/xm-test/tests/vtpm/Makefile.am	Tue Mar 21 11:19:11 2006 -0700
    61.3 @@ -1,13 +1,12 @@
    61.4 -
    61.5  SUBDIRS =
    61.6  
    61.7  TESTS = 01_vtpm-list_pos.test \
    61.8 -        02_vtpm-cat_pcrs.test
    61.9 +        02_vtpm-cat_pcrs.test \
   61.10 +        03_vtpm-susp_res.test
   61.11  
   61.12  XFAIL_TESTS =
   61.13  
   61.14 -EXTRA_DIST = $(TESTS) $(XFAIL_TESTS)
   61.15 -
   61.16 +EXTRA_DIST = $(TESTS) $(XFAIL_TESTS) vtpm_utils.py
   61.17  TESTS_ENVIRONMENT=@TENV@
   61.18  
   61.19  %.test: %.py
    62.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    62.2 +++ b/tools/xm-test/tests/vtpm/vtpm_utils.py	Tue Mar 21 11:19:11 2006 -0700
    62.3 @@ -0,0 +1,19 @@
    62.4 +#!/usr/bin/python
    62.5 +
    62.6 +# Copyright (C) International Business Machines Corp., 2006
    62.7 +# Author: Stefan Berger <stefanb@us.ibm.com>
    62.8 +
    62.9 +from XmTestLib import *
   62.10 +
   62.11 +if ENABLE_HVM_SUPPORT:
   62.12 +    SKIP("vtpm tests not supported for HVM domains")
   62.13 +
   62.14 +if not os.path.isfile("/dev/tpm0"):
   62.15 +    SKIP("This machine has no hardware TPM; cannot run this test")
   62.16 +
   62.17 +status, output = traceCommand("ps aux | grep vtpm_manager | grep -v grep")
   62.18 +if output == "":
   62.19 +    FAIL("virtual TPM manager must be started to run this test")
   62.20 +
   62.21 +def vtpm_cleanup(domName):
   62.22 +	traceCommand("/etc/xen/scripts/vtpm-delete %s" % domName)
    63.1 --- a/xen/Makefile	Tue Mar 21 09:55:44 2006 -0700
    63.2 +++ b/xen/Makefile	Tue Mar 21 11:19:11 2006 -0700
    63.3 @@ -55,12 +55,7 @@ clean: delete-unfresh-files
    63.4  	[ -e include/asm ] || ln -sf asm-$(TARGET_ARCH) include/asm
    63.5  	$(MAKE) -C arch/$(TARGET_ARCH) asm-offsets.s
    63.6  	$(MAKE) include/asm-$(TARGET_ARCH)/asm-offsets.h
    63.7 -	$(MAKE) -C common
    63.8 -	$(MAKE) -C drivers
    63.9 -ifeq ($(ACM_SECURITY),y)
   63.10 -	$(MAKE) -C acm
   63.11 -endif
   63.12 -	$(MAKE) -C arch/$(TARGET_ARCH)
   63.13 +	$(MAKE) -C arch/$(TARGET_ARCH) $(TARGET)
   63.14  
   63.15  # drivers/char/console.o contains static banner/compile info. Blow it away.
   63.16  # Don't refresh these files during e.g., 'sudo make install'
    64.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    64.2 +++ b/xen/Post.mk	Tue Mar 21 11:19:11 2006 -0700
    64.3 @@ -0,0 +1,27 @@
    64.4 +# Ensure each subdirectory has exactly one trailing slash.
    64.5 +subdir-n := $(patsubst %,%/,$(patsubst %/,%,$(subdir-n)))
    64.6 +subdir-y := $(patsubst %,%/,$(patsubst %/,%,$(subdir-y)))
    64.7 +
    64.8 +# Add explicitly declared subdirectories to the object list.
    64.9 +obj-y += $(patsubst %,%/built_in.o,$(subdir-y))
   64.10 +
   64.11 +# Add implicitly declared subdirectories (in the object list) to the
   64.12 +# subdirectory list, and rewrite the object-list entry.
   64.13 +subdir-y += $(filter %/,$(obj-y))
   64.14 +obj-y    := $(patsubst %/,%/built-in.o,$(obj-y))
   64.15 +
   64.16 +subdir-all := $(subdir-y) $(subdir-n)
   64.17 +
   64.18 +built_in.o: $(obj-y)
   64.19 +	$(LD) $(LDFLAGS) -r -o $@ $^
   64.20 +
   64.21 +.PHONY: FORCE
   64.22 +FORCE:
   64.23 +
   64.24 +%/built_in.o: FORCE
   64.25 +	$(MAKE) -C $*
   64.26 +
   64.27 +clean:: $(addprefix _clean_, $(subdir-all)) FORCE
   64.28 +	rm -f *.o *~ core
   64.29 +_clean_%/: FORCE
   64.30 +	$(MAKE) -C $* clean
    65.1 --- a/xen/Rules.mk	Tue Mar 21 09:55:44 2006 -0700
    65.2 +++ b/xen/Rules.mk	Tue Mar 21 11:19:11 2006 -0700
    65.3 @@ -8,6 +8,15 @@ perfc       ?= n
    65.4  perfc_arrays?= n
    65.5  crash_debug ?= n
    65.6  
    65.7 +# Hardcoded configuration implications and dependencies.
    65.8 +# Do this is a neater way if it becomes unwieldy.
    65.9 +ifeq ($(debug),y)
   65.10 +verbose := y
   65.11 +endif
   65.12 +ifeq ($(perfc_arrays),y)
   65.13 +perfc := y
   65.14 +endif
   65.15 +
   65.16  XEN_ROOT=$(BASEDIR)/..
   65.17  include $(XEN_ROOT)/Config.mk
   65.18  
   65.19 @@ -27,41 +36,23 @@ HDRS    := $(subst $(BASEDIR)/include/as
   65.20  HDRS    := $(subst $(BASEDIR)/include/xen/banner.h,,$(HDRS))
   65.21  HDRS    := $(subst $(BASEDIR)/include/xen/compile.h,,$(HDRS))
   65.22  
   65.23 -C_SRCS  := $(wildcard *.c)
   65.24 -S_SRCS  := $(wildcard *.S)
   65.25 -OBJS    := $(patsubst %.S,%.o,$(S_SRCS))
   65.26 -OBJS    += $(patsubst %.c,%.o,$(C_SRCS))
   65.27 -
   65.28 -# Note that link order matters!
   65.29 -ALL_OBJS := $(BASEDIR)/common/common.o
   65.30 -ALL_OBJS += $(BASEDIR)/drivers/char/driver.o
   65.31 -ALL_OBJS += $(BASEDIR)/drivers/acpi/driver.o
   65.32 -ifeq ($(ACM_SECURITY),y)
   65.33 -ALL_OBJS += $(BASEDIR)/acm/acm.o
   65.34 -CFLAGS += -DACM_SECURITY
   65.35 -endif
   65.36 -ALL_OBJS += $(BASEDIR)/arch/$(TARGET_ARCH)/arch.o
   65.37 -
   65.38  include $(BASEDIR)/arch/$(TARGET_ARCH)/Rules.mk
   65.39  
   65.40 -CFLAGS += -g -D__XEN__
   65.41 -
   65.42 -ifneq ($(debug)$(verbose),nn)
   65.43 -CFLAGS += -DVERBOSE
   65.44 -endif
   65.45 +# Note that link order matters!
   65.46 +ALL_OBJS-y               += $(BASEDIR)/common/built_in.o
   65.47 +ALL_OBJS-y               += $(BASEDIR)/drivers/built_in.o
   65.48 +ALL_OBJS-$(ACM_SECURITY) += $(BASEDIR)/acm/built_in.o
   65.49 +ALL_OBJS-y               += $(BASEDIR)/arch/$(TARGET_ARCH)/built_in.o
   65.50  
   65.51 -ifeq ($(crash_debug),y)
   65.52 -CFLAGS += -DCRASH_DEBUG
   65.53 -endif
   65.54 +CFLAGS-y               += -g -D__XEN__
   65.55 +CFLAGS-$(ACM_SECURITY) += -DACM_SECURITY
   65.56 +CFLAGS-$(verbose)      += -DVERBOSE
   65.57 +CFLAGS-$(crash_debug)  += -DCRASH_DEBUG
   65.58 +CFLAGS-$(perfc)        += -DPERF_COUNTERS
   65.59 +CFLAGS-$(perfc_arrays) += -DPERF_ARRAYS
   65.60  
   65.61 -ifeq ($(perfc),y)
   65.62 -CFLAGS += -DPERF_COUNTERS
   65.63 -ifeq ($(perfc_arrays),y)
   65.64 -CFLAGS += -DPERF_ARRAYS
   65.65 -endif
   65.66 -endif
   65.67 -
   65.68 -CFLAGS := $(strip $(CFLAGS))
   65.69 +ALL_OBJS := $(ALL_OBJS-y)
   65.70 +CFLAGS   := $(strip $(CFLAGS) $(CFLAGS-y))
   65.71  
   65.72  %.o: %.c $(HDRS) Makefile
   65.73  	$(CC) $(CFLAGS) -c $< -o $@
    66.1 --- a/xen/acm/Makefile	Tue Mar 21 09:55:44 2006 -0700
    66.2 +++ b/xen/acm/Makefile	Tue Mar 21 11:19:11 2006 -0700
    66.3 @@ -1,15 +1,9 @@
    66.4 -
    66.5  include $(BASEDIR)/Rules.mk
    66.6 -OBJS =  acm_core.o 
    66.7 -OBJS += acm_policy.o
    66.8 -OBJS += acm_simple_type_enforcement_hooks.o
    66.9 -OBJS += acm_chinesewall_hooks.o
   66.10 -OBJS += acm_null_hooks.o
   66.11  
   66.12 -default: acm.o
   66.13 +obj-y += acm_core.o 
   66.14 +obj-y += acm_policy.o
   66.15 +obj-y += acm_simple_type_enforcement_hooks.o
   66.16 +obj-y += acm_chinesewall_hooks.o
   66.17 +obj-y += acm_null_hooks.o
   66.18  
   66.19 -acm.o: $(OBJS)
   66.20 -	$(LD) $(LDFLAGS) -r -o acm.o $(OBJS)
   66.21 -
   66.22 -clean:
   66.23 -	rm -f *.o *~ core
   66.24 +include $(BASEDIR)/Post.mk
    67.1 --- a/xen/arch/ia64/Makefile	Tue Mar 21 09:55:44 2006 -0700
    67.2 +++ b/xen/arch/ia64/Makefile	Tue Mar 21 11:19:11 2006 -0700
    67.3 @@ -1,63 +1,23 @@
    67.4  include $(BASEDIR)/Rules.mk
    67.5  
    67.6 -VPATH = xen vmx linux linux-xen
    67.7 -
    67.8 -OBJS = xensetup.o setup.o time.o irq.o process.o smp.o \
    67.9 -	xenmisc.o acpi.o hypercall.o \
   67.10 -	machvec.o dom0_ops.o domain.o hpsimserial.o pcdp.o \
   67.11 -	idle0_task.o pal.o hpsim.o efi.o efi_stub.o ivt.o mm_contig.o \
   67.12 -	xenmem.o sal.o cmdline.o mm_init.o tlb.o smpboot.o \
   67.13 -	extable.o linuxextable.o sort.o xenirq.o xentime.o \
   67.14 -	regionreg.o entry.o unaligned.o privop.o vcpu.o \
   67.15 -	irq_ia64.o irq_lsapic.o vhpt.o xenasm.o hyperprivop.o dom_fw.o \
   67.16 -	sn_console.o # ia64_ksyms.o 
   67.17 -
   67.18 -OBJS += vmx_init.o vmx_virt.o vmx_vcpu.o vmx_process.o vmx_vsa.o vmx_ivt.o\
   67.19 -	vmx_phy_mode.o vmx_utility.o vmx_interrupt.o vmx_entry.o vmmu.o \
   67.20 -	vtlb.o mmio.o vlsapic.o vmx_hypercall.o mm.o vmx_support.o \
   67.21 -	pal_emul.o vmx_irq_ia64.o hvm_vioapic.o
   67.22 -
   67.23 -# lib files from xen/arch/ia64/linux/ (linux/arch/ia64/lib)
   67.24 -OBJS +=	bitop.o clear_page.o flush.o copy_page_mck.o			\
   67.25 -	memset.o strlen.o memcpy_mck.o 					\
   67.26 -	__divsi3.o __udivsi3.o __modsi3.o __umodsi3.o			\
   67.27 -	__divdi3.o __udivdi3.o __moddi3.o __umoddi3.o
   67.28 +subdir-y += xen
   67.29 +subdir-y += vmx
   67.30 +subdir-y += linux
   67.31 +subdir-y += linux-xen
   67.32  
   67.33 -ifeq ($(crash_debug),y)
   67.34 -OBJS += gdbstub.o
   67.35 -endif
   67.36 -
   67.37 -# xen stack unwinder
   67.38 -# unwind_decoder.c is included in unwind.c
   67.39 -OBJS += unwind.o
   67.40 -#unwind.o: CFLAGS += -DUNW_DEBUG=4
   67.41 -
   67.42 -OBJS += process-linux-xen.o
   67.43 -
   67.44 -# perfmon.o
   67.45 -# unwind.o needed for kernel unwinding (rare)
   67.46 +include $(BASEDIR)/Post.mk
   67.47  
   67.48 -OBJS := $(subst $(TARGET_ARCH)/asm-offsets.o,,$(OBJS))
   67.49 -
   67.50 -# remove following line if not privifying in memory
   67.51 -# OBJS += privify.o
   67.52 -
   67.53 -default: $(TARGET)
   67.54 -
   67.55 -$(CURDIR)/arch.o: $(OBJS)
   67.56 -	$(LD) -r -o $@ $(OBJS)
   67.57 -
   67.58 -$(TARGET)-syms: $(ALL_OBJS) head.o xen.lds.s
   67.59 -	$(LD) $(LDFLAGS) -T $(BASEDIR)/arch/$(TARGET_ARCH)/xen.lds.s -N \
   67.60 -		-Map map.out head.o $(ALL_OBJS) -o $@
   67.61 +$(TARGET)-syms: linux-xen/head.o $(ALL_OBJS) xen.lds.s
   67.62 +	$(LD) $(LDFLAGS) -T xen.lds.s -N \
   67.63 +		-Map map.out linux-xen/head.o $(ALL_OBJS) -o $@
   67.64  	$(NM) -n $@ | $(BASEDIR)/tools/symbols > $(BASEDIR)/xen-syms.S
   67.65  	$(MAKE) $(BASEDIR)/xen-syms.o
   67.66 -	$(LD) $(LDFLAGS) -T $(BASEDIR)/arch/$(TARGET_ARCH)/xen.lds.s -N \
   67.67 -		-Map map.out head.o $(ALL_OBJS) $(BASEDIR)/xen-syms.o -o $@
   67.68 +	$(LD) $(LDFLAGS) -T xen.lds.s -N \
   67.69 +		-Map map.out linux-xen/head.o $(ALL_OBJS) $(BASEDIR)/xen-syms.o -o $@
   67.70  	$(NM) -n $@ | $(BASEDIR)/tools/symbols >$(BASEDIR)/xen-syms.S
   67.71  	$(MAKE) $(BASEDIR)/xen-syms.o
   67.72 -	$(LD) $(LDFLAGS) -T $(BASEDIR)/arch/$(TARGET_ARCH)/xen.lds.s -N \
   67.73 -		-Map map.out head.o $(ALL_OBJS) $(BASEDIR)/xen-syms.o -o $@
   67.74 +	$(LD) $(LDFLAGS) -T xen.lds.s -N \
   67.75 +		-Map map.out linux-xen/head.o $(ALL_OBJS) $(BASEDIR)/xen-syms.o -o $@
   67.76  	rm -f $(BASEDIR)/xen-syms.S $(BASEDIR)/xen-syms.o
   67.77  
   67.78  $(TARGET): $(TARGET)-syms
   67.79 @@ -119,31 +79,9 @@ xen.lds.s: xen/xen.lds.S
   67.80  	$(CC) -E $(CPPFLAGS) -P -DXEN -D__ASSEMBLY__ \
   67.81  		-o xen.lds.s xen/xen.lds.S
   67.82  
   67.83 -# variants of divide/modulo
   67.84 -# see files in xen/arch/ia64/linux/lib (linux/arch/ia64/lib)
   67.85 -__divdi3.o: idiv64.S
   67.86 -	$(CC) $(AFLAGS) $(AFLAGS_KERNEL) -c -o $@ $<
   67.87 -__udivdi3.o: idiv64.S
   67.88 -	$(CC) $(AFLAGS) $(AFLAGS_KERNEL) -c -DUNSIGNED -c -o $@ $<
   67.89 -__moddi3.o: idiv64.S
   67.90 -	$(CC) $(AFLAGS) $(AFLAGS_KERNEL) -c -DMODULO -c -o $@ $<
   67.91 -__umoddi3.o: idiv64.S
   67.92 -	$(CC) $(AFLAGS) $(AFLAGS_KERNEL) -c -DMODULO -DUNSIGNED -c -o $@ $<
   67.93 -__divsi3.o: idiv32.S
   67.94 -	$(CC) $(AFLAGS) $(AFLAGS_KERNEL) -c -o $@ $<
   67.95 -__udivsi3.o: idiv32.S
   67.96 -	$(CC) $(AFLAGS) $(AFLAGS_KERNEL) -c -DUNSIGNED -c -o $@ $<
   67.97 -__modsi3.o: idiv32.S
   67.98 -	$(CC) $(AFLAGS) $(AFLAGS_KERNEL) -c -DMODULO -c -o $@ $<
   67.99 -__umodsi3.o: idiv32.S
  67.100 -	$(CC) $(AFLAGS) $(AFLAGS_KERNEL) -c -DMODULO -DUNSIGNED -c -o $@ $<
  67.101 -
  67.102 -
  67.103 -clean:
  67.104 +clean:: FORCE
  67.105  	rm -f *.o *~ core  xen.lds.s $(BASEDIR)/include/asm-ia64/.offsets.h.stamp asm-offsets.s map.out
  67.106  	rm -f asm-xsi-offsets.s $(BASEDIR)/include/asm-ia64/asm-xsi-offsets.h
  67.107 -	rm -f $(BASEDIR)/arch/ia64/vmx/hvm_*.c
  67.108 +	rm -f $(BASEDIR)/System.map
  67.109 +	rm -f vmx/hvm_*.c
  67.110  	rm -rf $(BASEDIR)/include/asm-ia64/hvm
  67.111 -	rm -f linux/lib/*.o
  67.112 -
  67.113 -.PHONY: default clean
    68.1 --- a/xen/arch/ia64/Rules.mk	Tue Mar 21 09:55:44 2006 -0700
    68.2 +++ b/xen/arch/ia64/Rules.mk	Tue Mar 21 11:19:11 2006 -0700
    68.3 @@ -1,6 +1,7 @@
    68.4  ########################################
    68.5  # ia64-specific definitions
    68.6  
    68.7 +HAS_ACPI := y
    68.8  VALIDATE_VT	?= n
    68.9  ifneq ($(COMPILE_ARCH),$(TARGET_ARCH))
   68.10  CROSS_COMPILE ?= /usr/local/sp_env/v2.2.5/i686/bin/ia64-unknown-linux-
    69.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    69.2 +++ b/xen/arch/ia64/linux-xen/Makefile	Tue Mar 21 11:19:11 2006 -0700
    69.3 @@ -0,0 +1,19 @@
    69.4 +include $(BASEDIR)/Rules.mk
    69.5 +
    69.6 +obj-y += efi.o
    69.7 +obj-y += entry.o
    69.8 +obj-y += irq_ia64.o
    69.9 +obj-y += mm_contig.o
   69.10 +obj-y += pal.o
   69.11 +obj-y += process-linux-xen.o
   69.12 +obj-y += sal.o
   69.13 +obj-y += setup.o
   69.14 +obj-y += smpboot.o
   69.15 +obj-y += smp.o
   69.16 +obj-y += sort.o
   69.17 +obj-y += time.o
   69.18 +obj-y += tlb.o
   69.19 +obj-y += unaligned.o
   69.20 +obj-y += unwind.o
   69.21 +
   69.22 +include $(BASEDIR)/Post.mk
    70.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    70.2 +++ b/xen/arch/ia64/linux/Makefile	Tue Mar 21 11:19:11 2006 -0700
    70.3 @@ -0,0 +1,56 @@
    70.4 +include $(BASEDIR)/Rules.mk
    70.5 +
    70.6 +
    70.7 +obj-y += bitop.o
    70.8 +obj-y += clear_page.o
    70.9 +obj-y += cmdline.o
   70.10 +obj-y += copy_page_mck.o
   70.11 +obj-y += efi_stub.o
   70.12 +obj-y += extable.o
   70.13 +obj-y += flush.o
   70.14 +obj-y += hpsim.o
   70.15 +obj-y += ia64_ksyms.o
   70.16 +obj-y += irq_lsapic.o
   70.17 +obj-y += linuxextable.o
   70.18 +obj-y += machvec.o
   70.19 +obj-y += memcpy_mck.o
   70.20 +obj-y += memset.o
   70.21 +obj-y += strlen.o
   70.22 +
   70.23 +obj-y += __divsi3.o
   70.24 +obj-y += __udivsi3.o
   70.25 +obj-y += __modsi3.o
   70.26 +obj-y += __umodsi3.o
   70.27 +obj-y += __divdi3.o
   70.28 +obj-y += __udivdi3.o
   70.29 +obj-y += __moddi3.o
   70.30 +obj-y += __umoddi3.o
   70.31 +
   70.32 +include $(BASEDIR)/Post.mk
   70.33 +
   70.34 +## variants of divide/modulo
   70.35 +## see files in xen/arch/ia64/linux/lib (linux/arch/ia64/lib)
   70.36 +__divdi3.o: idiv64.S
   70.37 +	$(CC) $(AFLAGS) $(AFLAGS_KERNEL) -c -o $@ $<
   70.38 +
   70.39 +__udivdi3.o: idiv64.S
   70.40 +	$(CC) $(AFLAGS) $(AFLAGS_KERNEL) -c -DUNSIGNED -c -o $@ $<
   70.41 +
   70.42 +__moddi3.o: idiv64.S
   70.43 +	$(CC) $(AFLAGS) $(AFLAGS_KERNEL) -c -DMODULO -c -o $@ $<
   70.44 +
   70.45 +__umoddi3.o: idiv64.S
   70.46 +	$(CC) $(AFLAGS) $(AFLAGS_KERNEL) -c -DMODULO -DUNSIGNED -c -o $@ $<
   70.47 +
   70.48 +__divsi3.o: idiv32.S
   70.49 +	$(CC) $(AFLAGS) $(AFLAGS_KERNEL) -c -o $@ $<
   70.50 +
   70.51 +__udivsi3.o: idiv32.S
   70.52 +	$(CC) $(AFLAGS) $(AFLAGS_KERNEL) -c -DUNSIGNED -c -o $@ $<
   70.53 +
   70.54 +__modsi3.o: idiv32.S
   70.55 +	$(CC) $(AFLAGS) $(AFLAGS_KERNEL) -c -DMODULO -c -o $@ $<
   70.56 +
   70.57 +__umodsi3.o: idiv32.S
   70.58 +	$(CC) $(AFLAGS) $(AFLAGS_KERNEL) -c -DMODULO -DUNSIGNED -c -o $@ $<
   70.59 +
    71.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    71.2 +++ b/xen/arch/ia64/vmx/Makefile	Tue Mar 21 11:19:11 2006 -0700
    71.3 @@ -0,0 +1,24 @@
    71.4 +include $(BASEDIR)/Rules.mk
    71.5 +
    71.6 +obj-y += hvm_vioapic.o
    71.7 +obj-y += mm.o
    71.8 +obj-y += mmio.o
    71.9 +obj-y += pal_emul.o
   71.10 +obj-y += vlsapic.o
   71.11 +obj-y += vmmu.o
   71.12 +obj-y += vmx_entry.o
   71.13 +obj-y += vmx_hypercall.o
   71.14 +obj-y += vmx_init.o
   71.15 +obj-y += vmx_interrupt.o
   71.16 +obj-y += vmx_irq_ia64.o
   71.17 +obj-y += vmx_ivt.o
   71.18 +obj-y += vmx_phy_mode.o
   71.19 +obj-y += vmx_process.o
   71.20 +obj-y += vmx_support.o
   71.21 +obj-y += vmx_utility.o
   71.22 +obj-y += vmx_vcpu.o
   71.23 +obj-y += vmx_virt.o
   71.24 +obj-y += vmx_vsa.o
   71.25 +obj-y += vtlb.o
   71.26 +
   71.27 +include $(BASEDIR)/Post.mk
    72.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    72.2 +++ b/xen/arch/ia64/xen/Makefile	Tue Mar 21 11:19:11 2006 -0700
    72.3 @@ -0,0 +1,30 @@
    72.4 +include $(BASEDIR)/Rules.mk
    72.5 +
    72.6 +obj-y += acpi.o
    72.7 +obj-y += dom0_ops.o
    72.8 +obj-y += domain.o
    72.9 +obj-y += dom_fw.o
   72.10 +obj-y += hpsimserial.o
   72.11 +obj-y += hypercall.o
   72.12 +obj-y += hyperprivop.o
   72.13 +obj-y += idle0_task.o
   72.14 +obj-y += irq.o
   72.15 +obj-y += ivt.o
   72.16 +obj-y += mm_init.o
   72.17 +obj-y += pcdp.o
   72.18 +obj-y += privop.o
   72.19 +obj-y += process.o
   72.20 +obj-y += regionreg.o
   72.21 +obj-y += sn_console.o
   72.22 +obj-y += vcpu.o
   72.23 +obj-y += vhpt.o
   72.24 +obj-y += xenasm.o
   72.25 +obj-y += xenirq.o
   72.26 +obj-y += xenmem.o
   72.27 +obj-y += xenmisc.o
   72.28 +obj-y += xensetup.o
   72.29 +obj-y += xentime.o
   72.30 +
   72.31 +obj-$(crash_debug) += gdbstub.o
   72.32 +
   72.33 +include $(BASEDIR)/Post.mk
    73.1 --- a/xen/arch/x86/Makefile	Tue Mar 21 09:55:44 2006 -0700
    73.2 +++ b/xen/arch/x86/Makefile	Tue Mar 21 11:19:11 2006 -0700
    73.3 @@ -1,58 +1,60 @@
    73.4 -
    73.5  include $(BASEDIR)/Rules.mk
    73.6  
    73.7 -OBJS += $(patsubst %.S,%.o,$(wildcard $(TARGET_SUBARCH)/*.S))
    73.8 -OBJS += $(patsubst %.c,%.o,$(wildcard $(TARGET_SUBARCH)/*.c))
    73.9 -OBJS += $(patsubst %.c,%.o,$(wildcard acpi/*.c))
   73.10 -OBJS += $(patsubst %.c,%.o,$(wildcard genapic/*.c))
   73.11 -OBJS += $(patsubst %.c,%.o,$(wildcard cpu/*.c))
   73.12 -OBJS += $(patsubst %.c,%.o,$(wildcard cpu/mcheck/*.c))
   73.13 -OBJS += $(patsubst %.c,%.o,$(wildcard cpu/mtrr/*.c))
   73.14 -OBJS += $(patsubst %.c,%.o,$(wildcard hvm/*.c))
   73.15 -OBJS += $(patsubst %.c,%.o,$(wildcard hvm/vmx/*.c))
   73.16 -OBJS += $(patsubst %.S,%.o,$(wildcard hvm/vmx/$(TARGET_SUBARCH)/*.S))
   73.17 -OBJS += $(patsubst %.c,%.o,$(wildcard hvm/svm/*.c))
   73.18 -OBJS += $(patsubst %.S,%.o,$(wildcard hvm/svm/$(TARGET_SUBARCH)/*.S))
   73.19 +subdir-y += acpi
   73.20 +subdir-y += cpu
   73.21 +subdir-y += genapic
   73.22 +subdir-y += hvm
   73.23 +
   73.24 +subdir-$(x86_32) += x86_32
   73.25 +subdir-$(x86_64) += x86_64
   73.26  
   73.27 -ifeq ($(TARGET_SUBARCH),x86_64) 
   73.28 -OBJS := $(subst cpu/centaur.o,,$(OBJS))
   73.29 -OBJS := $(subst cpu/cyrix.o,,$(OBJS))
   73.30 -OBJS := $(subst cpu/rise.o,,$(OBJS))
   73.31 -OBJS := $(subst cpu/transmeta.o,,$(OBJS))
   73.32 +obj-y += apic.o
   73.33 +obj-y += audit.o
   73.34 +obj-y += bitops.o
   73.35 +obj-y += delay.o
   73.36 +obj-y += dmi_scan.o
   73.37 +obj-y += dom0_ops.o
   73.38 +obj-y += domain.o
   73.39 +obj-y += domain_build.o
   73.40 +obj-y += e820.o
   73.41 +obj-y += extable.o
   73.42 +obj-y += flushtlb.o
   73.43 +obj-y += i387.o
   73.44 +obj-y += i8259.o
   73.45 +obj-y += io_apic.o
   73.46 +obj-y += irq.o
   73.47 +obj-y += microcode.o
   73.48 +obj-y += mm.o
   73.49 +obj-y += mpparse.o
   73.50 +obj-y += nmi.o
   73.51 +obj-y += physdev.o
   73.52 +obj-y += rwlock.o
   73.53 +obj-y += setup.o
   73.54 +obj-y += smp.o
   73.55 +obj-y += smpboot.o
   73.56 +obj-y += string.o
   73.57 +obj-y += time.o
   73.58 +obj-y += trampoline.o
   73.59 +obj-y += traps.o
   73.60 +obj-y += usercopy.o
   73.61 +obj-y += x86_emulate.o
   73.62 +
   73.63 +ifneq ($(pae),n)
   73.64 +obj-$(x86_32) += shadow.o shadow_public.o shadow_guest32.o
   73.65 +else
   73.66 +obj-$(x86_32) += shadow32.o
   73.67  endif
   73.68  
   73.69 -OBJS := $(patsubst shadow%.o,,$(OBJS))	# drop all
   73.70 -ifeq ($(TARGET_SUBARCH),x86_64) 
   73.71 - OBJS += shadow.o shadow_public.o shadow_guest32.o shadow_guest32pae.o	# x86_64: new code
   73.72 -endif
   73.73 -ifeq ($(TARGET_SUBARCH),x86_32) 
   73.74 - ifneq ($(pae),n)
   73.75 -  OBJS += shadow.o shadow_public.o shadow_guest32.o	# x86_32p: new code
   73.76 - else
   73.77 -  OBJS += shadow32.o			# x86_32: old code
   73.78 - endif
   73.79 -endif
   73.80 +obj-$(x86_64) += shadow.o shadow_public.o shadow_guest32.o shadow_guest32pae.o
   73.81  
   73.82 -ifneq ($(supervisor_mode_kernel),y)
   73.83 -OBJS := $(subst x86_32/supervisor_mode_kernel.o,,$(OBJS))
   73.84 -endif
   73.85 +obj-$(crash_debug) += gdbstub.o
   73.86  
   73.87 -OBJS := $(subst $(TARGET_SUBARCH)/asm-offsets.o,,$(OBJS))
   73.88 -OBJS := $(subst $(TARGET_SUBARCH)/xen.lds.o,,$(OBJS))
   73.89 -
   73.90 -ifneq ($(crash_debug),y)
   73.91 -OBJS := $(patsubst gdbstub%.o,,$(OBJS))
   73.92 -endif
   73.93 -
   73.94 -default: $(TARGET)
   73.95 +include $(BASEDIR)/Post.mk
   73.96  
   73.97  $(TARGET): $(TARGET)-syms boot/mkelf32
   73.98  	./boot/mkelf32 $(TARGET)-syms $(TARGET) 0x100000 \
   73.99  	`$(NM) $(TARGET)-syms | sort | tail -n 1 | sed -e 's/^\([^ ]*\).*/0x\1/'`
  73.100  
  73.101 -$(CURDIR)/arch.o: $(OBJS)
  73.102 -	$(LD) $(LDFLAGS) -r -o $@ $(OBJS)
  73.103 -
  73.104  $(TARGET)-syms: boot/$(TARGET_SUBARCH).o $(ALL_OBJS) xen.lds
  73.105  	$(LD) $(LDFLAGS) -T xen.lds -N \
  73.106  	    boot/$(TARGET_SUBARCH).o $(ALL_OBJS) -o $@
  73.107 @@ -77,21 +79,5 @@ boot/mkelf32: boot/mkelf32.c
  73.108  
  73.109  shadow_guest32.o: shadow.c
  73.110  
  73.111 -clean:
  73.112 -	rm -f *.o *.s *~ core boot/*.o boot/*~ boot/core boot/mkelf32
  73.113 -	rm -f x86_32/*.o x86_32/*~ x86_32/core
  73.114 -	rm -f x86_64/*.o x86_64/*~ x86_64/core
  73.115 -	rm -f mtrr/*.o mtrr/*~ mtrr/core
  73.116 -	rm -f acpi/*.o acpi/*~ acpi/core
  73.117 -	rm -f genapic/*.o genapic/*~ genapic/core
  73.118 -	rm -f cpu/*.o cpu/*~ cpu/core
  73.119 -	rm -f hvm/*.o hvm/*~ hvm/core
  73.120 -	rm -f hvm/vmx/*.o hvm/vmx/*~ hvm/vmx/core
  73.121 -	rm -f hvm/vmx/x86_32/*.o hvm/vmx/x86_32/*~ hvm/vmx/x86_32/core
  73.122 -	rm -f hvm/vmx/x86_64/*.o hvm/vmx/x86_64/*~ hvm/vmx/x86_64/core
  73.123 -	rm -f hvm/svm/*.o hvm/svm/*~ hvm/svm/core
  73.124 -	rm -f hvm/svm/x86_32/*.o hvm/svm/x86_32/*~ hvm/svm/x86_32/core
  73.125 -	rm -f hvm/svm/x86_64/*.o hvm/svm/x86_64/*~ hvm/svm/x86_64/core
  73.126 -	rm -f xen.lds
  73.127 -
  73.128 -.PHONY: default clean
  73.129 +clean:: FORCE
  73.130 +	rm -f asm-offsets.s xen.lds boot/*.o boot/*~ boot/core boot/mkelf32
    74.1 --- a/xen/arch/x86/Rules.mk	Tue Mar 21 09:55:44 2006 -0700
    74.2 +++ b/xen/arch/x86/Rules.mk	Tue Mar 21 11:19:11 2006 -0700
    74.3 @@ -1,6 +1,8 @@
    74.4  ########################################
    74.5  # x86-specific definitions
    74.6  
    74.7 +HAS_ACPI := y
    74.8 +
    74.9  #
   74.10  # If you change any of these configuration options then you must
   74.11  # 'make clean' before rebuilding.
   74.12 @@ -31,13 +33,17 @@ CFLAGS  += -DCONFIG_X86_SUPERVISOR_MODE_
   74.13  endif
   74.14  
   74.15  ifeq ($(XEN_TARGET_ARCH),x86_32)
   74.16 -LDFLAGS += -m elf_i386 
   74.17 +LDFLAGS += -m elf_i386
   74.18 +x86_32 := y
   74.19 +x86_64 := n
   74.20  endif
   74.21  
   74.22  ifeq ($(TARGET_SUBARCH),x86_64)
   74.23  CFLAGS  += -mno-red-zone -fpic -fno-reorder-blocks
   74.24  CFLAGS  += -fno-asynchronous-unwind-tables
   74.25  LDFLAGS += -m elf_x86_64
   74.26 +x86_32 := n
   74.27 +x86_64 := y
   74.28  endif
   74.29  
   74.30  # Test for at least GCC v3.2.x.
    75.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    75.2 +++ b/xen/arch/x86/acpi/Makefile	Tue Mar 21 11:19:11 2006 -0700
    75.3 @@ -0,0 +1,5 @@
    75.4 +include $(BASEDIR)/Rules.mk
    75.5 +
    75.6 +obj-y += boot.o
    75.7 +
    75.8 +include $(BASEDIR)/Post.mk
    76.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    76.2 +++ b/xen/arch/x86/cpu/Makefile	Tue Mar 21 11:19:11 2006 -0700
    76.3 @@ -0,0 +1,16 @@
    76.4 +include $(BASEDIR)/Rules.mk
    76.5 +
    76.6 +subdir-y += mcheck
    76.7 +subdir-y += mtrr
    76.8 +
    76.9 +obj-y += amd.o
   76.10 +obj-y += common.o
   76.11 +obj-y += intel.o
   76.12 +obj-y += intel_cacheinfo.o
   76.13 +
   76.14 +obj-$(x86_32) += centaur.o
   76.15 +obj-$(x86_32) += cyrix.o
   76.16 +obj-$(x86_32) += rise.o
   76.17 +obj-$(x86_32) += transmeta.o
   76.18 +
   76.19 +include $(BASEDIR)/Post.mk
    77.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    77.2 +++ b/xen/arch/x86/cpu/mcheck/Makefile	Tue Mar 21 11:19:11 2006 -0700
    77.3 @@ -0,0 +1,11 @@
    77.4 +include $(BASEDIR)/Rules.mk
    77.5 +
    77.6 +obj-y += k7.o
    77.7 +obj-y += mce.o
    77.8 +obj-y += non-fatal.o
    77.9 +obj-y += p4.o
   77.10 +obj-y += p5.o
   77.11 +obj-y += p6.o
   77.12 +obj-y += winchip.o
   77.13 +
   77.14 +include $(BASEDIR)/Post.mk
    78.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    78.2 +++ b/xen/arch/x86/cpu/mtrr/Makefile	Tue Mar 21 11:19:11 2006 -0700
    78.3 @@ -0,0 +1,10 @@
    78.4 +include $(BASEDIR)/Rules.mk
    78.5 +
    78.6 +obj-y += amd.o
    78.7 +obj-y += centaur.o
    78.8 +obj-y += cyrix.o
    78.9 +obj-y += generic.o
   78.10 +obj-y += main.o
   78.11 +obj-y += state.o
   78.12 +
   78.13 +include $(BASEDIR)/Post.mk
    79.1 --- a/xen/arch/x86/domain.c	Tue Mar 21 09:55:44 2006 -0700
    79.2 +++ b/xen/arch/x86/domain.c	Tue Mar 21 11:19:11 2006 -0700
    79.3 @@ -51,6 +51,9 @@ struct percpu_ctxt {
    79.4  } __cacheline_aligned;
    79.5  static struct percpu_ctxt percpu_ctxt[NR_CPUS];
    79.6  
    79.7 +static void paravirt_ctxt_switch_from(struct vcpu *v);
    79.8 +static void paravirt_ctxt_switch_to(struct vcpu *v);
    79.9 +
   79.10  static void continue_idle_domain(struct vcpu *v)
   79.11  {
   79.12      reset_stack_and_jump(idle_loop);
   79.13 @@ -226,6 +229,9 @@ struct vcpu *alloc_vcpu_struct(struct do
   79.14          v->arch.schedule_tail = continue_nonidle_domain;
   79.15      }
   79.16  
   79.17 +    v->arch.ctxt_switch_from = paravirt_ctxt_switch_from;
   79.18 +    v->arch.ctxt_switch_to   = paravirt_ctxt_switch_to;
   79.19 +
   79.20      v->arch.perdomain_ptes =
   79.21          d->arch.mm_perdomain_pt + (vcpu_id << GDT_LDT_VCPU_SHIFT);
   79.22  
   79.23 @@ -685,21 +691,32 @@ static void save_segments(struct vcpu *v
   79.24      percpu_ctxt[smp_processor_id()].dirty_segment_mask = dirty_segment_mask;
   79.25  }
   79.26  
   79.27 -#define switch_kernel_stack(_n,_c) ((void)0)
   79.28 +#define switch_kernel_stack(v) ((void)0)
   79.29  
   79.30  #elif defined(__i386__)
   79.31  
   79.32  #define load_segments(n) ((void)0)
   79.33  #define save_segments(p) ((void)0)
   79.34  
   79.35 -static inline void switch_kernel_stack(struct vcpu *n, unsigned int cpu)
   79.36 +static inline void switch_kernel_stack(struct vcpu *v)
   79.37  {
   79.38 -    struct tss_struct *tss = &init_tss[cpu];
   79.39 -    tss->esp1 = n->arch.guest_context.kernel_sp;
   79.40 -    tss->ss1  = n->arch.guest_context.kernel_ss;
   79.41 +    struct tss_struct *tss = &init_tss[smp_processor_id()];
   79.42 +    tss->esp1 = v->arch.guest_context.kernel_sp;
   79.43 +    tss->ss1  = v->arch.guest_context.kernel_ss;
   79.44  }
   79.45  
   79.46 -#endif
   79.47 +#endif /* __i386__ */
   79.48 +
   79.49 +static void paravirt_ctxt_switch_from(struct vcpu *v)
   79.50 +{
   79.51 +    save_segments(v);
   79.52 +}
   79.53 +
   79.54 +static void paravirt_ctxt_switch_to(struct vcpu *v)
   79.55 +{
   79.56 +    set_int80_direct_trap(v);
   79.57 +    switch_kernel_stack(v);
   79.58 +}
   79.59  
   79.60  #define loaddebug(_v,_reg) \
   79.61      __asm__ __volatile__ ("mov %0,%%db" #_reg : : "r" ((_v)->debugreg[_reg]))
   79.62 @@ -720,15 +737,7 @@ static void __context_switch(void)
   79.63                 stack_regs,
   79.64                 CTXT_SWITCH_STACK_BYTES);
   79.65          unlazy_fpu(p);
   79.66 -        if ( !hvm_guest(p) )
   79.67 -        {
   79.68 -            save_segments(p);
   79.69 -        }
   79.70 -        else
   79.71 -        {
   79.72 -            hvm_save_segments(p);
   79.73 -            hvm_load_msrs();
   79.74 -        }
   79.75 +        p->arch.ctxt_switch_from(p);
   79.76      }
   79.77  
   79.78      if ( !is_idle_vcpu(n) )
   79.79 @@ -749,15 +758,7 @@ static void __context_switch(void)
   79.80              loaddebug(&n->arch.guest_context, 7);
   79.81          }
   79.82  
   79.83 -        if ( !hvm_guest(n) )
   79.84 -        {
   79.85 -            set_int80_direct_trap(n);
   79.86 -            switch_kernel_stack(n, cpu);
   79.87 -        }
   79.88 -        else
   79.89 -        {
   79.90 -            hvm_restore_msrs(n);
   79.91 -        }
   79.92 +        n->arch.ctxt_switch_to(n);
   79.93      }
   79.94  
   79.95      if ( p->domain != n->domain )
    80.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    80.2 +++ b/xen/arch/x86/genapic/Makefile	Tue Mar 21 11:19:11 2006 -0700
    80.3 @@ -0,0 +1,10 @@
    80.4 +include $(BASEDIR)/Rules.mk
    80.5 +
    80.6 +obj-y += bigsmp.o
    80.7 +obj-y += default.o
    80.8 +obj-y += es7000.o
    80.9 +obj-y += es7000plat.o
   80.10 +obj-y += probe.o
   80.11 +obj-y += summit.o
   80.12 +
   80.13 +include $(BASEDIR)/Post.mk
    81.1 --- a/xen/arch/x86/genapic/default.c	Tue Mar 21 09:55:44 2006 -0700
    81.2 +++ b/xen/arch/x86/genapic/default.c	Tue Mar 21 11:19:11 2006 -0700
    81.3 @@ -18,6 +18,15 @@
    81.4  #include <asm/mach-default/mach_ipi.h>
    81.5  #include <asm/mach-default/mach_mpparse.h>
    81.6  
    81.7 +#ifdef CONFIG_HOTPLUG_CPU
    81.8 +#define DEFAULT_SEND_IPI	(1)
    81.9 +#else
   81.10 +#define DEFAULT_SEND_IPI	(0)
   81.11 +#endif
   81.12 +
   81.13 +int no_broadcast = DEFAULT_SEND_IPI;
   81.14 +integer_param("no_ipi_broadcast", no_broadcast);
   81.15 +
   81.16  /* should be called last. */
   81.17  static __init int probe_default(void)
   81.18  { 
   81.19 @@ -25,3 +34,12 @@ static __init int probe_default(void)
   81.20  } 
   81.21  
   81.22  struct genapic apic_default = APIC_INIT("default", probe_default); 
   81.23 +
   81.24 +static int __init print_ipi_mode(void)
   81.25 +{
   81.26 +	if (genapic == &apic_default)
   81.27 +		printk("Using IPI %sShortcut mode\n",
   81.28 +		       no_broadcast ? "No-" : "");
   81.29 +	return 0;
   81.30 +}
   81.31 +__initcall(print_ipi_mode);
    82.1 --- a/xen/arch/x86/genapic/es7000.h	Tue Mar 21 09:55:44 2006 -0700
    82.2 +++ b/xen/arch/x86/genapic/es7000.h	Tue Mar 21 11:19:11 2006 -0700
    82.3 @@ -24,6 +24,15 @@
    82.4   * http://www.unisys.com
    82.5   */
    82.6  
    82.7 +/*
    82.8 + * ES7000 chipsets
    82.9 + */
   82.10 +
   82.11 +#define NON_UNISYS		0
   82.12 +#define ES7000_CLASSIC		1
   82.13 +#define ES7000_ZORRO		2
   82.14 +
   82.15 +
   82.16  #define	MIP_REG			1
   82.17  #define	MIP_PSAI_REG		4
   82.18  
   82.19 @@ -104,7 +113,8 @@ struct mip_reg {
   82.20  #define	MIP_SW_APIC		0x1020b
   82.21  #define	MIP_FUNC(VALUE) 	(VALUE & 0xff)
   82.22  
   82.23 -extern int parse_unisys_oem (char *oemptr, int oem_entries);
   82.24 -extern int find_unisys_acpi_oem_table(unsigned long *oem_addr, int *length);
   82.25 +extern int parse_unisys_oem (char *oemptr);
   82.26 +extern int find_unisys_acpi_oem_table(unsigned long *oem_addr);
   82.27 +extern void setup_unisys(void);
   82.28  extern int es7000_start_cpu(int cpu, unsigned long eip);
   82.29  extern void es7000_sw_apic(void);
    83.1 --- a/xen/arch/x86/genapic/es7000plat.c	Tue Mar 21 09:55:44 2006 -0700
    83.2 +++ b/xen/arch/x86/genapic/es7000plat.c	Tue Mar 21 11:19:11 2006 -0700
    83.3 @@ -49,7 +49,7 @@ struct mip_reg		*host_reg;
    83.4  int 			mip_port;
    83.5  unsigned long		mip_addr, host_addr;
    83.6  
    83.7 -#if defined(CONFIG_X86_IO_APIC) && (defined(CONFIG_ACPI_INTERPRETER) || defined(CONFIG_ACPI_BOOT))
    83.8 +#if defined(CONFIG_X86_IO_APIC) && defined(CONFIG_ACPI)
    83.9  
   83.10  /*
   83.11   * GSI override for ES7000 platforms.
   83.12 @@ -60,6 +60,9 @@ static unsigned int base;
   83.13  static int
   83.14  es7000_rename_gsi(int ioapic, int gsi)
   83.15  {
   83.16 +	if (es7000_plat == ES7000_ZORRO)
   83.17 +		return gsi;
   83.18 +
   83.19  	if (!base) {
   83.20  		int i;
   83.21  		for (i = 0; i < nr_ioapics; i++)
   83.22 @@ -71,14 +74,31 @@ es7000_rename_gsi(int ioapic, int gsi)
   83.23  	return gsi;
   83.24  }
   83.25  
   83.26 -#endif // (CONFIG_X86_IO_APIC) && (CONFIG_ACPI_INTERPRETER || CONFIG_ACPI_BOOT)
   83.27 +#endif	/* (CONFIG_X86_IO_APIC) && (CONFIG_ACPI) */
   83.28 +
   83.29 +void __init
   83.30 +setup_unisys(void)
   83.31 +{
   83.32 +	/*
   83.33 +	 * Determine the generation of the ES7000 currently running.
   83.34 +	 *
   83.35 +	 * es7000_plat = 1 if the machine is a 5xx ES7000 box
   83.36 +	 * es7000_plat = 2 if the machine is a x86_64 ES7000 box
   83.37 +	 *
   83.38 +	 */
   83.39 +	if (!(boot_cpu_data.x86 <= 15 && boot_cpu_data.x86_model <= 2))
   83.40 +		es7000_plat = ES7000_ZORRO;
   83.41 +	else
   83.42 +		es7000_plat = ES7000_CLASSIC;
   83.43 +	ioapic_renumber_irq = es7000_rename_gsi;
   83.44 +}
   83.45  
   83.46  /*
   83.47   * Parse the OEM Table
   83.48   */
   83.49  
   83.50  int __init
   83.51 -parse_unisys_oem (char *oemptr, int oem_entries)
   83.52 +parse_unisys_oem (char *oemptr)
   83.53  {
   83.54  	int                     i;
   83.55  	int 			success = 0;
   83.56 @@ -93,7 +113,7 @@ parse_unisys_oem (char *oemptr, int oem_
   83.57  
   83.58  	tp += 8;
   83.59  
   83.60 -	for (i=0; i <= oem_entries; i++) {
   83.61 +	for (i=0; i <= 6; i++) {
   83.62  		type = *tp++;
   83.63  		size = *tp++;
   83.64  		tp -= 2;
   83.65 @@ -128,40 +148,24 @@ parse_unisys_oem (char *oemptr, int oem_
   83.66  		default:
   83.67  			break;
   83.68  		}
   83.69 -		if (i == 6) break;
   83.70  		tp += size;
   83.71  	}
   83.72  
   83.73  	if (success < 2) {
   83.74 -		es7000_plat = 0;
   83.75 -	} else {
   83.76 -		printk("\nEnabling ES7000 specific features...\n");
   83.77 -		/*
   83.78 -		 * Determine the generation of the ES7000 currently running.
   83.79 -		 *
   83.80 -		 * es7000_plat = 0 if the machine is NOT a Unisys ES7000 box
   83.81 -		 * es7000_plat = 1 if the machine is a 5xx ES7000 box
   83.82 -		 * es7000_plat = 2 if the machine is a x86_64 ES7000 box
   83.83 -		 *
   83.84 -		 */
   83.85 -		if (!(boot_cpu_data.x86 <= 15 && boot_cpu_data.x86_model <= 2))
   83.86 -			es7000_plat = 2;
   83.87 -		else
   83.88 -			es7000_plat = 1;
   83.89 -
   83.90 -		ioapic_renumber_irq = es7000_rename_gsi;
   83.91 -	}
   83.92 +		es7000_plat = NON_UNISYS;
   83.93 +	} else
   83.94 +		setup_unisys();
   83.95  	return es7000_plat;
   83.96  }
   83.97  
   83.98  int __init
   83.99 -find_unisys_acpi_oem_table(unsigned long *oem_addr, int *length)
  83.100 +find_unisys_acpi_oem_table(unsigned long *oem_addr)
  83.101  {
  83.102  	struct acpi_table_rsdp		*rsdp = NULL;
  83.103  	unsigned long			rsdp_phys = 0;
  83.104  	struct acpi_table_header 	*header = NULL;
  83.105  	int				i;
  83.106 -	struct acpi_table_sdt		sdt = { 0 };
  83.107 +	struct acpi_table_sdt		sdt = { 0 }; /* initialise sdt.count */
  83.108  
  83.109  	rsdp_phys = acpi_find_rsdp();
  83.110  	rsdp = __va(rsdp_phys);
  83.111 @@ -199,13 +203,11 @@ find_unisys_acpi_oem_table(unsigned long
  83.112  				acpi_table_print(header, sdt.entry[i].pa);
  83.113  				t = (struct oem_table *) __acpi_map_table(sdt.entry[i].pa, header->length);
  83.114  				addr = (void *) __acpi_map_table(t->OEMTableAddr, t->OEMTableSize);
  83.115 -				*length = header->length;
  83.116  				*oem_addr = (unsigned long) addr;
  83.117  				return 0;
  83.118  			}
  83.119  		}
  83.120  	}
  83.121 -	Dprintk("ES7000: did not find Unisys ACPI OEM table!\n");
  83.122  	return -1;
  83.123  }
  83.124  
  83.125 @@ -298,7 +300,7 @@ es7000_stop_cpu(int cpu)
  83.126  void __init
  83.127  es7000_sw_apic()
  83.128  {
  83.129 -	if (es7000_plat == 1) {
  83.130 +	if (es7000_plat) {
  83.131  		int mip_status;
  83.132  		struct mip_reg es7000_mip_reg;
  83.133  
    84.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    84.2 +++ b/xen/arch/x86/hvm/Makefile	Tue Mar 21 11:19:11 2006 -0700
    84.3 @@ -0,0 +1,14 @@
    84.4 +include $(BASEDIR)/Rules.mk
    84.5 +
    84.6 +subdir-y += svm
    84.7 +subdir-y += vmx
    84.8 +
    84.9 +obj-y += hvm.o
   84.10 +obj-y += i8259.o
   84.11 +obj-y += intercept.o
   84.12 +obj-y += io.o
   84.13 +obj-y += platform.o
   84.14 +obj-y += vioapic.o
   84.15 +obj-y += vlapic.o
   84.16 +
   84.17 +include $(BASEDIR)/Post.mk
    85.1 --- a/xen/arch/x86/hvm/intercept.c	Tue Mar 21 09:55:44 2006 -0700
    85.2 +++ b/xen/arch/x86/hvm/intercept.c	Tue Mar 21 11:19:11 2006 -0700
    85.3 @@ -338,10 +338,10 @@ void hlt_timer_fn(void *data)
    85.4  
    85.5  static __inline__ void missed_ticks(struct hvm_virpit*vpit)
    85.6  {
    85.7 -    int        missed_ticks;
    85.8 +    int missed_ticks;
    85.9  
   85.10      missed_ticks = (NOW() - vpit->scheduled)/(s_time_t) vpit->period;
   85.11 -    if ( missed_ticks > 0 ) {
   85.12 +    if ( missed_ticks++ >= 0 ) {
   85.13          vpit->pending_intr_nr += missed_ticks;
   85.14          vpit->scheduled += missed_ticks * vpit->period;
   85.15      }
   85.16 @@ -355,22 +355,16 @@ static void pit_timer_fn(void *data)
   85.17  
   85.18      /* pick up missed timer tick */
   85.19      missed_ticks(vpit);
   85.20 -
   85.21 -    vpit->pending_intr_nr++;
   85.22      if ( test_bit(_VCPUF_running, &v->vcpu_flags) ) {
   85.23 -        vpit->scheduled += vpit->period;
   85.24          set_timer(&vpit->pit_timer, vpit->scheduled);
   85.25      }
   85.26  }
   85.27  
   85.28 +/* pick up missed timer ticks at deactive time */
   85.29  void pickup_deactive_ticks(struct hvm_virpit *vpit)
   85.30  {
   85.31 -
   85.32      if ( !active_timer(&(vpit->pit_timer)) ) {
   85.33 -        /* pick up missed timer tick */
   85.34          missed_ticks(vpit);
   85.35 -    
   85.36 -        vpit->scheduled += vpit->period;
   85.37          set_timer(&vpit->pit_timer, vpit->scheduled);
   85.38      }
   85.39  }
    86.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    86.2 +++ b/xen/arch/x86/hvm/svm/Makefile	Tue Mar 21 11:19:11 2006 -0700
    86.3 @@ -0,0 +1,12 @@
    86.4 +include $(BASEDIR)/Rules.mk
    86.5 +
    86.6 +subdir-$(x86_32) += x86_32
    86.7 +subdir-$(x86_64) += x86_64
    86.8 +
    86.9 +obj-y += emulate.o
   86.10 +obj-y += instrlen.o
   86.11 +obj-y += intr.o
   86.12 +obj-y += svm.o
   86.13 +obj-y += vmcb.o
   86.14 +
   86.15 +include $(BASEDIR)/Post.mk
    87.1 --- a/xen/arch/x86/hvm/svm/svm.c	Tue Mar 21 09:55:44 2006 -0700
    87.2 +++ b/xen/arch/x86/hvm/svm/svm.c	Tue Mar 21 11:19:11 2006 -0700
    87.3 @@ -200,7 +200,8 @@ int svm_initialize_guest_resources(struc
    87.4      return 1;
    87.5  }
    87.6  
    87.7 -void svm_store_cpu_guest_regs(struct vcpu *v, struct cpu_user_regs *regs)
    87.8 +static void svm_store_cpu_guest_regs(
    87.9 +    struct vcpu *v, struct cpu_user_regs *regs)
   87.10  {
   87.11      struct vmcb_struct *vmcb = v->arch.hvm_svm.vmcb;
   87.12  
   87.13 @@ -227,24 +228,12 @@ void svm_store_cpu_guest_regs(struct vcp
   87.14  #endif
   87.15  }
   87.16  
   87.17 -void svm_load_cpu_guest_regs(struct vcpu *v, struct cpu_user_regs *regs)
   87.18 +static void svm_load_cpu_guest_regs(
   87.19 +    struct vcpu *v, struct cpu_user_regs *regs)
   87.20  {
   87.21      svm_load_cpu_user_regs(v, regs);
   87.22  }
   87.23  
   87.24 -#ifdef __x86_64__
   87.25 -
   87.26 -void svm_save_segments(struct vcpu *v)
   87.27 -{
   87.28 -}
   87.29 -void svm_load_msrs(void)
   87.30 -{
   87.31 -}
   87.32 -void svm_restore_msrs(struct vcpu *v)
   87.33 -{
   87.34 -}
   87.35 -#endif
   87.36 -
   87.37  #define IS_CANO_ADDRESS(add) 1
   87.38  
   87.39  static inline int long_mode_do_msr_read(struct cpu_user_regs *regs)
   87.40 @@ -459,12 +448,6 @@ int start_svm(void)
   87.41      hvm_funcs.store_cpu_guest_regs = svm_store_cpu_guest_regs;
   87.42      hvm_funcs.load_cpu_guest_regs = svm_load_cpu_guest_regs;
   87.43  
   87.44 -#ifdef __x86_64__
   87.45 -    hvm_funcs.save_segments = svm_save_segments;
   87.46 -    hvm_funcs.load_msrs = svm_load_msrs;
   87.47 -    hvm_funcs.restore_msrs = svm_restore_msrs;
   87.48 -#endif
   87.49 -
   87.50      hvm_funcs.store_cpu_guest_ctrl_regs = svm_store_cpu_guest_ctrl_regs;
   87.51      hvm_funcs.modify_guest_state = svm_modify_guest_state;
   87.52  
   87.53 @@ -687,9 +670,19 @@ static void arch_svm_do_launch(struct vc
   87.54      reset_stack_and_jump(svm_asm_do_launch);
   87.55  }
   87.56  
   87.57 +static void svm_ctxt_switch_from(struct vcpu *v)
   87.58 +{
   87.59 +}
   87.60 +
   87.61 +static void svm_ctxt_switch_to(struct vcpu *v)
   87.62 +{
   87.63 +}
   87.64 +
   87.65  void svm_final_setup_guest(struct vcpu *v)
   87.66  {
   87.67 -    v->arch.schedule_tail = arch_svm_do_launch;
   87.68 +    v->arch.schedule_tail    = arch_svm_do_launch;
   87.69 +    v->arch.ctxt_switch_from = svm_ctxt_switch_from;
   87.70 +    v->arch.ctxt_switch_to   = svm_ctxt_switch_to;
   87.71  
   87.72      if (v == v->domain->vcpu[0]) 
   87.73      {
    88.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    88.2 +++ b/xen/arch/x86/hvm/svm/x86_32/Makefile	Tue Mar 21 11:19:11 2006 -0700
    88.3 @@ -0,0 +1,5 @@
    88.4 +include $(BASEDIR)/Rules.mk
    88.5 +
    88.6 +obj-y += exits.o
    88.7 +
    88.8 +include $(BASEDIR)/Post.mk
    89.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    89.2 +++ b/xen/arch/x86/hvm/svm/x86_64/Makefile	Tue Mar 21 11:19:11 2006 -0700
    89.3 @@ -0,0 +1,5 @@
    89.4 +include $(BASEDIR)/Rules.mk
    89.5 +
    89.6 +obj-y += exits.o
    89.7 +
    89.8 +include $(BASEDIR)/Post.mk
    90.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    90.2 +++ b/xen/arch/x86/hvm/vmx/Makefile	Tue Mar 21 11:19:11 2006 -0700
    90.3 @@ -0,0 +1,10 @@
    90.4 +include $(BASEDIR)/Rules.mk
    90.5 +
    90.6 +subdir-$(x86_32) += x86_32
    90.7 +subdir-$(x86_64) += x86_64
    90.8 +
    90.9 +obj-y += io.o
   90.10 +obj-y += vmcs.o
   90.11 +obj-y += vmx.o
   90.12 +
   90.13 +include $(BASEDIR)/Post.mk
    91.1 --- a/xen/arch/x86/hvm/vmx/io.c	Tue Mar 21 09:55:44 2006 -0700
    91.2 +++ b/xen/arch/x86/hvm/vmx/io.c	Tue Mar 21 11:19:11 2006 -0700
    91.3 @@ -40,20 +40,33 @@
    91.4  
    91.5  #define BSP_CPU(v)    (!(v->vcpu_id))
    91.6  
    91.7 -void vmx_set_tsc_shift(struct vcpu *v, struct hvm_virpit *vpit)
    91.8 +static inline 
    91.9 +void __set_tsc_offset(u64  offset)
   91.10  {
   91.11 -    u64   drift;
   91.12 +    __vmwrite(TSC_OFFSET, offset);
   91.13 +#if defined (__i386__)
   91.14 +    __vmwrite(TSC_OFFSET_HIGH, offset >> 32);
   91.15 +#endif
   91.16 +}
   91.17  
   91.18 -    if ( vpit->first_injected )
   91.19 -        drift = vpit->period_cycles * vpit->pending_intr_nr;
   91.20 -    else 
   91.21 -        drift = 0;
   91.22 -    vpit->shift = v->arch.hvm_vmx.tsc_offset - drift;
   91.23 -    __vmwrite(TSC_OFFSET, vpit->shift);
   91.24 +u64 get_guest_time(struct vcpu *v)
   91.25 +{
   91.26 +    struct hvm_virpit *vpit = &(v->domain->arch.hvm_domain.vpit);
   91.27 +    u64    host_tsc;
   91.28 +    
   91.29 +    rdtscll(host_tsc);
   91.30 +    return host_tsc + vpit->cache_tsc_offset;
   91.31 +}
   91.32  
   91.33 -#if defined (__i386__)
   91.34 -    __vmwrite(TSC_OFFSET_HIGH, ((vpit->shift)>> 32));
   91.35 -#endif
   91.36 +void set_guest_time(struct vcpu *v, u64 gtime)
   91.37 +{
   91.38 +    struct hvm_virpit *vpit = &(v->domain->arch.hvm_domain.vpit);
   91.39 +    u64    host_tsc;
   91.40 +   
   91.41 +    rdtscll(host_tsc);
   91.42 +    
   91.43 +    vpit->cache_tsc_offset = gtime - host_tsc;
   91.44 +    __set_tsc_offset(vpit->cache_tsc_offset);
   91.45  }
   91.46  
   91.47  static inline void
   91.48 @@ -64,6 +77,7 @@ interrupt_post_injection(struct vcpu * v
   91.49      if ( is_pit_irq(v, vector, type) ) {
   91.50          if ( !vpit->first_injected ) {
   91.51              vpit->pending_intr_nr = 0;
   91.52 +            vpit->last_pit_gtime = get_guest_time(v);
   91.53              vpit->scheduled = NOW() + vpit->period;
   91.54              set_timer(&vpit->pit_timer, vpit->scheduled);
   91.55              vpit->first_injected = 1;
   91.56 @@ -71,7 +85,9 @@ interrupt_post_injection(struct vcpu * v
   91.57              vpit->pending_intr_nr--;
   91.58          }
   91.59          vpit->inject_point = NOW();
   91.60 -        vmx_set_tsc_shift (v, vpit);
   91.61 +
   91.62 +        vpit->last_pit_gtime += vpit->period;
   91.63 +        set_guest_time(v, vpit->last_pit_gtime);
   91.64      }
   91.65  
   91.66      switch(type)
   91.67 @@ -189,15 +205,16 @@ void vmx_do_resume(struct vcpu *v)
   91.68  
   91.69      vmx_stts();
   91.70  
   91.71 +    /* pick up the elapsed PIT ticks and re-enable pit_timer */
   91.72 +    if ( vpit->first_injected) {
   91.73 +        set_guest_time(v, v->domain->arch.hvm_domain.guest_time);
   91.74 +        pickup_deactive_ticks(vpit);
   91.75 +    }
   91.76 +
   91.77      if ( test_bit(iopacket_port(v), &d->shared_info->evtchn_pending[0]) ||
   91.78           test_bit(ARCH_HVM_IO_WAIT, &v->arch.hvm_vcpu.ioflags) )
   91.79          hvm_wait_io();
   91.80  
   91.81 -    /* pick up the elapsed PIT ticks and re-enable pit_timer */
   91.82 -    if ( vpit->first_injected )
   91.83 -        pickup_deactive_ticks(vpit);
   91.84 -    vmx_set_tsc_shift(v, vpit);
   91.85 -
   91.86      /* We can't resume the guest if we're waiting on I/O */
   91.87      ASSERT(!test_bit(ARCH_HVM_IO_WAIT, &v->arch.hvm_vcpu.ioflags));
   91.88  }
    92.1 --- a/xen/arch/x86/hvm/vmx/vmcs.c	Tue Mar 21 09:55:44 2006 -0700
    92.2 +++ b/xen/arch/x86/hvm/vmx/vmcs.c	Tue Mar 21 11:19:11 2006 -0700
    92.3 @@ -195,7 +195,6 @@ static void vmx_do_launch(struct vcpu *v
    92.4  /* Update CR3, GDT, LDT, TR */
    92.5      unsigned int  error = 0;
    92.6      unsigned long cr0, cr4;
    92.7 -    u64     host_tsc;
    92.8  
    92.9      if (v->vcpu_id == 0)
   92.10          hvm_setup_platform(v->domain);
   92.11 @@ -250,9 +249,7 @@ static void vmx_do_launch(struct vcpu *v
   92.12      v->arch.hvm_vmx.launch_cpu = smp_processor_id();
   92.13  
   92.14      /* init guest tsc to start from 0 */
   92.15 -    rdtscll(host_tsc);
   92.16 -    v->arch.hvm_vmx.tsc_offset = 0 - host_tsc;
   92.17 -    vmx_set_tsc_shift(v, &v->domain->arch.hvm_domain.vpit);
   92.18 +    set_guest_time(v, 0);
   92.19  }
   92.20  
   92.21  /*
    93.1 --- a/xen/arch/x86/hvm/vmx/vmx.c	Tue Mar 21 09:55:44 2006 -0700
    93.2 +++ b/xen/arch/x86/hvm/vmx/vmx.c	Tue Mar 21 11:19:11 2006 -0700
    93.3 @@ -50,9 +50,14 @@
    93.4  static unsigned long trace_values[NR_CPUS][4];
    93.5  #define TRACE_VMEXIT(index,value) trace_values[smp_processor_id()][index]=value
    93.6  
    93.7 +static void vmx_ctxt_switch_from(struct vcpu *v);
    93.8 +static void vmx_ctxt_switch_to(struct vcpu *v);
    93.9 +
   93.10  void vmx_final_setup_guest(struct vcpu *v)
   93.11  {
   93.12 -    v->arch.schedule_tail = arch_vmx_do_launch;
   93.13 +    v->arch.schedule_tail    = arch_vmx_do_launch;
   93.14 +    v->arch.ctxt_switch_from = vmx_ctxt_switch_from;
   93.15 +    v->arch.ctxt_switch_to   = vmx_ctxt_switch_to;
   93.16  
   93.17      if ( v->vcpu_id == 0 )
   93.18      {
   93.19 @@ -105,6 +110,7 @@ static void vmx_relinquish_guest_resourc
   93.20  }
   93.21  
   93.22  #ifdef __x86_64__
   93.23 +
   93.24  static struct vmx_msr_state percpu_msr[NR_CPUS];
   93.25  
   93.26  static u32 msr_data_index[VMX_MSR_COUNT] =
   93.27 @@ -113,7 +119,7 @@ static u32 msr_data_index[VMX_MSR_COUNT]
   93.28      MSR_SYSCALL_MASK, MSR_EFER,
   93.29  };
   93.30  
   93.31 -void vmx_save_segments(struct vcpu *v)
   93.32 +static void vmx_save_segments(struct vcpu *v)
   93.33  {
   93.34      rdmsrl(MSR_SHADOW_GS_BASE, v->arch.hvm_vmx.msr_content.shadow_gs);
   93.35  }
   93.36 @@ -124,7 +130,7 @@ void vmx_save_segments(struct vcpu *v)
   93.37   * are not modified once set for generic domains, we don't save them,
   93.38   * but simply reset them to the values set at percpu_traps_init().
   93.39   */
   93.40 -void vmx_load_msrs(void)
   93.41 +static void vmx_load_msrs(void)
   93.42  {
   93.43      struct vmx_msr_state *host_state = &percpu_msr[smp_processor_id()];
   93.44      int i;
   93.45 @@ -166,118 +172,143 @@ static void vmx_save_init_msrs(void)
   93.46  #define IS_CANO_ADDRESS(add) 1
   93.47  static inline int long_mode_do_msr_read(struct cpu_user_regs *regs)
   93.48  {
   93.49 -    u64     msr_content = 0;
   93.50 -    struct vcpu *vc = current;
   93.51 -    struct vmx_msr_state * msr = &vc->arch.hvm_vmx.msr_content;
   93.52 -    switch(regs->ecx){
   93.53 +    u64 msr_content = 0;
   93.54 +    struct vcpu *v = current;
   93.55 +    struct vmx_msr_state *msr = &v->arch.hvm_vmx.msr_content;
   93.56 +
   93.57 +    switch ( regs->ecx ) {
   93.58      case MSR_EFER:
   93.59 +        HVM_DBG_LOG(DBG_LEVEL_2, "EFER msr_content 0x%"PRIx64, msr_content);
   93.60          msr_content = msr->msr_items[VMX_INDEX_MSR_EFER];
   93.61 -        HVM_DBG_LOG(DBG_LEVEL_2, "EFER msr_content %"PRIx64"\n", msr_content);
   93.62 -        if (test_bit(VMX_CPU_STATE_LME_ENABLED,
   93.63 -                     &vc->arch.hvm_vmx.cpu_state))
   93.64 -            msr_content |= 1 << _EFER_LME;
   93.65 +
   93.66 +        /* the following code may be not needed */
   93.67 +        if ( test_bit(VMX_CPU_STATE_LME_ENABLED, &v->arch.hvm_vmx.cpu_state) )
   93.68 +            msr_content |= EFER_LME;
   93.69 +        else
   93.70 +            msr_content &= ~EFER_LME;
   93.71  
   93.72 -        if (VMX_LONG_GUEST(vc))
   93.73 -            msr_content |= 1 << _EFER_LMA;
   93.74 +        if ( VMX_LONG_GUEST(v) )
   93.75 +            msr_content |= EFER_LMA;
   93.76 +        else
   93.77 +            msr_content &= ~EFER_LMA;
   93.78          break;
   93.79 +
   93.80      case MSR_FS_BASE:
   93.81 -        if (!(VMX_LONG_GUEST(vc)))
   93.82 +        if ( !(VMX_LONG_GUEST(v)) )
   93.83              /* XXX should it be GP fault */
   93.84              domain_crash_synchronous();
   93.85 +
   93.86          __vmread(GUEST_FS_BASE, &msr_content);
   93.87          break;
   93.88 +
   93.89      case MSR_GS_BASE:
   93.90 -        if (!(VMX_LONG_GUEST(vc)))
   93.91 +        if ( !(VMX_LONG_GUEST(v)) )
   93.92              domain_crash_synchronous();
   93.93 +
   93.94          __vmread(GUEST_GS_BASE, &msr_content);
   93.95          break;
   93.96 +
   93.97      case MSR_SHADOW_GS_BASE:
   93.98          msr_content = msr->shadow_gs;
   93.99          break;
  93.100  
  93.101 -        CASE_READ_MSR(STAR);
  93.102 -        CASE_READ_MSR(LSTAR);
  93.103 -        CASE_READ_MSR(CSTAR);
  93.104 -        CASE_READ_MSR(SYSCALL_MASK);
  93.105 +    CASE_READ_MSR(STAR);
  93.106 +    CASE_READ_MSR(LSTAR);
  93.107 +    CASE_READ_MSR(CSTAR);
  93.108 +    CASE_READ_MSR(SYSCALL_MASK);
  93.109 +
  93.110      default:
  93.111          return 0;
  93.112      }
  93.113 -    HVM_DBG_LOG(DBG_LEVEL_2, "mode_do_msr_read: msr_content: %"PRIx64"\n",
  93.114 -                msr_content);
  93.115 +
  93.116 +    HVM_DBG_LOG(DBG_LEVEL_2, "msr_content: 0x%"PRIx64, msr_content);
  93.117 +
  93.118      regs->eax = msr_content & 0xffffffff;
  93.119      regs->edx = msr_content >> 32;
  93.120 +
  93.121      return 1;
  93.122  }
  93.123  
  93.124  static inline int long_mode_do_msr_write(struct cpu_user_regs *regs)
  93.125  {
  93.126 -    u64     msr_content = regs->eax | ((u64)regs->edx << 32);
  93.127 -    struct vcpu *vc = current;
  93.128 -    struct vmx_msr_state * msr = &vc->arch.hvm_vmx.msr_content;
  93.129 -    struct vmx_msr_state * host_state =
  93.130 -        &percpu_msr[smp_processor_id()];
  93.131 +    u64 msr_content = regs->eax | ((u64)regs->edx << 32);
  93.132 +    struct vcpu *v = current;
  93.133 +    struct vmx_msr_state *msr = &v->arch.hvm_vmx.msr_content;
  93.134 +    struct vmx_msr_state *host_state = &percpu_msr[smp_processor_id()];
  93.135  
  93.136 -    HVM_DBG_LOG(DBG_LEVEL_1, " mode_do_msr_write msr %lx "
  93.137 -                "msr_content %"PRIx64"\n",
  93.138 +    HVM_DBG_LOG(DBG_LEVEL_1, "msr 0x%lx msr_content 0x%"PRIx64"\n",
  93.139                  (unsigned long)regs->ecx, msr_content);
  93.140  
  93.141 -    switch (regs->ecx){
  93.142 +    switch ( regs->ecx ) {
  93.143      case MSR_EFER:
  93.144          /* offending reserved bit will cause #GP */
  93.145 -        if ( msr_content &
  93.146 -                ~( EFER_LME | EFER_LMA | EFER_NX | EFER_SCE ) )
  93.147 -             vmx_inject_exception(vc, TRAP_gp_fault, 0);
  93.148 +        if ( msr_content & ~(EFER_LME | EFER_LMA | EFER_NX | EFER_SCE) )
  93.149 +        {
  93.150 +            printk("trying to set reserved bit in EFER\n");
  93.151 +            vmx_inject_exception(v, TRAP_gp_fault, 0);
  93.152 +            return 0;
  93.153 +        }
  93.154  
  93.155 -        if ((msr_content & EFER_LME) ^
  93.156 -            test_bit(VMX_CPU_STATE_LME_ENABLED,
  93.157 -                     &vc->arch.hvm_vmx.cpu_state)){
  93.158 -            if ( vmx_paging_enabled(vc) ||
  93.159 +        /* LME: 0 -> 1 */
  93.160 +        if ( msr_content & EFER_LME &&
  93.161 +             !test_bit(VMX_CPU_STATE_LME_ENABLED, &v->arch.hvm_vmx.cpu_state) )
  93.162 +        {
  93.163 +            if ( vmx_paging_enabled(v) ||
  93.164                   !test_bit(VMX_CPU_STATE_PAE_ENABLED,
  93.165 -                           &vc->arch.hvm_vmx.cpu_state)) {
  93.166 -                vmx_inject_exception(vc, TRAP_gp_fault, 0);
  93.167 +                           &v->arch.hvm_vmx.cpu_state) )
  93.168 +            {
  93.169 +                printk("trying to set LME bit when "
  93.170 +                       "in paging mode or PAE bit is not set\n");
  93.171 +                vmx_inject_exception(v, TRAP_gp_fault, 0);
  93.172 +                return 0;
  93.173              }
  93.174 +
  93.175 +            set_bit(VMX_CPU_STATE_LME_ENABLED, &v->arch.hvm_vmx.cpu_state);
  93.176          }
  93.177 -        if (msr_content & EFER_LME)
  93.178 -            set_bit(VMX_CPU_STATE_LME_ENABLED,
  93.179 -                    &vc->arch.hvm_vmx.cpu_state);
  93.180  
  93.181 -        msr->msr_items[VMX_INDEX_MSR_EFER] =
  93.182 -            msr_content;
  93.183 +        msr->msr_items[VMX_INDEX_MSR_EFER] = msr_content;
  93.184          break;
  93.185  
  93.186      case MSR_FS_BASE:
  93.187      case MSR_GS_BASE:
  93.188 -        if (!(VMX_LONG_GUEST(vc)))
  93.189 +        if ( !(VMX_LONG_GUEST(v)) )
  93.190              domain_crash_synchronous();
  93.191 -        if (!IS_CANO_ADDRESS(msr_content)){
  93.192 +
  93.193 +        if ( !IS_CANO_ADDRESS(msr_content) )
  93.194 +        {
  93.195              HVM_DBG_LOG(DBG_LEVEL_1, "Not cano address of msr write\n");
  93.196 -            vmx_inject_exception(vc, TRAP_gp_fault, 0);
  93.197 +            vmx_inject_exception(v, TRAP_gp_fault, 0);
  93.198 +            return 0;
  93.199          }
  93.200 -        if (regs->ecx == MSR_FS_BASE)
  93.201 +
  93.202 +        if ( regs->ecx == MSR_FS_BASE )
  93.203              __vmwrite(GUEST_FS_BASE, msr_content);
  93.204          else
  93.205              __vmwrite(GUEST_GS_BASE, msr_content);
  93.206 +
  93.207          break;
  93.208  
  93.209      case MSR_SHADOW_GS_BASE:
  93.210 -        if (!(VMX_LONG_GUEST(vc)))
  93.211 +        if ( !(VMX_LONG_GUEST(v)) )
  93.212              domain_crash_synchronous();
  93.213 -        vc->arch.hvm_vmx.msr_content.shadow_gs = msr_content;
  93.214 +
  93.215 +        v->arch.hvm_vmx.msr_content.shadow_gs = msr_content;
  93.216          wrmsrl(MSR_SHADOW_GS_BASE, msr_content);
  93.217          break;
  93.218  
  93.219 -        CASE_WRITE_MSR(STAR);
  93.220 -        CASE_WRITE_MSR(LSTAR);
  93.221 -        CASE_WRITE_MSR(CSTAR);
  93.222 -        CASE_WRITE_MSR(SYSCALL_MASK);
  93.223 +    CASE_WRITE_MSR(STAR);
  93.224 +    CASE_WRITE_MSR(LSTAR);
  93.225 +    CASE_WRITE_MSR(CSTAR);
  93.226 +    CASE_WRITE_MSR(SYSCALL_MASK);
  93.227 +
  93.228      default:
  93.229          return 0;
  93.230      }
  93.231 +
  93.232      return 1;
  93.233  }
  93.234  
  93.235 -void
  93.236 -vmx_restore_msrs(struct vcpu *v)
  93.237 +static void vmx_restore_msrs(struct vcpu *v)
  93.238  {
  93.239      int i = 0;
  93.240      struct vmx_msr_state *guest_state;
  93.241 @@ -297,22 +328,52 @@ vmx_restore_msrs(struct vcpu *v)
  93.242  
  93.243          HVM_DBG_LOG(DBG_LEVEL_2,
  93.244                      "restore guest's index %d msr %lx with %lx\n",
  93.245 -                    i, (unsigned long) msr_data_index[i], (unsigned long) guest_state->msr_items[i]);
  93.246 +                    i, (unsigned long)msr_data_index[i],
  93.247 +                    (unsigned long)guest_state->msr_items[i]);
  93.248          set_bit(i, &host_state->flags);
  93.249          wrmsrl(msr_data_index[i], guest_state->msr_items[i]);
  93.250          clear_bit(i, &guest_flags);
  93.251      }
  93.252  }
  93.253  #else  /* __i386__ */
  93.254 -#define  vmx_save_init_msrs()   ((void)0)
  93.255 +
  93.256 +#define vmx_save_segments(v)      ((void)0)
  93.257 +#define vmx_load_msrs()           ((void)0)
  93.258 +#define vmx_restore_msrs(v)       ((void)0)
  93.259 +#define vmx_save_init_msrs()      ((void)0)
  93.260  
  93.261 -static inline int  long_mode_do_msr_read(struct cpu_user_regs *regs){
  93.262 +static inline int long_mode_do_msr_read(struct cpu_user_regs *regs)
  93.263 +{
  93.264 +    return 0;
  93.265 +}
  93.266 +
  93.267 +static inline int long_mode_do_msr_write(struct cpu_user_regs *regs)
  93.268 +{
  93.269      return 0;
  93.270  }
  93.271 -static inline int  long_mode_do_msr_write(struct cpu_user_regs *regs){
  93.272 -    return 0;
  93.273 +
  93.274 +#endif /* __i386__ */
  93.275 +
  93.276 +static void vmx_freeze_time(struct vcpu *v)
  93.277 +{
  93.278 +    struct hvm_virpit *vpit = &v->domain->arch.hvm_domain.vpit;
  93.279 +    
  93.280 +    v->domain->arch.hvm_domain.guest_time = get_guest_time(v);
  93.281 +    if ( vpit->first_injected )
  93.282 +        stop_timer(&(vpit->pit_timer));
  93.283  }
  93.284 -#endif
  93.285 +
  93.286 +static void vmx_ctxt_switch_from(struct vcpu *v)
  93.287 +{
  93.288 +    vmx_freeze_time(v);
  93.289 +    vmx_save_segments(v);
  93.290 +    vmx_load_msrs();
  93.291 +}
  93.292 +
  93.293 +static void vmx_ctxt_switch_to(struct vcpu *v)
  93.294 +{
  93.295 +    vmx_restore_msrs(v);
  93.296 +}
  93.297  
  93.298  void stop_vmx(void)
  93.299  {
  93.300 @@ -554,12 +615,6 @@ int start_vmx(void)
  93.301      hvm_funcs.store_cpu_guest_regs = vmx_store_cpu_guest_regs;
  93.302      hvm_funcs.load_cpu_guest_regs = vmx_load_cpu_guest_regs;
  93.303  
  93.304 -#ifdef __x86_64__
  93.305 -    hvm_funcs.save_segments = vmx_save_segments;
  93.306 -    hvm_funcs.load_msrs = vmx_load_msrs;
  93.307 -    hvm_funcs.restore_msrs = vmx_restore_msrs;
  93.308 -#endif
  93.309 -
  93.310      hvm_funcs.store_cpu_guest_ctrl_regs = vmx_store_cpu_guest_ctrl_regs;
  93.311      hvm_funcs.modify_guest_state = vmx_modify_guest_state;
  93.312  
  93.313 @@ -1662,7 +1717,7 @@ static inline void vmx_do_msr_read(struc
  93.314  
  93.315          rdtscll(msr_content);
  93.316          vpit = &(v->domain->arch.hvm_domain.vpit);
  93.317 -        msr_content += vpit->shift;
  93.318 +        msr_content += vpit->cache_tsc_offset;
  93.319          break;
  93.320      }
  93.321      case MSR_IA32_SYSENTER_CS:
  93.322 @@ -1706,22 +1761,8 @@ static inline void vmx_do_msr_write(stru
  93.323  
  93.324      switch (regs->ecx) {
  93.325      case MSR_IA32_TIME_STAMP_COUNTER:
  93.326 -    {
  93.327 -        struct hvm_virpit *vpit;
  93.328 -        u64 host_tsc, drift;
  93.329 -
  93.330 -        rdtscll(host_tsc);
  93.331 -        vpit = &(v->domain->arch.hvm_domain.vpit);
  93.332 -        drift = v->arch.hvm_vmx.tsc_offset - vpit->shift;
  93.333 -        vpit->shift = msr_content - host_tsc;
  93.334 -	v->arch.hvm_vmx.tsc_offset = vpit->shift + drift;
  93.335 -        __vmwrite(TSC_OFFSET, vpit->shift);
  93.336 -
  93.337 -#if defined (__i386__)
  93.338 -        __vmwrite(TSC_OFFSET_HIGH, ((vpit->shift)>>32));
  93.339 -#endif
  93.340 +        set_guest_time(v, msr_content);
  93.341          break;
  93.342 -    }
  93.343      case MSR_IA32_SYSENTER_CS:
  93.344          __vmwrite(GUEST_SYSENTER_CS, msr_content);
  93.345          break;
    94.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    94.2 +++ b/xen/arch/x86/hvm/vmx/x86_32/Makefile	Tue Mar 21 11:19:11 2006 -0700
    94.3 @@ -0,0 +1,5 @@
    94.4 +include $(BASEDIR)/Rules.mk
    94.5 +
    94.6 +obj-y += exits.o
    94.7 +
    94.8 +include $(BASEDIR)/Post.mk
    95.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    95.2 +++ b/xen/arch/x86/hvm/vmx/x86_64/Makefile	Tue Mar 21 11:19:11 2006 -0700
    95.3 @@ -0,0 +1,5 @@
    95.4 +include $(BASEDIR)/Rules.mk
    95.5 +
    95.6 +obj-y += exits.o
    95.7 +
    95.8 +include $(BASEDIR)/Post.mk
    96.1 --- a/xen/arch/x86/smp.c	Tue Mar 21 09:55:44 2006 -0700
    96.2 +++ b/xen/arch/x86/smp.c	Tue Mar 21 11:19:11 2006 -0700
    96.3 @@ -266,7 +266,7 @@ void smp_send_event_check_mask(cpumask_t
    96.4  }
    96.5  
    96.6  /*
    96.7 - * Structure and data for smp_call_function().
    96.8 + * Structure and data for smp_call_function()/on_selected_cpus().
    96.9   */
   96.10  
   96.11  struct call_data_struct {
   96.12 @@ -275,41 +275,48 @@ struct call_data_struct {
   96.13      int wait;
   96.14      atomic_t started;
   96.15      atomic_t finished;
   96.16 +    cpumask_t selected;
   96.17  };
   96.18  
   96.19 -static spinlock_t call_lock = SPIN_LOCK_UNLOCKED;
   96.20 +static DEFINE_SPINLOCK(call_lock);
   96.21  static struct call_data_struct *call_data;
   96.22  
   96.23 -/*
   96.24 - * Run a function on all other CPUs.
   96.25 - *  @func: The function to run. This must be fast and non-blocking.
   96.26 - *  @info: An arbitrary pointer to pass to the function.
   96.27 - *  @wait: If true, spin until function has completed on other CPUs.
   96.28 - *  Returns: 0 on success, else a negative status code.
   96.29 - */
   96.30  int smp_call_function(
   96.31 -    void (*func) (void *info), void *info, int unused, int wait)
   96.32 +    void (*func) (void *info),
   96.33 +    void *info,
   96.34 +    int retry,
   96.35 +    int wait)
   96.36 +{
   96.37 +    cpumask_t allbutself = cpu_online_map;
   96.38 +    cpu_clear(smp_processor_id(), allbutself);
   96.39 +    return on_selected_cpus(allbutself, func, info, retry, wait);
   96.40 +}
   96.41 +
   96.42 +extern int on_selected_cpus(
   96.43 +    cpumask_t selected,
   96.44 +    void (*func) (void *info),
   96.45 +    void *info,
   96.46 +    int retry,
   96.47 +    int wait)
   96.48  {
   96.49      struct call_data_struct data;
   96.50 -    unsigned int nr_cpus = num_online_cpus() - 1;
   96.51 +    unsigned int nr_cpus = cpus_weight(selected);
   96.52  
   96.53      ASSERT(local_irq_is_enabled());
   96.54  
   96.55 -    if ( nr_cpus == 0 )
   96.56 -        return 0;
   96.57 -
   96.58      data.func = func;
   96.59      data.info = info;
   96.60      data.wait = wait;
   96.61      atomic_set(&data.started, 0);
   96.62      atomic_set(&data.finished, 0);
   96.63 +    data.selected = selected;
   96.64  
   96.65      spin_lock(&call_lock);
   96.66  
   96.67      call_data = &data;
   96.68      wmb();
   96.69  
   96.70 -    send_IPI_allbutself(CALL_FUNCTION_VECTOR);
   96.71 +    send_IPI_mask(selected, CALL_FUNCTION_VECTOR);
   96.72  
   96.73      while ( atomic_read(wait ? &data.finished : &data.started) != nr_cpus )
   96.74          cpu_relax();
   96.75 @@ -353,6 +360,9 @@ fastcall void smp_call_function_interrup
   96.76      ack_APIC_irq();
   96.77      perfc_incrc(ipis);
   96.78  
   96.79 +    if ( !cpu_isset(smp_processor_id(), call_data->selected) )
   96.80 +        return;
   96.81 +
   96.82      if ( call_data->wait )
   96.83      {
   96.84          (*func)(info);
    97.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    97.2 +++ b/xen/arch/x86/x86_32/Makefile	Tue Mar 21 11:19:11 2006 -0700
    97.3 @@ -0,0 +1,11 @@
    97.4 +include $(BASEDIR)/Rules.mk
    97.5 +
    97.6 +obj-y += domain_page.o
    97.7 +obj-y += entry.o
    97.8 +obj-y += mm.o
    97.9 +obj-y += seg_fixup.o
   97.10 +obj-y += traps.o
   97.11 +
   97.12 +obj-$(supervisor_mode_kernel) += supervisor_mode_kernel.o
   97.13 +
   97.14 +include $(BASEDIR)/Post.mk
    98.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    98.2 +++ b/xen/arch/x86/x86_64/Makefile	Tue Mar 21 11:19:11 2006 -0700
    98.3 @@ -0,0 +1,7 @@
    98.4 +include $(BASEDIR)/Rules.mk
    98.5 +
    98.6 +obj-y += entry.o
    98.7 +obj-y += mm.o
    98.8 +obj-y += traps.o
    98.9 +
   98.10 +include $(BASEDIR)/Post.mk
    99.1 --- a/xen/common/Makefile	Tue Mar 21 09:55:44 2006 -0700
    99.2 +++ b/xen/common/Makefile	Tue Mar 21 11:19:11 2006 -0700
    99.3 @@ -1,19 +1,34 @@
    99.4 -
    99.5  include $(BASEDIR)/Rules.mk
    99.6  
    99.7 -ifneq ($(perfc),y)
    99.8 -OBJS := $(subst perfc.o,,$(OBJS))
    99.9 -endif
   99.10 -ifneq ($(crash_debug),y)
   99.11 -OBJS := $(patsubst gdbstub.o,,$(OBJS))
   99.12 -endif
   99.13 +obj-y += acm_ops.o
   99.14 +obj-y += bitmap.o
   99.15 +obj-y += dom0_ops.o
   99.16 +obj-y += domain.o
   99.17 +obj-y += elf.o
   99.18 +obj-y += event_channel.o
   99.19 +obj-y += grant_table.o
   99.20 +obj-y += kernel.o
   99.21 +obj-y += keyhandler.o
   99.22 +obj-y += lib.o
   99.23 +obj-y += memory.o
   99.24 +obj-y += multicall.o
   99.25 +obj-y += page_alloc.o
   99.26 +obj-y += rangeset.o
   99.27 +obj-y += sched_bvt.o
   99.28 +obj-y += sched_sedf.o
   99.29 +obj-y += schedule.o
   99.30 +obj-y += softirq.o
   99.31 +obj-y += string.o
   99.32 +obj-y += symbols.o
   99.33 +obj-y += trace.o
   99.34 +obj-y += timer.o
   99.35 +obj-y += vsprintf.o
   99.36 +obj-y += xmalloc.o
   99.37  
   99.38 -default: common.o
   99.39 -common.o: $(OBJS)
   99.40 -	$(LD) $(LDFLAGS) -r -o common.o $(OBJS)
   99.41 +obj-$(perfc)       += perfc.o
   99.42 +obj-$(crash_debug) += gdbstub.o
   99.43  
   99.44 -clean:
   99.45 -	rm -f *.o *~ core
   99.46 +include $(BASEDIR)/Post.mk
   99.47  
   99.48  # Object file contains changeset and compiler information.
   99.49  kernel.o: $(BASEDIR)/include/xen/compile.h
   100.1 --- a/xen/drivers/Makefile	Tue Mar 21 09:55:44 2006 -0700
   100.2 +++ b/xen/drivers/Makefile	Tue Mar 21 11:19:11 2006 -0700
   100.3 @@ -1,8 +1,6 @@
   100.4 +include $(BASEDIR)/Rules.mk
   100.5  
   100.6 -default:
   100.7 -	$(MAKE) -C char
   100.8 -	$(MAKE) -C acpi
   100.9 +subdir-y += char
  100.10 +subdir-$(HAS_ACPI) += acpi
  100.11  
  100.12 -clean:
  100.13 -	$(MAKE) -C char clean
  100.14 -	$(MAKE) -C acpi clean
  100.15 +include $(BASEDIR)/Post.mk
   101.1 --- a/xen/drivers/acpi/Makefile	Tue Mar 21 09:55:44 2006 -0700
   101.2 +++ b/xen/drivers/acpi/Makefile	Tue Mar 21 11:19:11 2006 -0700
   101.3 @@ -1,11 +1,5 @@
   101.4 -
   101.5  include $(BASEDIR)/Rules.mk
   101.6  
   101.7 -OBJS := tables.o
   101.8 +obj-y += tables.o
   101.9  
  101.10 -default: driver.o
  101.11 -driver.o: $(OBJS)
  101.12 -	$(LD) $(LDFLAGS) -r -o driver.o $(OBJS)
  101.13 -
  101.14 -clean:
  101.15 -	rm -f *.o *~ core
  101.16 +include $(BASEDIR)/Post.mk
   102.1 --- a/xen/drivers/char/Makefile	Tue Mar 21 09:55:44 2006 -0700
   102.2 +++ b/xen/drivers/char/Makefile	Tue Mar 21 11:19:11 2006 -0700
   102.3 @@ -1,12 +1,10 @@
   102.4 -
   102.5  include $(BASEDIR)/Rules.mk
   102.6  
   102.7 -default: driver.o
   102.8 -driver.o: $(OBJS)
   102.9 -	$(LD) $(LDFLAGS) -r -o driver.o $(OBJS)
  102.10 +obj-y += console.o
  102.11 +obj-y += ns16550.o
  102.12 +obj-y += serial.o
  102.13  
  102.14 -clean:
  102.15 -	rm -f *.o *~ core
  102.16 +include $(BASEDIR)/Post.mk
  102.17  
  102.18  # Object file contains changeset and compiler information.
  102.19  console.o: $(BASEDIR)/include/xen/compile.h
   105.1 --- a/xen/include/asm-ia64/linux/asm/irq.h	Tue Mar 21 09:55:44 2006 -0700
   105.2 +++ b/xen/include/asm-ia64/linux/asm/irq.h	Tue Mar 21 11:19:11 2006 -0700
   105.3 @@ -40,4 +40,6 @@ struct irqaction;
   105.4  struct pt_regs;
   105.5  int handle_IRQ_event(unsigned int, struct pt_regs *, struct irqaction *);
   105.6  
   105.7 +extern fastcall unsigned int __do_IRQ(unsigned int irq, struct pt_regs *regs);
   105.8 +
   105.9  #endif /* _ASM_IA64_IRQ_H */
   106.1 --- a/xen/include/asm-x86/domain.h	Tue Mar 21 09:55:44 2006 -0700
   106.2 +++ b/xen/include/asm-x86/domain.h	Tue Mar 21 11:19:11 2006 -0700
   106.3 @@ -124,6 +124,9 @@ struct arch_vcpu
   106.4  
   106.5      void (*schedule_tail) (struct vcpu *);
   106.6  
   106.7 +    void (*ctxt_switch_from) (struct vcpu *);
   106.8 +    void (*ctxt_switch_to) (struct vcpu *);
   106.9 +
  106.10      /* Bounce information for propagating an exception to guest OS. */
  106.11      struct trap_bounce trap_bounce;
  106.12  
   107.1 --- a/xen/include/asm-x86/genapic.h	Tue Mar 21 09:55:44 2006 -0700
   107.2 +++ b/xen/include/asm-x86/genapic.h	Tue Mar 21 11:19:11 2006 -0700
   107.3 @@ -34,24 +34,14 @@ struct genapic {
   107.4  	physid_mask_t (*ioapic_phys_id_map)(physid_mask_t map);
   107.5  
   107.6  	void (*clustered_apic_check)(void);
   107.7 -	int (*multi_timer_check)(int apic, int irq);
   107.8  	int (*apicid_to_node)(int logical_apicid); 
   107.9  	int (*cpu_to_logical_apicid)(int cpu);
  107.10  	int (*cpu_present_to_apicid)(int mps_cpu);
  107.11  	physid_mask_t (*apicid_to_cpu_present)(int phys_apicid);
  107.12 -	int (*mpc_apic_id)(struct mpc_config_processor *m, 
  107.13 -			   struct mpc_config_translation *t); 
  107.14 -	void (*setup_portio_remap)(void); 
  107.15  	int (*check_phys_apicid_present)(int boot_cpu_physical_apicid);
  107.16  	void (*enable_apic_mode)(void);
  107.17  	u32 (*phys_pkg_id)(u32 cpuid_apic, int index_msb);
  107.18  
  107.19 -	/* mpparse */
  107.20 -	void (*mpc_oem_bus_info)(struct mpc_config_bus *, char *, 
  107.21 -				 struct mpc_config_translation *);
  107.22 -	void (*mpc_oem_pci_bus)(struct mpc_config_bus *, 
  107.23 -				struct mpc_config_translation *); 
  107.24 -
  107.25  	/* When one of the next two hooks returns 1 the genapic
  107.26  	   is switched to this. Essentially they are additional probe 
  107.27  	   functions. */
  107.28 @@ -60,7 +50,6 @@ struct genapic {
  107.29  	int (*acpi_madt_oem_check)(char *oem_id, char *oem_table_id);
  107.30  
  107.31  	unsigned (*get_apic_id)(unsigned long x);
  107.32 -	unsigned long apic_id_mask;
  107.33  	unsigned int (*cpu_mask_to_apicid)(cpumask_t cpumask);
  107.34  	
  107.35  	/* ipi */
  107.36 @@ -86,19 +75,13 @@ struct genapic {
  107.37  	APICFUNC(init_apic_ldr), \
  107.38  	APICFUNC(ioapic_phys_id_map), \
  107.39  	APICFUNC(clustered_apic_check), \
  107.40 -	APICFUNC(multi_timer_check), \
  107.41  	APICFUNC(apicid_to_node), \
  107.42  	APICFUNC(cpu_to_logical_apicid), \
  107.43  	APICFUNC(cpu_present_to_apicid), \
  107.44  	APICFUNC(apicid_to_cpu_present), \
  107.45 -	APICFUNC(mpc_apic_id), \
  107.46 -	APICFUNC(setup_portio_remap), \
  107.47  	APICFUNC(check_phys_apicid_present), \
  107.48 -	APICFUNC(mpc_oem_bus_info), \
  107.49 -	APICFUNC(mpc_oem_pci_bus), \
  107.50  	APICFUNC(mps_oem_check), \
  107.51  	APICFUNC(get_apic_id), \
  107.52 -	.apic_id_mask = APIC_ID_MASK, \
  107.53  	APICFUNC(cpu_mask_to_apicid), \
  107.54  	APICFUNC(acpi_madt_oem_check), \
  107.55  	APICFUNC(send_IPI_mask), \
   108.1 --- a/xen/include/asm-x86/hvm/domain.h	Tue Mar 21 09:55:44 2006 -0700
   108.2 +++ b/xen/include/asm-x86/hvm/domain.h	Tue Mar 21 11:19:11 2006 -0700
   108.3 @@ -37,6 +37,7 @@ struct hvm_domain {
   108.4      unsigned int           pae_enabled;
   108.5  
   108.6      struct hvm_virpit      vpit;
   108.7 +    u64                    guest_time;
   108.8      struct hvm_virpic      vpic;
   108.9      struct hvm_vioapic     vioapic;
  108.10      struct hvm_io_handler  io_handler;
   109.1 --- a/xen/include/asm-x86/hvm/hvm.h	Tue Mar 21 09:55:44 2006 -0700
   109.2 +++ b/xen/include/asm-x86/hvm/hvm.h	Tue Mar 21 11:19:11 2006 -0700
   109.3 @@ -41,18 +41,11 @@ struct hvm_function_table {
   109.4      /*
   109.5       * Store and load guest state:
   109.6       * 1) load/store guest register state,
   109.7 -     * 2) load/store segment state (x86_64 only),
   109.8 -     * 3) load/store msr register state (x86_64 only),
   109.9 -     * 4) store guest control register state (used for panic dumps),
  109.10 -     * 5) modify guest state (e.g., set debug flags).
  109.11 +     * 2) store guest control register state (used for panic dumps),
  109.12 +     * 3) modify guest state (e.g., set debug flags).
  109.13       */
  109.14      void (*store_cpu_guest_regs)(struct vcpu *v, struct cpu_user_regs *r);
  109.15      void (*load_cpu_guest_regs)(struct vcpu *v, struct cpu_user_regs *r);
  109.16 -#ifdef __x86_64__
  109.17 -    void (*save_segments)(struct vcpu *v);
  109.18 -    void (*load_msrs)(void);
  109.19 -    void (*restore_msrs)(struct vcpu *v);
  109.20 -#endif
  109.21      void (*store_cpu_guest_ctrl_regs)(struct vcpu *v, unsigned long crs[8]);
  109.22      void (*modify_guest_state)(struct vcpu *v);
  109.23  
  109.24 @@ -111,33 +104,6 @@ hvm_load_cpu_guest_regs(struct vcpu *v, 
  109.25      hvm_funcs.load_cpu_guest_regs(v, r);
  109.26  }
  109.27  
  109.28 -#ifdef __x86_64__
  109.29 -static inline void
  109.30 -hvm_save_segments(struct vcpu *v)
  109.31 -{
  109.32 -    if (hvm_funcs.save_segments)
  109.33 -        hvm_funcs.save_segments(v);
  109.34 -}
  109.35 -
  109.36 -static inline void
  109.37 -hvm_load_msrs(void)
  109.38 -{
  109.39 -    if (hvm_funcs.load_msrs)
  109.40 -        hvm_funcs.load_msrs();
  109.41 -}
  109.42 -
  109.43 -static inline void
  109.44 -hvm_restore_msrs(struct vcpu *v)
  109.45 -{
  109.46 -    if (hvm_funcs.restore_msrs)
  109.47 -        hvm_funcs.restore_msrs(v);
  109.48 -}
  109.49 -#else
  109.50 -#define hvm_save_segments(v)    ((void)0)
  109.51 -#define hvm_load_msrs(v)        ((void)0)
  109.52 -#define hvm_restore_msrs(v)     ((void)0)
  109.53 -#endif /* __x86_64__ */
  109.54 -
  109.55  static inline void
  109.56  hvm_store_cpu_guest_ctrl_regs(struct vcpu *v, unsigned long crs[8])
  109.57  {
   110.1 --- a/xen/include/asm-x86/hvm/vmx/vmcs.h	Tue Mar 21 09:55:44 2006 -0700
   110.2 +++ b/xen/include/asm-x86/hvm/vmx/vmcs.h	Tue Mar 21 11:19:11 2006 -0700
   110.3 @@ -77,7 +77,6 @@ struct arch_vmx_struct {
   110.4      unsigned long           cpu_based_exec_control;
   110.5      struct vmx_msr_state    msr_content;
   110.6      void                    *io_bitmap_a, *io_bitmap_b;
   110.7 -    u64                     tsc_offset;
   110.8      struct timer            hlt_timer;  /* hlt ins emulation wakeup timer */
   110.9  };
  110.10  
   111.1 --- a/xen/include/asm-x86/hvm/vmx/vmx.h	Tue Mar 21 09:55:44 2006 -0700
   111.2 +++ b/xen/include/asm-x86/hvm/vmx/vmx.h	Tue Mar 21 11:19:11 2006 -0700
   111.3 @@ -30,10 +30,11 @@ extern void vmx_asm_vmexit_handler(struc
   111.4  extern void vmx_asm_do_resume(void);
   111.5  extern void vmx_asm_do_launch(void);
   111.6  extern void vmx_intr_assist(void);
   111.7 -extern void vmx_set_tsc_shift(struct vcpu *, struct hvm_virpit *);
   111.8  extern void vmx_migrate_timers(struct vcpu *v);
   111.9  extern void arch_vmx_do_launch(struct vcpu *);
  111.10  extern void arch_vmx_do_resume(struct vcpu *);
  111.11 +extern void set_guest_time(struct vcpu *v, u64 gtime);
  111.12 +extern u64  get_guest_time(struct vcpu *v);
  111.13  
  111.14  extern unsigned int cpu_rev;
  111.15  
   112.1 --- a/xen/include/asm-x86/hvm/vpit.h	Tue Mar 21 09:55:44 2006 -0700
   112.2 +++ b/xen/include/asm-x86/hvm/vpit.h	Tue Mar 21 11:19:11 2006 -0700
   112.3 @@ -38,7 +38,6 @@
   112.4  struct hvm_virpit {
   112.5      /* for simulation of counter 0 in mode 2 */
   112.6      u64 period_cycles;          /* pit frequency in cpu cycles */
   112.7 -    u64 shift;                  /* save the value of offset - drift */
   112.8      s_time_t inject_point;      /* the time inject virt intr */
   112.9      s_time_t scheduled;         /* scheduled timer interrupt */
  112.10      struct timer pit_timer;     /* periodic timer for mode 2*/
  112.11 @@ -46,6 +45,8 @@ struct hvm_virpit {
  112.12      unsigned int pending_intr_nr; /* the couner for pending timer interrupts */
  112.13      u32 period;                 /* pit frequency in ns */
  112.14      int first_injected;         /* flag to prevent shadow window */
  112.15 +    s64 cache_tsc_offset;       /* cache of VMCS TSC_OFFSET offset */
  112.16 +    u64 last_pit_gtime;         /* guest time when last pit is injected */
  112.17  
  112.18      /* virtual PIT state for handle related I/O */
  112.19      int read_state;
   113.1 --- a/xen/include/asm-x86/mach-bigsmp/mach_apic.h	Tue Mar 21 09:55:44 2006 -0700
   113.2 +++ b/xen/include/asm-x86/mach-bigsmp/mach_apic.h	Tue Mar 21 11:19:11 2006 -0700
   113.3 @@ -1,17 +1,10 @@
   113.4  #ifndef __ASM_MACH_APIC_H
   113.5  #define __ASM_MACH_APIC_H
   113.6 -#include <asm/smp.h>
   113.7 +
   113.8  
   113.9 -#define SEQUENTIAL_APICID
  113.10 -#ifdef SEQUENTIAL_APICID
  113.11 -#define xapic_phys_to_log_apicid(phys_apic) ( (1ul << ((phys_apic) & 0x3)) |\
  113.12 -		((phys_apic<<2) & (~0xf)) )
  113.13 -#elif CLUSTERED_APICID
  113.14 -#define xapic_phys_to_log_apicid(phys_apic) ( (1ul << ((phys_apic) & 0x3)) |\
  113.15 -		((phys_apic) & (~0xf)) )
  113.16 -#endif
  113.17 +extern u8 bios_cpu_apicid[];
  113.18  
  113.19 -#define NO_BALANCE_IRQ (1)
  113.20 +#define xapic_phys_to_log_apicid(cpu) (bios_cpu_apicid[cpu])
  113.21  #define esr_disable (1)
  113.22  
  113.23  static inline int apic_id_registered(void)
  113.24 @@ -19,7 +12,6 @@ static inline int apic_id_registered(voi
  113.25  	return (1);
  113.26  }
  113.27  
  113.28 -#define APIC_DFR_VALUE	(APIC_DFR_CLUSTER)
  113.29  /* Round robin the irqs amoung the online cpus */
  113.30  static inline cpumask_t target_cpus(void)
  113.31  { 
  113.32 @@ -32,29 +24,34 @@ static inline cpumask_t target_cpus(void
  113.33  	} while (cpu >= NR_CPUS);
  113.34  	return cpumask_of_cpu(cpu);
  113.35  }
  113.36 -#define TARGET_CPUS	(target_cpus())
  113.37  
  113.38 -#define INT_DELIVERY_MODE dest_Fixed
  113.39 -#define INT_DEST_MODE 1     /* logical delivery broadcast to all procs */
  113.40 +#undef APIC_DEST_LOGICAL
  113.41 +#define APIC_DEST_LOGICAL 	0
  113.42 +#define TARGET_CPUS		(target_cpus())
  113.43 +#define APIC_DFR_VALUE		(APIC_DFR_FLAT)
  113.44 +#define INT_DELIVERY_MODE	(dest_Fixed)
  113.45 +#define INT_DEST_MODE		(0)    /* phys delivery to target proc */
  113.46 +#define NO_BALANCE_IRQ		(0)
  113.47 +#define WAKE_SECONDARY_VIA_INIT
  113.48 +
  113.49  
  113.50  static inline unsigned long check_apicid_used(physid_mask_t bitmap, int apicid)
  113.51  {
  113.52 -	return 0;
  113.53 +	return (0);
  113.54 +}
  113.55 +
  113.56 +static inline unsigned long check_apicid_present(int bit)
  113.57 +{
  113.58 +	return (1);
  113.59  }
  113.60  
  113.61 -/* we don't use the phys_cpu_present_map to indicate apicid presence */
  113.62 -static inline unsigned long check_apicid_present(int bit) 
  113.63 +static inline unsigned long calculate_ldr(int cpu)
  113.64  {
  113.65 -	return 1;
  113.66 -}
  113.67 -
  113.68 -#define apicid_cluster(apicid) (apicid & 0xF0)
  113.69 -
  113.70 -static inline unsigned long calculate_ldr(unsigned long old)
  113.71 -{
  113.72 -	unsigned long id;
  113.73 -	id = xapic_phys_to_log_apicid(hard_smp_processor_id());
  113.74 -	return ((old & ~APIC_LDR_MASK) | SET_APIC_LOGICAL_ID(id));
  113.75 +	unsigned long val, id;
  113.76 +	val = apic_read(APIC_LDR) & ~APIC_LDR_MASK;
  113.77 +	id = xapic_phys_to_log_apicid(cpu);
  113.78 +	val |= SET_APIC_LOGICAL_ID(id);
  113.79 +	return val;
  113.80  }
  113.81  
  113.82  /*
  113.83 @@ -67,37 +64,30 @@ static inline unsigned long calculate_ld
  113.84  static inline void init_apic_ldr(void)
  113.85  {
  113.86  	unsigned long val;
  113.87 +	int cpu = smp_processor_id();
  113.88  
  113.89  	apic_write_around(APIC_DFR, APIC_DFR_VALUE);
  113.90 -	val = apic_read(APIC_LDR) & ~APIC_LDR_MASK;
  113.91 -	val = calculate_ldr(val);
  113.92 +	val = calculate_ldr(cpu);
  113.93  	apic_write_around(APIC_LDR, val);
  113.94  }
  113.95  
  113.96  static inline void clustered_apic_check(void)
  113.97  {
  113.98  	printk("Enabling APIC mode:  %s.  Using %d I/O APICs\n",
  113.99 -		"Cluster", nr_ioapics);
 113.100 -}
 113.101 -
 113.102 -static inline int multi_timer_check(int apic, int irq)
 113.103 -{
 113.104 -	return 0;
 113.105 +		"Physflat", nr_ioapics);
 113.106  }
 113.107  
 113.108  static inline int apicid_to_node(int logical_apicid)
 113.109  {
 113.110 -	return 0;
 113.111 +	return (0);
 113.112  }
 113.113  
 113.114 -extern u8 bios_cpu_apicid[];
 113.115 -
 113.116  static inline int cpu_present_to_apicid(int mps_cpu)
 113.117  {
 113.118  	if (mps_cpu < NR_CPUS)
 113.119 -		return (int)bios_cpu_apicid[mps_cpu];
 113.120 -	else
 113.121 -		return BAD_APICID;
 113.122 +		return (int) bios_cpu_apicid[mps_cpu];
 113.123 +
 113.124 +	return BAD_APICID;
 113.125  }
 113.126  
 113.127  static inline physid_mask_t apicid_to_cpu_present(int phys_apicid)
 113.128 @@ -109,32 +99,15 @@ extern u8 cpu_2_logical_apicid[];
 113.129  /* Mapping from cpu number to logical apicid */
 113.130  static inline int cpu_to_logical_apicid(int cpu)
 113.131  {
 113.132 -       if (cpu >= NR_CPUS)
 113.133 -	       return BAD_APICID;
 113.134 -       return (int)cpu_2_logical_apicid[cpu];
 113.135 - }
 113.136 -
 113.137 -static inline int mpc_apic_id(struct mpc_config_processor *m,
 113.138 -			struct mpc_config_translation *translation_record)
 113.139 -{
 113.140 -	printk("Processor #%d %d:%d APIC version %d\n",
 113.141 -	        m->mpc_apicid,
 113.142 -	        (m->mpc_cpufeature & CPU_FAMILY_MASK) >> 8,
 113.143 -	        (m->mpc_cpufeature & CPU_MODEL_MASK) >> 4,
 113.144 -	        m->mpc_apicver);
 113.145 -	return m->mpc_apicid;
 113.146 +	if (cpu >= NR_CPUS)
 113.147 +		return BAD_APICID;
 113.148 +	return cpu_physical_id(cpu);
 113.149  }
 113.150  
 113.151  static inline physid_mask_t ioapic_phys_id_map(physid_mask_t phys_map)
 113.152  {
 113.153  	/* For clustered we don't have a good way to do this yet - hack */
 113.154 -	return physids_promote(0xFUL);
 113.155 -}
 113.156 -
 113.157 -#define WAKE_SECONDARY_VIA_INIT
 113.158 -
 113.159 -static inline void setup_portio_remap(void)
 113.160 -{
 113.161 +	return physids_promote(0xFFL);
 113.162  }
 113.163  
 113.164  static inline void enable_apic_mode(void)
   114.1 --- a/xen/include/asm-x86/mach-bigsmp/mach_apicdef.h	Tue Mar 21 09:55:44 2006 -0700
   114.2 +++ b/xen/include/asm-x86/mach-bigsmp/mach_apicdef.h	Tue Mar 21 11:19:11 2006 -0700
   114.3 @@ -1,11 +1,9 @@
   114.4  #ifndef __ASM_MACH_APICDEF_H
   114.5  #define __ASM_MACH_APICDEF_H
   114.6  
   114.7 -#define		APIC_ID_MASK		(0x0F<<24)
   114.8 -
   114.9  static inline unsigned get_apic_id(unsigned long x) 
  114.10  { 
  114.11 -	return (((x)>>24)&0x0F);
  114.12 +	return (((x)>>24)&0xFF);
  114.13  } 
  114.14  
  114.15  #define		GET_APIC_ID(x)	get_apic_id(x)
   115.1 --- a/xen/include/asm-x86/mach-default/mach_apic.h	Tue Mar 21 09:55:44 2006 -0700
   115.2 +++ b/xen/include/asm-x86/mach-default/mach_apic.h	Tue Mar 21 11:19:11 2006 -0700
   115.3 @@ -60,11 +60,6 @@ static inline void clustered_apic_check(
   115.4  					"Flat", nr_ioapics);
   115.5  }
   115.6  
   115.7 -static inline int multi_timer_check(int apic, int irq)
   115.8 -{
   115.9 -	return 0;
  115.10 -}
  115.11 -
  115.12  static inline int apicid_to_node(int logical_apicid)
  115.13  {
  115.14  	return 0;
  115.15 @@ -89,21 +84,6 @@ static inline physid_mask_t apicid_to_cp
  115.16  	return physid_mask_of_physid(phys_apicid);
  115.17  }
  115.18  
  115.19 -static inline int mpc_apic_id(struct mpc_config_processor *m, 
  115.20 -			struct mpc_config_translation *translation_record)
  115.21 -{
  115.22 -	printk("Processor #%d %d:%d APIC version %d\n",
  115.23 -			m->mpc_apicid,
  115.24 -			(m->mpc_cpufeature & CPU_FAMILY_MASK) >> 8,
  115.25 -			(m->mpc_cpufeature & CPU_MODEL_MASK) >> 4,
  115.26 -			m->mpc_apicver);
  115.27 -	return (m->mpc_apicid);
  115.28 -}
  115.29 -
  115.30 -static inline void setup_portio_remap(void)
  115.31 -{
  115.32 -}
  115.33 -
  115.34  static inline int check_phys_apicid_present(int boot_cpu_physical_apicid)
  115.35  {
  115.36  	return physid_isset(boot_cpu_physical_apicid, phys_cpu_present_map);
   116.1 --- a/xen/include/asm-x86/mach-default/mach_apicdef.h	Tue Mar 21 09:55:44 2006 -0700
   116.2 +++ b/xen/include/asm-x86/mach-default/mach_apicdef.h	Tue Mar 21 11:19:11 2006 -0700
   116.3 @@ -1,8 +1,6 @@
   116.4  #ifndef __ASM_MACH_APICDEF_H
   116.5  #define __ASM_MACH_APICDEF_H
   116.6  
   116.7 -#define		APIC_ID_MASK		(0xF<<24)
   116.8 -
   116.9  static inline unsigned get_apic_id(unsigned long x) 
  116.10  { 
  116.11  	return (((x)>>24)&0xF);
   117.1 --- a/xen/include/asm-x86/mach-default/mach_ipi.h	Tue Mar 21 09:55:44 2006 -0700
   117.2 +++ b/xen/include/asm-x86/mach-default/mach_ipi.h	Tue Mar 21 11:19:11 2006 -0700
   117.3 @@ -4,11 +4,32 @@
   117.4  void send_IPI_mask_bitmask(cpumask_t mask, int vector);
   117.5  void __send_IPI_shortcut(unsigned int shortcut, int vector);
   117.6  
   117.7 +extern int no_broadcast;
   117.8 +
   117.9  static inline void send_IPI_mask(cpumask_t mask, int vector)
  117.10  {
  117.11  	send_IPI_mask_bitmask(mask, vector);
  117.12  }
  117.13  
  117.14 +static inline void __local_send_IPI_allbutself(int vector)
  117.15 +{
  117.16 +	if (no_broadcast) {
  117.17 +		cpumask_t mask = cpu_online_map;
  117.18 +
  117.19 +		cpu_clear(smp_processor_id(), mask);
  117.20 +		send_IPI_mask(mask, vector);
  117.21 +	} else
  117.22 +		__send_IPI_shortcut(APIC_DEST_ALLBUT, vector);
  117.23 +}
  117.24 +
  117.25 +static inline void __local_send_IPI_all(int vector)
  117.26 +{
  117.27 +	if (no_broadcast)
  117.28 +		send_IPI_mask(cpu_online_map, vector);
  117.29 +	else
  117.30 +		__send_IPI_shortcut(APIC_DEST_ALLINC, vector);
  117.31 +}
  117.32 +
  117.33  static inline void send_IPI_allbutself(int vector)
  117.34  {
  117.35  	/*
  117.36 @@ -18,13 +39,13 @@ static inline void send_IPI_allbutself(i
  117.37  	if (!(num_online_cpus() > 1))
  117.38  		return;
  117.39  
  117.40 -	__send_IPI_shortcut(APIC_DEST_ALLBUT, vector);
  117.41 +	__local_send_IPI_allbutself(vector);
  117.42  	return;
  117.43  }
  117.44  
  117.45  static inline void send_IPI_all(int vector)
  117.46  {
  117.47 -	__send_IPI_shortcut(APIC_DEST_ALLINC, vector);
  117.48 +	__local_send_IPI_all(vector);
  117.49  }
  117.50  
  117.51  #endif /* __ASM_MACH_IPI_H */
   118.1 --- a/xen/include/asm-x86/mach-default/mach_mpparse.h	Tue Mar 21 09:55:44 2006 -0700
   118.2 +++ b/xen/include/asm-x86/mach-default/mach_mpparse.h	Tue Mar 21 11:19:11 2006 -0700
   118.3 @@ -1,17 +1,6 @@
   118.4  #ifndef __ASM_MACH_MPPARSE_H
   118.5  #define __ASM_MACH_MPPARSE_H
   118.6  
   118.7 -static inline void mpc_oem_bus_info(struct mpc_config_bus *m, char *name, 
   118.8 -				struct mpc_config_translation *translation)
   118.9 -{
  118.10 -//	Dprintk("Bus #%d is %s\n", m->mpc_busid, name);
  118.11 -}
  118.12 -
  118.13 -static inline void mpc_oem_pci_bus(struct mpc_config_bus *m, 
  118.14 -				struct mpc_config_translation *translation)
  118.15 -{
  118.16 -}
  118.17 -
  118.18  static inline int mps_oem_check(struct mp_config_table *mpc, char *oem, 
  118.19  		char *productid)
  118.20  {
   119.1 --- a/xen/include/asm-x86/mach-es7000/mach_apic.h	Tue Mar 21 09:55:44 2006 -0700
   119.2 +++ b/xen/include/asm-x86/mach-es7000/mach_apic.h	Tue Mar 21 11:19:11 2006 -0700
   119.3 @@ -89,11 +89,6 @@ static inline void clustered_apic_check(
   119.4  		"Physical Cluster" : "Logical Cluster", nr_ioapics, cpus_addr(TARGET_CPUS)[0]);
   119.5  }
   119.6  
   119.7 -static inline int multi_timer_check(int apic, int irq)
   119.8 -{
   119.9 -	return 0;
  119.10 -}
  119.11 -
  119.12  static inline int apicid_to_node(int logical_apicid)
  119.13  {
  119.14  	return 0;
  119.15 @@ -128,27 +123,12 @@ static inline int cpu_to_logical_apicid(
  119.16         return (int)cpu_2_logical_apicid[cpu];
  119.17  }
  119.18  
  119.19 -static inline int mpc_apic_id(struct mpc_config_processor *m, struct mpc_config_translation *unused)
  119.20 -{
  119.21 -	printk("Processor #%d %d:%d APIC version %d\n",
  119.22 -	        m->mpc_apicid,
  119.23 -	        (m->mpc_cpufeature & CPU_FAMILY_MASK) >> 8,
  119.24 -	        (m->mpc_cpufeature & CPU_MODEL_MASK) >> 4,
  119.25 -	        m->mpc_apicver);
  119.26 -	return (m->mpc_apicid);
  119.27 -}
  119.28 -
  119.29  static inline physid_mask_t ioapic_phys_id_map(physid_mask_t phys_map)
  119.30  {
  119.31  	/* For clustered we don't have a good way to do this yet - hack */
  119.32  	return physids_promote(0xff);
  119.33  }
  119.34  
  119.35 -
  119.36 -static inline void setup_portio_remap(void)
  119.37 -{
  119.38 -}
  119.39 -
  119.40  extern unsigned int boot_cpu_physical_apicid;
  119.41  static inline int check_phys_apicid_present(int cpu_physical_apicid)
  119.42  {
   120.1 --- a/xen/include/asm-x86/mach-es7000/mach_apicdef.h	Tue Mar 21 09:55:44 2006 -0700
   120.2 +++ b/xen/include/asm-x86/mach-es7000/mach_apicdef.h	Tue Mar 21 11:19:11 2006 -0700
   120.3 @@ -1,8 +1,6 @@
   120.4  #ifndef __ASM_MACH_APICDEF_H
   120.5  #define __ASM_MACH_APICDEF_H
   120.6  
   120.7 -#define		APIC_ID_MASK		(0xFF<<24)
   120.8 -
   120.9  static inline unsigned get_apic_id(unsigned long x) 
  120.10  { 
  120.11  	return (((x)>>24)&0xFF);
   121.1 --- a/xen/include/asm-x86/mach-es7000/mach_mpparse.h	Tue Mar 21 09:55:44 2006 -0700
   121.2 +++ b/xen/include/asm-x86/mach-es7000/mach_mpparse.h	Tue Mar 21 11:19:11 2006 -0700
   121.3 @@ -1,19 +1,11 @@
   121.4  #ifndef __ASM_MACH_MPPARSE_H
   121.5  #define __ASM_MACH_MPPARSE_H
   121.6  
   121.7 -static inline void mpc_oem_bus_info(struct mpc_config_bus *m, char *name, 
   121.8 -				struct mpc_config_translation *translation)
   121.9 -{
  121.10 -	Dprintk("Bus #%d is %s\n", m->mpc_busid, name);
  121.11 -}
  121.12 +#include <xen/acpi.h>
  121.13  
  121.14 -static inline void mpc_oem_pci_bus(struct mpc_config_bus *m, 
  121.15 -				struct mpc_config_translation *translation)
  121.16 -{
  121.17 -}
  121.18 -
  121.19 -extern int parse_unisys_oem (char *oemptr, int oem_entries);
  121.20 -extern int find_unisys_acpi_oem_table(unsigned long *oem_addr, int *length);
  121.21 +extern int parse_unisys_oem (char *oemptr);
  121.22 +extern int find_unisys_acpi_oem_table(unsigned long *oem_addr);
  121.23 +extern void setup_unisys(void);
  121.24  
  121.25  static inline int mps_oem_check(struct mp_config_table *mpc, char *oem,
  121.26  		char *productid)
  121.27 @@ -22,18 +14,33 @@ static inline int mps_oem_check(struct m
  121.28  		struct mp_config_oemtable *oem_table = 
  121.29  			(struct mp_config_oemtable *)(long)mpc->mpc_oemptr;
  121.30  		if (!strncmp(oem, "UNISYS", 6))
  121.31 -			return parse_unisys_oem((char *)oem_table, oem_table->oem_length);
  121.32 +			return parse_unisys_oem((char *)oem_table);
  121.33  	}
  121.34  	return 0;
  121.35  }
  121.36  
  121.37 +static inline int es7000_check_dsdt(void)
  121.38 +{
  121.39 +	struct acpi_table_header *header = NULL;
  121.40 +	if(!acpi_get_table_header_early(ACPI_DSDT, &header))
  121.41 +		acpi_table_print(header, 0);
  121.42 +	if (!strncmp(header->oem_id, "UNISYS", 6))
  121.43 +		return 1;
  121.44 +	return 0;
  121.45 +}
  121.46 +
  121.47  /* Hook from generic ACPI tables.c */
  121.48  static inline int acpi_madt_oem_check(char *oem_id, char *oem_table_id)
  121.49  {
  121.50  	unsigned long oem_addr; 
  121.51 -	int oem_entries;
  121.52 -	if (!find_unisys_acpi_oem_table(&oem_addr, &oem_entries))
  121.53 -		return parse_unisys_oem((char *)oem_addr, oem_entries);
  121.54 +	if (!find_unisys_acpi_oem_table(&oem_addr)) {
  121.55 +		if (es7000_check_dsdt())
  121.56 +			return parse_unisys_oem((char *)oem_addr);
  121.57 +		else {
  121.58 +			setup_unisys();
  121.59 +			return 1;
  121.60 +		}
  121.61 +	}
  121.62  	return 0;
  121.63  }
  121.64  
   122.1 --- a/xen/include/asm-x86/mach-generic/mach_apic.h	Tue Mar 21 09:55:44 2006 -0700
   122.2 +++ b/xen/include/asm-x86/mach-generic/mach_apic.h	Tue Mar 21 11:19:11 2006 -0700
   122.3 @@ -14,13 +14,10 @@
   122.4  #define init_apic_ldr (genapic->init_apic_ldr)
   122.5  #define ioapic_phys_id_map (genapic->ioapic_phys_id_map)
   122.6  #define clustered_apic_check (genapic->clustered_apic_check) 
   122.7 -#define multi_timer_check (genapic->multi_timer_check)
   122.8  #define apicid_to_node (genapic->apicid_to_node)
   122.9  #define cpu_to_logical_apicid (genapic->cpu_to_logical_apicid) 
  122.10  #define cpu_present_to_apicid (genapic->cpu_present_to_apicid)
  122.11  #define apicid_to_cpu_present (genapic->apicid_to_cpu_present)
  122.12 -#define mpc_apic_id (genapic->mpc_apic_id) 
  122.13 -#define setup_portio_remap (genapic->setup_portio_remap)
  122.14  #define check_apicid_present (genapic->check_apicid_present)
  122.15  #define check_phys_apicid_present (genapic->check_phys_apicid_present)
  122.16  #define check_apicid_used (genapic->check_apicid_used)
  122.17 @@ -28,6 +25,26 @@
  122.18  #define enable_apic_mode (genapic->enable_apic_mode)
  122.19  #define phys_pkg_id (genapic->phys_pkg_id)
  122.20  
  122.21 +static inline int mpc_apic_id(struct mpc_config_processor *m, 
  122.22 +			struct mpc_config_translation *translation_record)
  122.23 +{
  122.24 +	printk("Processor #%d %d:%d APIC version %d\n",
  122.25 +			m->mpc_apicid,
  122.26 +			(m->mpc_cpufeature & CPU_FAMILY_MASK) >> 8,
  122.27 +			(m->mpc_cpufeature & CPU_MODEL_MASK) >> 4,
  122.28 +			m->mpc_apicver);
  122.29 +	return (m->mpc_apicid);
  122.30 +}
  122.31 +
  122.32 +static inline void setup_portio_remap(void)
  122.33 +{
  122.34 +}
  122.35 +
  122.36 +static inline int multi_timer_check(int apic, int irq)
  122.37 +{
  122.38 +	return 0;
  122.39 +}
  122.40 +
  122.41  extern void generic_bigsmp_probe(void);
  122.42  
  122.43  #endif /* __ASM_MACH_APIC_H */
   123.1 --- a/xen/include/asm-x86/mach-generic/mach_apicdef.h	Tue Mar 21 09:55:44 2006 -0700
   123.2 +++ b/xen/include/asm-x86/mach-generic/mach_apicdef.h	Tue Mar 21 11:19:11 2006 -0700
   123.3 @@ -5,7 +5,6 @@
   123.4  #include <asm/genapic.h>
   123.5  
   123.6  #define GET_APIC_ID (genapic->get_apic_id)
   123.7 -#define APIC_ID_MASK (genapic->apic_id_mask)
   123.8  #endif
   123.9  
  123.10  #endif
   124.1 --- a/xen/include/asm-x86/mach-generic/mach_mpparse.h	Tue Mar 21 09:55:44 2006 -0700
   124.2 +++ b/xen/include/asm-x86/mach-generic/mach_mpparse.h	Tue Mar 21 11:19:11 2006 -0700
   124.3 @@ -1,10 +1,16 @@
   124.4  #ifndef _MACH_MPPARSE_H
   124.5  #define _MACH_MPPARSE_H 1
   124.6  
   124.7 -#include <asm/genapic.h>
   124.8 +static inline void mpc_oem_bus_info(struct mpc_config_bus *m, char *name, 
   124.9 +				struct mpc_config_translation *translation)
  124.10 +{
  124.11 +	Dprintk("Bus #%d is %s\n", m->mpc_busid, name);
  124.12 +}
  124.13  
  124.14 -#define mpc_oem_bus_info (genapic->mpc_oem_bus_info)
  124.15 -#define mpc_oem_pci_bus (genapic->mpc_oem_pci_bus)
  124.16 +static inline void mpc_oem_pci_bus(struct mpc_config_bus *m, 
  124.17 +				struct mpc_config_translation *translation)
  124.18 +{
  124.19 +}
  124.20  
  124.21  int mps_oem_check(struct mp_config_table *mpc, char *oem, char *productid); 
  124.22  int acpi_madt_oem_check(char *oem_id, char *oem_table_id); 
   125.1 --- a/xen/include/asm-x86/mach-summit/mach_apic.h	Tue Mar 21 09:55:44 2006 -0700
   125.2 +++ b/xen/include/asm-x86/mach-summit/mach_apic.h	Tue Mar 21 11:19:11 2006 -0700
   125.3 @@ -68,11 +68,6 @@ static inline void init_apic_ldr(void)
   125.4  	apic_write_around(APIC_LDR, val);
   125.5  }
   125.6  
   125.7 -static inline int multi_timer_check(int apic, int irq)
   125.8 -{
   125.9 -	return 0;
  125.10 -}
  125.11 -
  125.12  static inline int apic_id_registered(void)
  125.13  {
  125.14  	return 1;
  125.15 @@ -116,21 +111,6 @@ static inline physid_mask_t apicid_to_cp
  125.16  	return physid_mask_of_physid(0);
  125.17  }
  125.18  
  125.19 -static inline int mpc_apic_id(struct mpc_config_processor *m, 
  125.20 -			struct mpc_config_translation *translation_record)
  125.21 -{
  125.22 -	printk("Processor #%d %d:%d APIC version %d\n",
  125.23 -			m->mpc_apicid,
  125.24 -			(m->mpc_cpufeature & CPU_FAMILY_MASK) >> 8,
  125.25 -			(m->mpc_cpufeature & CPU_MODEL_MASK) >> 4,
  125.26 -			m->mpc_apicver);
  125.27 -	return (m->mpc_apicid);
  125.28 -}
  125.29 -
  125.30 -static inline void setup_portio_remap(void)
  125.31 -{
  125.32 -}
  125.33 -
  125.34  static inline int check_phys_apicid_present(int boot_cpu_physical_apicid)
  125.35  {
  125.36  	return 1;
   126.1 --- a/xen/include/asm-x86/mach-summit/mach_apicdef.h	Tue Mar 21 09:55:44 2006 -0700
   126.2 +++ b/xen/include/asm-x86/mach-summit/mach_apicdef.h	Tue Mar 21 11:19:11 2006 -0700
   126.3 @@ -1,8 +1,6 @@
   126.4  #ifndef __ASM_MACH_APICDEF_H
   126.5  #define __ASM_MACH_APICDEF_H
   126.6  
   126.7 -#define		APIC_ID_MASK		(0xFF<<24)
   126.8 -
   126.9  static inline unsigned get_apic_id(unsigned long x) 
  126.10  { 
  126.11  	return (((x)>>24)&0xFF);
   127.1 --- a/xen/include/asm-x86/mach-summit/mach_mpparse.h	Tue Mar 21 09:55:44 2006 -0700
   127.2 +++ b/xen/include/asm-x86/mach-summit/mach_mpparse.h	Tue Mar 21 11:19:11 2006 -0700
   127.3 @@ -11,17 +11,6 @@ extern void setup_summit(void);
   127.4  #define setup_summit()	{}
   127.5  #endif
   127.6  
   127.7 -static inline void mpc_oem_bus_info(struct mpc_config_bus *m, char *name, 
   127.8 -				struct mpc_config_translation *translation)
   127.9 -{
  127.10 -	Dprintk("Bus #%d is %s\n", m->mpc_busid, name);
  127.11 -}
  127.12 -
  127.13 -static inline void mpc_oem_pci_bus(struct mpc_config_bus *m, 
  127.14 -				struct mpc_config_translation *translation)
  127.15 -{
  127.16 -}
  127.17 -
  127.18  extern int usb_early_handoff;
  127.19  static inline int mps_oem_check(struct mp_config_table *mpc, char *oem, 
  127.20  		char *productid)
   128.1 --- a/xen/include/xen/irq.h	Tue Mar 21 09:55:44 2006 -0700
   128.2 +++ b/xen/include/xen/irq.h	Tue Mar 21 11:19:11 2006 -0700
   128.3 @@ -71,6 +71,5 @@ struct vcpu;
   128.4  extern int pirq_guest_unmask(struct domain *p);
   128.5  extern int pirq_guest_bind(struct vcpu *p, int irq, int will_share);
   128.6  extern int pirq_guest_unbind(struct domain *p, int irq);
   128.7 -extern  fastcall unsigned int __do_IRQ(unsigned int irq, struct pt_regs *regs);
   128.8  
   128.9  #endif /* __XEN_IRQ_H__ */
   129.1 --- a/xen/include/xen/smp.h	Tue Mar 21 09:55:44 2006 -0700
   129.2 +++ b/xen/include/xen/smp.h	Tue Mar 21 11:19:11 2006 -0700
   129.3 @@ -45,33 +45,35 @@ extern void smp_cpus_done(unsigned int m
   129.4   * Call a function on all other processors
   129.5   */
   129.6  extern int smp_call_function(
   129.7 -    void (*func) (void *info), void *info, int retry, int wait);
   129.8 +    void (*func) (void *info),
   129.9 +    void *info,
  129.10 +    int retry,
  129.11 +    int wait);
  129.12 +
  129.13 +/* 
  129.14 + * Call a function on a selection of processors
  129.15 + */
  129.16 +extern int on_selected_cpus(
  129.17 +    cpumask_t selected,
  129.18 +    void (*func) (void *info),
  129.19 +    void *info,
  129.20 +    int retry,
  129.21 +    int wait);
  129.22  
  129.23  /*
  129.24   * Call a function on all processors
  129.25   */
  129.26 -static inline int on_each_cpu(void (*func) (void *info), void *info,
  129.27 -                              int retry, int wait)
  129.28 +static inline int on_each_cpu(
  129.29 +    void (*func) (void *info),
  129.30 +    void *info,
  129.31 +    int retry,
  129.32 +    int wait)
  129.33  {
  129.34      int ret = smp_call_function(func, info, retry, wait);
  129.35      func(info);
  129.36      return ret;
  129.37  }
  129.38  
  129.39 -extern volatile unsigned long smp_msg_data;
  129.40 -extern volatile int smp_src_cpu;
  129.41 -extern volatile int smp_msg_id;
  129.42 -
  129.43 -#define MSG_ALL_BUT_SELF	0x8000	/* Assume <32768 CPU's */
  129.44 -#define MSG_ALL			0x8001
  129.45 -
  129.46 -#define MSG_INVALIDATE_TLB	0x0001	/* Remote processor TLB invalidate */
  129.47 -#define MSG_STOP_CPU		0x0002	/* Sent to shut down slave CPU's
  129.48 -					 * when rebooting
  129.49 -					 */
  129.50 -#define MSG_RESCHEDULE		0x0003	/* Reschedule request from master CPU*/
  129.51 -#define MSG_CALL_FUNCTION       0x0004  /* Call function on all other CPUs */
  129.52 -
  129.53  /*
  129.54   * Mark the boot cpu "online" so that it can call console drivers in
  129.55   * printk() and can access its per-cpu storage.
  129.56 @@ -93,6 +95,18 @@ void smp_prepare_boot_cpu(void);
  129.57  #define num_booting_cpus()			1
  129.58  #define smp_prepare_boot_cpu()			do {} while (0)
  129.59  
  129.60 +static inline int on_selected_cpus(
  129.61 +    cpumask_t selected,
  129.62 +    void (*func) (void *info),
  129.63 +    void *info,
  129.64 +    int retry,
  129.65 +    int wait)
  129.66 +{
  129.67 +    if ( cpu_isset(0, selected) )
  129.68 +        func(info);
  129.69 +    return 0;
  129.70 +}
  129.71 +
  129.72  #endif
  129.73  
  129.74  #define smp_processor_id() raw_smp_processor_id()