WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] merge

# HG changeset patch
# User awilliam@xxxxxxxxxxx
# Node ID a9f5cf43451f228140f221ce8c92c290bf0ab247
# Parent  f163677f87672d000ea77179690663663ab42a1a
# Parent  5e5e56b5e7516c0569b766a52079595e4ff1b955
merge

diff -r f163677f8767 -r a9f5cf43451f .hgignore
--- a/.hgignore Tue Mar 21 16:55:44 2006
+++ b/.hgignore Tue Mar 21 18:19:11 2006
@@ -13,6 +13,7 @@
 .*\.flc$
 .*\.orig$
 .*\.rej$
+.*/a\.out$
 ^[^/]*\.bz2$
 ^TAGS$
 ^dist/.*$
diff -r f163677f8767 -r a9f5cf43451f buildconfigs/Rules.mk
--- a/buildconfigs/Rules.mk     Tue Mar 21 16:55:44 2006
+++ b/buildconfigs/Rules.mk     Tue Mar 21 18:19:11 2006
@@ -70,7 +70,7 @@
        rm -rf tmp-pristine-$* $(@D)
        mkdir -p tmp-pristine-$*
        tar -C tmp-pristine-$* -jxf $<
-       -@rm tmp-pristine-$*/pax_global_header
+       -@rm -f tmp-pristine-$*/pax_global_header
        mv tmp-pristine-$*/* $(@D)
        @rm -rf tmp-pristine-$*
        touch $(@D)/.hgskip
diff -r f163677f8767 -r a9f5cf43451f buildconfigs/linux-defconfig_xen0_x86_32
--- a/buildconfigs/linux-defconfig_xen0_x86_32  Tue Mar 21 16:55:44 2006
+++ b/buildconfigs/linux-defconfig_xen0_x86_32  Tue Mar 21 18:19:11 2006
@@ -1328,6 +1328,7 @@
 # CONFIG_XEN_TPMDEV_FRONTEND is not set
 CONFIG_XEN_SCRUB_PAGES=y
 CONFIG_XEN_DISABLE_SERIAL=y
+CONFIG_XEN_SYSFS=y
 CONFIG_HAVE_ARCH_ALLOC_SKB=y
 CONFIG_HAVE_ARCH_DEV_ALLOC_SKB=y
 
diff -r f163677f8767 -r a9f5cf43451f buildconfigs/linux-defconfig_xen0_x86_64
--- a/buildconfigs/linux-defconfig_xen0_x86_64  Tue Mar 21 16:55:44 2006
+++ b/buildconfigs/linux-defconfig_xen0_x86_64  Tue Mar 21 18:19:11 2006
@@ -1253,6 +1253,7 @@
 # CONFIG_XEN_TPMDEV_FRONTEND is not set
 CONFIG_XEN_SCRUB_PAGES=y
 CONFIG_XEN_DISABLE_SERIAL=y
+CONFIG_XEN_SYSFS=y
 CONFIG_HAVE_ARCH_ALLOC_SKB=y
 CONFIG_HAVE_ARCH_DEV_ALLOC_SKB=y
 
diff -r f163677f8767 -r a9f5cf43451f buildconfigs/linux-defconfig_xenU_x86_32
--- a/buildconfigs/linux-defconfig_xenU_x86_32  Tue Mar 21 16:55:44 2006
+++ b/buildconfigs/linux-defconfig_xenU_x86_32  Tue Mar 21 18:19:11 2006
@@ -868,6 +868,7 @@
 # CONFIG_XEN_TPMDEV_FRONTEND is not set
 CONFIG_XEN_SCRUB_PAGES=y
 CONFIG_XEN_DISABLE_SERIAL=y
+CONFIG_XEN_SYSFS=y
 CONFIG_HAVE_ARCH_ALLOC_SKB=y
 CONFIG_HAVE_ARCH_DEV_ALLOC_SKB=y
 
diff -r f163677f8767 -r a9f5cf43451f buildconfigs/linux-defconfig_xenU_x86_64
--- a/buildconfigs/linux-defconfig_xenU_x86_64  Tue Mar 21 16:55:44 2006
+++ b/buildconfigs/linux-defconfig_xenU_x86_64  Tue Mar 21 18:19:11 2006
@@ -1144,6 +1144,7 @@
 # CONFIG_XEN_TPMDEV_FRONTEND is not set
 CONFIG_XEN_SCRUB_PAGES=y
 CONFIG_XEN_DISABLE_SERIAL=y
+CONFIG_XEN_SYSFS=y
 CONFIG_HAVE_ARCH_ALLOC_SKB=y
 CONFIG_HAVE_ARCH_DEV_ALLOC_SKB=y
 
diff -r f163677f8767 -r a9f5cf43451f buildconfigs/linux-defconfig_xen_x86_32
--- a/buildconfigs/linux-defconfig_xen_x86_32   Tue Mar 21 16:55:44 2006
+++ b/buildconfigs/linux-defconfig_xen_x86_32   Tue Mar 21 18:19:11 2006
@@ -2994,6 +2994,7 @@
 # CONFIG_XEN_TPMDEV_FRONTEND is not set
 CONFIG_XEN_SCRUB_PAGES=y
 CONFIG_XEN_DISABLE_SERIAL=y
+CONFIG_XEN_SYSFS=m
 CONFIG_HAVE_ARCH_ALLOC_SKB=y
 CONFIG_HAVE_ARCH_DEV_ALLOC_SKB=y
 
diff -r f163677f8767 -r a9f5cf43451f buildconfigs/linux-defconfig_xen_x86_64
--- a/buildconfigs/linux-defconfig_xen_x86_64   Tue Mar 21 16:55:44 2006
+++ b/buildconfigs/linux-defconfig_xen_x86_64   Tue Mar 21 18:19:11 2006
@@ -2665,6 +2665,7 @@
 # CONFIG_XEN_TPMDEV_FRONTEND is not set
 CONFIG_XEN_SCRUB_PAGES=y
 CONFIG_XEN_DISABLE_SERIAL=y
+CONFIG_XEN_SYSFS=m
 CONFIG_HAVE_ARCH_ALLOC_SKB=y
 CONFIG_HAVE_ARCH_DEV_ALLOC_SKB=y
 
diff -r f163677f8767 -r a9f5cf43451f buildconfigs/mk.linux-2.6-xen
--- a/buildconfigs/mk.linux-2.6-xen     Tue Mar 21 16:55:44 2006
+++ b/buildconfigs/mk.linux-2.6-xen     Tue Mar 21 18:19:11 2006
@@ -2,9 +2,8 @@
 OS           = linux
 
 LINUX_SERIES = 2.6
-LINUX_VER    = 2.6.16-rc5
-LINUX_SRCS = linux-2.6.15.tar.bz2 patch-2.6.16-rc5.bz2
-LINUX_PDIR = linux-$(LINUX_VER)
+LINUX_VER    = 2.6.16
+LINUX_SRCS = linux-2.6.16.tar.bz2
 
 EXTRAVERSION ?= xen
 
@@ -22,20 +21,6 @@
        fi
        $(MAKE) -C $(LINUX_DIR) ARCH=$(LINUX_ARCH) INSTALL_PATH=$(DESTDIR) 
vmlinuz
        $(MAKE) -C $(LINUX_DIR) ARCH=$(LINUX_ARCH) INSTALL_PATH=$(DESTDIR) 
install
-
-pristine-$(LINUX_PDIR)/.valid-srcs: $(LINUX_SRCS)
-       rm -rf tmp-pristine-$(LINUX_PDIR) $(@D)
-       mkdir -p tmp-pristine-$(LINUX_PDIR)
-       tar -C tmp-pristine-$(LINUX_PDIR) -jxf $<
-       -@rm tmp-pristine-$(LINUX_PDIR)/pax_global_header
-       mv tmp-pristine-$(LINUX_PDIR)/* $(@D)
-       @rm -rf tmp-pristine-$(LINUX_PDIR)
-       bzcat $(wordlist 2,$(words $^),$^) | patch -d $(@D) -p1
-       touch $(@D)/.hgskip
-       touch $@
-
-pristine-linux-%.16-rc5/.valid-pristine: pristine-$(LINUX_PDIR)/.valid-srcs
-       touch $@ # update timestamp to avoid rebuild
 
 $(LINUX_DIR)/include/linux/autoconf.h: ref-$(OS)-$(LINUX_VER)/.valid-ref
        rm -rf $(LINUX_DIR)
diff -r f163677f8767 -r a9f5cf43451f 
linux-2.6-xen-sparse/arch/i386/kernel/Makefile
--- a/linux-2.6-xen-sparse/arch/i386/kernel/Makefile    Tue Mar 21 16:55:44 2006
+++ b/linux-2.6-xen-sparse/arch/i386/kernel/Makefile    Tue Mar 21 18:19:11 2006
@@ -11,7 +11,7 @@
 
 obj-y                          += cpu/
 obj-y                          += timers/
-obj-$(CONFIG_ACPI)             += acpi/
+obj-y                          += acpi/
 obj-$(CONFIG_X86_BIOS_REBOOT)  += reboot.o
 obj-$(CONFIG_MCA)              += mca.o
 obj-$(CONFIG_X86_MSR)          += msr.o
diff -r f163677f8767 -r a9f5cf43451f 
linux-2.6-xen-sparse/arch/i386/kernel/acpi/Makefile
--- a/linux-2.6-xen-sparse/arch/i386/kernel/acpi/Makefile       Tue Mar 21 
16:55:44 2006
+++ b/linux-2.6-xen-sparse/arch/i386/kernel/acpi/Makefile       Tue Mar 21 
18:19:11 2006
@@ -1,4 +1,4 @@
-obj-y                          := boot.o
+obj-$(CONFIG_ACPI)             += boot.o
 obj-$(CONFIG_X86_IO_APIC)      += earlyquirk.o
 obj-$(CONFIG_ACPI_SLEEP)       += sleep.o wakeup.o
 
diff -r f163677f8767 -r a9f5cf43451f 
linux-2.6-xen-sparse/arch/i386/kernel/acpi/boot-xen.c
--- a/linux-2.6-xen-sparse/arch/i386/kernel/acpi/boot-xen.c     Tue Mar 21 
16:55:44 2006
+++ b/linux-2.6-xen-sparse/arch/i386/kernel/acpi/boot-xen.c     Tue Mar 21 
18:19:11 2006
@@ -44,6 +44,9 @@
 extern int gsi_irq_sharing(int gsi);
 #include <asm/proto.h>
 
+static inline int acpi_madt_oem_check(char *oem_id, char *oem_table_id) { 
return 0; }
+
+
 #else                          /* X86 */
 
 #ifdef CONFIG_X86_LOCAL_APIC
@@ -1111,9 +1114,6 @@
                disable_acpi();
                return error;
        }
-#ifdef __i386__
-       check_acpi_pci();
-#endif
 
        acpi_table_parse(ACPI_BOOT, acpi_parse_sbf);
 
diff -r f163677f8767 -r a9f5cf43451f 
linux-2.6-xen-sparse/arch/i386/kernel/cpu/common-xen.c
--- a/linux-2.6-xen-sparse/arch/i386/kernel/cpu/common-xen.c    Tue Mar 21 
16:55:44 2006
+++ b/linux-2.6-xen-sparse/arch/i386/kernel/cpu/common-xen.c    Tue Mar 21 
18:19:11 2006
@@ -283,10 +283,10 @@
                        c->x86_capability[4] = excap;
                        c->x86 = (tfms >> 8) & 15;
                        c->x86_model = (tfms >> 4) & 15;
-                       if (c->x86 == 0xf) {
+                       if (c->x86 == 0xf)
                                c->x86 += (tfms >> 20) & 0xff;
+                       if (c->x86 >= 0x6)
                                c->x86_model += ((tfms >> 16) & 0xF) << 4;
-                       } 
                        c->x86_mask = tfms & 15;
                } else {
                        /* Have CPUID level 0 only - unheard of */
diff -r f163677f8767 -r a9f5cf43451f 
linux-2.6-xen-sparse/arch/i386/kernel/io_apic-xen.c
--- a/linux-2.6-xen-sparse/arch/i386/kernel/io_apic-xen.c       Tue Mar 21 
16:55:44 2006
+++ b/linux-2.6-xen-sparse/arch/i386/kernel/io_apic-xen.c       Tue Mar 21 
18:19:11 2006
@@ -92,6 +92,8 @@
 static struct { int pin, apic; } ioapic_i8259 = { -1, -1 };
 
 static DEFINE_SPINLOCK(ioapic_lock);
+
+int timer_over_8254 __initdata = 1;
 
 /*
  *     Is the SiS APIC rmw bug present ?
@@ -2329,7 +2331,8 @@
        apic_write_around(APIC_LVT0, APIC_LVT_MASKED | APIC_DM_EXTINT);
        init_8259A(1);
        timer_ack = 1;
-       enable_8259A_irq(0);
+       if (timer_over_8254 > 0)
+               enable_8259A_irq(0);
 
        pin1  = find_isa_irq_pin(0, mp_INT);
        apic1 = find_isa_irq_apic(0, mp_INT);
@@ -2459,6 +2462,20 @@
                print_IO_APIC();
 }
 
+static int __init setup_disable_8254_timer(char *s)
+{
+       timer_over_8254 = -1;
+       return 1;
+}
+static int __init setup_enable_8254_timer(char *s)
+{
+       timer_over_8254 = 2;
+       return 1;
+}
+
+__setup("disable_8254_timer", setup_disable_8254_timer);
+__setup("enable_8254_timer", setup_enable_8254_timer);
+
 /*
  *     Called after all the initialization is done. If we didnt find any
  *     APIC bugs then we can allow the modify fast path
diff -r f163677f8767 -r a9f5cf43451f 
linux-2.6-xen-sparse/arch/i386/kernel/microcode-xen.c
--- a/linux-2.6-xen-sparse/arch/i386/kernel/microcode-xen.c     Tue Mar 21 
16:55:44 2006
+++ b/linux-2.6-xen-sparse/arch/i386/kernel/microcode-xen.c     Tue Mar 21 
18:19:11 2006
@@ -25,6 +25,7 @@
 #include <linux/kernel.h>
 #include <linux/init.h>
 #include <linux/sched.h>
+#include <linux/cpumask.h>
 #include <linux/module.h>
 #include <linux/slab.h>
 #include <linux/vmalloc.h>
diff -r f163677f8767 -r a9f5cf43451f 
linux-2.6-xen-sparse/arch/i386/kernel/setup-xen.c
--- a/linux-2.6-xen-sparse/arch/i386/kernel/setup-xen.c Tue Mar 21 16:55:44 2006
+++ b/linux-2.6-xen-sparse/arch/i386/kernel/setup-xen.c Tue Mar 21 18:19:11 2006
@@ -1819,6 +1819,10 @@
        op.u.set_iopl.iopl = 1;
        HYPERVISOR_physdev_op(&op);
 
+#ifdef CONFIG_X86_IO_APIC
+       check_acpi_pci();       /* Checks more than just ACPI actually */
+#endif
+
 #ifdef CONFIG_ACPI
        if (!(xen_start_info->flags & SIF_INITDOMAIN)) {
                printk(KERN_INFO "ACPI in unprivileged domain disabled\n");
diff -r f163677f8767 -r a9f5cf43451f 
linux-2.6-xen-sparse/arch/i386/kernel/smpboot.c
--- a/linux-2.6-xen-sparse/arch/i386/kernel/smpboot.c   Tue Mar 21 16:55:44 2006
+++ b/linux-2.6-xen-sparse/arch/i386/kernel/smpboot.c   Tue Mar 21 18:19:11 2006
@@ -1029,6 +1029,16 @@
        int     apicid, ret;
 
        lock_cpu_hotplug();
+
+       /*
+        * On x86, CPU0 is never offlined.  Trying to bring up an
+        * already-booted CPU will hang.  So check for that case.
+        */
+       if (cpu_online(cpu)) {
+               ret = -EINVAL;
+               goto exit;
+       }
+
        apicid = x86_cpu_to_apicid[cpu];
        if (apicid == BAD_APICID) {
                ret = -ENODEV;
diff -r f163677f8767 -r a9f5cf43451f 
linux-2.6-xen-sparse/arch/i386/kernel/time-xen.c
--- a/linux-2.6-xen-sparse/arch/i386/kernel/time-xen.c  Tue Mar 21 16:55:44 2006
+++ b/linux-2.6-xen-sparse/arch/i386/kernel/time-xen.c  Tue Mar 21 18:19:11 2006
@@ -157,8 +157,8 @@
 }
 __setup("independent_wallclock", __independent_wallclock);
 
-/* Permitted clock jitter, in usecs, beyond which a warning will be printed. */
-static unsigned long permitted_clock_jitter = 10000UL;
+/* Permitted clock jitter, in nsecs, beyond which a warning will be printed. */
+static unsigned long permitted_clock_jitter = 10000000UL; /* 10ms */
 static int __init __permitted_clock_jitter(char *str)
 {
        permitted_clock_jitter = simple_strtoul(str, NULL, 0);
@@ -840,9 +840,9 @@
        write_seqlock_irqsave(&xtime_lock, flags);
        xtime.tv_sec = sec;
        xtime.tv_nsec = 0;
+       jiffies_64 += sleep_length;
+       wall_jiffies += sleep_length;
        write_sequnlock_irqrestore(&xtime_lock, flags);
-       jiffies += sleep_length;
-       wall_jiffies += sleep_length;
        if (last_timer->resume)
                last_timer->resume();
        cur_timer = last_timer;
diff -r f163677f8767 -r a9f5cf43451f 
linux-2.6-xen-sparse/arch/i386/mm/init-xen.c
--- a/linux-2.6-xen-sparse/arch/i386/mm/init-xen.c      Tue Mar 21 16:55:44 2006
+++ b/linux-2.6-xen-sparse/arch/i386/mm/init-xen.c      Tue Mar 21 18:19:11 2006
@@ -42,6 +42,11 @@
 #include <asm/tlbflush.h>
 #include <asm/sections.h>
 #include <asm/hypervisor.h>
+#if defined(CONFIG_SWIOTLB)
+#include <linux/dma-mapping.h>
+#include <asm/scatterlist.h>
+#include <asm/swiotlb.h>
+#endif
 
 extern unsigned long *contiguous_bitmap;
 
diff -r f163677f8767 -r a9f5cf43451f 
linux-2.6-xen-sparse/arch/x86_64/kernel/entry-xen.S
--- a/linux-2.6-xen-sparse/arch/x86_64/kernel/entry-xen.S       Tue Mar 21 
16:55:44 2006
+++ b/linux-2.6-xen-sparse/arch/x86_64/kernel/entry-xen.S       Tue Mar 21 
18:19:11 2006
@@ -818,7 +818,7 @@
        jmp  error_exit
 
 #ifdef CONFIG_X86_LOCAL_APIC
-ENTRY(nmi)
+KPROBE_ENTRY(nmi)
        zeroentry do_nmi_callback
 ENTRY(do_nmi_callback)
         addq $8, %rsp
@@ -828,6 +828,7 @@
         XEN_BLOCK_EVENTS(%rsi)
         GET_THREAD_INFO(%rcx)
         jmp  retint_restore_args
+       .previous .text
 #endif
 
         ALIGN
diff -r f163677f8767 -r a9f5cf43451f linux-2.6-xen-sparse/drivers/char/tty_io.c
--- a/linux-2.6-xen-sparse/drivers/char/tty_io.c        Tue Mar 21 16:55:44 2006
+++ b/linux-2.6-xen-sparse/drivers/char/tty_io.c        Tue Mar 21 18:19:11 2006
@@ -305,7 +305,7 @@
                        t->commit = 0;
                        t->read = 0;
                        /* DEBUG ONLY */
-                       memset(t->data, '*', size);
+/*                     memset(t->data, '*', size); */
 /*                     printk("Flip recycle %p\n", t); */
                        return t;
                }
diff -r f163677f8767 -r a9f5cf43451f linux-2.6-xen-sparse/drivers/xen/Kconfig
--- a/linux-2.6-xen-sparse/drivers/xen/Kconfig  Tue Mar 21 16:55:44 2006
+++ b/linux-2.6-xen-sparse/drivers/xen/Kconfig  Tue Mar 21 18:19:11 2006
@@ -189,6 +189,14 @@
          Disable serial port drivers, allowing the Xen console driver
          to provide a serial console at ttyS0.
 
+config XEN_SYSFS
+       tristate "Export Xen attributes in sysfs"
+       depends on XEN
+       depends on SYSFS
+       default y
+       help
+               Xen hypervisor attributes will show up under /sys/hypervisor/.
+
 endmenu
 
 config HAVE_ARCH_ALLOC_SKB
diff -r f163677f8767 -r a9f5cf43451f 
linux-2.6-xen-sparse/drivers/xen/core/Makefile
--- a/linux-2.6-xen-sparse/drivers/xen/core/Makefile    Tue Mar 21 16:55:44 2006
+++ b/linux-2.6-xen-sparse/drivers/xen/core/Makefile    Tue Mar 21 18:19:11 2006
@@ -7,3 +7,5 @@
 obj-$(CONFIG_PROC_FS) += xen_proc.o
 obj-$(CONFIG_NET)     += skbuff.o
 obj-$(CONFIG_SMP)     += smpboot.o
+obj-$(CONFIG_SYSFS)   += hypervisor_sysfs.o
+obj-$(CONFIG_XEN_SYSFS) += xen_sysfs.o
diff -r f163677f8767 -r a9f5cf43451f 
linux-2.6-xen-sparse/drivers/xen/netback/xenbus.c
--- a/linux-2.6-xen-sparse/drivers/xen/netback/xenbus.c Tue Mar 21 16:55:44 2006
+++ b/linux-2.6-xen-sparse/drivers/xen/netback/xenbus.c Tue Mar 21 18:19:11 2006
@@ -213,7 +213,8 @@
                break;
 
        case XenbusStateClosed:
-               kobject_uevent(&dev->dev.kobj, KOBJ_OFFLINE);
+               if (be->netif != NULL)
+                       kobject_uevent(&dev->dev.kobj, KOBJ_OFFLINE);
                device_unregister(&dev->dev);
                break;
 
diff -r f163677f8767 -r a9f5cf43451f 
linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_dev.c
--- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_dev.c      Tue Mar 21 
16:55:44 2006
+++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_dev.c      Tue Mar 21 
18:19:11 2006
@@ -36,6 +36,7 @@
 #include <linux/notifier.h>
 #include <linux/wait.h>
 #include <linux/fs.h>
+#include <linux/poll.h>
 
 #include "xenbus_comms.h"
 
@@ -207,11 +208,22 @@
        return 0;
 }
 
+static unsigned int xenbus_dev_poll(struct file *file, poll_table *wait)
+{
+       struct xenbus_dev_data *u = file->private_data;
+
+       poll_wait(file, &u->read_waitq, wait);
+       if (u->read_cons != u->read_prod)
+               return POLLIN | POLLRDNORM;
+       return 0;
+}
+
 static struct file_operations xenbus_dev_file_ops = {
        .read = xenbus_dev_read,
        .write = xenbus_dev_write,
        .open = xenbus_dev_open,
        .release = xenbus_dev_release,
+       .poll = xenbus_dev_poll,
 };
 
 static int __init
diff -r f163677f8767 -r a9f5cf43451f 
linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c
--- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c    Tue Mar 21 
16:55:44 2006
+++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c    Tue Mar 21 
18:19:11 2006
@@ -1049,6 +1049,8 @@
                if (xsd_port_intf)
                        xsd_port_intf->read_proc = xsd_port_read;
        }
+       else
+               xenstored_ready = 1;
 
        /* Initialize the interface to xenstore. */
        err = xs_init();
@@ -1058,10 +1060,8 @@
                return err;
        }
 
-       if (!dom0) {
-               xenstored_ready = 1;
+       if (!dom0)
                xenbus_probe(NULL);
-       }
 
        return 0;
 }
diff -r f163677f8767 -r a9f5cf43451f 
linux-2.6-xen-sparse/include/asm-i386/apic.h
--- a/linux-2.6-xen-sparse/include/asm-i386/apic.h      Tue Mar 21 16:55:44 2006
+++ b/linux-2.6-xen-sparse/include/asm-i386/apic.h      Tue Mar 21 18:19:11 2006
@@ -139,6 +139,8 @@
 #define ARCH_APICTIMER_STOPS_ON_C3     1
 #endif
 
+extern int timer_over_8254;
+
 #else /* !CONFIG_X86_LOCAL_APIC */
 static inline void lapic_shutdown(void) { }
 
diff -r f163677f8767 -r a9f5cf43451f linux-2.6-xen-sparse/include/linux/gfp.h
--- a/linux-2.6-xen-sparse/include/linux/gfp.h  Tue Mar 21 16:55:44 2006
+++ b/linux-2.6-xen-sparse/include/linux/gfp.h  Tue Mar 21 18:19:11 2006
@@ -161,9 +161,9 @@
 
 void page_alloc_init(void);
 #ifdef CONFIG_NUMA
-void drain_remote_pages(void);
+void drain_node_pages(int node);
 #else
-static inline void drain_remote_pages(void) { };
+static inline void drain_node_pages(int node) { };
 #endif
 
 #endif /* __LINUX_GFP_H */
diff -r f163677f8767 -r a9f5cf43451f linux-2.6-xen-sparse/mm/memory.c
--- a/linux-2.6-xen-sparse/mm/memory.c  Tue Mar 21 16:55:44 2006
+++ b/linux-2.6-xen-sparse/mm/memory.c  Tue Mar 21 18:19:11 2006
@@ -624,10 +624,11 @@
                        (*zap_work)--;
                        continue;
                }
+
+               (*zap_work) -= PAGE_SIZE;
+
                if (pte_present(ptent)) {
                        struct page *page;
-
-                       (*zap_work) -= PAGE_SIZE;
 
                        page = vm_normal_page(vma, addr, ptent);
                        if (unlikely(details) && page) {
diff -r f163677f8767 -r a9f5cf43451f linux-2.6-xen-sparse/mm/page_alloc.c
--- a/linux-2.6-xen-sparse/mm/page_alloc.c      Tue Mar 21 16:55:44 2006
+++ b/linux-2.6-xen-sparse/mm/page_alloc.c      Tue Mar 21 18:19:11 2006
@@ -591,20 +591,19 @@
 }
 
 #ifdef CONFIG_NUMA
-/* Called from the slab reaper to drain remote pagesets */
-void drain_remote_pages(void)
-{
-       struct zone *zone;
-       int i;
+/*
+ * Called from the slab reaper to drain pagesets on a particular node that
+ * belong to the currently executing processor.
+ */
+void drain_node_pages(int nodeid)
+{
+       int i, z;
        unsigned long flags;
 
        local_irq_save(flags);
-       for_each_zone(zone) {
+       for (z = 0; z < MAX_NR_ZONES; z++) {
+               struct zone *zone = NODE_DATA(nodeid)->node_zones + z;
                struct per_cpu_pageset *pset;
-
-               /* Do not drain local pagesets */
-               if (zone->zone_pgdat->node_id == numa_node_id())
-                       continue;
 
                pset = zone_pcp(zone, smp_processor_id());
                for (i = 0; i < ARRAY_SIZE(pset->pcp); i++) {
diff -r f163677f8767 -r a9f5cf43451f tools/console/client/main.c
--- a/tools/console/client/main.c       Tue Mar 21 16:55:44 2006
+++ b/tools/console/client/main.c       Tue Mar 21 18:19:11 2006
@@ -242,7 +242,7 @@
 
        now = time(0);
        while (str_pty == NULL && (now + 5) > time(0)) {
-               struct timeval tv = { 0, 500 };
+               struct timeval tv = { 0, 250000 };
                select(0, NULL, NULL, NULL, &tv); /* pause briefly */
 
                str_pty = xs_read(xs, XBT_NULL, path, &len);
diff -r f163677f8767 -r a9f5cf43451f tools/firmware/rombios/apmbios.S
--- a/tools/firmware/rombios/apmbios.S  Tue Mar 21 16:55:44 2006
+++ b/tools/firmware/rombios/apmbios.S  Tue Mar 21 18:19:11 2006
@@ -217,14 +217,22 @@
 ; APM interface disconnect
 APMSYM(04):
   cmp al, #0x04
+  jne APMSYM(05)
+  jmp APMSYM(ok)
+
+;-----------------
+; APM cpu idle
+APMSYM(05):
+  cmp al, #0x05
   jne APMSYM(07)
+  hlt
   jmp APMSYM(ok)
 
 ;-----------------
 ; APM Set Power State
 APMSYM(07):
   cmp al, #0x07
-  jne APMSYM(0a)
+  jne APMSYM(08)
   
   cmp bx, #1
   jne APMSYM(ok)
@@ -265,6 +273,14 @@
   mov ax, #APMSYM(07_standby_str)
   call APMSYM(out_str)
   pop edx
+  jmp APMSYM(ok)
+
+;-----------------
+; APM Enable / Disable
+APMSYM(08):
+  cmp al, #0x08
+  jne APMSYM(0a)
+
   jmp APMSYM(ok)
 
 ;-----------------
@@ -297,11 +313,30 @@
 ; APM Driver Version
 APMSYM(0e):
   cmp al, #0x0e
-  jne APMSYM(unimplemented)
+  jne APMSYM(0f)
   
   mov ah, #1
   mov al, #2
   
+  jmp APMSYM(ok)
+
+;-----------------
+; APM Engage / Disengage
+APMSYM(0f):
+  cmp al, #0x0f
+  jne APMSYM(10)
+
+  jmp APMSYM(ok)
+
+;-----------------
+; APM Get Capabilities
+APMSYM(10):
+  cmp al, #0x10
+  jne APMSYM(unimplemented)
+
+  mov bl, #0
+  mov cx, #0
+
   jmp APMSYM(ok)
 
 ;-----------------
diff -r f163677f8767 -r a9f5cf43451f tools/firmware/rombios/rombios.c
--- a/tools/firmware/rombios/rombios.c  Tue Mar 21 16:55:44 2006
+++ b/tools/firmware/rombios/rombios.c  Tue Mar 21 18:19:11 2006
@@ -149,7 +149,7 @@
 #define BX_SUPPORT_FLOPPY 1
 #define BX_FLOPPY_ON_CNT 37   /* 2 seconds */
 #define BX_PCIBIOS       1
-#define BX_APM           0
+#define BX_APM           1
 
 #define BX_USE_ATADRV    1
 #define BX_ELTORITO_BOOT 1
diff -r f163677f8767 -r a9f5cf43451f tools/ioemu/hw/pcnet.h
--- a/tools/ioemu/hw/pcnet.h    Tue Mar 21 16:55:44 2006
+++ b/tools/ioemu/hw/pcnet.h    Tue Mar 21 18:19:11 2006
@@ -225,9 +225,11 @@
         ((uint32_t *)tmd)[3] = 0;
     }
     else
-    if (BCR_SWSTYLE(s) != 3)
-        cpu_physical_memory_read(addr, (void *)tmd, 16);
-    else {
+    if (BCR_SWSTYLE(s) != 3) {
+        ((uint32_t *)tmd)[2] = 0;
+        cpu_physical_memory_read(addr+4, (void *)&tmd->tmd1, 4);
+        cpu_physical_memory_read(addr, (void *)&tmd->tmd0, 4);
+    } else {
         uint32_t xda[4];
         cpu_physical_memory_read(addr,
                 (void *)&xda[0], sizeof(xda));
@@ -253,9 +255,10 @@
         cpu_physical_memory_set_dirty(addr+7);
     }
     else {
-        if (BCR_SWSTYLE(s) != 3)
-            cpu_physical_memory_write(addr, (void *)tmd, 16);
-        else {
+        if (BCR_SWSTYLE(s) != 3) {
+            cpu_physical_memory_write(addr+8, (void *)&tmd->tmd2, 4);
+            cpu_physical_memory_write(addr+4, (void *)&tmd->tmd1, 4);
+        } else {
             uint32_t xda[4];
             xda[0] = ((uint32_t *)tmd)[2];
             xda[1] = ((uint32_t *)tmd)[1];
@@ -282,9 +285,11 @@
         ((uint32_t *)rmd)[3] = 0;
     }
     else
-    if (BCR_SWSTYLE(s) != 3)
-        cpu_physical_memory_read(addr, (void *)rmd, 16);
-    else {
+    if (BCR_SWSTYLE(s) != 3) {
+        rmd->rmd2.zeros = 0;
+        cpu_physical_memory_read(addr+4, (void *)&rmd->rmd1, 4);
+        cpu_physical_memory_read(addr, (void *)&rmd->rmd0, 4);
+    } else {
         uint32_t rda[4];
         cpu_physical_memory_read(addr,
                 (void *)&rda[0], sizeof(rda));
@@ -310,9 +315,10 @@
         cpu_physical_memory_set_dirty(addr+7);
     }
     else {
-        if (BCR_SWSTYLE(s) != 3)
-            cpu_physical_memory_write(addr, (void *)rmd, 16);
-        else {
+        if (BCR_SWSTYLE(s) != 3) {
+            cpu_physical_memory_write(addr+8, (void *)&rmd->rmd2, 4);
+            cpu_physical_memory_write(addr+4, (void *)&rmd->rmd1, 4);
+        } else {
             uint32_t rda[4];
             rda[0] = ((uint32_t *)rmd)[2];
             rda[1] = ((uint32_t *)rmd)[1];
@@ -339,8 +345,7 @@
 #define CHECK_RMD(ADDR,RES) do {                \
     struct pcnet_RMD rmd;                       \
     RMDLOAD(&rmd,(ADDR));                       \
-    (RES) |= (rmd.rmd1.ones != 15)              \
-          || (rmd.rmd2.zeros != 0);             \
+    (RES) |= (rmd.rmd1.ones != 15);             \
 } while (0)
 
 #define CHECK_TMD(ADDR,RES) do {                \
diff -r f163677f8767 -r a9f5cf43451f tools/libxc/xc_hvm_build.c
--- a/tools/libxc/xc_hvm_build.c        Tue Mar 21 16:55:44 2006
+++ b/tools/libxc/xc_hvm_build.c        Tue Mar 21 18:19:11 2006
@@ -51,7 +51,7 @@
     char *elfbase, int xch, uint32_t dom, unsigned long *parray,
     struct domain_setup_info *dsi);
 
-static unsigned char build_e820map(void *e820_page, unsigned long mem_size)
+static unsigned char build_e820map(void *e820_page, unsigned long long 
mem_size)
 {
     struct e820entry *e820entry =
         (struct e820entry *)(((unsigned char *)e820_page) + E820_MAP_OFFSET);
@@ -81,11 +81,17 @@
 #define STATIC_PAGES    2       /* for ioreq_t and store_mfn */
     /* Most of the ram goes here */
     e820entry[nr_map].addr = 0x100000;
-    e820entry[nr_map].size = mem_size - 0x100000 - STATIC_PAGES*PAGE_SIZE;
+    e820entry[nr_map].size = mem_size - 0x100000 - STATIC_PAGES * PAGE_SIZE;
     e820entry[nr_map].type = E820_RAM;
     nr_map++;
 
     /* Statically allocated special pages */
+
+    /* For xenstore */
+    e820entry[nr_map].addr = mem_size - 2 * PAGE_SIZE;
+    e820entry[nr_map].size = PAGE_SIZE;
+    e820entry[nr_map].type = E820_XENSTORE;
+    nr_map++;
 
     /* Shared ioreq_t page */
     e820entry[nr_map].addr = mem_size - PAGE_SIZE;
@@ -93,12 +99,6 @@
     e820entry[nr_map].type = E820_SHARED_PAGE;
     nr_map++;
 
-    /* For xenstore */
-    e820entry[nr_map].addr = mem_size - 2*PAGE_SIZE;
-    e820entry[nr_map].size = PAGE_SIZE;
-    e820entry[nr_map].type = E820_XENSTORE;
-    nr_map++;
-
     e820entry[nr_map].addr = mem_size;
     e820entry[nr_map].size = 0x3 * PAGE_SIZE;
     e820entry[nr_map].type = E820_NVS;
@@ -117,8 +117,7 @@
     return (*(((unsigned char *)e820_page) + E820_MAP_NR_OFFSET) = nr_map);
 }
 
-static void
-set_hvm_info_checksum(struct hvm_info_table *t)
+static void set_hvm_info_checksum(struct hvm_info_table *t)
 {
     uint8_t *ptr = (uint8_t *)t, sum = 0;
     unsigned int i;
@@ -142,19 +141,16 @@
     char *va_map;
     struct hvm_info_table *va_hvm;
 
-
-    va_map = xc_map_foreign_range(
-        xc_handle,
-        dom,
-        PAGE_SIZE,
-        PROT_READ|PROT_WRITE,
-        pfn_list[HVM_INFO_PFN]);
+    va_map = xc_map_foreign_range(xc_handle, dom, PAGE_SIZE,
+                                  PROT_READ | PROT_WRITE,
+                                  pfn_list[HVM_INFO_PFN]);
 
     if ( va_map == NULL )
         return -1;
 
     va_hvm = (struct hvm_info_table *)(va_map + HVM_INFO_OFFSET);
     memset(va_hvm, 0, sizeof(*va_hvm));
+
     strncpy(va_hvm->signature, "HVM INFO", 8);
     va_hvm->length       = sizeof(struct hvm_info_table);
     va_hvm->acpi_enabled = acpi;
@@ -183,58 +179,59 @@
                        unsigned long *store_mfn)
 {
     unsigned long *page_array = NULL;
-
     unsigned long count, i;
+    unsigned long long ptr;
+    xc_mmu_t *mmu = NULL;
+
     shared_info_t *shared_info;
     void *e820_page;
     unsigned char e820_map_nr;
-    xc_mmu_t *mmu = NULL;
-    int rc;
 
     struct domain_setup_info dsi;
-    unsigned long v_end;
+    unsigned long long v_end;
 
     unsigned long shared_page_frame = 0;
     shared_iopage_t *sp;
 
     memset(&dsi, 0, sizeof(struct domain_setup_info));
 
-    if ( (rc = parseelfimage(image, image_size, &dsi)) != 0 )
-        goto error_out;
-
-    if ( (dsi.v_start & (PAGE_SIZE-1)) != 0 )
+    if ( (parseelfimage(image, image_size, &dsi)) != 0 )
+        goto error_out;
+
+    if ( (dsi.v_kernstart & (PAGE_SIZE - 1)) != 0 )
     {
         PERROR("Guest OS must load to a page boundary.\n");
         goto error_out;
     }
 
     /* memsize is in megabytes */
-    v_end              = (unsigned long)memsize << 20;
+    v_end = (unsigned long long)memsize << 20;
 
     printf("VIRTUAL MEMORY ARRANGEMENT:\n"
-           " Loaded HVM loader: %08lx->%08lx\n"
-           " TOTAL:         %08lx->%08lx\n",
+           "  Loaded HVM loader:    %08lx->%08lx\n"
+           "  TOTAL:                %08lx->%016llx\n",
            dsi.v_kernstart, dsi.v_kernend,
            dsi.v_start, v_end);
-    printf(" ENTRY ADDRESS: %08lx\n", dsi.v_kernentry);
-
-    if ( (v_end - dsi.v_start) > (nr_pages * PAGE_SIZE) )
-    {
-        ERROR("Initial guest OS requires too much space\n"
-               "(%luMB is greater than %luMB limit)\n",
-               (v_end-dsi.v_start)>>20, (nr_pages<<PAGE_SHIFT)>>20);
+    printf("  ENTRY ADDRESS:        %08lx\n", dsi.v_kernentry);
+
+    if ( (v_end - dsi.v_start) > ((unsigned long long)nr_pages << PAGE_SHIFT) )
+    {
+        PERROR("Initial guest OS requires too much space: "
+               "(%lluMB is greater than %lluMB limit)\n",
+               (unsigned long long)(v_end - dsi.v_start) >> 20,
+               ((unsigned long long)nr_pages << PAGE_SHIFT) >> 20);
         goto error_out;
     }
 
     if ( (page_array = malloc(nr_pages * sizeof(unsigned long))) == NULL )
     {
-        PERROR("Could not allocate memory");
+        PERROR("Could not allocate memory.\n");
         goto error_out;
     }
 
     if ( xc_get_pfn_list(xc_handle, dom, page_array, nr_pages) != nr_pages )
     {
-        PERROR("Could not get the page frame list");
+        PERROR("Could not get the page frame list.\n");
         goto error_out;
     }
 
@@ -246,20 +243,21 @@
     /* Write the machine->phys table entries. */
     for ( count = 0; count < nr_pages; count++ )
     {
+        ptr = (unsigned long long)page_array[count] << PAGE_SHIFT;
         if ( xc_add_mmu_update(xc_handle, mmu,
-                               (page_array[count] << PAGE_SHIFT) |
-                               MMU_MACHPHYS_UPDATE, count) )
+                               ptr | MMU_MACHPHYS_UPDATE, count) )
             goto error_out;
     }
 
-    if ( set_hvm_info(xc_handle, dom, page_array, vcpus, pae, acpi, apic) ) {
-        fprintf(stderr, "Couldn't set hvm info for HVM guest.\n");
+    if ( set_hvm_info(xc_handle, dom, page_array, vcpus, pae, acpi, apic) )
+    {
+        ERROR("Couldn't set hvm info for HVM guest.\n");
         goto error_out;
     }
 
     if ( (e820_page = xc_map_foreign_range(
-         xc_handle, dom, PAGE_SIZE, PROT_READ|PROT_WRITE,
-         page_array[E820_MAP_PAGE >> PAGE_SHIFT])) == 0 )
+              xc_handle, dom, PAGE_SIZE, PROT_READ | PROT_WRITE,
+              page_array[E820_MAP_PAGE >> PAGE_SHIFT])) == 0 )
         goto error_out;
     memset(e820_page, 0, PAGE_SIZE);
     e820_map_nr = build_e820map(e820_page, v_end);
@@ -267,8 +265,8 @@
 
     /* shared_info page starts its life empty. */
     if ( (shared_info = xc_map_foreign_range(
-         xc_handle, dom, PAGE_SIZE, PROT_READ|PROT_WRITE,
-         shared_info_frame)) == 0 )
+              xc_handle, dom, PAGE_SIZE, PROT_READ | PROT_WRITE,
+              shared_info_frame)) == 0 )
         goto error_out;
     memset(shared_info, 0, sizeof(shared_info_t));
     /* Mask all upcalls... */
@@ -279,8 +277,8 @@
     /* Populate the event channel port in the shared page */
     shared_page_frame = page_array[(v_end >> PAGE_SHIFT) - 1];
     if ( (sp = (shared_iopage_t *) xc_map_foreign_range(
-         xc_handle, dom, PAGE_SIZE, PROT_READ|PROT_WRITE,
-         shared_page_frame)) == 0 )
+              xc_handle, dom, PAGE_SIZE, PROT_READ | PROT_WRITE,
+              shared_page_frame)) == 0 )
         goto error_out;
     memset(sp, 0, PAGE_SIZE);
 
@@ -290,7 +288,7 @@
 
         vp_eport = xc_evtchn_alloc_unbound(xc_handle, dom, 0);
         if ( vp_eport < 0 ) {
-            fprintf(stderr, "Couldn't get unbound port from VMX guest.\n");
+            PERROR("Couldn't get unbound port from VMX guest.\n");
             goto error_out;
         }
         sp->vcpu_iodata[i].vp_eport = vp_eport;
diff -r f163677f8767 -r a9f5cf43451f tools/libxc/xc_ptrace.c
--- a/tools/libxc/xc_ptrace.c   Tue Mar 21 16:55:44 2006
+++ b/tools/libxc/xc_ptrace.c   Tue Mar 21 18:19:11 2006
@@ -251,35 +251,39 @@
     if (fetch_regs(xc_handle, cpu, NULL))
         return NULL;
 
-    if ( ctxt[cpu].ctrlreg[3] != cr3_phys[cpu] )
-    {
-        cr3_phys[cpu] = ctxt[cpu].ctrlreg[3];
-        if ( cr3_virt[cpu] )
-            munmap(cr3_virt[cpu], PAGE_SIZE);
-        cr3_virt[cpu] = xc_map_foreign_range(
-            xc_handle, current_domid, PAGE_SIZE, PROT_READ,
-            cr3_phys[cpu] >> PAGE_SHIFT);
-        if ( cr3_virt[cpu] == NULL )
+    if (paging_enabled(&ctxt[cpu])) {
+       if ( ctxt[cpu].ctrlreg[3] != cr3_phys[cpu] )
+        {
+            cr3_phys[cpu] = ctxt[cpu].ctrlreg[3];
+            if ( cr3_virt[cpu] )
+                munmap(cr3_virt[cpu], PAGE_SIZE);
+            cr3_virt[cpu] = xc_map_foreign_range(
+                xc_handle, current_domid, PAGE_SIZE, PROT_READ,
+                cr3_phys[cpu] >> PAGE_SHIFT);
+            if ( cr3_virt[cpu] == NULL )
+                return NULL;
+        }
+        if ( (pde = cr3_virt[cpu][vtopdi(va)]) == 0 )
             return NULL;
-    }
-    if ( (pde = cr3_virt[cpu][vtopdi(va)]) == 0 )
-        return NULL;
-    if ( (ctxt[cpu].flags & VGCF_HVM_GUEST) && paging_enabled(&ctxt[cpu]) )
-        pde = page_array[pde >> PAGE_SHIFT] << PAGE_SHIFT;
-    if ( pde != pde_phys[cpu] )
-    {
-        pde_phys[cpu] = pde;
-        if ( pde_virt[cpu] )
-            munmap(pde_virt[cpu], PAGE_SIZE);
-        pde_virt[cpu] = xc_map_foreign_range(
-            xc_handle, current_domid, PAGE_SIZE, PROT_READ,
-            pde_phys[cpu] >> PAGE_SHIFT);
-        if ( pde_virt[cpu] == NULL )
+        if ( (ctxt[cpu].flags & VGCF_HVM_GUEST) && paging_enabled(&ctxt[cpu]) )
+            pde = page_array[pde >> PAGE_SHIFT] << PAGE_SHIFT;
+        if ( pde != pde_phys[cpu] )
+        {
+            pde_phys[cpu] = pde;
+            if ( pde_virt[cpu] )
+                munmap(pde_virt[cpu], PAGE_SIZE);
+            pde_virt[cpu] = xc_map_foreign_range(
+                xc_handle, current_domid, PAGE_SIZE, PROT_READ,
+                pde_phys[cpu] >> PAGE_SHIFT);
+            if ( pde_virt[cpu] == NULL )
+                return NULL;
+        }
+        if ( (page = pde_virt[cpu][vtopti(va)]) == 0 )
             return NULL;
-    }
-    if ( (page = pde_virt[cpu][vtopti(va)]) == 0 )
-        return NULL;
-    if ( (ctxt[cpu].flags & VGCF_HVM_GUEST) && paging_enabled(&ctxt[cpu]) )
+    } else {
+        page = va;
+    }
+    if (ctxt[cpu].flags & VGCF_HVM_GUEST)
         page = page_array[page >> PAGE_SHIFT] << PAGE_SHIFT;
     if ( (page != page_phys[cpu]) || (perm != prev_perm[cpu]) )
     {
diff -r f163677f8767 -r a9f5cf43451f tools/python/xen/xend/XendDomainInfo.py
--- a/tools/python/xen/xend/XendDomainInfo.py   Tue Mar 21 16:55:44 2006
+++ b/tools/python/xen/xend/XendDomainInfo.py   Tue Mar 21 18:19:11 2006
@@ -24,6 +24,7 @@
 
 """
 
+import errno
 import logging
 import string
 import time
@@ -893,7 +894,7 @@
                 self.domid, timeout)
             threading.Timer(timeout, self.refreshShutdown).start()
 
-        return 1
+        return True
 
 
     def shutdown(self, reason):
@@ -1246,30 +1247,34 @@
         """Cleanup domain resources; release devices.  Idempotent.  Nothrow
         guarantee."""
 
-        self.unwatchShutdown()
-
-        self.release_devices()
-
-        if self.image:
+        self.refresh_shutdown_lock.acquire()
+        try:
+            self.unwatchShutdown()
+
+            self.release_devices()
+
+            if self.image:
+                try:
+                    self.image.destroy()
+                except:
+                    log.exception(
+                        "XendDomainInfo.cleanup: image.destroy() failed.")
+                self.image = None
+
             try:
-                self.image.destroy()
+                self.removeDom()
             except:
-                log.exception(
-                    "XendDomainInfo.cleanup: image.destroy() failed.")
-            self.image = None
-
-        try:
-            self.removeDom()
-        except:
-            log.exception("Removing domain path failed.")
-
-        try:
-            if not self.info['name'].startswith(ZOMBIE_PREFIX):
-                self.info['name'] = ZOMBIE_PREFIX + self.info['name']
-        except:
-            log.exception("Renaming Zombie failed.")
-
-        self.state_set(STATE_DOM_SHUTDOWN)
+                log.exception("Removing domain path failed.")
+
+            try:
+                if not self.info['name'].startswith(ZOMBIE_PREFIX):
+                    self.info['name'] = ZOMBIE_PREFIX + self.info['name']
+            except:
+                log.exception("Renaming Zombie failed.")
+
+            self.state_set(STATE_DOM_SHUTDOWN)
+        finally:
+            self.refresh_shutdown_lock.release()
 
 
     def cleanupVm(self):
@@ -1301,7 +1306,8 @@
 
     def unwatchShutdown(self):
         """Remove the watch on the domain's control/shutdown node, if any.
-        Idempotent.  Nothrow guarantee."""
+        Idempotent.  Nothrow guarantee.  Expects to be protected by the
+        refresh_shutdown_lock."""
 
         try:
             try:
diff -r f163677f8767 -r a9f5cf43451f tools/python/xen/xm/create.py
--- a/tools/python/xen/xm/create.py     Tue Mar 21 16:55:44 2006
+++ b/tools/python/xen/xm/create.py     Tue Mar 21 18:19:11 2006
@@ -14,7 +14,7 @@
 #============================================================================
 # Copyright (C) 2004, 2005 Mike Wray <mike.wray@xxxxxx>
 # Copyright (C) 2005 Nguyen Anh Quynh <aquynh@xxxxxxxxx>
-# Copyright (C) 2005 XenSource Ltd
+# Copyright (C) 2005-2006 XenSource Ltd
 #============================================================================
 
 """Domain creation.
@@ -27,8 +27,6 @@
 import commands
 import time
 import re
-
-import xen.lowlevel.xc
 
 from xen.xend import sxp
 from xen.xend import PrettyPrint
@@ -90,10 +88,6 @@
           SXP is the underlying configuration format used by Xen.
           SXP configurations can be hand-written or generated from Python 
configuration
           scripts, using the -n (dryrun) option to print the configuration.""")
-
-gopts.opt('load', short='L', val='FILE',
-          fn=set_value, default=None,
-          use='Domain saved state to load.')
 
 gopts.opt('dryrun', short='n',
           fn=set_true, default=0,
@@ -819,11 +813,7 @@
     """
 
     try:
-        if opts.vals.load:
-            filename = os.path.abspath(opts.vals.load)
-            dominfo = server.xend_domain_restore(filename, config)
-        else:
-            dominfo = server.xend_domain_create(config)
+        dominfo = server.xend_domain_create(config)
     except XendError, ex:
         import signal
         if vncpid:
diff -r f163677f8767 -r a9f5cf43451f tools/xm-test/lib/XmTestLib/XenDomain.py
--- a/tools/xm-test/lib/XmTestLib/XenDomain.py  Tue Mar 21 16:55:44 2006
+++ b/tools/xm-test/lib/XmTestLib/XenDomain.py  Tue Mar 21 18:19:11 2006
@@ -74,7 +74,7 @@
                     "vcpus"        : 1,
                     "acpi"         : 0,
                     "apic"         : 0,
-                    "disk"         : ["file:%s/disk.img,ioemu:%s,w" %
+                    "disk"         : ["file:%s/disk.img,ioemu:%s,w!" %
                                    (getRdPath(), BLOCK_ROOT_DEV)],
                     "kernel"       : "/usr/lib/xen/boot/hvmloader",
                     "builder"      : "hvm",
@@ -251,9 +251,6 @@
         if ENABLE_HVM_SUPPORT:
             waitForBoot()
 
-    def startNow(self):
-        XenDomain.start(self)
-
     def minSafeMem(self):
         return 16
 
diff -r f163677f8767 -r a9f5cf43451f tools/xm-test/lib/XmTestReport/Report.py
--- a/tools/xm-test/lib/XmTestReport/Report.py  Tue Mar 21 16:55:44 2006
+++ b/tools/xm-test/lib/XmTestReport/Report.py  Tue Mar 21 18:19:11 2006
@@ -32,11 +32,7 @@
 import httplib
 import urllib
 import re
-
-#REPORT_HOST = "xmtest-dev.dague.org"
-REPORT_HOST = "xmtest.dague.org"
-REPORT_URL  = "/cgi-bin/report-results";
-VIEW_URL = "cgi-bin/display?view=single&testid="
+from urlparse import urlparse
 
 class XmTestReport:
 
@@ -88,8 +84,11 @@
 
     return 'multipart/form-data; boundary=%s' % boundary, textBody
 
-def postResults(results):
-    conn = httplib.HTTPConnection(REPORT_HOST)
+def postResults(report_server, results):
+    if not re.match('http://', report_server):
+       report_server = 'http://'+report_server
+    (report_host,report_url) = urlparse(report_server)[1:3]
+    conn = httplib.HTTPConnection(report_host)
 
     type, body = encodeForm({"log" : results})
 
@@ -100,22 +99,17 @@
     # print "%s\n" % type
     # print headers
     
-    conn.request("POST", REPORT_URL, body, headers)
+    conn.request("POST", report_url, body, headers)
     
     resp = conn.getresponse()
     data = resp.read()
 
     if resp.status == 200:
         print >>sys.stderr, "Your results have been submitted successfully!"
-        match = re.match("^id=([0-9]+)$", data.split("\n")[1])
-        if match:
-            id = match.group(1)
-            print >>sys.stderr, "See your report at:"
-            print >>sys.stderr, "http://%s/%s%s"; % (REPORT_HOST, VIEW_URL, id)
     else:
         print >>sys.stderr, "Unable to submit results:"
-        print >>sys.stderr, "[http://%s%s] said %i: %s" % (REPORT_HOST,
-                                                           REPORT_URL,
+        print >>sys.stderr, "[http://%s%s] said %i: %s" % (report_host,
+                                                           report_url,
                                                            resp.status,
                                                            resp.reason)
         print >>sys.stderr, data
@@ -133,7 +127,9 @@
     dump = False
     files = []
 
-    for a in sys.argv[1:]:
+    report_server = sys.argv[1]
+
+    for a in sys.argv[2:]:
         if a == "-d":
             submit = False
             dump = True
@@ -156,5 +152,5 @@
         print xmlout
 
     if submit:
-        postResults(xmlout)
+        postResults(report_server, xmlout)
     
diff -r f163677f8767 -r a9f5cf43451f tools/xm-test/ramdisk/Makefile.am
--- a/tools/xm-test/ramdisk/Makefile.am Tue Mar 21 16:55:44 2006
+++ b/tools/xm-test/ramdisk/Makefile.am Tue Mar 21 18:19:11 2006
@@ -13,6 +13,8 @@
 
 XMTEST_MAJ_VER = $(shell echo @PACKAGE_VERSION@ | perl -pe 
's/(\d+)\.(\d+)\.\d+/\1.\2/')
 XMTEST_VER_IMG = initrd-$(XMTEST_MAJ_VER).img
+
+EXTRA_ROOT_DIRS = sys
 
 if HVM
 all: initrd.img disk.img
@@ -36,7 +38,8 @@
 
 $(XMTEST_VER_IMG): $(BR_IMG)
        chmod a+x skel/etc/init.d/rcS
-       (cd skel; tar cf - .) | (cd $(BR_SRC)/$(BR_ROOT); tar xvf -)
+       (cd skel; mkdir -p $(EXTRA_ROOT_DIRS); tar cf - .) \
+               | (cd $(BR_SRC)/$(BR_ROOT); tar xvf -)
        cd $(BR_SRC) && make
        cp $(BR_IMG) initrd-$(XMTEST_MAJ_VER).img
 
diff -r f163677f8767 -r a9f5cf43451f tools/xm-test/ramdisk/skel/etc/init.d/rcS
--- a/tools/xm-test/ramdisk/skel/etc/init.d/rcS Tue Mar 21 16:55:44 2006
+++ b/tools/xm-test/ramdisk/skel/etc/init.d/rcS Tue Mar 21 18:19:11 2006
@@ -2,3 +2,7 @@
 
 mount -a
 
+# If we're running 2.6, make sure /sys is mounted
+if uname -r | grep -q '^2.6'; then
+       mount -t sysfs none /sys
+fi
diff -r f163677f8767 -r a9f5cf43451f tools/xm-test/runtest.sh
--- a/tools/xm-test/runtest.sh  Tue Mar 21 16:55:44 2006
+++ b/tools/xm-test/runtest.sh  Tue Mar 21 18:19:11 2006
@@ -13,7 +13,9 @@
     echo "  -b          : do not ask any questions (batch mode)"
     echo "  -g          : run a group test set"
     echo "  -e <email>  : set email address for report"
+    echo "  -r <url>    : url of test results repository to use"
     echo "  -s <report> : just submit report <report>"
+    echo "  -u          : unsafe -- do not run the sanity checks before 
starting"
     echo "  -h | --help : show this help"
 }
 
@@ -22,7 +24,7 @@
 
     reportfile=$1
 
-    ./lib/XmTestReport/Report.py $reportfile
+    ./lib/XmTestReport/Report.py $reportserver $reportfile
 }
 
 # Generate XML result report from output file
@@ -189,8 +191,10 @@
 # Defaults
 MAXFAIL=10
 report=yes
+reportserver=${xmtest_repo:-'http://xmtest.dague.org/cgi-bin/report-results'}
 batch=no
 run=yes
+unsafe=no
 GROUPENTERED=default
 
 # Resolve options
@@ -218,8 +222,17 @@
              exit 1
           fi
          ;;
+      -r)
+         shift
+         reportserver=$1
+         ;;
       -s)
          run=no
+         ;;
+      -u)
+         echo "(Unsafe mode)"
+         unsafe=yes
+         report=no
          ;;
       -h|--help)
           usage
@@ -264,15 +277,25 @@
     fi
 fi
 
+if [ "$GROUPENTERED" != "default" ]; then
+   report=no;
+fi
+
 if [ "$run" != "no" ]; then
-    runnable_tests
-    make_environment_report $OSREPORTTEMP $PROGREPORTTEMP
+    if [ "$unsafe" = "no" ]; then
+      runnable_tests
+    fi
+    rm -f $REPORT"*"
+    if [ "$unsafe" = "no" ]; then
+      make_environment_report $OSREPORTTEMP $PROGREPORTTEMP
+    fi
     run_tests $GROUPENTERED $OUTPUT
     make_text_reports $PASSFAIL $FAILURES $OUTPUT $TXTREPORT
-    make_result_report $OUTPUT $RESULTREPORTTEMP
-    cat $OSREPORTTEMP $PROGREPORTTEMP $RESULTREPORTTEMP > $XMLREPORT
-    rm $OSREPORTTEMP $PROGREPORTTEMP $RESULTREPORTTEMP
-
+    if [ "$unsafe" = "no" ]; then
+      make_result_report $OUTPUT $RESULTREPORTTEMP
+      cat $OSREPORTTEMP $PROGREPORTTEMP $RESULTREPORTTEMP > $XMLREPORT
+      rm $OSREPORTTEMP $PROGREPORTTEMP $RESULTREPORTTEMP
+    fi
 fi
 
 if [ "$report" = "yes" ]; then
diff -r f163677f8767 -r a9f5cf43451f 
tools/xm-test/tests/create/10_create_fastdestroy.py
--- a/tools/xm-test/tests/create/10_create_fastdestroy.py       Tue Mar 21 
16:55:44 2006
+++ b/tools/xm-test/tests/create/10_create_fastdestroy.py       Tue Mar 21 
18:19:11 2006
@@ -28,7 +28,7 @@
 for i in range(0,50):
     domain = XmTestDomain("testdomain")
     try:
-        domain.startNow()
+        domain.start()
     except DomainError,e:
         print "Failed: " + e.extra
         NSPerror = check_for_NSP_error(e.extra)
diff -r f163677f8767 -r a9f5cf43451f 
tools/xm-test/tests/destroy/07_destroy_stale_pos.py
--- a/tools/xm-test/tests/destroy/07_destroy_stale_pos.py       Tue Mar 21 
16:55:44 2006
+++ b/tools/xm-test/tests/destroy/07_destroy_stale_pos.py       Tue Mar 21 
18:19:11 2006
@@ -101,29 +101,24 @@
     if not re.search("[Ee]rror", output):
         FAIL("sysrq failed to report error after destroy!")
 
-def runTests(tests, wait):
+def runTests(tests):
     for test in tests:
         domain = XmTestDomain()
 
         # Create a domain
 
         try:
-            if wait:
-                domain.start()
-            else:
-                domain.startNow()
+            domain.start()
         except DomainError, e:
             FAIL(str(e))
 
-
-        if wait:
-            # Attach a console and make sure it's live
-            try:
-                console = XmConsole(domain.getName())
-                console.sendInput("foo")
-                console.runCmd("ls")
-            except ConsoleError, e:
-                FAIL(str(e))
+        # Attach a console and make sure it's live
+        try:
+            console = XmConsole(domain.getName())
+            console.sendInput("foo")
+            console.runCmd("ls")
+        except ConsoleError, e:
+            FAIL(str(e))
 
         # Destroy it
                 
@@ -137,9 +132,5 @@
          test_block_list, test_shutdown, test_domid, test_domname]
 
 if verbose:
-    print "Running stale tests (nice mode)"
-runTests(tests, True)
-
-if verbose:
-    print "Running stale tests (mean mode)"
-runTests(tests, False)
+    print "Running stale tests"
+runTests(tests)
diff -r f163677f8767 -r a9f5cf43451f 
tools/xm-test/tests/vcpu-pin/01_vcpu-pin_basic_pos.py
--- a/tools/xm-test/tests/vcpu-pin/01_vcpu-pin_basic_pos.py     Tue Mar 21 
16:55:44 2006
+++ b/tools/xm-test/tests/vcpu-pin/01_vcpu-pin_basic_pos.py     Tue Mar 21 
18:19:11 2006
@@ -46,3 +46,5 @@
 
 if cpu != 1:
     FAIL("failed to switch VCPU 0 to CPU 1")
+
+domain.stop()
diff -r f163677f8767 -r a9f5cf43451f 
tools/xm-test/tests/vtpm/01_vtpm-list_pos.py
--- a/tools/xm-test/tests/vtpm/01_vtpm-list_pos.py      Tue Mar 21 16:55:44 2006
+++ b/tools/xm-test/tests/vtpm/01_vtpm-list_pos.py      Tue Mar 21 18:19:11 2006
@@ -1,21 +1,16 @@
 #!/usr/bin/python
 
 # Copyright (C) International Business Machines Corp., 2006
-# Author: Stefan Berger <stefanb@xxxxxxxxxx)
+# Author: Stefan Berger <stefanb@xxxxxxxxxx>
 
 # Positive Test: create domain with virtual TPM attached at build time,
 #                verify list
 
 
 from XmTestLib import *
-
-def vtpm_cleanup(domName):
-       # Since this is only a temporary domain I clean up the domain from the
-       # virtual TPM directory
-       traceCommand("/etc/xen/scripts/vtpm-delete %s" % domName)
-
-if ENABLE_HVM_SUPPORT:
-    SKIP("vtpm-list not supported for HVM domains")
+from vtpm_utils import *
+import commands
+import os
 
 config = {"vtpm":"instance=1,backend=0"}
 domain = XmTestDomain(extraConfig=config)
diff -r f163677f8767 -r a9f5cf43451f 
tools/xm-test/tests/vtpm/02_vtpm-cat_pcrs.py
--- a/tools/xm-test/tests/vtpm/02_vtpm-cat_pcrs.py      Tue Mar 21 16:55:44 2006
+++ b/tools/xm-test/tests/vtpm/02_vtpm-cat_pcrs.py      Tue Mar 21 18:19:11 2006
@@ -1,30 +1,17 @@
 #!/usr/bin/python
 
 # Copyright (C) International Business Machines Corp., 2006
-# Author: Stefan Berger <stefanb@xxxxxxxxxx)
+# Author: Stefan Berger <stefanb@xxxxxxxxxx>
 
 # Positive Test: create domain with virtual TPM attached at build time,
 #                check list of pcrs
 
 from XmTestLib import *
+from vtpm_utils import *
+import commands
+import os
+import os.path
 
-def vtpm_cleanup(domName):
-       # Since this is only a temporary domain I clean up the domain from the
-       # virtual TPM directory
-       traceCommand("/etc/xen/scripts/vtpm-delete %s" % domName)
-
-if ENABLE_HVM_SUPPORT:
-    SKIP("vtpm-list not supported for HVM domains")
-
-status, output = traceCommand("ls /dev/tpm0")
-if re.search("No such file or directory",output):
-    SKIP("This machine has no hardware TPM; cannot run this test")
-
-status, output = traceCommand("ps aux | grep vtpm_manager | grep -v grep")
-if output == "":
-    FAIL("virtual TPM manager must be started to run this test")
-
-# vtpm manager has been detected
 config = {"vtpm":"instance=1,backend=0"}
 domain = XmTestDomain(extraConfig=config)
 
@@ -46,20 +33,10 @@
 
 try:
     console.sendInput("input")
-    run = console.runCmd("ls /sys")
 except ConsoleError, e:
     saveLog(console.getHistory())
     vtpm_cleanup(domName)
     FAIL(str(e))
-
-if re.search("No such file",run["output"]):
-    try:
-        run = console.runCmd("mkdir /sys")
-        run = console.runCmd("mount -t sysfs /sys /sys")
-    except ConsoleError, e:
-        saveLog(console.getHistory())
-        vtpm_cleanup(domName)
-        FAIL(str(e))
 
 try:
     run = console.runCmd("cat /sys/devices/platform/tpm_vtpm/pcrs")
diff -r f163677f8767 -r a9f5cf43451f tools/xm-test/tests/vtpm/Makefile.am
--- a/tools/xm-test/tests/vtpm/Makefile.am      Tue Mar 21 16:55:44 2006
+++ b/tools/xm-test/tests/vtpm/Makefile.am      Tue Mar 21 18:19:11 2006
@@ -1,13 +1,12 @@
-
 SUBDIRS =
 
 TESTS = 01_vtpm-list_pos.test \
-        02_vtpm-cat_pcrs.test
+        02_vtpm-cat_pcrs.test \
+        03_vtpm-susp_res.test
 
 XFAIL_TESTS =
 
-EXTRA_DIST = $(TESTS) $(XFAIL_TESTS)
-
+EXTRA_DIST = $(TESTS) $(XFAIL_TESTS) vtpm_utils.py
 TESTS_ENVIRONMENT=@TENV@
 
 %.test: %.py
diff -r f163677f8767 -r a9f5cf43451f xen/Makefile
--- a/xen/Makefile      Tue Mar 21 16:55:44 2006
+++ b/xen/Makefile      Tue Mar 21 18:19:11 2006
@@ -55,12 +55,7 @@
        [ -e include/asm ] || ln -sf asm-$(TARGET_ARCH) include/asm
        $(MAKE) -C arch/$(TARGET_ARCH) asm-offsets.s
        $(MAKE) include/asm-$(TARGET_ARCH)/asm-offsets.h
-       $(MAKE) -C common
-       $(MAKE) -C drivers
-ifeq ($(ACM_SECURITY),y)
-       $(MAKE) -C acm
-endif
-       $(MAKE) -C arch/$(TARGET_ARCH)
+       $(MAKE) -C arch/$(TARGET_ARCH) $(TARGET)
 
 # drivers/char/console.o contains static banner/compile info. Blow it away.
 # Don't refresh these files during e.g., 'sudo make install'
diff -r f163677f8767 -r a9f5cf43451f xen/Rules.mk
--- a/xen/Rules.mk      Tue Mar 21 16:55:44 2006
+++ b/xen/Rules.mk      Tue Mar 21 18:19:11 2006
@@ -7,6 +7,15 @@
 perfc       ?= n
 perfc_arrays?= n
 crash_debug ?= n
+
+# Hardcoded configuration implications and dependencies.
+# Do this is a neater way if it becomes unwieldy.
+ifeq ($(debug),y)
+verbose := y
+endif
+ifeq ($(perfc_arrays),y)
+perfc := y
+endif
 
 XEN_ROOT=$(BASEDIR)/..
 include $(XEN_ROOT)/Config.mk
@@ -27,41 +36,23 @@
 HDRS    := $(subst $(BASEDIR)/include/xen/banner.h,,$(HDRS))
 HDRS    := $(subst $(BASEDIR)/include/xen/compile.h,,$(HDRS))
 
-C_SRCS  := $(wildcard *.c)
-S_SRCS  := $(wildcard *.S)
-OBJS    := $(patsubst %.S,%.o,$(S_SRCS))
-OBJS    += $(patsubst %.c,%.o,$(C_SRCS))
+include $(BASEDIR)/arch/$(TARGET_ARCH)/Rules.mk
 
 # Note that link order matters!
-ALL_OBJS := $(BASEDIR)/common/common.o
-ALL_OBJS += $(BASEDIR)/drivers/char/driver.o
-ALL_OBJS += $(BASEDIR)/drivers/acpi/driver.o
-ifeq ($(ACM_SECURITY),y)
-ALL_OBJS += $(BASEDIR)/acm/acm.o
-CFLAGS += -DACM_SECURITY
-endif
-ALL_OBJS += $(BASEDIR)/arch/$(TARGET_ARCH)/arch.o
+ALL_OBJS-y               += $(BASEDIR)/common/built_in.o
+ALL_OBJS-y               += $(BASEDIR)/drivers/built_in.o
+ALL_OBJS-$(ACM_SECURITY) += $(BASEDIR)/acm/built_in.o
+ALL_OBJS-y               += $(BASEDIR)/arch/$(TARGET_ARCH)/built_in.o
 
-include $(BASEDIR)/arch/$(TARGET_ARCH)/Rules.mk
+CFLAGS-y               += -g -D__XEN__
+CFLAGS-$(ACM_SECURITY) += -DACM_SECURITY
+CFLAGS-$(verbose)      += -DVERBOSE
+CFLAGS-$(crash_debug)  += -DCRASH_DEBUG
+CFLAGS-$(perfc)        += -DPERF_COUNTERS
+CFLAGS-$(perfc_arrays) += -DPERF_ARRAYS
 
-CFLAGS += -g -D__XEN__
-
-ifneq ($(debug)$(verbose),nn)
-CFLAGS += -DVERBOSE
-endif
-
-ifeq ($(crash_debug),y)
-CFLAGS += -DCRASH_DEBUG
-endif
-
-ifeq ($(perfc),y)
-CFLAGS += -DPERF_COUNTERS
-ifeq ($(perfc_arrays),y)
-CFLAGS += -DPERF_ARRAYS
-endif
-endif
-
-CFLAGS := $(strip $(CFLAGS))
+ALL_OBJS := $(ALL_OBJS-y)
+CFLAGS   := $(strip $(CFLAGS) $(CFLAGS-y))
 
 %.o: %.c $(HDRS) Makefile
        $(CC) $(CFLAGS) -c $< -o $@
diff -r f163677f8767 -r a9f5cf43451f xen/acm/Makefile
--- a/xen/acm/Makefile  Tue Mar 21 16:55:44 2006
+++ b/xen/acm/Makefile  Tue Mar 21 18:19:11 2006
@@ -1,15 +1,9 @@
+include $(BASEDIR)/Rules.mk
 
-include $(BASEDIR)/Rules.mk
-OBJS =  acm_core.o 
-OBJS += acm_policy.o
-OBJS += acm_simple_type_enforcement_hooks.o
-OBJS += acm_chinesewall_hooks.o
-OBJS += acm_null_hooks.o
+obj-y += acm_core.o 
+obj-y += acm_policy.o
+obj-y += acm_simple_type_enforcement_hooks.o
+obj-y += acm_chinesewall_hooks.o
+obj-y += acm_null_hooks.o
 
-default: acm.o
-
-acm.o: $(OBJS)
-       $(LD) $(LDFLAGS) -r -o acm.o $(OBJS)
-
-clean:
-       rm -f *.o *~ core
+include $(BASEDIR)/Post.mk
diff -r f163677f8767 -r a9f5cf43451f xen/arch/ia64/Makefile
--- a/xen/arch/ia64/Makefile    Tue Mar 21 16:55:44 2006
+++ b/xen/arch/ia64/Makefile    Tue Mar 21 18:19:11 2006
@@ -1,63 +1,23 @@
 include $(BASEDIR)/Rules.mk
 
-VPATH = xen vmx linux linux-xen
+subdir-y += xen
+subdir-y += vmx
+subdir-y += linux
+subdir-y += linux-xen
 
-OBJS = xensetup.o setup.o time.o irq.o process.o smp.o \
-       xenmisc.o acpi.o hypercall.o \
-       machvec.o dom0_ops.o domain.o hpsimserial.o pcdp.o \
-       idle0_task.o pal.o hpsim.o efi.o efi_stub.o ivt.o mm_contig.o \
-       xenmem.o sal.o cmdline.o mm_init.o tlb.o smpboot.o \
-       extable.o linuxextable.o sort.o xenirq.o xentime.o \
-       regionreg.o entry.o unaligned.o privop.o vcpu.o \
-       irq_ia64.o irq_lsapic.o vhpt.o xenasm.o hyperprivop.o dom_fw.o \
-       sn_console.o # ia64_ksyms.o 
+include $(BASEDIR)/Post.mk
 
-OBJS += vmx_init.o vmx_virt.o vmx_vcpu.o vmx_process.o vmx_vsa.o vmx_ivt.o\
-       vmx_phy_mode.o vmx_utility.o vmx_interrupt.o vmx_entry.o vmmu.o \
-       vtlb.o mmio.o vlsapic.o vmx_hypercall.o mm.o vmx_support.o \
-       pal_emul.o vmx_irq_ia64.o hvm_vioapic.o
-
-# lib files from xen/arch/ia64/linux/ (linux/arch/ia64/lib)
-OBJS +=        bitop.o clear_page.o flush.o copy_page_mck.o                    
\
-       memset.o strlen.o memcpy_mck.o                                  \
-       __divsi3.o __udivsi3.o __modsi3.o __umodsi3.o                   \
-       __divdi3.o __udivdi3.o __moddi3.o __umoddi3.o
-
-ifeq ($(crash_debug),y)
-OBJS += gdbstub.o
-endif
-
-# xen stack unwinder
-# unwind_decoder.c is included in unwind.c
-OBJS += unwind.o
-#unwind.o: CFLAGS += -DUNW_DEBUG=4
-
-OBJS += process-linux-xen.o
-
-# perfmon.o
-# unwind.o needed for kernel unwinding (rare)
-
-OBJS := $(subst $(TARGET_ARCH)/asm-offsets.o,,$(OBJS))
-
-# remove following line if not privifying in memory
-# OBJS += privify.o
-
-default: $(TARGET)
-
-$(CURDIR)/arch.o: $(OBJS)
-       $(LD) -r -o $@ $(OBJS)
-
-$(TARGET)-syms: $(ALL_OBJS) head.o xen.lds.s
-       $(LD) $(LDFLAGS) -T $(BASEDIR)/arch/$(TARGET_ARCH)/xen.lds.s -N \
-               -Map map.out head.o $(ALL_OBJS) -o $@
+$(TARGET)-syms: linux-xen/head.o $(ALL_OBJS) xen.lds.s
+       $(LD) $(LDFLAGS) -T xen.lds.s -N \
+               -Map map.out linux-xen/head.o $(ALL_OBJS) -o $@
        $(NM) -n $@ | $(BASEDIR)/tools/symbols > $(BASEDIR)/xen-syms.S
        $(MAKE) $(BASEDIR)/xen-syms.o
-       $(LD) $(LDFLAGS) -T $(BASEDIR)/arch/$(TARGET_ARCH)/xen.lds.s -N \
-               -Map map.out head.o $(ALL_OBJS) $(BASEDIR)/xen-syms.o -o $@
+       $(LD) $(LDFLAGS) -T xen.lds.s -N \
+               -Map map.out linux-xen/head.o $(ALL_OBJS) $(BASEDIR)/xen-syms.o 
-o $@
        $(NM) -n $@ | $(BASEDIR)/tools/symbols >$(BASEDIR)/xen-syms.S
        $(MAKE) $(BASEDIR)/xen-syms.o
-       $(LD) $(LDFLAGS) -T $(BASEDIR)/arch/$(TARGET_ARCH)/xen.lds.s -N \
-               -Map map.out head.o $(ALL_OBJS) $(BASEDIR)/xen-syms.o -o $@
+       $(LD) $(LDFLAGS) -T xen.lds.s -N \
+               -Map map.out linux-xen/head.o $(ALL_OBJS) $(BASEDIR)/xen-syms.o 
-o $@
        rm -f $(BASEDIR)/xen-syms.S $(BASEDIR)/xen-syms.o
 
 $(TARGET): $(TARGET)-syms
@@ -119,31 +79,9 @@
        $(CC) -E $(CPPFLAGS) -P -DXEN -D__ASSEMBLY__ \
                -o xen.lds.s xen/xen.lds.S
 
-# variants of divide/modulo
-# see files in xen/arch/ia64/linux/lib (linux/arch/ia64/lib)
-__divdi3.o: idiv64.S
-       $(CC) $(AFLAGS) $(AFLAGS_KERNEL) -c -o $@ $<
-__udivdi3.o: idiv64.S
-       $(CC) $(AFLAGS) $(AFLAGS_KERNEL) -c -DUNSIGNED -c -o $@ $<
-__moddi3.o: idiv64.S
-       $(CC) $(AFLAGS) $(AFLAGS_KERNEL) -c -DMODULO -c -o $@ $<
-__umoddi3.o: idiv64.S
-       $(CC) $(AFLAGS) $(AFLAGS_KERNEL) -c -DMODULO -DUNSIGNED -c -o $@ $<
-__divsi3.o: idiv32.S
-       $(CC) $(AFLAGS) $(AFLAGS_KERNEL) -c -o $@ $<
-__udivsi3.o: idiv32.S
-       $(CC) $(AFLAGS) $(AFLAGS_KERNEL) -c -DUNSIGNED -c -o $@ $<
-__modsi3.o: idiv32.S
-       $(CC) $(AFLAGS) $(AFLAGS_KERNEL) -c -DMODULO -c -o $@ $<
-__umodsi3.o: idiv32.S
-       $(CC) $(AFLAGS) $(AFLAGS_KERNEL) -c -DMODULO -DUNSIGNED -c -o $@ $<
-
-
-clean:
+clean:: FORCE
        rm -f *.o *~ core  xen.lds.s 
$(BASEDIR)/include/asm-ia64/.offsets.h.stamp asm-offsets.s map.out
        rm -f asm-xsi-offsets.s $(BASEDIR)/include/asm-ia64/asm-xsi-offsets.h
-       rm -f $(BASEDIR)/arch/ia64/vmx/hvm_*.c
+       rm -f $(BASEDIR)/System.map
+       rm -f vmx/hvm_*.c
        rm -rf $(BASEDIR)/include/asm-ia64/hvm
-       rm -f linux/lib/*.o
-
-.PHONY: default clean
diff -r f163677f8767 -r a9f5cf43451f xen/arch/ia64/Rules.mk
--- a/xen/arch/ia64/Rules.mk    Tue Mar 21 16:55:44 2006
+++ b/xen/arch/ia64/Rules.mk    Tue Mar 21 18:19:11 2006
@@ -1,6 +1,7 @@
 ########################################
 # ia64-specific definitions
 
+HAS_ACPI := y
 VALIDATE_VT    ?= n
 ifneq ($(COMPILE_ARCH),$(TARGET_ARCH))
 CROSS_COMPILE ?= /usr/local/sp_env/v2.2.5/i686/bin/ia64-unknown-linux-
diff -r f163677f8767 -r a9f5cf43451f xen/arch/x86/Makefile
--- a/xen/arch/x86/Makefile     Tue Mar 21 16:55:44 2006
+++ b/xen/arch/x86/Makefile     Tue Mar 21 18:19:11 2006
@@ -1,57 +1,59 @@
-
 include $(BASEDIR)/Rules.mk
 
-OBJS += $(patsubst %.S,%.o,$(wildcard $(TARGET_SUBARCH)/*.S))
-OBJS += $(patsubst %.c,%.o,$(wildcard $(TARGET_SUBARCH)/*.c))
-OBJS += $(patsubst %.c,%.o,$(wildcard acpi/*.c))
-OBJS += $(patsubst %.c,%.o,$(wildcard genapic/*.c))
-OBJS += $(patsubst %.c,%.o,$(wildcard cpu/*.c))
-OBJS += $(patsubst %.c,%.o,$(wildcard cpu/mcheck/*.c))
-OBJS += $(patsubst %.c,%.o,$(wildcard cpu/mtrr/*.c))
-OBJS += $(patsubst %.c,%.o,$(wildcard hvm/*.c))
-OBJS += $(patsubst %.c,%.o,$(wildcard hvm/vmx/*.c))
-OBJS += $(patsubst %.S,%.o,$(wildcard hvm/vmx/$(TARGET_SUBARCH)/*.S))
-OBJS += $(patsubst %.c,%.o,$(wildcard hvm/svm/*.c))
-OBJS += $(patsubst %.S,%.o,$(wildcard hvm/svm/$(TARGET_SUBARCH)/*.S))
+subdir-y += acpi
+subdir-y += cpu
+subdir-y += genapic
+subdir-y += hvm
 
-ifeq ($(TARGET_SUBARCH),x86_64) 
-OBJS := $(subst cpu/centaur.o,,$(OBJS))
-OBJS := $(subst cpu/cyrix.o,,$(OBJS))
-OBJS := $(subst cpu/rise.o,,$(OBJS))
-OBJS := $(subst cpu/transmeta.o,,$(OBJS))
+subdir-$(x86_32) += x86_32
+subdir-$(x86_64) += x86_64
+
+obj-y += apic.o
+obj-y += audit.o
+obj-y += bitops.o
+obj-y += delay.o
+obj-y += dmi_scan.o
+obj-y += dom0_ops.o
+obj-y += domain.o
+obj-y += domain_build.o
+obj-y += e820.o
+obj-y += extable.o
+obj-y += flushtlb.o
+obj-y += i387.o
+obj-y += i8259.o
+obj-y += io_apic.o
+obj-y += irq.o
+obj-y += microcode.o
+obj-y += mm.o
+obj-y += mpparse.o
+obj-y += nmi.o
+obj-y += physdev.o
+obj-y += rwlock.o
+obj-y += setup.o
+obj-y += smp.o
+obj-y += smpboot.o
+obj-y += string.o
+obj-y += time.o
+obj-y += trampoline.o
+obj-y += traps.o
+obj-y += usercopy.o
+obj-y += x86_emulate.o
+
+ifneq ($(pae),n)
+obj-$(x86_32) += shadow.o shadow_public.o shadow_guest32.o
+else
+obj-$(x86_32) += shadow32.o
 endif
 
-OBJS := $(patsubst shadow%.o,,$(OBJS)) # drop all
-ifeq ($(TARGET_SUBARCH),x86_64) 
- OBJS += shadow.o shadow_public.o shadow_guest32.o shadow_guest32pae.o # 
x86_64: new code
-endif
-ifeq ($(TARGET_SUBARCH),x86_32) 
- ifneq ($(pae),n)
-  OBJS += shadow.o shadow_public.o shadow_guest32.o    # x86_32p: new code
- else
-  OBJS += shadow32.o                   # x86_32: old code
- endif
-endif
+obj-$(x86_64) += shadow.o shadow_public.o shadow_guest32.o shadow_guest32pae.o
 
-ifneq ($(supervisor_mode_kernel),y)
-OBJS := $(subst x86_32/supervisor_mode_kernel.o,,$(OBJS))
-endif
+obj-$(crash_debug) += gdbstub.o
 
-OBJS := $(subst $(TARGET_SUBARCH)/asm-offsets.o,,$(OBJS))
-OBJS := $(subst $(TARGET_SUBARCH)/xen.lds.o,,$(OBJS))
-
-ifneq ($(crash_debug),y)
-OBJS := $(patsubst gdbstub%.o,,$(OBJS))
-endif
-
-default: $(TARGET)
+include $(BASEDIR)/Post.mk
 
 $(TARGET): $(TARGET)-syms boot/mkelf32
        ./boot/mkelf32 $(TARGET)-syms $(TARGET) 0x100000 \
        `$(NM) $(TARGET)-syms | sort | tail -n 1 | sed -e 's/^\([^ 
]*\).*/0x\1/'`
-
-$(CURDIR)/arch.o: $(OBJS)
-       $(LD) $(LDFLAGS) -r -o $@ $(OBJS)
 
 $(TARGET)-syms: boot/$(TARGET_SUBARCH).o $(ALL_OBJS) xen.lds
        $(LD) $(LDFLAGS) -T xen.lds -N \
@@ -77,21 +79,5 @@
 
 shadow_guest32.o: shadow.c
 
-clean:
-       rm -f *.o *.s *~ core boot/*.o boot/*~ boot/core boot/mkelf32
-       rm -f x86_32/*.o x86_32/*~ x86_32/core
-       rm -f x86_64/*.o x86_64/*~ x86_64/core
-       rm -f mtrr/*.o mtrr/*~ mtrr/core
-       rm -f acpi/*.o acpi/*~ acpi/core
-       rm -f genapic/*.o genapic/*~ genapic/core
-       rm -f cpu/*.o cpu/*~ cpu/core
-       rm -f hvm/*.o hvm/*~ hvm/core
-       rm -f hvm/vmx/*.o hvm/vmx/*~ hvm/vmx/core
-       rm -f hvm/vmx/x86_32/*.o hvm/vmx/x86_32/*~ hvm/vmx/x86_32/core
-       rm -f hvm/vmx/x86_64/*.o hvm/vmx/x86_64/*~ hvm/vmx/x86_64/core
-       rm -f hvm/svm/*.o hvm/svm/*~ hvm/svm/core
-       rm -f hvm/svm/x86_32/*.o hvm/svm/x86_32/*~ hvm/svm/x86_32/core
-       rm -f hvm/svm/x86_64/*.o hvm/svm/x86_64/*~ hvm/svm/x86_64/core
-       rm -f xen.lds
-
-.PHONY: default clean
+clean:: FORCE
+       rm -f asm-offsets.s xen.lds boot/*.o boot/*~ boot/core boot/mkelf32
diff -r f163677f8767 -r a9f5cf43451f xen/arch/x86/Rules.mk
--- a/xen/arch/x86/Rules.mk     Tue Mar 21 16:55:44 2006
+++ b/xen/arch/x86/Rules.mk     Tue Mar 21 18:19:11 2006
@@ -1,5 +1,7 @@
 ########################################
 # x86-specific definitions
+
+HAS_ACPI := y
 
 #
 # If you change any of these configuration options then you must
@@ -31,13 +33,17 @@
 endif
 
 ifeq ($(XEN_TARGET_ARCH),x86_32)
-LDFLAGS += -m elf_i386 
+LDFLAGS += -m elf_i386
+x86_32 := y
+x86_64 := n
 endif
 
 ifeq ($(TARGET_SUBARCH),x86_64)
 CFLAGS  += -mno-red-zone -fpic -fno-reorder-blocks
 CFLAGS  += -fno-asynchronous-unwind-tables
 LDFLAGS += -m elf_x86_64
+x86_32 := n
+x86_64 := y
 endif
 
 # Test for at least GCC v3.2.x.
diff -r f163677f8767 -r a9f5cf43451f xen/arch/x86/domain.c
--- a/xen/arch/x86/domain.c     Tue Mar 21 16:55:44 2006
+++ b/xen/arch/x86/domain.c     Tue Mar 21 18:19:11 2006
@@ -51,6 +51,9 @@
 } __cacheline_aligned;
 static struct percpu_ctxt percpu_ctxt[NR_CPUS];
 
+static void paravirt_ctxt_switch_from(struct vcpu *v);
+static void paravirt_ctxt_switch_to(struct vcpu *v);
+
 static void continue_idle_domain(struct vcpu *v)
 {
     reset_stack_and_jump(idle_loop);
@@ -225,6 +228,9 @@
     {
         v->arch.schedule_tail = continue_nonidle_domain;
     }
+
+    v->arch.ctxt_switch_from = paravirt_ctxt_switch_from;
+    v->arch.ctxt_switch_to   = paravirt_ctxt_switch_to;
 
     v->arch.perdomain_ptes =
         d->arch.mm_perdomain_pt + (vcpu_id << GDT_LDT_VCPU_SHIFT);
@@ -685,21 +691,32 @@
     percpu_ctxt[smp_processor_id()].dirty_segment_mask = dirty_segment_mask;
 }
 
-#define switch_kernel_stack(_n,_c) ((void)0)
+#define switch_kernel_stack(v) ((void)0)
 
 #elif defined(__i386__)
 
 #define load_segments(n) ((void)0)
 #define save_segments(p) ((void)0)
 
-static inline void switch_kernel_stack(struct vcpu *n, unsigned int cpu)
-{
-    struct tss_struct *tss = &init_tss[cpu];
-    tss->esp1 = n->arch.guest_context.kernel_sp;
-    tss->ss1  = n->arch.guest_context.kernel_ss;
-}
-
-#endif
+static inline void switch_kernel_stack(struct vcpu *v)
+{
+    struct tss_struct *tss = &init_tss[smp_processor_id()];
+    tss->esp1 = v->arch.guest_context.kernel_sp;
+    tss->ss1  = v->arch.guest_context.kernel_ss;
+}
+
+#endif /* __i386__ */
+
+static void paravirt_ctxt_switch_from(struct vcpu *v)
+{
+    save_segments(v);
+}
+
+static void paravirt_ctxt_switch_to(struct vcpu *v)
+{
+    set_int80_direct_trap(v);
+    switch_kernel_stack(v);
+}
 
 #define loaddebug(_v,_reg) \
     __asm__ __volatile__ ("mov %0,%%db" #_reg : : "r" ((_v)->debugreg[_reg]))
@@ -720,15 +737,7 @@
                stack_regs,
                CTXT_SWITCH_STACK_BYTES);
         unlazy_fpu(p);
-        if ( !hvm_guest(p) )
-        {
-            save_segments(p);
-        }
-        else
-        {
-            hvm_save_segments(p);
-            hvm_load_msrs();
-        }
+        p->arch.ctxt_switch_from(p);
     }
 
     if ( !is_idle_vcpu(n) )
@@ -749,15 +758,7 @@
             loaddebug(&n->arch.guest_context, 7);
         }
 
-        if ( !hvm_guest(n) )
-        {
-            set_int80_direct_trap(n);
-            switch_kernel_stack(n, cpu);
-        }
-        else
-        {
-            hvm_restore_msrs(n);
-        }
+        n->arch.ctxt_switch_to(n);
     }
 
     if ( p->domain != n->domain )
diff -r f163677f8767 -r a9f5cf43451f xen/arch/x86/genapic/default.c
--- a/xen/arch/x86/genapic/default.c    Tue Mar 21 16:55:44 2006
+++ b/xen/arch/x86/genapic/default.c    Tue Mar 21 18:19:11 2006
@@ -18,6 +18,15 @@
 #include <asm/mach-default/mach_ipi.h>
 #include <asm/mach-default/mach_mpparse.h>
 
+#ifdef CONFIG_HOTPLUG_CPU
+#define DEFAULT_SEND_IPI       (1)
+#else
+#define DEFAULT_SEND_IPI       (0)
+#endif
+
+int no_broadcast = DEFAULT_SEND_IPI;
+integer_param("no_ipi_broadcast", no_broadcast);
+
 /* should be called last. */
 static __init int probe_default(void)
 { 
@@ -25,3 +34,12 @@
 } 
 
 struct genapic apic_default = APIC_INIT("default", probe_default); 
+
+static int __init print_ipi_mode(void)
+{
+       if (genapic == &apic_default)
+               printk("Using IPI %sShortcut mode\n",
+                      no_broadcast ? "No-" : "");
+       return 0;
+}
+__initcall(print_ipi_mode);
diff -r f163677f8767 -r a9f5cf43451f xen/arch/x86/genapic/es7000.h
--- a/xen/arch/x86/genapic/es7000.h     Tue Mar 21 16:55:44 2006
+++ b/xen/arch/x86/genapic/es7000.h     Tue Mar 21 18:19:11 2006
@@ -23,6 +23,15 @@
  *
  * http://www.unisys.com
  */
+
+/*
+ * ES7000 chipsets
+ */
+
+#define NON_UNISYS             0
+#define ES7000_CLASSIC         1
+#define ES7000_ZORRO           2
+
 
 #define        MIP_REG                 1
 #define        MIP_PSAI_REG            4
@@ -104,7 +113,8 @@
 #define        MIP_SW_APIC             0x1020b
 #define        MIP_FUNC(VALUE)         (VALUE & 0xff)
 
-extern int parse_unisys_oem (char *oemptr, int oem_entries);
-extern int find_unisys_acpi_oem_table(unsigned long *oem_addr, int *length);
+extern int parse_unisys_oem (char *oemptr);
+extern int find_unisys_acpi_oem_table(unsigned long *oem_addr);
+extern void setup_unisys(void);
 extern int es7000_start_cpu(int cpu, unsigned long eip);
 extern void es7000_sw_apic(void);
diff -r f163677f8767 -r a9f5cf43451f xen/arch/x86/genapic/es7000plat.c
--- a/xen/arch/x86/genapic/es7000plat.c Tue Mar 21 16:55:44 2006
+++ b/xen/arch/x86/genapic/es7000plat.c Tue Mar 21 18:19:11 2006
@@ -49,7 +49,7 @@
 int                    mip_port;
 unsigned long          mip_addr, host_addr;
 
-#if defined(CONFIG_X86_IO_APIC) && (defined(CONFIG_ACPI_INTERPRETER) || 
defined(CONFIG_ACPI_BOOT))
+#if defined(CONFIG_X86_IO_APIC) && defined(CONFIG_ACPI)
 
 /*
  * GSI override for ES7000 platforms.
@@ -60,6 +60,9 @@
 static int
 es7000_rename_gsi(int ioapic, int gsi)
 {
+       if (es7000_plat == ES7000_ZORRO)
+               return gsi;
+
        if (!base) {
                int i;
                for (i = 0; i < nr_ioapics; i++)
@@ -71,14 +74,31 @@
        return gsi;
 }
 
-#endif // (CONFIG_X86_IO_APIC) && (CONFIG_ACPI_INTERPRETER || CONFIG_ACPI_BOOT)
+#endif /* (CONFIG_X86_IO_APIC) && (CONFIG_ACPI) */
+
+void __init
+setup_unisys(void)
+{
+       /*
+        * Determine the generation of the ES7000 currently running.
+        *
+        * es7000_plat = 1 if the machine is a 5xx ES7000 box
+        * es7000_plat = 2 if the machine is a x86_64 ES7000 box
+        *
+        */
+       if (!(boot_cpu_data.x86 <= 15 && boot_cpu_data.x86_model <= 2))
+               es7000_plat = ES7000_ZORRO;
+       else
+               es7000_plat = ES7000_CLASSIC;
+       ioapic_renumber_irq = es7000_rename_gsi;
+}
 
 /*
  * Parse the OEM Table
  */
 
 int __init
-parse_unisys_oem (char *oemptr, int oem_entries)
+parse_unisys_oem (char *oemptr)
 {
        int                     i;
        int                     success = 0;
@@ -93,7 +113,7 @@
 
        tp += 8;
 
-       for (i=0; i <= oem_entries; i++) {
+       for (i=0; i <= 6; i++) {
                type = *tp++;
                size = *tp++;
                tp -= 2;
@@ -128,40 +148,24 @@
                default:
                        break;
                }
-               if (i == 6) break;
                tp += size;
        }
 
        if (success < 2) {
-               es7000_plat = 0;
-       } else {
-               printk("\nEnabling ES7000 specific features...\n");
-               /*
-                * Determine the generation of the ES7000 currently running.
-                *
-                * es7000_plat = 0 if the machine is NOT a Unisys ES7000 box
-                * es7000_plat = 1 if the machine is a 5xx ES7000 box
-                * es7000_plat = 2 if the machine is a x86_64 ES7000 box
-                *
-                */
-               if (!(boot_cpu_data.x86 <= 15 && boot_cpu_data.x86_model <= 2))
-                       es7000_plat = 2;
-               else
-                       es7000_plat = 1;
-
-               ioapic_renumber_irq = es7000_rename_gsi;
-       }
+               es7000_plat = NON_UNISYS;
+       } else
+               setup_unisys();
        return es7000_plat;
 }
 
 int __init
-find_unisys_acpi_oem_table(unsigned long *oem_addr, int *length)
+find_unisys_acpi_oem_table(unsigned long *oem_addr)
 {
        struct acpi_table_rsdp          *rsdp = NULL;
        unsigned long                   rsdp_phys = 0;
        struct acpi_table_header        *header = NULL;
        int                             i;
-       struct acpi_table_sdt           sdt = { 0 };
+       struct acpi_table_sdt           sdt = { 0 }; /* initialise sdt.count */
 
        rsdp_phys = acpi_find_rsdp();
        rsdp = __va(rsdp_phys);
@@ -199,13 +203,11 @@
                                acpi_table_print(header, sdt.entry[i].pa);
                                t = (struct oem_table *) 
__acpi_map_table(sdt.entry[i].pa, header->length);
                                addr = (void *) 
__acpi_map_table(t->OEMTableAddr, t->OEMTableSize);
-                               *length = header->length;
                                *oem_addr = (unsigned long) addr;
                                return 0;
                        }
                }
        }
-       Dprintk("ES7000: did not find Unisys ACPI OEM table!\n");
        return -1;
 }
 
@@ -298,7 +300,7 @@
 void __init
 es7000_sw_apic()
 {
-       if (es7000_plat == 1) {
+       if (es7000_plat) {
                int mip_status;
                struct mip_reg es7000_mip_reg;
 
diff -r f163677f8767 -r a9f5cf43451f xen/arch/x86/hvm/intercept.c
--- a/xen/arch/x86/hvm/intercept.c      Tue Mar 21 16:55:44 2006
+++ b/xen/arch/x86/hvm/intercept.c      Tue Mar 21 18:19:11 2006
@@ -338,10 +338,10 @@
 
 static __inline__ void missed_ticks(struct hvm_virpit*vpit)
 {
-    int        missed_ticks;
+    int missed_ticks;
 
     missed_ticks = (NOW() - vpit->scheduled)/(s_time_t) vpit->period;
-    if ( missed_ticks > 0 ) {
+    if ( missed_ticks++ >= 0 ) {
         vpit->pending_intr_nr += missed_ticks;
         vpit->scheduled += missed_ticks * vpit->period;
     }
@@ -355,22 +355,16 @@
 
     /* pick up missed timer tick */
     missed_ticks(vpit);
-
-    vpit->pending_intr_nr++;
     if ( test_bit(_VCPUF_running, &v->vcpu_flags) ) {
-        vpit->scheduled += vpit->period;
         set_timer(&vpit->pit_timer, vpit->scheduled);
     }
 }
 
+/* pick up missed timer ticks at deactive time */
 void pickup_deactive_ticks(struct hvm_virpit *vpit)
 {
-
     if ( !active_timer(&(vpit->pit_timer)) ) {
-        /* pick up missed timer tick */
         missed_ticks(vpit);
-    
-        vpit->scheduled += vpit->period;
         set_timer(&vpit->pit_timer, vpit->scheduled);
     }
 }
diff -r f163677f8767 -r a9f5cf43451f xen/arch/x86/hvm/svm/svm.c
--- a/xen/arch/x86/hvm/svm/svm.c        Tue Mar 21 16:55:44 2006
+++ b/xen/arch/x86/hvm/svm/svm.c        Tue Mar 21 18:19:11 2006
@@ -200,7 +200,8 @@
     return 1;
 }
 
-void svm_store_cpu_guest_regs(struct vcpu *v, struct cpu_user_regs *regs)
+static void svm_store_cpu_guest_regs(
+    struct vcpu *v, struct cpu_user_regs *regs)
 {
     struct vmcb_struct *vmcb = v->arch.hvm_svm.vmcb;
 
@@ -227,23 +228,11 @@
 #endif
 }
 
-void svm_load_cpu_guest_regs(struct vcpu *v, struct cpu_user_regs *regs)
+static void svm_load_cpu_guest_regs(
+    struct vcpu *v, struct cpu_user_regs *regs)
 {
     svm_load_cpu_user_regs(v, regs);
 }
-
-#ifdef __x86_64__
-
-void svm_save_segments(struct vcpu *v)
-{
-}
-void svm_load_msrs(void)
-{
-}
-void svm_restore_msrs(struct vcpu *v)
-{
-}
-#endif
 
 #define IS_CANO_ADDRESS(add) 1
 
@@ -458,12 +447,6 @@
 
     hvm_funcs.store_cpu_guest_regs = svm_store_cpu_guest_regs;
     hvm_funcs.load_cpu_guest_regs = svm_load_cpu_guest_regs;
-
-#ifdef __x86_64__
-    hvm_funcs.save_segments = svm_save_segments;
-    hvm_funcs.load_msrs = svm_load_msrs;
-    hvm_funcs.restore_msrs = svm_restore_msrs;
-#endif
 
     hvm_funcs.store_cpu_guest_ctrl_regs = svm_store_cpu_guest_ctrl_regs;
     hvm_funcs.modify_guest_state = svm_modify_guest_state;
@@ -687,9 +670,19 @@
     reset_stack_and_jump(svm_asm_do_launch);
 }
 
+static void svm_ctxt_switch_from(struct vcpu *v)
+{
+}
+
+static void svm_ctxt_switch_to(struct vcpu *v)
+{
+}
+
 void svm_final_setup_guest(struct vcpu *v)
 {
-    v->arch.schedule_tail = arch_svm_do_launch;
+    v->arch.schedule_tail    = arch_svm_do_launch;
+    v->arch.ctxt_switch_from = svm_ctxt_switch_from;
+    v->arch.ctxt_switch_to   = svm_ctxt_switch_to;
 
     if (v == v->domain->vcpu[0]) 
     {
diff -r f163677f8767 -r a9f5cf43451f xen/arch/x86/hvm/vmx/io.c
--- a/xen/arch/x86/hvm/vmx/io.c Tue Mar 21 16:55:44 2006
+++ b/xen/arch/x86/hvm/vmx/io.c Tue Mar 21 18:19:11 2006
@@ -40,20 +40,33 @@
 
 #define BSP_CPU(v)    (!(v->vcpu_id))
 
-void vmx_set_tsc_shift(struct vcpu *v, struct hvm_virpit *vpit)
-{
-    u64   drift;
-
-    if ( vpit->first_injected )
-        drift = vpit->period_cycles * vpit->pending_intr_nr;
-    else 
-        drift = 0;
-    vpit->shift = v->arch.hvm_vmx.tsc_offset - drift;
-    __vmwrite(TSC_OFFSET, vpit->shift);
-
+static inline 
+void __set_tsc_offset(u64  offset)
+{
+    __vmwrite(TSC_OFFSET, offset);
 #if defined (__i386__)
-    __vmwrite(TSC_OFFSET_HIGH, ((vpit->shift)>> 32));
+    __vmwrite(TSC_OFFSET_HIGH, offset >> 32);
 #endif
+}
+
+u64 get_guest_time(struct vcpu *v)
+{
+    struct hvm_virpit *vpit = &(v->domain->arch.hvm_domain.vpit);
+    u64    host_tsc;
+    
+    rdtscll(host_tsc);
+    return host_tsc + vpit->cache_tsc_offset;
+}
+
+void set_guest_time(struct vcpu *v, u64 gtime)
+{
+    struct hvm_virpit *vpit = &(v->domain->arch.hvm_domain.vpit);
+    u64    host_tsc;
+   
+    rdtscll(host_tsc);
+    
+    vpit->cache_tsc_offset = gtime - host_tsc;
+    __set_tsc_offset(vpit->cache_tsc_offset);
 }
 
 static inline void
@@ -64,6 +77,7 @@
     if ( is_pit_irq(v, vector, type) ) {
         if ( !vpit->first_injected ) {
             vpit->pending_intr_nr = 0;
+            vpit->last_pit_gtime = get_guest_time(v);
             vpit->scheduled = NOW() + vpit->period;
             set_timer(&vpit->pit_timer, vpit->scheduled);
             vpit->first_injected = 1;
@@ -71,7 +85,9 @@
             vpit->pending_intr_nr--;
         }
         vpit->inject_point = NOW();
-        vmx_set_tsc_shift (v, vpit);
+
+        vpit->last_pit_gtime += vpit->period;
+        set_guest_time(v, vpit->last_pit_gtime);
     }
 
     switch(type)
@@ -189,14 +205,15 @@
 
     vmx_stts();
 
+    /* pick up the elapsed PIT ticks and re-enable pit_timer */
+    if ( vpit->first_injected) {
+        set_guest_time(v, v->domain->arch.hvm_domain.guest_time);
+        pickup_deactive_ticks(vpit);
+    }
+
     if ( test_bit(iopacket_port(v), &d->shared_info->evtchn_pending[0]) ||
          test_bit(ARCH_HVM_IO_WAIT, &v->arch.hvm_vcpu.ioflags) )
         hvm_wait_io();
-
-    /* pick up the elapsed PIT ticks and re-enable pit_timer */
-    if ( vpit->first_injected )
-        pickup_deactive_ticks(vpit);
-    vmx_set_tsc_shift(v, vpit);
 
     /* We can't resume the guest if we're waiting on I/O */
     ASSERT(!test_bit(ARCH_HVM_IO_WAIT, &v->arch.hvm_vcpu.ioflags));
diff -r f163677f8767 -r a9f5cf43451f xen/arch/x86/hvm/vmx/vmcs.c
--- a/xen/arch/x86/hvm/vmx/vmcs.c       Tue Mar 21 16:55:44 2006
+++ b/xen/arch/x86/hvm/vmx/vmcs.c       Tue Mar 21 18:19:11 2006
@@ -195,7 +195,6 @@
 /* Update CR3, GDT, LDT, TR */
     unsigned int  error = 0;
     unsigned long cr0, cr4;
-    u64     host_tsc;
 
     if (v->vcpu_id == 0)
         hvm_setup_platform(v->domain);
@@ -250,9 +249,7 @@
     v->arch.hvm_vmx.launch_cpu = smp_processor_id();
 
     /* init guest tsc to start from 0 */
-    rdtscll(host_tsc);
-    v->arch.hvm_vmx.tsc_offset = 0 - host_tsc;
-    vmx_set_tsc_shift(v, &v->domain->arch.hvm_domain.vpit);
+    set_guest_time(v, 0);
 }
 
 /*
diff -r f163677f8767 -r a9f5cf43451f xen/arch/x86/hvm/vmx/vmx.c
--- a/xen/arch/x86/hvm/vmx/vmx.c        Tue Mar 21 16:55:44 2006
+++ b/xen/arch/x86/hvm/vmx/vmx.c        Tue Mar 21 18:19:11 2006
@@ -50,9 +50,14 @@
 static unsigned long trace_values[NR_CPUS][4];
 #define TRACE_VMEXIT(index,value) trace_values[smp_processor_id()][index]=value
 
+static void vmx_ctxt_switch_from(struct vcpu *v);
+static void vmx_ctxt_switch_to(struct vcpu *v);
+
 void vmx_final_setup_guest(struct vcpu *v)
 {
-    v->arch.schedule_tail = arch_vmx_do_launch;
+    v->arch.schedule_tail    = arch_vmx_do_launch;
+    v->arch.ctxt_switch_from = vmx_ctxt_switch_from;
+    v->arch.ctxt_switch_to   = vmx_ctxt_switch_to;
 
     if ( v->vcpu_id == 0 )
     {
@@ -105,6 +110,7 @@
 }
 
 #ifdef __x86_64__
+
 static struct vmx_msr_state percpu_msr[NR_CPUS];
 
 static u32 msr_data_index[VMX_MSR_COUNT] =
@@ -113,7 +119,7 @@
     MSR_SYSCALL_MASK, MSR_EFER,
 };
 
-void vmx_save_segments(struct vcpu *v)
+static void vmx_save_segments(struct vcpu *v)
 {
     rdmsrl(MSR_SHADOW_GS_BASE, v->arch.hvm_vmx.msr_content.shadow_gs);
 }
@@ -124,7 +130,7 @@
  * are not modified once set for generic domains, we don't save them,
  * but simply reset them to the values set at percpu_traps_init().
  */
-void vmx_load_msrs(void)
+static void vmx_load_msrs(void)
 {
     struct vmx_msr_state *host_state = &percpu_msr[smp_processor_id()];
     int i;
@@ -166,118 +172,143 @@
 #define IS_CANO_ADDRESS(add) 1
 static inline int long_mode_do_msr_read(struct cpu_user_regs *regs)
 {
-    u64     msr_content = 0;
-    struct vcpu *vc = current;
-    struct vmx_msr_state * msr = &vc->arch.hvm_vmx.msr_content;
-    switch(regs->ecx){
+    u64 msr_content = 0;
+    struct vcpu *v = current;
+    struct vmx_msr_state *msr = &v->arch.hvm_vmx.msr_content;
+
+    switch ( regs->ecx ) {
     case MSR_EFER:
+        HVM_DBG_LOG(DBG_LEVEL_2, "EFER msr_content 0x%"PRIx64, msr_content);
         msr_content = msr->msr_items[VMX_INDEX_MSR_EFER];
-        HVM_DBG_LOG(DBG_LEVEL_2, "EFER msr_content %"PRIx64"\n", msr_content);
-        if (test_bit(VMX_CPU_STATE_LME_ENABLED,
-                     &vc->arch.hvm_vmx.cpu_state))
-            msr_content |= 1 << _EFER_LME;
-
-        if (VMX_LONG_GUEST(vc))
-            msr_content |= 1 << _EFER_LMA;
-        break;
+
+        /* the following code may be not needed */
+        if ( test_bit(VMX_CPU_STATE_LME_ENABLED, &v->arch.hvm_vmx.cpu_state) )
+            msr_content |= EFER_LME;
+        else
+            msr_content &= ~EFER_LME;
+
+        if ( VMX_LONG_GUEST(v) )
+            msr_content |= EFER_LMA;
+        else
+            msr_content &= ~EFER_LMA;
+        break;
+
     case MSR_FS_BASE:
-        if (!(VMX_LONG_GUEST(vc)))
+        if ( !(VMX_LONG_GUEST(v)) )
             /* XXX should it be GP fault */
             domain_crash_synchronous();
+
         __vmread(GUEST_FS_BASE, &msr_content);
         break;
+
     case MSR_GS_BASE:
-        if (!(VMX_LONG_GUEST(vc)))
+        if ( !(VMX_LONG_GUEST(v)) )
             domain_crash_synchronous();
+
         __vmread(GUEST_GS_BASE, &msr_content);
         break;
+
     case MSR_SHADOW_GS_BASE:
         msr_content = msr->shadow_gs;
         break;
 
-        CASE_READ_MSR(STAR);
-        CASE_READ_MSR(LSTAR);
-        CASE_READ_MSR(CSTAR);
-        CASE_READ_MSR(SYSCALL_MASK);
+    CASE_READ_MSR(STAR);
+    CASE_READ_MSR(LSTAR);
+    CASE_READ_MSR(CSTAR);
+    CASE_READ_MSR(SYSCALL_MASK);
+
     default:
         return 0;
     }
-    HVM_DBG_LOG(DBG_LEVEL_2, "mode_do_msr_read: msr_content: %"PRIx64"\n",
-                msr_content);
+
+    HVM_DBG_LOG(DBG_LEVEL_2, "msr_content: 0x%"PRIx64, msr_content);
+
     regs->eax = msr_content & 0xffffffff;
     regs->edx = msr_content >> 32;
+
     return 1;
 }
 
 static inline int long_mode_do_msr_write(struct cpu_user_regs *regs)
 {
-    u64     msr_content = regs->eax | ((u64)regs->edx << 32);
-    struct vcpu *vc = current;
-    struct vmx_msr_state * msr = &vc->arch.hvm_vmx.msr_content;
-    struct vmx_msr_state * host_state =
-        &percpu_msr[smp_processor_id()];
-
-    HVM_DBG_LOG(DBG_LEVEL_1, " mode_do_msr_write msr %lx "
-                "msr_content %"PRIx64"\n",
+    u64 msr_content = regs->eax | ((u64)regs->edx << 32);
+    struct vcpu *v = current;
+    struct vmx_msr_state *msr = &v->arch.hvm_vmx.msr_content;
+    struct vmx_msr_state *host_state = &percpu_msr[smp_processor_id()];
+
+    HVM_DBG_LOG(DBG_LEVEL_1, "msr 0x%lx msr_content 0x%"PRIx64"\n",
                 (unsigned long)regs->ecx, msr_content);
 
-    switch (regs->ecx){
+    switch ( regs->ecx ) {
     case MSR_EFER:
         /* offending reserved bit will cause #GP */
-        if ( msr_content &
-                ~( EFER_LME | EFER_LMA | EFER_NX | EFER_SCE ) )
-             vmx_inject_exception(vc, TRAP_gp_fault, 0);
-
-        if ((msr_content & EFER_LME) ^
-            test_bit(VMX_CPU_STATE_LME_ENABLED,
-                     &vc->arch.hvm_vmx.cpu_state)){
-            if ( vmx_paging_enabled(vc) ||
+        if ( msr_content & ~(EFER_LME | EFER_LMA | EFER_NX | EFER_SCE) )
+        {
+            printk("trying to set reserved bit in EFER\n");
+            vmx_inject_exception(v, TRAP_gp_fault, 0);
+            return 0;
+        }
+
+        /* LME: 0 -> 1 */
+        if ( msr_content & EFER_LME &&
+             !test_bit(VMX_CPU_STATE_LME_ENABLED, &v->arch.hvm_vmx.cpu_state) )
+        {
+            if ( vmx_paging_enabled(v) ||
                  !test_bit(VMX_CPU_STATE_PAE_ENABLED,
-                           &vc->arch.hvm_vmx.cpu_state)) {
-                vmx_inject_exception(vc, TRAP_gp_fault, 0);
+                           &v->arch.hvm_vmx.cpu_state) )
+            {
+                printk("trying to set LME bit when "
+                       "in paging mode or PAE bit is not set\n");
+                vmx_inject_exception(v, TRAP_gp_fault, 0);
+                return 0;
             }
-        }
-        if (msr_content & EFER_LME)
-            set_bit(VMX_CPU_STATE_LME_ENABLED,
-                    &vc->arch.hvm_vmx.cpu_state);
-
-        msr->msr_items[VMX_INDEX_MSR_EFER] =
-            msr_content;
+
+            set_bit(VMX_CPU_STATE_LME_ENABLED, &v->arch.hvm_vmx.cpu_state);
+        }
+
+        msr->msr_items[VMX_INDEX_MSR_EFER] = msr_content;
         break;
 
     case MSR_FS_BASE:
     case MSR_GS_BASE:
-        if (!(VMX_LONG_GUEST(vc)))
+        if ( !(VMX_LONG_GUEST(v)) )
             domain_crash_synchronous();
-        if (!IS_CANO_ADDRESS(msr_content)){
+
+        if ( !IS_CANO_ADDRESS(msr_content) )
+        {
             HVM_DBG_LOG(DBG_LEVEL_1, "Not cano address of msr write\n");
-            vmx_inject_exception(vc, TRAP_gp_fault, 0);
-        }
-        if (regs->ecx == MSR_FS_BASE)
+            vmx_inject_exception(v, TRAP_gp_fault, 0);
+            return 0;
+        }
+
+        if ( regs->ecx == MSR_FS_BASE )
             __vmwrite(GUEST_FS_BASE, msr_content);
         else
             __vmwrite(GUEST_GS_BASE, msr_content);
+
         break;
 
     case MSR_SHADOW_GS_BASE:
-        if (!(VMX_LONG_GUEST(vc)))
+        if ( !(VMX_LONG_GUEST(v)) )
             domain_crash_synchronous();
-        vc->arch.hvm_vmx.msr_content.shadow_gs = msr_content;
+
+        v->arch.hvm_vmx.msr_content.shadow_gs = msr_content;
         wrmsrl(MSR_SHADOW_GS_BASE, msr_content);
         break;
 
-        CASE_WRITE_MSR(STAR);
-        CASE_WRITE_MSR(LSTAR);
-        CASE_WRITE_MSR(CSTAR);
-        CASE_WRITE_MSR(SYSCALL_MASK);
+    CASE_WRITE_MSR(STAR);
+    CASE_WRITE_MSR(LSTAR);
+    CASE_WRITE_MSR(CSTAR);
+    CASE_WRITE_MSR(SYSCALL_MASK);
+
     default:
         return 0;
     }
+
     return 1;
 }
 
-void
-vmx_restore_msrs(struct vcpu *v)
+static void vmx_restore_msrs(struct vcpu *v)
 {
     int i = 0;
     struct vmx_msr_state *guest_state;
@@ -297,22 +328,52 @@
 
         HVM_DBG_LOG(DBG_LEVEL_2,
                     "restore guest's index %d msr %lx with %lx\n",
-                    i, (unsigned long) msr_data_index[i], (unsigned long) 
guest_state->msr_items[i]);
+                    i, (unsigned long)msr_data_index[i],
+                    (unsigned long)guest_state->msr_items[i]);
         set_bit(i, &host_state->flags);
         wrmsrl(msr_data_index[i], guest_state->msr_items[i]);
         clear_bit(i, &guest_flags);
     }
 }
 #else  /* __i386__ */
-#define  vmx_save_init_msrs()   ((void)0)
-
-static inline int  long_mode_do_msr_read(struct cpu_user_regs *regs){
+
+#define vmx_save_segments(v)      ((void)0)
+#define vmx_load_msrs()           ((void)0)
+#define vmx_restore_msrs(v)       ((void)0)
+#define vmx_save_init_msrs()      ((void)0)
+
+static inline int long_mode_do_msr_read(struct cpu_user_regs *regs)
+{
     return 0;
 }
-static inline int  long_mode_do_msr_write(struct cpu_user_regs *regs){
+
+static inline int long_mode_do_msr_write(struct cpu_user_regs *regs)
+{
     return 0;
 }
-#endif
+
+#endif /* __i386__ */
+
+static void vmx_freeze_time(struct vcpu *v)
+{
+    struct hvm_virpit *vpit = &v->domain->arch.hvm_domain.vpit;
+    
+    v->domain->arch.hvm_domain.guest_time = get_guest_time(v);
+    if ( vpit->first_injected )
+        stop_timer(&(vpit->pit_timer));
+}
+
+static void vmx_ctxt_switch_from(struct vcpu *v)
+{
+    vmx_freeze_time(v);
+    vmx_save_segments(v);
+    vmx_load_msrs();
+}
+
+static void vmx_ctxt_switch_to(struct vcpu *v)
+{
+    vmx_restore_msrs(v);
+}
 
 void stop_vmx(void)
 {
@@ -553,12 +614,6 @@
 
     hvm_funcs.store_cpu_guest_regs = vmx_store_cpu_guest_regs;
     hvm_funcs.load_cpu_guest_regs = vmx_load_cpu_guest_regs;
-
-#ifdef __x86_64__
-    hvm_funcs.save_segments = vmx_save_segments;
-    hvm_funcs.load_msrs = vmx_load_msrs;
-    hvm_funcs.restore_msrs = vmx_restore_msrs;
-#endif
 
     hvm_funcs.store_cpu_guest_ctrl_regs = vmx_store_cpu_guest_ctrl_regs;
     hvm_funcs.modify_guest_state = vmx_modify_guest_state;
@@ -1662,7 +1717,7 @@
 
         rdtscll(msr_content);
         vpit = &(v->domain->arch.hvm_domain.vpit);
-        msr_content += vpit->shift;
+        msr_content += vpit->cache_tsc_offset;
         break;
     }
     case MSR_IA32_SYSENTER_CS:
@@ -1706,22 +1761,8 @@
 
     switch (regs->ecx) {
     case MSR_IA32_TIME_STAMP_COUNTER:
-    {
-        struct hvm_virpit *vpit;
-        u64 host_tsc, drift;
-
-        rdtscll(host_tsc);
-        vpit = &(v->domain->arch.hvm_domain.vpit);
-        drift = v->arch.hvm_vmx.tsc_offset - vpit->shift;
-        vpit->shift = msr_content - host_tsc;
-       v->arch.hvm_vmx.tsc_offset = vpit->shift + drift;
-        __vmwrite(TSC_OFFSET, vpit->shift);
-
-#if defined (__i386__)
-        __vmwrite(TSC_OFFSET_HIGH, ((vpit->shift)>>32));
-#endif
-        break;
-    }
+        set_guest_time(v, msr_content);
+        break;
     case MSR_IA32_SYSENTER_CS:
         __vmwrite(GUEST_SYSENTER_CS, msr_content);
         break;
diff -r f163677f8767 -r a9f5cf43451f xen/arch/x86/smp.c
--- a/xen/arch/x86/smp.c        Tue Mar 21 16:55:44 2006
+++ b/xen/arch/x86/smp.c        Tue Mar 21 18:19:11 2006
@@ -266,7 +266,7 @@
 }
 
 /*
- * Structure and data for smp_call_function().
+ * Structure and data for smp_call_function()/on_selected_cpus().
  */
 
 struct call_data_struct {
@@ -275,41 +275,48 @@
     int wait;
     atomic_t started;
     atomic_t finished;
+    cpumask_t selected;
 };
 
-static spinlock_t call_lock = SPIN_LOCK_UNLOCKED;
+static DEFINE_SPINLOCK(call_lock);
 static struct call_data_struct *call_data;
 
-/*
- * Run a function on all other CPUs.
- *  @func: The function to run. This must be fast and non-blocking.
- *  @info: An arbitrary pointer to pass to the function.
- *  @wait: If true, spin until function has completed on other CPUs.
- *  Returns: 0 on success, else a negative status code.
- */
 int smp_call_function(
-    void (*func) (void *info), void *info, int unused, int wait)
+    void (*func) (void *info),
+    void *info,
+    int retry,
+    int wait)
+{
+    cpumask_t allbutself = cpu_online_map;
+    cpu_clear(smp_processor_id(), allbutself);
+    return on_selected_cpus(allbutself, func, info, retry, wait);
+}
+
+extern int on_selected_cpus(
+    cpumask_t selected,
+    void (*func) (void *info),
+    void *info,
+    int retry,
+    int wait)
 {
     struct call_data_struct data;
-    unsigned int nr_cpus = num_online_cpus() - 1;
+    unsigned int nr_cpus = cpus_weight(selected);
 
     ASSERT(local_irq_is_enabled());
-
-    if ( nr_cpus == 0 )
-        return 0;
 
     data.func = func;
     data.info = info;
     data.wait = wait;
     atomic_set(&data.started, 0);
     atomic_set(&data.finished, 0);
+    data.selected = selected;
 
     spin_lock(&call_lock);
 
     call_data = &data;
     wmb();
 
-    send_IPI_allbutself(CALL_FUNCTION_VECTOR);
+    send_IPI_mask(selected, CALL_FUNCTION_VECTOR);
 
     while ( atomic_read(wait ? &data.finished : &data.started) != nr_cpus )
         cpu_relax();
@@ -353,6 +360,9 @@
     ack_APIC_irq();
     perfc_incrc(ipis);
 
+    if ( !cpu_isset(smp_processor_id(), call_data->selected) )
+        return;
+
     if ( call_data->wait )
     {
         (*func)(info);
diff -r f163677f8767 -r a9f5cf43451f xen/common/Makefile
--- a/xen/common/Makefile       Tue Mar 21 16:55:44 2006
+++ b/xen/common/Makefile       Tue Mar 21 18:19:11 2006
@@ -1,19 +1,34 @@
-
 include $(BASEDIR)/Rules.mk
 
-ifneq ($(perfc),y)
-OBJS := $(subst perfc.o,,$(OBJS))
-endif
-ifneq ($(crash_debug),y)
-OBJS := $(patsubst gdbstub.o,,$(OBJS))
-endif
+obj-y += acm_ops.o
+obj-y += bitmap.o
+obj-y += dom0_ops.o
+obj-y += domain.o
+obj-y += elf.o
+obj-y += event_channel.o
+obj-y += grant_table.o
+obj-y += kernel.o
+obj-y += keyhandler.o
+obj-y += lib.o
+obj-y += memory.o
+obj-y += multicall.o
+obj-y += page_alloc.o
+obj-y += rangeset.o
+obj-y += sched_bvt.o
+obj-y += sched_sedf.o
+obj-y += schedule.o
+obj-y += softirq.o
+obj-y += string.o
+obj-y += symbols.o
+obj-y += trace.o
+obj-y += timer.o
+obj-y += vsprintf.o
+obj-y += xmalloc.o
 
-default: common.o
-common.o: $(OBJS)
-       $(LD) $(LDFLAGS) -r -o common.o $(OBJS)
+obj-$(perfc)       += perfc.o
+obj-$(crash_debug) += gdbstub.o
 
-clean:
-       rm -f *.o *~ core
+include $(BASEDIR)/Post.mk
 
 # Object file contains changeset and compiler information.
 kernel.o: $(BASEDIR)/include/xen/compile.h
diff -r f163677f8767 -r a9f5cf43451f xen/drivers/Makefile
--- a/xen/drivers/Makefile      Tue Mar 21 16:55:44 2006
+++ b/xen/drivers/Makefile      Tue Mar 21 18:19:11 2006
@@ -1,8 +1,6 @@
+include $(BASEDIR)/Rules.mk
 
-default:
-       $(MAKE) -C char
-       $(MAKE) -C acpi
+subdir-y += char
+subdir-$(HAS_ACPI) += acpi
 
-clean:
-       $(MAKE) -C char clean
-       $(MAKE) -C acpi clean
+include $(BASEDIR)/Post.mk
diff -r f163677f8767 -r a9f5cf43451f xen/drivers/acpi/Makefile
--- a/xen/drivers/acpi/Makefile Tue Mar 21 16:55:44 2006
+++ b/xen/drivers/acpi/Makefile Tue Mar 21 18:19:11 2006
@@ -1,11 +1,5 @@
-
 include $(BASEDIR)/Rules.mk
 
-OBJS := tables.o
+obj-y += tables.o
 
-default: driver.o
-driver.o: $(OBJS)
-       $(LD) $(LDFLAGS) -r -o driver.o $(OBJS)
-
-clean:
-       rm -f *.o *~ core
+include $(BASEDIR)/Post.mk
diff -r f163677f8767 -r a9f5cf43451f xen/drivers/char/Makefile
--- a/xen/drivers/char/Makefile Tue Mar 21 16:55:44 2006
+++ b/xen/drivers/char/Makefile Tue Mar 21 18:19:11 2006
@@ -1,12 +1,10 @@
-
 include $(BASEDIR)/Rules.mk
 
-default: driver.o
-driver.o: $(OBJS)
-       $(LD) $(LDFLAGS) -r -o driver.o $(OBJS)
+obj-y += console.o
+obj-y += ns16550.o
+obj-y += serial.o
 
-clean:
-       rm -f *.o *~ core
+include $(BASEDIR)/Post.mk
 
 # Object file contains changeset and compiler information.
 console.o: $(BASEDIR)/include/xen/compile.h
diff -r f163677f8767 -r a9f5cf43451f xen/include/asm-ia64/linux/asm/irq.h
--- a/xen/include/asm-ia64/linux/asm/irq.h      Tue Mar 21 16:55:44 2006
+++ b/xen/include/asm-ia64/linux/asm/irq.h      Tue Mar 21 18:19:11 2006
@@ -40,4 +40,6 @@
 struct pt_regs;
 int handle_IRQ_event(unsigned int, struct pt_regs *, struct irqaction *);
 
+extern fastcall unsigned int __do_IRQ(unsigned int irq, struct pt_regs *regs);
+
 #endif /* _ASM_IA64_IRQ_H */
diff -r f163677f8767 -r a9f5cf43451f xen/include/asm-x86/domain.h
--- a/xen/include/asm-x86/domain.h      Tue Mar 21 16:55:44 2006
+++ b/xen/include/asm-x86/domain.h      Tue Mar 21 18:19:11 2006
@@ -124,6 +124,9 @@
 
     void (*schedule_tail) (struct vcpu *);
 
+    void (*ctxt_switch_from) (struct vcpu *);
+    void (*ctxt_switch_to) (struct vcpu *);
+
     /* Bounce information for propagating an exception to guest OS. */
     struct trap_bounce trap_bounce;
 
diff -r f163677f8767 -r a9f5cf43451f xen/include/asm-x86/genapic.h
--- a/xen/include/asm-x86/genapic.h     Tue Mar 21 16:55:44 2006
+++ b/xen/include/asm-x86/genapic.h     Tue Mar 21 18:19:11 2006
@@ -34,23 +34,13 @@
        physid_mask_t (*ioapic_phys_id_map)(physid_mask_t map);
 
        void (*clustered_apic_check)(void);
-       int (*multi_timer_check)(int apic, int irq);
        int (*apicid_to_node)(int logical_apicid); 
        int (*cpu_to_logical_apicid)(int cpu);
        int (*cpu_present_to_apicid)(int mps_cpu);
        physid_mask_t (*apicid_to_cpu_present)(int phys_apicid);
-       int (*mpc_apic_id)(struct mpc_config_processor *m, 
-                          struct mpc_config_translation *t); 
-       void (*setup_portio_remap)(void); 
        int (*check_phys_apicid_present)(int boot_cpu_physical_apicid);
        void (*enable_apic_mode)(void);
        u32 (*phys_pkg_id)(u32 cpuid_apic, int index_msb);
-
-       /* mpparse */
-       void (*mpc_oem_bus_info)(struct mpc_config_bus *, char *, 
-                                struct mpc_config_translation *);
-       void (*mpc_oem_pci_bus)(struct mpc_config_bus *, 
-                               struct mpc_config_translation *); 
 
        /* When one of the next two hooks returns 1 the genapic
           is switched to this. Essentially they are additional probe 
@@ -60,7 +50,6 @@
        int (*acpi_madt_oem_check)(char *oem_id, char *oem_table_id);
 
        unsigned (*get_apic_id)(unsigned long x);
-       unsigned long apic_id_mask;
        unsigned int (*cpu_mask_to_apicid)(cpumask_t cpumask);
        
        /* ipi */
@@ -86,19 +75,13 @@
        APICFUNC(init_apic_ldr), \
        APICFUNC(ioapic_phys_id_map), \
        APICFUNC(clustered_apic_check), \
-       APICFUNC(multi_timer_check), \
        APICFUNC(apicid_to_node), \
        APICFUNC(cpu_to_logical_apicid), \
        APICFUNC(cpu_present_to_apicid), \
        APICFUNC(apicid_to_cpu_present), \
-       APICFUNC(mpc_apic_id), \
-       APICFUNC(setup_portio_remap), \
        APICFUNC(check_phys_apicid_present), \
-       APICFUNC(mpc_oem_bus_info), \
-       APICFUNC(mpc_oem_pci_bus), \
        APICFUNC(mps_oem_check), \
        APICFUNC(get_apic_id), \
-       .apic_id_mask = APIC_ID_MASK, \
        APICFUNC(cpu_mask_to_apicid), \
        APICFUNC(acpi_madt_oem_check), \
        APICFUNC(send_IPI_mask), \
diff -r f163677f8767 -r a9f5cf43451f xen/include/asm-x86/hvm/domain.h
--- a/xen/include/asm-x86/hvm/domain.h  Tue Mar 21 16:55:44 2006
+++ b/xen/include/asm-x86/hvm/domain.h  Tue Mar 21 18:19:11 2006
@@ -37,6 +37,7 @@
     unsigned int           pae_enabled;
 
     struct hvm_virpit      vpit;
+    u64                    guest_time;
     struct hvm_virpic      vpic;
     struct hvm_vioapic     vioapic;
     struct hvm_io_handler  io_handler;
diff -r f163677f8767 -r a9f5cf43451f xen/include/asm-x86/hvm/hvm.h
--- a/xen/include/asm-x86/hvm/hvm.h     Tue Mar 21 16:55:44 2006
+++ b/xen/include/asm-x86/hvm/hvm.h     Tue Mar 21 18:19:11 2006
@@ -41,18 +41,11 @@
     /*
      * Store and load guest state:
      * 1) load/store guest register state,
-     * 2) load/store segment state (x86_64 only),
-     * 3) load/store msr register state (x86_64 only),
-     * 4) store guest control register state (used for panic dumps),
-     * 5) modify guest state (e.g., set debug flags).
+     * 2) store guest control register state (used for panic dumps),
+     * 3) modify guest state (e.g., set debug flags).
      */
     void (*store_cpu_guest_regs)(struct vcpu *v, struct cpu_user_regs *r);
     void (*load_cpu_guest_regs)(struct vcpu *v, struct cpu_user_regs *r);
-#ifdef __x86_64__
-    void (*save_segments)(struct vcpu *v);
-    void (*load_msrs)(void);
-    void (*restore_msrs)(struct vcpu *v);
-#endif
     void (*store_cpu_guest_ctrl_regs)(struct vcpu *v, unsigned long crs[8]);
     void (*modify_guest_state)(struct vcpu *v);
 
@@ -111,33 +104,6 @@
     hvm_funcs.load_cpu_guest_regs(v, r);
 }
 
-#ifdef __x86_64__
-static inline void
-hvm_save_segments(struct vcpu *v)
-{
-    if (hvm_funcs.save_segments)
-        hvm_funcs.save_segments(v);
-}
-
-static inline void
-hvm_load_msrs(void)
-{
-    if (hvm_funcs.load_msrs)
-        hvm_funcs.load_msrs();
-}
-
-static inline void
-hvm_restore_msrs(struct vcpu *v)
-{
-    if (hvm_funcs.restore_msrs)
-        hvm_funcs.restore_msrs(v);
-}
-#else
-#define hvm_save_segments(v)    ((void)0)
-#define hvm_load_msrs(v)        ((void)0)
-#define hvm_restore_msrs(v)     ((void)0)
-#endif /* __x86_64__ */
-
 static inline void
 hvm_store_cpu_guest_ctrl_regs(struct vcpu *v, unsigned long crs[8])
 {
diff -r f163677f8767 -r a9f5cf43451f xen/include/asm-x86/hvm/vmx/vmcs.h
--- a/xen/include/asm-x86/hvm/vmx/vmcs.h        Tue Mar 21 16:55:44 2006
+++ b/xen/include/asm-x86/hvm/vmx/vmcs.h        Tue Mar 21 18:19:11 2006
@@ -77,7 +77,6 @@
     unsigned long           cpu_based_exec_control;
     struct vmx_msr_state    msr_content;
     void                    *io_bitmap_a, *io_bitmap_b;
-    u64                     tsc_offset;
     struct timer            hlt_timer;  /* hlt ins emulation wakeup timer */
 };
 
diff -r f163677f8767 -r a9f5cf43451f xen/include/asm-x86/hvm/vmx/vmx.h
--- a/xen/include/asm-x86/hvm/vmx/vmx.h Tue Mar 21 16:55:44 2006
+++ b/xen/include/asm-x86/hvm/vmx/vmx.h Tue Mar 21 18:19:11 2006
@@ -30,10 +30,11 @@
 extern void vmx_asm_do_resume(void);
 extern void vmx_asm_do_launch(void);
 extern void vmx_intr_assist(void);
-extern void vmx_set_tsc_shift(struct vcpu *, struct hvm_virpit *);
 extern void vmx_migrate_timers(struct vcpu *v);
 extern void arch_vmx_do_launch(struct vcpu *);
 extern void arch_vmx_do_resume(struct vcpu *);
+extern void set_guest_time(struct vcpu *v, u64 gtime);
+extern u64  get_guest_time(struct vcpu *v);
 
 extern unsigned int cpu_rev;
 
diff -r f163677f8767 -r a9f5cf43451f xen/include/asm-x86/hvm/vpit.h
--- a/xen/include/asm-x86/hvm/vpit.h    Tue Mar 21 16:55:44 2006
+++ b/xen/include/asm-x86/hvm/vpit.h    Tue Mar 21 18:19:11 2006
@@ -38,7 +38,6 @@
 struct hvm_virpit {
     /* for simulation of counter 0 in mode 2 */
     u64 period_cycles;          /* pit frequency in cpu cycles */
-    u64 shift;                  /* save the value of offset - drift */
     s_time_t inject_point;      /* the time inject virt intr */
     s_time_t scheduled;         /* scheduled timer interrupt */
     struct timer pit_timer;     /* periodic timer for mode 2*/
@@ -46,6 +45,8 @@
     unsigned int pending_intr_nr; /* the couner for pending timer interrupts */
     u32 period;                 /* pit frequency in ns */
     int first_injected;         /* flag to prevent shadow window */
+    s64 cache_tsc_offset;       /* cache of VMCS TSC_OFFSET offset */
+    u64 last_pit_gtime;         /* guest time when last pit is injected */
 
     /* virtual PIT state for handle related I/O */
     int read_state;
diff -r f163677f8767 -r a9f5cf43451f xen/include/asm-x86/mach-bigsmp/mach_apic.h
--- a/xen/include/asm-x86/mach-bigsmp/mach_apic.h       Tue Mar 21 16:55:44 2006
+++ b/xen/include/asm-x86/mach-bigsmp/mach_apic.h       Tue Mar 21 18:19:11 2006
@@ -1,17 +1,10 @@
 #ifndef __ASM_MACH_APIC_H
 #define __ASM_MACH_APIC_H
-#include <asm/smp.h>
 
-#define SEQUENTIAL_APICID
-#ifdef SEQUENTIAL_APICID
-#define xapic_phys_to_log_apicid(phys_apic) ( (1ul << ((phys_apic) & 0x3)) |\
-               ((phys_apic<<2) & (~0xf)) )
-#elif CLUSTERED_APICID
-#define xapic_phys_to_log_apicid(phys_apic) ( (1ul << ((phys_apic) & 0x3)) |\
-               ((phys_apic) & (~0xf)) )
-#endif
 
-#define NO_BALANCE_IRQ (1)
+extern u8 bios_cpu_apicid[];
+
+#define xapic_phys_to_log_apicid(cpu) (bios_cpu_apicid[cpu])
 #define esr_disable (1)
 
 static inline int apic_id_registered(void)
@@ -19,7 +12,6 @@
        return (1);
 }
 
-#define APIC_DFR_VALUE (APIC_DFR_CLUSTER)
 /* Round robin the irqs amoung the online cpus */
 static inline cpumask_t target_cpus(void)
 { 
@@ -32,29 +24,34 @@
        } while (cpu >= NR_CPUS);
        return cpumask_of_cpu(cpu);
 }
-#define TARGET_CPUS    (target_cpus())
 
-#define INT_DELIVERY_MODE dest_Fixed
-#define INT_DEST_MODE 1     /* logical delivery broadcast to all procs */
+#undef APIC_DEST_LOGICAL
+#define APIC_DEST_LOGICAL      0
+#define TARGET_CPUS            (target_cpus())
+#define APIC_DFR_VALUE         (APIC_DFR_FLAT)
+#define INT_DELIVERY_MODE      (dest_Fixed)
+#define INT_DEST_MODE          (0)    /* phys delivery to target proc */
+#define NO_BALANCE_IRQ         (0)
+#define WAKE_SECONDARY_VIA_INIT
+
 
 static inline unsigned long check_apicid_used(physid_mask_t bitmap, int apicid)
 {
-       return 0;
+       return (0);
 }
 
-/* we don't use the phys_cpu_present_map to indicate apicid presence */
-static inline unsigned long check_apicid_present(int bit) 
+static inline unsigned long check_apicid_present(int bit)
 {
-       return 1;
+       return (1);
 }
 
-#define apicid_cluster(apicid) (apicid & 0xF0)
-
-static inline unsigned long calculate_ldr(unsigned long old)
+static inline unsigned long calculate_ldr(int cpu)
 {
-       unsigned long id;
-       id = xapic_phys_to_log_apicid(hard_smp_processor_id());
-       return ((old & ~APIC_LDR_MASK) | SET_APIC_LOGICAL_ID(id));
+       unsigned long val, id;
+       val = apic_read(APIC_LDR) & ~APIC_LDR_MASK;
+       id = xapic_phys_to_log_apicid(cpu);
+       val |= SET_APIC_LOGICAL_ID(id);
+       return val;
 }
 
 /*
@@ -67,37 +64,30 @@
 static inline void init_apic_ldr(void)
 {
        unsigned long val;
+       int cpu = smp_processor_id();
 
        apic_write_around(APIC_DFR, APIC_DFR_VALUE);
-       val = apic_read(APIC_LDR) & ~APIC_LDR_MASK;
-       val = calculate_ldr(val);
+       val = calculate_ldr(cpu);
        apic_write_around(APIC_LDR, val);
 }
 
 static inline void clustered_apic_check(void)
 {
        printk("Enabling APIC mode:  %s.  Using %d I/O APICs\n",
-               "Cluster", nr_ioapics);
-}
-
-static inline int multi_timer_check(int apic, int irq)
-{
-       return 0;
+               "Physflat", nr_ioapics);
 }
 
 static inline int apicid_to_node(int logical_apicid)
 {
-       return 0;
+       return (0);
 }
-
-extern u8 bios_cpu_apicid[];
 
 static inline int cpu_present_to_apicid(int mps_cpu)
 {
        if (mps_cpu < NR_CPUS)
-               return (int)bios_cpu_apicid[mps_cpu];
-       else
-               return BAD_APICID;
+               return (int) bios_cpu_apicid[mps_cpu];
+
+       return BAD_APICID;
 }
 
 static inline physid_mask_t apicid_to_cpu_present(int phys_apicid)
@@ -109,32 +99,15 @@
 /* Mapping from cpu number to logical apicid */
 static inline int cpu_to_logical_apicid(int cpu)
 {
-       if (cpu >= NR_CPUS)
-              return BAD_APICID;
-       return (int)cpu_2_logical_apicid[cpu];
- }
-
-static inline int mpc_apic_id(struct mpc_config_processor *m,
-                       struct mpc_config_translation *translation_record)
-{
-       printk("Processor #%d %d:%d APIC version %d\n",
-               m->mpc_apicid,
-               (m->mpc_cpufeature & CPU_FAMILY_MASK) >> 8,
-               (m->mpc_cpufeature & CPU_MODEL_MASK) >> 4,
-               m->mpc_apicver);
-       return m->mpc_apicid;
+       if (cpu >= NR_CPUS)
+               return BAD_APICID;
+       return cpu_physical_id(cpu);
 }
 
 static inline physid_mask_t ioapic_phys_id_map(physid_mask_t phys_map)
 {
        /* For clustered we don't have a good way to do this yet - hack */
-       return physids_promote(0xFUL);
-}
-
-#define WAKE_SECONDARY_VIA_INIT
-
-static inline void setup_portio_remap(void)
-{
+       return physids_promote(0xFFL);
 }
 
 static inline void enable_apic_mode(void)
diff -r f163677f8767 -r a9f5cf43451f 
xen/include/asm-x86/mach-bigsmp/mach_apicdef.h
--- a/xen/include/asm-x86/mach-bigsmp/mach_apicdef.h    Tue Mar 21 16:55:44 2006
+++ b/xen/include/asm-x86/mach-bigsmp/mach_apicdef.h    Tue Mar 21 18:19:11 2006
@@ -1,11 +1,9 @@
 #ifndef __ASM_MACH_APICDEF_H
 #define __ASM_MACH_APICDEF_H
 
-#define                APIC_ID_MASK            (0x0F<<24)
-
 static inline unsigned get_apic_id(unsigned long x) 
 { 
-       return (((x)>>24)&0x0F);
+       return (((x)>>24)&0xFF);
 } 
 
 #define                GET_APIC_ID(x)  get_apic_id(x)
diff -r f163677f8767 -r a9f5cf43451f 
xen/include/asm-x86/mach-default/mach_apic.h
--- a/xen/include/asm-x86/mach-default/mach_apic.h      Tue Mar 21 16:55:44 2006
+++ b/xen/include/asm-x86/mach-default/mach_apic.h      Tue Mar 21 18:19:11 2006
@@ -60,11 +60,6 @@
                                        "Flat", nr_ioapics);
 }
 
-static inline int multi_timer_check(int apic, int irq)
-{
-       return 0;
-}
-
 static inline int apicid_to_node(int logical_apicid)
 {
        return 0;
@@ -87,21 +82,6 @@
 static inline physid_mask_t apicid_to_cpu_present(int phys_apicid)
 {
        return physid_mask_of_physid(phys_apicid);
-}
-
-static inline int mpc_apic_id(struct mpc_config_processor *m, 
-                       struct mpc_config_translation *translation_record)
-{
-       printk("Processor #%d %d:%d APIC version %d\n",
-                       m->mpc_apicid,
-                       (m->mpc_cpufeature & CPU_FAMILY_MASK) >> 8,
-                       (m->mpc_cpufeature & CPU_MODEL_MASK) >> 4,
-                       m->mpc_apicver);
-       return (m->mpc_apicid);
-}
-
-static inline void setup_portio_remap(void)
-{
 }
 
 static inline int check_phys_apicid_present(int boot_cpu_physical_apicid)
diff -r f163677f8767 -r a9f5cf43451f 
xen/include/asm-x86/mach-default/mach_apicdef.h
--- a/xen/include/asm-x86/mach-default/mach_apicdef.h   Tue Mar 21 16:55:44 2006
+++ b/xen/include/asm-x86/mach-default/mach_apicdef.h   Tue Mar 21 18:19:11 2006
@@ -1,7 +1,5 @@
 #ifndef __ASM_MACH_APICDEF_H
 #define __ASM_MACH_APICDEF_H
-
-#define                APIC_ID_MASK            (0xF<<24)
 
 static inline unsigned get_apic_id(unsigned long x) 
 { 
diff -r f163677f8767 -r a9f5cf43451f xen/include/asm-x86/mach-default/mach_ipi.h
--- a/xen/include/asm-x86/mach-default/mach_ipi.h       Tue Mar 21 16:55:44 2006
+++ b/xen/include/asm-x86/mach-default/mach_ipi.h       Tue Mar 21 18:19:11 2006
@@ -4,9 +4,30 @@
 void send_IPI_mask_bitmask(cpumask_t mask, int vector);
 void __send_IPI_shortcut(unsigned int shortcut, int vector);
 
+extern int no_broadcast;
+
 static inline void send_IPI_mask(cpumask_t mask, int vector)
 {
        send_IPI_mask_bitmask(mask, vector);
+}
+
+static inline void __local_send_IPI_allbutself(int vector)
+{
+       if (no_broadcast) {
+               cpumask_t mask = cpu_online_map;
+
+               cpu_clear(smp_processor_id(), mask);
+               send_IPI_mask(mask, vector);
+       } else
+               __send_IPI_shortcut(APIC_DEST_ALLBUT, vector);
+}
+
+static inline void __local_send_IPI_all(int vector)
+{
+       if (no_broadcast)
+               send_IPI_mask(cpu_online_map, vector);
+       else
+               __send_IPI_shortcut(APIC_DEST_ALLINC, vector);
 }
 
 static inline void send_IPI_allbutself(int vector)
@@ -18,13 +39,13 @@
        if (!(num_online_cpus() > 1))
                return;
 
-       __send_IPI_shortcut(APIC_DEST_ALLBUT, vector);
+       __local_send_IPI_allbutself(vector);
        return;
 }
 
 static inline void send_IPI_all(int vector)
 {
-       __send_IPI_shortcut(APIC_DEST_ALLINC, vector);
+       __local_send_IPI_all(vector);
 }
 
 #endif /* __ASM_MACH_IPI_H */
diff -r f163677f8767 -r a9f5cf43451f 
xen/include/asm-x86/mach-default/mach_mpparse.h
--- a/xen/include/asm-x86/mach-default/mach_mpparse.h   Tue Mar 21 16:55:44 2006
+++ b/xen/include/asm-x86/mach-default/mach_mpparse.h   Tue Mar 21 18:19:11 2006
@@ -1,16 +1,5 @@
 #ifndef __ASM_MACH_MPPARSE_H
 #define __ASM_MACH_MPPARSE_H
-
-static inline void mpc_oem_bus_info(struct mpc_config_bus *m, char *name, 
-                               struct mpc_config_translation *translation)
-{
-//     Dprintk("Bus #%d is %s\n", m->mpc_busid, name);
-}
-
-static inline void mpc_oem_pci_bus(struct mpc_config_bus *m, 
-                               struct mpc_config_translation *translation)
-{
-}
 
 static inline int mps_oem_check(struct mp_config_table *mpc, char *oem, 
                char *productid)
diff -r f163677f8767 -r a9f5cf43451f xen/include/asm-x86/mach-es7000/mach_apic.h
--- a/xen/include/asm-x86/mach-es7000/mach_apic.h       Tue Mar 21 16:55:44 2006
+++ b/xen/include/asm-x86/mach-es7000/mach_apic.h       Tue Mar 21 18:19:11 2006
@@ -89,11 +89,6 @@
                "Physical Cluster" : "Logical Cluster", nr_ioapics, 
cpus_addr(TARGET_CPUS)[0]);
 }
 
-static inline int multi_timer_check(int apic, int irq)
-{
-       return 0;
-}
-
 static inline int apicid_to_node(int logical_apicid)
 {
        return 0;
@@ -128,25 +123,10 @@
        return (int)cpu_2_logical_apicid[cpu];
 }
 
-static inline int mpc_apic_id(struct mpc_config_processor *m, struct 
mpc_config_translation *unused)
-{
-       printk("Processor #%d %d:%d APIC version %d\n",
-               m->mpc_apicid,
-               (m->mpc_cpufeature & CPU_FAMILY_MASK) >> 8,
-               (m->mpc_cpufeature & CPU_MODEL_MASK) >> 4,
-               m->mpc_apicver);
-       return (m->mpc_apicid);
-}
-
 static inline physid_mask_t ioapic_phys_id_map(physid_mask_t phys_map)
 {
        /* For clustered we don't have a good way to do this yet - hack */
        return physids_promote(0xff);
-}
-
-
-static inline void setup_portio_remap(void)
-{
 }
 
 extern unsigned int boot_cpu_physical_apicid;
diff -r f163677f8767 -r a9f5cf43451f 
xen/include/asm-x86/mach-es7000/mach_apicdef.h
--- a/xen/include/asm-x86/mach-es7000/mach_apicdef.h    Tue Mar 21 16:55:44 2006
+++ b/xen/include/asm-x86/mach-es7000/mach_apicdef.h    Tue Mar 21 18:19:11 2006
@@ -1,7 +1,5 @@
 #ifndef __ASM_MACH_APICDEF_H
 #define __ASM_MACH_APICDEF_H
-
-#define                APIC_ID_MASK            (0xFF<<24)
 
 static inline unsigned get_apic_id(unsigned long x) 
 { 
diff -r f163677f8767 -r a9f5cf43451f 
xen/include/asm-x86/mach-es7000/mach_mpparse.h
--- a/xen/include/asm-x86/mach-es7000/mach_mpparse.h    Tue Mar 21 16:55:44 2006
+++ b/xen/include/asm-x86/mach-es7000/mach_mpparse.h    Tue Mar 21 18:19:11 2006
@@ -1,19 +1,11 @@
 #ifndef __ASM_MACH_MPPARSE_H
 #define __ASM_MACH_MPPARSE_H
 
-static inline void mpc_oem_bus_info(struct mpc_config_bus *m, char *name, 
-                               struct mpc_config_translation *translation)
-{
-       Dprintk("Bus #%d is %s\n", m->mpc_busid, name);
-}
+#include <xen/acpi.h>
 
-static inline void mpc_oem_pci_bus(struct mpc_config_bus *m, 
-                               struct mpc_config_translation *translation)
-{
-}
-
-extern int parse_unisys_oem (char *oemptr, int oem_entries);
-extern int find_unisys_acpi_oem_table(unsigned long *oem_addr, int *length);
+extern int parse_unisys_oem (char *oemptr);
+extern int find_unisys_acpi_oem_table(unsigned long *oem_addr);
+extern void setup_unisys(void);
 
 static inline int mps_oem_check(struct mp_config_table *mpc, char *oem,
                char *productid)
@@ -22,8 +14,18 @@
                struct mp_config_oemtable *oem_table = 
                        (struct mp_config_oemtable *)(long)mpc->mpc_oemptr;
                if (!strncmp(oem, "UNISYS", 6))
-                       return parse_unisys_oem((char *)oem_table, 
oem_table->oem_length);
+                       return parse_unisys_oem((char *)oem_table);
        }
+       return 0;
+}
+
+static inline int es7000_check_dsdt(void)
+{
+       struct acpi_table_header *header = NULL;
+       if(!acpi_get_table_header_early(ACPI_DSDT, &header))
+               acpi_table_print(header, 0);
+       if (!strncmp(header->oem_id, "UNISYS", 6))
+               return 1;
        return 0;
 }
 
@@ -31,9 +33,14 @@
 static inline int acpi_madt_oem_check(char *oem_id, char *oem_table_id)
 {
        unsigned long oem_addr; 
-       int oem_entries;
-       if (!find_unisys_acpi_oem_table(&oem_addr, &oem_entries))
-               return parse_unisys_oem((char *)oem_addr, oem_entries);
+       if (!find_unisys_acpi_oem_table(&oem_addr)) {
+               if (es7000_check_dsdt())
+                       return parse_unisys_oem((char *)oem_addr);
+               else {
+                       setup_unisys();
+                       return 1;
+               }
+       }
        return 0;
 }
 
diff -r f163677f8767 -r a9f5cf43451f 
xen/include/asm-x86/mach-generic/mach_apic.h
--- a/xen/include/asm-x86/mach-generic/mach_apic.h      Tue Mar 21 16:55:44 2006
+++ b/xen/include/asm-x86/mach-generic/mach_apic.h      Tue Mar 21 18:19:11 2006
@@ -14,13 +14,10 @@
 #define init_apic_ldr (genapic->init_apic_ldr)
 #define ioapic_phys_id_map (genapic->ioapic_phys_id_map)
 #define clustered_apic_check (genapic->clustered_apic_check) 
-#define multi_timer_check (genapic->multi_timer_check)
 #define apicid_to_node (genapic->apicid_to_node)
 #define cpu_to_logical_apicid (genapic->cpu_to_logical_apicid) 
 #define cpu_present_to_apicid (genapic->cpu_present_to_apicid)
 #define apicid_to_cpu_present (genapic->apicid_to_cpu_present)
-#define mpc_apic_id (genapic->mpc_apic_id) 
-#define setup_portio_remap (genapic->setup_portio_remap)
 #define check_apicid_present (genapic->check_apicid_present)
 #define check_phys_apicid_present (genapic->check_phys_apicid_present)
 #define check_apicid_used (genapic->check_apicid_used)
@@ -28,6 +25,26 @@
 #define enable_apic_mode (genapic->enable_apic_mode)
 #define phys_pkg_id (genapic->phys_pkg_id)
 
+static inline int mpc_apic_id(struct mpc_config_processor *m, 
+                       struct mpc_config_translation *translation_record)
+{
+       printk("Processor #%d %d:%d APIC version %d\n",
+                       m->mpc_apicid,
+                       (m->mpc_cpufeature & CPU_FAMILY_MASK) >> 8,
+                       (m->mpc_cpufeature & CPU_MODEL_MASK) >> 4,
+                       m->mpc_apicver);
+       return (m->mpc_apicid);
+}
+
+static inline void setup_portio_remap(void)
+{
+}
+
+static inline int multi_timer_check(int apic, int irq)
+{
+       return 0;
+}
+
 extern void generic_bigsmp_probe(void);
 
 #endif /* __ASM_MACH_APIC_H */
diff -r f163677f8767 -r a9f5cf43451f 
xen/include/asm-x86/mach-generic/mach_apicdef.h
--- a/xen/include/asm-x86/mach-generic/mach_apicdef.h   Tue Mar 21 16:55:44 2006
+++ b/xen/include/asm-x86/mach-generic/mach_apicdef.h   Tue Mar 21 18:19:11 2006
@@ -5,7 +5,6 @@
 #include <asm/genapic.h>
 
 #define GET_APIC_ID (genapic->get_apic_id)
-#define APIC_ID_MASK (genapic->apic_id_mask)
 #endif
 
 #endif
diff -r f163677f8767 -r a9f5cf43451f 
xen/include/asm-x86/mach-generic/mach_mpparse.h
--- a/xen/include/asm-x86/mach-generic/mach_mpparse.h   Tue Mar 21 16:55:44 2006
+++ b/xen/include/asm-x86/mach-generic/mach_mpparse.h   Tue Mar 21 18:19:11 2006
@@ -1,10 +1,16 @@
 #ifndef _MACH_MPPARSE_H
 #define _MACH_MPPARSE_H 1
 
-#include <asm/genapic.h>
+static inline void mpc_oem_bus_info(struct mpc_config_bus *m, char *name, 
+                               struct mpc_config_translation *translation)
+{
+       Dprintk("Bus #%d is %s\n", m->mpc_busid, name);
+}
 
-#define mpc_oem_bus_info (genapic->mpc_oem_bus_info)
-#define mpc_oem_pci_bus (genapic->mpc_oem_pci_bus)
+static inline void mpc_oem_pci_bus(struct mpc_config_bus *m, 
+                               struct mpc_config_translation *translation)
+{
+}
 
 int mps_oem_check(struct mp_config_table *mpc, char *oem, char *productid); 
 int acpi_madt_oem_check(char *oem_id, char *oem_table_id); 
diff -r f163677f8767 -r a9f5cf43451f xen/include/asm-x86/mach-summit/mach_apic.h
--- a/xen/include/asm-x86/mach-summit/mach_apic.h       Tue Mar 21 16:55:44 2006
+++ b/xen/include/asm-x86/mach-summit/mach_apic.h       Tue Mar 21 18:19:11 2006
@@ -68,11 +68,6 @@
        apic_write_around(APIC_LDR, val);
 }
 
-static inline int multi_timer_check(int apic, int irq)
-{
-       return 0;
-}
-
 static inline int apic_id_registered(void)
 {
        return 1;
@@ -114,21 +109,6 @@
 static inline physid_mask_t apicid_to_cpu_present(int apicid)
 {
        return physid_mask_of_physid(0);
-}
-
-static inline int mpc_apic_id(struct mpc_config_processor *m, 
-                       struct mpc_config_translation *translation_record)
-{
-       printk("Processor #%d %d:%d APIC version %d\n",
-                       m->mpc_apicid,
-                       (m->mpc_cpufeature & CPU_FAMILY_MASK) >> 8,
-                       (m->mpc_cpufeature & CPU_MODEL_MASK) >> 4,
-                       m->mpc_apicver);
-       return (m->mpc_apicid);
-}
-
-static inline void setup_portio_remap(void)
-{
 }
 
 static inline int check_phys_apicid_present(int boot_cpu_physical_apicid)
diff -r f163677f8767 -r a9f5cf43451f 
xen/include/asm-x86/mach-summit/mach_apicdef.h
--- a/xen/include/asm-x86/mach-summit/mach_apicdef.h    Tue Mar 21 16:55:44 2006
+++ b/xen/include/asm-x86/mach-summit/mach_apicdef.h    Tue Mar 21 18:19:11 2006
@@ -1,7 +1,5 @@
 #ifndef __ASM_MACH_APICDEF_H
 #define __ASM_MACH_APICDEF_H
-
-#define                APIC_ID_MASK            (0xFF<<24)
 
 static inline unsigned get_apic_id(unsigned long x) 
 { 
diff -r f163677f8767 -r a9f5cf43451f 
xen/include/asm-x86/mach-summit/mach_mpparse.h
--- a/xen/include/asm-x86/mach-summit/mach_mpparse.h    Tue Mar 21 16:55:44 2006
+++ b/xen/include/asm-x86/mach-summit/mach_mpparse.h    Tue Mar 21 18:19:11 2006
@@ -10,17 +10,6 @@
 #else
 #define setup_summit() {}
 #endif
-
-static inline void mpc_oem_bus_info(struct mpc_config_bus *m, char *name, 
-                               struct mpc_config_translation *translation)
-{
-       Dprintk("Bus #%d is %s\n", m->mpc_busid, name);
-}
-
-static inline void mpc_oem_pci_bus(struct mpc_config_bus *m, 
-                               struct mpc_config_translation *translation)
-{
-}
 
 extern int usb_early_handoff;
 static inline int mps_oem_check(struct mp_config_table *mpc, char *oem, 
diff -r f163677f8767 -r a9f5cf43451f xen/include/xen/irq.h
--- a/xen/include/xen/irq.h     Tue Mar 21 16:55:44 2006
+++ b/xen/include/xen/irq.h     Tue Mar 21 18:19:11 2006
@@ -71,6 +71,5 @@
 extern int pirq_guest_unmask(struct domain *p);
 extern int pirq_guest_bind(struct vcpu *p, int irq, int will_share);
 extern int pirq_guest_unbind(struct domain *p, int irq);
-extern  fastcall unsigned int __do_IRQ(unsigned int irq, struct pt_regs *regs);
 
 #endif /* __XEN_IRQ_H__ */
diff -r f163677f8767 -r a9f5cf43451f xen/include/xen/smp.h
--- a/xen/include/xen/smp.h     Tue Mar 21 16:55:44 2006
+++ b/xen/include/xen/smp.h     Tue Mar 21 18:19:11 2006
@@ -45,32 +45,34 @@
  * Call a function on all other processors
  */
 extern int smp_call_function(
-    void (*func) (void *info), void *info, int retry, int wait);
+    void (*func) (void *info),
+    void *info,
+    int retry,
+    int wait);
+
+/* 
+ * Call a function on a selection of processors
+ */
+extern int on_selected_cpus(
+    cpumask_t selected,
+    void (*func) (void *info),
+    void *info,
+    int retry,
+    int wait);
 
 /*
  * Call a function on all processors
  */
-static inline int on_each_cpu(void (*func) (void *info), void *info,
-                              int retry, int wait)
+static inline int on_each_cpu(
+    void (*func) (void *info),
+    void *info,
+    int retry,
+    int wait)
 {
     int ret = smp_call_function(func, info, retry, wait);
     func(info);
     return ret;
 }
-
-extern volatile unsigned long smp_msg_data;
-extern volatile int smp_src_cpu;
-extern volatile int smp_msg_id;
-
-#define MSG_ALL_BUT_SELF       0x8000  /* Assume <32768 CPU's */
-#define MSG_ALL                        0x8001
-
-#define MSG_INVALIDATE_TLB     0x0001  /* Remote processor TLB invalidate */
-#define MSG_STOP_CPU           0x0002  /* Sent to shut down slave CPU's
-                                        * when rebooting
-                                        */
-#define MSG_RESCHEDULE         0x0003  /* Reschedule request from master CPU*/
-#define MSG_CALL_FUNCTION       0x0004  /* Call function on all other CPUs */
 
 /*
  * Mark the boot cpu "online" so that it can call console drivers in
@@ -93,6 +95,18 @@
 #define num_booting_cpus()                     1
 #define smp_prepare_boot_cpu()                 do {} while (0)
 
+static inline int on_selected_cpus(
+    cpumask_t selected,
+    void (*func) (void *info),
+    void *info,
+    int retry,
+    int wait)
+{
+    if ( cpu_isset(0, selected) )
+        func(info);
+    return 0;
+}
+
 #endif
 
 #define smp_processor_id() raw_smp_processor_id()
diff -r f163677f8767 -r a9f5cf43451f 
linux-2.6-xen-sparse/drivers/xen/core/hypervisor_sysfs.c
--- /dev/null   Tue Mar 21 16:55:44 2006
+++ b/linux-2.6-xen-sparse/drivers/xen/core/hypervisor_sysfs.c  Tue Mar 21 
18:19:11 2006
@@ -0,0 +1,57 @@
+/*
+ *  copyright (c) 2006 IBM Corporation
+ *  Authored by: Mike D. Day <ncmike@xxxxxxxxxx>
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 2 as
+ *  published by the Free Software Foundation.
+ */
+
+#include <linux/config.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/kobject.h>
+#include <xen/hypervisor_sysfs.h>
+
+decl_subsys(hypervisor, NULL, NULL);
+
+static ssize_t hyp_sysfs_show(struct kobject *kobj,
+                             struct attribute *attr,
+                             char *buffer)
+{
+       struct hyp_sysfs_attr *hyp_attr;
+       hyp_attr = container_of(attr, struct hyp_sysfs_attr, attr);
+       if (hyp_attr->show)
+               return hyp_attr->show(hyp_attr, buffer);
+       return 0;
+}
+
+static ssize_t hyp_sysfs_store(struct kobject *kobj,
+                              struct attribute *attr,
+                              const char *buffer,
+                              size_t len)
+{
+       struct hyp_sysfs_attr *hyp_attr;
+       hyp_attr = container_of(attr, struct hyp_sysfs_attr, attr);
+       if (hyp_attr->store)
+               return hyp_attr->store(hyp_attr, buffer, len);
+       return 0;
+}
+
+struct sysfs_ops hyp_sysfs_ops = {
+       .show = hyp_sysfs_show,
+       .store = hyp_sysfs_store,
+};
+
+static struct kobj_type hyp_sysfs_kobj_type = {
+       .sysfs_ops = &hyp_sysfs_ops,
+};
+
+static int __init hypervisor_subsys_init(void)
+{
+       hypervisor_subsys.kset.kobj.ktype = &hyp_sysfs_kobj_type;
+       return subsystem_register(&hypervisor_subsys);
+}
+
+device_initcall(hypervisor_subsys_init);
+EXPORT_SYMBOL_GPL(hypervisor_subsys);
diff -r f163677f8767 -r a9f5cf43451f 
linux-2.6-xen-sparse/drivers/xen/core/xen_sysfs.c
--- /dev/null   Tue Mar 21 16:55:44 2006
+++ b/linux-2.6-xen-sparse/drivers/xen/core/xen_sysfs.c Tue Mar 21 18:19:11 2006
@@ -0,0 +1,310 @@
+/*
+ *  copyright (c) 2006 IBM Corporation
+ *  Authored by: Mike D. Day <ncmike@xxxxxxxxxx>
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 2 as
+ *  published by the Free Software Foundation.
+ */
+
+#include <linux/config.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <asm/hypervisor.h>
+#include <xen/hypervisor_sysfs.h>
+
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Mike D. Day <ncmike@xxxxxxxxxx>");
+
+static ssize_t type_show(struct hyp_sysfs_attr *attr, char *buffer)
+{
+       return sprintf(buffer, "xen\n");
+}
+
+HYPERVISOR_ATTR_RO(type);
+
+static int __init xen_sysfs_type_init(void)
+{
+       return sysfs_create_file(&hypervisor_subsys.kset.kobj, &type_attr.attr);
+}
+
+static void xen_sysfs_type_destroy(void)
+{
+       sysfs_remove_file(&hypervisor_subsys.kset.kobj, &type_attr.attr);
+}
+
+/* xen version attributes */
+static ssize_t major_show(struct hyp_sysfs_attr *attr, char *buffer)
+{
+       int version = HYPERVISOR_xen_version(XENVER_version, NULL);
+       if (version)
+               return sprintf(buffer, "%d\n", version >> 16);
+       return -ENODEV;
+}
+
+HYPERVISOR_ATTR_RO(major);
+
+static ssize_t minor_show(struct hyp_sysfs_attr *attr, char *buffer)
+{
+       int version = HYPERVISOR_xen_version(XENVER_version, NULL);
+       if (version)
+               return sprintf(buffer, "%d\n", version & 0xff);
+       return -ENODEV;
+}
+
+HYPERVISOR_ATTR_RO(minor);
+
+static ssize_t extra_show(struct hyp_sysfs_attr *attr, char *buffer)
+{
+       int ret;
+       char *extra = kmalloc(XEN_EXTRAVERSION_LEN, GFP_KERNEL);
+       if (extra) {
+               ret = HYPERVISOR_xen_version(XENVER_extraversion, extra);
+               if (!ret)
+                       return sprintf(buffer, "%s\n", extra);
+               kfree(extra);
+       } else
+               ret = -ENOMEM;
+       return ret;
+}
+
+HYPERVISOR_ATTR_RO(extra);
+
+static struct attribute *version_attrs[] = {
+       &major_attr.attr,
+       &minor_attr.attr,
+       &extra_attr.attr,
+       NULL
+};
+
+static struct attribute_group version_group = {
+       .name = "version",
+       .attrs = version_attrs,
+};
+
+static int __init xen_sysfs_version_init(void)
+{
+       return sysfs_create_group(&hypervisor_subsys.kset.kobj, &version_group);
+}
+
+static void xen_sysfs_version_destroy(void)
+{
+       sysfs_remove_group(&hypervisor_subsys.kset.kobj, &version_group);
+}
+
+/* xen compilation attributes */
+
+static ssize_t compiler_show(struct hyp_sysfs_attr *attr, char *buffer)
+{
+       int ret;
+       struct xen_compile_info *info =
+           kmalloc(sizeof(struct xen_compile_info), GFP_KERNEL);
+       if (info) {
+               ret = HYPERVISOR_xen_version(XENVER_compile_info, info);
+               if (!ret)
+                       ret = sprintf(buffer, "%s\n", info->compiler);
+               kfree(info);
+       } else
+               ret = -ENOMEM;
+
+       return ret;
+}
+
+HYPERVISOR_ATTR_RO(compiler);
+
+static ssize_t compiled_by_show(struct hyp_sysfs_attr *attr, char *buffer)
+{
+       int ret;
+       struct xen_compile_info *info;
+
+       info = kmalloc(sizeof(struct xen_compile_info), GFP_KERNEL);
+       if (info) {
+               ret = HYPERVISOR_xen_version(XENVER_compile_info, info);
+               if (!ret)
+                       ret = sprintf(buffer, "%s\n", info->compile_by);
+               kfree(info);
+       } else
+               ret = -ENOMEM;
+       return ret;
+}
+
+HYPERVISOR_ATTR_RO(compiled_by);
+
+static ssize_t compile_date_show(struct hyp_sysfs_attr *attr, char *buffer)
+{
+       int ret;
+       struct xen_compile_info *info;
+
+       info = kmalloc(sizeof(struct xen_compile_info), GFP_KERNEL);
+       if (info) {
+               ret = HYPERVISOR_xen_version(XENVER_compile_info, info);
+               if (!ret)
+                       ret = sprintf(buffer, "%s\n", info->compile_date);
+               kfree(info);
+       } else
+               ret = -ENOMEM;
+       return ret;
+}
+
+HYPERVISOR_ATTR_RO(compile_date);
+
+static struct attribute *xen_compile_attrs[] = {
+       &compiler_attr.attr,
+       &compiled_by_attr.attr,
+       &compile_date_attr.attr,
+       NULL
+};
+
+static struct attribute_group xen_compilation_group = {
+       .name = "compilation",
+       .attrs = xen_compile_attrs,
+};
+
+int __init static xen_compilation_init(void)
+{
+       return sysfs_create_group(&hypervisor_subsys.kset.kobj,
+                                 &xen_compilation_group);
+}
+
+static void xen_compilation_destroy(void)
+{
+       sysfs_remove_group(&hypervisor_subsys.kset.kobj,
+                          &xen_compilation_group);
+}
+
+/* xen properties info */
+
+static ssize_t capabilities_show(struct hyp_sysfs_attr *attr, char *buffer)
+{
+       int ret;
+       char *caps = kmalloc(XEN_CAPABILITIES_INFO_LEN, GFP_KERNEL);
+       if (caps) {
+               ret = HYPERVISOR_xen_version(XENVER_capabilities, caps);
+               if (!ret)
+                       ret = sprintf(buffer, "%s\n", caps);
+               kfree(caps);
+       } else
+               ret = -ENOMEM;
+       return ret;
+}
+
+HYPERVISOR_ATTR_RO(capabilities);
+
+static ssize_t changeset_show(struct hyp_sysfs_attr *attr, char *buffer)
+{
+       int ret;
+       char *cset = kmalloc(XEN_CHANGESET_INFO_LEN, GFP_KERNEL);
+       if (cset) {
+               ret = HYPERVISOR_xen_version(XENVER_changeset, cset);
+               if (!ret)
+                       ret = sprintf(buffer, "%s\n", cset);
+               kfree(cset);
+       } else
+               ret = -ENOMEM;
+       return ret;
+}
+
+HYPERVISOR_ATTR_RO(changeset);
+
+static ssize_t virtual_start_show(struct hyp_sysfs_attr *attr, char *buffer)
+{
+       int ret;
+       struct xen_platform_parameters *parms =
+           kmalloc(sizeof(struct xen_platform_parameters), GFP_KERNEL);
+       if (parms) {
+               ret = HYPERVISOR_xen_version(XENVER_platform_parameters, parms);
+               if (!ret)
+                       ret = sprintf(buffer, "%lx\n", parms->virt_start);
+               kfree(parms);
+       } else
+               ret = -ENOMEM;
+       return ret;
+}
+
+HYPERVISOR_ATTR_RO(virtual_start);
+
+/* eventually there will be several more features to export */
+static ssize_t xen_feature_show(int index, char *buffer)
+{
+       int ret;
+
+       struct xen_feature_info *info =
+           kmalloc(sizeof(struct xen_feature_info), GFP_KERNEL);
+       if (info) {
+               info->submap_idx = index;
+               ret = HYPERVISOR_xen_version(XENVER_get_features, info);
+               if (!ret)
+                       ret = sprintf(buffer, "%d\n", info->submap);
+               kfree(info);
+       } else
+               ret = -ENOMEM;
+       return ret;
+}
+
+static ssize_t writable_pt_show(struct hyp_sysfs_attr *attr, char *buffer)
+{
+       return xen_feature_show(XENFEAT_writable_page_tables, buffer);
+}
+
+HYPERVISOR_ATTR_RO(writable_pt);
+
+static struct attribute *xen_properties_attrs[] = {
+       &capabilities_attr.attr,
+       &changeset_attr.attr,
+       &virtual_start_attr.attr,
+       &writable_pt_attr.attr,
+       NULL
+};
+
+static struct attribute_group xen_properties_group = {
+       .name = "properties",
+       .attrs = xen_properties_attrs,
+};
+
+static int __init xen_properties_init(void)
+{
+       return sysfs_create_group(&hypervisor_subsys.kset.kobj,
+                                 &xen_properties_group);
+}
+
+static void xen_properties_destroy(void)
+{
+       sysfs_remove_group(&hypervisor_subsys.kset.kobj, &xen_properties_group);
+}
+
+static int __init hyper_sysfs_init(void)
+{
+       int ret = xen_sysfs_type_init();
+       if (ret)
+               goto out;
+       ret = xen_sysfs_version_init();
+       if (ret)
+               goto version_out;
+       ret = xen_compilation_init();
+       if (ret)
+               goto comp_out;
+       ret = xen_properties_init();
+       if (!ret)
+               goto out;
+
+       xen_compilation_destroy();
+comp_out:
+       xen_sysfs_version_destroy();
+version_out:
+       xen_sysfs_type_destroy();
+out:
+       return ret;
+}
+
+static void hyper_sysfs_exit(void)
+{
+       xen_properties_destroy();
+       xen_compilation_destroy();
+       xen_sysfs_version_destroy();
+       xen_sysfs_type_destroy();
+
+}
+
+module_init(hyper_sysfs_init);
+module_exit(hyper_sysfs_exit);
diff -r f163677f8767 -r a9f5cf43451f 
linux-2.6-xen-sparse/include/xen/hypervisor_sysfs.h
--- /dev/null   Tue Mar 21 16:55:44 2006
+++ b/linux-2.6-xen-sparse/include/xen/hypervisor_sysfs.h       Tue Mar 21 
18:19:11 2006
@@ -0,0 +1,32 @@
+/*
+ *  copyright (c) 2006 IBM Corporation
+ *  Authored by: Mike D. Day <ncmike@xxxxxxxxxx>
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 2 as
+ *  published by the Free Software Foundation.
+ */
+
+#ifndef _HYP_SYSFS_H_
+#define _HYP_SYSFS_H_
+
+#include <linux/kobject.h>
+#include <linux/sysfs.h>
+
+#define HYPERVISOR_ATTR_RO(_name) \
+static struct hyp_sysfs_attr  _name##_attr = __ATTR_RO(_name)
+
+#define HYPERVISOR_ATTR_RW(_name) \
+static struct hyp_sysfs_attr _name##_attr = \
+       __ATTR(_name, 0644, _name##_show, _name##_store)
+
+extern struct subsystem hypervisor_subsys;
+
+struct hyp_sysfs_attr {
+       struct attribute attr;
+       ssize_t (*show)(struct hyp_sysfs_attr *, char *);
+       ssize_t (*store)(struct hyp_sysfs_attr *, const char *, size_t);
+       void *hyp_attr_data;
+};
+
+#endif /* _HYP_SYSFS_H_ */
diff -r f163677f8767 -r a9f5cf43451f 
patches/linux-2.6.16/i386-mach-io-check-nmi.patch
--- /dev/null   Tue Mar 21 16:55:44 2006
+++ b/patches/linux-2.6.16/i386-mach-io-check-nmi.patch Tue Mar 21 18:19:11 2006
@@ -0,0 +1,45 @@
+diff -pruN ../pristine-linux-2.6.16/arch/i386/kernel/traps.c 
./arch/i386/kernel/traps.c
+--- ../pristine-linux-2.6.16/arch/i386/kernel/traps.c  2006-03-20 
05:53:29.000000000 +0000
++++ ./arch/i386/kernel/traps.c 2006-03-20 19:38:17.000000000 +0000
+@@ -567,18 +567,11 @@ static void mem_parity_error(unsigned ch
+ 
+ static void io_check_error(unsigned char reason, struct pt_regs * regs)
+ {
+-      unsigned long i;
+-
+       printk(KERN_EMERG "NMI: IOCK error (debug interrupt?)\n");
+       show_registers(regs);
+ 
+       /* Re-enable the IOCK line, wait for a few seconds */
+-      reason = (reason & 0xf) | 8;
+-      outb(reason, 0x61);
+-      i = 2000;
+-      while (--i) udelay(1000);
+-      reason &= ~8;
+-      outb(reason, 0x61);
++      clear_io_check_error(reason);
+ }
+ 
+ static void unknown_nmi_error(unsigned char reason, struct pt_regs * regs)
+diff -pruN ../pristine-linux-2.6.16/include/asm-i386/mach-default/mach_traps.h 
./include/asm-i386/mach-default/mach_traps.h
+--- ../pristine-linux-2.6.16/include/asm-i386/mach-default/mach_traps.h        
2006-03-20 05:53:29.000000000 +0000
++++ ./include/asm-i386/mach-default/mach_traps.h       2006-03-20 
19:38:17.000000000 +0000
+@@ -15,6 +15,18 @@ static inline void clear_mem_error(unsig
+       outb(reason, 0x61);
+ }
+ 
++static inline void clear_io_check_error(unsigned char reason)
++{
++      unsigned long i;
++
++      reason = (reason & 0xf) | 8;
++      outb(reason, 0x61);
++      i = 2000;
++      while (--i) udelay(1000);
++      reason &= ~8;
++      outb(reason, 0x61);
++}
++
+ static inline unsigned char get_nmi_reason(void)
+ {
+       return inb(0x61);
diff -r f163677f8767 -r a9f5cf43451f patches/linux-2.6.16/net-csum.patch
--- /dev/null   Tue Mar 21 16:55:44 2006
+++ b/patches/linux-2.6.16/net-csum.patch       Tue Mar 21 18:19:11 2006
@@ -0,0 +1,41 @@
+diff -pruN ../pristine-linux-2.6.16/net/ipv4/netfilter/ip_nat_proto_tcp.c 
./net/ipv4/netfilter/ip_nat_proto_tcp.c
+--- ../pristine-linux-2.6.16/net/ipv4/netfilter/ip_nat_proto_tcp.c     
2006-03-20 05:53:29.000000000 +0000
++++ ./net/ipv4/netfilter/ip_nat_proto_tcp.c    2006-03-20 19:38:19.000000000 
+0000
+@@ -129,10 +129,14 @@ tcp_manip_pkt(struct sk_buff **pskb,
+       if (hdrsize < sizeof(*hdr))
+               return 1;
+ 
+-      hdr->check = ip_nat_cheat_check(~oldip, newip,
++      if ((*pskb)->proto_csum_blank) {
++              hdr->check = ip_nat_cheat_check(oldip, ~newip, hdr->check);
++      } else {
++              hdr->check = ip_nat_cheat_check(~oldip, newip,
+                                       ip_nat_cheat_check(oldport ^ 0xFFFF,
+                                                          newport,
+                                                          hdr->check));
++      }
+       return 1;
+ }
+ 
+diff -pruN ../pristine-linux-2.6.16/net/ipv4/netfilter/ip_nat_proto_udp.c 
./net/ipv4/netfilter/ip_nat_proto_udp.c
+--- ../pristine-linux-2.6.16/net/ipv4/netfilter/ip_nat_proto_udp.c     
2006-03-20 05:53:29.000000000 +0000
++++ ./net/ipv4/netfilter/ip_nat_proto_udp.c    2006-03-20 19:38:19.000000000 
+0000
+@@ -113,11 +113,16 @@ udp_manip_pkt(struct sk_buff **pskb,
+               newport = tuple->dst.u.udp.port;
+               portptr = &hdr->dest;
+       }
+-      if (hdr->check) /* 0 is a special case meaning no checksum */
+-              hdr->check = ip_nat_cheat_check(~oldip, newip,
++      if (hdr->check) { /* 0 is a special case meaning no checksum */
++              if ((*pskb)->proto_csum_blank) {
++                      hdr->check = ip_nat_cheat_check(oldip, ~newip, 
hdr->check);
++              } else {
++                      hdr->check = ip_nat_cheat_check(~oldip, newip,
+                                       ip_nat_cheat_check(*portptr ^ 0xFFFF,
+                                                          newport,
+                                                          hdr->check));
++              }
++      }
+       *portptr = newport;
+       return 1;
+ }
diff -r f163677f8767 -r a9f5cf43451f patches/linux-2.6.16/pmd-shared.patch
--- /dev/null   Tue Mar 21 16:55:44 2006
+++ b/patches/linux-2.6.16/pmd-shared.patch     Tue Mar 21 18:19:11 2006
@@ -0,0 +1,111 @@
+diff -pruN ../pristine-linux-2.6.16/arch/i386/mm/pageattr.c 
./arch/i386/mm/pageattr.c
+--- ../pristine-linux-2.6.16/arch/i386/mm/pageattr.c   2006-03-20 
05:53:29.000000000 +0000
++++ ./arch/i386/mm/pageattr.c  2006-03-20 19:38:23.000000000 +0000
+@@ -78,7 +78,7 @@ static void set_pmd_pte(pte_t *kpte, uns
+       unsigned long flags;
+ 
+       set_pte_atomic(kpte, pte);      /* change init_mm */
+-      if (PTRS_PER_PMD > 1)
++      if (HAVE_SHARED_KERNEL_PMD)
+               return;
+ 
+       spin_lock_irqsave(&pgd_lock, flags);
+diff -pruN ../pristine-linux-2.6.16/arch/i386/mm/pgtable.c 
./arch/i386/mm/pgtable.c
+--- ../pristine-linux-2.6.16/arch/i386/mm/pgtable.c    2006-03-20 
05:53:29.000000000 +0000
++++ ./arch/i386/mm/pgtable.c   2006-03-20 19:38:23.000000000 +0000
+@@ -215,9 +215,10 @@ void pgd_ctor(void *pgd, kmem_cache_t *c
+               spin_lock_irqsave(&pgd_lock, flags);
+       }
+ 
+-      clone_pgd_range((pgd_t *)pgd + USER_PTRS_PER_PGD,
+-                      swapper_pg_dir + USER_PTRS_PER_PGD,
+-                      KERNEL_PGD_PTRS);
++      if (PTRS_PER_PMD == 1 || HAVE_SHARED_KERNEL_PMD)
++              clone_pgd_range((pgd_t *)pgd + USER_PTRS_PER_PGD,
++                              swapper_pg_dir + USER_PTRS_PER_PGD,
++                              KERNEL_PGD_PTRS);
+       if (PTRS_PER_PMD > 1)
+               return;
+ 
+@@ -249,6 +250,30 @@ pgd_t *pgd_alloc(struct mm_struct *mm)
+                       goto out_oom;
+               set_pgd(&pgd[i], __pgd(1 + __pa(pmd)));
+       }
++
++      if (!HAVE_SHARED_KERNEL_PMD) {
++              unsigned long flags;
++
++              for (i = USER_PTRS_PER_PGD; i < PTRS_PER_PGD; i++) {
++                      pmd_t *pmd = kmem_cache_alloc(pmd_cache, GFP_KERNEL);
++                      if (!pmd)
++                              goto out_oom;
++                      set_pgd(&pgd[USER_PTRS_PER_PGD], __pgd(1 + __pa(pmd)));
++              }
++
++              spin_lock_irqsave(&pgd_lock, flags);
++              for (i = USER_PTRS_PER_PGD; i < PTRS_PER_PGD; i++) {
++                      unsigned long v = (unsigned long)i << PGDIR_SHIFT;
++                      pgd_t *kpgd = pgd_offset_k(v);
++                      pud_t *kpud = pud_offset(kpgd, v);
++                      pmd_t *kpmd = pmd_offset(kpud, v);
++                      pmd_t *pmd = (void *)__va(pgd_val(pgd[i])-1);
++                      memcpy(pmd, kpmd, PAGE_SIZE);
++              }
++              pgd_list_add(pgd);
++              spin_unlock_irqrestore(&pgd_lock, flags);
++      }
++
+       return pgd;
+ 
+ out_oom:
+@@ -263,9 +288,23 @@ void pgd_free(pgd_t *pgd)
+       int i;
+ 
+       /* in the PAE case user pgd entries are overwritten before usage */
+-      if (PTRS_PER_PMD > 1)
+-              for (i = 0; i < USER_PTRS_PER_PGD; ++i)
+-                      kmem_cache_free(pmd_cache, (void 
*)__va(pgd_val(pgd[i])-1));
++      if (PTRS_PER_PMD > 1) {
++              for (i = 0; i < USER_PTRS_PER_PGD; ++i) {
++                      pmd_t *pmd = (void *)__va(pgd_val(pgd[i])-1);
++                      kmem_cache_free(pmd_cache, pmd);
++              }
++              if (!HAVE_SHARED_KERNEL_PMD) {
++                      unsigned long flags;
++                      spin_lock_irqsave(&pgd_lock, flags);
++                      pgd_list_del(pgd);
++                      spin_unlock_irqrestore(&pgd_lock, flags);
++                      for (i = USER_PTRS_PER_PGD; i < PTRS_PER_PGD; i++) {
++                              pmd_t *pmd = (void *)__va(pgd_val(pgd[i])-1);
++                              memset(pmd, 0, PTRS_PER_PMD*sizeof(pmd_t));
++                              kmem_cache_free(pmd_cache, pmd);
++                      }
++              }
++      }
+       /* in the non-PAE case, free_pgtables() clears user pgd entries */
+       kmem_cache_free(pgd_cache, pgd);
+ }
+diff -pruN ../pristine-linux-2.6.16/include/asm-i386/pgtable-2level-defs.h 
./include/asm-i386/pgtable-2level-defs.h
+--- ../pristine-linux-2.6.16/include/asm-i386/pgtable-2level-defs.h    
2006-03-20 05:53:29.000000000 +0000
++++ ./include/asm-i386/pgtable-2level-defs.h   2006-03-20 19:38:23.000000000 
+0000
+@@ -1,6 +1,8 @@
+ #ifndef _I386_PGTABLE_2LEVEL_DEFS_H
+ #define _I386_PGTABLE_2LEVEL_DEFS_H
+ 
++#define HAVE_SHARED_KERNEL_PMD 0
++
+ /*
+  * traditional i386 two-level paging structure:
+  */
+diff -pruN ../pristine-linux-2.6.16/include/asm-i386/pgtable-3level-defs.h 
./include/asm-i386/pgtable-3level-defs.h
+--- ../pristine-linux-2.6.16/include/asm-i386/pgtable-3level-defs.h    
2006-03-20 05:53:29.000000000 +0000
++++ ./include/asm-i386/pgtable-3level-defs.h   2006-03-20 19:38:23.000000000 
+0000
+@@ -1,6 +1,8 @@
+ #ifndef _I386_PGTABLE_3LEVEL_DEFS_H
+ #define _I386_PGTABLE_3LEVEL_DEFS_H
+ 
++#define HAVE_SHARED_KERNEL_PMD 1
++
+ /*
+  * PGDIR_SHIFT determines what a top-level page table entry can map
+  */
diff -r f163677f8767 -r a9f5cf43451f patches/linux-2.6.16/smp-alts.patch
--- /dev/null   Tue Mar 21 16:55:44 2006
+++ b/patches/linux-2.6.16/smp-alts.patch       Tue Mar 21 18:19:11 2006
@@ -0,0 +1,591 @@
+diff -pruN ../pristine-linux-2.6.16/arch/i386/Kconfig ./arch/i386/Kconfig
+--- ../pristine-linux-2.6.16/arch/i386/Kconfig 2006-03-20 05:53:29.000000000 
+0000
++++ ./arch/i386/Kconfig        2006-03-20 19:38:27.000000000 +0000
+@@ -202,6 +202,19 @@ config SMP
+ 
+         If you don't know what to do here, say N.
+ 
++config SMP_ALTERNATIVES
++      bool "SMP alternatives support (EXPERIMENTAL)"
++      depends on SMP && EXPERIMENTAL
++      help
++        Try to reduce the overhead of running an SMP kernel on a uniprocessor
++        host slightly by replacing certain key instruction sequences
++        according to whether we currently have more than one CPU available.
++        This should provide a noticeable boost to performance when
++        running SMP kernels on UP machines, and have negligible impact
++        when running on an true SMP host.
++
++          If unsure, say N.
++        
+ config NR_CPUS
+       int "Maximum number of CPUs (2-255)"
+       range 2 255
+diff -pruN ../pristine-linux-2.6.16/arch/i386/kernel/Makefile 
./arch/i386/kernel/Makefile
+--- ../pristine-linux-2.6.16/arch/i386/kernel/Makefile 2006-03-20 
05:53:29.000000000 +0000
++++ ./arch/i386/kernel/Makefile        2006-03-20 19:38:27.000000000 +0000
+@@ -37,6 +37,7 @@ obj-$(CONFIG_EFI)            += efi.o efi_stub.o
+ obj-$(CONFIG_DOUBLEFAULT)     += doublefault.o
+ obj-$(CONFIG_VM86)            += vm86.o
+ obj-$(CONFIG_EARLY_PRINTK)    += early_printk.o
++obj-$(CONFIG_SMP_ALTERNATIVES)  += smpalts.o
+ 
+ EXTRA_AFLAGS   := -traditional
+ 
+diff -pruN ../pristine-linux-2.6.16/arch/i386/kernel/smpalts.c 
./arch/i386/kernel/smpalts.c
+--- ../pristine-linux-2.6.16/arch/i386/kernel/smpalts.c        1970-01-01 
01:00:00.000000000 +0100
++++ ./arch/i386/kernel/smpalts.c       2006-03-20 19:38:27.000000000 +0000
+@@ -0,0 +1,85 @@
++#include <linux/kernel.h>
++#include <asm/system.h>
++#include <asm/smp_alt.h>
++#include <asm/processor.h>
++#include <asm/string.h>
++
++struct smp_replacement_record {
++      unsigned char targ_size;
++      unsigned char smp1_size;
++      unsigned char smp2_size;
++      unsigned char up_size;
++      unsigned char feature;
++      unsigned char data[0];
++};
++
++struct smp_alternative_record {
++      void *targ_start;
++      struct smp_replacement_record *repl;
++};
++
++extern struct smp_alternative_record __start_smp_alternatives_table,
++  __stop_smp_alternatives_table;
++extern unsigned long __init_begin, __init_end;
++
++void prepare_for_smp(void)
++{
++      struct smp_alternative_record *r;
++      printk(KERN_INFO "Enabling SMP...\n");
++      for (r = &__start_smp_alternatives_table;
++           r != &__stop_smp_alternatives_table;
++           r++) {
++              BUG_ON(r->repl->targ_size < r->repl->smp1_size);
++              BUG_ON(r->repl->targ_size < r->repl->smp2_size);
++              BUG_ON(r->repl->targ_size < r->repl->up_size);
++               if (system_state == SYSTEM_RUNNING &&
++                   r->targ_start >= (void *)&__init_begin &&
++                   r->targ_start < (void *)&__init_end)
++                       continue;
++              if (r->repl->feature != (unsigned char)-1 &&
++                  boot_cpu_has(r->repl->feature)) {
++                      memcpy(r->targ_start,
++                             r->repl->data + r->repl->smp1_size,
++                             r->repl->smp2_size);
++                      memset(r->targ_start + r->repl->smp2_size,
++                             0x90,
++                             r->repl->targ_size - r->repl->smp2_size);
++              } else {
++                      memcpy(r->targ_start,
++                             r->repl->data,
++                             r->repl->smp1_size);
++                      memset(r->targ_start + r->repl->smp1_size,
++                             0x90,
++                             r->repl->targ_size - r->repl->smp1_size);
++              }
++      }
++      /* Paranoia */
++      asm volatile ("jmp 1f\n1:");
++      mb();
++}
++
++void unprepare_for_smp(void)
++{
++      struct smp_alternative_record *r;
++      printk(KERN_INFO "Disabling SMP...\n");
++      for (r = &__start_smp_alternatives_table;
++           r != &__stop_smp_alternatives_table;
++           r++) {
++              BUG_ON(r->repl->targ_size < r->repl->smp1_size);
++              BUG_ON(r->repl->targ_size < r->repl->smp2_size);
++              BUG_ON(r->repl->targ_size < r->repl->up_size);
++               if (system_state == SYSTEM_RUNNING &&
++                   r->targ_start >= (void *)&__init_begin &&
++                   r->targ_start < (void *)&__init_end)
++                       continue;
++              memcpy(r->targ_start,
++                     r->repl->data + r->repl->smp1_size + r->repl->smp2_size,
++                     r->repl->up_size);
++              memset(r->targ_start + r->repl->up_size,
++                     0x90,
++                     r->repl->targ_size - r->repl->up_size);
++      }
++      /* Paranoia */
++      asm volatile ("jmp 1f\n1:");
++      mb();
++}
+diff -pruN ../pristine-linux-2.6.16/arch/i386/kernel/smpboot.c 
./arch/i386/kernel/smpboot.c
+--- ../pristine-linux-2.6.16/arch/i386/kernel/smpboot.c        2006-03-20 
05:53:29.000000000 +0000
++++ ./arch/i386/kernel/smpboot.c       2006-03-20 19:38:27.000000000 +0000
+@@ -1218,6 +1218,11 @@ static void __init smp_boot_cpus(unsigne
+               if (max_cpus <= cpucount+1)
+                       continue;
+ 
++#ifdef CONFIG_SMP_ALTERNATIVES
++              if (kicked == 1)
++                      prepare_for_smp();
++#endif
++
+               if (((cpu = alloc_cpu_id()) <= 0) || do_boot_cpu(apicid, cpu))
+                       printk("CPU #%d not responding - cannot use it.\n",
+                                                               apicid);
+@@ -1396,6 +1401,11 @@ int __devinit __cpu_up(unsigned int cpu)
+               return -EIO;
+       }
+ 
++#ifdef CONFIG_SMP_ALTERNATIVES
++      if (num_online_cpus() == 1)
++              prepare_for_smp();
++#endif
++
+       local_irq_enable();
+       per_cpu(cpu_state, cpu) = CPU_UP_PREPARE;
+       /* Unleash the CPU! */
+diff -pruN ../pristine-linux-2.6.16/arch/i386/kernel/vmlinux.lds.S 
./arch/i386/kernel/vmlinux.lds.S
+--- ../pristine-linux-2.6.16/arch/i386/kernel/vmlinux.lds.S    2006-03-20 
05:53:29.000000000 +0000
++++ ./arch/i386/kernel/vmlinux.lds.S   2006-03-20 19:38:27.000000000 +0000
+@@ -34,6 +34,13 @@ SECTIONS
+   __ex_table : AT(ADDR(__ex_table) - LOAD_OFFSET) { *(__ex_table) }
+   __stop___ex_table = .;
+ 
++  . = ALIGN(16);
++  __start_smp_alternatives_table = .;
++  __smp_alternatives : { *(__smp_alternatives) }
++  __stop_smp_alternatives_table = .;
++
++  __smp_replacements : { *(__smp_replacements) }
++
+   RODATA
+ 
+   /* writeable */
+diff -pruN ../pristine-linux-2.6.16/include/asm-i386/atomic.h 
./include/asm-i386/atomic.h
+--- ../pristine-linux-2.6.16/include/asm-i386/atomic.h 2006-03-20 
05:53:29.000000000 +0000
++++ ./include/asm-i386/atomic.h        2006-03-20 19:38:27.000000000 +0000
+@@ -4,18 +4,13 @@
+ #include <linux/config.h>
+ #include <linux/compiler.h>
+ #include <asm/processor.h>
++#include <asm/smp_alt.h>
+ 
+ /*
+  * Atomic operations that C can't guarantee us.  Useful for
+  * resource counting etc..
+  */
+ 
+-#ifdef CONFIG_SMP
+-#define LOCK "lock ; "
+-#else
+-#define LOCK ""
+-#endif
+-
+ /*
+  * Make sure gcc doesn't try to be clever and move things around
+  * on us. We need to use _exactly_ the address the user gave us,
+diff -pruN ../pristine-linux-2.6.16/include/asm-i386/bitops.h 
./include/asm-i386/bitops.h
+--- ../pristine-linux-2.6.16/include/asm-i386/bitops.h 2006-03-20 
05:53:29.000000000 +0000
++++ ./include/asm-i386/bitops.h        2006-03-20 19:38:27.000000000 +0000
+@@ -7,6 +7,7 @@
+ 
+ #include <linux/config.h>
+ #include <linux/compiler.h>
++#include <asm/smp_alt.h>
+ 
+ /*
+  * These have to be done with inline assembly: that way the bit-setting
+@@ -16,12 +17,6 @@
+  * bit 0 is the LSB of addr; bit 32 is the LSB of (addr+1).
+  */
+ 
+-#ifdef CONFIG_SMP
+-#define LOCK_PREFIX "lock ; "
+-#else
+-#define LOCK_PREFIX ""
+-#endif
+-
+ #define ADDR (*(volatile long *) addr)
+ 
+ /**
+@@ -41,7 +36,7 @@
+  */
+ static inline void set_bit(int nr, volatile unsigned long * addr)
+ {
+-      __asm__ __volatile__( LOCK_PREFIX
++      __asm__ __volatile__( LOCK
+               "btsl %1,%0"
+               :"+m" (ADDR)
+               :"Ir" (nr));
+@@ -76,7 +71,7 @@ static inline void __set_bit(int nr, vol
+  */
+ static inline void clear_bit(int nr, volatile unsigned long * addr)
+ {
+-      __asm__ __volatile__( LOCK_PREFIX
++      __asm__ __volatile__( LOCK
+               "btrl %1,%0"
+               :"+m" (ADDR)
+               :"Ir" (nr));
+@@ -121,7 +116,7 @@ static inline void __change_bit(int nr, 
+  */
+ static inline void change_bit(int nr, volatile unsigned long * addr)
+ {
+-      __asm__ __volatile__( LOCK_PREFIX
++      __asm__ __volatile__( LOCK
+               "btcl %1,%0"
+               :"+m" (ADDR)
+               :"Ir" (nr));
+@@ -140,7 +135,7 @@ static inline int test_and_set_bit(int n
+ {
+       int oldbit;
+ 
+-      __asm__ __volatile__( LOCK_PREFIX
++      __asm__ __volatile__( LOCK
+               "btsl %2,%1\n\tsbbl %0,%0"
+               :"=r" (oldbit),"+m" (ADDR)
+               :"Ir" (nr) : "memory");
+@@ -180,7 +175,7 @@ static inline int test_and_clear_bit(int
+ {
+       int oldbit;
+ 
+-      __asm__ __volatile__( LOCK_PREFIX
++      __asm__ __volatile__( LOCK
+               "btrl %2,%1\n\tsbbl %0,%0"
+               :"=r" (oldbit),"+m" (ADDR)
+               :"Ir" (nr) : "memory");
+@@ -231,7 +226,7 @@ static inline int test_and_change_bit(in
+ {
+       int oldbit;
+ 
+-      __asm__ __volatile__( LOCK_PREFIX
++      __asm__ __volatile__( LOCK
+               "btcl %2,%1\n\tsbbl %0,%0"
+               :"=r" (oldbit),"+m" (ADDR)
+               :"Ir" (nr) : "memory");
+diff -pruN ../pristine-linux-2.6.16/include/asm-i386/futex.h 
./include/asm-i386/futex.h
+--- ../pristine-linux-2.6.16/include/asm-i386/futex.h  2006-03-20 
05:53:29.000000000 +0000
++++ ./include/asm-i386/futex.h 2006-03-20 19:38:27.000000000 +0000
+@@ -28,7 +28,7 @@
+ "1:   movl    %2, %0\n\
+       movl    %0, %3\n"                                       \
+       insn "\n"                                               \
+-"2:   " LOCK_PREFIX "cmpxchgl %3, %2\n\
++"2:   " LOCK "cmpxchgl %3, %2\n\
+       jnz     1b\n\
+ 3:    .section .fixup,\"ax\"\n\
+ 4:    mov     %5, %1\n\
+@@ -68,7 +68,7 @@ futex_atomic_op_inuser (int encoded_op, 
+ #endif
+               switch (op) {
+               case FUTEX_OP_ADD:
+-                      __futex_atomic_op1(LOCK_PREFIX "xaddl %0, %2", ret,
++                      __futex_atomic_op1(LOCK "xaddl %0, %2", ret,
+                                          oldval, uaddr, oparg);
+                       break;
+               case FUTEX_OP_OR:
+diff -pruN ../pristine-linux-2.6.16/include/asm-i386/rwsem.h 
./include/asm-i386/rwsem.h
+--- ../pristine-linux-2.6.16/include/asm-i386/rwsem.h  2006-03-20 
05:53:29.000000000 +0000
++++ ./include/asm-i386/rwsem.h 2006-03-20 19:38:27.000000000 +0000
+@@ -40,6 +40,7 @@
+ 
+ #include <linux/list.h>
+ #include <linux/spinlock.h>
++#include <asm/smp_alt.h>
+ 
+ struct rwsem_waiter;
+ 
+@@ -99,7 +100,7 @@ static inline void __down_read(struct rw
+ {
+       __asm__ __volatile__(
+               "# beginning down_read\n\t"
+-LOCK_PREFIX   "  incl      (%%eax)\n\t" /* adds 0x00000001, returns the old 
value */
++LOCK          "  incl      (%%eax)\n\t" /* adds 0x00000001, returns the old 
value */
+               "  js        2f\n\t" /* jump if we weren't granted the lock */
+               "1:\n\t"
+               LOCK_SECTION_START("")
+@@ -130,7 +131,7 @@ static inline int __down_read_trylock(st
+               "  movl      %1,%2\n\t"
+               "  addl      %3,%2\n\t"
+               "  jle       2f\n\t"
+-LOCK_PREFIX   "  cmpxchgl  %2,%0\n\t"
++LOCK          "  cmpxchgl  %2,%0\n\t"
+               "  jnz       1b\n\t"
+               "2:\n\t"
+               "# ending __down_read_trylock\n\t"
+@@ -150,7 +151,7 @@ static inline void __down_write(struct r
+       tmp = RWSEM_ACTIVE_WRITE_BIAS;
+       __asm__ __volatile__(
+               "# beginning down_write\n\t"
+-LOCK_PREFIX   "  xadd      %%edx,(%%eax)\n\t" /* subtract 0x0000ffff, returns 
the old value */
++LOCK          "  xadd      %%edx,(%%eax)\n\t" /* subtract 0x0000ffff, returns 
the old value */
+               "  testl     %%edx,%%edx\n\t" /* was the count 0 before? */
+               "  jnz       2f\n\t" /* jump if we weren't granted the lock */
+               "1:\n\t"
+@@ -188,7 +189,7 @@ static inline void __up_read(struct rw_s
+       __s32 tmp = -RWSEM_ACTIVE_READ_BIAS;
+       __asm__ __volatile__(
+               "# beginning __up_read\n\t"
+-LOCK_PREFIX   "  xadd      %%edx,(%%eax)\n\t" /* subtracts 1, returns the old 
value */
++LOCK          "  xadd      %%edx,(%%eax)\n\t" /* subtracts 1, returns the old 
value */
+               "  js        2f\n\t" /* jump if the lock is being waited upon */
+               "1:\n\t"
+               LOCK_SECTION_START("")
+@@ -214,7 +215,7 @@ static inline void __up_write(struct rw_
+       __asm__ __volatile__(
+               "# beginning __up_write\n\t"
+               "  movl      %2,%%edx\n\t"
+-LOCK_PREFIX   "  xaddl     %%edx,(%%eax)\n\t" /* tries to transition 
0xffff0001 -> 0x00000000 */
++LOCK          "  xaddl     %%edx,(%%eax)\n\t" /* tries to transition 
0xffff0001 -> 0x00000000 */
+               "  jnz       2f\n\t" /* jump if the lock is being waited upon */
+               "1:\n\t"
+               LOCK_SECTION_START("")
+@@ -239,7 +240,7 @@ static inline void __downgrade_write(str
+ {
+       __asm__ __volatile__(
+               "# beginning __downgrade_write\n\t"
+-LOCK_PREFIX   "  addl      %2,(%%eax)\n\t" /* transitions 0xZZZZ0001 -> 
0xYYYY0001 */
++LOCK          "  addl      %2,(%%eax)\n\t" /* transitions 0xZZZZ0001 -> 
0xYYYY0001 */
+               "  js        2f\n\t" /* jump if the lock is being waited upon */
+               "1:\n\t"
+               LOCK_SECTION_START("")
+@@ -263,7 +264,7 @@ LOCK_PREFIX        "  addl      %2,(%%eax)\n\t"
+ static inline void rwsem_atomic_add(int delta, struct rw_semaphore *sem)
+ {
+       __asm__ __volatile__(
+-LOCK_PREFIX   "addl %1,%0"
++LOCK            "addl %1,%0"
+               : "=m"(sem->count)
+               : "ir"(delta), "m"(sem->count));
+ }
+@@ -276,7 +277,7 @@ static inline int rwsem_atomic_update(in
+       int tmp = delta;
+ 
+       __asm__ __volatile__(
+-LOCK_PREFIX   "xadd %0,(%2)"
++LOCK                    "xadd %0,(%2)"
+               : "+r"(tmp), "=m"(sem->count)
+               : "r"(sem), "m"(sem->count)
+               : "memory");
+diff -pruN ../pristine-linux-2.6.16/include/asm-i386/smp_alt.h 
./include/asm-i386/smp_alt.h
+--- ../pristine-linux-2.6.16/include/asm-i386/smp_alt.h        1970-01-01 
01:00:00.000000000 +0100
++++ ./include/asm-i386/smp_alt.h       2006-03-20 19:38:27.000000000 +0000
+@@ -0,0 +1,32 @@
++#ifndef __ASM_SMP_ALT_H__
++#define __ASM_SMP_ALT_H__
++
++#include <linux/config.h>
++
++#ifdef CONFIG_SMP
++#if defined(CONFIG_SMP_ALTERNATIVES) && !defined(MODULE)
++#define LOCK \
++        "6677: nop\n" \
++      ".section __smp_alternatives,\"a\"\n" \
++      ".long 6677b\n" \
++      ".long 6678f\n" \
++      ".previous\n" \
++      ".section __smp_replacements,\"a\"\n" \
++      "6678: .byte 1\n" \
++      ".byte 1\n" \
++      ".byte 0\n" \
++        ".byte 1\n" \
++      ".byte -1\n" \
++      "lock\n" \
++      "nop\n" \
++      ".previous\n"
++void prepare_for_smp(void);
++void unprepare_for_smp(void);
++#else
++#define LOCK "lock ; "
++#endif
++#else
++#define LOCK ""
++#endif
++
++#endif /* __ASM_SMP_ALT_H__ */
+diff -pruN ../pristine-linux-2.6.16/include/asm-i386/spinlock.h 
./include/asm-i386/spinlock.h
+--- ../pristine-linux-2.6.16/include/asm-i386/spinlock.h       2006-03-20 
05:53:29.000000000 +0000
++++ ./include/asm-i386/spinlock.h      2006-03-20 19:38:27.000000000 +0000
+@@ -6,6 +6,7 @@
+ #include <asm/page.h>
+ #include <linux/config.h>
+ #include <linux/compiler.h>
++#include <asm/smp_alt.h>
+ 
+ /*
+  * Your basic SMP spinlocks, allowing only a single CPU anywhere
+@@ -23,7 +24,8 @@
+ 
+ #define __raw_spin_lock_string \
+       "\n1:\t" \
+-      "lock ; decb %0\n\t" \
++      LOCK \
++      "decb %0\n\t" \
+       "jns 3f\n" \
+       "2:\t" \
+       "rep;nop\n\t" \
+@@ -34,7 +36,8 @@
+ 
+ #define __raw_spin_lock_string_flags \
+       "\n1:\t" \
+-      "lock ; decb %0\n\t" \
++      LOCK \
++      "decb %0\n\t" \
+       "jns 4f\n\t" \
+       "2:\t" \
+       "testl $0x200, %1\n\t" \
+@@ -65,10 +68,34 @@ static inline void __raw_spin_lock_flags
+ static inline int __raw_spin_trylock(raw_spinlock_t *lock)
+ {
+       char oldval;
++#ifdef CONFIG_SMP_ALTERNATIVES
+       __asm__ __volatile__(
+-              "xchgb %b0,%1"
++              "1:movb %1,%b0\n"
++              "movb $0,%1\n"
++              "2:"
++              ".section __smp_alternatives,\"a\"\n"
++              ".long 1b\n"
++              ".long 3f\n"
++              ".previous\n"
++              ".section __smp_replacements,\"a\"\n"
++              "3: .byte 2b - 1b\n"
++              ".byte 5f-4f\n"
++              ".byte 0\n"
++              ".byte 6f-5f\n"
++              ".byte -1\n"
++              "4: xchgb %b0,%1\n"
++              "5: movb %1,%b0\n"
++              "movb $0,%1\n"
++              "6:\n"
++              ".previous\n"
+               :"=q" (oldval), "=m" (lock->slock)
+               :"0" (0) : "memory");
++#else
++      __asm__ __volatile__(
++              "xchgb %b0,%1\n"
++              :"=q" (oldval), "=m" (lock->slock)
++              :"0" (0) : "memory");
++#endif
+       return oldval > 0;
+ }
+ 
+@@ -178,12 +205,12 @@ static inline int __raw_write_trylock(ra
+ 
+ static inline void __raw_read_unlock(raw_rwlock_t *rw)
+ {
+-      asm volatile("lock ; incl %0" :"=m" (rw->lock) : : "memory");
++      asm volatile(LOCK "incl %0" :"=m" (rw->lock) : : "memory");
+ }
+ 
+ static inline void __raw_write_unlock(raw_rwlock_t *rw)
+ {
+-      asm volatile("lock ; addl $" RW_LOCK_BIAS_STR ", %0"
++      asm volatile(LOCK "addl $" RW_LOCK_BIAS_STR ", %0"
+                                : "=m" (rw->lock) : : "memory");
+ }
+ 
+diff -pruN ../pristine-linux-2.6.16/include/asm-i386/system.h 
./include/asm-i386/system.h
+--- ../pristine-linux-2.6.16/include/asm-i386/system.h 2006-03-20 
05:53:29.000000000 +0000
++++ ./include/asm-i386/system.h        2006-03-20 19:38:27.000000000 +0000
+@@ -5,7 +5,7 @@
+ #include <linux/kernel.h>
+ #include <asm/segment.h>
+ #include <asm/cpufeature.h>
+-#include <linux/bitops.h> /* for LOCK_PREFIX */
++#include <asm/smp_alt.h>
+ 
+ #ifdef __KERNEL__
+ 
+@@ -271,19 +271,19 @@ static inline unsigned long __cmpxchg(vo
+       unsigned long prev;
+       switch (size) {
+       case 1:
+-              __asm__ __volatile__(LOCK_PREFIX "cmpxchgb %b1,%2"
++              __asm__ __volatile__(LOCK "cmpxchgb %b1,%2"
+                                    : "=a"(prev)
+                                    : "q"(new), "m"(*__xg(ptr)), "0"(old)
+                                    : "memory");
+               return prev;
+       case 2:
+-              __asm__ __volatile__(LOCK_PREFIX "cmpxchgw %w1,%2"
++              __asm__ __volatile__(LOCK "cmpxchgw %w1,%2"
+                                    : "=a"(prev)
+                                    : "r"(new), "m"(*__xg(ptr)), "0"(old)
+                                    : "memory");
+               return prev;
+       case 4:
+-              __asm__ __volatile__(LOCK_PREFIX "cmpxchgl %1,%2"
++              __asm__ __volatile__(LOCK "cmpxchgl %1,%2"
+                                    : "=a"(prev)
+                                    : "r"(new), "m"(*__xg(ptr)), "0"(old)
+                                    : "memory");
+@@ -336,7 +336,7 @@ static inline unsigned long long __cmpxc
+                                     unsigned long long new)
+ {
+       unsigned long long prev;
+-      __asm__ __volatile__(LOCK_PREFIX "cmpxchg8b %3"
++      __asm__ __volatile__(LOCK "cmpxchg8b %3"
+                            : "=A"(prev)
+                            : "b"((unsigned long)new),
+                              "c"((unsigned long)(new >> 32)),
+@@ -503,11 +503,55 @@ struct alt_instr { 
+ #endif
+ 
+ #ifdef CONFIG_SMP
++#if defined(CONFIG_SMP_ALTERNATIVES) && !defined(MODULE)
++#define smp_alt_mb(instr)                                           \
++__asm__ __volatile__("6667:\nnop\nnop\nnop\nnop\nnop\nnop\n6668:\n" \
++                   ".section __smp_alternatives,\"a\"\n"          \
++                   ".long 6667b\n"                                \
++                     ".long 6673f\n"                                \
++                   ".previous\n"                                  \
++                   ".section __smp_replacements,\"a\"\n"          \
++                   "6673:.byte 6668b-6667b\n"                     \
++                   ".byte 6670f-6669f\n"                          \
++                   ".byte 6671f-6670f\n"                          \
++                     ".byte 0\n"                                    \
++                   ".byte %c0\n"                                  \
++                   "6669:lock;addl $0,0(%%esp)\n"                 \
++                   "6670:" instr "\n"                             \
++                   "6671:\n"                                      \
++                   ".previous\n"                                  \
++                   :                                              \
++                   : "i" (X86_FEATURE_XMM2)                       \
++                   : "memory")
++#define smp_rmb() smp_alt_mb("lfence")
++#define smp_mb()  smp_alt_mb("mfence")
++#define set_mb(var, value) do {                                     \
++unsigned long __set_mb_temp;                                        \
++__asm__ __volatile__("6667:movl %1, %0\n6668:\n"                    \
++                   ".section __smp_alternatives,\"a\"\n"          \
++                   ".long 6667b\n"                                \
++                   ".long 6673f\n"                                \
++                   ".previous\n"                                  \
++                   ".section __smp_replacements,\"a\"\n"          \
++                   "6673: .byte 6668b-6667b\n"                    \
++                   ".byte 6670f-6669f\n"                          \
++                   ".byte 0\n"                                    \
++                   ".byte 6671f-6670f\n"                          \
++                   ".byte -1\n"                                   \
++                   "6669: xchg %1, %0\n"                          \
++                   "6670:movl %1, %0\n"                           \
++                   "6671:\n"                                      \
++                   ".previous\n"                                  \
++                   : "=m" (var), "=r" (__set_mb_temp)             \
++                   : "1" (value)                                  \
++                   : "memory"); } while (0)
++#else
+ #define smp_mb()      mb()
+ #define smp_rmb()     rmb()
++#define set_mb(var, value) do { (void) xchg(&var, value); } while (0)
++#endif
+ #define smp_wmb()     wmb()
+ #define smp_read_barrier_depends()    read_barrier_depends()
+-#define set_mb(var, value) do { (void) xchg(&var, value); } while (0)
+ #else
+ #define smp_mb()      barrier()
+ #define smp_rmb()     barrier()
diff -r f163677f8767 -r a9f5cf43451f 
tools/xm-test/tests/vtpm/03_vtpm-susp_res.py
--- /dev/null   Tue Mar 21 16:55:44 2006
+++ b/tools/xm-test/tests/vtpm/03_vtpm-susp_res.py      Tue Mar 21 18:19:11 2006
@@ -0,0 +1,105 @@
+#!/usr/bin/python
+
+# Copyright (C) International Business Machines Corp., 2006
+# Author: Stefan Berger <stefanb@xxxxxxxxxx>
+
+# Positive Test: create domain with virtual TPM attached at build time,
+#                check list of pcrs; suspend and resume the domain and
+#                check list of pcrs again
+
+from XmTestLib import *
+from vtpm_utils import *
+import commands
+import os
+import os.path
+
+config = {"vtpm":"instance=1,backend=0"}
+domain = XmTestDomain(extraConfig=config)
+
+try:
+    domain.start()
+except DomainError, e:
+    if verbose:
+        print e.extra
+    vtpm_cleanup(domain.getName())
+    FAIL("Unable to create domain")
+
+domName = domain.getName()
+
+try:
+    console = XmConsole(domain.getName())
+except ConsoleError, e:
+    vtpm_cleanup(domName)
+    FAIL(str(e))
+
+try:
+    console.sendInput("input")
+except ConsoleError, e:
+    saveLog(console.getHistory())
+    vtpm_cleanup(domName)
+    FAIL(str(e))
+
+try:
+    run = console.runCmd("cat /sys/devices/platform/tpm_vtpm/pcrs")
+except ConsoleError, e:
+    saveLog(console.getHistory())
+    vtpm_cleanup(domName)
+    FAIL(str(e))
+
+if re.search("No such file",run["output"]):
+    FAIL("TPM frontend support not compiled into (domU?) kernel")
+
+console.closeConsole()
+
+try:
+    status, ouptut = traceCommand("xm save %s %s.save" %
+                                  (domName, domName),
+                                  timeout=30)
+except TimeoutError, e:
+    saveLog(console.getHistory())
+    vtpm_cleanup(domName)
+    FAIL(str(e))
+
+if status != 0:
+    saveLog(console.getHistory())
+    vtpm_cleanup(domName)
+    FAIL("xm save did not succeed")
+
+try:
+    status, ouptut = traceCommand("xm restore %s.save" %
+                                  (domName),
+                                  timeout=30)
+except TimeoutError, e:
+    os.remove("%s.save" % domName)
+    saveLog(console.getHistory())
+    vtpm_cleanup(domName)
+    FAIL(str(e))
+
+os.remove("%s.save" % domName)
+
+if status != 0:
+    saveLog(console.getHistory())
+    vtpm_cleanup(domName)
+    FAIL("xm restore did not succeed")
+
+try:
+    console = XmConsole(domain.getName())
+except ConsoleError, e:
+    vtpm_cleanup(domName)
+    FAIL(str(e))
+
+try:
+    run = console.runCmd("cat /sys/devices/platform/tpm_vtpm/pcrs")
+except ConsoleError, e:
+    saveLog(console.getHistory())
+    vtpm_cleanup(domName)
+    FAIL(str(e))
+
+console.closeConsole()
+
+domain.stop()
+
+vtpm_cleanup(domName)
+
+if not re.search("PCR-00:",run["output"]):
+       FAIL("Virtual TPM is not working correctly on /dev/vtpm on backend 
side")
diff -r f163677f8767 -r a9f5cf43451f tools/xm-test/tests/vtpm/vtpm_utils.py
--- /dev/null   Tue Mar 21 16:55:44 2006
+++ b/tools/xm-test/tests/vtpm/vtpm_utils.py    Tue Mar 21 18:19:11 2006
@@ -0,0 +1,19 @@
+#!/usr/bin/python
+
+# Copyright (C) International Business Machines Corp., 2006
+# Author: Stefan Berger <stefanb@xxxxxxxxxx>
+
+from XmTestLib import *
+
+if ENABLE_HVM_SUPPORT:
+    SKIP("vtpm tests not supported for HVM domains")
+
+if not os.path.isfile("/dev/tpm0"):
+    SKIP("This machine has no hardware TPM; cannot run this test")
+
+status, output = traceCommand("ps aux | grep vtpm_manager | grep -v grep")
+if output == "":
+    FAIL("virtual TPM manager must be started to run this test")
+
+def vtpm_cleanup(domName):
+       traceCommand("/etc/xen/scripts/vtpm-delete %s" % domName)
diff -r f163677f8767 -r a9f5cf43451f xen/Post.mk
--- /dev/null   Tue Mar 21 16:55:44 2006
+++ b/xen/Post.mk       Tue Mar 21 18:19:11 2006
@@ -0,0 +1,27 @@
+# Ensure each subdirectory has exactly one trailing slash.
+subdir-n := $(patsubst %,%/,$(patsubst %/,%,$(subdir-n)))
+subdir-y := $(patsubst %,%/,$(patsubst %/,%,$(subdir-y)))
+
+# Add explicitly declared subdirectories to the object list.
+obj-y += $(patsubst %,%/built_in.o,$(subdir-y))
+
+# Add implicitly declared subdirectories (in the object list) to the
+# subdirectory list, and rewrite the object-list entry.
+subdir-y += $(filter %/,$(obj-y))
+obj-y    := $(patsubst %/,%/built-in.o,$(obj-y))
+
+subdir-all := $(subdir-y) $(subdir-n)
+
+built_in.o: $(obj-y)
+       $(LD) $(LDFLAGS) -r -o $@ $^
+
+.PHONY: FORCE
+FORCE:
+
+%/built_in.o: FORCE
+       $(MAKE) -C $*
+
+clean:: $(addprefix _clean_, $(subdir-all)) FORCE
+       rm -f *.o *~ core
+_clean_%/: FORCE
+       $(MAKE) -C $* clean
diff -r f163677f8767 -r a9f5cf43451f xen/arch/ia64/linux-xen/Makefile
--- /dev/null   Tue Mar 21 16:55:44 2006
+++ b/xen/arch/ia64/linux-xen/Makefile  Tue Mar 21 18:19:11 2006
@@ -0,0 +1,19 @@
+include $(BASEDIR)/Rules.mk
+
+obj-y += efi.o
+obj-y += entry.o
+obj-y += irq_ia64.o
+obj-y += mm_contig.o
+obj-y += pal.o
+obj-y += process-linux-xen.o
+obj-y += sal.o
+obj-y += setup.o
+obj-y += smpboot.o
+obj-y += smp.o
+obj-y += sort.o
+obj-y += time.o
+obj-y += tlb.o
+obj-y += unaligned.o
+obj-y += unwind.o
+
+include $(BASEDIR)/Post.mk
diff -r f163677f8767 -r a9f5cf43451f xen/arch/ia64/linux/Makefile
--- /dev/null   Tue Mar 21 16:55:44 2006
+++ b/xen/arch/ia64/linux/Makefile      Tue Mar 21 18:19:11 2006
@@ -0,0 +1,56 @@
+include $(BASEDIR)/Rules.mk
+
+
+obj-y += bitop.o
+obj-y += clear_page.o
+obj-y += cmdline.o
+obj-y += copy_page_mck.o
+obj-y += efi_stub.o
+obj-y += extable.o
+obj-y += flush.o
+obj-y += hpsim.o
+obj-y += ia64_ksyms.o
+obj-y += irq_lsapic.o
+obj-y += linuxextable.o
+obj-y += machvec.o
+obj-y += memcpy_mck.o
+obj-y += memset.o
+obj-y += strlen.o
+
+obj-y += __divsi3.o
+obj-y += __udivsi3.o
+obj-y += __modsi3.o
+obj-y += __umodsi3.o
+obj-y += __divdi3.o
+obj-y += __udivdi3.o
+obj-y += __moddi3.o
+obj-y += __umoddi3.o
+
+include $(BASEDIR)/Post.mk
+
+## variants of divide/modulo
+## see files in xen/arch/ia64/linux/lib (linux/arch/ia64/lib)
+__divdi3.o: idiv64.S
+       $(CC) $(AFLAGS) $(AFLAGS_KERNEL) -c -o $@ $<
+
+__udivdi3.o: idiv64.S
+       $(CC) $(AFLAGS) $(AFLAGS_KERNEL) -c -DUNSIGNED -c -o $@ $<
+
+__moddi3.o: idiv64.S
+       $(CC) $(AFLAGS) $(AFLAGS_KERNEL) -c -DMODULO -c -o $@ $<
+
+__umoddi3.o: idiv64.S
+       $(CC) $(AFLAGS) $(AFLAGS_KERNEL) -c -DMODULO -DUNSIGNED -c -o $@ $<
+
+__divsi3.o: idiv32.S
+       $(CC) $(AFLAGS) $(AFLAGS_KERNEL) -c -o $@ $<
+
+__udivsi3.o: idiv32.S
+       $(CC) $(AFLAGS) $(AFLAGS_KERNEL) -c -DUNSIGNED -c -o $@ $<
+
+__modsi3.o: idiv32.S
+       $(CC) $(AFLAGS) $(AFLAGS_KERNEL) -c -DMODULO -c -o $@ $<
+
+__umodsi3.o: idiv32.S
+       $(CC) $(AFLAGS) $(AFLAGS_KERNEL) -c -DMODULO -DUNSIGNED -c -o $@ $<
+
diff -r f163677f8767 -r a9f5cf43451f xen/arch/ia64/vmx/Makefile
--- /dev/null   Tue Mar 21 16:55:44 2006
+++ b/xen/arch/ia64/vmx/Makefile        Tue Mar 21 18:19:11 2006
@@ -0,0 +1,24 @@
+include $(BASEDIR)/Rules.mk
+
+obj-y += hvm_vioapic.o
+obj-y += mm.o
+obj-y += mmio.o
+obj-y += pal_emul.o
+obj-y += vlsapic.o
+obj-y += vmmu.o
+obj-y += vmx_entry.o
+obj-y += vmx_hypercall.o
+obj-y += vmx_init.o
+obj-y += vmx_interrupt.o
+obj-y += vmx_irq_ia64.o
+obj-y += vmx_ivt.o
+obj-y += vmx_phy_mode.o
+obj-y += vmx_process.o
+obj-y += vmx_support.o
+obj-y += vmx_utility.o
+obj-y += vmx_vcpu.o
+obj-y += vmx_virt.o
+obj-y += vmx_vsa.o
+obj-y += vtlb.o
+
+include $(BASEDIR)/Post.mk
diff -r f163677f8767 -r a9f5cf43451f xen/arch/ia64/xen/Makefile
--- /dev/null   Tue Mar 21 16:55:44 2006
+++ b/xen/arch/ia64/xen/Makefile        Tue Mar 21 18:19:11 2006
@@ -0,0 +1,30 @@
+include $(BASEDIR)/Rules.mk
+
+obj-y += acpi.o
+obj-y += dom0_ops.o
+obj-y += domain.o
+obj-y += dom_fw.o
+obj-y += hpsimserial.o
+obj-y += hypercall.o
+obj-y += hyperprivop.o
+obj-y += idle0_task.o
+obj-y += irq.o
+obj-y += ivt.o
+obj-y += mm_init.o
+obj-y += pcdp.o
+obj-y += privop.o
+obj-y += process.o
+obj-y += regionreg.o
+obj-y += sn_console.o
+obj-y += vcpu.o
+obj-y += vhpt.o
+obj-y += xenasm.o
+obj-y += xenirq.o
+obj-y += xenmem.o
+obj-y += xenmisc.o
+obj-y += xensetup.o
+obj-y += xentime.o
+
+obj-$(crash_debug) += gdbstub.o
+
+include $(BASEDIR)/Post.mk
diff -r f163677f8767 -r a9f5cf43451f xen/arch/x86/acpi/Makefile
--- /dev/null   Tue Mar 21 16:55:44 2006
+++ b/xen/arch/x86/acpi/Makefile        Tue Mar 21 18:19:11 2006
@@ -0,0 +1,5 @@
+include $(BASEDIR)/Rules.mk
+
+obj-y += boot.o
+
+include $(BASEDIR)/Post.mk
diff -r f163677f8767 -r a9f5cf43451f xen/arch/x86/cpu/Makefile
--- /dev/null   Tue Mar 21 16:55:44 2006
+++ b/xen/arch/x86/cpu/Makefile Tue Mar 21 18:19:11 2006
@@ -0,0 +1,16 @@
+include $(BASEDIR)/Rules.mk
+
+subdir-y += mcheck
+subdir-y += mtrr
+
+obj-y += amd.o
+obj-y += common.o
+obj-y += intel.o
+obj-y += intel_cacheinfo.o
+
+obj-$(x86_32) += centaur.o
+obj-$(x86_32) += cyrix.o
+obj-$(x86_32) += rise.o
+obj-$(x86_32) += transmeta.o
+
+include $(BASEDIR)/Post.mk
diff -r f163677f8767 -r a9f5cf43451f xen/arch/x86/cpu/mcheck/Makefile
--- /dev/null   Tue Mar 21 16:55:44 2006
+++ b/xen/arch/x86/cpu/mcheck/Makefile  Tue Mar 21 18:19:11 2006
@@ -0,0 +1,11 @@
+include $(BASEDIR)/Rules.mk
+
+obj-y += k7.o
+obj-y += mce.o
+obj-y += non-fatal.o
+obj-y += p4.o
+obj-y += p5.o
+obj-y += p6.o
+obj-y += winchip.o
+
+include $(BASEDIR)/Post.mk
diff -r f163677f8767 -r a9f5cf43451f xen/arch/x86/cpu/mtrr/Makefile
--- /dev/null   Tue Mar 21 16:55:44 2006
+++ b/xen/arch/x86/cpu/mtrr/Makefile    Tue Mar 21 18:19:11 2006
@@ -0,0 +1,10 @@
+include $(BASEDIR)/Rules.mk
+
+obj-y += amd.o
+obj-y += centaur.o
+obj-y += cyrix.o
+obj-y += generic.o
+obj-y += main.o
+obj-y += state.o
+
+include $(BASEDIR)/Post.mk
diff -r f163677f8767 -r a9f5cf43451f xen/arch/x86/genapic/Makefile
--- /dev/null   Tue Mar 21 16:55:44 2006
+++ b/xen/arch/x86/genapic/Makefile     Tue Mar 21 18:19:11 2006
@@ -0,0 +1,10 @@
+include $(BASEDIR)/Rules.mk
+
+obj-y += bigsmp.o
+obj-y += default.o
+obj-y += es7000.o
+obj-y += es7000plat.o
+obj-y += probe.o
+obj-y += summit.o
+
+include $(BASEDIR)/Post.mk
diff -r f163677f8767 -r a9f5cf43451f xen/arch/x86/hvm/Makefile
--- /dev/null   Tue Mar 21 16:55:44 2006
+++ b/xen/arch/x86/hvm/Makefile Tue Mar 21 18:19:11 2006
@@ -0,0 +1,14 @@
+include $(BASEDIR)/Rules.mk
+
+subdir-y += svm
+subdir-y += vmx
+
+obj-y += hvm.o
+obj-y += i8259.o
+obj-y += intercept.o
+obj-y += io.o
+obj-y += platform.o
+obj-y += vioapic.o
+obj-y += vlapic.o
+
+include $(BASEDIR)/Post.mk
diff -r f163677f8767 -r a9f5cf43451f xen/arch/x86/hvm/svm/Makefile
--- /dev/null   Tue Mar 21 16:55:44 2006
+++ b/xen/arch/x86/hvm/svm/Makefile     Tue Mar 21 18:19:11 2006
@@ -0,0 +1,12 @@
+include $(BASEDIR)/Rules.mk
+
+subdir-$(x86_32) += x86_32
+subdir-$(x86_64) += x86_64
+
+obj-y += emulate.o
+obj-y += instrlen.o
+obj-y += intr.o
+obj-y += svm.o
+obj-y += vmcb.o
+
+include $(BASEDIR)/Post.mk
diff -r f163677f8767 -r a9f5cf43451f xen/arch/x86/hvm/svm/x86_32/Makefile
--- /dev/null   Tue Mar 21 16:55:44 2006
+++ b/xen/arch/x86/hvm/svm/x86_32/Makefile      Tue Mar 21 18:19:11 2006
@@ -0,0 +1,5 @@
+include $(BASEDIR)/Rules.mk
+
+obj-y += exits.o
+
+include $(BASEDIR)/Post.mk
diff -r f163677f8767 -r a9f5cf43451f xen/arch/x86/hvm/svm/x86_64/Makefile
--- /dev/null   Tue Mar 21 16:55:44 2006
+++ b/xen/arch/x86/hvm/svm/x86_64/Makefile      Tue Mar 21 18:19:11 2006
@@ -0,0 +1,5 @@
+include $(BASEDIR)/Rules.mk
+
+obj-y += exits.o
+
+include $(BASEDIR)/Post.mk
diff -r f163677f8767 -r a9f5cf43451f xen/arch/x86/hvm/vmx/Makefile
--- /dev/null   Tue Mar 21 16:55:44 2006
+++ b/xen/arch/x86/hvm/vmx/Makefile     Tue Mar 21 18:19:11 2006
@@ -0,0 +1,10 @@
+include $(BASEDIR)/Rules.mk
+
+subdir-$(x86_32) += x86_32
+subdir-$(x86_64) += x86_64
+
+obj-y += io.o
+obj-y += vmcs.o
+obj-y += vmx.o
+
+include $(BASEDIR)/Post.mk
diff -r f163677f8767 -r a9f5cf43451f xen/arch/x86/hvm/vmx/x86_32/Makefile
--- /dev/null   Tue Mar 21 16:55:44 2006
+++ b/xen/arch/x86/hvm/vmx/x86_32/Makefile      Tue Mar 21 18:19:11 2006
@@ -0,0 +1,5 @@
+include $(BASEDIR)/Rules.mk
+
+obj-y += exits.o
+
+include $(BASEDIR)/Post.mk
diff -r f163677f8767 -r a9f5cf43451f xen/arch/x86/hvm/vmx/x86_64/Makefile
--- /dev/null   Tue Mar 21 16:55:44 2006
+++ b/xen/arch/x86/hvm/vmx/x86_64/Makefile      Tue Mar 21 18:19:11 2006
@@ -0,0 +1,5 @@
+include $(BASEDIR)/Rules.mk
+
+obj-y += exits.o
+
+include $(BASEDIR)/Post.mk
diff -r f163677f8767 -r a9f5cf43451f xen/arch/x86/x86_32/Makefile
--- /dev/null   Tue Mar 21 16:55:44 2006
+++ b/xen/arch/x86/x86_32/Makefile      Tue Mar 21 18:19:11 2006
@@ -0,0 +1,11 @@
+include $(BASEDIR)/Rules.mk
+
+obj-y += domain_page.o
+obj-y += entry.o
+obj-y += mm.o
+obj-y += seg_fixup.o
+obj-y += traps.o
+
+obj-$(supervisor_mode_kernel) += supervisor_mode_kernel.o
+
+include $(BASEDIR)/Post.mk
diff -r f163677f8767 -r a9f5cf43451f xen/arch/x86/x86_64/Makefile
--- /dev/null   Tue Mar 21 16:55:44 2006
+++ b/xen/arch/x86/x86_64/Makefile      Tue Mar 21 18:19:11 2006
@@ -0,0 +1,7 @@
+include $(BASEDIR)/Rules.mk
+
+obj-y += entry.o
+obj-y += mm.o
+obj-y += traps.o
+
+include $(BASEDIR)/Post.mk
diff -r f163677f8767 -r a9f5cf43451f 
patches/linux-2.6.16-rc5/i386-mach-io-check-nmi.patch
--- a/patches/linux-2.6.16-rc5/i386-mach-io-check-nmi.patch     Tue Mar 21 
16:55:44 2006
+++ /dev/null   Tue Mar 21 18:19:11 2006
@@ -1,45 +0,0 @@
-diff -pruN ../pristine-linux-2.6.16-rc5/arch/i386/kernel/traps.c 
./arch/i386/kernel/traps.c
---- ../pristine-linux-2.6.16-rc5/arch/i386/kernel/traps.c      2006-02-27 
15:46:58.000000000 +0000
-+++ ./arch/i386/kernel/traps.c 2006-02-27 15:55:23.000000000 +0000
-@@ -567,18 +567,11 @@ static void mem_parity_error(unsigned ch
- 
- static void io_check_error(unsigned char reason, struct pt_regs * regs)
- {
--      unsigned long i;
--
-       printk(KERN_EMERG "NMI: IOCK error (debug interrupt?)\n");
-       show_registers(regs);
- 
-       /* Re-enable the IOCK line, wait for a few seconds */
--      reason = (reason & 0xf) | 8;
--      outb(reason, 0x61);
--      i = 2000;
--      while (--i) udelay(1000);
--      reason &= ~8;
--      outb(reason, 0x61);
-+      clear_io_check_error(reason);
- }
- 
- static void unknown_nmi_error(unsigned char reason, struct pt_regs * regs)
-diff -pruN 
../pristine-linux-2.6.16-rc5/include/asm-i386/mach-default/mach_traps.h 
./include/asm-i386/mach-default/mach_traps.h
---- ../pristine-linux-2.6.16-rc5/include/asm-i386/mach-default/mach_traps.h    
2006-01-03 03:21:10.000000000 +0000
-+++ ./include/asm-i386/mach-default/mach_traps.h       2006-02-27 
15:55:23.000000000 +0000
-@@ -15,6 +15,18 @@ static inline void clear_mem_error(unsig
-       outb(reason, 0x61);
- }
- 
-+static inline void clear_io_check_error(unsigned char reason)
-+{
-+      unsigned long i;
-+
-+      reason = (reason & 0xf) | 8;
-+      outb(reason, 0x61);
-+      i = 2000;
-+      while (--i) udelay(1000);
-+      reason &= ~8;
-+      outb(reason, 0x61);
-+}
-+
- static inline unsigned char get_nmi_reason(void)
- {
-       return inb(0x61);
diff -r f163677f8767 -r a9f5cf43451f patches/linux-2.6.16-rc5/net-csum.patch
--- a/patches/linux-2.6.16-rc5/net-csum.patch   Tue Mar 21 16:55:44 2006
+++ /dev/null   Tue Mar 21 18:19:11 2006
@@ -1,41 +0,0 @@
-diff -pruN ../pristine-linux-2.6.16-rc5/net/ipv4/netfilter/ip_nat_proto_tcp.c 
./net/ipv4/netfilter/ip_nat_proto_tcp.c
---- ../pristine-linux-2.6.16-rc5/net/ipv4/netfilter/ip_nat_proto_tcp.c 
2006-02-27 15:47:38.000000000 +0000
-+++ ./net/ipv4/netfilter/ip_nat_proto_tcp.c    2006-02-27 15:55:25.000000000 
+0000
-@@ -129,10 +129,14 @@ tcp_manip_pkt(struct sk_buff **pskb,
-       if (hdrsize < sizeof(*hdr))
-               return 1;
- 
--      hdr->check = ip_nat_cheat_check(~oldip, newip,
-+      if ((*pskb)->proto_csum_blank) {
-+              hdr->check = ip_nat_cheat_check(oldip, ~newip, hdr->check);
-+      } else {
-+              hdr->check = ip_nat_cheat_check(~oldip, newip,
-                                       ip_nat_cheat_check(oldport ^ 0xFFFF,
-                                                          newport,
-                                                          hdr->check));
-+      }
-       return 1;
- }
- 
-diff -pruN ../pristine-linux-2.6.16-rc5/net/ipv4/netfilter/ip_nat_proto_udp.c 
./net/ipv4/netfilter/ip_nat_proto_udp.c
---- ../pristine-linux-2.6.16-rc5/net/ipv4/netfilter/ip_nat_proto_udp.c 
2006-02-27 15:47:38.000000000 +0000
-+++ ./net/ipv4/netfilter/ip_nat_proto_udp.c    2006-02-27 15:55:25.000000000 
+0000
-@@ -113,11 +113,16 @@ udp_manip_pkt(struct sk_buff **pskb,
-               newport = tuple->dst.u.udp.port;
-               portptr = &hdr->dest;
-       }
--      if (hdr->check) /* 0 is a special case meaning no checksum */
--              hdr->check = ip_nat_cheat_check(~oldip, newip,
-+      if (hdr->check) { /* 0 is a special case meaning no checksum */
-+              if ((*pskb)->proto_csum_blank) {
-+                      hdr->check = ip_nat_cheat_check(oldip, ~newip, 
hdr->check);
-+              } else {
-+                      hdr->check = ip_nat_cheat_check(~oldip, newip,
-                                       ip_nat_cheat_check(*portptr ^ 0xFFFF,
-                                                          newport,
-                                                          hdr->check));
-+              }
-+      }
-       *portptr = newport;
-       return 1;
- }
diff -r f163677f8767 -r a9f5cf43451f patches/linux-2.6.16-rc5/pmd-shared.patch
--- a/patches/linux-2.6.16-rc5/pmd-shared.patch Tue Mar 21 16:55:44 2006
+++ /dev/null   Tue Mar 21 18:19:11 2006
@@ -1,111 +0,0 @@
-diff -pruN ../pristine-linux-2.6.16-rc5/arch/i386/mm/pageattr.c 
./arch/i386/mm/pageattr.c
---- ../pristine-linux-2.6.16-rc5/arch/i386/mm/pageattr.c       2006-02-27 
15:46:58.000000000 +0000
-+++ ./arch/i386/mm/pageattr.c  2006-02-27 15:55:31.000000000 +0000
-@@ -78,7 +78,7 @@ static void set_pmd_pte(pte_t *kpte, uns
-       unsigned long flags;
- 
-       set_pte_atomic(kpte, pte);      /* change init_mm */
--      if (PTRS_PER_PMD > 1)
-+      if (HAVE_SHARED_KERNEL_PMD)
-               return;
- 
-       spin_lock_irqsave(&pgd_lock, flags);
-diff -pruN ../pristine-linux-2.6.16-rc5/arch/i386/mm/pgtable.c 
./arch/i386/mm/pgtable.c
---- ../pristine-linux-2.6.16-rc5/arch/i386/mm/pgtable.c        2006-01-03 
03:21:10.000000000 +0000
-+++ ./arch/i386/mm/pgtable.c   2006-02-27 15:55:31.000000000 +0000
-@@ -215,9 +215,10 @@ void pgd_ctor(void *pgd, kmem_cache_t *c
-               spin_lock_irqsave(&pgd_lock, flags);
-       }
- 
--      clone_pgd_range((pgd_t *)pgd + USER_PTRS_PER_PGD,
--                      swapper_pg_dir + USER_PTRS_PER_PGD,
--                      KERNEL_PGD_PTRS);
-+      if (PTRS_PER_PMD == 1 || HAVE_SHARED_KERNEL_PMD)
-+              clone_pgd_range((pgd_t *)pgd + USER_PTRS_PER_PGD,
-+                              swapper_pg_dir + USER_PTRS_PER_PGD,
-+                              KERNEL_PGD_PTRS);
-       if (PTRS_PER_PMD > 1)
-               return;
- 
-@@ -249,6 +250,30 @@ pgd_t *pgd_alloc(struct mm_struct *mm)
-                       goto out_oom;
-               set_pgd(&pgd[i], __pgd(1 + __pa(pmd)));
-       }
-+
-+      if (!HAVE_SHARED_KERNEL_PMD) {
-+              unsigned long flags;
-+
-+              for (i = USER_PTRS_PER_PGD; i < PTRS_PER_PGD; i++) {
-+                      pmd_t *pmd = kmem_cache_alloc(pmd_cache, GFP_KERNEL);
-+                      if (!pmd)
-+                              goto out_oom;
-+                      set_pgd(&pgd[USER_PTRS_PER_PGD], __pgd(1 + __pa(pmd)));
-+              }
-+
-+              spin_lock_irqsave(&pgd_lock, flags);
-+              for (i = USER_PTRS_PER_PGD; i < PTRS_PER_PGD; i++) {
-+                      unsigned long v = (unsigned long)i << PGDIR_SHIFT;
-+                      pgd_t *kpgd = pgd_offset_k(v);
-+                      pud_t *kpud = pud_offset(kpgd, v);
-+                      pmd_t *kpmd = pmd_offset(kpud, v);
-+                      pmd_t *pmd = (void *)__va(pgd_val(pgd[i])-1);
-+                      memcpy(pmd, kpmd, PAGE_SIZE);
-+              }
-+              pgd_list_add(pgd);
-+              spin_unlock_irqrestore(&pgd_lock, flags);
-+      }
-+
-       return pgd;
- 
- out_oom:
-@@ -263,9 +288,23 @@ void pgd_free(pgd_t *pgd)
-       int i;
- 
-       /* in the PAE case user pgd entries are overwritten before usage */
--      if (PTRS_PER_PMD > 1)
--              for (i = 0; i < USER_PTRS_PER_PGD; ++i)
--                      kmem_cache_free(pmd_cache, (void 
*)__va(pgd_val(pgd[i])-1));
-+      if (PTRS_PER_PMD > 1) {
-+              for (i = 0; i < USER_PTRS_PER_PGD; ++i) {
-+                      pmd_t *pmd = (void *)__va(pgd_val(pgd[i])-1);
-+                      kmem_cache_free(pmd_cache, pmd);
-+              }
-+              if (!HAVE_SHARED_KERNEL_PMD) {
-+                      unsigned long flags;
-+                      spin_lock_irqsave(&pgd_lock, flags);
-+                      pgd_list_del(pgd);
-+                      spin_unlock_irqrestore(&pgd_lock, flags);
-+                      for (i = USER_PTRS_PER_PGD; i < PTRS_PER_PGD; i++) {
-+                              pmd_t *pmd = (void *)__va(pgd_val(pgd[i])-1);
-+                              memset(pmd, 0, PTRS_PER_PMD*sizeof(pmd_t));
-+                              kmem_cache_free(pmd_cache, pmd);
-+                      }
-+              }
-+      }
-       /* in the non-PAE case, free_pgtables() clears user pgd entries */
-       kmem_cache_free(pgd_cache, pgd);
- }
-diff -pruN ../pristine-linux-2.6.16-rc5/include/asm-i386/pgtable-2level-defs.h 
./include/asm-i386/pgtable-2level-defs.h
---- ../pristine-linux-2.6.16-rc5/include/asm-i386/pgtable-2level-defs.h        
2006-01-03 03:21:10.000000000 +0000
-+++ ./include/asm-i386/pgtable-2level-defs.h   2006-02-27 15:55:31.000000000 
+0000
-@@ -1,6 +1,8 @@
- #ifndef _I386_PGTABLE_2LEVEL_DEFS_H
- #define _I386_PGTABLE_2LEVEL_DEFS_H
- 
-+#define HAVE_SHARED_KERNEL_PMD 0
-+
- /*
-  * traditional i386 two-level paging structure:
-  */
-diff -pruN ../pristine-linux-2.6.16-rc5/include/asm-i386/pgtable-3level-defs.h 
./include/asm-i386/pgtable-3level-defs.h
---- ../pristine-linux-2.6.16-rc5/include/asm-i386/pgtable-3level-defs.h        
2006-01-03 03:21:10.000000000 +0000
-+++ ./include/asm-i386/pgtable-3level-defs.h   2006-02-27 15:55:31.000000000 
+0000
-@@ -1,6 +1,8 @@
- #ifndef _I386_PGTABLE_3LEVEL_DEFS_H
- #define _I386_PGTABLE_3LEVEL_DEFS_H
- 
-+#define HAVE_SHARED_KERNEL_PMD 1
-+
- /*
-  * PGDIR_SHIFT determines what a top-level page table entry can map
-  */
diff -r f163677f8767 -r a9f5cf43451f patches/linux-2.6.16-rc5/smp-alts.patch
--- a/patches/linux-2.6.16-rc5/smp-alts.patch   Tue Mar 21 16:55:44 2006
+++ /dev/null   Tue Mar 21 18:19:11 2006
@@ -1,591 +0,0 @@
-diff -pruN ../pristine-linux-2.6.16-rc5/arch/i386/Kconfig ./arch/i386/Kconfig
---- ../pristine-linux-2.6.16-rc5/arch/i386/Kconfig     2006-02-27 
15:46:58.000000000 +0000
-+++ ./arch/i386/Kconfig        2006-02-27 15:55:34.000000000 +0000
-@@ -202,6 +202,19 @@ config SMP
- 
-         If you don't know what to do here, say N.
- 
-+config SMP_ALTERNATIVES
-+      bool "SMP alternatives support (EXPERIMENTAL)"
-+      depends on SMP && EXPERIMENTAL
-+      help
-+        Try to reduce the overhead of running an SMP kernel on a uniprocessor
-+        host slightly by replacing certain key instruction sequences
-+        according to whether we currently have more than one CPU available.
-+        This should provide a noticeable boost to performance when
-+        running SMP kernels on UP machines, and have negligible impact
-+        when running on an true SMP host.
-+
-+          If unsure, say N.
-+        
- config NR_CPUS
-       int "Maximum number of CPUs (2-255)"
-       range 2 255
-diff -pruN ../pristine-linux-2.6.16-rc5/arch/i386/kernel/Makefile 
./arch/i386/kernel/Makefile
---- ../pristine-linux-2.6.16-rc5/arch/i386/kernel/Makefile     2006-02-27 
15:46:58.000000000 +0000
-+++ ./arch/i386/kernel/Makefile        2006-02-27 15:55:34.000000000 +0000
-@@ -37,6 +37,7 @@ obj-$(CONFIG_EFI)            += efi.o efi_stub.o
- obj-$(CONFIG_DOUBLEFAULT)     += doublefault.o
- obj-$(CONFIG_VM86)            += vm86.o
- obj-$(CONFIG_EARLY_PRINTK)    += early_printk.o
-+obj-$(CONFIG_SMP_ALTERNATIVES)  += smpalts.o
- 
- EXTRA_AFLAGS   := -traditional
- 
-diff -pruN ../pristine-linux-2.6.16-rc5/arch/i386/kernel/smpalts.c 
./arch/i386/kernel/smpalts.c
---- ../pristine-linux-2.6.16-rc5/arch/i386/kernel/smpalts.c    1970-01-01 
01:00:00.000000000 +0100
-+++ ./arch/i386/kernel/smpalts.c       2006-02-27 15:55:34.000000000 +0000
-@@ -0,0 +1,85 @@
-+#include <linux/kernel.h>
-+#include <asm/system.h>
-+#include <asm/smp_alt.h>
-+#include <asm/processor.h>
-+#include <asm/string.h>
-+
-+struct smp_replacement_record {
-+      unsigned char targ_size;
-+      unsigned char smp1_size;
-+      unsigned char smp2_size;
-+      unsigned char up_size;
-+      unsigned char feature;
-+      unsigned char data[0];
-+};
-+
-+struct smp_alternative_record {
-+      void *targ_start;
-+      struct smp_replacement_record *repl;
-+};
-+
-+extern struct smp_alternative_record __start_smp_alternatives_table,
-+  __stop_smp_alternatives_table;
-+extern unsigned long __init_begin, __init_end;
-+
-+void prepare_for_smp(void)
-+{
-+      struct smp_alternative_record *r;
-+      printk(KERN_INFO "Enabling SMP...\n");
-+      for (r = &__start_smp_alternatives_table;
-+           r != &__stop_smp_alternatives_table;
-+           r++) {
-+              BUG_ON(r->repl->targ_size < r->repl->smp1_size);
-+              BUG_ON(r->repl->targ_size < r->repl->smp2_size);
-+              BUG_ON(r->repl->targ_size < r->repl->up_size);
-+               if (system_state == SYSTEM_RUNNING &&
-+                   r->targ_start >= (void *)&__init_begin &&
-+                   r->targ_start < (void *)&__init_end)
-+                       continue;
-+              if (r->repl->feature != (unsigned char)-1 &&
-+                  boot_cpu_has(r->repl->feature)) {
-+                      memcpy(r->targ_start,
-+                             r->repl->data + r->repl->smp1_size,
-+                             r->repl->smp2_size);
-+                      memset(r->targ_start + r->repl->smp2_size,
-+                             0x90,
-+                             r->repl->targ_size - r->repl->smp2_size);
-+              } else {
-+                      memcpy(r->targ_start,
-+                             r->repl->data,
-+                             r->repl->smp1_size);
-+                      memset(r->targ_start + r->repl->smp1_size,
-+                             0x90,
-+                             r->repl->targ_size - r->repl->smp1_size);
-+              }
-+      }
-+      /* Paranoia */
-+      asm volatile ("jmp 1f\n1:");
-+      mb();
-+}
-+
-+void unprepare_for_smp(void)
-+{
-+      struct smp_alternative_record *r;
-+      printk(KERN_INFO "Disabling SMP...\n");
-+      for (r = &__start_smp_alternatives_table;
-+           r != &__stop_smp_alternatives_table;
-+           r++) {
-+              BUG_ON(r->repl->targ_size < r->repl->smp1_size);
-+              BUG_ON(r->repl->targ_size < r->repl->smp2_size);
-+              BUG_ON(r->repl->targ_size < r->repl->up_size);
-+               if (system_state == SYSTEM_RUNNING &&
-+                   r->targ_start >= (void *)&__init_begin &&
-+                   r->targ_start < (void *)&__init_end)
-+                       continue;
-+              memcpy(r->targ_start,
-+                     r->repl->data + r->repl->smp1_size + r->repl->smp2_size,
-+                     r->repl->up_size);
-+              memset(r->targ_start + r->repl->up_size,
-+                     0x90,
-+                     r->repl->targ_size - r->repl->up_size);
-+      }
-+      /* Paranoia */
-+      asm volatile ("jmp 1f\n1:");
-+      mb();
-+}
-diff -pruN ../pristine-linux-2.6.16-rc5/arch/i386/kernel/smpboot.c 
./arch/i386/kernel/smpboot.c
---- ../pristine-linux-2.6.16-rc5/arch/i386/kernel/smpboot.c    2006-02-27 
15:46:58.000000000 +0000
-+++ ./arch/i386/kernel/smpboot.c       2006-02-27 15:55:34.000000000 +0000
-@@ -1208,6 +1208,11 @@ static void __init smp_boot_cpus(unsigne
-               if (max_cpus <= cpucount+1)
-                       continue;
- 
-+#ifdef CONFIG_SMP_ALTERNATIVES
-+              if (kicked == 1)
-+                      prepare_for_smp();
-+#endif
-+
-               if (((cpu = alloc_cpu_id()) <= 0) || do_boot_cpu(apicid, cpu))
-                       printk("CPU #%d not responding - cannot use it.\n",
-                                                               apicid);
-@@ -1386,6 +1391,11 @@ int __devinit __cpu_up(unsigned int cpu)
-               return -EIO;
-       }
- 
-+#ifdef CONFIG_SMP_ALTERNATIVES
-+      if (num_online_cpus() == 1)
-+              prepare_for_smp();
-+#endif
-+
-       local_irq_enable();
-       per_cpu(cpu_state, cpu) = CPU_UP_PREPARE;
-       /* Unleash the CPU! */
-diff -pruN ../pristine-linux-2.6.16-rc5/arch/i386/kernel/vmlinux.lds.S 
./arch/i386/kernel/vmlinux.lds.S
---- ../pristine-linux-2.6.16-rc5/arch/i386/kernel/vmlinux.lds.S        
2006-01-03 03:21:10.000000000 +0000
-+++ ./arch/i386/kernel/vmlinux.lds.S   2006-02-27 15:55:34.000000000 +0000
-@@ -34,6 +34,13 @@ SECTIONS
-   __ex_table : AT(ADDR(__ex_table) - LOAD_OFFSET) { *(__ex_table) }
-   __stop___ex_table = .;
- 
-+  . = ALIGN(16);
-+  __start_smp_alternatives_table = .;
-+  __smp_alternatives : { *(__smp_alternatives) }
-+  __stop_smp_alternatives_table = .;
-+
-+  __smp_replacements : { *(__smp_replacements) }
-+
-   RODATA
- 
-   /* writeable */
-diff -pruN ../pristine-linux-2.6.16-rc5/include/asm-i386/atomic.h 
./include/asm-i386/atomic.h
---- ../pristine-linux-2.6.16-rc5/include/asm-i386/atomic.h     2006-02-27 
15:47:25.000000000 +0000
-+++ ./include/asm-i386/atomic.h        2006-02-27 15:55:34.000000000 +0000
-@@ -4,18 +4,13 @@
- #include <linux/config.h>
- #include <linux/compiler.h>
- #include <asm/processor.h>
-+#include <asm/smp_alt.h>
- 
- /*
-  * Atomic operations that C can't guarantee us.  Useful for
-  * resource counting etc..
-  */
- 
--#ifdef CONFIG_SMP
--#define LOCK "lock ; "
--#else
--#define LOCK ""
--#endif
--
- /*
-  * Make sure gcc doesn't try to be clever and move things around
-  * on us. We need to use _exactly_ the address the user gave us,
-diff -pruN ../pristine-linux-2.6.16-rc5/include/asm-i386/bitops.h 
./include/asm-i386/bitops.h
---- ../pristine-linux-2.6.16-rc5/include/asm-i386/bitops.h     2006-02-27 
15:47:25.000000000 +0000
-+++ ./include/asm-i386/bitops.h        2006-02-27 15:55:34.000000000 +0000
-@@ -7,6 +7,7 @@
- 
- #include <linux/config.h>
- #include <linux/compiler.h>
-+#include <asm/smp_alt.h>
- 
- /*
-  * These have to be done with inline assembly: that way the bit-setting
-@@ -16,12 +17,6 @@
-  * bit 0 is the LSB of addr; bit 32 is the LSB of (addr+1).
-  */
- 
--#ifdef CONFIG_SMP
--#define LOCK_PREFIX "lock ; "
--#else
--#define LOCK_PREFIX ""
--#endif
--
- #define ADDR (*(volatile long *) addr)
- 
- /**
-@@ -41,7 +36,7 @@
-  */
- static inline void set_bit(int nr, volatile unsigned long * addr)
- {
--      __asm__ __volatile__( LOCK_PREFIX
-+      __asm__ __volatile__( LOCK
-               "btsl %1,%0"
-               :"+m" (ADDR)
-               :"Ir" (nr));
-@@ -76,7 +71,7 @@ static inline void __set_bit(int nr, vol
-  */
- static inline void clear_bit(int nr, volatile unsigned long * addr)
- {
--      __asm__ __volatile__( LOCK_PREFIX
-+      __asm__ __volatile__( LOCK
-               "btrl %1,%0"
-               :"+m" (ADDR)
-               :"Ir" (nr));
-@@ -121,7 +116,7 @@ static inline void __change_bit(int nr, 
-  */
- static inline void change_bit(int nr, volatile unsigned long * addr)
- {
--      __asm__ __volatile__( LOCK_PREFIX
-+      __asm__ __volatile__( LOCK
-               "btcl %1,%0"
-               :"+m" (ADDR)
-               :"Ir" (nr));
-@@ -140,7 +135,7 @@ static inline int test_and_set_bit(int n
- {
-       int oldbit;
- 
--      __asm__ __volatile__( LOCK_PREFIX
-+      __asm__ __volatile__( LOCK
-               "btsl %2,%1\n\tsbbl %0,%0"
-               :"=r" (oldbit),"+m" (ADDR)
-               :"Ir" (nr) : "memory");
-@@ -180,7 +175,7 @@ static inline int test_and_clear_bit(int
- {
-       int oldbit;
- 
--      __asm__ __volatile__( LOCK_PREFIX
-+      __asm__ __volatile__( LOCK
-               "btrl %2,%1\n\tsbbl %0,%0"
-               :"=r" (oldbit),"+m" (ADDR)
-               :"Ir" (nr) : "memory");
-@@ -231,7 +226,7 @@ static inline int test_and_change_bit(in
- {
-       int oldbit;
- 
--      __asm__ __volatile__( LOCK_PREFIX
-+      __asm__ __volatile__( LOCK
-               "btcl %2,%1\n\tsbbl %0,%0"
-               :"=r" (oldbit),"+m" (ADDR)
-               :"Ir" (nr) : "memory");
-diff -pruN ../pristine-linux-2.6.16-rc5/include/asm-i386/futex.h 
./include/asm-i386/futex.h
---- ../pristine-linux-2.6.16-rc5/include/asm-i386/futex.h      2006-02-27 
15:47:25.000000000 +0000
-+++ ./include/asm-i386/futex.h 2006-02-27 15:55:34.000000000 +0000
-@@ -28,7 +28,7 @@
- "1:   movl    %2, %0\n\
-       movl    %0, %3\n"                                       \
-       insn "\n"                                               \
--"2:   " LOCK_PREFIX "cmpxchgl %3, %2\n\
-+"2:   " LOCK "cmpxchgl %3, %2\n\
-       jnz     1b\n\
- 3:    .section .fixup,\"ax\"\n\
- 4:    mov     %5, %1\n\
-@@ -68,7 +68,7 @@ futex_atomic_op_inuser (int encoded_op, 
- #endif
-               switch (op) {
-               case FUTEX_OP_ADD:
--                      __futex_atomic_op1(LOCK_PREFIX "xaddl %0, %2", ret,
-+                      __futex_atomic_op1(LOCK "xaddl %0, %2", ret,
-                                          oldval, uaddr, oparg);
-                       break;
-               case FUTEX_OP_OR:
-diff -pruN ../pristine-linux-2.6.16-rc5/include/asm-i386/rwsem.h 
./include/asm-i386/rwsem.h
---- ../pristine-linux-2.6.16-rc5/include/asm-i386/rwsem.h      2006-01-03 
03:21:10.000000000 +0000
-+++ ./include/asm-i386/rwsem.h 2006-02-27 15:55:34.000000000 +0000
-@@ -40,6 +40,7 @@
- 
- #include <linux/list.h>
- #include <linux/spinlock.h>
-+#include <asm/smp_alt.h>
- 
- struct rwsem_waiter;
- 
-@@ -99,7 +100,7 @@ static inline void __down_read(struct rw
- {
-       __asm__ __volatile__(
-               "# beginning down_read\n\t"
--LOCK_PREFIX   "  incl      (%%eax)\n\t" /* adds 0x00000001, returns the old 
value */
-+LOCK          "  incl      (%%eax)\n\t" /* adds 0x00000001, returns the old 
value */
-               "  js        2f\n\t" /* jump if we weren't granted the lock */
-               "1:\n\t"
-               LOCK_SECTION_START("")
-@@ -130,7 +131,7 @@ static inline int __down_read_trylock(st
-               "  movl      %1,%2\n\t"
-               "  addl      %3,%2\n\t"
-               "  jle       2f\n\t"
--LOCK_PREFIX   "  cmpxchgl  %2,%0\n\t"
-+LOCK          "  cmpxchgl  %2,%0\n\t"
-               "  jnz       1b\n\t"
-               "2:\n\t"
-               "# ending __down_read_trylock\n\t"
-@@ -150,7 +151,7 @@ static inline void __down_write(struct r
-       tmp = RWSEM_ACTIVE_WRITE_BIAS;
-       __asm__ __volatile__(
-               "# beginning down_write\n\t"
--LOCK_PREFIX   "  xadd      %%edx,(%%eax)\n\t" /* subtract 0x0000ffff, returns 
the old value */
-+LOCK          "  xadd      %%edx,(%%eax)\n\t" /* subtract 0x0000ffff, returns 
the old value */
-               "  testl     %%edx,%%edx\n\t" /* was the count 0 before? */
-               "  jnz       2f\n\t" /* jump if we weren't granted the lock */
-               "1:\n\t"
-@@ -188,7 +189,7 @@ static inline void __up_read(struct rw_s
-       __s32 tmp = -RWSEM_ACTIVE_READ_BIAS;
-       __asm__ __volatile__(
-               "# beginning __up_read\n\t"
--LOCK_PREFIX   "  xadd      %%edx,(%%eax)\n\t" /* subtracts 1, returns the old 
value */
-+LOCK          "  xadd      %%edx,(%%eax)\n\t" /* subtracts 1, returns the old 
value */
-               "  js        2f\n\t" /* jump if the lock is being waited upon */
-               "1:\n\t"
-               LOCK_SECTION_START("")
-@@ -214,7 +215,7 @@ static inline void __up_write(struct rw_
-       __asm__ __volatile__(
-               "# beginning __up_write\n\t"
-               "  movl      %2,%%edx\n\t"
--LOCK_PREFIX   "  xaddl     %%edx,(%%eax)\n\t" /* tries to transition 
0xffff0001 -> 0x00000000 */
-+LOCK          "  xaddl     %%edx,(%%eax)\n\t" /* tries to transition 
0xffff0001 -> 0x00000000 */
-               "  jnz       2f\n\t" /* jump if the lock is being waited upon */
-               "1:\n\t"
-               LOCK_SECTION_START("")
-@@ -239,7 +240,7 @@ static inline void __downgrade_write(str
- {
-       __asm__ __volatile__(
-               "# beginning __downgrade_write\n\t"
--LOCK_PREFIX   "  addl      %2,(%%eax)\n\t" /* transitions 0xZZZZ0001 -> 
0xYYYY0001 */
-+LOCK          "  addl      %2,(%%eax)\n\t" /* transitions 0xZZZZ0001 -> 
0xYYYY0001 */
-               "  js        2f\n\t" /* jump if the lock is being waited upon */
-               "1:\n\t"
-               LOCK_SECTION_START("")
-@@ -263,7 +264,7 @@ LOCK_PREFIX        "  addl      %2,(%%eax)\n\t"
- static inline void rwsem_atomic_add(int delta, struct rw_semaphore *sem)
- {
-       __asm__ __volatile__(
--LOCK_PREFIX   "addl %1,%0"
-+LOCK            "addl %1,%0"
-               : "=m"(sem->count)
-               : "ir"(delta), "m"(sem->count));
- }
-@@ -276,7 +277,7 @@ static inline int rwsem_atomic_update(in
-       int tmp = delta;
- 
-       __asm__ __volatile__(
--LOCK_PREFIX   "xadd %0,(%2)"
-+LOCK                    "xadd %0,(%2)"
-               : "+r"(tmp), "=m"(sem->count)
-               : "r"(sem), "m"(sem->count)
-               : "memory");
-diff -pruN ../pristine-linux-2.6.16-rc5/include/asm-i386/smp_alt.h 
./include/asm-i386/smp_alt.h
---- ../pristine-linux-2.6.16-rc5/include/asm-i386/smp_alt.h    1970-01-01 
01:00:00.000000000 +0100
-+++ ./include/asm-i386/smp_alt.h       2006-02-27 15:55:34.000000000 +0000
-@@ -0,0 +1,32 @@
-+#ifndef __ASM_SMP_ALT_H__
-+#define __ASM_SMP_ALT_H__
-+
-+#include <linux/config.h>
-+
-+#ifdef CONFIG_SMP
-+#if defined(CONFIG_SMP_ALTERNATIVES) && !defined(MODULE)
-+#define LOCK \
-+        "6677: nop\n" \
-+      ".section __smp_alternatives,\"a\"\n" \
-+      ".long 6677b\n" \
-+      ".long 6678f\n" \
-+      ".previous\n" \
-+      ".section __smp_replacements,\"a\"\n" \
-+      "6678: .byte 1\n" \
-+      ".byte 1\n" \
-+      ".byte 0\n" \
-+        ".byte 1\n" \
-+      ".byte -1\n" \
-+      "lock\n" \
-+      "nop\n" \
-+      ".previous\n"
-+void prepare_for_smp(void);
-+void unprepare_for_smp(void);
-+#else
-+#define LOCK "lock ; "
-+#endif
-+#else
-+#define LOCK ""
-+#endif
-+
-+#endif /* __ASM_SMP_ALT_H__ */
-diff -pruN ../pristine-linux-2.6.16-rc5/include/asm-i386/spinlock.h 
./include/asm-i386/spinlock.h
---- ../pristine-linux-2.6.16-rc5/include/asm-i386/spinlock.h   2006-01-03 
03:21:10.000000000 +0000
-+++ ./include/asm-i386/spinlock.h      2006-02-27 15:55:34.000000000 +0000
-@@ -6,6 +6,7 @@
- #include <asm/page.h>
- #include <linux/config.h>
- #include <linux/compiler.h>
-+#include <asm/smp_alt.h>
- 
- /*
-  * Your basic SMP spinlocks, allowing only a single CPU anywhere
-@@ -23,7 +24,8 @@
- 
- #define __raw_spin_lock_string \
-       "\n1:\t" \
--      "lock ; decb %0\n\t" \
-+      LOCK \
-+      "decb %0\n\t" \
-       "jns 3f\n" \
-       "2:\t" \
-       "rep;nop\n\t" \
-@@ -34,7 +36,8 @@
- 
- #define __raw_spin_lock_string_flags \
-       "\n1:\t" \
--      "lock ; decb %0\n\t" \
-+      LOCK \
-+      "decb %0\n\t" \
-       "jns 4f\n\t" \
-       "2:\t" \
-       "testl $0x200, %1\n\t" \
-@@ -65,10 +68,34 @@ static inline void __raw_spin_lock_flags
- static inline int __raw_spin_trylock(raw_spinlock_t *lock)
- {
-       char oldval;
-+#ifdef CONFIG_SMP_ALTERNATIVES
-       __asm__ __volatile__(
--              "xchgb %b0,%1"
-+              "1:movb %1,%b0\n"
-+              "movb $0,%1\n"
-+              "2:"
-+              ".section __smp_alternatives,\"a\"\n"
-+              ".long 1b\n"
-+              ".long 3f\n"
-+              ".previous\n"
-+              ".section __smp_replacements,\"a\"\n"
-+              "3: .byte 2b - 1b\n"
-+              ".byte 5f-4f\n"
-+              ".byte 0\n"
-+              ".byte 6f-5f\n"
-+              ".byte -1\n"
-+              "4: xchgb %b0,%1\n"
-+              "5: movb %1,%b0\n"
-+              "movb $0,%1\n"
-+              "6:\n"
-+              ".previous\n"
-               :"=q" (oldval), "=m" (lock->slock)
-               :"0" (0) : "memory");
-+#else
-+      __asm__ __volatile__(
-+              "xchgb %b0,%1\n"
-+              :"=q" (oldval), "=m" (lock->slock)
-+              :"0" (0) : "memory");
-+#endif
-       return oldval > 0;
- }
- 
-@@ -178,12 +205,12 @@ static inline int __raw_write_trylock(ra
- 
- static inline void __raw_read_unlock(raw_rwlock_t *rw)
- {
--      asm volatile("lock ; incl %0" :"=m" (rw->lock) : : "memory");
-+      asm volatile(LOCK "incl %0" :"=m" (rw->lock) : : "memory");
- }
- 
- static inline void __raw_write_unlock(raw_rwlock_t *rw)
- {
--      asm volatile("lock ; addl $" RW_LOCK_BIAS_STR ", %0"
-+      asm volatile(LOCK "addl $" RW_LOCK_BIAS_STR ", %0"
-                                : "=m" (rw->lock) : : "memory");
- }
- 
-diff -pruN ../pristine-linux-2.6.16-rc5/include/asm-i386/system.h 
./include/asm-i386/system.h
---- ../pristine-linux-2.6.16-rc5/include/asm-i386/system.h     2006-02-27 
15:47:25.000000000 +0000
-+++ ./include/asm-i386/system.h        2006-02-27 15:55:34.000000000 +0000
-@@ -5,7 +5,7 @@
- #include <linux/kernel.h>
- #include <asm/segment.h>
- #include <asm/cpufeature.h>
--#include <linux/bitops.h> /* for LOCK_PREFIX */
-+#include <asm/smp_alt.h>
- 
- #ifdef __KERNEL__
- 
-@@ -271,19 +271,19 @@ static inline unsigned long __cmpxchg(vo
-       unsigned long prev;
-       switch (size) {
-       case 1:
--              __asm__ __volatile__(LOCK_PREFIX "cmpxchgb %b1,%2"
-+              __asm__ __volatile__(LOCK "cmpxchgb %b1,%2"
-                                    : "=a"(prev)
-                                    : "q"(new), "m"(*__xg(ptr)), "0"(old)
-                                    : "memory");
-               return prev;
-       case 2:
--              __asm__ __volatile__(LOCK_PREFIX "cmpxchgw %w1,%2"
-+              __asm__ __volatile__(LOCK "cmpxchgw %w1,%2"
-                                    : "=a"(prev)
-                                    : "r"(new), "m"(*__xg(ptr)), "0"(old)
-                                    : "memory");
-               return prev;
-       case 4:
--              __asm__ __volatile__(LOCK_PREFIX "cmpxchgl %1,%2"
-+              __asm__ __volatile__(LOCK "cmpxchgl %1,%2"
-                                    : "=a"(prev)
-                                    : "r"(new), "m"(*__xg(ptr)), "0"(old)
-                                    : "memory");
-@@ -336,7 +336,7 @@ static inline unsigned long long __cmpxc
-                                     unsigned long long new)
- {
-       unsigned long long prev;
--      __asm__ __volatile__(LOCK_PREFIX "cmpxchg8b %3"
-+      __asm__ __volatile__(LOCK "cmpxchg8b %3"
-                            : "=A"(prev)
-                            : "b"((unsigned long)new),
-                              "c"((unsigned long)(new >> 32)),
-@@ -503,11 +503,55 @@ struct alt_instr { 
- #endif
- 
- #ifdef CONFIG_SMP
-+#if defined(CONFIG_SMP_ALTERNATIVES) && !defined(MODULE)
-+#define smp_alt_mb(instr)                                           \
-+__asm__ __volatile__("6667:\nnop\nnop\nnop\nnop\nnop\nnop\n6668:\n" \
-+                   ".section __smp_alternatives,\"a\"\n"          \
-+                   ".long 6667b\n"                                \
-+                     ".long 6673f\n"                                \
-+                   ".previous\n"                                  \
-+                   ".section __smp_replacements,\"a\"\n"          \
-+                   "6673:.byte 6668b-6667b\n"                     \
-+                   ".byte 6670f-6669f\n"                          \
-+                   ".byte 6671f-6670f\n"                          \
-+                     ".byte 0\n"                                    \
-+                   ".byte %c0\n"                                  \
-+                   "6669:lock;addl $0,0(%%esp)\n"                 \
-+                   "6670:" instr "\n"                             \
-+                   "6671:\n"                                      \
-+                   ".previous\n"                                  \
-+                   :                                              \
-+                   : "i" (X86_FEATURE_XMM2)                       \
-+                   : "memory")
-+#define smp_rmb() smp_alt_mb("lfence")
-+#define smp_mb()  smp_alt_mb("mfence")
-+#define set_mb(var, value) do {                                     \
-+unsigned long __set_mb_temp;                                        \
-+__asm__ __volatile__("6667:movl %1, %0\n6668:\n"                    \
-+                   ".section __smp_alternatives,\"a\"\n"          \
-+                   ".long 6667b\n"                                \
-+                   ".long 6673f\n"                                \
-+                   ".previous\n"                                  \
-+                   ".section __smp_replacements,\"a\"\n"          \
-+                   "6673: .byte 6668b-6667b\n"                    \
-+                   ".byte 6670f-6669f\n"                          \
-+                   ".byte 0\n"                                    \
-+                   ".byte 6671f-6670f\n"                          \
-+                   ".byte -1\n"                                   \
-+                   "6669: xchg %1, %0\n"                          \
-+                   "6670:movl %1, %0\n"                           \
-+                   "6671:\n"                                      \
-+                   ".previous\n"                                  \
-+                   : "=m" (var), "=r" (__set_mb_temp)             \
-+                   : "1" (value)                                  \
-+                   : "memory"); } while (0)
-+#else
- #define smp_mb()      mb()
- #define smp_rmb()     rmb()
-+#define set_mb(var, value) do { (void) xchg(&var, value); } while (0)
-+#endif
- #define smp_wmb()     wmb()
- #define smp_read_barrier_depends()    read_barrier_depends()
--#define set_mb(var, value) do { (void) xchg(&var, value); } while (0)
- #else
- #define smp_mb()      barrier()
- #define smp_rmb()     barrier()

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>