]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blame - src/patches/60033_xen3-patch-2.6.24.patch1
Revert "Remove unused ath5k patch"
[people/pmueller/ipfire-2.x.git] / src / patches / 60033_xen3-patch-2.6.24.patch1
CommitLineData
cc90b958
BS
1From: www.kernel.org
2Subject: Update to 2.6.24
3Patch-mainline: 2.6.24
4
5Automatically created from "patches.kernel.org/patch-2.6.24" by xen-port-patches.py
6
7Acked-by: jbeulich@novell.com
8
9Index: head-2008-12-01/arch/x86/Kconfig
10===================================================================
11--- head-2008-12-01.orig/arch/x86/Kconfig 2008-12-01 11:36:13.000000000 +0100
12+++ head-2008-12-01/arch/x86/Kconfig 2008-12-01 11:36:55.000000000 +0100
13@@ -50,15 +50,16 @@ config GENERIC_CMOS_UPDATE
14
15 config CLOCKSOURCE_WATCHDOG
16 def_bool y
17- depends on !X86_XEN
18+ depends on !XEN
19
20 config GENERIC_CLOCKEVENTS
21 def_bool y
22- depends on !X86_XEN
23+ depends on !XEN
24
25 config GENERIC_CLOCKEVENTS_BROADCAST
26 def_bool y
27- depends on X86_64 || (X86_32 && X86_LOCAL_APIC && !X86_XEN)
28+ depends on X86_64 || (X86_32 && X86_LOCAL_APIC)
29+ depends on !XEN
30
31 config LOCKDEP_SUPPORT
32 def_bool y
33@@ -208,12 +209,12 @@ config X86_TRAMPOLINE
34
35 config X86_NO_TSS
36 bool
37- depends on X86_XEN || X86_64_XEN
38+ depends on XEN
39 default y
40
41 config X86_NO_IDT
42 bool
43- depends on X86_XEN || X86_64_XEN
44+ depends on XEN
45 default y
46
47 config KTIME_SCALAR
48@@ -283,6 +284,7 @@ config X86_PC
49
50 config X86_XEN
51 bool "Xen-compatible"
52+ depends on X86_32
53 select XEN
54 select X86_PAE
55 select X86_UP_APIC if !SMP && XEN_PRIVILEGED_GUEST
56@@ -361,6 +363,7 @@ endif
57
58 config X86_64_XEN
59 bool "Enable Xen compatible kernel"
60+ depends on X86_64
61 select XEN
62 select SWIOTLB
63 help
64@@ -413,7 +416,7 @@ config SCHED_NO_NO_OMIT_FRAME_POINTER
65
66 menuconfig PARAVIRT_GUEST
67 bool "Paravirtualized guest support"
68- depends on !X86_XEN && !X86_64_XEN
69+ depends on !XEN
70 help
71 Say Y here to get to see options related to running Linux under
72 various hypervisors. This option alone does not add any kernel code.
73@@ -507,7 +510,7 @@ source "arch/x86/Kconfig.cpu"
74 config HPET_TIMER
75 def_bool X86_64
76 prompt "HPET Timer Support" if X86_32
77- depends on !X86_XEN && !X86_64_XEN
78+ depends on !XEN
79 help
80 Use the IA-PC HPET (High Precision Event Timer) to manage
81 time in preference to the PIT and RTC, if a HPET is
82@@ -827,7 +830,7 @@ config I8K
83 config X86_REBOOTFIXUPS
84 def_bool n
85 prompt "Enable X86 board specific fixups for reboot"
86- depends on X86_32 && !X86_XEN
87+ depends on X86_32 && !XEN
88 ---help---
89 This enables chipset and/or board specific fixups to be done
90 in order to get reboot to work correctly. This is only needed on
91@@ -1160,7 +1163,7 @@ config X86_RESERVE_LOW_64K
92 config MATH_EMULATION
93 bool
94 prompt "Math emulation" if X86_32
95- depends on !X86_XEN
96+ depends on !XEN
97 ---help---
98 Linux can emulate a math coprocessor (used for floating point
99 operations) if you don't have one. 486DX and Pentium processors have
100@@ -1268,7 +1271,7 @@ config X86_PAT
101 config EFI
102 def_bool n
103 prompt "EFI runtime service support"
104- depends on ACPI && !X86_XEN && !X86_64_XEN
105+ depends on ACPI && !XEN
106 ---help---
107 This enables the kernel to use EFI runtime services that are
108 available (such as the EFI variable services).
109@@ -1283,7 +1286,7 @@ config EFI
110 config IRQBALANCE
111 def_bool y
112 prompt "Enable kernel irq balancing"
113- depends on X86_32 && SMP && X86_IO_APIC && !X86_XEN
114+ depends on X86_32 && SMP && X86_IO_APIC && !XEN
115 help
116 The default yes will allow the kernel to do irq load balancing.
117 Saying no will keep the kernel from doing irq load balancing.
118@@ -1429,7 +1432,7 @@ config PHYSICAL_START
119
120 config RELOCATABLE
121 bool "Build a relocatable kernel (EXPERIMENTAL)"
122- depends on EXPERIMENTAL && !X86_XEN && !X86_64_XEN
123+ depends on EXPERIMENTAL && !XEN
124 help
125 This builds a kernel image that retains relocation information
126 so it can be loaded someplace besides the default 1MB.
127@@ -1499,6 +1502,7 @@ endmenu
128 config ARCH_ENABLE_MEMORY_HOTPLUG
129 def_bool y
130 depends on X86_64 || (X86_32 && HIGHMEM)
131+ depends on !XEN
132
133 config HAVE_ARCH_EARLY_PFN_TO_NID
134 def_bool X86_64
135@@ -1689,7 +1693,7 @@ choice
136
137 config PCI_GOBIOS
138 bool "BIOS"
139- depends on !X86_XEN
140+ depends on !XEN
141
142 config PCI_GOMMCONFIG
143 bool "MMConfig"
144@@ -1740,7 +1744,7 @@ config PCI_MMCONFIG
145
146 config XEN_PCIDEV_FRONTEND
147 bool "Xen PCI Frontend" if X86_64
148- depends on PCI && ((X86_XEN && (PCI_GOXEN_FE || PCI_GOANY)) || X86_64_XEN)
149+ depends on PCI && XEN && (PCI_GOXEN_FE || PCI_GOANY || X86_64)
150 select HOTPLUG
151 default y
152 help
153@@ -1757,6 +1761,7 @@ config XEN_PCIDEV_FE_DEBUG
154 config DMAR
155 bool "Support for DMA Remapping Devices (EXPERIMENTAL)"
156 depends on X86_64 && PCI_MSI && ACPI && EXPERIMENTAL
157+ depends on !XEN
158 help
159 DMA remapping (DMAR) devices support enables independent address
160 translations for Direct Memory Access (DMA) from devices.
161Index: head-2008-12-01/arch/x86/Makefile
162===================================================================
163--- head-2008-12-01.orig/arch/x86/Makefile 2008-12-01 11:36:47.000000000 +0100
164+++ head-2008-12-01/arch/x86/Makefile 2008-12-01 11:36:55.000000000 +0100
165@@ -191,8 +191,8 @@ PHONY += zImage bzImage vmlinuz compress
166 zdisk bzdisk fdimage fdimage144 fdimage288 isoimage install
167
168 ifdef CONFIG_XEN
169-CPPFLAGS := -D__XEN_INTERFACE_VERSION__=$(CONFIG_XEN_INTERFACE_VERSION) \
170- -Iinclude$(if $(KBUILD_SRC),2)/asm/mach-xen $(CPPFLAGS)
171+KBUILD_CPPFLAGS := -D__XEN_INTERFACE_VERSION__=$(CONFIG_XEN_INTERFACE_VERSION) \
172+ -Iinclude$(if $(KBUILD_SRC),2)/asm/mach-xen $(KBUILD_CPPFLAGS)
173
174 ifdef CONFIG_X86_64
175 LDFLAGS_vmlinux := -e startup_64
176@@ -206,6 +206,8 @@ KBUILD_IMAGE := $(boot)/vmlinuz
177
178 vmlinuz: vmlinux
179 $(Q)$(MAKE) $(build)=$(boot) $(KBUILD_IMAGE)
180+ $(Q)mkdir -p $(objtree)/arch/$(UTS_MACHINE)/boot
181+ $(Q)ln -fsn ../../x86/boot/$@ $(objtree)/arch/$(UTS_MACHINE)/boot/$@
182 else
183 # Default kernel to build
184 all: bzImage
185Index: head-2008-12-01/arch/x86/ia32/ia32entry-xen.S
186===================================================================
187--- head-2008-12-01.orig/arch/x86/ia32/ia32entry-xen.S 2008-12-01 11:36:47.000000000 +0100
188+++ head-2008-12-01/arch/x86/ia32/ia32entry-xen.S 2008-12-01 11:36:55.000000000 +0100
189@@ -125,20 +125,16 @@ sysenter_do_call:
190 jmp int_ret_from_sys_call
191
192 sysenter_tracesys:
193+ xchgl %r9d,%ebp
194 SAVE_REST
195 CLEAR_RREGS
196+ movq %r9,R9(%rsp)
197 movq $-ENOSYS,RAX(%rsp) /* really needed? */
198 movq %rsp,%rdi /* &pt_regs -> arg1 */
199 call syscall_trace_enter
200 LOAD_ARGS32 ARGOFFSET /* reload args from stack in case ptrace changed it */
201 RESTORE_REST
202- movl %ebp, %ebp
203- /* no need to do an access_ok check here because rbp has been
204- 32bit zero extended */
205-1: movl (%rbp),%r9d
206- .section __ex_table,"a"
207- .quad 1b,ia32_badarg
208- .previous
209+ xchgl %ebp,%r9d
210 jmp sysenter_do_call
211 CFI_ENDPROC
212 ENDPROC(ia32_sysenter_target)
213@@ -200,20 +196,17 @@ cstar_do_call:
214 jmp int_ret_from_sys_call
215
216 cstar_tracesys:
217+ xchgl %r9d,%ebp
218 SAVE_REST
219 CLEAR_RREGS
220+ movq %r9,R9(%rsp)
221 movq $-ENOSYS,RAX(%rsp) /* really needed? */
222 movq %rsp,%rdi /* &pt_regs -> arg1 */
223 call syscall_trace_enter
224 LOAD_ARGS32 ARGOFFSET /* reload args from stack in case ptrace changed it */
225 RESTORE_REST
226+ xchgl %ebp,%r9d
227 movl RSP-ARGOFFSET(%rsp), %r8d
228- /* no need to do an access_ok check here because r8 has been
229- 32bit zero extended */
230-1: movl (%r8),%r9d
231- .section __ex_table,"a"
232- .quad 1b,ia32_badarg
233- .previous
234 jmp cstar_do_call
235 END(ia32_cstar_target)
236
237Index: head-2008-12-01/arch/x86/kernel/Makefile
238===================================================================
239--- head-2008-12-01.orig/arch/x86/kernel/Makefile 2008-12-01 11:36:13.000000000 +0100
240+++ head-2008-12-01/arch/x86/kernel/Makefile 2008-12-01 11:36:55.000000000 +0100
241@@ -127,4 +127,4 @@ endif
242 disabled-obj-$(CONFIG_XEN) := early-quirks.o hpet.o i8253.o i8259_$(BITS).o reboot.o \
243 smpboot_$(BITS).o tsc_$(BITS).o tsc_sync.o
244 disabled-obj-$(CONFIG_XEN_UNPRIVILEGED_GUEST) += mpparse_64.o
245-%/head_64.o %/head_64.s: $(if $(CONFIG_XEN),EXTRA_AFLAGS,dummy) :=
246+%/head_64.o %/head_64.s: asflags-$(CONFIG_XEN) :=
247Index: head-2008-12-01/arch/x86/kernel/acpi/sleep_32-xen.c
248===================================================================
249--- head-2008-12-01.orig/arch/x86/kernel/acpi/sleep_32-xen.c 2008-12-01 11:36:47.000000000 +0100
250+++ head-2008-12-01/arch/x86/kernel/acpi/sleep_32-xen.c 2008-12-01 11:36:55.000000000 +0100
251@@ -90,7 +90,7 @@ __setup("acpi_sleep=", acpi_sleep_setup)
252
253 /* Ouch, we want to delete this. We already have better version in userspace, in
254 s2ram from suspend.sf.net project */
255-static __init int reset_videomode_after_s3(struct dmi_system_id *d)
256+static __init int reset_videomode_after_s3(const struct dmi_system_id *d)
257 {
258 acpi_realmode_flags |= 2;
259 return 0;
260Index: head-2008-12-01/arch/x86/kernel/acpi/sleep_64-xen.c
261===================================================================
262--- head-2008-12-01.orig/arch/x86/kernel/acpi/sleep_64-xen.c 2008-12-01 11:36:47.000000000 +0100
263+++ head-2008-12-01/arch/x86/kernel/acpi/sleep_64-xen.c 2008-12-01 11:36:55.000000000 +0100
264@@ -123,6 +123,3 @@ static int __init acpi_sleep_setup(char
265 __setup("acpi_sleep=", acpi_sleep_setup);
266 #endif /* CONFIG_ACPI_PV_SLEEP */
267
268-void acpi_pci_link_exit(void)
269-{
270-}
271Index: head-2008-12-01/arch/x86/kernel/apic_64-xen.c
272===================================================================
273--- head-2008-12-01.orig/arch/x86/kernel/apic_64-xen.c 2008-12-01 11:36:47.000000000 +0100
274+++ head-2008-12-01/arch/x86/kernel/apic_64-xen.c 2008-12-01 11:36:55.000000000 +0100
275@@ -63,22 +63,38 @@ int setup_profiling_timer(unsigned int m
276
277 void smp_local_timer_interrupt(void)
278 {
279- profile_tick(CPU_PROFILING);
280 #ifndef CONFIG_XEN
281-#ifdef CONFIG_SMP
282- update_process_times(user_mode(get_irq_regs()));
283-#endif
284-#endif
285+ int cpu = smp_processor_id();
286+ struct clock_event_device *evt = &per_cpu(lapic_events, cpu);
287+
288 /*
289- * We take the 'long' return path, and there every subsystem
290- * grabs the appropriate locks (kernel lock/ irq lock).
291+ * Normally we should not be here till LAPIC has been initialized but
292+ * in some cases like kdump, its possible that there is a pending LAPIC
293+ * timer interrupt from previous kernel's context and is delivered in
294+ * new kernel the moment interrupts are enabled.
295 *
296- * We might want to decouple profiling from the 'long path',
297- * and do the profiling totally in assembly.
298- *
299- * Currently this isn't too much of an issue (performance wise),
300- * we can take more than 100K local irqs per second on a 100 MHz P5.
301+ * Interrupts are enabled early and LAPIC is setup much later, hence
302+ * its possible that when we get here evt->event_handler is NULL.
303+ * Check for event_handler being NULL and discard the interrupt as
304+ * spurious.
305+ */
306+ if (!evt->event_handler) {
307+ printk(KERN_WARNING
308+ "Spurious LAPIC timer interrupt on cpu %d\n", cpu);
309+ /* Switch it off */
310+ lapic_timer_setup(CLOCK_EVT_MODE_SHUTDOWN, evt);
311+ return;
312+ }
313+#endif
314+
315+ /*
316+ * the NMI deadlock-detector uses this.
317 */
318+ add_pda(apic_timer_irqs, 1);
319+
320+#ifndef CONFIG_XEN
321+ evt->event_handler(evt);
322+#endif
323 }
324
325 /*
326@@ -94,11 +110,6 @@ void smp_apic_timer_interrupt(struct pt_
327 struct pt_regs *old_regs = set_irq_regs(regs);
328
329 /*
330- * the NMI deadlock-detector uses this.
331- */
332- add_pda(apic_timer_irqs, 1);
333-
334- /*
335 * NOTE! We'd better ACK the irq immediately,
336 * because timer handling can be slow.
337 */
338@@ -132,6 +143,7 @@ asmlinkage void smp_spurious_interrupt(v
339 if (v & (1 << (SPURIOUS_APIC_VECTOR & 0x1f)))
340 ack_APIC_irq();
341
342+ add_pda(irq_spurious_count, 1);
343 irq_exit();
344 }
345
346Index: head-2008-12-01/arch/x86/kernel/cpu/common-xen.c
347===================================================================
348--- head-2008-12-01.orig/arch/x86/kernel/cpu/common-xen.c 2008-12-01 11:36:47.000000000 +0100
349+++ head-2008-12-01/arch/x86/kernel/cpu/common-xen.c 2008-12-01 11:36:55.000000000 +0100
350@@ -214,7 +214,7 @@ static void __cpuinit get_cpu_vendor(str
351
352 static int __init x86_fxsr_setup(char * s)
353 {
354- /* Tell all the other CPU's to not use it... */
355+ /* Tell all the other CPUs to not use it... */
356 disable_x86_fxsr = 1;
357
358 /*
359Index: head-2008-12-01/arch/x86/kernel/e820_32-xen.c
360===================================================================
361--- head-2008-12-01.orig/arch/x86/kernel/e820_32-xen.c 2008-12-01 11:36:47.000000000 +0100
362+++ head-2008-12-01/arch/x86/kernel/e820_32-xen.c 2008-12-01 11:36:55.000000000 +0100
363@@ -52,6 +52,13 @@ struct resource code_resource = {
364 .flags = IORESOURCE_BUSY | IORESOURCE_MEM
365 };
366
367+struct resource bss_resource = {
368+ .name = "Kernel bss",
369+ .start = 0,
370+ .end = 0,
371+ .flags = IORESOURCE_BUSY | IORESOURCE_MEM
372+};
373+
374 static struct resource system_rom_resource = {
375 .name = "System ROM",
376 .start = 0xf0000,
377@@ -266,7 +273,9 @@ static struct e820map machine_e820;
378 * and also for regions reported as reserved by the e820.
379 */
380 static void __init
381-legacy_init_iomem_resources(struct resource *code_resource, struct resource *data_resource)
382+legacy_init_iomem_resources(struct resource *code_resource,
383+ struct resource *data_resource,
384+ struct resource *bss_resource)
385 {
386 int i;
387
388@@ -300,9 +309,11 @@ legacy_init_iomem_resources(struct resou
389 #ifndef CONFIG_XEN
390 request_resource(res, code_resource);
391 request_resource(res, data_resource);
392+ request_resource(res, bss_resource);
393 #endif
394 #ifdef CONFIG_KEXEC
395- request_resource(res, &crashk_res);
396+ if (crashk_res.start != crashk_res.end)
397+ request_resource(res, &crashk_res);
398 #ifdef CONFIG_XEN
399 xen_machine_kexec_register_resources(res);
400 #endif
401@@ -329,9 +340,11 @@ static int __init request_standard_resou
402
403 printk("Setting up standard PCI resources\n");
404 if (efi_enabled)
405- efi_initialize_iomem_resources(&code_resource, &data_resource);
406+ efi_initialize_iomem_resources(&code_resource,
407+ &data_resource, &bss_resource);
408 else
409- legacy_init_iomem_resources(&code_resource, &data_resource);
410+ legacy_init_iomem_resources(&code_resource,
411+ &data_resource, &bss_resource);
412
413 /* EFI systems may still have VGA */
414 request_resource(&iomem_resource, &video_ram_resource);
415@@ -774,7 +787,7 @@ void __init e820_register_memory(void)
416 #endif
417
418 /*
419- * Search for the bigest gap in the low 32 bits of the e820
420+ * Search for the biggest gap in the low 32 bits of the e820
421 * memory space.
422 */
423 last = 0x100000000ull;
424Index: head-2008-12-01/arch/x86/kernel/e820_64-xen.c
425===================================================================
426--- head-2008-12-01.orig/arch/x86/kernel/e820_64-xen.c 2008-12-01 11:36:47.000000000 +0100
427+++ head-2008-12-01/arch/x86/kernel/e820_64-xen.c 2008-12-01 11:36:55.000000000 +0100
428@@ -24,7 +24,7 @@
429 #include <asm/page.h>
430 #include <asm/e820.h>
431 #include <asm/proto.h>
432-#include <asm/bootsetup.h>
433+#include <asm/setup.h>
434 #include <asm/sections.h>
435 #include <xen/interface/memory.h>
436
437@@ -51,7 +51,7 @@ unsigned long end_pfn_map;
438 */
439 static unsigned long __initdata end_user_pfn = MAXMEM>>PAGE_SHIFT;
440
441-extern struct resource code_resource, data_resource;
442+extern struct resource code_resource, data_resource, bss_resource;
443
444 /* Check for some hardcoded bad areas that early boot is not allowed to touch */
445 static inline int bad_addr(unsigned long *addrp, unsigned long size)
446@@ -73,10 +73,15 @@ static inline int bad_addr(unsigned long
447
448 /* initrd */
449 #ifdef CONFIG_BLK_DEV_INITRD
450- if (LOADER_TYPE && INITRD_START && last >= INITRD_START &&
451- addr < INITRD_START+INITRD_SIZE) {
452- *addrp = PAGE_ALIGN(INITRD_START + INITRD_SIZE);
453- return 1;
454+ if (boot_params.hdr.type_of_loader && boot_params.hdr.ramdisk_image) {
455+ unsigned long ramdisk_image = boot_params.hdr.ramdisk_image;
456+ unsigned long ramdisk_size = boot_params.hdr.ramdisk_size;
457+ unsigned long ramdisk_end = ramdisk_image+ramdisk_size;
458+
459+ if (last >= ramdisk_image && addr < ramdisk_end) {
460+ *addrp = PAGE_ALIGN(ramdisk_end);
461+ return 1;
462+ }
463 }
464 #endif
465 /* kernel code */
466@@ -249,6 +254,7 @@ void __init e820_reserve_resources(struc
467 #ifndef CONFIG_XEN
468 request_resource(res, &code_resource);
469 request_resource(res, &data_resource);
470+ request_resource(res, &bss_resource);
471 #endif
472 #ifdef CONFIG_KEXEC
473 if (crashk_res.start != crashk_res.end)
474@@ -650,8 +656,8 @@ void __init setup_memory_region(void)
475 * Otherwise fake a memory map; one section from 0k->640k,
476 * the next section from 1mb->appropriate_mem_k
477 */
478- sanitize_e820_map(E820_MAP, &E820_MAP_NR);
479- if (copy_e820_map(E820_MAP, E820_MAP_NR) < 0)
480+ sanitize_e820_map(boot_params.e820_map, &boot_params.e820_entries);
481+ if (copy_e820_map(boot_params.e820_map, boot_params.e820_entries) < 0)
482 early_panic("Cannot find a valid memory map");
483 printk(KERN_INFO "BIOS-provided physical RAM map:\n");
484 e820_print_map("BIOS-e820");
485@@ -836,3 +842,22 @@ __init void e820_setup_gap(struct e820en
486 printk(KERN_INFO "Allocating PCI resources starting at %lx (gap: %lx:%lx)\n",
487 pci_mem_start, gapstart, gapsize);
488 }
489+
490+int __init arch_get_ram_range(int slot, u64 *addr, u64 *size)
491+{
492+ int i;
493+
494+ if (slot < 0 || slot >= e820.nr_map)
495+ return -1;
496+ for (i = slot; i < e820.nr_map; i++) {
497+ if (e820.map[i].type != E820_RAM)
498+ continue;
499+ break;
500+ }
501+ if (i == e820.nr_map || e820.map[i].addr > (max_pfn << PAGE_SHIFT))
502+ return -1;
503+ *addr = e820.map[i].addr;
504+ *size = min_t(u64, e820.map[i].size + e820.map[i].addr,
505+ max_pfn << PAGE_SHIFT) - *addr;
506+ return i + 1;
507+}
508Index: head-2008-12-01/arch/x86/kernel/early_printk-xen.c
509===================================================================
510--- head-2008-12-01.orig/arch/x86/kernel/early_printk-xen.c 2008-12-01 11:36:47.000000000 +0100
511+++ head-2008-12-01/arch/x86/kernel/early_printk-xen.c 2008-12-01 11:36:55.000000000 +0100
512@@ -6,14 +6,9 @@
513 #include <asm/io.h>
514 #include <asm/processor.h>
515 #include <asm/fcntl.h>
516+#include <asm/setup.h>
517
518 /* Simple VGA output */
519-
520-#ifdef __i386__
521-#include <asm/setup.h>
522-#else
523-#include <asm/bootsetup.h>
524-#endif
525 #define VGABASE (__ISA_IO_base + 0xb8000)
526
527 #ifndef CONFIG_XEN
528@@ -264,10 +259,10 @@ static int __init setup_early_printk(cha
529 early_console = &early_serial_console;
530 } else if (!strncmp(buf, "vga", 3)) {
531 #ifndef CONFIG_XEN
532- && SCREEN_INFO.orig_video_isVGA == 1) {
533- max_xpos = SCREEN_INFO.orig_video_cols;
534- max_ypos = SCREEN_INFO.orig_video_lines;
535- current_ypos = SCREEN_INFO.orig_y;
536+ && boot_params.screen_info.orig_video_isVGA == 1) {
537+ max_xpos = boot_params.screen_info.orig_video_cols;
538+ max_ypos = boot_params.screen_info.orig_video_lines;
539+ current_ypos = boot_params.screen_info.orig_y;
540 #endif
541 early_console = &early_vga_console;
542 } else if (!strncmp(buf, "simnow", 6)) {
543Index: head-2008-12-01/arch/x86/kernel/entry_32-xen.S
544===================================================================
545--- head-2008-12-01.orig/arch/x86/kernel/entry_32-xen.S 2008-12-01 11:36:47.000000000 +0100
546+++ head-2008-12-01/arch/x86/kernel/entry_32-xen.S 2008-12-01 11:36:55.000000000 +0100
547@@ -254,6 +254,7 @@ check_userspace:
548 jb resume_kernel # not returning to v8086 or userspace
549
550 ENTRY(resume_userspace)
551+ LOCKDEP_SYS_EXIT
552 DISABLE_INTERRUPTS(CLBR_ANY) # make sure we don't miss an interrupt
553 # setting need_resched or sigpending
554 # between sampling and the iret
555@@ -341,6 +342,7 @@ sysenter_past_esp:
556 jae syscall_badsys
557 call *sys_call_table(,%eax,4)
558 movl %eax,PT_EAX(%esp)
559+ LOCKDEP_SYS_EXIT
560 DISABLE_INTERRUPTS(CLBR_ANY)
561 TRACE_IRQS_OFF
562 movl TI_flags(%ebp), %ecx
563@@ -406,6 +408,7 @@ syscall_call:
564 call *sys_call_table(,%eax,4)
565 movl %eax,PT_EAX(%esp) # store the return value
566 syscall_exit:
567+ LOCKDEP_SYS_EXIT
568 DISABLE_INTERRUPTS(CLBR_ANY) # make sure we don't miss an interrupt
569 # setting need_resched or sigpending
570 # between sampling and the iret
571@@ -478,7 +481,7 @@ ldt_ss:
572 * is still available to implement the setting of the high
573 * 16-bits in the INTERRUPT_RETURN paravirt-op.
574 */
575- cmpl $0, paravirt_ops+PARAVIRT_enabled
576+ cmpl $0, pv_info+PARAVIRT_enabled
577 jne restore_nocheck
578 #endif
579
580@@ -540,6 +543,7 @@ work_pending:
581 jz work_notifysig
582 work_resched:
583 call schedule
584+ LOCKDEP_SYS_EXIT
585 DISABLE_INTERRUPTS(CLBR_ANY) # make sure we don't miss an interrupt
586 # setting need_resched or sigpending
587 # between sampling and the iret
588@@ -1264,6 +1268,6 @@ ENTRY(kernel_thread_helper)
589 ENDPROC(kernel_thread_helper)
590
591 .section .rodata,"a"
592-#include "syscall_table.S"
593+#include "syscall_table_32.S"
594
595 syscall_table_size=(.-sys_call_table)
596Index: head-2008-12-01/arch/x86/kernel/entry_64-xen.S
597===================================================================
598--- head-2008-12-01.orig/arch/x86/kernel/entry_64-xen.S 2008-12-01 11:36:47.000000000 +0100
599+++ head-2008-12-01/arch/x86/kernel/entry_64-xen.S 2008-12-01 11:36:55.000000000 +0100
600@@ -57,7 +57,7 @@
601 #include <xen/interface/arch-x86_64.h>
602 #include <xen/interface/features.h>
603
604-#include "xen_entry.S"
605+#include "xen_entry_64.S"
606
607 .code64
608
609@@ -275,6 +275,7 @@ ret_from_sys_call:
610 movl $_TIF_ALLWORK_MASK,%edi
611 /* edi: flagmask */
612 sysret_check:
613+ LOCKDEP_SYS_EXIT
614 GET_THREAD_INFO(%rcx)
615 XEN_BLOCK_EVENTS(%rsi)
616 TRACE_IRQS_OFF
617@@ -365,6 +366,7 @@ int_ret_from_sys_call:
618 movl $_TIF_ALLWORK_MASK,%edi
619 /* edi: mask to check */
620 int_with_check:
621+ LOCKDEP_SYS_EXIT_IRQ
622 GET_THREAD_INFO(%rcx)
623 movl threadinfo_flags(%rcx),%edx
624 andl %edi,%edx
625@@ -516,11 +518,12 @@ END(stub_rt_sigreturn)
626
627 retint_check:
628 CFI_DEFAULT_STACK adj=1
629+ LOCKDEP_SYS_EXIT_IRQ
630 movl threadinfo_flags(%rcx),%edx
631 andl %edi,%edx
632 CFI_REMEMBER_STATE
633 jnz retint_careful
634-retint_restore_args:
635+retint_restore_args: /* return to kernel space */
636 movl EFLAGS-REST_SKIP(%rsp), %eax
637 shr $9, %eax # EAX[0] == IRET_EFLAGS.IF
638 XEN_GET_VCPU_INFO(%rsi)
639@@ -841,7 +844,7 @@ error_call_handler:
640 movq ORIG_RAX(%rsp),%rsi # get error code
641 movq $-1,ORIG_RAX(%rsp)
642 call *%rax
643-error_exit:
644+error_exit:
645 RESTORE_REST
646 /* cli */
647 XEN_BLOCK_EVENTS(%rsi)
648@@ -849,14 +852,11 @@ error_exit:
649 GET_THREAD_INFO(%rcx)
650 testb $3,CS-ARGOFFSET(%rsp)
651 jz retint_kernel
652+ LOCKDEP_SYS_EXIT_IRQ
653 movl threadinfo_flags(%rcx),%edx
654 movl $_TIF_WORK_MASK,%edi
655 andl %edi,%edx
656 jnz retint_careful
657- /*
658- * The iret might restore flags:
659- */
660- TRACE_IRQS_IRETQ
661 jmp retint_restore_args
662
663 #if 0
664@@ -1071,7 +1071,7 @@ child_rip:
665 movq %rsi, %rdi
666 call *%rax
667 # exit
668- xorl %edi, %edi
669+ mov %eax, %edi
670 call do_exit
671 CFI_ENDPROC
672 ENDPROC(child_rip)
673Index: head-2008-12-01/arch/x86/kernel/genapic_64-xen.c
674===================================================================
675--- head-2008-12-01.orig/arch/x86/kernel/genapic_64-xen.c 2008-12-01 11:36:13.000000000 +0100
676+++ head-2008-12-01/arch/x86/kernel/genapic_64-xen.c 2008-12-01 11:36:55.000000000 +0100
677@@ -24,12 +24,21 @@
678 #include <acpi/acpi_bus.h>
679 #endif
680
681-/* which logical CPU number maps to which CPU (physical APIC ID) */
682-u8 x86_cpu_to_apicid[NR_CPUS] __read_mostly
683+/*
684+ * which logical CPU number maps to which CPU (physical APIC ID)
685+ *
686+ * The following static array is used during kernel startup
687+ * and the x86_cpu_to_apicid_ptr contains the address of the
688+ * array during this time. Is it zeroed when the per_cpu
689+ * data area is removed.
690+ */
691+#ifndef CONFIG_XEN
692+u8 x86_cpu_to_apicid_init[NR_CPUS] __initdata
693 = { [0 ... NR_CPUS-1] = BAD_APICID };
694-EXPORT_SYMBOL(x86_cpu_to_apicid);
695-
696-u8 x86_cpu_to_log_apicid[NR_CPUS] = { [0 ... NR_CPUS-1] = BAD_APICID };
697+void *x86_cpu_to_apicid_ptr;
698+#endif
699+DEFINE_PER_CPU(u8, x86_cpu_to_apicid) = BAD_APICID;
700+EXPORT_PER_CPU_SYMBOL(x86_cpu_to_apicid);
701
702 #ifndef CONFIG_XEN
703 struct genapic __read_mostly *genapic = &apic_flat;
704Index: head-2008-12-01/arch/x86/kernel/head64-xen.c
705===================================================================
706--- head-2008-12-01.orig/arch/x86/kernel/head64-xen.c 2008-12-01 11:36:47.000000000 +0100
707+++ head-2008-12-01/arch/x86/kernel/head64-xen.c 2008-12-01 11:36:55.000000000 +0100
708@@ -1,5 +1,5 @@
709 /*
710- * linux/arch/x86_64/kernel/head64.c -- prepare to run common code
711+ * prepare to run common code
712 *
713 * Copyright (C) 2000 Andrea Arcangeli <andrea@suse.de> SuSE
714 *
715@@ -21,7 +21,6 @@
716 #include <asm/processor.h>
717 #include <asm/proto.h>
718 #include <asm/smp.h>
719-#include <asm/bootsetup.h>
720 #include <asm/setup.h>
721 #include <asm/desc.h>
722 #include <asm/pgtable.h>
723@@ -47,27 +46,16 @@ static void __init clear_bss(void)
724 }
725 #endif
726
727-#define NEW_CL_POINTER 0x228 /* Relative to real mode data */
728-#define OLD_CL_MAGIC_ADDR 0x20
729-#define OLD_CL_MAGIC 0xA33F
730-#define OLD_CL_OFFSET 0x22
731-
732 static void __init copy_bootdata(char *real_mode_data)
733 {
734 #ifndef CONFIG_XEN
735- unsigned long new_data;
736 char * command_line;
737
738- memcpy(x86_boot_params, real_mode_data, BOOT_PARAM_SIZE);
739- new_data = *(u32 *) (x86_boot_params + NEW_CL_POINTER);
740- if (!new_data) {
741- if (OLD_CL_MAGIC != *(u16 *)(real_mode_data + OLD_CL_MAGIC_ADDR)) {
742- return;
743- }
744- new_data = __pa(real_mode_data) + *(u16 *)(real_mode_data + OLD_CL_OFFSET);
745+ memcpy(&boot_params, real_mode_data, sizeof boot_params);
746+ if (boot_params.hdr.cmd_line_ptr) {
747+ command_line = __va(boot_params.hdr.cmd_line_ptr);
748+ memcpy(boot_command_line, command_line, COMMAND_LINE_SIZE);
749 }
750- command_line = __va(new_data);
751- memcpy(boot_command_line, command_line, COMMAND_LINE_SIZE);
752 #else
753 int max_cmdline;
754
755@@ -117,7 +105,7 @@ void __init x86_64_start_kernel(char * r
756
757 for (i = 0; i < IDT_ENTRIES; i++)
758 set_intr_gate(i, early_idt_handler);
759- asm volatile("lidt %0" :: "m" (idt_descr));
760+ load_idt((const struct desc_ptr *)&idt_descr);
761 #endif
762
763 early_printk("Kernel alive\n");
764Index: head-2008-12-01/arch/x86/kernel/init_task-xen.c
765===================================================================
766--- head-2008-12-01.orig/arch/x86/kernel/init_task-xen.c 2008-12-01 11:36:47.000000000 +0100
767+++ head-2008-12-01/arch/x86/kernel/init_task-xen.c 2008-12-01 11:36:55.000000000 +0100
768@@ -14,11 +14,11 @@ static struct fs_struct init_fs = INIT_F
769 static struct files_struct init_files = INIT_FILES;
770 static struct signal_struct init_signals = INIT_SIGNALS(init_signals);
771 static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand);
772-
773+#ifdef CONFIG_X86_XEN
774 #define swapper_pg_dir ((pgd_t *)NULL)
775+#endif
776 struct mm_struct init_mm = INIT_MM(init_mm);
777 #undef swapper_pg_dir
778-
779 EXPORT_SYMBOL(init_mm);
780
781 /*
782@@ -28,7 +28,7 @@ EXPORT_SYMBOL(init_mm);
783 * way process stacks are handled. This is done by having a special
784 * "init_task" linker map entry..
785 */
786-union thread_union init_thread_union
787+union thread_union init_thread_union
788 __attribute__((__section__(".data.init_task"))) =
789 { INIT_THREAD_INFO(init_task) };
790
791@@ -38,14 +38,15 @@ union thread_union init_thread_union
792 * All other task structs will be allocated on slabs in fork.c
793 */
794 struct task_struct init_task = INIT_TASK(init_task);
795-
796 EXPORT_SYMBOL(init_task);
797
798 #ifndef CONFIG_X86_NO_TSS
799 /*
800- * per-CPU TSS segments. Threads are completely 'soft' on Linux,
801- * no more per-task TSS's.
802- */
803+ * no more per-task TSS's. The TSS size is kept cacheline-aligned
804+ * so they are allowed to end up in the .data.cacheline_aligned
805+ * section. Since TSS's are completely CPU-local, we want them
806+ * on exact cacheline boundaries, to eliminate cacheline ping-pong.
807+ */
808 DEFINE_PER_CPU_SHARED_ALIGNED(struct tss_struct, init_tss) = INIT_TSS;
809 #endif
810
811Index: head-2008-12-01/arch/x86/kernel/io_apic_32-xen.c
812===================================================================
813--- head-2008-12-01.orig/arch/x86/kernel/io_apic_32-xen.c 2008-12-01 11:36:47.000000000 +0100
814+++ head-2008-12-01/arch/x86/kernel/io_apic_32-xen.c 2008-12-01 11:36:55.000000000 +0100
815@@ -427,7 +427,7 @@ static struct irq_cpu_info {
816
817 #define IRQ_ALLOWED(cpu, allowed_mask) cpu_isset(cpu, allowed_mask)
818
819-#define CPU_TO_PACKAGEINDEX(i) (first_cpu(cpu_sibling_map[i]))
820+#define CPU_TO_PACKAGEINDEX(i) (first_cpu(per_cpu(cpu_sibling_map, i)))
821
822 static cpumask_t balance_irq_affinity[NR_IRQS] = {
823 [0 ... NR_IRQS-1] = CPU_MASK_ALL
824@@ -633,7 +633,7 @@ tryanotherirq:
825
826 imbalance = move_this_load;
827
828- /* For physical_balance case, we accumlated both load
829+ /* For physical_balance case, we accumulated both load
830 * values in the one of the siblings cpu_irq[],
831 * to use the same code for physical and logical processors
832 * as much as possible.
833@@ -647,7 +647,7 @@ tryanotherirq:
834 * (A+B)/2 vs B
835 */
836 load = CPU_IRQ(min_loaded) >> 1;
837- for_each_cpu_mask(j, cpu_sibling_map[min_loaded]) {
838+ for_each_cpu_mask(j, per_cpu(cpu_sibling_map, min_loaded)) {
839 if (load > CPU_IRQ(j)) {
840 /* This won't change cpu_sibling_map[min_loaded] */
841 load = CPU_IRQ(j);
842@@ -1018,7 +1018,7 @@ static int EISA_ELCR(unsigned int irq)
843 #define default_MCA_trigger(idx) (1)
844 #define default_MCA_polarity(idx) (0)
845
846-static int __init MPBIOS_polarity(int idx)
847+static int MPBIOS_polarity(int idx)
848 {
849 int bus = mp_irqs[idx].mpc_srcbus;
850 int polarity;
851@@ -1347,6 +1347,11 @@ static void __init setup_IO_APIC_irqs(vo
852 continue;
853 }
854
855+ if (!first_notcon) {
856+ apic_printk(APIC_VERBOSE, " not connected.\n");
857+ first_notcon = 1;
858+ }
859+
860 entry.trigger = irq_trigger(idx);
861 entry.polarity = irq_polarity(idx);
862
863@@ -1936,13 +1941,16 @@ __setup("no_timer_check", notimercheck);
864 static int __init timer_irq_works(void)
865 {
866 unsigned long t1 = jiffies;
867+ unsigned long flags;
868
869 if (no_timer_check)
870 return 1;
871
872+ local_save_flags(flags);
873 local_irq_enable();
874 /* Let ten ticks pass... */
875 mdelay((10 * 1000) / HZ);
876+ local_irq_restore(flags);
877
878 /*
879 * Expect a few ticks at least, to be sure some possible
880@@ -2223,6 +2231,9 @@ static inline void __init check_timer(vo
881 {
882 int apic1, pin1, apic2, pin2;
883 int vector;
884+ unsigned long flags;
885+
886+ local_irq_save(flags);
887
888 /*
889 * get/set the timer IRQ vector:
890@@ -2268,7 +2279,7 @@ static inline void __init check_timer(vo
891 }
892 if (disable_timer_pin_1 > 0)
893 clear_IO_APIC_pin(0, pin1);
894- return;
895+ goto out;
896 }
897 clear_IO_APIC_pin(apic1, pin1);
898 printk(KERN_ERR "..MP-BIOS bug: 8254 timer not connected to "
899@@ -2291,7 +2302,7 @@ static inline void __init check_timer(vo
900 if (nmi_watchdog == NMI_IO_APIC) {
901 setup_nmi();
902 }
903- return;
904+ goto out;
905 }
906 /*
907 * Cleanup, just in case ...
908@@ -2315,7 +2326,7 @@ static inline void __init check_timer(vo
909
910 if (timer_irq_works()) {
911 printk(" works.\n");
912- return;
913+ goto out;
914 }
915 apic_write_around(APIC_LVT0, APIC_LVT_MASKED | APIC_DM_FIXED | vector);
916 printk(" failed.\n");
917@@ -2331,11 +2342,13 @@ static inline void __init check_timer(vo
918
919 if (timer_irq_works()) {
920 printk(" works.\n");
921- return;
922+ goto out;
923 }
924 printk(" failed :(.\n");
925 panic("IO-APIC + timer doesn't work! Boot with apic=debug and send a "
926 "report. Then try booting with the 'noapic' option");
927+out:
928+ local_irq_restore(flags);
929 }
930 #else
931 int timer_uses_ioapic_pin_0 = 0;
932@@ -2353,6 +2366,14 @@ int timer_uses_ioapic_pin_0 = 0;
933
934 void __init setup_IO_APIC(void)
935 {
936+#ifndef CONFIG_XEN
937+ int i;
938+
939+ /* Reserve all the system vectors. */
940+ for (i = FIRST_SYSTEM_VECTOR; i < NR_VECTORS; i++)
941+ set_bit(i, used_vectors);
942+#endif
943+
944 enable_IO_APIC();
945
946 if (acpi_ioapic)
947@@ -2542,7 +2563,7 @@ void destroy_irq(unsigned int irq)
948 #endif /* CONFIG_XEN */
949
950 /*
951- * MSI mesage composition
952+ * MSI message composition
953 */
954 #if defined(CONFIG_PCI_MSI) && !defined(CONFIG_XEN)
955 static int msi_compose_msg(struct pci_dev *pdev, unsigned int irq, struct msi_msg *msg)
956@@ -2899,6 +2920,25 @@ int io_apic_set_pci_routing (int ioapic,
957 return 0;
958 }
959
960+int acpi_get_override_irq(int bus_irq, int *trigger, int *polarity)
961+{
962+ int i;
963+
964+ if (skip_ioapic_setup)
965+ return -1;
966+
967+ for (i = 0; i < mp_irq_entries; i++)
968+ if (mp_irqs[i].mpc_irqtype == mp_INT &&
969+ mp_irqs[i].mpc_srcbusirq == bus_irq)
970+ break;
971+ if (i >= mp_irq_entries)
972+ return -1;
973+
974+ *trigger = irq_trigger(i);
975+ *polarity = irq_polarity(i);
976+ return 0;
977+}
978+
979 #endif /* CONFIG_ACPI */
980
981 static int __init parse_disable_timer_pin_1(char *arg)
982Index: head-2008-12-01/arch/x86/kernel/io_apic_64-xen.c
983===================================================================
984--- head-2008-12-01.orig/arch/x86/kernel/io_apic_64-xen.c 2008-12-01 11:36:47.000000000 +0100
985+++ head-2008-12-01/arch/x86/kernel/io_apic_64-xen.c 2008-12-01 11:36:55.000000000 +0100
986@@ -31,6 +31,7 @@
987 #include <linux/sysdev.h>
988 #include <linux/msi.h>
989 #include <linux/htirq.h>
990+#include <linux/dmar.h>
991 #ifdef CONFIG_ACPI
992 #include <acpi/acpi_bus.h>
993 #endif
994@@ -584,7 +585,7 @@ int IO_APIC_get_PCI_irq_vector(int bus,
995 #define default_PCI_trigger(idx) (1)
996 #define default_PCI_polarity(idx) (1)
997
998-static int __init MPBIOS_polarity(int idx)
999+static int MPBIOS_polarity(int idx)
1000 {
1001 int bus = mp_irqs[idx].mpc_srcbus;
1002 int polarity;
1003@@ -871,6 +872,10 @@ static void __init setup_IO_APIC_irqs(vo
1004 apic_printk(APIC_VERBOSE, ", %d-%d", mp_ioapics[apic].mpc_apicid, pin);
1005 continue;
1006 }
1007+ if (!first_notcon) {
1008+ apic_printk(APIC_VERBOSE, " not connected.\n");
1009+ first_notcon = 1;
1010+ }
1011
1012 irq = pin_2_irq(idx, apic, pin);
1013 add_pin_to_irq(irq, apic, pin);
1014@@ -881,7 +886,7 @@ static void __init setup_IO_APIC_irqs(vo
1015 }
1016
1017 if (!first_notcon)
1018- apic_printk(APIC_VERBOSE," not connected.\n");
1019+ apic_printk(APIC_VERBOSE, " not connected.\n");
1020 }
1021
1022 #ifndef CONFIG_XEN
1023@@ -1277,10 +1282,13 @@ void disable_IO_APIC(void)
1024 static int __init timer_irq_works(void)
1025 {
1026 unsigned long t1 = jiffies;
1027+ unsigned long flags;
1028
1029+ local_save_flags(flags);
1030 local_irq_enable();
1031 /* Let ten ticks pass... */
1032 mdelay((10 * 1000) / HZ);
1033+ local_irq_restore(flags);
1034
1035 /*
1036 * Expect a few ticks at least, to be sure some possible
1037@@ -1655,6 +1663,9 @@ static inline void check_timer(void)
1038 {
1039 struct irq_cfg *cfg = irq_cfg + 0;
1040 int apic1, pin1, apic2, pin2;
1041+ unsigned long flags;
1042+
1043+ local_irq_save(flags);
1044
1045 /*
1046 * get/set the timer IRQ vector:
1047@@ -1696,7 +1707,7 @@ static inline void check_timer(void)
1048 }
1049 if (disable_timer_pin_1 > 0)
1050 clear_IO_APIC_pin(0, pin1);
1051- return;
1052+ goto out;
1053 }
1054 clear_IO_APIC_pin(apic1, pin1);
1055 apic_printk(APIC_QUIET,KERN_ERR "..MP-BIOS bug: 8254 timer not "
1056@@ -1718,7 +1729,7 @@ static inline void check_timer(void)
1057 if (nmi_watchdog == NMI_IO_APIC) {
1058 setup_nmi();
1059 }
1060- return;
1061+ goto out;
1062 }
1063 /*
1064 * Cleanup, just in case ...
1065@@ -1741,7 +1752,7 @@ static inline void check_timer(void)
1066
1067 if (timer_irq_works()) {
1068 apic_printk(APIC_VERBOSE," works.\n");
1069- return;
1070+ goto out;
1071 }
1072 apic_write(APIC_LVT0, APIC_LVT_MASKED | APIC_DM_FIXED | cfg->vector);
1073 apic_printk(APIC_VERBOSE," failed.\n");
1074@@ -1756,10 +1767,12 @@ static inline void check_timer(void)
1075
1076 if (timer_irq_works()) {
1077 apic_printk(APIC_VERBOSE," works.\n");
1078- return;
1079+ goto out;
1080 }
1081 apic_printk(APIC_VERBOSE," failed :(.\n");
1082 panic("IO-APIC + timer doesn't work! Try using the 'noapic' kernel parameter\n");
1083+out:
1084+ local_irq_restore(flags);
1085 }
1086 #else
1087 #define check_timer() ((void)0)
1088@@ -1775,7 +1788,7 @@ __setup("no_timer_check", notimercheck);
1089
1090 /*
1091 *
1092- * IRQ's that are handled by the PIC in the MPS IOAPIC case.
1093+ * IRQs that are handled by the PIC in the MPS IOAPIC case.
1094 * - IRQ2 is the cascade IRQ, and cannot be a io-apic IRQ.
1095 * Linux doesn't really care, as it's not actually used
1096 * for any interrupt handling anyway.
1097@@ -1858,7 +1871,7 @@ static struct sysdev_class ioapic_sysdev
1098 static int __init ioapic_init_sysfs(void)
1099 {
1100 struct sys_device * dev;
1101- int i, size, error = 0;
1102+ int i, size, error;
1103
1104 error = sysdev_class_register(&ioapic_sysdev_class);
1105 if (error)
1106@@ -1867,12 +1880,11 @@ static int __init ioapic_init_sysfs(void
1107 for (i = 0; i < nr_ioapics; i++ ) {
1108 size = sizeof(struct sys_device) + nr_ioapic_registers[i]
1109 * sizeof(struct IO_APIC_route_entry);
1110- mp_ioapic_data[i] = kmalloc(size, GFP_KERNEL);
1111+ mp_ioapic_data[i] = kzalloc(size, GFP_KERNEL);
1112 if (!mp_ioapic_data[i]) {
1113 printk(KERN_ERR "Can't suspend/resume IOAPIC %d\n", i);
1114 continue;
1115 }
1116- memset(mp_ioapic_data[i], 0, size);
1117 dev = &mp_ioapic_data[i]->dev;
1118 dev->id = i;
1119 dev->cls = &ioapic_sysdev_class;
1120@@ -1933,7 +1945,7 @@ void destroy_irq(unsigned int irq)
1121 #endif /* CONFIG_XEN */
1122
1123 /*
1124- * MSI mesage composition
1125+ * MSI message composition
1126 */
1127 #if defined(CONFIG_PCI_MSI) && !defined(CONFIG_XEN)
1128 static int msi_compose_msg(struct pci_dev *pdev, unsigned int irq, struct msi_msg *msg)
1129@@ -2043,8 +2055,64 @@ void arch_teardown_msi_irq(unsigned int
1130 destroy_irq(irq);
1131 }
1132
1133-#endif /* CONFIG_PCI_MSI */
1134+#ifdef CONFIG_DMAR
1135+#ifdef CONFIG_SMP
1136+static void dmar_msi_set_affinity(unsigned int irq, cpumask_t mask)
1137+{
1138+ struct irq_cfg *cfg = irq_cfg + irq;
1139+ struct msi_msg msg;
1140+ unsigned int dest;
1141+ cpumask_t tmp;
1142+
1143+ cpus_and(tmp, mask, cpu_online_map);
1144+ if (cpus_empty(tmp))
1145+ return;
1146+
1147+ if (assign_irq_vector(irq, mask))
1148+ return;
1149+
1150+ cpus_and(tmp, cfg->domain, mask);
1151+ dest = cpu_mask_to_apicid(tmp);
1152+
1153+ dmar_msi_read(irq, &msg);
1154+
1155+ msg.data &= ~MSI_DATA_VECTOR_MASK;
1156+ msg.data |= MSI_DATA_VECTOR(cfg->vector);
1157+ msg.address_lo &= ~MSI_ADDR_DEST_ID_MASK;
1158+ msg.address_lo |= MSI_ADDR_DEST_ID(dest);
1159+
1160+ dmar_msi_write(irq, &msg);
1161+ irq_desc[irq].affinity = mask;
1162+}
1163+#endif /* CONFIG_SMP */
1164+
1165+struct irq_chip dmar_msi_type = {
1166+ .name = "DMAR_MSI",
1167+ .unmask = dmar_msi_unmask,
1168+ .mask = dmar_msi_mask,
1169+ .ack = ack_apic_edge,
1170+#ifdef CONFIG_SMP
1171+ .set_affinity = dmar_msi_set_affinity,
1172+#endif
1173+ .retrigger = ioapic_retrigger_irq,
1174+};
1175+
1176+int arch_setup_dmar_msi(unsigned int irq)
1177+{
1178+ int ret;
1179+ struct msi_msg msg;
1180+
1181+ ret = msi_compose_msg(NULL, irq, &msg);
1182+ if (ret < 0)
1183+ return ret;
1184+ dmar_msi_write(irq, &msg);
1185+ set_irq_chip_and_handler_name(irq, &dmar_msi_type, handle_edge_irq,
1186+ "edge");
1187+ return 0;
1188+}
1189+#endif
1190
1191+#endif /* CONFIG_PCI_MSI */
1192 /*
1193 * Hypertransport interrupt support
1194 */
1195@@ -2177,8 +2245,27 @@ int io_apic_set_pci_routing (int ioapic,
1196 return 0;
1197 }
1198
1199-#endif /* CONFIG_ACPI */
1200
1201+int acpi_get_override_irq(int bus_irq, int *trigger, int *polarity)
1202+{
1203+ int i;
1204+
1205+ if (skip_ioapic_setup)
1206+ return -1;
1207+
1208+ for (i = 0; i < mp_irq_entries; i++)
1209+ if (mp_irqs[i].mpc_irqtype == mp_INT &&
1210+ mp_irqs[i].mpc_srcbusirq == bus_irq)
1211+ break;
1212+ if (i >= mp_irq_entries)
1213+ return -1;
1214+
1215+ *trigger = irq_trigger(i);
1216+ *polarity = irq_polarity(i);
1217+ return 0;
1218+}
1219+
1220+#endif /* CONFIG_ACPI */
1221
1222 #ifndef CONFIG_XEN
1223 /*
1224@@ -2217,3 +2304,4 @@ void __init setup_ioapic_dest(void)
1225 }
1226 #endif
1227 #endif /* !CONFIG_XEN */
1228+
1229Index: head-2008-12-01/arch/x86/kernel/ioport_32-xen.c
1230===================================================================
1231--- head-2008-12-01.orig/arch/x86/kernel/ioport_32-xen.c 2008-12-01 11:36:13.000000000 +0100
1232+++ head-2008-12-01/arch/x86/kernel/ioport_32-xen.c 2008-12-01 11:36:55.000000000 +0100
1233@@ -1,6 +1,4 @@
1234 /*
1235- * linux/arch/i386/kernel/ioport.c
1236- *
1237 * This contains the io-permission bitmap code - written by obz, with changes
1238 * by Linus.
1239 */
1240Index: head-2008-12-01/arch/x86/kernel/ioport_64-xen.c
1241===================================================================
1242--- head-2008-12-01.orig/arch/x86/kernel/ioport_64-xen.c 2008-12-01 11:36:13.000000000 +0100
1243+++ head-2008-12-01/arch/x86/kernel/ioport_64-xen.c 2008-12-01 11:36:55.000000000 +0100
1244@@ -1,6 +1,4 @@
1245 /*
1246- * linux/arch/x86_64/kernel/ioport.c
1247- *
1248 * This contains the io-permission bitmap code - written by obz, with changes
1249 * by Linus.
1250 */
1251Index: head-2008-12-01/arch/x86/kernel/irq_32-xen.c
1252===================================================================
1253--- head-2008-12-01.orig/arch/x86/kernel/irq_32-xen.c 2008-12-01 11:36:47.000000000 +0100
1254+++ head-2008-12-01/arch/x86/kernel/irq_32-xen.c 2008-12-01 11:36:55.000000000 +0100
1255@@ -1,6 +1,4 @@
1256 /*
1257- * linux/arch/i386/kernel/irq.c
1258- *
1259 * Copyright (C) 1992, 1998 Linus Torvalds, Ingo Molnar
1260 *
1261 * This file contains the lowest level x86-specific interrupt
1262@@ -231,8 +229,6 @@ asmlinkage void do_softirq(void)
1263
1264 local_irq_restore(flags);
1265 }
1266-
1267-EXPORT_SYMBOL(do_softirq);
1268 #endif
1269
1270 /*
1271@@ -259,9 +255,17 @@ int show_interrupts(struct seq_file *p,
1272 }
1273
1274 if (i < NR_IRQS) {
1275+ unsigned any_count = 0;
1276+
1277 spin_lock_irqsave(&irq_desc[i].lock, flags);
1278+#ifndef CONFIG_SMP
1279+ any_count = kstat_irqs(i);
1280+#else
1281+ for_each_online_cpu(j)
1282+ any_count |= kstat_cpu(j).irqs[i];
1283+#endif
1284 action = irq_desc[i].action;
1285- if (!action)
1286+ if (!action && !any_count)
1287 goto skip;
1288 seq_printf(p, "%3d: ",i);
1289 #ifndef CONFIG_SMP
1290@@ -272,10 +276,12 @@ int show_interrupts(struct seq_file *p,
1291 #endif
1292 seq_printf(p, " %8s", irq_desc[i].chip->name);
1293 seq_printf(p, "-%-8s", irq_desc[i].name);
1294- seq_printf(p, " %s", action->name);
1295
1296- for (action=action->next; action; action = action->next)
1297- seq_printf(p, ", %s", action->name);
1298+ if (action) {
1299+ seq_printf(p, " %s", action->name);
1300+ while ((action = action->next) != NULL)
1301+ seq_printf(p, ", %s", action->name);
1302+ }
1303
1304 seq_putc(p, '\n');
1305 skip:
1306@@ -284,13 +290,46 @@ skip:
1307 seq_printf(p, "NMI: ");
1308 for_each_online_cpu(j)
1309 seq_printf(p, "%10u ", nmi_count(j));
1310- seq_putc(p, '\n');
1311+ seq_printf(p, " Non-maskable interrupts\n");
1312 #ifdef CONFIG_X86_LOCAL_APIC
1313 seq_printf(p, "LOC: ");
1314 for_each_online_cpu(j)
1315 seq_printf(p, "%10u ",
1316 per_cpu(irq_stat,j).apic_timer_irqs);
1317- seq_putc(p, '\n');
1318+ seq_printf(p, " Local timer interrupts\n");
1319+#endif
1320+#ifdef CONFIG_SMP
1321+ seq_printf(p, "RES: ");
1322+ for_each_online_cpu(j)
1323+ seq_printf(p, "%10u ",
1324+ per_cpu(irq_stat,j).irq_resched_count);
1325+ seq_printf(p, " Rescheduling interrupts\n");
1326+ seq_printf(p, "CAL: ");
1327+ for_each_online_cpu(j)
1328+ seq_printf(p, "%10u ",
1329+ per_cpu(irq_stat,j).irq_call_count);
1330+ seq_printf(p, " function call interrupts\n");
1331+#ifndef CONFIG_XEN
1332+ seq_printf(p, "TLB: ");
1333+ for_each_online_cpu(j)
1334+ seq_printf(p, "%10u ",
1335+ per_cpu(irq_stat,j).irq_tlb_count);
1336+ seq_printf(p, " TLB shootdowns\n");
1337+#endif
1338+#endif
1339+#ifdef CONFIG_X86_MCE
1340+ seq_printf(p, "TRM: ");
1341+ for_each_online_cpu(j)
1342+ seq_printf(p, "%10u ",
1343+ per_cpu(irq_stat,j).irq_thermal_count);
1344+ seq_printf(p, " Thermal event interrupts\n");
1345+#endif
1346+#ifdef CONFIG_X86_LOCAL_APIC
1347+ seq_printf(p, "SPU: ");
1348+ for_each_online_cpu(j)
1349+ seq_printf(p, "%10u ",
1350+ per_cpu(irq_stat,j).irq_spurious_count);
1351+ seq_printf(p, " Spurious interrupts\n");
1352 #endif
1353 seq_printf(p, "ERR: %10u\n", atomic_read(&irq_err_count));
1354 #if defined(CONFIG_X86_IO_APIC)
1355Index: head-2008-12-01/arch/x86/kernel/irq_64-xen.c
1356===================================================================
1357--- head-2008-12-01.orig/arch/x86/kernel/irq_64-xen.c 2008-12-01 11:36:13.000000000 +0100
1358+++ head-2008-12-01/arch/x86/kernel/irq_64-xen.c 2008-12-01 11:36:55.000000000 +0100
1359@@ -1,6 +1,4 @@
1360 /*
1361- * linux/arch/x86_64/kernel/irq.c
1362- *
1363 * Copyright (C) 1992, 1998 Linus Torvalds, Ingo Molnar
1364 *
1365 * This file contains the lowest level x86_64-specific interrupt
1366@@ -64,9 +62,17 @@ int show_interrupts(struct seq_file *p,
1367 }
1368
1369 if (i < NR_IRQS) {
1370+ unsigned any_count = 0;
1371+
1372 spin_lock_irqsave(&irq_desc[i].lock, flags);
1373+#ifndef CONFIG_SMP
1374+ any_count = kstat_irqs(i);
1375+#else
1376+ for_each_online_cpu(j)
1377+ any_count |= kstat_cpu(j).irqs[i];
1378+#endif
1379 action = irq_desc[i].action;
1380- if (!action)
1381+ if (!action && !any_count)
1382 goto skip;
1383 seq_printf(p, "%3d: ",i);
1384 #ifndef CONFIG_SMP
1385@@ -78,9 +84,11 @@ int show_interrupts(struct seq_file *p,
1386 seq_printf(p, " %8s", irq_desc[i].chip->name);
1387 seq_printf(p, "-%-8s", irq_desc[i].name);
1388
1389- seq_printf(p, " %s", action->name);
1390- for (action=action->next; action; action = action->next)
1391- seq_printf(p, ", %s", action->name);
1392+ if (action) {
1393+ seq_printf(p, " %s", action->name);
1394+ while ((action = action->next) != NULL)
1395+ seq_printf(p, ", %s", action->name);
1396+ }
1397 seq_putc(p, '\n');
1398 skip:
1399 spin_unlock_irqrestore(&irq_desc[i].lock, flags);
1400@@ -88,12 +96,44 @@ skip:
1401 seq_printf(p, "NMI: ");
1402 for_each_online_cpu(j)
1403 seq_printf(p, "%10u ", cpu_pda(j)->__nmi_count);
1404- seq_putc(p, '\n');
1405+ seq_printf(p, " Non-maskable interrupts\n");
1406 #ifdef CONFIG_X86_LOCAL_APIC
1407 seq_printf(p, "LOC: ");
1408 for_each_online_cpu(j)
1409 seq_printf(p, "%10u ", cpu_pda(j)->apic_timer_irqs);
1410- seq_putc(p, '\n');
1411+ seq_printf(p, " Local timer interrupts\n");
1412+#endif
1413+#ifdef CONFIG_SMP
1414+ seq_printf(p, "RES: ");
1415+ for_each_online_cpu(j)
1416+ seq_printf(p, "%10u ", cpu_pda(j)->irq_resched_count);
1417+ seq_printf(p, " Rescheduling interrupts\n");
1418+ seq_printf(p, "CAL: ");
1419+ for_each_online_cpu(j)
1420+ seq_printf(p, "%10u ", cpu_pda(j)->irq_call_count);
1421+ seq_printf(p, " function call interrupts\n");
1422+#ifndef CONFIG_XEN
1423+ seq_printf(p, "TLB: ");
1424+ for_each_online_cpu(j)
1425+ seq_printf(p, "%10u ", cpu_pda(j)->irq_tlb_count);
1426+ seq_printf(p, " TLB shootdowns\n");
1427+#endif
1428+#endif
1429+#ifdef CONFIG_X86_MCE
1430+ seq_printf(p, "TRM: ");
1431+ for_each_online_cpu(j)
1432+ seq_printf(p, "%10u ", cpu_pda(j)->irq_thermal_count);
1433+ seq_printf(p, " Thermal event interrupts\n");
1434+ seq_printf(p, "THR: ");
1435+ for_each_online_cpu(j)
1436+ seq_printf(p, "%10u ", cpu_pda(j)->irq_threshold_count);
1437+ seq_printf(p, " Threshold APIC interrupts\n");
1438+#endif
1439+#ifdef CONFIG_X86_LOCAL_APIC
1440+ seq_printf(p, "SPU: ");
1441+ for_each_online_cpu(j)
1442+ seq_printf(p, "%10u ", cpu_pda(j)->irq_spurious_count);
1443+ seq_printf(p, " Spurious interrupts\n");
1444 #endif
1445 seq_printf(p, "ERR: %10u\n", atomic_read(&irq_err_count));
1446 }
1447@@ -211,7 +251,6 @@ asmlinkage void do_softirq(void)
1448 }
1449 local_irq_restore(flags);
1450 }
1451-EXPORT_SYMBOL(do_softirq);
1452
1453 #ifndef CONFIG_X86_LOCAL_APIC
1454 /*
1455Index: head-2008-12-01/arch/x86/kernel/ldt_32-xen.c
1456===================================================================
1457--- head-2008-12-01.orig/arch/x86/kernel/ldt_32-xen.c 2008-12-01 11:36:13.000000000 +0100
1458+++ head-2008-12-01/arch/x86/kernel/ldt_32-xen.c 2008-12-01 11:36:55.000000000 +0100
1459@@ -1,6 +1,4 @@
1460 /*
1461- * linux/arch/i386/kernel/ldt.c
1462- *
1463 * Copyright (C) 1992 Krishna Balasubramanian and Linus Torvalds
1464 * Copyright (C) 1999 Ingo Molnar <mingo@redhat.com>
1465 */
1466@@ -106,14 +104,14 @@ int init_new_context(struct task_struct
1467 struct mm_struct * old_mm;
1468 int retval = 0;
1469
1470- init_MUTEX(&mm->context.sem);
1471+ mutex_init(&mm->context.lock);
1472 mm->context.size = 0;
1473 mm->context.has_foreign_mappings = 0;
1474 old_mm = current->mm;
1475 if (old_mm && old_mm->context.size > 0) {
1476- down(&old_mm->context.sem);
1477+ mutex_lock(&old_mm->context.lock);
1478 retval = copy_ldt(&mm->context, &old_mm->context);
1479- up(&old_mm->context.sem);
1480+ mutex_unlock(&old_mm->context.lock);
1481 }
1482 return retval;
1483 }
1484@@ -149,7 +147,7 @@ static int read_ldt(void __user * ptr, u
1485 if (bytecount > LDT_ENTRY_SIZE*LDT_ENTRIES)
1486 bytecount = LDT_ENTRY_SIZE*LDT_ENTRIES;
1487
1488- down(&mm->context.sem);
1489+ mutex_lock(&mm->context.lock);
1490 size = mm->context.size*LDT_ENTRY_SIZE;
1491 if (size > bytecount)
1492 size = bytecount;
1493@@ -157,7 +155,7 @@ static int read_ldt(void __user * ptr, u
1494 err = 0;
1495 if (copy_to_user(ptr, mm->context.ldt, size))
1496 err = -EFAULT;
1497- up(&mm->context.sem);
1498+ mutex_unlock(&mm->context.lock);
1499 if (err < 0)
1500 goto error_return;
1501 if (size != bytecount) {
1502@@ -213,7 +211,7 @@ static int write_ldt(void __user * ptr,
1503 goto out;
1504 }
1505
1506- down(&mm->context.sem);
1507+ mutex_lock(&mm->context.lock);
1508 if (ldt_info.entry_number >= mm->context.size) {
1509 error = alloc_ldt(&current->mm->context, ldt_info.entry_number+1, 1);
1510 if (error < 0)
1511@@ -240,7 +238,7 @@ install:
1512 entry_1, entry_2);
1513
1514 out_unlock:
1515- up(&mm->context.sem);
1516+ mutex_unlock(&mm->context.lock);
1517 out:
1518 return error;
1519 }
1520Index: head-2008-12-01/arch/x86/kernel/ldt_64-xen.c
1521===================================================================
1522--- head-2008-12-01.orig/arch/x86/kernel/ldt_64-xen.c 2008-12-01 11:36:47.000000000 +0100
1523+++ head-2008-12-01/arch/x86/kernel/ldt_64-xen.c 2008-12-01 11:36:55.000000000 +0100
1524@@ -1,6 +1,4 @@
1525 /*
1526- * linux/arch/x86_64/kernel/ldt.c
1527- *
1528 * Copyright (C) 1992 Krishna Balasubramanian and Linus Torvalds
1529 * Copyright (C) 1999 Ingo Molnar <mingo@redhat.com>
1530 * Copyright (C) 2002 Andi Kleen
1531@@ -112,19 +110,14 @@ int init_new_context(struct task_struct
1532 int retval = 0;
1533
1534 memset(&mm->context, 0, sizeof(mm->context));
1535- init_MUTEX(&mm->context.sem);
1536+ mutex_init(&mm->context.lock);
1537 old_mm = current->mm;
1538 if (old_mm)
1539 mm->context.vdso = old_mm->context.vdso;
1540 if (old_mm && old_mm->context.size > 0) {
1541- down(&old_mm->context.sem);
1542+ mutex_lock(&old_mm->context.lock);
1543 retval = copy_ldt(&mm->context, &old_mm->context);
1544- up(&old_mm->context.sem);
1545- }
1546- if (retval == 0) {
1547- spin_lock(&mm_unpinned_lock);
1548- list_add(&mm->context.unpinned, &mm_unpinned);
1549- spin_unlock(&mm_unpinned_lock);
1550+ mutex_unlock(&old_mm->context.lock);
1551 }
1552 return retval;
1553 }
1554@@ -148,11 +141,6 @@ void destroy_context(struct mm_struct *m
1555 kfree(mm->context.ldt);
1556 mm->context.size = 0;
1557 }
1558- if (!PagePinned(virt_to_page(mm->pgd))) {
1559- spin_lock(&mm_unpinned_lock);
1560- list_del(&mm->context.unpinned);
1561- spin_unlock(&mm_unpinned_lock);
1562- }
1563 }
1564
1565 static int read_ldt(void __user * ptr, unsigned long bytecount)
1566@@ -166,7 +154,7 @@ static int read_ldt(void __user * ptr, u
1567 if (bytecount > LDT_ENTRY_SIZE*LDT_ENTRIES)
1568 bytecount = LDT_ENTRY_SIZE*LDT_ENTRIES;
1569
1570- down(&mm->context.sem);
1571+ mutex_lock(&mm->context.lock);
1572 size = mm->context.size*LDT_ENTRY_SIZE;
1573 if (size > bytecount)
1574 size = bytecount;
1575@@ -174,7 +162,7 @@ static int read_ldt(void __user * ptr, u
1576 err = 0;
1577 if (copy_to_user(ptr, mm->context.ldt, size))
1578 err = -EFAULT;
1579- up(&mm->context.sem);
1580+ mutex_unlock(&mm->context.lock);
1581 if (err < 0)
1582 goto error_return;
1583 if (size != bytecount) {
1584@@ -227,7 +215,7 @@ static int write_ldt(void __user * ptr,
1585 goto out;
1586 }
1587
1588- down(&mm->context.sem);
1589+ mutex_lock(&mm->context.lock);
1590 if (ldt_info.entry_number >= (unsigned)mm->context.size) {
1591 error = alloc_ldt(&current->mm->context, ldt_info.entry_number+1, 1);
1592 if (error < 0)
1593@@ -256,7 +244,7 @@ install:
1594 error = HYPERVISOR_update_descriptor(mach_lp, (unsigned long)((entry_1 | (unsigned long) entry_2 << 32)));
1595
1596 out_unlock:
1597- up(&mm->context.sem);
1598+ mutex_unlock(&mm->context.lock);
1599 out:
1600 return error;
1601 }
1602Index: head-2008-12-01/arch/x86/kernel/mpparse_32-xen.c
1603===================================================================
1604--- head-2008-12-01.orig/arch/x86/kernel/mpparse_32-xen.c 2008-12-01 11:36:13.000000000 +0100
1605+++ head-2008-12-01/arch/x86/kernel/mpparse_32-xen.c 2008-12-01 11:36:55.000000000 +0100
1606@@ -1023,7 +1023,7 @@ void __init mp_config_acpi_legacy_irqs (
1607
1608 /*
1609 * Use the default configuration for the IRQs 0-15. Unless
1610- * overriden by (MADT) interrupt source override entries.
1611+ * overridden by (MADT) interrupt source override entries.
1612 */
1613 for (i = 0; i < 16; i++) {
1614 int idx;
1615Index: head-2008-12-01/arch/x86/kernel/mpparse_64-xen.c
1616===================================================================
1617--- head-2008-12-01.orig/arch/x86/kernel/mpparse_64-xen.c 2008-12-01 11:36:47.000000000 +0100
1618+++ head-2008-12-01/arch/x86/kernel/mpparse_64-xen.c 2008-12-01 11:36:55.000000000 +0100
1619@@ -57,6 +57,8 @@ unsigned long mp_lapic_addr = 0;
1620
1621 /* Processor that is doing the boot up */
1622 unsigned int boot_cpu_id = -1U;
1623+EXPORT_SYMBOL(boot_cpu_id);
1624+
1625 /* Internal processor count */
1626 unsigned int num_processors __cpuinitdata = 0;
1627
1628@@ -87,7 +89,7 @@ static int __init mpf_checksum(unsigned
1629 }
1630
1631 #ifndef CONFIG_XEN
1632-static void __cpuinit MP_processor_info (struct mpc_config_processor *m)
1633+static void __cpuinit MP_processor_info(struct mpc_config_processor *m)
1634 {
1635 int cpu;
1636 cpumask_t tmp_map;
1637@@ -124,13 +126,24 @@ static void __cpuinit MP_processor_info
1638 cpu = 0;
1639 }
1640 bios_cpu_apicid[cpu] = m->mpc_apicid;
1641- x86_cpu_to_apicid[cpu] = m->mpc_apicid;
1642+ /*
1643+ * We get called early in the the start_kernel initialization
1644+ * process when the per_cpu data area is not yet setup, so we
1645+ * use a static array that is removed after the per_cpu data
1646+ * area is created.
1647+ */
1648+ if (x86_cpu_to_apicid_ptr) {
1649+ u8 *x86_cpu_to_apicid = (u8 *)x86_cpu_to_apicid_ptr;
1650+ x86_cpu_to_apicid[cpu] = m->mpc_apicid;
1651+ } else {
1652+ per_cpu(x86_cpu_to_apicid, cpu) = m->mpc_apicid;
1653+ }
1654
1655 cpu_set(cpu, cpu_possible_map);
1656 cpu_set(cpu, cpu_present_map);
1657 }
1658 #else
1659-static void __cpuinit MP_processor_info (struct mpc_config_processor *m)
1660+static void __cpuinit MP_processor_info(struct mpc_config_processor *m)
1661 {
1662 num_processors++;
1663 }
1664Index: head-2008-12-01/arch/x86/kernel/pci-dma-xen.c
1665===================================================================
1666--- head-2008-12-01.orig/arch/x86/kernel/pci-dma-xen.c 2008-12-01 11:36:47.000000000 +0100
1667+++ head-2008-12-01/arch/x86/kernel/pci-dma-xen.c 2008-12-01 11:36:55.000000000 +0100
1668@@ -13,14 +13,13 @@
1669 #include <linux/pci.h>
1670 #include <linux/module.h>
1671 #include <linux/version.h>
1672-#include <linux/pci.h>
1673 #include <asm/io.h>
1674 #include <xen/balloon.h>
1675 #include <xen/gnttab.h>
1676 #include <asm/swiotlb.h>
1677 #include <asm/tlbflush.h>
1678-#include <asm-i386/mach-xen/asm/swiotlb.h>
1679-#include <asm-i386/mach-xen/asm/gnttab_dma.h>
1680+#include <asm/swiotlb_32.h>
1681+#include <asm/gnttab_dma.h>
1682 #include <asm/bug.h>
1683
1684 #ifdef __x86_64__
1685@@ -106,27 +105,29 @@ int range_straddles_page_boundary(paddr_
1686 }
1687
1688 int
1689-dma_map_sg(struct device *hwdev, struct scatterlist *sg, int nents,
1690+dma_map_sg(struct device *hwdev, struct scatterlist *sgl, int nents,
1691 enum dma_data_direction direction)
1692 {
1693 int i, rc;
1694
1695 BUG_ON(!valid_dma_direction(direction));
1696- WARN_ON(nents == 0 || sg[0].length == 0);
1697+ WARN_ON(nents == 0 || sgl->length == 0);
1698
1699 if (swiotlb) {
1700- rc = swiotlb_map_sg(hwdev, sg, nents, direction);
1701+ rc = swiotlb_map_sg(hwdev, sgl, nents, direction);
1702 } else {
1703- for (i = 0; i < nents; i++ ) {
1704- BUG_ON(!sg[i].page);
1705- sg[i].dma_address =
1706- gnttab_dma_map_page(sg[i].page) + sg[i].offset;
1707- sg[i].dma_length = sg[i].length;
1708+ struct scatterlist *sg;
1709+
1710+ for_each_sg(sgl, sg, nents, i) {
1711+ BUG_ON(!sg_page(sg));
1712+ sg->dma_address =
1713+ gnttab_dma_map_page(sg_page(sg)) + sg->offset;
1714+ sg->dma_length = sg->length;
1715 IOMMU_BUG_ON(address_needs_mapping(
1716- hwdev, sg[i].dma_address));
1717+ hwdev, sg->dma_address));
1718 IOMMU_BUG_ON(range_straddles_page_boundary(
1719- page_to_pseudophys(sg[i].page) + sg[i].offset,
1720- sg[i].length));
1721+ page_to_pseudophys(sg_page(sg)) + sg->offset,
1722+ sg->length));
1723 }
1724 rc = nents;
1725 }
1726@@ -137,17 +138,19 @@ dma_map_sg(struct device *hwdev, struct
1727 EXPORT_SYMBOL(dma_map_sg);
1728
1729 void
1730-dma_unmap_sg(struct device *hwdev, struct scatterlist *sg, int nents,
1731+dma_unmap_sg(struct device *hwdev, struct scatterlist *sgl, int nents,
1732 enum dma_data_direction direction)
1733 {
1734 int i;
1735
1736 BUG_ON(!valid_dma_direction(direction));
1737 if (swiotlb)
1738- swiotlb_unmap_sg(hwdev, sg, nents, direction);
1739+ swiotlb_unmap_sg(hwdev, sgl, nents, direction);
1740 else {
1741- for (i = 0; i < nents; i++ )
1742- gnttab_dma_unmap_page(sg[i].dma_address);
1743+ struct scatterlist *sg;
1744+
1745+ for_each_sg(sgl, sg, nents, i)
1746+ gnttab_dma_unmap_page(sg->dma_address);
1747 }
1748 }
1749 EXPORT_SYMBOL(dma_unmap_sg);
1750@@ -261,7 +264,8 @@ void dma_free_coherent(struct device *de
1751 {
1752 struct dma_coherent_mem *mem = dev ? dev->dma_mem : NULL;
1753 int order = get_order(size);
1754-
1755+
1756+ WARN_ON(irqs_disabled()); /* for portability */
1757 if (mem && vaddr >= mem->virt_base && vaddr < (mem->virt_base + (mem->size << PAGE_SHIFT))) {
1758 int page = (vaddr - mem->virt_base) >> PAGE_SHIFT;
1759
1760Index: head-2008-12-01/arch/x86/kernel/process_32-xen.c
1761===================================================================
1762--- head-2008-12-01.orig/arch/x86/kernel/process_32-xen.c 2008-12-01 11:36:47.000000000 +0100
1763+++ head-2008-12-01/arch/x86/kernel/process_32-xen.c 2008-12-01 11:36:55.000000000 +0100
1764@@ -1,6 +1,4 @@
1765 /*
1766- * linux/arch/i386/kernel/process.c
1767- *
1768 * Copyright (C) 1995 Linus Torvalds
1769 *
1770 * Pentium III FXSR, SSE support
1771@@ -190,6 +188,10 @@ void cpu_idle(void)
1772 }
1773 }
1774
1775+static void do_nothing(void *unused)
1776+{
1777+}
1778+
1779 void cpu_idle_wait(void)
1780 {
1781 unsigned int cpu, this_cpu = get_cpu();
1782@@ -214,13 +216,20 @@ void cpu_idle_wait(void)
1783 cpu_clear(cpu, map);
1784 }
1785 cpus_and(map, map, cpu_online_map);
1786+ /*
1787+ * We waited 1 sec, if a CPU still did not call idle
1788+ * it may be because it is in idle and not waking up
1789+ * because it has nothing to do.
1790+ * Give all the remaining CPUS a kick.
1791+ */
1792+ smp_call_function_mask(map, do_nothing, 0, 0);
1793 } while (!cpus_empty(map));
1794
1795 set_cpus_allowed(current, tmp);
1796 }
1797 EXPORT_SYMBOL_GPL(cpu_idle_wait);
1798
1799-void __devinit select_idle_routine(const struct cpuinfo_x86 *c)
1800+void __cpuinit select_idle_routine(const struct cpuinfo_x86 *c)
1801 {
1802 }
1803
1804@@ -238,34 +247,52 @@ static int __init idle_setup(char *str)
1805 }
1806 early_param("idle", idle_setup);
1807
1808-void show_regs(struct pt_regs * regs)
1809+void __show_registers(struct pt_regs *regs, int all)
1810 {
1811 unsigned long cr0 = 0L, cr2 = 0L, cr3 = 0L, cr4 = 0L;
1812 unsigned long d0, d1, d2, d3, d6, d7;
1813+ unsigned long esp;
1814+ unsigned short ss, gs;
1815+
1816+ if (user_mode_vm(regs)) {
1817+ esp = regs->esp;
1818+ ss = regs->xss & 0xffff;
1819+ savesegment(gs, gs);
1820+ } else {
1821+ esp = (unsigned long) (&regs->esp);
1822+ savesegment(ss, ss);
1823+ savesegment(gs, gs);
1824+ }
1825
1826 printk("\n");
1827- printk("Pid: %d, comm: %20s\n", current->pid, current->comm);
1828- printk("EIP: %04x:[<%08lx>] CPU: %d\n",0xffff & regs->xcs,regs->eip, smp_processor_id());
1829+ printk("Pid: %d, comm: %s %s (%s %.*s)\n",
1830+ task_pid_nr(current), current->comm,
1831+ print_tainted(), init_utsname()->release,
1832+ (int)strcspn(init_utsname()->version, " "),
1833+ init_utsname()->version);
1834+
1835+ printk("EIP: %04x:[<%08lx>] EFLAGS: %08lx CPU: %d\n",
1836+ 0xffff & regs->xcs, regs->eip, regs->eflags,
1837+ smp_processor_id());
1838 print_symbol("EIP is at %s\n", regs->eip);
1839
1840- if (user_mode_vm(regs))
1841- printk(" ESP: %04x:%08lx",0xffff & regs->xss,regs->esp);
1842- printk(" EFLAGS: %08lx %s (%s %.*s)\n",
1843- regs->eflags, print_tainted(), init_utsname()->release,
1844- (int)strcspn(init_utsname()->version, " "),
1845- init_utsname()->version);
1846 printk("EAX: %08lx EBX: %08lx ECX: %08lx EDX: %08lx\n",
1847- regs->eax,regs->ebx,regs->ecx,regs->edx);
1848- printk("ESI: %08lx EDI: %08lx EBP: %08lx",
1849- regs->esi, regs->edi, regs->ebp);
1850- printk(" DS: %04x ES: %04x FS: %04x\n",
1851- 0xffff & regs->xds,0xffff & regs->xes, 0xffff & regs->xfs);
1852+ regs->eax, regs->ebx, regs->ecx, regs->edx);
1853+ printk("ESI: %08lx EDI: %08lx EBP: %08lx ESP: %08lx\n",
1854+ regs->esi, regs->edi, regs->ebp, esp);
1855+ printk(" DS: %04x ES: %04x FS: %04x GS: %04x SS: %04x\n",
1856+ regs->xds & 0xffff, regs->xes & 0xffff,
1857+ regs->xfs & 0xffff, gs, ss);
1858+
1859+ if (!all)
1860+ return;
1861
1862 cr0 = read_cr0();
1863 cr2 = read_cr2();
1864 cr3 = read_cr3();
1865 cr4 = read_cr4_safe();
1866- printk("CR0: %08lx CR2: %08lx CR3: %08lx CR4: %08lx\n", cr0, cr2, cr3, cr4);
1867+ printk("CR0: %08lx CR2: %08lx CR3: %08lx CR4: %08lx\n",
1868+ cr0, cr2, cr3, cr4);
1869
1870 get_debugreg(d0, 0);
1871 get_debugreg(d1, 1);
1872@@ -273,10 +300,16 @@ void show_regs(struct pt_regs * regs)
1873 get_debugreg(d3, 3);
1874 printk("DR0: %08lx DR1: %08lx DR2: %08lx DR3: %08lx\n",
1875 d0, d1, d2, d3);
1876+
1877 get_debugreg(d6, 6);
1878 get_debugreg(d7, 7);
1879- printk("DR6: %08lx DR7: %08lx\n", d6, d7);
1880+ printk("DR6: %08lx DR7: %08lx\n",
1881+ d6, d7);
1882+}
1883
1884+void show_regs(struct pt_regs *regs)
1885+{
1886+ __show_registers(regs, 1);
1887 show_trace(NULL, regs, &regs->esp);
1888 }
1889
1890Index: head-2008-12-01/arch/x86/kernel/process_64-xen.c
1891===================================================================
1892--- head-2008-12-01.orig/arch/x86/kernel/process_64-xen.c 2008-12-01 11:36:47.000000000 +0100
1893+++ head-2008-12-01/arch/x86/kernel/process_64-xen.c 2008-12-01 11:36:55.000000000 +0100
1894@@ -1,6 +1,4 @@
1895 /*
1896- * linux/arch/x86-64/kernel/process.c
1897- *
1898 * Copyright (C) 1995 Linus Torvalds
1899 *
1900 * Pentium III FXSR, SSE support
1901@@ -41,6 +39,7 @@
1902 #include <linux/notifier.h>
1903 #include <linux/kprobes.h>
1904 #include <linux/kdebug.h>
1905+#include <linux/tick.h>
1906
1907 #include <asm/uaccess.h>
1908 #include <asm/pgtable.h>
1909@@ -172,6 +171,9 @@ void cpu_idle (void)
1910
1911 if (__get_cpu_var(cpu_idle_state))
1912 __get_cpu_var(cpu_idle_state) = 0;
1913+
1914+ tick_nohz_stop_sched_tick();
1915+
1916 rmb();
1917 idle = xen_idle; /* no alternatives */
1918 if (cpu_is_offline(smp_processor_id()))
1919@@ -190,12 +192,17 @@ void cpu_idle (void)
1920 __exit_idle();
1921 }
1922
1923+ tick_nohz_restart_sched_tick();
1924 preempt_enable_no_resched();
1925 schedule();
1926 preempt_disable();
1927 }
1928 }
1929
1930+static void do_nothing(void *unused)
1931+{
1932+}
1933+
1934 void cpu_idle_wait(void)
1935 {
1936 unsigned int cpu, this_cpu = get_cpu();
1937@@ -221,6 +228,13 @@ void cpu_idle_wait(void)
1938 cpu_clear(cpu, map);
1939 }
1940 cpus_and(map, map, cpu_online_map);
1941+ /*
1942+ * We waited 1 sec, if a CPU still did not call idle
1943+ * it may be because it is in idle and not waking up
1944+ * because it has nothing to do.
1945+ * Give all the remaining CPUS a kick.
1946+ */
1947+ smp_call_function_mask(map, do_nothing, 0, 0);
1948 } while (!cpus_empty(map));
1949
1950 set_cpus_allowed(current, tmp);
1951@@ -528,7 +542,7 @@ static inline void __switch_to_xtra(stru
1952 *
1953 * Kprobes not supported here. Set the probe on schedule instead.
1954 */
1955-__kprobes struct task_struct *
1956+struct task_struct *
1957 __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
1958 {
1959 struct thread_struct *prev = &prev_p->thread,
1960Index: head-2008-12-01/arch/x86/kernel/quirks-xen.c
1961===================================================================
1962--- head-2008-12-01.orig/arch/x86/kernel/quirks-xen.c 2008-12-01 11:36:13.000000000 +0100
1963+++ head-2008-12-01/arch/x86/kernel/quirks-xen.c 2008-12-01 11:36:55.000000000 +0100
1964@@ -41,7 +41,353 @@ static void __devinit quirk_intel_irqbal
1965 if (!(config & 0x2))
1966 pci_write_config_byte(dev, 0xf4, config);
1967 }
1968-DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_E7320_MCH, quirk_intel_irqbalance);
1969-DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_E7525_MCH, quirk_intel_irqbalance);
1970-DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_E7520_MCH, quirk_intel_irqbalance);
1971+DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_E7320_MCH,
1972+ quirk_intel_irqbalance);
1973+DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_E7525_MCH,
1974+ quirk_intel_irqbalance);
1975+DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_E7520_MCH,
1976+ quirk_intel_irqbalance);
1977+#endif
1978+
1979+#if defined(CONFIG_HPET_TIMER)
1980+#include <asm/hpet.h>
1981+
1982+unsigned long force_hpet_address;
1983+
1984+static enum {
1985+ NONE_FORCE_HPET_RESUME,
1986+ OLD_ICH_FORCE_HPET_RESUME,
1987+ ICH_FORCE_HPET_RESUME,
1988+ VT8237_FORCE_HPET_RESUME,
1989+ NVIDIA_FORCE_HPET_RESUME,
1990+} force_hpet_resume_type;
1991+
1992+static void __iomem *rcba_base;
1993+
1994+static void ich_force_hpet_resume(void)
1995+{
1996+ u32 val;
1997+
1998+ if (!force_hpet_address)
1999+ return;
2000+
2001+ if (rcba_base == NULL)
2002+ BUG();
2003+
2004+ /* read the Function Disable register, dword mode only */
2005+ val = readl(rcba_base + 0x3404);
2006+ if (!(val & 0x80)) {
2007+ /* HPET disabled in HPTC. Trying to enable */
2008+ writel(val | 0x80, rcba_base + 0x3404);
2009+ }
2010+
2011+ val = readl(rcba_base + 0x3404);
2012+ if (!(val & 0x80))
2013+ BUG();
2014+ else
2015+ printk(KERN_DEBUG "Force enabled HPET at resume\n");
2016+
2017+ return;
2018+}
2019+
2020+static void ich_force_enable_hpet(struct pci_dev *dev)
2021+{
2022+ u32 val;
2023+ u32 uninitialized_var(rcba);
2024+ int err = 0;
2025+
2026+ if (hpet_address || force_hpet_address)
2027+ return;
2028+
2029+ pci_read_config_dword(dev, 0xF0, &rcba);
2030+ rcba &= 0xFFFFC000;
2031+ if (rcba == 0) {
2032+ printk(KERN_DEBUG "RCBA disabled. Cannot force enable HPET\n");
2033+ return;
2034+ }
2035+
2036+ /* use bits 31:14, 16 kB aligned */
2037+ rcba_base = ioremap_nocache(rcba, 0x4000);
2038+ if (rcba_base == NULL) {
2039+ printk(KERN_DEBUG "ioremap failed. Cannot force enable HPET\n");
2040+ return;
2041+ }
2042+
2043+ /* read the Function Disable register, dword mode only */
2044+ val = readl(rcba_base + 0x3404);
2045+
2046+ if (val & 0x80) {
2047+ /* HPET is enabled in HPTC. Just not reported by BIOS */
2048+ val = val & 0x3;
2049+ force_hpet_address = 0xFED00000 | (val << 12);
2050+ printk(KERN_DEBUG "Force enabled HPET at base address 0x%lx\n",
2051+ force_hpet_address);
2052+ iounmap(rcba_base);
2053+ return;
2054+ }
2055+
2056+ /* HPET disabled in HPTC. Trying to enable */
2057+ writel(val | 0x80, rcba_base + 0x3404);
2058+
2059+ val = readl(rcba_base + 0x3404);
2060+ if (!(val & 0x80)) {
2061+ err = 1;
2062+ } else {
2063+ val = val & 0x3;
2064+ force_hpet_address = 0xFED00000 | (val << 12);
2065+ }
2066+
2067+ if (err) {
2068+ force_hpet_address = 0;
2069+ iounmap(rcba_base);
2070+ printk(KERN_DEBUG "Failed to force enable HPET\n");
2071+ } else {
2072+ force_hpet_resume_type = ICH_FORCE_HPET_RESUME;
2073+ printk(KERN_DEBUG "Force enabled HPET at base address 0x%lx\n",
2074+ force_hpet_address);
2075+ }
2076+}
2077+
2078+DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ESB2_0,
2079+ ich_force_enable_hpet);
2080+DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH6_1,
2081+ ich_force_enable_hpet);
2082+DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH7_0,
2083+ ich_force_enable_hpet);
2084+DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH7_1,
2085+ ich_force_enable_hpet);
2086+DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH7_31,
2087+ ich_force_enable_hpet);
2088+DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH8_1,
2089+ ich_force_enable_hpet);
2090+
2091+
2092+static struct pci_dev *cached_dev;
2093+
2094+static void old_ich_force_hpet_resume(void)
2095+{
2096+ u32 val;
2097+ u32 uninitialized_var(gen_cntl);
2098+
2099+ if (!force_hpet_address || !cached_dev)
2100+ return;
2101+
2102+ pci_read_config_dword(cached_dev, 0xD0, &gen_cntl);
2103+ gen_cntl &= (~(0x7 << 15));
2104+ gen_cntl |= (0x4 << 15);
2105+
2106+ pci_write_config_dword(cached_dev, 0xD0, gen_cntl);
2107+ pci_read_config_dword(cached_dev, 0xD0, &gen_cntl);
2108+ val = gen_cntl >> 15;
2109+ val &= 0x7;
2110+ if (val == 0x4)
2111+ printk(KERN_DEBUG "Force enabled HPET at resume\n");
2112+ else
2113+ BUG();
2114+}
2115+
2116+static void old_ich_force_enable_hpet(struct pci_dev *dev)
2117+{
2118+ u32 val;
2119+ u32 uninitialized_var(gen_cntl);
2120+
2121+ if (hpet_address || force_hpet_address)
2122+ return;
2123+
2124+ pci_read_config_dword(dev, 0xD0, &gen_cntl);
2125+ /*
2126+ * Bit 17 is HPET enable bit.
2127+ * Bit 16:15 control the HPET base address.
2128+ */
2129+ val = gen_cntl >> 15;
2130+ val &= 0x7;
2131+ if (val & 0x4) {
2132+ val &= 0x3;
2133+ force_hpet_address = 0xFED00000 | (val << 12);
2134+ printk(KERN_DEBUG "HPET at base address 0x%lx\n",
2135+ force_hpet_address);
2136+ return;
2137+ }
2138+
2139+ /*
2140+ * HPET is disabled. Trying enabling at FED00000 and check
2141+ * whether it sticks
2142+ */
2143+ gen_cntl &= (~(0x7 << 15));
2144+ gen_cntl |= (0x4 << 15);
2145+ pci_write_config_dword(dev, 0xD0, gen_cntl);
2146+
2147+ pci_read_config_dword(dev, 0xD0, &gen_cntl);
2148+
2149+ val = gen_cntl >> 15;
2150+ val &= 0x7;
2151+ if (val & 0x4) {
2152+ /* HPET is enabled in HPTC. Just not reported by BIOS */
2153+ val &= 0x3;
2154+ force_hpet_address = 0xFED00000 | (val << 12);
2155+ printk(KERN_DEBUG "Force enabled HPET at base address 0x%lx\n",
2156+ force_hpet_address);
2157+ cached_dev = dev;
2158+ force_hpet_resume_type = OLD_ICH_FORCE_HPET_RESUME;
2159+ return;
2160+ }
2161+
2162+ printk(KERN_DEBUG "Failed to force enable HPET\n");
2163+}
2164+
2165+/*
2166+ * Undocumented chipset features. Make sure that the user enforced
2167+ * this.
2168+ */
2169+static void old_ich_force_enable_hpet_user(struct pci_dev *dev)
2170+{
2171+ if (hpet_force_user)
2172+ old_ich_force_enable_hpet(dev);
2173+}
2174+
2175+DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801CA_0,
2176+ old_ich_force_enable_hpet_user);
2177+DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801CA_12,
2178+ old_ich_force_enable_hpet_user);
2179+DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801DB_0,
2180+ old_ich_force_enable_hpet_user);
2181+DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801DB_12,
2182+ old_ich_force_enable_hpet_user);
2183+DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801EB_0,
2184+ old_ich_force_enable_hpet);
2185+DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801EB_12,
2186+ old_ich_force_enable_hpet);
2187+
2188+
2189+static void vt8237_force_hpet_resume(void)
2190+{
2191+ u32 val;
2192+
2193+ if (!force_hpet_address || !cached_dev)
2194+ return;
2195+
2196+ val = 0xfed00000 | 0x80;
2197+ pci_write_config_dword(cached_dev, 0x68, val);
2198+
2199+ pci_read_config_dword(cached_dev, 0x68, &val);
2200+ if (val & 0x80)
2201+ printk(KERN_DEBUG "Force enabled HPET at resume\n");
2202+ else
2203+ BUG();
2204+}
2205+
2206+static void vt8237_force_enable_hpet(struct pci_dev *dev)
2207+{
2208+ u32 uninitialized_var(val);
2209+
2210+ if (!hpet_force_user || hpet_address || force_hpet_address)
2211+ return;
2212+
2213+ pci_read_config_dword(dev, 0x68, &val);
2214+ /*
2215+ * Bit 7 is HPET enable bit.
2216+ * Bit 31:10 is HPET base address (contrary to what datasheet claims)
2217+ */
2218+ if (val & 0x80) {
2219+ force_hpet_address = (val & ~0x3ff);
2220+ printk(KERN_DEBUG "HPET at base address 0x%lx\n",
2221+ force_hpet_address);
2222+ return;
2223+ }
2224+
2225+ /*
2226+ * HPET is disabled. Trying enabling at FED00000 and check
2227+ * whether it sticks
2228+ */
2229+ val = 0xfed00000 | 0x80;
2230+ pci_write_config_dword(dev, 0x68, val);
2231+
2232+ pci_read_config_dword(dev, 0x68, &val);
2233+ if (val & 0x80) {
2234+ force_hpet_address = (val & ~0x3ff);
2235+ printk(KERN_DEBUG "Force enabled HPET at base address 0x%lx\n",
2236+ force_hpet_address);
2237+ cached_dev = dev;
2238+ force_hpet_resume_type = VT8237_FORCE_HPET_RESUME;
2239+ return;
2240+ }
2241+
2242+ printk(KERN_DEBUG "Failed to force enable HPET\n");
2243+}
2244+
2245+DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8235,
2246+ vt8237_force_enable_hpet);
2247+DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8237,
2248+ vt8237_force_enable_hpet);
2249+
2250+/*
2251+ * Undocumented chipset feature taken from LinuxBIOS.
2252+ */
2253+static void nvidia_force_hpet_resume(void)
2254+{
2255+ pci_write_config_dword(cached_dev, 0x44, 0xfed00001);
2256+ printk(KERN_DEBUG "Force enabled HPET at resume\n");
2257+}
2258+
2259+static void nvidia_force_enable_hpet(struct pci_dev *dev)
2260+{
2261+ u32 uninitialized_var(val);
2262+
2263+ if (!hpet_force_user || hpet_address || force_hpet_address)
2264+ return;
2265+
2266+ pci_write_config_dword(dev, 0x44, 0xfed00001);
2267+ pci_read_config_dword(dev, 0x44, &val);
2268+ force_hpet_address = val & 0xfffffffe;
2269+ force_hpet_resume_type = NVIDIA_FORCE_HPET_RESUME;
2270+ printk(KERN_DEBUG "Force enabled HPET at base address 0x%lx\n",
2271+ force_hpet_address);
2272+ cached_dev = dev;
2273+ return;
2274+}
2275+
2276+/* ISA Bridges */
2277+DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_NVIDIA, 0x0050,
2278+ nvidia_force_enable_hpet);
2279+DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_NVIDIA, 0x0051,
2280+ nvidia_force_enable_hpet);
2281+
2282+/* LPC bridges */
2283+DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_NVIDIA, 0x0360,
2284+ nvidia_force_enable_hpet);
2285+DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_NVIDIA, 0x0361,
2286+ nvidia_force_enable_hpet);
2287+DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_NVIDIA, 0x0362,
2288+ nvidia_force_enable_hpet);
2289+DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_NVIDIA, 0x0363,
2290+ nvidia_force_enable_hpet);
2291+DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_NVIDIA, 0x0364,
2292+ nvidia_force_enable_hpet);
2293+DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_NVIDIA, 0x0365,
2294+ nvidia_force_enable_hpet);
2295+DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_NVIDIA, 0x0366,
2296+ nvidia_force_enable_hpet);
2297+DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_NVIDIA, 0x0367,
2298+ nvidia_force_enable_hpet);
2299+
2300+void force_hpet_resume(void)
2301+{
2302+ switch (force_hpet_resume_type) {
2303+ case ICH_FORCE_HPET_RESUME:
2304+ return ich_force_hpet_resume();
2305+
2306+ case OLD_ICH_FORCE_HPET_RESUME:
2307+ return old_ich_force_hpet_resume();
2308+
2309+ case VT8237_FORCE_HPET_RESUME:
2310+ return vt8237_force_hpet_resume();
2311+
2312+ case NVIDIA_FORCE_HPET_RESUME:
2313+ return nvidia_force_hpet_resume();
2314+
2315+ default:
2316+ break;
2317+ }
2318+}
2319+
2320 #endif
2321Index: head-2008-12-01/arch/x86/kernel/setup64-xen.c
2322===================================================================
2323--- head-2008-12-01.orig/arch/x86/kernel/setup64-xen.c 2008-12-01 11:36:47.000000000 +0100
2324+++ head-2008-12-01/arch/x86/kernel/setup64-xen.c 2008-12-01 11:36:55.000000000 +0100
2325@@ -15,7 +15,6 @@
2326 #include <linux/bootmem.h>
2327 #include <linux/bitops.h>
2328 #include <linux/module.h>
2329-#include <asm/bootsetup.h>
2330 #include <asm/pda.h>
2331 #include <asm/pgtable.h>
2332 #include <asm/processor.h>
2333@@ -27,11 +26,12 @@
2334 #include <asm/percpu.h>
2335 #include <asm/proto.h>
2336 #include <asm/sections.h>
2337+#include <asm/setup.h>
2338 #ifdef CONFIG_XEN
2339 #include <asm/hypervisor.h>
2340 #endif
2341
2342-char x86_boot_params[BOOT_PARAM_SIZE] __initdata;
2343+struct boot_params __initdata boot_params;
2344
2345 cpumask_t cpu_initialized __cpuinitdata = CPU_MASK_NONE;
2346
2347@@ -159,8 +159,8 @@ static void switch_pt(void)
2348
2349 static void __cpuinit cpu_gdt_init(const struct desc_ptr *gdt_descr)
2350 {
2351- asm volatile("lgdt %0" :: "m" (*gdt_descr));
2352- asm volatile("lidt %0" :: "m" (idt_descr));
2353+ load_gdt(gdt_descr);
2354+ load_idt(idt_descr);
2355 }
2356 #endif
2357
2358@@ -252,6 +252,14 @@ void __cpuinit check_efer(void)
2359
2360 unsigned long kernel_eflags;
2361
2362+#ifndef CONFIG_X86_NO_TSS
2363+/*
2364+ * Copies of the original ist values from the tss are only accessed during
2365+ * debugging, no special alignment required.
2366+ */
2367+DEFINE_PER_CPU(struct orig_ist, orig_ist);
2368+#endif
2369+
2370 /*
2371 * cpu_init() initializes state that is per-CPU. Some data is already
2372 * initialized (naturally) in the bootstrap process, such as the GDT
2373Index: head-2008-12-01/arch/x86/kernel/setup_32-xen.c
2374===================================================================
2375--- head-2008-12-01.orig/arch/x86/kernel/setup_32-xen.c 2008-12-01 11:36:47.000000000 +0100
2376+++ head-2008-12-01/arch/x86/kernel/setup_32-xen.c 2008-12-01 11:36:55.000000000 +0100
2377@@ -1,6 +1,4 @@
2378 /*
2379- * linux/arch/i386/kernel/setup.c
2380- *
2381 * Copyright (C) 1995 Linus Torvalds
2382 *
2383 * Support of BIGMEM added by Gerhard Wichert, Siemens AG, July 1999
2384@@ -70,6 +68,7 @@
2385 #include <xen/xencons.h>
2386 #include <setup_arch.h>
2387 #include <bios_ebda.h>
2388+#include <asm/cacheflush.h>
2389
2390 #ifdef CONFIG_XEN
2391 #include <xen/interface/kexec.h>
2392@@ -80,13 +79,14 @@ static struct notifier_block xen_panic_b
2393 xen_panic_event, NULL, 0 /* try to go last */
2394 };
2395
2396-int disable_pse __devinitdata = 0;
2397+int disable_pse __cpuinitdata = 0;
2398
2399 /*
2400 * Machine setup..
2401 */
2402 extern struct resource code_resource;
2403 extern struct resource data_resource;
2404+extern struct resource bss_resource;
2405
2406 /* cpu data as detected by the assembly code in head.S */
2407 struct cpuinfo_x86 new_cpu_data __cpuinitdata = { 0, 0, 0, 0, -1, 1, 0, 0, -1 };
2408@@ -98,9 +98,6 @@ unsigned long mmu_cr4_features;
2409
2410 /* for MCA, but anyone else can use it if they want */
2411 unsigned int machine_id;
2412-#ifdef CONFIG_MCA
2413-EXPORT_SYMBOL(machine_id);
2414-#endif
2415 unsigned int machine_submodel_id;
2416 unsigned int BIOS_revision;
2417 unsigned int mca_pentium_flag;
2418@@ -121,7 +118,7 @@ EXPORT_SYMBOL(apm_info);
2419 struct edid_info edid_info;
2420 EXPORT_SYMBOL_GPL(edid_info);
2421 #ifndef CONFIG_XEN
2422-#define copy_edid() (edid_info = EDID_INFO)
2423+#define copy_edid() (edid_info = boot_params.edid_info)
2424 #endif
2425 struct ist_info ist_info;
2426 #if defined(CONFIG_X86_SPEEDSTEP_SMI) || \
2427@@ -170,10 +167,11 @@ EXPORT_SYMBOL(edd);
2428 */
2429 static inline void copy_edd(void)
2430 {
2431- memcpy(edd.mbr_signature, EDD_MBR_SIGNATURE, sizeof(edd.mbr_signature));
2432- memcpy(edd.edd_info, EDD_BUF, sizeof(edd.edd_info));
2433- edd.mbr_signature_nr = EDD_MBR_SIG_NR;
2434- edd.edd_info_nr = EDD_NR;
2435+ memcpy(edd.mbr_signature, boot_params.edd_mbr_sig_buffer,
2436+ sizeof(edd.mbr_signature));
2437+ memcpy(edd.edd_info, boot_params.eddbuf, sizeof(edd.edd_info));
2438+ edd.mbr_signature_nr = boot_params.edd_mbr_sig_buf_entries;
2439+ edd.edd_info_nr = boot_params.eddbuf_entries;
2440 }
2441 #endif
2442 #else
2443@@ -416,6 +414,53 @@ extern unsigned long __init setup_memory
2444 extern void zone_sizes_init(void);
2445 #endif /* !CONFIG_NEED_MULTIPLE_NODES */
2446
2447+static inline unsigned long long get_total_mem(void)
2448+{
2449+ unsigned long long total;
2450+
2451+ total = max_low_pfn - min_low_pfn;
2452+#ifdef CONFIG_HIGHMEM
2453+ total += highend_pfn - highstart_pfn;
2454+#endif
2455+
2456+ return total << PAGE_SHIFT;
2457+}
2458+
2459+#ifdef CONFIG_KEXEC
2460+#ifndef CONFIG_XEN
2461+static void __init reserve_crashkernel(void)
2462+{
2463+ unsigned long long total_mem;
2464+ unsigned long long crash_size, crash_base;
2465+ int ret;
2466+
2467+ total_mem = get_total_mem();
2468+
2469+ ret = parse_crashkernel(boot_command_line, total_mem,
2470+ &crash_size, &crash_base);
2471+ if (ret == 0 && crash_size > 0) {
2472+ if (crash_base > 0) {
2473+ printk(KERN_INFO "Reserving %ldMB of memory at %ldMB "
2474+ "for crashkernel (System RAM: %ldMB)\n",
2475+ (unsigned long)(crash_size >> 20),
2476+ (unsigned long)(crash_base >> 20),
2477+ (unsigned long)(total_mem >> 20));
2478+ crashk_res.start = crash_base;
2479+ crashk_res.end = crash_base + crash_size - 1;
2480+ reserve_bootmem(crash_base, crash_size);
2481+ } else
2482+ printk(KERN_INFO "crashkernel reservation failed - "
2483+ "you have to specify a base address\n");
2484+ }
2485+}
2486+#else
2487+#define reserve_crashkernel xen_machine_kexec_setup_resources
2488+#endif
2489+#else
2490+static inline void __init reserve_crashkernel(void)
2491+{}
2492+#endif
2493+
2494 void __init setup_bootmem_allocator(void)
2495 {
2496 unsigned long bootmap_size;
2497@@ -471,30 +516,25 @@ void __init setup_bootmem_allocator(void
2498
2499 #ifdef CONFIG_BLK_DEV_INITRD
2500 if (xen_start_info->mod_start) {
2501- if (INITRD_START + INITRD_SIZE <= (max_low_pfn << PAGE_SHIFT)) {
2502- /*reserve_bootmem(INITRD_START, INITRD_SIZE);*/
2503- initrd_start = INITRD_START + PAGE_OFFSET;
2504- initrd_end = initrd_start+INITRD_SIZE;
2505+ unsigned long ramdisk_image = __pa(xen_start_info->mod_start);
2506+ unsigned long ramdisk_size = xen_start_info->mod_len;
2507+ unsigned long ramdisk_end = ramdisk_image + ramdisk_size;
2508+ unsigned long end_of_lowmem = max_low_pfn << PAGE_SHIFT;
2509+
2510+ if (ramdisk_end <= end_of_lowmem) {
2511+ /*reserve_bootmem(ramdisk_image, ramdisk_size);*/
2512+ initrd_start = ramdisk_image + PAGE_OFFSET;
2513+ initrd_end = initrd_start+ramdisk_size;
2514 initrd_below_start_ok = 1;
2515- }
2516- else {
2517+ } else {
2518 printk(KERN_ERR "initrd extends beyond end of memory "
2519- "(0x%08lx > 0x%08lx)\ndisabling initrd\n",
2520- INITRD_START + INITRD_SIZE,
2521- max_low_pfn << PAGE_SHIFT);
2522+ "(0x%08lx > 0x%08lx)\ndisabling initrd\n",
2523+ ramdisk_end, end_of_lowmem);
2524 initrd_start = 0;
2525 }
2526 }
2527 #endif
2528-#ifdef CONFIG_KEXEC
2529-#ifdef CONFIG_XEN
2530- xen_machine_kexec_setup_resources();
2531-#else
2532- if (crashk_res.start != crashk_res.end)
2533- reserve_bootmem(crashk_res.start,
2534- crashk_res.end - crashk_res.start + 1);
2535-#endif
2536-#endif
2537+ reserve_crashkernel();
2538 }
2539
2540 /*
2541@@ -572,7 +612,8 @@ void __init setup_arch(char **cmdline_p)
2542 * the system table is valid. If not, then initialize normally.
2543 */
2544 #ifdef CONFIG_EFI
2545- if ((LOADER_TYPE == 0x50) && EFI_SYSTAB)
2546+ if ((boot_params.hdr.type_of_loader == 0x50) &&
2547+ boot_params.efi_info.efi_systab)
2548 efi_enabled = 1;
2549 #endif
2550
2551@@ -580,18 +621,18 @@ void __init setup_arch(char **cmdline_p)
2552 properly. Setting ROOT_DEV to default to /dev/ram0 breaks initrd.
2553 */
2554 ROOT_DEV = MKDEV(UNNAMED_MAJOR,0);
2555- screen_info = SCREEN_INFO;
2556+ screen_info = boot_params.screen_info;
2557 copy_edid();
2558- apm_info.bios = APM_BIOS_INFO;
2559- ist_info = IST_INFO;
2560- saved_videomode = VIDEO_MODE;
2561- if( SYS_DESC_TABLE.length != 0 ) {
2562- set_mca_bus(SYS_DESC_TABLE.table[3] & 0x2);
2563- machine_id = SYS_DESC_TABLE.table[0];
2564- machine_submodel_id = SYS_DESC_TABLE.table[1];
2565- BIOS_revision = SYS_DESC_TABLE.table[2];
2566+ apm_info.bios = boot_params.apm_bios_info;
2567+ ist_info = boot_params.ist_info;
2568+ saved_videomode = boot_params.hdr.vid_mode;
2569+ if( boot_params.sys_desc_table.length != 0 ) {
2570+ set_mca_bus(boot_params.sys_desc_table.table[3] & 0x2);
2571+ machine_id = boot_params.sys_desc_table.table[0];
2572+ machine_submodel_id = boot_params.sys_desc_table.table[1];
2573+ BIOS_revision = boot_params.sys_desc_table.table[2];
2574 }
2575- bootloader_type = LOADER_TYPE;
2576+ bootloader_type = boot_params.hdr.type_of_loader;
2577
2578 if (is_initial_xendomain()) {
2579 const struct dom0_vga_console_info *info =
2580@@ -606,9 +647,9 @@ void __init setup_arch(char **cmdline_p)
2581 screen_info.orig_video_isVGA = 0;
2582
2583 #ifdef CONFIG_BLK_DEV_RAM
2584- rd_image_start = RAMDISK_FLAGS & RAMDISK_IMAGE_START_MASK;
2585- rd_prompt = ((RAMDISK_FLAGS & RAMDISK_PROMPT_FLAG) != 0);
2586- rd_doload = ((RAMDISK_FLAGS & RAMDISK_LOAD_FLAG) != 0);
2587+ rd_image_start = boot_params.hdr.ram_size & RAMDISK_IMAGE_START_MASK;
2588+ rd_prompt = ((boot_params.hdr.ram_size & RAMDISK_PROMPT_FLAG) != 0);
2589+ rd_doload = ((boot_params.hdr.ram_size & RAMDISK_LOAD_FLAG) != 0);
2590 #endif
2591
2592 ARCH_SETUP
2593@@ -621,7 +662,7 @@ void __init setup_arch(char **cmdline_p)
2594
2595 copy_edd();
2596
2597- if (!MOUNT_ROOT_RDONLY)
2598+ if (!boot_params.hdr.root_flags)
2599 root_mountflags &= ~MS_RDONLY;
2600 init_mm.start_code = (unsigned long) _text;
2601 init_mm.end_code = (unsigned long) _etext;
2602@@ -633,6 +674,8 @@ void __init setup_arch(char **cmdline_p)
2603 code_resource.end = virt_to_phys(_etext)-1;
2604 data_resource.start = virt_to_phys(_etext);
2605 data_resource.end = virt_to_phys(_edata)-1;
2606+ bss_resource.start = virt_to_phys(&__bss_start);
2607+ bss_resource.end = virt_to_phys(&__bss_stop)-1;
2608
2609 if ((i = MAX_GUEST_CMDLINE) > COMMAND_LINE_SIZE)
2610 i = COMMAND_LINE_SIZE;
2611@@ -661,7 +704,7 @@ void __init setup_arch(char **cmdline_p)
2612 /*
2613 * NOTE: before this point _nobody_ is allowed to allocate
2614 * any memory using the bootmem allocator. Although the
2615- * alloctor is now initialised only the first 8Mb of the kernel
2616+ * allocator is now initialised only the first 8Mb of the kernel
2617 * virtual address space has been mapped. All allocations before
2618 * paging_init() has completed must use the alloc_bootmem_low_pages()
2619 * variant (which allocates DMA'able memory) and care must be taken
2620@@ -784,10 +827,8 @@ void __init setup_arch(char **cmdline_p)
2621 acpi_boot_table_init();
2622 #endif
2623
2624-#ifdef CONFIG_PCI
2625-#ifdef CONFIG_X86_IO_APIC
2626- check_acpi_pci(); /* Checks more than just ACPI actually */
2627-#endif
2628+#if defined(CONFIG_PCI) && !defined(CONFIG_XEN)
2629+ early_quirks();
2630 #endif
2631
2632 #ifdef CONFIG_ACPI
2633Index: head-2008-12-01/arch/x86/kernel/setup_64-xen.c
2634===================================================================
2635--- head-2008-12-01.orig/arch/x86/kernel/setup_64-xen.c 2008-12-01 11:36:47.000000000 +0100
2636+++ head-2008-12-01/arch/x86/kernel/setup_64-xen.c 2008-12-01 11:36:55.000000000 +0100
2637@@ -1,10 +1,5 @@
2638 /*
2639- * linux/arch/x86-64/kernel/setup.c
2640- *
2641 * Copyright (C) 1995 Linus Torvalds
2642- *
2643- * Nov 2001 Dave Jones <davej@suse.de>
2644- * Forked from i386 setup code.
2645 */
2646
2647 /*
2648@@ -57,13 +52,13 @@
2649 #include <asm/dma.h>
2650 #include <asm/mpspec.h>
2651 #include <asm/mmu_context.h>
2652-#include <asm/bootsetup.h>
2653 #include <asm/proto.h>
2654 #include <asm/setup.h>
2655 #include <asm/mach_apic.h>
2656 #include <asm/numa.h>
2657 #include <asm/sections.h>
2658 #include <asm/dmi.h>
2659+#include <asm/cacheflush.h>
2660 #ifdef CONFIG_XEN
2661 #include <linux/percpu.h>
2662 #include <xen/interface/physdev.h>
2663@@ -180,6 +175,12 @@ struct resource code_resource = {
2664 .end = 0,
2665 .flags = IORESOURCE_RAM,
2666 };
2667+struct resource bss_resource = {
2668+ .name = "Kernel bss",
2669+ .start = 0,
2670+ .end = 0,
2671+ .flags = IORESOURCE_RAM,
2672+};
2673
2674 #ifdef CONFIG_PROC_VMCORE
2675 /* elfcorehdr= specifies the location of elf core header
2676@@ -231,10 +232,11 @@ EXPORT_SYMBOL(edd);
2677 */
2678 static inline void copy_edd(void)
2679 {
2680- memcpy(edd.mbr_signature, EDD_MBR_SIGNATURE, sizeof(edd.mbr_signature));
2681- memcpy(edd.edd_info, EDD_BUF, sizeof(edd.edd_info));
2682- edd.mbr_signature_nr = EDD_MBR_SIG_NR;
2683- edd.edd_info_nr = EDD_NR;
2684+ memcpy(edd.mbr_signature, boot_params.edd_mbr_sig_buffer,
2685+ sizeof(edd.mbr_signature));
2686+ memcpy(edd.edd_info, boot_params.eddbuf, sizeof(edd.edd_info));
2687+ edd.mbr_signature_nr = boot_params.edd_mbr_sig_buf_entries;
2688+ edd.edd_info_nr = boot_params.eddbuf_entries;
2689 }
2690 #endif
2691 #else
2692@@ -243,6 +245,41 @@ static inline void copy_edd(void)
2693 }
2694 #endif
2695
2696+#ifdef CONFIG_KEXEC
2697+#ifndef CONFIG_XEN
2698+static void __init reserve_crashkernel(void)
2699+{
2700+ unsigned long long free_mem;
2701+ unsigned long long crash_size, crash_base;
2702+ int ret;
2703+
2704+ free_mem = ((unsigned long long)max_low_pfn - min_low_pfn) << PAGE_SHIFT;
2705+
2706+ ret = parse_crashkernel(boot_command_line, free_mem,
2707+ &crash_size, &crash_base);
2708+ if (ret == 0 && crash_size) {
2709+ if (crash_base > 0) {
2710+ printk(KERN_INFO "Reserving %ldMB of memory at %ldMB "
2711+ "for crashkernel (System RAM: %ldMB)\n",
2712+ (unsigned long)(crash_size >> 20),
2713+ (unsigned long)(crash_base >> 20),
2714+ (unsigned long)(free_mem >> 20));
2715+ crashk_res.start = crash_base;
2716+ crashk_res.end = crash_base + crash_size - 1;
2717+ reserve_bootmem(crash_base, crash_size);
2718+ } else
2719+ printk(KERN_INFO "crashkernel reservation failed - "
2720+ "you have to specify a base address\n");
2721+ }
2722+}
2723+#else
2724+#define reserve_crashkernel xen_machine_kexec_setup_resources
2725+#endif
2726+#else
2727+static inline void __init reserve_crashkernel(void)
2728+{}
2729+#endif
2730+
2731 #ifndef CONFIG_XEN
2732 #define EBDA_ADDR_POINTER 0x40E
2733
2734@@ -283,7 +320,7 @@ void __init setup_arch(char **cmdline_p)
2735 atomic_notifier_chain_register(&panic_notifier_list, &xen_panic_block);
2736
2737 ROOT_DEV = MKDEV(RAMDISK_MAJOR,0);
2738- screen_info = SCREEN_INFO;
2739+ screen_info = boot_params.screen_info;
2740
2741 if (is_initial_xendomain()) {
2742 const struct dom0_vga_console_info *info =
2743@@ -306,22 +343,22 @@ void __init setup_arch(char **cmdline_p)
2744 #else
2745 printk(KERN_INFO "Command line: %s\n", boot_command_line);
2746
2747- ROOT_DEV = old_decode_dev(ORIG_ROOT_DEV);
2748- screen_info = SCREEN_INFO;
2749- edid_info = EDID_INFO;
2750+ ROOT_DEV = old_decode_dev(boot_params.hdr.root_dev);
2751+ screen_info = boot_params.screen_info;
2752+ edid_info = boot_params.edid_info;
2753 #endif /* !CONFIG_XEN */
2754- saved_video_mode = SAVED_VIDEO_MODE;
2755- bootloader_type = LOADER_TYPE;
2756+ saved_video_mode = boot_params.hdr.vid_mode;
2757+ bootloader_type = boot_params.hdr.type_of_loader;
2758
2759 #ifdef CONFIG_BLK_DEV_RAM
2760- rd_image_start = RAMDISK_FLAGS & RAMDISK_IMAGE_START_MASK;
2761- rd_prompt = ((RAMDISK_FLAGS & RAMDISK_PROMPT_FLAG) != 0);
2762- rd_doload = ((RAMDISK_FLAGS & RAMDISK_LOAD_FLAG) != 0);
2763+ rd_image_start = boot_params.hdr.ram_size & RAMDISK_IMAGE_START_MASK;
2764+ rd_prompt = ((boot_params.hdr.ram_size & RAMDISK_PROMPT_FLAG) != 0);
2765+ rd_doload = ((boot_params.hdr.ram_size & RAMDISK_LOAD_FLAG) != 0);
2766 #endif
2767 setup_memory_region();
2768 copy_edd();
2769
2770- if (!MOUNT_ROOT_RDONLY)
2771+ if (!boot_params.hdr.root_flags)
2772 root_mountflags &= ~MS_RDONLY;
2773 init_mm.start_code = (unsigned long) &_text;
2774 init_mm.end_code = (unsigned long) &_etext;
2775@@ -332,6 +369,8 @@ void __init setup_arch(char **cmdline_p)
2776 code_resource.end = virt_to_phys(&_etext)-1;
2777 data_resource.start = virt_to_phys(&_etext);
2778 data_resource.end = virt_to_phys(&_edata)-1;
2779+ bss_resource.start = virt_to_phys(&__bss_start);
2780+ bss_resource.end = virt_to_phys(&__bss_stop)-1;
2781
2782 early_identify_cpu(&boot_cpu_data);
2783
2784@@ -359,6 +398,11 @@ void __init setup_arch(char **cmdline_p)
2785 if (is_initial_xendomain())
2786 dmi_scan_machine();
2787
2788+#if defined(CONFIG_SMP) && !defined(CONFIG_XEN)
2789+ /* setup to use the static apicid table during kernel startup */
2790+ x86_cpu_to_apicid_ptr = (void *)&x86_cpu_to_apicid_init;
2791+#endif
2792+
2793 /* How many end-of-memory variables you have, grandma! */
2794 max_low_pfn = end_pfn;
2795 max_pfn = end_pfn;
2796@@ -423,52 +467,37 @@ void __init setup_arch(char **cmdline_p)
2797 */
2798 acpi_reserve_bootmem();
2799 #endif
2800-#ifdef CONFIG_XEN
2801 #ifdef CONFIG_BLK_DEV_INITRD
2802+#ifdef CONFIG_XEN
2803 if (xen_start_info->mod_start) {
2804- if (INITRD_START + INITRD_SIZE <= (end_pfn << PAGE_SHIFT)) {
2805- /*reserve_bootmem_generic(INITRD_START, INITRD_SIZE);*/
2806- initrd_start = INITRD_START + PAGE_OFFSET;
2807- initrd_end = initrd_start+INITRD_SIZE;
2808+ unsigned long ramdisk_image = __pa(xen_start_info->mod_start);
2809+ unsigned long ramdisk_size = xen_start_info->mod_len;
2810+#else
2811+ if (boot_params.hdr.type_of_loader && boot_params.hdr.ramdisk_image) {
2812+ unsigned long ramdisk_image = boot_params.hdr.ramdisk_image;
2813+ unsigned long ramdisk_size = boot_params.hdr.ramdisk_size;
2814+#endif
2815+ unsigned long ramdisk_end = ramdisk_image + ramdisk_size;
2816+ unsigned long end_of_mem = end_pfn << PAGE_SHIFT;
2817+
2818+ if (ramdisk_end <= end_of_mem) {
2819+#ifndef CONFIG_XEN
2820+ reserve_bootmem_generic(ramdisk_image, ramdisk_size);
2821+#endif
2822+ initrd_start = ramdisk_image + PAGE_OFFSET;
2823+ initrd_end = initrd_start+ramdisk_size;
2824+#ifdef CONFIG_XEN
2825 initrd_below_start_ok = 1;
2826- } else {
2827- printk(KERN_ERR "initrd extends beyond end of memory "
2828- "(0x%08lx > 0x%08lx)\ndisabling initrd\n",
2829- (unsigned long)(INITRD_START + INITRD_SIZE),
2830- (unsigned long)(end_pfn << PAGE_SHIFT));
2831- initrd_start = 0;
2832- }
2833- }
2834 #endif
2835-#else /* CONFIG_XEN */
2836-#ifdef CONFIG_BLK_DEV_INITRD
2837- if (LOADER_TYPE && INITRD_START) {
2838- if (INITRD_START + INITRD_SIZE <= (end_pfn << PAGE_SHIFT)) {
2839- reserve_bootmem_generic(INITRD_START, INITRD_SIZE);
2840- initrd_start = INITRD_START + PAGE_OFFSET;
2841- initrd_end = initrd_start+INITRD_SIZE;
2842- }
2843- else {
2844+ } else {
2845 printk(KERN_ERR "initrd extends beyond end of memory "
2846- "(0x%08lx > 0x%08lx)\ndisabling initrd\n",
2847- (unsigned long)(INITRD_START + INITRD_SIZE),
2848- (unsigned long)(end_pfn << PAGE_SHIFT));
2849+ "(0x%08lx > 0x%08lx)\ndisabling initrd\n",
2850+ ramdisk_end, end_of_mem);
2851 initrd_start = 0;
2852 }
2853 }
2854 #endif
2855-#endif /* !CONFIG_XEN */
2856-#ifdef CONFIG_KEXEC
2857-#ifdef CONFIG_XEN
2858- xen_machine_kexec_setup_resources();
2859-#else
2860- if (crashk_res.start != crashk_res.end) {
2861- reserve_bootmem_generic(crashk_res.start,
2862- crashk_res.end - crashk_res.start + 1);
2863- }
2864-#endif
2865-#endif
2866-
2867+ reserve_crashkernel();
2868 paging_init();
2869 #ifdef CONFIG_X86_LOCAL_APIC
2870 /*
2871@@ -783,7 +812,7 @@ static void __init amd_detect_cmp(struct
2872 but in the same order as the HT nodeids.
2873 If that doesn't result in a usable node fall back to the
2874 path for the previous case. */
2875- int ht_nodeid = apicid - (cpu_data[0].phys_proc_id << bits);
2876+ int ht_nodeid = apicid - (cpu_data(0).phys_proc_id << bits);
2877 if (ht_nodeid >= 0 &&
2878 apicid_to_node[ht_nodeid] != NUMA_NO_NODE)
2879 node = apicid_to_node[ht_nodeid];
2880@@ -798,6 +827,39 @@ static void __init amd_detect_cmp(struct
2881 #endif
2882 }
2883
2884+#define ENABLE_C1E_MASK 0x18000000
2885+#define CPUID_PROCESSOR_SIGNATURE 1
2886+#define CPUID_XFAM 0x0ff00000
2887+#define CPUID_XFAM_K8 0x00000000
2888+#define CPUID_XFAM_10H 0x00100000
2889+#define CPUID_XFAM_11H 0x00200000
2890+#define CPUID_XMOD 0x000f0000
2891+#define CPUID_XMOD_REV_F 0x00040000
2892+
2893+#ifndef CONFIG_XEN
2894+/* AMD systems with C1E don't have a working lAPIC timer. Check for that. */
2895+static __cpuinit int amd_apic_timer_broken(void)
2896+{
2897+ u32 lo, hi;
2898+ u32 eax = cpuid_eax(CPUID_PROCESSOR_SIGNATURE);
2899+ switch (eax & CPUID_XFAM) {
2900+ case CPUID_XFAM_K8:
2901+ if ((eax & CPUID_XMOD) < CPUID_XMOD_REV_F)
2902+ break;
2903+ case CPUID_XFAM_10H:
2904+ case CPUID_XFAM_11H:
2905+ rdmsr(MSR_K8_ENABLE_C1E, lo, hi);
2906+ if (lo & ENABLE_C1E_MASK)
2907+ return 1;
2908+ break;
2909+ default:
2910+ /* err on the side of caution */
2911+ return 1;
2912+ }
2913+ return 0;
2914+}
2915+#endif
2916+
2917 static void __cpuinit init_amd(struct cpuinfo_x86 *c)
2918 {
2919 unsigned level;
2920@@ -827,7 +889,7 @@ static void __cpuinit init_amd(struct cp
2921 level = cpuid_eax(1);
2922 if (c->x86 == 15 && ((level >= 0x0f48 && level < 0x0f50) || level >= 0x0f58))
2923 set_bit(X86_FEATURE_REP_GOOD, &c->x86_capability);
2924- if (c->x86 == 0x10)
2925+ if (c->x86 == 0x10 || c->x86 == 0x11)
2926 set_bit(X86_FEATURE_REP_GOOD, &c->x86_capability);
2927
2928 /* Enable workaround for FXSAVE leak */
2929@@ -869,6 +931,11 @@ static void __cpuinit init_amd(struct cp
2930 /* Family 10 doesn't support C states in MWAIT so don't use it */
2931 if (c->x86 == 0x10 && !force_mwait)
2932 clear_bit(X86_FEATURE_MWAIT, &c->x86_capability);
2933+
2934+#ifndef CONFIG_XEN
2935+ if (amd_apic_timer_broken())
2936+ disable_apic_timer = 1;
2937+#endif
2938 }
2939
2940 static void __cpuinit detect_ht(struct cpuinfo_x86 *c)
2941@@ -1179,6 +1246,7 @@ void __cpuinit print_cpu_info(struct cpu
2942 static int show_cpuinfo(struct seq_file *m, void *v)
2943 {
2944 struct cpuinfo_x86 *c = v;
2945+ int cpu = 0;
2946
2947 /*
2948 * These flag bits must match the definitions in <asm/cpufeature.h>.
2949@@ -1188,7 +1256,7 @@ static int show_cpuinfo(struct seq_file
2950 * applications want to get the raw CPUID data, they should access
2951 * /dev/cpu/<cpu_nr>/cpuid instead.
2952 */
2953- static char *x86_cap_flags[] = {
2954+ static const char *const x86_cap_flags[] = {
2955 /* Intel-defined */
2956 "fpu", "vme", "de", "pse", "tsc", "msr", "pae", "mce",
2957 "cx8", "apic", NULL, "sep", "mtrr", "pge", "mca", "cmov",
2958@@ -1219,7 +1287,7 @@ static int show_cpuinfo(struct seq_file
2959 /* Intel-defined (#2) */
2960 "pni", NULL, NULL, "monitor", "ds_cpl", "vmx", "smx", "est",
2961 "tm2", "ssse3", "cid", NULL, NULL, "cx16", "xtpr", NULL,
2962- NULL, NULL, "dca", NULL, NULL, NULL, NULL, "popcnt",
2963+ NULL, NULL, "dca", "sse4_1", "sse4_2", NULL, NULL, "popcnt",
2964 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
2965
2966 /* VIA/Cyrix/Centaur-defined */
2967@@ -1229,10 +1297,10 @@ static int show_cpuinfo(struct seq_file
2968 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
2969
2970 /* AMD-defined (#2) */
2971- "lahf_lm", "cmp_legacy", "svm", "extapic", "cr8_legacy",
2972- "altmovcr8", "abm", "sse4a",
2973- "misalignsse", "3dnowprefetch",
2974- "osvw", "ibs", NULL, NULL, NULL, NULL,
2975+ "lahf_lm", "cmp_legacy", "svm", "extapic",
2976+ "cr8_legacy", "abm", "sse4a", "misalignsse",
2977+ "3dnowprefetch", "osvw", "ibs", "sse5",
2978+ "skinit", "wdt", NULL, NULL,
2979 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
2980 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
2981
2982@@ -1242,7 +1310,7 @@ static int show_cpuinfo(struct seq_file
2983 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
2984 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
2985 };
2986- static char *x86_power_flags[] = {
2987+ static const char *const x86_power_flags[] = {
2988 "ts", /* temperature sensor */
2989 "fid", /* frequency id control */
2990 "vid", /* voltage id control */
2991@@ -1257,8 +1325,7 @@ static int show_cpuinfo(struct seq_file
2992
2993
2994 #ifdef CONFIG_SMP
2995- if (!cpu_online(c-cpu_data))
2996- return 0;
2997+ cpu = c->cpu_index;
2998 #endif
2999
3000 seq_printf(m,"processor\t: %u\n"
3001@@ -1266,7 +1333,7 @@ static int show_cpuinfo(struct seq_file
3002 "cpu family\t: %d\n"
3003 "model\t\t: %d\n"
3004 "model name\t: %s\n",
3005- (unsigned)(c-cpu_data),
3006+ (unsigned)cpu,
3007 c->x86_vendor_id[0] ? c->x86_vendor_id : "unknown",
3008 c->x86,
3009 (int)c->x86_model,
3010@@ -1278,7 +1345,7 @@ static int show_cpuinfo(struct seq_file
3011 seq_printf(m, "stepping\t: unknown\n");
3012
3013 if (cpu_has(c,X86_FEATURE_TSC)) {
3014- unsigned int freq = cpufreq_quick_get((unsigned)(c-cpu_data));
3015+ unsigned int freq = cpufreq_quick_get((unsigned)cpu);
3016 if (!freq)
3017 freq = cpu_khz;
3018 seq_printf(m, "cpu MHz\t\t: %u.%03u\n",
3019@@ -1291,9 +1358,9 @@ static int show_cpuinfo(struct seq_file
3020
3021 #ifdef CONFIG_SMP
3022 if (smp_num_siblings * c->x86_max_cores > 1) {
3023- int cpu = c - cpu_data;
3024 seq_printf(m, "physical id\t: %d\n", c->phys_proc_id);
3025- seq_printf(m, "siblings\t: %d\n", cpus_weight(cpu_core_map[cpu]));
3026+ seq_printf(m, "siblings\t: %d\n",
3027+ cpus_weight(per_cpu(cpu_core_map, cpu)));
3028 seq_printf(m, "core id\t\t: %d\n", c->cpu_core_id);
3029 seq_printf(m, "cpu cores\t: %d\n", c->booted_cores);
3030 }
3031@@ -1348,12 +1415,16 @@ static int show_cpuinfo(struct seq_file
3032
3033 static void *c_start(struct seq_file *m, loff_t *pos)
3034 {
3035- return *pos < NR_CPUS ? cpu_data + *pos : NULL;
3036+ if (*pos == 0) /* just in case, cpu 0 is not the first */
3037+ *pos = first_cpu(cpu_online_map);
3038+ if ((*pos) < NR_CPUS && cpu_online(*pos))
3039+ return &cpu_data(*pos);
3040+ return NULL;
3041 }
3042
3043 static void *c_next(struct seq_file *m, void *v, loff_t *pos)
3044 {
3045- ++*pos;
3046+ *pos = next_cpu(*pos, cpu_online_map);
3047 return c_start(m, pos);
3048 }
3049
3050Index: head-2008-12-01/arch/x86/kernel/smp_32-xen.c
3051===================================================================
3052--- head-2008-12-01.orig/arch/x86/kernel/smp_32-xen.c 2008-12-01 11:36:47.000000000 +0100
3053+++ head-2008-12-01/arch/x86/kernel/smp_32-xen.c 2008-12-01 11:36:55.000000000 +0100
3054@@ -72,7 +72,7 @@
3055 *
3056 * B stepping CPUs may hang. There are hardware work arounds
3057 * for this. We warn about it in case your board doesn't have the work
3058- * arounds. Basically thats so I can tell anyone with a B stepping
3059+ * arounds. Basically that's so I can tell anyone with a B stepping
3060 * CPU and SMP problems "tough".
3061 *
3062 * Specific items [From Pentium Processor Specification Update]
3063@@ -241,7 +241,7 @@ void leave_mm(unsigned long cpu)
3064 * 1a1) cpu_clear(cpu, old_mm->cpu_vm_mask);
3065 * Stop ipi delivery for the old mm. This is not synchronized with
3066 * the other cpus, but smp_invalidate_interrupt ignore flush ipis
3067- * for the wrong mm, and in the worst case we perform a superflous
3068+ * for the wrong mm, and in the worst case we perform a superfluous
3069 * tlb flush.
3070 * 1a2) set cpu_tlbstate to TLBSTATE_OK
3071 * Now the smp_invalidate_interrupt won't call leave_mm if cpu0
3072@@ -309,6 +309,7 @@ irqreturn_t smp_invalidate_interrupt(int
3073 smp_mb__after_clear_bit();
3074 out:
3075 put_cpu_no_resched();
3076+ __get_cpu_var(irq_stat).irq_tlb_count++;
3077
3078 return IRQ_HANDLED;
3079 }
3080@@ -580,7 +581,7 @@ static void stop_this_cpu (void * dummy)
3081 */
3082 cpu_clear(smp_processor_id(), cpu_online_map);
3083 disable_all_local_evtchn();
3084- if (cpu_data[smp_processor_id()].hlt_works_ok)
3085+ if (cpu_data(smp_processor_id()).hlt_works_ok)
3086 for(;;) halt();
3087 for (;;);
3088 }
3089@@ -610,6 +611,7 @@ void xen_smp_send_stop(void)
3090 */
3091 irqreturn_t smp_reschedule_interrupt(int irq, void *dev_id)
3092 {
3093+ __get_cpu_var(irq_stat).irq_resched_count++;
3094
3095 return IRQ_HANDLED;
3096 }
3097@@ -632,6 +634,7 @@ irqreturn_t smp_call_function_interrupt(
3098 */
3099 irq_enter();
3100 (*func)(info);
3101+ __get_cpu_var(irq_stat).irq_call_count++;
3102 irq_exit();
3103
3104 if (wait) {
3105Index: head-2008-12-01/arch/x86/kernel/smp_64-xen.c
3106===================================================================
3107--- head-2008-12-01.orig/arch/x86/kernel/smp_64-xen.c 2008-12-01 11:36:47.000000000 +0100
3108+++ head-2008-12-01/arch/x86/kernel/smp_64-xen.c 2008-12-01 11:36:55.000000000 +0100
3109@@ -167,6 +167,7 @@ asmlinkage void smp_invalidate_interrupt
3110 out:
3111 ack_APIC_irq();
3112 cpu_clear(cpu, f->flush_cpumask);
3113+ add_pda(irq_tlb_count, 1);
3114 }
3115
3116 static void flush_tlb_others(cpumask_t cpumask, struct mm_struct *mm,
3117@@ -326,17 +327,27 @@ void unlock_ipi_call_lock(void)
3118 }
3119
3120 /*
3121- * this function sends a 'generic call function' IPI to one other CPU
3122- * in the system.
3123- *
3124- * cpu is a standard Linux logical CPU number.
3125+ * this function sends a 'generic call function' IPI to all other CPU
3126+ * of the system defined in the mask.
3127 */
3128-static void
3129-__smp_call_function_single(int cpu, void (*func) (void *info), void *info,
3130- int nonatomic, int wait)
3131+
3132+static int
3133+__smp_call_function_mask(cpumask_t mask,
3134+ void (*func)(void *), void *info,
3135+ int wait)
3136 {
3137 struct call_data_struct data;
3138- int cpus = 1;
3139+ cpumask_t allbutself;
3140+ int cpus;
3141+
3142+ allbutself = cpu_online_map;
3143+ cpu_clear(smp_processor_id(), allbutself);
3144+
3145+ cpus_and(mask, mask, allbutself);
3146+ cpus = cpus_weight(mask);
3147+
3148+ if (!cpus)
3149+ return 0;
3150
3151 data.func = func;
3152 data.info = info;
3153@@ -347,19 +358,55 @@ __smp_call_function_single(int cpu, void
3154
3155 call_data = &data;
3156 wmb();
3157- /* Send a message to all other CPUs and wait for them to respond */
3158- send_IPI_mask(cpumask_of_cpu(cpu), CALL_FUNCTION_VECTOR);
3159+
3160+ /* Send a message to other CPUs */
3161+ if (cpus_equal(mask, allbutself))
3162+ send_IPI_allbutself(CALL_FUNCTION_VECTOR);
3163+ else
3164+ send_IPI_mask(mask, CALL_FUNCTION_VECTOR);
3165
3166 /* Wait for response */
3167 while (atomic_read(&data.started) != cpus)
3168 cpu_relax();
3169
3170 if (!wait)
3171- return;
3172+ return 0;
3173
3174 while (atomic_read(&data.finished) != cpus)
3175 cpu_relax();
3176+
3177+ return 0;
3178+}
3179+/**
3180+ * smp_call_function_mask(): Run a function on a set of other CPUs.
3181+ * @mask: The set of cpus to run on. Must not include the current cpu.
3182+ * @func: The function to run. This must be fast and non-blocking.
3183+ * @info: An arbitrary pointer to pass to the function.
3184+ * @wait: If true, wait (atomically) until function has completed on other CPUs.
3185+ *
3186+ * Returns 0 on success, else a negative status code.
3187+ *
3188+ * If @wait is true, then returns once @func has returned; otherwise
3189+ * it returns just before the target cpu calls @func.
3190+ *
3191+ * You must not call this function with disabled interrupts or from a
3192+ * hardware interrupt handler or from a bottom half handler.
3193+ */
3194+int smp_call_function_mask(cpumask_t mask,
3195+ void (*func)(void *), void *info,
3196+ int wait)
3197+{
3198+ int ret;
3199+
3200+ /* Can deadlock when called with interrupts disabled */
3201+ WARN_ON(irqs_disabled());
3202+
3203+ spin_lock(&call_lock);
3204+ ret = __smp_call_function_mask(mask, func, info, wait);
3205+ spin_unlock(&call_lock);
3206+ return ret;
3207 }
3208+EXPORT_SYMBOL(smp_call_function_mask);
3209
3210 /*
3211 * smp_call_function_single - Run a function on a specific CPU
3212@@ -378,6 +425,7 @@ int smp_call_function_single (int cpu, v
3213 int nonatomic, int wait)
3214 {
3215 /* prevent preemption and reschedule on another processor */
3216+ int ret;
3217 int me = get_cpu();
3218
3219 /* Can deadlock when called with interrupts disabled */
3220@@ -391,51 +439,14 @@ int smp_call_function_single (int cpu, v
3221 return 0;
3222 }
3223
3224- spin_lock(&call_lock);
3225- __smp_call_function_single(cpu, func, info, nonatomic, wait);
3226- spin_unlock(&call_lock);
3227+ ret = smp_call_function_mask(cpumask_of_cpu(cpu), func, info, wait);
3228+
3229 put_cpu();
3230- return 0;
3231+ return ret;
3232 }
3233 EXPORT_SYMBOL(smp_call_function_single);
3234
3235 /*
3236- * this function sends a 'generic call function' IPI to all other CPUs
3237- * in the system.
3238- */
3239-static void __smp_call_function (void (*func) (void *info), void *info,
3240- int nonatomic, int wait)
3241-{
3242- struct call_data_struct data;
3243- int cpus = num_online_cpus()-1;
3244-
3245- if (!cpus)
3246- return;
3247-
3248- data.func = func;
3249- data.info = info;
3250- atomic_set(&data.started, 0);
3251- data.wait = wait;
3252- if (wait)
3253- atomic_set(&data.finished, 0);
3254-
3255- call_data = &data;
3256- wmb();
3257- /* Send a message to all other CPUs and wait for them to respond */
3258- send_IPI_allbutself(CALL_FUNCTION_VECTOR);
3259-
3260- /* Wait for response */
3261- while (atomic_read(&data.started) != cpus)
3262- cpu_relax();
3263-
3264- if (!wait)
3265- return;
3266-
3267- while (atomic_read(&data.finished) != cpus)
3268- cpu_relax();
3269-}
3270-
3271-/*
3272 * smp_call_function - run a function on all other CPUs.
3273 * @func: The function to run. This must be fast and non-blocking.
3274 * @info: An arbitrary pointer to pass to the function.
3275@@ -453,10 +464,7 @@ static void __smp_call_function (void (*
3276 int smp_call_function (void (*func) (void *info), void *info, int nonatomic,
3277 int wait)
3278 {
3279- spin_lock(&call_lock);
3280- __smp_call_function(func,info,nonatomic,wait);
3281- spin_unlock(&call_lock);
3282- return 0;
3283+ return smp_call_function_mask(cpu_online_map, func, info, wait);
3284 }
3285 EXPORT_SYMBOL(smp_call_function);
3286
3287@@ -485,7 +493,7 @@ void smp_send_stop(void)
3288 /* Don't deadlock on the call lock in panic */
3289 nolock = !spin_trylock(&call_lock);
3290 local_irq_save(flags);
3291- __smp_call_function(stop_this_cpu, NULL, 0, 0);
3292+ __smp_call_function_mask(cpu_online_map, stop_this_cpu, NULL, 0);
3293 if (!nolock)
3294 spin_unlock(&call_lock);
3295 disable_all_local_evtchn();
3296@@ -505,7 +513,9 @@ asmlinkage irqreturn_t smp_reschedule_in
3297 {
3298 #ifndef CONFIG_XEN
3299 ack_APIC_irq();
3300-#else
3301+#endif
3302+ add_pda(irq_resched_count, 1);
3303+#ifdef CONFIG_XEN
3304 return IRQ_HANDLED;
3305 #endif
3306 }
3307@@ -535,6 +545,7 @@ asmlinkage irqreturn_t smp_call_function
3308 exit_idle();
3309 irq_enter();
3310 (*func)(info);
3311+ add_pda(irq_call_count, 1);
3312 irq_exit();
3313 if (wait) {
3314 mb();
3315Index: head-2008-12-01/arch/x86/kernel/time_32-xen.c
3316===================================================================
3317--- head-2008-12-01.orig/arch/x86/kernel/time_32-xen.c 2008-12-01 11:36:47.000000000 +0100
3318+++ head-2008-12-01/arch/x86/kernel/time_32-xen.c 2008-12-01 11:36:55.000000000 +0100
3319@@ -1,6 +1,4 @@
3320 /*
3321- * linux/arch/i386/kernel/time.c
3322- *
3323 * Copyright (C) 1991, 1992, 1995 Linus Torvalds
3324 *
3325 * This file contains the PC-specific time handling details:
3326@@ -74,6 +72,7 @@
3327 #include <asm/arch_hooks.h>
3328
3329 #include <xen/evtchn.h>
3330+#include <xen/sysctl.h>
3331 #include <xen/interface/vcpu.h>
3332
3333 #include <asm/i8253.h>
3334@@ -546,6 +545,13 @@ irqreturn_t timer_interrupt(int irq, voi
3335 struct shadow_time_info *shadow = &per_cpu(shadow_time, cpu);
3336 struct vcpu_runstate_info runstate;
3337
3338+ /* Keep nmi watchdog up to date */
3339+#ifdef __i386__
3340+ per_cpu(irq_stat, smp_processor_id()).irq0_irqs++;
3341+#else
3342+ add_pda(irq0_irqs, 1);
3343+#endif
3344+
3345 /*
3346 * Here we are in the timer irq handler. We just have irqs locally
3347 * disabled but we don't know if the timer_bh is running on the other
3348@@ -996,7 +1002,7 @@ static int time_cpufreq_notifier(struct
3349 struct cpufreq_freqs *freq = data;
3350 struct xen_platform_op op;
3351
3352- if (cpu_has(&cpu_data[freq->cpu], X86_FEATURE_CONSTANT_TSC))
3353+ if (cpu_has(&cpu_data(freq->cpu), X86_FEATURE_CONSTANT_TSC))
3354 return 0;
3355
3356 if (val == CPUFREQ_PRECHANGE)
3357@@ -1034,30 +1040,33 @@ core_initcall(cpufreq_time_setup);
3358 */
3359 static ctl_table xen_subtable[] = {
3360 {
3361- .ctl_name = 1,
3362+ .ctl_name = CTL_XEN_INDEPENDENT_WALLCLOCK,
3363 .procname = "independent_wallclock",
3364 .data = &independent_wallclock,
3365 .maxlen = sizeof(independent_wallclock),
3366 .mode = 0644,
3367+ .strategy = sysctl_data,
3368 .proc_handler = proc_dointvec
3369 },
3370 {
3371- .ctl_name = 2,
3372+ .ctl_name = CTL_XEN_PERMITTED_CLOCK_JITTER,
3373 .procname = "permitted_clock_jitter",
3374 .data = &permitted_clock_jitter,
3375 .maxlen = sizeof(permitted_clock_jitter),
3376 .mode = 0644,
3377+ .strategy = sysctl_data,
3378 .proc_handler = proc_doulongvec_minmax
3379 },
3380- { 0 }
3381+ { }
3382 };
3383 static ctl_table xen_table[] = {
3384 {
3385- .ctl_name = 123,
3386+ .ctl_name = CTL_XEN,
3387 .procname = "xen",
3388 .mode = 0555,
3389- .child = xen_subtable},
3390- { 0 }
3391+ .child = xen_subtable
3392+ },
3393+ { }
3394 };
3395 static int __init xen_sysctl_init(void)
3396 {
3397Index: head-2008-12-01/arch/x86/kernel/traps_32-xen.c
3398===================================================================
3399--- head-2008-12-01.orig/arch/x86/kernel/traps_32-xen.c 2008-12-01 11:36:47.000000000 +0100
3400+++ head-2008-12-01/arch/x86/kernel/traps_32-xen.c 2008-12-01 11:36:55.000000000 +0100
3401@@ -1,6 +1,4 @@
3402 /*
3403- * linux/arch/i386/traps.c
3404- *
3405 * Copyright (C) 1991, 1992 Linus Torvalds
3406 *
3407 * Pentium III FXSR, SSE support
3408@@ -65,6 +63,11 @@
3409
3410 int panic_on_unrecovered_nmi;
3411
3412+#ifndef CONFIG_XEN
3413+DECLARE_BITMAP(used_vectors, NR_VECTORS);
3414+EXPORT_SYMBOL_GPL(used_vectors);
3415+#endif
3416+
3417 asmlinkage int system_call(void);
3418
3419 /* Do we ignore FPU interrupts ? */
3420@@ -120,7 +123,7 @@ struct stack_frame {
3421
3422 static inline unsigned long print_context_stack(struct thread_info *tinfo,
3423 unsigned long *stack, unsigned long ebp,
3424- struct stacktrace_ops *ops, void *data)
3425+ const struct stacktrace_ops *ops, void *data)
3426 {
3427 #ifdef CONFIG_FRAME_POINTER
3428 struct stack_frame *frame = (struct stack_frame *)ebp;
3429@@ -157,7 +160,7 @@ static inline unsigned long print_contex
3430
3431 void dump_trace(struct task_struct *task, struct pt_regs *regs,
3432 unsigned long *stack,
3433- struct stacktrace_ops *ops, void *data)
3434+ const struct stacktrace_ops *ops, void *data)
3435 {
3436 unsigned long ebp = 0;
3437
3438@@ -229,7 +232,7 @@ static void print_trace_address(void *da
3439 touch_nmi_watchdog();
3440 }
3441
3442-static struct stacktrace_ops print_trace_ops = {
3443+static const struct stacktrace_ops print_trace_ops = {
3444 .warning = print_trace_warning,
3445 .warning_symbol = print_trace_warning_symbol,
3446 .stack = print_trace_stack,
3447@@ -288,6 +291,11 @@ void dump_stack(void)
3448 {
3449 unsigned long stack;
3450
3451+ printk("Pid: %d, comm: %.20s %s %s %.*s\n",
3452+ current->pid, current->comm, print_tainted(),
3453+ init_utsname()->release,
3454+ (int)strcspn(init_utsname()->version, " "),
3455+ init_utsname()->version);
3456 show_trace(current, NULL, &stack);
3457 }
3458
3459@@ -296,48 +304,24 @@ EXPORT_SYMBOL(dump_stack);
3460 void show_registers(struct pt_regs *regs)
3461 {
3462 int i;
3463- int in_kernel = 1;
3464- unsigned long esp;
3465- unsigned short ss, gs;
3466-
3467- esp = (unsigned long) (&regs->esp);
3468- savesegment(ss, ss);
3469- savesegment(gs, gs);
3470- if (user_mode_vm(regs)) {
3471- in_kernel = 0;
3472- esp = regs->esp;
3473- ss = regs->xss & 0xffff;
3474- }
3475+
3476 print_modules();
3477- printk(KERN_EMERG "CPU: %d\n"
3478- KERN_EMERG "EIP: %04x:[<%08lx>] %s VLI\n"
3479- KERN_EMERG "EFLAGS: %08lx (%s %.*s)\n",
3480- smp_processor_id(), 0xffff & regs->xcs, regs->eip,
3481- print_tainted(), regs->eflags, init_utsname()->release,
3482- (int)strcspn(init_utsname()->version, " "),
3483- init_utsname()->version);
3484- print_symbol(KERN_EMERG "EIP is at %s\n", regs->eip);
3485- printk(KERN_EMERG "eax: %08lx ebx: %08lx ecx: %08lx edx: %08lx\n",
3486- regs->eax, regs->ebx, regs->ecx, regs->edx);
3487- printk(KERN_EMERG "esi: %08lx edi: %08lx ebp: %08lx esp: %08lx\n",
3488- regs->esi, regs->edi, regs->ebp, esp);
3489- printk(KERN_EMERG "ds: %04x es: %04x fs: %04x gs: %04x ss: %04x\n",
3490- regs->xds & 0xffff, regs->xes & 0xffff, regs->xfs & 0xffff, gs, ss);
3491+ __show_registers(regs, 0);
3492 printk(KERN_EMERG "Process %.*s (pid: %d, ti=%p task=%p task.ti=%p)",
3493- TASK_COMM_LEN, current->comm, current->pid,
3494+ TASK_COMM_LEN, current->comm, task_pid_nr(current),
3495 current_thread_info(), current, task_thread_info(current));
3496 /*
3497 * When in-kernel, we also print out the stack and code at the
3498 * time of the fault..
3499 */
3500- if (in_kernel) {
3501+ if (!user_mode_vm(regs)) {
3502 u8 *eip;
3503 unsigned int code_prologue = code_bytes * 43 / 64;
3504 unsigned int code_len = code_bytes;
3505 unsigned char c;
3506
3507 printk("\n" KERN_EMERG "Stack: ");
3508- show_stack_log_lvl(NULL, regs, (unsigned long *)esp, KERN_EMERG);
3509+ show_stack_log_lvl(NULL, regs, &regs->esp, KERN_EMERG);
3510
3511 printk(KERN_EMERG "Code: ");
3512
3513@@ -382,11 +366,11 @@ int is_valid_bugaddr(unsigned long eip)
3514 void die(const char * str, struct pt_regs * regs, long err)
3515 {
3516 static struct {
3517- spinlock_t lock;
3518+ raw_spinlock_t lock;
3519 u32 lock_owner;
3520 int lock_owner_depth;
3521 } die = {
3522- .lock = __SPIN_LOCK_UNLOCKED(die.lock),
3523+ .lock = __RAW_SPIN_LOCK_UNLOCKED,
3524 .lock_owner = -1,
3525 .lock_owner_depth = 0
3526 };
3527@@ -397,40 +381,33 @@ void die(const char * str, struct pt_reg
3528
3529 if (die.lock_owner != raw_smp_processor_id()) {
3530 console_verbose();
3531- spin_lock_irqsave(&die.lock, flags);
3532+ raw_local_irq_save(flags);
3533+ __raw_spin_lock(&die.lock);
3534 die.lock_owner = smp_processor_id();
3535 die.lock_owner_depth = 0;
3536 bust_spinlocks(1);
3537- }
3538- else
3539- local_save_flags(flags);
3540+ } else
3541+ raw_local_irq_save(flags);
3542
3543 if (++die.lock_owner_depth < 3) {
3544- int nl = 0;
3545 unsigned long esp;
3546 unsigned short ss;
3547
3548 report_bug(regs->eip, regs);
3549
3550- printk(KERN_EMERG "%s: %04lx [#%d]\n", str, err & 0xffff, ++die_counter);
3551+ printk(KERN_EMERG "%s: %04lx [#%d] ", str, err & 0xffff,
3552+ ++die_counter);
3553 #ifdef CONFIG_PREEMPT
3554- printk(KERN_EMERG "PREEMPT ");
3555- nl = 1;
3556+ printk("PREEMPT ");
3557 #endif
3558 #ifdef CONFIG_SMP
3559- if (!nl)
3560- printk(KERN_EMERG);
3561 printk("SMP ");
3562- nl = 1;
3563 #endif
3564 #ifdef CONFIG_DEBUG_PAGEALLOC
3565- if (!nl)
3566- printk(KERN_EMERG);
3567 printk("DEBUG_PAGEALLOC");
3568- nl = 1;
3569 #endif
3570- if (nl)
3571- printk("\n");
3572+ printk("\n");
3573+
3574 if (notify_die(DIE_OOPS, str, regs, err,
3575 current->thread.trap_no, SIGSEGV) !=
3576 NOTIFY_STOP) {
3577@@ -454,7 +431,8 @@ void die(const char * str, struct pt_reg
3578 bust_spinlocks(0);
3579 die.lock_owner = -1;
3580 add_taint(TAINT_DIE);
3581- spin_unlock_irqrestore(&die.lock, flags);
3582+ __raw_spin_unlock(&die.lock);
3583+ raw_local_irq_restore(flags);
3584
3585 if (!regs)
3586 return;
3587@@ -571,6 +549,7 @@ fastcall void do_##name(struct pt_regs *
3588 info.si_errno = 0; \
3589 info.si_code = sicode; \
3590 info.si_addr = (void __user *)siaddr; \
3591+ trace_hardirqs_fixup(); \
3592 if (notify_die(DIE_TRAP, str, regs, error_code, trapnr, signr) \
3593 == NOTIFY_STOP) \
3594 return; \
3595@@ -606,7 +585,7 @@ fastcall void __kprobes do_general_prote
3596 printk_ratelimit())
3597 printk(KERN_INFO
3598 "%s[%d] general protection eip:%lx esp:%lx error:%lx\n",
3599- current->comm, current->pid,
3600+ current->comm, task_pid_nr(current),
3601 regs->eip, regs->esp, error_code);
3602
3603 force_sig(SIGSEGV, current);
3604@@ -785,6 +764,8 @@ void restart_nmi(void)
3605 #ifdef CONFIG_KPROBES
3606 fastcall void __kprobes do_int3(struct pt_regs *regs, long error_code)
3607 {
3608+ trace_hardirqs_fixup();
3609+
3610 if (notify_die(DIE_INT3, "int3", regs, error_code, 3, SIGTRAP)
3611 == NOTIFY_STOP)
3612 return;
3613@@ -822,6 +803,8 @@ fastcall void __kprobes do_debug(struct
3614 unsigned int condition;
3615 struct task_struct *tsk = current;
3616
3617+ trace_hardirqs_fixup();
3618+
3619 get_debugreg(condition, 6);
3620
3621 if (notify_die(DIE_DEBUG, "debug", regs, condition, error_code,
3622@@ -1084,20 +1067,6 @@ asmlinkage void math_emulate(long arg)
3623
3624 #endif /* CONFIG_MATH_EMULATION */
3625
3626-#ifdef CONFIG_X86_F00F_BUG
3627-void __init trap_init_f00f_bug(void)
3628-{
3629- __set_fixmap(FIX_F00F_IDT, __pa(&idt_table), PAGE_KERNEL_RO);
3630-
3631- /*
3632- * Update the IDT descriptor and reload the IDT so that
3633- * it uses the read-only mapped virtual address.
3634- */
3635- idt_descr.address = fix_to_virt(FIX_F00F_IDT);
3636- load_idt(&idt_descr);
3637-}
3638-#endif
3639-
3640
3641 /*
3642 * NB. All these are "trap gates" (i.e. events_mask isn't set) except
3643Index: head-2008-12-01/arch/x86/kernel/traps_64-xen.c
3644===================================================================
3645--- head-2008-12-01.orig/arch/x86/kernel/traps_64-xen.c 2008-12-01 11:36:47.000000000 +0100
3646+++ head-2008-12-01/arch/x86/kernel/traps_64-xen.c 2008-12-01 11:36:55.000000000 +0100
3647@@ -1,6 +1,4 @@
3648 /*
3649- * linux/arch/x86-64/traps.c
3650- *
3651 * Copyright (C) 1991, 1992 Linus Torvalds
3652 * Copyright (C) 2000, 2001, 2002 Andi Kleen, SuSE Labs
3653 *
3654@@ -33,6 +31,7 @@
3655 #include <linux/uaccess.h>
3656 #include <linux/bug.h>
3657 #include <linux/kdebug.h>
3658+#include <linux/utsname.h>
3659
3660 #if defined(CONFIG_EDAC)
3661 #include <linux/edac.h>
3662@@ -205,7 +204,7 @@ static unsigned long *in_exception_stack
3663 #define MSG(txt) ops->warning(data, txt)
3664
3665 /*
3666- * x86-64 can have upto three kernel stacks:
3667+ * x86-64 can have up to three kernel stacks:
3668 * process stack
3669 * interrupt stack
3670 * severe exception (double fault, nmi, stack fault, debug, mce) hardware stack
3671@@ -219,7 +218,7 @@ static inline int valid_stack_ptr(struct
3672
3673 void dump_trace(struct task_struct *tsk, struct pt_regs *regs,
3674 unsigned long *stack,
3675- struct stacktrace_ops *ops, void *data)
3676+ const struct stacktrace_ops *ops, void *data)
3677 {
3678 const unsigned cpu = get_cpu();
3679 unsigned long *irqstack_end = (unsigned long*)cpu_pda(cpu)->irqstackptr;
3680@@ -340,7 +339,7 @@ static void print_trace_address(void *da
3681 printk_address(addr);
3682 }
3683
3684-static struct stacktrace_ops print_trace_ops = {
3685+static const struct stacktrace_ops print_trace_ops = {
3686 .warning = print_trace_warning,
3687 .warning_symbol = print_trace_warning_symbol,
3688 .stack = print_trace_stack,
3689@@ -404,6 +403,12 @@ void show_stack(struct task_struct *tsk,
3690 void dump_stack(void)
3691 {
3692 unsigned long dummy;
3693+
3694+ printk("Pid: %d, comm: %.20s %s %s %.*s\n",
3695+ current->pid, current->comm, print_tainted(),
3696+ init_utsname()->release,
3697+ (int)strcspn(init_utsname()->version, " "),
3698+ init_utsname()->version);
3699 show_trace(NULL, NULL, &dummy);
3700 }
3701
3702@@ -466,7 +471,7 @@ void out_of_line_bug(void)
3703 EXPORT_SYMBOL(out_of_line_bug);
3704 #endif
3705
3706-static DEFINE_SPINLOCK(die_lock);
3707+static raw_spinlock_t die_lock = __RAW_SPIN_LOCK_UNLOCKED;
3708 static int die_owner = -1;
3709 static unsigned int die_nest_count;
3710
3711@@ -478,13 +483,13 @@ unsigned __kprobes long oops_begin(void)
3712 oops_enter();
3713
3714 /* racy, but better than risking deadlock. */
3715- local_irq_save(flags);
3716+ raw_local_irq_save(flags);
3717 cpu = smp_processor_id();
3718- if (!spin_trylock(&die_lock)) {
3719+ if (!__raw_spin_trylock(&die_lock)) {
3720 if (cpu == die_owner)
3721 /* nested oops. should stop eventually */;
3722 else
3723- spin_lock(&die_lock);
3724+ __raw_spin_lock(&die_lock);
3725 }
3726 die_nest_count++;
3727 die_owner = cpu;
3728@@ -498,12 +503,10 @@ void __kprobes oops_end(unsigned long fl
3729 die_owner = -1;
3730 bust_spinlocks(0);
3731 die_nest_count--;
3732- if (die_nest_count)
3733- /* We still own the lock */
3734- local_irq_restore(flags);
3735- else
3736+ if (!die_nest_count)
3737 /* Nest count reaches zero, release the lock. */
3738- spin_unlock_irqrestore(&die_lock, flags);
3739+ __raw_spin_unlock(&die_lock);
3740+ raw_local_irq_restore(flags);
3741 if (panic_on_oops)
3742 panic("Fatal exception");
3743 oops_exit();
3744@@ -636,6 +639,7 @@ asmlinkage void do_##name(struct pt_regs
3745 info.si_errno = 0; \
3746 info.si_code = sicode; \
3747 info.si_addr = (void __user *)siaddr; \
3748+ trace_hardirqs_fixup(); \
3749 if (notify_die(DIE_TRAP, str, regs, error_code, trapnr, signr) \
3750 == NOTIFY_STOP) \
3751 return; \
3752@@ -741,11 +745,8 @@ mem_parity_error(unsigned char reason, s
3753
3754 printk(KERN_EMERG "Dazed and confused, but trying to continue\n");
3755
3756-#if 0 /* XEN */
3757 /* Clear and disable the memory parity error line. */
3758- reason = (reason & 0xf) | 4;
3759- outb(reason, 0x61);
3760-#endif /* XEN */
3761+ clear_mem_error(reason);
3762 }
3763
3764 static __kprobes void
3765@@ -754,14 +755,8 @@ io_check_error(unsigned char reason, str
3766 printk("NMI: IOCK error (debug interrupt?)\n");
3767 show_registers(regs);
3768
3769-#if 0 /* XEN */
3770 /* Re-enable the IOCK line, wait for a few seconds */
3771- reason = (reason & 0xf) | 8;
3772- outb(reason, 0x61);
3773- mdelay(2000);
3774- reason &= ~8;
3775- outb(reason, 0x61);
3776-#endif /* XEN */
3777+ clear_io_check_error(reason);
3778 }
3779
3780 static __kprobes void
3781@@ -821,6 +816,8 @@ asmlinkage __kprobes void default_do_nmi
3782 /* runs on IST stack. */
3783 asmlinkage void __kprobes do_int3(struct pt_regs * regs, long error_code)
3784 {
3785+ trace_hardirqs_fixup();
3786+
3787 if (notify_die(DIE_INT3, "int3", regs, error_code, 3, SIGTRAP) == NOTIFY_STOP) {
3788 return;
3789 }
3790@@ -858,6 +855,8 @@ asmlinkage void __kprobes do_debug(struc
3791 struct task_struct *tsk = current;
3792 siginfo_t info;
3793
3794+ trace_hardirqs_fixup();
3795+
3796 get_debugreg(condition, 6);
3797
3798 if (notify_die(DIE_DEBUG, "debug", regs, condition, error_code,
3799Index: head-2008-12-01/arch/x86/kernel/vsyscall_64-xen.c
3800===================================================================
3801--- head-2008-12-01.orig/arch/x86/kernel/vsyscall_64-xen.c 2008-12-01 11:36:47.000000000 +0100
3802+++ head-2008-12-01/arch/x86/kernel/vsyscall_64-xen.c 2008-12-01 11:36:55.000000000 +0100
3803@@ -1,6 +1,4 @@
3804 /*
3805- * linux/arch/x86_64/kernel/vsyscall.c
3806- *
3807 * Copyright (C) 2001 Andrea Arcangeli <andrea@suse.de> SuSE
3808 * Copyright 2003 Andi Kleen, SuSE Labs.
3809 *
3810@@ -50,12 +48,12 @@
3811 ({unsigned long v; \
3812 extern char __vsyscall_0; \
3813 asm("" : "=r" (v) : "0" (x)); \
3814- ((v - VSYSCALL_FIRST_PAGE) + __pa_symbol(&__vsyscall_0)); })
3815+ ((v - VSYSCALL_START) + __pa_symbol(&__vsyscall_0)); })
3816
3817 /*
3818 * vsyscall_gtod_data contains data that is :
3819 * - readonly from vsyscalls
3820- * - writen by timer interrupt or systcl (/proc/sys/kernel/vsyscall64)
3821+ * - written by timer interrupt or systcl (/proc/sys/kernel/vsyscall64)
3822 * Try to keep this structure as small as possible to avoid cache line ping pongs
3823 */
3824 int __vgetcpu_mode __section_vgetcpu_mode;
3825@@ -66,6 +64,16 @@ struct vsyscall_gtod_data __vsyscall_gto
3826 .sysctl_enabled = 1,
3827 };
3828
3829+void update_vsyscall_tz(void)
3830+{
3831+ unsigned long flags;
3832+
3833+ write_seqlock_irqsave(&vsyscall_gtod_data.lock, flags);
3834+ /* sys_tz has changed */
3835+ vsyscall_gtod_data.sys_tz = sys_tz;
3836+ write_sequnlock_irqrestore(&vsyscall_gtod_data.lock, flags);
3837+}
3838+
3839 void update_vsyscall(struct timespec *wall_time, struct clocksource *clock)
3840 {
3841 unsigned long flags;
3842@@ -79,8 +87,6 @@ void update_vsyscall(struct timespec *wa
3843 vsyscall_gtod_data.clock.shift = clock->shift;
3844 vsyscall_gtod_data.wall_time_sec = wall_time->tv_sec;
3845 vsyscall_gtod_data.wall_time_nsec = wall_time->tv_nsec;
3846- vsyscall_gtod_data.sys_tz = sys_tz;
3847- vsyscall_gtod_data.wall_time_nsec = wall_time->tv_nsec;
3848 vsyscall_gtod_data.wall_to_monotonic = wall_to_monotonic;
3849 write_sequnlock_irqrestore(&vsyscall_gtod_data.lock, flags);
3850 }
3851@@ -166,7 +172,7 @@ time_t __vsyscall(1) vtime(time_t *t)
3852 if (unlikely(!__vsyscall_gtod_data.sysctl_enabled))
3853 return time_syscall(t);
3854
3855- vgettimeofday(&tv, 0);
3856+ vgettimeofday(&tv, NULL);
3857 result = tv.tv_sec;
3858 if (t)
3859 *t = result;
3860@@ -260,18 +266,10 @@ out:
3861 return ret;
3862 }
3863
3864-static int vsyscall_sysctl_nostrat(ctl_table *t, int __user *name, int nlen,
3865- void __user *oldval, size_t __user *oldlenp,
3866- void __user *newval, size_t newlen)
3867-{
3868- return -ENOSYS;
3869-}
3870-
3871 static ctl_table kernel_table2[] = {
3872- { .ctl_name = 99, .procname = "vsyscall64",
3873+ { .procname = "vsyscall64",
3874 .data = &vsyscall_gtod_data.sysctl_enabled, .maxlen = sizeof(int),
3875 .mode = 0644,
3876- .strategy = vsyscall_sysctl_nostrat,
3877 .proc_handler = vsyscall_sysctl_change },
3878 {}
3879 };
3880@@ -291,9 +289,9 @@ static void __cpuinit vsyscall_set_cpu(i
3881 unsigned long d;
3882 unsigned long node = 0;
3883 #ifdef CONFIG_NUMA
3884- node = cpu_to_node[cpu];
3885+ node = cpu_to_node(cpu);
3886 #endif
3887- if (cpu_has(&cpu_data[cpu], X86_FEATURE_RDTSCP))
3888+ if (cpu_has(&cpu_data(cpu), X86_FEATURE_RDTSCP))
3889 write_rdtscp_aux((node << 12) | cpu);
3890
3891 /* Store cpu number in limit so that it can be loaded quickly
3892Index: head-2008-12-01/arch/x86/mm/fault_32-xen.c
3893===================================================================
3894--- head-2008-12-01.orig/arch/x86/mm/fault_32-xen.c 2008-12-01 11:36:47.000000000 +0100
3895+++ head-2008-12-01/arch/x86/mm/fault_32-xen.c 2008-12-01 11:36:55.000000000 +0100
3896@@ -25,6 +25,7 @@
3897 #include <linux/kprobes.h>
3898 #include <linux/uaccess.h>
3899 #include <linux/kdebug.h>
3900+#include <linux/kprobes.h>
3901
3902 #include <asm/system.h>
3903 #include <asm/desc.h>
3904@@ -32,33 +33,27 @@
3905
3906 extern void die(const char *,struct pt_regs *,long);
3907
3908-static ATOMIC_NOTIFIER_HEAD(notify_page_fault_chain);
3909-
3910-int register_page_fault_notifier(struct notifier_block *nb)
3911+#ifdef CONFIG_KPROBES
3912+static inline int notify_page_fault(struct pt_regs *regs)
3913 {
3914- vmalloc_sync_all();
3915- return atomic_notifier_chain_register(&notify_page_fault_chain, nb);
3916-}
3917-EXPORT_SYMBOL_GPL(register_page_fault_notifier);
3918+ int ret = 0;
3919
3920-int unregister_page_fault_notifier(struct notifier_block *nb)
3921-{
3922- return atomic_notifier_chain_unregister(&notify_page_fault_chain, nb);
3923-}
3924-EXPORT_SYMBOL_GPL(unregister_page_fault_notifier);
3925+ /* kprobe_running() needs smp_processor_id() */
3926+ if (!user_mode_vm(regs)) {
3927+ preempt_disable();
3928+ if (kprobe_running() && kprobe_fault_handler(regs, 14))
3929+ ret = 1;
3930+ preempt_enable();
3931+ }
3932
3933-static inline int notify_page_fault(struct pt_regs *regs, long err)
3934+ return ret;
3935+}
3936+#else
3937+static inline int notify_page_fault(struct pt_regs *regs)
3938 {
3939- struct die_args args = {
3940- .regs = regs,
3941- .str = "page fault",
3942- .err = err,
3943- .trapnr = 14,
3944- .signr = SIGSEGV
3945- };
3946- return atomic_notifier_call_chain(&notify_page_fault_chain,
3947- DIE_PAGE_FAULT, &args);
3948+ return 0;
3949 }
3950+#endif
3951
3952 /*
3953 * Return EIP plus the CS segment base. The segment limit is also
3954@@ -110,7 +105,7 @@ static inline unsigned long get_segment_
3955 LDT and other horrors are only used in user space. */
3956 if (seg & (1<<2)) {
3957 /* Must lock the LDT while reading it. */
3958- down(&current->mm->context.sem);
3959+ mutex_lock(&current->mm->context.lock);
3960 desc = current->mm->context.ldt;
3961 desc = (void *)desc + (seg & ~7);
3962 } else {
3963@@ -123,7 +118,7 @@ static inline unsigned long get_segment_
3964 base = get_desc_base((unsigned long *)desc);
3965
3966 if (seg & (1<<2)) {
3967- up(&current->mm->context.sem);
3968+ mutex_unlock(&current->mm->context.lock);
3969 } else
3970 put_cpu();
3971
3972@@ -244,7 +239,7 @@ static void dump_fault_path(unsigned lon
3973 if (mfn_to_pfn(mfn) >= highstart_pfn)
3974 return;
3975 #endif
3976- if (p[0] & _PAGE_PRESENT) {
3977+ if ((p[0] & _PAGE_PRESENT) && !(p[0] & _PAGE_PSE)) {
3978 page = mfn_to_pfn(mfn) << PAGE_SHIFT;
3979 p = (unsigned long *) __va(page);
3980 address &= 0x001fffff;
3981@@ -270,7 +265,8 @@ static void dump_fault_path(unsigned lon
3982 * it's allocated already.
3983 */
3984 if ((machine_to_phys(page) >> PAGE_SHIFT) < max_low_pfn
3985- && (page & _PAGE_PRESENT)) {
3986+ && (page & _PAGE_PRESENT)
3987+ && !(page & _PAGE_PSE)) {
3988 page = machine_to_phys(page & PAGE_MASK);
3989 page = ((unsigned long *) __va(page))[(address >> PAGE_SHIFT)
3990 & (PTRS_PER_PTE - 1)];
3991@@ -416,6 +412,11 @@ fastcall void __kprobes do_page_fault(st
3992 int write, si_code;
3993 int fault;
3994
3995+ /*
3996+ * We can fault from pretty much anywhere, with unknown IRQ state.
3997+ */
3998+ trace_hardirqs_fixup();
3999+
4000 /* get the address */
4001 address = read_cr2();
4002
4003@@ -453,7 +454,7 @@ fastcall void __kprobes do_page_fault(st
4004 /* Can take a spurious fault if mapping changes R/O -> R/W. */
4005 if (spurious_fault(regs, address, error_code))
4006 return;
4007- if (notify_page_fault(regs, error_code) == NOTIFY_STOP)
4008+ if (notify_page_fault(regs))
4009 return;
4010 /*
4011 * Don't take the mm semaphore here. If we fixup a prefetch
4012@@ -462,7 +463,7 @@ fastcall void __kprobes do_page_fault(st
4013 goto bad_area_nosemaphore;
4014 }
4015
4016- if (notify_page_fault(regs, error_code) == NOTIFY_STOP)
4017+ if (notify_page_fault(regs))
4018 return;
4019
4020 /* It's safe to allow irq's after cr2 has been saved and the vmalloc
4021@@ -481,7 +482,7 @@ fastcall void __kprobes do_page_fault(st
4022
4023 /* When running in the kernel we expect faults to occur only to
4024 * addresses in user space. All other faults represent errors in the
4025- * kernel and should generate an OOPS. Unfortunatly, in the case of an
4026+ * kernel and should generate an OOPS. Unfortunately, in the case of an
4027 * erroneous fault occurring in a code path which already holds mmap_sem
4028 * we will deadlock attempting to validate the fault against the
4029 * address space. Luckily the kernel only validly references user
4030@@ -489,7 +490,7 @@ fastcall void __kprobes do_page_fault(st
4031 * exceptions table.
4032 *
4033 * As the vast majority of faults will be valid we will only perform
4034- * the source reference check when there is a possibilty of a deadlock.
4035+ * the source reference check when there is a possibility of a deadlock.
4036 * Attempt to lock the address space, if we cannot we then validate the
4037 * source. If this is invalid we can skip the address space check,
4038 * thus avoiding the deadlock.
4039@@ -598,8 +599,8 @@ bad_area_nosemaphore:
4040 printk_ratelimit()) {
4041 printk("%s%s[%d]: segfault at %08lx eip %08lx "
4042 "esp %08lx error %lx\n",
4043- tsk->pid > 1 ? KERN_INFO : KERN_EMERG,
4044- tsk->comm, tsk->pid, address, regs->eip,
4045+ task_pid_nr(tsk) > 1 ? KERN_INFO : KERN_EMERG,
4046+ tsk->comm, task_pid_nr(tsk), address, regs->eip,
4047 regs->esp, error_code);
4048 }
4049 tsk->thread.cr2 = address;
4050@@ -664,8 +665,7 @@ no_context:
4051 printk(KERN_ALERT "BUG: unable to handle kernel paging"
4052 " request");
4053 printk(" at virtual address %08lx\n",address);
4054- printk(KERN_ALERT " printing eip:\n");
4055- printk("%08lx\n", regs->eip);
4056+ printk(KERN_ALERT "printing eip: %08lx\n", regs->eip);
4057 dump_fault_path(address);
4058 }
4059 tsk->thread.cr2 = address;
4060@@ -681,14 +681,14 @@ no_context:
4061 */
4062 out_of_memory:
4063 up_read(&mm->mmap_sem);
4064- if (is_init(tsk)) {
4065+ if (is_global_init(tsk)) {
4066 yield();
4067 down_read(&mm->mmap_sem);
4068 goto survive;
4069 }
4070 printk("VM: killing process %s\n", tsk->comm);
4071 if (error_code & 4)
4072- do_exit(SIGKILL);
4073+ do_group_exit(SIGKILL);
4074 goto no_context;
4075
4076 do_sigbus:
4077Index: head-2008-12-01/arch/x86/mm/fault_64-xen.c
4078===================================================================
4079--- head-2008-12-01.orig/arch/x86/mm/fault_64-xen.c 2008-12-01 11:36:47.000000000 +0100
4080+++ head-2008-12-01/arch/x86/mm/fault_64-xen.c 2008-12-01 11:36:55.000000000 +0100
4081@@ -25,6 +25,7 @@
4082 #include <linux/kprobes.h>
4083 #include <linux/uaccess.h>
4084 #include <linux/kdebug.h>
4085+#include <linux/kprobes.h>
4086
4087 #include <asm/system.h>
4088 #include <asm/pgalloc.h>
4089@@ -40,34 +41,27 @@
4090 #define PF_RSVD (1<<3)
4091 #define PF_INSTR (1<<4)
4092
4093-static ATOMIC_NOTIFIER_HEAD(notify_page_fault_chain);
4094-
4095-/* Hook to register for page fault notifications */
4096-int register_page_fault_notifier(struct notifier_block *nb)
4097+#ifdef CONFIG_KPROBES
4098+static inline int notify_page_fault(struct pt_regs *regs)
4099 {
4100- vmalloc_sync_all();
4101- return atomic_notifier_chain_register(&notify_page_fault_chain, nb);
4102-}
4103-EXPORT_SYMBOL_GPL(register_page_fault_notifier);
4104+ int ret = 0;
4105
4106-int unregister_page_fault_notifier(struct notifier_block *nb)
4107-{
4108- return atomic_notifier_chain_unregister(&notify_page_fault_chain, nb);
4109-}
4110-EXPORT_SYMBOL_GPL(unregister_page_fault_notifier);
4111+ /* kprobe_running() needs smp_processor_id() */
4112+ if (!user_mode(regs)) {
4113+ preempt_disable();
4114+ if (kprobe_running() && kprobe_fault_handler(regs, 14))
4115+ ret = 1;
4116+ preempt_enable();
4117+ }
4118
4119-static inline int notify_page_fault(struct pt_regs *regs, long err)
4120+ return ret;
4121+}
4122+#else
4123+static inline int notify_page_fault(struct pt_regs *regs)
4124 {
4125- struct die_args args = {
4126- .regs = regs,
4127- .str = "page fault",
4128- .err = err,
4129- .trapnr = 14,
4130- .signr = SIGSEGV
4131- };
4132- return atomic_notifier_call_chain(&notify_page_fault_chain,
4133- DIE_PAGE_FAULT, &args);
4134+ return 0;
4135 }
4136+#endif
4137
4138 /* Sometimes the CPU reports invalid exceptions on prefetch.
4139 Check that here and ignore.
4140@@ -175,7 +169,7 @@ void dump_pagetable(unsigned long addres
4141 pmd = pmd_offset(pud, address);
4142 if (bad_address(pmd)) goto bad;
4143 printk("PMD %lx ", pmd_val(*pmd));
4144- if (!pmd_present(*pmd)) goto ret;
4145+ if (!pmd_present(*pmd) || pmd_large(*pmd)) goto ret;
4146
4147 pte = pte_offset_kernel(pmd, address);
4148 if (bad_address(pte)) goto bad;
4149@@ -294,7 +288,6 @@ static int vmalloc_fault(unsigned long a
4150 return 0;
4151 }
4152
4153-static int page_fault_trace;
4154 int show_unhandled_signals = 1;
4155
4156
4157@@ -371,6 +364,11 @@ asmlinkage void __kprobes do_page_fault(
4158 if (!user_mode(regs))
4159 error_code &= ~PF_USER; /* means kernel */
4160
4161+ /*
4162+ * We can fault from pretty much anywhere, with unknown IRQ state.
4163+ */
4164+ trace_hardirqs_fixup();
4165+
4166 tsk = current;
4167 mm = tsk->mm;
4168 prefetchw(&mm->mmap_sem);
4169@@ -408,7 +406,7 @@ asmlinkage void __kprobes do_page_fault(
4170 /* Can take a spurious fault if mapping changes R/O -> R/W. */
4171 if (spurious_fault(regs, address, error_code))
4172 return;
4173- if (notify_page_fault(regs, error_code) == NOTIFY_STOP)
4174+ if (notify_page_fault(regs))
4175 return;
4176 /*
4177 * Don't take the mm semaphore here. If we fixup a prefetch
4178@@ -417,16 +415,12 @@ asmlinkage void __kprobes do_page_fault(
4179 goto bad_area_nosemaphore;
4180 }
4181
4182- if (notify_page_fault(regs, error_code) == NOTIFY_STOP)
4183+ if (notify_page_fault(regs))
4184 return;
4185
4186 if (likely(regs->eflags & X86_EFLAGS_IF))
4187 local_irq_enable();
4188
4189- if (unlikely(page_fault_trace))
4190- printk("pagefault rip:%lx rsp:%lx cs:%lu ss:%lu address %lx error %lx\n",
4191- regs->rip,regs->rsp,regs->cs,regs->ss,address,error_code);
4192-
4193 if (unlikely(error_code & PF_RSVD))
4194 pgtable_bad(address, regs, error_code);
4195
4196@@ -447,7 +441,7 @@ asmlinkage void __kprobes do_page_fault(
4197 again:
4198 /* When running in the kernel we expect faults to occur only to
4199 * addresses in user space. All other faults represent errors in the
4200- * kernel and should generate an OOPS. Unfortunatly, in the case of an
4201+ * kernel and should generate an OOPS. Unfortunately, in the case of an
4202 * erroneous fault occurring in a code path which already holds mmap_sem
4203 * we will deadlock attempting to validate the fault against the
4204 * address space. Luckily the kernel only validly references user
4205@@ -455,7 +449,7 @@ asmlinkage void __kprobes do_page_fault(
4206 * exceptions table.
4207 *
4208 * As the vast majority of faults will be valid we will only perform
4209- * the source reference check when there is a possibilty of a deadlock.
4210+ * the source reference check when there is a possibility of a deadlock.
4211 * Attempt to lock the address space, if we cannot we then validate the
4212 * source. If this is invalid we can skip the address space check,
4213 * thus avoiding the deadlock.
4214@@ -557,7 +551,7 @@ bad_area_nosemaphore:
4215 if (show_unhandled_signals && unhandled_signal(tsk, SIGSEGV) &&
4216 printk_ratelimit()) {
4217 printk(
4218- "%s%s[%d]: segfault at %016lx rip %016lx rsp %016lx error %lx\n",
4219+ "%s%s[%d]: segfault at %lx rip %lx rsp %lx error %lx\n",
4220 tsk->pid > 1 ? KERN_INFO : KERN_EMERG,
4221 tsk->comm, tsk->pid, address, regs->rip,
4222 regs->rsp, error_code);
4223@@ -623,7 +617,7 @@ no_context:
4224 */
4225 out_of_memory:
4226 up_read(&mm->mmap_sem);
4227- if (is_init(current)) {
4228+ if (is_global_init(current)) {
4229 yield();
4230 goto again;
4231 }
4232@@ -690,10 +684,3 @@ void vmalloc_sync_all(void)
4233 BUILD_BUG_ON(!(((MODULES_END - 1) & PGDIR_MASK) ==
4234 (__START_KERNEL & PGDIR_MASK)));
4235 }
4236-
4237-static int __init enable_pagefaulttrace(char *str)
4238-{
4239- page_fault_trace = 1;
4240- return 1;
4241-}
4242-__setup("pagefaulttrace", enable_pagefaulttrace);
4243Index: head-2008-12-01/arch/x86/mm/init_32-xen.c
4244===================================================================
4245--- head-2008-12-01.orig/arch/x86/mm/init_32-xen.c 2008-12-01 11:36:47.000000000 +0100
4246+++ head-2008-12-01/arch/x86/mm/init_32-xen.c 2008-12-01 11:36:55.000000000 +0100
4247@@ -94,7 +94,14 @@ static pte_t * __init one_page_table_ini
4248 #else
4249 if (!(__pmd_val(*pmd) & _PAGE_PRESENT)) {
4250 #endif
4251- pte_t *page_table = (pte_t *) alloc_bootmem_low_pages(PAGE_SIZE);
4252+ pte_t *page_table = NULL;
4253+
4254+#ifdef CONFIG_DEBUG_PAGEALLOC
4255+ page_table = (pte_t *) alloc_bootmem_pages(PAGE_SIZE);
4256+#endif
4257+ if (!page_table)
4258+ page_table =
4259+ (pte_t *)alloc_bootmem_low_pages(PAGE_SIZE);
4260
4261 paravirt_alloc_pt(&init_mm, __pa(page_table) >> PAGE_SHIFT);
4262 make_lowmem_page_readonly(page_table,
4263@@ -102,7 +109,7 @@ static pte_t * __init one_page_table_ini
4264 set_pmd(pmd, __pmd(__pa(page_table) | _PAGE_TABLE));
4265 BUG_ON(page_table != pte_offset_kernel(pmd, 0));
4266 }
4267-
4268+
4269 return pte_offset_kernel(pmd, 0);
4270 }
4271
4272@@ -360,8 +367,13 @@ extern void set_highmem_pages_init(int);
4273 static void __init set_highmem_pages_init(int bad_ppro)
4274 {
4275 int pfn;
4276- for (pfn = highstart_pfn; pfn < highend_pfn; pfn++)
4277- add_one_highpage_init(pfn_to_page(pfn), pfn, bad_ppro);
4278+ for (pfn = highstart_pfn; pfn < highend_pfn; pfn++) {
4279+ /*
4280+ * Holes under sparsemem might not have no mem_map[]:
4281+ */
4282+ if (pfn_valid(pfn))
4283+ add_one_highpage_init(pfn_to_page(pfn), pfn, bad_ppro);
4284+ }
4285 totalram_pages += totalhigh_pages;
4286 }
4287 #endif /* CONFIG_FLATMEM */
4288@@ -779,35 +791,18 @@ int arch_add_memory(int nid, u64 start,
4289 return __add_pages(zone, start_pfn, nr_pages);
4290 }
4291
4292-int remove_memory(u64 start, u64 size)
4293-{
4294- return -EINVAL;
4295-}
4296-EXPORT_SYMBOL_GPL(remove_memory);
4297 #endif
4298
4299 struct kmem_cache *pmd_cache;
4300
4301 void __init pgtable_cache_init(void)
4302 {
4303- size_t pgd_size = PTRS_PER_PGD*sizeof(pgd_t);
4304-
4305- if (PTRS_PER_PMD > 1) {
4306+ if (PTRS_PER_PMD > 1)
4307 pmd_cache = kmem_cache_create("pmd",
4308- PTRS_PER_PMD*sizeof(pmd_t),
4309- PTRS_PER_PMD*sizeof(pmd_t),
4310- SLAB_PANIC,
4311- pmd_ctor);
4312- if (!SHARED_KERNEL_PMD) {
4313- /* If we're in PAE mode and have a non-shared
4314- kernel pmd, then the pgd size must be a
4315- page size. This is because the pgd_list
4316- links through the page structure, so there
4317- can only be one pgd per page for this to
4318- work. */
4319- pgd_size = PAGE_SIZE;
4320- }
4321- }
4322+ PTRS_PER_PMD*sizeof(pmd_t),
4323+ PTRS_PER_PMD*sizeof(pmd_t),
4324+ SLAB_PANIC,
4325+ pmd_ctor);
4326 }
4327
4328 /*
4329Index: head-2008-12-01/arch/x86/mm/init_64-xen.c
4330===================================================================
4331--- head-2008-12-01.orig/arch/x86/mm/init_64-xen.c 2008-12-01 11:36:47.000000000 +0100
4332+++ head-2008-12-01/arch/x86/mm/init_64-xen.c 2008-12-01 11:36:55.000000000 +0100
4333@@ -767,7 +767,7 @@ static void xen_finish_init_mapping(void
4334 /* Setup the direct mapping of the physical memory at PAGE_OFFSET.
4335 This runs before bootmem is initialized and gets pages directly from the
4336 physical memory. To access them they are temporarily mapped. */
4337-void __meminit init_memory_mapping(unsigned long start, unsigned long end)
4338+void __init_refok init_memory_mapping(unsigned long start, unsigned long end)
4339 {
4340 unsigned long next;
4341
4342@@ -901,12 +901,6 @@ error:
4343 }
4344 EXPORT_SYMBOL_GPL(arch_add_memory);
4345
4346-int remove_memory(u64 start, u64 size)
4347-{
4348- return -EINVAL;
4349-}
4350-EXPORT_SYMBOL_GPL(remove_memory);
4351-
4352 #if !defined(CONFIG_ACPI_NUMA) && defined(CONFIG_NUMA)
4353 int memory_add_physaddr_to_nid(u64 start)
4354 {
4355@@ -1175,14 +1169,6 @@ int in_gate_area_no_task(unsigned long a
4356 return (addr >= VSYSCALL_START) && (addr < VSYSCALL_END);
4357 }
4358
4359-#ifndef CONFIG_XEN
4360-void * __init alloc_bootmem_high_node(pg_data_t *pgdat, unsigned long size)
4361-{
4362- return __alloc_bootmem_core(pgdat->bdata, size,
4363- SMP_CACHE_BYTES, (4UL*1024*1024*1024), 0);
4364-}
4365-#endif
4366-
4367 const char *arch_vma_name(struct vm_area_struct *vma)
4368 {
4369 if (vma->vm_mm && vma->vm_start == (long)vma->vm_mm->context.vdso)
4370@@ -1191,3 +1177,48 @@ const char *arch_vma_name(struct vm_area
4371 return "[vsyscall]";
4372 return NULL;
4373 }
4374+
4375+#ifdef CONFIG_SPARSEMEM_VMEMMAP
4376+/*
4377+ * Initialise the sparsemem vmemmap using huge-pages at the PMD level.
4378+ */
4379+int __meminit vmemmap_populate(struct page *start_page,
4380+ unsigned long size, int node)
4381+{
4382+ unsigned long addr = (unsigned long)start_page;
4383+ unsigned long end = (unsigned long)(start_page + size);
4384+ unsigned long next;
4385+ pgd_t *pgd;
4386+ pud_t *pud;
4387+ pmd_t *pmd;
4388+
4389+ for (; addr < end; addr = next) {
4390+ next = pmd_addr_end(addr, end);
4391+
4392+ pgd = vmemmap_pgd_populate(addr, node);
4393+ if (!pgd)
4394+ return -ENOMEM;
4395+ pud = vmemmap_pud_populate(pgd, addr, node);
4396+ if (!pud)
4397+ return -ENOMEM;
4398+
4399+ pmd = pmd_offset(pud, addr);
4400+ if (pmd_none(*pmd)) {
4401+ pte_t entry;
4402+ void *p = vmemmap_alloc_block(PMD_SIZE, node);
4403+ if (!p)
4404+ return -ENOMEM;
4405+
4406+ entry = pfn_pte(__pa(p) >> PAGE_SHIFT, PAGE_KERNEL);
4407+ mk_pte_huge(entry);
4408+ set_pmd(pmd, __pmd(pte_val(entry)));
4409+
4410+ printk(KERN_DEBUG " [%lx-%lx] PMD ->%p on node %d\n",
4411+ addr, addr + PMD_SIZE - 1, p, node);
4412+ } else
4413+ vmemmap_verify((pte_t *)pmd, node, addr, next);
4414+ }
4415+
4416+ return 0;
4417+}
4418+#endif
4419Index: head-2008-12-01/arch/x86/mm/pageattr_64-xen.c
4420===================================================================
4421--- head-2008-12-01.orig/arch/x86/mm/pageattr_64-xen.c 2008-12-01 11:36:47.000000000 +0100
4422+++ head-2008-12-01/arch/x86/mm/pageattr_64-xen.c 2008-12-01 11:36:55.000000000 +0100
4423@@ -17,9 +17,6 @@
4424 #include <asm/pgalloc.h>
4425 #include <asm/mmu_context.h>
4426
4427-LIST_HEAD(mm_unpinned);
4428-DEFINE_SPINLOCK(mm_unpinned_lock);
4429-
4430 static void _pin_lock(struct mm_struct *mm, int lock) {
4431 if (lock)
4432 spin_lock(&mm->page_table_lock);
4433@@ -81,8 +78,8 @@ static void _pin_lock(struct mm_struct *
4434 #define PIN_BATCH 8
4435 static DEFINE_PER_CPU(multicall_entry_t[PIN_BATCH], pb_mcl);
4436
4437-static inline unsigned int mm_walk_set_prot(void *pt, pgprot_t flags,
4438- unsigned int cpu, unsigned int seq)
4439+static inline unsigned int pgd_walk_set_prot(void *pt, pgprot_t flags,
4440+ unsigned int cpu, unsigned int seq)
4441 {
4442 struct page *page = virt_to_page(pt);
4443 unsigned long pfn = page_to_pfn(page);
4444@@ -100,9 +97,9 @@ static inline unsigned int mm_walk_set_p
4445 return seq;
4446 }
4447
4448-static void mm_walk(struct mm_struct *mm, pgprot_t flags)
4449+static void pgd_walk(pgd_t *pgd_base, pgprot_t flags)
4450 {
4451- pgd_t *pgd;
4452+ pgd_t *pgd = pgd_base;
4453 pud_t *pud;
4454 pmd_t *pmd;
4455 pte_t *pte;
4456@@ -110,7 +107,6 @@ static void mm_walk(struct mm_struct *mm
4457 unsigned int cpu, seq;
4458 multicall_entry_t *mcl;
4459
4460- pgd = mm->pgd;
4461 cpu = get_cpu();
4462
4463 /*
4464@@ -125,18 +121,18 @@ static void mm_walk(struct mm_struct *mm
4465 continue;
4466 pud = pud_offset(pgd, 0);
4467 if (PTRS_PER_PUD > 1) /* not folded */
4468- seq = mm_walk_set_prot(pud,flags,cpu,seq);
4469+ seq = pgd_walk_set_prot(pud,flags,cpu,seq);
4470 for (u = 0; u < PTRS_PER_PUD; u++, pud++) {
4471 if (pud_none(*pud))
4472 continue;
4473 pmd = pmd_offset(pud, 0);
4474 if (PTRS_PER_PMD > 1) /* not folded */
4475- seq = mm_walk_set_prot(pmd,flags,cpu,seq);
4476+ seq = pgd_walk_set_prot(pmd,flags,cpu,seq);
4477 for (m = 0; m < PTRS_PER_PMD; m++, pmd++) {
4478 if (pmd_none(*pmd))
4479 continue;
4480 pte = pte_offset_kernel(pmd,0);
4481- seq = mm_walk_set_prot(pte,flags,cpu,seq);
4482+ seq = pgd_walk_set_prot(pte,flags,cpu,seq);
4483 }
4484 }
4485 }
4486@@ -148,12 +144,12 @@ static void mm_walk(struct mm_struct *mm
4487 seq = 0;
4488 }
4489 MULTI_update_va_mapping(mcl + seq,
4490- (unsigned long)__user_pgd(mm->pgd),
4491- pfn_pte(virt_to_phys(__user_pgd(mm->pgd))>>PAGE_SHIFT, flags),
4492+ (unsigned long)__user_pgd(pgd_base),
4493+ pfn_pte(virt_to_phys(__user_pgd(pgd_base))>>PAGE_SHIFT, flags),
4494 0);
4495 MULTI_update_va_mapping(mcl + seq + 1,
4496- (unsigned long)mm->pgd,
4497- pfn_pte(virt_to_phys(mm->pgd)>>PAGE_SHIFT, flags),
4498+ (unsigned long)pgd_base,
4499+ pfn_pte(virt_to_phys(pgd_base)>>PAGE_SHIFT, flags),
4500 UVMF_TLB_FLUSH);
4501 if (unlikely(HYPERVISOR_multicall_check(mcl, seq + 2, NULL)))
4502 BUG();
4503@@ -161,21 +157,35 @@ static void mm_walk(struct mm_struct *mm
4504 put_cpu();
4505 }
4506
4507+static void __pgd_pin(pgd_t *pgd)
4508+{
4509+ pgd_walk(pgd, PAGE_KERNEL_RO);
4510+ xen_pgd_pin(__pa(pgd)); /* kernel */
4511+ xen_pgd_pin(__pa(__user_pgd(pgd))); /* user */
4512+ SetPagePinned(virt_to_page(pgd));
4513+}
4514+
4515+static void __pgd_unpin(pgd_t *pgd)
4516+{
4517+ xen_pgd_unpin(__pa(pgd));
4518+ xen_pgd_unpin(__pa(__user_pgd(pgd)));
4519+ pgd_walk(pgd, PAGE_KERNEL);
4520+ ClearPagePinned(virt_to_page(pgd));
4521+}
4522+
4523+void pgd_test_and_unpin(pgd_t *pgd)
4524+{
4525+ if (PagePinned(virt_to_page(pgd)))
4526+ __pgd_unpin(pgd);
4527+}
4528+
4529 void mm_pin(struct mm_struct *mm)
4530 {
4531 if (xen_feature(XENFEAT_writable_page_tables))
4532 return;
4533
4534 pin_lock(mm);
4535-
4536- mm_walk(mm, PAGE_KERNEL_RO);
4537- xen_pgd_pin(__pa(mm->pgd)); /* kernel */
4538- xen_pgd_pin(__pa(__user_pgd(mm->pgd))); /* user */
4539- SetPagePinned(virt_to_page(mm->pgd));
4540- spin_lock(&mm_unpinned_lock);
4541- list_del(&mm->context.unpinned);
4542- spin_unlock(&mm_unpinned_lock);
4543-
4544+ __pgd_pin(mm->pgd);
4545 pin_unlock(mm);
4546 }
4547
4548@@ -185,34 +195,30 @@ void mm_unpin(struct mm_struct *mm)
4549 return;
4550
4551 pin_lock(mm);
4552-
4553- xen_pgd_unpin(__pa(mm->pgd));
4554- xen_pgd_unpin(__pa(__user_pgd(mm->pgd)));
4555- mm_walk(mm, PAGE_KERNEL);
4556- ClearPagePinned(virt_to_page(mm->pgd));
4557- spin_lock(&mm_unpinned_lock);
4558- list_add(&mm->context.unpinned, &mm_unpinned);
4559- spin_unlock(&mm_unpinned_lock);
4560-
4561+ __pgd_unpin(mm->pgd);
4562 pin_unlock(mm);
4563 }
4564
4565 void mm_pin_all(void)
4566 {
4567+ struct page *page;
4568+ unsigned long flags;
4569+
4570 if (xen_feature(XENFEAT_writable_page_tables))
4571 return;
4572
4573 /*
4574- * Allow uninterrupted access to the mm_unpinned list. We don't
4575- * actually take the mm_unpinned_lock as it is taken inside mm_pin().
4576+ * Allow uninterrupted access to the pgd_list. Also protects
4577+ * __pgd_pin() by disabling preemption.
4578 * All other CPUs must be at a safe point (e.g., in stop_machine
4579 * or offlined entirely).
4580 */
4581- preempt_disable();
4582- while (!list_empty(&mm_unpinned))
4583- mm_pin(list_entry(mm_unpinned.next, struct mm_struct,
4584- context.unpinned));
4585- preempt_enable();
4586+ spin_lock_irqsave(&pgd_lock, flags);
4587+ list_for_each_entry(page, &pgd_list, lru) {
4588+ if (!PagePinned(page))
4589+ __pgd_pin((pgd_t *)page_address(page));
4590+ }
4591+ spin_unlock_irqrestore(&pgd_lock, flags);
4592 }
4593
4594 void arch_dup_mmap(struct mm_struct *oldmm, struct mm_struct *mm)
4595@@ -331,11 +337,11 @@ static struct page *split_large_page(uns
4596 return base;
4597 }
4598
4599-static void cache_flush_page(void *adr)
4600+void clflush_cache_range(void *adr, int size)
4601 {
4602 int i;
4603- for (i = 0; i < PAGE_SIZE; i += boot_cpu_data.x86_clflush_size)
4604- asm volatile("clflush (%0)" :: "r" (adr + i));
4605+ for (i = 0; i < size; i += boot_cpu_data.x86_clflush_size)
4606+ clflush(adr+i);
4607 }
4608
4609 static void flush_kernel_map(void *arg)
4610@@ -350,7 +356,7 @@ static void flush_kernel_map(void *arg)
4611 asm volatile("wbinvd" ::: "memory");
4612 else list_for_each_entry(pg, l, lru) {
4613 void *adr = page_address(pg);
4614- cache_flush_page(adr);
4615+ clflush_cache_range(adr, PAGE_SIZE);
4616 }
4617 __flush_tlb_all();
4618 }
4619@@ -418,6 +424,7 @@ __change_page_attr(unsigned long address
4620 split = split_large_page(address, prot, ref_prot2);
4621 if (!split)
4622 return -ENOMEM;
4623+ pgprot_val(ref_prot2) &= ~_PAGE_NX;
4624 set_pte(kpte, mk_pte(split, ref_prot2));
4625 kpte_page = split;
4626 }
4627@@ -510,9 +517,14 @@ void global_flush_tlb(void)
4628 struct page *pg, *next;
4629 struct list_head l;
4630
4631- down_read(&init_mm.mmap_sem);
4632+ /*
4633+ * Write-protect the semaphore, to exclude two contexts
4634+ * doing a list_replace_init() call in parallel and to
4635+ * exclude new additions to the deferred_pages list:
4636+ */
4637+ down_write(&init_mm.mmap_sem);
4638 list_replace_init(&deferred_pages, &l);
4639- up_read(&init_mm.mmap_sem);
4640+ up_write(&init_mm.mmap_sem);
4641
4642 flush_map(&l);
4643
4644Index: head-2008-12-01/arch/x86/mm/pgtable_32-xen.c
4645===================================================================
4646--- head-2008-12-01.orig/arch/x86/mm/pgtable_32-xen.c 2008-12-01 11:36:47.000000000 +0100
4647+++ head-2008-12-01/arch/x86/mm/pgtable_32-xen.c 2008-12-01 11:36:55.000000000 +0100
4648@@ -6,6 +6,7 @@
4649 #include <linux/kernel.h>
4650 #include <linux/errno.h>
4651 #include <linux/mm.h>
4652+#include <linux/nmi.h>
4653 #include <linux/swap.h>
4654 #include <linux/smp.h>
4655 #include <linux/highmem.h>
4656@@ -46,6 +47,8 @@ void show_mem(void)
4657 for_each_online_pgdat(pgdat) {
4658 pgdat_resize_lock(pgdat, &flags);
4659 for (i = 0; i < pgdat->node_spanned_pages; ++i) {
4660+ if (unlikely(i % MAX_ORDER_NR_PAGES == 0))
4661+ touch_nmi_watchdog();
4662 page = pgdat_page_nr(pgdat, i);
4663 total++;
4664 if (PageHighMem(page))
4665@@ -206,7 +209,7 @@ void pte_free(struct page *pte)
4666 __free_page(pte);
4667 }
4668
4669-void pmd_ctor(void *pmd, struct kmem_cache *cache, unsigned long flags)
4670+void pmd_ctor(struct kmem_cache *cache, void *pmd)
4671 {
4672 memset(pmd, 0, PTRS_PER_PMD*sizeof(pmd_t));
4673 }
4674Index: head-2008-12-01/arch/x86/pci/irq-xen.c
4675===================================================================
4676--- head-2008-12-01.orig/arch/x86/pci/irq-xen.c 2008-12-01 11:36:47.000000000 +0100
4677+++ head-2008-12-01/arch/x86/pci/irq-xen.c 2008-12-01 11:36:55.000000000 +0100
4678@@ -173,7 +173,7 @@ void eisa_set_level_irq(unsigned int irq
4679 }
4680
4681 /*
4682- * Common IRQ routing practice: nybbles in config space,
4683+ * Common IRQ routing practice: nibbles in config space,
4684 * offset by some magic constant.
4685 */
4686 static unsigned int read_config_nybble(struct pci_dev *router, unsigned offset, unsigned nr)
4687@@ -496,6 +496,26 @@ static int pirq_amd756_set(struct pci_de
4688 return 1;
4689 }
4690
4691+/*
4692+ * PicoPower PT86C523
4693+ */
4694+static int pirq_pico_get(struct pci_dev *router, struct pci_dev *dev, int pirq)
4695+{
4696+ outb(0x10 + ((pirq - 1) >> 1), 0x24);
4697+ return ((pirq - 1) & 1) ? (inb(0x26) >> 4) : (inb(0x26) & 0xf);
4698+}
4699+
4700+static int pirq_pico_set(struct pci_dev *router, struct pci_dev *dev, int pirq,
4701+ int irq)
4702+{
4703+ unsigned int x;
4704+ outb(0x10 + ((pirq - 1) >> 1), 0x24);
4705+ x = inb(0x26);
4706+ x = ((pirq - 1) & 1) ? ((x & 0x0f) | (irq << 4)) : ((x & 0xf0) | (irq));
4707+ outb(x, 0x26);
4708+ return 1;
4709+}
4710+
4711 #ifdef CONFIG_PCI_BIOS
4712
4713 static int pirq_bios_set(struct pci_dev *router, struct pci_dev *dev, int pirq, int irq)
4714@@ -569,7 +589,7 @@ static __init int via_router_probe(struc
4715 /* FIXME: We should move some of the quirk fixup stuff here */
4716
4717 /*
4718- * work arounds for some buggy BIOSes
4719+ * workarounds for some buggy BIOSes
4720 */
4721 if (device == PCI_DEVICE_ID_VIA_82C586_0) {
4722 switch(router->device) {
4723@@ -725,6 +745,24 @@ static __init int amd_router_probe(struc
4724 return 1;
4725 }
4726
4727+static __init int pico_router_probe(struct irq_router *r, struct pci_dev *router, u16 device)
4728+{
4729+ switch (device) {
4730+ case PCI_DEVICE_ID_PICOPOWER_PT86C523:
4731+ r->name = "PicoPower PT86C523";
4732+ r->get = pirq_pico_get;
4733+ r->set = pirq_pico_set;
4734+ return 1;
4735+
4736+ case PCI_DEVICE_ID_PICOPOWER_PT86C523BBP:
4737+ r->name = "PicoPower PT86C523 rev. BB+";
4738+ r->get = pirq_pico_get;
4739+ r->set = pirq_pico_set;
4740+ return 1;
4741+ }
4742+ return 0;
4743+}
4744+
4745 static __initdata struct irq_router_handler pirq_routers[] = {
4746 { PCI_VENDOR_ID_INTEL, intel_router_probe },
4747 { PCI_VENDOR_ID_AL, ali_router_probe },
4748@@ -736,6 +774,7 @@ static __initdata struct irq_router_hand
4749 { PCI_VENDOR_ID_VLSI, vlsi_router_probe },
4750 { PCI_VENDOR_ID_SERVERWORKS, serverworks_router_probe },
4751 { PCI_VENDOR_ID_AMD, amd_router_probe },
4752+ { PCI_VENDOR_ID_PICOPOWER, pico_router_probe },
4753 /* Someone with docs needs to add the ATI Radeon IGP */
4754 { 0, NULL }
4755 };
4756@@ -1014,7 +1053,7 @@ static void __init pcibios_fixup_irqs(vo
4757 * Work around broken HP Pavilion Notebooks which assign USB to
4758 * IRQ 9 even though it is actually wired to IRQ 11
4759 */
4760-static int __init fix_broken_hp_bios_irq9(struct dmi_system_id *d)
4761+static int __init fix_broken_hp_bios_irq9(const struct dmi_system_id *d)
4762 {
4763 if (!broken_hp_bios_irq9) {
4764 broken_hp_bios_irq9 = 1;
4765@@ -1027,7 +1066,7 @@ static int __init fix_broken_hp_bios_irq
4766 * Work around broken Acer TravelMate 360 Notebooks which assign
4767 * Cardbus to IRQ 11 even though it is actually wired to IRQ 10
4768 */
4769-static int __init fix_acer_tm360_irqrouting(struct dmi_system_id *d)
4770+static int __init fix_acer_tm360_irqrouting(const struct dmi_system_id *d)
4771 {
4772 if (!acer_tm360_irqrouting) {
4773 acer_tm360_irqrouting = 1;
4774Index: head-2008-12-01/drivers/acpi/processor_idle.c
4775===================================================================
4776--- head-2008-12-01.orig/drivers/acpi/processor_idle.c 2008-12-01 11:11:03.000000000 +0100
4777+++ head-2008-12-01/drivers/acpi/processor_idle.c 2008-12-01 11:36:55.000000000 +0100
4778@@ -1742,6 +1742,13 @@ int acpi_processor_cst_has_changed(struc
4779 if (!pr->flags.power_setup_done)
4780 return -ENODEV;
4781
4782+ if (processor_pm_external()) {
4783+ acpi_processor_get_power_info(pr);
4784+ processor_notify_external(pr,
4785+ PROCESSOR_PM_CHANGE, PM_TYPE_IDLE);
4786+ return ret;
4787+ }
4788+
4789 cpuidle_pause_and_lock();
4790 cpuidle_disable_device(&pr->power.dev);
4791 acpi_processor_get_power_info(pr);
4792Index: head-2008-12-01/drivers/cpuidle/Kconfig
4793===================================================================
4794--- head-2008-12-01.orig/drivers/cpuidle/Kconfig 2008-12-01 10:53:14.000000000 +0100
4795+++ head-2008-12-01/drivers/cpuidle/Kconfig 2008-12-01 11:36:55.000000000 +0100
4796@@ -1,6 +1,7 @@
4797
4798 config CPU_IDLE
4799 bool "CPU idle PM support"
4800+ depends on !PROCESSOR_EXTERNAL_CONTROL
4801 default ACPI
4802 help
4803 CPU idle is a generic framework for supporting software-controlled
4804Index: head-2008-12-01/drivers/pci/msi-xen.c
4805===================================================================
4806--- head-2008-12-01.orig/drivers/pci/msi-xen.c 2008-12-01 11:36:13.000000000 +0100
4807+++ head-2008-12-01/drivers/pci/msi-xen.c 2008-12-01 11:36:55.000000000 +0100
4808@@ -264,6 +264,12 @@ static int msi_map_vector(struct pci_dev
4809 return msi_map_pirq_to_vector(dev, -1, entry_nr, table_base);
4810 }
4811
4812+static void pci_intx_for_msi(struct pci_dev *dev, int enable)
4813+{
4814+ if (!(dev->dev_flags & PCI_DEV_FLAGS_MSI_INTX_DISABLE_BUG))
4815+ pci_intx(dev, enable);
4816+}
4817+
4818 #ifdef CONFIG_PM
4819 static void __pci_restore_msi_state(struct pci_dev *dev)
4820 {
4821@@ -276,7 +282,7 @@ static void __pci_restore_msi_state(stru
4822 if (pirq < 0)
4823 return;
4824
4825- pci_intx(dev, 0); /* disable intx */
4826+ pci_intx_for_msi(dev, 0);
4827 msi_set_enable(dev, 0);
4828 }
4829
4830@@ -313,7 +319,7 @@ static void __pci_restore_msix_state(str
4831 }
4832 spin_unlock_irqrestore(&msi_dev_entry->pirq_list_lock, flags);
4833
4834- pci_intx(dev, 0); /* disable intx */
4835+ pci_intx_for_msi(dev, 0);
4836 msix_set_enable(dev, 0);
4837 }
4838
4839@@ -348,7 +354,7 @@ static int msi_capability_init(struct pc
4840 return -EBUSY;
4841
4842 /* Set MSI enabled bits */
4843- pci_intx(dev, 0); /* disable intx */
4844+ pci_intx_for_msi(dev, 0);
4845 msi_set_enable(dev, 1);
4846 dev->msi_enabled = 1;
4847
4848@@ -422,7 +428,7 @@ static int msix_capability_init(struct p
4849 return avail;
4850 }
4851
4852- pci_intx(dev, 0); /* disable intx */
4853+ pci_intx_for_msi(dev, 0);
4854 msix_set_enable(dev, 1);
4855 dev->msix_enabled = 1;
4856
4857@@ -562,7 +568,7 @@ void pci_disable_msi(struct pci_dev* dev
4858
4859 /* Disable MSI mode */
4860 msi_set_enable(dev, 0);
4861- pci_intx(dev, 1); /* enable intx */
4862+ pci_intx_for_msi(dev, 1);
4863 dev->msi_enabled = 0;
4864 }
4865 EXPORT_SYMBOL(pci_disable_msi);
4866@@ -701,7 +707,7 @@ void pci_disable_msix(struct pci_dev* de
4867
4868 /* Disable MSI mode */
4869 msix_set_enable(dev, 0);
4870- pci_intx(dev, 1); /* enable intx */
4871+ pci_intx_for_msi(dev, 1);
4872 dev->msix_enabled = 0;
4873 }
4874 EXPORT_SYMBOL(pci_disable_msix);
4875Index: head-2008-12-01/drivers/xen/blkback/blkback.c
4876===================================================================
4877--- head-2008-12-01.orig/drivers/xen/blkback/blkback.c 2008-12-01 11:36:47.000000000 +0100
4878+++ head-2008-12-01/drivers/xen/blkback/blkback.c 2008-12-01 11:36:55.000000000 +0100
4879@@ -269,13 +269,10 @@ static void __end_block_io_op(pending_re
4880 }
4881 }
4882
4883-static int end_block_io_op(struct bio *bio, unsigned int done, int error)
4884+static void end_block_io_op(struct bio *bio, int error)
4885 {
4886- if (bio->bi_size != 0)
4887- return 1;
4888 __end_block_io_op(bio->bi_private, error);
4889 bio_put(bio);
4890- return error;
4891 }
4892
4893
4894Index: head-2008-12-01/drivers/xen/blkfront/blkfront.c
4895===================================================================
4896--- head-2008-12-01.orig/drivers/xen/blkfront/blkfront.c 2008-12-01 11:36:47.000000000 +0100
4897+++ head-2008-12-01/drivers/xen/blkfront/blkfront.c 2008-12-01 11:36:55.000000000 +0100
4898@@ -587,9 +587,8 @@ static int blkif_queue_request(struct re
4899 struct blkfront_info *info = req->rq_disk->private_data;
4900 unsigned long buffer_mfn;
4901 blkif_request_t *ring_req;
4902- struct bio *bio;
4903 struct bio_vec *bvec;
4904- int idx;
4905+ struct req_iterator iter;
4906 unsigned long id;
4907 unsigned int fsect, lsect;
4908 int ref;
4909@@ -623,34 +622,32 @@ static int blkif_queue_request(struct re
4910 ring_req->operation = BLKIF_OP_WRITE_BARRIER;
4911
4912 ring_req->nr_segments = 0;
4913- rq_for_each_bio (bio, req) {
4914- bio_for_each_segment (bvec, bio, idx) {
4915- BUG_ON(ring_req->nr_segments
4916- == BLKIF_MAX_SEGMENTS_PER_REQUEST);
4917- buffer_mfn = page_to_phys(bvec->bv_page) >> PAGE_SHIFT;
4918- fsect = bvec->bv_offset >> 9;
4919- lsect = fsect + (bvec->bv_len >> 9) - 1;
4920- /* install a grant reference. */
4921- ref = gnttab_claim_grant_reference(&gref_head);
4922- BUG_ON(ref == -ENOSPC);
4923+ rq_for_each_segment(bvec, req, iter) {
4924+ BUG_ON(ring_req->nr_segments
4925+ == BLKIF_MAX_SEGMENTS_PER_REQUEST);
4926+ buffer_mfn = page_to_phys(bvec->bv_page) >> PAGE_SHIFT;
4927+ fsect = bvec->bv_offset >> 9;
4928+ lsect = fsect + (bvec->bv_len >> 9) - 1;
4929+ /* install a grant reference. */
4930+ ref = gnttab_claim_grant_reference(&gref_head);
4931+ BUG_ON(ref == -ENOSPC);
4932+
4933+ gnttab_grant_foreign_access_ref(
4934+ ref,
4935+ info->xbdev->otherend_id,
4936+ buffer_mfn,
4937+ rq_data_dir(req) ? GTF_readonly : 0 );
4938+
4939+ info->shadow[id].frame[ring_req->nr_segments] =
4940+ mfn_to_pfn(buffer_mfn);
4941+
4942+ ring_req->seg[ring_req->nr_segments] =
4943+ (struct blkif_request_segment) {
4944+ .gref = ref,
4945+ .first_sect = fsect,
4946+ .last_sect = lsect };
4947
4948- gnttab_grant_foreign_access_ref(
4949- ref,
4950- info->xbdev->otherend_id,
4951- buffer_mfn,
4952- rq_data_dir(req) ? GTF_readonly : 0 );
4953-
4954- info->shadow[id].frame[ring_req->nr_segments] =
4955- mfn_to_pfn(buffer_mfn);
4956-
4957- ring_req->seg[ring_req->nr_segments] =
4958- (struct blkif_request_segment) {
4959- .gref = ref,
4960- .first_sect = fsect,
4961- .last_sect = lsect };
4962-
4963- ring_req->nr_segments++;
4964- }
4965+ ring_req->nr_segments++;
4966 }
4967
4968 info->ring.req_prod_pvt++;
4969Index: head-2008-12-01/drivers/xen/core/machine_kexec.c
4970===================================================================
4971--- head-2008-12-01.orig/drivers/xen/core/machine_kexec.c 2008-10-13 13:43:45.000000000 +0200
4972+++ head-2008-12-01/drivers/xen/core/machine_kexec.c 2008-12-01 11:36:55.000000000 +0100
4973@@ -29,6 +29,10 @@ void __init xen_machine_kexec_setup_reso
4974 int k = 0;
4975 int rc;
4976
4977+ if (strstr(boot_command_line, "crashkernel="))
4978+ printk(KERN_WARNING "Ignoring crashkernel command line, "
4979+ "parameter will be supplied by xen\n");
4980+
4981 if (!is_initial_xendomain())
4982 return;
4983
4984Index: head-2008-12-01/drivers/xen/core/smpboot.c
4985===================================================================
4986--- head-2008-12-01.orig/drivers/xen/core/smpboot.c 2008-12-01 11:36:13.000000000 +0100
4987+++ head-2008-12-01/drivers/xen/core/smpboot.c 2008-12-01 11:36:55.000000000 +0100
4988@@ -45,8 +45,8 @@ cpumask_t cpu_possible_map;
4989 EXPORT_SYMBOL(cpu_possible_map);
4990 cpumask_t cpu_initialized_map;
4991
4992-struct cpuinfo_x86 cpu_data[NR_CPUS] __cacheline_aligned;
4993-EXPORT_SYMBOL(cpu_data);
4994+DEFINE_PER_CPU(struct cpuinfo_x86, cpu_info);
4995+EXPORT_PER_CPU_SYMBOL(cpu_info);
4996
4997 #ifdef CONFIG_HOTPLUG_CPU
4998 DEFINE_PER_CPU(int, cpu_state) = { 0 };
4999@@ -59,13 +59,13 @@ static char callfunc_name[NR_CPUS][15];
5000
5001 u8 cpu_2_logical_apicid[NR_CPUS] = { [0 ... NR_CPUS-1] = BAD_APICID };
5002
5003-cpumask_t cpu_sibling_map[NR_CPUS] __cacheline_aligned;
5004-cpumask_t cpu_core_map[NR_CPUS] __cacheline_aligned;
5005-EXPORT_SYMBOL(cpu_core_map);
5006+DEFINE_PER_CPU(cpumask_t, cpu_sibling_map);
5007+DEFINE_PER_CPU(cpumask_t, cpu_core_map);
5008+EXPORT_PER_CPU_SYMBOL(cpu_core_map);
5009
5010 #if defined(__i386__)
5011-u8 x86_cpu_to_apicid[NR_CPUS] = { [0 ... NR_CPUS-1] = 0xff };
5012-EXPORT_SYMBOL(x86_cpu_to_apicid);
5013+DEFINE_PER_CPU(u8, x86_cpu_to_apicid) = BAD_APICID;
5014+EXPORT_PER_CPU_SYMBOL(x86_cpu_to_apicid);
5015 #endif
5016
5017 void __init prefill_possible_map(void)
5018@@ -90,25 +90,25 @@ void __init smp_alloc_memory(void)
5019 static inline void
5020 set_cpu_sibling_map(unsigned int cpu)
5021 {
5022- cpu_data[cpu].phys_proc_id = cpu;
5023- cpu_data[cpu].cpu_core_id = 0;
5024+ cpu_data(cpu).phys_proc_id = cpu;
5025+ cpu_data(cpu).cpu_core_id = 0;
5026
5027- cpu_sibling_map[cpu] = cpumask_of_cpu(cpu);
5028- cpu_core_map[cpu] = cpumask_of_cpu(cpu);
5029+ per_cpu(cpu_sibling_map, cpu) = cpumask_of_cpu(cpu);
5030+ per_cpu(cpu_core_map, cpu) = cpumask_of_cpu(cpu);
5031
5032- cpu_data[cpu].booted_cores = 1;
5033+ cpu_data(cpu).booted_cores = 1;
5034 }
5035
5036 static void
5037 remove_siblinginfo(unsigned int cpu)
5038 {
5039- cpu_data[cpu].phys_proc_id = BAD_APICID;
5040- cpu_data[cpu].cpu_core_id = BAD_APICID;
5041+ cpu_data(cpu).phys_proc_id = BAD_APICID;
5042+ cpu_data(cpu).cpu_core_id = BAD_APICID;
5043
5044- cpus_clear(cpu_sibling_map[cpu]);
5045- cpus_clear(cpu_core_map[cpu]);
5046+ cpus_clear(per_cpu(cpu_sibling_map, cpu));
5047+ cpus_clear(per_cpu(cpu_core_map, cpu));
5048
5049- cpu_data[cpu].booted_cores = 0;
5050+ cpu_data(cpu).booted_cores = 0;
5051 }
5052
5053 static int __cpuinit xen_smp_intr_init(unsigned int cpu)
5054@@ -167,9 +167,9 @@ void __cpuinit cpu_bringup(void)
5055 {
5056 cpu_init();
5057 #ifdef __i386__
5058- identify_secondary_cpu(cpu_data + smp_processor_id());
5059+ identify_secondary_cpu(&current_cpu_data);
5060 #else
5061- identify_cpu(cpu_data + smp_processor_id());
5062+ identify_cpu(&current_cpu_data);
5063 #endif
5064 touch_softlockup_watchdog();
5065 preempt_disable();
5066@@ -270,16 +270,16 @@ void __init smp_prepare_cpus(unsigned in
5067 if (HYPERVISOR_vcpu_op(VCPUOP_get_physid, 0, &cpu_id) == 0)
5068 apicid = xen_vcpu_physid_to_x86_apicid(cpu_id.phys_id);
5069 boot_cpu_data.apicid = apicid;
5070- cpu_data[0] = boot_cpu_data;
5071+ cpu_data(0) = boot_cpu_data;
5072
5073 cpu_2_logical_apicid[0] = apicid;
5074- x86_cpu_to_apicid[0] = apicid;
5075+ per_cpu(x86_cpu_to_apicid, 0) = apicid;
5076
5077 current_thread_info()->cpu = 0;
5078
5079 for (cpu = 0; cpu < NR_CPUS; cpu++) {
5080- cpus_clear(cpu_sibling_map[cpu]);
5081- cpus_clear(cpu_core_map[cpu]);
5082+ cpus_clear(per_cpu(cpu_sibling_map, cpu));
5083+ cpus_clear(per_cpu(cpu_core_map, cpu));
5084 }
5085
5086 set_cpu_sibling_map(0);
5087@@ -324,11 +324,12 @@ void __init smp_prepare_cpus(unsigned in
5088 apicid = cpu;
5089 if (HYPERVISOR_vcpu_op(VCPUOP_get_physid, cpu, &cpu_id) == 0)
5090 apicid = xen_vcpu_physid_to_x86_apicid(cpu_id.phys_id);
5091- cpu_data[cpu] = boot_cpu_data;
5092- cpu_data[cpu].apicid = apicid;
5093+ cpu_data(cpu) = boot_cpu_data;
5094+ cpu_data(cpu).cpu_index = cpu;
5095+ cpu_data(cpu).apicid = apicid;
5096
5097 cpu_2_logical_apicid[cpu] = apicid;
5098- x86_cpu_to_apicid[cpu] = apicid;
5099+ per_cpu(x86_cpu_to_apicid, cpu) = apicid;
5100
5101 #ifdef __x86_64__
5102 cpu_pda(cpu)->pcurrent = idle;
5103Index: head-2008-12-01/drivers/xen/netback/loopback.c
5104===================================================================
5105--- head-2008-12-01.orig/drivers/xen/netback/loopback.c 2008-12-01 11:32:38.000000000 +0100
5106+++ head-2008-12-01/drivers/xen/netback/loopback.c 2008-12-01 11:36:55.000000000 +0100
5107@@ -285,9 +285,9 @@ static void __exit clean_loopback(int i)
5108 char dev_name[IFNAMSIZ];
5109
5110 sprintf(dev_name, "vif0.%d", i);
5111- dev1 = dev_get_by_name(dev_name);
5112+ dev1 = dev_get_by_name(&init_net, dev_name);
5113 sprintf(dev_name, "veth%d", i);
5114- dev2 = dev_get_by_name(dev_name);
5115+ dev2 = dev_get_by_name(&init_net, dev_name);
5116 if (dev1 && dev2) {
5117 unregister_netdev(dev2);
5118 unregister_netdev(dev1);
5119Index: head-2008-12-01/drivers/xen/netback/netback.c
5120===================================================================
5121--- head-2008-12-01.orig/drivers/xen/netback/netback.c 2008-12-01 11:36:13.000000000 +0100
5122+++ head-2008-12-01/drivers/xen/netback/netback.c 2008-12-01 11:36:55.000000000 +0100
5123@@ -334,8 +334,8 @@ static void xen_network_done_notify(void
5124 {
5125 static struct net_device *eth0_dev = NULL;
5126 if (unlikely(eth0_dev == NULL))
5127- eth0_dev = __dev_get_by_name("eth0");
5128- netif_rx_schedule(eth0_dev);
5129+ eth0_dev = __dev_get_by_name(&init_net, "eth0");
5130+ netif_rx_schedule(eth0_dev, ???);
5131 }
5132 /*
5133 * Add following to poll() function in NAPI driver (Tigon3 is example):
5134Index: head-2008-12-01/drivers/xen/netback/xenbus.c
5135===================================================================
5136--- head-2008-12-01.orig/drivers/xen/netback/xenbus.c 2008-12-01 11:36:07.000000000 +0100
5137+++ head-2008-12-01/drivers/xen/netback/xenbus.c 2008-12-01 11:36:55.000000000 +0100
5138@@ -149,12 +149,10 @@ fail:
5139 * and vif variables to the environment, for the benefit of the vif-* hotplug
5140 * scripts.
5141 */
5142-static int netback_uevent(struct xenbus_device *xdev, char **envp,
5143- int num_envp, char *buffer, int buffer_size)
5144+static int netback_uevent(struct xenbus_device *xdev, struct kobj_uevent_env *env)
5145 {
5146 struct backend_info *be = xdev->dev.driver_data;
5147 netif_t *netif = be->netif;
5148- int i = 0, length = 0;
5149 char *val;
5150
5151 DPRINTK("netback_uevent");
5152@@ -166,15 +164,11 @@ static int netback_uevent(struct xenbus_
5153 return err;
5154 }
5155 else {
5156- add_uevent_var(envp, num_envp, &i, buffer, buffer_size,
5157- &length, "script=%s", val);
5158+ add_uevent_var(env, "script=%s", val);
5159 kfree(val);
5160 }
5161
5162- add_uevent_var(envp, num_envp, &i, buffer, buffer_size, &length,
5163- "vif=%s", netif->dev->name);
5164-
5165- envp[i] = NULL;
5166+ add_uevent_var(env, "vif=%s", netif->dev->name);
5167
5168 return 0;
5169 }
5170Index: head-2008-12-01/drivers/xen/netfront/accel.c
5171===================================================================
5172--- head-2008-12-01.orig/drivers/xen/netfront/accel.c 2008-08-07 12:44:36.000000000 +0200
5173+++ head-2008-12-01/drivers/xen/netfront/accel.c 2008-12-01 11:36:55.000000000 +0100
5174@@ -325,13 +325,13 @@ accelerator_set_vif_state_hooks(struct n
5175 DPRINTK("%p\n",vif_state);
5176
5177 /* Make sure there are no data path operations going on */
5178- netif_poll_disable(vif_state->np->netdev);
5179+ napi_disable(&vif_state->np->napi);
5180 netif_tx_lock_bh(vif_state->np->netdev);
5181
5182 vif_state->hooks = vif_state->np->accelerator->hooks;
5183
5184 netif_tx_unlock_bh(vif_state->np->netdev);
5185- netif_poll_enable(vif_state->np->netdev);
5186+ napi_enable(&vif_state->np->napi);
5187 }
5188
5189
5190@@ -509,7 +509,7 @@ accelerator_remove_single_hook(struct ne
5191 struct netfront_accel_vif_state *vif_state)
5192 {
5193 /* Make sure there are no data path operations going on */
5194- netif_poll_disable(vif_state->np->netdev);
5195+ napi_disable(&vif_state->np->napi);
5196 netif_tx_lock_bh(vif_state->np->netdev);
5197
5198 /*
5199@@ -521,7 +521,7 @@ accelerator_remove_single_hook(struct ne
5200 vif_state->hooks = NULL;
5201
5202 netif_tx_unlock_bh(vif_state->np->netdev);
5203- netif_poll_enable(vif_state->np->netdev);
5204+ napi_enable(&vif_state->np->napi);
5205 }
5206
5207
5208Index: head-2008-12-01/drivers/xen/netfront/netfront.c
5209===================================================================
5210--- head-2008-12-01.orig/drivers/xen/netfront/netfront.c 2008-12-01 11:36:13.000000000 +0100
5211+++ head-2008-12-01/drivers/xen/netfront/netfront.c 2008-12-01 11:36:55.000000000 +0100
5212@@ -626,6 +626,7 @@ static int network_open(struct net_devic
5213 struct netfront_info *np = netdev_priv(dev);
5214
5215 memset(&np->stats, 0, sizeof(np->stats));
5216+ napi_enable(&np->napi);
5217
5218 spin_lock_bh(&np->rx_lock);
5219 if (netfront_carrier_ok(np)) {
5220@@ -634,7 +635,7 @@ static int network_open(struct net_devic
5221 if (RING_HAS_UNCONSUMED_RESPONSES(&np->rx)){
5222 netfront_accelerator_call_stop_napi_irq(np, dev);
5223
5224- netif_rx_schedule(dev);
5225+ netif_rx_schedule(dev, &np->napi);
5226 }
5227 }
5228 spin_unlock_bh(&np->rx_lock);
5229@@ -706,7 +707,7 @@ static void rx_refill_timeout(unsigned l
5230
5231 netfront_accelerator_call_stop_napi_irq(np, dev);
5232
5233- netif_rx_schedule(dev);
5234+ netif_rx_schedule(dev, &np->napi);
5235 }
5236
5237 static void network_alloc_rx_buffers(struct net_device *dev)
5238@@ -1063,7 +1064,7 @@ static irqreturn_t netif_int(int irq, vo
5239 if (RING_HAS_UNCONSUMED_RESPONSES(&np->rx)) {
5240 netfront_accelerator_call_stop_napi_irq(np, dev);
5241
5242- netif_rx_schedule(dev);
5243+ netif_rx_schedule(dev, &np->napi);
5244 dev->last_rx = jiffies;
5245 }
5246 }
5247@@ -1316,16 +1317,17 @@ static int xennet_set_skb_gso(struct sk_
5248 #endif
5249 }
5250
5251-static int netif_poll(struct net_device *dev, int *pbudget)
5252+static int netif_poll(struct napi_struct *napi, int budget)
5253 {
5254- struct netfront_info *np = netdev_priv(dev);
5255+ struct netfront_info *np = container_of(napi, struct netfront_info, napi);
5256+ struct net_device *dev = np->netdev;
5257 struct sk_buff *skb;
5258 struct netfront_rx_info rinfo;
5259 struct netif_rx_response *rx = &rinfo.rx;
5260 struct netif_extra_info *extras = rinfo.extras;
5261 RING_IDX i, rp;
5262 struct multicall_entry *mcl;
5263- int work_done, budget, more_to_do = 1, accel_more_to_do = 1;
5264+ int work_done, more_to_do = 1, accel_more_to_do = 1;
5265 struct sk_buff_head rxq;
5266 struct sk_buff_head errq;
5267 struct sk_buff_head tmpq;
5268@@ -1345,8 +1347,6 @@ static int netif_poll(struct net_device
5269 skb_queue_head_init(&errq);
5270 skb_queue_head_init(&tmpq);
5271
5272- if ((budget = *pbudget) > dev->quota)
5273- budget = dev->quota;
5274 rp = np->rx.sring->rsp_prod;
5275 rmb(); /* Ensure we see queued responses up to 'rp'. */
5276
5277@@ -1508,9 +1508,6 @@ err:
5278 accel_more_to_do = 0;
5279 }
5280
5281- *pbudget -= work_done;
5282- dev->quota -= work_done;
5283-
5284 if (work_done < budget) {
5285 local_irq_save(flags);
5286
5287@@ -1527,14 +1524,14 @@ err:
5288 }
5289
5290 if (!more_to_do && !accel_more_to_do)
5291- __netif_rx_complete(dev);
5292+ __netif_rx_complete(dev, napi);
5293
5294 local_irq_restore(flags);
5295 }
5296
5297 spin_unlock(&np->rx_lock);
5298
5299- return more_to_do | accel_more_to_do;
5300+ return work_done;
5301 }
5302
5303 static void netif_release_tx_bufs(struct netfront_info *np)
5304@@ -1681,6 +1678,7 @@ static int network_close(struct net_devi
5305 {
5306 struct netfront_info *np = netdev_priv(dev);
5307 netif_stop_queue(np->netdev);
5308+ napi_disable(&np->napi);
5309 return 0;
5310 }
5311
5312@@ -2088,16 +2086,14 @@ static struct net_device * __devinit cre
5313 netdev->hard_start_xmit = network_start_xmit;
5314 netdev->stop = network_close;
5315 netdev->get_stats = network_get_stats;
5316- netdev->poll = netif_poll;
5317+ netif_napi_add(netdev, &np->napi, netif_poll, 64);
5318 netdev->set_multicast_list = network_set_multicast_list;
5319 netdev->uninit = netif_uninit;
5320 netdev->set_mac_address = xennet_set_mac_address;
5321 netdev->change_mtu = xennet_change_mtu;
5322- netdev->weight = 64;
5323 netdev->features = NETIF_F_IP_CSUM;
5324
5325 SET_ETHTOOL_OPS(netdev, &network_ethtool_ops);
5326- SET_MODULE_OWNER(netdev);
5327 SET_NETDEV_DEV(netdev, &dev->dev);
5328
5329 np->netdev = netdev;
5330Index: head-2008-12-01/drivers/xen/netfront/netfront.h
5331===================================================================
5332--- head-2008-12-01.orig/drivers/xen/netfront/netfront.h 2008-01-07 13:19:18.000000000 +0100
5333+++ head-2008-12-01/drivers/xen/netfront/netfront.h 2008-12-01 11:36:55.000000000 +0100
5334@@ -157,6 +157,8 @@ struct netfront_info {
5335 spinlock_t tx_lock;
5336 spinlock_t rx_lock;
5337
5338+ struct napi_struct napi;
5339+
5340 unsigned int irq;
5341 unsigned int copying_receiver;
5342 unsigned int carrier;
5343Index: head-2008-12-01/drivers/xen/pciback/Makefile
5344===================================================================
5345--- head-2008-12-01.orig/drivers/xen/pciback/Makefile 2008-07-21 11:00:33.000000000 +0200
5346+++ head-2008-12-01/drivers/xen/pciback/Makefile 2008-12-01 11:36:55.000000000 +0100
5347@@ -12,6 +12,4 @@ pciback-$(CONFIG_XEN_PCIDEV_BACKEND_SLOT
5348 pciback-$(CONFIG_XEN_PCIDEV_BACKEND_PASS) += passthrough.o
5349 pciback-$(CONFIG_XEN_PCIDEV_BACKEND_CONTROLLER) += controller.o
5350
5351-ifeq ($(CONFIG_XEN_PCIDEV_BE_DEBUG),y)
5352-EXTRA_CFLAGS += -DDEBUG
5353-endif
5354+ccflags-$(CONFIG_XEN_PCIDEV_BE_DEBUG) += -DDEBUG
5355Index: head-2008-12-01/drivers/xen/pcifront/Makefile
5356===================================================================
5357--- head-2008-12-01.orig/drivers/xen/pcifront/Makefile 2007-06-12 13:13:45.000000000 +0200
5358+++ head-2008-12-01/drivers/xen/pcifront/Makefile 2008-12-01 11:36:55.000000000 +0100
5359@@ -2,6 +2,4 @@ obj-y += pcifront.o
5360
5361 pcifront-y := pci_op.o xenbus.o pci.o
5362
5363-ifeq ($(CONFIG_XEN_PCIDEV_FE_DEBUG),y)
5364-EXTRA_CFLAGS += -DDEBUG
5365-endif
5366+ccflags-$(CONFIG_XEN_PCIDEV_FE_DEBUG) += -DDEBUG
5367Index: head-2008-12-01/drivers/xen/scsiback/emulate.c
5368===================================================================
5369--- head-2008-12-01.orig/drivers/xen/scsiback/emulate.c 2008-08-07 12:44:36.000000000 +0200
5370+++ head-2008-12-01/drivers/xen/scsiback/emulate.c 2008-12-01 11:36:55.000000000 +0100
5371@@ -104,9 +104,10 @@ static void resp_not_supported_cmd(pendi
5372 }
5373
5374
5375-static int __copy_to_sg(struct scatterlist *sg, unsigned int nr_sg,
5376+static int __copy_to_sg(struct scatterlist *sgl, unsigned int nr_sg,
5377 void *buf, unsigned int buflen)
5378 {
5379+ struct scatterlist *sg;
5380 void *from = buf;
5381 void *to;
5382 unsigned int from_rest = buflen;
5383@@ -115,8 +116,8 @@ static int __copy_to_sg(struct scatterli
5384 unsigned int i;
5385 unsigned long pfn;
5386
5387- for (i = 0; i < nr_sg; i++) {
5388- if (sg->page == NULL) {
5389+ for_each_sg (sgl, sg, nr_sg, i) {
5390+ if (sg_page(sg) == NULL) {
5391 printk(KERN_WARNING "%s: inconsistent length field in "
5392 "scatterlist\n", __FUNCTION__);
5393 return -ENOMEM;
5394@@ -125,7 +126,7 @@ static int __copy_to_sg(struct scatterli
5395 to_capa = sg->length;
5396 copy_size = min_t(unsigned int, to_capa, from_rest);
5397
5398- pfn = page_to_pfn(sg->page);
5399+ pfn = page_to_pfn(sg_page(sg));
5400 to = pfn_to_kaddr(pfn) + (sg->offset);
5401 memcpy(to, from, copy_size);
5402
5403@@ -134,7 +135,6 @@ static int __copy_to_sg(struct scatterli
5404 return 0;
5405 }
5406
5407- sg++;
5408 from += copy_size;
5409 }
5410
5411@@ -143,9 +143,10 @@ static int __copy_to_sg(struct scatterli
5412 return -ENOMEM;
5413 }
5414
5415-static int __copy_from_sg(struct scatterlist *sg, unsigned int nr_sg,
5416+static int __copy_from_sg(struct scatterlist *sgl, unsigned int nr_sg,
5417 void *buf, unsigned int buflen)
5418 {
5419+ struct scatterlist *sg;
5420 void *from;
5421 void *to = buf;
5422 unsigned int from_rest;
5423@@ -154,8 +155,8 @@ static int __copy_from_sg(struct scatter
5424 unsigned int i;
5425 unsigned long pfn;
5426
5427- for (i = 0; i < nr_sg; i++) {
5428- if (sg->page == NULL) {
5429+ for_each_sg (sgl, sg, nr_sg, i) {
5430+ if (sg_page(sg) == NULL) {
5431 printk(KERN_WARNING "%s: inconsistent length field in "
5432 "scatterlist\n", __FUNCTION__);
5433 return -ENOMEM;
5434@@ -170,13 +171,11 @@ static int __copy_from_sg(struct scatter
5435 }
5436 copy_size = from_rest;
5437
5438- pfn = page_to_pfn(sg->page);
5439+ pfn = page_to_pfn(sg_page(sg));
5440 from = pfn_to_kaddr(pfn) + (sg->offset);
5441 memcpy(to, from, copy_size);
5442
5443 to_capa -= copy_size;
5444-
5445- sg++;
5446 to += copy_size;
5447 }
5448
5449Index: head-2008-12-01/drivers/xen/scsiback/scsiback.c
5450===================================================================
5451--- head-2008-12-01.orig/drivers/xen/scsiback/scsiback.c 2008-12-01 11:32:38.000000000 +0100
5452+++ head-2008-12-01/drivers/xen/scsiback/scsiback.c 2008-12-01 11:36:55.000000000 +0100
5453@@ -247,6 +247,8 @@ static int scsiback_gnttab_data_map(vscs
5454 write = (data_dir == DMA_TO_DEVICE);
5455
5456 if (nr_segments) {
5457+ struct scatterlist *sg;
5458+
5459 /* free of (sgl) in fast_flush_area()*/
5460 pending_req->sgl = kmalloc(sizeof(struct scatterlist) * nr_segments,
5461 GFP_KERNEL);
5462@@ -255,6 +257,8 @@ static int scsiback_gnttab_data_map(vscs
5463 return -ENOMEM;
5464 }
5465
5466+ sg_init_table(pending_req->sgl, nr_segments);
5467+
5468 for (i = 0; i < nr_segments; i++) {
5469 flags = GNTMAP_host_map;
5470 if (write)
5471@@ -267,7 +271,7 @@ static int scsiback_gnttab_data_map(vscs
5472 err = HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, map, nr_segments);
5473 BUG_ON(err);
5474
5475- for (i = 0; i < nr_segments; i++) {
5476+ for_each_sg (pending_req->sgl, sg, nr_segments, i) {
5477 if (unlikely(map[i].status != 0)) {
5478 printk(KERN_ERR "scsiback: invalid buffer -- could not remap it\n");
5479 map[i].handle = SCSIBACK_INVALID_HANDLE;
5480@@ -283,15 +287,15 @@ static int scsiback_gnttab_data_map(vscs
5481 pending_req, i)) >> PAGE_SHIFT,
5482 FOREIGN_FRAME(map[i].dev_bus_addr >> PAGE_SHIFT));
5483
5484- pending_req->sgl[i].page = virt_to_page(vaddr(pending_req, i));
5485- pending_req->sgl[i].offset = ring_req->seg[i].offset;
5486- pending_req->sgl[i].length = ring_req->seg[i].length;
5487- data_len += pending_req->sgl[i].length;
5488+ sg_set_page(sg, virt_to_page(vaddr(pending_req, i)),
5489+ ring_req->seg[i].length,
5490+ ring_req->seg[i].offset);
5491+ data_len += sg->length;
5492
5493 barrier();
5494- if (pending_req->sgl[i].offset >= PAGE_SIZE ||
5495- pending_req->sgl[i].length > PAGE_SIZE ||
5496- pending_req->sgl[i].offset + pending_req->sgl[i].length > PAGE_SIZE)
5497+ if (sg->offset >= PAGE_SIZE ||
5498+ sg->length > PAGE_SIZE ||
5499+ sg->offset + sg->length > PAGE_SIZE)
5500 err |= 1;
5501
5502 }
5503@@ -320,27 +324,14 @@ static int scsiback_merge_bio(struct req
5504
5505 blk_queue_bounce(q, &bio);
5506
5507- if (!rq->bio)
5508- blk_rq_bio_prep(q, rq, bio);
5509- else if (!ll_back_merge_fn(q, rq, bio))
5510- return -EINVAL;
5511- else {
5512- rq->biotail->bi_next = bio;
5513- rq->biotail = bio;
5514- }
5515-
5516- return 0;
5517+ return blk_rq_append_bio(q, rq, bio);
5518 }
5519
5520
5521 /* quoted scsi_lib.c/scsi_bi_endio */
5522-static int scsiback_bi_endio(struct bio *bio, unsigned int bytes_done, int error)
5523+static void scsiback_bi_endio(struct bio *bio, int error)
5524 {
5525- if (bio->bi_size)
5526- return 1;
5527-
5528 bio_put(bio);
5529- return 0;
5530 }
5531
5532
5533@@ -351,16 +342,16 @@ static int request_map_sg(struct request
5534 struct request_queue *q = rq->q;
5535 int nr_pages;
5536 unsigned int nsegs = count;
5537-
5538 unsigned int data_len = 0, len, bytes, off;
5539+ struct scatterlist *sg;
5540 struct page *page;
5541 struct bio *bio = NULL;
5542 int i, err, nr_vecs = 0;
5543
5544- for (i = 0; i < nsegs; i++) {
5545- page = pending_req->sgl[i].page;
5546- off = (unsigned int)pending_req->sgl[i].offset;
5547- len = (unsigned int)pending_req->sgl[i].length;
5548+ for_each_sg (pending_req->sgl, sg, nsegs, i) {
5549+ page = sg_page(sg);
5550+ off = sg->offset;
5551+ len = sg->length;
5552 data_len += len;
5553
5554 nr_pages = (len + off + PAGE_SIZE - 1) >> PAGE_SHIFT;
5555@@ -388,7 +379,7 @@ static int request_map_sg(struct request
5556 if (bio->bi_vcnt >= nr_vecs) {
5557 err = scsiback_merge_bio(rq, bio);
5558 if (err) {
5559- bio_endio(bio, bio->bi_size, 0);
5560+ bio_endio(bio, 0);
5561 goto free_bios;
5562 }
5563 bio = NULL;
5564@@ -411,7 +402,7 @@ free_bios:
5565 /*
5566 * call endio instead of bio_put incase it was bounced
5567 */
5568- bio_endio(bio, bio->bi_size, 0);
5569+ bio_endio(bio, 0);
5570 }
5571
5572 return err;
5573Index: head-2008-12-01/drivers/xen/scsifront/scsifront.c
5574===================================================================
5575--- head-2008-12-01.orig/drivers/xen/scsifront/scsifront.c 2008-12-01 11:36:47.000000000 +0100
5576+++ head-2008-12-01/drivers/xen/scsifront/scsifront.c 2008-12-01 11:36:55.000000000 +0100
5577@@ -246,11 +246,10 @@ static int map_data_for_request(struct v
5578 {
5579 grant_ref_t gref_head;
5580 struct page *page;
5581- int err, i, ref, ref_cnt = 0;
5582+ int err, ref, ref_cnt = 0;
5583 int write = (sc->sc_data_direction == DMA_TO_DEVICE);
5584- int nr_pages, off, len, bytes;
5585+ unsigned int i, nr_pages, off, len, bytes;
5586 unsigned long buffer_pfn;
5587- unsigned int data_len = 0;
5588
5589 if (sc->sc_data_direction == DMA_NONE)
5590 return 0;
5591@@ -263,25 +262,31 @@ static int map_data_for_request(struct v
5592
5593 if (sc->use_sg) {
5594 /* quoted scsi_lib.c/scsi_req_map_sg . */
5595- struct scatterlist *sg = (struct scatterlist *)sc->request_buffer;
5596- nr_pages = (sc->request_bufflen + sg[0].offset + PAGE_SIZE - 1) >> PAGE_SHIFT;
5597+ struct scatterlist *sg, *sgl = (struct scatterlist *)sc->request_buffer;
5598+ unsigned int data_len = sc->request_bufflen;
5599
5600+ nr_pages = (sc->request_bufflen + sgl->offset + PAGE_SIZE - 1) >> PAGE_SHIFT;
5601 if (nr_pages > VSCSIIF_SG_TABLESIZE) {
5602 printk(KERN_ERR "scsifront: Unable to map request_buffer for command!\n");
5603 ref_cnt = (-E2BIG);
5604 goto big_to_sg;
5605 }
5606
5607- for (i = 0; i < sc->use_sg; i++) {
5608- page = sg[i].page;
5609- off = sg[i].offset;
5610- len = sg[i].length;
5611- data_len += len;
5612+ for_each_sg (sgl, sg, sc->use_sg, i) {
5613+ page = sg_page(sg);
5614+ off = sg->offset;
5615+ len = sg->length;
5616
5617 buffer_pfn = page_to_phys(page) >> PAGE_SHIFT;
5618
5619- while (len > 0) {
5620+ while (len > 0 && data_len > 0) {
5621+ /*
5622+ * sg sends a scatterlist that is larger than
5623+ * the data_len it wants transferred for certain
5624+ * IO sizes
5625+ */
5626 bytes = min_t(unsigned int, len, PAGE_SIZE - off);
5627+ bytes = min(bytes, data_len);
5628
5629 ref = gnttab_claim_grant_reference(&gref_head);
5630 BUG_ON(ref == -ENOSPC);
5631@@ -296,6 +301,7 @@ static int map_data_for_request(struct v
5632
5633 buffer_pfn++;
5634 len -= bytes;
5635+ data_len -= bytes;
5636 off = 0;
5637 ref_cnt++;
5638 }
5639Index: head-2008-12-01/drivers/xen/sfc_netback/accel_fwd.c
5640===================================================================
5641--- head-2008-12-01.orig/drivers/xen/sfc_netback/accel_fwd.c 2008-12-01 11:36:13.000000000 +0100
5642+++ head-2008-12-01/drivers/xen/sfc_netback/accel_fwd.c 2008-12-01 11:36:55.000000000 +0100
5643@@ -181,10 +181,11 @@ int netback_accel_fwd_add(const __u8 *ma
5644 unsigned long flags;
5645 cuckoo_hash_mac_key key = cuckoo_mac_to_key(mac);
5646 struct port_fwd *fwd_set = (struct port_fwd *)fwd_priv;
5647+ DECLARE_MAC_BUF(buf);
5648
5649 BUG_ON(fwd_priv == NULL);
5650
5651- DPRINTK("Adding mac " MAC_FMT "\n", MAC_ARG(mac));
5652+ DPRINTK("Adding mac %s\n", print_mac(buf, mac));
5653
5654 spin_lock_irqsave(&fwd_set->fwd_lock, flags);
5655
5656@@ -199,8 +200,8 @@ int netback_accel_fwd_add(const __u8 *ma
5657 if (cuckoo_hash_lookup(&fwd_set->fwd_hash_table,
5658 (cuckoo_hash_key *)(&key), &rc) != 0) {
5659 spin_unlock_irqrestore(&fwd_set->fwd_lock, flags);
5660- EPRINTK("MAC address " MAC_FMT " already accelerated.\n",
5661- MAC_ARG(mac));
5662+ EPRINTK("MAC address %s already accelerated.\n",
5663+ print_mac(buf, mac));
5664 return -EEXIST;
5665 }
5666
5667@@ -235,8 +236,9 @@ void netback_accel_fwd_remove(const __u8
5668 unsigned long flags;
5669 cuckoo_hash_mac_key key = cuckoo_mac_to_key(mac);
5670 struct port_fwd *fwd_set = (struct port_fwd *)fwd_priv;
5671+ DECLARE_MAC_BUF(buf);
5672
5673- DPRINTK("Removing mac " MAC_FMT "\n", MAC_ARG(mac));
5674+ DPRINTK("Removing mac %s\n", print_mac(buf, mac));
5675
5676 BUG_ON(fwd_priv == NULL);
5677
5678@@ -394,14 +396,16 @@ void netback_accel_tx_packet(struct sk_b
5679
5680 if (is_broadcast_ether_addr(skb_mac_header(skb))
5681 && packet_is_arp_reply(skb)) {
5682+ DECLARE_MAC_BUF(buf);
5683+
5684 /*
5685 * update our fast path forwarding to reflect this
5686 * gratuitous ARP
5687 */
5688 mac = skb_mac_header(skb)+ETH_ALEN;
5689
5690- DPRINTK("%s: found gratuitous ARP for " MAC_FMT "\n",
5691- __FUNCTION__, MAC_ARG(mac));
5692+ DPRINTK("%s: found gratuitous ARP for %s\n",
5693+ __FUNCTION__, print_mac(buf, mac));
5694
5695 spin_lock_irqsave(&fwd_set->fwd_lock, flags);
5696 /*
5697Index: head-2008-12-01/drivers/xen/sfc_netback/accel_msg.c
5698===================================================================
5699--- head-2008-12-01.orig/drivers/xen/sfc_netback/accel_msg.c 2008-02-20 09:32:49.000000000 +0100
5700+++ head-2008-12-01/drivers/xen/sfc_netback/accel_msg.c 2008-12-01 11:36:55.000000000 +0100
5701@@ -57,11 +57,11 @@ static void netback_accel_msg_tx_localma
5702 {
5703 unsigned long lock_state;
5704 struct net_accel_msg *msg;
5705+ DECLARE_MAC_BUF(buf);
5706
5707 BUG_ON(bend == NULL || mac == NULL);
5708
5709- VPRINTK("Sending local mac message: " MAC_FMT "\n",
5710- MAC_ARG((const char *)mac));
5711+ VPRINTK("Sending local mac message: %s\n", print_mac(buf, mac));
5712
5713 msg = net_accel_msg_start_send(bend->shared_page, &bend->to_domU,
5714 &lock_state);
5715Index: head-2008-12-01/drivers/xen/sfc_netfront/accel_msg.c
5716===================================================================
5717--- head-2008-12-01.orig/drivers/xen/sfc_netfront/accel_msg.c 2008-12-01 11:29:05.000000000 +0100
5718+++ head-2008-12-01/drivers/xen/sfc_netfront/accel_msg.c 2008-12-01 11:36:55.000000000 +0100
5719@@ -41,11 +41,13 @@ static void vnic_start_interrupts(netfro
5720 /* Prime our interrupt */
5721 spin_lock_irqsave(&vnic->irq_enabled_lock, flags);
5722 if (!netfront_accel_vi_enable_interrupts(vnic)) {
5723+ struct netfront_info *np = netdev_priv(vnic->net_dev);
5724+
5725 /* Cripes, that was quick, better pass it up */
5726 netfront_accel_disable_net_interrupts(vnic);
5727 vnic->irq_enabled = 0;
5728 NETFRONT_ACCEL_STATS_OP(vnic->stats.poll_schedule_count++);
5729- netif_rx_schedule(vnic->net_dev);
5730+ netif_rx_schedule(vnic->net_dev, &np->napi);
5731 } else {
5732 /*
5733 * Nothing yet, make sure we get interrupts through
5734@@ -72,6 +74,7 @@ static void vnic_stop_interrupts(netfron
5735 static void vnic_start_fastpath(netfront_accel_vnic *vnic)
5736 {
5737 struct net_device *net_dev = vnic->net_dev;
5738+ struct netfront_info *np = netdev_priv(net_dev);
5739 unsigned long flags;
5740
5741 DPRINTK("%s\n", __FUNCTION__);
5742@@ -80,9 +83,9 @@ static void vnic_start_fastpath(netfront
5743 vnic->tx_enabled = 1;
5744 spin_unlock_irqrestore(&vnic->tx_lock, flags);
5745
5746- netif_poll_disable(net_dev);
5747+ napi_disable(&np->napi);
5748 vnic->poll_enabled = 1;
5749- netif_poll_enable(net_dev);
5750+ napi_enable(&np->napi);
5751
5752 vnic_start_interrupts(vnic);
5753 }
5754@@ -114,11 +117,11 @@ void vnic_stop_fastpath(netfront_accel_v
5755 spin_unlock_irqrestore(&vnic->tx_lock, flags1);
5756
5757 /* Must prevent polls and hold lock to modify poll_enabled */
5758- netif_poll_disable(net_dev);
5759+ napi_disable(&np->napi);
5760 spin_lock_irqsave(&vnic->irq_enabled_lock, flags1);
5761 vnic->poll_enabled = 0;
5762 spin_unlock_irqrestore(&vnic->irq_enabled_lock, flags1);
5763- netif_poll_enable(net_dev);
5764+ napi_enable(&np->napi);
5765 }
5766
5767
5768@@ -326,8 +329,10 @@ static int vnic_process_localmac_msg(net
5769 cuckoo_hash_mac_key key;
5770
5771 if (msg->u.localmac.flags & NET_ACCEL_MSG_ADD) {
5772- DPRINTK("MAC has moved, could be local: " MAC_FMT "\n",
5773- MAC_ARG(msg->u.localmac.mac));
5774+ DECLARE_MAC_BUF(buf);
5775+
5776+ DPRINTK("MAC has moved, could be local: %s\n",
5777+ print_mac(buf, msg->u.localmac.mac));
5778 key = cuckoo_mac_to_key(msg->u.localmac.mac);
5779 spin_lock_irqsave(&vnic->table_lock, flags);
5780 /* Try to remove it, not a big deal if not there */
5781@@ -515,6 +520,8 @@ irqreturn_t netfront_accel_net_channel_i
5782
5783 spin_lock_irqsave(&vnic->irq_enabled_lock, flags);
5784 if (vnic->irq_enabled) {
5785+ struct netfront_info *np = netdev_priv(net_dev);
5786+
5787 netfront_accel_disable_net_interrupts(vnic);
5788 vnic->irq_enabled = 0;
5789 spin_unlock_irqrestore(&vnic->irq_enabled_lock, flags);
5790@@ -527,7 +534,7 @@ irqreturn_t netfront_accel_net_channel_i
5791 vnic->stats.event_count_since_irq;
5792 vnic->stats.event_count_since_irq = 0;
5793 #endif
5794- netif_rx_schedule(net_dev);
5795+ netif_rx_schedule(net_dev, &np->napi);
5796 }
5797 else {
5798 spin_unlock_irqrestore(&vnic->irq_enabled_lock, flags);
5799Index: head-2008-12-01/drivers/xen/sfc_netfront/accel_vi.c
5800===================================================================
5801--- head-2008-12-01.orig/drivers/xen/sfc_netfront/accel_vi.c 2008-12-01 11:36:13.000000000 +0100
5802+++ head-2008-12-01/drivers/xen/sfc_netfront/accel_vi.c 2008-12-01 11:36:55.000000000 +0100
5803@@ -641,8 +641,10 @@ netfront_accel_vi_tx_post(netfront_accel
5804 (cuckoo_hash_key *)(&key), &value);
5805
5806 if (!try_fastpath) {
5807- VPRINTK("try fast path false for mac: " MAC_FMT "\n",
5808- MAC_ARG(skb->data));
5809+ DECLARE_MAC_BUF(buf);
5810+
5811+ VPRINTK("try fast path false for mac: %s\n",
5812+ print_mac(buf, skb->data));
5813
5814 return NETFRONT_ACCEL_STATUS_CANT;
5815 }
5816@@ -768,9 +770,10 @@ static void netfront_accel_vi_rx_comple
5817 if (compare_ether_addr(skb->data, vnic->mac)) {
5818 struct iphdr *ip = (struct iphdr *)(skb->data + ETH_HLEN);
5819 u16 port;
5820+ DECLARE_MAC_BUF(buf);
5821
5822- DPRINTK("%s: saw wrong MAC address " MAC_FMT "\n",
5823- __FUNCTION__, MAC_ARG(skb->data));
5824+ DPRINTK("%s: saw wrong MAC address %s\n",
5825+ __FUNCTION__, print_mac(buf, skb->data));
5826
5827 if (ip->protocol == IPPROTO_TCP) {
5828 struct tcphdr *tcp = (struct tcphdr *)
5829Index: head-2008-12-01/drivers/xen/sfc_netutil/accel_util.h
5830===================================================================
5831--- head-2008-12-01.orig/drivers/xen/sfc_netutil/accel_util.h 2008-02-20 09:32:49.000000000 +0100
5832+++ head-2008-12-01/drivers/xen/sfc_netutil/accel_util.h 2008-12-01 11:36:55.000000000 +0100
5833@@ -63,9 +63,6 @@
5834 DPRINTK("%s at %s:%d\n", #exp, __FILE__, __LINE__); \
5835 } while(0)
5836
5837-#define MAC_FMT "%.2x:%.2x:%.2x:%.2x:%.2x:%.2x"
5838-#define MAC_ARG(_mac) (_mac)[0], (_mac)[1], (_mac)[2], (_mac)[3], (_mac)[4], (_mac)[5]
5839-
5840 #include <xen/xenbus.h>
5841
5842 /*! Map a set of pages from another domain
5843Index: head-2008-12-01/drivers/xen/xenbus/xenbus_probe.c
5844===================================================================
5845--- head-2008-12-01.orig/drivers/xen/xenbus/xenbus_probe.c 2008-12-01 11:36:47.000000000 +0100
5846+++ head-2008-12-01/drivers/xen/xenbus/xenbus_probe.c 2008-12-01 11:36:55.000000000 +0100
5847@@ -174,11 +174,9 @@ static int read_backend_details(struct x
5848 }
5849
5850 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16) && (defined(CONFIG_XEN) || defined(MODULE))
5851-static int xenbus_uevent_frontend(struct device *dev, char **envp,
5852- int num_envp, char *buffer, int buffer_size)
5853+static int xenbus_uevent_frontend(struct device *dev, struct kobj_uevent_env *env)
5854 {
5855 struct xenbus_device *xdev;
5856- int length = 0, i = 0;
5857
5858 if (dev == NULL)
5859 return -ENODEV;
5860@@ -187,12 +185,9 @@ static int xenbus_uevent_frontend(struct
5861 return -ENODEV;
5862
5863 /* stuff we want to pass to /sbin/hotplug */
5864- add_uevent_var(envp, num_envp, &i, buffer, buffer_size, &length,
5865- "XENBUS_TYPE=%s", xdev->devicetype);
5866- add_uevent_var(envp, num_envp, &i, buffer, buffer_size, &length,
5867- "XENBUS_PATH=%s", xdev->nodename);
5868- add_uevent_var(envp, num_envp, &i, buffer, buffer_size, &length,
5869- "MODALIAS=xen:%s", xdev->devicetype);
5870+ add_uevent_var(env, "XENBUS_TYPE=%s", xdev->devicetype);
5871+ add_uevent_var(env, "XENBUS_PATH=%s", xdev->nodename);
5872+ add_uevent_var(env, "MODALIAS=xen:%s", xdev->devicetype);
5873
5874 return 0;
5875 }
5876Index: head-2008-12-01/drivers/xen/xenbus/xenbus_probe_backend.c
5877===================================================================
5878--- head-2008-12-01.orig/drivers/xen/xenbus/xenbus_probe_backend.c 2008-12-01 11:36:47.000000000 +0100
5879+++ head-2008-12-01/drivers/xen/xenbus/xenbus_probe_backend.c 2008-12-01 11:36:55.000000000 +0100
5880@@ -60,8 +60,7 @@
5881 #include <xen/platform-compat.h>
5882 #endif
5883
5884-static int xenbus_uevent_backend(struct device *dev, char **envp,
5885- int num_envp, char *buffer, int buffer_size);
5886+static int xenbus_uevent_backend(struct device *dev, struct kobj_uevent_env *env);
5887 static int xenbus_probe_backend(const char *type, const char *domid);
5888
5889 extern int read_otherend_details(struct xenbus_device *xendev,
5890@@ -128,13 +127,10 @@ static struct xen_bus_type xenbus_backen
5891 },
5892 };
5893
5894-static int xenbus_uevent_backend(struct device *dev, char **envp,
5895- int num_envp, char *buffer, int buffer_size)
5896+static int xenbus_uevent_backend(struct device *dev, struct kobj_uevent_env *env)
5897 {
5898 struct xenbus_device *xdev;
5899 struct xenbus_driver *drv;
5900- int i = 0;
5901- int length = 0;
5902
5903 DPRINTK("");
5904
5905@@ -146,27 +142,16 @@ static int xenbus_uevent_backend(struct
5906 return -ENODEV;
5907
5908 /* stuff we want to pass to /sbin/hotplug */
5909- add_uevent_var(envp, num_envp, &i, buffer, buffer_size, &length,
5910- "XENBUS_TYPE=%s", xdev->devicetype);
5911+ add_uevent_var(env, "XENBUS_TYPE=%s", xdev->devicetype);
5912
5913- add_uevent_var(envp, num_envp, &i, buffer, buffer_size, &length,
5914- "XENBUS_PATH=%s", xdev->nodename);
5915+ add_uevent_var(env, "XENBUS_PATH=%s", xdev->nodename);
5916
5917- add_uevent_var(envp, num_envp, &i, buffer, buffer_size, &length,
5918- "XENBUS_BASE_PATH=%s", xenbus_backend.root);
5919-
5920- /* terminate, set to next free slot, shrink available space */
5921- envp[i] = NULL;
5922- envp = &envp[i];
5923- num_envp -= i;
5924- buffer = &buffer[length];
5925- buffer_size -= length;
5926+ add_uevent_var(env, "XENBUS_BASE_PATH=%s", xenbus_backend.root);
5927
5928 if (dev->driver) {
5929 drv = to_xenbus_driver(dev->driver);
5930 if (drv && drv->uevent)
5931- return drv->uevent(xdev, envp, num_envp, buffer,
5932- buffer_size);
5933+ return drv->uevent(xdev, env);
5934 }
5935
5936 return 0;
5937Index: head-2008-12-01/fs/xfs/linux-2.6/xfs_buf.c
5938===================================================================
5939--- head-2008-12-01.orig/fs/xfs/linux-2.6/xfs_buf.c 2008-12-01 10:53:14.000000000 +0100
5940+++ head-2008-12-01/fs/xfs/linux-2.6/xfs_buf.c 2008-12-01 11:36:55.000000000 +0100
5941@@ -187,7 +187,7 @@ free_address(
5942 {
5943 a_list_t *aentry;
5944
5945-#ifdef CONFIG_XEN
5946+#if defined(CONFIG_XEN) || defined(CONFIG_PARAVIRT_XEN)
5947 /*
5948 * Xen needs to be able to make sure it can get an exclusive
5949 * RO mapping of pages it wants to turn into a pagetable. If
5950Index: head-2008-12-01/include/asm-x86/mach-xen/asm/agp.h
5951===================================================================
5952--- head-2008-12-01.orig/include/asm-x86/mach-xen/asm/agp.h 2007-06-22 09:08:06.000000000 +0200
5953+++ head-2008-12-01/include/asm-x86/mach-xen/asm/agp.h 2008-12-01 11:36:55.000000000 +0100
5954@@ -1,20 +1,22 @@
5955-#ifndef AGP_H
5956-#define AGP_H 1
5957+#ifndef _ASM_X86_AGP_H
5958+#define _ASM_X86_AGP_H
5959
5960 #include <asm/pgtable.h>
5961 #include <asm/cacheflush.h>
5962 #include <asm/system.h>
5963
5964-/*
5965- * Functions to keep the agpgart mappings coherent with the MMU.
5966- * The GART gives the CPU a physical alias of pages in memory. The alias region is
5967- * mapped uncacheable. Make sure there are no conflicting mappings
5968- * with different cachability attributes for the same page. This avoids
5969- * data corruption on some CPUs.
5970+/*
5971+ * Functions to keep the agpgart mappings coherent with the MMU. The
5972+ * GART gives the CPU a physical alias of pages in memory. The alias
5973+ * region is mapped uncacheable. Make sure there are no conflicting
5974+ * mappings with different cachability attributes for the same
5975+ * page. This avoids data corruption on some CPUs.
5976 */
5977
5978-/* Caller's responsibility to call global_flush_tlb() for
5979- * performance reasons */
5980+/*
5981+ * Caller's responsibility to call global_flush_tlb() for performance
5982+ * reasons
5983+ */
5984 #define map_page_into_agp(page) ( \
5985 xen_create_contiguous_region((unsigned long)page_address(page), 0, 32) \
5986 ?: change_page_attr(page, 1, PAGE_KERNEL_NOCACHE))
5987@@ -24,9 +26,11 @@
5988 change_page_attr(page, 1, PAGE_KERNEL))
5989 #define flush_agp_mappings() global_flush_tlb()
5990
5991-/* Could use CLFLUSH here if the cpu supports it. But then it would
5992- need to be called for each cacheline of the whole page so it may not be
5993- worth it. Would need a page for it. */
5994+/*
5995+ * Could use CLFLUSH here if the cpu supports it. But then it would
5996+ * need to be called for each cacheline of the whole page so it may
5997+ * not be worth it. Would need a page for it.
5998+ */
5999 #define flush_agp_cache() wbinvd()
6000
6001 /* Convert a physical address to an address suitable for the GART. */
6002Index: head-2008-12-01/include/asm-x86/mach-xen/asm/desc.h
6003===================================================================
6004--- /dev/null 1970-01-01 00:00:00.000000000 +0000
6005+++ head-2008-12-01/include/asm-x86/mach-xen/asm/desc.h 2008-12-01 11:36:55.000000000 +0100
6006@@ -0,0 +1,5 @@
6007+#ifdef CONFIG_X86_32
6008+# include "desc_32.h"
6009+#else
6010+# include "desc_64.h"
6011+#endif
6012Index: head-2008-12-01/include/asm-x86/mach-xen/asm/desc_64.h
6013===================================================================
6014--- head-2008-12-01.orig/include/asm-x86/mach-xen/asm/desc_64.h 2008-12-01 11:36:13.000000000 +0100
6015+++ head-2008-12-01/include/asm-x86/mach-xen/asm/desc_64.h 2008-12-01 11:36:55.000000000 +0100
6016@@ -34,6 +34,18 @@ static inline void clear_LDT(void)
6017 put_cpu();
6018 }
6019
6020+#ifndef CONFIG_X86_NO_TSS
6021+static inline unsigned long __store_tr(void)
6022+{
6023+ unsigned long tr;
6024+
6025+ asm volatile ("str %w0":"=r" (tr));
6026+ return tr;
6027+}
6028+
6029+#define store_tr(tr) (tr) = __store_tr()
6030+#endif
6031+
6032 /*
6033 * This is the ldt that every process will get unless we need
6034 * something other than this.
6035@@ -47,6 +59,18 @@ extern struct desc_ptr cpu_gdt_descr[];
6036 /* the cpu gdt accessor */
6037 #define cpu_gdt(_cpu) ((struct desc_struct *)cpu_gdt_descr[_cpu].address)
6038
6039+#ifndef CONFIG_XEN
6040+static inline void load_gdt(const struct desc_ptr *ptr)
6041+{
6042+ asm volatile("lgdt %w0"::"m" (*ptr));
6043+}
6044+
6045+static inline void store_gdt(struct desc_ptr *ptr)
6046+{
6047+ asm("sgdt %w0":"=m" (*ptr));
6048+}
6049+#endif
6050+
6051 static inline void _set_gate(void *adr, unsigned type, unsigned long func, unsigned dpl, unsigned ist)
6052 {
6053 struct gate_struct s;
6054@@ -87,6 +111,16 @@ static inline void set_system_gate_ist(i
6055 {
6056 _set_gate(&idt_table[nr], GATE_INTERRUPT, (unsigned long) func, 3, ist);
6057 }
6058+
6059+static inline void load_idt(const struct desc_ptr *ptr)
6060+{
6061+ asm volatile("lidt %w0"::"m" (*ptr));
6062+}
6063+
6064+static inline void store_idt(struct desc_ptr *dtr)
6065+{
6066+ asm("sidt %w0":"=m" (*dtr));
6067+}
6068 #endif
6069
6070 static inline void set_tssldt_descriptor(void *ptr, unsigned long tss, unsigned type,
6071Index: head-2008-12-01/include/asm-x86/mach-xen/asm/dma-mapping.h
6072===================================================================
6073--- /dev/null 1970-01-01 00:00:00.000000000 +0000
6074+++ head-2008-12-01/include/asm-x86/mach-xen/asm/dma-mapping.h 2008-12-01 11:36:55.000000000 +0100
6075@@ -0,0 +1,5 @@
6076+#ifdef CONFIG_X86_32
6077+# include "dma-mapping_32.h"
6078+#else
6079+# include "dma-mapping_64.h"
6080+#endif
6081Index: head-2008-12-01/include/asm-x86/mach-xen/asm/dma-mapping_32.h
6082===================================================================
6083--- head-2008-12-01.orig/include/asm-x86/mach-xen/asm/dma-mapping_32.h 2008-12-01 11:32:38.000000000 +0100
6084+++ head-2008-12-01/include/asm-x86/mach-xen/asm/dma-mapping_32.h 2008-12-01 11:36:55.000000000 +0100
6085@@ -7,9 +7,9 @@
6086 */
6087
6088 #include <linux/mm.h>
6089+#include <linux/scatterlist.h>
6090 #include <asm/cache.h>
6091 #include <asm/io.h>
6092-#include <asm/scatterlist.h>
6093 #include <asm/swiotlb.h>
6094
6095 static inline int
6096Index: head-2008-12-01/include/asm-x86/mach-xen/asm/dma-mapping_64.h
6097===================================================================
6098--- head-2008-12-01.orig/include/asm-x86/mach-xen/asm/dma-mapping_64.h 2008-12-01 11:36:13.000000000 +0100
6099+++ head-2008-12-01/include/asm-x86/mach-xen/asm/dma-mapping_64.h 2008-12-01 11:36:55.000000000 +0100
6100@@ -6,8 +6,7 @@
6101 * documentation.
6102 */
6103
6104-
6105-#include <asm/scatterlist.h>
6106+#include <linux/scatterlist.h>
6107 #include <asm/io.h>
6108
6109 struct dma_mapping_ops {
6110@@ -203,4 +202,4 @@ extern int panic_on_overflow;
6111
6112 #endif /* _X8664_DMA_MAPPING_H */
6113
6114-#include <asm-i386/mach-xen/asm/dma-mapping.h>
6115+#include "dma-mapping_32.h"
6116Index: head-2008-12-01/include/asm-x86/mach-xen/asm/fixmap.h
6117===================================================================
6118--- /dev/null 1970-01-01 00:00:00.000000000 +0000
6119+++ head-2008-12-01/include/asm-x86/mach-xen/asm/fixmap.h 2008-12-01 11:36:55.000000000 +0100
6120@@ -0,0 +1,5 @@
6121+#ifdef CONFIG_X86_32
6122+# include "fixmap_32.h"
6123+#else
6124+# include "fixmap_64.h"
6125+#endif
6126Index: head-2008-12-01/include/asm-x86/mach-xen/asm/hypercall.h
6127===================================================================
6128--- /dev/null 1970-01-01 00:00:00.000000000 +0000
6129+++ head-2008-12-01/include/asm-x86/mach-xen/asm/hypercall.h 2008-12-01 11:36:55.000000000 +0100
6130@@ -0,0 +1,404 @@
6131+/******************************************************************************
6132+ * hypercall.h
6133+ *
6134+ * Linux-specific hypervisor handling.
6135+ *
6136+ * Copyright (c) 2002-2004, K A Fraser
6137+ *
6138+ * 64-bit updates:
6139+ * Benjamin Liu <benjamin.liu@intel.com>
6140+ * Jun Nakajima <jun.nakajima@intel.com>
6141+ *
6142+ * This program is free software; you can redistribute it and/or
6143+ * modify it under the terms of the GNU General Public License version 2
6144+ * as published by the Free Software Foundation; or, when distributed
6145+ * separately from the Linux kernel or incorporated into other
6146+ * software packages, subject to the following license:
6147+ *
6148+ * Permission is hereby granted, free of charge, to any person obtaining a copy
6149+ * of this source file (the "Software"), to deal in the Software without
6150+ * restriction, including without limitation the rights to use, copy, modify,
6151+ * merge, publish, distribute, sublicense, and/or sell copies of the Software,
6152+ * and to permit persons to whom the Software is furnished to do so, subject to
6153+ * the following conditions:
6154+ *
6155+ * The above copyright notice and this permission notice shall be included in
6156+ * all copies or substantial portions of the Software.
6157+ *
6158+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
6159+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
6160+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
6161+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
6162+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
6163+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
6164+ * IN THE SOFTWARE.
6165+ */
6166+
6167+#ifndef __HYPERCALL_H__
6168+#define __HYPERCALL_H__
6169+
6170+#ifndef __HYPERVISOR_H__
6171+# error "please don't include this file directly"
6172+#endif
6173+
6174+#if CONFIG_XEN_COMPAT <= 0x030002
6175+# include <linux/string.h> /* memcpy() */
6176+#endif
6177+
6178+#ifdef CONFIG_XEN
6179+#define HYPERCALL_ASM_OPERAND "%c"
6180+#define HYPERCALL_LOCATION(op) (hypercall_page + (op) * 32)
6181+#define HYPERCALL_C_OPERAND(name) "i" (HYPERCALL_LOCATION(__HYPERVISOR_##name))
6182+#else
6183+#define HYPERCALL_ASM_OPERAND "*%"
6184+#define HYPERCALL_LOCATION(op) (hypercall_stubs + (op) * 32)
6185+#define HYPERCALL_C_OPERAND(name) "g" (HYPERCALL_LOCATION(__HYPERVISOR_##name))
6186+#endif
6187+
6188+#define HYPERCALL_ARG(arg, n) \
6189+ register typeof((arg)+0) __arg##n asm(HYPERCALL_arg##n) = (arg)
6190+
6191+#define _hypercall0(type, name) \
6192+({ \
6193+ type __res; \
6194+ asm volatile ( \
6195+ "call " HYPERCALL_ASM_OPERAND "1" \
6196+ : "=a" (__res) \
6197+ : HYPERCALL_C_OPERAND(name) \
6198+ : "memory" ); \
6199+ __res; \
6200+})
6201+
6202+#define _hypercall1(type, name, arg) \
6203+({ \
6204+ type __res; \
6205+ HYPERCALL_ARG(arg, 1); \
6206+ asm volatile ( \
6207+ "call " HYPERCALL_ASM_OPERAND "2" \
6208+ : "=a" (__res), "+r" (__arg1) \
6209+ : HYPERCALL_C_OPERAND(name) \
6210+ : "memory" ); \
6211+ __res; \
6212+})
6213+
6214+#define _hypercall2(type, name, a1, a2) \
6215+({ \
6216+ type __res; \
6217+ HYPERCALL_ARG(a1, 1); \
6218+ HYPERCALL_ARG(a2, 2); \
6219+ asm volatile ( \
6220+ "call " HYPERCALL_ASM_OPERAND "3" \
6221+ : "=a" (__res), "+r" (__arg1), "+r" (__arg2) \
6222+ : HYPERCALL_C_OPERAND(name) \
6223+ : "memory" ); \
6224+ __res; \
6225+})
6226+
6227+#define _hypercall3(type, name, a1, a2, a3) \
6228+({ \
6229+ type __res; \
6230+ HYPERCALL_ARG(a1, 1); \
6231+ HYPERCALL_ARG(a2, 2); \
6232+ HYPERCALL_ARG(a3, 3); \
6233+ asm volatile ( \
6234+ "call " HYPERCALL_ASM_OPERAND "4" \
6235+ : "=a" (__res), "+r" (__arg1), \
6236+ "+r" (__arg2), "+r" (__arg3) \
6237+ : HYPERCALL_C_OPERAND(name) \
6238+ : "memory" ); \
6239+ __res; \
6240+})
6241+
6242+#define _hypercall4(type, name, a1, a2, a3, a4) \
6243+({ \
6244+ type __res; \
6245+ HYPERCALL_ARG(a1, 1); \
6246+ HYPERCALL_ARG(a2, 2); \
6247+ HYPERCALL_ARG(a3, 3); \
6248+ HYPERCALL_ARG(a4, 4); \
6249+ asm volatile ( \
6250+ "call " HYPERCALL_ASM_OPERAND "5" \
6251+ : "=a" (__res), "+r" (__arg1), "+r" (__arg2), \
6252+ "+r" (__arg3), "+r" (__arg4) \
6253+ : HYPERCALL_C_OPERAND(name) \
6254+ : "memory" ); \
6255+ __res; \
6256+})
6257+
6258+#define _hypercall5(type, name, a1, a2, a3, a4, a5) \
6259+({ \
6260+ type __res; \
6261+ HYPERCALL_ARG(a1, 1); \
6262+ HYPERCALL_ARG(a2, 2); \
6263+ HYPERCALL_ARG(a3, 3); \
6264+ HYPERCALL_ARG(a4, 4); \
6265+ HYPERCALL_ARG(a5, 5); \
6266+ asm volatile ( \
6267+ "call " HYPERCALL_ASM_OPERAND "6" \
6268+ : "=a" (__res), "+r" (__arg1), "+r" (__arg2), \
6269+ "+r" (__arg3), "+r" (__arg4), "+r" (__arg5) \
6270+ : HYPERCALL_C_OPERAND(name) \
6271+ : "memory" ); \
6272+ __res; \
6273+})
6274+
6275+#define _hypercall(type, op, a1, a2, a3, a4, a5) \
6276+({ \
6277+ type __res; \
6278+ HYPERCALL_ARG(a1, 1); \
6279+ HYPERCALL_ARG(a2, 2); \
6280+ HYPERCALL_ARG(a3, 3); \
6281+ HYPERCALL_ARG(a4, 4); \
6282+ HYPERCALL_ARG(a5, 5); \
6283+ asm volatile ( \
6284+ "call *%6" \
6285+ : "=a" (__res), "+r" (__arg1), "+r" (__arg2), \
6286+ "+r" (__arg3), "+r" (__arg4), "+r" (__arg5) \
6287+ : "g" (HYPERCALL_LOCATION(op)) \
6288+ : "memory" ); \
6289+ __res; \
6290+})
6291+
6292+#ifdef CONFIG_X86_32
6293+# include "hypercall_32.h"
6294+#else
6295+# include "hypercall_64.h"
6296+#endif
6297+
6298+static inline int __must_check
6299+HYPERVISOR_set_trap_table(
6300+ const trap_info_t *table)
6301+{
6302+ return _hypercall1(int, set_trap_table, table);
6303+}
6304+
6305+static inline int __must_check
6306+HYPERVISOR_mmu_update(
6307+ mmu_update_t *req, unsigned int count, unsigned int *success_count,
6308+ domid_t domid)
6309+{
6310+ if (arch_use_lazy_mmu_mode())
6311+ return xen_multi_mmu_update(req, count, success_count, domid);
6312+ return _hypercall4(int, mmu_update, req, count, success_count, domid);
6313+}
6314+
6315+static inline int __must_check
6316+HYPERVISOR_mmuext_op(
6317+ struct mmuext_op *op, unsigned int count, unsigned int *success_count,
6318+ domid_t domid)
6319+{
6320+ if (arch_use_lazy_mmu_mode())
6321+ return xen_multi_mmuext_op(op, count, success_count, domid);
6322+ return _hypercall4(int, mmuext_op, op, count, success_count, domid);
6323+}
6324+
6325+static inline int __must_check
6326+HYPERVISOR_set_gdt(
6327+ unsigned long *frame_list, unsigned int entries)
6328+{
6329+ return _hypercall2(int, set_gdt, frame_list, entries);
6330+}
6331+
6332+static inline int __must_check
6333+HYPERVISOR_stack_switch(
6334+ unsigned long ss, unsigned long esp)
6335+{
6336+ return _hypercall2(int, stack_switch, ss, esp);
6337+}
6338+
6339+static inline int
6340+HYPERVISOR_fpu_taskswitch(
6341+ int set)
6342+{
6343+ return _hypercall1(int, fpu_taskswitch, set);
6344+}
6345+
6346+#if CONFIG_XEN_COMPAT <= 0x030002
6347+static inline int __must_check
6348+HYPERVISOR_sched_op_compat(
6349+ int cmd, unsigned long arg)
6350+{
6351+ return _hypercall2(int, sched_op_compat, cmd, arg);
6352+}
6353+#endif
6354+
6355+static inline int __must_check
6356+HYPERVISOR_sched_op(
6357+ int cmd, void *arg)
6358+{
6359+ return _hypercall2(int, sched_op, cmd, arg);
6360+}
6361+
6362+static inline int __must_check
6363+HYPERVISOR_platform_op(
6364+ struct xen_platform_op *platform_op)
6365+{
6366+ platform_op->interface_version = XENPF_INTERFACE_VERSION;
6367+ return _hypercall1(int, platform_op, platform_op);
6368+}
6369+
6370+static inline int __must_check
6371+HYPERVISOR_set_debugreg(
6372+ unsigned int reg, unsigned long value)
6373+{
6374+ return _hypercall2(int, set_debugreg, reg, value);
6375+}
6376+
6377+static inline unsigned long __must_check
6378+HYPERVISOR_get_debugreg(
6379+ unsigned int reg)
6380+{
6381+ return _hypercall1(unsigned long, get_debugreg, reg);
6382+}
6383+
6384+static inline int __must_check
6385+HYPERVISOR_memory_op(
6386+ unsigned int cmd, void *arg)
6387+{
6388+ if (arch_use_lazy_mmu_mode())
6389+ xen_multicall_flush(false);
6390+ return _hypercall2(int, memory_op, cmd, arg);
6391+}
6392+
6393+static inline int __must_check
6394+HYPERVISOR_multicall(
6395+ multicall_entry_t *call_list, unsigned int nr_calls)
6396+{
6397+ return _hypercall2(int, multicall, call_list, nr_calls);
6398+}
6399+
6400+static inline int __must_check
6401+HYPERVISOR_event_channel_op(
6402+ int cmd, void *arg)
6403+{
6404+ int rc = _hypercall2(int, event_channel_op, cmd, arg);
6405+
6406+#if CONFIG_XEN_COMPAT <= 0x030002
6407+ if (unlikely(rc == -ENOSYS)) {
6408+ struct evtchn_op op;
6409+ op.cmd = cmd;
6410+ memcpy(&op.u, arg, sizeof(op.u));
6411+ rc = _hypercall1(int, event_channel_op_compat, &op);
6412+ memcpy(arg, &op.u, sizeof(op.u));
6413+ }
6414+#endif
6415+
6416+ return rc;
6417+}
6418+
6419+static inline int __must_check
6420+HYPERVISOR_xen_version(
6421+ int cmd, void *arg)
6422+{
6423+ return _hypercall2(int, xen_version, cmd, arg);
6424+}
6425+
6426+static inline int __must_check
6427+HYPERVISOR_console_io(
6428+ int cmd, unsigned int count, char *str)
6429+{
6430+ return _hypercall3(int, console_io, cmd, count, str);
6431+}
6432+
6433+static inline int __must_check
6434+HYPERVISOR_physdev_op(
6435+ int cmd, void *arg)
6436+{
6437+ int rc = _hypercall2(int, physdev_op, cmd, arg);
6438+
6439+#if CONFIG_XEN_COMPAT <= 0x030002
6440+ if (unlikely(rc == -ENOSYS)) {
6441+ struct physdev_op op;
6442+ op.cmd = cmd;
6443+ memcpy(&op.u, arg, sizeof(op.u));
6444+ rc = _hypercall1(int, physdev_op_compat, &op);
6445+ memcpy(arg, &op.u, sizeof(op.u));
6446+ }
6447+#endif
6448+
6449+ return rc;
6450+}
6451+
6452+static inline int __must_check
6453+HYPERVISOR_grant_table_op(
6454+ unsigned int cmd, void *uop, unsigned int count)
6455+{
6456+ if (arch_use_lazy_mmu_mode())
6457+ xen_multicall_flush(false);
6458+ return _hypercall3(int, grant_table_op, cmd, uop, count);
6459+}
6460+
6461+static inline int __must_check
6462+HYPERVISOR_vm_assist(
6463+ unsigned int cmd, unsigned int type)
6464+{
6465+ return _hypercall2(int, vm_assist, cmd, type);
6466+}
6467+
6468+static inline int __must_check
6469+HYPERVISOR_vcpu_op(
6470+ int cmd, unsigned int vcpuid, void *extra_args)
6471+{
6472+ return _hypercall3(int, vcpu_op, cmd, vcpuid, extra_args);
6473+}
6474+
6475+static inline int __must_check
6476+HYPERVISOR_suspend(
6477+ unsigned long srec)
6478+{
6479+ struct sched_shutdown sched_shutdown = {
6480+ .reason = SHUTDOWN_suspend
6481+ };
6482+
6483+ int rc = _hypercall3(int, sched_op, SCHEDOP_shutdown,
6484+ &sched_shutdown, srec);
6485+
6486+#if CONFIG_XEN_COMPAT <= 0x030002
6487+ if (rc == -ENOSYS)
6488+ rc = _hypercall3(int, sched_op_compat, SCHEDOP_shutdown,
6489+ SHUTDOWN_suspend, srec);
6490+#endif
6491+
6492+ return rc;
6493+}
6494+
6495+#if CONFIG_XEN_COMPAT <= 0x030002
6496+static inline int
6497+HYPERVISOR_nmi_op(
6498+ unsigned long op, void *arg)
6499+{
6500+ return _hypercall2(int, nmi_op, op, arg);
6501+}
6502+#endif
6503+
6504+#ifndef CONFIG_XEN
6505+static inline unsigned long __must_check
6506+HYPERVISOR_hvm_op(
6507+ int op, void *arg)
6508+{
6509+ return _hypercall2(unsigned long, hvm_op, op, arg);
6510+}
6511+#endif
6512+
6513+static inline int __must_check
6514+HYPERVISOR_callback_op(
6515+ int cmd, const void *arg)
6516+{
6517+ return _hypercall2(int, callback_op, cmd, arg);
6518+}
6519+
6520+static inline int __must_check
6521+HYPERVISOR_xenoprof_op(
6522+ int op, void *arg)
6523+{
6524+ return _hypercall2(int, xenoprof_op, op, arg);
6525+}
6526+
6527+static inline int __must_check
6528+HYPERVISOR_kexec_op(
6529+ unsigned long op, void *args)
6530+{
6531+ return _hypercall2(int, kexec_op, op, args);
6532+}
6533+
6534+#endif /* __HYPERCALL_H__ */
6535Index: head-2008-12-01/include/asm-x86/mach-xen/asm/hypercall_32.h
6536===================================================================
6537--- head-2008-12-01.orig/include/asm-x86/mach-xen/asm/hypercall_32.h 2008-12-01 11:29:05.000000000 +0100
6538+++ head-2008-12-01/include/asm-x86/mach-xen/asm/hypercall_32.h 2008-12-01 11:36:55.000000000 +0100
6539@@ -1,191 +1,10 @@
6540-/******************************************************************************
6541- * hypercall.h
6542- *
6543- * Linux-specific hypervisor handling.
6544- *
6545- * Copyright (c) 2002-2004, K A Fraser
6546- *
6547- * This program is free software; you can redistribute it and/or
6548- * modify it under the terms of the GNU General Public License version 2
6549- * as published by the Free Software Foundation; or, when distributed
6550- * separately from the Linux kernel or incorporated into other
6551- * software packages, subject to the following license:
6552- *
6553- * Permission is hereby granted, free of charge, to any person obtaining a copy
6554- * of this source file (the "Software"), to deal in the Software without
6555- * restriction, including without limitation the rights to use, copy, modify,
6556- * merge, publish, distribute, sublicense, and/or sell copies of the Software,
6557- * and to permit persons to whom the Software is furnished to do so, subject to
6558- * the following conditions:
6559- *
6560- * The above copyright notice and this permission notice shall be included in
6561- * all copies or substantial portions of the Software.
6562- *
6563- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
6564- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
6565- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
6566- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
6567- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
6568- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
6569- * IN THE SOFTWARE.
6570- */
6571-
6572-#ifndef __HYPERCALL_H__
6573-#define __HYPERCALL_H__
6574-
6575-#include <linux/string.h> /* memcpy() */
6576-#include <linux/stringify.h>
6577-
6578-#ifndef __HYPERVISOR_H__
6579-# error "please don't include this file directly"
6580-#endif
6581-
6582-#ifdef CONFIG_XEN
6583-#define HYPERCALL_STR(name) \
6584- "call hypercall_page + ("__stringify(__HYPERVISOR_##name)" * 32)"
6585-#else
6586-#define HYPERCALL_STR(name) \
6587- "mov hypercall_stubs,%%eax; " \
6588- "add $("__stringify(__HYPERVISOR_##name)" * 32),%%eax; "\
6589- "call *%%eax"
6590-#endif
6591-
6592-#define _hypercall0(type, name) \
6593-({ \
6594- type __res; \
6595- asm volatile ( \
6596- HYPERCALL_STR(name) \
6597- : "=a" (__res) \
6598- : \
6599- : "memory" ); \
6600- __res; \
6601-})
6602-
6603-#define _hypercall1(type, name, a1) \
6604-({ \
6605- type __res; \
6606- long __ign1; \
6607- asm volatile ( \
6608- HYPERCALL_STR(name) \
6609- : "=a" (__res), "=b" (__ign1) \
6610- : "1" ((long)(a1)) \
6611- : "memory" ); \
6612- __res; \
6613-})
6614-
6615-#define _hypercall2(type, name, a1, a2) \
6616-({ \
6617- type __res; \
6618- long __ign1, __ign2; \
6619- asm volatile ( \
6620- HYPERCALL_STR(name) \
6621- : "=a" (__res), "=b" (__ign1), "=c" (__ign2) \
6622- : "1" ((long)(a1)), "2" ((long)(a2)) \
6623- : "memory" ); \
6624- __res; \
6625-})
6626-
6627-#define _hypercall3(type, name, a1, a2, a3) \
6628-({ \
6629- type __res; \
6630- long __ign1, __ign2, __ign3; \
6631- asm volatile ( \
6632- HYPERCALL_STR(name) \
6633- : "=a" (__res), "=b" (__ign1), "=c" (__ign2), \
6634- "=d" (__ign3) \
6635- : "1" ((long)(a1)), "2" ((long)(a2)), \
6636- "3" ((long)(a3)) \
6637- : "memory" ); \
6638- __res; \
6639-})
6640-
6641-#define _hypercall4(type, name, a1, a2, a3, a4) \
6642-({ \
6643- type __res; \
6644- long __ign1, __ign2, __ign3, __ign4; \
6645- asm volatile ( \
6646- HYPERCALL_STR(name) \
6647- : "=a" (__res), "=b" (__ign1), "=c" (__ign2), \
6648- "=d" (__ign3), "=S" (__ign4) \
6649- : "1" ((long)(a1)), "2" ((long)(a2)), \
6650- "3" ((long)(a3)), "4" ((long)(a4)) \
6651- : "memory" ); \
6652- __res; \
6653-})
6654-
6655-#define _hypercall5(type, name, a1, a2, a3, a4, a5) \
6656-({ \
6657- type __res; \
6658- long __ign1, __ign2, __ign3, __ign4, __ign5; \
6659- asm volatile ( \
6660- HYPERCALL_STR(name) \
6661- : "=a" (__res), "=b" (__ign1), "=c" (__ign2), \
6662- "=d" (__ign3), "=S" (__ign4), "=D" (__ign5) \
6663- : "1" ((long)(a1)), "2" ((long)(a2)), \
6664- "3" ((long)(a3)), "4" ((long)(a4)), \
6665- "5" ((long)(a5)) \
6666- : "memory" ); \
6667- __res; \
6668-})
6669-
6670-#define _hypercall(type, op, a1, a2, a3, a4, a5) \
6671-({ \
6672- type __res; \
6673- register typeof((a1)+0) __arg1 asm("ebx") = (a1); \
6674- register typeof((a2)+0) __arg2 asm("ecx") = (a2); \
6675- register typeof((a3)+0) __arg3 asm("edx") = (a3); \
6676- register typeof((a4)+0) __arg4 asm("esi") = (a4); \
6677- register typeof((a5)+0) __arg5 asm("edi") = (a5); \
6678- asm volatile ( \
6679- "call *%6" \
6680- : "=a" (__res), "+r" (__arg1), "+r" (__arg2), \
6681- "+r" (__arg3), "+r" (__arg4), "+r" (__arg5) \
6682- : "0" (hypercall_page + (op) * 32) \
6683- : "memory" ); \
6684- __res; \
6685-})
6686-
6687-static inline int __must_check
6688-HYPERVISOR_set_trap_table(
6689- const trap_info_t *table)
6690-{
6691- return _hypercall1(int, set_trap_table, table);
6692-}
6693-
6694-static inline int __must_check
6695-HYPERVISOR_mmu_update(
6696- mmu_update_t *req, unsigned int count, unsigned int *success_count,
6697- domid_t domid)
6698-{
6699- if (arch_use_lazy_mmu_mode())
6700- return xen_multi_mmu_update(req, count, success_count, domid);
6701- return _hypercall4(int, mmu_update, req, count, success_count, domid);
6702-}
6703-
6704-static inline int __must_check
6705-HYPERVISOR_mmuext_op(
6706- struct mmuext_op *op, unsigned int count, unsigned int *success_count,
6707- domid_t domid)
6708-{
6709- if (arch_use_lazy_mmu_mode())
6710- return xen_multi_mmuext_op(op, count, success_count, domid);
6711- return _hypercall4(int, mmuext_op, op, count, success_count, domid);
6712-}
6713-
6714-static inline int __must_check
6715-HYPERVISOR_set_gdt(
6716- unsigned long *frame_list, unsigned int entries)
6717-{
6718- return _hypercall2(int, set_gdt, frame_list, entries);
6719-}
6720-
6721-static inline int __must_check
6722-HYPERVISOR_stack_switch(
6723- unsigned long ss, unsigned long esp)
6724-{
6725- return _hypercall2(int, stack_switch, ss, esp);
6726-}
6727+#define HYPERCALL_arg1 "ebx"
6728+#define HYPERCALL_arg2 "ecx"
6729+#define HYPERCALL_arg3 "edx"
6730+#define HYPERCALL_arg4 "esi"
6731+#define HYPERCALL_arg5 "edi"
6732
6733+#if CONFIG_XEN_COMPAT <= 0x030002
6734 static inline int __must_check
6735 HYPERVISOR_set_callbacks(
6736 unsigned long event_selector, unsigned long event_address,
6737@@ -195,80 +14,24 @@ HYPERVISOR_set_callbacks(
6738 event_selector, event_address,
6739 failsafe_selector, failsafe_address);
6740 }
6741-
6742-static inline int
6743-HYPERVISOR_fpu_taskswitch(
6744- int set)
6745-{
6746- return _hypercall1(int, fpu_taskswitch, set);
6747-}
6748-
6749-static inline int __must_check
6750-HYPERVISOR_sched_op_compat(
6751- int cmd, unsigned long arg)
6752-{
6753- return _hypercall2(int, sched_op_compat, cmd, arg);
6754-}
6755-
6756-static inline int __must_check
6757-HYPERVISOR_sched_op(
6758- int cmd, void *arg)
6759-{
6760- return _hypercall2(int, sched_op, cmd, arg);
6761-}
6762+#endif
6763
6764 static inline long __must_check
6765 HYPERVISOR_set_timer_op(
6766 u64 timeout)
6767 {
6768- unsigned long timeout_hi = (unsigned long)(timeout>>32);
6769- unsigned long timeout_lo = (unsigned long)timeout;
6770- return _hypercall2(long, set_timer_op, timeout_lo, timeout_hi);
6771-}
6772-
6773-static inline int __must_check
6774-HYPERVISOR_platform_op(
6775- struct xen_platform_op *platform_op)
6776-{
6777- platform_op->interface_version = XENPF_INTERFACE_VERSION;
6778- return _hypercall1(int, platform_op, platform_op);
6779-}
6780-
6781-static inline int __must_check
6782-HYPERVISOR_set_debugreg(
6783- unsigned int reg, unsigned long value)
6784-{
6785- return _hypercall2(int, set_debugreg, reg, value);
6786-}
6787-
6788-static inline unsigned long __must_check
6789-HYPERVISOR_get_debugreg(
6790- unsigned int reg)
6791-{
6792- return _hypercall1(unsigned long, get_debugreg, reg);
6793+ return _hypercall2(long, set_timer_op,
6794+ (unsigned long)timeout,
6795+ (unsigned long)(timeout>>32));
6796 }
6797
6798 static inline int __must_check
6799 HYPERVISOR_update_descriptor(
6800 u64 ma, u64 desc)
6801 {
6802- return _hypercall4(int, update_descriptor, ma, ma>>32, desc, desc>>32);
6803-}
6804-
6805-static inline int __must_check
6806-HYPERVISOR_memory_op(
6807- unsigned int cmd, void *arg)
6808-{
6809- if (arch_use_lazy_mmu_mode())
6810- xen_multicall_flush(false);
6811- return _hypercall2(int, memory_op, cmd, arg);
6812-}
6813-
6814-static inline int __must_check
6815-HYPERVISOR_multicall(
6816- multicall_entry_t *call_list, unsigned int nr_calls)
6817-{
6818- return _hypercall2(int, multicall, call_list, nr_calls);
6819+ return _hypercall4(int, update_descriptor,
6820+ (unsigned long)ma, (unsigned long)(ma>>32),
6821+ (unsigned long)desc, (unsigned long)(desc>>32));
6822 }
6823
6824 static inline int __must_check
6825@@ -287,67 +50,6 @@ HYPERVISOR_update_va_mapping(
6826 }
6827
6828 static inline int __must_check
6829-HYPERVISOR_event_channel_op(
6830- int cmd, void *arg)
6831-{
6832- int rc = _hypercall2(int, event_channel_op, cmd, arg);
6833-
6834-#if CONFIG_XEN_COMPAT <= 0x030002
6835- if (unlikely(rc == -ENOSYS)) {
6836- struct evtchn_op op;
6837- op.cmd = cmd;
6838- memcpy(&op.u, arg, sizeof(op.u));
6839- rc = _hypercall1(int, event_channel_op_compat, &op);
6840- memcpy(arg, &op.u, sizeof(op.u));
6841- }
6842-#endif
6843-
6844- return rc;
6845-}
6846-
6847-static inline int __must_check
6848-HYPERVISOR_xen_version(
6849- int cmd, void *arg)
6850-{
6851- return _hypercall2(int, xen_version, cmd, arg);
6852-}
6853-
6854-static inline int __must_check
6855-HYPERVISOR_console_io(
6856- int cmd, unsigned int count, char *str)
6857-{
6858- return _hypercall3(int, console_io, cmd, count, str);
6859-}
6860-
6861-static inline int __must_check
6862-HYPERVISOR_physdev_op(
6863- int cmd, void *arg)
6864-{
6865- int rc = _hypercall2(int, physdev_op, cmd, arg);
6866-
6867-#if CONFIG_XEN_COMPAT <= 0x030002
6868- if (unlikely(rc == -ENOSYS)) {
6869- struct physdev_op op;
6870- op.cmd = cmd;
6871- memcpy(&op.u, arg, sizeof(op.u));
6872- rc = _hypercall1(int, physdev_op_compat, &op);
6873- memcpy(arg, &op.u, sizeof(op.u));
6874- }
6875-#endif
6876-
6877- return rc;
6878-}
6879-
6880-static inline int __must_check
6881-HYPERVISOR_grant_table_op(
6882- unsigned int cmd, void *uop, unsigned int count)
6883-{
6884- if (arch_use_lazy_mmu_mode())
6885- xen_multicall_flush(false);
6886- return _hypercall3(int, grant_table_op, cmd, uop, count);
6887-}
6888-
6889-static inline int __must_check
6890 HYPERVISOR_update_va_mapping_otherdomain(
6891 unsigned long va, pte_t new_val, unsigned long flags, domid_t domid)
6892 {
6893@@ -358,80 +60,3 @@ HYPERVISOR_update_va_mapping_otherdomain
6894 return _hypercall5(int, update_va_mapping_otherdomain, va,
6895 new_val.pte_low, pte_hi, flags, domid);
6896 }
6897-
6898-static inline int __must_check
6899-HYPERVISOR_vm_assist(
6900- unsigned int cmd, unsigned int type)
6901-{
6902- return _hypercall2(int, vm_assist, cmd, type);
6903-}
6904-
6905-static inline int __must_check
6906-HYPERVISOR_vcpu_op(
6907- int cmd, unsigned int vcpuid, void *extra_args)
6908-{
6909- return _hypercall3(int, vcpu_op, cmd, vcpuid, extra_args);
6910-}
6911-
6912-static inline int __must_check
6913-HYPERVISOR_suspend(
6914- unsigned long srec)
6915-{
6916- struct sched_shutdown sched_shutdown = {
6917- .reason = SHUTDOWN_suspend
6918- };
6919-
6920- int rc = _hypercall3(int, sched_op, SCHEDOP_shutdown,
6921- &sched_shutdown, srec);
6922-
6923-#if CONFIG_XEN_COMPAT <= 0x030002
6924- if (rc == -ENOSYS)
6925- rc = _hypercall3(int, sched_op_compat, SCHEDOP_shutdown,
6926- SHUTDOWN_suspend, srec);
6927-#endif
6928-
6929- return rc;
6930-}
6931-
6932-#if CONFIG_XEN_COMPAT <= 0x030002
6933-static inline int
6934-HYPERVISOR_nmi_op(
6935- unsigned long op, void *arg)
6936-{
6937- return _hypercall2(int, nmi_op, op, arg);
6938-}
6939-#endif
6940-
6941-#ifndef CONFIG_XEN
6942-static inline unsigned long __must_check
6943-HYPERVISOR_hvm_op(
6944- int op, void *arg)
6945-{
6946- return _hypercall2(unsigned long, hvm_op, op, arg);
6947-}
6948-#endif
6949-
6950-static inline int __must_check
6951-HYPERVISOR_callback_op(
6952- int cmd, const void *arg)
6953-{
6954- return _hypercall2(int, callback_op, cmd, arg);
6955-}
6956-
6957-static inline int __must_check
6958-HYPERVISOR_xenoprof_op(
6959- int op, void *arg)
6960-{
6961- return _hypercall2(int, xenoprof_op, op, arg);
6962-}
6963-
6964-static inline int __must_check
6965-HYPERVISOR_kexec_op(
6966- unsigned long op, void *args)
6967-{
6968- return _hypercall2(int, kexec_op, op, args);
6969-}
6970-
6971-
6972-
6973-#endif /* __HYPERCALL_H__ */
6974Index: head-2008-12-01/include/asm-x86/mach-xen/asm/hypercall_64.h
6975===================================================================
6976--- head-2008-12-01.orig/include/asm-x86/mach-xen/asm/hypercall_64.h 2008-12-01 11:29:05.000000000 +0100
6977+++ head-2008-12-01/include/asm-x86/mach-xen/asm/hypercall_64.h 2008-12-01 11:36:55.000000000 +0100
6978@@ -1,197 +1,10 @@
6979-/******************************************************************************
6980- * hypercall.h
6981- *
6982- * Linux-specific hypervisor handling.
6983- *
6984- * Copyright (c) 2002-2004, K A Fraser
6985- *
6986- * 64-bit updates:
6987- * Benjamin Liu <benjamin.liu@intel.com>
6988- * Jun Nakajima <jun.nakajima@intel.com>
6989- *
6990- * This program is free software; you can redistribute it and/or
6991- * modify it under the terms of the GNU General Public License version 2
6992- * as published by the Free Software Foundation; or, when distributed
6993- * separately from the Linux kernel or incorporated into other
6994- * software packages, subject to the following license:
6995- *
6996- * Permission is hereby granted, free of charge, to any person obtaining a copy
6997- * of this source file (the "Software"), to deal in the Software without
6998- * restriction, including without limitation the rights to use, copy, modify,
6999- * merge, publish, distribute, sublicense, and/or sell copies of the Software,
7000- * and to permit persons to whom the Software is furnished to do so, subject to
7001- * the following conditions:
7002- *
7003- * The above copyright notice and this permission notice shall be included in
7004- * all copies or substantial portions of the Software.
7005- *
7006- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
7007- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
7008- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
7009- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
7010- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
7011- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
7012- * IN THE SOFTWARE.
7013- */
7014-
7015-#ifndef __HYPERCALL_H__
7016-#define __HYPERCALL_H__
7017-
7018-#include <linux/string.h> /* memcpy() */
7019-#include <linux/stringify.h>
7020-
7021-#ifndef __HYPERVISOR_H__
7022-# error "please don't include this file directly"
7023-#endif
7024-
7025-#ifdef CONFIG_XEN
7026-#define HYPERCALL_STR(name) \
7027- "call hypercall_page + ("__stringify(__HYPERVISOR_##name)" * 32)"
7028-#else
7029-#define HYPERCALL_STR(name) \
7030- "mov $("__stringify(__HYPERVISOR_##name)" * 32),%%eax; "\
7031- "add hypercall_stubs(%%rip),%%rax; " \
7032- "call *%%rax"
7033-#endif
7034-
7035-#define _hypercall0(type, name) \
7036-({ \
7037- type __res; \
7038- asm volatile ( \
7039- HYPERCALL_STR(name) \
7040- : "=a" (__res) \
7041- : \
7042- : "memory" ); \
7043- __res; \
7044-})
7045-
7046-#define _hypercall1(type, name, a1) \
7047-({ \
7048- type __res; \
7049- long __ign1; \
7050- asm volatile ( \
7051- HYPERCALL_STR(name) \
7052- : "=a" (__res), "=D" (__ign1) \
7053- : "1" ((long)(a1)) \
7054- : "memory" ); \
7055- __res; \
7056-})
7057-
7058-#define _hypercall2(type, name, a1, a2) \
7059-({ \
7060- type __res; \
7061- long __ign1, __ign2; \
7062- asm volatile ( \
7063- HYPERCALL_STR(name) \
7064- : "=a" (__res), "=D" (__ign1), "=S" (__ign2) \
7065- : "1" ((long)(a1)), "2" ((long)(a2)) \
7066- : "memory" ); \
7067- __res; \
7068-})
7069-
7070-#define _hypercall3(type, name, a1, a2, a3) \
7071-({ \
7072- type __res; \
7073- long __ign1, __ign2, __ign3; \
7074- asm volatile ( \
7075- HYPERCALL_STR(name) \
7076- : "=a" (__res), "=D" (__ign1), "=S" (__ign2), \
7077- "=d" (__ign3) \
7078- : "1" ((long)(a1)), "2" ((long)(a2)), \
7079- "3" ((long)(a3)) \
7080- : "memory" ); \
7081- __res; \
7082-})
7083-
7084-#define _hypercall4(type, name, a1, a2, a3, a4) \
7085-({ \
7086- type __res; \
7087- long __ign1, __ign2, __ign3; \
7088- register long __arg4 asm("r10") = (long)(a4); \
7089- asm volatile ( \
7090- HYPERCALL_STR(name) \
7091- : "=a" (__res), "=D" (__ign1), "=S" (__ign2), \
7092- "=d" (__ign3), "+r" (__arg4) \
7093- : "1" ((long)(a1)), "2" ((long)(a2)), \
7094- "3" ((long)(a3)) \
7095- : "memory" ); \
7096- __res; \
7097-})
7098-
7099-#define _hypercall5(type, name, a1, a2, a3, a4, a5) \
7100-({ \
7101- type __res; \
7102- long __ign1, __ign2, __ign3; \
7103- register long __arg4 asm("r10") = (long)(a4); \
7104- register long __arg5 asm("r8") = (long)(a5); \
7105- asm volatile ( \
7106- HYPERCALL_STR(name) \
7107- : "=a" (__res), "=D" (__ign1), "=S" (__ign2), \
7108- "=d" (__ign3), "+r" (__arg4), "+r" (__arg5) \
7109- : "1" ((long)(a1)), "2" ((long)(a2)), \
7110- "3" ((long)(a3)) \
7111- : "memory" ); \
7112- __res; \
7113-})
7114-
7115-#define _hypercall(type, op, a1, a2, a3, a4, a5) \
7116-({ \
7117- type __res; \
7118- register typeof((a1)+0) __arg1 asm("rdi") = (a1); \
7119- register typeof((a2)+0) __arg2 asm("rsi") = (a2); \
7120- register typeof((a3)+0) __arg3 asm("rdx") = (a3); \
7121- register typeof((a4)+0) __arg4 asm("r10") = (a4); \
7122- register typeof((a5)+0) __arg5 asm("r8") = (a5); \
7123- asm volatile ( \
7124- "call *%6" \
7125- : "=a" (__res), "+r" (__arg1), "+r" (__arg2), \
7126- "+r" (__arg3), "+r" (__arg4), "+r" (__arg5) \
7127- : "0" (hypercall_page + (op) * 32) \
7128- : "memory" ); \
7129- __res; \
7130-})
7131-
7132-static inline int __must_check
7133-HYPERVISOR_set_trap_table(
7134- const trap_info_t *table)
7135-{
7136- return _hypercall1(int, set_trap_table, table);
7137-}
7138-
7139-static inline int __must_check
7140-HYPERVISOR_mmu_update(
7141- mmu_update_t *req, unsigned int count, unsigned int *success_count,
7142- domid_t domid)
7143-{
7144- if (arch_use_lazy_mmu_mode())
7145- return xen_multi_mmu_update(req, count, success_count, domid);
7146- return _hypercall4(int, mmu_update, req, count, success_count, domid);
7147-}
7148-
7149-static inline int __must_check
7150-HYPERVISOR_mmuext_op(
7151- struct mmuext_op *op, unsigned int count, unsigned int *success_count,
7152- domid_t domid)
7153-{
7154- if (arch_use_lazy_mmu_mode())
7155- return xen_multi_mmuext_op(op, count, success_count, domid);
7156- return _hypercall4(int, mmuext_op, op, count, success_count, domid);
7157-}
7158-
7159-static inline int __must_check
7160-HYPERVISOR_set_gdt(
7161- unsigned long *frame_list, unsigned int entries)
7162-{
7163- return _hypercall2(int, set_gdt, frame_list, entries);
7164-}
7165-
7166-static inline int __must_check
7167-HYPERVISOR_stack_switch(
7168- unsigned long ss, unsigned long esp)
7169-{
7170- return _hypercall2(int, stack_switch, ss, esp);
7171-}
7172+#define HYPERCALL_arg1 "rdi"
7173+#define HYPERCALL_arg2 "rsi"
7174+#define HYPERCALL_arg3 "rdx"
7175+#define HYPERCALL_arg4 "r10"
7176+#define HYPERCALL_arg5 "r8"
7177
7178+#if CONFIG_XEN_COMPAT <= 0x030002
7179 static inline int __must_check
7180 HYPERVISOR_set_callbacks(
7181 unsigned long event_address, unsigned long failsafe_address,
7182@@ -200,27 +13,7 @@ HYPERVISOR_set_callbacks(
7183 return _hypercall3(int, set_callbacks,
7184 event_address, failsafe_address, syscall_address);
7185 }
7186-
7187-static inline int
7188-HYPERVISOR_fpu_taskswitch(
7189- int set)
7190-{
7191- return _hypercall1(int, fpu_taskswitch, set);
7192-}
7193-
7194-static inline int __must_check
7195-HYPERVISOR_sched_op_compat(
7196- int cmd, unsigned long arg)
7197-{
7198- return _hypercall2(int, sched_op_compat, cmd, arg);
7199-}
7200-
7201-static inline int __must_check
7202-HYPERVISOR_sched_op(
7203- int cmd, void *arg)
7204-{
7205- return _hypercall2(int, sched_op, cmd, arg);
7206-}
7207+#endif
7208
7209 static inline long __must_check
7210 HYPERVISOR_set_timer_op(
7211@@ -230,28 +23,6 @@ HYPERVISOR_set_timer_op(
7212 }
7213
7214 static inline int __must_check
7215-HYPERVISOR_platform_op(
7216- struct xen_platform_op *platform_op)
7217-{
7218- platform_op->interface_version = XENPF_INTERFACE_VERSION;
7219- return _hypercall1(int, platform_op, platform_op);
7220-}
7221-
7222-static inline int __must_check
7223-HYPERVISOR_set_debugreg(
7224- unsigned int reg, unsigned long value)
7225-{
7226- return _hypercall2(int, set_debugreg, reg, value);
7227-}
7228-
7229-static inline unsigned long __must_check
7230-HYPERVISOR_get_debugreg(
7231- unsigned int reg)
7232-{
7233- return _hypercall1(unsigned long, get_debugreg, reg);
7234-}
7235-
7236-static inline int __must_check
7237 HYPERVISOR_update_descriptor(
7238 unsigned long ma, unsigned long word)
7239 {
7240@@ -259,22 +30,6 @@ HYPERVISOR_update_descriptor(
7241 }
7242
7243 static inline int __must_check
7244-HYPERVISOR_memory_op(
7245- unsigned int cmd, void *arg)
7246-{
7247- if (arch_use_lazy_mmu_mode())
7248- xen_multicall_flush(false);
7249- return _hypercall2(int, memory_op, cmd, arg);
7250-}
7251-
7252-static inline int __must_check
7253-HYPERVISOR_multicall(
7254- multicall_entry_t *call_list, unsigned int nr_calls)
7255-{
7256- return _hypercall2(int, multicall, call_list, nr_calls);
7257-}
7258-
7259-static inline int __must_check
7260 HYPERVISOR_update_va_mapping(
7261 unsigned long va, pte_t new_val, unsigned long flags)
7262 {
7263@@ -284,67 +39,6 @@ HYPERVISOR_update_va_mapping(
7264 }
7265
7266 static inline int __must_check
7267-HYPERVISOR_event_channel_op(
7268- int cmd, void *arg)
7269-{
7270- int rc = _hypercall2(int, event_channel_op, cmd, arg);
7271-
7272-#if CONFIG_XEN_COMPAT <= 0x030002
7273- if (unlikely(rc == -ENOSYS)) {
7274- struct evtchn_op op;
7275- op.cmd = cmd;
7276- memcpy(&op.u, arg, sizeof(op.u));
7277- rc = _hypercall1(int, event_channel_op_compat, &op);
7278- memcpy(arg, &op.u, sizeof(op.u));
7279- }
7280-#endif
7281-
7282- return rc;
7283-}
7284-
7285-static inline int __must_check
7286-HYPERVISOR_xen_version(
7287- int cmd, void *arg)
7288-{
7289- return _hypercall2(int, xen_version, cmd, arg);
7290-}
7291-
7292-static inline int __must_check
7293-HYPERVISOR_console_io(
7294- int cmd, unsigned int count, char *str)
7295-{
7296- return _hypercall3(int, console_io, cmd, count, str);
7297-}
7298-
7299-static inline int __must_check
7300-HYPERVISOR_physdev_op(
7301- int cmd, void *arg)
7302-{
7303- int rc = _hypercall2(int, physdev_op, cmd, arg);
7304-
7305-#if CONFIG_XEN_COMPAT <= 0x030002
7306- if (unlikely(rc == -ENOSYS)) {
7307- struct physdev_op op;
7308- op.cmd = cmd;
7309- memcpy(&op.u, arg, sizeof(op.u));
7310- rc = _hypercall1(int, physdev_op_compat, &op);
7311- memcpy(arg, &op.u, sizeof(op.u));
7312- }
7313-#endif
7314-
7315- return rc;
7316-}
7317-
7318-static inline int __must_check
7319-HYPERVISOR_grant_table_op(
7320- unsigned int cmd, void *uop, unsigned int count)
7321-{
7322- if (arch_use_lazy_mmu_mode())
7323- xen_multicall_flush(false);
7324- return _hypercall3(int, grant_table_op, cmd, uop, count);
7325-}
7326-
7327-static inline int __must_check
7328 HYPERVISOR_update_va_mapping_otherdomain(
7329 unsigned long va, pte_t new_val, unsigned long flags, domid_t domid)
7330 {
7331@@ -353,83 +47,8 @@ HYPERVISOR_update_va_mapping_otherdomain
7332 }
7333
7334 static inline int __must_check
7335-HYPERVISOR_vm_assist(
7336- unsigned int cmd, unsigned int type)
7337-{
7338- return _hypercall2(int, vm_assist, cmd, type);
7339-}
7340-
7341-static inline int __must_check
7342-HYPERVISOR_vcpu_op(
7343- int cmd, unsigned int vcpuid, void *extra_args)
7344-{
7345- return _hypercall3(int, vcpu_op, cmd, vcpuid, extra_args);
7346-}
7347-
7348-static inline int __must_check
7349 HYPERVISOR_set_segment_base(
7350 int reg, unsigned long value)
7351 {
7352 return _hypercall2(int, set_segment_base, reg, value);
7353 }
7354-
7355-static inline int __must_check
7356-HYPERVISOR_suspend(
7357- unsigned long srec)
7358-{
7359- struct sched_shutdown sched_shutdown = {
7360- .reason = SHUTDOWN_suspend
7361- };
7362-
7363- int rc = _hypercall3(int, sched_op, SCHEDOP_shutdown,
7364- &sched_shutdown, srec);
7365-
7366-#if CONFIG_XEN_COMPAT <= 0x030002
7367- if (rc == -ENOSYS)
7368- rc = _hypercall3(int, sched_op_compat, SCHEDOP_shutdown,
7369- SHUTDOWN_suspend, srec);
7370-#endif
7371-
7372- return rc;
7373-}
7374-
7375-#if CONFIG_XEN_COMPAT <= 0x030002
7376-static inline int
7377-HYPERVISOR_nmi_op(
7378- unsigned long op, void *arg)
7379-{
7380- return _hypercall2(int, nmi_op, op, arg);
7381-}
7382-#endif
7383-
7384-#ifndef CONFIG_XEN
7385-static inline unsigned long __must_check
7386-HYPERVISOR_hvm_op(
7387- int op, void *arg)
7388-{
7389- return _hypercall2(unsigned long, hvm_op, op, arg);
7390-}
7391-#endif
7392-
7393-static inline int __must_check
7394-HYPERVISOR_callback_op(
7395- int cmd, const void *arg)
7396-{
7397- return _hypercall2(int, callback_op, cmd, arg);
7398-}
7399-
7400-static inline int __must_check
7401-HYPERVISOR_xenoprof_op(
7402- int op, void *arg)
7403-{
7404- return _hypercall2(int, xenoprof_op, op, arg);
7405-}
7406-
7407-static inline int __must_check
7408-HYPERVISOR_kexec_op(
7409- unsigned long op, void *args)
7410-{
7411- return _hypercall2(int, kexec_op, op, args);
7412-}
7413-
7414-#endif /* __HYPERCALL_H__ */
7415Index: head-2008-12-01/include/asm-x86/mach-xen/asm/hypervisor.h
7416===================================================================
7417--- head-2008-12-01.orig/include/asm-x86/mach-xen/asm/hypervisor.h 2008-12-01 11:36:07.000000000 +0100
7418+++ head-2008-12-01/include/asm-x86/mach-xen/asm/hypervisor.h 2008-12-01 11:36:55.000000000 +0100
7419@@ -194,7 +194,6 @@ static inline void xen_multicall_flush(b
7420 extern char hypercall_page[PAGE_SIZE];
7421 #else
7422 extern char *hypercall_stubs;
7423-#define hypercall_page hypercall_stubs
7424 #define is_running_on_xen() (!!hypercall_stubs)
7425 #endif
7426
7427Index: head-2008-12-01/include/asm-x86/mach-xen/asm/io.h
7428===================================================================
7429--- /dev/null 1970-01-01 00:00:00.000000000 +0000
7430+++ head-2008-12-01/include/asm-x86/mach-xen/asm/io.h 2008-12-01 11:36:55.000000000 +0100
7431@@ -0,0 +1,5 @@
7432+#ifdef CONFIG_X86_32
7433+# include "io_32.h"
7434+#else
7435+# include "io_64.h"
7436+#endif
7437Index: head-2008-12-01/include/asm-x86/mach-xen/asm/io_32.h
7438===================================================================
7439--- head-2008-12-01.orig/include/asm-x86/mach-xen/asm/io_32.h 2008-12-01 11:36:47.000000000 +0100
7440+++ head-2008-12-01/include/asm-x86/mach-xen/asm/io_32.h 2008-12-01 11:36:55.000000000 +0100
7441@@ -212,17 +212,22 @@ static inline void writel(unsigned int b
7442
7443 #define mmiowb()
7444
7445-static inline void memset_io(volatile void __iomem *addr, unsigned char val, int count)
7446+static inline void
7447+memset_io(volatile void __iomem *addr, unsigned char val, int count)
7448 {
7449- memset((void __force *) addr, val, count);
7450+ memset((void __force *)addr, val, count);
7451 }
7452-static inline void memcpy_fromio(void *dst, const volatile void __iomem *src, int count)
7453+
7454+static inline void
7455+memcpy_fromio(void *dst, const volatile void __iomem *src, int count)
7456 {
7457- __memcpy(dst, (void __force *) src, count);
7458+ __memcpy(dst, (const void __force *)src, count);
7459 }
7460-static inline void memcpy_toio(volatile void __iomem *dst, const void *src, int count)
7461+
7462+static inline void
7463+memcpy_toio(volatile void __iomem *dst, const void *src, int count)
7464 {
7465- __memcpy((void __force *) dst, src, count);
7466+ __memcpy((void __force *)dst, src, count);
7467 }
7468
7469 /*
7470@@ -250,18 +255,9 @@ static inline void flush_write_buffers(v
7471 __asm__ __volatile__ ("lock; addl $0,0(%%esp)": : :"memory");
7472 }
7473
7474-#define dma_cache_inv(_start,_size) flush_write_buffers()
7475-#define dma_cache_wback(_start,_size) flush_write_buffers()
7476-#define dma_cache_wback_inv(_start,_size) flush_write_buffers()
7477-
7478 #else
7479
7480-/* Nothing to do */
7481-
7482-#define dma_cache_inv(_start,_size) do { } while (0)
7483-#define dma_cache_wback(_start,_size) do { } while (0)
7484-#define dma_cache_wback_inv(_start,_size) do { } while (0)
7485-#define flush_write_buffers()
7486+#define flush_write_buffers() do { } while (0)
7487
7488 #endif
7489
7490Index: head-2008-12-01/include/asm-x86/mach-xen/asm/io_64.h
7491===================================================================
7492--- head-2008-12-01.orig/include/asm-x86/mach-xen/asm/io_64.h 2008-12-01 11:36:47.000000000 +0100
7493+++ head-2008-12-01/include/asm-x86/mach-xen/asm/io_64.h 2008-12-01 11:36:55.000000000 +0100
7494@@ -268,12 +268,6 @@ void memset_io(volatile void __iomem *a,
7495 */
7496 #define __ISA_IO_base ((char __iomem *)(fix_to_virt(FIX_ISAMAP_BEGIN)))
7497
7498-/* Nothing to do */
7499-
7500-#define dma_cache_inv(_start,_size) do { } while (0)
7501-#define dma_cache_wback(_start,_size) do { } while (0)
7502-#define dma_cache_wback_inv(_start,_size) do { } while (0)
7503-
7504 #define flush_write_buffers()
7505
7506 extern int iommu_bio_merge;
7507Index: head-2008-12-01/include/asm-x86/mach-xen/asm/irqflags.h
7508===================================================================
7509--- /dev/null 1970-01-01 00:00:00.000000000 +0000
7510+++ head-2008-12-01/include/asm-x86/mach-xen/asm/irqflags.h 2008-12-01 11:36:55.000000000 +0100
7511@@ -0,0 +1,5 @@
7512+#ifdef CONFIG_X86_32
7513+# include "irqflags_32.h"
7514+#else
7515+# include "irqflags_64.h"
7516+#endif
7517Index: head-2008-12-01/include/asm-x86/mach-xen/asm/irqflags_32.h
7518===================================================================
7519--- head-2008-12-01.orig/include/asm-x86/mach-xen/asm/irqflags_32.h 2008-12-01 11:36:13.000000000 +0100
7520+++ head-2008-12-01/include/asm-x86/mach-xen/asm/irqflags_32.h 2008-12-01 11:36:55.000000000 +0100
7521@@ -148,6 +148,23 @@ static inline int raw_irqs_disabled_flag
7522 \
7523 raw_irqs_disabled_flags(flags); \
7524 })
7525+
7526+/*
7527+ * makes the traced hardirq state match with the machine state
7528+ *
7529+ * should be a rarely used function, only in places where its
7530+ * otherwise impossible to know the irq state, like in traps.
7531+ */
7532+static inline void trace_hardirqs_fixup_flags(unsigned long flags)
7533+{
7534+ if (raw_irqs_disabled_flags(flags))
7535+ trace_hardirqs_off();
7536+ else
7537+ trace_hardirqs_on();
7538+}
7539+
7540+#define trace_hardirqs_fixup() \
7541+ trace_hardirqs_fixup_flags(__raw_local_save_flags())
7542 #endif /* __ASSEMBLY__ */
7543
7544 /*
7545@@ -179,4 +196,17 @@ static inline int raw_irqs_disabled_flag
7546 # define TRACE_IRQS_OFF
7547 #endif
7548
7549+#ifdef CONFIG_DEBUG_LOCK_ALLOC
7550+# define LOCKDEP_SYS_EXIT \
7551+ pushl %eax; \
7552+ pushl %ecx; \
7553+ pushl %edx; \
7554+ call lockdep_sys_exit; \
7555+ popl %edx; \
7556+ popl %ecx; \
7557+ popl %eax;
7558+#else
7559+# define LOCKDEP_SYS_EXIT
7560+#endif
7561+
7562 #endif
7563Index: head-2008-12-01/include/asm-x86/mach-xen/asm/irqflags_64.h
7564===================================================================
7565--- head-2008-12-01.orig/include/asm-x86/mach-xen/asm/irqflags_64.h 2008-12-01 11:36:13.000000000 +0100
7566+++ head-2008-12-01/include/asm-x86/mach-xen/asm/irqflags_64.h 2008-12-01 11:36:55.000000000 +0100
7567@@ -116,6 +116,22 @@ static inline int raw_irqs_disabled_flag
7568 })
7569
7570 /*
7571+ * makes the traced hardirq state match with the machine state
7572+ *
7573+ * should be a rarely used function, only in places where its
7574+ * otherwise impossible to know the irq state, like in traps.
7575+ */
7576+static inline void trace_hardirqs_fixup_flags(unsigned long flags)
7577+{
7578+ if (raw_irqs_disabled_flags(flags))
7579+ trace_hardirqs_off();
7580+ else
7581+ trace_hardirqs_on();
7582+}
7583+
7584+#define trace_hardirqs_fixup() \
7585+ trace_hardirqs_fixup_flags(__raw_local_save_flags())
7586+/*
7587 * Used in the idle loop; sti takes one instruction cycle
7588 * to complete:
7589 */
7590@@ -143,6 +159,20 @@ static inline void halt(void)
7591 # define TRACE_IRQS_ON
7592 # define TRACE_IRQS_OFF
7593 # endif
7594+# ifdef CONFIG_DEBUG_LOCK_ALLOC
7595+# define LOCKDEP_SYS_EXIT call lockdep_sys_exit_thunk
7596+# define LOCKDEP_SYS_EXIT_IRQ \
7597+ TRACE_IRQS_ON; \
7598+ sti; \
7599+ SAVE_REST; \
7600+ LOCKDEP_SYS_EXIT; \
7601+ RESTORE_REST; \
7602+ cli; \
7603+ TRACE_IRQS_OFF;
7604+# else
7605+# define LOCKDEP_SYS_EXIT
7606+# define LOCKDEP_SYS_EXIT_IRQ
7607+# endif
7608 #endif
7609
7610 #endif
7611Index: head-2008-12-01/include/asm-x86/mach-xen/asm/maddr.h
7612===================================================================
7613--- /dev/null 1970-01-01 00:00:00.000000000 +0000
7614+++ head-2008-12-01/include/asm-x86/mach-xen/asm/maddr.h 2008-12-01 11:36:55.000000000 +0100
7615@@ -0,0 +1,5 @@
7616+#ifdef CONFIG_X86_32
7617+# include "maddr_32.h"
7618+#else
7619+# include "maddr_64.h"
7620+#endif
7621Index: head-2008-12-01/include/asm-x86/mach-xen/asm/mmu_context.h
7622===================================================================
7623--- /dev/null 1970-01-01 00:00:00.000000000 +0000
7624+++ head-2008-12-01/include/asm-x86/mach-xen/asm/mmu_context.h 2008-12-01 11:36:55.000000000 +0100
7625@@ -0,0 +1,5 @@
7626+#ifdef CONFIG_X86_32
7627+# include "mmu_context_32.h"
7628+#else
7629+# include "mmu_context_64.h"
7630+#endif
7631Index: head-2008-12-01/include/asm-x86/mach-xen/asm/page.h
7632===================================================================
7633--- /dev/null 1970-01-01 00:00:00.000000000 +0000
7634+++ head-2008-12-01/include/asm-x86/mach-xen/asm/page.h 2008-12-01 11:36:55.000000000 +0100
7635@@ -0,0 +1,13 @@
7636+#ifdef __KERNEL__
7637+# ifdef CONFIG_X86_32
7638+# include "page_32.h"
7639+# else
7640+# include "page_64.h"
7641+# endif
7642+#else
7643+# ifdef __i386__
7644+# include "page_32.h"
7645+# else
7646+# include "page_64.h"
7647+# endif
7648+#endif
7649Index: head-2008-12-01/include/asm-x86/mach-xen/asm/page_64.h
7650===================================================================
7651--- head-2008-12-01.orig/include/asm-x86/mach-xen/asm/page_64.h 2008-12-01 11:36:47.000000000 +0100
7652+++ head-2008-12-01/include/asm-x86/mach-xen/asm/page_64.h 2008-12-01 11:36:55.000000000 +0100
7653@@ -207,6 +207,7 @@ static inline unsigned long __phys_addr(
7654 VM_READ | VM_WRITE | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
7655
7656 #define __HAVE_ARCH_GATE_AREA 1
7657+#define vmemmap ((struct page *)VMEMMAP_START)
7658
7659 #include <asm-generic/memory_model.h>
7660 #include <asm-generic/page.h>
7661Index: head-2008-12-01/include/asm-x86/mach-xen/asm/pci.h
7662===================================================================
7663--- /dev/null 1970-01-01 00:00:00.000000000 +0000
7664+++ head-2008-12-01/include/asm-x86/mach-xen/asm/pci.h 2008-12-01 11:36:55.000000000 +0100
7665@@ -0,0 +1,100 @@
7666+#ifndef __x86_PCI_H
7667+#define __x86_PCI_H
7668+
7669+#include <linux/mm.h> /* for struct page */
7670+#include <linux/types.h>
7671+#include <linux/slab.h>
7672+#include <linux/string.h>
7673+#include <asm/scatterlist.h>
7674+#include <asm/io.h>
7675+
7676+
7677+#ifdef __KERNEL__
7678+
7679+struct pci_sysdata {
7680+ int domain; /* PCI domain */
7681+ int node; /* NUMA node */
7682+#ifdef CONFIG_X86_64
7683+ void* iommu; /* IOMMU private data */
7684+#endif
7685+#ifdef CONFIG_XEN_PCIDEV_FRONTEND
7686+ struct pcifront_device *pdev;
7687+#endif
7688+};
7689+
7690+/* scan a bus after allocating a pci_sysdata for it */
7691+extern struct pci_bus *pci_scan_bus_with_sysdata(int busno);
7692+
7693+static inline int pci_domain_nr(struct pci_bus *bus)
7694+{
7695+ struct pci_sysdata *sd = bus->sysdata;
7696+ return sd->domain;
7697+}
7698+
7699+static inline int pci_proc_domain(struct pci_bus *bus)
7700+{
7701+ return pci_domain_nr(bus);
7702+}
7703+
7704+
7705+/* Can be used to override the logic in pci_scan_bus for skipping
7706+ already-configured bus numbers - to be used for buggy BIOSes
7707+ or architectures with incomplete PCI setup by the loader */
7708+
7709+#ifdef CONFIG_PCI
7710+extern unsigned int pcibios_assign_all_busses(void);
7711+#else
7712+#define pcibios_assign_all_busses() 0
7713+#endif
7714+
7715+#include <asm/hypervisor.h>
7716+#define pcibios_scan_all_fns(a, b) (!is_initial_xendomain())
7717+
7718+extern unsigned long pci_mem_start;
7719+#define PCIBIOS_MIN_IO 0x1000
7720+#define PCIBIOS_MIN_MEM (pci_mem_start)
7721+
7722+#define PCIBIOS_MIN_CARDBUS_IO 0x4000
7723+
7724+void pcibios_config_init(void);
7725+struct pci_bus * pcibios_scan_root(int bus);
7726+
7727+void pcibios_set_master(struct pci_dev *dev);
7728+void pcibios_penalize_isa_irq(int irq, int active);
7729+struct irq_routing_table *pcibios_get_irq_routing_table(void);
7730+int pcibios_set_irq_routing(struct pci_dev *dev, int pin, int irq);
7731+
7732+
7733+#define HAVE_PCI_MMAP
7734+extern int pci_mmap_page_range(struct pci_dev *dev, struct vm_area_struct *vma,
7735+ enum pci_mmap_state mmap_state, int write_combine);
7736+
7737+
7738+#ifdef CONFIG_PCI
7739+static inline void pci_dma_burst_advice(struct pci_dev *pdev,
7740+ enum pci_dma_burst_strategy *strat,
7741+ unsigned long *strategy_parameter)
7742+{
7743+ *strat = PCI_DMA_BURST_INFINITY;
7744+ *strategy_parameter = ~0UL;
7745+}
7746+#endif
7747+
7748+
7749+#endif /* __KERNEL__ */
7750+
7751+#ifdef CONFIG_X86_32
7752+# include "pci_32.h"
7753+#else
7754+# include "pci_64.h"
7755+#endif
7756+
7757+/* implement the pci_ DMA API in terms of the generic device dma_ one */
7758+#include <asm-generic/pci-dma-compat.h>
7759+
7760+/* generic pci stuff */
7761+#include <asm-generic/pci.h>
7762+
7763+
7764+
7765+#endif
7766Index: head-2008-12-01/include/asm-x86/mach-xen/asm/pci_32.h
7767===================================================================
7768--- head-2008-12-01.orig/include/asm-x86/mach-xen/asm/pci_32.h 2008-12-01 11:36:47.000000000 +0100
7769+++ head-2008-12-01/include/asm-x86/mach-xen/asm/pci_32.h 2008-12-01 11:36:55.000000000 +0100
7770@@ -4,52 +4,10 @@
7771
7772 #ifdef __KERNEL__
7773
7774-struct pci_sysdata {
7775- int node; /* NUMA node */
7776-};
7777-
7778-/* scan a bus after allocating a pci_sysdata for it */
7779-extern struct pci_bus *pci_scan_bus_with_sysdata(int busno);
7780-
7781-#include <linux/mm.h> /* for struct page */
7782-
7783-/* Can be used to override the logic in pci_scan_bus for skipping
7784- already-configured bus numbers - to be used for buggy BIOSes
7785- or architectures with incomplete PCI setup by the loader */
7786-
7787-#ifdef CONFIG_PCI
7788-extern unsigned int pcibios_assign_all_busses(void);
7789-#else
7790-#define pcibios_assign_all_busses() 0
7791-#endif
7792-
7793-#include <asm/hypervisor.h>
7794-#define pcibios_scan_all_fns(a, b) (!is_initial_xendomain())
7795-
7796-extern unsigned long pci_mem_start;
7797-#define PCIBIOS_MIN_IO 0x1000
7798-#define PCIBIOS_MIN_MEM (pci_mem_start)
7799-
7800-#define PCIBIOS_MIN_CARDBUS_IO 0x4000
7801-
7802-void pcibios_config_init(void);
7803-struct pci_bus * pcibios_scan_root(int bus);
7804-
7805-void pcibios_set_master(struct pci_dev *dev);
7806-void pcibios_penalize_isa_irq(int irq, int active);
7807-struct irq_routing_table *pcibios_get_irq_routing_table(void);
7808-int pcibios_set_irq_routing(struct pci_dev *dev, int pin, int irq);
7809-
7810 /* Dynamic DMA mapping stuff.
7811 * i386 has everything mapped statically.
7812 */
7813
7814-#include <linux/types.h>
7815-#include <linux/slab.h>
7816-#include <asm/scatterlist.h>
7817-#include <linux/string.h>
7818-#include <asm/io.h>
7819-
7820 struct pci_dev;
7821
7822 #ifdef CONFIG_SWIOTLB
7823@@ -89,31 +47,8 @@ struct pci_dev;
7824
7825 #endif
7826
7827-#define HAVE_PCI_MMAP
7828-extern int pci_mmap_page_range(struct pci_dev *dev, struct vm_area_struct *vma,
7829- enum pci_mmap_state mmap_state, int write_combine);
7830-
7831-
7832-#ifdef CONFIG_PCI
7833-static inline void pci_dma_burst_advice(struct pci_dev *pdev,
7834- enum pci_dma_burst_strategy *strat,
7835- unsigned long *strategy_parameter)
7836-{
7837- *strat = PCI_DMA_BURST_INFINITY;
7838- *strategy_parameter = ~0UL;
7839-}
7840-#endif
7841
7842 #endif /* __KERNEL__ */
7843
7844-#ifdef CONFIG_XEN_PCIDEV_FRONTEND
7845-#include <xen/pcifront.h>
7846-#endif /* CONFIG_XEN_PCIDEV_FRONTEND */
7847-
7848-/* implement the pci_ DMA API in terms of the generic device dma_ one */
7849-#include <asm-generic/pci-dma-compat.h>
7850-
7851-/* generic pci stuff */
7852-#include <asm-generic/pci.h>
7853
7854 #endif /* __i386_PCI_H */
7855Index: head-2008-12-01/include/asm-x86/mach-xen/asm/pci_64.h
7856===================================================================
7857--- head-2008-12-01.orig/include/asm-x86/mach-xen/asm/pci_64.h 2008-12-01 11:36:47.000000000 +0100
7858+++ head-2008-12-01/include/asm-x86/mach-xen/asm/pci_64.h 2008-12-01 11:36:55.000000000 +0100
7859@@ -1,16 +1,9 @@
7860 #ifndef __x8664_PCI_H
7861 #define __x8664_PCI_H
7862
7863-#include <asm/io.h>
7864
7865 #ifdef __KERNEL__
7866
7867-struct pci_sysdata {
7868- int node; /* NUMA node */
7869- void* iommu; /* IOMMU private data */
7870-};
7871-
7872-extern struct pci_bus *pci_scan_bus_with_sysdata(int busno);
7873
7874 #ifdef CONFIG_CALGARY_IOMMU
7875 static inline void* pci_iommu(struct pci_bus *bus)
7876@@ -26,42 +19,11 @@ static inline void set_pci_iommu(struct
7877 }
7878 #endif /* CONFIG_CALGARY_IOMMU */
7879
7880-#include <linux/mm.h> /* for struct page */
7881-
7882-/* Can be used to override the logic in pci_scan_bus for skipping
7883- already-configured bus numbers - to be used for buggy BIOSes
7884- or architectures with incomplete PCI setup by the loader */
7885-
7886-#ifdef CONFIG_PCI
7887-extern unsigned int pcibios_assign_all_busses(void);
7888-#else
7889-#define pcibios_assign_all_busses() 0
7890-#endif
7891-
7892-#include <asm/hypervisor.h>
7893-#define pcibios_scan_all_fns(a, b) (!is_initial_xendomain())
7894-
7895-extern unsigned long pci_mem_start;
7896-#define PCIBIOS_MIN_IO 0x1000
7897-#define PCIBIOS_MIN_MEM (pci_mem_start)
7898-
7899-#define PCIBIOS_MIN_CARDBUS_IO 0x4000
7900
7901-void pcibios_config_init(void);
7902-struct pci_bus * pcibios_scan_root(int bus);
7903 extern int (*pci_config_read)(int seg, int bus, int dev, int fn, int reg, int len, u32 *value);
7904 extern int (*pci_config_write)(int seg, int bus, int dev, int fn, int reg, int len, u32 value);
7905
7906-void pcibios_set_master(struct pci_dev *dev);
7907-void pcibios_penalize_isa_irq(int irq, int active);
7908-struct irq_routing_table *pcibios_get_irq_routing_table(void);
7909-int pcibios_set_irq_routing(struct pci_dev *dev, int pin, int irq);
7910-
7911-#include <linux/types.h>
7912-#include <linux/slab.h>
7913-#include <asm/scatterlist.h>
7914-#include <linux/string.h>
7915-#include <asm/page.h>
7916+
7917
7918 extern void pci_iommu_alloc(void);
7919 extern int iommu_setup(char *opt);
7920@@ -75,7 +37,7 @@ extern int iommu_setup(char *opt);
7921 */
7922 #define PCI_DMA_BUS_IS_PHYS (dma_ops->is_phys)
7923
7924-#if defined(CONFIG_IOMMU) || defined(CONFIG_CALGARY_IOMMU)
7925+#if defined(CONFIG_GART_IOMMU) || defined(CONFIG_CALGARY_IOMMU)
7926
7927 #define DECLARE_PCI_UNMAP_ADDR(ADDR_NAME) \
7928 dma_addr_t ADDR_NAME;
7929@@ -119,27 +81,7 @@ extern int iommu_setup(char *opt);
7930
7931 #endif
7932
7933-#include <asm-generic/pci-dma-compat.h>
7934-
7935-#ifdef CONFIG_PCI
7936-static inline void pci_dma_burst_advice(struct pci_dev *pdev,
7937- enum pci_dma_burst_strategy *strat,
7938- unsigned long *strategy_parameter)
7939-{
7940- *strat = PCI_DMA_BURST_INFINITY;
7941- *strategy_parameter = ~0UL;
7942-}
7943-#endif
7944-
7945-#define HAVE_PCI_MMAP
7946-extern int pci_mmap_page_range(struct pci_dev *dev, struct vm_area_struct *vma,
7947- enum pci_mmap_state mmap_state, int write_combine);
7948-
7949 #endif /* __KERNEL__ */
7950
7951-/* generic pci stuff */
7952-#ifdef CONFIG_PCI
7953-#include <asm-generic/pci.h>
7954-#endif
7955
7956 #endif /* __x8664_PCI_H */
7957Index: head-2008-12-01/include/asm-x86/mach-xen/asm/pgalloc.h
7958===================================================================
7959--- /dev/null 1970-01-01 00:00:00.000000000 +0000
7960+++ head-2008-12-01/include/asm-x86/mach-xen/asm/pgalloc.h 2008-12-01 11:36:55.000000000 +0100
7961@@ -0,0 +1,5 @@
7962+#ifdef CONFIG_X86_32
7963+# include "pgalloc_32.h"
7964+#else
7965+# include "pgalloc_64.h"
7966+#endif
7967Index: head-2008-12-01/include/asm-x86/mach-xen/asm/pgalloc_64.h
7968===================================================================
7969--- head-2008-12-01.orig/include/asm-x86/mach-xen/asm/pgalloc_64.h 2008-12-01 11:36:47.000000000 +0100
7970+++ head-2008-12-01/include/asm-x86/mach-xen/asm/pgalloc_64.h 2008-12-01 11:36:55.000000000 +0100
7971@@ -112,6 +112,8 @@ static inline void pgd_list_del(pgd_t *p
7972 spin_unlock(&pgd_lock);
7973 }
7974
7975+extern void pgd_test_and_unpin(pgd_t *);
7976+
7977 static inline pgd_t *pgd_alloc(struct mm_struct *mm)
7978 {
7979 /*
7980@@ -122,6 +124,7 @@ static inline pgd_t *pgd_alloc(struct mm
7981 if (!pgd)
7982 return NULL;
7983 pgd_list_add(pgd);
7984+ pgd_test_and_unpin(pgd);
7985 /*
7986 * Copy kernel pointers in from init.
7987 * Could keep a freelist or slab cache of those because the kernel
7988@@ -144,27 +147,7 @@ static inline pgd_t *pgd_alloc(struct mm
7989
7990 static inline void pgd_free(pgd_t *pgd)
7991 {
7992- pte_t *ptep = virt_to_ptep(pgd);
7993-
7994- if (!pte_write(*ptep)) {
7995- xen_pgd_unpin(__pa(pgd));
7996- BUG_ON(HYPERVISOR_update_va_mapping(
7997- (unsigned long)pgd,
7998- pfn_pte(virt_to_phys(pgd)>>PAGE_SHIFT, PAGE_KERNEL),
7999- 0));
8000- }
8001-
8002- ptep = virt_to_ptep(__user_pgd(pgd));
8003-
8004- if (!pte_write(*ptep)) {
8005- xen_pgd_unpin(__pa(__user_pgd(pgd)));
8006- BUG_ON(HYPERVISOR_update_va_mapping(
8007- (unsigned long)__user_pgd(pgd),
8008- pfn_pte(virt_to_phys(__user_pgd(pgd))>>PAGE_SHIFT,
8009- PAGE_KERNEL),
8010- 0));
8011- }
8012-
8013+ pgd_test_and_unpin(pgd);
8014 pgd_list_del(pgd);
8015 free_pages((unsigned long)pgd, 1);
8016 }
8017Index: head-2008-12-01/include/asm-x86/mach-xen/asm/pgtable.h
8018===================================================================
8019--- /dev/null 1970-01-01 00:00:00.000000000 +0000
8020+++ head-2008-12-01/include/asm-x86/mach-xen/asm/pgtable.h 2008-12-01 11:36:55.000000000 +0100
8021@@ -0,0 +1,5 @@
8022+#ifdef CONFIG_X86_32
8023+# include "pgtable_32.h"
8024+#else
8025+# include "pgtable_64.h"
8026+#endif
8027Index: head-2008-12-01/include/asm-x86/mach-xen/asm/pgtable_32.h
8028===================================================================
8029--- head-2008-12-01.orig/include/asm-x86/mach-xen/asm/pgtable_32.h 2008-12-01 11:36:47.000000000 +0100
8030+++ head-2008-12-01/include/asm-x86/mach-xen/asm/pgtable_32.h 2008-12-01 11:36:55.000000000 +0100
8031@@ -17,10 +17,7 @@
8032 #include <asm/fixmap.h>
8033 #include <linux/threads.h>
8034
8035-#ifndef _I386_BITOPS_H
8036-#include <asm/bitops.h>
8037-#endif
8038-
8039+#include <linux/bitops.h>
8040 #include <linux/slab.h>
8041 #include <linux/list.h>
8042 #include <linux/spinlock.h>
8043@@ -40,7 +37,7 @@ extern spinlock_t pgd_lock;
8044 extern struct page *pgd_list;
8045 void check_pgt_cache(void);
8046
8047-void pmd_ctor(void *, struct kmem_cache *, unsigned long);
8048+void pmd_ctor(struct kmem_cache *, void *);
8049 void pgtable_cache_init(void);
8050 void paging_init(void);
8051
8052Index: head-2008-12-01/include/asm-x86/mach-xen/asm/pgtable_64.h
8053===================================================================
8054--- head-2008-12-01.orig/include/asm-x86/mach-xen/asm/pgtable_64.h 2008-12-01 11:36:47.000000000 +0100
8055+++ head-2008-12-01/include/asm-x86/mach-xen/asm/pgtable_64.h 2008-12-01 11:36:55.000000000 +0100
8056@@ -9,7 +9,7 @@
8057 * the x86-64 page table tree.
8058 */
8059 #include <asm/processor.h>
8060-#include <asm/bitops.h>
8061+#include <linux/bitops.h>
8062 #include <linux/threads.h>
8063 #include <linux/sched.h>
8064 #include <asm/pda.h>
8065@@ -137,6 +137,7 @@ static inline void pgd_clear (pgd_t * pg
8066 #define MAXMEM _AC(0x3fffffffffff, UL)
8067 #define VMALLOC_START _AC(0xffffc20000000000, UL)
8068 #define VMALLOC_END _AC(0xffffe1ffffffffff, UL)
8069+#define VMEMMAP_START _AC(0xffffe20000000000, UL)
8070 #define MODULES_VADDR _AC(0xffffffff88000000, UL)
8071 #define MODULES_END _AC(0xfffffffffff00000, UL)
8072 #define MODULES_LEN (MODULES_END - MODULES_VADDR)
8073Index: head-2008-12-01/include/asm-x86/mach-xen/asm/processor.h
8074===================================================================
8075--- /dev/null 1970-01-01 00:00:00.000000000 +0000
8076+++ head-2008-12-01/include/asm-x86/mach-xen/asm/processor.h 2008-12-01 11:36:55.000000000 +0100
8077@@ -0,0 +1,5 @@
8078+#ifdef CONFIG_X86_32
8079+# include "processor_32.h"
8080+#else
8081+# include "processor_64.h"
8082+#endif
8083Index: head-2008-12-01/include/asm-x86/mach-xen/asm/processor_32.h
8084===================================================================
8085--- head-2008-12-01.orig/include/asm-x86/mach-xen/asm/processor_32.h 2008-12-01 11:36:47.000000000 +0100
8086+++ head-2008-12-01/include/asm-x86/mach-xen/asm/processor_32.h 2008-12-01 11:36:55.000000000 +0100
8087@@ -80,6 +80,7 @@ struct cpuinfo_x86 {
8088 unsigned char booted_cores; /* number of cores as seen by OS */
8089 __u8 phys_proc_id; /* Physical processor id. */
8090 __u8 cpu_core_id; /* Core id */
8091+ __u8 cpu_index; /* index into per_cpu list */
8092 #endif
8093 } __attribute__((__aligned__(SMP_CACHE_BYTES)));
8094
8095@@ -106,14 +107,19 @@ DECLARE_PER_CPU(struct tss_struct, init_
8096 #endif
8097
8098 #ifdef CONFIG_SMP
8099-extern struct cpuinfo_x86 cpu_data[];
8100-#define current_cpu_data cpu_data[smp_processor_id()]
8101+DECLARE_PER_CPU(struct cpuinfo_x86, cpu_info);
8102+#define cpu_data(cpu) per_cpu(cpu_info, cpu)
8103+#define current_cpu_data cpu_data(smp_processor_id())
8104 #else
8105-#define cpu_data (&boot_cpu_data)
8106-#define current_cpu_data boot_cpu_data
8107+#define cpu_data(cpu) boot_cpu_data
8108+#define current_cpu_data boot_cpu_data
8109 #endif
8110
8111-extern int cpu_llc_id[NR_CPUS];
8112+/*
8113+ * the following now lives in the per cpu area:
8114+ * extern int cpu_llc_id[NR_CPUS];
8115+ */
8116+DECLARE_PER_CPU(u8, cpu_llc_id);
8117 extern char ignore_fpu_irq;
8118
8119 void __init cpu_detect(struct cpuinfo_x86 *c);
8120@@ -560,7 +566,9 @@ static inline void xen_set_iopl_mask(uns
8121 * clear %ecx since some cpus (Cyrix MII) do not set or clear %ecx
8122 * resulting in stale register contents being returned.
8123 */
8124-static inline void cpuid(unsigned int op, unsigned int *eax, unsigned int *ebx, unsigned int *ecx, unsigned int *edx)
8125+static inline void cpuid(unsigned int op,
8126+ unsigned int *eax, unsigned int *ebx,
8127+ unsigned int *ecx, unsigned int *edx)
8128 {
8129 *eax = op;
8130 *ecx = 0;
8131@@ -568,8 +576,9 @@ static inline void cpuid(unsigned int op
8132 }
8133
8134 /* Some CPUID calls want 'count' to be placed in ecx */
8135-static inline void cpuid_count(int op, int count, int *eax, int *ebx, int *ecx,
8136- int *edx)
8137+static inline void cpuid_count(unsigned int op, int count,
8138+ unsigned int *eax, unsigned int *ebx,
8139+ unsigned int *ecx, unsigned int *edx)
8140 {
8141 *eax = op;
8142 *ecx = count;
8143@@ -639,6 +648,17 @@ static inline unsigned int cpuid_edx(uns
8144 #define K7_NOP7 ".byte 0x8D,0x04,0x05,0,0,0,0\n"
8145 #define K7_NOP8 K7_NOP7 ASM_NOP1
8146
8147+/* P6 nops */
8148+/* uses eax dependencies (Intel-recommended choice) */
8149+#define P6_NOP1 GENERIC_NOP1
8150+#define P6_NOP2 ".byte 0x66,0x90\n"
8151+#define P6_NOP3 ".byte 0x0f,0x1f,0x00\n"
8152+#define P6_NOP4 ".byte 0x0f,0x1f,0x40,0\n"
8153+#define P6_NOP5 ".byte 0x0f,0x1f,0x44,0x00,0\n"
8154+#define P6_NOP6 ".byte 0x66,0x0f,0x1f,0x44,0x00,0\n"
8155+#define P6_NOP7 ".byte 0x0f,0x1f,0x80,0,0,0,0\n"
8156+#define P6_NOP8 ".byte 0x0f,0x1f,0x84,0x00,0,0,0,0\n"
8157+
8158 #ifdef CONFIG_MK8
8159 #define ASM_NOP1 K8_NOP1
8160 #define ASM_NOP2 K8_NOP2
8161@@ -657,6 +677,17 @@ static inline unsigned int cpuid_edx(uns
8162 #define ASM_NOP6 K7_NOP6
8163 #define ASM_NOP7 K7_NOP7
8164 #define ASM_NOP8 K7_NOP8
8165+#elif defined(CONFIG_M686) || defined(CONFIG_MPENTIUMII) || \
8166+ defined(CONFIG_MPENTIUMIII) || defined(CONFIG_MPENTIUMM) || \
8167+ defined(CONFIG_MCORE2) || defined(CONFIG_PENTIUM4)
8168+#define ASM_NOP1 P6_NOP1
8169+#define ASM_NOP2 P6_NOP2
8170+#define ASM_NOP3 P6_NOP3
8171+#define ASM_NOP4 P6_NOP4
8172+#define ASM_NOP5 P6_NOP5
8173+#define ASM_NOP6 P6_NOP6
8174+#define ASM_NOP7 P6_NOP7
8175+#define ASM_NOP8 P6_NOP8
8176 #else
8177 #define ASM_NOP1 GENERIC_NOP1
8178 #define ASM_NOP2 GENERIC_NOP2
8179Index: head-2008-12-01/include/asm-x86/mach-xen/asm/processor_64.h
8180===================================================================
8181--- head-2008-12-01.orig/include/asm-x86/mach-xen/asm/processor_64.h 2008-12-01 11:36:47.000000000 +0100
8182+++ head-2008-12-01/include/asm-x86/mach-xen/asm/processor_64.h 2008-12-01 11:36:55.000000000 +0100
8183@@ -74,6 +74,7 @@ struct cpuinfo_x86 {
8184 __u8 booted_cores; /* number of cores as seen by OS */
8185 __u8 phys_proc_id; /* Physical Processor id. */
8186 __u8 cpu_core_id; /* Core id. */
8187+ __u8 cpu_index; /* index into per_cpu list */
8188 #endif
8189 } ____cacheline_aligned;
8190
8191@@ -88,11 +89,12 @@ struct cpuinfo_x86 {
8192 #define X86_VENDOR_UNKNOWN 0xff
8193
8194 #ifdef CONFIG_SMP
8195-extern struct cpuinfo_x86 cpu_data[];
8196-#define current_cpu_data cpu_data[smp_processor_id()]
8197+DECLARE_PER_CPU(struct cpuinfo_x86, cpu_info);
8198+#define cpu_data(cpu) per_cpu(cpu_info, cpu)
8199+#define current_cpu_data cpu_data(smp_processor_id())
8200 #else
8201-#define cpu_data (&boot_cpu_data)
8202-#define current_cpu_data boot_cpu_data
8203+#define cpu_data(cpu) boot_cpu_data
8204+#define current_cpu_data boot_cpu_data
8205 #endif
8206
8207 extern char ignore_irq13;
8208@@ -343,6 +345,16 @@ struct extended_sigtable {
8209 };
8210
8211
8212+#if defined(CONFIG_MPSC) || defined(CONFIG_MCORE2)
8213+#define ASM_NOP1 P6_NOP1
8214+#define ASM_NOP2 P6_NOP2
8215+#define ASM_NOP3 P6_NOP3
8216+#define ASM_NOP4 P6_NOP4
8217+#define ASM_NOP5 P6_NOP5
8218+#define ASM_NOP6 P6_NOP6
8219+#define ASM_NOP7 P6_NOP7
8220+#define ASM_NOP8 P6_NOP8
8221+#else
8222 #define ASM_NOP1 K8_NOP1
8223 #define ASM_NOP2 K8_NOP2
8224 #define ASM_NOP3 K8_NOP3
8225@@ -351,6 +363,7 @@ struct extended_sigtable {
8226 #define ASM_NOP6 K8_NOP6
8227 #define ASM_NOP7 K8_NOP7
8228 #define ASM_NOP8 K8_NOP8
8229+#endif
8230
8231 /* Opteron nops */
8232 #define K8_NOP1 ".byte 0x90\n"
8233@@ -362,6 +375,17 @@ struct extended_sigtable {
8234 #define K8_NOP7 K8_NOP4 K8_NOP3
8235 #define K8_NOP8 K8_NOP4 K8_NOP4
8236
8237+/* P6 nops */
8238+/* uses eax dependencies (Intel-recommended choice) */
8239+#define P6_NOP1 ".byte 0x90\n"
8240+#define P6_NOP2 ".byte 0x66,0x90\n"
8241+#define P6_NOP3 ".byte 0x0f,0x1f,0x00\n"
8242+#define P6_NOP4 ".byte 0x0f,0x1f,0x40,0\n"
8243+#define P6_NOP5 ".byte 0x0f,0x1f,0x44,0x00,0\n"
8244+#define P6_NOP6 ".byte 0x66,0x0f,0x1f,0x44,0x00,0\n"
8245+#define P6_NOP7 ".byte 0x0f,0x1f,0x80,0,0,0,0\n"
8246+#define P6_NOP8 ".byte 0x0f,0x1f,0x84,0x00,0,0,0,0\n"
8247+
8248 #define ASM_NOP_MAX 8
8249
8250 /* REP NOP (PAUSE) is a good thing to insert into busy-wait loops. */
8251@@ -377,12 +401,6 @@ static inline void sync_core(void)
8252 asm volatile("cpuid" : "=a" (tmp) : "0" (1) : "ebx","ecx","edx","memory");
8253 }
8254
8255-#define ARCH_HAS_PREFETCH
8256-static inline void prefetch(void *x)
8257-{
8258- asm volatile("prefetcht0 (%0)" :: "r" (x));
8259-}
8260-
8261 #define ARCH_HAS_PREFETCHW 1
8262 static inline void prefetchw(void *x)
8263 {
8264@@ -398,11 +416,6 @@ static inline void prefetchw(void *x)
8265
8266 #define cpu_relax() rep_nop()
8267
8268-static inline void serialize_cpu(void)
8269-{
8270- __asm__ __volatile__ ("cpuid" : : : "ax", "bx", "cx", "dx");
8271-}
8272-
8273 static inline void __monitor(const void *eax, unsigned long ecx,
8274 unsigned long edx)
8275 {
8276Index: head-2008-12-01/include/asm-x86/mach-xen/asm/segment.h
8277===================================================================
8278--- /dev/null 1970-01-01 00:00:00.000000000 +0000
8279+++ head-2008-12-01/include/asm-x86/mach-xen/asm/segment.h 2008-12-01 11:36:55.000000000 +0100
8280@@ -0,0 +1,5 @@
8281+#ifdef CONFIG_X86_32
8282+# include "segment_32.h"
8283+#else
8284+# include "../../segment_64.h"
8285+#endif
8286Index: head-2008-12-01/include/asm-x86/mach-xen/asm/smp.h
8287===================================================================
8288--- /dev/null 1970-01-01 00:00:00.000000000 +0000
8289+++ head-2008-12-01/include/asm-x86/mach-xen/asm/smp.h 2008-12-01 11:36:55.000000000 +0100
8290@@ -0,0 +1,5 @@
8291+#ifdef CONFIG_X86_32
8292+# include "smp_32.h"
8293+#else
8294+# include "smp_64.h"
8295+#endif
8296Index: head-2008-12-01/include/asm-x86/mach-xen/asm/smp_32.h
8297===================================================================
8298--- head-2008-12-01.orig/include/asm-x86/mach-xen/asm/smp_32.h 2008-12-01 11:36:13.000000000 +0100
8299+++ head-2008-12-01/include/asm-x86/mach-xen/asm/smp_32.h 2008-12-01 11:36:55.000000000 +0100
8300@@ -11,7 +11,7 @@
8301 #endif
8302
8303 #if defined(CONFIG_X86_LOCAL_APIC) && !defined(__ASSEMBLY__)
8304-#include <asm/bitops.h>
8305+#include <linux/bitops.h>
8306 #include <asm/mpspec.h>
8307 #include <asm/apic.h>
8308 #ifdef CONFIG_X86_IO_APIC
8309@@ -30,8 +30,8 @@
8310 extern void smp_alloc_memory(void);
8311 extern int pic_mode;
8312 extern int smp_num_siblings;
8313-extern cpumask_t cpu_sibling_map[];
8314-extern cpumask_t cpu_core_map[];
8315+DECLARE_PER_CPU(cpumask_t, cpu_sibling_map);
8316+DECLARE_PER_CPU(cpumask_t, cpu_core_map);
8317
8318 extern void (*mtrr_hook) (void);
8319 extern void zap_low_mappings (void);
8320@@ -39,9 +39,11 @@ extern void lock_ipi_call_lock(void);
8321 extern void unlock_ipi_call_lock(void);
8322
8323 #define MAX_APICID 256
8324-extern u8 x86_cpu_to_apicid[];
8325+extern u8 __initdata x86_cpu_to_apicid_init[];
8326+extern void *x86_cpu_to_apicid_ptr;
8327+DECLARE_PER_CPU(u8, x86_cpu_to_apicid);
8328
8329-#define cpu_physical_id(cpu) x86_cpu_to_apicid[cpu]
8330+#define cpu_physical_id(cpu) per_cpu(x86_cpu_to_apicid, cpu)
8331
8332 #ifdef CONFIG_HOTPLUG_CPU
8333 extern void cpu_exit_clear(void);
8334Index: head-2008-12-01/include/asm-x86/mach-xen/asm/smp_64.h
8335===================================================================
8336--- head-2008-12-01.orig/include/asm-x86/mach-xen/asm/smp_64.h 2008-12-01 11:36:13.000000000 +0100
8337+++ head-2008-12-01/include/asm-x86/mach-xen/asm/smp_64.h 2008-12-01 11:36:55.000000000 +0100
8338@@ -40,10 +40,19 @@ extern void lock_ipi_call_lock(void);
8339 extern void unlock_ipi_call_lock(void);
8340 extern int smp_num_siblings;
8341 extern void smp_send_reschedule(int cpu);
8342+extern int smp_call_function_mask(cpumask_t mask, void (*func)(void *),
8343+ void *info, int wait);
8344
8345-extern cpumask_t cpu_sibling_map[NR_CPUS];
8346-extern cpumask_t cpu_core_map[NR_CPUS];
8347-extern u8 cpu_llc_id[NR_CPUS];
8348+/*
8349+ * cpu_sibling_map and cpu_core_map now live
8350+ * in the per cpu area
8351+ *
8352+ * extern cpumask_t cpu_sibling_map[NR_CPUS];
8353+ * extern cpumask_t cpu_core_map[NR_CPUS];
8354+ */
8355+DECLARE_PER_CPU(cpumask_t, cpu_sibling_map);
8356+DECLARE_PER_CPU(cpumask_t, cpu_core_map);
8357+DECLARE_PER_CPU(u8, cpu_llc_id);
8358
8359 #define SMP_TRAMPOLINE_BASE 0x6000
8360
8361@@ -70,6 +79,8 @@ extern unsigned __cpuinitdata disabled_c
8362
8363 #endif /* CONFIG_SMP */
8364
8365+#define safe_smp_processor_id() smp_processor_id()
8366+
8367 #ifdef CONFIG_X86_LOCAL_APIC
8368 static inline int hard_smp_processor_id(void)
8369 {
8370@@ -82,8 +93,9 @@ static inline int hard_smp_processor_id(
8371 * Some lowlevel functions might want to know about
8372 * the real APIC ID <-> CPU # mapping.
8373 */
8374-extern u8 x86_cpu_to_apicid[NR_CPUS]; /* physical ID */
8375-extern u8 x86_cpu_to_log_apicid[NR_CPUS];
8376+extern u8 __initdata x86_cpu_to_apicid_init[];
8377+extern void *x86_cpu_to_apicid_ptr;
8378+DECLARE_PER_CPU(u8, x86_cpu_to_apicid); /* physical ID */
8379 extern u8 bios_cpu_apicid[];
8380
8381 #ifdef CONFIG_X86_LOCAL_APIC
8382@@ -118,8 +130,9 @@ static __inline int logical_smp_processo
8383 #endif
8384
8385 #ifdef CONFIG_SMP
8386-#define cpu_physical_id(cpu) x86_cpu_to_apicid[cpu]
8387+#define cpu_physical_id(cpu) per_cpu(x86_cpu_to_apicid, cpu)
8388 #else
8389+extern unsigned int boot_cpu_id;
8390 #define cpu_physical_id(cpu) boot_cpu_id
8391 #endif /* !CONFIG_SMP */
8392 #endif
8393Index: head-2008-12-01/include/asm-x86/mach-xen/asm/swiotlb.h
8394===================================================================
8395--- /dev/null 1970-01-01 00:00:00.000000000 +0000
8396+++ head-2008-12-01/include/asm-x86/mach-xen/asm/swiotlb.h 2008-12-01 11:36:55.000000000 +0100
8397@@ -0,0 +1,5 @@
8398+#ifdef CONFIG_X86_32
8399+# include "swiotlb_32.h"
8400+#else
8401+# include "../../swiotlb.h"
8402+#endif
8403Index: head-2008-12-01/include/asm-x86/mach-xen/asm/system.h
8404===================================================================
8405--- /dev/null 1970-01-01 00:00:00.000000000 +0000
8406+++ head-2008-12-01/include/asm-x86/mach-xen/asm/system.h 2008-12-01 11:36:55.000000000 +0100
8407@@ -0,0 +1,5 @@
8408+#ifdef CONFIG_X86_32
8409+# include "system_32.h"
8410+#else
8411+# include "system_64.h"
8412+#endif
8413Index: head-2008-12-01/include/asm-x86/mach-xen/asm/system_32.h
8414===================================================================
8415--- head-2008-12-01.orig/include/asm-x86/mach-xen/asm/system_32.h 2008-12-01 11:36:47.000000000 +0100
8416+++ head-2008-12-01/include/asm-x86/mach-xen/asm/system_32.h 2008-12-01 11:36:55.000000000 +0100
8417@@ -9,6 +9,7 @@
8418 #include <asm/hypervisor.h>
8419
8420 #ifdef __KERNEL__
8421+#define AT_VECTOR_SIZE_ARCH 2 /* entries in ARCH_DLINFO */
8422
8423 struct task_struct; /* one of the stranger aspects of C forward declarations.. */
8424 extern struct task_struct * FASTCALL(__switch_to(struct task_struct *prev, struct task_struct *next));
8425@@ -138,7 +139,7 @@ static inline unsigned long xen_read_cr4
8426 {
8427 unsigned long val;
8428 /* This could fault if %cr4 does not exist */
8429- asm("1: movl %%cr4, %0 \n"
8430+ asm volatile("1: movl %%cr4, %0 \n"
8431 "2: \n"
8432 ".section __ex_table,\"a\" \n"
8433 ".long 1b,2b \n"
8434@@ -157,6 +158,11 @@ static inline void xen_wbinvd(void)
8435 asm volatile("wbinvd": : :"memory");
8436 }
8437
8438+static inline void clflush(volatile void *__p)
8439+{
8440+ asm volatile("clflush %0" : "+m" (*(char __force *)__p));
8441+}
8442+
8443 #define read_cr0() (xen_read_cr0())
8444 #define write_cr0(x) (xen_write_cr0(x))
8445 #define read_cr2() (xen_read_cr2())
8446@@ -207,6 +213,7 @@ static inline unsigned long get_limit(un
8447
8448 #define mb() alternative("lock; addl $0,0(%%esp)", "mfence", X86_FEATURE_XMM2)
8449 #define rmb() alternative("lock; addl $0,0(%%esp)", "lfence", X86_FEATURE_XMM2)
8450+#define wmb() alternative("lock; addl $0,0(%%esp)", "sfence", X86_FEATURE_XMM)
8451
8452 /**
8453 * read_barrier_depends - Flush all pending reads that subsequents reads
8454@@ -262,18 +269,18 @@ static inline unsigned long get_limit(un
8455
8456 #define read_barrier_depends() do { } while(0)
8457
8458+#ifdef CONFIG_SMP
8459+#define smp_mb() mb()
8460+#ifdef CONFIG_X86_PPRO_FENCE
8461+# define smp_rmb() rmb()
8462+#else
8463+# define smp_rmb() barrier()
8464+#endif
8465 #ifdef CONFIG_X86_OOSTORE
8466-/* Actually there are no OOO store capable CPUs for now that do SSE,
8467- but make it already an possibility. */
8468-#define wmb() alternative("lock; addl $0,0(%%esp)", "sfence", X86_FEATURE_XMM)
8469+# define smp_wmb() wmb()
8470 #else
8471-#define wmb() __asm__ __volatile__ ("": : :"memory")
8472+# define smp_wmb() barrier()
8473 #endif
8474-
8475-#ifdef CONFIG_SMP
8476-#define smp_mb() mb()
8477-#define smp_rmb() rmb()
8478-#define smp_wmb() wmb()
8479 #define smp_read_barrier_depends() read_barrier_depends()
8480 #define set_mb(var, value) do { (void) xchg(&var, value); } while (0)
8481 #else
8482@@ -300,5 +307,6 @@ extern unsigned long arch_align_stack(un
8483 extern void free_init_pages(char *what, unsigned long begin, unsigned long end);
8484
8485 void default_idle(void);
8486+void __show_registers(struct pt_regs *, int all);
8487
8488 #endif
8489Index: head-2008-12-01/include/asm-x86/mach-xen/asm/system_64.h
8490===================================================================
8491--- head-2008-12-01.orig/include/asm-x86/mach-xen/asm/system_64.h 2008-12-01 11:36:47.000000000 +0100
8492+++ head-2008-12-01/include/asm-x86/mach-xen/asm/system_64.h 2008-12-01 11:36:55.000000000 +0100
8493@@ -11,8 +11,12 @@
8494
8495 #ifdef __KERNEL__
8496
8497-#define __STR(x) #x
8498-#define STR(x) __STR(x)
8499+/* entries in ARCH_DLINFO: */
8500+#ifdef CONFIG_IA32_EMULATION
8501+# define AT_VECTOR_SIZE_ARCH 2
8502+#else
8503+# define AT_VECTOR_SIZE_ARCH 1
8504+#endif
8505
8506 #define __SAVE(reg,offset) "movq %%" #reg ",(14-" #offset ")*8(%%rsp)\n\t"
8507 #define __RESTORE(reg,offset) "movq (14-" #offset ")*8(%%rsp),%%" #reg "\n\t"
8508@@ -92,7 +96,7 @@ static inline void write_cr0(unsigned lo
8509
8510 #define read_cr3() ({ \
8511 unsigned long __dummy; \
8512- asm("movq %%cr3,%0" : "=r" (__dummy)); \
8513+ asm volatile("movq %%cr3,%0" : "=r" (__dummy)); \
8514 machine_to_phys(__dummy); \
8515 })
8516
8517@@ -105,7 +109,7 @@ static inline void write_cr3(unsigned lo
8518 static inline unsigned long read_cr4(void)
8519 {
8520 unsigned long cr4;
8521- asm("movq %%cr4,%0" : "=r" (cr4));
8522+ asm volatile("movq %%cr4,%0" : "=r" (cr4));
8523 return cr4;
8524 }
8525
8526@@ -131,12 +135,17 @@ static inline void write_cr8(unsigned lo
8527
8528 #endif /* __KERNEL__ */
8529
8530+static inline void clflush(volatile void *__p)
8531+{
8532+ asm volatile("clflush %0" : "+m" (*(char __force *)__p));
8533+}
8534+
8535 #define nop() __asm__ __volatile__ ("nop")
8536
8537 #ifdef CONFIG_SMP
8538 #define smp_mb() mb()
8539-#define smp_rmb() rmb()
8540-#define smp_wmb() wmb()
8541+#define smp_rmb() barrier()
8542+#define smp_wmb() barrier()
8543 #define smp_read_barrier_depends() do {} while(0)
8544 #else
8545 #define smp_mb() barrier()
8546@@ -153,12 +162,8 @@ static inline void write_cr8(unsigned lo
8547 */
8548 #define mb() asm volatile("mfence":::"memory")
8549 #define rmb() asm volatile("lfence":::"memory")
8550-
8551-#ifdef CONFIG_UNORDERED_IO
8552 #define wmb() asm volatile("sfence" ::: "memory")
8553-#else
8554-#define wmb() asm volatile("" ::: "memory")
8555-#endif
8556+
8557 #define read_barrier_depends() do {} while(0)
8558 #define set_mb(var, value) do { (void) xchg(&var, value); } while (0)
8559
8560Index: head-2008-12-01/include/asm-x86/mach-xen/asm/tlbflush.h
8561===================================================================
8562--- /dev/null 1970-01-01 00:00:00.000000000 +0000
8563+++ head-2008-12-01/include/asm-x86/mach-xen/asm/tlbflush.h 2008-12-01 11:36:55.000000000 +0100
8564@@ -0,0 +1,5 @@
8565+#ifdef CONFIG_X86_32
8566+# include "tlbflush_32.h"
8567+#else
8568+# include "tlbflush_64.h"
8569+#endif
8570Index: head-2008-12-01/include/asm-x86/mach-xen/asm/tlbflush_32.h
8571===================================================================
8572--- head-2008-12-01.orig/include/asm-x86/mach-xen/asm/tlbflush_32.h 2008-12-01 11:36:47.000000000 +0100
8573+++ head-2008-12-01/include/asm-x86/mach-xen/asm/tlbflush_32.h 2008-12-01 11:36:55.000000000 +0100
8574@@ -23,7 +23,6 @@
8575 * - flush_tlb_page(vma, vmaddr) flushes one page
8576 * - flush_tlb_range(vma, start, end) flushes a range of pages
8577 * - flush_tlb_kernel_range(start, end) flushes a range of kernel pages
8578- * - flush_tlb_pgtables(mm, start, end) flushes a range of page tables
8579 *
8580 * ..but the i386 has somewhat limited tlb flushing capabilities,
8581 * and page-granular flushes are available only on i486 and up.
8582@@ -97,10 +96,4 @@ static inline void flush_tlb_kernel_rang
8583 flush_tlb_all();
8584 }
8585
8586-static inline void flush_tlb_pgtables(struct mm_struct *mm,
8587- unsigned long start, unsigned long end)
8588-{
8589- /* i386 does not keep any page table caches in TLB */
8590-}
8591-
8592 #endif /* _I386_TLBFLUSH_H */
8593Index: head-2008-12-01/include/asm-x86/mach-xen/asm/tlbflush_64.h
8594===================================================================
8595--- head-2008-12-01.orig/include/asm-x86/mach-xen/asm/tlbflush_64.h 2008-12-01 11:36:47.000000000 +0100
8596+++ head-2008-12-01/include/asm-x86/mach-xen/asm/tlbflush_64.h 2008-12-01 11:36:55.000000000 +0100
8597@@ -28,7 +28,6 @@
8598 * - flush_tlb_page(vma, vmaddr) flushes one page
8599 * - flush_tlb_range(vma, start, end) flushes a range of pages
8600 * - flush_tlb_kernel_range(start, end) flushes a range of kernel pages
8601- * - flush_tlb_pgtables(mm, start, end) flushes a range of page tables
8602 *
8603 * x86-64 can only flush individual pages or full VMs. For a range flush
8604 * we always do the full VM. Might be worth trying if for a small
8605@@ -95,12 +94,4 @@ static inline void flush_tlb_kernel_rang
8606 flush_tlb_all();
8607 }
8608
8609-static inline void flush_tlb_pgtables(struct mm_struct *mm,
8610- unsigned long start, unsigned long end)
8611-{
8612- /* x86_64 does not keep any page table caches in a software TLB.
8613- The CPUs do in their hardware TLBs, but they are handled
8614- by the normal TLB flushing algorithms. */
8615-}
8616-
8617 #endif /* _X8664_TLBFLUSH_H */
8618Index: head-2008-12-01/include/asm-x86/mach-xen/asm/xor.h
8619===================================================================
8620--- /dev/null 1970-01-01 00:00:00.000000000 +0000
8621+++ head-2008-12-01/include/asm-x86/mach-xen/asm/xor.h 2008-12-01 11:36:55.000000000 +0100
8622@@ -0,0 +1,5 @@
8623+#ifdef CONFIG_X86_32
8624+# include "../../xor_32.h"
8625+#else
8626+# include "xor_64.h"
8627+#endif
8628Index: head-2008-12-01/include/asm-x86/mach-xen/mach_time.h
8629===================================================================
8630--- head-2008-12-01.orig/include/asm-x86/mach-xen/mach_time.h 2007-06-12 13:14:13.000000000 +0200
8631+++ head-2008-12-01/include/asm-x86/mach-xen/mach_time.h 2008-12-01 11:36:55.000000000 +0100
8632@@ -1,111 +1,2 @@
8633-/*
8634- * include/asm-i386/mach-default/mach_time.h
8635- *
8636- * Machine specific set RTC function for generic.
8637- * Split out from time.c by Osamu Tomita <tomita@cinet.co.jp>
8638- */
8639-#ifndef _MACH_TIME_H
8640-#define _MACH_TIME_H
8641-
8642-#include <asm-i386/mc146818rtc.h>
8643-
8644-/* for check timing call set_rtc_mmss() 500ms */
8645-/* used in arch/i386/time.c::do_timer_interrupt() */
8646-#define USEC_AFTER 500000
8647-#define USEC_BEFORE 500000
8648-
8649-/*
8650- * In order to set the CMOS clock precisely, set_rtc_mmss has to be
8651- * called 500 ms after the second nowtime has started, because when
8652- * nowtime is written into the registers of the CMOS clock, it will
8653- * jump to the next second precisely 500 ms later. Check the Motorola
8654- * MC146818A or Dallas DS12887 data sheet for details.
8655- *
8656- * BUG: This routine does not handle hour overflow properly; it just
8657- * sets the minutes. Usually you'll only notice that after reboot!
8658- */
8659-static inline int mach_set_rtc_mmss(unsigned long nowtime)
8660-{
8661- int retval = 0;
8662- int real_seconds, real_minutes, cmos_minutes;
8663- unsigned char save_control, save_freq_select;
8664-
8665- save_control = CMOS_READ(RTC_CONTROL); /* tell the clock it's being set */
8666- CMOS_WRITE((save_control|RTC_SET), RTC_CONTROL);
8667-
8668- save_freq_select = CMOS_READ(RTC_FREQ_SELECT); /* stop and reset prescaler */
8669- CMOS_WRITE((save_freq_select|RTC_DIV_RESET2), RTC_FREQ_SELECT);
8670-
8671- cmos_minutes = CMOS_READ(RTC_MINUTES);
8672- if (!(save_control & RTC_DM_BINARY) || RTC_ALWAYS_BCD)
8673- BCD_TO_BIN(cmos_minutes);
8674-
8675- /*
8676- * since we're only adjusting minutes and seconds,
8677- * don't interfere with hour overflow. This avoids
8678- * messing with unknown time zones but requires your
8679- * RTC not to be off by more than 15 minutes
8680- */
8681- real_seconds = nowtime % 60;
8682- real_minutes = nowtime / 60;
8683- if (((abs(real_minutes - cmos_minutes) + 15)/30) & 1)
8684- real_minutes += 30; /* correct for half hour time zone */
8685- real_minutes %= 60;
8686-
8687- if (abs(real_minutes - cmos_minutes) < 30) {
8688- if (!(save_control & RTC_DM_BINARY) || RTC_ALWAYS_BCD) {
8689- BIN_TO_BCD(real_seconds);
8690- BIN_TO_BCD(real_minutes);
8691- }
8692- CMOS_WRITE(real_seconds,RTC_SECONDS);
8693- CMOS_WRITE(real_minutes,RTC_MINUTES);
8694- } else {
8695- printk(KERN_WARNING
8696- "set_rtc_mmss: can't update from %d to %d\n",
8697- cmos_minutes, real_minutes);
8698- retval = -1;
8699- }
8700-
8701- /* The following flags have to be released exactly in this order,
8702- * otherwise the DS12887 (popular MC146818A clone with integrated
8703- * battery and quartz) will not reset the oscillator and will not
8704- * update precisely 500 ms later. You won't find this mentioned in
8705- * the Dallas Semiconductor data sheets, but who believes data
8706- * sheets anyway ... -- Markus Kuhn
8707- */
8708- CMOS_WRITE(save_control, RTC_CONTROL);
8709- CMOS_WRITE(save_freq_select, RTC_FREQ_SELECT);
8710-
8711- return retval;
8712-}
8713-
8714-static inline unsigned long mach_get_cmos_time(void)
8715-{
8716- unsigned int year, mon, day, hour, min, sec;
8717-
8718- do {
8719- sec = CMOS_READ(RTC_SECONDS);
8720- min = CMOS_READ(RTC_MINUTES);
8721- hour = CMOS_READ(RTC_HOURS);
8722- day = CMOS_READ(RTC_DAY_OF_MONTH);
8723- mon = CMOS_READ(RTC_MONTH);
8724- year = CMOS_READ(RTC_YEAR);
8725- } while (sec != CMOS_READ(RTC_SECONDS));
8726-
8727- if (!(CMOS_READ(RTC_CONTROL) & RTC_DM_BINARY) || RTC_ALWAYS_BCD) {
8728- BCD_TO_BIN(sec);
8729- BCD_TO_BIN(min);
8730- BCD_TO_BIN(hour);
8731- BCD_TO_BIN(day);
8732- BCD_TO_BIN(mon);
8733- BCD_TO_BIN(year);
8734- }
8735-
8736- year += 1900;
8737- if (year < 1970)
8738- year += 100;
8739-
8740- return mktime(year, mon, day, hour, min, sec);
8741-}
8742-
8743-#endif /* !_MACH_TIME_H */
8744+#include "../mc146818rtc_32.h"
8745+#include "../mach-default/mach_time.h"
8746Index: head-2008-12-01/include/asm-x86/mach-xen/mach_timer.h
8747===================================================================
8748--- head-2008-12-01.orig/include/asm-x86/mach-xen/mach_timer.h 2007-06-12 13:14:13.000000000 +0200
8749+++ head-2008-12-01/include/asm-x86/mach-xen/mach_timer.h 2008-12-01 11:36:55.000000000 +0100
8750@@ -1,50 +1 @@
8751-/*
8752- * include/asm-i386/mach-default/mach_timer.h
8753- *
8754- * Machine specific calibrate_tsc() for generic.
8755- * Split out from timer_tsc.c by Osamu Tomita <tomita@cinet.co.jp>
8756- */
8757-/* ------ Calibrate the TSC -------
8758- * Return 2^32 * (1 / (TSC clocks per usec)) for do_fast_gettimeoffset().
8759- * Too much 64-bit arithmetic here to do this cleanly in C, and for
8760- * accuracy's sake we want to keep the overhead on the CTC speaker (channel 2)
8761- * output busy loop as low as possible. We avoid reading the CTC registers
8762- * directly because of the awkward 8-bit access mechanism of the 82C54
8763- * device.
8764- */
8765-#ifndef _MACH_TIMER_H
8766-#define _MACH_TIMER_H
8767-
8768-#define CALIBRATE_TIME_MSEC 30 /* 30 msecs */
8769-#define CALIBRATE_LATCH \
8770- ((CLOCK_TICK_RATE * CALIBRATE_TIME_MSEC + 1000/2)/1000)
8771-
8772-static inline void mach_prepare_counter(void)
8773-{
8774- /* Set the Gate high, disable speaker */
8775- outb((inb(0x61) & ~0x02) | 0x01, 0x61);
8776-
8777- /*
8778- * Now let's take care of CTC channel 2
8779- *
8780- * Set the Gate high, program CTC channel 2 for mode 0,
8781- * (interrupt on terminal count mode), binary count,
8782- * load 5 * LATCH count, (LSB and MSB) to begin countdown.
8783- *
8784- * Some devices need a delay here.
8785- */
8786- outb(0xb0, 0x43); /* binary, mode 0, LSB/MSB, Ch 2 */
8787- outb_p(CALIBRATE_LATCH & 0xff, 0x42); /* LSB of count */
8788- outb_p(CALIBRATE_LATCH >> 8, 0x42); /* MSB of count */
8789-}
8790-
8791-static inline void mach_countup(unsigned long *count_p)
8792-{
8793- unsigned long count = 0;
8794- do {
8795- count++;
8796- } while ((inb_p(0x61) & 0x20) == 0);
8797- *count_p = count;
8798-}
8799-
8800-#endif /* !_MACH_TIMER_H */
8801+#include "../mach-default/mach_timer.h"
8802Index: head-2008-12-01/include/asm-x86/mmu.h
8803===================================================================
8804--- head-2008-12-01.orig/include/asm-x86/mmu.h 2008-12-01 10:53:14.000000000 +0100
8805+++ head-2008-12-01/include/asm-x86/mmu.h 2008-12-01 11:36:55.000000000 +0100
8806@@ -16,6 +16,9 @@ typedef struct {
8807 rwlock_t ldtlock;
8808 #endif
8809 int size;
8810+#ifdef CONFIG_XEN
8811+ unsigned has_foreign_mappings:1;
8812+#endif
8813 struct mutex lock;
8814 void *vdso;
8815 } mm_context_t;
8816Index: head-2008-12-01/include/linux/sysctl.h
8817===================================================================
8818--- head-2008-12-01.orig/include/linux/sysctl.h 2008-12-01 10:53:14.000000000 +0100
8819+++ head-2008-12-01/include/linux/sysctl.h 2008-12-01 11:36:55.000000000 +0100
8820@@ -69,6 +69,7 @@ enum
8821 CTL_BUS=8, /* Busses */
8822 CTL_ABI=9, /* Binary emulation */
8823 CTL_CPU=10, /* CPU stuff (speed scaling, etc) */
8824+ CTL_XEN=123, /* Xen info and control */
8825 CTL_ARLAN=254, /* arlan wireless driver */
8826 CTL_S390DBF=5677, /* s390 debug */
8827 CTL_SUNRPC=7249, /* sunrpc debug */
8828Index: head-2008-12-01/include/xen/pcifront.h
8829===================================================================
8830--- head-2008-12-01.orig/include/xen/pcifront.h 2007-06-18 08:38:13.000000000 +0200
8831+++ head-2008-12-01/include/xen/pcifront.h 2008-12-01 11:36:55.000000000 +0100
8832@@ -12,13 +12,11 @@
8833
8834 #ifndef __ia64__
8835
8836+#include <asm/pci.h>
8837+
8838 struct pcifront_device;
8839 struct pci_bus;
8840-
8841-struct pcifront_sd {
8842- int domain;
8843- struct pcifront_device *pdev;
8844-};
8845+#define pcifront_sd pci_sysdata
8846
8847 static inline struct pcifront_device *
8848 pcifront_get_pdev(struct pcifront_sd *sd)
8849@@ -34,18 +32,6 @@ static inline void pcifront_init_sd(stru
8850 sd->pdev = pdev;
8851 }
8852
8853-#if defined(CONFIG_PCI_DOMAINS)
8854-static inline int pci_domain_nr(struct pci_bus *bus)
8855-{
8856- struct pcifront_sd *sd = bus->sysdata;
8857- return sd->domain;
8858-}
8859-static inline int pci_proc_domain(struct pci_bus *bus)
8860-{
8861- return pci_domain_nr(bus);
8862-}
8863-#endif /* CONFIG_PCI_DOMAINS */
8864-
8865 static inline void pcifront_setup_root_resources(struct pci_bus *bus,
8866 struct pcifront_sd *sd)
8867 {
8868Index: head-2008-12-01/include/xen/sysctl.h
8869===================================================================
8870--- /dev/null 1970-01-01 00:00:00.000000000 +0000
8871+++ head-2008-12-01/include/xen/sysctl.h 2008-12-01 11:36:55.000000000 +0100
8872@@ -0,0 +1,11 @@
8873+#ifndef _XEN_SYSCTL_H
8874+#define _XEN_SYSCTL_H
8875+
8876+/* CTL_XEN names: */
8877+enum
8878+{
8879+ CTL_XEN_INDEPENDENT_WALLCLOCK=1,
8880+ CTL_XEN_PERMITTED_CLOCK_JITTER=2,
8881+};
8882+
8883+#endif /* _XEN_SYSCTL_H */
8884Index: head-2008-12-01/include/xen/xenbus.h
8885===================================================================
8886--- head-2008-12-01.orig/include/xen/xenbus.h 2008-12-01 11:36:47.000000000 +0100
8887+++ head-2008-12-01/include/xen/xenbus.h 2008-12-01 11:36:55.000000000 +0100
8888@@ -107,7 +107,7 @@ struct xenbus_driver {
8889 int (*suspend)(struct xenbus_device *dev);
8890 int (*suspend_cancel)(struct xenbus_device *dev);
8891 int (*resume)(struct xenbus_device *dev);
8892- int (*uevent)(struct xenbus_device *, char **, int, char *, int);
8893+ int (*uevent)(struct xenbus_device *, struct kobj_uevent_env *);
8894 struct device_driver driver;
8895 int (*read_otherend_details)(struct xenbus_device *dev);
8896 int (*is_ready)(struct xenbus_device *dev);
8897Index: head-2008-12-01/kernel/kexec.c
8898===================================================================
8899--- head-2008-12-01.orig/kernel/kexec.c 2008-12-01 11:32:38.000000000 +0100
8900+++ head-2008-12-01/kernel/kexec.c 2008-12-01 11:36:55.000000000 +0100
8901@@ -1235,6 +1235,7 @@ static int __init crash_notes_memory_ini
8902 module_init(crash_notes_memory_init)
8903
8904
8905+#ifndef CONFIG_XEN
8906 /*
8907 * parsing the "crashkernel" commandline
8908 *
8909@@ -1397,7 +1398,7 @@ int __init parse_crashkernel(char *cm
8910
8911 return 0;
8912 }
8913-
8914+#endif
8915
8916
8917 void crash_save_vmcoreinfo(void)
8918@@ -1454,7 +1455,18 @@ static int __init crash_save_vmcoreinfo_
8919
8920 VMCOREINFO_SYMBOL(init_uts_ns);
8921 VMCOREINFO_SYMBOL(node_online_map);
8922+#ifndef CONFIG_X86_XEN
8923+ VMCOREINFO_SYMBOL(swapper_pg_dir);
8924+#else
8925+/*
8926+ * Since for x86-32 Xen swapper_pg_dir is a pointer rather than an array,
8927+ * make the value stored consistent with native (i.e. the base address of
8928+ * the page directory).
8929+ */
8930+# define swapper_pg_dir *swapper_pg_dir
8931 VMCOREINFO_SYMBOL(swapper_pg_dir);
8932+# undef swapper_pg_dir
8933+#endif
8934 VMCOREINFO_SYMBOL(_stext);
8935
8936 #ifndef CONFIG_NEED_MULTIPLE_NODES
8937Index: head-2008-12-01/kernel/sysctl_check.c
8938===================================================================
8939--- head-2008-12-01.orig/kernel/sysctl_check.c 2008-12-01 10:53:14.000000000 +0100
8940+++ head-2008-12-01/kernel/sysctl_check.c 2008-12-01 11:36:55.000000000 +0100
8941@@ -4,6 +4,7 @@
8942 #include <linux/sunrpc/debug.h>
8943 #include <linux/string.h>
8944 #include <net/ip_vs.h>
8945+#include <xen/sysctl.h>
8946
8947 struct trans_ctl_table {
8948 int ctl_name;
8949@@ -897,6 +898,14 @@ static const struct trans_ctl_table tran
8950 {}
8951 };
8952
8953+#ifdef CONFIG_XEN
8954+static struct trans_ctl_table trans_xen_table[] = {
8955+ { CTL_XEN_INDEPENDENT_WALLCLOCK, "independent_wallclock" },
8956+ { CTL_XEN_PERMITTED_CLOCK_JITTER, "permitted_clock_jitter" },
8957+ {}
8958+};
8959+#endif
8960+
8961 static const struct trans_ctl_table trans_arlan_conf_table0[] = {
8962 { 1, "spreadingCode" },
8963 { 2, "channelNumber" },
8964@@ -1232,6 +1241,9 @@ static const struct trans_ctl_table tran
8965 { CTL_BUS, "bus", trans_bus_table },
8966 { CTL_ABI, "abi" },
8967 /* CTL_CPU not used */
8968+#ifdef CONFIG_XEN
8969+ { CTL_XEN, "xen", trans_xen_table },
8970+#endif
8971 { CTL_ARLAN, "arlan", trans_arlan_table },
8972 { CTL_S390DBF, "s390dbf", trans_s390dbf_table },
8973 { CTL_SUNRPC, "sunrpc", trans_sunrpc_table },
8974Index: head-2008-12-01/lib/swiotlb-xen.c
8975===================================================================
8976--- head-2008-12-01.orig/lib/swiotlb-xen.c 2008-12-01 11:36:13.000000000 +0100
8977+++ head-2008-12-01/lib/swiotlb-xen.c 2008-12-01 11:36:55.000000000 +0100
8978@@ -27,7 +27,7 @@
8979 #include <asm/uaccess.h>
8980 #include <xen/gnttab.h>
8981 #include <xen/interface/memory.h>
8982-#include <asm-i386/mach-xen/asm/gnttab_dma.h>
8983+#include <asm/gnttab_dma.h>
8984
8985 int swiotlb;
8986 EXPORT_SYMBOL(swiotlb);
8987@@ -574,9 +574,10 @@ swiotlb_sync_single_for_device(struct de
8988 * same here.
8989 */
8990 int
8991-swiotlb_map_sg(struct device *hwdev, struct scatterlist *sg, int nelems,
8992+swiotlb_map_sg(struct device *hwdev, struct scatterlist *sgl, int nelems,
8993 int dir)
8994 {
8995+ struct scatterlist *sg;
8996 struct phys_addr buffer;
8997 dma_addr_t dev_addr;
8998 char *map;
8999@@ -584,22 +585,22 @@ swiotlb_map_sg(struct device *hwdev, str
9000
9001 BUG_ON(dir == DMA_NONE);
9002
9003- for (i = 0; i < nelems; i++, sg++) {
9004- dev_addr = gnttab_dma_map_page(sg->page) + sg->offset;
9005+ for_each_sg(sgl, sg, nelems, i) {
9006+ dev_addr = gnttab_dma_map_page(sg_page(sg)) + sg->offset;
9007
9008- if (range_straddles_page_boundary(page_to_pseudophys(sg->page)
9009+ if (range_straddles_page_boundary(page_to_pseudophys(sg_page(sg))
9010 + sg->offset, sg->length)
9011 || address_needs_mapping(hwdev, dev_addr)) {
9012 gnttab_dma_unmap_page(dev_addr);
9013- buffer.page = sg->page;
9014+ buffer.page = sg_page(sg);
9015 buffer.offset = sg->offset;
9016 map = map_single(hwdev, buffer, sg->length, dir);
9017 if (!map) {
9018 /* Don't panic here, we expect map_sg users
9019 to do proper error handling. */
9020 swiotlb_full(hwdev, sg->length, dir, 0);
9021- swiotlb_unmap_sg(hwdev, sg - i, i, dir);
9022- sg[0].dma_length = 0;
9023+ swiotlb_unmap_sg(hwdev, sgl, i, dir);
9024+ sgl[0].dma_length = 0;
9025 return 0;
9026 }
9027 sg->dma_address = virt_to_bus(map);
9028@@ -615,19 +616,21 @@ swiotlb_map_sg(struct device *hwdev, str
9029 * concerning calls here are the same as for swiotlb_unmap_single() above.
9030 */
9031 void
9032-swiotlb_unmap_sg(struct device *hwdev, struct scatterlist *sg, int nelems,
9033+swiotlb_unmap_sg(struct device *hwdev, struct scatterlist *sgl, int nelems,
9034 int dir)
9035 {
9036+ struct scatterlist *sg;
9037 int i;
9038
9039 BUG_ON(dir == DMA_NONE);
9040
9041- for (i = 0; i < nelems; i++, sg++)
9042+ for_each_sg(sgl, sg, nelems, i) {
9043 if (in_swiotlb_aperture(sg->dma_address))
9044 unmap_single(hwdev, bus_to_virt(sg->dma_address),
9045 sg->dma_length, dir);
9046 else
9047 gnttab_dma_unmap_page(sg->dma_address);
9048+ }
9049 }
9050
9051 /*
9052@@ -638,31 +641,35 @@ swiotlb_unmap_sg(struct device *hwdev, s
9053 * and usage.
9054 */
9055 void
9056-swiotlb_sync_sg_for_cpu(struct device *hwdev, struct scatterlist *sg,
9057+swiotlb_sync_sg_for_cpu(struct device *hwdev, struct scatterlist *sgl,
9058 int nelems, int dir)
9059 {
9060+ struct scatterlist *sg;
9061 int i;
9062
9063 BUG_ON(dir == DMA_NONE);
9064
9065- for (i = 0; i < nelems; i++, sg++)
9066+ for_each_sg(sgl, sg, nelems, i) {
9067 if (in_swiotlb_aperture(sg->dma_address))
9068 sync_single(hwdev, bus_to_virt(sg->dma_address),
9069 sg->dma_length, dir);
9070+ }
9071 }
9072
9073 void
9074-swiotlb_sync_sg_for_device(struct device *hwdev, struct scatterlist *sg,
9075+swiotlb_sync_sg_for_device(struct device *hwdev, struct scatterlist *sgl,
9076 int nelems, int dir)
9077 {
9078+ struct scatterlist *sg;
9079 int i;
9080
9081 BUG_ON(dir == DMA_NONE);
9082
9083- for (i = 0; i < nelems; i++, sg++)
9084+ for_each_sg(sgl, sg, nelems, i) {
9085 if (in_swiotlb_aperture(sg->dma_address))
9086 sync_single(hwdev, bus_to_virt(sg->dma_address),
9087 sg->dma_length, dir);
9088+ }
9089 }
9090
9091 #ifdef CONFIG_HIGHMEM