summaryrefslogtreecommitdiff
path: root/trunk
diff options
context:
space:
mode:
authorMichael Marineau <marineam@gentoo.org>2007-09-05 22:09:32 +0000
committerMichael Marineau <marineam@gentoo.org>2007-09-05 22:09:32 +0000
commita391d3f5e1c83eb96c92a2ba6b3671068c9be899 (patch)
tree40a4053c95a7d0ea500b3e1d69ccf0337135c4e0 /trunk
parentReleasing 2.6.18-3 (diff)
downloadxen-a391d3f5e1c83eb96c92a2ba6b3671068c9be899.tar.gz
xen-a391d3f5e1c83eb96c92a2ba6b3671068c9be899.tar.bz2
xen-a391d3f5e1c83eb96c92a2ba6b3671068c9be899.zip
Sync patchset with Red Hat's 2.6.20-2931.fc7 release.
svn path=/patches/; revision=36
Diffstat (limited to 'trunk')
-rw-r--r--trunk/2.6.20/20950_linux-2.6.20.14-xen-3.1.0.patch (renamed from trunk/2.6.20/20950_linux-2.6-xen.patch)28260
-rw-r--r--trunk/2.6.20/20956-linux-2.6-fix-x86_64-smp.patch19
-rw-r--r--trunk/2.6.20/20958-linux-2.6-xen-iscsi-x86_64-no_iommu_init.patch15
-rw-r--r--trunk/2.6.20/20959-linux-2.6-xen-fix-nosegneg-detection.patch29
-rw-r--r--trunk/2.6.20/20960-linux-2.6-xen-blkfront-wait-add.patch3
-rw-r--r--trunk/2.6.20/20961_linux-2.6-xen-backwards-time.patch63
-rw-r--r--trunk/2.6.20/20962_linux-2.6-xen-add-packet_auxdata-cmsg-1.patch233
-rw-r--r--trunk/2.6.20/20963_linux-2.6-xen-add-packet_auxdata-cmsg-2.patch144
8 files changed, 13528 insertions, 15238 deletions
diff --git a/trunk/2.6.20/20950_linux-2.6-xen.patch b/trunk/2.6.20/20950_linux-2.6.20.14-xen-3.1.0.patch
index 9c58fd2..b46f4a4 100644
--- a/trunk/2.6.20/20950_linux-2.6-xen.patch
+++ b/trunk/2.6.20/20950_linux-2.6.20.14-xen-3.1.0.patch
@@ -1,31 +1,6 @@
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/arch/i386/boot-xen/Makefile source/arch/i386/boot-xen/Makefile
---- /scratch/src/linux-2.6.20.3/arch/i386/boot-xen/Makefile 1970-01-01 01:00:00.000000000 +0100
-+++ source/arch/i386/boot-xen/Makefile 2007-03-20 21:26:26.000000000 +0100
-@@ -0,0 +1,21 @@
-+
-+OBJCOPYFLAGS := -g --strip-unneeded
-+
-+vmlinuz: vmlinux-stripped FORCE
-+ $(call if_changed,gzip)
-+
-+vmlinux-stripped: vmlinux FORCE
-+ $(call if_changed,objcopy)
-+
-+INSTALL_ROOT := $(patsubst %/boot,%,$(INSTALL_PATH))
-+
-+XINSTALL_NAME ?= $(KERNELRELEASE)
-+install:
-+ mkdir -p $(INSTALL_ROOT)/boot
-+ ln -f -s vmlinuz-$(XINSTALL_NAME)$(INSTALL_SUFFIX) $(INSTALL_ROOT)/boot/vmlinuz-$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(XENGUEST)$(INSTALL_SUFFIX)
-+ rm -f $(INSTALL_ROOT)/boot/vmlinuz-$(XINSTALL_NAME)$(INSTALL_SUFFIX)
-+ install -m0644 vmlinuz $(INSTALL_ROOT)/boot/vmlinuz-$(XINSTALL_NAME)$(INSTALL_SUFFIX)
-+ install -m0644 vmlinux $(INSTALL_ROOT)/boot/vmlinux-syms-$(XINSTALL_NAME)$(INSTALL_SUFFIX)
-+ install -m0664 .config $(INSTALL_ROOT)/boot/config-$(XINSTALL_NAME)$(INSTALL_SUFFIX)
-+ install -m0664 System.map $(INSTALL_ROOT)/boot/System.map-$(XINSTALL_NAME)$(INSTALL_SUFFIX)
-+ ln -f -s vmlinuz-$(XINSTALL_NAME)$(INSTALL_SUFFIX) $(INSTALL_ROOT)/boot/vmlinuz-$(VERSION).$(PATCHLEVEL)$(XENGUEST)$(INSTALL_SUFFIX)
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/arch/i386/Kconfig source/arch/i386/Kconfig
---- /scratch/src/linux-2.6.20.3/arch/i386/Kconfig 2007-02-04 19:44:54.000000000 +0100
-+++ source/arch/i386/Kconfig 2007-03-21 14:49:46.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 arch/i386/Kconfig
+--- a/arch/i386/Kconfig Wed Jul 18 12:23:24 2007 -0300
++++ b/arch/i386/Kconfig Wed Aug 08 16:25:28 2007 -0300
@@ -16,6 +16,7 @@ config X86_32
config GENERIC_TIME
@@ -34,10 +9,11 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
default y
config LOCKDEP_SUPPORT
-@@ -108,6 +109,15 @@ config X86_PC
+@@ -107,6 +108,15 @@ config X86_PC
+ bool "PC-compatible"
help
Choose this option if your computer is a standard PC or compatible.
-
++
+config X86_XEN
+ bool "Xen-compatible"
+ select X86_UP_APIC if !SMP && XEN_PRIVILEGED_GUEST
@@ -46,10 +22,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ help
+ Choose this option if you plan to run this kernel on top of the
+ Xen Hypervisor.
-+
+
config X86_ELAN
bool "AMD Elan"
- help
@@ -229,6 +239,7 @@ source "arch/i386/Kconfig.cpu"
config HPET_TIMER
@@ -107,26 +82,17 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
help
This device gives privileged processes access to the x86
Model-Specific Registers (MSRs). It is a character device with
-@@ -456,6 +469,10 @@ config X86_CPUID
+@@ -455,6 +468,10 @@ config X86_CPUID
+ be executed on a specific processor. It is a character device
with major 203 and minors 0 to 31 for /dev/cpu/0/cpuid to
/dev/cpu/31/cpuid.
-
++
+config SWIOTLB
+ bool
+ default n
-+
- source "drivers/firmware/Kconfig"
- choice
-@@ -629,7 +646,7 @@ source "mm/Kconfig"
+ source "drivers/firmware/Kconfig"
- config HIGHPTE
- bool "Allocate 3rd-level pagetables from highmem"
-- depends on HIGHMEM4G || HIGHMEM64G
-+ depends on (HIGHMEM4G || HIGHMEM64G) && !X86_XEN
- help
- The VM uses one page table entry for each page of physical memory.
- For systems with a lot of RAM, this can be wasteful of precious
@@ -638,6 +655,7 @@ config HIGHPTE
config MATH_EMULATION
@@ -183,8 +149,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
menu "Power management options (ACPI, APM)"
- depends on !X86_VOYAGER
+-
+ depends on !(X86_VOYAGER || XEN_UNPRIVILEGED_GUEST)
-
++
+if !X86_XEN
source kernel/power/Kconfig
+endif
@@ -210,7 +177,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
config PCI_GOMMCONFIG
bool "MMConfig"
-@@ -1085,6 +1110,13 @@ config PCI_GOMMCONFIG
+@@ -1085,6 +1110,13 @@ config PCI_GODIRECT
config PCI_GODIRECT
bool "Direct"
@@ -233,10 +200,11 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
default y
config PCI_DIRECT
-@@ -1105,6 +1137,18 @@ config PCI_MMCONFIG
+@@ -1104,6 +1136,18 @@ config PCI_MMCONFIG
+ bool
depends on PCI && ACPI && (PCI_GOMMCONFIG || PCI_GOANY)
default y
-
++
+config XEN_PCIDEV_FRONTEND
+ bool
+ depends on PCI && X86_XEN && (PCI_GOXEN_FE || PCI_GOANY)
@@ -248,10 +216,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ default n
+ help
+ Enables some debug statements within the PCI Frontend.
-+
+
source "drivers/pci/pcie/Kconfig"
- source "drivers/pci/Kconfig"
@@ -1115,7 +1159,7 @@ config ISA_DMA_API
config ISA
@@ -261,7 +228,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
help
Find out whether you have ISA slots on your motherboard. ISA is the
name of a bus system, i.e. the way the CPU talks to the other stuff
-@@ -1142,7 +1186,7 @@ config EISA
+@@ -1142,7 +1186,7 @@ source "drivers/eisa/Kconfig"
source "drivers/eisa/Kconfig"
config MCA
@@ -305,9 +272,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
config KTIME_SCALAR
bool
default y
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/arch/i386/Kconfig.cpu source/arch/i386/Kconfig.cpu
---- /scratch/src/linux-2.6.20.3/arch/i386/Kconfig.cpu 2007-02-04 19:44:54.000000000 +0100
-+++ source/arch/i386/Kconfig.cpu 2007-03-20 21:26:26.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 arch/i386/Kconfig.cpu
+--- a/arch/i386/Kconfig.cpu Wed Jul 18 12:23:24 2007 -0300
++++ b/arch/i386/Kconfig.cpu Wed Aug 08 16:25:28 2007 -0300
@@ -267,7 +267,7 @@ config X86_PPRO_FENCE
config X86_F00F_BUG
@@ -322,12 +289,13 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
config X86_TSC
bool
- depends on (MWINCHIP3D || MWINCHIP2 || MCRUSOE || MEFFICEON || MCYRIXIII || MK7 || MK6 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || M586MMX || M586TSC || MK8 || MVIAC3_2 || MGEODEGX1 || MGEODE_LX || MCORE2) && !X86_NUMAQ
+- default y
+ depends on (MWINCHIP3D || MWINCHIP2 || MCRUSOE || MEFFICEON || MCYRIXIII || MK7 || MK6 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || M586MMX || M586TSC || MK8 || MVIAC3_2 || MGEODEGX1 || MGEODE_LX || MCORE2) && !X86_NUMAQ && !X86_XEN
- default y
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/arch/i386/Kconfig.debug source/arch/i386/Kconfig.debug
---- /scratch/src/linux-2.6.20.3/arch/i386/Kconfig.debug 2007-02-04 19:44:54.000000000 +0100
-+++ source/arch/i386/Kconfig.debug 2007-03-20 21:26:26.000000000 +0100
-@@ -79,6 +79,7 @@ config X86_MPPARSE
++ default y
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 arch/i386/Kconfig.debug
+--- a/arch/i386/Kconfig.debug Wed Jul 18 12:23:24 2007 -0300
++++ b/arch/i386/Kconfig.debug Wed Aug 08 16:25:28 2007 -0300
+@@ -79,6 +79,7 @@ config DOUBLEFAULT
config DOUBLEFAULT
default y
bool "Enable doublefault exception handler" if EMBEDDED
@@ -335,9 +303,149 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
help
This option allows trapping of rare doublefault exceptions that
would otherwise cause a system to silently reboot. Disabling this
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/arch/i386/kernel/acpi/boot.c source/arch/i386/kernel/acpi/boot.c
---- /scratch/src/linux-2.6.20.3/arch/i386/kernel/acpi/boot.c 2007-02-04 19:44:54.000000000 +0100
-+++ source/arch/i386/kernel/acpi/boot.c 2007-03-20 21:26:26.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 arch/i386/Makefile
+--- a/arch/i386/Makefile Wed Jul 18 12:23:24 2007 -0300
++++ b/arch/i386/Makefile Wed Aug 08 16:25:28 2007 -0300
+@@ -60,6 +60,11 @@ AFLAGS += $(call as-instr,.cfi_startproc
+
+ CFLAGS += $(cflags-y)
+
++cppflags-$(CONFIG_XEN) += \
++ -D__XEN_INTERFACE_VERSION__=$(CONFIG_XEN_INTERFACE_VERSION)
++
++CPPFLAGS += $(cppflags-y)
++
+ # Default subarch .c files
+ mcore-y := mach-default
+
+@@ -82,6 +87,10 @@ mcore-$(CONFIG_X86_BIGSMP) := mach-defau
+ #Summit subarch support
+ mflags-$(CONFIG_X86_SUMMIT) := -Iinclude/asm-i386/mach-summit
+ mcore-$(CONFIG_X86_SUMMIT) := mach-default
++
++# Xen subarch support
++mflags-$(CONFIG_X86_XEN) := -Iinclude/asm-i386/mach-xen
++mcore-$(CONFIG_X86_XEN) := mach-xen
+
+ # generic subarchitecture
+ mflags-$(CONFIG_X86_GENERICARCH) := -Iinclude/asm-i386/mach-generic
+@@ -117,6 +126,19 @@ PHONY += zImage bzImage compressed zlilo
+ PHONY += zImage bzImage compressed zlilo bzlilo \
+ zdisk bzdisk fdimage fdimage144 fdimage288 isoimage install
+
++ifdef CONFIG_XEN
++CPPFLAGS := -Iinclude$(if $(KBUILD_SRC),2)/asm/mach-xen $(CPPFLAGS)
++head-y := arch/i386/kernel/head-xen.o arch/i386/kernel/init_task.o
++boot := arch/i386/boot-xen
++.PHONY: vmlinuz
++all: vmlinuz
++
++vmlinuz: vmlinux
++ $(Q)$(MAKE) $(build)=$(boot) $@
++
++install:
++ $(Q)$(MAKE) $(build)=$(boot) XENGUEST=$(XENGUEST) $@
++else
+ all: bzImage
+
+ # KBUILD_IMAGE specify target image being built
+@@ -139,6 +161,7 @@ fdimage fdimage144 fdimage288 isoimage:
+
+ install:
+ $(Q)$(MAKE) $(build)=$(boot) BOOTIMAGE=$(KBUILD_IMAGE) install
++endif
+
+ archclean:
+ $(Q)$(MAKE) $(clean)=arch/i386/boot
+@@ -157,3 +180,4 @@ CLEAN_FILES += arch/$(ARCH)/boot/fdimage
+ CLEAN_FILES += arch/$(ARCH)/boot/fdimage \
+ arch/$(ARCH)/boot/image.iso \
+ arch/$(ARCH)/boot/mtools.conf
++CLEAN_FILES += vmlinuz vmlinux-stripped
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 arch/i386/boot-xen/Makefile
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/arch/i386/boot-xen/Makefile Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,21 @@
++
++OBJCOPYFLAGS := -g --strip-unneeded
++
++vmlinuz: vmlinux-stripped FORCE
++ $(call if_changed,gzip)
++
++vmlinux-stripped: vmlinux FORCE
++ $(call if_changed,objcopy)
++
++INSTALL_ROOT := $(patsubst %/boot,%,$(INSTALL_PATH))
++
++XINSTALL_NAME ?= $(KERNELRELEASE)
++install:
++ mkdir -p $(INSTALL_ROOT)/boot
++ ln -f -s vmlinuz-$(XINSTALL_NAME)$(INSTALL_SUFFIX) $(INSTALL_ROOT)/boot/vmlinuz-$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(XENGUEST)$(INSTALL_SUFFIX)
++ rm -f $(INSTALL_ROOT)/boot/vmlinuz-$(XINSTALL_NAME)$(INSTALL_SUFFIX)
++ install -m0644 vmlinuz $(INSTALL_ROOT)/boot/vmlinuz-$(XINSTALL_NAME)$(INSTALL_SUFFIX)
++ install -m0644 vmlinux $(INSTALL_ROOT)/boot/vmlinux-syms-$(XINSTALL_NAME)$(INSTALL_SUFFIX)
++ install -m0664 .config $(INSTALL_ROOT)/boot/config-$(XINSTALL_NAME)$(INSTALL_SUFFIX)
++ install -m0664 System.map $(INSTALL_ROOT)/boot/System.map-$(XINSTALL_NAME)$(INSTALL_SUFFIX)
++ ln -f -s vmlinuz-$(XINSTALL_NAME)$(INSTALL_SUFFIX) $(INSTALL_ROOT)/boot/vmlinuz-$(VERSION).$(PATCHLEVEL)$(XENGUEST)$(INSTALL_SUFFIX)
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 arch/i386/kernel/Makefile
+--- a/arch/i386/kernel/Makefile Wed Jul 18 12:23:24 2007 -0300
++++ b/arch/i386/kernel/Makefile Wed Aug 08 16:25:28 2007 -0300
+@@ -47,6 +47,12 @@ EXTRA_AFLAGS := -traditional
+
+ obj-$(CONFIG_SCx200) += scx200.o
+
++ifdef CONFIG_XEN
++vsyscall_note := vsyscall-note-xen.o
++else
++vsyscall_note := vsyscall-note.o
++endif
++
+ # vsyscall.o contains the vsyscall DSO images as __initdata.
+ # We must build both images before we can assemble it.
+ # Note: kbuild does not track this dependency due to usage of .incbin
+@@ -68,7 +74,7 @@ SYSCFLAGS_vsyscall-int80.so = $(vsyscall
+
+ $(obj)/vsyscall-int80.so $(obj)/vsyscall-sysenter.so: \
+ $(obj)/vsyscall-%.so: $(src)/vsyscall.lds \
+- $(obj)/vsyscall-%.o $(obj)/vsyscall-note.o FORCE
++ $(obj)/vsyscall-%.o $(obj)/$(vsyscall_note) FORCE
+ $(call if_changed,syscall)
+
+ # We also create a special relocatable object that should mirror the symbol
+@@ -80,9 +86,21 @@ extra-y += vsyscall-syms.o
+
+ SYSCFLAGS_vsyscall-syms.o = -r
+ $(obj)/vsyscall-syms.o: $(src)/vsyscall.lds \
+- $(obj)/vsyscall-sysenter.o $(obj)/vsyscall-note.o FORCE
++ $(obj)/vsyscall-sysenter.o $(obj)/$(vsyscall_note) FORCE
+ $(call if_changed,syscall)
+
+ k8-y += ../../x86_64/kernel/k8.o
+ stacktrace-y += ../../x86_64/kernel/stacktrace.o
+
++ifdef CONFIG_XEN
++include $(srctree)/scripts/Makefile.xen
++
++obj-y += fixup.o
++microcode-$(subst m,y,$(CONFIG_MICROCODE)) := microcode-xen.o
++n-obj-xen := i8259.o timers/ reboot.o smpboot.o trampoline.o
++
++obj-y := $(call filterxen, $(obj-y), $(n-obj-xen))
++obj-y := $(call cherrypickxen, $(obj-y))
++extra-y := $(call cherrypickxen, $(extra-y))
++%/head-xen.o %/head-xen.s: EXTRA_AFLAGS :=
++endif
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 arch/i386/kernel/acpi/Makefile
+--- a/arch/i386/kernel/acpi/Makefile Wed Jul 18 12:23:24 2007 -0300
++++ b/arch/i386/kernel/acpi/Makefile Wed Aug 08 16:25:28 2007 -0300
+@@ -7,4 +7,3 @@ ifneq ($(CONFIG_ACPI_PROCESSOR),)
+ ifneq ($(CONFIG_ACPI_PROCESSOR),)
+ obj-y += cstate.o processor.o
+ endif
+-
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 arch/i386/kernel/acpi/boot.c
+--- a/arch/i386/kernel/acpi/boot.c Wed Jul 18 12:23:24 2007 -0300
++++ b/arch/i386/kernel/acpi/boot.c Wed Aug 08 16:25:28 2007 -0300
@@ -107,7 +107,7 @@ EXPORT_SYMBOL(x86_acpiid_to_apicid);
*/
enum acpi_irq_model_id acpi_irq_model = ACPI_IRQ_MODEL_PIC;
@@ -358,19 +466,21 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
offset = phys & (PAGE_SIZE - 1);
mapped_size = PAGE_SIZE - offset;
-@@ -611,7 +613,11 @@ acpi_scan_rsdp(unsigned long start, unsi
+@@ -611,7 +613,13 @@ acpi_scan_rsdp(unsigned long start, unsi
* RSDP signature.
*/
for (offset = 0; offset < length; offset += 16) {
+#ifdef CONFIG_XEN
-+ if (strncmp((char *)((unsigned long)isa_bus_to_virt(start) + offset), "RSD PTR ", sig_len))
++ unsigned long vstart = (unsigned long)isa_bus_to_virt(start);
++
++ if (strncmp((char *)(vstart + offset), "RSD PTR ", sig_len))
+#else
if (strncmp((char *)(phys_to_virt(start) + offset), "RSD PTR ", sig_len))
+#endif
continue;
return (start + offset);
}
-@@ -724,7 +730,7 @@ static int __init acpi_parse_fadt(unsign
+@@ -724,7 +732,7 @@ static int __init acpi_parse_fadt(unsign
acpi_fadt.force_apic_physical_destination_mode =
fadt->force_apic_physical_destination_mode;
@@ -379,60 +489,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
/* detect the location of the ACPI PM Timer */
if (fadt->revision >= FADT2_REVISION_ID) {
/* FADT rev. 2 */
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/arch/i386/kernel/acpi/Makefile source/arch/i386/kernel/acpi/Makefile
---- /scratch/src/linux-2.6.20.3/arch/i386/kernel/acpi/Makefile 2007-02-04 19:44:54.000000000 +0100
-+++ source/arch/i386/kernel/acpi/Makefile 2007-03-20 21:26:26.000000000 +0100
-@@ -8,3 +8,7 @@ ifneq ($(CONFIG_ACPI_PROCESSOR),)
- obj-y += cstate.o processor.o
- endif
-
-+ifdef CONFIG_XEN
-+include $(srctree)/scripts/Makefile.xen
-+obj-y := $(call cherrypickxen, $(obj-y), $(src))
-+endif
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/arch/i386/kernel/alternative.c source/arch/i386/kernel/alternative.c
---- /scratch/src/linux-2.6.20.3/arch/i386/kernel/alternative.c 2007-02-04 19:44:54.000000000 +0100
-+++ source/arch/i386/kernel/alternative.c 2007-03-21 14:49:46.000000000 +0100
-@@ -5,7 +5,11 @@
- #include <asm/alternative.h>
- #include <asm/sections.h>
-
-+#ifdef CONFIG_X86_64_XEN
-+static int no_replacement = 1;
-+#else
- static int no_replacement = 0;
-+#endif
- static int smp_alt_once = 0;
- static int debug_alternative = 0;
-
-@@ -165,7 +169,11 @@ void apply_alternatives(struct alt_instr
- #ifdef CONFIG_X86_64
- /* vsyscall code is not mapped yet. resolve it manually. */
- if (instr >= (u8 *)VSYSCALL_START && instr < (u8*)VSYSCALL_END) {
-+#ifdef CONFIG_XEN
-+ instr = __va(instr - (u8*)VSYSCALL_START + (u8*)phys_to_machine(__pa_symbol(&__vsyscall_0)));
-+#else
- instr = __va(instr - (u8*)VSYSCALL_START + (u8*)__pa_symbol(&__vsyscall_0));
-+#endif
- DPRINTK("%s: vsyscall fixup: %p => %p\n",
- __FUNCTION__, a->instr, instr);
- }
-@@ -388,9 +396,12 @@ void __init alternative_instructions(voi
- unsigned long flags;
- if (no_replacement) {
- printk(KERN_INFO "(SMP-)alternatives turned off\n");
-+#ifndef CONFIG_X86_64_XEN
-+/* ToDo: x86_64 put something strange there, not sure what yet */
- free_init_pages("SMP alternatives",
- (unsigned long)__smp_alt_begin,
- (unsigned long)__smp_alt_end);
-+#endif
- return;
- }
-
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/arch/i386/kernel/apic-xen.c source/arch/i386/kernel/apic-xen.c
---- /scratch/src/linux-2.6.20.3/arch/i386/kernel/apic-xen.c 1970-01-01 01:00:00.000000000 +0100
-+++ source/arch/i386/kernel/apic-xen.c 2007-03-20 21:26:26.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 arch/i386/kernel/apic-xen.c
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/arch/i386/kernel/apic-xen.c Wed Aug 08 16:25:28 2007 -0300
@@ -0,0 +1,223 @@
+/*
+ * Local APIC handling, local APIC timers
@@ -657,9 +716,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+}
+early_param("nolapic", parse_nolapic);
+
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/arch/i386/kernel/asm-offsets.c source/arch/i386/kernel/asm-offsets.c
---- /scratch/src/linux-2.6.20.3/arch/i386/kernel/asm-offsets.c 2007-02-04 19:44:54.000000000 +0100
-+++ source/arch/i386/kernel/asm-offsets.c 2007-03-20 21:26:26.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 arch/i386/kernel/asm-offsets.c
+--- a/arch/i386/kernel/asm-offsets.c Wed Jul 18 12:23:24 2007 -0300
++++ b/arch/i386/kernel/asm-offsets.c Wed Aug 08 16:25:28 2007 -0300
@@ -89,9 +89,14 @@ void foo(void)
OFFSET(pbe_orig_address, pbe, orig_address);
OFFSET(pbe_next, pbe, next);
@@ -687,614 +746,24 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ OFFSET(XEN_START_mfn_list, start_info, mfn_list);
+#endif
}
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/arch/i386/kernel/cpu/common-xen.c source/arch/i386/kernel/cpu/common-xen.c
---- /scratch/src/linux-2.6.20.3/arch/i386/kernel/cpu/common-xen.c 1970-01-01 01:00:00.000000000 +0100
-+++ source/arch/i386/kernel/cpu/common-xen.c 2007-03-20 21:26:26.000000000 +0100
-@@ -0,0 +1,868 @@
-+#include <linux/init.h>
-+#include <linux/string.h>
-+#include <linux/delay.h>
-+#include <linux/smp.h>
-+#include <linux/module.h>
-+#include <linux/percpu.h>
-+#include <linux/bootmem.h>
-+#include <asm/semaphore.h>
-+#include <asm/processor.h>
-+#include <asm/i387.h>
-+#include <asm/msr.h>
-+#include <asm/io.h>
-+#include <asm/mmu_context.h>
-+#include <asm/mtrr.h>
-+#include <asm/mce.h>
-+#ifdef CONFIG_X86_LOCAL_APIC
-+#include <asm/mpspec.h>
-+#include <asm/apic.h>
-+#include <mach_apic.h>
-+#endif
-+#include <asm/pda.h>
-+#include <asm/hypervisor.h>
-+
-+#include "cpu.h"
-+
-+DEFINE_PER_CPU(struct Xgt_desc_struct, cpu_gdt_descr);
-+EXPORT_PER_CPU_SYMBOL(cpu_gdt_descr);
-+
-+struct i386_pda *_cpu_pda[NR_CPUS] __read_mostly;
-+EXPORT_SYMBOL(_cpu_pda);
-+
-+static int cachesize_override __cpuinitdata = -1;
-+static int disable_x86_fxsr __cpuinitdata;
-+static int disable_x86_serial_nr __cpuinitdata = 1;
-+static int disable_x86_sep __cpuinitdata;
-+
-+struct cpu_dev * cpu_devs[X86_VENDOR_NUM] = {};
-+
-+extern int disable_pse;
-+
-+static void __cpuinit default_init(struct cpuinfo_x86 * c)
-+{
-+ /* Not much we can do here... */
-+ /* Check if at least it has cpuid */
-+ if (c->cpuid_level == -1) {
-+ /* No cpuid. It must be an ancient CPU */
-+ if (c->x86 == 4)
-+ strcpy(c->x86_model_id, "486");
-+ else if (c->x86 == 3)
-+ strcpy(c->x86_model_id, "386");
-+ }
-+}
-+
-+static struct cpu_dev __cpuinitdata default_cpu = {
-+ .c_init = default_init,
-+ .c_vendor = "Unknown",
-+};
-+static struct cpu_dev * this_cpu __cpuinitdata = &default_cpu;
-+
-+static int __init cachesize_setup(char *str)
-+{
-+ get_option (&str, &cachesize_override);
-+ return 1;
-+}
-+__setup("cachesize=", cachesize_setup);
-+
-+int __cpuinit get_model_name(struct cpuinfo_x86 *c)
-+{
-+ unsigned int *v;
-+ char *p, *q;
-+
-+ if (cpuid_eax(0x80000000) < 0x80000004)
-+ return 0;
-+
-+ v = (unsigned int *) c->x86_model_id;
-+ cpuid(0x80000002, &v[0], &v[1], &v[2], &v[3]);
-+ cpuid(0x80000003, &v[4], &v[5], &v[6], &v[7]);
-+ cpuid(0x80000004, &v[8], &v[9], &v[10], &v[11]);
-+ c->x86_model_id[48] = 0;
-+
-+ /* Intel chips right-justify this string for some dumb reason;
-+ undo that brain damage */
-+ p = q = &c->x86_model_id[0];
-+ while ( *p == ' ' )
-+ p++;
-+ if ( p != q ) {
-+ while ( *p )
-+ *q++ = *p++;
-+ while ( q <= &c->x86_model_id[48] )
-+ *q++ = '\0'; /* Zero-pad the rest */
-+ }
-+
-+ return 1;
-+}
-+
-+
-+void __cpuinit display_cacheinfo(struct cpuinfo_x86 *c)
-+{
-+ unsigned int n, dummy, ecx, edx, l2size;
-+
-+ n = cpuid_eax(0x80000000);
-+
-+ if (n >= 0x80000005) {
-+ cpuid(0x80000005, &dummy, &dummy, &ecx, &edx);
-+ printk(KERN_INFO "CPU: L1 I Cache: %dK (%d bytes/line), D cache %dK (%d bytes/line)\n",
-+ edx>>24, edx&0xFF, ecx>>24, ecx&0xFF);
-+ c->x86_cache_size=(ecx>>24)+(edx>>24);
-+ }
-+
-+ if (n < 0x80000006) /* Some chips just has a large L1. */
-+ return;
-+
-+ ecx = cpuid_ecx(0x80000006);
-+ l2size = ecx >> 16;
-+
-+ /* do processor-specific cache resizing */
-+ if (this_cpu->c_size_cache)
-+ l2size = this_cpu->c_size_cache(c,l2size);
-+
-+ /* Allow user to override all this if necessary. */
-+ if (cachesize_override != -1)
-+ l2size = cachesize_override;
-+
-+ if ( l2size == 0 )
-+ return; /* Again, no L2 cache is possible */
-+
-+ c->x86_cache_size = l2size;
-+
-+ printk(KERN_INFO "CPU: L2 Cache: %dK (%d bytes/line)\n",
-+ l2size, ecx & 0xFF);
-+}
-+
-+/* Naming convention should be: <Name> [(<Codename>)] */
-+/* This table only is used unless init_<vendor>() below doesn't set it; */
-+/* in particular, if CPUID levels 0x80000002..4 are supported, this isn't used */
-+
-+/* Look up CPU names by table lookup. */
-+static char __cpuinit *table_lookup_model(struct cpuinfo_x86 *c)
-+{
-+ struct cpu_model_info *info;
-+
-+ if ( c->x86_model >= 16 )
-+ return NULL; /* Range check */
-+
-+ if (!this_cpu)
-+ return NULL;
-+
-+ info = this_cpu->c_models;
-+
-+ while (info && info->family) {
-+ if (info->family == c->x86)
-+ return info->model_names[c->x86_model];
-+ info++;
-+ }
-+ return NULL; /* Not found */
-+}
-+
-+
-+static void __cpuinit get_cpu_vendor(struct cpuinfo_x86 *c, int early)
-+{
-+ char *v = c->x86_vendor_id;
-+ int i;
-+ static int printed;
-+
-+ for (i = 0; i < X86_VENDOR_NUM; i++) {
-+ if (cpu_devs[i]) {
-+ if (!strcmp(v,cpu_devs[i]->c_ident[0]) ||
-+ (cpu_devs[i]->c_ident[1] &&
-+ !strcmp(v,cpu_devs[i]->c_ident[1]))) {
-+ c->x86_vendor = i;
-+ if (!early)
-+ this_cpu = cpu_devs[i];
-+ return;
-+ }
-+ }
-+ }
-+ if (!printed) {
-+ printed++;
-+ printk(KERN_ERR "CPU: Vendor unknown, using generic init.\n");
-+ printk(KERN_ERR "CPU: Your system may be unstable.\n");
-+ }
-+ c->x86_vendor = X86_VENDOR_UNKNOWN;
-+ this_cpu = &default_cpu;
-+}
-+
-+
-+static int __init x86_fxsr_setup(char * s)
-+{
-+ /* Tell all the other CPU's to not use it... */
-+ disable_x86_fxsr = 1;
-+
-+ /*
-+ * ... and clear the bits early in the boot_cpu_data
-+ * so that the bootup process doesn't try to do this
-+ * either.
-+ */
-+ clear_bit(X86_FEATURE_FXSR, boot_cpu_data.x86_capability);
-+ clear_bit(X86_FEATURE_XMM, boot_cpu_data.x86_capability);
-+ return 1;
-+}
-+__setup("nofxsr", x86_fxsr_setup);
-+
-+
-+static int __init x86_sep_setup(char * s)
-+{
-+ disable_x86_sep = 1;
-+ return 1;
-+}
-+__setup("nosep", x86_sep_setup);
-+
-+
-+/* Standard macro to see if a specific flag is changeable */
-+static inline int flag_is_changeable_p(u32 flag)
-+{
-+ u32 f1, f2;
-+
-+ asm("pushfl\n\t"
-+ "pushfl\n\t"
-+ "popl %0\n\t"
-+ "movl %0,%1\n\t"
-+ "xorl %2,%0\n\t"
-+ "pushl %0\n\t"
-+ "popfl\n\t"
-+ "pushfl\n\t"
-+ "popl %0\n\t"
-+ "popfl\n\t"
-+ : "=&r" (f1), "=&r" (f2)
-+ : "ir" (flag));
-+
-+ return ((f1^f2) & flag) != 0;
-+}
-+
-+
-+/* Probe for the CPUID instruction */
-+static int __cpuinit have_cpuid_p(void)
-+{
-+ return flag_is_changeable_p(X86_EFLAGS_ID);
-+}
-+
-+void __init cpu_detect(struct cpuinfo_x86 *c)
-+{
-+ /* Get vendor name */
-+ cpuid(0x00000000, &c->cpuid_level,
-+ (int *)&c->x86_vendor_id[0],
-+ (int *)&c->x86_vendor_id[8],
-+ (int *)&c->x86_vendor_id[4]);
-+
-+ c->x86 = 4;
-+ if (c->cpuid_level >= 0x00000001) {
-+ u32 junk, tfms, cap0, misc;
-+ cpuid(0x00000001, &tfms, &misc, &junk, &cap0);
-+ c->x86 = (tfms >> 8) & 15;
-+ c->x86_model = (tfms >> 4) & 15;
-+ 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;
-+ if (cap0 & (1<<19))
-+ c->x86_cache_alignment = ((misc >> 8) & 0xff) * 8;
-+ }
-+}
-+
-+/* Do minimum CPU detection early.
-+ Fields really needed: vendor, cpuid_level, family, model, mask, cache alignment.
-+ The others are not touched to avoid unwanted side effects.
-+
-+ WARNING: this function is only called on the BP. Don't add code here
-+ that is supposed to run on all CPUs. */
-+static void __init early_cpu_detect(void)
-+{
-+ struct cpuinfo_x86 *c = &boot_cpu_data;
-+
-+ c->x86_cache_alignment = 32;
-+
-+ if (!have_cpuid_p())
-+ return;
-+
-+ cpu_detect(c);
-+
-+ get_cpu_vendor(c, 1);
-+}
-+
-+static void __cpuinit generic_identify(struct cpuinfo_x86 * c)
-+{
-+ u32 tfms, xlvl;
-+ int ebx;
-+
-+ if (have_cpuid_p()) {
-+ /* Get vendor name */
-+ cpuid(0x00000000, &c->cpuid_level,
-+ (int *)&c->x86_vendor_id[0],
-+ (int *)&c->x86_vendor_id[8],
-+ (int *)&c->x86_vendor_id[4]);
-+
-+ get_cpu_vendor(c, 0);
-+ /* Initialize the standard set of capabilities */
-+ /* Note that the vendor-specific code below might override */
-+
-+ /* Intel-defined flags: level 0x00000001 */
-+ if ( c->cpuid_level >= 0x00000001 ) {
-+ u32 capability, excap;
-+ cpuid(0x00000001, &tfms, &ebx, &excap, &capability);
-+ c->x86_capability[0] = capability;
-+ c->x86_capability[4] = excap;
-+ c->x86 = (tfms >> 8) & 15;
-+ c->x86_model = (tfms >> 4) & 15;
-+ 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;
-+#ifdef CONFIG_X86_HT
-+ c->apicid = phys_pkg_id((ebx >> 24) & 0xFF, 0);
-+#else
-+ c->apicid = (ebx >> 24) & 0xFF;
-+#endif
-+ if (c->x86_capability[0] & (1<<19))
-+ c->x86_clflush_size = ((ebx >> 8) & 0xff) * 8;
-+ } else {
-+ /* Have CPUID level 0 only - unheard of */
-+ c->x86 = 4;
-+ }
-+
-+ /* AMD-defined flags: level 0x80000001 */
-+ xlvl = cpuid_eax(0x80000000);
-+ if ( (xlvl & 0xffff0000) == 0x80000000 ) {
-+ if ( xlvl >= 0x80000001 ) {
-+ c->x86_capability[1] = cpuid_edx(0x80000001);
-+ c->x86_capability[6] = cpuid_ecx(0x80000001);
-+ }
-+ if ( xlvl >= 0x80000004 )
-+ get_model_name(c); /* Default name */
-+ }
-+ }
-+
-+ early_intel_workaround(c);
-+
-+#ifdef CONFIG_X86_HT
-+ c->phys_proc_id = (cpuid_ebx(1) >> 24) & 0xff;
-+#endif
-+}
-+
-+static void __cpuinit squash_the_stupid_serial_number(struct cpuinfo_x86 *c)
-+{
-+ if (cpu_has(c, X86_FEATURE_PN) && disable_x86_serial_nr ) {
-+ /* Disable processor serial number */
-+ unsigned long lo,hi;
-+ rdmsr(MSR_IA32_BBL_CR_CTL,lo,hi);
-+ lo |= 0x200000;
-+ wrmsr(MSR_IA32_BBL_CR_CTL,lo,hi);
-+ printk(KERN_NOTICE "CPU serial number disabled.\n");
-+ clear_bit(X86_FEATURE_PN, c->x86_capability);
-+
-+ /* Disabling the serial number may affect the cpuid level */
-+ c->cpuid_level = cpuid_eax(0);
-+ }
-+}
-+
-+static int __init x86_serial_nr_setup(char *s)
-+{
-+ disable_x86_serial_nr = 0;
-+ return 1;
-+}
-+__setup("serialnumber", x86_serial_nr_setup);
-+
-+
-+
-+/*
-+ * This does the hard work of actually picking apart the CPU stuff...
-+ */
-+void __cpuinit identify_cpu(struct cpuinfo_x86 *c)
-+{
-+ int i;
-+
-+ c->loops_per_jiffy = loops_per_jiffy;
-+ c->x86_cache_size = -1;
-+ c->x86_vendor = X86_VENDOR_UNKNOWN;
-+ c->cpuid_level = -1; /* CPUID not detected */
-+ c->x86_model = c->x86_mask = 0; /* So far unknown... */
-+ c->x86_vendor_id[0] = '\0'; /* Unset */
-+ c->x86_model_id[0] = '\0'; /* Unset */
-+ c->x86_max_cores = 1;
-+ c->x86_clflush_size = 32;
-+ memset(&c->x86_capability, 0, sizeof c->x86_capability);
-+
-+ if (!have_cpuid_p()) {
-+ /* First of all, decide if this is a 486 or higher */
-+ /* It's a 486 if we can modify the AC flag */
-+ if ( flag_is_changeable_p(X86_EFLAGS_AC) )
-+ c->x86 = 4;
-+ else
-+ c->x86 = 3;
-+ }
-+
-+ generic_identify(c);
-+
-+ printk(KERN_DEBUG "CPU: After generic identify, caps:");
-+ for (i = 0; i < NCAPINTS; i++)
-+ printk(" %08lx", c->x86_capability[i]);
-+ printk("\n");
-+
-+ if (this_cpu->c_identify) {
-+ this_cpu->c_identify(c);
-+
-+ printk(KERN_DEBUG "CPU: After vendor identify, caps:");
-+ for (i = 0; i < NCAPINTS; i++)
-+ printk(" %08lx", c->x86_capability[i]);
-+ printk("\n");
-+ }
-+
-+ /*
-+ * Vendor-specific initialization. In this section we
-+ * canonicalize the feature flags, meaning if there are
-+ * features a certain CPU supports which CPUID doesn't
-+ * tell us, CPUID claiming incorrect flags, or other bugs,
-+ * we handle them here.
-+ *
-+ * At the end of this section, c->x86_capability better
-+ * indicate the features this CPU genuinely supports!
-+ */
-+ if (this_cpu->c_init)
-+ this_cpu->c_init(c);
-+
-+ /* Disable the PN if appropriate */
-+ squash_the_stupid_serial_number(c);
-+
-+ /*
-+ * The vendor-specific functions might have changed features. Now
-+ * we do "generic changes."
-+ */
-+
-+ /* TSC disabled? */
-+ if ( tsc_disable )
-+ clear_bit(X86_FEATURE_TSC, c->x86_capability);
-+
-+ /* FXSR disabled? */
-+ if (disable_x86_fxsr) {
-+ clear_bit(X86_FEATURE_FXSR, c->x86_capability);
-+ clear_bit(X86_FEATURE_XMM, c->x86_capability);
-+ }
-+
-+ /* SEP disabled? */
-+ if (disable_x86_sep)
-+ clear_bit(X86_FEATURE_SEP, c->x86_capability);
-+
-+ if (disable_pse)
-+ clear_bit(X86_FEATURE_PSE, c->x86_capability);
-+
-+ /* If the model name is still unset, do table lookup. */
-+ if ( !c->x86_model_id[0] ) {
-+ char *p;
-+ p = table_lookup_model(c);
-+ if ( p )
-+ strcpy(c->x86_model_id, p);
-+ else
-+ /* Last resort... */
-+ sprintf(c->x86_model_id, "%02x/%02x",
-+ c->x86, c->x86_model);
-+ }
-+
-+ /* Now the feature flags better reflect actual CPU features! */
-+
-+ printk(KERN_DEBUG "CPU: After all inits, caps:");
-+ for (i = 0; i < NCAPINTS; i++)
-+ printk(" %08lx", c->x86_capability[i]);
-+ printk("\n");
-+
-+ /*
-+ * On SMP, boot_cpu_data holds the common feature set between
-+ * all CPUs; so make sure that we indicate which features are
-+ * common between the CPUs. The first time this routine gets
-+ * executed, c == &boot_cpu_data.
-+ */
-+ if ( c != &boot_cpu_data ) {
-+ /* AND the already accumulated flags with these */
-+ for ( i = 0 ; i < NCAPINTS ; i++ )
-+ boot_cpu_data.x86_capability[i] &= c->x86_capability[i];
-+ }
-+
-+ /* Init Machine Check Exception if available. */
-+ mcheck_init(c);
-+
-+ if (c == &boot_cpu_data)
-+ sysenter_setup();
-+ enable_sep_cpu();
-+
-+ if (c == &boot_cpu_data)
-+ mtrr_bp_init();
-+ else
-+ mtrr_ap_init();
-+}
-+
-+#ifdef CONFIG_X86_HT
-+void __cpuinit detect_ht(struct cpuinfo_x86 *c)
-+{
-+ u32 eax, ebx, ecx, edx;
-+ int index_msb, core_bits;
-+
-+ cpuid(1, &eax, &ebx, &ecx, &edx);
-+
-+ if (!cpu_has(c, X86_FEATURE_HT) || cpu_has(c, X86_FEATURE_CMP_LEGACY))
-+ return;
-+
-+ smp_num_siblings = (ebx & 0xff0000) >> 16;
-+
-+ if (smp_num_siblings == 1) {
-+ printk(KERN_INFO "CPU: Hyper-Threading is disabled\n");
-+ } else if (smp_num_siblings > 1 ) {
-+
-+ if (smp_num_siblings > NR_CPUS) {
-+ printk(KERN_WARNING "CPU: Unsupported number of the "
-+ "siblings %d", smp_num_siblings);
-+ smp_num_siblings = 1;
-+ return;
-+ }
-+
-+ index_msb = get_count_order(smp_num_siblings);
-+ c->phys_proc_id = phys_pkg_id((ebx >> 24) & 0xFF, index_msb);
-+
-+ printk(KERN_INFO "CPU: Physical Processor ID: %d\n",
-+ c->phys_proc_id);
-+
-+ smp_num_siblings = smp_num_siblings / c->x86_max_cores;
-+
-+ index_msb = get_count_order(smp_num_siblings) ;
-+
-+ core_bits = get_count_order(c->x86_max_cores);
-+
-+ c->cpu_core_id = phys_pkg_id((ebx >> 24) & 0xFF, index_msb) &
-+ ((1 << core_bits) - 1);
-+
-+ if (c->x86_max_cores > 1)
-+ printk(KERN_INFO "CPU: Processor Core ID: %d\n",
-+ c->cpu_core_id);
-+ }
-+}
-+#endif
-+
-+void __cpuinit print_cpu_info(struct cpuinfo_x86 *c)
-+{
-+ char *vendor = NULL;
-+
-+ if (c->x86_vendor < X86_VENDOR_NUM)
-+ vendor = this_cpu->c_vendor;
-+ else if (c->cpuid_level >= 0)
-+ vendor = c->x86_vendor_id;
-+
-+ if (vendor && strncmp(c->x86_model_id, vendor, strlen(vendor)))
-+ printk("%s ", vendor);
-+
-+ if (!c->x86_model_id[0])
-+ printk("%d86", c->x86);
-+ else
-+ printk("%s", c->x86_model_id);
-+
-+ if (c->x86_mask || c->cpuid_level >= 0)
-+ printk(" stepping %02x\n", c->x86_mask);
-+ else
-+ printk("\n");
-+}
-+
-+cpumask_t cpu_initialized __cpuinitdata = CPU_MASK_NONE;
-+
-+/* This is hacky. :)
-+ * We're emulating future behavior.
-+ * In the future, the cpu-specific init functions will be called implicitly
-+ * via the magic of initcalls.
-+ * They will insert themselves into the cpu_devs structure.
-+ * Then, when cpu_init() is called, we can just iterate over that array.
-+ */
-+
-+extern int intel_cpu_init(void);
-+extern int cyrix_init_cpu(void);
-+extern int nsc_init_cpu(void);
-+extern int amd_init_cpu(void);
-+extern int centaur_init_cpu(void);
-+extern int transmeta_init_cpu(void);
-+extern int rise_init_cpu(void);
-+extern int nexgen_init_cpu(void);
-+extern int umc_init_cpu(void);
-+
-+void __init early_cpu_init(void)
-+{
-+ intel_cpu_init();
-+ cyrix_init_cpu();
-+ nsc_init_cpu();
-+ amd_init_cpu();
-+ centaur_init_cpu();
-+ transmeta_init_cpu();
-+ rise_init_cpu();
-+ nexgen_init_cpu();
-+ umc_init_cpu();
-+ early_cpu_detect();
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 arch/i386/kernel/cpu/common.c
+--- a/arch/i386/kernel/cpu/common.c Wed Jul 18 12:23:24 2007 -0300
++++ b/arch/i386/kernel/cpu/common.c Wed Aug 08 16:25:28 2007 -0300
+@@ -19,6 +19,10 @@
+ #include <mach_apic.h>
+ #endif
+ #include <asm/pda.h>
+
-+#ifdef CONFIG_DEBUG_PAGEALLOC
-+ /* pse is not compatible with on-the-fly unmapping,
-+ * disable it even if the cpus claim to support it.
-+ */
-+ clear_bit(X86_FEATURE_PSE, boot_cpu_data.x86_capability);
-+ disable_pse = 1;
++#ifdef CONFIG_XEN
++#include <asm/hypervisor.h>
+#endif
-+}
-+
+
+ #include "cpu.h"
+
+@@ -601,6 +605,31 @@ void __init early_cpu_init(void)
+ #endif
+ }
+
+/* We can't move load_gdt to asm/desc.h because it lacks make_lowmen_page_readonly()
+ definition, and as this is still the only user of load_gdt in xen.
+ ToDo: JQ
@@ -1320,261 +789,90 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+}
+#endif /* CONFIG_XEN */
+
-+/* Make sure %gs is initialized properly in idle threads */
-+struct pt_regs * __devinit idle_regs(struct pt_regs *regs)
-+{
-+ memset(regs, 0, sizeof(struct pt_regs));
-+ regs->xgs = __KERNEL_PDA;
-+ return regs;
-+}
-+
-+static __cpuinit int alloc_gdt(int cpu)
-+{
-+ struct Xgt_desc_struct *cpu_gdt_descr = &per_cpu(cpu_gdt_descr, cpu);
-+ struct desc_struct *gdt;
-+ struct i386_pda *pda;
-+
-+ gdt = (struct desc_struct *)cpu_gdt_descr->address;
-+ pda = cpu_pda(cpu);
-+
-+ /*
-+ * This is a horrible hack to allocate the GDT. The problem
-+ * is that cpu_init() is called really early for the boot CPU
-+ * (and hence needs bootmem) but much later for the secondary
-+ * CPUs, when bootmem will have gone away
-+ */
-+ if (NODE_DATA(0)->bdata->node_bootmem_map) {
-+ BUG_ON(gdt != NULL || pda != NULL);
-+
-+ gdt = alloc_bootmem_pages(PAGE_SIZE);
-+ pda = alloc_bootmem(sizeof(*pda));
-+ /* alloc_bootmem(_pages) panics on failure, so no check */
-+
-+ memset(gdt, 0, PAGE_SIZE);
-+ memset(pda, 0, sizeof(*pda));
+ /* Make sure %gs is initialized properly in idle threads */
+ struct pt_regs * __devinit idle_regs(struct pt_regs *regs)
+ {
+@@ -633,6 +662,10 @@ static __cpuinit int alloc_gdt(int cpu)
+
+ memset(gdt, 0, PAGE_SIZE);
+ memset(pda, 0, sizeof(*pda));
+#ifdef CONFIG_XEN
+ memcpy(gdt, cpu_gdt_table, GDT_SIZE);
+ cpu_gdt_descr->size = GDT_SIZE;
+#endif
-+ } else {
-+ /* GDT and PDA might already have been allocated if
-+ this is a CPU hotplug re-insertion. */
-+ if (gdt == NULL)
-+ gdt = (struct desc_struct *)get_zeroed_page(GFP_KERNEL);
-+
-+ if (pda == NULL)
-+ pda = kmalloc_node(sizeof(*pda), GFP_KERNEL, cpu_to_node(cpu));
-+
-+ if (unlikely(!gdt || !pda)) {
-+ free_pages((unsigned long)gdt, 0);
-+ kfree(pda);
-+ return 0;
-+ }
-+ }
-+
-+ cpu_gdt_descr->address = (unsigned long)gdt;
-+ cpu_pda(cpu) = pda;
-+
-+ return 1;
-+}
-+
-+/* Initial PDA used by boot CPU */
-+struct i386_pda boot_pda = {
-+ ._pda = &boot_pda,
-+ .cpu_number = 0,
-+ .pcurrent = &init_task,
-+};
-+
-+static inline void set_kernel_gs(void)
-+{
-+ /* Set %gs for this CPU's PDA. Memory clobber is to create a
-+ barrier with respect to any PDA operations, so the compiler
-+ doesn't move any before here. */
-+ asm volatile ("mov %0, %%gs" : : "r" (__KERNEL_PDA) : "memory");
-+}
-+
-+/* Initialize the CPU's GDT and PDA. The boot CPU does this for
-+ itself, but secondaries find this done for them. */
-+__cpuinit int init_gdt(int cpu, struct task_struct *idle)
-+{
-+ struct Xgt_desc_struct *cpu_gdt_descr = &per_cpu(cpu_gdt_descr, cpu);
-+ struct desc_struct *gdt;
-+ struct i386_pda *pda;
-+
-+ /* For non-boot CPUs, the GDT and PDA should already have been
-+ allocated. */
-+ if (!alloc_gdt(cpu)) {
-+ printk(KERN_CRIT "CPU%d failed to allocate GDT or PDA\n", cpu);
-+ return 0;
-+ }
-+
-+ gdt = (struct desc_struct *)cpu_gdt_descr->address;
-+ pda = cpu_pda(cpu);
-+
-+ BUG_ON(gdt == NULL || pda == NULL);
-+
+ } else {
+ /* GDT and PDA might already have been allocated if
+ this is a CPU hotplug re-insertion. */
+@@ -690,14 +723,18 @@ __cpuinit int init_gdt(int cpu, struct t
+
+ BUG_ON(gdt == NULL || pda == NULL);
+
+#ifndef CONFIG_XEN
-+ /*
-+ * Initialize the per-CPU GDT with the boot GDT,
-+ * and set up the GDT descriptor:
-+ */
-+ memcpy(gdt, cpu_gdt_table, GDT_SIZE);
-+ cpu_gdt_descr->size = GDT_SIZE - 1;
+ /*
+ * Initialize the per-CPU GDT with the boot GDT,
+ * and set up the GDT descriptor:
+ */
+ memcpy(gdt, cpu_gdt_table, GDT_SIZE);
+ cpu_gdt_descr->size = GDT_SIZE - 1;
+-
+- pack_descriptor((u32 *)&gdt[GDT_ENTRY_PDA].a,
+#endif
+
+
+ if (cpu == 0)
+ pack_descriptor((u32 *)&gdt[GDT_ENTRY_PDA].a,
-+ (u32 *)&gdt[GDT_ENTRY_PDA].b,
-+ (unsigned long)pda, sizeof(*pda) - 1,
-+ 0x80 | DESCTYPE_S | 0x2, 0); /* present read-write data segment */
-+
-+ memset(pda, 0, sizeof(*pda));
-+ pda->_pda = pda;
-+ pda->cpu_number = cpu;
-+ pda->pcurrent = idle;
-+
-+ return 1;
-+}
-+
-+void __cpuinit cpu_set_gdt(int cpu)
-+{
-+ struct Xgt_desc_struct *cpu_gdt_descr = &per_cpu(cpu_gdt_descr, cpu);
-+
-+ /* Reinit these anyway, even if they've already been done (on
-+ the boot CPU, this will transition from the boot gdt+pda to
-+ the real ones). */
-+ load_gdt(cpu_gdt_descr);
-+ set_kernel_gs();
-+}
-+
-+/* Common CPU init for both boot and secondary CPUs */
-+static void __cpuinit _cpu_init(int cpu, struct task_struct *curr)
-+{
+ (u32 *)&gdt[GDT_ENTRY_PDA].b,
+ (unsigned long)pda, sizeof(*pda) - 1,
+ 0x80 | DESCTYPE_S | 0x2, 0); /* present read-write data segment */
+@@ -724,7 +761,9 @@ void __cpuinit cpu_set_gdt(int cpu)
+ /* Common CPU init for both boot and secondary CPUs */
+ static void __cpuinit _cpu_init(int cpu, struct task_struct *curr)
+ {
+#ifndef CONFIG_X86_NO_TSS
-+ struct tss_struct * t = &per_cpu(init_tss, cpu);
+ struct tss_struct * t = &per_cpu(init_tss, cpu);
+#endif
-+ struct thread_struct *thread = &curr->thread;
-+
-+ if (cpu_test_and_set(cpu, cpu_initialized)) {
-+ printk(KERN_WARNING "CPU#%d already initialized!\n", cpu);
-+ for (;;) local_irq_enable();
-+ }
-+
-+ printk(KERN_INFO "Initializing CPU#%d\n", cpu);
-+
-+ if (cpu_has_vme || cpu_has_tsc || cpu_has_de)
-+ clear_in_cr4(X86_CR4_VME|X86_CR4_PVI|X86_CR4_TSD|X86_CR4_DE);
-+ if (tsc_disable && cpu_has_tsc) {
-+ printk(KERN_NOTICE "Disabling TSC...\n");
-+ /**** FIX-HPA: DOES THIS REALLY BELONG HERE? ****/
-+ clear_bit(X86_FEATURE_TSC, boot_cpu_data.x86_capability);
-+ set_in_cr4(X86_CR4_TSD);
-+ }
-+
+ struct thread_struct *thread = &curr->thread;
+
+ if (cpu_test_and_set(cpu, cpu_initialized)) {
+@@ -743,7 +782,9 @@ static void __cpuinit _cpu_init(int cpu,
+ set_in_cr4(X86_CR4_TSD);
+ }
+
+#ifndef CONFIG_X86_NO_IDT
-+ load_idt(&idt_descr);
+ load_idt(&idt_descr);
+#endif
-+
-+ /*
-+ * Set up and load the per-CPU TSS and LDT
-+ */
-+ atomic_inc(&init_mm.mm_count);
-+ curr->active_mm = &init_mm;
-+ if (curr->mm)
-+ BUG();
-+ enter_lazy_tlb(&init_mm, curr);
-+
-+ load_esp0(t, thread);
+
+ /*
+ * Set up and load the per-CPU TSS and LDT
+@@ -755,8 +796,10 @@ static void __cpuinit _cpu_init(int cpu,
+ enter_lazy_tlb(&init_mm, curr);
+
+ load_esp0(t, thread);
+#ifndef CONFIG_X86_NO_TSS
-+ set_tss_desc(cpu,t);
-+ load_TR_desc();
+ set_tss_desc(cpu,t);
+ load_TR_desc();
+#endif
-+ load_LDT(&init_mm.context);
-+
-+#ifdef CONFIG_DOUBLEFAULT
-+ /* Set up doublefault TSS pointer in the GDT */
-+ __set_tss_desc(cpu, GDT_ENTRY_DOUBLEFAULT_TSS, &doublefault_tss);
-+#endif
-+
-+ /* Clear %fs. */
-+ asm volatile ("mov %0, %%fs" : : "r" (0));
-+
-+ /* Clear all 6 debug registers: */
-+ set_debugreg(0, 0);
-+ set_debugreg(0, 1);
-+ set_debugreg(0, 2);
-+ set_debugreg(0, 3);
-+ set_debugreg(0, 6);
-+ set_debugreg(0, 7);
-+
-+ /*
-+ * Force FPU initialization:
-+ */
-+ current_thread_info()->status = 0;
-+ clear_used_math();
-+ mxcsr_feature_mask_init();
-+}
-+
-+/* Entrypoint to initialize secondary CPU */
-+void __cpuinit secondary_cpu_init(void)
-+{
-+ int cpu = smp_processor_id();
-+ struct task_struct *curr = current;
-+
-+ _cpu_init(cpu, curr);
-+}
-+
-+/*
-+ * cpu_init() initializes state that is per-CPU. Some data is already
-+ * initialized (naturally) in the bootstrap process, such as the GDT
-+ * and IDT. We reload them nevertheless, this function acts as a
-+ * 'CPU state barrier', nothing should get across.
-+ */
-+void __cpuinit cpu_init(void)
-+{
-+ int cpu = smp_processor_id();
-+ struct task_struct *curr = current;
-+
-+ /* Set up the real GDT and PDA, so we can transition from the
-+ boot versions. */
-+ if (!init_gdt(cpu, curr)) {
-+ /* failed to allocate something; not much we can do... */
-+ for (;;)
-+ local_irq_enable();
-+ }
-+
-+ cpu_set_gdt(cpu);
-+ _cpu_init(cpu, curr);
-+}
-+
-+#ifdef CONFIG_HOTPLUG_CPU
-+void __cpuinit cpu_uninit(void)
-+{
-+ int cpu = raw_smp_processor_id();
-+ cpu_clear(cpu, cpu_initialized);
-+
-+ /* lazy TLB state */
-+ per_cpu(cpu_tlbstate, cpu).state = 0;
-+ per_cpu(cpu_tlbstate, cpu).active_mm = &init_mm;
-+}
-+#endif
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/arch/i386/kernel/cpu/Makefile source/arch/i386/kernel/cpu/Makefile
---- /scratch/src/linux-2.6.20.3/arch/i386/kernel/cpu/Makefile 2007-02-04 19:44:54.000000000 +0100
-+++ source/arch/i386/kernel/cpu/Makefile 2007-03-20 21:26:26.000000000 +0100
-@@ -17,3 +17,8 @@ obj-$(CONFIG_X86_MCE) += mcheck/
+ load_LDT(&init_mm.context);
+
+ #ifdef CONFIG_DOUBLEFAULT
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 arch/i386/kernel/cpu/mtrr/Makefile
+--- a/arch/i386/kernel/cpu/mtrr/Makefile Wed Jul 18 12:23:24 2007 -0300
++++ b/arch/i386/kernel/cpu/mtrr/Makefile Wed Aug 08 16:25:28 2007 -0300
+@@ -1,3 +1,10 @@ obj-y := main.o if.o generic.o state.o
+ obj-y := main.o if.o generic.o state.o
+ obj-$(CONFIG_X86_32) += amd.o cyrix.o centaur.o
- obj-$(CONFIG_MTRR) += mtrr/
- obj-$(CONFIG_CPU_FREQ) += cpufreq/
-+
+ifdef CONFIG_XEN
+include $(srctree)/scripts/Makefile.xen
-+obj-y := $(call cherrypickxen, $(obj-y), $(src))
++n-obj-xen := generic.o state.o amd.o cyrix.o centaur.o
++
++obj-y := $(call filterxen, $(obj-y), $(n-obj-xen))
++obj-y := $(call cherrypickxen, $(obj-y))
+endif
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/arch/i386/kernel/cpu/mtrr/main-xen.c source/arch/i386/kernel/cpu/mtrr/main-xen.c
---- /scratch/src/linux-2.6.20.3/arch/i386/kernel/cpu/mtrr/main-xen.c 1970-01-01 01:00:00.000000000 +0100
-+++ source/arch/i386/kernel/cpu/mtrr/main-xen.c 2007-03-20 21:26:26.000000000 +0100
-@@ -0,0 +1,197 @@
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 arch/i386/kernel/cpu/mtrr/main-xen.c
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/arch/i386/kernel/cpu/mtrr/main-xen.c Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,198 @@
+#include <linux/init.h>
+#include <linux/proc_fs.h>
+#include <linux/ctype.h>
@@ -1582,6 +880,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#include <linux/seq_file.h>
+#include <linux/mutex.h>
+#include <asm/uaccess.h>
++#include <linux/mutex.h>
+
+#include <asm/mtrr.h>
+#include "mtrr.h"
@@ -1591,11 +890,11 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+static void generic_get_mtrr(unsigned int reg, unsigned long *base,
+ unsigned long *size, mtrr_type * type)
+{
-+ dom0_op_t op;
++ struct xen_platform_op op;
+
-+ op.cmd = DOM0_READ_MEMTYPE;
++ op.cmd = XENPF_read_memtype;
+ op.u.read_memtype.reg = reg;
-+ (void)HYPERVISOR_dom0_op(&op);
++ (void)HYPERVISOR_platform_op(&op);
+
+ *size = op.u.read_memtype.nr_mfns;
+ *base = op.u.read_memtype.mfn;
@@ -1614,12 +913,12 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+/* This function returns the number of variable MTRRs */
+static void __init set_num_var_ranges(void)
+{
-+ dom0_op_t op;
++ struct xen_platform_op op;
+
+ for (num_var_ranges = 0; ; num_var_ranges++) {
-+ op.cmd = DOM0_READ_MEMTYPE;
++ op.cmd = XENPF_read_memtype;
+ op.u.read_memtype.reg = num_var_ranges;
-+ if (HYPERVISOR_dom0_op(&op) != 0)
++ if (HYPERVISOR_platform_op(&op) != 0)
+ break;
+ }
+}
@@ -1642,15 +941,15 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ unsigned int type, char increment)
+{
+ int error;
-+ dom0_op_t op;
++ struct xen_platform_op op;
+
+ mutex_lock(&mtrr_mutex);
+
-+ op.cmd = DOM0_ADD_MEMTYPE;
++ op.cmd = XENPF_add_memtype;
+ op.u.add_memtype.mfn = base;
+ op.u.add_memtype.nr_mfns = size;
+ op.u.add_memtype.type = type;
-+ error = HYPERVISOR_dom0_op(&op);
++ error = HYPERVISOR_platform_op(&op);
+ if (error) {
+ mutex_unlock(&mtrr_mutex);
+ BUG_ON(error > 0);
@@ -1694,7 +993,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ mtrr_type ltype;
+ unsigned long lbase, lsize;
+ int error = -EINVAL;
-+ dom0_op_t op;
++ struct xen_platform_op op;
+
+ mutex_lock(&mtrr_mutex);
+
@@ -1718,10 +1017,10 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ goto out;
+ }
+ if (--usage_table[reg] < 1) {
-+ op.cmd = DOM0_DEL_MEMTYPE;
++ op.cmd = XENPF_del_memtype;
+ op.u.del_memtype.handle = 0;
+ op.u.del_memtype.reg = reg;
-+ error = HYPERVISOR_dom0_op(&op);
++ error = HYPERVISOR_platform_op(&op);
+ if (error) {
+ BUG_ON(error > 0);
+ goto out;
@@ -1772,23 +1071,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+}
+
+subsys_initcall(mtrr_init);
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/arch/i386/kernel/cpu/mtrr/Makefile source/arch/i386/kernel/cpu/mtrr/Makefile
---- /scratch/src/linux-2.6.20.3/arch/i386/kernel/cpu/mtrr/Makefile 2007-02-04 19:44:54.000000000 +0100
-+++ source/arch/i386/kernel/cpu/mtrr/Makefile 2007-03-20 21:26:26.000000000 +0100
-@@ -1,3 +1,10 @@
- obj-y := main.o if.o generic.o state.o
- obj-$(CONFIG_X86_32) += amd.o cyrix.o centaur.o
-
-+ifdef CONFIG_XEN
-+include $(srctree)/scripts/Makefile.xen
-+n-obj-xen := generic.o state.o amd.o cyrix.o centaur.o
-+
-+obj-y := $(call filterxen, $(obj-y), $(n-obj-xen))
-+obj-y := $(call cherrypickxen, $(obj-y))
-+endif
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/arch/i386/kernel/crash.c source/arch/i386/kernel/crash.c
---- /scratch/src/linux-2.6.20.3/arch/i386/kernel/crash.c 2007-02-04 19:44:54.000000000 +0100
-+++ source/arch/i386/kernel/crash.c 2007-03-20 21:26:26.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 arch/i386/kernel/crash.c
+--- a/arch/i386/kernel/crash.c Wed Jul 18 12:23:24 2007 -0300
++++ b/arch/i386/kernel/crash.c Wed Aug 08 16:25:28 2007 -0300
@@ -31,6 +31,7 @@
/* This keeps a track of which one is crashing cpu. */
static int crashing_cpu;
@@ -1818,10 +1103,10 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#endif /* CONFIG_XEN */
crash_save_cpu(regs, safe_smp_processor_id());
}
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/arch/i386/kernel/e820.c source/arch/i386/kernel/e820.c
---- /scratch/src/linux-2.6.20.3/arch/i386/kernel/e820.c 2007-02-04 19:44:54.000000000 +0100
-+++ source/arch/i386/kernel/e820.c 2007-03-20 21:26:26.000000000 +0100
-@@ -15,11 +15,25 @@
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 arch/i386/kernel/e820.c
+--- a/arch/i386/kernel/e820.c Wed Jul 18 12:23:24 2007 -0300
++++ b/arch/i386/kernel/e820.c Wed Aug 08 16:25:28 2007 -0300
+@@ -15,10 +15,24 @@
#include <asm/page.h>
#include <asm/e820.h>
@@ -1837,16 +1122,15 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
int efi_enabled = 0;
EXPORT_SYMBOL(efi_enabled);
#endif
-
++
+#ifdef CONFIG_XEN
+struct e820map machine_e820;
+#endif
+static void __init
+e820_setup_gap(struct e820entry *e820, int nr_map);
-+
+
struct e820map e820;
struct change_member {
- struct e820entry *pbios; /* pointer to original bios entry */
@@ -180,6 +194,12 @@ static void __init probe_roms(void)
unsigned char *rom;
int i;
@@ -1860,7 +1144,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
/* video rom */
upper = adapter_rom_resources[0].start;
for (start = video_rom_resource.start; start < upper; start += 2048) {
-@@ -247,36 +267,54 @@ static void __init
+@@ -247,36 +267,54 @@ legacy_init_iomem_resources(struct resou
legacy_init_iomem_resources(struct resource *code_resource, struct resource *data_resource)
{
int i;
@@ -2008,20 +1292,20 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
/*
* Since "last" is at most 4GB, we know we'll
-@@ -716,6 +778,13 @@ void __init e820_register_memory(void)
- pci_mem_start, gapstart, gapsize);
- }
+@@ -714,6 +776,13 @@ void __init e820_register_memory(void)
+ printk("Allocating PCI resources starting at %08lx (gap: %08lx:%08lx)\n",
+ pci_mem_start, gapstart, gapsize);
++}
++
+void __init e820_register_memory(void)
+{
+#ifndef CONFIG_XEN
+ e820_setup_gap(e820.map, e820.nr_map);
+#endif
-+}
-+
+ }
+
void __init print_memory_map(char *who)
- {
- int i;
@@ -784,7 +853,7 @@ static __init __always_inline void efi_l
void __init limit_regions(unsigned long long size)
@@ -2051,40 +1335,26 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
print_memory_map("limit_regions endfunc");
}
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/arch/i386/kernel/entry.S source/arch/i386/kernel/entry.S
---- /scratch/src/linux-2.6.20.3/arch/i386/kernel/entry.S 2007-02-04 19:44:54.000000000 +0100
-+++ source/arch/i386/kernel/entry.S 2007-03-20 21:26:26.000000000 +0100
-@@ -284,7 +284,7 @@ ENTRY(sysenter_entry)
- CFI_SIGNAL_FRAME
- CFI_DEF_CFA esp, 0
- CFI_REGISTER esp, ebp
-- movl TSS_sysenter_esp0(%esp),%esp
-+ movl SYSENTER_stack_esp0(%esp),%esp
- sysenter_past_esp:
- /*
- * No need to follow this irqs on/off section: the syscall
-@@ -727,7 +727,7 @@ device_not_available_emulate:
- * that sets up the real kernel stack. Check here, since we can't
- * allow the wrong stack to be used.
- *
-- * "TSS_sysenter_esp0+12" is because the NMI/debug handler will have
-+ * "SYSENTER_stack_esp0+12" is because the NMI/debug handler will have
- * already pushed 3 words if it hits on the sysenter instruction:
- * eflags, cs and eip.
- *
-@@ -739,7 +739,7 @@ device_not_available_emulate:
- cmpw $__KERNEL_CS,4(%esp); \
- jne ok; \
- label: \
-- movl TSS_sysenter_esp0+offset(%esp),%esp; \
-+ movl SYSENTER_stack_esp0+offset(%esp),%esp; \
- CFI_DEF_CFA esp, 0; \
- CFI_UNDEFINED eip; \
- pushfl; \
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/arch/i386/kernel/entry-xen.S source/arch/i386/kernel/entry-xen.S
---- /scratch/src/linux-2.6.20.3/arch/i386/kernel/entry-xen.S 1970-01-01 01:00:00.000000000 +0100
-+++ source/arch/i386/kernel/entry-xen.S 2007-03-20 21:26:26.000000000 +0100
-@@ -0,0 +1,1254 @@
+@@ -828,8 +910,15 @@ e820_all_mapped(unsigned long s, unsigne
+ u64 start = s;
+ u64 end = e;
+ int i;
++#ifndef CONFIG_XEN
+ for (i = 0; i < e820.nr_map; i++) {
+ struct e820entry *ei = &e820.map[i];
++#else
++ if (!is_initial_xendomain())
++ return 0;
++ for (i = 0; i < machine_e820.nr_map; ++i) {
++ const struct e820entry *ei = &machine_e820.map[i];
++#endif
+ if (type && ei->type != type)
+ continue;
+ /* is the region (part) in overlap with the current region ?*/
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 arch/i386/kernel/entry-xen.S
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/arch/i386/kernel/entry-xen.S Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,1264 @@
+/*
+ * linux/arch/i386/entry.S
+ *
@@ -2468,6 +1738,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ movl PT_ESI(%esp), %esi
+ sysexit
+14: __DISABLE_INTERRUPTS
++ TRACE_IRQS_OFF
+sysexit_ecrit: /**** END OF SYSEXIT CRITICAL REGION ****/
+ push %esp
+ CFI_ADJUST_CFA_OFFSET 4
@@ -2533,11 +1804,13 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+restore_nocheck:
+ movl PT_EFLAGS(%esp), %eax
+ testl $(VM_MASK|NMI_MASK), %eax
++ CFI_REMEMBER_STATE
+ jnz hypervisor_iret
+ shr $9, %eax # EAX[0] == IRET_EFLAGS.IF
+ GET_VCPU_INFO
+ andb evtchn_upcall_mask(%esi),%al
+ andb $1,%al # EAX[0] == IRET_EFLAGS.IF & event_mask
++ CFI_REMEMBER_STATE
+ jnz restore_all_enable_events # != 0 => enable event delivery
+ CFI_REMEMBER_STATE
+#endif
@@ -2602,10 +1875,32 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ CFI_ADJUST_CFA_OFFSET -8
+ jmp restore_nocheck
+#else
++ ALIGN
++restore_all_enable_events:
++ TRACE_IRQS_ON
++ __ENABLE_INTERRUPTS
++scrit: /**** START OF CRITICAL REGION ****/
++ __TEST_PENDING
++ jnz 14f # process more events if necessary...
++ RESTORE_REGS
++ addl $4, %esp
++ CFI_ADJUST_CFA_OFFSET -4
++1: iret
++.section __ex_table,"a"
++ .align 4
++ .long 1b,iret_exc
++.previous
++14: __DISABLE_INTERRUPTS
++ TRACE_IRQS_OFF
++ jmp 11f
++ecrit: /**** END OF CRITICAL REGION ****/
++
++ CFI_RESTORE_STATE
+hypervisor_iret:
+ andl $~NMI_MASK, PT_EFLAGS(%esp)
+ RESTORE_REGS
+ addl $4, %esp
++ CFI_ADJUST_CFA_OFFSET -4
+ jmp hypercall_page + (__HYPERVISOR_iret * 32)
+#endif
+ CFI_ENDPROC
@@ -2870,33 +2165,15 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ cmpl $sysexit_ecrit,%eax
+ ja 11f
+ # interrupted in sysexit critical
-+ addl $0x38,%esp # Remove cs...ebx from stack frame.
-+ # this popped off new frame to reuse the old one, therefore no
-+ # CFI_ADJUST_CFA_OFFSET here
++ addl $PT_OLDESP,%esp # Remove cs...ebx from stack frame.
+11: push %esp
+ CFI_ADJUST_CFA_OFFSET 4
+ call evtchn_do_upcall
+ add $4,%esp
+ CFI_ADJUST_CFA_OFFSET -4
+ jmp ret_from_intr
++ CFI_ENDPROC
+
-+ ALIGN
-+restore_all_enable_events:
-+ __ENABLE_INTERRUPTS
-+scrit: /**** START OF CRITICAL REGION ****/
-+ __TEST_PENDING
-+ jnz 14f # process more events if necessary...
-+ RESTORE_REGS
-+ addl $4, %esp
-+ CFI_ADJUST_CFA_OFFSET -4
-+1: iret
-+.section __ex_table,"a"
-+ .align 4
-+ .long 1b,iret_exc
-+.previous
-+14: __DISABLE_INTERRUPTS
-+ jmp 11b
-+ecrit: /**** END OF CRITICAL REGION ****/
+# [How we do the fixup]. We want to merge the current stack frame with the
+# just-interrupted frame. How we do this depends on where in the critical
+# region the interrupted handler was executing, and so how many saved
@@ -2905,18 +2182,13 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+# provides the number of bytes which have already been popped from the
+# interrupted stack frame.
+critical_region_fixup:
-+ addl $critical_fixup_table-scrit,%eax
-+ movzbl (%eax),%eax # %eax contains num bytes popped
-+ cmpb $0xff,%al # 0xff => vcpu_info critical region
++ movzbl critical_fixup_table-scrit(%eax),%ecx # %eax contains num bytes popped
++ cmpb $0xff,%cl # 0xff => vcpu_info critical region
+ jne 15f
-+ GET_THREAD_INFO(%ebp)
-+ xorl %eax,%eax
-+15: mov %esp,%esi
-+ add %eax,%esi # %esi points at end of src region
-+ mov %esp,%edi
-+ add $0x38,%edi # %edi points at end of dst region
-+ mov %eax,%ecx
-+ shr $2,%ecx # convert words to bytes
++ xorl %ecx,%ecx
++15: leal (%esp,%ecx),%esi # %esi points at end of src region
++ leal PT_OLDESP(%esp),%edi # %edi points at end of dst region
++ shrl $2,%ecx # convert words to bytes
+ je 17f # skip loop if nothing to copy
+16: subl $4,%esi # pre-decrementing copy loop
+ subl $4,%edi
@@ -2924,11 +2196,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ movl %eax,(%edi)
+ loop 16b
+17: movl %edi,%esp # final %edi is top of merged stack
-+ # this popped off new frame to reuse the old one, therefore no
-+ # CFI_DEF_CFA_OFFSET here
+ jmp 11b
-+ CFI_ENDPROC
+
++.section .rodata,"a"
+critical_fixup_table:
+ .byte 0xff,0xff,0xff # testb $0xff,(%esi) = __TEST_PENDING
+ .byte 0xff,0xff # jnz 14f
@@ -2946,6 +2216,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ .byte 0x2c # iret
+ .byte 0xff,0xff,0xff,0xff # movb $1,1(%esi)
+ .byte 0x00,0x00 # jmp 11b
++.previous
+
+# Hypervisor uses this for application faults while it executes.
+# We get here for two reasons:
@@ -2971,13 +2242,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ CFI_ADJUST_CFA_OFFSET -4
+ jz 5f
+ addl $16,%esp # EAX != 0 => Category 2 (Bad IRET)
-+ CFI_ADJUST_CFA_OFFSET -16
+ jmp iret_exc
-+ CFI_ADJUST_CFA_OFFSET 16
+5: addl $16,%esp # EAX == 0 => Category 1 (Bad segment)
-+ CFI_ADJUST_CFA_OFFSET -16
+ pushl $0
-+ CFI_ADJUST_CFA_OFFSET 4
+ SAVE_ALL
+ jmp ret_from_exception
+.section .fixup,"ax"; \
@@ -3001,8 +2268,8 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ .long 3b,8b; \
+ .long 4b,9b; \
+.previous
-+ CFI_ENDPROC
+#endif
++ CFI_ENDPROC
+
+ENTRY(coprocessor_error)
+ RING0_INT_FRAME
@@ -3091,6 +2358,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ jmp ret_from_exception
+ CFI_ENDPROC
+KPROBE_END(debug)
++ .previous .text
+
+#ifndef CONFIG_XEN
+/*
@@ -3315,12 +2583,16 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ CFI_ENDPROC
+#endif
+
-+ENTRY(fixup_4gb_segment)
++#ifndef CONFIG_XEN
++ENTRY(spurious_interrupt_bug)
+ RING0_INT_FRAME
-+ pushl $do_fixup_4gb_segment
++ pushl $0
++ CFI_ADJUST_CFA_OFFSET 4
++ pushl $do_spurious_interrupt_bug
+ CFI_ADJUST_CFA_OFFSET 4
+ jmp error_code
+ CFI_ENDPROC
++#endif /* !CONFIG_XEN */
+
+ENTRY(kernel_thread_helper)
+ pushl $0 # fake return address for unwinder
@@ -3335,13 +2607,51 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ CFI_ENDPROC
+ENDPROC(kernel_thread_helper)
+
++ENTRY(fixup_4gb_segment)
++ RING0_EC_FRAME
++ pushl $do_fixup_4gb_segment
++ CFI_ADJUST_CFA_OFFSET 4
++ jmp error_code
++ CFI_ENDPROC
++
+.section .rodata,"a"
++.align 4
+#include "syscall_table.S"
+
+syscall_table_size=(.-sys_call_table)
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/arch/i386/kernel/fixup.c source/arch/i386/kernel/fixup.c
---- /scratch/src/linux-2.6.20.3/arch/i386/kernel/fixup.c 1970-01-01 01:00:00.000000000 +0100
-+++ source/arch/i386/kernel/fixup.c 2007-03-20 21:26:26.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 arch/i386/kernel/entry.S
+--- a/arch/i386/kernel/entry.S Wed Jul 18 12:23:24 2007 -0300
++++ b/arch/i386/kernel/entry.S Wed Aug 08 16:25:28 2007 -0300
+@@ -284,7 +284,7 @@ ENTRY(sysenter_entry)
+ CFI_SIGNAL_FRAME
+ CFI_DEF_CFA esp, 0
+ CFI_REGISTER esp, ebp
+- movl TSS_sysenter_esp0(%esp),%esp
++ movl SYSENTER_stack_esp0(%esp),%esp
+ sysenter_past_esp:
+ /*
+ * No need to follow this irqs on/off section: the syscall
+@@ -727,7 +727,7 @@ device_not_available_emulate:
+ * that sets up the real kernel stack. Check here, since we can't
+ * allow the wrong stack to be used.
+ *
+- * "TSS_sysenter_esp0+12" is because the NMI/debug handler will have
++ * "SYSENTER_stack_esp0+12" is because the NMI/debug handler will have
+ * already pushed 3 words if it hits on the sysenter instruction:
+ * eflags, cs and eip.
+ *
+@@ -739,7 +739,7 @@ device_not_available_emulate:
+ cmpw $__KERNEL_CS,4(%esp); \
+ jne ok; \
+ label: \
+- movl TSS_sysenter_esp0+offset(%esp),%esp; \
++ movl SYSENTER_stack_esp0+offset(%esp),%esp; \
+ CFI_DEF_CFA esp, 0; \
+ CFI_UNDEFINED eip; \
+ pushfl; \
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 arch/i386/kernel/fixup.c
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/arch/i386/kernel/fixup.c Wed Aug 08 16:25:28 2007 -0300
@@ -0,0 +1,95 @@
+/******************************************************************************
+ * fixup.c
@@ -3438,10 +2748,10 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ return 0;
+}
+__initcall(fixup_init);
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/arch/i386/kernel/head-xen.S source/arch/i386/kernel/head-xen.S
---- /scratch/src/linux-2.6.20.3/arch/i386/kernel/head-xen.S 1970-01-01 01:00:00.000000000 +0100
-+++ source/arch/i386/kernel/head-xen.S 2007-03-20 21:26:26.000000000 +0100
-@@ -0,0 +1,287 @@
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 arch/i386/kernel/head-xen.S
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/arch/i386/kernel/head-xen.S Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,292 @@
+
+
+.text
@@ -3451,8 +2761,10 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#include <asm/segment.h>
+#include <asm/page.h>
+#include <asm/boot.h>
++#include <asm/cache.h>
+#include <asm/thread_info.h>
+#include <asm/asm-offsets.h>
++#include <asm/dwarf2.h>
+#include <xen/interface/xen.h>
+#include <xen/interface/elfnote.h>
+
@@ -3517,10 +2829,8 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+
+ cld # gcc2 wants the direction flag cleared at all times
+
-+ call start_kernel
-+L6:
-+ jmp L6 # main should never return here, but
-+ # just in case, we know what happens.
++ pushl %eax # fake return address
++ jmp start_kernel
+
+/*
+ * Point the GDT at this CPU's PDA. This will be
@@ -3566,7 +2876,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#define HYPERCALL_PAGE_OFFSET 0x1000
+.org HYPERCALL_PAGE_OFFSET
+ENTRY(hypercall_page)
++ CFI_STARTPROC
+.skip 0x1000
++ CFI_ENDPROC
+
+/*
+ * Real beginning of normal "text" segment
@@ -3669,7 +2981,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ .quad 0x0000000000000000 /* 0xf8 - GDT entry 31: double-fault TSS */
+ .align PAGE_SIZE_asm
+
-+#ifdef CONFIG_XEN_COMPAT_030002
++#if CONFIG_XEN_COMPAT <= 0x030002
+/*
+ * __xen_guest information
+ */
@@ -3707,86 +3019,64 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#endif
+ .ascii ",LOADER=generic"
+ .byte 0
-+#endif /* CONFIG_XEN_COMPAT_030002 */
++#endif /* CONFIG_XEN_COMPAT <= 0x030002 */
+
+
+ ELFNOTE(Xen, XEN_ELFNOTE_GUEST_OS, .asciz, "linux")
+ ELFNOTE(Xen, XEN_ELFNOTE_GUEST_VERSION, .asciz, "2.6")
+ ELFNOTE(Xen, XEN_ELFNOTE_XEN_VERSION, .asciz, "xen-3.0")
+ ELFNOTE(Xen, XEN_ELFNOTE_VIRT_BASE, .long, __PAGE_OFFSET)
-+#ifdef CONFIG_XEN_COMPAT_030002
++#if CONFIG_XEN_COMPAT <= 0x030002
+ ELFNOTE(Xen, XEN_ELFNOTE_PADDR_OFFSET, .long, __PAGE_OFFSET)
+#else
+ ELFNOTE(Xen, XEN_ELFNOTE_PADDR_OFFSET, .long, 0)
-+#endif /* !CONFIG_XEN_COMPAT_030002 */
++#endif
+ ELFNOTE(Xen, XEN_ELFNOTE_ENTRY, .long, startup_32)
+ ELFNOTE(Xen, XEN_ELFNOTE_HYPERCALL_PAGE, .long, hypercall_page)
+ ELFNOTE(Xen, XEN_ELFNOTE_HV_START_LOW, .long, HYPERVISOR_VIRT_START)
+ ELFNOTE(Xen, XEN_ELFNOTE_FEATURES, .asciz, "writable_page_tables|writable_descriptor_tables|auto_translated_physmap|pae_pgdir_above_4gb|supervisor_mode_kernel")
+#ifdef CONFIG_X86_PAE
+ ELFNOTE(Xen, XEN_ELFNOTE_PAE_MODE, .asciz, "yes")
++ ELFNOTE(Xen, XEN_ELFNOTE_L1_MFN_VALID, .quad, _PAGE_PRESENT,_PAGE_PRESENT)
+#else
+ ELFNOTE(Xen, XEN_ELFNOTE_PAE_MODE, .asciz, "no")
++ ELFNOTE(Xen, XEN_ELFNOTE_L1_MFN_VALID, .long, _PAGE_PRESENT,_PAGE_PRESENT)
+#endif
+ ELFNOTE(Xen, XEN_ELFNOTE_LOADER, .asciz, "generic")
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/arch/i386/kernel/init_task-xen.c source/arch/i386/kernel/init_task-xen.c
---- /scratch/src/linux-2.6.20.3/arch/i386/kernel/init_task-xen.c 1970-01-01 01:00:00.000000000 +0100
-+++ source/arch/i386/kernel/init_task-xen.c 2007-03-20 21:26:26.000000000 +0100
-@@ -0,0 +1,51 @@
-+#include <linux/mm.h>
-+#include <linux/module.h>
-+#include <linux/sched.h>
-+#include <linux/init.h>
-+#include <linux/init_task.h>
-+#include <linux/fs.h>
-+#include <linux/mqueue.h>
-+
-+#include <asm/uaccess.h>
-+#include <asm/pgtable.h>
-+#include <asm/desc.h>
-+
-+static struct fs_struct init_fs = INIT_FS;
-+static struct files_struct init_files = INIT_FILES;
-+static struct signal_struct init_signals = INIT_SIGNALS(init_signals);
-+static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand);
++ ELFNOTE(Xen, XEN_ELFNOTE_SUSPEND_CANCEL, .long, 1)
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 arch/i386/kernel/init_task.c
+--- a/arch/i386/kernel/init_task.c Wed Jul 18 12:23:24 2007 -0300
++++ b/arch/i386/kernel/init_task.c Wed Aug 08 16:25:28 2007 -0300
+@@ -14,7 +14,14 @@ static struct files_struct init_files =
+ static struct files_struct init_files = INIT_FILES;
+ static struct signal_struct init_signals = INIT_SIGNALS(init_signals);
+ static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand);
+
++#ifdef CONFIG_XEN
+#define swapper_pg_dir ((pgd_t *)NULL)
-+struct mm_struct init_mm = INIT_MM(init_mm);
+ struct mm_struct init_mm = INIT_MM(init_mm);
+#undef swapper_pg_dir
-+
-+EXPORT_SYMBOL(init_mm);
-+
-+/*
-+ * Initial thread structure.
-+ *
-+ * We need to make sure that this is THREAD_SIZE aligned due to the
-+ * way process stacks are handled. This is done by having a special
-+ * "init_task" linker map entry..
-+ */
-+union thread_union init_thread_union
-+ __attribute__((__section__(".data.init_task"))) =
-+ { INIT_THREAD_INFO(init_task) };
-+
-+/*
-+ * Initial task structure.
-+ *
-+ * All other task structs will be allocated on slabs in fork.c
-+ */
-+struct task_struct init_task = INIT_TASK(init_task);
-+
-+EXPORT_SYMBOL(init_task);
-+
++#else
++struct mm_struct init_mm = INIT_MM(init_mm);
++#endif
+
+ EXPORT_SYMBOL(init_mm);
+
+@@ -38,9 +45,11 @@ struct task_struct init_task = INIT_TASK
+
+ EXPORT_SYMBOL(init_task);
+
+#ifndef CONFIG_X86_NO_TSS
-+/*
-+ * per-CPU TSS segments. Threads are completely 'soft' on Linux,
-+ * no more per-task TSS's.
-+ */
-+DEFINE_PER_CPU(struct tss_struct, init_tss) ____cacheline_internodealigned_in_smp = INIT_TSS;
+ /*
+ * per-CPU TSS segments. Threads are completely 'soft' on Linux,
+ * no more per-task TSS's.
+ */
+ DEFINE_PER_CPU(struct tss_struct, init_tss) ____cacheline_internodealigned_in_smp = INIT_TSS;
+#endif
-+
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/arch/i386/kernel/io_apic-xen.c source/arch/i386/kernel/io_apic-xen.c
---- /scratch/src/linux-2.6.20.3/arch/i386/kernel/io_apic-xen.c 1970-01-01 01:00:00.000000000 +0100
-+++ source/arch/i386/kernel/io_apic-xen.c 2007-03-20 21:26:26.000000000 +0100
+
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 arch/i386/kernel/io_apic-xen.c
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/arch/i386/kernel/io_apic-xen.c Wed Aug 08 16:25:28 2007 -0300
@@ -0,0 +1,2973 @@
+/*
+ * Intel IO-APIC support for multi-Pentium hosts.
@@ -5070,8 +4360,8 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+
+static int __assign_irq_vector(int irq)
+{
-+ struct physdev_irq irq_op;
+ int vector;
++ struct physdev_irq irq_op;
+
+ BUG_ON((unsigned)irq >= NR_IRQ_VECTORS);
+
@@ -6248,10 +5538,10 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ if(sis_apic_bug == -1)
+ sis_apic_bug = 0;
+ if (is_initial_xendomain()) {
-+ dom0_op_t op = { .cmd = DOM0_PLATFORM_QUIRK };
++ struct xen_platform_op op = { .cmd = XENPF_platform_quirk };
+ op.u.platform_quirk.quirk_id = sis_apic_bug ?
+ QUIRK_IOAPIC_BAD_REGSEL : QUIRK_IOAPIC_GOOD_REGSEL;
-+ HYPERVISOR_dom0_op(&op);
++ HYPERVISOR_platform_op(&op);
+ }
+ return 0;
+}
@@ -6761,10 +6051,10 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ return 0;
+}
+early_param("noapic", parse_noapic);
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/arch/i386/kernel/ioport-xen.c source/arch/i386/kernel/ioport-xen.c
---- /scratch/src/linux-2.6.20.3/arch/i386/kernel/ioport-xen.c 1970-01-01 01:00:00.000000000 +0100
-+++ source/arch/i386/kernel/ioport-xen.c 2007-03-20 21:26:26.000000000 +0100
-@@ -0,0 +1,121 @@
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 arch/i386/kernel/ioport-xen.c
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/arch/i386/kernel/ioport-xen.c Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,122 @@
+/*
+ * linux/arch/i386/kernel/ioport.c
+ *
@@ -6846,8 +6136,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+
+ memset(bitmap, 0xff, IO_BITMAP_BYTES);
+ t->io_bitmap_ptr = bitmap;
++ set_thread_flag(TIF_IO_BITMAP);
+
-+ set_iobitmap.bitmap = (char *)bitmap;
++ set_xen_guest_handle(set_iobitmap.bitmap, (char *)bitmap);
+ set_iobitmap.nr_ports = IO_BITMAP_BITS;
+ HYPERVISOR_physdev_op(PHYSDEVOP_set_iobitmap, &set_iobitmap);
+ }
@@ -6886,9 +6177,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ set_iopl_mask(t->iopl);
+ return 0;
+}
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/arch/i386/kernel/irq.c source/arch/i386/kernel/irq.c
---- /scratch/src/linux-2.6.20.3/arch/i386/kernel/irq.c 2007-02-04 19:44:54.000000000 +0100
-+++ source/arch/i386/kernel/irq.c 2007-03-20 21:26:26.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 arch/i386/kernel/irq.c
+--- a/arch/i386/kernel/irq.c Wed Jul 18 12:23:24 2007 -0300
++++ b/arch/i386/kernel/irq.c Wed Aug 08 16:25:28 2007 -0300
@@ -288,7 +288,9 @@ skip:
}
@@ -6909,9 +6200,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
mask = map;
}
if (irq_desc[irq].chip->set_affinity)
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/arch/i386/kernel/ldt-xen.c source/arch/i386/kernel/ldt-xen.c
---- /scratch/src/linux-2.6.20.3/arch/i386/kernel/ldt-xen.c 1970-01-01 01:00:00.000000000 +0100
-+++ source/arch/i386/kernel/ldt-xen.c 2007-03-20 21:26:26.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 arch/i386/kernel/ldt-xen.c
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/arch/i386/kernel/ldt-xen.c Wed Aug 08 16:25:28 2007 -0300
@@ -0,0 +1,268 @@
+/*
+ * linux/arch/i386/kernel/ldt.c
@@ -7181,9 +6472,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ }
+ return ret;
+}
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/arch/i386/kernel/machine_kexec.c source/arch/i386/kernel/machine_kexec.c
---- /scratch/src/linux-2.6.20.3/arch/i386/kernel/machine_kexec.c 2007-02-04 19:44:54.000000000 +0100
-+++ source/arch/i386/kernel/machine_kexec.c 2007-03-21 14:49:46.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 arch/i386/kernel/machine_kexec.c
+--- a/arch/i386/kernel/machine_kexec.c Wed Jul 18 12:23:24 2007 -0300
++++ b/arch/i386/kernel/machine_kexec.c Wed Aug 08 16:25:28 2007 -0300
@@ -20,6 +20,10 @@
#include <asm/desc.h>
#include <asm/system.h>
@@ -7195,10 +6486,11 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
#define PAGE_ALIGNED __attribute__ ((__aligned__(PAGE_SIZE)))
static u32 kexec_pgd[1024] PAGE_ALIGNED;
#ifdef CONFIG_X86_PAE
-@@ -29,6 +33,40 @@ static u32 kexec_pmd1[1024] PAGE_ALIGNED
+@@ -28,6 +32,40 @@ static u32 kexec_pmd1[1024] PAGE_ALIGNED
+ #endif
static u32 kexec_pte0[1024] PAGE_ALIGNED;
static u32 kexec_pte1[1024] PAGE_ALIGNED;
-
++
+#ifdef CONFIG_XEN
+
+#define __ma(x) (pfn_to_mfn(__pa((x)) >> PAGE_SHIFT) << PAGE_SHIFT)
@@ -7232,15 +6524,14 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+}
+
+#else /* CONFIG_XEN */
-+
+
static void set_idt(void *newidt, __u16 limit)
{
- struct Xgt_desc_struct curidt;
@@ -70,6 +108,7 @@ static void load_segments(void)
#undef STR
#undef __STR
}
-+#endif /* CONFIG_XEN */
++#endif /* !CONFIG_XEN */
/*
* A architecture hook called to validate the
@@ -7260,57 +6551,10 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
/* crashkernel=size@addr specifies the location to reserve for
* a crash kernel. By reserving this memory we guarantee
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/arch/i386/kernel/Makefile source/arch/i386/kernel/Makefile
---- /scratch/src/linux-2.6.20.3/arch/i386/kernel/Makefile 2007-02-04 19:44:54.000000000 +0100
-+++ source/arch/i386/kernel/Makefile 2007-03-20 21:26:26.000000000 +0100
-@@ -47,6 +47,12 @@ EXTRA_AFLAGS := -traditional
-
- obj-$(CONFIG_SCx200) += scx200.o
-
-+ifdef CONFIG_XEN
-+vsyscall_note := vsyscall-note-xen.o
-+else
-+vsyscall_note := vsyscall-note.o
-+endif
-+
- # vsyscall.o contains the vsyscall DSO images as __initdata.
- # We must build both images before we can assemble it.
- # Note: kbuild does not track this dependency due to usage of .incbin
-@@ -68,7 +74,7 @@ SYSCFLAGS_vsyscall-int80.so = $(vsyscall
-
- $(obj)/vsyscall-int80.so $(obj)/vsyscall-sysenter.so: \
- $(obj)/vsyscall-%.so: $(src)/vsyscall.lds \
-- $(obj)/vsyscall-%.o $(obj)/vsyscall-note.o FORCE
-+ $(obj)/vsyscall-%.o $(obj)/$(vsyscall_note) FORCE
- $(call if_changed,syscall)
-
- # We also create a special relocatable object that should mirror the symbol
-@@ -80,9 +86,20 @@ $(obj)/built-in.o: ld_flags += -R $(obj)
-
- SYSCFLAGS_vsyscall-syms.o = -r
- $(obj)/vsyscall-syms.o: $(src)/vsyscall.lds \
-- $(obj)/vsyscall-sysenter.o $(obj)/vsyscall-note.o FORCE
-+ $(obj)/vsyscall-sysenter.o $(obj)/$(vsyscall_note) FORCE
- $(call if_changed,syscall)
-
- k8-y += ../../x86_64/kernel/k8.o
- stacktrace-y += ../../x86_64/kernel/stacktrace.o
-
-+ifdef CONFIG_XEN
-+include $(srctree)/scripts/Makefile.xen
-+
-+obj-y += fixup.o
-+microcode-$(subst m,y,$(CONFIG_MICROCODE)) := microcode-xen.o
-+n-obj-xen := i8259.o timers/ reboot.o smpboot.o trampoline.o
-+
-+obj-y := $(call filterxen, $(obj-y), $(n-obj-xen))
-+obj-y := $(call cherrypickxen, $(obj-y))
-+extra-y := $(call cherrypickxen, $(extra-y))
-+endif
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/arch/i386/kernel/microcode-xen.c source/arch/i386/kernel/microcode-xen.c
---- /scratch/src/linux-2.6.20.3/arch/i386/kernel/microcode-xen.c 1970-01-01 01:00:00.000000000 +0100
-+++ source/arch/i386/kernel/microcode-xen.c 2007-03-20 21:26:26.000000000 +0100
-@@ -0,0 +1,141 @@
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 arch/i386/kernel/microcode-xen.c
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/arch/i386/kernel/microcode-xen.c Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,144 @@
+/*
+ * Intel CPU Microcode Update Driver for Linux
+ *
@@ -7356,7 +6600,10 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+MODULE_AUTHOR("Tigran Aivazian <tigran@veritas.com>");
+MODULE_LICENSE("GPL");
+
-+#define MICROCODE_VERSION "1.14-xen"
++static int verbose;
++module_param(verbose, int, 0644);
++
++#define MICROCODE_VERSION "1.14a-xen"
+
+#define DEFAULT_UCODE_DATASIZE (2000) /* 2000 bytes */
+#define MC_HEADER_SIZE (sizeof (microcode_header_t)) /* 48 bytes */
@@ -7381,12 +6628,12 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ return -ENOMEM;
+
+ if (copy_from_user(kbuf, ubuf, len) == 0) {
-+ dom0_op_t op;
++ struct xen_platform_op op;
+
-+ op.cmd = DOM0_MICROCODE;
++ op.cmd = XENPF_microcode_update;
+ set_xen_guest_handle(op.u.microcode.data, kbuf);
+ op.u.microcode.length = len;
-+ err = HYPERVISOR_dom0_op(&op);
++ err = HYPERVISOR_platform_op(&op);
+ } else
+ err = -EFAULT;
+
@@ -7399,7 +6646,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+{
+ ssize_t ret;
+
-+ if (len < DEFAULT_UCODE_TOTALSIZE) {
++ if (len < MC_HEADER_SIZE) {
+ printk(KERN_ERR "microcode: not enough data\n");
+ return -EINVAL;
+ }
@@ -7452,9 +6699,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+module_init(microcode_init)
+module_exit(microcode_exit)
+MODULE_ALIAS_MISCDEV(MICROCODE_MINOR);
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/arch/i386/kernel/mpparse.c source/arch/i386/kernel/mpparse.c
---- /scratch/src/linux-2.6.20.3/arch/i386/kernel/mpparse.c 2007-02-04 19:44:54.000000000 +0100
-+++ source/arch/i386/kernel/mpparse.c 2007-03-20 21:26:26.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 arch/i386/kernel/mpparse.c
+--- a/arch/i386/kernel/mpparse.c Wed Jul 18 12:23:24 2007 -0300
++++ b/arch/i386/kernel/mpparse.c Wed Aug 08 16:25:28 2007 -0300
@@ -106,6 +106,7 @@ static struct mpc_config_translation *tr
static void __cpuinit MP_processor_info (struct mpc_config_processor *m)
@@ -7589,10 +6836,10 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
if ((boot_cpu_data.x86_vendor == X86_VENDOR_INTEL)
&& !APIC_XAPIC(apic_version[boot_cpu_physical_apicid]))
tmpid = io_apic_get_unique_id(idx, id);
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/arch/i386/kernel/pci-dma-xen.c source/arch/i386/kernel/pci-dma-xen.c
---- /scratch/src/linux-2.6.20.3/arch/i386/kernel/pci-dma-xen.c 1970-01-01 01:00:00.000000000 +0100
-+++ source/arch/i386/kernel/pci-dma-xen.c 2007-03-20 21:26:26.000000000 +0100
-@@ -0,0 +1,375 @@
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 arch/i386/kernel/pci-dma-xen.c
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/arch/i386/kernel/pci-dma-xen.c Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,378 @@
+/*
+ * Dynamic DMA mapping support.
+ *
@@ -7616,6 +6863,8 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#include <asm/bug.h>
+
+#ifdef __x86_64__
++#include <asm/proto.h>
++
+int iommu_merge __read_mostly = 0;
+EXPORT_SYMBOL(iommu_merge);
+
@@ -7721,13 +6970,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+}
+EXPORT_SYMBOL(dma_unmap_sg);
+
-+/*
-+ * XXX This file is also used by xenLinux/ia64.
-+ * "defined(__i386__) || defined (__x86_64__)" means "!defined(__ia64__)".
-+ * This #if work around should be removed once this file is merbed back into
-+ * i386' pci-dma or is moved to drivers/xen/core.
-+ */
-+#if defined(__i386__) || defined(__x86_64__)
++#ifdef CONFIG_HIGHMEM
+dma_addr_t
+dma_map_page(struct device *dev, struct page *page, unsigned long offset,
+ size_t size, enum dma_data_direction direction)
@@ -7757,7 +7000,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ swiotlb_unmap_page(dev, dma_address, size, direction);
+}
+EXPORT_SYMBOL(dma_unmap_page);
-+#endif /* defined(__i386__) || defined(__x86_64__) */
++#endif /* CONFIG_HIGHMEM */
+
+int
+dma_mapping_error(dma_addr_t dma_addr)
@@ -7788,6 +7031,8 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ struct dma_coherent_mem *mem = dev ? dev->dma_mem : NULL;
+ unsigned int order = get_order(size);
+ unsigned long vstart;
++ u64 mask;
++
+ /* ignore region specifiers */
+ gfp &= ~(__GFP_DMA | __GFP_HIGHMEM);
+
@@ -7810,9 +7055,14 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ vstart = __get_free_pages(gfp, order);
+ ret = (void *)vstart;
+
++ if (dev != NULL && dev->coherent_dma_mask)
++ mask = dev->coherent_dma_mask;
++ else
++ mask = 0xffffffff;
++
+ if (ret != NULL) {
+ if (xen_create_contiguous_region(vstart, order,
-+ dma_bits) != 0) {
++ fls64(mask)) != 0) {
+ free_pages(vstart, order);
+ return NULL;
+ }
@@ -7968,10 +7218,10 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ swiotlb_sync_single_for_device(dev, dma_handle, size, direction);
+}
+EXPORT_SYMBOL(dma_sync_single_for_device);
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/arch/i386/kernel/process-xen.c source/arch/i386/kernel/process-xen.c
---- /scratch/src/linux-2.6.20.3/arch/i386/kernel/process-xen.c 1970-01-01 01:00:00.000000000 +0100
-+++ source/arch/i386/kernel/process-xen.c 2007-03-20 21:26:26.000000000 +0100
-@@ -0,0 +1,851 @@
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 arch/i386/kernel/process-xen.c
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/arch/i386/kernel/process-xen.c Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,884 @@
+/*
+ * linux/arch/i386/kernel/process.c
+ *
@@ -8072,8 +7322,24 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+
+EXPORT_SYMBOL(enable_hlt);
+
-+/* XXX XEN doesn't use default_idle(), poll_idle(). Use xen_idle() instead. */
-+void xen_idle(void)
++/*
++ * On SMP it's slightly faster (but much more power-consuming!)
++ * to poll the ->work.need_resched flag instead of waiting for the
++ * cross-CPU IPI to arrive. Use this option with caution.
++ */
++static void poll_idle (void)
++{
++ local_irq_enable();
++
++ asm volatile(
++ "2:"
++ "testl %0, %1;"
++ "rep; nop;"
++ "je 2b;"
++ : : "i"(_TIF_NEED_RESCHED), "m" (current_thread_info()->flags));
++}
++
++static void xen_idle(void)
+{
+ current_thread_info()->status &= ~TS_POLLING;
+ /*
@@ -8126,17 +7392,19 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ /* endless idle loop with no priority at all */
+ while (1) {
+ while (!need_resched()) {
++ void (*idle)(void);
+
+ if (__get_cpu_var(cpu_idle_state))
+ __get_cpu_var(cpu_idle_state) = 0;
+
+ rmb();
++ idle = xen_idle; /* no alternatives */
+
+ if (cpu_is_offline(cpu))
+ play_dead();
+
+ __get_cpu_var(irq_stat).idle_timestamp = jiffies;
-+ xen_idle();
++ idle();
+ }
+ preempt_enable_no_resched();
+ schedule();
@@ -8178,7 +7446,22 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+/* Always use xen_idle() instead. */
+void mwait_idle_with_hints(unsigned long eax, unsigned long ecx) {}
+
-+void __devinit select_idle_routine(const struct cpuinfo_x86 *c) {}
++void __devinit select_idle_routine(const struct cpuinfo_x86 *c)
++{
++}
++
++static int __init idle_setup (char *str)
++{
++ if (!strncmp(str, "poll", 4)) {
++ printk("using polling idle threads.\n");
++ pm_idle = poll_idle;
++ }
++
++ boot_option_idle_override = 1;
++ return 1;
++}
++
++__setup("idle=", idle_setup);
+
+void show_regs(struct pt_regs * regs)
+{
@@ -8251,8 +7534,8 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ if (unlikely(test_thread_flag(TIF_IO_BITMAP))) {
+ struct task_struct *tsk = current;
+ struct thread_struct *t = &tsk->thread;
-+
-+ struct physdev_set_iobitmap set_iobitmap = { 0 };
++ struct physdev_set_iobitmap set_iobitmap;
++ memset(&set_iobitmap, 0, sizeof(set_iobitmap));
+ HYPERVISOR_physdev_op(PHYSDEVOP_set_iobitmap, &set_iobitmap);
+ kfree(t->io_bitmap_ptr);
+ t->io_bitmap_ptr = NULL;
@@ -8570,7 +7853,8 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#undef C
+
+ if (unlikely(prev->io_bitmap_ptr || next->io_bitmap_ptr)) {
-+ iobmp_op.bitmap = (char *)next->io_bitmap_ptr;
++ set_xen_guest_handle(iobmp_op.bitmap,
++ (char *)next->io_bitmap_ptr);
+ iobmp_op.nr_ports = next->io_bitmap_ptr ? IO_BITMAP_BITS : 0;
+ mcl->op = __HYPERVISOR_physdev_op;
+ mcl->args[0] = PHYSDEVOP_set_iobitmap;
@@ -8595,10 +7879,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ prefetch(&next->i387.fxsave);
+
+ /*
-+ * Now maybe handle debug registers and/or IO bitmaps
++ * Now maybe handle debug registers
+ */
-+ if (unlikely((task_thread_info(next_p)->flags & _TIF_WORK_CTXSW)
-+ || test_tsk_thread_flag(prev_p, TIF_IO_BITMAP)))
++ if (unlikely(task_thread_info(next_p)->flags & _TIF_WORK_CTXSW))
+ __switch_to_xtra(next_p);
+
+ disable_tsc(prev_p, next_p);
@@ -8823,9 +8106,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ sp -= get_random_int() % 8192;
+ return sp & ~0xf;
+}
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/arch/i386/kernel/quirks.c source/arch/i386/kernel/quirks.c
---- /scratch/src/linux-2.6.20.3/arch/i386/kernel/quirks.c 2007-02-04 19:44:54.000000000 +0100
-+++ source/arch/i386/kernel/quirks.c 2007-03-20 21:26:26.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 arch/i386/kernel/quirks.c
+--- a/arch/i386/kernel/quirks.c Wed Jul 18 12:23:24 2007 -0300
++++ b/arch/i386/kernel/quirks.c Wed Aug 08 16:25:28 2007 -0300
@@ -7,7 +7,7 @@
#include <asm/genapic.h>
#include <asm/cpu.h>
@@ -8840,11 +8123,11 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
if (!(word & (1 << 13))) {
+#ifdef CONFIG_XEN
-+ dom0_op_t op;
++ struct xen_platform_op op;
+ printk(KERN_INFO "Disabling irq balancing and affinity\n");
-+ op.cmd = DOM0_PLATFORM_QUIRK;
++ op.cmd = XENPF_platform_quirk;
+ op.u.platform_quirk.quirk_id = QUIRK_NOIRQBALANCING;
-+ (void)HYPERVISOR_dom0_op(&op);
++ (void)HYPERVISOR_platform_op(&op);
+#else
printk(KERN_INFO "Disabling irq balancing and affinity\n");
#ifdef CONFIG_IRQBALANCE
@@ -8855,7 +8138,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
#ifdef CONFIG_PROC_FS
no_irq_affinity = 1;
#endif
-@@ -80,7 +88,7 @@ void __init quirk_intel_irqbalance(void)
+@@ -80,12 +88,12 @@ void __init quirk_intel_irqbalance(void)
printk(KERN_INFO "Disabling cpu hotplug control\n");
enable_cpu_hotplug = 0;
#endif
@@ -8864,10 +8147,16 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
/* force the genapic selection to flat mode so that
* interrupts can be redirected to more than one CPU.
*/
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/arch/i386/kernel/setup-xen.c source/arch/i386/kernel/setup-xen.c
---- /scratch/src/linux-2.6.20.3/arch/i386/kernel/setup-xen.c 1970-01-01 01:00:00.000000000 +0100
-+++ source/arch/i386/kernel/setup-xen.c 2007-03-20 21:26:26.000000000 +0100
-@@ -0,0 +1,843 @@
+ genapic_force = &apic_flat;
+-#endif
++#endif /* CONFIG_XEN */
+ }
+
+ /* put back the original value for config space */
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 arch/i386/kernel/setup-xen.c
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/arch/i386/kernel/setup-xen.c Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,845 @@
+/*
+ * linux/arch/i386/kernel/setup.c
+ *
@@ -9441,6 +8730,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ memcpy(&boot_cpu_data, &new_cpu_data, sizeof(new_cpu_data));
+ pre_setup_arch_hook();
+ early_cpu_init();
++#if defined(CONFIG_XEN) && defined(CONFIG_SMP)
++ prefill_possible_map();
++#endif
+
+ /*
+ * FIXME: This isn't an official loader_type right
@@ -9583,8 +8875,6 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ * frames that make up the p2m table. Used by save/restore
+ */
+ pfn_to_mfn_frame_list_list = alloc_bootmem_low_pages(PAGE_SIZE);
-+ HYPERVISOR_shared_info->arch.pfn_to_mfn_frame_list_list =
-+ virt_to_mfn(pfn_to_mfn_frame_list_list);
+
+ fpp = PAGE_SIZE/sizeof(unsigned long);
+ for (i=0, j=0, k=-1; i< max_pfn; i+=fpp, j++) {
@@ -9601,6 +8891,8 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ virt_to_mfn(&phys_to_machine_mapping[i]);
+ }
+ HYPERVISOR_shared_info->arch.max_pfn = max_pfn;
++ HYPERVISOR_shared_info->arch.pfn_to_mfn_frame_list_list =
++ virt_to_mfn(pfn_to_mfn_frame_list_list);
+ }
+
+ /*
@@ -9652,9 +8944,6 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ if (smp_found_config)
+ get_smp_config();
+#endif
-+#if defined(CONFIG_XEN) && defined(CONFIG_SMP)
-+ prefill_possible_map();
-+#endif
+
+ e820_register_memory();
+
@@ -9673,10 +8962,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ conswitchp = &dummy_con;
+#endif
+ }
-+ xencons_early_setup();
-+#ifdef CONFIG_X86_TSC
+ tsc_init();
-+#endif
++
++ xencons_early_setup();
+}
+
+static int
@@ -9692,6 +8980,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ struct platform_device *pd;
+ int ret;
+
++ if (!is_initial_xendomain())
++ return 0;
++
+ pd = platform_device_alloc("pcspkr", -1);
+ if (!pd)
+ return -ENOMEM;
@@ -9711,9 +9002,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ * c-basic-offset:8
+ * End:
+ */
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/arch/i386/kernel/smp-xen.c source/arch/i386/kernel/smp-xen.c
---- /scratch/src/linux-2.6.20.3/arch/i386/kernel/smp-xen.c 1970-01-01 01:00:00.000000000 +0100
-+++ source/arch/i386/kernel/smp-xen.c 2007-03-20 21:26:26.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 arch/i386/kernel/smp-xen.c
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/arch/i386/kernel/smp-xen.c Wed Aug 08 16:25:28 2007 -0300
@@ -0,0 +1,628 @@
+/*
+ * Intel SMP support routines.
@@ -10134,7 +9425,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ if (current->active_mm == mm) {
+ if(current->mm)
+ __flush_tlb_one(va);
-+ else
++ else
+ leave_mm(smp_processor_id());
+ }
+
@@ -10343,10 +9634,10 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+{
+ return smp_processor_id();
+}
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/arch/i386/kernel/swiotlb.c source/arch/i386/kernel/swiotlb.c
---- /scratch/src/linux-2.6.20.3/arch/i386/kernel/swiotlb.c 1970-01-01 01:00:00.000000000 +0100
-+++ source/arch/i386/kernel/swiotlb.c 2007-03-20 21:26:26.000000000 +0100
-@@ -0,0 +1,683 @@
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 arch/i386/kernel/swiotlb.c
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/arch/i386/kernel/swiotlb.c Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,716 @@
+/*
+ * Dynamic DMA mapping support.
+ *
@@ -10396,10 +9687,8 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ */
+#define IO_TLB_SHIFT 11
+
-+/* Width of DMA addresses. 30 bits is a b44 limitation. */
-+#define DEFAULT_DMA_BITS 30
-+
+int swiotlb_force;
++
+static char *iotlb_virt_start;
+static unsigned long iotlb_nslabs;
+
@@ -10447,11 +9736,12 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ */
+static DEFINE_SPINLOCK(io_tlb_lock);
+
-+unsigned int dma_bits = DEFAULT_DMA_BITS;
++static unsigned int dma_bits;
++static unsigned int __initdata max_dma_bits = 32;
+static int __init
+setup_dma_bits(char *str)
+{
-+ dma_bits = simple_strtoul(str, NULL, 0);
++ max_dma_bits = simple_strtoul(str, NULL, 0);
+ return 0;
+}
+__setup("dma_bits=", setup_dma_bits);
@@ -10492,6 +9782,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+swiotlb_init_with_default_size (size_t default_size)
+{
+ unsigned long i, bytes;
++ int rc;
+
+ if (!iotlb_nslabs) {
+ iotlb_nslabs = (default_size >> IO_TLB_SHIFT);
@@ -10508,16 +9799,33 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ */
+ iotlb_virt_start = alloc_bootmem_low_pages(bytes);
+ if (!iotlb_virt_start)
-+ panic("Cannot allocate SWIOTLB buffer!\n"
-+ "Use dom0_mem Xen boot parameter to reserve\n"
-+ "some DMA memory (e.g., dom0_mem=-128M).\n");
++ panic("Cannot allocate SWIOTLB buffer!\n");
+
++ dma_bits = get_order(IO_TLB_SEGSIZE << IO_TLB_SHIFT) + PAGE_SHIFT;
+ for (i = 0; i < iotlb_nslabs; i += IO_TLB_SEGSIZE) {
-+ int rc = xen_create_contiguous_region(
-+ (unsigned long)iotlb_virt_start + (i << IO_TLB_SHIFT),
-+ get_order(IO_TLB_SEGSIZE << IO_TLB_SHIFT),
-+ dma_bits);
-+ BUG_ON(rc);
++ do {
++ rc = xen_create_contiguous_region(
++ (unsigned long)iotlb_virt_start + (i << IO_TLB_SHIFT),
++ get_order(IO_TLB_SEGSIZE << IO_TLB_SHIFT),
++ dma_bits);
++ } while (rc && dma_bits++ < max_dma_bits);
++ if (rc) {
++ if (i == 0)
++ panic("No suitable physical memory available for SWIOTLB buffer!\n"
++ "Use dom0_mem Xen boot parameter to reserve\n"
++ "some DMA memory (e.g., dom0_mem=-128M).\n");
++ iotlb_nslabs = i;
++ i <<= IO_TLB_SHIFT;
++ free_bootmem(__pa(iotlb_virt_start + i), bytes - i);
++ bytes = i;
++ for (dma_bits = 0; i > 0; i -= IO_TLB_SEGSIZE << IO_TLB_SHIFT) {
++ unsigned int bits = fls64(virt_to_bus(iotlb_virt_start + i - 1));
++
++ if (bits > dma_bits)
++ dma_bits = bits;
++ }
++ break;
++ }
+ }
+
+ /*
@@ -10535,17 +9843,27 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ * Get the overflow emergency buffer
+ */
+ io_tlb_overflow_buffer = alloc_bootmem_low(io_tlb_overflow);
++ if (!io_tlb_overflow_buffer)
++ panic("Cannot allocate SWIOTLB overflow buffer!\n");
++
++ do {
++ rc = xen_create_contiguous_region(
++ (unsigned long)io_tlb_overflow_buffer,
++ get_order(io_tlb_overflow),
++ dma_bits);
++ } while (rc && dma_bits++ < max_dma_bits);
++ if (rc)
++ panic("No suitable physical memory available for SWIOTLB overflow buffer!\n");
+
+ iotlb_pfn_start = __pa(iotlb_virt_start) >> PAGE_SHIFT;
+ iotlb_pfn_end = iotlb_pfn_start + (bytes >> PAGE_SHIFT);
+
+ printk(KERN_INFO "Software IO TLB enabled: \n"
+ " Aperture: %lu megabytes\n"
-+ " Kernel range: 0x%016lx - 0x%016lx\n"
++ " Kernel range: %p - %p\n"
+ " Address size: %u bits\n",
+ bytes >> 20,
-+ (unsigned long)iotlb_virt_start,
-+ (unsigned long)iotlb_virt_start + bytes,
++ iotlb_virt_start, iotlb_virt_start + bytes,
+ dma_bits);
+}
+
@@ -10587,9 +9905,12 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ char *dev, *host, *kmp;
+ len = size;
+ while (len != 0) {
++ unsigned long flags;
++
+ if (((bytes = len) + buffer.offset) > PAGE_SIZE)
+ bytes = PAGE_SIZE - buffer.offset;
-+ kmp = kmap_atomic(buffer.page, KM_SWIOTLB);
++ local_irq_save(flags); /* protects KM_BOUNCE_READ */
++ kmp = kmap_atomic(buffer.page, KM_BOUNCE_READ);
+ dev = dma_addr + size - len;
+ host = kmp + buffer.offset;
+ if (dir == DMA_FROM_DEVICE) {
@@ -10597,7 +9918,8 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ /* inaccessible */;
+ } else
+ memcpy(dev, host, bytes);
-+ kunmap_atomic(kmp, KM_SWIOTLB);
++ kunmap_atomic(kmp, KM_BOUNCE_READ);
++ local_irq_restore(flags);
+ len -= bytes;
+ buffer.page++;
+ buffer.offset = 0;
@@ -10966,6 +10288,8 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ sg->dma_length, dir);
+}
+
++#ifdef CONFIG_HIGHMEM
++
+dma_addr_t
+swiotlb_map_page(struct device *hwdev, struct page *page,
+ unsigned long offset, size_t size,
@@ -10999,6 +10323,8 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ unmap_single(hwdev, bus_to_virt(dma_address), size, direction);
+}
+
++#endif
++
+int
+swiotlb_dma_mapping_error(dma_addr_t dma_addr)
+{
@@ -11026,13 +10352,11 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+EXPORT_SYMBOL(swiotlb_sync_single_for_device);
+EXPORT_SYMBOL(swiotlb_sync_sg_for_cpu);
+EXPORT_SYMBOL(swiotlb_sync_sg_for_device);
-+EXPORT_SYMBOL(swiotlb_map_page);
-+EXPORT_SYMBOL(swiotlb_unmap_page);
+EXPORT_SYMBOL(swiotlb_dma_mapping_error);
+EXPORT_SYMBOL(swiotlb_dma_supported);
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/arch/i386/kernel/sysenter.c source/arch/i386/kernel/sysenter.c
---- /scratch/src/linux-2.6.20.3/arch/i386/kernel/sysenter.c 2007-03-20 21:30:35.000000000 +0100
-+++ source/arch/i386/kernel/sysenter.c 2007-03-20 21:33:43.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 arch/i386/kernel/sysenter.c
+--- a/arch/i386/kernel/sysenter.c Wed Jul 18 12:23:24 2007 -0300
++++ b/arch/i386/kernel/sysenter.c Wed Aug 08 16:25:28 2007 -0300
@@ -23,6 +23,10 @@
#include <asm/pgtable.h>
#include <asm/unistd.h>
@@ -11060,7 +10384,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
}
/*
-@@ -76,6 +82,18 @@ int __init sysenter_setup(void)
+@@ -76,9 +82,26 @@ int __init sysenter_setup(void)
{
syscall_page = (void *)get_zeroed_page(GFP_ATOMIC);
@@ -11079,10 +10403,18 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
#ifdef CONFIG_COMPAT_VDSO
__set_fixmap(FIX_VDSO, __pa(syscall_page), PAGE_READONLY_EXEC);
printk("Compat vDSO mapped to %08lx.\n", __fix_to_virt(FIX_VDSO));
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/arch/i386/kernel/time-xen.c source/arch/i386/kernel/time-xen.c
---- /scratch/src/linux-2.6.20.3/arch/i386/kernel/time-xen.c 1970-01-01 01:00:00.000000000 +0100
-+++ source/arch/i386/kernel/time-xen.c 2007-03-20 21:26:26.000000000 +0100
-@@ -0,0 +1,1074 @@
++#else
++ /*
++ * In the non-compat case the ELF coredumping code needs the fixmap:
++ */
++ __set_fixmap(FIX_VDSO, __pa(syscall_page), PAGE_KERNEL_RO);
+ #endif
+
+ if (!boot_cpu_has(X86_FEATURE_SEP)) {
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 arch/i386/kernel/time-xen.c
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/arch/i386/kernel/time-xen.c Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,1091 @@
+/*
+ * linux/arch/i386/kernel/time.c
+ *
@@ -11153,7 +10485,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+
+#include <asm/hpet.h>
+
++#ifdef __i386__
+#include <asm/arch_hooks.h>
++#endif
+
+#include <xen/evtchn.h>
+#include <xen/interface/vcpu.h>
@@ -11236,26 +10570,6 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+}
+__setup("permitted_clock_jitter=", __permitted_clock_jitter);
+
-+#ifndef CONFIG_X86
-+int tsc_disable __devinitdata = 0;
-+#endif
-+
-+static void delay_tsc(unsigned long loops)
-+{
-+ unsigned long bclock, now;
-+
-+ rdtscl(bclock);
-+ do {
-+ rep_nop();
-+ rdtscl(now);
-+ } while ((now - bclock) < loops);
-+}
-+
-+struct timer_opts timer_tsc = {
-+ .name = "tsc",
-+ .delay = delay_tsc,
-+};
-+
+/*
+ * Scale a 64-bit delta by scaling and multiplying by a 32-bit fraction,
+ * yielding a 64-bit result.
@@ -11284,17 +10598,10 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ return product;
+}
+
-+int read_current_timer(unsigned long *timer_val)
-+{
-+ rdtscl(*timer_val);
-+ return 0;
-+}
-+
+void init_cpu_khz(void)
+{
+ u64 __cpu_khz = 1000000ULL << US_SCALE;
-+ struct vcpu_time_info *info;
-+ info = &HYPERVISOR_shared_info->vcpu_info[0].time;
++ struct vcpu_time_info *info = &vcpu_info(0)->time;
+ do_div(__cpu_khz, info->tsc_to_system_mul);
+ if (info->tsc_shift < 0)
+ cpu_khz = __cpu_khz << -info->tsc_shift;
@@ -11363,14 +10670,13 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ * Reads a consistent set of time-base values from Xen, into a shadow data
+ * area.
+ */
-+static void get_time_values_from_xen(void)
++static void get_time_values_from_xen(int cpu)
+{
-+ shared_info_t *s = HYPERVISOR_shared_info;
+ struct vcpu_time_info *src;
+ struct shadow_time_info *dst;
+
-+ src = &s->vcpu_info[smp_processor_id()].time;
-+ dst = &per_cpu(shadow_time, smp_processor_id());
++ src = &vcpu_info(cpu)->time;
++ dst = &per_cpu(shadow_time, cpu);
+
+ do {
+ dst->version = src->version;
@@ -11390,7 +10696,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ struct vcpu_time_info *src;
+ struct shadow_time_info *dst;
+
-+ src = &HYPERVISOR_shared_info->vcpu_info[cpu].time;
++ src = &vcpu_info(cpu)->time;
+ dst = &per_cpu(shadow_time, cpu);
+
+ rmb();
@@ -11474,7 +10780,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ * overflowed). Detect that and recalculate
+ * with fresh values.
+ */
-+ get_time_values_from_xen();
++ get_time_values_from_xen(cpu);
+ continue;
+ }
+ } while (read_seqretry(&xtime_lock, seq) ||
@@ -11499,7 +10805,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ s64 nsec;
+ unsigned int cpu;
+ struct shadow_time_info *shadow;
-+ dom0_op_t op;
++ struct xen_platform_op op;
+
+ if ((unsigned long)tv->tv_nsec >= NSEC_PER_SEC)
+ return -EINVAL;
@@ -11518,17 +10824,17 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ nsec = tv->tv_nsec - get_nsec_offset(shadow);
+ if (time_values_up_to_date(cpu))
+ break;
-+ get_time_values_from_xen();
++ get_time_values_from_xen(cpu);
+ }
+ sec = tv->tv_sec;
+ __normalize_time(&sec, &nsec);
+
+ if (is_initial_xendomain() && !independent_wallclock) {
-+ op.cmd = DOM0_SETTIME;
++ op.cmd = XENPF_settime;
+ op.u.settime.secs = sec;
+ op.u.settime.nsecs = nsec;
+ op.u.settime.system_time = shadow->system_timestamp;
-+ HYPERVISOR_dom0_op(&op);
++ HYPERVISOR_platform_op(&op);
+ update_wallclock();
+ } else if (independent_wallclock) {
+ nsec -= shadow->system_timestamp;
@@ -11552,7 +10858,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+{
+ time_t sec;
+ s64 nsec;
-+ dom0_op_t op;
++ struct xen_platform_op op;
+
+ if (!ntp_synced() || independent_wallclock || !is_initial_xendomain())
+ return;
@@ -11563,11 +10869,11 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ nsec = xtime.tv_nsec;
+ __normalize_time(&sec, &nsec);
+
-+ op.cmd = DOM0_SETTIME;
++ op.cmd = XENPF_settime;
+ op.u.settime.secs = sec;
+ op.u.settime.nsecs = nsec;
+ op.u.settime.system_time = processed_system_time;
-+ HYPERVISOR_dom0_op(&op);
++ HYPERVISOR_platform_op(&op);
+
+ update_wallclock();
+
@@ -11586,6 +10892,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ return 0;
+
+ /* gets recalled with irq locally disabled */
++ /* XXX - does irqsave resolve this? -johnstul */
+ spin_lock_irqsave(&rtc_lock, flags);
+ retval = set_wallclock(nowtime);
+ spin_unlock_irqrestore(&rtc_lock, flags);
@@ -11609,7 +10916,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ barrier();
+ time = shadow->system_timestamp + get_nsec_offset(shadow);
+ if (!time_values_up_to_date(cpu))
-+ get_time_values_from_xen();
++ get_time_values_from_xen(cpu);
+ barrier();
+ } while (local_time_version != shadow->version);
+
@@ -11619,10 +10926,12 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+}
+EXPORT_SYMBOL(monotonic_clock);
+
++#ifdef __x86_64__
+unsigned long long sched_clock(void)
+{
+ return monotonic_clock();
+}
++#endif
+
+unsigned long profile_pc(struct pt_regs *regs)
+{
@@ -11652,6 +10961,11 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+}
+EXPORT_SYMBOL(profile_pc);
+
++/*
++ * This is the same as the above, except we _also_ save the current
++ * Time Stamp Counter value at the time of the timer interrupt, so that
++ * we later on can estimate the time of day more exactly.
++ */
+irqreturn_t timer_interrupt(int irq, void *dev_id)
+{
+ s64 delta, delta_cpu, stolen, blocked;
@@ -11660,10 +10974,17 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ struct shadow_time_info *shadow = &per_cpu(shadow_time, cpu);
+ struct vcpu_runstate_info *runstate = &per_cpu(runstate, cpu);
+
++ /*
++ * Here we are in the timer irq handler. We just have irqs locally
++ * disabled but we don't know if the timer_bh is running on the other
++ * CPU. We need to avoid to SMP race with it. NOTE: we don' t need
++ * the irq version of write_lock because as just said we have irq
++ * locally disabled. -arca
++ */
+ write_seqlock(&xtime_lock);
+
+ do {
-+ get_time_values_from_xen();
++ get_time_values_from_xen(cpu);
+
+ /* Obtain a consistent snapshot of elapsed wallclock cycles. */
+ delta = delta_cpu =
@@ -11750,7 +11071,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ if (delta_cpu > 0) {
+ do_div(delta_cpu, NS_PER_TICK);
+ per_cpu(processed_system_time, cpu) += delta_cpu * NS_PER_TICK;
-+ if (user_mode(get_irq_regs()))
++ if (user_mode_vm(get_irq_regs()))
+ account_user_time(current, (cputime_t)delta_cpu);
+ else
+ account_system_time(current, HARDIRQ_OFFSET,
@@ -11764,7 +11085,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ /* Local timer processing (see update_process_times()). */
+ run_local_timers();
+ if (rcu_pending(cpu))
-+ rcu_check_callbacks(cpu, user_mode(get_irq_regs()));
++ rcu_check_callbacks(cpu, user_mode_vm(get_irq_regs()));
+ scheduler_tick();
+ run_posix_cpu_timers(current);
+// JQ: Why this works on 2.6.16 & 2.6.18 and generates a page
@@ -11961,6 +11282,10 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ BUG_ON(per_cpu(timer_irq, 0) < 0);
+}
+
++static struct vcpu_set_periodic_timer xen_set_periodic_tick = {
++ .period_ns = NS_PER_TICK
++};
++
+void __init time_init(void)
+{
+#ifdef CONFIG_HPET_TIMER
@@ -11973,7 +11298,11 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ return;
+ }
+#endif
-+ get_time_values_from_xen();
++
++ HYPERVISOR_vcpu_op(VCPUOP_set_periodic_timer, 0,
++ &xen_set_periodic_tick);
++
++ get_time_values_from_xen(0);
+
+ processed_system_time = per_cpu(shadow_time, 0).system_timestamp;
+ per_cpu(processed_system_time, 0) = processed_system_time;
@@ -12022,8 +11351,10 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ */
+static void stop_hz_timer(void)
+{
++ struct vcpu_set_singleshot_timer singleshot;
+ unsigned int cpu = smp_processor_id();
+ unsigned long j;
++ int rc;
+
+ cpu_set(cpu, nohz_cpu_mask);
+
@@ -12043,8 +11374,16 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ j = jiffies + 1;
+ }
+
-+ if (HYPERVISOR_set_timer_op(jiffies_to_st(j)) != 0)
-+ BUG();
++ singleshot.timeout_abs_ns = jiffies_to_st(j);
++ singleshot.flags = 0;
++ rc = HYPERVISOR_vcpu_op(VCPUOP_set_singleshot_timer, cpu, &singleshot);
++#if CONFIG_XEN_COMPAT <= 0x030004
++ if (rc) {
++ BUG_ON(rc != -ENOSYS);
++ rc = HYPERVISOR_set_timer_op(singleshot.timeout_abs_ns);
++ }
++#endif
++ BUG_ON(rc);
+}
+
+static void start_hz_timer(void)
@@ -12068,16 +11407,23 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+}
+EXPORT_SYMBOL(halt);
+
-+/* No locking required. We are only CPU running, and interrupts are off. */
++/* No locking required. Interrupts are disabled on all CPUs. */
+void time_resume(void)
+{
++ unsigned int cpu;
++
+ init_cpu_khz();
+
-+ get_time_values_from_xen();
++ for_each_online_cpu(cpu) {
++ HYPERVISOR_vcpu_op(VCPUOP_set_periodic_timer, cpu,
++ &xen_set_periodic_tick);
++ get_time_values_from_xen(cpu);
++ per_cpu(processed_system_time, cpu) =
++ per_cpu(shadow_time, 0).system_timestamp;
++ init_missing_ticks_accounting(cpu);
++ }
+
+ processed_system_time = per_cpu(shadow_time, 0).system_timestamp;
-+ per_cpu(processed_system_time, 0) = processed_system_time;
-+ init_missing_ticks_accounting(0);
+
+ update_wallclock();
+}
@@ -12091,6 +11437,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+
+ BUG_ON(cpu == 0);
+
++ HYPERVISOR_vcpu_op(VCPUOP_set_periodic_timer, cpu,
++ &xen_set_periodic_tick);
++
+ do {
+ seq = read_seqbegin(&xtime_lock);
+ /* Use cpu0 timestamp: cpu's shadow is not initialised yet. */
@@ -12157,32 +11506,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ return 0;
+}
+__initcall(xen_sysctl_init);
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/arch/i386/kernel/traps.c source/arch/i386/kernel/traps.c
---- /scratch/src/linux-2.6.20.3/arch/i386/kernel/traps.c 2007-02-04 19:44:54.000000000 +0100
-+++ source/arch/i386/kernel/traps.c 2007-03-20 21:26:26.000000000 +0100
-@@ -646,18 +646,11 @@ mem_parity_error(unsigned char reason, s
- static __kprobes 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 __kprobes void
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/arch/i386/kernel/traps-xen.c source/arch/i386/kernel/traps-xen.c
---- /scratch/src/linux-2.6.20.3/arch/i386/kernel/traps-xen.c 1970-01-01 01:00:00.000000000 +0100
-+++ source/arch/i386/kernel/traps-xen.c 2007-03-20 21:26:26.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 arch/i386/kernel/traps-xen.c
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/arch/i386/kernel/traps-xen.c Wed Aug 08 16:25:28 2007 -0300
@@ -0,0 +1,1132 @@
+/*
+ * linux/arch/i386/traps.c
@@ -13316,29 +12642,21 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ return 1;
+}
+__setup("kstack=", kstack_setup);
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/arch/i386/kernel/tsc.c source/arch/i386/kernel/tsc.c
---- /scratch/src/linux-2.6.20.3/arch/i386/kernel/tsc.c 2007-02-04 19:44:54.000000000 +0100
-+++ source/arch/i386/kernel/tsc.c 2007-03-20 21:26:26.000000000 +0100
-@@ -100,6 +100,7 @@ static inline unsigned long long cycles_
- return (cyc * cyc2ns_scale) >> CYC2NS_SCALE_FACTOR;
- }
-
-+#ifndef CONFIG_XEN
- /*
- * Scheduler clock - returns current time in nanosec units.
- */
-@@ -123,6 +124,7 @@ unsigned long long sched_clock(void)
- /* return the value in ns */
- return cycles_2_ns(this_offset);
- }
-+#endif
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 arch/i386/kernel/traps.c
+--- a/arch/i386/kernel/traps.c Wed Jul 18 12:23:24 2007 -0300
++++ b/arch/i386/kernel/traps.c Wed Aug 08 16:25:28 2007 -0300
+@@ -402,7 +402,6 @@ void die(const char * str, struct pt_reg
+ unsigned short ss;
- static unsigned long calculate_cpu_khz(void)
- {
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/arch/i386/kernel/vm86.c source/arch/i386/kernel/vm86.c
---- /scratch/src/linux-2.6.20.3/arch/i386/kernel/vm86.c 2007-02-04 19:44:54.000000000 +0100
-+++ source/arch/i386/kernel/vm86.c 2007-03-20 21:26:26.000000000 +0100
-@@ -125,7 +125,9 @@ static int copy_vm86_regs_from_user(stru
+ report_bug(regs->eip);
+-
+ printk(KERN_EMERG "%s: %04lx [#%d]\n", str, err & 0xffff, ++die_counter);
+ #ifdef CONFIG_PREEMPT
+ printk(KERN_EMERG "PREEMPT ");
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 arch/i386/kernel/vm86.c
+--- a/arch/i386/kernel/vm86.c Wed Jul 18 12:23:24 2007 -0300
++++ b/arch/i386/kernel/vm86.c Wed Aug 08 16:25:28 2007 -0300
+@@ -125,7 +125,9 @@ struct pt_regs * FASTCALL(save_v86_state
struct pt_regs * FASTCALL(save_v86_state(struct kernel_vm86_regs * regs));
struct pt_regs * fastcall save_v86_state(struct kernel_vm86_regs * regs)
{
@@ -13392,9 +12710,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
tsk->thread.screen_bitmap = info->screen_bitmap;
if (info->flags & VM86_SCREEN_BITMAP)
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/arch/i386/kernel/vmlinux.lds.S source/arch/i386/kernel/vmlinux.lds.S
---- /scratch/src/linux-2.6.20.3/arch/i386/kernel/vmlinux.lds.S 2007-02-04 19:44:54.000000000 +0100
-+++ source/arch/i386/kernel/vmlinux.lds.S 2007-03-20 21:26:26.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 arch/i386/kernel/vmlinux.lds.S
+--- a/arch/i386/kernel/vmlinux.lds.S Wed Jul 18 12:23:24 2007 -0300
++++ b/arch/i386/kernel/vmlinux.lds.S Wed Aug 08 16:25:28 2007 -0300
@@ -35,7 +35,13 @@ PHDRS {
}
SECTIONS
@@ -13409,9 +12727,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
phys_startup_32 = startup_32 - LOAD_OFFSET;
/* read-only */
.text : AT(ADDR(.text) - LOAD_OFFSET) {
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/arch/i386/kernel/vsyscall-note-xen.S source/arch/i386/kernel/vsyscall-note-xen.S
---- /scratch/src/linux-2.6.20.3/arch/i386/kernel/vsyscall-note-xen.S 1970-01-01 01:00:00.000000000 +0100
-+++ source/arch/i386/kernel/vsyscall-note-xen.S 2007-03-20 21:26:26.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 arch/i386/kernel/vsyscall-note-xen.S
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/arch/i386/kernel/vsyscall-note-xen.S Wed Aug 08 16:25:28 2007 -0300
@@ -0,0 +1,32 @@
+/*
+ * This supplies .note.* sections to go into the PT_NOTE inside the vDSO text.
@@ -13443,147 +12761,21 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#define NOTE_KERNELCAP_END ASM_ELF_NOTE_END
+
+NOTE_KERNELCAP_BEGIN(1, 1)
-+NOTE_KERNELCAP(1, "nosegneg") /* Change 1 back to 0 when glibc is fixed! */
++NOTE_KERNELCAP(0, "nosegneg")
+NOTE_KERNELCAP_END
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/arch/i386/lib/delay.c source/arch/i386/lib/delay.c
---- /scratch/src/linux-2.6.20.3/arch/i386/lib/delay.c 2007-02-04 19:44:54.000000000 +0100
-+++ source/arch/i386/lib/delay.c 2007-03-21 14:49:46.000000000 +0100
-@@ -60,6 +60,7 @@ void use_tsc_delay(void)
- delay_fn = delay_tsc;
- }
-
-+#ifndef CONFIG_X86_XEN
- int read_current_timer(unsigned long *timer_val)
- {
- if (delay_fn == delay_tsc) {
-@@ -68,6 +69,7 @@ int read_current_timer(unsigned long *ti
- }
- return -1;
- }
-+#endif
-
- void __delay(unsigned long loops)
- {
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/arch/i386/mach-xen/irqflags.c source/arch/i386/mach-xen/irqflags.c
---- /scratch/src/linux-2.6.20.3/arch/i386/mach-xen/irqflags.c 1970-01-01 01:00:00.000000000 +0100
-+++ source/arch/i386/mach-xen/irqflags.c 2007-03-20 21:26:26.000000000 +0100
-@@ -0,0 +1,103 @@
-+#include <linux/module.h>
-+#include <linux/smp.h>
-+#include <asm/irqflags.h>
-+#include <asm/hypervisor.h>
-+
-+/* interrupt control.. */
-+
-+/*
-+ * The use of 'barrier' in the following reflects their use as local-lock
-+ * operations. Reentrancy must be prevented (e.g., __cli()) /before/ following
-+ * critical operations are executed. All critical operations must complete
-+ * /before/ reentrancy is permitted (e.g., __sti()). Alpha architecture also
-+ * includes these barriers, for example.
-+ */
-+
-+unsigned long __raw_local_save_flags(void)
-+{
-+ struct vcpu_info *_vcpu;
-+ unsigned long flags;
-+
-+ preempt_disable();
-+ _vcpu = &HYPERVISOR_shared_info->vcpu_info[__vcpu_id];
-+ flags = _vcpu->evtchn_upcall_mask;
-+ preempt_enable();
-+
-+ return flags;
-+}
-+EXPORT_SYMBOL(__raw_local_save_flags);
-+
-+void raw_local_irq_restore(unsigned long flags)
-+{
-+ struct vcpu_info *_vcpu;
-+
-+ preempt_disable();
-+ _vcpu = &HYPERVISOR_shared_info->vcpu_info[__vcpu_id];
-+ if ((_vcpu->evtchn_upcall_mask = flags) == 0) {
-+ barrier(); /* unmask then check (avoid races) */
-+ if (unlikely(_vcpu->evtchn_upcall_pending))
-+ force_evtchn_callback();
-+ preempt_enable();
-+ } else
-+ preempt_enable_no_resched();
-+}
-+EXPORT_SYMBOL(raw_local_irq_restore);
-+
-+void raw_local_irq_disable(void)
-+{
-+ struct vcpu_info *_vcpu;
-+
-+ preempt_disable();
-+ _vcpu = &HYPERVISOR_shared_info->vcpu_info[__vcpu_id];
-+ _vcpu->evtchn_upcall_mask = 1;
-+ preempt_enable_no_resched();
-+}
-+EXPORT_SYMBOL(raw_local_irq_disable);
-+
-+void raw_local_irq_enable(void)
-+{
-+ struct vcpu_info *_vcpu;
-+
-+ preempt_disable();
-+ _vcpu = &HYPERVISOR_shared_info->vcpu_info[__vcpu_id];
-+ _vcpu->evtchn_upcall_mask = 0;
-+ barrier(); /* unmask then check (avoid races) */
-+ if (unlikely(_vcpu->evtchn_upcall_pending))
-+ force_evtchn_callback();
-+ preempt_enable();
-+}
-+EXPORT_SYMBOL(raw_local_irq_enable);
-+
-+/*
-+ * For spinlocks, etc.:
-+ */
-+
-+unsigned long __raw_local_irq_save(void)
-+{
-+ struct vcpu_info *_vcpu;
-+ unsigned long flags;
-+
-+ preempt_disable();
-+ _vcpu = &HYPERVISOR_shared_info->vcpu_info[__vcpu_id];
-+ flags = _vcpu->evtchn_upcall_mask;
-+ _vcpu->evtchn_upcall_mask = 1;
-+ preempt_enable_no_resched();
-+
-+ return flags;
-+}
-+EXPORT_SYMBOL(__raw_local_irq_save);
-+
-+/* Cannot use preempt_enable() here as we would recurse in preempt_sched(). */
-+int raw_irqs_disabled(void)
-+{
-+ struct vcpu_info *_vcpu;
-+ int disabled;
-+
-+ preempt_disable();
-+ _vcpu = &HYPERVISOR_shared_info->vcpu_info[__vcpu_id];
-+ disabled = (_vcpu->evtchn_upcall_mask != 0);
-+ preempt_enable_no_resched();
-+
-+ return disabled;
-+}
-+EXPORT_SYMBOL(raw_irqs_disabled);
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/arch/i386/mach-xen/Makefile source/arch/i386/mach-xen/Makefile
---- /scratch/src/linux-2.6.20.3/arch/i386/mach-xen/Makefile 1970-01-01 01:00:00.000000000 +0100
-+++ source/arch/i386/mach-xen/Makefile 2007-03-20 21:26:26.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 arch/i386/mach-xen/Makefile
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/arch/i386/mach-xen/Makefile Wed Aug 08 16:25:28 2007 -0300
@@ -0,0 +1,5 @@
+#
+# Makefile for the linux kernel.
+#
+
-+obj-y := setup.o irqflags.o
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/arch/i386/mach-xen/setup.c source/arch/i386/mach-xen/setup.c
---- /scratch/src/linux-2.6.20.3/arch/i386/mach-xen/setup.c 1970-01-01 01:00:00.000000000 +0100
-+++ source/arch/i386/mach-xen/setup.c 2007-03-20 21:26:26.000000000 +0100
-@@ -0,0 +1,169 @@
++obj-y := setup.o
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 arch/i386/mach-xen/setup.c
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/arch/i386/mach-xen/setup.c Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,168 @@
+/*
+ * Machine specific setup for generic
+ */
@@ -13653,7 +12845,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ if ( rc == -ENOSYS ) {
+ memmap.nr_entries = 1;
+ map[0].addr = 0ULL;
-+ map[0].size = PFN_PHYS(xen_start_info->nr_pages);
++ map[0].size = PFN_PHYS((unsigned long long)xen_start_info->nr_pages);
+ /* 8MB slack (to balance backend allocations). */
+ map[0].size += 8ULL << 20;
+ map[0].type = E820_RAM;
@@ -13668,6 +12860,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ return "Xen";
+}
+
++
+extern void hypervisor_callback(void);
+extern void failsafe_callback(void);
+extern void nmi(void);
@@ -13699,7 +12892,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ ret = HYPERVISOR_callback_op(CALLBACKOP_register, &event);
+ if (ret == 0)
+ ret = HYPERVISOR_callback_op(CALLBACKOP_register, &failsafe);
-+#ifdef CONFIG_XEN_COMPAT_030002
++#if CONFIG_XEN_COMPAT <= 0x030002
+ if (ret == -ENOSYS)
+ ret = HYPERVISOR_set_callbacks(
+ event.address.cs, event.address.eip,
@@ -13708,19 +12901,17 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ BUG_ON(ret);
+
+ ret = HYPERVISOR_callback_op(CALLBACKOP_register, &nmi_cb);
-+#ifdef CONFIG_XEN_COMPAT_030002
++#if CONFIG_XEN_COMPAT <= 0x030002
+ if (ret == -ENOSYS) {
+ static struct xennmi_callback __initdata cb = {
+ .handler_address = (unsigned long)nmi
+ };
+
-+ cb.handler_address = nmi_cb.address.eip;
+ HYPERVISOR_nmi_op(XENNMI_register_callback, &cb);
+ }
+#endif
+
-+ if (HYPERVISOR_xen_version(XENVER_platform_parameters,
-+ &pp) == 0) {
++ if (HYPERVISOR_xen_version(XENVER_platform_parameters, &pp) == 0) {
+ hypervisor_virt_start = pp.virt_start;
+ set_fixaddr_top();
+ }
@@ -13753,69 +12944,25 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ /* Save unparsed command line copy for /proc/cmdline */
+ saved_command_line[max_cmdline-1] = '\0';
+}
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/arch/i386/Makefile source/arch/i386/Makefile
---- /scratch/src/linux-2.6.20.3/arch/i386/Makefile 2007-02-04 19:44:54.000000000 +0100
-+++ source/arch/i386/Makefile 2007-03-20 21:26:26.000000000 +0100
-@@ -60,6 +60,11 @@ AFLAGS += $(call as-instr,.cfi_startproc
-
- CFLAGS += $(cflags-y)
-
-+cppflags-$(CONFIG_XEN) += \
-+ -D__XEN_INTERFACE_VERSION__=$(CONFIG_XEN_INTERFACE_VERSION)
-+
-+CPPFLAGS += $(cppflags-y)
-+
- # Default subarch .c files
- mcore-y := mach-default
-
-@@ -83,6 +88,10 @@ mcore-$(CONFIG_X86_BIGSMP) := mach-defau
- mflags-$(CONFIG_X86_SUMMIT) := -Iinclude/asm-i386/mach-summit
- mcore-$(CONFIG_X86_SUMMIT) := mach-default
-
-+# Xen subarch support
-+mflags-$(CONFIG_X86_XEN) := -Iinclude/asm-i386/mach-xen
-+mcore-$(CONFIG_X86_XEN) := mach-xen
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 arch/i386/mm/Makefile
+--- a/arch/i386/mm/Makefile Wed Jul 18 12:23:24 2007 -0300
++++ b/arch/i386/mm/Makefile Wed Aug 08 16:25:28 2007 -0300
+@@ -8,3 +8,11 @@ obj-$(CONFIG_HUGETLB_PAGE) += hugetlbpag
+ obj-$(CONFIG_HUGETLB_PAGE) += hugetlbpage.o
+ obj-$(CONFIG_HIGHMEM) += highmem.o
+ obj-$(CONFIG_BOOT_IOREMAP) += boot_ioremap.o
+
- # generic subarchitecture
- mflags-$(CONFIG_X86_GENERICARCH) := -Iinclude/asm-i386/mach-generic
- mcore-$(CONFIG_X86_GENERICARCH) := mach-default
-@@ -117,6 +126,19 @@ boot := arch/i386/boot
- PHONY += zImage bzImage compressed zlilo bzlilo \
- zdisk bzdisk fdimage fdimage144 fdimage288 isoimage install
-
+ifdef CONFIG_XEN
-+CPPFLAGS := -Iinclude$(if $(KBUILD_SRC),2)/asm/mach-xen $(CPPFLAGS)
-+head-y := arch/i386/kernel/head-xen.o arch/i386/kernel/init_task-xen.o
-+boot := arch/i386/boot-xen
-+.PHONY: vmlinuz
-+all: vmlinuz
++include $(srctree)/scripts/Makefile.xen
+
-+vmlinuz: vmlinux
-+ $(Q)$(MAKE) $(build)=$(boot) $@
++obj-y += hypervisor.o
+
-+install:
-+ $(Q)$(MAKE) $(build)=$(boot) XENGUEST=$(XENGUEST) $@
-+else
- all: bzImage
-
- # KBUILD_IMAGE specify target image being built
-@@ -139,6 +161,7 @@ fdimage fdimage144 fdimage288 isoimage:
-
- install:
- $(Q)$(MAKE) $(build)=$(boot) BOOTIMAGE=$(KBUILD_IMAGE) install
++obj-y := $(call cherrypickxen, $(obj-y))
+endif
-
- archclean:
- $(Q)$(MAKE) $(clean)=arch/i386/boot
-@@ -157,3 +180,4 @@ endef
- CLEAN_FILES += arch/$(ARCH)/boot/fdimage \
- arch/$(ARCH)/boot/image.iso \
- arch/$(ARCH)/boot/mtools.conf
-+CLEAN_FILES += vmlinuz vmlinux-stripped
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/arch/i386/mm/fault-xen.c source/arch/i386/mm/fault-xen.c
---- /scratch/src/linux-2.6.20.3/arch/i386/mm/fault-xen.c 1970-01-01 01:00:00.000000000 +0100
-+++ source/arch/i386/mm/fault-xen.c 2007-03-20 21:26:26.000000000 +0100
-@@ -0,0 +1,756 @@
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 arch/i386/mm/fault-xen.c
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/arch/i386/mm/fault-xen.c Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,760 @@
+/*
+ * linux/arch/i386/mm/fault.c
+ *
@@ -14075,16 +13222,19 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ p += (address >> 30) * 2;
+ printk(KERN_ALERT "%08lx -> *pde = %08lx:%08lx\n", page, p[1], p[0]);
+ if (p[0] & 1) {
-+ mfn = (p[0] >> PAGE_SHIFT) | ((p[1] & 0x7) << 20);
++ mfn = (p[0] >> PAGE_SHIFT) | (p[1] << 20);
+ page = mfn_to_pfn(mfn) << PAGE_SHIFT;
+ p = (unsigned long *)__va(page);
+ address &= 0x3fffffff;
+ p += (address >> 21) * 2;
+ printk(KERN_ALERT "%08lx -> *pme = %08lx:%08lx\n",
+ page, p[1], p[0]);
-+#ifndef CONFIG_HIGHPTE
++ mfn = (p[0] >> PAGE_SHIFT) | (p[1] << 20);
++#ifdef CONFIG_HIGHPTE
++ if (mfn_to_pfn(mfn) >= highstart_pfn)
++ return;
++#endif
+ if (p[0] & 1) {
-+ mfn = (p[0] >> PAGE_SHIFT) | ((p[1] & 0x7) << 20);
+ page = mfn_to_pfn(mfn) << PAGE_SHIFT;
+ p = (unsigned long *) __va(page);
+ address &= 0x001fffff;
@@ -14092,7 +13242,6 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ printk(KERN_ALERT "%08lx -> *pte = %08lx:%08lx\n",
+ page, p[1], p[0]);
+ }
-+#endif
+ }
+}
+#else
@@ -14107,11 +13256,14 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ machine_to_phys(page));
+ /*
+ * We must not directly access the pte in the highpte
-+ * case, the page table might be allocated in highmem.
++ * case if the page table is located in highmem.
+ * And lets rather not kmap-atomic the pte, just in case
+ * it's allocated already.
+ */
-+#ifndef CONFIG_HIGHPTE
++#ifdef CONFIG_HIGHPTE
++ if ((page >> PAGE_SHIFT) >= highstart_pfn)
++ return;
++#endif
+ if ((page & 1) && oops_may_print()) {
+ page &= PAGE_MASK;
+ address &= 0x003ff000;
@@ -14120,7 +13272,6 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ printk(KERN_ALERT "*pte = ma %08lx pa %08lx\n", page,
+ machine_to_phys(page));
+ }
-+#endif
+}
+#endif
+
@@ -14494,8 +13645,8 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ printk(" at virtual address %08lx\n",address);
+ printk(KERN_ALERT " printing eip:\n");
+ printk("%08lx\n", regs->eip);
-+ dump_fault_path(address);
+ }
++ dump_fault_path(address);
+ tsk->thread.cr2 = address;
+ tsk->thread.trap_no = 14;
+ tsk->thread.error_code = error_code;
@@ -14536,7 +13687,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ force_sig_info_fault(SIGBUS, BUS_ADRERR, address, tsk);
+}
+
-+#ifndef CONFIG_X86_PAE
++#if !HAVE_SHARED_KERNEL_PMD
+void vmalloc_sync_all(void)
+{
+ /*
@@ -14572,10 +13723,10 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ }
+}
+#endif
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/arch/i386/mm/highmem-xen.c source/arch/i386/mm/highmem-xen.c
---- /scratch/src/linux-2.6.20.3/arch/i386/mm/highmem-xen.c 1970-01-01 01:00:00.000000000 +0100
-+++ source/arch/i386/mm/highmem-xen.c 2007-03-20 21:26:26.000000000 +0100
-@@ -0,0 +1,117 @@
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 arch/i386/mm/highmem-xen.c
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/arch/i386/mm/highmem-xen.c Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,120 @@
+#include <linux/highmem.h>
+#include <linux/module.h>
+
@@ -14631,7 +13782,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+/* Same as kmap_atomic but with PAGE_KERNEL_RO page protection. */
+void *kmap_atomic_pte(struct page *page, enum km_type type)
+{
-+ return __kmap_atomic(page, type, PAGE_KERNEL_RO);
++ return __kmap_atomic(page, type,
++ test_bit(PG_pinned, &page->flags)
++ ? PAGE_KERNEL_RO : kmap_prot);
+}
+
+void kunmap_atomic(void *kvaddr, enum km_type type)
@@ -14691,12 +13844,13 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+EXPORT_SYMBOL(kmap);
+EXPORT_SYMBOL(kunmap);
+EXPORT_SYMBOL(kmap_atomic);
++EXPORT_SYMBOL(kmap_atomic_pte);
+EXPORT_SYMBOL(kunmap_atomic);
+EXPORT_SYMBOL(kmap_atomic_to_page);
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/arch/i386/mm/hypervisor.c source/arch/i386/mm/hypervisor.c
---- /scratch/src/linux-2.6.20.3/arch/i386/mm/hypervisor.c 1970-01-01 01:00:00.000000000 +0100
-+++ source/arch/i386/mm/hypervisor.c 2007-03-20 21:26:26.000000000 +0100
-@@ -0,0 +1,449 @@
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 arch/i386/mm/hypervisor.c
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/arch/i386/mm/hypervisor.c Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,451 @@
+/******************************************************************************
+ * mm/hypervisor.c
+ *
@@ -14845,7 +13999,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ if ( cpus_empty(*mask) )
+ return;
+ op.cmd = MMUEXT_TLB_FLUSH_MULTI;
-+ op.arg2.vcpumask = mask->bits;
++ set_xen_guest_handle(op.arg2.vcpumask, mask->bits);
+ BUG_ON(HYPERVISOR_mmuext_op(&op, 1, NULL, DOMID_SELF) < 0);
+}
+
@@ -14864,7 +14018,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ return;
+ op.cmd = MMUEXT_INVLPG_MULTI;
+ op.arg1.linear_addr = ptr & PAGE_MASK;
-+ op.arg2.vcpumask = mask->bits;
++ set_xen_guest_handle(op.arg2.vcpumask, mask->bits);
+ BUG_ON(HYPERVISOR_mmuext_op(&op, 1, NULL, DOMID_SELF) < 0);
+}
+
@@ -15002,7 +14156,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ set_phys_to_machine((__pa(vstart)>>PAGE_SHIFT)+i,
+ INVALID_P2M_ENTRY);
+ }
-+ if (HYPERVISOR_multicall(cr_mcl, i))
++ if (HYPERVISOR_multicall_check(cr_mcl, i, NULL))
+ BUG();
+
+ /* 2. Get a new contiguous memory extent. */
@@ -15011,7 +14165,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ success = (exchange.nr_exchanged == (1UL << order));
+ BUG_ON(!success && ((exchange.nr_exchanged != 0) || (rc == 0)));
+ BUG_ON(success && (rc != 0));
-+#ifdef CONFIG_XEN_COMPAT_030002
++#if CONFIG_XEN_COMPAT <= 0x030002
+ if (unlikely(rc == -ENOSYS)) {
+ /* Compatibility when XENMEM_exchange is unsupported. */
+ if (HYPERVISOR_memory_op(XENMEM_decrease_reservation,
@@ -15041,7 +14195,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ cr_mcl[i - 1].args[MULTI_UVMFLAGS_INDEX] = order
+ ? UVMF_TLB_FLUSH|UVMF_ALL
+ : UVMF_INVLPG|UVMF_ALL;
-+ if (HYPERVISOR_multicall(cr_mcl, i))
++ if (HYPERVISOR_multicall_check(cr_mcl, i, NULL))
+ BUG();
+
+ if (success)
@@ -15052,6 +14206,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+
+ return success ? 0 : -ENOMEM;
+}
++EXPORT_SYMBOL_GPL(xen_create_contiguous_region);
+
+void xen_destroy_contiguous_region(unsigned long vstart, unsigned int order)
+{
@@ -15099,7 +14254,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ INVALID_P2M_ENTRY);
+ out_frames[i] = (__pa(vstart) >> PAGE_SHIFT) + i;
+ }
-+ if (HYPERVISOR_multicall(cr_mcl, i))
++ if (HYPERVISOR_multicall_check(cr_mcl, i, NULL))
+ BUG();
+
+ /* 3. Do the exchange for non-contiguous MFNs. */
@@ -15107,7 +14262,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ success = (exchange.nr_exchanged == 1);
+ BUG_ON(!success && ((exchange.nr_exchanged != 0) || (rc == 0)));
+ BUG_ON(success && (rc != 0));
-+#ifdef CONFIG_XEN_COMPAT_030002
++#if CONFIG_XEN_COMPAT <= 0x030002
+ if (unlikely(rc == -ENOSYS)) {
+ /* Compatibility when XENMEM_exchange is unsupported. */
+ if (HYPERVISOR_memory_op(XENMEM_decrease_reservation,
@@ -15131,11 +14286,12 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ cr_mcl[i - 1].args[MULTI_UVMFLAGS_INDEX] = order
+ ? UVMF_TLB_FLUSH|UVMF_ALL
+ : UVMF_INVLPG|UVMF_ALL;
-+ if (HYPERVISOR_multicall(cr_mcl, i))
++ if (HYPERVISOR_multicall_check(cr_mcl, i, NULL))
+ BUG();
+
+ balloon_unlock(flags);
+}
++EXPORT_SYMBOL_GPL(xen_destroy_contiguous_region);
+
+#ifdef __i386__
+int write_ldt_entry(void *ldt, int entry, __u32 entry_a, __u32 entry_b)
@@ -15146,9 +14302,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ mach_lp, (u64)entry_a | ((u64)entry_b<<32));
+}
+#endif
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/arch/i386/mm/init-xen.c source/arch/i386/mm/init-xen.c
---- /scratch/src/linux-2.6.20.3/arch/i386/mm/init-xen.c 1970-01-01 01:00:00.000000000 +0100
-+++ source/arch/i386/mm/init-xen.c 2007-03-20 21:26:27.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 arch/i386/mm/init-xen.c
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/arch/i386/mm/init-xen.c Wed Aug 08 16:25:28 2007 -0300
@@ -0,0 +1,871 @@
+/*
+ * linux/arch/i386/mm/init.c
@@ -16021,9 +15177,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+}
+#endif
+
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/arch/i386/mm/ioremap-xen.c source/arch/i386/mm/ioremap-xen.c
---- /scratch/src/linux-2.6.20.3/arch/i386/mm/ioremap-xen.c 1970-01-01 01:00:00.000000000 +0100
-+++ source/arch/i386/mm/ioremap-xen.c 2007-03-20 21:26:27.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 arch/i386/mm/ioremap-xen.c
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/arch/i386/mm/ioremap-xen.c Wed Aug 08 16:25:28 2007 -0300
@@ -0,0 +1,443 @@
+/*
+ * arch/i386/mm/ioremap.c
@@ -16468,24 +15624,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ --nrpages;
+ }
+}
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/arch/i386/mm/Makefile source/arch/i386/mm/Makefile
---- /scratch/src/linux-2.6.20.3/arch/i386/mm/Makefile 2007-02-04 19:44:54.000000000 +0100
-+++ source/arch/i386/mm/Makefile 2007-03-20 21:26:26.000000000 +0100
-@@ -8,3 +8,11 @@ obj-$(CONFIG_NUMA) += discontig.o
- obj-$(CONFIG_HUGETLB_PAGE) += hugetlbpage.o
- obj-$(CONFIG_HIGHMEM) += highmem.o
- obj-$(CONFIG_BOOT_IOREMAP) += boot_ioremap.o
-+
-+ifdef CONFIG_XEN
-+include $(srctree)/scripts/Makefile.xen
-+
-+obj-y += hypervisor.o
-+
-+obj-y := $(call cherrypickxen, $(obj-y))
-+endif
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/arch/i386/mm/pageattr.c source/arch/i386/mm/pageattr.c
---- /scratch/src/linux-2.6.20.3/arch/i386/mm/pageattr.c 2007-02-04 19:44:54.000000000 +0100
-+++ source/arch/i386/mm/pageattr.c 2007-03-20 21:26:27.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 arch/i386/mm/pageattr.c
+--- a/arch/i386/mm/pageattr.c Wed Jul 18 12:23:24 2007 -0300
++++ b/arch/i386/mm/pageattr.c Wed Aug 08 16:25:28 2007 -0300
@@ -90,7 +90,7 @@ static void set_pmd_pte(pte_t *kpte, uns
unsigned long flags;
@@ -16495,10 +15636,10 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
return;
spin_lock_irqsave(&pgd_lock, flags);
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/arch/i386/mm/pgtable-xen.c source/arch/i386/mm/pgtable-xen.c
---- /scratch/src/linux-2.6.20.3/arch/i386/mm/pgtable-xen.c 1970-01-01 01:00:00.000000000 +0100
-+++ source/arch/i386/mm/pgtable-xen.c 2007-03-20 21:26:27.000000000 +0100
-@@ -0,0 +1,728 @@
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 arch/i386/mm/pgtable-xen.c
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/arch/i386/mm/pgtable-xen.c Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,748 @@
+/*
+ * linux/arch/i386/mm/pgtable.c
+ */
@@ -16526,7 +15667,6 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#include <asm/mmu_context.h>
+
+#include <xen/features.h>
-+#include <xen/foreign_page.h>
+#include <asm/hypervisor.h>
+
+static void pgd_test_and_unpin(pgd_t *pgd);
@@ -16719,6 +15859,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#ifdef CONFIG_X86_F00F_BUG
+ case FIX_F00F_IDT:
+#endif
++ case FIX_VDSO:
+ set_pte_pfn(address, phys >> PAGE_SHIFT, flags);
+ break;
+ default:
@@ -16762,21 +15903,27 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ pte = alloc_pages(GFP_KERNEL|__GFP_HIGHMEM|__GFP_REPEAT|__GFP_ZERO, 0);
+#else
+ pte = alloc_pages(GFP_KERNEL|__GFP_REPEAT|__GFP_ZERO, 0);
++#endif
+ if (pte) {
+ SetPageForeign(pte, pte_free);
+ init_page_count(pte);
+ }
-+#endif
+ return pte;
+}
+
+void pte_free(struct page *pte)
+{
-+ unsigned long va = (unsigned long)__va(page_to_pfn(pte)<<PAGE_SHIFT);
++ unsigned long pfn = page_to_pfn(pte);
+
-+ if (!pte_write(*virt_to_ptep(va)))
-+ BUG_ON(HYPERVISOR_update_va_mapping(
-+ va, pfn_pte(page_to_pfn(pte), PAGE_KERNEL), 0));
++ if (!PageHighMem(pte)) {
++ unsigned long va = (unsigned long)__va(pfn << PAGE_SHIFT);
++
++ if (!pte_write(*virt_to_ptep(va)))
++ if (HYPERVISOR_update_va_mapping(
++ va, pfn_pte(pfn, PAGE_KERNEL), 0))
++ BUG();
++ } else
++ clear_bit(PG_pinned, &pte->flags);
+
+ ClearPageForeign(pte);
+ init_page_count(pte);
@@ -17090,16 +16237,23 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ }
+}
+
-+static inline void pgd_walk_set_prot(void *pt, pgprot_t flags)
++static inline void pgd_walk_set_prot(struct page *page, pgprot_t flags)
+{
-+ struct page *page = virt_to_page(pt);
+ unsigned long pfn = page_to_pfn(page);
++ int rc;
+
-+ if (PageHighMem(page))
-+ return;
-+ BUG_ON(HYPERVISOR_update_va_mapping(
-+ (unsigned long)__va(pfn << PAGE_SHIFT),
-+ pfn_pte(pfn, flags), 0));
++ if (PageHighMem(page)) {
++ if (pgprot_val(flags) & _PAGE_RW)
++ clear_bit(PG_pinned, &page->flags);
++ else
++ set_bit(PG_pinned, &page->flags);
++ } else {
++ rc = HYPERVISOR_update_va_mapping(
++ (unsigned long)__va(pfn << PAGE_SHIFT),
++ pfn_pte(pfn, flags), 0);
++ if (rc)
++ BUG();
++ }
+}
+
+static void pgd_walk(pgd_t *pgd_base, pgprot_t flags)
@@ -17107,8 +16261,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ pgd_t *pgd = pgd_base;
+ pud_t *pud;
+ pmd_t *pmd;
-+ pte_t *pte;
-+ int g, u, m;
++ int g, u, m, rc;
+
+ if (xen_feature(XENFEAT_auto_translated_physmap))
+ return;
@@ -17118,31 +16271,33 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ continue;
+ pud = pud_offset(pgd, 0);
+ if (PTRS_PER_PUD > 1) /* not folded */
-+ pgd_walk_set_prot(pud,flags);
++ pgd_walk_set_prot(virt_to_page(pud),flags);
+ for (u = 0; u < PTRS_PER_PUD; u++, pud++) {
+ if (pud_none(*pud))
+ continue;
+ pmd = pmd_offset(pud, 0);
+ if (PTRS_PER_PMD > 1) /* not folded */
-+ pgd_walk_set_prot(pmd,flags);
++ pgd_walk_set_prot(virt_to_page(pmd),flags);
+ for (m = 0; m < PTRS_PER_PMD; m++, pmd++) {
+ if (pmd_none(*pmd))
+ continue;
-+ pte = pte_offset_kernel(pmd,0);
-+ pgd_walk_set_prot(pte,flags);
++ pgd_walk_set_prot(pmd_page(*pmd),flags);
+ }
+ }
+ }
+
-+ BUG_ON(HYPERVISOR_update_va_mapping(
++ rc = HYPERVISOR_update_va_mapping(
+ (unsigned long)pgd_base,
+ pfn_pte(virt_to_phys(pgd_base)>>PAGE_SHIFT, flags),
-+ UVMF_TLB_FLUSH));
++ UVMF_TLB_FLUSH);
++ if (rc)
++ BUG();
+}
+
+static void __pgd_pin(pgd_t *pgd)
+{
+ pgd_walk(pgd, PAGE_KERNEL_RO);
++ kmap_flush_unused();
+ xen_pgd_pin(__pa(pgd));
+ set_bit(PG_pinned, &virt_to_page(pgd)->flags);
+}
@@ -17181,17 +16336,23 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+void mm_pin_all(void)
+{
+ struct page *page;
-+
-+ /* Only pgds on the pgd_list please: none hidden in the slab cache. */
-+ kmem_cache_shrink(pgd_cache);
++ unsigned long flags;
+
+ if (xen_feature(XENFEAT_writable_page_tables))
+ return;
+
++ /*
++ * Allow uninterrupted access to the pgd_list. Also protects
++ * __pgd_pin() by disabling preemption.
++ * All other CPUs must be at a safe point (e.g., in stop_machine
++ * or offlined entirely).
++ */
++ spin_lock_irqsave(&pgd_lock, flags);
+ for (page = pgd_list; page; page = (struct page *)page->index) {
+ if (!test_bit(PG_pinned, &page->flags))
+ __pgd_pin((pgd_t *)page_address(page));
+ }
++ spin_unlock_irqrestore(&pgd_lock, flags);
+}
+
+void _arch_dup_mmap(struct mm_struct *mm)
@@ -17227,9 +16388,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ !mm->context.has_foreign_mappings)
+ mm_unpin(mm);
+}
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/arch/i386/oprofile/Makefile source/arch/i386/oprofile/Makefile
---- /scratch/src/linux-2.6.20.3/arch/i386/oprofile/Makefile 2007-02-04 19:44:54.000000000 +0100
-+++ source/arch/i386/oprofile/Makefile 2007-03-20 21:26:27.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 arch/i386/oprofile/Makefile
+--- a/arch/i386/oprofile/Makefile Wed Jul 18 12:23:24 2007 -0300
++++ b/arch/i386/oprofile/Makefile Wed Aug 08 16:25:28 2007 -0300
@@ -6,7 +6,14 @@ DRIVER_OBJS = $(addprefix ../../../drive
oprofilefs.o oprofile_stats.o \
timer_int.o )
@@ -17245,9 +16406,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
op_model_ppro.o op_model_p4.o
oprofile-$(CONFIG_X86_IO_APIC) += nmi_timer_int.o
+endif
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/arch/i386/oprofile/xenoprof.c source/arch/i386/oprofile/xenoprof.c
---- /scratch/src/linux-2.6.20.3/arch/i386/oprofile/xenoprof.c 1970-01-01 01:00:00.000000000 +0100
-+++ source/arch/i386/oprofile/xenoprof.c 2007-03-20 21:26:27.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 arch/i386/oprofile/xenoprof.c
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/arch/i386/oprofile/xenoprof.c Wed Aug 08 16:25:28 2007 -0300
@@ -0,0 +1,179 @@
+/**
+ * @file xenoprof.c
@@ -17428,9 +16589,23 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+{
+ xenoprofile_exit();
+}
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/arch/i386/pci/irq.c source/arch/i386/pci/irq.c
---- /scratch/src/linux-2.6.20.3/arch/i386/pci/irq.c 2007-02-04 19:44:54.000000000 +0100
-+++ source/arch/i386/pci/irq.c 2007-03-20 21:26:27.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 arch/i386/pci/Makefile
+--- a/arch/i386/pci/Makefile Wed Jul 18 12:23:24 2007 -0300
++++ b/arch/i386/pci/Makefile Wed Aug 08 16:25:28 2007 -0300
+@@ -3,6 +3,10 @@ obj-$(CONFIG_PCI_BIOS) += pcbios.o
+ obj-$(CONFIG_PCI_BIOS) += pcbios.o
+ obj-$(CONFIG_PCI_MMCONFIG) += mmconfig.o direct.o
+ obj-$(CONFIG_PCI_DIRECT) += direct.o
++
++# pcifront should be after pcbios.o, mmconfig.o, and direct.o as it should only
++# take over if direct access to the PCI bus is unavailable
++obj-$(CONFIG_XEN_PCIDEV_FRONTEND) += pcifront.o
+
+ pci-y := fixup.o
+ pci-$(CONFIG_ACPI) += acpi.o
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 arch/i386/pci/irq.c
+--- a/arch/i386/pci/irq.c Wed Jul 18 12:23:24 2007 -0300
++++ b/arch/i386/pci/irq.c Wed Aug 08 16:25:28 2007 -0300
@@ -94,13 +94,25 @@ static struct irq_routing_table * __init
u8 *addr;
struct irq_routing_table *rt;
@@ -17457,32 +16632,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
rt = pirq_check_routing_table(addr);
if (rt)
return rt;
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/arch/i386/pci/Makefile source/arch/i386/pci/Makefile
---- /scratch/src/linux-2.6.20.3/arch/i386/pci/Makefile 2007-02-04 19:44:54.000000000 +0100
-+++ source/arch/i386/pci/Makefile 2007-03-20 21:26:27.000000000 +0100
-@@ -4,6 +4,10 @@ obj-$(CONFIG_PCI_BIOS) += pcbios.o
- obj-$(CONFIG_PCI_MMCONFIG) += mmconfig.o direct.o
- obj-$(CONFIG_PCI_DIRECT) += direct.o
-
-+# pcifront should be after pcbios.o, mmconfig.o, and direct.o as it should only
-+# take over if direct access to the PCI bus is unavailable
-+obj-$(CONFIG_XEN_PCIDEV_FRONTEND) += pcifront.o
-+
- pci-y := fixup.o
- pci-$(CONFIG_ACPI) += acpi.o
- pci-y += legacy.o irq.o
-@@ -12,3 +16,8 @@ pci-$(CONFIG_X86_VISWS) := visws.o fixu
- pci-$(CONFIG_X86_NUMAQ) := numa.o irq.o
-
- obj-y += $(pci-y) common.o early.o
-+
-+ifdef CONFIG_XEN
-+include $(srctree)/scripts/Makefile.xen
-+obj-y := $(call cherrypickxen, $(obj-y))
-+endif
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/arch/i386/pci/pcifront.c source/arch/i386/pci/pcifront.c
---- /scratch/src/linux-2.6.20.3/arch/i386/pci/pcifront.c 1970-01-01 01:00:00.000000000 +0100
-+++ source/arch/i386/pci/pcifront.c 2007-03-20 21:26:27.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 arch/i386/pci/pcifront.c
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/arch/i386/pci/pcifront.c Wed Aug 08 16:25:28 2007 -0300
@@ -0,0 +1,55 @@
+/*
+ * PCI Frontend Stub - puts some "dummy" functions in to the Linux x86 PCI core
@@ -17539,63 +16691,23 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+}
+
+arch_initcall(pcifront_x86_stub_init);
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/arch/i386/power/Makefile source/arch/i386/power/Makefile
---- /scratch/src/linux-2.6.20.3/arch/i386/power/Makefile 2007-02-04 19:44:54.000000000 +0100
-+++ source/arch/i386/power/Makefile 2007-03-20 21:26:27.000000000 +0100
-@@ -1,2 +1,4 @@
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 arch/i386/power/Makefile
+--- a/arch/i386/power/Makefile Wed Jul 18 12:23:24 2007 -0300
++++ b/arch/i386/power/Makefile Wed Aug 08 16:25:28 2007 -0300
+@@ -1,2 +1,4 @@ obj-$(CONFIG_PM) += cpu.o
-obj-$(CONFIG_PM) += cpu.o
+obj-$(CONFIG_PM_LEGACY) += cpu.o
+obj-$(CONFIG_SOFTWARE_SUSPEND) += cpu.o
+obj-$(CONFIG_ACPI_SLEEP) += cpu.o
obj-$(CONFIG_SOFTWARE_SUSPEND) += swsusp.o suspend.o
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/arch/ia64/dig/setup.c source/arch/ia64/dig/setup.c
---- /scratch/src/linux-2.6.20.3/arch/ia64/dig/setup.c 2007-02-04 19:44:54.000000000 +0100
-+++ source/arch/ia64/dig/setup.c 2007-03-20 21:26:27.000000000 +0100
-@@ -24,6 +24,8 @@
- #include <asm/machvec.h>
- #include <asm/system.h>
-
-+#include <xen/xencons.h>
-+
- void __init
- dig_setup (char **cmdline_p)
- {
-@@ -67,4 +69,19 @@ dig_setup (char **cmdline_p)
- screen_info.orig_video_mode = 3; /* XXX fake */
- screen_info.orig_video_isVGA = 1; /* XXX fake */
- screen_info.orig_video_ega_bx = 3; /* XXX fake */
-+#ifdef CONFIG_XEN
-+ if (!is_running_on_xen() || !is_initial_xendomain())
-+ return;
-+
-+ if (xen_start_info->console.dom0.info_size >=
-+ sizeof(struct dom0_vga_console_info)) {
-+ const struct dom0_vga_console_info *info =
-+ (struct dom0_vga_console_info *)(
-+ (char *)xen_start_info +
-+ xen_start_info->console.dom0.info_off);
-+ dom0_init_screen_info(info);
-+ }
-+ xen_start_info->console.domU.mfn = 0;
-+ xen_start_info->console.domU.evtchn = 0;
-+#endif
- }
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/arch/ia64/hp/sim/Makefile source/arch/ia64/hp/sim/Makefile
---- /scratch/src/linux-2.6.20.3/arch/ia64/hp/sim/Makefile 2007-02-04 19:44:54.000000000 +0100
-+++ source/arch/ia64/hp/sim/Makefile 2007-03-20 21:26:27.000000000 +0100
-@@ -14,3 +14,5 @@ obj-$(CONFIG_HP_SIMETH) += simeth.o
- obj-$(CONFIG_HP_SIMSERIAL) += simserial.o
- obj-$(CONFIG_HP_SIMSERIAL_CONSOLE) += hpsim_console.o
- obj-$(CONFIG_HP_SIMSCSI) += simscsi.o
-+obj-$(CONFIG_XEN) += simserial.o
-+obj-$(CONFIG_XEN) += hpsim_console.o
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/arch/ia64/Kconfig source/arch/ia64/Kconfig
---- /scratch/src/linux-2.6.20.3/arch/ia64/Kconfig 2007-03-20 21:30:35.000000000 +0100
-+++ source/arch/ia64/Kconfig 2007-03-20 21:33:43.000000000 +0100
-@@ -67,6 +67,34 @@ config GENERIC_IOMAP
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 arch/ia64/Kconfig
+--- a/arch/ia64/Kconfig Wed Jul 18 12:23:24 2007 -0300
++++ b/arch/ia64/Kconfig Wed Aug 08 16:25:28 2007 -0300
+@@ -66,6 +66,34 @@ config GENERIC_IOMAP
+ config GENERIC_IOMAP
bool
default y
-
++
+config XEN
+ bool "Xen hypervisor support"
+ default y
@@ -17623,10 +16735,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ default y
+ help
+ use dtr to map the exposed p2m table
-+
+
config SCHED_NO_NO_OMIT_FRAME_POINTER
bool
- default y
@@ -500,6 +528,21 @@ config PCI_DOMAINS
bool
default PCI
@@ -17649,7 +16760,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
source "drivers/pci/pcie/Kconfig"
source "drivers/pci/Kconfig"
-@@ -572,3 +615,32 @@ source "arch/ia64/Kconfig.debug"
+@@ -572,3 +615,13 @@ source "security/Kconfig"
source "security/Kconfig"
source "crypto/Kconfig"
@@ -17658,34 +16769,110 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+# override default values of drivers/xen/Kconfig
+#
+if XEN
-+config XEN_UTIL
++config XEN_SMPBOOT
+ default n
++endif
+
-+config HAVE_ARCH_ALLOC_SKB
-+ default y
-+
-+config HAVE_ARCH_DEV_ALLOC_SKB
-+ default y
-+
-+config XEN_BALLOON
-+ default y
++source "drivers/xen/Kconfig"
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 arch/ia64/Makefile
+--- a/arch/ia64/Makefile Wed Jul 18 12:23:24 2007 -0300
++++ b/arch/ia64/Makefile Wed Aug 08 16:25:28 2007 -0300
+@@ -45,6 +45,12 @@ endif
+ endif
+
+ CFLAGS += $(cflags-y)
+
-+config XEN_SKBUFF
-+ default y
-+ depends on NET
++cppflags-$(CONFIG_XEN) += \
++ -D__XEN_INTERFACE_VERSION__=$(CONFIG_XEN_INTERFACE_VERSION)
+
-+config XEN_REBOOT
-+ default y
++CPPFLAGS += $(cppflags-y)
+
-+config XEN_SMPBOOT
-+ default n
+ head-y := arch/ia64/kernel/head.o arch/ia64/kernel/init_task.o
+
+ libs-y += arch/ia64/lib/
+@@ -55,9 +61,15 @@ core-$(CONFIG_IA64_HP_ZX1) += arch/ia64/
+ core-$(CONFIG_IA64_HP_ZX1) += arch/ia64/dig/
+ core-$(CONFIG_IA64_HP_ZX1_SWIOTLB) += arch/ia64/dig/
+ core-$(CONFIG_IA64_SGI_SN2) += arch/ia64/sn/
++core-$(CONFIG_XEN) += arch/ia64/xen/
+
+ drivers-$(CONFIG_PCI) += arch/ia64/pci/
++ifneq ($(CONFIG_XEN),y)
+ drivers-$(CONFIG_IA64_HP_SIM) += arch/ia64/hp/sim/
+endif
++ifneq ($(CONFIG_IA64_GENERIC),y)
++drivers-$(CONFIG_XEN) += arch/ia64/hp/sim/
++endif
+ drivers-$(CONFIG_IA64_HP_ZX1) += arch/ia64/hp/common/ arch/ia64/hp/zx1/
+ drivers-$(CONFIG_IA64_HP_ZX1_SWIOTLB) += arch/ia64/hp/common/ arch/ia64/hp/zx1/
+ drivers-$(CONFIG_IA64_GENERIC) += arch/ia64/hp/common/ arch/ia64/hp/zx1/ arch/ia64/hp/sim/ arch/ia64/sn/
+@@ -87,8 +99,8 @@ boot: lib/lib.a vmlinux
+ boot: lib/lib.a vmlinux
+ $(Q)$(MAKE) $(build)=$(boot) $@
+
+-install: vmlinux.gz
+- sh $(srctree)/arch/ia64/install.sh $(KERNELRELEASE) $< System.map "$(INSTALL_PATH)"
++install:
++ -yes | sh $(srctree)/arch/ia64/install.sh $(KERNELRELEASE) vmlinux.gz System.map "$(INSTALL_PATH)"
+
+ define archhelp
+ echo '* compressed - Build compressed kernel image'
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 arch/ia64/dig/setup.c
+--- a/arch/ia64/dig/setup.c Wed Jul 18 12:23:24 2007 -0300
++++ b/arch/ia64/dig/setup.c Wed Aug 08 16:25:28 2007 -0300
+@@ -23,6 +23,8 @@
+ #include <asm/io.h>
+ #include <asm/machvec.h>
+ #include <asm/system.h>
+
-+source "drivers/xen/Kconfig"
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/arch/ia64/kernel/asm-offsets.c source/arch/ia64/kernel/asm-offsets.c
---- /scratch/src/linux-2.6.20.3/arch/ia64/kernel/asm-offsets.c 2007-02-04 19:44:54.000000000 +0100
-+++ source/arch/ia64/kernel/asm-offsets.c 2007-03-20 21:26:27.000000000 +0100
-@@ -268,4 +268,28 @@ void foo(void)
++#include <xen/xencons.h>
+
+ void __init
+ dig_setup (char **cmdline_p)
+@@ -67,4 +69,19 @@ dig_setup (char **cmdline_p)
+ screen_info.orig_video_mode = 3; /* XXX fake */
+ screen_info.orig_video_isVGA = 1; /* XXX fake */
+ screen_info.orig_video_ega_bx = 3; /* XXX fake */
++#ifdef CONFIG_XEN
++ if (!is_running_on_xen() || !is_initial_xendomain())
++ return;
++
++ if (xen_start_info->console.dom0.info_size >=
++ sizeof(struct dom0_vga_console_info)) {
++ const struct dom0_vga_console_info *info =
++ (struct dom0_vga_console_info *)(
++ (char *)xen_start_info +
++ xen_start_info->console.dom0.info_off);
++ dom0_init_screen_info(info);
++ }
++ xen_start_info->console.domU.mfn = 0;
++ xen_start_info->console.domU.evtchn = 0;
++#endif
+ }
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 arch/ia64/hp/sim/Makefile
+--- a/arch/ia64/hp/sim/Makefile Wed Jul 18 12:23:24 2007 -0300
++++ /dev/null Thu Jan 01 00:00:00 1970 +0000
+@@ -1,16 +0,0 @@
+-#
+-# ia64/platform/hp/sim/Makefile
+-#
+-# Copyright (C) 2002 Hewlett-Packard Co.
+-# David Mosberger-Tang <davidm@hpl.hp.com>
+-# Copyright (C) 1999 Silicon Graphics, Inc.
+-# Copyright (C) Srinivasa Thirumalachar (sprasad@engr.sgi.com)
+-#
+-
+-obj-y := hpsim_irq.o hpsim_setup.o hpsim.o
+-obj-$(CONFIG_IA64_GENERIC) += hpsim_machvec.o
+-
+-obj-$(CONFIG_HP_SIMETH) += simeth.o
+-obj-$(CONFIG_HP_SIMSERIAL) += simserial.o
+-obj-$(CONFIG_HP_SIMSERIAL_CONSOLE) += hpsim_console.o
+-obj-$(CONFIG_HP_SIMSCSI) += simscsi.o
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 arch/ia64/kernel/asm-offsets.c
+--- a/arch/ia64/kernel/asm-offsets.c Wed Jul 18 12:23:24 2007 -0300
++++ b/arch/ia64/kernel/asm-offsets.c Wed Aug 08 16:25:28 2007 -0300
+@@ -268,4 +268,29 @@ void foo(void)
DEFINE(IA64_TIME_SOURCE_MMIO64, TIME_SOURCE_MMIO64);
DEFINE(IA64_TIME_SOURCE_MMIO32, TIME_SOURCE_MMIO32);
DEFINE(IA64_TIMESPEC_TV_NSEC_OFFSET, offsetof (struct timespec, tv_nsec));
@@ -17708,15 +16895,16 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ DEFINE_MAPPED_REG_OFS(XSI_IHA_OFS, iha);
+ DEFINE_MAPPED_REG_OFS(XSI_ITIR_OFS, itir);
+ DEFINE_MAPPED_REG_OFS(XSI_PSR_IC_OFS, interrupt_collection_enabled);
-+ DEFINE_MAPPED_REG_OFS(XSI_INCOMPL_REGFR_OFS, incomplete_regframe);
+ DEFINE_MAPPED_REG_OFS(XSI_BANKNUM_OFS, banknum);
+ DEFINE_MAPPED_REG_OFS(XSI_BANK0_R16_OFS, bank0_regs[0]);
+ DEFINE_MAPPED_REG_OFS(XSI_BANK1_R16_OFS, bank1_regs[0]);
++ DEFINE_MAPPED_REG_OFS(XSI_B0NATS_OFS, vbnat);
++ DEFINE_MAPPED_REG_OFS(XSI_B1NATS_OFS, vnat);
+#endif /* CONFIG_XEN */
}
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/arch/ia64/kernel/entry.S source/arch/ia64/kernel/entry.S
---- /scratch/src/linux-2.6.20.3/arch/ia64/kernel/entry.S 2007-02-04 19:44:54.000000000 +0100
-+++ source/arch/ia64/kernel/entry.S 2007-03-20 21:26:27.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 arch/ia64/kernel/entry.S
+--- a/arch/ia64/kernel/entry.S Wed Jul 18 12:23:24 2007 -0300
++++ b/arch/ia64/kernel/entry.S Wed Aug 08 16:25:28 2007 -0300
@@ -180,7 +180,7 @@ END(sys_clone)
* called. The code starting at .map relies on this. The rest of the code
* doesn't care about the interrupt masking status.
@@ -17854,41 +17042,84 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
;;
mov ar.unat=r9
br.many b7
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/arch/ia64/kernel/gate.lds.S source/arch/ia64/kernel/gate.lds.S
---- /scratch/src/linux-2.6.20.3/arch/ia64/kernel/gate.lds.S 2007-02-04 19:44:54.000000000 +0100
-+++ source/arch/ia64/kernel/gate.lds.S 2007-03-20 21:26:27.000000000 +0100
-@@ -43,6 +43,28 @@ SECTIONS
- __start_gate_brl_fsys_bubble_down_patchlist = .;
- *(.data.patch.brl_fsys_bubble_down)
- __end_gate_brl_fsys_bubble_down_patchlist = .;
-+
-+#ifdef CONFIG_XEN_IA64_VDSO_PARAVIRT
-+ __start_gate_running_on_xen_patchlist = .;
-+ *(.data.patch.running_on_xen)
-+ __end_gate_running_on_xen_patchlist = .;
-+
-+ __start_gate_brl_xen_rsm_be_i_patchlist = .;
-+ *(.data.patch.brl_xen_rsm_be_i)
-+ __end_gate_brl_xen_rsm_be_i_patchlist = .;
-+
-+ __start_gate_brl_xen_get_psr_patchlist = .;
-+ *(.data.patch.brl_xen_get_psr)
-+ __end_gate_brl_xen_get_psr_patchlist = .;
-+
-+ __start_gate_brl_xen_ssm_i_0_patchlist = .;
-+ *(.data.patch.brl_xen_ssm_i_0)
-+ __end_gate_brl_xen_ssm_i_0_patchlist = .;
-+
-+ __start_gate_brl_xen_ssm_i_1_patchlist = .;
-+ *(.data.patch.brl_xen_ssm_i_1)
-+ __end_gate_brl_xen_ssm_i_1_patchlist = .;
-+#endif
- } :readable
- .IA_64.unwind_info : { *(.IA_64.unwind_info*) }
- .IA_64.unwind : { *(.IA_64.unwind*) } :readable :unwind
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/arch/ia64/kernel/gate.S source/arch/ia64/kernel/gate.S
---- /scratch/src/linux-2.6.20.3/arch/ia64/kernel/gate.S 2007-02-04 19:44:54.000000000 +0100
-+++ source/arch/ia64/kernel/gate.S 2007-03-20 21:26:27.000000000 +0100
+@@ -1605,8 +1611,8 @@ sys_call_table:
+ data8 sys_ni_syscall // 1295 reserved for ppoll
+ data8 sys_unshare
+ data8 sys_splice
+- data8 sys_set_robust_list
+- data8 sys_get_robust_list
++ data8 sys_ni_syscall // reserved for set_robust_list
++ data8 sys_ni_syscall // reserved for get_robust_list
+ data8 sys_sync_file_range // 1300
+ data8 sys_tee
+ data8 sys_vmsplice
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 arch/ia64/kernel/fsys.S
+--- a/arch/ia64/kernel/fsys.S Wed Jul 18 12:23:24 2007 -0300
++++ b/arch/ia64/kernel/fsys.S Wed Aug 08 16:25:28 2007 -0300
+@@ -516,11 +516,34 @@ ENTRY(fsys_fallback_syscall)
+ adds r17=-1024,r15
+ movl r14=sys_call_table
+ ;;
++#ifdef CONFIG_XEN
++ movl r18=running_on_xen;;
++ ld4 r18=[r18];;
++ // p14 = running_on_xen
++ // p15 = !running_on_xen
++ cmp.ne p14,p15=r0,r18
++ ;;
++(p14) movl r18=XSI_PSR_I_ADDR;;
++(p14) ld8 r18=[r18]
++(p14) mov r29=1;;
++(p14) st1 [r18]=r29
++(p15) rsm psr.i
++#else
+ rsm psr.i
++#endif
+ shladd r18=r17,3,r14
+ ;;
+ ld8 r18=[r18] // load normal (heavy-weight) syscall entry-point
++#ifdef CONFIG_XEN
++(p14) mov r27=r8
++(p14) XEN_HYPER_GET_PSR
++ ;;
++(p14) mov r29=r8
++(p14) mov r8=r27
++(p15) mov r29=psr // read psr (12 cyc load latency)
++#else
+ mov r29=psr // read psr (12 cyc load latency)
++#endif
+ mov r27=ar.rsc
+ mov r21=ar.fpsr
+ mov r26=ar.pfs
+@@ -632,7 +655,25 @@ GLOBAL_ENTRY(fsys_bubble_down)
+ mov rp=r14 // I0 set the real return addr
+ and r3=_TIF_SYSCALL_TRACEAUDIT,r3 // A
+ ;;
++#ifdef CONFIG_XEN
++ movl r14=running_on_xen;;
++ ld4 r14=[r14];;
++ // p14 = running_on_xen
++ // p15 = !running_on_xen
++ cmp.ne p14,p15=r0,r14
++ ;;
++(p14) movl r28=XSI_PSR_I_ADDR;;
++(p14) ld8 r28=[r28];;
++(p14) adds r28=-1,r28;; // event_pending
++(p14) ld1 r14=[r28];;
++(p14) cmp.ne.unc p13,p14=r14,r0;;
++(p13) XEN_HYPER_SSM_I
++(p14) adds r28=1,r28;; // event_mask
++(p14) st1 [r28]=r0;;
++(p15) ssm psr.i
++#else
+ ssm psr.i // M2 we're on kernel stacks now, reenable irqs
++#endif
+ cmp.eq p8,p0=r3,r0 // A
+ (p10) br.cond.spnt.many ia64_ret_from_syscall // B return if bad call-frame or r15 is a NaT
+
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 arch/ia64/kernel/gate.S
+--- a/arch/ia64/kernel/gate.S Wed Jul 18 12:23:24 2007 -0300
++++ b/arch/ia64/kernel/gate.S Wed Aug 08 16:25:28 2007 -0300
@@ -6,13 +6,15 @@
* David Mosberger-Tang <davidm@hpl.hp.com>
*/
@@ -17906,10 +17137,11 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
/*
* We can't easily refer to symbols inside the kernel. To avoid full runtime relocation,
-@@ -32,6 +34,52 @@
+@@ -31,6 +33,40 @@
+ #define BRL_COND_FSYS_BUBBLE_DOWN(pr) \
[1:](pr)brl.cond.sptk 0; \
.xdata4 ".data.patch.brl_fsys_bubble_down", 1b-.
-
++
+#ifdef CONFIG_XEN_IA64_VDSO_PARAVIRT
+ // The page in which hyperprivop lives must be pinned by ITR.
+ // However vDSO area isn't pinned. So issuing hyperprivop
@@ -17931,18 +17163,6 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+[1:] movl reg=0; \
+ .xdata4 ".data.patch.running_on_xen", 1b-.
+
-+ .section ".data.patch.brl_xen_rsm_be_i", "a"
-+ .previous
-+#define BRL_COND_XEN_RSM_BE_I(pr) \
-+[1:](pr)brl.cond.sptk 0; \
-+ .xdata4 ".data.patch.brl_xen_rsm_be_i", 1b-.
-+
-+ .section ".data.patch.brl_xen_get_psr", "a"
-+ .previous
-+#define BRL_COND_XEN_GET_PSR(pr) \
-+[1:](pr)brl.cond.sptk 0; \
-+ .xdata4 ".data.patch.brl_xen_get_psr", 1b-.
-+
+ .section ".data.patch.brl_xen_ssm_i_0", "a"
+ .previous
+#define BRL_COND_XEN_SSM_I_0(pr) \
@@ -17955,11 +17175,10 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+[1:](pr)brl.cond.sptk 0; \
+ .xdata4 ".data.patch.brl_xen_ssm_i_1", 1b-.
+#endif
-+
+
GLOBAL_ENTRY(__kernel_syscall_via_break)
.prologue
- .altrp b6
-@@ -76,7 +124,42 @@ GLOBAL_ENTRY(__kernel_syscall_via_epc)
+@@ -76,7 +112,42 @@ GLOBAL_ENTRY(__kernel_syscall_via_epc)
epc // B causes split-issue
}
;;
@@ -17993,31 +17212,31 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ cmp.ne isXen,isRaw=r0,r30
+ ;;
+(isRaw) rsm psr.be | psr.i
-+ BRL_COND_XEN_RSM_BE_I(isXen)
-+ .global .vdso_rsm_be_i_ret
-+.vdso_rsm_be_i_ret:
++(isXen) st1 [r22]=r20
++(isXen) rum psr.be
++ ;;
+#else
rsm psr.be | psr.i // M2 (5 cyc to srlz.d)
+#endif
LOAD_FSYSCALL_TABLE(r14) // X
;;
mov r16=IA64_KR(CURRENT) // M2 (12 cyc)
-@@ -84,7 +167,14 @@ GLOBAL_ENTRY(__kernel_syscall_via_epc)
+@@ -84,7 +155,14 @@ GLOBAL_ENTRY(__kernel_syscall_via_epc)
mov r19=NR_syscalls-1 // A
;;
lfetch [r18] // M0|1
+#ifdef CONFIG_XEN_IA64_VDSO_PARAVIRT
+(isRaw) mov r29=psr
-+ BRL_COND_XEN_GET_PSR(isXen)
-+ .global .vdso_get_psr_ret
-+.vdso_get_psr_ret:
++(isXen) XEN_HYPER_GET_PSR
++ ;;
++(isXen) mov r29=r8
+#else
mov r29=psr // M2 (12 cyc)
+#endif
// If r17 is a NaT, p6 will be zero
cmp.geu p6,p7=r19,r17 // A (sysnr > 0 && sysnr < 1024+NR_syscalls)?
;;
-@@ -98,9 +188,21 @@ GLOBAL_ENTRY(__kernel_syscall_via_epc)
+@@ -98,9 +176,21 @@ GLOBAL_ENTRY(__kernel_syscall_via_epc)
;;
nop.m 0
(p6) tbit.z.unc p8,p0=r18,0 // I0 (dual-issues with "mov b7=r18"!)
@@ -18039,7 +17258,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
(p6) mov b7=r18 // I0
(p8) br.dptk.many b7 // B
-@@ -121,9 +223,21 @@ GLOBAL_ENTRY(__kernel_syscall_via_epc)
+@@ -121,9 +211,21 @@ GLOBAL_ENTRY(__kernel_syscall_via_epc)
#else
BRL_COND_FSYS_BUBBLE_DOWN(p6)
#endif
@@ -18061,26 +17280,50 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
(p9) mov r8=ENOSYS
FSYS_RETURN
END(__kernel_syscall_via_epc)
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/arch/ia64/kernel/head.S source/arch/ia64/kernel/head.S
---- /scratch/src/linux-2.6.20.3/arch/ia64/kernel/head.S 2007-02-04 19:44:54.000000000 +0100
-+++ source/arch/ia64/kernel/head.S 2007-03-20 21:26:27.000000000 +0100
-@@ -367,6 +367,12 @@ start_ap:
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 arch/ia64/kernel/gate.lds.S
+--- a/arch/ia64/kernel/gate.lds.S Wed Jul 18 12:23:24 2007 -0300
++++ b/arch/ia64/kernel/gate.lds.S Wed Aug 08 16:25:28 2007 -0300
+@@ -43,6 +43,20 @@ SECTIONS
+ __start_gate_brl_fsys_bubble_down_patchlist = .;
+ *(.data.patch.brl_fsys_bubble_down)
+ __end_gate_brl_fsys_bubble_down_patchlist = .;
++
++#ifdef CONFIG_XEN_IA64_VDSO_PARAVIRT
++ __start_gate_running_on_xen_patchlist = .;
++ *(.data.patch.running_on_xen)
++ __end_gate_running_on_xen_patchlist = .;
++
++ __start_gate_brl_xen_ssm_i_0_patchlist = .;
++ *(.data.patch.brl_xen_ssm_i_0)
++ __end_gate_brl_xen_ssm_i_0_patchlist = .;
++
++ __start_gate_brl_xen_ssm_i_1_patchlist = .;
++ *(.data.patch.brl_xen_ssm_i_1)
++ __end_gate_brl_xen_ssm_i_1_patchlist = .;
++#endif
+ } :readable
+ .IA_64.unwind_info : { *(.IA_64.unwind_info*) }
+ .IA_64.unwind : { *(.IA_64.unwind*) } :readable :unwind
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 arch/ia64/kernel/head.S
+--- a/arch/ia64/kernel/head.S Wed Jul 18 12:23:24 2007 -0300
++++ b/arch/ia64/kernel/head.S Wed Aug 08 16:25:28 2007 -0300
+@@ -366,6 +366,12 @@ 1: // now we are in virtual mode
+ (isBP) movl r2=ia64_boot_param
;;
(isBP) st8 [r2]=r28 // save the address of the boot param area passed by the bootloader
-
++
+#ifdef CONFIG_XEN
+ // Note: isBP is used by the subprogram.
+ br.call.sptk.many rp=early_xen_setup
+ ;;
+#endif
-+
+
#ifdef CONFIG_SMP
(isAP) br.call.sptk.many rp=start_secondary
- .ret0:
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/arch/ia64/kernel/iosapic.c source/arch/ia64/kernel/iosapic.c
---- /scratch/src/linux-2.6.20.3/arch/ia64/kernel/iosapic.c 2007-02-04 19:44:54.000000000 +0100
-+++ source/arch/ia64/kernel/iosapic.c 2007-03-20 21:26:27.000000000 +0100
-@@ -159,6 +159,75 @@ static unsigned char pcat_compat __devin
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 arch/ia64/kernel/iosapic.c
+--- a/arch/ia64/kernel/iosapic.c Wed Jul 18 12:23:24 2007 -0300
++++ b/arch/ia64/kernel/iosapic.c Wed Aug 08 16:25:28 2007 -0300
+@@ -159,6 +159,75 @@ static int iosapic_kmalloc_ok;
static int iosapic_kmalloc_ok;
static LIST_HEAD(free_rte_list);
@@ -18156,17 +17399,17 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
/*
* Find an IOSAPIC associated with a GSI
*/
-@@ -674,6 +743,9 @@ register_intr (unsigned int gsi, int vec
+@@ -677,6 +746,9 @@ register_intr (unsigned int gsi, int vec
+ iosapic_intr_info[vector].polarity = polarity;
iosapic_intr_info[vector].dmode = delivery;
iosapic_intr_info[vector].trigger = trigger;
-
++
+ if (is_running_on_xen())
+ return 0;
-+
+
if (trigger == IOSAPIC_EDGE)
irq_type = &irq_type_iosapic_edge;
- else
-@@ -1036,6 +1108,9 @@ iosapic_system_init (int system_pcat_com
+@@ -1040,6 +1112,9 @@ iosapic_system_init (int system_pcat_com
}
pcat_compat = system_pcat_compat;
@@ -18176,9 +17419,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
if (pcat_compat) {
/*
* Disable the compatibility mode interrupts (8259 style),
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/arch/ia64/kernel/irq_ia64.c source/arch/ia64/kernel/irq_ia64.c
---- /scratch/src/linux-2.6.20.3/arch/ia64/kernel/irq_ia64.c 2007-02-04 19:44:54.000000000 +0100
-+++ source/arch/ia64/kernel/irq_ia64.c 2007-03-20 21:26:27.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 arch/ia64/kernel/irq_ia64.c
+--- a/arch/ia64/kernel/irq_ia64.c Wed Jul 18 12:23:24 2007 -0300
++++ b/arch/ia64/kernel/irq_ia64.c Wed Aug 08 16:25:28 2007 -0300
@@ -31,6 +31,10 @@
#include <linux/threads.h>
#include <linux/bitops.h>
@@ -18190,7 +17433,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
#include <asm/delay.h>
#include <asm/intrinsics.h>
-@@ -70,6 +74,13 @@ int
+@@ -70,6 +74,13 @@ assign_irq_vector (int irq)
assign_irq_vector (int irq)
{
int pos, vector;
@@ -18218,7 +17461,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
pos = vector - IA64_FIRST_DEVICE_VECTOR;
if (!test_and_clear_bit(pos, ia64_vector_mask))
printk(KERN_WARNING "%s: double free!\n", __FUNCTION__);
-@@ -280,14 +298,270 @@ static struct irqaction resched_irqactio
+@@ -280,11 +298,267 @@ static struct irqaction resched_irqactio
};
#endif
@@ -18284,81 +17527,85 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ * required.
+ */
+static void
-+xen_register_percpu_irq (unsigned int irq, struct irqaction *action, int save)
++xen_register_percpu_irq (unsigned int vec, struct irqaction *action, int save)
+{
+ unsigned int cpu = smp_processor_id();
-+ int ret = 0;
++ irq_desc_t *desc;
++ int irq = 0;
+
+ if (xen_slab_ready) {
-+ switch (irq) {
++ switch (vec) {
+ case IA64_TIMER_VECTOR:
+ sprintf(timer_name[cpu], "%s%d", action->name, cpu);
-+ ret = bind_virq_to_irqhandler(VIRQ_ITC, cpu,
++ irq = bind_virq_to_irqhandler(VIRQ_ITC, cpu,
+ action->handler, action->flags,
+ timer_name[cpu], action->dev_id);
-+ per_cpu(timer_irq,cpu) = ret;
-+ printk(KERN_INFO "register VIRQ_ITC (%s) to xen irq (%d)\n", timer_name[cpu], ret);
++ per_cpu(timer_irq,cpu) = irq;
+ break;
+ case IA64_IPI_RESCHEDULE:
+ sprintf(resched_name[cpu], "%s%d", action->name, cpu);
-+ ret = bind_ipi_to_irqhandler(RESCHEDULE_VECTOR, cpu,
++ irq = bind_ipi_to_irqhandler(RESCHEDULE_VECTOR, cpu,
+ action->handler, action->flags,
+ resched_name[cpu], action->dev_id);
-+ per_cpu(resched_irq,cpu) = ret;
-+ printk(KERN_INFO "register RESCHEDULE_VECTOR (%s) to xen irq (%d)\n", resched_name[cpu], ret);
++ per_cpu(resched_irq,cpu) = irq;
+ break;
+ case IA64_IPI_VECTOR:
+ sprintf(ipi_name[cpu], "%s%d", action->name, cpu);
-+ ret = bind_ipi_to_irqhandler(IPI_VECTOR, cpu,
++ irq = bind_ipi_to_irqhandler(IPI_VECTOR, cpu,
+ action->handler, action->flags,
+ ipi_name[cpu], action->dev_id);
-+ per_cpu(ipi_irq,cpu) = ret;
-+ printk(KERN_INFO "register IPI_VECTOR (%s) to xen irq (%d)\n", ipi_name[cpu], ret);
-+ break;
-+ case IA64_SPURIOUS_INT_VECTOR:
++ per_cpu(ipi_irq,cpu) = irq;
+ break;
+ case IA64_CMC_VECTOR:
+ sprintf(cmc_name[cpu], "%s%d", action->name, cpu);
-+ ret = bind_virq_to_irqhandler(VIRQ_MCA_CMC, cpu,
++ irq = bind_virq_to_irqhandler(VIRQ_MCA_CMC, cpu,
+ action->handler,
+ action->flags,
+ cmc_name[cpu],
+ action->dev_id);
-+ per_cpu(cmc_irq,cpu) = ret;
-+ printk(KERN_INFO "register VIRQ_MCA_CMC (%s) to xen "
-+ "irq (%d)\n", cmc_name[cpu], ret);
++ per_cpu(cmc_irq,cpu) = irq;
+ break;
+ case IA64_CMCP_VECTOR:
+ sprintf(cmcp_name[cpu], "%s%d", action->name, cpu);
-+ ret = bind_ipi_to_irqhandler(CMCP_VECTOR, cpu,
++ irq = bind_ipi_to_irqhandler(CMCP_VECTOR, cpu,
+ action->handler,
+ action->flags,
+ cmcp_name[cpu],
+ action->dev_id);
-+ per_cpu(cmcp_irq,cpu) = ret;
-+ printk(KERN_INFO "register CMCP_VECTOR (%s) to xen "
-+ "irq (%d)\n", cmcp_name[cpu], ret);
++ per_cpu(cmcp_irq,cpu) = irq;
+ break;
+ case IA64_CPEP_VECTOR:
+ sprintf(cpep_name[cpu], "%s%d", action->name, cpu);
-+ ret = bind_ipi_to_irqhandler(CPEP_VECTOR, cpu,
++ irq = bind_ipi_to_irqhandler(CPEP_VECTOR, cpu,
+ action->handler,
+ action->flags,
+ cpep_name[cpu],
+ action->dev_id);
-+ per_cpu(cpep_irq,cpu) = ret;
-+ printk(KERN_INFO "register CPEP_VECTOR (%s) to xen "
-+ "irq (%d)\n", cpep_name[cpu], ret);
++ per_cpu(cpep_irq,cpu) = irq;
+ break;
+ case IA64_CPE_VECTOR:
-+ printk(KERN_WARNING "register IA64_CPE_VECTOR "
-+ "IGNORED\n");
++ case IA64_MCA_RENDEZ_VECTOR:
++ case IA64_PERFMON_VECTOR:
++ case IA64_MCA_WAKEUP_VECTOR:
++ case IA64_SPURIOUS_INT_VECTOR:
++ /* No need to complain, these aren't supported. */
+ break;
+ default:
-+ printk(KERN_WARNING "Percpu irq %d is unsupported by xen!\n", irq);
++ printk(KERN_WARNING "Percpu irq %d is unsupported "
++ "by xen!\n", vec);
+ break;
+ }
-+ BUG_ON(ret < 0);
++ BUG_ON(irq < 0);
++
++ if (irq > 0) {
++ /*
++ * Mark percpu. Without this, migrate_irqs() will
++ * mark the interrupt for migrations and trigger it
++ * on cpu hotplug.
++ */
++ desc = irq_desc + irq;
++ desc->status |= IRQ_PER_CPU;
++ }
+ }
+
+ /* For BSP, we cache registered percpu irqs, and then re-walk
@@ -18366,7 +17613,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ */
+ if (!cpu && save) {
+ BUG_ON(saved_irq_cnt == MAX_LATE_IRQ);
-+ saved_percpu_irqs[saved_irq_cnt].irq = irq;
++ saved_percpu_irqs[saved_irq_cnt].irq = vec;
+ saved_percpu_irqs[saved_irq_cnt].action = action;
+ saved_irq_cnt++;
+ if (!xen_slab_ready)
@@ -18474,22 +17721,15 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
{
irq_desc_t *desc;
unsigned int irq;
-
++
+#ifdef CONFIG_XEN
+ if (is_running_on_xen())
+ return xen_register_percpu_irq(vec, action, 1);
+#endif
-+
+
for (irq = 0; irq < NR_IRQS; ++irq)
if (irq_to_vector(irq) == vec) {
-+#ifdef CONFIG_XEN
-+ if (is_running_on_xen())
-+ return xen_register_percpu_irq(vec, action, 1);
-+#endif
- desc = irq_desc + irq;
- desc->status |= IRQ_PER_CPU;
- desc->chip = &irq_type_ia64_lsapic;
-@@ -299,6 +573,21 @@ register_percpu_irq (ia64_vector vec, st
+@@ -299,6 +573,21 @@ void __init
void __init
init_IRQ (void)
{
@@ -18511,7 +17751,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
register_percpu_irq(IA64_SPURIOUS_INT_VECTOR, NULL);
#ifdef CONFIG_SMP
register_percpu_irq(IA64_IPI_VECTOR, &ipi_irqaction);
-@@ -317,6 +606,45 @@ ia64_send_ipi (int cpu, int vector, int
+@@ -317,6 +606,46 @@ ia64_send_ipi (int cpu, int vector, int
unsigned long ipi_data;
unsigned long phys_cpu_id;
@@ -18543,7 +17783,8 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ irq = per_cpu(ipi_to_irq, cpu)[CPEP_VECTOR];
+ break;
+ default:
-+ printk(KERN_WARNING"Unsupported IPI type 0x%x\n", vector);
++ printk(KERN_WARNING "Unsupported IPI type 0x%x\n",
++ vector);
+ irq = 0;
+ break;
+ }
@@ -18557,9 +17798,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
#ifdef CONFIG_SMP
phys_cpu_id = cpu_physical_id(cpu);
#else
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/arch/ia64/kernel/pal.S source/arch/ia64/kernel/pal.S
---- /scratch/src/linux-2.6.20.3/arch/ia64/kernel/pal.S 2007-02-04 19:44:54.000000000 +0100
-+++ source/arch/ia64/kernel/pal.S 2007-03-20 21:26:27.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 arch/ia64/kernel/pal.S
+--- a/arch/ia64/kernel/pal.S Wed Jul 18 12:23:24 2007 -0300
++++ b/arch/ia64/kernel/pal.S Wed Aug 08 16:25:28 2007 -0300
@@ -16,6 +16,7 @@
#include <asm/processor.h>
@@ -18568,7 +17809,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
pal_entry_point:
data8 ia64_pal_default_handler
.text
-@@ -86,7 +87,7 @@ GLOBAL_ENTRY(ia64_pal_call_static)
+@@ -86,7 +87,7 @@ 1: mov psr.l = loc3
;;
srlz.d // seralize restoration of psr.l
br.ret.sptk.many b0
@@ -18577,10 +17818,10 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
/*
* Make a PAL call using the stacked registers calling convention.
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/arch/ia64/kernel/patch.c source/arch/ia64/kernel/patch.c
---- /scratch/src/linux-2.6.20.3/arch/ia64/kernel/patch.c 2007-02-04 19:44:54.000000000 +0100
-+++ source/arch/ia64/kernel/patch.c 2007-03-20 21:26:27.000000000 +0100
-@@ -184,6 +184,73 @@ patch_brl_fsys_bubble_down (unsigned lon
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 arch/ia64/kernel/patch.c
+--- a/arch/ia64/kernel/patch.c Wed Jul 18 12:23:24 2007 -0300
++++ b/arch/ia64/kernel/patch.c Wed Aug 08 16:25:28 2007 -0300
+@@ -184,6 +184,69 @@ patch_brl_fsys_bubble_down (unsigned lon
ia64_srlz_i();
}
@@ -18636,13 +17877,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+static void __init
+patch_brl_in_vdso(void)
+{
-+ EXTERN_PATCHLIST(xen_rsm_be_i);
-+ EXTERN_PATCHLIST(xen_get_psr);
+ EXTERN_PATCHLIST(xen_ssm_i_0);
+ EXTERN_PATCHLIST(xen_ssm_i_1);
+
-+ PATCH_BRL_SYMADDR(xen_rsm_be_i);
-+ PATCH_BRL_SYMADDR(xen_get_psr);
+ PATCH_BRL_SYMADDR(xen_ssm_i_0);
+ PATCH_BRL_SYMADDR(xen_ssm_i_1);
+}
@@ -18654,7 +17891,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
void __init
ia64_patch_gate (void)
{
-@@ -192,6 +259,10 @@ ia64_patch_gate (void)
+@@ -192,6 +255,10 @@ ia64_patch_gate (void)
patch_fsyscall_table(START(fsyscall), END(fsyscall));
patch_brl_fsys_bubble_down(START(brl_fsys_bubble_down), END(brl_fsys_bubble_down));
@@ -18665,9 +17902,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
ia64_patch_vtop(START(vtop), END(vtop));
ia64_patch_mckinley_e9(START(mckinley_e9), END(mckinley_e9));
}
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/arch/ia64/kernel/perfmon.c source/arch/ia64/kernel/perfmon.c
---- /scratch/src/linux-2.6.20.3/arch/ia64/kernel/perfmon.c 2007-02-04 19:44:54.000000000 +0100
-+++ source/arch/ia64/kernel/perfmon.c 2007-03-20 21:26:27.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 arch/ia64/kernel/perfmon.c
+--- a/arch/ia64/kernel/perfmon.c Wed Jul 18 12:23:24 2007 -0300
++++ b/arch/ia64/kernel/perfmon.c Wed Aug 08 16:25:28 2007 -0300
@@ -53,6 +53,28 @@
#include <asm/delay.h>
@@ -18787,7 +18024,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
state = ctx->ctx_state;
fmt = ctx->ctx_buf_fmt;
-@@ -3704,6 +3767,7 @@ static int
+@@ -3704,6 +3767,7 @@ pfm_debug(pfm_context_t *ctx, void *arg,
pfm_debug(pfm_context_t *ctx, void *arg, int count, struct pt_regs *regs)
{
unsigned int m = *(unsigned int *)arg;
@@ -18804,19 +18041,19 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
req->ft_version = PFM_VERSION;
return 0;
}
-@@ -3985,6 +4051,12 @@ pfm_stop(pfm_context_t *ctx, void *arg,
+@@ -3984,6 +4050,12 @@ pfm_stop(pfm_context_t *ctx, void *arg,
+ struct pt_regs *tregs;
struct task_struct *task = PFM_CTX_TASK(ctx);
int state, is_system;
-
++
+ if (is_running_on_xen()) {
+ if (is_xenoprof_primary())
+ return HYPERVISOR_perfmon_op(PFM_STOP, NULL, 0);
+ return 0;
+ }
-+
+
state = ctx->ctx_state;
is_system = ctx->ctx_fl_system;
-
@@ -4073,6 +4145,11 @@ pfm_start(pfm_context_t *ctx, void *arg,
struct pt_regs *tregs;
int state, is_system;
@@ -18862,30 +18099,41 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
DPRINT(("ctx_state=%d task [%d]\n", ctx->ctx_state, task ? task->pid : -1));
prev_state = ctx->ctx_state;
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/arch/ia64/kernel/setup.c source/arch/ia64/kernel/setup.c
---- /scratch/src/linux-2.6.20.3/arch/ia64/kernel/setup.c 2007-02-04 19:44:54.000000000 +0100
-+++ source/arch/ia64/kernel/setup.c 2007-03-20 21:26:27.000000000 +0100
-@@ -61,6 +61,11 @@
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 arch/ia64/kernel/setup.c
+--- a/arch/ia64/kernel/setup.c Wed Jul 18 12:23:24 2007 -0300
++++ b/arch/ia64/kernel/setup.c Wed Aug 08 16:25:28 2007 -0300
+@@ -61,6 +61,12 @@
#include <asm/system.h>
#include <asm/unistd.h>
#include <asm/system.h>
+#ifdef CONFIG_XEN
+#include <asm/hypervisor.h>
+#include <asm/xen/xencomm.h>
++#include <xen/xencons.h>
+#endif
+#include <linux/dma-mapping.h>
#if defined(CONFIG_SMP) && (IA64_CPU_SIZE > PAGE_SIZE)
# error "struct cpuinfo_ia64 too big!"
-@@ -71,6 +76,22 @@ unsigned long __per_cpu_offset[NR_CPUS];
+@@ -69,6 +75,36 @@
+ #ifdef CONFIG_SMP
+ unsigned long __per_cpu_offset[NR_CPUS];
EXPORT_SYMBOL(__per_cpu_offset);
- #endif
-
++#endif
++
+#ifdef CONFIG_XEN
++static void
++xen_panic_hypercall(struct unw_frame_info *info, void *arg)
++{
++ current->thread.ksp = (__u64)info->sw - 16;
++ HYPERVISOR_shutdown(SHUTDOWN_crash);
++ /* we're never actually going to get here... */
++}
++
+static int
+xen_panic_event(struct notifier_block *this, unsigned long event, void *ptr)
+{
-+ HYPERVISOR_shutdown(SHUTDOWN_crash);
++ unw_init_running(xen_panic_hypercall, NULL);
+ /* we're never actually going to get here... */
+ return NOTIFY_DONE;
+}
@@ -18895,12 +18143,16 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ .next = NULL,
+ .priority = 0 /* try to go last */
+};
-+#endif
+
- extern void ia64_setup_printk_clock(void);
++void xen_pm_power_off(void)
++{
++ local_irq_disable();
++ HYPERVISOR_shutdown(SHUTDOWN_poweroff);
++}
+ #endif
- DEFINE_PER_CPU(struct cpuinfo_ia64, cpu_info);
-@@ -177,15 +198,33 @@ filter_rsvd_memory (unsigned long start,
+ extern void ia64_setup_printk_clock(void);
+@@ -177,15 +213,33 @@ filter_rsvd_memory (unsigned long start,
return 0;
}
@@ -18935,7 +18187,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
struct rsvd_region tmp;
tmp = rsvd_region[j];
rsvd_region[j] = rsvd_region[j + 1];
-@@ -193,6 +232,36 @@ sort_regions (struct rsvd_region *rsvd_r
+@@ -193,6 +247,36 @@ sort_regions (struct rsvd_region *rsvd_r
}
}
}
@@ -18972,10 +18224,11 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
}
/*
-@@ -243,6 +312,14 @@ reserve_memory (void)
+@@ -242,6 +326,14 @@ reserve_memory (void)
+ rsvd_region[n].start = (unsigned long) ia64_imva((void *)KERNEL_START);
rsvd_region[n].end = (unsigned long) ia64_imva(_end);
n++;
-
++
+#ifdef CONFIG_XEN
+ if (is_running_on_xen()) {
+ rsvd_region[n].start = (unsigned long)__va((HYPERVISOR_shared_info->arch.start_info_pfn << PAGE_SHIFT));
@@ -18983,28 +18236,10 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ n++;
+ }
+#endif
-+
+
#ifdef CONFIG_BLK_DEV_INITRD
if (ia64_boot_param->initrd_start) {
- rsvd_region[n].start = (unsigned long)__va(ia64_boot_param->initrd_start);
-@@ -376,6 +453,16 @@ early_console_setup (char *cmdline)
- {
- int earlycons = 0;
-
-+#ifdef CONFIG_XEN
-+#ifndef CONFIG_IA64_HP_SIM
-+ if (is_running_on_xen()) {
-+ extern struct console hpsim_cons;
-+ hpsim_cons.flags |= CON_BOOT;
-+ register_console(&hpsim_cons);
-+ earlycons++;
-+ }
-+#endif
-+#endif
- #ifdef CONFIG_SERIAL_SGI_L1_CONSOLE
- {
- extern int sn_serial_console_early_setup(void);
-@@ -460,6 +547,17 @@ setup_arch (char **cmdline_p)
+@@ -460,6 +552,19 @@ setup_arch (char **cmdline_p)
{
unw_init();
@@ -19015,17 +18250,20 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+
+ setup_xen_features();
+ /* Register a call for panic conditions. */
-+ atomic_notifier_chain_register(&panic_notifier_list, &xen_panic_block);
++ atomic_notifier_chain_register(&panic_notifier_list,
++ &xen_panic_block);
++ pm_power_off = xen_pm_power_off;
+ }
+#endif
+
ia64_patch_vtop((u64) __start___vtop_patchlist, (u64) __end___vtop_patchlist);
*cmdline_p = __va(ia64_boot_param->command_line);
-@@ -538,7 +636,26 @@ setup_arch (char **cmdline_p)
+@@ -538,14 +643,79 @@ setup_arch (char **cmdline_p)
conswitchp = &vga_con;
# endif
}
+-#endif
+#ifdef CONFIG_XEN
+ if (is_running_on_xen()) {
+ shared_info_t *s = HYPERVISOR_shared_info;
@@ -19039,7 +18277,46 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ if (!is_initial_xendomain()) {
+#if !defined(CONFIG_VT) || !defined(CONFIG_DUMMY_CONSOLE)
+ conswitchp = NULL;
- #endif
++#endif
++ }
++
++ /*
++ * If a console= is NOT specified, we assume using the
++ * xencons console is desired. By default, this is ttyS0
++ * for dom0 and tty0 for domU.
++ */
++ if (!strstr(*cmdline_p, "console=")) {
++ char *p, *q, name[5];
++ int offset = 0;
++
++ if (is_initial_xendomain())
++ strncpy(name, "ttyS", 4);
++ else
++ strncpy(name, "tty", 3);
++
++ p = strstr(*cmdline_p, "xencons=");
++
++ if (p) {
++ p += 8;
++ if (!strncmp(p, "ttyS", 4)) {
++ strncpy(name, p, 4);
++ p += 4;
++ offset = simple_strtol(p, &q, 10);
++ if (p == q)
++ offset = 0;
++ } else if (!strncmp(p, "tty", 3) ||
++ !strncmp(p, "xvc", 3)) {
++ strncpy(name, p, 3);
++ p += 3;
++ offset = simple_strtol(p, &q, 10);
++ if (p == q)
++ offset = 0;
++ } else if (!strncmp(p, "off", 3))
++ offset = -1;
++ }
++
++ if (offset >= 0)
++ add_preferred_console(name, offset, NULL);
+ }
+ }
+ xencons_early_setup();
@@ -19048,8 +18325,12 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+
/* enable IA-64 Machine Check Abort Handling unless disabled */
++#ifdef CONFIG_XEN
++ if (is_running_on_xen() && !is_initial_xendomain())
++ nomca = 1;
++#endif
if (!nomca)
-@@ -546,6 +663,9 @@ setup_arch (char **cmdline_p)
+ ia64_mca_init();
platform_setup(cmdline_p);
paging_init();
@@ -19059,7 +18340,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
}
/*
-@@ -951,6 +1071,15 @@ cpu_init (void)
+@@ -951,6 +1121,15 @@ cpu_init (void)
/* size of physical stacked register partition plus 8 bytes: */
__get_cpu_var(ia64_phys_stacked_size_p8) = num_phys_stacked*8 + 8;
platform_cpu_init();
@@ -19075,53 +18356,197 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
pm_idle = default_idle;
}
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/arch/ia64/Makefile source/arch/ia64/Makefile
---- /scratch/src/linux-2.6.20.3/arch/ia64/Makefile 2007-02-04 19:44:54.000000000 +0100
-+++ source/arch/ia64/Makefile 2007-03-20 21:26:27.000000000 +0100
-@@ -45,6 +45,12 @@ ifeq ($(call cc-version),0304)
- endif
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 arch/ia64/kernel/time.c
+--- a/arch/ia64/kernel/time.c Wed Jul 18 12:23:24 2007 -0300
++++ b/arch/ia64/kernel/time.c Wed Aug 08 16:25:28 2007 -0300
+@@ -29,6 +29,13 @@
+ #include <asm/sections.h>
+ #include <asm/system.h>
- CFLAGS += $(cflags-y)
++#ifdef CONFIG_XEN
++#include <linux/kernel_stat.h>
++#include <linux/posix-timers.h>
++#include <xen/interface/vcpu.h>
++#include <asm/percpu.h>
++#endif
+
-+cppflags-$(CONFIG_XEN) += \
-+ -D__XEN_INTERFACE_VERSION__=$(CONFIG_XEN_INTERFACE_VERSION)
+ volatile int time_keeper_id = 0; /* smp_processor_id() of time-keeper */
+
+ #ifdef CONFIG_IA64_DEBUG_IRQ
+@@ -36,6 +43,13 @@ unsigned long last_cli_ip;
+ unsigned long last_cli_ip;
+ EXPORT_SYMBOL(last_cli_ip);
+
++#endif
+
-+CPPFLAGS += $(cppflags-y)
++#ifdef CONFIG_XEN
++DEFINE_PER_CPU(struct vcpu_runstate_info, runstate);
++DEFINE_PER_CPU(unsigned long, processed_stolen_time);
++DEFINE_PER_CPU(unsigned long, processed_blocked_time);
++#define NS_PER_TICK (1000000000LL/HZ)
+ #endif
+
+ static struct time_interpolator itc_interpolator = {
+@@ -44,10 +58,96 @@ static struct time_interpolator itc_inte
+ .source = TIME_SOURCE_CPU
+ };
+
++#ifdef CONFIG_XEN
++static unsigned long
++consider_steal_time(unsigned long new_itm, struct pt_regs *regs)
++{
++ unsigned long stolen, blocked, sched_time;
++ unsigned long delta_itm = 0, stolentick = 0;
++ int i, cpu = smp_processor_id();
++ struct vcpu_runstate_info *runstate;
++ struct task_struct *p = current;
+
- head-y := arch/ia64/kernel/head.o arch/ia64/kernel/init_task.o
++ runstate = &per_cpu(runstate, smp_processor_id());
++
++ do {
++ sched_time = runstate->state_entry_time;
++ mb();
++ stolen = runstate->time[RUNSTATE_runnable] +
++ runstate->time[RUNSTATE_offline] -
++ per_cpu(processed_stolen_time, cpu);
++ blocked = runstate->time[RUNSTATE_blocked] -
++ per_cpu(processed_blocked_time, cpu);
++ mb();
++ } while (sched_time != runstate->state_entry_time);
++
++ /*
++ * Check for vcpu migration effect
++ * In this case, itc value is reversed.
++ * This causes huge stolen value.
++ * This function just checks and reject this effect.
++ */
++ if (!time_after_eq(runstate->time[RUNSTATE_blocked],
++ per_cpu(processed_blocked_time, cpu)))
++ blocked = 0;
++
++ if (!time_after_eq(runstate->time[RUNSTATE_runnable] +
++ runstate->time[RUNSTATE_offline],
++ per_cpu(processed_stolen_time, cpu)))
++ stolen = 0;
++
++ if (!time_after(delta_itm + new_itm, ia64_get_itc()))
++ stolentick = ia64_get_itc() - delta_itm - new_itm;
++
++ do_div(stolentick, NS_PER_TICK);
++ stolentick++;
++
++ do_div(stolen, NS_PER_TICK);
++
++ if (stolen > stolentick)
++ stolen = stolentick;
++
++ stolentick -= stolen;
++ do_div(blocked, NS_PER_TICK);
++
++ if (blocked > stolentick)
++ blocked = stolentick;
++
++ if (stolen > 0 || blocked > 0) {
++ account_steal_time(NULL, jiffies_to_cputime(stolen));
++ account_steal_time(idle_task(cpu), jiffies_to_cputime(blocked));
++ run_local_timers();
++
++ if (rcu_pending(cpu))
++ rcu_check_callbacks(cpu, user_mode(regs));
++
++ scheduler_tick();
++ run_posix_cpu_timers(p);
++ delta_itm += local_cpu_data->itm_delta * (stolen + blocked);
++
++ if (cpu == time_keeper_id) {
++ write_seqlock(&xtime_lock);
++ for(i = 0; i < stolen + blocked; i++)
++ do_timer(regs);
++ local_cpu_data->itm_next = delta_itm + new_itm;
++ write_sequnlock(&xtime_lock);
++ } else {
++ local_cpu_data->itm_next = delta_itm + new_itm;
++ }
++ per_cpu(processed_stolen_time,cpu) += NS_PER_TICK * stolen;
++ per_cpu(processed_blocked_time,cpu) += NS_PER_TICK * blocked;
++ }
++ return delta_itm;
++}
++#else
++#define consider_steal_time(new_itm, regs) (0)
++#endif
++
+ static irqreturn_t
+ timer_interrupt (int irq, void *dev_id)
+ {
+ unsigned long new_itm;
++ unsigned long delta_itm; /* XEN */
- libs-y += arch/ia64/lib/
-@@ -55,9 +61,15 @@ core-$(CONFIG_IA64_GENERIC) += arch/ia6
- core-$(CONFIG_IA64_HP_ZX1) += arch/ia64/dig/
- core-$(CONFIG_IA64_HP_ZX1_SWIOTLB) += arch/ia64/dig/
- core-$(CONFIG_IA64_SGI_SN2) += arch/ia64/sn/
-+core-$(CONFIG_XEN) += arch/ia64/xen/
+ if (unlikely(cpu_is_offline(smp_processor_id()))) {
+ return IRQ_HANDLED;
+@@ -62,6 +162,13 @@ timer_interrupt (int irq, void *dev_id)
+ ia64_get_itc(), new_itm);
- drivers-$(CONFIG_PCI) += arch/ia64/pci/
-+ifneq ($(CONFIG_XEN),y)
- drivers-$(CONFIG_IA64_HP_SIM) += arch/ia64/hp/sim/
-+endif
-+ifneq ($(CONFIG_IA64_GENERIC),y)
-+drivers-$(CONFIG_XEN) += arch/ia64/hp/sim/
-+endif
- drivers-$(CONFIG_IA64_HP_ZX1) += arch/ia64/hp/common/ arch/ia64/hp/zx1/
- drivers-$(CONFIG_IA64_HP_ZX1_SWIOTLB) += arch/ia64/hp/common/ arch/ia64/hp/zx1/
- drivers-$(CONFIG_IA64_GENERIC) += arch/ia64/hp/common/ arch/ia64/hp/zx1/ arch/ia64/hp/sim/ arch/ia64/sn/
-@@ -87,8 +99,8 @@ CLEAN_FILES += vmlinux.gz bootloader
- boot: lib/lib.a vmlinux
- $(Q)$(MAKE) $(build)=$(boot) $@
+ profile_tick(CPU_PROFILING);
++
++ if (is_running_on_xen()) {
++ delta_itm = consider_steal_time(new_itm, regs);
++ new_itm += delta_itm;
++ if (time_after(new_itm, ia64_get_itc()) && delta_itm)
++ goto skip_process_time_accounting;
++ }
--install: vmlinux.gz
-- sh $(srctree)/arch/ia64/install.sh $(KERNELRELEASE) $< System.map "$(INSTALL_PATH)"
-+install:
-+ -yes | sh $(srctree)/arch/ia64/install.sh $(KERNELRELEASE) vmlinux.gz System.map "$(INSTALL_PATH)"
+ while (1) {
+ update_process_times(user_mode(get_irq_regs()));
+@@ -91,6 +198,8 @@ timer_interrupt (int irq, void *dev_id)
+ local_irq_enable();
+ local_irq_disable();
+ }
++
++skip_process_time_accounting: /* XEN */
- define archhelp
- echo '* compressed - Build compressed kernel image'
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/arch/ia64/mm/ioremap.c source/arch/ia64/mm/ioremap.c
---- /scratch/src/linux-2.6.20.3/arch/ia64/mm/ioremap.c 2007-02-04 19:44:54.000000000 +0100
-+++ source/arch/ia64/mm/ioremap.c 2007-03-20 21:26:27.000000000 +0100
-@@ -16,6 +16,9 @@
+ do {
+ /*
+@@ -146,6 +255,25 @@ static int __init nojitter_setup(char *s
+
+ __setup("nojitter", nojitter_setup);
+
++#ifdef CONFIG_XEN
++/* taken from i386/kernel/time-xen.c */
++static void init_missing_ticks_accounting(int cpu)
++{
++ struct vcpu_register_runstate_memory_area area;
++ struct vcpu_runstate_info *runstate = &per_cpu(runstate, cpu);
++
++ memset(runstate, 0, sizeof(*runstate));
++
++ area.addr.v = runstate;
++ HYPERVISOR_vcpu_op(VCPUOP_register_runstate_memory_area, cpu, &area);
++
++ per_cpu(processed_blocked_time, cpu) = runstate->time[RUNSTATE_blocked];
++ per_cpu(processed_stolen_time, cpu) = runstate->time[RUNSTATE_runnable]
++ + runstate->time[RUNSTATE_offline];
++}
++#else
++#define init_missing_ticks_accounting(cpu) do {} while (0)
++#endif
+
+ void __devinit
+ ia64_init_itm (void)
+@@ -229,6 +357,9 @@ ia64_init_itm (void)
+ register_time_interpolator(&itc_interpolator);
+ }
+
++ if (is_running_on_xen())
++ init_missing_ticks_accounting(smp_processor_id());
++
+ /* Setup the CPU local timer tick */
+ ia64_cpu_local_tick();
+ }
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 arch/ia64/mm/ioremap.c
+--- a/arch/ia64/mm/ioremap.c Wed Jul 18 12:23:24 2007 -0300
++++ b/arch/ia64/mm/ioremap.c Wed Aug 08 16:25:28 2007 -0300
+@@ -16,6 +16,9 @@ static inline void __iomem *
static inline void __iomem *
__ioremap (unsigned long offset, unsigned long size)
{
@@ -19131,9 +18556,20 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
return (void __iomem *) (__IA64_UNCACHED_OFFSET | offset);
}
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/arch/ia64/oprofile/init.c source/arch/ia64/oprofile/init.c
---- /scratch/src/linux-2.6.20.3/arch/ia64/oprofile/init.c 2007-02-04 19:44:54.000000000 +0100
-+++ source/arch/ia64/oprofile/init.c 2007-03-20 21:26:27.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 arch/ia64/oprofile/Makefile
+--- a/arch/ia64/oprofile/Makefile Wed Jul 18 12:23:24 2007 -0300
++++ b/arch/ia64/oprofile/Makefile Wed Aug 08 16:25:28 2007 -0300
+@@ -8,3 +8,7 @@ DRIVER_OBJS := $(addprefix ../../../driv
+
+ oprofile-y := $(DRIVER_OBJS) init.o backtrace.o
+ oprofile-$(CONFIG_PERFMON) += perfmon.o
++ifeq ($(CONFIG_XEN), y)
++oprofile-$(CONFIG_PERFMON) += xenoprof.o \
++ ../../../drivers/xen/xenoprof/xenoprofile.o
++endif
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 arch/ia64/oprofile/init.c
+--- a/arch/ia64/oprofile/init.c Wed Jul 18 12:23:24 2007 -0300
++++ b/arch/ia64/oprofile/init.c Wed Aug 08 16:25:28 2007 -0300
@@ -11,6 +11,7 @@
#include <linux/oprofile.h>
#include <linux/init.h>
@@ -19142,20 +18578,20 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
extern int perfmon_init(struct oprofile_operations * ops);
extern void perfmon_exit(void);
-@@ -20,6 +21,13 @@ int __init oprofile_arch_init(struct opr
+@@ -19,6 +20,13 @@ int __init oprofile_arch_init(struct opr
+ int __init oprofile_arch_init(struct oprofile_operations * ops)
{
int ret = -ENODEV;
-
++
+ if (is_running_on_xen()) {
+ ret = xen_perfmon_init();
+ if (ret)
+ return ret;
+ return xenoprofile_init(ops);
+ }
-+
+
#ifdef CONFIG_PERFMON
/* perfmon_init() can fail, but we have no way to report it */
- ret = perfmon_init(ops);
@@ -32,6 +40,12 @@ int __init oprofile_arch_init(struct opr
void oprofile_arch_exit(void)
@@ -19169,26 +18605,13 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
#ifdef CONFIG_PERFMON
perfmon_exit();
#endif
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/arch/ia64/oprofile/Makefile source/arch/ia64/oprofile/Makefile
---- /scratch/src/linux-2.6.20.3/arch/ia64/oprofile/Makefile 2007-02-04 19:44:54.000000000 +0100
-+++ source/arch/ia64/oprofile/Makefile 2007-03-20 21:26:27.000000000 +0100
-@@ -8,3 +8,7 @@ DRIVER_OBJS := $(addprefix ../../../driv
-
- oprofile-y := $(DRIVER_OBJS) init.o backtrace.o
- oprofile-$(CONFIG_PERFMON) += perfmon.o
-+ifeq ($(CONFIG_XEN), y)
-+oprofile-$(CONFIG_PERFMON) += xenoprof.o \
-+ ../../../drivers/xen/xenoprof/xenoprofile.o
-+endif
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/arch/ia64/oprofile/oprofile_perfmon.h source/arch/ia64/oprofile/oprofile_perfmon.h
---- /scratch/src/linux-2.6.20.3/arch/ia64/oprofile/oprofile_perfmon.h 1970-01-01 01:00:00.000000000 +0100
-+++ source/arch/ia64/oprofile/oprofile_perfmon.h 2007-03-20 21:26:27.000000000 +0100
-@@ -0,0 +1,30 @@
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 arch/ia64/oprofile/oprofile_perfmon.h
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/arch/ia64/oprofile/oprofile_perfmon.h Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,28 @@
+#ifndef OPROFILE_PERFMON_H
+#define OPROFILE_PERFMON_H
+
-+#include <linux/config.h>
-+
+#ifdef CONFIG_PERFMON
+int __perfmon_init(void);
+void __perfmon_exit(void);
@@ -19214,9 +18637,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#endif /* CONFIG_XEN */
+
+#endif /* OPROFILE_PERFMON_H */
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/arch/ia64/oprofile/perfmon.c source/arch/ia64/oprofile/perfmon.c
---- /scratch/src/linux-2.6.20.3/arch/ia64/oprofile/perfmon.c 2007-02-04 19:44:54.000000000 +0100
-+++ source/arch/ia64/oprofile/perfmon.c 2007-03-20 21:26:27.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 arch/ia64/oprofile/perfmon.c
+--- a/arch/ia64/oprofile/perfmon.c Wed Jul 18 12:23:24 2007 -0300
++++ b/arch/ia64/oprofile/perfmon.c Wed Aug 08 16:25:28 2007 -0300
@@ -13,6 +13,7 @@
#include <asm/perfmon.h>
#include <asm/ptrace.h>
@@ -19248,14 +18671,13 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
static int using_perfmon;
--int perfmon_init(struct oprofile_operations * ops)
+STATIC_IF_NO_XEN
+int __perfmon_init(void)
- {
- int ret = pfm_register_buffer_fmt(&oprofile_fmt);
- if (ret)
- return -ENODEV;
-
++{
++ int ret = pfm_register_buffer_fmt(&oprofile_fmt);
++ if (ret)
++ return -ENODEV;
++
+ using_perfmon = 1;
+ return 0;
+}
@@ -19269,12 +18691,13 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ pfm_unregister_buffer_fmt(oprofile_fmt.fmt_uuid);
+}
+
-+int perfmon_init(struct oprofile_operations * ops)
-+{
+ int perfmon_init(struct oprofile_operations * ops)
+ {
+- int ret = pfm_register_buffer_fmt(&oprofile_fmt);
+ int ret = __perfmon_init();
-+ if (ret)
-+ return -ENODEV;
-+
+ if (ret)
+ return -ENODEV;
+
ops->cpu_type = get_cpu_type();
ops->start = perfmon_start;
ops->stop = perfmon_stop;
@@ -19292,9 +18715,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
- pfm_unregister_buffer_fmt(oprofile_fmt.fmt_uuid);
+ __perfmon_exit();
}
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/arch/ia64/oprofile/xenoprof.c source/arch/ia64/oprofile/xenoprof.c
---- /scratch/src/linux-2.6.20.3/arch/ia64/oprofile/xenoprof.c 1970-01-01 01:00:00.000000000 +0100
-+++ source/arch/ia64/oprofile/xenoprof.c 2007-03-20 21:26:27.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 arch/ia64/oprofile/xenoprof.c
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/arch/ia64/oprofile/xenoprof.c Wed Aug 08 16:25:28 2007 -0300
@@ -0,0 +1,142 @@
+/******************************************************************************
+ * xenoprof ia64 specific part
@@ -19438,16 +18861,56 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+
+ return ret;
+}
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/arch/ia64/xen/drivers/README source/arch/ia64/xen/drivers/README
---- /scratch/src/linux-2.6.20.3/arch/ia64/xen/drivers/README 1970-01-01 01:00:00.000000000 +0100
-+++ source/arch/ia64/xen/drivers/README 2007-03-20 21:26:27.000000000 +0100
-@@ -0,0 +1,2 @@
-+This is a temporary location for source/Makefiles that need to be
-+patched/reworked in drivers/xen to work with xenlinux/ia64.
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/arch/ia64/xen/hypercall.S source/arch/ia64/xen/hypercall.S
---- /scratch/src/linux-2.6.20.3/arch/ia64/xen/hypercall.S 1970-01-01 01:00:00.000000000 +0100
-+++ source/arch/ia64/xen/hypercall.S 2007-03-20 21:26:27.000000000 +0100
-@@ -0,0 +1,411 @@
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 arch/ia64/pci/pci.c
+--- a/arch/ia64/pci/pci.c Wed Jul 18 12:23:24 2007 -0300
++++ b/arch/ia64/pci/pci.c Wed Aug 08 16:25:28 2007 -0300
+@@ -609,6 +609,14 @@ pci_mmap_page_range (struct pci_dev *dev
+ else
+ vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
+
++ if (is_initial_xendomain()) {
++ unsigned long addr = vma->vm_pgoff << PAGE_SHIFT;
++ size_t size = vma->vm_end - vma->vm_start;
++ unsigned long offset = HYPERVISOR_ioremap(addr, size);
++ if (IS_ERR_VALUE(offset))
++ return offset;
++ }
++
+ if (remap_pfn_range(vma, vma->vm_start, vma->vm_pgoff,
+ vma->vm_end - vma->vm_start, vma->vm_page_prot))
+ return -EAGAIN;
+@@ -665,6 +673,14 @@ pci_mmap_legacy_page_range(struct pci_bu
+
+ vma->vm_pgoff += (unsigned long)addr >> PAGE_SHIFT;
+ vma->vm_page_prot = prot;
++
++ if (is_initial_xendomain()) {
++ unsigned long addr = vma->vm_pgoff << PAGE_SHIFT;
++ size_t size = vma->vm_end - vma->vm_start;
++ unsigned long offset = HYPERVISOR_ioremap(addr, size);
++ if (IS_ERR_VALUE(offset))
++ return offset;
++ }
+
+ if (remap_pfn_range(vma, vma->vm_start, vma->vm_pgoff,
+ size, vma->vm_page_prot))
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 arch/ia64/xen/Makefile
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/arch/ia64/xen/Makefile Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,9 @@
++#
++# Makefile for Xen components
++#
++
++obj-y := hypercall.o xenivt.o xenentry.o xensetup.o xenpal.o xenhpski.o \
++ hypervisor.o pci-dma-xen.o util.o xencomm.o xcom_hcall.o \
++ xcom_mini.o xcom_privcmd.o mem.o
++
++pci-dma-xen-y := ../../i386/kernel/pci-dma-xen.o
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 arch/ia64/xen/hypercall.S
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/arch/ia64/xen/hypercall.S Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,170 @@
+/*
+ * Support routines for Xen hypercalls
+ *
@@ -19457,336 +18920,110 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#include <asm/processor.h>
+#include <asm/asmmacro.h>
+
-+/* To clear vpsr.ic, vpsr.i needs to be cleared first */
-+#define XEN_CLEAR_PSR_IC \
-+ mov r14=1; \
-+ movl r15=XSI_PSR_I_ADDR; \
-+ movl r2=XSI_PSR_IC; \
-+ ;; \
-+ ld8 r15=[r15]; \
-+ ld4 r3=[r2]; \
-+ ;; \
-+ ld1 r16=[r15]; \
-+ ;; \
-+ st1 [r15]=r14; \
-+ st4 [r2]=r0; \
-+ ;;
-+
-+/* First restore vpsr.ic, and then vpsr.i */
-+#define XEN_RESTORE_PSR_IC \
-+ st4 [r2]=r3; \
-+ st1 [r15]=r16; \
-+ ;;
++GLOBAL_ENTRY(xen_get_psr)
++ XEN_HYPER_GET_PSR
++ br.ret.sptk.many rp
++ ;;
++END(xen_get_psr)
+
+GLOBAL_ENTRY(xen_get_ivr)
-+ movl r8=running_on_xen;;
-+ ld4 r8=[r8];;
-+ cmp.eq p7,p0=r8,r0;;
-+(p7) mov r8=cr.ivr;;
-+(p7) br.ret.sptk.many rp
-+ ;;
-+ XEN_CLEAR_PSR_IC
-+ ;;
+ XEN_HYPER_GET_IVR
-+ ;;
-+ XEN_RESTORE_PSR_IC
-+ ;;
+ br.ret.sptk.many rp
+ ;;
+END(xen_get_ivr)
+
+GLOBAL_ENTRY(xen_get_tpr)
-+ movl r8=running_on_xen;;
-+ ld4 r8=[r8];;
-+ cmp.eq p7,p0=r8,r0;;
-+(p7) mov r8=cr.tpr;;
-+(p7) br.ret.sptk.many rp
-+ ;;
-+ XEN_CLEAR_PSR_IC
-+ ;;
+ XEN_HYPER_GET_TPR
-+ ;;
-+ XEN_RESTORE_PSR_IC
-+ ;;
+ br.ret.sptk.many rp
+ ;;
+END(xen_get_tpr)
+
+GLOBAL_ENTRY(xen_set_tpr)
-+ movl r8=running_on_xen;;
-+ ld4 r8=[r8];;
-+ cmp.eq p7,p0=r8,r0;;
-+(p7) mov cr.tpr=r32;;
-+(p7) br.ret.sptk.many rp
-+ ;;
+ mov r8=r32
-+ ;;
-+ XEN_CLEAR_PSR_IC
-+ ;;
+ XEN_HYPER_SET_TPR
-+ ;;
-+ XEN_RESTORE_PSR_IC
-+ ;;
+ br.ret.sptk.many rp
+ ;;
+END(xen_set_tpr)
+
+GLOBAL_ENTRY(xen_eoi)
-+ movl r8=running_on_xen;;
-+ ld4 r8=[r8];;
-+ cmp.eq p7,p0=r8,r0;;
-+(p7) mov cr.eoi=r0;;
-+(p7) br.ret.sptk.many rp
-+ ;;
+ mov r8=r32
-+ ;;
-+ XEN_CLEAR_PSR_IC
-+ ;;
+ XEN_HYPER_EOI
-+ ;;
-+ XEN_RESTORE_PSR_IC
-+ ;;
+ br.ret.sptk.many rp
+ ;;
+END(xen_eoi)
+
+GLOBAL_ENTRY(xen_thash)
-+ movl r8=running_on_xen;;
-+ ld4 r8=[r8];;
-+ cmp.eq p7,p0=r8,r0;;
-+(p7) thash r8=r32;;
-+(p7) br.ret.sptk.many rp
-+ ;;
+ mov r8=r32
-+ ;;
-+ XEN_CLEAR_PSR_IC
-+ ;;
+ XEN_HYPER_THASH
-+ ;;
-+ XEN_RESTORE_PSR_IC
-+ ;;
+ br.ret.sptk.many rp
+ ;;
+END(xen_thash)
+
+GLOBAL_ENTRY(xen_set_itm)
-+ movl r8=running_on_xen;;
-+ ld4 r8=[r8];;
-+ cmp.eq p7,p0=r8,r0;;
-+(p7) mov cr.itm=r32;;
-+(p7) br.ret.sptk.many rp
-+ ;;
+ mov r8=r32
-+ ;;
-+ XEN_CLEAR_PSR_IC
-+ ;;
+ XEN_HYPER_SET_ITM
-+ ;;
-+ XEN_RESTORE_PSR_IC
-+ ;;
+ br.ret.sptk.many rp
+ ;;
+END(xen_set_itm)
+
+GLOBAL_ENTRY(xen_ptcga)
-+ movl r8=running_on_xen;;
-+ ld4 r8=[r8];;
-+ cmp.eq p7,p0=r8,r0;;
-+(p7) ptc.ga r32,r33;;
-+(p7) br.ret.sptk.many rp
-+ ;;
+ mov r8=r32
+ mov r9=r33
-+ ;;
-+ XEN_CLEAR_PSR_IC
-+ ;;
+ XEN_HYPER_PTC_GA
-+ ;;
-+ XEN_RESTORE_PSR_IC
-+ ;;
+ br.ret.sptk.many rp
+ ;;
+END(xen_ptcga)
+
+GLOBAL_ENTRY(xen_get_rr)
-+ movl r8=running_on_xen;;
-+ ld4 r8=[r8];;
-+ cmp.eq p7,p0=r8,r0;;
-+(p7) mov r8=rr[r32];;
-+(p7) br.ret.sptk.many rp
-+ ;;
+ mov r8=r32
-+ ;;
-+ XEN_CLEAR_PSR_IC
-+ ;;
+ XEN_HYPER_GET_RR
-+ ;;
-+ XEN_RESTORE_PSR_IC
-+ ;;
+ br.ret.sptk.many rp
+ ;;
+END(xen_get_rr)
+
+GLOBAL_ENTRY(xen_set_rr)
-+ movl r8=running_on_xen;;
-+ ld4 r8=[r8];;
-+ cmp.eq p7,p0=r8,r0;;
-+(p7) mov rr[r32]=r33;;
-+(p7) br.ret.sptk.many rp
-+ ;;
+ mov r8=r32
+ mov r9=r33
-+ ;;
-+ XEN_CLEAR_PSR_IC
-+ ;;
+ XEN_HYPER_SET_RR
-+ ;;
-+ XEN_RESTORE_PSR_IC
-+ ;;
+ br.ret.sptk.many rp
+ ;;
+END(xen_set_rr)
+
+GLOBAL_ENTRY(xen_set_kr)
-+ movl r8=running_on_xen;;
-+ ld4 r8=[r8];;
-+ cmp.ne p7,p0=r8,r0;;
-+(p7) br.cond.spnt.few 1f;
-+ ;;
-+ cmp.eq p7,p0=r8,r0
-+ adds r8=-1,r8;;
-+(p7) mov ar0=r9
-+(p7) br.ret.sptk.many rp;;
-+ cmp.eq p7,p0=r8,r0
-+ adds r8=-1,r8;;
-+(p7) mov ar1=r9
-+(p7) br.ret.sptk.many rp;;
-+ cmp.eq p7,p0=r8,r0
-+ adds r8=-1,r8;;
-+(p7) mov ar2=r9
-+(p7) br.ret.sptk.many rp;;
-+ cmp.eq p7,p0=r8,r0
-+ adds r8=-1,r8;;
-+(p7) mov ar3=r9
-+(p7) br.ret.sptk.many rp;;
-+ cmp.eq p7,p0=r8,r0
-+ adds r8=-1,r8;;
-+(p7) mov ar4=r9
-+(p7) br.ret.sptk.many rp;;
-+ cmp.eq p7,p0=r8,r0
-+ adds r8=-1,r8;;
-+(p7) mov ar5=r9
-+(p7) br.ret.sptk.many rp;;
-+ cmp.eq p7,p0=r8,r0
-+ adds r8=-1,r8;;
-+(p7) mov ar6=r9
-+(p7) br.ret.sptk.many rp;;
-+ cmp.eq p7,p0=r8,r0
-+ adds r8=-1,r8;;
-+(p7) mov ar7=r9
-+(p7) br.ret.sptk.many rp;;
-+
-+1: mov r8=r32
++ mov r8=r32
+ mov r9=r33
-+ ;;
-+ XEN_CLEAR_PSR_IC
-+ ;;
+ XEN_HYPER_SET_KR
-+ ;;
-+ XEN_RESTORE_PSR_IC
-+ ;;
+ br.ret.sptk.many rp
+END(xen_set_kr)
+
+GLOBAL_ENTRY(xen_fc)
-+ movl r8=running_on_xen;;
-+ ld4 r8=[r8];;
-+ cmp.eq p7,p0=r8,r0;;
-+(p7) fc r32;;
-+(p7) br.ret.sptk.many rp
-+ ;;
+ mov r8=r32
-+ ;;
-+ XEN_CLEAR_PSR_IC
-+ ;;
+ XEN_HYPER_FC
-+ ;;
-+ XEN_RESTORE_PSR_IC
-+ ;;
+ br.ret.sptk.many rp
+END(xen_fc)
+
+GLOBAL_ENTRY(xen_get_cpuid)
-+ movl r8=running_on_xen;;
-+ ld4 r8=[r8];;
-+ cmp.eq p7,p0=r8,r0;;
-+(p7) mov r8=cpuid[r32];;
-+(p7) br.ret.sptk.many rp
-+ ;;
+ mov r8=r32
-+ ;;
-+ XEN_CLEAR_PSR_IC
-+ ;;
+ XEN_HYPER_GET_CPUID
-+ ;;
-+ XEN_RESTORE_PSR_IC
-+ ;;
+ br.ret.sptk.many rp
+END(xen_get_cpuid)
+
+GLOBAL_ENTRY(xen_get_pmd)
-+ movl r8=running_on_xen;;
-+ ld4 r8=[r8];;
-+ cmp.eq p7,p0=r8,r0;;
-+(p7) mov r8=pmd[r32];;
-+(p7) br.ret.sptk.many rp
-+ ;;
+ mov r8=r32
-+ ;;
-+ XEN_CLEAR_PSR_IC
-+ ;;
+ XEN_HYPER_GET_PMD
-+ ;;
-+ XEN_RESTORE_PSR_IC
-+ ;;
+ br.ret.sptk.many rp
+END(xen_get_pmd)
+
+#ifdef CONFIG_IA32_SUPPORT
+GLOBAL_ENTRY(xen_get_eflag)
-+ movl r8=running_on_xen;;
-+ ld4 r8=[r8];;
-+ cmp.eq p7,p0=r8,r0;;
-+(p7) mov r8=ar24;;
-+(p7) br.ret.sptk.many rp
-+ ;;
-+ mov r8=r32
-+ ;;
-+ XEN_CLEAR_PSR_IC
-+ ;;
+ XEN_HYPER_GET_EFLAG
-+ ;;
-+ XEN_RESTORE_PSR_IC
-+ ;;
+ br.ret.sptk.many rp
+END(xen_get_eflag)
+
+// some bits aren't set if pl!=0, see SDM vol1 3.1.8
+GLOBAL_ENTRY(xen_set_eflag)
-+ movl r8=running_on_xen;;
-+ ld4 r8=[r8];;
-+ cmp.eq p7,p0=r8,r0;;
-+(p7) mov ar24=r32
-+(p7) br.ret.sptk.many rp
-+ ;;
+ mov r8=r32
-+ ;;
-+ XEN_CLEAR_PSR_IC
-+ ;;
+ XEN_HYPER_SET_EFLAG
-+ ;;
-+ XEN_RESTORE_PSR_IC
-+ ;;
+ br.ret.sptk.many rp
+END(xen_set_eflag)
+#endif
@@ -19804,27 +19041,6 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#ifdef CONFIG_XEN_IA64_VDSO_PARAVIRT
+// Those are vdso specialized.
+// In fsys mode, call, ret can't be used.
-+GLOBAL_ENTRY(xen_rsm_be_i)
-+ st1 [r22]=r20
-+ st4 [r23]=r0
-+ XEN_HYPER_RSM_BE
-+ st4 [r23]=r20
-+ brl.cond.sptk .vdso_rsm_be_i_ret
-+ ;;
-+END(xen_rsm_be_i)
-+
-+GLOBAL_ENTRY(xen_get_psr)
-+ mov r31=r8
-+ mov r25=IA64_PSR_IC
-+ st4 [r23]=r0
-+ XEN_HYPER_GET_PSR
-+ ;;
-+ st4 [r23]=r20
-+ or r29=r8,r25 // vpsr.ic was cleared for hyperprivop
-+ mov r8=r31
-+ brl.cond.sptk .vdso_get_psr_ret
-+ ;;
-+END(xen_get_psr)
+
+ // see xen_ssm_i() in privop.h
+ // r22 = &vcpu->vcpu_info->evtchn_upcall_mask
@@ -19844,7 +19060,6 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+(p14) cmp.ne.unc p11,p0=r0,r25; \
+ ;; \
+(p11) st1 [r22]=r20; \
-+(p11) st4 [r23]=r0; \
+(p11) XEN_HYPER_SSM_I;
+
+GLOBAL_ENTRY(xen_ssm_i_0)
@@ -19858,11 +19073,18 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ brl.cond.sptk .vdso_ssm_i_1_ret
+ ;;
+END(xen_ssm_i_1)
++
++GLOBAL_ENTRY(__hypercall)
++ mov r2=r37
++ break 0x1000
++ br.ret.sptk.many b0
++ ;;
++END(__hypercall)
+#endif
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/arch/ia64/xen/hypervisor.c source/arch/ia64/xen/hypervisor.c
---- /scratch/src/linux-2.6.20.3/arch/ia64/xen/hypervisor.c 1970-01-01 01:00:00.000000000 +0100
-+++ source/arch/ia64/xen/hypervisor.c 2007-03-20 21:26:27.000000000 +0100
-@@ -0,0 +1,1104 @@
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 arch/ia64/xen/hypervisor.c
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/arch/ia64/xen/hypervisor.c Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,1183 @@
+/******************************************************************************
+ * include/asm-ia64/shadow.h
+ *
@@ -19890,7 +19112,10 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#include <linux/bootmem.h>
+#include <linux/module.h>
+#include <linux/vmalloc.h>
++#include <linux/efi.h>
+#include <asm/page.h>
++#include <asm/pgalloc.h>
++#include <asm/meminit.h>
+#include <asm/hypervisor.h>
+#include <asm/hypercall.h>
+#include <xen/interface/memory.h>
@@ -19911,6 +19136,8 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#define p2m_expose_init() (-ENOSYS)
+#endif
+
++EXPORT_SYMBOL(__hypercall);
++
+//XXX same as i386, x86_64 contiguous_bitmap_set(), contiguous_bitmap_clear()
+// move those to lib/contiguous_bitmap?
+//XXX discontigmem/sparsemem
@@ -19921,13 +19148,90 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ */
+unsigned long *contiguous_bitmap;
+
++#ifdef CONFIG_VIRTUAL_MEM_MAP
++/* Following logic is stolen from create_mem_map_table() for virtual memmap */
++static int
++create_contiguous_bitmap(u64 start, u64 end, void *arg)
++{
++ unsigned long address, start_page, end_page;
++ unsigned long bitmap_start, bitmap_end;
++ unsigned char *bitmap;
++ int node;
++ pgd_t *pgd;
++ pud_t *pud;
++ pmd_t *pmd;
++ pte_t *pte;
++
++ bitmap_start = (unsigned long)contiguous_bitmap +
++ ((__pa(start) >> PAGE_SHIFT) >> 3);
++ bitmap_end = (unsigned long)contiguous_bitmap +
++ (((__pa(end) >> PAGE_SHIFT) + 2 * BITS_PER_LONG) >> 3);
++
++ start_page = bitmap_start & PAGE_MASK;
++ end_page = PAGE_ALIGN(bitmap_end);
++ node = paddr_to_nid(__pa(start));
++
++ bitmap = alloc_bootmem_pages_node(NODE_DATA(node),
++ end_page - start_page);
++ BUG_ON(!bitmap);
++ memset(bitmap, 0, end_page - start_page);
++
++ for (address = start_page; address < end_page; address += PAGE_SIZE) {
++ pgd = pgd_offset_k(address);
++ if (pgd_none(*pgd))
++ pgd_populate(&init_mm, pgd,
++ alloc_bootmem_pages_node(NODE_DATA(node),
++ PAGE_SIZE));
++ pud = pud_offset(pgd, address);
++
++ if (pud_none(*pud))
++ pud_populate(&init_mm, pud,
++ alloc_bootmem_pages_node(NODE_DATA(node),
++ PAGE_SIZE));
++ pmd = pmd_offset(pud, address);
++
++ if (pmd_none(*pmd))
++ pmd_populate_kernel(&init_mm, pmd,
++ alloc_bootmem_pages_node
++ (NODE_DATA(node), PAGE_SIZE));
++ pte = pte_offset_kernel(pmd, address);
++
++ if (pte_none(*pte))
++ set_pte(pte,
++ pfn_pte(__pa(bitmap + (address - start_page))
++ >> PAGE_SHIFT, PAGE_KERNEL));
++ }
++ return 0;
++}
++#endif
++
++static void
++__contiguous_bitmap_init(unsigned long size)
++{
++ contiguous_bitmap = alloc_bootmem_pages(size);
++ BUG_ON(!contiguous_bitmap);
++ memset(contiguous_bitmap, 0, size);
++}
++
+void
+contiguous_bitmap_init(unsigned long end_pfn)
+{
+ unsigned long size = (end_pfn + 2 * BITS_PER_LONG) >> 3;
-+ contiguous_bitmap = alloc_bootmem_low_pages(size);
-+ BUG_ON(!contiguous_bitmap);
-+ memset(contiguous_bitmap, 0, size);
++#ifndef CONFIG_VIRTUAL_MEM_MAP
++ __contiguous_bitmap_init(size);
++#else
++ unsigned long max_gap = 0;
++
++ efi_memmap_walk(find_largest_hole, (u64*)&max_gap);
++ if (max_gap < LARGE_GAP) {
++ __contiguous_bitmap_init(size);
++ } else {
++ unsigned long map_size = PAGE_ALIGN(size);
++ vmalloc_end -= map_size;
++ contiguous_bitmap = (unsigned long*)vmalloc_end;
++ efi_memmap_walk(create_contiguous_bitmap, NULL);
++ }
++#endif
+}
+
+#if 0
@@ -20200,12 +19504,6 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+EXPORT_SYMBOL(HYPERVISOR_grant_table_op);
+
+///////////////////////////////////////////////////////////////////////////
-+// PageForeign(), SetPageForeign(), ClearPageForeign()
-+
-+struct address_space xen_ia64_foreign_dummy_mapping;
-+EXPORT_SYMBOL(xen_ia64_foreign_dummy_mapping);
-+
-+///////////////////////////////////////////////////////////////////////////
+// foreign mapping
+#include <linux/efi.h>
+#include <asm/meminit.h> // for IA64_GRANULE_SIZE, GRANULEROUND{UP,DOWN}()
@@ -20641,6 +19939,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+
+ /* Just trigger a tick. */
+ ia64_cpu_local_tick();
++
++ /* Time interpolator remembers the last timer status. Forget it */
++ time_interpolator_reset();
+}
+
+///////////////////////////////////////////////////////////////////////////
@@ -20967,23 +20268,10 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ xen_ia64_release_resource(res);
+}
+EXPORT_SYMBOL_GPL(xen_ia64_unmap_resource);
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/arch/ia64/xen/Makefile source/arch/ia64/xen/Makefile
---- /scratch/src/linux-2.6.20.3/arch/ia64/xen/Makefile 1970-01-01 01:00:00.000000000 +0100
-+++ source/arch/ia64/xen/Makefile 2007-03-20 21:26:27.000000000 +0100
-@@ -0,0 +1,9 @@
-+#
-+# Makefile for Xen components
-+#
-+
-+obj-y := hypercall.o xenivt.o xenentry.o xensetup.o xenpal.o xenhpski.o \
-+ hypervisor.o pci-dma-xen.o util.o xencomm.o xcom_hcall.o \
-+ xcom_mini.o xcom_privcmd.o mem.o
-+
-+pci-dma-xen-y := ../../i386/kernel/pci-dma-xen.o
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/arch/ia64/xen/mem.c source/arch/ia64/xen/mem.c
---- /scratch/src/linux-2.6.20.3/arch/ia64/xen/mem.c 1970-01-01 01:00:00.000000000 +0100
-+++ source/arch/ia64/xen/mem.c 2007-03-20 21:26:27.000000000 +0100
-@@ -0,0 +1,76 @@
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 arch/ia64/xen/mem.c
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/arch/ia64/xen/mem.c Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,75 @@
+/*
+ * Originally from linux/drivers/char/mem.c
+ *
@@ -21001,7 +20289,6 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ * VA Linux Systems Japan K.K.
+ */
+
-+#include <linux/config.h>
+#include <linux/mm.h>
+#include <linux/efi.h>
+
@@ -21060,10 +20347,10 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ return -EAGAIN;
+ return 0;
+}
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/arch/ia64/xen/util.c source/arch/ia64/xen/util.c
---- /scratch/src/linux-2.6.20.3/arch/ia64/xen/util.c 1970-01-01 01:00:00.000000000 +0100
-+++ source/arch/ia64/xen/util.c 2007-03-20 21:26:27.000000000 +0100
-@@ -0,0 +1,117 @@
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 arch/ia64/xen/util.c
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/arch/ia64/xen/util.c Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,105 @@
+/******************************************************************************
+ * arch/ia64/xen/util.c
+ * This file is the ia64 counterpart of drivers/xen/util.c
@@ -21160,18 +20447,6 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+}
+EXPORT_SYMBOL_GPL(free_vm_area);
+
-+void lock_vm_area(struct vm_struct *area)
-+{
-+ // nothing
-+}
-+EXPORT_SYMBOL_GPL(lock_vm_area);
-+
-+void unlock_vm_area(struct vm_struct *area)
-+{
-+ // nothing
-+}
-+EXPORT_SYMBOL_GPL(unlock_vm_area);
-+
+/*
+ * Local variables:
+ * c-file-style: "linux"
@@ -21181,10 +20456,10 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ * tab-width: 8
+ * End:
+ */
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/arch/ia64/xen/xcom_hcall.c source/arch/ia64/xen/xcom_hcall.c
---- /scratch/src/linux-2.6.20.3/arch/ia64/xen/xcom_hcall.c 1970-01-01 01:00:00.000000000 +0100
-+++ source/arch/ia64/xen/xcom_hcall.c 2007-03-20 21:26:27.000000000 +0100
-@@ -0,0 +1,365 @@
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 arch/ia64/xen/xcom_hcall.c
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/arch/ia64/xen/xcom_hcall.c Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,383 @@
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
@@ -21208,7 +20483,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#include <linux/gfp.h>
+#include <linux/module.h>
+#include <xen/interface/xen.h>
-+#include <xen/interface/dom0_ops.h>
++#include <xen/interface/platform.h>
+#include <xen/interface/memory.h>
+#include <xen/interface/xencomm.h>
+#include <xen/interface/version.h>
@@ -21220,6 +20495,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#include <xen/interface/acm_ops.h>
+#include <xen/interface/hvm/params.h>
+#include <xen/interface/xenoprof.h>
++#include <xen/interface/vcpu.h>
+#include <asm/hypercall.h>
+#include <asm/page.h>
+#include <asm/uaccess.h>
@@ -21550,10 +20826,27 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ xencomm_create_inline(arg),
+ count);
+}
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/arch/ia64/xen/xcom_mini.c source/arch/ia64/xen/xcom_mini.c
---- /scratch/src/linux-2.6.20.3/arch/ia64/xen/xcom_mini.c 1970-01-01 01:00:00.000000000 +0100
-+++ source/arch/ia64/xen/xcom_mini.c 2007-03-20 21:26:27.000000000 +0100
-@@ -0,0 +1,417 @@
++
++long
++xencomm_hypercall_vcpu_op(int cmd, int cpu, void *arg)
++{
++ switch (cmd) {
++ case VCPUOP_register_runstate_memory_area:
++ xencommize_memory_reservation((xen_memory_reservation_t *)arg);
++ break;
++
++ default:
++ printk("%s: unknown vcpu op %d\n", __func__, cmd);
++ return -ENOSYS;
++ }
++
++ return xencomm_arch_hypercall_vcpu_op(cmd, cpu,
++ xencomm_create_inline(arg));
++}
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 arch/ia64/xen/xcom_mini.c
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/arch/ia64/xen/xcom_mini.c Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,456 @@
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
@@ -21576,7 +20869,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <xen/interface/xen.h>
-+#include <xen/interface/dom0_ops.h>
++#include <xen/interface/platform.h>
+#include <xen/interface/memory.h>
+#include <xen/interface/xencomm.h>
+#include <xen/interface/version.h>
@@ -21654,6 +20947,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ case GNTTABOP_copy:
+ argsize = sizeof(struct gnttab_copy);
+ break;
++ case GNTTABOP_query_size:
++ argsize = sizeof(struct gnttab_query_size);
++ break;
+ default:
+ printk("%s: unknown mini grant table op %d\n", __func__, cmd);
+ BUG();
@@ -21971,10 +21267,46 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ return xencomm_arch_hypercall_perfmon_op(cmd, desc, count);
+}
+EXPORT_SYMBOL_GPL(xencomm_mini_hypercall_perfmon_op);
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/arch/ia64/xen/xcom_privcmd.c source/arch/ia64/xen/xcom_privcmd.c
---- /scratch/src/linux-2.6.20.3/arch/ia64/xen/xcom_privcmd.c 1970-01-01 01:00:00.000000000 +0100
-+++ source/arch/ia64/xen/xcom_privcmd.c 2007-03-20 21:26:27.000000000 +0100
-@@ -0,0 +1,663 @@
++
++int
++xencomm_mini_hypercall_sched_op(int cmd, void *arg)
++{
++ int rc, nbr_area = 2;
++ struct xencomm_mini xc_area[2];
++ struct xencomm_handle *desc;
++ unsigned int argsize;
++
++ switch (cmd) {
++ case SCHEDOP_yield:
++ case SCHEDOP_block:
++ argsize = 0;
++ break;
++ case SCHEDOP_shutdown:
++ argsize = sizeof(sched_shutdown_t);
++ break;
++ case SCHEDOP_poll:
++ argsize = sizeof(sched_poll_t);
++ break;
++ case SCHEDOP_remote_shutdown:
++ argsize = sizeof(sched_remote_shutdown_t);
++ break;
++
++ default:
++ printk("%s: unknown sched op %d\n", __func__, cmd);
++ return -ENOSYS;
++ }
++
++ rc = xencomm_create_mini(xc_area, &nbr_area, arg, argsize, &desc);
++ if (rc)
++ return rc;
++
++ return xencomm_arch_hypercall_sched_op(cmd, desc);
++}
++EXPORT_SYMBOL_GPL(xencomm_mini_hypercall_sched_op);
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 arch/ia64/xen/xcom_privcmd.c
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/arch/ia64/xen/xcom_privcmd.c Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,664 @@
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
@@ -21999,7 +21331,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#include <linux/gfp.h>
+#include <linux/module.h>
+#include <xen/interface/xen.h>
-+#include <xen/interface/dom0_ops.h>
++#include <xen/interface/platform.h>
+#define __XEN__
+#include <xen/interface/domctl.h>
+#include <xen/interface/sysctl.h>
@@ -22017,25 +21349,25 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#define ROUND_DIV(v,s) (((v) + (s) - 1) / (s))
+
+static int
-+xencomm_privcmd_dom0_op(privcmd_hypercall_t *hypercall)
++xencomm_privcmd_platform_op(privcmd_hypercall_t *hypercall)
+{
-+ dom0_op_t kern_op;
-+ dom0_op_t __user *user_op = (dom0_op_t __user *)hypercall->arg[0];
++ struct xen_platform_op kern_op;
++ struct xen_platform_op __user *user_op = (struct xen_platform_op __user *)hypercall->arg[0];
+ struct xencomm_handle *op_desc;
+ struct xencomm_handle *desc = NULL;
+ int ret = 0;
+
-+ if (copy_from_user(&kern_op, user_op, sizeof(dom0_op_t)))
++ if (copy_from_user(&kern_op, user_op, sizeof(struct xen_platform_op)))
+ return -EFAULT;
+
-+ if (kern_op.interface_version != DOM0_INTERFACE_VERSION)
++ if (kern_op.interface_version != XENPF_INTERFACE_VERSION)
+ return -EACCES;
+
+ op_desc = xencomm_create_inline(&kern_op);
+
+ switch (kern_op.cmd) {
+ default:
-+ printk("%s: unknown dom0 cmd %d\n", __func__, kern_op.cmd);
++ printk("%s: unknown platform cmd %d\n", __func__, kern_op.cmd);
+ return -ENOSYS;
+ }
+
@@ -22044,10 +21376,10 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ return ret;
+ }
+
-+ ret = xencomm_arch_hypercall_dom0_op(op_desc);
++ ret = xencomm_arch_hypercall_platform_op(op_desc);
+
+ /* FIXME: should we restore the handle? */
-+ if (copy_to_user(user_op, &kern_op, sizeof(dom0_op_t)))
++ if (copy_to_user(user_op, &kern_op, sizeof(struct xen_platform_op)))
+ ret = -EFAULT;
+
+ if (desc)
@@ -22280,6 +21612,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ case XEN_DOMCTL_hypercall_init:
+ case XEN_DOMCTL_arch_setup:
+ case XEN_DOMCTL_settimeoffset:
++ case XEN_DOMCTL_sendtrigger:
+ break;
+ default:
+ printk("%s: unknown domctl cmd %d\n", __func__, kern_op.cmd);
@@ -22614,8 +21947,8 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+privcmd_hypercall(privcmd_hypercall_t *hypercall)
+{
+ switch (hypercall->op) {
-+ case __HYPERVISOR_dom0_op:
-+ return xencomm_privcmd_dom0_op(hypercall);
++ case __HYPERVISOR_platform_op:
++ return xencomm_privcmd_platform_op(hypercall);
+ case __HYPERVISOR_domctl:
+ return xencomm_privcmd_domctl(hypercall);
+ case __HYPERVISOR_sysctl:
@@ -22638,9 +21971,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ }
+}
+
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/arch/ia64/xen/xencomm.c source/arch/ia64/xen/xencomm.c
---- /scratch/src/linux-2.6.20.3/arch/ia64/xen/xencomm.c 1970-01-01 01:00:00.000000000 +0100
-+++ source/arch/ia64/xen/xencomm.c 2007-03-20 21:26:27.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 arch/ia64/xen/xencomm.c
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/arch/ia64/xen/xencomm.c Wed Aug 08 16:25:28 2007 -0300
@@ -0,0 +1,263 @@
+/*
+ * Copyright (C) 2006 Hollis Blanchard <hollisb@us.ibm.com>, IBM Corporation
@@ -22905,10 +22238,10 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ *ret = (struct xencomm_handle*)res;
+ return 0;
+}
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/arch/ia64/xen/xenentry.S source/arch/ia64/xen/xenentry.S
---- /scratch/src/linux-2.6.20.3/arch/ia64/xen/xenentry.S 1970-01-01 01:00:00.000000000 +0100
-+++ source/arch/ia64/xen/xenentry.S 2007-03-20 21:26:27.000000000 +0100
-@@ -0,0 +1,908 @@
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 arch/ia64/xen/xenentry.S
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/arch/ia64/xen/xenentry.S Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,931 @@
+/*
+ * ia64/xen/entry.S
+ *
@@ -22968,12 +22301,6 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ shr.u r26=r20,IA64_GRANULE_SHIFT
+ cmp.eq p7,p6=r25,in0
+ ;;
-+#ifdef CONFIG_XEN
-+ movl r8=XSI_PSR_IC
-+ ;;
-+ st4 [r8]=r0 // force psr.ic off for hyperprivop(s)
-+ ;;
-+#endif
+ /*
+ * If we've already mapped this task's page, we can skip doing it again.
+ */
@@ -22981,19 +22308,13 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+(p6) br.cond.dpnt .map
+ ;;
+.done:
++ ld8 sp=[r21] // load kernel stack pointer of new task
+#ifdef CONFIG_XEN
-+ // psr.ic already off
+ // update "current" application register
+ mov r8=IA64_KR_CURRENT
+ mov r9=in0;;
+ XEN_HYPER_SET_KR
-+ ld8 sp=[r21] // load kernel stack pointer of new task
-+ movl r27=XSI_PSR_IC
-+ mov r8=1
-+ ;;
-+ st4 [r27]=r8 // psr.ic back on
+#else
-+ ld8 sp=[r21] // load kernel stack pointer of new task
+ mov IA64_KR(CURRENT)=in0 // update "current" application register
+#endif
+ mov r8=r13 // return pointer to previously running task
@@ -23008,7 +22329,10 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+
+.map:
+#ifdef CONFIG_XEN
-+ // psr.ic already off
++ movl r25=XSI_PSR_IC // clear psr.ic
++ ;;
++ st4 [r25]=r0
++ ;;
+#else
+ rsm psr.ic // interrupts (psr.i) are already disabled here
+#endif
@@ -23041,7 +22365,15 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#endif
+ ;;
+ itr.d dtr[r25]=r23 // wire in new mapping...
-+#ifndef CONFIG_XEN
++#ifdef CONFIG_XEN
++ ;;
++ srlz.d
++ mov r9=1
++ movl r8=XSI_PSR_IC
++ ;;
++ st4 [r8]=r9
++ ;;
++#else
+ ssm psr.ic // reenable the psr.ic bit
+ ;;
+ srlz.d
@@ -23324,7 +22656,16 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+(pUStk) add r14=IA64_TASK_THREAD_ON_USTACK_OFFSET,r13
+ ;;
+ ld8 r26=[r2],PT(B0)-PT(AR_PFS) // M0|1 load ar.pfs
++#ifdef CONFIG_XEN
++(pKStk) mov r21=r8
++(pKStk) XEN_HYPER_GET_PSR
++ ;;
++(pKStk) mov r22=r8
++(pKStk) mov r8=r21
++ ;;
++#else
+(pKStk) mov r22=psr // M2 read PSR now that interrupts are disabled
++#endif
+ nop 0
+ ;;
+ ld8 r21=[r2],PT(AR_RNAT)-PT(B0) // M0|1 load b0
@@ -23517,6 +22858,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#ifdef CONFIG_XEN
+ ;;
+ // r16-r31 all now hold bank1 values
++ mov r15=ar.unat
+ movl r2=XSI_BANK1_R16
+ movl r3=XSI_BANK1_R16+8
+ ;;
@@ -23544,6 +22886,11 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+.mem.offset 0,0; st8.spill [r2]=r30,16
+.mem.offset 8,0; st8.spill [r3]=r31,16
+ ;;
++ mov r3=ar.unat
++ movl r2=XSI_B1NAT
++ ;;
++ st8 [r2]=r3
++ mov ar.unat=r15
+ movl r2=XSI_BANKNUM;;
+ st4 [r2]=r0;
+#else
@@ -23554,7 +22901,16 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ adds r16=PT(CR_IPSR)+16,r12
+ adds r17=PT(CR_IIP)+16,r12
+
++#ifdef CONFIG_XEN
++(pKStk) mov r29=r8
++(pKStk) XEN_HYPER_GET_PSR
++ ;;
++(pKStk) mov r22=r8
++(pKStk) mov r8=r29
++ ;;
++#else
+(pKStk) mov r22=psr // M2 read PSR now that interrupts are disabled
++#endif
+ nop.i 0
+ nop.i 0
+ ;;
@@ -23817,9 +23173,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#else
+END(ia64_leave_kernel)
+#endif
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/arch/ia64/xen/xenhpski.c source/arch/ia64/xen/xenhpski.c
---- /scratch/src/linux-2.6.20.3/arch/ia64/xen/xenhpski.c 1970-01-01 01:00:00.000000000 +0100
-+++ source/arch/ia64/xen/xenhpski.c 2007-03-20 21:26:27.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 arch/ia64/xen/xenhpski.c
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/arch/ia64/xen/xenhpski.c Wed Aug 08 16:25:28 2007 -0300
@@ -0,0 +1,19 @@
+
+extern unsigned long xen_get_cpuid(int);
@@ -23840,10 +23196,10 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ return 1;
+}
+
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/arch/ia64/xen/xenivt.S source/arch/ia64/xen/xenivt.S
---- /scratch/src/linux-2.6.20.3/arch/ia64/xen/xenivt.S 1970-01-01 01:00:00.000000000 +0100
-+++ source/arch/ia64/xen/xenivt.S 2007-03-20 21:26:27.000000000 +0100
-@@ -0,0 +1,2178 @@
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 arch/ia64/xen/xenivt.S
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/arch/ia64/xen/xenivt.S Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,2177 @@
+/*
+ * arch/ia64/xen/ivt.S
+ *
@@ -24553,11 +23909,23 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ ;;
+#endif
+#ifdef CONFIG_XEN
-+ br.cond.sptk.many xen_page_fault
++
++#define MASK_TO_PEND_OFS (-1)
++
++(p15) movl r14=XSI_PSR_I_ADDR
+ ;;
-+done_xen_page_fault:
-+#endif
++(p15) ld8 r14=[r14]
++ ;;
++(p15) st1 [r14]=r0,MASK_TO_PEND_OFS // if (p15) vpsr.i = 1
++ ;; // if (p15) (vcpu->vcpu_info->evtchn_upcall_mask)=0
++(p15) ld1 r14=[r14] // if (vcpu->vcpu_info->evtchn_upcall_pending)
++ ;;
++(p15) cmp.ne p15,p0=r14,r0
++ ;;
++(p15) XEN_HYPER_SSM_I
++#else
+(p15) ssm psr.i // restore psr.i
++#endif
+ movl r14=ia64_leave_kernel
+ ;;
+ SAVE_REST
@@ -24573,25 +23941,6 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ENTRY(dkey_miss)
+ DBG_FAULT(7)
+ FAULT(7)
-+#ifdef CONFIG_XEN
-+ // Leaving this code inline above results in an IVT section overflow
-+ // There is no particular reason for this code to be here...
-+xen_page_fault:
-+(p15) movl r3=XSI_PSR_I_ADDR
-+ ;;
-+(p15) ld8 r3=[r3]
-+ ;;
-+(p15) st1 [r3]=r0,-1 // if (p15) vpsr.i = 1
-+ mov r14=r0
-+ ;;
-+(p15) ld1 r14=[r3] // if (pending_events)
-+ adds r3=8,r2 // re-set up second base pointer
-+ ;;
-+(p15) cmp.ne p15,p0=r14,r0
-+ ;;
-+ br.cond.sptk.many done_xen_page_fault
-+ ;;
-+#endif
+END(dkey_miss)
+
+ .org ia64_ivt+0x2000
@@ -25014,14 +24363,13 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#ifdef CONFIG_XEN
+(p15) ld8 r16=[r16] // vpsr.i
+ ;;
-+(p15) st1 [r16]=r0,-1 // if (p15) vpsr.i = 1
-+ mov r2=r0
++(p15) st1 [r16]=r0,MASK_TO_PEND_OFS // if (p15) vpsr.i = 1
++ ;; // if (p15) (vcpu->vcpu_info->evtchn_upcall_mask)=0
++(p15) ld1 r2=[r16] // if (vcpu->vcpu_info->evtchn_upcall_pending)
+ ;;
-+(p15) ld1 r2=[r16] // if (pending_events)
++(p15) cmp.ne.unc p6,p0=r2,r0
+ ;;
-+ cmp.ne p6,p0=r2,r0
-+ ;;
-+(p6) ssm psr.i // do a real ssm psr.i
++(p6) XEN_HYPER_SSM_I // do a real ssm psr.i
+#else
+(p15) ssm psr.i // M2 restore psr.i
+#endif
@@ -25867,33 +25215,6 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ DBG_FAULT(66)
+ FAULT(66)
+
-+#ifdef CONFIG_XEN
-+ /*
-+ * There is no particular reason for this code to be here, other than that
-+ * there happens to be space here that would go unused otherwise. If this
-+ * fault ever gets "unreserved", simply moved the following code to a more
-+ * suitable spot...
-+ */
-+
-+GLOBAL_ENTRY(xen_bsw1)
-+ /* FIXME: THIS CODE IS NOT NaT SAFE! */
-+ movl r30=XSI_BANKNUM;
-+ mov r31=1;;
-+ st4 [r30]=r31;
-+ movl r30=XSI_BANK1_R16;
-+ movl r31=XSI_BANK1_R16+8;;
-+ ld8 r16=[r30],16; ld8 r17=[r31],16;;
-+ ld8 r18=[r30],16; ld8 r19=[r31],16;;
-+ ld8 r20=[r30],16; ld8 r21=[r31],16;;
-+ ld8 r22=[r30],16; ld8 r23=[r31],16;;
-+ ld8 r24=[r30],16; ld8 r25=[r31],16;;
-+ ld8 r26=[r30],16; ld8 r27=[r31],16;;
-+ ld8 r28=[r30],16; ld8 r29=[r31],16;;
-+ ld8 r30=[r30]; ld8 r31=[r31];;
-+ br.ret.sptk.many b0
-+END(xen_bsw1)
-+#endif
-+
+ .org ia64_ivt+0x7f00
+/////////////////////////////////////////////////////////////////////////////////////////
+// 0x7f00 Entry 67 (size 16 bundles) Reserved
@@ -26021,11 +25342,45 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ (p6) br.spnt.few 1b // call evtchn_do_upcall again.
+ br.sptk.many ia64_leave_kernel
+END(xen_event_callback)
++
++
++ /*
++ * There is no particular reason for this code to be here, other than that
++ * there happens to be space here that would go unused otherwise. If this
++ * fault ever gets "unreserved", simply moved the following code to a more
++ * suitable spot...
++ */
++
++GLOBAL_ENTRY(xen_bsw1)
++ /* FIXME: THIS CODE IS NOT NaT SAFE! */
++ mov r14=ar.unat
++ movl r30=XSI_B1NAT
++ ;;
++ ld8 r30=[r30];;
++ mov ar.unat=r30
++ movl r30=XSI_BANKNUM;
++ mov r31=1;;
++ st4 [r30]=r31;
++ movl r30=XSI_BANK1_R16;
++ movl r31=XSI_BANK1_R16+8;;
++ ld8.fill r16=[r30],16; ld8.fill r17=[r31],16;;
++ ld8.fill r18=[r30],16; ld8.fill r19=[r31],16;;
++ ld8.fill r20=[r30],16; ld8.fill r21=[r31],16;;
++ ld8.fill r22=[r30],16; ld8.fill r23=[r31],16;;
++ ld8.fill r24=[r30],16; ld8.fill r25=[r31],16;;
++ ld8.fill r26=[r30],16; ld8.fill r27=[r31],16;;
++ ld8.fill r28=[r30],16; ld8.fill r29=[r31],16;;
++ ld8.fill r30=[r30]; ld8.fill r31=[r31];;
++ mov ar.unat=r14
++ br.ret.sptk.many b0
++END(xen_bsw1)
++
++
+#endif
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/arch/ia64/xen/xenminstate.h source/arch/ia64/xen/xenminstate.h
---- /scratch/src/linux-2.6.20.3/arch/ia64/xen/xenminstate.h 1970-01-01 01:00:00.000000000 +0100
-+++ source/arch/ia64/xen/xenminstate.h 2007-03-20 21:26:27.000000000 +0100
-@@ -0,0 +1,368 @@
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 arch/ia64/xen/xenminstate.h
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/arch/ia64/xen/xenminstate.h Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,359 @@
+
+#include <asm/cache.h>
+
@@ -26178,16 +25533,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+.mem.offset 8,0; st8.spill [r17]=r11,24; \
+ ;; \
+ /* xen special handling for possibly lazy cover */ \
-+ movl r8=XSI_INCOMPL_REGFR; \
-+ ;; \
-+ ld4 r30=[r8]; \
-+ ;; \
-+ /* set XSI_INCOMPL_REGFR 0 */ \
-+ st4 [r8]=r0; \
-+ cmp.eq p6,p7=r30,r0; \
-+ ;; /* not sure if this stop bit is necessary */ \
-+(p6) adds r8=XSI_PRECOVER_IFS-XSI_INCOMPL_REGFR,r8; \
-+(p7) adds r8=XSI_IFS-XSI_INCOMPL_REGFR,r8; \
++ movl r8=XSI_PRECOVER_IFS; \
+ ;; \
+ ld8 r30=[r8]; \
+ ;; \
@@ -26394,10 +25740,10 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#else
+#define SAVE_MIN DO_SAVE_MIN( , mov r30=r0, )
+#endif
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/arch/ia64/xen/xenpal.S source/arch/ia64/xen/xenpal.S
---- /scratch/src/linux-2.6.20.3/arch/ia64/xen/xenpal.S 1970-01-01 01:00:00.000000000 +0100
-+++ source/arch/ia64/xen/xenpal.S 2007-03-20 21:26:27.000000000 +0100
-@@ -0,0 +1,76 @@
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 arch/ia64/xen/xenpal.S
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/arch/ia64/xen/xenpal.S Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,85 @@
+/*
+ * ia64/xen/xenpal.S
+ *
@@ -26433,7 +25779,16 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ mov loc4=ar.rsc // save RSE configuration
+ ;;
+ mov ar.rsc=0 // put RSE in enforced lazy, LE mode
++#ifdef CONFIG_XEN
++ mov r9 = r8
++ XEN_HYPER_GET_PSR
++ ;;
++ mov loc3 = r8
++ mov r8 = r9
++ ;;
++#else
+ mov loc3 = psr
++#endif
+ mov loc0 = rp
+ .body
+ mov r30 = in2
@@ -26441,16 +25796,16 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#ifdef CONFIG_XEN
+ // this is low priority for paravirtualization, but is called
+ // from the idle loop so confuses privop counting
-+ movl r31=XSI_PSR_IC
-+ ;;
-+(p6) st4 [r31]=r0
++ movl r31=XSI_PSR_I_ADDR
+ ;;
-+(p7) adds r31=XSI_PSR_I_ADDR_OFS-XSI_PSR_IC_OFS,r31
-+(p7) mov r22=1
++ ld8 r31=[r31]
++ mov r22=1
+ ;;
-+(p7) ld8 r31=[r31]
++ st1 [r31]=r22
++ ;;
++(p6) movl r31=XSI_PSR_IC
+ ;;
-+(p7) st1 [r31]=r22
++(p6) st4.rel [r31]=r0
+ ;;
+ mov r31 = in3
+ mov b7 = loc2
@@ -26474,10 +25829,10 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ srlz.d // seralize restoration of psr.l
+ br.ret.sptk.many b0
+END(xen_pal_call_static)
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/arch/ia64/xen/xensetup.S source/arch/ia64/xen/xensetup.S
---- /scratch/src/linux-2.6.20.3/arch/ia64/xen/xensetup.S 1970-01-01 01:00:00.000000000 +0100
-+++ source/arch/ia64/xen/xensetup.S 2007-03-20 21:26:27.000000000 +0100
-@@ -0,0 +1,53 @@
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 arch/ia64/xen/xensetup.S
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/arch/ia64/xen/xensetup.S Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,52 @@
+/*
+ * Support routines for Xen
+ *
@@ -26517,24 +25872,23 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+/* Stub for suspend.
+ Just force the stacked registers to be written in memory. */
+GLOBAL_ENTRY(xencomm_arch_hypercall_suspend)
-+ mov r15=r32
+ ;;
-+ alloc r20=ar.pfs,0,0,0,0
++ alloc r20=ar.pfs,0,0,6,0
+ mov r2=__HYPERVISOR_sched_op
+ ;;
+ /* We don't want to deal with RSE. */
+ flushrs
-+ mov r14=2 // SCHEDOP_shutdown
++ mov r33=r32
++ mov r32=2 // SCHEDOP_shutdown
+ ;;
+ break 0x1000
+ ;;
-+ mov ar.pfs=r20
+ br.ret.sptk.many b0
+END(xencomm_arch_hypercall_suspend)
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/arch/um/kernel/physmem.c source/arch/um/kernel/physmem.c
---- /scratch/src/linux-2.6.20.3/arch/um/kernel/physmem.c 2007-02-04 19:44:54.000000000 +0100
-+++ source/arch/um/kernel/physmem.c 2007-03-20 21:26:32.000000000 +0100
-@@ -226,7 +226,7 @@ EXPORT_SYMBOL(physmem_forget_descriptor)
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 arch/um/kernel/physmem.c
+--- a/arch/um/kernel/physmem.c Wed Jul 18 12:23:24 2007 -0300
++++ b/arch/um/kernel/physmem.c Wed Aug 08 16:25:28 2007 -0300
+@@ -226,7 +226,7 @@ EXPORT_SYMBOL(physmem_remove_mapping);
EXPORT_SYMBOL(physmem_remove_mapping);
EXPORT_SYMBOL(physmem_subst_mapping);
@@ -26552,10 +25906,292 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
}
int is_remapped(void *virt)
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/arch/x86_64/ia32/ia32entry-xen.S source/arch/x86_64/ia32/ia32entry-xen.S
---- /scratch/src/linux-2.6.20.3/arch/x86_64/ia32/ia32entry-xen.S 1970-01-01 01:00:00.000000000 +0100
-+++ source/arch/x86_64/ia32/ia32entry-xen.S 2007-03-20 21:26:32.000000000 +0100
-@@ -0,0 +1,743 @@
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 arch/x86_64/Kconfig
+--- a/arch/x86_64/Kconfig Wed Jul 18 12:23:24 2007 -0300
++++ b/arch/x86_64/Kconfig Wed Aug 08 16:25:28 2007 -0300
+@@ -34,6 +34,7 @@ config LOCKDEP_SUPPORT
+
+ config STACKTRACE_SUPPORT
+ bool
++ depends on !X86_64_XEN
+ default y
+
+ config SEMAPHORE_SLEEPERS
+@@ -171,6 +172,22 @@ config GENERIC_CPU
+
+ endchoice
+
++config X86_64_XEN
++ bool "Enable Xen compatible kernel"
++ select SWIOTLB
++ help
++ This option will compile a kernel compatible with Xen hypervisor
++
++config X86_NO_TSS
++ bool
++ depends on X86_64_XEN
++ default y
++
++config X86_NO_IDT
++ bool
++ depends on X86_64_XEN
++ default y
++
+ #
+ # Define implied options from the CPU selection here
+ #
+@@ -191,6 +208,7 @@ config X86_INTERNODE_CACHE_BYTES
+
+ config X86_TSC
+ bool
++ depends on !X86_64_XEN
+ default y
+
+ config X86_GOOD_APIC
+@@ -239,7 +257,7 @@ config X86_CPUID
+
+ config X86_HT
+ bool
+- depends on SMP && !MK8
++ depends on SMP && !MK8 && !X86_64_XEN
+ default y
+
+ config MATH_EMULATION
+@@ -253,14 +271,22 @@ config EISA
+
+ config X86_IO_APIC
+ bool
+- default y
++ depends !XEN_UNPRIVILEGED_GUEST
++ default y
++
++config X86_XEN_GENAPIC
++ bool
++ depends X86_64_XEN
++ default XEN_PRIVILEGED_GUEST || SMP
+
+ config X86_LOCAL_APIC
+ bool
++ depends !XEN_UNPRIVILEGED_GUEST
+ default y
+
+ config MTRR
+ bool "MTRR (Memory Type Range Register) support"
++ depends on !XEN_UNPRIVILEGED_GUEST
+ ---help---
+ On Intel P6 family processors (Pentium Pro, Pentium II and later)
+ the Memory Type Range Registers (MTRRs) may be used to control
+@@ -301,7 +327,7 @@ config SMP
+
+ config SCHED_SMT
+ bool "SMT (Hyperthreading) scheduler support"
+- depends on SMP
++ depends on SMP && !X86_64_XEN
+ default n
+ help
+ SMT scheduler support improves the CPU scheduler's decision making
+@@ -311,7 +337,7 @@ config SCHED_SMT
+
+ config SCHED_MC
+ bool "Multi-core scheduler support"
+- depends on SMP
++ depends on SMP && !X86_64_XEN
+ default y
+ help
+ Multi-core scheduler support improves the CPU scheduler's decision
+@@ -322,7 +348,7 @@ source "kernel/Kconfig.preempt"
+
+ config NUMA
+ bool "Non Uniform Memory Access (NUMA) Support"
+- depends on SMP
++ depends on SMP && !X86_64_XEN
+ help
+ Enable NUMA (Non Uniform Memory Access) support. The kernel
+ will try to allocate memory used by a CPU on the local memory
+@@ -378,7 +404,7 @@ config ARCH_DISCONTIGMEM_DEFAULT
+
+ config ARCH_SPARSEMEM_ENABLE
+ def_bool y
+- depends on (NUMA || EXPERIMENTAL)
++ depends on (NUMA || EXPERIMENTAL) && !X86_64_XEN
+
+ config ARCH_MEMORY_PROBE
+ def_bool y
+@@ -406,6 +432,7 @@ config NR_CPUS
+ int "Maximum number of CPUs (2-256)"
+ range 2 255
+ depends on SMP
++ default "16" if X86_64_XEN
+ default "8"
+ help
+ This allows you to specify the maximum number of CPUs which this
+@@ -428,6 +455,7 @@ config ARCH_ENABLE_MEMORY_HOTPLUG
+
+ config HPET_TIMER
+ bool
++ depends on !X86_64_XEN
+ default y
+ help
+ Use the IA-PC HPET (High Precision Event Timer) to manage
+@@ -448,7 +476,7 @@ config IOMMU
+ default y
+ select SWIOTLB
+ select AGP
+- depends on PCI
++ depends on PCI && !X86_64_XEN
+ help
+ Support for full DMA access of devices with 32bit memory access only
+ on systems with more than 3GB. This is usually needed for USB,
+@@ -495,6 +523,7 @@ config SWIOTLB
+
+ config X86_MCE
+ bool "Machine check support" if EMBEDDED
++ depends on !X86_64_XEN
+ default y
+ help
+ Include a machine check error handler to report hardware errors.
+@@ -520,6 +549,7 @@ config X86_MCE_AMD
+
+ config KEXEC
+ bool "kexec system call"
++ depends on !XEN_UNPRIVILEGED_GUEST
+ help
+ kexec is a system call that implements the ability to shutdown your
+ current kernel, and to start another kernel. It is like a reboot
+@@ -645,8 +675,11 @@ config GENERIC_PENDING_IRQ
+ default y
+
+ menu "Power management options"
+-
++ depends on !XEN_UNPRIVILEGED_GUEST
++
++if !X86_64_XEN
+ source kernel/power/Kconfig
++endif
+
+ source "drivers/acpi/Kconfig"
+
+@@ -668,6 +701,21 @@ config PCI_MMCONFIG
+ config PCI_MMCONFIG
+ bool "Support mmconfig PCI config space access"
+ depends on PCI && ACPI
++
++config XEN_PCIDEV_FRONTEND
++ bool "Xen PCI Frontend"
++ depends on PCI && X86_64_XEN
++ default y
++ help
++ The PCI device frontend driver allows the kernel to import arbitrary
++ PCI devices from a PCI backend to support PCI driver domains.
++
++config XEN_PCIDEV_FE_DEBUG
++ bool "Xen PCI Frontend Debugging"
++ depends on XEN_PCIDEV_FRONTEND
++ default n
++ help
++ Enables some debug statements within the PCI Frontend.
+
+ source "drivers/pci/pcie/Kconfig"
+
+@@ -739,4 +787,6 @@ source "security/Kconfig"
+
+ source "crypto/Kconfig"
+
++source "drivers/xen/Kconfig"
++
+ source "lib/Kconfig"
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 arch/x86_64/Makefile
+--- a/arch/x86_64/Makefile Wed Jul 18 12:23:24 2007 -0300
++++ b/arch/x86_64/Makefile Wed Aug 08 16:25:28 2007 -0300
+@@ -35,6 +35,10 @@ cflags-$(CONFIG_MCORE2) += \
+ cflags-$(CONFIG_MCORE2) += \
+ $(call cc-option,-march=core2,$(call cc-option,-mtune=generic))
+ cflags-$(CONFIG_GENERIC_CPU) += $(call cc-option,-mtune=generic)
++
++cppflags-$(CONFIG_XEN) += \
++ -D__XEN_INTERFACE_VERSION__=$(CONFIG_XEN_INTERFACE_VERSION)
++CPPFLAGS += $(cppflags-y)
+
+ cflags-y += -m64
+ cflags-y += -mno-red-zone
+@@ -90,6 +94,21 @@ PHONY += bzImage bzlilo install archmrpr
+ PHONY += bzImage bzlilo install archmrproper \
+ fdimage fdimage144 fdimage288 isoimage archclean
+
++ifdef CONFIG_XEN
++CPPFLAGS := -Iinclude$(if $(KBUILD_SRC),2)/asm/mach-xen $(CPPFLAGS)
++head-y := arch/x86_64/kernel/head-xen.o arch/x86_64/kernel/head64.o arch/x86_64/kernel/init_task.o
++LDFLAGS_vmlinux := -e _start
++boot := arch/i386/boot-xen
++.PHONY: vmlinuz
++#Default target when executing "make"
++all: vmlinuz
++
++vmlinuz: vmlinux
++ $(Q)$(MAKE) $(build)=$(boot) $@
++
++install:
++ $(Q)$(MAKE) $(build)=$(boot) XENGUEST=$(XENGUEST) $@
++else
+ #Default target when executing "make"
+ all: bzImage
+
+@@ -110,6 +129,7 @@ fdimage fdimage144 fdimage288 isoimage:
+
+ install:
+ $(Q)$(MAKE) $(build)=$(boot) BOOTIMAGE=$(BOOTIMAGE) $@
++endif
+
+ archclean:
+ $(Q)$(MAKE) $(clean)=$(boot)
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 arch/x86_64/ia32/Makefile
+--- a/arch/x86_64/ia32/Makefile Wed Jul 18 12:23:24 2007 -0300
++++ b/arch/x86_64/ia32/Makefile Wed Aug 08 16:25:28 2007 -0300
+@@ -14,11 +14,19 @@ audit-class-$(CONFIG_AUDIT) := audit.o
+ audit-class-$(CONFIG_AUDIT) := audit.o
+ obj-$(CONFIG_IA32_EMULATION) += $(audit-class-y)
+
++ifdef CONFIG_XEN
++$(obj)/syscall32_syscall.o: \
++ $(foreach F,int80 sysenter syscall,$(obj)/vsyscall-$F.so)
++
++targets := $(foreach F,int80 sysenter syscall,vsyscall-$F.o vsyscall-$F.so)
++
++else
+ $(obj)/syscall32_syscall.o: \
+ $(foreach F,sysenter syscall,$(obj)/vsyscall-$F.so)
+
+ # Teach kbuild about targets
+ targets := $(foreach F,sysenter syscall,vsyscall-$F.o vsyscall-$F.so)
++endif
+
+ # The DSO images are built using a special linker script
+ quiet_cmd_syscall = SYSCALL $@
+@@ -27,9 +35,20 @@ quiet_cmd_syscall = SYSCALL $@
+ -Wl,-soname=linux-gate.so.1 -o $@ \
+ -Wl,-T,$(filter-out FORCE,$^)
+
++$(obj)/vsyscall-int80.so \
+ $(obj)/vsyscall-sysenter.so $(obj)/vsyscall-syscall.so: \
+ $(obj)/vsyscall-%.so: $(src)/vsyscall.lds $(obj)/vsyscall-%.o FORCE
+ $(call if_changed,syscall)
+
+ AFLAGS_vsyscall-sysenter.o = -m32 -Wa,-32
+ AFLAGS_vsyscall-syscall.o = -m32 -Wa,-32
++
++ifdef CONFIG_XEN
++AFLAGS_vsyscall-int80.o = -m32 -Wa,-32
++CFLAGS_syscall32.o += -DUSE_INT80
++AFLAGS_syscall32_syscall.o += -DUSE_INT80
++
++include $(srctree)/scripts/Makefile.xen
++
++obj-y := $(call cherrypickxen, $(obj-y))
++endif
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 arch/x86_64/ia32/ia32entry-xen.S
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/arch/x86_64/ia32/ia32entry-xen.S Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,744 @@
+/*
+ * Compatibility mode system call entry point for x86-64.
+ *
@@ -26720,7 +26356,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ XEN_UNBLOCK_EVENTS(%r11)
+ __sti /* sti only takes effect after the next instruction */
+ /* sysexit */
-+ .byte 0xf, 0x35
++ .byte 0xf, 0x35 /* TBD */
+
+sysenter_tracesys:
+ CFI_RESTORE_STATE
@@ -26824,7 +26460,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ movl RSP-ARGOFFSET(%rsp),%esp
+ CFI_RESTORE rsp
+ __swapgs
-+ sysretl
++ sysretl /* TBD */
+
+cstar_tracesys:
+ CFI_RESTORE_STATE
@@ -26893,6 +26529,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ pushq %rax
+ CFI_ADJUST_CFA_OFFSET 8
+ cld
++/* 1: jmp 1b */
+ /* note the registers are not zero extended to the sf.
+ this could be a problem. */
+ SAVE_ARGS 0,0,1
@@ -27299,55 +26936,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ .quad compat_sys_move_pages
+ .quad sys_getcpu
+ia32_syscall_end:
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/arch/x86_64/ia32/Makefile source/arch/x86_64/ia32/Makefile
---- /scratch/src/linux-2.6.20.3/arch/x86_64/ia32/Makefile 2007-02-04 19:44:54.000000000 +0100
-+++ source/arch/x86_64/ia32/Makefile 2007-03-20 21:26:32.000000000 +0100
-@@ -14,11 +14,19 @@ obj-$(CONFIG_IA32_AOUT) += ia32_aout.o
- audit-class-$(CONFIG_AUDIT) := audit.o
- obj-$(CONFIG_IA32_EMULATION) += $(audit-class-y)
-
-+ifdef CONFIG_XEN
-+$(obj)/syscall32_syscall.o: \
-+ $(foreach F,int80 sysenter syscall,$(obj)/vsyscall-$F.so)
-+
-+targets := $(foreach F,int80 sysenter syscall,vsyscall-$F.o vsyscall-$F.so)
-+
-+else
- $(obj)/syscall32_syscall.o: \
- $(foreach F,sysenter syscall,$(obj)/vsyscall-$F.so)
-
- # Teach kbuild about targets
- targets := $(foreach F,sysenter syscall,vsyscall-$F.o vsyscall-$F.so)
-+endif
-
- # The DSO images are built using a special linker script
- quiet_cmd_syscall = SYSCALL $@
-@@ -27,9 +35,20 @@ quiet_cmd_syscall = SYSCALL $@
- -Wl,-soname=linux-gate.so.1 -o $@ \
- -Wl,-T,$(filter-out FORCE,$^)
-
-+$(obj)/vsyscall-int80.so \
- $(obj)/vsyscall-sysenter.so $(obj)/vsyscall-syscall.so: \
- $(obj)/vsyscall-%.so: $(src)/vsyscall.lds $(obj)/vsyscall-%.o FORCE
- $(call if_changed,syscall)
-
--AFLAGS_vsyscall-sysenter.o = -m32 -Wa,-32
--AFLAGS_vsyscall-syscall.o = -m32 -Wa,-32
-+AFLAGS_vsyscall-sysenter.o = -m32 -Wa,-32 -Iarch/i386/kernel
-+AFLAGS_vsyscall-syscall.o = -m32 -Wa,-32 -Iarch/i386/kernel
-+
-+ifdef CONFIG_XEN
-+AFLAGS_vsyscall-int80.o = -m32 -Wa,-32 -Iarch/i386/kernel
-+CFLAGS_syscall32.o += -DUSE_INT80
-+AFLAGS_syscall32_syscall.o += -DUSE_INT80
-+
-+include $(srctree)/scripts/Makefile.xen
-+
-+obj-y := $(call cherrypickxen, $(obj-y))
-+endif
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/arch/x86_64/ia32/syscall32.c source/arch/x86_64/ia32/syscall32.c
---- /scratch/src/linux-2.6.20.3/arch/x86_64/ia32/syscall32.c 2007-02-04 19:44:54.000000000 +0100
-+++ source/arch/x86_64/ia32/syscall32.c 2007-03-20 21:26:32.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 arch/x86_64/ia32/syscall32.c
+--- a/arch/x86_64/ia32/syscall32.c Wed Jul 18 12:23:24 2007 -0300
++++ b/arch/x86_64/ia32/syscall32.c Wed Aug 08 16:25:28 2007 -0300
@@ -14,12 +14,17 @@
#include <asm/tlbflush.h>
#include <asm/ia32_unistd.h>
@@ -27410,13 +27001,14 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
wrmsrl(MSR_CSTAR, ia32_cstar_target);
+#endif
}
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/arch/x86_64/ia32/syscall32_syscall.S source/arch/x86_64/ia32/syscall32_syscall.S
---- /scratch/src/linux-2.6.20.3/arch/x86_64/ia32/syscall32_syscall.S 2007-02-04 19:44:54.000000000 +0100
-+++ source/arch/x86_64/ia32/syscall32_syscall.S 2007-03-20 21:26:32.000000000 +0100
-@@ -2,6 +2,17 @@
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 arch/x86_64/ia32/syscall32_syscall.S
+--- a/arch/x86_64/ia32/syscall32_syscall.S Wed Jul 18 12:23:24 2007 -0300
++++ b/arch/x86_64/ia32/syscall32_syscall.S Wed Aug 08 16:25:28 2007 -0300
+@@ -1,6 +1,17 @@
+ /* 32bit VDSOs mapped into user space. */
.section ".init.data","aw"
-
++
+#ifdef USE_INT80
+
+ .globl syscall32_int80
@@ -27427,13 +27019,12 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+syscall32_int80_end:
+
+#endif
-+
+
.globl syscall32_syscall
.globl syscall32_syscall_end
-
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/arch/x86_64/ia32/vsyscall-int80.S source/arch/x86_64/ia32/vsyscall-int80.S
---- /scratch/src/linux-2.6.20.3/arch/x86_64/ia32/vsyscall-int80.S 1970-01-01 01:00:00.000000000 +0100
-+++ source/arch/x86_64/ia32/vsyscall-int80.S 2007-03-20 21:26:32.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 arch/x86_64/ia32/vsyscall-int80.S
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/arch/x86_64/ia32/vsyscall-int80.S Wed Aug 08 16:25:28 2007 -0300
@@ -0,0 +1,58 @@
+/*
+ * Code for the vsyscall page. This version uses the old int $0x80 method.
@@ -27493,211 +27084,45 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ */
+#define SYSCALL_ENTER_KERNEL int $0x80
+#include "vsyscall-sigreturn.S"
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/arch/x86_64/ia32/vsyscall-sigreturn.S source/arch/x86_64/ia32/vsyscall-sigreturn.S
---- /scratch/src/linux-2.6.20.3/arch/x86_64/ia32/vsyscall-sigreturn.S 2007-02-04 19:44:54.000000000 +0100
-+++ source/arch/x86_64/ia32/vsyscall-sigreturn.S 2007-03-20 21:26:32.000000000 +0100
-@@ -139,5 +139,5 @@ __kernel_rt_sigreturn:
- .align 4
- .LENDFDE3:
-
--#include "../../i386/kernel/vsyscall-note.S"
-+#include <vsyscall-note.S>
-
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/arch/x86_64/Kconfig source/arch/x86_64/Kconfig
---- /scratch/src/linux-2.6.20.3/arch/x86_64/Kconfig 2007-02-04 19:44:54.000000000 +0100
-+++ source/arch/x86_64/Kconfig 2007-03-20 21:26:32.000000000 +0100
-@@ -34,6 +34,7 @@ config LOCKDEP_SUPPORT
-
- config STACKTRACE_SUPPORT
- bool
-+ depends on !X86_64_XEN
- default y
-
- config SEMAPHORE_SLEEPERS
-@@ -171,6 +172,22 @@ config GENERIC_CPU
-
- endchoice
-
-+config X86_64_XEN
-+ bool "Enable Xen compatible kernel"
-+ select SWIOTLB
-+ help
-+ This option will compile a kernel compatible with Xen hypervisor
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 arch/x86_64/kernel/Makefile
+--- a/arch/x86_64/kernel/Makefile Wed Jul 18 12:23:24 2007 -0300
++++ b/arch/x86_64/kernel/Makefile Wed Aug 08 16:25:28 2007 -0300
+@@ -21,11 +21,13 @@ obj-$(CONFIG_X86_CPUID) += cpuid.o
+ obj-$(CONFIG_X86_CPUID) += cpuid.o
+ obj-$(CONFIG_SMP) += smp.o smpboot.o trampoline.o
+ obj-y += apic.o nmi.o
++obj-$(CONFIG_X86_XEN_GENAPIC) += genapic.o genapic_xen.o
+ obj-y += io_apic.o mpparse.o \
+ genapic.o genapic_cluster.o genapic_flat.o
+ obj-$(CONFIG_KEXEC) += machine_kexec.o relocate_kernel.o crash.o
+ obj-$(CONFIG_CRASH_DUMP) += crash_dump.o
+-obj-$(CONFIG_PM) += suspend.o
++obj-$(CONFIG_SOFTWARE_SUSPEND) += suspend.o
++obj-$(CONFIG_ACPI_SLEEP) += suspend.o
+ obj-$(CONFIG_SOFTWARE_SUSPEND) += suspend_asm.o
+ obj-$(CONFIG_CPU_FREQ) += cpufreq/
+ obj-$(CONFIG_EARLY_PRINTK) += early_printk.o
+@@ -56,3 +58,17 @@ i8237-y += ../../i386/kernel/i8237.o
+ i8237-y += ../../i386/kernel/i8237.o
+ msr-$(subst m,y,$(CONFIG_X86_MSR)) += ../../i386/kernel/msr.o
+ alternative-y += ../../i386/kernel/alternative.o
+
-+config X86_NO_TSS
-+ bool
-+ depends on X86_64_XEN
-+ default y
++ifdef CONFIG_XEN
++pci-dma-y += ../../i386/kernel/pci-dma-xen.o
++microcode-$(subst m,y,$(CONFIG_MICROCODE)) := ../../i386/kernel/microcode-xen.o
+
-+config X86_NO_IDT
-+ bool
-+ depends on X86_64_XEN
-+ default y
++n-obj-xen := i8259.o reboot.o i8237.o smpboot.o trampoline.o
+
- #
- # Define implied options from the CPU selection here
- #
-@@ -191,6 +208,7 @@ config X86_INTERNODE_CACHE_BYTES
-
- config X86_TSC
- bool
-+ depends on !X86_64_XEN
- default y
-
- config X86_GOOD_APIC
-@@ -239,7 +257,7 @@ config X86_CPUID
-
- config X86_HT
- bool
-- depends on SMP && !MK8
-+ depends on SMP && !MK8 && !X86_64_XEN
- default y
-
- config MATH_EMULATION
-@@ -253,14 +271,22 @@ config EISA
-
- config X86_IO_APIC
- bool
-+ depends !XEN_UNPRIVILEGED_GUEST
- default y
-
-+config X86_XEN_GENAPIC
-+ bool
-+ depends X86_64_XEN
-+ default XEN_PRIVILEGED_GUEST || SMP
++include $(srctree)/scripts/Makefile.xen
+
- config X86_LOCAL_APIC
- bool
-+ depends !XEN_UNPRIVILEGED_GUEST
- default y
-
- config MTRR
- bool "MTRR (Memory Type Range Register) support"
-+ depends on !XEN_UNPRIVILEGED_GUEST
- ---help---
- On Intel P6 family processors (Pentium Pro, Pentium II and later)
- the Memory Type Range Registers (MTRRs) may be used to control
-@@ -301,7 +327,7 @@ config SMP
-
- config SCHED_SMT
- bool "SMT (Hyperthreading) scheduler support"
-- depends on SMP
-+ depends on SMP && !X86_64_XEN
- default n
- help
- SMT scheduler support improves the CPU scheduler's decision making
-@@ -311,7 +337,7 @@ config SCHED_SMT
-
- config SCHED_MC
- bool "Multi-core scheduler support"
-- depends on SMP
-+ depends on SMP && !X86_64_XEN
- default y
- help
- Multi-core scheduler support improves the CPU scheduler's decision
-@@ -322,7 +348,7 @@ source "kernel/Kconfig.preempt"
-
- config NUMA
- bool "Non Uniform Memory Access (NUMA) Support"
-- depends on SMP
-+ depends on SMP && !X86_64_XEN
- help
- Enable NUMA (Non Uniform Memory Access) support. The kernel
- will try to allocate memory used by a CPU on the local memory
-@@ -378,7 +404,7 @@ config ARCH_DISCONTIGMEM_DEFAULT
-
- config ARCH_SPARSEMEM_ENABLE
- def_bool y
-- depends on (NUMA || EXPERIMENTAL)
-+ depends on (NUMA || EXPERIMENTAL) && !X86_64_XEN
-
- config ARCH_MEMORY_PROBE
- def_bool y
-@@ -406,6 +432,7 @@ config NR_CPUS
- int "Maximum number of CPUs (2-256)"
- range 2 255
- depends on SMP
-+ default "16" if X86_64_XEN
- default "8"
- help
- This allows you to specify the maximum number of CPUs which this
-@@ -428,6 +455,7 @@ config ARCH_ENABLE_MEMORY_HOTPLUG
-
- config HPET_TIMER
- bool
-+ depends on !X86_64_XEN
- default y
- help
- Use the IA-PC HPET (High Precision Event Timer) to manage
-@@ -448,7 +476,7 @@ config IOMMU
- default y
- select SWIOTLB
- select AGP
-- depends on PCI
-+ depends on PCI && !X86_64_XEN
- help
- Support for full DMA access of devices with 32bit memory access only
- on systems with more than 3GB. This is usually needed for USB,
-@@ -495,6 +523,7 @@ config SWIOTLB
-
- config X86_MCE
- bool "Machine check support" if EMBEDDED
-+ depends on !X86_64_XEN
- default y
- help
- Include a machine check error handler to report hardware errors.
-@@ -520,6 +549,7 @@ config X86_MCE_AMD
-
- config KEXEC
- bool "kexec system call"
-+ depends on !XEN_UNPRIVILEGED_GUEST
- help
- kexec is a system call that implements the ability to shutdown your
- current kernel, and to start another kernel. It is like a reboot
-@@ -645,8 +675,11 @@ config GENERIC_PENDING_IRQ
- default y
-
- menu "Power management options"
-+ depends on !XEN_UNPRIVILEGED_GUEST
-
-+if !X86_64_XEN
- source kernel/power/Kconfig
++obj-y := $(call filterxen, $(obj-y), $(n-obj-xen))
++obj-y := $(call cherrypickxen, $(obj-y))
++extra-y := $(call cherrypickxen, $(extra-y))
++%/head-xen.o %/head-xen.s: EXTRA_AFLAGS :=
+endif
-
- source "drivers/acpi/Kconfig"
-
-@@ -669,6 +702,21 @@ config PCI_MMCONFIG
- bool "Support mmconfig PCI config space access"
- depends on PCI && ACPI
-
-+config XEN_PCIDEV_FRONTEND
-+ bool "Xen PCI Frontend"
-+ depends on PCI && X86_64_XEN
-+ default y
-+ help
-+ The PCI device frontend driver allows the kernel to import arbitrary
-+ PCI devices from a PCI backend to support PCI driver domains.
-+
-+config XEN_PCIDEV_FE_DEBUG
-+ bool "Xen PCI Frontend Debugging"
-+ depends on XEN_PCIDEV_FRONTEND
-+ default n
-+ help
-+ Enables some debug statements within the PCI Frontend.
-+
- source "drivers/pci/pcie/Kconfig"
-
- source "drivers/pci/Kconfig"
-@@ -739,4 +787,6 @@ source "security/Kconfig"
-
- source "crypto/Kconfig"
-
-+source "drivers/xen/Kconfig"
-+
- source "lib/Kconfig"
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/arch/x86_64/kernel/apic-xen.c source/arch/x86_64/kernel/apic-xen.c
---- /scratch/src/linux-2.6.20.3/arch/x86_64/kernel/apic-xen.c 1970-01-01 01:00:00.000000000 +0100
-+++ source/arch/x86_64/kernel/apic-xen.c 2007-03-20 21:26:32.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 arch/x86_64/kernel/apic-xen.c
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/arch/x86_64/kernel/apic-xen.c Wed Aug 08 16:25:28 2007 -0300
@@ -0,0 +1,254 @@
+/*
+ * Local APIC handling, local APIC timers
@@ -27953,9 +27378,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+__setup("noapictimer", setup_noapictimer);
+
+#endif
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/arch/x86_64/kernel/asm-offsets.c source/arch/x86_64/kernel/asm-offsets.c
---- /scratch/src/linux-2.6.20.3/arch/x86_64/kernel/asm-offsets.c 2007-02-04 19:44:54.000000000 +0100
-+++ source/arch/x86_64/kernel/asm-offsets.c 2007-03-20 21:26:32.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 arch/x86_64/kernel/asm-offsets.c
+--- a/arch/x86_64/kernel/asm-offsets.c Wed Jul 18 12:23:24 2007 -0300
++++ b/arch/x86_64/kernel/asm-offsets.c Wed Aug 08 16:25:28 2007 -0300
@@ -67,8 +67,10 @@ int main(void)
DEFINE(pbe_address, offsetof(struct pbe, address));
DEFINE(pbe_orig_address, offsetof(struct pbe, orig_address));
@@ -27967,9 +27392,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
BLANK();
DEFINE(crypto_tfm_ctx_offset, offsetof(struct crypto_tfm, __crt_ctx));
return 0;
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/arch/x86_64/kernel/crash.c source/arch/x86_64/kernel/crash.c
---- /scratch/src/linux-2.6.20.3/arch/x86_64/kernel/crash.c 2007-02-04 19:44:54.000000000 +0100
-+++ source/arch/x86_64/kernel/crash.c 2007-03-20 21:26:32.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 arch/x86_64/kernel/crash.c
+--- a/arch/x86_64/kernel/crash.c Wed Jul 18 12:23:24 2007 -0300
++++ b/arch/x86_64/kernel/crash.c Wed Aug 08 16:25:28 2007 -0300
@@ -28,6 +28,7 @@
/* This keeps a track of which one is crashing cpu. */
static int crashing_cpu;
@@ -28002,10 +27427,10 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#endif /* CONFIG_XEN */
crash_save_cpu(regs, smp_processor_id());
}
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/arch/x86_64/kernel/e820-xen.c source/arch/x86_64/kernel/e820-xen.c
---- /scratch/src/linux-2.6.20.3/arch/x86_64/kernel/e820-xen.c 1970-01-01 01:00:00.000000000 +0100
-+++ source/arch/x86_64/kernel/e820-xen.c 2007-03-20 21:26:32.000000000 +0100
-@@ -0,0 +1,762 @@
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 arch/x86_64/kernel/e820-xen.c
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/arch/x86_64/kernel/e820-xen.c Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,773 @@
+/*
+ * Handle the memory map.
+ * The functions here do the job until bootmem takes over.
@@ -28131,8 +27556,19 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+int __init e820_all_mapped(unsigned long start, unsigned long end, unsigned type)
+{
+ int i;
++
++#ifndef CONFIG_XEN
+ for (i = 0; i < e820.nr_map; i++) {
+ struct e820entry *ei = &e820.map[i];
++#else
++ extern struct e820map machine_e820;
++
++ if (!is_initial_xendomain())
++ return 0;
++ for (i = 0; i < machine_e820.nr_map; i++) {
++ const struct e820entry *ei = &machine_e820.map[i];
++#endif
++
+ if (type && ei->type != type)
+ continue;
+ /* is the region (part) in overlap with the current region ?*/
@@ -28768,27 +28204,22 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ printk(KERN_INFO "Allocating PCI resources starting at %lx (gap: %lx:%lx)\n",
+ pci_mem_start, gapstart, gapsize);
+}
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/arch/x86_64/kernel/early_printk.c source/arch/x86_64/kernel/early_printk.c
---- /scratch/src/linux-2.6.20.3/arch/x86_64/kernel/early_printk.c 2007-02-04 19:44:54.000000000 +0100
-+++ source/arch/x86_64/kernel/early_printk.c 2007-03-20 21:26:32.000000000 +0100
-@@ -20,6 +20,7 @@
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 arch/x86_64/kernel/early_printk.c
+--- a/arch/x86_64/kernel/early_printk.c Wed Jul 18 12:23:24 2007 -0300
++++ b/arch/x86_64/kernel/early_printk.c Wed Aug 08 16:25:28 2007 -0300
+@@ -17,6 +17,7 @@
+ #define VGABASE ((void __iomem *)0xffffffff800b8000UL)
+ #endif
+
++#ifndef CONFIG_XEN
static int max_ypos = 25, max_xpos = 80;
static int current_ypos = 25, current_xpos = 0;
-+#ifndef CONFIG_XEN
- static void early_vga_write(struct console *con, const char *str, unsigned n)
- {
- char c;
-@@ -149,6 +150,39 @@ static __init void early_serial_init(cha
+@@ -149,6 +150,33 @@ static __init void early_serial_init(cha
outb(c & ~DLAB, early_serial_base + LCR);
}
+#else /* CONFIG_XEN */
-+
-+#undef SCREEN_INFO
-+#define SCREEN_INFO screen_info
-+extern struct screen_info screen_info;
-+
+static void
+early_serial_write(struct console *con, const char *s, unsigned count)
+{
@@ -28805,7 +28236,6 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+
+static __init void early_serial_init(char *s)
+{
-+ current_xpos = 0;
+}
+
+/*
@@ -28819,10 +28249,25 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
static struct console early_serial_console = {
.name = "earlyser",
.write = early_serial_write,
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/arch/x86_64/kernel/entry-xen.S source/arch/x86_64/kernel/entry-xen.S
---- /scratch/src/linux-2.6.20.3/arch/x86_64/kernel/entry-xen.S 1970-01-01 01:00:00.000000000 +0100
-+++ source/arch/x86_64/kernel/entry-xen.S 2007-03-20 21:26:32.000000000 +0100
-@@ -0,0 +1,1160 @@
+@@ -234,10 +262,14 @@ static int __init setup_early_printk(cha
+ early_serial_init(buf);
+ early_console = &early_serial_console;
+ } else if (!strncmp(buf, "vga", 3)
++#ifndef CONFIG_XEN
+ && SCREEN_INFO.orig_video_isVGA == 1) {
+ max_xpos = SCREEN_INFO.orig_video_cols;
+ max_ypos = SCREEN_INFO.orig_video_lines;
+ current_ypos = SCREEN_INFO.orig_y;
++#else
++ || !strncmp(buf, "xen", 3)) {
++#endif
+ early_console = &early_vga_console;
+ } else if (!strncmp(buf, "simnow", 6)) {
+ simnow_init(buf + 6);
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 arch/x86_64/kernel/entry-xen.S
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/arch/x86_64/kernel/entry-xen.S Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,1206 @@
+/*
+ * linux/arch/x86_64/entry.S
+ *
@@ -28949,20 +28394,22 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ CFI_ADJUST_CFA_OFFSET -(6*8)
+ .endm
+
-+ .macro CFI_DEFAULT_STACK start=1
++ .macro CFI_DEFAULT_STACK start=1,adj=0
+ .if \start
+ CFI_STARTPROC simple
+ CFI_SIGNAL_FRAME
-+ CFI_DEF_CFA rsp,SS+8
++ CFI_DEF_CFA rsp,SS+8-(\adj*ARGOFFSET)
+ .else
-+ CFI_DEF_CFA_OFFSET SS+8
++ CFI_DEF_CFA_OFFSET SS+8-(\adj*ARGOFFSET)
+ .endif
++ .if \adj == 0
+ CFI_REL_OFFSET r15,R15
+ CFI_REL_OFFSET r14,R14
+ CFI_REL_OFFSET r13,R13
+ CFI_REL_OFFSET r12,R12
+ CFI_REL_OFFSET rbp,RBP
+ CFI_REL_OFFSET rbx,RBX
++ .endif
+ CFI_REL_OFFSET r11,R11
+ CFI_REL_OFFSET r10,R10
+ CFI_REL_OFFSET r9,R9
@@ -28980,11 +28427,11 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ .endm
+
+ /*
-+ * Must be consistent with the definition in arch-x86_64.h:
++ * Must be consistent with the definition in arch-x86/xen-x86_64.h:
+ * struct iret_context {
+ * u64 rax, r11, rcx, flags, rip, cs, rflags, rsp, ss;
+ * };
-+ * #define VGCF_IN_SYSCALL (1<<8)
++ * with rax, r11, and rcx being taken care of in the hypercall stub.
+ */
+ .macro HYPERVISOR_IRET flag
+ testb $3,1*8(%rsp)
@@ -28992,26 +28439,20 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ testl $NMI_MASK,2*8(%rsp)
+ jnz 2f
+
-+ testb $1,(xen_features+XENFEAT_supervisor_mode_kernel)
-+ jnz 1f
++ cmpb $0,(xen_features+XENFEAT_supervisor_mode_kernel)(%rip)
++ jne 1f
+
+ /* Direct iret to kernel space. Correct CS and SS. */
-+ orb $3,1*8(%rsp)
-+ orb $3,4*8(%rsp)
++ orl $3,1*8(%rsp)
++ orl $3,4*8(%rsp)
+1: iretq
+
+2: /* Slow iret via hypervisor. */
-+ andl $~NMI_MASK, 16(%rsp)
++ andl $~NMI_MASK, 2*8(%rsp)
+ pushq $\flag
+ jmp hypercall_page + (__HYPERVISOR_iret * 32)
+ .endm
+
-+ .macro SWITCH_TO_KERNEL ssoff,adjust=0
-+ jc 1f
-+ orb $1,\ssoff-\adjust+4(%rsp)
-+1:
-+ .endm
-+
+/*
+ * A newly forked process directly context switches into this.
+ */
@@ -29043,6 +28484,19 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+END(ret_from_fork)
+
+/*
++ * initial frame state for interrupts and exceptions
++ */
++ .macro _frame ref
++ CFI_STARTPROC simple
++ CFI_DEF_CFA rsp,SS+8-\ref
++ /*CFI_REL_OFFSET ss,SS-\ref*/
++ CFI_REL_OFFSET rsp,RSP-\ref
++ /*CFI_REL_OFFSET rflags,EFLAGS-\ref*/
++ /*CFI_REL_OFFSET cs,CS-\ref*/
++ CFI_REL_OFFSET rip,RIP-\ref
++ .endm
++
++/*
+ * System call entry. Upto 6 arguments in registers are supported.
+ *
+ * SYSCALL does not save anything on the stack and does not change the
@@ -29074,11 +28528,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ */
+
+ENTRY(system_call)
-+ CFI_STARTPROC simple
-+ CFI_SIGNAL_FRAME
-+ CFI_DEF_CFA rsp,PDA_STACKOFFSET
-+ CFI_REGISTER rip,rcx
-+ /*CFI_REGISTER rflags,r11*/
++ _frame (RIP-0x10)
+ SAVE_ARGS -8,0
+ movq %rax,ORIG_RAX-ARGOFFSET(%rsp)
+ /*
@@ -29114,9 +28564,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ */
+ TRACE_IRQS_ON
+ XEN_UNBLOCK_EVENTS(%rsi)
-+ CFI_REGISTER rip,rcx
+ RESTORE_ARGS 0,8,0
-+ /*CFI_REGISTER rflags,r11*/
+ HYPERVISOR_IRET VGCF_IN_SYSCALL
+
+ CFI_RESTORE_STATE
@@ -29324,25 +28772,16 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ CFI_ENDPROC
+END(stub_rt_sigreturn)
+
-+/*
-+ * initial frame state for interrupts and exceptions
-+ */
-+ .macro _frame ref
-+ CFI_STARTPROC simple
-+ CFI_SIGNAL_FRAME
-+ CFI_DEF_CFA rsp,SS+8-\ref
-+ /*CFI_REL_OFFSET ss,SS-\ref*/
-+ CFI_REL_OFFSET rsp,RSP-\ref
-+ /*CFI_REL_OFFSET rflags,EFLAGS-\ref*/
-+ /*CFI_REL_OFFSET cs,CS-\ref*/
-+ CFI_REL_OFFSET rip,RIP-\ref
-+ .endm
-+
+/* initial frame state for interrupts (and exceptions without error code) */
-+#define INTR_FRAME _frame RIP
++#define INTR_FRAME _frame (RIP-0x10); \
++ CFI_REL_OFFSET rcx,0; \
++ CFI_REL_OFFSET r11,8
++
+/* initial frame state for exceptions with error code (and interrupts with
+ vector already pushed) */
-+#define XCPT_FRAME _frame ORIG_RAX
++#define XCPT_FRAME _frame (RIP-0x18); \
++ CFI_REL_OFFSET rcx,0; \
++ CFI_REL_OFFSET r11,8
+
+/*
+ * Interrupt exit.
@@ -29350,6 +28789,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ */
+
+retint_check:
++ CFI_DEFAULT_STACK adj=1
+ movl threadinfo_flags(%rcx),%edx
+ andl %edi,%edx
+ CFI_REMEMBER_STATE
@@ -29415,8 +28855,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#endif
+
+ CFI_ENDPROC
-+END(common_interrupt)
++END(retint_check)
+
++#ifndef CONFIG_XEN
+/*
+ * APIC interrupts.
+ */
@@ -29429,7 +28870,6 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ CFI_ENDPROC
+ .endm
+
-+#ifndef CONFIG_XEN
+ENTRY(thermal_interrupt)
+ apicinterrupt THERMAL_APIC_VECTOR,smp_thermal_interrupt
+END(thermal_interrupt)
@@ -29482,12 +28922,16 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ .macro zeroentry sym
+ INTR_FRAME
+ movq (%rsp),%rcx
++ CFI_RESTORE rcx
+ movq 8(%rsp),%r11
++ CFI_RESTORE r11
+ addq $0x10,%rsp /* skip rcx and r11 */
++ CFI_ADJUST_CFA_OFFSET -0x10
+ pushq $0 /* push error code/oldrax */
+ CFI_ADJUST_CFA_OFFSET 8
+ pushq %rax /* push real oldrax to the rdi slot */
+ CFI_ADJUST_CFA_OFFSET 8
++ CFI_REL_OFFSET rax,0
+ leaq \sym(%rip),%rax
+ jmp error_entry
+ CFI_ENDPROC
@@ -29496,10 +28940,14 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ .macro errorentry sym
+ XCPT_FRAME
+ movq (%rsp),%rcx
++ CFI_RESTORE rcx
+ movq 8(%rsp),%r11
++ CFI_RESTORE r11
+ addq $0x10,%rsp /* rsp points to the error code */
++ CFI_ADJUST_CFA_OFFSET -0x10
+ pushq %rax
+ CFI_ADJUST_CFA_OFFSET 8
++ CFI_REL_OFFSET rax,0
+ leaq \sym(%rip),%rax
+ jmp error_entry
+ CFI_ENDPROC
@@ -29550,6 +28998,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ */
+KPROBE_ENTRY(error_entry)
+ _frame RDI
++ CFI_REL_OFFSET rax,0
+ /* rdi slot contains rax, oldrax contains error code */
+ cld
+ subq $14*8,%rsp
@@ -29557,6 +29006,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ movq %rsi,13*8(%rsp)
+ CFI_REL_OFFSET rsi,RSI
+ movq 14*8(%rsp),%rsi /* load rax from rdi slot */
++ CFI_REGISTER rax,rsi
+ movq %rdx,12*8(%rsp)
+ CFI_REL_OFFSET rdx,RDX
+ movq %rcx,11*8(%rsp)
@@ -29585,10 +29035,12 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ CFI_REL_OFFSET r15,R15
+#if 0
+ cmpl $__KERNEL_CS,CS(%rsp)
++ CFI_REMEMBER_STATE
+ je error_kernelspace
+#endif
+error_call_handler:
+ movq %rdi,RDI(%rsp)
++ CFI_REL_OFFSET rdi,RDI
+ movq %rsp,%rdi
+ movq ORIG_RAX(%rsp),%rsi /* get error code */
+ movq $-1,ORIG_RAX(%rsp)
@@ -29604,9 +29056,13 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ movl $_TIF_WORK_MASK,%edi
+ andl %edi,%edx
+ jnz retint_careful
++ /*
++ * The iret might restore flags:
++ */
++ TRACE_IRQS_IRETQ
+ jmp retint_restore_args
+
-+error_kernelspace:
++#if 0
+ /*
+ * We need to re-write the logic here because we don't do iretq to
+ * to return to user mode. It's still possible that we get trap/fault
@@ -29614,7 +29070,8 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ * for example).
+ *
+ */
-+#if 0
++ CFI_RESTORE_STATE
++error_kernelspace:
+ incl %ebx
+ /* There are two places in the kernel that can potentially fault with
+ usergs. Handle them here. The exception handlers after
@@ -29631,10 +29088,12 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ je error_swapgs
+ jmp error_sti
+#endif
++ CFI_ENDPROC
+KPROBE_END(error_entry)
+
+ENTRY(hypervisor_callback)
+ zeroentry do_hypervisor_callback
++END(hypervisor_callback)
+
+/*
+ * Copied from arch/xen/i386/kernel/entry.S
@@ -29651,46 +29110,64 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+# existing activation in its critical region -- if so, we pop the current
+# activation and restart the handler using the previous one.
+ENTRY(do_hypervisor_callback) # do_hypervisor_callback(struct *pt_regs)
++ CFI_STARTPROC
+# Since we don't modify %rdi, evtchn_do_upall(struct *pt_regs) will
+# see the correct pointer to the pt_regs
+ movq %rdi, %rsp # we don't return, adjust the stack frame
-+11: movq %gs:pda_irqstackptr,%rax
-+ incl %gs:pda_irqcount
-+ cmovzq %rax,%rsp
-+ pushq %rdi
++ CFI_ENDPROC
++ CFI_DEFAULT_STACK
++11: incl %gs:pda_irqcount
++ movq %rsp,%rbp
++ CFI_DEF_CFA_REGISTER rbp
++ cmovzq %gs:pda_irqstackptr,%rsp
++ pushq %rbp # backlink for old unwinder
+ call evtchn_do_upcall
+ popq %rsp
++ CFI_DEF_CFA_REGISTER rsp
+ decl %gs:pda_irqcount
+ jmp error_exit
++ CFI_ENDPROC
++END(do_hypervisor_callback)
+
+KPROBE_ENTRY(nmi)
-+ zeroentry do_nmi_callback
++ zeroentry xen_do_nmi_callback
+ENTRY(xen_do_nmi_callback)
++ CFI_STARTPROC
+ addq $8, %rsp
++ CFI_ENDPROC
++ CFI_DEFAULT_STACK
+ call do_nmi
+ orl $NMI_MASK,EFLAGS(%rsp)
+ RESTORE_REST
+ XEN_BLOCK_EVENTS(%rsi)
++ TRACE_IRQS_OFF
+ GET_THREAD_INFO(%rcx)
+ jmp retint_restore_args
++ CFI_ENDPROC
+ .previous .text
++KPROBE_END(nmi)
+
+ ALIGN
+restore_all_enable_events:
++ CFI_DEFAULT_STACK adj=1
++ TRACE_IRQS_ON
+ XEN_UNBLOCK_EVENTS(%rsi) # %rsi is already set up...
+
+scrit: /**** START OF CRITICAL REGION ****/
+ XEN_TEST_PENDING(%rsi)
++ CFI_REMEMBER_STATE
+ jnz 14f # process more events if necessary...
+ XEN_PUT_VCPU_INFO(%rsi)
+ RESTORE_ARGS 0,8,0
+ HYPERVISOR_IRET 0
+
++ CFI_RESTORE_STATE
+14: XEN_LOCKED_BLOCK_EVENTS(%rsi)
+ XEN_PUT_VCPU_INFO(%rsi)
+ SAVE_REST
+ movq %rsp,%rdi # set the argument again
+ jmp 11b
++ CFI_ENDPROC
+ecrit: /**** END OF CRITICAL REGION ****/
+# At this point, unlike on x86-32, we don't do the fixup to simplify the
+# code and the stack frame is more complex on x86-64.
@@ -29710,8 +29187,12 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+# We distinguish between categories by comparing each saved segment register
+# with its current contents: any discrepancy means we in category 1.
+ENTRY(failsafe_callback)
++ _frame (RIP-0x30)
++ CFI_REL_OFFSET rcx, 0
++ CFI_REL_OFFSET r11, 8
+ movw %ds,%cx
+ cmpw %cx,0x10(%rsp)
++ CFI_REMEMBER_STATE
+ jne 1f
+ movw %es,%cx
+ cmpw %cx,0x18(%rsp)
@@ -29724,17 +29205,26 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ jne 1f
+ /* All segments match their saved values => Category 2 (Bad IRET). */
+ movq (%rsp),%rcx
++ CFI_RESTORE rcx
+ movq 8(%rsp),%r11
++ CFI_RESTORE r11
+ addq $0x30,%rsp
-+ movq $-9999,%rdi /* better code? */
++ CFI_ADJUST_CFA_OFFSET -0x30
++ movq $11,%rdi /* SIGSEGV */
+ jmp do_exit
++ CFI_RESTORE_STATE
+1: /* Segment mismatch => Category 1 (Bad segment). Retry the IRET. */
+ movq (%rsp),%rcx
++ CFI_RESTORE rcx
+ movq 8(%rsp),%r11
++ CFI_RESTORE r11
+ addq $0x30,%rsp
++ CFI_ADJUST_CFA_OFFSET -0x30
+ pushq $0
++ CFI_ADJUST_CFA_OFFSET 8
+ SAVE_ALL
+ jmp error_exit
++ CFI_ENDPROC
+#if 0
+ .section __ex_table,"a"
+ .align 8
@@ -29856,14 +29346,13 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+
+ /* runs on exception stack */
+KPROBE_ENTRY(debug)
-+ INTR_FRAME
-+/* pushq $0
++/* INTR_FRAME
++ pushq $0
+ CFI_ADJUST_CFA_OFFSET 8 */
+ zeroentry do_debug
-+/* jmp paranoid_exit */
++/* paranoid_exit */
+ CFI_ENDPROC
+KPROBE_END(debug)
-+ .previous .text
+
+#if 0
+ /* runs on exception stack */
@@ -29883,11 +29372,11 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#endif
+
+KPROBE_ENTRY(int3)
-+ INTR_FRAME
-+/* pushq $0
++/* INTR_FRAME
++ pushq $0
+ CFI_ADJUST_CFA_OFFSET 8 */
+ zeroentry do_int3
-+/* jmp paranoid_exit */
++/* jmp paranoid_exit1 */
+ CFI_ENDPROC
+KPROBE_END(int3)
+
@@ -29931,9 +29420,11 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+
+ /* runs on exception stack */
+ENTRY(stack_segment)
-+ XCPT_FRAME
++/* XCPT_FRAME
++ paranoidentry do_stack_segment */
+ errorentry do_stack_segment
-+ CFI_ENDPROC
++/* jmp paranoid_exit1
++ CFI_ENDPROC */
+END(stack_segment)
+
+KPROBE_ENTRY(general_protection)
@@ -29983,9 +29474,58 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ ret
+ CFI_ENDPROC
+ENDPROC(call_softirq)
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/arch/x86_64/kernel/genapic_xen.c source/arch/x86_64/kernel/genapic_xen.c
---- /scratch/src/linux-2.6.20.3/arch/x86_64/kernel/genapic_xen.c 1970-01-01 01:00:00.000000000 +0100
-+++ source/arch/x86_64/kernel/genapic_xen.c 2007-03-20 21:26:32.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 arch/x86_64/kernel/genapic.c
+--- a/arch/x86_64/kernel/genapic.c Wed Jul 18 12:23:24 2007 -0300
++++ b/arch/x86_64/kernel/genapic.c Wed Aug 08 16:25:28 2007 -0300
+@@ -32,14 +32,20 @@ extern struct genapic apic_flat;
+ extern struct genapic apic_flat;
+ extern struct genapic apic_physflat;
+
++#ifndef CONFIG_XEN
+ struct genapic *genapic = &apic_flat;
+ struct genapic *genapic_force;
++#else
++extern struct genapic apic_xen;
++struct genapic *genapic = &apic_xen;
++#endif
+
+ /*
+ * Check the APIC IDs in bios_cpu_apicid and choose the APIC mode.
+ */
+ void __init clustered_apic_check(void)
+ {
++#ifndef CONFIG_XEN
+ long i;
+ u8 clusters, max_cluster;
+ u8 id;
+@@ -121,12 +127,24 @@ void __init clustered_apic_check(void)
+ genapic = &apic_cluster;
+
+ print:
++#else
++ /* hardcode to xen apic functions */
++ genapic = &apic_xen;
++#endif
+ printk(KERN_INFO "Setting APIC routing to %s\n", genapic->name);
+ }
+
+ /* Same for both flat and clustered. */
+
++#ifdef CONFIG_XEN
++extern void xen_send_IPI_shortcut(unsigned int shortcut, int vector, unsigned int dest);
++#endif
++
+ void send_IPI_self(int vector)
+ {
++#ifndef CONFIG_XEN
+ __send_IPI_shortcut(APIC_DEST_SELF, vector, APIC_DEST_PHYSICAL);
++#else
++ xen_send_IPI_shortcut(APIC_DEST_SELF, vector, APIC_DEST_PHYSICAL);
++#endif
+ }
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 arch/x86_64/kernel/genapic_xen.c
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/arch/x86_64/kernel/genapic_xen.c Wed Aug 08 16:25:28 2007 -0300
@@ -0,0 +1,190 @@
+/*
+ * Copyright 2004 James Cleverdon, IBM.
@@ -30177,275 +29717,10 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ .cpu_mask_to_apicid = xen_cpu_mask_to_apicid,
+ .phys_pkg_id = phys_pkg_id,
+};
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/arch/x86_64/kernel/genapic-xen.c source/arch/x86_64/kernel/genapic-xen.c
---- /scratch/src/linux-2.6.20.3/arch/x86_64/kernel/genapic-xen.c 1970-01-01 01:00:00.000000000 +0100
-+++ source/arch/x86_64/kernel/genapic-xen.c 2007-03-20 21:26:32.000000000 +0100
-@@ -0,0 +1,143 @@
-+/*
-+ * Copyright 2004 James Cleverdon, IBM.
-+ * Subject to the GNU Public License, v.2
-+ *
-+ * Generic APIC sub-arch probe layer.
-+ *
-+ * Hacked for x86-64 by James Cleverdon from i386 architecture code by
-+ * Martin Bligh, Andi Kleen, James Bottomley, John Stultz, and
-+ * James Cleverdon.
-+ */
-+#include <linux/threads.h>
-+#include <linux/cpumask.h>
-+#include <linux/string.h>
-+#include <linux/kernel.h>
-+#include <linux/ctype.h>
-+#include <linux/init.h>
-+#include <linux/module.h>
-+
-+#include <asm/smp.h>
-+#include <asm/ipi.h>
-+
-+#if defined(CONFIG_ACPI)
-+#include <acpi/acpi_bus.h>
-+#endif
-+
-+/* which logical CPU number maps to which CPU (physical APIC ID) */
-+u8 x86_cpu_to_apicid[NR_CPUS] __read_mostly = { [0 ... NR_CPUS-1] = BAD_APICID };
-+EXPORT_SYMBOL(x86_cpu_to_apicid);
-+u8 x86_cpu_to_log_apicid[NR_CPUS] = { [0 ... NR_CPUS-1] = BAD_APICID };
-+
-+extern struct genapic apic_cluster;
-+extern struct genapic apic_flat;
-+extern struct genapic apic_physflat;
-+
-+#ifndef CONFIG_XEN
-+struct genapic *genapic = &apic_flat;
-+#else
-+extern struct genapic apic_xen;
-+struct genapic *genapic = &apic_xen;
-+#endif
-+
-+
-+/*
-+ * Check the APIC IDs in bios_cpu_apicid and choose the APIC mode.
-+ */
-+void __init clustered_apic_check(void)
-+{
-+#ifndef CONFIG_XEN
-+ long i;
-+ u8 clusters, max_cluster;
-+ u8 id;
-+ u8 cluster_cnt[NUM_APIC_CLUSTERS];
-+ int max_apic = 0;
-+
-+#if defined(CONFIG_ACPI)
-+ /*
-+ * Some x86_64 machines use physical APIC mode regardless of how many
-+ * procs/clusters are present (x86_64 ES7000 is an example).
-+ */
-+ if (acpi_fadt.revision > FADT2_REVISION_ID)
-+ if (acpi_fadt.force_apic_physical_destination_mode) {
-+ genapic = &apic_cluster;
-+ goto print;
-+ }
-+#endif
-+
-+ memset(cluster_cnt, 0, sizeof(cluster_cnt));
-+ for (i = 0; i < NR_CPUS; i++) {
-+ id = bios_cpu_apicid[i];
-+ if (id == BAD_APICID)
-+ continue;
-+ if (id > max_apic)
-+ max_apic = id;
-+ cluster_cnt[APIC_CLUSTERID(id)]++;
-+ }
-+
-+ /* Don't use clustered mode on AMD platforms. */
-+ if (boot_cpu_data.x86_vendor == X86_VENDOR_AMD) {
-+ genapic = &apic_physflat;
-+#ifndef CONFIG_HOTPLUG_CPU
-+ /* In the CPU hotplug case we cannot use broadcast mode
-+ because that opens a race when a CPU is removed.
-+ Stay at physflat mode in this case.
-+ It is bad to do this unconditionally though. Once
-+ we have ACPI platform support for CPU hotplug
-+ we should detect hotplug capablity from ACPI tables and
-+ only do this when really needed. -AK */
-+ if (max_apic <= 8)
-+ genapic = &apic_flat;
-+#endif
-+ goto print;
-+ }
-+
-+ clusters = 0;
-+ max_cluster = 0;
-+
-+ for (i = 0; i < NUM_APIC_CLUSTERS; i++) {
-+ if (cluster_cnt[i] > 0) {
-+ ++clusters;
-+ if (cluster_cnt[i] > max_cluster)
-+ max_cluster = cluster_cnt[i];
-+ }
-+ }
-+
-+ /*
-+ * If we have clusters <= 1 and CPUs <= 8 in cluster 0, then flat mode,
-+ * else if max_cluster <= 4 and cluster_cnt[15] == 0, clustered logical
-+ * else physical mode.
-+ * (We don't use lowest priority delivery + HW APIC IRQ steering, so
-+ * can ignore the clustered logical case and go straight to physical.)
-+ */
-+ if (clusters <= 1 && max_cluster <= 8 && cluster_cnt[0] == max_cluster) {
-+#ifdef CONFIG_HOTPLUG_CPU
-+ /* Don't use APIC shortcuts in CPU hotplug to avoid races */
-+ genapic = &apic_physflat;
-+#else
-+ genapic = &apic_flat;
-+#endif
-+ } else
-+ genapic = &apic_cluster;
-+
-+print:
-+#else
-+ /* hardcode to xen apic functions */
-+ genapic = &apic_xen;
-+#endif
-+ printk(KERN_INFO "Setting APIC routing to %s\n", genapic->name);
-+}
-+
-+/* Same for both flat and clustered. */
-+
-+#ifdef CONFIG_XEN
-+extern void xen_send_IPI_shortcut(unsigned int shortcut, int vector, unsigned int dest);
-+#endif
-+
-+void send_IPI_self(int vector)
-+{
-+#ifndef CONFIG_XEN
-+ __send_IPI_shortcut(APIC_DEST_SELF, vector, APIC_DEST_PHYSICAL);
-+#else
-+ xen_send_IPI_shortcut(APIC_DEST_SELF, vector, APIC_DEST_PHYSICAL);
-+#endif
-+}
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/arch/x86_64/kernel/head64.c source/arch/x86_64/kernel/head64.c
---- /scratch/src/linux-2.6.20.3/arch/x86_64/kernel/head64.c 2007-02-04 19:44:54.000000000 +0100
-+++ source/arch/x86_64/kernel/head64.c 2007-03-20 21:26:32.000000000 +0100
-@@ -2,6 +2,9 @@
- * linux/arch/x86_64/kernel/head64.c -- prepare to run common code
- *
- * Copyright (C) 2000 Andrea Arcangeli <andrea@suse.de> SuSE
-+ *
-+ * Jun Nakajima <jun.nakajima@intel.com>
-+ * Modified for Xen.
- */
-
- #include <linux/init.h>
-@@ -10,6 +13,7 @@
- #include <linux/kernel.h>
- #include <linux/string.h>
- #include <linux/percpu.h>
-+#include <linux/module.h>
-
- #include <asm/processor.h>
- #include <asm/proto.h>
-@@ -20,13 +24,19 @@
- #include <asm/pgtable.h>
- #include <asm/sections.h>
-
-+#ifdef CONFIG_XEN
-+unsigned long start_pfn;
-+#endif
-+
- /* Don't add a printk in there. printk relies on the PDA which is not initialized
- yet. */
-+#ifndef CONFIG_XEN
- static void __init clear_bss(void)
- {
- memset(__bss_start, 0,
- (unsigned long) __bss_stop - (unsigned long) __bss_start);
- }
-+#endif
-
- #define NEW_CL_POINTER 0x228 /* Relative to real mode data */
- #define OLD_CL_MAGIC_ADDR 0x90020
-@@ -38,6 +48,7 @@ extern char saved_command_line[];
-
- static void __init copy_bootdata(char *real_mode_data)
- {
-+#ifndef CONFIG_XEN
- int new_data;
- char * command_line;
-
-@@ -51,26 +62,67 @@ static void __init copy_bootdata(char *r
- }
- command_line = (char *) ((u64)(new_data));
- memcpy(saved_command_line, command_line, COMMAND_LINE_SIZE);
-+#else
-+ int max_cmdline;
-+
-+ if ((max_cmdline = MAX_GUEST_CMDLINE) > COMMAND_LINE_SIZE)
-+ max_cmdline = COMMAND_LINE_SIZE;
-+ memcpy(saved_command_line, xen_start_info->cmd_line, max_cmdline);
-+ saved_command_line[max_cmdline-1] = '\0';
-+#endif
- }
-
-+#ifdef CONFIG_XEN
-+#include <xen/interface/memory.h>
-+unsigned long *machine_to_phys_mapping;
-+EXPORT_SYMBOL(machine_to_phys_mapping);
-+unsigned int machine_to_phys_order;
-+EXPORT_SYMBOL(machine_to_phys_order);
-+#endif
-+
- void __init x86_64_start_kernel(char * real_mode_data)
- {
-+#ifdef CONFIG_XEN
-+ struct xen_machphys_mapping mapping;
-+ unsigned long machine_to_phys_nr_ents;
-+#endif
- int i;
-
-+#ifdef CONFIG_XEN
-+ xen_start_info = (struct start_info *)real_mode_data;
-+ if (!xen_feature(XENFEAT_auto_translated_physmap)) {
-+ phys_to_machine_mapping =
-+ (unsigned long *)xen_start_info->mfn_list;
-+ start_pfn = (__pa(xen_start_info->pt_base) >> PAGE_SHIFT) +
-+ xen_start_info->nr_pt_frames;
-+ }
-+
-+ machine_to_phys_mapping = (unsigned long *)MACH2PHYS_VIRT_START;
-+ machine_to_phys_nr_ents = MACH2PHYS_NR_ENTRIES;
-+ if (HYPERVISOR_memory_op(XENMEM_machphys_mapping, &mapping) == 0) {
-+ machine_to_phys_mapping = (unsigned long *)mapping.v_start;
-+ machine_to_phys_nr_ents = mapping.max_mfn + 1;
-+ }
-+ while ((1UL << machine_to_phys_order) < machine_to_phys_nr_ents )
-+ machine_to_phys_order++;
-+
-+#else
- /* clear bss before set_intr_gate with early_idt_handler */
- clear_bss();
-
- for (i = 0; i < IDT_ENTRIES; i++)
- set_intr_gate(i, early_idt_handler);
- asm volatile("lidt %0" :: "m" (idt_descr));
--
-+#endif /* CONFIG_XEN */
- early_printk("Kernel alive\n");
-
-+#ifndef CONFIG_XEN
- /*
- * switch to init_level4_pgt from boot_level4_pgt
- */
- memcpy(init_level4_pgt, boot_level4_pgt, PTRS_PER_PGD*sizeof(pgd_t));
- asm volatile("movq %0,%%cr3" :: "r" (__pa_symbol(&init_level4_pgt)));
-+#endif
-
- for (i = 0; i < NR_CPUS; i++)
- cpu_pda(i) = &boot_cpu_pda[i];
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/arch/x86_64/kernel/head-xen.S source/arch/x86_64/kernel/head-xen.S
---- /scratch/src/linux-2.6.20.3/arch/x86_64/kernel/head-xen.S 1970-01-01 01:00:00.000000000 +0100
-+++ source/arch/x86_64/kernel/head-xen.S 2007-03-20 21:26:32.000000000 +0100
-@@ -0,0 +1,189 @@
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 arch/x86_64/kernel/head-xen.S
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/arch/x86_64/kernel/head-xen.S Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,206 @@
+/*
+ * linux/arch/x86_64/kernel/head.S -- start in 32bit and switch to 64bit
+ *
@@ -30468,11 +29743,10 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#include <asm/page.h>
+#include <asm/msr.h>
+#include <asm/cache.h>
-+
++#include <asm/dwarf2.h>
+#include <xen/interface/elfnote.h>
+
-+ .text
-+ .section .bootstrap.text
++ .section .bootstrap.text, "ax", @progbits
+ .code64
+#define VIRT_ENTRY_OFFSET 0x0
+.org VIRT_ENTRY_OFFSET
@@ -30480,13 +29754,11 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+startup_64:
+ENTRY(_start)
+ movq $(init_thread_union+THREAD_SIZE-8),%rsp
-+ /* zero EFLAGS after setting rsp */
-+ pushq $0
-+ popfq
+
+ /* rsi is pointer to startup info structure.
+ pass it to C */
+ movq %rsi,%rdi
++ pushq $0 # fake return address
+ jmp x86_64_start_kernel
+
+ENTRY(stext)
@@ -30496,7 +29768,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#define NEXT_PAGE(name) \
+ $page = $page + 1; \
+ .org $page * 0x1000; \
-+ phys_/**/name = $page * 0x1000 + __PHYSICAL_START; \
++ phys_##name = $page * 0x1000 + __PHYSICAL_START; \
+ENTRY(name)
+
+NEXT_PAGE(init_level4_pgt)
@@ -30527,7 +29799,25 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ .fill 512,8,0
+
+NEXT_PAGE(hypercall_page)
-+ .fill 512,8,0
++ CFI_STARTPROC
++ .rept 0x1000 / 0x20
++ .skip 1 /* push %rcx */
++ CFI_ADJUST_CFA_OFFSET 8
++ CFI_REL_OFFSET rcx,0
++ .skip 2 /* push %r11 */
++ CFI_ADJUST_CFA_OFFSET 8
++ CFI_REL_OFFSET rcx,0
++ .skip 5 /* mov $#,%eax */
++ .skip 2 /* syscall */
++ .skip 2 /* pop %r11 */
++ CFI_ADJUST_CFA_OFFSET -8
++ CFI_RESTORE r11
++ .skip 1 /* pop %rcx */
++ CFI_ADJUST_CFA_OFFSET -8
++ CFI_RESTORE rcx
++ .align 0x20,0 /* ret */
++ .endr
++ CFI_ENDPROC
+
+#undef NEXT_PAGE
+
@@ -30588,7 +29878,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ENTRY(empty_zero_page)
+ .skip PAGE_SIZE
+
-+#ifdef CONFIG_XEN_COMPAT_030002
++#if CONFIG_XEN_COMPAT <= 0x030002
+/*
+ * __xen_guest information
+ */
@@ -30620,25 +29910,146 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ .ascii "|supervisor_mode_kernel"
+ .ascii ",LOADER=generic"
+ .byte 0
-+#endif /* CONFIG_XEN_COMPAT_030002 */
++#endif /* CONFIG_XEN_COMPAT <= 0x030002 */
+
+ ELFNOTE(Xen, XEN_ELFNOTE_GUEST_OS, .asciz, "linux")
+ ELFNOTE(Xen, XEN_ELFNOTE_GUEST_VERSION, .asciz, "2.6")
+ ELFNOTE(Xen, XEN_ELFNOTE_XEN_VERSION, .asciz, "xen-3.0")
+ ELFNOTE(Xen, XEN_ELFNOTE_VIRT_BASE, .quad, __START_KERNEL_map)
-+#ifdef CONFIG_XEN_COMPAT_030002
++#if CONFIG_XEN_COMPAT <= 0x030002
+ ELFNOTE(Xen, XEN_ELFNOTE_PADDR_OFFSET, .quad, __START_KERNEL_map)
+#else
+ ELFNOTE(Xen, XEN_ELFNOTE_PADDR_OFFSET, .quad, 0)
-+#endif /* !CONFIG_XEN_COMPAT_030002 */
++#endif
+ ELFNOTE(Xen, XEN_ELFNOTE_ENTRY, .quad, startup_64)
+ ELFNOTE(Xen, XEN_ELFNOTE_HYPERCALL_PAGE, .quad, hypercall_page)
++ ELFNOTE(Xen, XEN_ELFNOTE_L1_MFN_VALID, .quad, _PAGE_PRESENT,_PAGE_PRESENT)
+ ELFNOTE(Xen, XEN_ELFNOTE_FEATURES, .asciz, "writable_page_tables|writable_descriptor_tables|auto_translated_physmap|pae_pgdir_above_4gb|supervisor_mode_kernel")
+ ELFNOTE(Xen, XEN_ELFNOTE_LOADER, .asciz, "generic")
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/arch/x86_64/kernel/init_task.c source/arch/x86_64/kernel/init_task.c
---- /scratch/src/linux-2.6.20.3/arch/x86_64/kernel/init_task.c 2007-02-04 19:44:54.000000000 +0100
-+++ source/arch/x86_64/kernel/init_task.c 2007-03-20 21:26:32.000000000 +0100
-@@ -37,6 +37,8 @@ union thread_union init_thread_union
++ ELFNOTE(Xen, XEN_ELFNOTE_SUSPEND_CANCEL, .long, 1)
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 arch/x86_64/kernel/head64.c
+--- a/arch/x86_64/kernel/head64.c Wed Jul 18 12:23:24 2007 -0300
++++ b/arch/x86_64/kernel/head64.c Wed Aug 08 16:25:28 2007 -0300
+@@ -2,6 +2,9 @@
+ * linux/arch/x86_64/kernel/head64.c -- prepare to run common code
+ *
+ * Copyright (C) 2000 Andrea Arcangeli <andrea@suse.de> SuSE
++ *
++ * Jun Nakajima <jun.nakajima@intel.com>
++ * Modified for Xen.
+ */
+
+ #include <linux/init.h>
+@@ -10,6 +13,7 @@
+ #include <linux/kernel.h>
+ #include <linux/string.h>
+ #include <linux/percpu.h>
++#include <linux/module.h>
+
+ #include <asm/processor.h>
+ #include <asm/proto.h>
+@@ -20,13 +24,19 @@
+ #include <asm/pgtable.h>
+ #include <asm/sections.h>
+
++#ifdef CONFIG_XEN
++unsigned long start_pfn;
++#endif
++
+ /* Don't add a printk in there. printk relies on the PDA which is not initialized
+ yet. */
++#ifndef CONFIG_XEN
+ static void __init clear_bss(void)
+ {
+ memset(__bss_start, 0,
+ (unsigned long) __bss_stop - (unsigned long) __bss_start);
+ }
++#endif
+
+ #define NEW_CL_POINTER 0x228 /* Relative to real mode data */
+ #define OLD_CL_MAGIC_ADDR 0x90020
+@@ -38,6 +48,7 @@ extern char saved_command_line[];
+
+ static void __init copy_bootdata(char *real_mode_data)
+ {
++#ifndef CONFIG_XEN
+ int new_data;
+ char * command_line;
+
+@@ -51,26 +62,68 @@ static void __init copy_bootdata(char *r
+ }
+ command_line = (char *) ((u64)(new_data));
+ memcpy(saved_command_line, command_line, COMMAND_LINE_SIZE);
++#else
++ int max_cmdline;
++
++ if ((max_cmdline = MAX_GUEST_CMDLINE) > COMMAND_LINE_SIZE)
++ max_cmdline = COMMAND_LINE_SIZE;
++ memcpy(saved_command_line, xen_start_info->cmd_line, max_cmdline);
++ saved_command_line[max_cmdline-1] = '\0';
++#endif
+ }
++
++#ifdef CONFIG_XEN
++#include <xen/interface/memory.h>
++unsigned long *machine_to_phys_mapping;
++EXPORT_SYMBOL(machine_to_phys_mapping);
++unsigned int machine_to_phys_order;
++EXPORT_SYMBOL(machine_to_phys_order);
++#endif
+
+ void __init x86_64_start_kernel(char * real_mode_data)
+ {
++#ifdef CONFIG_XEN
++ struct xen_machphys_mapping mapping;
++ unsigned long machine_to_phys_nr_ents;
++#endif
+ int i;
+
++#ifdef CONFIG_XEN
++ setup_xen_features();
++
++ xen_start_info = (struct start_info *)real_mode_data;
++ if (!xen_feature(XENFEAT_auto_translated_physmap))
++ phys_to_machine_mapping =
++ (unsigned long *)xen_start_info->mfn_list;
++ start_pfn = (__pa(xen_start_info->pt_base) >> PAGE_SHIFT) +
++ xen_start_info->nr_pt_frames;
++
++ machine_to_phys_mapping = (unsigned long *)MACH2PHYS_VIRT_START;
++ machine_to_phys_nr_ents = MACH2PHYS_NR_ENTRIES;
++ if (HYPERVISOR_memory_op(XENMEM_machphys_mapping, &mapping) == 0) {
++ machine_to_phys_mapping = (unsigned long *)mapping.v_start;
++ machine_to_phys_nr_ents = mapping.max_mfn + 1;
++ }
++ while ((1UL << machine_to_phys_order) < machine_to_phys_nr_ents )
++ machine_to_phys_order++;
++
++#else
+ /* clear bss before set_intr_gate with early_idt_handler */
+ clear_bss();
+
+ for (i = 0; i < IDT_ENTRIES; i++)
+ set_intr_gate(i, early_idt_handler);
+ asm volatile("lidt %0" :: "m" (idt_descr));
+-
++#endif /* CONFIG_XEN */
+ early_printk("Kernel alive\n");
+
++#ifndef CONFIG_XEN
+ /*
+ * switch to init_level4_pgt from boot_level4_pgt
+ */
+ memcpy(init_level4_pgt, boot_level4_pgt, PTRS_PER_PGD*sizeof(pgd_t));
+ asm volatile("movq %0,%%cr3" :: "r" (__pa_symbol(&init_level4_pgt)));
++#endif
+
+ for (i = 0; i < NR_CPUS; i++)
+ cpu_pda(i) = &boot_cpu_pda[i];
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 arch/x86_64/kernel/init_task.c
+--- a/arch/x86_64/kernel/init_task.c Wed Jul 18 12:23:24 2007 -0300
++++ b/arch/x86_64/kernel/init_task.c Wed Aug 08 16:25:28 2007 -0300
+@@ -37,6 +37,8 @@ struct task_struct init_task = INIT_TASK
struct task_struct init_task = INIT_TASK(init_task);
EXPORT_SYMBOL(init_task);
@@ -30647,17 +30058,16 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
/*
* per-CPU TSS segments. Threads are completely 'soft' on Linux,
* no more per-task TSS's. The TSS size is kept cacheline-aligned
-@@ -45,6 +47,7 @@ EXPORT_SYMBOL(init_task);
- * on exact cacheline boundaries, to eliminate cacheline ping-pong.
- */
- DEFINE_PER_CPU(struct tss_struct, init_tss) ____cacheline_internodealigned_in_smp = INIT_TSS;
+@@ -50,5 +52,6 @@ DEFINE_PER_CPU(struct tss_struct, init_t
+ * debugging, no special alignment required.
+ */
+ DEFINE_PER_CPU(struct orig_ist, orig_ist);
+#endif
- /* Copies of the original ist values from the tss are only accessed during
- * debugging, no special alignment required.
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/arch/x86_64/kernel/io_apic-xen.c source/arch/x86_64/kernel/io_apic-xen.c
---- /scratch/src/linux-2.6.20.3/arch/x86_64/kernel/io_apic-xen.c 1970-01-01 01:00:00.000000000 +0100
-+++ source/arch/x86_64/kernel/io_apic-xen.c 2007-03-20 21:26:32.000000000 +0100
+ #define ALIGN_TO_4K __attribute__((section(".data.init_task")))
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 arch/x86_64/kernel/io_apic-xen.c
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/arch/x86_64/kernel/io_apic-xen.c Wed Aug 08 16:25:28 2007 -0300
@@ -0,0 +1,2221 @@
+/*
+ * Intel IO-APIC support for multi-Pentium hosts.
@@ -31393,12 +30803,11 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ struct physdev_irq irq_op;
+ int vector;
+
-+ BUG_ON((unsigned)irq >= NR_IRQ_VECTORS);
-+
+ if (irq_vector[irq] > 0) {
+ cpus_and(*result, irq_domain[irq], mask);
+ return irq_vector[irq];
+ }
++
+ irq_op.irq = irq;
+ if (HYPERVISOR_physdev_op(PHYSDEVOP_alloc_irq_vector, &irq_op))
+ return -ENOSPC;
@@ -32398,6 +31807,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+}
+#else
+#define check_timer() ((void)0)
++int timer_uses_ioapic_pin_0 = 0;
+#endif /* !CONFIG_XEN */
+
+static int __init notimercheck(char *s)
@@ -32880,10 +32290,10 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+}
+#endif
+#endif /* !CONFIG_XEN */
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/arch/x86_64/kernel/ioport-xen.c source/arch/x86_64/kernel/ioport-xen.c
---- /scratch/src/linux-2.6.20.3/arch/x86_64/kernel/ioport-xen.c 1970-01-01 01:00:00.000000000 +0100
-+++ source/arch/x86_64/kernel/ioport-xen.c 2007-03-20 21:26:32.000000000 +0100
-@@ -0,0 +1,99 @@
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 arch/x86_64/kernel/ioport-xen.c
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/arch/x86_64/kernel/ioport-xen.c Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,100 @@
+/*
+ * linux/arch/x86_64/kernel/ioport.c
+ *
@@ -32909,12 +32319,13 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+static void set_bitmap(unsigned long *bitmap, unsigned int base, unsigned int extent, int new_value)
+{
+ int i;
-+ if (new_value)
-+ for (i = base; i < base + extent; i++)
-+ __set_bit(i, bitmap);
-+ else
-+ for (i = base; i < base + extent; i++)
-+ clear_bit(i, bitmap);
++
++ if (new_value)
++ for (i = base; i < base + extent; i++)
++ __set_bit(i, bitmap);
++ else
++ for (i = base; i < base + extent; i++)
++ clear_bit(i, bitmap);
+}
+
+/*
@@ -32945,7 +32356,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ t->io_bitmap_ptr = bitmap;
+ set_thread_flag(TIF_IO_BITMAP);
+
-+ set_iobitmap.bitmap = (char *)bitmap;
++ set_xen_guest_handle(set_iobitmap.bitmap, (char *)bitmap);
+ set_iobitmap.nr_ports = IO_BITMAP_BITS;
+ HYPERVISOR_physdev_op(PHYSDEVOP_set_iobitmap, &set_iobitmap);
+ }
@@ -32983,9 +32394,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+
+ return 0;
+}
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/arch/x86_64/kernel/irq.c source/arch/x86_64/kernel/irq.c
---- /scratch/src/linux-2.6.20.3/arch/x86_64/kernel/irq.c 2007-03-20 21:30:35.000000000 +0100
-+++ source/arch/x86_64/kernel/irq.c 2007-03-20 21:33:43.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 arch/x86_64/kernel/irq.c
+--- a/arch/x86_64/kernel/irq.c Wed Jul 18 12:23:24 2007 -0300
++++ b/arch/x86_64/kernel/irq.c Wed Aug 08 16:25:28 2007 -0300
@@ -113,7 +113,11 @@ asmlinkage unsigned int do_IRQ(struct pt
exit_idle();
@@ -32998,9 +32409,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
#ifdef CONFIG_DEBUG_STACKOVERFLOW
stack_overflow_check(regs);
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/arch/x86_64/kernel/ldt-xen.c source/arch/x86_64/kernel/ldt-xen.c
---- /scratch/src/linux-2.6.20.3/arch/x86_64/kernel/ldt-xen.c 1970-01-01 01:00:00.000000000 +0100
-+++ source/arch/x86_64/kernel/ldt-xen.c 2007-03-20 21:26:32.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 arch/x86_64/kernel/ldt-xen.c
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/arch/x86_64/kernel/ldt-xen.c Wed Aug 08 16:25:28 2007 -0300
@@ -0,0 +1,283 @@
+/*
+ * linux/arch/x86_64/kernel/ldt.c
@@ -33285,10 +32696,10 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ }
+ return ret;
+}
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/arch/x86_64/kernel/machine_kexec.c source/arch/x86_64/kernel/machine_kexec.c
---- /scratch/src/linux-2.6.20.3/arch/x86_64/kernel/machine_kexec.c 2007-02-04 19:44:54.000000000 +0100
-+++ source/arch/x86_64/kernel/machine_kexec.c 2007-03-21 14:49:46.000000000 +0100
-@@ -24,6 +24,104 @@ static u64 kexec_pud1[512] PAGE_ALIGNED;
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 arch/x86_64/kernel/machine_kexec.c
+--- a/arch/x86_64/kernel/machine_kexec.c Wed Jul 18 12:23:24 2007 -0300
++++ b/arch/x86_64/kernel/machine_kexec.c Wed Aug 08 16:25:28 2007 -0300
+@@ -24,6 +24,104 @@ static u64 kexec_pmd1[512] PAGE_ALIGNED;
static u64 kexec_pmd1[512] PAGE_ALIGNED;
static u64 kexec_pte1[512] PAGE_ALIGNED;
@@ -33432,7 +32843,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
addr += PGDIR_SIZE;
}
out:
-@@ -108,10 +206,17 @@ out:
+@@ -108,10 +206,17 @@ static int init_pgtable(struct kimage *i
static int init_pgtable(struct kimage *image, unsigned long start_pgtable)
{
pgd_t *level4p;
@@ -33444,9 +32855,11 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+
level4p = (pgd_t *)__va(start_pgtable);
- return init_level4_page(image, level4p, 0, end_pfn << PAGE_SHIFT);
+-}
+-
+ return init_level4_page(image, level4p, 0, x_end_pfn << PAGE_SHIFT);
- }
-
++}
++
+#ifndef CONFIG_XEN
static void set_idt(void *newidt, u16 limit)
{
@@ -33480,54 +32893,21 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
}
early_param("crashkernel", setup_crashkernel);
-
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/arch/x86_64/kernel/Makefile source/arch/x86_64/kernel/Makefile
---- /scratch/src/linux-2.6.20.3/arch/x86_64/kernel/Makefile 2007-02-04 19:44:54.000000000 +0100
-+++ source/arch/x86_64/kernel/Makefile 2007-03-20 21:26:32.000000000 +0100
-@@ -21,11 +21,13 @@ obj-$(CONFIG_MICROCODE) += microcode.o
- obj-$(CONFIG_X86_CPUID) += cpuid.o
- obj-$(CONFIG_SMP) += smp.o smpboot.o trampoline.o
- obj-y += apic.o nmi.o
-+obj-$(CONFIG_X86_XEN_GENAPIC) += genapic.o genapic_xen.o
- obj-y += io_apic.o mpparse.o \
- genapic.o genapic_cluster.o genapic_flat.o
- obj-$(CONFIG_KEXEC) += machine_kexec.o relocate_kernel.o crash.o
- obj-$(CONFIG_CRASH_DUMP) += crash_dump.o
--obj-$(CONFIG_PM) += suspend.o
-+obj-$(CONFIG_SOFTWARE_SUSPEND) += suspend.o
-+obj-$(CONFIG_ACPI_SLEEP) += suspend.o
- obj-$(CONFIG_SOFTWARE_SUSPEND) += suspend_asm.o
- obj-$(CONFIG_CPU_FREQ) += cpufreq/
- obj-$(CONFIG_EARLY_PRINTK) += early_printk.o
-@@ -56,3 +58,17 @@ quirks-y += ../../i386/kernel/quirks.o
- i8237-y += ../../i386/kernel/i8237.o
- msr-$(subst m,y,$(CONFIG_X86_MSR)) += ../../i386/kernel/msr.o
- alternative-y += ../../i386/kernel/alternative.o
-+
-+ifdef CONFIG_XEN
-+obj-y += irqflags.o
-+irqflags-y += ../../i386/mach-xen/irqflags.o
-+pci-dma-y += ../../i386/kernel/pci-dma-xen.o
-+microcode-$(subst m,y,$(CONFIG_MICROCODE)) := ../../i386/kernel/microcode-xen.o
-+n-obj-xen := i8259.o reboot.o i8237.o smpboot.o trampoline.o
-+
-+include $(srctree)/scripts/Makefile.xen
-+
-+obj-y := $(call filterxen, $(obj-y), $(n-obj-xen))
-+obj-y := $(call cherrypickxen, $(obj-y))
-+extra-y := $(call cherrypickxen, $(extra-y))
-+endif
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/arch/x86_64/kernel/mpparse.c source/arch/x86_64/kernel/mpparse.c
---- /scratch/src/linux-2.6.20.3/arch/x86_64/kernel/mpparse.c 2007-02-04 19:44:54.000000000 +0100
-+++ source/arch/x86_64/kernel/mpparse.c 2007-03-20 21:26:32.000000000 +0100
-@@ -90,6 +90,7 @@ static int __init mpf_checksum(unsigned
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 arch/x86_64/kernel/mpparse.c
+--- a/arch/x86_64/kernel/mpparse.c Wed Jul 18 12:23:24 2007 -0300
++++ b/arch/x86_64/kernel/mpparse.c Wed Aug 08 16:25:28 2007 -0300
+@@ -88,8 +88,10 @@ static int __init mpf_checksum(unsigned
+ return sum & 0xFF;
+ }
++#ifndef CONFIG_XEN
static void __cpuinit MP_processor_info (struct mpc_config_processor *m)
{
+#ifndef CONFIG_XEN
int cpu;
cpumask_t tmp_map;
char *bootup_cpu = "";
-@@ -110,8 +111,9 @@ static void __cpuinit MP_processor_info
+@@ -110,8 +112,9 @@ static void __cpuinit MP_processor_info
" Processor ignored.\n", NR_CPUS);
return;
}
@@ -33538,15 +32918,23 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
cpus_complement(tmp_map, cpu_present_map);
cpu = first_cpu(tmp_map);
-@@ -129,6 +131,7 @@ static void __cpuinit MP_processor_info
+@@ -129,7 +132,14 @@ static void __cpuinit MP_processor_info
cpu_set(cpu, cpu_possible_map);
cpu_set(cpu, cpu_present_map);
+-}
++#endif /* CONFIG_XEN */
++}
++#else
++static void __cpuinit MP_processor_info (struct mpc_config_processor *m)
++{
++ num_processors++;
++}
+#endif /* CONFIG_XEN */
- }
static void __init MP_bus_info (struct mpc_config_bus *m)
-@@ -488,7 +491,11 @@ void __init get_smp_config (void)
+ {
+@@ -488,7 +498,11 @@ void __init get_smp_config (void)
* Read the physical hardware table. Anything here will
* override the defaults.
*/
@@ -33558,7 +32946,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
smp_found_config = 0;
printk(KERN_ERR "BIOS bug, MP table errors detected!...\n");
printk(KERN_ERR "... disabling SMP support. (tell your hw vendor)\n");
-@@ -524,7 +531,12 @@ void __init get_smp_config (void)
+@@ -524,7 +538,11 @@ static int __init smp_scan_config (unsig
static int __init smp_scan_config (unsigned long base, unsigned long length)
{
extern void __bad_mpf_size(void);
@@ -33567,11 +32955,10 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#else
unsigned int *bp = phys_to_virt(base);
+#endif
-+
struct intel_mp_floating *mpf;
Dprintk("Scan SMP from %p for %ld bytes.\n", bp,length);
-@@ -540,9 +552,11 @@ static int __init smp_scan_config (unsig
+@@ -540,9 +558,11 @@ static int __init smp_scan_config (unsig
|| (mpf->mpf_specification == 4)) ) {
smp_found_config = 1;
@@ -33583,7 +32970,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
mpf_found = mpf;
return 1;
}
-@@ -598,10 +612,12 @@ void __init find_smp_config(void)
+@@ -598,10 +618,12 @@ void __init find_smp_config(void)
void __init mp_register_lapic_address(u64 address)
{
@@ -33596,7 +32983,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
}
void __cpuinit mp_register_lapic (u8 id, u8 enabled)
-@@ -612,6 +628,7 @@ void __cpuinit mp_register_lapic (u8 id,
+@@ -612,6 +634,7 @@ void __cpuinit mp_register_lapic (u8 id,
if (id == boot_cpu_id)
boot_cpu = 1;
@@ -33604,7 +32991,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
processor.mpc_type = MP_PROCESSOR;
processor.mpc_apicid = id;
processor.mpc_apicver = 0;
-@@ -621,6 +638,7 @@ void __cpuinit mp_register_lapic (u8 id,
+@@ -621,6 +644,7 @@ void __cpuinit mp_register_lapic (u8 id,
processor.mpc_featureflag = 0;
processor.mpc_reserved[0] = 0;
processor.mpc_reserved[1] = 0;
@@ -33612,7 +32999,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
MP_processor_info(&processor);
}
-@@ -663,7 +681,9 @@ void __init mp_register_ioapic(u8 id, u3
+@@ -663,7 +687,9 @@ void __init mp_register_ioapic(u8 id, u3
mp_ioapics[idx].mpc_flags = MPC_APIC_USABLE;
mp_ioapics[idx].mpc_apicaddr = address;
@@ -33622,9 +33009,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
mp_ioapics[idx].mpc_apicid = id;
mp_ioapics[idx].mpc_apicver = 0;
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/arch/x86_64/kernel/pci-swiotlb.c source/arch/x86_64/kernel/pci-swiotlb.c
---- /scratch/src/linux-2.6.20.3/arch/x86_64/kernel/pci-swiotlb.c 2007-02-04 19:44:54.000000000 +0100
-+++ source/arch/x86_64/kernel/pci-swiotlb.c 2007-03-20 21:26:32.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 arch/x86_64/kernel/pci-swiotlb.c
+--- a/arch/x86_64/kernel/pci-swiotlb.c Wed Jul 18 12:23:24 2007 -0300
++++ b/arch/x86_64/kernel/pci-swiotlb.c Wed Aug 08 16:25:28 2007 -0300
@@ -9,10 +9,13 @@
#include <asm/swiotlb.h>
#include <asm/dma.h>
@@ -33664,10 +33051,10 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
}
+#endif /* CONFIG_XEN */
}
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/arch/x86_64/kernel/process-xen.c source/arch/x86_64/kernel/process-xen.c
---- /scratch/src/linux-2.6.20.3/arch/x86_64/kernel/process-xen.c 1970-01-01 01:00:00.000000000 +0100
-+++ source/arch/x86_64/kernel/process-xen.c 2007-03-20 21:26:32.000000000 +0100
-@@ -0,0 +1,865 @@
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 arch/x86_64/kernel/process-xen.c
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/arch/x86_64/kernel/process-xen.c Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,901 @@
+/*
+ * linux/arch/x86-64/kernel/process.c
+ *
@@ -33720,7 +33107,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#include <asm/pda.h>
+#include <asm/prctl.h>
+#include <asm/kdebug.h>
-+#include <xen/interface/dom0_ops.h>
++#include <xen/interface/platform.h>
+#include <xen/interface/physdev.h>
+#include <xen/interface/vcpu.h>
+#include <asm/desc.h>
@@ -33742,6 +33129,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ * Powermanagement idle function, if any..
+ */
+void (*pm_idle)(void);
++EXPORT_SYMBOL(pm_idle);
+static DEFINE_PER_CPU(unsigned int, cpu_idle_state);
+
+static ATOMIC_NOTIFIER_HEAD(idle_notifier);
@@ -33780,8 +33168,26 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ __exit_idle();
+}
+
-+/* XXX XEN doesn't use default_idle(), poll_idle(). Use xen_idle() instead. */
-+void xen_idle(void)
++/*
++ * On SMP it's slightly faster (but much more power-consuming!)
++ * to poll the ->need_resched flag instead of waiting for the
++ * cross-CPU IPI to arrive. Use this option with caution.
++ */
++static void poll_idle (void)
++{
++ local_irq_enable();
++
++ asm volatile(
++ "2:"
++ "testl %0,%1;"
++ "rep; nop;"
++ "je 2b;"
++ : :
++ "i" (_TIF_NEED_RESCHED),
++ "m" (current_thread_info()->flags));
++}
++
++static void xen_idle(void)
+{
+ current_thread_info()->status &= ~TS_POLLING;
+ /*
@@ -33828,10 +33234,13 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ /* endless idle loop with no priority at all */
+ while (1) {
+ while (!need_resched()) {
++ void (*idle)(void);
++
+ if (__get_cpu_var(cpu_idle_state))
+ __get_cpu_var(cpu_idle_state) = 0;
+
+ rmb();
++ idle = xen_idle; /* no alternatives */
+ if (cpu_is_offline(smp_processor_id()))
+ play_dead();
+ /*
@@ -33841,10 +33250,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ */
+ local_irq_disable();
+ enter_idle();
-+ xen_idle();
-+ /* In many cases the interrupt that ended idle
-+ has already called exit_idle. But some idle
-+ loops can be woken up without interrupt. */
++ idle();
+ __exit_idle();
+ }
+
@@ -33889,7 +33295,22 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+/* Always use xen_idle() instead. */
+void mwait_idle_with_hints(unsigned long eax, unsigned long ecx) {}
+
-+void __cpuinit select_idle_routine(const struct cpuinfo_x86 *c) {}
++void __cpuinit select_idle_routine(const struct cpuinfo_x86 *c)
++{
++}
++
++static int __init idle_setup (char *str)
++{
++ if (!strncmp(str, "poll", 4)) {
++ printk("using polling idle threads.\n");
++ pm_idle = poll_idle;
++ }
++
++ boot_option_idle_override = 1;
++ return 1;
++}
++
++__setup("idle=", idle_setup);
+
+/* Prints also some state that isn't saved in the pt_regs */
+void __show_regs(struct pt_regs * regs)
@@ -33961,7 +33382,8 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ struct tss_struct *tss = &per_cpu(init_tss, get_cpu());
+#endif
+#ifdef CONFIG_XEN
-+ struct physdev_set_iobitmap iobmp_op = { 0 };
++ struct physdev_set_iobitmap iobmp_op;
++ memset(&iobmp_op, 0, sizeof(iobmp_op));
+#endif
+
+ kfree(t->io_bitmap_ptr);
@@ -34230,7 +33652,8 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+
+ if (test_tsk_thread_flag(prev_p, TIF_IO_BITMAP) ||
+ test_tsk_thread_flag(next_p, TIF_IO_BITMAP)) {
-+ iobmp_op.bitmap = (char *)next->io_bitmap_ptr;
++ set_xen_guest_handle(iobmp_op.bitmap,
++ (char *)next->io_bitmap_ptr);
+ iobmp_op.nr_ports = next->io_bitmap_ptr ? IO_BITMAP_BITS : 0;
+ mcl->op = __HYPERVISOR_physdev_op;
+ mcl->args[0] = PHYSDEVOP_set_iobitmap;
@@ -34274,7 +33697,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ }
+
+ /*
-+ * Switch the PDA and FPU contexts.
++ * Switch the PDA context.
+ */
+ prev->userrsp = read_pda(oldrsp);
+ write_pda(oldrsp, next->userrsp);
@@ -34533,370 +33956,10 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+{
+}
+#endif
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/arch/x86_64/kernel/setup64-xen.c source/arch/x86_64/kernel/setup64-xen.c
---- /scratch/src/linux-2.6.20.3/arch/x86_64/kernel/setup64-xen.c 1970-01-01 01:00:00.000000000 +0100
-+++ source/arch/x86_64/kernel/setup64-xen.c 2007-03-20 21:26:32.000000000 +0100
-@@ -0,0 +1,356 @@
-+/*
-+ * X86-64 specific CPU setup.
-+ * Copyright (C) 1995 Linus Torvalds
-+ * Copyright 2001, 2002, 2003 SuSE Labs / Andi Kleen.
-+ * See setup.c for older changelog.
-+ *
-+ * Jun Nakajima <jun.nakajima@intel.com>
-+ * Modified for Xen
-+ *
-+ */
-+#include <linux/init.h>
-+#include <linux/kernel.h>
-+#include <linux/sched.h>
-+#include <linux/string.h>
-+#include <linux/bootmem.h>
-+#include <linux/bitops.h>
-+#include <linux/module.h>
-+#include <asm/bootsetup.h>
-+#include <asm/pda.h>
-+#include <asm/pgtable.h>
-+#include <asm/processor.h>
-+#include <asm/desc.h>
-+#include <asm/atomic.h>
-+#include <asm/mmu_context.h>
-+#include <asm/smp.h>
-+#include <asm/i387.h>
-+#include <asm/percpu.h>
-+#include <asm/proto.h>
-+#include <asm/sections.h>
-+#ifdef CONFIG_XEN
-+#include <asm/hypervisor.h>
-+#endif
-+
-+char x86_boot_params[BOOT_PARAM_SIZE] __initdata;
-+
-+cpumask_t cpu_initialized __cpuinitdata = CPU_MASK_NONE;
-+
-+struct x8664_pda *_cpu_pda[NR_CPUS] __read_mostly;
-+EXPORT_SYMBOL(_cpu_pda);
-+struct x8664_pda boot_cpu_pda[NR_CPUS] __cacheline_aligned;
-+
-+#ifndef CONFIG_X86_NO_IDT
-+struct desc_ptr idt_descr = { 256 * 16 - 1, (unsigned long) idt_table };
-+#endif
-+
-+char boot_cpu_stack[IRQSTACKSIZE] __attribute__((section(".bss.page_aligned")));
-+
-+unsigned long __supported_pte_mask __read_mostly = ~0UL;
-+EXPORT_SYMBOL(__supported_pte_mask);
-+static int do_not_nx __cpuinitdata = 0;
-+
-+/* noexec=on|off
-+Control non executable mappings for 64bit processes.
-+
-+on Enable(default)
-+off Disable
-+*/
-+static int __init nonx_setup(char *str)
-+{
-+ if (!str)
-+ return -EINVAL;
-+ if (!strncmp(str, "on", 2)) {
-+ __supported_pte_mask |= _PAGE_NX;
-+ do_not_nx = 0;
-+ } else if (!strncmp(str, "off", 3)) {
-+ do_not_nx = 1;
-+ __supported_pte_mask &= ~_PAGE_NX;
-+ }
-+ return 0;
-+}
-+early_param("noexec", nonx_setup);
-+
-+int force_personality32 = 0;
-+
-+/* noexec32=on|off
-+Control non executable heap for 32bit processes.
-+To control the stack too use noexec=off
-+
-+on PROT_READ does not imply PROT_EXEC for 32bit processes
-+off PROT_READ implies PROT_EXEC (default)
-+*/
-+static int __init nonx32_setup(char *str)
-+{
-+ if (!strcmp(str, "on"))
-+ force_personality32 &= ~READ_IMPLIES_EXEC;
-+ else if (!strcmp(str, "off"))
-+ force_personality32 |= READ_IMPLIES_EXEC;
-+ return 1;
-+}
-+__setup("noexec32=", nonx32_setup);
-+
-+/*
-+ * Great future plan:
-+ * Declare PDA itself and support (irqstack,tss,pgd) as per cpu data.
-+ * Always point %gs to its beginning
-+ */
-+void __init setup_per_cpu_areas(void)
-+{
-+ int i;
-+ unsigned long size;
-+
-+#ifdef CONFIG_HOTPLUG_CPU
-+ prefill_possible_map();
-+#endif
-+
-+ /* Copy section for each CPU (we discard the original) */
-+ size = PERCPU_ENOUGH_ROOM;
-+
-+ printk(KERN_INFO "PERCPU: Allocating %lu bytes of per cpu data\n", size);
-+ for_each_cpu_mask (i, cpu_possible_map) {
-+ char *ptr;
-+
-+ if (!NODE_DATA(cpu_to_node(i))) {
-+ printk("cpu with no node %d, num_online_nodes %d\n",
-+ i, num_online_nodes());
-+ ptr = alloc_bootmem(size);
-+ } else {
-+ ptr = alloc_bootmem_node(NODE_DATA(cpu_to_node(i)), size);
-+ }
-+ if (!ptr)
-+ panic("Cannot allocate cpu data for CPU %d\n", i);
-+ cpu_pda(i)->data_offset = ptr - __per_cpu_start;
-+ memcpy(ptr, __per_cpu_start, __per_cpu_end - __per_cpu_start);
-+ }
-+}
-+
-+#ifdef CONFIG_XEN
-+static void switch_pt(void)
-+{
-+ xen_pt_switch(__pa(init_level4_pgt));
-+ xen_new_user_pt(__pa(init_level4_user_pgt));
-+}
-+
-+void __cpuinit cpu_gdt_init(struct desc_ptr *gdt_descr)
-+{
-+ unsigned long frames[16];
-+ unsigned long va;
-+ int f;
-+
-+ for (va = gdt_descr->address, f = 0;
-+ va < gdt_descr->address + gdt_descr->size;
-+ va += PAGE_SIZE, f++) {
-+ frames[f] = virt_to_mfn(va);
-+ make_page_readonly(
-+ (void *)va, XENFEAT_writable_descriptor_tables);
-+ }
-+ if (HYPERVISOR_set_gdt(frames, gdt_descr->size /
-+ sizeof (struct desc_struct)))
-+ BUG();
-+}
-+#else
-+static void switch_pt(void)
-+{
-+ asm volatile("movq %0,%%cr3" :: "r" (__pa_symbol(&init_level4_pgt)));
-+}
-+
-+void __init cpu_gdt_init(struct desc_ptr *gdt_descr)
-+{
-+ asm volatile("lgdt %0" :: "m" (*gdt_descr));
-+ asm volatile("lidt %0" :: "m" (idt_descr));
-+}
-+#endif
-+
-+void pda_init(int cpu)
-+{
-+ struct x8664_pda *pda = cpu_pda(cpu);
-+
-+ /* Setup up data that may be needed in __get_free_pages early */
-+ asm volatile("movl %0,%%fs ; movl %0,%%gs" :: "r" (0));
-+#ifndef CONFIG_XEN
-+ /* Memory clobbers used to order PDA accessed */
-+ mb();
-+ wrmsrl(MSR_GS_BASE, pda);
-+ mb();
-+#else
-+ HYPERVISOR_set_segment_base(SEGBASE_GS_KERNEL, (unsigned long)pda);
-+#endif
-+ pda->cpunumber = cpu;
-+ pda->irqcount = -1;
-+ pda->kernelstack =
-+ (unsigned long)stack_thread_info() - PDA_STACKOFFSET + THREAD_SIZE;
-+ pda->active_mm = &init_mm;
-+ pda->mmu_state = 0;
-+
-+ if (cpu == 0) {
-+#ifdef CONFIG_XEN
-+ xen_init_pt();
-+#endif
-+ /* others are initialized in smpboot.c */
-+ pda->pcurrent = &init_task;
-+ pda->irqstackptr = boot_cpu_stack;
-+ } else {
-+ pda->irqstackptr = (char *)
-+ __get_free_pages(GFP_ATOMIC, IRQSTACK_ORDER);
-+ if (!pda->irqstackptr)
-+ panic("cannot allocate irqstack for cpu %d", cpu);
-+ }
-+
-+ switch_pt();
-+
-+ pda->irqstackptr += IRQSTACKSIZE-64;
-+}
-+
-+#ifndef CONFIG_X86_NO_TSS
-+char boot_exception_stacks[(N_EXCEPTION_STACKS - 1) * EXCEPTION_STKSZ + DEBUG_STKSZ]
-+__attribute__((section(".bss.page_aligned")));
-+#endif
-+
-+/* May not be marked __init: used by software suspend */
-+void syscall_init(void)
-+{
-+#ifndef CONFIG_XEN
-+ /*
-+ * LSTAR and STAR live in a bit strange symbiosis.
-+ * They both write to the same internal register. STAR allows to set CS/DS
-+ * but only a 32bit target. LSTAR sets the 64bit rip.
-+ */
-+ wrmsrl(MSR_STAR, ((u64)__USER32_CS)<<48 | ((u64)__KERNEL_CS)<<32);
-+ wrmsrl(MSR_LSTAR, system_call);
-+
-+ /* Flags to clear on syscall */
-+ wrmsrl(MSR_SYSCALL_MASK, EF_TF|EF_DF|EF_IE|0x3000);
-+#endif
-+#ifdef CONFIG_IA32_EMULATION
-+ syscall32_cpu_init ();
-+#endif
-+}
-+
-+void __cpuinit check_efer(void)
-+{
-+ unsigned long efer;
-+
-+ rdmsrl(MSR_EFER, efer);
-+ if (!(efer & EFER_NX) || do_not_nx) {
-+ __supported_pte_mask &= ~_PAGE_NX;
-+ }
-+}
-+
-+unsigned long kernel_eflags;
-+
-+/*
-+ * cpu_init() initializes state that is per-CPU. Some data is already
-+ * initialized (naturally) in the bootstrap process, such as the GDT
-+ * and IDT. We reload them nevertheless, this function acts as a
-+ * 'CPU state barrier', nothing should get across.
-+ * A lot of state is already set up in PDA init.
-+ */
-+void __cpuinit cpu_init (void)
-+{
-+ int cpu = stack_smp_processor_id();
-+#ifndef CONFIG_X86_NO_TSS
-+ struct tss_struct *t = &per_cpu(init_tss, cpu);
-+ struct orig_ist *orig_ist = &per_cpu(orig_ist, cpu);
-+ unsigned long v;
-+ char *estacks = NULL;
-+ int i;
-+#endif
-+ struct task_struct *me;
-+
-+ /* CPU 0 is initialised in head64.c */
-+ if (cpu != 0) {
-+ pda_init(cpu);
-+ zap_low_mappings(cpu);
-+ }
-+#ifndef CONFIG_X86_NO_TSS
-+ else
-+ estacks = boot_exception_stacks;
-+#endif
-+
-+ me = current;
-+
-+ if (cpu_test_and_set(cpu, cpu_initialized))
-+ panic("CPU#%d already initialized!\n", cpu);
-+
-+ printk("Initializing CPU#%d\n", cpu);
-+
-+ clear_in_cr4(X86_CR4_VME|X86_CR4_PVI|X86_CR4_TSD|X86_CR4_DE);
-+
-+ /*
-+ * Initialize the per-CPU GDT with the boot GDT,
-+ * and set up the GDT descriptor:
-+ */
-+#ifndef CONFIG_XEN
-+ if (cpu)
-+ memcpy(cpu_gdt(cpu), cpu_gdt_table, GDT_SIZE);
-+#endif
-+
-+ cpu_gdt_descr[cpu].size = GDT_SIZE;
-+ cpu_gdt_init(&cpu_gdt_descr[cpu]);
-+
-+ memset(me->thread.tls_array, 0, GDT_ENTRY_TLS_ENTRIES * 8);
-+ syscall_init();
-+
-+ wrmsrl(MSR_FS_BASE, 0);
-+ wrmsrl(MSR_KERNEL_GS_BASE, 0);
-+ barrier();
-+
-+ check_efer();
-+
-+#ifndef CONFIG_X86_NO_TSS
-+ /*
-+ * set up and load the per-CPU TSS
-+ */
-+ for (v = 0; v < N_EXCEPTION_STACKS; v++) {
-+ static const unsigned int order[N_EXCEPTION_STACKS] = {
-+ [0 ... N_EXCEPTION_STACKS - 1] = EXCEPTION_STACK_ORDER,
-+ [DEBUG_STACK - 1] = DEBUG_STACK_ORDER
-+ };
-+ if (cpu) {
-+ estacks = (char *)__get_free_pages(GFP_ATOMIC, order[v]);
-+ if (!estacks)
-+ panic("Cannot allocate exception stack %ld %d\n",
-+ v, cpu);
-+ }
-+ estacks += PAGE_SIZE << order[v];
-+ orig_ist->ist[v] = t->ist[v] = (unsigned long)estacks;
-+ }
-+
-+ t->io_bitmap_base = offsetof(struct tss_struct, io_bitmap);
-+ /*
-+ * <= is required because the CPU will access up to
-+ * 8 bits beyond the end of the IO permission bitmap.
-+ */
-+ for (i = 0; i <= IO_BITMAP_LONGS; i++)
-+ t->io_bitmap[i] = ~0UL;
-+#endif
-+
-+ atomic_inc(&init_mm.mm_count);
-+ me->active_mm = &init_mm;
-+ if (me->mm)
-+ BUG();
-+ enter_lazy_tlb(&init_mm, me);
-+
-+#ifndef CONFIG_X86_NO_TSS
-+ set_tss_desc(cpu, t);
-+#endif
-+#ifndef CONFIG_XEN
-+ load_TR_desc();
-+#endif
-+ load_LDT(&init_mm.context);
-+
-+ /*
-+ * Clear all 6 debug registers:
-+ */
-+
-+ set_debugreg(0UL, 0);
-+ set_debugreg(0UL, 1);
-+ set_debugreg(0UL, 2);
-+ set_debugreg(0UL, 3);
-+ set_debugreg(0UL, 6);
-+ set_debugreg(0UL, 7);
-+
-+ fpu_init();
-+
-+ raw_local_save_flags(kernel_eflags);
-+}
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/arch/x86_64/kernel/setup-xen.c source/arch/x86_64/kernel/setup-xen.c
---- /scratch/src/linux-2.6.20.3/arch/x86_64/kernel/setup-xen.c 1970-01-01 01:00:00.000000000 +0100
-+++ source/arch/x86_64/kernel/setup-xen.c 2007-03-20 21:26:32.000000000 +0100
-@@ -0,0 +1,1487 @@
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 arch/x86_64/kernel/setup-xen.c
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/arch/x86_64/kernel/setup-xen.c Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,1489 @@
+/*
+ * linux/arch/x86-64/kernel/setup.c
+ *
@@ -34987,9 +34050,6 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+extern char hypercall_page[PAGE_SIZE];
+EXPORT_SYMBOL(hypercall_page);
+
-+/* Allows setting of maximum possible memory size */
-+unsigned long xen_override_max_pfn;
-+
+static int xen_panic_event(struct notifier_block *, unsigned long, void *);
+static struct notifier_block xen_panic_block = {
+ xen_panic_event, NULL, 0 /* try to go last */
@@ -35297,6 +34357,8 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ if (ebda_size > 64*1024)
+ ebda_size = 64*1024;
+}
++#else
++#define discover_ebda() ((void)0)
+#endif
+
+void __init setup_arch(char **cmdline_p)
@@ -35347,8 +34409,6 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ rd_doload = ((RAMDISK_FLAGS & RAMDISK_LOAD_FLAG) != 0);
+#endif
+#ifdef CONFIG_XEN
-+ setup_xen_features();
-+
+ HYPERVISOR_vm_assist(VMASST_CMD_enable,
+ VMASST_TYPE_writable_pagetables);
+
@@ -35389,12 +34449,13 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+
+ check_efer();
+
-+#ifndef CONFIG_XEN
+ discover_ebda();
-+#endif
+
+ init_memory_mapping(0, (end_pfn_map << PAGE_SHIFT));
+
++ if (is_initial_xendomain())
++ dmi_scan_machine();
++
+ zap_low_mappings(0);
+
+ /* How many end-of-memory variables you have, grandma! */
@@ -35418,6 +34479,14 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ contig_initmem_init(0, end_pfn);
+#endif
+
++#ifdef CONFIG_XEN
++ /*
++ * Reserve kernel, physmap, start info, initial page tables, and
++ * direct mapping.
++ */
++ reserve_bootmem_generic(__pa_symbol(&_text),
++ (table_end << PAGE_SHIFT) - __pa_symbol(&_text));
++#else
+ /* Reserve direct mapping */
+ reserve_bootmem_generic(table_start << PAGE_SHIFT,
+ (table_end - table_start) << PAGE_SHIFT);
@@ -35426,10 +34495,6 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ reserve_bootmem_generic(__pa_symbol(&_text),
+ __pa_symbol(&_end) - __pa_symbol(&_text));
+
-+#ifdef CONFIG_XEN
-+ /* reserve physmap, start info and initial page tables */
-+ reserve_bootmem(__pa_symbol(&_end), (table_start<<PAGE_SHIFT)-__pa_symbol(&_end));
-+#else
+ /*
+ * reserve physical page 0 - it's a special BIOS page on many boxes,
+ * enabling clean reboots, SMP operation, laptop functions.
@@ -35439,7 +34504,6 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ /* reserve ebda region */
+ if (ebda_addr)
+ reserve_bootmem_generic(ebda_addr, ebda_size);
-+#endif
+
+#ifdef CONFIG_SMP
+ /*
@@ -35452,6 +34516,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ /* Reserve SMP trampoline */
+ reserve_bootmem_generic(SMP_TRAMPOLINE_BASE, PAGE_SIZE);
+#endif
++#endif
+
+#ifdef CONFIG_ACPI_SLEEP
+ /*
@@ -35534,8 +34599,6 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ * save/restore.
+ */
+ pfn_to_mfn_frame_list_list = alloc_bootmem_pages(PAGE_SIZE);
-+ HYPERVISOR_shared_info->arch.pfn_to_mfn_frame_list_list =
-+ virt_to_mfn(pfn_to_mfn_frame_list_list);
+
+ fpp = PAGE_SIZE/sizeof(unsigned long);
+ for (i=0, j=0, k=-1; i< end_pfn; i+=fpp, j++) {
@@ -35552,13 +34615,12 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ virt_to_mfn(&phys_to_machine_mapping[i]);
+ }
+ HYPERVISOR_shared_info->arch.max_pfn = end_pfn;
++ HYPERVISOR_shared_info->arch.pfn_to_mfn_frame_list_list =
++ virt_to_mfn(pfn_to_mfn_frame_list_list);
+ }
+
+ }
+
-+ if (is_initial_xendomain())
-+ dmi_scan_machine();
-+
+#ifdef CONFIG_ACPI
+ if (!is_initial_xendomain()) {
+ acpi_disabled = 1;
@@ -36372,6 +35434,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ struct platform_device *pd;
+ int ret;
+
++ if (!is_initial_xendomain())
++ return 0;
++
+ pd = platform_device_alloc("pcspkr", -1);
+ if (!pd)
+ return -ENOMEM;
@@ -36384,590 +35449,517 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+}
+device_initcall(add_pcspkr);
+#endif
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/arch/x86_64/kernel/smp-xen.c source/arch/x86_64/kernel/smp-xen.c
---- /scratch/src/linux-2.6.20.3/arch/x86_64/kernel/smp-xen.c 1970-01-01 01:00:00.000000000 +0100
-+++ source/arch/x86_64/kernel/smp-xen.c 2007-03-20 21:26:32.000000000 +0100
-@@ -0,0 +1,576 @@
-+/*
-+ * Intel SMP support routines.
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 arch/x86_64/kernel/setup64-xen.c
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/arch/x86_64/kernel/setup64-xen.c Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,356 @@
++/*
++ * X86-64 specific CPU setup.
++ * Copyright (C) 1995 Linus Torvalds
++ * Copyright 2001, 2002, 2003 SuSE Labs / Andi Kleen.
++ * See setup.c for older changelog.
+ *
-+ * (c) 1995 Alan Cox, Building #3 <alan@redhat.com>
-+ * (c) 1998-99, 2000 Ingo Molnar <mingo@redhat.com>
-+ * (c) 2002,2003 Andi Kleen, SuSE Labs.
++ * Jun Nakajima <jun.nakajima@intel.com>
++ * Modified for Xen
+ *
-+ * This code is released under the GNU General Public License version 2 or
-+ * later.
-+ */
-+
++ */
+#include <linux/init.h>
-+
-+#include <linux/mm.h>
-+#include <linux/delay.h>
-+#include <linux/spinlock.h>
-+#include <linux/smp_lock.h>
-+#include <linux/smp.h>
-+#include <linux/kernel_stat.h>
-+#include <linux/mc146818rtc.h>
-+#include <linux/interrupt.h>
-+
-+#include <asm/mtrr.h>
-+#include <asm/pgalloc.h>
-+#include <asm/tlbflush.h>
-+#include <asm/mach_apic.h>
++#include <linux/kernel.h>
++#include <linux/sched.h>
++#include <linux/string.h>
++#include <linux/bootmem.h>
++#include <linux/bitops.h>
++#include <linux/module.h>
++#include <asm/bootsetup.h>
++#include <asm/pda.h>
++#include <asm/pgtable.h>
++#include <asm/processor.h>
++#include <asm/desc.h>
++#include <asm/atomic.h>
+#include <asm/mmu_context.h>
++#include <asm/smp.h>
++#include <asm/i387.h>
++#include <asm/percpu.h>
+#include <asm/proto.h>
-+#include <asm/apicdef.h>
-+#include <asm/idle.h>
++#include <asm/sections.h>
+#ifdef CONFIG_XEN
-+#include <xen/evtchn.h>
++#include <asm/hypervisor.h>
+#endif
+
-+#ifndef CONFIG_XEN
-+/*
-+ * Smarter SMP flushing macros.
-+ * c/o Linus Torvalds.
-+ *
-+ * These mean you can really definitely utterly forget about
-+ * writing to user space from interrupts. (Its not allowed anyway).
-+ *
-+ * Optimizations Manfred Spraul <manfred@colorfullife.com>
-+ *
-+ * More scalable flush, from Andi Kleen
-+ *
-+ * To avoid global state use 8 different call vectors.
-+ * Each CPU uses a specific vector to trigger flushes on other
-+ * CPUs. Depending on the received vector the target CPUs look into
-+ * the right per cpu variable for the flush data.
-+ *
-+ * With more than 8 CPUs they are hashed to the 8 available
-+ * vectors. The limited global vector space forces us to this right now.
-+ * In future when interrupts are split into per CPU domains this could be
-+ * fixed, at the cost of triggering multiple IPIs in some cases.
-+ */
++char x86_boot_params[BOOT_PARAM_SIZE] __initdata;
+
-+union smp_flush_state {
-+ struct {
-+ cpumask_t flush_cpumask;
-+ struct mm_struct *flush_mm;
-+ unsigned long flush_va;
-+#define FLUSH_ALL -1ULL
-+ spinlock_t tlbstate_lock;
-+ };
-+ char pad[SMP_CACHE_BYTES];
-+} ____cacheline_aligned;
++cpumask_t cpu_initialized __cpuinitdata = CPU_MASK_NONE;
+
-+/* State is put into the per CPU data section, but padded
-+ to a full cache line because other CPUs can access it and we don't
-+ want false sharing in the per cpu data segment. */
-+static DEFINE_PER_CPU(union smp_flush_state, flush_state);
++struct x8664_pda *_cpu_pda[NR_CPUS] __read_mostly;
++EXPORT_SYMBOL(_cpu_pda);
++struct x8664_pda boot_cpu_pda[NR_CPUS] __cacheline_aligned;
++
++#ifndef CONFIG_X86_NO_IDT
++struct desc_ptr idt_descr = { 256 * 16 - 1, (unsigned long) idt_table };
+#endif
+
-+/*
-+ * We cannot call mmdrop() because we are in interrupt context,
-+ * instead update mm->cpu_vm_mask.
-+ */
-+static inline void leave_mm(int cpu)
-+{
-+ if (read_pda(mmu_state) == TLBSTATE_OK)
-+ BUG();
-+ cpu_clear(cpu, read_pda(active_mm)->cpu_vm_mask);
-+ load_cr3(swapper_pg_dir);
-+}
++char boot_cpu_stack[IRQSTACKSIZE] __attribute__((section(".bss.page_aligned")));
+
-+#ifndef CONFIG_XEN
-+/*
-+ *
-+ * The flush IPI assumes that a thread switch happens in this order:
-+ * [cpu0: the cpu that switches]
-+ * 1) switch_mm() either 1a) or 1b)
-+ * 1a) thread switch to a different mm
-+ * 1a1) cpu_clear(cpu, old_mm->cpu_vm_mask);
-+ * Stop ipi delivery for the old mm. This is not synchronized with
-+ * the other cpus, but smp_invalidate_interrupt ignore flush ipis
-+ * for the wrong mm, and in the worst case we perform a superfluous
-+ * tlb flush.
-+ * 1a2) set cpu mmu_state to TLBSTATE_OK
-+ * Now the smp_invalidate_interrupt won't call leave_mm if cpu0
-+ * was in lazy tlb mode.
-+ * 1a3) update cpu active_mm
-+ * Now cpu0 accepts tlb flushes for the new mm.
-+ * 1a4) cpu_set(cpu, new_mm->cpu_vm_mask);
-+ * Now the other cpus will send tlb flush ipis.
-+ * 1a4) change cr3.
-+ * 1b) thread switch without mm change
-+ * cpu active_mm is correct, cpu0 already handles
-+ * flush ipis.
-+ * 1b1) set cpu mmu_state to TLBSTATE_OK
-+ * 1b2) test_and_set the cpu bit in cpu_vm_mask.
-+ * Atomically set the bit [other cpus will start sending flush ipis],
-+ * and test the bit.
-+ * 1b3) if the bit was 0: leave_mm was called, flush the tlb.
-+ * 2) switch %%esp, ie current
-+ *
-+ * The interrupt must handle 2 special cases:
-+ * - cr3 is changed before %%esp, ie. it cannot use current->{active_,}mm.
-+ * - the cpu performs speculative tlb reads, i.e. even if the cpu only
-+ * runs in kernel space, the cpu could load tlb entries for user space
-+ * pages.
-+ *
-+ * The good news is that cpu mmu_state is local to each cpu, no
-+ * write/read ordering problems.
-+ */
++unsigned long __supported_pte_mask __read_mostly = ~0UL;
++EXPORT_SYMBOL(__supported_pte_mask);
++static int do_not_nx __cpuinitdata = 0;
+
-+/*
-+ * TLB flush IPI:
-+ *
-+ * 1) Flush the tlb entries if the cpu uses the mm that's being flushed.
-+ * 2) Leave the mm if we are in the lazy tlb mode.
-+ *
-+ * Interrupts are disabled.
-+ */
++/* noexec=on|off
++Control non executable mappings for 64bit processes.
+
-+asmlinkage void smp_invalidate_interrupt(struct pt_regs *regs)
++on Enable(default)
++off Disable
++*/
++static int __init nonx_setup(char *str)
+{
-+ int cpu;
-+ int sender;
-+ union smp_flush_state *f;
++ if (!str)
++ return -EINVAL;
++ if (!strncmp(str, "on", 2)) {
++ __supported_pte_mask |= _PAGE_NX;
++ do_not_nx = 0;
++ } else if (!strncmp(str, "off", 3)) {
++ do_not_nx = 1;
++ __supported_pte_mask &= ~_PAGE_NX;
++ }
++ return 0;
++}
++early_param("noexec", nonx_setup);
+
-+ cpu = smp_processor_id();
-+ /*
-+ * orig_rax contains the interrupt vector - 256.
-+ * Use that to determine where the sender put the data.
-+ */
-+ sender = regs->orig_rax + 256 - INVALIDATE_TLB_VECTOR_START;
-+ f = &per_cpu(flush_state, sender);
++int force_personality32 = 0;
+
-+ if (!cpu_isset(cpu, f->flush_cpumask))
-+ goto out;
-+ /*
-+ * This was a BUG() but until someone can quote me the
-+ * line from the intel manual that guarantees an IPI to
-+ * multiple CPUs is retried _only_ on the erroring CPUs
-+ * its staying as a return
-+ *
-+ * BUG();
-+ */
-+
-+ if (f->flush_mm == read_pda(active_mm)) {
-+ if (read_pda(mmu_state) == TLBSTATE_OK) {
-+ if (f->flush_va == FLUSH_ALL)
-+ local_flush_tlb();
-+ else
-+ __flush_tlb_one(f->flush_va);
-+ } else
-+ leave_mm(cpu);
-+ }
-+out:
-+ ack_APIC_irq();
-+ cpu_clear(cpu, f->flush_cpumask);
-+}
++/* noexec32=on|off
++Control non executable heap for 32bit processes.
++To control the stack too use noexec=off
+
-+static void flush_tlb_others(cpumask_t cpumask, struct mm_struct *mm,
-+ unsigned long va)
++on PROT_READ does not imply PROT_EXEC for 32bit processes
++off PROT_READ implies PROT_EXEC (default)
++*/
++static int __init nonx32_setup(char *str)
+{
-+ int sender;
-+ union smp_flush_state *f;
++ if (!strcmp(str, "on"))
++ force_personality32 &= ~READ_IMPLIES_EXEC;
++ else if (!strcmp(str, "off"))
++ force_personality32 |= READ_IMPLIES_EXEC;
++ return 1;
++}
++__setup("noexec32=", nonx32_setup);
+
-+ /* Caller has disabled preemption */
-+ sender = smp_processor_id() % NUM_INVALIDATE_TLB_VECTORS;
-+ f = &per_cpu(flush_state, sender);
++/*
++ * Great future plan:
++ * Declare PDA itself and support (irqstack,tss,pgd) as per cpu data.
++ * Always point %gs to its beginning
++ */
++void __init setup_per_cpu_areas(void)
++{
++ int i;
++ unsigned long size;
+
-+ /* Could avoid this lock when
-+ num_online_cpus() <= NUM_INVALIDATE_TLB_VECTORS, but it is
-+ probably not worth checking this for a cache-hot lock. */
-+ spin_lock(&f->tlbstate_lock);
++#ifdef CONFIG_HOTPLUG_CPU
++ prefill_possible_map();
++#endif
+
-+ f->flush_mm = mm;
-+ f->flush_va = va;
-+ cpus_or(f->flush_cpumask, cpumask, f->flush_cpumask);
++ /* Copy section for each CPU (we discard the original) */
++ size = PERCPU_ENOUGH_ROOM;
+
-+ /*
-+ * We have to send the IPI only to
-+ * CPUs affected.
-+ */
-+ send_IPI_mask(cpumask, INVALIDATE_TLB_VECTOR_START + sender);
++ printk(KERN_INFO "PERCPU: Allocating %lu bytes of per cpu data\n", size);
++ for_each_cpu_mask (i, cpu_possible_map) {
++ char *ptr;
+
-+ while (!cpus_empty(f->flush_cpumask))
-+ cpu_relax();
++ if (!NODE_DATA(cpu_to_node(i))) {
++ printk("cpu with no node %d, num_online_nodes %d\n",
++ i, num_online_nodes());
++ ptr = alloc_bootmem(size);
++ } else {
++ ptr = alloc_bootmem_node(NODE_DATA(cpu_to_node(i)), size);
++ }
++ if (!ptr)
++ panic("Cannot allocate cpu data for CPU %d\n", i);
++ cpu_pda(i)->data_offset = ptr - __per_cpu_start;
++ memcpy(ptr, __per_cpu_start, __per_cpu_end - __per_cpu_start);
++ }
++}
+
-+ f->flush_mm = NULL;
-+ f->flush_va = 0;
-+ spin_unlock(&f->tlbstate_lock);
++#ifdef CONFIG_XEN
++static void switch_pt(void)
++{
++ xen_pt_switch(__pa(init_level4_pgt));
++ xen_new_user_pt(__pa(init_level4_user_pgt));
+}
+
-+int __cpuinit init_smp_flush(void)
++void __cpuinit cpu_gdt_init(struct desc_ptr *gdt_descr)
+{
-+ int i;
-+ for_each_cpu_mask(i, cpu_possible_map) {
-+ spin_lock_init(&per_cpu(flush_state, i).tlbstate_lock);
++ unsigned long frames[16];
++ unsigned long va;
++ int f;
++
++ for (va = gdt_descr->address, f = 0;
++ va < gdt_descr->address + gdt_descr->size;
++ va += PAGE_SIZE, f++) {
++ frames[f] = virt_to_mfn(va);
++ make_page_readonly(
++ (void *)va, XENFEAT_writable_descriptor_tables);
+ }
-+ return 0;
++ if (HYPERVISOR_set_gdt(frames, gdt_descr->size /
++ sizeof (struct desc_struct)))
++ BUG();
+}
-+
-+core_initcall(init_smp_flush);
-+
-+void flush_tlb_current_task(void)
++#else
++static void switch_pt(void)
+{
-+ struct mm_struct *mm = current->mm;
-+ cpumask_t cpu_mask;
-+
-+ preempt_disable();
-+ cpu_mask = mm->cpu_vm_mask;
-+ cpu_clear(smp_processor_id(), cpu_mask);
-+
-+ local_flush_tlb();
-+ if (!cpus_empty(cpu_mask))
-+ flush_tlb_others(cpu_mask, mm, FLUSH_ALL);
-+ preempt_enable();
++ asm volatile("movq %0,%%cr3" :: "r" (__pa_symbol(&init_level4_pgt)));
+}
-+EXPORT_SYMBOL(flush_tlb_current_task);
+
-+void flush_tlb_mm (struct mm_struct * mm)
++void __init cpu_gdt_init(struct desc_ptr *gdt_descr)
+{
-+ cpumask_t cpu_mask;
-+
-+ preempt_disable();
-+ cpu_mask = mm->cpu_vm_mask;
-+ cpu_clear(smp_processor_id(), cpu_mask);
-+
-+ if (current->active_mm == mm) {
-+ if (current->mm)
-+ local_flush_tlb();
-+ else
-+ leave_mm(smp_processor_id());
-+ }
-+ if (!cpus_empty(cpu_mask))
-+ flush_tlb_others(cpu_mask, mm, FLUSH_ALL);
-+
-+ preempt_enable();
++ asm volatile("lgdt %0" :: "m" (*gdt_descr));
++ asm volatile("lidt %0" :: "m" (idt_descr));
+}
-+EXPORT_SYMBOL(flush_tlb_mm);
++#endif
+
-+void flush_tlb_page(struct vm_area_struct * vma, unsigned long va)
-+{
-+ struct mm_struct *mm = vma->vm_mm;
-+ cpumask_t cpu_mask;
++void pda_init(int cpu)
++{
++ struct x8664_pda *pda = cpu_pda(cpu);
+
-+ preempt_disable();
-+ cpu_mask = mm->cpu_vm_mask;
-+ cpu_clear(smp_processor_id(), cpu_mask);
++ /* Setup up data that may be needed in __get_free_pages early */
++ asm volatile("movl %0,%%fs ; movl %0,%%gs" :: "r" (0));
++#ifndef CONFIG_XEN
++ /* Memory clobbers used to order PDA accessed */
++ mb();
++ wrmsrl(MSR_GS_BASE, pda);
++ mb();
++#else
++ HYPERVISOR_set_segment_base(SEGBASE_GS_KERNEL, (unsigned long)pda);
++#endif
++ pda->cpunumber = cpu;
++ pda->irqcount = -1;
++ pda->kernelstack =
++ (unsigned long)stack_thread_info() - PDA_STACKOFFSET + THREAD_SIZE;
++ pda->active_mm = &init_mm;
++ pda->mmu_state = 0;
+
-+ if (current->active_mm == mm) {
-+ if(current->mm)
-+ __flush_tlb_one(va);
-+ else
-+ leave_mm(smp_processor_id());
++ if (cpu == 0) {
++#ifdef CONFIG_XEN
++ xen_init_pt();
++#endif
++ /* others are initialized in smpboot.c */
++ pda->pcurrent = &init_task;
++ pda->irqstackptr = boot_cpu_stack;
++ } else {
++ pda->irqstackptr = (char *)
++ __get_free_pages(GFP_ATOMIC, IRQSTACK_ORDER);
++ if (!pda->irqstackptr)
++ panic("cannot allocate irqstack for cpu %d", cpu);
+ }
+
-+ if (!cpus_empty(cpu_mask))
-+ flush_tlb_others(cpu_mask, mm, va);
++ switch_pt();
+
-+ preempt_enable();
-+}
-+EXPORT_SYMBOL(flush_tlb_page);
++ pda->irqstackptr += IRQSTACKSIZE-64;
++}
+
-+static void do_flush_tlb_all(void* info)
++#ifndef CONFIG_X86_NO_TSS
++char boot_exception_stacks[(N_EXCEPTION_STACKS - 1) * EXCEPTION_STKSZ + DEBUG_STKSZ]
++__attribute__((section(".bss.page_aligned")));
++#endif
++
++/* May not be marked __init: used by software suspend */
++void syscall_init(void)
+{
-+ unsigned long cpu = smp_processor_id();
++#ifndef CONFIG_XEN
++ /*
++ * LSTAR and STAR live in a bit strange symbiosis.
++ * They both write to the same internal register. STAR allows to set CS/DS
++ * but only a 32bit target. LSTAR sets the 64bit rip.
++ */
++ wrmsrl(MSR_STAR, ((u64)__USER32_CS)<<48 | ((u64)__KERNEL_CS)<<32);
++ wrmsrl(MSR_LSTAR, system_call);
+
-+ __flush_tlb_all();
-+ if (read_pda(mmu_state) == TLBSTATE_LAZY)
-+ leave_mm(cpu);
++ /* Flags to clear on syscall */
++ wrmsrl(MSR_SYSCALL_MASK, EF_TF|EF_DF|EF_IE|0x3000);
++#endif
++#ifdef CONFIG_IA32_EMULATION
++ syscall32_cpu_init ();
++#endif
+}
+
-+void flush_tlb_all(void)
++void __cpuinit check_efer(void)
+{
-+ on_each_cpu(do_flush_tlb_all, NULL, 1, 1);
-+}
-+#else
-+asmlinkage void smp_invalidate_interrupt (void)
-+{ return; }
-+void flush_tlb_current_task(void)
-+{ xen_tlb_flush_mask(&current->mm->cpu_vm_mask); }
-+void flush_tlb_mm (struct mm_struct * mm)
-+{ xen_tlb_flush_mask(&mm->cpu_vm_mask); }
-+void flush_tlb_page(struct vm_area_struct * vma, unsigned long va)
-+{ xen_invlpg_mask(&vma->vm_mm->cpu_vm_mask, va); }
-+void flush_tlb_all(void)
-+{ xen_tlb_flush_all(); }
-+#endif /* Xen */
-+
-+/*
-+ * this function sends a 'reschedule' IPI to another CPU.
-+ * it goes straight through and wastes no time serializing
-+ * anything. Worst case is that we lose a reschedule ...
-+ */
++ unsigned long efer;
+
-+void smp_send_reschedule(int cpu)
-+{
-+ send_IPI_mask(cpumask_of_cpu(cpu), RESCHEDULE_VECTOR);
++ rdmsrl(MSR_EFER, efer);
++ if (!(efer & EFER_NX) || do_not_nx) {
++ __supported_pte_mask &= ~_PAGE_NX;
++ }
+}
+
++unsigned long kernel_eflags;
++
+/*
-+ * Structure and data for smp_call_function(). This is designed to minimise
-+ * static memory requirements. It also looks cleaner.
++ * cpu_init() initializes state that is per-CPU. Some data is already
++ * initialized (naturally) in the bootstrap process, such as the GDT
++ * and IDT. We reload them nevertheless, this function acts as a
++ * 'CPU state barrier', nothing should get across.
++ * A lot of state is already set up in PDA init.
+ */
-+static DEFINE_SPINLOCK(call_lock);
-+
-+struct call_data_struct {
-+ void (*func) (void *info);
-+ void *info;
-+ atomic_t started;
-+ atomic_t finished;
-+ int wait;
-+};
++void __cpuinit cpu_init (void)
++{
++ int cpu = stack_smp_processor_id();
++#ifndef CONFIG_X86_NO_TSS
++ struct tss_struct *t = &per_cpu(init_tss, cpu);
++ struct orig_ist *orig_ist = &per_cpu(orig_ist, cpu);
++ unsigned long v;
++ char *estacks = NULL;
++ int i;
++#endif
++ struct task_struct *me;
+
-+static struct call_data_struct * call_data;
++ /* CPU 0 is initialised in head64.c */
++ if (cpu != 0) {
++ pda_init(cpu);
++ zap_low_mappings(cpu);
++ }
++#ifndef CONFIG_X86_NO_TSS
++ else
++ estacks = boot_exception_stacks;
++#endif
+
-+void lock_ipi_call_lock(void)
-+{
-+ spin_lock_irq(&call_lock);
-+}
++ me = current;
+
-+void unlock_ipi_call_lock(void)
-+{
-+ spin_unlock_irq(&call_lock);
-+}
++ if (cpu_test_and_set(cpu, cpu_initialized))
++ panic("CPU#%d already initialized!\n", cpu);
+
-+/*
-+ * this function sends a 'generic call function' IPI to one other CPU
-+ * in the system.
-+ *
-+ * cpu is a standard Linux logical CPU number.
-+ */
-+static void
-+__smp_call_function_single(int cpu, void (*func) (void *info), void *info,
-+ int nonatomic, int wait)
-+{
-+ struct call_data_struct data;
-+ int cpus = 1;
++ printk("Initializing CPU#%d\n", cpu);
+
-+ data.func = func;
-+ data.info = info;
-+ atomic_set(&data.started, 0);
-+ data.wait = wait;
-+ if (wait)
-+ atomic_set(&data.finished, 0);
++ clear_in_cr4(X86_CR4_VME|X86_CR4_PVI|X86_CR4_TSD|X86_CR4_DE);
+
-+ call_data = &data;
-+ wmb();
-+ /* Send a message to all other CPUs and wait for them to respond */
-+ send_IPI_mask(cpumask_of_cpu(cpu), CALL_FUNCTION_VECTOR);
++ /*
++ * Initialize the per-CPU GDT with the boot GDT,
++ * and set up the GDT descriptor:
++ */
++#ifndef CONFIG_XEN
++ if (cpu)
++ memcpy(cpu_gdt(cpu), cpu_gdt_table, GDT_SIZE);
++#endif
+
-+ /* Wait for response */
-+ while (atomic_read(&data.started) != cpus)
-+ cpu_relax();
++ cpu_gdt_descr[cpu].size = GDT_SIZE;
++ cpu_gdt_init(&cpu_gdt_descr[cpu]);
+
-+ if (!wait)
-+ return;
++ memset(me->thread.tls_array, 0, GDT_ENTRY_TLS_ENTRIES * 8);
++ syscall_init();
+
-+ while (atomic_read(&data.finished) != cpus)
-+ cpu_relax();
-+}
++ wrmsrl(MSR_FS_BASE, 0);
++ wrmsrl(MSR_KERNEL_GS_BASE, 0);
++ barrier();
+
-+/*
-+ * smp_call_function_single - Run a function on another CPU
-+ * @func: The function to run. This must be fast and non-blocking.
-+ * @info: An arbitrary pointer to pass to the function.
-+ * @nonatomic: Currently unused.
-+ * @wait: If true, wait until function has completed on other CPUs.
-+ *
-+ * Retrurns 0 on success, else a negative status code.
-+ *
-+ * Does not return until the remote CPU is nearly ready to execute <func>
-+ * or is or has executed.
-+ */
++ check_efer();
+
-+int smp_call_function_single (int cpu, void (*func) (void *info), void *info,
-+ int nonatomic, int wait)
-+{
-+ /* prevent preemption and reschedule on another processor */
-+ int me = get_cpu();
-+ if (cpu == me) {
-+ put_cpu();
-+ return 0;
++#ifndef CONFIG_X86_NO_TSS
++ /*
++ * set up and load the per-CPU TSS
++ */
++ for (v = 0; v < N_EXCEPTION_STACKS; v++) {
++ static const unsigned int order[N_EXCEPTION_STACKS] = {
++ [0 ... N_EXCEPTION_STACKS - 1] = EXCEPTION_STACK_ORDER,
++ [DEBUG_STACK - 1] = DEBUG_STACK_ORDER
++ };
++ if (cpu) {
++ estacks = (char *)__get_free_pages(GFP_ATOMIC, order[v]);
++ if (!estacks)
++ panic("Cannot allocate exception stack %ld %d\n",
++ v, cpu);
++ }
++ estacks += PAGE_SIZE << order[v];
++ orig_ist->ist[v] = t->ist[v] = (unsigned long)estacks;
+ }
+
-+ /* Can deadlock when called with interrupts disabled */
-+ WARN_ON(irqs_disabled());
++ t->io_bitmap_base = offsetof(struct tss_struct, io_bitmap);
++ /*
++ * <= is required because the CPU will access up to
++ * 8 bits beyond the end of the IO permission bitmap.
++ */
++ for (i = 0; i <= IO_BITMAP_LONGS; i++)
++ t->io_bitmap[i] = ~0UL;
++#endif
+
-+ spin_lock_bh(&call_lock);
-+ __smp_call_function_single(cpu, func, info, nonatomic, wait);
-+ spin_unlock_bh(&call_lock);
-+ put_cpu();
-+ return 0;
-+}
-+EXPORT_SYMBOL(smp_call_function_single);
++ atomic_inc(&init_mm.mm_count);
++ me->active_mm = &init_mm;
++ if (me->mm)
++ BUG();
++ enter_lazy_tlb(&init_mm, me);
+
-+/*
-+ * this function sends a 'generic call function' IPI to all other CPUs
-+ * in the system.
-+ */
-+static void __smp_call_function (void (*func) (void *info), void *info,
-+ int nonatomic, int wait)
-+{
-+ struct call_data_struct data;
-+ int cpus = num_online_cpus()-1;
++#ifndef CONFIG_X86_NO_TSS
++ set_tss_desc(cpu, t);
++#endif
++#ifndef CONFIG_XEN
++ load_TR_desc();
++#endif
++ load_LDT(&init_mm.context);
+
-+ if (!cpus)
-+ return;
++ /*
++ * Clear all 6 debug registers:
++ */
+
-+ data.func = func;
-+ data.info = info;
-+ atomic_set(&data.started, 0);
-+ data.wait = wait;
-+ if (wait)
-+ atomic_set(&data.finished, 0);
++ set_debugreg(0UL, 0);
++ set_debugreg(0UL, 1);
++ set_debugreg(0UL, 2);
++ set_debugreg(0UL, 3);
++ set_debugreg(0UL, 6);
++ set_debugreg(0UL, 7);
+
-+ call_data = &data;
-+ wmb();
-+ /* Send a message to all other CPUs and wait for them to respond */
-+ send_IPI_allbutself(CALL_FUNCTION_VECTOR);
++ fpu_init();
+
-+ /* Wait for response */
-+ while (atomic_read(&data.started) != cpus)
-+#ifndef CONFIG_XEN
-+ cpu_relax();
-+#else
-+ barrier();
++ raw_local_save_flags(kernel_eflags);
++}
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 arch/x86_64/kernel/smp.c
+--- a/arch/x86_64/kernel/smp.c Wed Jul 18 12:23:24 2007 -0300
++++ b/arch/x86_64/kernel/smp.c Wed Aug 08 16:25:28 2007 -0300
+@@ -28,7 +28,11 @@
+ #include <asm/proto.h>
+ #include <asm/apicdef.h>
+ #include <asm/idle.h>
+-
++#ifdef CONFIG_XEN
++#include <xen/evtchn.h>
+#endif
+
-+ if (!wait)
-+ return;
-+
-+ while (atomic_read(&data.finished) != cpus)
+#ifndef CONFIG_XEN
-+ cpu_relax();
+ /*
+ * Smarter SMP flushing macros.
+ * c/o Linus Torvalds.
+@@ -66,6 +70,7 @@ union smp_flush_state {
+ to a full cache line because other CPUs can access it and we don't
+ want false sharing in the per cpu data segment. */
+ static DEFINE_PER_CPU(union smp_flush_state, flush_state);
++#endif
+
+ /*
+ * We cannot call mmdrop() because we are in interrupt context,
+@@ -79,6 +84,7 @@ static inline void leave_mm(int cpu)
+ load_cr3(swapper_pg_dir);
+ }
+
++#ifndef CONFIG_XEN
+ /*
+ *
+ * The flush IPI assumes that a thread switch happens in this order:
+@@ -283,6 +289,18 @@ void flush_tlb_all(void)
+ {
+ on_each_cpu(do_flush_tlb_all, NULL, 1, 1);
+ }
+#else
++asmlinkage void smp_invalidate_interrupt (void)
++{ return; }
++void flush_tlb_current_task(void)
++{ xen_tlb_flush_mask(&current->mm->cpu_vm_mask); }
++void flush_tlb_mm (struct mm_struct * mm)
++{ xen_tlb_flush_mask(&mm->cpu_vm_mask); }
++void flush_tlb_page(struct vm_area_struct * vma, unsigned long va)
++{ xen_invlpg_mask(&vma->vm_mm->cpu_vm_mask, va); }
++void flush_tlb_all(void)
++{ xen_tlb_flush_all(); }
++#endif /* Xen */
+
+ /*
+ * this function sends a 'reschedule' IPI to another CPU.
+@@ -418,13 +436,21 @@ static void __smp_call_function (void (*
+
+ /* Wait for response */
+ while (atomic_read(&data.started) != cpus)
++#ifdef CONFIG_XEN
+ barrier();
++#else
+ cpu_relax();
+#endif
-+}
-+
-+/*
-+ * smp_call_function - 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.
-+ * @nonatomic: currently unused.
-+ * @wait: If true, wait (atomically) until function has completed on other
-+ * CPUs.
-+ *
-+ * Returns 0 on success, else a negative status code. Does not return until
-+ * remote CPUs are nearly ready to execute func or are or have executed.
-+ *
-+ * You must not call this function with disabled interrupts or from a
-+ * hardware interrupt handler or from a bottom half handler.
-+ * Actually there are a few legal cases, like panic.
-+ */
-+int smp_call_function (void (*func) (void *info), void *info, int nonatomic,
-+ int wait)
-+{
-+ spin_lock(&call_lock);
-+ __smp_call_function(func,info,nonatomic,wait);
-+ spin_unlock(&call_lock);
-+ return 0;
-+}
-+EXPORT_SYMBOL(smp_call_function);
-+
-+void smp_stop_cpu(void)
-+{
-+ unsigned long flags;
-+ /*
-+ * Remove this CPU:
-+ */
-+ cpu_clear(smp_processor_id(), cpu_online_map);
-+ local_irq_save(flags);
-+#ifndef CONFIG_XEN
-+ disable_local_APIC();
+
+ if (!wait)
+ return;
+
+ while (atomic_read(&data.finished) != cpus)
++#ifdef CONFIG_XEN
++ barrier();
++#else
+ cpu_relax();
+#endif
-+ local_irq_restore(flags);
-+}
-+
-+static void smp_really_stop_cpu(void *dummy)
-+{
-+ smp_stop_cpu();
-+ for (;;)
-+ halt();
-+}
-+
-+void smp_send_stop(void)
-+{
-+ int nolock = 0;
+ }
+
+ /*
+@@ -460,7 +486,9 @@ void smp_stop_cpu(void)
+ */
+ cpu_clear(smp_processor_id(), cpu_online_map);
+ local_irq_save(flags);
+#ifndef CONFIG_XEN
-+ if (reboot_force)
-+ return;
+ disable_local_APIC();
+#endif
-+ /* Don't deadlock on the call lock in panic */
-+ if (!spin_trylock(&call_lock)) {
-+ /* ignore locking because we have panicked anyways */
-+ nolock = 1;
-+ }
-+ __smp_call_function(smp_really_stop_cpu, NULL, 0, 0);
-+ if (!nolock)
-+ spin_unlock(&call_lock);
-+
-+ local_irq_disable();
+ local_irq_restore(flags);
+ }
+
+@@ -474,8 +502,10 @@ void smp_send_stop(void)
+ void smp_send_stop(void)
+ {
+ int nolock = 0;
+#ifndef CONFIG_XEN
-+ disable_local_APIC();
+ if (reboot_force)
+ return;
+#endif
-+ local_irq_enable();
-+}
-+
-+/*
-+ * Reschedule call back. Nothing to do,
-+ * all the work is done automatically when
-+ * we return from the interrupt.
-+ */
+ /* Don't deadlock on the call lock in panic */
+ if (!spin_trylock(&call_lock)) {
+ /* ignore locking because we have panicked anyways */
+@@ -486,7 +516,9 @@ void smp_send_stop(void)
+ spin_unlock(&call_lock);
+
+ local_irq_disable();
+#ifndef CONFIG_XEN
-+asmlinkage void smp_reschedule_interrupt(void)
-+#else
-+asmlinkage irqreturn_t smp_reschedule_interrupt(void)
+ disable_local_APIC();
+#endif
+ local_irq_enable();
+ }
+
+@@ -495,18 +527,31 @@ void smp_send_stop(void)
+ * all the work is done automatically when
+ * we return from the interrupt.
+ */
++#ifdef CONFIG_XEN
++asmlinkage irqreturn_t smp_reschedule_interrupt(void)
+{
-+#ifndef CONFIG_XEN
-+ ack_APIC_irq();
-+#else
+ return IRQ_HANDLED;
-+#endif
+}
-+
-+#ifndef CONFIG_XEN
-+asmlinkage void smp_call_function_interrupt(void)
+#else
-+asmlinkage irqreturn_t smp_call_function_interrupt(void)
+ asmlinkage void smp_reschedule_interrupt(void)
+ {
+ ack_APIC_irq();
+ }
+-
+#endif
-+{
-+ void (*func) (void *info) = call_data->func;
-+ void *info = call_data->info;
-+ int wait = call_data->wait;
+
++#ifdef CONFIG_XEN
++asmlinkage irqreturn_t smp_call_function_interrupt(void)
++#else
+ asmlinkage void smp_call_function_interrupt(void)
++#endif
+ {
+ void (*func) (void *info) = call_data->func;
+ void *info = call_data->info;
+ int wait = call_data->wait;
+
+#ifndef CONFIG_XEN
-+ ack_APIC_irq();
+ ack_APIC_irq();
+#endif
-+ /*
-+ * Notify initiating CPU that I've grabbed the data and am
-+ * about to execute the function
-+ */
-+ mb();
-+ atomic_inc(&call_data->started);
-+ /*
-+ * At this point the info structure may be out of scope unless wait==1
-+ */
-+ exit_idle();
-+ irq_enter();
-+ (*func)(info);
-+ irq_exit();
-+ if (wait) {
-+ mb();
-+ atomic_inc(&call_data->finished);
-+ }
+ /*
+ * Notify initiating CPU that I've grabbed the data and am
+ * about to execute the function
+@@ -524,5 +569,7 @@ asmlinkage void smp_call_function_interr
+ mb();
+ atomic_inc(&call_data->finished);
+ }
+-}
+-
+#ifdef CONFIG_XEN
+ return IRQ_HANDLED;
+#endif
+}
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/arch/x86_64/kernel/time-xen.c source/arch/x86_64/kernel/time-xen.c
---- /scratch/src/linux-2.6.20.3/arch/x86_64/kernel/time-xen.c 1970-01-01 01:00:00.000000000 +0100
-+++ source/arch/x86_64/kernel/time-xen.c 2007-03-20 21:26:32.000000000 +0100
-@@ -0,0 +1,1057 @@
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 arch/x86_64/kernel/time-xen.c
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/arch/x86_64/kernel/time-xen.c Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,1073 @@
+/*
+ * linux/arch/i386/kernel/time.c
+ *
@@ -37038,8 +36030,6 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+
+#include <asm/hpet.h>
+
-+#include <asm/arch_hooks.h>
-+
+#include <xen/evtchn.h>
+#include <xen/interface/vcpu.h>
+
@@ -37125,26 +36115,6 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+}
+__setup("permitted_clock_jitter=", __permitted_clock_jitter);
+
-+#ifndef CONFIG_X86
-+int tsc_disable __devinitdata = 0;
-+#endif
-+
-+static void delay_tsc(unsigned long loops)
-+{
-+ unsigned long bclock, now;
-+
-+ rdtscl(bclock);
-+ do {
-+ rep_nop();
-+ rdtscl(now);
-+ } while ((now - bclock) < loops);
-+}
-+
-+struct timer_opts timer_tsc = {
-+ .name = "tsc",
-+ .delay = delay_tsc,
-+};
-+
+/*
+ * Scale a 64-bit delta by scaling and multiplying by a 32-bit fraction,
+ * yielding a 64-bit result.
@@ -37238,14 +36208,13 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ * Reads a consistent set of time-base values from Xen, into a shadow data
+ * area.
+ */
-+static void get_time_values_from_xen(void)
++static void get_time_values_from_xen(int cpu)
+{
-+ shared_info_t *s = HYPERVISOR_shared_info;
+ struct vcpu_time_info *src;
+ struct shadow_time_info *dst;
+
-+ src = &s->vcpu_info[smp_processor_id()].time;
-+ dst = &per_cpu(shadow_time, smp_processor_id());
++ src = &vcpu_info(cpu)->time;
++ dst = &per_cpu(shadow_time, cpu);
+
+ do {
+ dst->version = src->version;
@@ -37265,7 +36234,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ struct vcpu_time_info *src;
+ struct shadow_time_info *dst;
+
-+ src = &HYPERVISOR_shared_info->vcpu_info[cpu].time;
++ src = &vcpu_info(cpu)->time;
+ dst = &per_cpu(shadow_time, cpu);
+
+ rmb();
@@ -37349,7 +36318,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ * overflowed). Detect that and recalculate
+ * with fresh values.
+ */
-+ get_time_values_from_xen();
++ get_time_values_from_xen(cpu);
+ continue;
+ }
+ } while (read_seqretry(&xtime_lock, seq) ||
@@ -37374,7 +36343,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ s64 nsec;
+ unsigned int cpu;
+ struct shadow_time_info *shadow;
-+ dom0_op_t op;
++ struct xen_platform_op op;
+
+ if ((unsigned long)tv->tv_nsec >= NSEC_PER_SEC)
+ return -EINVAL;
@@ -37393,17 +36362,17 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ nsec = tv->tv_nsec - get_nsec_offset(shadow);
+ if (time_values_up_to_date(cpu))
+ break;
-+ get_time_values_from_xen();
++ get_time_values_from_xen(cpu);
+ }
+ sec = tv->tv_sec;
+ __normalize_time(&sec, &nsec);
+
+ if (is_initial_xendomain() && !independent_wallclock) {
-+ op.cmd = DOM0_SETTIME;
++ op.cmd = XENPF_settime;
+ op.u.settime.secs = sec;
+ op.u.settime.nsecs = nsec;
+ op.u.settime.system_time = shadow->system_timestamp;
-+ HYPERVISOR_dom0_op(&op);
++ HYPERVISOR_platform_op(&op);
+ update_wallclock();
+ } else if (independent_wallclock) {
+ nsec -= shadow->system_timestamp;
@@ -37427,7 +36396,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+{
+ time_t sec;
+ s64 nsec;
-+ dom0_op_t op;
++ struct xen_platform_op op;
+
+ if (!ntp_synced() || independent_wallclock || !is_initial_xendomain())
+ return;
@@ -37438,11 +36407,11 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ nsec = xtime.tv_nsec;
+ __normalize_time(&sec, &nsec);
+
-+ op.cmd = DOM0_SETTIME;
++ op.cmd = XENPF_settime;
+ op.u.settime.secs = sec;
+ op.u.settime.nsecs = nsec;
+ op.u.settime.system_time = processed_system_time;
-+ HYPERVISOR_dom0_op(&op);
++ HYPERVISOR_platform_op(&op);
+
+ update_wallclock();
+
@@ -37487,7 +36456,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ barrier();
+ time = shadow->system_timestamp + get_nsec_offset(shadow);
+ if (!time_values_up_to_date(cpu))
-+ get_time_values_from_xen();
++ get_time_values_from_xen(cpu);
+ barrier();
+ } while (local_time_version != shadow->version);
+
@@ -37520,6 +36489,11 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+}
+EXPORT_SYMBOL(profile_pc);
+
++/*
++ * This is the same as the above, except we _also_ save the current
++ * Time Stamp Counter value at the time of the timer interrupt, so that
++ * we later on can estimate the time of day more exactly.
++ */
+irqreturn_t timer_interrupt(int irq, void *dev_id)
+{
+ s64 delta, delta_cpu, stolen, blocked;
@@ -37528,10 +36502,17 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ struct shadow_time_info *shadow = &per_cpu(shadow_time, cpu);
+ struct vcpu_runstate_info *runstate = &per_cpu(runstate, cpu);
+
++ /*
++ * Here we are in the timer irq handler. We just have irqs locally
++ * disabled but we don't know if the timer_bh is running on the other
++ * CPU. We need to avoid to SMP race with it. NOTE: we don' t need
++ * the irq version of write_lock because as just said we have irq
++ * locally disabled. -arca
++ */
+ write_seqlock(&xtime_lock);
+
+ do {
-+ get_time_values_from_xen();
++ get_time_values_from_xen(cpu);
+
+ /* Obtain a consistent snapshot of elapsed wallclock cycles. */
+ delta = delta_cpu =
@@ -37618,7 +36599,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ if (delta_cpu > 0) {
+ do_div(delta_cpu, NS_PER_TICK);
+ per_cpu(processed_system_time, cpu) += delta_cpu * NS_PER_TICK;
-+ if (user_mode(get_irq_regs()))
++ if (user_mode_vm(get_irq_regs()))
+ account_user_time(current, (cputime_t)delta_cpu);
+ else
+ account_system_time(current, HARDIRQ_OFFSET,
@@ -37628,9 +36609,12 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ /* Local timer processing (see update_process_times()). */
+ run_local_timers();
+ if (rcu_pending(cpu))
-+ rcu_check_callbacks(cpu, user_mode(get_irq_regs()));
++ rcu_check_callbacks(cpu, user_mode_vm(get_irq_regs()));
+ scheduler_tick();
+ run_posix_cpu_timers(current);
++// JQ: Why this works on 2.6.16 & 2.6.18 and generates a page
++// fault on 2.6.19 is a mistery to me.
++// profile_tick(CPU_PROFILING);
+
+ return IRQ_HANDLED;
+}
@@ -37825,6 +36809,10 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ BUG_ON(per_cpu(timer_irq, 0) < 0);
+}
+
++static struct vcpu_set_periodic_timer xen_set_periodic_tick = {
++ .period_ns = NS_PER_TICK
++};
++
+void __init time_init(void)
+{
+#ifdef CONFIG_HPET_TIMER
@@ -37837,7 +36825,11 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ return;
+ }
+#endif
-+ get_time_values_from_xen();
++
++ HYPERVISOR_vcpu_op(VCPUOP_set_periodic_timer, 0,
++ &xen_set_periodic_tick);
++
++ get_time_values_from_xen(0);
+
+ processed_system_time = per_cpu(shadow_time, 0).system_timestamp;
+ per_cpu(processed_system_time, 0) = processed_system_time;
@@ -37849,12 +36841,6 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ printk(KERN_INFO "Xen reported: %u.%03u MHz processor.\n",
+ cpu_khz / 1000, cpu_khz % 1000);
+
-+ vxtime.mode = VXTIME_TSC;
-+ vxtime.quot = (1000000L << US_SCALE) / vxtime_hz;
-+ vxtime.tsc_quot = (1000L << US_SCALE) / cpu_khz;
-+ sync_core();
-+ rdtscll(vxtime.last_tsc);
-+
+ /* Cannot request_irq() until kmem is initialised. */
+ late_time_init = setup_cpu0_timer_irq;
+}
@@ -37892,8 +36878,10 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ */
+static void stop_hz_timer(void)
+{
++ struct vcpu_set_singleshot_timer singleshot;
+ unsigned int cpu = smp_processor_id();
+ unsigned long j;
++ int rc;
+
+ cpu_set(cpu, nohz_cpu_mask);
+
@@ -37913,8 +36901,16 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ j = jiffies + 1;
+ }
+
-+ if (HYPERVISOR_set_timer_op(jiffies_to_st(j)) != 0)
-+ BUG();
++ singleshot.timeout_abs_ns = jiffies_to_st(j);
++ singleshot.flags = 0;
++ rc = HYPERVISOR_vcpu_op(VCPUOP_set_singleshot_timer, cpu, &singleshot);
++#if CONFIG_XEN_COMPAT <= 0x030004
++ if (rc) {
++ BUG_ON(rc != -ENOSYS);
++ rc = HYPERVISOR_set_timer_op(singleshot.timeout_abs_ns);
++ }
++#endif
++ BUG_ON(rc);
+}
+
+static void start_hz_timer(void)
@@ -37938,16 +36934,23 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+}
+EXPORT_SYMBOL(halt);
+
-+/* No locking required. We are only CPU running, and interrupts are off. */
++/* No locking required. Interrupts are disabled on all CPUs. */
+void time_resume(void)
+{
++ unsigned int cpu;
++
+ init_cpu_khz();
+
-+ get_time_values_from_xen();
++ for_each_online_cpu(cpu) {
++ HYPERVISOR_vcpu_op(VCPUOP_set_periodic_timer, cpu,
++ &xen_set_periodic_tick);
++ get_time_values_from_xen(cpu);
++ per_cpu(processed_system_time, cpu) =
++ per_cpu(shadow_time, 0).system_timestamp;
++ init_missing_ticks_accounting(cpu);
++ }
+
+ processed_system_time = per_cpu(shadow_time, 0).system_timestamp;
-+ per_cpu(processed_system_time, 0) = processed_system_time;
-+ init_missing_ticks_accounting(0);
+
+ update_wallclock();
+}
@@ -37955,12 +36958,15 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#ifdef CONFIG_SMP
+static char timer_name[NR_CPUS][15];
+
-+void local_setup_timer(unsigned int cpu)
++int local_setup_timer(unsigned int cpu)
+{
-+ int seq;
++ int seq, irq;
+
+ BUG_ON(cpu == 0);
+
++ HYPERVISOR_vcpu_op(VCPUOP_set_periodic_timer, cpu,
++ &xen_set_periodic_tick);
++
+ do {
+ seq = read_seqbegin(&xtime_lock);
+ /* Use cpu0 timestamp: cpu's shadow is not initialised yet. */
@@ -37970,15 +36976,17 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ } while (read_seqretry(&xtime_lock, seq));
+
+ sprintf(timer_name[cpu], "timer%d", cpu);
-+ per_cpu(timer_irq, cpu) =
-+ bind_virq_to_irqhandler(
-+ VIRQ_TIMER,
-+ cpu,
-+ timer_interrupt,
-+ SA_INTERRUPT,
-+ timer_name[cpu],
-+ NULL);
-+ BUG_ON(per_cpu(timer_irq, cpu) < 0);
++ irq = bind_virq_to_irqhandler(VIRQ_TIMER,
++ cpu,
++ timer_interrupt,
++ SA_INTERRUPT,
++ timer_name[cpu],
++ NULL);
++ if (irq < 0)
++ return irq;
++ per_cpu(timer_irq, cpu) = irq;
++
++ return 0;
+}
+
+void local_teardown_timer(unsigned int cpu)
@@ -38025,9 +37033,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ return 0;
+}
+__initcall(xen_sysctl_init);
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/arch/x86_64/kernel/traps-xen.c source/arch/x86_64/kernel/traps-xen.c
---- /scratch/src/linux-2.6.20.3/arch/x86_64/kernel/traps-xen.c 1970-01-01 01:00:00.000000000 +0100
-+++ source/arch/x86_64/kernel/traps-xen.c 2007-03-20 21:26:32.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 arch/x86_64/kernel/traps-xen.c
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/arch/x86_64/kernel/traps-xen.c Wed Aug 08 16:25:28 2007 -0300
@@ -0,0 +1,1156 @@
+/*
+ * linux/arch/x86-64/traps.c
@@ -39185,9 +38193,18 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ return 0;
+}
+early_param("kstack", kstack_setup);
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/arch/x86_64/kernel/vmlinux.lds.S source/arch/x86_64/kernel/vmlinux.lds.S
---- /scratch/src/linux-2.6.20.3/arch/x86_64/kernel/vmlinux.lds.S 2007-02-04 19:44:54.000000000 +0100
-+++ source/arch/x86_64/kernel/vmlinux.lds.S 2007-03-20 21:26:32.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 arch/x86_64/kernel/vmlinux.lds.S
+--- a/arch/x86_64/kernel/vmlinux.lds.S Wed Jul 18 12:23:24 2007 -0300
++++ b/arch/x86_64/kernel/vmlinux.lds.S Wed Aug 08 16:25:28 2007 -0300
+@@ -127,7 +127,7 @@ SECTIONS
+ . = ALIGN(8192); /* init_task */
+ .data.init_task : AT(ADDR(.data.init_task) - LOAD_OFFSET) {
+ *(.data.init_task)
+- }:data.init
++ } :data.init
+
+ . = ALIGN(4096);
+ .data.page_aligned : AT(ADDR(.data.page_aligned) - LOAD_OFFSET) {
@@ -227,4 +227,6 @@ SECTIONS
STABS_DEBUG
@@ -39195,9 +38212,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+
+ NOTES
}
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/arch/x86_64/kernel/vsyscall.c source/arch/x86_64/kernel/vsyscall.c
---- /scratch/src/linux-2.6.20.3/arch/x86_64/kernel/vsyscall.c 2007-02-04 19:44:54.000000000 +0100
-+++ source/arch/x86_64/kernel/vsyscall.c 2007-03-20 21:26:32.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 arch/x86_64/kernel/vsyscall.c
+--- a/arch/x86_64/kernel/vsyscall.c Wed Jul 18 12:23:24 2007 -0300
++++ b/arch/x86_64/kernel/vsyscall.c Wed Aug 08 16:25:28 2007 -0300
@@ -246,6 +246,7 @@ static ctl_table kernel_root_table2[] =
#endif
@@ -39214,10 +38231,11 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
static void __init map_vsyscall(void)
{
-@@ -292,6 +294,17 @@ static void __init map_vsyscall(void)
+@@ -291,6 +293,17 @@ static void __init map_vsyscall(void)
+ /* Note that VSYSCALL_MAPPED_PAGES must agree with the code below. */
__set_fixmap(VSYSCALL_FIRST_PAGE, physaddr_page0, PAGE_KERNEL_VSYSCALL);
}
-
++
+#ifdef CONFIG_XEN
+static void __init map_vsyscall_user(void)
+{
@@ -39228,10 +38246,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ __set_fixmap_user(VSYSCALL_FIRST_PAGE, physaddr_page0, PAGE_KERNEL_VSYSCALL);
+}
+#endif
-+
+
static int __init vsyscall_init(void)
{
- BUG_ON(((unsigned long) &vgettimeofday !=
@@ -300,11 +313,17 @@ static int __init vsyscall_init(void)
BUG_ON((VSYSCALL_ADDR(0) != __fix_to_virt(VSYSCALL_FIRST_PAGE)));
BUG_ON((unsigned long) &vgetcpu != VSYSCALL_ADDR(__NR_vgetcpu));
@@ -39250,9 +38267,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
return 0;
}
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/arch/x86_64/kernel/xen_entry.S source/arch/x86_64/kernel/xen_entry.S
---- /scratch/src/linux-2.6.20.3/arch/x86_64/kernel/xen_entry.S 1970-01-01 01:00:00.000000000 +0100
-+++ source/arch/x86_64/kernel/xen_entry.S 2007-03-20 21:26:32.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 arch/x86_64/kernel/xen_entry.S
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/arch/x86_64/kernel/xen_entry.S Wed Aug 08 16:25:28 2007 -0300
@@ -0,0 +1,40 @@
+/*
+ * Copied from arch/xen/i386/kernel/entry.S
@@ -39294,383 +38311,56 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+VGCF_IN_SYSCALL = (1<<8)
+
+
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/arch/x86_64/Makefile source/arch/x86_64/Makefile
---- /scratch/src/linux-2.6.20.3/arch/x86_64/Makefile 2007-02-04 19:44:54.000000000 +0100
-+++ source/arch/x86_64/Makefile 2007-03-20 21:26:32.000000000 +0100
-@@ -36,6 +36,10 @@ cflags-$(CONFIG_MCORE2) += \
- $(call cc-option,-march=core2,$(call cc-option,-mtune=generic))
- cflags-$(CONFIG_GENERIC_CPU) += $(call cc-option,-mtune=generic)
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 arch/x86_64/mm/Makefile
+--- a/arch/x86_64/mm/Makefile Wed Jul 18 12:23:24 2007 -0300
++++ b/arch/x86_64/mm/Makefile Wed Aug 08 16:25:28 2007 -0300
+@@ -9,3 +9,13 @@ obj-$(CONFIG_ACPI_NUMA) += srat.o
+ obj-$(CONFIG_ACPI_NUMA) += srat.o
-+cppflags-$(CONFIG_XEN) += \
-+ -D__XEN_INTERFACE_VERSION__=$(CONFIG_XEN_INTERFACE_VERSION)
-+CPPFLAGS += $(cppflags-y)
+ hugetlbpage-y = ../../i386/mm/hugetlbpage.o
+
- cflags-y += -m64
- cflags-y += -mno-red-zone
- cflags-y += -mcmodel=kernel
-@@ -90,6 +94,21 @@ boot := arch/x86_64/boot
- PHONY += bzImage bzlilo install archmrproper \
- fdimage fdimage144 fdimage288 isoimage archclean
-
+ifdef CONFIG_XEN
-+CPPFLAGS := -Iinclude$(if $(KBUILD_SRC),2)/asm/mach-xen $(CPPFLAGS)
-+head-y := arch/x86_64/kernel/head-xen.o arch/x86_64/kernel/head64.o arch/x86_64/kernel/init_task.o
-+LDFLAGS_vmlinux := -e _start
-+boot := arch/i386/boot-xen
-+.PHONY: vmlinuz
-+#Default target when executing "make"
-+all: vmlinuz
++include $(srctree)/scripts/Makefile.xen
+
-+vmlinuz: vmlinux
-+ $(Q)$(MAKE) $(build)=$(boot) $@
++ioremap-y += ../../i386/mm/ioremap-xen.o
++hypervisor-y += ../../i386/mm/hypervisor.o
++obj-y += hypervisor.o
+
-+install:
-+ $(Q)$(MAKE) $(build)=$(boot) XENGUEST=$(XENGUEST) $@
-+else
- #Default target when executing "make"
- all: bzImage
-
-@@ -110,6 +129,7 @@ fdimage fdimage144 fdimage288 isoimage:
-
- install:
- $(Q)$(MAKE) $(build)=$(boot) BOOTIMAGE=$(BOOTIMAGE) $@
++obj-y := $(call cherrypickxen, $(obj-y))
+endif
-
- archclean:
- $(Q)$(MAKE) $(clean)=$(boot)
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/arch/x86_64/mm/fault-xen.c source/arch/x86_64/mm/fault-xen.c
---- /scratch/src/linux-2.6.20.3/arch/x86_64/mm/fault-xen.c 1970-01-01 01:00:00.000000000 +0100
-+++ source/arch/x86_64/mm/fault-xen.c 2007-03-20 21:26:32.000000000 +0100
-@@ -0,0 +1,717 @@
-+/*
-+ * linux/arch/x86-64/mm/fault.c
-+ *
-+ * Copyright (C) 1995 Linus Torvalds
-+ * Copyright (C) 2001,2002 Andi Kleen, SuSE Labs.
-+ */
-+
-+#include <linux/signal.h>
-+#include <linux/sched.h>
-+#include <linux/kernel.h>
-+#include <linux/errno.h>
-+#include <linux/string.h>
-+#include <linux/types.h>
-+#include <linux/ptrace.h>
-+#include <linux/mman.h>
-+#include <linux/mm.h>
-+#include <linux/smp.h>
-+#include <linux/smp_lock.h>
-+#include <linux/interrupt.h>
-+#include <linux/init.h>
-+#include <linux/tty.h>
-+#include <linux/vt_kern.h> /* For unblank_screen() */
-+#include <linux/compiler.h>
-+#include <linux/module.h>
-+#include <linux/kprobes.h>
-+#include <linux/uaccess.h>
-+
-+#include <asm/system.h>
-+#include <asm/pgalloc.h>
-+#include <asm/smp.h>
-+#include <asm/tlbflush.h>
-+#include <asm/proto.h>
-+#include <asm/kdebug.h>
-+#include <asm-generic/sections.h>
-+
-+/* Page fault error code bits */
-+#define PF_PROT (1<<0) /* or no page found */
-+#define PF_WRITE (1<<1)
-+#define PF_USER (1<<2)
-+#define PF_RSVD (1<<3)
-+#define PF_INSTR (1<<4)
-+
-+static ATOMIC_NOTIFIER_HEAD(notify_page_fault_chain);
-+
-+/* Hook to register for page fault notifications */
-+int register_page_fault_notifier(struct notifier_block *nb)
-+{
-+ vmalloc_sync_all();
-+ return atomic_notifier_chain_register(&notify_page_fault_chain, nb);
-+}
-+EXPORT_SYMBOL_GPL(register_page_fault_notifier);
-+
-+int unregister_page_fault_notifier(struct notifier_block *nb)
-+{
-+ return atomic_notifier_chain_unregister(&notify_page_fault_chain, nb);
-+}
-+EXPORT_SYMBOL_GPL(unregister_page_fault_notifier);
-+
-+static inline int notify_page_fault(enum die_val val, const char *str,
-+ struct pt_regs *regs, long err, int trap, int sig)
-+{
-+ struct die_args args = {
-+ .regs = regs,
-+ .str = str,
-+ .err = err,
-+ .trapnr = trap,
-+ .signr = sig
-+ };
-+ return atomic_notifier_call_chain(&notify_page_fault_chain, val, &args);
-+}
-+
-+void bust_spinlocks(int yes)
-+{
-+ int loglevel_save = console_loglevel;
-+ if (yes) {
-+ oops_in_progress = 1;
-+ } else {
-+#ifdef CONFIG_VT
-+ unblank_screen();
-+#endif
-+ oops_in_progress = 0;
-+ /*
-+ * OK, the message is on the console. Now we call printk()
-+ * without oops_in_progress set so that printk will give klogd
-+ * a poke. Hold onto your hats...
-+ */
-+ console_loglevel = 15; /* NMI oopser may have shut the console up */
-+ printk(" ");
-+ console_loglevel = loglevel_save;
-+ }
-+}
-+
-+/* Sometimes the CPU reports invalid exceptions on prefetch.
-+ Check that here and ignore.
-+ Opcode checker based on code by Richard Brunner */
-+static noinline int is_prefetch(struct pt_regs *regs, unsigned long addr,
-+ unsigned long error_code)
-+{
-+ unsigned char *instr;
-+ int scan_more = 1;
-+ int prefetch = 0;
-+ unsigned char *max_instr;
-+
-+ /* If it was a exec fault ignore */
-+ if (error_code & PF_INSTR)
-+ return 0;
-+
-+ instr = (unsigned char __user *)convert_rip_to_linear(current, regs);
-+ max_instr = instr + 15;
-+
-+ if (user_mode(regs) && instr >= (unsigned char *)TASK_SIZE)
-+ return 0;
-+
-+ while (scan_more && instr < max_instr) {
-+ unsigned char opcode;
-+ unsigned char instr_hi;
-+ unsigned char instr_lo;
-+
-+ if (probe_kernel_address(instr, opcode))
-+ break;
-+
-+ instr_hi = opcode & 0xf0;
-+ instr_lo = opcode & 0x0f;
-+ instr++;
-+
-+ switch (instr_hi) {
-+ case 0x20:
-+ case 0x30:
-+ /* Values 0x26,0x2E,0x36,0x3E are valid x86
-+ prefixes. In long mode, the CPU will signal
-+ invalid opcode if some of these prefixes are
-+ present so we will never get here anyway */
-+ scan_more = ((instr_lo & 7) == 0x6);
-+ break;
-+
-+ case 0x40:
-+ /* In AMD64 long mode, 0x40 to 0x4F are valid REX prefixes
-+ Need to figure out under what instruction mode the
-+ instruction was issued ... */
-+ /* Could check the LDT for lm, but for now it's good
-+ enough to assume that long mode only uses well known
-+ segments or kernel. */
-+ scan_more = (!user_mode(regs)) || (regs->cs == __USER_CS);
-+ break;
-+
-+ case 0x60:
-+ /* 0x64 thru 0x67 are valid prefixes in all modes. */
-+ scan_more = (instr_lo & 0xC) == 0x4;
-+ break;
-+ case 0xF0:
-+ /* 0xF0, 0xF2, and 0xF3 are valid prefixes in all modes. */
-+ scan_more = !instr_lo || (instr_lo>>1) == 1;
-+ break;
-+ case 0x00:
-+ /* Prefetch instruction is 0x0F0D or 0x0F18 */
-+ scan_more = 0;
-+ if (probe_kernel_address(instr, opcode))
-+ break;
-+ prefetch = (instr_lo == 0xF) &&
-+ (opcode == 0x0D || opcode == 0x18);
-+ break;
-+ default:
-+ scan_more = 0;
-+ break;
-+ }
-+ }
-+ return prefetch;
-+}
-+
-+static int bad_address(void *p)
-+{
-+ unsigned long dummy;
-+ return probe_kernel_address((unsigned long *)p, dummy);
-+}
-+
-+void dump_pagetable(unsigned long address)
-+{
-+ pgd_t *pgd;
-+ pud_t *pud;
-+ pmd_t *pmd;
-+ pte_t *pte;
-+
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 arch/x86_64/mm/fault.c
+--- a/arch/x86_64/mm/fault.c Wed Jul 18 12:23:24 2007 -0300
++++ b/arch/x86_64/mm/fault.c Wed Aug 08 16:25:28 2007 -0300
+@@ -180,9 +180,7 @@ void dump_pagetable(unsigned long addres
+ pmd_t *pmd;
+ pte_t *pte;
+
+- asm("movq %%cr3,%0" : "=r" (pgd));
+-
+- pgd = __va((unsigned long)pgd & PHYSICAL_PAGE_MASK);
+ pgd = __va(read_cr3() & PHYSICAL_PAGE_MASK);
-+ pgd += pgd_index(address);
-+ if (bad_address(pgd)) goto bad;
-+ printk("PGD %lx ", pgd_val(*pgd));
-+ if (!pgd_present(*pgd)) goto ret;
-+
-+ pud = pud_offset(pgd, address);
-+ if (bad_address(pud)) goto bad;
-+ printk("PUD %lx ", pud_val(*pud));
-+ if (!pud_present(*pud)) goto ret;
-+
-+ pmd = pmd_offset(pud, address);
-+ if (bad_address(pmd)) goto bad;
-+ printk("PMD %lx ", pmd_val(*pmd));
-+ if (!pmd_present(*pmd)) goto ret;
-+
-+ pte = pte_offset_kernel(pmd, address);
-+ if (bad_address(pte)) goto bad;
-+ printk("PTE %lx", pte_val(*pte));
-+ret:
-+ printk("\n");
-+ return;
-+bad:
-+ printk("BAD\n");
-+}
-+
-+static const char errata93_warning[] =
-+KERN_ERR "******* Your BIOS seems to not contain a fix for K8 errata #93\n"
-+KERN_ERR "******* Working around it, but it may cause SEGVs or burn power.\n"
-+KERN_ERR "******* Please consider a BIOS update.\n"
-+KERN_ERR "******* Disabling USB legacy in the BIOS may also help.\n";
-+
-+/* Workaround for K8 erratum #93 & buggy BIOS.
-+ BIOS SMM functions are required to use a specific workaround
-+ to avoid corruption of the 64bit RIP register on C stepping K8.
-+ A lot of BIOS that didn't get tested properly miss this.
-+ The OS sees this as a page fault with the upper 32bits of RIP cleared.
-+ Try to work around it here.
-+ Note we only handle faults in kernel here. */
-+
-+static int is_errata93(struct pt_regs *regs, unsigned long address)
-+{
-+ static int warned;
-+ if (address != regs->rip)
-+ return 0;
-+ if ((address >> 32) != 0)
-+ return 0;
-+ address |= 0xffffffffUL << 32;
-+ if ((address >= (u64)_stext && address <= (u64)_etext) ||
-+ (address >= MODULES_VADDR && address <= MODULES_END)) {
-+ if (!warned) {
-+ printk(errata93_warning);
-+ warned = 1;
-+ }
-+ regs->rip = address;
-+ return 1;
-+ }
-+ return 0;
-+}
-+
-+int unhandled_signal(struct task_struct *tsk, int sig)
-+{
-+ if (is_init(tsk))
-+ return 1;
-+ if (tsk->ptrace & PT_PTRACED)
-+ return 0;
-+ return (tsk->sighand->action[sig-1].sa.sa_handler == SIG_IGN) ||
-+ (tsk->sighand->action[sig-1].sa.sa_handler == SIG_DFL);
-+}
-+
-+static noinline void pgtable_bad(unsigned long address, struct pt_regs *regs,
-+ unsigned long error_code)
-+{
-+ unsigned long flags = oops_begin();
-+ struct task_struct *tsk;
-+
-+ printk(KERN_ALERT "%s: Corrupted page table at address %lx\n",
-+ current->comm, address);
-+ dump_pagetable(address);
-+ tsk = current;
-+ tsk->thread.cr2 = address;
-+ tsk->thread.trap_no = 14;
-+ tsk->thread.error_code = error_code;
-+ __die("Bad pagetable", regs, error_code);
-+ oops_end(flags);
-+ do_exit(SIGKILL);
-+}
-+
-+/*
-+ * Handle a fault on the vmalloc area
-+ *
-+ * This assumes no large pages in there.
-+ */
-+static int vmalloc_fault(unsigned long address)
-+{
-+ pgd_t *pgd, *pgd_ref;
-+ pud_t *pud, *pud_ref;
-+ pmd_t *pmd, *pmd_ref;
-+ pte_t *pte, *pte_ref;
-+
-+ /* Copy kernel mappings over when needed. This can also
-+ happen within a race in page table update. In the later
-+ case just flush. */
-+
+ pgd += pgd_index(address);
+ if (bad_address(pgd)) goto bad;
+ printk("PGD %lx ", pgd_val(*pgd));
+@@ -286,7 +284,13 @@ static int vmalloc_fault(unsigned long a
+ happen within a race in page table update. In the later
+ case just flush. */
+
++#ifdef CONFIG_XEN
+ /* On Xen the line below does not always work. Needs investigating! */
-+ /*pgd = pgd_offset(current->mm ?: &init_mm, address);*/
+ pgd = __va(read_cr3() & PHYSICAL_PAGE_MASK);
+ pgd += pgd_index(address);
-+ pgd_ref = pgd_offset_k(address);
-+ if (pgd_none(*pgd_ref))
-+ return -1;
-+ if (pgd_none(*pgd))
-+ set_pgd(pgd, *pgd_ref);
-+ else
-+ BUG_ON(pgd_page_vaddr(*pgd) != pgd_page_vaddr(*pgd_ref));
-+
-+ /* Below here mismatches are bugs because these lower tables
-+ are shared */
-+
-+ pud = pud_offset(pgd, address);
-+ pud_ref = pud_offset(pgd_ref, address);
-+ if (pud_none(*pud_ref))
-+ return -1;
-+ if (pud_none(*pud) || pud_page_vaddr(*pud) != pud_page_vaddr(*pud_ref))
-+ BUG();
-+ pmd = pmd_offset(pud, address);
-+ pmd_ref = pmd_offset(pud_ref, address);
-+ if (pmd_none(*pmd_ref))
-+ return -1;
-+ if (pmd_none(*pmd) || pmd_page(*pmd) != pmd_page(*pmd_ref))
-+ BUG();
-+ pte_ref = pte_offset_kernel(pmd_ref, address);
-+ if (!pte_present(*pte_ref))
-+ return -1;
-+ pte = pte_offset_kernel(pmd, address);
-+ /* Don't use pte_page here, because the mappings can point
-+ outside mem_map, and the NUMA hash lookup cannot handle
-+ that. */
-+ if (!pte_present(*pte) || pte_pfn(*pte) != pte_pfn(*pte_ref))
-+ BUG();
-+ return 0;
-+}
-+
-+int page_fault_trace = 0;
-+int exception_trace = 1;
-+
-+
++#else
+ pgd = pgd_offset(current->mm ?: &init_mm, address);
++#endif
+ pgd_ref = pgd_offset_k(address);
+ if (pgd_none(*pgd_ref))
+ return -1;
+@@ -325,6 +329,61 @@ int page_fault_trace = 0;
+ int page_fault_trace = 0;
+ int exception_trace = 1;
+
++#ifdef CONFIG_XEN
+#define MEM_VERBOSE 1
+
+#ifdef MEM_VERBOSE
@@ -39723,346 +38413,49 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+
+ return 1;
+}
++#endif
+
-+/*
-+ * This routine handles page faults. It determines the address,
-+ * and the problem, and then passes it off to one of the appropriate
-+ * routines.
-+ */
-+asmlinkage void __kprobes do_page_fault(struct pt_regs *regs,
-+ unsigned long error_code)
-+{
-+ struct task_struct *tsk;
-+ struct mm_struct *mm;
-+ struct vm_area_struct * vma;
-+ unsigned long address;
-+ const struct exception_table_entry *fixup;
-+ int write;
-+ unsigned long flags;
-+ siginfo_t info;
-+
+ /*
+ * This routine handles page faults. It determines the address,
+ * and the problem, and then passes it off to one of the appropriate
+@@ -342,12 +401,21 @@ asmlinkage void __kprobes do_page_fault(
+ unsigned long flags;
+ siginfo_t info;
+
++#ifdef CONFIG_XEN
+ if (!user_mode(regs))
+ error_code &= ~PF_USER; /* means kernel */
++#endif
+
-+ tsk = current;
-+ mm = tsk->mm;
-+ prefetchw(&mm->mmap_sem);
-+
-+ /* get the address */
-+ address = HYPERVISOR_shared_info->vcpu_info[
-+ smp_processor_id()].arch.cr2;
-+
-+ info.si_code = SEGV_MAPERR;
-+
-+
-+ /*
-+ * We fault-in kernel-space virtual memory on-demand. The
-+ * 'reference' page table is init_mm.pgd.
-+ *
-+ * NOTE! We MUST NOT take any locks for this case. We may
-+ * be in an interrupt or a critical region, and should
-+ * only copy the information from the master page table,
-+ * nothing more.
-+ *
-+ * This verifies that the fault happens in kernel space
-+ * (error_code & 4) == 0, and that the fault was not a
-+ * protection error (error_code & 9) == 0.
-+ */
-+ if (unlikely(address >= TASK_SIZE64)) {
-+ /*
-+ * Don't check for the module range here: its PML4
-+ * is always initialized because it's shared with the main
-+ * kernel text. Only vmalloc may need PML4 syncups.
-+ */
-+ if (!(error_code & (PF_RSVD|PF_USER|PF_PROT)) &&
-+ ((address >= VMALLOC_START && address < VMALLOC_END))) {
-+ if (vmalloc_fault(address) >= 0)
-+ return;
-+ }
-+ if (notify_page_fault(DIE_PAGE_FAULT, "page fault", regs, error_code, 14,
-+ SIGSEGV) == NOTIFY_STOP)
-+ return;
+ tsk = current;
+ mm = tsk->mm;
+ prefetchw(&mm->mmap_sem);
+
+ /* get the address */
++#ifdef CONFIG_XEN
++ address = current_vcpu_info()->arch.cr2;
++#else
+ __asm__("movq %%cr2,%0":"=r" (address));
++#endif
+
+ info.si_code = SEGV_MAPERR;
+
+@@ -376,6 +444,11 @@ asmlinkage void __kprobes do_page_fault(
+ if (vmalloc_fault(address) >= 0)
+ return;
+ }
++#ifdef CONFIG_XEN
+ /* Can take a spurious fault if mapping changes R/O -> R/W. */
+ if (spurious_fault(regs, address, error_code))
+ return;
-+ /*
-+ * Don't take the mm semaphore here. If we fixup a prefetch
-+ * fault we could otherwise deadlock.
-+ */
-+ goto bad_area_nosemaphore;
-+ }
-+
-+ if (notify_page_fault(DIE_PAGE_FAULT, "page fault", regs, error_code, 14,
-+ SIGSEGV) == NOTIFY_STOP)
-+ return;
-+
-+ if (likely(regs->eflags & X86_EFLAGS_IF))
-+ local_irq_enable();
-+
-+ if (unlikely(page_fault_trace))
-+ printk("pagefault rip:%lx rsp:%lx cs:%lu ss:%lu address %lx error %lx\n",
-+ regs->rip,regs->rsp,regs->cs,regs->ss,address,error_code);
-+
-+ if (unlikely(error_code & PF_RSVD))
-+ pgtable_bad(address, regs, error_code);
-+
-+ /*
-+ * If we're in an interrupt or have no user
-+ * context, we must not take the fault..
-+ */
-+ if (unlikely(in_atomic() || !mm))
-+ goto bad_area_nosemaphore;
-+
-+ again:
-+ /* When running in the kernel we expect faults to occur only to
-+ * addresses in user space. All other faults represent errors in the
-+ * kernel and should generate an OOPS. Unfortunatly, in the case of an
-+ * erroneous fault occurring in a code path which already holds mmap_sem
-+ * we will deadlock attempting to validate the fault against the
-+ * address space. Luckily the kernel only validly references user
-+ * space from well defined areas of code, which are listed in the
-+ * exceptions table.
-+ *
-+ * As the vast majority of faults will be valid we will only perform
-+ * the source reference check when there is a possibilty of a deadlock.
-+ * Attempt to lock the address space, if we cannot we then validate the
-+ * source. If this is invalid we can skip the address space check,
-+ * thus avoiding the deadlock.
-+ */
-+ if (!down_read_trylock(&mm->mmap_sem)) {
-+ if ((error_code & PF_USER) == 0 &&
-+ !search_exception_tables(regs->rip))
-+ goto bad_area_nosemaphore;
-+ down_read(&mm->mmap_sem);
-+ }
-+
-+ vma = find_vma(mm, address);
-+ if (!vma)
-+ goto bad_area;
-+ if (likely(vma->vm_start <= address))
-+ goto good_area;
-+ if (!(vma->vm_flags & VM_GROWSDOWN))
-+ goto bad_area;
-+ if (error_code & 4) {
-+ // XXX: align red zone size with ABI
-+ if (address + 128 < regs->rsp)
-+ goto bad_area;
-+ }
-+ if (expand_stack(vma, address))
-+ goto bad_area;
-+/*
-+ * Ok, we have a good vm_area for this memory access, so
-+ * we can handle it..
-+ */
-+good_area:
-+ info.si_code = SEGV_ACCERR;
-+ write = 0;
-+ switch (error_code & (PF_PROT|PF_WRITE)) {
-+ default: /* 3: write, present */
-+ /* fall through */
-+ case PF_WRITE: /* write, not present */
-+ if (!(vma->vm_flags & VM_WRITE))
-+ goto bad_area;
-+ write++;
-+ break;
-+ case PF_PROT: /* read, present */
-+ goto bad_area;
-+ case 0: /* read, not present */
-+ if (!(vma->vm_flags & (VM_READ | VM_EXEC | VM_WRITE)))
-+ goto bad_area;
-+ }
-+
-+ /*
-+ * If for any reason at all we couldn't handle the fault,
-+ * make sure we exit gracefully rather than endlessly redo
-+ * the fault.
-+ */
-+ switch (handle_mm_fault(mm, vma, address, write)) {
-+ case VM_FAULT_MINOR:
-+ tsk->min_flt++;
-+ break;
-+ case VM_FAULT_MAJOR:
-+ tsk->maj_flt++;
-+ break;
-+ case VM_FAULT_SIGBUS:
-+ goto do_sigbus;
-+ default:
-+ goto out_of_memory;
-+ }
-+
-+ up_read(&mm->mmap_sem);
-+ return;
-+
-+/*
-+ * Something tried to access memory that isn't in our memory map..
-+ * Fix it, but check if it's kernel or user first..
-+ */
-+bad_area:
-+ up_read(&mm->mmap_sem);
-+
-+bad_area_nosemaphore:
-+ /* User mode accesses just cause a SIGSEGV */
-+ if (error_code & PF_USER) {
-+ if (is_prefetch(regs, address, error_code))
-+ return;
-+
-+ /* Work around K8 erratum #100 K8 in compat mode
-+ occasionally jumps to illegal addresses >4GB. We
-+ catch this here in the page fault handler because
-+ these addresses are not reachable. Just detect this
-+ case and return. Any code segment in LDT is
-+ compatibility mode. */
-+ if ((regs->cs == __USER32_CS || (regs->cs & (1<<2))) &&
-+ (address >> 32))
-+ return;
-+
-+ if (exception_trace && unhandled_signal(tsk, SIGSEGV)) {
-+ printk(
-+ "%s%s[%d]: segfault at %016lx rip %016lx rsp %016lx error %lx\n",
-+ tsk->pid > 1 ? KERN_INFO : KERN_EMERG,
-+ tsk->comm, tsk->pid, address, regs->rip,
-+ regs->rsp, error_code);
-+ }
-+
-+ tsk->thread.cr2 = address;
-+ /* Kernel addresses are always protection faults */
-+ tsk->thread.error_code = error_code | (address >= TASK_SIZE);
-+ tsk->thread.trap_no = 14;
-+ info.si_signo = SIGSEGV;
-+ info.si_errno = 0;
-+ /* info.si_code has been set above */
-+ info.si_addr = (void __user *)address;
-+ force_sig_info(SIGSEGV, &info, tsk);
-+ return;
-+ }
-+
-+no_context:
-+
-+ /* Are we prepared to handle this kernel fault? */
-+ fixup = search_exception_tables(regs->rip);
-+ if (fixup) {
-+ regs->rip = fixup->fixup;
-+ return;
-+ }
-+
-+ /*
-+ * Hall of shame of CPU/BIOS bugs.
-+ */
-+
-+ if (is_prefetch(regs, address, error_code))
-+ return;
-+
-+ if (is_errata93(regs, address))
-+ return;
-+
-+/*
-+ * Oops. The kernel tried to access some bad page. We'll have to
-+ * terminate things with extreme prejudice.
-+ */
-+
-+ flags = oops_begin();
-+
-+ if (address < PAGE_SIZE)
-+ printk(KERN_ALERT "Unable to handle kernel NULL pointer dereference");
-+ else
-+ printk(KERN_ALERT "Unable to handle kernel paging request");
-+ printk(" at %016lx RIP: \n" KERN_ALERT,address);
-+ printk_address(regs->rip);
-+ dump_pagetable(address);
-+ tsk->thread.cr2 = address;
-+ tsk->thread.trap_no = 14;
-+ tsk->thread.error_code = error_code;
-+ __die("Oops", regs, error_code);
-+ /* Executive summary in case the body of the oops scrolled away */
-+ printk(KERN_EMERG "CR2: %016lx\n", address);
-+ oops_end(flags);
-+ do_exit(SIGKILL);
-+
-+/*
-+ * We ran out of memory, or some other thing happened to us that made
-+ * us unable to handle the page fault gracefully.
-+ */
-+out_of_memory:
-+ up_read(&mm->mmap_sem);
-+ if (is_init(current)) {
-+ yield();
-+ goto again;
-+ }
-+ printk("VM: killing process %s\n", tsk->comm);
-+ if (error_code & 4)
-+ do_exit(SIGKILL);
-+ goto no_context;
-+
-+do_sigbus:
-+ up_read(&mm->mmap_sem);
-+
-+ /* Kernel mode? Handle exceptions or die */
-+ if (!(error_code & PF_USER))
-+ goto no_context;
-+
-+ tsk->thread.cr2 = address;
-+ tsk->thread.error_code = error_code;
-+ tsk->thread.trap_no = 14;
-+ info.si_signo = SIGBUS;
-+ info.si_errno = 0;
-+ info.si_code = BUS_ADRERR;
-+ info.si_addr = (void __user *)address;
-+ force_sig_info(SIGBUS, &info, tsk);
-+ return;
-+}
-+
-+DEFINE_SPINLOCK(pgd_lock);
-+struct page *pgd_list;
-+
-+void vmalloc_sync_all(void)
-+{
-+ /* Note that races in the updates of insync and start aren't
-+ problematic:
-+ insync can only get set bits added, and updates to start are only
-+ improving performance (without affecting correctness if undone). */
-+ static DECLARE_BITMAP(insync, PTRS_PER_PGD);
-+ static unsigned long start = VMALLOC_START & PGDIR_MASK;
-+ unsigned long address;
-+
-+ for (address = start; address <= VMALLOC_END; address += PGDIR_SIZE) {
-+ if (!test_bit(pgd_index(address), insync)) {
-+ const pgd_t *pgd_ref = pgd_offset_k(address);
-+ struct page *page;
-+
-+ if (pgd_none(*pgd_ref))
-+ continue;
-+ spin_lock(&pgd_lock);
-+ for (page = pgd_list; page;
-+ page = (struct page *)page->index) {
-+ pgd_t *pgd;
-+ pgd = (pgd_t *)page_address(page) + pgd_index(address);
-+ if (pgd_none(*pgd))
-+ set_pgd(pgd, *pgd_ref);
-+ else
-+ BUG_ON(pgd_page_vaddr(*pgd) != pgd_page_vaddr(*pgd_ref));
-+ }
-+ spin_unlock(&pgd_lock);
-+ set_bit(pgd_index(address), insync);
-+ }
-+ if (address == start)
-+ start = address + PGDIR_SIZE;
-+ }
-+ /* Check that there is no need to do the same for the modules area. */
-+ BUILD_BUG_ON(!(MODULES_VADDR > __START_KERNEL));
-+ BUILD_BUG_ON(!(((MODULES_END - 1) & PGDIR_MASK) ==
-+ (__START_KERNEL & PGDIR_MASK)));
-+}
-+
-+static int __init enable_pagefaulttrace(char *str)
-+{
-+ page_fault_trace = 1;
-+ return 1;
-+}
-+__setup("pagefaulttrace", enable_pagefaulttrace);
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/arch/x86_64/mm/init-xen.c source/arch/x86_64/mm/init-xen.c
---- /scratch/src/linux-2.6.20.3/arch/x86_64/mm/init-xen.c 1970-01-01 01:00:00.000000000 +0100
-+++ source/arch/x86_64/mm/init-xen.c 2007-03-20 21:26:32.000000000 +0100
-@@ -0,0 +1,1183 @@
++#endif
+ if (notify_page_fault(DIE_PAGE_FAULT, "page fault", regs, error_code, 14,
+ SIGSEGV) == NOTIFY_STOP)
+ return;
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 arch/x86_64/mm/init-xen.c
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/arch/x86_64/mm/init-xen.c Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,1205 @@
+/*
+ * linux/arch/x86_64/mm/init.c
+ *
@@ -40119,7 +38512,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+struct dma_mapping_ops* dma_ops;
+EXPORT_SYMBOL(dma_ops);
+
-+#ifdef CONFIG_XEN_COMPAT_030002
++#if CONFIG_XEN_COMPAT <= 0x030002
+unsigned int __kernel_page_user;
+EXPORT_SYMBOL(__kernel_page_user);
+#endif
@@ -40142,7 +38535,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ (((mfn_to_pfn((addr) >> PAGE_SHIFT)) << PAGE_SHIFT) + \
+ __START_KERNEL_map)))
+
-+static void early_make_page_readonly(void *va, unsigned int feature)
++static void __meminit early_make_page_readonly(void *va, unsigned int feature)
+{
+ unsigned long addr, _va = (unsigned long)va;
+ pte_t pte, *ptep;
@@ -40167,14 +38560,11 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ BUG();
+}
+
-+void make_page_readonly(void *va, unsigned int feature)
++static void __make_page_readonly(void *va)
+{
+ pgd_t *pgd; pud_t *pud; pmd_t *pmd; pte_t pte, *ptep;
+ unsigned long addr = (unsigned long) va;
+
-+ if (xen_feature(feature))
-+ return;
-+
+ pgd = pgd_offset_k(addr);
+ pud = pud_offset(pgd, addr);
+ pmd = pmd_offset(pud, addr);
@@ -40185,17 +38575,14 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ xen_l1_entry_update(ptep, pte); /* fallback */
+
+ if ((addr >= VMALLOC_START) && (addr < VMALLOC_END))
-+ make_page_readonly(__va(pte_pfn(pte) << PAGE_SHIFT), feature);
++ __make_page_readonly(__va(pte_pfn(pte) << PAGE_SHIFT));
+}
+
-+void make_page_writable(void *va, unsigned int feature)
++static void __make_page_writable(void *va)
+{
+ pgd_t *pgd; pud_t *pud; pmd_t *pmd; pte_t pte, *ptep;
+ unsigned long addr = (unsigned long) va;
+
-+ if (xen_feature(feature))
-+ return;
-+
+ pgd = pgd_offset_k(addr);
+ pud = pud_offset(pgd, addr);
+ pmd = pmd_offset(pud, addr);
@@ -40206,7 +38593,19 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ xen_l1_entry_update(ptep, pte); /* fallback */
+
+ if ((addr >= VMALLOC_START) && (addr < VMALLOC_END))
-+ make_page_writable(__va(pte_pfn(pte) << PAGE_SHIFT), feature);
++ __make_page_writable(__va(pte_pfn(pte) << PAGE_SHIFT));
++}
++
++void make_page_readonly(void *va, unsigned int feature)
++{
++ if (!xen_feature(feature))
++ __make_page_readonly(va);
++}
++
++void make_page_writable(void *va, unsigned int feature)
++{
++ if (!xen_feature(feature))
++ __make_page_writable(va);
+}
+
+void make_pages_readonly(void *va, unsigned nr, unsigned int feature)
@@ -40215,7 +38614,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ return;
+
+ while (nr-- != 0) {
-+ make_page_readonly(va, feature);
++ __make_page_readonly(va);
+ va = (void*)((unsigned long)va + PAGE_SIZE);
+ }
+}
@@ -40226,7 +38625,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ return;
+
+ while (nr-- != 0) {
-+ make_page_writable(va, feature);
++ __make_page_writable(va);
+ va = (void*)((unsigned long)va + PAGE_SIZE);
+ }
+}
@@ -40273,7 +38672,11 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ void *ptr;
+ if (after_bootmem)
+ ptr = (void *) get_zeroed_page(GFP_ATOMIC);
-+ else
++ else if (start_pfn < table_end) {
++ ptr = __va(start_pfn << PAGE_SHIFT);
++ start_pfn++;
++ memset(ptr, 0, PAGE_SIZE);
++ } else
+ ptr = alloc_bootmem_pages(PAGE_SIZE);
+ if (!ptr || ((unsigned long)ptr & ~PAGE_MASK))
+ panic("set_pte_phys: cannot allocate page data %s\n", after_bootmem?"after bootmem":"");
@@ -40344,8 +38747,8 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ __flush_tlb_one(vaddr);
+}
+
-+static void set_pte_phys_ma(unsigned long vaddr,
-+ unsigned long phys, pgprot_t prot)
++static __init void set_pte_phys_ma(unsigned long vaddr,
++ unsigned long phys, pgprot_t prot)
+{
+ pgd_t *pgd;
+ pud_t *pud;
@@ -40364,36 +38767,26 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+
+ pmd = (pmd_t *) spp_getpage();
+ make_page_readonly(pmd, XENFEAT_writable_page_tables);
-+
+ set_pud(pud, __pud(__pa(pmd) | _KERNPG_TABLE | _PAGE_USER));
-+
+ if (pmd != pmd_offset(pud, 0)) {
+ printk("PAGETABLE BUG #01! %p <-> %p\n", pmd, pmd_offset(pud,0));
+ return;
+ }
+ }
+ pmd = pmd_offset(pud, vaddr);
-+
+ if (pmd_none(*pmd)) {
+ pte = (pte_t *) spp_getpage();
+ make_page_readonly(pte, XENFEAT_writable_page_tables);
-+
+ set_pmd(pmd, __pmd(__pa(pte) | _KERNPG_TABLE | _PAGE_USER));
+ if (pte != pte_offset_kernel(pmd, 0)) {
+ printk("PAGETABLE BUG #02!\n");
+ return;
+ }
+ }
-+
+ new_pte = pfn_pte_ma(phys >> PAGE_SHIFT, prot);
-+ pte = pte_offset_kernel(pmd, vaddr);
+
-+ /*
-+ * Note that the pte page is already RO, thus we want to use
-+ * xen_l1_entry_update(), not set_pte().
-+ */
-+ xen_l1_entry_update(pte,
-+ pfn_pte_ma(phys >> PAGE_SHIFT, prot));
++ pte = pte_offset_kernel(pmd, vaddr);
++ set_pte(pte, new_pte);
+
+ /*
+ * It's enough to flush this one mapping.
@@ -40416,7 +38809,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ return;
+ }
+ switch (idx) {
-+ case VSYSCALL_FIRST_PAGE:
++ case VSYSCALL_LAST_PAGE ... VSYSCALL_FIRST_PAGE:
+ set_pte_phys(address, phys, prot, SET_FIXMAP_KERNEL);
+ break;
+ default:
@@ -40426,9 +38819,10 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+}
+
+/*
-+ * At this point it only supports vsyscall area.
++ * This only supports vsyscall area.
+ */
-+void __set_fixmap_user (enum fixed_addresses idx, unsigned long phys, pgprot_t prot)
++void __init
++__set_fixmap_user (enum fixed_addresses idx, unsigned long phys, pgprot_t prot)
+{
+ unsigned long address = __fix_to_virt(idx);
+
@@ -40456,15 +38850,6 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+};
+#endif /* !CONFIG_XEN */
+
-+unsigned long get_machine_pfn(unsigned long addr)
-+{
-+ pud_t* pud = pud_offset_k(NULL, addr);
-+ pmd_t* pmd = pmd_offset(pud, addr);
-+ pte_t *pte = pte_offset_kernel(pmd, addr);
-+
-+ return pte_mfn(*pte);
-+}
-+
+static __meminit void *alloc_static_page(unsigned long *phys)
+{
+ unsigned long va = (start_pfn << PAGE_SHIFT) + __START_KERNEL_map;
@@ -40490,6 +38875,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+
+static inline int make_readonly(unsigned long paddr)
+{
++ extern char __vsyscall_0;
+ int readonly = 0;
+
+ /* Make new page tables read-only. */
@@ -40506,9 +38892,12 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ /*
+ * No need for writable mapping of kernel image. This also ensures that
+ * page and descriptor tables embedded inside don't have writable
-+ * mappings.
++ * mappings. Exclude the vsyscall area here, allowing alternative
++ * instruction patching to work.
+ */
-+ if ((paddr >= __pa_symbol(&_text)) && (paddr < __pa_symbol(&_end)))
++ if ((paddr >= __pa_symbol(&_text)) && (paddr < __pa_symbol(&_end))
++ && !(paddr >= __pa_symbol(&__vsyscall_0)
++ && paddr < __pa_symbol(&__vsyscall_0) + PAGE_SIZE))
+ readonly = 1;
+
+ return readonly;
@@ -40627,10 +39016,6 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+{
+ unsigned long addr, *page;
+
-+ memset((void *)init_level4_pgt, 0, PAGE_SIZE);
-+ memset((void *)level3_kernel_pgt, 0, PAGE_SIZE);
-+ memset((void *)level2_kernel_pgt, 0, PAGE_SIZE);
-+
+ /* Find the initial pte page that was built for us. */
+ page = (unsigned long *)xen_start_info->pt_base;
+ addr = page[pgd_index(__START_KERNEL_map)];
@@ -40638,7 +39023,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ addr = page[pud_index(__START_KERNEL_map)];
+ addr_to_page(addr, page);
+
-+#ifdef CONFIG_XEN_COMPAT_030002
++#if CONFIG_XEN_COMPAT <= 0x030002
+ /* On Xen 3.0.2 and older we may need to explicitly specify _PAGE_USER
+ in kernel PTEs. We check that here. */
+ if (HYPERVISOR_xen_version(XENVER_version, NULL) <= 0x30000) {
@@ -40684,14 +39069,16 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ early_make_page_readonly(level2_kernel_pgt,
+ XENFEAT_writable_page_tables);
+
-+ xen_pgd_pin(__pa_symbol(init_level4_pgt));
-+ xen_pgd_pin(__pa_symbol(init_level4_user_pgt));
++ if (!xen_feature(XENFEAT_writable_page_tables)) {
++ xen_pgd_pin(__pa_symbol(init_level4_pgt));
++ xen_pgd_pin(__pa_symbol(init_level4_user_pgt));
++ }
+
+ set_pgd((pgd_t *)(init_level4_user_pgt + 511),
+ mk_kernel_pgd(__pa_symbol(level3_user_pgt)));
+}
+
-+void __init extend_init_mapping(unsigned long tables_space)
++static void __init extend_init_mapping(unsigned long tables_space)
+{
+ unsigned long va = __START_KERNEL_map;
+ unsigned long phys, addr, *pte_page;
@@ -40746,7 +39133,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+
+static void __init find_early_table_space(unsigned long end)
+{
-+ unsigned long puds, pmds, ptes, tables;
++ unsigned long puds, pmds, ptes, tables;
+
+ puds = (end + PUD_SIZE - 1) >> PUD_SHIFT;
+ pmds = (end + PMD_SIZE - 1) >> PMD_SHIFT;
@@ -40763,7 +39150,65 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+
+ early_printk("kernel direct mapping tables up to %lx @ %lx-%lx\n",
+ end, table_start << PAGE_SHIFT,
-+ (table_end << PAGE_SHIFT) + tables);
++ (table_start << PAGE_SHIFT) + tables);
++}
++
++static void xen_finish_init_mapping(void)
++{
++ unsigned long i, start, end;
++
++ /* Re-vector virtual addresses pointing into the initial
++ mapping to the just-established permanent ones. */
++ xen_start_info = __va(__pa(xen_start_info));
++ xen_start_info->pt_base = (unsigned long)
++ __va(__pa(xen_start_info->pt_base));
++ if (!xen_feature(XENFEAT_auto_translated_physmap)) {
++ phys_to_machine_mapping =
++ __va(__pa(xen_start_info->mfn_list));
++ xen_start_info->mfn_list = (unsigned long)
++ phys_to_machine_mapping;
++ }
++ if (xen_start_info->mod_start)
++ xen_start_info->mod_start = (unsigned long)
++ __va(__pa(xen_start_info->mod_start));
++
++ /* Destroy the Xen-created mappings beyond the kernel image as
++ * well as the temporary mappings created above. Prevents
++ * overlap with modules area (if init mapping is very big).
++ */
++ start = PAGE_ALIGN((unsigned long)_end);
++ end = __START_KERNEL_map + (table_end << PAGE_SHIFT);
++ for (; start < end; start += PAGE_SIZE)
++ WARN_ON(HYPERVISOR_update_va_mapping(
++ start, __pte_ma(0), 0));
++
++ /* Allocate pte's for initial fixmaps from 'start_pfn' allocator. */
++ table_end = ~0UL;
++
++ /*
++ * Prefetch pte's for the bt_ioremap() area. It gets used before the
++ * boot-time allocator is online, so allocate-on-demand would fail.
++ */
++ for (i = FIX_BTMAP_END; i <= FIX_BTMAP_BEGIN; i++)
++ __set_fixmap(i, 0, __pgprot(0));
++
++ /* Switch to the real shared_info page, and clear the dummy page. */
++ set_fixmap(FIX_SHARED_INFO, xen_start_info->shared_info);
++ HYPERVISOR_shared_info = (shared_info_t *)fix_to_virt(FIX_SHARED_INFO);
++ memset(empty_zero_page, 0, sizeof(empty_zero_page));
++
++ /* Set up mapping of lowest 1MB of physical memory. */
++ for (i = 0; i < NR_FIX_ISAMAPS; i++)
++ if (is_initial_xendomain())
++ set_fixmap(FIX_ISAMAP_BEGIN - i, i * PAGE_SIZE);
++ else
++ __set_fixmap(FIX_ISAMAP_BEGIN - i,
++ virt_to_mfn(empty_zero_page)
++ << PAGE_SHIFT,
++ PAGE_KERNEL_RO);
++
++ /* Disable the 'start_pfn' allocator. */
++ table_end = start_pfn;
+}
+
+/* Setup the direct mapping of the physical memory at PAGE_OFFSET.
@@ -40771,7 +39216,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ physical memory. To access them they are temporarily mapped. */
+void __meminit init_memory_mapping(unsigned long start, unsigned long end)
+{
-+ unsigned long next;
++ unsigned long next;
+
+ Dprintk("init_memory_mapping\n");
+
@@ -40810,31 +39255,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+
+ if (!after_bootmem) {
+ BUG_ON(start_pfn != table_end);
-+
-+ /* Re-vector virtual addresses pointing into the initial
-+ mapping to the just-established permanent ones. */
-+ xen_start_info = __va(__pa(xen_start_info));
-+ xen_start_info->pt_base = (unsigned long)
-+ __va(__pa(xen_start_info->pt_base));
-+ if (!xen_feature(XENFEAT_auto_translated_physmap)) {
-+ phys_to_machine_mapping =
-+ __va(__pa(xen_start_info->mfn_list));
-+ xen_start_info->mfn_list = (unsigned long)
-+ phys_to_machine_mapping;
-+ }
-+ if (xen_start_info->mod_start)
-+ xen_start_info->mod_start = (unsigned long)
-+ __va(__pa(xen_start_info->mod_start));
-+
-+ /* Destroy the Xen-created mappings beyond the kernel image as
-+ * well as the temporary mappings created above. Prevents
-+ * overlap with modules area (if init mapping is very big).
-+ */
-+ start = PAGE_ALIGN((unsigned long)_end);
-+ end = __START_KERNEL_map + (table_end << PAGE_SHIFT);
-+ for (; start < end; start += PAGE_SIZE)
-+ WARN_ON(HYPERVISOR_update_va_mapping(
-+ start, __pte_ma(0), 0));
++ xen_finish_init_mapping();
+ }
+
+ __flush_tlb_all();
@@ -40851,7 +39272,6 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#ifndef CONFIG_NUMA
+void __init paging_init(void)
+{
-+ int i;
+ unsigned long max_zone_pfns[MAX_NR_ZONES];
+ memset(max_zone_pfns, 0, sizeof(max_zone_pfns));
+ max_zone_pfns[ZONE_DMA] = end_pfn;
@@ -40862,22 +39282,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ sparse_init();
+ free_area_init_nodes(max_zone_pfns);
+
-+ /* Switch to the real shared_info page, and clear the
-+ * dummy page. */
-+ set_fixmap(FIX_SHARED_INFO, xen_start_info->shared_info);
-+ HYPERVISOR_shared_info = (shared_info_t *)fix_to_virt(FIX_SHARED_INFO);
-+ memset(empty_zero_page, 0, sizeof(empty_zero_page));
-+
+ init_mm.context.pinned = 1;
-+
-+ /* Setup mapping of lower 1st MB */
-+ for (i = 0; i < NR_FIX_ISAMAPS; i++)
-+ if (is_initial_xendomain())
-+ set_fixmap(FIX_ISAMAP_BEGIN - i, i * PAGE_SIZE);
-+ else
-+ __set_fixmap(FIX_ISAMAP_BEGIN - i,
-+ virt_to_mfn(empty_zero_page) << PAGE_SHIFT,
-+ PAGE_KERNEL_RO);
+}
+#endif
+
@@ -41080,7 +39485,19 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ ClearPageReserved(virt_to_page(addr));
+ init_page_count(virt_to_page(addr));
+ memset((void *)(addr & ~(PAGE_SIZE-1)),
-+ POISON_FREE_INITMEM, PAGE_SIZE);
++ POISON_FREE_INITMEM, PAGE_SIZE);
++ if (addr >= __START_KERNEL_map) {
++ /* make_readonly() reports all kernel addresses. */
++ __make_page_writable(__va(__pa(addr)));
++ if (HYPERVISOR_update_va_mapping(addr, __pte(0), 0)) {
++ pgd_t *pgd = pgd_offset_k(addr);
++ pud_t *pud = pud_offset(pgd, addr);
++ pmd_t *pmd = pmd_offset(pud, addr);
++ pte_t *pte = pte_offset_kernel(pmd, addr);
++
++ xen_l1_entry_update(pte, __pte(0)); /* fallback */
++ }
++ }
+ free_page(addr);
+ totalram_pages++;
+ }
@@ -41089,12 +39506,10 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+void free_initmem(void)
+{
+ memset(__initdata_begin, POISON_FREE_INITDATA,
-+ __initdata_end - __initdata_begin);
-+#ifdef __DO_LATER__
++ __initdata_end - __initdata_begin);
+ free_init_pages("unused kernel memory",
+ (unsigned long)(&__init_begin),
+ (unsigned long)(&__init_end));
-+#endif
+}
+
+#ifdef CONFIG_DEBUG_RODATA
@@ -41169,7 +39584,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ if (pgd_none(*pgd))
+ return 0;
+
-+ pud = pud_offset_k(pgd, addr);
++ pud = pud_offset(pgd, addr);
+ if (pud_none(*pud))
+ return 0;
+
@@ -41246,30 +39661,14 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+{
+ return (addr >= VSYSCALL_START) && (addr < VSYSCALL_END);
+}
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/arch/x86_64/mm/Makefile source/arch/x86_64/mm/Makefile
---- /scratch/src/linux-2.6.20.3/arch/x86_64/mm/Makefile 2007-02-04 19:44:54.000000000 +0100
-+++ source/arch/x86_64/mm/Makefile 2007-03-20 21:26:32.000000000 +0100
-@@ -9,3 +9,13 @@ obj-$(CONFIG_K8_NUMA) += k8topology.o
- obj-$(CONFIG_ACPI_NUMA) += srat.o
-
- hugetlbpage-y = ../../i386/mm/hugetlbpage.o
-+
-+ifdef CONFIG_XEN
-+include $(srctree)/scripts/Makefile.xen
-+
-+ioremap-y += ../../i386/mm/ioremap-xen.o
-+hypervisor-y += ../../i386/mm/hypervisor.o
-+obj-y += hypervisor.o
-+
-+obj-y := $(call cherrypickxen, $(obj-y))
-+endif
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/arch/x86_64/mm/pageattr.c source/arch/x86_64/mm/pageattr.c
---- /scratch/src/linux-2.6.20.3/arch/x86_64/mm/pageattr.c 2007-02-04 19:44:54.000000000 +0100
-+++ source/arch/x86_64/mm/pageattr.c 2007-03-20 21:26:33.000000000 +0100
-@@ -13,6 +13,167 @@
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 arch/x86_64/mm/pageattr.c
+--- a/arch/x86_64/mm/pageattr.c Wed Jul 18 12:23:24 2007 -0300
++++ b/arch/x86_64/mm/pageattr.c Wed Aug 08 16:25:28 2007 -0300
+@@ -12,6 +12,201 @@
+ #include <asm/processor.h>
#include <asm/tlbflush.h>
#include <asm/io.h>
-
++
+#ifdef CONFIG_XEN
+#include <asm/pgalloc.h>
+#include <asm/mmu_context.h>
@@ -41281,10 +39680,13 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+{
+ struct page *page = virt_to_page(pt);
+ unsigned long pfn = page_to_pfn(page);
++ int rc;
+
-+ BUG_ON(HYPERVISOR_update_va_mapping(
-+ (unsigned long)__va(pfn << PAGE_SHIFT),
-+ pfn_pte(pfn, flags), 0));
++ rc = HYPERVISOR_update_va_mapping(
++ (unsigned long)__va(pfn << PAGE_SHIFT),
++ pfn_pte(pfn, flags), 0);
++ if (rc)
++ BUG();
+}
+
+static void mm_walk(struct mm_struct *mm, pgprot_t flags)
@@ -41333,14 +39735,17 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ spin_lock(&mm->page_table_lock);
+
+ mm_walk(mm, PAGE_KERNEL_RO);
-+ BUG_ON(HYPERVISOR_update_va_mapping(
-+ (unsigned long)mm->pgd,
-+ pfn_pte(virt_to_phys(mm->pgd)>>PAGE_SHIFT, PAGE_KERNEL_RO),
-+ UVMF_TLB_FLUSH));
-+ BUG_ON(HYPERVISOR_update_va_mapping(
-+ (unsigned long)__user_pgd(mm->pgd),
-+ pfn_pte(virt_to_phys(__user_pgd(mm->pgd))>>PAGE_SHIFT, PAGE_KERNEL_RO),
-+ UVMF_TLB_FLUSH));
++ if (HYPERVISOR_update_va_mapping(
++ (unsigned long)mm->pgd,
++ pfn_pte(virt_to_phys(mm->pgd)>>PAGE_SHIFT, PAGE_KERNEL_RO),
++ UVMF_TLB_FLUSH))
++ BUG();
++ if (HYPERVISOR_update_va_mapping(
++ (unsigned long)__user_pgd(mm->pgd),
++ pfn_pte(virt_to_phys(__user_pgd(mm->pgd))>>PAGE_SHIFT,
++ PAGE_KERNEL_RO),
++ UVMF_TLB_FLUSH))
++ BUG();
+ xen_pgd_pin(__pa(mm->pgd)); /* kernel */
+ xen_pgd_pin(__pa(__user_pgd(mm->pgd))); /* user */
+ mm->context.pinned = 1;
@@ -41360,12 +39765,15 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+
+ xen_pgd_unpin(__pa(mm->pgd));
+ xen_pgd_unpin(__pa(__user_pgd(mm->pgd)));
-+ BUG_ON(HYPERVISOR_update_va_mapping(
-+ (unsigned long)mm->pgd,
-+ pfn_pte(virt_to_phys(mm->pgd)>>PAGE_SHIFT, PAGE_KERNEL), 0));
-+ BUG_ON(HYPERVISOR_update_va_mapping(
-+ (unsigned long)__user_pgd(mm->pgd),
-+ pfn_pte(virt_to_phys(__user_pgd(mm->pgd))>>PAGE_SHIFT, PAGE_KERNEL), 0));
++ if (HYPERVISOR_update_va_mapping(
++ (unsigned long)mm->pgd,
++ pfn_pte(virt_to_phys(mm->pgd)>>PAGE_SHIFT, PAGE_KERNEL), 0))
++ BUG();
++ if (HYPERVISOR_update_va_mapping(
++ (unsigned long)__user_pgd(mm->pgd),
++ pfn_pte(virt_to_phys(__user_pgd(mm->pgd))>>PAGE_SHIFT,
++ PAGE_KERNEL), 0))
++ BUG();
+ mm_walk(mm, PAGE_KERNEL);
+ xen_tlb_flush();
+ mm->context.pinned = 0;
@@ -41381,43 +39789,63 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ if (xen_feature(XENFEAT_writable_page_tables))
+ return;
+
++ /*
++ * Allow uninterrupted access to the mm_unpinned list. We don't
++ * actually take the mm_unpinned_lock as it is taken inside mm_pin().
++ * All other CPUs must be at a safe point (e.g., in stop_machine
++ * or offlined entirely).
++ */
++ preempt_disable();
+ while (!list_empty(&mm_unpinned))
+ mm_pin(list_entry(mm_unpinned.next, struct mm_struct,
+ context.unpinned));
++ preempt_enable();
+}
+
+void _arch_dup_mmap(struct mm_struct *mm)
+{
-+ if (!mm->context.pinned)
-+ mm_pin(mm);
++ if (!mm->context.pinned)
++ mm_pin(mm);
+}
+
+void _arch_exit_mmap(struct mm_struct *mm)
+{
-+ struct task_struct *tsk = current;
++ struct task_struct *tsk = current;
+
-+ task_lock(tsk);
++ task_lock(tsk);
+
-+ /*
-+ * We aggressively remove defunct pgd from cr3. We execute unmap_vmas()
-+ * *much* faster this way, as no tlb flushes means bigger wrpt batches.
-+ */
-+ if ( tsk->active_mm == mm )
-+ {
-+ tsk->active_mm = &init_mm;
-+ atomic_inc(&init_mm.mm_count);
++ /*
++ * We aggressively remove defunct pgd from cr3. We execute unmap_vmas()
++ * *much* faster this way, as no tlb flushes means bigger wrpt batches.
++ */
++ if ( tsk->active_mm == mm )
++ {
++ tsk->active_mm = &init_mm;
++ atomic_inc(&init_mm.mm_count);
+
-+ switch_mm(mm, &init_mm, tsk);
++ switch_mm(mm, &init_mm, tsk);
+
-+ atomic_dec(&mm->mm_count);
-+ BUG_ON(atomic_read(&mm->mm_count) == 0);
-+ }
++ atomic_dec(&mm->mm_count);
++ BUG_ON(atomic_read(&mm->mm_count) == 0);
++ }
++
++ task_unlock(tsk);
++
++ if ( mm->context.pinned && (atomic_read(&mm->mm_count) == 1) &&
++ !mm->context.has_foreign_mappings )
++ mm_unpin(mm);
++}
+
-+ task_unlock(tsk);
++struct page *pte_alloc_one(struct mm_struct *mm, unsigned long address)
++{
++ struct page *pte;
+
-+ if ( mm->context.pinned && (atomic_read(&mm->mm_count) == 1) &&
-+ !mm->context.has_foreign_mappings )
-+ mm_unpin(mm);
++ pte = alloc_pages(GFP_KERNEL|__GFP_REPEAT|__GFP_ZERO, 0);
++ if (pte) {
++ SetPageForeign(pte, pte_free);
++ init_page_count(pte);
++ }
++ return pte;
+}
+
+void pte_free(struct page *pte)
@@ -41425,16 +39853,20 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ unsigned long va = (unsigned long)__va(page_to_pfn(pte)<<PAGE_SHIFT);
+
+ if (!pte_write(*virt_to_ptep(va)))
-+ BUG_ON(HYPERVISOR_update_va_mapping(
-+ va, pfn_pte(page_to_pfn(pte), PAGE_KERNEL), 0));
++ if (HYPERVISOR_update_va_mapping(
++ va, pfn_pte(page_to_pfn(pte), PAGE_KERNEL), 0))
++ BUG();
++
++ ClearPageForeign(pte);
++ init_page_count(pte);
++
+ __free_page(pte);
+}
+#endif /* CONFIG_XEN */
-+
+
static inline pte_t *lookup_address(unsigned long address)
{
- pgd_t *pgd = pgd_offset_k(address);
-@@ -154,7 +315,17 @@ __change_page_attr(unsigned long address
+@@ -154,8 +349,18 @@ __change_page_attr(unsigned long address
BUG();
/* on x86-64 the direct mapping set at boot is not using 4k pages */
@@ -41446,15 +39878,17 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ */
+#ifndef CONFIG_XEN
BUG_ON(PageReserved(kpte_page));
+-
+#else
-+ if(!PageReserved(kpte_page))
++ if(PageReserved(kpte_page))
++ return 0;
+#endif
-
if (page_private(kpte_page) == 0) {
save_page(kpte_page);
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/arch/x86_64/oprofile/Makefile source/arch/x86_64/oprofile/Makefile
---- /scratch/src/linux-2.6.20.3/arch/x86_64/oprofile/Makefile 2007-02-04 19:44:54.000000000 +0100
-+++ source/arch/x86_64/oprofile/Makefile 2007-03-20 21:26:33.000000000 +0100
+ revert_page(address, ref_prot);
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 arch/x86_64/oprofile/Makefile
+--- a/arch/x86_64/oprofile/Makefile Wed Jul 18 12:23:24 2007 -0300
++++ b/arch/x86_64/oprofile/Makefile Wed Aug 08 16:25:28 2007 -0300
@@ -11,9 +11,15 @@ DRIVER_OBJS = $(addprefix ../../../drive
oprofilefs.o oprofile_stats.o \
timer_int.o )
@@ -41473,9 +39907,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+endif
+oprofile-y = $(DRIVER_OBJS) $(XENOPROF_COMMON_OBJS) \
+ $(addprefix ../../i386/oprofile/, $(OPROFILE-y))
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/arch/x86_64/pci/Makefile source/arch/x86_64/pci/Makefile
---- /scratch/src/linux-2.6.20.3/arch/x86_64/pci/Makefile 2007-02-04 19:44:54.000000000 +0100
-+++ source/arch/x86_64/pci/Makefile 2007-03-20 21:26:33.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 arch/x86_64/pci/Makefile
+--- a/arch/x86_64/pci/Makefile Wed Jul 18 12:23:24 2007 -0300
++++ b/arch/x86_64/pci/Makefile Wed Aug 08 16:25:28 2007 -0300
@@ -15,8 +15,13 @@ obj-$(CONFIG_PCI_MMCONFIG) += mmconfig.o
obj-$(CONFIG_NUMA) += k8-bus.o
@@ -41490,9 +39924,20 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
legacy-y += ../../i386/pci/legacy.o
irq-y += ../../i386/pci/irq.o
common-y += ../../i386/pci/common.o
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/drivers/acpi/Kconfig source/drivers/acpi/Kconfig
---- /scratch/src/linux-2.6.20.3/drivers/acpi/Kconfig 2007-02-04 19:44:54.000000000 +0100
-+++ source/drivers/acpi/Kconfig 2007-03-20 21:26:33.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 drivers/Makefile
+--- a/drivers/Makefile Wed Jul 18 12:23:24 2007 -0300
++++ b/drivers/Makefile Wed Aug 08 16:25:28 2007 -0300
+@@ -31,6 +31,7 @@ obj-$(CONFIG_NUBUS) += nubus/
+ obj-$(CONFIG_NUBUS) += nubus/
+ obj-$(CONFIG_ATM) += atm/
+ obj-y += macintosh/
++obj-$(CONFIG_XEN) += xen/
+ obj-$(CONFIG_IDE) += ide/
+ obj-$(CONFIG_FC4) += fc4/
+ obj-$(CONFIG_SCSI) += scsi/
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 drivers/acpi/Kconfig
+--- a/drivers/acpi/Kconfig Wed Jul 18 12:23:24 2007 -0300
++++ b/drivers/acpi/Kconfig Wed Aug 08 16:25:28 2007 -0300
@@ -11,7 +11,7 @@ config ACPI
bool "ACPI Support"
depends on IA64 || X86
@@ -41511,7 +39956,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
depends on PM
default y
---help---
-@@ -309,6 +309,7 @@ config ACPI_SYSTEM
+@@ -309,6 +309,7 @@ config X86_PM_TIMER
config X86_PM_TIMER
bool "Power Management Timer Support" if EMBEDDED
depends on X86
@@ -41519,21 +39964,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
default y
help
The Power Management Timer is available on all ACPI-capable,
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/drivers/char/hangcheck-timer.c source/drivers/char/hangcheck-timer.c
---- /scratch/src/linux-2.6.20.3/drivers/char/hangcheck-timer.c 2007-02-04 19:44:54.000000000 +0100
-+++ source/drivers/char/hangcheck-timer.c 2007-03-20 21:26:35.000000000 +0100
-@@ -117,7 +117,7 @@ __setup("hcheck_reboot", hangcheck_parse
- __setup("hcheck_dump_tasks", hangcheck_parse_dump_tasks);
- #endif /* not MODULE */
-
--#if defined(CONFIG_X86_64) || defined(CONFIG_S390)
-+#if defined(CONFIG_X86_64) || defined(CONFIG_S390) || defined(CONFIG_X86_XEN)
- # define HAVE_MONOTONIC
- # define TIMER_FREQ 1000000000ULL
- #elif defined(CONFIG_IA64)
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/drivers/char/mem.c source/drivers/char/mem.c
---- /scratch/src/linux-2.6.20.3/drivers/char/mem.c 2007-02-04 19:44:54.000000000 +0100
-+++ source/drivers/char/mem.c 2007-03-20 21:26:35.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 drivers/char/mem.c
+--- a/drivers/char/mem.c Wed Jul 18 12:23:24 2007 -0300
++++ b/drivers/char/mem.c Wed Aug 08 16:25:28 2007 -0300
@@ -102,6 +102,7 @@ static inline int valid_mmap_phys_addr_r
}
#endif
@@ -41563,28 +39996,18 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
.get_unmapped_area = get_unmapped_area_mem,
};
+#else
-+extern struct file_operations mem_fops;
++extern const struct file_operations mem_fops;
+#endif
static const struct file_operations kmem_fops = {
.llseek = memory_lseek,
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/drivers/char/tpm/Kconfig source/drivers/char/tpm/Kconfig
---- /scratch/src/linux-2.6.20.3/drivers/char/tpm/Kconfig 2007-02-04 19:44:54.000000000 +0100
-+++ source/drivers/char/tpm/Kconfig 2007-03-20 21:26:35.000000000 +0100
-@@ -31,7 +31,7 @@ config TCG_TIS
-
- config TCG_NSC
- tristate "National Semiconductor TPM Interface"
-- depends on TCG_TPM && PNPACPI
-+ depends on TCG_TPM && PNPACPI && !XEN_UNPRIVILEGED_GUEST
- ---help---
- If you have a TPM security chip from National Semicondutor
- say Yes and it will be accessible from within Linux. To
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 drivers/char/tpm/Kconfig
+--- a/drivers/char/tpm/Kconfig Wed Jul 18 12:23:24 2007 -0300
++++ b/drivers/char/tpm/Kconfig Wed Aug 08 16:25:28 2007 -0300
@@ -58,5 +58,13 @@ config TCG_INFINEON
Further information on this driver and the supported hardware
can be found at http://www.prosec.rub.de/tpm
--endmenu
+config TCG_XEN
+ tristate "XEN TPM Interface"
+ depends on TCG_TPM && XEN
@@ -41593,175 +40016,54 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ say Yes and it will be accessible from within Linux.
+ To compile this driver as a module, choose M here; the module
+ will be called tpm_xenu.
-
-+endmenu
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/drivers/char/tpm/Makefile source/drivers/char/tpm/Makefile
---- /scratch/src/linux-2.6.20.3/drivers/char/tpm/Makefile 2007-02-04 19:44:54.000000000 +0100
-+++ source/drivers/char/tpm/Makefile 2007-03-20 21:26:35.000000000 +0100
-@@ -9,3 +9,5 @@ obj-$(CONFIG_TCG_TIS) += tpm_tis.o
++
+ endmenu
+-
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 drivers/char/tpm/Makefile
+--- a/drivers/char/tpm/Makefile Wed Jul 18 12:23:24 2007 -0300
++++ b/drivers/char/tpm/Makefile Wed Aug 08 16:25:28 2007 -0300
+@@ -9,3 +9,5 @@ obj-$(CONFIG_TCG_NSC) += tpm_nsc.o
obj-$(CONFIG_TCG_NSC) += tpm_nsc.o
obj-$(CONFIG_TCG_ATMEL) += tpm_atmel.o
obj-$(CONFIG_TCG_INFINEON) += tpm_infineon.o
+obj-$(CONFIG_TCG_XEN) += tpm_xenu.o
+tpm_xenu-y = tpm_xen.o tpm_vtpm.o
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/drivers/char/tpm/tpm.c source/drivers/char/tpm/tpm.c
---- /scratch/src/linux-2.6.20.3/drivers/char/tpm/tpm.c 2007-02-04 19:44:54.000000000 +0100
-+++ source/drivers/char/tpm/tpm.c 2007-03-20 21:26:35.000000000 +0100
-@@ -30,7 +30,9 @@
-
- enum tpm_const {
- TPM_MINOR = 224, /* officially assigned */
-+#ifndef CONFIG_XEN
- TPM_BUFSIZE = 2048,
-+#endif
- TPM_NUM_DEVICES = 256,
- };
-
-@@ -331,7 +333,11 @@ static void timeout_work(struct work_str
-
- down(&chip->buffer_mutex);
- atomic_set(&chip->data_pending, 0);
-+#ifndef CONFIG_XEN
- memset(chip->data_buffer, 0, TPM_BUFSIZE);
-+#else
-+ memset(chip->data_buffer, 0, get_chip_buffersize(chip));
-+#endif
- up(&chip->buffer_mutex);
- }
-
-@@ -921,7 +927,12 @@ int tpm_open(struct inode *inode, struct
-
- spin_unlock(&driver_lock);
-
-+#ifndef CONFIG_XEN
- chip->data_buffer = kmalloc(TPM_BUFSIZE * sizeof(u8), GFP_KERNEL);
-+#else
-+ chip->data_buffer = kmalloc(get_chip_buffersize(chip) * sizeof(u8),
-+ GFP_KERNEL);
-+#endif
- if (chip->data_buffer == NULL) {
- chip->num_opens--;
- put_device(chip->dev);
-@@ -969,8 +980,13 @@ ssize_t tpm_write(struct file *file, con
-
- down(&chip->buffer_mutex);
-
-+#ifndef CONFIG_XEN
- if (in_size > TPM_BUFSIZE)
- in_size = TPM_BUFSIZE;
-+#else
-+ if (in_size > get_chip_buffersize(chip))
-+ in_size = get_chip_buffersize(chip);
-+#endif
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 drivers/char/tpm/tpm.h
+--- a/drivers/char/tpm/tpm.h Wed Jul 18 12:23:24 2007 -0300
++++ b/drivers/char/tpm/tpm.h Wed Aug 08 16:25:28 2007 -0300
+@@ -106,6 +106,9 @@ struct tpm_chip {
+ struct dentry **bios_dir;
- if (copy_from_user
- (chip->data_buffer, (void __user *) buf, in_size)) {
-@@ -979,9 +995,17 @@ ssize_t tpm_write(struct file *file, con
- }
-
- /* atomic tpm command send and result receive */
-+#ifndef CONFIG_XEN
- out_size = tpm_transmit(chip, chip->data_buffer, TPM_BUFSIZE);
-+#else
-+ out_size = tpm_transmit(chip, chip->data_buffer,
-+ get_chip_buffersize(chip));
-+#endif
-
- atomic_set(&chip->data_pending, out_size);
-+#ifdef CONFIG_XEN
-+ atomic_set(&chip->data_position, 0);
-+#endif
- up(&chip->buffer_mutex);
-
- /* Set a timeout by which the reader must come claim the result */
-@@ -996,21 +1020,52 @@ ssize_t tpm_read(struct file *file, char
- {
- struct tpm_chip *chip = file->private_data;
- int ret_size;
+ struct list_head list;
+#ifdef CONFIG_XEN
-+ int pos, pending = 0;
++ void *priv;
+#endif
+ };
-+#ifndef CONFIG_XEN
- del_singleshot_timer_sync(&chip->user_read_timer);
- flush_scheduled_work();
-+#endif
- ret_size = atomic_read(&chip->data_pending);
-+#ifndef CONFIG_XEN
- atomic_set(&chip->data_pending, 0);
-+#endif
- if (ret_size > 0) { /* relay data */
- if (size < ret_size)
- ret_size = size;
-
-+#ifdef CONFIG_XEN
-+ pos = atomic_read(&chip->data_position);
-+#endif
- down(&chip->buffer_mutex);
-+#ifndef CONFIG_XEN
- if (copy_to_user(buf, chip->data_buffer, ret_size))
-+#else
-+ if (copy_to_user(buf, &chip->data_buffer[pos], ret_size)) {
-+#endif
- ret_size = -EFAULT;
-+#ifdef CONFIG_XEN
-+ } else {
-+ pending = atomic_read(&chip->data_pending) - ret_size;
-+ if ( pending ) {
-+ atomic_set(&chip->data_pending, pending);
-+ atomic_set(&chip->data_position,
-+ pos+ret_size);
-+ }
-+ }
-+#endif
- up(&chip->buffer_mutex);
- }
-
-+#ifdef CONFIG_XEN
-+ if ( ret_size <= 0 || pending == 0 ) {
-+ atomic_set(&chip->data_pending, 0);
-+ del_singleshot_timer_sync(&chip->user_read_timer);
-+ flush_scheduled_work();
-+ }
-+#endif
- return ret_size;
- }
- EXPORT_SYMBOL_GPL(tpm_read);
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/drivers/char/tpm/tpm.h source/drivers/char/tpm/tpm.h
---- /scratch/src/linux-2.6.20.3/drivers/char/tpm/tpm.h 2007-02-04 19:44:54.000000000 +0100
-+++ source/drivers/char/tpm/tpm.h 2007-03-20 21:26:35.000000000 +0100
-@@ -62,6 +62,7 @@ struct tpm_vendor_specific {
- const u8 req_complete_mask;
- const u8 req_complete_val;
- const u8 req_canceled;
-+ u32 buffersize;
- void __iomem *iobase; /* ioremapped address */
- unsigned long base; /* TPM base address */
-
-@@ -95,6 +96,7 @@ struct tpm_chip {
- /* Data passed to and from the tpm via the read/write calls */
- u8 *data_buffer;
- atomic_t data_pending;
-+ atomic_t data_position;
- struct semaphore buffer_mutex;
-
- struct timer_list user_read_timer; /* user needs to claim result */
-@@ -122,6 +124,11 @@ static inline void tpm_write_index(int b
+ #define to_tpm_chip(n) container_of(n, struct tpm_chip, vendor)
+@@ -121,6 +124,18 @@ static inline void tpm_write_index(int b
+ outb(index, base);
outb(value & 0xFF, base+1);
}
-
-+static inline u32 get_chip_buffersize(struct tpm_chip *chip)
++
++#ifdef CONFIG_XEN
++static inline void *chip_get_private(const struct tpm_chip *chip)
+{
-+ return chip->vendor.buffersize;
++ return chip->priv;
+}
+
++static inline void chip_set_private(struct tpm_chip *chip, void *priv)
++{
++ chip->priv = priv;
++}
++#endif
+
extern void tpm_get_timeouts(struct tpm_chip *);
extern void tpm_gen_interrupt(struct tpm_chip *);
- extern void tpm_continue_selftest(struct tpm_chip *);
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/drivers/char/tpm/tpm_vtpm.c source/drivers/char/tpm/tpm_vtpm.c
---- /scratch/src/linux-2.6.20.3/drivers/char/tpm/tpm_vtpm.c 1970-01-01 01:00:00.000000000 +0100
-+++ source/drivers/char/tpm/tpm_vtpm.c 2007-03-20 21:26:35.000000000 +0100
-@@ -0,0 +1,547 @@
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 drivers/char/tpm/tpm_vtpm.c
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/drivers/char/tpm/tpm_vtpm.c Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,542 @@
+/*
+ * Copyright (C) 2006 IBM Corporation
+ *
@@ -42268,7 +40570,6 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+};
+
+struct tpm_chip *init_vtpm(struct device *dev,
-+ struct tpm_virtual_device *tvd,
+ struct tpm_private *tp)
+{
+ long rc;
@@ -42280,12 +40581,8 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ return ERR_PTR(-ENOMEM);
+
+ vtpm_state_init(vtpms);
-+ vtpms->tpmvd = tvd;
+ vtpms->tpm_private = tp;
+
-+ if (tvd)
-+ tpm_vtpm.buffersize = tvd->max_tx_size;
-+
+ chip = tpm_register_hardware(dev, &tpm_vtpm);
+ if (!chip) {
+ rc = -ENODEV;
@@ -42309,26 +40606,16 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ tpm_remove_hardware(dev);
+ kfree(vtpms);
+}
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/drivers/char/tpm/tpm_vtpm.h source/drivers/char/tpm/tpm_vtpm.h
---- /scratch/src/linux-2.6.20.3/drivers/char/tpm/tpm_vtpm.h 1970-01-01 01:00:00.000000000 +0100
-+++ source/drivers/char/tpm/tpm_vtpm.h 2007-03-20 21:26:35.000000000 +0100
-@@ -0,0 +1,68 @@
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 drivers/char/tpm/tpm_vtpm.h
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/drivers/char/tpm/tpm_vtpm.h Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,55 @@
+#ifndef TPM_VTPM_H
+#define TPM_VTPM_H
+
+struct tpm_chip;
+struct tpm_private;
+
-+struct tpm_virtual_device {
-+ /*
-+ * This field indicates the maximum size the driver can
-+ * transfer in one chunk. It is filled in by the front-end
-+ * driver and should be propagated to the generic tpm driver
-+ * for allocation of buffers.
-+ */
-+ unsigned int max_tx_size;
-+};
-+
+struct vtpm_state {
+ struct transmission *current_request;
+ spinlock_t req_list_lock;
@@ -42345,8 +40632,6 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+
+ unsigned long disconnect_time;
+
-+ struct tpm_virtual_device *tpmvd;
-+
+ /*
+ * The following is a private structure of the underlying
+ * driver. It is passed as parameter in the send function.
@@ -42366,7 +40651,6 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+
+/* these functions are offered by tpm_vtpm.c */
+struct tpm_chip *init_vtpm(struct device *,
-+ struct tpm_virtual_device *,
+ struct tpm_private *);
+void cleanup_vtpm(struct device *);
+int vtpm_vd_recv(const struct tpm_chip* chip,
@@ -42381,10 +40665,10 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+}
+
+#endif
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/drivers/char/tpm/tpm_xen.c source/drivers/char/tpm/tpm_xen.c
---- /scratch/src/linux-2.6.20.3/drivers/char/tpm/tpm_xen.c 1970-01-01 01:00:00.000000000 +0100
-+++ source/drivers/char/tpm/tpm_xen.c 2007-03-20 21:26:35.000000000 +0100
-@@ -0,0 +1,760 @@
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 drivers/char/tpm/tpm_xen.c
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/drivers/char/tpm/tpm_xen.c Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,720 @@
+/*
+ * Copyright (c) 2005, IBM Corporation
+ *
@@ -42441,7 +40725,6 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+
+ tpmif_tx_interface_t *tx;
+ atomic_t refcnt;
-+ unsigned int evtchn;
+ unsigned int irq;
+ u8 is_connected;
+ u8 is_suspended;
@@ -42501,14 +40784,13 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+
+
+static inline int
-+tx_buffer_copy(struct tx_buffer *txb, const u8 * src, int len,
++tx_buffer_copy(struct tx_buffer *txb, const u8 *src, int len,
+ int isuserbuffer)
+{
+ int copied = len;
+
-+ if (len > txb->size) {
++ if (len > txb->size)
+ copied = txb->size;
-+ }
+ if (isuserbuffer) {
+ if (copy_from_user(txb->data, src, copied))
+ return -EFAULT;
@@ -42521,18 +40803,20 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+
+static inline struct tx_buffer *tx_buffer_alloc(void)
+{
-+ struct tx_buffer *txb = kzalloc(sizeof (struct tx_buffer),
-+ GFP_KERNEL);
++ struct tx_buffer *txb;
+
-+ if (txb) {
-+ txb->len = 0;
-+ txb->size = PAGE_SIZE;
-+ txb->data = (unsigned char *)__get_free_page(GFP_KERNEL);
-+ if (txb->data == NULL) {
-+ kfree(txb);
-+ txb = NULL;
-+ }
++ txb = kzalloc(sizeof(struct tx_buffer), GFP_KERNEL);
++ if (!txb)
++ return NULL;
++
++ txb->len = 0;
++ txb->size = PAGE_SIZE;
++ txb->data = (unsigned char *)__get_free_page(GFP_KERNEL);
++ if (txb->data == NULL) {
++ kfree(txb);
++ txb = NULL;
+ }
++
+ return txb;
+}
+
@@ -42548,37 +40832,41 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+/**************************************************************
+ Utility function for the tpm_private structure
+**************************************************************/
-+static inline void tpm_private_init(struct tpm_private *tp)
++static void tpm_private_init(struct tpm_private *tp)
+{
+ spin_lock_init(&tp->tx_lock);
+ init_waitqueue_head(&tp->wait_q);
+ atomic_set(&tp->refcnt, 1);
+}
+
-+static inline void tpm_private_put(void)
++static void tpm_private_put(void)
+{
-+ if ( atomic_dec_and_test(&my_priv->refcnt)) {
-+ tpmif_free_tx_buffers(my_priv);
-+ kfree(my_priv);
-+ my_priv = NULL;
-+ }
++ if (!atomic_dec_and_test(&my_priv->refcnt))
++ return;
++
++ tpmif_free_tx_buffers(my_priv);
++ kfree(my_priv);
++ my_priv = NULL;
+}
+
+static struct tpm_private *tpm_private_get(void)
+{
+ int err;
-+ if (!my_priv) {
-+ my_priv = kzalloc(sizeof(struct tpm_private), GFP_KERNEL);
-+ if (my_priv) {
-+ tpm_private_init(my_priv);
-+ err = tpmif_allocate_tx_buffers(my_priv);
-+ if (err < 0) {
-+ tpm_private_put();
-+ }
-+ }
-+ } else {
++
++ if (my_priv) {
+ atomic_inc(&my_priv->refcnt);
++ return my_priv;
+ }
++
++ my_priv = kzalloc(sizeof(struct tpm_private), GFP_KERNEL);
++ if (!my_priv)
++ return NULL;
++
++ tpm_private_init(my_priv);
++ err = tpmif_allocate_tx_buffers(my_priv);
++ if (err < 0)
++ tpm_private_put();
++
+ return my_priv;
+}
+
@@ -42658,7 +40946,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ if (tp->irq)
+ unbind_from_irqhandler(tp->irq, tp);
+
-+ tp->evtchn = tp->irq = 0;
++ tp->irq = 0;
+}
+
+
@@ -42689,8 +40977,8 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ goto abort_transaction;
+ }
+
-+ err = xenbus_printf(xbt, dev->nodename,
-+ "event-channel", "%u", tp->evtchn);
++ err = xenbus_printf(xbt, dev->nodename, "event-channel", "%u",
++ irq_to_evtchn_port(tp->irq));
+ if (err) {
+ message = "writing event-channel";
+ goto abort_transaction;
@@ -42752,10 +41040,6 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ }
+}
+
-+struct tpm_virtual_device tvd = {
-+ .max_tx_size = PAGE_SIZE * TPMIF_TX_RING_SIZE,
-+};
-+
+static int tpmfront_probe(struct xenbus_device *dev,
+ const struct xenbus_device_id *id)
+{
@@ -42766,11 +41050,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ if (!tp)
+ return -ENOMEM;
+
-+ tp->chip = init_vtpm(&dev->dev, &tvd, tp);
-+
-+ if (IS_ERR(tp->chip)) {
++ tp->chip = init_vtpm(&dev->dev, tp);
++ if (IS_ERR(tp->chip))
+ return PTR_ERR(tp->chip);
-+ }
+
+ err = xenbus_scanf(XBT_NIL, dev->nodename,
+ "handle", "%i", &handle);
@@ -42789,6 +41071,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ tpm_private_put();
+ return err;
+ }
++
+ return 0;
+}
+
@@ -42805,32 +41088,36 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+{
+ struct tpm_private *tp = tpm_private_from_dev(&dev->dev);
+ u32 ctr;
-+ /* lock, so no app can send */
++
++ /* Take the lock, preventing any application from sending. */
+ mutex_lock(&suspend_lock);
+ tp->is_suspended = 1;
+
-+ for (ctr = 0; atomic_read(&tp->tx_busy) && ctr <= 300; ctr++) {
++ for (ctr = 0; atomic_read(&tp->tx_busy); ctr++) {
+ if ((ctr % 10) == 0)
+ printk("TPM-FE [INFO]: Waiting for outstanding "
+ "request.\n");
-+ /*
-+ * Wait for a request to be responded to.
-+ */
++ /* Wait for a request to be responded to. */
+ interruptible_sleep_on_timeout(&tp->wait_q, 100);
+ }
-+ xenbus_switch_state(dev, XenbusStateClosing);
+
-+ if (atomic_read(&tp->tx_busy)) {
-+ /*
-+ * A temporary work-around.
-+ */
-+ printk("TPM-FE [WARNING]: Resetting busy flag.");
-+ atomic_set(&tp->tx_busy, 0);
-+ }
++ return 0;
++}
+
++static int tpmfront_suspend_finish(struct tpm_private *tp)
++{
++ tp->is_suspended = 0;
++ /* Allow applications to send again. */
++ mutex_unlock(&suspend_lock);
+ return 0;
+}
+
++static int tpmfront_suspend_cancel(struct xenbus_device *dev)
++{
++ struct tpm_private *tp = tpm_private_from_dev(&dev->dev);
++ return tpmfront_suspend_finish(tp);
++}
++
+static int tpmfront_resume(struct xenbus_device *dev)
+{
+ struct tpm_private *tp = tpm_private_from_dev(&dev->dev);
@@ -42846,19 +41133,15 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+
+ tp->backend_id = domid;
+
-+ err = xenbus_alloc_evtchn(dev, &tp->evtchn);
-+ if (err)
-+ return err;
-+
-+ err = bind_evtchn_to_irqhandler(tp->evtchn,
-+ tpmif_int, SA_SAMPLE_RANDOM, "tpmif",
-+ tp);
++ err = bind_listening_port_to_irqhandler(
++ domid, tpmif_int, SA_SAMPLE_RANDOM, "tpmif", tp);
+ if (err <= 0) {
-+ WPRINTK("bind_evtchn_to_irqhandler failed (err=%d)\n", err);
++ WPRINTK("bind_listening_port_to_irqhandler failed "
++ "(err=%d)\n", err);
+ return err;
+ }
-+
+ tp->irq = err;
++
+ return 0;
+}
+
@@ -42876,6 +41159,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ .resume = tpmfront_resume,
+ .otherend_changed = backend_changed,
+ .suspend = tpmfront_suspend,
++ .suspend_cancel = tpmfront_suspend_cancel,
+};
+
+static void __init init_tpm_xenbus(void)
@@ -42883,11 +41167,6 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ xenbus_register_frontend(&tpmfront);
+}
+
-+static void __exit exit_tpm_xenbus(void)
-+{
-+ xenbus_unregister_driver(&tpmfront);
-+}
-+
+static int tpmif_allocate_tx_buffers(struct tpm_private *tp)
+{
+ unsigned int i;
@@ -42906,21 +41185,18 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+{
+ unsigned int i;
+
-+ for (i = 0; i < TPMIF_TX_RING_SIZE; i++) {
++ for (i = 0; i < TPMIF_TX_RING_SIZE; i++)
+ tx_buffer_free(tp->tx_buffers[i]);
-+ }
+}
+
+static void tpmif_rx_action(unsigned long priv)
+{
+ struct tpm_private *tp = (struct tpm_private *)priv;
-+
+ int i = 0;
+ unsigned int received;
+ unsigned int offset = 0;
+ u8 *buffer;
-+ tpmif_tx_request_t *tx;
-+ tx = &tp->tx->ring[i].req;
++ tpmif_tx_request_t *tx = &tp->tx->ring[i].req;
+
+ atomic_set(&tp->tx_busy, 0);
+ wake_up_interruptible(&tp->wait_q);
@@ -42928,9 +41204,8 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ received = tx->size;
+
+ buffer = kmalloc(received, GFP_ATOMIC);
-+ if (NULL == buffer) {
-+ goto exit;
-+ }
++ if (!buffer)
++ return;
+
+ for (i = 0; i < TPMIF_TX_RING_SIZE && offset < received; i++) {
+ struct tx_buffer *txb = tp->tx_buffers[i];
@@ -42939,9 +41214,8 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+
+ tx = &tp->tx->ring[i].req;
+ tocopy = tx->size;
-+ if (tocopy > PAGE_SIZE) {
++ if (tocopy > PAGE_SIZE)
+ tocopy = PAGE_SIZE;
-+ }
+
+ memcpy(&buffer[offset], txb->data, tocopy);
+
@@ -42952,10 +41226,6 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+
+ vtpm_vd_recv(tp->chip, buffer, received, tp->tx_remember);
+ kfree(buffer);
-+
-+exit:
-+
-+ return;
+}
+
+
@@ -42999,12 +41269,13 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ struct tx_buffer *txb = tp->tx_buffers[i];
+ int copied;
+
-+ if (NULL == txb) {
++ if (!txb) {
+ DPRINTK("txb (i=%d) is NULL. buffers initilized?\n"
+ "Not transmitting anything!\n", i);
+ spin_unlock_irq(&tp->tx_lock);
+ return -EFAULT;
+ }
++
+ copied = tx_buffer_copy(txb, &buf[offset], count,
+ isuserbuffer);
+ if (copied < 0) {
@@ -43016,25 +41287,26 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ offset += copied;
+
+ tx = &tp->tx->ring[i].req;
-+
+ tx->addr = virt_to_machine(txb->data);
+ tx->size = txb->len;
+
-+ DPRINTK("First 4 characters sent by TPM-FE are 0x%02x 0x%02x 0x%02x 0x%02x\n",
++ DPRINTK("First 4 characters sent by TPM-FE are "
++ "0x%02x 0x%02x 0x%02x 0x%02x\n",
+ txb->data[0],txb->data[1],txb->data[2],txb->data[3]);
+
-+ /* get the granttable reference for this page */
++ /* Get the granttable reference for this page. */
+ tx->ref = gnttab_claim_grant_reference(&gref_head);
-+
-+ if (-ENOSPC == tx->ref) {
++ if (tx->ref == -ENOSPC) {
+ spin_unlock_irq(&tp->tx_lock);
-+ DPRINTK(" Grant table claim reference failed in func:%s line:%d file:%s\n", __FUNCTION__, __LINE__, __FILE__);
++ DPRINTK("Grant table claim reference failed in "
++ "func:%s line:%d file:%s\n",
++ __FUNCTION__, __LINE__, __FILE__);
+ return -ENOSPC;
+ }
-+ gnttab_grant_foreign_access_ref( tx->ref,
-+ tp->backend_id,
-+ (tx->addr >> PAGE_SHIFT),
-+ 0 /*RW*/);
++ gnttab_grant_foreign_access_ref(tx->ref,
++ tp->backend_id,
++ virt_to_mfn(txb->data),
++ 0 /*RW*/);
+ wmb();
+ }
+
@@ -43043,9 +41315,6 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+
+ mb();
+
-+ DPRINTK("Notifying backend via event channel %d\n",
-+ tp->evtchn);
-+
+ notify_remote_via_irq(tp->irq);
+
+ spin_unlock_irq(&tp->tx_lock);
@@ -43055,15 +41324,10 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+
+static void tpmif_notify_upperlayer(struct tpm_private *tp)
+{
-+ /*
-+ * Notify upper layer about the state of the connection
-+ * to the BE.
-+ */
-+ if (tp->is_connected) {
-+ vtpm_vd_status(tp->chip, TPM_VD_STATUS_CONNECTED);
-+ } else {
-+ vtpm_vd_status(tp->chip, TPM_VD_STATUS_DISCONNECTED);
-+ }
++ /* Notify upper layer about the state of the connection to the BE. */
++ vtpm_vd_status(tp->chip, (tp->is_connected
++ ? TPM_VD_STATUS_CONNECTED
++ : TPM_VD_STATUS_DISCONNECTED));
+}
+
+
@@ -43074,20 +41338,16 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ * should disconnect - assumption is that we will resume
+ * The mutex keeps apps from sending.
+ */
-+ if (is_connected == 0 && tp->is_suspended == 1) {
++ if (is_connected == 0 && tp->is_suspended == 1)
+ return;
-+ }
+
+ /*
+ * Unlock the mutex if we are connected again
+ * after being suspended - now resuming.
+ * This also removes the suspend state.
+ */
-+ if (is_connected == 1 && tp->is_suspended == 1) {
-+ tp->is_suspended = 0;
-+ /* unlock, so apps can resume sending */
-+ mutex_unlock(&suspend_lock);
-+ }
++ if (is_connected == 1 && tp->is_suspended == 1)
++ tpmfront_suspend_finish(tp);
+
+ if (is_connected != tp->is_connected) {
+ tp->is_connected = is_connected;
@@ -43105,61 +41365,44 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+
+static int __init tpmif_init(void)
+{
-+ long rc = 0;
+ struct tpm_private *tp;
+
+ if (is_initial_xendomain())
+ return -EPERM;
+
+ tp = tpm_private_get();
-+ if (!tp) {
-+ rc = -ENOMEM;
-+ goto failexit;
-+ }
++ if (!tp)
++ return -ENOMEM;
+
+ IPRINTK("Initialising the vTPM driver.\n");
-+ if ( gnttab_alloc_grant_references ( TPMIF_TX_RING_SIZE,
-+ &gref_head ) < 0) {
-+ rc = -EFAULT;
-+ goto gnttab_alloc_failed;
++ if (gnttab_alloc_grant_references(TPMIF_TX_RING_SIZE,
++ &gref_head) < 0) {
++ tpm_private_put();
++ return -EFAULT;
+ }
+
+ init_tpm_xenbus();
+ return 0;
-+
-+gnttab_alloc_failed:
-+ tpm_private_put();
-+failexit:
-+
-+ return (int)rc;
+}
+
+
-+void __exit tpmif_exit(void)
-+{
-+ exit_tpm_xenbus();
-+ tpm_private_put();
-+ gnttab_free_grant_references(gref_head);
-+}
-+
+module_init(tpmif_init);
+
+MODULE_LICENSE("Dual BSD/GPL");
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/drivers/firmware/Kconfig source/drivers/firmware/Kconfig
---- /scratch/src/linux-2.6.20.3/drivers/firmware/Kconfig 2007-02-04 19:44:54.000000000 +0100
-+++ source/drivers/firmware/Kconfig 2007-03-20 21:26:36.000000000 +0100
-@@ -7,7 +7,7 @@ menu "Firmware Drivers"
-
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 drivers/firmware/Kconfig
+--- a/drivers/firmware/Kconfig Wed Jul 18 12:23:24 2007 -0300
++++ b/drivers/firmware/Kconfig Wed Aug 08 16:25:28 2007 -0300
+@@ -8,6 +8,7 @@ config EDD
config EDD
tristate "BIOS Enhanced Disk Drive calls determine boot disk"
-- depends on !IA64
-+ depends on !IA64 && !XEN
+ depends on !IA64
++ depends on !XEN
help
Say Y or M here if you want to enable BIOS Enhanced Disk Drive
Services real mode BIOS calls to determine which disk
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/drivers/ide/ide-lib.c source/drivers/ide/ide-lib.c
---- /scratch/src/linux-2.6.20.3/drivers/ide/ide-lib.c 2007-02-04 19:44:54.000000000 +0100
-+++ source/drivers/ide/ide-lib.c 2007-03-20 21:26:36.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 drivers/ide/ide-lib.c
+--- a/drivers/ide/ide-lib.c Wed Jul 18 12:23:24 2007 -0300
++++ b/drivers/ide/ide-lib.c Wed Aug 08 16:25:28 2007 -0300
@@ -429,10 +429,10 @@ void ide_toggle_bounce(ide_drive_t *driv
{
u64 addr = BLK_BOUNCE_HIGH; /* dma64_addr_t */
@@ -43175,43 +41418,36 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
addr = HWIF(drive)->pci_dev->dma_mask;
}
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/drivers/Makefile source/drivers/Makefile
---- /scratch/src/linux-2.6.20.3/drivers/Makefile 2007-03-20 21:30:35.000000000 +0100
-+++ source/drivers/Makefile 2007-03-20 21:34:58.000000000 +0100
-@@ -31,6 +31,7 @@ obj-y += base/ block/ misc/ mfd/ net/
- obj-$(CONFIG_NUBUS) += nubus/
- obj-$(CONFIG_ATM) += atm/
- obj-y += macintosh/
-+obj-$(CONFIG_XEN) += xen/
- obj-$(CONFIG_IDE) += ide/
- obj-$(CONFIG_FC4) += fc4/
- obj-$(CONFIG_SCSI) += scsi/
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/drivers/oprofile/buffer_sync.c source/drivers/oprofile/buffer_sync.c
---- /scratch/src/linux-2.6.20.3/drivers/oprofile/buffer_sync.c 2007-02-04 19:44:54.000000000 +0100
-+++ source/drivers/oprofile/buffer_sync.c 2007-03-20 21:26:43.000000000 +0100
-@@ -6,6 +6,10 @@
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 drivers/oprofile/buffer_sync.c
+--- a/drivers/oprofile/buffer_sync.c Wed Jul 18 12:23:24 2007 -0300
++++ b/drivers/oprofile/buffer_sync.c Wed Aug 08 16:25:28 2007 -0300
+@@ -5,6 +5,10 @@
+ * @remark Read the file COPYING
*
* @author John Levon <levon@movementarian.org>
- *
++ *
+ * Modified by Aravind Menon for Xen
+ * These modifications are:
+ * Copyright (C) 2005 Hewlett-Packard Co.
-+ *
+ *
* This is the core of the buffer management. Each
* CPU buffer is processed and entered into the
- * global event buffer. Such processing is necessary
@@ -275,15 +279,31 @@ static void add_cpu_switch(int i)
last_cookie = INVALID_COOKIE;
}
-static void add_kernel_ctx_switch(unsigned int in_kernel)
-+static void add_cpu_mode_switch(unsigned int cpu_mode)
- {
- add_event_entry(ESCAPE_CODE);
+-{
+- add_event_entry(ESCAPE_CODE);
- if (in_kernel)
- add_event_entry(KERNEL_ENTER_SWITCH_CODE);
- else
- add_event_entry(KERNEL_EXIT_SWITCH_CODE);
+-}
+-
++static void add_cpu_mode_switch(unsigned int cpu_mode)
++{
++ add_event_entry(ESCAPE_CODE);
+ switch (cpu_mode) {
+ case CPU_MODE_USER:
+ add_event_entry(USER_ENTER_SWITCH_CODE);
@@ -43225,8 +41461,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ default:
+ break;
+ }
- }
--
++}
+
+static void add_domain_switch(unsigned long domain_id)
+{
@@ -43243,9 +41478,10 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
*/
static int
-add_sample(struct mm_struct * mm, struct op_sample * s, int in_kernel)
-+add_sample(struct mm_struct * mm, struct op_sample * s, int cpu_mode)
- {
+-{
- if (in_kernel) {
++add_sample(struct mm_struct * mm, struct op_sample * s, int cpu_mode)
++{
+ if (cpu_mode >= CPU_MODE_KERNEL) {
add_sample_entry(s->eip, s->event);
return 1;
@@ -43309,20 +41545,20 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
}
}
}
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/drivers/oprofile/cpu_buffer.c source/drivers/oprofile/cpu_buffer.c
---- /scratch/src/linux-2.6.20.3/drivers/oprofile/cpu_buffer.c 2007-02-04 19:44:54.000000000 +0100
-+++ source/drivers/oprofile/cpu_buffer.c 2007-03-20 21:26:43.000000000 +0100
-@@ -6,6 +6,10 @@
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 drivers/oprofile/cpu_buffer.c
+--- a/drivers/oprofile/cpu_buffer.c Wed Jul 18 12:23:24 2007 -0300
++++ b/drivers/oprofile/cpu_buffer.c Wed Aug 08 16:25:28 2007 -0300
+@@ -5,6 +5,10 @@
+ * @remark Read the file COPYING
*
* @author John Levon <levon@movementarian.org>
- *
++ *
+ * Modified by Aravind Menon for Xen
+ * These modifications are:
+ * Copyright (C) 2005 Hewlett-Packard Co.
-+ *
+ *
* Each CPU has a local buffer that stores PC value/event
* pairs. We also log context switches when we notice them.
- * Eventually each CPU's buffer is processed into the global
@@ -34,6 +38,8 @@ static void wq_sync_buffer(struct work_s
#define DEFAULT_TIMER_EXPIRE (HZ / 10)
static int work_enabled;
@@ -43381,11 +41617,12 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
- if (cpu_buf->last_is_kernel != is_kernel) {
- cpu_buf->last_is_kernel = is_kernel;
- add_code(cpu_buf, is_kernel);
+- }
+-
+ if (cpu_buf->last_cpu_mode != cpu_mode) {
+ cpu_buf->last_cpu_mode = cpu_mode;
+ add_code(cpu_buf, cpu_mode);
- }
--
++ }
+
/* notice a task switch */
- if (cpu_buf->last_task != task) {
@@ -43421,9 +41658,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
/*
* This serves to avoid cpu buffer overflow, and makes sure
* the task mortuary progresses
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/drivers/oprofile/cpu_buffer.h source/drivers/oprofile/cpu_buffer.h
---- /scratch/src/linux-2.6.20.3/drivers/oprofile/cpu_buffer.h 2007-02-04 19:44:54.000000000 +0100
-+++ source/drivers/oprofile/cpu_buffer.h 2007-03-20 21:26:43.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 drivers/oprofile/cpu_buffer.h
+--- a/drivers/oprofile/cpu_buffer.h Wed Jul 18 12:23:24 2007 -0300
++++ b/drivers/oprofile/cpu_buffer.h Wed Aug 08 16:25:28 2007 -0300
@@ -36,7 +36,7 @@ struct oprofile_cpu_buffer {
volatile unsigned long tail_pos;
unsigned long buffer_size;
@@ -43433,7 +41670,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
int tracing;
struct op_sample * buffer;
unsigned long sample_received;
-@@ -51,7 +51,10 @@ extern struct oprofile_cpu_buffer cpu_bu
+@@ -51,7 +51,10 @@ void cpu_buffer_reset(struct oprofile_cp
void cpu_buffer_reset(struct oprofile_cpu_buffer * cpu_buf);
/* transient events for the CPU buffer -> event buffer */
@@ -43446,10 +41683,10 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#define CPU_DOMAIN_SWITCH 4
#endif /* OPROFILE_CPU_BUFFER_H */
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/drivers/oprofile/event_buffer.h source/drivers/oprofile/event_buffer.h
---- /scratch/src/linux-2.6.20.3/drivers/oprofile/event_buffer.h 2007-02-04 19:44:54.000000000 +0100
-+++ source/drivers/oprofile/event_buffer.h 2007-03-20 21:26:43.000000000 +0100
-@@ -29,15 +29,20 @@ void wake_up_buffer_waiter(void);
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 drivers/oprofile/event_buffer.h
+--- a/drivers/oprofile/event_buffer.h Wed Jul 18 12:23:24 2007 -0300
++++ b/drivers/oprofile/event_buffer.h Wed Aug 08 16:25:28 2007 -0300
+@@ -29,14 +29,19 @@ void wake_up_buffer_waiter(void);
#define CPU_SWITCH_CODE 2
#define COOKIE_SWITCH_CODE 3
#define KERNEL_ENTER_SWITCH_CODE 4
@@ -43464,16 +41701,15 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
#define INVALID_COOKIE ~0UL
#define NO_COOKIE 0UL
-
++
+/* Constant used to refer to coordinator domain (Xen) */
+#define COORDINATOR_DOMAIN -1
-+
+
/* add data to the event buffer */
void add_event_entry(unsigned long data);
-
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/drivers/oprofile/oprof.c source/drivers/oprofile/oprof.c
---- /scratch/src/linux-2.6.20.3/drivers/oprofile/oprof.c 2007-02-04 19:44:54.000000000 +0100
-+++ source/drivers/oprofile/oprof.c 2007-03-20 21:26:43.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 drivers/oprofile/oprof.c
+--- a/drivers/oprofile/oprof.c Wed Jul 18 12:23:24 2007 -0300
++++ b/drivers/oprofile/oprof.c Wed Aug 08 16:25:28 2007 -0300
@@ -5,6 +5,10 @@
* @remark Read the file COPYING
*
@@ -43494,10 +41730,11 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
struct oprofile_operations oprofile_ops;
unsigned long oprofile_started;
-@@ -33,6 +37,32 @@ static DEFINE_MUTEX(start_mutex);
+@@ -32,6 +36,32 @@ static DEFINE_MUTEX(start_mutex);
+ 1 - use the timer int mechanism regardless
*/
static int timer = 0;
-
++
+int oprofile_set_active(int active_domains[], unsigned int adomains)
+{
+ int err;
@@ -43523,14 +41760,13 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ mutex_unlock(&start_mutex);
+ return err;
+}
-+
+
int oprofile_setup(void)
{
- int err;
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/drivers/oprofile/oprof.h source/drivers/oprofile/oprof.h
---- /scratch/src/linux-2.6.20.3/drivers/oprofile/oprof.h 2007-02-04 19:44:54.000000000 +0100
-+++ source/drivers/oprofile/oprof.h 2007-03-20 21:26:43.000000000 +0100
-@@ -35,5 +35,8 @@ void oprofile_create_files(struct super_
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 drivers/oprofile/oprof.h
+--- a/drivers/oprofile/oprof.h Wed Jul 18 12:23:24 2007 -0300
++++ b/drivers/oprofile/oprof.h Wed Aug 08 16:25:28 2007 -0300
+@@ -35,5 +35,8 @@ void oprofile_timer_init(struct oprofile
void oprofile_timer_init(struct oprofile_operations * ops);
int oprofile_set_backtrace(unsigned long depth);
@@ -43539,9 +41775,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+int oprofile_set_passive(int passive_domains[], unsigned int pdomains);
#endif /* OPROF_H */
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/drivers/oprofile/oprofile_files.c source/drivers/oprofile/oprofile_files.c
---- /scratch/src/linux-2.6.20.3/drivers/oprofile/oprofile_files.c 2007-02-04 19:44:54.000000000 +0100
-+++ source/drivers/oprofile/oprofile_files.c 2007-03-20 21:26:43.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 drivers/oprofile/oprofile_files.c
+--- a/drivers/oprofile/oprofile_files.c Wed Jul 18 12:23:24 2007 -0300
++++ b/drivers/oprofile/oprofile_files.c Wed Aug 08 16:25:28 2007 -0300
@@ -5,15 +5,21 @@
* @remark Read the file COPYING
*
@@ -43565,7 +41801,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
unsigned long fs_buffer_size = 131072;
unsigned long fs_cpu_buffer_size = 8192;
unsigned long fs_buffer_watershed = 32768; /* FIXME: tune */
-@@ -117,11 +123,208 @@ static ssize_t dump_write(struct file *
+@@ -117,11 +123,208 @@ static struct file_operations dump_fops
static struct file_operations dump_fops = {
.write = dump_write,
};
@@ -43775,9 +42011,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
oprofilefs_create_file(sb, root, "buffer", &event_buffer_fops);
oprofilefs_create_ulong(sb, root, "buffer_size", &fs_buffer_size);
oprofilefs_create_ulong(sb, root, "buffer_watershed", &fs_buffer_watershed);
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/drivers/pci/Kconfig source/drivers/pci/Kconfig
---- /scratch/src/linux-2.6.20.3/drivers/pci/Kconfig 2007-02-04 19:44:54.000000000 +0100
-+++ source/drivers/pci/Kconfig 2007-03-20 21:26:43.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 drivers/pci/Kconfig
+--- a/drivers/pci/Kconfig Wed Jul 18 12:23:24 2007 -0300
++++ b/drivers/pci/Kconfig Wed Aug 08 16:25:28 2007 -0300
@@ -5,6 +5,7 @@ config PCI_MSI
bool "Message Signaled Interrupts (MSI and MSI-X)"
depends on PCI
@@ -43786,7 +42022,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
help
This allows device drivers to enable MSI (Message Signaled
Interrupts). Message Signaled Interrupts enable a device to
-@@ -55,7 +56,7 @@ config PCI_DEBUG
+@@ -55,7 +56,7 @@ config HT_IRQ
config HT_IRQ
bool "Interrupts on hypertransport devices"
default y
@@ -43795,10 +42031,10 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
help
This allows native hypertransport devices to use interrupts.
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/drivers/serial/Kconfig source/drivers/serial/Kconfig
---- /scratch/src/linux-2.6.20.3/drivers/serial/Kconfig 2007-02-04 19:44:54.000000000 +0100
-+++ source/drivers/serial/Kconfig 2007-03-20 21:26:46.000000000 +0100
-@@ -11,6 +11,7 @@ menu "Serial drivers"
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 drivers/serial/Kconfig
+--- a/drivers/serial/Kconfig Wed Jul 18 12:23:24 2007 -0300
++++ b/drivers/serial/Kconfig Wed Aug 08 16:25:28 2007 -0300
+@@ -11,6 +11,7 @@ config SERIAL_8250
config SERIAL_8250
tristate "8250/16550 and compatible serial support"
depends on (BROKEN || !SPARC)
@@ -43806,10 +42042,315 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
select SERIAL_CORE
---help---
This selects whether you want to include the driver for the standard
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/drivers/xen/balloon/balloon.c source/drivers/xen/balloon/balloon.c
---- /scratch/src/linux-2.6.20.3/drivers/xen/balloon/balloon.c 1970-01-01 01:00:00.000000000 +0100
-+++ source/drivers/xen/balloon/balloon.c 2007-03-20 21:26:48.000000000 +0100
-@@ -0,0 +1,624 @@
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 drivers/video/console/Kconfig
+--- a/drivers/video/console/Kconfig Wed Jul 18 12:23:24 2007 -0300
++++ b/drivers/video/console/Kconfig Wed Aug 08 16:25:28 2007 -0300
+@@ -53,6 +53,7 @@ config VIDEO_SELECT
+ config VIDEO_SELECT
+ bool "Video mode selection support"
+ depends on X86 && VGA_CONSOLE
++ depends on !XEN
+ ---help---
+ This enables support for text mode selection on kernel startup. If
+ you want to take advantage of some high-resolution text mode your
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 drivers/xen/Kconfig
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/drivers/xen/Kconfig Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,260 @@
++#
++# This Kconfig describe xen options
++#
++
++mainmenu "Xen Configuration"
++
++config XEN
++ bool
++ default y if X86_XEN || X86_64_XEN
++ help
++ This is the Linux Xen port.
++
++if XEN
++config XEN_INTERFACE_VERSION
++ hex
++ default 0x00030205
++
++menu "XEN"
++
++config XEN_PRIVILEGED_GUEST
++ bool "Privileged Guest (domain 0)"
++ depends XEN
++ default n
++ help
++ Support for privileged operation (domain 0)
++
++config XEN_UNPRIVILEGED_GUEST
++ bool
++ default !XEN_PRIVILEGED_GUEST
++
++config XEN_PRIVCMD
++ bool
++ depends on PROC_FS
++ default y
++
++config XEN_XENBUS_DEV
++ bool
++ depends on PROC_FS
++ default y
++
++config XEN_BACKEND
++ tristate "Backend driver support"
++ default y
++ help
++ Support for backend device drivers that provide I/O services
++ to other virtual machines.
++
++config XEN_BLKDEV_BACKEND
++ tristate "Block-device backend driver"
++ depends on XEN_BACKEND
++ default y
++ help
++ The block-device backend driver allows the kernel to export its
++ block devices to other guests via a high-performance shared-memory
++ interface.
++
++config XEN_BLKDEV_TAP
++ tristate "Block-device tap backend driver"
++ depends on XEN_BACKEND
++ default XEN_PRIVILEGED_GUEST
++ help
++ The block tap driver is an alternative to the block back driver
++ and allows VM block requests to be redirected to userspace through
++ a device interface. The tap allows user-space development of
++ high-performance block backends, where disk images may be implemented
++ as files, in memory, or on other hosts across the network. This
++ driver can safely coexist with the existing blockback driver.
++
++config XEN_NETDEV_BACKEND
++ tristate "Network-device backend driver"
++ depends on XEN_BACKEND && NET
++ default y
++ help
++ The network-device backend driver allows the kernel to export its
++ network devices to other guests via a high-performance shared-memory
++ interface.
++
++config XEN_NETDEV_PIPELINED_TRANSMITTER
++ bool "Pipelined transmitter (DANGEROUS)"
++ depends on XEN_NETDEV_BACKEND
++ default n
++ help
++ If the net backend is a dumb domain, such as a transparent Ethernet
++ bridge with no local IP interface, it is safe to say Y here to get
++ slightly lower network overhead.
++ If the backend has a local IP interface; or may be doing smart things
++ like reassembling packets to perform firewall filtering; or if you
++ are unsure; or if you experience network hangs when this option is
++ enabled; then you must say N here.
++
++config XEN_NETDEV_LOOPBACK
++ tristate "Network-device loopback driver"
++ depends on XEN_NETDEV_BACKEND
++ default y
++ help
++ A two-interface loopback device to emulate a local netfront-netback
++ connection.
++
++config XEN_PCIDEV_BACKEND
++ tristate "PCI-device backend driver"
++ depends on PCI && XEN_BACKEND
++ default XEN_PRIVILEGED_GUEST
++ help
++ The PCI device backend driver allows the kernel to export arbitrary
++ PCI devices to other guests. If you select this to be a module, you
++ will need to make sure no other driver has bound to the device(s)
++ you want to make visible to other guests.
++
++choice
++ prompt "PCI Backend Mode"
++ depends on XEN_PCIDEV_BACKEND
++ default XEN_PCIDEV_BACKEND_VPCI
++
++config XEN_PCIDEV_BACKEND_VPCI
++ bool "Virtual PCI"
++ ---help---
++ This PCI Backend hides the true PCI topology and makes the frontend
++ think there is a single PCI bus with only the exported devices on it.
++ For example, a device at 03:05.0 will be re-assigned to 00:00.0. A
++ second device at 02:1a.1 will be re-assigned to 00:01.1.
++
++config XEN_PCIDEV_BACKEND_PASS
++ bool "Passthrough"
++ ---help---
++ This PCI Backend provides a real view of the PCI topology to the
++ frontend (for example, a device at 06:01.b will still appear at
++ 06:01.b to the frontend). This is similar to how Xen 2.0.x exposed
++ PCI devices to its driver domains. This may be required for drivers
++ which depend on finding their hardward in certain bus/slot
++ locations.
++
++config XEN_PCIDEV_BACKEND_SLOT
++ bool "Slot"
++ ---help---
++ This PCI Backend hides the true PCI topology and makes the frontend
++ think there is a single PCI bus with only the exported devices on it.
++ Contrary to the virtual PCI backend, a function becomes a new slot.
++ For example, a device at 03:05.2 will be re-assigned to 00:00.0. A
++ second device at 02:1a.1 will be re-assigned to 00:01.0.
++
++endchoice
++
++config XEN_PCIDEV_BE_DEBUG
++ bool "PCI Backend Debugging"
++ depends on XEN_PCIDEV_BACKEND
++ default n
++
++config XEN_TPMDEV_BACKEND
++ tristate "TPM-device backend driver"
++ depends on XEN_BACKEND
++ default n
++ help
++ The TPM-device backend driver
++
++config XEN_BLKDEV_FRONTEND
++ tristate "Block-device frontend driver"
++ depends on XEN
++ default y
++ help
++ The block-device frontend driver allows the kernel to access block
++ devices mounted within another guest OS. Unless you are building a
++ dedicated device-driver domain, or your master control domain
++ (domain 0), then you almost certainly want to say Y here.
++
++config XEN_NETDEV_FRONTEND
++ tristate "Network-device frontend driver"
++ depends on XEN && NET
++ default y
++ help
++ The network-device frontend driver allows the kernel to access
++ network interfaces within another guest OS. Unless you are building a
++ dedicated device-driver domain, or your master control domain
++ (domain 0), then you almost certainly want to say Y here.
++
++config XEN_FRAMEBUFFER
++ tristate "Framebuffer-device frontend driver"
++ depends on XEN && FB
++ select FB_CFB_FILLRECT
++ select FB_CFB_COPYAREA
++ select FB_CFB_IMAGEBLIT
++ default y
++ help
++ The framebuffer-device frontend drivers allows the kernel to create a
++ virtual framebuffer. This framebuffer can be viewed in another
++ domain. Unless this domain has access to a real video card, you
++ probably want to say Y here.
++
++config XEN_KEYBOARD
++ tristate "Keyboard-device frontend driver"
++ depends on XEN && XEN_FRAMEBUFFER && INPUT
++ default y
++ help
++ The keyboard-device frontend driver allows the kernel to create a
++ virtual keyboard. This keyboard can then be driven by another
++ domain. If you've said Y to CONFIG_XEN_FRAMEBUFFER, you probably
++ want to say Y here.
++
++config XEN_SCRUB_PAGES
++ bool "Scrub memory before freeing it to Xen"
++ default y
++ help
++ Erase memory contents before freeing it back to Xen's global
++ pool. This ensures that any secrets contained within that
++ memory (e.g., private keys) cannot be found by other guests that
++ may be running on the machine. Most people will want to say Y here.
++ If security is not a concern then you may increase performance by
++ saying N.
++
++config XEN_DISABLE_SERIAL
++ bool "Disable serial port drivers"
++ default y
++ help
++ 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 SYSFS
++ default y
++ help
++ Xen hypervisor attributes will show up under /sys/hypervisor/.
++
++choice
++ prompt "Xen version compatibility"
++ default XEN_COMPAT_030002_AND_LATER
++
++ config XEN_COMPAT_030002_AND_LATER
++ bool "3.0.2 and later"
++
++ config XEN_COMPAT_030004_AND_LATER
++ bool "3.0.4 and later"
++
++ config XEN_COMPAT_LATEST_ONLY
++ bool "no compatibility code"
++
++endchoice
++
++config XEN_COMPAT
++ hex
++ default 0xffffff if XEN_COMPAT_LATEST_ONLY
++ default 0x030004 if XEN_COMPAT_030004_AND_LATER
++ default 0x030002 if XEN_COMPAT_030002_AND_LATER
++ default 0
++
++endmenu
++
++config HAVE_IRQ_IGNORE_UNHANDLED
++ bool
++ default y
++
++config NO_IDLE_HZ
++ bool
++ default y
++
++config XEN_SMPBOOT
++ bool
++ default y
++ depends on SMP
++
++endif
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 drivers/xen/Makefile
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/drivers/xen/Makefile Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,20 @@
++obj-y += core/
++obj-y += console/
++obj-y += evtchn/
++obj-y += privcmd/
++obj-y += xenbus/
++obj-y += gntdev/
++obj-y += balloon/
++obj-y += char/
++
++obj-y += util.o
++obj-$(CONFIG_XEN_BLKDEV_BACKEND) += blkback/
++obj-$(CONFIG_XEN_BLKDEV_TAP) += blktap/
++obj-$(CONFIG_XEN_NETDEV_BACKEND) += netback/
++obj-$(CONFIG_XEN_TPMDEV_BACKEND) += tpmback/
++obj-$(CONFIG_XEN_BLKDEV_FRONTEND) += blkfront/
++obj-$(CONFIG_XEN_NETDEV_FRONTEND) += netfront/
++obj-$(CONFIG_XEN_PCIDEV_BACKEND) += pciback/
++obj-$(CONFIG_XEN_PCIDEV_FRONTEND) += pcifront/
++obj-$(CONFIG_XEN_FRAMEBUFFER) += fbfront/
++obj-$(CONFIG_XEN_KEYBOARD) += fbfront/
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 drivers/xen/balloon/Makefile
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/drivers/xen/balloon/Makefile Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,2 @@
++
++obj-y := balloon.o sysfs.o
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 drivers/xen/balloon/balloon.c
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/drivers/xen/balloon/balloon.c Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,663 @@
+/******************************************************************************
+ * balloon.c
+ *
@@ -43855,23 +42396,31 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#include <linux/bootmem.h>
+#include <linux/highmem.h>
+#include <linux/vmalloc.h>
++#include <linux/mutex.h>
+#include <xen/xen_proc.h>
+#include <asm/hypervisor.h>
+#include <xen/balloon.h>
+#include <xen/interface/memory.h>
++#include <asm/maddr.h>
++#include <asm/page.h>
+#include <asm/pgalloc.h>
+#include <asm/pgtable.h>
+#include <asm/uaccess.h>
+#include <asm/tlb.h>
++#include <linux/highmem.h>
+#include <linux/list.h>
+#include <xen/xenbus.h>
+#include "common.h"
+
++#ifdef HAVE_XEN_PLATFORM_COMPAT_H
++#include <xen/platform-compat.h>
++#endif
++
+#ifdef CONFIG_PROC_FS
+static struct proc_dir_entry *balloon_pde;
+#endif
+
-+static DECLARE_MUTEX(balloon_mutex);
++static DEFINE_MUTEX(balloon_mutex);
+
+/*
+ * Protects atomic reservation decrease/increase against concurrent increases.
@@ -44028,6 +42577,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+
+ set_phys_to_machine(pfn, frame_list[i]);
+
++#ifdef CONFIG_XEN
+ /* Link back into the page tables if not highmem. */
+ if (pfn < max_low_pfn) {
+ int ret;
@@ -44037,6 +42587,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ 0);
+ BUG_ON(ret);
+ }
++#endif
+
+ /* Relinquish the page back to the allocator. */
+ ClearPageReserved(page);
@@ -44082,9 +42633,11 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ if (!PageHighMem(page)) {
+ v = phys_to_virt(pfn << PAGE_SHIFT);
+ scrub_pages(v, 1);
++#ifdef CONFIG_XEN
+ ret = HYPERVISOR_update_va_mapping(
+ (unsigned long)v, __pte_ma(0), 0);
+ BUG_ON(ret);
++#endif
+ }
+#ifdef CONFIG_XEN_SCRUB_PAGES
+ else {
@@ -44095,9 +42648,11 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#endif
+ }
+
++#ifdef CONFIG_XEN
+ /* Ensure that ballooned highmem pages don't have kmaps. */
+ kmap_flush_unused();
+ flush_tlb_all();
++#endif
+
+ balloon_lock(flags);
+
@@ -44132,7 +42687,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ int need_sleep = 0;
+ long credit;
+
-+ down(&balloon_mutex);
++ mutex_lock(&balloon_mutex);
+
+ do {
+ credit = current_target() - bs.current_pages;
@@ -44151,7 +42706,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ if (current_target() != bs.current_pages)
+ mod_timer(&balloon_timer, jiffies + HZ);
+
-+ up(&balloon_mutex);
++ mutex_unlock(&balloon_mutex);
+}
+
+/* Resets the Xen limit, sets new target, and kicks off processing. */
@@ -44257,16 +42812,22 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+
+static int __init balloon_init(void)
+{
++#if defined(CONFIG_X86) && defined(CONFIG_XEN)
+ unsigned long pfn;
+ struct page *page;
++#endif
+
+ if (!is_running_on_xen())
+ return -ENODEV;
+
+ IPRINTK("Initialising balloon driver.\n");
+
++#ifdef CONFIG_XEN
+ bs.current_pages = min(xen_start_info->nr_pages, max_pfn);
+ totalram_pages = bs.current_pages;
++#else
++ bs.current_pages = totalram_pages;
++#endif
+ bs.target_pages = bs.current_pages;
+ bs.balloon_low = 0;
+ bs.balloon_high = 0;
@@ -44287,13 +42848,15 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ balloon_pde->write_proc = balloon_write;
+#endif
+ balloon_sysfs_init();
-+
++
++#if defined(CONFIG_X86) && defined(CONFIG_XEN)
+ /* Initialise the balloon with excess memory space. */
+ for (pfn = xen_start_info->nr_pages; pfn < max_pfn; pfn++) {
+ page = pfn_to_page(pfn);
+ if (!PageReserved(page))
+ balloon_append(page);
+ }
++#endif
+
+ target_watch.callback = watch_target;
+ xenstore_notifier.notifier_call = balloon_init_watcher;
@@ -44305,6 +42868,14 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+
+subsys_initcall(balloon_init);
+
++static void balloon_exit(void)
++{
++ /* XXX - release balloon here */
++ return;
++}
++
++module_exit(balloon_exit);
++
+void balloon_update_driver_allowance(long delta)
+{
+ unsigned long flags;
@@ -44314,6 +42885,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ balloon_unlock(flags);
+}
+
++#ifdef CONFIG_XEN
+static int dealloc_pte_fn(
+ pte_t *pte, struct page *pmd_page, unsigned long addr, void *data)
+{
@@ -44331,6 +42903,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ BUG_ON(ret != 1);
+ return 0;
+}
++#endif
+
+struct page **alloc_empty_pages_and_pagevec(int nr_pages)
+{
@@ -44366,8 +42939,13 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ if (ret == 1)
+ ret = 0; /* success */
+ } else {
++#ifdef CONFIG_XEN
+ ret = apply_to_page_range(&init_mm, vaddr, PAGE_SIZE,
+ dealloc_pte_fn, NULL);
++#else
++ /* Cannot handle non-auto translate mode. */
++ ret = 1;
++#endif
+ }
+
+ if (ret != 0) {
@@ -44383,7 +42961,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+
+ out:
+ schedule_work(&balloon_worker);
++#ifdef CONFIG_XEN
+ flush_tlb_all();
++#endif
+ return pagevec;
+
+ err:
@@ -44434,9 +43014,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+EXPORT_SYMBOL_GPL(balloon_release_driver_page);
+
+MODULE_LICENSE("Dual BSD/GPL");
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/drivers/xen/balloon/common.h source/drivers/xen/balloon/common.h
---- /scratch/src/linux-2.6.20.3/drivers/xen/balloon/common.h 1970-01-01 01:00:00.000000000 +0100
-+++ source/drivers/xen/balloon/common.h 2007-03-20 21:26:48.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 drivers/xen/balloon/common.h
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/drivers/xen/balloon/common.h Wed Aug 08 16:25:28 2007 -0300
@@ -0,0 +1,58 @@
+/******************************************************************************
+ * balloon/common.h
@@ -44496,16 +43076,10 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+void balloon_set_new_target(unsigned long target);
+
+#endif /* __XEN_BALLOON_COMMON_H__ */
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/drivers/xen/balloon/Makefile source/drivers/xen/balloon/Makefile
---- /scratch/src/linux-2.6.20.3/drivers/xen/balloon/Makefile 1970-01-01 01:00:00.000000000 +0100
-+++ source/drivers/xen/balloon/Makefile 2007-03-20 21:26:48.000000000 +0100
-@@ -0,0 +1,2 @@
-+
-+obj-y := balloon.o sysfs.o
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/drivers/xen/balloon/sysfs.c source/drivers/xen/balloon/sysfs.c
---- /scratch/src/linux-2.6.20.3/drivers/xen/balloon/sysfs.c 1970-01-01 01:00:00.000000000 +0100
-+++ source/drivers/xen/balloon/sysfs.c 2007-03-20 21:26:48.000000000 +0100
-@@ -0,0 +1,164 @@
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 drivers/xen/balloon/sysfs.c
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/drivers/xen/balloon/sysfs.c Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,170 @@
+/******************************************************************************
+ * balloon/sysfs.c
+ *
@@ -44537,10 +43111,16 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ */
+
+#include <linux/capability.h>
++#include <linux/errno.h>
+#include <linux/stat.h>
++#include <linux/string.h>
+#include <linux/sysdev.h>
+#include "common.h"
+
++#ifdef HAVE_XEN_PLATFORM_COMPAT_H
++#include <xen/platform-compat.h>
++#endif
++
+#define BALLOON_CLASS_NAME "memory"
+
+#define BALLOON_SHOW(name, format, args...) \
@@ -44670,10 +43250,17 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+{
+ unregister_balloon(&balloon_sysdev);
+}
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/drivers/xen/blkback/blkback.c source/drivers/xen/blkback/blkback.c
---- /scratch/src/linux-2.6.20.3/drivers/xen/blkback/blkback.c 1970-01-01 01:00:00.000000000 +0100
-+++ source/drivers/xen/blkback/blkback.c 2007-03-20 21:26:48.000000000 +0100
-@@ -0,0 +1,581 @@
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 drivers/xen/blkback/Makefile
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/drivers/xen/blkback/Makefile Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,3 @@
++obj-$(CONFIG_XEN_BLKDEV_BACKEND) := blkbk.o
++
++blkbk-y := blkback.o xenbus.o interface.o vbd.o
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 drivers/xen/blkback/blkback.c
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/drivers/xen/blkback/blkback.c Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,614 @@
+/******************************************************************************
+ * arch/xen/drivers/blkif/backend/main.c
+ *
@@ -44716,7 +43303,6 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#include <linux/list.h>
+#include <xen/balloon.h>
+#include <asm/hypervisor.h>
-+#include <asm/hypercall.h>
+#include "common.h"
+
+/*
@@ -44747,7 +43333,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ */
+typedef struct {
+ blkif_t *blkif;
-+ unsigned long id;
++ u64 id;
+ int nr_pages;
+ atomic_t pendcnt;
+ unsigned short operation;
@@ -44784,7 +43370,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+static void dispatch_rw_block_io(blkif_t *blkif,
+ blkif_request_t *req,
+ pending_req_t *pending_req);
-+static void make_response(blkif_t *blkif, unsigned long id,
++static void make_response(blkif_t *blkif, u64 id,
+ unsigned short op, int st);
+
+/******************************************************************
@@ -44975,17 +43561,20 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+
+static int do_block_io_op(blkif_t *blkif)
+{
-+ blkif_back_ring_t *blk_ring = &blkif->blk_ring;
++ blkif_back_rings_t *blk_rings = &blkif->blk_rings;
+ blkif_request_t req;
+ pending_req_t *pending_req;
+ RING_IDX rc, rp;
+ int more_to_do = 0;
+
-+ rc = blk_ring->req_cons;
-+ rp = blk_ring->sring->req_prod;
++ rc = blk_rings->common.req_cons;
++ rp = blk_rings->common.sring->req_prod;
+ rmb(); /* Ensure we see queued requests up to 'rp'. */
+
-+ while ((rc != rp) && !RING_REQUEST_CONS_OVERFLOW(blk_ring, rc)) {
++ while ((rc != rp)) {
++
++ if (RING_REQUEST_CONS_OVERFLOW(&blk_rings->common, rc))
++ break;
+
+ pending_req = alloc_req();
+ if (NULL == pending_req) {
@@ -44994,8 +43583,20 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ break;
+ }
+
-+ memcpy(&req, RING_GET_REQUEST(blk_ring, rc), sizeof(req));
-+ blk_ring->req_cons = ++rc; /* before make_response() */
++ switch (blkif->blk_protocol) {
++ case BLKIF_PROTOCOL_NATIVE:
++ memcpy(&req, RING_GET_REQUEST(&blk_rings->native, rc), sizeof(req));
++ break;
++ case BLKIF_PROTOCOL_X86_32:
++ blkif_get_x86_32_req(&req, RING_GET_REQUEST(&blk_rings->x86_32, rc));
++ break;
++ case BLKIF_PROTOCOL_X86_64:
++ blkif_get_x86_64_req(&req, RING_GET_REQUEST(&blk_rings->x86_64, rc));
++ break;
++ default:
++ BUG();
++ }
++ blk_rings->common.req_cons = ++rc; /* before make_response() */
+
+ switch (req.operation) {
+ case BLKIF_OP_READ:
@@ -45153,6 +43754,11 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ for (i = 0; i < nbio; i++)
+ submit_bio(operation, biolist[i]);
+
++ if (operation == READ)
++ blkif->st_rd_sect += preq.nr_sects;
++ else if (operation == WRITE)
++ blkif->st_wr_sect += preq.nr_sects;
++
+ return;
+
+ fail_put_bio:
@@ -45172,37 +43778,51 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ */
+
+
-+static void make_response(blkif_t *blkif, unsigned long id,
++static void make_response(blkif_t *blkif, u64 id,
+ unsigned short op, int st)
+{
-+ blkif_response_t *resp;
++ blkif_response_t resp;
+ unsigned long flags;
-+ blkif_back_ring_t *blk_ring = &blkif->blk_ring;
++ blkif_back_rings_t *blk_rings = &blkif->blk_rings;
+ int more_to_do = 0;
+ int notify;
+
-+ spin_lock_irqsave(&blkif->blk_ring_lock, flags);
-+
-+ /* Place on the response ring for the relevant domain. */
-+ resp = RING_GET_RESPONSE(blk_ring, blk_ring->rsp_prod_pvt);
-+ resp->id = id;
-+ resp->operation = op;
-+ resp->status = st;
-+ blk_ring->rsp_prod_pvt++;
-+ RING_PUSH_RESPONSES_AND_CHECK_NOTIFY(blk_ring, notify);
++ resp.id = id;
++ resp.operation = op;
++ resp.status = st;
+
-+ if (blk_ring->rsp_prod_pvt == blk_ring->req_cons) {
++ spin_lock_irqsave(&blkif->blk_ring_lock, flags);
++ /* Place on the response ring for the relevant domain. */
++ switch (blkif->blk_protocol) {
++ case BLKIF_PROTOCOL_NATIVE:
++ memcpy(RING_GET_RESPONSE(&blk_rings->native, blk_rings->native.rsp_prod_pvt),
++ &resp, sizeof(resp));
++ break;
++ case BLKIF_PROTOCOL_X86_32:
++ memcpy(RING_GET_RESPONSE(&blk_rings->x86_32, blk_rings->x86_32.rsp_prod_pvt),
++ &resp, sizeof(resp));
++ break;
++ case BLKIF_PROTOCOL_X86_64:
++ memcpy(RING_GET_RESPONSE(&blk_rings->x86_64, blk_rings->x86_64.rsp_prod_pvt),
++ &resp, sizeof(resp));
++ break;
++ default:
++ BUG();
++ }
++ blk_rings->common.rsp_prod_pvt++;
++ RING_PUSH_RESPONSES_AND_CHECK_NOTIFY(&blk_rings->common, notify);
++ if (blk_rings->common.rsp_prod_pvt == blk_rings->common.req_cons) {
+ /*
+ * Tail check for pending requests. Allows frontend to avoid
+ * notifications if requests are already in flight (lower
+ * overheads and promotes batching).
+ */
-+ RING_FINAL_CHECK_FOR_REQUESTS(blk_ring, more_to_do);
++ RING_FINAL_CHECK_FOR_REQUESTS(&blk_rings->common, more_to_do);
+
-+ } else if (RING_HAS_UNCONSUMED_REQUESTS(blk_ring)) {
++ } else if (RING_HAS_UNCONSUMED_REQUESTS(&blk_rings->common)) {
+ more_to_do = 1;
-+
+ }
++
+ spin_unlock_irqrestore(&blkif->blk_ring_lock, flags);
+
+ if (more_to_do)
@@ -45255,10 +43875,10 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+module_init(blkif_init);
+
+MODULE_LICENSE("Dual BSD/GPL");
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/drivers/xen/blkback/common.h source/drivers/xen/blkback/common.h
---- /scratch/src/linux-2.6.20.3/drivers/xen/blkback/common.h 1970-01-01 01:00:00.000000000 +0100
-+++ source/drivers/xen/blkback/common.h 2007-03-20 21:26:48.000000000 +0100
-@@ -0,0 +1,138 @@
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 drivers/xen/blkback/common.h
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/drivers/xen/blkback/common.h Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,139 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License version 2
@@ -45300,8 +43920,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#include <asm/pgalloc.h>
+#include <xen/evtchn.h>
+#include <asm/hypervisor.h>
-+#include <xen/interface/io/blkif.h>
-+#include <xen/interface/io/ring.h>
++#include <xen/blkif.h>
+#include <xen/gnttab.h>
+#include <xen/driver_util.h>
+#include <xen/xenbus.h>
@@ -45325,10 +43944,10 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ domid_t domid;
+ unsigned int handle;
+ /* Physical parameters of the comms window. */
-+ unsigned int evtchn;
+ unsigned int irq;
+ /* Comms information. */
-+ blkif_back_ring_t blk_ring;
++ enum blkif_protocol blk_protocol;
++ blkif_back_rings_t blk_rings;
+ struct vm_struct *blk_ring_area;
+ /* The VBD attached to this interface. */
+ struct vbd vbd;
@@ -45349,6 +43968,8 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ int st_wr_req;
+ int st_oo_req;
+ int st_br_req;
++ int st_rd_sect;
++ int st_wr_sect;
+
+ wait_queue_head_t waiting_to_free;
+
@@ -45397,10 +44018,10 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ struct backend_info *be, int state);
+
+#endif /* __BLKIF__BACKEND__COMMON_H__ */
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/drivers/xen/blkback/interface.c source/drivers/xen/blkback/interface.c
---- /scratch/src/linux-2.6.20.3/drivers/xen/blkback/interface.c 1970-01-01 01:00:00.000000000 +0100
-+++ source/drivers/xen/blkback/interface.c 2007-03-20 21:26:48.000000000 +0100
-@@ -0,0 +1,171 @@
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 drivers/xen/blkback/interface.c
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/drivers/xen/blkback/interface.c Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,181 @@
+/******************************************************************************
+ * arch/xen/drivers/blkif/backend/interface.c
+ *
@@ -45461,15 +44082,12 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+static int map_frontend_page(blkif_t *blkif, unsigned long shared_page)
+{
+ struct gnttab_map_grant_ref op;
-+ int ret;
+
+ gnttab_set_map_op(&op, (unsigned long)blkif->blk_ring_area->addr,
+ GNTMAP_host_map, shared_page, blkif->domid);
+
-+ lock_vm_area(blkif->blk_ring_area);
-+ ret = HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &op, 1);
-+ unlock_vm_area(blkif->blk_ring_area);
-+ BUG_ON(ret);
++ if (HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &op, 1))
++ BUG();
+
+ if (op.status) {
+ DPRINTK(" Grant table operation failure !\n");
@@ -45485,22 +44103,17 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+static void unmap_frontend_page(blkif_t *blkif)
+{
+ struct gnttab_unmap_grant_ref op;
-+ int ret;
+
+ gnttab_set_unmap_op(&op, (unsigned long)blkif->blk_ring_area->addr,
+ GNTMAP_host_map, blkif->shmem_handle);
+
-+ lock_vm_area(blkif->blk_ring_area);
-+ ret = HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1);
-+ unlock_vm_area(blkif->blk_ring_area);
-+ BUG_ON(ret);
++ if (HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1))
++ BUG();
+}
+
+int blkif_map(blkif_t *blkif, unsigned long shared_page, unsigned int evtchn)
+{
-+ blkif_sring_t *sring;
+ int err;
-+ struct evtchn_bind_interdomain bind_interdomain;
+
+ /* Already connected through? */
+ if (blkif->irq)
@@ -45515,24 +44128,42 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ return err;
+ }
+
-+ bind_interdomain.remote_dom = blkif->domid;
-+ bind_interdomain.remote_port = evtchn;
++ switch (blkif->blk_protocol) {
++ case BLKIF_PROTOCOL_NATIVE:
++ {
++ blkif_sring_t *sring;
++ sring = (blkif_sring_t *)blkif->blk_ring_area->addr;
++ BACK_RING_INIT(&blkif->blk_rings.native, sring, PAGE_SIZE);
++ break;
++ }
++ case BLKIF_PROTOCOL_X86_32:
++ {
++ blkif_x86_32_sring_t *sring_x86_32;
++ sring_x86_32 = (blkif_x86_32_sring_t *)blkif->blk_ring_area->addr;
++ BACK_RING_INIT(&blkif->blk_rings.x86_32, sring_x86_32, PAGE_SIZE);
++ break;
++ }
++ case BLKIF_PROTOCOL_X86_64:
++ {
++ blkif_x86_64_sring_t *sring_x86_64;
++ sring_x86_64 = (blkif_x86_64_sring_t *)blkif->blk_ring_area->addr;
++ BACK_RING_INIT(&blkif->blk_rings.x86_64, sring_x86_64, PAGE_SIZE);
++ break;
++ }
++ default:
++ BUG();
++ }
+
-+ err = HYPERVISOR_event_channel_op(EVTCHNOP_bind_interdomain,
-+ &bind_interdomain);
-+ if (err) {
++ err = bind_interdomain_evtchn_to_irqhandler(
++ blkif->domid, evtchn, blkif_be_int, 0, "blkif-backend", blkif);
++ if (err < 0)
++ {
+ unmap_frontend_page(blkif);
+ free_vm_area(blkif->blk_ring_area);
++ blkif->blk_rings.common.sring = NULL;
+ return err;
+ }
-+
-+ blkif->evtchn = bind_interdomain.local_port;
-+
-+ sring = (blkif_sring_t *)blkif->blk_ring_area->addr;
-+ BACK_RING_INIT(&blkif->blk_ring, sring, PAGE_SIZE);
-+
-+ blkif->irq = bind_evtchn_to_irqhandler(
-+ blkif->evtchn, blkif_be_int, 0, "blkif-backend", blkif);
++ blkif->irq = err;
+
+ return 0;
+}
@@ -45553,10 +44184,10 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ blkif->irq = 0;
+ }
+
-+ if (blkif->blk_ring.sring) {
++ if (blkif->blk_rings.common.sring) {
+ unmap_frontend_page(blkif);
+ free_vm_area(blkif->blk_ring_area);
-+ blkif->blk_ring.sring = NULL;
++ blkif->blk_rings.common.sring = NULL;
+ }
+}
+
@@ -45572,16 +44203,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ blkif_cachep = kmem_cache_create("blkif_cache", sizeof(blkif_t),
+ 0, 0, NULL, NULL);
+}
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/drivers/xen/blkback/Makefile source/drivers/xen/blkback/Makefile
---- /scratch/src/linux-2.6.20.3/drivers/xen/blkback/Makefile 1970-01-01 01:00:00.000000000 +0100
-+++ source/drivers/xen/blkback/Makefile 2007-03-20 21:26:48.000000000 +0100
-@@ -0,0 +1,3 @@
-+obj-$(CONFIG_XEN_BLKDEV_BACKEND) := blkbk.o
-+
-+blkbk-y := blkback.o xenbus.o interface.o vbd.o
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/drivers/xen/blkback/vbd.c source/drivers/xen/blkback/vbd.c
---- /scratch/src/linux-2.6.20.3/drivers/xen/blkback/vbd.c 1970-01-01 01:00:00.000000000 +0100
-+++ source/drivers/xen/blkback/vbd.c 2007-03-20 21:26:48.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 drivers/xen/blkback/vbd.c
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/drivers/xen/blkback/vbd.c Wed Aug 08 16:25:28 2007 -0300
@@ -0,0 +1,118 @@
+/******************************************************************************
+ * blkback/vbd.c
@@ -45701,10 +44325,10 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ out:
+ return rc;
+}
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/drivers/xen/blkback/xenbus.c source/drivers/xen/blkback/xenbus.c
---- /scratch/src/linux-2.6.20.3/drivers/xen/blkback/xenbus.c 1970-01-01 01:00:00.000000000 +0100
-+++ source/drivers/xen/blkback/xenbus.c 2007-03-20 21:26:48.000000000 +0100
-@@ -0,0 +1,485 @@
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 drivers/xen/blkback/xenbus.c
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/drivers/xen/blkback/xenbus.c Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,533 @@
+/* Xenbus code for blkif backend
+ Copyright (C) 2005 Rusty Russell <rusty@rustcorp.com.au>
+ Copyright (C) 2005 XenSource Ltd
@@ -45749,9 +44373,30 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+static void backend_changed(struct xenbus_watch *, const char **,
+ unsigned int);
+
++static int blkback_name(blkif_t *blkif, char *buf)
++{
++ char *devpath, *devname;
++ struct xenbus_device *dev = blkif->be->dev;
++
++ devpath = xenbus_read(XBT_NIL, dev->nodename, "dev", NULL);
++ if (IS_ERR(devpath))
++ return PTR_ERR(devpath);
++
++ if ((devname = strstr(devpath, "/dev/")) != NULL)
++ devname += strlen("/dev/");
++ else
++ devname = devpath;
++
++ snprintf(buf, TASK_COMM_LEN, "blkback.%d.%s", blkif->domid, devname);
++ kfree(devpath);
++
++ return 0;
++}
++
+static void update_blkif_status(blkif_t *blkif)
+{
+ int err;
++ char name[TASK_COMM_LEN];
+
+ /* Not ready to connect? */
+ if (!blkif->irq || !blkif->vbd.bdev)
@@ -45766,10 +44411,13 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ if (blkif->be->dev->state != XenbusStateConnected)
+ return;
+
-+ blkif->xenblkd = kthread_run(blkif_schedule, blkif,
-+ "xvd %d %02x:%02x",
-+ blkif->domid,
-+ blkif->be->major, blkif->be->minor);
++ err = blkback_name(blkif, name);
++ if (err) {
++ xenbus_dev_error(blkif->be->dev, err, "get blkback dev name");
++ return;
++ }
++
++ blkif->xenblkd = kthread_run(blkif_schedule, blkif, name);
+ if (IS_ERR(blkif->xenblkd)) {
+ err = PTR_ERR(blkif->xenblkd);
+ blkif->xenblkd = NULL;
@@ -45794,16 +44442,20 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ } \
+ DEVICE_ATTR(name, S_IRUGO, show_##name, NULL)
+
-+VBD_SHOW(oo_req, "%d\n", be->blkif->st_oo_req);
-+VBD_SHOW(rd_req, "%d\n", be->blkif->st_rd_req);
-+VBD_SHOW(wr_req, "%d\n", be->blkif->st_wr_req);
-+VBD_SHOW(br_req, "%d\n", be->blkif->st_br_req);
++VBD_SHOW(oo_req, "%d\n", be->blkif->st_oo_req);
++VBD_SHOW(rd_req, "%d\n", be->blkif->st_rd_req);
++VBD_SHOW(wr_req, "%d\n", be->blkif->st_wr_req);
++VBD_SHOW(br_req, "%d\n", be->blkif->st_br_req);
++VBD_SHOW(rd_sect, "%d\n", be->blkif->st_rd_sect);
++VBD_SHOW(wr_sect, "%d\n", be->blkif->st_wr_sect);
+
+static struct attribute *vbdstat_attrs[] = {
+ &dev_attr_oo_req.attr,
+ &dev_attr_rd_req.attr,
+ &dev_attr_wr_req.attr,
+ &dev_attr_br_req.attr,
++ &dev_attr_rd_sect.attr,
++ &dev_attr_wr_sect.attr,
+ NULL
+};
+
@@ -46027,7 +44679,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ switch (frontend_state) {
+ case XenbusStateInitialising:
+ if (dev->state == XenbusStateClosed) {
-+ printk("%s: %s: prepare for reconnect\n",
++ printk(KERN_INFO "%s: %s: prepare for reconnect\n",
+ __FUNCTION__, dev->nodename);
+ xenbus_switch_state(dev, XenbusStateInitWait);
+ }
@@ -46142,6 +44794,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ struct xenbus_device *dev = be->dev;
+ unsigned long ring_ref;
+ unsigned int evtchn;
++ char protocol[64] = "";
+ int err;
+
+ DPRINTK("%s", dev->otherend);
@@ -46155,6 +44808,25 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ return err;
+ }
+
++ be->blkif->blk_protocol = BLKIF_PROTOCOL_NATIVE;
++ err = xenbus_gather(XBT_NIL, dev->otherend, "protocol",
++ "%63s", protocol, NULL);
++ if (err)
++ strcpy(protocol, "unspecified, assuming native");
++ else if (0 == strcmp(protocol, XEN_IO_PROTO_ABI_NATIVE))
++ be->blkif->blk_protocol = BLKIF_PROTOCOL_NATIVE;
++ else if (0 == strcmp(protocol, XEN_IO_PROTO_ABI_X86_32))
++ be->blkif->blk_protocol = BLKIF_PROTOCOL_X86_32;
++ else if (0 == strcmp(protocol, XEN_IO_PROTO_ABI_X86_64))
++ be->blkif->blk_protocol = BLKIF_PROTOCOL_X86_64;
++ else {
++ xenbus_dev_fatal(dev, err, "unknown fe protocol %s", protocol);
++ return -1;
++ }
++ printk(KERN_INFO
++ "blkback: ring-ref %ld, event-channel %d, protocol %d (%s)\n",
++ ring_ref, evtchn, be->blkif->blk_protocol, protocol);
++
+ /* Map the shared frame, irq etc. */
+ err = blkif_map(be->blkif, ring_ref, evtchn);
+ if (err) {
@@ -46190,10 +44862,19 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+{
+ xenbus_register_backend(&blkback);
+}
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/drivers/xen/blkfront/blkfront.c source/drivers/xen/blkfront/blkfront.c
---- /scratch/src/linux-2.6.20.3/drivers/xen/blkfront/blkfront.c 1970-01-01 01:00:00.000000000 +0100
-+++ source/drivers/xen/blkfront/blkfront.c 2007-03-20 21:26:48.000000000 +0100
-@@ -0,0 +1,892 @@
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 drivers/xen/blkfront/Makefile
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/drivers/xen/blkfront/Makefile Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,5 @@
++
++obj-$(CONFIG_XEN_BLKDEV_FRONTEND) := xenblk.o
++
++xenblk-objs := blkfront.o vbd.o
++
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 drivers/xen/blkfront/blkfront.c
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/drivers/xen/blkfront/blkfront.c Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,903 @@
+/******************************************************************************
+ * blkfront.c
+ *
@@ -46240,6 +44921,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#include <xen/evtchn.h>
+#include <xen/xenbus.h>
+#include <xen/interface/grant_table.h>
++#include <xen/interface/io/protocols.h>
+#include <xen/gnttab.h>
+#include <asm/hypervisor.h>
+#include <asm/maddr.h>
@@ -46370,12 +45052,18 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ message = "writing ring-ref";
+ goto abort_transaction;
+ }
-+ err = xenbus_printf(xbt, dev->nodename,
-+ "event-channel", "%u", info->evtchn);
++ err = xenbus_printf(xbt, dev->nodename, "event-channel", "%u",
++ irq_to_evtchn_port(info->irq));
+ if (err) {
+ message = "writing event-channel";
+ goto abort_transaction;
+ }
++ err = xenbus_printf(xbt, dev->nodename, "protocol", "%s",
++ XEN_IO_PROTO_ABI_NATIVE);
++ if (err) {
++ message = "writing protocol";
++ goto abort_transaction;
++ }
+
+ err = xenbus_transaction_end(xbt, 0);
+ if (err) {
@@ -46424,15 +45112,11 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ }
+ info->ring_ref = err;
+
-+ err = xenbus_alloc_evtchn(dev, &info->evtchn);
-+ if (err)
-+ goto fail;
-+
-+ err = bind_evtchn_to_irqhandler(
-+ info->evtchn, blkif_int, SA_SAMPLE_RANDOM, "blkif", info);
++ err = bind_listening_port_to_irqhandler(
++ dev->otherend_id, blkif_int, SA_SAMPLE_RANDOM, "blkif", info);
+ if (err <= 0) {
+ xenbus_dev_fatal(dev, err,
-+ "bind_evtchn_to_irqhandler failed");
++ "bind_listening_port_to_irqhandler");
+ goto fail;
+ }
+ info->irq = err;
@@ -46472,13 +45156,21 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ if (bd == NULL)
+ xenbus_dev_fatal(dev, -ENODEV, "bdget failed");
+
++#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,17)
++ down(&bd->bd_sem);
++#else
+ mutex_lock(&bd->bd_mutex);
++#endif
+ if (info->users > 0)
+ xenbus_dev_error(dev, -EBUSY,
+ "Device in use; refusing to close");
+ else
+ blkfront_closing(dev);
++#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,17)
++ up(&bd->bd_sem);
++#else
+ mutex_unlock(&bd->bd_mutex);
++#endif
+ bdput(bd);
+ break;
+ }
@@ -46849,7 +45541,8 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+
+ DPRINTK("do_blk_req %p: cmd %p, sec %llx, "
+ "(%u/%li) buffer:%p [%s]\n",
-+ req, req->cmd, (u64)req->sector, req->current_nr_sectors,
++ req, req->cmd, (long long)req->sector,
++ req->current_nr_sectors,
+ req->nr_sectors, req->buffer,
+ rq_data_dir(req) ? "write" : "read");
+
@@ -46972,8 +45665,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ }
+ if (info->irq)
+ unbind_from_irqhandler(info->irq, info);
-+ info->evtchn = info->irq = 0;
-+
++ info->irq = 0;
+}
+
+static void blkif_completion(struct blk_shadow *s)
@@ -47086,10 +45778,10 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+module_exit(xlblk_exit);
+
+MODULE_LICENSE("Dual BSD/GPL");
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/drivers/xen/blkfront/block.h source/drivers/xen/blkfront/block.h
---- /scratch/src/linux-2.6.20.3/drivers/xen/blkfront/block.h 1970-01-01 01:00:00.000000000 +0100
-+++ source/drivers/xen/blkfront/block.h 2007-03-20 21:26:48.000000000 +0100
-@@ -0,0 +1,156 @@
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 drivers/xen/blkfront/block.h
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/drivers/xen/blkfront/block.h Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,142 @@
+/******************************************************************************
+ * block.h
+ *
@@ -47148,20 +45840,6 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#include <asm/atomic.h>
+#include <asm/uaccess.h>
+
-+#if 1
-+#define IPRINTK(fmt, args...) \
-+ printk(KERN_INFO "xen_blk: " fmt, ##args)
-+#else
-+#define IPRINTK(fmt, args...) ((void)0)
-+#endif
-+
-+#if 1
-+#define WPRINTK(fmt, args...) \
-+ printk(KERN_WARNING "xen_blk: " fmt, ##args)
-+#else
-+#define WPRINTK(fmt, args...) ((void)0)
-+#endif
-+
+#define DPRINTK(_f, _a...) pr_debug(_f, ## _a)
+
+#if 0
@@ -47209,7 +45887,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ int connected;
+ int ring_ref;
+ blkif_front_ring_t ring;
-+ unsigned int evtchn, irq;
++ unsigned int irq;
+ struct xlbd_major_info *mi;
+ request_queue_t *rq;
+ struct work_struct work;
@@ -47246,29 +45924,10 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+int xlvbd_barrier(struct blkfront_info *info);
+
+#endif /* __XEN_DRIVERS_BLOCK_H__ */
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/drivers/xen/blkfront/Kconfig source/drivers/xen/blkfront/Kconfig
---- /scratch/src/linux-2.6.20.3/drivers/xen/blkfront/Kconfig 1970-01-01 01:00:00.000000000 +0100
-+++ source/drivers/xen/blkfront/Kconfig 2007-03-20 21:26:48.000000000 +0100
-@@ -0,0 +1,6 @@
-+
-+config XENBLOCK
-+ tristate "Block device driver"
-+ depends on ARCH_XEN
-+ help
-+ Block device driver for Xen
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/drivers/xen/blkfront/Makefile source/drivers/xen/blkfront/Makefile
---- /scratch/src/linux-2.6.20.3/drivers/xen/blkfront/Makefile 1970-01-01 01:00:00.000000000 +0100
-+++ source/drivers/xen/blkfront/Makefile 2007-03-20 21:26:48.000000000 +0100
-@@ -0,0 +1,5 @@
-+
-+obj-$(CONFIG_XEN_BLKDEV_FRONTEND) := xenblk.o
-+
-+xenblk-objs := blkfront.o vbd.o
-+
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/drivers/xen/blkfront/vbd.c source/drivers/xen/blkfront/vbd.c
---- /scratch/src/linux-2.6.20.3/drivers/xen/blkfront/vbd.c 1970-01-01 01:00:00.000000000 +0100
-+++ source/drivers/xen/blkfront/vbd.c 2007-03-20 21:26:48.000000000 +0100
-@@ -0,0 +1,375 @@
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 drivers/xen/blkfront/vbd.c
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/drivers/xen/blkfront/vbd.c Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,372 @@
+/******************************************************************************
+ * vbd.c
+ *
@@ -47399,15 +46058,12 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ break;
+ }
+
-+ printk("Registering block device major %i\n", ptr->major);
+ if (register_blkdev(ptr->major, ptr->type->devname)) {
-+ WPRINTK("can't get major %d with name %s\n",
-+ ptr->major, ptr->type->devname);
+ kfree(ptr);
+ return NULL;
+ }
+
-+/* devfs_mk_dir(ptr->type->devname);*/
++ printk("xen-vbd: registered block device major %i\n", ptr->major);
+ major_info[index] = ptr;
+ return ptr;
+}
@@ -47644,1531 +46300,19 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ return -ENOSYS;
+}
+#endif
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/drivers/xen/blktap/blktap.c source/drivers/xen/blktap/blktap.c
---- /scratch/src/linux-2.6.20.3/drivers/xen/blktap/blktap.c 1970-01-01 01:00:00.000000000 +0100
-+++ source/drivers/xen/blktap/blktap.c 2007-03-20 21:26:48.000000000 +0100
-@@ -0,0 +1,1517 @@
-+/******************************************************************************
-+ * drivers/xen/blktap/blktap.c
-+ *
-+ * Back-end driver for user level virtual block devices. This portion of the
-+ * driver exports a 'unified' block-device interface that can be accessed
-+ * by any operating system that implements a compatible front end. Requests
-+ * are remapped to a user-space memory region.
-+ *
-+ * Based on the blkback driver code.
-+ *
-+ * Copyright (c) 2004-2005, Andrew Warfield and Julian Chesterfield
-+ *
-+ * Clean ups and fix ups:
-+ * Copyright (c) 2006, Steven Rostedt - Red Hat, Inc.
-+ *
-+ * 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; or, when distributed
-+ * separately from the Linux kernel or incorporated into other
-+ * software packages, subject to the following license:
-+ *
-+ * Permission is hereby granted, free of charge, to any person obtaining a copy
-+ * of this source file (the "Software"), to deal in the Software without
-+ * restriction, including without limitation the rights to use, copy, modify,
-+ * merge, publish, distribute, sublicense, and/or sell copies of the Software,
-+ * and to permit persons to whom the Software is furnished to do so, subject to
-+ * the following conditions:
-+ *
-+ * The above copyright notice and this permission notice shall be included in
-+ * all copies or substantial portions of the Software.
-+ *
-+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-+ * IN THE SOFTWARE.
-+ */
-+
-+#include <linux/spinlock.h>
-+#include <linux/kthread.h>
-+#include <linux/list.h>
-+#include <asm/hypervisor.h>
-+#include "common.h"
-+#include <xen/balloon.h>
-+#include <linux/kernel.h>
-+#include <linux/fs.h>
-+#include <linux/mm.h>
-+#include <linux/errno.h>
-+#include <linux/major.h>
-+#include <linux/gfp.h>
-+#include <linux/poll.h>
-+#include <asm/tlbflush.h>
-+#include <linux/devfs_fs_kernel.h>
-+
-+#define MAX_TAP_DEV 256 /*the maximum number of tapdisk ring devices */
-+#define MAX_DEV_NAME 100 /*the max tapdisk ring device name e.g. blktap0 */
-+
-+
-+struct class *xen_class;
-+EXPORT_SYMBOL_GPL(xen_class);
-+
-+/*
-+ * Setup the xen class. This should probably go in another file, but
-+ * since blktap is the only user of it so far, it gets to keep it.
-+ */
-+int setup_xen_class(void)
-+{
-+ int ret;
-+
-+ if (xen_class)
-+ return 0;
-+
-+ xen_class = class_create(THIS_MODULE, "xen");
-+ if ((ret = IS_ERR(xen_class))) {
-+ xen_class = NULL;
-+ return ret;
-+ }
-+
-+ return 0;
-+}
-+
-+/*
-+ * The maximum number of requests that can be outstanding at any time
-+ * is determined by
-+ *
-+ * [mmap_alloc * MAX_PENDING_REQS * BLKIF_MAX_SEGMENTS_PER_REQUEST]
-+ *
-+ * where mmap_alloc < MAX_DYNAMIC_MEM.
-+ *
-+ * TODO:
-+ * mmap_alloc is initialised to 2 and should be adjustable on the fly via
-+ * sysfs.
-+ */
-+#define BLK_RING_SIZE __RING_SIZE((blkif_sring_t *)0, PAGE_SIZE)
-+#define MAX_DYNAMIC_MEM BLK_RING_SIZE
-+#define MAX_PENDING_REQS BLK_RING_SIZE
-+#define MMAP_PAGES (MAX_PENDING_REQS * BLKIF_MAX_SEGMENTS_PER_REQUEST)
-+#define MMAP_VADDR(_start, _req,_seg) \
-+ (_start + \
-+ ((_req) * BLKIF_MAX_SEGMENTS_PER_REQUEST * PAGE_SIZE) + \
-+ ((_seg) * PAGE_SIZE))
-+static int blkif_reqs = MAX_PENDING_REQS;
-+static int mmap_pages = MMAP_PAGES;
-+
-+#define RING_PAGES 1 /* BLKTAP - immediately before the mmap area, we
-+ * have a bunch of pages reserved for shared
-+ * memory rings.
-+ */
-+
-+/*Data struct handed back to userspace for tapdisk device to VBD mapping*/
-+typedef struct domid_translate {
-+ unsigned short domid;
-+ unsigned short busid;
-+} domid_translate_t ;
-+
-+/*Data struct associated with each of the tapdisk devices*/
-+typedef struct tap_blkif {
-+ struct vm_area_struct *vma; /*Shared memory area */
-+ unsigned long rings_vstart; /*Kernel memory mapping */
-+ unsigned long user_vstart; /*User memory mapping */
-+ unsigned long dev_inuse; /*One process opens device at a time. */
-+ unsigned long dev_pending; /*In process of being opened */
-+ unsigned long ring_ok; /*make this ring->state */
-+ blkif_front_ring_t ufe_ring; /*Rings up to user space. */
-+ wait_queue_head_t wait; /*for poll */
-+ unsigned long mode; /*current switching mode */
-+ int minor; /*Minor number for tapdisk device */
-+ pid_t pid; /*tapdisk process id */
-+ enum { RUNNING, CLEANSHUTDOWN } status; /*Detect a clean userspace
-+ shutdown */
-+ unsigned long *idx_map; /*Record the user ring id to kern
-+ [req id, idx] tuple */
-+ blkif_t *blkif; /*Associate blkif with tapdev */
-+ struct domid_translate trans; /*Translation from domid to bus. */
-+} tap_blkif_t;
-+
-+static struct tap_blkif *tapfds[MAX_TAP_DEV];
-+static int blktap_next_minor;
-+
-+static int __init set_blkif_reqs(char *str)
-+{
-+ get_option(&str, &blkif_reqs);
-+ return 1;
-+}
-+__setup("blkif_reqs=", set_blkif_reqs);
-+
-+/* Run-time switchable: /sys/module/blktap/parameters/ */
-+static unsigned int log_stats = 0;
-+static unsigned int debug_lvl = 0;
-+module_param(log_stats, int, 0644);
-+module_param(debug_lvl, int, 0644);
-+
-+/*
-+ * Each outstanding request that we've passed to the lower device layers has a
-+ * 'pending_req' allocated to it. Each buffer_head that completes decrements
-+ * the pendcnt towards zero. When it hits zero, the specified domain has a
-+ * response queued for it, with the saved 'id' passed back.
-+ */
-+typedef struct {
-+ blkif_t *blkif;
-+ unsigned long id;
-+ unsigned short mem_idx;
-+ int nr_pages;
-+ atomic_t pendcnt;
-+ unsigned short operation;
-+ int status;
-+ struct list_head free_list;
-+ int inuse;
-+} pending_req_t;
-+
-+static pending_req_t *pending_reqs[MAX_PENDING_REQS];
-+static struct list_head pending_free;
-+static DEFINE_SPINLOCK(pending_free_lock);
-+static DECLARE_WAIT_QUEUE_HEAD (pending_free_wq);
-+static int alloc_pending_reqs;
-+
-+typedef unsigned int PEND_RING_IDX;
-+
-+static inline int MASK_PEND_IDX(int i) {
-+ return (i & (MAX_PENDING_REQS-1));
-+}
-+
-+static inline unsigned int RTN_PEND_IDX(pending_req_t *req, int idx) {
-+ return (req - pending_reqs[idx]);
-+}
-+
-+#define NR_PENDING_REQS (MAX_PENDING_REQS - pending_prod + pending_cons)
-+
-+#define BLKBACK_INVALID_HANDLE (~0)
-+
-+static struct page **foreign_pages[MAX_DYNAMIC_MEM];
-+static inline unsigned long idx_to_kaddr(
-+ unsigned int mmap_idx, unsigned int req_idx, unsigned int sg_idx)
-+{
-+ unsigned int arr_idx = req_idx*BLKIF_MAX_SEGMENTS_PER_REQUEST + sg_idx;
-+ unsigned long pfn = page_to_pfn(foreign_pages[mmap_idx][arr_idx]);
-+ return (unsigned long)pfn_to_kaddr(pfn);
-+}
-+
-+static unsigned short mmap_alloc = 0;
-+static unsigned short mmap_lock = 0;
-+static unsigned short mmap_inuse = 0;
-+
-+/******************************************************************
-+ * GRANT HANDLES
-+ */
-+
-+/* When using grant tables to map a frame for device access then the
-+ * handle returned must be used to unmap the frame. This is needed to
-+ * drop the ref count on the frame.
-+ */
-+struct grant_handle_pair
-+{
-+ grant_handle_t kernel;
-+ grant_handle_t user;
-+};
-+#define INVALID_GRANT_HANDLE 0xFFFF
-+
-+static struct grant_handle_pair
-+ pending_grant_handles[MAX_DYNAMIC_MEM][MMAP_PAGES];
-+#define pending_handle(_id, _idx, _i) \
-+ (pending_grant_handles[_id][((_idx) * BLKIF_MAX_SEGMENTS_PER_REQUEST) \
-+ + (_i)])
-+
-+
-+static int blktap_read_ufe_ring(tap_blkif_t *info); /*local prototypes*/
-+
-+#define BLKTAP_MINOR 0 /*/dev/xen/blktap has a dynamic major */
-+#define BLKTAP_DEV_DIR "/dev/xen"
-+
-+static int blktap_major;
-+
-+/* blktap IOCTLs: */
-+#define BLKTAP_IOCTL_KICK_FE 1
-+#define BLKTAP_IOCTL_KICK_BE 2 /* currently unused */
-+#define BLKTAP_IOCTL_SETMODE 3
-+#define BLKTAP_IOCTL_SENDPID 4
-+#define BLKTAP_IOCTL_NEWINTF 5
-+#define BLKTAP_IOCTL_MINOR 6
-+#define BLKTAP_IOCTL_MAJOR 7
-+#define BLKTAP_QUERY_ALLOC_REQS 8
-+#define BLKTAP_IOCTL_FREEINTF 9
-+#define BLKTAP_IOCTL_PRINT_IDXS 100
-+
-+/* blktap switching modes: (Set with BLKTAP_IOCTL_SETMODE) */
-+#define BLKTAP_MODE_PASSTHROUGH 0x00000000 /* default */
-+#define BLKTAP_MODE_INTERCEPT_FE 0x00000001
-+#define BLKTAP_MODE_INTERCEPT_BE 0x00000002 /* unimp. */
-+
-+#define BLKTAP_MODE_INTERPOSE \
-+ (BLKTAP_MODE_INTERCEPT_FE | BLKTAP_MODE_INTERCEPT_BE)
-+
-+
-+static inline int BLKTAP_MODE_VALID(unsigned long arg)
-+{
-+ return ((arg == BLKTAP_MODE_PASSTHROUGH ) ||
-+ (arg == BLKTAP_MODE_INTERCEPT_FE) ||
-+ (arg == BLKTAP_MODE_INTERPOSE ));
-+}
-+
-+/* Requests passing through the tap to userspace are re-assigned an ID.
-+ * We must record a mapping between the BE [IDX,ID] tuple and the userspace
-+ * ring ID.
-+ */
-+
-+static inline unsigned long MAKE_ID(domid_t fe_dom, PEND_RING_IDX idx)
-+{
-+ return ((fe_dom << 16) | MASK_PEND_IDX(idx));
-+}
-+
-+extern inline PEND_RING_IDX ID_TO_IDX(unsigned long id)
-+{
-+ return (PEND_RING_IDX)(id & 0x0000ffff);
-+}
-+
-+extern inline int ID_TO_MIDX(unsigned long id)
-+{
-+ return (int)(id >> 16);
-+}
-+
-+#define INVALID_REQ 0xdead0000
-+
-+/*TODO: Convert to a free list*/
-+static inline int GET_NEXT_REQ(unsigned long *idx_map)
-+{
-+ int i;
-+ for (i = 0; i < MAX_PENDING_REQS; i++)
-+ if (idx_map[i] == INVALID_REQ)
-+ return i;
-+
-+ return INVALID_REQ;
-+}
-+
-+
-+#define BLKTAP_INVALID_HANDLE(_g) \
-+ (((_g->kernel) == INVALID_GRANT_HANDLE) && \
-+ ((_g->user) == INVALID_GRANT_HANDLE))
-+
-+#define BLKTAP_INVALIDATE_HANDLE(_g) do { \
-+ (_g)->kernel = INVALID_GRANT_HANDLE; (_g)->user = INVALID_GRANT_HANDLE; \
-+ } while(0)
-+
-+
-+/******************************************************************
-+ * BLKTAP VM OPS
-+ */
-+
-+static struct page *blktap_nopage(struct vm_area_struct *vma,
-+ unsigned long address,
-+ int *type)
-+{
-+ /*
-+ * if the page has not been mapped in by the driver then return
-+ * NOPAGE_SIGBUS to the domain.
-+ */
-+
-+ return NOPAGE_SIGBUS;
-+}
-+
-+struct vm_operations_struct blktap_vm_ops = {
-+ nopage: blktap_nopage,
-+};
-+
-+/******************************************************************
-+ * BLKTAP FILE OPS
-+ */
-+
-+/*Function Declarations*/
-+static tap_blkif_t *get_next_free_dev(void);
-+static int blktap_open(struct inode *inode, struct file *filp);
-+static int blktap_release(struct inode *inode, struct file *filp);
-+static int blktap_mmap(struct file *filp, struct vm_area_struct *vma);
-+static int blktap_ioctl(struct inode *inode, struct file *filp,
-+ unsigned int cmd, unsigned long arg);
-+static unsigned int blktap_poll(struct file *file, poll_table *wait);
-+
-+static struct file_operations blktap_fops = {
-+ .owner = THIS_MODULE,
-+ .poll = blktap_poll,
-+ .ioctl = blktap_ioctl,
-+ .open = blktap_open,
-+ .release = blktap_release,
-+ .mmap = blktap_mmap,
-+};
-+
-+
-+static tap_blkif_t *get_next_free_dev(void)
-+{
-+ tap_blkif_t *info;
-+ int minor;
-+
-+ /*
-+ * This is called only from the ioctl, which
-+ * means we should always have interrupts enabled.
-+ */
-+ BUG_ON(irqs_disabled());
-+
-+ spin_lock_irq(&pending_free_lock);
-+
-+ /* tapfds[0] is always NULL */
-+
-+ for (minor = 1; minor < blktap_next_minor; minor++) {
-+ info = tapfds[minor];
-+ /* we could have failed a previous attempt. */
-+ if (!info ||
-+ ((info->dev_inuse == 0) &&
-+ (info->dev_pending == 0)) ) {
-+ info->dev_pending = 1;
-+ goto found;
-+ }
-+ }
-+ info = NULL;
-+ minor = -1;
-+
-+ /*
-+ * We didn't find free device. If we can still allocate
-+ * more, then we grab the next device minor that is
-+ * available. This is done while we are still under
-+ * the protection of the pending_free_lock.
-+ */
-+ if (blktap_next_minor < MAX_TAP_DEV)
-+ minor = blktap_next_minor++;
-+found:
-+ spin_unlock_irq(&pending_free_lock);
-+
-+ if (!info && minor > 0) {
-+ info = kzalloc(sizeof(*info), GFP_KERNEL);
-+ if (unlikely(!info)) {
-+ /*
-+ * If we failed here, try to put back
-+ * the next minor number. But if one
-+ * was just taken, then we just lose this
-+ * minor. We can try to allocate this
-+ * minor again later.
-+ */
-+ spin_lock_irq(&pending_free_lock);
-+ if (blktap_next_minor == minor+1)
-+ blktap_next_minor--;
-+ spin_unlock_irq(&pending_free_lock);
-+ goto out;
-+ }
-+
-+ info->minor = minor;
-+ /*
-+ * Make sure that we have a minor before others can
-+ * see us.
-+ */
-+ wmb();
-+ tapfds[minor] = info;
-+
-+ class_device_create(xen_class, NULL,
-+ MKDEV(blktap_major, minor), NULL,
-+ "blktap%d", minor);
-+ devfs_mk_cdev(MKDEV(blktap_major, minor),
-+ S_IFCHR|S_IRUGO|S_IWUSR, "xen/blktap%d", minor);
-+ }
-+
-+out:
-+ return info;
-+}
-+
-+int dom_to_devid(domid_t domid, int xenbus_id, blkif_t *blkif)
-+{
-+ tap_blkif_t *info;
-+ int i;
-+
-+ for (i = 1; i < blktap_next_minor; i++) {
-+ info = tapfds[i];
-+ if ( info &&
-+ (info->trans.domid == domid) &&
-+ (info->trans.busid == xenbus_id) ) {
-+ info->blkif = blkif;
-+ info->status = RUNNING;
-+ return i;
-+ }
-+ }
-+ return -1;
-+}
-+
-+void signal_tapdisk(int idx)
-+{
-+ tap_blkif_t *info;
-+ struct task_struct *ptask;
-+
-+ info = tapfds[idx];
-+ if ((idx < 0) || (idx > MAX_TAP_DEV) || !info)
-+ return;
-+
-+ if (info->pid > 0) {
-+ ptask = find_task_by_pid(info->pid);
-+ if (ptask)
-+ info->status = CLEANSHUTDOWN;
-+ }
-+ info->blkif = NULL;
-+
-+ return;
-+}
-+
-+static int blktap_open(struct inode *inode, struct file *filp)
-+{
-+ blkif_sring_t *sring;
-+ int idx = iminor(inode) - BLKTAP_MINOR;
-+ tap_blkif_t *info;
-+ int i;
-+
-+ /* ctrl device, treat differently */
-+ if (!idx)
-+ return 0;
-+
-+ info = tapfds[idx];
-+
-+ if ((idx < 0) || (idx > MAX_TAP_DEV) || !info) {
-+ WPRINTK("Unable to open device /dev/xen/blktap%d\n",
-+ idx);
-+ return -ENODEV;
-+ }
-+
-+ DPRINTK("Opening device /dev/xen/blktap%d\n",idx);
-+
-+ /*Only one process can access device at a time*/
-+ if (test_and_set_bit(0, &info->dev_inuse))
-+ return -EBUSY;
-+
-+ info->dev_pending = 0;
-+
-+ /* Allocate the fe ring. */
-+ sring = (blkif_sring_t *)get_zeroed_page(GFP_KERNEL);
-+ if (sring == NULL)
-+ goto fail_nomem;
-+
-+ SetPageReserved(virt_to_page(sring));
-+
-+ SHARED_RING_INIT(sring);
-+ FRONT_RING_INIT(&info->ufe_ring, sring, PAGE_SIZE);
-+
-+ filp->private_data = info;
-+ info->vma = NULL;
-+
-+ info->idx_map = kmalloc(sizeof(unsigned long) * MAX_PENDING_REQS,
-+ GFP_KERNEL);
-+
-+ if (idx > 0) {
-+ init_waitqueue_head(&info->wait);
-+ for (i = 0; i < MAX_PENDING_REQS; i++)
-+ info->idx_map[i] = INVALID_REQ;
-+ }
-+
-+ DPRINTK("Tap open: device /dev/xen/blktap%d\n",idx);
-+ return 0;
-+
-+ fail_nomem:
-+ return -ENOMEM;
-+}
-+
-+static int blktap_release(struct inode *inode, struct file *filp)
-+{
-+ tap_blkif_t *info = filp->private_data;
-+
-+ /* check for control device */
-+ if (!info)
-+ return 0;
-+
-+ info->dev_inuse = 0;
-+ DPRINTK("Freeing device [/dev/xen/blktap%d]\n",info->minor);
-+
-+ /* Free the ring page. */
-+ ClearPageReserved(virt_to_page(info->ufe_ring.sring));
-+ free_page((unsigned long) info->ufe_ring.sring);
-+
-+ /* Clear any active mappings and free foreign map table */
-+ if (info->vma) {
-+ zap_page_range(
-+ info->vma, info->vma->vm_start,
-+ info->vma->vm_end - info->vma->vm_start, NULL);
-+ info->vma = NULL;
-+ }
-+
-+ if ( (info->status != CLEANSHUTDOWN) && (info->blkif != NULL) ) {
-+ if (info->blkif->xenblkd != NULL) {
-+ kthread_stop(info->blkif->xenblkd);
-+ info->blkif->xenblkd = NULL;
-+ }
-+ info->status = CLEANSHUTDOWN;
-+ }
-+ return 0;
-+}
-+
-+
-+/* Note on mmap:
-+ * We need to map pages to user space in a way that will allow the block
-+ * subsystem set up direct IO to them. This couldn't be done before, because
-+ * there isn't really a sane way to translate a user virtual address down to a
-+ * physical address when the page belongs to another domain.
-+ *
-+ * My first approach was to map the page in to kernel memory, add an entry
-+ * for it in the physical frame list (using alloc_lomem_region as in blkback)
-+ * and then attempt to map that page up to user space. This is disallowed
-+ * by xen though, which realizes that we don't really own the machine frame
-+ * underlying the physical page.
-+ *
-+ * The new approach is to provide explicit support for this in xen linux.
-+ * The VMA now has a flag, VM_FOREIGN, to indicate that it contains pages
-+ * mapped from other vms. vma->vm_private_data is set up as a mapping
-+ * from pages to actual page structs. There is a new clause in get_user_pages
-+ * that does the right thing for this sort of mapping.
-+ */
-+static int blktap_mmap(struct file *filp, struct vm_area_struct *vma)
-+{
-+ int size;
-+ struct page **map;
-+ int i;
-+ tap_blkif_t *info = filp->private_data;
-+
-+ if (info == NULL) {
-+ WPRINTK("blktap: mmap, retrieving idx failed\n");
-+ return -ENOMEM;
-+ }
-+
-+ vma->vm_flags |= VM_RESERVED;
-+ vma->vm_ops = &blktap_vm_ops;
-+
-+ size = vma->vm_end - vma->vm_start;
-+ if (size != ((mmap_pages + RING_PAGES) << PAGE_SHIFT)) {
-+ WPRINTK("you _must_ map exactly %d pages!\n",
-+ mmap_pages + RING_PAGES);
-+ return -EAGAIN;
-+ }
-+
-+ size >>= PAGE_SHIFT;
-+ info->rings_vstart = vma->vm_start;
-+ info->user_vstart = info->rings_vstart + (RING_PAGES << PAGE_SHIFT);
-+
-+ /* Map the ring pages to the start of the region and reserve it. */
-+ if (remap_pfn_range(vma, vma->vm_start,
-+ __pa(info->ufe_ring.sring) >> PAGE_SHIFT,
-+ PAGE_SIZE, vma->vm_page_prot)) {
-+ WPRINTK("Mapping user ring failed!\n");
-+ goto fail;
-+ }
-+
-+ /* Mark this VM as containing foreign pages, and set up mappings. */
-+ map = kzalloc(((vma->vm_end - vma->vm_start) >> PAGE_SHIFT)
-+ * sizeof(struct page_struct*),
-+ GFP_KERNEL);
-+ if (map == NULL) {
-+ WPRINTK("Couldn't alloc VM_FOREIGN map.\n");
-+ goto fail;
-+ }
-+
-+ for (i = 0; i < ((vma->vm_end - vma->vm_start) >> PAGE_SHIFT); i++)
-+ map[i] = NULL;
-+
-+ vma->vm_private_data = map;
-+ vma->vm_flags |= VM_FOREIGN;
-+
-+ info->vma = vma;
-+ info->ring_ok = 1;
-+ return 0;
-+ fail:
-+ /* Clear any active mappings. */
-+ zap_page_range(vma, vma->vm_start,
-+ vma->vm_end - vma->vm_start, NULL);
-+
-+ return -ENOMEM;
-+}
-+
-+
-+static int blktap_ioctl(struct inode *inode, struct file *filp,
-+ unsigned int cmd, unsigned long arg)
-+{
-+ tap_blkif_t *info = filp->private_data;
-+
-+ switch(cmd) {
-+ case BLKTAP_IOCTL_KICK_FE:
-+ {
-+ /* There are fe messages to process. */
-+ return blktap_read_ufe_ring(info);
-+ }
-+ case BLKTAP_IOCTL_SETMODE:
-+ {
-+ if (info) {
-+ if (BLKTAP_MODE_VALID(arg)) {
-+ info->mode = arg;
-+ /* XXX: may need to flush rings here. */
-+ DPRINTK("blktap: set mode to %lx\n",
-+ arg);
-+ return 0;
-+ }
-+ }
-+ return 0;
-+ }
-+ case BLKTAP_IOCTL_PRINT_IDXS:
-+ {
-+ if (info) {
-+ printk("User Rings: \n-----------\n");
-+ printk("UF: rsp_cons: %2d, req_prod_prv: %2d "
-+ "| req_prod: %2d, rsp_prod: %2d\n",
-+ info->ufe_ring.rsp_cons,
-+ info->ufe_ring.req_prod_pvt,
-+ info->ufe_ring.sring->req_prod,
-+ info->ufe_ring.sring->rsp_prod);
-+ }
-+ return 0;
-+ }
-+ case BLKTAP_IOCTL_SENDPID:
-+ {
-+ if (info) {
-+ info->pid = (pid_t)arg;
-+ DPRINTK("blktap: pid received %d\n",
-+ info->pid);
-+ }
-+ return 0;
-+ }
-+ case BLKTAP_IOCTL_NEWINTF:
-+ {
-+ uint64_t val = (uint64_t)arg;
-+ domid_translate_t *tr = (domid_translate_t *)&val;
-+
-+ DPRINTK("NEWINTF Req for domid %d and bus id %d\n",
-+ tr->domid, tr->busid);
-+ info = get_next_free_dev();
-+ if (!info) {
-+ WPRINTK("Error initialising /dev/xen/blktap - "
-+ "No more devices\n");
-+ return -1;
-+ }
-+ info->trans.domid = tr->domid;
-+ info->trans.busid = tr->busid;
-+ return info->minor;
-+ }
-+ case BLKTAP_IOCTL_FREEINTF:
-+ {
-+ unsigned long dev = arg;
-+ unsigned long flags;
-+
-+ info = tapfds[dev];
-+
-+ if ((dev > MAX_TAP_DEV) || !info)
-+ return 0; /* should this be an error? */
-+
-+ spin_lock_irqsave(&pending_free_lock, flags);
-+ if (info->dev_pending)
-+ info->dev_pending = 0;
-+ spin_unlock_irqrestore(&pending_free_lock, flags);
-+
-+ return 0;
-+ }
-+ case BLKTAP_IOCTL_MINOR:
-+ {
-+ unsigned long dev = arg;
-+
-+ info = tapfds[dev];
-+
-+ if ((dev > MAX_TAP_DEV) || !info)
-+ return -EINVAL;
-+
-+ return info->minor;
-+ }
-+ case BLKTAP_IOCTL_MAJOR:
-+ return blktap_major;
-+
-+ case BLKTAP_QUERY_ALLOC_REQS:
-+ {
-+ WPRINTK("BLKTAP_QUERY_ALLOC_REQS ioctl: %d/%d\n",
-+ alloc_pending_reqs, blkif_reqs);
-+ return (alloc_pending_reqs/blkif_reqs) * 100;
-+ }
-+ }
-+ return -ENOIOCTLCMD;
-+}
-+
-+static unsigned int blktap_poll(struct file *filp, poll_table *wait)
-+{
-+ tap_blkif_t *info = filp->private_data;
-+
-+ /* do not work on the control device */
-+ if (!info)
-+ return 0;
-+
-+ poll_wait(filp, &info->wait, wait);
-+ if (info->ufe_ring.req_prod_pvt != info->ufe_ring.sring->req_prod) {
-+ RING_PUSH_REQUESTS(&info->ufe_ring);
-+ return POLLIN | POLLRDNORM;
-+ }
-+ return 0;
-+}
-+
-+void blktap_kick_user(int idx)
-+{
-+ tap_blkif_t *info;
-+
-+ info = tapfds[idx];
-+
-+ if ((idx < 0) || (idx > MAX_TAP_DEV) || !info)
-+ return;
-+
-+ wake_up_interruptible(&info->wait);
-+
-+ return;
-+}
-+
-+static int do_block_io_op(blkif_t *blkif);
-+static void dispatch_rw_block_io(blkif_t *blkif,
-+ blkif_request_t *req,
-+ pending_req_t *pending_req);
-+static void make_response(blkif_t *blkif, unsigned long id,
-+ unsigned short op, int st);
-+
-+/******************************************************************
-+ * misc small helpers
-+ */
-+static int req_increase(void)
-+{
-+ int i, j;
-+
-+ if (mmap_alloc >= MAX_PENDING_REQS || mmap_lock)
-+ return -EINVAL;
-+
-+ pending_reqs[mmap_alloc] = kzalloc(sizeof(pending_req_t)
-+ * blkif_reqs, GFP_KERNEL);
-+ foreign_pages[mmap_alloc] = alloc_empty_pages_and_pagevec(mmap_pages);
-+
-+ if (!pending_reqs[mmap_alloc] || !foreign_pages[mmap_alloc])
-+ goto out_of_memory;
-+
-+ DPRINTK("%s: reqs=%d, pages=%d\n",
-+ __FUNCTION__, blkif_reqs, mmap_pages);
-+
-+ for (i = 0; i < MAX_PENDING_REQS; i++) {
-+ list_add_tail(&pending_reqs[mmap_alloc][i].free_list,
-+ &pending_free);
-+ pending_reqs[mmap_alloc][i].mem_idx = mmap_alloc;
-+ for (j = 0; j < BLKIF_MAX_SEGMENTS_PER_REQUEST; j++)
-+ BLKTAP_INVALIDATE_HANDLE(&pending_handle(mmap_alloc,
-+ i, j));
-+ }
-+
-+ mmap_alloc++;
-+ DPRINTK("# MMAPs increased to %d\n",mmap_alloc);
-+ return 0;
-+
-+ out_of_memory:
-+ free_empty_pages_and_pagevec(foreign_pages[mmap_alloc], mmap_pages);
-+ kfree(pending_reqs[mmap_alloc]);
-+ WPRINTK("%s: out of memory\n", __FUNCTION__);
-+ return -ENOMEM;
-+}
-+
-+static void mmap_req_del(int mmap)
-+{
-+ BUG_ON(!spin_is_locked(&pending_free_lock));
-+
-+ kfree(pending_reqs[mmap]);
-+ pending_reqs[mmap] = NULL;
-+
-+ free_empty_pages_and_pagevec(foreign_pages[mmap_alloc], mmap_pages);
-+ foreign_pages[mmap] = NULL;
-+
-+ mmap_lock = 0;
-+ DPRINTK("# MMAPs decreased to %d\n",mmap_alloc);
-+ mmap_alloc--;
-+}
-+
-+static pending_req_t* alloc_req(void)
-+{
-+ pending_req_t *req = NULL;
-+ unsigned long flags;
-+
-+ spin_lock_irqsave(&pending_free_lock, flags);
-+
-+ if (!list_empty(&pending_free)) {
-+ req = list_entry(pending_free.next, pending_req_t, free_list);
-+ list_del(&req->free_list);
-+ }
-+
-+ if (req) {
-+ req->inuse = 1;
-+ alloc_pending_reqs++;
-+ }
-+ spin_unlock_irqrestore(&pending_free_lock, flags);
-+
-+ return req;
-+}
-+
-+static void free_req(pending_req_t *req)
-+{
-+ unsigned long flags;
-+ int was_empty;
-+
-+ spin_lock_irqsave(&pending_free_lock, flags);
-+
-+ alloc_pending_reqs--;
-+ req->inuse = 0;
-+ if (mmap_lock && (req->mem_idx == mmap_alloc-1)) {
-+ mmap_inuse--;
-+ if (mmap_inuse == 0) mmap_req_del(mmap_alloc-1);
-+ spin_unlock_irqrestore(&pending_free_lock, flags);
-+ return;
-+ }
-+ was_empty = list_empty(&pending_free);
-+ list_add(&req->free_list, &pending_free);
-+
-+ spin_unlock_irqrestore(&pending_free_lock, flags);
-+
-+ if (was_empty)
-+ wake_up(&pending_free_wq);
-+}
-+
-+static void fast_flush_area(pending_req_t *req, int k_idx, int u_idx,
-+ int tapidx)
-+{
-+ struct gnttab_unmap_grant_ref unmap[BLKIF_MAX_SEGMENTS_PER_REQUEST*2];
-+ unsigned int i, invcount = 0;
-+ struct grant_handle_pair *khandle;
-+ uint64_t ptep;
-+ int ret, mmap_idx;
-+ unsigned long kvaddr, uvaddr;
-+ tap_blkif_t *info;
-+
-+
-+ info = tapfds[tapidx];
-+
-+ if ((tapidx < 0) || (tapidx > MAX_TAP_DEV) || !info) {
-+ WPRINTK("fast_flush: Couldn't get info!\n");
-+ return;
-+ }
-+
-+ if (info->vma != NULL &&
-+ xen_feature(XENFEAT_auto_translated_physmap)) {
-+ down_write(&info->vma->vm_mm->mmap_sem);
-+ zap_page_range(info->vma,
-+ MMAP_VADDR(info->user_vstart, u_idx, 0),
-+ req->nr_pages << PAGE_SHIFT, NULL);
-+ up_write(&info->vma->vm_mm->mmap_sem);
-+ }
-+
-+ mmap_idx = req->mem_idx;
-+
-+ for (i = 0; i < req->nr_pages; i++) {
-+ kvaddr = idx_to_kaddr(mmap_idx, k_idx, i);
-+ uvaddr = MMAP_VADDR(info->user_vstart, u_idx, i);
-+
-+ khandle = &pending_handle(mmap_idx, k_idx, i);
-+
-+ if (khandle->kernel != INVALID_GRANT_HANDLE) {
-+ gnttab_set_unmap_op(&unmap[invcount],
-+ idx_to_kaddr(mmap_idx, k_idx, i),
-+ GNTMAP_host_map, khandle->kernel);
-+ invcount++;
-+ }
-+
-+ if (khandle->user != INVALID_GRANT_HANDLE) {
-+ BUG_ON(xen_feature(XENFEAT_auto_translated_physmap));
-+ if (create_lookup_pte_addr(
-+ info->vma->vm_mm,
-+ MMAP_VADDR(info->user_vstart, u_idx, i),
-+ &ptep) !=0) {
-+ WPRINTK("Couldn't get a pte addr!\n");
-+ return;
-+ }
-+
-+ gnttab_set_unmap_op(&unmap[invcount], ptep,
-+ GNTMAP_host_map
-+ | GNTMAP_application_map
-+ | GNTMAP_contains_pte,
-+ khandle->user);
-+ invcount++;
-+ }
-+
-+ BLKTAP_INVALIDATE_HANDLE(khandle);
-+ }
-+ ret = HYPERVISOR_grant_table_op(
-+ GNTTABOP_unmap_grant_ref, unmap, invcount);
-+ BUG_ON(ret);
-+
-+ if (info->vma != NULL && !xen_feature(XENFEAT_auto_translated_physmap))
-+ zap_page_range(info->vma,
-+ MMAP_VADDR(info->user_vstart, u_idx, 0),
-+ req->nr_pages << PAGE_SHIFT, NULL);
-+}
-+
-+/******************************************************************
-+ * SCHEDULER FUNCTIONS
-+ */
-+
-+static void print_stats(blkif_t *blkif)
-+{
-+ printk(KERN_DEBUG "%s: oo %3d | rd %4d | wr %4d\n",
-+ current->comm, blkif->st_oo_req,
-+ blkif->st_rd_req, blkif->st_wr_req);
-+ blkif->st_print = jiffies + msecs_to_jiffies(10 * 1000);
-+ blkif->st_rd_req = 0;
-+ blkif->st_wr_req = 0;
-+ blkif->st_oo_req = 0;
-+}
-+
-+int tap_blkif_schedule(void *arg)
-+{
-+ blkif_t *blkif = arg;
-+
-+ blkif_get(blkif);
-+
-+ if (debug_lvl)
-+ printk(KERN_DEBUG "%s: started\n", current->comm);
-+
-+ while (!kthread_should_stop()) {
-+ wait_event_interruptible(
-+ blkif->wq,
-+ blkif->waiting_reqs || kthread_should_stop());
-+ wait_event_interruptible(
-+ pending_free_wq,
-+ !list_empty(&pending_free) || kthread_should_stop());
-+
-+ blkif->waiting_reqs = 0;
-+ smp_mb(); /* clear flag *before* checking for work */
-+
-+ if (do_block_io_op(blkif))
-+ blkif->waiting_reqs = 1;
-+
-+ if (log_stats && time_after(jiffies, blkif->st_print))
-+ print_stats(blkif);
-+ }
-+
-+ if (log_stats)
-+ print_stats(blkif);
-+ if (debug_lvl)
-+ printk(KERN_DEBUG "%s: exiting\n", current->comm);
-+
-+ blkif->xenblkd = NULL;
-+ blkif_put(blkif);
-+
-+ return 0;
-+}
-+
-+/******************************************************************
-+ * COMPLETION CALLBACK -- Called by user level ioctl()
-+ */
-+
-+static int blktap_read_ufe_ring(tap_blkif_t *info)
-+{
-+ /* This is called to read responses from the UFE ring. */
-+ RING_IDX i, j, rp;
-+ blkif_response_t *resp;
-+ blkif_t *blkif=NULL;
-+ int pending_idx, usr_idx, mmap_idx;
-+ pending_req_t *pending_req;
-+
-+ if (!info)
-+ return 0;
-+
-+ /* We currently only forward packets in INTERCEPT_FE mode. */
-+ if (!(info->mode & BLKTAP_MODE_INTERCEPT_FE))
-+ return 0;
-+
-+ /* for each outstanding message on the UFEring */
-+ rp = info->ufe_ring.sring->rsp_prod;
-+ rmb();
-+
-+ for (i = info->ufe_ring.rsp_cons; i != rp; i++) {
-+ blkif_response_t res;
-+ resp = RING_GET_RESPONSE(&info->ufe_ring, i);
-+ memcpy(&res, resp, sizeof(res));
-+ mb(); /* rsp_cons read by RING_FULL() in do_block_io_op(). */
-+ ++info->ufe_ring.rsp_cons;
-+
-+ /*retrieve [usr_idx] to [mmap_idx,pending_idx] mapping*/
-+ usr_idx = (int)res.id;
-+ pending_idx = MASK_PEND_IDX(ID_TO_IDX(info->idx_map[usr_idx]));
-+ mmap_idx = ID_TO_MIDX(info->idx_map[usr_idx]);
-+
-+ if ( (mmap_idx >= mmap_alloc) ||
-+ (ID_TO_IDX(info->idx_map[usr_idx]) >= MAX_PENDING_REQS) )
-+ WPRINTK("Incorrect req map"
-+ "[%d], internal map [%d,%d (%d)]\n",
-+ usr_idx, mmap_idx,
-+ ID_TO_IDX(info->idx_map[usr_idx]),
-+ MASK_PEND_IDX(
-+ ID_TO_IDX(info->idx_map[usr_idx])));
-+
-+ pending_req = &pending_reqs[mmap_idx][pending_idx];
-+ blkif = pending_req->blkif;
-+
-+ for (j = 0; j < pending_req->nr_pages; j++) {
-+
-+ unsigned long kvaddr, uvaddr;
-+ struct page **map = info->vma->vm_private_data;
-+ struct page *pg;
-+ int offset;
-+
-+ uvaddr = MMAP_VADDR(info->user_vstart, usr_idx, j);
-+ kvaddr = idx_to_kaddr(mmap_idx, pending_idx, j);
-+
-+ pg = pfn_to_page(__pa(kvaddr) >> PAGE_SHIFT);
-+ ClearPageReserved(pg);
-+ offset = (uvaddr - info->vma->vm_start)
-+ >> PAGE_SHIFT;
-+ map[offset] = NULL;
-+ }
-+ fast_flush_area(pending_req, pending_idx, usr_idx, info->minor);
-+ info->idx_map[usr_idx] = INVALID_REQ;
-+ make_response(blkif, pending_req->id, res.operation,
-+ res.status);
-+ blkif_put(pending_req->blkif);
-+ free_req(pending_req);
-+ }
-+
-+ return 0;
-+}
-+
-+
-+/******************************************************************************
-+ * NOTIFICATION FROM GUEST OS.
-+ */
-+
-+static void blkif_notify_work(blkif_t *blkif)
-+{
-+ blkif->waiting_reqs = 1;
-+ wake_up(&blkif->wq);
-+}
-+
-+irqreturn_t tap_blkif_be_int(int irq, void *dev_id, struct pt_regs *regs)
-+{
-+ blkif_notify_work(dev_id);
-+ return IRQ_HANDLED;
-+}
-+
-+
-+
-+/******************************************************************
-+ * DOWNWARD CALLS -- These interface with the block-device layer proper.
-+ */
-+static int print_dbug = 1;
-+static int do_block_io_op(blkif_t *blkif)
-+{
-+ blkif_back_ring_t *blk_ring = &blkif->blk_ring;
-+ blkif_request_t req;
-+ pending_req_t *pending_req;
-+ RING_IDX rc, rp;
-+ int more_to_do = 0;
-+ tap_blkif_t *info;
-+
-+ rc = blk_ring->req_cons;
-+ rp = blk_ring->sring->req_prod;
-+ rmb(); /* Ensure we see queued requests up to 'rp'. */
-+
-+ /*Check blkif has corresponding UE ring*/
-+ if (blkif->dev_num < 0) {
-+ /*oops*/
-+ if (print_dbug) {
-+ WPRINTK("Corresponding UE "
-+ "ring does not exist!\n");
-+ print_dbug = 0; /*We only print this message once*/
-+ }
-+ return 0;
-+ }
-+
-+ info = tapfds[blkif->dev_num];
-+
-+ if (blkif->dev_num > MAX_TAP_DEV || !info || !info->dev_inuse) {
-+ if (print_dbug) {
-+ WPRINTK("Can't get UE info!\n");
-+ print_dbug = 0;
-+ }
-+ return 0;
-+ }
-+
-+ while (rc != rp) {
-+
-+ if (RING_FULL(&info->ufe_ring)) {
-+ WPRINTK("RING_FULL! More to do\n");
-+ more_to_do = 1;
-+ break;
-+ }
-+
-+ if (RING_REQUEST_CONS_OVERFLOW(blk_ring, rc)) {
-+ WPRINTK("RING_REQUEST_CONS_OVERFLOW!"
-+ " More to do\n");
-+ more_to_do = 1;
-+ break;
-+ }
-+
-+ pending_req = alloc_req();
-+ if (NULL == pending_req) {
-+ blkif->st_oo_req++;
-+ more_to_do = 1;
-+ break;
-+ }
-+
-+ memcpy(&req, RING_GET_REQUEST(blk_ring, rc), sizeof(req));
-+ blk_ring->req_cons = ++rc; /* before make_response() */
-+
-+ switch (req.operation) {
-+ case BLKIF_OP_READ:
-+ blkif->st_rd_req++;
-+ dispatch_rw_block_io(blkif, &req, pending_req);
-+ break;
-+
-+ case BLKIF_OP_WRITE:
-+ blkif->st_wr_req++;
-+ dispatch_rw_block_io(blkif, &req, pending_req);
-+ break;
-+
-+ default:
-+ WPRINTK("unknown operation [%d]\n",
-+ req.operation);
-+ make_response(blkif, req.id, req.operation,
-+ BLKIF_RSP_ERROR);
-+ free_req(pending_req);
-+ break;
-+ }
-+ }
-+
-+ blktap_kick_user(blkif->dev_num);
-+
-+ return more_to_do;
-+}
-+
-+static void dispatch_rw_block_io(blkif_t *blkif,
-+ blkif_request_t *req,
-+ pending_req_t *pending_req)
-+{
-+ extern void ll_rw_block(int rw, int nr, struct buffer_head * bhs[]);
-+ int op, operation = (req->operation == BLKIF_OP_WRITE) ? WRITE : READ;
-+ struct gnttab_map_grant_ref map[BLKIF_MAX_SEGMENTS_PER_REQUEST*2];
-+ unsigned int nseg;
-+ int ret, i;
-+ tap_blkif_t *info;
-+ uint64_t sector;
-+ blkif_request_t *target;
-+ int pending_idx = RTN_PEND_IDX(pending_req,pending_req->mem_idx);
-+ int usr_idx;
-+ uint16_t mmap_idx = pending_req->mem_idx;
-+
-+ if (blkif->dev_num < 0 || blkif->dev_num > MAX_TAP_DEV)
-+ goto fail_response;
-+
-+ info = tapfds[blkif->dev_num];
-+ if (info == NULL)
-+ goto fail_response;
-+
-+ /* Check we have space on user ring - should never fail. */
-+ usr_idx = GET_NEXT_REQ(info->idx_map);
-+ if (usr_idx == INVALID_REQ) {
-+ BUG();
-+ goto fail_response;
-+ }
-+
-+ /* Check that number of segments is sane. */
-+ nseg = req->nr_segments;
-+ if ( unlikely(nseg == 0) ||
-+ unlikely(nseg > BLKIF_MAX_SEGMENTS_PER_REQUEST) ) {
-+ WPRINTK("Bad number of segments in request (%d)\n", nseg);
-+ goto fail_response;
-+ }
-+
-+ /* Make sure userspace is ready. */
-+ if (!info->ring_ok) {
-+ WPRINTK("blktap: ring not ready for requests!\n");
-+ goto fail_response;
-+ }
-+
-+ if (RING_FULL(&info->ufe_ring)) {
-+ WPRINTK("blktap: fe_ring is full, can't add "
-+ "IO Request will be dropped. %d %d\n",
-+ RING_SIZE(&info->ufe_ring),
-+ RING_SIZE(&blkif->blk_ring));
-+ goto fail_response;
-+ }
-+
-+ pending_req->blkif = blkif;
-+ pending_req->id = req->id;
-+ pending_req->operation = operation;
-+ pending_req->status = BLKIF_RSP_OKAY;
-+ pending_req->nr_pages = nseg;
-+ op = 0;
-+ for (i = 0; i < nseg; i++) {
-+ unsigned long uvaddr;
-+ unsigned long kvaddr;
-+ uint64_t ptep;
-+ uint32_t flags;
-+
-+ uvaddr = MMAP_VADDR(info->user_vstart, usr_idx, i);
-+ kvaddr = idx_to_kaddr(mmap_idx, pending_idx, i);
-+
-+ sector = req->sector_number + ((PAGE_SIZE / 512) * i);
-+ if( (blkif->sectors > 0) && (sector >= blkif->sectors) ) {
-+ WPRINTK("BLKTAP: Sector request greater"
-+ "than size\n");
-+ WPRINTK("BLKTAP: %s request sector"
-+ "[%llu,%llu], Total [%llu]\n",
-+ (req->operation ==
-+ BLKIF_OP_WRITE ? "WRITE" : "READ"),
-+ (long long unsigned) sector,
-+ (long long unsigned) sector>>9,
-+ (long long unsigned) blkif->sectors);
-+ }
-+
-+ flags = GNTMAP_host_map;
-+ if (operation == WRITE)
-+ flags |= GNTMAP_readonly;
-+ gnttab_set_map_op(&map[op], kvaddr, flags,
-+ req->seg[i].gref, blkif->domid);
-+ op++;
-+
-+ if (!xen_feature(XENFEAT_auto_translated_physmap)) {
-+ /* Now map it to user. */
-+ ret = create_lookup_pte_addr(info->vma->vm_mm,
-+ uvaddr, &ptep);
-+ if (ret) {
-+ WPRINTK("Couldn't get a pte addr!\n");
-+ goto fail_flush;
-+ }
-+
-+ flags = GNTMAP_host_map | GNTMAP_application_map
-+ | GNTMAP_contains_pte;
-+ if (operation == WRITE)
-+ flags |= GNTMAP_readonly;
-+ gnttab_set_map_op(&map[op], ptep, flags,
-+ req->seg[i].gref, blkif->domid);
-+ op++;
-+ }
-+ }
-+
-+ ret = HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, map, op);
-+ BUG_ON(ret);
-+
-+ if (!xen_feature(XENFEAT_auto_translated_physmap)) {
-+ for (i = 0; i < (nseg*2); i+=2) {
-+ unsigned long uvaddr;
-+ unsigned long kvaddr;
-+ unsigned long offset;
-+ struct page *pg;
-+
-+ uvaddr = MMAP_VADDR(info->user_vstart, usr_idx, i/2);
-+ kvaddr = idx_to_kaddr(mmap_idx, pending_idx, i/2);
-+
-+ if (unlikely(map[i].status != 0)) {
-+ WPRINTK("invalid kernel buffer -- "
-+ "could not remap it\n");
-+ ret |= 1;
-+ map[i].handle = INVALID_GRANT_HANDLE;
-+ }
-+
-+ if (unlikely(map[i+1].status != 0)) {
-+ WPRINTK("invalid user buffer -- "
-+ "could not remap it\n");
-+ ret |= 1;
-+ map[i+1].handle = INVALID_GRANT_HANDLE;
-+ }
-+
-+ pending_handle(mmap_idx, pending_idx, i/2).kernel
-+ = map[i].handle;
-+ pending_handle(mmap_idx, pending_idx, i/2).user
-+ = map[i+1].handle;
-+
-+ if (ret)
-+ continue;
-+
-+ set_phys_to_machine(__pa(kvaddr) >> PAGE_SHIFT,
-+ FOREIGN_FRAME(map[i].dev_bus_addr
-+ >> PAGE_SHIFT));
-+ offset = (uvaddr - info->vma->vm_start) >> PAGE_SHIFT;
-+ pg = pfn_to_page(__pa(kvaddr) >> PAGE_SHIFT);
-+ ((struct page **)info->vma->vm_private_data)[offset] =
-+ pg;
-+ }
-+ } else {
-+ for (i = 0; i < nseg; i++) {
-+ unsigned long uvaddr;
-+ unsigned long kvaddr;
-+ unsigned long offset;
-+ struct page *pg;
-+
-+ uvaddr = MMAP_VADDR(info->user_vstart, usr_idx, i);
-+ kvaddr = idx_to_kaddr(mmap_idx, pending_idx, i);
-+
-+ if (unlikely(map[i].status != 0)) {
-+ WPRINTK("invalid kernel buffer -- "
-+ "could not remap it\n");
-+ ret |= 1;
-+ map[i].handle = INVALID_GRANT_HANDLE;
-+ }
-+
-+ pending_handle(mmap_idx, pending_idx, i).kernel
-+ = map[i].handle;
-+
-+ if (ret)
-+ continue;
-+
-+ offset = (uvaddr - info->vma->vm_start) >> PAGE_SHIFT;
-+ pg = pfn_to_page(__pa(kvaddr) >> PAGE_SHIFT);
-+ ((struct page **)info->vma->vm_private_data)[offset] =
-+ pg;
-+ }
-+ }
-+
-+ if (ret)
-+ goto fail_flush;
-+
-+ if (xen_feature(XENFEAT_auto_translated_physmap))
-+ down_write(&info->vma->vm_mm->mmap_sem);
-+ /* Mark mapped pages as reserved: */
-+ for (i = 0; i < req->nr_segments; i++) {
-+ unsigned long kvaddr;
-+ struct page *pg;
-+
-+ kvaddr = idx_to_kaddr(mmap_idx, pending_idx, i);
-+ pg = pfn_to_page(__pa(kvaddr) >> PAGE_SHIFT);
-+ SetPageReserved(pg);
-+ if (xen_feature(XENFEAT_auto_translated_physmap)) {
-+ ret = vm_insert_page(info->vma,
-+ MMAP_VADDR(info->user_vstart,
-+ usr_idx, i), pg);
-+ if (ret) {
-+ up_write(&info->vma->vm_mm->mmap_sem);
-+ goto fail_flush;
-+ }
-+ }
-+ }
-+ if (xen_feature(XENFEAT_auto_translated_physmap))
-+ up_write(&info->vma->vm_mm->mmap_sem);
-+
-+ /*record [mmap_idx,pending_idx] to [usr_idx] mapping*/
-+ info->idx_map[usr_idx] = MAKE_ID(mmap_idx, pending_idx);
-+
-+ blkif_get(blkif);
-+ /* Finally, write the request message to the user ring. */
-+ target = RING_GET_REQUEST(&info->ufe_ring,
-+ info->ufe_ring.req_prod_pvt);
-+ memcpy(target, req, sizeof(*req));
-+ target->id = usr_idx;
-+ wmb(); /* blktap_poll() reads req_prod_pvt asynchronously */
-+ info->ufe_ring.req_prod_pvt++;
-+ return;
-+
-+ fail_flush:
-+ WPRINTK("Reached Fail_flush\n");
-+ fast_flush_area(pending_req, pending_idx, usr_idx, blkif->dev_num);
-+ fail_response:
-+ make_response(blkif, req->id, req->operation, BLKIF_RSP_ERROR);
-+ free_req(pending_req);
-+}
-+
-+
-+
-+/******************************************************************
-+ * MISCELLANEOUS SETUP / TEARDOWN / DEBUGGING
-+ */
-+
-+
-+static void make_response(blkif_t *blkif, unsigned long id,
-+ unsigned short op, int st)
-+{
-+ blkif_response_t *resp;
-+ unsigned long flags;
-+ blkif_back_ring_t *blk_ring = &blkif->blk_ring;
-+ int more_to_do = 0;
-+ int notify;
-+
-+ spin_lock_irqsave(&blkif->blk_ring_lock, flags);
-+ /* Place on the response ring for the relevant domain. */
-+ resp = RING_GET_RESPONSE(blk_ring, blk_ring->rsp_prod_pvt);
-+ resp->id = id;
-+ resp->operation = op;
-+ resp->status = st;
-+ blk_ring->rsp_prod_pvt++;
-+ RING_PUSH_RESPONSES_AND_CHECK_NOTIFY(blk_ring, notify);
-+
-+ if (blk_ring->rsp_prod_pvt == blk_ring->req_cons) {
-+ /*
-+ * Tail check for pending requests. Allows frontend to avoid
-+ * notifications if requests are already in flight (lower
-+ * overheads and promotes batching).
-+ */
-+ RING_FINAL_CHECK_FOR_REQUESTS(blk_ring, more_to_do);
-+ } else if (RING_HAS_UNCONSUMED_REQUESTS(blk_ring)) {
-+ more_to_do = 1;
-+
-+ }
-+ spin_unlock_irqrestore(&blkif->blk_ring_lock, flags);
-+ if (more_to_do)
-+ blkif_notify_work(blkif);
-+ if (notify)
-+ notify_remote_via_irq(blkif->irq);
-+}
-+
-+static int __init blkif_init(void)
-+{
-+ int i,ret,blktap_dir;
-+
-+ if (!is_running_on_xen())
-+ return -ENODEV;
-+
-+ INIT_LIST_HEAD(&pending_free);
-+ for(i = 0; i < 2; i++) {
-+ ret = req_increase();
-+ if (ret)
-+ break;
-+ }
-+ if (i == 0)
-+ return ret;
-+
-+ tap_blkif_interface_init();
-+
-+ alloc_pending_reqs = 0;
-+
-+ tap_blkif_xenbus_init();
-+
-+ /* Dynamically allocate a major for this device */
-+ ret = register_chrdev(0, "blktap", &blktap_fops);
-+ blktap_dir = devfs_mk_dir(NULL, "xen", 0, NULL);
-+
-+ if ( (ret < 0)||(blktap_dir < 0) ) {
-+ WPRINTK("Couldn't register /dev/xen/blktap\n");
-+ return -ENOMEM;
-+ }
-+
-+ blktap_major = ret;
-+
-+ /* tapfds[0] is always NULL */
-+ blktap_next_minor++;
-+
-+ ret = devfs_mk_cdev(MKDEV(blktap_major, i),
-+ S_IFCHR|S_IRUGO|S_IWUSR, "xen/blktap%d", i);
-+
-+ if(ret != 0)
-+ return -ENOMEM;
-+
-+ DPRINTK("Created misc_dev [/dev/xen/blktap%d]\n",i);
-+
-+ /* Make sure the xen class exists */
-+ if (!setup_xen_class()) {
-+ /*
-+ * This will allow udev to create the blktap ctrl device.
-+ * We only want to create blktap0 first. We don't want
-+ * to flood the sysfs system with needless blktap devices.
-+ * We only create the device when a request of a new device is
-+ * made.
-+ */
-+ class_device_create(xen_class, NULL,
-+ MKDEV(blktap_major, 0), NULL,
-+ "blktap0");
-+ } else {
-+ /* this is bad, but not fatal */
-+ WPRINTK("blktap: sysfs xen_class not created\n");
-+ }
-+
-+ DPRINTK("Blktap device successfully created\n");
-+
-+ return 0;
-+}
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 drivers/xen/blktap/Makefile
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/drivers/xen/blktap/Makefile Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,5 @@
++LINUXINCLUDE += -I../xen/include/public/io
+
-+module_init(blkif_init);
++obj-$(CONFIG_XEN_BLKDEV_TAP) := xenblktap.o
+
-+MODULE_LICENSE("Dual BSD/GPL");
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/drivers/xen/blktap/blktapmain.c source/drivers/xen/blktap/blktapmain.c
---- /scratch/src/linux-2.6.20.3/drivers/xen/blktap/blktapmain.c 1970-01-01 01:00:00.000000000 +0100
-+++ source/drivers/xen/blktap/blktapmain.c 2007-03-21 14:49:46.000000000 +0100
-@@ -0,0 +1,1503 @@
++xenblktap-y := xenbus.o interface.o blktap.o
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 drivers/xen/blktap/blktap.c
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/drivers/xen/blktap/blktap.c Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,1524 @@
+/******************************************************************************
+ * drivers/xen/blktap/blktap.c
+ *
@@ -49215,6 +46359,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#include <asm/hypervisor.h>
+#include "common.h"
+#include <xen/balloon.h>
++#include <xen/driver_util.h>
+#include <linux/kernel.h>
+#include <linux/fs.h>
+#include <linux/mm.h>
@@ -49228,30 +46373,6 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#define MAX_TAP_DEV 256 /*the maximum number of tapdisk ring devices */
+#define MAX_DEV_NAME 100 /*the max tapdisk ring device name e.g. blktap0 */
+
-+
-+struct class *xen_class;
-+EXPORT_SYMBOL_GPL(xen_class);
-+
-+/*
-+ * Setup the xen class. This should probably go in another file, but
-+ * since blktap is the only user of it so far, it gets to keep it.
-+ */
-+int setup_xen_class(void)
-+{
-+ int ret;
-+
-+ if (xen_class)
-+ return 0;
-+
-+ xen_class = class_create(THIS_MODULE, "xen");
-+ if ((ret = IS_ERR(xen_class))) {
-+ xen_class = NULL;
-+ return ret;
-+ }
-+
-+ return 0;
-+}
-+
+/*
+ * The maximum number of requests that can be outstanding at any time
+ * is determined by
@@ -49326,7 +46447,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ */
+typedef struct {
+ blkif_t *blkif;
-+ unsigned long id;
++ u64 id;
+ unsigned short mem_idx;
+ int nr_pages;
+ atomic_t pendcnt;
@@ -49502,7 +46623,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ unsigned int cmd, unsigned long arg);
+static unsigned int blktap_poll(struct file *file, poll_table *wait);
+
-+static struct file_operations blktap_fops = {
++static const struct file_operations blktap_fops = {
+ .owner = THIS_MODULE,
+ .poll = blktap_poll,
+ .ioctl = blktap_ioctl,
@@ -49514,6 +46635,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+
+static tap_blkif_t *get_next_free_dev(void)
+{
++ struct class *class;
+ tap_blkif_t *info;
+ int minor;
+
@@ -49576,9 +46698,10 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ wmb();
+ tapfds[minor] = info;
+
-+ class_device_create(xen_class, NULL,
-+ MKDEV(blktap_major, minor), NULL,
-+ "blktap%d", minor);
++ if ((class = get_xen_class()) != NULL)
++ class_device_create(class, NULL,
++ MKDEV(blktap_major, minor), NULL,
++ "blktap%d", minor);
+ }
+
+out:
@@ -49929,7 +47052,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+static void dispatch_rw_block_io(blkif_t *blkif,
+ blkif_request_t *req,
+ pending_req_t *pending_req);
-+static void make_response(blkif_t *blkif, unsigned long id,
++static void make_response(blkif_t *blkif, u64 id,
+ unsigned short op, int st);
+
+/******************************************************************
@@ -50258,15 +47381,15 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+static int print_dbug = 1;
+static int do_block_io_op(blkif_t *blkif)
+{
-+ blkif_back_ring_t *blk_ring = &blkif->blk_ring;
++ blkif_back_rings_t *blk_rings = &blkif->blk_rings;
+ blkif_request_t req;
+ pending_req_t *pending_req;
+ RING_IDX rc, rp;
+ int more_to_do = 0;
+ tap_blkif_t *info;
+
-+ rc = blk_ring->req_cons;
-+ rp = blk_ring->sring->req_prod;
++ rc = blk_rings->common.req_cons;
++ rp = blk_rings->common.sring->req_prod;
+ rmb(); /* Ensure we see queued requests up to 'rp'. */
+
+ /*Check blkif has corresponding UE ring*/
@@ -50297,8 +47420,8 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ more_to_do = 1;
+ break;
+ }
-+
-+ if (RING_REQUEST_CONS_OVERFLOW(blk_ring, rc)) {
++
++ if (RING_REQUEST_CONS_OVERFLOW(&blk_rings->common, rc)) {
+ WPRINTK("RING_REQUEST_CONS_OVERFLOW!"
+ " More to do\n");
+ more_to_do = 1;
@@ -50312,8 +47435,21 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ break;
+ }
+
-+ memcpy(&req, RING_GET_REQUEST(blk_ring, rc), sizeof(req));
-+ blk_ring->req_cons = ++rc; /* before make_response() */
++ switch (blkif->blk_protocol) {
++ case BLKIF_PROTOCOL_NATIVE:
++ memcpy(&req, RING_GET_REQUEST(&blk_rings->native, rc),
++ sizeof(req));
++ break;
++ case BLKIF_PROTOCOL_X86_32:
++ blkif_get_x86_32_req(&req, RING_GET_REQUEST(&blk_rings->x86_32, rc));
++ break;
++ case BLKIF_PROTOCOL_X86_64:
++ blkif_get_x86_64_req(&req, RING_GET_REQUEST(&blk_rings->x86_64, rc));
++ break;
++ default:
++ BUG();
++ }
++ blk_rings->common.req_cons = ++rc; /* before make_response() */
+
+ switch (req.operation) {
+ case BLKIF_OP_READ:
@@ -50349,7 +47485,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ int op, operation = (req->operation == BLKIF_OP_WRITE) ? WRITE : READ;
+ struct gnttab_map_grant_ref map[BLKIF_MAX_SEGMENTS_PER_REQUEST*2];
+ unsigned int nseg;
-+ int ret, i;
++ int ret, i, nr_sects = 0;
+ tap_blkif_t *info;
+ uint64_t sector;
+ blkif_request_t *target;
@@ -50389,7 +47525,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ WPRINTK("blktap: fe_ring is full, can't add "
+ "IO Request will be dropped. %d %d\n",
+ RING_SIZE(&info->ufe_ring),
-+ RING_SIZE(&blkif->blk_ring));
++ RING_SIZE(&blkif->blk_rings.common));
+ goto fail_response;
+ }
+
@@ -50445,6 +47581,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ req->seg[i].gref, blkif->domid);
+ op++;
+ }
++
++ nr_sects += (req->seg[i].last_sect -
++ req->seg[i].first_sect + 1);
+ }
+
+ ret = HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, map, op);
@@ -50557,6 +47696,12 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ target->id = usr_idx;
+ wmb(); /* blktap_poll() reads req_prod_pvt asynchronously */
+ info->ufe_ring.req_prod_pvt++;
++
++ if (operation == READ)
++ blkif->st_rd_sect += nr_sects;
++ else if (operation == WRITE)
++ blkif->st_wr_sect += nr_sects;
++
+ return;
+
+ fail_flush:
@@ -50574,35 +47719,54 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ */
+
+
-+static void make_response(blkif_t *blkif, unsigned long id,
++static void make_response(blkif_t *blkif, u64 id,
+ unsigned short op, int st)
+{
-+ blkif_response_t *resp;
++ blkif_response_t resp;
+ unsigned long flags;
-+ blkif_back_ring_t *blk_ring = &blkif->blk_ring;
++ blkif_back_rings_t *blk_rings = &blkif->blk_rings;
+ int more_to_do = 0;
+ int notify;
+
++ resp.id = id;
++ resp.operation = op;
++ resp.status = st;
++
+ spin_lock_irqsave(&blkif->blk_ring_lock, flags);
-+ /* Place on the response ring for the relevant domain. */
-+ resp = RING_GET_RESPONSE(blk_ring, blk_ring->rsp_prod_pvt);
-+ resp->id = id;
-+ resp->operation = op;
-+ resp->status = st;
-+ blk_ring->rsp_prod_pvt++;
-+ RING_PUSH_RESPONSES_AND_CHECK_NOTIFY(blk_ring, notify);
-+
-+ if (blk_ring->rsp_prod_pvt == blk_ring->req_cons) {
++ /* Place on the response ring for the relevant domain. */
++ switch (blkif->blk_protocol) {
++ case BLKIF_PROTOCOL_NATIVE:
++ memcpy(RING_GET_RESPONSE(&blk_rings->native,
++ blk_rings->native.rsp_prod_pvt),
++ &resp, sizeof(resp));
++ break;
++ case BLKIF_PROTOCOL_X86_32:
++ memcpy(RING_GET_RESPONSE(&blk_rings->x86_32,
++ blk_rings->x86_32.rsp_prod_pvt),
++ &resp, sizeof(resp));
++ break;
++ case BLKIF_PROTOCOL_X86_64:
++ memcpy(RING_GET_RESPONSE(&blk_rings->x86_64,
++ blk_rings->x86_64.rsp_prod_pvt),
++ &resp, sizeof(resp));
++ break;
++ default:
++ BUG();
++ }
++ blk_rings->common.rsp_prod_pvt++;
++ RING_PUSH_RESPONSES_AND_CHECK_NOTIFY(&blk_rings->common, notify);
++
++ if (blk_rings->common.rsp_prod_pvt == blk_rings->common.req_cons) {
+ /*
+ * Tail check for pending requests. Allows frontend to avoid
+ * notifications if requests are already in flight (lower
+ * overheads and promotes batching).
+ */
-+ RING_FINAL_CHECK_FOR_REQUESTS(blk_ring, more_to_do);
-+ } else if (RING_HAS_UNCONSUMED_REQUESTS(blk_ring)) {
++ RING_FINAL_CHECK_FOR_REQUESTS(&blk_rings->common, more_to_do);
++ } else if (RING_HAS_UNCONSUMED_REQUESTS(&blk_rings->common)) {
+ more_to_do = 1;
++ }
+
-+ }
+ spin_unlock_irqrestore(&blkif->blk_ring_lock, flags);
+ if (more_to_do)
+ blkif_notify_work(blkif);
@@ -50612,7 +47776,8 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+
+static int __init blkif_init(void)
+{
-+ int i,ret;
++ int i, ret;
++ struct class *class;
+
+ if (!is_running_on_xen())
+ return -ENODEV;
@@ -50648,7 +47813,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ DPRINTK("Created misc_dev [/dev/xen/blktap%d]\n",i);
+
+ /* Make sure the xen class exists */
-+ if (!setup_xen_class()) {
++ if ((class = get_xen_class()) != NULL) {
+ /*
+ * This will allow udev to create the blktap ctrl device.
+ * We only want to create blktap0 first. We don't want
@@ -50656,7 +47821,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ * We only create the device when a request of a new device is
+ * made.
+ */
-+ class_device_create(xen_class, NULL,
++ class_device_create(class, NULL,
+ MKDEV(blktap_major, 0), NULL,
+ "blktap0");
+ } else {
@@ -50672,10 +47837,10 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+module_init(blkif_init);
+
+MODULE_LICENSE("Dual BSD/GPL");
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/drivers/xen/blktap/common.h source/drivers/xen/blktap/common.h
---- /scratch/src/linux-2.6.20.3/drivers/xen/blktap/common.h 1970-01-01 01:00:00.000000000 +0100
-+++ source/drivers/xen/blktap/common.h 2007-03-20 21:26:48.000000000 +0100
-@@ -0,0 +1,120 @@
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 drivers/xen/blktap/common.h
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/drivers/xen/blktap/common.h Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,121 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License version 2
@@ -50716,8 +47881,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#include <asm/pgalloc.h>
+#include <xen/evtchn.h>
+#include <asm/hypervisor.h>
-+#include <xen/interface/io/blkif.h>
-+#include <xen/interface/io/ring.h>
++#include <xen/blkif.h>
+#include <xen/gnttab.h>
+#include <xen/driver_util.h>
+
@@ -50733,10 +47897,10 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ domid_t domid;
+ unsigned int handle;
+ /* Physical parameters of the comms window. */
-+ unsigned int evtchn;
+ unsigned int irq;
+ /* Comms information. */
-+ blkif_back_ring_t blk_ring;
++ enum blkif_protocol blk_protocol;
++ blkif_back_rings_t blk_rings;
+ struct vm_struct *blk_ring_area;
+ /* Back pointer to the backend_info. */
+ struct backend_info *be;
@@ -50754,6 +47918,8 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ int st_rd_req;
+ int st_wr_req;
+ int st_oo_req;
++ int st_rd_sect;
++ int st_wr_sect;
+
+ wait_queue_head_t waiting_to_free;
+
@@ -50796,10 +47962,10 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+void signal_tapdisk(int idx);
+
+#endif /* __BLKIF__BACKEND__COMMON_H__ */
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/drivers/xen/blktap/interface.c source/drivers/xen/blktap/interface.c
---- /scratch/src/linux-2.6.20.3/drivers/xen/blktap/interface.c 1970-01-01 01:00:00.000000000 +0100
-+++ source/drivers/xen/blktap/interface.c 2007-03-20 21:26:48.000000000 +0100
-@@ -0,0 +1,164 @@
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 drivers/xen/blktap/interface.c
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/drivers/xen/blktap/interface.c Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,174 @@
+/******************************************************************************
+ * drivers/xen/blktap/interface.c
+ *
@@ -50860,15 +48026,12 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+static int map_frontend_page(blkif_t *blkif, unsigned long shared_page)
+{
+ struct gnttab_map_grant_ref op;
-+ int ret;
+
+ gnttab_set_map_op(&op, (unsigned long)blkif->blk_ring_area->addr,
+ GNTMAP_host_map, shared_page, blkif->domid);
+
-+ lock_vm_area(blkif->blk_ring_area);
-+ ret = HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &op, 1);
-+ unlock_vm_area(blkif->blk_ring_area);
-+ BUG_ON(ret);
++ if (HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &op, 1))
++ BUG();
+
+ if (op.status) {
+ DPRINTK(" Grant table operation failure !\n");
@@ -50884,23 +48047,18 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+static void unmap_frontend_page(blkif_t *blkif)
+{
+ struct gnttab_unmap_grant_ref op;
-+ int ret;
+
+ gnttab_set_unmap_op(&op, (unsigned long)blkif->blk_ring_area->addr,
+ GNTMAP_host_map, blkif->shmem_handle);
+
-+ lock_vm_area(blkif->blk_ring_area);
-+ ret = HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1);
-+ unlock_vm_area(blkif->blk_ring_area);
-+ BUG_ON(ret);
++ if (HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1))
++ BUG();
+}
+
+int tap_blkif_map(blkif_t *blkif, unsigned long shared_page,
+ unsigned int evtchn)
+{
-+ blkif_sring_t *sring;
+ int err;
-+ struct evtchn_bind_interdomain bind_interdomain;
+
+ /* Already connected through? */
+ if (blkif->irq)
@@ -50915,24 +48073,42 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ return err;
+ }
+
-+ bind_interdomain.remote_dom = blkif->domid;
-+ bind_interdomain.remote_port = evtchn;
++ switch (blkif->blk_protocol) {
++ case BLKIF_PROTOCOL_NATIVE:
++ {
++ blkif_sring_t *sring;
++ sring = (blkif_sring_t *)blkif->blk_ring_area->addr;
++ BACK_RING_INIT(&blkif->blk_rings.native, sring, PAGE_SIZE);
++ break;
++ }
++ case BLKIF_PROTOCOL_X86_32:
++ {
++ blkif_x86_32_sring_t *sring_x86_32;
++ sring_x86_32 = (blkif_x86_32_sring_t *)blkif->blk_ring_area->addr;
++ BACK_RING_INIT(&blkif->blk_rings.x86_32, sring_x86_32, PAGE_SIZE);
++ break;
++ }
++ case BLKIF_PROTOCOL_X86_64:
++ {
++ blkif_x86_64_sring_t *sring_x86_64;
++ sring_x86_64 = (blkif_x86_64_sring_t *)blkif->blk_ring_area->addr;
++ BACK_RING_INIT(&blkif->blk_rings.x86_64, sring_x86_64, PAGE_SIZE);
++ break;
++ }
++ default:
++ BUG();
++ }
+
-+ err = HYPERVISOR_event_channel_op(EVTCHNOP_bind_interdomain,
-+ &bind_interdomain);
-+ if (err) {
++ err = bind_interdomain_evtchn_to_irqhandler(
++ blkif->domid, evtchn, tap_blkif_be_int,
++ 0, "blkif-backend", blkif);
++ if (err < 0) {
+ unmap_frontend_page(blkif);
+ free_vm_area(blkif->blk_ring_area);
++ blkif->blk_rings.common.sring = NULL;
+ return err;
+ }
-+
-+ blkif->evtchn = bind_interdomain.local_port;
-+
-+ sring = (blkif_sring_t *)blkif->blk_ring_area->addr;
-+ BACK_RING_INIT(&blkif->blk_ring, sring, PAGE_SIZE);
-+
-+ blkif->irq = bind_evtchn_to_irqhandler(
-+ blkif->evtchn, tap_blkif_be_int, 0, "blkif-backend", blkif);
++ blkif->irq = err;
+
+ return 0;
+}
@@ -50943,10 +48119,10 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ unbind_from_irqhandler(blkif->irq, blkif);
+ blkif->irq = 0;
+ }
-+ if (blkif->blk_ring.sring) {
++ if (blkif->blk_rings.common.sring) {
+ unmap_frontend_page(blkif);
+ free_vm_area(blkif->blk_ring_area);
-+ blkif->blk_ring.sring = NULL;
++ blkif->blk_rings.common.sring = NULL;
+ }
+}
+
@@ -50964,20 +48140,10 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ blkif_cachep = kmem_cache_create("blktapif_cache", sizeof(blkif_t),
+ 0, 0, NULL, NULL);
+}
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/drivers/xen/blktap/Makefile source/drivers/xen/blktap/Makefile
---- /scratch/src/linux-2.6.20.3/drivers/xen/blktap/Makefile 1970-01-01 01:00:00.000000000 +0100
-+++ source/drivers/xen/blktap/Makefile 2007-03-20 21:26:48.000000000 +0100
-@@ -0,0 +1,6 @@
-+LINUXINCLUDE += -I../xen/include/public/io
-+
-+obj-$(CONFIG_XEN_BLKDEV_TAP) := blktap.o
-+
-+blktap-y := xenbus.o interface.o blktapmain.o
-+
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/drivers/xen/blktap/xenbus.c source/drivers/xen/blktap/xenbus.c
---- /scratch/src/linux-2.6.20.3/drivers/xen/blktap/xenbus.c 1970-01-01 01:00:00.000000000 +0100
-+++ source/drivers/xen/blktap/xenbus.c 2007-03-20 21:26:48.000000000 +0100
-@@ -0,0 +1,366 @@
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 drivers/xen/blktap/xenbus.c
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/drivers/xen/blktap/xenbus.c Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,473 @@
+/* drivers/xen/blktap/xenbus.c
+ *
+ * Xenbus code for blktap
@@ -51027,6 +48193,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ blkif_t *blkif;
+ struct xenbus_watch backend_watch;
+ int xenbus_id;
++ int group_added;
+};
+
+
@@ -51072,34 +48239,75 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ return simple_strtol(num, NULL, 10);
+}
+
-+static void tap_update_blkif_status(blkif_t *blkif)
-+{
-+ int err;
++static int blktap_name(blkif_t *blkif, char *buf)
++{
++ char *devpath, *devname;
++ struct xenbus_device *dev = blkif->be->dev;
+
-+ /* Not ready to connect? */
-+ if(!blkif->irq || !blkif->sectors) {
-+ return;
-+ }
++ devpath = xenbus_read(XBT_NIL, dev->nodename, "dev", NULL);
++ if (IS_ERR(devpath))
++ return PTR_ERR(devpath);
++
++ if ((devname = strstr(devpath, "/dev/")) != NULL)
++ devname += strlen("/dev/");
++ else
++ devname = devpath;
+
-+ /* Already connected? */
-+ if (blkif->be->dev->state == XenbusStateConnected)
-+ return;
++ snprintf(buf, TASK_COMM_LEN, "blktap.%d.%s", blkif->domid, devname);
++ kfree(devpath);
++
++ return 0;
++}
+
-+ /* Attempt to connect: exit if we fail to. */
-+ connect(blkif->be);
-+ if (blkif->be->dev->state != XenbusStateConnected)
-+ return;
++/****************************************************************
++ * sysfs interface for VBD I/O requests
++ */
+
-+ blkif->xenblkd = kthread_run(tap_blkif_schedule, blkif,
-+ "xvd %d",
-+ blkif->domid);
++#define VBD_SHOW(name, format, args...) \
++ static ssize_t show_##name(struct device *_dev, \
++ struct device_attribute *attr, \
++ char *buf) \
++ { \
++ struct xenbus_device *dev = to_xenbus_device(_dev); \
++ struct backend_info *be = dev->dev.driver_data; \
++ \
++ return sprintf(buf, format, ##args); \
++ } \
++ DEVICE_ATTR(name, S_IRUGO, show_##name, NULL)
+
-+ if (IS_ERR(blkif->xenblkd)) {
-+ err = PTR_ERR(blkif->xenblkd);
-+ blkif->xenblkd = NULL;
-+ xenbus_dev_fatal(blkif->be->dev, err, "start xenblkd");
-+ WPRINTK("Error starting thread\n");
-+ }
++VBD_SHOW(tap_oo_req, "%d\n", be->blkif->st_oo_req);
++VBD_SHOW(tap_rd_req, "%d\n", be->blkif->st_rd_req);
++VBD_SHOW(tap_wr_req, "%d\n", be->blkif->st_wr_req);
++VBD_SHOW(tap_rd_sect, "%d\n", be->blkif->st_rd_sect);
++VBD_SHOW(tap_wr_sect, "%d\n", be->blkif->st_wr_sect);
++
++static struct attribute *tapstat_attrs[] = {
++ &dev_attr_tap_oo_req.attr,
++ &dev_attr_tap_rd_req.attr,
++ &dev_attr_tap_wr_req.attr,
++ &dev_attr_tap_rd_sect.attr,
++ &dev_attr_tap_wr_sect.attr,
++ NULL
++};
++
++static struct attribute_group tapstat_group = {
++ .name = "statistics",
++ .attrs = tapstat_attrs,
++};
++
++int xentap_sysfs_addif(struct xenbus_device *dev)
++{
++ int err;
++ struct backend_info *be = dev->dev.driver_data;
++ err = sysfs_create_group(&dev->dev.kobj, &tapstat_group);
++ if (!err)
++ be->group_added = 1;
++ return err;
++}
++
++void xentap_sysfs_delif(struct xenbus_device *dev)
++{
++ sysfs_remove_group(&dev->dev.kobj, &tapstat_group);
+}
+
+static int blktap_remove(struct xenbus_device *dev)
@@ -51118,11 +48326,54 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ tap_blkif_free(be->blkif);
+ be->blkif = NULL;
+ }
++ if (be->group_added)
++ xentap_sysfs_delif(be->dev);
+ kfree(be);
+ dev->dev.driver_data = NULL;
+ return 0;
+}
+
++static void tap_update_blkif_status(blkif_t *blkif)
++{
++ int err;
++ char name[TASK_COMM_LEN];
++
++ /* Not ready to connect? */
++ if(!blkif->irq || !blkif->sectors) {
++ return;
++ }
++
++ /* Already connected? */
++ if (blkif->be->dev->state == XenbusStateConnected)
++ return;
++
++ /* Attempt to connect: exit if we fail to. */
++ connect(blkif->be);
++ if (blkif->be->dev->state != XenbusStateConnected)
++ return;
++
++ err = blktap_name(blkif, name);
++ if (err) {
++ xenbus_dev_error(blkif->be->dev, err, "get blktap dev name");
++ return;
++ }
++
++ err = xentap_sysfs_addif(blkif->be->dev);
++ if (err) {
++ xenbus_dev_fatal(blkif->be->dev, err,
++ "creating sysfs entries");
++ return;
++ }
++
++ blkif->xenblkd = kthread_run(tap_blkif_schedule, blkif, name);
++ if (IS_ERR(blkif->xenblkd)) {
++ err = PTR_ERR(blkif->xenblkd);
++ blkif->xenblkd = NULL;
++ xenbus_dev_fatal(blkif->be->dev, err, "start xenblkd");
++ WPRINTK("Error starting thread\n");
++ }
++}
++
+/**
+ * Entry point to this code when a new device is created. Allocate
+ * the basic structures, and watch the store waiting for the
@@ -51194,7 +48445,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ * and disk info to xenstore
+ */
+ err = xenbus_gather(XBT_NIL, dev->nodename, "info", "%lu", &info,
-+ NULL);
++ NULL);
++ if (XENBUS_EXIST_ERR(err))
++ return;
+ if (err) {
+ xenbus_dev_error(dev, err, "getting info");
+ return;
@@ -51228,7 +48481,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ switch (frontend_state) {
+ case XenbusStateInitialising:
+ if (dev->state == XenbusStateClosed) {
-+ printk("%s: %s: prepare for reconnect\n",
++ printk(KERN_INFO "%s: %s: prepare for reconnect\n",
+ __FUNCTION__, dev->nodename);
+ xenbus_switch_state(dev, XenbusStateInitWait);
+ }
@@ -51296,6 +48549,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ struct xenbus_device *dev = be->dev;
+ unsigned long ring_ref;
+ unsigned int evtchn;
++ char protocol[64];
+ int err;
+
+ DPRINTK("%s\n", dev->otherend);
@@ -51309,6 +48563,25 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ return err;
+ }
+
++ be->blkif->blk_protocol = BLKIF_PROTOCOL_NATIVE;
++ err = xenbus_gather(XBT_NIL, dev->otherend, "protocol",
++ "%63s", protocol, NULL);
++ if (err)
++ strcpy(protocol, "unspecified, assuming native");
++ else if (0 == strcmp(protocol, XEN_IO_PROTO_ABI_NATIVE))
++ be->blkif->blk_protocol = BLKIF_PROTOCOL_NATIVE;
++ else if (0 == strcmp(protocol, XEN_IO_PROTO_ABI_X86_32))
++ be->blkif->blk_protocol = BLKIF_PROTOCOL_X86_32;
++ else if (0 == strcmp(protocol, XEN_IO_PROTO_ABI_X86_64))
++ be->blkif->blk_protocol = BLKIF_PROTOCOL_X86_64;
++ else {
++ xenbus_dev_fatal(dev, err, "unknown fe protocol %s", protocol);
++ return -1;
++ }
++ printk(KERN_INFO
++ "blktap: ring-ref %ld, event-channel %d, protocol %d (%s)\n",
++ ring_ref, evtchn, be->blkif->blk_protocol, protocol);
++
+ /* Map the shared frame, irq etc. */
+ err = tap_blkif_map(be->blkif, ring_ref, evtchn);
+ if (err) {
@@ -51344,15 +48617,15 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+{
+ xenbus_register_backend(&blktap);
+}
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/drivers/xen/char/Makefile source/drivers/xen/char/Makefile
---- /scratch/src/linux-2.6.20.3/drivers/xen/char/Makefile 1970-01-01 01:00:00.000000000 +0100
-+++ source/drivers/xen/char/Makefile 2007-03-20 21:26:48.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 drivers/xen/char/Makefile
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/drivers/xen/char/Makefile Wed Aug 08 16:25:28 2007 -0300
@@ -0,0 +1,2 @@
+
+obj-y := mem.o
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/drivers/xen/char/mem.c source/drivers/xen/char/mem.c
---- /scratch/src/linux-2.6.20.3/drivers/xen/char/mem.c 1970-01-01 01:00:00.000000000 +0100
-+++ source/drivers/xen/char/mem.c 2007-03-20 21:26:48.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 drivers/xen/char/mem.c
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/drivers/xen/char/mem.c Wed Aug 08 16:25:28 2007 -0300
@@ -0,0 +1,203 @@
+/*
+ * Originally from linux/drivers/char/mem.c
@@ -51383,7 +48656,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#include <asm/hypervisor.h>
+
+#ifndef ARCH_HAS_VALID_PHYS_ADDR_RANGE
-+static inline int valid_phys_addr_range(unsigned long addr, size_t *count)
++static inline int valid_phys_addr_range(unsigned long addr, size_t count)
+{
+ return 1;
+}
@@ -51400,7 +48673,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ ssize_t read = 0, sz;
+ void __iomem *v;
+
-+ if (!valid_phys_addr_range(p, &count))
++ if (!valid_phys_addr_range(p, count))
+ return -EFAULT;
+
+ while (count > 0) {
@@ -51451,7 +48724,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ ssize_t written = 0, sz;
+ void __iomem *v;
+
-+ if (!valid_phys_addr_range(p, &count))
++ if (!valid_phys_addr_range(p, count))
+ return -EFAULT;
+
+ while (count > 0) {
@@ -51550,17 +48823,23 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ return capable(CAP_SYS_RAWIO) ? 0 : -EPERM;
+}
+
-+struct file_operations mem_fops = {
++const struct file_operations mem_fops = {
+ .llseek = memory_lseek,
+ .read = read_mem,
+ .write = write_mem,
+ .mmap = xen_mmap_mem,
+ .open = open_mem,
+};
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/drivers/xen/console/console.c source/drivers/xen/console/console.c
---- /scratch/src/linux-2.6.20.3/drivers/xen/console/console.c 1970-01-01 01:00:00.000000000 +0100
-+++ source/drivers/xen/console/console.c 2007-03-20 21:26:48.000000000 +0100
-@@ -0,0 +1,709 @@
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 drivers/xen/console/Makefile
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/drivers/xen/console/Makefile Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,2 @@
++
++obj-y := console.o xencons_ring.o
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 drivers/xen/console/console.c
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/drivers/xen/console/console.c Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,712 @@
+/******************************************************************************
+ * console.c
+ *
@@ -51601,7 +48880,6 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#include <linux/interrupt.h>
+#include <linux/tty.h>
+#include <linux/tty_flip.h>
-+#include <linux/vt.h>
+#include <linux/serial.h>
+#include <linux/major.h>
+#include <linux/ptrace.h>
@@ -51613,6 +48891,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#include <linux/bootmem.h>
+#include <linux/sysrq.h>
+#include <linux/screen_info.h>
++#include <linux/vt.h>
+#include <asm/io.h>
+#include <asm/irq.h>
+#include <asm/uaccess.h>
@@ -51903,8 +49182,11 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#ifdef CONFIG_MAGIC_SYSRQ
+ if (sysrq_on()) {
+ if (buf[i] == '\x0f') { /* ^O */
-+ sysrq_requested = jiffies;
-+ continue; /* don't print the sysrq key */
++ if (!sysrq_requested) {
++ sysrq_requested = jiffies;
++ continue; /* don't print sysrq key */
++ }
++ sysrq_requested = 0;
+ } else if (sysrq_requested) {
+ unsigned long sysrq_timeout =
+ sysrq_requested + HZ*2;
@@ -52270,15 +49552,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+module_init(xencons_init);
+
+MODULE_LICENSE("Dual BSD/GPL");
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/drivers/xen/console/Makefile source/drivers/xen/console/Makefile
---- /scratch/src/linux-2.6.20.3/drivers/xen/console/Makefile 1970-01-01 01:00:00.000000000 +0100
-+++ source/drivers/xen/console/Makefile 2007-03-20 21:26:48.000000000 +0100
-@@ -0,0 +1,2 @@
-+
-+obj-y := console.o xencons_ring.o
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/drivers/xen/console/xencons_ring.c source/drivers/xen/console/xencons_ring.c
---- /scratch/src/linux-2.6.20.3/drivers/xen/console/xencons_ring.c 1970-01-01 01:00:00.000000000 +0100
-+++ source/drivers/xen/console/xencons_ring.c 2007-03-20 21:26:48.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 drivers/xen/console/xencons_ring.c
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/drivers/xen/console/xencons_ring.c Wed Aug 08 16:25:28 2007 -0300
@@ -0,0 +1,143 @@
+/*
+ * This program is free software; you can redistribute it and/or
@@ -52403,7 +49679,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ !xen_start_info->console.domU.evtchn)
+ return -ENODEV;
+
-+ irq = bind_evtchn_to_irqhandler(
++ irq = bind_caller_port_to_irqhandler(
+ xen_start_info->console.domU.evtchn,
+ handle_input, 0, "xencons", NULL);
+ if (irq < 0) {
@@ -52423,11 +49699,26 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+{
+ (void)xencons_ring_init();
+}
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/drivers/xen/core/cpu_hotplug.c source/drivers/xen/core/cpu_hotplug.c
---- /scratch/src/linux-2.6.20.3/drivers/xen/core/cpu_hotplug.c 1970-01-01 01:00:00.000000000 +0100
-+++ source/drivers/xen/core/cpu_hotplug.c 2007-03-20 21:26:49.000000000 +0100
-@@ -0,0 +1,188 @@
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 drivers/xen/core/Makefile
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/drivers/xen/core/Makefile Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,12 @@
++#
++# Makefile for the linux kernel.
++#
+
++obj-y := evtchn.o gnttab.o features.o reboot.o machine_reboot.o
++
++obj-$(CONFIG_PROC_FS) += xen_proc.o
++obj-$(CONFIG_SYSFS) += hypervisor_sysfs.o
++obj-$(CONFIG_HOTPLUG_CPU) += cpu_hotplug.o
++obj-$(CONFIG_XEN_SYSFS) += xen_sysfs.o
++obj-$(CONFIG_XEN_SMPBOOT) += smpboot.o
++obj-$(CONFIG_KEXEC) += machine_kexec.o
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 drivers/xen/core/cpu_hotplug.c
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/drivers/xen/core/cpu_hotplug.c Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,172 @@
+#include <linux/init.h>
+#include <linux/kernel.h>
+#include <linux/sched.h>
@@ -52551,29 +49842,19 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+
+int smp_suspend(void)
+{
-+ int i, err;
-+
-+ lock_cpu_hotplug();
++ int cpu, err;
+
-+ /*
-+ * Take all other CPUs offline. We hold the hotplug mutex to
-+ * avoid other processes bringing up CPUs under our feet.
-+ */
-+ while (num_online_cpus() > 1) {
-+ unlock_cpu_hotplug();
-+ for_each_online_cpu(i) {
-+ if (i == 0)
-+ continue;
-+ err = cpu_down(i);
-+ if (err) {
-+ printk(KERN_CRIT "Failed to take all CPUs "
-+ "down: %d.\n", err);
-+ for_each_possible_cpu(i)
-+ vcpu_hotplug(i);
-+ return err;
-+ }
++ for_each_online_cpu(cpu) {
++ if (cpu == 0)
++ continue;
++ err = cpu_down(cpu);
++ if (err) {
++ printk(KERN_CRIT "Failed to take all CPUs "
++ "down: %d.\n", err);
++ for_each_possible_cpu(cpu)
++ vcpu_hotplug(cpu);
++ return err;
+ }
-+ lock_cpu_hotplug();
+ }
+
+ return 0;
@@ -52584,11 +49865,6 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ int cpu;
+
+ for_each_possible_cpu(cpu)
-+ cpu_initialize_context(cpu);
-+
-+ unlock_cpu_hotplug();
-+
-+ for_each_possible_cpu(cpu)
+ vcpu_hotplug(cpu);
+}
+
@@ -52615,10 +49891,10 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+{
+ xenbus_allowed_cpumask = cpu_present_map;
+}
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/drivers/xen/core/evtchn.c source/drivers/xen/core/evtchn.c
---- /scratch/src/linux-2.6.20.3/drivers/xen/core/evtchn.c 1970-01-01 01:00:00.000000000 +0100
-+++ source/drivers/xen/core/evtchn.c 2007-03-20 21:26:49.000000000 +0100
-@@ -0,0 +1,860 @@
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 drivers/xen/core/evtchn.c
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/drivers/xen/core/evtchn.c Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,988 @@
+/******************************************************************************
+ * evtchn.c
+ *
@@ -52681,7 +49957,14 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+static u32 irq_info[NR_IRQS];
+
+/* Binding types. */
-+enum { IRQT_UNBOUND, IRQT_PIRQ, IRQT_VIRQ, IRQT_IPI, IRQT_EVTCHN };
++enum {
++ IRQT_UNBOUND,
++ IRQT_PIRQ,
++ IRQT_VIRQ,
++ IRQT_IPI,
++ IRQT_LOCAL_PORT,
++ IRQT_CALLER_PORT
++};
+
+/* Constructor for packed IRQ information. */
+static inline u32 mk_irq_info(u32 type, u32 index, u32 evtchn)
@@ -52724,7 +50007,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+static int irq_bindcount[NR_IRQS];
+
+/* Bitmap indicating which PIRQs require Xen to be notified on unmask. */
-+static unsigned long pirq_needs_eoi[NR_PIRQS/sizeof(unsigned long)];
++static DECLARE_BITMAP(pirq_needs_eoi, NR_PIRQS);
+
+#ifdef CONFIG_SMP
+
@@ -52828,38 +50111,51 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+/* Not a GPL symbol: used in ubiquitous macros, so too restrictive. */
+EXPORT_SYMBOL(force_evtchn_callback);
+
++static DEFINE_PER_CPU(unsigned int, upcall_count) = { 0 };
++
+/* NB. Interrupts are disabled on entry. */
+asmlinkage void evtchn_do_upcall(struct pt_regs *regs)
+{
+ unsigned long l1, l2;
-+ unsigned int l1i, l2i, port;
++ unsigned int l1i, l2i, port, count;
+ int irq, cpu = smp_processor_id();
+ shared_info_t *s = HYPERVISOR_shared_info;
+ vcpu_info_t *vcpu_info = &s->vcpu_info[cpu];
+
-+ vcpu_info->evtchn_upcall_pending = 0;
++ do {
++ /* Avoid a callback storm when we reenable delivery. */
++ vcpu_info->evtchn_upcall_pending = 0;
++
++ /* Nested invocations bail immediately. */
++ if (unlikely(per_cpu(upcall_count, cpu)++))
++ return;
+
+#ifndef CONFIG_X86 /* No need for a barrier -- XCHG is a barrier on x86. */
-+ /* Clear master pending flag /before/ clearing selector flag. */
-+ rmb();
++ /* Clear master flag /before/ clearing selector flag. */
++ rmb();
+#endif
-+ l1 = xchg(&vcpu_info->evtchn_pending_sel, 0);
-+ while (l1 != 0) {
-+ l1i = __ffs(l1);
-+ l1 &= ~(1UL << l1i);
++ l1 = xchg(&vcpu_info->evtchn_pending_sel, 0);
++ while (l1 != 0) {
++ l1i = __ffs(l1);
++ l1 &= ~(1UL << l1i);
+
-+ while ((l2 = active_evtchns(cpu, s, l1i)) != 0) {
-+ l2i = __ffs(l2);
++ while ((l2 = active_evtchns(cpu, s, l1i)) != 0) {
++ l2i = __ffs(l2);
+
-+ port = (l1i * BITS_PER_LONG) + l2i;
-+ if ((irq = evtchn_to_irq[port]) != -1)
-+ do_IRQ(irq, regs);
-+ else {
-+ exit_idle();
-+ evtchn_device_upcall(port);
++ port = (l1i * BITS_PER_LONG) + l2i;
++ if ((irq = evtchn_to_irq[port]) != -1)
++ do_IRQ(irq, regs);
++ else {
++ exit_idle();
++ evtchn_device_upcall(port);
++ }
+ }
+ }
-+ }
++
++ /* If there were nested callbacks then we have more to do. */
++ count = per_cpu(upcall_count, cpu);
++ per_cpu(upcall_count, cpu) = 0;
++ } while (unlikely(count != 1));
+}
+
+static int find_unbound_irq(void)
@@ -52882,18 +50178,18 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ return -ENOSPC;
+}
+
-+static int bind_evtchn_to_irq(unsigned int evtchn)
++static int bind_caller_port_to_irq(unsigned int caller_port)
+{
+ int irq;
+
+ spin_lock(&irq_mapping_update_lock);
+
-+ if ((irq = evtchn_to_irq[evtchn]) == -1) {
++ if ((irq = evtchn_to_irq[caller_port]) == -1) {
+ if ((irq = find_unbound_irq()) < 0)
+ goto out;
+
-+ evtchn_to_irq[evtchn] = irq;
-+ irq_info[irq] = mk_irq_info(IRQT_EVTCHN, 0, evtchn);
++ evtchn_to_irq[caller_port] = irq;
++ irq_info[irq] = mk_irq_info(IRQT_CALLER_PORT, 0, caller_port);
+ }
+
+ irq_bindcount[irq]++;
@@ -52903,6 +50199,59 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ return irq;
+}
+
++static int bind_local_port_to_irq(unsigned int local_port)
++{
++ int irq;
++
++ spin_lock(&irq_mapping_update_lock);
++
++ BUG_ON(evtchn_to_irq[local_port] != -1);
++
++ if ((irq = find_unbound_irq()) < 0) {
++ struct evtchn_close close = { .port = local_port };
++ if (HYPERVISOR_event_channel_op(EVTCHNOP_close, &close))
++ BUG();
++ goto out;
++ }
++
++ evtchn_to_irq[local_port] = irq;
++ irq_info[irq] = mk_irq_info(IRQT_LOCAL_PORT, 0, local_port);
++ irq_bindcount[irq]++;
++
++ out:
++ spin_unlock(&irq_mapping_update_lock);
++ return irq;
++}
++
++static int bind_listening_port_to_irq(unsigned int remote_domain)
++{
++ struct evtchn_alloc_unbound alloc_unbound;
++ int err;
++
++ alloc_unbound.dom = DOMID_SELF;
++ alloc_unbound.remote_dom = remote_domain;
++
++ err = HYPERVISOR_event_channel_op(EVTCHNOP_alloc_unbound,
++ &alloc_unbound);
++
++ return err ? : bind_local_port_to_irq(alloc_unbound.port);
++}
++
++static int bind_interdomain_evtchn_to_irq(unsigned int remote_domain,
++ unsigned int remote_port)
++{
++ struct evtchn_bind_interdomain bind_interdomain;
++ int err;
++
++ bind_interdomain.remote_dom = remote_domain;
++ bind_interdomain.remote_port = remote_port;
++
++ err = HYPERVISOR_event_channel_op(EVTCHNOP_bind_interdomain,
++ &bind_interdomain);
++
++ return err ? : bind_local_port_to_irq(bind_interdomain.local_port);
++}
++
+static int bind_virq_to_irq(unsigned int virq, unsigned int cpu)
+{
+ struct evtchn_bind_virq bind_virq;
@@ -52971,13 +50320,14 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+static void unbind_from_irq(unsigned int irq)
+{
+ struct evtchn_close close;
-+ int evtchn = evtchn_from_irq(irq);
++ int cpu, evtchn = evtchn_from_irq(irq);
+
+ spin_lock(&irq_mapping_update_lock);
+
+ if ((--irq_bindcount[irq] == 0) && VALID_EVTCHN(evtchn)) {
+ close.port = evtchn;
-+ if (HYPERVISOR_event_channel_op(EVTCHNOP_close, &close) != 0)
++ if ((type_from_irq(irq) != IRQT_CALLER_PORT) &&
++ HYPERVISOR_event_channel_op(EVTCHNOP_close, &close))
+ BUG();
+
+ switch (type_from_irq(irq)) {
@@ -52998,22 +50348,48 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+
+ evtchn_to_irq[evtchn] = -1;
+ irq_info[irq] = IRQ_UNBOUND;
++
++ /* Zap stats across IRQ changes of use. */
++ for_each_possible_cpu(cpu)
++ kstat_cpu(cpu).irqs[irq] = 0;
+ }
+
+ spin_unlock(&irq_mapping_update_lock);
+}
+
-+int bind_evtchn_to_irqhandler(
-+ unsigned int evtchn,
++int bind_caller_port_to_irqhandler(
++ unsigned int caller_port,
+ irq_handler_t handler,
+ unsigned long irqflags,
+ const char *devname,
+ void *dev_id)
+{
-+ unsigned int irq;
-+ int retval;
++ int irq, retval;
++
++ irq = bind_caller_port_to_irq(caller_port);
++ if (irq < 0)
++ return irq;
++
++ retval = request_irq(irq, handler, irqflags, devname, dev_id);
++ if (retval != 0) {
++ unbind_from_irq(irq);
++ return retval;
++ }
++
++ return irq;
++}
++EXPORT_SYMBOL_GPL(bind_caller_port_to_irqhandler);
+
-+ irq = bind_evtchn_to_irq(evtchn);
++int bind_listening_port_to_irqhandler(
++ unsigned int remote_domain,
++ irq_handler_t handler,
++ unsigned long irqflags,
++ const char *devname,
++ void *dev_id)
++{
++ int irq, retval;
++
++ irq = bind_listening_port_to_irq(remote_domain);
+ if (irq < 0)
+ return irq;
+
@@ -53025,7 +50401,31 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+
+ return irq;
+}
-+EXPORT_SYMBOL_GPL(bind_evtchn_to_irqhandler);
++EXPORT_SYMBOL_GPL(bind_listening_port_to_irqhandler);
++
++int bind_interdomain_evtchn_to_irqhandler(
++ unsigned int remote_domain,
++ unsigned int remote_port,
++ irq_handler_t handler,
++ unsigned long irqflags,
++ const char *devname,
++ void *dev_id)
++{
++ int irq, retval;
++
++ irq = bind_interdomain_evtchn_to_irq(remote_domain, remote_port);
++ if (irq < 0)
++ return irq;
++
++ retval = request_irq(irq, handler, irqflags, devname, dev_id);
++ if (retval != 0) {
++ unbind_from_irq(irq);
++ return retval;
++ }
++
++ return irq;
++}
++EXPORT_SYMBOL_GPL(bind_interdomain_evtchn_to_irqhandler);
+
+int bind_virq_to_irqhandler(
+ unsigned int virq,
@@ -53035,8 +50435,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ const char *devname,
+ void *dev_id)
+{
-+ unsigned int irq;
-+ int retval;
++ int irq, retval;
+
+ irq = bind_virq_to_irq(virq, cpu);
+ if (irq < 0)
@@ -53060,8 +50459,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ const char *devname,
+ void *dev_id)
+{
-+ unsigned int irq;
-+ int retval;
++ int irq, retval;
+
+ irq = bind_ipi_to_irq(ipi, cpu);
+ if (irq < 0)
@@ -53084,6 +50482,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+}
+EXPORT_SYMBOL_GPL(unbind_from_irqhandler);
+
++#ifdef CONFIG_SMP
+/* Rebind an evtchn so that it gets delivered to a specific cpu */
+static void rebind_irq_to_cpu(unsigned irq, unsigned tcpu)
+{
@@ -53106,20 +50505,26 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ bind_evtchn_to_cpu(evtchn, tcpu);
+}
+
-+
+static void set_affinity_irq(unsigned irq, cpumask_t dest)
+{
+ unsigned tcpu = first_cpu(dest);
+ rebind_irq_to_cpu(irq, tcpu);
+}
++#endif
+
-+static int retrigger_vector(unsigned int irq)
++int resend_irq_on_evtchn(unsigned int irq)
+{
-+ int evtchn = evtchn_from_irq(irq);
++ int masked, evtchn = evtchn_from_irq(irq);
+ shared_info_t *s = HYPERVISOR_shared_info;
++
+ if (!VALID_EVTCHN(evtchn))
+ return 1;
-+ synch_set_bit(evtchn, &s->evtchn_pending[0]);
++
++ masked = synch_test_and_set_bit(evtchn, s->evtchn_mask);
++ synch_set_bit(evtchn, s->evtchn_pending);
++ if (!masked)
++ unmask_evtchn(evtchn);
++
+ return 1;
+}
+
@@ -53180,15 +50585,15 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ .ack = ack_dynirq_vector,
+ .eoi = ack_dynirq_quirk_vector,
+#ifdef CONFIG_SMP
-+ .set_affinity = set_affinity_irq,
++ .set_affinity = set_affinity_irq,
+#endif
-+ .retrigger = retrigger_vector,
++ .retrigger = resend_irq_on_evtchn,
+};
+
+static inline void pirq_unmask_notify(int pirq)
+{
+ struct physdev_eoi eoi = { .irq = pirq };
-+ if (unlikely(test_bit(pirq, &pirq_needs_eoi[0])))
++ if (unlikely(test_bit(pirq, pirq_needs_eoi)))
+ (void)HYPERVISOR_physdev_op(PHYSDEVOP_eoi, &eoi);
+}
+
@@ -53197,9 +50602,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ struct physdev_irq_status_query irq_status;
+ irq_status.irq = pirq;
+ (void)HYPERVISOR_physdev_op(PHYSDEVOP_irq_status_query, &irq_status);
-+ clear_bit(pirq, &pirq_needs_eoi[0]);
++ clear_bit(pirq, pirq_needs_eoi);
+ if (irq_status.flags & XENIRQSTAT_needs_eoi)
-+ set_bit(pirq, &pirq_needs_eoi[0]);
++ set_bit(pirq, pirq_needs_eoi);
+}
+
+/*
@@ -53288,9 +50693,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ .ack = ack_pirq_vector,
+ .eoi = ack_pirq_quirk_vector,
+#ifdef CONFIG_SMP
-+ .set_affinity = set_affinity_irq,
++ .set_affinity = set_affinity_irq,
+#endif
-+ .retrigger = retrigger_vector,
++ .retrigger = resend_irq_on_evtchn,
+};
+
+int irq_ignore_unhandled(unsigned int irq)
@@ -53304,16 +50709,6 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ return !!(irq_status.flags & XENIRQSTAT_shared);
+}
+
-+void resend_irq_on_evtchn(unsigned int i)
-+{
-+ int evtchn = evtchn_from_irq(i);
-+ shared_info_t *s = HYPERVISOR_shared_info;
-+ if (!VALID_EVTCHN(evtchn))
-+ return;
-+ BUG_ON(!synch_test_bit(evtchn, &s->evtchn_mask[0]));
-+ synch_set_bit(evtchn, &s->evtchn_pending[0]);
-+}
-+
+void notify_remote_via_irq(int irq)
+{
+ int evtchn = evtchn_from_irq(irq);
@@ -53323,10 +50718,16 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+}
+EXPORT_SYMBOL_GPL(notify_remote_via_irq);
+
++int irq_to_evtchn_port(int irq)
++{
++ return evtchn_from_irq(irq);
++}
++EXPORT_SYMBOL_GPL(irq_to_evtchn_port);
++
+void mask_evtchn(int port)
+{
+ shared_info_t *s = HYPERVISOR_shared_info;
-+ synch_set_bit(port, &s->evtchn_mask[0]);
++ synch_set_bit(port, s->evtchn_mask);
+}
+EXPORT_SYMBOL_GPL(mask_evtchn);
+
@@ -53345,62 +50746,30 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ return;
+ }
+
-+ synch_clear_bit(port, &s->evtchn_mask[0]);
++ synch_clear_bit(port, s->evtchn_mask);
+
-+ /*
-+ * The following is basically the equivalent of 'hw_resend_irq'. Just
-+ * like a real IO-APIC we 'lose the interrupt edge' if the channel is
-+ * masked.
-+ */
-+ if (synch_test_bit(port, &s->evtchn_pending[0]) &&
++ /* Did we miss an interrupt 'edge'? Re-fire if so. */
++ if (synch_test_bit(port, s->evtchn_pending) &&
+ !synch_test_and_set_bit(port / BITS_PER_LONG,
+ &vcpu_info->evtchn_pending_sel))
+ vcpu_info->evtchn_upcall_pending = 1;
+}
+EXPORT_SYMBOL_GPL(unmask_evtchn);
+
-+void irq_resume(void)
++static void restore_cpu_virqs(int cpu)
+{
+ struct evtchn_bind_virq bind_virq;
-+ struct evtchn_bind_ipi bind_ipi;
-+ int cpu, pirq, virq, ipi, irq, evtchn;
-+
-+ init_evtchn_cpu_bindings();
-+
-+ /* New event-channel space is not 'live' yet. */
-+ for (evtchn = 0; evtchn < NR_EVENT_CHANNELS; evtchn++)
-+ mask_evtchn(evtchn);
++ int virq, irq, evtchn;
+
-+ /* Check that no PIRQs are still bound. */
-+ for (pirq = 0; pirq < NR_PIRQS; pirq++)
-+ BUG_ON(irq_info[pirq_to_irq(pirq)] != IRQ_UNBOUND);
-+
-+ /* Secondary CPUs must have no VIRQ or IPI bindings. */
-+ for_each_possible_cpu(cpu) {
-+ if (cpu == 0)
-+ continue;
-+ for (virq = 0; virq < NR_VIRQS; virq++)
-+ BUG_ON(per_cpu(virq_to_irq, cpu)[virq] != -1);
-+ for (ipi = 0; ipi < NR_IPIS; ipi++)
-+ BUG_ON(per_cpu(ipi_to_irq, cpu)[ipi] != -1);
-+ }
-+
-+ /* No IRQ <-> event-channel mappings. */
-+ for (irq = 0; irq < NR_IRQS; irq++)
-+ irq_info[irq] &= ~0xFFFF; /* zap event-channel binding */
-+ for (evtchn = 0; evtchn < NR_EVENT_CHANNELS; evtchn++)
-+ evtchn_to_irq[evtchn] = -1;
-+
-+ /* Primary CPU: rebind VIRQs automatically. */
+ for (virq = 0; virq < NR_VIRQS; virq++) {
-+ if ((irq = per_cpu(virq_to_irq, 0)[virq]) == -1)
++ if ((irq = per_cpu(virq_to_irq, cpu)[virq]) == -1)
+ continue;
+
+ BUG_ON(irq_info[irq] != mk_irq_info(IRQT_VIRQ, virq, 0));
+
+ /* Get a new binding from Xen. */
+ bind_virq.virq = virq;
-+ bind_virq.vcpu = 0;
++ bind_virq.vcpu = cpu;
+ if (HYPERVISOR_event_channel_op(EVTCHNOP_bind_virq,
+ &bind_virq) != 0)
+ BUG();
@@ -53409,20 +50778,26 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ /* Record the new mapping. */
+ evtchn_to_irq[evtchn] = irq;
+ irq_info[irq] = mk_irq_info(IRQT_VIRQ, virq, evtchn);
++ bind_evtchn_to_cpu(evtchn, cpu);
+
+ /* Ready for use. */
+ unmask_evtchn(evtchn);
+ }
++}
++
++static void restore_cpu_ipis(int cpu)
++{
++ struct evtchn_bind_ipi bind_ipi;
++ int ipi, irq, evtchn;
+
-+ /* Primary CPU: rebind IPIs automatically. */
+ for (ipi = 0; ipi < NR_IPIS; ipi++) {
-+ if ((irq = per_cpu(ipi_to_irq, 0)[ipi]) == -1)
++ if ((irq = per_cpu(ipi_to_irq, cpu)[ipi]) == -1)
+ continue;
+
+ BUG_ON(irq_info[irq] != mk_irq_info(IRQT_IPI, ipi, 0));
+
+ /* Get a new binding from Xen. */
-+ bind_ipi.vcpu = 0;
++ bind_ipi.vcpu = cpu;
+ if (HYPERVISOR_event_channel_op(EVTCHNOP_bind_ipi,
+ &bind_ipi) != 0)
+ BUG();
@@ -53431,10 +50806,39 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ /* Record the new mapping. */
+ evtchn_to_irq[evtchn] = irq;
+ irq_info[irq] = mk_irq_info(IRQT_IPI, ipi, evtchn);
++ bind_evtchn_to_cpu(evtchn, cpu);
+
+ /* Ready for use. */
+ unmask_evtchn(evtchn);
++
++ }
++}
++
++void irq_resume(void)
++{
++ int cpu, pirq, irq, evtchn;
++
++ init_evtchn_cpu_bindings();
++
++ /* New event-channel space is not 'live' yet. */
++ for (evtchn = 0; evtchn < NR_EVENT_CHANNELS; evtchn++)
++ mask_evtchn(evtchn);
++
++ /* Check that no PIRQs are still bound. */
++ for (pirq = 0; pirq < NR_PIRQS; pirq++)
++ BUG_ON(irq_info[pirq_to_irq(pirq)] != IRQ_UNBOUND);
++
++ /* No IRQ <-> event-channel mappings. */
++ for (irq = 0; irq < NR_IRQS; irq++)
++ irq_info[irq] &= ~0xFFFF; /* zap event-channel binding */
++ for (evtchn = 0; evtchn < NR_EVENT_CHANNELS; evtchn++)
++ evtchn_to_irq[evtchn] = -1;
++
++ for_each_possible_cpu(cpu) {
++ restore_cpu_virqs(cpu);
++ restore_cpu_ipis(cpu);
+ }
++
+}
+
+void __init xen_init_IRQ(void)
@@ -53455,9 +50859,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ for (i = 0; i < NR_DYNIRQS; i++) {
+ irq_bindcount[dynirq_to_irq(i)] = 0;
+
-+ irq_desc[dynirq_to_irq(i)].status = IRQ_DISABLED;
-+ irq_desc[dynirq_to_irq(i)].action = NULL;
-+ irq_desc[dynirq_to_irq(i)].depth = 1;
++ irq_desc[dynirq_to_irq(i)].status = IRQ_DISABLED;
++ irq_desc[dynirq_to_irq(i)].action = NULL;
++ irq_desc[dynirq_to_irq(i)].depth = 1;
+ set_irq_chip_and_handler_name(dynirq_to_irq(i), &dynirq_chip,
+ handle_level_irq, "level");
+ }
@@ -53472,16 +50876,16 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ continue;
+#endif
+
-+ irq_desc[pirq_to_irq(i)].status = IRQ_DISABLED;
-+ irq_desc[pirq_to_irq(i)].action = NULL;
-+ irq_desc[pirq_to_irq(i)].depth = 1;
++ irq_desc[pirq_to_irq(i)].status = IRQ_DISABLED;
++ irq_desc[pirq_to_irq(i)].action = NULL;
++ irq_desc[pirq_to_irq(i)].depth = 1;
+ set_irq_chip_and_handler_name(pirq_to_irq(i), &pirq_chip,
+ handle_level_irq, "level");
+ }
+}
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/drivers/xen/core/features.c source/drivers/xen/core/features.c
---- /scratch/src/linux-2.6.20.3/drivers/xen/core/features.c 1970-01-01 01:00:00.000000000 +0100
-+++ source/drivers/xen/core/features.c 2007-03-20 21:26:49.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 drivers/xen/core/features.c
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/drivers/xen/core/features.c Wed Aug 08 16:25:28 2007 -0300
@@ -0,0 +1,34 @@
+/******************************************************************************
+ * features.c
@@ -53517,16 +50921,16 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ xen_features[i*32+j] = !!(fi.submap & 1<<j);
+ }
+}
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/drivers/xen/core/gnttab.c source/drivers/xen/core/gnttab.c
---- /scratch/src/linux-2.6.20.3/drivers/xen/core/gnttab.c 1970-01-01 01:00:00.000000000 +0100
-+++ source/drivers/xen/core/gnttab.c 2007-03-20 21:26:49.000000000 +0100
-@@ -0,0 +1,487 @@
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 drivers/xen/core/gnttab.c
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/drivers/xen/core/gnttab.c Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,631 @@
+/******************************************************************************
+ * gnttab.c
+ *
+ * Granting foreign access to our memory reservation.
+ *
-+ * Copyright (c) 2005, Christopher Clark
++ * Copyright (c) 2005-2006, Christopher Clark
+ * Copyright (c) 2004-2005, K A Fraser
+ *
+ * This program is free software; you can redistribute it and/or
@@ -53557,7 +50961,6 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#include <linux/module.h>
+#include <linux/sched.h>
+#include <linux/mm.h>
-+#include <linux/vmalloc.h>
+#include <xen/interface/xen.h>
+#include <xen/gnttab.h>
+#include <asm/pgtable.h>
@@ -53565,6 +50968,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#include <asm/synch_bitops.h>
+#include <asm/io.h>
+#include <xen/interface/memory.h>
++#include <xen/driver_util.h>
+
+#ifdef HAVE_XEN_PLATFORM_COMPAT_H
+#include <xen/platform-compat.h>
@@ -53572,12 +50976,12 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+
+/* External tools reserve first few grant table entries. */
+#define NR_RESERVED_ENTRIES 8
++#define GNTTAB_LIST_END 0xffffffff
++#define GREFS_PER_GRANT_FRAME (PAGE_SIZE / sizeof(grant_entry_t))
+
-+#define NR_GRANT_ENTRIES \
-+ (NR_GRANT_FRAMES * PAGE_SIZE / sizeof(struct grant_entry))
-+#define GNTTAB_LIST_END (NR_GRANT_ENTRIES + 1)
-+
-+static grant_ref_t gnttab_list[NR_GRANT_ENTRIES];
++static grant_ref_t **gnttab_list;
++static unsigned int nr_grant_frames;
++static unsigned int boot_max_nr_grant_frames;
+static int gnttab_free_count;
+static grant_ref_t gnttab_free_head;
+static DEFINE_SPINLOCK(gnttab_list_lock);
@@ -53586,23 +50990,34 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+
+static struct gnttab_free_callback *gnttab_free_callback_list;
+
++static int gnttab_expand(unsigned int req_entries);
++
++#define RPP (PAGE_SIZE / sizeof(grant_ref_t))
++#define gnttab_entry(entry) (gnttab_list[(entry) / RPP][(entry) % RPP])
++
+static int get_free_entries(int count)
+{
+ unsigned long flags;
-+ int ref;
++ int ref, rc;
+ grant_ref_t head;
++
+ spin_lock_irqsave(&gnttab_list_lock, flags);
-+ if (gnttab_free_count < count) {
++
++ if ((gnttab_free_count < count) &&
++ ((rc = gnttab_expand(count - gnttab_free_count)) < 0)) {
+ spin_unlock_irqrestore(&gnttab_list_lock, flags);
-+ return -1;
++ return rc;
+ }
++
+ ref = head = gnttab_free_head;
+ gnttab_free_count -= count;
+ while (count-- > 1)
-+ head = gnttab_list[head];
-+ gnttab_free_head = gnttab_list[head];
-+ gnttab_list[head] = GNTTAB_LIST_END;
++ head = gnttab_entry(head);
++ gnttab_free_head = gnttab_entry(head);
++ gnttab_entry(head) = GNTTAB_LIST_END;
++
+ spin_unlock_irqrestore(&gnttab_list_lock, flags);
++
+ return ref;
+}
+
@@ -53638,7 +51053,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+{
+ unsigned long flags;
+ spin_lock_irqsave(&gnttab_list_lock, flags);
-+ gnttab_list[ref] = gnttab_free_head;
++ gnttab_entry(ref) = gnttab_free_head;
+ gnttab_free_head = ref;
+ gnttab_free_count++;
+ check_free_callbacks();
@@ -53654,7 +51069,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+{
+ int ref;
+
-+ if (unlikely((ref = get_free_entry()) == -1))
++ if (unlikely((ref = get_free_entry()) < 0))
+ return -ENOSPC;
+
+ shared[ref].frame = frame;
@@ -53724,7 +51139,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+{
+ int ref;
+
-+ if (unlikely((ref = get_free_entry()) == -1))
++ if (unlikely((ref = get_free_entry()) < 0))
+ return -ENOSPC;
+ gnttab_grant_foreign_transfer_ref(ref, domid, pfn);
+
@@ -53795,11 +51210,11 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ return;
+ spin_lock_irqsave(&gnttab_list_lock, flags);
+ ref = head;
-+ while (gnttab_list[ref] != GNTTAB_LIST_END) {
-+ ref = gnttab_list[ref];
++ while (gnttab_entry(ref) != GNTTAB_LIST_END) {
++ ref = gnttab_entry(ref);
+ count++;
+ }
-+ gnttab_list[ref] = gnttab_free_head;
++ gnttab_entry(ref) = gnttab_free_head;
+ gnttab_free_head = head;
+ gnttab_free_count += count;
+ check_free_callbacks();
@@ -53811,7 +51226,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+{
+ int h = get_free_entries(count);
+
-+ if (h == -1)
++ if (h < 0)
+ return -ENOSPC;
+
+ *head = h;
@@ -53831,7 +51246,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ grant_ref_t g = *private_head;
+ if (unlikely(g == GNTTAB_LIST_END))
+ return -ENOSPC;
-+ *private_head = gnttab_list[g];
++ *private_head = gnttab_entry(g);
+ return g;
+}
+EXPORT_SYMBOL_GPL(gnttab_claim_grant_reference);
@@ -53839,7 +51254,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+void gnttab_release_grant_reference(grant_ref_t *private_head,
+ grant_ref_t release)
+{
-+ gnttab_list[release] = *private_head;
++ gnttab_entry(release) = *private_head;
+ *private_head = release;
+}
+EXPORT_SYMBOL_GPL(gnttab_release_grant_reference);
@@ -53878,6 +51293,64 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+}
+EXPORT_SYMBOL_GPL(gnttab_cancel_free_callback);
+
++static int grow_gnttab_list(unsigned int more_frames)
++{
++ unsigned int new_nr_grant_frames, extra_entries, i;
++
++ new_nr_grant_frames = nr_grant_frames + more_frames;
++ extra_entries = more_frames * GREFS_PER_GRANT_FRAME;
++
++ for (i = nr_grant_frames; i < new_nr_grant_frames; i++)
++ {
++ gnttab_list[i] = (grant_ref_t *)__get_free_page(GFP_ATOMIC);
++ if (!gnttab_list[i])
++ goto grow_nomem;
++ }
++
++
++ for (i = GREFS_PER_GRANT_FRAME * nr_grant_frames;
++ i < GREFS_PER_GRANT_FRAME * new_nr_grant_frames - 1; i++)
++ gnttab_entry(i) = i + 1;
++
++ gnttab_entry(i) = gnttab_free_head;
++ gnttab_free_head = GREFS_PER_GRANT_FRAME * nr_grant_frames;
++ gnttab_free_count += extra_entries;
++
++ nr_grant_frames = new_nr_grant_frames;
++
++ check_free_callbacks();
++
++ return 0;
++
++grow_nomem:
++ for ( ; i >= nr_grant_frames; i--)
++ free_page((unsigned long) gnttab_list[i]);
++ return -ENOMEM;
++}
++
++static unsigned int __max_nr_grant_frames(void)
++{
++ struct gnttab_query_size query;
++ int rc;
++
++ query.dom = DOMID_SELF;
++
++ rc = HYPERVISOR_grant_table_op(GNTTABOP_query_size, &query, 1);
++ if ((rc < 0) || (query.status != GNTST_okay))
++ return 4; /* Legacy max supported number of frames */
++
++ return query.max_nr_frames;
++}
++
++static inline unsigned int max_nr_grant_frames(void)
++{
++ unsigned int xen_max = __max_nr_grant_frames();
++
++ if (xen_max > boot_max_nr_grant_frames)
++ return boot_max_nr_grant_frames;
++ return xen_max;
++}
++
+#ifdef CONFIG_XEN
+
+#ifndef __ia64__
@@ -53900,49 +51373,62 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+}
+#endif
+
-+int gnttab_resume(void)
++static int gnttab_map(unsigned int start_idx, unsigned int end_idx)
+{
+ struct gnttab_setup_table setup;
-+ unsigned long frames[NR_GRANT_FRAMES];
++ unsigned long *frames;
++ unsigned int nr_gframes = end_idx + 1;
+ int rc;
-+#ifndef __ia64__
-+ void *pframes = frames;
-+ struct vm_struct *area;
-+#endif
++
++ frames = kmalloc(nr_gframes * sizeof(unsigned long), GFP_ATOMIC);
++ if (!frames)
++ return -ENOMEM;
+
+ setup.dom = DOMID_SELF;
-+ setup.nr_frames = NR_GRANT_FRAMES;
++ setup.nr_frames = nr_gframes;
+ set_xen_guest_handle(setup.frame_list, frames);
+
+ rc = HYPERVISOR_grant_table_op(GNTTABOP_setup_table, &setup, 1);
-+ if (rc == -ENOSYS)
++ if (rc == -ENOSYS) {
++ kfree(frames);
+ return -ENOSYS;
++ }
+
+ BUG_ON(rc || setup.status);
+
+#ifndef __ia64__
+ if (shared == NULL) {
-+ area = get_vm_area(PAGE_SIZE * NR_GRANT_FRAMES, VM_IOREMAP);
++ struct vm_struct *area;
++ area = alloc_vm_area(PAGE_SIZE * max_nr_grant_frames());
+ BUG_ON(area == NULL);
+ shared = area->addr;
+ }
+ rc = apply_to_page_range(&init_mm, (unsigned long)shared,
-+ PAGE_SIZE * NR_GRANT_FRAMES,
-+ map_pte_fn, &pframes);
++ PAGE_SIZE * nr_gframes,
++ map_pte_fn, &frames);
+ BUG_ON(rc);
++ frames -= nr_gframes; /* adjust after map_pte_fn() */
+#else
+ shared = __va(frames[0] << PAGE_SHIFT);
-+ printk("grant table at %p\n", shared);
+#endif
+
++ kfree(frames);
++
+ return 0;
+}
+
++int gnttab_resume(void)
++{
++ if (max_nr_grant_frames() < nr_grant_frames)
++ return -ENOSYS;
++ return gnttab_map(0, nr_grant_frames - 1);
++}
++
+int gnttab_suspend(void)
+{
+#ifndef __ia64__
+ apply_to_page_range(&init_mm, (unsigned long)shared,
-+ PAGE_SIZE * NR_GRANT_FRAMES,
++ PAGE_SIZE * nr_grant_frames,
+ unmap_pte_fn, NULL);
+#endif
+ return 0;
@@ -53952,65 +51438,127 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+
+#include <platform-pci.h>
+
-+int gnttab_resume(void)
++static unsigned long resume_frames;
++
++static int gnttab_map(unsigned int start_idx, unsigned int end_idx)
+{
-+ unsigned long frames;
+ struct xen_add_to_physmap xatp;
-+ unsigned int i;
-+
-+ frames = alloc_xen_mmio(PAGE_SIZE * NR_GRANT_FRAMES);
++ unsigned int i = end_idx;
+
-+ for (i = 0; i < NR_GRANT_FRAMES; i++) {
++ /* Loop backwards, so that the first hypercall has the largest index,
++ * ensuring that the table will grow only once.
++ */
++ do {
+ xatp.domid = DOMID_SELF;
+ xatp.idx = i;
+ xatp.space = XENMAPSPACE_grant_table;
-+ xatp.gpfn = (frames >> PAGE_SHIFT) + i;
++ xatp.gpfn = (resume_frames >> PAGE_SHIFT) + i;
+ if (HYPERVISOR_memory_op(XENMEM_add_to_physmap, &xatp))
+ BUG();
-+ }
-+
-+ shared = ioremap(frames, PAGE_SIZE * NR_GRANT_FRAMES);
-+ if (shared == NULL) {
-+ printk("error to ioremap gnttab share frames\n");
-+ return -1;
-+ }
++ } while (i-- > start_idx);
+
+ return 0;
+}
+
-+int gnttab_suspend(void)
++int gnttab_resume(void)
+{
-+ iounmap(shared);
++ unsigned int max_nr_gframes, nr_gframes;
++
++ nr_gframes = nr_grant_frames;
++ max_nr_gframes = max_nr_grant_frames();
++ if (max_nr_gframes < nr_gframes)
++ return -ENOSYS;
++
++ if (!resume_frames) {
++ resume_frames = alloc_xen_mmio(PAGE_SIZE * max_nr_gframes);
++ shared = ioremap(resume_frames, PAGE_SIZE * max_nr_gframes);
++ if (shared == NULL) {
++ printk("error to ioremap gnttab share frames\n");
++ return -1;
++ }
++ }
++
++ gnttab_map(0, nr_gframes - 1);
++
+ return 0;
+}
+
+#endif /* !CONFIG_XEN */
+
-+int __init gnttab_init(void)
++static int gnttab_expand(unsigned int req_entries)
++{
++ int rc;
++ unsigned int cur, extra;
++
++ cur = nr_grant_frames;
++ extra = ((req_entries + (GREFS_PER_GRANT_FRAME-1)) /
++ GREFS_PER_GRANT_FRAME);
++ if (cur + extra > max_nr_grant_frames())
++ return -ENOSPC;
++
++ if ((rc = gnttab_map(cur, cur + extra - 1)) == 0)
++ rc = grow_gnttab_list(extra);
++
++ return rc;
++}
++
++int __devinit gnttab_init(void)
+{
+ int i;
++ unsigned int max_nr_glist_frames;
++ unsigned int nr_init_grefs;
+
+ if (!is_running_on_xen())
+ return -ENODEV;
+
++ nr_grant_frames = 1;
++ boot_max_nr_grant_frames = __max_nr_grant_frames();
++
++ /* Determine the maximum number of frames required for the
++ * grant reference free list on the current hypervisor.
++ */
++ max_nr_glist_frames = (boot_max_nr_grant_frames *
++ GREFS_PER_GRANT_FRAME /
++ (PAGE_SIZE / sizeof(grant_ref_t)));
++
++ gnttab_list = kmalloc(max_nr_glist_frames * sizeof(grant_ref_t *),
++ GFP_KERNEL);
++ if (gnttab_list == NULL)
++ return -ENOMEM;
++
++ for (i = 0; i < nr_grant_frames; i++) {
++ gnttab_list[i] = (grant_ref_t *)__get_free_page(GFP_KERNEL);
++ if (gnttab_list[i] == NULL)
++ goto ini_nomem;
++ }
++
+ if (gnttab_resume() < 0)
+ return -ENODEV;
+
-+ for (i = NR_RESERVED_ENTRIES; i < NR_GRANT_ENTRIES; i++)
-+ gnttab_list[i] = i + 1;
-+ gnttab_free_count = NR_GRANT_ENTRIES - NR_RESERVED_ENTRIES;
++ nr_init_grefs = nr_grant_frames * GREFS_PER_GRANT_FRAME;
++
++ for (i = NR_RESERVED_ENTRIES; i < nr_init_grefs - 1; i++)
++ gnttab_entry(i) = i + 1;
++
++ gnttab_entry(nr_init_grefs - 1) = GNTTAB_LIST_END;
++ gnttab_free_count = nr_init_grefs - NR_RESERVED_ENTRIES;
+ gnttab_free_head = NR_RESERVED_ENTRIES;
+
-+ printk("Grant table initialized\n");
+ return 0;
++
++ ini_nomem:
++ for (i--; i >= 0; i--)
++ free_page((unsigned long)gnttab_list[i]);
++ kfree(gnttab_list);
++ return -ENOMEM;
+}
+
+#ifdef CONFIG_XEN
+core_initcall(gnttab_init);
+#endif
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/drivers/xen/core/hypervisor_sysfs.c source/drivers/xen/core/hypervisor_sysfs.c
---- /scratch/src/linux-2.6.20.3/drivers/xen/core/hypervisor_sysfs.c 1970-01-01 01:00:00.000000000 +0100
-+++ source/drivers/xen/core/hypervisor_sysfs.c 2007-03-20 21:26:49.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 drivers/xen/core/hypervisor_sysfs.c
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/drivers/xen/core/hypervisor_sysfs.c Wed Aug 08 16:25:28 2007 -0300
@@ -0,0 +1,59 @@
+/*
+ * copyright (c) 2006 IBM Corporation
@@ -54071,10 +51619,10 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+
+device_initcall(hypervisor_subsys_init);
+EXPORT_SYMBOL_GPL(hypervisor_subsys);
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/drivers/xen/core/machine_kexec.c source/drivers/xen/core/machine_kexec.c
---- /scratch/src/linux-2.6.20.3/drivers/xen/core/machine_kexec.c 1970-01-01 01:00:00.000000000 +0100
-+++ source/drivers/xen/core/machine_kexec.c 2007-03-20 21:26:49.000000000 +0100
-@@ -0,0 +1,190 @@
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 drivers/xen/core/machine_kexec.c
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/drivers/xen/core/machine_kexec.c Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,189 @@
+/*
+ * drivers/xen/core/machine_kexec.c
+ * handle transition of Linux booting another kernel
@@ -54084,7 +51632,6 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#include <xen/interface/kexec.h>
+#include <linux/mm.h>
+#include <linux/bootmem.h>
-+#include <asm/hypercall.h>
+
+extern void machine_kexec_setup_load_arg(xen_kexec_image_t *xki,
+ struct kimage *image);
@@ -54175,8 +51722,8 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ err:
+ /*
+ * It isn't possible to free xen_phys_cpus this early in the
-+ * boot. Since failure at this stage is unexpected and the
-+ * amount is small we leak the memory.
++ * boot. Failure at this stage is unexpected and the amount of
++ * memory is small therefore we tolerate the potential leak.
+ */
+ xen_max_nr_phys_cpus = 0;
+ return;
@@ -54265,11 +51812,10 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ * tab-width: 8
+ * End:
+ */
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/drivers/xen/core/machine_reboot.c source/drivers/xen/core/machine_reboot.c
---- /scratch/src/linux-2.6.20.3/drivers/xen/core/machine_reboot.c 1970-01-01 01:00:00.000000000 +0100
-+++ source/drivers/xen/core/machine_reboot.c 2007-03-20 21:26:49.000000000 +0100
-@@ -0,0 +1,185 @@
-+#define __KERNEL_SYSCALLS__
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 drivers/xen/core/machine_reboot.c
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/drivers/xen/core/machine_reboot.c Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,241 @@
+#include <linux/version.h>
+#include <linux/kernel.h>
+#include <linux/mm.h>
@@ -54278,17 +51824,18 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#include <linux/reboot.h>
+#include <linux/sysrq.h>
+#include <linux/stringify.h>
++#include <linux/stop_machine.h>
+#include <asm/irq.h>
+#include <asm/mmu_context.h>
+#include <xen/evtchn.h>
+#include <asm/hypervisor.h>
-+#include <xen/interface/dom0_ops.h>
+#include <xen/xenbus.h>
+#include <linux/cpu.h>
+#include <linux/kthread.h>
+#include <xen/gnttab.h>
+#include <xen/xencons.h>
+#include <xen/cpu_hotplug.h>
++#include <xen/interface/vcpu.h>
+
+#if defined(__i386__) || defined(__x86_64__)
+
@@ -54329,49 +51876,43 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+EXPORT_SYMBOL(machine_halt);
+EXPORT_SYMBOL(machine_power_off);
+
-+/* Ensure we run on the idle task page tables so that we will
-+ switch page tables before running user space. This is needed
-+ on architectures with separate kernel and user page tables
-+ because the user page table pointer is not saved/restored. */
-+static void switch_idle_mm(void)
-+{
-+ struct mm_struct *mm = current->active_mm;
-+
-+ if (mm == &init_mm)
-+ return;
-+
-+ atomic_inc(&init_mm.mm_count);
-+ switch_mm(mm, &init_mm, current);
-+ current->active_mm = &init_mm;
-+ mmdrop(mm);
-+}
-+
+static void pre_suspend(void)
+{
+ HYPERVISOR_shared_info = (shared_info_t *)empty_zero_page;
-+ clear_fixmap(FIX_SHARED_INFO);
++ HYPERVISOR_update_va_mapping(fix_to_virt(FIX_SHARED_INFO),
++ __pte_ma(0), 0);
+
+ xen_start_info->store_mfn = mfn_to_pfn(xen_start_info->store_mfn);
+ xen_start_info->console.domU.mfn =
+ mfn_to_pfn(xen_start_info->console.domU.mfn);
+}
+
-+static void post_suspend(void)
++static void post_suspend(int suspend_cancelled)
+{
+ int i, j, k, fpp;
++ unsigned long shinfo_mfn;
+ extern unsigned long max_pfn;
+ extern unsigned long *pfn_to_mfn_frame_list_list;
+ extern unsigned long *pfn_to_mfn_frame_list[];
+
-+ set_fixmap(FIX_SHARED_INFO, xen_start_info->shared_info);
++ if (suspend_cancelled) {
++ xen_start_info->store_mfn =
++ pfn_to_mfn(xen_start_info->store_mfn);
++ xen_start_info->console.domU.mfn =
++ pfn_to_mfn(xen_start_info->console.domU.mfn);
++ } else {
++#ifdef CONFIG_SMP
++ cpu_initialized_map = cpu_online_map;
++#endif
++ }
+
++ shinfo_mfn = xen_start_info->shared_info >> PAGE_SHIFT;
++ HYPERVISOR_update_va_mapping(fix_to_virt(FIX_SHARED_INFO),
++ pfn_pte_ma(shinfo_mfn, PAGE_KERNEL), 0);
+ HYPERVISOR_shared_info = (shared_info_t *)fix_to_virt(FIX_SHARED_INFO);
+
+ memset(empty_zero_page, 0, PAGE_SIZE);
+
-+ HYPERVISOR_shared_info->arch.pfn_to_mfn_frame_list_list =
-+ virt_to_mfn(pfn_to_mfn_frame_list_list);
-+
+ fpp = PAGE_SIZE/sizeof(unsigned long);
+ for (i = 0, j = 0, k = -1; i < max_pfn; i += fpp, j++) {
+ if ((j % fpp) == 0) {
@@ -54384,98 +51925,142 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ virt_to_mfn(&phys_to_machine_mapping[i]);
+ }
+ HYPERVISOR_shared_info->arch.max_pfn = max_pfn;
++ HYPERVISOR_shared_info->arch.pfn_to_mfn_frame_list_list =
++ virt_to_mfn(pfn_to_mfn_frame_list_list);
+}
+
+#else /* !(defined(__i386__) || defined(__x86_64__)) */
+
++#ifndef HAVE_XEN_PRE_SUSPEND
++#define xen_pre_suspend() ((void)0)
++#endif
++
++#ifndef HAVE_XEN_POST_SUSPEND
++#define xen_post_suspend(x) ((void)0)
++#endif
++
+#define switch_idle_mm() ((void)0)
+#define mm_pin_all() ((void)0)
-+#define pre_suspend() ((void)0)
-+#define post_suspend() ((void)0)
++#define pre_suspend() xen_pre_suspend()
++#define post_suspend(x) xen_post_suspend(x)
+
+#endif
+
-+int __xen_suspend(void)
++static int take_machine_down(void *p_fast_suspend)
+{
-+ int err;
-+
++ int fast_suspend = *(int *)p_fast_suspend;
++ int suspend_cancelled, err;
+ extern void time_resume(void);
+
-+ BUG_ON(smp_processor_id() != 0);
-+ BUG_ON(in_interrupt());
++ if (fast_suspend) {
++ BUG_ON(!irqs_disabled());
++ } else {
++ BUG_ON(irqs_disabled());
+
-+#if defined(__i386__) || defined(__x86_64__)
-+ if (xen_feature(XENFEAT_auto_translated_physmap)) {
-+ printk(KERN_WARNING "Cannot suspend in "
-+ "auto_translated_physmap mode.\n");
-+ return -EOPNOTSUPP;
-+ }
-+#endif
++ for (;;) {
++ err = smp_suspend();
++ if (err)
++ return err;
+
-+ err = smp_suspend();
-+ if (err)
-+ return err;
++ xenbus_suspend();
++ preempt_disable();
+
-+ xenbus_suspend();
++ if (num_online_cpus() == 1)
++ break;
+
-+ preempt_disable();
++ preempt_enable();
++ xenbus_suspend_cancel();
++ }
+
-+ mm_pin_all();
-+ local_irq_disable();
-+ preempt_enable();
++ local_irq_disable();
++ }
+
++ mm_pin_all();
+ gnttab_suspend();
-+
+ pre_suspend();
+
+ /*
-+ * We'll stop somewhere inside this hypercall. When it returns,
-+ * we'll start resuming after the restore.
++ * This hypercall returns 1 if suspend was cancelled or the domain was
++ * merely checkpointed, and 0 if it is resuming in a new domain.
+ */
-+ HYPERVISOR_suspend(virt_to_mfn(xen_start_info));
-+
-+ post_suspend();
++ suspend_cancelled = HYPERVISOR_suspend(virt_to_mfn(xen_start_info));
+
++ post_suspend(suspend_cancelled);
+ gnttab_resume();
++ if (!suspend_cancelled) {
++ irq_resume();
++#ifdef __x86_64__
++ /*
++ * Older versions of Xen do not save/restore the user %cr3.
++ * We do it here just in case, but there's no need if we are
++ * in fast-suspend mode as that implies a new enough Xen.
++ */
++ if (!fast_suspend) {
++ struct mmuext_op op;
++ op.cmd = MMUEXT_NEW_USER_BASEPTR;
++ op.arg1.mfn = pfn_to_mfn(__pa(__user_pgd(
++ current->active_mm->pgd)) >> PAGE_SHIFT);
++ if (HYPERVISOR_mmuext_op(&op, 1, NULL, DOMID_SELF))
++ BUG();
++ }
++#endif
++ }
++ time_resume();
+
-+ irq_resume();
++ if (!fast_suspend)
++ local_irq_enable();
+
-+ time_resume();
++ return suspend_cancelled;
++}
+
-+ switch_idle_mm();
++int __xen_suspend(int fast_suspend)
++{
++ int err, suspend_cancelled;
+
-+ local_irq_enable();
++ BUG_ON(smp_processor_id() != 0);
++ BUG_ON(in_interrupt());
+
-+ xencons_resume();
++#if defined(__i386__) || defined(__x86_64__)
++ if (xen_feature(XENFEAT_auto_translated_physmap)) {
++ printk(KERN_WARNING "Cannot suspend in "
++ "auto_translated_physmap mode.\n");
++ return -EOPNOTSUPP;
++ }
++#endif
+
-+ xenbus_resume();
++ /* If we are definitely UP then 'slow mode' is actually faster. */
++ if (num_possible_cpus() == 1)
++ fast_suspend = 0;
+
-+ smp_resume();
++ if (fast_suspend) {
++ xenbus_suspend();
++ err = stop_machine_run(take_machine_down, &fast_suspend, 0);
++ if (err < 0)
++ xenbus_suspend_cancel();
++ } else {
++ err = take_machine_down(&fast_suspend);
++ }
+
-+ return err;
-+}
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/drivers/xen/core/Makefile source/drivers/xen/core/Makefile
---- /scratch/src/linux-2.6.20.3/drivers/xen/core/Makefile 1970-01-01 01:00:00.000000000 +0100
-+++ source/drivers/xen/core/Makefile 2007-03-20 21:26:49.000000000 +0100
-@@ -0,0 +1,14 @@
-+#
-+# Makefile for the linux kernel.
-+#
++ if (err < 0)
++ return err;
+
-+obj-y := evtchn.o gnttab.o features.o
++ suspend_cancelled = err;
++ if (!suspend_cancelled) {
++ xencons_resume();
++ xenbus_resume();
++ } else {
++ xenbus_suspend_cancel();
++ }
+
-+obj-$(CONFIG_PROC_FS) += xen_proc.o
-+obj-$(CONFIG_SYSFS) += hypervisor_sysfs.o
-+obj-$(CONFIG_HOTPLUG_CPU) += cpu_hotplug.o
-+obj-$(CONFIG_XEN_SYSFS) += xen_sysfs.o
-+obj-$(CONFIG_XEN_SKBUFF) += skbuff.o
-+obj-$(CONFIG_XEN_REBOOT) += reboot.o machine_reboot.o
-+obj-$(CONFIG_XEN_SMPBOOT) += smpboot.o
-+obj-$(CONFIG_KEXEC) += machine_kexec.o
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/drivers/xen/core/reboot.c source/drivers/xen/core/reboot.c
---- /scratch/src/linux-2.6.20.3/drivers/xen/core/reboot.c 1970-01-01 01:00:00.000000000 +0100
-+++ source/drivers/xen/core/reboot.c 2007-03-20 21:26:49.000000000 +0100
-@@ -0,0 +1,221 @@
++ if (!fast_suspend)
++ smp_resume();
++
++ return 0;
++}
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 drivers/xen/core/reboot.c
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/drivers/xen/core/reboot.c Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,249 @@
+#define __KERNEL_SYSCALLS__
+#include <linux/version.h>
+#include <linux/kernel.h>
@@ -54488,6 +52073,10 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#include <xen/xenbus.h>
+#include <linux/kthread.h>
+
++#ifdef HAVE_XEN_PLATFORM_COMPAT_H
++#include <xen/platform-compat.h>
++#endif
++
+MODULE_LICENSE("Dual BSD/GPL");
+
+#define SHUTDOWN_INVALID -1
@@ -54503,14 +52092,13 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+/* Ignore multiple shutdown requests. */
+static int shutting_down = SHUTDOWN_INVALID;
+
++/* Can we leave APs online when we suspend? */
++static int fast_suspend;
++
+static void __shutdown_handler(struct work_struct *work);
+static DECLARE_DELAYED_WORK(shutdown_work, __shutdown_handler);
+
-+#ifdef CONFIG_XEN
-+int __xen_suspend(void);
-+#else
-+#define __xen_suspend() (void)0
-+#endif
++int __xen_suspend(int fast_suspend);
+
+static int shutdown_process(void *__unused)
+{
@@ -54540,7 +52128,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+
+static int xen_suspend(void *__unused)
+{
-+ __xen_suspend();
++ int err = __xen_suspend(fast_suspend);
++ if (err)
++ printk(KERN_ERR "Xen suspend failed (%d)\n", err);
+ shutting_down = SHUTDOWN_INVALID;
+ return 0;
+}
@@ -54579,6 +52169,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+static void shutdown_handler(struct xenbus_watch *watch,
+ const char **vec, unsigned int len)
+{
++ extern void ctrl_alt_del(void);
+ char *str;
+ struct xenbus_transaction xbt;
+ int err;
@@ -54590,6 +52181,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ err = xenbus_transaction_start(&xbt);
+ if (err)
+ return;
++
+ str = (char *)xenbus_read(xbt, "control", "shutdown", NULL);
+ /* Ignore read errors and empty reads. */
+ if (XENBUS_IS_ERR_READ(str)) {
@@ -54608,7 +52200,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ if (strcmp(str, "poweroff") == 0)
+ shutting_down = SHUTDOWN_POWEROFF;
+ else if (strcmp(str, "reboot") == 0)
-+ kill_proc(1, SIGINT, 1); /* interrupt init */
++ ctrl_alt_del();
+ else if (strcmp(str, "suspend") == 0)
+ shutting_down = SHUTDOWN_SUSPEND;
+ else if (strcmp(str, "halt") == 0)
@@ -54661,35 +52253,47 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+};
+
+static struct xenbus_watch sysrq_watch = {
-+ .node ="control/sysrq",
++ .node = "control/sysrq",
+ .callback = sysrq_handler
+};
+
-+static int setup_shutdown_watcher(struct notifier_block *notifier,
-+ unsigned long event,
-+ void *data)
++static int setup_shutdown_watcher(void)
+{
+ int err;
+
++ xenbus_scanf(XBT_NIL, "control",
++ "platform-feature-multiprocessor-suspend",
++ "%d", &fast_suspend);
++
+ err = register_xenbus_watch(&shutdown_watch);
-+ if (err)
++ if (err) {
+ printk(KERN_ERR "Failed to set shutdown watcher\n");
-+ else
-+ xenbus_write(XBT_NIL, "control", "feature-reboot", "1");
++ return err;
++ }
+
+ err = register_xenbus_watch(&sysrq_watch);
-+ if (err)
++ if (err) {
+ printk(KERN_ERR "Failed to set sysrq watcher\n");
-+ else
-+ xenbus_write(XBT_NIL, "control", "feature-sysrq", "1");
++ return err;
++ }
+
++ return 0;
++}
++
++#ifdef CONFIG_XEN
++
++static int shutdown_event(struct notifier_block *notifier,
++ unsigned long event,
++ void *data)
++{
++ setup_shutdown_watcher();
+ return NOTIFY_DONE;
+}
+
+static int __init setup_shutdown_event(void)
+{
+ static struct notifier_block xenstore_notifier = {
-+ .notifier_call = setup_shutdown_watcher
++ .notifier_call = shutdown_event
+ };
+ register_xenstore_notifier(&xenstore_notifier);
+
@@ -54697,158 +52301,19 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+}
+
+subsys_initcall(setup_shutdown_event);
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/drivers/xen/core/skbuff.c source/drivers/xen/core/skbuff.c
---- /scratch/src/linux-2.6.20.3/drivers/xen/core/skbuff.c 1970-01-01 01:00:00.000000000 +0100
-+++ source/drivers/xen/core/skbuff.c 2007-03-20 21:26:49.000000000 +0100
-@@ -0,0 +1,144 @@
-+
-+#include <linux/module.h>
-+#include <linux/version.h>
-+#include <linux/kernel.h>
-+#include <linux/sched.h>
-+#include <linux/slab.h>
-+#include <linux/netdevice.h>
-+#include <linux/inetdevice.h>
-+#include <linux/etherdevice.h>
-+#include <linux/skbuff.h>
-+#include <linux/init.h>
-+#include <asm/io.h>
-+#include <asm/page.h>
-+#include <asm/hypervisor.h>
-+
-+/* Referenced in netback.c. */
-+/*static*/ struct kmem_cache *skbuff_cachep;
-+EXPORT_SYMBOL(skbuff_cachep);
-+
-+/* Allow up to 64kB or page-sized packets (whichever is greater). */
-+#if PAGE_SHIFT < 16
-+#define MAX_SKBUFF_ORDER (16 - PAGE_SHIFT)
-+#else
-+#define MAX_SKBUFF_ORDER 0
-+#endif
-+static struct kmem_cache *skbuff_order_cachep[MAX_SKBUFF_ORDER + 1];
-+
-+static struct {
-+ int size;
-+ struct kmem_cache *cachep;
-+} skbuff_small[] = { { 512, NULL }, { 2048, NULL } };
-+
-+struct sk_buff *__alloc_skb(unsigned int length, gfp_t gfp_mask,
-+ int fclone, int node)
-+{
-+ int order, i;
-+ struct kmem_cache *cachep;
-+
-+ length = SKB_DATA_ALIGN(length) + sizeof(struct skb_shared_info);
-+
-+ if (length <= skbuff_small[ARRAY_SIZE(skbuff_small)-1].size) {
-+ for (i = 0; skbuff_small[i].size < length; i++)
-+ continue;
-+ cachep = skbuff_small[i].cachep;
-+ } else {
-+ order = get_order(length);
-+ if (order > MAX_SKBUFF_ORDER) {
-+ printk(KERN_ALERT "Attempt to allocate order %d "
-+ "skbuff. Increase MAX_SKBUFF_ORDER.\n", order);
-+ return NULL;
-+ }
-+ cachep = skbuff_order_cachep[order];
-+ }
-+
-+ length -= sizeof(struct skb_shared_info);
-+
-+ return alloc_skb_from_cache(cachep, length, gfp_mask, fclone);
-+}
-+
-+struct sk_buff *__dev_alloc_skb(unsigned int length, gfp_t gfp_mask)
-+{
-+ struct sk_buff *skb;
-+ int order;
-+
-+ length = SKB_DATA_ALIGN(length + 16);
-+ order = get_order(length + sizeof(struct skb_shared_info));
-+ if (order > MAX_SKBUFF_ORDER) {
-+ printk(KERN_ALERT "Attempt to allocate order %d skbuff. "
-+ "Increase MAX_SKBUFF_ORDER.\n", order);
-+ return NULL;
-+ }
-+
-+ skb = alloc_skb_from_cache(
-+ skbuff_order_cachep[order], length, gfp_mask, 0);
-+ if (skb != NULL)
-+ skb_reserve(skb, 16);
-+
-+ return skb;
-+}
-+
-+static void skbuff_ctor(void *buf, struct kmem_cache *cachep, unsigned long unused)
-+{
-+ int order = 0;
-+
-+ while (skbuff_order_cachep[order] != cachep)
-+ order++;
+
-+ /* Do our best to allocate contiguous memory but fall back to IOMMU. */
-+ if (order != 0)
-+ (void)xen_create_contiguous_region(
-+ (unsigned long)buf, order, 0);
++#else /* !defined(CONFIG_XEN) */
+
-+ scrub_pages(buf, 1 << order);
-+}
-+
-+static void skbuff_dtor(void *buf, struct kmem_cache *cachep, unsigned long unused)
++int xen_reboot_init(void)
+{
-+ int order = 0;
-+
-+ while (skbuff_order_cachep[order] != cachep)
-+ order++;
-+
-+ if (order != 0)
-+ xen_destroy_contiguous_region((unsigned long)buf, order);
++ return setup_shutdown_watcher();
+}
+
-+static int __init skbuff_init(void)
-+{
-+ static char name[MAX_SKBUFF_ORDER + 1][20];
-+ static char small_name[ARRAY_SIZE(skbuff_small)][20];
-+ unsigned long size;
-+ int i, order;
-+
-+ for (i = 0; i < ARRAY_SIZE(skbuff_small); i++) {
-+ size = skbuff_small[i].size;
-+ sprintf(small_name[i], "xen-skb-%lu", size);
-+ /*
-+ * No ctor/dtor: objects do not span page boundaries, and they
-+ * are only used on transmit path so no need for scrubbing.
-+ */
-+ skbuff_small[i].cachep = kmem_cache_create(
-+ small_name[i], size, size, 0, NULL, NULL);
-+ }
-+
-+ for (order = 0; order <= MAX_SKBUFF_ORDER; order++) {
-+ size = PAGE_SIZE << order;
-+ sprintf(name[order], "xen-skb-%lu", size);
-+ if (is_running_on_xen() && is_initial_xendomain())
-+ skbuff_order_cachep[order] = kmem_cache_create(
-+ name[order], size, size, 0,
-+ skbuff_ctor, skbuff_dtor);
-+ else
-+ skbuff_order_cachep[order] = kmem_cache_create(
-+ name[order], size, size, 0, NULL, NULL);
-+
-+ }
-+
-+ skbuff_cachep = skbuff_order_cachep[0];
-+
-+ return 0;
-+}
-+core_initcall(skbuff_init);
-+
-+EXPORT_SYMBOL(__dev_alloc_skb);
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/drivers/xen/core/smpboot.c source/drivers/xen/core/smpboot.c
---- /scratch/src/linux-2.6.20.3/drivers/xen/core/smpboot.c 1970-01-01 01:00:00.000000000 +0100
-+++ source/drivers/xen/core/smpboot.c 2007-03-20 21:26:49.000000000 +0100
-@@ -0,0 +1,503 @@
++#endif /* !defined(CONFIG_XEN) */
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 drivers/xen/core/smpboot.c
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/drivers/xen/core/smpboot.c Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,511 @@
+/*
+ * Xen SMP booting functions
+ *
@@ -54869,7 +52334,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#include <linux/cpu.h>
+#include <linux/percpu.h>
+#include <asm/desc.h>
++#ifdef __i386__
+#include <asm/arch_hooks.h>
++#endif
+#include <asm/pgalloc.h>
+#if defined(__i386__)
+#include <asm/pda.h>
@@ -54904,6 +52371,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+EXPORT_SYMBOL(cpu_online_map);
+cpumask_t cpu_possible_map;
+EXPORT_SYMBOL(cpu_possible_map);
++cpumask_t cpu_initialized_map;
+
+struct cpuinfo_x86 cpu_data[NR_CPUS] __cacheline_aligned;
+EXPORT_SYMBOL(cpu_data);
@@ -54935,6 +52403,10 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+{
+ int i, rc;
+
++ for_each_possible_cpu(i)
++ if (i != smp_processor_id())
++ return;
++
+ for (i = 0; i < NR_CPUS; i++) {
+ rc = HYPERVISOR_vcpu_op(VCPUOP_is_up, i, NULL);
+ if (rc >= 0)
@@ -54962,7 +52434,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+remove_siblinginfo(int cpu)
+{
+ cpu_data[cpu].phys_proc_id = BAD_APICID;
-+ cpu_data[cpu].cpu_core_id = BAD_APICID;
++ cpu_data[cpu].cpu_core_id = BAD_APICID;
+
+ cpus_clear(cpu_sibling_map[cpu]);
+ cpus_clear(cpu_core_map[cpu]);
@@ -55051,7 +52523,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ cpu_idle();
+}
+
-+void cpu_initialize_context(unsigned int cpu)
++static void cpu_initialize_context(unsigned int cpu)
+{
+ vcpu_guest_context_t ctxt;
+ struct task_struct *idle = idle_task(cpu);
@@ -55061,7 +52533,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ struct Xgt_desc_struct *gdt_descr = &per_cpu(cpu_gdt_descr, cpu);
+#endif
+
-+ if (cpu == 0)
++ if (cpu_test_and_set(cpu, cpu_initialized_map))
+ return;
+
+ memset(&ctxt, 0, sizeof(ctxt));
@@ -55144,6 +52616,8 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ if (xen_smp_intr_init(0))
+ BUG();
+
++ cpu_initialized_map = cpumask_of_cpu(0);
++
+ /* Restrict the possible_map according to max_cpus. */
+ while ((num_possible_cpus() > 1) && (num_possible_cpus() > max_cpus)) {
+ for (cpu = NR_CPUS-1; !cpu_isset(cpu, cpu_possible_map); cpu--)
@@ -55182,9 +52656,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ cpu);
+ continue;
+ }
-+ memset(pda, 0, sizeof(*pda));
+ cpu_pda(cpu) = pda;
-+ pda->_pda = pda;
+ cpu_pda(cpu)->cpu_number = cpu;
+ pack_descriptor((u32 *)&gdt[GDT_ENTRY_PDA].a,
+ (u32 *)&gdt[GDT_ENTRY_PDA].b,
@@ -55219,8 +52691,6 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#else
+ cpu_set(cpu, cpu_present_map);
+#endif
-+
-+ cpu_initialize_context(cpu);
+ }
+
+ init_xenbus_allowed_cpumask();
@@ -55237,6 +52707,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+
+void __init smp_prepare_boot_cpu(void)
+{
++ prefill_possible_map();
+}
+
+#ifdef CONFIG_HOTPLUG_CPU
@@ -55305,6 +52776,8 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ if (rc)
+ return rc;
+
++ cpu_initialize_context(cpu);
++
+ if (num_online_cpus() == 1)
+ alternatives_smp_switch(1);
+
@@ -55352,11 +52825,12 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ return -EINVAL;
+}
+#endif
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/drivers/xen/core/xen_proc.c source/drivers/xen/core/xen_proc.c
---- /scratch/src/linux-2.6.20.3/drivers/xen/core/xen_proc.c 1970-01-01 01:00:00.000000000 +0100
-+++ source/drivers/xen/core/xen_proc.c 2007-03-20 21:26:49.000000000 +0100
-@@ -0,0 +1,18 @@
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 drivers/xen/core/xen_proc.c
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/drivers/xen/core/xen_proc.c Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,23 @@
+
++#include <linux/module.h>
+#include <linux/proc_fs.h>
+#include <xen/xen_proc.h>
+
@@ -55370,13 +52844,17 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ return create_proc_entry(name, mode, xen_base);
+}
+
++EXPORT_SYMBOL_GPL(create_xen_proc_entry);
++
+void remove_xen_proc_entry(const char *name)
+{
+ remove_proc_entry(name, xen_base);
+}
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/drivers/xen/core/xen_sysfs.c source/drivers/xen/core/xen_sysfs.c
---- /scratch/src/linux-2.6.20.3/drivers/xen/core/xen_sysfs.c 1970-01-01 01:00:00.000000000 +0100
-+++ source/drivers/xen/core/xen_sysfs.c 2007-03-20 21:26:49.000000000 +0100
++
++EXPORT_SYMBOL_GPL(remove_xen_proc_entry);
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 drivers/xen/core/xen_sysfs.c
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/drivers/xen/core/xen_sysfs.c Wed Aug 08 16:25:28 2007 -0300
@@ -0,0 +1,378 @@
+/*
+ * copyright (c) 2006 IBM Corporation
@@ -55756,10 +53234,16 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+
+module_init(hyper_sysfs_init);
+module_exit(hyper_sysfs_exit);
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/drivers/xen/evtchn/evtchn.c source/drivers/xen/evtchn/evtchn.c
---- /scratch/src/linux-2.6.20.3/drivers/xen/evtchn/evtchn.c 1970-01-01 01:00:00.000000000 +0100
-+++ source/drivers/xen/evtchn/evtchn.c 2007-03-20 21:26:49.000000000 +0100
-@@ -0,0 +1,456 @@
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 drivers/xen/evtchn/Makefile
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/drivers/xen/evtchn/Makefile Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,2 @@
++
++obj-y := evtchn.o
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 drivers/xen/evtchn/evtchn.c
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/drivers/xen/evtchn/evtchn.c Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,469 @@
+/******************************************************************************
+ * evtchn.c
+ *
@@ -55809,6 +53293,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#include <linux/irq.h>
+#include <linux/init.h>
+#include <linux/gfp.h>
++#include <linux/mutex.h>
+#include <xen/evtchn.h>
+#include <xen/public/evtchn.h>
+
@@ -55818,6 +53303,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#define EVTCHN_RING_MASK(_i) ((_i)&(EVTCHN_RING_SIZE-1))
+ evtchn_port_t *ring;
+ unsigned int ring_cons, ring_prod, ring_overflow;
++ struct mutex ring_cons_mutex; /* protect against concurrent readers */
+
+ /* Processes wait on this queue when ring is empty. */
+ wait_queue_head_t evtchn_wait;
@@ -55870,12 +53356,17 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ count = PAGE_SIZE;
+
+ for (;;) {
++ mutex_lock(&u->ring_cons_mutex);
++
++ rc = -EFBIG;
+ if (u->ring_overflow)
-+ return -EFBIG;
++ goto unlock_out;
+
+ if ((c = u->ring_cons) != (p = u->ring_prod))
+ break;
+
++ mutex_unlock(&u->ring_cons_mutex);
++
+ if (file->f_flags & O_NONBLOCK)
+ return -EAGAIN;
+
@@ -55903,20 +53394,24 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ bytes2 = count - bytes1;
+ }
+
++ rc = -EFAULT;
+ if (copy_to_user(buf, &u->ring[EVTCHN_RING_MASK(c)], bytes1) ||
+ ((bytes2 != 0) &&
+ copy_to_user(&buf[bytes1], &u->ring[0], bytes2)))
-+ return -EFAULT;
++ goto unlock_out;
+
+ u->ring_cons += (bytes1 + bytes2) / sizeof(evtchn_port_t);
++ rc = bytes1 + bytes2;
+
-+ return bytes1 + bytes2;
++ unlock_out:
++ mutex_unlock(&u->ring_cons_mutex);
++ return rc;
+}
+
+static ssize_t evtchn_write(struct file *file, const char __user *buf,
+ size_t count, loff_t *ppos)
+{
-+ int rc, i;
++ int rc, i;
+ evtchn_port_t *kbuf = (evtchn_port_t *)__get_free_page(GFP_KERNEL);
+ struct per_user_data *u = file->private_data;
+
@@ -55926,18 +53421,16 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ /* Whole number of ports. */
+ count &= ~(sizeof(evtchn_port_t)-1);
+
-+ if (count == 0) {
-+ rc = 0;
++ rc = 0;
++ if (count == 0)
+ goto out;
-+ }
+
+ if (count > PAGE_SIZE)
+ count = PAGE_SIZE;
+
-+ if (copy_from_user(kbuf, buf, count) != 0) {
-+ rc = -EFAULT;
++ rc = -EFAULT;
++ if (copy_from_user(kbuf, buf, count) != 0)
+ goto out;
-+ }
+
+ spin_lock_irq(&port_user_lock);
+ for (i = 0; i < (count/sizeof(evtchn_port_t)); i++)
@@ -56083,9 +53576,11 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+
+ case IOCTL_EVTCHN_RESET: {
+ /* Initialise the ring to empty. Clear errors. */
++ mutex_lock(&u->ring_cons_mutex);
+ spin_lock_irq(&port_user_lock);
+ u->ring_cons = u->ring_prod = u->ring_overflow = 0;
+ spin_unlock_irq(&port_user_lock);
++ mutex_unlock(&u->ring_cons_mutex);
+ rc = 0;
+ break;
+ }
@@ -56133,6 +53628,8 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ return -ENOMEM;
+ }
+
++ mutex_init(&u->ring_cons_mutex);
++
+ filp->private_data = u;
+
+ return 0;
@@ -56168,7 +53665,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ return 0;
+}
+
-+static struct file_operations evtchn_fops = {
++static const struct file_operations evtchn_fops = {
+ .owner = THIS_MODULE,
+ .read = evtchn_read,
+ .write = evtchn_write,
@@ -56216,22 +53713,16 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+module_exit(evtchn_cleanup);
+
+MODULE_LICENSE("Dual BSD/GPL");
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/drivers/xen/evtchn/Makefile source/drivers/xen/evtchn/Makefile
---- /scratch/src/linux-2.6.20.3/drivers/xen/evtchn/Makefile 1970-01-01 01:00:00.000000000 +0100
-+++ source/drivers/xen/evtchn/Makefile 2007-03-20 21:26:49.000000000 +0100
-@@ -0,0 +1,2 @@
-+
-+obj-y := evtchn.o
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/drivers/xen/fbfront/Makefile source/drivers/xen/fbfront/Makefile
---- /scratch/src/linux-2.6.20.3/drivers/xen/fbfront/Makefile 1970-01-01 01:00:00.000000000 +0100
-+++ source/drivers/xen/fbfront/Makefile 2007-03-20 21:26:49.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 drivers/xen/fbfront/Makefile
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/drivers/xen/fbfront/Makefile Wed Aug 08 16:25:28 2007 -0300
@@ -0,0 +1,2 @@
+obj-$(CONFIG_XEN_FRAMEBUFFER) := xenfb.o
+obj-$(CONFIG_XEN_KEYBOARD) += xenkbd.o
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/drivers/xen/fbfront/xenfb.c source/drivers/xen/fbfront/xenfb.c
---- /scratch/src/linux-2.6.20.3/drivers/xen/fbfront/xenfb.c 1970-01-01 01:00:00.000000000 +0100
-+++ source/drivers/xen/fbfront/xenfb.c 2007-03-21 14:49:46.000000000 +0100
-@@ -0,0 +1,750 @@
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 drivers/xen/fbfront/xenfb.c
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/drivers/xen/fbfront/xenfb.c Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,752 @@
+/*
+ * linux/drivers/video/xenfb.c -- Xen para-virtual frame buffer device
+ *
@@ -56259,9 +53750,11 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#include <linux/vmalloc.h>
+#include <linux/mm.h>
+#include <linux/freezer.h>
++#include <linux/mutex.h>
+#include <asm/hypervisor.h>
+#include <xen/evtchn.h>
+#include <xen/interface/io/fbif.h>
++#include <xen/interface/io/protocols.h>
+#include <xen/xenbus.h>
+#include <linux/kthread.h>
+
@@ -56291,7 +53784,6 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ struct page **pages;
+ struct list_head mappings; /* protected by mm_lock */
+
-+ unsigned evtchn;
+ int irq;
+ struct xenfb_page *page;
+ unsigned long *mfns;
@@ -56391,7 +53883,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ wmb(); /* ensure ring contents visible */
+ info->page->out_prod = prod + 1;
+
-+ notify_remote_via_evtchn(info->evtchn);
++ notify_remote_via_irq(info->irq);
+}
+
+static int xenfb_queue_full(struct xenfb_info *info)
@@ -56663,7 +54155,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+
+ if (page->in_cons != page->in_prod) {
+ info->page->in_cons = info->page->in_prod;
-+ notify_remote_via_evtchn(info->evtchn);
++ notify_remote_via_irq(info->irq);
+ }
+ return IRQ_HANDLED;
+}
@@ -56714,7 +54206,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ goto error_nomem;
+
+ /* set up shared page */
-+ info->page = (void *)__get_free_page(GFP_KERNEL);
++ info->page = (void *)__get_free_page(GFP_KERNEL | __GFP_ZERO);
+ if (!info->page)
+ goto error_nomem;
+
@@ -56852,14 +54344,11 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ int ret;
+ struct xenbus_transaction xbt;
+
-+ ret = xenbus_alloc_evtchn(dev, &info->evtchn);
-+ if (ret)
-+ return ret;
-+ ret = bind_evtchn_to_irqhandler(info->evtchn, xenfb_event_handler,
-+ 0, "xenfb", info);
++ ret = bind_listening_port_to_irqhandler(
++ dev->otherend_id, xenfb_event_handler, 0, "xenfb", info);
+ if (ret < 0) {
-+ xenbus_free_evtchn(dev, info->evtchn);
-+ xenbus_dev_fatal(dev, ret, "bind_evtchn_to_irqhandler");
++ xenbus_dev_fatal(dev, ret,
++ "bind_listening_port_to_irqhandler");
+ return ret;
+ }
+ info->irq = ret;
@@ -56875,7 +54364,11 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ if (ret)
+ goto error_xenbus;
+ ret = xenbus_printf(xbt, dev->nodename, "event-channel", "%u",
-+ info->evtchn);
++ irq_to_evtchn_port(info->irq));
++ if (ret)
++ goto error_xenbus;
++ ret = xenbus_printf(xbt, dev->nodename, "protocol", "%s",
++ XEN_IO_PROTO_ABI_NATIVE);
+ if (ret)
+ goto error_xenbus;
+ ret = xenbus_printf(xbt, dev->nodename, "feature-update", "1");
@@ -56982,10 +54475,10 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+module_exit(xenfb_cleanup);
+
+MODULE_LICENSE("GPL");
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/drivers/xen/fbfront/xenkbd.c source/drivers/xen/fbfront/xenkbd.c
---- /scratch/src/linux-2.6.20.3/drivers/xen/fbfront/xenkbd.c 1970-01-01 01:00:00.000000000 +0100
-+++ source/drivers/xen/fbfront/xenkbd.c 2007-03-21 14:49:46.000000000 +0100
-@@ -0,0 +1,300 @@
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 drivers/xen/fbfront/xenkbd.c
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/drivers/xen/fbfront/xenkbd.c Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,333 @@
+/*
+ * linux/drivers/input/keyboard/xenkbd.c -- Xen para-virtual input device
+ *
@@ -57017,11 +54510,12 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+
+struct xenkbd_info
+{
-+ struct input_dev *dev;
++ struct input_dev *kbd;
++ struct input_dev *ptr;
+ struct xenkbd_page *page;
-+ unsigned evtchn;
+ int irq;
+ struct xenbus_device *xbdev;
++ char phys[32];
+};
+
+static int xenkbd_remove(struct xenbus_device *);
@@ -57045,26 +54539,39 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ rmb(); /* ensure we see ring contents up to prod */
+ for (cons = page->in_cons; cons != prod; cons++) {
+ union xenkbd_in_event *event;
++ struct input_dev *dev;
+ event = &XENKBD_IN_RING_REF(page, cons);
+
++ dev = info->ptr;
+ switch (event->type) {
+ case XENKBD_TYPE_MOTION:
-+ input_report_rel(info->dev, REL_X, event->motion.rel_x);
-+ input_report_rel(info->dev, REL_Y, event->motion.rel_y);
++ input_report_rel(dev, REL_X, event->motion.rel_x);
++ input_report_rel(dev, REL_Y, event->motion.rel_y);
+ break;
+ case XENKBD_TYPE_KEY:
-+ input_report_key(info->dev, event->key.keycode, event->key.pressed);
++ dev = NULL;
++ if (test_bit(event->key.keycode, info->kbd->keybit))
++ dev = info->kbd;
++ if (test_bit(event->key.keycode, info->ptr->keybit))
++ dev = info->ptr;
++ if (dev)
++ input_report_key(dev, event->key.keycode,
++ event->key.pressed);
++ else
++ printk("xenkbd: unhandled keycode 0x%x\n",
++ event->key.keycode);
+ break;
+ case XENKBD_TYPE_POS:
-+ input_report_abs(info->dev, ABS_X, event->pos.abs_x);
-+ input_report_abs(info->dev, ABS_Y, event->pos.abs_y);
++ input_report_abs(dev, ABS_X, event->pos.abs_x);
++ input_report_abs(dev, ABS_Y, event->pos.abs_y);
+ break;
+ }
++ if (dev)
++ input_sync(dev);
+ }
-+ input_sync(info->dev);
+ mb(); /* ensure we got ring contents */
+ page->in_cons = cons;
-+ notify_remote_via_evtchn(info->evtchn);
++ notify_remote_via_irq(info->irq);
+
+ return IRQ_HANDLED;
+}
@@ -57074,7 +54581,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+{
+ int ret, i;
+ struct xenkbd_info *info;
-+ struct input_dev *input_dev;
++ struct input_dev *kbd, *ptr;
+
+ info = kzalloc(sizeof(*info), GFP_KERNEL);
+ if (!info) {
@@ -57083,6 +54590,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ }
+ dev->dev.driver_data = info;
+ info->xbdev = dev;
++ snprintf(info->phys, sizeof(info->phys), "xenbus/%s", dev->nodename);
+
+ info->page = (void *)__get_free_page(GFP_KERNEL);
+ if (!info->page)
@@ -57090,32 +54598,52 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ info->page->in_cons = info->page->in_prod = 0;
+ info->page->out_cons = info->page->out_prod = 0;
+
-+ input_dev = input_allocate_device();
-+ if (!input_dev)
++ /* keyboard */
++ kbd = input_allocate_device();
++ if (!kbd)
+ goto error_nomem;
++ kbd->name = "Xen Virtual Keyboard";
++ kbd->phys = info->phys;
++ kbd->id.bustype = BUS_PCI;
++ kbd->id.vendor = 0x5853;
++ kbd->id.product = 0xffff;
++ kbd->evbit[0] = BIT(EV_KEY);
++ for (i = KEY_ESC; i < KEY_UNKNOWN; i++)
++ set_bit(i, kbd->keybit);
++ for (i = KEY_OK; i < KEY_MAX; i++)
++ set_bit(i, kbd->keybit);
++
++ ret = input_register_device(kbd);
++ if (ret) {
++ input_free_device(kbd);
++ xenbus_dev_fatal(dev, ret, "input_register_device(kbd)");
++ goto error;
++ }
++ info->kbd = kbd;
+
-+ input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REL) | BIT(EV_ABS);
-+ input_dev->keybit[LONG(BTN_MOUSE)]
-+ = BIT(BTN_LEFT) | BIT(BTN_MIDDLE) | BIT(BTN_RIGHT);
-+ /* TODO additional buttons */
-+ input_dev->relbit[0] = BIT(REL_X) | BIT(REL_Y);
-+
-+ /* FIXME not sure this is quite right */
-+ for (i = 0; i < 256; i++)
-+ set_bit(i, input_dev->keybit);
-+
-+ input_dev->name = "Xen Virtual Keyboard/Mouse";
-+
-+ input_set_abs_params(input_dev, ABS_X, 0, XENFB_WIDTH, 0, 0);
-+ input_set_abs_params(input_dev, ABS_Y, 0, XENFB_HEIGHT, 0, 0);
-+
-+ ret = input_register_device(input_dev);
++ /* pointing device */
++ ptr = input_allocate_device();
++ if (!ptr)
++ goto error_nomem;
++ ptr->name = "Xen Virtual Pointer";
++ ptr->phys = info->phys;
++ ptr->id.bustype = BUS_PCI;
++ ptr->id.vendor = 0x5853;
++ ptr->id.product = 0xfffe;
++ ptr->evbit[0] = BIT(EV_KEY) | BIT(EV_REL) | BIT(EV_ABS);
++ for (i = BTN_LEFT; i <= BTN_TASK; i++)
++ set_bit(i, ptr->keybit);
++ ptr->relbit[0] = BIT(REL_X) | BIT(REL_Y);
++ input_set_abs_params(ptr, ABS_X, 0, XENFB_WIDTH, 0, 0);
++ input_set_abs_params(ptr, ABS_Y, 0, XENFB_HEIGHT, 0, 0);
++
++ ret = input_register_device(ptr);
+ if (ret) {
-+ input_free_device(input_dev);
-+ xenbus_dev_fatal(dev, ret, "input_register_device");
++ input_free_device(ptr);
++ xenbus_dev_fatal(dev, ret, "input_register_device(ptr)");
+ goto error;
+ }
-+ info->dev = input_dev;
++ info->ptr = ptr;
+
+ ret = xenkbd_connect_backend(dev, info);
+ if (ret < 0)
@@ -57144,7 +54672,8 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ struct xenkbd_info *info = dev->dev.driver_data;
+
+ xenkbd_disconnect_backend(info);
-+ input_unregister_device(info->dev);
++ input_unregister_device(info->kbd);
++ input_unregister_device(info->ptr);
+ free_page((unsigned long)info->page);
+ kfree(info);
+ return 0;
@@ -57156,14 +54685,11 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ int ret;
+ struct xenbus_transaction xbt;
+
-+ ret = xenbus_alloc_evtchn(dev, &info->evtchn);
-+ if (ret)
-+ return ret;
-+ ret = bind_evtchn_to_irqhandler(info->evtchn, input_handler, 0,
-+ "xenkbd", info);
++ ret = bind_listening_port_to_irqhandler(
++ dev->otherend_id, input_handler, 0, "xenkbd", info);
+ if (ret < 0) {
-+ xenbus_free_evtchn(dev, info->evtchn);
-+ xenbus_dev_fatal(dev, ret, "bind_evtchn_to_irqhandler");
++ xenbus_dev_fatal(dev, ret,
++ "bind_listening_port_to_irqhandler");
+ return ret;
+ }
+ info->irq = ret;
@@ -57179,7 +54705,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ if (ret)
+ goto error_xenbus;
+ ret = xenbus_printf(xbt, dev->nodename, "event-channel", "%u",
-+ info->evtchn);
++ irq_to_evtchn_port(info->irq));
+ if (ret)
+ goto error_xenbus;
+ ret = xenbus_transaction_end(xbt, 0);
@@ -57286,320 +54812,1001 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+module_exit(xenkbd_cleanup);
+
+MODULE_LICENSE("GPL");
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/drivers/xen/Kconfig source/drivers/xen/Kconfig
---- /scratch/src/linux-2.6.20.3/drivers/xen/Kconfig 1970-01-01 01:00:00.000000000 +0100
-+++ source/drivers/xen/Kconfig 2007-03-20 21:26:48.000000000 +0100
-@@ -0,0 +1,283 @@
-+#
-+# This Kconfig describe xen options
-+#
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 drivers/xen/gntdev/Makefile
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/drivers/xen/gntdev/Makefile Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,1 @@
++obj-y := gntdev.o
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 drivers/xen/gntdev/gntdev.c
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/drivers/xen/gntdev/gntdev.c Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,973 @@
++/******************************************************************************
++ * gntdev.c
++ *
++ * Device for accessing (in user-space) pages that have been granted by other
++ * domains.
++ *
++ * Copyright (c) 2006-2007, D G Murray.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
++ */
+
-+mainmenu "Xen Configuration"
++#include <asm/atomic.h>
++#include <linux/module.h>
++#include <linux/kernel.h>
++#include <linux/init.h>
++#include <linux/fs.h>
++#include <linux/device.h>
++#include <linux/mm.h>
++#include <linux/mman.h>
++#include <asm/uaccess.h>
++#include <asm/io.h>
++#include <xen/gnttab.h>
++#include <asm/hypervisor.h>
++#include <xen/balloon.h>
++#include <xen/evtchn.h>
++#include <xen/driver_util.h>
+
-+config XEN
-+ bool
-+ default y if X86_XEN || X86_64_XEN
-+ help
-+ This is the Linux Xen port.
++#include <linux/types.h>
++#include <xen/public/gntdev.h>
+
-+if XEN
-+config XEN_INTERFACE_VERSION
-+ hex
-+ default 0x00030203
+
-+menu "XEN"
++#define DRIVER_AUTHOR "Derek G. Murray <Derek.Murray@cl.cam.ac.uk>"
++#define DRIVER_DESC "User-space granted page access driver"
+
-+config XEN_PRIVILEGED_GUEST
-+ bool "Privileged Guest (domain 0)"
-+ depends XEN
-+ default n
-+ help
-+ Support for privileged operation (domain 0)
++MODULE_LICENSE("GPL");
++MODULE_AUTHOR(DRIVER_AUTHOR);
++MODULE_DESCRIPTION(DRIVER_DESC);
+
-+config XEN_UNPRIVILEGED_GUEST
-+ bool
-+ default !XEN_PRIVILEGED_GUEST
++#define MAX_GRANTS 128
+
-+config XEN_PRIVCMD
-+ bool
-+ depends on PROC_FS
-+ default y
++/* A slot can be in one of three states:
++ *
++ * 0. GNTDEV_SLOT_INVALID:
++ * This slot is not associated with a grant reference, and is therefore free
++ * to be overwritten by a new grant reference.
++ *
++ * 1. GNTDEV_SLOT_NOT_YET_MAPPED:
++ * This slot is associated with a grant reference (via the
++ * IOCTL_GNTDEV_MAP_GRANT_REF ioctl), but it has not yet been mmap()-ed.
++ *
++ * 2. GNTDEV_SLOT_MAPPED:
++ * This slot is associated with a grant reference, and has been mmap()-ed.
++ */
++typedef enum gntdev_slot_state {
++ GNTDEV_SLOT_INVALID = 0,
++ GNTDEV_SLOT_NOT_YET_MAPPED,
++ GNTDEV_SLOT_MAPPED
++} gntdev_slot_state_t;
+
-+config XEN_XENBUS_DEV
-+ bool
-+ depends on PROC_FS
-+ default y
++#define GNTDEV_INVALID_HANDLE -1
++#define GNTDEV_FREE_LIST_INVALID -1
++/* Each opened instance of gntdev is associated with a list of grants,
++ * represented by an array of elements of the following type,
++ * gntdev_grant_info_t.
++ */
++typedef struct gntdev_grant_info {
++ gntdev_slot_state_t state;
++ union {
++ uint32_t free_list_index;
++ struct {
++ domid_t domid;
++ grant_ref_t ref;
++ grant_handle_t kernel_handle;
++ grant_handle_t user_handle;
++ uint64_t dev_bus_addr;
++ } valid;
++ } u;
++} gntdev_grant_info_t;
+
-+config XEN_BACKEND
-+ tristate "Backend driver support"
-+ default y
-+ help
-+ Support for backend device drivers that provide I/O services
-+ to other virtual machines.
++/* Private data structure, which is stored in the file pointer for files
++ * associated with this device.
++ */
++typedef struct gntdev_file_private_data {
++
++ /* Array of grant information. */
++ gntdev_grant_info_t grants[MAX_GRANTS];
++
++ /* Read/write semaphore used to protect the grants array. */
++ struct rw_semaphore grants_sem;
++
++ /* An array of indices of free slots in the grants array.
++ * N.B. An entry in this list may temporarily have the value
++ * GNTDEV_FREE_LIST_INVALID if the corresponding slot has been removed
++ * from the list by the contiguous allocator, but the list has not yet
++ * been compressed. However, this is not visible across invocations of
++ * the device.
++ */
++ int32_t free_list[MAX_GRANTS];
++
++ /* The number of free slots in the grants array. */
++ uint32_t free_list_size;
+
-+config XEN_BLKDEV_BACKEND
-+ tristate "Block-device backend driver"
-+ depends on XEN_BACKEND
-+ default y
-+ help
-+ The block-device backend driver allows the kernel to export its
-+ block devices to other guests via a high-performance shared-memory
-+ interface.
++ /* Read/write semaphore used to protect the free list. */
++ struct rw_semaphore free_list_sem;
++
++ /* Index of the next slot after the most recent contiguous allocation,
++ * for use in a next-fit allocator.
++ */
++ uint32_t next_fit_index;
+
-+config XEN_BLKDEV_TAP
-+ tristate "Block-device tap backend driver"
-+ depends on XEN_BACKEND
-+ default XEN_PRIVILEGED_GUEST
-+ help
-+ The block tap driver is an alternative to the block back driver
-+ and allows VM block requests to be redirected to userspace through
-+ a device interface. The tap allows user-space development of
-+ high-performance block backends, where disk images may be implemented
-+ as files, in memory, or on other hosts across the network. This
-+ driver can safely coexist with the existing blockback driver.
++ /* Used to map grants into the kernel, before mapping them into user
++ * space.
++ */
++ struct page **foreign_pages;
+
-+config XEN_NETDEV_BACKEND
-+ tristate "Network-device backend driver"
-+ depends on XEN_BACKEND && NET
-+ default y
-+ help
-+ The network-device backend driver allows the kernel to export its
-+ network devices to other guests via a high-performance shared-memory
-+ interface.
++} gntdev_file_private_data_t;
+
-+config XEN_NETDEV_PIPELINED_TRANSMITTER
-+ bool "Pipelined transmitter (DANGEROUS)"
-+ depends on XEN_NETDEV_BACKEND
-+ default n
-+ help
-+ If the net backend is a dumb domain, such as a transparent Ethernet
-+ bridge with no local IP interface, it is safe to say Y here to get
-+ slightly lower network overhead.
-+ If the backend has a local IP interface; or may be doing smart things
-+ like reassembling packets to perform firewall filtering; or if you
-+ are unsure; or if you experience network hangs when this option is
-+ enabled; then you must say N here.
++/* Module lifecycle operations. */
++static int __init gntdev_init(void);
++static void __exit gntdev_exit(void);
+
-+config XEN_NETDEV_LOOPBACK
-+ tristate "Network-device loopback driver"
-+ depends on XEN_NETDEV_BACKEND
-+ default y
-+ help
-+ A two-interface loopback device to emulate a local netfront-netback
-+ connection.
++module_init(gntdev_init);
++module_exit(gntdev_exit);
+
-+config XEN_PCIDEV_BACKEND
-+ tristate "PCI-device backend driver"
-+ depends on PCI && XEN_BACKEND
-+ default XEN_PRIVILEGED_GUEST
-+ help
-+ The PCI device backend driver allows the kernel to export arbitrary
-+ PCI devices to other guests. If you select this to be a module, you
-+ will need to make sure no other driver has bound to the device(s)
-+ you want to make visible to other guests.
++/* File operations. */
++static int gntdev_open(struct inode *inode, struct file *flip);
++static int gntdev_release(struct inode *inode, struct file *flip);
++static int gntdev_mmap(struct file *flip, struct vm_area_struct *vma);
++static int gntdev_ioctl (struct inode *inode, struct file *flip,
++ unsigned int cmd, unsigned long arg);
+
-+choice
-+ prompt "PCI Backend Mode"
-+ depends on XEN_PCIDEV_BACKEND
-+ default XEN_PCIDEV_BACKEND_VPCI
++static struct file_operations gntdev_fops = {
++ .owner = THIS_MODULE,
++ .open = gntdev_open,
++ .release = gntdev_release,
++ .mmap = gntdev_mmap,
++ .ioctl = gntdev_ioctl
++};
+
-+config XEN_PCIDEV_BACKEND_VPCI
-+ bool "Virtual PCI"
-+ ---help---
-+ This PCI Backend hides the true PCI topology and makes the frontend
-+ think there is a single PCI bus with only the exported devices on it.
-+ For example, a device at 03:05.0 will be re-assigned to 00:00.0. A
-+ second device at 02:1a.1 will be re-assigned to 00:01.1.
++/* VM operations. */
++static void gntdev_vma_close(struct vm_area_struct *vma);
++static pte_t gntdev_clear_pte(struct vm_area_struct *vma, unsigned long addr,
++ pte_t *ptep, int is_fullmm);
+
-+config XEN_PCIDEV_BACKEND_PASS
-+ bool "Passthrough"
-+ ---help---
-+ This PCI Backend provides a real view of the PCI topology to the
-+ frontend (for example, a device at 06:01.b will still appear at
-+ 06:01.b to the frontend). This is similar to how Xen 2.0.x exposed
-+ PCI devices to its driver domains. This may be required for drivers
-+ which depend on finding their hardward in certain bus/slot
-+ locations.
++static struct vm_operations_struct gntdev_vmops = {
++ .close = gntdev_vma_close,
++ .zap_pte = gntdev_clear_pte
++};
+
-+config XEN_PCIDEV_BACKEND_SLOT
-+ bool "Slot"
-+ ---help---
-+ This PCI Backend hides the true PCI topology and makes the frontend
-+ think there is a single PCI bus with only the exported devices on it.
-+ Contrary to the virtual PCI backend, a function becomes a new slot.
-+ For example, a device at 03:05.2 will be re-assigned to 00:00.0. A
-+ second device at 02:1a.1 will be re-assigned to 00:01.0.
++/* Global variables. */
+
-+endchoice
++/* The driver major number, for use when unregistering the driver. */
++static int gntdev_major;
+
-+config XEN_PCIDEV_BE_DEBUG
-+ bool "PCI Backend Debugging"
-+ depends on XEN_PCIDEV_BACKEND
-+ default n
++#define GNTDEV_NAME "gntdev"
+
-+config XEN_TPMDEV_BACKEND
-+ tristate "TPM-device backend driver"
-+ depends on XEN_BACKEND
-+ default n
-+ help
-+ The TPM-device backend driver
++/* Memory mapping functions
++ * ------------------------
++ *
++ * Every granted page is mapped into both kernel and user space, and the two
++ * following functions return the respective virtual addresses of these pages.
++ *
++ * When shadow paging is disabled, the granted page is mapped directly into
++ * user space; when it is enabled, it is mapped into the kernel and remapped
++ * into user space using vm_insert_page() (see gntdev_mmap(), below).
++ */
+
-+config XEN_BLKDEV_FRONTEND
-+ tristate "Block-device frontend driver"
-+ depends on XEN
-+ default y
-+ help
-+ The block-device frontend driver allows the kernel to access block
-+ devices mounted within another guest OS. Unless you are building a
-+ dedicated device-driver domain, or your master control domain
-+ (domain 0), then you almost certainly want to say Y here.
++/* Returns the virtual address (in user space) of the @page_index'th page
++ * in the given VM area.
++ */
++static inline unsigned long get_user_vaddr (struct vm_area_struct *vma,
++ int page_index)
++{
++ return (unsigned long) vma->vm_start + (page_index << PAGE_SHIFT);
++}
+
-+config XEN_NETDEV_FRONTEND
-+ tristate "Network-device frontend driver"
-+ depends on XEN && NET
-+ default y
-+ help
-+ The network-device frontend driver allows the kernel to access
-+ network interfaces within another guest OS. Unless you are building a
-+ dedicated device-driver domain, or your master control domain
-+ (domain 0), then you almost certainly want to say Y here.
++/* Returns the virtual address (in kernel space) of the @slot_index'th page
++ * mapped by the gntdev instance that owns the given private data struct.
++ */
++static inline unsigned long get_kernel_vaddr (gntdev_file_private_data_t *priv,
++ int slot_index)
++{
++ unsigned long pfn;
++ void *kaddr;
++ pfn = page_to_pfn(priv->foreign_pages[slot_index]);
++ kaddr = pfn_to_kaddr(pfn);
++ return (unsigned long) kaddr;
++}
+
-+config XEN_FRAMEBUFFER
-+ tristate "Framebuffer-device frontend driver"
-+ depends on XEN && FB
-+ select FB_CFB_FILLRECT
-+ select FB_CFB_COPYAREA
-+ select FB_CFB_IMAGEBLIT
-+ default y
-+ help
-+ The framebuffer-device frontend drivers allows the kernel to create a
-+ virtual framebuffer. This framebuffer can be viewed in another
-+ domain. Unless this domain has access to a real video card, you
-+ probably want to say Y here.
++/* Helper functions. */
+
-+config XEN_KEYBOARD
-+ tristate "Keyboard-device frontend driver"
-+ depends on XEN && XEN_FRAMEBUFFER && INPUT
-+ default y
-+ help
-+ The keyboard-device frontend driver allows the kernel to create a
-+ virtual keyboard. This keyboard can then be driven by another
-+ domain. If you've said Y to CONFIG_XEN_FRAMEBUFFER, you probably
-+ want to say Y here.
++/* Adds information about a grant reference to the list of grants in the file's
++ * private data structure. Returns non-zero on failure. On success, sets the
++ * value of *offset to the offset that should be mmap()-ed in order to map the
++ * grant reference.
++ */
++static int add_grant_reference(struct file *flip,
++ struct ioctl_gntdev_grant_ref *op,
++ uint64_t *offset)
++{
++ gntdev_file_private_data_t *private_data
++ = (gntdev_file_private_data_t *) flip->private_data;
+
-+config XEN_SCRUB_PAGES
-+ bool "Scrub memory before freeing it to Xen"
-+ default y
-+ help
-+ Erase memory contents before freeing it back to Xen's global
-+ pool. This ensures that any secrets contained within that
-+ memory (e.g., private keys) cannot be found by other guests that
-+ may be running on the machine. Most people will want to say Y here.
-+ If security is not a concern then you may increase performance by
-+ saying N.
++ uint32_t slot_index;
+
-+config XEN_DISABLE_SERIAL
-+ bool "Disable serial port drivers"
-+ default y
-+ help
-+ Disable serial port drivers, allowing the Xen console driver
-+ to provide a serial console at ttyS0.
++ if (unlikely(private_data->free_list_size == 0)) {
++ return -ENOMEM;
++ }
+
-+config XEN_SYSFS
-+ tristate "Export Xen attributes in sysfs"
-+ depends on SYSFS
-+ default y
-+ help
-+ Xen hypervisor attributes will show up under /sys/hypervisor/.
++ slot_index = private_data->free_list[--private_data->free_list_size];
+
-+choice
-+ prompt "Xen version compatibility"
-+ default XEN_COMPAT_030002_AND_LATER
++ /* Copy the grant information into file's private data. */
++ private_data->grants[slot_index].state = GNTDEV_SLOT_NOT_YET_MAPPED;
++ private_data->grants[slot_index].u.valid.domid = op->domid;
++ private_data->grants[slot_index].u.valid.ref = op->ref;
+
-+ config XEN_COMPAT_030002_AND_LATER
-+ bool "3.0.2 and later"
++ /* The offset is calculated as the index of the chosen entry in the
++ * file's private data's array of grant information. This is then
++ * shifted to give an offset into the virtual "file address space".
++ */
++ *offset = slot_index << PAGE_SHIFT;
+
-+ config XEN_COMPAT_LATEST_ONLY
-+ bool "no compatibility code"
++ return 0;
++}
+
-+endchoice
++/* Adds the @count grant references to the contiguous range in the slot array
++ * beginning at @first_slot. It is assumed that @first_slot was returned by a
++ * previous invocation of find_contiguous_free_range(), during the same
++ * invocation of the driver.
++ */
++static int add_grant_references(struct file *flip,
++ int count,
++ struct ioctl_gntdev_grant_ref *ops,
++ uint32_t first_slot)
++{
++ gntdev_file_private_data_t *private_data
++ = (gntdev_file_private_data_t *) flip->private_data;
++ int i;
++
++ for (i = 0; i < count; ++i) {
+
-+config XEN_COMPAT_030002
-+ bool
-+ default XEN_COMPAT_030002_AND_LATER
++ /* First, mark the slot's entry in the free list as invalid. */
++ int free_list_index =
++ private_data->grants[first_slot+i].u.free_list_index;
++ private_data->free_list[free_list_index] =
++ GNTDEV_FREE_LIST_INVALID;
+
-+endmenu
++ /* Now, update the slot. */
++ private_data->grants[first_slot+i].state =
++ GNTDEV_SLOT_NOT_YET_MAPPED;
++ private_data->grants[first_slot+i].u.valid.domid =
++ ops[i].domid;
++ private_data->grants[first_slot+i].u.valid.ref = ops[i].ref;
++ }
+
-+config HAVE_ARCH_ALLOC_SKB
-+ bool
-+ default y
++ return 0;
++}
+
-+config HAVE_ARCH_DEV_ALLOC_SKB
-+ bool
-+ default y
++/* Scans through the free list for @flip, removing entries that are marked as
++ * GNTDEV_SLOT_INVALID. This will reduce the recorded size of the free list to
++ * the number of valid entries.
++ */
++static void compress_free_list(struct file *flip)
++{
++ gntdev_file_private_data_t *private_data
++ = (gntdev_file_private_data_t *) flip->private_data;
++ int i, j = 0, old_size;
++
++ old_size = private_data->free_list_size;
++ for (i = 0; i < old_size; ++i) {
++ if (private_data->free_list[i] != GNTDEV_FREE_LIST_INVALID) {
++ private_data->free_list[j] =
++ private_data->free_list[i];
++ ++j;
++ } else {
++ --private_data->free_list_size;
++ }
++ }
++}
+
-+config HAVE_IRQ_IGNORE_UNHANDLED
-+ bool
-+ default y
++/* Searches the grant array in the private data of @flip for a range of
++ * @num_slots contiguous slots in the GNTDEV_SLOT_INVALID state.
++ *
++ * Returns the index of the first slot if a range is found, otherwise -ENOMEM.
++ */
++static int find_contiguous_free_range(struct file *flip,
++ uint32_t num_slots)
++{
++ gntdev_file_private_data_t *private_data
++ = (gntdev_file_private_data_t *) flip->private_data;
++
++ int i;
++ int start_index = private_data->next_fit_index;
++ int range_start = 0, range_length;
+
-+config NO_IDLE_HZ
-+ bool
-+ default y
++ if (private_data->free_list_size < num_slots) {
++ return -ENOMEM;
++ }
+
-+config XEN_UTIL
-+ bool
-+ default y
++ /* First search from the start_index to the end of the array. */
++ range_length = 0;
++ for (i = start_index; i < MAX_GRANTS; ++i) {
++ if (private_data->grants[i].state == GNTDEV_SLOT_INVALID) {
++ if (range_length == 0) {
++ range_start = i;
++ }
++ ++range_length;
++ if (range_length == num_slots) {
++ return range_start;
++ }
++ }
++ }
++
++ /* Now search from the start of the array to the start_index. */
++ range_length = 0;
++ for (i = 0; i < start_index; ++i) {
++ if (private_data->grants[i].state == GNTDEV_SLOT_INVALID) {
++ if (range_length == 0) {
++ range_start = i;
++ }
++ ++range_length;
++ if (range_length == num_slots) {
++ return range_start;
++ }
++ }
++ }
++
++ return -ENOMEM;
++}
+
-+config XEN_BALLOON
-+ bool
-+ default y
++/* Interface functions. */
+
-+config XEN_DEVMEM
-+ bool
-+ default y
++/* Initialises the driver. Called when the module is loaded. */
++static int __init gntdev_init(void)
++{
++ struct class *class;
++ struct class_device *device;
+
-+config XEN_SKBUFF
-+ bool
-+ default y
-+ depends on NET
++ if (!is_running_on_xen()) {
++ printk(KERN_ERR "You must be running Xen to use gntdev\n");
++ return -ENODEV;
++ }
+
-+config XEN_REBOOT
-+ bool
-+ default y
++ gntdev_major = register_chrdev(0, GNTDEV_NAME, &gntdev_fops);
++ if (gntdev_major < 0)
++ {
++ printk(KERN_ERR "Could not register gntdev device\n");
++ return -ENOMEM;
++ }
+
-+config XEN_SMPBOOT
-+ bool
-+ default y
-+ depends on SMP
++ /* Note that if the sysfs code fails, we will still initialise the
++ * device, and output the major number so that the device can be
++ * created manually using mknod.
++ */
++ if ((class = get_xen_class()) == NULL) {
++ printk(KERN_ERR "Error setting up xen_class\n");
++ printk(KERN_ERR "gntdev created with major number = %d\n",
++ gntdev_major);
++ return 0;
++ }
+
-+endif
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/drivers/xen/Makefile source/drivers/xen/Makefile
---- /scratch/src/linux-2.6.20.3/drivers/xen/Makefile 1970-01-01 01:00:00.000000000 +0100
-+++ source/drivers/xen/Makefile 2007-03-20 21:26:48.000000000 +0100
-@@ -0,0 +1,19 @@
-+obj-y += core/
-+obj-y += console/
-+obj-y += evtchn/
-+obj-y += privcmd/
-+obj-y += xenbus/
++ device = class_device_create(class, NULL, MKDEV(gntdev_major, 0),
++ NULL, GNTDEV_NAME);
++ if (IS_ERR(device)) {
++ printk(KERN_ERR "Error creating gntdev device in xen_class\n");
++ printk(KERN_ERR "gntdev created with major number = %d\n",
++ gntdev_major);
++ return 0;
++ }
+
-+obj-$(CONFIG_XEN_UTIL) += util.o
-+obj-$(CONFIG_XEN_BALLOON) += balloon/
-+obj-$(CONFIG_XEN_DEVMEM) += char/
-+obj-$(CONFIG_XEN_BLKDEV_BACKEND) += blkback/
-+obj-$(CONFIG_XEN_BLKDEV_TAP) += blktap/
-+obj-$(CONFIG_XEN_NETDEV_BACKEND) += netback/
-+obj-$(CONFIG_XEN_TPMDEV_BACKEND) += tpmback/
-+obj-$(CONFIG_XEN_BLKDEV_FRONTEND) += blkfront/
-+obj-$(CONFIG_XEN_NETDEV_FRONTEND) += netfront/
-+obj-$(CONFIG_XEN_PCIDEV_BACKEND) += pciback/
-+obj-$(CONFIG_XEN_PCIDEV_FRONTEND) += pcifront/
-+obj-$(CONFIG_XEN_FRAMEBUFFER) += fbfront/
-+obj-$(CONFIG_XEN_KEYBOARD) += fbfront/
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/drivers/xen/netback/common.h source/drivers/xen/netback/common.h
---- /scratch/src/linux-2.6.20.3/drivers/xen/netback/common.h 1970-01-01 01:00:00.000000000 +0100
-+++ source/drivers/xen/netback/common.h 2007-03-20 21:26:49.000000000 +0100
-@@ -0,0 +1,146 @@
++ return 0;
++}
++
++/* Cleans up and unregisters the driver. Called when the driver is unloaded.
++ */
++static void __exit gntdev_exit(void)
++{
++ struct class *class;
++ if ((class = get_xen_class()) != NULL)
++ class_device_destroy(class, MKDEV(gntdev_major, 0));
++ unregister_chrdev(gntdev_major, GNTDEV_NAME);
++}
++
++/* Called when the device is opened. */
++static int gntdev_open(struct inode *inode, struct file *flip)
++{
++ gntdev_file_private_data_t *private_data;
++ int i;
++
++ try_module_get(THIS_MODULE);
++
++ /* Allocate space for the per-instance private data. */
++ private_data = kmalloc(sizeof(*private_data), GFP_KERNEL);
++ if (!private_data)
++ goto nomem_out;
++
++ /* Allocate space for the kernel-mapping of granted pages. */
++ private_data->foreign_pages =
++ alloc_empty_pages_and_pagevec(MAX_GRANTS);
++ if (!private_data->foreign_pages)
++ goto nomem_out2;
++
++ /* Initialise the free-list, which contains all slots at first.
++ */
++ for (i = 0; i < MAX_GRANTS; ++i) {
++ private_data->free_list[MAX_GRANTS - i - 1] = i;
++ private_data->grants[i].state = GNTDEV_SLOT_INVALID;
++ private_data->grants[i].u.free_list_index = MAX_GRANTS - i - 1;
++ }
++ private_data->free_list_size = MAX_GRANTS;
++ private_data->next_fit_index = 0;
++
++ init_rwsem(&private_data->grants_sem);
++ init_rwsem(&private_data->free_list_sem);
++
++ flip->private_data = private_data;
++
++ return 0;
++
++nomem_out2:
++ kfree(private_data);
++nomem_out:
++ return -ENOMEM;
++}
++
++/* Called when the device is closed.
++ */
++static int gntdev_release(struct inode *inode, struct file *flip)
++{
++ if (flip->private_data) {
++ gntdev_file_private_data_t *private_data =
++ (gntdev_file_private_data_t *) flip->private_data;
++ if (private_data->foreign_pages) {
++ free_empty_pages_and_pagevec
++ (private_data->foreign_pages, MAX_GRANTS);
++ }
++ kfree(private_data);
++ }
++ module_put(THIS_MODULE);
++ return 0;
++}
++
++/* Called when an attempt is made to mmap() the device. The private data from
++ * @flip contains the list of grant references that can be mapped. The vm_pgoff
++ * field of @vma contains the index into that list that refers to the grant
++ * reference that will be mapped. Only mappings that are a multiple of
++ * PAGE_SIZE are handled.
++ */
++static int gntdev_mmap (struct file *flip, struct vm_area_struct *vma)
++{
++ struct gnttab_map_grant_ref op;
++ unsigned long slot_index = vma->vm_pgoff;
++ unsigned long kernel_vaddr, user_vaddr;
++ uint32_t size = (vma->vm_end - vma->vm_start) >> PAGE_SHIFT;
++ uint64_t ptep;
++ int ret;
++ int flags;
++ int i;
++ struct page *page;
++ gntdev_file_private_data_t *private_data = flip->private_data;
++
++ if (unlikely(!private_data)) {
++ printk(KERN_ERR "File's private data is NULL.\n");
++ return -EINVAL;
++ }
++
++ if (unlikely((size <= 0) || (size + slot_index) > MAX_GRANTS)) {
++ printk(KERN_ERR "Invalid number of pages or offset"
++ "(num_pages = %d, first_slot = %ld).\n",
++ size, slot_index);
++ return -ENXIO;
++ }
++
++ if ((vma->vm_flags & VM_WRITE) && !(vma->vm_flags & VM_SHARED)) {
++ printk(KERN_ERR "Writable mappings must be shared.\n");
++ return -EINVAL;
++ }
++
++ /* Slots must be in the NOT_YET_MAPPED state. */
++ down_write(&private_data->grants_sem);
++ for (i = 0; i < size; ++i) {
++ if (private_data->grants[slot_index + i].state !=
++ GNTDEV_SLOT_NOT_YET_MAPPED) {
++ printk(KERN_ERR "Slot (index = %ld) is in the wrong "
++ "state (%d).\n", slot_index + i,
++ private_data->grants[slot_index + i].state);
++ up_write(&private_data->grants_sem);
++ return -EINVAL;
++ }
++ }
++
++ /* Install the hook for unmapping. */
++ vma->vm_ops = &gntdev_vmops;
++
++ /* The VM area contains pages from another VM. */
++ vma->vm_flags |= VM_FOREIGN;
++ vma->vm_private_data = kzalloc(size * sizeof(struct page_struct *),
++ GFP_KERNEL);
++ if (vma->vm_private_data == NULL) {
++ printk(KERN_ERR "Couldn't allocate mapping structure for VM "
++ "area.\n");
++ return -ENOMEM;
++ }
++
++ /* This flag prevents Bad PTE errors when the memory is unmapped. */
++ vma->vm_flags |= VM_RESERVED;
++
++ /* This flag prevents this VM area being copied on a fork(). A better
++ * behaviour might be to explicitly carry out the appropriate mappings
++ * on fork(), but I don't know if there's a hook for this.
++ */
++ vma->vm_flags |= VM_DONTCOPY;
++
++#ifdef CONFIG_X86
++ /* This flag ensures that the page tables are not unpinned before the
++ * VM area is unmapped. Therefore Xen still recognises the PTE as
++ * belonging to an L1 pagetable, and the grant unmap operation will
++ * succeed, even if the process does not exit cleanly.
++ */
++ vma->vm_mm->context.has_foreign_mappings = 1;
++#endif
++
++ for (i = 0; i < size; ++i) {
++
++ flags = GNTMAP_host_map;
++ if (!(vma->vm_flags & VM_WRITE))
++ flags |= GNTMAP_readonly;
++
++ kernel_vaddr = get_kernel_vaddr(private_data, slot_index + i);
++ user_vaddr = get_user_vaddr(vma, i);
++ page = pfn_to_page(__pa(kernel_vaddr) >> PAGE_SHIFT);
++
++ gnttab_set_map_op(&op, kernel_vaddr, flags,
++ private_data->grants[slot_index+i]
++ .u.valid.ref,
++ private_data->grants[slot_index+i]
++ .u.valid.domid);
++
++ /* Carry out the mapping of the grant reference. */
++ ret = HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref,
++ &op, 1);
++ BUG_ON(ret);
++ if (op.status) {
++ printk(KERN_ERR "Error mapping the grant reference "
++ "into the kernel (%d). domid = %d; ref = %d\n",
++ op.status,
++ private_data->grants[slot_index+i]
++ .u.valid.domid,
++ private_data->grants[slot_index+i]
++ .u.valid.ref);
++ goto undo_map_out;
++ }
++
++ /* Store a reference to the page that will be mapped into user
++ * space.
++ */
++ ((struct page **) vma->vm_private_data)[i] = page;
++
++ /* Mark mapped page as reserved. */
++ SetPageReserved(page);
++
++ /* Record the grant handle, for use in the unmap operation. */
++ private_data->grants[slot_index+i].u.valid.kernel_handle =
++ op.handle;
++ private_data->grants[slot_index+i].u.valid.dev_bus_addr =
++ op.dev_bus_addr;
++
++ private_data->grants[slot_index+i].state = GNTDEV_SLOT_MAPPED;
++ private_data->grants[slot_index+i].u.valid.user_handle =
++ GNTDEV_INVALID_HANDLE;
++
++ /* Now perform the mapping to user space. */
++ if (!xen_feature(XENFEAT_auto_translated_physmap)) {
++
++ /* NOT USING SHADOW PAGE TABLES. */
++ /* In this case, we map the grant(s) straight into user
++ * space.
++ */
++
++ /* Get the machine address of the PTE for the user
++ * page.
++ */
++ if ((ret = create_lookup_pte_addr(vma->vm_mm,
++ vma->vm_start
++ + (i << PAGE_SHIFT),
++ &ptep)))
++ {
++ printk(KERN_ERR "Error obtaining PTE pointer "
++ "(%d).\n", ret);
++ goto undo_map_out;
++ }
++
++ /* Configure the map operation. */
++
++ /* The reference is to be used by host CPUs. */
++ flags = GNTMAP_host_map;
++
++ /* Specifies a user space mapping. */
++ flags |= GNTMAP_application_map;
++
++ /* The map request contains the machine address of the
++ * PTE to update.
++ */
++ flags |= GNTMAP_contains_pte;
++
++ if (!(vma->vm_flags & VM_WRITE))
++ flags |= GNTMAP_readonly;
++
++ gnttab_set_map_op(&op, ptep, flags,
++ private_data->grants[slot_index+i]
++ .u.valid.ref,
++ private_data->grants[slot_index+i]
++ .u.valid.domid);
++
++ /* Carry out the mapping of the grant reference. */
++ ret = HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref,
++ &op, 1);
++ BUG_ON(ret);
++ if (op.status) {
++ printk(KERN_ERR "Error mapping the grant "
++ "reference into user space (%d). domid "
++ "= %d; ref = %d\n", op.status,
++ private_data->grants[slot_index+i].u
++ .valid.domid,
++ private_data->grants[slot_index+i].u
++ .valid.ref);
++ goto undo_map_out;
++ }
++
++ /* Record the grant handle, for use in the unmap
++ * operation.
++ */
++ private_data->grants[slot_index+i].u.
++ valid.user_handle = op.handle;
++
++ /* Update p2m structure with the new mapping. */
++ set_phys_to_machine(__pa(kernel_vaddr) >> PAGE_SHIFT,
++ FOREIGN_FRAME(private_data->
++ grants[slot_index+i]
++ .u.valid.dev_bus_addr
++ >> PAGE_SHIFT));
++ } else {
++ /* USING SHADOW PAGE TABLES. */
++ /* In this case, we simply insert the page into the VM
++ * area. */
++ ret = vm_insert_page(vma, user_vaddr, page);
++ }
++
++ }
++
++ up_write(&private_data->grants_sem);
++ return 0;
++
++undo_map_out:
++ /* If we have a mapping failure, the unmapping will be taken care of
++ * by do_mmap_pgoff(), which will eventually call gntdev_clear_pte().
++ * All we need to do here is free the vma_private_data.
++ */
++ kfree(vma->vm_private_data);
++
++ /* THIS IS VERY UNPLEASANT: do_mmap_pgoff() will set the vma->vm_file
++ * to NULL on failure. However, we need this in gntdev_clear_pte() to
++ * unmap the grants. Therefore, we smuggle a reference to the file's
++ * private data in the VM area's private data pointer.
++ */
++ vma->vm_private_data = private_data;
++
++ up_write(&private_data->grants_sem);
++
++ return -ENOMEM;
++}
++
++static pte_t gntdev_clear_pte(struct vm_area_struct *vma, unsigned long addr,
++ pte_t *ptep, int is_fullmm)
++{
++ int slot_index, ret;
++ pte_t copy;
++ struct gnttab_unmap_grant_ref op;
++ gntdev_file_private_data_t *private_data;
++
++ /* THIS IS VERY UNPLEASANT: do_mmap_pgoff() will set the vma->vm_file
++ * to NULL on failure. However, we need this in gntdev_clear_pte() to
++ * unmap the grants. Therefore, we smuggle a reference to the file's
++ * private data in the VM area's private data pointer.
++ */
++ if (vma->vm_file) {
++ private_data = (gntdev_file_private_data_t *)
++ vma->vm_file->private_data;
++ } else if (vma->vm_private_data) {
++ private_data = (gntdev_file_private_data_t *)
++ vma->vm_private_data;
++ } else {
++ private_data = NULL; /* gcc warning */
++ BUG();
++ }
++
++ /* Copy the existing value of the PTE for returning. */
++ copy = *ptep;
++
++ /* Calculate the grant relating to this PTE. */
++ slot_index = vma->vm_pgoff + ((addr - vma->vm_start) >> PAGE_SHIFT);
++
++ /* Only unmap grants if the slot has been mapped. This could be being
++ * called from a failing mmap().
++ */
++ if (private_data->grants[slot_index].state == GNTDEV_SLOT_MAPPED) {
++
++ /* First, we clear the user space mapping, if it has been made.
++ */
++ if (private_data->grants[slot_index].u.valid.user_handle !=
++ GNTDEV_INVALID_HANDLE &&
++ !xen_feature(XENFEAT_auto_translated_physmap)) {
++ /* NOT USING SHADOW PAGE TABLES. */
++ gnttab_set_unmap_op(&op, virt_to_machine(ptep),
++ GNTMAP_contains_pte,
++ private_data->grants[slot_index]
++ .u.valid.user_handle);
++ ret = HYPERVISOR_grant_table_op(
++ GNTTABOP_unmap_grant_ref, &op, 1);
++ BUG_ON(ret);
++ if (op.status)
++ printk("User unmap grant status = %d\n",
++ op.status);
++ } else {
++ /* USING SHADOW PAGE TABLES. */
++ pte_clear_not_present_full(vma->vm_mm, addr, ptep, is_fullmm);
++ }
++
++ /* Finally, we unmap the grant from kernel space. */
++ gnttab_set_unmap_op(&op,
++ get_kernel_vaddr(private_data, slot_index),
++ GNTMAP_host_map,
++ private_data->grants[slot_index].u.valid
++ .kernel_handle);
++ ret = HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref,
++ &op, 1);
++ BUG_ON(ret);
++ if (op.status)
++ printk("Kernel unmap grant status = %d\n", op.status);
++
++
++ /* Return slot to the not-yet-mapped state, so that it may be
++ * mapped again, or removed by a subsequent ioctl.
++ */
++ private_data->grants[slot_index].state =
++ GNTDEV_SLOT_NOT_YET_MAPPED;
++
++ /* Invalidate the physical to machine mapping for this page. */
++ set_phys_to_machine(__pa(get_kernel_vaddr(private_data,
++ slot_index))
++ >> PAGE_SHIFT, INVALID_P2M_ENTRY);
++
++ } else {
++ pte_clear_not_present_full(vma->vm_mm, addr, ptep, is_fullmm);
++ }
++
++ return copy;
++}
++
++/* "Destructor" for a VM area.
++ */
++static void gntdev_vma_close(struct vm_area_struct *vma) {
++ if (vma->vm_private_data) {
++ kfree(vma->vm_private_data);
++ }
++}
++
++/* Called when an ioctl is made on the device.
++ */
++static int gntdev_ioctl(struct inode *inode, struct file *flip,
++ unsigned int cmd, unsigned long arg)
++{
++ int rc = 0;
++ gntdev_file_private_data_t *private_data =
++ (gntdev_file_private_data_t *) flip->private_data;
++
++ switch (cmd) {
++ case IOCTL_GNTDEV_MAP_GRANT_REF:
++ {
++ struct ioctl_gntdev_map_grant_ref op;
++ down_write(&private_data->grants_sem);
++ down_write(&private_data->free_list_sem);
++
++ if ((rc = copy_from_user(&op, (void __user *) arg,
++ sizeof(op)))) {
++ rc = -EFAULT;
++ goto map_out;
++ }
++ if (unlikely(op.count <= 0)) {
++ rc = -EINVAL;
++ goto map_out;
++ }
++
++ if (op.count == 1) {
++ if ((rc = add_grant_reference(flip, &op.refs[0],
++ &op.index)) < 0) {
++ printk(KERN_ERR "Adding grant reference "
++ "failed (%d).\n", rc);
++ goto map_out;
++ }
++ } else {
++ struct ioctl_gntdev_grant_ref *refs, *u;
++ refs = kmalloc(op.count * sizeof(*refs), GFP_KERNEL);
++ if (!refs) {
++ rc = -ENOMEM;
++ goto map_out;
++ }
++ u = ((struct ioctl_gntdev_map_grant_ref *)arg)->refs;
++ if ((rc = copy_from_user(refs,
++ (void __user *)u,
++ sizeof(*refs) * op.count))) {
++ printk(KERN_ERR "Copying refs from user failed"
++ " (%d).\n", rc);
++ rc = -EINVAL;
++ goto map_out;
++ }
++ if ((rc = find_contiguous_free_range(flip, op.count))
++ < 0) {
++ printk(KERN_ERR "Finding contiguous range "
++ "failed (%d).\n", rc);
++ kfree(refs);
++ goto map_out;
++ }
++ op.index = rc << PAGE_SHIFT;
++ if ((rc = add_grant_references(flip, op.count,
++ refs, rc))) {
++ printk(KERN_ERR "Adding grant references "
++ "failed (%d).\n", rc);
++ kfree(refs);
++ goto map_out;
++ }
++ compress_free_list(flip);
++ kfree(refs);
++ }
++ if ((rc = copy_to_user((void __user *) arg,
++ &op,
++ sizeof(op)))) {
++ printk(KERN_ERR "Copying result back to user failed "
++ "(%d)\n", rc);
++ rc = -EFAULT;
++ goto map_out;
++ }
++ map_out:
++ up_write(&private_data->grants_sem);
++ up_write(&private_data->free_list_sem);
++ return rc;
++ }
++ case IOCTL_GNTDEV_UNMAP_GRANT_REF:
++ {
++ struct ioctl_gntdev_unmap_grant_ref op;
++ int i, start_index;
++
++ down_write(&private_data->grants_sem);
++ down_write(&private_data->free_list_sem);
++
++ if ((rc = copy_from_user(&op,
++ (void __user *) arg,
++ sizeof(op)))) {
++ rc = -EFAULT;
++ goto unmap_out;
++ }
++
++ start_index = op.index >> PAGE_SHIFT;
++
++ /* First, check that all pages are in the NOT_YET_MAPPED
++ * state.
++ */
++ for (i = 0; i < op.count; ++i) {
++ if (unlikely
++ (private_data->grants[start_index + i].state
++ != GNTDEV_SLOT_NOT_YET_MAPPED)) {
++ if (private_data->grants[start_index + i].state
++ == GNTDEV_SLOT_INVALID) {
++ printk(KERN_ERR
++ "Tried to remove an invalid "
++ "grant at offset 0x%x.",
++ (start_index + i)
++ << PAGE_SHIFT);
++ rc = -EINVAL;
++ } else {
++ printk(KERN_ERR
++ "Tried to remove a grant which "
++ "is currently mmap()-ed at "
++ "offset 0x%x.",
++ (start_index + i)
++ << PAGE_SHIFT);
++ rc = -EBUSY;
++ }
++ goto unmap_out;
++ }
++ }
++
++ /* Unmap pages and add them to the free list.
++ */
++ for (i = 0; i < op.count; ++i) {
++ private_data->grants[start_index+i].state =
++ GNTDEV_SLOT_INVALID;
++ private_data->grants[start_index+i].u.free_list_index =
++ private_data->free_list_size;
++ private_data->free_list[private_data->free_list_size] =
++ start_index + i;
++ ++private_data->free_list_size;
++ }
++ compress_free_list(flip);
++
++ unmap_out:
++ up_write(&private_data->grants_sem);
++ up_write(&private_data->free_list_sem);
++ return rc;
++ }
++ case IOCTL_GNTDEV_GET_OFFSET_FOR_VADDR:
++ {
++ struct ioctl_gntdev_get_offset_for_vaddr op;
++ struct vm_area_struct *vma;
++ unsigned long vaddr;
++
++ if ((rc = copy_from_user(&op,
++ (void __user *) arg,
++ sizeof(op)))) {
++ rc = -EFAULT;
++ goto get_offset_out;
++ }
++ vaddr = (unsigned long)op.vaddr;
++
++ down_read(&current->mm->mmap_sem);
++ vma = find_vma(current->mm, vaddr);
++ if (vma == NULL) {
++ rc = -EFAULT;
++ goto get_offset_unlock_out;
++ }
++ if ((!vma->vm_ops) || (vma->vm_ops != &gntdev_vmops)) {
++ printk(KERN_ERR "The vaddr specified does not belong "
++ "to a gntdev instance: %#lx\n", vaddr);
++ rc = -EFAULT;
++ goto get_offset_unlock_out;
++ }
++ if (vma->vm_start != vaddr) {
++ printk(KERN_ERR "The vaddr specified in an "
++ "IOCTL_GNTDEV_GET_OFFSET_FOR_VADDR must be at "
++ "the start of the VM area. vma->vm_start = "
++ "%#lx; vaddr = %#lx\n",
++ vma->vm_start, vaddr);
++ rc = -EFAULT;
++ goto get_offset_unlock_out;
++ }
++ op.offset = vma->vm_pgoff << PAGE_SHIFT;
++ op.count = (vma->vm_end - vma->vm_start) >> PAGE_SHIFT;
++ up_read(&current->mm->mmap_sem);
++ if ((rc = copy_to_user((void __user *) arg,
++ &op,
++ sizeof(op)))) {
++ rc = -EFAULT;
++ goto get_offset_out;
++ }
++ goto get_offset_out;
++ get_offset_unlock_out:
++ up_read(&current->mm->mmap_sem);
++ get_offset_out:
++ return rc;
++ }
++ default:
++ return -ENOIOCTLCMD;
++ }
++
++ return 0;
++}
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 drivers/xen/netback/Makefile
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/drivers/xen/netback/Makefile Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,5 @@
++obj-$(CONFIG_XEN_NETDEV_BACKEND) := netbk.o
++obj-$(CONFIG_XEN_NETDEV_LOOPBACK) += netloop.o
++
++netbk-y := netback.o xenbus.o interface.o
++netloop-y := loopback.o
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 drivers/xen/netback/common.h
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/drivers/xen/netback/common.h Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,157 @@
+/******************************************************************************
+ * arch/xen/drivers/netif/backend/common.h
+ *
@@ -57647,7 +55854,6 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#include <xen/interface/grant_table.h>
+#include <xen/gnttab.h>
+#include <xen/driver_util.h>
-+#include <asm/hypercall.h>
+
+#define DPRINTK(_f, _a...) \
+ pr_debug("(file=%s, line=%d) " _f, \
@@ -57669,7 +55875,6 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ grant_ref_t tx_shmem_ref;
+ grant_handle_t rx_shmem_handle;
+ grant_ref_t rx_shmem_ref;
-+ unsigned int evtchn;
+ unsigned int irq;
+
+ /* The shared rings and indexes. */
@@ -57703,9 +55908,21 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ struct net_device *dev;
+ struct net_device_stats stats;
+
++ unsigned int carrier;
++
+ wait_queue_head_t waiting_to_free;
+} netif_t;
+
++/*
++ * Implement our own carrier flag: the network stack's version causes delays
++ * when the carrier is re-enabled (in particular, dev_activate() may not
++ * immediately be called, which can cause packet loss; also the etherbridge
++ * can be rather lazy in activating its port).
++ */
++#define netback_carrier_on(netif) ((netif)->carrier = 1)
++#define netback_carrier_off(netif) ((netif)->carrier = 0)
++#define netback_carrier_ok(netif) ((netif)->carrier)
++
+#define NET_TX_RING_SIZE __RING_SIZE((netif_tx_sring_t *)0, PAGE_SIZE)
+#define NET_RX_RING_SIZE __RING_SIZE((netif_rx_sring_t *)0, PAGE_SIZE)
+
@@ -57724,7 +55941,8 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+
+void netif_xenbus_init(void);
+
-+#define netif_schedulable(dev) (netif_running(dev) && netif_carrier_ok(dev))
++#define netif_schedulable(netif) \
++ (netif_running((netif)->dev) && netback_carrier_ok(netif))
+
+void netif_schedule_work(netif_t *netif);
+void netif_deschedule_work(netif_t *netif);
@@ -57746,10 +55964,10 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+}
+
+#endif /* __NETIF__BACKEND__COMMON_H__ */
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/drivers/xen/netback/interface.c source/drivers/xen/netback/interface.c
---- /scratch/src/linux-2.6.20.3/drivers/xen/netback/interface.c 1970-01-01 01:00:00.000000000 +0100
-+++ source/drivers/xen/netback/interface.c 2007-03-20 21:26:49.000000000 +0100
-@@ -0,0 +1,349 @@
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 drivers/xen/netback/interface.c
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/drivers/xen/netback/interface.c Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,336 @@
+/******************************************************************************
+ * arch/xen/drivers/netif/backend/interface.c
+ *
@@ -57818,16 +56036,19 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+static int net_open(struct net_device *dev)
+{
+ netif_t *netif = netdev_priv(dev);
-+ if (netif_carrier_ok(dev))
++ if (netback_carrier_ok(netif)) {
+ __netif_up(netif);
++ netif_start_queue(dev);
++ }
+ return 0;
+}
+
+static int net_close(struct net_device *dev)
+{
+ netif_t *netif = netdev_priv(dev);
-+ if (netif_carrier_ok(dev))
++ if (netback_carrier_ok(netif))
+ __netif_down(netif);
++ netif_stop_queue(dev);
+ return 0;
+}
+
@@ -57890,8 +56111,6 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ return ERR_PTR(-ENOMEM);
+ }
+
-+ netif_carrier_off(dev);
-+
+ netif = netdev_priv(dev);
+ memset(netif, 0, sizeof(*netif));
+ netif->domid = domid;
@@ -57900,6 +56119,8 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ init_waitqueue_head(&netif->waiting_to_free);
+ netif->dev = dev;
+
++ netback_carrier_off(netif);
++
+ netif->credit_bytes = netif->remaining_credit = ~0UL;
+ netif->credit_usec = 0UL;
+ init_timer(&netif->credit_timeout);
@@ -57946,15 +56167,12 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ netif_t *netif, grant_ref_t tx_ring_ref, grant_ref_t rx_ring_ref)
+{
+ struct gnttab_map_grant_ref op;
-+ int ret;
+
+ gnttab_set_map_op(&op, (unsigned long)netif->tx_comms_area->addr,
+ GNTMAP_host_map, tx_ring_ref, netif->domid);
+
-+ lock_vm_area(netif->tx_comms_area);
-+ ret = HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &op, 1);
-+ unlock_vm_area(netif->tx_comms_area);
-+ BUG_ON(ret);
++ if (HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &op, 1))
++ BUG();
+
+ if (op.status) {
+ DPRINTK(" Gnttab failure mapping tx_ring_ref!\n");
@@ -57967,10 +56185,8 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ gnttab_set_map_op(&op, (unsigned long)netif->rx_comms_area->addr,
+ GNTMAP_host_map, rx_ring_ref, netif->domid);
+
-+ lock_vm_area(netif->rx_comms_area);
-+ ret = HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &op, 1);
-+ unlock_vm_area(netif->rx_comms_area);
-+ BUG_ON(ret);
++ if (HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &op, 1))
++ BUG();
+
+ if (op.status) {
+ DPRINTK(" Gnttab failure mapping rx_ring_ref!\n");
@@ -57986,23 +56202,18 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+static void unmap_frontend_pages(netif_t *netif)
+{
+ struct gnttab_unmap_grant_ref op;
-+ int ret;
+
+ gnttab_set_unmap_op(&op, (unsigned long)netif->tx_comms_area->addr,
+ GNTMAP_host_map, netif->tx_shmem_handle);
+
-+ lock_vm_area(netif->tx_comms_area);
-+ ret = HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1);
-+ unlock_vm_area(netif->tx_comms_area);
-+ BUG_ON(ret);
++ if (HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1))
++ BUG();
+
+ gnttab_set_unmap_op(&op, (unsigned long)netif->rx_comms_area->addr,
+ GNTMAP_host_map, netif->rx_shmem_handle);
+
-+ lock_vm_area(netif->rx_comms_area);
-+ ret = HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1);
-+ unlock_vm_area(netif->rx_comms_area);
-+ BUG_ON(ret);
++ if (HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1))
++ BUG();
+}
+
+int netif_map(netif_t *netif, unsigned long tx_ring_ref,
@@ -58011,7 +56222,6 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ int err = -ENOMEM;
+ netif_tx_sring_t *txs;
+ netif_rx_sring_t *rxs;
-+ struct evtchn_bind_interdomain bind_interdomain;
+
+ /* Already connected through? */
+ if (netif->irq)
@@ -58028,18 +56238,12 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ if (err)
+ goto err_map;
+
-+ bind_interdomain.remote_dom = netif->domid;
-+ bind_interdomain.remote_port = evtchn;
-+
-+ err = HYPERVISOR_event_channel_op(EVTCHNOP_bind_interdomain,
-+ &bind_interdomain);
-+ if (err)
++ err = bind_interdomain_evtchn_to_irqhandler(
++ netif->domid, evtchn, netif_be_int, 0,
++ netif->dev->name, netif);
++ if (err < 0)
+ goto err_hypervisor;
-+
-+ netif->evtchn = bind_interdomain.local_port;
-+
-+ netif->irq = bind_evtchn_to_irqhandler(
-+ netif->evtchn, netif_be_int, 0, netif->dev->name, netif);
++ netif->irq = err;
+ disable_irq(netif->irq);
+
+ txs = (netif_tx_sring_t *)netif->tx_comms_area->addr;
@@ -58054,7 +56258,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ netif_get(netif);
+
+ rtnl_lock();
-+ netif_carrier_on(netif->dev);
++ netback_carrier_on(netif);
+ if (netif_running(netif->dev))
+ __netif_up(netif);
+ rtnl_unlock();
@@ -58071,9 +56275,10 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+
+void netif_disconnect(netif_t *netif)
+{
-+ if (netif_carrier_ok(netif->dev)) {
++ if (netback_carrier_ok(netif)) {
+ rtnl_lock();
-+ netif_carrier_off(netif->dev);
++ netback_carrier_off(netif);
++ netif_carrier_off(netif->dev); /* discard queued packets */
+ if (netif_running(netif->dev))
+ __netif_down(netif);
+ rtnl_unlock();
@@ -58099,9 +56304,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+
+ free_netdev(netif->dev);
+}
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/drivers/xen/netback/loopback.c source/drivers/xen/netback/loopback.c
---- /scratch/src/linux-2.6.20.3/drivers/xen/netback/loopback.c 1970-01-01 01:00:00.000000000 +0100
-+++ source/drivers/xen/netback/loopback.c 2007-03-20 21:26:49.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 drivers/xen/netback/loopback.c
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/drivers/xen/netback/loopback.c Wed Aug 08 16:25:28 2007 -0300
@@ -0,0 +1,322 @@
+/******************************************************************************
+ * netback/loopback.c
@@ -58425,19 +56630,10 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+module_exit(loopback_exit);
+
+MODULE_LICENSE("Dual BSD/GPL");
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/drivers/xen/netback/Makefile source/drivers/xen/netback/Makefile
---- /scratch/src/linux-2.6.20.3/drivers/xen/netback/Makefile 1970-01-01 01:00:00.000000000 +0100
-+++ source/drivers/xen/netback/Makefile 2007-03-20 21:26:49.000000000 +0100
-@@ -0,0 +1,5 @@
-+obj-$(CONFIG_XEN_NETDEV_BACKEND) := netbk.o
-+obj-$(CONFIG_XEN_NETDEV_LOOPBACK) += netloop.o
-+
-+netbk-y := netback.o xenbus.o interface.o
-+netloop-y := loopback.o
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/drivers/xen/netback/netback.c source/drivers/xen/netback/netback.c
---- /scratch/src/linux-2.6.20.3/drivers/xen/netback/netback.c 1970-01-01 01:00:00.000000000 +0100
-+++ source/drivers/xen/netback/netback.c 2007-03-20 21:26:49.000000000 +0100
-@@ -0,0 +1,1524 @@
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 drivers/xen/netback/netback.c
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/drivers/xen/netback/netback.c Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,1496 @@
+/******************************************************************************
+ * drivers/xen/netback/netback.c
+ *
@@ -58477,9 +56673,11 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#include "common.h"
+#include <xen/balloon.h>
+#include <xen/interface/memory.h>
-+#include <asm/page.h>
+
-+/*#define NETBE_DEBUG_INTERRUPT*/
++/*define NETBE_DEBUG_INTERRUPT*/
++
++/* extra field used in struct page */
++#define netif_page_index(pg) (*(long *)&(pg)->mapping)
+
+struct netbk_rx_meta {
+ skb_frag_t frag;
@@ -58548,6 +56746,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+
+static inline unsigned long alloc_mfn(void)
+{
++ BUG_ON(alloc_index == 0);
+ return mfn_list[--alloc_index];
+}
+
@@ -58577,42 +56776,6 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ tasklet_schedule(&net_tx_tasklet);
+}
+
-+/*
-+ * A gross way of confirming the origin of an skb data page. The slab
-+ * allocator abuses a field in the page struct to cache the struct kmem_cache ptr.
-+ */
-+static inline int is_xen_skb(struct sk_buff *skb)
-+{
-+ extern struct kmem_cache *skbuff_cachep;
-+ struct kmem_cache *cp = (struct kmem_cache *)virt_to_page(skb->head)->lru.next;
-+ return (cp == skbuff_cachep);
-+}
-+
-+/*
-+ * We can flip without copying the packet unless:
-+ * 1. The data is not allocated from our special cache; or
-+ * 2. The main data area is shared; or
-+ * 3. One or more fragments are shared; or
-+ * 4. There are chained fragments.
-+ */
-+static inline int is_flippable_skb(struct sk_buff *skb)
-+{
-+ int frag;
-+
-+ if (!is_xen_skb(skb) || skb_cloned(skb))
-+ return 0;
-+
-+ for (frag = 0; frag < skb_shinfo(skb)->nr_frags; frag++) {
-+ if (page_count(skb_shinfo(skb)->frags[frag].page) > 1)
-+ return 0;
-+ }
-+
-+ if (skb_shinfo(skb)->frag_list != NULL)
-+ return 0;
-+
-+ return 1;
-+}
-+
+static struct sk_buff *netbk_copy_skb(struct sk_buff *skb)
+{
+ struct skb_shared_info *ninfo;
@@ -58708,7 +56871,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+static void tx_queue_callback(unsigned long data)
+{
+ netif_t *netif = (netif_t *)data;
-+ if (netif_schedulable(netif->dev))
++ if (netif_schedulable(netif))
+ netif_wake_queue(netif->dev);
+}
+
@@ -58719,14 +56882,17 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ BUG_ON(skb->dev != dev);
+
+ /* Drop the packet if the target domain has no receive buffers. */
-+ if (unlikely(!netif_schedulable(dev) || netbk_queue_full(netif)))
++ if (unlikely(!netif_schedulable(netif) || netbk_queue_full(netif)))
+ goto drop;
+
+ /*
+ * Copy the packet here if it's destined for a flipping interface
+ * but isn't flippable (e.g. extra references to data).
++ * XXX For now we also copy skbuffs whose head crosses a page
++ * boundary, because netbk_gop_skb can't handle them.
+ */
-+ if (!netif->copying_receiver && !is_flippable_skb(skb)) {
++ if (!netif->copying_receiver ||
++ ((skb_headlen(skb) + offset_in_page(skb->data)) >= PAGE_SIZE)) {
+ struct sk_buff *nskb = netbk_copy_skb(skb);
+ if ( unlikely(nskb == NULL) )
+ goto drop;
@@ -58829,7 +56995,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ copy_gop->flags = GNTCOPY_dest_gref;
+ if (PageForeign(page)) {
+ struct pending_tx_info *src_pend =
-+ &pending_tx_info[page->index];
++ &pending_tx_info[netif_page_index(page)];
+ copy_gop->source.domid = src_pend->netif->domid;
+ copy_gop->source.u.ref = src_pend->req.gref;
+ copy_gop->flags |= GNTCOPY_source_gref;
@@ -58898,8 +57064,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ }
+
+ /*
-+ * This must occur at the end to ensure that we don't trash
-+ * skb_shinfo until we're done.
++ * This must occur at the end to ensure that we don't trash skb_shinfo
++ * until we're done. We know that the head doesn't cross a page
++ * boundary because such packets get copied in netif_be_start_xmit.
+ */
+ head_meta->id = netbk_gop_frag(netif, head_meta, 0, npo,
+ virt_to_page(skb->data),
@@ -59026,6 +57193,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ *(int *)skb->cb = nr_frags;
+
+ if (!xen_feature(XENFEAT_auto_translated_physmap) &&
++ !((netif_t *)netdev_priv(skb->dev))->copying_receiver &&
+ check_mfn(nr_frags + 1)) {
+ /* Memory squeeze? Back off for an arbitrary while. */
+ if ( net_ratelimit() )
@@ -59158,7 +57326,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ }
+
+ if (netif_queue_stopped(netif->dev) &&
-+ netif_schedulable(netif->dev) &&
++ netif_schedulable(netif) &&
+ !netbk_queue_full(netif))
+ netif_wake_queue(netif->dev);
+
@@ -59216,7 +57384,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+
+ spin_lock_irq(&net_schedule_list_lock);
+ if (!__on_net_schedule_list(netif) &&
-+ likely(netif_schedulable(netif->dev))) {
++ likely(netif_schedulable(netif))) {
+ list_add_tail(&netif->list, &net_schedule_list);
+ netif_get(netif);
+ }
@@ -59739,7 +57907,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+
+ /* Check the remap error code. */
+ if (unlikely(netbk_tx_check_mop(skb, &mop))) {
-+ printk(KERN_ALERT "#### netback grant fails\n");
++ DPRINTK("netback grant failed.\n");
+ skb_shinfo(skb)->nr_frags = 0;
+ kfree_skb(skb);
+ continue;
@@ -59804,7 +57972,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ /* Ready for next use. */
+ init_page_count(page);
+
-+ netif_idx_release(page->index);
++ netif_idx_release(netif_page_index(page));
+}
+
+irqreturn_t netif_be_int(int irq, void *dev_id)
@@ -59814,7 +57982,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ add_to_net_schedule_list_tail(netif);
+ maybe_schedule_tx_action();
+
-+ if (netif_schedulable(netif->dev) && !netbk_queue_full(netif))
++ if (netif_schedulable(netif) && !netbk_queue_full(netif))
+ netif_wake_queue(netif->dev);
+
+ return IRQ_HANDLED;
@@ -59934,7 +58102,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ for (i = 0; i < MAX_PENDING_REQS; i++) {
+ page = mmap_pages[i];
+ SetPageForeign(page, netif_page_release);
-+ page->index = i;
++ netif_page_index(page) = i;
+ }
+
+ pending_cons = 0;
@@ -59962,10 +58130,10 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+module_init(netback_init);
+
+MODULE_LICENSE("Dual BSD/GPL");
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/drivers/xen/netback/xenbus.c source/drivers/xen/netback/xenbus.c
---- /scratch/src/linux-2.6.20.3/drivers/xen/netback/xenbus.c 1970-01-01 01:00:00.000000000 +0100
-+++ source/drivers/xen/netback/xenbus.c 2007-03-20 21:26:49.000000000 +0100
-@@ -0,0 +1,450 @@
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 drivers/xen/netback/xenbus.c
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/drivers/xen/netback/xenbus.c Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,448 @@
+/* Xenbus code for netif backend
+ Copyright (C) 2005 Rusty Russell <rusty@rustcorp.com.au>
+ Copyright (C) 2005 XenSource Ltd
@@ -60185,7 +58353,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ switch (frontend_state) {
+ case XenbusStateInitialising:
+ if (dev->state == XenbusStateClosed) {
-+ printk("%s: %s: prepare for reconnect\n",
++ printk(KERN_INFO "%s: %s: prepare for reconnect\n",
+ __FUNCTION__, dev->nodename);
+ if (be->netif) {
+ netif_disconnect(be->netif);
@@ -60306,9 +58474,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+
+ xenbus_switch_state(dev, XenbusStateConnected);
+
-+ /* May not get a kick from the frontend, so start the tx_queue now. */
-+ if (!netbk_can_queue(be->netif->dev))
-+ netif_wake_queue(be->netif->dev);
++ netif_wake_queue(be->netif->dev);
+}
+
+
@@ -60416,28 +58582,18 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+{
+ xenbus_register_backend(&netback);
+}
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/drivers/xen/netfront/Kconfig source/drivers/xen/netfront/Kconfig
---- /scratch/src/linux-2.6.20.3/drivers/xen/netfront/Kconfig 1970-01-01 01:00:00.000000000 +0100
-+++ source/drivers/xen/netfront/Kconfig 2007-03-20 21:26:49.000000000 +0100
-@@ -0,0 +1,6 @@
-+
-+config XENNET
-+ tristate "Xen network driver"
-+ depends on NETDEVICES && ARCH_XEN
-+ help
-+ Network driver for Xen
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/drivers/xen/netfront/Makefile source/drivers/xen/netfront/Makefile
---- /scratch/src/linux-2.6.20.3/drivers/xen/netfront/Makefile 1970-01-01 01:00:00.000000000 +0100
-+++ source/drivers/xen/netfront/Makefile 2007-03-20 21:26:49.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 drivers/xen/netfront/Makefile
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/drivers/xen/netfront/Makefile Wed Aug 08 16:25:28 2007 -0300
@@ -0,0 +1,4 @@
+
+obj-$(CONFIG_XEN_NETDEV_FRONTEND) := xennet.o
+
+xennet-objs := netfront.o
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/drivers/xen/netfront/netfront.c source/drivers/xen/netfront/netfront.c
---- /scratch/src/linux-2.6.20.3/drivers/xen/netfront/netfront.c 1970-01-01 01:00:00.000000000 +0100
-+++ source/drivers/xen/netfront/netfront.c 2007-03-20 21:26:49.000000000 +0100
-@@ -0,0 +1,2114 @@
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 drivers/xen/netfront/netfront.c
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/drivers/xen/netfront/netfront.c Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,2133 @@
+/******************************************************************************
+ * Virtual network driver for conversing with remote driver backends.
+ *
@@ -60491,7 +58647,6 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#include <net/pkt_sched.h>
+#include <net/arp.h>
+#include <net/route.h>
-+#include <asm/hypercall.h>
+#include <asm/uaccess.h>
+#include <xen/evtchn.h>
+#include <xen/xenbus.h>
@@ -60508,6 +58663,13 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#include <xen/platform-compat.h>
+#endif
+
++struct netfront_cb {
++ struct page *page;
++ unsigned offset;
++};
++
++#define NETFRONT_SKB_CB(skb) ((struct netfront_cb *)((skb)->cb))
++
+/*
+ * Mutually-exclusive module options to select receive data path:
+ * rx_copy : Packets are copied by network backend into local memory
@@ -60593,8 +58755,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ spinlock_t tx_lock;
+ spinlock_t rx_lock;
+
-+ unsigned int evtchn, irq;
++ unsigned int irq;
+ unsigned int copying_receiver;
++ unsigned int carrier;
+
+ /* Receive-ring batched refills. */
+#define RX_MIN_TARGET 8
@@ -60634,6 +58797,15 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+};
+
+/*
++ * Implement our own carrier flag: the network stack's version causes delays
++ * when the carrier is re-enabled (in particular, dev_activate() may not
++ * immediately be called, which can cause packet loss).
++ */
++#define netfront_carrier_on(netif) ((netif)->carrier = 1)
++#define netfront_carrier_off(netif) ((netif)->carrier = 0)
++#define netfront_carrier_ok(netif) ((netif)->carrier)
++
++/*
+ * Access macros for acquiring freeing slots in tx_skbs[].
+ */
+
@@ -60848,7 +59020,8 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ goto abort_transaction;
+ }
+ err = xenbus_printf(xbt, dev->nodename,
-+ "event-channel", "%u", info->evtchn);
++ "event-channel", "%u",
++ irq_to_evtchn_port(info->irq));
+ if (err) {
+ message = "writing event-channel";
+ goto abort_transaction;
@@ -60953,17 +59126,15 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ }
+ info->rx_ring_ref = err;
+
-+ err = xenbus_alloc_evtchn(dev, &info->evtchn);
-+ if (err)
-+ goto fail;
-+
+ memcpy(netdev->dev_addr, info->mac, ETH_ALEN);
-+ err = bind_evtchn_to_irqhandler(info->evtchn, netif_int,
-+ SA_SAMPLE_RANDOM, netdev->name,
-+ netdev);
++
++ err = bind_listening_port_to_irqhandler(
++ dev->otherend_id, netif_int, SA_SAMPLE_RANDOM, netdev->name,
++ netdev);
+ if (err < 0)
+ goto fail;
+ info->irq = err;
++
+ return 0;
+
+ fail:
@@ -61032,41 +59203,42 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ return dev_queue_xmit(skb);
+}
+
++static inline int netfront_tx_slot_available(struct netfront_info *np)
++{
++ return ((np->tx.req_prod_pvt - np->tx.rsp_cons) <
++ (TX_MAX_TARGET - MAX_SKB_FRAGS - 2));
++}
++
++static inline void network_maybe_wake_tx(struct net_device *dev)
++{
++ struct netfront_info *np = netdev_priv(dev);
++
++ if (unlikely(netif_queue_stopped(dev)) &&
++ netfront_tx_slot_available(np) &&
++ likely(netif_running(dev)))
++ netif_wake_queue(dev);
++}
++
+static int network_open(struct net_device *dev)
+{
+ struct netfront_info *np = netdev_priv(dev);
+
+ memset(&np->stats, 0, sizeof(np->stats));
+
-+ spin_lock(&np->rx_lock);
-+ if (netif_carrier_ok(dev)) {
++ spin_lock_bh(&np->rx_lock);
++ if (netfront_carrier_ok(np)) {
+ network_alloc_rx_buffers(dev);
+ np->rx.sring->rsp_event = np->rx.rsp_cons + 1;
+ if (RING_HAS_UNCONSUMED_RESPONSES(&np->rx))
+ netif_rx_schedule(dev);
+ }
-+ spin_unlock(&np->rx_lock);
++ spin_unlock_bh(&np->rx_lock);
+
-+ netif_start_queue(dev);
++ network_maybe_wake_tx(dev);
+
+ return 0;
+}
+
-+static inline int netfront_tx_slot_available(struct netfront_info *np)
-+{
-+ return RING_FREE_REQUESTS(&np->tx) >= MAX_SKB_FRAGS + 2;
-+}
-+
-+static inline void network_maybe_wake_tx(struct net_device *dev)
-+{
-+ struct netfront_info *np = netdev_priv(dev);
-+
-+ if (unlikely(netif_queue_stopped(dev)) &&
-+ netfront_tx_slot_available(np) &&
-+ likely(netif_running(dev)))
-+ netif_wake_queue(dev);
-+}
-+
+static void network_tx_buf_gc(struct net_device *dev)
+{
+ RING_IDX cons, prod;
@@ -61074,7 +59246,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ struct netfront_info *np = netdev_priv(dev);
+ struct sk_buff *skb;
+
-+ BUG_ON(!netif_carrier_ok(dev));
++ BUG_ON(!netfront_carrier_ok(np));
+
+ do {
+ prod = np->tx.sring->rsp_prod;
@@ -61144,7 +59316,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ int nr_flips;
+ netif_rx_request_t *req;
+
-+ if (unlikely(!netif_carrier_ok(dev)))
++ if (unlikely(!netfront_carrier_ok(np)))
+ return;
+
+ /*
@@ -61375,7 +59547,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+
+ spin_lock_irq(&np->tx_lock);
+
-+ if (unlikely(!netif_carrier_ok(dev) ||
++ if (unlikely(!netfront_carrier_ok(np) ||
+ (frags > 1 && !xennet_can_sg(dev)) ||
+ netif_needs_gso(dev, skb))) {
+ spin_unlock_irq(&np->tx_lock);
@@ -61465,7 +59637,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+
+ spin_lock_irqsave(&np->tx_lock, flags);
+
-+ if (likely(netif_carrier_ok(dev))) {
++ if (likely(netfront_carrier_ok(np))) {
+ network_tx_buf_gc(dev);
+ /* Under tx_lock: protects access to rx shared-ring indexes. */
+ if (RING_HAS_UNCONSUMED_RESPONSES(&np->rx))
@@ -61738,9 +59910,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ int pages_flipped = 0;
+ int err;
+
-+ spin_lock(&np->rx_lock);
++ spin_lock(&np->rx_lock); /* no need for spin_lock_bh() in ->poll() */
+
-+ if (unlikely(!netif_carrier_ok(dev))) {
++ if (unlikely(!netfront_carrier_ok(np))) {
+ spin_unlock(&np->rx_lock);
+ return 0;
+ }
@@ -61758,7 +59930,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ work_done = 0;
+ while ((i != rp) && (work_done < budget)) {
+ memcpy(rx, RING_GET_RESPONSE(&np->rx, i), sizeof(*rx));
-+ memset(extras, 0, sizeof(extras));
++ memset(extras, 0, sizeof(rinfo.extras));
+
+ err = xennet_get_responses(np, &rinfo, rp, &tmpq,
+ &pages_flipped);
@@ -61785,8 +59957,8 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ }
+ }
+
-+ skb->nh.raw = (void *)skb_shinfo(skb)->frags[0].page;
-+ skb->h.raw = skb->nh.raw + rx->offset;
++ NETFRONT_SKB_CB(skb)->page = skb_shinfo(skb)->frags[0].page;
++ NETFRONT_SKB_CB(skb)->offset = rx->offset;
+
+ len = rx->status;
+ if (len > RX_COPY_THRESHOLD)
@@ -61870,11 +60042,11 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ kfree_skb(skb);
+
+ while ((skb = __skb_dequeue(&rxq)) != NULL) {
-+ struct page *page = (struct page *)skb->nh.raw;
++ struct page *page = NETFRONT_SKB_CB(skb)->page;
+ void *vaddr = page_address(page);
++ unsigned offset = NETFRONT_SKB_CB(skb)->offset;
+
-+ memcpy(skb->data, vaddr + (skb->h.raw - skb->nh.raw),
-+ skb_headlen(skb));
++ memcpy(skb->data, vaddr + offset, skb_headlen(skb));
+
+ if (page != skb_shinfo(skb)->frags[0].page)
+ __free_page(page);
@@ -61942,16 +60114,16 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ struct sk_buff *skb;
+ unsigned long mfn;
+ int xfer = 0, noxfer = 0, unused = 0;
-+ int id, ref;
++ int id, ref, rc;
+
+ if (np->copying_receiver) {
-+ printk("%s: fix me for copying receiver.\n", __FUNCTION__);
++ WPRINTK("%s: fix me for copying receiver.\n", __FUNCTION__);
+ return;
+ }
+
+ skb_queue_head_init(&free_list);
+
-+ spin_lock(&np->rx_lock);
++ spin_lock_bh(&np->rx_lock);
+
+ for (id = 0; id < NET_RX_RING_SIZE; id++) {
+ if ((ref = np->grant_rx_ref[id]) == GRANT_INVALID_REF) {
@@ -61995,8 +60167,8 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ xfer++;
+ }
+
-+ printk("%s: %d xfer, %d noxfer, %d unused\n",
-+ __FUNCTION__, xfer, noxfer, unused);
++ IPRINTK("%s: %d xfer, %d noxfer, %d unused\n",
++ __FUNCTION__, xfer, noxfer, unused);
+
+ if (xfer) {
+ /* Some pages are no longer absent... */
@@ -62010,14 +60182,16 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ mcl->args[2] = 0;
+ mcl->args[3] = DOMID_SELF;
+ mcl++;
-+ HYPERVISOR_multicall(np->rx_mcl, mcl - np->rx_mcl);
++ rc = HYPERVISOR_multicall_check(
++ np->rx_mcl, mcl - np->rx_mcl, NULL);
++ BUG_ON(rc);
+ }
+ }
+
+ while ((skb = __skb_dequeue(&free_list)) != NULL)
+ dev_kfree_skb(skb);
+
-+ spin_unlock(&np->rx_lock);
++ spin_unlock_bh(&np->rx_lock);
+}
+
+static int network_close(struct net_device *dev)
@@ -62137,8 +60311,8 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ IPRINTK("device %s has %sing receive path.\n",
+ dev->name, np->copying_receiver ? "copy" : "flipp");
+
++ spin_lock_bh(&np->rx_lock);
+ spin_lock_irq(&np->tx_lock);
-+ spin_lock(&np->rx_lock);
+
+ /*
+ * Recovery procedure:
@@ -62185,13 +60359,13 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ * domain a kick because we've probably just requeued some
+ * packets.
+ */
-+ netif_carrier_on(dev);
++ netfront_carrier_on(np);
+ notify_remote_via_irq(np->irq);
+ network_tx_buf_gc(dev);
+ network_alloc_rx_buffers(dev);
+
-+ spin_unlock(&np->rx_lock);
+ spin_unlock_irq(&np->tx_lock);
++ spin_unlock_bh(&np->rx_lock);
+
+ return 0;
+}
@@ -62247,7 +60421,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ if (target > RX_MAX_TARGET)
+ target = RX_MAX_TARGET;
+
-+ spin_lock(&np->rx_lock);
++ spin_lock_bh(&np->rx_lock);
+ if (target > np->rx_max_target)
+ np->rx_max_target = target;
+ np->rx_min_target = target;
@@ -62256,7 +60430,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+
+ network_alloc_rx_buffers(netdev);
+
-+ spin_unlock(&np->rx_lock);
++ spin_unlock_bh(&np->rx_lock);
+ return len;
+}
+
@@ -62290,7 +60464,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ if (target > RX_MAX_TARGET)
+ target = RX_MAX_TARGET;
+
-+ spin_lock(&np->rx_lock);
++ spin_lock_bh(&np->rx_lock);
+ if (target < np->rx_min_target)
+ np->rx_min_target = target;
+ np->rx_max_target = target;
@@ -62299,7 +60473,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+
+ network_alloc_rx_buffers(netdev);
+
-+ spin_unlock(&np->rx_lock);
++ spin_unlock_bh(&np->rx_lock);
+ return len;
+}
+
@@ -62375,8 +60549,6 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ np = netdev_priv(netdev);
+ np->xbdev = dev;
+
-+ netif_carrier_off(netdev);
-+
+ spin_lock_init(&np->tx_lock);
+ spin_lock_init(&np->rx_lock);
+
@@ -62431,6 +60603,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ SET_NETDEV_DEV(netdev, &dev->dev);
+
+ np->netdev = netdev;
++
++ netfront_carrier_off(np);
++
+ return netdev;
+
+ exit_free_tx:
@@ -62461,15 +60636,15 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+static void netif_disconnect_backend(struct netfront_info *info)
+{
+ /* Stop old i/f to prevent errors whilst we rebuild the state. */
++ spin_lock_bh(&info->rx_lock);
+ spin_lock_irq(&info->tx_lock);
-+ spin_lock(&info->rx_lock);
-+ netif_carrier_off(info->netdev);
-+ spin_unlock(&info->rx_lock);
++ netfront_carrier_off(info);
+ spin_unlock_irq(&info->tx_lock);
++ spin_unlock_bh(&info->rx_lock);
+
+ if (info->irq)
+ unbind_from_irqhandler(info->irq, info->netdev);
-+ info->evtchn = info->irq = 0;
++ info->irq = 0;
+
+ end_access(info->tx_ring_ref, info->tx.sring);
+ end_access(info->rx_ring_ref, info->rx.sring);
@@ -62552,10 +60727,29 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+module_exit(netif_exit);
+
+MODULE_LICENSE("Dual BSD/GPL");
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/drivers/xen/pciback/conf_space.c source/drivers/xen/pciback/conf_space.c
---- /scratch/src/linux-2.6.20.3/drivers/xen/pciback/conf_space.c 1970-01-01 01:00:00.000000000 +0100
-+++ source/drivers/xen/pciback/conf_space.c 2007-03-20 21:26:49.000000000 +0100
-@@ -0,0 +1,425 @@
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 drivers/xen/pciback/Makefile
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/drivers/xen/pciback/Makefile Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,15 @@
++obj-$(CONFIG_XEN_PCIDEV_BACKEND) += pciback.o
++
++pciback-y := pci_stub.o pciback_ops.o xenbus.o
++pciback-y += conf_space.o conf_space_header.o \
++ conf_space_capability.o \
++ conf_space_capability_vpd.o \
++ conf_space_capability_pm.o \
++ conf_space_quirks.o
++pciback-$(CONFIG_XEN_PCIDEV_BACKEND_VPCI) += vpci.o
++pciback-$(CONFIG_XEN_PCIDEV_BACKEND_SLOT) += slot.o
++pciback-$(CONFIG_XEN_PCIDEV_BACKEND_PASS) += passthrough.o
++
++ifeq ($(CONFIG_XEN_PCIDEV_BE_DEBUG),y)
++EXTRA_CFLAGS += -DDEBUG
++endif
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 drivers/xen/pciback/conf_space.c
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/drivers/xen/pciback/conf_space.c Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,426 @@
+/*
+ * PCI Backend - Functions for creating a virtual configuration space for
+ * exported PCI Devices.
@@ -62907,17 +61101,13 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+
+int pciback_config_add_field_offset(struct pci_dev *dev,
+ struct config_field *field,
-+ unsigned int offset)
++ unsigned int base_offset)
+{
+ int err = 0;
+ struct pciback_dev_data *dev_data = pci_get_drvdata(dev);
+ struct config_field_entry *cfg_entry;
+ void *tmp;
+
-+ /* silently ignore duplicate fields */
-+ if (pciback_field_is_dup(dev, field->offset))
-+ goto out;
-+
+ cfg_entry = kmalloc(sizeof(*cfg_entry), GFP_KERNEL);
+ if (!cfg_entry) {
+ err = -ENOMEM;
@@ -62926,7 +61116,12 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+
+ cfg_entry->data = NULL;
+ cfg_entry->field = field;
-+ cfg_entry->base_offset = offset;
++ cfg_entry->base_offset = base_offset;
++
++ /* silently ignore duplicate fields */
++ err = pciback_field_is_dup(dev,OFFSET(cfg_entry));
++ if (err)
++ goto out;
+
+ if (field->init) {
+ tmp = field->init(dev, OFFSET(cfg_entry));
@@ -62981,9 +61176,139 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+{
+ return pciback_config_capability_init();
+}
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/drivers/xen/pciback/conf_space_capability.c source/drivers/xen/pciback/conf_space_capability.c
---- /scratch/src/linux-2.6.20.3/drivers/xen/pciback/conf_space_capability.c 1970-01-01 01:00:00.000000000 +0100
-+++ source/drivers/xen/pciback/conf_space_capability.c 2007-03-20 21:26:49.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 drivers/xen/pciback/conf_space.h
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/drivers/xen/pciback/conf_space.h Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,126 @@
++/*
++ * PCI Backend - Common data structures for overriding the configuration space
++ *
++ * Author: Ryan Wilson <hap9@epoch.ncsc.mil>
++ */
++
++#ifndef __XEN_PCIBACK_CONF_SPACE_H__
++#define __XEN_PCIBACK_CONF_SPACE_H__
++
++#include <linux/list.h>
++#include <linux/err.h>
++
++/* conf_field_init can return an errno in a ptr with ERR_PTR() */
++typedef void *(*conf_field_init) (struct pci_dev * dev, int offset);
++typedef void (*conf_field_reset) (struct pci_dev * dev, int offset, void *data);
++typedef void (*conf_field_free) (struct pci_dev * dev, int offset, void *data);
++
++typedef int (*conf_dword_write) (struct pci_dev * dev, int offset, u32 value,
++ void *data);
++typedef int (*conf_word_write) (struct pci_dev * dev, int offset, u16 value,
++ void *data);
++typedef int (*conf_byte_write) (struct pci_dev * dev, int offset, u8 value,
++ void *data);
++typedef int (*conf_dword_read) (struct pci_dev * dev, int offset, u32 * value,
++ void *data);
++typedef int (*conf_word_read) (struct pci_dev * dev, int offset, u16 * value,
++ void *data);
++typedef int (*conf_byte_read) (struct pci_dev * dev, int offset, u8 * value,
++ void *data);
++
++/* These are the fields within the configuration space which we
++ * are interested in intercepting reads/writes to and changing their
++ * values.
++ */
++struct config_field {
++ unsigned int offset;
++ unsigned int size;
++ unsigned int mask;
++ conf_field_init init;
++ conf_field_reset reset;
++ conf_field_free release;
++ void (*clean) (struct config_field * field);
++ union {
++ struct {
++ conf_dword_write write;
++ conf_dword_read read;
++ } dw;
++ struct {
++ conf_word_write write;
++ conf_word_read read;
++ } w;
++ struct {
++ conf_byte_write write;
++ conf_byte_read read;
++ } b;
++ } u;
++ struct list_head list;
++};
++
++struct config_field_entry {
++ struct list_head list;
++ struct config_field *field;
++ unsigned int base_offset;
++ void *data;
++};
++
++#define OFFSET(cfg_entry) ((cfg_entry)->base_offset+(cfg_entry)->field->offset)
++
++/* Add fields to a device - the add_fields macro expects to get a pointer to
++ * the first entry in an array (of which the ending is marked by size==0)
++ */
++int pciback_config_add_field_offset(struct pci_dev *dev,
++ struct config_field *field,
++ unsigned int offset);
++
++static inline int pciback_config_add_field(struct pci_dev *dev,
++ struct config_field *field)
++{
++ return pciback_config_add_field_offset(dev, field, 0);
++}
++
++static inline int pciback_config_add_fields(struct pci_dev *dev,
++ struct config_field *field)
++{
++ int i, err = 0;
++ for (i = 0; field[i].size != 0; i++) {
++ err = pciback_config_add_field(dev, &field[i]);
++ if (err)
++ break;
++ }
++ return err;
++}
++
++static inline int pciback_config_add_fields_offset(struct pci_dev *dev,
++ struct config_field *field,
++ unsigned int offset)
++{
++ int i, err = 0;
++ for (i = 0; field[i].size != 0; i++) {
++ err = pciback_config_add_field_offset(dev, &field[i], offset);
++ if (err)
++ break;
++ }
++ return err;
++}
++
++/* Read/Write the real configuration space */
++int pciback_read_config_byte(struct pci_dev *dev, int offset, u8 * value,
++ void *data);
++int pciback_read_config_word(struct pci_dev *dev, int offset, u16 * value,
++ void *data);
++int pciback_read_config_dword(struct pci_dev *dev, int offset, u32 * value,
++ void *data);
++int pciback_write_config_byte(struct pci_dev *dev, int offset, u8 value,
++ void *data);
++int pciback_write_config_word(struct pci_dev *dev, int offset, u16 value,
++ void *data);
++int pciback_write_config_dword(struct pci_dev *dev, int offset, u32 value,
++ void *data);
++
++int pciback_config_capability_init(void);
++
++int pciback_config_header_add_fields(struct pci_dev *dev);
++int pciback_config_capability_add_fields(struct pci_dev *dev);
++
++#endif /* __XEN_PCIBACK_CONF_SPACE_H__ */
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 drivers/xen/pciback/conf_space_capability.c
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/drivers/xen/pciback/conf_space_capability.c Wed Aug 08 16:25:28 2007 -0300
@@ -0,0 +1,71 @@
+/*
+ * PCI Backend - Handles the virtual fields found on the capability lists
@@ -63056,9 +61381,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+
+ return 0;
+}
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/drivers/xen/pciback/conf_space_capability.h source/drivers/xen/pciback/conf_space_capability.h
---- /scratch/src/linux-2.6.20.3/drivers/xen/pciback/conf_space_capability.h 1970-01-01 01:00:00.000000000 +0100
-+++ source/drivers/xen/pciback/conf_space_capability.h 2007-03-20 21:26:49.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 drivers/xen/pciback/conf_space_capability.h
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/drivers/xen/pciback/conf_space_capability.h Wed Aug 08 16:25:28 2007 -0300
@@ -0,0 +1,23 @@
+/*
+ * PCI Backend - Data structures for special overlays for structures on
@@ -63083,10 +61408,10 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+};
+
+#endif
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/drivers/xen/pciback/conf_space_capability_pm.c source/drivers/xen/pciback/conf_space_capability_pm.c
---- /scratch/src/linux-2.6.20.3/drivers/xen/pciback/conf_space_capability_pm.c 1970-01-01 01:00:00.000000000 +0100
-+++ source/drivers/xen/pciback/conf_space_capability_pm.c 2007-03-20 21:26:49.000000000 +0100
-@@ -0,0 +1,113 @@
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 drivers/xen/pciback/conf_space_capability_pm.c
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/drivers/xen/pciback/conf_space_capability_pm.c Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,128 @@
+/*
+ * PCI Backend - Configuration space overlay for power management
+ *
@@ -63121,19 +61446,19 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ void *data)
+{
+ int err;
-+ u16 cur_value;
-+ pci_power_t new_state;
-+
-+ /* Handle setting power state separately */
-+ new_state = (pci_power_t)(new_value & PCI_PM_CTRL_STATE_MASK);
++ u16 old_value;
++ pci_power_t new_state, old_state;
+
-+ err = pci_read_config_word(dev, offset, &cur_value);
++ err = pci_read_config_word(dev, offset, &old_value);
+ if (err)
+ goto out;
+
++ old_state = (pci_power_t)(old_value & PCI_PM_CTRL_STATE_MASK);
++ new_state = (pci_power_t)(new_value & PCI_PM_CTRL_STATE_MASK);
++
+ new_value &= PM_OK_BITS;
-+ if ((cur_value & PM_OK_BITS) != new_value) {
-+ new_value = (cur_value & ~PM_OK_BITS) | new_value;
++ if ((old_value & PM_OK_BITS) != new_value) {
++ new_value = (old_value & ~PM_OK_BITS) | new_value;
+ err = pci_write_config_word(dev, offset, new_value);
+ if (err)
+ goto out;
@@ -63142,10 +61467,25 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ /* Let pci core handle the power management change */
+ dev_dbg(&dev->dev, "set power state to %x\n", new_state);
+ err = pci_set_power_state(dev, new_state);
-+ if (err)
++ if (err) {
+ err = PCIBIOS_SET_FAILED;
++ goto out;
++ }
+
-+ out:
++ /*
++ * Device may lose PCI config info on D3->D0 transition. This
++ * is a problem for some guests which will not reset BARs. Even
++ * those that have a go will be foiled by our BAR-write handler
++ * which will discard the write! Since Linux won't re-init
++ * the config space automatically in all cases, we do it here.
++ * Future: Should we re-initialise all first 64 bytes of config space?
++ */
++ if (new_state == PCI_D0 &&
++ (old_state == PCI_D3hot || old_state == PCI_D3cold) &&
++ !(old_value & PCI_PM_CTRL_NO_SOFT_RESET))
++ pci_restore_bars(dev);
++
++ out:
+ return err;
+}
+
@@ -63200,9 +61540,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ .capability = PCI_CAP_ID_PM,
+ .fields = caplist_pm,
+};
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/drivers/xen/pciback/conf_space_capability_vpd.c source/drivers/xen/pciback/conf_space_capability_vpd.c
---- /scratch/src/linux-2.6.20.3/drivers/xen/pciback/conf_space_capability_vpd.c 1970-01-01 01:00:00.000000000 +0100
-+++ source/drivers/xen/pciback/conf_space_capability_vpd.c 2007-03-20 21:26:49.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 drivers/xen/pciback/conf_space_capability_vpd.c
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/drivers/xen/pciback/conf_space_capability_vpd.c Wed Aug 08 16:25:28 2007 -0300
@@ -0,0 +1,42 @@
+/*
+ * PCI Backend - Configuration space overlay for Vital Product Data
@@ -63246,140 +61586,10 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ .capability = PCI_CAP_ID_VPD,
+ .fields = caplist_vpd,
+};
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/drivers/xen/pciback/conf_space.h source/drivers/xen/pciback/conf_space.h
---- /scratch/src/linux-2.6.20.3/drivers/xen/pciback/conf_space.h 1970-01-01 01:00:00.000000000 +0100
-+++ source/drivers/xen/pciback/conf_space.h 2007-03-20 21:26:49.000000000 +0100
-@@ -0,0 +1,126 @@
-+/*
-+ * PCI Backend - Common data structures for overriding the configuration space
-+ *
-+ * Author: Ryan Wilson <hap9@epoch.ncsc.mil>
-+ */
-+
-+#ifndef __XEN_PCIBACK_CONF_SPACE_H__
-+#define __XEN_PCIBACK_CONF_SPACE_H__
-+
-+#include <linux/list.h>
-+#include <linux/err.h>
-+
-+/* conf_field_init can return an errno in a ptr with ERR_PTR() */
-+typedef void *(*conf_field_init) (struct pci_dev * dev, int offset);
-+typedef void (*conf_field_reset) (struct pci_dev * dev, int offset, void *data);
-+typedef void (*conf_field_free) (struct pci_dev * dev, int offset, void *data);
-+
-+typedef int (*conf_dword_write) (struct pci_dev * dev, int offset, u32 value,
-+ void *data);
-+typedef int (*conf_word_write) (struct pci_dev * dev, int offset, u16 value,
-+ void *data);
-+typedef int (*conf_byte_write) (struct pci_dev * dev, int offset, u8 value,
-+ void *data);
-+typedef int (*conf_dword_read) (struct pci_dev * dev, int offset, u32 * value,
-+ void *data);
-+typedef int (*conf_word_read) (struct pci_dev * dev, int offset, u16 * value,
-+ void *data);
-+typedef int (*conf_byte_read) (struct pci_dev * dev, int offset, u8 * value,
-+ void *data);
-+
-+/* These are the fields within the configuration space which we
-+ * are interested in intercepting reads/writes to and changing their
-+ * values.
-+ */
-+struct config_field {
-+ unsigned int offset;
-+ unsigned int size;
-+ unsigned int mask;
-+ conf_field_init init;
-+ conf_field_reset reset;
-+ conf_field_free release;
-+ void (*clean) (struct config_field * field);
-+ union {
-+ struct {
-+ conf_dword_write write;
-+ conf_dword_read read;
-+ } dw;
-+ struct {
-+ conf_word_write write;
-+ conf_word_read read;
-+ } w;
-+ struct {
-+ conf_byte_write write;
-+ conf_byte_read read;
-+ } b;
-+ } u;
-+ struct list_head list;
-+};
-+
-+struct config_field_entry {
-+ struct list_head list;
-+ struct config_field *field;
-+ unsigned int base_offset;
-+ void *data;
-+};
-+
-+#define OFFSET(cfg_entry) ((cfg_entry)->base_offset+(cfg_entry)->field->offset)
-+
-+/* Add fields to a device - the add_fields macro expects to get a pointer to
-+ * the first entry in an array (of which the ending is marked by size==0)
-+ */
-+int pciback_config_add_field_offset(struct pci_dev *dev,
-+ struct config_field *field,
-+ unsigned int offset);
-+
-+static inline int pciback_config_add_field(struct pci_dev *dev,
-+ struct config_field *field)
-+{
-+ return pciback_config_add_field_offset(dev, field, 0);
-+}
-+
-+static inline int pciback_config_add_fields(struct pci_dev *dev,
-+ struct config_field *field)
-+{
-+ int i, err = 0;
-+ for (i = 0; field[i].size != 0; i++) {
-+ err = pciback_config_add_field(dev, &field[i]);
-+ if (err)
-+ break;
-+ }
-+ return err;
-+}
-+
-+static inline int pciback_config_add_fields_offset(struct pci_dev *dev,
-+ struct config_field *field,
-+ unsigned int offset)
-+{
-+ int i, err = 0;
-+ for (i = 0; field[i].size != 0; i++) {
-+ err = pciback_config_add_field_offset(dev, &field[i], offset);
-+ if (err)
-+ break;
-+ }
-+ return err;
-+}
-+
-+/* Read/Write the real configuration space */
-+int pciback_read_config_byte(struct pci_dev *dev, int offset, u8 * value,
-+ void *data);
-+int pciback_read_config_word(struct pci_dev *dev, int offset, u16 * value,
-+ void *data);
-+int pciback_read_config_dword(struct pci_dev *dev, int offset, u32 * value,
-+ void *data);
-+int pciback_write_config_byte(struct pci_dev *dev, int offset, u8 value,
-+ void *data);
-+int pciback_write_config_word(struct pci_dev *dev, int offset, u16 value,
-+ void *data);
-+int pciback_write_config_dword(struct pci_dev *dev, int offset, u32 value,
-+ void *data);
-+
-+int pciback_config_capability_init(void);
-+
-+int pciback_config_header_add_fields(struct pci_dev *dev);
-+int pciback_config_capability_add_fields(struct pci_dev *dev);
-+
-+#endif /* __XEN_PCIBACK_CONF_SPACE_H__ */
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/drivers/xen/pciback/conf_space_header.c source/drivers/xen/pciback/conf_space_header.c
---- /scratch/src/linux-2.6.20.3/drivers/xen/pciback/conf_space_header.c 1970-01-01 01:00:00.000000000 +0100
-+++ source/drivers/xen/pciback/conf_space_header.c 2007-03-20 21:26:49.000000000 +0100
-@@ -0,0 +1,301 @@
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 drivers/xen/pciback/conf_space_header.c
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/drivers/xen/pciback/conf_space_header.c Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,309 @@
+/*
+ * PCI Backend - Handles the virtual fields in the configuration space headers.
+ *
@@ -63402,12 +61612,15 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+
+static int command_write(struct pci_dev *dev, int offset, u16 value, void *data)
+{
++ int err;
++
+ if (!atomic_read(&dev->enable_cnt) && is_enable_cmd(value)) {
+ if (unlikely(verbose_request))
+ printk(KERN_DEBUG "pciback: %s: enable\n",
+ pci_name(dev));
-+ if (pci_enable_device(dev))
-+ return -ENODEV;
++ err = pci_enable_device(dev);
++ if (err)
++ return err;
+ } else if (atomic_read(&dev->enable_cnt) && !is_enable_cmd(value)) {
+ if (unlikely(verbose_request))
+ printk(KERN_DEBUG "pciback: %s: disable\n",
@@ -63427,8 +61640,13 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ printk(KERN_DEBUG
+ "pciback: %s: enable memory-write-invalidate\n",
+ pci_name(dev));
-+ if (pci_set_mwi(dev))
-+ return -EINVAL;
++ err = pci_set_mwi(dev);
++ if (err) {
++ printk(KERN_WARNING
++ "pciback: %s: cannot enable memory-write-invalidate (%d)\n",
++ pci_name(dev), err);
++ value &= ~PCI_COMMAND_INVALIDATE;
++ }
+ }
+
+ return pci_write_config_word(dev, offset, value);
@@ -63681,10 +61899,10 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ out:
+ return err;
+}
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/drivers/xen/pciback/conf_space_quirks.c source/drivers/xen/pciback/conf_space_quirks.c
---- /scratch/src/linux-2.6.20.3/drivers/xen/pciback/conf_space_quirks.c 1970-01-01 01:00:00.000000000 +0100
-+++ source/drivers/xen/pciback/conf_space_quirks.c 2007-03-20 21:26:49.000000000 +0100
-@@ -0,0 +1,128 @@
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 drivers/xen/pciback/conf_space_quirks.c
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/drivers/xen/pciback/conf_space_quirks.c Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,126 @@
+/*
+ * PCI Backend - Handle special overlays for broken devices.
+ *
@@ -63719,16 +61937,14 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ list_add_tail(&quirk->quirks_list, &pciback_quirks);
+}
+
-+int pciback_field_is_dup(struct pci_dev *dev, int reg)
++int pciback_field_is_dup(struct pci_dev *dev, unsigned int reg)
+{
+ int ret = 0;
+ struct pciback_dev_data *dev_data = pci_get_drvdata(dev);
-+ struct config_field *field;
+ struct config_field_entry *cfg_entry;
+
+ list_for_each_entry(cfg_entry, &dev_data->config_fields, list) {
-+ field = cfg_entry->field;
-+ if (field->offset == reg) {
++ if ( OFFSET(cfg_entry) == reg) {
+ ret = 1;
+ break;
+ }
@@ -63813,9 +62029,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ out:
+ return ret;
+}
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/drivers/xen/pciback/conf_space_quirks.h source/drivers/xen/pciback/conf_space_quirks.h
---- /scratch/src/linux-2.6.20.3/drivers/xen/pciback/conf_space_quirks.h 1970-01-01 01:00:00.000000000 +0100
-+++ source/drivers/xen/pciback/conf_space_quirks.h 2007-03-20 21:26:49.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 drivers/xen/pciback/conf_space_quirks.h
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/drivers/xen/pciback/conf_space_quirks.h Wed Aug 08 16:25:28 2007 -0300
@@ -0,0 +1,35 @@
+/*
+ * PCI Backend - Data structures for special overlays for broken devices.
@@ -63849,31 +62065,12 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+
+int pciback_config_quirk_release(struct pci_dev *dev);
+
-+int pciback_field_is_dup(struct pci_dev *dev, int reg);
++int pciback_field_is_dup(struct pci_dev *dev, unsigned int reg);
+
+#endif
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/drivers/xen/pciback/Makefile source/drivers/xen/pciback/Makefile
---- /scratch/src/linux-2.6.20.3/drivers/xen/pciback/Makefile 1970-01-01 01:00:00.000000000 +0100
-+++ source/drivers/xen/pciback/Makefile 2007-03-20 21:26:49.000000000 +0100
-@@ -0,0 +1,15 @@
-+obj-$(CONFIG_XEN_PCIDEV_BACKEND) += pciback.o
-+
-+pciback-y := pci_stub.o pciback_ops.o xenbus.o
-+pciback-y += conf_space.o conf_space_header.o \
-+ conf_space_capability.o \
-+ conf_space_capability_vpd.o \
-+ conf_space_capability_pm.o \
-+ conf_space_quirks.o
-+pciback-$(CONFIG_XEN_PCIDEV_BACKEND_VPCI) += vpci.o
-+pciback-$(CONFIG_XEN_PCIDEV_BACKEND_SLOT) += slot.o
-+pciback-$(CONFIG_XEN_PCIDEV_BACKEND_PASS) += passthrough.o
-+
-+ifeq ($(CONFIG_XEN_PCIDEV_BE_DEBUG),y)
-+EXTRA_CFLAGS += -DDEBUG
-+endif
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/drivers/xen/pciback/passthrough.c source/drivers/xen/pciback/passthrough.c
---- /scratch/src/linux-2.6.20.3/drivers/xen/pciback/passthrough.c 1970-01-01 01:00:00.000000000 +0100
-+++ source/drivers/xen/pciback/passthrough.c 2007-03-20 21:26:49.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 drivers/xen/pciback/passthrough.c
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/drivers/xen/pciback/passthrough.c Wed Aug 08 16:25:28 2007 -0300
@@ -0,0 +1,157 @@
+/*
+ * PCI Backend - Provides restricted access to the real PCI bus topology
@@ -64032,205 +62229,10 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ kfree(dev_data);
+ pdev->pci_dev_data = NULL;
+}
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/drivers/xen/pciback/pciback.h source/drivers/xen/pciback/pciback.h
---- /scratch/src/linux-2.6.20.3/drivers/xen/pciback/pciback.h 1970-01-01 01:00:00.000000000 +0100
-+++ source/drivers/xen/pciback/pciback.h 2007-03-20 21:26:49.000000000 +0100
-@@ -0,0 +1,93 @@
-+/*
-+ * PCI Backend Common Data Structures & Function Declarations
-+ *
-+ * Author: Ryan Wilson <hap9@epoch.ncsc.mil>
-+ */
-+#ifndef __XEN_PCIBACK_H__
-+#define __XEN_PCIBACK_H__
-+
-+#include <linux/pci.h>
-+#include <linux/interrupt.h>
-+#include <xen/xenbus.h>
-+#include <linux/list.h>
-+#include <linux/spinlock.h>
-+#include <linux/workqueue.h>
-+#include <asm/atomic.h>
-+#include <xen/interface/io/pciif.h>
-+
-+struct pci_dev_entry {
-+ struct list_head list;
-+ struct pci_dev *dev;
-+};
-+
-+#define _PDEVF_op_active (0)
-+#define PDEVF_op_active (1<<(_PDEVF_op_active))
-+
-+struct pciback_device {
-+ void *pci_dev_data;
-+ spinlock_t dev_lock;
-+
-+ struct xenbus_device *xdev;
-+
-+ struct xenbus_watch be_watch;
-+ u8 be_watching;
-+
-+ int evtchn_irq;
-+
-+ struct vm_struct *sh_area;
-+ struct xen_pci_sharedinfo *sh_info;
-+
-+ unsigned long flags;
-+
-+ struct delayed_work op_work;
-+};
-+
-+struct pciback_dev_data {
-+ struct list_head config_fields;
-+ int permissive;
-+ int warned_on_write;
-+};
-+
-+/* Get/Put PCI Devices that are hidden from the PCI Backend Domain */
-+struct pci_dev *pcistub_get_pci_dev_by_slot(struct pciback_device *pdev,
-+ int domain, int bus,
-+ int slot, int func);
-+struct pci_dev *pcistub_get_pci_dev(struct pciback_device *pdev,
-+ struct pci_dev *dev);
-+void pcistub_put_pci_dev(struct pci_dev *dev);
-+
-+/* Ensure a device is turned off or reset */
-+void pciback_reset_device(struct pci_dev *pdev);
-+
-+/* Access a virtual configuration space for a PCI device */
-+int pciback_config_init(void);
-+int pciback_config_init_dev(struct pci_dev *dev);
-+void pciback_config_free_dyn_fields(struct pci_dev *dev);
-+void pciback_config_reset_dev(struct pci_dev *dev);
-+void pciback_config_free_dev(struct pci_dev *dev);
-+int pciback_config_read(struct pci_dev *dev, int offset, int size,
-+ u32 * ret_val);
-+int pciback_config_write(struct pci_dev *dev, int offset, int size, u32 value);
-+
-+/* Handle requests for specific devices from the frontend */
-+typedef int (*publish_pci_root_cb) (struct pciback_device * pdev,
-+ unsigned int domain, unsigned int bus);
-+int pciback_add_pci_dev(struct pciback_device *pdev, struct pci_dev *dev);
-+void pciback_release_pci_dev(struct pciback_device *pdev, struct pci_dev *dev);
-+struct pci_dev *pciback_get_pci_dev(struct pciback_device *pdev,
-+ unsigned int domain, unsigned int bus,
-+ unsigned int devfn);
-+int pciback_init_devices(struct pciback_device *pdev);
-+int pciback_publish_pci_roots(struct pciback_device *pdev,
-+ publish_pci_root_cb cb);
-+void pciback_release_devices(struct pciback_device *pdev);
-+
-+/* Handles events from front-end */
-+irqreturn_t pciback_handle_event(int irq, void *dev_id);
-+void pciback_do_op(struct work_struct *work);
-+
-+int pciback_xenbus_register(void);
-+void pciback_xenbus_unregister(void);
-+
-+extern int verbose_request;
-+#endif
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/drivers/xen/pciback/pciback_ops.c source/drivers/xen/pciback/pciback_ops.c
---- /scratch/src/linux-2.6.20.3/drivers/xen/pciback/pciback_ops.c 1970-01-01 01:00:00.000000000 +0100
-+++ source/drivers/xen/pciback/pciback_ops.c 2007-03-20 21:26:49.000000000 +0100
-@@ -0,0 +1,94 @@
-+/*
-+ * PCI Backend Operations - respond to PCI requests from Frontend
-+ *
-+ * Author: Ryan Wilson <hap9@epoch.ncsc.mil>
-+ */
-+#include <linux/module.h>
-+#include <asm/bitops.h>
-+#include <xen/evtchn.h>
-+#include "pciback.h"
-+
-+int verbose_request = 0;
-+module_param(verbose_request, int, 0644);
-+
-+/* Ensure a device is "turned off" and ready to be exported.
-+ * (Also see pciback_config_reset to ensure virtual configuration space is
-+ * ready to be re-exported)
-+ */
-+void pciback_reset_device(struct pci_dev *dev)
-+{
-+ u16 cmd;
-+
-+ /* Disable devices (but not bridges) */
-+ if (dev->hdr_type == PCI_HEADER_TYPE_NORMAL) {
-+ pci_disable_device(dev);
-+
-+ pci_write_config_word(dev, PCI_COMMAND, 0);
-+
-+ dev->is_busmaster = 0;
-+ } else {
-+ pci_read_config_word(dev, PCI_COMMAND, &cmd);
-+ if (cmd & (PCI_COMMAND_INVALIDATE)) {
-+ cmd &= ~(PCI_COMMAND_INVALIDATE);
-+ pci_write_config_word(dev, PCI_COMMAND, cmd);
-+
-+ dev->is_busmaster = 0;
-+ }
-+ }
-+}
-+
-+static inline void test_and_schedule_op(struct pciback_device *pdev)
-+{
-+ /* Check that frontend is requesting an operation and that we are not
-+ * already processing a request */
-+ if (test_bit(_XEN_PCIF_active, (unsigned long *)&pdev->sh_info->flags)
-+ && !test_and_set_bit(_PDEVF_op_active, &pdev->flags))
-+ schedule_delayed_work(&pdev->op_work, 0);
-+}
-+
-+/* Performing the configuration space reads/writes must not be done in atomic
-+ * context because some of the pci_* functions can sleep (mostly due to ACPI
-+ * use of semaphores). This function is intended to be called from a work
-+ * queue in process context taking a struct pciback_device as a parameter */
-+void pciback_do_op(struct work_struct *work)
-+{
-+ struct pciback_device *pdev = container_of(work, struct pciback_device, op_work.work);
-+ struct pci_dev *dev;
-+ struct xen_pci_op *op = &pdev->sh_info->op;
-+
-+ dev = pciback_get_pci_dev(pdev, op->domain, op->bus, op->devfn);
-+
-+ if (dev == NULL)
-+ op->err = XEN_PCI_ERR_dev_not_found;
-+ else if (op->cmd == XEN_PCI_OP_conf_read)
-+ op->err = pciback_config_read(dev, op->offset, op->size,
-+ &op->value);
-+ else if (op->cmd == XEN_PCI_OP_conf_write)
-+ op->err = pciback_config_write(dev, op->offset, op->size,
-+ op->value);
-+ else
-+ op->err = XEN_PCI_ERR_not_implemented;
-+
-+ /* Tell the driver domain that we're done. */
-+ wmb();
-+ clear_bit(_XEN_PCIF_active, (unsigned long *)&pdev->sh_info->flags);
-+ notify_remote_via_irq(pdev->evtchn_irq);
-+
-+ /* Mark that we're done. */
-+ smp_mb__before_clear_bit(); /* /after/ clearing PCIF_active */
-+ clear_bit(_PDEVF_op_active, &pdev->flags);
-+ smp_mb__after_clear_bit(); /* /before/ final check for work */
-+
-+ /* Check to see if the driver domain tried to start another request in
-+ * between clearing _XEN_PCIF_active and clearing _PDEVF_op_active. */
-+ test_and_schedule_op(pdev);
-+}
-+
-+irqreturn_t pciback_handle_event(int irq, void *dev_id)
-+{
-+ struct pciback_device *pdev = dev_id;
-+
-+ test_and_schedule_op(pdev);
-+
-+ return IRQ_HANDLED;
-+}
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/drivers/xen/pciback/pci_stub.c source/drivers/xen/pciback/pci_stub.c
---- /scratch/src/linux-2.6.20.3/drivers/xen/pciback/pci_stub.c 1970-01-01 01:00:00.000000000 +0100
-+++ source/drivers/xen/pciback/pci_stub.c 2007-03-20 21:26:49.000000000 +0100
-@@ -0,0 +1,923 @@
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 drivers/xen/pciback/pci_stub.c
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/drivers/xen/pciback/pci_stub.c Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,929 @@
+/*
+ * PCI Stub Driver - Grabs devices in backend to be exported later
+ *
@@ -64822,10 +62824,6 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ }
+ dev = psdev->dev;
+
-+ /* check for duplicate field */
-+ if (pciback_field_is_dup(dev, reg))
-+ goto out;
-+
+ field = kzalloc(sizeof(*field), GFP_ATOMIC);
+ if (!field) {
+ err = -ENOMEM;
@@ -64961,10 +62959,10 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ if (count >= PAGE_SIZE)
+ goto out;
+
-+ count += scnprintf(buf + count, PAGE_SIZE -
-+ count, "\t\t%08x:%01x:%08x\n",
-+ field->offset, field->size,
-+ field->mask);
++ count += scnprintf(buf + count, PAGE_SIZE - count,
++ "\t\t%08x:%01x:%08x\n",
++ cfg_entry->base_offset + field->offset,
++ field->size, field->mask);
+ }
+ }
+
@@ -65042,6 +63040,18 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+
+DRIVER_ATTR(permissive, S_IRUSR | S_IWUSR, permissive_show, permissive_add);
+
++static void pcistub_exit(void)
++{
++ driver_remove_file(&pciback_pci_driver.driver, &driver_attr_new_slot);
++ driver_remove_file(&pciback_pci_driver.driver,
++ &driver_attr_remove_slot);
++ driver_remove_file(&pciback_pci_driver.driver, &driver_attr_slots);
++ driver_remove_file(&pciback_pci_driver.driver, &driver_attr_quirks);
++ driver_remove_file(&pciback_pci_driver.driver, &driver_attr_permissive);
++
++ pci_unregister_driver(&pciback_pci_driver);
++}
++
+static int __init pcistub_init(void)
+{
+ int pos = 0;
@@ -65081,20 +63091,24 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ err = pci_register_driver(&pciback_pci_driver);
+ if (err < 0)
+ goto out;
-+ err = driver_create_file(&pciback_pci_driver.driver, &driver_attr_new_slot);
-+ if (err < 0)
-+ goto out;
++
+ err = driver_create_file(&pciback_pci_driver.driver,
-+ &driver_attr_remove_slot);
-+ if (err < 0)
-+ goto out;
-+ err = driver_create_file(&pciback_pci_driver.driver, &driver_attr_slots);
-+ if (err < 0)
-+ goto out;
-+ err = driver_create_file(&pciback_pci_driver.driver, &driver_attr_quirks);
-+ if (err < 0)
-+ goto out;
-+ err = driver_create_file(&pciback_pci_driver.driver, &driver_attr_permissive);
++ &driver_attr_new_slot);
++ if (!err)
++ err = driver_create_file(&pciback_pci_driver.driver,
++ &driver_attr_remove_slot);
++ if (!err)
++ err = driver_create_file(&pciback_pci_driver.driver,
++ &driver_attr_slots);
++ if (!err)
++ err = driver_create_file(&pciback_pci_driver.driver,
++ &driver_attr_quirks);
++ if (!err)
++ err = driver_create_file(&pciback_pci_driver.driver,
++ &driver_attr_permissive);
++
++ if (err)
++ pcistub_exit();
+
+ out:
+ return err;
@@ -65131,32 +63145,221 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#endif
+
+ pcistub_init_devices_late();
-+ pciback_xenbus_register();
++ err = pciback_xenbus_register();
++ if (err)
++ pcistub_exit();
+
-+ return 0;
++ return err;
+}
+
+static void __exit pciback_cleanup(void)
+{
+ pciback_xenbus_unregister();
-+
-+ driver_remove_file(&pciback_pci_driver.driver, &driver_attr_new_slot);
-+ driver_remove_file(&pciback_pci_driver.driver,
-+ &driver_attr_remove_slot);
-+ driver_remove_file(&pciback_pci_driver.driver, &driver_attr_slots);
-+ driver_remove_file(&pciback_pci_driver.driver, &driver_attr_quirks);
-+ driver_remove_file(&pciback_pci_driver.driver, &driver_attr_permissive);
-+
-+ pci_unregister_driver(&pciback_pci_driver);
++ pcistub_exit();
+}
+
+module_init(pciback_init);
+module_exit(pciback_cleanup);
+
+MODULE_LICENSE("Dual BSD/GPL");
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/drivers/xen/pciback/slot.c source/drivers/xen/pciback/slot.c
---- /scratch/src/linux-2.6.20.3/drivers/xen/pciback/slot.c 1970-01-01 01:00:00.000000000 +0100
-+++ source/drivers/xen/pciback/slot.c 2007-03-20 21:26:49.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 drivers/xen/pciback/pciback.h
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/drivers/xen/pciback/pciback.h Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,93 @@
++/*
++ * PCI Backend Common Data Structures & Function Declarations
++ *
++ * Author: Ryan Wilson <hap9@epoch.ncsc.mil>
++ */
++#ifndef __XEN_PCIBACK_H__
++#define __XEN_PCIBACK_H__
++
++#include <linux/pci.h>
++#include <linux/interrupt.h>
++#include <xen/xenbus.h>
++#include <linux/list.h>
++#include <linux/spinlock.h>
++#include <linux/workqueue.h>
++#include <asm/atomic.h>
++#include <xen/interface/io/pciif.h>
++
++struct pci_dev_entry {
++ struct list_head list;
++ struct pci_dev *dev;
++};
++
++#define _PDEVF_op_active (0)
++#define PDEVF_op_active (1<<(_PDEVF_op_active))
++
++struct pciback_device {
++ void *pci_dev_data;
++ spinlock_t dev_lock;
++
++ struct xenbus_device *xdev;
++
++ struct xenbus_watch be_watch;
++ u8 be_watching;
++
++ int evtchn_irq;
++
++ struct vm_struct *sh_area;
++ struct xen_pci_sharedinfo *sh_info;
++
++ unsigned long flags;
++
++ struct delayed_work op_work;
++};
++
++struct pciback_dev_data {
++ struct list_head config_fields;
++ int permissive;
++ int warned_on_write;
++};
++
++/* Get/Put PCI Devices that are hidden from the PCI Backend Domain */
++struct pci_dev *pcistub_get_pci_dev_by_slot(struct pciback_device *pdev,
++ int domain, int bus,
++ int slot, int func);
++struct pci_dev *pcistub_get_pci_dev(struct pciback_device *pdev,
++ struct pci_dev *dev);
++void pcistub_put_pci_dev(struct pci_dev *dev);
++
++/* Ensure a device is turned off or reset */
++void pciback_reset_device(struct pci_dev *pdev);
++
++/* Access a virtual configuration space for a PCI device */
++int pciback_config_init(void);
++int pciback_config_init_dev(struct pci_dev *dev);
++void pciback_config_free_dyn_fields(struct pci_dev *dev);
++void pciback_config_reset_dev(struct pci_dev *dev);
++void pciback_config_free_dev(struct pci_dev *dev);
++int pciback_config_read(struct pci_dev *dev, int offset, int size,
++ u32 * ret_val);
++int pciback_config_write(struct pci_dev *dev, int offset, int size, u32 value);
++
++/* Handle requests for specific devices from the frontend */
++typedef int (*publish_pci_root_cb) (struct pciback_device * pdev,
++ unsigned int domain, unsigned int bus);
++int pciback_add_pci_dev(struct pciback_device *pdev, struct pci_dev *dev);
++void pciback_release_pci_dev(struct pciback_device *pdev, struct pci_dev *dev);
++struct pci_dev *pciback_get_pci_dev(struct pciback_device *pdev,
++ unsigned int domain, unsigned int bus,
++ unsigned int devfn);
++int pciback_init_devices(struct pciback_device *pdev);
++int pciback_publish_pci_roots(struct pciback_device *pdev,
++ publish_pci_root_cb cb);
++void pciback_release_devices(struct pciback_device *pdev);
++
++/* Handles events from front-end */
++irqreturn_t pciback_handle_event(int irq, void *dev_id);
++void pciback_do_op(struct work_struct *work);
++
++int pciback_xenbus_register(void);
++void pciback_xenbus_unregister(void);
++
++extern int verbose_request;
++#endif
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 drivers/xen/pciback/pciback_ops.c
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/drivers/xen/pciback/pciback_ops.c Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,94 @@
++/*
++ * PCI Backend Operations - respond to PCI requests from Frontend
++ *
++ * Author: Ryan Wilson <hap9@epoch.ncsc.mil>
++ */
++#include <linux/module.h>
++#include <asm/bitops.h>
++#include <xen/evtchn.h>
++#include "pciback.h"
++
++int verbose_request = 0;
++module_param(verbose_request, int, 0644);
++
++/* Ensure a device is "turned off" and ready to be exported.
++ * (Also see pciback_config_reset to ensure virtual configuration space is
++ * ready to be re-exported)
++ */
++void pciback_reset_device(struct pci_dev *dev)
++{
++ u16 cmd;
++
++ /* Disable devices (but not bridges) */
++ if (dev->hdr_type == PCI_HEADER_TYPE_NORMAL) {
++ pci_disable_device(dev);
++
++ pci_write_config_word(dev, PCI_COMMAND, 0);
++
++ dev->is_busmaster = 0;
++ } else {
++ pci_read_config_word(dev, PCI_COMMAND, &cmd);
++ if (cmd & (PCI_COMMAND_INVALIDATE)) {
++ cmd &= ~(PCI_COMMAND_INVALIDATE);
++ pci_write_config_word(dev, PCI_COMMAND, cmd);
++
++ dev->is_busmaster = 0;
++ }
++ }
++}
++
++static inline void test_and_schedule_op(struct pciback_device *pdev)
++{
++ /* Check that frontend is requesting an operation and that we are not
++ * already processing a request */
++ if (test_bit(_XEN_PCIF_active, (unsigned long *)&pdev->sh_info->flags)
++ && !test_and_set_bit(_PDEVF_op_active, &pdev->flags))
++ schedule_delayed_work(&pdev->op_work, 0);
++}
++
++/* Performing the configuration space reads/writes must not be done in atomic
++ * context because some of the pci_* functions can sleep (mostly due to ACPI
++ * use of semaphores). This function is intended to be called from a work
++ * queue in process context taking a struct pciback_device as a parameter */
++void pciback_do_op(struct work_struct *work)
++{
++ struct pciback_device *pdev = container_of(work, struct pciback_device, op_work.work);
++ struct pci_dev *dev;
++ struct xen_pci_op *op = &pdev->sh_info->op;
++
++ dev = pciback_get_pci_dev(pdev, op->domain, op->bus, op->devfn);
++
++ if (dev == NULL)
++ op->err = XEN_PCI_ERR_dev_not_found;
++ else if (op->cmd == XEN_PCI_OP_conf_read)
++ op->err = pciback_config_read(dev, op->offset, op->size,
++ &op->value);
++ else if (op->cmd == XEN_PCI_OP_conf_write)
++ op->err = pciback_config_write(dev, op->offset, op->size,
++ op->value);
++ else
++ op->err = XEN_PCI_ERR_not_implemented;
++
++ /* Tell the driver domain that we're done. */
++ wmb();
++ clear_bit(_XEN_PCIF_active, (unsigned long *)&pdev->sh_info->flags);
++ notify_remote_via_irq(pdev->evtchn_irq);
++
++ /* Mark that we're done. */
++ smp_mb__before_clear_bit(); /* /after/ clearing PCIF_active */
++ clear_bit(_PDEVF_op_active, &pdev->flags);
++ smp_mb__after_clear_bit(); /* /before/ final check for work */
++
++ /* Check to see if the driver domain tried to start another request in
++ * between clearing _XEN_PCIF_active and clearing _PDEVF_op_active. */
++ test_and_schedule_op(pdev);
++}
++
++irqreturn_t pciback_handle_event(int irq, void *dev_id)
++{
++ struct pciback_device *pdev = dev_id;
++
++ test_and_schedule_op(pdev);
++
++ return IRQ_HANDLED;
++}
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 drivers/xen/pciback/slot.c
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/drivers/xen/pciback/slot.c Wed Aug 08 16:25:28 2007 -0300
@@ -0,0 +1,151 @@
+/*
+ * PCI Backend - Provides a Virtual PCI bus (with real devices)
@@ -65309,9 +63512,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ kfree(slot_dev);
+ pdev->pci_dev_data = NULL;
+}
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/drivers/xen/pciback/vpci.c source/drivers/xen/pciback/vpci.c
---- /scratch/src/linux-2.6.20.3/drivers/xen/pciback/vpci.c 1970-01-01 01:00:00.000000000 +0100
-+++ source/drivers/xen/pciback/vpci.c 2007-03-20 21:26:49.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 drivers/xen/pciback/vpci.c
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/drivers/xen/pciback/vpci.c Wed Aug 08 16:25:28 2007 -0300
@@ -0,0 +1,204 @@
+/*
+ * PCI Backend - Provides a Virtual PCI bus (with real devices)
@@ -65517,10 +63720,10 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ kfree(vpci_dev);
+ pdev->pci_dev_data = NULL;
+}
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/drivers/xen/pciback/xenbus.c source/drivers/xen/pciback/xenbus.c
---- /scratch/src/linux-2.6.20.3/drivers/xen/pciback/xenbus.c 1970-01-01 01:00:00.000000000 +0100
-+++ source/drivers/xen/pciback/xenbus.c 2007-03-20 21:26:49.000000000 +0100
-@@ -0,0 +1,458 @@
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 drivers/xen/pciback/xenbus.c
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/drivers/xen/pciback/xenbus.c Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,454 @@
+/*
+ * PCI Backend Xenbus Setup - handles setup with frontend and xend
+ *
@@ -65594,7 +63797,6 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ int remote_evtchn)
+{
+ int err = 0;
-+ int evtchn;
+ struct vm_struct *area;
+
+ dev_dbg(&pdev->xdev->dev,
@@ -65609,12 +63811,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ pdev->sh_area = area;
+ pdev->sh_info = area->addr;
+
-+ err = xenbus_bind_evtchn(pdev->xdev, remote_evtchn, &evtchn);
-+ if (err)
-+ goto out;
-+
-+ err = bind_evtchn_to_irqhandler(evtchn, pciback_handle_event,
-+ SA_SAMPLE_RANDOM, "pciback", pdev);
++ err = bind_interdomain_evtchn_to_irqhandler(
++ pdev->xdev->otherend_id, remote_evtchn, pciback_handle_event,
++ SA_SAMPLE_RANDOM, "pciback", pdev);
+ if (err < 0) {
+ xenbus_dev_fatal(pdev->xdev, err,
+ "Error binding event channel to IRQ");
@@ -65979,9 +64178,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+{
+ xenbus_unregister_driver(&xenbus_pciback_driver);
+}
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/drivers/xen/pcifront/Makefile source/drivers/xen/pcifront/Makefile
---- /scratch/src/linux-2.6.20.3/drivers/xen/pcifront/Makefile 1970-01-01 01:00:00.000000000 +0100
-+++ source/drivers/xen/pcifront/Makefile 2007-03-20 21:26:49.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 drivers/xen/pcifront/Makefile
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/drivers/xen/pcifront/Makefile Wed Aug 08 16:25:28 2007 -0300
@@ -0,0 +1,7 @@
+obj-y += pcifront.o
+
@@ -65990,9 +64189,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ifeq ($(CONFIG_XEN_PCIDEV_FE_DEBUG),y)
+EXTRA_CFLAGS += -DDEBUG
+endif
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/drivers/xen/pcifront/pci.c source/drivers/xen/pcifront/pci.c
---- /scratch/src/linux-2.6.20.3/drivers/xen/pcifront/pci.c 1970-01-01 01:00:00.000000000 +0100
-+++ source/drivers/xen/pcifront/pci.c 2007-03-20 21:26:49.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 drivers/xen/pcifront/pci.c
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/drivers/xen/pcifront/pci.c Wed Aug 08 16:25:28 2007 -0300
@@ -0,0 +1,46 @@
+/*
+ * PCI Frontend Operations - ensure only one PCI frontend runs at a time
@@ -66040,54 +64239,10 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+
+ spin_unlock(&pcifront_dev_lock);
+}
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/drivers/xen/pcifront/pcifront.h source/drivers/xen/pcifront/pcifront.h
---- /scratch/src/linux-2.6.20.3/drivers/xen/pcifront/pcifront.h 1970-01-01 01:00:00.000000000 +0100
-+++ source/drivers/xen/pcifront/pcifront.h 2007-03-20 21:26:49.000000000 +0100
-@@ -0,0 +1,40 @@
-+/*
-+ * PCI Frontend - Common data structures & function declarations
-+ *
-+ * Author: Ryan Wilson <hap9@epoch.ncsc.mil>
-+ */
-+#ifndef __XEN_PCIFRONT_H__
-+#define __XEN_PCIFRONT_H__
-+
-+#include <linux/spinlock.h>
-+#include <linux/pci.h>
-+#include <xen/xenbus.h>
-+#include <xen/interface/io/pciif.h>
-+#include <xen/pcifront.h>
-+
-+struct pci_bus_entry {
-+ struct list_head list;
-+ struct pci_bus *bus;
-+};
-+
-+struct pcifront_device {
-+ struct xenbus_device *xdev;
-+ struct list_head root_buses;
-+ spinlock_t dev_lock;
-+
-+ int evtchn;
-+ int gnt_ref;
-+
-+ /* Lock this when doing any operations in sh_info */
-+ spinlock_t sh_info_lock;
-+ struct xen_pci_sharedinfo *sh_info;
-+};
-+
-+int pcifront_connect(struct pcifront_device *pdev);
-+void pcifront_disconnect(struct pcifront_device *pdev);
-+
-+int pcifront_scan_root(struct pcifront_device *pdev,
-+ unsigned int domain, unsigned int bus);
-+void pcifront_free_roots(struct pcifront_device *pdev);
-+
-+#endif /* __XEN_PCIFRONT_H__ */
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/drivers/xen/pcifront/pci_op.c source/drivers/xen/pcifront/pci_op.c
---- /scratch/src/linux-2.6.20.3/drivers/xen/pcifront/pci_op.c 1970-01-01 01:00:00.000000000 +0100
-+++ source/drivers/xen/pcifront/pci_op.c 2007-03-20 21:26:49.000000000 +0100
-@@ -0,0 +1,273 @@
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 drivers/xen/pcifront/pci_op.c
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/drivers/xen/pcifront/pci_op.c Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,268 @@
+/*
+ * PCI Frontend Operations - Communicates with frontend
+ *
@@ -66152,7 +64307,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ * timeout in the past). 1s difference gives plenty of slack for error.
+ */
+ do_gettimeofday(&tv);
-+ ns_timeout = timeval_to_ns(&tv) + 2 * NSEC_PER_SEC;
++ ns_timeout = timeval_to_ns(&tv) + 2 * (s64)NSEC_PER_SEC;
+
+ clear_evtchn(port);
+
@@ -66329,17 +64484,12 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+{
+ struct pci_dev *dev;
+
-+ down_write(&pci_bus_sem);
+ while (!list_empty(&bus->devices)) {
-+ dev = container_of(bus->devices.next, struct pci_dev, bus_list);
-+ up_write(&pci_bus_sem);
-+
++ dev = container_of(bus->devices.next, struct pci_dev,
++ bus_list);
+ dev_dbg(&dev->dev, "removing device\n");
+ pci_remove_bus_device(dev);
-+
-+ down_write(&pci_bus_sem);
+ }
-+ up_write(&pci_bus_sem);
+}
+
+void pcifront_free_roots(struct pcifront_device *pdev)
@@ -66361,9 +64511,53 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ kfree(bus_entry);
+ }
+}
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/drivers/xen/pcifront/xenbus.c source/drivers/xen/pcifront/xenbus.c
---- /scratch/src/linux-2.6.20.3/drivers/xen/pcifront/xenbus.c 1970-01-01 01:00:00.000000000 +0100
-+++ source/drivers/xen/pcifront/xenbus.c 2007-03-20 21:26:49.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 drivers/xen/pcifront/pcifront.h
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/drivers/xen/pcifront/pcifront.h Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,40 @@
++/*
++ * PCI Frontend - Common data structures & function declarations
++ *
++ * Author: Ryan Wilson <hap9@epoch.ncsc.mil>
++ */
++#ifndef __XEN_PCIFRONT_H__
++#define __XEN_PCIFRONT_H__
++
++#include <linux/spinlock.h>
++#include <linux/pci.h>
++#include <xen/xenbus.h>
++#include <xen/interface/io/pciif.h>
++#include <xen/pcifront.h>
++
++struct pci_bus_entry {
++ struct list_head list;
++ struct pci_bus *bus;
++};
++
++struct pcifront_device {
++ struct xenbus_device *xdev;
++ struct list_head root_buses;
++ spinlock_t dev_lock;
++
++ int evtchn;
++ int gnt_ref;
++
++ /* Lock this when doing any operations in sh_info */
++ spinlock_t sh_info_lock;
++ struct xen_pci_sharedinfo *sh_info;
++};
++
++int pcifront_connect(struct pcifront_device *pdev);
++void pcifront_disconnect(struct pcifront_device *pdev);
++
++int pcifront_scan_root(struct pcifront_device *pdev,
++ unsigned int domain, unsigned int bus);
++void pcifront_free_roots(struct pcifront_device *pdev);
++
++#endif /* __XEN_PCIFRONT_H__ */
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 drivers/xen/pcifront/xenbus.c
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/drivers/xen/pcifront/xenbus.c Wed Aug 08 16:25:28 2007 -0300
@@ -0,0 +1,295 @@
+/*
+ * PCI Frontend Xenbus Setup - handles setup with backend (imports page/evtchn)
@@ -66660,16 +64854,16 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+
+/* Initialize after the Xen PCI Frontend Stub is initialized */
+subsys_initcall(pcifront_init);
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/drivers/xen/privcmd/Makefile source/drivers/xen/privcmd/Makefile
---- /scratch/src/linux-2.6.20.3/drivers/xen/privcmd/Makefile 1970-01-01 01:00:00.000000000 +0100
-+++ source/drivers/xen/privcmd/Makefile 2007-03-20 21:26:49.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 drivers/xen/privcmd/Makefile
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/drivers/xen/privcmd/Makefile Wed Aug 08 16:25:28 2007 -0300
@@ -0,0 +1,2 @@
+
+obj-$(CONFIG_XEN_PRIVCMD) := privcmd.o
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/drivers/xen/privcmd/privcmd.c source/drivers/xen/privcmd/privcmd.c
---- /scratch/src/linux-2.6.20.3/drivers/xen/privcmd/privcmd.c 1970-01-01 01:00:00.000000000 +0100
-+++ source/drivers/xen/privcmd/privcmd.c 2007-03-20 21:26:49.000000000 +0100
-@@ -0,0 +1,285 @@
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 drivers/xen/privcmd/privcmd.c
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/drivers/xen/privcmd/privcmd.c Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,284 @@
+/******************************************************************************
+ * privcmd.c
+ *
@@ -66700,7 +64894,6 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#include <asm/hypervisor.h>
+#include <xen/public/privcmd.h>
+#include <xen/interface/xen.h>
-+#include <xen/interface/dom0_ops.h>
+#include <xen/xen_proc.h>
+
+static struct proc_dir_entry *privcmd_intf;
@@ -66920,7 +65113,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+}
+#endif
+
-+static struct file_operations privcmd_file_ops = {
++static const struct file_operations privcmd_file_ops = {
+ .ioctl = privcmd_ioctl,
+ .mmap = privcmd_mmap,
+};
@@ -66955,16 +65148,24 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+}
+
+__initcall(privcmd_init);
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/drivers/xen/tpmback/common.h source/drivers/xen/tpmback/common.h
---- /scratch/src/linux-2.6.20.3/drivers/xen/tpmback/common.h 1970-01-01 01:00:00.000000000 +0100
-+++ source/drivers/xen/tpmback/common.h 2007-03-20 21:26:49.000000000 +0100
-@@ -0,0 +1,86 @@
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 drivers/xen/tpmback/Makefile
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/drivers/xen/tpmback/Makefile Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,4 @@
++
++obj-$(CONFIG_XEN_TPMDEV_BACKEND) += tpmbk.o
++
++tpmbk-y += tpmback.o interface.o xenbus.o
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 drivers/xen/tpmback/common.h
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/drivers/xen/tpmback/common.h Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,85 @@
+/******************************************************************************
+ * drivers/xen/tpmback/common.h
+ */
+
-+#ifndef __NETIF__BACKEND__COMMON_H__
-+#define __NETIF__BACKEND__COMMON_H__
++#ifndef __TPM__BACKEND__COMMON_H__
++#define __TPM__BACKEND__COMMON_H__
+
+#include <linux/version.h>
+#include <linux/module.h>
@@ -66990,7 +65191,6 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ unsigned int handle;
+
+ /* Physical parameters of the comms window. */
-+ unsigned int evtchn;
+ unsigned int irq;
+
+ /* The shared rings and indexes. */
@@ -67045,10 +65245,10 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+}
+
+#endif /* __TPMIF__BACKEND__COMMON_H__ */
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/drivers/xen/tpmback/interface.c source/drivers/xen/tpmback/interface.c
---- /scratch/src/linux-2.6.20.3/drivers/xen/tpmback/interface.c 1970-01-01 01:00:00.000000000 +0100
-+++ source/drivers/xen/tpmback/interface.c 2007-03-20 21:26:49.000000000 +0100
-@@ -0,0 +1,182 @@
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 drivers/xen/tpmback/interface.c
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/drivers/xen/tpmback/interface.c Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,167 @@
+ /*****************************************************************************
+ * drivers/xen/tpmback/interface.c
+ *
@@ -67130,16 +65330,13 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+
+static int map_frontend_page(tpmif_t *tpmif, unsigned long shared_page)
+{
-+ int ret;
+ struct gnttab_map_grant_ref op;
+
+ gnttab_set_map_op(&op, (unsigned long)tpmif->tx_area->addr,
+ GNTMAP_host_map, shared_page, tpmif->domid);
+
-+ lock_vm_area(tpmif->tx_area);
-+ ret = HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &op, 1);
-+ unlock_vm_area(tpmif->tx_area);
-+ BUG_ON(ret);
++ if (HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &op, 1))
++ BUG();
+
+ if (op.status) {
+ DPRINTK(" Grant table operation failure !\n");
@@ -67155,25 +65352,20 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+static void unmap_frontend_page(tpmif_t *tpmif)
+{
+ struct gnttab_unmap_grant_ref op;
-+ int ret;
+
+ gnttab_set_unmap_op(&op, (unsigned long)tpmif->tx_area->addr,
+ GNTMAP_host_map, tpmif->shmem_handle);
+
-+ lock_vm_area(tpmif->tx_area);
-+ ret = HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1);
-+ unlock_vm_area(tpmif->tx_area);
-+ BUG_ON(ret);
++ if (HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1))
++ BUG();
+}
+
+int tpmif_map(tpmif_t *tpmif, unsigned long shared_page, unsigned int evtchn)
+{
+ int err;
-+ struct evtchn_bind_interdomain bind_interdomain;
+
-+ if (tpmif->irq) {
++ if (tpmif->irq)
+ return 0;
-+ }
+
+ if ((tpmif->tx_area = alloc_vm_area(PAGE_SIZE)) == NULL)
+ return -ENOMEM;
@@ -67184,24 +65376,17 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ return err;
+ }
+
++ tpmif->tx = (tpmif_tx_interface_t *)tpmif->tx_area->addr;
+
-+ bind_interdomain.remote_dom = tpmif->domid;
-+ bind_interdomain.remote_port = evtchn;
-+
-+ err = HYPERVISOR_event_channel_op(EVTCHNOP_bind_interdomain,
-+ &bind_interdomain);
-+ if (err) {
++ err = bind_interdomain_evtchn_to_irqhandler(
++ tpmif->domid, evtchn, tpmif_be_int, 0, tpmif->devname, tpmif);
++ if (err < 0) {
+ unmap_frontend_page(tpmif);
+ free_vm_area(tpmif->tx_area);
+ return err;
+ }
++ tpmif->irq = err;
+
-+ tpmif->evtchn = bind_interdomain.local_port;
-+
-+ tpmif->tx = (tpmif_tx_interface_t *)tpmif->tx_area->addr;
-+
-+ tpmif->irq = bind_evtchn_to_irqhandler(
-+ tpmif->evtchn, tpmif_be_int, 0, tpmif->devname, tpmif);
+ tpmif->shmem_ref = shared_page;
+ tpmif->active = 1;
+
@@ -67231,17 +65416,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+{
+ kmem_cache_destroy(tpmif_cachep);
+}
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/drivers/xen/tpmback/Makefile source/drivers/xen/tpmback/Makefile
---- /scratch/src/linux-2.6.20.3/drivers/xen/tpmback/Makefile 1970-01-01 01:00:00.000000000 +0100
-+++ source/drivers/xen/tpmback/Makefile 2007-03-20 21:26:49.000000000 +0100
-@@ -0,0 +1,4 @@
-+
-+obj-$(CONFIG_XEN_TPMDEV_BACKEND) += tpmbk.o
-+
-+tpmbk-y += tpmback.o interface.o xenbus.o
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/drivers/xen/tpmback/tpmback.c source/drivers/xen/tpmback/tpmback.c
---- /scratch/src/linux-2.6.20.3/drivers/xen/tpmback/tpmback.c 1970-01-01 01:00:00.000000000 +0100
-+++ source/drivers/xen/tpmback/tpmback.c 2007-03-20 21:26:49.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 drivers/xen/tpmback/tpmback.c
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/drivers/xen/tpmback/tpmback.c Wed Aug 08 16:25:28 2007 -0300
@@ -0,0 +1,944 @@
+/******************************************************************************
+ * drivers/xen/tpmback/tpmback.c
@@ -67874,7 +66051,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ return flags;
+}
+
-+static struct file_operations vtpm_ops = {
++static const struct file_operations vtpm_ops = {
+ .owner = THIS_MODULE,
+ .llseek = no_llseek,
+ .open = vtpm_op_open,
@@ -68187,9 +66364,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+}
+
+MODULE_LICENSE("Dual BSD/GPL");
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/drivers/xen/tpmback/xenbus.c source/drivers/xen/tpmback/xenbus.c
---- /scratch/src/linux-2.6.20.3/drivers/xen/tpmback/xenbus.c 1970-01-01 01:00:00.000000000 +0100
-+++ source/drivers/xen/tpmback/xenbus.c 2007-03-20 21:26:49.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 drivers/xen/tpmback/xenbus.c
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/drivers/xen/tpmback/xenbus.c Wed Aug 08 16:25:28 2007 -0300
@@ -0,0 +1,289 @@
+/* Xenbus code for tpmif backend
+ Copyright (C) 2005 IBM Corporation
@@ -68480,11 +66657,10 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+{
+ xenbus_unregister_driver(&tpmback);
+}
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/drivers/xen/util.c source/drivers/xen/util.c
---- /scratch/src/linux-2.6.20.3/drivers/xen/util.c 1970-01-01 01:00:00.000000000 +0100
-+++ source/drivers/xen/util.c 2007-03-20 21:26:49.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 drivers/xen/util.c
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/drivers/xen/util.c Wed Aug 08 16:25:28 2007 -0300
@@ -0,0 +1,70 @@
-+
+#include <linux/mm.h>
+#include <linux/module.h>
+#include <linux/slab.h>
@@ -68492,6 +66668,26 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#include <asm/uaccess.h>
+#include <xen/driver_util.h>
+
++struct class *get_xen_class(void)
++{
++ static struct class *xen_class;
++
++ if (xen_class)
++ return xen_class;
++
++ xen_class = class_create(THIS_MODULE, "xen");
++ if (IS_ERR(xen_class)) {
++ printk("Failed to create xen sysfs class.\n");
++ xen_class = NULL;
++ }
++
++ return xen_class;
++}
++EXPORT_SYMBOL_GPL(get_xen_class);
++
++/* Todo: merge ia64 ('auto-translate physmap') versions of these functions. */
++#ifndef __ia64__
++
+static int f(pte_t *pte, struct page *pmd_page, unsigned long addr, void *data)
+{
+ /* apply_to_page_range() does all the hard work. */
@@ -68516,6 +66712,11 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ return NULL;
+ }
+
++ /* Map page directories into every address space. */
++#ifdef CONFIG_X86
++ vmalloc_sync_all();
++#endif
++
+ return area;
+}
+EXPORT_SYMBOL_GPL(alloc_vm_area);
@@ -68529,34 +66730,10 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+}
+EXPORT_SYMBOL_GPL(free_vm_area);
+
-+void lock_vm_area(struct vm_struct *area)
-+{
-+ unsigned long i;
-+ char c;
-+
-+ /*
-+ * Prevent context switch to a lazy mm that doesn't have this area
-+ * mapped into its page tables.
-+ */
-+ preempt_disable();
-+
-+ /*
-+ * Ensure that the page tables are mapped into the current mm. The
-+ * page-fault path will copy the page directory pointers from init_mm.
-+ */
-+ for (i = 0; i < area->size; i += PAGE_SIZE)
-+ (void)__get_user(c, (char __user *)area->addr + i);
-+}
-+EXPORT_SYMBOL_GPL(lock_vm_area);
-+
-+void unlock_vm_area(struct vm_struct *area)
-+{
-+ preempt_enable();
-+}
-+EXPORT_SYMBOL_GPL(unlock_vm_area);
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/drivers/xen/xenbus/Makefile source/drivers/xen/xenbus/Makefile
---- /scratch/src/linux-2.6.20.3/drivers/xen/xenbus/Makefile 1970-01-01 01:00:00.000000000 +0100
-+++ source/drivers/xen/xenbus/Makefile 2007-03-20 21:26:49.000000000 +0100
++#endif /* !__ia64__ */
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 drivers/xen/xenbus/Makefile
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/drivers/xen/xenbus/Makefile Wed Aug 08 16:25:28 2007 -0300
@@ -0,0 +1,9 @@
+obj-y += xenbus_client.o xenbus_comms.o xenbus_xs.o xenbus_probe.o
+obj-$(CONFIG_XEN_BACKEND) += xenbus_be.o
@@ -68567,9 +66744,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+xenbus-$(CONFIG_XEN_BACKEND) += xenbus_probe_backend.o
+obj-y += $(xenbus-y) $(xenbus-m)
+obj-$(CONFIG_XEN_XENBUS_DEV) += xenbus_dev.o
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/drivers/xen/xenbus/xenbus_backend_client.c source/drivers/xen/xenbus/xenbus_backend_client.c
---- /scratch/src/linux-2.6.20.3/drivers/xen/xenbus/xenbus_backend_client.c 1970-01-01 01:00:00.000000000 +0100
-+++ source/drivers/xen/xenbus/xenbus_backend_client.c 2007-03-20 21:26:49.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 drivers/xen/xenbus/xenbus_backend_client.c
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/drivers/xen/xenbus/xenbus_backend_client.c Wed Aug 08 16:25:28 2007 -0300
@@ -0,0 +1,147 @@
+/******************************************************************************
+ * Backend-client-facing interface for the Xenbus driver. In other words, the
@@ -68621,9 +66798,8 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ gnttab_set_map_op(&op, (unsigned long)area->addr, GNTMAP_host_map,
+ gnt_ref, dev->otherend_id);
+
-+ lock_vm_area(area);
-+ BUG_ON(HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &op, 1));
-+ unlock_vm_area(area);
++ if (HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &op, 1))
++ BUG();
+
+ if (op.status != GNTST_okay) {
+ free_vm_area(area);
@@ -68649,7 +66825,8 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+
+ gnttab_set_map_op(&op, (unsigned long)vaddr, GNTMAP_host_map,
+ gnt_ref, dev->otherend_id);
-+ BUG_ON(HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &op, 1));
++ if (HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &op, 1))
++ BUG();
+
+ if (op.status != GNTST_okay) {
+ xenbus_dev_fatal(dev, op.status,
@@ -68671,9 +66848,8 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ gnttab_set_unmap_op(&op, (unsigned long)area->addr, GNTMAP_host_map,
+ (grant_handle_t)area->phys_addr);
+
-+ lock_vm_area(area);
-+ BUG_ON(HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1));
-+ unlock_vm_area(area);
++ if (HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1))
++ BUG();
+
+ if (op.status == GNTST_okay)
+ free_vm_area(area);
@@ -68694,7 +66870,8 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+
+ gnttab_set_unmap_op(&op, (unsigned long)vaddr, GNTMAP_host_map,
+ handle);
-+ BUG_ON(HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1));
++ if (HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1))
++ BUG();
+
+ if (op.status != GNTST_okay)
+ xenbus_dev_error(dev, op.status,
@@ -68718,10 +66895,10 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+EXPORT_SYMBOL_GPL(xenbus_dev_is_online);
+
+MODULE_LICENSE("Dual BSD/GPL");
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/drivers/xen/xenbus/xenbus_client.c source/drivers/xen/xenbus/xenbus_client.c
---- /scratch/src/linux-2.6.20.3/drivers/xen/xenbus/xenbus_client.c 1970-01-01 01:00:00.000000000 +0100
-+++ source/drivers/xen/xenbus/xenbus_client.c 2007-03-20 21:26:49.000000000 +0100
-@@ -0,0 +1,305 @@
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 drivers/xen/xenbus/xenbus_client.c
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/drivers/xen/xenbus/xenbus_client.c Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,283 @@
+/******************************************************************************
+ * Client-facing interface for the Xenbus driver. In other words, the
+ * interface between the Xenbus and the device-specific code, be it the
@@ -68766,9 +66943,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#define DPRINTK(fmt, args...) \
+ pr_debug("xenbus_client (%s:%d) " fmt ".\n", __FUNCTION__, __LINE__, ##args)
+
-+char *xenbus_strstate(enum xenbus_state state)
++const char *xenbus_strstate(enum xenbus_state state)
+{
-+ static char *name[] = {
++ static const char *const name[] = {
+ [ XenbusStateUnknown ] = "Unknown",
+ [ XenbusStateInitialising ] = "Initialising",
+ [ XenbusStateInitWait ] = "InitWait",
@@ -68979,28 +67156,6 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+EXPORT_SYMBOL_GPL(xenbus_alloc_evtchn);
+
+
-+int xenbus_bind_evtchn(struct xenbus_device *dev, int remote_port, int *port)
-+{
-+ struct evtchn_bind_interdomain bind_interdomain;
-+ int err;
-+
-+ bind_interdomain.remote_dom = dev->otherend_id;
-+ bind_interdomain.remote_port = remote_port,
-+
-+ err = HYPERVISOR_event_channel_op(EVTCHNOP_bind_interdomain,
-+ &bind_interdomain);
-+ if (err)
-+ xenbus_dev_fatal(dev, err,
-+ "binding to event channel %d from domain %d",
-+ remote_port, dev->otherend_id);
-+ else
-+ *port = bind_interdomain.local_port;
-+
-+ return err;
-+}
-+EXPORT_SYMBOL_GPL(xenbus_bind_evtchn);
-+
-+
+int xenbus_free_evtchn(struct xenbus_device *dev, int port)
+{
+ struct evtchn_close close;
@@ -69027,10 +67182,10 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ return result;
+}
+EXPORT_SYMBOL_GPL(xenbus_read_driver_state);
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/drivers/xen/xenbus/xenbus_comms.c source/drivers/xen/xenbus/xenbus_comms.c
---- /scratch/src/linux-2.6.20.3/drivers/xen/xenbus/xenbus_comms.c 1970-01-01 01:00:00.000000000 +0100
-+++ source/drivers/xen/xenbus/xenbus_comms.c 2007-03-20 21:26:49.000000000 +0100
-@@ -0,0 +1,210 @@
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 drivers/xen/xenbus/xenbus_comms.c
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/drivers/xen/xenbus/xenbus_comms.c Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,232 @@
+/******************************************************************************
+ * xenbus_comms.c
+ *
@@ -69143,7 +67298,6 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ /* Read indexes, then verify. */
+ cons = intf->req_cons;
+ prod = intf->req_prod;
-+ mb();
+ if (!check_indexes(cons, prod)) {
+ intf->req_cons = intf->req_prod = 0;
+ return -EIO;
@@ -69155,21 +67309,35 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ if (avail > len)
+ avail = len;
+
++ /* Must write data /after/ reading the consumer index. */
++ mb();
++
+ memcpy(dst, data, avail);
+ data += avail;
+ len -= avail;
+
-+ /* Other side must not see new header until data is there. */
++ /* Other side must not see new producer until data is there. */
+ wmb();
+ intf->req_prod += avail;
+
-+ /* This implies mb() before other side sees interrupt. */
++ /* Implies mb(): other side will see the updated producer. */
+ notify_remote_via_evtchn(xen_store_evtchn);
+ }
+
+ return 0;
+}
+
++int xb_data_to_read(void)
++{
++ struct xenstore_domain_interface *intf = xen_store_interface;
++ return (intf->rsp_cons != intf->rsp_prod);
++}
++
++int xb_wait_for_data_to_read(void)
++{
++ return wait_event_interruptible(xb_waitq, xb_data_to_read());
++}
++
+int xb_read(void *data, unsigned len)
+{
+ struct xenstore_domain_interface *intf = xen_store_interface;
@@ -69180,16 +67348,13 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ unsigned int avail;
+ const char *src;
+
-+ rc = wait_event_interruptible(
-+ xb_waitq,
-+ intf->rsp_cons != intf->rsp_prod);
++ rc = xb_wait_for_data_to_read();
+ if (rc < 0)
+ return rc;
+
+ /* Read indexes, then verify. */
+ cons = intf->rsp_cons;
+ prod = intf->rsp_prod;
-+ mb();
+ if (!check_indexes(cons, prod)) {
+ intf->rsp_cons = intf->rsp_prod = 0;
+ return -EIO;
@@ -69201,7 +67366,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ if (avail > len)
+ avail = len;
+
-+ /* We must read header before we read data. */
++ /* Must read data /after/ reading the producer index. */
+ rmb();
+
+ memcpy(data, src, avail);
@@ -69214,7 +67379,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+
+ pr_debug("Finished read of %i bytes (%i to go)\n", avail, len);
+
-+ /* Implies mb(): they will see new header. */
++ /* Implies mb(): other side will see the updated consumer. */
+ notify_remote_via_evtchn(xen_store_evtchn);
+ }
+
@@ -69224,12 +67389,24 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+/* Set up interrupt handler off store event channel. */
+int xb_init_comms(void)
+{
++ struct xenstore_domain_interface *intf = xen_store_interface;
+ int err;
+
++ if (intf->req_prod != intf->req_cons)
++ printk(KERN_ERR "XENBUS request ring is not quiescent "
++ "(%08x:%08x)!\n", intf->req_cons, intf->req_prod);
++
++ if (intf->rsp_prod != intf->rsp_cons) {
++ printk(KERN_WARNING "XENBUS response ring is not quiescent "
++ "(%08x:%08x): fixing up\n",
++ intf->rsp_cons, intf->rsp_prod);
++ intf->rsp_cons = intf->rsp_prod;
++ }
++
+ if (xenbus_irq)
+ unbind_from_irqhandler(xenbus_irq, &xb_waitq);
+
-+ err = bind_evtchn_to_irqhandler(
++ err = bind_caller_port_to_irqhandler(
+ xen_store_evtchn, wake_waiting,
+ 0, "xenbus", &xb_waitq);
+ if (err <= 0) {
@@ -69241,10 +67418,10 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+
+ return 0;
+}
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/drivers/xen/xenbus/xenbus_comms.h source/drivers/xen/xenbus/xenbus_comms.h
---- /scratch/src/linux-2.6.20.3/drivers/xen/xenbus/xenbus_comms.h 1970-01-01 01:00:00.000000000 +0100
-+++ source/drivers/xen/xenbus/xenbus_comms.h 2007-03-20 21:26:49.000000000 +0100
-@@ -0,0 +1,44 @@
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 drivers/xen/xenbus/xenbus_comms.h
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/drivers/xen/xenbus/xenbus_comms.h Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,46 @@
+/*
+ * Private include for xenbus communications.
+ *
@@ -69284,15 +67461,17 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+/* Low level routines. */
+int xb_write(const void *data, unsigned len);
+int xb_read(void *data, unsigned len);
++int xb_data_to_read(void);
++int xb_wait_for_data_to_read(void);
+int xs_input_avail(void);
+extern struct xenstore_domain_interface *xen_store_interface;
+extern int xen_store_evtchn;
+
+#endif /* _XENBUS_COMMS_H */
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/drivers/xen/xenbus/xenbus_dev.c source/drivers/xen/xenbus/xenbus_dev.c
---- /scratch/src/linux-2.6.20.3/drivers/xen/xenbus/xenbus_dev.c 1970-01-01 01:00:00.000000000 +0100
-+++ source/drivers/xen/xenbus/xenbus_dev.c 2007-03-20 21:26:49.000000000 +0100
-@@ -0,0 +1,361 @@
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 drivers/xen/xenbus/xenbus_dev.c
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/drivers/xen/xenbus/xenbus_dev.c Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,404 @@
+/*
+ * xenbus_dev.c
+ *
@@ -69353,6 +67532,13 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ struct xenbus_transaction handle;
+};
+
++struct read_buffer {
++ struct list_head list;
++ unsigned int cons;
++ unsigned int len;
++ char msg[];
++};
++
+struct xenbus_dev_data {
+ /* In-progress transaction. */
+ struct list_head transactions;
@@ -69368,9 +67554,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ } u;
+
+ /* Response queue. */
-+#define MASK_READ_IDX(idx) ((idx)&(PAGE_SIZE-1))
-+ char read_buffer[PAGE_SIZE];
-+ unsigned int read_cons, read_prod;
++ struct list_head read_buffers;
+ wait_queue_head_t read_waitq;
+
+ struct mutex reply_mutex;
@@ -69383,18 +67567,34 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ size_t len, loff_t *ppos)
+{
+ struct xenbus_dev_data *u = filp->private_data;
-+ int i;
++ struct read_buffer *rb;
++ int i, ret;
+
-+ if (wait_event_interruptible(u->read_waitq,
-+ u->read_prod != u->read_cons))
-+ return -EINTR;
++ mutex_lock(&u->reply_mutex);
++ while (list_empty(&u->read_buffers)) {
++ mutex_unlock(&u->reply_mutex);
++ ret = wait_event_interruptible(u->read_waitq,
++ !list_empty(&u->read_buffers));
++ if (ret)
++ return ret;
++ mutex_lock(&u->reply_mutex);
++ }
+
-+ for (i = 0; i < len; i++) {
-+ if (u->read_cons == u->read_prod)
-+ break;
-+ put_user(u->read_buffer[MASK_READ_IDX(u->read_cons)], ubuf+i);
-+ u->read_cons++;
++ rb = list_entry(u->read_buffers.next, struct read_buffer, list);
++ for (i = 0; i < len;) {
++ put_user(rb->msg[rb->cons], ubuf + i);
++ i++;
++ rb->cons++;
++ if (rb->cons == rb->len) {
++ list_del(&rb->list);
++ kfree(rb);
++ if (list_empty(&u->read_buffers))
++ break;
++ rb = list_entry(u->read_buffers.next,
++ struct read_buffer, list);
++ }
+ }
++ mutex_unlock(&u->reply_mutex);
+
+ return i;
+}
@@ -69402,16 +67602,20 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+static void queue_reply(struct xenbus_dev_data *u,
+ char *data, unsigned int len)
+{
-+ int i;
++ struct read_buffer *rb;
+
-+ mutex_lock(&u->reply_mutex);
++ if (len == 0)
++ return;
+
-+ for (i = 0; i < len; i++, u->read_prod++)
-+ u->read_buffer[MASK_READ_IDX(u->read_prod)] = data[i];
++ rb = kmalloc(sizeof(*rb) + len, GFP_KERNEL);
++ BUG_ON(rb == NULL);
+
-+ BUG_ON((u->read_prod - u->read_cons) > sizeof(u->read_buffer));
++ rb->cons = 0;
++ rb->len = len;
+
-+ mutex_unlock(&u->reply_mutex);
++ memcpy(rb->msg, data, len);
++
++ list_add_tail(&rb->list, &u->read_buffers);
+
+ wake_up(&u->read_waitq);
+}
@@ -69450,10 +67654,12 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+
+ hdr.type = XS_WATCH_EVENT;
+ hdr.len = body_len;
-+
++
++ mutex_lock(&adap->dev_data->reply_mutex);
+ queue_reply(adap->dev_data, (char *)&hdr, sizeof(hdr));
+ queue_reply(adap->dev_data, (char *)path, path_len);
+ queue_reply(adap->dev_data, (char *)token, tok_len);
++ mutex_unlock(&adap->dev_data->reply_mutex);
+}
+
+static LIST_HEAD(watch_list);
@@ -69468,17 +67674,22 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ void *reply;
+ char *path, *token;
+ struct watch_adapter *watch, *tmp_watch;
-+ int err;
++ int err, rc = len;
+
-+ if ((len + u->len) > sizeof(u->u.buffer))
-+ return -EINVAL;
++ if ((len + u->len) > sizeof(u->u.buffer)) {
++ rc = -EINVAL;
++ goto out;
++ }
+
-+ if (copy_from_user(u->u.buffer + u->len, ubuf, len) != 0)
-+ return -EFAULT;
++ if (copy_from_user(u->u.buffer + u->len, ubuf, len) != 0) {
++ rc = -EFAULT;
++ goto out;
++ }
+
+ u->len += len;
-+ if (u->len < (sizeof(u->u.msg) + u->u.msg.len))
-+ return len;
++ if ((u->len < sizeof(u->u.msg)) ||
++ (u->len < (sizeof(u->u.msg) + u->u.msg.len)))
++ return rc;
+
+ msg_type = u->u.msg.type;
+
@@ -69496,14 +67707,17 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ case XS_SET_PERMS:
+ if (msg_type == XS_TRANSACTION_START) {
+ trans = kmalloc(sizeof(*trans), GFP_KERNEL);
-+ if (!trans)
-+ return -ENOMEM;
++ if (!trans) {
++ rc = -ENOMEM;
++ goto out;
++ }
+ }
+
+ reply = xenbus_dev_request_and_reply(&u->u.msg);
+ if (IS_ERR(reply)) {
+ kfree(trans);
-+ return PTR_ERR(reply);
++ rc = PTR_ERR(reply);
++ goto out;
+ }
+
+ if (msg_type == XS_TRANSACTION_START) {
@@ -69517,23 +67731,27 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ list_del(&trans->list);
+ kfree(trans);
+ }
++ mutex_lock(&u->reply_mutex);
+ queue_reply(u, (char *)&u->u.msg, sizeof(u->u.msg));
+ queue_reply(u, (char *)reply, u->u.msg.len);
++ mutex_unlock(&u->reply_mutex);
+ kfree(reply);
+ break;
+
+ case XS_WATCH:
-+ case XS_UNWATCH:
++ case XS_UNWATCH: {
++ static const char *XS_RESP = "OK";
++ struct xsd_sockmsg hdr;
++
+ path = u->u.buffer + sizeof(u->u.msg);
+ token = memchr(path, 0, u->u.msg.len);
-+ if (token == NULL)
-+ return -EILSEQ;
++ if (token == NULL) {
++ rc = -EILSEQ;
++ goto out;
++ }
+ token++;
+
+ if (msg_type == XS_WATCH) {
-+ static const char * XS_WATCH_RESP = "OK";
-+ struct xsd_sockmsg hdr;
-+
+ watch = kmalloc(sizeof(*watch), GFP_KERNEL);
+ watch->watch.node = kmalloc(strlen(path)+1,
+ GFP_KERNEL);
@@ -69546,21 +67764,16 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ err = register_xenbus_watch(&watch->watch);
+ if (err) {
+ free_watch_adapter(watch);
-+ return err;
++ rc = err;
++ goto out;
+ }
+
+ list_add(&watch->list, &u->watches);
-+
-+ hdr.type = XS_WATCH;
-+ hdr.len = strlen(XS_WATCH_RESP) + 1;
-+ queue_reply(u, (char *)&hdr, sizeof(hdr));
-+ queue_reply(u, (char *)XS_WATCH_RESP, hdr.len);
+ } else {
+ list_for_each_entry_safe(watch, tmp_watch,
+ &u->watches, list) {
+ if (!strcmp(watch->token, token) &&
+ !strcmp(watch->watch.node, path))
-+ break;
+ {
+ unregister_xenbus_watch(&watch->watch);
+ list_del(&watch->list);
@@ -69570,14 +67783,23 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ }
+ }
+
++ hdr.type = msg_type;
++ hdr.len = strlen(XS_RESP) + 1;
++ mutex_lock(&u->reply_mutex);
++ queue_reply(u, (char *)&hdr, sizeof(hdr));
++ queue_reply(u, (char *)XS_RESP, hdr.len);
++ mutex_unlock(&u->reply_mutex);
+ break;
++ }
+
+ default:
-+ return -EINVAL;
++ rc = -EINVAL;
++ break;
+ }
+
++ out:
+ u->len = 0;
-+ return len;
++ return rc;
+}
+
+static int xenbus_dev_open(struct inode *inode, struct file *filp)
@@ -69595,6 +67817,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+
+ INIT_LIST_HEAD(&u->transactions);
+ INIT_LIST_HEAD(&u->watches);
++ INIT_LIST_HEAD(&u->read_buffers);
+ init_waitqueue_head(&u->read_waitq);
+
+ mutex_init(&u->reply_mutex);
@@ -69632,12 +67855,12 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ struct xenbus_dev_data *u = file->private_data;
+
+ poll_wait(file, &u->read_waitq, wait);
-+ if (u->read_cons != u->read_prod)
++ if (!list_empty(&u->read_buffers))
+ return POLLIN | POLLRDNORM;
+ return 0;
+}
+
-+static struct file_operations xenbus_dev_file_ops = {
++static const struct file_operations xenbus_dev_file_ops = {
+ .read = xenbus_dev_read,
+ .write = xenbus_dev_write,
+ .open = xenbus_dev_open,
@@ -69645,8 +67868,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ .poll = xenbus_dev_poll,
+};
+
-+int __init
-+xenbus_dev_init(void)
++int xenbus_dev_init(void)
+{
+ xenbus_dev_intf = create_xen_proc_entry("xenbus", 0400);
+ if (xenbus_dev_intf)
@@ -69654,285 +67876,10 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+
+ return 0;
+}
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/drivers/xen/xenbus/xenbus_probe_backend.c source/drivers/xen/xenbus/xenbus_probe_backend.c
---- /scratch/src/linux-2.6.20.3/drivers/xen/xenbus/xenbus_probe_backend.c 1970-01-01 01:00:00.000000000 +0100
-+++ source/drivers/xen/xenbus/xenbus_probe_backend.c 2007-03-20 21:26:49.000000000 +0100
-@@ -0,0 +1,271 @@
-+/******************************************************************************
-+ * Talks to Xen Store to figure out what devices we have (backend half).
-+ *
-+ * Copyright (C) 2005 Rusty Russell, IBM Corporation
-+ * Copyright (C) 2005 Mike Wray, Hewlett-Packard
-+ * Copyright (C) 2005, 2006 XenSource Ltd
-+ *
-+ * 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; or, when distributed
-+ * separately from the Linux kernel or incorporated into other
-+ * software packages, subject to the following license:
-+ *
-+ * Permission is hereby granted, free of charge, to any person obtaining a copy
-+ * of this source file (the "Software"), to deal in the Software without
-+ * restriction, including without limitation the rights to use, copy, modify,
-+ * merge, publish, distribute, sublicense, and/or sell copies of the Software,
-+ * and to permit persons to whom the Software is furnished to do so, subject to
-+ * the following conditions:
-+ *
-+ * The above copyright notice and this permission notice shall be included in
-+ * all copies or substantial portions of the Software.
-+ *
-+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-+ * IN THE SOFTWARE.
-+ */
-+
-+#define DPRINTK(fmt, args...) \
-+ pr_debug("xenbus_probe (%s:%d) " fmt ".\n", \
-+ __FUNCTION__, __LINE__, ##args)
-+
-+#include <linux/kernel.h>
-+#include <linux/err.h>
-+#include <linux/string.h>
-+#include <linux/ctype.h>
-+#include <linux/fcntl.h>
-+#include <linux/mm.h>
-+#include <linux/notifier.h>
-+#include <linux/kthread.h>
-+
-+#include <asm/io.h>
-+#include <asm/page.h>
-+#include <asm/maddr.h>
-+#include <asm/pgtable.h>
-+#include <asm/hypervisor.h>
-+#include <xen/xenbus.h>
-+#include <xen/xen_proc.h>
-+#include <xen/evtchn.h>
-+#include <xen/features.h>
-+#include <xen/hvm.h>
-+
-+#include "xenbus_comms.h"
-+#include "xenbus_probe.h"
-+
-+#ifdef HAVE_XEN_PLATFORM_COMPAT_H
-+#include <xen/platform-compat.h>
-+#endif
-+
-+static int xenbus_uevent_backend(struct device *dev, char **envp,
-+ int num_envp, char *buffer, int buffer_size);
-+static int xenbus_probe_backend(const char *type, const char *domid);
-+
-+extern int read_otherend_details(struct xenbus_device *xendev,
-+ char *id_node, char *path_node);
-+
-+static int read_frontend_details(struct xenbus_device *xendev)
-+{
-+ return read_otherend_details(xendev, "frontend-id", "frontend");
-+}
-+
-+/* backend/<type>/<fe-uuid>/<id> => <type>-<fe-domid>-<id> */
-+static int backend_bus_id(char bus_id[BUS_ID_SIZE], const char *nodename)
-+{
-+ int domid, err;
-+ const char *devid, *type, *frontend;
-+ unsigned int typelen;
-+
-+ type = strchr(nodename, '/');
-+ if (!type)
-+ return -EINVAL;
-+ type++;
-+ typelen = strcspn(type, "/");
-+ if (!typelen || type[typelen] != '/')
-+ return -EINVAL;
-+
-+ devid = strrchr(nodename, '/') + 1;
-+
-+ err = xenbus_gather(XBT_NIL, nodename, "frontend-id", "%i", &domid,
-+ "frontend", NULL, &frontend,
-+ NULL);
-+ if (err)
-+ return err;
-+ if (strlen(frontend) == 0)
-+ err = -ERANGE;
-+ if (!err && !xenbus_exists(XBT_NIL, frontend, ""))
-+ err = -ENOENT;
-+ kfree(frontend);
-+
-+ if (err)
-+ return err;
-+
-+ if (snprintf(bus_id, BUS_ID_SIZE,
-+ "%.*s-%i-%s", typelen, type, domid, devid) >= BUS_ID_SIZE)
-+ return -ENOSPC;
-+ return 0;
-+}
-+
-+static struct xen_bus_type xenbus_backend = {
-+ .root = "backend",
-+ .levels = 3, /* backend/type/<frontend>/<id> */
-+ .get_bus_id = backend_bus_id,
-+ .probe = xenbus_probe_backend,
-+ .bus = {
-+ .name = "xen-backend",
-+ .match = xenbus_match,
-+ .probe = xenbus_dev_probe,
-+ .remove = xenbus_dev_remove,
-+// .shutdown = xenbus_dev_shutdown,
-+ .uevent = xenbus_uevent_backend,
-+ },
-+ .dev = {
-+ .bus_id = "xen-backend",
-+ },
-+};
-+
-+static int xenbus_uevent_backend(struct device *dev, char **envp,
-+ int num_envp, char *buffer, int buffer_size)
-+{
-+ struct xenbus_device *xdev;
-+ struct xenbus_driver *drv;
-+ int i = 0;
-+ int length = 0;
-+
-+ DPRINTK("");
-+
-+ if (dev == NULL)
-+ return -ENODEV;
-+
-+ xdev = to_xenbus_device(dev);
-+ if (xdev == NULL)
-+ return -ENODEV;
-+
-+ /* stuff we want to pass to /sbin/hotplug */
-+ add_uevent_var(envp, num_envp, &i, buffer, buffer_size, &length,
-+ "XENBUS_TYPE=%s", xdev->devicetype);
-+
-+ add_uevent_var(envp, num_envp, &i, buffer, buffer_size, &length,
-+ "XENBUS_PATH=%s", xdev->nodename);
-+
-+ add_uevent_var(envp, num_envp, &i, buffer, buffer_size, &length,
-+ "XENBUS_BASE_PATH=%s", xenbus_backend.root);
-+
-+ /* terminate, set to next free slot, shrink available space */
-+ envp[i] = NULL;
-+ envp = &envp[i];
-+ num_envp -= i;
-+ buffer = &buffer[length];
-+ buffer_size -= length;
-+
-+ if (dev->driver) {
-+ drv = to_xenbus_driver(dev->driver);
-+ if (drv && drv->uevent)
-+ return drv->uevent(xdev, envp, num_envp, buffer,
-+ buffer_size);
-+ }
-+
-+ return 0;
-+}
-+
-+int xenbus_register_backend(struct xenbus_driver *drv)
-+{
-+ drv->read_otherend_details = read_frontend_details;
-+
-+ return xenbus_register_driver_common(drv, &xenbus_backend);
-+}
-+EXPORT_SYMBOL_GPL(xenbus_register_backend);
-+
-+/* backend/<typename>/<frontend-uuid>/<name> */
-+static int xenbus_probe_backend_unit(const char *dir,
-+ const char *type,
-+ const char *name)
-+{
-+ char *nodename;
-+ int err;
-+
-+ nodename = kasprintf(GFP_KERNEL, "%s/%s", dir, name);
-+ if (!nodename)
-+ return -ENOMEM;
-+
-+ DPRINTK("%s\n", nodename);
-+
-+ err = xenbus_probe_node(&xenbus_backend, type, nodename);
-+ kfree(nodename);
-+ return err;
-+}
-+
-+/* backend/<typename>/<frontend-domid> */
-+static int xenbus_probe_backend(const char *type, const char *domid)
-+{
-+ char *nodename;
-+ int err = 0;
-+ char **dir;
-+ unsigned int i, dir_n = 0;
-+
-+ DPRINTK("");
-+
-+ nodename = kasprintf(GFP_KERNEL, "%s/%s/%s", xenbus_backend.root, type, domid);
-+ if (!nodename)
-+ return -ENOMEM;
-+
-+ dir = xenbus_directory(XBT_NIL, nodename, "", &dir_n);
-+ if (IS_ERR(dir)) {
-+ kfree(nodename);
-+ return PTR_ERR(dir);
-+ }
-+
-+ for (i = 0; i < dir_n; i++) {
-+ err = xenbus_probe_backend_unit(nodename, type, dir[i]);
-+ if (err)
-+ break;
-+ }
-+ kfree(dir);
-+ kfree(nodename);
-+ return err;
-+}
-+
-+static void backend_changed(struct xenbus_watch *watch,
-+ const char **vec, unsigned int len)
-+{
-+ DPRINTK("");
-+
-+ dev_changed(vec[XS_WATCH_PATH], &xenbus_backend);
-+}
-+
-+static struct xenbus_watch be_watch = {
-+ .node = "backend",
-+ .callback = backend_changed,
-+};
-+
-+void xenbus_backend_suspend(int (*fn)(struct device *, void *))
-+{
-+ DPRINTK("");
-+ bus_for_each_dev(&xenbus_backend.bus, NULL, NULL, fn);
-+}
-+
-+void xenbus_backend_resume(int (*fn)(struct device *, void *))
-+{
-+ DPRINTK("");
-+ bus_for_each_dev(&xenbus_backend.bus, NULL, NULL, fn);
-+}
-+
-+void xenbus_backend_probe_and_watch(void)
-+{
-+ xenbus_probe_devices(&xenbus_backend);
-+ register_xenbus_watch(&be_watch);
-+}
-+
-+void xenbus_backend_bus_register(void)
-+{
-+ bus_register(&xenbus_backend.bus);
-+}
-+
-+void xenbus_backend_device_register(void)
-+{
-+ device_register(&xenbus_backend.dev);
-+}
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/drivers/xen/xenbus/xenbus_probe.c source/drivers/xen/xenbus/xenbus_probe.c
---- /scratch/src/linux-2.6.20.3/drivers/xen/xenbus/xenbus_probe.c 1970-01-01 01:00:00.000000000 +0100
-+++ source/drivers/xen/xenbus/xenbus_probe.c 2007-03-20 21:26:49.000000000 +0100
-@@ -0,0 +1,1030 @@
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 drivers/xen/xenbus/xenbus_probe.c
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/drivers/xen/xenbus/xenbus_probe.c Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,1089 @@
+/******************************************************************************
+ * Talks to Xen Store to figure out what devices we have.
+ *
@@ -70003,7 +67950,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+
+extern struct mutex xenwatch_mutex;
+
-+static BLOCKING_NOTIFIER_HEAD(xenstore_notifier_list);
++static ATOMIC_NOTIFIER_HEAD(xenstore_chain);
+
+static void wait_for_devices(struct xenbus_driver *xendrv);
+
@@ -70270,6 +68217,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+{
+ int ret;
+
++ if (bus->error)
++ return bus->error;
++
+ drv->driver.name = drv->name;
+ drv->driver.bus = &bus->bus;
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,10)
@@ -70411,6 +68361,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+
+ enum xenbus_state state = xenbus_read_driver_state(nodename);
+
++ if (bus->error)
++ return bus->error;
++
+ if (state != XenbusStateInitialising) {
+ /* Device is not new, so ignore it. This can happen if a
+ device is going away after switching to Closed. */
@@ -70450,13 +68403,16 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+
+ err = device_create_file(&xendev->dev, &dev_attr_nodename);
+ if (err)
-+ goto fail;
-+
++ goto unregister;
+ err = device_create_file(&xendev->dev, &dev_attr_devtype);
+ if (err)
-+ goto fail;
++ goto unregister;
+
+ return 0;
++unregister:
++ device_remove_file(&xendev->dev, &dev_attr_nodename);
++ device_remove_file(&xendev->dev, &dev_attr_devtype);
++ device_unregister(&xendev->dev);
+fail:
+ kfree(xendev);
+ return err;
@@ -70505,6 +68461,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ char **dir;
+ unsigned int i, dir_n;
+
++ if (bus->error)
++ return bus->error;
++
+ dir = xenbus_directory(XBT_NIL, bus->root, "", &dir_n);
+ if (IS_ERR(dir))
+ return PTR_ERR(dir);
@@ -70548,7 +68507,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ char type[BUS_ID_SIZE];
+ const char *p, *root;
+
-+ if (char_count(node, '/') < 2)
++ if (bus->error || char_count(node, '/') < 2)
+ return;
+
+ exists = xenbus_exists(XBT_NIL, node, "");
@@ -70612,6 +68571,27 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ return 0;
+}
+
++static int suspend_cancel_dev(struct device *dev, void *data)
++{
++ int err = 0;
++ struct xenbus_driver *drv;
++ struct xenbus_device *xdev;
++
++ DPRINTK("");
++
++ if (dev->driver == NULL)
++ return 0;
++ drv = to_xenbus_driver(dev->driver);
++ xdev = container_of(dev, struct xenbus_device, dev);
++ if (drv->suspend_cancel)
++ err = drv->suspend_cancel(xdev);
++ if (err)
++ printk(KERN_WARNING
++ "xenbus: suspend_cancel %s failed: %i\n",
++ dev->bus_id, err);
++ return 0;
++}
++
+static int resume_dev(struct device *dev, void *data)
+{
+ int err;
@@ -70661,7 +68641,8 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+{
+ DPRINTK("");
+
-+ bus_for_each_dev(&xenbus_frontend.bus, NULL, NULL, suspend_dev);
++ if (!xenbus_frontend.error)
++ bus_for_each_dev(&xenbus_frontend.bus, NULL, NULL, suspend_dev);
+ xenbus_backend_suspend(suspend_dev);
+ xs_suspend();
+}
@@ -70671,11 +68652,20 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+{
+ xb_init_comms();
+ xs_resume();
-+ bus_for_each_dev(&xenbus_frontend.bus, NULL, NULL, resume_dev);
++ if (!xenbus_frontend.error)
++ bus_for_each_dev(&xenbus_frontend.bus, NULL, NULL, resume_dev);
+ xenbus_backend_resume(resume_dev);
+}
+EXPORT_SYMBOL_GPL(xenbus_resume);
+
++void xenbus_suspend_cancel(void)
++{
++ xs_suspend_cancel();
++ if (!xenbus_frontend.error)
++ bus_for_each_dev(&xenbus_frontend.bus, NULL, NULL, suspend_cancel_dev);
++ xenbus_backend_resume(suspend_cancel_dev);
++}
++EXPORT_SYMBOL_GPL(xenbus_suspend_cancel);
+
+/* A flag to determine if xenstored is 'ready' (i.e. has started) */
+int xenstored_ready = 0;
@@ -70688,7 +68678,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ if (xenstored_ready > 0)
+ ret = nb->notifier_call(nb, 0, NULL);
+ else
-+ blocking_notifier_chain_register(&xenstore_notifier_list, nb);
++ atomic_notifier_chain_register(&xenstore_chain, nb);
+
+ return ret;
+}
@@ -70696,7 +68686,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+
+void unregister_xenstore_notifier(struct notifier_block *nb)
+{
-+ blocking_notifier_chain_unregister(&xenstore_notifier_list, nb);
++ atomic_notifier_chain_unregister(&xenstore_chain, nb);
+}
+EXPORT_SYMBOL_GPL(unregister_xenstore_notifier);
+
@@ -70711,7 +68701,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ xenbus_backend_probe_and_watch();
+
+ /* Notify others that xenstore is up */
-+ blocking_notifier_call_chain(&xenstore_notifier_list, 0, NULL);
++ atomic_notifier_call_chain(&xenstore_chain, 0, NULL);
+}
+
+
@@ -70755,7 +68745,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+}
+#endif
+
-+static int __init xenbus_probe_init(void)
++static int xenbus_probe_init(void)
+{
+ int err = 0;
+ unsigned long page = 0;
@@ -70766,9 +68756,11 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ return -ENODEV;
+
+ /* Register ourselves with the kernel bus subsystem */
-+ err = bus_register(&xenbus_frontend.bus);
-+ if (err)
-+ goto err_frontend_bus;
++ xenbus_frontend.error = bus_register(&xenbus_frontend.bus);
++ if (xenbus_frontend.error)
++ printk(KERN_WARNING
++ "XENBUS: Error registering frontend bus: %i\n",
++ xenbus_frontend.error);
+ xenbus_backend_bus_register();
+
+ /*
@@ -70841,9 +68833,15 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ }
+
+ /* Register ourselves with the kernel device subsystem */
-+ err = device_register(&xenbus_frontend.dev);
-+ if (err)
-+ goto err;
++ if (!xenbus_frontend.error) {
++ xenbus_frontend.error = device_register(&xenbus_frontend.dev);
++ if (xenbus_frontend.error) {
++ bus_unregister(&xenbus_frontend.bus);
++ printk(KERN_WARNING
++ "XENBUS: Error registering frontend device: %i\n",
++ xenbus_frontend.error);
++ }
++ }
+ xenbus_backend_device_register();
+
+ if (!is_initial_xendomain())
@@ -70862,14 +68860,18 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ */
+ err_nomem:
+ bus_unregister(&xenbus_frontend.bus);
-+ err_frontend_bus:
+ return err;
+}
+
++#ifdef CONFIG_XEN
+postcore_initcall(xenbus_probe_init);
-+
+MODULE_LICENSE("Dual BSD/GPL");
-+
++#else
++int xenbus_init(void)
++{
++ return xenbus_probe_init();
++}
++#endif
+
+static int is_disconnected_device(struct device *dev, void *data)
+{
@@ -70892,6 +68894,8 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+
+static int exists_disconnected_device(struct device_driver *drv)
+{
++ if (xenbus_frontend.error)
++ return xenbus_frontend.error;
+ return bus_for_each_dev(&xenbus_frontend.bus, NULL, drv,
+ is_disconnected_device);
+}
@@ -70956,17 +68960,19 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#ifndef MODULE
+static int __init boot_wait_for_devices(void)
+{
-+ ready_to_wait_for_devices = 1;
-+ wait_for_devices(NULL);
++ if (!xenbus_frontend.error) {
++ ready_to_wait_for_devices = 1;
++ wait_for_devices(NULL);
++ }
+ return 0;
+}
+
+late_initcall(boot_wait_for_devices);
+#endif
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/drivers/xen/xenbus/xenbus_probe.h source/drivers/xen/xenbus/xenbus_probe.h
---- /scratch/src/linux-2.6.20.3/drivers/xen/xenbus/xenbus_probe.h 1970-01-01 01:00:00.000000000 +0100
-+++ source/drivers/xen/xenbus/xenbus_probe.h 2007-03-20 21:26:49.000000000 +0100
-@@ -0,0 +1,73 @@
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 drivers/xen/xenbus/xenbus_probe.h
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/drivers/xen/xenbus/xenbus_probe.h Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,74 @@
+/******************************************************************************
+ * xenbus_probe.h
+ *
@@ -71020,6 +69026,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+struct xen_bus_type
+{
+ char *root;
++ int error;
+ unsigned int levels;
+ int (*get_bus_id)(char bus_id[BUS_ID_SIZE], const char *nodename);
+ int (*probe)(const char *type, const char *dir);
@@ -71040,10 +69047,300 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+extern void dev_changed(const char *node, struct xen_bus_type *bus);
+#endif
+
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/drivers/xen/xenbus/xenbus_xs.c source/drivers/xen/xenbus/xenbus_xs.c
---- /scratch/src/linux-2.6.20.3/drivers/xen/xenbus/xenbus_xs.c 1970-01-01 01:00:00.000000000 +0100
-+++ source/drivers/xen/xenbus/xenbus_xs.c 2007-03-20 21:26:49.000000000 +0100
-@@ -0,0 +1,859 @@
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 drivers/xen/xenbus/xenbus_probe_backend.c
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/drivers/xen/xenbus/xenbus_probe_backend.c Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,286 @@
++/******************************************************************************
++ * Talks to Xen Store to figure out what devices we have (backend half).
++ *
++ * Copyright (C) 2005 Rusty Russell, IBM Corporation
++ * Copyright (C) 2005 Mike Wray, Hewlett-Packard
++ * Copyright (C) 2005, 2006 XenSource Ltd
++ *
++ * 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; or, when distributed
++ * separately from the Linux kernel or incorporated into other
++ * software packages, subject to the following license:
++ *
++ * Permission is hereby granted, free of charge, to any person obtaining a copy
++ * of this source file (the "Software"), to deal in the Software without
++ * restriction, including without limitation the rights to use, copy, modify,
++ * merge, publish, distribute, sublicense, and/or sell copies of the Software,
++ * and to permit persons to whom the Software is furnished to do so, subject to
++ * the following conditions:
++ *
++ * The above copyright notice and this permission notice shall be included in
++ * all copies or substantial portions of the Software.
++ *
++ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
++ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
++ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
++ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
++ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
++ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
++ * IN THE SOFTWARE.
++ */
++
++#define DPRINTK(fmt, args...) \
++ pr_debug("xenbus_probe (%s:%d) " fmt ".\n", \
++ __FUNCTION__, __LINE__, ##args)
++
++#include <linux/kernel.h>
++#include <linux/err.h>
++#include <linux/string.h>
++#include <linux/ctype.h>
++#include <linux/fcntl.h>
++#include <linux/mm.h>
++#include <linux/notifier.h>
++#include <linux/kthread.h>
++
++#include <asm/io.h>
++#include <asm/page.h>
++#include <asm/maddr.h>
++#include <asm/pgtable.h>
++#include <asm/hypervisor.h>
++#include <xen/xenbus.h>
++#include <xen/xen_proc.h>
++#include <xen/evtchn.h>
++#include <xen/features.h>
++#include <xen/hvm.h>
++
++#include "xenbus_comms.h"
++#include "xenbus_probe.h"
++
++#ifdef HAVE_XEN_PLATFORM_COMPAT_H
++#include <xen/platform-compat.h>
++#endif
++
++static int xenbus_uevent_backend(struct device *dev, char **envp,
++ int num_envp, char *buffer, int buffer_size);
++static int xenbus_probe_backend(const char *type, const char *domid);
++
++extern int read_otherend_details(struct xenbus_device *xendev,
++ char *id_node, char *path_node);
++
++static int read_frontend_details(struct xenbus_device *xendev)
++{
++ return read_otherend_details(xendev, "frontend-id", "frontend");
++}
++
++/* backend/<type>/<fe-uuid>/<id> => <type>-<fe-domid>-<id> */
++static int backend_bus_id(char bus_id[BUS_ID_SIZE], const char *nodename)
++{
++ int domid, err;
++ const char *devid, *type, *frontend;
++ unsigned int typelen;
++
++ type = strchr(nodename, '/');
++ if (!type)
++ return -EINVAL;
++ type++;
++ typelen = strcspn(type, "/");
++ if (!typelen || type[typelen] != '/')
++ return -EINVAL;
++
++ devid = strrchr(nodename, '/') + 1;
++
++ err = xenbus_gather(XBT_NIL, nodename, "frontend-id", "%i", &domid,
++ "frontend", NULL, &frontend,
++ NULL);
++ if (err)
++ return err;
++ if (strlen(frontend) == 0)
++ err = -ERANGE;
++ if (!err && !xenbus_exists(XBT_NIL, frontend, ""))
++ err = -ENOENT;
++ kfree(frontend);
++
++ if (err)
++ return err;
++
++ if (snprintf(bus_id, BUS_ID_SIZE,
++ "%.*s-%i-%s", typelen, type, domid, devid) >= BUS_ID_SIZE)
++ return -ENOSPC;
++ return 0;
++}
++
++static struct xen_bus_type xenbus_backend = {
++ .root = "backend",
++ .levels = 3, /* backend/type/<frontend>/<id> */
++ .get_bus_id = backend_bus_id,
++ .probe = xenbus_probe_backend,
++ .bus = {
++ .name = "xen-backend",
++ .match = xenbus_match,
++ .probe = xenbus_dev_probe,
++ .remove = xenbus_dev_remove,
++// .shutdown = xenbus_dev_shutdown,
++ .uevent = xenbus_uevent_backend,
++ },
++ .dev = {
++ .bus_id = "xen-backend",
++ },
++};
++
++static int xenbus_uevent_backend(struct device *dev, char **envp,
++ int num_envp, char *buffer, int buffer_size)
++{
++ struct xenbus_device *xdev;
++ struct xenbus_driver *drv;
++ int i = 0;
++ int length = 0;
++
++ DPRINTK("");
++
++ if (dev == NULL)
++ return -ENODEV;
++
++ xdev = to_xenbus_device(dev);
++ if (xdev == NULL)
++ return -ENODEV;
++
++ /* stuff we want to pass to /sbin/hotplug */
++ add_uevent_var(envp, num_envp, &i, buffer, buffer_size, &length,
++ "XENBUS_TYPE=%s", xdev->devicetype);
++
++ add_uevent_var(envp, num_envp, &i, buffer, buffer_size, &length,
++ "XENBUS_PATH=%s", xdev->nodename);
++
++ add_uevent_var(envp, num_envp, &i, buffer, buffer_size, &length,
++ "XENBUS_BASE_PATH=%s", xenbus_backend.root);
++
++ /* terminate, set to next free slot, shrink available space */
++ envp[i] = NULL;
++ envp = &envp[i];
++ num_envp -= i;
++ buffer = &buffer[length];
++ buffer_size -= length;
++
++ if (dev->driver) {
++ drv = to_xenbus_driver(dev->driver);
++ if (drv && drv->uevent)
++ return drv->uevent(xdev, envp, num_envp, buffer,
++ buffer_size);
++ }
++
++ return 0;
++}
++
++int xenbus_register_backend(struct xenbus_driver *drv)
++{
++ drv->read_otherend_details = read_frontend_details;
++
++ return xenbus_register_driver_common(drv, &xenbus_backend);
++}
++EXPORT_SYMBOL_GPL(xenbus_register_backend);
++
++/* backend/<typename>/<frontend-uuid>/<name> */
++static int xenbus_probe_backend_unit(const char *dir,
++ const char *type,
++ const char *name)
++{
++ char *nodename;
++ int err;
++
++ nodename = kasprintf(GFP_KERNEL, "%s/%s", dir, name);
++ if (!nodename)
++ return -ENOMEM;
++
++ DPRINTK("%s\n", nodename);
++
++ err = xenbus_probe_node(&xenbus_backend, type, nodename);
++ kfree(nodename);
++ return err;
++}
++
++/* backend/<typename>/<frontend-domid> */
++static int xenbus_probe_backend(const char *type, const char *domid)
++{
++ char *nodename;
++ int err = 0;
++ char **dir;
++ unsigned int i, dir_n = 0;
++
++ DPRINTK("");
++
++ nodename = kasprintf(GFP_KERNEL, "%s/%s/%s", xenbus_backend.root, type, domid);
++ if (!nodename)
++ return -ENOMEM;
++
++ dir = xenbus_directory(XBT_NIL, nodename, "", &dir_n);
++ if (IS_ERR(dir)) {
++ kfree(nodename);
++ return PTR_ERR(dir);
++ }
++
++ for (i = 0; i < dir_n; i++) {
++ err = xenbus_probe_backend_unit(nodename, type, dir[i]);
++ if (err)
++ break;
++ }
++ kfree(dir);
++ kfree(nodename);
++ return err;
++}
++
++static void backend_changed(struct xenbus_watch *watch,
++ const char **vec, unsigned int len)
++{
++ DPRINTK("");
++
++ dev_changed(vec[XS_WATCH_PATH], &xenbus_backend);
++}
++
++static struct xenbus_watch be_watch = {
++ .node = "backend",
++ .callback = backend_changed,
++};
++
++void xenbus_backend_suspend(int (*fn)(struct device *, void *))
++{
++ DPRINTK("");
++ if (!xenbus_backend.error)
++ bus_for_each_dev(&xenbus_backend.bus, NULL, NULL, fn);
++}
++
++void xenbus_backend_resume(int (*fn)(struct device *, void *))
++{
++ DPRINTK("");
++ if (!xenbus_backend.error)
++ bus_for_each_dev(&xenbus_backend.bus, NULL, NULL, fn);
++}
++
++void xenbus_backend_probe_and_watch(void)
++{
++ xenbus_probe_devices(&xenbus_backend);
++ register_xenbus_watch(&be_watch);
++}
++
++void xenbus_backend_bus_register(void)
++{
++ xenbus_backend.error = bus_register(&xenbus_backend.bus);
++ if (xenbus_backend.error)
++ printk(KERN_WARNING
++ "XENBUS: Error registering backend bus: %i\n",
++ xenbus_backend.error);
++}
++
++void xenbus_backend_device_register(void)
++{
++ if (xenbus_backend.error)
++ return;
++
++ xenbus_backend.error = device_register(&xenbus_backend.dev);
++ if (xenbus_backend.error) {
++ bus_unregister(&xenbus_backend.bus);
++ printk(KERN_WARNING
++ "XENBUS: Error registering backend device: %i\n",
++ xenbus_backend.error);
++ }
++}
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 drivers/xen/xenbus/xenbus_xs.c
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/drivers/xen/xenbus/xenbus_xs.c Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,880 @@
+/******************************************************************************
+ * xenbus_xs.c
+ *
@@ -71123,11 +69420,22 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ spinlock_t reply_lock;
+ wait_queue_head_t reply_waitq;
+
++ /*
++ * Mutex ordering: transaction_mutex -> watch_mutex -> request_mutex.
++ * response_mutex is never taken simultaneously with the other three.
++ */
++
+ /* One request at a time. */
+ struct mutex request_mutex;
+
++ /* Protect xenbus reader thread against save/restore. */
++ struct mutex response_mutex;
++
+ /* Protect transactions against save/restore. */
-+ struct rw_semaphore suspend_mutex;
++ struct rw_semaphore transaction_mutex;
++
++ /* Protect watch (de)register against save/restore. */
++ struct rw_semaphore watch_mutex;
+};
+
+static struct xs_handle xs_state;
@@ -71196,22 +69504,6 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ return body;
+}
+
-+/* Emergency write. */
-+void xenbus_debug_write(const char *str, unsigned int count)
-+{
-+ struct xsd_sockmsg msg = { 0 };
-+
-+ msg.type = XS_DEBUG;
-+ msg.len = sizeof("print") + count + 1;
-+
-+ mutex_lock(&xs_state.request_mutex);
-+ xb_write(&msg, sizeof(msg));
-+ xb_write("print", sizeof("print"));
-+ xb_write(str, count);
-+ xb_write("", 1);
-+ mutex_unlock(&xs_state.request_mutex);
-+}
-+
+void *xenbus_dev_request_and_reply(struct xsd_sockmsg *msg)
+{
+ void *ret;
@@ -71219,7 +69511,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ int err;
+
+ if (req_msg.type == XS_TRANSACTION_START)
-+ down_read(&xs_state.suspend_mutex);
++ down_read(&xs_state.transaction_mutex);
+
+ mutex_lock(&xs_state.request_mutex);
+
@@ -71235,7 +69527,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ if ((req_msg.type == XS_TRANSACTION_END) ||
+ ((req_msg.type == XS_TRANSACTION_START) &&
+ (msg->type == XS_ERROR)))
-+ up_read(&xs_state.suspend_mutex);
++ up_read(&xs_state.transaction_mutex);
+
+ return ret;
+}
@@ -71486,11 +69778,11 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+{
+ char *id_str;
+
-+ down_read(&xs_state.suspend_mutex);
++ down_read(&xs_state.transaction_mutex);
+
+ id_str = xs_single(XBT_NIL, XS_TRANSACTION_START, "", NULL);
+ if (IS_ERR(id_str)) {
-+ up_read(&xs_state.suspend_mutex);
++ up_read(&xs_state.transaction_mutex);
+ return PTR_ERR(id_str);
+ }
+
@@ -71515,7 +69807,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+
+ err = xs_error(xs_single(t, XS_TRANSACTION_END, abortstr, NULL));
+
-+ up_read(&xs_state.suspend_mutex);
++ up_read(&xs_state.transaction_mutex);
+
+ return err;
+}
@@ -71648,7 +69940,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+
+ sprintf(token, "%lX", (long)watch);
+
-+ down_read(&xs_state.suspend_mutex);
++ down_read(&xs_state.watch_mutex);
+
+ spin_lock(&watches_lock);
+ BUG_ON(find_watch(token));
@@ -71664,7 +69956,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ spin_unlock(&watches_lock);
+ }
+
-+ up_read(&xs_state.suspend_mutex);
++ up_read(&xs_state.watch_mutex);
+
+ return err;
+}
@@ -71678,7 +69970,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+
+ sprintf(token, "%lX", (long)watch);
+
-+ down_read(&xs_state.suspend_mutex);
++ down_read(&xs_state.watch_mutex);
+
+ spin_lock(&watches_lock);
+ BUG_ON(!find_watch(token));
@@ -71691,7 +69983,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ "XENBUS Failed to release watch %s: %i\n",
+ watch->node, err);
+
-+ up_read(&xs_state.suspend_mutex);
++ up_read(&xs_state.watch_mutex);
+
+ /* Cancel pending watch events. */
+ spin_lock(&watch_events_lock);
@@ -71714,18 +70006,10 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+
+void xs_suspend(void)
+{
-+ struct xenbus_watch *watch;
-+ char token[sizeof(watch) * 2 + 1];
-+
-+ down_write(&xs_state.suspend_mutex);
-+
-+ /* No need for watches_lock: the suspend_mutex is sufficient. */
-+ list_for_each_entry(watch, &watches, list) {
-+ sprintf(token, "%lX", (long)watch);
-+ xs_unwatch(watch->node, token);
-+ }
-+
++ down_write(&xs_state.transaction_mutex);
++ down_write(&xs_state.watch_mutex);
+ mutex_lock(&xs_state.request_mutex);
++ mutex_lock(&xs_state.response_mutex);
+}
+
+void xs_resume(void)
@@ -71733,15 +70017,25 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ struct xenbus_watch *watch;
+ char token[sizeof(watch) * 2 + 1];
+
++ mutex_unlock(&xs_state.response_mutex);
+ mutex_unlock(&xs_state.request_mutex);
++ up_write(&xs_state.transaction_mutex);
+
-+ /* No need for watches_lock: the suspend_mutex is sufficient. */
++ /* No need for watches_lock: the watch_mutex is sufficient. */
+ list_for_each_entry(watch, &watches, list) {
+ sprintf(token, "%lX", (long)watch);
+ xs_watch(watch->node, token);
+ }
+
-+ up_write(&xs_state.suspend_mutex);
++ up_write(&xs_state.watch_mutex);
++}
++
++void xs_suspend_cancel(void)
++{
++ mutex_unlock(&xs_state.response_mutex);
++ mutex_unlock(&xs_state.request_mutex);
++ up_write(&xs_state.watch_mutex);
++ up_write(&xs_state.transaction_mutex);
+}
+
+static int xenwatch_handle_callback(void *data)
@@ -71803,27 +70097,46 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ char *body;
+ int err;
+
++ /*
++ * We must disallow save/restore while reading a xenstore message.
++ * A partial read across s/r leaves us out of sync with xenstored.
++ */
++ for (;;) {
++ err = xb_wait_for_data_to_read();
++ if (err)
++ return err;
++ mutex_lock(&xs_state.response_mutex);
++ if (xb_data_to_read())
++ break;
++ /* We raced with save/restore: pending data 'disappeared'. */
++ mutex_unlock(&xs_state.response_mutex);
++ }
++
++
+ msg = kmalloc(sizeof(*msg), GFP_KERNEL);
-+ if (msg == NULL)
-+ return -ENOMEM;
++ if (msg == NULL) {
++ err = -ENOMEM;
++ goto out;
++ }
+
+ err = xb_read(&msg->hdr, sizeof(msg->hdr));
+ if (err) {
+ kfree(msg);
-+ return err;
++ goto out;
+ }
+
+ body = kmalloc(msg->hdr.len + 1, GFP_KERNEL);
+ if (body == NULL) {
+ kfree(msg);
-+ return -ENOMEM;
++ err = -ENOMEM;
++ goto out;
+ }
+
+ err = xb_read(body, msg->hdr.len);
+ if (err) {
+ kfree(body);
+ kfree(msg);
-+ return err;
++ goto out;
+ }
+ body[msg->hdr.len] = '\0';
+
@@ -71832,7 +70145,8 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ &msg->u.watch.vec_size);
+ if (IS_ERR(msg->u.watch.vec)) {
+ kfree(msg);
-+ return PTR_ERR(msg->u.watch.vec);
++ err = PTR_ERR(msg->u.watch.vec);
++ goto out;
+ }
+
+ spin_lock(&watches_lock);
@@ -71856,7 +70170,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ wake_up(&xs_state.reply_waitq);
+ }
+
-+ return 0;
++ out:
++ mutex_unlock(&xs_state.response_mutex);
++ return err;
+}
+
+static int xenbus_thread(void *unused)
@@ -71885,7 +70201,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ init_waitqueue_head(&xs_state.reply_waitq);
+
+ mutex_init(&xs_state.request_mutex);
-+ init_rwsem(&xs_state.suspend_mutex);
++ mutex_init(&xs_state.response_mutex);
++ init_rwsem(&xs_state.transaction_mutex);
++ init_rwsem(&xs_state.watch_mutex);
+
+ /* Initialize the shared memory rings to talk to xenstored */
+ err = xb_init_comms();
@@ -71903,9 +70221,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+
+ return 0;
+}
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/drivers/xen/xenoprof/xenoprofile.c source/drivers/xen/xenoprof/xenoprofile.c
---- /scratch/src/linux-2.6.20.3/drivers/xen/xenoprof/xenoprofile.c 1970-01-01 01:00:00.000000000 +0100
-+++ source/drivers/xen/xenoprof/xenoprofile.c 2007-03-21 14:49:46.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 drivers/xen/xenoprof/xenoprofile.c
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/drivers/xen/xenoprof/xenoprofile.c Wed Aug 08 16:25:28 2007 -0300
@@ -0,0 +1,500 @@
+/**
+ * @file xenoprofile.c
@@ -72407,10 +70725,10 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ HYPERVISOR_xenoprof_op(XENOPROF_shutdown, NULL);
+ }
+}
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/fs/Kconfig source/fs/Kconfig
---- /scratch/src/linux-2.6.20.3/fs/Kconfig 2007-02-04 19:44:54.000000000 +0100
-+++ source/fs/Kconfig 2007-03-20 21:26:49.000000000 +0100
-@@ -1003,6 +1003,7 @@ config TMPFS_POSIX_ACL
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 fs/Kconfig
+--- a/fs/Kconfig Wed Jul 18 12:23:24 2007 -0300
++++ b/fs/Kconfig Wed Aug 08 16:25:28 2007 -0300
+@@ -1003,6 +1003,7 @@ config HUGETLBFS
config HUGETLBFS
bool "HugeTLB file system support"
depends on X86 || IA64 || PPC64 || SPARC64 || SUPERH || BROKEN
@@ -72418,9 +70736,21 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
help
hugetlbfs is a filesystem backing for HugeTLB pages, based on
ramfs. For architectures that support it, say Y here and read
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/asm-i386/apic.h source/include/asm-i386/apic.h
---- /scratch/src/linux-2.6.20.3/include/asm-i386/apic.h 2007-02-04 19:44:54.000000000 +0100
-+++ source/include/asm-i386/apic.h 2007-03-20 21:26:55.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 fs/proc/vmcore.c
+--- a/fs/proc/vmcore.c Wed Jul 18 12:23:24 2007 -0300
++++ b/fs/proc/vmcore.c Wed Aug 08 16:25:28 2007 -0300
+@@ -514,7 +514,7 @@ static int __init parse_crash_elf64_head
+ /* Do some basic Verification. */
+ if (memcmp(ehdr.e_ident, ELFMAG, SELFMAG) != 0 ||
+ (ehdr.e_type != ET_CORE) ||
+- !elf_check_arch(&ehdr) ||
++ !vmcore_elf_check_arch(&ehdr) ||
+ ehdr.e_ident[EI_CLASS] != ELFCLASS64 ||
+ ehdr.e_ident[EI_VERSION] != EV_CURRENT ||
+ ehdr.e_version != EV_CURRENT ||
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/asm-i386/apic.h
+--- a/include/asm-i386/apic.h Wed Jul 18 12:23:24 2007 -0300
++++ b/include/asm-i386/apic.h Wed Aug 08 16:25:28 2007 -0300
@@ -116,10 +116,12 @@ extern void enable_APIC_timer(void);
extern void enable_NMI_through_LVT0 (void * dummy);
@@ -72434,10 +70764,94 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
extern int timer_over_8254;
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/asm-i386/highmem.h source/include/asm-i386/highmem.h
---- /scratch/src/linux-2.6.20.3/include/asm-i386/highmem.h 2007-02-04 19:44:54.000000000 +0100
-+++ source/include/asm-i386/highmem.h 2007-03-20 21:26:55.000000000 +0100
-@@ -68,6 +68,9 @@ extern void FASTCALL(kunmap_high(struct
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/asm-i386/desc.h
+--- a/include/asm-i386/desc.h Wed Jul 18 12:23:24 2007 -0300
++++ b/include/asm-i386/desc.h Wed Aug 08 16:25:28 2007 -0300
+@@ -76,12 +76,20 @@ static inline void pack_gate(__u32 *a, _
+
+ static inline void load_TLS(struct thread_struct *t, unsigned int cpu)
+ {
++#ifdef CONFIG_XEN
++#define C(i) HYPERVISOR_update_descriptor(virt_to_machine(&get_cpu_gdt_table(cpu)[GDT_ENTRY_TLS_MIN + i]), *(u64 *)&t->tls_array[i])
++#else
+ #define C(i) get_cpu_gdt_table(cpu)[GDT_ENTRY_TLS_MIN + i] = t->tls_array[i]
++#endif
+ C(0); C(1); C(2);
+ #undef C
+ }
+
++#ifdef CONFIG_XEN
++extern int write_ldt_entry(void *ldt, int entry, __u32 entry_a, __u32 entry_b);
++#else
+ #define write_ldt_entry(dt, entry, a, b) write_dt_entry(dt, entry, a, b)
++#endif
+ #define write_gdt_entry(dt, entry, a, b) write_dt_entry(dt, entry, a, b)
+ #define write_idt_entry(dt, entry, a, b) write_dt_entry(dt, entry, a, b)
+
+@@ -92,7 +100,11 @@ static inline void write_dt_entry(void *
+ *(lp+1) = entry_b;
+ }
+
++#ifdef CONFIG_XEN
++#define set_ldt(address,count) xen_set_ldt((unsigned long)address, count)
++#else
+ #define set_ldt native_set_ldt
++#endif
+ #endif /* CONFIG_PARAVIRT */
+
+ static inline fastcall void native_set_ldt(const void *addr,
+@@ -119,6 +131,7 @@ static inline void _set_gate(int gate, u
+ write_idt_entry(idt_table, gate, a, b);
+ }
+
++#ifndef CONFIG_X86_NO_TSS
+ static inline void __set_tss_desc(unsigned int cpu, unsigned int entry, const void *addr)
+ {
+ __u32 a, b;
+@@ -127,6 +140,7 @@ static inline void __set_tss_desc(unsign
+ DESCTYPE_TSS, 0);
+ write_gdt_entry(get_cpu_gdt_table(cpu), entry, a, b);
+ }
++#endif
+
+
+ #define set_tss_desc(cpu,addr) __set_tss_desc(cpu, GDT_ENTRY_TSS, addr)
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/asm-i386/fixmap.h
+--- a/include/asm-i386/fixmap.h Wed Jul 18 12:23:24 2007 -0300
++++ b/include/asm-i386/fixmap.h Wed Aug 08 16:25:28 2007 -0300
+@@ -88,6 +88,12 @@ enum fixed_addresses {
+ #ifdef CONFIG_PCI_MMCONFIG
+ FIX_PCIE_MCFG,
+ #endif
++#ifdef CONFIG_XEN
++ FIX_SHARED_INFO,
++#define NR_FIX_ISAMAPS 256
++ FIX_ISAMAP_END,
++ FIX_ISAMAP_BEGIN = FIX_ISAMAP_END + NR_FIX_ISAMAPS - 1,
++#endif
+ __end_of_permanent_fixed_addresses,
+ /* temporary boot-time mappings, used before ioremap() is functional */
+ #define NR_FIX_BTMAPS 16
+@@ -97,8 +103,15 @@ enum fixed_addresses {
+ __end_of_fixed_addresses
+ };
+
++#ifdef CONFIG_XEN
++extern void set_fixaddr_top(void);
++
++extern void __set_fixmap(enum fixed_addresses idx,
++ maddr_t phys, pgprot_t flags);
++#else
+ extern void __set_fixmap (enum fixed_addresses idx,
+ unsigned long phys, pgprot_t flags);
++#endif
+ extern void reserve_top_address(unsigned long reserve);
+
+ #define set_fixmap(idx, phys) \
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/asm-i386/highmem.h
+--- a/include/asm-i386/highmem.h Wed Jul 18 12:23:24 2007 -0300
++++ b/include/asm-i386/highmem.h Wed Aug 08 16:25:28 2007 -0300
+@@ -68,6 +68,9 @@ void *kmap(struct page *page);
void *kmap(struct page *page);
void kunmap(struct page *page);
void *kmap_atomic(struct page *page, enum km_type type);
@@ -72447,10 +70861,20 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
void kunmap_atomic(void *kvaddr, enum km_type type);
void *kmap_atomic_pfn(unsigned long pfn, enum km_type type);
struct page *kmap_atomic_to_page(void *ptr);
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/asm-i386/kexec.h source/include/asm-i386/kexec.h
---- /scratch/src/linux-2.6.20.3/include/asm-i386/kexec.h 2007-02-04 19:44:54.000000000 +0100
-+++ source/include/asm-i386/kexec.h 2007-03-20 21:26:55.000000000 +0100
-@@ -98,6 +98,20 @@ relocate_kernel(unsigned long indirectio
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/asm-i386/kexec.h
+--- a/include/asm-i386/kexec.h Wed Jul 18 12:23:24 2007 -0300
++++ b/include/asm-i386/kexec.h Wed Aug 08 16:25:28 2007 -0300
+@@ -46,6 +46,9 @@
+
+ /* The native architecture */
+ #define KEXEC_ARCH KEXEC_ARCH_386
++
++/* We can also handle crash dumps from 64 bit kernel. */
++#define vmcore_elf_check_arch_cross(x) ((x)->e_machine == EM_X86_64)
+
+ #define MAX_NOTE_BYTES 1024
+
+@@ -98,6 +101,20 @@ relocate_kernel(unsigned long indirectio
unsigned long start_address,
unsigned int has_pae) ATTRIB_NORET;
@@ -72471,10 +70895,10 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
#endif /* __ASSEMBLY__ */
#endif /* _I386_KEXEC_H */
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/asm-i386/kmap_types.h source/include/asm-i386/kmap_types.h
---- /scratch/src/linux-2.6.20.3/include/asm-i386/kmap_types.h 2007-02-04 19:44:54.000000000 +0100
-+++ source/include/asm-i386/kmap_types.h 2007-03-20 21:26:55.000000000 +0100
-@@ -22,7 +22,12 @@ D(9) KM_IRQ0,
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/asm-i386/kmap_types.h
+--- a/include/asm-i386/kmap_types.h Wed Jul 18 12:23:24 2007 -0300
++++ b/include/asm-i386/kmap_types.h Wed Aug 08 16:25:28 2007 -0300
+@@ -22,7 +22,12 @@ D(10) KM_IRQ1,
D(10) KM_IRQ1,
D(11) KM_SOFTIRQ0,
D(12) KM_SOFTIRQ1,
@@ -72487,13 +70911,16 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
};
#undef D
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/asm-i386/mach-default/mach_traps.h source/include/asm-i386/mach-default/mach_traps.h
---- /scratch/src/linux-2.6.20.3/include/asm-i386/mach-default/mach_traps.h 2007-02-04 19:44:54.000000000 +0100
-+++ source/include/asm-i386/mach-default/mach_traps.h 2007-03-20 21:26:55.000000000 +0100
-@@ -15,6 +15,18 @@ static inline void clear_mem_error(unsig
- outb(reason, 0x61);
- }
-
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/asm-i386/mach-default/mach_traps.h
+--- a/include/asm-i386/mach-default/mach_traps.h Wed Jul 18 12:23:24 2007 -0300
++++ b/include/asm-i386/mach-default/mach_traps.h Wed Aug 08 16:25:28 2007 -0300
+@@ -12,6 +12,18 @@ static inline void clear_mem_error(unsig
+ static inline void clear_mem_error(unsigned char reason)
+ {
+ reason = (reason & 0xf) | 4;
++ outb(reason, 0x61);
++}
++
+static inline void clear_io_check_error(unsigned char reason)
+{
+ unsigned long i;
@@ -72503,15 +70930,12 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ i = 2000;
+ while (--i) udelay(1000);
+ reason &= ~8;
-+ outb(reason, 0x61);
-+}
-+
- static inline unsigned char get_nmi_reason(void)
- {
- return inb(0x61);
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/asm-i386/mach-xen/asm/agp.h source/include/asm-i386/mach-xen/asm/agp.h
---- /scratch/src/linux-2.6.20.3/include/asm-i386/mach-xen/asm/agp.h 1970-01-01 01:00:00.000000000 +0100
-+++ source/include/asm-i386/mach-xen/asm/agp.h 2007-03-20 21:26:56.000000000 +0100
+ outb(reason, 0x61);
+ }
+
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/asm-i386/mach-xen/asm/agp.h
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/include/asm-i386/mach-xen/asm/agp.h Wed Aug 08 16:25:28 2007 -0300
@@ -0,0 +1,37 @@
+#ifndef AGP_H
+#define AGP_H 1
@@ -72550,236 +70974,10 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ dma_free_coherent(NULL,PAGE_SIZE<<(order),(table),virt_to_bus(table))
+
+#endif
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/asm-i386/mach-xen/asm/desc.h source/include/asm-i386/mach-xen/asm/desc.h
---- /scratch/src/linux-2.6.20.3/include/asm-i386/mach-xen/asm/desc.h 1970-01-01 01:00:00.000000000 +0100
-+++ source/include/asm-i386/mach-xen/asm/desc.h 2007-03-20 21:26:56.000000000 +0100
-@@ -0,0 +1,222 @@
-+#ifndef __ARCH_DESC_H
-+#define __ARCH_DESC_H
-+
-+#include <asm/ldt.h>
-+#include <asm/segment.h>
-+
-+#ifndef __ASSEMBLY__
-+
-+#include <linux/preempt.h>
-+#include <linux/smp.h>
-+#include <linux/percpu.h>
-+
-+#include <asm/mmu.h>
-+
-+extern struct desc_struct cpu_gdt_table[GDT_ENTRIES];
-+
-+struct Xgt_desc_struct {
-+ unsigned short size;
-+ unsigned long address __attribute__((packed));
-+ unsigned short pad;
-+} __attribute__ ((packed));
-+
-+extern struct Xgt_desc_struct idt_descr;
-+DECLARE_PER_CPU(struct Xgt_desc_struct, cpu_gdt_descr);
-+
-+
-+static inline struct desc_struct *get_cpu_gdt_table(unsigned int cpu)
-+{
-+ return (struct desc_struct *)per_cpu(cpu_gdt_descr, cpu).address;
-+}
-+
-+extern struct desc_struct idt_table[];
-+extern void set_intr_gate(unsigned int irq, void * addr);
-+
-+static inline void pack_descriptor(__u32 *a, __u32 *b,
-+ unsigned long base, unsigned long limit, unsigned char type, unsigned char flags)
-+{
-+ *a = ((base & 0xffff) << 16) | (limit & 0xffff);
-+ *b = (base & 0xff000000) | ((base & 0xff0000) >> 16) |
-+ (limit & 0x000f0000) | ((type & 0xff) << 8) | ((flags & 0xf) << 20);
-+}
-+
-+static inline void pack_gate(__u32 *a, __u32 *b,
-+ unsigned long base, unsigned short seg, unsigned char type, unsigned char flags)
-+{
-+ *a = (seg << 16) | (base & 0xffff);
-+ *b = (base & 0xffff0000) | ((type & 0xff) << 8) | (flags & 0xff);
-+}
-+
-+#define DESCTYPE_LDT 0x82 /* present, system, DPL-0, LDT */
-+#define DESCTYPE_TSS 0x89 /* present, system, DPL-0, 32-bit TSS */
-+#define DESCTYPE_TASK 0x85 /* present, system, DPL-0, task gate */
-+#define DESCTYPE_INT 0x8e /* present, system, DPL-0, interrupt gate */
-+#define DESCTYPE_TRAP 0x8f /* present, system, DPL-0, trap gate */
-+#define DESCTYPE_DPL3 0x60 /* DPL-3 */
-+#define DESCTYPE_S 0x10 /* !system */
-+
-+#ifdef CONFIG_PARAVIRT
-+#include <asm/paravirt.h>
-+#else
-+#define load_TR_desc() __asm__ __volatile__("ltr %w0"::"q" (GDT_ENTRY_TSS*8))
-+
-+#define load_gdt(dtr) __asm__ __volatile("lgdt %0"::"m" (*dtr))
-+#define load_idt(dtr) __asm__ __volatile("lidt %0"::"m" (*dtr))
-+#define load_tr(tr) __asm__ __volatile("ltr %0"::"m" (tr))
-+#define load_ldt(ldt) __asm__ __volatile("lldt %0"::"m" (ldt))
-+
-+#define store_gdt(dtr) __asm__ ("sgdt %0":"=m" (*dtr))
-+#define store_idt(dtr) __asm__ ("sidt %0":"=m" (*dtr))
-+#define store_tr(tr) __asm__ ("str %0":"=m" (tr))
-+#define store_ldt(ldt) __asm__ ("sldt %0":"=m" (ldt))
-+
-+#if TLS_SIZE != 24
-+# error update this code.
-+#endif
-+
-+static inline void load_TLS(struct thread_struct *t, unsigned int cpu)
-+{
-+#define C(i) HYPERVISOR_update_descriptor(virt_to_machine(&get_cpu_gdt_table(cpu)[GDT_ENTRY_TLS_MIN + i]), *(u64 *)&t->tls_array[i])
-+ C(0); C(1); C(2);
-+#undef C
-+}
-+
-+extern int write_ldt_entry(void *ldt, int entry, __u32 entry_a, __u32 entry_b);
-+#define write_gdt_entry(dt, entry, a, b) write_dt_entry(dt, entry, a, b)
-+#define write_idt_entry(dt, entry, a, b) write_dt_entry(dt, entry, a, b)
-+
-+static inline void write_dt_entry(void *dt, int entry, __u32 entry_a, __u32 entry_b)
-+{
-+ __u32 *lp = (__u32 *)((char *)dt + entry*8);
-+ *lp = entry_a;
-+ *(lp+1) = entry_b;
-+}
-+
-+#define set_ldt native_set_ldt
-+#endif /* CONFIG_PARAVIRT */
-+
-+static inline fastcall void native_set_ldt(const void *addr,
-+ unsigned int entries)
-+{
-+ if (likely(entries == 0))
-+ __asm__ __volatile__("lldt %w0"::"q" (0));
-+ else {
-+ unsigned cpu = smp_processor_id();
-+ __u32 a, b;
-+
-+ pack_descriptor(&a, &b, (unsigned long)addr,
-+ entries * sizeof(struct desc_struct) - 1,
-+ DESCTYPE_LDT, 0);
-+ write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_LDT, a, b);
-+ __asm__ __volatile__("lldt %w0"::"q" (GDT_ENTRY_LDT*8));
-+ }
-+}
-+
-+static inline void _set_gate(int gate, unsigned int type, void *addr, unsigned short seg)
-+{
-+ __u32 a, b;
-+ pack_gate(&a, &b, (unsigned long)addr, seg, type, 0);
-+ write_idt_entry(idt_table, gate, a, b);
-+}
-+
-+#ifndef CONFIG_X86_NO_TSS
-+static inline void __set_tss_desc(unsigned int cpu, unsigned int entry, const void *addr)
-+{
-+ __u32 a, b;
-+ pack_descriptor(&a, &b, (unsigned long)addr,
-+ offsetof(struct tss_struct, __cacheline_filler) - 1,
-+ DESCTYPE_TSS, 0);
-+ write_gdt_entry(get_cpu_gdt_table(cpu), entry, a, b);
-+}
-+
-+#define set_tss_desc(cpu,addr) __set_tss_desc(cpu, GDT_ENTRY_TSS, addr)
-+#endif
-+
-+#define LDT_entry_a(info) \
-+ ((((info)->base_addr & 0x0000ffff) << 16) | ((info)->limit & 0x0ffff))
-+
-+#define LDT_entry_b(info) \
-+ (((info)->base_addr & 0xff000000) | \
-+ (((info)->base_addr & 0x00ff0000) >> 16) | \
-+ ((info)->limit & 0xf0000) | \
-+ (((info)->read_exec_only ^ 1) << 9) | \
-+ ((info)->contents << 10) | \
-+ (((info)->seg_not_present ^ 1) << 15) | \
-+ ((info)->seg_32bit << 22) | \
-+ ((info)->limit_in_pages << 23) | \
-+ ((info)->useable << 20) | \
-+ 0x7000)
-+
-+#define LDT_empty(info) (\
-+ (info)->base_addr == 0 && \
-+ (info)->limit == 0 && \
-+ (info)->contents == 0 && \
-+ (info)->read_exec_only == 1 && \
-+ (info)->seg_32bit == 0 && \
-+ (info)->limit_in_pages == 0 && \
-+ (info)->seg_not_present == 1 && \
-+ (info)->useable == 0 )
-+
-+static inline void clear_LDT(void)
-+{
-+ int cpu = get_cpu();
-+
-+ /*
-+ * NB. We load the default_ldt for lcall7/27 handling on demand, as
-+ * it slows down context switching. Noone uses it anyway.
-+ */
-+ cpu = cpu; /* XXX avoid compiler warning */
-+ xen_set_ldt(0UL, 0);
-+ put_cpu();
-+}
-+
-+/*
-+ * load one particular LDT into the current CPU
-+ */
-+static inline void load_LDT_nolock(mm_context_t *pc)
-+{
-+ xen_set_ldt((unsigned long)pc->ldt, pc->size);
-+}
-+
-+static inline void load_LDT(mm_context_t *pc)
-+{
-+ preempt_disable();
-+ load_LDT_nolock(pc);
-+ preempt_enable();
-+}
-+
-+static inline unsigned long get_desc_base(unsigned long *desc)
-+{
-+ unsigned long base;
-+ base = ((desc[0] >> 16) & 0x0000ffff) |
-+ ((desc[1] << 16) & 0x00ff0000) |
-+ (desc[1] & 0xff000000);
-+ return base;
-+}
-+
-+#else /* __ASSEMBLY__ */
-+
-+/*
-+ * GET_DESC_BASE reads the descriptor base of the specified segment.
-+ *
-+ * Args:
-+ * idx - descriptor index
-+ * gdt - GDT pointer
-+ * base - 32bit register to which the base will be written
-+ * lo_w - lo word of the "base" register
-+ * lo_b - lo byte of the "base" register
-+ * hi_b - hi byte of the low word of the "base" register
-+ *
-+ * Example:
-+ * GET_DESC_BASE(GDT_ENTRY_ESPFIX_SS, %ebx, %eax, %ax, %al, %ah)
-+ * Will read the base address of GDT_ENTRY_ESPFIX_SS and put it into %eax.
-+ */
-+#define GET_DESC_BASE(idx, gdt, base, lo_w, lo_b, hi_b) \
-+ movb idx*8+4(gdt), lo_b; \
-+ movb idx*8+7(gdt), hi_b; \
-+ shll $16, base; \
-+ movw idx*8+2(gdt), lo_w;
-+
-+#endif /* !__ASSEMBLY__ */
-+
-+#endif
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/asm-i386/mach-xen/asm/dma-mapping.h source/include/asm-i386/mach-xen/asm/dma-mapping.h
---- /scratch/src/linux-2.6.20.3/include/asm-i386/mach-xen/asm/dma-mapping.h 1970-01-01 01:00:00.000000000 +0100
-+++ source/include/asm-i386/mach-xen/asm/dma-mapping.h 2007-03-20 21:26:56.000000000 +0100
-@@ -0,0 +1,151 @@
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/asm-i386/mach-xen/asm/dma-mapping.h
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/include/asm-i386/mach-xen/asm/dma-mapping.h Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,157 @@
+#ifndef _ASM_I386_DMA_MAPPING_H
+#define _ASM_I386_DMA_MAPPING_H
+
@@ -72830,6 +71028,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+dma_map_sg(struct device *dev, struct scatterlist *sg, int nents,
+ enum dma_data_direction direction);
+
++#ifdef CONFIG_HIGHMEM
+extern dma_addr_t
+dma_map_page(struct device *dev, struct page *page, unsigned long offset,
+ size_t size, enum dma_data_direction direction);
@@ -72837,6 +71036,11 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+extern void
+dma_unmap_page(struct device *dev, dma_addr_t dma_address, size_t size,
+ enum dma_data_direction direction);
++#else
++#define dma_map_page(dev, page, offset, size, dir) \
++ dma_map_single(dev, page_address(page) + (offset), (size), (dir))
++#define dma_unmap_page dma_unmap_single
++#endif
+
+extern void
+dma_unmap_sg(struct device *dev, struct scatterlist *sg, int nhwentries,
@@ -72931,175 +71135,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ dma_addr_t device_addr, size_t size);
+
+#endif
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/asm-i386/mach-xen/asm/fixmap.h source/include/asm-i386/mach-xen/asm/fixmap.h
---- /scratch/src/linux-2.6.20.3/include/asm-i386/mach-xen/asm/fixmap.h 1970-01-01 01:00:00.000000000 +0100
-+++ source/include/asm-i386/mach-xen/asm/fixmap.h 2007-03-20 21:26:56.000000000 +0100
-@@ -0,0 +1,162 @@
-+/*
-+ * fixmap.h: compile-time virtual memory allocation
-+ *
-+ * This file is subject to the terms and conditions of the GNU General Public
-+ * License. See the file "COPYING" in the main directory of this archive
-+ * for more details.
-+ *
-+ * Copyright (C) 1998 Ingo Molnar
-+ *
-+ * Support of BIGMEM added by Gerhard Wichert, Siemens AG, July 1999
-+ */
-+
-+#ifndef _ASM_FIXMAP_H
-+#define _ASM_FIXMAP_H
-+
-+
-+/* used by vmalloc.c, vsyscall.lds.S.
-+ *
-+ * Leave one empty page between vmalloc'ed areas and
-+ * the start of the fixmap.
-+ */
-+#ifndef CONFIG_COMPAT_VDSO
-+extern unsigned long __FIXADDR_TOP;
-+#else
-+#define __FIXADDR_TOP 0xfffff000
-+#define FIXADDR_USER_START __fix_to_virt(FIX_VDSO)
-+#define FIXADDR_USER_END __fix_to_virt(FIX_VDSO - 1)
-+#endif
-+
-+#ifndef __ASSEMBLY__
-+#include <linux/kernel.h>
-+#include <asm/acpi.h>
-+#include <asm/apicdef.h>
-+#include <asm/page.h>
-+#ifdef CONFIG_HIGHMEM
-+#include <linux/threads.h>
-+#include <asm/kmap_types.h>
-+#endif
-+
-+/*
-+ * Here we define all the compile-time 'special' virtual
-+ * addresses. The point is to have a constant address at
-+ * compile time, but to set the physical address only
-+ * in the boot process. We allocate these special addresses
-+ * from the end of virtual memory (0xfffff000) backwards.
-+ * Also this lets us do fail-safe vmalloc(), we
-+ * can guarantee that these special addresses and
-+ * vmalloc()-ed addresses never overlap.
-+ *
-+ * these 'compile-time allocated' memory buffers are
-+ * fixed-size 4k pages. (or larger if used with an increment
-+ * highger than 1) use fixmap_set(idx,phys) to associate
-+ * physical memory with fixmap indices.
-+ *
-+ * TLB entries of such buffers will not be flushed across
-+ * task switches.
-+ */
-+enum fixed_addresses {
-+ FIX_HOLE,
-+ FIX_VDSO,
-+#ifdef CONFIG_X86_LOCAL_APIC
-+ FIX_APIC_BASE, /* local (CPU) APIC) -- required for SMP or not */
-+#endif
-+#ifdef CONFIG_X86_IO_APIC
-+ FIX_IO_APIC_BASE_0,
-+ FIX_IO_APIC_BASE_END = FIX_IO_APIC_BASE_0 + MAX_IO_APICS-1,
-+#endif
-+#ifdef CONFIG_X86_VISWS_APIC
-+ FIX_CO_CPU, /* Cobalt timer */
-+ FIX_CO_APIC, /* Cobalt APIC Redirection Table */
-+ FIX_LI_PCIA, /* Lithium PCI Bridge A */
-+ FIX_LI_PCIB, /* Lithium PCI Bridge B */
-+#endif
-+#ifdef CONFIG_X86_F00F_BUG
-+ FIX_F00F_IDT, /* Virtual mapping for IDT */
-+#endif
-+#ifdef CONFIG_X86_CYCLONE_TIMER
-+ FIX_CYCLONE_TIMER, /*cyclone timer register*/
-+#endif
-+#ifdef CONFIG_HIGHMEM
-+ FIX_KMAP_BEGIN, /* reserved pte's for temporary kernel mappings */
-+ FIX_KMAP_END = FIX_KMAP_BEGIN+(KM_TYPE_NR*NR_CPUS)-1,
-+#endif
-+#ifdef CONFIG_ACPI
-+ FIX_ACPI_BEGIN,
-+ FIX_ACPI_END = FIX_ACPI_BEGIN + FIX_ACPI_PAGES - 1,
-+#endif
-+#ifdef CONFIG_PCI_MMCONFIG
-+ FIX_PCIE_MCFG,
-+#endif
-+ FIX_SHARED_INFO,
-+#define NR_FIX_ISAMAPS 256
-+ FIX_ISAMAP_END,
-+ FIX_ISAMAP_BEGIN = FIX_ISAMAP_END + NR_FIX_ISAMAPS - 1,
-+ __end_of_permanent_fixed_addresses,
-+ /* temporary boot-time mappings, used before ioremap() is functional */
-+#define NR_FIX_BTMAPS 16
-+ FIX_BTMAP_END = __end_of_permanent_fixed_addresses,
-+ FIX_BTMAP_BEGIN = FIX_BTMAP_END + NR_FIX_BTMAPS - 1,
-+ FIX_WP_TEST,
-+ __end_of_fixed_addresses
-+};
-+
-+extern void __set_fixmap(enum fixed_addresses idx,
-+ maddr_t phys, pgprot_t flags);
-+
-+extern void reserve_top_address(unsigned long reserve);
-+extern void set_fixaddr_top(void);
-+
-+#define set_fixmap(idx, phys) \
-+ __set_fixmap(idx, phys, PAGE_KERNEL)
-+/*
-+ * Some hardware wants to get fixmapped without caching.
-+ */
-+#define set_fixmap_nocache(idx, phys) \
-+ __set_fixmap(idx, phys, PAGE_KERNEL_NOCACHE)
-+
-+#define clear_fixmap(idx) \
-+ __set_fixmap(idx, 0, __pgprot(0))
-+
-+#define FIXADDR_TOP ((unsigned long)__FIXADDR_TOP)
-+
-+#define __FIXADDR_SIZE (__end_of_permanent_fixed_addresses << PAGE_SHIFT)
-+#define __FIXADDR_BOOT_SIZE (__end_of_fixed_addresses << PAGE_SHIFT)
-+#define FIXADDR_START (FIXADDR_TOP - __FIXADDR_SIZE)
-+#define FIXADDR_BOOT_START (FIXADDR_TOP - __FIXADDR_BOOT_SIZE)
-+
-+#define __fix_to_virt(x) (FIXADDR_TOP - ((x) << PAGE_SHIFT))
-+#define __virt_to_fix(x) ((FIXADDR_TOP - ((x)&PAGE_MASK)) >> PAGE_SHIFT)
-+
-+extern void __this_fixmap_does_not_exist(void);
-+
-+/*
-+ * 'index to address' translation. If anyone tries to use the idx
-+ * directly without tranlation, we catch the bug with a NULL-deference
-+ * kernel oops. Illegal ranges of incoming indices are caught too.
-+ */
-+static __always_inline unsigned long fix_to_virt(const unsigned int idx)
-+{
-+ /*
-+ * this branch gets completely eliminated after inlining,
-+ * except when someone tries to use fixaddr indices in an
-+ * illegal way. (such as mixing up address types or using
-+ * out-of-range indices).
-+ *
-+ * If it doesn't get removed, the linker will complain
-+ * loudly with a reasonably clear error message..
-+ */
-+ if (idx >= __end_of_fixed_addresses)
-+ __this_fixmap_does_not_exist();
-+
-+ return __fix_to_virt(idx);
-+}
-+
-+static inline unsigned long virt_to_fix(const unsigned long vaddr)
-+{
-+ BUG_ON(vaddr >= FIXADDR_TOP || vaddr < FIXADDR_START);
-+ return __virt_to_fix(vaddr);
-+}
-+
-+#endif /* !__ASSEMBLY__ */
-+#endif
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/asm-i386/mach-xen/asm/floppy.h source/include/asm-i386/mach-xen/asm/floppy.h
---- /scratch/src/linux-2.6.20.3/include/asm-i386/mach-xen/asm/floppy.h 1970-01-01 01:00:00.000000000 +0100
-+++ source/include/asm-i386/mach-xen/asm/floppy.h 2007-03-20 21:26:56.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/asm-i386/mach-xen/asm/floppy.h
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/include/asm-i386/mach-xen/asm/floppy.h Wed Aug 08 16:25:28 2007 -0300
@@ -0,0 +1,147 @@
+/*
+ * Architecture specific parts of the Floppy driver
@@ -73248,9 +71286,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#define EXTRA_FLOPPY_PARAMS
+
+#endif /* __ASM_XEN_I386_FLOPPY_H */
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/asm-i386/mach-xen/asm/hypercall.h source/include/asm-i386/mach-xen/asm/hypercall.h
---- /scratch/src/linux-2.6.20.3/include/asm-i386/mach-xen/asm/hypercall.h 1970-01-01 01:00:00.000000000 +0100
-+++ source/include/asm-i386/mach-xen/asm/hypercall.h 2007-03-20 21:26:56.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/asm-i386/mach-xen/asm/hypercall.h
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/include/asm-i386/mach-xen/asm/hypercall.h Wed Aug 08 16:25:28 2007 -0300
@@ -0,0 +1,407 @@
+/******************************************************************************
+ * hypercall.h
@@ -73455,11 +71493,11 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+}
+
+static inline int
-+HYPERVISOR_dom0_op(
-+ dom0_op_t *dom0_op)
++HYPERVISOR_platform_op(
++ struct xen_platform_op *platform_op)
+{
-+ dom0_op->interface_version = DOM0_INTERFACE_VERSION;
-+ return _hypercall1(int, dom0_op, dom0_op);
++ platform_op->interface_version = XENPF_INTERFACE_VERSION;
++ return _hypercall1(int, platform_op, platform_op);
+}
+
+static inline int
@@ -73492,7 +71530,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+
+static inline int
+HYPERVISOR_multicall(
-+ void *call_list, int nr_calls)
++ multicall_entry_t *call_list, int nr_calls)
+{
+ return _hypercall2(int, multicall, call_list, nr_calls);
+}
@@ -73515,7 +71553,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+{
+ int rc = _hypercall2(int, event_channel_op, cmd, arg);
+
-+#ifdef CONFIG_XEN_COMPAT_030002
++#if CONFIG_XEN_COMPAT <= 0x030002
+ if (unlikely(rc == -ENOSYS)) {
+ struct evtchn_op op;
+ op.cmd = cmd;
@@ -73555,7 +71593,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+{
+ int rc = _hypercall2(int, physdev_op, cmd, arg);
+
-+#ifdef CONFIG_XEN_COMPAT_030002
++#if CONFIG_XEN_COMPAT <= 0x030002
+ if (unlikely(rc == -ENOSYS)) {
+ struct physdev_op op;
+ op.cmd = cmd;
@@ -73612,7 +71650,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ int rc = _hypercall3(int, sched_op, SCHEDOP_shutdown,
+ &sched_shutdown, srec);
+
-+#ifdef CONFIG_XEN_COMPAT_030002
++#if CONFIG_XEN_COMPAT <= 0x030002
+ if (rc == -ENOSYS)
+ rc = _hypercall3(int, sched_op_compat, SCHEDOP_shutdown,
+ SHUTDOWN_suspend, srec);
@@ -73659,10 +71697,10 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+
+
+#endif /* __HYPERCALL_H__ */
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/asm-i386/mach-xen/asm/hypervisor.h source/include/asm-i386/mach-xen/asm/hypervisor.h
---- /scratch/src/linux-2.6.20.3/include/asm-i386/mach-xen/asm/hypervisor.h 1970-01-01 01:00:00.000000000 +0100
-+++ source/include/asm-i386/mach-xen/asm/hypervisor.h 2007-03-20 21:26:56.000000000 +0100
-@@ -0,0 +1,245 @@
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/asm-i386/mach-xen/asm/hypervisor.h
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/include/asm-i386/mach-xen/asm/hypervisor.h Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,258 @@
+/******************************************************************************
+ * hypervisor.h
+ *
@@ -73703,7 +71741,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#include <linux/version.h>
+#include <linux/errno.h>
+#include <xen/interface/xen.h>
-+#include <xen/interface/dom0_ops.h>
++#include <xen/interface/platform.h>
+#include <xen/interface/event_channel.h>
+#include <xen/interface/physdev.h>
+#include <xen/interface/sched.h>
@@ -73720,6 +71758,13 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+
+extern shared_info_t *HYPERVISOR_shared_info;
+
++#define vcpu_info(cpu) (HYPERVISOR_shared_info->vcpu_info + (cpu))
++#ifdef CONFIG_SMP
++#define current_vcpu_info() vcpu_info(smp_processor_id())
++#else
++#define current_vcpu_info() vcpu_info(0)
++#endif
++
+#ifdef CONFIG_X86_32
+extern unsigned long hypervisor_virt_start;
+#endif
@@ -73780,7 +71825,13 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+/* Turn jiffies into Xen system time. */
+u64 jiffies_to_st(unsigned long jiffies);
+
-+#include <asm/hypercall.h>
++#ifdef CONFIG_XEN_SCRUB_PAGES
++#define scrub_pages(_p,_n) memset((void *)(_p), 0, (_n) << PAGE_SHIFT)
++#else
++#define scrub_pages(_p,_n) ((void)0)
++#endif
++
++#include <xen/hypercall.h>
+
+#if defined(CONFIG_X86_64)
+#define MULTI_UVMFLAGS_INDEX 2
@@ -73798,7 +71849,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+{
+ int rc = HYPERVISOR_sched_op(SCHEDOP_yield, NULL);
+
-+#ifdef CONFIG_XEN_COMPAT_030002
++#if CONFIG_XEN_COMPAT <= 0x030002
+ if (rc == -ENOSYS)
+ rc = HYPERVISOR_sched_op_compat(SCHEDOP_yield, 0);
+#endif
@@ -73812,7 +71863,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+{
+ int rc = HYPERVISOR_sched_op(SCHEDOP_block, NULL);
+
-+#ifdef CONFIG_XEN_COMPAT_030002
++#if CONFIG_XEN_COMPAT <= 0x030002
+ if (rc == -ENOSYS)
+ rc = HYPERVISOR_sched_op_compat(SCHEDOP_block, 0);
+#endif
@@ -73830,7 +71881,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+
+ int rc = HYPERVISOR_sched_op(SCHEDOP_shutdown, &sched_shutdown);
+
-+#ifdef CONFIG_XEN_COMPAT_030002
++#if CONFIG_XEN_COMPAT <= 0x030002
+ if (rc == -ENOSYS)
+ rc = HYPERVISOR_sched_op_compat(SCHEDOP_shutdown, reason);
+#endif
@@ -73850,7 +71901,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ set_xen_guest_handle(sched_poll.ports, ports);
+
+ rc = HYPERVISOR_sched_op(SCHEDOP_poll, &sched_poll);
-+#ifdef CONFIG_XEN_COMPAT_030002
++#if CONFIG_XEN_COMPAT <= 0x030002
+ if (rc == -ENOSYS)
+ rc = HYPERVISOR_sched_op_compat(SCHEDOP_yield, 0);
+#endif
@@ -73908,9 +71959,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+}
+
+#endif /* __HYPERVISOR_H__ */
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/asm-i386/mach-xen/asm/io.h source/include/asm-i386/mach-xen/asm/io.h
---- /scratch/src/linux-2.6.20.3/include/asm-i386/mach-xen/asm/io.h 1970-01-01 01:00:00.000000000 +0100
-+++ source/include/asm-i386/mach-xen/asm/io.h 2007-03-20 21:26:56.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/asm-i386/mach-xen/asm/io.h
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/include/asm-i386/mach-xen/asm/io.h Wed Aug 08 16:25:28 2007 -0300
@@ -0,0 +1,369 @@
+#ifndef _ASM_IO_H
+#define _ASM_IO_H
@@ -74281,10 +72332,10 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#define ARCH_HAS_DEV_MEM
+
+#endif
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/asm-i386/mach-xen/asm/irqflags.h source/include/asm-i386/mach-xen/asm/irqflags.h
---- /scratch/src/linux-2.6.20.3/include/asm-i386/mach-xen/asm/irqflags.h 1970-01-01 01:00:00.000000000 +0100
-+++ source/include/asm-i386/mach-xen/asm/irqflags.h 2007-03-20 21:26:56.000000000 +0100
-@@ -0,0 +1,96 @@
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/asm-i386/mach-xen/asm/irqflags.h
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/include/asm-i386/mach-xen/asm/irqflags.h Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,129 @@
+/*
+ * include/asm-i386/irqflags.h
+ *
@@ -74302,11 +72353,39 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#else
+#ifndef __ASSEMBLY__
+
-+unsigned long __raw_local_save_flags(void);
++#define __raw_local_save_flags() (current_vcpu_info()->evtchn_upcall_mask)
+
-+void raw_local_irq_restore(unsigned long flags);
-+void raw_local_irq_disable(void);
-+void raw_local_irq_enable(void);
++#define raw_local_save_flags(flags) \
++ do { (flags) = __raw_local_save_flags(); } while (0)
++
++#define raw_local_irq_restore(x) \
++do { \
++ vcpu_info_t *_vcpu; \
++ barrier(); \
++ _vcpu = current_vcpu_info(); \
++ if ((_vcpu->evtchn_upcall_mask = (x)) == 0) { \
++ barrier(); /* unmask then check (avoid races) */ \
++ if (unlikely(_vcpu->evtchn_upcall_pending)) \
++ force_evtchn_callback(); \
++ } \
++} while (0)
++
++#define raw_local_irq_disable() \
++do { \
++ current_vcpu_info()->evtchn_upcall_mask = 1; \
++ barrier(); \
++} while (0)
++
++#define raw_local_irq_enable() \
++do { \
++ vcpu_info_t *_vcpu; \
++ barrier(); \
++ _vcpu = current_vcpu_info(); \
++ _vcpu->evtchn_upcall_mask = 0; \
++ barrier(); /* unmask then check (avoid races) */ \
++ if (unlikely(_vcpu->evtchn_upcall_pending)) \
++ force_evtchn_callback(); \
++} while (0)
+
+/*
+ * Used in the idle loop; sti takes one instruction cycle
@@ -74323,7 +72402,14 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+/*
+ * For spinlocks, etc:
+ */
-+unsigned long __raw_local_irq_save(void);
++#define __raw_local_irq_save() \
++({ \
++ unsigned long flags = __raw_local_save_flags(); \
++ \
++ raw_local_irq_disable(); \
++ \
++ flags; \
++})
+
+#else
+#define DISABLE_INTERRUPTS(clobbers) GET_VCPU_INFO ; \
@@ -74337,8 +72423,6 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#endif /* CONFIG_PARAVIRT */
+
+#ifndef __ASSEMBLY__
-+#define raw_local_save_flags(flags) \
-+ do { (flags) = __raw_local_save_flags(); } while (0)
+
+#define raw_local_irq_save(flags) \
+ do { (flags) = __raw_local_irq_save(); } while (0)
@@ -74381,10 +72465,10 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#endif
+
+#endif
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/asm-i386/mach-xen/asm/maddr.h source/include/asm-i386/mach-xen/asm/maddr.h
---- /scratch/src/linux-2.6.20.3/include/asm-i386/mach-xen/asm/maddr.h 1970-01-01 01:00:00.000000000 +0100
-+++ source/include/asm-i386/mach-xen/asm/maddr.h 2007-03-20 21:26:56.000000000 +0100
-@@ -0,0 +1,176 @@
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/asm-i386/mach-xen/asm/maddr.h
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/include/asm-i386/mach-xen/asm/maddr.h Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,193 @@
+#ifndef _I386_MADDR_H
+#define _I386_MADDR_H
+
@@ -74408,6 +72492,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#ifdef CONFIG_XEN
+
+extern unsigned long *phys_to_machine_mapping;
++extern unsigned long max_mapnr;
+
+#undef machine_to_phys_mapping
+extern unsigned long *machine_to_phys_mapping;
@@ -74417,20 +72502,20 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+{
+ if (xen_feature(XENFEAT_auto_translated_physmap))
+ return pfn;
-+ return phys_to_machine_mapping[(unsigned int)(pfn)] &
-+ ~FOREIGN_FRAME_BIT;
++ BUG_ON(max_mapnr && pfn >= max_mapnr);
++ return phys_to_machine_mapping[pfn] & ~FOREIGN_FRAME_BIT;
+}
+
+static inline int phys_to_machine_mapping_valid(unsigned long pfn)
+{
+ if (xen_feature(XENFEAT_auto_translated_physmap))
+ return 1;
++ BUG_ON(max_mapnr && pfn >= max_mapnr);
+ return (phys_to_machine_mapping[pfn] != INVALID_P2M_ENTRY);
+}
+
+static inline unsigned long mfn_to_pfn(unsigned long mfn)
+{
-+ extern unsigned long max_mapnr;
+ unsigned long pfn;
+
+ if (xen_feature(XENFEAT_auto_translated_physmap))
@@ -74479,7 +72564,6 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ */
+static inline unsigned long mfn_to_local_pfn(unsigned long mfn)
+{
-+ extern unsigned long max_mapnr;
+ unsigned long pfn = mfn_to_pfn(mfn);
+ if ((pfn < max_mapnr)
+ && !xen_feature(XENFEAT_auto_translated_physmap)
@@ -74490,6 +72574,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+
+static inline void set_phys_to_machine(unsigned long pfn, unsigned long mfn)
+{
++ BUG_ON(max_mapnr && pfn >= max_mapnr);
+ if (xen_feature(XENFEAT_auto_translated_physmap)) {
+ BUG_ON(pfn != mfn && mfn != INVALID_P2M_ENTRY);
+ return;
@@ -74511,6 +72596,20 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ return phys;
+}
+
++#ifdef CONFIG_X86_PAE
++static inline paddr_t pte_phys_to_machine(paddr_t phys)
++{
++ /*
++ * In PAE mode, the NX bit needs to be dealt with in the value
++ * passed to pfn_to_mfn(). On x86_64, we need to mask it off,
++ * but for i386 the conversion to ulong for the argument will
++ * clip it off.
++ */
++ maddr_t machine = pfn_to_mfn(phys >> PAGE_SHIFT);
++ machine = (machine << PAGE_SHIFT) | (phys & ~PHYSICAL_PAGE_MASK);
++ return machine;
++}
++
+static inline paddr_t pte_machine_to_phys(maddr_t machine)
+{
+ /*
@@ -74523,24 +72622,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ phys = (phys << PAGE_SHIFT) | (machine & ~PHYSICAL_PAGE_MASK);
+ return phys;
+}
-+
-+#else /* !CONFIG_XEN */
-+
-+#define pfn_to_mfn(pfn) (pfn)
-+#define mfn_to_pfn(mfn) (mfn)
-+#define mfn_to_local_pfn(mfn) (mfn)
-+#define set_phys_to_machine(pfn, mfn) BUG_ON((pfn) != (mfn))
-+#define phys_to_machine_mapping_valid(pfn) (1)
-+#define phys_to_machine(phys) ((maddr_t)(phys))
-+#define machine_to_phys(mach) ((paddr_t)(mach))
-+#define pte_machine_to_phys(mach) ((paddr_t)(mach))
-+
-+#endif /* !CONFIG_XEN */
-+
-+/* VIRT <-> MACHINE conversion */
-+#define virt_to_machine(v) (phys_to_machine(__pa(v)))
-+#define virt_to_mfn(v) (pfn_to_mfn(__pa(v) >> PAGE_SHIFT))
-+#define mfn_to_virt(m) (__va(mfn_to_pfn(m) << PAGE_SHIFT))
++#endif
+
+#ifdef CONFIG_X86_PAE
+static inline pte_t pfn_pte_ma(unsigned long page_nr, pgprot_t pgprot)
@@ -74560,10 +72642,29 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+
+#define __pte_ma(x) ((pte_t) { (x) } )
+
++#else /* !CONFIG_XEN */
++
++#define pfn_to_mfn(pfn) (pfn)
++#define mfn_to_pfn(mfn) (mfn)
++#define mfn_to_local_pfn(mfn) (mfn)
++#define set_phys_to_machine(pfn, mfn) ((void)0)
++#define phys_to_machine_mapping_valid(pfn) (1)
++#define phys_to_machine(phys) ((maddr_t)(phys))
++#define machine_to_phys(mach) ((paddr_t)(mach))
++#define pfn_pte_ma(pfn, prot) pfn_pte(pfn, prot)
++#define __pte_ma(x) __pte(x)
++
++#endif /* !CONFIG_XEN */
++
++/* VIRT <-> MACHINE conversion */
++#define virt_to_machine(v) (phys_to_machine(__pa(v)))
++#define virt_to_mfn(v) (pfn_to_mfn(__pa(v) >> PAGE_SHIFT))
++#define mfn_to_virt(m) (__va(mfn_to_pfn(m) << PAGE_SHIFT))
++
+#endif /* _I386_MADDR_H */
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/asm-i386/mach-xen/asm/mmu_context.h source/include/asm-i386/mach-xen/asm/mmu_context.h
---- /scratch/src/linux-2.6.20.3/include/asm-i386/mach-xen/asm/mmu_context.h 1970-01-01 01:00:00.000000000 +0100
-+++ source/include/asm-i386/mach-xen/asm/mmu_context.h 2007-03-20 21:26:56.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/asm-i386/mach-xen/asm/mmu_context.h
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/include/asm-i386/mach-xen/asm/mmu_context.h Wed Aug 08 16:25:28 2007 -0300
@@ -0,0 +1,107 @@
+#ifndef __I386_SCHED_H
+#define __I386_SCHED_H
@@ -74672,10 +72773,10 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+}
+
+#endif
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/asm-i386/mach-xen/asm/page.h source/include/asm-i386/mach-xen/asm/page.h
---- /scratch/src/linux-2.6.20.3/include/asm-i386/mach-xen/asm/page.h 1970-01-01 01:00:00.000000000 +0100
-+++ source/include/asm-i386/mach-xen/asm/page.h 2007-03-20 21:26:56.000000000 +0100
-@@ -0,0 +1,235 @@
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/asm-i386/mach-xen/asm/page.h
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/include/asm-i386/mach-xen/asm/page.h Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,233 @@
+#ifndef _I386_PAGE_H
+#define _I386_PAGE_H
+
@@ -74685,7 +72786,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#define PAGE_MASK (~(PAGE_SIZE-1))
+
+#ifdef CONFIG_X86_PAE
-+#define __PHYSICAL_MASK_SHIFT 36
++#define __PHYSICAL_MASK_SHIFT 40
+#define __PHYSICAL_MASK ((1ULL << __PHYSICAL_MASK_SHIFT) - 1)
+#define PHYSICAL_PAGE_MASK (~((1ULL << PAGE_SHIFT) - 1) & __PHYSICAL_MASK)
+#else
@@ -74698,6 +72799,14 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#define LARGE_PAGE_SIZE (1UL << PMD_SHIFT)
+
+#ifdef __KERNEL__
++
++/*
++ * Need to repeat this here in order to not include pgtable.h (which in turn
++ * depends on definitions made here), but to be able to use the symbolic
++ * below. The preprocessor will warn if the two definitions aren't identical.
++ */
++#define _PAGE_PRESENT 0x001
++
+#ifndef __ASSEMBLY__
+
+#include <linux/string.h>
@@ -74706,22 +72815,15 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#include <asm/bug.h>
+#include <xen/interface/xen.h>
+#include <xen/features.h>
-+#include <xen/foreign_page.h>
+
-+#define arch_free_page(_page,_order) \
-+({ int foreign = PageForeign(_page); \
-+ if (foreign) \
-+ (PageForeignDestructor(_page))(_page); \
-+ foreign; \
++#define arch_free_page(_page,_order) \
++({ int foreign = PageForeign(_page); \
++ if (foreign) \
++ PageForeignDestructor(_page); \
++ foreign; \
+})
+#define HAVE_ARCH_FREE_PAGE
+
-+#ifdef CONFIG_XEN_SCRUB_PAGES
-+#define scrub_pages(_p,_n) memset((void *)(_p), 0, (_n) << PAGE_SHIFT)
-+#else
-+#define scrub_pages(_p,_n) ((void)0)
-+#endif
-+
+#ifdef CONFIG_X86_USE_3DNOW
+
+#include <asm/mmx.h>
@@ -74760,40 +72862,38 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#define pgprot_val(x) ((x).pgprot)
+#include <asm/maddr.h>
+#define __pte(x) ({ unsigned long long _x = (x); \
-+ if (_x & 1) _x = phys_to_machine(_x); \
++ if (_x & _PAGE_PRESENT) _x = pte_phys_to_machine(_x); \
+ ((pte_t) {(unsigned long)(_x), (unsigned long)(_x>>32)}); })
+#define __pgd(x) ({ unsigned long long _x = (x); \
-+ (((_x)&1) ? ((pgd_t) {phys_to_machine(_x)}) : ((pgd_t) {(_x)})); })
++ (pgd_t) {((_x) & _PAGE_PRESENT) ? pte_phys_to_machine(_x) : (_x)}; })
+#define __pmd(x) ({ unsigned long long _x = (x); \
-+ (((_x)&1) ? ((pmd_t) {phys_to_machine(_x)}) : ((pmd_t) {(_x)})); })
++ (pmd_t) {((_x) & _PAGE_PRESENT) ? pte_phys_to_machine(_x) : (_x)}; })
++static inline unsigned long long pte_val_ma(pte_t x)
++{
++ return ((unsigned long long)x.pte_high << 32) | x.pte_low;
++}
+static inline unsigned long long pte_val(pte_t x)
+{
-+ unsigned long long ret;
-+
-+ if (x.pte_low) {
-+ ret = x.pte_low | (unsigned long long)x.pte_high << 32;
-+ ret = pte_machine_to_phys(ret) | 1;
-+ } else {
-+ ret = 0;
-+ }
++ unsigned long long ret = pte_val_ma(x);
++ if (x.pte_low & _PAGE_PRESENT) ret = pte_machine_to_phys(ret);
+ return ret;
+}
+static inline unsigned long long pmd_val(pmd_t x)
+{
+ unsigned long long ret = x.pmd;
-+ if (ret) ret = pte_machine_to_phys(ret) | 1;
++#if CONFIG_XEN_COMPAT <= 0x030002
++ if (ret) ret = pte_machine_to_phys(ret) | _PAGE_PRESENT;
++#else
++ if (ret & _PAGE_PRESENT) ret = pte_machine_to_phys(ret);
++#endif
+ return ret;
+}
+static inline unsigned long long pgd_val(pgd_t x)
+{
+ unsigned long long ret = x.pgd;
-+ if (ret) ret = pte_machine_to_phys(ret) | 1;
++ if (ret & _PAGE_PRESENT) ret = pte_machine_to_phys(ret);
+ return ret;
+}
-+static inline unsigned long long pte_val_ma(pte_t x)
-+{
-+ return (unsigned long long)x.pte_high << 32 | x.pte_low;
-+}
+#define HPAGE_SHIFT 21
+#include <asm-generic/pgtable-nopud.h>
+#else
@@ -74803,24 +72903,28 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#define pgprot_val(x) ((x).pgprot)
+#include <asm/maddr.h>
+#define boot_pte_t pte_t /* or would you rather have a typedef */
-+#define pte_val(x) (((x).pte_low & 1) ? \
-+ pte_machine_to_phys((x).pte_low) : \
++#define pte_val(x) (((x).pte_low & _PAGE_PRESENT) ? \
++ machine_to_phys((x).pte_low) : \
+ (x).pte_low)
+#define pte_val_ma(x) ((x).pte_low)
+#define __pte(x) ({ unsigned long _x = (x); \
-+ (((_x)&1) ? ((pte_t) {phys_to_machine(_x)}) : ((pte_t) {(_x)})); })
++ (pte_t) {((_x) & _PAGE_PRESENT) ? phys_to_machine(_x) : (_x)}; })
+#define __pgd(x) ({ unsigned long _x = (x); \
-+ (((_x)&1) ? ((pgd_t) {phys_to_machine(_x)}) : ((pgd_t) {(_x)})); })
++ (pgd_t) {((_x) & _PAGE_PRESENT) ? phys_to_machine(_x) : (_x)}; })
+static inline unsigned long pgd_val(pgd_t x)
+{
+ unsigned long ret = x.pgd;
-+ if (ret) ret = pte_machine_to_phys(ret) | 1;
++#if CONFIG_XEN_COMPAT <= 0x030002
++ if (ret) ret = machine_to_phys(ret) | _PAGE_PRESENT;
++#else
++ if (ret & _PAGE_PRESENT) ret = machine_to_phys(ret);
++#endif
+ return ret;
+}
+#define HPAGE_SHIFT 22
+#include <asm-generic/pgtable-nopmd.h>
+#endif
-+#define PTE_MASK PAGE_MASK
++#define PTE_MASK PHYSICAL_PAGE_MASK
+
+#ifdef CONFIG_HUGETLB_PAGE
+#define HPAGE_SIZE ((1UL) << HPAGE_SHIFT)
@@ -74871,10 +72975,10 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#define __PAGE_OFFSET ((unsigned long)CONFIG_PAGE_OFFSET)
+#endif
+
-+#ifdef CONFIG_XEN_COMPAT_030002
++#if CONFIG_XEN_COMPAT <= 0x030002
+#undef LOAD_OFFSET
+#define LOAD_OFFSET 0
-+#endif /* CONFIG_XEN_COMPAT_030002 */
++#endif
+
+#define PAGE_OFFSET ((unsigned long)__PAGE_OFFSET)
+#define VMALLOC_RESERVE ((unsigned long)__VMALLOC_RESERVE)
@@ -74897,11 +73001,6 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ ((current->personality & READ_IMPLIES_EXEC) ? VM_EXEC : 0 ) | \
+ VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
+
-+/* VIRT <-> MACHINE conversion */
-+#define virt_to_machine(v) (phys_to_machine(__pa(v)))
-+#define virt_to_mfn(v) (pfn_to_mfn(__pa(v) >> PAGE_SHIFT))
-+#define mfn_to_virt(m) (__va(mfn_to_pfn(m) << PAGE_SHIFT))
-+
+#include <asm-generic/memory_model.h>
+#include <asm-generic/page.h>
+
@@ -74911,77 +73010,10 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#endif /* __KERNEL__ */
+
+#endif /* _I386_PAGE_H */
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/asm-i386/mach-xen/asm/pgalloc.h source/include/asm-i386/mach-xen/asm/pgalloc.h
---- /scratch/src/linux-2.6.20.3/include/asm-i386/mach-xen/asm/pgalloc.h 1970-01-01 01:00:00.000000000 +0100
-+++ source/include/asm-i386/mach-xen/asm/pgalloc.h 2007-03-20 21:26:56.000000000 +0100
-@@ -0,0 +1,63 @@
-+#ifndef _I386_PGALLOC_H
-+#define _I386_PGALLOC_H
-+
-+#include <asm/fixmap.h>
-+#include <linux/threads.h>
-+#include <linux/mm.h> /* for struct page */
-+#include <asm/io.h> /* for phys_to_virt and page_to_pseudophys */
-+
-+/* Is this pagetable pinned? */
-+#define PG_pinned PG_arch_1
-+
-+#define pmd_populate_kernel(mm, pmd, pte) \
-+ set_pmd(pmd, __pmd(_PAGE_TABLE + __pa(pte)))
-+
-+#define pmd_populate(mm, pmd, pte) \
-+do { \
-+ if (test_bit(PG_pinned, &virt_to_page((mm)->pgd)->flags)) { \
-+ if (!PageHighMem(pte)) \
-+ BUG_ON(HYPERVISOR_update_va_mapping( \
-+ (unsigned long)__va(page_to_pfn(pte)<<PAGE_SHIFT),\
-+ pfn_pte(page_to_pfn(pte), PAGE_KERNEL_RO), 0));\
-+ set_pmd(pmd, __pmd(_PAGE_TABLE + \
-+ ((unsigned long long)page_to_pfn(pte) << \
-+ (unsigned long long) PAGE_SHIFT))); \
-+ } else { \
-+ *(pmd) = __pmd(_PAGE_TABLE + \
-+ ((unsigned long long)page_to_pfn(pte) << \
-+ (unsigned long long) PAGE_SHIFT)); \
-+ } \
-+} while (0)
-+
-+/*
-+ * Allocate and free page tables.
-+ */
-+extern pgd_t *pgd_alloc(struct mm_struct *);
-+extern void pgd_free(pgd_t *pgd);
-+
-+extern pte_t *pte_alloc_one_kernel(struct mm_struct *, unsigned long);
-+extern struct page *pte_alloc_one(struct mm_struct *, unsigned long);
-+
-+static inline void pte_free_kernel(pte_t *pte)
-+{
-+ free_page((unsigned long)pte);
-+ make_page_writable(pte, XENFEAT_writable_page_tables);
-+}
-+
-+extern void pte_free(struct page *pte);
-+
-+#define __pte_free_tlb(tlb,pte) tlb_remove_page((tlb),(pte))
-+
-+#ifdef CONFIG_X86_PAE
-+/*
-+ * In the PAE case we free the pmds as part of the pgd.
-+ */
-+#define pmd_alloc_one(mm, addr) ({ BUG(); ((pmd_t *)2); })
-+#define pmd_free(x) do { } while (0)
-+#define __pmd_free_tlb(tlb,x) do { } while (0)
-+#define pud_populate(mm, pmd, pte) BUG()
-+#endif
-+
-+#define check_pgt_cache() do { } while (0)
-+
-+#endif /* _I386_PGALLOC_H */
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/asm-i386/mach-xen/asm/pgtable-2level.h source/include/asm-i386/mach-xen/asm/pgtable-2level.h
---- /scratch/src/linux-2.6.20.3/include/asm-i386/mach-xen/asm/pgtable-2level.h 1970-01-01 01:00:00.000000000 +0100
-+++ source/include/asm-i386/mach-xen/asm/pgtable-2level.h 2007-03-20 21:26:56.000000000 +0100
-@@ -0,0 +1,77 @@
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/asm-i386/mach-xen/asm/pgtable-2level.h
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/include/asm-i386/mach-xen/asm/pgtable-2level.h Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,110 @@
+#ifndef _I386_PGTABLE_2LEVEL_H
+#define _I386_PGTABLE_2LEVEL_H
+
@@ -75012,12 +73044,45 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#define pte_clear(mm,addr,xp) do { set_pte_at(mm, addr, xp, __pte(0)); } while (0)
+#define pmd_clear(xp) do { set_pmd(xp, __pmd(0)); } while (0)
+
-+#define raw_ptep_get_and_clear(xp) __pte_ma(xchg(&(xp)->pte_low, 0))
++#define pte_none(x) (!(x).pte_low)
++
++#define __HAVE_ARCH_PTEP_GET_AND_CLEAR
++static inline pte_t ptep_get_and_clear(struct mm_struct *mm, unsigned long addr, pte_t *ptep)
++{
++ pte_t pte = *ptep;
++ if (!pte_none(pte)) {
++ if (mm != &init_mm)
++ pte = __pte_ma(xchg(&ptep->pte_low, 0));
++ else
++ HYPERVISOR_update_va_mapping(addr, __pte(0), 0);
++ }
++ return pte;
++}
++
++#define __HAVE_ARCH_PTEP_CLEAR_FLUSH
++#define ptep_clear_flush(vma, addr, ptep) \
++({ \
++ pte_t *__ptep = (ptep); \
++ pte_t __res = *__ptep; \
++ if (!pte_none(__res) && \
++ ((vma)->vm_mm != current->mm || \
++ HYPERVISOR_update_va_mapping(addr, __pte(0), \
++ (unsigned long)(vma)->vm_mm->cpu_vm_mask.bits| \
++ UVMF_INVLPG|UVMF_MULTI))) { \
++ __ptep->pte_low = 0; \
++ flush_tlb_page(vma, addr); \
++ } \
++ __res; \
++})
++
++#define __pte_mfn(_pte) ((_pte).pte_low >> PAGE_SHIFT)
++#define pte_mfn(_pte) ((_pte).pte_low & _PAGE_PRESENT ? \
++ __pte_mfn(_pte) : pfn_to_mfn(__pte_mfn(_pte)))
++#define pte_pfn(_pte) ((_pte).pte_low & _PAGE_PRESENT ? \
++ mfn_to_local_pfn(__pte_mfn(_pte)) : __pte_mfn(_pte))
++
++#define pte_page(x) pfn_to_page(pte_pfn(x))
+
-+#define pte_mfn(_pte) ((_pte).pte_low >> PAGE_SHIFT)
-+#define pte_page(x) pfn_to_page(pte_pfn(x))
-+#define pte_none(x) (!(x).pte_low)
-+#define pte_pfn(x) mfn_to_local_pfn(pte_mfn(x))
+#define pfn_pte(pfn, prot) __pte(((pfn) << PAGE_SHIFT) | pgprot_val(prot))
+#define pfn_pmd(pfn, prot) __pmd(((pfn) << PAGE_SHIFT) | pgprot_val(prot))
+
@@ -75059,10 +73124,10 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+void vmalloc_sync_all(void);
+
+#endif /* _I386_PGTABLE_2LEVEL_H */
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/asm-i386/mach-xen/asm/pgtable-3level.h source/include/asm-i386/mach-xen/asm/pgtable-3level.h
---- /scratch/src/linux-2.6.20.3/include/asm-i386/mach-xen/asm/pgtable-3level.h 1970-01-01 01:00:00.000000000 +0100
-+++ source/include/asm-i386/mach-xen/asm/pgtable-3level.h 2007-03-20 21:26:56.000000000 +0100
-@@ -0,0 +1,194 @@
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/asm-i386/mach-xen/asm/pgtable-3level.h
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/include/asm-i386/mach-xen/asm/pgtable-3level.h Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,216 @@
+#ifndef _I386_PGTABLE_3LEVEL_H
+#define _I386_PGTABLE_3LEVEL_H
+
@@ -75116,15 +73181,13 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ */
+#define __HAVE_ARCH_SET_PTE_ATOMIC
+
-+#if 1
-+/* use writable pagetables */
+static inline void set_pte(pte_t *ptep, pte_t pte)
+{
+ ptep->pte_high = pte.pte_high;
+ smp_wmb();
+ ptep->pte_low = pte.pte_low;
+}
-+# define set_pte_atomic(pteptr,pteval) \
++#define set_pte_atomic(pteptr,pteval) \
+ set_64bit((unsigned long long *)(pteptr),pte_val_ma(pteval))
+
+/*
@@ -75141,13 +73204,6 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ smp_wmb();
+ ptep->pte_low = pte.pte_low;
+}
-+#else
-+/* no writable pagetables */
-+# define set_pte(pteptr,pteval) \
-+ xen_l1_entry_update((pteptr), (pteval))
-+# define set_pte_atomic(pteptr,pteval) set_pte(pteptr,pteval)
-+# define set_pte_pressent(mm,addr,ptep,pte) set_pte_at(mm,addr,ptep,pteval)
-+#endif
+
+#define set_pte_at(_mm,addr,ptep,pteval) do { \
+ if (((_mm) != current->mm && (_mm) != &init_mm) || \
@@ -75160,31 +73216,6 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#define set_pud(pudptr,pudval) \
+ xen_l3_entry_update((pudptr), (pudval))
+
-+/*
-+ * For PTEs and PDEs, we must clear the P-bit first when clearing a page table
-+ * entry, so clear the bottom half first and enforce ordering with a compiler
-+ * barrier.
-+ */
-+static inline void pte_clear(struct mm_struct *mm, unsigned long addr, pte_t *ptep)
-+{
-+ ptep->pte_low = 0;
-+ smp_wmb();
-+ ptep->pte_high = 0;
-+}
-+
-+#define pmd_clear(xp) do { set_pmd(xp, __pmd(0)); } while (0)
-+
-+static inline pte_t raw_ptep_get_and_clear(pte_t *ptep)
-+{
-+ pte_t res;
-+
-+ /* xchg acts as a barrier before the setting of the high bits */
-+ res.pte_low = xchg(&ptep->pte_low, 0);
-+ res.pte_high = ptep->pte_high;
-+ ptep->pte_high = 0;
-+
-+ return res;
-+}
+#endif
+
+/*
@@ -75206,6 +73237,64 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#define pmd_offset(pud, address) ((pmd_t *) pud_page(*(pud)) + \
+ pmd_index(address))
+
++static inline int pte_none(pte_t pte)
++{
++ return !(pte.pte_low | pte.pte_high);
++}
++
++/*
++ * For PTEs and PDEs, we must clear the P-bit first when clearing a page table
++ * entry, so clear the bottom half first and enforce ordering with a compiler
++ * barrier.
++ */
++static inline void pte_clear(struct mm_struct *mm, unsigned long addr, pte_t *ptep)
++{
++ if ((mm != current->mm && mm != &init_mm)
++ || HYPERVISOR_update_va_mapping(addr, __pte(0), 0)) {
++ ptep->pte_low = 0;
++ smp_wmb();
++ ptep->pte_high = 0;
++ }
++}
++
++#define pmd_clear(xp) do { set_pmd(xp, __pmd(0)); } while (0)
++
++static inline pte_t raw_ptep_get_and_clear(struct mm_struct *mm, unsigned long addr, pte_t *ptep)
++{
++ pte_t pte = *ptep;
++ if (!pte_none(pte)) {
++ if (mm != &init_mm) {
++ uint64_t val = pte_val_ma(pte);
++ if (__cmpxchg64(ptep, val, 0) != val) {
++ /* xchg acts as a barrier before the setting of the high bits */
++ pte.pte_low = xchg(&ptep->pte_low, 0);
++ pte.pte_high = ptep->pte_high;
++ ptep->pte_high = 0;
++ }
++ } else
++ HYPERVISOR_update_va_mapping(addr, __pte(0), 0);
++ }
++ return pte;
++}
++
++#define __HAVE_ARCH_PTEP_CLEAR_FLUSH
++#define ptep_clear_flush(vma, addr, ptep) \
++({ \
++ pte_t *__ptep = (ptep); \
++ pte_t __res = *__ptep; \
++ if (!pte_none(__res) && \
++ ((vma)->vm_mm != current->mm || \
++ HYPERVISOR_update_va_mapping(addr, __pte(0), \
++ (unsigned long)(vma)->vm_mm->cpu_vm_mask.bits| \
++ UVMF_INVLPG|UVMF_MULTI))) { \
++ __ptep->pte_low = 0; \
++ smp_wmb(); \
++ __ptep->pte_high = 0; \
++ flush_tlb_page(vma, addr); \
++ } \
++ __res; \
++})
++
+#define __HAVE_ARCH_PTE_SAME
+static inline int pte_same(pte_t a, pte_t b)
+{
@@ -75214,26 +73303,24 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+
+#define pte_page(x) pfn_to_page(pte_pfn(x))
+
-+static inline int pte_none(pte_t pte)
-+{
-+ return !pte.pte_low && !pte.pte_high;
-+}
-+
-+#define pte_mfn(_pte) (((_pte).pte_low >> PAGE_SHIFT) |\
-+ (((_pte).pte_high & 0xfff) << (32-PAGE_SHIFT)))
-+#define pte_pfn(_pte) mfn_to_local_pfn(pte_mfn(_pte))
++#define __pte_mfn(_pte) (((_pte).pte_low >> PAGE_SHIFT) | \
++ ((_pte).pte_high << (32-PAGE_SHIFT)))
++#define pte_mfn(_pte) ((_pte).pte_low & _PAGE_PRESENT ? \
++ __pte_mfn(_pte) : pfn_to_mfn(__pte_mfn(_pte)))
++#define pte_pfn(_pte) ((_pte).pte_low & _PAGE_PRESENT ? \
++ mfn_to_local_pfn(__pte_mfn(_pte)) : __pte_mfn(_pte))
+
+extern unsigned long long __supported_pte_mask;
+
+static inline pte_t pfn_pte(unsigned long page_nr, pgprot_t pgprot)
+{
-+ return pfn_pte_ma(pfn_to_mfn(page_nr), pgprot);
++ return __pte((((unsigned long long)page_nr << PAGE_SHIFT) |
++ pgprot_val(pgprot)) & __supported_pte_mask);
+}
+
+static inline pmd_t pfn_pmd(unsigned long page_nr, pgprot_t pgprot)
+{
-+ BUG(); panic("needs review");
-+ return __pmd((((unsigned long long)page_nr << PAGE_SHIFT) | \
++ return __pmd((((unsigned long long)page_nr << PAGE_SHIFT) |
+ pgprot_val(pgprot)) & __supported_pte_mask);
+}
+
@@ -75254,13 +73341,13 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+
+#define __pmd_free_tlb(tlb, x) do { } while (0)
+
-+#define vmalloc_sync_all() ((void)0)
++void vmalloc_sync_all(void);
+
+#endif /* _I386_PGTABLE_3LEVEL_H */
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/asm-i386/mach-xen/asm/pgtable.h source/include/asm-i386/mach-xen/asm/pgtable.h
---- /scratch/src/linux-2.6.20.3/include/asm-i386/mach-xen/asm/pgtable.h 1970-01-01 01:00:00.000000000 +0100
-+++ source/include/asm-i386/mach-xen/asm/pgtable.h 2007-03-20 21:26:56.000000000 +0100
-@@ -0,0 +1,561 @@
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/asm-i386/mach-xen/asm/pgtable.h
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/include/asm-i386/mach-xen/asm/pgtable.h Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,568 @@
+#ifndef _I386_PGTABLE_H
+#define _I386_PGTABLE_H
+
@@ -75289,6 +73376,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#include <linux/list.h>
+#include <linux/spinlock.h>
+
++/* Is this pagetable pinned? */
++#define PG_pinned PG_arch_1
++
+struct mm_struct;
+struct vm_area_struct;
+
@@ -75471,9 +73561,13 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+
+/* To avoid harmful races, pmd_none(x) should check only the lower when PAE */
+#define pmd_none(x) (!(unsigned long)pmd_val(x))
++#if CONFIG_XEN_COMPAT <= 0x030002
+/* pmd_present doesn't just test the _PAGE_PRESENT bit since wr.p.t.
+ can temporarily clear it. */
+#define pmd_present(x) (pmd_val(x))
++#else
++#define pmd_present(x) (pmd_val(x) & _PAGE_PRESENT)
++#endif
+#define pmd_bad(x) ((pmd_val(x) & (~PAGE_MASK & ~_PAGE_USER & ~_PAGE_PRESENT)) != (_KERNPG_TABLE & ~_PAGE_PRESENT))
+
+
@@ -75532,28 +73626,6 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#endif
+
+/*
-+ * We only update the dirty/accessed state if we set
-+ * the dirty bit by hand in the kernel, since the hardware
-+ * will do the accessed bit for us, and we don't want to
-+ * race with other CPU's that might be updating the dirty
-+ * bit at the same time.
-+ */
-+#define __HAVE_ARCH_PTEP_SET_ACCESS_FLAGS
-+#define ptep_set_access_flags(__vma, __address, __ptep, __entry, __dirty) \
-+ do { \
-+ if (__dirty) { \
-+ if ( likely((__vma)->vm_mm == current->mm) ) { \
-+ BUG_ON(HYPERVISOR_update_va_mapping((__address), (__entry), UVMF_INVLPG|UVMF_MULTI|(unsigned long)((__vma)->vm_mm->cpu_vm_mask.bits))); \
-+ pte_update_defer((__vma)->vm_mm, (__address), (__ptep)); \
-+ } else { \
-+ xen_l1_entry_update((__ptep), (__entry)); \
-+ pte_update_defer((__vma)->vm_mm, (__address), (__ptep)); \
-+ flush_tlb_page((__vma), (__address)); \
-+ } \
-+ } \
-+ } while (0)
-+
-+/*
+ * We don't actually have these, but we want to advertise them so that
+ * we can encompass the flush here.
+ */
@@ -75563,55 +73635,61 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#define __HAVE_ARCH_PTEP_CLEAR_DIRTY_FLUSH
+#define ptep_clear_flush_dirty(vma, address, ptep) \
+({ \
-+ int __dirty; \
-+ __dirty = pte_dirty(*(ptep)); \
-+ if (__dirty) { \
-+ clear_bit(_PAGE_BIT_DIRTY, &(ptep)->pte_low); \
-+ pte_update_defer((vma)->vm_mm, (address), (ptep)); \
++ pte_t __pte = *(ptep); \
++ int __ret = pte_dirty(__pte); \
++ if (__ret) { \
++ __pte = pte_mkclean(__pte); \
++ if ((vma)->vm_mm != current->mm || \
++ HYPERVISOR_update_va_mapping(addr, __pte, 0)) \
++ (ptep)->pte_low = __pte.pte_low; \
++ pte_update_defer((vma)->vm_mm, (addr), (ptep)); \
+ flush_tlb_page(vma, address); \
+ } \
-+ __dirty; \
++ __ret; \
+})
+
+#define __HAVE_ARCH_PTEP_CLEAR_YOUNG_FLUSH
-+#define ptep_clear_flush_young(vma, address, ptep) \
++#define ptep_clear_flush_young(vma, addr, ptep) \
+({ \
-+ int __young; \
-+ __young = pte_young(*(ptep)); \
-+ if (__young) { \
-+ clear_bit(_PAGE_BIT_ACCESSED, &(ptep)->pte_low); \
-+ pte_update_defer((vma)->vm_mm, (address), (ptep)); \
++ pte_t __pte = *(ptep); \
++ int __ret = pte_young(__pte); \
++ if (__ret) { \
++ __pte = pte_mkold(__pte); \
++ if ((vma)->vm_mm != current->mm || \
++ HYPERVISOR_update_va_mapping(addr, __pte, 0)) \
++ (ptep)->pte_low = __pte.pte_low; \
++ pte_update_defer((vma)->vm_mm, (addr), (ptep)); \
+ flush_tlb_page(vma, address); \
+ } \
-+ __young; \
++ __ret; \
+})
+
+#define __HAVE_ARCH_PTEP_GET_AND_CLEAR
+static inline pte_t ptep_get_and_clear(struct mm_struct *mm, unsigned long addr, pte_t *ptep)
+{
-+ pte_t pte = raw_ptep_get_and_clear(ptep);
++ pte_t pte = raw_ptep_get_and_clear(mm, addr, ptep);
+ pte_update(mm, addr, ptep);
+ return pte;
+}
+
+#define __HAVE_ARCH_PTEP_GET_AND_CLEAR_FULL
-+static inline pte_t ptep_get_and_clear_full(struct mm_struct *mm, unsigned long addr, pte_t *ptep, int full)
-+{
-+ pte_t pte;
-+ if (full) {
-+ pte = *ptep;
-+ pte_clear(mm, addr, ptep);
-+ } else {
-+ pte = ptep_get_and_clear(mm, addr, ptep);
-+ }
-+ return pte;
-+}
++#define ptep_get_and_clear_full(mm, addr, ptep, full) \
++ ((full) ? ({ \
++ pte_t __res = *(ptep); \
++ if (test_bit(PG_pinned, &virt_to_page((mm)->pgd)->flags)) \
++ xen_l1_entry_update(ptep, __pte(0)); \
++ else \
++ *(ptep) = __pte(0); \
++ __res; \
++ }) : \
++ ptep_get_and_clear(mm, addr, ptep))
+
+#define __HAVE_ARCH_PTEP_SET_WRPROTECT
+static inline void ptep_set_wrprotect(struct mm_struct *mm, unsigned long addr, pte_t *ptep)
+{
-+ if (pte_write(*ptep))
-+ clear_bit(_PAGE_BIT_RW, &ptep->pte_low);
++ pte_t pte = *ptep;
++ if (pte_write(pte))
++ set_pte_at(mm, addr, ptep, pte_wrprotect(pte));
+ pte_update(mm, addr, ptep);
+}
+
@@ -75646,18 +73724,19 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+
+static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
+{
-+ pte.pte_low &= _PAGE_CHG_MASK;
-+ pte.pte_low |= pgprot_val(newprot);
-+#ifdef CONFIG_X86_PAE
+ /*
-+ * Chop off the NX bit (if present), and add the NX portion of
-+ * the newprot (if present):
++ * Since this might change the present bit (which controls whether
++ * a pte_t object has undergone p2m translation), we must use
++ * pte_val() on the input pte and __pte() for the return value.
+ */
-+ pte.pte_high &= ~(1 << (_PAGE_BIT_NX - 32));
-+ pte.pte_high |= (pgprot_val(newprot) >> 32) & \
-+ (__supported_pte_mask >> 32);
++ paddr_t pteval = pte_val(pte);
++
++ pteval &= _PAGE_CHG_MASK;
++ pteval |= pgprot_val(newprot);
++#ifdef CONFIG_X86_PAE
++ pteval &= __supported_pte_mask;
+#endif
-+ return pte;
++ return __pte(pteval);
+}
+
+#define pmd_large(pmd) \
@@ -75753,18 +73832,33 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ __flush_tlb_one(vaddr); \
+} while (0)
+
++#define __HAVE_ARCH_PTEP_ESTABLISH
++#define ptep_establish(vma, address, ptep, pteval) \
++ do { \
++ if ( likely((vma)->vm_mm == current->mm) ) { \
++ BUG_ON(HYPERVISOR_update_va_mapping(address, \
++ pteval, \
++ (unsigned long)(vma)->vm_mm->cpu_vm_mask.bits| \
++ UVMF_INVLPG|UVMF_MULTI)); \
++ pte_update_defer((__vma)->vm_mm, (__address), (__ptep)); \
++ } else { \
++ xen_l1_entry_update(ptep, pteval); \
++ pte_update_defer((__vma)->vm_mm, (__address), (__ptep)); \
++ flush_tlb_page(vma, address); \
++ } \
++ } while (0)
++
+/*
+ * The i386 doesn't have any external MMU info: the kernel page
+ * tables contain all the necessary information.
+ */
+#define update_mmu_cache(vma,address,pte) do { } while (0)
+#define __HAVE_ARCH_PTEP_SET_ACCESS_FLAGS
-+
-+#define __HAVE_ARCH_PTEP_ESTABLISH
-+#define ptep_establish(__vma, __address, __ptep, __entry) \
-+do { \
-+ ptep_set_access_flags(__vma, __address, __ptep, __entry, 1); \
-+} while (0)
++#define ptep_set_access_flags(vma, address, ptep, entry, dirty) \
++ do { \
++ if (dirty) \
++ ptep_establish(vma, address, ptep, entry); \
++ } while (0)
+
+#include <xen/features.h>
+void make_lowmem_page_readonly(void *va, unsigned int feature);
@@ -75822,9 +73916,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#include <asm-generic/pgtable.h>
+
+#endif /* _I386_PGTABLE_H */
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/asm-i386/mach-xen/asm/processor.h source/include/asm-i386/mach-xen/asm/processor.h
---- /scratch/src/linux-2.6.20.3/include/asm-i386/mach-xen/asm/processor.h 1970-01-01 01:00:00.000000000 +0100
-+++ source/include/asm-i386/mach-xen/asm/processor.h 2007-03-20 21:26:56.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/asm-i386/mach-xen/asm/processor.h
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/include/asm-i386/mach-xen/asm/processor.h Wed Aug 08 16:25:28 2007 -0300
@@ -0,0 +1,759 @@
+/*
+ * include/asm-i386/processor.h
@@ -76585,9 +74679,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+extern void secondary_cpu_init(void);
+
+#endif /* __ASM_I386_PROCESSOR_H */
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/asm-i386/mach-xen/asm/scatterlist.h source/include/asm-i386/mach-xen/asm/scatterlist.h
---- /scratch/src/linux-2.6.20.3/include/asm-i386/mach-xen/asm/scatterlist.h 1970-01-01 01:00:00.000000000 +0100
-+++ source/include/asm-i386/mach-xen/asm/scatterlist.h 2007-03-20 21:26:56.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/asm-i386/mach-xen/asm/scatterlist.h
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/include/asm-i386/mach-xen/asm/scatterlist.h Wed Aug 08 16:25:28 2007 -0300
@@ -0,0 +1,22 @@
+#ifndef _I386_SCATTERLIST_H
+#define _I386_SCATTERLIST_H
@@ -76611,128 +74705,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#define ISA_DMA_THRESHOLD (0x00ffffff)
+
+#endif /* !(_I386_SCATTERLIST_H) */
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/asm-i386/mach-xen/asm/smp.h source/include/asm-i386/mach-xen/asm/smp.h
---- /scratch/src/linux-2.6.20.3/include/asm-i386/mach-xen/asm/smp.h 1970-01-01 01:00:00.000000000 +0100
-+++ source/include/asm-i386/mach-xen/asm/smp.h 2007-03-20 21:26:56.000000000 +0100
-@@ -0,0 +1,115 @@
-+#ifndef __ASM_SMP_H
-+#define __ASM_SMP_H
-+
-+/*
-+ * We need the APIC definitions automatically as part of 'smp.h'
-+ */
-+#ifndef __ASSEMBLY__
-+#include <linux/kernel.h>
-+#include <linux/threads.h>
-+#include <linux/cpumask.h>
-+#include <asm/pda.h>
-+#endif
-+
-+#ifdef CONFIG_X86_LOCAL_APIC
-+#ifndef __ASSEMBLY__
-+#include <asm/fixmap.h>
-+#include <asm/bitops.h>
-+#include <asm/mpspec.h>
-+#ifdef CONFIG_X86_IO_APIC
-+#include <asm/io_apic.h>
-+#endif
-+#include <asm/apic.h>
-+#endif
-+#endif
-+
-+#define BAD_APICID 0xFFu
-+#ifdef CONFIG_SMP
-+#ifndef __ASSEMBLY__
-+
-+/*
-+ * Private routines/data
-+ */
-+
-+extern void smp_alloc_memory(void);
-+extern int pic_mode;
-+extern int smp_num_siblings;
-+extern cpumask_t cpu_sibling_map[];
-+extern cpumask_t cpu_core_map[];
-+
-+extern void (*mtrr_hook) (void);
-+extern void zap_low_mappings (void);
-+extern void lock_ipi_call_lock(void);
-+extern void unlock_ipi_call_lock(void);
-+
-+#define MAX_APICID 256
-+extern u8 x86_cpu_to_apicid[];
-+
-+#define cpu_physical_id(cpu) x86_cpu_to_apicid[cpu]
-+
-+#ifdef CONFIG_HOTPLUG_CPU
-+extern void cpu_exit_clear(void);
-+extern void cpu_uninit(void);
-+#endif
-+
-+/*
-+ * This function is needed by all SMP systems. It must _always_ be valid
-+ * from the initial startup. We map APIC_BASE very early in page_setup(),
-+ * so this is correct in the x86 case.
-+ */
-+#define raw_smp_processor_id() (read_pda(cpu_number))
-+
-+extern cpumask_t cpu_possible_map;
-+#define cpu_callin_map cpu_possible_map
-+
-+/* We don't mark CPUs online until __cpu_up(), so we need another measure */
-+static inline int num_booting_cpus(void)
-+{
-+ return cpus_weight(cpu_possible_map);
-+}
-+
-+#ifdef CONFIG_X86_LOCAL_APIC
-+
-+#ifdef APIC_DEFINITION
-+extern int hard_smp_processor_id(void);
-+#else
-+#include <mach_apicdef.h>
-+static inline int hard_smp_processor_id(void)
-+{
-+ /* we don't want to mark this access volatile - bad code generation */
-+ return GET_APIC_ID(*(unsigned long *)(APIC_BASE+APIC_ID));
-+}
-+#endif
-+#endif
-+
-+extern int safe_smp_processor_id(void);
-+extern int __cpu_disable(void);
-+extern void __cpu_die(unsigned int cpu);
-+extern unsigned int num_processors;
-+extern void prefill_possible_map(void);
-+
-+#endif /* !__ASSEMBLY__ */
-+
-+#else /* CONFIG_SMP */
-+
-+#define safe_smp_processor_id() 0
-+#define cpu_physical_id(cpu) boot_cpu_physical_apicid
-+
-+#define NO_PROC_ID 0xFF /* No processor magic marker */
-+
-+#endif
-+
-+#ifndef __ASSEMBLY__
-+
-+extern u8 apicid_2_node[];
-+
-+#ifdef CONFIG_X86_LOCAL_APIC
-+static __inline int logical_smp_processor_id(void)
-+{
-+ /* we don't want to mark this access volatile - bad code generation */
-+ return GET_APIC_LOGICAL_ID(*(unsigned long *)(APIC_BASE+APIC_LDR));
-+}
-+#endif
-+#endif
-+
-+#endif
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/asm-i386/mach-xen/asm/swiotlb.h source/include/asm-i386/mach-xen/asm/swiotlb.h
---- /scratch/src/linux-2.6.20.3/include/asm-i386/mach-xen/asm/swiotlb.h 1970-01-01 01:00:00.000000000 +0100
-+++ source/include/asm-i386/mach-xen/asm/swiotlb.h 2007-03-20 21:26:56.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/asm-i386/mach-xen/asm/swiotlb.h
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/include/asm-i386/mach-xen/asm/swiotlb.h Wed Aug 08 16:25:28 2007 -0300
@@ -0,0 +1,43 @@
+#ifndef _ASM_SWIOTLB_H
+#define _ASM_SWIOTLB_H 1
@@ -76760,16 +74735,16 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+extern void swiotlb_unmap_sg(struct device *hwdev, struct scatterlist *sg,
+ int nents, int direction);
+extern int swiotlb_dma_mapping_error(dma_addr_t dma_addr);
++#ifdef CONFIG_HIGHMEM
+extern dma_addr_t swiotlb_map_page(struct device *hwdev, struct page *page,
+ unsigned long offset, size_t size,
+ enum dma_data_direction direction);
+extern void swiotlb_unmap_page(struct device *hwdev, dma_addr_t dma_address,
+ size_t size, enum dma_data_direction direction);
++#endif
+extern int swiotlb_dma_supported(struct device *hwdev, u64 mask);
+extern void swiotlb_init(void);
+
-+extern unsigned int dma_bits;
-+
+#ifdef CONFIG_SWIOTLB
+extern int swiotlb;
+#else
@@ -76777,9 +74752,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#endif
+
+#endif
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/asm-i386/mach-xen/asm/synch_bitops.h source/include/asm-i386/mach-xen/asm/synch_bitops.h
---- /scratch/src/linux-2.6.20.3/include/asm-i386/mach-xen/asm/synch_bitops.h 1970-01-01 01:00:00.000000000 +0100
-+++ source/include/asm-i386/mach-xen/asm/synch_bitops.h 2007-03-20 21:26:56.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/asm-i386/mach-xen/asm/synch_bitops.h
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/include/asm-i386/mach-xen/asm/synch_bitops.h Wed Aug 08 16:25:28 2007 -0300
@@ -0,0 +1,145 @@
+#ifndef __XEN_SYNCH_BITOPS_H__
+#define __XEN_SYNCH_BITOPS_H__
@@ -76926,729 +74901,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#define synch_cmpxchg_subword synch_cmpxchg
+
+#endif /* __XEN_SYNCH_BITOPS_H__ */
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/asm-i386/mach-xen/asm/system.h source/include/asm-i386/mach-xen/asm/system.h
---- /scratch/src/linux-2.6.20.3/include/asm-i386/mach-xen/asm/system.h 1970-01-01 01:00:00.000000000 +0100
-+++ source/include/asm-i386/mach-xen/asm/system.h 2007-03-20 21:26:56.000000000 +0100
-@@ -0,0 +1,535 @@
-+#ifndef __ASM_SYSTEM_H
-+#define __ASM_SYSTEM_H
-+
-+#include <linux/kernel.h>
-+#include <asm/segment.h>
-+#include <asm/cpufeature.h>
-+#include <linux/bitops.h> /* for LOCK_PREFIX */
-+#include <asm/synch_bitops.h>
-+#include <asm/hypervisor.h>
-+
-+#ifdef __KERNEL__
-+
-+#ifdef CONFIG_SMP
-+#define __vcpu_id smp_processor_id()
-+#else
-+#define __vcpu_id 0
-+#endif
-+
-+struct task_struct; /* one of the stranger aspects of C forward declarations.. */
-+extern struct task_struct * FASTCALL(__switch_to(struct task_struct *prev, struct task_struct *next));
-+
-+/*
-+ * Saving eflags is important. It switches not only IOPL between tasks,
-+ * it also protects other tasks from NT leaking through sysenter etc.
-+ */
-+#define switch_to(prev,next,last) do { \
-+ unsigned long esi,edi; \
-+ asm volatile("pushfl\n\t" /* Save flags */ \
-+ "pushl %%ebp\n\t" \
-+ "movl %%esp,%0\n\t" /* save ESP */ \
-+ "movl %5,%%esp\n\t" /* restore ESP */ \
-+ "movl $1f,%1\n\t" /* save EIP */ \
-+ "pushl %6\n\t" /* restore EIP */ \
-+ "jmp __switch_to\n" \
-+ "1:\t" \
-+ "popl %%ebp\n\t" \
-+ "popfl" \
-+ :"=m" (prev->thread.esp),"=m" (prev->thread.eip), \
-+ "=a" (last),"=S" (esi),"=D" (edi) \
-+ :"m" (next->thread.esp),"m" (next->thread.eip), \
-+ "2" (prev), "d" (next)); \
-+} while (0)
-+
-+#define _set_base(addr,base) do { unsigned long __pr; \
-+__asm__ __volatile__ ("movw %%dx,%1\n\t" \
-+ "rorl $16,%%edx\n\t" \
-+ "movb %%dl,%2\n\t" \
-+ "movb %%dh,%3" \
-+ :"=&d" (__pr) \
-+ :"m" (*((addr)+2)), \
-+ "m" (*((addr)+4)), \
-+ "m" (*((addr)+7)), \
-+ "0" (base) \
-+ ); } while(0)
-+
-+#define _set_limit(addr,limit) do { unsigned long __lr; \
-+__asm__ __volatile__ ("movw %%dx,%1\n\t" \
-+ "rorl $16,%%edx\n\t" \
-+ "movb %2,%%dh\n\t" \
-+ "andb $0xf0,%%dh\n\t" \
-+ "orb %%dh,%%dl\n\t" \
-+ "movb %%dl,%2" \
-+ :"=&d" (__lr) \
-+ :"m" (*(addr)), \
-+ "m" (*((addr)+6)), \
-+ "0" (limit) \
-+ ); } while(0)
-+
-+#define set_base(ldt,base) _set_base( ((char *)&(ldt)) , (base) )
-+#define set_limit(ldt,limit) _set_limit( ((char *)&(ldt)) , ((limit)-1) )
-+
-+/*
-+ * Load a segment. Fall back on loading the zero
-+ * segment if something goes wrong..
-+ */
-+#define loadsegment(seg,value) \
-+ asm volatile("\n" \
-+ "1:\t" \
-+ "mov %0,%%" #seg "\n" \
-+ "2:\n" \
-+ ".section .fixup,\"ax\"\n" \
-+ "3:\t" \
-+ "pushl $0\n\t" \
-+ "popl %%" #seg "\n\t" \
-+ "jmp 2b\n" \
-+ ".previous\n" \
-+ ".section __ex_table,\"a\"\n\t" \
-+ ".align 4\n\t" \
-+ ".long 1b,3b\n" \
-+ ".previous" \
-+ : :"rm" (value))
-+
-+/*
-+ * Save a segment register away
-+ */
-+#define savesegment(seg, value) \
-+ asm volatile("mov %%" #seg ",%0":"=rm" (value))
-+
-+#ifdef CONFIG_PARAVIRT
-+#include <asm/paravirt.h>
-+#else
-+#define read_cr0() ({ \
-+ unsigned int __dummy; \
-+ __asm__ __volatile__( \
-+ "movl %%cr0,%0\n\t" \
-+ :"=r" (__dummy)); \
-+ __dummy; \
-+})
-+#define write_cr0(x) \
-+ __asm__ __volatile__("movl %0,%%cr0": :"r" (x))
-+
-+#define read_cr2() \
-+ (HYPERVISOR_shared_info->vcpu_info[smp_processor_id()].arch.cr2)
-+#define write_cr2(x) \
-+ __asm__ __volatile__("movl %0,%%cr2": :"r" (x))
-+
-+#define read_cr3() ({ \
-+ unsigned int __dummy; \
-+ __asm__ ( \
-+ "movl %%cr3,%0\n\t" \
-+ :"=r" (__dummy)); \
-+ __dummy = xen_cr3_to_pfn(__dummy); \
-+ mfn_to_pfn(__dummy) << PAGE_SHIFT; \
-+})
-+#define write_cr3(x) ({ \
-+ unsigned int __dummy = pfn_to_mfn((x) >> PAGE_SHIFT); \
-+ __dummy = xen_pfn_to_cr3(__dummy); \
-+ __asm__ __volatile__("movl %0,%%cr3": :"r" (__dummy)); \
-+})
-+
-+#define read_cr4() ({ \
-+ unsigned int __dummy; \
-+ __asm__( \
-+ "movl %%cr4,%0\n\t" \
-+ :"=r" (__dummy)); \
-+ __dummy; \
-+})
-+#define read_cr4_safe() ({ \
-+ unsigned int __dummy; \
-+ /* This could fault if %cr4 does not exist */ \
-+ __asm__("1: movl %%cr4, %0 \n" \
-+ "2: \n" \
-+ ".section __ex_table,\"a\" \n" \
-+ ".long 1b,2b \n" \
-+ ".previous \n" \
-+ : "=r" (__dummy): "0" (0)); \
-+ __dummy; \
-+})
-+#define write_cr4(x) \
-+ __asm__ __volatile__("movl %0,%%cr4": :"r" (x))
-+
-+#define wbinvd() \
-+ __asm__ __volatile__ ("wbinvd": : :"memory")
-+
-+/* Clear the 'TS' bit */
-+#define clts() (HYPERVISOR_fpu_taskswitch(0))
-+#endif/* CONFIG_PARAVIRT */
-+
-+/* Set the 'TS' bit */
-+#define stts() (HYPERVISOR_fpu_taskswitch(1))
-+
-+#endif /* __KERNEL__ */
-+
-+static inline unsigned long get_limit(unsigned long segment)
-+{
-+ unsigned long __limit;
-+ __asm__("lsll %1,%0"
-+ :"=r" (__limit):"r" (segment));
-+ return __limit+1;
-+}
-+
-+#define nop() __asm__ __volatile__ ("nop")
-+
-+#define xchg(ptr,v) ((__typeof__(*(ptr)))__xchg((unsigned long)(v),(ptr),sizeof(*(ptr))))
-+
-+#define tas(ptr) (xchg((ptr),1))
-+
-+struct __xchg_dummy { unsigned long a[100]; };
-+#define __xg(x) ((struct __xchg_dummy *)(x))
-+
-+
-+#ifdef CONFIG_X86_CMPXCHG64
-+
-+/*
-+ * The semantics of XCHGCMP8B are a bit strange, this is why
-+ * there is a loop and the loading of %%eax and %%edx has to
-+ * be inside. This inlines well in most cases, the cached
-+ * cost is around ~38 cycles. (in the future we might want
-+ * to do an SIMD/3DNOW!/MMX/FPU 64-bit store here, but that
-+ * might have an implicit FPU-save as a cost, so it's not
-+ * clear which path to go.)
-+ *
-+ * cmpxchg8b must be used with the lock prefix here to allow
-+ * the instruction to be executed atomically, see page 3-102
-+ * of the instruction set reference 24319102.pdf. We need
-+ * the reader side to see the coherent 64bit value.
-+ */
-+static inline void __set_64bit (unsigned long long * ptr,
-+ unsigned int low, unsigned int high)
-+{
-+ __asm__ __volatile__ (
-+ "\n1:\t"
-+ "movl (%0), %%eax\n\t"
-+ "movl 4(%0), %%edx\n\t"
-+ "lock cmpxchg8b (%0)\n\t"
-+ "jnz 1b"
-+ : /* no outputs */
-+ : "D"(ptr),
-+ "b"(low),
-+ "c"(high)
-+ : "ax","dx","memory");
-+}
-+
-+static inline void __set_64bit_constant (unsigned long long *ptr,
-+ unsigned long long value)
-+{
-+ __set_64bit(ptr,(unsigned int)(value), (unsigned int)((value)>>32ULL));
-+}
-+#define ll_low(x) *(((unsigned int*)&(x))+0)
-+#define ll_high(x) *(((unsigned int*)&(x))+1)
-+
-+static inline void __set_64bit_var (unsigned long long *ptr,
-+ unsigned long long value)
-+{
-+ __set_64bit(ptr,ll_low(value), ll_high(value));
-+}
-+
-+#define set_64bit(ptr,value) \
-+(__builtin_constant_p(value) ? \
-+ __set_64bit_constant(ptr, value) : \
-+ __set_64bit_var(ptr, value) )
-+
-+#define _set_64bit(ptr,value) \
-+(__builtin_constant_p(value) ? \
-+ __set_64bit(ptr, (unsigned int)(value), (unsigned int)((value)>>32ULL) ) : \
-+ __set_64bit(ptr, ll_low(value), ll_high(value)) )
-+
-+#endif
-+
-+/*
-+ * Note: no "lock" prefix even on SMP: xchg always implies lock anyway
-+ * Note 2: xchg has side effect, so that attribute volatile is necessary,
-+ * but generally the primitive is invalid, *ptr is output argument. --ANK
-+ */
-+static inline unsigned long __xchg(unsigned long x, volatile void * ptr, int size)
-+{
-+ switch (size) {
-+ case 1:
-+ __asm__ __volatile__("xchgb %b0,%1"
-+ :"=q" (x)
-+ :"m" (*__xg(ptr)), "0" (x)
-+ :"memory");
-+ break;
-+ case 2:
-+ __asm__ __volatile__("xchgw %w0,%1"
-+ :"=r" (x)
-+ :"m" (*__xg(ptr)), "0" (x)
-+ :"memory");
-+ break;
-+ case 4:
-+ __asm__ __volatile__("xchgl %0,%1"
-+ :"=r" (x)
-+ :"m" (*__xg(ptr)), "0" (x)
-+ :"memory");
-+ break;
-+ }
-+ return x;
-+}
-+
-+/*
-+ * Atomic compare and exchange. Compare OLD with MEM, if identical,
-+ * store NEW in MEM. Return the initial value in MEM. Success is
-+ * indicated by comparing RETURN with OLD.
-+ */
-+
-+#ifdef CONFIG_X86_CMPXCHG
-+#define __HAVE_ARCH_CMPXCHG 1
-+#define cmpxchg(ptr,o,n)\
-+ ((__typeof__(*(ptr)))__cmpxchg((ptr),(unsigned long)(o),\
-+ (unsigned long)(n),sizeof(*(ptr))))
-+#define sync_cmpxchg(ptr,o,n)\
-+ ((__typeof__(*(ptr)))__sync_cmpxchg((ptr),(unsigned long)(o),\
-+ (unsigned long)(n),sizeof(*(ptr))))
-+#endif
-+
-+static inline unsigned long __cmpxchg(volatile void *ptr, unsigned long old,
-+ unsigned long new, int size)
-+{
-+ unsigned long prev;
-+ switch (size) {
-+ case 1:
-+ __asm__ __volatile__(LOCK_PREFIX "cmpxchgb %b1,%2"
-+ : "=a"(prev)
-+ : "q"(new), "m"(*__xg(ptr)), "0"(old)
-+ : "memory");
-+ return prev;
-+ case 2:
-+ __asm__ __volatile__(LOCK_PREFIX "cmpxchgw %w1,%2"
-+ : "=a"(prev)
-+ : "r"(new), "m"(*__xg(ptr)), "0"(old)
-+ : "memory");
-+ return prev;
-+ case 4:
-+ __asm__ __volatile__(LOCK_PREFIX "cmpxchgl %1,%2"
-+ : "=a"(prev)
-+ : "r"(new), "m"(*__xg(ptr)), "0"(old)
-+ : "memory");
-+ return prev;
-+ }
-+ return old;
-+}
-+
-+/*
-+ * Always use locked operations when touching memory shared with a
-+ * hypervisor, since the system may be SMP even if the guest kernel
-+ * isn't.
-+ */
-+static inline unsigned long __sync_cmpxchg(volatile void *ptr,
-+ unsigned long old,
-+ unsigned long new, int size)
-+{
-+ unsigned long prev;
-+ switch (size) {
-+ case 1:
-+ __asm__ __volatile__("lock; cmpxchgb %b1,%2"
-+ : "=a"(prev)
-+ : "q"(new), "m"(*__xg(ptr)), "0"(old)
-+ : "memory");
-+ return prev;
-+ case 2:
-+ __asm__ __volatile__("lock; cmpxchgw %w1,%2"
-+ : "=a"(prev)
-+ : "r"(new), "m"(*__xg(ptr)), "0"(old)
-+ : "memory");
-+ return prev;
-+ case 4:
-+ __asm__ __volatile__("lock; cmpxchgl %1,%2"
-+ : "=a"(prev)
-+ : "r"(new), "m"(*__xg(ptr)), "0"(old)
-+ : "memory");
-+ return prev;
-+ }
-+ return old;
-+}
-+
-+#ifndef CONFIG_X86_CMPXCHG
-+/*
-+ * Building a kernel capable running on 80386. It may be necessary to
-+ * simulate the cmpxchg on the 80386 CPU. For that purpose we define
-+ * a function for each of the sizes we support.
-+ */
-+
-+extern unsigned long cmpxchg_386_u8(volatile void *, u8, u8);
-+extern unsigned long cmpxchg_386_u16(volatile void *, u16, u16);
-+extern unsigned long cmpxchg_386_u32(volatile void *, u32, u32);
-+
-+static inline unsigned long cmpxchg_386(volatile void *ptr, unsigned long old,
-+ unsigned long new, int size)
-+{
-+ switch (size) {
-+ case 1:
-+ return cmpxchg_386_u8(ptr, old, new);
-+ case 2:
-+ return cmpxchg_386_u16(ptr, old, new);
-+ case 4:
-+ return cmpxchg_386_u32(ptr, old, new);
-+ }
-+ return old;
-+}
-+
-+#define cmpxchg(ptr,o,n) \
-+({ \
-+ __typeof__(*(ptr)) __ret; \
-+ if (likely(boot_cpu_data.x86 > 3)) \
-+ __ret = __cmpxchg((ptr), (unsigned long)(o), \
-+ (unsigned long)(n), sizeof(*(ptr))); \
-+ else \
-+ __ret = cmpxchg_386((ptr), (unsigned long)(o), \
-+ (unsigned long)(n), sizeof(*(ptr))); \
-+ __ret; \
-+})
-+#endif
-+
-+#ifdef CONFIG_X86_CMPXCHG64
-+
-+static inline unsigned long long __cmpxchg64(volatile void *ptr, unsigned long long old,
-+ unsigned long long new)
-+{
-+ unsigned long long prev;
-+ __asm__ __volatile__(LOCK_PREFIX "cmpxchg8b %3"
-+ : "=A"(prev)
-+ : "b"((unsigned long)new),
-+ "c"((unsigned long)(new >> 32)),
-+ "m"(*__xg(ptr)),
-+ "0"(old)
-+ : "memory");
-+ return prev;
-+}
-+
-+#define cmpxchg64(ptr,o,n)\
-+ ((__typeof__(*(ptr)))__cmpxchg64((ptr),(unsigned long long)(o),\
-+ (unsigned long long)(n)))
-+
-+#endif
-+
-+/*
-+ * Force strict CPU ordering.
-+ * And yes, this is required on UP too when we're talking
-+ * to devices.
-+ *
-+ * For now, "wmb()" doesn't actually do anything, as all
-+ * Intel CPU's follow what Intel calls a *Processor Order*,
-+ * in which all writes are seen in the program order even
-+ * outside the CPU.
-+ *
-+ * I expect future Intel CPU's to have a weaker ordering,
-+ * but I'd also expect them to finally get their act together
-+ * and add some real memory barriers if so.
-+ *
-+ * Some non intel clones support out of order store. wmb() ceases to be a
-+ * nop for these.
-+ */
-+
-+
-+/*
-+ * Actually only lfence would be needed for mb() because all stores done
-+ * by the kernel should be already ordered. But keep a full barrier for now.
-+ */
-+
-+#define mb() alternative("lock; addl $0,0(%%esp)", "mfence", X86_FEATURE_XMM2)
-+#define rmb() alternative("lock; addl $0,0(%%esp)", "lfence", X86_FEATURE_XMM2)
-+
-+/**
-+ * read_barrier_depends - Flush all pending reads that subsequents reads
-+ * depend on.
-+ *
-+ * No data-dependent reads from memory-like regions are ever reordered
-+ * over this barrier. All reads preceding this primitive are guaranteed
-+ * to access memory (but not necessarily other CPUs' caches) before any
-+ * reads following this primitive that depend on the data return by
-+ * any of the preceding reads. This primitive is much lighter weight than
-+ * rmb() on most CPUs, and is never heavier weight than is
-+ * rmb().
-+ *
-+ * These ordering constraints are respected by both the local CPU
-+ * and the compiler.
-+ *
-+ * Ordering is not guaranteed by anything other than these primitives,
-+ * not even by data dependencies. See the documentation for
-+ * memory_barrier() for examples and URLs to more information.
-+ *
-+ * For example, the following code would force ordering (the initial
-+ * value of "a" is zero, "b" is one, and "p" is "&a"):
-+ *
-+ * <programlisting>
-+ * CPU 0 CPU 1
-+ *
-+ * b = 2;
-+ * memory_barrier();
-+ * p = &b; q = p;
-+ * read_barrier_depends();
-+ * d = *q;
-+ * </programlisting>
-+ *
-+ * because the read of "*q" depends on the read of "p" and these
-+ * two reads are separated by a read_barrier_depends(). However,
-+ * the following code, with the same initial values for "a" and "b":
-+ *
-+ * <programlisting>
-+ * CPU 0 CPU 1
-+ *
-+ * a = 2;
-+ * memory_barrier();
-+ * b = 3; y = b;
-+ * read_barrier_depends();
-+ * x = a;
-+ * </programlisting>
-+ *
-+ * does not enforce ordering, since there is no data dependency between
-+ * the read of "a" and the read of "b". Therefore, on some CPUs, such
-+ * as Alpha, "y" could be set to 3 and "x" to 0. Use rmb()
-+ * in cases like this where there are no data dependencies.
-+ **/
-+
-+#define read_barrier_depends() do { } while(0)
-+
-+#ifdef CONFIG_X86_OOSTORE
-+/* Actually there are no OOO store capable CPUs for now that do SSE,
-+ but make it already an possibility. */
-+#define wmb() alternative("lock; addl $0,0(%%esp)", "sfence", X86_FEATURE_XMM)
-+#else
-+#define wmb() __asm__ __volatile__ ("": : :"memory")
-+#endif
-+
-+#ifdef CONFIG_SMP
-+#define smp_mb() mb()
-+#define smp_rmb() rmb()
-+#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()
-+#define smp_wmb() barrier()
-+#define smp_read_barrier_depends() do { } while(0)
-+#define set_mb(var, value) do { var = value; barrier(); } while (0)
-+#endif
-+
-+#include <linux/irqflags.h>
-+
-+/*
-+ * disable hlt during certain critical i/o operations
-+ */
-+#define HAVE_DISABLE_HLT
-+void disable_hlt(void);
-+void enable_hlt(void);
-+
-+extern int es7000_plat;
-+void cpu_idle_wait(void);
-+
-+/*
-+ * On SMP systems, when the scheduler does migration-cost autodetection,
-+ * it needs a way to flush as much of the CPU's caches as possible:
-+ */
-+static inline void sched_cacheflush(void)
-+{
-+ wbinvd();
-+}
-+
-+extern unsigned long arch_align_stack(unsigned long sp);
-+extern void free_init_pages(char *what, unsigned long begin, unsigned long end);
-+
-+void default_idle(void);
-+
-+#endif
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/asm-i386/mach-xen/asm/timer.h source/include/asm-i386/mach-xen/asm/timer.h
---- /scratch/src/linux-2.6.20.3/include/asm-i386/mach-xen/asm/timer.h 1970-01-01 01:00:00.000000000 +0100
-+++ source/include/asm-i386/mach-xen/asm/timer.h 2007-03-20 21:26:56.000000000 +0100
-@@ -0,0 +1,67 @@
-+#ifndef _ASMi386_TIMER_H
-+#define _ASMi386_TIMER_H
-+#include <linux/init.h>
-+#include <linux/pm.h>
-+
-+/**
-+ * struct timer_ops - used to define a timer source
-+ *
-+ * @name: name of the timer.
-+ * @init: Probes and initializes the timer. Takes clock= override
-+ * string as an argument. Returns 0 on success, anything else
-+ * on failure.
-+ * @mark_offset: called by the timer interrupt.
-+ * @get_offset: called by gettimeofday(). Returns the number of microseconds
-+ * since the last timer interupt.
-+ * @monotonic_clock: returns the number of nanoseconds since the init of the
-+ * timer.
-+ * @delay: delays this many clock cycles.
-+ */
-+struct timer_opts {
-+ char* name;
-+ void (*mark_offset)(void);
-+ unsigned long (*get_offset)(void);
-+ unsigned long long (*monotonic_clock)(void);
-+ void (*delay)(unsigned long);
-+ unsigned long (*read_timer)(void);
-+ int (*suspend)(pm_message_t state);
-+ int (*resume)(void);
-+};
-+
-+struct init_timer_opts {
-+ int (*init)(char *override);
-+ struct timer_opts *opts;
-+};
-+
-+#define TICK_SIZE (tick_nsec / 1000)
-+
-+extern struct timer_opts* __init select_timer(void);
-+extern void clock_fallback(void);
-+void setup_pit_timer(void);
-+/* Modifiers for buggy PIT handling */
-+extern int pit_latch_buggy;
-+extern struct timer_opts *cur_timer;
-+extern int timer_ack;
-+
-+/* list of externed timers */
-+extern struct timer_opts timer_none;
-+extern struct timer_opts timer_pit;
-+extern struct init_timer_opts timer_pit_init;
-+extern struct init_timer_opts timer_tsc_init;
-+#ifdef CONFIG_X86_CYCLONE_TIMER
-+extern struct init_timer_opts timer_cyclone_init;
-+#endif
-+
-+extern unsigned long calibrate_tsc(void);
-+extern unsigned long read_timer_tsc(void);
-+extern void init_cpu_khz(void);
-+extern int recalibrate_cpu_khz(void);
-+#ifdef CONFIG_HPET_TIMER
-+extern struct init_timer_opts timer_hpet_init;
-+extern unsigned long calibrate_tsc_hpet(unsigned long *tsc_hpet_quotient_ptr);
-+#endif
-+
-+#ifdef CONFIG_X86_PM_TIMER
-+extern struct init_timer_opts timer_pmtmr_init;
-+#endif
-+#endif
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/asm-i386/mach-xen/asm/tlbflush.h source/include/asm-i386/mach-xen/asm/tlbflush.h
---- /scratch/src/linux-2.6.20.3/include/asm-i386/mach-xen/asm/tlbflush.h 1970-01-01 01:00:00.000000000 +0100
-+++ source/include/asm-i386/mach-xen/asm/tlbflush.h 2007-03-20 21:26:56.000000000 +0100
-@@ -0,0 +1,106 @@
-+#ifndef _I386_TLBFLUSH_H
-+#define _I386_TLBFLUSH_H
-+
-+#include <linux/mm.h>
-+#include <asm/processor.h>
-+
-+#ifdef CONFIG_PARAVIRT
-+#include <asm/paravirt.h>
-+#else
-+#define __flush_tlb() __native_flush_tlb()
-+#define __flush_tlb_global() __native_flush_tlb_global()
-+#define __flush_tlb_single(addr) __native_flush_tlb_single(addr)
-+#endif
-+
-+#define __native_flush_tlb() xen_tlb_flush()
-+#define __native_flush_tlb_global() xen_tlb_flush()
-+#define __native_flush_tlb_single(addr) xen_invlpg(addr)
-+#define __flush_tlb_all() xen_tlb_flush()
-+
-+#define cpu_has_invlpg (boot_cpu_data.x86 > 3)
-+
-+#define __flush_tlb_one(addr) __flush_tlb_single(addr)
-+
-+/*
-+ * TLB flushing:
-+ *
-+ * - flush_tlb() flushes the current mm struct TLBs
-+ * - flush_tlb_all() flushes all processes TLBs
-+ * - flush_tlb_mm(mm) flushes the specified mm context TLB's
-+ * - flush_tlb_page(vma, vmaddr) flushes one page
-+ * - flush_tlb_range(vma, start, end) flushes a range of pages
-+ * - flush_tlb_kernel_range(start, end) flushes a range of kernel pages
-+ * - flush_tlb_pgtables(mm, start, end) flushes a range of page tables
-+ *
-+ * ..but the i386 has somewhat limited tlb flushing capabilities,
-+ * and page-granular flushes are available only on i486 and up.
-+ */
-+
-+#ifndef CONFIG_SMP
-+
-+#define flush_tlb() __flush_tlb()
-+#define flush_tlb_all() __flush_tlb_all()
-+#define local_flush_tlb() __flush_tlb()
-+
-+static inline void flush_tlb_mm(struct mm_struct *mm)
-+{
-+ if (mm == current->active_mm)
-+ __flush_tlb();
-+}
-+
-+static inline void flush_tlb_page(struct vm_area_struct *vma,
-+ unsigned long addr)
-+{
-+ if (vma->vm_mm == current->active_mm)
-+ __flush_tlb_one(addr);
-+}
-+
-+static inline void flush_tlb_range(struct vm_area_struct *vma,
-+ unsigned long start, unsigned long end)
-+{
-+ if (vma->vm_mm == current->active_mm)
-+ __flush_tlb();
-+}
-+
-+#else
-+
-+#include <asm/smp.h>
-+
-+#define local_flush_tlb() \
-+ __flush_tlb()
-+
-+extern void flush_tlb_all(void);
-+extern void flush_tlb_current_task(void);
-+extern void flush_tlb_mm(struct mm_struct *);
-+extern void flush_tlb_page(struct vm_area_struct *, unsigned long);
-+
-+#define flush_tlb() flush_tlb_current_task()
-+
-+static inline void flush_tlb_range(struct vm_area_struct * vma, unsigned long start, unsigned long end)
-+{
-+ flush_tlb_mm(vma->vm_mm);
-+}
-+
-+#define TLBSTATE_OK 1
-+#define TLBSTATE_LAZY 2
-+
-+struct tlb_state
-+{
-+ struct mm_struct *active_mm;
-+ int state;
-+ char __cacheline_padding[L1_CACHE_BYTES-8];
-+};
-+DECLARE_PER_CPU(struct tlb_state, cpu_tlbstate);
-+
-+
-+#endif
-+
-+#define flush_tlb_kernel_range(start, end) flush_tlb_all()
-+
-+static inline void flush_tlb_pgtables(struct mm_struct *mm,
-+ unsigned long start, unsigned long end)
-+{
-+ /* i386 does not keep any page table caches in TLB */
-+}
-+
-+#endif /* _I386_TLBFLUSH_H */
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/asm-i386/mach-xen/asm/xenoprof.h source/include/asm-i386/mach-xen/asm/xenoprof.h
---- /scratch/src/linux-2.6.20.3/include/asm-i386/mach-xen/asm/xenoprof.h 1970-01-01 01:00:00.000000000 +0100
-+++ source/include/asm-i386/mach-xen/asm/xenoprof.h 2007-03-20 21:26:56.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/asm-i386/mach-xen/asm/xenoprof.h
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/include/asm-i386/mach-xen/asm/xenoprof.h Wed Aug 08 16:25:28 2007 -0300
@@ -0,0 +1,48 @@
+/******************************************************************************
+ * asm-i386/mach-xen/asm/xenoprof.h
@@ -77698,9 +74953,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+
+#endif /* CONFIG_XEN */
+#endif /* __ASM_XENOPROF_H__ */
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/asm-i386/mach-xen/irq_vectors.h source/include/asm-i386/mach-xen/irq_vectors.h
---- /scratch/src/linux-2.6.20.3/include/asm-i386/mach-xen/irq_vectors.h 1970-01-01 01:00:00.000000000 +0100
-+++ source/include/asm-i386/mach-xen/irq_vectors.h 2007-03-20 21:26:56.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/asm-i386/mach-xen/irq_vectors.h
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/include/asm-i386/mach-xen/irq_vectors.h Wed Aug 08 16:25:28 2007 -0300
@@ -0,0 +1,125 @@
+/*
+ * This file should contain #defines for all of the interrupt vector
@@ -77827,9 +75082,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#define irq_to_dynirq(_x) ((_x) - DYNIRQ_BASE)
+
+#endif /* _ASM_IRQ_VECTORS_H */
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/asm-i386/mach-xen/mach_traps.h source/include/asm-i386/mach-xen/mach_traps.h
---- /scratch/src/linux-2.6.20.3/include/asm-i386/mach-xen/mach_traps.h 1970-01-01 01:00:00.000000000 +0100
-+++ source/include/asm-i386/mach-xen/mach_traps.h 2007-03-20 21:26:56.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/asm-i386/mach-xen/mach_traps.h
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/include/asm-i386/mach-xen/mach_traps.h Wed Aug 08 16:25:28 2007 -0300
@@ -0,0 +1,33 @@
+/*
+ * include/asm-xen/asm-i386/mach-xen/mach_traps.h
@@ -77864,19 +75119,19 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+static inline void reassert_nmi(void) {}
+
+#endif /* !_MACH_TRAPS_H */
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/asm-i386/mach-xen/setup_arch.h source/include/asm-i386/mach-xen/setup_arch.h
---- /scratch/src/linux-2.6.20.3/include/asm-i386/mach-xen/setup_arch.h 1970-01-01 01:00:00.000000000 +0100
-+++ source/include/asm-i386/mach-xen/setup_arch.h 2007-03-20 21:26:56.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/asm-i386/mach-xen/setup_arch.h
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/include/asm-i386/mach-xen/setup_arch.h Wed Aug 08 16:25:28 2007 -0300
@@ -0,0 +1,5 @@
+/* Hook to call BIOS initialisation function */
+
+#define ARCH_SETUP machine_specific_arch_setup();
+
+void __init machine_specific_arch_setup(void);
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/asm-i386/mmu.h source/include/asm-i386/mmu.h
---- /scratch/src/linux-2.6.20.3/include/asm-i386/mmu.h 2007-02-04 19:44:54.000000000 +0100
-+++ source/include/asm-i386/mmu.h 2007-03-20 21:26:56.000000000 +0100
-@@ -13,6 +13,19 @@ typedef struct {
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/asm-i386/mmu.h
+--- a/include/asm-i386/mmu.h Wed Jul 18 12:23:24 2007 -0300
++++ b/include/asm-i386/mmu.h Wed Aug 08 16:25:28 2007 -0300
+@@ -13,6 +13,19 @@ typedef struct {
struct semaphore sem;
void *ldt;
void *vdso;
@@ -77896,9 +75151,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#endif /* CONFIG_XEN */
+
#endif
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/asm-i386/pci.h source/include/asm-i386/pci.h
---- /scratch/src/linux-2.6.20.3/include/asm-i386/pci.h 2007-02-04 19:44:54.000000000 +0100
-+++ source/include/asm-i386/pci.h 2007-03-20 21:26:56.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/asm-i386/pci.h
+--- a/include/asm-i386/pci.h Wed Jul 18 12:23:24 2007 -0300
++++ b/include/asm-i386/pci.h Wed Aug 08 16:25:28 2007 -0300
@@ -42,6 +42,27 @@ int pcibios_set_irq_routing(struct pci_d
struct pci_dev;
@@ -77927,16 +75182,16 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
/* The PCI address space does equal the physical memory
* address space. The networking and block device layers use
* this boolean for bounce buffer decisions.
-@@ -56,6 +77,8 @@ struct pci_dev;
+@@ -55,6 +76,8 @@ struct pci_dev;
+ #define pci_unmap_addr_set(PTR, ADDR_NAME, VAL) do { } while (0)
#define pci_unmap_len(PTR, LEN_NAME) (0)
#define pci_unmap_len_set(PTR, LEN_NAME, VAL) do { } while (0)
-
-+#endif
+
++#endif
+
/* This is always fine. */
#define pci_dac_dma_supported(pci_dev, mask) (1)
-
-@@ -110,10 +133,22 @@ static inline void pci_dma_burst_advice(
+@@ -110,6 +133,10 @@ static inline void pci_dma_burst_advice(
#endif /* __KERNEL__ */
@@ -77947,49 +75202,95 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
/* implement the pci_ DMA API in terms of the generic device dma_ one */
#include <asm-generic/pci-dma-compat.h>
- /* generic pci stuff */
- #include <asm-generic/pci.h>
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/asm-i386/pgalloc.h
+--- a/include/asm-i386/pgalloc.h Wed Jul 18 12:23:24 2007 -0300
++++ b/include/asm-i386/pgalloc.h Wed Aug 08 16:25:28 2007 -0300
+@@ -4,14 +4,35 @@
+ #include <asm/fixmap.h>
+ #include <linux/threads.h>
+ #include <linux/mm.h> /* for struct page */
++#ifdef CONFIG_XEN
++#include <asm/io.h> /* for phys_to_virt and page_to_pseudophys */
++#endif
+
+ #define pmd_populate_kernel(mm, pmd, pte) \
+ set_pmd(pmd, __pmd(_PAGE_TABLE + __pa(pte)))
+#ifdef CONFIG_XEN
-+/* On Xen we have to scan all functions since Xen hides bridges from
-+ * us. If a bridge is at fn=0 and that slot has a multifunction
-+ * device, we won't find the additional devices without scanning all
-+ * functions. */
-+#undef pcibios_scan_all_fns
-+#define pcibios_scan_all_fns(a, b) 1
-+#endif /* CONFIG_XEN */
- #endif /* __i386_PCI_H */
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/asm-i386/pgtable-2level-defs.h source/include/asm-i386/pgtable-2level-defs.h
---- /scratch/src/linux-2.6.20.3/include/asm-i386/pgtable-2level-defs.h 2007-02-04 19:44:54.000000000 +0100
-+++ source/include/asm-i386/pgtable-2level-defs.h 2007-03-20 21:26:56.000000000 +0100
-@@ -1,6 +1,8 @@
++#define pmd_populate(mm, pmd, pte) \
++do { \
++ unsigned long pfn = page_to_pfn(pte); \
++ if (test_bit(PG_pinned, &virt_to_page((mm)->pgd)->flags)) { \
++ if (!PageHighMem(pte)) \
++ BUG_ON(HYPERVISOR_update_va_mapping( \
++ (unsigned long)__va(pfn << PAGE_SHIFT), \
++ pfn_pte(pfn, PAGE_KERNEL_RO), 0)); \
++ else if (!test_and_set_bit(PG_pinned, &pte->flags)) \
++ kmap_flush_unused(); \
++ set_pmd(pmd, \
++ __pmd(_PAGE_TABLE + ((paddr_t)pfn << PAGE_SHIFT))); \
++ } else \
++ *(pmd) = __pmd(_PAGE_TABLE + ((paddr_t)pfn << PAGE_SHIFT)); \
++} while (0)
++#else
+ #define pmd_populate(mm, pmd, pte) \
+ set_pmd(pmd, __pmd(_PAGE_TABLE + \
+ ((unsigned long long)page_to_pfn(pte) << \
+ (unsigned long long) PAGE_SHIFT)))
++#endif
+ /*
+ * Allocate and free page tables.
+ */
+@@ -24,13 +45,19 @@ static inline void pte_free_kernel(pte_t
+ static inline void pte_free_kernel(pte_t *pte)
+ {
+ free_page((unsigned long)pte);
++#ifdef CONFIG_XEN
++ make_lowmem_page_writable(pte, XENFEAT_writable_page_tables);
++#endif
+ }
+
++#ifdef CONFIG_XEN
++extern void pte_free(struct page *pte);
++#else
+ static inline void pte_free(struct page *pte)
+ {
+ __free_page(pte);
+ }
+-
++#endif
+
+ #define __pte_free_tlb(tlb,pte) tlb_remove_page((tlb),(pte))
+
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/asm-i386/pgtable-2level-defs.h
+--- a/include/asm-i386/pgtable-2level-defs.h Wed Jul 18 12:23:24 2007 -0300
++++ b/include/asm-i386/pgtable-2level-defs.h Wed Aug 08 16:25:28 2007 -0300
+@@ -1,5 +1,7 @@
#ifndef _I386_PGTABLE_2LEVEL_DEFS_H
#define _I386_PGTABLE_2LEVEL_DEFS_H
-
-+#define HAVE_SHARED_KERNEL_PMD 0
+
++#define HAVE_SHARED_KERNEL_PMD 0
+
/*
* traditional i386 two-level paging structure:
- */
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/asm-i386/pgtable-3level-defs.h source/include/asm-i386/pgtable-3level-defs.h
---- /scratch/src/linux-2.6.20.3/include/asm-i386/pgtable-3level-defs.h 2007-02-04 19:44:54.000000000 +0100
-+++ source/include/asm-i386/pgtable-3level-defs.h 2007-03-20 21:26:56.000000000 +0100
-@@ -1,6 +1,12 @@
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/asm-i386/pgtable-3level-defs.h
+--- a/include/asm-i386/pgtable-3level-defs.h Wed Jul 18 12:23:24 2007 -0300
++++ b/include/asm-i386/pgtable-3level-defs.h Wed Aug 08 16:25:28 2007 -0300
+@@ -1,5 +1,11 @@
#ifndef _I386_PGTABLE_3LEVEL_DEFS_H
#define _I386_PGTABLE_3LEVEL_DEFS_H
-
++
+#ifdef CONFIG_XEN
+#define HAVE_SHARED_KERNEL_PMD 0
+#else
+#define HAVE_SHARED_KERNEL_PMD 1
+#endif
-+
+
/*
* PGDIR_SHIFT determines what a top-level page table entry can map
- */
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/asm-i386/segment.h source/include/asm-i386/segment.h
---- /scratch/src/linux-2.6.20.3/include/asm-i386/segment.h 2007-02-04 19:44:54.000000000 +0100
-+++ source/include/asm-i386/segment.h 2007-03-20 21:26:56.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/asm-i386/segment.h
+--- a/include/asm-i386/segment.h Wed Jul 18 12:23:24 2007 -0300
++++ b/include/asm-i386/segment.h Wed Aug 08 16:25:28 2007 -0300
@@ -87,7 +87,11 @@
#define GDT_SIZE (GDT_ENTRIES * 8)
@@ -78013,9 +75314,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#endif /* CONFIG_XEN */
#endif
#endif
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/asm-i386/setup.h source/include/asm-i386/setup.h
---- /scratch/src/linux-2.6.20.3/include/asm-i386/setup.h 2007-02-04 19:44:54.000000000 +0100
-+++ source/include/asm-i386/setup.h 2007-03-20 21:26:56.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/asm-i386/setup.h
+--- a/include/asm-i386/setup.h Wed Jul 18 12:23:24 2007 -0300
++++ b/include/asm-i386/setup.h Wed Aug 08 16:25:28 2007 -0300
@@ -53,9 +53,15 @@ extern unsigned char boot_params[PARAM_S
#define AUX_DEVICE_INFO (*(unsigned char *) (PARAM+0x1FF))
#define LOADER_TYPE (*(unsigned char *) (PARAM+0x210))
@@ -78032,14 +75333,176 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
#define EDD_NR (*(unsigned char *) (PARAM+EDDNR))
#define EDD_MBR_SIG_NR (*(unsigned char *) (PARAM+EDD_MBR_SIG_NR_BUF))
#define EDD_MBR_SIGNATURE ((unsigned int *) (PARAM+EDD_MBR_SIG_BUF))
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/asm-i386/vga.h source/include/asm-i386/vga.h
---- /scratch/src/linux-2.6.20.3/include/asm-i386/vga.h 2007-02-04 19:44:54.000000000 +0100
-+++ source/include/asm-i386/vga.h 2007-03-20 21:26:56.000000000 +0100
-@@ -12,7 +12,11 @@
- * access the videoram directly without any black magic.
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/asm-i386/smp.h
+--- a/include/asm-i386/smp.h Wed Jul 18 12:23:24 2007 -0300
++++ b/include/asm-i386/smp.h Wed Aug 08 16:25:28 2007 -0300
+@@ -59,14 +59,22 @@ extern void cpu_uninit(void);
*/
+ #define raw_smp_processor_id() (read_pda(cpu_number))
+
++#ifdef CONFIG_XEN
++#define cpu_callin_map cpu_possible_map
++#else
+ extern cpumask_t cpu_callout_map;
+ extern cpumask_t cpu_callin_map;
++#endif
+ extern cpumask_t cpu_possible_map;
+
+ /* We don't mark CPUs online until __cpu_up(), so we need another measure */
+ static inline int num_booting_cpus(void)
+ {
++#ifdef CONFIG_XEN
++ return cpus_weight(cpu_possible_map);
++#else
+ return cpus_weight(cpu_callout_map);
++#endif
+ }
+
+ #ifdef CONFIG_X86_LOCAL_APIC
+@@ -88,6 +96,9 @@ extern void __cpu_die(unsigned int cpu);
+ extern void __cpu_die(unsigned int cpu);
+ extern unsigned int num_processors;
+
++#ifdef CONFIG_XEN
++extern void prefill_possible_map(void);
++#endif
+ #endif /* !__ASSEMBLY__ */
+
+ #else /* CONFIG_SMP */
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/asm-i386/system.h
+--- a/include/asm-i386/system.h Wed Jul 18 12:23:24 2007 -0300
++++ b/include/asm-i386/system.h Wed Aug 08 16:25:28 2007 -0300
+@@ -5,6 +5,10 @@
+ #include <asm/segment.h>
+ #include <asm/cpufeature.h>
+ #include <linux/bitops.h> /* for LOCK_PREFIX */
++#ifdef CONFIG_XEN
++#include <asm/synch_bitops.h>
++#include <asm/hypervisor.h>
++#endif
+
+ #ifdef __KERNEL__
+
+@@ -101,6 +105,9 @@ __asm__ __volatile__ ("movw %%dx,%1\n\t"
+ #define write_cr0(x) \
+ __asm__ __volatile__("movl %0,%%cr0": :"r" (x))
+#ifdef CONFIG_XEN
++#define read_cr2() (current_vcpu_info()->arch.cr2)
++#else
+ #define read_cr2() ({ \
+ unsigned int __dummy; \
+ __asm__ __volatile__( \
+@@ -108,9 +115,25 @@ __asm__ __volatile__ ("movw %%dx,%1\n\t"
+ :"=r" (__dummy)); \
+ __dummy; \
+ })
++#endif
+ #define write_cr2(x) \
+ __asm__ __volatile__("movl %0,%%cr2": :"r" (x))
+
++#ifdef CONFIG_XEN
++#define read_cr3() ({ \
++ unsigned int __dummy; \
++ __asm__ ( \
++ "movl %%cr3,%0\n\t" \
++ :"=r" (__dummy)); \
++ __dummy = xen_cr3_to_pfn(__dummy); \
++ mfn_to_pfn(__dummy) << PAGE_SHIFT; \
++})
++#define write_cr3(x) ({ \
++ unsigned int __dummy = pfn_to_mfn((x) >> PAGE_SHIFT); \
++ __dummy = xen_pfn_to_cr3(__dummy); \
++ __asm__ __volatile__("movl %0,%%cr3": :"r" (__dummy)); \
++})
++#else
+ #define read_cr3() ({ \
+ unsigned int __dummy; \
+ __asm__ ( \
+@@ -120,6 +143,7 @@ __asm__ __volatile__ ("movw %%dx,%1\n\t"
+ })
+ #define write_cr3(x) \
+ __asm__ __volatile__("movl %0,%%cr3": :"r" (x))
++#endif
+
+ #define read_cr4() ({ \
+ unsigned int __dummy; \
+@@ -146,11 +170,17 @@ __asm__ __volatile__ ("movw %%dx,%1\n\t"
+ __asm__ __volatile__ ("wbinvd": : :"memory")
+
+ /* Clear the 'TS' bit */
++/*
++ * Clear and set 'TS' bit respectively
++ */
++#ifdef CONFIG_XEN
++#define clts() (HYPERVISOR_fpu_taskswitch(0))
++#define stts() (HYPERVISOR_fpu_taskswitch(1))
++#else
+ #define clts() __asm__ __volatile__ ("clts")
++#define stts() write_cr0(8 | read_cr0())
++#endif
+ #endif/* CONFIG_PARAVIRT */
+-
+-/* Set the 'TS' bit */
+-#define stts() write_cr0(8 | read_cr0())
+
+ #endif /* __KERNEL__ */
+
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/asm-i386/tlbflush.h
+--- a/include/asm-i386/tlbflush.h Wed Jul 18 12:23:24 2007 -0300
++++ b/include/asm-i386/tlbflush.h Wed Aug 08 16:25:28 2007 -0300
+@@ -7,10 +7,23 @@
+ #ifdef CONFIG_PARAVIRT
+ #include <asm/paravirt.h>
+ #else
++#ifdef CONFIG_XEN
++#define __flush_tlb() xen_tlb_flush()
++#define __flush_tlb_global() xen_tlb_flush()
++
++extern unsigned long pgkern_mask;
++
++#define __flush_tlb_all() xen_tlb_flush()
++
++#define cpu_has_invlpg (boot_cpu_data.x86 > 3)
++
++#define __flush_tlb_single(addr) xen_invlpg(addr)
++
++#define __flush_tlb_one(addr) __flush_tlb_single(addr)
++#else
+ #define __flush_tlb() __native_flush_tlb()
+ #define __flush_tlb_global() __native_flush_tlb_global()
+ #define __flush_tlb_single(addr) __native_flush_tlb_single(addr)
+-#endif
+
+ #define __native_flush_tlb() \
+ do { \
+@@ -47,6 +60,7 @@
+ #define __native_flush_tlb_single(addr) \
+ __asm__ __volatile__("invlpg (%0)" ::"r" (addr) : "memory")
+
++
+ # define __flush_tlb_all() \
+ do { \
+ if (cpu_has_pge) \
+@@ -68,7 +82,8 @@
+ __flush_tlb(); \
+ } while (0)
+ #endif
+-
++#endif /* CONFIG_XEN */
++#endif /* CONFIG_PARAVIRT */
+ /*
+ * TLB flushing:
+ *
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/asm-i386/vga.h
+--- a/include/asm-i386/vga.h Wed Jul 18 12:23:24 2007 -0300
++++ b/include/asm-i386/vga.h Wed Aug 08 16:25:28 2007 -0300
+@@ -11,8 +11,11 @@
+ * On the PC, we can just recalculate addresses and then
+ * access the videoram directly without any black magic.
+ */
+-
++#ifdef CONFIG_XEN
+#define VGA_MAP_MEM(x,s) (unsigned long)isa_bus_to_virt(x)
+#else
#define VGA_MAP_MEM(x,s) (unsigned long)phys_to_virt(x)
@@ -78047,9 +75510,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
#define vga_readb(x) (*(x))
#define vga_writeb(x,y) (*(y) = (x))
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/asm-ia64/agp.h source/include/asm-ia64/agp.h
---- /scratch/src/linux-2.6.20.3/include/asm-ia64/agp.h 2007-02-04 19:44:54.000000000 +0100
-+++ source/include/asm-ia64/agp.h 2007-03-20 21:26:56.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/asm-ia64/agp.h
+--- a/include/asm-ia64/agp.h Wed Jul 18 12:23:24 2007 -0300
++++ b/include/asm-ia64/agp.h Wed Aug 08 16:25:28 2007 -0300
@@ -19,13 +19,44 @@
#define flush_agp_cache() mb()
@@ -78095,9 +75558,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#endif /* CONFIG_XEN */
#endif /* _ASM_IA64_AGP_H */
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/asm-ia64/dma-mapping.h source/include/asm-ia64/dma-mapping.h
---- /scratch/src/linux-2.6.20.3/include/asm-ia64/dma-mapping.h 2007-02-04 19:44:54.000000000 +0100
-+++ source/include/asm-ia64/dma-mapping.h 2007-03-20 21:26:56.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/asm-ia64/dma-mapping.h
+--- a/include/asm-ia64/dma-mapping.h Wed Jul 18 12:23:24 2007 -0300
++++ b/include/asm-ia64/dma-mapping.h Wed Aug 08 16:25:28 2007 -0300
@@ -6,20 +6,67 @@
* David Mosberger-Tang <davidm@hpl.hp.com>
*/
@@ -78134,7 +75597,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+/* Needed for arch/i386/kernel/swiotlb.c and arch/i386/kernel/pci-dma-xen.c */
+#include <asm/hypervisor.h>
+/* Needed for arch/i386/kernel/swiotlb.c */
-+#include <asm-i386/mach-xen/asm/swiotlb.h>
++#include <asm/swiotlb.h>
+
+int dma_map_sg(struct device *hwdev, struct scatterlist *sg, int nents,
+ enum dma_data_direction direction);
@@ -78218,15 +75681,15 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+}
+
#endif /* _ASM_IA64_DMA_MAPPING_H */
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/asm-ia64/fixmap.h source/include/asm-ia64/fixmap.h
---- /scratch/src/linux-2.6.20.3/include/asm-ia64/fixmap.h 1970-01-01 01:00:00.000000000 +0100
-+++ source/include/asm-ia64/fixmap.h 2007-03-20 21:26:56.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/asm-ia64/fixmap.h
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/include/asm-ia64/fixmap.h Wed Aug 08 16:25:28 2007 -0300
@@ -0,0 +1,2 @@
+#define clear_fixmap(x) do {} while (0)
+#define set_fixmap(x,y) do {} while (0)
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/asm-ia64/gcc_intrin.h source/include/asm-ia64/gcc_intrin.h
---- /scratch/src/linux-2.6.20.3/include/asm-ia64/gcc_intrin.h 2007-02-04 19:44:54.000000000 +0100
-+++ source/include/asm-ia64/gcc_intrin.h 2007-03-20 21:26:56.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/asm-ia64/gcc_intrin.h
+--- a/include/asm-ia64/gcc_intrin.h Wed Jul 18 12:23:24 2007 -0300
++++ b/include/asm-ia64/gcc_intrin.h Wed Aug 08 16:25:28 2007 -0300
@@ -26,7 +26,7 @@ extern void ia64_bad_param_for_getreg (v
register unsigned long ia64_r13 asm ("r13") __attribute_used__;
@@ -78268,13 +75731,16 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
#define ia64_nop(x) asm volatile ("nop %0"::"i"(x));
-#define ia64_itci(addr) asm volatile ("itc.i %0;;" :: "r"(addr) : "memory")
-+#define __ia64_itci(addr) asm volatile ("itc.i %0;;" :: "r"(addr) : "memory")
-
+-
-#define ia64_itcd(addr) asm volatile ("itc.d %0;;" :: "r"(addr) : "memory")
-+#define __ia64_itcd(addr) asm volatile ("itc.d %0;;" :: "r"(addr) : "memory")
-
-
+-
+-
-#define ia64_itri(trnum, addr) asm volatile ("itr.i itr[%0]=%1" \
++#define __ia64_itci(addr) asm volatile ("itc.i %0;;" :: "r"(addr) : "memory")
++
++#define __ia64_itcd(addr) asm volatile ("itc.d %0;;" :: "r"(addr) : "memory")
++
++
+#define __ia64_itri(trnum, addr) asm volatile ("itr.i itr[%0]=%1" \
:: "r"(trnum), "r"(addr) : "memory")
@@ -78375,9 +75841,10 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
#define ia64_rum(mask) asm volatile ("rum %0":: "i"((mask)) : "memory")
-#define ia64_ptce(addr) asm volatile ("ptc.e %0" :: "r"(addr))
-+#define __ia64_ptce(addr) asm volatile ("ptc.e %0" :: "r"(addr))
-
+-
-#define ia64_ptcga(addr, size) \
++#define __ia64_ptce(addr) asm volatile ("ptc.e %0" :: "r"(addr))
++
+#define __ia64_ptcga(addr, size) \
do { \
asm volatile ("ptc.ga %0,%1" :: "r"(addr), "r"(size) : "memory"); \
@@ -78416,9 +75883,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#define __ia64_get_psr_i() (__ia64_getreg(_IA64_REG_PSR) & 0x4000UL)
+
#endif /* _ASM_IA64_GCC_INTRIN_H */
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/asm-ia64/hw_irq.h source/include/asm-ia64/hw_irq.h
---- /scratch/src/linux-2.6.20.3/include/asm-ia64/hw_irq.h 2007-02-04 19:44:54.000000000 +0100
-+++ source/include/asm-ia64/hw_irq.h 2007-03-20 21:26:56.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/asm-ia64/hw_irq.h
+--- a/include/asm-ia64/hw_irq.h Wed Jul 18 12:23:24 2007 -0300
++++ b/include/asm-ia64/hw_irq.h Wed Aug 08 16:25:28 2007 -0300
@@ -15,7 +15,11 @@
#include <asm/ptrace.h>
#include <asm/smp.h>
@@ -78444,10 +75911,10 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
platform_send_ipi(smp_processor_id(), vector, IA64_IPI_DM_INT, 0);
}
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/asm-ia64/hypercall.h source/include/asm-ia64/hypercall.h
---- /scratch/src/linux-2.6.20.3/include/asm-ia64/hypercall.h 1970-01-01 01:00:00.000000000 +0100
-+++ source/include/asm-ia64/hypercall.h 2007-03-20 21:26:56.000000000 +0100
-@@ -0,0 +1,463 @@
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/asm-ia64/hypercall.h
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/include/asm-ia64/hypercall.h Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,416 @@
+/******************************************************************************
+ * hypercall.h
+ *
@@ -78489,6 +75956,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+
+#include <asm/xen/xcom_hcall.h>
+struct xencomm_handle;
++extern unsigned long __hypercall(unsigned long a1, unsigned long a2,
++ unsigned long a3, unsigned long a4,
++ unsigned long a5, unsigned long cmd);
+
+/*
+ * Assembler stubs for hyper-calls.
@@ -78497,115 +75967,58 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#define _hypercall0(type, name) \
+({ \
+ long __res; \
-+ __asm__ __volatile__ (";;\n" \
-+ "mov r2=%1\n" \
-+ "break 0x1000 ;;\n" \
-+ "mov %0=r8 ;;\n" \
-+ : "=r" (__res) \
-+ : "J" (__HYPERVISOR_##name) \
-+ : "r2","r8", \
-+ "memory" ); \
++ __res=__hypercall(0, 0, 0, 0, 0, __HYPERVISOR_##name); \
+ (type)__res; \
+})
+
+#define _hypercall1(type, name, a1) \
+({ \
+ long __res; \
-+ __asm__ __volatile__ (";;\n" \
-+ "mov r14=%2\n" \
-+ "mov r2=%1\n" \
-+ "break 0x1000 ;;\n" \
-+ "mov %0=r8 ;;\n" \
-+ : "=r" (__res) \
-+ : "J" (__HYPERVISOR_##name), \
-+ "rI" ((unsigned long)(a1)) \
-+ : "r14","r2","r8", \
-+ "memory" ); \
++ __res = __hypercall((unsigned long)a1, \
++ 0, 0, 0, 0, __HYPERVISOR_##name); \
+ (type)__res; \
+})
+
+#define _hypercall2(type, name, a1, a2) \
+({ \
+ long __res; \
-+ __asm__ __volatile__ (";;\n" \
-+ "mov r14=%2\n" \
-+ "mov r15=%3\n" \
-+ "mov r2=%1\n" \
-+ "break 0x1000 ;;\n" \
-+ "mov %0=r8 ;;\n" \
-+ : "=r" (__res) \
-+ : "J" (__HYPERVISOR_##name), \
-+ "rI" ((unsigned long)(a1)), \
-+ "rI" ((unsigned long)(a2)) \
-+ : "r14","r15","r2","r8", \
-+ "memory" ); \
++ __res = __hypercall((unsigned long)a1, \
++ (unsigned long)a2, \
++ 0, 0, 0, __HYPERVISOR_##name); \
+ (type)__res; \
+})
+
+#define _hypercall3(type, name, a1, a2, a3) \
+({ \
+ long __res; \
-+ __asm__ __volatile__ (";;\n" \
-+ "mov r14=%2\n" \
-+ "mov r15=%3\n" \
-+ "mov r16=%4\n" \
-+ "mov r2=%1\n" \
-+ "break 0x1000 ;;\n" \
-+ "mov %0=r8 ;;\n" \
-+ : "=r" (__res) \
-+ : "J" (__HYPERVISOR_##name), \
-+ "rI" ((unsigned long)(a1)), \
-+ "rI" ((unsigned long)(a2)), \
-+ "rI" ((unsigned long)(a3)) \
-+ : "r14","r15","r16","r2","r8", \
-+ "memory" ); \
-+ (type)__res; \
++ __res = __hypercall((unsigned long)a1, \
++ (unsigned long)a2, \
++ (unsigned long)a3, \
++ 0, 0, __HYPERVISOR_##name); \
++ (type)__res; \
+})
+
+#define _hypercall4(type, name, a1, a2, a3, a4) \
+({ \
+ long __res; \
-+ __asm__ __volatile__ (";;\n" \
-+ "mov r14=%2\n" \
-+ "mov r15=%3\n" \
-+ "mov r16=%4\n" \
-+ "mov r17=%5\n" \
-+ "mov r2=%1\n" \
-+ "break 0x1000 ;;\n" \
-+ "mov %0=r8 ;;\n" \
-+ : "=r" (__res) \
-+ : "J" (__HYPERVISOR_##name), \
-+ "rI" ((unsigned long)(a1)), \
-+ "rI" ((unsigned long)(a2)), \
-+ "rI" ((unsigned long)(a3)), \
-+ "rI" ((unsigned long)(a4)) \
-+ : "r14","r15","r16","r2","r8", \
-+ "r17","memory" ); \
-+ (type)__res; \
++ __res = __hypercall((unsigned long)a1, \
++ (unsigned long)a2, \
++ (unsigned long)a3, \
++ (unsigned long)a4, \
++ 0, __HYPERVISOR_##name); \
++ (type)__res; \
+})
+
+#define _hypercall5(type, name, a1, a2, a3, a4, a5) \
+({ \
+ long __res; \
-+ __asm__ __volatile__ (";;\n" \
-+ "mov r14=%2\n" \
-+ "mov r15=%3\n" \
-+ "mov r16=%4\n" \
-+ "mov r17=%5\n" \
-+ "mov r18=%6\n" \
-+ "mov r2=%1\n" \
-+ "break 0x1000 ;;\n" \
-+ "mov %0=r8 ;;\n" \
-+ : "=r" (__res) \
-+ : "J" (__HYPERVISOR_##name), \
-+ "rI" ((unsigned long)(a1)), \
-+ "rI" ((unsigned long)(a2)), \
-+ "rI" ((unsigned long)(a3)), \
-+ "rI" ((unsigned long)(a4)), \
-+ "rI" ((unsigned long)(a5)) \
-+ : "r14","r15","r16","r2","r8", \
-+ "r17","r18","memory" ); \
-+ (type)__res; \
++ __res = __hypercall((unsigned long)a1, \
++ (unsigned long)a2, \
++ (unsigned long)a3, \
++ (unsigned long)a4, \
++ (unsigned long)a5, \
++ __HYPERVISOR_##name); \
++ (type)__res; \
+})
+
+
@@ -78624,9 +76037,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+}
+
+static inline int
-+xencomm_arch_hypercall_dom0_op(struct xencomm_handle *op)
++xencomm_arch_hypercall_platform_op(struct xencomm_handle *op)
+{
-+ return _hypercall1(int, dom0_op, op);
++ return _hypercall1(int, platform_op, op);
+}
+
+static inline int
@@ -78709,6 +76122,12 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ return _hypercall2(unsigned long, hvm_op, cmd, arg);
+}
+
++static inline long
++xencomm_arch_hypercall_vcpu_op(int cmd, int cpu, void *arg)
++{
++ return _hypercall3(long, vcpu_op, cmd, cpu, arg);
++}
++
+static inline int
+HYPERVISOR_physdev_op(int cmd, void *arg)
+{
@@ -78909,12 +76328,13 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#endif
+
+#define HYPERVISOR_suspend xencomm_hypercall_suspend
++#define HYPERVISOR_vcpu_op xencomm_hypercall_vcpu_op
+
+#endif /* __HYPERCALL_H__ */
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/asm-ia64/hypervisor.h source/include/asm-ia64/hypervisor.h
---- /scratch/src/linux-2.6.20.3/include/asm-ia64/hypervisor.h 1970-01-01 01:00:00.000000000 +0100
-+++ source/include/asm-ia64/hypervisor.h 2007-03-20 21:26:56.000000000 +0100
-@@ -0,0 +1,224 @@
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/asm-ia64/hypervisor.h
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/include/asm-ia64/hypervisor.h Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,225 @@
+/******************************************************************************
+ * hypervisor.h
+ *
@@ -78968,11 +76388,11 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#include <linux/version.h>
+#include <linux/errno.h>
+#include <xen/interface/xen.h>
-+#include <xen/interface/dom0_ops.h>
++#include <xen/interface/platform.h>
+#include <xen/interface/event_channel.h>
+#include <xen/interface/physdev.h>
+#include <xen/interface/sched.h>
-+#include <asm/hypercall.h>
++#include <xen/hypercall.h>
+#include <asm/ptrace.h>
+#include <asm/page.h>
+
@@ -78981,7 +76401,6 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+
+void force_evtchn_callback(void);
+
-+#ifndef CONFIG_VMX_GUEST
+/* Turn jiffies into Xen system time. XXX Implement me. */
+#define jiffies_to_st(j) 0
+
@@ -79035,6 +76454,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+
+#include <asm/hypercall.h>
+
++#ifndef CONFIG_VMX_GUEST
+// for drivers/xen/privcmd/privcmd.c
+#define machine_to_phys_mapping 0
+struct vm_area_struct;
@@ -79133,16 +76553,17 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#endif /* CONFIG_XEN || CONFIG_VMX_GUEST */
+
+#ifdef CONFIG_XEN_PRIVILEGED_GUEST
-+#define is_initial_xendomain() (xen_start_info->flags & SIF_INITDOMAIN)
++#define is_initial_xendomain() \
++ (is_running_on_xen() ? xen_start_info->flags & SIF_INITDOMAIN : 0)
+#else
+#define is_initial_xendomain() 0
+#endif
+
+#endif /* __HYPERVISOR_H__ */
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/asm-ia64/intel_intrin.h source/include/asm-ia64/intel_intrin.h
---- /scratch/src/linux-2.6.20.3/include/asm-ia64/intel_intrin.h 2007-02-04 19:44:54.000000000 +0100
-+++ source/include/asm-ia64/intel_intrin.h 2007-03-20 21:26:56.000000000 +0100
-@@ -16,8 +16,10 @@
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/asm-ia64/intel_intrin.h
+--- a/include/asm-ia64/intel_intrin.h Wed Jul 18 12:23:24 2007 -0300
++++ b/include/asm-ia64/intel_intrin.h Wed Aug 08 16:25:28 2007 -0300
+@@ -16,8 +16,11 @@
* intrinsic
*/
@@ -79151,11 +76572,12 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#define __ia64_getreg __getReg
+#define __ia64_setreg __setReg
+
-+#define __ia64_hint(x)
++#define ia64_hint __hint
++#define ia64_hint_pause __hint_pause
#define ia64_hint __hint
#define ia64_hint_pause __hint_pause
-@@ -33,16 +35,16 @@
+@@ -33,16 +36,16 @@
#define ia64_getf_exp __getf_exp
#define ia64_shrp _m64_shrp
@@ -79176,7 +76598,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
#define ia64_ldfs __ldfs
#define ia64_ldfd __ldfd
-@@ -80,24 +82,24 @@
+@@ -80,24 +83,24 @@
#define __ia64_set_dbr(index, val) \
__setIndReg(_IA64_REG_INDR_DBR, index, val)
@@ -79212,7 +76634,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
#define ia64_srlz_d __dsrlz
#define ia64_srlz_i __isrlz
-@@ -116,18 +118,18 @@
+@@ -116,18 +119,18 @@
#define ia64_ld8_acq __ld8_acq
#define ia64_sync_i __synci
@@ -79243,7 +76665,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
#define ia64_dep_mi _m64_dep_mi
/* Values for lfhint in __lfetch and __lfetch_fault */
-@@ -142,16 +144,18 @@
+@@ -142,15 +145,17 @@
#define ia64_lfetch_fault __lfetch_fault
#define ia64_lfetch_fault_excl __lfetch_fault_excl
@@ -79259,15 +76681,14 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ __ia64_rsm(IA64_PSR_I); \
} \
} while (0)
-
-+#define __ia64_get_psr_i() (__ia64_getreg(_IA64_REG_PSR) & 0x4000UL)
+
++#define __ia64_get_psr_i() (__ia64_getreg(_IA64_REG_PSR) & 0x4000UL)
+
#define __builtin_trap() __break(0);
- #endif /* _ASM_IA64_INTEL_INTRIN_H */
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/asm-ia64/io.h source/include/asm-ia64/io.h
---- /scratch/src/linux-2.6.20.3/include/asm-ia64/io.h 2007-02-04 19:44:54.000000000 +0100
-+++ source/include/asm-ia64/io.h 2007-03-20 21:26:56.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/asm-ia64/io.h
+--- a/include/asm-ia64/io.h Wed Jul 18 12:23:24 2007 -0300
++++ b/include/asm-ia64/io.h Wed Aug 08 16:25:28 2007 -0300
@@ -66,9 +66,11 @@ extern unsigned int num_io_spaces;
#define PIO_RESERVED __IA64_UNCACHED_OFFSET
#define HAVE_ARCH_PIO_SIZE
@@ -79327,33 +76748,17 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
# endif /* KERNEL */
-@@ -418,9 +457,20 @@ __writeq (unsigned long val, volatile vo
+@@ -418,7 +457,6 @@ __writeq (unsigned long val, volatile vo
#endif
# ifdef __KERNEL__
-
--extern void __iomem * ioremap(unsigned long offset, unsigned long size);
--extern void __iomem * ioremap_nocache (unsigned long offset, unsigned long size);
-+/*
-+ * An "address" in IO memory space is not clearly either an integer or a pointer. We will
-+ * accept both, thus the casts.
-+ *
-+ * On ia-64, we access the physical I/O memory space through the uncached kernel region.
-+ */
-+static inline void __iomem *
-+ioremap (unsigned long offset, unsigned long size)
-+{
-+ offset = HYPERVISOR_ioremap(offset, size);
-+ if (IS_ERR_VALUE(offset))
-+ return (void __iomem*)offset;
-+ return (void __iomem *) (__IA64_UNCACHED_OFFSET | (offset));
-+}
+ extern void __iomem * ioremap(unsigned long offset, unsigned long size);
+ extern void __iomem * ioremap_nocache (unsigned long offset, unsigned long size);
- static inline void
- iounmap (volatile void __iomem *addr)
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/asm-ia64/iosapic.h source/include/asm-ia64/iosapic.h
---- /scratch/src/linux-2.6.20.3/include/asm-ia64/iosapic.h 2007-02-04 19:44:54.000000000 +0100
-+++ source/include/asm-ia64/iosapic.h 2007-03-20 21:26:56.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/asm-ia64/iosapic.h
+--- a/include/asm-ia64/iosapic.h Wed Jul 18 12:23:24 2007 -0300
++++ b/include/asm-ia64/iosapic.h Wed Aug 08 16:25:28 2007 -0300
@@ -53,6 +53,7 @@
#define NR_IOSAPICS 256
@@ -79370,9 +76775,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
static inline void iosapic_eoi(char __iomem *iosapic, u32 vector)
{
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/asm-ia64/irq.h source/include/asm-ia64/irq.h
---- /scratch/src/linux-2.6.20.3/include/asm-ia64/irq.h 2007-02-04 19:44:54.000000000 +0100
-+++ source/include/asm-ia64/irq.h 2007-03-20 21:26:56.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/asm-ia64/irq.h
+--- a/include/asm-ia64/irq.h Wed Jul 18 12:23:24 2007 -0300
++++ b/include/asm-ia64/irq.h Wed Aug 08 16:25:28 2007 -0300
@@ -11,8 +11,41 @@
* 02/29/00 D.Mosberger moved most things into hw_irq.h
*/
@@ -79415,9 +76820,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
static __inline__ int
irq_canonicalize (int irq)
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/asm-ia64/machvec_dig.h source/include/asm-ia64/machvec_dig.h
---- /scratch/src/linux-2.6.20.3/include/asm-ia64/machvec_dig.h 2007-02-04 19:44:54.000000000 +0100
-+++ source/include/asm-ia64/machvec_dig.h 2007-03-20 21:26:56.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/asm-ia64/machvec_dig.h
+--- a/include/asm-ia64/machvec_dig.h Wed Jul 18 12:23:24 2007 -0300
++++ b/include/asm-ia64/machvec_dig.h Wed Aug 08 16:25:28 2007 -0300
@@ -13,4 +13,19 @@ extern ia64_mv_setup_t dig_setup;
#define platform_name "dig"
#define platform_setup dig_setup
@@ -79438,10 +76843,10 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#endif
+
#endif /* _ASM_IA64_MACHVEC_DIG_h */
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/asm-ia64/maddr.h source/include/asm-ia64/maddr.h
---- /scratch/src/linux-2.6.20.3/include/asm-ia64/maddr.h 1970-01-01 01:00:00.000000000 +0100
-+++ source/include/asm-ia64/maddr.h 2007-03-20 21:26:56.000000000 +0100
-@@ -0,0 +1,102 @@
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/asm-ia64/maddr.h
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/include/asm-ia64/maddr.h Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,98 @@
+#ifndef _ASM_IA64_MADDR_H
+#define _ASM_IA64_MADDR_H
+
@@ -79512,7 +76917,6 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+static inline unsigned long
+mfn_to_local_pfn(unsigned long mfn)
+{
-+ extern unsigned long max_mapnr;
+ unsigned long pfn = mfn_to_pfn_for_dma(mfn);
+ if (!pfn_valid(pfn))
+ return INVALID_P2M_ENTRY;
@@ -79529,9 +76933,6 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+
+#endif /* !CONFIG_XEN */
+
-+/* XXX to compile set_phys_to_machine(vaddr, FOREIGN_FRAME(m)) */
-+#define FOREIGN_FRAME(m) (INVALID_P2M_ENTRY)
-+
+#define mfn_to_pfn(mfn) (mfn)
+#define pfn_to_mfn(pfn) (pfn)
+
@@ -79544,9 +76945,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+typedef unsigned long maddr_t; // to compile netback, netfront
+
+#endif /* _ASM_IA64_MADDR_H */
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/asm-ia64/meminit.h source/include/asm-ia64/meminit.h
---- /scratch/src/linux-2.6.20.3/include/asm-ia64/meminit.h 2007-02-04 19:44:54.000000000 +0100
-+++ source/include/asm-ia64/meminit.h 2007-03-20 21:26:56.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/asm-ia64/meminit.h
+--- a/include/asm-ia64/meminit.h Wed Jul 18 12:23:24 2007 -0300
++++ b/include/asm-ia64/meminit.h Wed Aug 08 16:25:28 2007 -0300
@@ -17,10 +17,15 @@
* - kernel code & data
* - crash dumping code reserved region
@@ -79563,10 +76964,18 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
struct rsvd_region {
unsigned long start; /* virtual address of beginning of element */
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/asm-ia64/page.h source/include/asm-ia64/page.h
---- /scratch/src/linux-2.6.20.3/include/asm-ia64/page.h 2007-02-04 19:44:54.000000000 +0100
-+++ source/include/asm-ia64/page.h 2007-03-20 21:26:56.000000000 +0100
-@@ -125,7 +125,9 @@ extern unsigned long max_low_pfn;
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/asm-ia64/page.h
+--- a/include/asm-ia64/page.h Wed Jul 18 12:23:24 2007 -0300
++++ b/include/asm-ia64/page.h Wed Aug 08 16:25:28 2007 -0300
+@@ -118,6 +118,7 @@ extern struct page *vmem_map;
+ #endif
+
+ #ifdef CONFIG_FLATMEM
++extern unsigned long max_mapnr;
+ # define pfn_valid(pfn) (((pfn) < max_mapnr) && ia64_pfn_valid(pfn))
+ #elif defined(CONFIG_DISCONTIGMEM)
+ extern unsigned long min_low_pfn;
+@@ -125,7 +126,9 @@ extern unsigned long max_low_pfn;
# define pfn_valid(pfn) (((pfn) >= min_low_pfn) && ((pfn) < max_low_pfn) && ia64_pfn_valid(pfn))
#endif
@@ -79576,7 +76985,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
#define virt_to_page(kaddr) pfn_to_page(__pa(kaddr) >> PAGE_SHIFT)
#define pfn_to_kaddr(pfn) __va((pfn) << PAGE_SHIFT)
-@@ -226,5 +228,53 @@ get_order (unsigned long size)
+@@ -226,5 +229,24 @@ get_order (unsigned long size)
(((current->personality & READ_IMPLIES_EXEC) != 0) \
? VM_EXEC : 0))
@@ -79587,53 +76996,24 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#include <linux/kernel.h>
+#include <asm/hypervisor.h>
+#include <xen/features.h> // to compile netback, netfront
++#include <asm/maddr.h>
+
-+/*
-+ * XXX hack!
-+ * Linux/IA64 uses PG_arch_1.
-+ * This hack will be removed once PG_foreign bit is taken.
-+ * #include <xen/foreign_page.h>
-+ */
-+#ifdef __ASM_XEN_FOREIGN_PAGE_H__
-+# error "don't include include/xen/foreign_page.h!"
-+#endif
-+
-+extern struct address_space xen_ia64_foreign_dummy_mapping;
-+#define PageForeign(page) \
-+ ((page)->mapping == &xen_ia64_foreign_dummy_mapping)
-+
-+#define SetPageForeign(page, dtor) do { \
-+ set_page_private((page), (unsigned long)(dtor)); \
-+ (page)->mapping = &xen_ia64_foreign_dummy_mapping; \
-+ smp_rmb(); \
-+} while (0)
-+
-+#define ClearPageForeign(page) do { \
-+ (page)->mapping = NULL; \
-+ smp_rmb(); \
-+ set_page_private((page), 0); \
-+} while (0)
-+
-+#define PageForeignDestructor(page) \
-+ ( (void (*) (struct page *)) page_private(page) )
-+
-+#define arch_free_page(_page,_order) \
-+({ int foreign = PageForeign(_page); \
-+ if (foreign) \
-+ (PageForeignDestructor(_page))(_page); \
-+ foreign; \
++#define arch_free_page(_page, _order) \
++({ \
++ int foreign = PageForeign(_page); \
++ if (foreign) \
++ PageForeignDestructor(_page); \
++ foreign; \
+})
+#define HAVE_ARCH_FREE_PAGE
+
-+#include <asm/maddr.h>
-+
+#endif /* CONFIG_XEN */
+#endif /* __ASSEMBLY__ */
+#endif /* __KERNEL__ */
#endif /* _ASM_IA64_PAGE_H */
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/asm-ia64/pal.h source/include/asm-ia64/pal.h
---- /scratch/src/linux-2.6.20.3/include/asm-ia64/pal.h 2007-02-04 19:44:54.000000000 +0100
-+++ source/include/asm-ia64/pal.h 2007-03-20 21:26:56.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/asm-ia64/pal.h
+--- a/include/asm-ia64/pal.h Wed Jul 18 12:23:24 2007 -0300
++++ b/include/asm-ia64/pal.h Wed Aug 08 16:25:28 2007 -0300
@@ -92,6 +92,7 @@
#ifndef __ASSEMBLY__
@@ -79642,10 +77022,10 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
#include <asm/fpu.h>
/*
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/asm-ia64/pgalloc.h source/include/asm-ia64/pgalloc.h
---- /scratch/src/linux-2.6.20.3/include/asm-ia64/pgalloc.h 2007-02-04 19:44:54.000000000 +0100
-+++ source/include/asm-ia64/pgalloc.h 2007-03-20 21:26:56.000000000 +0100
-@@ -125,7 +125,11 @@ static inline void pmd_free(pmd_t * pmd)
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/asm-ia64/pgalloc.h
+--- a/include/asm-ia64/pgalloc.h Wed Jul 18 12:23:24 2007 -0300
++++ b/include/asm-ia64/pgalloc.h Wed Aug 08 16:25:28 2007 -0300
+@@ -125,7 +125,11 @@ static inline void
static inline void
pmd_populate(struct mm_struct *mm, pmd_t * pmd_entry, struct page *pte)
{
@@ -79657,9 +77037,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
}
static inline void
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/asm-ia64/privop.h source/include/asm-ia64/privop.h
---- /scratch/src/linux-2.6.20.3/include/asm-ia64/privop.h 1970-01-01 01:00:00.000000000 +0100
-+++ source/include/asm-ia64/privop.h 2007-03-20 21:26:56.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/asm-ia64/privop.h
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/include/asm-ia64/privop.h Wed Aug 08 16:25:28 2007 -0300
@@ -0,0 +1,60 @@
+#ifndef _ASM_IA64_PRIVOP_H
+#define _ASM_IA64_PRIVOP_H
@@ -79721,9 +77101,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#endif /* !__ASSEMBLY */
+
+#endif /* _ASM_IA64_PRIVOP_H */
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/asm-ia64/processor.h source/include/asm-ia64/processor.h
---- /scratch/src/linux-2.6.20.3/include/asm-ia64/processor.h 2007-02-04 19:44:54.000000000 +0100
-+++ source/include/asm-ia64/processor.h 2007-03-20 21:26:56.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/asm-ia64/processor.h
+--- a/include/asm-ia64/processor.h Wed Jul 18 12:23:24 2007 -0300
++++ b/include/asm-ia64/processor.h Wed Aug 08 16:25:28 2007 -0300
@@ -18,6 +18,7 @@
#include <asm/kregs.h>
#include <asm/ptrace.h>
@@ -79732,9 +77112,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
#define IA64_NUM_DBG_REGS 8
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/asm-ia64/sal.h source/include/asm-ia64/sal.h
---- /scratch/src/linux-2.6.20.3/include/asm-ia64/sal.h 2007-02-04 19:44:54.000000000 +0100
-+++ source/include/asm-ia64/sal.h 2007-03-20 21:26:56.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/asm-ia64/sal.h
+--- a/include/asm-ia64/sal.h Wed Jul 18 12:23:24 2007 -0300
++++ b/include/asm-ia64/sal.h Wed Aug 08 16:25:28 2007 -0300
@@ -42,6 +42,9 @@
#include <asm/pal.h>
#include <asm/system.h>
@@ -79774,9 +77154,54 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
SAL_CALL_REENTRANT(isrv, SAL_GET_STATE_INFO, sal_info_type, 0,
sal_info, 0, 0, 0, 0);
if (isrv.status)
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/asm-ia64/synch_bitops.h source/include/asm-ia64/synch_bitops.h
---- /scratch/src/linux-2.6.20.3/include/asm-ia64/synch_bitops.h 1970-01-01 01:00:00.000000000 +0100
-+++ source/include/asm-ia64/synch_bitops.h 2007-03-20 21:26:56.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/asm-ia64/swiotlb.h
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/include/asm-ia64/swiotlb.h Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,41 @@
++#ifndef _ASM_SWIOTLB_H
++#define _ASM_SWIOTLB_H 1
++
++/* SWIOTLB interface */
++
++extern dma_addr_t swiotlb_map_single(struct device *hwdev, void *ptr, size_t size,
++ int dir);
++extern void swiotlb_unmap_single(struct device *hwdev, dma_addr_t dev_addr,
++ size_t size, int dir);
++extern void swiotlb_sync_single_for_cpu(struct device *hwdev,
++ dma_addr_t dev_addr,
++ size_t size, int dir);
++extern void swiotlb_sync_single_for_device(struct device *hwdev,
++ dma_addr_t dev_addr,
++ size_t size, int dir);
++extern void swiotlb_sync_sg_for_cpu(struct device *hwdev,
++ struct scatterlist *sg, int nelems,
++ int dir);
++extern void swiotlb_sync_sg_for_device(struct device *hwdev,
++ struct scatterlist *sg, int nelems,
++ int dir);
++extern int swiotlb_map_sg(struct device *hwdev, struct scatterlist *sg,
++ int nents, int direction);
++extern void swiotlb_unmap_sg(struct device *hwdev, struct scatterlist *sg,
++ int nents, int direction);
++extern int swiotlb_dma_mapping_error(dma_addr_t dma_addr);
++extern dma_addr_t swiotlb_map_page(struct device *hwdev, struct page *page,
++ unsigned long offset, size_t size,
++ enum dma_data_direction direction);
++extern void swiotlb_unmap_page(struct device *hwdev, dma_addr_t dma_address,
++ size_t size, enum dma_data_direction direction);
++extern int swiotlb_dma_supported(struct device *hwdev, u64 mask);
++extern void swiotlb_init(void);
++
++#ifdef CONFIG_SWIOTLB
++extern int swiotlb;
++#else
++#define swiotlb 0
++#endif
++
++#endif
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/asm-ia64/synch_bitops.h
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/include/asm-ia64/synch_bitops.h Wed Aug 08 16:25:28 2007 -0300
@@ -0,0 +1,61 @@
+#ifndef __XEN_SYNCH_BITOPS_H__
+#define __XEN_SYNCH_BITOPS_H__
@@ -79839,9 +77264,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#define synch_cmpxchg_subword synch_cmpxchg
+
+#endif /* __XEN_SYNCH_BITOPS_H__ */
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/asm-ia64/system.h source/include/asm-ia64/system.h
---- /scratch/src/linux-2.6.20.3/include/asm-ia64/system.h 2007-02-04 19:44:54.000000000 +0100
-+++ source/include/asm-ia64/system.h 2007-03-20 21:26:56.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/asm-ia64/system.h
+--- a/include/asm-ia64/system.h Wed Jul 18 12:23:24 2007 -0300
++++ b/include/asm-ia64/system.h Wed Aug 08 16:25:28 2007 -0300
@@ -123,7 +123,7 @@ extern struct ia64_boot_param {
#define __local_irq_save(x) \
do { \
@@ -79860,9 +77285,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
#define irqs_disabled() \
({ \
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/asm-ia64/uaccess.h source/include/asm-ia64/uaccess.h
---- /scratch/src/linux-2.6.20.3/include/asm-ia64/uaccess.h 2007-02-04 19:44:54.000000000 +0100
-+++ source/include/asm-ia64/uaccess.h 2007-03-20 21:26:56.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/asm-ia64/uaccess.h
+--- a/include/asm-ia64/uaccess.h Wed Jul 18 12:23:24 2007 -0300
++++ b/include/asm-ia64/uaccess.h Wed Aug 08 16:25:28 2007 -0300
@@ -365,6 +365,7 @@ ia64_done_with_exception (struct pt_regs
}
@@ -79897,10 +77322,10 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
/*
* Convert a virtual cached kernel memory pointer to an uncached pointer
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/asm-ia64/xen/privop.h source/include/asm-ia64/xen/privop.h
---- /scratch/src/linux-2.6.20.3/include/asm-ia64/xen/privop.h 1970-01-01 01:00:00.000000000 +0100
-+++ source/include/asm-ia64/xen/privop.h 2007-03-20 21:26:56.000000000 +0100
-@@ -0,0 +1,303 @@
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/asm-ia64/xen/privop.h
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/include/asm-ia64/xen/privop.h Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,310 @@
+#ifndef _ASM_IA64_XEN_PRIVOP_H
+#define _ASM_IA64_XEN_PRIVOP_H
+
@@ -79948,12 +77373,10 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#define XEN_HYPER_GET_PMD break HYPERPRIVOP_GET_PMD
+#define XEN_HYPER_GET_EFLAG break HYPERPRIVOP_GET_EFLAG
+#define XEN_HYPER_SET_EFLAG break HYPERPRIVOP_SET_EFLAG
-+#define XEN_HYPER_RSM_BE break HYPERPRIVOP_RSM_BE
+#define XEN_HYPER_GET_PSR break HYPERPRIVOP_GET_PSR
+
+#define XSI_IFS (XSI_BASE + XSI_IFS_OFS)
+#define XSI_PRECOVER_IFS (XSI_BASE + XSI_PRECOVER_IFS_OFS)
-+#define XSI_INCOMPL_REGFR (XSI_BASE + XSI_INCOMPL_REGFR_OFS)
+#define XSI_IFA (XSI_BASE + XSI_IFA_OFS)
+#define XSI_ISR (XSI_BASE + XSI_ISR_OFS)
+#define XSI_IIM (XSI_BASE + XSI_IIM_OFS)
@@ -79962,6 +77385,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#define XSI_PSR_IC (XSI_BASE + XSI_PSR_IC_OFS)
+#define XSI_IPSR (XSI_BASE + XSI_IPSR_OFS)
+#define XSI_IIP (XSI_BASE + XSI_IIP_OFS)
++#define XSI_B1NAT (XSI_BASE + XSI_B1NATS_OFS)
+#define XSI_BANK1_R16 (XSI_BASE + XSI_BANK1_R16_OFS)
+#define XSI_BANKNUM (XSI_BASE + XSI_BANKNUM_OFS)
+#define XSI_IHA (XSI_BASE + XSI_IHA_OFS)
@@ -80026,8 +77450,6 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ * that we inline it */
+#define xen_hyper_ssm_i() \
+({ \
-+ xen_set_virtual_psr_i(0); \
-+ xen_set_virtual_psr_ic(0); \
+ XEN_HYPER_SSM_I; \
+})
+
@@ -80042,8 +77464,12 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#define xen_ssm_i() \
+({ \
+ int old = xen_get_virtual_psr_i(); \
-+ xen_set_virtual_psr_i(1); \
-+ if (!old && xen_get_virtual_pend()) xen_hyper_ssm_i(); \
++ if (!old) { \
++ if (xen_get_virtual_pend()) \
++ xen_hyper_ssm_i(); \
++ else \
++ xen_set_virtual_psr_i(1); \
++ } \
+})
+
+#define xen_ia64_intrin_local_irq_restore(x) \
@@ -80085,6 +77511,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ * be properly handled by Xen, some are frequent enough that we use
+ * hyperprivops for performance. */
+
++extern unsigned long xen_get_psr(void);
+extern unsigned long xen_get_ivr(void);
+extern unsigned long xen_get_tpr(void);
+extern void xen_set_itm(unsigned long);
@@ -80104,6 +77531,11 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ __u64 ia64_intri_res; \
+ \
+ switch(regnum) { \
++ case _IA64_REG_PSR: \
++ ia64_intri_res = (is_running_on_xen()) ? \
++ xen_get_psr() : \
++ __ia64_getreg(regnum); \
++ break; \
+ case _IA64_REG_CR_IVR: \
+ ia64_intri_res = (is_running_on_xen()) ? \
+ xen_get_ivr() : \
@@ -80204,10 +77636,10 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#define ia64_pal_call_static xen_pal_call_static
+
+#endif /* _ASM_IA64_XEN_PRIVOP_H */
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/asm-ia64/xen/xcom_hcall.h source/include/asm-ia64/xen/xcom_hcall.h
---- /scratch/src/linux-2.6.20.3/include/asm-ia64/xen/xcom_hcall.h 1970-01-01 01:00:00.000000000 +0100
-+++ source/include/asm-ia64/xen/xcom_hcall.h 2007-03-20 21:26:56.000000000 +0100
-@@ -0,0 +1,86 @@
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/asm-ia64/xen/xcom_hcall.h
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/include/asm-ia64/xen/xcom_hcall.h Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,88 @@
+/*
+ * Copyright (C) 2006 Tristan Gingold <tristan.gingold@bull.net>, Bull SAS
+ *
@@ -80261,6 +77693,8 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+extern int xencomm_hypercall_perfmon_op(unsigned long cmd, void* arg,
+ unsigned long count);
+
++extern long xencomm_hypercall_vcpu_op(int cmd, int cpu, void *arg);
++
+/* Using mini xencomm. */
+extern int xencomm_mini_hypercall_console_io(int cmd, int count, char *str);
+
@@ -80294,9 +77728,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+extern int privcmd_hypercall(struct privcmd_hypercall *hypercall);
+
+#endif /* _LINUX_XENCOMM_HCALL_H_ */
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/asm-ia64/xen/xencomm.h source/include/asm-ia64/xen/xencomm.h
---- /scratch/src/linux-2.6.20.3/include/asm-ia64/xen/xencomm.h 1970-01-01 01:00:00.000000000 +0100
-+++ source/include/asm-ia64/xen/xencomm.h 2007-03-20 21:26:56.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/asm-ia64/xen/xencomm.h
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/include/asm-ia64/xen/xencomm.h Wed Aug 08 16:25:28 2007 -0300
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2006 Hollis Blanchard <hollisb@us.ibm.com>, IBM Corporation
@@ -80358,9 +77792,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#define xen_guest_handle(hnd) ((hnd).p)
+
+#endif /* _LINUX_XENCOMM_H_ */
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/asm-ia64/xenoprof.h source/include/asm-ia64/xenoprof.h
---- /scratch/src/linux-2.6.20.3/include/asm-ia64/xenoprof.h 1970-01-01 01:00:00.000000000 +0100
-+++ source/include/asm-ia64/xenoprof.h 2007-03-20 21:26:56.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/asm-ia64/xenoprof.h
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/include/asm-ia64/xenoprof.h Wed Aug 08 16:25:28 2007 -0300
@@ -0,0 +1,48 @@
+/******************************************************************************
+ * asm-ia64/xenoprof.h
@@ -80410,10 +77844,10 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+
+#endif /* CONFIG_XEN */
+#endif /* __ASM_XENOPROF_H__ */
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/asm-um/page.h source/include/asm-um/page.h
---- /scratch/src/linux-2.6.20.3/include/asm-um/page.h 2007-02-04 19:44:54.000000000 +0100
-+++ source/include/asm-um/page.h 2007-03-20 21:26:59.000000000 +0100
-@@ -114,7 +114,7 @@ extern unsigned long uml_physmem;
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/asm-um/page.h
+--- a/include/asm-um/page.h Wed Jul 18 12:23:24 2007 -0300
++++ b/include/asm-um/page.h Wed Aug 08 16:25:28 2007 -0300
+@@ -114,7 +114,7 @@ extern struct page *arch_validate(struct
extern struct page *arch_validate(struct page *page, gfp_t mask, int order);
#define HAVE_ARCH_VALIDATE
@@ -80422,9 +77856,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
#define HAVE_ARCH_FREE_PAGE
#include <asm-generic/memory_model.h>
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/asm-x86_64/apic.h source/include/asm-x86_64/apic.h
---- /scratch/src/linux-2.6.20.3/include/asm-x86_64/apic.h 2007-02-04 19:44:54.000000000 +0100
-+++ source/include/asm-x86_64/apic.h 2007-03-20 21:26:59.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/asm-x86_64/apic.h
+--- a/include/asm-x86_64/apic.h Wed Jul 18 12:23:24 2007 -0300
++++ b/include/asm-x86_64/apic.h Wed Aug 08 16:25:28 2007 -0300
@@ -95,11 +95,13 @@ extern void setup_APIC_extened_lvt(unsig
#define K8_APIC_EXT_INT_MSG_EXT 0x7
#define K8_APIC_EXT_LVT_ENTRY_THRESHOLD 0
@@ -80439,9 +77873,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
extern unsigned boot_cpu_id;
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/asm-x86_64/bootsetup.h source/include/asm-x86_64/bootsetup.h
---- /scratch/src/linux-2.6.20.3/include/asm-x86_64/bootsetup.h 2007-02-04 19:44:54.000000000 +0100
-+++ source/include/asm-x86_64/bootsetup.h 2007-03-20 21:26:59.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/asm-x86_64/bootsetup.h
+--- a/include/asm-x86_64/bootsetup.h Wed Jul 18 12:23:24 2007 -0300
++++ b/include/asm-x86_64/bootsetup.h Wed Aug 08 16:25:28 2007 -0300
@@ -24,9 +24,15 @@ extern char x86_boot_params[BOOT_PARAM_S
#define AUX_DEVICE_INFO (*(unsigned char *) (PARAM+0x1FF))
#define LOADER_TYPE (*(unsigned char *) (PARAM+0x210))
@@ -80454,14 +77888,124 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
#define INITRD_START (*(unsigned int *) (PARAM+0x218))
#define INITRD_SIZE (*(unsigned int *) (PARAM+0x21c))
#define EDID_INFO (*(struct edid_info *) (PARAM+0x140))
-+#endif
++#endif /* CONFIG_XEN */
#define EDD_NR (*(unsigned char *) (PARAM+EDDNR))
#define EDD_MBR_SIG_NR (*(unsigned char *) (PARAM+EDD_MBR_SIG_NR_BUF))
#define EDD_MBR_SIGNATURE ((unsigned int *) (PARAM+EDD_MBR_SIG_BUF))
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/asm-x86_64/dma-mapping.h source/include/asm-x86_64/dma-mapping.h
---- /scratch/src/linux-2.6.20.3/include/asm-x86_64/dma-mapping.h 2007-02-04 19:44:54.000000000 +0100
-+++ source/include/asm-x86_64/dma-mapping.h 2007-03-20 21:26:59.000000000 +0100
-@@ -55,6 +55,7 @@ extern dma_addr_t bad_dma_address;
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/asm-x86_64/desc.h
+--- a/include/asm-x86_64/desc.h Wed Jul 18 12:23:24 2007 -0300
++++ b/include/asm-x86_64/desc.h Wed Aug 08 16:25:28 2007 -0300
+@@ -18,14 +18,31 @@ extern struct desc_struct cpu_gdt_table[
+
+ #define load_TR_desc() asm volatile("ltr %w0"::"r" (GDT_ENTRY_TSS*8))
+ #define load_LDT_desc() asm volatile("lldt %w0"::"r" (GDT_ENTRY_LDT*8))
++#ifdef CONFIG_XEN
++static inline void clear_LDT(void)
++{
++ int cpu = get_cpu();
++
++ /*
++ * NB. We load the default_ldt for lcall7/27 handling on demand, as
++ * it slows down context switching. Noone uses it anyway.
++ */
++ cpu = cpu; /* XXX avoid compiler warning */
++ xen_set_ldt(0UL, 0);
++ put_cpu();
++}
++#else
+ #define clear_LDT() asm volatile("lldt %w0"::"r" (0))
++#endif
+
+ /*
+ * This is the ldt that every process will get unless we need
+ * something other than this.
+ */
+ extern struct desc_struct default_ldt[];
++#ifndef CONFIG_X86_NO_IDT
+ extern struct gate_struct idt_table[];
++#endif
+ extern struct desc_ptr cpu_gdt_descr[];
+
+ /* the cpu gdt accessor */
+@@ -48,6 +65,7 @@ static inline void _set_gate(void *adr,
+ memcpy(adr, &s, 16);
+ }
+
++#ifndef CONFIG_X86_NO_IDT
+ static inline void set_intr_gate(int nr, void *func)
+ {
+ BUG_ON((unsigned)nr > 0xFF);
+@@ -70,6 +88,7 @@ static inline void set_system_gate_ist(i
+ {
+ _set_gate(&idt_table[nr], GATE_INTERRUPT, (unsigned long) func, 3, ist);
+ }
++#endif
+
+ static inline void set_tssldt_descriptor(void *ptr, unsigned long tss, unsigned type,
+ unsigned size)
+@@ -87,6 +106,7 @@ static inline void set_tssldt_descriptor
+ memcpy(ptr, &d, 16);
+ }
+
++#ifndef CONFIG_X86_NO_TSS
+ static inline void set_tss_desc(unsigned cpu, void *addr)
+ {
+ /*
+@@ -100,6 +120,7 @@ static inline void set_tss_desc(unsigned
+ (unsigned long)addr, DESC_TSS,
+ IO_BITMAP_OFFSET + IO_BITMAP_BYTES + sizeof(unsigned long) - 1);
+ }
++#endif
+
+ static inline void set_ldt_desc(unsigned cpu, void *addr, int size)
+ {
+@@ -151,10 +172,18 @@ static inline void set_seg_base(unsigned
+
+ static inline void load_TLS(struct thread_struct *t, unsigned int cpu)
+ {
++#ifdef CONFIG_XEN
++#define C(i) \
++ HYPERVISOR_update_descriptor(virt_to_machine(&cpu_gdt(cpu)[GDT_ENTRY_TLS_MIN + i]), t->tls_array[i])
++
++ C(0); C(1); C(2);
++#undef C
++#else
+ u64 *gdt = (u64 *)(cpu_gdt(cpu) + GDT_ENTRY_TLS_MIN);
+ gdt[0] = t->tls_array[0];
+ gdt[1] = t->tls_array[1];
+ gdt[2] = t->tls_array[2];
++#endif
+ }
+
+ /*
+@@ -162,6 +191,15 @@ static inline void load_TLS(struct threa
+ */
+ static inline void load_LDT_nolock (mm_context_t *pc, int cpu)
+ {
++#ifdef CONFIG_XEN
++ void *segments = pc->ldt;
++ int count = pc->size;
++
++ if (likely(!count))
++ segments = NULL;
++
++ xen_set_ldt((unsigned long)segments, count);
++#else
+ int count = pc->size;
+
+ if (likely(!count)) {
+@@ -171,6 +209,7 @@ static inline void load_LDT_nolock (mm_c
+
+ set_ldt_desc(cpu, pc->ldt, count);
+ load_LDT_desc();
++#endif
+ }
+
+ static inline void load_LDT(mm_context_t *pc)
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/asm-x86_64/dma-mapping.h
+--- a/include/asm-x86_64/dma-mapping.h Wed Jul 18 12:23:24 2007 -0300
++++ b/include/asm-x86_64/dma-mapping.h Wed Aug 08 16:25:28 2007 -0300
+@@ -55,6 +55,7 @@ extern struct dma_mapping_ops* dma_ops;
extern struct dma_mapping_ops* dma_ops;
extern int iommu_merge;
@@ -80480,9 +78024,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
extern int panic_on_overflow;
#endif /* _X8664_DMA_MAPPING_H */
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/asm-x86_64/dmi.h source/include/asm-x86_64/dmi.h
---- /scratch/src/linux-2.6.20.3/include/asm-x86_64/dmi.h 2007-02-04 19:44:54.000000000 +0100
-+++ source/include/asm-x86_64/dmi.h 2007-03-20 21:26:59.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/asm-x86_64/dmi.h
+--- a/include/asm-x86_64/dmi.h Wed Jul 18 12:23:24 2007 -0300
++++ b/include/asm-x86_64/dmi.h Wed Aug 08 16:25:28 2007 -0300
@@ -5,6 +5,10 @@
extern void *dmi_ioremap(unsigned long addr, unsigned long size);
@@ -80507,9 +78051,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#endif
#endif
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/asm-x86_64/dwarf2.h source/include/asm-x86_64/dwarf2.h
---- /scratch/src/linux-2.6.20.3/include/asm-x86_64/dwarf2.h 2007-02-04 19:44:54.000000000 +0100
-+++ source/include/asm-x86_64/dwarf2.h 2007-03-20 21:26:59.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/asm-x86_64/dwarf2.h
+--- a/include/asm-x86_64/dwarf2.h Wed Jul 18 12:23:24 2007 -0300
++++ b/include/asm-x86_64/dwarf2.h Wed Aug 08 16:25:28 2007 -0300
@@ -13,7 +13,7 @@
away for older version.
*/
@@ -80519,10 +78063,10 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
#define CFI_STARTPROC .cfi_startproc
#define CFI_ENDPROC .cfi_endproc
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/asm-x86_64/e820.h source/include/asm-x86_64/e820.h
---- /scratch/src/linux-2.6.20.3/include/asm-x86_64/e820.h 2007-02-04 19:44:54.000000000 +0100
-+++ source/include/asm-x86_64/e820.h 2007-03-20 21:26:59.000000000 +0100
-@@ -41,13 +41,21 @@ extern void add_memory_region(unsigned l
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/asm-x86_64/e820.h
+--- a/include/asm-x86_64/e820.h Wed Jul 18 12:23:24 2007 -0300
++++ b/include/asm-x86_64/e820.h Wed Aug 08 16:25:28 2007 -0300
+@@ -41,13 +41,21 @@ extern void setup_memory_region(void);
extern void setup_memory_region(void);
extern void contig_e820_setup(void);
extern unsigned long e820_end_of_ram(void);
@@ -80544,9 +78088,28 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
extern void e820_register_active_regions(int nid,
unsigned long start_pfn, unsigned long end_pfn);
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/asm-x86_64/ipi.h source/include/asm-x86_64/ipi.h
---- /scratch/src/linux-2.6.20.3/include/asm-x86_64/ipi.h 2007-02-04 19:44:54.000000000 +0100
-+++ source/include/asm-x86_64/ipi.h 2007-03-20 21:26:59.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/asm-x86_64/hw_irq.h
+--- a/include/asm-x86_64/hw_irq.h Wed Jul 18 12:23:24 2007 -0300
++++ b/include/asm-x86_64/hw_irq.h Wed Aug 08 16:25:28 2007 -0300
+@@ -43,6 +43,7 @@
+ * into a single vector (CALL_FUNCTION_VECTOR) to save vector space.
+ * TLB, reschedule and local APIC vectors are performance-critical.
+ */
++#ifndef CONFIG_XEN
+ #define SPURIOUS_APIC_VECTOR 0xff
+ #define ERROR_APIC_VECTOR 0xfe
+ #define RESCHEDULE_VECTOR 0xfd
+@@ -56,6 +57,7 @@
+ #define INVALIDATE_TLB_VECTOR_START 0xf0 /* f0-f7 used for TLB flush */
+
+ #define NUM_INVALIDATE_TLB_VECTORS 8
++#endif
+
+ /*
+ * Local APIC timer IRQ vector is on a different priority level,
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/asm-x86_64/ipi.h
+--- a/include/asm-x86_64/ipi.h Wed Jul 18 12:23:24 2007 -0300
++++ b/include/asm-x86_64/ipi.h Wed Aug 08 16:25:28 2007 -0300
@@ -49,8 +49,12 @@ static inline int __prepare_ICR2 (unsign
return SET_APIC_DEST_FIELD(mask);
}
@@ -80568,9 +78131,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
}
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/asm-x86_64/kexec.h source/include/asm-x86_64/kexec.h
---- /scratch/src/linux-2.6.20.3/include/asm-x86_64/kexec.h 2007-02-04 19:44:54.000000000 +0100
-+++ source/include/asm-x86_64/kexec.h 2007-03-20 21:26:59.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/asm-x86_64/kexec.h
+--- a/include/asm-x86_64/kexec.h Wed Jul 18 12:23:24 2007 -0300
++++ b/include/asm-x86_64/kexec.h Wed Aug 08 16:25:28 2007 -0300
@@ -91,6 +91,19 @@ relocate_kernel(unsigned long indirectio
unsigned long page_list,
unsigned long start_address) ATTRIB_NORET;
@@ -80591,9 +78154,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
#endif /* __ASSEMBLY__ */
#endif /* _X86_64_KEXEC_H */
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/asm-x86_64/mach-xen/asm/agp.h source/include/asm-x86_64/mach-xen/asm/agp.h
---- /scratch/src/linux-2.6.20.3/include/asm-x86_64/mach-xen/asm/agp.h 1970-01-01 01:00:00.000000000 +0100
-+++ source/include/asm-x86_64/mach-xen/asm/agp.h 2007-03-20 21:26:59.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/asm-x86_64/mach-xen/asm/agp.h
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/include/asm-x86_64/mach-xen/asm/agp.h Wed Aug 08 16:25:28 2007 -0300
@@ -0,0 +1,35 @@
+#ifndef AGP_H
+#define AGP_H 1
@@ -80630,256 +78193,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ dma_free_coherent(NULL,PAGE_SIZE<<(order),(table),virt_to_bus(table))
+
+#endif
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/asm-x86_64/mach-xen/asm/arch_hooks.h source/include/asm-x86_64/mach-xen/asm/arch_hooks.h
---- /scratch/src/linux-2.6.20.3/include/asm-x86_64/mach-xen/asm/arch_hooks.h 1970-01-01 01:00:00.000000000 +0100
-+++ source/include/asm-x86_64/mach-xen/asm/arch_hooks.h 2007-03-20 21:26:59.000000000 +0100
-@@ -0,0 +1,27 @@
-+#ifndef _ASM_ARCH_HOOKS_H
-+#define _ASM_ARCH_HOOKS_H
-+
-+#include <linux/interrupt.h>
-+
-+/*
-+ * linux/include/asm/arch_hooks.h
-+ *
-+ * define the architecture specific hooks
-+ */
-+
-+/* these aren't arch hooks, they are generic routines
-+ * that can be used by the hooks */
-+extern void init_ISA_irqs(void);
-+extern void apic_intr_init(void);
-+extern void smp_intr_init(void);
-+extern irqreturn_t timer_interrupt(int irq, void *dev_id);
-+
-+/* these are the defined hooks */
-+extern void intr_init_hook(void);
-+extern void pre_intr_init_hook(void);
-+extern void pre_setup_arch_hook(void);
-+extern void trap_init_hook(void);
-+extern void time_init_hook(void);
-+extern void mca_nmi_hook(void);
-+
-+#endif
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/asm-x86_64/mach-xen/asm/desc.h source/include/asm-x86_64/mach-xen/asm/desc.h
---- /scratch/src/linux-2.6.20.3/include/asm-x86_64/mach-xen/asm/desc.h 1970-01-01 01:00:00.000000000 +0100
-+++ source/include/asm-x86_64/mach-xen/asm/desc.h 2007-03-20 21:26:59.000000000 +0100
-@@ -0,0 +1,212 @@
-+/* Written 2000 by Andi Kleen */
-+#ifndef __ARCH_DESC_H
-+#define __ARCH_DESC_H
-+
-+#include <linux/threads.h>
-+#include <asm/ldt.h>
-+
-+#ifndef __ASSEMBLY__
-+
-+#include <linux/string.h>
-+#include <linux/smp.h>
-+#include <asm/desc_defs.h>
-+
-+#include <asm/segment.h>
-+#include <asm/mmu.h>
-+
-+extern struct desc_struct cpu_gdt_table[GDT_ENTRIES];
-+
-+extern struct desc_ptr idt_descr, cpu_gdt_descr[NR_CPUS];
-+
-+#define load_TR_desc() asm volatile("ltr %w0"::"r" (GDT_ENTRY_TSS*8))
-+#define load_LDT_desc() asm volatile("lldt %w0"::"r" (GDT_ENTRY_LDT*8))
-+
-+static inline void clear_LDT(void)
-+{
-+ int cpu = get_cpu();
-+
-+ /*
-+ * NB. We load the default_ldt for lcall7/27 handling on demand, as
-+ * it slows down context switching. Noone uses it anyway.
-+ */
-+ cpu = cpu; /* XXX avoid compiler warning */
-+ xen_set_ldt(0UL, 0);
-+ put_cpu();
-+}
-+
-+/*
-+ * This is the ldt that every process will get unless we need
-+ * something other than this.
-+ */
-+extern struct desc_struct default_ldt[];
-+#ifndef CONFIG_X86_NO_IDT
-+extern struct gate_struct idt_table[];
-+#endif
-+extern struct desc_ptr cpu_gdt_descr[];
-+
-+/* the cpu gdt accessor */
-+#define cpu_gdt(_cpu) ((struct desc_struct *)cpu_gdt_descr[_cpu].address)
-+
-+static inline void _set_gate(void *adr, unsigned type, unsigned long func, unsigned dpl, unsigned ist)
-+{
-+ struct gate_struct s;
-+ s.offset_low = PTR_LOW(func);
-+ s.segment = __KERNEL_CS;
-+ s.ist = ist;
-+ s.p = 1;
-+ s.dpl = dpl;
-+ s.zero0 = 0;
-+ s.zero1 = 0;
-+ s.type = type;
-+ s.offset_middle = PTR_MIDDLE(func);
-+ s.offset_high = PTR_HIGH(func);
-+ /* does not need to be atomic because it is only done once at setup time */
-+ memcpy(adr, &s, 16);
-+}
-+
-+#ifndef CONFIG_X86_NO_IDT
-+static inline void set_intr_gate(int nr, void *func)
-+{
-+ BUG_ON((unsigned)nr > 0xFF);
-+ _set_gate(&idt_table[nr], GATE_INTERRUPT, (unsigned long) func, 0, 0);
-+}
-+
-+static inline void set_intr_gate_ist(int nr, void *func, unsigned ist)
-+{
-+ BUG_ON((unsigned)nr > 0xFF);
-+ _set_gate(&idt_table[nr], GATE_INTERRUPT, (unsigned long) func, 0, ist);
-+}
-+
-+static inline void set_system_gate(int nr, void *func)
-+{
-+ BUG_ON((unsigned)nr > 0xFF);
-+ _set_gate(&idt_table[nr], GATE_INTERRUPT, (unsigned long) func, 3, 0);
-+}
-+
-+static inline void set_system_gate_ist(int nr, void *func, unsigned ist)
-+{
-+ _set_gate(&idt_table[nr], GATE_INTERRUPT, (unsigned long) func, 3, ist);
-+}
-+#endif
-+
-+static inline void set_tssldt_descriptor(void *ptr, unsigned long tss, unsigned type,
-+ unsigned size)
-+{
-+ struct ldttss_desc d;
-+ memset(&d,0,sizeof(d));
-+ d.limit0 = size & 0xFFFF;
-+ d.base0 = PTR_LOW(tss);
-+ d.base1 = PTR_MIDDLE(tss) & 0xFF;
-+ d.type = type;
-+ d.p = 1;
-+ d.limit1 = (size >> 16) & 0xF;
-+ d.base2 = (PTR_MIDDLE(tss) >> 8) & 0xFF;
-+ d.base3 = PTR_HIGH(tss);
-+ memcpy(ptr, &d, 16);
-+}
-+
-+#ifndef CONFIG_X86_NO_TSS
-+static inline void set_tss_desc(unsigned cpu, void *addr)
-+{
-+ /*
-+ * sizeof(unsigned long) coming from an extra "long" at the end
-+ * of the iobitmap. See tss_struct definition in processor.h
-+ *
-+ * -1? seg base+limit should be pointing to the address of the
-+ * last valid byte
-+ */
-+ set_tssldt_descriptor(&cpu_gdt(cpu)[GDT_ENTRY_TSS],
-+ (unsigned long)addr, DESC_TSS,
-+ IO_BITMAP_OFFSET + IO_BITMAP_BYTES + sizeof(unsigned long) - 1);
-+}
-+#endif
-+
-+static inline void set_ldt_desc(unsigned cpu, void *addr, int size)
-+{
-+ set_tssldt_descriptor(&cpu_gdt(cpu)[GDT_ENTRY_LDT], (unsigned long)addr,
-+ DESC_LDT, size * 8 - 1);
-+}
-+
-+static inline void set_seg_base(unsigned cpu, int entry, void *base)
-+{
-+ struct desc_struct *d = &cpu_gdt(cpu)[entry];
-+ u32 addr = (u32)(u64)base;
-+ BUG_ON((u64)base >> 32);
-+ d->base0 = addr & 0xffff;
-+ d->base1 = (addr >> 16) & 0xff;
-+ d->base2 = (addr >> 24) & 0xff;
-+}
-+
-+#define LDT_entry_a(info) \
-+ ((((info)->base_addr & 0x0000ffff) << 16) | ((info)->limit & 0x0ffff))
-+/* Don't allow setting of the lm bit. It is useless anyways because
-+ 64bit system calls require __USER_CS. */
-+#define LDT_entry_b(info) \
-+ (((info)->base_addr & 0xff000000) | \
-+ (((info)->base_addr & 0x00ff0000) >> 16) | \
-+ ((info)->limit & 0xf0000) | \
-+ (((info)->read_exec_only ^ 1) << 9) | \
-+ ((info)->contents << 10) | \
-+ (((info)->seg_not_present ^ 1) << 15) | \
-+ ((info)->seg_32bit << 22) | \
-+ ((info)->limit_in_pages << 23) | \
-+ ((info)->useable << 20) | \
-+ /* ((info)->lm << 21) | */ \
-+ 0x7000)
-+
-+#define LDT_empty(info) (\
-+ (info)->base_addr == 0 && \
-+ (info)->limit == 0 && \
-+ (info)->contents == 0 && \
-+ (info)->read_exec_only == 1 && \
-+ (info)->seg_32bit == 0 && \
-+ (info)->limit_in_pages == 0 && \
-+ (info)->seg_not_present == 1 && \
-+ (info)->useable == 0 && \
-+ (info)->lm == 0)
-+
-+#if TLS_SIZE != 24
-+# error update this code.
-+#endif
-+
-+static inline void load_TLS(struct thread_struct *t, unsigned int cpu)
-+{
-+#if 0
-+ u64 *gdt = (u64 *)(cpu_gdt(cpu) + GDT_ENTRY_TLS_MIN);
-+ gdt[0] = t->tls_array[0];
-+ gdt[1] = t->tls_array[1];
-+ gdt[2] = t->tls_array[2];
-+#endif
-+#define C(i) \
-+ HYPERVISOR_update_descriptor(virt_to_machine(&cpu_gdt(cpu)[GDT_ENTRY_TLS_MIN + i]), t->tls_array[i])
-+
-+ C(0); C(1); C(2);
-+#undef C
-+}
-+
-+/*
-+ * load one particular LDT into the current CPU
-+ */
-+static inline void load_LDT_nolock (mm_context_t *pc, int cpu)
-+{
-+ void *segments = pc->ldt;
-+ int count = pc->size;
-+
-+ if (likely(!count))
-+ segments = NULL;
-+
-+ xen_set_ldt((unsigned long)segments, count);
-+}
-+
-+static inline void load_LDT(mm_context_t *pc)
-+{
-+ int cpu = get_cpu();
-+ load_LDT_nolock(pc, cpu);
-+ put_cpu();
-+}
-+
-+extern struct desc_ptr idt_descr;
-+
-+#endif /* !__ASSEMBLY__ */
-+
-+#endif
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/asm-x86_64/mach-xen/asm/fixmap.h source/include/asm-x86_64/mach-xen/asm/fixmap.h
---- /scratch/src/linux-2.6.20.3/include/asm-x86_64/mach-xen/asm/fixmap.h 1970-01-01 01:00:00.000000000 +0100
-+++ source/include/asm-x86_64/mach-xen/asm/fixmap.h 2007-03-20 21:26:59.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/asm-x86_64/mach-xen/asm/fixmap.h
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/include/asm-x86_64/mach-xen/asm/fixmap.h Wed Aug 08 16:25:28 2007 -0300
@@ -0,0 +1,108 @@
+/*
+ * fixmap.h: compile-time virtual memory allocation
@@ -80989,10 +78305,10 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+}
+
+#endif
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/asm-x86_64/mach-xen/asm/floppy.h source/include/asm-x86_64/mach-xen/asm/floppy.h
---- /scratch/src/linux-2.6.20.3/include/asm-x86_64/mach-xen/asm/floppy.h 1970-01-01 01:00:00.000000000 +0100
-+++ source/include/asm-x86_64/mach-xen/asm/floppy.h 2007-03-20 21:26:59.000000000 +0100
-@@ -0,0 +1,207 @@
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/asm-x86_64/mach-xen/asm/floppy.h
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/include/asm-x86_64/mach-xen/asm/floppy.h Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,206 @@
+/*
+ * Architecture specific parts of the Floppy driver
+ *
@@ -81009,7 +78325,6 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+
+#include <linux/vmalloc.h>
+
-+
+/*
+ * The DMA channel used by the floppy controller cannot access data at
+ * addresses >= 16MB
@@ -81200,149 +78515,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#define EXTRA_FLOPPY_PARAMS
+
+#endif /* __ASM_XEN_X86_64_FLOPPY_H */
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/asm-x86_64/mach-xen/asm/hw_irq.h source/include/asm-x86_64/mach-xen/asm/hw_irq.h
---- /scratch/src/linux-2.6.20.3/include/asm-x86_64/mach-xen/asm/hw_irq.h 1970-01-01 01:00:00.000000000 +0100
-+++ source/include/asm-x86_64/mach-xen/asm/hw_irq.h 2007-03-20 21:26:59.000000000 +0100
-@@ -0,0 +1,136 @@
-+#ifndef _ASM_HW_IRQ_H
-+#define _ASM_HW_IRQ_H
-+
-+/*
-+ * linux/include/asm/hw_irq.h
-+ *
-+ * (C) 1992, 1993 Linus Torvalds, (C) 1997 Ingo Molnar
-+ *
-+ * moved some of the old arch/i386/kernel/irq.h to here. VY
-+ *
-+ * IRQ/IPI changes taken from work by Thomas Radke
-+ * <tomsoft@informatik.tu-chemnitz.de>
-+ *
-+ * hacked by Andi Kleen for x86-64.
-+ */
-+
-+#ifndef __ASSEMBLY__
-+#include <asm/atomic.h>
-+#include <asm/irq.h>
-+#include <linux/profile.h>
-+#include <linux/smp.h>
-+#include <linux/percpu.h>
-+#endif
-+
-+#define NMI_VECTOR 0x02
-+/*
-+ * IDT vectors usable for external interrupt sources start
-+ * at 0x20:
-+ */
-+#define FIRST_EXTERNAL_VECTOR 0x20
-+
-+#define IA32_SYSCALL_VECTOR 0x80
-+
-+
-+/*
-+ * Vectors 0x20-0x2f are used for ISA interrupts.
-+ */
-+
-+/*
-+ * Special IRQ vectors used by the SMP architecture, 0xf0-0xff
-+ *
-+ * some of the following vectors are 'rare', they are merged
-+ * into a single vector (CALL_FUNCTION_VECTOR) to save vector space.
-+ * TLB, reschedule and local APIC vectors are performance-critical.
-+ */
-+#ifndef CONFIG_XEN
-+#define SPURIOUS_APIC_VECTOR 0xff
-+#define ERROR_APIC_VECTOR 0xfe
-+#define RESCHEDULE_VECTOR 0xfd
-+#define CALL_FUNCTION_VECTOR 0xfc
-+/* fb free - please don't readd KDB here because it's useless
-+ (hint - think what a NMI bit does to a vector) */
-+#define THERMAL_APIC_VECTOR 0xfa
-+#define THRESHOLD_APIC_VECTOR 0xf9
-+/* f8 free */
-+#define INVALIDATE_TLB_VECTOR_END 0xf7
-+#define INVALIDATE_TLB_VECTOR_START 0xf0 /* f0-f7 used for TLB flush */
-+
-+#define NUM_INVALIDATE_TLB_VECTORS 8
-+#endif
-+
-+/*
-+ * Local APIC timer IRQ vector is on a different priority level,
-+ * to work around the 'lost local interrupt if more than 2 IRQ
-+ * sources per level' errata.
-+ */
-+#define LOCAL_TIMER_VECTOR 0xef
-+
-+/*
-+ * First APIC vector available to drivers: (vectors 0x30-0xee)
-+ * we start at 0x31 to spread out vectors evenly between priority
-+ * levels. (0x80 is the syscall vector)
-+ */
-+#define FIRST_DEVICE_VECTOR 0x31
-+#define FIRST_SYSTEM_VECTOR 0xef /* duplicated in irq.h */
-+
-+
-+#ifndef __ASSEMBLY__
-+typedef int vector_irq_t[NR_VECTORS];
-+DECLARE_PER_CPU(vector_irq_t, vector_irq);
-+extern void __setup_vector_irq(int cpu);
-+extern spinlock_t vector_lock;
-+
-+/*
-+ * Various low-level irq details needed by irq.c, process.c,
-+ * time.c, io_apic.c and smp.c
-+ *
-+ * Interrupt entry/exit code at both C and assembly level
-+ */
-+
-+extern void disable_8259A_irq(unsigned int irq);
-+extern void enable_8259A_irq(unsigned int irq);
-+extern int i8259A_irq_pending(unsigned int irq);
-+extern void make_8259A_irq(unsigned int irq);
-+extern void init_8259A(int aeoi);
-+extern void FASTCALL(send_IPI_self(int vector));
-+extern void init_VISWS_APIC_irqs(void);
-+extern void setup_IO_APIC(void);
-+extern void disable_IO_APIC(void);
-+extern void print_IO_APIC(void);
-+extern int IO_APIC_get_PCI_irq_vector(int bus, int slot, int fn);
-+extern void send_IPI(int dest, int vector);
-+extern void setup_ioapic_dest(void);
-+
-+extern unsigned long io_apic_irqs;
-+
-+extern atomic_t irq_err_count;
-+extern atomic_t irq_mis_count;
-+
-+#define IO_APIC_IRQ(x) (((x) >= 16) || ((1<<(x)) & io_apic_irqs))
-+
-+#define __STR(x) #x
-+#define STR(x) __STR(x)
-+
-+#include <asm/ptrace.h>
-+
-+#define IRQ_NAME2(nr) nr##_interrupt(void)
-+#define IRQ_NAME(nr) IRQ_NAME2(IRQ##nr)
-+
-+/*
-+ * SMP has a few special interrupts for IPI messages
-+ */
-+
-+#define BUILD_IRQ(nr) \
-+asmlinkage void IRQ_NAME(nr); \
-+__asm__( \
-+"\n.p2align\n" \
-+"IRQ" #nr "_interrupt:\n\t" \
-+ "push $" #nr "-256 ; " \
-+ "jmp common_interrupt");
-+
-+#define platform_legacy_irq(irq) ((irq) < 16)
-+
-+#endif
-+
-+#endif /* _ASM_HW_IRQ_H */
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/asm-x86_64/mach-xen/asm/hypercall.h source/include/asm-x86_64/mach-xen/asm/hypercall.h
---- /scratch/src/linux-2.6.20.3/include/asm-x86_64/mach-xen/asm/hypercall.h 1970-01-01 01:00:00.000000000 +0100
-+++ source/include/asm-x86_64/mach-xen/asm/hypercall.h 2007-03-20 21:26:59.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/asm-x86_64/mach-xen/asm/hypercall.h
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/include/asm-x86_64/mach-xen/asm/hypercall.h Wed Aug 08 16:25:28 2007 -0300
@@ -0,0 +1,406 @@
+/******************************************************************************
+ * hypercall.h
@@ -81550,11 +78725,11 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+}
+
+static inline int
-+HYPERVISOR_dom0_op(
-+ dom0_op_t *dom0_op)
++HYPERVISOR_platform_op(
++ struct xen_platform_op *platform_op)
+{
-+ dom0_op->interface_version = DOM0_INTERFACE_VERSION;
-+ return _hypercall1(int, dom0_op, dom0_op);
++ platform_op->interface_version = XENPF_INTERFACE_VERSION;
++ return _hypercall1(int, platform_op, platform_op);
+}
+
+static inline int
@@ -81587,7 +78762,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+
+static inline int
+HYPERVISOR_multicall(
-+ void *call_list, int nr_calls)
++ multicall_entry_t *call_list, int nr_calls)
+{
+ return _hypercall2(int, multicall, call_list, nr_calls);
+}
@@ -81605,7 +78780,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+{
+ int rc = _hypercall2(int, event_channel_op, cmd, arg);
+
-+#ifdef CONFIG_XEN_COMPAT_030002
++#if CONFIG_XEN_COMPAT <= 0x030002
+ if (unlikely(rc == -ENOSYS)) {
+ struct evtchn_op op;
+ op.cmd = cmd;
@@ -81645,7 +78820,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+{
+ int rc = _hypercall2(int, physdev_op, cmd, arg);
+
-+#ifdef CONFIG_XEN_COMPAT_030002
++#if CONFIG_XEN_COMPAT <= 0x030002
+ if (unlikely(rc == -ENOSYS)) {
+ struct physdev_op op;
+ op.cmd = cmd;
@@ -81705,7 +78880,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ int rc = _hypercall3(int, sched_op, SCHEDOP_shutdown,
+ &sched_shutdown, srec);
+
-+#ifdef CONFIG_XEN_COMPAT_030002
++#if CONFIG_XEN_COMPAT <= 0x030002
+ if (rc == -ENOSYS)
+ rc = _hypercall3(int, sched_op_compat, SCHEDOP_shutdown,
+ SHUTDOWN_suspend, srec);
@@ -81750,16 +78925,16 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+}
+
+#endif /* __HYPERCALL_H__ */
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/asm-x86_64/mach-xen/asm/hypervisor.h source/include/asm-x86_64/mach-xen/asm/hypervisor.h
---- /scratch/src/linux-2.6.20.3/include/asm-x86_64/mach-xen/asm/hypervisor.h 1970-01-01 01:00:00.000000000 +0100
-+++ source/include/asm-x86_64/mach-xen/asm/hypervisor.h 2007-03-20 21:26:59.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/asm-x86_64/mach-xen/asm/hypervisor.h
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/include/asm-x86_64/mach-xen/asm/hypervisor.h Wed Aug 08 16:25:28 2007 -0300
@@ -0,0 +1,2 @@
+
+#include <asm-i386/mach-xen/asm/hypervisor.h>
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/asm-x86_64/mach-xen/asm/io.h source/include/asm-x86_64/mach-xen/asm/io.h
---- /scratch/src/linux-2.6.20.3/include/asm-x86_64/mach-xen/asm/io.h 1970-01-01 01:00:00.000000000 +0100
-+++ source/include/asm-x86_64/mach-xen/asm/io.h 2007-03-20 21:26:59.000000000 +0100
-@@ -0,0 +1,301 @@
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/asm-x86_64/mach-xen/asm/io.h
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/include/asm-x86_64/mach-xen/asm/io.h Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,303 @@
+#ifndef _ASM_IO_H
+#define _ASM_IO_H
+
@@ -81912,8 +79087,10 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ return __ioremap(offset, size, 0);
+}
+
-+extern void *early_ioremap(unsigned long addr, unsigned long size);
-+extern void early_iounmap(void *addr, unsigned long size);
++extern void *bt_ioremap(unsigned long addr, unsigned long size);
++extern void bt_iounmap(void *addr, unsigned long size);
++#define early_ioremap bt_ioremap
++#define early_iounmap bt_iounmap
+
+/*
+ * This one maps high address device memory and turns off caching for that area.
@@ -82061,10 +79238,48 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#define ARCH_HAS_DEV_MEM
+
+#endif
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/asm-x86_64/mach-xen/asm/irqflags.h source/include/asm-x86_64/mach-xen/asm/irqflags.h
---- /scratch/src/linux-2.6.20.3/include/asm-x86_64/mach-xen/asm/irqflags.h 1970-01-01 01:00:00.000000000 +0100
-+++ source/include/asm-x86_64/mach-xen/asm/irqflags.h 2007-03-20 21:26:59.000000000 +0100
-@@ -0,0 +1,65 @@
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/asm-x86_64/mach-xen/asm/irq.h
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/include/asm-x86_64/mach-xen/asm/irq.h Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,34 @@
++#ifndef _ASM_IRQ_H
++#define _ASM_IRQ_H
++
++/*
++ * linux/include/asm/irq.h
++ *
++ * (C) 1992, 1993 Linus Torvalds, (C) 1997 Ingo Molnar
++ *
++ * IRQ/IPI changes taken from work by Thomas Radke
++ * <tomsoft@informatik.tu-chemnitz.de>
++ */
++
++#include <linux/sched.h>
++/* include comes from machine specific directory */
++#include "irq_vectors.h"
++#include <asm/thread_info.h>
++
++static __inline__ int irq_canonicalize(int irq)
++{
++ return ((irq == 2) ? 9 : irq);
++}
++
++#define ARCH_HAS_NMI_WATCHDOG /* See include/linux/nmi.h */
++
++# define irq_ctx_init(cpu) do { } while (0)
++
++#ifdef CONFIG_HOTPLUG_CPU
++#include <linux/cpumask.h>
++extern void fixup_irqs(cpumask_t map);
++#endif
++
++#define __ARCH_HAS_DO_SOFTIRQ 1
++
++#endif /* _ASM_IRQ_H */
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/asm-x86_64/mach-xen/asm/irqflags.h
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/include/asm-x86_64/mach-xen/asm/irqflags.h Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,131 @@
+/*
+ * include/asm-x86_64/irqflags.h
+ *
@@ -82082,29 +79297,96 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ * Interrupt control:
+ */
+
-+unsigned long __raw_local_save_flags(void);
++#define __raw_local_save_flags() (current_vcpu_info()->evtchn_upcall_mask)
++
+#define raw_local_save_flags(flags) \
+ do { (flags) = __raw_local_save_flags(); } while (0)
+
-+void raw_local_irq_restore(unsigned long flags);
-+void raw_local_irq_disable(void);
-+void raw_local_irq_enable(void);
++#define raw_local_irq_restore(x) \
++do { \
++ vcpu_info_t *_vcpu; \
++ barrier(); \
++ _vcpu = current_vcpu_info(); \
++ if ((_vcpu->evtchn_upcall_mask = (x)) == 0) { \
++ barrier(); /* unmask then check (avoid races) */ \
++ if ( unlikely(_vcpu->evtchn_upcall_pending) ) \
++ force_evtchn_callback(); \
++ } \
++} while (0)
++
++#ifdef CONFIG_X86_VSMP
++
++/*
++ * Interrupt control for the VSMP architecture:
++ */
++
++static inline void raw_local_irq_disable(void)
++{
++ unsigned long flags = __raw_local_save_flags();
++
++ raw_local_irq_restore((flags & ~(1 << 9)) | (1 << 18));
++}
++
++static inline void raw_local_irq_enable(void)
++{
++ unsigned long flags = __raw_local_save_flags();
++
++ raw_local_irq_restore((flags | (1 << 9)) & ~(1 << 18));
++}
+
+static inline int raw_irqs_disabled_flags(unsigned long flags)
+{
-+ return flags != 0;
++ return !(flags & (1<<9)) || (flags & (1 << 18));
+}
+
++#else /* CONFIG_X86_VSMP */
++
++#define raw_local_irq_disable() \
++do { \
++ current_vcpu_info()->evtchn_upcall_mask = 1; \
++ barrier(); \
++} while (0)
++
++#define raw_local_irq_enable() \
++do { \
++ vcpu_info_t *_vcpu; \
++ barrier(); \
++ _vcpu = current_vcpu_info(); \
++ _vcpu->evtchn_upcall_mask = 0; \
++ barrier(); /* unmask then check (avoid races) */ \
++ if ( unlikely(_vcpu->evtchn_upcall_pending) ) \
++ force_evtchn_callback(); \
++} while (0)
++
++static inline int raw_irqs_disabled_flags(unsigned long flags)
++{
++ return (flags != 0);
++}
++
++#endif
++
+/*
+ * For spinlocks, etc.:
+ */
+
-+unsigned long __raw_local_irq_save(void);
++#define __raw_local_irq_save() \
++({ \
++ unsigned long flags = __raw_local_save_flags(); \
++ \
++ raw_local_irq_disable(); \
++ \
++ flags; \
++})
+
+#define raw_local_irq_save(flags) \
+ do { (flags) = __raw_local_irq_save(); } while (0)
+
-+int raw_irqs_disabled(void);
++#define raw_irqs_disabled() \
++({ \
++ unsigned long flags = __raw_local_save_flags(); \
++ \
++ raw_irqs_disabled_flags(flags); \
++})
+
+/*
+ * Used in the idle loop; sti takes one instruction cycle
@@ -82112,7 +79394,6 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ */
+void raw_safe_halt(void);
+
-+
+/*
+ * Used when interrupts are already enabled or to
+ * shutdown the processor:
@@ -82130,48 +79411,10 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#endif
+
+#endif
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/asm-x86_64/mach-xen/asm/irq.h source/include/asm-x86_64/mach-xen/asm/irq.h
---- /scratch/src/linux-2.6.20.3/include/asm-x86_64/mach-xen/asm/irq.h 1970-01-01 01:00:00.000000000 +0100
-+++ source/include/asm-x86_64/mach-xen/asm/irq.h 2007-03-20 21:26:59.000000000 +0100
-@@ -0,0 +1,34 @@
-+#ifndef _ASM_IRQ_H
-+#define _ASM_IRQ_H
-+
-+/*
-+ * linux/include/asm/irq.h
-+ *
-+ * (C) 1992, 1993 Linus Torvalds, (C) 1997 Ingo Molnar
-+ *
-+ * IRQ/IPI changes taken from work by Thomas Radke
-+ * <tomsoft@informatik.tu-chemnitz.de>
-+ */
-+
-+#include <linux/sched.h>
-+/* include comes from machine specific directory */
-+#include "irq_vectors.h"
-+#include <asm/thread_info.h>
-+
-+static __inline__ int irq_canonicalize(int irq)
-+{
-+ return ((irq == 2) ? 9 : irq);
-+}
-+
-+#define ARCH_HAS_NMI_WATCHDOG /* See include/linux/nmi.h */
-+
-+# define irq_ctx_init(cpu) do { } while (0)
-+
-+#ifdef CONFIG_HOTPLUG_CPU
-+#include <linux/cpumask.h>
-+extern void fixup_irqs(cpumask_t map);
-+#endif
-+
-+#define __ARCH_HAS_DO_SOFTIRQ 1
-+
-+#endif /* _ASM_IRQ_H */
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/asm-x86_64/mach-xen/asm/maddr.h source/include/asm-x86_64/mach-xen/asm/maddr.h
---- /scratch/src/linux-2.6.20.3/include/asm-x86_64/mach-xen/asm/maddr.h 1970-01-01 01:00:00.000000000 +0100
-+++ source/include/asm-x86_64/mach-xen/asm/maddr.h 2007-03-20 21:26:59.000000000 +0100
-@@ -0,0 +1,150 @@
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/asm-x86_64/mach-xen/asm/maddr.h
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/include/asm-x86_64/mach-xen/asm/maddr.h Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,161 @@
+#ifndef _X86_64_MADDR_H
+#define _X86_64_MADDR_H
+
@@ -82199,14 +79442,15 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+{
+ if (xen_feature(XENFEAT_auto_translated_physmap))
+ return pfn;
-+ return phys_to_machine_mapping[(unsigned int)(pfn)] &
-+ ~FOREIGN_FRAME_BIT;
++ BUG_ON(end_pfn && pfn >= end_pfn);
++ return phys_to_machine_mapping[pfn] & ~FOREIGN_FRAME_BIT;
+}
+
+static inline int phys_to_machine_mapping_valid(unsigned long pfn)
+{
+ if (xen_feature(XENFEAT_auto_translated_physmap))
+ return 1;
++ BUG_ON(end_pfn && pfn >= end_pfn);
+ return (phys_to_machine_mapping[pfn] != INVALID_P2M_ENTRY);
+}
+
@@ -82270,6 +79514,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+
+static inline void set_phys_to_machine(unsigned long pfn, unsigned long mfn)
+{
++ BUG_ON(end_pfn && pfn >= end_pfn);
+ if (xen_feature(XENFEAT_auto_translated_physmap)) {
+ BUG_ON(pfn != mfn && mfn != INVALID_P2M_ENTRY);
+ return;
@@ -82291,6 +79536,14 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ return phys;
+}
+
++static inline paddr_t pte_phys_to_machine(paddr_t phys)
++{
++ maddr_t machine;
++ machine = pfn_to_mfn((phys & PHYSICAL_PAGE_MASK) >> PAGE_SHIFT);
++ machine = (machine << PAGE_SHIFT) | (phys & ~PHYSICAL_PAGE_MASK);
++ return machine;
++}
++
+static inline paddr_t pte_machine_to_phys(maddr_t machine)
+{
+ paddr_t phys;
@@ -82299,16 +79552,20 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ return phys;
+}
+
++#define __pte_ma(x) ((pte_t) { (x) } )
++#define pfn_pte_ma(pfn, prot) __pte_ma((((pfn) << PAGE_SHIFT) | pgprot_val(prot)) & __supported_pte_mask)
++
+#else /* !CONFIG_XEN */
+
+#define pfn_to_mfn(pfn) (pfn)
+#define mfn_to_pfn(mfn) (mfn)
+#define mfn_to_local_pfn(mfn) (mfn)
-+#define set_phys_to_machine(pfn, mfn) BUG_ON((pfn) != (mfn))
++#define set_phys_to_machine(pfn, mfn) ((void)0)
+#define phys_to_machine_mapping_valid(pfn) (1)
+#define phys_to_machine(phys) ((maddr_t)(phys))
+#define machine_to_phys(mach) ((paddr_t)(mach))
-+#define pte_machine_to_phys(mach) ((paddr_t)(mach))
++#define pfn_pte_ma(pfn, prot) pfn_pte(pfn, prot)
++#define __pte_ma(x) __pte(x)
+
+#endif /* !CONFIG_XEN */
+
@@ -82317,15 +79574,12 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#define virt_to_mfn(v) (pfn_to_mfn(__pa(v) >> PAGE_SHIFT))
+#define mfn_to_virt(m) (__va(mfn_to_pfn(m) << PAGE_SHIFT))
+
-+#define __pte_ma(x) ((pte_t) { (x) } )
-+#define pfn_pte_ma(pfn, prot) __pte_ma((((pfn) << PAGE_SHIFT) | pgprot_val(prot)) & __supported_pte_mask)
-+
+#endif /* _X86_64_MADDR_H */
+
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/asm-x86_64/mach-xen/asm/mmu_context.h source/include/asm-x86_64/mach-xen/asm/mmu_context.h
---- /scratch/src/linux-2.6.20.3/include/asm-x86_64/mach-xen/asm/mmu_context.h 1970-01-01 01:00:00.000000000 +0100
-+++ source/include/asm-x86_64/mach-xen/asm/mmu_context.h 2007-03-20 21:26:59.000000000 +0100
-@@ -0,0 +1,135 @@
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/asm-x86_64/mach-xen/asm/mmu_context.h
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/include/asm-x86_64/mach-xen/asm/mmu_context.h Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,136 @@
+#ifndef __X86_64_MMU_CONTEXT_H
+#define __X86_64_MMU_CONTEXT_H
+
@@ -82400,7 +79654,8 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ struct mmuext_op _op[3], *op = _op;
+
+ if (likely(prev != next)) {
-+ BUG_ON(!next->context.pinned);
++ BUG_ON(!xen_feature(XENFEAT_writable_page_tables) &&
++ !next->context.pinned);
+
+ /* stop flush ipis for the previous mm */
+ cpu_clear(cpu, prev->cpu_vm_mask);
@@ -82461,441 +79716,10 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+}
+
+#endif
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/asm-x86_64/mach-xen/asm/msr.h source/include/asm-x86_64/mach-xen/asm/msr.h
---- /scratch/src/linux-2.6.20.3/include/asm-x86_64/mach-xen/asm/msr.h 1970-01-01 01:00:00.000000000 +0100
-+++ source/include/asm-x86_64/mach-xen/asm/msr.h 2007-03-20 21:26:59.000000000 +0100
-@@ -0,0 +1,427 @@
-+#ifndef X86_64_MSR_H
-+#define X86_64_MSR_H 1
-+
-+#ifndef __ASSEMBLY__
-+/*
-+ * Access to machine-specific registers (available on 586 and better only)
-+ * Note: the rd* operations modify the parameters directly (without using
-+ * pointer indirection), this allows gcc to optimize better
-+ */
-+
-+#define rdmsr(msr,val1,val2) \
-+ __asm__ __volatile__("rdmsr" \
-+ : "=a" (val1), "=d" (val2) \
-+ : "c" (msr))
-+
-+
-+#define rdmsrl(msr,val) do { unsigned long a__,b__; \
-+ __asm__ __volatile__("rdmsr" \
-+ : "=a" (a__), "=d" (b__) \
-+ : "c" (msr)); \
-+ val = a__ | (b__<<32); \
-+} while(0)
-+
-+#define wrmsr(msr,val1,val2) \
-+ __asm__ __volatile__("wrmsr" \
-+ : /* no outputs */ \
-+ : "c" (msr), "a" (val1), "d" (val2))
-+
-+#define wrmsrl(msr,val) wrmsr(msr,(__u32)((__u64)(val)),((__u64)(val))>>32)
-+
-+/* wrmsr with exception handling */
-+#define wrmsr_safe(msr,a,b) ({ int ret__; \
-+ asm volatile("2: wrmsr ; xorl %0,%0\n" \
-+ "1:\n\t" \
-+ ".section .fixup,\"ax\"\n\t" \
-+ "3: movl %4,%0 ; jmp 1b\n\t" \
-+ ".previous\n\t" \
-+ ".section __ex_table,\"a\"\n" \
-+ " .align 8\n\t" \
-+ " .quad 2b,3b\n\t" \
-+ ".previous" \
-+ : "=a" (ret__) \
-+ : "c" (msr), "0" (a), "d" (b), "i" (-EFAULT)); \
-+ ret__; })
-+
-+#define checking_wrmsrl(msr,val) wrmsr_safe(msr,(u32)(val),(u32)((val)>>32))
-+
-+#define rdmsr_safe(msr,a,b) \
-+ ({ int ret__; \
-+ asm volatile ("1: rdmsr\n" \
-+ "2:\n" \
-+ ".section .fixup,\"ax\"\n" \
-+ "3: movl %4,%0\n" \
-+ " jmp 2b\n" \
-+ ".previous\n" \
-+ ".section __ex_table,\"a\"\n" \
-+ " .align 8\n" \
-+ " .quad 1b,3b\n" \
-+ ".previous":"=&bDS" (ret__), "=a"(*(a)), "=d"(*(b))\
-+ :"c"(msr), "i"(-EIO), "0"(0)); \
-+ ret__; })
-+
-+#define rdtsc(low,high) \
-+ __asm__ __volatile__("rdtsc" : "=a" (low), "=d" (high))
-+
-+#define rdtscl(low) \
-+ __asm__ __volatile__ ("rdtsc" : "=a" (low) : : "edx")
-+
-+#define rdtscp(low,high,aux) \
-+ asm volatile (".byte 0x0f,0x01,0xf9" : "=a" (low), "=d" (high), "=c" (aux))
-+
-+#define rdtscll(val) do { \
-+ unsigned int __a,__d; \
-+ asm volatile("rdtsc" : "=a" (__a), "=d" (__d)); \
-+ (val) = ((unsigned long)__a) | (((unsigned long)__d)<<32); \
-+} while(0)
-+
-+#define rdtscpll(val, aux) do { \
-+ unsigned long __a, __d; \
-+ asm volatile (".byte 0x0f,0x01,0xf9" : "=a" (__a), "=d" (__d), "=c" (aux)); \
-+ (val) = (__d << 32) | __a; \
-+} while (0)
-+
-+#define write_tsc(val1,val2) wrmsr(0x10, val1, val2)
-+
-+#define write_rdtscp_aux(val) wrmsr(0xc0000103, val, 0)
-+
-+#define rdpmc(counter,low,high) \
-+ __asm__ __volatile__("rdpmc" \
-+ : "=a" (low), "=d" (high) \
-+ : "c" (counter))
-+
-+static inline void cpuid(int op, unsigned int *eax, unsigned int *ebx,
-+ unsigned int *ecx, unsigned int *edx)
-+{
-+ __asm__(XEN_CPUID
-+ : "=a" (*eax),
-+ "=b" (*ebx),
-+ "=c" (*ecx),
-+ "=d" (*edx)
-+ : "0" (op));
-+}
-+
-+/* Some CPUID calls want 'count' to be placed in ecx */
-+static inline void cpuid_count(int op, int count, int *eax, int *ebx, int *ecx,
-+ int *edx)
-+{
-+ __asm__(XEN_CPUID
-+ : "=a" (*eax),
-+ "=b" (*ebx),
-+ "=c" (*ecx),
-+ "=d" (*edx)
-+ : "0" (op), "c" (count));
-+}
-+
-+/*
-+ * CPUID functions returning a single datum
-+ */
-+static inline unsigned int cpuid_eax(unsigned int op)
-+{
-+ unsigned int eax;
-+
-+ __asm__(XEN_CPUID
-+ : "=a" (eax)
-+ : "0" (op)
-+ : "bx", "cx", "dx");
-+ return eax;
-+}
-+static inline unsigned int cpuid_ebx(unsigned int op)
-+{
-+ unsigned int eax, ebx;
-+
-+ __asm__(XEN_CPUID
-+ : "=a" (eax), "=b" (ebx)
-+ : "0" (op)
-+ : "cx", "dx" );
-+ return ebx;
-+}
-+static inline unsigned int cpuid_ecx(unsigned int op)
-+{
-+ unsigned int eax, ecx;
-+
-+ __asm__(XEN_CPUID
-+ : "=a" (eax), "=c" (ecx)
-+ : "0" (op)
-+ : "bx", "dx" );
-+ return ecx;
-+}
-+static inline unsigned int cpuid_edx(unsigned int op)
-+{
-+ unsigned int eax, edx;
-+
-+ __asm__(XEN_CPUID
-+ : "=a" (eax), "=d" (edx)
-+ : "0" (op)
-+ : "bx", "cx");
-+ return edx;
-+}
-+
-+#define MSR_IA32_UCODE_WRITE 0x79
-+#define MSR_IA32_UCODE_REV 0x8b
-+
-+
-+#endif
-+
-+/* AMD/K8 specific MSRs */
-+#define MSR_EFER 0xc0000080 /* extended feature register */
-+#define MSR_STAR 0xc0000081 /* legacy mode SYSCALL target */
-+#define MSR_LSTAR 0xc0000082 /* long mode SYSCALL target */
-+#define MSR_CSTAR 0xc0000083 /* compatibility mode SYSCALL target */
-+#define MSR_SYSCALL_MASK 0xc0000084 /* EFLAGS mask for syscall */
-+#define MSR_FS_BASE 0xc0000100 /* 64bit FS base */
-+#define MSR_GS_BASE 0xc0000101 /* 64bit GS base */
-+#define MSR_KERNEL_GS_BASE 0xc0000102 /* SwapGS GS shadow (or USER_GS from kernel) */
-+/* EFER bits: */
-+#define _EFER_SCE 0 /* SYSCALL/SYSRET */
-+#define _EFER_LME 8 /* Long mode enable */
-+#define _EFER_LMA 10 /* Long mode active (read-only) */
-+#define _EFER_NX 11 /* No execute enable */
-+
-+#define EFER_SCE (1<<_EFER_SCE)
-+#define EFER_LME (1<<_EFER_LME)
-+#define EFER_LMA (1<<_EFER_LMA)
-+#define EFER_NX (1<<_EFER_NX)
-+
-+/* Intel MSRs. Some also available on other CPUs */
-+#define MSR_IA32_TSC 0x10
-+#define MSR_IA32_PLATFORM_ID 0x17
-+
-+#define MSR_IA32_PERFCTR0 0xc1
-+#define MSR_IA32_PERFCTR1 0xc2
-+#define MSR_FSB_FREQ 0xcd
-+
-+#define MSR_MTRRcap 0x0fe
-+#define MSR_IA32_BBL_CR_CTL 0x119
-+
-+#define MSR_IA32_SYSENTER_CS 0x174
-+#define MSR_IA32_SYSENTER_ESP 0x175
-+#define MSR_IA32_SYSENTER_EIP 0x176
-+
-+#define MSR_IA32_MCG_CAP 0x179
-+#define MSR_IA32_MCG_STATUS 0x17a
-+#define MSR_IA32_MCG_CTL 0x17b
-+
-+#define MSR_IA32_EVNTSEL0 0x186
-+#define MSR_IA32_EVNTSEL1 0x187
-+
-+#define MSR_IA32_DEBUGCTLMSR 0x1d9
-+#define MSR_IA32_LASTBRANCHFROMIP 0x1db
-+#define MSR_IA32_LASTBRANCHTOIP 0x1dc
-+#define MSR_IA32_LASTINTFROMIP 0x1dd
-+#define MSR_IA32_LASTINTTOIP 0x1de
-+
-+#define MSR_IA32_PEBS_ENABLE 0x3f1
-+#define MSR_IA32_DS_AREA 0x600
-+#define MSR_IA32_PERF_CAPABILITIES 0x345
-+
-+#define MSR_MTRRfix64K_00000 0x250
-+#define MSR_MTRRfix16K_80000 0x258
-+#define MSR_MTRRfix16K_A0000 0x259
-+#define MSR_MTRRfix4K_C0000 0x268
-+#define MSR_MTRRfix4K_C8000 0x269
-+#define MSR_MTRRfix4K_D0000 0x26a
-+#define MSR_MTRRfix4K_D8000 0x26b
-+#define MSR_MTRRfix4K_E0000 0x26c
-+#define MSR_MTRRfix4K_E8000 0x26d
-+#define MSR_MTRRfix4K_F0000 0x26e
-+#define MSR_MTRRfix4K_F8000 0x26f
-+#define MSR_MTRRdefType 0x2ff
-+
-+#define MSR_IA32_MC0_CTL 0x400
-+#define MSR_IA32_MC0_STATUS 0x401
-+#define MSR_IA32_MC0_ADDR 0x402
-+#define MSR_IA32_MC0_MISC 0x403
-+
-+#define MSR_P6_PERFCTR0 0xc1
-+#define MSR_P6_PERFCTR1 0xc2
-+#define MSR_P6_EVNTSEL0 0x186
-+#define MSR_P6_EVNTSEL1 0x187
-+
-+/* K7/K8 MSRs. Not complete. See the architecture manual for a more complete list. */
-+#define MSR_K7_EVNTSEL0 0xC0010000
-+#define MSR_K7_PERFCTR0 0xC0010004
-+#define MSR_K7_EVNTSEL1 0xC0010001
-+#define MSR_K7_PERFCTR1 0xC0010005
-+#define MSR_K7_EVNTSEL2 0xC0010002
-+#define MSR_K7_PERFCTR2 0xC0010006
-+#define MSR_K7_EVNTSEL3 0xC0010003
-+#define MSR_K7_PERFCTR3 0xC0010007
-+#define MSR_K8_TOP_MEM1 0xC001001A
-+#define MSR_K8_TOP_MEM2 0xC001001D
-+#define MSR_K8_SYSCFG 0xC0010010
-+#define MSR_K8_HWCR 0xC0010015
-+
-+/* K6 MSRs */
-+#define MSR_K6_EFER 0xC0000080
-+#define MSR_K6_STAR 0xC0000081
-+#define MSR_K6_WHCR 0xC0000082
-+#define MSR_K6_UWCCR 0xC0000085
-+#define MSR_K6_PSOR 0xC0000087
-+#define MSR_K6_PFIR 0xC0000088
-+
-+/* Centaur-Hauls/IDT defined MSRs. */
-+#define MSR_IDT_FCR1 0x107
-+#define MSR_IDT_FCR2 0x108
-+#define MSR_IDT_FCR3 0x109
-+#define MSR_IDT_FCR4 0x10a
-+
-+#define MSR_IDT_MCR0 0x110
-+#define MSR_IDT_MCR1 0x111
-+#define MSR_IDT_MCR2 0x112
-+#define MSR_IDT_MCR3 0x113
-+#define MSR_IDT_MCR4 0x114
-+#define MSR_IDT_MCR5 0x115
-+#define MSR_IDT_MCR6 0x116
-+#define MSR_IDT_MCR7 0x117
-+#define MSR_IDT_MCR_CTRL 0x120
-+
-+/* VIA Cyrix defined MSRs*/
-+#define MSR_VIA_FCR 0x1107
-+#define MSR_VIA_LONGHAUL 0x110a
-+#define MSR_VIA_RNG 0x110b
-+#define MSR_VIA_BCR2 0x1147
-+
-+/* Intel defined MSRs. */
-+#define MSR_IA32_P5_MC_ADDR 0
-+#define MSR_IA32_P5_MC_TYPE 1
-+#define MSR_IA32_PLATFORM_ID 0x17
-+#define MSR_IA32_EBL_CR_POWERON 0x2a
-+
-+#define MSR_IA32_APICBASE 0x1b
-+#define MSR_IA32_APICBASE_BSP (1<<8)
-+#define MSR_IA32_APICBASE_ENABLE (1<<11)
-+#define MSR_IA32_APICBASE_BASE (0xfffff<<12)
-+
-+/* P4/Xeon+ specific */
-+#define MSR_IA32_MCG_EAX 0x180
-+#define MSR_IA32_MCG_EBX 0x181
-+#define MSR_IA32_MCG_ECX 0x182
-+#define MSR_IA32_MCG_EDX 0x183
-+#define MSR_IA32_MCG_ESI 0x184
-+#define MSR_IA32_MCG_EDI 0x185
-+#define MSR_IA32_MCG_EBP 0x186
-+#define MSR_IA32_MCG_ESP 0x187
-+#define MSR_IA32_MCG_EFLAGS 0x188
-+#define MSR_IA32_MCG_EIP 0x189
-+#define MSR_IA32_MCG_RESERVED 0x18A
-+
-+#define MSR_P6_EVNTSEL0 0x186
-+#define MSR_P6_EVNTSEL1 0x187
-+
-+#define MSR_IA32_PERF_STATUS 0x198
-+#define MSR_IA32_PERF_CTL 0x199
-+
-+#define MSR_IA32_MPERF 0xE7
-+#define MSR_IA32_APERF 0xE8
-+
-+#define MSR_IA32_THERM_CONTROL 0x19a
-+#define MSR_IA32_THERM_INTERRUPT 0x19b
-+#define MSR_IA32_THERM_STATUS 0x19c
-+#define MSR_IA32_MISC_ENABLE 0x1a0
-+
-+#define MSR_IA32_DEBUGCTLMSR 0x1d9
-+#define MSR_IA32_LASTBRANCHFROMIP 0x1db
-+#define MSR_IA32_LASTBRANCHTOIP 0x1dc
-+#define MSR_IA32_LASTINTFROMIP 0x1dd
-+#define MSR_IA32_LASTINTTOIP 0x1de
-+
-+#define MSR_IA32_MC0_CTL 0x400
-+#define MSR_IA32_MC0_STATUS 0x401
-+#define MSR_IA32_MC0_ADDR 0x402
-+#define MSR_IA32_MC0_MISC 0x403
-+
-+/* Pentium IV performance counter MSRs */
-+#define MSR_P4_BPU_PERFCTR0 0x300
-+#define MSR_P4_BPU_PERFCTR1 0x301
-+#define MSR_P4_BPU_PERFCTR2 0x302
-+#define MSR_P4_BPU_PERFCTR3 0x303
-+#define MSR_P4_MS_PERFCTR0 0x304
-+#define MSR_P4_MS_PERFCTR1 0x305
-+#define MSR_P4_MS_PERFCTR2 0x306
-+#define MSR_P4_MS_PERFCTR3 0x307
-+#define MSR_P4_FLAME_PERFCTR0 0x308
-+#define MSR_P4_FLAME_PERFCTR1 0x309
-+#define MSR_P4_FLAME_PERFCTR2 0x30a
-+#define MSR_P4_FLAME_PERFCTR3 0x30b
-+#define MSR_P4_IQ_PERFCTR0 0x30c
-+#define MSR_P4_IQ_PERFCTR1 0x30d
-+#define MSR_P4_IQ_PERFCTR2 0x30e
-+#define MSR_P4_IQ_PERFCTR3 0x30f
-+#define MSR_P4_IQ_PERFCTR4 0x310
-+#define MSR_P4_IQ_PERFCTR5 0x311
-+#define MSR_P4_BPU_CCCR0 0x360
-+#define MSR_P4_BPU_CCCR1 0x361
-+#define MSR_P4_BPU_CCCR2 0x362
-+#define MSR_P4_BPU_CCCR3 0x363
-+#define MSR_P4_MS_CCCR0 0x364
-+#define MSR_P4_MS_CCCR1 0x365
-+#define MSR_P4_MS_CCCR2 0x366
-+#define MSR_P4_MS_CCCR3 0x367
-+#define MSR_P4_FLAME_CCCR0 0x368
-+#define MSR_P4_FLAME_CCCR1 0x369
-+#define MSR_P4_FLAME_CCCR2 0x36a
-+#define MSR_P4_FLAME_CCCR3 0x36b
-+#define MSR_P4_IQ_CCCR0 0x36c
-+#define MSR_P4_IQ_CCCR1 0x36d
-+#define MSR_P4_IQ_CCCR2 0x36e
-+#define MSR_P4_IQ_CCCR3 0x36f
-+#define MSR_P4_IQ_CCCR4 0x370
-+#define MSR_P4_IQ_CCCR5 0x371
-+#define MSR_P4_ALF_ESCR0 0x3ca
-+#define MSR_P4_ALF_ESCR1 0x3cb
-+#define MSR_P4_BPU_ESCR0 0x3b2
-+#define MSR_P4_BPU_ESCR1 0x3b3
-+#define MSR_P4_BSU_ESCR0 0x3a0
-+#define MSR_P4_BSU_ESCR1 0x3a1
-+#define MSR_P4_CRU_ESCR0 0x3b8
-+#define MSR_P4_CRU_ESCR1 0x3b9
-+#define MSR_P4_CRU_ESCR2 0x3cc
-+#define MSR_P4_CRU_ESCR3 0x3cd
-+#define MSR_P4_CRU_ESCR4 0x3e0
-+#define MSR_P4_CRU_ESCR5 0x3e1
-+#define MSR_P4_DAC_ESCR0 0x3a8
-+#define MSR_P4_DAC_ESCR1 0x3a9
-+#define MSR_P4_FIRM_ESCR0 0x3a4
-+#define MSR_P4_FIRM_ESCR1 0x3a5
-+#define MSR_P4_FLAME_ESCR0 0x3a6
-+#define MSR_P4_FLAME_ESCR1 0x3a7
-+#define MSR_P4_FSB_ESCR0 0x3a2
-+#define MSR_P4_FSB_ESCR1 0x3a3
-+#define MSR_P4_IQ_ESCR0 0x3ba
-+#define MSR_P4_IQ_ESCR1 0x3bb
-+#define MSR_P4_IS_ESCR0 0x3b4
-+#define MSR_P4_IS_ESCR1 0x3b5
-+#define MSR_P4_ITLB_ESCR0 0x3b6
-+#define MSR_P4_ITLB_ESCR1 0x3b7
-+#define MSR_P4_IX_ESCR0 0x3c8
-+#define MSR_P4_IX_ESCR1 0x3c9
-+#define MSR_P4_MOB_ESCR0 0x3aa
-+#define MSR_P4_MOB_ESCR1 0x3ab
-+#define MSR_P4_MS_ESCR0 0x3c0
-+#define MSR_P4_MS_ESCR1 0x3c1
-+#define MSR_P4_PMH_ESCR0 0x3ac
-+#define MSR_P4_PMH_ESCR1 0x3ad
-+#define MSR_P4_RAT_ESCR0 0x3bc
-+#define MSR_P4_RAT_ESCR1 0x3bd
-+#define MSR_P4_SAAT_ESCR0 0x3ae
-+#define MSR_P4_SAAT_ESCR1 0x3af
-+#define MSR_P4_SSU_ESCR0 0x3be
-+#define MSR_P4_SSU_ESCR1 0x3bf /* guess: not defined in manual */
-+#define MSR_P4_TBPU_ESCR0 0x3c2
-+#define MSR_P4_TBPU_ESCR1 0x3c3
-+#define MSR_P4_TC_ESCR0 0x3c4
-+#define MSR_P4_TC_ESCR1 0x3c5
-+#define MSR_P4_U2L_ESCR0 0x3b0
-+#define MSR_P4_U2L_ESCR1 0x3b1
-+
-+/* Intel Core-based CPU performance counters */
-+#define MSR_CORE_PERF_FIXED_CTR0 0x309
-+#define MSR_CORE_PERF_FIXED_CTR1 0x30a
-+#define MSR_CORE_PERF_FIXED_CTR2 0x30b
-+#define MSR_CORE_PERF_FIXED_CTR_CTRL 0x38d
-+#define MSR_CORE_PERF_GLOBAL_STATUS 0x38e
-+#define MSR_CORE_PERF_GLOBAL_CTRL 0x38f
-+#define MSR_CORE_PERF_GLOBAL_OVF_CTRL 0x390
-+
-+#endif
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/asm-x86_64/mach-xen/asm/page.h source/include/asm-x86_64/mach-xen/asm/page.h
---- /scratch/src/linux-2.6.20.3/include/asm-x86_64/mach-xen/asm/page.h 1970-01-01 01:00:00.000000000 +0100
-+++ source/include/asm-x86_64/mach-xen/asm/page.h 2007-03-20 21:26:59.000000000 +0100
-@@ -0,0 +1,214 @@
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/asm-x86_64/mach-xen/asm/page.h
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/include/asm-x86_64/mach-xen/asm/page.h Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,219 @@
+#ifndef _X86_64_PAGE_H
+#define _X86_64_PAGE_H
+
@@ -82906,22 +79730,22 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#include <asm/bug.h>
+#endif
+#include <xen/interface/xen.h>
-+#include <xen/foreign_page.h>
+
-+#define arch_free_page(_page,_order) \
-+({ int foreign = PageForeign(_page); \
-+ if (foreign) \
-+ (PageForeignDestructor(_page))(_page); \
-+ foreign; \
++/*
++ * Need to repeat this here in order to not include pgtable.h (which in turn
++ * depends on definitions made here), but to be able to use the symbolic
++ * below. The preprocessor will warn if the two definitions aren't identical.
++ */
++#define _PAGE_PRESENT 0x001
++
++#define arch_free_page(_page,_order) \
++({ int foreign = PageForeign(_page); \
++ if (foreign) \
++ PageForeignDestructor(_page); \
++ foreign; \
+})
+#define HAVE_ARCH_FREE_PAGE
+
-+#ifdef CONFIG_XEN_SCRUB_PAGES
-+#define scrub_pages(_p,_n) memset((void *)(_p), 0, (_n) << PAGE_SHIFT)
-+#else
-+#define scrub_pages(_p,_n) ((void)0)
-+#endif
-+
+/* PAGE_SHIFT determines the page size */
+#define PAGE_SHIFT 12
+#ifdef __ASSEMBLY__
@@ -82993,28 +79817,33 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+
+typedef struct { unsigned long pgprot; } pgprot_t;
+
-+#define pte_val(x) (((x).pte & 1) ? pte_machine_to_phys((x).pte) : \
++#define pte_val(x) (((x).pte & _PAGE_PRESENT) ? \
++ pte_machine_to_phys((x).pte) : \
+ (x).pte)
+#define pte_val_ma(x) ((x).pte)
+
+static inline unsigned long pmd_val(pmd_t x)
+{
+ unsigned long ret = x.pmd;
-+ if (ret) ret = pte_machine_to_phys(ret);
++#if CONFIG_XEN_COMPAT <= 0x030002
++ if (ret) ret = pte_machine_to_phys(ret) | _PAGE_PRESENT;
++#else
++ if (ret & _PAGE_PRESENT) ret = pte_machine_to_phys(ret);
++#endif
+ return ret;
+}
+
+static inline unsigned long pud_val(pud_t x)
+{
+ unsigned long ret = x.pud;
-+ if (ret) ret = pte_machine_to_phys(ret);
++ if (ret & _PAGE_PRESENT) ret = pte_machine_to_phys(ret);
+ return ret;
+}
+
+static inline unsigned long pgd_val(pgd_t x)
+{
+ unsigned long ret = x.pgd;
-+ if (ret) ret = pte_machine_to_phys(ret);
++ if (ret & _PAGE_PRESENT) ret = pte_machine_to_phys(ret);
+ return ret;
+}
+
@@ -83022,25 +79851,25 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+
+static inline pte_t __pte(unsigned long x)
+{
-+ if (x & 1) x = phys_to_machine(x);
++ if (x & _PAGE_PRESENT) x = pte_phys_to_machine(x);
+ return ((pte_t) { (x) });
+}
+
+static inline pmd_t __pmd(unsigned long x)
+{
-+ if ((x & 1)) x = phys_to_machine(x);
++ if (x & _PAGE_PRESENT) x = pte_phys_to_machine(x);
+ return ((pmd_t) { (x) });
+}
+
+static inline pud_t __pud(unsigned long x)
+{
-+ if ((x & 1)) x = phys_to_machine(x);
++ if (x & _PAGE_PRESENT) x = pte_phys_to_machine(x);
+ return ((pud_t) { (x) });
+}
+
+static inline pgd_t __pgd(unsigned long x)
+{
-+ if ((x & 1)) x = phys_to_machine(x);
++ if (x & _PAGE_PRESENT) x = pte_phys_to_machine(x);
+ return ((pgd_t) { (x) });
+}
+
@@ -83058,10 +79887,10 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#define __PAGE_OFFSET 0xffff880000000000
+#endif /* !__ASSEMBLY__ */
+
-+#ifdef CONFIG_XEN_COMPAT_030002
++#if CONFIG_XEN_COMPAT <= 0x030002
+#undef LOAD_OFFSET
+#define LOAD_OFFSET 0
-+#endif /* CONFIG_XEN_COMPAT_030002 */
++#endif
+
+/* to align the pointer to the (next) page boundary */
+#define PAGE_ALIGN(addr) (((addr)+PAGE_SIZE-1)&PAGE_MASK)
@@ -83110,10 +79939,10 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#endif /* __KERNEL__ */
+
+#endif /* _X86_64_PAGE_H */
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/asm-x86_64/mach-xen/asm/pgalloc.h source/include/asm-x86_64/mach-xen/asm/pgalloc.h
---- /scratch/src/linux-2.6.20.3/include/asm-x86_64/mach-xen/asm/pgalloc.h 1970-01-01 01:00:00.000000000 +0100
-+++ source/include/asm-x86_64/mach-xen/asm/pgalloc.h 2007-03-20 21:26:59.000000000 +0100
-@@ -0,0 +1,224 @@
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/asm-x86_64/mach-xen/asm/pgalloc.h
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/include/asm-x86_64/mach-xen/asm/pgalloc.h Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,205 @@
+#ifndef _X86_64_PGALLOC_H
+#define _X86_64_PGALLOC_H
+
@@ -83136,6 +79965,18 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ set_pmd(pmd, __pmd(_PAGE_TABLE | __pa(pte)));
+}
+
++static inline void pmd_populate(struct mm_struct *mm, pmd_t *pmd, struct page *pte)
++{
++ if (unlikely((mm)->context.pinned)) {
++ BUG_ON(HYPERVISOR_update_va_mapping(
++ (unsigned long)__va(page_to_pfn(pte) << PAGE_SHIFT),
++ pfn_pte(page_to_pfn(pte), PAGE_KERNEL_RO), 0));
++ set_pmd(pmd, __pmd(_PAGE_TABLE | (page_to_pfn(pte) << PAGE_SHIFT)));
++ } else {
++ *(pmd) = __pmd(_PAGE_TABLE | (page_to_pfn(pte) << PAGE_SHIFT));
++ }
++}
++
+static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
+{
+ if (unlikely((mm)->context.pinned)) {
@@ -83168,52 +80009,35 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ }
+}
+
-+static inline void pmd_populate(struct mm_struct *mm, pmd_t *pmd, struct page *pte)
-+{
-+ if (unlikely((mm)->context.pinned)) {
-+ BUG_ON(HYPERVISOR_update_va_mapping(
-+ (unsigned long)__va(page_to_pfn(pte) << PAGE_SHIFT),
-+ pfn_pte(page_to_pfn(pte), PAGE_KERNEL_RO), 0));
-+ set_pmd(pmd, __pmd(_PAGE_TABLE | (page_to_pfn(pte) << PAGE_SHIFT)));
-+ } else {
-+ *(pmd) = __pmd(_PAGE_TABLE | (page_to_pfn(pte) << PAGE_SHIFT));
-+ }
-+}
++extern struct page *pte_alloc_one(struct mm_struct *mm, unsigned long addr);
++extern void pte_free(struct page *pte);
+
+static inline void pmd_free(pmd_t *pmd)
+{
-+ pte_t *ptep = virt_to_ptep(pmd);
-+
-+ if (!pte_write(*ptep)) {
-+ BUG_ON(HYPERVISOR_update_va_mapping(
-+ (unsigned long)pmd,
-+ pfn_pte(virt_to_phys(pmd)>>PAGE_SHIFT, PAGE_KERNEL),
-+ 0));
-+ }
-+ free_page((unsigned long)pmd);
++ BUG_ON((unsigned long)pmd & (PAGE_SIZE-1));
++ pte_free(virt_to_page(pmd));
+}
+
+static inline pmd_t *pmd_alloc_one (struct mm_struct *mm, unsigned long addr)
+{
-+ return (pmd_t *)get_zeroed_page(GFP_KERNEL|__GFP_REPEAT);
++ struct page *pg;
++
++ pg = pte_alloc_one(mm, addr);
++ return pg ? page_address(pg) : NULL;
+}
+
+static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
+{
-+ return (pud_t *)get_zeroed_page(GFP_KERNEL|__GFP_REPEAT);
++ struct page *pg;
++
++ pg = pte_alloc_one(mm, addr);
++ return pg ? page_address(pg) : NULL;
+}
+
+static inline void pud_free (pud_t *pud)
+{
-+ pte_t *ptep = virt_to_ptep(pud);
-+
-+ if (!pte_write(*ptep)) {
-+ BUG_ON(HYPERVISOR_update_va_mapping(
-+ (unsigned long)pud,
-+ pfn_pte(virt_to_phys(pud)>>PAGE_SHIFT, PAGE_KERNEL),
-+ 0));
-+ }
-+ free_page((unsigned long)pud);
++ BUG_ON((unsigned long)pud & (PAGE_SIZE-1));
++ pte_free(virt_to_page(pud));
+}
+
+static inline void pgd_list_add(pgd_t *pgd)
@@ -83244,12 +80068,11 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+
+static inline pgd_t *pgd_alloc(struct mm_struct *mm)
+{
-+ /*
-+ * We allocate two contiguous pages for kernel and user.
-+ */
-+ unsigned boundary;
++ /*
++ * We allocate two contiguous pages for kernel and user.
++ */
++ unsigned boundary;
+ pgd_t *pgd = (pgd_t *)__get_free_pages(GFP_KERNEL|__GFP_REPEAT, 1);
-+
+ if (!pgd)
+ return NULL;
+ pgd_list_add(pgd);
@@ -83265,11 +80088,11 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ (PTRS_PER_PGD - boundary) * sizeof(pgd_t));
+
+ memset(__user_pgd(pgd), 0, PAGE_SIZE); /* clean up user pgd */
-+ /*
-+ * Set level3_user_pgt for vsyscall area
-+ */
++ /*
++ * Set level3_user_pgt for vsyscall area
++ */
+ set_pgd(__user_pgd(pgd) + pgd_index(VSYSCALL_START),
-+ mk_kernel_pgd(__pa_symbol(level3_user_pgt)));
++ mk_kernel_pgd(__pa_symbol(level3_user_pgt)));
+ return pgd;
+}
+
@@ -83302,46 +80125,33 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+
+static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm, unsigned long address)
+{
-+ pte_t *pte = (pte_t *)get_zeroed_page(GFP_KERNEL|__GFP_REPEAT);
-+ if (pte)
++ pte_t *pte = (pte_t *)get_zeroed_page(GFP_KERNEL|__GFP_REPEAT);
++ if (pte)
+ make_page_readonly(pte, XENFEAT_writable_page_tables);
+
+ return pte;
+}
+
-+static inline struct page *pte_alloc_one(struct mm_struct *mm, unsigned long address)
-+{
-+ struct page *pte;
-+
-+ pte = alloc_pages(GFP_KERNEL|__GFP_REPEAT|__GFP_ZERO, 0);
-+ return pte;
-+}
-+
+/* Should really implement gc for free page table pages. This could be
+ done with a reference count in struct page. */
+
+static inline void pte_free_kernel(pte_t *pte)
+{
+ BUG_ON((unsigned long)pte & (PAGE_SIZE-1));
-+ make_page_writable(pte, XENFEAT_writable_page_tables);
++ make_page_writable(pte, XENFEAT_writable_page_tables);
+ free_page((unsigned long)pte);
+}
+
-+extern void pte_free(struct page *pte);
-+
-+//#define __pte_free_tlb(tlb,pte) tlb_remove_page((tlb),(pte))
-+//#define __pmd_free_tlb(tlb,x) tlb_remove_page((tlb),virt_to_page(x))
-+//#define __pud_free_tlb(tlb,x) tlb_remove_page((tlb),virt_to_page(x))
++#define __pte_free_tlb(tlb,pte) tlb_remove_page((tlb),(pte))
+
-+#define __pte_free_tlb(tlb,x) pte_free((x))
-+#define __pmd_free_tlb(tlb,x) pmd_free((x))
-+#define __pud_free_tlb(tlb,x) pud_free((x))
++#define __pmd_free_tlb(tlb,x) tlb_remove_page((tlb),virt_to_page(x))
++#define __pud_free_tlb(tlb,x) tlb_remove_page((tlb),virt_to_page(x))
+
+#endif /* _X86_64_PGALLOC_H */
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/asm-x86_64/mach-xen/asm/pgtable.h source/include/asm-x86_64/mach-xen/asm/pgtable.h
---- /scratch/src/linux-2.6.20.3/include/asm-x86_64/mach-xen/asm/pgtable.h 1970-01-01 01:00:00.000000000 +0100
-+++ source/include/asm-x86_64/mach-xen/asm/pgtable.h 2007-03-20 21:26:59.000000000 +0100
-@@ -0,0 +1,559 @@
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/asm-x86_64/mach-xen/asm/pgtable.h
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/include/asm-x86_64/mach-xen/asm/pgtable.h Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,569 @@
+#ifndef _X86_64_PGTABLE_H
+#define _X86_64_PGTABLE_H
+
@@ -83434,9 +80244,6 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#define pgd_none(x) (!pgd_val(x))
+#define pud_none(x) (!pud_val(x))
+
-+#define set_pte_batched(pteptr, pteval) \
-+ queue_l1_entry_update(pteptr, (pteval))
-+
+static inline void set_pte(pte_t *dst, pte_t val)
+{
+ *dst = val;
@@ -83466,41 +80273,6 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ set_pgd(__user_pgd(pgd), __pgd(0));
+}
+
-+/*
-+ * A note on implementation of this atomic 'get-and-clear' operation.
-+ * This is actually very simple because Xen Linux can only run on a single
-+ * processor. Therefore, we cannot race other processors setting the 'accessed'
-+ * or 'dirty' bits on a page-table entry.
-+ * Even if pages are shared between domains, that is not a problem because
-+ * each domain will have separate page tables, with their own versions of
-+ * accessed & dirty state.
-+ */
-+#define ptep_get_and_clear(mm,addr,xp) __pte_ma(xchg(&(xp)->pte, 0))
-+
-+#if 0
-+static inline pte_t ptep_get_and_clear(struct mm_struct *mm, unsigned long addr, pte_t *xp)
-+{
-+ pte_t pte = *xp;
-+ if (pte.pte)
-+ set_pte(xp, __pte_ma(0));
-+ return pte;
-+}
-+#endif
-+
-+struct mm_struct;
-+
-+static inline pte_t ptep_get_and_clear_full(struct mm_struct *mm, unsigned long addr, pte_t *ptep, int full)
-+{
-+ pte_t pte;
-+ if (full) {
-+ pte = *ptep;
-+ *ptep = __pte(0);
-+ } else {
-+ pte = ptep_get_and_clear(mm, addr, ptep);
-+ }
-+ return pte;
-+}
-+
+#define pte_same(a, b) ((a).pte == (b).pte)
+
+#define pte_pgprot(a) (__pgprot((a).pte & ~PHYSICAL_PAGE_MASK))
@@ -83548,7 +80320,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#define _PAGE_PROTNONE 0x080 /* If not present */
+#define _PAGE_NX (1UL<<_PAGE_BIT_NX)
+
-+#ifdef CONFIG_XEN_COMPAT_030002
++#if CONFIG_XEN_COMPAT <= 0x030002
+extern unsigned int __kernel_page_user;
+#else
+#define __kernel_page_user 0
@@ -83636,21 +80408,63 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#define pte_present(x) ((x).pte & (_PAGE_PRESENT | _PAGE_PROTNONE))
+#define pte_clear(mm,addr,xp) do { set_pte_at(mm, addr, xp, __pte(0)); } while (0)
+
-+#define pages_to_mb(x) ((x) >> (20-PAGE_SHIFT)) /* FIXME: is this
++#define pages_to_mb(x) ((x) >> (20-PAGE_SHIFT))/* FIXME: is this
+ right? */
+#define pte_page(x) pfn_to_page(pte_pfn(x))
-+#define pte_pfn(x) mfn_to_local_pfn(pte_mfn(x))
-+#define pte_mfn(_pte) (((_pte).pte & PTE_MASK) >> PAGE_SHIFT)
++#define __pte_mfn(_pte) (((_pte).pte & PTE_MASK) >> PAGE_SHIFT)
++#define pte_mfn(_pte) ((_pte).pte & _PAGE_PRESENT ? \
++ __pte_mfn(_pte) : pfn_to_mfn(__pte_mfn(_pte)))
++#define pte_pfn(_pte) ((_pte).pte & _PAGE_PRESENT ? \
++ mfn_to_local_pfn(__pte_mfn(_pte)) : __pte_mfn(_pte))
+
+static inline pte_t pfn_pte(unsigned long page_nr, pgprot_t pgprot)
+{
-+ pte_t pte;
-+ (pte).pte = (pfn_to_mfn(page_nr) << PAGE_SHIFT);
-+ (pte).pte |= pgprot_val(pgprot);
-+ (pte).pte &= __supported_pte_mask;
++ unsigned long pte = page_nr << PAGE_SHIFT;
++ pte |= pgprot_val(pgprot);
++ pte &= __supported_pte_mask;
++ return __pte(pte);
++}
++
++static inline pte_t ptep_get_and_clear(struct mm_struct *mm, unsigned long addr, pte_t *ptep)
++{
++ pte_t pte = *ptep;
++ if (!pte_none(pte)) {
++ if (mm != &init_mm)
++ pte = __pte_ma(xchg(&ptep->pte, 0));
++ else
++ HYPERVISOR_update_va_mapping(addr, __pte(0), 0);
++ }
+ return pte;
+}
+
++static inline pte_t ptep_get_and_clear_full(struct mm_struct *mm, unsigned long addr, pte_t *ptep, int full)
++{
++ if (full) {
++ pte_t pte = *ptep;
++ if (mm->context.pinned)
++ xen_l1_entry_update(ptep, __pte(0));
++ else
++ *ptep = __pte(0);
++ return pte;
++ }
++ return ptep_get_and_clear(mm, addr, ptep);
++}
++
++#define ptep_clear_flush(vma, addr, ptep) \
++({ \
++ pte_t *__ptep = (ptep); \
++ pte_t __res = *__ptep; \
++ if (!pte_none(__res) && \
++ ((vma)->vm_mm != current->mm || \
++ HYPERVISOR_update_va_mapping(addr, __pte(0), \
++ (unsigned long)(vma)->vm_mm->cpu_vm_mask.bits| \
++ UVMF_INVLPG|UVMF_MULTI))) { \
++ __ptep->pte = 0; \
++ flush_tlb_page(vma, addr); \
++ } \
++ __res; \
++})
++
+/*
+ * The following only work if pte_present() is true.
+ * Undefined behaviour if not..
@@ -83680,31 +80494,29 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+static inline pte_t pte_mkhuge(pte_t pte) { __pte_val(pte) |= _PAGE_PSE; return pte; }
+static inline pte_t pte_clrhuge(pte_t pte) { __pte_val(pte) &= ~_PAGE_PSE; return pte; }
+
-+struct vm_area_struct;
-+
-+static inline int ptep_test_and_clear_dirty(struct vm_area_struct *vma, unsigned long addr, pte_t *ptep)
-+{
-+ pte_t pte = *ptep;
-+ int ret = pte_dirty(pte);
-+ if (ret)
-+ set_pte(ptep, pte_mkclean(pte));
-+ return ret;
-+}
++#define ptep_test_and_clear_dirty(vma, addr, ptep) \
++({ \
++ pte_t __pte = *(ptep); \
++ int __ret = pte_dirty(__pte); \
++ if (__ret) \
++ set_pte_at((vma)->vm_mm, addr, ptep, pte_mkclean(__pte)); \
++ __ret; \
++})
+
-+static inline int ptep_test_and_clear_young(struct vm_area_struct *vma, unsigned long addr, pte_t *ptep)
-+{
-+ pte_t pte = *ptep;
-+ int ret = pte_young(pte);
-+ if (ret)
-+ set_pte(ptep, pte_mkold(pte));
-+ return ret;
-+}
++#define ptep_test_and_clear_young(vma, addr, ptep) \
++({ \
++ pte_t __pte = *(ptep); \
++ int __ret = pte_young(__pte); \
++ if (__ret) \
++ set_pte_at((vma)->vm_mm, addr, ptep, pte_mkold(__pte)); \
++ __ret; \
++})
+
+static inline void ptep_set_wrprotect(struct mm_struct *mm, unsigned long addr, pte_t *ptep)
+{
+ pte_t pte = *ptep;
+ if (pte_write(pte))
-+ set_pte(ptep, pte_wrprotect(pte));
++ set_pte_at(mm, addr, ptep, pte_wrprotect(pte));
+}
+
+/*
@@ -83730,7 +80542,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#define pgd_page(pgd) (pfn_to_page(pgd_val(pgd) >> PAGE_SHIFT))
+#define pgd_index(address) (((address) >> PGDIR_SHIFT) & (PTRS_PER_PGD-1))
+#define pgd_offset(mm, addr) ((mm)->pgd + pgd_index(addr))
-+#define pgd_offset_k(address) (pgd_t *)(init_level4_pgt + pgd_index(address))
++#define pgd_offset_k(address) (init_level4_pgt + pgd_index(address))
+#define pgd_present(pgd) (pgd_val(pgd) & _PAGE_PRESENT)
+#define mk_kernel_pgd(address) __pgd((address) | _KERNPG_TABLE)
+
@@ -83740,16 +80552,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#define pud_page(pud) (pfn_to_page(pud_val(pud) >> PAGE_SHIFT))
+#define pud_index(address) (((address) >> PUD_SHIFT) & (PTRS_PER_PUD-1))
+#define pud_offset(pgd, address) ((pud_t *) pgd_page_vaddr(*(pgd)) + pud_index(address))
-+extern inline int pud_present(pud_t pud) { return !pud_none(pud); }
-+
-+/* Find correct pud via the hidden fourth level page level: */
-+
-+/* This accesses the reference page table of the boot cpu.
-+ Other CPUs get synced lazily via the page fault handler. */
-+static inline pud_t *pud_offset_k(pgd_t *pgd, unsigned long address)
-+{
-+ return pud_offset(pgd_offset_k(address), address);
-+}
++#define pud_present(pud) (pud_val(pud) & _PAGE_PRESENT)
+
+/* PMD - Level 2 access */
+#define pmd_page_vaddr(pmd) ((unsigned long) __va(pmd_val(pmd) & PTE_MASK))
@@ -83759,9 +80562,13 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#define pmd_offset(dir, address) ((pmd_t *) pud_page_vaddr(*(dir)) + \
+ pmd_index(address))
+#define pmd_none(x) (!pmd_val(x))
++#if CONFIG_XEN_COMPAT <= 0x030002
+/* pmd_present doesn't just test the _PAGE_PRESENT bit since wr.p.t.
+ can temporarily clear it. */
+#define pmd_present(x) (pmd_val(x))
++#else
++#define pmd_present(x) (pmd_val(x) & _PAGE_PRESENT)
++#endif
+#define pmd_clear(xp) do { set_pmd(xp, __pmd(0)); } while (0)
+#define pfn_pmd(nr,prot) (__pmd(((nr) << PAGE_SHIFT) | pgprot_val(prot)))
+#define pmd_pfn(x) ((pmd_val(x) & __PHYSICAL_MASK) >> PAGE_SHIFT)
@@ -83788,10 +80595,17 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+/* Change flags of a PTE */
+static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
+{
-+ (pte).pte &= _PAGE_CHG_MASK;
-+ (pte).pte |= pgprot_val(newprot);
-+ (pte).pte &= __supported_pte_mask;
-+ return pte;
++ /*
++ * Since this might change the present bit (which controls whether
++ * a pte_t object has undergone p2m translation), we must use
++ * pte_val() on the input pte and __pte() for the return value.
++ */
++ unsigned long pteval = pte_val(pte);
++
++ pteval &= _PAGE_CHG_MASK;
++ pteval |= pgprot_val(newprot);
++ pteval &= __supported_pte_mask;
++ return __pte(pteval);
+}
+
+#define pte_index(address) \
@@ -83807,31 +80621,34 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+
+#define update_mmu_cache(vma,address,pte) do { } while (0)
+
++/*
++ * Rules for using ptep_establish: the pte MUST be a user pte, and
++ * must be a present->present transition.
++ */
++#define __HAVE_ARCH_PTEP_ESTABLISH
++#define ptep_establish(vma, address, ptep, pteval) \
++ do { \
++ if ( likely((vma)->vm_mm == current->mm) ) { \
++ BUG_ON(HYPERVISOR_update_va_mapping(address, \
++ pteval, \
++ (unsigned long)(vma)->vm_mm->cpu_vm_mask.bits| \
++ UVMF_INVLPG|UVMF_MULTI)); \
++ } else { \
++ xen_l1_entry_update(ptep, pteval); \
++ flush_tlb_page(vma, address); \
++ } \
++ } while (0)
++
+/* We only update the dirty/accessed state if we set
+ * the dirty bit by hand in the kernel, since the hardware
+ * will do the accessed bit for us, and we don't want to
+ * race with other CPU's that might be updating the dirty
+ * bit at the same time. */
+#define __HAVE_ARCH_PTEP_SET_ACCESS_FLAGS
-+#if 0
-+#define ptep_set_access_flags(__vma, __address, __ptep, __entry, __dirty) \
-+ do { \
-+ if (__dirty) { \
-+ set_pte(__ptep, __entry); \
-+ flush_tlb_page(__vma, __address); \
-+ } \
-+ } while (0)
-+#endif
+#define ptep_set_access_flags(__vma, __address, __ptep, __entry, __dirty) \
+ do { \
-+ if (__dirty) { \
-+ if ( likely((__vma)->vm_mm == current->mm) ) { \
-+ BUG_ON(HYPERVISOR_update_va_mapping((__address), (__entry), UVMF_INVLPG|UVMF_MULTI|(unsigned long)((__vma)->vm_mm->cpu_vm_mask.bits))); \
-+ } else { \
-+ xen_l1_entry_update((__ptep), (__entry)); \
-+ flush_tlb_page((__vma), (__address)); \
-+ } \
-+ } \
++ if (__dirty) \
++ ptep_establish(__vma, __address, __ptep, __entry);\
+ } while (0)
+
+/* Encode and de-code a swap entry */
@@ -83851,6 +80668,8 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+
+#define DOMID_LOCAL (0xFFFFU)
+
++struct vm_area_struct;
++
+int direct_remap_pfn_range(struct vm_area_struct *vma,
+ unsigned long address,
+ unsigned long mfn,
@@ -83896,1456 +80715,41 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#define __HAVE_ARCH_PTEP_TEST_AND_CLEAR_DIRTY
+#define __HAVE_ARCH_PTEP_GET_AND_CLEAR
+#define __HAVE_ARCH_PTEP_GET_AND_CLEAR_FULL
++#define __HAVE_ARCH_PTEP_CLEAR_FLUSH
+#define __HAVE_ARCH_PTEP_SET_WRPROTECT
+#define __HAVE_ARCH_PTE_SAME
+#include <asm-generic/pgtable.h>
+
+#endif /* _X86_64_PGTABLE_H */
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/asm-x86_64/mach-xen/asm/processor.h source/include/asm-x86_64/mach-xen/asm/processor.h
---- /scratch/src/linux-2.6.20.3/include/asm-x86_64/mach-xen/asm/processor.h 1970-01-01 01:00:00.000000000 +0100
-+++ source/include/asm-x86_64/mach-xen/asm/processor.h 2007-03-20 21:26:59.000000000 +0100
-@@ -0,0 +1,507 @@
-+/*
-+ * include/asm-x86_64/processor.h
-+ *
-+ * Copyright (C) 1994 Linus Torvalds
-+ */
-+
-+#ifndef __ASM_X86_64_PROCESSOR_H
-+#define __ASM_X86_64_PROCESSOR_H
-+
-+#include <asm/segment.h>
-+#include <asm/page.h>
-+#include <asm/types.h>
-+#include <asm/sigcontext.h>
-+#include <asm/cpufeature.h>
-+#include <linux/threads.h>
-+#include <asm/msr.h>
-+#include <asm/current.h>
-+#include <asm/system.h>
-+#include <asm/mmsegment.h>
-+#include <asm/percpu.h>
-+#include <linux/personality.h>
-+#include <linux/cpumask.h>
-+
-+#define TF_MASK 0x00000100
-+#define IF_MASK 0x00000200
-+#define IOPL_MASK 0x00003000
-+#define NT_MASK 0x00004000
-+#define VM_MASK 0x00020000
-+#define AC_MASK 0x00040000
-+#define VIF_MASK 0x00080000 /* virtual interrupt flag */
-+#define VIP_MASK 0x00100000 /* virtual interrupt pending */
-+#define ID_MASK 0x00200000
-+
-+#define desc_empty(desc) \
-+ (!((desc)->a | (desc)->b))
-+
-+#define desc_equal(desc1, desc2) \
-+ (((desc1)->a == (desc2)->a) && ((desc1)->b == (desc2)->b))
-+
-+/*
-+ * Default implementation of macro that returns current
-+ * instruction pointer ("program counter").
-+ */
-+#define current_text_addr() ({ void *pc; asm volatile("leaq 1f(%%rip),%0\n1:":"=r"(pc)); pc; })
-+
-+/*
-+ * CPU type and hardware bug flags. Kept separately for each CPU.
-+ */
-+
-+struct cpuinfo_x86 {
-+ __u8 x86; /* CPU family */
-+ __u8 x86_vendor; /* CPU vendor */
-+ __u8 x86_model;
-+ __u8 x86_mask;
-+ int cpuid_level; /* Maximum supported CPUID level, -1=no CPUID */
-+ __u32 x86_capability[NCAPINTS];
-+ char x86_vendor_id[16];
-+ char x86_model_id[64];
-+ int x86_cache_size; /* in KB */
-+ int x86_clflush_size;
-+ int x86_cache_alignment;
-+ int x86_tlbsize; /* number of 4K pages in DTLB/ITLB combined(in pages)*/
-+ __u8 x86_virt_bits, x86_phys_bits;
-+ __u8 x86_max_cores; /* cpuid returned max cores value */
-+ __u32 x86_power;
-+ __u32 extended_cpuid_level; /* Max extended CPUID function supported */
-+ unsigned long loops_per_jiffy;
-+#ifdef CONFIG_SMP
-+ cpumask_t llc_shared_map; /* cpus sharing the last level cache */
-+#endif
-+ __u8 apicid;
-+#ifdef CONFIG_SMP
-+ __u8 booted_cores; /* number of cores as seen by OS */
-+ __u8 phys_proc_id; /* Physical Processor id. */
-+ __u8 cpu_core_id; /* Core id. */
-+#endif
-+} ____cacheline_aligned;
-+
-+#define X86_VENDOR_INTEL 0
-+#define X86_VENDOR_CYRIX 1
-+#define X86_VENDOR_AMD 2
-+#define X86_VENDOR_UMC 3
-+#define X86_VENDOR_NEXGEN 4
-+#define X86_VENDOR_CENTAUR 5
-+#define X86_VENDOR_RISE 6
-+#define X86_VENDOR_TRANSMETA 7
-+#define X86_VENDOR_NUM 8
-+#define X86_VENDOR_UNKNOWN 0xff
-+
-+#ifdef CONFIG_SMP
-+extern struct cpuinfo_x86 cpu_data[];
-+#define current_cpu_data cpu_data[smp_processor_id()]
-+#else
-+#define cpu_data (&boot_cpu_data)
-+#define current_cpu_data boot_cpu_data
-+#endif
-+
-+extern char ignore_irq13;
-+
-+extern void identify_cpu(struct cpuinfo_x86 *);
-+extern void print_cpu_info(struct cpuinfo_x86 *);
-+extern unsigned int init_intel_cacheinfo(struct cpuinfo_x86 *c);
-+extern unsigned short num_cache_leaves;
-+
-+/*
-+ * EFLAGS bits
-+ */
-+#define X86_EFLAGS_CF 0x00000001 /* Carry Flag */
-+#define X86_EFLAGS_PF 0x00000004 /* Parity Flag */
-+#define X86_EFLAGS_AF 0x00000010 /* Auxillary carry Flag */
-+#define X86_EFLAGS_ZF 0x00000040 /* Zero Flag */
-+#define X86_EFLAGS_SF 0x00000080 /* Sign Flag */
-+#define X86_EFLAGS_TF 0x00000100 /* Trap Flag */
-+#define X86_EFLAGS_IF 0x00000200 /* Interrupt Flag */
-+#define X86_EFLAGS_DF 0x00000400 /* Direction Flag */
-+#define X86_EFLAGS_OF 0x00000800 /* Overflow Flag */
-+#define X86_EFLAGS_IOPL 0x00003000 /* IOPL mask */
-+#define X86_EFLAGS_NT 0x00004000 /* Nested Task */
-+#define X86_EFLAGS_RF 0x00010000 /* Resume Flag */
-+#define X86_EFLAGS_VM 0x00020000 /* Virtual Mode */
-+#define X86_EFLAGS_AC 0x00040000 /* Alignment Check */
-+#define X86_EFLAGS_VIF 0x00080000 /* Virtual Interrupt Flag */
-+#define X86_EFLAGS_VIP 0x00100000 /* Virtual Interrupt Pending */
-+#define X86_EFLAGS_ID 0x00200000 /* CPUID detection flag */
-+
-+/*
-+ * Intel CPU features in CR4
-+ */
-+#define X86_CR4_VME 0x0001 /* enable vm86 extensions */
-+#define X86_CR4_PVI 0x0002 /* virtual interrupts flag enable */
-+#define X86_CR4_TSD 0x0004 /* disable time stamp at ipl 3 */
-+#define X86_CR4_DE 0x0008 /* enable debugging extensions */
-+#define X86_CR4_PSE 0x0010 /* enable page size extensions */
-+#define X86_CR4_PAE 0x0020 /* enable physical address extensions */
-+#define X86_CR4_MCE 0x0040 /* Machine check enable */
-+#define X86_CR4_PGE 0x0080 /* enable global pages */
-+#define X86_CR4_PCE 0x0100 /* enable performance counters at ipl 3 */
-+#define X86_CR4_OSFXSR 0x0200 /* enable fast FPU save and restore */
-+#define X86_CR4_OSXMMEXCPT 0x0400 /* enable unmasked SSE exceptions */
-+
-+/*
-+ * Save the cr4 feature set we're using (ie
-+ * Pentium 4MB enable and PPro Global page
-+ * enable), so that any CPU's that boot up
-+ * after us can get the correct flags.
-+ */
-+extern unsigned long mmu_cr4_features;
-+
-+static inline void set_in_cr4 (unsigned long mask)
-+{
-+ mmu_cr4_features |= mask;
-+ __asm__("movq %%cr4,%%rax\n\t"
-+ "orq %0,%%rax\n\t"
-+ "movq %%rax,%%cr4\n"
-+ : : "irg" (mask)
-+ :"ax");
-+}
-+
-+static inline void clear_in_cr4 (unsigned long mask)
-+{
-+ mmu_cr4_features &= ~mask;
-+ __asm__("movq %%cr4,%%rax\n\t"
-+ "andq %0,%%rax\n\t"
-+ "movq %%rax,%%cr4\n"
-+ : : "irg" (~mask)
-+ :"ax");
-+}
-+
-+
-+/*
-+ * User space process size. 47bits minus one guard page.
-+ */
-+#define TASK_SIZE64 (0x800000000000UL - 4096)
-+
-+/* This decides where the kernel will search for a free chunk of vm
-+ * space during mmap's.
-+ */
-+#define IA32_PAGE_OFFSET ((current->personality & ADDR_LIMIT_3GB) ? 0xc0000000 : 0xFFFFe000)
-+
-+#define TASK_SIZE (test_thread_flag(TIF_IA32) ? IA32_PAGE_OFFSET : TASK_SIZE64)
-+#define TASK_SIZE_OF(child) ((test_tsk_thread_flag(child, TIF_IA32)) ? IA32_PAGE_OFFSET : TASK_SIZE64)
-+
-+#define TASK_UNMAPPED_BASE PAGE_ALIGN(TASK_SIZE/3)
-+
-+/*
-+ * Size of io_bitmap.
-+ */
-+#define IO_BITMAP_BITS 65536
-+#define IO_BITMAP_BYTES (IO_BITMAP_BITS/8)
-+#define IO_BITMAP_LONGS (IO_BITMAP_BYTES/sizeof(long))
-+#ifndef CONFIG_X86_NO_TSS
-+#define IO_BITMAP_OFFSET offsetof(struct tss_struct,io_bitmap)
-+#endif
-+#define INVALID_IO_BITMAP_OFFSET 0x8000
-+
-+struct i387_fxsave_struct {
-+ u16 cwd;
-+ u16 swd;
-+ u16 twd;
-+ u16 fop;
-+ u64 rip;
-+ u64 rdp;
-+ u32 mxcsr;
-+ u32 mxcsr_mask;
-+ u32 st_space[32]; /* 8*16 bytes for each FP-reg = 128 bytes */
-+ u32 xmm_space[64]; /* 16*16 bytes for each XMM-reg = 128 bytes */
-+ u32 padding[24];
-+} __attribute__ ((aligned (16)));
-+
-+union i387_union {
-+ struct i387_fxsave_struct fxsave;
-+};
-+
-+#ifndef CONFIG_X86_NO_TSS
-+struct tss_struct {
-+ u32 reserved1;
-+ u64 rsp0;
-+ u64 rsp1;
-+ u64 rsp2;
-+ u64 reserved2;
-+ u64 ist[7];
-+ u32 reserved3;
-+ u32 reserved4;
-+ u16 reserved5;
-+ u16 io_bitmap_base;
-+ /*
-+ * The extra 1 is there because the CPU will access an
-+ * additional byte beyond the end of the IO permission
-+ * bitmap. The extra byte must be all 1 bits, and must
-+ * be within the limit. Thus we have:
-+ *
-+ * 128 bytes, the bitmap itself, for ports 0..0x3ff
-+ * 8 bytes, for an extra "long" of ~0UL
-+ */
-+ unsigned long io_bitmap[IO_BITMAP_LONGS + 1];
-+} __attribute__((packed)) ____cacheline_aligned;
-+
-+DECLARE_PER_CPU(struct tss_struct,init_tss);
-+/* Save the original ist values for checking stack pointers during debugging */
-+#endif
-+
-+extern struct cpuinfo_x86 boot_cpu_data;
-+struct orig_ist {
-+ unsigned long ist[7];
-+};
-+DECLARE_PER_CPU(struct orig_ist, orig_ist);
-+
-+#ifdef CONFIG_X86_VSMP
-+#define ARCH_MIN_TASKALIGN (1 << INTERNODE_CACHE_SHIFT)
-+#define ARCH_MIN_MMSTRUCT_ALIGN (1 << INTERNODE_CACHE_SHIFT)
-+#else
-+#define ARCH_MIN_TASKALIGN 16
-+#define ARCH_MIN_MMSTRUCT_ALIGN 0
-+#endif
-+
-+struct thread_struct {
-+ unsigned long rsp0;
-+ unsigned long rsp;
-+ unsigned long userrsp; /* Copy from PDA */
-+ unsigned long fs;
-+ unsigned long gs;
-+ unsigned short es, ds, fsindex, gsindex;
-+/* Hardware debugging registers */
-+ unsigned long debugreg0;
-+ unsigned long debugreg1;
-+ unsigned long debugreg2;
-+ unsigned long debugreg3;
-+ unsigned long debugreg6;
-+ unsigned long debugreg7;
-+/* fault info */
-+ unsigned long cr2, trap_no, error_code;
-+/* floating point info */
-+ union i387_union i387 __attribute__((aligned(16)));
-+/* IO permissions. the bitmap could be moved into the GDT, that would make
-+ switch faster for a limited number of ioperm using tasks. -AK */
-+ int ioperm;
-+ unsigned long *io_bitmap_ptr;
-+ unsigned io_bitmap_max;
-+/* cached TLS descriptors. */
-+ u64 tls_array[GDT_ENTRY_TLS_ENTRIES];
-+ unsigned int iopl;
-+} __attribute__((aligned(16)));
-+
-+#define INIT_THREAD { \
-+ .rsp0 = (unsigned long)&init_stack + sizeof(init_stack) \
-+}
-+
-+#ifndef CONFIG_X86_NO_TSS
-+#define INIT_TSS { \
-+ .rsp0 = (unsigned long)&init_stack + sizeof(init_stack) \
-+}
-+#endif
-+
-+#define INIT_MMAP \
-+{ &init_mm, 0, 0, NULL, PAGE_SHARED, VM_READ | VM_WRITE | VM_EXEC, 1, NULL, NULL }
-+
-+#define start_thread(regs,new_rip,new_rsp) do { \
-+ asm volatile("movl %0,%%fs; movl %0,%%es; movl %0,%%ds": :"r" (0)); \
-+ load_gs_index(0); \
-+ (regs)->rip = (new_rip); \
-+ (regs)->rsp = (new_rsp); \
-+ write_pda(oldrsp, (new_rsp)); \
-+ (regs)->cs = __USER_CS; \
-+ (regs)->ss = __USER_DS; \
-+ (regs)->eflags = 0x200; \
-+ set_fs(USER_DS); \
-+} while(0)
-+
-+#define get_debugreg(var, register) \
-+ var = HYPERVISOR_get_debugreg(register)
-+#define set_debugreg(value, register) \
-+ HYPERVISOR_set_debugreg(register, value)
-+
-+struct task_struct;
-+struct mm_struct;
-+
-+/* Free all resources held by a thread. */
-+extern void release_thread(struct task_struct *);
-+
-+/* Prepare to copy thread state - unlazy all lazy status */
-+extern void prepare_to_copy(struct task_struct *tsk);
-+
-+/*
-+ * create a kernel thread without removing it from tasklists
-+ */
-+extern long kernel_thread(int (*fn)(void *), void * arg, unsigned long flags);
-+
-+/*
-+ * Return saved PC of a blocked thread.
-+ * What is this good for? it will be always the scheduler or ret_from_fork.
-+ */
-+#define thread_saved_pc(t) (*(unsigned long *)((t)->thread.rsp - 8))
-+
-+extern unsigned long get_wchan(struct task_struct *p);
-+#define task_pt_regs(tsk) ((struct pt_regs *)(tsk)->thread.rsp0 - 1)
-+#define KSTK_EIP(tsk) (task_pt_regs(tsk)->rip)
-+#define KSTK_ESP(tsk) -1 /* sorry. doesn't work for syscall. */
-+
-+
-+struct microcode_header {
-+ unsigned int hdrver;
-+ unsigned int rev;
-+ unsigned int date;
-+ unsigned int sig;
-+ unsigned int cksum;
-+ unsigned int ldrver;
-+ unsigned int pf;
-+ unsigned int datasize;
-+ unsigned int totalsize;
-+ unsigned int reserved[3];
-+};
-+
-+struct microcode {
-+ struct microcode_header hdr;
-+ unsigned int bits[0];
-+};
-+
-+typedef struct microcode microcode_t;
-+typedef struct microcode_header microcode_header_t;
-+
-+/* microcode format is extended from prescott processors */
-+struct extended_signature {
-+ unsigned int sig;
-+ unsigned int pf;
-+ unsigned int cksum;
-+};
-+
-+struct extended_sigtable {
-+ unsigned int count;
-+ unsigned int cksum;
-+ unsigned int reserved[3];
-+ struct extended_signature sigs[0];
-+};
-+
-+
-+#define ASM_NOP1 K8_NOP1
-+#define ASM_NOP2 K8_NOP2
-+#define ASM_NOP3 K8_NOP3
-+#define ASM_NOP4 K8_NOP4
-+#define ASM_NOP5 K8_NOP5
-+#define ASM_NOP6 K8_NOP6
-+#define ASM_NOP7 K8_NOP7
-+#define ASM_NOP8 K8_NOP8
-+
-+/* Opteron nops */
-+#define K8_NOP1 ".byte 0x90\n"
-+#define K8_NOP2 ".byte 0x66,0x90\n"
-+#define K8_NOP3 ".byte 0x66,0x66,0x90\n"
-+#define K8_NOP4 ".byte 0x66,0x66,0x66,0x90\n"
-+#define K8_NOP5 K8_NOP3 K8_NOP2
-+#define K8_NOP6 K8_NOP3 K8_NOP3
-+#define K8_NOP7 K8_NOP4 K8_NOP3
-+#define K8_NOP8 K8_NOP4 K8_NOP4
-+
-+#define ASM_NOP_MAX 8
-+
-+/* REP NOP (PAUSE) is a good thing to insert into busy-wait loops. */
-+static inline void rep_nop(void)
-+{
-+ __asm__ __volatile__("rep;nop": : :"memory");
-+}
-+
-+/* Stop speculative execution */
-+static inline void sync_core(void)
-+{
-+ int tmp;
-+ asm volatile("cpuid" : "=a" (tmp) : "0" (1) : "ebx","ecx","edx","memory");
-+}
-+
-+#define cpu_has_fpu 1
-+
-+#define ARCH_HAS_PREFETCH
-+static inline void prefetch(void *x)
-+{
-+ asm volatile("prefetcht0 %0" :: "m" (*(unsigned long *)x));
-+}
-+
-+#define ARCH_HAS_PREFETCHW 1
-+static inline void prefetchw(void *x)
-+{
-+ alternative_input("prefetcht0 (%1)",
-+ "prefetchw (%1)",
-+ X86_FEATURE_3DNOW,
-+ "r" (x));
-+}
-+
-+#define ARCH_HAS_SPINLOCK_PREFETCH 1
-+
-+#define spin_lock_prefetch(x) prefetchw(x)
-+
-+#define cpu_relax() rep_nop()
-+
-+/*
-+ * NSC/Cyrix CPU configuration register indexes
-+ */
-+#define CX86_CCR0 0xc0
-+#define CX86_CCR1 0xc1
-+#define CX86_CCR2 0xc2
-+#define CX86_CCR3 0xc3
-+#define CX86_CCR4 0xe8
-+#define CX86_CCR5 0xe9
-+#define CX86_CCR6 0xea
-+#define CX86_CCR7 0xeb
-+#define CX86_DIR0 0xfe
-+#define CX86_DIR1 0xff
-+#define CX86_ARR_BASE 0xc4
-+#define CX86_RCR_BASE 0xdc
-+
-+/*
-+ * NSC/Cyrix CPU indexed register access macros
-+ */
-+
-+#define getCx86(reg) ({ outb((reg), 0x22); inb(0x23); })
-+
-+#define setCx86(reg, data) do { \
-+ outb((reg), 0x22); \
-+ outb((data), 0x23); \
-+} while (0)
-+
-+static inline void serialize_cpu(void)
-+{
-+ __asm__ __volatile__ ("cpuid" : : : "ax", "bx", "cx", "dx");
-+}
-+
-+static inline void __monitor(const void *eax, unsigned long ecx,
-+ unsigned long edx)
-+{
-+ /* "monitor %eax,%ecx,%edx;" */
-+ asm volatile(
-+ ".byte 0x0f,0x01,0xc8;"
-+ : :"a" (eax), "c" (ecx), "d"(edx));
-+}
-+
-+static inline void __mwait(unsigned long eax, unsigned long ecx)
-+{
-+ /* "mwait %eax,%ecx;" */
-+ asm volatile(
-+ ".byte 0x0f,0x01,0xc9;"
-+ : :"a" (eax), "c" (ecx));
-+}
-+
-+static inline void __sti_mwait(unsigned long eax, unsigned long ecx)
-+{
-+ /* "mwait %eax,%ecx;" */
-+ asm volatile(
-+ "sti; .byte 0x0f,0x01,0xc9;"
-+ : :"a" (eax), "c" (ecx));
-+}
-+
-+extern void mwait_idle_with_hints(unsigned long eax, unsigned long ecx);
-+
-+#define stack_current() \
-+({ \
-+ struct thread_info *ti; \
-+ asm("andq %%rsp,%0; ":"=r" (ti) : "0" (CURRENT_MASK)); \
-+ ti->task; \
-+})
-+
-+#define cache_line_size() (boot_cpu_data.x86_cache_alignment)
-+
-+extern unsigned long boot_option_idle_override;
-+/* Boot loader type from the setup header */
-+extern int bootloader_type;
-+
-+#define HAVE_ARCH_PICK_MMAP_LAYOUT 1
-+
-+#endif /* __ASM_X86_64_PROCESSOR_H */
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/asm-x86_64/mach-xen/asm/smp.h source/include/asm-x86_64/mach-xen/asm/smp.h
---- /scratch/src/linux-2.6.20.3/include/asm-x86_64/mach-xen/asm/smp.h 1970-01-01 01:00:00.000000000 +0100
-+++ source/include/asm-x86_64/mach-xen/asm/smp.h 2007-03-20 21:26:59.000000000 +0100
-@@ -0,0 +1,119 @@
-+#ifndef __ASM_SMP_H
-+#define __ASM_SMP_H
-+
-+/*
-+ * We need the APIC definitions automatically as part of 'smp.h'
-+ */
-+#include <linux/threads.h>
-+#include <linux/cpumask.h>
-+#include <linux/bitops.h>
-+extern int disable_apic;
-+
-+#include <asm/fixmap.h>
-+#include <asm/mpspec.h>
-+#include <asm/io_apic.h>
-+#include <asm/apic.h>
-+#include <asm/thread_info.h>
-+
-+#ifdef CONFIG_SMP
-+
-+#include <asm/pda.h>
-+
-+struct pt_regs;
-+
-+extern cpumask_t cpu_present_mask;
-+extern cpumask_t cpu_possible_map;
-+extern cpumask_t cpu_online_map;
-+extern cpumask_t cpu_initialized;
-+
-+/*
-+ * Private routines/data
-+ */
-+
-+extern void smp_alloc_memory(void);
-+extern volatile unsigned long smp_invalidate_needed;
-+extern void lock_ipi_call_lock(void);
-+extern void unlock_ipi_call_lock(void);
-+extern int smp_num_siblings;
-+extern void smp_send_reschedule(int cpu);
-+void smp_stop_cpu(void);
-+extern int smp_call_function_single(int cpuid, void (*func) (void *info),
-+ void *info, int retry, int wait);
-+
-+extern cpumask_t cpu_sibling_map[NR_CPUS];
-+extern cpumask_t cpu_core_map[NR_CPUS];
-+extern u8 cpu_llc_id[NR_CPUS];
-+
-+#define SMP_TRAMPOLINE_BASE 0x6000
-+
-+/*
-+ * On x86 all CPUs are mapped 1:1 to the APIC space.
-+ * This simplifies scheduling and IPI sending and
-+ * compresses data structures.
-+ */
-+
-+static inline int num_booting_cpus(void)
-+{
-+ return cpus_weight(cpu_possible_map);
-+}
-+
-+#define raw_smp_processor_id() read_pda(cpunumber)
-+
-+static inline int hard_smp_processor_id(void)
-+{
-+ /* we don't want to mark this access volatile - bad code generation */
-+ return GET_APIC_ID(*(unsigned int *)(APIC_BASE+APIC_ID));
-+}
-+
-+extern int __cpu_disable(void);
-+extern void __cpu_die(unsigned int cpu);
-+extern void prefill_possible_map(void);
-+extern unsigned num_processors;
-+extern unsigned disabled_cpus;
-+
-+#define NO_PROC_ID 0xFF /* No processor magic marker */
-+
-+#endif
-+
-+/*
-+ * Some lowlevel functions might want to know about
-+ * the real APIC ID <-> CPU # mapping.
-+ */
-+extern u8 x86_cpu_to_apicid[NR_CPUS]; /* physical ID */
-+extern u8 x86_cpu_to_log_apicid[NR_CPUS];
-+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;
-+}
-+
-+#ifndef CONFIG_SMP
-+#define stack_smp_processor_id() 0
-+#define cpu_logical_map(x) (x)
-+#else
-+#include <asm/thread_info.h>
-+#define stack_smp_processor_id() \
-+({ \
-+ struct thread_info *ti; \
-+ __asm__("andq %%rsp,%0; ":"=r" (ti) : "0" (CURRENT_MASK)); \
-+ ti->cpu; \
-+})
-+#endif
-+
-+static __inline int logical_smp_processor_id(void)
-+{
-+ /* we don't want to mark this access volatile - bad code generation */
-+ return GET_APIC_LOGICAL_ID(*(unsigned long *)(APIC_BASE+APIC_LDR));
-+}
-+
-+#ifdef CONFIG_SMP
-+#define cpu_physical_id(cpu) x86_cpu_to_apicid[cpu]
-+#else
-+#define cpu_physical_id(cpu) boot_cpu_id
-+#endif /* !CONFIG_SMP */
-+#endif
-+
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/asm-x86_64/mach-xen/asm/synch_bitops.h source/include/asm-x86_64/mach-xen/asm/synch_bitops.h
---- /scratch/src/linux-2.6.20.3/include/asm-x86_64/mach-xen/asm/synch_bitops.h 1970-01-01 01:00:00.000000000 +0100
-+++ source/include/asm-x86_64/mach-xen/asm/synch_bitops.h 2007-03-20 21:26:59.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/asm-x86_64/mach-xen/asm/synch_bitops.h
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/include/asm-x86_64/mach-xen/asm/synch_bitops.h Wed Aug 08 16:25:28 2007 -0300
@@ -0,0 +1,2 @@
+
+#include <asm-i386/mach-xen/asm/synch_bitops.h>
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/asm-x86_64/mach-xen/asm/system.h source/include/asm-x86_64/mach-xen/asm/system.h
---- /scratch/src/linux-2.6.20.3/include/asm-x86_64/mach-xen/asm/system.h 1970-01-01 01:00:00.000000000 +0100
-+++ source/include/asm-x86_64/mach-xen/asm/system.h 2007-03-20 21:26:59.000000000 +0100
-@@ -0,0 +1,266 @@
-+#ifndef __ASM_SYSTEM_H
-+#define __ASM_SYSTEM_H
-+
-+#include <linux/kernel.h>
-+#include <asm/segment.h>
-+#include <asm/alternative.h>
-+#include <asm/synch_bitops.h>
-+#include <asm/hypervisor.h>
-+#include <xen/interface/arch-x86_64.h>
-+
-+#ifdef __KERNEL__
-+
-+#ifdef CONFIG_SMP
-+#define __vcpu_id smp_processor_id()
-+#else
-+#define __vcpu_id 0
-+#endif
-+
-+#define __STR(x) #x
-+#define STR(x) __STR(x)
-+
-+#define __SAVE(reg,offset) "movq %%" #reg ",(14-" #offset ")*8(%%rsp)\n\t"
-+#define __RESTORE(reg,offset) "movq (14-" #offset ")*8(%%rsp),%%" #reg "\n\t"
-+
-+/* frame pointer must be last for get_wchan */
-+#define SAVE_CONTEXT "pushf ; pushq %%rbp ; movq %%rsi,%%rbp\n\t"
-+#define RESTORE_CONTEXT "movq %%rbp,%%rsi ; popq %%rbp ; popf\t"
-+
-+#define __EXTRA_CLOBBER \
-+ ,"rcx","rbx","rdx","r8","r9","r10","r11","r12","r13","r14","r15"
-+
-+/* Save restore flags to clear handle leaking NT */
-+#define switch_to(prev,next,last) \
-+ asm volatile(SAVE_CONTEXT \
-+ "movq %%rsp,%P[threadrsp](%[prev])\n\t" /* save RSP */ \
-+ "movq %P[threadrsp](%[next]),%%rsp\n\t" /* restore RSP */ \
-+ "call __switch_to\n\t" \
-+ ".globl thread_return\n" \
-+ "thread_return:\n\t" \
-+ "movq %%gs:%P[pda_pcurrent],%%rsi\n\t" \
-+ "movq %P[thread_info](%%rsi),%%r8\n\t" \
-+ LOCK_PREFIX "btr %[tif_fork],%P[ti_flags](%%r8)\n\t" \
-+ "movq %%rax,%%rdi\n\t" \
-+ "jc ret_from_fork\n\t" \
-+ RESTORE_CONTEXT \
-+ : "=a" (last) \
-+ : [next] "S" (next), [prev] "D" (prev), \
-+ [threadrsp] "i" (offsetof(struct task_struct, thread.rsp)), \
-+ [ti_flags] "i" (offsetof(struct thread_info, flags)),\
-+ [tif_fork] "i" (TIF_FORK), \
-+ [thread_info] "i" (offsetof(struct task_struct, thread_info)), \
-+ [pda_pcurrent] "i" (offsetof(struct x8664_pda, pcurrent)) \
-+ : "memory", "cc" __EXTRA_CLOBBER)
-+
-+extern void load_gs_index(unsigned);
-+
-+/*
-+ * Load a segment. Fall back on loading the zero
-+ * segment if something goes wrong..
-+ */
-+#define loadsegment(seg,value) \
-+ asm volatile("\n" \
-+ "1:\t" \
-+ "movl %k0,%%" #seg "\n" \
-+ "2:\n" \
-+ ".section .fixup,\"ax\"\n" \
-+ "3:\t" \
-+ "movl %1,%%" #seg "\n\t" \
-+ "jmp 2b\n" \
-+ ".previous\n" \
-+ ".section __ex_table,\"a\"\n\t" \
-+ ".align 8\n\t" \
-+ ".quad 1b,3b\n" \
-+ ".previous" \
-+ : :"r" (value), "r" (0))
-+
-+/*
-+ * Clear and set 'TS' bit respectively
-+ */
-+#define clts() (HYPERVISOR_fpu_taskswitch(0))
-+
-+static inline unsigned long read_cr0(void)
-+{
-+ unsigned long cr0;
-+ asm volatile("movq %%cr0,%0" : "=r" (cr0));
-+ return cr0;
-+}
-+
-+static inline void write_cr0(unsigned long val)
-+{
-+ asm volatile("movq %0,%%cr0" :: "r" (val));
-+}
-+
-+static inline unsigned long read_cr3(void)
-+{
-+ unsigned long cr3;
-+ asm("movq %%cr3,%0" : "=r" (cr3));
-+ return machine_to_phys(cr3);
-+}
-+
-+static inline unsigned long read_cr4(void)
-+{
-+ unsigned long cr4;
-+ asm("movq %%cr4,%0" : "=r" (cr4));
-+ return cr4;
-+}
-+
-+static inline void write_cr4(unsigned long val)
-+{
-+ asm volatile("movq %0,%%cr4" :: "r" (val));
-+}
-+
-+#define stts() (HYPERVISOR_fpu_taskswitch(1))
-+
-+#define wbinvd() \
-+ __asm__ __volatile__ ("wbinvd": : :"memory");
-+
-+/*
-+ * On SMP systems, when the scheduler does migration-cost autodetection,
-+ * it needs a way to flush as much of the CPU's caches as possible.
-+ */
-+static inline void sched_cacheflush(void)
-+{
-+ wbinvd();
-+}
-+
-+#endif /* __KERNEL__ */
-+
-+#define nop() __asm__ __volatile__ ("nop")
-+
-+#define xchg(ptr,v) ((__typeof__(*(ptr)))__xchg((unsigned long)(v),(ptr),sizeof(*(ptr))))
-+
-+#define tas(ptr) (xchg((ptr),1))
-+
-+#define __xg(x) ((volatile long *)(x))
-+
-+static inline void set_64bit(volatile unsigned long *ptr, unsigned long val)
-+{
-+ *ptr = val;
-+}
-+
-+#define _set_64bit set_64bit
-+
-+/*
-+ * Note: no "lock" prefix even on SMP: xchg always implies lock anyway
-+ * Note 2: xchg has side effect, so that attribute volatile is necessary,
-+ * but generally the primitive is invalid, *ptr is output argument. --ANK
-+ */
-+static inline unsigned long __xchg(unsigned long x, volatile void * ptr, int size)
-+{
-+ switch (size) {
-+ case 1:
-+ __asm__ __volatile__("xchgb %b0,%1"
-+ :"=q" (x)
-+ :"m" (*__xg(ptr)), "0" (x)
-+ :"memory");
-+ break;
-+ case 2:
-+ __asm__ __volatile__("xchgw %w0,%1"
-+ :"=r" (x)
-+ :"m" (*__xg(ptr)), "0" (x)
-+ :"memory");
-+ break;
-+ case 4:
-+ __asm__ __volatile__("xchgl %k0,%1"
-+ :"=r" (x)
-+ :"m" (*__xg(ptr)), "0" (x)
-+ :"memory");
-+ break;
-+ case 8:
-+ __asm__ __volatile__("xchgq %0,%1"
-+ :"=r" (x)
-+ :"m" (*__xg(ptr)), "0" (x)
-+ :"memory");
-+ break;
-+ }
-+ return x;
-+}
-+
-+/*
-+ * Atomic compare and exchange. Compare OLD with MEM, if identical,
-+ * store NEW in MEM. Return the initial value in MEM. Success is
-+ * indicated by comparing RETURN with OLD.
-+ */
-+
-+#define __HAVE_ARCH_CMPXCHG 1
-+
-+static inline unsigned long __cmpxchg(volatile void *ptr, unsigned long old,
-+ unsigned long new, int size)
-+{
-+ unsigned long prev;
-+ switch (size) {
-+ case 1:
-+ __asm__ __volatile__(LOCK_PREFIX "cmpxchgb %b1,%2"
-+ : "=a"(prev)
-+ : "q"(new), "m"(*__xg(ptr)), "0"(old)
-+ : "memory");
-+ return prev;
-+ case 2:
-+ __asm__ __volatile__(LOCK_PREFIX "cmpxchgw %w1,%2"
-+ : "=a"(prev)
-+ : "r"(new), "m"(*__xg(ptr)), "0"(old)
-+ : "memory");
-+ return prev;
-+ case 4:
-+ __asm__ __volatile__(LOCK_PREFIX "cmpxchgl %k1,%2"
-+ : "=a"(prev)
-+ : "r"(new), "m"(*__xg(ptr)), "0"(old)
-+ : "memory");
-+ return prev;
-+ case 8:
-+ __asm__ __volatile__(LOCK_PREFIX "cmpxchgq %1,%2"
-+ : "=a"(prev)
-+ : "r"(new), "m"(*__xg(ptr)), "0"(old)
-+ : "memory");
-+ return prev;
-+ }
-+ return old;
-+}
-+
-+#define cmpxchg(ptr,o,n)\
-+ ((__typeof__(*(ptr)))__cmpxchg((ptr),(unsigned long)(o),\
-+ (unsigned long)(n),sizeof(*(ptr))))
-+
-+#ifdef CONFIG_SMP
-+#define smp_mb() mb()
-+#define smp_rmb() rmb()
-+#define smp_wmb() wmb()
-+#define smp_read_barrier_depends() do {} while(0)
-+#else
-+#define smp_mb() barrier()
-+#define smp_rmb() barrier()
-+#define smp_wmb() barrier()
-+#define smp_read_barrier_depends() do {} while(0)
-+#endif
-+
-+
-+/*
-+ * Force strict CPU ordering.
-+ * And yes, this is required on UP too when we're talking
-+ * to devices.
-+ */
-+#define mb() asm volatile("mfence":::"memory")
-+#define rmb() asm volatile("lfence":::"memory")
-+
-+#ifdef CONFIG_UNORDERED_IO
-+#define wmb() asm volatile("sfence" ::: "memory")
-+#else
-+#define wmb() asm volatile("" ::: "memory")
-+#endif
-+#define read_barrier_depends() do {} while(0)
-+#define set_mb(var, value) do { (void) xchg(&var, value); } while (0)
-+
-+#define warn_if_not_ulong(x) do { unsigned long foo; (void) (&(x) == &foo); } while (0)
-+
-+void safe_halt(void);
-+void halt(void);
-+
-+#include <linux/irqflags.h>
-+
-+void cpu_idle_wait(void);
-+
-+extern unsigned long arch_align_stack(unsigned long sp);
-+extern void free_init_pages(char *what, unsigned long begin, unsigned long end);
-+
-+#endif
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/asm-x86_64/mach-xen/asm/timer.h source/include/asm-x86_64/mach-xen/asm/timer.h
---- /scratch/src/linux-2.6.20.3/include/asm-x86_64/mach-xen/asm/timer.h 1970-01-01 01:00:00.000000000 +0100
-+++ source/include/asm-x86_64/mach-xen/asm/timer.h 2007-03-20 21:26:59.000000000 +0100
-@@ -0,0 +1,67 @@
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/asm-x86_64/mach-xen/asm/timer.h
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/include/asm-x86_64/mach-xen/asm/timer.h Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,11 @@
+#ifndef _ASMi386_TIMER_H
+#define _ASMi386_TIMER_H
+#include <linux/init.h>
+
-+/**
-+ * struct timer_ops - used to define a timer source
-+ *
-+ * @name: name of the timer.
-+ * @init: Probes and initializes the timer. Takes clock= override
-+ * string as an argument. Returns 0 on success, anything else
-+ * on failure.
-+ * @mark_offset: called by the timer interrupt.
-+ * @get_offset: called by gettimeofday(). Returns the number of microseconds
-+ * since the last timer interupt.
-+ * @monotonic_clock: returns the number of nanoseconds since the init of the
-+ * timer.
-+ * @delay: delays this many clock cycles.
-+ */
-+struct timer_opts {
-+ char* name;
-+ void (*mark_offset)(void);
-+ unsigned long (*get_offset)(void);
-+ unsigned long long (*monotonic_clock)(void);
-+ void (*delay)(unsigned long);
-+ unsigned long (*read_timer)(void);
-+ int (*suspend)(pm_message_t state);
-+ int (*resume)(void);
-+};
-+
-+struct init_timer_opts {
-+ int (*init)(char *override);
-+ struct timer_opts *opts;
-+};
-+
+#define TICK_SIZE (tick_nsec / 1000)
-+
-+extern struct timer_opts* __init select_timer(void);
-+extern void clock_fallback(void);
+void setup_pit_timer(void);
-+
+/* Modifiers for buggy PIT handling */
-+
+extern int pit_latch_buggy;
-+
-+extern struct timer_opts *cur_timer;
+extern int timer_ack;
+
-+/* list of externed timers */
-+extern struct timer_opts timer_none;
-+extern struct timer_opts timer_pit;
-+extern struct init_timer_opts timer_pit_init;
-+extern struct init_timer_opts timer_tsc_init;
-+#ifdef CONFIG_X86_CYCLONE_TIMER
-+extern struct init_timer_opts timer_cyclone_init;
+#endif
-+
-+extern unsigned long calibrate_tsc(void);
-+extern void init_cpu_khz(void);
-+#ifdef CONFIG_HPET_TIMER
-+extern struct init_timer_opts timer_hpet_init;
-+extern unsigned long calibrate_tsc_hpet(unsigned long *tsc_hpet_quotient_ptr);
-+#endif
-+
-+#ifdef CONFIG_X86_PM_TIMER
-+extern struct init_timer_opts timer_pmtmr_init;
-+#endif
-+#endif
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/asm-x86_64/mach-xen/asm/tlbflush.h source/include/asm-x86_64/mach-xen/asm/tlbflush.h
---- /scratch/src/linux-2.6.20.3/include/asm-x86_64/mach-xen/asm/tlbflush.h 1970-01-01 01:00:00.000000000 +0100
-+++ source/include/asm-x86_64/mach-xen/asm/tlbflush.h 2007-03-20 21:26:59.000000000 +0100
-@@ -0,0 +1,120 @@
-+#ifndef _X8664_TLBFLUSH_H
-+#define _X8664_TLBFLUSH_H
-+
-+#include <linux/mm.h>
-+#include <asm/processor.h>
-+
-+static inline unsigned long get_cr3(void)
-+{
-+ unsigned long cr3;
-+ asm volatile("mov %%cr3,%0" : "=r" (cr3));
-+ return machine_to_phys(cr3);
-+}
-+
-+static inline void set_cr3(unsigned long cr3)
-+{
-+ BUG();
-+ /* What the hell is this supposed to do: JQ */
-+ asm volatile("mov %0,%%cr3" :: "r" (cr3) : "memory");
-+}
-+
-+#define __flush_tlb() xen_tlb_flush()
-+
-+static inline unsigned long get_cr4(void)
-+{
-+ unsigned long cr4;
-+ asm volatile("mov %%cr4,%0" : "=r" (cr4));
-+ return cr4;
-+}
-+
-+static inline void set_cr4(unsigned long cr4)
-+{
-+ asm volatile("mov %0,%%cr4" :: "r" (cr4) : "memory");
-+}
-+
-+#define __flush_tlb_all() xen_tlb_flush()
-+
-+#define __flush_tlb_one(addr) xen_invlpg((unsigned long)addr)
-+
-+
-+/*
-+ * TLB flushing:
-+ *
-+ * - flush_tlb() flushes the current mm struct TLBs
-+ * - flush_tlb_all() flushes all processes TLBs
-+ * - flush_tlb_mm(mm) flushes the specified mm context TLB's
-+ * - flush_tlb_page(vma, vmaddr) flushes one page
-+ * - flush_tlb_range(vma, start, end) flushes a range of pages
-+ * - flush_tlb_kernel_range(start, end) flushes a range of kernel pages
-+ * - flush_tlb_pgtables(mm, start, end) flushes a range of page tables
-+ *
-+ * x86-64 can only flush individual pages or full VMs. For a range flush
-+ * we always do the full VM. Might be worth trying if for a small
-+ * range a few INVLPGs in a row are a win.
-+ */
-+
-+#ifndef CONFIG_SMP
-+
-+#define flush_tlb() __flush_tlb()
-+#define flush_tlb_all() __flush_tlb_all()
-+#define local_flush_tlb() __flush_tlb()
-+
-+static inline void flush_tlb_mm(struct mm_struct *mm)
-+{
-+ if (mm == current->active_mm)
-+ __flush_tlb();
-+}
-+
-+static inline void flush_tlb_page(struct vm_area_struct *vma,
-+ unsigned long addr)
-+{
-+ if (vma->vm_mm == current->active_mm)
-+ __flush_tlb_one(addr);
-+}
-+
-+static inline void flush_tlb_range(struct vm_area_struct *vma,
-+ unsigned long start, unsigned long end)
-+{
-+ if (vma->vm_mm == current->active_mm)
-+ __flush_tlb();
-+}
-+
-+#else
-+
-+#include <asm/smp.h>
-+
-+#define local_flush_tlb() \
-+ __flush_tlb()
-+
-+extern void flush_tlb_all(void);
-+extern void flush_tlb_current_task(void);
-+extern void flush_tlb_mm(struct mm_struct *);
-+extern void flush_tlb_page(struct vm_area_struct *, unsigned long);
-+
-+#define flush_tlb() flush_tlb_current_task()
-+
-+static inline void flush_tlb_range(struct vm_area_struct * vma, unsigned long start, unsigned long end)
-+{
-+ flush_tlb_mm(vma->vm_mm);
-+}
-+
-+#define TLBSTATE_OK 1
-+#define TLBSTATE_LAZY 2
-+
-+/* Roughly an IPI every 20MB with 4k pages for freeing page table
-+ ranges. Cost is about 42k of memory for each CPU. */
-+#define ARCH_FREE_PTE_NR 5350
-+
-+#endif
-+
-+#define flush_tlb_kernel_range(start, end) flush_tlb_all()
-+
-+static inline void flush_tlb_pgtables(struct mm_struct *mm,
-+ unsigned long start, unsigned long end)
-+{
-+ /* x86_64 does not keep any page table caches in a software TLB.
-+ The CPUs do in their hardware TLBs, but they are handled
-+ by the normal TLB flushing algorithms. */
-+}
-+
-+#endif /* _X8664_TLBFLUSH_H */
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/asm-x86_64/mach-xen/asm/xenoprof.h source/include/asm-x86_64/mach-xen/asm/xenoprof.h
---- /scratch/src/linux-2.6.20.3/include/asm-x86_64/mach-xen/asm/xenoprof.h 1970-01-01 01:00:00.000000000 +0100
-+++ source/include/asm-x86_64/mach-xen/asm/xenoprof.h 2007-03-20 21:26:59.000000000 +0100
-@@ -0,0 +1 @@
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/asm-x86_64/mach-xen/asm/xenoprof.h
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/include/asm-x86_64/mach-xen/asm/xenoprof.h Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,1 @@
+#include <asm-i386/mach-xen/asm/xenoprof.h>
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/asm-x86_64/mach-xen/asm/xor.h source/include/asm-x86_64/mach-xen/asm/xor.h
---- /scratch/src/linux-2.6.20.3/include/asm-x86_64/mach-xen/asm/xor.h 1970-01-01 01:00:00.000000000 +0100
-+++ source/include/asm-x86_64/mach-xen/asm/xor.h 2007-03-20 21:26:59.000000000 +0100
-@@ -0,0 +1,328 @@
-+/*
-+ * x86-64 changes / gcc fixes from Andi Kleen.
-+ * Copyright 2002 Andi Kleen, SuSE Labs.
-+ *
-+ * This hasn't been optimized for the hammer yet, but there are likely
-+ * no advantages to be gotten from x86-64 here anyways.
-+ */
-+
-+typedef struct { unsigned long a,b; } __attribute__((aligned(16))) xmm_store_t;
-+
-+/* Doesn't use gcc to save the XMM registers, because there is no easy way to
-+ tell it to do a clts before the register saving. */
-+#define XMMS_SAVE do { \
-+ preempt_disable(); \
-+ if (!(current_thread_info()->status & TS_USEDFPU)) \
-+ clts(); \
-+ asm volatile ( \
-+ "movups %%xmm0,(%1) ;\n\t" \
-+ "movups %%xmm1,0x10(%1) ;\n\t" \
-+ "movups %%xmm2,0x20(%1) ;\n\t" \
-+ "movups %%xmm3,0x30(%1) ;\n\t" \
-+ : "=&r" (cr0) \
-+ : "r" (xmm_save) \
-+ : "memory"); \
-+} while(0)
-+
-+#define XMMS_RESTORE do { \
-+ asm volatile ( \
-+ "sfence ;\n\t" \
-+ "movups (%1),%%xmm0 ;\n\t" \
-+ "movups 0x10(%1),%%xmm1 ;\n\t" \
-+ "movups 0x20(%1),%%xmm2 ;\n\t" \
-+ "movups 0x30(%1),%%xmm3 ;\n\t" \
-+ : \
-+ : "r" (cr0), "r" (xmm_save) \
-+ : "memory"); \
-+ if (!(current_thread_info()->status & TS_USEDFPU)) \
-+ stts(); \
-+ preempt_enable(); \
-+} while(0)
-+
-+#define OFFS(x) "16*("#x")"
-+#define PF_OFFS(x) "256+16*("#x")"
-+#define PF0(x) " prefetchnta "PF_OFFS(x)"(%[p1]) ;\n"
-+#define LD(x,y) " movaps "OFFS(x)"(%[p1]), %%xmm"#y" ;\n"
-+#define ST(x,y) " movaps %%xmm"#y", "OFFS(x)"(%[p1]) ;\n"
-+#define PF1(x) " prefetchnta "PF_OFFS(x)"(%[p2]) ;\n"
-+#define PF2(x) " prefetchnta "PF_OFFS(x)"(%[p3]) ;\n"
-+#define PF3(x) " prefetchnta "PF_OFFS(x)"(%[p4]) ;\n"
-+#define PF4(x) " prefetchnta "PF_OFFS(x)"(%[p5]) ;\n"
-+#define PF5(x) " prefetchnta "PF_OFFS(x)"(%[p6]) ;\n"
-+#define XO1(x,y) " xorps "OFFS(x)"(%[p2]), %%xmm"#y" ;\n"
-+#define XO2(x,y) " xorps "OFFS(x)"(%[p3]), %%xmm"#y" ;\n"
-+#define XO3(x,y) " xorps "OFFS(x)"(%[p4]), %%xmm"#y" ;\n"
-+#define XO4(x,y) " xorps "OFFS(x)"(%[p5]), %%xmm"#y" ;\n"
-+#define XO5(x,y) " xorps "OFFS(x)"(%[p6]), %%xmm"#y" ;\n"
-+
-+
-+static void
-+xor_sse_2(unsigned long bytes, unsigned long *p1, unsigned long *p2)
-+{
-+ unsigned int lines = bytes >> 8;
-+ unsigned long cr0;
-+ xmm_store_t xmm_save[4];
-+
-+ XMMS_SAVE;
-+
-+ asm volatile (
-+#undef BLOCK
-+#define BLOCK(i) \
-+ LD(i,0) \
-+ LD(i+1,1) \
-+ PF1(i) \
-+ PF1(i+2) \
-+ LD(i+2,2) \
-+ LD(i+3,3) \
-+ PF0(i+4) \
-+ PF0(i+6) \
-+ XO1(i,0) \
-+ XO1(i+1,1) \
-+ XO1(i+2,2) \
-+ XO1(i+3,3) \
-+ ST(i,0) \
-+ ST(i+1,1) \
-+ ST(i+2,2) \
-+ ST(i+3,3) \
-+
-+
-+ PF0(0)
-+ PF0(2)
-+
-+ " .align 32 ;\n"
-+ " 1: ;\n"
-+
-+ BLOCK(0)
-+ BLOCK(4)
-+ BLOCK(8)
-+ BLOCK(12)
-+
-+ " addq %[inc], %[p1] ;\n"
-+ " addq %[inc], %[p2] ;\n"
-+ " decl %[cnt] ; jnz 1b"
-+ : [p1] "+r" (p1), [p2] "+r" (p2), [cnt] "+r" (lines)
-+ : [inc] "r" (256UL)
-+ : "memory");
-+
-+ XMMS_RESTORE;
-+}
-+
-+static void
-+xor_sse_3(unsigned long bytes, unsigned long *p1, unsigned long *p2,
-+ unsigned long *p3)
-+{
-+ unsigned int lines = bytes >> 8;
-+ xmm_store_t xmm_save[4];
-+ unsigned long cr0;
-+
-+ XMMS_SAVE;
-+
-+ __asm__ __volatile__ (
-+#undef BLOCK
-+#define BLOCK(i) \
-+ PF1(i) \
-+ PF1(i+2) \
-+ LD(i,0) \
-+ LD(i+1,1) \
-+ LD(i+2,2) \
-+ LD(i+3,3) \
-+ PF2(i) \
-+ PF2(i+2) \
-+ PF0(i+4) \
-+ PF0(i+6) \
-+ XO1(i,0) \
-+ XO1(i+1,1) \
-+ XO1(i+2,2) \
-+ XO1(i+3,3) \
-+ XO2(i,0) \
-+ XO2(i+1,1) \
-+ XO2(i+2,2) \
-+ XO2(i+3,3) \
-+ ST(i,0) \
-+ ST(i+1,1) \
-+ ST(i+2,2) \
-+ ST(i+3,3) \
-+
-+
-+ PF0(0)
-+ PF0(2)
-+
-+ " .align 32 ;\n"
-+ " 1: ;\n"
-+
-+ BLOCK(0)
-+ BLOCK(4)
-+ BLOCK(8)
-+ BLOCK(12)
-+
-+ " addq %[inc], %[p1] ;\n"
-+ " addq %[inc], %[p2] ;\n"
-+ " addq %[inc], %[p3] ;\n"
-+ " decl %[cnt] ; jnz 1b"
-+ : [cnt] "+r" (lines),
-+ [p1] "+r" (p1), [p2] "+r" (p2), [p3] "+r" (p3)
-+ : [inc] "r" (256UL)
-+ : "memory");
-+ XMMS_RESTORE;
-+}
-+
-+static void
-+xor_sse_4(unsigned long bytes, unsigned long *p1, unsigned long *p2,
-+ unsigned long *p3, unsigned long *p4)
-+{
-+ unsigned int lines = bytes >> 8;
-+ xmm_store_t xmm_save[4];
-+ unsigned long cr0;
-+
-+ XMMS_SAVE;
-+
-+ __asm__ __volatile__ (
-+#undef BLOCK
-+#define BLOCK(i) \
-+ PF1(i) \
-+ PF1(i+2) \
-+ LD(i,0) \
-+ LD(i+1,1) \
-+ LD(i+2,2) \
-+ LD(i+3,3) \
-+ PF2(i) \
-+ PF2(i+2) \
-+ XO1(i,0) \
-+ XO1(i+1,1) \
-+ XO1(i+2,2) \
-+ XO1(i+3,3) \
-+ PF3(i) \
-+ PF3(i+2) \
-+ PF0(i+4) \
-+ PF0(i+6) \
-+ XO2(i,0) \
-+ XO2(i+1,1) \
-+ XO2(i+2,2) \
-+ XO2(i+3,3) \
-+ XO3(i,0) \
-+ XO3(i+1,1) \
-+ XO3(i+2,2) \
-+ XO3(i+3,3) \
-+ ST(i,0) \
-+ ST(i+1,1) \
-+ ST(i+2,2) \
-+ ST(i+3,3) \
-+
-+
-+ PF0(0)
-+ PF0(2)
-+
-+ " .align 32 ;\n"
-+ " 1: ;\n"
-+
-+ BLOCK(0)
-+ BLOCK(4)
-+ BLOCK(8)
-+ BLOCK(12)
-+
-+ " addq %[inc], %[p1] ;\n"
-+ " addq %[inc], %[p2] ;\n"
-+ " addq %[inc], %[p3] ;\n"
-+ " addq %[inc], %[p4] ;\n"
-+ " decl %[cnt] ; jnz 1b"
-+ : [cnt] "+c" (lines),
-+ [p1] "+r" (p1), [p2] "+r" (p2), [p3] "+r" (p3), [p4] "+r" (p4)
-+ : [inc] "r" (256UL)
-+ : "memory" );
-+
-+ XMMS_RESTORE;
-+}
-+
-+static void
-+xor_sse_5(unsigned long bytes, unsigned long *p1, unsigned long *p2,
-+ unsigned long *p3, unsigned long *p4, unsigned long *p5)
-+{
-+ unsigned int lines = bytes >> 8;
-+ xmm_store_t xmm_save[4];
-+ unsigned long cr0;
-+
-+ XMMS_SAVE;
-+
-+ __asm__ __volatile__ (
-+#undef BLOCK
-+#define BLOCK(i) \
-+ PF1(i) \
-+ PF1(i+2) \
-+ LD(i,0) \
-+ LD(i+1,1) \
-+ LD(i+2,2) \
-+ LD(i+3,3) \
-+ PF2(i) \
-+ PF2(i+2) \
-+ XO1(i,0) \
-+ XO1(i+1,1) \
-+ XO1(i+2,2) \
-+ XO1(i+3,3) \
-+ PF3(i) \
-+ PF3(i+2) \
-+ XO2(i,0) \
-+ XO2(i+1,1) \
-+ XO2(i+2,2) \
-+ XO2(i+3,3) \
-+ PF4(i) \
-+ PF4(i+2) \
-+ PF0(i+4) \
-+ PF0(i+6) \
-+ XO3(i,0) \
-+ XO3(i+1,1) \
-+ XO3(i+2,2) \
-+ XO3(i+3,3) \
-+ XO4(i,0) \
-+ XO4(i+1,1) \
-+ XO4(i+2,2) \
-+ XO4(i+3,3) \
-+ ST(i,0) \
-+ ST(i+1,1) \
-+ ST(i+2,2) \
-+ ST(i+3,3) \
-+
-+
-+ PF0(0)
-+ PF0(2)
-+
-+ " .align 32 ;\n"
-+ " 1: ;\n"
-+
-+ BLOCK(0)
-+ BLOCK(4)
-+ BLOCK(8)
-+ BLOCK(12)
-+
-+ " addq %[inc], %[p1] ;\n"
-+ " addq %[inc], %[p2] ;\n"
-+ " addq %[inc], %[p3] ;\n"
-+ " addq %[inc], %[p4] ;\n"
-+ " addq %[inc], %[p5] ;\n"
-+ " decl %[cnt] ; jnz 1b"
-+ : [cnt] "+c" (lines),
-+ [p1] "+r" (p1), [p2] "+r" (p2), [p3] "+r" (p3), [p4] "+r" (p4),
-+ [p5] "+r" (p5)
-+ : [inc] "r" (256UL)
-+ : "memory");
-+
-+ XMMS_RESTORE;
-+}
-+
-+static struct xor_block_template xor_block_sse = {
-+ .name = "generic_sse",
-+ .do_2 = xor_sse_2,
-+ .do_3 = xor_sse_3,
-+ .do_4 = xor_sse_4,
-+ .do_5 = xor_sse_5,
-+};
-+
-+#undef XOR_TRY_TEMPLATES
-+#define XOR_TRY_TEMPLATES \
-+ do { \
-+ xor_speed(&xor_block_sse); \
-+ } while (0)
-+
-+/* We force the use of the SSE xor block because it can write around L2.
-+ We may also be able to load into the L1 only depending on how the cpu
-+ deals with a load to a line that is being prefetched. */
-+#define XOR_SELECT_TEMPLATE(FASTEST) (&xor_block_sse)
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/asm-x86_64/mach-xen/irq_vectors.h source/include/asm-x86_64/mach-xen/irq_vectors.h
---- /scratch/src/linux-2.6.20.3/include/asm-x86_64/mach-xen/irq_vectors.h 1970-01-01 01:00:00.000000000 +0100
-+++ source/include/asm-x86_64/mach-xen/irq_vectors.h 2007-03-20 21:26:59.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/asm-x86_64/mach-xen/irq_vectors.h
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/include/asm-x86_64/mach-xen/irq_vectors.h Wed Aug 08 16:25:28 2007 -0300
@@ -0,0 +1,123 @@
+/*
+ * This file should contain #defines for all of the interrupt vector
@@ -85470,9 +80874,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#define irq_to_dynirq(_x) ((_x) - DYNIRQ_BASE)
+
+#endif /* _ASM_IRQ_VECTORS_H */
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/asm-x86_64/mach-xen/mach_time.h source/include/asm-x86_64/mach-xen/mach_time.h
---- /scratch/src/linux-2.6.20.3/include/asm-x86_64/mach-xen/mach_time.h 1970-01-01 01:00:00.000000000 +0100
-+++ source/include/asm-x86_64/mach-xen/mach_time.h 2007-03-20 21:26:59.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/asm-x86_64/mach-xen/mach_time.h
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/include/asm-x86_64/mach-xen/mach_time.h Wed Aug 08 16:25:28 2007 -0300
@@ -0,0 +1,111 @@
+/*
+ * include/asm-i386/mach-default/mach_time.h
@@ -85585,10 +80989,10 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+}
+
+#endif /* !_MACH_TIME_H */
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/asm-x86_64/mach-xen/mach_timer.h source/include/asm-x86_64/mach-xen/mach_timer.h
---- /scratch/src/linux-2.6.20.3/include/asm-x86_64/mach-xen/mach_timer.h 1970-01-01 01:00:00.000000000 +0100
-+++ source/include/asm-x86_64/mach-xen/mach_timer.h 2007-03-20 21:26:59.000000000 +0100
-@@ -0,0 +1,48 @@
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/asm-x86_64/mach-xen/mach_timer.h
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/include/asm-x86_64/mach-xen/mach_timer.h Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,50 @@
+/*
+ * include/asm-i386/mach-default/mach_timer.h
+ *
@@ -85606,7 +81010,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#ifndef _MACH_TIMER_H
+#define _MACH_TIMER_H
+
-+#define CALIBRATE_LATCH (5 * LATCH)
++#define CALIBRATE_TIME_MSEC 30 /* 30 msecs */
++#define CALIBRATE_LATCH \
++ ((CLOCK_TICK_RATE * CALIBRATE_TIME_MSEC + 1000/2)/1000)
+
+static inline void mach_prepare_counter(void)
+{
@@ -85637,9 +81043,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+}
+
+#endif /* !_MACH_TIMER_H */
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/asm-x86_64/mach-xen/setup_arch_post.h source/include/asm-x86_64/mach-xen/setup_arch_post.h
---- /scratch/src/linux-2.6.20.3/include/asm-x86_64/mach-xen/setup_arch_post.h 1970-01-01 01:00:00.000000000 +0100
-+++ source/include/asm-x86_64/mach-xen/setup_arch_post.h 2007-03-20 21:26:59.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/asm-x86_64/mach-xen/setup_arch_post.h
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/include/asm-x86_64/mach-xen/setup_arch_post.h Wed Aug 08 16:25:28 2007 -0300
@@ -0,0 +1,63 @@
+/**
+ * machine_specific_* - Hooks for machine specific setup.
@@ -85682,7 +81088,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ ret = HYPERVISOR_callback_op(CALLBACKOP_register, &failsafe);
+ if (ret == 0)
+ ret = HYPERVISOR_callback_op(CALLBACKOP_register, &syscall);
-+#ifdef CONFIG_XEN_COMPAT_030002
++#if CONFIG_XEN_COMPAT <= 0x030002
+ if (ret == -ENOSYS)
+ ret = HYPERVISOR_set_callbacks(
+ event.address,
@@ -85693,7 +81099,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+
+#ifdef CONFIG_X86_LOCAL_APIC
+ ret = HYPERVISOR_callback_op(CALLBACKOP_register, &nmi_cb);
-+#ifdef CONFIG_XEN_COMPAT_030002
++#if CONFIG_XEN_COMPAT <= 0x030002
+ if (ret == -ENOSYS) {
+ static struct xennmi_callback __initdata cb = {
+ .handler_address = (unsigned long)nmi
@@ -85704,19 +81110,19 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#endif
+#endif
+}
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/asm-x86_64/mach-xen/setup_arch_pre.h source/include/asm-x86_64/mach-xen/setup_arch_pre.h
---- /scratch/src/linux-2.6.20.3/include/asm-x86_64/mach-xen/setup_arch_pre.h 1970-01-01 01:00:00.000000000 +0100
-+++ source/include/asm-x86_64/mach-xen/setup_arch_pre.h 2007-03-20 21:26:59.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/asm-x86_64/mach-xen/setup_arch_pre.h
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/include/asm-x86_64/mach-xen/setup_arch_pre.h Wed Aug 08 16:25:28 2007 -0300
@@ -0,0 +1,5 @@
+/* Hook to call BIOS initialisation function */
+
+#define ARCH_SETUP machine_specific_arch_setup();
+
+static void __init machine_specific_arch_setup(void);
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/asm-x86_64/mmu.h source/include/asm-x86_64/mmu.h
---- /scratch/src/linux-2.6.20.3/include/asm-x86_64/mmu.h 2007-02-04 19:44:54.000000000 +0100
-+++ source/include/asm-x86_64/mmu.h 2007-03-20 21:26:59.000000000 +0100
-@@ -15,6 +15,24 @@ typedef struct {
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/asm-x86_64/mmu.h
+--- a/include/asm-x86_64/mmu.h Wed Jul 18 12:23:24 2007 -0300
++++ b/include/asm-x86_64/mmu.h Wed Aug 08 16:25:28 2007 -0300
+@@ -15,6 +15,24 @@ typedef struct {
rwlock_t ldtlock;
int size;
struct semaphore sem;
@@ -85738,12 +81144,78 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+/* kernel/fork.c:dup_mmap hook */
+extern void _arch_dup_mmap(struct mm_struct *mm);
+#define arch_dup_mmap(mm, oldmm) ((void)(oldmm), _arch_dup_mmap(mm))
+ #endif
++
++#endif
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/asm-x86_64/msr.h
+--- a/include/asm-x86_64/msr.h Wed Jul 18 12:23:24 2007 -0300
++++ b/include/asm-x86_64/msr.h Wed Aug 08 16:25:28 2007 -0300
+@@ -90,10 +90,16 @@
+ : "=a" (low), "=d" (high) \
+ : "c" (counter))
+
++#ifdef CONFIG_XEN
++#define CPUID_STRING XEN_CPUID
++#else
++#define CPUID_STRING "cpuid"
+#endif
+
- #endif
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/asm-x86_64/nmi.h source/include/asm-x86_64/nmi.h
---- /scratch/src/linux-2.6.20.3/include/asm-x86_64/nmi.h 2007-02-04 19:44:54.000000000 +0100
-+++ source/include/asm-x86_64/nmi.h 2007-03-20 21:26:59.000000000 +0100
+ static inline void cpuid(int op, unsigned int *eax, unsigned int *ebx,
+ unsigned int *ecx, unsigned int *edx)
+ {
+- __asm__("cpuid"
++ __asm__(CPUID_STRING
+ : "=a" (*eax),
+ "=b" (*ebx),
+ "=c" (*ecx),
+@@ -105,7 +111,7 @@ static inline void cpuid_count(int op, i
+ static inline void cpuid_count(int op, int count, int *eax, int *ebx, int *ecx,
+ int *edx)
+ {
+- __asm__("cpuid"
++ __asm__(CPUID_STRING
+ : "=a" (*eax),
+ "=b" (*ebx),
+ "=c" (*ecx),
+@@ -120,7 +126,7 @@ static inline unsigned int cpuid_eax(uns
+ {
+ unsigned int eax;
+
+- __asm__("cpuid"
++ __asm__(CPUID_STRING
+ : "=a" (eax)
+ : "0" (op)
+ : "bx", "cx", "dx");
+@@ -130,7 +136,7 @@ static inline unsigned int cpuid_ebx(uns
+ {
+ unsigned int eax, ebx;
+
+- __asm__("cpuid"
++ __asm__(CPUID_STRING
+ : "=a" (eax), "=b" (ebx)
+ : "0" (op)
+ : "cx", "dx" );
+@@ -140,7 +146,7 @@ static inline unsigned int cpuid_ecx(uns
+ {
+ unsigned int eax, ecx;
+
+- __asm__("cpuid"
++ __asm__(CPUID_STRING
+ : "=a" (eax), "=c" (ecx)
+ : "0" (op)
+ : "bx", "dx" );
+@@ -150,7 +156,7 @@ static inline unsigned int cpuid_edx(uns
+ {
+ unsigned int eax, edx;
+
+- __asm__("cpuid"
++ __asm__(CPUID_STRING
+ : "=a" (eax), "=d" (edx)
+ : "0" (op)
+ : "bx", "cx");
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/asm-x86_64/nmi.h
+--- a/include/asm-x86_64/nmi.h Wed Jul 18 12:23:24 2007 -0300
++++ b/include/asm-x86_64/nmi.h Wed Aug 08 16:25:28 2007 -0300
@@ -7,6 +7,10 @@
#include <linux/pm.h>
#include <asm/io.h>
@@ -85755,7 +81227,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
/**
* do_nmi_callback
*
-@@ -39,7 +43,25 @@ static inline void unset_nmi_pm_callback
+@@ -39,7 +43,25 @@ extern void default_do_nmi(struct pt_reg
extern void default_do_nmi(struct pt_regs *);
extern void die_nmi(char *str, struct pt_regs *regs, int do_panic);
@@ -85781,16 +81253,13 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
extern int panic_on_timeout;
extern int unknown_nmi_panic;
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/asm-x86_64/pci.h source/include/asm-x86_64/pci.h
---- /scratch/src/linux-2.6.20.3/include/asm-x86_64/pci.h 2007-02-04 19:44:54.000000000 +0100
-+++ source/include/asm-x86_64/pci.h 2007-03-20 21:26:59.000000000 +0100
-@@ -75,6 +75,23 @@ extern int iommu_sac_force;
- #define pci_unmap_len_set(PTR, LEN_NAME, VAL) \
- (((PTR)->LEN_NAME) = (VAL))
-
-+#elif defined(CONFIG_SWIOTLB)
-+
-+#define pci_dac_dma_supported(pci_dev, mask) 1
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/asm-x86_64/pci.h
+--- a/include/asm-x86_64/pci.h Wed Jul 18 12:23:24 2007 -0300
++++ b/include/asm-x86_64/pci.h Wed Aug 08 16:25:28 2007 -0300
+@@ -61,6 +61,23 @@ extern int iommu_setup(char *opt);
+ */
+ extern int iommu_sac_force;
+ #define pci_dac_dma_supported(pci_dev, mask) (!iommu_sac_force)
+
+#define DECLARE_PCI_UNMAP_ADDR(ADDR_NAME) \
+ dma_addr_t ADDR_NAME;
@@ -85805,26 +81274,206 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#define pci_unmap_len_set(PTR, LEN_NAME, VAL) \
+ (((PTR)->LEN_NAME) = (VAL))
+
- #else
- /* No IOMMU */
++#elif defined(CONFIG_SWIOTLB)
++
++#define pci_dac_dma_supported(pci_dev, mask) 1
-@@ -146,4 +163,13 @@ static inline void pcibios_add_platform_
- #include <asm-generic/pci.h>
- #endif
+ #define DECLARE_PCI_UNMAP_ADDR(ADDR_NAME) \
+ dma_addr_t ADDR_NAME;
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/asm-x86_64/processor.h
+--- a/include/asm-x86_64/processor.h Wed Jul 18 12:23:24 2007 -0300
++++ b/include/asm-x86_64/processor.h Wed Aug 08 16:25:28 2007 -0300
+@@ -188,7 +188,9 @@ static inline void clear_in_cr4 (unsigne
+ #define IO_BITMAP_BITS 65536
+ #define IO_BITMAP_BYTES (IO_BITMAP_BITS/8)
+ #define IO_BITMAP_LONGS (IO_BITMAP_BYTES/sizeof(long))
++#ifndef CONFIG_X86_NO_TSS
+ #define IO_BITMAP_OFFSET offsetof(struct tss_struct,io_bitmap)
++#endif
+ #define INVALID_IO_BITMAP_OFFSET 0x8000
+
+ struct i387_fxsave_struct {
+@@ -209,6 +211,7 @@ union i387_union {
+ struct i387_fxsave_struct fxsave;
+ };
+
++#ifndef CONFIG_X86_NO_TSS
+ struct tss_struct {
+ u32 reserved1;
+ u64 rsp0;
+@@ -231,15 +234,18 @@ struct tss_struct {
+ */
+ unsigned long io_bitmap[IO_BITMAP_LONGS + 1];
+ } __attribute__((packed)) ____cacheline_aligned;
++#endif
+
+
+ extern struct cpuinfo_x86 boot_cpu_data;
++#ifndef CONFIG_X86_NO_TSS
+ DECLARE_PER_CPU(struct tss_struct,init_tss);
+ /* Save the original ist values for checking stack pointers during debugging */
+ struct orig_ist {
+ unsigned long ist[7];
+ };
+ DECLARE_PER_CPU(struct orig_ist, orig_ist);
++#endif
+
+ #ifdef CONFIG_X86_VSMP
+ #define ARCH_MIN_TASKALIGN (1 << INTERNODE_CACHE_SHIFT)
+@@ -274,15 +280,20 @@ struct thread_struct {
+ unsigned io_bitmap_max;
+ /* cached TLS descriptors. */
+ u64 tls_array[GDT_ENTRY_TLS_ENTRIES];
++#ifdef CONFIG_XEN
++ unsigned int iopl;
++#endif
+ } __attribute__((aligned(16)));
+
+ #define INIT_THREAD { \
+ .rsp0 = (unsigned long)&init_stack + sizeof(init_stack) \
+ }
+
++#ifndef CONFIG_X86_NO_TSS
+ #define INIT_TSS { \
+ .rsp0 = (unsigned long)&init_stack + sizeof(init_stack) \
+ }
++#endif
+
+ #define INIT_MMAP \
+ { &init_mm, 0, 0, NULL, PAGE_SHARED, VM_READ | VM_WRITE | VM_EXEC, 1, NULL, NULL }
+@@ -299,6 +310,12 @@ struct thread_struct {
+ set_fs(USER_DS); \
+ } while(0)
+
++#ifdef CONFIG_XEN
++#define get_debugreg(var, register) \
++ var = HYPERVISOR_get_debugreg(register)
++#define set_debugreg(value, register) \
++ HYPERVISOR_set_debugreg(register, value)
++#else
+ #define get_debugreg(var, register) \
+ __asm__("movq %%db" #register ", %0" \
+ :"=r" (var))
+@@ -306,6 +323,7 @@ struct thread_struct {
+ __asm__("movq %0,%%db" #register \
+ : /* no output */ \
+ :"r" (value))
++#endif
+
+ struct task_struct;
+ struct mm_struct;
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/asm-x86_64/smp.h
+--- a/include/asm-x86_64/smp.h Wed Jul 18 12:23:24 2007 -0300
++++ b/include/asm-x86_64/smp.h Wed Aug 08 16:25:28 2007 -0300
+@@ -53,7 +53,11 @@ extern u8 cpu_llc_id[NR_CPUS];
+
+ static inline int num_booting_cpus(void)
+ {
++#ifdef CONFIG_XEN
++ return cpus_weight(cpu_possible_map);
++#else
+ return cpus_weight(cpu_callout_map);
++#endif
+ }
+ #define raw_smp_processor_id() read_pda(cpunumber)
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/asm-x86_64/system.h
+--- a/include/asm-x86_64/system.h Wed Jul 18 12:23:24 2007 -0300
++++ b/include/asm-x86_64/system.h Wed Aug 08 16:25:28 2007 -0300
+@@ -4,6 +4,12 @@
+ #include <linux/kernel.h>
+ #include <asm/segment.h>
+ #include <asm/alternative.h>
++
+#ifdef CONFIG_XEN
-+/* On Xen we have to scan all functions since Xen hides bridges from
-+ * us. If a bridge is at fn=0 and that slot has a multifunction
-+ * device, we won't find the additional devices without scanning all
-+ * functions. */
-+#undef pcibios_scan_all_fns
-+#define pcibios_scan_all_fns(a, b) 1
-+#endif
-+
- #endif /* __x8664_PCI_H */
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/asm-x86_64/vga.h source/include/asm-x86_64/vga.h
---- /scratch/src/linux-2.6.20.3/include/asm-x86_64/vga.h 2007-02-04 19:44:54.000000000 +0100
-+++ source/include/asm-x86_64/vga.h 2007-03-20 21:26:59.000000000 +0100
++#include <asm/synch_bitops.h>
++#include <asm/hypervisor.h>
++#include <xen/interface/arch-x86_64.h>
++#endif
+
+ #ifdef __KERNEL__
+
+@@ -68,7 +74,11 @@ extern void load_gs_index(unsigned);
+ /*
+ * Clear and set 'TS' bit respectively
+ */
++#ifdef CONFIG_XEN
++#define clts() (HYPERVISOR_fpu_taskswitch(0))
++#else
+ #define clts() __asm__ __volatile__ ("clts")
++#endif
+
+ static inline unsigned long read_cr0(void)
+ {
+@@ -86,7 +96,11 @@ static inline unsigned long read_cr3(voi
+ {
+ unsigned long cr3;
+ asm("movq %%cr3,%0" : "=r" (cr3));
++#ifdef CONFIG_XEN
++ return machine_to_phys(cr3);
++#else
+ return cr3;
++#endif
+ }
+
+ static inline unsigned long read_cr4(void)
+@@ -101,7 +115,11 @@ static inline void write_cr4(unsigned lo
+ asm volatile("movq %0,%%cr4" :: "r" (val));
+ }
+
++#ifdef CONFIG_XEN
++#define stts() (HYPERVISOR_fpu_taskswitch(1))
++#else
+ #define stts() write_cr0(8 | read_cr0())
++#endif
+
+ #define wbinvd() \
+ __asm__ __volatile__ ("wbinvd": : :"memory");
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/asm-x86_64/tlbflush.h
+--- a/include/asm-x86_64/tlbflush.h Wed Jul 18 12:23:24 2007 -0300
++++ b/include/asm-x86_64/tlbflush.h Wed Aug 08 16:25:28 2007 -0300
+@@ -16,10 +16,14 @@ static inline void set_cr3(unsigned long
+ asm volatile("mov %0,%%cr3" :: "r" (cr3) : "memory");
+ }
+
++#ifdef CONFIG_XEN
++#define __flush_tlb() xen_tlb_flush()
++#else
+ static inline void __flush_tlb(void)
+ {
+ set_cr3(get_cr3());
+ }
++#endif
+
+ static inline unsigned long get_cr4(void)
+ {
+@@ -33,15 +37,23 @@ static inline void set_cr4(unsigned long
+ asm volatile("mov %0,%%cr4" :: "r" (cr4) : "memory");
+ }
+
++#ifdef CONFIG_XEN
++#define __flush_tlb_all() xen_tlb_flush()
++#else
+ static inline void __flush_tlb_all(void)
+ {
+ unsigned long cr4 = get_cr4();
+ set_cr4(cr4 & ~X86_CR4_PGE); /* clear PGE */
+ set_cr4(cr4); /* write old PGE again and flush TLBs */
+ }
++#endif
+
++#ifdef CONFIG_XEN
++#define __flush_tlb_one(addr) xen_invlpg((unsigned long)addr)
++#else
+ #define __flush_tlb_one(addr) \
+ __asm__ __volatile__("invlpg (%0)" :: "r" (addr) : "memory")
++#endif
+
+
+ /*
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/asm-x86_64/vga.h
+--- a/include/asm-x86_64/vga.h Wed Jul 18 12:23:24 2007 -0300
++++ b/include/asm-x86_64/vga.h Wed Aug 08 16:25:28 2007 -0300
@@ -12,7 +12,11 @@
* access the videoram directly without any black magic.
*/
@@ -85837,9 +81486,94 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
#define vga_readb(x) (*(x))
#define vga_writeb(x,y) (*(y) = (x))
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/linux/gfp.h source/include/linux/gfp.h
---- /scratch/src/linux-2.6.20.3/include/linux/gfp.h 2007-02-04 19:44:54.000000000 +0100
-+++ source/include/linux/gfp.h 2007-03-20 21:27:00.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/asm-x86_64/xor.h
+--- a/include/asm-x86_64/xor.h Wed Jul 18 12:23:24 2007 -0300
++++ b/include/asm-x86_64/xor.h Wed Aug 08 16:25:28 2007 -0300
+@@ -37,6 +37,37 @@ typedef struct { unsigned long a,b; } __
+
+ /* Doesn't use gcc to save the XMM registers, because there is no easy way to
+ tell it to do a clts before the register saving. */
++
++#ifdef CONFIG_XEN
++#define XMMS_SAVE do { \
++ preempt_disable(); \
++ if (!(current_thread_info()->status & TS_USEDFPU)) \
++ clts(); \
++ asm volatile ( \
++ "movups %%xmm0,(%1) ;\n\t" \
++ "movups %%xmm1,0x10(%1) ;\n\t" \
++ "movups %%xmm2,0x20(%1) ;\n\t" \
++ "movups %%xmm3,0x30(%1) ;\n\t" \
++ : "=&r" (cr0) \
++ : "r" (xmm_save) \
++ : "memory"); \
++} while(0)
++
++#define XMMS_RESTORE do { \
++ asm volatile ( \
++ "sfence ;\n\t" \
++ "movups (%1),%%xmm0 ;\n\t" \
++ "movups 0x10(%1),%%xmm1 ;\n\t" \
++ "movups 0x20(%1),%%xmm2 ;\n\t" \
++ "movups 0x30(%1),%%xmm3 ;\n\t" \
++ : \
++ : "r" (cr0), "r" (xmm_save) \
++ : "memory"); \
++ if (!(current_thread_info()->status & TS_USEDFPU)) \
++ stts(); \
++ preempt_enable(); \
++} while(0)
++#else
+ #define XMMS_SAVE do { \
+ preempt_disable(); \
+ asm volatile ( \
+@@ -64,6 +95,7 @@ typedef struct { unsigned long a,b; } __
+ : "memory"); \
+ preempt_enable(); \
+ } while(0)
++#endif /* CONFIG_XEN */
+
+ #define OFFS(x) "16*("#x")"
+ #define PF_OFFS(x) "256+16*("#x")"
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/linux/crash_dump.h
+--- a/include/linux/crash_dump.h Wed Jul 18 12:23:24 2007 -0300
++++ b/include/linux/crash_dump.h Wed Aug 08 16:25:28 2007 -0300
+@@ -14,5 +14,13 @@ extern const struct file_operations proc
+ extern const struct file_operations proc_vmcore_operations;
+ extern struct proc_dir_entry *proc_vmcore;
+
++/* Architecture code defines this if there are other possible ELF
++ * machine types, e.g. on bi-arch capable hardware. */
++#ifndef vmcore_elf_check_arch_cross
++#define vmcore_elf_check_arch_cross(x) 0
++#endif
++
++#define vmcore_elf_check_arch(x) (elf_check_arch(x) || vmcore_elf_check_arch_cross(x))
++
+ #endif /* CONFIG_CRASH_DUMP */
+ #endif /* LINUX_CRASHDUMP_H */
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/linux/elfnote.h
+--- a/include/linux/elfnote.h Wed Jul 18 12:23:24 2007 -0300
++++ b/include/linux/elfnote.h Wed Aug 08 16:25:28 2007 -0300
+@@ -38,13 +38,13 @@
+ * e.g. ELFNOTE(XYZCo, 42, .asciz, "forty-two")
+ * ELFNOTE(XYZCo, 12, .long, 0xdeadbeef)
+ */
+-#define ELFNOTE(name, type, desctype, descdata) \
++#define ELFNOTE(name, type, desctype, descdata...) \
+ .pushsection .note.name ; \
+ .align 4 ; \
+ .long 2f - 1f /* namesz */ ; \
+ .long 4f - 3f /* descsz */ ; \
+ .long type ; \
+-1:.asciz "name" ; \
++1:.asciz #name ; \
+ 2:.align 4 ; \
+ 3:desctype descdata ; \
+ 4:.align 4 ; \
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/linux/gfp.h
+--- a/include/linux/gfp.h Wed Jul 18 12:23:24 2007 -0300
++++ b/include/linux/gfp.h Wed Aug 08 16:25:28 2007 -0300
@@ -114,7 +114,11 @@ static inline enum zone_type gfp_zone(gf
*/
@@ -85853,9 +81587,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
#endif
#ifndef HAVE_ARCH_ALLOC_PAGE
static inline void arch_alloc_page(struct page *page, int order) { }
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/linux/highmem.h source/include/linux/highmem.h
---- /scratch/src/linux-2.6.20.3/include/linux/highmem.h 2007-02-04 19:44:54.000000000 +0100
-+++ source/include/linux/highmem.h 2007-03-20 21:27:00.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/linux/highmem.h
+--- a/include/linux/highmem.h Wed Jul 18 12:23:24 2007 -0300
++++ b/include/linux/highmem.h Wed Aug 08 16:25:28 2007 -0300
@@ -26,10 +26,16 @@ static inline void flush_kernel_dcache_p
/* declarations for linux/mm/highmem.c */
unsigned int nr_free_highpages(void);
@@ -85873,36 +81607,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
#define totalhigh_pages 0
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/linux/if_packet.h source/include/linux/if_packet.h
---- /scratch/src/linux-2.6.20.3/include/linux/if_packet.h 2007-02-04 19:44:54.000000000 +0100
-+++ source/include/linux/if_packet.h 2007-03-21 15:57:54.000000000 +0100
-@@ -41,6 +41,7 @@ struct sockaddr_ll
- #define PACKET_RX_RING 5
- #define PACKET_STATISTICS 6
- #define PACKET_COPY_THRESH 7
-+#define PACKET_AUXDATA 8
-
- struct tpacket_stats
- {
-@@ -48,6 +49,15 @@ struct tpacket_stats
- unsigned int tp_drops;
- };
-
-+struct tpacket_auxdata
-+{
-+ __u32 tp_status;
-+ __u32 tp_len;
-+ __u32 tp_snaplen;
-+ __u16 tp_mac;
-+ __u16 tp_net;
-+};
-+
- struct tpacket_hdr
- {
- unsigned long tp_status;
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/linux/interrupt.h source/include/linux/interrupt.h
---- /scratch/src/linux-2.6.20.3/include/linux/interrupt.h 2007-02-04 19:44:54.000000000 +0100
-+++ source/include/linux/interrupt.h 2007-03-20 21:27:00.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/linux/interrupt.h
+--- a/include/linux/interrupt.h Wed Jul 18 12:23:24 2007 -0300
++++ b/include/linux/interrupt.h Wed Aug 08 16:25:28 2007 -0300
@@ -184,6 +184,12 @@ static inline int disable_irq_wake(unsig
#endif /* CONFIG_GENERIC_HARDIRQS */
@@ -85916,24 +81623,24 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
#ifndef __ARCH_SET_SOFTIRQ_PENDING
#define set_softirq_pending(x) (local_softirq_pending() = (x))
#define or_softirq_pending(x) (local_softirq_pending() |= (x))
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/linux/kexec.h source/include/linux/kexec.h
---- /scratch/src/linux-2.6.20.3/include/linux/kexec.h 2007-02-04 19:44:54.000000000 +0100
-+++ source/include/linux/kexec.h 2007-03-20 21:27:00.000000000 +0100
-@@ -31,6 +31,13 @@
- #error KEXEC_ARCH not defined
- #endif
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/linux/kexec.h
+--- a/include/linux/kexec.h Wed Jul 18 12:23:24 2007 -0300
++++ b/include/linux/kexec.h Wed Aug 08 16:25:28 2007 -0300
+@@ -29,6 +29,13 @@
+ #ifndef KEXEC_ARCH
+ #error KEXEC_ARCH not defined
++#endif
++
+#ifndef KEXEC_ARCH_HAS_PAGE_MACROS
+#define kexec_page_to_pfn(page) page_to_pfn(page)
+#define kexec_pfn_to_page(pfn) pfn_to_page(pfn)
+#define kexec_virt_to_phys(addr) virt_to_phys(addr)
+#define kexec_phys_to_virt(addr) phys_to_virt(addr)
-+#endif
-+
+ #endif
+
/*
- * This structure is used to hold the arguments that are used when loading
- * kernel binaries.
-@@ -91,6 +98,12 @@ struct kimage {
+@@ -91,6 +98,12 @@ extern NORET_TYPE void machine_kexec(str
extern NORET_TYPE void machine_kexec(struct kimage *image) ATTRIB_NORET;
extern int machine_kexec_prepare(struct kimage *image);
extern void machine_kexec_cleanup(struct kimage *image);
@@ -85946,9 +81653,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
extern asmlinkage long sys_kexec_load(unsigned long entry,
unsigned long nr_segments,
struct kexec_segment __user *segments,
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/linux/mm.h source/include/linux/mm.h
---- /scratch/src/linux-2.6.20.3/include/linux/mm.h 2007-02-04 19:44:54.000000000 +0100
-+++ source/include/linux/mm.h 2007-03-20 21:27:00.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/linux/mm.h
+--- a/include/linux/mm.h Wed Jul 18 12:23:24 2007 -0300
++++ b/include/linux/mm.h Wed Aug 08 16:25:28 2007 -0300
@@ -169,6 +169,9 @@ extern unsigned int kobjsize(const void
#define VM_MAPPED_COPY 0x01000000 /* T if mapped copy of data (nommu mmap) */
#define VM_INSERTPAGE 0x02000000 /* The vma has had "vm_insert_page()" done on it */
@@ -85959,7 +81666,20 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
#ifndef VM_STACK_DEFAULT_FLAGS /* arch can override this */
#define VM_STACK_DEFAULT_FLAGS VM_DATA_DEFAULT_FLAGS
-@@ -1129,6 +1132,13 @@ struct page *follow_page(struct vm_area_
+@@ -208,6 +211,12 @@ struct vm_operations_struct {
+ /* notification that a previously read-only page is about to become
+ * writable, if an error is returned it will cause a SIGBUS */
+ int (*page_mkwrite)(struct vm_area_struct *vma, struct page *page);
++ /* Area-specific function for clearing the PTE at @ptep. Returns the
++ * original value of @ptep. */
++#ifdef CONFIG_XEN
++ pte_t (*zap_pte)(struct vm_area_struct *vma,
++ unsigned long addr, pte_t *ptep, int is_fullmm);
++#endif
+ #ifdef CONFIG_NUMA
+ int (*set_policy)(struct vm_area_struct *vma, struct mempolicy *new);
+ struct mempolicy *(*get_policy)(struct vm_area_struct *vma,
+@@ -1129,6 +1138,13 @@ struct page *follow_page(struct vm_area_
#define FOLL_GET 0x04 /* do get_page on page */
#define FOLL_ANON 0x08 /* give ZERO_PAGE if no pgtable */
@@ -85973,9 +81693,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
#ifdef CONFIG_PROC_FS
void vm_stat_account(struct mm_struct *, unsigned long, struct file *, long);
#else
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/linux/oprofile.h source/include/linux/oprofile.h
---- /scratch/src/linux-2.6.20.3/include/linux/oprofile.h 2007-02-04 19:44:54.000000000 +0100
-+++ source/include/linux/oprofile.h 2007-03-20 21:27:01.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/linux/oprofile.h
+--- a/include/linux/oprofile.h Wed Jul 18 12:23:24 2007 -0300
++++ b/include/linux/oprofile.h Wed Aug 08 16:25:28 2007 -0300
@@ -16,6 +16,10 @@
#include <linux/types.h>
#include <linux/spinlock.h>
@@ -86008,23 +81728,59 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
/**
* Create a file of the given name as a child of the given root, with
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/linux/pfn.h source/include/linux/pfn.h
---- /scratch/src/linux-2.6.20.3/include/linux/pfn.h 2007-02-04 19:44:54.000000000 +0100
-+++ source/include/linux/pfn.h 2007-03-20 21:27:01.000000000 +0100
-@@ -4,6 +4,10 @@
- #define PFN_ALIGN(x) (((unsigned long)(x) + (PAGE_SIZE - 1)) & PAGE_MASK)
- #define PFN_UP(x) (((x) + PAGE_SIZE-1) >> PAGE_SHIFT)
- #define PFN_DOWN(x) ((x) >> PAGE_SHIFT)
-+#if defined(CONFIG_X86_XEN) && defined(CONFIG_X86_PAE)
-+#define PFN_PHYS(x) ((unsigned long long)(x) << PAGE_SHIFT)
-+#else
- #define PFN_PHYS(x) ((x) << PAGE_SHIFT)
-+#endif
-
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/linux/page-flags.h
+--- a/include/linux/page-flags.h Wed Jul 18 12:23:24 2007 -0300
++++ b/include/linux/page-flags.h Wed Aug 08 16:25:28 2007 -0300
+@@ -102,6 +102,8 @@
+ */
+ #define PG_uncached 31 /* Page has been mapped as uncached */
#endif
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/linux/skbuff.h source/include/linux/skbuff.h
---- /scratch/src/linux-2.6.20.3/include/linux/skbuff.h 2007-02-04 19:44:54.000000000 +0100
-+++ source/include/linux/skbuff.h 2007-03-20 21:27:01.000000000 +0100
++
++#define PG_foreign 20 /* Page is owned by foreign allocator. */
+
+ /*
+ * Manipulation of page state flags
+@@ -251,6 +253,18 @@ static inline void SetPageUptodate(struc
+ #define SetPageUncached(page) set_bit(PG_uncached, &(page)->flags)
+ #define ClearPageUncached(page) clear_bit(PG_uncached, &(page)->flags)
+
++#define PageForeign(page) test_bit(PG_foreign, &(page)->flags)
++#define SetPageForeign(page, dtor) do { \
++ set_bit(PG_foreign, &(page)->flags); \
++ (page)->index = (long)(dtor); \
++} while (0)
++#define ClearPageForeign(page) do { \
++ clear_bit(PG_foreign, &(page)->flags); \
++ (page)->index = 0; \
++} while (0)
++#define PageForeignDestructor(page) \
++ ( (void (*) (struct page *)) (page)->index )(page)
++
+ struct page; /* forward declaration */
+
+ extern void cancel_dirty_page(struct page *page, unsigned int account_size);
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/linux/sched.h
+--- a/include/linux/sched.h Wed Jul 18 12:23:24 2007 -0300
++++ b/include/linux/sched.h Wed Aug 08 16:25:28 2007 -0300
+@@ -223,10 +223,15 @@ extern void scheduler_tick(void);
+ extern void scheduler_tick(void);
+
+ #ifdef CONFIG_DETECT_SOFTLOCKUP
++extern unsigned long softlockup_get_next_event(void);
+ extern void softlockup_tick(void);
+ extern void spawn_softlockup_task(void);
+ extern void touch_softlockup_watchdog(void);
+ #else
++static inline unsigned long softlockup_get_next_event(void)
++{
++ return MAX_JIFFY_OFFSET;
++}
+ static inline void softlockup_tick(void)
+ {
+ }
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/linux/skbuff.h
+--- a/include/linux/skbuff.h Wed Jul 18 12:23:24 2007 -0300
++++ b/include/linux/skbuff.h Wed Aug 08 16:25:28 2007 -0300
@@ -202,6 +202,8 @@ enum {
* @local_df: allow local fragmentation
* @cloned: Head may be cloned (check refcnt to be sure)
@@ -86034,7 +81790,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
* @pkt_type: Packet class
* @fclone: skbuff clone status
* @ip_summed: Driver fed us an IP checksum
-@@ -284,7 +286,13 @@ struct sk_buff {
+@@ -285,7 +287,13 @@ struct sk_buff {
nfctinfo:3;
__u8 pkt_type:3,
fclone:2,
@@ -86048,37 +81804,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
__be16 protocol;
void (*destructor)(struct sk_buff *skb);
-@@ -347,7 +355,8 @@ static inline struct sk_buff *alloc_skb_
-
- extern struct sk_buff *alloc_skb_from_cache(struct kmem_cache *cp,
- unsigned int size,
-- gfp_t priority);
-+ gfp_t priority,
-+ int fclone);
- extern void kfree_skbmem(struct sk_buff *skb);
- extern struct sk_buff *skb_clone(struct sk_buff *skb,
- gfp_t priority);
-@@ -1088,6 +1097,7 @@ static inline void __skb_queue_purge(str
- kfree_skb(skb);
- }
-
-+#ifndef CONFIG_HAVE_ARCH_DEV_ALLOC_SKB
- /**
- * __dev_alloc_skb - allocate an skbuff for receiving
- * @length: length to allocate
-@@ -1108,6 +1118,9 @@ static inline struct sk_buff *__dev_allo
- skb_reserve(skb, NET_SKB_PAD);
- return skb;
- }
-+#else
-+extern struct sk_buff *__dev_alloc_skb(unsigned int length, gfp_t gfp_mask);
-+#endif
-
- /**
- * dev_alloc_skb - allocate an skbuff for receiving
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/xen/balloon.h source/include/xen/balloon.h
---- /scratch/src/linux-2.6.20.3/include/xen/balloon.h 1970-01-01 01:00:00.000000000 +0100
-+++ source/include/xen/balloon.h 2007-03-20 21:27:02.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/xen/balloon.h
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/include/xen/balloon.h Wed Aug 08 16:25:28 2007 -0300
@@ -0,0 +1,57 @@
+/******************************************************************************
+ * balloon.h
@@ -86137,24 +81865,126 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#define balloon_unlock(__flags) spin_unlock_irqrestore(&balloon_lock, __flags)
+
+#endif /* __ASM_BALLOON_H__ */
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/xen/cpu_hotplug.h source/include/xen/cpu_hotplug.h
---- /scratch/src/linux-2.6.20.3/include/xen/cpu_hotplug.h 1970-01-01 01:00:00.000000000 +0100
-+++ source/include/xen/cpu_hotplug.h 2007-03-20 21:27:02.000000000 +0100
-@@ -0,0 +1,43 @@
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/xen/blkif.h
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/include/xen/blkif.h Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,97 @@
++#ifndef __XEN_BLKIF_H__
++#define __XEN_BLKIF_H__
++
++#include <xen/interface/io/ring.h>
++#include <xen/interface/io/blkif.h>
++#include <xen/interface/io/protocols.h>
++
++/* Not a real protocol. Used to generate ring structs which contain
++ * the elements common to all protocols only. This way we get a
++ * compiler-checkable way to use common struct elements, so we can
++ * avoid using switch(protocol) in a number of places. */
++struct blkif_common_request {
++ char dummy;
++};
++struct blkif_common_response {
++ char dummy;
++};
++
++/* i386 protocol version */
++#pragma pack(push, 4)
++struct blkif_x86_32_request {
++ uint8_t operation; /* BLKIF_OP_??? */
++ uint8_t nr_segments; /* number of segments */
++ blkif_vdev_t handle; /* only for read/write requests */
++ uint64_t id; /* private guest value, echoed in resp */
++ blkif_sector_t sector_number;/* start sector idx on disk (r/w only) */
++ struct blkif_request_segment seg[BLKIF_MAX_SEGMENTS_PER_REQUEST];
++};
++struct blkif_x86_32_response {
++ uint64_t id; /* copied from request */
++ uint8_t operation; /* copied from request */
++ int16_t status; /* BLKIF_RSP_??? */
++};
++typedef struct blkif_x86_32_request blkif_x86_32_request_t;
++typedef struct blkif_x86_32_response blkif_x86_32_response_t;
++#pragma pack(pop)
++
++/* x86_64 protocol version */
++struct blkif_x86_64_request {
++ uint8_t operation; /* BLKIF_OP_??? */
++ uint8_t nr_segments; /* number of segments */
++ blkif_vdev_t handle; /* only for read/write requests */
++ uint64_t __attribute__((__aligned__(8))) id;
++ blkif_sector_t sector_number;/* start sector idx on disk (r/w only) */
++ struct blkif_request_segment seg[BLKIF_MAX_SEGMENTS_PER_REQUEST];
++};
++struct blkif_x86_64_response {
++ uint64_t __attribute__((__aligned__(8))) id;
++ uint8_t operation; /* copied from request */
++ int16_t status; /* BLKIF_RSP_??? */
++};
++typedef struct blkif_x86_64_request blkif_x86_64_request_t;
++typedef struct blkif_x86_64_response blkif_x86_64_response_t;
++
++DEFINE_RING_TYPES(blkif_common, struct blkif_common_request, struct blkif_common_response);
++DEFINE_RING_TYPES(blkif_x86_32, struct blkif_x86_32_request, struct blkif_x86_32_response);
++DEFINE_RING_TYPES(blkif_x86_64, struct blkif_x86_64_request, struct blkif_x86_64_response);
++
++union blkif_back_rings {
++ blkif_back_ring_t native;
++ blkif_common_back_ring_t common;
++ blkif_x86_32_back_ring_t x86_32;
++ blkif_x86_64_back_ring_t x86_64;
++};
++typedef union blkif_back_rings blkif_back_rings_t;
++
++enum blkif_protocol {
++ BLKIF_PROTOCOL_NATIVE = 1,
++ BLKIF_PROTOCOL_X86_32 = 2,
++ BLKIF_PROTOCOL_X86_64 = 3,
++};
++
++static void inline blkif_get_x86_32_req(blkif_request_t *dst, blkif_x86_32_request_t *src)
++{
++ int i;
++ dst->operation = src->operation;
++ dst->nr_segments = src->nr_segments;
++ dst->handle = src->handle;
++ dst->id = src->id;
++ dst->sector_number = src->sector_number;
++ for (i = 0; i < src->nr_segments; i++)
++ dst->seg[i] = src->seg[i];
++}
++
++static void inline blkif_get_x86_64_req(blkif_request_t *dst, blkif_x86_64_request_t *src)
++{
++ int i;
++ dst->operation = src->operation;
++ dst->nr_segments = src->nr_segments;
++ dst->handle = src->handle;
++ dst->id = src->id;
++ dst->sector_number = src->sector_number;
++ for (i = 0; i < src->nr_segments; i++)
++ dst->seg[i] = src->seg[i];
++}
++
++#endif /* __XEN_BLKIF_H__ */
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/xen/cpu_hotplug.h
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/include/xen/cpu_hotplug.h Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,44 @@
+#ifndef __XEN_CPU_HOTPLUG_H__
+#define __XEN_CPU_HOTPLUG_H__
+
+#include <linux/kernel.h>
+#include <linux/cpumask.h>
+
-+#if defined(CONFIG_HOTPLUG_CPU)
-+
-+#if defined(CONFIG_X86)
-+void cpu_initialize_context(unsigned int cpu);
++#if defined(CONFIG_X86) && defined(CONFIG_SMP)
++extern cpumask_t cpu_initialized_map;
++#define cpu_set_initialized(cpu) cpu_set(cpu, cpu_initialized_map)
+#else
-+#define cpu_initialize_context(cpu) ((void)0)
++#define cpu_set_initialized(cpu) ((void)0)
+#endif
+
++#if defined(CONFIG_HOTPLUG_CPU)
++
+int cpu_up_check(unsigned int cpu);
+void init_xenbus_allowed_cpumask(void);
+int smp_suspend(void);
@@ -86184,29 +82014,28 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#endif /* !defined(CONFIG_HOTPLUG_CPU) */
+
+#endif /* __XEN_CPU_HOTPLUG_H__ */
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/xen/driver_util.h source/include/xen/driver_util.h
---- /scratch/src/linux-2.6.20.3/include/xen/driver_util.h 1970-01-01 01:00:00.000000000 +0100
-+++ source/include/xen/driver_util.h 2007-03-20 21:27:02.000000000 +0100
-@@ -0,0 +1,15 @@
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/xen/driver_util.h
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/include/xen/driver_util.h Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,14 @@
+
+#ifndef __ASM_XEN_DRIVER_UTIL_H__
+#define __ASM_XEN_DRIVER_UTIL_H__
+
+#include <linux/vmalloc.h>
++#include <linux/device.h>
+
+/* Allocate/destroy a 'vmalloc' VM area. */
+extern struct vm_struct *alloc_vm_area(unsigned long size);
+extern void free_vm_area(struct vm_struct *area);
+
-+/* Lock an area so that PTEs are accessible in the current address space. */
-+extern void lock_vm_area(struct vm_struct *area);
-+extern void unlock_vm_area(struct vm_struct *area);
++extern struct class *get_xen_class(void);
+
+#endif /* __ASM_XEN_DRIVER_UTIL_H__ */
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/xen/evtchn.h source/include/xen/evtchn.h
---- /scratch/src/linux-2.6.20.3/include/xen/evtchn.h 1970-01-01 01:00:00.000000000 +0100
-+++ source/include/xen/evtchn.h 2007-03-20 21:27:02.000000000 +0100
-@@ -0,0 +1,113 @@
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/xen/evtchn.h
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/include/xen/evtchn.h Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,126 @@
+/******************************************************************************
+ * evtchn.h
+ *
@@ -86260,22 +82089,34 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ * The IRQ argument passed to the callback handler is the same as returned
+ * from the bind call. It may not correspond to a Linux IRQ number.
+ * Returns IRQ or negative errno.
-+ * UNBIND: Takes IRQ to unbind from; automatically closes the event channel.
+ */
-+extern int bind_evtchn_to_irqhandler(
-+ unsigned int evtchn,
++int bind_caller_port_to_irqhandler(
++ unsigned int caller_port,
+ irq_handler_t handler,
+ unsigned long irqflags,
+ const char *devname,
+ void *dev_id);
-+extern int bind_virq_to_irqhandler(
++int bind_listening_port_to_irqhandler(
++ unsigned int remote_domain,
++ irq_handler_t handler,
++ unsigned long irqflags,
++ const char *devname,
++ void *dev_id);
++int bind_interdomain_evtchn_to_irqhandler(
++ unsigned int remote_domain,
++ unsigned int remote_port,
++ irq_handler_t handler,
++ unsigned long irqflags,
++ const char *devname,
++ void *dev_id);
++int bind_virq_to_irqhandler(
+ unsigned int virq,
+ unsigned int cpu,
+ irq_handler_t handler,
+ unsigned long irqflags,
+ const char *devname,
+ void *dev_id);
-+extern int bind_ipi_to_irqhandler(
++int bind_ipi_to_irqhandler(
+ unsigned int ipi,
+ unsigned int cpu,
+ irq_handler_t handler,
@@ -86285,26 +82126,26 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+
+/*
+ * Common unbind function for all event sources. Takes IRQ to unbind from.
-+ * Automatically closes the underlying event channel (even for bindings
-+ * made with bind_evtchn_to_irqhandler()).
++ * Automatically closes the underlying event channel (except for bindings
++ * made with bind_caller_port_to_irqhandler()).
+ */
-+extern void unbind_from_irqhandler(unsigned int irq, void *dev_id);
++void unbind_from_irqhandler(unsigned int irq, void *dev_id);
+
-+extern void irq_resume(void);
++void irq_resume(void);
+
+/* Entry point for notifications into Linux subsystems. */
+asmlinkage void evtchn_do_upcall(struct pt_regs *regs);
+
+/* Entry point for notifications into the userland character device. */
-+extern void evtchn_device_upcall(int port);
++void evtchn_device_upcall(int port);
+
-+extern void mask_evtchn(int port);
-+extern void unmask_evtchn(int port);
++void mask_evtchn(int port);
++void unmask_evtchn(int port);
+
+static inline void clear_evtchn(int port)
+{
+ shared_info_t *s = HYPERVISOR_shared_info;
-+ synch_clear_bit(port, &s->evtchn_pending[0]);
++ synch_clear_bit(port, s->evtchn_pending);
+}
+
+static inline void notify_remote_via_evtchn(int port)
@@ -86314,15 +82155,16 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+}
+
+/*
-+ * Unlike notify_remote_via_evtchn(), this is safe to use across
-+ * save/restore. Notifications on a broken connection are silently dropped.
++ * Use these to access the event channel underlying the IRQ handle returned
++ * by bind_*_to_irqhandler().
+ */
-+extern void notify_remote_via_irq(int irq);
++void notify_remote_via_irq(int irq);
++int irq_to_evtchn_port(int irq);
+
+#endif /* __ASM_EVTCHN_H__ */
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/xen/features.h source/include/xen/features.h
---- /scratch/src/linux-2.6.20.3/include/xen/features.h 1970-01-01 01:00:00.000000000 +0100
-+++ source/include/xen/features.h 2007-03-20 21:27:02.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/xen/features.h
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/include/xen/features.h Wed Aug 08 16:25:28 2007 -0300
@@ -0,0 +1,20 @@
+/******************************************************************************
+ * features.h
@@ -86344,44 +82186,10 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#define xen_feature(flag) (xen_features[flag])
+
+#endif /* __ASM_XEN_FEATURES_H__ */
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/xen/foreign_page.h source/include/xen/foreign_page.h
---- /scratch/src/linux-2.6.20.3/include/xen/foreign_page.h 1970-01-01 01:00:00.000000000 +0100
-+++ source/include/xen/foreign_page.h 2007-03-20 21:27:02.000000000 +0100
-@@ -0,0 +1,30 @@
-+/******************************************************************************
-+ * foreign_page.h
-+ *
-+ * Provide a "foreign" page type, that is owned by a foreign allocator and
-+ * not the normal buddy allocator in page_alloc.c
-+ *
-+ * Copyright (c) 2004, K A Fraser
-+ */
-+
-+#ifndef __ASM_XEN_FOREIGN_PAGE_H__
-+#define __ASM_XEN_FOREIGN_PAGE_H__
-+
-+#define PG_foreign PG_arch_1
-+
-+#define PageForeign(page) test_bit(PG_foreign, &(page)->flags)
-+
-+#define SetPageForeign(page, dtor) do { \
-+ set_bit(PG_foreign, &(page)->flags); \
-+ (page)->mapping = (void *)dtor; \
-+} while (0)
-+
-+#define ClearPageForeign(page) do { \
-+ clear_bit(PG_foreign, &(page)->flags); \
-+ (page)->mapping = NULL; \
-+} while (0)
-+
-+#define PageForeignDestructor(page) \
-+ ( (void (*) (struct page *)) (page)->mapping )
-+
-+#endif /* __ASM_XEN_FOREIGN_PAGE_H__ */
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/xen/gnttab.h source/include/xen/gnttab.h
---- /scratch/src/linux-2.6.20.3/include/xen/gnttab.h 1970-01-01 01:00:00.000000000 +0100
-+++ source/include/xen/gnttab.h 2007-03-20 21:27:02.000000000 +0100
-@@ -0,0 +1,151 @@
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/xen/gnttab.h
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/include/xen/gnttab.h Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,138 @@
+/******************************************************************************
+ * gnttab.h
+ *
@@ -86426,13 +82234,6 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#include <xen/interface/grant_table.h>
+#include <xen/features.h>
+
-+/* NR_GRANT_FRAMES must be less than or equal to that configured in Xen */
-+#ifdef __ia64__
-+#define NR_GRANT_FRAMES 1
-+#else
-+#define NR_GRANT_FRAMES 4
-+#endif
-+
+struct gnttab_free_callback {
+ struct gnttab_free_callback *next;
+ void (*fn)(void *);
@@ -86492,12 +82293,6 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+void gnttab_grant_foreign_transfer_ref(grant_ref_t, domid_t domid,
+ unsigned long pfn);
+
-+#ifdef __ia64__
-+#define gnttab_map_vaddr(map) __va(map.dev_bus_addr)
-+#else
-+#define gnttab_map_vaddr(map) ((void *)(map.host_virt_addr))
-+#endif
-+
+int gnttab_suspend(void);
+int gnttab_resume(void);
+
@@ -86533,16 +82328,15 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+}
+
+#endif /* __ASM_GNTTAB_H__ */
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/xen/hvm.h source/include/xen/hvm.h
---- /scratch/src/linux-2.6.20.3/include/xen/hvm.h 1970-01-01 01:00:00.000000000 +0100
-+++ source/include/xen/hvm.h 2007-03-20 21:27:02.000000000 +0100
-@@ -0,0 +1,24 @@
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/xen/hvm.h
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/include/xen/hvm.h Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,23 @@
+/* Simple wrappers around HVM functions */
+#ifndef XEN_HVM_H__
+#define XEN_HVM_H__
+
+#include <xen/interface/hvm/params.h>
-+#include <asm/hypercall.h>
+
+static inline unsigned long hvm_get_parameter(int idx)
+{
@@ -86561,9 +82355,37 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+}
+
+#endif /* XEN_HVM_H__ */
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/xen/hypervisor_sysfs.h source/include/xen/hypervisor_sysfs.h
---- /scratch/src/linux-2.6.20.3/include/xen/hypervisor_sysfs.h 1970-01-01 01:00:00.000000000 +0100
-+++ source/include/xen/hypervisor_sysfs.h 2007-03-20 21:27:02.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/xen/hypercall.h
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/include/xen/hypercall.h Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,24 @@
++#ifndef __XEN_HYPERCALL_H__
++#define __XEN_HYPERCALL_H__
++
++#include <asm/hypercall.h>
++
++static inline int
++HYPERVISOR_multicall_check(
++ multicall_entry_t *call_list, int nr_calls,
++ const unsigned long *rc_list)
++{
++ int rc = HYPERVISOR_multicall(call_list, nr_calls);
++
++ if (unlikely(rc < 0))
++ return rc;
++ BUG_ON(rc);
++
++ for ( ; nr_calls > 0; --nr_calls, ++call_list)
++ if (unlikely(call_list->result != (rc_list ? *rc_list++ : 0)))
++ return nr_calls;
++
++ return 0;
++}
++
++#endif /* __XEN_HYPERCALL_H__ */
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/xen/hypervisor_sysfs.h
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/include/xen/hypervisor_sysfs.h Wed Aug 08 16:25:28 2007 -0300
@@ -0,0 +1,32 @@
+/*
+ * copyright (c) 2006 IBM Corporation
@@ -86597,10 +82419,52 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+};
+
+#endif /* _HYP_SYSFS_H_ */
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/xen/interface/acm.h source/include/xen/interface/acm.h
---- /scratch/src/linux-2.6.20.3/include/xen/interface/acm.h 1970-01-01 01:00:00.000000000 +0100
-+++ source/include/xen/interface/acm.h 2007-03-20 21:27:02.000000000 +0100
-@@ -0,0 +1,205 @@
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/xen/interface/COPYING
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/include/xen/interface/COPYING Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,38 @@
++XEN NOTICE
++==========
++
++This copyright applies to all files within this subdirectory and its
++subdirectories:
++ include/public/*.h
++ include/public/hvm/*.h
++ include/public/io/*.h
++
++The intention is that these files can be freely copied into the source
++tree of an operating system when porting that OS to run on Xen. Doing
++so does *not* cause the OS to become subject to the terms of the GPL.
++
++All other files in the Xen source distribution are covered by version
++2 of the GNU General Public License except where explicitly stated
++otherwise within individual source files.
++
++ -- Keir Fraser (on behalf of the Xen team)
++
++=====================================================================
++
++Permission is hereby granted, free of charge, to any person obtaining a copy
++of this software and associated documentation files (the "Software"), to
++deal in the Software without restriction, including without limitation the
++rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
++sell copies of the Software, and to permit persons to whom the Software is
++furnished to do so, subject to the following conditions:
++
++The above copyright notice and this permission notice shall be included in
++all copies or substantial portions of the Software.
++
++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
++IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
++FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
++AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
++LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
++FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
++DEALINGS IN THE SOFTWARE.
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/xen/interface/acm.h
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/include/xen/interface/acm.h Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,228 @@
+/*
+ * acm.h: Xen access control module interface defintions
+ *
@@ -86659,6 +82523,19 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#define ACM_ACCESS_DENIED -111
+#define ACM_NULL_POINTER_ERROR -200
+
++/*
++ Error codes reported in when trying to test for a new policy
++ These error codes are reported in an array of tuples where
++ each error code is followed by a parameter describing the error
++ more closely, such as a domain id.
++*/
++#define ACM_EVTCHN_SHARING_VIOLATION 0x100
++#define ACM_GNTTAB_SHARING_VIOLATION 0x101
++#define ACM_DOMAIN_LOOKUP 0x102
++#define ACM_CHWALL_CONFLICT 0x103
++#define ACM_SSIDREF_IN_USE 0x104
++
++
+/* primary policy in lower 4 bits */
+#define ACM_NULL_POLICY 0
+#define ACM_CHINESE_WALL_POLICY 1
@@ -86681,7 +82558,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ * whenever the interpretation of the related
+ * policy's data structure changes
+ */
-+#define ACM_POLICY_VERSION 2
++#define ACM_POLICY_VERSION 3
+#define ACM_CHWALL_VERSION 1
+#define ACM_STE_VERSION 1
+
@@ -86722,6 +82599,14 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+/* each offset in bytes from start of the struct they
+ * are part of */
+
++/* V3 of the policy buffer aded a version structure */
++struct acm_policy_version
++{
++ uint32_t major;
++ uint32_t minor;
++};
++
++
+/* each buffer consists of all policy information for
+ * the respective policy given in the policy code
+ *
@@ -86739,8 +82624,10 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ uint32_t primary_buffer_offset;
+ uint32_t secondary_policy_code;
+ uint32_t secondary_buffer_offset;
++ struct acm_policy_version xml_pol_version; /* add in V3 */
+};
+
++
+struct acm_policy_reference_buffer {
+ uint32_t len;
+};
@@ -86806,10 +82693,10 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ * indent-tabs-mode: nil
+ * End:
+ */
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/xen/interface/acm_ops.h source/include/xen/interface/acm_ops.h
---- /scratch/src/linux-2.6.20.3/include/xen/interface/acm_ops.h 1970-01-01 01:00:00.000000000 +0100
-+++ source/include/xen/interface/acm_ops.h 2007-03-20 21:27:02.000000000 +0100
-@@ -0,0 +1,120 @@
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/xen/interface/acm_ops.h
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/include/xen/interface/acm_ops.h Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,166 @@
+/*
+ * acm_ops.h: Xen access control module hypervisor commands
+ *
@@ -86846,7 +82733,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ * This makes sure that old versions of acm tools will stop working in a
+ * well-defined way (rather than crashing the machine, for instance).
+ */
-+#define ACM_INTERFACE_VERSION 0xAAAA0008
++#define ACM_INTERFACE_VERSION 0xAAAA0009
+
+/************************************************************************/
+
@@ -86862,7 +82749,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+struct acm_setpolicy {
+ /* IN */
+ uint32_t interface_version;
-+ XEN_GUEST_HANDLE(void) pushcache;
++ XEN_GUEST_HANDLE_64(void) pushcache;
+ uint32_t pushcache_size;
+};
+
@@ -86871,7 +82758,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+struct acm_getpolicy {
+ /* IN */
+ uint32_t interface_version;
-+ XEN_GUEST_HANDLE(void) pullcache;
++ XEN_GUEST_HANDLE_64(void) pullcache;
+ uint32_t pullcache_size;
+};
+
@@ -86880,7 +82767,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+struct acm_dumpstats {
+ /* IN */
+ uint32_t interface_version;
-+ XEN_GUEST_HANDLE(void) pullcache;
++ XEN_GUEST_HANDLE_64(void) pullcache;
+ uint32_t pullcache_size;
+};
+
@@ -86896,7 +82783,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ domaintype_t domainid;
+ ssidref_t ssidref;
+ } id;
-+ XEN_GUEST_HANDLE(void) ssidbuf;
++ XEN_GUEST_HANDLE_64(void) ssidbuf;
+ uint32_t ssidbuf_size;
+};
+
@@ -86919,6 +82806,52 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ uint32_t acm_decision;
+};
+
++
++#define ACMOP_chgpolicy 6
++struct acm_change_policy {
++ /* IN */
++ uint32_t interface_version;
++ XEN_GUEST_HANDLE_64(void) policy_pushcache;
++ uint32_t policy_pushcache_size;
++ XEN_GUEST_HANDLE_64(void) del_array;
++ uint32_t delarray_size;
++ XEN_GUEST_HANDLE_64(void) chg_array;
++ uint32_t chgarray_size;
++ /* OUT */
++ /* array with error code */
++ XEN_GUEST_HANDLE_64(void) err_array;
++ uint32_t errarray_size;
++};
++
++#define ACMOP_relabeldoms 7
++struct acm_relabel_doms {
++ /* IN */
++ uint32_t interface_version;
++ XEN_GUEST_HANDLE_64(void) relabel_map;
++ uint32_t relabel_map_size;
++ /* OUT */
++ XEN_GUEST_HANDLE_64(void) err_array;
++ uint32_t errarray_size;
++};
++
++/* future interface to Xen */
++struct xen_acmctl {
++ uint32_t cmd;
++ uint32_t interface_version;
++ union {
++ struct acm_setpolicy setpolicy;
++ struct acm_getpolicy getpolicy;
++ struct acm_dumpstats dumpstats;
++ struct acm_getssid getssid;
++ struct acm_getdecision getdecision;
++ struct acm_change_policy change_policy;
++ struct acm_relabel_doms relabel_doms;
++ } u;
++};
++
++typedef struct xen_acmctl xen_acmctl_t;
++DEFINE_XEN_GUEST_HANDLE(xen_acmctl_t);
++
+#endif /* __XEN_PUBLIC_ACM_OPS_H__ */
+
+/*
@@ -86930,10 +82863,10 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ * indent-tabs-mode: nil
+ * End:
+ */
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/xen/interface/arch-ia64.h source/include/xen/interface/arch-ia64.h
---- /scratch/src/linux-2.6.20.3/include/xen/interface/arch-ia64.h 1970-01-01 01:00:00.000000000 +0100
-+++ source/include/xen/interface/arch-ia64.h 2007-03-20 21:27:02.000000000 +0100
-@@ -0,0 +1,500 @@
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/xen/interface/arch-ia64.h
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/include/xen/interface/arch-ia64.h Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,508 @@
+/******************************************************************************
+ * arch-ia64/hypervisor-if.h
+ *
@@ -86973,6 +82906,8 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+
+#define DEFINE_XEN_GUEST_HANDLE(name) __DEFINE_XEN_GUEST_HANDLE(name, name)
+#define XEN_GUEST_HANDLE(name) __guest_handle_ ## name
++#define XEN_GUEST_HANDLE_64(name) XEN_GUEST_HANDLE(name)
++#define uint64_aligned_t uint64_t
+#define set_xen_guest_handle(hnd, val) do { (hnd).p = val; } while (0)
+#ifdef __XEN_TOOLS__
+#define get_xen_guest_handle(val, hnd) do { val = (hnd).p; } while (0)
@@ -86991,6 +82926,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+
+typedef unsigned long xen_pfn_t;
+DEFINE_XEN_GUEST_HANDLE(xen_pfn_t);
++#define PRI_xen_pfn "lx"
+#endif
+
+/* Arch specific VIRQs definition */
@@ -87024,11 +82960,14 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#define IO_PAGE_SIZE PAGE_SIZE
+
+#define STORE_PAGE_START (IO_PAGE_START + IO_PAGE_SIZE)
-+#define STORE_PAGE_SIZE PAGE_SIZE
++#define STORE_PAGE_SIZE PAGE_SIZE
+
-+#define BUFFER_IO_PAGE_START (STORE_PAGE_START+PAGE_SIZE)
++#define BUFFER_IO_PAGE_START (STORE_PAGE_START+STORE_PAGE_SIZE)
+#define BUFFER_IO_PAGE_SIZE PAGE_SIZE
+
++#define BUFFER_PIO_PAGE_START (BUFFER_IO_PAGE_START+BUFFER_IO_PAGE_SIZE)
++#define BUFFER_PIO_PAGE_SIZE PAGE_SIZE
++
+#define IO_SAPIC_START 0xfec00000UL
+#define IO_SAPIC_SIZE 0x100000
+
@@ -87219,10 +83158,11 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ */
+ unsigned char *interrupt_mask_addr;
+ int pending_interruption;
-+ int incomplete_regframe; // see SDM vol2 6.8
+ unsigned char vpsr_pp;
-+ unsigned char reserved5_2[7];
-+ unsigned long reserved5_1[3];
++ unsigned char vpsr_dfh;
++ unsigned char hpsr_dfh;
++ unsigned char hpsr_mfh;
++ unsigned long reserved5_1[4];
+ int metaphysical_mode; // 1 = use metaphys mapping, 0 = use virtual
+ int banknum; // 0 or 1, which virtual register bank is active
+ unsigned long rrs[8]; // region registers
@@ -87366,35 +83306,36 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#define XMAPPEDREGS_OFS XSI_SIZE
+
+/* Hyperprivops. */
-+#define HYPERPRIVOP_RFI 0x1
-+#define HYPERPRIVOP_RSM_DT 0x2
-+#define HYPERPRIVOP_SSM_DT 0x3
-+#define HYPERPRIVOP_COVER 0x4
-+#define HYPERPRIVOP_ITC_D 0x5
-+#define HYPERPRIVOP_ITC_I 0x6
-+#define HYPERPRIVOP_SSM_I 0x7
-+#define HYPERPRIVOP_GET_IVR 0x8
-+#define HYPERPRIVOP_GET_TPR 0x9
-+#define HYPERPRIVOP_SET_TPR 0xa
-+#define HYPERPRIVOP_EOI 0xb
-+#define HYPERPRIVOP_SET_ITM 0xc
-+#define HYPERPRIVOP_THASH 0xd
-+#define HYPERPRIVOP_PTC_GA 0xe
-+#define HYPERPRIVOP_ITR_D 0xf
-+#define HYPERPRIVOP_GET_RR 0x10
-+#define HYPERPRIVOP_SET_RR 0x11
-+#define HYPERPRIVOP_SET_KR 0x12
-+#define HYPERPRIVOP_FC 0x13
-+#define HYPERPRIVOP_GET_CPUID 0x14
-+#define HYPERPRIVOP_GET_PMD 0x15
-+#define HYPERPRIVOP_GET_EFLAG 0x16
-+#define HYPERPRIVOP_SET_EFLAG 0x17
-+#define HYPERPRIVOP_RSM_BE 0x18
-+#define HYPERPRIVOP_GET_PSR 0x19
-+#define HYPERPRIVOP_MAX 0x19
++#define HYPERPRIVOP_START 0x1
++#define HYPERPRIVOP_RFI (HYPERPRIVOP_START + 0x0)
++#define HYPERPRIVOP_RSM_DT (HYPERPRIVOP_START + 0x1)
++#define HYPERPRIVOP_SSM_DT (HYPERPRIVOP_START + 0x2)
++#define HYPERPRIVOP_COVER (HYPERPRIVOP_START + 0x3)
++#define HYPERPRIVOP_ITC_D (HYPERPRIVOP_START + 0x4)
++#define HYPERPRIVOP_ITC_I (HYPERPRIVOP_START + 0x5)
++#define HYPERPRIVOP_SSM_I (HYPERPRIVOP_START + 0x6)
++#define HYPERPRIVOP_GET_IVR (HYPERPRIVOP_START + 0x7)
++#define HYPERPRIVOP_GET_TPR (HYPERPRIVOP_START + 0x8)
++#define HYPERPRIVOP_SET_TPR (HYPERPRIVOP_START + 0x9)
++#define HYPERPRIVOP_EOI (HYPERPRIVOP_START + 0xa)
++#define HYPERPRIVOP_SET_ITM (HYPERPRIVOP_START + 0xb)
++#define HYPERPRIVOP_THASH (HYPERPRIVOP_START + 0xc)
++#define HYPERPRIVOP_PTC_GA (HYPERPRIVOP_START + 0xd)
++#define HYPERPRIVOP_ITR_D (HYPERPRIVOP_START + 0xe)
++#define HYPERPRIVOP_GET_RR (HYPERPRIVOP_START + 0xf)
++#define HYPERPRIVOP_SET_RR (HYPERPRIVOP_START + 0x10)
++#define HYPERPRIVOP_SET_KR (HYPERPRIVOP_START + 0x11)
++#define HYPERPRIVOP_FC (HYPERPRIVOP_START + 0x12)
++#define HYPERPRIVOP_GET_CPUID (HYPERPRIVOP_START + 0x13)
++#define HYPERPRIVOP_GET_PMD (HYPERPRIVOP_START + 0x14)
++#define HYPERPRIVOP_GET_EFLAG (HYPERPRIVOP_START + 0x15)
++#define HYPERPRIVOP_SET_EFLAG (HYPERPRIVOP_START + 0x16)
++#define HYPERPRIVOP_RSM_BE (HYPERPRIVOP_START + 0x17)
++#define HYPERPRIVOP_GET_PSR (HYPERPRIVOP_START + 0x18)
++#define HYPERPRIVOP_MAX (0x19)
+
+/* Fast and light hypercalls. */
-+#define __HYPERVISOR_ia64_fast_eoi 0x0200
++#define __HYPERVISOR_ia64_fast_eoi __HYPERVISOR_arch_1
+
+/* Xencomm macros. */
+#define XENCOMM_INLINE_MASK 0xf800000000000000UL
@@ -87434,10 +83375,10 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ * indent-tabs-mode: nil
+ * End:
+ */
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/xen/interface/arch-powerpc.h source/include/xen/interface/arch-powerpc.h
---- /scratch/src/linux-2.6.20.3/include/xen/interface/arch-powerpc.h 1970-01-01 01:00:00.000000000 +0100
-+++ source/include/xen/interface/arch-powerpc.h 2007-03-20 21:27:02.000000000 +0100
-@@ -0,0 +1,121 @@
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/xen/interface/arch-powerpc.h
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/include/xen/interface/arch-powerpc.h Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,125 @@
+/*
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
@@ -87496,6 +83437,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+
+typedef unsigned long long xen_pfn_t;
+DEFINE_XEN_GUEST_HANDLE(xen_pfn_t);
++#define PRI_xen_pfn "llx"
+#endif
+
+/*
@@ -87517,8 +83459,8 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+
+typedef uint64_t xen_ulong_t;
+
-+/* User-accessible registers: need to be saved/restored for every nested Xen
-+ * invocation. */
++/* User-accessible registers: nost of these need to be saved/restored
++ * for every nested Xen invocation. */
+struct cpu_user_regs
+{
+ uint64_t gprs[32];
@@ -87528,10 +83470,13 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ uint64_t srr1;
+ uint64_t pc;
+ uint64_t msr;
-+ uint64_t fpscr;
++ uint64_t fpscr; /* XXX Is this necessary */
+ uint64_t xer;
-+ uint64_t hid4;
++ uint64_t hid4; /* debug only */
++ uint64_t dar; /* debug only */
++ uint32_t dsisr; /* debug only */
+ uint32_t cr;
++ uint32_t __pad; /* good spot for another 32bit reg */
+ uint32_t entry_vector;
+};
+typedef struct cpu_user_regs cpu_user_regs_t;
@@ -87548,7 +83493,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+DEFINE_XEN_GUEST_HANDLE(vcpu_guest_context_t);
+
+struct arch_shared_info {
-+ uint64_t pad[32];
++ uint64_t boot_timebase;
+};
+
+struct arch_vcpu_info {
@@ -87559,204 +83504,10 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#endif
+
+#endif
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/xen/interface/arch-x86/xen.h source/include/xen/interface/arch-x86/xen.h
---- /scratch/src/linux-2.6.20.3/include/xen/interface/arch-x86/xen.h 1970-01-01 01:00:00.000000000 +0100
-+++ source/include/xen/interface/arch-x86/xen.h 2007-03-20 21:27:02.000000000 +0100
-@@ -0,0 +1,190 @@
-+/******************************************************************************
-+ * arch-x86/xen.h
-+ *
-+ * Guest OS interface to x86 Xen.
-+ *
-+ * Permission is hereby granted, free of charge, to any person obtaining a copy
-+ * of this software and associated documentation files (the "Software"), to
-+ * deal in the Software without restriction, including without limitation the
-+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-+ * sell copies of the Software, and to permit persons to whom the Software is
-+ * furnished to do so, subject to the following conditions:
-+ *
-+ * The above copyright notice and this permission notice shall be included in
-+ * all copies or substantial portions of the Software.
-+ *
-+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-+ * DEALINGS IN THE SOFTWARE.
-+ *
-+ * Copyright (c) 2004-2006, K A Fraser
-+ */
-+
-+#ifndef __XEN_PUBLIC_ARCH_X86_XEN_H__
-+#define __XEN_PUBLIC_ARCH_X86_XEN_H__
-+
-+/* Structural guest handles introduced in 0x00030201. */
-+#if __XEN_INTERFACE_VERSION__ >= 0x00030201
-+#define __DEFINE_XEN_GUEST_HANDLE(name, type) \
-+ typedef struct { type *p; } __guest_handle_ ## name
-+#else
-+#define __DEFINE_XEN_GUEST_HANDLE(name, type) \
-+ typedef type * __guest_handle_ ## name
-+#endif
-+
-+#define DEFINE_XEN_GUEST_HANDLE(name) __DEFINE_XEN_GUEST_HANDLE(name, name)
-+#define XEN_GUEST_HANDLE(name) __guest_handle_ ## name
-+#define set_xen_guest_handle(hnd, val) do { (hnd).p = val; } while (0)
-+#ifdef __XEN_TOOLS__
-+#define get_xen_guest_handle(val, hnd) do { val = (hnd).p; } while (0)
-+#endif
-+
-+#ifndef __ASSEMBLY__
-+/* Guest handles for primitive C types. */
-+__DEFINE_XEN_GUEST_HANDLE(uchar, unsigned char);
-+__DEFINE_XEN_GUEST_HANDLE(uint, unsigned int);
-+__DEFINE_XEN_GUEST_HANDLE(ulong, unsigned long);
-+DEFINE_XEN_GUEST_HANDLE(char);
-+DEFINE_XEN_GUEST_HANDLE(int);
-+DEFINE_XEN_GUEST_HANDLE(long);
-+DEFINE_XEN_GUEST_HANDLE(void);
-+
-+typedef unsigned long xen_pfn_t;
-+DEFINE_XEN_GUEST_HANDLE(xen_pfn_t);
-+#endif
-+
-+#if defined(__i386__)
-+#include "xen-x86_32.h"
-+#elif defined(__x86_64__)
-+#include "xen-x86_64.h"
-+#endif
-+
-+/*
-+ * SEGMENT DESCRIPTOR TABLES
-+ */
-+/*
-+ * A number of GDT entries are reserved by Xen. These are not situated at the
-+ * start of the GDT because some stupid OSes export hard-coded selector values
-+ * in their ABI. These hard-coded values are always near the start of the GDT,
-+ * so Xen places itself out of the way, at the far end of the GDT.
-+ */
-+#define FIRST_RESERVED_GDT_PAGE 14
-+#define FIRST_RESERVED_GDT_BYTE (FIRST_RESERVED_GDT_PAGE * 4096)
-+#define FIRST_RESERVED_GDT_ENTRY (FIRST_RESERVED_GDT_BYTE / 8)
-+
-+/* Maximum number of virtual CPUs in multi-processor guests. */
-+#define MAX_VIRT_CPUS 32
-+
-+#ifndef __ASSEMBLY__
-+
-+typedef unsigned long xen_ulong_t;
-+
-+/*
-+ * Send an array of these to HYPERVISOR_set_trap_table().
-+ * The privilege level specifies which modes may enter a trap via a software
-+ * interrupt. On x86/64, since rings 1 and 2 are unavailable, we allocate
-+ * privilege levels as follows:
-+ * Level == 0: Noone may enter
-+ * Level == 1: Kernel may enter
-+ * Level == 2: Kernel may enter
-+ * Level == 3: Everyone may enter
-+ */
-+#define TI_GET_DPL(_ti) ((_ti)->flags & 3)
-+#define TI_GET_IF(_ti) ((_ti)->flags & 4)
-+#define TI_SET_DPL(_ti,_dpl) ((_ti)->flags |= (_dpl))
-+#define TI_SET_IF(_ti,_if) ((_ti)->flags |= ((!!(_if))<<2))
-+struct trap_info {
-+ uint8_t vector; /* exception vector */
-+ uint8_t flags; /* 0-3: privilege level; 4: clear event enable? */
-+ uint16_t cs; /* code selector */
-+ unsigned long address; /* code offset */
-+};
-+typedef struct trap_info trap_info_t;
-+DEFINE_XEN_GUEST_HANDLE(trap_info_t);
-+
-+typedef uint64_t tsc_timestamp_t; /* RDTSC timestamp */
-+
-+/*
-+ * The following is all CPU context. Note that the fpu_ctxt block is filled
-+ * in by FXSAVE if the CPU has feature FXSR; otherwise FSAVE is used.
-+ */
-+struct vcpu_guest_context {
-+ /* FPU registers come first so they can be aligned for FXSAVE/FXRSTOR. */
-+ struct { char x[512]; } fpu_ctxt; /* User-level FPU registers */
-+#define VGCF_I387_VALID (1<<0)
-+#define VGCF_IN_KERNEL (1<<2)
-+#define _VGCF_i387_valid 0
-+#define VGCF_i387_valid (1<<_VGCF_i387_valid)
-+#define _VGCF_in_kernel 2
-+#define VGCF_in_kernel (1<<_VGCF_in_kernel)
-+#define _VGCF_failsafe_disables_events 3
-+#define VGCF_failsafe_disables_events (1<<_VGCF_failsafe_disables_events)
-+#define _VGCF_syscall_disables_events 4
-+#define VGCF_syscall_disables_events (1<<_VGCF_syscall_disables_events)
-+ unsigned long flags; /* VGCF_* flags */
-+ struct cpu_user_regs user_regs; /* User-level CPU registers */
-+ struct trap_info trap_ctxt[256]; /* Virtual IDT */
-+ unsigned long ldt_base, ldt_ents; /* LDT (linear address, # ents) */
-+ unsigned long gdt_frames[16], gdt_ents; /* GDT (machine frames, # ents) */
-+ unsigned long kernel_ss, kernel_sp; /* Virtual TSS (only SS1/SP1) */
-+ unsigned long ctrlreg[8]; /* CR0-CR7 (control registers) */
-+ unsigned long debugreg[8]; /* DB0-DB7 (debug registers) */
-+#ifdef __i386__
-+ unsigned long event_callback_cs; /* CS:EIP of event callback */
-+ unsigned long event_callback_eip;
-+ unsigned long failsafe_callback_cs; /* CS:EIP of failsafe callback */
-+ unsigned long failsafe_callback_eip;
-+#else
-+ unsigned long event_callback_eip;
-+ unsigned long failsafe_callback_eip;
-+ unsigned long syscall_callback_eip;
-+#endif
-+ unsigned long vm_assist; /* VMASST_TYPE_* bitmap */
-+#ifdef __x86_64__
-+ /* Segment base addresses. */
-+ uint64_t fs_base;
-+ uint64_t gs_base_kernel;
-+ uint64_t gs_base_user;
-+#endif
-+};
-+typedef struct vcpu_guest_context vcpu_guest_context_t;
-+DEFINE_XEN_GUEST_HANDLE(vcpu_guest_context_t);
-+
-+struct arch_shared_info {
-+ unsigned long max_pfn; /* max pfn that appears in table */
-+ /* Frame containing list of mfns containing list of mfns containing p2m. */
-+ xen_pfn_t pfn_to_mfn_frame_list_list;
-+ unsigned long nmi_reason;
-+ uint64_t pad[32];
-+};
-+typedef struct arch_shared_info arch_shared_info_t;
-+
-+#endif /* !__ASSEMBLY__ */
-+
-+/*
-+ * Prefix forces emulation of some non-trapping instructions.
-+ * Currently only CPUID.
-+ */
-+#ifdef __ASSEMBLY__
-+#define XEN_EMULATE_PREFIX .byte 0x0f,0x0b,0x78,0x65,0x6e ;
-+#define XEN_CPUID XEN_EMULATE_PREFIX cpuid
-+#else
-+#define XEN_EMULATE_PREFIX ".byte 0x0f,0x0b,0x78,0x65,0x6e ; "
-+#define XEN_CPUID XEN_EMULATE_PREFIX "cpuid"
-+#endif
-+
-+#endif /* __XEN_PUBLIC_ARCH_X86_XEN_H__ */
-+
-+/*
-+ * Local variables:
-+ * mode: C
-+ * c-set-style: "BSD"
-+ * c-basic-offset: 4
-+ * tab-width: 4
-+ * indent-tabs-mode: nil
-+ * End:
-+ */
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/xen/interface/arch-x86/xen-x86_32.h source/include/xen/interface/arch-x86/xen-x86_32.h
---- /scratch/src/linux-2.6.20.3/include/xen/interface/arch-x86/xen-x86_32.h 1970-01-01 01:00:00.000000000 +0100
-+++ source/include/xen/interface/arch-x86/xen-x86_32.h 2007-03-20 21:27:02.000000000 +0100
-@@ -0,0 +1,151 @@
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/xen/interface/arch-x86/xen-x86_32.h
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/include/xen/interface/arch-x86/xen-x86_32.h Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,168 @@
+/******************************************************************************
+ * xen-x86_32.h
+ *
@@ -87780,7 +83531,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
-+ * Copyright (c) 2004-2006, K A Fraser
++ * Copyright (c) 2004-2007, K A Fraser
+ */
+
+#ifndef __XEN_PUBLIC_ARCH_X86_XEN_X86_32_H__
@@ -87848,6 +83599,23 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#define machine_to_phys_mapping ((unsigned long *)MACH2PHYS_VIRT_START)
+#endif
+
++/* 32-/64-bit invariability for control interfaces (domctl/sysctl). */
++#if defined(__XEN__) || defined(__XEN_TOOLS__)
++#undef __DEFINE_XEN_GUEST_HANDLE
++#define __DEFINE_XEN_GUEST_HANDLE(name, type) \
++ typedef struct { type *p; } \
++ __guest_handle_ ## name; \
++ typedef struct { union { type *p; uint64_aligned_t q; }; } \
++ __guest_handle_64_ ## name
++#undef set_xen_guest_handle
++#define set_xen_guest_handle(hnd, val) \
++ do { if ( sizeof(hnd) == 8 ) *(uint64_t *)&(hnd) = 0; \
++ (hnd).p = val; \
++ } while ( 0 )
++#define uint64_aligned_t uint64_t __attribute__((aligned(8)))
++#define XEN_GUEST_HANDLE_64(name) __guest_handle_64_ ## name
++#endif
++
+#ifndef __ASSEMBLY__
+
+struct cpu_user_regs {
@@ -87908,10 +83676,10 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ * indent-tabs-mode: nil
+ * End:
+ */
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/xen/interface/arch-x86/xen-x86_64.h source/include/xen/interface/arch-x86/xen-x86_64.h
---- /scratch/src/linux-2.6.20.3/include/xen/interface/arch-x86/xen-x86_64.h 1970-01-01 01:00:00.000000000 +0100
-+++ source/include/xen/interface/arch-x86/xen-x86_64.h 2007-03-20 21:27:02.000000000 +0100
-@@ -0,0 +1,208 @@
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/xen/interface/arch-x86/xen-x86_64.h
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/include/xen/interface/arch-x86/xen-x86_64.h Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,211 @@
+/******************************************************************************
+ * xen-x86_64.h
+ *
@@ -88055,7 +83823,10 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+
+#ifdef __GNUC__
+/* Anonymous union includes both 32- and 64-bit names (e.g., eax/rax). */
-+#define __DECL_REG(name) union { uint64_t r ## name, e ## name; }
++#define __DECL_REG(name) union { \
++ uint64_t r ## name, e ## name; \
++ uint32_t _e ## name; \
++}
+#else
+/* Non-gcc sources must always use the proper 64-bit name (e.g., rax). */
+#define __DECL_REG(name) uint64_t r ## name
@@ -88120,9 +83891,217 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ * indent-tabs-mode: nil
+ * End:
+ */
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/xen/interface/arch-x86_32.h source/include/xen/interface/arch-x86_32.h
---- /scratch/src/linux-2.6.20.3/include/xen/interface/arch-x86_32.h 1970-01-01 01:00:00.000000000 +0100
-+++ source/include/xen/interface/arch-x86_32.h 2007-03-20 21:27:02.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/xen/interface/arch-x86/xen.h
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/include/xen/interface/arch-x86/xen.h Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,204 @@
++/******************************************************************************
++ * arch-x86/xen.h
++ *
++ * Guest OS interface to x86 Xen.
++ *
++ * Permission is hereby granted, free of charge, to any person obtaining a copy
++ * of this software and associated documentation files (the "Software"), to
++ * deal in the Software without restriction, including without limitation the
++ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
++ * sell copies of the Software, and to permit persons to whom the Software is
++ * furnished to do so, subject to the following conditions:
++ *
++ * The above copyright notice and this permission notice shall be included in
++ * all copies or substantial portions of the Software.
++ *
++ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
++ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
++ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
++ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
++ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
++ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
++ * DEALINGS IN THE SOFTWARE.
++ *
++ * Copyright (c) 2004-2006, K A Fraser
++ */
++
++#ifndef __XEN_PUBLIC_ARCH_X86_XEN_H__
++#define __XEN_PUBLIC_ARCH_X86_XEN_H__
++
++/* Structural guest handles introduced in 0x00030201. */
++#if __XEN_INTERFACE_VERSION__ >= 0x00030201
++#define __DEFINE_XEN_GUEST_HANDLE(name, type) \
++ typedef struct { type *p; } __guest_handle_ ## name
++#else
++#define __DEFINE_XEN_GUEST_HANDLE(name, type) \
++ typedef type * __guest_handle_ ## name
++#endif
++
++#define DEFINE_XEN_GUEST_HANDLE(name) __DEFINE_XEN_GUEST_HANDLE(name, name)
++#define XEN_GUEST_HANDLE(name) __guest_handle_ ## name
++#define set_xen_guest_handle(hnd, val) do { (hnd).p = val; } while (0)
++#ifdef __XEN_TOOLS__
++#define get_xen_guest_handle(val, hnd) do { val = (hnd).p; } while (0)
++#endif
++
++#if defined(__i386__)
++#include "xen-x86_32.h"
++#elif defined(__x86_64__)
++#include "xen-x86_64.h"
++#endif
++
++#ifndef __ASSEMBLY__
++/* Guest handles for primitive C types. */
++__DEFINE_XEN_GUEST_HANDLE(uchar, unsigned char);
++__DEFINE_XEN_GUEST_HANDLE(uint, unsigned int);
++__DEFINE_XEN_GUEST_HANDLE(ulong, unsigned long);
++DEFINE_XEN_GUEST_HANDLE(char);
++DEFINE_XEN_GUEST_HANDLE(int);
++DEFINE_XEN_GUEST_HANDLE(long);
++DEFINE_XEN_GUEST_HANDLE(void);
++
++typedef unsigned long xen_pfn_t;
++DEFINE_XEN_GUEST_HANDLE(xen_pfn_t);
++#define PRI_xen_pfn "lx"
++#endif
++
++/*
++ * SEGMENT DESCRIPTOR TABLES
++ */
++/*
++ * A number of GDT entries are reserved by Xen. These are not situated at the
++ * start of the GDT because some stupid OSes export hard-coded selector values
++ * in their ABI. These hard-coded values are always near the start of the GDT,
++ * so Xen places itself out of the way, at the far end of the GDT.
++ */
++#define FIRST_RESERVED_GDT_PAGE 14
++#define FIRST_RESERVED_GDT_BYTE (FIRST_RESERVED_GDT_PAGE * 4096)
++#define FIRST_RESERVED_GDT_ENTRY (FIRST_RESERVED_GDT_BYTE / 8)
++
++/* Maximum number of virtual CPUs in multi-processor guests. */
++#define MAX_VIRT_CPUS 32
++
++#ifndef __ASSEMBLY__
++
++typedef unsigned long xen_ulong_t;
++
++/*
++ * Send an array of these to HYPERVISOR_set_trap_table().
++ * The privilege level specifies which modes may enter a trap via a software
++ * interrupt. On x86/64, since rings 1 and 2 are unavailable, we allocate
++ * privilege levels as follows:
++ * Level == 0: Noone may enter
++ * Level == 1: Kernel may enter
++ * Level == 2: Kernel may enter
++ * Level == 3: Everyone may enter
++ */
++#define TI_GET_DPL(_ti) ((_ti)->flags & 3)
++#define TI_GET_IF(_ti) ((_ti)->flags & 4)
++#define TI_SET_DPL(_ti,_dpl) ((_ti)->flags |= (_dpl))
++#define TI_SET_IF(_ti,_if) ((_ti)->flags |= ((!!(_if))<<2))
++struct trap_info {
++ uint8_t vector; /* exception vector */
++ uint8_t flags; /* 0-3: privilege level; 4: clear event enable? */
++ uint16_t cs; /* code selector */
++ unsigned long address; /* code offset */
++};
++typedef struct trap_info trap_info_t;
++DEFINE_XEN_GUEST_HANDLE(trap_info_t);
++
++typedef uint64_t tsc_timestamp_t; /* RDTSC timestamp */
++
++/*
++ * The following is all CPU context. Note that the fpu_ctxt block is filled
++ * in by FXSAVE if the CPU has feature FXSR; otherwise FSAVE is used.
++ */
++struct vcpu_guest_context {
++ /* FPU registers come first so they can be aligned for FXSAVE/FXRSTOR. */
++ struct { char x[512]; } fpu_ctxt; /* User-level FPU registers */
++#define VGCF_I387_VALID (1<<0)
++#define VGCF_IN_KERNEL (1<<2)
++#define _VGCF_i387_valid 0
++#define VGCF_i387_valid (1<<_VGCF_i387_valid)
++#define _VGCF_in_kernel 2
++#define VGCF_in_kernel (1<<_VGCF_in_kernel)
++#define _VGCF_failsafe_disables_events 3
++#define VGCF_failsafe_disables_events (1<<_VGCF_failsafe_disables_events)
++#define _VGCF_syscall_disables_events 4
++#define VGCF_syscall_disables_events (1<<_VGCF_syscall_disables_events)
++#define _VGCF_online 5
++#define VGCF_online (1<<_VGCF_online)
++ unsigned long flags; /* VGCF_* flags */
++ struct cpu_user_regs user_regs; /* User-level CPU registers */
++ struct trap_info trap_ctxt[256]; /* Virtual IDT */
++ unsigned long ldt_base, ldt_ents; /* LDT (linear address, # ents) */
++ unsigned long gdt_frames[16], gdt_ents; /* GDT (machine frames, # ents) */
++ unsigned long kernel_ss, kernel_sp; /* Virtual TSS (only SS1/SP1) */
++ /* NB. User pagetable on x86/64 is placed in ctrlreg[1]. */
++ unsigned long ctrlreg[8]; /* CR0-CR7 (control registers) */
++ unsigned long debugreg[8]; /* DB0-DB7 (debug registers) */
++#ifdef __i386__
++ unsigned long event_callback_cs; /* CS:EIP of event callback */
++ unsigned long event_callback_eip;
++ unsigned long failsafe_callback_cs; /* CS:EIP of failsafe callback */
++ unsigned long failsafe_callback_eip;
++#else
++ unsigned long event_callback_eip;
++ unsigned long failsafe_callback_eip;
++#ifdef __XEN__
++ union {
++ unsigned long syscall_callback_eip;
++ struct {
++ unsigned int event_callback_cs; /* compat CS of event cb */
++ unsigned int failsafe_callback_cs; /* compat CS of failsafe cb */
++ };
++ };
++#else
++ unsigned long syscall_callback_eip;
++#endif
++#endif
++ unsigned long vm_assist; /* VMASST_TYPE_* bitmap */
++#ifdef __x86_64__
++ /* Segment base addresses. */
++ uint64_t fs_base;
++ uint64_t gs_base_kernel;
++ uint64_t gs_base_user;
++#endif
++};
++typedef struct vcpu_guest_context vcpu_guest_context_t;
++DEFINE_XEN_GUEST_HANDLE(vcpu_guest_context_t);
++
++struct arch_shared_info {
++ unsigned long max_pfn; /* max pfn that appears in table */
++ /* Frame containing list of mfns containing list of mfns containing p2m. */
++ xen_pfn_t pfn_to_mfn_frame_list_list;
++ unsigned long nmi_reason;
++ uint64_t pad[32];
++};
++typedef struct arch_shared_info arch_shared_info_t;
++
++#endif /* !__ASSEMBLY__ */
++
++/*
++ * Prefix forces emulation of some non-trapping instructions.
++ * Currently only CPUID.
++ */
++#ifdef __ASSEMBLY__
++#define XEN_EMULATE_PREFIX .byte 0x0f,0x0b,0x78,0x65,0x6e ;
++#define XEN_CPUID XEN_EMULATE_PREFIX cpuid
++#else
++#define XEN_EMULATE_PREFIX ".byte 0x0f,0x0b,0x78,0x65,0x6e ; "
++#define XEN_CPUID XEN_EMULATE_PREFIX "cpuid"
++#endif
++
++#endif /* __XEN_PUBLIC_ARCH_X86_XEN_H__ */
++
++/*
++ * Local variables:
++ * mode: C
++ * c-set-style: "BSD"
++ * c-basic-offset: 4
++ * tab-width: 4
++ * indent-tabs-mode: nil
++ * End:
++ */
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/xen/interface/arch-x86_32.h
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/include/xen/interface/arch-x86_32.h Wed Aug 08 16:25:28 2007 -0300
@@ -0,0 +1,27 @@
+/******************************************************************************
+ * arch-x86_32.h
@@ -88151,9 +84130,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ */
+
+#include "arch-x86/xen.h"
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/xen/interface/arch-x86_64.h source/include/xen/interface/arch-x86_64.h
---- /scratch/src/linux-2.6.20.3/include/xen/interface/arch-x86_64.h 1970-01-01 01:00:00.000000000 +0100
-+++ source/include/xen/interface/arch-x86_64.h 2007-03-20 21:27:02.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/xen/interface/arch-x86_64.h
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/include/xen/interface/arch-x86_64.h Wed Aug 08 16:25:28 2007 -0300
@@ -0,0 +1,27 @@
+/******************************************************************************
+ * arch-x86_64.h
@@ -88182,9 +84161,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ */
+
+#include "arch-x86/xen.h"
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/xen/interface/callback.h source/include/xen/interface/callback.h
---- /scratch/src/linux-2.6.20.3/include/xen/interface/callback.h 1970-01-01 01:00:00.000000000 +0100
-+++ source/include/xen/interface/callback.h 2007-03-20 21:27:02.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/xen/interface/callback.h
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/include/xen/interface/callback.h Wed Aug 08 16:25:28 2007 -0300
@@ -0,0 +1,92 @@
+/******************************************************************************
+ * callback.h
@@ -88278,9 +84257,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ * indent-tabs-mode: nil
+ * End:
+ */
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/xen/interface/dom0_ops.h source/include/xen/interface/dom0_ops.h
---- /scratch/src/linux-2.6.20.3/include/xen/interface/dom0_ops.h 1970-01-01 01:00:00.000000000 +0100
-+++ source/include/xen/interface/dom0_ops.h 2007-03-20 21:27:02.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/xen/interface/dom0_ops.h
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/include/xen/interface/dom0_ops.h Wed Aug 08 16:25:28 2007 -0300
@@ -0,0 +1,120 @@
+/******************************************************************************
+ * dom0_ops.h
@@ -88402,10 +84381,10 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ * indent-tabs-mode: nil
+ * End:
+ */
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/xen/interface/domctl.h source/include/xen/interface/domctl.h
---- /scratch/src/linux-2.6.20.3/include/xen/interface/domctl.h 1970-01-01 01:00:00.000000000 +0100
-+++ source/include/xen/interface/domctl.h 2007-03-20 21:27:02.000000000 +0100
-@@ -0,0 +1,437 @@
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/xen/interface/domctl.h
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/include/xen/interface/domctl.h Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,478 @@
+/******************************************************************************
+ * domctl.h
+ *
@@ -88442,10 +84421,10 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+
+#include "xen.h"
+
-+#define XEN_DOMCTL_INTERFACE_VERSION 0x00000004
++#define XEN_DOMCTL_INTERFACE_VERSION 0x00000005
+
+struct xenctl_cpumap {
-+ XEN_GUEST_HANDLE(uint8_t) bitmap;
++ XEN_GUEST_HANDLE_64(uint8_t) bitmap;
+ uint32_t nr_cpus;
+};
+
@@ -88469,6 +84448,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#define XEN_DOMCTL_destroydomain 2
+#define XEN_DOMCTL_pausedomain 3
+#define XEN_DOMCTL_unpausedomain 4
++#define XEN_DOMCTL_resumedomain 27
+
+#define XEN_DOMCTL_getdomaininfo 5
+struct xen_domctl_getdomaininfo {
@@ -88499,10 +84479,10 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#define XEN_DOMINF_shutdownmask 255
+#define XEN_DOMINF_shutdownshift 16
+ uint32_t flags; /* XEN_DOMINF_* */
-+ uint64_t tot_pages;
-+ uint64_t max_pages;
-+ uint64_t shared_info_frame; /* GMFN of shared_info struct */
-+ uint64_t cpu_time;
++ uint64_aligned_t tot_pages;
++ uint64_aligned_t max_pages;
++ uint64_aligned_t shared_info_frame; /* GMFN of shared_info struct */
++ uint64_aligned_t cpu_time;
+ uint32_t nr_online_vcpus; /* Number of VCPUs currently online. */
+ uint32_t max_vcpu_id; /* Maximum VCPUID in use by this domain. */
+ uint32_t ssidref;
@@ -88516,12 +84496,12 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+struct xen_domctl_getmemlist {
+ /* IN variables. */
+ /* Max entries to write to output buffer. */
-+ uint64_t max_pfns;
++ uint64_aligned_t max_pfns;
+ /* Start index in guest's page list. */
-+ uint64_t start_pfn;
-+ XEN_GUEST_HANDLE(xen_pfn_t) buffer;
++ uint64_aligned_t start_pfn;
++ XEN_GUEST_HANDLE_64(uint64_t) buffer;
+ /* OUT variables. */
-+ uint64_t num_pfns;
++ uint64_aligned_t num_pfns;
+};
+typedef struct xen_domctl_getmemlist xen_domctl_getmemlist_t;
+DEFINE_XEN_GUEST_HANDLE(xen_domctl_getmemlist_t);
@@ -88530,19 +84510,19 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#define XEN_DOMCTL_getpageframeinfo 7
+
+#define XEN_DOMCTL_PFINFO_LTAB_SHIFT 28
-+#define XEN_DOMCTL_PFINFO_NOTAB (0x0<<28)
-+#define XEN_DOMCTL_PFINFO_L1TAB (0x1<<28)
-+#define XEN_DOMCTL_PFINFO_L2TAB (0x2<<28)
-+#define XEN_DOMCTL_PFINFO_L3TAB (0x3<<28)
-+#define XEN_DOMCTL_PFINFO_L4TAB (0x4<<28)
-+#define XEN_DOMCTL_PFINFO_LTABTYPE_MASK (0x7<<28)
-+#define XEN_DOMCTL_PFINFO_LPINTAB (0x1<<31)
-+#define XEN_DOMCTL_PFINFO_XTAB (0xf<<28) /* invalid page */
-+#define XEN_DOMCTL_PFINFO_LTAB_MASK (0xf<<28)
++#define XEN_DOMCTL_PFINFO_NOTAB (0x0U<<28)
++#define XEN_DOMCTL_PFINFO_L1TAB (0x1U<<28)
++#define XEN_DOMCTL_PFINFO_L2TAB (0x2U<<28)
++#define XEN_DOMCTL_PFINFO_L3TAB (0x3U<<28)
++#define XEN_DOMCTL_PFINFO_L4TAB (0x4U<<28)
++#define XEN_DOMCTL_PFINFO_LTABTYPE_MASK (0x7U<<28)
++#define XEN_DOMCTL_PFINFO_LPINTAB (0x1U<<31)
++#define XEN_DOMCTL_PFINFO_XTAB (0xfU<<28) /* invalid page */
++#define XEN_DOMCTL_PFINFO_LTAB_MASK (0xfU<<28)
+
+struct xen_domctl_getpageframeinfo {
+ /* IN variables. */
-+ uint64_t gmfn; /* GMFN to query */
++ uint64_aligned_t gmfn; /* GMFN to query */
+ /* OUT variables. */
+ /* Is the page PINNED to a type? */
+ uint32_t type; /* see above type defs */
@@ -88554,9 +84534,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#define XEN_DOMCTL_getpageframeinfo2 8
+struct xen_domctl_getpageframeinfo2 {
+ /* IN variables. */
-+ uint64_t num;
++ uint64_aligned_t num;
+ /* IN/OUT variables. */
-+ XEN_GUEST_HANDLE(ulong) array;
++ XEN_GUEST_HANDLE_64(uint32_t) array;
+};
+typedef struct xen_domctl_getpageframeinfo2 xen_domctl_getpageframeinfo2_t;
+DEFINE_XEN_GUEST_HANDLE(xen_domctl_getpageframeinfo2_t);
@@ -88630,8 +84610,8 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ uint32_t mb; /* Shadow memory allocation in MB */
+
+ /* OP_PEEK / OP_CLEAN */
-+ XEN_GUEST_HANDLE(ulong) dirty_bitmap;
-+ uint64_t pages; /* Size of buffer. Updated with actual size. */
++ XEN_GUEST_HANDLE_64(uint8_t) dirty_bitmap;
++ uint64_aligned_t pages; /* Size of buffer. Updated with actual size. */
+ struct xen_domctl_shadow_op_stats stats;
+};
+typedef struct xen_domctl_shadow_op xen_domctl_shadow_op_t;
@@ -88641,7 +84621,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#define XEN_DOMCTL_max_mem 11
+struct xen_domctl_max_mem {
+ /* IN variables. */
-+ uint64_t max_memkb;
++ uint64_aligned_t max_memkb;
+};
+typedef struct xen_domctl_max_mem xen_domctl_max_mem_t;
+DEFINE_XEN_GUEST_HANDLE(xen_domctl_max_mem_t);
@@ -88651,7 +84631,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#define XEN_DOMCTL_getvcpucontext 13
+struct xen_domctl_vcpucontext {
+ uint32_t vcpu; /* IN */
-+ XEN_GUEST_HANDLE(vcpu_guest_context_t) ctxt; /* IN/OUT */
++ XEN_GUEST_HANDLE_64(vcpu_guest_context_t) ctxt; /* IN/OUT */
+};
+typedef struct xen_domctl_vcpucontext xen_domctl_vcpucontext_t;
+DEFINE_XEN_GUEST_HANDLE(xen_domctl_vcpucontext_t);
@@ -88665,7 +84645,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ uint8_t online; /* currently online (not hotplugged)? */
+ uint8_t blocked; /* blocked waiting for an event? */
+ uint8_t running; /* currently scheduled on its CPU? */
-+ uint64_t cpu_time; /* total cpu time consumed (ns) */
++ uint64_aligned_t cpu_time; /* total cpu time consumed (ns) */
+ uint32_t cpu; /* current mapping */
+};
+typedef struct xen_domctl_getvcpuinfo xen_domctl_getvcpuinfo_t;
@@ -88703,9 +84683,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ uint32_t cmd; /* XEN_DOMCTL_SCHEDOP_* */
+ union {
+ struct xen_domctl_sched_sedf {
-+ uint64_t period;
-+ uint64_t slice;
-+ uint64_t latency;
++ uint64_aligned_t period;
++ uint64_aligned_t slice;
++ uint64_aligned_t latency;
+ uint32_t extratime;
+ uint32_t weight;
+ } sedf;
@@ -88746,9 +84726,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+
+#define XEN_DOMCTL_iomem_permission 20
+struct xen_domctl_iomem_permission {
-+ uint64_t first_mfn; /* first page (physical page number) in range */
-+ uint64_t nr_mfns; /* number of pages in range (>0) */
-+ uint8_t allow_access; /* allow (!0) or deny (0) access to range? */
++ uint64_aligned_t first_mfn;/* first page (physical page number) in range */
++ uint64_aligned_t nr_mfns; /* number of pages in range (>0) */
++ uint8_t allow_access; /* allow (!0) or deny (0) access to range? */
+};
+typedef struct xen_domctl_iomem_permission xen_domctl_iomem_permission_t;
+DEFINE_XEN_GUEST_HANDLE(xen_domctl_iomem_permission_t);
@@ -88763,29 +84743,32 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+typedef struct xen_domctl_ioport_permission xen_domctl_ioport_permission_t;
+DEFINE_XEN_GUEST_HANDLE(xen_domctl_ioport_permission_t);
+
++
+#define XEN_DOMCTL_hypercall_init 22
+struct xen_domctl_hypercall_init {
-+ uint64_t gmfn; /* GMFN to be initialised */
++ uint64_aligned_t gmfn; /* GMFN to be initialised */
+};
+typedef struct xen_domctl_hypercall_init xen_domctl_hypercall_init_t;
+DEFINE_XEN_GUEST_HANDLE(xen_domctl_hypercall_init_t);
+
++
+#define XEN_DOMCTL_arch_setup 23
+#define _XEN_DOMAINSETUP_hvm_guest 0
+#define XEN_DOMAINSETUP_hvm_guest (1UL<<_XEN_DOMAINSETUP_hvm_guest)
+#define _XEN_DOMAINSETUP_query 1 /* Get parameters (for save) */
+#define XEN_DOMAINSETUP_query (1UL<<_XEN_DOMAINSETUP_query)
+typedef struct xen_domctl_arch_setup {
-+ uint64_t flags; /* XEN_DOMAINSETUP_* */
++ uint64_aligned_t flags; /* XEN_DOMAINSETUP_* */
+#ifdef __ia64__
-+ uint64_t bp; /* mpaddr of boot param area */
-+ uint64_t maxmem; /* Highest memory address for MDT. */
-+ uint64_t xsi_va; /* Xen shared_info area virtual address. */
-+ uint32_t hypercall_imm; /* Break imm for Xen hypercalls. */
++ uint64_aligned_t bp; /* mpaddr of boot param area */
++ uint64_aligned_t maxmem; /* Highest memory address for MDT. */
++ uint64_aligned_t xsi_va; /* Xen shared_info area virtual address. */
++ uint32_t hypercall_imm; /* Break imm for Xen hypercalls. */
+#endif
+} xen_domctl_arch_setup_t;
+DEFINE_XEN_GUEST_HANDLE(xen_domctl_arch_setup_t);
+
++
+#define XEN_DOMCTL_settimeoffset 24
+struct xen_domctl_settimeoffset {
+ int32_t time_offset_seconds; /* applied to domain wallclock time */
@@ -88793,13 +84776,47 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+typedef struct xen_domctl_settimeoffset xen_domctl_settimeoffset_t;
+DEFINE_XEN_GUEST_HANDLE(xen_domctl_settimeoffset_t);
+
-+#define XEN_DOMCTL_real_mode_area 26
++
++#define XEN_DOMCTL_gethvmcontext 33
++#define XEN_DOMCTL_sethvmcontext 34
++typedef struct xen_domctl_hvmcontext {
++ uint32_t size; /* IN/OUT: size of buffer / bytes filled */
++ XEN_GUEST_HANDLE_64(uint8_t) buffer; /* IN/OUT: data, or call
++ * gethvmcontext with NULL
++ * buffer to get size
++ * req'd */
++} xen_domctl_hvmcontext_t;
++DEFINE_XEN_GUEST_HANDLE(xen_domctl_hvmcontext_t);
++
++
++#define XEN_DOMCTL_set_address_size 35
++#define XEN_DOMCTL_get_address_size 36
++typedef struct xen_domctl_address_size {
++ uint32_t size;
++} xen_domctl_address_size_t;
++DEFINE_XEN_GUEST_HANDLE(xen_domctl_address_size_t);
++
++
++#define XEN_DOMCTL_real_mode_area 26
+struct xen_domctl_real_mode_area {
+ uint32_t log; /* log2 of Real Mode Area size */
+};
+typedef struct xen_domctl_real_mode_area xen_domctl_real_mode_area_t;
+DEFINE_XEN_GUEST_HANDLE(xen_domctl_real_mode_area_t);
+
++
++#define XEN_DOMCTL_sendtrigger 28
++#define XEN_DOMCTL_SENDTRIGGER_NMI 0
++#define XEN_DOMCTL_SENDTRIGGER_RESET 1
++#define XEN_DOMCTL_SENDTRIGGER_INIT 2
++struct xen_domctl_sendtrigger {
++ uint32_t trigger; /* IN */
++ uint32_t vcpu; /* IN */
++};
++typedef struct xen_domctl_sendtrigger xen_domctl_sendtrigger_t;
++DEFINE_XEN_GUEST_HANDLE(xen_domctl_sendtrigger_t);
++
++
+struct xen_domctl {
+ uint32_t cmd;
+ uint32_t interface_version; /* XEN_DOMCTL_INTERFACE_VERSION */
@@ -88826,6 +84843,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ struct xen_domctl_arch_setup arch_setup;
+ struct xen_domctl_settimeoffset settimeoffset;
+ struct xen_domctl_real_mode_area real_mode_area;
++ struct xen_domctl_hvmcontext hvmcontext;
++ struct xen_domctl_address_size address_size;
++ struct xen_domctl_sendtrigger sendtrigger;
+ uint8_t pad[128];
+ } u;
+};
@@ -88843,10 +84863,10 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ * indent-tabs-mode: nil
+ * End:
+ */
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/xen/interface/elfnote.h source/include/xen/interface/elfnote.h
---- /scratch/src/linux-2.6.20.3/include/xen/interface/elfnote.h 1970-01-01 01:00:00.000000000 +0100
-+++ source/include/xen/interface/elfnote.h 2007-03-20 21:27:02.000000000 +0100
-@@ -0,0 +1,179 @@
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/xen/interface/elfnote.h
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/include/xen/interface/elfnote.h Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,233 @@
+/******************************************************************************
+ * elfnote.h
+ *
@@ -88877,7 +84897,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#define __XEN_PUBLIC_ELFNOTE_H__
+
+/*
-+ * The notes should live in a SHT_NOTE segment and have "Xen" in the
++ * The notes should live in a PT_NOTE segment and have "Xen" in the
+ * name field.
+ *
+ * Numeric types are either 4 or 8 bytes depending on the content of
@@ -88889,8 +84909,6 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+
+/*
+ * NAME=VALUE pair (string).
-+ *
-+ * LEGACY: FEATURES and PAE
+ */
+#define XEN_ELFNOTE_INFO 0
+
@@ -88957,7 +84975,12 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#define XEN_ELFNOTE_LOADER 8
+
+/*
-+ * The kernel supports PAE (x86/32 only, string = "yes" or "no").
++ * The kernel supports PAE (x86/32 only, string = "yes", "no" or
++ * "bimodal").
++ *
++ * For compatibility with Xen 3.0.3 and earlier the "bimodal" setting
++ * may be given as "yes,bimodal" which will cause older Xen to treat
++ * this kernel as PAE.
+ *
+ * LEGACY: PAE (n.b. The legacy interface included a provision to
+ * indicate 'extended-cr3' support allowing L3 page tables to be
@@ -88997,6 +85020,22 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#define XEN_ELFNOTE_HV_START_LOW 12
+
+/*
++ * List of maddr_t-sized mask/value pairs describing how to recognize
++ * (non-present) L1 page table entries carrying valid MFNs (numeric).
++ */
++#define XEN_ELFNOTE_L1_MFN_VALID 13
++
++/*
++ * Whether or not the guest supports cooperative suspend cancellation.
++ */
++#define XEN_ELFNOTE_SUSPEND_CANCEL 14
++
++/*
++ * The number of the highest elfnote defined.
++ */
++#define XEN_ELFNOTE_MAX XEN_ELFNOTE_SUSPEND_CANCEL
++
++/*
+ * System information exported through crash notes.
+ *
+ * The kexec / kdump code will create one XEN_ELFNOTE_CRASH_INFO
@@ -89015,6 +85054,41 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ */
+#define XEN_ELFNOTE_CRASH_REGS 0x1000002
+
++
++/*
++ * xen dump-core none note.
++ * xm dump-core code will create one XEN_ELFNOTE_DUMPCORE_NONE
++ * in its dump file to indicate that the file is xen dump-core
++ * file. This note doesn't have any other information.
++ * See tools/libxc/xc_core.h for more information.
++ */
++#define XEN_ELFNOTE_DUMPCORE_NONE 0x2000000
++
++/*
++ * xen dump-core header note.
++ * xm dump-core code will create one XEN_ELFNOTE_DUMPCORE_HEADER
++ * in its dump file.
++ * See tools/libxc/xc_core.h for more information.
++ */
++#define XEN_ELFNOTE_DUMPCORE_HEADER 0x2000001
++
++/*
++ * xen dump-core xen version note.
++ * xm dump-core code will create one XEN_ELFNOTE_DUMPCORE_XEN_VERSION
++ * in its dump file. It contains the xen version obtained via the
++ * XENVER hypercall.
++ * See tools/libxc/xc_core.h for more information.
++ */
++#define XEN_ELFNOTE_DUMPCORE_XEN_VERSION 0x2000002
++
++/*
++ * xen dump-core format version note.
++ * xm dump-core code will create one XEN_ELFNOTE_DUMPCORE_FORMAT_VERSION
++ * in its dump file. It contains a format version identifier.
++ * See tools/libxc/xc_core.h for more information.
++ */
++#define XEN_ELFNOTE_DUMPCORE_FORMAT_VERSION 0x2000003
++
+#endif /* __XEN_PUBLIC_ELFNOTE_H__ */
+
+/*
@@ -89026,10 +85100,541 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ * indent-tabs-mode: nil
+ * End:
+ */
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/xen/interface/event_channel.h source/include/xen/interface/event_channel.h
---- /scratch/src/linux-2.6.20.3/include/xen/interface/event_channel.h 1970-01-01 01:00:00.000000000 +0100
-+++ source/include/xen/interface/event_channel.h 2007-03-20 21:27:02.000000000 +0100
-@@ -0,0 +1,251 @@
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/xen/interface/elfstructs.h
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/include/xen/interface/elfstructs.h Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,527 @@
++#ifndef __XEN_PUBLIC_ELFSTRUCTS_H__
++#define __XEN_PUBLIC_ELFSTRUCTS_H__ 1
++/*
++ * Copyright (c) 1995, 1996 Erik Theisen. All rights reserved.
++ *
++ * Redistribution and use in source and binary forms, with or without
++ * modification, are permitted provided that the following conditions
++ * are met:
++ * 1. Redistributions of source code must retain the above copyright
++ * notice, this list of conditions and the following disclaimer.
++ * 2. Redistributions in binary form must reproduce the above copyright
++ * notice, this list of conditions and the following disclaimer in the
++ * documentation and/or other materials provided with the distribution.
++ * 3. The name of the author may not be used to endorse or promote products
++ * derived from this software without specific prior written permission
++ *
++ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
++ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
++ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
++ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
++ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
++ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
++ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
++ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
++ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
++ */
++
++typedef uint8_t Elf_Byte;
++
++typedef uint32_t Elf32_Addr; /* Unsigned program address */
++typedef uint32_t Elf32_Off; /* Unsigned file offset */
++typedef int32_t Elf32_Sword; /* Signed large integer */
++typedef uint32_t Elf32_Word; /* Unsigned large integer */
++typedef uint16_t Elf32_Half; /* Unsigned medium integer */
++
++typedef uint64_t Elf64_Addr;
++typedef uint64_t Elf64_Off;
++typedef int32_t Elf64_Shalf;
++
++typedef int32_t Elf64_Sword;
++typedef uint32_t Elf64_Word;
++
++typedef int64_t Elf64_Sxword;
++typedef uint64_t Elf64_Xword;
++
++typedef uint32_t Elf64_Half;
++typedef uint16_t Elf64_Quarter;
++
++/*
++ * e_ident[] identification indexes
++ * See http://www.caldera.com/developers/gabi/2000-07-17/ch4.eheader.html
++ */
++#define EI_MAG0 0 /* file ID */
++#define EI_MAG1 1 /* file ID */
++#define EI_MAG2 2 /* file ID */
++#define EI_MAG3 3 /* file ID */
++#define EI_CLASS 4 /* file class */
++#define EI_DATA 5 /* data encoding */
++#define EI_VERSION 6 /* ELF header version */
++#define EI_OSABI 7 /* OS/ABI ID */
++#define EI_ABIVERSION 8 /* ABI version */
++#define EI_PAD 9 /* start of pad bytes */
++#define EI_NIDENT 16 /* Size of e_ident[] */
++
++/* e_ident[] magic number */
++#define ELFMAG0 0x7f /* e_ident[EI_MAG0] */
++#define ELFMAG1 'E' /* e_ident[EI_MAG1] */
++#define ELFMAG2 'L' /* e_ident[EI_MAG2] */
++#define ELFMAG3 'F' /* e_ident[EI_MAG3] */
++#define ELFMAG "\177ELF" /* magic */
++#define SELFMAG 4 /* size of magic */
++
++/* e_ident[] file class */
++#define ELFCLASSNONE 0 /* invalid */
++#define ELFCLASS32 1 /* 32-bit objs */
++#define ELFCLASS64 2 /* 64-bit objs */
++#define ELFCLASSNUM 3 /* number of classes */
++
++/* e_ident[] data encoding */
++#define ELFDATANONE 0 /* invalid */
++#define ELFDATA2LSB 1 /* Little-Endian */
++#define ELFDATA2MSB 2 /* Big-Endian */
++#define ELFDATANUM 3 /* number of data encode defines */
++
++/* e_ident[] Operating System/ABI */
++#define ELFOSABI_SYSV 0 /* UNIX System V ABI */
++#define ELFOSABI_HPUX 1 /* HP-UX operating system */
++#define ELFOSABI_NETBSD 2 /* NetBSD */
++#define ELFOSABI_LINUX 3 /* GNU/Linux */
++#define ELFOSABI_HURD 4 /* GNU/Hurd */
++#define ELFOSABI_86OPEN 5 /* 86Open common IA32 ABI */
++#define ELFOSABI_SOLARIS 6 /* Solaris */
++#define ELFOSABI_MONTEREY 7 /* Monterey */
++#define ELFOSABI_IRIX 8 /* IRIX */
++#define ELFOSABI_FREEBSD 9 /* FreeBSD */
++#define ELFOSABI_TRU64 10 /* TRU64 UNIX */
++#define ELFOSABI_MODESTO 11 /* Novell Modesto */
++#define ELFOSABI_OPENBSD 12 /* OpenBSD */
++#define ELFOSABI_ARM 97 /* ARM */
++#define ELFOSABI_STANDALONE 255 /* Standalone (embedded) application */
++
++/* e_ident */
++#define IS_ELF(ehdr) ((ehdr).e_ident[EI_MAG0] == ELFMAG0 && \
++ (ehdr).e_ident[EI_MAG1] == ELFMAG1 && \
++ (ehdr).e_ident[EI_MAG2] == ELFMAG2 && \
++ (ehdr).e_ident[EI_MAG3] == ELFMAG3)
++
++/* ELF Header */
++typedef struct elfhdr {
++ unsigned char e_ident[EI_NIDENT]; /* ELF Identification */
++ Elf32_Half e_type; /* object file type */
++ Elf32_Half e_machine; /* machine */
++ Elf32_Word e_version; /* object file version */
++ Elf32_Addr e_entry; /* virtual entry point */
++ Elf32_Off e_phoff; /* program header table offset */
++ Elf32_Off e_shoff; /* section header table offset */
++ Elf32_Word e_flags; /* processor-specific flags */
++ Elf32_Half e_ehsize; /* ELF header size */
++ Elf32_Half e_phentsize; /* program header entry size */
++ Elf32_Half e_phnum; /* number of program header entries */
++ Elf32_Half e_shentsize; /* section header entry size */
++ Elf32_Half e_shnum; /* number of section header entries */
++ Elf32_Half e_shstrndx; /* section header table's "section
++ header string table" entry offset */
++} Elf32_Ehdr;
++
++typedef struct {
++ unsigned char e_ident[EI_NIDENT]; /* Id bytes */
++ Elf64_Quarter e_type; /* file type */
++ Elf64_Quarter e_machine; /* machine type */
++ Elf64_Half e_version; /* version number */
++ Elf64_Addr e_entry; /* entry point */
++ Elf64_Off e_phoff; /* Program hdr offset */
++ Elf64_Off e_shoff; /* Section hdr offset */
++ Elf64_Half e_flags; /* Processor flags */
++ Elf64_Quarter e_ehsize; /* sizeof ehdr */
++ Elf64_Quarter e_phentsize; /* Program header entry size */
++ Elf64_Quarter e_phnum; /* Number of program headers */
++ Elf64_Quarter e_shentsize; /* Section header entry size */
++ Elf64_Quarter e_shnum; /* Number of section headers */
++ Elf64_Quarter e_shstrndx; /* String table index */
++} Elf64_Ehdr;
++
++/* e_type */
++#define ET_NONE 0 /* No file type */
++#define ET_REL 1 /* relocatable file */
++#define ET_EXEC 2 /* executable file */
++#define ET_DYN 3 /* shared object file */
++#define ET_CORE 4 /* core file */
++#define ET_NUM 5 /* number of types */
++#define ET_LOPROC 0xff00 /* reserved range for processor */
++#define ET_HIPROC 0xffff /* specific e_type */
++
++/* e_machine */
++#define EM_NONE 0 /* No Machine */
++#define EM_M32 1 /* AT&T WE 32100 */
++#define EM_SPARC 2 /* SPARC */
++#define EM_386 3 /* Intel 80386 */
++#define EM_68K 4 /* Motorola 68000 */
++#define EM_88K 5 /* Motorola 88000 */
++#define EM_486 6 /* Intel 80486 - unused? */
++#define EM_860 7 /* Intel 80860 */
++#define EM_MIPS 8 /* MIPS R3000 Big-Endian only */
++/*
++ * Don't know if EM_MIPS_RS4_BE,
++ * EM_SPARC64, EM_PARISC,
++ * or EM_PPC are ABI compliant
++ */
++#define EM_MIPS_RS4_BE 10 /* MIPS R4000 Big-Endian */
++#define EM_SPARC64 11 /* SPARC v9 64-bit unoffical */
++#define EM_PARISC 15 /* HPPA */
++#define EM_SPARC32PLUS 18 /* Enhanced instruction set SPARC */
++#define EM_PPC 20 /* PowerPC */
++#define EM_PPC64 21 /* PowerPC 64-bit */
++#define EM_ARM 40 /* Advanced RISC Machines ARM */
++#define EM_ALPHA 41 /* DEC ALPHA */
++#define EM_SPARCV9 43 /* SPARC version 9 */
++#define EM_ALPHA_EXP 0x9026 /* DEC ALPHA */
++#define EM_IA_64 50 /* Intel Merced */
++#define EM_X86_64 62 /* AMD x86-64 architecture */
++#define EM_VAX 75 /* DEC VAX */
++
++/* Version */
++#define EV_NONE 0 /* Invalid */
++#define EV_CURRENT 1 /* Current */
++#define EV_NUM 2 /* number of versions */
++
++/* Section Header */
++typedef struct {
++ Elf32_Word sh_name; /* name - index into section header
++ string table section */
++ Elf32_Word sh_type; /* type */
++ Elf32_Word sh_flags; /* flags */
++ Elf32_Addr sh_addr; /* address */
++ Elf32_Off sh_offset; /* file offset */
++ Elf32_Word sh_size; /* section size */
++ Elf32_Word sh_link; /* section header table index link */
++ Elf32_Word sh_info; /* extra information */
++ Elf32_Word sh_addralign; /* address alignment */
++ Elf32_Word sh_entsize; /* section entry size */
++} Elf32_Shdr;
++
++typedef struct {
++ Elf64_Half sh_name; /* section name */
++ Elf64_Half sh_type; /* section type */
++ Elf64_Xword sh_flags; /* section flags */
++ Elf64_Addr sh_addr; /* virtual address */
++ Elf64_Off sh_offset; /* file offset */
++ Elf64_Xword sh_size; /* section size */
++ Elf64_Half sh_link; /* link to another */
++ Elf64_Half sh_info; /* misc info */
++ Elf64_Xword sh_addralign; /* memory alignment */
++ Elf64_Xword sh_entsize; /* table entry size */
++} Elf64_Shdr;
++
++/* Special Section Indexes */
++#define SHN_UNDEF 0 /* undefined */
++#define SHN_LORESERVE 0xff00 /* lower bounds of reserved indexes */
++#define SHN_LOPROC 0xff00 /* reserved range for processor */
++#define SHN_HIPROC 0xff1f /* specific section indexes */
++#define SHN_ABS 0xfff1 /* absolute value */
++#define SHN_COMMON 0xfff2 /* common symbol */
++#define SHN_HIRESERVE 0xffff /* upper bounds of reserved indexes */
++
++/* sh_type */
++#define SHT_NULL 0 /* inactive */
++#define SHT_PROGBITS 1 /* program defined information */
++#define SHT_SYMTAB 2 /* symbol table section */
++#define SHT_STRTAB 3 /* string table section */
++#define SHT_RELA 4 /* relocation section with addends*/
++#define SHT_HASH 5 /* symbol hash table section */
++#define SHT_DYNAMIC 6 /* dynamic section */
++#define SHT_NOTE 7 /* note section */
++#define SHT_NOBITS 8 /* no space section */
++#define SHT_REL 9 /* relation section without addends */
++#define SHT_SHLIB 10 /* reserved - purpose unknown */
++#define SHT_DYNSYM 11 /* dynamic symbol table section */
++#define SHT_NUM 12 /* number of section types */
++#define SHT_LOPROC 0x70000000 /* reserved range for processor */
++#define SHT_HIPROC 0x7fffffff /* specific section header types */
++#define SHT_LOUSER 0x80000000 /* reserved range for application */
++#define SHT_HIUSER 0xffffffff /* specific indexes */
++
++/* Section names */
++#define ELF_BSS ".bss" /* uninitialized data */
++#define ELF_DATA ".data" /* initialized data */
++#define ELF_DEBUG ".debug" /* debug */
++#define ELF_DYNAMIC ".dynamic" /* dynamic linking information */
++#define ELF_DYNSTR ".dynstr" /* dynamic string table */
++#define ELF_DYNSYM ".dynsym" /* dynamic symbol table */
++#define ELF_FINI ".fini" /* termination code */
++#define ELF_GOT ".got" /* global offset table */
++#define ELF_HASH ".hash" /* symbol hash table */
++#define ELF_INIT ".init" /* initialization code */
++#define ELF_REL_DATA ".rel.data" /* relocation data */
++#define ELF_REL_FINI ".rel.fini" /* relocation termination code */
++#define ELF_REL_INIT ".rel.init" /* relocation initialization code */
++#define ELF_REL_DYN ".rel.dyn" /* relocaltion dynamic link info */
++#define ELF_REL_RODATA ".rel.rodata" /* relocation read-only data */
++#define ELF_REL_TEXT ".rel.text" /* relocation code */
++#define ELF_RODATA ".rodata" /* read-only data */
++#define ELF_SHSTRTAB ".shstrtab" /* section header string table */
++#define ELF_STRTAB ".strtab" /* string table */
++#define ELF_SYMTAB ".symtab" /* symbol table */
++#define ELF_TEXT ".text" /* code */
++
++
++/* Section Attribute Flags - sh_flags */
++#define SHF_WRITE 0x1 /* Writable */
++#define SHF_ALLOC 0x2 /* occupies memory */
++#define SHF_EXECINSTR 0x4 /* executable */
++#define SHF_MASKPROC 0xf0000000 /* reserved bits for processor */
++ /* specific section attributes */
++
++/* Symbol Table Entry */
++typedef struct elf32_sym {
++ Elf32_Word st_name; /* name - index into string table */
++ Elf32_Addr st_value; /* symbol value */
++ Elf32_Word st_size; /* symbol size */
++ unsigned char st_info; /* type and binding */
++ unsigned char st_other; /* 0 - no defined meaning */
++ Elf32_Half st_shndx; /* section header index */
++} Elf32_Sym;
++
++typedef struct {
++ Elf64_Half st_name; /* Symbol name index in str table */
++ Elf_Byte st_info; /* type / binding attrs */
++ Elf_Byte st_other; /* unused */
++ Elf64_Quarter st_shndx; /* section index of symbol */
++ Elf64_Xword st_value; /* value of symbol */
++ Elf64_Xword st_size; /* size of symbol */
++} Elf64_Sym;
++
++/* Symbol table index */
++#define STN_UNDEF 0 /* undefined */
++
++/* Extract symbol info - st_info */
++#define ELF32_ST_BIND(x) ((x) >> 4)
++#define ELF32_ST_TYPE(x) (((unsigned int) x) & 0xf)
++#define ELF32_ST_INFO(b,t) (((b) << 4) + ((t) & 0xf))
++
++#define ELF64_ST_BIND(x) ((x) >> 4)
++#define ELF64_ST_TYPE(x) (((unsigned int) x) & 0xf)
++#define ELF64_ST_INFO(b,t) (((b) << 4) + ((t) & 0xf))
++
++/* Symbol Binding - ELF32_ST_BIND - st_info */
++#define STB_LOCAL 0 /* Local symbol */
++#define STB_GLOBAL 1 /* Global symbol */
++#define STB_WEAK 2 /* like global - lower precedence */
++#define STB_NUM 3 /* number of symbol bindings */
++#define STB_LOPROC 13 /* reserved range for processor */
++#define STB_HIPROC 15 /* specific symbol bindings */
++
++/* Symbol type - ELF32_ST_TYPE - st_info */
++#define STT_NOTYPE 0 /* not specified */
++#define STT_OBJECT 1 /* data object */
++#define STT_FUNC 2 /* function */
++#define STT_SECTION 3 /* section */
++#define STT_FILE 4 /* file */
++#define STT_NUM 5 /* number of symbol types */
++#define STT_LOPROC 13 /* reserved range for processor */
++#define STT_HIPROC 15 /* specific symbol types */
++
++/* Relocation entry with implicit addend */
++typedef struct {
++ Elf32_Addr r_offset; /* offset of relocation */
++ Elf32_Word r_info; /* symbol table index and type */
++} Elf32_Rel;
++
++/* Relocation entry with explicit addend */
++typedef struct {
++ Elf32_Addr r_offset; /* offset of relocation */
++ Elf32_Word r_info; /* symbol table index and type */
++ Elf32_Sword r_addend;
++} Elf32_Rela;
++
++/* Extract relocation info - r_info */
++#define ELF32_R_SYM(i) ((i) >> 8)
++#define ELF32_R_TYPE(i) ((unsigned char) (i))
++#define ELF32_R_INFO(s,t) (((s) << 8) + (unsigned char)(t))
++
++typedef struct {
++ Elf64_Xword r_offset; /* where to do it */
++ Elf64_Xword r_info; /* index & type of relocation */
++} Elf64_Rel;
++
++typedef struct {
++ Elf64_Xword r_offset; /* where to do it */
++ Elf64_Xword r_info; /* index & type of relocation */
++ Elf64_Sxword r_addend; /* adjustment value */
++} Elf64_Rela;
++
++#define ELF64_R_SYM(info) ((info) >> 32)
++#define ELF64_R_TYPE(info) ((info) & 0xFFFFFFFF)
++#define ELF64_R_INFO(s,t) (((s) << 32) + (u_int32_t)(t))
++
++/* Program Header */
++typedef struct {
++ Elf32_Word p_type; /* segment type */
++ Elf32_Off p_offset; /* segment offset */
++ Elf32_Addr p_vaddr; /* virtual address of segment */
++ Elf32_Addr p_paddr; /* physical address - ignored? */
++ Elf32_Word p_filesz; /* number of bytes in file for seg. */
++ Elf32_Word p_memsz; /* number of bytes in mem. for seg. */
++ Elf32_Word p_flags; /* flags */
++ Elf32_Word p_align; /* memory alignment */
++} Elf32_Phdr;
++
++typedef struct {
++ Elf64_Half p_type; /* entry type */
++ Elf64_Half p_flags; /* flags */
++ Elf64_Off p_offset; /* offset */
++ Elf64_Addr p_vaddr; /* virtual address */
++ Elf64_Addr p_paddr; /* physical address */
++ Elf64_Xword p_filesz; /* file size */
++ Elf64_Xword p_memsz; /* memory size */
++ Elf64_Xword p_align; /* memory & file alignment */
++} Elf64_Phdr;
++
++/* Segment types - p_type */
++#define PT_NULL 0 /* unused */
++#define PT_LOAD 1 /* loadable segment */
++#define PT_DYNAMIC 2 /* dynamic linking section */
++#define PT_INTERP 3 /* the RTLD */
++#define PT_NOTE 4 /* auxiliary information */
++#define PT_SHLIB 5 /* reserved - purpose undefined */
++#define PT_PHDR 6 /* program header */
++#define PT_NUM 7 /* Number of segment types */
++#define PT_LOPROC 0x70000000 /* reserved range for processor */
++#define PT_HIPROC 0x7fffffff /* specific segment types */
++
++/* Segment flags - p_flags */
++#define PF_X 0x1 /* Executable */
++#define PF_W 0x2 /* Writable */
++#define PF_R 0x4 /* Readable */
++#define PF_MASKPROC 0xf0000000 /* reserved bits for processor */
++ /* specific segment flags */
++
++/* Dynamic structure */
++typedef struct {
++ Elf32_Sword d_tag; /* controls meaning of d_val */
++ union {
++ Elf32_Word d_val; /* Multiple meanings - see d_tag */
++ Elf32_Addr d_ptr; /* program virtual address */
++ } d_un;
++} Elf32_Dyn;
++
++typedef struct {
++ Elf64_Xword d_tag; /* controls meaning of d_val */
++ union {
++ Elf64_Addr d_ptr;
++ Elf64_Xword d_val;
++ } d_un;
++} Elf64_Dyn;
++
++/* Dynamic Array Tags - d_tag */
++#define DT_NULL 0 /* marks end of _DYNAMIC array */
++#define DT_NEEDED 1 /* string table offset of needed lib */
++#define DT_PLTRELSZ 2 /* size of relocation entries in PLT */
++#define DT_PLTGOT 3 /* address PLT/GOT */
++#define DT_HASH 4 /* address of symbol hash table */
++#define DT_STRTAB 5 /* address of string table */
++#define DT_SYMTAB 6 /* address of symbol table */
++#define DT_RELA 7 /* address of relocation table */
++#define DT_RELASZ 8 /* size of relocation table */
++#define DT_RELAENT 9 /* size of relocation entry */
++#define DT_STRSZ 10 /* size of string table */
++#define DT_SYMENT 11 /* size of symbol table entry */
++#define DT_INIT 12 /* address of initialization func. */
++#define DT_FINI 13 /* address of termination function */
++#define DT_SONAME 14 /* string table offset of shared obj */
++#define DT_RPATH 15 /* string table offset of library
++ search path */
++#define DT_SYMBOLIC 16 /* start sym search in shared obj. */
++#define DT_REL 17 /* address of rel. tbl. w addends */
++#define DT_RELSZ 18 /* size of DT_REL relocation table */
++#define DT_RELENT 19 /* size of DT_REL relocation entry */
++#define DT_PLTREL 20 /* PLT referenced relocation entry */
++#define DT_DEBUG 21 /* bugger */
++#define DT_TEXTREL 22 /* Allow rel. mod. to unwritable seg */
++#define DT_JMPREL 23 /* add. of PLT's relocation entries */
++#define DT_BIND_NOW 24 /* Bind now regardless of env setting */
++#define DT_NUM 25 /* Number used. */
++#define DT_LOPROC 0x70000000 /* reserved range for processor */
++#define DT_HIPROC 0x7fffffff /* specific dynamic array tags */
++
++/* Standard ELF hashing function */
++unsigned int elf_hash(const unsigned char *name);
++
++/*
++ * Note Definitions
++ */
++typedef struct {
++ Elf32_Word namesz;
++ Elf32_Word descsz;
++ Elf32_Word type;
++} Elf32_Note;
++
++typedef struct {
++ Elf64_Half namesz;
++ Elf64_Half descsz;
++ Elf64_Half type;
++} Elf64_Note;
++
++
++#if defined(ELFSIZE)
++#define CONCAT(x,y) __CONCAT(x,y)
++#define ELFNAME(x) CONCAT(elf,CONCAT(ELFSIZE,CONCAT(_,x)))
++#define ELFNAME2(x,y) CONCAT(x,CONCAT(_elf,CONCAT(ELFSIZE,CONCAT(_,y))))
++#define ELFNAMEEND(x) CONCAT(x,CONCAT(_elf,ELFSIZE))
++#define ELFDEFNNAME(x) CONCAT(ELF,CONCAT(ELFSIZE,CONCAT(_,x)))
++#endif
++
++#if defined(ELFSIZE) && (ELFSIZE == 32)
++#define Elf_Ehdr Elf32_Ehdr
++#define Elf_Phdr Elf32_Phdr
++#define Elf_Shdr Elf32_Shdr
++#define Elf_Sym Elf32_Sym
++#define Elf_Rel Elf32_Rel
++#define Elf_RelA Elf32_Rela
++#define Elf_Dyn Elf32_Dyn
++#define Elf_Word Elf32_Word
++#define Elf_Sword Elf32_Sword
++#define Elf_Addr Elf32_Addr
++#define Elf_Off Elf32_Off
++#define Elf_Nhdr Elf32_Nhdr
++#define Elf_Note Elf32_Note
++
++#define ELF_R_SYM ELF32_R_SYM
++#define ELF_R_TYPE ELF32_R_TYPE
++#define ELF_R_INFO ELF32_R_INFO
++#define ELFCLASS ELFCLASS32
++
++#define ELF_ST_BIND ELF32_ST_BIND
++#define ELF_ST_TYPE ELF32_ST_TYPE
++#define ELF_ST_INFO ELF32_ST_INFO
++
++#define AuxInfo Aux32Info
++#elif defined(ELFSIZE) && (ELFSIZE == 64)
++#define Elf_Ehdr Elf64_Ehdr
++#define Elf_Phdr Elf64_Phdr
++#define Elf_Shdr Elf64_Shdr
++#define Elf_Sym Elf64_Sym
++#define Elf_Rel Elf64_Rel
++#define Elf_RelA Elf64_Rela
++#define Elf_Dyn Elf64_Dyn
++#define Elf_Word Elf64_Word
++#define Elf_Sword Elf64_Sword
++#define Elf_Addr Elf64_Addr
++#define Elf_Off Elf64_Off
++#define Elf_Nhdr Elf64_Nhdr
++#define Elf_Note Elf64_Note
++
++#define ELF_R_SYM ELF64_R_SYM
++#define ELF_R_TYPE ELF64_R_TYPE
++#define ELF_R_INFO ELF64_R_INFO
++#define ELFCLASS ELFCLASS64
++
++#define ELF_ST_BIND ELF64_ST_BIND
++#define ELF_ST_TYPE ELF64_ST_TYPE
++#define ELF_ST_INFO ELF64_ST_INFO
++
++#define AuxInfo Aux64Info
++#endif
++
++#endif /* __XEN_PUBLIC_ELFSTRUCTS_H__ */
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/xen/interface/event_channel.h
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/include/xen/interface/event_channel.h Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,264 @@
+/******************************************************************************
+ * event_channel.h
+ *
@@ -89249,6 +85854,19 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+typedef struct evtchn_unmask evtchn_unmask_t;
+
+/*
++ * EVTCHNOP_reset: Close all event channels associated with specified domain.
++ * NOTES:
++ * 1. <dom> may be specified as DOMID_SELF.
++ * 2. Only a sufficiently-privileged domain may specify other than DOMID_SELF.
++ */
++#define EVTCHNOP_reset 10
++struct evtchn_reset {
++ /* IN parameters. */
++ domid_t dom;
++};
++typedef struct evtchn_reset evtchn_reset_t;
++
++/*
+ * Argument to event_channel_op_compat() hypercall. Superceded by new
+ * event_channel_op() hypercall since 0x00030202.
+ */
@@ -89281,9 +85899,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ * indent-tabs-mode: nil
+ * End:
+ */
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/xen/interface/features.h source/include/xen/interface/features.h
---- /scratch/src/linux-2.6.20.3/include/xen/interface/features.h 1970-01-01 01:00:00.000000000 +0100
-+++ source/include/xen/interface/features.h 2007-03-20 21:27:03.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/xen/interface/features.h
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/include/xen/interface/features.h Wed Aug 08 16:25:28 2007 -0300
@@ -0,0 +1,71 @@
+/******************************************************************************
+ * features.h
@@ -89356,10 +85974,349 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ * indent-tabs-mode: nil
+ * End:
+ */
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/xen/interface/grant_table.h source/include/xen/interface/grant_table.h
---- /scratch/src/linux-2.6.20.3/include/xen/interface/grant_table.h 1970-01-01 01:00:00.000000000 +0100
-+++ source/include/xen/interface/grant_table.h 2007-03-20 21:27:03.000000000 +0100
-@@ -0,0 +1,380 @@
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/xen/interface/foreign/Makefile
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/include/xen/interface/foreign/Makefile Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,37 @@
++XEN_ROOT=../../../..
++include $(XEN_ROOT)/Config.mk
++
++architectures := x86_32 x86_64 ia64
++headers := $(patsubst %, %.h, $(architectures))
++scripts := $(wildcard *.py)
++
++.PHONY: all clean check-headers
++all: $(headers) check-headers
++
++clean:
++ rm -f $(headers)
++ rm -f checker checker.c $(XEN_TARGET_ARCH).size
++ rm -f *.pyc *.o *~
++
++ifeq ($(CROSS_COMPILE)$(XEN_TARGET_ARCH),$(XEN_COMPILE_ARCH))
++check-headers: checker
++ ./checker > $(XEN_TARGET_ARCH).size
++ diff -u reference.size $(XEN_TARGET_ARCH).size
++checker: checker.c $(headers)
++ $(HOSTCC) $(HOSTCFLAGS) -o $@ $<
++else
++check-headers:
++ @echo "cross build: skipping check"
++endif
++
++x86_32.h: ../arch-x86/xen-x86_32.h ../arch-x86/xen.h ../xen.h $(scripts)
++ python mkheader.py $* $@ $(filter %.h,$^)
++
++x86_64.h: ../arch-x86/xen-x86_64.h ../arch-x86/xen.h ../xen.h $(scripts)
++ python mkheader.py $* $@ $(filter %.h,$^)
++
++ia64.h: ../arch-ia64.h ../xen.h $(scripts)
++ python mkheader.py $* $@ $(filter %.h,$^)
++
++checker.c: $(scripts)
++ python mkchecker.py $(XEN_TARGET_ARCH) $@ $(architectures)
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/xen/interface/foreign/mkchecker.py
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/include/xen/interface/foreign/mkchecker.py Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,58 @@
++#!/usr/bin/python
++
++import sys;
++from structs import structs;
++
++# command line arguments
++arch = sys.argv[1];
++outfile = sys.argv[2];
++archs = sys.argv[3:];
++
++f = open(outfile, "w");
++f.write('''
++/*
++ * sanity checks for generated foreign headers:
++ * - verify struct sizes
++ *
++ * generated by %s -- DO NOT EDIT
++ */
++#include <stdio.h>
++#include <stdlib.h>
++#include <stddef.h>
++#include <inttypes.h>
++#include "../xen.h"
++''');
++
++for a in archs:
++ f.write('#include "%s.h"\n' % a);
++
++f.write('int main(int argc, char *argv[])\n{\n');
++
++f.write('\tprintf("\\n");');
++f.write('printf("%-20s |", "structs");\n');
++for a in archs:
++ f.write('\tprintf("%%8s", "%s");\n' % a);
++f.write('\tprintf("\\n");');
++
++f.write('\tprintf("\\n");');
++for struct in structs:
++ f.write('\tprintf("%%-20s |", "%s");\n' % struct);
++ for a in archs:
++ if a == arch:
++ s = struct; # native
++ else:
++ s = struct + "_" + a;
++ f.write('#ifdef %s_has_no_%s\n' % (a, struct));
++ f.write('\tprintf("%8s", "-");\n');
++ f.write("#else\n");
++ f.write('\tprintf("%%8zd", sizeof(struct %s));\n' % s);
++ f.write("#endif\n");
++
++ f.write('\tprintf("\\n");\n\n');
++
++f.write('\tprintf("\\n");\n');
++f.write('\texit(0);\n');
++f.write('}\n');
++
++f.close();
++
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/xen/interface/foreign/mkheader.py
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/include/xen/interface/foreign/mkheader.py Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,153 @@
++#!/usr/bin/python
++
++import sys, re;
++from structs import structs, defines;
++
++# command line arguments
++arch = sys.argv[1];
++outfile = sys.argv[2];
++infiles = sys.argv[3:];
++
++
++###########################################################################
++# configuration #2: architecture information
++
++inttypes = {};
++header = {};
++footer = {};
++
++# x86_32
++inttypes["x86_32"] = {
++ "unsigned long" : "uint32_t",
++ "long" : "uint32_t",
++ "xen_pfn_t" : "uint32_t",
++};
++header["x86_32"] = """
++#define __i386___X86_32 1
++#pragma pack(4)
++""";
++footer["x86_32"] = """
++#pragma pack()
++""";
++
++# x86_64
++inttypes["x86_64"] = {
++ "unsigned long" : "__align8__ uint64_t",
++ "long" : "__align8__ uint64_t",
++ "xen_pfn_t" : "__align8__ uint64_t",
++};
++header["x86_64"] = """
++#ifdef __GNUC__
++# define __DECL_REG(name) union { uint64_t r ## name, e ## name; }
++# define __align8__ __attribute__((aligned (8)))
++#else
++# define __DECL_REG(name) uint64_t r ## name
++# define __align8__ FIXME
++#endif
++#define __x86_64___X86_64 1
++""";
++
++# ia64
++inttypes["ia64"] = {
++ "unsigned long" : "__align8__ uint64_t",
++ "long" : "__align8__ uint64_t",
++ "xen_pfn_t" : "__align8__ uint64_t",
++ "long double" : "__align16__ ldouble_t",
++};
++header["ia64"] = """
++#define __align8__ __attribute__((aligned (8)))
++#define __align16__ __attribute__((aligned (16)))
++typedef unsigned char ldouble_t[16];
++""";
++
++
++###########################################################################
++# main
++
++input = "";
++output = "";
++fileid = re.sub("[-.]", "_", "__FOREIGN_%s__" % outfile.upper());
++
++# read input header files
++for name in infiles:
++ f = open(name, "r");
++ input += f.read();
++ f.close();
++
++# add header
++output += """
++/*
++ * public xen defines and struct for %s
++ * generated by %s -- DO NOT EDIT
++ */
++
++#ifndef %s
++#define %s 1
++
++""" % (arch, sys.argv[0], fileid, fileid)
++
++if arch in header:
++ output += header[arch];
++ output += "\n";
++
++# add defines to output
++for line in re.findall("#define[^\n]+", input):
++ for define in defines:
++ regex = "#define\s+%s\\b" % define;
++ match = re.search(regex, line);
++ if None == match:
++ continue;
++ if define.upper()[0] == define[0]:
++ replace = define + "_" + arch.upper();
++ else:
++ replace = define + "_" + arch;
++ regex = "\\b%s\\b" % define;
++ output += re.sub(regex, replace, line) + "\n";
++output += "\n";
++
++# delete defines, comments, empty lines
++input = re.sub("#define[^\n]+\n", "", input);
++input = re.compile("/\*(.*?)\*/", re.S).sub("", input)
++input = re.compile("\n\s*\n", re.S).sub("\n", input);
++
++# add structs to output
++for struct in structs:
++ regex = "struct\s+%s\s*\{(.*?)\n\};" % struct;
++ match = re.search(regex, input, re.S)
++ if None == match:
++ output += "#define %s_has_no_%s 1\n" % (arch, struct);
++ else:
++ output += "struct %s_%s {%s\n};\n" % (struct, arch, match.group(1));
++ output += "typedef struct %s_%s %s_%s_t;\n" % (struct, arch, struct, arch);
++ output += "\n";
++
++# add footer
++if arch in footer:
++ output += footer[arch];
++ output += "\n";
++output += "#endif /* %s */\n" % fileid;
++
++# replace: defines
++for define in defines:
++ if define.upper()[0] == define[0]:
++ replace = define + "_" + arch.upper();
++ else:
++ replace = define + "_" + arch;
++ output = re.sub("\\b%s\\b" % define, replace, output);
++
++# replace: structs + struct typedefs
++for struct in structs:
++ output = re.sub("\\b(struct\s+%s)\\b" % struct, "\\1_%s" % arch, output);
++ output = re.sub("\\b(%s)_t\\b" % struct, "\\1_%s_t" % arch, output);
++
++# replace: integer types
++integers = inttypes[arch].keys();
++integers.sort(lambda a, b: cmp(len(b),len(a)));
++for type in integers:
++ output = re.sub("\\b%s\\b" % type, inttypes[arch][type], output);
++
++# print results
++f = open(outfile, "w");
++f.write(output);
++f.close;
++
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/xen/interface/foreign/reference.size
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/include/xen/interface/foreign/reference.size Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,17 @@
++
++structs | x86_32 x86_64 ia64
++
++start_info | 1104 1152 1152
++trap_info | 8 16 -
++pt_fpreg | - - 16
++cpu_user_regs | 68 200 496
++xen_ia64_boot_param | - - 96
++ia64_tr_entry | - - 32
++vcpu_extra_regs | - - 536
++vcpu_guest_context | 2800 5168 1056
++arch_vcpu_info | 24 16 0
++vcpu_time_info | 32 32 32
++vcpu_info | 64 64 48
++arch_shared_info | 268 280 272
++shared_info | 2584 3368 4384
++
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/xen/interface/foreign/structs.py
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/include/xen/interface/foreign/structs.py Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,54 @@
++# configuration: what needs translation
++
++structs = [ "start_info",
++ "trap_info",
++ "pt_fpreg",
++ "cpu_user_regs",
++ "xen_ia64_boot_param",
++ "ia64_tr_entry",
++ "vcpu_extra_regs",
++ "vcpu_guest_context",
++ "arch_vcpu_info",
++ "vcpu_time_info",
++ "vcpu_info",
++ "arch_shared_info",
++ "shared_info" ];
++
++defines = [ "__i386__",
++ "__x86_64__",
++
++ "FLAT_RING1_CS",
++ "FLAT_RING1_DS",
++ "FLAT_RING1_SS",
++
++ "FLAT_RING3_CS64",
++ "FLAT_RING3_DS64",
++ "FLAT_RING3_SS64",
++ "FLAT_KERNEL_CS64",
++ "FLAT_KERNEL_DS64",
++ "FLAT_KERNEL_SS64",
++
++ "FLAT_KERNEL_CS",
++ "FLAT_KERNEL_DS",
++ "FLAT_KERNEL_SS",
++
++ # x86_{32,64}
++ "_VGCF_i387_valid",
++ "VGCF_i387_valid",
++ "_VGCF_in_kernel",
++ "VGCF_in_kernel",
++ "_VGCF_failsafe_disables_events",
++ "VGCF_failsafe_disables_events",
++ "_VGCF_syscall_disables_events",
++ "VGCF_syscall_disables_events",
++ "_VGCF_online",
++ "VGCF_online",
++
++ # ia64
++ "VGCF_EXTRA_REGS",
++
++ # all archs
++ "xen_pfn_to_cr3",
++ "MAX_VIRT_CPUS",
++ "MAX_GUEST_CMDLINE" ];
++
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/xen/interface/grant_table.h
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/include/xen/interface/grant_table.h Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,399 @@
+/******************************************************************************
+ * grant_table.h
+ *
@@ -89671,6 +86628,25 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+} gnttab_copy_t;
+DEFINE_XEN_GUEST_HANDLE(gnttab_copy_t);
+
++/*
++ * GNTTABOP_query_size: Query the current and maximum sizes of the shared
++ * grant table.
++ * NOTES:
++ * 1. <dom> may be specified as DOMID_SELF.
++ * 2. Only a sufficiently-privileged domain may specify <dom> != DOMID_SELF.
++ */
++#define GNTTABOP_query_size 6
++struct gnttab_query_size {
++ /* IN parameters. */
++ domid_t dom;
++ /* OUT parameters. */
++ uint32_t nr_frames;
++ uint32_t max_nr_frames;
++ int16_t status; /* GNTST_* */
++};
++typedef struct gnttab_query_size gnttab_query_size_t;
++DEFINE_XEN_GUEST_HANDLE(gnttab_query_size_t);
++
+
+/*
+ * Bitfield values for update_pin_status.flags.
@@ -89740,9 +86716,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ * indent-tabs-mode: nil
+ * End:
+ */
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/xen/interface/hvm/e820.h source/include/xen/interface/hvm/e820.h
---- /scratch/src/linux-2.6.20.3/include/xen/interface/hvm/e820.h 1970-01-01 01:00:00.000000000 +0100
-+++ source/include/xen/interface/hvm/e820.h 2007-03-20 21:27:03.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/xen/interface/hvm/e820.h
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/include/xen/interface/hvm/e820.h Wed Aug 08 16:25:28 2007 -0300
@@ -0,0 +1,47 @@
+
+/*
@@ -89791,9 +86767,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#define HVM_BELOW_4G_MMIO_LENGTH ((1ULL << 32) - HVM_BELOW_4G_MMIO_START)
+
+#endif /* __XEN_PUBLIC_HVM_E820_H__ */
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/xen/interface/hvm/hvm_info_table.h source/include/xen/interface/hvm/hvm_info_table.h
---- /scratch/src/linux-2.6.20.3/include/xen/interface/hvm/hvm_info_table.h 1970-01-01 01:00:00.000000000 +0100
-+++ source/include/xen/interface/hvm/hvm_info_table.h 2007-03-20 21:27:03.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/xen/interface/hvm/hvm_info_table.h
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/include/xen/interface/hvm/hvm_info_table.h Wed Aug 08 16:25:28 2007 -0300
@@ -0,0 +1,41 @@
+/******************************************************************************
+ * hvm/hvm_info_table.h
@@ -89836,10 +86812,30 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+};
+
+#endif /* __XEN_PUBLIC_HVM_HVM_INFO_TABLE_H__ */
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/xen/interface/hvm/hvm_op.h source/include/xen/interface/hvm/hvm_op.h
---- /scratch/src/linux-2.6.20.3/include/xen/interface/hvm/hvm_op.h 1970-01-01 01:00:00.000000000 +0100
-+++ source/include/xen/interface/hvm/hvm_op.h 2007-03-20 21:27:03.000000000 +0100
-@@ -0,0 +1,53 @@
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/xen/interface/hvm/hvm_op.h
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/include/xen/interface/hvm/hvm_op.h Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,73 @@
++/*
++ * Permission is hereby granted, free of charge, to any person obtaining a copy
++ * of this software and associated documentation files (the "Software"), to
++ * deal in the Software without restriction, including without limitation the
++ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
++ * sell copies of the Software, and to permit persons to whom the Software is
++ * furnished to do so, subject to the following conditions:
++ *
++ * The above copyright notice and this permission notice shall be included in
++ * all copies or substantial portions of the Software.
++ *
++ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
++ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
++ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
++ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
++ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
++ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
++ * DEALINGS IN THE SOFTWARE.
++ */
++
+#ifndef __XEN_PUBLIC_HVM_HVM_OP_H__
+#define __XEN_PUBLIC_HVM_HVM_OP_H__
+
@@ -89893,10 +86889,10 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+DEFINE_XEN_GUEST_HANDLE(xen_hvm_set_pci_link_route_t);
+
+#endif /* __XEN_PUBLIC_HVM_HVM_OP_H__ */
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/xen/interface/hvm/ioreq.h source/include/xen/interface/hvm/ioreq.h
---- /scratch/src/linux-2.6.20.3/include/xen/interface/hvm/ioreq.h 1970-01-01 01:00:00.000000000 +0100
-+++ source/include/xen/interface/hvm/ioreq.h 2007-03-20 21:27:03.000000000 +0100
-@@ -0,0 +1,97 @@
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/xen/interface/hvm/ioreq.h
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/include/xen/interface/hvm/ioreq.h Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,122 @@
+/*
+ * ioreq.h: I/O request definitions for device models
+ * Copyright (c) 2004, Intel Corporation.
@@ -89938,6 +86934,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#define IOREQ_TYPE_XOR 4
+#define IOREQ_TYPE_XCHG 5
+#define IOREQ_TYPE_ADD 6
++#define IOREQ_TYPE_TIMEOFFSET 7
++#define IOREQ_TYPE_INVALIDATE 8 /* mapcache */
++#define IOREQ_TYPE_SUB 9
+
+/*
+ * VMExit dispatcher should cooperate with instruction decoder to
@@ -89955,14 +86954,16 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ uint8_t dir:1; /* 1=read, 0=write */
+ uint8_t df:1;
+ uint8_t type; /* I/O type */
++ uint8_t _pad0[6];
+ uint64_t io_count; /* How many IO done on a vcpu */
+};
+typedef struct ioreq ioreq_t;
+
+struct vcpu_iodata {
-+ struct ioreq vp_ioreq;
-+ /* Event channel port */
-+ unsigned int vp_eport; /* VMX vcpu uses this to notify DM */
++ struct ioreq vp_ioreq;
++ /* Event channel port, used for notifications to/from the device model. */
++ uint32_t vp_eport;
++ uint32_t _pad0;
+};
+typedef struct vcpu_iodata vcpu_iodata_t;
+
@@ -89973,15 +86974,35 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+
+#define IOREQ_BUFFER_SLOT_NUM 80
+struct buffered_iopage {
-+ unsigned long read_pointer;
-+ unsigned long write_pointer;
++ unsigned int read_pointer;
++ unsigned int write_pointer;
+ ioreq_t ioreq[IOREQ_BUFFER_SLOT_NUM];
-+}; /* sizeof this structure must be in one page */
++}; /* NB. Size of this structure must be no greater than one page. */
+typedef struct buffered_iopage buffered_iopage_t;
+
++#if defined(__ia64__)
++struct pio_buffer {
++ uint32_t page_offset;
++ uint32_t pointer;
++ uint32_t data_end;
++ uint32_t buf_size;
++ void *opaque;
++};
++
++#define PIO_BUFFER_IDE_PRIMARY 0 /* I/O port = 0x1F0 */
++#define PIO_BUFFER_IDE_SECONDARY 1 /* I/O port = 0x170 */
++#define PIO_BUFFER_ENTRY_NUM 2
++struct buffered_piopage {
++ struct pio_buffer pio[PIO_BUFFER_ENTRY_NUM];
++ uint8_t buffer[1];
++};
++#endif /* defined(__ia64__) */
++
++#if defined(__i386__) || defined(__x86_64__)
+#define ACPI_PM1A_EVT_BLK_ADDRESS 0x0000000000001f40
+#define ACPI_PM1A_CNT_BLK_ADDRESS (ACPI_PM1A_EVT_BLK_ADDRESS + 0x04)
+#define ACPI_PM_TMR_BLK_ADDRESS (ACPI_PM1A_EVT_BLK_ADDRESS + 0x08)
++#endif /* defined(__i386__) || defined(__x86_64__) */
+
+#endif /* _IOREQ_H_ */
+
@@ -89994,11 +87015,10 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ * indent-tabs-mode: nil
+ * End:
+ */
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/xen/interface/hvm/params.h source/include/xen/interface/hvm/params.h
---- /scratch/src/linux-2.6.20.3/include/xen/interface/hvm/params.h 1970-01-01 01:00:00.000000000 +0100
-+++ source/include/xen/interface/hvm/params.h 2007-03-20 21:27:03.000000000 +0100
-@@ -0,0 +1,36 @@
-+
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/xen/interface/hvm/params.h
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/include/xen/interface/hvm/params.h Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,55 @@
+/*
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
@@ -90024,19 +87044,505 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+
+#include "hvm_op.h"
+
-+/* Parameter space for HVMOP_{set,get}_param. */
++/*
++ * Parameter space for HVMOP_{set,get}_param.
++ */
++
++/*
++ * How should CPU0 event-channel notifications be delivered?
++ * val[63:56] == 0: val[55:0] is a delivery GSI (Global System Interrupt).
++ * val[63:56] == 1: val[55:0] is a delivery PCI INTx line, as follows:
++ * Domain = val[47:32], Bus = val[31:16],
++ * DevFn = val[15: 8], IntX = val[ 1: 0]
++ * If val == 0 then CPU0 event-channel notifications are not delivered.
++ */
+#define HVM_PARAM_CALLBACK_IRQ 0
++
++/*
++ * These are not used by Xen. They are here for convenience of HVM-guest
++ * xenbus implementations.
++ */
+#define HVM_PARAM_STORE_PFN 1
+#define HVM_PARAM_STORE_EVTCHN 2
++
+#define HVM_PARAM_PAE_ENABLED 4
++
+#define HVM_PARAM_IOREQ_PFN 5
++
+#define HVM_PARAM_BUFIOREQ_PFN 6
++
+#define HVM_NR_PARAMS 7
+
+#endif /* __XEN_PUBLIC_HVM_PARAMS_H__ */
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/xen/interface/hvm/vmx_assist.h source/include/xen/interface/hvm/vmx_assist.h
---- /scratch/src/linux-2.6.20.3/include/xen/interface/hvm/vmx_assist.h 1970-01-01 01:00:00.000000000 +0100
-+++ source/include/xen/interface/hvm/vmx_assist.h 2007-03-20 21:27:03.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/xen/interface/hvm/save.h
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/include/xen/interface/hvm/save.h Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,462 @@
++/*
++ * hvm/save.h
++ *
++ * Structure definitions for HVM state that is held by Xen and must
++ * be saved along with the domain's memory and device-model state.
++ *
++ *
++ * Copyright (c) 2007 XenSource Ltd.
++ *
++ * Permission is hereby granted, free of charge, to any person obtaining a copy
++ * of this software and associated documentation files (the "Software"), to
++ * deal in the Software without restriction, including without limitation the
++ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
++ * sell copies of the Software, and to permit persons to whom the Software is
++ * furnished to do so, subject to the following conditions:
++ *
++ * The above copyright notice and this permission notice shall be included in
++ * all copies or substantial portions of the Software.
++ *
++ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
++ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
++ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
++ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
++ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
++ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
++ * DEALINGS IN THE SOFTWARE.
++ */
++
++#ifndef __XEN_PUBLIC_HVM_SAVE_H__
++#define __XEN_PUBLIC_HVM_SAVE_H__
++
++/*
++ * Structures in this header *must* have the same layout in 32bit
++ * and 64bit environments: this means that all fields must be explicitly
++ * sized types and aligned to their sizes, and the structs must be
++ * a multiple of eight bytes long.
++ *
++ * Only the state necessary for saving and restoring (i.e. fields
++ * that are analogous to actual hardware state) should go in this file.
++ * Internal mechanisms should be kept in Xen-private headers.
++ */
++
++/*
++ * Each entry is preceded by a descriptor giving its type and length
++ */
++struct hvm_save_descriptor {
++ uint16_t typecode; /* Used to demux the various types below */
++ uint16_t instance; /* Further demux within a type */
++ uint32_t length; /* In bytes, *not* including this descriptor */
++};
++
++
++/*
++ * Each entry has a datatype associated with it: for example, the CPU state
++ * is saved as a HVM_SAVE_TYPE(CPU), which has HVM_SAVE_LENGTH(CPU),
++ * and is identified by a descriptor with typecode HVM_SAVE_CODE(CPU).
++ * DECLARE_HVM_SAVE_TYPE binds these things together with some type-system
++ * ugliness.
++ */
++
++#define DECLARE_HVM_SAVE_TYPE(_x, _code, _type) \
++ struct __HVM_SAVE_TYPE_##_x { _type t; char c[_code]; }
++
++#define HVM_SAVE_TYPE(_x) typeof (((struct __HVM_SAVE_TYPE_##_x *)(0))->t)
++#define HVM_SAVE_LENGTH(_x) (sizeof (HVM_SAVE_TYPE(_x)))
++#define HVM_SAVE_CODE(_x) (sizeof (((struct __HVM_SAVE_TYPE_##_x *)(0))->c))
++
++
++/*
++ * Save/restore header: general info about the save file.
++ */
++
++#define HVM_FILE_MAGIC 0x54381286
++#define HVM_FILE_VERSION 0x00000001
++
++struct hvm_save_header {
++ uint32_t magic; /* Must be HVM_FILE_MAGIC */
++ uint32_t version; /* File format version */
++ uint64_t changeset; /* Version of Xen that saved this file */
++ uint32_t cpuid; /* CPUID[0x01][%eax] on the saving machine */
++ uint32_t pad0;
++};
++
++DECLARE_HVM_SAVE_TYPE(HEADER, 1, struct hvm_save_header);
++
++
++/*
++ * Processor
++ */
++
++struct hvm_hw_cpu {
++ uint8_t fpu_regs[512];
++
++ uint64_t rax;
++ uint64_t rbx;
++ uint64_t rcx;
++ uint64_t rdx;
++ uint64_t rbp;
++ uint64_t rsi;
++ uint64_t rdi;
++ uint64_t rsp;
++ uint64_t r8;
++ uint64_t r9;
++ uint64_t r10;
++ uint64_t r11;
++ uint64_t r12;
++ uint64_t r13;
++ uint64_t r14;
++ uint64_t r15;
++
++ uint64_t rip;
++ uint64_t rflags;
++
++ uint64_t cr0;
++ uint64_t cr2;
++ uint64_t cr3;
++ uint64_t cr4;
++
++ uint64_t dr0;
++ uint64_t dr1;
++ uint64_t dr2;
++ uint64_t dr3;
++ uint64_t dr6;
++ uint64_t dr7;
++
++ uint32_t cs_sel;
++ uint32_t ds_sel;
++ uint32_t es_sel;
++ uint32_t fs_sel;
++ uint32_t gs_sel;
++ uint32_t ss_sel;
++ uint32_t tr_sel;
++ uint32_t ldtr_sel;
++
++ uint32_t cs_limit;
++ uint32_t ds_limit;
++ uint32_t es_limit;
++ uint32_t fs_limit;
++ uint32_t gs_limit;
++ uint32_t ss_limit;
++ uint32_t tr_limit;
++ uint32_t ldtr_limit;
++ uint32_t idtr_limit;
++ uint32_t gdtr_limit;
++
++ uint64_t cs_base;
++ uint64_t ds_base;
++ uint64_t es_base;
++ uint64_t fs_base;
++ uint64_t gs_base;
++ uint64_t ss_base;
++ uint64_t tr_base;
++ uint64_t ldtr_base;
++ uint64_t idtr_base;
++ uint64_t gdtr_base;
++
++ uint32_t cs_arbytes;
++ uint32_t ds_arbytes;
++ uint32_t es_arbytes;
++ uint32_t fs_arbytes;
++ uint32_t gs_arbytes;
++ uint32_t ss_arbytes;
++ uint32_t tr_arbytes;
++ uint32_t ldtr_arbytes;
++
++ uint32_t sysenter_cs;
++ uint32_t padding0;
++
++ uint64_t sysenter_esp;
++ uint64_t sysenter_eip;
++
++ /* msr for em64t */
++ uint64_t shadow_gs;
++
++ /* msr content saved/restored. */
++ uint64_t msr_flags;
++ uint64_t msr_lstar;
++ uint64_t msr_star;
++ uint64_t msr_cstar;
++ uint64_t msr_syscall_mask;
++ uint64_t msr_efer;
++
++ /* guest's idea of what rdtsc() would return */
++ uint64_t tsc;
++
++ /* pending event, if any */
++ union {
++ uint32_t pending_event;
++ struct {
++ uint8_t pending_vector:8;
++ uint8_t pending_type:3;
++ uint8_t pending_error_valid:1;
++ uint32_t pending_reserved:19;
++ uint8_t pending_valid:1;
++ };
++ };
++ /* error code for pending event */
++ uint32_t error_code;
++};
++
++DECLARE_HVM_SAVE_TYPE(CPU, 2, struct hvm_hw_cpu);
++
++
++/*
++ * PIC
++ */
++
++struct hvm_hw_vpic {
++ /* IR line bitmasks. */
++ uint8_t irr;
++ uint8_t imr;
++ uint8_t isr;
++
++ /* Line IRx maps to IRQ irq_base+x */
++ uint8_t irq_base;
++
++ /*
++ * Where are we in ICW2-4 initialisation (0 means no init in progress)?
++ * Bits 0-1 (=x): Next write at A=1 sets ICW(x+1).
++ * Bit 2: ICW1.IC4 (1 == ICW4 included in init sequence)
++ * Bit 3: ICW1.SNGL (0 == ICW3 included in init sequence)
++ */
++ uint8_t init_state:4;
++
++ /* IR line with highest priority. */
++ uint8_t priority_add:4;
++
++ /* Reads from A=0 obtain ISR or IRR? */
++ uint8_t readsel_isr:1;
++
++ /* Reads perform a polling read? */
++ uint8_t poll:1;
++
++ /* Automatically clear IRQs from the ISR during INTA? */
++ uint8_t auto_eoi:1;
++
++ /* Automatically rotate IRQ priorities during AEOI? */
++ uint8_t rotate_on_auto_eoi:1;
++
++ /* Exclude slave inputs when considering in-service IRQs? */
++ uint8_t special_fully_nested_mode:1;
++
++ /* Special mask mode excludes masked IRs from AEOI and priority checks. */
++ uint8_t special_mask_mode:1;
++
++ /* Is this a master PIC or slave PIC? (NB. This is not programmable.) */
++ uint8_t is_master:1;
++
++ /* Edge/trigger selection. */
++ uint8_t elcr;
++
++ /* Virtual INT output. */
++ uint8_t int_output;
++};
++
++DECLARE_HVM_SAVE_TYPE(PIC, 3, struct hvm_hw_vpic);
++
++
++/*
++ * IO-APIC
++ */
++
++#ifdef __ia64__
++#define VIOAPIC_IS_IOSAPIC 1
++#define VIOAPIC_NUM_PINS 24
++#else
++#define VIOAPIC_NUM_PINS 48 /* 16 ISA IRQs, 32 non-legacy PCI IRQS. */
++#endif
++
++struct hvm_hw_vioapic {
++ uint64_t base_address;
++ uint32_t ioregsel;
++ uint32_t id;
++ union vioapic_redir_entry
++ {
++ uint64_t bits;
++ struct {
++ uint8_t vector;
++ uint8_t delivery_mode:3;
++ uint8_t dest_mode:1;
++ uint8_t delivery_status:1;
++ uint8_t polarity:1;
++ uint8_t remote_irr:1;
++ uint8_t trig_mode:1;
++ uint8_t mask:1;
++ uint8_t reserve:7;
++#if !VIOAPIC_IS_IOSAPIC
++ uint8_t reserved[4];
++ uint8_t dest_id;
++#else
++ uint8_t reserved[3];
++ uint16_t dest_id;
++#endif
++ } fields;
++ } redirtbl[VIOAPIC_NUM_PINS];
++};
++
++DECLARE_HVM_SAVE_TYPE(IOAPIC, 4, struct hvm_hw_vioapic);
++
++
++/*
++ * LAPIC
++ */
++
++struct hvm_hw_lapic {
++ uint64_t apic_base_msr;
++ uint32_t disabled; /* VLAPIC_xx_DISABLED */
++ uint32_t timer_divisor;
++};
++
++DECLARE_HVM_SAVE_TYPE(LAPIC, 5, struct hvm_hw_lapic);
++
++struct hvm_hw_lapic_regs {
++ /* A 4k page of register state */
++ uint8_t data[0x400];
++};
++
++DECLARE_HVM_SAVE_TYPE(LAPIC_REGS, 6, struct hvm_hw_lapic_regs);
++
++
++/*
++ * IRQs
++ */
++
++struct hvm_hw_pci_irqs {
++ /*
++ * Virtual interrupt wires for a single PCI bus.
++ * Indexed by: device*4 + INTx#.
++ */
++ union {
++ DECLARE_BITMAP(i, 32*4);
++ uint64_t pad[2];
++ };
++};
++
++DECLARE_HVM_SAVE_TYPE(PCI_IRQ, 7, struct hvm_hw_pci_irqs);
++
++struct hvm_hw_isa_irqs {
++ /*
++ * Virtual interrupt wires for ISA devices.
++ * Indexed by ISA IRQ (assumes no ISA-device IRQ sharing).
++ */
++ union {
++ DECLARE_BITMAP(i, 16);
++ uint64_t pad[1];
++ };
++};
++
++DECLARE_HVM_SAVE_TYPE(ISA_IRQ, 8, struct hvm_hw_isa_irqs);
++
++struct hvm_hw_pci_link {
++ /*
++ * PCI-ISA interrupt router.
++ * Each PCI <device:INTx#> is 'wire-ORed' into one of four links using
++ * the traditional 'barber's pole' mapping ((device + INTx#) & 3).
++ * The router provides a programmable mapping from each link to a GSI.
++ */
++ uint8_t route[4];
++ uint8_t pad0[4];
++};
++
++DECLARE_HVM_SAVE_TYPE(PCI_LINK, 9, struct hvm_hw_pci_link);
++
++/*
++ * PIT
++ */
++
++struct hvm_hw_pit {
++ struct hvm_hw_pit_channel {
++ uint32_t count; /* can be 65536 */
++ uint16_t latched_count;
++ uint8_t count_latched;
++ uint8_t status_latched;
++ uint8_t status;
++ uint8_t read_state;
++ uint8_t write_state;
++ uint8_t write_latch;
++ uint8_t rw_mode;
++ uint8_t mode;
++ uint8_t bcd; /* not supported */
++ uint8_t gate; /* timer start */
++ } channels[3]; /* 3 x 16 bytes */
++ uint32_t speaker_data_on;
++ uint32_t pad0;
++};
++
++DECLARE_HVM_SAVE_TYPE(PIT, 10, struct hvm_hw_pit);
++
++
++/*
++ * RTC
++ */
++
++#define RTC_CMOS_SIZE 14
++struct hvm_hw_rtc {
++ /* CMOS bytes */
++ uint8_t cmos_data[RTC_CMOS_SIZE];
++ /* Index register for 2-part operations */
++ uint8_t cmos_index;
++ uint8_t pad0;
++};
++
++DECLARE_HVM_SAVE_TYPE(RTC, 11, struct hvm_hw_rtc);
++
++
++/*
++ * HPET
++ */
++
++#define HPET_TIMER_NUM 3 /* 3 timers supported now */
++struct hvm_hw_hpet {
++ /* Memory-mapped, software visible registers */
++ uint64_t capability; /* capabilities */
++ uint64_t res0; /* reserved */
++ uint64_t config; /* configuration */
++ uint64_t res1; /* reserved */
++ uint64_t isr; /* interrupt status reg */
++ uint64_t res2[25]; /* reserved */
++ uint64_t mc64; /* main counter */
++ uint64_t res3; /* reserved */
++ struct { /* timers */
++ uint64_t config; /* configuration/cap */
++ uint64_t cmp; /* comparator */
++ uint64_t fsb; /* FSB route, not supported now */
++ uint64_t res4; /* reserved */
++ } timers[HPET_TIMER_NUM];
++ uint64_t res5[4*(24-HPET_TIMER_NUM)]; /* reserved, up to 0x3ff */
++
++ /* Hidden register state */
++ uint64_t period[HPET_TIMER_NUM]; /* Last value written to comparator */
++};
++
++DECLARE_HVM_SAVE_TYPE(HPET, 12, struct hvm_hw_hpet);
++
++
++/*
++ * PM timer
++ */
++
++struct hvm_hw_pmtimer {
++ uint32_t tmr_val; /* PM_TMR_BLK.TMR_VAL: 32bit free-running counter */
++ uint16_t pm1a_sts; /* PM1a_EVT_BLK.PM1a_STS: status register */
++ uint16_t pm1a_en; /* PM1a_EVT_BLK.PM1a_EN: enable register */
++};
++
++DECLARE_HVM_SAVE_TYPE(PMTIMER, 13, struct hvm_hw_pmtimer);
++
++/*
++ * Largest type-code in use
++ */
++#define HVM_SAVE_CODE_MAX 13
++
++
++/*
++ * The series of save records is teminated by a zero-type, zero-length
++ * descriptor.
++ */
++
++struct hvm_save_end {};
++DECLARE_HVM_SAVE_TYPE(END, 0, struct hvm_save_end);
++
++#endif /* __XEN_PUBLIC_HVM_SAVE_H__ */
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/xen/interface/hvm/vmx_assist.h
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/include/xen/interface/hvm/vmx_assist.h Wed Aug 08 16:25:28 2007 -0300
@@ -0,0 +1,116 @@
+/*
+ * vmx_assist.h: Context definitions for the VMXASSIST world switch.
@@ -90154,10 +87660,10 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ * indent-tabs-mode: nil
+ * End:
+ */
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/xen/interface/io/blkif.h source/include/xen/interface/io/blkif.h
---- /scratch/src/linux-2.6.20.3/include/xen/interface/io/blkif.h 1970-01-01 01:00:00.000000000 +0100
-+++ source/include/xen/interface/io/blkif.h 2007-03-20 21:27:03.000000000 +0100
-@@ -0,0 +1,126 @@
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/xen/interface/io/blkif.h
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/include/xen/interface/io/blkif.h Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,128 @@
+/******************************************************************************
+ * blkif.h
+ *
@@ -90231,18 +87737,20 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ */
+#define BLKIF_MAX_SEGMENTS_PER_REQUEST 11
+
++struct blkif_request_segment {
++ grant_ref_t gref; /* reference to I/O buffer frame */
++ /* @first_sect: first sector in frame to transfer (inclusive). */
++ /* @last_sect: last sector in frame to transfer (inclusive). */
++ uint8_t first_sect, last_sect;
++};
++
+struct blkif_request {
+ uint8_t operation; /* BLKIF_OP_??? */
+ uint8_t nr_segments; /* number of segments */
+ blkif_vdev_t handle; /* only for read/write requests */
+ uint64_t id; /* private guest value, echoed in resp */
+ blkif_sector_t sector_number;/* start sector idx on disk (r/w only) */
-+ struct blkif_request_segment {
-+ grant_ref_t gref; /* reference to I/O buffer frame */
-+ /* @first_sect: first sector in frame to transfer (inclusive). */
-+ /* @last_sect: last sector in frame to transfer (inclusive). */
-+ uint8_t first_sect, last_sect;
-+ } seg[BLKIF_MAX_SEGMENTS_PER_REQUEST];
++ struct blkif_request_segment seg[BLKIF_MAX_SEGMENTS_PER_REQUEST];
+};
+typedef struct blkif_request blkif_request_t;
+
@@ -90284,9 +87792,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ * indent-tabs-mode: nil
+ * End:
+ */
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/xen/interface/io/console.h source/include/xen/interface/io/console.h
---- /scratch/src/linux-2.6.20.3/include/xen/interface/io/console.h 1970-01-01 01:00:00.000000000 +0100
-+++ source/include/xen/interface/io/console.h 2007-03-20 21:27:03.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/xen/interface/io/console.h
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/include/xen/interface/io/console.h Wed Aug 08 16:25:28 2007 -0300
@@ -0,0 +1,51 @@
+/******************************************************************************
+ * console.h
@@ -90339,9 +87847,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ * indent-tabs-mode: nil
+ * End:
+ */
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/xen/interface/io/fbif.h source/include/xen/interface/io/fbif.h
---- /scratch/src/linux-2.6.20.3/include/xen/interface/io/fbif.h 1970-01-01 01:00:00.000000000 +0100
-+++ source/include/xen/interface/io/fbif.h 2007-03-20 21:27:03.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/xen/interface/io/fbif.h
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/include/xen/interface/io/fbif.h Wed Aug 08 16:25:28 2007 -0300
@@ -0,0 +1,138 @@
+/*
+ * fbif.h -- Xen virtual frame buffer device
@@ -90481,9 +87989,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ * indent-tabs-mode: nil
+ * End:
+ */
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/xen/interface/io/kbdif.h source/include/xen/interface/io/kbdif.h
---- /scratch/src/linux-2.6.20.3/include/xen/interface/io/kbdif.h 1970-01-01 01:00:00.000000000 +0100
-+++ source/include/xen/interface/io/kbdif.h 2007-03-20 21:27:03.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/xen/interface/io/kbdif.h
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/include/xen/interface/io/kbdif.h Wed Aug 08 16:25:28 2007 -0300
@@ -0,0 +1,130 @@
+/*
+ * kbdif.h -- Xen virtual keyboard/mouse
@@ -90615,9 +88123,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ * indent-tabs-mode: nil
+ * End:
+ */
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/xen/interface/io/netif.h source/include/xen/interface/io/netif.h
---- /scratch/src/linux-2.6.20.3/include/xen/interface/io/netif.h 1970-01-01 01:00:00.000000000 +0100
-+++ source/include/xen/interface/io/netif.h 2007-03-20 21:27:03.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/xen/interface/io/netif.h
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/include/xen/interface/io/netif.h Wed Aug 08 16:25:28 2007 -0300
@@ -0,0 +1,184 @@
+/******************************************************************************
+ * netif.h
@@ -90803,9 +88311,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ * indent-tabs-mode: nil
+ * End:
+ */
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/xen/interface/io/pciif.h source/include/xen/interface/io/pciif.h
---- /scratch/src/linux-2.6.20.3/include/xen/interface/io/pciif.h 1970-01-01 01:00:00.000000000 +0100
-+++ source/include/xen/interface/io/pciif.h 2007-03-20 21:27:03.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/xen/interface/io/pciif.h
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/include/xen/interface/io/pciif.h Wed Aug 08 16:25:28 2007 -0300
@@ -0,0 +1,83 @@
+/*
+ * PCI Backend/Frontend Common Data Structures & Macros
@@ -90890,9 +88398,34 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ * indent-tabs-mode: nil
+ * End:
+ */
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/xen/interface/io/ring.h source/include/xen/interface/io/ring.h
---- /scratch/src/linux-2.6.20.3/include/xen/interface/io/ring.h 1970-01-01 01:00:00.000000000 +0100
-+++ source/include/xen/interface/io/ring.h 2007-03-20 21:27:03.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/xen/interface/io/protocols.h
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/include/xen/interface/io/protocols.h Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,21 @@
++#ifndef __XEN_PROTOCOLS_H__
++#define __XEN_PROTOCOLS_H__
++
++#define XEN_IO_PROTO_ABI_X86_32 "x86_32-abi"
++#define XEN_IO_PROTO_ABI_X86_64 "x86_64-abi"
++#define XEN_IO_PROTO_ABI_IA64 "ia64-abi"
++#define XEN_IO_PROTO_ABI_POWERPC64 "powerpc64-abi"
++
++#if defined(__i386__)
++# define XEN_IO_PROTO_ABI_NATIVE XEN_IO_PROTO_ABI_X86_32
++#elif defined(__x86_64__)
++# define XEN_IO_PROTO_ABI_NATIVE XEN_IO_PROTO_ABI_X86_64
++#elif defined(__ia64__)
++# define XEN_IO_PROTO_ABI_NATIVE XEN_IO_PROTO_ABI_IA64
++#elif defined(__powerpc64__)
++# define XEN_IO_PROTO_ABI_NATIVE XEN_IO_PROTO_ABI_POWERPC64
++#else
++# error arch fixup needed here
++#endif
++
++#endif
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/xen/interface/io/ring.h
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/include/xen/interface/io/ring.h Wed Aug 08 16:25:28 2007 -0300
@@ -0,0 +1,299 @@
+/******************************************************************************
+ * ring.h
@@ -91193,9 +88726,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ * indent-tabs-mode: nil
+ * End:
+ */
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/xen/interface/io/tpmif.h source/include/xen/interface/io/tpmif.h
---- /scratch/src/linux-2.6.20.3/include/xen/interface/io/tpmif.h 1970-01-01 01:00:00.000000000 +0100
-+++ source/include/xen/interface/io/tpmif.h 2007-03-20 21:27:03.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/xen/interface/io/tpmif.h
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/include/xen/interface/io/tpmif.h Wed Aug 08 16:25:28 2007 -0300
@@ -0,0 +1,77 @@
+/******************************************************************************
+ * tpmif.h
@@ -91249,7 +88782,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ */
+typedef uint32_t TPMIF_RING_IDX;
+
-+#define TPMIF_TX_RING_SIZE 10
++#define TPMIF_TX_RING_SIZE 1
+
+/* This structure must fit in a memory page. */
+
@@ -91274,9 +88807,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ * indent-tabs-mode: nil
+ * End:
+ */
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/xen/interface/io/xenbus.h source/include/xen/interface/io/xenbus.h
---- /scratch/src/linux-2.6.20.3/include/xen/interface/io/xenbus.h 1970-01-01 01:00:00.000000000 +0100
-+++ source/include/xen/interface/io/xenbus.h 2007-03-20 21:27:03.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/xen/interface/io/xenbus.h
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/include/xen/interface/io/xenbus.h Wed Aug 08 16:25:28 2007 -0300
@@ -0,0 +1,73 @@
+/*****************************************************************************
+ * xenbus.h
@@ -91351,10 +88884,10 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ * indent-tabs-mode: nil
+ * End:
+ */
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/xen/interface/io/xs_wire.h source/include/xen/interface/io/xs_wire.h
---- /scratch/src/linux-2.6.20.3/include/xen/interface/io/xs_wire.h 1970-01-01 01:00:00.000000000 +0100
-+++ source/include/xen/interface/io/xs_wire.h 2007-03-20 21:27:03.000000000 +0100
-@@ -0,0 +1,116 @@
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/xen/interface/io/xs_wire.h
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/include/xen/interface/io/xs_wire.h Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,117 @@
+/*
+ * Details of the "wire" protocol between Xen Store Daemon and client
+ * library or guest kernel.
@@ -91402,7 +88935,8 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ XS_SET_PERMS,
+ XS_WATCH_EVENT,
+ XS_ERROR,
-+ XS_IS_DOMAIN_INTRODUCED
++ XS_IS_DOMAIN_INTRODUCED,
++ XS_RESUME
+};
+
+#define XS_WRITE_NONE "NONE"
@@ -91471,9 +89005,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ * indent-tabs-mode: nil
+ * End:
+ */
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/xen/interface/kexec.h source/include/xen/interface/kexec.h
---- /scratch/src/linux-2.6.20.3/include/xen/interface/kexec.h 1970-01-01 01:00:00.000000000 +0100
-+++ source/include/xen/interface/kexec.h 2007-03-20 21:27:03.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/xen/interface/kexec.h
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/include/xen/interface/kexec.h Wed Aug 08 16:25:28 2007 -0300
@@ -0,0 +1,137 @@
+/******************************************************************************
+ * kexec.h - Public portion
@@ -91612,10 +89146,255 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ * indent-tabs-mode: nil
+ * End:
+ */
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/xen/interface/memory.h source/include/xen/interface/memory.h
---- /scratch/src/linux-2.6.20.3/include/xen/interface/memory.h 1970-01-01 01:00:00.000000000 +0100
-+++ source/include/xen/interface/memory.h 2007-03-20 21:27:03.000000000 +0100
-@@ -0,0 +1,276 @@
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/xen/interface/libelf.h
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/include/xen/interface/libelf.h Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,241 @@
++#ifndef __XC_LIBELF__
++#define __XC_LIBELF__ 1
++
++#if defined(__i386__) || defined(__x86_64) || defined(__ia64__)
++#define XEN_ELF_LITTLE_ENDIAN
++#elif defined(__powerpc__)
++#define XEN_ELF_BIG_ENDIAN
++#else
++#error define architectural endianness
++#endif
++
++#undef ELFSIZE
++#include "elfnote.h"
++#include "elfstructs.h"
++#include "features.h"
++
++/* ------------------------------------------------------------------------ */
++
++typedef union {
++ Elf32_Ehdr e32;
++ Elf64_Ehdr e64;
++} elf_ehdr;
++
++typedef union {
++ Elf32_Phdr e32;
++ Elf64_Phdr e64;
++} elf_phdr;
++
++typedef union {
++ Elf32_Shdr e32;
++ Elf64_Shdr e64;
++} elf_shdr;
++
++typedef union {
++ Elf32_Sym e32;
++ Elf64_Sym e64;
++} elf_sym;
++
++typedef union {
++ Elf32_Rel e32;
++ Elf64_Rel e64;
++} elf_rel;
++
++typedef union {
++ Elf32_Rela e32;
++ Elf64_Rela e64;
++} elf_rela;
++
++typedef union {
++ Elf32_Note e32;
++ Elf64_Note e64;
++} elf_note;
++
++struct elf_binary {
++ /* elf binary */
++ const char *image;
++ size_t size;
++ char class;
++ char data;
++
++ const elf_ehdr *ehdr;
++ const char *sec_strtab;
++ const elf_shdr *sym_tab;
++ const char *sym_strtab;
++
++ /* loaded to */
++ char *dest;
++ uint64_t pstart;
++ uint64_t pend;
++ uint64_t reloc_offset;
++
++#ifndef __XEN__
++ /* misc */
++ FILE *log;
++#endif
++ int verbose;
++};
++
++/* ------------------------------------------------------------------------ */
++/* accessing elf header fields */
++
++#ifdef XEN_ELF_BIG_ENDIAN
++# define NATIVE_ELFDATA ELFDATA2MSB
++#else
++# define NATIVE_ELFDATA ELFDATA2LSB
++#endif
++
++#define elf_32bit(elf) (ELFCLASS32 == (elf)->class)
++#define elf_64bit(elf) (ELFCLASS64 == (elf)->class)
++#define elf_msb(elf) (ELFDATA2MSB == (elf)->data)
++#define elf_lsb(elf) (ELFDATA2LSB == (elf)->data)
++#define elf_swap(elf) (NATIVE_ELFDATA != (elf)->data)
++
++#define elf_uval(elf, str, elem) \
++ ((ELFCLASS64 == (elf)->class) \
++ ? elf_access_unsigned((elf), (str), \
++ offsetof(typeof(*(str)),e64.elem), \
++ sizeof((str)->e64.elem)) \
++ : elf_access_unsigned((elf), (str), \
++ offsetof(typeof(*(str)),e32.elem), \
++ sizeof((str)->e32.elem)))
++
++#define elf_sval(elf, str, elem) \
++ ((ELFCLASS64 == (elf)->class) \
++ ? elf_access_signed((elf), (str), \
++ offsetof(typeof(*(str)),e64.elem), \
++ sizeof((str)->e64.elem)) \
++ : elf_access_signed((elf), (str), \
++ offsetof(typeof(*(str)),e32.elem), \
++ sizeof((str)->e32.elem)))
++
++#define elf_size(elf, str) \
++ ((ELFCLASS64 == (elf)->class) \
++ ? sizeof((str)->e64) \
++ : sizeof((str)->e32))
++
++uint64_t elf_access_unsigned(struct elf_binary *elf, const void *ptr,
++ uint64_t offset, size_t size);
++int64_t elf_access_signed(struct elf_binary *elf, const void *ptr,
++ uint64_t offset, size_t size);
++
++uint64_t elf_round_up(struct elf_binary *elf, uint64_t addr);
++
++/* ------------------------------------------------------------------------ */
++/* xc_libelf_tools.c */
++
++int elf_shdr_count(struct elf_binary *elf);
++int elf_phdr_count(struct elf_binary *elf);
++
++const elf_shdr *elf_shdr_by_name(struct elf_binary *elf, const char *name);
++const elf_shdr *elf_shdr_by_index(struct elf_binary *elf, int index);
++const elf_phdr *elf_phdr_by_index(struct elf_binary *elf, int index);
++
++const char *elf_section_name(struct elf_binary *elf, const elf_shdr * shdr);
++const void *elf_section_start(struct elf_binary *elf, const elf_shdr * shdr);
++const void *elf_section_end(struct elf_binary *elf, const elf_shdr * shdr);
++
++const void *elf_segment_start(struct elf_binary *elf, const elf_phdr * phdr);
++const void *elf_segment_end(struct elf_binary *elf, const elf_phdr * phdr);
++
++const elf_sym *elf_sym_by_name(struct elf_binary *elf, const char *symbol);
++const elf_sym *elf_sym_by_index(struct elf_binary *elf, int index);
++
++const char *elf_note_name(struct elf_binary *elf, const elf_note * note);
++const void *elf_note_desc(struct elf_binary *elf, const elf_note * note);
++uint64_t elf_note_numeric(struct elf_binary *elf, const elf_note * note);
++const elf_note *elf_note_next(struct elf_binary *elf, const elf_note * note);
++
++int elf_is_elfbinary(const void *image);
++int elf_phdr_is_loadable(struct elf_binary *elf, const elf_phdr * phdr);
++
++/* ------------------------------------------------------------------------ */
++/* xc_libelf_loader.c */
++
++int elf_init(struct elf_binary *elf, const char *image, size_t size);
++#ifdef __XEN__
++void elf_set_verbose(struct elf_binary *elf);
++#else
++void elf_set_logfile(struct elf_binary *elf, FILE * log, int verbose);
++#endif
++
++void elf_parse_binary(struct elf_binary *elf);
++void elf_load_binary(struct elf_binary *elf);
++
++void *elf_get_ptr(struct elf_binary *elf, unsigned long addr);
++uint64_t elf_lookup_addr(struct elf_binary *elf, const char *symbol);
++
++/* ------------------------------------------------------------------------ */
++/* xc_libelf_relocate.c */
++
++int elf_reloc(struct elf_binary *elf);
++
++/* ------------------------------------------------------------------------ */
++/* xc_libelf_dominfo.c */
++
++#define UNSET_ADDR ((uint64_t)-1)
++
++enum xen_elfnote_type {
++ XEN_ENT_NONE = 0,
++ XEN_ENT_LONG = 1,
++ XEN_ENT_STR = 2
++};
++
++struct xen_elfnote {
++ enum xen_elfnote_type type;
++ const char *name;
++ union {
++ const char *str;
++ uint64_t num;
++ } data;
++};
++
++struct elf_dom_parms {
++ /* raw */
++ const char *guest_info;
++ const void *elf_note_start;
++ const void *elf_note_end;
++ struct xen_elfnote elf_notes[XEN_ELFNOTE_MAX + 1];
++
++ /* parsed */
++ char guest_os[16];
++ char guest_ver[16];
++ char xen_ver[16];
++ char loader[16];
++ int pae;
++ int bsd_symtab;
++ uint64_t virt_base;
++ uint64_t virt_entry;
++ uint64_t virt_hypercall;
++ uint64_t virt_hv_start_low;
++ uint64_t elf_paddr_offset;
++ uint32_t f_supported[XENFEAT_NR_SUBMAPS];
++ uint32_t f_required[XENFEAT_NR_SUBMAPS];
++
++ /* calculated */
++ uint64_t virt_offset;
++ uint64_t virt_kstart;
++ uint64_t virt_kend;
++};
++
++static inline void elf_xen_feature_set(int nr, uint32_t * addr)
++{
++ addr[nr >> 5] |= 1 << (nr & 31);
++}
++static inline int elf_xen_feature_get(int nr, uint32_t * addr)
++{
++ return !!(addr[nr >> 5] & (1 << (nr & 31)));
++}
++
++int elf_xen_parse_features(const char *features,
++ uint32_t *supported,
++ uint32_t *required);
++int elf_xen_parse_note(struct elf_binary *elf,
++ struct elf_dom_parms *parms,
++ const elf_note *note);
++int elf_xen_parse_guest_info(struct elf_binary *elf,
++ struct elf_dom_parms *parms);
++int elf_xen_parse(struct elf_binary *elf,
++ struct elf_dom_parms *parms);
++
++#endif /* __XC_LIBELF__ */
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/xen/interface/memory.h
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/include/xen/interface/memory.h Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,281 @@
+/******************************************************************************
+ * memory.h
+ *
@@ -91747,6 +89526,11 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#define XENMEM_maximum_reservation 4
+
+/*
++ * Returns the maximum GPFN in use by the guest, or -ve errcode on failure.
++ */
++#define XENMEM_maximum_gpfn 14
++
++/*
+ * Returns a list of MFN bases of 2MB extents comprising the machine_to_phys
+ * mapping table. Architectures which do not have a m2p table do not implement
+ * this command.
@@ -91892,9 +89676,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ * indent-tabs-mode: nil
+ * End:
+ */
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/xen/interface/nmi.h source/include/xen/interface/nmi.h
---- /scratch/src/linux-2.6.20.3/include/xen/interface/nmi.h 1970-01-01 01:00:00.000000000 +0100
-+++ source/include/xen/interface/nmi.h 2007-03-20 21:27:03.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/xen/interface/nmi.h
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/include/xen/interface/nmi.h Wed Aug 08 16:25:28 2007 -0300
@@ -0,0 +1,78 @@
+/******************************************************************************
+ * nmi.h
@@ -91974,9 +89758,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ * indent-tabs-mode: nil
+ * End:
+ */
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/xen/interface/physdev.h source/include/xen/interface/physdev.h
---- /scratch/src/linux-2.6.20.3/include/xen/interface/physdev.h 1970-01-01 01:00:00.000000000 +0100
-+++ source/include/xen/interface/physdev.h 2007-03-20 21:27:03.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/xen/interface/physdev.h
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/include/xen/interface/physdev.h Wed Aug 08 16:25:28 2007 -0300
@@ -0,0 +1,169 @@
+/*
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -92147,9 +89931,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ * indent-tabs-mode: nil
+ * End:
+ */
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/xen/interface/platform.h source/include/xen/interface/platform.h
---- /scratch/src/linux-2.6.20.3/include/xen/interface/platform.h 1970-01-01 01:00:00.000000000 +0100
-+++ source/include/xen/interface/platform.h 2007-03-20 21:27:03.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/xen/interface/platform.h
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/include/xen/interface/platform.h Wed Aug 08 16:25:28 2007 -0300
@@ -0,0 +1,143 @@
+/******************************************************************************
+ * platform.h
@@ -92294,9 +90078,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ * indent-tabs-mode: nil
+ * End:
+ */
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/xen/interface/sched.h source/include/xen/interface/sched.h
---- /scratch/src/linux-2.6.20.3/include/xen/interface/sched.h 1970-01-01 01:00:00.000000000 +0100
-+++ source/include/xen/interface/sched.h 2007-03-20 21:27:03.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/xen/interface/sched.h
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/include/xen/interface/sched.h Wed Aug 08 16:25:28 2007 -0300
@@ -0,0 +1,121 @@
+/******************************************************************************
+ * sched.h
@@ -92419,10 +90203,10 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ * indent-tabs-mode: nil
+ * End:
+ */
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/xen/interface/sysctl.h source/include/xen/interface/sysctl.h
---- /scratch/src/linux-2.6.20.3/include/xen/interface/sysctl.h 1970-01-01 01:00:00.000000000 +0100
-+++ source/include/xen/interface/sysctl.h 2007-03-20 21:27:03.000000000 +0100
-@@ -0,0 +1,169 @@
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/xen/interface/sysctl.h
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/include/xen/interface/sysctl.h Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,182 @@
+/******************************************************************************
+ * sysctl.h
+ *
@@ -92459,7 +90243,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#include "xen.h"
+#include "domctl.h"
+
-+#define XEN_SYSCTL_INTERFACE_VERSION 0x00000002
++#define XEN_SYSCTL_INTERFACE_VERSION 0x00000003
+
+/*
+ * Read console content from Xen buffer ring.
@@ -92468,7 +90252,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+struct xen_sysctl_readconsole {
+ /* IN variables. */
+ uint32_t clear; /* Non-zero -> clear after reading. */
-+ XEN_GUEST_HANDLE(char) buffer; /* Buffer start */
++ XEN_GUEST_HANDLE_64(char) buffer; /* Buffer start */
+ /* IN/OUT variables. */
+ uint32_t count; /* In: Buffer size; Out: Used buffer size */
+};
@@ -92490,7 +90274,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ struct xenctl_cpumap cpu_mask;
+ uint32_t evt_mask;
+ /* OUT variables */
-+ uint64_t buffer_mfn;
++ uint64_aligned_t buffer_mfn;
+ uint32_t size;
+};
+typedef struct xen_sysctl_tbuf_op xen_sysctl_tbuf_op_t;
@@ -92506,9 +90290,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ uint32_t sockets_per_node;
+ uint32_t nr_nodes;
+ uint32_t cpu_khz;
-+ uint64_t total_pages;
-+ uint64_t free_pages;
-+ uint64_t scrub_pages;
++ uint64_aligned_t total_pages;
++ uint64_aligned_t free_pages;
++ uint64_aligned_t scrub_pages;
+ uint32_t hw_cap[8];
+};
+typedef struct xen_sysctl_physinfo xen_sysctl_physinfo_t;
@@ -92546,9 +90330,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ uint32_t nr_counters; /* number of counters description */
+ uint32_t nr_vals; /* number of values */
+ /* counter information (or NULL) */
-+ XEN_GUEST_HANDLE(xen_sysctl_perfc_desc_t) desc;
++ XEN_GUEST_HANDLE_64(xen_sysctl_perfc_desc_t) desc;
+ /* counter values (or NULL) */
-+ XEN_GUEST_HANDLE(xen_sysctl_perfc_val_t) val;
++ XEN_GUEST_HANDLE_64(xen_sysctl_perfc_val_t) val;
+};
+typedef struct xen_sysctl_perfc_op xen_sysctl_perfc_op_t;
+DEFINE_XEN_GUEST_HANDLE(xen_sysctl_perfc_op_t);
@@ -92558,13 +90342,25 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ /* IN variables. */
+ domid_t first_domain;
+ uint32_t max_domains;
-+ XEN_GUEST_HANDLE(xen_domctl_getdomaininfo_t) buffer;
++ XEN_GUEST_HANDLE_64(xen_domctl_getdomaininfo_t) buffer;
+ /* OUT variables. */
+ uint32_t num_domains;
+};
+typedef struct xen_sysctl_getdomaininfolist xen_sysctl_getdomaininfolist_t;
+DEFINE_XEN_GUEST_HANDLE(xen_sysctl_getdomaininfolist_t);
+
++/*
++ * Inject debug keys into Xen.
++ */
++#define XEN_SYSCTL_debug_keys 7
++struct xen_sysctl_debug_keys {
++ /* IN variables. */
++ XEN_GUEST_HANDLE_64(char) keys;
++ uint32_t nr_keys;
++};
++typedef struct xen_sysctl_debug_keys xen_sysctl_debug_keys_t;
++DEFINE_XEN_GUEST_HANDLE(xen_sysctl_debug_keys_t);
++
+struct xen_sysctl {
+ uint32_t cmd;
+ uint32_t interface_version; /* XEN_SYSCTL_INTERFACE_VERSION */
@@ -92575,6 +90371,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ struct xen_sysctl_sched_id sched_id;
+ struct xen_sysctl_perfc_op perfc_op;
+ struct xen_sysctl_getdomaininfolist getdomaininfolist;
++ struct xen_sysctl_debug_keys debug_keys;
+ uint8_t pad[128];
+ } u;
+};
@@ -92592,10 +90389,10 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ * indent-tabs-mode: nil
+ * End:
+ */
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/xen/interface/trace.h source/include/xen/interface/trace.h
---- /scratch/src/linux-2.6.20.3/include/xen/interface/trace.h 1970-01-01 01:00:00.000000000 +0100
-+++ source/include/xen/interface/trace.h 2007-03-20 21:27:03.000000000 +0100
-@@ -0,0 +1,102 @@
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/xen/interface/trace.h
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/include/xen/interface/trace.h Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,119 @@
+/******************************************************************************
+ * include/public/trace.h
+ *
@@ -92629,17 +90426,16 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#define TRC_GEN 0x0001f000 /* General trace */
+#define TRC_SCHED 0x0002f000 /* Xen Scheduler trace */
+#define TRC_DOM0OP 0x0004f000 /* Xen DOM0 operation trace */
-+#define TRC_VMX 0x0008f000 /* Xen VMX trace */
++#define TRC_HVM 0x0008f000 /* Xen HVM trace */
+#define TRC_MEM 0x0010f000 /* Xen memory trace */
+#define TRC_ALL 0xfffff000
+
+/* Trace subclasses */
+#define TRC_SUBCLS_SHIFT 12
+
-+/* trace subclasses for VMX */
-+#define TRC_VMXEXIT 0x00081000 /* VMX exit trace */
-+#define TRC_VMXENTRY 0x00082000 /* VMX exit trace */
-+#define TRC_VMXINTR 0x00084000 /* VMX interrupt trace */
++/* trace subclasses for SVM */
++#define TRC_HVM_ENTRYEXIT 0x00081000 /* VMENTRY and #VMEXIT */
++#define TRC_HVM_HANDLER 0x00082000 /* various HVM handlers */
+
+/* Trace events per class */
+#define TRC_LOST_RECORDS (TRC_GEN + 1)
@@ -92665,10 +90461,28 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#define TRC_MEM_PAGE_GRANT_TRANSFER (TRC_MEM + 3)
+
+/* trace events per subclass */
-+#define TRC_VMX_VMEXIT (TRC_VMXEXIT + 1)
-+#define TRC_VMX_VMENTRY (TRC_VMXENTRY + 1)
-+#define TRC_VMX_INTR (TRC_VMXINTR + 1)
-+
++#define TRC_HVM_VMENTRY (TRC_HVM_ENTRYEXIT + 0x01)
++#define TRC_HVM_VMEXIT (TRC_HVM_ENTRYEXIT + 0x02)
++#define TRC_HVM_PF_XEN (TRC_HVM_HANDLER + 0x01)
++#define TRC_HVM_PF_INJECT (TRC_HVM_HANDLER + 0x02)
++#define TRC_HVM_INJ_EXC (TRC_HVM_HANDLER + 0x03)
++#define TRC_HVM_INJ_VIRQ (TRC_HVM_HANDLER + 0x04)
++#define TRC_HVM_REINJ_VIRQ (TRC_HVM_HANDLER + 0x05)
++#define TRC_HVM_IO_READ (TRC_HVM_HANDLER + 0x06)
++#define TRC_HVM_IO_WRITE (TRC_HVM_HANDLER + 0x07)
++#define TRC_HVM_CR_READ (TRC_HVM_HANDLER + 0x08)
++#define TRC_HVM_CR_WRITE (TRC_HVM_HANDLER + 0x09)
++#define TRC_HVM_DR_READ (TRC_HVM_HANDLER + 0x0A)
++#define TRC_HVM_DR_WRITE (TRC_HVM_HANDLER + 0x0B)
++#define TRC_HVM_MSR_READ (TRC_HVM_HANDLER + 0x0C)
++#define TRC_HVM_MSR_WRITE (TRC_HVM_HANDLER + 0x0D)
++#define TRC_HVM_CPUID (TRC_HVM_HANDLER + 0x0E)
++#define TRC_HVM_INTR (TRC_HVM_HANDLER + 0x0F)
++#define TRC_HVM_NMI (TRC_HVM_HANDLER + 0x10)
++#define TRC_HVM_SMI (TRC_HVM_HANDLER + 0x11)
++#define TRC_HVM_VMMCALL (TRC_HVM_HANDLER + 0x12)
++#define TRC_HVM_HLT (TRC_HVM_HANDLER + 0x13)
++#define TRC_HVM_INVLPG (TRC_HVM_HANDLER + 0x14)
+
+/* This structure represents a single trace buffer record. */
+struct t_rec {
@@ -92698,10 +90512,10 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ * indent-tabs-mode: nil
+ * End:
+ */
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/xen/interface/vcpu.h source/include/xen/interface/vcpu.h
---- /scratch/src/linux-2.6.20.3/include/xen/interface/vcpu.h 1970-01-01 01:00:00.000000000 +0100
-+++ source/include/xen/interface/vcpu.h 2007-03-20 21:27:03.000000000 +0100
-@@ -0,0 +1,142 @@
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/xen/interface/vcpu.h
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/include/xen/interface/vcpu.h Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,192 @@
+/******************************************************************************
+ * vcpu.h
+ *
@@ -92746,13 +90560,13 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ * @extra_arg == pointer to vcpu_guest_context structure containing initial
+ * state for the VCPU.
+ */
-+#define VCPUOP_initialise 0
++#define VCPUOP_initialise 0
+
+/*
+ * Bring up a VCPU. This makes the VCPU runnable. This operation will fail
+ * if the VCPU has not been initialised (VCPUOP_initialise).
+ */
-+#define VCPUOP_up 1
++#define VCPUOP_up 1
+
+/*
+ * Bring down a VCPU (i.e., make it non-runnable).
@@ -92768,16 +90582,16 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ * practise to move a VCPU onto an 'idle' or default page table, LDT and
+ * GDT before bringing it down.
+ */
-+#define VCPUOP_down 2
++#define VCPUOP_down 2
+
+/* Returns 1 if the given VCPU is up. */
-+#define VCPUOP_is_up 3
++#define VCPUOP_is_up 3
+
+/*
+ * Return information about the state and running time of a VCPU.
+ * @extra_arg == pointer to vcpu_runstate_info structure.
+ */
-+#define VCPUOP_get_runstate_info 4
++#define VCPUOP_get_runstate_info 4
+struct vcpu_runstate_info {
+ /* VCPU's current state (RUNSTATE_*). */
+ int state;
@@ -92832,6 +90646,56 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ } addr;
+};
+typedef struct vcpu_register_runstate_memory_area vcpu_register_runstate_memory_area_t;
++DEFINE_XEN_GUEST_HANDLE(vcpu_register_runstate_memory_area_t);
++
++/*
++ * Set or stop a VCPU's periodic timer. Every VCPU has one periodic timer
++ * which can be set via these commands. Periods smaller than one millisecond
++ * may not be supported.
++ */
++#define VCPUOP_set_periodic_timer 6 /* arg == vcpu_set_periodic_timer_t */
++#define VCPUOP_stop_periodic_timer 7 /* arg == NULL */
++struct vcpu_set_periodic_timer {
++ uint64_t period_ns;
++};
++typedef struct vcpu_set_periodic_timer vcpu_set_periodic_timer_t;
++DEFINE_XEN_GUEST_HANDLE(vcpu_set_periodic_timer_t);
++
++/*
++ * Set or stop a VCPU's single-shot timer. Every VCPU has one single-shot
++ * timer which can be set via these commands.
++ */
++#define VCPUOP_set_singleshot_timer 8 /* arg == vcpu_set_singleshot_timer_t */
++#define VCPUOP_stop_singleshot_timer 9 /* arg == NULL */
++struct vcpu_set_singleshot_timer {
++ uint64_t timeout_abs_ns; /* Absolute system time value in nanoseconds. */
++ uint32_t flags; /* VCPU_SSHOTTMR_??? */
++};
++typedef struct vcpu_set_singleshot_timer vcpu_set_singleshot_timer_t;
++DEFINE_XEN_GUEST_HANDLE(vcpu_set_singleshot_timer_t);
++
++/* Flags to VCPUOP_set_singleshot_timer. */
++ /* Require the timeout to be in the future (return -ETIME if it's passed). */
++#define _VCPU_SSHOTTMR_future (0)
++#define VCPU_SSHOTTMR_future (1U << _VCPU_SSHOTTMR_future)
++
++/*
++ * Register a memory location in the guest address space for the
++ * vcpu_info structure. This allows the guest to place the vcpu_info
++ * structure in a convenient place, such as in a per-cpu data area.
++ * The pointer need not be page aligned, but the structure must not
++ * cross a page boundary.
++ *
++ * If the specified mfn is INVALID_MFN, then it reverts to using the
++ * vcpu_info structure in the shared_info page.
++ */
++#define VCPUOP_register_vcpu_info 10 /* arg == struct vcpu_info */
++struct vcpu_register_vcpu_info {
++ xen_pfn_t mfn; /* mfn of page to place vcpu_info */
++ uint32_t offset; /* offset within page */
++};
++typedef struct vcpu_register_vcpu_info vcpu_register_vcpu_info_t;
++DEFINE_XEN_GUEST_HANDLE(vcpu_register_vcpu_info_t);
+
+#endif /* __XEN_PUBLIC_VCPU_H__ */
+
@@ -92844,9 +90708,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ * indent-tabs-mode: nil
+ * End:
+ */
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/xen/interface/version.h source/include/xen/interface/version.h
---- /scratch/src/linux-2.6.20.3/include/xen/interface/version.h 1970-01-01 01:00:00.000000000 +0100
-+++ source/include/xen/interface/version.h 2007-03-20 21:27:03.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/xen/interface/version.h
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/include/xen/interface/version.h Wed Aug 08 16:25:28 2007 -0300
@@ -0,0 +1,91 @@
+/******************************************************************************
+ * version.h
@@ -92939,54 +90803,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ * indent-tabs-mode: nil
+ * End:
+ */
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/xen/interface/xencomm.h source/include/xen/interface/xencomm.h
---- /scratch/src/linux-2.6.20.3/include/xen/interface/xencomm.h 1970-01-01 01:00:00.000000000 +0100
-+++ source/include/xen/interface/xencomm.h 2007-03-20 21:27:03.000000000 +0100
-@@ -0,0 +1,41 @@
-+/*
-+ * Permission is hereby granted, free of charge, to any person obtaining a copy
-+ * of this software and associated documentation files (the "Software"), to
-+ * deal in the Software without restriction, including without limitation the
-+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-+ * sell copies of the Software, and to permit persons to whom the Software is
-+ * furnished to do so, subject to the following conditions:
-+ *
-+ * The above copyright notice and this permission notice shall be included in
-+ * all copies or substantial portions of the Software.
-+ *
-+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-+ * DEALINGS IN THE SOFTWARE.
-+ *
-+ * Copyright (C) IBM Corp. 2006
-+ */
-+
-+#ifndef _XEN_XENCOMM_H_
-+#define _XEN_XENCOMM_H_
-+
-+/* A xencomm descriptor is a scatter/gather list containing physical
-+ * addresses corresponding to a virtually contiguous memory area. The
-+ * hypervisor translates these physical addresses to machine addresses to copy
-+ * to and from the virtually contiguous area.
-+ */
-+
-+#define XENCOMM_MAGIC 0x58434F4D /* 'XCOM' */
-+#define XENCOMM_INVALID (~0UL)
-+
-+struct xencomm_desc {
-+ uint32_t magic;
-+ uint32_t nr_addrs; /* the number of entries in address[] */
-+ uint64_t address[0];
-+};
-+
-+#endif /* _XEN_XENCOMM_H_ */
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/xen/interface/xen-compat.h source/include/xen/interface/xen-compat.h
---- /scratch/src/linux-2.6.20.3/include/xen/interface/xen-compat.h 1970-01-01 01:00:00.000000000 +0100
-+++ source/include/xen/interface/xen-compat.h 2007-03-20 21:27:03.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/xen/interface/xen-compat.h
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/include/xen/interface/xen-compat.h Wed Aug 08 16:25:28 2007 -0300
@@ -0,0 +1,51 @@
+/******************************************************************************
+ * xen-compat.h
@@ -93039,10 +90858,10 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#endif
+
+#endif /* __XEN_PUBLIC_XEN_COMPAT_H__ */
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/xen/interface/xen.h source/include/xen/interface/xen.h
---- /scratch/src/linux-2.6.20.3/include/xen/interface/xen.h 1970-01-01 01:00:00.000000000 +0100
-+++ source/include/xen/interface/xen.h 2007-03-20 21:27:03.000000000 +0100
-@@ -0,0 +1,597 @@
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/xen/interface/xen.h
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/include/xen/interface/xen.h Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,610 @@
+/******************************************************************************
+ * xen.h
+ *
@@ -93176,6 +90995,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#define VIRQ_TBUF 4 /* G. (DOM0) Trace buffer has records available. */
+#define VIRQ_DEBUGGER 6 /* G. (DOM0) A domain has paused for debugging. */
+#define VIRQ_XENOPROF 7 /* V. XenOprofile interrupt: new sample available */
++#define VIRQ_CON_RING 8 /* G. (DOM0) Bytes received on console */
+
+/* Architecture-specific VIRQ definitions. */
+#define VIRQ_ARCH_0 16
@@ -93453,7 +91273,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ struct arch_vcpu_info arch;
+ struct vcpu_time_info time;
+}; /* 64 bytes (x86) */
++#ifndef __XEN__
+typedef struct vcpu_info vcpu_info_t;
++#endif
+
+/*
+ * Xen/kernel shared data -- pointer provided in start_info.
@@ -93511,29 +91333,29 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ struct arch_shared_info arch;
+
+};
++#ifndef __XEN__
+typedef struct shared_info shared_info_t;
++#endif
+
+/*
-+ * Start-of-day memory layout for the initial domain (DOM0):
++ * Start-of-day memory layout:
+ * 1. The domain is started within contiguous virtual-memory region.
-+ * 2. The contiguous region begins and ends on an aligned 4MB boundary.
-+ * 3. The region start corresponds to the load address of the OS image.
-+ * If the load address is not 4MB aligned then the address is rounded down.
-+ * 4. This the order of bootstrap elements in the initial virtual region:
++ * 2. The contiguous region ends on an aligned 4MB boundary.
++ * 3. This the order of bootstrap elements in the initial virtual region:
+ * a. relocated kernel image
+ * b. initial ram disk [mod_start, mod_len]
+ * c. list of allocated page frames [mfn_list, nr_pages]
+ * d. start_info_t structure [register ESI (x86)]
+ * e. bootstrap page tables [pt_base, CR3 (x86)]
+ * f. bootstrap stack [register ESP (x86)]
-+ * 5. Bootstrap elements are packed together, but each is 4kB-aligned.
-+ * 6. The initial ram disk may be omitted.
-+ * 7. The list of page frames forms a contiguous 'pseudo-physical' memory
++ * 4. Bootstrap elements are packed together, but each is 4kB-aligned.
++ * 5. The initial ram disk may be omitted.
++ * 6. The list of page frames forms a contiguous 'pseudo-physical' memory
+ * layout for the domain. In particular, the bootstrap virtual-memory
+ * region is a 1:1 mapping to the first section of the pseudo-physical map.
-+ * 8. All bootstrap elements are mapped read-writable for the guest OS. The
++ * 7. All bootstrap elements are mapped read-writable for the guest OS. The
+ * only exception is the bootstrap page table, which is mapped read-only.
-+ * 9. There is guaranteed to be at least 512kB padding after the final
++ * 8. There is guaranteed to be at least 512kB padding after the final
+ * bootstrap element. If necessary, the bootstrap virtual region is
+ * extended by an extra 4MB to ensure this.
+ */
@@ -93629,6 +91451,16 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+
+#endif /* !__ASSEMBLY__ */
+
++/* Default definitions for macros used by domctl/sysctl. */
++#if defined(__XEN__) || defined(__XEN_TOOLS__)
++#ifndef uint64_aligned_t
++#define uint64_aligned_t uint64_t
++#endif
++#ifndef XEN_GUEST_HANDLE_64
++#define XEN_GUEST_HANDLE_64(name) XEN_GUEST_HANDLE(name)
++#endif
++#endif
++
+#endif /* __XEN_PUBLIC_XEN_H__ */
+
+/*
@@ -93640,10 +91472,55 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ * indent-tabs-mode: nil
+ * End:
+ */
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/xen/interface/xenoprof.h source/include/xen/interface/xenoprof.h
---- /scratch/src/linux-2.6.20.3/include/xen/interface/xenoprof.h 1970-01-01 01:00:00.000000000 +0100
-+++ source/include/xen/interface/xenoprof.h 2007-03-20 21:27:03.000000000 +0100
-@@ -0,0 +1,130 @@
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/xen/interface/xencomm.h
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/include/xen/interface/xencomm.h Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,41 @@
++/*
++ * Permission is hereby granted, free of charge, to any person obtaining a copy
++ * of this software and associated documentation files (the "Software"), to
++ * deal in the Software without restriction, including without limitation the
++ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
++ * sell copies of the Software, and to permit persons to whom the Software is
++ * furnished to do so, subject to the following conditions:
++ *
++ * The above copyright notice and this permission notice shall be included in
++ * all copies or substantial portions of the Software.
++ *
++ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
++ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
++ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
++ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
++ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
++ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
++ * DEALINGS IN THE SOFTWARE.
++ *
++ * Copyright (C) IBM Corp. 2006
++ */
++
++#ifndef _XEN_XENCOMM_H_
++#define _XEN_XENCOMM_H_
++
++/* A xencomm descriptor is a scatter/gather list containing physical
++ * addresses corresponding to a virtually contiguous memory area. The
++ * hypervisor translates these physical addresses to machine addresses to copy
++ * to and from the virtually contiguous area.
++ */
++
++#define XENCOMM_MAGIC 0x58434F4D /* 'XCOM' */
++#define XENCOMM_INVALID (~0UL)
++
++struct xencomm_desc {
++ uint32_t magic;
++ uint32_t nr_addrs; /* the number of entries in address[] */
++ uint64_t address[0];
++};
++
++#endif /* _XEN_XENCOMM_H_ */
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/xen/interface/xenoprof.h
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/include/xen/interface/xenoprof.h Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,132 @@
+/******************************************************************************
+ * xenoprof.h
+ *
@@ -93720,8 +91597,10 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ uint64_t lost_samples;
+ struct event_log event_log[1];
+};
++#ifndef __XEN__
+typedef struct xenoprof_buf xenoprof_buf_t;
+DEFINE_XEN_GUEST_HANDLE(xenoprof_buf_t);
++#endif
+
+struct xenoprof_init {
+ int32_t num_events;
@@ -93774,9 +91653,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ * indent-tabs-mode: nil
+ * End:
+ */
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/xen/pcifront.h source/include/xen/pcifront.h
---- /scratch/src/linux-2.6.20.3/include/xen/pcifront.h 1970-01-01 01:00:00.000000000 +0100
-+++ source/include/xen/pcifront.h 2007-03-20 21:27:03.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/xen/pcifront.h
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/include/xen/pcifront.h Wed Aug 08 16:25:28 2007 -0300
@@ -0,0 +1,76 @@
+/*
+ * PCI Frontend - arch-dependendent declarations
@@ -93854,9 +91733,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+#endif /* __KERNEL__ */
+
+#endif /* __XEN_ASM_PCIFRONT_H__ */
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/xen/public/evtchn.h source/include/xen/public/evtchn.h
---- /scratch/src/linux-2.6.20.3/include/xen/public/evtchn.h 1970-01-01 01:00:00.000000000 +0100
-+++ source/include/xen/public/evtchn.h 2007-03-20 21:27:03.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/xen/public/evtchn.h
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/include/xen/public/evtchn.h Wed Aug 08 16:25:28 2007 -0300
@@ -0,0 +1,88 @@
+/******************************************************************************
+ * evtchn.h
@@ -93946,9 +91825,118 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ _IOC(_IOC_NONE, 'E', 5, 0)
+
+#endif /* __LINUX_PUBLIC_EVTCHN_H__ */
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/xen/public/privcmd.h source/include/xen/public/privcmd.h
---- /scratch/src/linux-2.6.20.3/include/xen/public/privcmd.h 1970-01-01 01:00:00.000000000 +0100
-+++ source/include/xen/public/privcmd.h 2007-03-20 21:27:03.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/xen/public/gntdev.h
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/include/xen/public/gntdev.h Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,105 @@
++/******************************************************************************
++ * gntdev.h
++ *
++ * Interface to /dev/xen/gntdev.
++ *
++ * Copyright (c) 2007, D G Murray
++ *
++ * 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; or, when distributed
++ * separately from the Linux kernel or incorporated into other
++ * software packages, subject to the following license:
++ *
++ * Permission is hereby granted, free of charge, to any person obtaining a copy
++ * of this source file (the "Software"), to deal in the Software without
++ * restriction, including without limitation the rights to use, copy, modify,
++ * merge, publish, distribute, sublicense, and/or sell copies of the Software,
++ * and to permit persons to whom the Software is furnished to do so, subject to
++ * the following conditions:
++ *
++ * The above copyright notice and this permission notice shall be included in
++ * all copies or substantial portions of the Software.
++ *
++ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
++ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
++ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
++ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
++ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
++ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
++ * IN THE SOFTWARE.
++ */
++
++#ifndef __LINUX_PUBLIC_GNTDEV_H__
++#define __LINUX_PUBLIC_GNTDEV_H__
++
++struct ioctl_gntdev_grant_ref {
++ /* The domain ID of the grant to be mapped. */
++ uint32_t domid;
++ /* The grant reference of the grant to be mapped. */
++ uint32_t ref;
++};
++
++/*
++ * Inserts the grant references into the mapping table of an instance
++ * of gntdev. N.B. This does not perform the mapping, which is deferred
++ * until mmap() is called with @index as the offset.
++ */
++#define IOCTL_GNTDEV_MAP_GRANT_REF \
++_IOC(_IOC_NONE, 'G', 0, sizeof(struct ioctl_gntdev_map_grant_ref))
++struct ioctl_gntdev_map_grant_ref {
++ /* IN parameters */
++ /* The number of grants to be mapped. */
++ uint32_t count;
++ uint32_t pad;
++ /* OUT parameters */
++ /* The offset to be used on a subsequent call to mmap(). */
++ uint64_t index;
++ /* Variable IN parameter. */
++ /* Array of grant references, of size @count. */
++ struct ioctl_gntdev_grant_ref refs[1];
++};
++
++/*
++ * Removes the grant references from the mapping table of an instance of
++ * of gntdev. N.B. munmap() must be called on the relevant virtual address(es)
++ * before this ioctl is called, or an error will result.
++ */
++#define IOCTL_GNTDEV_UNMAP_GRANT_REF \
++_IOC(_IOC_NONE, 'G', 1, sizeof(struct ioctl_gntdev_unmap_grant_ref))
++struct ioctl_gntdev_unmap_grant_ref {
++ /* IN parameters */
++ /* The offset was returned by the corresponding map operation. */
++ uint64_t index;
++ /* The number of pages to be unmapped. */
++ uint32_t count;
++ uint32_t pad;
++};
++
++/*
++ * Returns the offset in the driver's address space that corresponds
++ * to @vaddr. This can be used to perform a munmap(), followed by an
++ * UNMAP_GRANT_REF ioctl, where no state about the offset is retained by
++ * the caller. The number of pages that were allocated at the same time as
++ * @vaddr is returned in @count.
++ *
++ * N.B. Where more than one page has been mapped into a contiguous range, the
++ * supplied @vaddr must correspond to the start of the range; otherwise
++ * an error will result. It is only possible to munmap() the entire
++ * contiguously-allocated range at once, and not any subrange thereof.
++ */
++#define IOCTL_GNTDEV_GET_OFFSET_FOR_VADDR \
++_IOC(_IOC_NONE, 'G', 2, sizeof(struct ioctl_gntdev_get_offset_for_vaddr))
++struct ioctl_gntdev_get_offset_for_vaddr {
++ /* IN parameters */
++ /* The virtual address of the first mapped page in a range. */
++ uint64_t vaddr;
++ /* OUT parameters */
++ /* The offset that was used in the initial mmap() operation. */
++ uint64_t offset;
++ /* The number of pages mapped in the VM area that begins at @vaddr. */
++ uint32_t count;
++ uint32_t pad;
++};
++
++#endif /* __LINUX_PUBLIC_GNTDEV_H__ */
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/xen/public/privcmd.h
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/include/xen/public/privcmd.h Wed Aug 08 16:25:28 2007 -0300
@@ -0,0 +1,79 @@
+/******************************************************************************
+ * privcmd.h
@@ -94029,10 +92017,26 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ _IOC(_IOC_NONE, 'P', 3, sizeof(privcmd_mmapbatch_t))
+
+#endif /* __LINUX_PUBLIC_PRIVCMD_H__ */
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/xen/xenbus.h source/include/xen/xenbus.h
---- /scratch/src/linux-2.6.20.3/include/xen/xenbus.h 1970-01-01 01:00:00.000000000 +0100
-+++ source/include/xen/xenbus.h 2007-03-20 21:27:03.000000000 +0100
-@@ -0,0 +1,307 @@
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/xen/xen_proc.h
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/include/xen/xen_proc.h Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,12 @@
++
++#ifndef __ASM_XEN_PROC_H__
++#define __ASM_XEN_PROC_H__
++
++#include <linux/proc_fs.h>
++
++extern struct proc_dir_entry *create_xen_proc_entry(
++ const char *name, mode_t mode);
++extern void remove_xen_proc_entry(
++ const char *name);
++
++#endif /* __ASM_XEN_PROC_H__ */
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/xen/xenbus.h
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/include/xen/xenbus.h Wed Aug 08 16:25:28 2007 -0300
+@@ -0,0 +1,302 @@
+/******************************************************************************
+ * xenbus.h
+ *
@@ -94136,6 +92140,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ enum xenbus_state backend_state);
+ int (*remove)(struct xenbus_device *dev);
+ int (*suspend)(struct xenbus_device *dev);
++ int (*suspend_cancel)(struct xenbus_device *dev);
+ int (*resume)(struct xenbus_device *dev);
+ int (*uevent)(struct xenbus_device *, char **, int, char *, int);
+ struct device_driver driver;
@@ -94195,13 +92200,15 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+void unregister_xenbus_watch(struct xenbus_watch *watch);
+void xs_suspend(void);
+void xs_resume(void);
++void xs_suspend_cancel(void);
+
+/* Used by xenbus_dev to borrow kernel's store connection. */
+void *xenbus_dev_request_and_reply(struct xsd_sockmsg *msg);
+
-+/* Called from xen core code. */
++/* Prepare for domain suspend: then resume or cancel the suspend. */
+void xenbus_suspend(void);
+void xenbus_resume(void);
++void xenbus_suspend_cancel(void);
+
+#define XENBUS_IS_ERR_READ(str) ({ \
+ if (!IS_ERR(str) && strlen(str) == 0) { \
@@ -94297,14 +92304,6 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+
+
+/**
-+ * Bind to an existing interdomain event channel in another domain. Returns 0
-+ * on success and stores the local port in *port. On error, returns -errno,
-+ * switches the device to XenbusStateClosing, and saves the error in XenStore.
-+ */
-+int xenbus_bind_evtchn(struct xenbus_device *dev, int remote_port, int *port);
-+
-+
-+/**
+ * Free an existing event channel. Returns 0 on success or -errno on error.
+ */
+int xenbus_free_evtchn(struct xenbus_device *dev, int port);
@@ -94333,16 +92332,16 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+void xenbus_dev_fatal(struct xenbus_device *dev, int err, const char *fmt,
+ ...);
+
-+int __init xenbus_dev_init(void);
++int xenbus_dev_init(void);
+
-+char *xenbus_strstate(enum xenbus_state state);
++const char *xenbus_strstate(enum xenbus_state state);
+int xenbus_dev_is_online(struct xenbus_device *dev);
+int xenbus_frontend_closed(struct xenbus_device *dev);
+
+#endif /* _XEN_XENBUS_H */
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/xen/xencons.h source/include/xen/xencons.h
---- /scratch/src/linux-2.6.20.3/include/xen/xencons.h 1970-01-01 01:00:00.000000000 +0100
-+++ source/include/xen/xencons.h 2007-03-20 21:27:03.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/xen/xencons.h
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/include/xen/xencons.h Wed Aug 08 16:25:28 2007 -0300
@@ -0,0 +1,19 @@
+#ifndef __ASM_XENCONS_H__
+#define __ASM_XENCONS_H__
@@ -94363,9 +92362,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+void xencons_early_setup(void);
+
+#endif /* __ASM_XENCONS_H__ */
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/xen/xenoprof.h source/include/xen/xenoprof.h
---- /scratch/src/linux-2.6.20.3/include/xen/xenoprof.h 1970-01-01 01:00:00.000000000 +0100
-+++ source/include/xen/xenoprof.h 2007-03-20 21:27:03.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 include/xen/xenoprof.h
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/include/xen/xenoprof.h Wed Aug 08 16:25:28 2007 -0300
@@ -0,0 +1,42 @@
+/******************************************************************************
+ * xen/xenoprof.h
@@ -94409,25 +92408,20 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+
+#endif /* CONFIG_XEN */
+#endif /* __XEN_XENOPROF_H__ */
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/include/xen/xen_proc.h source/include/xen/xen_proc.h
---- /scratch/src/linux-2.6.20.3/include/xen/xen_proc.h 1970-01-01 01:00:00.000000000 +0100
-+++ source/include/xen/xen_proc.h 2007-03-20 21:27:03.000000000 +0100
-@@ -0,0 +1,12 @@
-+
-+#ifndef __ASM_XEN_PROC_H__
-+#define __ASM_XEN_PROC_H__
-+
-+#include <linux/proc_fs.h>
-+
-+extern struct proc_dir_entry *create_xen_proc_entry(
-+ const char *name, mode_t mode);
-+extern void remove_xen_proc_entry(
-+ const char *name);
-+
-+#endif /* __ASM_XEN_PROC_H__ */
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/kernel/fork.c source/kernel/fork.c
---- /scratch/src/linux-2.6.20.3/kernel/fork.c 2007-02-04 19:44:54.000000000 +0100
-+++ source/kernel/fork.c 2007-03-20 21:27:04.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 kernel/Kconfig.preempt
+--- a/kernel/Kconfig.preempt Wed Jul 18 12:23:24 2007 -0300
++++ b/kernel/Kconfig.preempt Wed Aug 08 16:25:28 2007 -0300
+@@ -35,6 +35,7 @@ config PREEMPT_VOLUNTARY
+
+ config PREEMPT
+ bool "Preemptible Kernel (Low-Latency Desktop)"
++ depends on !XEN
+ help
+ This option reduces the latency of the kernel by making
+ all kernel code (that is not executing in a critical section)
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 kernel/fork.c
+--- a/kernel/fork.c Wed Jul 18 12:23:24 2007 -0300
++++ b/kernel/fork.c Wed Aug 08 16:25:28 2007 -0300
@@ -286,6 +286,9 @@ static inline int dup_mmap(struct mm_str
if (retval)
goto out;
@@ -94438,22 +92432,78 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
retval = 0;
out:
up_write(&mm->mmap_sem);
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/kernel/Kconfig.preempt source/kernel/Kconfig.preempt
---- /scratch/src/linux-2.6.20.3/kernel/Kconfig.preempt 2007-02-04 19:44:54.000000000 +0100
-+++ source/kernel/Kconfig.preempt 2007-03-20 21:27:04.000000000 +0100
-@@ -35,6 +35,7 @@ config PREEMPT_VOLUNTARY
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 kernel/irq/manage.c
+--- a/kernel/irq/manage.c Wed Jul 18 12:23:24 2007 -0300
++++ b/kernel/irq/manage.c Wed Aug 08 16:25:28 2007 -0300
+@@ -30,6 +30,7 @@ void synchronize_irq(unsigned int irq)
+ {
+ struct irq_desc *desc = irq_desc + irq;
- config PREEMPT
- bool "Preemptible Kernel (Low-Latency Desktop)"
-+ depends on !XEN
- help
- This option reduces the latency of the kernel by making
- all kernel code (that is not executing in a critical section)
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/kernel/kexec.c source/kernel/kexec.c
---- /scratch/src/linux-2.6.20.3/kernel/kexec.c 2007-02-04 19:44:54.000000000 +0100
-+++ source/kernel/kexec.c 2007-03-21 14:49:46.000000000 +0100
-@@ -404,7 +404,7 @@ static struct page *kimage_alloc_normal_
- pages = kimage_alloc_pages(GFP_KERNEL, order);
++ WARN_ON(in_interrupt());
+ if (irq >= NR_IRQS)
+ return;
+
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 kernel/irq/spurious.c
+--- a/kernel/irq/spurious.c Wed Jul 18 12:23:24 2007 -0300
++++ b/kernel/irq/spurious.c Wed Aug 08 16:25:28 2007 -0300
+@@ -139,7 +139,8 @@ void note_interrupt(unsigned int irq, st
+ irqreturn_t action_ret)
+ {
+ if (unlikely(action_ret != IRQ_HANDLED)) {
+- desc->irqs_unhandled++;
++ if (!irq_ignore_unhandled(irq))
++ desc->irqs_unhandled++;
+ if (unlikely(action_ret != IRQ_NONE))
+ report_bad_irq(irq, desc, action_ret);
+ }
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 kernel/kexec.c
+--- a/kernel/kexec.c Wed Jul 18 12:23:24 2007 -0300
++++ b/kernel/kexec.c Wed Aug 08 16:25:28 2007 -0300
+@@ -331,13 +331,27 @@ static int kimage_is_destination_range(s
+ return 0;
+ }
+
+-static struct page *kimage_alloc_pages(gfp_t gfp_mask, unsigned int order)
++static struct page *kimage_alloc_pages(gfp_t gfp_mask, unsigned int order, unsigned long limit)
+ {
+ struct page *pages;
+
+ pages = alloc_pages(gfp_mask, order);
+ if (pages) {
+ unsigned int count, i;
++#ifdef CONFIG_XEN
++ int address_bits;
++
++ if (limit == ~0UL)
++ address_bits = BITS_PER_LONG;
++ else
++ address_bits = ilog2(limit);
++
++ if (xen_create_contiguous_region((unsigned long)page_address(pages),
++ order, address_bits) < 0) {
++ __free_pages(pages, order);
++ return NULL;
++ }
++#endif
+ pages->mapping = NULL;
+ set_page_private(pages, order);
+ count = 1 << order;
+@@ -356,6 +370,9 @@ static void kimage_free_pages(struct pag
+ count = 1 << order;
+ for (i = 0; i < count; i++)
+ ClearPageReserved(page + i);
++#ifdef CONFIG_XEN
++ xen_destroy_contiguous_region((unsigned long)page_address(page), order);
++#endif
+ __free_pages(page, order);
+ }
+
+@@ -401,10 +418,10 @@ static struct page *kimage_alloc_normal_
+ do {
+ unsigned long pfn, epfn, addr, eaddr;
+
+- pages = kimage_alloc_pages(GFP_KERNEL, order);
++ pages = kimage_alloc_pages(GFP_KERNEL, order, KEXEC_CONTROL_MEMORY_LIMIT);
if (!pages)
break;
- pfn = page_to_pfn(pages);
@@ -94461,7 +92511,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
epfn = pfn + count;
addr = pfn << PAGE_SHIFT;
eaddr = epfn << PAGE_SHIFT;
-@@ -438,6 +438,7 @@ static struct page *kimage_alloc_normal_
+@@ -438,6 +455,7 @@ static struct page *kimage_alloc_normal_
return pages;
}
@@ -94469,7 +92519,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
static struct page *kimage_alloc_crash_control_pages(struct kimage *image,
unsigned int order)
{
-@@ -491,7 +492,7 @@ static struct page *kimage_alloc_crash_c
+@@ -491,7 +509,7 @@ static struct page *kimage_alloc_crash_c
}
/* If I don't overlap any segments I have found my hole! */
if (i == image->nr_segments) {
@@ -94478,7 +92528,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
break;
}
}
-@@ -518,6 +519,13 @@ struct page *kimage_alloc_control_pages(
+@@ -518,6 +536,13 @@ struct page *kimage_alloc_control_pages(
return pages;
}
@@ -94492,7 +92542,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
static int kimage_add_entry(struct kimage *image, kimage_entry_t entry)
{
-@@ -533,7 +541,7 @@ static int kimage_add_entry(struct kimag
+@@ -533,7 +558,7 @@ static int kimage_add_entry(struct kimag
return -ENOMEM;
ind_page = page_address(page);
@@ -94501,7 +92551,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
image->entry = ind_page;
image->last_entry = ind_page +
((PAGE_SIZE/sizeof(kimage_entry_t)) - 1);
-@@ -594,13 +602,13 @@ static int kimage_terminate(struct kimag
+@@ -594,13 +619,13 @@ static int kimage_terminate(struct kimag
#define for_each_kimage_entry(image, ptr, entry) \
for (ptr = &image->head; (entry = *ptr) && !(entry & IND_DONE); \
ptr = (entry & IND_INDIRECTION)? \
@@ -94517,18 +92567,18 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
kimage_free_pages(page);
}
-@@ -612,6 +620,10 @@ static void kimage_free(struct kimage *i
+@@ -611,6 +636,10 @@ static void kimage_free(struct kimage *i
+
if (!image)
return;
-
++
+#ifdef CONFIG_XEN
+ xen_machine_kexec_unload(image);
+#endif
-+
+
kimage_free_extra_pages(image);
for_each_kimage_entry(image, ptr, entry) {
- if (entry & IND_INDIRECTION) {
-@@ -687,7 +699,7 @@ static struct page *kimage_alloc_page(st
+@@ -687,7 +716,7 @@ static struct page *kimage_alloc_page(st
* have a match.
*/
list_for_each_entry(page, &image->dest_pages, lru) {
@@ -94537,7 +92587,12 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
if (addr == destination) {
list_del(&page->lru);
return page;
-@@ -702,12 +714,12 @@ static struct page *kimage_alloc_page(st
+@@ -698,16 +727,16 @@ static struct page *kimage_alloc_page(st
+ kimage_entry_t *old;
+
+ /* Allocate a page, if we run out of memory give up */
+- page = kimage_alloc_pages(gfp_mask, 0);
++ page = kimage_alloc_pages(gfp_mask, 0, KEXEC_SOURCE_MEMORY_LIMIT);
if (!page)
return NULL;
/* If the page cannot be used file it away */
@@ -94552,7 +92607,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
/* If it is the destination page we want use it */
if (addr == destination)
-@@ -730,7 +742,7 @@ static struct page *kimage_alloc_page(st
+@@ -730,7 +759,7 @@ static struct page *kimage_alloc_page(st
struct page *old_page;
old_addr = *old & PAGE_MASK;
@@ -94561,7 +92616,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
copy_highpage(page, old_page);
*old = addr | (*old & ~PAGE_MASK);
-@@ -780,7 +792,7 @@ static int kimage_load_normal_segment(st
+@@ -780,7 +809,7 @@ static int kimage_load_normal_segment(st
result = -ENOMEM;
goto out;
}
@@ -94570,7 +92625,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
<< PAGE_SHIFT);
if (result < 0)
goto out;
-@@ -812,6 +824,7 @@ out:
+@@ -812,6 +841,7 @@ out:
return result;
}
@@ -94578,7 +92633,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
static int kimage_load_crash_segment(struct kimage *image,
struct kexec_segment *segment)
{
-@@ -834,7 +847,7 @@ static int kimage_load_crash_segment(str
+@@ -834,7 +864,7 @@ static int kimage_load_crash_segment(str
char *ptr;
size_t uchunk, mchunk;
@@ -94587,7 +92642,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
if (page == 0) {
result = -ENOMEM;
goto out;
-@@ -883,6 +896,13 @@ static int kimage_load_segment(struct ki
+@@ -883,6 +913,13 @@ static int kimage_load_segment(struct ki
return result;
}
@@ -94601,21 +92656,60 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
/*
* Exec Kernel system call: for obvious reasons only root may call it.
-@@ -993,6 +1013,11 @@ asmlinkage long sys_kexec_load(unsigned
+@@ -993,6 +1030,13 @@ asmlinkage long sys_kexec_load(unsigned
if (result)
goto out;
}
+#ifdef CONFIG_XEN
-+ result = xen_machine_kexec_load(image);
-+ if (result)
-+ goto out;
++ if (image) {
++ result = xen_machine_kexec_load(image);
++ if (result)
++ goto out;
++ }
+#endif
/* Install the new kernel, and Uninstall the old */
image = xchg(dest_image, image);
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/lib/Makefile source/lib/Makefile
---- /scratch/src/linux-2.6.20.3/lib/Makefile 2007-02-04 19:44:54.000000000 +0100
-+++ source/lib/Makefile 2007-03-20 21:27:04.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 kernel/softlockup.c
+--- a/kernel/softlockup.c Wed Jul 18 12:23:24 2007 -0300
++++ b/kernel/softlockup.c Wed Aug 08 16:25:28 2007 -0300
+@@ -39,6 +39,19 @@ void touch_softlockup_watchdog(void)
+ __raw_get_cpu_var(touch_timestamp) = jiffies;
+ }
+ EXPORT_SYMBOL(touch_softlockup_watchdog);
++
++unsigned long softlockup_get_next_event(void)
++{
++ int this_cpu = smp_processor_id();
++ unsigned long touch_timestamp = per_cpu(touch_timestamp, this_cpu);
++
++ if (per_cpu(print_timestamp, this_cpu) == touch_timestamp ||
++ did_panic ||
++ !per_cpu(watchdog_task, this_cpu))
++ return MAX_JIFFY_OFFSET;
++
++ return max_t(long, 0, touch_timestamp + HZ - jiffies);
++}
+
+ /*
+ * This callback runs from the timer interrupt, and checks
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 kernel/timer.c
+--- a/kernel/timer.c Wed Jul 18 12:23:24 2007 -0300
++++ b/kernel/timer.c Wed Aug 08 16:25:28 2007 -0300
+@@ -616,7 +616,9 @@ unsigned long next_timer_interrupt(void)
+ if (hr_expires < 3)
+ return hr_expires + jiffies;
+ }
+- hr_expires += jiffies;
++ hr_expires = min_t(unsigned long,
++ softlockup_get_next_event(),
++ hr_expires) + jiffies;
+
+ base = __get_cpu_var(tvec_bases);
+ spin_lock(&base->lock);
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 lib/Makefile
+--- a/lib/Makefile Wed Jul 18 12:23:24 2007 -0300
++++ b/lib/Makefile Wed Aug 08 16:25:28 2007 -0300
@@ -57,6 +57,7 @@ obj-$(CONFIG_AUDIT_GENERIC) += audit.o
obj-$(CONFIG_SWIOTLB) += swiotlb.o
@@ -94624,30 +92718,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
lib-$(CONFIG_GENERIC_BUG) += bug.o
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/mm/highmem.c source/mm/highmem.c
---- /scratch/src/linux-2.6.20.3/mm/highmem.c 2007-02-04 19:44:54.000000000 +0100
-+++ source/mm/highmem.c 2007-03-20 21:27:04.000000000 +0100
-@@ -148,6 +148,17 @@ start:
- return vaddr;
- }
-
-+#ifdef CONFIG_XEN
-+void kmap_flush_unused(void)
-+{
-+ spin_lock(&kmap_lock);
-+ flush_all_zero_pkmaps();
-+ spin_unlock(&kmap_lock);
-+}
-+
-+EXPORT_SYMBOL(kmap_flush_unused);
-+#endif
-+
- void fastcall *kmap_high(struct page *page)
- {
- unsigned long vaddr;
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/mm/Kconfig source/mm/Kconfig
---- /scratch/src/linux-2.6.20.3/mm/Kconfig 2007-02-04 19:44:54.000000000 +0100
-+++ source/mm/Kconfig 2007-03-20 21:27:04.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 mm/Kconfig
+--- a/mm/Kconfig Wed Jul 18 12:23:24 2007 -0300
++++ b/mm/Kconfig Wed Aug 08 16:25:28 2007 -0300
@@ -132,11 +132,14 @@ config MEMORY_HOTPLUG_SPARSE
# Default to 4 for wider testing, though 8 might be more appropriate.
# ARM's adjust_pte (unused if VIPT) depends on mm-wide page_table_lock.
@@ -94663,9 +92736,30 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
default "4"
#
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/mm/memory.c source/mm/memory.c
---- /scratch/src/linux-2.6.20.3/mm/memory.c 2007-02-04 19:44:54.000000000 +0100
-+++ source/mm/memory.c 2007-03-20 21:27:04.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 mm/highmem.c
+--- a/mm/highmem.c Wed Jul 18 12:23:24 2007 -0300
++++ b/mm/highmem.c Wed Aug 08 16:25:28 2007 -0300
+@@ -147,6 +147,17 @@ start:
+
+ return vaddr;
+ }
++
++#ifdef CONFIG_XEN
++void kmap_flush_unused(void)
++{
++ spin_lock(&kmap_lock);
++ flush_all_zero_pkmaps();
++ spin_unlock(&kmap_lock);
++}
++
++EXPORT_SYMBOL(kmap_flush_unused);
++#endif
+
+ void fastcall *kmap_high(struct page *page)
+ {
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 mm/memory.c
+--- a/mm/memory.c Wed Jul 18 12:23:24 2007 -0300
++++ b/mm/memory.c Wed Aug 08 16:25:28 2007 -0300
@@ -404,7 +404,8 @@ struct page *vm_normal_page(struct vm_ar
* and that the resulting page looks ok.
*/
@@ -94676,7 +92770,25 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
return NULL;
}
-@@ -896,6 +897,7 @@ unsigned long zap_page_range(struct vm_a
+@@ -662,8 +663,17 @@ static unsigned long zap_pte_range(struc
+ page->index > details->last_index))
+ continue;
+ }
++#ifdef CONFIG_XEN
++ if (unlikely(vma->vm_ops && vma->vm_ops->zap_pte))
++ ptent = vma->vm_ops->zap_pte(vma, addr, pte,
++ tlb->fullmm);
++ else
++ ptent = ptep_get_and_clear_full(mm, addr, pte,
++ tlb->fullmm);
++#else
+ ptent = ptep_get_and_clear_full(mm, addr, pte,
+ tlb->fullmm);
++#endif
+ tlb_remove_tlb_entry(tlb, pte, addr);
+ if (unlikely(!page))
+ continue;
+@@ -896,6 +906,7 @@ unsigned long zap_page_range(struct vm_a
tlb_finish_mmu(tlb, address, end);
return end;
}
@@ -94684,7 +92796,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
/*
* Do a quick page-table lookup for a single page.
-@@ -1035,6 +1037,26 @@ int get_user_pages(struct task_struct *t
+@@ -1035,6 +1046,26 @@ int get_user_pages(struct task_struct *t
continue;
}
@@ -94711,7 +92823,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
if (!vma || (vma->vm_flags & (VM_IO | VM_PFNMAP))
|| !(vm_flags & vma->vm_flags))
return i ? : -EFAULT;
-@@ -1403,6 +1425,102 @@ int remap_pfn_range(struct vm_area_struc
+@@ -1403,6 +1434,102 @@ int remap_pfn_range(struct vm_area_struc
}
EXPORT_SYMBOL(remap_pfn_range);
@@ -94814,24 +92926,58 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
/*
* handle_pte_fault chooses page fault handler according to an entry
* which was read non-atomically. Before making any commitment, on
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/mm/mmap.c source/mm/mmap.c
---- /scratch/src/linux-2.6.20.3/mm/mmap.c 2007-02-04 19:44:54.000000000 +0100
-+++ source/mm/mmap.c 2007-03-20 21:27:04.000000000 +0100
-@@ -1977,6 +1977,10 @@ void exit_mmap(struct mm_struct *mm)
+@@ -1462,7 +1589,6 @@ static inline void cow_user_page(struct
+ if (__copy_from_user_inatomic(kaddr, uaddr, PAGE_SIZE))
+ memset(kaddr, 0, PAGE_SIZE);
+ kunmap_atomic(kaddr, KM_USER0);
+- flush_dcache_page(dst);
+ return;
+
+ }
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 mm/mmap.c
+--- a/mm/mmap.c Wed Jul 18 12:23:24 2007 -0300
++++ b/mm/mmap.c Wed Aug 08 16:25:28 2007 -0300
+@@ -1976,6 +1976,10 @@ void exit_mmap(struct mm_struct *mm)
+ struct vm_area_struct *vma = mm->mmap;
unsigned long nr_accounted = 0;
unsigned long end;
-
++
+#ifdef arch_exit_mmap
+ arch_exit_mmap(mm);
+#endif
-+
+
lru_add_drain();
flush_cache_mm(mm);
- tlb = tlb_gather_mmu(mm, 1);
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/mm/page_alloc.c source/mm/page_alloc.c
---- /scratch/src/linux-2.6.20.3/mm/page_alloc.c 2007-02-04 19:44:54.000000000 +0100
-+++ source/mm/page_alloc.c 2007-03-20 21:27:04.000000000 +0100
-@@ -490,6 +490,8 @@ static void __free_pages_ok(struct page
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 mm/page_alloc.c
+--- a/mm/page_alloc.c Wed Jul 18 12:23:24 2007 -0300
++++ b/mm/page_alloc.c Wed Aug 08 16:25:28 2007 -0300
+@@ -199,7 +199,11 @@ static void bad_page(struct page *page)
+ 1 << PG_slab |
+ 1 << PG_swapcache |
+ 1 << PG_writeback |
+- 1 << PG_buddy );
++ 1 << PG_buddy |
++#ifdef CONFIG_X86_XEN
++ 1 << PG_pinned |
++#endif
++ 1 << PG_foreign );
+ set_page_count(page, 0);
+ reset_page_mapcount(page);
+ page->mapping = NULL;
+@@ -434,7 +438,11 @@ static inline int free_pages_check(struc
+ 1 << PG_swapcache |
+ 1 << PG_writeback |
+ 1 << PG_reserved |
+- 1 << PG_buddy ))))
++ 1 << PG_buddy |
++#ifdef CONFIG_X86_XEN
++ 1 << PG_pinned |
++#endif
++ 1 << PG_foreign ))))
+ bad_page(page);
+ if (PageDirty(page))
+ __ClearPageDirty(page);
+@@ -490,6 +498,8 @@ static void __free_pages_ok(struct page
int i;
int reserved = 0;
@@ -94840,7 +92986,7 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
for (i = 0 ; i < (1 << order) ; ++i)
reserved += free_pages_check(page + i);
if (reserved)
-@@ -497,7 +499,6 @@ static void __free_pages_ok(struct page
+@@ -497,7 +507,6 @@ static void __free_pages_ok(struct page
if (!PageHighMem(page))
debug_check_no_locks_freed(page_address(page),PAGE_SIZE<<order);
@@ -94848,19 +92994,32 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
kernel_map_pages(page, 1 << order, 0);
local_irq_save(flags);
-@@ -784,6 +785,9 @@ static void fastcall free_hot_cold_page(
+@@ -584,7 +593,11 @@ static int prep_new_page(struct page *pa
+ 1 << PG_swapcache |
+ 1 << PG_writeback |
+ 1 << PG_reserved |
+- 1 << PG_buddy ))))
++ 1 << PG_buddy |
++#ifdef CONFIG_X86_XEN
++ 1 << PG_pinned |
++#endif
++ 1 << PG_foreign ))))
+ bad_page(page);
+
+ /*
+@@ -783,6 +796,9 @@ static void fastcall free_hot_cold_page(
+ struct zone *zone = page_zone(page);
struct per_cpu_pages *pcp;
unsigned long flags;
-
++
+ if (arch_free_page(page, 0))
+ return;
-+
+
if (PageAnon(page))
page->mapping = NULL;
- if (free_pages_check(page))
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/net/core/dev.c source/net/core/dev.c
---- /scratch/src/linux-2.6.20.3/net/core/dev.c 2007-02-04 19:44:54.000000000 +0100
-+++ source/net/core/dev.c 2007-03-20 21:27:05.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 net/core/dev.c
+--- a/net/core/dev.c Wed Jul 18 12:23:24 2007 -0300
++++ b/net/core/dev.c Wed Aug 08 16:25:28 2007 -0300
@@ -117,6 +117,12 @@
#include <linux/err.h>
#include <linux/ctype.h>
@@ -94918,23 +93077,26 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
/**
* dev_queue_xmit - transmit a buffer
* @skb: buffer to transmit
-@@ -1424,6 +1467,12 @@ int dev_queue_xmit(struct sk_buff *skb)
+@@ -1423,6 +1466,12 @@ int dev_queue_xmit(struct sk_buff *skb)
+ struct net_device *dev = skb->dev;
struct Qdisc *q;
int rc = -ENOMEM;
-
++
+ /* If a checksum-deferred packet is forwarded to a device that needs a
+ * checksum, correct the pointers and force checksumming.
+ */
+ if (skb_checksum_setup(skb))
+ goto out_kfree_skb;
-+
+
/* GSO will handle the following emulations directly. */
if (netif_needs_gso(dev, skb))
- goto gso;
-@@ -1799,6 +1848,19 @@ int netif_receive_skb(struct sk_buff *sk
- }
- #endif
-
+@@ -1796,6 +1845,19 @@ int netif_receive_skb(struct sk_buff *sk
+ if (skb->tc_verd & TC_NCLS) {
+ skb->tc_verd = CLR_TC_NCLS(skb->tc_verd);
+ goto ncls;
++ }
++#endif
++
+#ifdef CONFIG_XEN
+ switch (skb->ip_summed) {
+ case CHECKSUM_UNNECESSARY:
@@ -94945,13 +93107,10 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
+ default:
+ skb->proto_data_valid = 0;
+ break;
-+ }
-+#endif
-+
- list_for_each_entry_rcu(ptype, &ptype_all, list) {
- if (!ptype->dev || ptype->dev == skb->dev) {
- if (pt_prev)
-@@ -3563,6 +3625,7 @@ EXPORT_SYMBOL(unregister_netdevice_notif
+ }
+ #endif
+
+@@ -3565,6 +3627,7 @@ EXPORT_SYMBOL(net_enable_timestamp);
EXPORT_SYMBOL(net_enable_timestamp);
EXPORT_SYMBOL(net_disable_timestamp);
EXPORT_SYMBOL(dev_get_flags);
@@ -94959,69 +93118,18 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
#if defined(CONFIG_BRIDGE) || defined(CONFIG_BRIDGE_MODULE)
EXPORT_SYMBOL(br_handle_frame_hook);
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/net/core/skbuff.c source/net/core/skbuff.c
---- /scratch/src/linux-2.6.20.3/net/core/skbuff.c 2007-02-04 19:44:54.000000000 +0100
-+++ source/net/core/skbuff.c 2007-03-21 14:49:46.000000000 +0100
-@@ -141,6 +141,7 @@ EXPORT_SYMBOL(skb_truesize_bug);
- * Buffers may only be allocated from interrupts using a @gfp_mask of
- * %GFP_ATOMIC.
- */
-+#ifndef CONFIG_HAVE_ARCH_ALLOC_SKB
- struct sk_buff *__alloc_skb(unsigned int size, gfp_t gfp_mask,
- int fclone, int node)
- {
-@@ -196,6 +197,7 @@ nodata:
- skb = NULL;
- goto out;
- }
-+#endif /* !CONFIG_HAVE_ARCH_ALLOC_SKB */
-
- /**
- * alloc_skb_from_cache - allocate a network buffer
-@@ -213,14 +215,17 @@ nodata:
- */
- struct sk_buff *alloc_skb_from_cache(struct kmem_cache *cp,
- unsigned int size,
-- gfp_t gfp_mask)
-+ gfp_t gfp_mask,
-+ int fclone)
- {
-+ struct kmem_cache *cache;
- struct sk_buff *skb;
- u8 *data;
-
-+ cache = fclone ? skbuff_fclone_cache : skbuff_head_cache;
-+
- /* Get the HEAD */
-- skb = kmem_cache_alloc(skbuff_head_cache,
-- gfp_mask & ~__GFP_DMA);
-+ skb = kmem_cache_alloc(cache, gfp_mask & ~__GFP_DMA);
- if (!skb)
- goto out;
-
-@@ -244,10 +249,20 @@ struct sk_buff *alloc_skb_from_cache(str
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 net/core/skbuff.c
+--- a/net/core/skbuff.c Wed Jul 18 12:23:24 2007 -0300
++++ b/net/core/skbuff.c Wed Aug 08 16:25:28 2007 -0300
+@@ -243,6 +243,7 @@ struct sk_buff *alloc_skb_from_cache(str
+ skb_shinfo(skb)->gso_size = 0;
skb_shinfo(skb)->gso_segs = 0;
skb_shinfo(skb)->gso_type = 0;
++ skb_shinfo(skb)->ip6_frag_id = 0;
skb_shinfo(skb)->frag_list = NULL;
-+
-+ if (fclone) {
-+ struct sk_buff *child = skb + 1;
-+ atomic_t *fclone_ref = (atomic_t *) (child + 1);
-+
-+ skb->fclone = SKB_FCLONE_ORIG;
-+ atomic_set(fclone_ref, 1);
-+
-+ child->fclone = SKB_FCLONE_UNAVAILABLE;
-+ }
out:
return skb;
- nodata:
-- kmem_cache_free(skbuff_head_cache, skb);
-+ kmem_cache_free(cache, skb);
- skb = NULL;
- goto out;
- }
-@@ -468,6 +483,10 @@ struct sk_buff *skb_clone(struct sk_buff
+@@ -469,6 +470,10 @@ struct sk_buff *skb_clone(struct sk_buff
C(local_df);
n->cloned = 1;
n->nohdr = 0;
@@ -95032,9 +93140,17 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
C(pkt_type);
C(ip_summed);
C(priority);
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/net/ipv4/netfilter/ip_nat_proto_tcp.c source/net/ipv4/netfilter/ip_nat_proto_tcp.c
---- /scratch/src/linux-2.6.20.3/net/ipv4/netfilter/ip_nat_proto_tcp.c 2007-02-04 19:44:54.000000000 +0100
-+++ source/net/ipv4/netfilter/ip_nat_proto_tcp.c 2007-03-20 21:27:06.000000000 +0100
+@@ -643,7 +648,6 @@ struct sk_buff *pskb_copy(struct sk_buff
+ n->csum = skb->csum;
+ n->ip_summed = skb->ip_summed;
+
+- n->truesize += skb->data_len;
+ n->data_len = skb->data_len;
+ n->len = skb->len;
+
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 net/ipv4/netfilter/ip_nat_proto_tcp.c
+--- a/net/ipv4/netfilter/ip_nat_proto_tcp.c Wed Jul 18 12:23:24 2007 -0300
++++ b/net/ipv4/netfilter/ip_nat_proto_tcp.c Wed Aug 08 16:25:28 2007 -0300
@@ -129,8 +129,15 @@ tcp_manip_pkt(struct sk_buff **pskb,
if (hdrsize < sizeof(*hdr))
return 1;
@@ -95051,9 +93167,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
return 1;
}
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/net/ipv4/netfilter/ip_nat_proto_udp.c source/net/ipv4/netfilter/ip_nat_proto_udp.c
---- /scratch/src/linux-2.6.20.3/net/ipv4/netfilter/ip_nat_proto_udp.c 2007-02-04 19:44:54.000000000 +0100
-+++ source/net/ipv4/netfilter/ip_nat_proto_udp.c 2007-03-20 21:27:06.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 net/ipv4/netfilter/ip_nat_proto_udp.c
+--- a/net/ipv4/netfilter/ip_nat_proto_udp.c Wed Jul 18 12:23:24 2007 -0300
++++ b/net/ipv4/netfilter/ip_nat_proto_udp.c Wed Aug 08 16:25:28 2007 -0300
@@ -115,8 +115,16 @@ udp_manip_pkt(struct sk_buff **pskb,
}
@@ -95071,18 +93187,18 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
if (!hdr->check)
hdr->check = CSUM_MANGLED_0;
}
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/net/ipv4/xfrm4_output.c source/net/ipv4/xfrm4_output.c
---- /scratch/src/linux-2.6.20.3/net/ipv4/xfrm4_output.c 2007-02-04 19:44:54.000000000 +0100
-+++ source/net/ipv4/xfrm4_output.c 2007-03-20 21:27:06.000000000 +0100
-@@ -18,6 +18,8 @@
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 net/ipv4/xfrm4_output.c
+--- a/net/ipv4/xfrm4_output.c Wed Jul 18 12:23:24 2007 -0300
++++ b/net/ipv4/xfrm4_output.c Wed Aug 08 16:25:28 2007 -0300
+@@ -17,6 +17,8 @@
+ #include <net/ip.h>
#include <net/xfrm.h>
#include <net/icmp.h>
-
-+extern int skb_checksum_setup(struct sk_buff *skb);
+
++extern int skb_checksum_setup(struct sk_buff *skb);
+
static int xfrm4_tunnel_check_size(struct sk_buff *skb)
{
- int mtu, ret = 0;
@@ -48,6 +50,10 @@ static int xfrm4_output_one(struct sk_bu
struct xfrm_state *x = dst->xfrm;
int err;
@@ -95094,223 +93210,9 @@ diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/sr
if (skb->ip_summed == CHECKSUM_PARTIAL) {
err = skb_checksum_help(skb);
if (err)
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/net/ipv6/addrconf.c source/net/ipv6/addrconf.c
---- /scratch/src/linux-2.6.20.3/net/ipv6/addrconf.c 2007-03-20 21:30:36.000000000 +0100
-+++ source/net/ipv6/addrconf.c 2007-03-20 21:33:44.000000000 +0100
-@@ -2553,6 +2553,8 @@ static void addrconf_dad_start(struct in
- spin_lock_bh(&ifp->lock);
-
- if (dev->flags&(IFF_NOARP|IFF_LOOPBACK) ||
-+
-+ !(dev->flags&IFF_MULTICAST) ||
- !(ifp->flags&IFA_F_TENTATIVE) ||
- ifp->flags & IFA_F_NODAD) {
- ifp->flags &= ~IFA_F_TENTATIVE;
-@@ -2638,6 +2640,7 @@ static void addrconf_dad_completed(struc
- if (ifp->idev->cnf.forwarding == 0 &&
- ifp->idev->cnf.rtr_solicits > 0 &&
- (dev->flags&IFF_LOOPBACK) == 0 &&
-+ (dev->flags & IFF_MULTICAST) &&
- (ipv6_addr_type(&ifp->addr) & IPV6_ADDR_LINKLOCAL)) {
- struct in6_addr all_routers;
-
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/net/packet/af_packet.c source/net/packet/af_packet.c
---- /scratch/src/linux-2.6.20.3/net/packet/af_packet.c 2007-02-04 19:44:54.000000000 +0100
-+++ source/net/packet/af_packet.c 2007-03-21 17:37:09.000000000 +0100
-@@ -60,6 +60,7 @@
- #include <linux/netdevice.h>
- #include <linux/if_packet.h>
- #include <linux/wireless.h>
-+#include <linux/kernel.h>
- #include <linux/kmod.h>
- #include <net/ip.h>
- #include <net/protocol.h>
-@@ -200,7 +201,8 @@ struct packet_sock {
- #endif
- struct packet_type prot_hook;
- spinlock_t bind_lock;
-- char running; /* prot_hook is attached*/
-+ unsigned int running:1, /* prot_hook is attached*/
-+ auxdata:1;
- int ifindex; /* bound device */
- __be16 num;
- #ifdef CONFIG_PACKET_MULTICAST
-@@ -214,6 +216,18 @@ struct packet_sock {
- #endif
- };
-
-+struct packet_skb_cb {
-+ unsigned int origlen;
-+ union {
-+ struct sockaddr_pkt pkt;
-+ struct sockaddr_ll ll;
-+ } sa;
-+};
-+
-+#define PACKET_SKB_CB(__skb) ((struct packet_skb_cb *)((__skb)->cb))
-+
-+extern int skb_checksum_setup(struct sk_buff *skb);
-+
- #ifdef CONFIG_PACKET_MMAP
-
- static inline char *packet_lookup_frame(struct packet_sock *po, unsigned int position)
-@@ -293,7 +307,7 @@ static int packet_rcv_spkt(struct sk_buf
- /* drop conntrack reference */
- nf_reset(skb);
-
-- spkt = (struct sockaddr_pkt*)skb->cb;
-+ spkt = &PACKET_SKB_CB(skb)->sa.pkt;
-
- skb_push(skb, skb->data-skb->mac.raw);
-
-@@ -512,7 +526,10 @@ static int packet_rcv(struct sk_buff *sk
- skb = nskb;
- }
-
-- sll = (struct sockaddr_ll*)skb->cb;
-+ BUILD_BUG_ON(sizeof(*PACKET_SKB_CB(skb)) + MAX_ADDR_LEN - 8 >
-+ sizeof(skb->cb));
-+
-+ sll = &PACKET_SKB_CB(skb)->sa.ll;
- sll->sll_family = AF_PACKET;
- sll->sll_hatype = dev->type;
- sll->sll_protocol = skb->protocol;
-@@ -523,6 +540,11 @@ static int packet_rcv(struct sk_buff *sk
- if (dev->hard_header_parse)
- sll->sll_halen = dev->hard_header_parse(skb, sll->sll_addr);
-
-+ if (skb_checksum_setup(skb))
-+ goto drop_n_acct;
-+
-+ PACKET_SKB_CB(skb)->origlen = skb->len;
-+
- if (pskb_trim(skb, snaplen))
- goto drop_n_acct;
-
-@@ -595,6 +617,11 @@ static int tpacket_rcv(struct sk_buff *s
- if (snaplen > res)
- snaplen = res;
-
-+ if (skb_checksum_setup(skb))
-+ goto drop;
-+ if (skb->ip_summed == CHECKSUM_PARTIAL)
-+ status |= TP_STATUS_CSUMNOTREADY;
-+
- if (sk->sk_type == SOCK_DGRAM) {
- macoff = netoff = TPACKET_ALIGN(TPACKET_HDRLEN) + 16;
- } else {
-@@ -1092,7 +1119,7 @@ static int packet_recvmsg(struct kiocb *
- * it in now.
- */
-
-- sll = (struct sockaddr_ll*)skb->cb;
-+ sll = &PACKET_SKB_CB(skb)->sa.ll;
- if (sock->type == SOCK_PACKET)
- msg->msg_namelen = sizeof(struct sockaddr_pkt);
- else
-@@ -1117,7 +1144,22 @@ static int packet_recvmsg(struct kiocb *
- sock_recv_timestamp(msg, sk, skb);
-
- if (msg->msg_name)
-- memcpy(msg->msg_name, skb->cb, msg->msg_namelen);
-+ memcpy(msg->msg_name, &PACKET_SKB_CB(skb)->sa,
-+ msg->msg_namelen);
-+
-+ if (pkt_sk(sk)->auxdata) {
-+ struct tpacket_auxdata aux;
-+
-+ aux.tp_status = TP_STATUS_USER;
-+ if (skb->ip_summed == CHECKSUM_PARTIAL)
-+ aux.tp_status |= TP_STATUS_CSUMNOTREADY;
-+ aux.tp_len = PACKET_SKB_CB(skb)->origlen;
-+ aux.tp_snaplen = skb->len;
-+ aux.tp_mac = 0;
-+ aux.tp_net = skb->nh.raw - skb->data;
-+
-+ put_cmsg(msg, SOL_PACKET, PACKET_AUXDATA, sizeof(aux), &aux);
-+ }
-
- /*
- * Free or return the buffer as appropriate. Again this
-@@ -1317,6 +1359,7 @@ static int
- packet_setsockopt(struct socket *sock, int level, int optname, char __user *optval, int optlen)
- {
- struct sock *sk = sock->sk;
-+ struct packet_sock *po = pkt_sk(sk);
- int ret;
-
- if (level != SOL_PACKET)
-@@ -1369,6 +1412,18 @@ packet_setsockopt(struct socket *sock, i
- return 0;
- }
- #endif
-+ case PACKET_AUXDATA:
-+ {
-+ int val;
-+
-+ if (optlen < sizeof(val))
-+ return -EINVAL;
-+ if (copy_from_user(&val, optval, sizeof(val)))
-+ return -EFAULT;
-+
-+ po->auxdata = !!val;
-+ return 0;
-+ }
- default:
- return -ENOPROTOOPT;
- }
-@@ -1378,8 +1433,11 @@ static int packet_getsockopt(struct sock
- char __user *optval, int __user *optlen)
- {
- int len;
-+ int val;
- struct sock *sk = sock->sk;
- struct packet_sock *po = pkt_sk(sk);
-+ void *data;
-+ struct tpacket_stats st;
-
- if (level != SOL_PACKET)
- return -ENOPROTOOPT;
-@@ -1392,9 +1450,6 @@ static int packet_getsockopt(struct sock
-
- switch(optname) {
- case PACKET_STATISTICS:
-- {
-- struct tpacket_stats st;
--
- if (len > sizeof(struct tpacket_stats))
- len = sizeof(struct tpacket_stats);
- spin_lock_bh(&sk->sk_receive_queue.lock);
-@@ -1403,16 +1458,23 @@ static int packet_getsockopt(struct sock
- spin_unlock_bh(&sk->sk_receive_queue.lock);
- st.tp_packets += st.tp_drops;
-
-- if (copy_to_user(optval, &st, len))
-- return -EFAULT;
-+ data = &st;
-+ break;
-+ case PACKET_AUXDATA:
-+ if (len > sizeof(int))
-+ len = sizeof(int);
-+ val = po->auxdata;
-+
-+ data = &val;
- break;
-- }
- default:
- return -ENOPROTOOPT;
- }
-
- if (put_user(len, optlen))
- return -EFAULT;
-+ if (copy_to_user(optval, data, len))
-+ return -EFAULT;
- return 0;
- }
-
-diff -urNp --exclude-from=/home/mitica/quintela/config/misc/dontdiff /scratch/src/linux-2.6.20.3/scripts/Makefile.xen source/scripts/Makefile.xen
---- /scratch/src/linux-2.6.20.3/scripts/Makefile.xen 1970-01-01 01:00:00.000000000 +0100
-+++ source/scripts/Makefile.xen 2007-03-20 21:27:08.000000000 +0100
+diff -r 4a9ef6a03fd9 -r 85b796b085e5 scripts/Makefile.xen
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/scripts/Makefile.xen Wed Aug 08 16:25:28 2007 -0300
@@ -0,0 +1,14 @@
+
+# cherrypickxen($1 = allobj)
diff --git a/trunk/2.6.20/20956-linux-2.6-fix-x86_64-smp.patch b/trunk/2.6.20/20956-linux-2.6-fix-x86_64-smp.patch
deleted file mode 100644
index 24796a5..0000000
--- a/trunk/2.6.20/20956-linux-2.6-fix-x86_64-smp.patch
+++ /dev/null
@@ -1,19 +0,0 @@
---- linux-2.6.20.noarch/arch/x86_64/kernel/time-xen.c~orig 2007-04-26 02:05:31.000000000 -0700
-+++ linux-2.6.20.noarch/arch/x86_64/kernel/time-xen.c 2007-04-26 02:02:27.000000000 -0700
-@@ -985,7 +985,7 @@ void time_resume(void)
- #ifdef CONFIG_SMP
- static char timer_name[NR_CPUS][15];
-
--void local_setup_timer(unsigned int cpu)
-+int local_setup_timer(unsigned int cpu)
- {
- int seq;
-
-@@ -1009,6 +1009,7 @@ void local_setup_timer(unsigned int cpu)
- timer_name[cpu],
- NULL);
- BUG_ON(per_cpu(timer_irq, cpu) < 0);
-+ return 0;
- }
-
- void local_teardown_timer(unsigned int cpu)
diff --git a/trunk/2.6.20/20958-linux-2.6-xen-iscsi-x86_64-no_iommu_init.patch b/trunk/2.6.20/20958-linux-2.6-xen-iscsi-x86_64-no_iommu_init.patch
index e46e657..925b47b 100644
--- a/trunk/2.6.20/20958-linux-2.6-xen-iscsi-x86_64-no_iommu_init.patch
+++ b/trunk/2.6.20/20958-linux-2.6-xen-iscsi-x86_64-no_iommu_init.patch
@@ -7,21 +7,20 @@ Make sure no_iommu_init is called when needed on x86_64. Thanks
to Mark McLoughlin <markmc@redhat.com> for spotting the issue and
proposing a fix.
-Index: linux-2.6.20.i386/arch/i386/kernel/pci-dma-xen.c
+Index: patching/arch/i386/kernel/pci-dma-xen.c
===================================================================
---- linux-2.6.20.i386.orig/arch/i386/kernel/pci-dma-xen.c
-+++ linux-2.6.20.i386/arch/i386/kernel/pci-dma-xen.c
-@@ -21,6 +21,9 @@
- #include <asm/bug.h>
+--- patching.orig/arch/i386/kernel/pci-dma-xen.c
++++ patching/arch/i386/kernel/pci-dma-xen.c
+@@ -22,6 +22,8 @@
#ifdef __x86_64__
-+#include <asm/proto.h>
+ #include <asm/proto.h>
+#include <asm/calgary.h>
+
+
int iommu_merge __read_mostly = 0;
EXPORT_SYMBOL(iommu_merge);
-
-@@ -69,6 +72,22 @@ void __init pci_iommu_alloc(void)
+@@ -71,6 +73,22 @@ void __init pci_iommu_alloc(void)
#endif
}
diff --git a/trunk/2.6.20/20959-linux-2.6-xen-fix-nosegneg-detection.patch b/trunk/2.6.20/20959-linux-2.6-xen-fix-nosegneg-detection.patch
deleted file mode 100644
index 915b84a..0000000
--- a/trunk/2.6.20/20959-linux-2.6-xen-fix-nosegneg-detection.patch
+++ /dev/null
@@ -1,29 +0,0 @@
-From: Rik van Riel <riel@redhat.com>
-Subject: [PATCH][RHEL5] fix nosegneg detection
-Date: Wed, 03 Jan 2007 12:59:10 -0500
-Bugzilla: 220675
-Message-Id: <459BEEEE.2060006@redhat.com>
-Changelog: xen: fix nosegneg detection
-
-
-The attached patch fixes bug 220675, by placing the nosegneg flag
-exactly where glibc expects it to be. I swear I fixed this bug
-before once or twice, but the fix must have gotten lost somewhere.
-
-Please apply.
-
---
-Politics is the struggle between those who want to make their country
-the best in the world, and those who believe it already is. Each group
-calls the other unpatriotic.
-
---- linux-2.6.18.x86_64/arch/i386/kernel/vsyscall-note-xen.S.220675 2007-01-03 12:56:38.000000000 -0500
-+++ linux-2.6.18.x86_64/arch/i386/kernel/vsyscall-note-xen.S 2007-01-03 12:56:47.000000000 -0500
-@@ -28,5 +28,5 @@
- #define NOTE_KERNELCAP_END ASM_ELF_NOTE_END
-
- NOTE_KERNELCAP_BEGIN(1, 1)
--NOTE_KERNELCAP(1, "nosegneg") /* Change 1 back to 0 when glibc is fixed! */
-+NOTE_KERNELCAP(0, "nosegneg")
- NOTE_KERNELCAP_END
-
diff --git a/trunk/2.6.20/20960-linux-2.6-xen-blkfront-wait-add.patch b/trunk/2.6.20/20960-linux-2.6-xen-blkfront-wait-add.patch
index e17438b..0450058 100644
--- a/trunk/2.6.20/20960-linux-2.6-xen-blkfront-wait-add.patch
+++ b/trunk/2.6.20/20960-linux-2.6-xen-blkfront-wait-add.patch
@@ -1,6 +1,3 @@
-Make xenblk wait to the disk to be added
-See http://bugzilla.redhat.com/248462
-
Index: linux-2.6.20.i386/drivers/xen/blkfront/blkfront.c
===================================================================
--- linux-2.6.20.i386.orig/drivers/xen/blkfront/blkfront.c
diff --git a/trunk/2.6.20/20961_linux-2.6-xen-backwards-time.patch b/trunk/2.6.20/20961_linux-2.6-xen-backwards-time.patch
new file mode 100644
index 0000000..44552c7
--- /dev/null
+++ b/trunk/2.6.20/20961_linux-2.6-xen-backwards-time.patch
@@ -0,0 +1,63 @@
+
+# HG changeset patch
+# User kfraser@localhost.localdomain
+# Date 1182263776 -3600
+# Node ID 87bb8705768a66ceabb15a419c5f86580bffb6bf
+# Parent a413dd61e7e5e1bba11bab447184cf5e6b43513a
+x86 time: Ensure gettimeofday() is monotonically increasing.
+Signed-off-by: Atsushi SAKAI <sakaia@jp.fujitsu.com>
+
+Index: linux-2.6.20.i386/arch/i386/kernel/time-xen.c
+===================================================================
+--- linux-2.6.20.i386.orig/arch/i386/kernel/time-xen.c
++++ linux-2.6.20.i386/arch/i386/kernel/time-xen.c
+@@ -109,6 +109,9 @@ static DEFINE_PER_CPU(struct shadow_time
+ static struct timespec shadow_tv;
+ static u32 shadow_tv_version;
+
++static struct timeval monotonic_tv;
++static spinlock_t monotonic_lock = SPIN_LOCK_UNLOCKED;
++
+ /* Keep track of last time we did processing/updating of jiffies and xtime. */
+ static u64 processed_system_time; /* System time (ns) at last processing. */
+ static DEFINE_PER_CPU(u64, processed_system_time);
+@@ -324,6 +327,7 @@ void do_gettimeofday(struct timeval *tv)
+ unsigned long seq;
+ unsigned long usec, sec;
+ unsigned long max_ntp_tick;
++ unsigned long flags;
+ s64 nsec;
+ unsigned int cpu;
+ struct shadow_time_info *shadow;
+@@ -376,6 +380,18 @@ void do_gettimeofday(struct timeval *tv)
+ sec++;
+ }
+
++ spin_lock_irqsave(&monotonic_lock, flags);
++ if ((sec > monotonic_tv.tv_sec) ||
++ ((sec == monotonic_tv.tv_sec) && (usec > monotonic_tv.tv_usec)))
++ {
++ monotonic_tv.tv_sec = sec;
++ monotonic_tv.tv_usec = usec;
++ } else {
++ sec = monotonic_tv.tv_sec;
++ usec = monotonic_tv.tv_usec;
++ }
++ spin_unlock_irqrestore(&monotonic_lock, flags);
++
+ tv->tv_sec = sec;
+ tv->tv_usec = usec;
+ }
+@@ -425,6 +441,12 @@ int do_settimeofday(struct timespec *tv)
+ __update_wallclock(sec, nsec);
+ }
+
++ /* Reset monotonic gettimeofday() timeval. */
++ spin_lock(&monotonic_lock);
++ monotonic_tv.tv_sec = 0;
++ monotonic_tv.tv_usec = 0;
++ spin_unlock(&monotonic_lock);
++
+ write_sequnlock_irq(&xtime_lock);
+
+ put_cpu();
diff --git a/trunk/2.6.20/20962_linux-2.6-xen-add-packet_auxdata-cmsg-1.patch b/trunk/2.6.20/20962_linux-2.6-xen-add-packet_auxdata-cmsg-1.patch
new file mode 100644
index 0000000..16f11fa
--- /dev/null
+++ b/trunk/2.6.20/20962_linux-2.6-xen-add-packet_auxdata-cmsg-1.patch
@@ -0,0 +1,233 @@
+From: Herbert Xu <herbert.xu@redhat.com>
+Subject: [RHEL5 PATCH] [PACKET]: Add PACKET_AUXDATA cmsg
+Date: Wed, 10 Jan 2007 20:17:36 +1100
+Message-Id: <20070110091736.GA28579@gondor.apana.org.au>
+Changelog: xen: Add PACKET_AUXDATA cmsg
+
+
+Hi:
+
+RHEL5 BZ 219681
+
+This patch forms part of the solution to #219681 where the DHCP server
+can't serve any requests from clients running (in different domains)
+on the same Xen host.
+
+I've sent a similar patch (without the Xen-specific code) upstream.
+
+This obsoletes the previous patch that computed the checksums in
+kernel-space.
+
+[PACKET]: Add PACKET_AUXDATA cmsg
+
+HCP servers/clients using AF_PACKET) to be able to serve another
+client on the same Xen host.
+
+The problem is that packets between different domains on the same
+Xen host only have partial checksums. Unfortunately this piece of
+information is not passed along in AF_PACKET unless you're using
+the mmap interface. Since dhcpd doesn't support packet-mmap, UDP
+packets from the same host come out with apparently bogus checksums.
+
+This patch adds a mechanism for AF_PACKET recvmsg(2) to return the
+status along with the packet. It does so by adding a new cmsg that
+contains this information along with some other relevant data such
+as the original packet length.
+
+I didn't include the time stamp information since there is already
+a cmsg for that.
+
+This patch also changes the mmap code to set the CSUMNOTREADY flag
+on all packets instead of just outoing packets on cooked sockets.
+
+Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
+
+Index: linux-2.6.20.i386/include/linux/if_packet.h
+===================================================================
+--- linux-2.6.20.i386.orig/include/linux/if_packet.h
++++ linux-2.6.20.i386/include/linux/if_packet.h
+@@ -41,6 +41,7 @@ struct sockaddr_ll
+ #define PACKET_RX_RING 5
+ #define PACKET_STATISTICS 6
+ #define PACKET_COPY_THRESH 7
++#define PACKET_AUXDATA 8
+
+ struct tpacket_stats
+ {
+@@ -48,6 +49,15 @@ struct tpacket_stats
+ unsigned int tp_drops;
+ };
+
++struct tpacket_auxdata
++{
++ __u32 tp_status;
++ __u32 tp_len;
++ __u32 tp_snaplen;
++ __u16 tp_mac;
++ __u16 tp_net;
++};
++
+ struct tpacket_hdr
+ {
+ unsigned long tp_status;
+Index: linux-2.6.20.i386/net/packet/af_packet.c
+===================================================================
+--- linux-2.6.20.i386.orig/net/packet/af_packet.c
++++ linux-2.6.20.i386/net/packet/af_packet.c
+@@ -200,7 +200,8 @@ struct packet_sock {
+ #endif
+ struct packet_type prot_hook;
+ spinlock_t bind_lock;
+- char running; /* prot_hook is attached*/
++ unsigned int running:1, /* prot_hook is attached*/
++ auxdata:1;
+ int ifindex; /* bound device */
+ __be16 num;
+ #ifdef CONFIG_PACKET_MULTICAST
+@@ -214,6 +215,10 @@ struct packet_sock {
+ #endif
+ };
+
++#define PACKET_SKB_CB(__skb) ((struct tpacket_auxdata *)((__skb)->cb))
++
++extern int skb_checksum_setup(struct sk_buff *skb);
++
+ #ifdef CONFIG_PACKET_MMAP
+
+ static inline char *packet_lookup_frame(struct packet_sock *po, unsigned int position)
+@@ -462,6 +467,7 @@ static int packet_rcv(struct sk_buff *sk
+ u8 * skb_head = skb->data;
+ int skb_len = skb->len;
+ unsigned int snaplen, res;
++ struct tpacket_auxdata *aux;
+
+ if (skb->pkt_type == PACKET_LOOPBACK)
+ goto drop;
+@@ -523,6 +529,18 @@ static int packet_rcv(struct sk_buff *sk
+ if (dev->hard_header_parse)
+ sll->sll_halen = dev->hard_header_parse(skb, sll->sll_addr);
+
++ if (skb_checksum_setup(skb))
++ goto drop_n_acct;
++
++ aux = PACKET_SKB_CB(skb);
++ aux->tp_status = TP_STATUS_USER;
++ if (skb->ip_summed == CHECKSUM_PARTIAL)
++ aux->tp_status |= TP_STATUS_CSUMNOTREADY;
++ aux->tp_len = skb->len;
++ aux->tp_snaplen = snaplen;
++ aux->tp_mac = 0;
++ aux->tp_net = skb->nh.raw - skb->data;
++
+ if (pskb_trim(skb, snaplen))
+ goto drop_n_acct;
+
+@@ -582,8 +600,6 @@ static int tpacket_rcv(struct sk_buff *s
+ else if (skb->pkt_type == PACKET_OUTGOING) {
+ /* Special case: outgoing packets have ll header at head */
+ skb_pull(skb, skb->nh.raw - skb->data);
+- if (skb->ip_summed == CHECKSUM_PARTIAL)
+- status |= TP_STATUS_CSUMNOTREADY;
+ }
+ }
+
+@@ -595,6 +611,11 @@ static int tpacket_rcv(struct sk_buff *s
+ if (snaplen > res)
+ snaplen = res;
+
++ if (skb_checksum_setup(skb))
++ goto drop;
++ if (skb->ip_summed == CHECKSUM_PARTIAL)
++ status |= TP_STATUS_CSUMNOTREADY;
++
+ if (sk->sk_type == SOCK_DGRAM) {
+ macoff = netoff = TPACKET_ALIGN(TPACKET_HDRLEN) + 16;
+ } else {
+@@ -1119,6 +1140,11 @@ static int packet_recvmsg(struct kiocb *
+ if (msg->msg_name)
+ memcpy(msg->msg_name, skb->cb, msg->msg_namelen);
+
++ if (pkt_sk(sk)->auxdata) {
++ struct tpacket_auxdata *aux = PACKET_SKB_CB(skb);
++ put_cmsg(msg, SOL_PACKET, PACKET_AUXDATA, sizeof(*aux), aux);
++ }
++
+ /*
+ * Free or return the buffer as appropriate. Again this
+ * hides all the races and re-entrancy issues from us.
+@@ -1317,6 +1343,7 @@ static int
+ packet_setsockopt(struct socket *sock, int level, int optname, char __user *optval, int optlen)
+ {
+ struct sock *sk = sock->sk;
++ struct packet_sock *po = pkt_sk(sk);
+ int ret;
+
+ if (level != SOL_PACKET)
+@@ -1369,6 +1396,18 @@ packet_setsockopt(struct socket *sock, i
+ return 0;
+ }
+ #endif
++ case PACKET_AUXDATA:
++ {
++ int val;
++
++ if (optlen < sizeof(val))
++ return -EINVAL;
++ if (copy_from_user(&val, optval, sizeof(val)))
++ return -EFAULT;
++
++ po->auxdata = !!val;
++ return 0;
++ }
+ default:
+ return -ENOPROTOOPT;
+ }
+@@ -1378,8 +1417,11 @@ static int packet_getsockopt(struct sock
+ char __user *optval, int __user *optlen)
+ {
+ int len;
++ int val;
+ struct sock *sk = sock->sk;
+ struct packet_sock *po = pkt_sk(sk);
++ void *data;
++ struct tpacket_stats st;
+
+ if (level != SOL_PACKET)
+ return -ENOPROTOOPT;
+@@ -1392,9 +1434,6 @@ static int packet_getsockopt(struct sock
+
+ switch(optname) {
+ case PACKET_STATISTICS:
+- {
+- struct tpacket_stats st;
+-
+ if (len > sizeof(struct tpacket_stats))
+ len = sizeof(struct tpacket_stats);
+ spin_lock_bh(&sk->sk_receive_queue.lock);
+@@ -1403,16 +1442,23 @@ static int packet_getsockopt(struct sock
+ spin_unlock_bh(&sk->sk_receive_queue.lock);
+ st.tp_packets += st.tp_drops;
+
+- if (copy_to_user(optval, &st, len))
+- return -EFAULT;
++ data = &st;
++ break;
++ case PACKET_AUXDATA:
++ if (len > sizeof(int))
++ len = sizeof(int);
++ val = po->auxdata;
++
++ data = &val;
+ break;
+- }
+ default:
+ return -ENOPROTOOPT;
+ }
+
+ if (put_user(len, optlen))
+ return -EFAULT;
++ if (copy_to_user(optval, data, len))
++ return -EFAULT;
+ return 0;
+ }
+
diff --git a/trunk/2.6.20/20963_linux-2.6-xen-add-packet_auxdata-cmsg-2.patch b/trunk/2.6.20/20963_linux-2.6-xen-add-packet_auxdata-cmsg-2.patch
new file mode 100644
index 0000000..8bf6bf7
--- /dev/null
+++ b/trunk/2.6.20/20963_linux-2.6-xen-add-packet_auxdata-cmsg-2.patch
@@ -0,0 +1,144 @@
+From: Herbert Xu <herbert.xu@redhat.com>
+Subject: Re: Help on BZ 223505 tcpdump causes ppc64 to enter xmon
+Date: Wed, 24 Jan 2007 10:23:55 +1100
+Message-Id: <20070123232355.GA4724@gondor.apana.org.au>
+
+On Wed, Jan 24, 2007 at 09:03:24AM +1100, Herbert Xu wrote:
+>
+> OK, I've found the problem. The skb->cb buffer is already being
+> used for sockaddr_ll which the aux data is overwriting. Let me
+> fix this up by getting them to share the buffer.
+
+The obvious fix of putting them together in the cb doesn't quite work
+because sockaddr_ll's last member can be as large as MAX_ADDR_LEN (32).
+In fact this means that older kernels with skb->cb less than 44 bytes
+may in fact be vulnerable if net devices with an address length of 32
+bytes exist.
+
+[PACKET]: Fix skb->cb clobbering between aux and sockaddr
+
+Both aux data and sockaddr tries to use the same buffer which
+obviously doesn't work. We just happen to have 4 bytes free in
+the skb->cb if you take away the maximum length of sockaddr_ll.
+That's just enough to store the one piece of info from aux data
+that we can't generate at recvmsg(2) time.
+
+This is what the following patch does.
+
+Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
+
+Cheers,
+--
+Visit Openswan at http://www.openswan.org/
+Email: Herbert Xu ~{PmV>HI~} <herbert@gondor.apana.org.au>
+Home Page: http://gondor.apana.org.au/~herbert/
+PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
+--
+Index: linux-2.6.20.i386/net/packet/af_packet.c
+===================================================================
+--- linux-2.6.20.i386.orig/net/packet/af_packet.c
++++ linux-2.6.20.i386/net/packet/af_packet.c
+@@ -60,6 +60,7 @@
+ #include <linux/netdevice.h>
+ #include <linux/if_packet.h>
+ #include <linux/wireless.h>
++#include <linux/kernel.h>
+ #include <linux/kmod.h>
+ #include <net/ip.h>
+ #include <net/protocol.h>
+@@ -215,7 +216,15 @@ struct packet_sock {
+ #endif
+ };
+
+-#define PACKET_SKB_CB(__skb) ((struct tpacket_auxdata *)((__skb)->cb))
++struct packet_skb_cb {
++ unsigned int origlen;
++ union {
++ struct sockaddr_pkt pkt;
++ struct sockaddr_ll ll;
++ } sa;
++};
++
++#define PACKET_SKB_CB(__skb) ((struct packet_skb_cb *)((__skb)->cb))
+
+ extern int skb_checksum_setup(struct sk_buff *skb);
+
+@@ -298,7 +307,7 @@ static int packet_rcv_spkt(struct sk_buf
+ /* drop conntrack reference */
+ nf_reset(skb);
+
+- spkt = (struct sockaddr_pkt*)skb->cb;
++ spkt = &PACKET_SKB_CB(skb)->sa.pkt;
+
+ skb_push(skb, skb->data-skb->mac.raw);
+
+@@ -467,7 +476,6 @@ static int packet_rcv(struct sk_buff *sk
+ u8 * skb_head = skb->data;
+ int skb_len = skb->len;
+ unsigned int snaplen, res;
+- struct tpacket_auxdata *aux;
+
+ if (skb->pkt_type == PACKET_LOOPBACK)
+ goto drop;
+@@ -518,7 +526,10 @@ static int packet_rcv(struct sk_buff *sk
+ skb = nskb;
+ }
+
+- sll = (struct sockaddr_ll*)skb->cb;
++ BUILD_BUG_ON(sizeof(*PACKET_SKB_CB(skb)) + MAX_ADDR_LEN - 8 >
++ sizeof(skb->cb));
++
++ sll = &PACKET_SKB_CB(skb)->sa.ll;
+ sll->sll_family = AF_PACKET;
+ sll->sll_hatype = dev->type;
+ sll->sll_protocol = skb->protocol;
+@@ -532,14 +543,7 @@ static int packet_rcv(struct sk_buff *sk
+ if (skb_checksum_setup(skb))
+ goto drop_n_acct;
+
+- aux = PACKET_SKB_CB(skb);
+- aux->tp_status = TP_STATUS_USER;
+- if (skb->ip_summed == CHECKSUM_PARTIAL)
+- aux->tp_status |= TP_STATUS_CSUMNOTREADY;
+- aux->tp_len = skb->len;
+- aux->tp_snaplen = snaplen;
+- aux->tp_mac = 0;
+- aux->tp_net = skb->nh.raw - skb->data;
++ PACKET_SKB_CB(skb)->origlen = skb->len;
+
+ if (pskb_trim(skb, snaplen))
+ goto drop_n_acct;
+@@ -1113,7 +1117,7 @@ static int packet_recvmsg(struct kiocb *
+ * it in now.
+ */
+
+- sll = (struct sockaddr_ll*)skb->cb;
++ sll = &PACKET_SKB_CB(skb)->sa.ll;
+ if (sock->type == SOCK_PACKET)
+ msg->msg_namelen = sizeof(struct sockaddr_pkt);
+ else
+@@ -1138,11 +1142,21 @@ static int packet_recvmsg(struct kiocb *
+ sock_recv_timestamp(msg, sk, skb);
+
+ if (msg->msg_name)
+- memcpy(msg->msg_name, skb->cb, msg->msg_namelen);
++ memcpy(msg->msg_name, &PACKET_SKB_CB(skb)->sa,
++ msg->msg_namelen);
+
+ if (pkt_sk(sk)->auxdata) {
+- struct tpacket_auxdata *aux = PACKET_SKB_CB(skb);
+- put_cmsg(msg, SOL_PACKET, PACKET_AUXDATA, sizeof(*aux), aux);
++ struct tpacket_auxdata aux;
++
++ aux.tp_status = TP_STATUS_USER;
++ if (skb->ip_summed == CHECKSUM_PARTIAL)
++ aux.tp_status |= TP_STATUS_CSUMNOTREADY;
++ aux.tp_len = PACKET_SKB_CB(skb)->origlen;
++ aux.tp_snaplen = skb->len;
++ aux.tp_mac = 0;
++ aux.tp_net = skb->nh.raw - skb->data;
++
++ put_cmsg(msg, SOL_PACKET, PACKET_AUXDATA, sizeof(aux), &aux);
+ }
+
+ /*