]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blame - src/patches/60032_xen3-patch-2.6.23.patch1
Stop dhcpcd before starting if it was running
[people/pmueller/ipfire-2.x.git] / src / patches / 60032_xen3-patch-2.6.23.patch1
CommitLineData
cc90b958
BS
1From: www.kernel.org
2Subject: Update to 2.6.23
3Patch-mainline: 2.6.23
4
5Automatically created from "patches.kernel.org/patch-2.6.23" by xen-port-patches.py
6
7Acked-by: jbeulich@novell.com
8
9Index: head-2008-12-01/arch/x86/Makefile
10===================================================================
11--- head-2008-12-01.orig/arch/x86/Makefile 2008-12-01 11:11:08.000000000 +0100
12+++ head-2008-12-01/arch/x86/Makefile 2008-12-01 11:36:47.000000000 +0100
13@@ -148,7 +148,7 @@ libs-y += arch/x86/lib/
14 core-y += $(fcore-y)
15
16 # Xen paravirtualization support
17-core-$(CONFIG_XEN) += arch/x86/xen/
18+core-$(CONFIG_PARAVIRT_XEN) += arch/x86/xen/
19
20 # lguest paravirtualization support
21 core-$(CONFIG_LGUEST_GUEST) += arch/x86/lguest/
22Index: head-2008-12-01/arch/x86/kernel/acpi/sleep_32-xen.c
23===================================================================
24--- head-2008-12-01.orig/arch/x86/kernel/acpi/sleep_32-xen.c 2008-04-15 09:29:41.000000000 +0200
25+++ head-2008-12-01/arch/x86/kernel/acpi/sleep_32-xen.c 2008-12-01 11:36:47.000000000 +0100
26@@ -15,7 +15,7 @@
27 #ifndef CONFIG_ACPI_PV_SLEEP
28 /* address in low memory of the wakeup routine. */
29 unsigned long acpi_wakeup_address = 0;
30-unsigned long acpi_video_flags;
31+unsigned long acpi_realmode_flags;
32 extern char wakeup_start, wakeup_end;
33
34 extern unsigned long FASTCALL(acpi_copy_wakeup_routine(unsigned long));
35@@ -74,9 +74,11 @@ static int __init acpi_sleep_setup(char
36 {
37 while ((str != NULL) && (*str != '\0')) {
38 if (strncmp(str, "s3_bios", 7) == 0)
39- acpi_video_flags = 1;
40+ acpi_realmode_flags |= 1;
41 if (strncmp(str, "s3_mode", 7) == 0)
42- acpi_video_flags |= 2;
43+ acpi_realmode_flags |= 2;
44+ if (strncmp(str, "s3_beep", 7) == 0)
45+ acpi_realmode_flags |= 4;
46 str = strchr(str, ',');
47 if (str != NULL)
48 str += strspn(str, ", \t");
49@@ -86,9 +88,11 @@ static int __init acpi_sleep_setup(char
50
51 __setup("acpi_sleep=", acpi_sleep_setup);
52
53+/* Ouch, we want to delete this. We already have better version in userspace, in
54+ s2ram from suspend.sf.net project */
55 static __init int reset_videomode_after_s3(struct dmi_system_id *d)
56 {
57- acpi_video_flags |= 2;
58+ acpi_realmode_flags |= 2;
59 return 0;
60 }
61
62Index: head-2008-12-01/arch/x86/kernel/asm-offsets_32.c
63===================================================================
64--- head-2008-12-01.orig/arch/x86/kernel/asm-offsets_32.c 2008-12-01 11:36:13.000000000 +0100
65+++ head-2008-12-01/arch/x86/kernel/asm-offsets_32.c 2008-12-01 11:36:47.000000000 +0100
66@@ -19,7 +19,9 @@
67 #include <asm/bootparam.h>
68 #include <asm/elf.h>
69
70+#if defined(CONFIG_XEN) || defined(CONFIG_PARAVIRT_XEN)
71 #include <xen/interface/xen.h>
72+#endif
73
74 #include <linux/lguest.h>
75 #include "../../../drivers/lguest/lg.h"
76@@ -121,7 +123,7 @@ void foo(void)
77 OFFSET(PV_CPU_read_cr0, pv_cpu_ops, read_cr0);
78 #endif
79
80-#ifdef CONFIG_XEN
81+#ifdef CONFIG_PARAVIRT_XEN
82 BLANK();
83 OFFSET(XEN_vcpu_info_mask, vcpu_info, evtchn_upcall_mask);
84 OFFSET(XEN_vcpu_info_pending, vcpu_info, evtchn_upcall_pending);
85Index: head-2008-12-01/arch/x86/kernel/cpu/common-xen.c
86===================================================================
87--- head-2008-12-01.orig/arch/x86/kernel/cpu/common-xen.c 2008-12-01 11:36:13.000000000 +0100
88+++ head-2008-12-01/arch/x86/kernel/cpu/common-xen.c 2008-12-01 11:36:47.000000000 +0100
89@@ -360,6 +360,8 @@ static void __cpuinit generic_identify(s
90 if ( xlvl >= 0x80000004 )
91 get_model_name(c); /* Default name */
92 }
93+
94+ init_scattered_cpuid_features(c);
95 }
96
97 early_intel_workaround(c);
98@@ -611,7 +613,6 @@ extern int nsc_init_cpu(void);
99 extern int amd_init_cpu(void);
100 extern int centaur_init_cpu(void);
101 extern int transmeta_init_cpu(void);
102-extern int rise_init_cpu(void);
103 extern int nexgen_init_cpu(void);
104 extern int umc_init_cpu(void);
105
106@@ -623,7 +624,6 @@ void __init early_cpu_init(void)
107 amd_init_cpu();
108 centaur_init_cpu();
109 transmeta_init_cpu();
110- rise_init_cpu();
111 nexgen_init_cpu();
112 umc_init_cpu();
113 early_cpu_detect();
114Index: head-2008-12-01/arch/x86/kernel/cpu/mtrr/main-xen.c
115===================================================================
116--- head-2008-12-01.orig/arch/x86/kernel/cpu/mtrr/main-xen.c 2008-12-01 11:36:13.000000000 +0100
117+++ head-2008-12-01/arch/x86/kernel/cpu/mtrr/main-xen.c 2008-12-01 11:36:47.000000000 +0100
118@@ -167,7 +167,7 @@ mtrr_del(int reg, unsigned long base, un
119 EXPORT_SYMBOL(mtrr_add);
120 EXPORT_SYMBOL(mtrr_del);
121
122-__init void mtrr_bp_init(void)
123+void __init mtrr_bp_init(void)
124 {
125 }
126
127Index: head-2008-12-01/arch/x86/kernel/e820_32-xen.c
128===================================================================
129--- head-2008-12-01.orig/arch/x86/kernel/e820_32-xen.c 2008-12-01 11:36:13.000000000 +0100
130+++ head-2008-12-01/arch/x86/kernel/e820_32-xen.c 2008-12-01 11:36:47.000000000 +0100
131@@ -10,6 +10,7 @@
132 #include <linux/efi.h>
133 #include <linux/pfn.h>
134 #include <linux/uaccess.h>
135+#include <linux/suspend.h>
136
137 #include <asm/pgtable.h>
138 #include <asm/page.h>
139@@ -343,6 +344,37 @@ static int __init request_standard_resou
140
141 subsys_initcall(request_standard_resources);
142
143+#if defined(CONFIG_PM) && defined(CONFIG_HIBERNATION)
144+/**
145+ * e820_mark_nosave_regions - Find the ranges of physical addresses that do not
146+ * correspond to e820 RAM areas and mark the corresponding pages as nosave for
147+ * hibernation.
148+ *
149+ * This function requires the e820 map to be sorted and without any
150+ * overlapping entries and assumes the first e820 area to be RAM.
151+ */
152+void __init e820_mark_nosave_regions(void)
153+{
154+ int i;
155+ unsigned long pfn;
156+
157+ pfn = PFN_DOWN(e820.map[0].addr + e820.map[0].size);
158+ for (i = 1; i < e820.nr_map; i++) {
159+ struct e820entry *ei = &e820.map[i];
160+
161+ if (pfn < PFN_UP(ei->addr))
162+ register_nosave_region(pfn, PFN_UP(ei->addr));
163+
164+ pfn = PFN_DOWN(ei->addr + ei->size);
165+ if (ei->type != E820_RAM)
166+ register_nosave_region(PFN_UP(ei->addr), pfn);
167+
168+ if (pfn >= max_low_pfn)
169+ break;
170+ }
171+}
172+#endif
173+
174 void __init add_memory_region(unsigned long long start,
175 unsigned long long size, int type)
176 {
177@@ -804,7 +836,7 @@ void __init print_memory_map(char *who)
178 case E820_NVS:
179 printk("(ACPI NVS)\n");
180 break;
181- default: printk("type %lu\n", e820.map[i].type);
182+ default: printk("type %u\n", e820.map[i].type);
183 break;
184 }
185 }
186Index: head-2008-12-01/arch/x86/kernel/entry_32.S
187===================================================================
188--- head-2008-12-01.orig/arch/x86/kernel/entry_32.S 2008-12-01 11:21:02.000000000 +0100
189+++ head-2008-12-01/arch/x86/kernel/entry_32.S 2008-12-01 11:36:47.000000000 +0100
190@@ -1112,7 +1112,7 @@ ENTRY(kernel_thread_helper)
191 CFI_ENDPROC
192 ENDPROC(kernel_thread_helper)
193
194-#ifdef CONFIG_XEN
195+#ifdef CONFIG_PARAVIRT_XEN
196 /* Xen doesn't set %esp to be precisely what the normal sysenter
197 entrypoint expects, so fix it up before using the normal path. */
198 ENTRY(xen_sysenter_target)
199@@ -1205,7 +1205,7 @@ ENTRY(xen_failsafe_callback)
200 .previous
201 ENDPROC(xen_failsafe_callback)
202
203-#endif /* CONFIG_XEN */
204+#endif /* CONFIG_PARAVIRT_XEN */
205
206 #ifdef CONFIG_FTRACE
207 #ifdef CONFIG_DYNAMIC_FTRACE
208Index: head-2008-12-01/arch/x86/kernel/entry_32-xen.S
209===================================================================
210--- head-2008-12-01.orig/arch/x86/kernel/entry_32-xen.S 2008-12-01 11:36:13.000000000 +0100
211+++ head-2008-12-01/arch/x86/kernel/entry_32-xen.S 2008-12-01 11:36:47.000000000 +0100
212@@ -452,9 +452,6 @@ restore_nocheck_notrace:
213 1: INTERRUPT_RETURN
214 .section .fixup,"ax"
215 iret_exc:
216-#ifndef CONFIG_XEN
217- ENABLE_INTERRUPTS(CLBR_NONE)
218-#endif
219 pushl $0 # no error code
220 pushl $do_iret_error
221 jmp error_code
222Index: head-2008-12-01/arch/x86/kernel/head_32-xen.S
223===================================================================
224--- head-2008-12-01.orig/arch/x86/kernel/head_32-xen.S 2008-12-01 11:36:13.000000000 +0100
225+++ head-2008-12-01/arch/x86/kernel/head_32-xen.S 2008-12-01 11:36:47.000000000 +0100
226@@ -86,7 +86,10 @@ ENTRY(_stext)
227 /*
228 * BSS section
229 */
230-.section ".bss.page_aligned","w"
231+.section ".bss.page_aligned","wa"
232+ .align PAGE_SIZE_asm
233+ENTRY(swapper_pg_pmd)
234+ .fill 1024,4,0
235 ENTRY(empty_zero_page)
236 .fill 4096,1,0
237
238@@ -136,25 +139,25 @@ ENTRY(empty_zero_page)
239 #endif /* CONFIG_XEN_COMPAT <= 0x030002 */
240
241
242- ELFNOTE(Xen, XEN_ELFNOTE_GUEST_OS, .asciz, "linux")
243- ELFNOTE(Xen, XEN_ELFNOTE_GUEST_VERSION, .asciz, "2.6")
244- ELFNOTE(Xen, XEN_ELFNOTE_XEN_VERSION, .asciz, "xen-3.0")
245- ELFNOTE(Xen, XEN_ELFNOTE_VIRT_BASE, .long, __PAGE_OFFSET)
246+ ELFNOTE(Xen, XEN_ELFNOTE_GUEST_OS, .asciz "linux")
247+ ELFNOTE(Xen, XEN_ELFNOTE_GUEST_VERSION, .asciz "2.6")
248+ ELFNOTE(Xen, XEN_ELFNOTE_XEN_VERSION, .asciz "xen-3.0")
249+ ELFNOTE(Xen, XEN_ELFNOTE_VIRT_BASE, .long __PAGE_OFFSET)
250 #if CONFIG_XEN_COMPAT <= 0x030002
251- ELFNOTE(Xen, XEN_ELFNOTE_PADDR_OFFSET, .long, __PAGE_OFFSET)
252+ ELFNOTE(Xen, XEN_ELFNOTE_PADDR_OFFSET, .long __PAGE_OFFSET)
253 #else
254- ELFNOTE(Xen, XEN_ELFNOTE_PADDR_OFFSET, .long, 0)
255+ ELFNOTE(Xen, XEN_ELFNOTE_PADDR_OFFSET, .long 0)
256 #endif
257- ELFNOTE(Xen, XEN_ELFNOTE_ENTRY, .long, startup_32)
258- ELFNOTE(Xen, XEN_ELFNOTE_HYPERCALL_PAGE, .long, hypercall_page)
259- ELFNOTE(Xen, XEN_ELFNOTE_HV_START_LOW, .long, HYPERVISOR_VIRT_START)
260- ELFNOTE(Xen, XEN_ELFNOTE_FEATURES, .asciz, "writable_page_tables|writable_descriptor_tables|auto_translated_physmap|pae_pgdir_above_4gb|supervisor_mode_kernel")
261+ ELFNOTE(Xen, XEN_ELFNOTE_ENTRY, .long startup_32)
262+ ELFNOTE(Xen, XEN_ELFNOTE_HYPERCALL_PAGE, .long hypercall_page)
263+ ELFNOTE(Xen, XEN_ELFNOTE_HV_START_LOW, .long HYPERVISOR_VIRT_START)
264+ ELFNOTE(Xen, XEN_ELFNOTE_FEATURES, .asciz "writable_page_tables|writable_descriptor_tables|auto_translated_physmap|pae_pgdir_above_4gb|supervisor_mode_kernel")
265 #ifdef CONFIG_X86_PAE
266- ELFNOTE(Xen, XEN_ELFNOTE_PAE_MODE, .asciz, "yes")
267- ELFNOTE(Xen, XEN_ELFNOTE_L1_MFN_VALID, .quad, _PAGE_PRESENT,_PAGE_PRESENT)
268+ ELFNOTE(Xen, XEN_ELFNOTE_PAE_MODE, .asciz "yes")
269+ ELFNOTE(Xen, XEN_ELFNOTE_L1_MFN_VALID, .quad _PAGE_PRESENT, _PAGE_PRESENT)
270 #else
271- ELFNOTE(Xen, XEN_ELFNOTE_PAE_MODE, .asciz, "no")
272- ELFNOTE(Xen, XEN_ELFNOTE_L1_MFN_VALID, .long, _PAGE_PRESENT,_PAGE_PRESENT)
273+ ELFNOTE(Xen, XEN_ELFNOTE_PAE_MODE, .asciz "no")
274+ ELFNOTE(Xen, XEN_ELFNOTE_L1_MFN_VALID, .long _PAGE_PRESENT, _PAGE_PRESENT)
275 #endif
276- ELFNOTE(Xen, XEN_ELFNOTE_LOADER, .asciz, "generic")
277- ELFNOTE(Xen, XEN_ELFNOTE_SUSPEND_CANCEL, .long, 1)
278+ ELFNOTE(Xen, XEN_ELFNOTE_LOADER, .asciz "generic")
279+ ELFNOTE(Xen, XEN_ELFNOTE_SUSPEND_CANCEL, .long 1)
280Index: head-2008-12-01/arch/x86/kernel/init_task-xen.c
281===================================================================
282--- head-2008-12-01.orig/arch/x86/kernel/init_task-xen.c 2007-06-12 13:12:48.000000000 +0200
283+++ head-2008-12-01/arch/x86/kernel/init_task-xen.c 2008-12-01 11:36:47.000000000 +0100
284@@ -46,6 +46,6 @@ EXPORT_SYMBOL(init_task);
285 * per-CPU TSS segments. Threads are completely 'soft' on Linux,
286 * no more per-task TSS's.
287 */
288-DEFINE_PER_CPU(struct tss_struct, init_tss) ____cacheline_internodealigned_in_smp = INIT_TSS;
289+DEFINE_PER_CPU_SHARED_ALIGNED(struct tss_struct, init_tss) = INIT_TSS;
290 #endif
291
292Index: head-2008-12-01/arch/x86/kernel/io_apic_32-xen.c
293===================================================================
294--- head-2008-12-01.orig/arch/x86/kernel/io_apic_32-xen.c 2008-12-01 11:36:13.000000000 +0100
295+++ head-2008-12-01/arch/x86/kernel/io_apic_32-xen.c 2008-12-01 11:36:47.000000000 +0100
296@@ -402,14 +402,6 @@ static void set_ioapic_affinity_irq(unsi
297 # include <linux/slab.h> /* kmalloc() */
298 # include <linux/timer.h> /* time_after() */
299
300-#ifdef CONFIG_BALANCED_IRQ_DEBUG
301-# define TDprintk(x...) do { printk("<%ld:%s:%d>: ", jiffies, __FILE__, __LINE__); printk(x); } while (0)
302-# define Dprintk(x...) do { TDprintk(x); } while (0)
303-# else
304-# define TDprintk(x...)
305-# define Dprintk(x...)
306-# endif
307-
308 #define IRQBALANCE_CHECK_ARCH -999
309 #define MAX_BALANCED_IRQ_INTERVAL (5*HZ)
310 #define MIN_BALANCED_IRQ_INTERVAL (HZ/2)
311@@ -492,7 +484,7 @@ static inline void balance_irq(int cpu,
312 static inline void rotate_irqs_among_cpus(unsigned long useful_load_threshold)
313 {
314 int i, j;
315- Dprintk("Rotating IRQs among CPUs.\n");
316+
317 for_each_online_cpu(i) {
318 for (j = 0; j < NR_IRQS; j++) {
319 if (!irq_desc[j].action)
320@@ -609,19 +601,11 @@ tryanothercpu:
321 max_loaded = tmp_loaded; /* processor */
322 imbalance = (max_cpu_irq - min_cpu_irq) / 2;
323
324- Dprintk("max_loaded cpu = %d\n", max_loaded);
325- Dprintk("min_loaded cpu = %d\n", min_loaded);
326- Dprintk("max_cpu_irq load = %ld\n", max_cpu_irq);
327- Dprintk("min_cpu_irq load = %ld\n", min_cpu_irq);
328- Dprintk("load imbalance = %lu\n", imbalance);
329-
330 /* if imbalance is less than approx 10% of max load, then
331 * observe diminishing returns action. - quit
332 */
333- if (imbalance < (max_cpu_irq >> 3)) {
334- Dprintk("Imbalance too trivial\n");
335+ if (imbalance < (max_cpu_irq >> 3))
336 goto not_worth_the_effort;
337- }
338
339 tryanotherirq:
340 /* if we select an IRQ to move that can't go where we want, then
341@@ -678,9 +662,6 @@ tryanotherirq:
342 cpus_and(tmp, target_cpu_mask, allowed_mask);
343
344 if (!cpus_empty(tmp)) {
345-
346- Dprintk("irq = %d moved to cpu = %d\n",
347- selected_irq, min_loaded);
348 /* mark for change destination */
349 set_pending_irq(selected_irq, cpumask_of_cpu(min_loaded));
350
351@@ -700,7 +681,6 @@ not_worth_the_effort:
352 */
353 balanced_irq_interval = min((long)MAX_BALANCED_IRQ_INTERVAL,
354 balanced_irq_interval + BALANCED_IRQ_MORE_DELTA);
355- Dprintk("IRQ worth rotating not found\n");
356 return;
357 }
358
359@@ -716,6 +696,7 @@ static int balanced_irq(void *unused)
360 set_pending_irq(i, cpumask_of_cpu(0));
361 }
362
363+ set_freezable();
364 for ( ; ; ) {
365 time_remaining = schedule_timeout_interruptible(time_remaining);
366 try_to_freeze();
367@@ -825,14 +806,6 @@ static int pirq_entries [MAX_PIRQS];
368 static int pirqs_enabled;
369 int skip_ioapic_setup;
370
371-static int __init ioapic_setup(char *str)
372-{
373- skip_ioapic_setup = 1;
374- return 1;
375-}
376-
377-__setup("noapic", ioapic_setup);
378-
379 static int __init ioapic_pirq_setup(char *str)
380 {
381 int i, max;
382@@ -1323,12 +1296,15 @@ static struct irq_chip ioapic_chip;
383 static void ioapic_register_intr(int irq, int vector, unsigned long trigger)
384 {
385 if ((trigger == IOAPIC_AUTO && IO_APIC_irq_trigger(irq)) ||
386- trigger == IOAPIC_LEVEL)
387+ trigger == IOAPIC_LEVEL) {
388+ irq_desc[irq].status |= IRQ_LEVEL;
389 set_irq_chip_and_handler_name(irq, &ioapic_chip,
390 handle_fasteoi_irq, "fasteoi");
391- else
392+ } else {
393+ irq_desc[irq].status &= ~IRQ_LEVEL;
394 set_irq_chip_and_handler_name(irq, &ioapic_chip,
395 handle_edge_irq, "edge");
396+ }
397 set_intr_gate(vector, interrupt[irq]);
398 }
399 #else
400@@ -1957,7 +1933,7 @@ __setup("no_timer_check", notimercheck);
401 * - if this function detects that timer IRQs are defunct, then we fall
402 * back to ISA timer IRQs
403 */
404-int __init timer_irq_works(void)
405+static int __init timer_irq_works(void)
406 {
407 unsigned long t1 = jiffies;
408
409Index: head-2008-12-01/arch/x86/kernel/irq_32-xen.c
410===================================================================
411--- head-2008-12-01.orig/arch/x86/kernel/irq_32-xen.c 2008-12-01 11:36:13.000000000 +0100
412+++ head-2008-12-01/arch/x86/kernel/irq_32-xen.c 2008-12-01 11:36:47.000000000 +0100
413@@ -21,7 +21,7 @@
414 #include <asm/apic.h>
415 #include <asm/uaccess.h>
416
417-DEFINE_PER_CPU(irq_cpustat_t, irq_stat) ____cacheline_internodealigned_in_smp;
418+DEFINE_PER_CPU_SHARED_ALIGNED(irq_cpustat_t, irq_stat);
419 EXPORT_PER_CPU_SYMBOL(irq_stat);
420
421 DEFINE_PER_CPU(struct pt_regs *, irq_regs);
422@@ -149,15 +149,11 @@ fastcall unsigned int do_IRQ(struct pt_r
423
424 #ifdef CONFIG_4KSTACKS
425
426-/*
427- * These should really be __section__(".bss.page_aligned") as well, but
428- * gcc's 3.0 and earlier don't handle that correctly.
429- */
430 static char softirq_stack[NR_CPUS * THREAD_SIZE]
431- __attribute__((__aligned__(THREAD_SIZE)));
432+ __attribute__((__section__(".bss.page_aligned")));
433
434 static char hardirq_stack[NR_CPUS * THREAD_SIZE]
435- __attribute__((__aligned__(THREAD_SIZE)));
436+ __attribute__((__section__(".bss.page_aligned")));
437
438 /*
439 * allocate per-cpu stacks for hardirq and for softirq processing
440Index: head-2008-12-01/arch/x86/kernel/microcode-xen.c
441===================================================================
442--- head-2008-12-01.orig/arch/x86/kernel/microcode-xen.c 2008-12-01 11:36:13.000000000 +0100
443+++ head-2008-12-01/arch/x86/kernel/microcode-xen.c 2008-12-01 11:36:47.000000000 +0100
444@@ -33,6 +33,7 @@
445 #include <linux/miscdevice.h>
446 #include <linux/spinlock.h>
447 #include <linux/mm.h>
448+#include <linux/fs.h>
449 #include <linux/mutex.h>
450 #include <linux/cpu.h>
451 #include <linux/firmware.h>
452Index: head-2008-12-01/arch/x86/kernel/pci-dma-xen.c
453===================================================================
454--- head-2008-12-01.orig/arch/x86/kernel/pci-dma-xen.c 2008-12-01 11:36:13.000000000 +0100
455+++ head-2008-12-01/arch/x86/kernel/pci-dma-xen.c 2008-12-01 11:36:47.000000000 +0100
456@@ -24,7 +24,7 @@
457 #include <asm/bug.h>
458
459 #ifdef __x86_64__
460-#include <asm/proto.h>
461+#include <asm/iommu.h>
462
463 int iommu_merge __read_mostly = 0;
464 EXPORT_SYMBOL(iommu_merge);
465Index: head-2008-12-01/arch/x86/kernel/process_32-xen.c
466===================================================================
467--- head-2008-12-01.orig/arch/x86/kernel/process_32-xen.c 2008-12-01 11:36:13.000000000 +0100
468+++ head-2008-12-01/arch/x86/kernel/process_32-xen.c 2008-12-01 11:36:47.000000000 +0100
469@@ -241,6 +241,7 @@ early_param("idle", idle_setup);
470 void show_regs(struct pt_regs * regs)
471 {
472 unsigned long cr0 = 0L, cr2 = 0L, cr3 = 0L, cr4 = 0L;
473+ unsigned long d0, d1, d2, d3, d6, d7;
474
475 printk("\n");
476 printk("Pid: %d, comm: %20s\n", current->pid, current->comm);
477@@ -265,6 +266,17 @@ void show_regs(struct pt_regs * regs)
478 cr3 = read_cr3();
479 cr4 = read_cr4_safe();
480 printk("CR0: %08lx CR2: %08lx CR3: %08lx CR4: %08lx\n", cr0, cr2, cr3, cr4);
481+
482+ get_debugreg(d0, 0);
483+ get_debugreg(d1, 1);
484+ get_debugreg(d2, 2);
485+ get_debugreg(d3, 3);
486+ printk("DR0: %08lx DR1: %08lx DR2: %08lx DR3: %08lx\n",
487+ d0, d1, d2, d3);
488+ get_debugreg(d6, 6);
489+ get_debugreg(d7, 7);
490+ printk("DR6: %08lx DR7: %08lx\n", d6, d7);
491+
492 show_trace(NULL, regs, &regs->esp);
493 }
494
495@@ -473,7 +485,30 @@ int dump_task_regs(struct task_struct *t
496 return 1;
497 }
498
499-static noinline void __switch_to_xtra(struct task_struct *next_p)
500+#ifdef CONFIG_SECCOMP
501+void hard_disable_TSC(void)
502+{
503+ write_cr4(read_cr4() | X86_CR4_TSD);
504+}
505+void disable_TSC(void)
506+{
507+ preempt_disable();
508+ if (!test_and_set_thread_flag(TIF_NOTSC))
509+ /*
510+ * Must flip the CPU state synchronously with
511+ * TIF_NOTSC in the current running context.
512+ */
513+ hard_disable_TSC();
514+ preempt_enable();
515+}
516+void hard_enable_TSC(void)
517+{
518+ write_cr4(read_cr4() & ~X86_CR4_TSD);
519+}
520+#endif /* CONFIG_SECCOMP */
521+
522+static noinline void
523+__switch_to_xtra(struct task_struct *prev_p, struct task_struct *next_p)
524 {
525 struct thread_struct *next;
526
527@@ -488,33 +523,17 @@ static noinline void __switch_to_xtra(st
528 set_debugreg(next->debugreg[6], 6);
529 set_debugreg(next->debugreg[7], 7);
530 }
531-}
532
533-/*
534- * This function selects if the context switch from prev to next
535- * has to tweak the TSC disable bit in the cr4.
536- */
537-static inline void disable_tsc(struct task_struct *prev_p,
538- struct task_struct *next_p)
539-{
540- struct thread_info *prev, *next;
541-
542- /*
543- * gcc should eliminate the ->thread_info dereference if
544- * has_secure_computing returns 0 at compile time (SECCOMP=n).
545- */
546- prev = task_thread_info(prev_p);
547- next = task_thread_info(next_p);
548-
549- if (has_secure_computing(prev) || has_secure_computing(next)) {
550- /* slow path here */
551- if (has_secure_computing(prev) &&
552- !has_secure_computing(next)) {
553- write_cr4(read_cr4() & ~X86_CR4_TSD);
554- } else if (!has_secure_computing(prev) &&
555- has_secure_computing(next))
556- write_cr4(read_cr4() | X86_CR4_TSD);
557+#ifdef CONFIG_SECCOMP
558+ if (test_tsk_thread_flag(prev_p, TIF_NOTSC) ^
559+ test_tsk_thread_flag(next_p, TIF_NOTSC)) {
560+ /* prev and next are different */
561+ if (test_tsk_thread_flag(next_p, TIF_NOTSC))
562+ hard_disable_TSC();
563+ else
564+ hard_enable_TSC();
565 }
566+#endif
567 }
568
569 /*
570@@ -649,10 +668,9 @@ struct task_struct fastcall * __switch_t
571 /*
572 * Now maybe handle debug registers
573 */
574- if (unlikely(task_thread_info(next_p)->flags & _TIF_WORK_CTXSW))
575- __switch_to_xtra(next_p);
576-
577- disable_tsc(prev_p, next_p);
578+ if (unlikely(task_thread_info(prev_p)->flags & _TIF_WORK_CTXSW_PREV ||
579+ task_thread_info(next_p)->flags & _TIF_WORK_CTXSW_NEXT))
580+ __switch_to_xtra(prev_p, next_p);
581
582 /*
583 * Leave lazy mode, flushing any hypercalls made here.
584Index: head-2008-12-01/arch/x86/kernel/setup_32-xen.c
585===================================================================
586--- head-2008-12-01.orig/arch/x86/kernel/setup_32-xen.c 2008-12-01 11:36:07.000000000 +0100
587+++ head-2008-12-01/arch/x86/kernel/setup_32-xen.c 2008-12-01 11:36:47.000000000 +0100
588@@ -114,19 +114,10 @@ static unsigned int highmem_pages = -1;
589 /*
590 * Setup options
591 */
592-struct drive_info_struct { char dummy[32]; } drive_info;
593-#if defined(CONFIG_BLK_DEV_IDE) || defined(CONFIG_BLK_DEV_HD) || \
594- defined(CONFIG_BLK_DEV_IDE_MODULE) || defined(CONFIG_BLK_DEV_HD_MODULE)
595-EXPORT_SYMBOL(drive_info);
596-#endif
597 struct screen_info screen_info;
598 EXPORT_SYMBOL(screen_info);
599 struct apm_info apm_info;
600 EXPORT_SYMBOL(apm_info);
601-struct sys_desc_table_struct {
602- unsigned short length;
603- unsigned char table[0];
604-};
605 struct edid_info edid_info;
606 EXPORT_SYMBOL_GPL(edid_info);
607 #ifndef CONFIG_XEN
608@@ -149,7 +140,7 @@ unsigned long saved_videomode;
609
610 static char __initdata command_line[COMMAND_LINE_SIZE];
611
612-unsigned char __initdata boot_params[PARAM_SIZE];
613+struct boot_params __initdata boot_params;
614
615 /*
616 * Point at the empty zero page to start with. We map the real shared_info
617@@ -316,18 +307,18 @@ unsigned long __init find_max_low_pfn(vo
618 printk(KERN_WARNING "Warning only %ldMB will be used.\n",
619 MAXMEM>>20);
620 if (max_pfn > MAX_NONPAE_PFN)
621- printk(KERN_WARNING "Use a PAE enabled kernel.\n");
622+ printk(KERN_WARNING "Use a HIGHMEM64G enabled kernel.\n");
623 else
624 printk(KERN_WARNING "Use a HIGHMEM enabled kernel.\n");
625 max_pfn = MAXMEM_PFN;
626 #else /* !CONFIG_HIGHMEM */
627-#ifndef CONFIG_X86_PAE
628+#ifndef CONFIG_HIGHMEM64G
629 if (max_pfn > MAX_NONPAE_PFN) {
630 max_pfn = MAX_NONPAE_PFN;
631 printk(KERN_WARNING "Warning only 4GB will be used.\n");
632- printk(KERN_WARNING "Use a PAE enabled kernel.\n");
633+ printk(KERN_WARNING "Use a HIGHMEM64G enabled kernel.\n");
634 }
635-#endif /* !CONFIG_X86_PAE */
636+#endif /* !CONFIG_HIGHMEM64G */
637 #endif /* !CONFIG_HIGHMEM */
638 } else {
639 if (highmem_pages == -1)
640@@ -514,7 +505,7 @@ void __init setup_bootmem_allocator(void
641 *
642 * This should all compile down to nothing when NUMA is off.
643 */
644-void __init remapped_pgdat_init(void)
645+static void __init remapped_pgdat_init(void)
646 {
647 int nid;
648
649@@ -589,7 +580,6 @@ void __init setup_arch(char **cmdline_p)
650 properly. Setting ROOT_DEV to default to /dev/ram0 breaks initrd.
651 */
652 ROOT_DEV = MKDEV(UNNAMED_MAJOR,0);
653- drive_info = DRIVE_INFO;
654 screen_info = SCREEN_INFO;
655 copy_edid();
656 apm_info.bios = APM_BIOS_INFO;
657@@ -767,6 +757,8 @@ void __init setup_arch(char **cmdline_p)
658 * NOTE: at this point the bootmem allocator is fully available.
659 */
660
661+ paravirt_post_allocator_init();
662+
663 if (is_initial_xendomain())
664 dmi_scan_machine();
665
666@@ -814,6 +806,7 @@ void __init setup_arch(char **cmdline_p)
667 #endif
668
669 e820_register_memory();
670+ e820_mark_nosave_regions();
671
672 if (is_initial_xendomain()) {
673 #ifdef CONFIG_VT
674Index: head-2008-12-01/arch/x86/kernel/smp_32-xen.c
675===================================================================
676--- head-2008-12-01.orig/arch/x86/kernel/smp_32-xen.c 2008-12-01 11:36:13.000000000 +0100
677+++ head-2008-12-01/arch/x86/kernel/smp_32-xen.c 2008-12-01 11:36:47.000000000 +0100
678@@ -22,6 +22,7 @@
679
680 #include <asm/mtrr.h>
681 #include <asm/tlbflush.h>
682+#include <asm/mmu_context.h>
683 #if 0
684 #include <mach_apic.h>
685 #endif
686@@ -217,13 +218,13 @@ static unsigned long flush_va;
687 static DEFINE_SPINLOCK(tlbstate_lock);
688
689 /*
690- * We cannot call mmdrop() because we are in interrupt context,
691+ * We cannot call mmdrop() because we are in interrupt context,
692 * instead update mm->cpu_vm_mask.
693 *
694 * We need to reload %cr3 since the page tables may be going
695 * away from under us..
696 */
697-static inline void leave_mm (unsigned long cpu)
698+void leave_mm(unsigned long cpu)
699 {
700 if (per_cpu(cpu_tlbstate, cpu).state == TLBSTATE_OK)
701 BUG();
702Index: head-2008-12-01/arch/x86/kernel/time_32-xen.c
703===================================================================
704--- head-2008-12-01.orig/arch/x86/kernel/time_32-xen.c 2008-12-01 11:36:13.000000000 +0100
705+++ head-2008-12-01/arch/x86/kernel/time_32-xen.c 2008-12-01 11:36:47.000000000 +0100
706@@ -76,11 +76,12 @@
707 #include <xen/evtchn.h>
708 #include <xen/interface/vcpu.h>
709
710-#ifdef CONFIG_X86_32
711 #include <asm/i8253.h>
712 DEFINE_SPINLOCK(i8253_lock);
713 EXPORT_SYMBOL(i8253_lock);
714-#else
715+
716+#ifdef CONFIG_X86_64
717+#include <asm/vsyscall.h>
718 volatile unsigned long __jiffies __section_jiffies = INITIAL_JIFFIES;
719 #endif
720
721@@ -758,56 +759,10 @@ unsigned long read_persistent_clock(void
722 return retval;
723 }
724
725-static void sync_cmos_clock(unsigned long dummy);
726-
727-static DEFINE_TIMER(sync_cmos_timer, sync_cmos_clock, 0, 0);
728-int no_sync_cmos_clock;
729-
730-static void sync_cmos_clock(unsigned long dummy)
731-{
732- struct timeval now, next;
733- int fail = 1;
734-
735- /*
736- * If we have an externally synchronized Linux clock, then update
737- * CMOS clock accordingly every ~11 minutes. Set_rtc_mmss() has to be
738- * called as close as possible to 500 ms before the new second starts.
739- * This code is run on a timer. If the clock is set, that timer
740- * may not expire at the correct time. Thus, we adjust...
741- */
742- if (!ntp_synced())
743- /*
744- * Not synced, exit, do not restart a timer (if one is
745- * running, let it run out).
746- */
747- return;
748-
749- do_gettimeofday(&now);
750- if (now.tv_usec >= USEC_AFTER - ((unsigned) TICK_SIZE) / 2 &&
751- now.tv_usec <= USEC_BEFORE + ((unsigned) TICK_SIZE) / 2)
752- fail = set_rtc_mmss(now.tv_sec);
753-
754- next.tv_usec = USEC_AFTER - now.tv_usec;
755- if (next.tv_usec <= 0)
756- next.tv_usec += USEC_PER_SEC;
757-
758- if (!fail)
759- next.tv_sec = 659;
760- else
761- next.tv_sec = 0;
762-
763- if (next.tv_usec >= USEC_PER_SEC) {
764- next.tv_sec++;
765- next.tv_usec -= USEC_PER_SEC;
766- }
767- mod_timer(&sync_cmos_timer, jiffies + timeval_to_jiffies(&next));
768-}
769-
770-void notify_arch_cmos_timer(void)
771+int update_persistent_clock(struct timespec now)
772 {
773- if (!no_sync_cmos_clock)
774- mod_timer(&sync_cmos_timer, jiffies + 1);
775 mod_timer(&sync_xen_wallclock_timer, jiffies + 1);
776+ return set_rtc_mmss(now.tv_sec);
777 }
778
779 extern void (*late_time_init)(void);
780Index: head-2008-12-01/arch/x86/kernel/traps_32-xen.c
781===================================================================
782--- head-2008-12-01.orig/arch/x86/kernel/traps_32-xen.c 2008-12-01 11:36:13.000000000 +0100
783+++ head-2008-12-01/arch/x86/kernel/traps_32-xen.c 2008-12-01 11:36:47.000000000 +0100
784@@ -41,6 +41,10 @@
785 #include <linux/mca.h>
786 #endif
787
788+#if defined(CONFIG_EDAC)
789+#include <linux/edac.h>
790+#endif
791+
792 #include <asm/processor.h>
793 #include <asm/system.h>
794 #include <asm/io.h>
795@@ -102,36 +106,45 @@ asmlinkage void machine_check(void);
796 int kstack_depth_to_print = 24;
797 static unsigned int code_bytes = 64;
798
799-static inline int valid_stack_ptr(struct thread_info *tinfo, void *p)
800+static inline int valid_stack_ptr(struct thread_info *tinfo, void *p, unsigned size)
801 {
802 return p > (void *)tinfo &&
803- p < (void *)tinfo + THREAD_SIZE - 3;
804+ p <= (void *)tinfo + THREAD_SIZE - size;
805 }
806
807+/* The form of the top of the frame on the stack */
808+struct stack_frame {
809+ struct stack_frame *next_frame;
810+ unsigned long return_address;
811+};
812+
813 static inline unsigned long print_context_stack(struct thread_info *tinfo,
814 unsigned long *stack, unsigned long ebp,
815 struct stacktrace_ops *ops, void *data)
816 {
817- unsigned long addr;
818-
819 #ifdef CONFIG_FRAME_POINTER
820- while (valid_stack_ptr(tinfo, (void *)ebp)) {
821- unsigned long new_ebp;
822- addr = *(unsigned long *)(ebp + 4);
823+ struct stack_frame *frame = (struct stack_frame *)ebp;
824+ while (valid_stack_ptr(tinfo, frame, sizeof(*frame))) {
825+ struct stack_frame *next;
826+ unsigned long addr;
827+
828+ addr = frame->return_address;
829 ops->address(data, addr);
830 /*
831 * break out of recursive entries (such as
832 * end_of_stack_stop_unwind_function). Also,
833 * we can never allow a frame pointer to
834 * move downwards!
835- */
836- new_ebp = *(unsigned long *)ebp;
837- if (new_ebp <= ebp)
838+ */
839+ next = frame->next_frame;
840+ if (next <= frame)
841 break;
842- ebp = new_ebp;
843+ frame = next;
844 }
845 #else
846- while (valid_stack_ptr(tinfo, stack)) {
847+ while (valid_stack_ptr(tinfo, stack, sizeof(*stack))) {
848+ unsigned long addr;
849+
850 addr = *stack++;
851 if (__kernel_text_address(addr))
852 ops->address(data, addr);
853@@ -154,7 +167,7 @@ void dump_trace(struct task_struct *task
854 if (!stack) {
855 unsigned long dummy;
856 stack = &dummy;
857- if (task && task != current)
858+ if (task != current)
859 stack = (unsigned long *)task->thread.esp;
860 }
861
862@@ -213,6 +226,7 @@ static void print_trace_address(void *da
863 {
864 printk("%s [<%08lx>] ", (char *)data, addr);
865 print_symbol("%s\n", addr);
866+ touch_nmi_watchdog();
867 }
868
869 static struct stacktrace_ops print_trace_ops = {
870@@ -396,7 +410,7 @@ void die(const char * str, struct pt_reg
871 unsigned long esp;
872 unsigned short ss;
873
874- report_bug(regs->eip);
875+ report_bug(regs->eip, regs);
876
877 printk(KERN_EMERG "%s: %04lx [#%d]\n", str, err & 0xffff, ++die_counter);
878 #ifdef CONFIG_PREEMPT
879@@ -439,6 +453,7 @@ void die(const char * str, struct pt_reg
880
881 bust_spinlocks(0);
882 die.lock_owner = -1;
883+ add_taint(TAINT_DIE);
884 spin_unlock_irqrestore(&die.lock, flags);
885
886 if (!regs)
887@@ -523,10 +538,12 @@ fastcall void do_##name(struct pt_regs *
888 do_trap(trapnr, signr, str, 0, regs, error_code, NULL); \
889 }
890
891-#define DO_ERROR_INFO(trapnr, signr, str, name, sicode, siaddr) \
892+#define DO_ERROR_INFO(trapnr, signr, str, name, sicode, siaddr, irq) \
893 fastcall void do_##name(struct pt_regs * regs, long error_code) \
894 { \
895 siginfo_t info; \
896+ if (irq) \
897+ local_irq_enable(); \
898 info.si_signo = signr; \
899 info.si_errno = 0; \
900 info.si_code = sicode; \
901@@ -566,13 +583,13 @@ DO_VM86_ERROR( 3, SIGTRAP, "int3", int3)
902 #endif
903 DO_VM86_ERROR( 4, SIGSEGV, "overflow", overflow)
904 DO_VM86_ERROR( 5, SIGSEGV, "bounds", bounds)
905-DO_ERROR_INFO( 6, SIGILL, "invalid opcode", invalid_op, ILL_ILLOPN, regs->eip)
906+DO_ERROR_INFO( 6, SIGILL, "invalid opcode", invalid_op, ILL_ILLOPN, regs->eip, 0)
907 DO_ERROR( 9, SIGFPE, "coprocessor segment overrun", coprocessor_segment_overrun)
908 DO_ERROR(10, SIGSEGV, "invalid TSS", invalid_TSS)
909 DO_ERROR(11, SIGBUS, "segment not present", segment_not_present)
910 DO_ERROR(12, SIGBUS, "stack segment", stack_segment)
911-DO_ERROR_INFO(17, SIGBUS, "alignment check", alignment_check, BUS_ADRALN, 0)
912-DO_ERROR_INFO(32, SIGSEGV, "iret exception", iret_error, ILL_BADSTK, 0)
913+DO_ERROR_INFO(17, SIGBUS, "alignment check", alignment_check, BUS_ADRALN, 0, 0)
914+DO_ERROR_INFO(32, SIGSEGV, "iret exception", iret_error, ILL_BADSTK, 0, 1)
915
916 fastcall void __kprobes do_general_protection(struct pt_regs * regs,
917 long error_code)
918@@ -585,6 +602,13 @@ fastcall void __kprobes do_general_prote
919
920 current->thread.error_code = error_code;
921 current->thread.trap_no = 13;
922+ if (show_unhandled_signals && unhandled_signal(current, SIGSEGV) &&
923+ printk_ratelimit())
924+ printk(KERN_INFO
925+ "%s[%d] general protection eip:%lx esp:%lx error:%lx\n",
926+ current->comm, current->pid,
927+ regs->eip, regs->esp, error_code);
928+
929 force_sig(SIGSEGV, current);
930 return;
931
932@@ -610,6 +634,14 @@ mem_parity_error(unsigned char reason, s
933 printk(KERN_EMERG "Uhhuh. NMI received for unknown reason %02x on "
934 "CPU %d.\n", reason, smp_processor_id());
935 printk(KERN_EMERG "You have some hardware problem, likely on the PCI bus.\n");
936+
937+#if defined(CONFIG_EDAC)
938+ if(edac_handler_set()) {
939+ edac_atomic_assert_error();
940+ return;
941+ }
942+#endif
943+
944 if (panic_on_unrecovered_nmi)
945 panic("NMI: Not continuing");
946
947@@ -720,6 +752,8 @@ static __kprobes void default_do_nmi(str
948 reassert_nmi();
949 }
950
951+static int ignore_nmis;
952+
953 fastcall __kprobes void do_nmi(struct pt_regs * regs, long error_code)
954 {
955 int cpu;
956@@ -730,11 +764,24 @@ fastcall __kprobes void do_nmi(struct pt
957
958 ++nmi_count(cpu);
959
960- default_do_nmi(regs);
961+ if (!ignore_nmis)
962+ default_do_nmi(regs);
963
964 nmi_exit();
965 }
966
967+void stop_nmi(void)
968+{
969+ acpi_nmi_disable();
970+ ignore_nmis++;
971+}
972+
973+void restart_nmi(void)
974+{
975+ ignore_nmis--;
976+ acpi_nmi_enable();
977+}
978+
979 #ifdef CONFIG_KPROBES
980 fastcall void __kprobes do_int3(struct pt_regs *regs, long error_code)
981 {
982@@ -1023,6 +1070,7 @@ asmlinkage void math_state_restore(void)
983 thread->status |= TS_USEDFPU; /* So we fnsave on switch_to() */
984 tsk->fpu_counter++;
985 }
986+EXPORT_SYMBOL_GPL(math_state_restore);
987
988 #ifndef CONFIG_MATH_EMULATION
989
990Index: head-2008-12-01/arch/x86/mach-xen/setup.c
991===================================================================
992--- head-2008-12-01.orig/arch/x86/mach-xen/setup.c 2008-12-01 11:29:05.000000000 +0100
993+++ head-2008-12-01/arch/x86/mach-xen/setup.c 2008-12-01 11:36:47.000000000 +0100
994@@ -12,6 +12,7 @@
995 #include <asm/e820.h>
996 #include <asm/setup.h>
997 #include <asm/fixmap.h>
998+#include <asm/pgtable.h>
999
1000 #include <xen/interface/callback.h>
1001 #include <xen/interface/memory.h>
1002@@ -101,7 +102,7 @@ void __init pre_setup_arch_hook(void)
1003
1004 init_mm.pgd = swapper_pg_dir = (pgd_t *)xen_start_info->pt_base;
1005
1006- setup_xen_features();
1007+ xen_setup_features();
1008
1009 if (HYPERVISOR_xen_version(XENVER_platform_parameters, &pp) == 0) {
1010 hypervisor_virt_start = pp.virt_start;
1011@@ -157,4 +158,18 @@ void __init machine_specific_arch_setup(
1012 HYPERVISOR_nmi_op(XENNMI_register_callback, &cb);
1013 }
1014 #endif
1015+
1016+ /* Do an early initialization of the fixmap area */
1017+ {
1018+ extern pte_t swapper_pg_pmd[PTRS_PER_PTE];
1019+ unsigned long addr = __fix_to_virt(FIX_EARLYCON_MEM_BASE);
1020+ pgd_t *pgd = (pgd_t *)xen_start_info->pt_base;
1021+ pud_t *pud = pud_offset(pgd + pgd_index(addr), addr);
1022+ pmd_t *pmd = pmd_offset(pud, addr);
1023+
1024+ swapper_pg_dir = pgd;
1025+ init_mm.pgd = pgd;
1026+ make_lowmem_page_readonly(swapper_pg_pmd, XENFEAT_writable_page_tables);
1027+ set_pmd(pmd, __pmd(__pa_symbol(swapper_pg_pmd) | _PAGE_TABLE));
1028+ }
1029 }
1030Index: head-2008-12-01/arch/x86/mm/fault_32-xen.c
1031===================================================================
1032--- head-2008-12-01.orig/arch/x86/mm/fault_32-xen.c 2008-12-01 11:36:13.000000000 +0100
1033+++ head-2008-12-01/arch/x86/mm/fault_32-xen.c 2008-12-01 11:36:47.000000000 +0100
1034@@ -346,7 +346,10 @@ static inline pmd_t *vmalloc_sync_one(pg
1035 pmd_k = pmd_offset(pud_k, address);
1036 if (!pmd_present(*pmd_k))
1037 return NULL;
1038- if (!pmd_present(*pmd))
1039+ if (!pmd_present(*pmd)) {
1040+ bool lazy = x86_read_percpu(xen_lazy_mmu);
1041+
1042+ x86_write_percpu(xen_lazy_mmu, false);
1043 #if CONFIG_XEN_COMPAT > 0x030002
1044 set_pmd(pmd, *pmd_k);
1045 #else
1046@@ -356,7 +359,8 @@ static inline pmd_t *vmalloc_sync_one(pg
1047 */
1048 set_pmd(pmd, __pmd(pmd_val(*pmd_k)));
1049 #endif
1050- else
1051+ x86_write_percpu(xen_lazy_mmu, lazy);
1052+ } else
1053 BUG_ON(pmd_page(*pmd) != pmd_page(*pmd_k));
1054 return pmd_k;
1055 }
1056@@ -388,6 +392,8 @@ static inline int vmalloc_fault(unsigned
1057 return 0;
1058 }
1059
1060+int show_unhandled_signals = 1;
1061+
1062 /*
1063 * This routine handles page faults. It determines the address,
1064 * and the problem, and then passes it off to one of the appropriate
1065@@ -408,6 +414,7 @@ fastcall void __kprobes do_page_fault(st
1066 struct vm_area_struct * vma;
1067 unsigned long address;
1068 int write, si_code;
1069+ int fault;
1070
1071 /* get the address */
1072 address = read_cr2();
1073@@ -541,20 +548,18 @@ good_area:
1074 * make sure we exit gracefully rather than endlessly redo
1075 * the fault.
1076 */
1077- switch (handle_mm_fault(mm, vma, address, write)) {
1078- case VM_FAULT_MINOR:
1079- tsk->min_flt++;
1080- break;
1081- case VM_FAULT_MAJOR:
1082- tsk->maj_flt++;
1083- break;
1084- case VM_FAULT_SIGBUS:
1085- goto do_sigbus;
1086- case VM_FAULT_OOM:
1087+ fault = handle_mm_fault(mm, vma, address, write);
1088+ if (unlikely(fault & VM_FAULT_ERROR)) {
1089+ if (fault & VM_FAULT_OOM)
1090 goto out_of_memory;
1091- default:
1092- BUG();
1093+ else if (fault & VM_FAULT_SIGBUS)
1094+ goto do_sigbus;
1095+ BUG();
1096 }
1097+ if (fault & VM_FAULT_MAJOR)
1098+ tsk->maj_flt++;
1099+ else
1100+ tsk->min_flt++;
1101
1102 /*
1103 * Did it hit the DOS screen memory VA from vm86 mode?
1104@@ -589,6 +594,14 @@ bad_area_nosemaphore:
1105 if (is_prefetch(regs, address, error_code))
1106 return;
1107
1108+ if (show_unhandled_signals && unhandled_signal(tsk, SIGSEGV) &&
1109+ printk_ratelimit()) {
1110+ printk("%s%s[%d]: segfault at %08lx eip %08lx "
1111+ "esp %08lx error %lx\n",
1112+ tsk->pid > 1 ? KERN_INFO : KERN_EMERG,
1113+ tsk->comm, tsk->pid, address, regs->eip,
1114+ regs->esp, error_code);
1115+ }
1116 tsk->thread.cr2 = address;
1117 /* Kernel addresses are always protection faults */
1118 tsk->thread.error_code = error_code | (address >= TASK_SIZE);
1119Index: head-2008-12-01/arch/x86/mm/highmem_32-xen.c
1120===================================================================
1121--- head-2008-12-01.orig/arch/x86/mm/highmem_32-xen.c 2008-12-01 11:36:13.000000000 +0100
1122+++ head-2008-12-01/arch/x86/mm/highmem_32-xen.c 2008-12-01 11:36:47.000000000 +0100
1123@@ -34,17 +34,16 @@ void *kmap_atomic_prot(struct page *page
1124 /* even !CONFIG_PREEMPT needs this, for in_atomic in do_page_fault */
1125 pagefault_disable();
1126
1127- idx = type + KM_TYPE_NR*smp_processor_id();
1128- BUG_ON(!pte_none(*(kmap_pte-idx)));
1129-
1130 if (!PageHighMem(page))
1131 return page_address(page);
1132
1133+ idx = type + KM_TYPE_NR*smp_processor_id();
1134 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
1135+ BUG_ON(!pte_none(*(kmap_pte-idx)));
1136 set_pte_at(&init_mm, vaddr, kmap_pte-idx, mk_pte(page, prot));
1137 /*arch_flush_lazy_mmu_mode();*/
1138
1139- return (void*) vaddr;
1140+ return (void *)vaddr;
1141 }
1142
1143 void *kmap_atomic(struct page *page, enum km_type type)
1144Index: head-2008-12-01/arch/x86/mm/init_32-xen.c
1145===================================================================
1146--- head-2008-12-01.orig/arch/x86/mm/init_32-xen.c 2008-12-01 11:36:13.000000000 +0100
1147+++ head-2008-12-01/arch/x86/mm/init_32-xen.c 2008-12-01 11:36:47.000000000 +0100
1148@@ -96,7 +96,7 @@ static pte_t * __init one_page_table_ini
1149 #endif
1150 pte_t *page_table = (pte_t *) alloc_bootmem_low_pages(PAGE_SIZE);
1151
1152- paravirt_alloc_pt(__pa(page_table) >> PAGE_SHIFT);
1153+ paravirt_alloc_pt(&init_mm, __pa(page_table) >> PAGE_SHIFT);
1154 make_lowmem_page_readonly(page_table,
1155 XENFEAT_writable_page_tables);
1156 set_pmd(pmd, __pmd(__pa(page_table) | _PAGE_TABLE));
1157@@ -446,7 +446,7 @@ static void __init pagetable_init (void)
1158 xen_pagetable_setup_done(pgd_base);
1159 }
1160
1161-#if defined(CONFIG_SOFTWARE_SUSPEND) || defined(CONFIG_ACPI_SLEEP)
1162+#if defined(CONFIG_HIBERNATION) || defined(CONFIG_ACPI)
1163 /*
1164 * Swap suspend & friends need this for resume because things like the intel-agp
1165 * driver might have split up a kernel 4MB mapping.
1166@@ -485,9 +485,13 @@ void zap_low_mappings (void)
1167 flush_tlb_all();
1168 }
1169
1170+int nx_enabled = 0;
1171+
1172+#ifdef CONFIG_X86_PAE
1173+
1174 static int disable_nx __initdata = 0;
1175 u64 __supported_pte_mask __read_mostly = ~_PAGE_NX;
1176-EXPORT_SYMBOL(__supported_pte_mask);
1177+EXPORT_SYMBOL_GPL(__supported_pte_mask);
1178
1179 /*
1180 * noexec = on|off
1181@@ -514,9 +518,6 @@ static int __init noexec_setup(char *str
1182 }
1183 early_param("noexec", noexec_setup);
1184
1185-int nx_enabled = 0;
1186-#ifdef CONFIG_X86_PAE
1187-
1188 static void __init set_nx(void)
1189 {
1190 unsigned int v[4], l, h;
1191@@ -764,7 +765,7 @@ void __init mem_init(void)
1192 zap_low_mappings();
1193 #endif
1194
1195- set_bit(PG_pinned, &virt_to_page(init_mm.pgd)->flags);
1196+ SetPagePinned(virt_to_page(init_mm.pgd));
1197 }
1198
1199 #ifdef CONFIG_MEMORY_HOTPLUG
1200@@ -796,8 +797,7 @@ void __init pgtable_cache_init(void)
1201 PTRS_PER_PMD*sizeof(pmd_t),
1202 PTRS_PER_PMD*sizeof(pmd_t),
1203 SLAB_PANIC,
1204- pmd_ctor,
1205- NULL);
1206+ pmd_ctor);
1207 if (!SHARED_KERNEL_PMD) {
1208 /* If we're in PAE mode and have a non-shared
1209 kernel pmd, then the pgd size must be a
1210Index: head-2008-12-01/arch/x86/mm/ioremap_32-xen.c
1211===================================================================
1212--- head-2008-12-01.orig/arch/x86/mm/ioremap_32-xen.c 2008-12-01 11:36:13.000000000 +0100
1213+++ head-2008-12-01/arch/x86/mm/ioremap_32-xen.c 2008-12-01 11:36:47.000000000 +0100
1214@@ -363,9 +363,8 @@ void iounmap(volatile void __iomem *addr
1215
1216 /* Reset the direct mapping. Can block */
1217 if ((p->flags >> 20) && is_local_lowmem(p->phys_addr)) {
1218- /* p->size includes the guard page, but cpa doesn't like that */
1219 change_page_attr(virt_to_page(bus_to_virt(p->phys_addr)),
1220- (p->size - PAGE_SIZE) >> PAGE_SHIFT,
1221+ get_vm_area_size(p) >> PAGE_SHIFT,
1222 PAGE_KERNEL);
1223 global_flush_tlb();
1224 }
1225Index: head-2008-12-01/arch/x86/mm/pgtable_32-xen.c
1226===================================================================
1227--- head-2008-12-01.orig/arch/x86/mm/pgtable_32-xen.c 2008-12-01 11:36:13.000000000 +0100
1228+++ head-2008-12-01/arch/x86/mm/pgtable_32-xen.c 2008-12-01 11:36:47.000000000 +0100
1229@@ -198,7 +198,7 @@ void pte_free(struct page *pte)
1230 va, pfn_pte(pfn, PAGE_KERNEL), 0))
1231 BUG();
1232 } else
1233- clear_bit(PG_pinned, &pte->flags);
1234+ ClearPagePinned(pte);
1235
1236 ClearPageForeign(pte);
1237 init_page_count(pte);
1238@@ -248,7 +248,7 @@ static inline void pgd_list_del(pgd_t *p
1239
1240 #if (PTRS_PER_PMD == 1)
1241 /* Non-PAE pgd constructor */
1242-void pgd_ctor(void *pgd)
1243+static void pgd_ctor(void *pgd)
1244 {
1245 unsigned long flags;
1246
1247@@ -271,7 +271,7 @@ void pgd_ctor(void *pgd)
1248 }
1249 #else /* PTRS_PER_PMD > 1 */
1250 /* PAE pgd constructor */
1251-void pgd_ctor(void *pgd)
1252+static void pgd_ctor(void *pgd)
1253 {
1254 /* PAE, kernel PMD may be shared */
1255
1256@@ -285,7 +285,7 @@ void pgd_ctor(void *pgd)
1257 }
1258 #endif /* PTRS_PER_PMD */
1259
1260-void pgd_dtor(void *pgd)
1261+static void pgd_dtor(void *pgd)
1262 {
1263 unsigned long flags; /* can be called from interrupt context */
1264
1265@@ -637,9 +637,9 @@ static inline unsigned int pgd_walk_set_
1266
1267 if (PageHighMem(page)) {
1268 if (pgprot_val(flags) & _PAGE_RW)
1269- clear_bit(PG_pinned, &page->flags);
1270+ ClearPagePinned(page);
1271 else
1272- set_bit(PG_pinned, &page->flags);
1273+ SetPagePinned(page);
1274 } else {
1275 MULTI_update_va_mapping(per_cpu(pb_mcl, cpu) + seq,
1276 (unsigned long)__va(pfn << PAGE_SHIFT),
1277@@ -709,19 +709,19 @@ static void __pgd_pin(pgd_t *pgd)
1278 pgd_walk(pgd, PAGE_KERNEL_RO);
1279 kmap_flush_unused();
1280 xen_pgd_pin(__pa(pgd));
1281- set_bit(PG_pinned, &virt_to_page(pgd)->flags);
1282+ SetPagePinned(virt_to_page(pgd));
1283 }
1284
1285 static void __pgd_unpin(pgd_t *pgd)
1286 {
1287 xen_pgd_unpin(__pa(pgd));
1288 pgd_walk(pgd, PAGE_KERNEL);
1289- clear_bit(PG_pinned, &virt_to_page(pgd)->flags);
1290+ ClearPagePinned(virt_to_page(pgd));
1291 }
1292
1293 static void pgd_test_and_unpin(pgd_t *pgd)
1294 {
1295- if (test_bit(PG_pinned, &virt_to_page(pgd)->flags))
1296+ if (PagePinned(virt_to_page(pgd)))
1297 __pgd_unpin(pgd);
1298 }
1299
1300@@ -759,7 +759,7 @@ void mm_pin_all(void)
1301 */
1302 spin_lock_irqsave(&pgd_lock, flags);
1303 for (page = pgd_list; page; page = (struct page *)page->index) {
1304- if (!test_bit(PG_pinned, &page->flags))
1305+ if (!PagePinned(page))
1306 __pgd_pin((pgd_t *)page_address(page));
1307 }
1308 spin_unlock_irqrestore(&pgd_lock, flags);
1309@@ -767,7 +767,7 @@ void mm_pin_all(void)
1310
1311 void arch_dup_mmap(struct mm_struct *oldmm, struct mm_struct *mm)
1312 {
1313- if (!test_bit(PG_pinned, &virt_to_page(mm->pgd)->flags))
1314+ if (!PagePinned(virt_to_page(mm->pgd)))
1315 mm_pin(mm);
1316 }
1317
1318@@ -793,7 +793,7 @@ void arch_exit_mmap(struct mm_struct *mm
1319
1320 task_unlock(tsk);
1321
1322- if (test_bit(PG_pinned, &virt_to_page(mm->pgd)->flags) &&
1323+ if (PagePinned(virt_to_page(mm->pgd)) &&
1324 (atomic_read(&mm->mm_count) == 1) &&
1325 !mm->context.has_foreign_mappings)
1326 mm_unpin(mm);
1327Index: head-2008-12-01/arch/x86/pci/irq-xen.c
1328===================================================================
1329--- head-2008-12-01.orig/arch/x86/pci/irq-xen.c 2008-12-01 11:32:38.000000000 +0100
1330+++ head-2008-12-01/arch/x86/pci/irq-xen.c 2008-12-01 11:36:47.000000000 +0100
1331@@ -142,8 +142,9 @@ static void __init pirq_peer_trick(void)
1332 for(i = 1; i < 256; i++) {
1333 if (!busmap[i] || pci_find_bus(0, i))
1334 continue;
1335- if (pci_scan_bus(i, &pci_root_ops, NULL))
1336- printk(KERN_INFO "PCI: Discovered primary peer bus %02x [IRQ]\n", i);
1337+ if (pci_scan_bus_with_sysdata(i))
1338+ printk(KERN_INFO "PCI: Discovered primary peer "
1339+ "bus %02x [IRQ]\n", i);
1340 }
1341 pcibios_last_bus = -1;
1342 }
1343@@ -553,6 +554,7 @@ static __init int intel_router_probe(str
1344 case PCI_DEVICE_ID_INTEL_ICH9_3:
1345 case PCI_DEVICE_ID_INTEL_ICH9_4:
1346 case PCI_DEVICE_ID_INTEL_ICH9_5:
1347+ case PCI_DEVICE_ID_INTEL_TOLAPAI_0:
1348 r->name = "PIIX/ICH";
1349 r->get = pirq_piix_get;
1350 r->set = pirq_piix_set;
1351Index: head-2008-12-01/arch/x86/xen/Kconfig
1352===================================================================
1353--- head-2008-12-01.orig/arch/x86/xen/Kconfig 2008-12-01 10:53:14.000000000 +0100
1354+++ head-2008-12-01/arch/x86/xen/Kconfig 2008-12-01 11:36:47.000000000 +0100
1355@@ -2,7 +2,7 @@
1356 # This Kconfig describes xen options
1357 #
1358
1359-config XEN
1360+config PARAVIRT_XEN
1361 bool "Xen guest support"
1362 select PARAVIRT
1363 select PARAVIRT_CLOCK
1364Index: head-2008-12-01/arch/x86/xen/xen-head.S
1365===================================================================
1366--- head-2008-12-01.orig/arch/x86/xen/xen-head.S 2008-12-01 10:53:14.000000000 +0100
1367+++ head-2008-12-01/arch/x86/xen/xen-head.S 2008-12-01 11:36:47.000000000 +0100
1368@@ -1,7 +1,7 @@
1369 /* Xen-specific pieces of head.S, intended to be included in the right
1370 place in head.S */
1371
1372-#ifdef CONFIG_XEN
1373+#ifdef CONFIG_PARAVIRT_XEN
1374
1375 #include <linux/elfnote.h>
1376 #include <linux/init.h>
1377@@ -52,4 +52,4 @@ ENTRY(hypercall_page)
1378 ELFNOTE(Xen, XEN_ELFNOTE_HV_START_LOW, _ASM_PTR __HYPERVISOR_VIRT_START)
1379 ELFNOTE(Xen, XEN_ELFNOTE_PADDR_OFFSET, _ASM_PTR 0)
1380
1381-#endif /*CONFIG_XEN */
1382+#endif /* CONFIG_PARAVIRT_XEN */
1383Index: head-2008-12-01/arch/x86/ia32/ia32entry-xen.S
1384===================================================================
1385--- head-2008-12-01.orig/arch/x86/ia32/ia32entry-xen.S 2008-12-01 11:36:13.000000000 +0100
1386+++ head-2008-12-01/arch/x86/ia32/ia32entry-xen.S 2008-12-01 11:36:47.000000000 +0100
1387@@ -105,7 +105,7 @@ ENTRY(ia32_sysenter_target)
1388 movl $VSYSCALL32_SYSEXIT,8(%rsp)
1389 movq %rax,(%rsp)
1390 cld
1391- SAVE_ARGS 0,0,0
1392+ SAVE_ARGS 0,0,1
1393 /* no need to do an access_ok check here because rbp has been
1394 32bit zero extended */
1395 1: movl (%rbp),%r9d
1396@@ -244,7 +244,7 @@ ia32_badarg:
1397 */
1398
1399 ENTRY(ia32_syscall)
1400- CFI_STARTPROC simple
1401+ CFI_STARTPROC32 simple
1402 CFI_SIGNAL_FRAME
1403 CFI_DEF_CFA rsp,SS+8-RIP+16
1404 /*CFI_REL_OFFSET ss,SS-RIP+16*/
1405@@ -280,6 +280,7 @@ ia32_sysret:
1406
1407 ia32_tracesys:
1408 SAVE_REST
1409+ CLEAR_RREGS
1410 movq $-ENOSYS,RAX(%rsp) /* really needed? */
1411 movq %rsp,%rdi /* &pt_regs -> arg1 */
1412 call syscall_trace_enter
1413@@ -476,7 +477,7 @@ ia32_sys_call_table:
1414 .quad sys_init_module
1415 .quad sys_delete_module
1416 .quad quiet_ni_syscall /* 130 get_kernel_syms */
1417- .quad sys_quotactl
1418+ .quad sys32_quotactl
1419 .quad sys_getpgid
1420 .quad sys_fchdir
1421 .quad quiet_ni_syscall /* bdflush */
1422@@ -669,4 +670,5 @@ ia32_sys_call_table:
1423 .quad compat_sys_signalfd
1424 .quad compat_sys_timerfd
1425 .quad sys_eventfd
1426+ .quad sys32_fallocate
1427 ia32_syscall_end:
1428Index: head-2008-12-01/arch/x86/kernel/acpi/sleep_64-xen.c
1429===================================================================
1430--- head-2008-12-01.orig/arch/x86/kernel/acpi/sleep_64-xen.c 2008-12-01 11:36:13.000000000 +0100
1431+++ head-2008-12-01/arch/x86/kernel/acpi/sleep_64-xen.c 2008-12-01 11:36:47.000000000 +0100
1432@@ -51,12 +51,10 @@
1433 Low-Level Sleep Support
1434 -------------------------------------------------------------------------- */
1435
1436-#ifdef CONFIG_ACPI_SLEEP
1437-
1438 #ifndef CONFIG_ACPI_PV_SLEEP
1439 /* address in low memory of the wakeup routine. */
1440 unsigned long acpi_wakeup_address = 0;
1441-unsigned long acpi_video_flags;
1442+unsigned long acpi_realmode_flags;
1443 extern char wakeup_start, wakeup_end;
1444
1445 extern unsigned long acpi_copy_wakeup_routine(unsigned long);
1446@@ -109,9 +107,11 @@ static int __init acpi_sleep_setup(char
1447 {
1448 while ((str != NULL) && (*str != '\0')) {
1449 if (strncmp(str, "s3_bios", 7) == 0)
1450- acpi_video_flags = 1;
1451+ acpi_realmode_flags |= 1;
1452 if (strncmp(str, "s3_mode", 7) == 0)
1453- acpi_video_flags |= 2;
1454+ acpi_realmode_flags |= 2;
1455+ if (strncmp(str, "s3_beep", 7) == 0)
1456+ acpi_realmode_flags |= 4;
1457 str = strchr(str, ',');
1458 if (str != NULL)
1459 str += strspn(str, ", \t");
1460@@ -123,8 +123,6 @@ static int __init acpi_sleep_setup(char
1461 __setup("acpi_sleep=", acpi_sleep_setup);
1462 #endif /* CONFIG_ACPI_PV_SLEEP */
1463
1464-#endif /*CONFIG_ACPI_SLEEP */
1465-
1466 void acpi_pci_link_exit(void)
1467 {
1468 }
1469Index: head-2008-12-01/arch/x86/kernel/apic_64-xen.c
1470===================================================================
1471--- head-2008-12-01.orig/arch/x86/kernel/apic_64-xen.c 2008-12-01 11:36:13.000000000 +0100
1472+++ head-2008-12-01/arch/x86/kernel/apic_64-xen.c 2008-12-01 11:36:47.000000000 +0100
1473@@ -50,7 +50,7 @@ void ack_bad_irq(unsigned int irq)
1474 * holds up an irq slot - in excessive cases (when multiple
1475 * unexpected vectors occur) that might lock up the APIC
1476 * completely.
1477- * But don't ack when the APIC is disabled. -AK
1478+ * But don't ack when the APIC is disabled. -AK
1479 */
1480 if (!disable_apic)
1481 ack_APIC_irq();
1482@@ -132,20 +132,6 @@ asmlinkage void smp_spurious_interrupt(v
1483 if (v & (1 << (SPURIOUS_APIC_VECTOR & 0x1f)))
1484 ack_APIC_irq();
1485
1486-#if 0
1487- static unsigned long last_warning;
1488- static unsigned long skipped;
1489-
1490- /* see sw-dev-man vol 3, chapter 7.4.13.5 */
1491- if (time_before(last_warning+30*HZ,jiffies)) {
1492- printk(KERN_INFO "spurious APIC interrupt on CPU#%d, %ld skipped.\n",
1493- smp_processor_id(), skipped);
1494- last_warning = jiffies;
1495- skipped = 0;
1496- } else {
1497- skipped++;
1498- }
1499-#endif
1500 irq_exit();
1501 }
1502
1503@@ -177,7 +163,7 @@ asmlinkage void smp_error_interrupt(void
1504 7: Illegal register address
1505 */
1506 printk (KERN_DEBUG "APIC error on CPU%d: %02x(%02x)\n",
1507- smp_processor_id(), v , v1);
1508+ smp_processor_id(), v , v1);
1509 irq_exit();
1510 }
1511
1512Index: head-2008-12-01/arch/x86/kernel/e820_64-xen.c
1513===================================================================
1514--- head-2008-12-01.orig/arch/x86/kernel/e820_64-xen.c 2008-12-01 11:36:13.000000000 +0100
1515+++ head-2008-12-01/arch/x86/kernel/e820_64-xen.c 2008-12-01 11:36:47.000000000 +0100
1516@@ -222,37 +222,6 @@ unsigned long __init e820_end_of_ram(voi
1517 }
1518
1519 /*
1520- * Find the hole size in the range.
1521- */
1522-unsigned long __init e820_hole_size(unsigned long start, unsigned long end)
1523-{
1524- unsigned long ram = 0;
1525- int i;
1526-
1527- for (i = 0; i < e820.nr_map; i++) {
1528- struct e820entry *ei = &e820.map[i];
1529- unsigned long last, addr;
1530-
1531- if (ei->type != E820_RAM ||
1532- ei->addr+ei->size <= start ||
1533- ei->addr >= end)
1534- continue;
1535-
1536- addr = round_up(ei->addr, PAGE_SIZE);
1537- if (addr < start)
1538- addr = start;
1539-
1540- last = round_down(ei->addr + ei->size, PAGE_SIZE);
1541- if (last >= end)
1542- last = end;
1543-
1544- if (last > addr)
1545- ram += last - addr;
1546- }
1547- return ((end - start) - ram);
1548-}
1549-
1550-/*
1551 * Mark e820 reserved areas as busy for the resource manager.
1552 */
1553 void __init e820_reserve_resources(struct e820entry *e820, int nr_map)
1554@@ -325,47 +294,61 @@ void __init e820_mark_nosave_regions(voi
1555 }
1556 #endif
1557
1558+/*
1559+ * Finds an active region in the address range from start_pfn to end_pfn and
1560+ * returns its range in ei_startpfn and ei_endpfn for the e820 entry.
1561+ */
1562+static int __init e820_find_active_region(const struct e820entry *ei,
1563+ unsigned long start_pfn,
1564+ unsigned long end_pfn,
1565+ unsigned long *ei_startpfn,
1566+ unsigned long *ei_endpfn)
1567+{
1568+ *ei_startpfn = round_up(ei->addr, PAGE_SIZE) >> PAGE_SHIFT;
1569+ *ei_endpfn = round_down(ei->addr + ei->size, PAGE_SIZE) >> PAGE_SHIFT;
1570+
1571+ /* Skip map entries smaller than a page */
1572+ if (*ei_startpfn >= *ei_endpfn)
1573+ return 0;
1574+
1575+ /* Check if end_pfn_map should be updated */
1576+ if (ei->type != E820_RAM && *ei_endpfn > end_pfn_map)
1577+ end_pfn_map = *ei_endpfn;
1578+
1579+ /* Skip if map is outside the node */
1580+ if (ei->type != E820_RAM || *ei_endpfn <= start_pfn ||
1581+ *ei_startpfn >= end_pfn)
1582+ return 0;
1583+
1584+ /* Check for overlaps */
1585+ if (*ei_startpfn < start_pfn)
1586+ *ei_startpfn = start_pfn;
1587+ if (*ei_endpfn > end_pfn)
1588+ *ei_endpfn = end_pfn;
1589+
1590+ /* Obey end_user_pfn to save on memmap */
1591+ if (*ei_startpfn >= end_user_pfn)
1592+ return 0;
1593+ if (*ei_endpfn > end_user_pfn)
1594+ *ei_endpfn = end_user_pfn;
1595+
1596+ return 1;
1597+}
1598+
1599 /* Walk the e820 map and register active regions within a node */
1600 void __init
1601 e820_register_active_regions(int nid, unsigned long start_pfn,
1602 unsigned long end_pfn)
1603 {
1604+ unsigned long ei_startpfn;
1605+ unsigned long ei_endpfn;
1606 int i;
1607- unsigned long ei_startpfn, ei_endpfn;
1608- for (i = 0; i < e820.nr_map; i++) {
1609- struct e820entry *ei = &e820.map[i];
1610- ei_startpfn = round_up(ei->addr, PAGE_SIZE) >> PAGE_SHIFT;
1611- ei_endpfn = round_down(ei->addr + ei->size, PAGE_SIZE)
1612- >> PAGE_SHIFT;
1613-
1614- /* Skip map entries smaller than a page */
1615- if (ei_startpfn >= ei_endpfn)
1616- continue;
1617-
1618- /* Check if end_pfn_map should be updated */
1619- if (ei->type != E820_RAM && ei_endpfn > end_pfn_map)
1620- end_pfn_map = ei_endpfn;
1621-
1622- /* Skip if map is outside the node */
1623- if (ei->type != E820_RAM ||
1624- ei_endpfn <= start_pfn ||
1625- ei_startpfn >= end_pfn)
1626- continue;
1627-
1628- /* Check for overlaps */
1629- if (ei_startpfn < start_pfn)
1630- ei_startpfn = start_pfn;
1631- if (ei_endpfn > end_pfn)
1632- ei_endpfn = end_pfn;
1633-
1634- /* Obey end_user_pfn to save on memmap */
1635- if (ei_startpfn >= end_user_pfn)
1636- continue;
1637- if (ei_endpfn > end_user_pfn)
1638- ei_endpfn = end_user_pfn;
1639
1640- add_active_range(nid, ei_startpfn, ei_endpfn);
1641- }
1642+ for (i = 0; i < e820.nr_map; i++)
1643+ if (e820_find_active_region(&e820.map[i],
1644+ start_pfn, end_pfn,
1645+ &ei_startpfn, &ei_endpfn))
1646+ add_active_range(nid, ei_startpfn, ei_endpfn);
1647 }
1648
1649 /*
1650@@ -386,12 +369,35 @@ void __init add_memory_region(unsigned l
1651 e820.nr_map++;
1652 }
1653
1654+/*
1655+ * Find the hole size (in bytes) in the memory range.
1656+ * @start: starting address of the memory range to scan
1657+ * @end: ending address of the memory range to scan
1658+ */
1659+unsigned long __init e820_hole_size(unsigned long start, unsigned long end)
1660+{
1661+ unsigned long start_pfn = start >> PAGE_SHIFT;
1662+ unsigned long end_pfn = end >> PAGE_SHIFT;
1663+ unsigned long ei_startpfn;
1664+ unsigned long ei_endpfn;
1665+ unsigned long ram = 0;
1666+ int i;
1667+
1668+ for (i = 0; i < e820.nr_map; i++) {
1669+ if (e820_find_active_region(&e820.map[i],
1670+ start_pfn, end_pfn,
1671+ &ei_startpfn, &ei_endpfn))
1672+ ram += ei_endpfn - ei_startpfn;
1673+ }
1674+ return end - start - (ram << PAGE_SHIFT);
1675+}
1676+
1677 void __init e820_print_map(char *who)
1678 {
1679 int i;
1680
1681 for (i = 0; i < e820.nr_map; i++) {
1682- printk(" %s: %016Lx - %016Lx ", who,
1683+ printk(KERN_INFO " %s: %016Lx - %016Lx ", who,
1684 (unsigned long long) e820.map[i].addr,
1685 (unsigned long long) (e820.map[i].addr + e820.map[i].size));
1686 switch (e820.map[i].type) {
1687Index: head-2008-12-01/arch/x86/kernel/early_printk-xen.c
1688===================================================================
1689--- head-2008-12-01.orig/arch/x86/kernel/early_printk-xen.c 2008-12-01 11:36:13.000000000 +0100
1690+++ head-2008-12-01/arch/x86/kernel/early_printk-xen.c 2008-12-01 11:36:47.000000000 +0100
1691@@ -174,6 +174,7 @@ static __init void early_serial_init(cha
1692 * mappings. Someone should fix this for domain 0. For now, use fake serial.
1693 */
1694 #define early_vga_console early_serial_console
1695+#define xenboot_console early_serial_console
1696
1697 #endif
1698
1699@@ -261,20 +262,22 @@ static int __init setup_early_printk(cha
1700 } else if (!strncmp(buf, "ttyS", 4)) {
1701 early_serial_init(buf);
1702 early_console = &early_serial_console;
1703- } else if (!strncmp(buf, "vga", 3)
1704+ } else if (!strncmp(buf, "vga", 3)) {
1705 #ifndef CONFIG_XEN
1706 && SCREEN_INFO.orig_video_isVGA == 1) {
1707 max_xpos = SCREEN_INFO.orig_video_cols;
1708 max_ypos = SCREEN_INFO.orig_video_lines;
1709 current_ypos = SCREEN_INFO.orig_y;
1710-#else
1711- || !strncmp(buf, "xen", 3)) {
1712 #endif
1713 early_console = &early_vga_console;
1714 } else if (!strncmp(buf, "simnow", 6)) {
1715 simnow_init(buf + 6);
1716 early_console = &simnow_console;
1717 keep_early = 1;
1718+#ifdef CONFIG_XEN
1719+ } else if (!strncmp(buf, "xen", 3)) {
1720+ early_console = &xenboot_console;
1721+#endif
1722 }
1723
1724 if (keep_early)
1725Index: head-2008-12-01/arch/x86/kernel/entry_64-xen.S
1726===================================================================
1727--- head-2008-12-01.orig/arch/x86/kernel/entry_64-xen.S 2008-12-01 11:36:13.000000000 +0100
1728+++ head-2008-12-01/arch/x86/kernel/entry_64-xen.S 2008-12-01 11:36:47.000000000 +0100
1729@@ -310,7 +310,7 @@ sysret_signal:
1730 TRACE_IRQS_ON
1731 /* sti */
1732 XEN_UNBLOCK_EVENTS(%rsi)
1733- testl $(_TIF_SIGPENDING|_TIF_NOTIFY_RESUME|_TIF_SINGLESTEP),%edx
1734+ testl $(_TIF_SIGPENDING|_TIF_SINGLESTEP|_TIF_MCE_NOTIFY),%edx
1735 jz 1f
1736
1737 /* Really a signal */
1738@@ -409,7 +409,7 @@ int_very_careful:
1739 jmp int_restore_rest
1740
1741 int_signal:
1742- testl $(_TIF_NOTIFY_RESUME|_TIF_SIGPENDING|_TIF_SINGLESTEP),%edx
1743+ testl $(_TIF_SIGPENDING|_TIF_SINGLESTEP|_TIF_MCE_NOTIFY),%edx
1744 jz 1f
1745 movq %rsp,%rdi # &ptregs -> arg1
1746 xorl %esi,%esi # oldset -> arg2
1747@@ -552,7 +552,7 @@ retint_careful:
1748 jmp retint_check
1749
1750 retint_signal:
1751- testl $(_TIF_SIGPENDING|_TIF_NOTIFY_RESUME|_TIF_SINGLESTEP),%edx
1752+ testl $(_TIF_SIGPENDING|_TIF_SINGLESTEP|_TIF_MCE_NOTIFY),%edx
1753 jz retint_restore_args
1754 TRACE_IRQS_ON
1755 XEN_UNBLOCK_EVENTS(%rsi)
1756Index: head-2008-12-01/arch/x86/kernel/head_64-xen.S
1757===================================================================
1758--- head-2008-12-01.orig/arch/x86/kernel/head_64-xen.S 2008-12-01 11:36:13.000000000 +0100
1759+++ head-2008-12-01/arch/x86/kernel/head_64-xen.S 2008-12-01 11:36:47.000000000 +0100
1760@@ -23,7 +23,7 @@
1761 #include <asm/dwarf2.h>
1762 #include <xen/interface/elfnote.h>
1763
1764- .section .bootstrap.text, "ax", @progbits
1765+ .section .text.head, "ax", @progbits
1766 .code64
1767 .globl startup_64
1768 startup_64:
1769@@ -39,7 +39,7 @@ startup_64:
1770
1771 #define NEXT_PAGE(name) \
1772 .balign PAGE_SIZE; \
1773- phys_##name = . - .bootstrap.text; \
1774+ phys_##name = . - .text.head; \
1775 ENTRY(name)
1776
1777 NEXT_PAGE(init_level4_pgt)
1778@@ -66,6 +66,12 @@ NEXT_PAGE(level3_user_pgt)
1779 NEXT_PAGE(level2_kernel_pgt)
1780 .fill 512,8,0
1781
1782+NEXT_PAGE(level2_fixmap_pgt)
1783+ .fill 512,8,0
1784+
1785+NEXT_PAGE(level1_fixmap_pgt)
1786+ .fill 512,8,0
1787+
1788 NEXT_PAGE(hypercall_page)
1789 CFI_STARTPROC
1790 .rept 0x1000 / 0x20
1791@@ -172,18 +178,18 @@ ENTRY(empty_zero_page)
1792 .byte 0
1793 #endif /* CONFIG_XEN_COMPAT <= 0x030002 */
1794
1795- ELFNOTE(Xen, XEN_ELFNOTE_GUEST_OS, .asciz, "linux")
1796- ELFNOTE(Xen, XEN_ELFNOTE_GUEST_VERSION, .asciz, "2.6")
1797- ELFNOTE(Xen, XEN_ELFNOTE_XEN_VERSION, .asciz, "xen-3.0")
1798- ELFNOTE(Xen, XEN_ELFNOTE_VIRT_BASE, .quad, __START_KERNEL_map)
1799+ ELFNOTE(Xen, XEN_ELFNOTE_GUEST_OS, .asciz "linux")
1800+ ELFNOTE(Xen, XEN_ELFNOTE_GUEST_VERSION, .asciz "2.6")
1801+ ELFNOTE(Xen, XEN_ELFNOTE_XEN_VERSION, .asciz "xen-3.0")
1802+ ELFNOTE(Xen, XEN_ELFNOTE_VIRT_BASE, .quad __START_KERNEL_map)
1803 #if CONFIG_XEN_COMPAT <= 0x030002
1804- ELFNOTE(Xen, XEN_ELFNOTE_PADDR_OFFSET, .quad, __START_KERNEL_map)
1805+ ELFNOTE(Xen, XEN_ELFNOTE_PADDR_OFFSET, .quad __START_KERNEL_map)
1806 #else
1807- ELFNOTE(Xen, XEN_ELFNOTE_PADDR_OFFSET, .quad, 0)
1808+ ELFNOTE(Xen, XEN_ELFNOTE_PADDR_OFFSET, .quad 0)
1809 #endif
1810- ELFNOTE(Xen, XEN_ELFNOTE_ENTRY, .quad, startup_64)
1811- ELFNOTE(Xen, XEN_ELFNOTE_HYPERCALL_PAGE, .quad, hypercall_page)
1812- ELFNOTE(Xen, XEN_ELFNOTE_L1_MFN_VALID, .quad, _PAGE_PRESENT,_PAGE_PRESENT)
1813- ELFNOTE(Xen, XEN_ELFNOTE_FEATURES, .asciz, "writable_page_tables|writable_descriptor_tables|auto_translated_physmap|pae_pgdir_above_4gb|supervisor_mode_kernel")
1814- ELFNOTE(Xen, XEN_ELFNOTE_LOADER, .asciz, "generic")
1815- ELFNOTE(Xen, XEN_ELFNOTE_SUSPEND_CANCEL, .long, 1)
1816+ ELFNOTE(Xen, XEN_ELFNOTE_ENTRY, .quad startup_64)
1817+ ELFNOTE(Xen, XEN_ELFNOTE_HYPERCALL_PAGE, .quad hypercall_page)
1818+ ELFNOTE(Xen, XEN_ELFNOTE_L1_MFN_VALID, .quad _PAGE_PRESENT, _PAGE_PRESENT)
1819+ ELFNOTE(Xen, XEN_ELFNOTE_FEATURES, .asciz "writable_page_tables|writable_descriptor_tables|auto_translated_physmap|pae_pgdir_above_4gb|supervisor_mode_kernel")
1820+ ELFNOTE(Xen, XEN_ELFNOTE_LOADER, .asciz "generic")
1821+ ELFNOTE(Xen, XEN_ELFNOTE_SUSPEND_CANCEL, .long 1)
1822Index: head-2008-12-01/arch/x86/kernel/head64-xen.c
1823===================================================================
1824--- head-2008-12-01.orig/arch/x86/kernel/head64-xen.c 2008-12-01 11:36:13.000000000 +0100
1825+++ head-2008-12-01/arch/x86/kernel/head64-xen.c 2008-12-01 11:36:47.000000000 +0100
1826@@ -90,7 +90,7 @@ void __init x86_64_start_kernel(char * r
1827 unsigned long machine_to_phys_nr_ents;
1828 int i;
1829
1830- setup_xen_features();
1831+ xen_setup_features();
1832
1833 xen_start_info = (struct start_info *)real_mode_data;
1834 if (!xen_feature(XENFEAT_auto_translated_physmap))
1835Index: head-2008-12-01/arch/x86/kernel/io_apic_64-xen.c
1836===================================================================
1837--- head-2008-12-01.orig/arch/x86/kernel/io_apic_64-xen.c 2008-12-01 11:36:13.000000000 +0100
1838+++ head-2008-12-01/arch/x86/kernel/io_apic_64-xen.c 2008-12-01 11:36:47.000000000 +0100
1839@@ -165,7 +165,9 @@ static inline void io_apic_write(unsigne
1840 #endif
1841 }
1842
1843-#ifndef CONFIG_XEN
1844+#ifdef CONFIG_XEN
1845+#define io_apic_modify io_apic_write
1846+#else
1847 /*
1848 * Re-write a value: to be used for read-modify-write
1849 * cycles where the read already set up the index register.
1850@@ -175,8 +177,32 @@ static inline void io_apic_modify(unsign
1851 struct io_apic __iomem *io_apic = io_apic_base(apic);
1852 writel(value, &io_apic->data);
1853 }
1854-#else
1855-#define io_apic_modify io_apic_write
1856+
1857+static int io_apic_level_ack_pending(unsigned int irq)
1858+{
1859+ struct irq_pin_list *entry;
1860+ unsigned long flags;
1861+ int pending = 0;
1862+
1863+ spin_lock_irqsave(&ioapic_lock, flags);
1864+ entry = irq_2_pin + irq;
1865+ for (;;) {
1866+ unsigned int reg;
1867+ int pin;
1868+
1869+ pin = entry->pin;
1870+ if (pin == -1)
1871+ break;
1872+ reg = io_apic_read(entry->apic, 0x10 + pin*2);
1873+ /* Is the remote IRR bit set? */
1874+ pending |= (reg >> 14) & 1;
1875+ if (!entry->next)
1876+ break;
1877+ entry = irq_2_pin + entry->next;
1878+ }
1879+ spin_unlock_irqrestore(&ioapic_lock, flags);
1880+ return pending;
1881+}
1882 #endif
1883
1884 /*
1885@@ -406,14 +432,12 @@ static void clear_IO_APIC (void)
1886 int skip_ioapic_setup;
1887 int ioapic_force;
1888
1889-/* dummy parsing: see setup.c */
1890-
1891-static int __init disable_ioapic_setup(char *str)
1892+static int __init parse_noapic(char *str)
1893 {
1894- skip_ioapic_setup = 1;
1895+ disable_ioapic_setup();
1896 return 0;
1897 }
1898-early_param("noapic", disable_ioapic_setup);
1899+early_param("noapic", parse_noapic);
1900
1901 /* Actually the next is obsolete, but keep it for paranoid reasons -AK */
1902 static int __init disable_timer_pin_setup(char *arg)
1903@@ -765,12 +789,15 @@ static struct irq_chip ioapic_chip;
1904
1905 static void ioapic_register_intr(int irq, unsigned long trigger)
1906 {
1907- if (trigger)
1908+ if (trigger) {
1909+ irq_desc[irq].status |= IRQ_LEVEL;
1910 set_irq_chip_and_handler_name(irq, &ioapic_chip,
1911 handle_fasteoi_irq, "fasteoi");
1912- else
1913+ } else {
1914+ irq_desc[irq].status &= ~IRQ_LEVEL;
1915 set_irq_chip_and_handler_name(irq, &ioapic_chip,
1916 handle_edge_irq, "edge");
1917+ }
1918 }
1919 #else
1920 #define ioapic_register_intr(irq, trigger) evtchn_register_pirq(irq)
1921@@ -1419,9 +1446,37 @@ static void ack_apic_level(unsigned int
1922 ack_APIC_irq();
1923
1924 /* Now we can move and renable the irq */
1925- move_masked_irq(irq);
1926- if (unlikely(do_unmask_irq))
1927+ if (unlikely(do_unmask_irq)) {
1928+ /* Only migrate the irq if the ack has been received.
1929+ *
1930+ * On rare occasions the broadcast level triggered ack gets
1931+ * delayed going to ioapics, and if we reprogram the
1932+ * vector while Remote IRR is still set the irq will never
1933+ * fire again.
1934+ *
1935+ * To prevent this scenario we read the Remote IRR bit
1936+ * of the ioapic. This has two effects.
1937+ * - On any sane system the read of the ioapic will
1938+ * flush writes (and acks) going to the ioapic from
1939+ * this cpu.
1940+ * - We get to see if the ACK has actually been delivered.
1941+ *
1942+ * Based on failed experiments of reprogramming the
1943+ * ioapic entry from outside of irq context starting
1944+ * with masking the ioapic entry and then polling until
1945+ * Remote IRR was clear before reprogramming the
1946+ * ioapic I don't trust the Remote IRR bit to be
1947+ * completey accurate.
1948+ *
1949+ * However there appears to be no other way to plug
1950+ * this race, so if the Remote IRR bit is not
1951+ * accurate and is causing problems then it is a hardware bug
1952+ * and you can go talk to the chipset vendor about it.
1953+ */
1954+ if (!io_apic_level_ack_pending(irq))
1955+ move_masked_irq(irq);
1956 unmask_IO_APIC_irq(irq);
1957+ }
1958 }
1959
1960 static struct irq_chip ioapic_chip __read_mostly = {
1961Index: head-2008-12-01/arch/x86/kernel/ldt_64-xen.c
1962===================================================================
1963--- head-2008-12-01.orig/arch/x86/kernel/ldt_64-xen.c 2008-12-01 11:36:13.000000000 +0100
1964+++ head-2008-12-01/arch/x86/kernel/ldt_64-xen.c 2008-12-01 11:36:47.000000000 +0100
1965@@ -114,6 +114,8 @@ int init_new_context(struct task_struct
1966 memset(&mm->context, 0, sizeof(mm->context));
1967 init_MUTEX(&mm->context.sem);
1968 old_mm = current->mm;
1969+ if (old_mm)
1970+ mm->context.vdso = old_mm->context.vdso;
1971 if (old_mm && old_mm->context.size > 0) {
1972 down(&old_mm->context.sem);
1973 retval = copy_ldt(&mm->context, &old_mm->context);
1974@@ -146,7 +148,7 @@ void destroy_context(struct mm_struct *m
1975 kfree(mm->context.ldt);
1976 mm->context.size = 0;
1977 }
1978- if (!mm->context.pinned) {
1979+ if (!PagePinned(virt_to_page(mm->pgd))) {
1980 spin_lock(&mm_unpinned_lock);
1981 list_del(&mm->context.unpinned);
1982 spin_unlock(&mm_unpinned_lock);
1983Index: head-2008-12-01/arch/x86/kernel/mpparse_64-xen.c
1984===================================================================
1985--- head-2008-12-01.orig/arch/x86/kernel/mpparse_64-xen.c 2008-12-01 11:36:13.000000000 +0100
1986+++ head-2008-12-01/arch/x86/kernel/mpparse_64-xen.c 2008-12-01 11:36:47.000000000 +0100
1987@@ -32,7 +32,6 @@
1988
1989 /* Have we found an MP table */
1990 int smp_found_config;
1991-unsigned int __initdata maxcpus = NR_CPUS;
1992
1993 /*
1994 * Various Linux-internal data structures created from the
1995@@ -657,6 +656,20 @@ static int mp_find_ioapic(int gsi)
1996 return -1;
1997 }
1998
1999+static u8 uniq_ioapic_id(u8 id)
2000+{
2001+ int i;
2002+ DECLARE_BITMAP(used, 256);
2003+ bitmap_zero(used, 256);
2004+ for (i = 0; i < nr_ioapics; i++) {
2005+ struct mpc_config_ioapic *ia = &mp_ioapics[i];
2006+ __set_bit(ia->mpc_apicid, used);
2007+ }
2008+ if (!test_bit(id, used))
2009+ return id;
2010+ return find_first_zero_bit(used, 256);
2011+}
2012+
2013 void __init mp_register_ioapic(u8 id, u32 address, u32 gsi_base)
2014 {
2015 int idx = 0;
2016@@ -664,7 +677,7 @@ void __init mp_register_ioapic(u8 id, u3
2017 if (bad_ioapic(address))
2018 return;
2019
2020- idx = nr_ioapics++;
2021+ idx = nr_ioapics;
2022
2023 mp_ioapics[idx].mpc_type = MP_IOAPIC;
2024 mp_ioapics[idx].mpc_flags = MPC_APIC_USABLE;
2025@@ -673,7 +686,7 @@ void __init mp_register_ioapic(u8 id, u3
2026 #ifndef CONFIG_XEN
2027 set_fixmap_nocache(FIX_IO_APIC_BASE_0 + idx, address);
2028 #endif
2029- mp_ioapics[idx].mpc_apicid = id;
2030+ mp_ioapics[idx].mpc_apicid = uniq_ioapic_id(id);
2031 mp_ioapics[idx].mpc_apicver = 0;
2032
2033 /*
2034@@ -690,6 +703,8 @@ void __init mp_register_ioapic(u8 id, u3
2035 mp_ioapics[idx].mpc_apicaddr,
2036 mp_ioapic_routing[idx].gsi_start,
2037 mp_ioapic_routing[idx].gsi_end);
2038+
2039+ nr_ioapics++;
2040 }
2041
2042 void __init
2043Index: head-2008-12-01/arch/x86/kernel/process_64-xen.c
2044===================================================================
2045--- head-2008-12-01.orig/arch/x86/kernel/process_64-xen.c 2008-12-01 11:36:13.000000000 +0100
2046+++ head-2008-12-01/arch/x86/kernel/process_64-xen.c 2008-12-01 11:36:47.000000000 +0100
2047@@ -26,6 +26,7 @@
2048 #include <linux/sched.h>
2049 #include <linux/kernel.h>
2050 #include <linux/mm.h>
2051+#include <linux/fs.h>
2052 #include <linux/elfcore.h>
2053 #include <linux/smp.h>
2054 #include <linux/slab.h>
2055@@ -249,6 +250,7 @@ early_param("idle", idle_setup);
2056 void __show_regs(struct pt_regs * regs)
2057 {
2058 unsigned long fs, gs, shadowgs;
2059+ unsigned long d0, d1, d2, d3, d6, d7;
2060 unsigned int fsindex,gsindex;
2061 unsigned int ds,cs,es;
2062
2063@@ -288,6 +290,14 @@ void __show_regs(struct pt_regs * regs)
2064 fs,fsindex,gs,gsindex,shadowgs);
2065 printk("CS: %04x DS: %04x ES: %04x\n", cs, ds, es);
2066
2067+ get_debugreg(d0, 0);
2068+ get_debugreg(d1, 1);
2069+ get_debugreg(d2, 2);
2070+ printk("DR0: %016lx DR1: %016lx DR2: %016lx\n", d0, d1, d2);
2071+ get_debugreg(d3, 3);
2072+ get_debugreg(d6, 6);
2073+ get_debugreg(d7, 7);
2074+ printk("DR3: %016lx DR6: %016lx DR7: %016lx\n", d3, d6, d7);
2075 }
2076
2077 void show_regs(struct pt_regs *regs)
2078Index: head-2008-12-01/arch/x86/kernel/setup_64-xen.c
2079===================================================================
2080--- head-2008-12-01.orig/arch/x86/kernel/setup_64-xen.c 2008-12-01 11:36:13.000000000 +0100
2081+++ head-2008-12-01/arch/x86/kernel/setup_64-xen.c 2008-12-01 11:36:47.000000000 +0100
2082@@ -827,6 +827,8 @@ static void __cpuinit init_amd(struct cp
2083 level = cpuid_eax(1);
2084 if (c->x86 == 15 && ((level >= 0x0f48 && level < 0x0f50) || level >= 0x0f58))
2085 set_bit(X86_FEATURE_REP_GOOD, &c->x86_capability);
2086+ if (c->x86 == 0x10)
2087+ set_bit(X86_FEATURE_REP_GOOD, &c->x86_capability);
2088
2089 /* Enable workaround for FXSAVE leak */
2090 if (c->x86 >= 6)
2091@@ -852,8 +854,14 @@ static void __cpuinit init_amd(struct cp
2092 if (c->extended_cpuid_level >= 0x80000008)
2093 amd_detect_cmp(c);
2094
2095- /* Fix cpuid4 emulation for more */
2096- num_cache_leaves = 3;
2097+ if (c->extended_cpuid_level >= 0x80000006 &&
2098+ (cpuid_edx(0x80000006) & 0xf000))
2099+ num_cache_leaves = 4;
2100+ else
2101+ num_cache_leaves = 3;
2102+
2103+ if (c->x86 == 0xf || c->x86 == 0x10 || c->x86 == 0x11)
2104+ set_bit(X86_FEATURE_K8, &c->x86_capability);
2105
2106 /* RDTSC can be speculated around */
2107 clear_bit(X86_FEATURE_SYNC_RDTSC, &c->x86_capability);
2108@@ -1098,6 +1106,8 @@ void __cpuinit identify_cpu(struct cpuin
2109 c->x86_capability[2] = cpuid_edx(0x80860001);
2110 }
2111
2112+ init_scattered_cpuid_features(c);
2113+
2114 c->apicid = phys_pkg_id(0);
2115
2116 /*
2117@@ -1183,7 +1193,7 @@ static int show_cpuinfo(struct seq_file
2118 "fpu", "vme", "de", "pse", "tsc", "msr", "pae", "mce",
2119 "cx8", "apic", NULL, "sep", "mtrr", "pge", "mca", "cmov",
2120 "pat", "pse36", "pn", "clflush", NULL, "dts", "acpi", "mmx",
2121- "fxsr", "sse", "sse2", "ss", "ht", "tm", "ia64", NULL,
2122+ "fxsr", "sse", "sse2", "ss", "ht", "tm", "ia64", "pbe",
2123
2124 /* AMD-defined */
2125 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
2126@@ -1199,10 +1209,11 @@ static int show_cpuinfo(struct seq_file
2127 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
2128
2129 /* Other (Linux-defined) */
2130- "cxmmx", NULL, "cyrix_arr", "centaur_mcr", NULL,
2131- "constant_tsc", NULL, NULL,
2132- "up", NULL, NULL, NULL, NULL, NULL, NULL, NULL,
2133- NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
2134+ "cxmmx", "k6_mtrr", "cyrix_arr", "centaur_mcr",
2135+ NULL, NULL, NULL, NULL,
2136+ "constant_tsc", "up", NULL, "arch_perfmon",
2137+ "pebs", "bts", NULL, "sync_rdtsc",
2138+ "rep_good", NULL, NULL, NULL, NULL, NULL, NULL, NULL,
2139 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
2140
2141 /* Intel-defined (#2) */
2142@@ -1213,7 +1224,7 @@ static int show_cpuinfo(struct seq_file
2143
2144 /* VIA/Cyrix/Centaur-defined */
2145 NULL, NULL, "rng", "rng_en", NULL, NULL, "ace", "ace_en",
2146- NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
2147+ "ace2", "ace2_en", "phe", "phe_en", "pmm", "pmm_en", NULL, NULL,
2148 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
2149 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
2150
2151@@ -1224,6 +1235,12 @@ static int show_cpuinfo(struct seq_file
2152 "osvw", "ibs", NULL, NULL, NULL, NULL,
2153 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
2154 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
2155+
2156+ /* Auxiliary (Linux-defined) */
2157+ "ida", NULL, NULL, NULL, NULL, NULL, NULL, NULL,
2158+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
2159+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
2160+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
2161 };
2162 static char *x86_power_flags[] = {
2163 "ts", /* temperature sensor */
2164Index: head-2008-12-01/arch/x86/kernel/setup64-xen.c
2165===================================================================
2166--- head-2008-12-01.orig/arch/x86/kernel/setup64-xen.c 2008-12-01 11:36:13.000000000 +0100
2167+++ head-2008-12-01/arch/x86/kernel/setup64-xen.c 2008-12-01 11:36:47.000000000 +0100
2168@@ -125,11 +125,14 @@ void __init setup_per_cpu_areas(void)
2169 }
2170
2171 #ifdef CONFIG_XEN
2172-static void switch_pt(void)
2173+static void __init_refok switch_pt(int cpu)
2174 {
2175+ if (cpu == 0)
2176+ xen_init_pt();
2177 xen_pt_switch(__pa_symbol(init_level4_pgt));
2178 xen_new_user_pt(__pa_symbol(__user_pgd(init_level4_pgt)));
2179 }
2180+#define switch_pt() switch_pt(cpu)
2181
2182 static void __cpuinit cpu_gdt_init(const struct desc_ptr *gdt_descr)
2183 {
2184@@ -185,9 +188,6 @@ void pda_init(int cpu)
2185 pda->mmu_state = 0;
2186
2187 if (cpu == 0) {
2188-#ifdef CONFIG_XEN
2189- xen_init_pt();
2190-#endif
2191 /* others are initialized in smpboot.c */
2192 pda->pcurrent = &init_task;
2193 pda->irqstackptr = boot_cpu_stack;
2194Index: head-2008-12-01/arch/x86/kernel/smp_64-xen.c
2195===================================================================
2196--- head-2008-12-01.orig/arch/x86/kernel/smp_64-xen.c 2008-12-01 11:36:13.000000000 +0100
2197+++ head-2008-12-01/arch/x86/kernel/smp_64-xen.c 2008-12-01 11:36:47.000000000 +0100
2198@@ -362,7 +362,7 @@ __smp_call_function_single(int cpu, void
2199 }
2200
2201 /*
2202- * smp_call_function_single - Run a function on another CPU
2203+ * smp_call_function_single - Run a function on a specific CPU
2204 * @func: The function to run. This must be fast and non-blocking.
2205 * @info: An arbitrary pointer to pass to the function.
2206 * @nonatomic: Currently unused.
2207@@ -379,17 +379,21 @@ int smp_call_function_single (int cpu, v
2208 {
2209 /* prevent preemption and reschedule on another processor */
2210 int me = get_cpu();
2211+
2212+ /* Can deadlock when called with interrupts disabled */
2213+ WARN_ON(irqs_disabled());
2214+
2215 if (cpu == me) {
2216+ local_irq_disable();
2217+ func(info);
2218+ local_irq_enable();
2219 put_cpu();
2220 return 0;
2221 }
2222
2223- /* Can deadlock when called with interrupts disabled */
2224- WARN_ON(irqs_disabled());
2225-
2226- spin_lock_bh(&call_lock);
2227+ spin_lock(&call_lock);
2228 __smp_call_function_single(cpu, func, info, nonatomic, wait);
2229- spin_unlock_bh(&call_lock);
2230+ spin_unlock(&call_lock);
2231 put_cpu();
2232 return 0;
2233 }
2234Index: head-2008-12-01/arch/x86/kernel/traps_64-xen.c
2235===================================================================
2236--- head-2008-12-01.orig/arch/x86/kernel/traps_64-xen.c 2008-12-01 11:36:13.000000000 +0100
2237+++ head-2008-12-01/arch/x86/kernel/traps_64-xen.c 2008-12-01 11:36:47.000000000 +0100
2238@@ -34,6 +34,10 @@
2239 #include <linux/bug.h>
2240 #include <linux/kdebug.h>
2241
2242+#if defined(CONFIG_EDAC)
2243+#include <linux/edac.h>
2244+#endif
2245+
2246 #include <asm/system.h>
2247 #include <asm/io.h>
2248 #include <asm/atomic.h>
2249@@ -332,6 +336,7 @@ static int print_trace_stack(void *data,
2250
2251 static void print_trace_address(void *data, unsigned long addr)
2252 {
2253+ touch_nmi_watchdog();
2254 printk_address(addr);
2255 }
2256
2257@@ -520,6 +525,7 @@ void __kprobes __die(const char * str, s
2258 printk("\n");
2259 notify_die(DIE_OOPS, str, regs, err, current->thread.trap_no, SIGSEGV);
2260 show_registers(regs);
2261+ add_taint(TAINT_DIE);
2262 /* Executive summary in case the oops scrolled away */
2263 printk(KERN_ALERT "RIP ");
2264 printk_address(regs->rip);
2265@@ -533,7 +539,7 @@ void die(const char * str, struct pt_reg
2266 unsigned long flags = oops_begin();
2267
2268 if (!user_mode(regs))
2269- report_bug(regs->rip);
2270+ report_bug(regs->rip, regs);
2271
2272 __die(str, regs, err);
2273 oops_end(flags);
2274@@ -582,7 +588,8 @@ static void __kprobes do_trap(int trapnr
2275 tsk->thread.error_code = error_code;
2276 tsk->thread.trap_no = trapnr;
2277
2278- if (exception_trace && unhandled_signal(tsk, signr))
2279+ if (show_unhandled_signals && unhandled_signal(tsk, signr) &&
2280+ printk_ratelimit())
2281 printk(KERN_INFO
2282 "%s[%d] trap %s rip:%lx rsp:%lx error:%lx\n",
2283 tsk->comm, tsk->pid, str,
2284@@ -686,7 +693,8 @@ asmlinkage void __kprobes do_general_pro
2285 tsk->thread.error_code = error_code;
2286 tsk->thread.trap_no = 13;
2287
2288- if (exception_trace && unhandled_signal(tsk, SIGSEGV))
2289+ if (show_unhandled_signals && unhandled_signal(tsk, SIGSEGV) &&
2290+ printk_ratelimit())
2291 printk(KERN_INFO
2292 "%s[%d] general protection rip:%lx rsp:%lx error:%lx\n",
2293 tsk->comm, tsk->pid,
2294@@ -721,6 +729,13 @@ mem_parity_error(unsigned char reason, s
2295 reason);
2296 printk(KERN_EMERG "You have some hardware problem, likely on the PCI bus.\n");
2297
2298+#if defined(CONFIG_EDAC)
2299+ if(edac_handler_set()) {
2300+ edac_atomic_assert_error();
2301+ return;
2302+ }
2303+#endif
2304+
2305 if (panic_on_unrecovered_nmi)
2306 panic("NMI: Not continuing");
2307
2308Index: head-2008-12-01/arch/x86/kernel/vsyscall_64-xen.c
2309===================================================================
2310--- head-2008-12-01.orig/arch/x86/kernel/vsyscall_64-xen.c 2008-12-01 11:36:13.000000000 +0100
2311+++ head-2008-12-01/arch/x86/kernel/vsyscall_64-xen.c 2008-12-01 11:36:47.000000000 +0100
2312@@ -42,6 +42,7 @@
2313 #include <asm/segment.h>
2314 #include <asm/desc.h>
2315 #include <asm/topology.h>
2316+#include <asm/vgtod.h>
2317
2318 #define __vsyscall(nr) __attribute__ ((unused,__section__(".vsyscall_" #nr)))
2319 #define __syscall_clobber "r11","rcx","memory"
2320@@ -57,26 +58,9 @@
2321 * - writen by timer interrupt or systcl (/proc/sys/kernel/vsyscall64)
2322 * Try to keep this structure as small as possible to avoid cache line ping pongs
2323 */
2324-struct vsyscall_gtod_data_t {
2325- seqlock_t lock;
2326-
2327- /* open coded 'struct timespec' */
2328- time_t wall_time_sec;
2329- u32 wall_time_nsec;
2330-
2331- int sysctl_enabled;
2332- struct timezone sys_tz;
2333- struct { /* extract of a clocksource struct */
2334- cycle_t (*vread)(void);
2335- cycle_t cycle_last;
2336- cycle_t mask;
2337- u32 mult;
2338- u32 shift;
2339- } clock;
2340-};
2341 int __vgetcpu_mode __section_vgetcpu_mode;
2342
2343-struct vsyscall_gtod_data_t __vsyscall_gtod_data __section_vsyscall_gtod_data =
2344+struct vsyscall_gtod_data __vsyscall_gtod_data __section_vsyscall_gtod_data =
2345 {
2346 .lock = SEQLOCK_UNLOCKED,
2347 .sysctl_enabled = 1,
2348@@ -96,6 +80,8 @@ void update_vsyscall(struct timespec *wa
2349 vsyscall_gtod_data.wall_time_sec = wall_time->tv_sec;
2350 vsyscall_gtod_data.wall_time_nsec = wall_time->tv_nsec;
2351 vsyscall_gtod_data.sys_tz = sys_tz;
2352+ vsyscall_gtod_data.wall_time_nsec = wall_time->tv_nsec;
2353+ vsyscall_gtod_data.wall_to_monotonic = wall_to_monotonic;
2354 write_sequnlock_irqrestore(&vsyscall_gtod_data.lock, flags);
2355 }
2356
2357Index: head-2008-12-01/arch/x86/mm/fault_64-xen.c
2358===================================================================
2359--- head-2008-12-01.orig/arch/x86/mm/fault_64-xen.c 2008-12-01 11:36:13.000000000 +0100
2360+++ head-2008-12-01/arch/x86/mm/fault_64-xen.c 2008-12-01 11:36:47.000000000 +0100
2361@@ -159,7 +159,9 @@ void dump_pagetable(unsigned long addres
2362 pmd_t *pmd;
2363 pte_t *pte;
2364
2365- pgd = __va(read_cr3() & PHYSICAL_PAGE_MASK);
2366+ pgd = (pgd_t *)read_cr3();
2367+
2368+ pgd = __va((unsigned long)pgd & PHYSICAL_PAGE_MASK);
2369 pgd += pgd_index(address);
2370 if (bad_address(pgd)) goto bad;
2371 printk("PGD %lx ", pgd_val(*pgd));
2372@@ -219,16 +221,6 @@ static int is_errata93(struct pt_regs *r
2373 return 0;
2374 }
2375
2376-int unhandled_signal(struct task_struct *tsk, int sig)
2377-{
2378- if (is_init(tsk))
2379- return 1;
2380- if (tsk->ptrace & PT_PTRACED)
2381- return 0;
2382- return (tsk->sighand->action[sig-1].sa.sa_handler == SIG_IGN) ||
2383- (tsk->sighand->action[sig-1].sa.sa_handler == SIG_DFL);
2384-}
2385-
2386 static noinline void pgtable_bad(unsigned long address, struct pt_regs *regs,
2387 unsigned long error_code)
2388 {
2389@@ -302,8 +294,8 @@ static int vmalloc_fault(unsigned long a
2390 return 0;
2391 }
2392
2393-int page_fault_trace = 0;
2394-int exception_trace = 1;
2395+static int page_fault_trace;
2396+int show_unhandled_signals = 1;
2397
2398
2399 #define MEM_VERBOSE 1
2400@@ -372,7 +364,7 @@ asmlinkage void __kprobes do_page_fault(
2401 struct vm_area_struct * vma;
2402 unsigned long address;
2403 const struct exception_table_entry *fixup;
2404- int write;
2405+ int write, fault;
2406 unsigned long flags;
2407 siginfo_t info;
2408
2409@@ -384,7 +376,7 @@ asmlinkage void __kprobes do_page_fault(
2410 prefetchw(&mm->mmap_sem);
2411
2412 /* get the address */
2413- address = current_vcpu_info()->arch.cr2;
2414+ address = read_cr2();
2415
2416 info.si_code = SEGV_MAPERR;
2417
2418@@ -445,6 +437,13 @@ asmlinkage void __kprobes do_page_fault(
2419 if (unlikely(in_atomic() || !mm))
2420 goto bad_area_nosemaphore;
2421
2422+ /*
2423+ * User-mode registers count as a user access even for any
2424+ * potential system fault or CPU buglet.
2425+ */
2426+ if (user_mode_vm(regs))
2427+ error_code |= PF_USER;
2428+
2429 again:
2430 /* When running in the kernel we expect faults to occur only to
2431 * addresses in user space. All other faults represent errors in the
2432@@ -511,19 +510,18 @@ good_area:
2433 * make sure we exit gracefully rather than endlessly redo
2434 * the fault.
2435 */
2436- switch (handle_mm_fault(mm, vma, address, write)) {
2437- case VM_FAULT_MINOR:
2438- tsk->min_flt++;
2439- break;
2440- case VM_FAULT_MAJOR:
2441- tsk->maj_flt++;
2442- break;
2443- case VM_FAULT_SIGBUS:
2444- goto do_sigbus;
2445- default:
2446- goto out_of_memory;
2447+ fault = handle_mm_fault(mm, vma, address, write);
2448+ if (unlikely(fault & VM_FAULT_ERROR)) {
2449+ if (fault & VM_FAULT_OOM)
2450+ goto out_of_memory;
2451+ else if (fault & VM_FAULT_SIGBUS)
2452+ goto do_sigbus;
2453+ BUG();
2454 }
2455-
2456+ if (fault & VM_FAULT_MAJOR)
2457+ tsk->maj_flt++;
2458+ else
2459+ tsk->min_flt++;
2460 up_read(&mm->mmap_sem);
2461 return;
2462
2463@@ -556,7 +554,8 @@ bad_area_nosemaphore:
2464 (address >> 32))
2465 return;
2466
2467- if (exception_trace && unhandled_signal(tsk, SIGSEGV)) {
2468+ if (show_unhandled_signals && unhandled_signal(tsk, SIGSEGV) &&
2469+ printk_ratelimit()) {
2470 printk(
2471 "%s%s[%d]: segfault at %016lx rip %016lx rsp %016lx error %lx\n",
2472 tsk->pid > 1 ? KERN_INFO : KERN_EMERG,
2473@@ -630,7 +629,7 @@ out_of_memory:
2474 }
2475 printk("VM: killing process %s\n", tsk->comm);
2476 if (error_code & 4)
2477- do_exit(SIGKILL);
2478+ do_group_exit(SIGKILL);
2479 goto no_context;
2480
2481 do_sigbus:
2482Index: head-2008-12-01/arch/x86/mm/init_64-xen.c
2483===================================================================
2484--- head-2008-12-01.orig/arch/x86/mm/init_64-xen.c 2008-12-01 11:36:13.000000000 +0100
2485+++ head-2008-12-01/arch/x86/mm/init_64-xen.c 2008-12-01 11:36:47.000000000 +0100
2486@@ -66,6 +66,9 @@ int after_bootmem;
2487 DEFINE_PER_CPU(struct mmu_gather, mmu_gathers);
2488 extern unsigned long start_pfn;
2489
2490+extern pmd_t level2_fixmap_pgt[PTRS_PER_PMD];
2491+extern pte_t level1_fixmap_pgt[PTRS_PER_PTE];
2492+
2493 /*
2494 * Use this until direct mapping is established, i.e. before __va() is
2495 * available in init_memory_mapping().
2496@@ -362,6 +365,10 @@ __set_fixmap (enum fixed_addresses idx,
2497 set_pte_phys(address, phys, prot, 0);
2498 set_pte_phys(address, phys, prot, 1);
2499 break;
2500+ case FIX_EARLYCON_MEM_BASE:
2501+ xen_l1_entry_update(level1_fixmap_pgt + pte_index(address),
2502+ pfn_pte_ma(phys >> PAGE_SHIFT, prot));
2503+ break;
2504 default:
2505 set_pte_phys_ma(address, phys, prot);
2506 break;
2507@@ -594,6 +601,13 @@ void __init xen_init_pt(void)
2508 __user_pgd(init_level4_pgt)[pgd_index(VSYSCALL_START)] =
2509 __pgd(__pa_symbol(level3_user_pgt) | _PAGE_TABLE);
2510
2511+ /* Do an early initialization of the fixmap area. */
2512+ addr = __fix_to_virt(FIX_EARLYCON_MEM_BASE);
2513+ level3_kernel_pgt[pud_index(addr)] =
2514+ __pud(__pa_symbol(level2_fixmap_pgt) | _PAGE_TABLE);
2515+ level2_fixmap_pgt[pmd_index(addr)] =
2516+ __pmd(__pa_symbol(level1_fixmap_pgt) | _PAGE_TABLE);
2517+
2518 early_make_page_readonly(init_level4_pgt,
2519 XENFEAT_writable_page_tables);
2520 early_make_page_readonly(__user_pgd(init_level4_pgt),
2521@@ -604,6 +618,10 @@ void __init xen_init_pt(void)
2522 XENFEAT_writable_page_tables);
2523 early_make_page_readonly(level2_kernel_pgt,
2524 XENFEAT_writable_page_tables);
2525+ early_make_page_readonly(level2_fixmap_pgt,
2526+ XENFEAT_writable_page_tables);
2527+ early_make_page_readonly(level1_fixmap_pgt,
2528+ XENFEAT_writable_page_tables);
2529
2530 if (!xen_feature(XENFEAT_writable_page_tables)) {
2531 xen_pgd_pin(__pa_symbol(init_level4_pgt));
2532@@ -807,7 +825,7 @@ void __init paging_init(void)
2533 sparse_init();
2534 free_area_init_nodes(max_zone_pfns);
2535
2536- init_mm.context.pinned = 1;
2537+ SetPagePinned(virt_to_page(init_mm.pgd));
2538 }
2539 #endif
2540
2541@@ -1120,41 +1138,6 @@ int kern_addr_valid(unsigned long addr)
2542 return pfn_valid(pte_pfn(*pte));
2543 }
2544
2545-#ifdef CONFIG_SYSCTL
2546-#include <linux/sysctl.h>
2547-
2548-extern int exception_trace, page_fault_trace;
2549-
2550-static ctl_table debug_table2[] = {
2551- {
2552- .ctl_name = 99,
2553- .procname = "exception-trace",
2554- .data = &exception_trace,
2555- .maxlen = sizeof(int),
2556- .mode = 0644,
2557- .proc_handler = proc_dointvec
2558- },
2559- {}
2560-};
2561-
2562-static ctl_table debug_root_table2[] = {
2563- {
2564- .ctl_name = CTL_DEBUG,
2565- .procname = "debug",
2566- .mode = 0555,
2567- .child = debug_table2
2568- },
2569- {}
2570-};
2571-
2572-static __init int x8664_sysctl_init(void)
2573-{
2574- register_sysctl_table(debug_root_table2);
2575- return 0;
2576-}
2577-__initcall(x8664_sysctl_init);
2578-#endif
2579-
2580 /* A pseudo VMA to allow ptrace access for the vsyscall page. This only
2581 covers the 64bit vsyscall page now. 32bit has a real VMA now and does
2582 not need special handling anymore. */
2583@@ -1193,9 +1176,18 @@ int in_gate_area_no_task(unsigned long a
2584 }
2585
2586 #ifndef CONFIG_XEN
2587-void *alloc_bootmem_high_node(pg_data_t *pgdat, unsigned long size)
2588+void * __init alloc_bootmem_high_node(pg_data_t *pgdat, unsigned long size)
2589 {
2590 return __alloc_bootmem_core(pgdat->bdata, size,
2591 SMP_CACHE_BYTES, (4UL*1024*1024*1024), 0);
2592 }
2593 #endif
2594+
2595+const char *arch_vma_name(struct vm_area_struct *vma)
2596+{
2597+ if (vma->vm_mm && vma->vm_start == (long)vma->vm_mm->context.vdso)
2598+ return "[vdso]";
2599+ if (vma == &gate_vma)
2600+ return "[vsyscall]";
2601+ return NULL;
2602+}
2603Index: head-2008-12-01/arch/x86/mm/pageattr_64-xen.c
2604===================================================================
2605--- head-2008-12-01.orig/arch/x86/mm/pageattr_64-xen.c 2008-12-01 11:36:13.000000000 +0100
2606+++ head-2008-12-01/arch/x86/mm/pageattr_64-xen.c 2008-12-01 11:36:47.000000000 +0100
2607@@ -171,7 +171,7 @@ void mm_pin(struct mm_struct *mm)
2608 mm_walk(mm, PAGE_KERNEL_RO);
2609 xen_pgd_pin(__pa(mm->pgd)); /* kernel */
2610 xen_pgd_pin(__pa(__user_pgd(mm->pgd))); /* user */
2611- mm->context.pinned = 1;
2612+ SetPagePinned(virt_to_page(mm->pgd));
2613 spin_lock(&mm_unpinned_lock);
2614 list_del(&mm->context.unpinned);
2615 spin_unlock(&mm_unpinned_lock);
2616@@ -189,7 +189,7 @@ void mm_unpin(struct mm_struct *mm)
2617 xen_pgd_unpin(__pa(mm->pgd));
2618 xen_pgd_unpin(__pa(__user_pgd(mm->pgd)));
2619 mm_walk(mm, PAGE_KERNEL);
2620- mm->context.pinned = 0;
2621+ ClearPagePinned(virt_to_page(mm->pgd));
2622 spin_lock(&mm_unpinned_lock);
2623 list_add(&mm->context.unpinned, &mm_unpinned);
2624 spin_unlock(&mm_unpinned_lock);
2625@@ -217,7 +217,7 @@ void mm_pin_all(void)
2626
2627 void arch_dup_mmap(struct mm_struct *oldmm, struct mm_struct *mm)
2628 {
2629- if (!mm->context.pinned)
2630+ if (!PagePinned(virt_to_page(mm->pgd)))
2631 mm_pin(mm);
2632 }
2633
2634@@ -243,8 +243,9 @@ void arch_exit_mmap(struct mm_struct *mm
2635
2636 task_unlock(tsk);
2637
2638- if ( mm->context.pinned && (atomic_read(&mm->mm_count) == 1) &&
2639- !mm->context.has_foreign_mappings )
2640+ if (PagePinned(virt_to_page(mm->pgd))
2641+ && (atomic_read(&mm->mm_count) == 1)
2642+ && !mm->context.has_foreign_mappings)
2643 mm_unpin(mm);
2644 }
2645
2646@@ -343,14 +344,13 @@ static void flush_kernel_map(void *arg)
2647 struct page *pg;
2648
2649 /* When clflush is available always use it because it is
2650- much cheaper than WBINVD. Disable clflush for now because
2651- the high level code is not ready yet */
2652+ much cheaper than WBINVD. */
2653+ /* clflush is still broken. Disable for now. */
2654 if (1 || !cpu_has_clflush)
2655 asm volatile("wbinvd" ::: "memory");
2656 else list_for_each_entry(pg, l, lru) {
2657 void *adr = page_address(pg);
2658- if (cpu_has_clflush)
2659- cache_flush_page(adr);
2660+ cache_flush_page(adr);
2661 }
2662 __flush_tlb_all();
2663 }
2664@@ -364,7 +364,8 @@ static LIST_HEAD(deferred_pages); /* pro
2665
2666 static inline void save_page(struct page *fpage)
2667 {
2668- list_add(&fpage->lru, &deferred_pages);
2669+ if (!test_and_set_bit(PG_arch_1, &fpage->flags))
2670+ list_add(&fpage->lru, &deferred_pages);
2671 }
2672
2673 /*
2674@@ -398,9 +399,12 @@ __change_page_attr(unsigned long address
2675 pte_t *kpte;
2676 struct page *kpte_page;
2677 pgprot_t ref_prot2;
2678+
2679 kpte = lookup_address(address);
2680 if (!kpte) return 0;
2681 kpte_page = virt_to_page(((unsigned long)kpte) & PAGE_MASK);
2682+ BUG_ON(PageLRU(kpte_page));
2683+ BUG_ON(PageCompound(kpte_page));
2684 if (pgprot_val(prot) != pgprot_val(ref_prot)) {
2685 if (!pte_huge(*kpte)) {
2686 set_pte(kpte, pfn_pte(pfn, prot));
2687@@ -439,10 +443,9 @@ __change_page_attr(unsigned long address
2688 return 0;
2689 #endif
2690
2691- if (page_private(kpte_page) == 0) {
2692- save_page(kpte_page);
2693+ save_page(kpte_page);
2694+ if (page_private(kpte_page) == 0)
2695 revert_page(address, ref_prot);
2696- }
2697 return 0;
2698 }
2699
2700@@ -514,6 +517,10 @@ void global_flush_tlb(void)
2701 flush_map(&l);
2702
2703 list_for_each_entry_safe(pg, next, &l, lru) {
2704+ list_del(&pg->lru);
2705+ clear_bit(PG_arch_1, &pg->flags);
2706+ if (page_private(pg) != 0)
2707+ continue;
2708 ClearPagePrivate(pg);
2709 __free_page(pg);
2710 }
2711Index: head-2008-12-01/arch/x86/vdso/vdso32/note.S
2712===================================================================
2713--- head-2008-12-01.orig/arch/x86/vdso/vdso32/note.S 2008-12-01 10:53:14.000000000 +0100
2714+++ head-2008-12-01/arch/x86/vdso/vdso32/note.S 2008-12-01 11:36:47.000000000 +0100
2715@@ -13,7 +13,7 @@ ELFNOTE_START(Linux, 0, "a")
2716 .long LINUX_VERSION_CODE
2717 ELFNOTE_END
2718
2719-#ifdef CONFIG_XEN
2720+#if defined(CONFIG_X86_XEN) || defined(CONFIG_PARAVIRT_XEN)
2721 /*
2722 * Add a special note telling glibc's dynamic linker a fake hardware
2723 * flavor that it will use to choose the search path for libraries in the
2724@@ -37,8 +37,12 @@ ELFNOTE_END
2725
2726 ELFNOTE_START(GNU, 2, "a")
2727 .long 1 /* ncaps */
2728+#ifdef CONFIG_PARAVIRT_XEN
2729 VDSO32_NOTE_MASK: /* Symbol used by arch/x86/xen/setup.c */
2730 .long 0 /* mask */
2731+#else
2732+ .long 1 << VDSO_NOTE_NONEGSEG_BIT /* mask */
2733+#endif
2734 .byte VDSO_NOTE_NONEGSEG_BIT; .asciz "nosegneg" /* bit, name */
2735 ELFNOTE_END
2736 #endif
2737Index: head-2008-12-01/drivers/Makefile
2738===================================================================
2739--- head-2008-12-01.orig/drivers/Makefile 2008-12-01 11:11:03.000000000 +0100
2740+++ head-2008-12-01/drivers/Makefile 2008-12-01 11:36:47.000000000 +0100
2741@@ -16,7 +16,7 @@ obj-$(CONFIG_ACPI) += acpi/
2742 obj-$(CONFIG_PNP) += pnp/
2743 obj-$(CONFIG_ARM_AMBA) += amba/
2744
2745-obj-$(CONFIG_XEN) += xen/
2746+obj-$(CONFIG_PARAVIRT_XEN) += xen/
2747
2748 # char/ comes before serial/ etc so that the VT console is the boot-time
2749 # default.
2750Index: head-2008-12-01/drivers/block/Kconfig
2751===================================================================
2752--- head-2008-12-01.orig/drivers/block/Kconfig 2008-12-01 10:53:14.000000000 +0100
2753+++ head-2008-12-01/drivers/block/Kconfig 2008-12-01 11:36:47.000000000 +0100
2754@@ -423,9 +423,9 @@ config XILINX_SYSACE
2755 help
2756 Include support for the Xilinx SystemACE CompactFlash interface
2757
2758-config XEN_BLKDEV_FRONTEND
2759+config XEN_BLKFRONT
2760 tristate "Xen virtual block device support"
2761- depends on XEN
2762+ depends on PARAVIRT_XEN
2763 default y
2764 help
2765 This driver implements the front-end of the Xen virtual
2766Index: head-2008-12-01/drivers/block/Makefile
2767===================================================================
2768--- head-2008-12-01.orig/drivers/block/Makefile 2008-12-01 10:53:14.000000000 +0100
2769+++ head-2008-12-01/drivers/block/Makefile 2008-12-01 11:36:47.000000000 +0100
2770@@ -31,4 +31,4 @@ obj-$(CONFIG_BLK_DEV_SX8) += sx8.o
2771 obj-$(CONFIG_BLK_DEV_UB) += ub.o
2772 obj-$(CONFIG_BLK_DEV_HD) += hd.o
2773
2774-obj-$(CONFIG_XEN_BLKDEV_FRONTEND) += xen-blkfront.o
2775+obj-$(CONFIG_XEN_BLKFRONT) += xen-blkfront.o
2776Index: head-2008-12-01/drivers/block/xen-blkfront.c
2777===================================================================
2778--- head-2008-12-01.orig/drivers/block/xen-blkfront.c 2008-12-01 10:53:14.000000000 +0100
2779+++ head-2008-12-01/drivers/block/xen-blkfront.c 2008-12-01 11:36:47.000000000 +0100
2780@@ -1021,7 +1021,6 @@ static struct xenbus_device_id blkfront_
2781
2782 static struct xenbus_driver blkfront = {
2783 .name = "vbd",
2784- .owner = THIS_MODULE,
2785 .ids = blkfront_ids,
2786 .probe = blkfront_probe,
2787 .remove = blkfront_remove,
2788Index: head-2008-12-01/drivers/char/Kconfig
2789===================================================================
2790--- head-2008-12-01.orig/drivers/char/Kconfig 2008-11-10 11:49:15.000000000 +0100
2791+++ head-2008-12-01/drivers/char/Kconfig 2008-12-01 11:36:47.000000000 +0100
2792@@ -624,7 +624,7 @@ config HVC_BEAT
2793
2794 config HVC_XEN
2795 bool "Xen Hypervisor Console support"
2796- depends on XEN
2797+ depends on PARAVIRT_XEN
2798 select HVC_DRIVER
2799 select HVC_IRQ
2800 default y
2801Index: head-2008-12-01/drivers/net/Kconfig
2802===================================================================
2803--- head-2008-12-01.orig/drivers/net/Kconfig 2008-12-01 10:53:14.000000000 +0100
2804+++ head-2008-12-01/drivers/net/Kconfig 2008-12-01 11:36:47.000000000 +0100
2805@@ -2535,9 +2535,9 @@ source "drivers/atm/Kconfig"
2806
2807 source "drivers/s390/net/Kconfig"
2808
2809-config XEN_NETDEV_FRONTEND
2810+config XEN_NETFRONT
2811 tristate "Xen network device frontend driver"
2812- depends on XEN
2813+ depends on PARAVIRT_XEN
2814 default y
2815 help
2816 The network device frontend driver allows the kernel to
2817Index: head-2008-12-01/drivers/net/Makefile
2818===================================================================
2819--- head-2008-12-01.orig/drivers/net/Makefile 2008-12-01 10:53:14.000000000 +0100
2820+++ head-2008-12-01/drivers/net/Makefile 2008-12-01 11:36:47.000000000 +0100
2821@@ -142,7 +142,7 @@ obj-$(CONFIG_PPPOL2TP) += pppox.o pppol2
2822 obj-$(CONFIG_SLIP) += slip.o
2823 obj-$(CONFIG_SLHC) += slhc.o
2824
2825-obj-$(CONFIG_XEN_NETDEV_FRONTEND) += xen-netfront.o
2826+obj-$(CONFIG_XEN_NETFRONT) += xen-netfront.o
2827
2828 obj-$(CONFIG_DUMMY) += dummy.o
2829 obj-$(CONFIG_IFB) += ifb.o
2830Index: head-2008-12-01/drivers/net/xen-netfront.c
2831===================================================================
2832--- head-2008-12-01.orig/drivers/net/xen-netfront.c 2008-12-01 10:53:14.000000000 +0100
2833+++ head-2008-12-01/drivers/net/xen-netfront.c 2008-12-01 11:36:47.000000000 +0100
2834@@ -36,8 +36,6 @@
2835 #include <linux/skbuff.h>
2836 #include <linux/ethtool.h>
2837 #include <linux/if_ether.h>
2838-#include <linux/tcp.h>
2839-#include <linux/udp.h>
2840 #include <linux/moduleparam.h>
2841 #include <linux/mm.h>
2842 #include <net/ip.h>
2843@@ -765,45 +763,6 @@ static RING_IDX xennet_fill_frags(struct
2844 return cons;
2845 }
2846
2847-static int skb_checksum_setup(struct sk_buff *skb)
2848-{
2849- struct iphdr *iph;
2850- unsigned char *th;
2851- int err = -EPROTO;
2852-
2853- if (skb->protocol != htons(ETH_P_IP))
2854- goto out;
2855-
2856- iph = (void *)skb->data;
2857- th = skb->data + 4 * iph->ihl;
2858- if (th >= skb_tail_pointer(skb))
2859- goto out;
2860-
2861- skb->csum_start = th - skb->head;
2862- switch (iph->protocol) {
2863- case IPPROTO_TCP:
2864- skb->csum_offset = offsetof(struct tcphdr, check);
2865- break;
2866- case IPPROTO_UDP:
2867- skb->csum_offset = offsetof(struct udphdr, check);
2868- break;
2869- default:
2870- if (net_ratelimit())
2871- printk(KERN_ERR "Attempting to checksum a non-"
2872- "TCP/UDP packet, dropping a protocol"
2873- " %d packet", iph->protocol);
2874- goto out;
2875- }
2876-
2877- if ((th + skb->csum_offset + 2) > skb_tail_pointer(skb))
2878- goto out;
2879-
2880- err = 0;
2881-
2882-out:
2883- return err;
2884-}
2885-
2886 static int handle_incoming_queue(struct net_device *dev,
2887 struct sk_buff_head *rxq)
2888 {
2889@@ -1784,7 +1743,6 @@ static int __devexit xennet_remove(struc
2890
2891 static struct xenbus_driver netfront = {
2892 .name = "vif",
2893- .owner = THIS_MODULE,
2894 .ids = netfront_ids,
2895 .probe = netfront_probe,
2896 .remove = __devexit_p(xennet_remove),
2897Index: head-2008-12-01/drivers/xen/Makefile
2898===================================================================
2899--- head-2008-12-01.orig/drivers/xen/Makefile 2008-12-01 11:22:58.000000000 +0100
2900+++ head-2008-12-01/drivers/xen/Makefile 2008-12-01 11:36:47.000000000 +0100
2901@@ -1,10 +1,12 @@
2902-obj-y += core/
2903-obj-y += console/
2904-obj-y += evtchn/
2905-obj-y += xenbus/
2906-obj-y += char/
2907+obj-$(CONFIG_PARAVIRT_XEN) += grant-table.o
2908
2909-obj-y += util.o
2910+obj-$(CONFIG_XEN) += core/
2911+obj-$(CONFIG_XEN) += console/
2912+obj-$(CONFIG_XEN) += evtchn/
2913+obj-y += xenbus/
2914+obj-$(CONFIG_XEN) += char/
2915+
2916+obj-$(CONFIG_XEN) += util.o
2917 obj-$(CONFIG_XEN_BALLOON) += balloon/
2918 obj-$(CONFIG_XEN_BLKDEV_BACKEND) += blkback/
2919 obj-$(CONFIG_XEN_BLKDEV_TAP) += blktap/
2920Index: head-2008-12-01/drivers/xen/blkback/blkback.c
2921===================================================================
2922--- head-2008-12-01.orig/drivers/xen/blkback/blkback.c 2008-12-01 11:32:38.000000000 +0100
2923+++ head-2008-12-01/drivers/xen/blkback/blkback.c 2008-12-01 11:36:47.000000000 +0100
2924@@ -154,7 +154,7 @@ static void unplug_queue(blkif_t *blkif)
2925
2926 static void plug_queue(blkif_t *blkif, struct block_device *bdev)
2927 {
2928- request_queue_t *q = bdev_get_queue(bdev);
2929+ struct request_queue *q = bdev_get_queue(bdev);
2930
2931 if (q == blkif->plug)
2932 return;
2933Index: head-2008-12-01/drivers/xen/blkback/common.h
2934===================================================================
2935--- head-2008-12-01.orig/drivers/xen/blkback/common.h 2008-12-01 11:29:05.000000000 +0100
2936+++ head-2008-12-01/drivers/xen/blkback/common.h 2008-12-01 11:36:47.000000000 +0100
2937@@ -79,7 +79,7 @@ typedef struct blkif_st {
2938 wait_queue_head_t wq;
2939 struct task_struct *xenblkd;
2940 unsigned int waiting_reqs;
2941- request_queue_t *plug;
2942+ struct request_queue *plug;
2943
2944 /* statistics */
2945 unsigned long st_print;
2946Index: head-2008-12-01/drivers/xen/blkback/interface.c
2947===================================================================
2948--- head-2008-12-01.orig/drivers/xen/blkback/interface.c 2008-12-01 11:32:38.000000000 +0100
2949+++ head-2008-12-01/drivers/xen/blkback/interface.c 2008-12-01 11:36:47.000000000 +0100
2950@@ -177,5 +177,5 @@ void blkif_free(blkif_t *blkif)
2951 void __init blkif_interface_init(void)
2952 {
2953 blkif_cachep = kmem_cache_create("blkif_cache", sizeof(blkif_t),
2954- 0, 0, NULL, NULL);
2955+ 0, 0, NULL);
2956 }
2957Index: head-2008-12-01/drivers/xen/blkfront/blkfront.c
2958===================================================================
2959--- head-2008-12-01.orig/drivers/xen/blkfront/blkfront.c 2008-12-01 11:36:13.000000000 +0100
2960+++ head-2008-12-01/drivers/xen/blkfront/blkfront.c 2008-12-01 11:36:47.000000000 +0100
2961@@ -667,7 +667,7 @@ static int blkif_queue_request(struct re
2962 * do_blkif_request
2963 * read a block; request is in a request queue
2964 */
2965-void do_blkif_request(request_queue_t *rq)
2966+void do_blkif_request(struct request_queue *rq)
2967 {
2968 struct blkfront_info *info = NULL;
2969 struct request *req;
2970Index: head-2008-12-01/drivers/xen/blkfront/block.h
2971===================================================================
2972--- head-2008-12-01.orig/drivers/xen/blkfront/block.h 2008-08-07 12:44:36.000000000 +0200
2973+++ head-2008-12-01/drivers/xen/blkfront/block.h 2008-12-01 11:36:47.000000000 +0100
2974@@ -105,7 +105,7 @@ struct blkfront_info
2975 blkif_front_ring_t ring;
2976 unsigned int irq;
2977 struct xlbd_major_info *mi;
2978- request_queue_t *rq;
2979+ struct request_queue *rq;
2980 struct work_struct work;
2981 struct gnttab_free_callback callback;
2982 struct blk_shadow shadow[BLK_RING_SIZE];
2983@@ -129,7 +129,7 @@ extern int blkif_ioctl(struct inode *ino
2984 extern int blkif_getgeo(struct block_device *, struct hd_geometry *);
2985 extern int blkif_check(dev_t dev);
2986 extern int blkif_revalidate(dev_t dev);
2987-extern void do_blkif_request (request_queue_t *rq);
2988+extern void do_blkif_request (struct request_queue *rq);
2989
2990 /* Virtual block-device subsystem. */
2991 /* Note that xlvbd_add doesn't call add_disk for you: you're expected
2992Index: head-2008-12-01/drivers/xen/blkfront/vbd.c
2993===================================================================
2994--- head-2008-12-01.orig/drivers/xen/blkfront/vbd.c 2008-08-07 12:44:36.000000000 +0200
2995+++ head-2008-12-01/drivers/xen/blkfront/vbd.c 2008-12-01 11:36:47.000000000 +0100
2996@@ -211,7 +211,7 @@ xlbd_put_major_info(struct xlbd_major_in
2997 static int
2998 xlvbd_init_blk_queue(struct gendisk *gd, u16 sector_size)
2999 {
3000- request_queue_t *rq;
3001+ struct request_queue *rq;
3002
3003 rq = blk_init_queue(do_blkif_request, &blkif_io_lock);
3004 if (rq == NULL)
3005Index: head-2008-12-01/drivers/xen/blktap/common.h
3006===================================================================
3007--- head-2008-12-01.orig/drivers/xen/blktap/common.h 2008-12-01 11:29:05.000000000 +0100
3008+++ head-2008-12-01/drivers/xen/blktap/common.h 2008-12-01 11:36:47.000000000 +0100
3009@@ -68,7 +68,7 @@ typedef struct blkif_st {
3010 wait_queue_head_t wq;
3011 struct task_struct *xenblkd;
3012 unsigned int waiting_reqs;
3013- request_queue_t *plug;
3014+ struct request_queue *plug;
3015
3016 /* statistics */
3017 unsigned long st_print;
3018Index: head-2008-12-01/drivers/xen/blktap/interface.c
3019===================================================================
3020--- head-2008-12-01.orig/drivers/xen/blktap/interface.c 2008-12-01 11:32:38.000000000 +0100
3021+++ head-2008-12-01/drivers/xen/blktap/interface.c 2008-12-01 11:36:47.000000000 +0100
3022@@ -177,5 +177,5 @@ void tap_blkif_kmem_cache_free(blkif_t *
3023 void __init tap_blkif_interface_init(void)
3024 {
3025 blkif_cachep = kmem_cache_create("blktapif_cache", sizeof(blkif_t),
3026- 0, 0, NULL, NULL);
3027+ 0, 0, NULL);
3028 }
3029Index: head-2008-12-01/drivers/xen/core/features.c
3030===================================================================
3031--- head-2008-12-01.orig/drivers/xen/core/features.c 2007-06-12 13:13:44.000000000 +0200
3032+++ head-2008-12-01/drivers/xen/core/features.c 2008-12-01 11:36:47.000000000 +0100
3033@@ -19,7 +19,7 @@ u8 xen_features[XENFEAT_NR_SUBMAPS * 32]
3034 /* Not a GPL symbol: used in ubiquitous macros, so too restrictive. */
3035 EXPORT_SYMBOL(xen_features);
3036
3037-void setup_xen_features(void)
3038+void xen_setup_features(void)
3039 {
3040 xen_feature_info_t fi;
3041 int i, j;
3042Index: head-2008-12-01/drivers/xen/core/reboot.c
3043===================================================================
3044--- head-2008-12-01.orig/drivers/xen/core/reboot.c 2008-12-01 11:32:38.000000000 +0100
3045+++ head-2008-12-01/drivers/xen/core/reboot.c 2008-12-01 11:36:47.000000000 +0100
3046@@ -4,6 +4,7 @@
3047 #include <linux/unistd.h>
3048 #include <linux/module.h>
3049 #include <linux/reboot.h>
3050+#include <linux/sched.h>
3051 #include <linux/sysrq.h>
3052 #include <asm/hypervisor.h>
3053 #include <xen/xenbus.h>
3054Index: head-2008-12-01/drivers/xen/scsiback/interface.c
3055===================================================================
3056--- head-2008-12-01.orig/drivers/xen/scsiback/interface.c 2008-12-01 11:32:38.000000000 +0100
3057+++ head-2008-12-01/drivers/xen/scsiback/interface.c 2008-12-01 11:36:47.000000000 +0100
3058@@ -167,7 +167,7 @@ void scsiback_free(struct vscsibk_info *
3059 int __init scsiback_interface_init(void)
3060 {
3061 scsiback_cachep = kmem_cache_create("vscsiif_cache",
3062- sizeof(struct vscsibk_info), 0, 0, NULL, NULL);
3063+ sizeof(struct vscsibk_info), 0, 0, NULL);
3064 if (!scsiback_cachep) {
3065 printk(KERN_ERR "scsiback: can't init scsi cache\n");
3066 return -ENOMEM;
3067Index: head-2008-12-01/drivers/xen/scsifront/scsifront.c
3068===================================================================
3069--- head-2008-12-01.orig/drivers/xen/scsifront/scsifront.c 2008-12-01 11:29:05.000000000 +0100
3070+++ head-2008-12-01/drivers/xen/scsifront/scsifront.c 2008-12-01 11:36:47.000000000 +0100
3071@@ -147,7 +147,7 @@ static void scsifront_cdb_cmd_done(struc
3072 add_id_to_freelist(info, id);
3073
3074 sc->result = ring_res->rslt;
3075- sc->resid = ring_res->residual_len;
3076+ scsi_set_resid(sc, ring_res->residual_len);
3077
3078 if (ring_res->sense_len > VSCSIIF_SENSE_BUFFERSIZE)
3079 sense_len = VSCSIIF_SENSE_BUFFERSIZE;
3080Index: head-2008-12-01/drivers/xen/tpmback/interface.c
3081===================================================================
3082--- head-2008-12-01.orig/drivers/xen/tpmback/interface.c 2008-12-01 11:36:07.000000000 +0100
3083+++ head-2008-12-01/drivers/xen/tpmback/interface.c 2008-12-01 11:36:47.000000000 +0100
3084@@ -12,6 +12,7 @@
3085 */
3086
3087 #include "common.h"
3088+#include <linux/err.h>
3089 #include <xen/balloon.h>
3090 #include <xen/gnttab.h>
3091
3092@@ -159,7 +160,7 @@ void tpmif_disconnect_complete(tpmif_t *
3093 int __init tpmif_interface_init(void)
3094 {
3095 tpmif_cachep = kmem_cache_create("tpmif_cache", sizeof (tpmif_t),
3096- 0, 0, NULL, NULL);
3097+ 0, 0, NULL);
3098 return tpmif_cachep ? 0 : -ENOMEM;
3099 }
3100
3101Index: head-2008-12-01/drivers/xen/util.c
3102===================================================================
3103--- head-2008-12-01.orig/drivers/xen/util.c 2007-07-10 09:42:30.000000000 +0200
3104+++ head-2008-12-01/drivers/xen/util.c 2008-12-01 11:36:47.000000000 +0100
3105@@ -1,8 +1,5 @@
3106-#include <linux/mm.h>
3107+#include <linux/err.h>
3108 #include <linux/module.h>
3109-#include <linux/slab.h>
3110-#include <linux/vmalloc.h>
3111-#include <asm/uaccess.h>
3112 #include <xen/driver_util.h>
3113
3114 struct class *get_xen_class(void)
3115@@ -21,45 +18,3 @@ struct class *get_xen_class(void)
3116 return xen_class;
3117 }
3118 EXPORT_SYMBOL_GPL(get_xen_class);
3119-
3120-#ifdef CONFIG_X86
3121-static int f(pte_t *pte, struct page *pmd_page, unsigned long addr, void *data)
3122-{
3123- /* apply_to_page_range() does all the hard work. */
3124- return 0;
3125-}
3126-
3127-struct vm_struct *alloc_vm_area(unsigned long size)
3128-{
3129- struct vm_struct *area;
3130-
3131- area = get_vm_area(size, VM_IOREMAP);
3132- if (area == NULL)
3133- return NULL;
3134-
3135- /*
3136- * This ensures that page tables are constructed for this region
3137- * of kernel virtual address space and mapped into init_mm.
3138- */
3139- if (apply_to_page_range(&init_mm, (unsigned long)area->addr,
3140- area->size, f, NULL)) {
3141- free_vm_area(area);
3142- return NULL;
3143- }
3144-
3145- /* Map page directories into every address space. */
3146- vmalloc_sync_all();
3147-
3148- return area;
3149-}
3150-EXPORT_SYMBOL_GPL(alloc_vm_area);
3151-
3152-void free_vm_area(struct vm_struct *area)
3153-{
3154- struct vm_struct *ret;
3155- ret = remove_vm_area(area->addr);
3156- BUG_ON(ret != area);
3157- kfree(area);
3158-}
3159-EXPORT_SYMBOL_GPL(free_vm_area);
3160-#endif /* CONFIG_X86 */
3161Index: head-2008-12-01/drivers/xen/xenbus/xenbus_client.c
3162===================================================================
3163--- head-2008-12-01.orig/drivers/xen/xenbus/xenbus_client.c 2008-12-01 11:22:58.000000000 +0100
3164+++ head-2008-12-01/drivers/xen/xenbus/xenbus_client.c 2008-12-01 11:36:47.000000000 +0100
3165@@ -30,19 +30,26 @@
3166 * IN THE SOFTWARE.
3167 */
3168
3169+#if defined(CONFIG_XEN) || defined(MODULE)
3170 #include <linux/slab.h>
3171 #include <xen/evtchn.h>
3172 #include <xen/gnttab.h>
3173-#include <xen/xenbus.h>
3174 #include <xen/driver_util.h>
3175+#else
3176+#include <linux/types.h>
3177+#include <linux/vmalloc.h>
3178+#include <asm/xen/hypervisor.h>
3179+#include <xen/interface/xen.h>
3180+#include <xen/interface/event_channel.h>
3181+#include <xen/events.h>
3182+#include <xen/grant_table.h>
3183+#endif
3184+#include <xen/xenbus.h>
3185
3186 #ifdef HAVE_XEN_PLATFORM_COMPAT_H
3187 #include <xen/platform-compat.h>
3188 #endif
3189
3190-#define DPRINTK(fmt, args...) \
3191- pr_debug("xenbus_client (%s:%d) " fmt ".\n", __FUNCTION__, __LINE__, ##args)
3192-
3193 const char *xenbus_strstate(enum xenbus_state state)
3194 {
3195 static const char *const name[] = {
3196@@ -58,6 +65,20 @@ const char *xenbus_strstate(enum xenbus_
3197 }
3198 EXPORT_SYMBOL_GPL(xenbus_strstate);
3199
3200+/**
3201+ * xenbus_watch_path - register a watch
3202+ * @dev: xenbus device
3203+ * @path: path to watch
3204+ * @watch: watch to register
3205+ * @callback: callback to register
3206+ *
3207+ * Register a @watch on the given path, using the given xenbus_watch structure
3208+ * for storage, and the given @callback function as the callback. Return 0 on
3209+ * success, or -errno on error. On success, the given @path will be saved as
3210+ * @watch->node, and remains the caller's to free. On error, @watch->node will
3211+ * be NULL, the device will switch to %XenbusStateClosing, and the error will
3212+ * be saved in the store.
3213+ */
3214 int xenbus_watch_path(struct xenbus_device *dev, const char *path,
3215 struct xenbus_watch *watch,
3216 void (*callback)(struct xenbus_watch *,
3217@@ -81,6 +102,7 @@ int xenbus_watch_path(struct xenbus_devi
3218 EXPORT_SYMBOL_GPL(xenbus_watch_path);
3219
3220
3221+#if defined(CONFIG_XEN) || defined(MODULE)
3222 int xenbus_watch_path2(struct xenbus_device *dev, const char *path,
3223 const char *path2, struct xenbus_watch *watch,
3224 void (*callback)(struct xenbus_watch *,
3225@@ -99,8 +121,60 @@ int xenbus_watch_path2(struct xenbus_dev
3226 return err;
3227 }
3228 EXPORT_SYMBOL_GPL(xenbus_watch_path2);
3229+#else
3230+/**
3231+ * xenbus_watch_pathfmt - register a watch on a sprintf-formatted path
3232+ * @dev: xenbus device
3233+ * @watch: watch to register
3234+ * @callback: callback to register
3235+ * @pathfmt: format of path to watch
3236+ *
3237+ * Register a watch on the given @path, using the given xenbus_watch
3238+ * structure for storage, and the given @callback function as the callback.
3239+ * Return 0 on success, or -errno on error. On success, the watched path
3240+ * (@path/@path2) will be saved as @watch->node, and becomes the caller's to
3241+ * kfree(). On error, watch->node will be NULL, so the caller has nothing to
3242+ * free, the device will switch to %XenbusStateClosing, and the error will be
3243+ * saved in the store.
3244+ */
3245+int xenbus_watch_pathfmt(struct xenbus_device *dev,
3246+ struct xenbus_watch *watch,
3247+ void (*callback)(struct xenbus_watch *,
3248+ const char **, unsigned int),
3249+ const char *pathfmt, ...)
3250+{
3251+ int err;
3252+ va_list ap;
3253+ char *path;
3254
3255+ va_start(ap, pathfmt);
3256+ path = kvasprintf(GFP_KERNEL, pathfmt, ap);
3257+ va_end(ap);
3258
3259+ if (!path) {
3260+ xenbus_dev_fatal(dev, -ENOMEM, "allocating path for watch");
3261+ return -ENOMEM;
3262+ }
3263+ err = xenbus_watch_path(dev, path, watch, callback);
3264+
3265+ if (err)
3266+ kfree(path);
3267+ return err;
3268+}
3269+EXPORT_SYMBOL_GPL(xenbus_watch_pathfmt);
3270+#endif
3271+
3272+
3273+/**
3274+ * xenbus_switch_state
3275+ * @dev: xenbus device
3276+ * @xbt: transaction handle
3277+ * @state: new state
3278+ *
3279+ * Advertise in the store a change of the given driver to the given new_state.
3280+ * Return 0 on success, or -errno on error. On error, the device will switch
3281+ * to XenbusStateClosing, and the error will be saved in the store.
3282+ */
3283 int xenbus_switch_state(struct xenbus_device *dev, enum xenbus_state state)
3284 {
3285 /* We check whether the state is currently set to the given value, and
3286@@ -159,8 +233,8 @@ static char *error_path(struct xenbus_de
3287 }
3288
3289
3290-void _dev_error(struct xenbus_device *dev, int err, const char *fmt,
3291- va_list ap)
3292+static void _dev_error(struct xenbus_device *dev, int err,
3293+ const char *fmt, va_list ap)
3294 {
3295 int ret;
3296 unsigned int len;
3297@@ -181,14 +255,16 @@ void _dev_error(struct xenbus_device *de
3298 path_buffer = error_path(dev);
3299
3300 if (path_buffer == NULL) {
3301- printk("xenbus: failed to write error node for %s (%s)\n",
3302- dev->nodename, printf_buffer);
3303+ dev_err(&dev->dev,
3304+ "xenbus: failed to write error node for %s (%s)\n",
3305+ dev->nodename, printf_buffer);
3306 goto fail;
3307 }
3308
3309 if (xenbus_write(XBT_NIL, path_buffer, "error", printf_buffer) != 0) {
3310- printk("xenbus: failed to write error node for %s (%s)\n",
3311- dev->nodename, printf_buffer);
3312+ dev_err(&dev->dev,
3313+ "xenbus: failed to write error node for %s (%s)\n",
3314+ dev->nodename, printf_buffer);
3315 goto fail;
3316 }
3317
3318@@ -200,6 +276,15 @@ fail:
3319 }
3320
3321
3322+/**
3323+ * xenbus_dev_error
3324+ * @dev: xenbus device
3325+ * @err: error to report
3326+ * @fmt: error message format
3327+ *
3328+ * Report the given negative errno into the store, along with the given
3329+ * formatted message.
3330+ */
3331 void xenbus_dev_error(struct xenbus_device *dev, int err, const char *fmt,
3332 ...)
3333 {
3334@@ -212,6 +297,16 @@ void xenbus_dev_error(struct xenbus_devi
3335 EXPORT_SYMBOL_GPL(xenbus_dev_error);
3336
3337
3338+/**
3339+ * xenbus_dev_fatal
3340+ * @dev: xenbus device
3341+ * @err: error to report
3342+ * @fmt: error message format
3343+ *
3344+ * Equivalent to xenbus_dev_error(dev, err, fmt, args), followed by
3345+ * xenbus_switch_state(dev, NULL, XenbusStateClosing) to schedule an orderly
3346+ * closedown of this driver and its peer.
3347+ */
3348 void xenbus_dev_fatal(struct xenbus_device *dev, int err, const char *fmt,
3349 ...)
3350 {
3351@@ -226,6 +321,15 @@ void xenbus_dev_fatal(struct xenbus_devi
3352 EXPORT_SYMBOL_GPL(xenbus_dev_fatal);
3353
3354
3355+/**
3356+ * xenbus_grant_ring
3357+ * @dev: xenbus device
3358+ * @ring_mfn: mfn of ring to grant
3359+ *
3360+ * Grant access to the given @ring_mfn to the peer of the given device. Return
3361+ * 0 on success, or -errno on error. On error, the device will switch to
3362+ * XenbusStateClosing, and the error will be saved in the store.
3363+ */
3364 int xenbus_grant_ring(struct xenbus_device *dev, unsigned long ring_mfn)
3365 {
3366 int err = gnttab_grant_foreign_access(dev->otherend_id, ring_mfn, 0);
3367@@ -236,6 +340,12 @@ int xenbus_grant_ring(struct xenbus_devi
3368 EXPORT_SYMBOL_GPL(xenbus_grant_ring);
3369
3370
3371+/**
3372+ * Allocate an event channel for the given xenbus_device, assigning the newly
3373+ * created local port to *port. Return 0 on success, or -errno on error. On
3374+ * error, the device will switch to XenbusStateClosing, and the error will be
3375+ * saved in the store.
3376+ */
3377 int xenbus_alloc_evtchn(struct xenbus_device *dev, int *port)
3378 {
3379 struct evtchn_alloc_unbound alloc_unbound;
3380@@ -256,6 +366,38 @@ int xenbus_alloc_evtchn(struct xenbus_de
3381 EXPORT_SYMBOL_GPL(xenbus_alloc_evtchn);
3382
3383
3384+#if 0 /* !defined(CONFIG_XEN) && !defined(MODULE) */
3385+/**
3386+ * Bind to an existing interdomain event channel in another domain. Returns 0
3387+ * on success and stores the local port in *port. On error, returns -errno,
3388+ * switches the device to XenbusStateClosing, and saves the error in XenStore.
3389+ */
3390+int xenbus_bind_evtchn(struct xenbus_device *dev, int remote_port, int *port)
3391+{
3392+ struct evtchn_bind_interdomain bind_interdomain;
3393+ int err;
3394+
3395+ bind_interdomain.remote_dom = dev->otherend_id;
3396+ bind_interdomain.remote_port = remote_port;
3397+
3398+ err = HYPERVISOR_event_channel_op(EVTCHNOP_bind_interdomain,
3399+ &bind_interdomain);
3400+ if (err)
3401+ xenbus_dev_fatal(dev, err,
3402+ "binding to event channel %d from domain %d",
3403+ remote_port, dev->otherend_id);
3404+ else
3405+ *port = bind_interdomain.local_port;
3406+
3407+ return err;
3408+}
3409+EXPORT_SYMBOL_GPL(xenbus_bind_evtchn);
3410+#endif
3411+
3412+
3413+/**
3414+ * Free an existing event channel. Returns 0 on success or -errno on error.
3415+ */
3416 int xenbus_free_evtchn(struct xenbus_device *dev, int port)
3417 {
3418 struct evtchn_close close;
3419@@ -272,6 +414,191 @@ int xenbus_free_evtchn(struct xenbus_dev
3420 EXPORT_SYMBOL_GPL(xenbus_free_evtchn);
3421
3422
3423+#if 0 /* !defined(CONFIG_XEN) && !defined(MODULE) */
3424+/**
3425+ * xenbus_map_ring_valloc
3426+ * @dev: xenbus device
3427+ * @gnt_ref: grant reference
3428+ * @vaddr: pointer to address to be filled out by mapping
3429+ *
3430+ * Based on Rusty Russell's skeleton driver's map_page.
3431+ * Map a page of memory into this domain from another domain's grant table.
3432+ * xenbus_map_ring_valloc allocates a page of virtual address space, maps the
3433+ * page to that address, and sets *vaddr to that address.
3434+ * Returns 0 on success, and GNTST_* (see xen/include/interface/grant_table.h)
3435+ * or -ENOMEM on error. If an error is returned, device will switch to
3436+ * XenbusStateClosing and the error message will be saved in XenStore.
3437+ */
3438+int xenbus_map_ring_valloc(struct xenbus_device *dev, int gnt_ref, void **vaddr)
3439+{
3440+ struct gnttab_map_grant_ref op = {
3441+ .flags = GNTMAP_host_map,
3442+ .ref = gnt_ref,
3443+ .dom = dev->otherend_id,
3444+ };
3445+ struct vm_struct *area;
3446+
3447+ *vaddr = NULL;
3448+
3449+ area = alloc_vm_area(PAGE_SIZE);
3450+ if (!area)
3451+ return -ENOMEM;
3452+
3453+ op.host_addr = (unsigned long)area->addr;
3454+
3455+ if (HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &op, 1))
3456+ BUG();
3457+
3458+ if (op.status != GNTST_okay) {
3459+ free_vm_area(area);
3460+ xenbus_dev_fatal(dev, op.status,
3461+ "mapping in shared page %d from domain %d",
3462+ gnt_ref, dev->otherend_id);
3463+ return op.status;
3464+ }
3465+
3466+ /* Stuff the handle in an unused field */
3467+ area->phys_addr = (unsigned long)op.handle;
3468+
3469+ *vaddr = area->addr;
3470+ return 0;
3471+}
3472+EXPORT_SYMBOL_GPL(xenbus_map_ring_valloc);
3473+
3474+
3475+/**
3476+ * xenbus_map_ring
3477+ * @dev: xenbus device
3478+ * @gnt_ref: grant reference
3479+ * @handle: pointer to grant handle to be filled
3480+ * @vaddr: address to be mapped to
3481+ *
3482+ * Map a page of memory into this domain from another domain's grant table.
3483+ * xenbus_map_ring does not allocate the virtual address space (you must do
3484+ * this yourself!). It only maps in the page to the specified address.
3485+ * Returns 0 on success, and GNTST_* (see xen/include/interface/grant_table.h)
3486+ * or -ENOMEM on error. If an error is returned, device will switch to
3487+ * XenbusStateClosing and the error message will be saved in XenStore.
3488+ */
3489+int xenbus_map_ring(struct xenbus_device *dev, int gnt_ref,
3490+ grant_handle_t *handle, void *vaddr)
3491+{
3492+ struct gnttab_map_grant_ref op = {
3493+ .host_addr = (unsigned long)vaddr,
3494+ .flags = GNTMAP_host_map,
3495+ .ref = gnt_ref,
3496+ .dom = dev->otherend_id,
3497+ };
3498+
3499+ if (HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &op, 1))
3500+ BUG();
3501+
3502+ if (op.status != GNTST_okay) {
3503+ xenbus_dev_fatal(dev, op.status,
3504+ "mapping in shared page %d from domain %d",
3505+ gnt_ref, dev->otherend_id);
3506+ } else
3507+ *handle = op.handle;
3508+
3509+ return op.status;
3510+}
3511+EXPORT_SYMBOL_GPL(xenbus_map_ring);
3512+
3513+
3514+/**
3515+ * xenbus_unmap_ring_vfree
3516+ * @dev: xenbus device
3517+ * @vaddr: addr to unmap
3518+ *
3519+ * Based on Rusty Russell's skeleton driver's unmap_page.
3520+ * Unmap a page of memory in this domain that was imported from another domain.
3521+ * Use xenbus_unmap_ring_vfree if you mapped in your memory with
3522+ * xenbus_map_ring_valloc (it will free the virtual address space).
3523+ * Returns 0 on success and returns GNTST_* on error
3524+ * (see xen/include/interface/grant_table.h).
3525+ */
3526+int xenbus_unmap_ring_vfree(struct xenbus_device *dev, void *vaddr)
3527+{
3528+ struct vm_struct *area;
3529+ struct gnttab_unmap_grant_ref op = {
3530+ .host_addr = (unsigned long)vaddr,
3531+ };
3532+
3533+ /* It'd be nice if linux/vmalloc.h provided a find_vm_area(void *addr)
3534+ * method so that we don't have to muck with vmalloc internals here.
3535+ * We could force the user to hang on to their struct vm_struct from
3536+ * xenbus_map_ring_valloc, but these 6 lines considerably simplify
3537+ * this API.
3538+ */
3539+ read_lock(&vmlist_lock);
3540+ for (area = vmlist; area != NULL; area = area->next) {
3541+ if (area->addr == vaddr)
3542+ break;
3543+ }
3544+ read_unlock(&vmlist_lock);
3545+
3546+ if (!area) {
3547+ xenbus_dev_error(dev, -ENOENT,
3548+ "can't find mapped virtual address %p", vaddr);
3549+ return GNTST_bad_virt_addr;
3550+ }
3551+
3552+ op.handle = (grant_handle_t)area->phys_addr;
3553+
3554+ if (HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1))
3555+ BUG();
3556+
3557+ if (op.status == GNTST_okay)
3558+ free_vm_area(area);
3559+ else
3560+ xenbus_dev_error(dev, op.status,
3561+ "unmapping page at handle %d error %d",
3562+ (int16_t)area->phys_addr, op.status);
3563+
3564+ return op.status;
3565+}
3566+EXPORT_SYMBOL_GPL(xenbus_unmap_ring_vfree);
3567+
3568+
3569+/**
3570+ * xenbus_unmap_ring
3571+ * @dev: xenbus device
3572+ * @handle: grant handle
3573+ * @vaddr: addr to unmap
3574+ *
3575+ * Unmap a page of memory in this domain that was imported from another domain.
3576+ * Returns 0 on success and returns GNTST_* on error
3577+ * (see xen/include/interface/grant_table.h).
3578+ */
3579+int xenbus_unmap_ring(struct xenbus_device *dev,
3580+ grant_handle_t handle, void *vaddr)
3581+{
3582+ struct gnttab_unmap_grant_ref op = {
3583+ .host_addr = (unsigned long)vaddr,
3584+ .handle = handle,
3585+ };
3586+
3587+ if (HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1))
3588+ BUG();
3589+
3590+ if (op.status != GNTST_okay)
3591+ xenbus_dev_error(dev, op.status,
3592+ "unmapping page at handle %d error %d",
3593+ handle, op.status);
3594+
3595+ return op.status;
3596+}
3597+EXPORT_SYMBOL_GPL(xenbus_unmap_ring);
3598+#endif
3599+
3600+
3601+/**
3602+ * xenbus_read_driver_state
3603+ * @path: path for driver
3604+ *
3605+ * Return the state of the driver rooted at the given store path, or
3606+ * XenbusStateUnknown if no state can be read.
3607+ */
3608 enum xenbus_state xenbus_read_driver_state(const char *path)
3609 {
3610 enum xenbus_state result;
3611Index: head-2008-12-01/drivers/xen/xenbus/xenbus_comms.c
3612===================================================================
3613--- head-2008-12-01.orig/drivers/xen/xenbus/xenbus_comms.c 2008-12-01 11:32:38.000000000 +0100
3614+++ head-2008-12-01/drivers/xen/xenbus/xenbus_comms.c 2008-12-01 11:36:47.000000000 +0100
3615@@ -34,12 +34,15 @@
3616 #include <linux/interrupt.h>
3617 #include <linux/sched.h>
3618 #include <linux/err.h>
3619-#include <linux/ptrace.h>
3620-#include <linux/workqueue.h>
3621-#include <xen/evtchn.h>
3622 #include <xen/xenbus.h>
3623-
3624+#if defined(CONFIG_XEN) || defined(MODULE)
3625+#include <xen/evtchn.h>
3626 #include <asm/hypervisor.h>
3627+#else
3628+#include <asm/xen/hypervisor.h>
3629+#include <xen/events.h>
3630+#include <xen/page.h>
3631+#endif
3632
3633 #include "xenbus_comms.h"
3634
3635@@ -91,6 +94,13 @@ static const void *get_input_chunk(XENST
3636 return buf + MASK_XENSTORE_IDX(cons);
3637 }
3638
3639+/**
3640+ * xb_write - low level write
3641+ * @data: buffer to send
3642+ * @len: length of buffer
3643+ *
3644+ * Returns 0 on success, error otherwise.
3645+ */
3646 int xb_write(const void *data, unsigned len)
3647 {
3648 struct xenstore_domain_interface *intf = xen_store_interface;
3649@@ -199,7 +209,9 @@ int xb_read(void *data, unsigned len)
3650 return 0;
3651 }
3652
3653-/* Set up interrupt handler off store event channel. */
3654+/**
3655+ * xb_init_comms - Set up interrupt handler off store event channel.
3656+ */
3657 int xb_init_comms(void)
3658 {
3659 struct xenstore_domain_interface *intf = xen_store_interface;
3660@@ -219,7 +231,11 @@ int xb_init_comms(void)
3661 if (xenbus_irq)
3662 unbind_from_irqhandler(xenbus_irq, &xb_waitq);
3663
3664+#if defined(CONFIG_XEN) || defined(MODULE)
3665 err = bind_caller_port_to_irqhandler(
3666+#else
3667+ err = bind_evtchn_to_irqhandler(
3668+#endif
3669 xen_store_evtchn, wake_waiting,
3670 0, "xenbus", &xb_waitq);
3671 if (err <= 0) {
3672Index: head-2008-12-01/drivers/xen/xenbus/xenbus_probe.c
3673===================================================================
3674--- head-2008-12-01.orig/drivers/xen/xenbus/xenbus_probe.c 2008-12-01 11:36:07.000000000 +0100
3675+++ head-2008-12-01/drivers/xen/xenbus/xenbus_probe.c 2008-12-01 11:36:47.000000000 +0100
3676@@ -43,12 +43,11 @@
3677 #include <linux/mm.h>
3678 #include <linux/notifier.h>
3679 #include <linux/mutex.h>
3680-#include <linux/module.h>
3681+#include <linux/io.h>
3682
3683-#include <asm/io.h>
3684 #include <asm/page.h>
3685-#include <asm/maddr.h>
3686 #include <asm/pgtable.h>
3687+#if defined(CONFIG_XEN) || defined(MODULE)
3688 #include <asm/hypervisor.h>
3689 #include <xen/xenbus.h>
3690 #include <xen/xen_proc.h>
3691@@ -57,6 +56,12 @@
3692 #ifdef MODULE
3693 #include <xen/hvm.h>
3694 #endif
3695+#else
3696+#include <asm/xen/hypervisor.h>
3697+#include <xen/xenbus.h>
3698+#include <xen/events.h>
3699+#include <xen/page.h>
3700+#endif
3701
3702 #include "xenbus_comms.h"
3703 #include "xenbus_probe.h"
3704@@ -168,7 +173,7 @@ static int read_backend_details(struct x
3705 return read_otherend_details(xendev, "backend-id", "backend");
3706 }
3707
3708-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
3709+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16) && (defined(CONFIG_XEN) || defined(MODULE))
3710 static int xenbus_uevent_frontend(struct device *dev, char **envp,
3711 int num_envp, char *buffer, int buffer_size)
3712 {
3713@@ -207,12 +212,16 @@ static struct xen_bus_type xenbus_fronte
3714 .probe = xenbus_dev_probe,
3715 .remove = xenbus_dev_remove,
3716 .shutdown = xenbus_dev_shutdown,
3717+#if defined(CONFIG_XEN) || defined(MODULE)
3718 .uevent = xenbus_uevent_frontend,
3719 #endif
3720+#endif
3721 },
3722+#if defined(CONFIG_XEN) || defined(MODULE)
3723 .dev = {
3724 .bus_id = "xen",
3725 },
3726+#endif
3727 };
3728
3729 static void otherend_changed(struct xenbus_watch *watch,
3730@@ -228,14 +237,15 @@ static void otherend_changed(struct xenb
3731 if (!dev->otherend ||
3732 strncmp(dev->otherend, vec[XS_WATCH_PATH],
3733 strlen(dev->otherend))) {
3734- DPRINTK("Ignoring watch at %s", vec[XS_WATCH_PATH]);
3735+ dev_dbg(&dev->dev, "Ignoring watch at %s", vec[XS_WATCH_PATH]);
3736 return;
3737 }
3738
3739 state = xenbus_read_driver_state(dev->otherend);
3740
3741- DPRINTK("state is %d (%s), %s, %s", state, xenbus_strstate(state),
3742- dev->otherend_watch.node, vec[XS_WATCH_PATH]);
3743+ dev_dbg(&dev->dev, "state is %d (%s), %s, %s",
3744+ state, xenbus_strstate(state), dev->otherend_watch.node,
3745+ vec[XS_WATCH_PATH]);
3746
3747 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
3748 /*
3749@@ -271,8 +281,13 @@ static int talk_to_otherend(struct xenbu
3750
3751 static int watch_otherend(struct xenbus_device *dev)
3752 {
3753+#if defined(CONFIG_XEN) || defined(MODULE)
3754 return xenbus_watch_path2(dev, dev->otherend, "state",
3755 &dev->otherend_watch, otherend_changed);
3756+#else
3757+ return xenbus_watch_pathfmt(dev, &dev->otherend_watch, otherend_changed,
3758+ "%s/%s", dev->otherend, "state");
3759+#endif
3760 }
3761
3762
3763@@ -298,9 +313,9 @@ int xenbus_dev_probe(struct device *_dev
3764
3765 err = talk_to_otherend(dev);
3766 if (err) {
3767- printk(KERN_WARNING
3768- "xenbus_probe: talk_to_otherend on %s failed.\n",
3769- dev->nodename);
3770+ dev_warn(&dev->dev,
3771+ "xenbus_probe: talk_to_otherend on %s failed.\n",
3772+ dev->nodename);
3773 return err;
3774 }
3775
3776@@ -310,9 +325,9 @@ int xenbus_dev_probe(struct device *_dev
3777
3778 err = watch_otherend(dev);
3779 if (err) {
3780- printk(KERN_WARNING
3781- "xenbus_probe: watch_otherend on %s failed.\n",
3782- dev->nodename);
3783+ dev_warn(&dev->dev,
3784+ "xenbus_probe: watch_otherend on %s failed.\n",
3785+ dev->nodename);
3786 return err;
3787 }
3788
3789@@ -352,14 +367,15 @@ static void xenbus_dev_shutdown(struct d
3790
3791 get_device(&dev->dev);
3792 if (dev->state != XenbusStateConnected) {
3793- printk("%s: %s: %s != Connected, skipping\n", __FUNCTION__,
3794- dev->nodename, xenbus_strstate(dev->state));
3795+ dev_info(&dev->dev, "%s: %s: %s != Connected, skipping\n", __FUNCTION__,
3796+ dev->nodename, xenbus_strstate(dev->state));
3797 goto out;
3798 }
3799 xenbus_switch_state(dev, XenbusStateClosing);
3800 timeout = wait_for_completion_timeout(&dev->down, timeout);
3801 if (!timeout)
3802- printk("%s: %s timeout closing device\n", __FUNCTION__, dev->nodename);
3803+ dev_info(&dev->dev, "%s: %s timeout closing device\n",
3804+ __FUNCTION__, dev->nodename);
3805 out:
3806 put_device(&dev->dev);
3807 }
3808@@ -547,7 +563,9 @@ int xenbus_probe_node(struct xen_bus_typ
3809 xendev->devicetype = tmpstring;
3810 init_completion(&xendev->down);
3811
3812+#if defined(CONFIG_XEN) || defined(MODULE)
3813 xendev->dev.parent = &bus->dev;
3814+#endif
3815 xendev->dev.bus = &bus->bus;
3816 xendev->dev.release = xenbus_dev_release;
3817
3818@@ -562,15 +580,16 @@ int xenbus_probe_node(struct xen_bus_typ
3819
3820 err = device_create_file(&xendev->dev, &dev_attr_nodename);
3821 if (err)
3822- goto unregister;
3823+ goto fail_unregister;
3824+
3825 err = device_create_file(&xendev->dev, &dev_attr_devtype);
3826 if (err)
3827- goto unregister;
3828+ goto fail_remove_file;
3829
3830 return 0;
3831-unregister:
3832+fail_remove_file:
3833 device_remove_file(&xendev->dev, &dev_attr_nodename);
3834- device_remove_file(&xendev->dev, &dev_attr_devtype);
3835+fail_unregister:
3836 device_unregister(&xendev->dev);
3837 fail:
3838 kfree(xendev);
3839@@ -583,7 +602,8 @@ static int xenbus_probe_frontend(const c
3840 char *nodename;
3841 int err;
3842
3843- nodename = kasprintf(GFP_KERNEL, "%s/%s/%s", xenbus_frontend.root, type, name);
3844+ nodename = kasprintf(GFP_KERNEL, "%s/%s/%s",
3845+ xenbus_frontend.root, type, name);
3846 if (!nodename)
3847 return -ENOMEM;
3848
3849@@ -659,7 +679,7 @@ static int strsep_len(const char *str, c
3850 return (len == 0) ? i : -ERANGE;
3851 }
3852
3853-void dev_changed(const char *node, struct xen_bus_type *bus)
3854+void xenbus_dev_changed(const char *node, struct xen_bus_type *bus)
3855 {
3856 int exists, rootlen;
3857 struct xenbus_device *dev;
3858@@ -667,7 +687,7 @@ void dev_changed(const char *node, struc
3859 const char *p, *root;
3860
3861 if (bus->error || char_count(node, '/') < 2)
3862- return;
3863+ return;
3864
3865 exists = xenbus_exists(XBT_NIL, node, "");
3866 if (!exists) {
3867@@ -701,7 +721,7 @@ static void frontend_changed(struct xenb
3868 {
3869 DPRINTK("");
3870
3871- dev_changed(vec[XS_WATCH_PATH], &xenbus_frontend);
3872+ xenbus_dev_changed(vec[XS_WATCH_PATH], &xenbus_frontend);
3873 }
3874
3875 /* We watch for devices appearing and vanishing. */
3876@@ -904,10 +924,16 @@ static int xsd_port_read(char *page, cha
3877 }
3878 #endif
3879
3880-static int xenbus_probe_init(void)
3881+#ifndef MODULE
3882+static int __init xenbus_probe_init(void)
3883+#else
3884+static int __devinit xenbus_probe_init(void)
3885+#endif
3886 {
3887 int err = 0;
3888+#if defined(CONFIG_XEN) || defined(MODULE)
3889 unsigned long page = 0;
3890+#endif
3891
3892 DPRINTK("");
3893
3894@@ -926,6 +952,7 @@ static int xenbus_probe_init(void)
3895 * Domain0 doesn't have a store_evtchn or store_mfn yet.
3896 */
3897 if (is_initial_xendomain()) {
3898+#if defined(CONFIG_XEN) || defined(MODULE)
3899 struct evtchn_alloc_unbound alloc_unbound;
3900
3901 /* Allocate page. */
3902@@ -963,10 +990,13 @@ static int xenbus_probe_init(void)
3903 if (xsd_port_intf)
3904 xsd_port_intf->read_proc = xsd_port_read;
3905 #endif
3906+#else
3907+ /* dom0 not yet supported */
3908+#endif
3909 xen_store_interface = mfn_to_virt(xen_store_mfn);
3910 } else {
3911 xenstored_ready = 1;
3912-#ifdef CONFIG_XEN
3913+#ifndef MODULE
3914 xen_store_evtchn = xen_start_info->store_evtchn;
3915 xen_store_mfn = xen_start_info->store_mfn;
3916 xen_store_interface = mfn_to_virt(xen_store_mfn);
3917@@ -979,7 +1009,9 @@ static int xenbus_probe_init(void)
3918 }
3919
3920
3921+#if defined(CONFIG_XEN) || defined(MODULE)
3922 xenbus_dev_init();
3923+#endif
3924
3925 /* Initialize the interface to xenstore. */
3926 err = xs_init();
3927@@ -989,6 +1021,7 @@ static int xenbus_probe_init(void)
3928 goto err;
3929 }
3930
3931+#if defined(CONFIG_XEN) || defined(MODULE)
3932 /* Register ourselves with the kernel device subsystem */
3933 if (!xenbus_frontend.error) {
3934 xenbus_frontend.error = device_register(&xenbus_frontend.dev);
3935@@ -999,6 +1032,7 @@ static int xenbus_probe_init(void)
3936 xenbus_frontend.error);
3937 }
3938 }
3939+#endif
3940 xenbus_backend_device_register();
3941
3942 if (!is_initial_xendomain())
3943@@ -1007,8 +1041,10 @@ static int xenbus_probe_init(void)
3944 return 0;
3945
3946 err:
3947+#if defined(CONFIG_XEN) || defined(MODULE)
3948 if (page)
3949 free_page(page);
3950+#endif
3951
3952 /*
3953 * Do not unregister the xenbus front/backend buses here. The buses
3954@@ -1019,11 +1055,15 @@ static int xenbus_probe_init(void)
3955 return err;
3956 }
3957
3958-#ifdef CONFIG_XEN
3959+#ifndef MODULE
3960 postcore_initcall(xenbus_probe_init);
3961+#ifdef CONFIG_XEN
3962 MODULE_LICENSE("Dual BSD/GPL");
3963 #else
3964-int xenbus_init(void)
3965+MODULE_LICENSE("GPL");
3966+#endif
3967+#else
3968+int __devinit xenbus_init(void)
3969 {
3970 return xenbus_probe_init();
3971 }
3972Index: head-2008-12-01/drivers/xen/xenbus/xenbus_probe.h
3973===================================================================
3974--- head-2008-12-01.orig/drivers/xen/xenbus/xenbus_probe.h 2008-12-01 11:36:07.000000000 +0100
3975+++ head-2008-12-01/drivers/xen/xenbus/xenbus_probe.h 2008-12-01 11:36:47.000000000 +0100
3976@@ -56,7 +56,9 @@ struct xen_bus_type
3977 int (*get_bus_id)(char bus_id[BUS_ID_SIZE], const char *nodename);
3978 int (*probe)(const char *type, const char *dir);
3979 struct bus_type bus;
3980+#if defined(CONFIG_XEN) || defined(MODULE)
3981 struct device dev;
3982+#endif
3983 };
3984
3985 extern int xenbus_match(struct device *_dev, struct device_driver *_drv);
3986@@ -71,7 +73,7 @@ extern int xenbus_probe_node(struct xen_
3987 const char *nodename);
3988 extern int xenbus_probe_devices(struct xen_bus_type *bus);
3989
3990-extern void dev_changed(const char *node, struct xen_bus_type *bus);
3991+extern void xenbus_dev_changed(const char *node, struct xen_bus_type *bus);
3992
3993 #endif
3994
3995Index: head-2008-12-01/drivers/xen/xenbus/xenbus_probe_backend.c
3996===================================================================
3997--- head-2008-12-01.orig/drivers/xen/xenbus/xenbus_probe_backend.c 2008-12-01 11:36:07.000000000 +0100
3998+++ head-2008-12-01/drivers/xen/xenbus/xenbus_probe_backend.c 2008-12-01 11:36:47.000000000 +0100
3999@@ -236,7 +236,7 @@ static void backend_changed(struct xenbu
4000 {
4001 DPRINTK("");
4002
4003- dev_changed(vec[XS_WATCH_PATH], &xenbus_backend);
4004+ xenbus_dev_changed(vec[XS_WATCH_PATH], &xenbus_backend);
4005 }
4006
4007 static struct xenbus_watch be_watch = {
4008Index: head-2008-12-01/drivers/xen/xenbus/xenbus_xs.c
4009===================================================================
4010--- head-2008-12-01.orig/drivers/xen/xenbus/xenbus_xs.c 2008-12-01 11:22:58.000000000 +0100
4011+++ head-2008-12-01/drivers/xen/xenbus/xenbus_xs.c 2008-12-01 11:36:47.000000000 +0100
4012@@ -221,7 +221,7 @@ static void *xs_talkv(struct xenbus_tran
4013 }
4014
4015 for (i = 0; i < num_vecs; i++) {
4016- err = xb_write(iovec[i].iov_base, iovec[i].iov_len);;
4017+ err = xb_write(iovec[i].iov_base, iovec[i].iov_len);
4018 if (err) {
4019 mutex_unlock(&xs_state.request_mutex);
4020 return ERR_PTR(err);
4021@@ -630,7 +630,9 @@ void unregister_xenbus_watch(struct xenb
4022 char token[sizeof(watch) * 2 + 1];
4023 int err;
4024
4025+#if defined(CONFIG_XEN) || defined(MODULE)
4026 BUG_ON(watch->flags & XBWF_new_thread);
4027+#endif
4028
4029 sprintf(token, "%lX", (long)watch);
4030
4031@@ -649,6 +651,11 @@ void unregister_xenbus_watch(struct xenb
4032
4033 up_read(&xs_state.watch_mutex);
4034
4035+ /* Make sure there are no callbacks running currently (unless
4036+ its us) */
4037+ if (current->pid != xenwatch_pid)
4038+ mutex_lock(&xenwatch_mutex);
4039+
4040 /* Cancel pending watch events. */
4041 spin_lock(&watch_events_lock);
4042 list_for_each_entry_safe(msg, tmp, &watch_events, list) {
4043@@ -660,11 +667,8 @@ void unregister_xenbus_watch(struct xenb
4044 }
4045 spin_unlock(&watch_events_lock);
4046
4047- /* Flush any currently-executing callback, unless we are it. :-) */
4048- if (current->pid != xenwatch_pid) {
4049- mutex_lock(&xenwatch_mutex);
4050+ if (current->pid != xenwatch_pid)
4051 mutex_unlock(&xenwatch_mutex);
4052- }
4053 }
4054 EXPORT_SYMBOL_GPL(unregister_xenbus_watch);
4055
4056@@ -702,6 +706,7 @@ void xs_suspend_cancel(void)
4057 up_write(&xs_state.transaction_mutex);
4058 }
4059
4060+#if defined(CONFIG_XEN) || defined(MODULE)
4061 static int xenwatch_handle_callback(void *data)
4062 {
4063 struct xs_stored_msg *msg = data;
4064@@ -719,6 +724,7 @@ static int xenwatch_handle_callback(void
4065
4066 return 0;
4067 }
4068+#endif
4069
4070 static int xenwatch_thread(void *unused)
4071 {
4072@@ -748,6 +754,7 @@ static int xenwatch_thread(void *unused)
4073
4074 msg = list_entry(ent, struct xs_stored_msg, list);
4075
4076+#if defined(CONFIG_XEN) || defined(MODULE)
4077 /*
4078 * Unlock the mutex before running an XBWF_new_thread
4079 * handler. kthread_run can block which can deadlock
4080@@ -764,6 +771,15 @@ static int xenwatch_thread(void *unused)
4081 xenwatch_handle_callback(msg);
4082 mutex_unlock(&xenwatch_mutex);
4083 }
4084+#else
4085+ msg->u.watch.handle->callback(
4086+ msg->u.watch.handle,
4087+ (const char **)msg->u.watch.vec,
4088+ msg->u.watch.vec_size);
4089+ mutex_unlock(&xenwatch_mutex);
4090+ kfree(msg->u.watch.vec);
4091+ kfree(msg);
4092+#endif
4093 }
4094
4095 return 0;
4096Index: head-2008-12-01/include/asm-x86/mach-xen/asm/fixmap_32.h
4097===================================================================
4098--- head-2008-12-01.orig/include/asm-x86/mach-xen/asm/fixmap_32.h 2008-12-01 11:36:13.000000000 +0100
4099+++ head-2008-12-01/include/asm-x86/mach-xen/asm/fixmap_32.h 2008-12-01 11:36:47.000000000 +0100
4100@@ -53,6 +53,8 @@ extern unsigned long __FIXADDR_TOP;
4101 enum fixed_addresses {
4102 FIX_HOLE,
4103 FIX_VDSO,
4104+ FIX_DBGP_BASE,
4105+ FIX_EARLYCON_MEM_BASE,
4106 #ifdef CONFIG_X86_LOCAL_APIC
4107 FIX_APIC_BASE, /* local (CPU) APIC) -- required for SMP or not */
4108 #endif
4109Index: head-2008-12-01/include/asm-x86/mach-xen/asm/highmem.h
4110===================================================================
4111--- head-2008-12-01.orig/include/asm-x86/mach-xen/asm/highmem.h 2008-12-01 11:36:13.000000000 +0100
4112+++ head-2008-12-01/include/asm-x86/mach-xen/asm/highmem.h 2008-12-01 11:36:47.000000000 +0100
4113@@ -76,8 +76,7 @@ struct page *kmap_atomic_to_page(void *p
4114
4115 #define kmap_atomic_pte(page, type) \
4116 kmap_atomic_prot(page, type, \
4117- test_bit(PG_pinned, &(page)->flags) \
4118- ? PAGE_KERNEL_RO : kmap_prot)
4119+ PagePinned(page) ? PAGE_KERNEL_RO : kmap_prot)
4120
4121 #define flush_cache_kmaps() do { } while (0)
4122
4123Index: head-2008-12-01/include/asm-x86/mach-xen/asm/io_32.h
4124===================================================================
4125--- head-2008-12-01.orig/include/asm-x86/mach-xen/asm/io_32.h 2008-12-01 11:36:13.000000000 +0100
4126+++ head-2008-12-01/include/asm-x86/mach-xen/asm/io_32.h 2008-12-01 11:36:47.000000000 +0100
4127@@ -125,6 +125,9 @@ extern void __iomem * __ioremap(unsigned
4128 * writew/writel functions and the other mmio helpers. The returned
4129 * address is not guaranteed to be usable directly as a virtual
4130 * address.
4131+ *
4132+ * If the area you are trying to map is a PCI BAR you should have a
4133+ * look at pci_iomap().
4134 */
4135
4136 static inline void __iomem * ioremap(unsigned long offset, unsigned long size)
4137@@ -142,6 +145,7 @@ extern void iounmap(volatile void __iome
4138 */
4139 extern void *bt_ioremap(unsigned long offset, unsigned long size);
4140 extern void bt_iounmap(void *addr, unsigned long size);
4141+extern void __iomem *fix_ioremap(unsigned idx, unsigned long phys);
4142
4143 /* Use early IO mappings for DMI because it's initialized early */
4144 #define dmi_ioremap bt_ioremap
4145Index: head-2008-12-01/include/asm-x86/mach-xen/asm/maddr_32.h
4146===================================================================
4147--- head-2008-12-01.orig/include/asm-x86/mach-xen/asm/maddr_32.h 2008-04-02 12:34:02.000000000 +0200
4148+++ head-2008-12-01/include/asm-x86/mach-xen/asm/maddr_32.h 2008-12-01 11:36:47.000000000 +0100
4149@@ -155,6 +155,7 @@ static inline paddr_t pte_machine_to_phy
4150
4151 #ifdef CONFIG_X86_PAE
4152 #define __pte_ma(x) ((pte_t) { (x), (maddr_t)(x) >> 32 } )
4153+extern unsigned long long __supported_pte_mask;
4154 static inline pte_t pfn_pte_ma(unsigned long page_nr, pgprot_t pgprot)
4155 {
4156 pte_t pte;
4157Index: head-2008-12-01/include/asm-x86/mach-xen/asm/mmu_context_32.h
4158===================================================================
4159--- head-2008-12-01.orig/include/asm-x86/mach-xen/asm/mmu_context_32.h 2008-12-01 11:36:13.000000000 +0100
4160+++ head-2008-12-01/include/asm-x86/mach-xen/asm/mmu_context_32.h 2008-12-01 11:36:47.000000000 +0100
4161@@ -16,7 +16,7 @@ void mm_pin_all(void);
4162 static inline void xen_activate_mm(struct mm_struct *prev,
4163 struct mm_struct *next)
4164 {
4165- if (!test_bit(PG_pinned, &virt_to_page(next->pgd)->flags))
4166+ if (!PagePinned(virt_to_page(next->pgd)))
4167 mm_pin(next);
4168 }
4169
4170@@ -51,6 +51,8 @@ static inline void __prepare_arch_switch
4171 : : "r" (0) );
4172 }
4173
4174+void leave_mm(unsigned long cpu);
4175+
4176 static inline void switch_mm(struct mm_struct *prev,
4177 struct mm_struct *next,
4178 struct task_struct *tsk)
4179@@ -60,7 +62,7 @@ static inline void switch_mm(struct mm_s
4180
4181 if (likely(prev != next)) {
4182 BUG_ON(!xen_feature(XENFEAT_writable_page_tables) &&
4183- !test_bit(PG_pinned, &virt_to_page(next->pgd)->flags));
4184+ !PagePinned(virt_to_page(next->pgd)));
4185
4186 /* stop flush ipis for the previous mm */
4187 cpu_clear(cpu, prev->cpu_vm_mask);
4188Index: head-2008-12-01/include/asm-x86/mach-xen/asm/pci_32.h
4189===================================================================
4190--- head-2008-12-01.orig/include/asm-x86/mach-xen/asm/pci_32.h 2007-09-14 11:14:51.000000000 +0200
4191+++ head-2008-12-01/include/asm-x86/mach-xen/asm/pci_32.h 2008-12-01 11:36:47.000000000 +0100
4192@@ -3,6 +3,14 @@
4193
4194
4195 #ifdef __KERNEL__
4196+
4197+struct pci_sysdata {
4198+ int node; /* NUMA node */
4199+};
4200+
4201+/* scan a bus after allocating a pci_sysdata for it */
4202+extern struct pci_bus *pci_scan_bus_with_sysdata(int busno);
4203+
4204 #include <linux/mm.h> /* for struct page */
4205
4206 /* Can be used to override the logic in pci_scan_bus for skipping
4207@@ -81,48 +89,11 @@ struct pci_dev;
4208
4209 #endif
4210
4211-/* This is always fine. */
4212-#define pci_dac_dma_supported(pci_dev, mask) (1)
4213-
4214-static inline dma64_addr_t
4215-pci_dac_page_to_dma(struct pci_dev *pdev, struct page *page, unsigned long offset, int direction)
4216-{
4217- return ((dma64_addr_t) page_to_phys(page) +
4218- (dma64_addr_t) offset);
4219-}
4220-
4221-static inline struct page *
4222-pci_dac_dma_to_page(struct pci_dev *pdev, dma64_addr_t dma_addr)
4223-{
4224- return pfn_to_page(dma_addr >> PAGE_SHIFT);
4225-}
4226-
4227-static inline unsigned long
4228-pci_dac_dma_to_offset(struct pci_dev *pdev, dma64_addr_t dma_addr)
4229-{
4230- return (dma_addr & ~PAGE_MASK);
4231-}
4232-
4233-static inline void
4234-pci_dac_dma_sync_single_for_cpu(struct pci_dev *pdev, dma64_addr_t dma_addr, size_t len, int direction)
4235-{
4236-}
4237-
4238-static inline void
4239-pci_dac_dma_sync_single_for_device(struct pci_dev *pdev, dma64_addr_t dma_addr, size_t len, int direction)
4240-{
4241- flush_write_buffers();
4242-}
4243-
4244 #define HAVE_PCI_MMAP
4245 extern int pci_mmap_page_range(struct pci_dev *dev, struct vm_area_struct *vma,
4246 enum pci_mmap_state mmap_state, int write_combine);
4247
4248
4249-static inline void pcibios_add_platform_entries(struct pci_dev *dev)
4250-{
4251-}
4252-
4253 #ifdef CONFIG_PCI
4254 static inline void pci_dma_burst_advice(struct pci_dev *pdev,
4255 enum pci_dma_burst_strategy *strat,
4256Index: head-2008-12-01/include/asm-x86/mach-xen/asm/pgalloc_32.h
4257===================================================================
4258--- head-2008-12-01.orig/include/asm-x86/mach-xen/asm/pgalloc_32.h 2008-12-01 11:36:13.000000000 +0100
4259+++ head-2008-12-01/include/asm-x86/mach-xen/asm/pgalloc_32.h 2008-12-01 11:36:47.000000000 +0100
4260@@ -5,7 +5,7 @@
4261 #include <linux/mm.h> /* for struct page */
4262 #include <asm/io.h> /* for phys_to_virt and page_to_pseudophys */
4263
4264-#define paravirt_alloc_pt(pfn) do { } while (0)
4265+#define paravirt_alloc_pt(mm, pfn) do { } while (0)
4266 #define paravirt_alloc_pd(pfn) do { } while (0)
4267 #define paravirt_alloc_pd(pfn) do { } while (0)
4268 #define paravirt_alloc_pd_clone(pfn, clonepfn, start, count) do { } while (0)
4269@@ -14,15 +14,15 @@
4270
4271 #define pmd_populate_kernel(mm, pmd, pte) \
4272 do { \
4273- paravirt_alloc_pt(__pa(pte) >> PAGE_SHIFT); \
4274+ paravirt_alloc_pt(mm, __pa(pte) >> PAGE_SHIFT); \
4275 set_pmd(pmd, __pmd(_PAGE_TABLE + __pa(pte))); \
4276 } while (0)
4277
4278 #define pmd_populate(mm, pmd, pte) \
4279 do { \
4280 unsigned long pfn = page_to_pfn(pte); \
4281- paravirt_alloc_pt(pfn); \
4282- if (test_bit(PG_pinned, &virt_to_page((mm)->pgd)->flags)) { \
4283+ paravirt_alloc_pt(mm, pfn); \
4284+ if (PagePinned(virt_to_page((mm)->pgd))) { \
4285 if (!PageHighMem(pte)) \
4286 BUG_ON(HYPERVISOR_update_va_mapping( \
4287 (unsigned long)__va(pfn << PAGE_SHIFT), \
4288Index: head-2008-12-01/include/asm-x86/mach-xen/asm/pgtable_32.h
4289===================================================================
4290--- head-2008-12-01.orig/include/asm-x86/mach-xen/asm/pgtable_32.h 2008-12-01 11:36:13.000000000 +0100
4291+++ head-2008-12-01/include/asm-x86/mach-xen/asm/pgtable_32.h 2008-12-01 11:36:47.000000000 +0100
4292@@ -26,9 +26,6 @@
4293 #include <linux/spinlock.h>
4294 #include <linux/sched.h>
4295
4296-/* Is this pagetable pinned? */
4297-#define PG_pinned PG_arch_1
4298-
4299 struct vm_area_struct;
4300
4301 /*
4302@@ -82,7 +79,7 @@ void paging_init(void);
4303 * area for the same reason. ;)
4304 */
4305 #define VMALLOC_OFFSET (8*1024*1024)
4306-#define VMALLOC_START (((unsigned long) high_memory + vmalloc_earlyreserve + \
4307+#define VMALLOC_START (((unsigned long) high_memory + \
4308 2*VMALLOC_OFFSET-1) & ~(VMALLOC_OFFSET-1))
4309 #ifdef CONFIG_HIGHMEM
4310 # define VMALLOC_END (PKMAP_BASE-2*PAGE_SIZE)
4311@@ -231,8 +228,6 @@ extern unsigned long pg0[];
4312 * The following only work if pte_present() is true.
4313 * Undefined behaviour if not..
4314 */
4315-static inline int pte_user(pte_t pte) { return (pte).pte_low & _PAGE_USER; }
4316-static inline int pte_read(pte_t pte) { return (pte).pte_low & _PAGE_USER; }
4317 static inline int pte_dirty(pte_t pte) { return (pte).pte_low & _PAGE_DIRTY; }
4318 static inline int pte_young(pte_t pte) { return (pte).pte_low & _PAGE_ACCESSED; }
4319 static inline int pte_write(pte_t pte) { return (pte).pte_low & _PAGE_RW; }
4320@@ -243,13 +238,9 @@ static inline int pte_huge(pte_t pte) {
4321 */
4322 static inline int pte_file(pte_t pte) { return (pte).pte_low & _PAGE_FILE; }
4323
4324-static inline pte_t pte_rdprotect(pte_t pte) { (pte).pte_low &= ~_PAGE_USER; return pte; }
4325-static inline pte_t pte_exprotect(pte_t pte) { (pte).pte_low &= ~_PAGE_USER; return pte; }
4326 static inline pte_t pte_mkclean(pte_t pte) { (pte).pte_low &= ~_PAGE_DIRTY; return pte; }
4327 static inline pte_t pte_mkold(pte_t pte) { (pte).pte_low &= ~_PAGE_ACCESSED; return pte; }
4328 static inline pte_t pte_wrprotect(pte_t pte) { (pte).pte_low &= ~_PAGE_RW; return pte; }
4329-static inline pte_t pte_mkread(pte_t pte) { (pte).pte_low |= _PAGE_USER; return pte; }
4330-static inline pte_t pte_mkexec(pte_t pte) { (pte).pte_low |= _PAGE_USER; return pte; }
4331 static inline pte_t pte_mkdirty(pte_t pte) { (pte).pte_low |= _PAGE_DIRTY; return pte; }
4332 static inline pte_t pte_mkyoung(pte_t pte) { (pte).pte_low |= _PAGE_ACCESSED; return pte; }
4333 static inline pte_t pte_mkwrite(pte_t pte) { (pte).pte_low |= _PAGE_RW; return pte; }
4334@@ -295,22 +286,20 @@ static inline pte_t xen_local_ptep_get_a
4335 #define ptep_set_access_flags(vma, address, ptep, entry, dirty) \
4336 ({ \
4337 int __changed = !pte_same(*(ptep), entry); \
4338- if (__changed && (dirty)) \
4339- ptep_establish(vma, address, ptep, entry); \
4340+ if (__changed && (dirty)) { \
4341+ if ( likely((vma)->vm_mm == current->mm) ) { \
4342+ BUG_ON(HYPERVISOR_update_va_mapping(address, \
4343+ entry, \
4344+ (unsigned long)(vma)->vm_mm->cpu_vm_mask.bits| \
4345+ UVMF_INVLPG|UVMF_MULTI)); \
4346+ } else { \
4347+ xen_l1_entry_update(ptep, entry); \
4348+ flush_tlb_page(vma, address); \
4349+ } \
4350+ } \
4351 __changed; \
4352 })
4353
4354-#define __HAVE_ARCH_PTEP_TEST_AND_CLEAR_DIRTY
4355-#define ptep_test_and_clear_dirty(vma, addr, ptep) ({ \
4356- int __ret = 0; \
4357- if (pte_dirty(*(ptep))) \
4358- __ret = test_and_clear_bit(_PAGE_BIT_DIRTY, \
4359- &(ptep)->pte_low); \
4360- if (__ret) \
4361- pte_update((vma)->vm_mm, addr, ptep); \
4362- __ret; \
4363-})
4364-
4365 #define __HAVE_ARCH_PTEP_TEST_AND_CLEAR_YOUNG
4366 #define ptep_test_and_clear_young(vma, addr, ptep) ({ \
4367 int __ret = 0; \
4368@@ -322,44 +311,13 @@ static inline pte_t xen_local_ptep_get_a
4369 __ret; \
4370 })
4371
4372-/*
4373- * Rules for using ptep_establish: the pte MUST be a user pte, and
4374- * must be a present->present transition.
4375- */
4376-#define __HAVE_ARCH_PTEP_ESTABLISH
4377-#define ptep_establish(vma, address, ptep, pteval) \
4378-do { \
4379- if ( likely((vma)->vm_mm == current->mm) ) { \
4380- BUG_ON(HYPERVISOR_update_va_mapping(address, \
4381- pteval, \
4382- (unsigned long)(vma)->vm_mm->cpu_vm_mask.bits| \
4383- UVMF_INVLPG|UVMF_MULTI)); \
4384- } else { \
4385- xen_l1_entry_update(ptep, pteval); \
4386- flush_tlb_page(vma, address); \
4387- } \
4388-} while (0)
4389-
4390-#define __HAVE_ARCH_PTEP_CLEAR_DIRTY_FLUSH
4391-#define ptep_clear_flush_dirty(vma, address, ptep) \
4392-({ \
4393- pte_t __pte = *(ptep); \
4394- int __dirty = pte_dirty(__pte); \
4395- __pte = pte_mkclean(__pte); \
4396- if (test_bit(PG_pinned, &virt_to_page((vma)->vm_mm->pgd)->flags)) \
4397- (void)ptep_set_access_flags(vma, address, ptep, __pte, __dirty); \
4398- else if (__dirty) \
4399- (ptep)->pte_low = __pte.pte_low; \
4400- __dirty; \
4401-})
4402-
4403 #define __HAVE_ARCH_PTEP_CLEAR_YOUNG_FLUSH
4404 #define ptep_clear_flush_young(vma, address, ptep) \
4405 ({ \
4406 pte_t __pte = *(ptep); \
4407 int __young = pte_young(__pte); \
4408 __pte = pte_mkold(__pte); \
4409- if (test_bit(PG_pinned, &virt_to_page((vma)->vm_mm->pgd)->flags)) \
4410+ if (PagePinned(virt_to_page((vma)->vm_mm->pgd))) \
4411 (void)ptep_set_access_flags(vma, address, ptep, __pte, __young); \
4412 else if (__young) \
4413 (ptep)->pte_low = __pte.pte_low; \
4414@@ -383,7 +341,7 @@ static inline pte_t ptep_get_and_clear(s
4415 #define ptep_get_and_clear_full(mm, addr, ptep, full) \
4416 ((full) ? ({ \
4417 pte_t __res = *(ptep); \
4418- if (test_bit(PG_pinned, &virt_to_page((mm)->pgd)->flags)) \
4419+ if (PagePinned(virt_to_page((mm)->pgd))) \
4420 xen_l1_entry_update(ptep, __pte(0)); \
4421 else \
4422 *(ptep) = __pte(0); \
4423Index: head-2008-12-01/include/asm-x86/mach-xen/asm/pgtable-3level.h
4424===================================================================
4425--- head-2008-12-01.orig/include/asm-x86/mach-xen/asm/pgtable-3level.h 2008-12-01 11:36:13.000000000 +0100
4426+++ head-2008-12-01/include/asm-x86/mach-xen/asm/pgtable-3level.h 2008-12-01 11:36:47.000000000 +0100
4427@@ -23,26 +23,11 @@
4428 #define pud_present(pud) 1
4429
4430 /*
4431- * Is the pte executable?
4432- */
4433-static inline int pte_x(pte_t pte)
4434-{
4435- return !(__pte_val(pte) & _PAGE_NX);
4436-}
4437-
4438-/*
4439- * All present user-pages with !NX bit are user-executable:
4440- */
4441-static inline int pte_exec(pte_t pte)
4442-{
4443- return pte_user(pte) && pte_x(pte);
4444-}
4445-/*
4446 * All present pages with !NX bit are kernel-executable:
4447 */
4448 static inline int pte_exec_kernel(pte_t pte)
4449 {
4450- return pte_x(pte);
4451+ return !(__pte_val(pte) & _PAGE_NX);
4452 }
4453
4454 /* Rules for using set_pte: the pte being assigned *must* be
4455Index: head-2008-12-01/include/asm-x86/mach-xen/asm/processor_32.h
4456===================================================================
4457--- head-2008-12-01.orig/include/asm-x86/mach-xen/asm/processor_32.h 2008-12-01 11:36:13.000000000 +0100
4458+++ head-2008-12-01/include/asm-x86/mach-xen/asm/processor_32.h 2008-12-01 11:36:47.000000000 +0100
4459@@ -89,7 +89,6 @@ struct cpuinfo_x86 {
4460 #define X86_VENDOR_UMC 3
4461 #define X86_VENDOR_NEXGEN 4
4462 #define X86_VENDOR_CENTAUR 5
4463-#define X86_VENDOR_RISE 6
4464 #define X86_VENDOR_TRANSMETA 7
4465 #define X86_VENDOR_NSC 8
4466 #define X86_VENDOR_NUM 9
4467@@ -122,6 +121,7 @@ void __init cpu_detect(struct cpuinfo_x8
4468 extern void identify_boot_cpu(void);
4469 extern void identify_secondary_cpu(struct cpuinfo_x86 *);
4470 extern void print_cpu_info(struct cpuinfo_x86 *);
4471+extern void init_scattered_cpuid_features(struct cpuinfo_x86 *c);
4472 extern unsigned int init_intel_cacheinfo(struct cpuinfo_x86 *c);
4473 extern unsigned short num_cache_leaves;
4474
4475@@ -171,17 +171,6 @@ static inline void clear_in_cr4 (unsigne
4476 write_cr4(cr4);
4477 }
4478
4479-/*
4480- * NSC/Cyrix CPU indexed register access macros
4481- */
4482-
4483-#define getCx86(reg) ({ outb((reg), 0x22); inb(0x23); })
4484-
4485-#define setCx86(reg, data) do { \
4486- outb((reg), 0x22); \
4487- outb((data), 0x23); \
4488-} while (0)
4489-
4490 /* Stop speculative execution */
4491 static inline void sync_core(void)
4492 {
4493@@ -230,6 +219,10 @@ extern int bootloader_type;
4494
4495 #define HAVE_ARCH_PICK_MMAP_LAYOUT
4496
4497+extern void hard_disable_TSC(void);
4498+extern void disable_TSC(void);
4499+extern void hard_enable_TSC(void);
4500+
4501 /*
4502 * Size of io_bitmap.
4503 */
4504Index: head-2008-12-01/include/asm-x86/mach-xen/asm/system_32.h
4505===================================================================
4506--- head-2008-12-01.orig/include/asm-x86/mach-xen/asm/system_32.h 2008-12-01 11:36:13.000000000 +0100
4507+++ head-2008-12-01/include/asm-x86/mach-xen/asm/system_32.h 2008-12-01 11:36:47.000000000 +0100
4508@@ -205,11 +205,6 @@ static inline unsigned long get_limit(un
4509 */
4510
4511
4512-/*
4513- * Actually only lfence would be needed for mb() because all stores done
4514- * by the kernel should be already ordered. But keep a full barrier for now.
4515- */
4516-
4517 #define mb() alternative("lock; addl $0,0(%%esp)", "mfence", X86_FEATURE_XMM2)
4518 #define rmb() alternative("lock; addl $0,0(%%esp)", "lfence", X86_FEATURE_XMM2)
4519
4520@@ -301,15 +296,6 @@ void enable_hlt(void);
4521 extern int es7000_plat;
4522 void cpu_idle_wait(void);
4523
4524-/*
4525- * On SMP systems, when the scheduler does migration-cost autodetection,
4526- * it needs a way to flush as much of the CPU's caches as possible:
4527- */
4528-static inline void sched_cacheflush(void)
4529-{
4530- wbinvd();
4531-}
4532-
4533 extern unsigned long arch_align_stack(unsigned long sp);
4534 extern void free_init_pages(char *what, unsigned long begin, unsigned long end);
4535
4536Index: head-2008-12-01/include/asm-x86/mach-xen/asm/tlbflush_32.h
4537===================================================================
4538--- head-2008-12-01.orig/include/asm-x86/mach-xen/asm/tlbflush_32.h 2008-12-01 11:36:13.000000000 +0100
4539+++ head-2008-12-01/include/asm-x86/mach-xen/asm/tlbflush_32.h 2008-12-01 11:36:47.000000000 +0100
4540@@ -91,7 +91,11 @@ struct tlb_state
4541 DECLARE_PER_CPU(struct tlb_state, cpu_tlbstate);
4542 #endif /* SMP */
4543
4544-#define flush_tlb_kernel_range(start, end) flush_tlb_all()
4545+static inline void flush_tlb_kernel_range(unsigned long start,
4546+ unsigned long end)
4547+{
4548+ flush_tlb_all();
4549+}
4550
4551 static inline void flush_tlb_pgtables(struct mm_struct *mm,
4552 unsigned long start, unsigned long end)
4553Index: head-2008-12-01/include/asm-x86/mach-xen/asm/fixmap_64.h
4554===================================================================
4555--- head-2008-12-01.orig/include/asm-x86/mach-xen/asm/fixmap_64.h 2008-12-01 11:36:13.000000000 +0100
4556+++ head-2008-12-01/include/asm-x86/mach-xen/asm/fixmap_64.h 2008-12-01 11:36:47.000000000 +0100
4557@@ -23,9 +23,9 @@
4558 * compile time, but to set the physical address only
4559 * in the boot process.
4560 *
4561- * these 'compile-time allocated' memory buffers are
4562- * fixed-size 4k pages. (or larger if used with an increment
4563- * highger than 1) use fixmap_set(idx,phys) to associate
4564+ * These 'compile-time allocated' memory buffers are
4565+ * fixed-size 4k pages (or larger if used with an increment
4566+ * higher than 1). Use set_fixmap(idx,phys) to associate
4567 * physical memory with fixmap indices.
4568 *
4569 * TLB entries of such buffers will not be flushed across
4570@@ -36,6 +36,8 @@ enum fixed_addresses {
4571 VSYSCALL_LAST_PAGE,
4572 VSYSCALL_FIRST_PAGE = VSYSCALL_LAST_PAGE + ((VSYSCALL_END-VSYSCALL_START) >> PAGE_SHIFT) - 1,
4573 VSYSCALL_HPET,
4574+ FIX_DBGP_BASE,
4575+ FIX_EARLYCON_MEM_BASE,
4576 FIX_HPET_BASE,
4577 #ifdef CONFIG_X86_LOCAL_APIC
4578 FIX_APIC_BASE, /* local (CPU) APIC) -- required for SMP or not */
4579@@ -105,7 +107,7 @@ static __always_inline unsigned long fix
4580 if (idx >= __end_of_fixed_addresses)
4581 __this_fixmap_does_not_exist();
4582
4583- return __fix_to_virt(idx);
4584+ return __fix_to_virt(idx);
4585 }
4586
4587 #endif
4588Index: head-2008-12-01/include/asm-x86/mach-xen/asm/io_64.h
4589===================================================================
4590--- head-2008-12-01.orig/include/asm-x86/mach-xen/asm/io_64.h 2008-12-01 11:36:07.000000000 +0100
4591+++ head-2008-12-01/include/asm-x86/mach-xen/asm/io_64.h 2008-12-01 11:36:47.000000000 +0100
4592@@ -162,6 +162,7 @@ extern void bt_iounmap(void *addr, unsig
4593 */
4594 extern void __iomem * ioremap_nocache (unsigned long offset, unsigned long size);
4595 extern void iounmap(volatile void __iomem *addr);
4596+extern void __iomem *fix_ioremap(unsigned idx, unsigned long phys);
4597
4598 /*
4599 * ISA I/O bus memory addresses are 1:1 with the physical address.
4600Index: head-2008-12-01/include/asm-x86/mach-xen/asm/mmu_context_64.h
4601===================================================================
4602--- head-2008-12-01.orig/include/asm-x86/mach-xen/asm/mmu_context_64.h 2008-12-01 11:36:13.000000000 +0100
4603+++ head-2008-12-01/include/asm-x86/mach-xen/asm/mmu_context_64.h 2008-12-01 11:36:47.000000000 +0100
4604@@ -76,7 +76,7 @@ static inline void switch_mm(struct mm_s
4605
4606 if (likely(prev != next)) {
4607 BUG_ON(!xen_feature(XENFEAT_writable_page_tables) &&
4608- !next->context.pinned);
4609+ !PagePinned(virt_to_page(next->pgd)));
4610
4611 /* stop flush ipis for the previous mm */
4612 cpu_clear(cpu, prev->cpu_vm_mask);
4613@@ -131,7 +131,7 @@ static inline void switch_mm(struct mm_s
4614
4615 static inline void activate_mm(struct mm_struct *prev, struct mm_struct *next)
4616 {
4617- if (!next->context.pinned)
4618+ if (!PagePinned(virt_to_page(next->pgd)))
4619 mm_pin(next);
4620 switch_mm(prev, next, NULL);
4621 }
4622Index: head-2008-12-01/include/asm-x86/mach-xen/asm/page_64.h
4623===================================================================
4624--- head-2008-12-01.orig/include/asm-x86/mach-xen/asm/page_64.h 2008-12-01 11:36:13.000000000 +0100
4625+++ head-2008-12-01/include/asm-x86/mach-xen/asm/page_64.h 2008-12-01 11:36:47.000000000 +0100
4626@@ -72,7 +72,8 @@ void copy_page(void *, void *);
4627 #define clear_user_page(page, vaddr, pg) clear_page(page)
4628 #define copy_user_page(to, from, vaddr, pg) copy_page(to, from)
4629
4630-#define alloc_zeroed_user_highpage(vma, vaddr) alloc_page_vma(GFP_HIGHUSER | __GFP_ZERO, vma, vaddr)
4631+#define __alloc_zeroed_user_highpage(movableflags, vma, vaddr) \
4632+ alloc_page_vma(GFP_HIGHUSER | __GFP_ZERO | movableflags, vma, vaddr)
4633 #define __HAVE_ARCH_ALLOC_ZEROED_USER_HIGHPAGE
4634
4635 /*
4636Index: head-2008-12-01/include/asm-x86/mach-xen/asm/pci_64.h
4637===================================================================
4638--- head-2008-12-01.orig/include/asm-x86/mach-xen/asm/pci_64.h 2007-09-14 11:14:51.000000000 +0200
4639+++ head-2008-12-01/include/asm-x86/mach-xen/asm/pci_64.h 2008-12-01 11:36:47.000000000 +0100
4640@@ -5,6 +5,27 @@
4641
4642 #ifdef __KERNEL__
4643
4644+struct pci_sysdata {
4645+ int node; /* NUMA node */
4646+ void* iommu; /* IOMMU private data */
4647+};
4648+
4649+extern struct pci_bus *pci_scan_bus_with_sysdata(int busno);
4650+
4651+#ifdef CONFIG_CALGARY_IOMMU
4652+static inline void* pci_iommu(struct pci_bus *bus)
4653+{
4654+ struct pci_sysdata *sd = bus->sysdata;
4655+ return sd->iommu;
4656+}
4657+
4658+static inline void set_pci_iommu(struct pci_bus *bus, void *val)
4659+{
4660+ struct pci_sysdata *sd = bus->sysdata;
4661+ sd->iommu = val;
4662+}
4663+#endif /* CONFIG_CALGARY_IOMMU */
4664+
4665 #include <linux/mm.h> /* for struct page */
4666
4667 /* Can be used to override the logic in pci_scan_bus for skipping
4668@@ -56,14 +77,6 @@ extern int iommu_setup(char *opt);
4669
4670 #if defined(CONFIG_IOMMU) || defined(CONFIG_CALGARY_IOMMU)
4671
4672-/*
4673- * x86-64 always supports DAC, but sometimes it is useful to force
4674- * devices through the IOMMU to get automatic sg list merging.
4675- * Optional right now.
4676- */
4677-extern int iommu_sac_force;
4678-#define pci_dac_dma_supported(pci_dev, mask) (!iommu_sac_force)
4679-
4680 #define DECLARE_PCI_UNMAP_ADDR(ADDR_NAME) \
4681 dma_addr_t ADDR_NAME;
4682 #define DECLARE_PCI_UNMAP_LEN(LEN_NAME) \
4683@@ -97,8 +110,6 @@ extern int iommu_sac_force;
4684 #else
4685 /* No IOMMU */
4686
4687-#define pci_dac_dma_supported(pci_dev, mask) 1
4688-
4689 #define DECLARE_PCI_UNMAP_ADDR(ADDR_NAME)
4690 #define DECLARE_PCI_UNMAP_LEN(LEN_NAME)
4691 #define pci_unmap_addr(PTR, ADDR_NAME) (0)
4692@@ -110,36 +121,6 @@ extern int iommu_sac_force;
4693
4694 #include <asm-generic/pci-dma-compat.h>
4695
4696-static inline dma64_addr_t
4697-pci_dac_page_to_dma(struct pci_dev *pdev, struct page *page, unsigned long offset, int direction)
4698-{
4699- return ((dma64_addr_t) page_to_phys(page) +
4700- (dma64_addr_t) offset);
4701-}
4702-
4703-static inline struct page *
4704-pci_dac_dma_to_page(struct pci_dev *pdev, dma64_addr_t dma_addr)
4705-{
4706- return virt_to_page(__va(dma_addr));
4707-}
4708-
4709-static inline unsigned long
4710-pci_dac_dma_to_offset(struct pci_dev *pdev, dma64_addr_t dma_addr)
4711-{
4712- return (dma_addr & ~PAGE_MASK);
4713-}
4714-
4715-static inline void
4716-pci_dac_dma_sync_single_for_cpu(struct pci_dev *pdev, dma64_addr_t dma_addr, size_t len, int direction)
4717-{
4718-}
4719-
4720-static inline void
4721-pci_dac_dma_sync_single_for_device(struct pci_dev *pdev, dma64_addr_t dma_addr, size_t len, int direction)
4722-{
4723- flush_write_buffers();
4724-}
4725-
4726 #ifdef CONFIG_PCI
4727 static inline void pci_dma_burst_advice(struct pci_dev *pdev,
4728 enum pci_dma_burst_strategy *strat,
4729@@ -154,10 +135,6 @@ static inline void pci_dma_burst_advice(
4730 extern int pci_mmap_page_range(struct pci_dev *dev, struct vm_area_struct *vma,
4731 enum pci_mmap_state mmap_state, int write_combine);
4732
4733-static inline void pcibios_add_platform_entries(struct pci_dev *dev)
4734-{
4735-}
4736-
4737 #endif /* __KERNEL__ */
4738
4739 /* generic pci stuff */
4740Index: head-2008-12-01/include/asm-x86/mach-xen/asm/pgalloc_64.h
4741===================================================================
4742--- head-2008-12-01.orig/include/asm-x86/mach-xen/asm/pgalloc_64.h 2008-12-01 11:36:13.000000000 +0100
4743+++ head-2008-12-01/include/asm-x86/mach-xen/asm/pgalloc_64.h 2008-12-01 11:36:47.000000000 +0100
4744@@ -21,7 +21,7 @@ static inline void pmd_populate_kernel(s
4745
4746 static inline void pmd_populate(struct mm_struct *mm, pmd_t *pmd, struct page *pte)
4747 {
4748- if (unlikely((mm)->context.pinned)) {
4749+ if (unlikely(PagePinned(virt_to_page((mm)->pgd)))) {
4750 BUG_ON(HYPERVISOR_update_va_mapping(
4751 (unsigned long)__va(page_to_pfn(pte) << PAGE_SHIFT),
4752 pfn_pte(page_to_pfn(pte), PAGE_KERNEL_RO), 0));
4753@@ -33,7 +33,7 @@ static inline void pmd_populate(struct m
4754
4755 static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
4756 {
4757- if (unlikely((mm)->context.pinned)) {
4758+ if (unlikely(PagePinned(virt_to_page((mm)->pgd)))) {
4759 BUG_ON(HYPERVISOR_update_va_mapping(
4760 (unsigned long)pmd,
4761 pfn_pte(virt_to_phys(pmd)>>PAGE_SHIFT,
4762@@ -50,7 +50,7 @@ static inline void pud_populate(struct m
4763 */
4764 static inline void pgd_populate(struct mm_struct *mm, pgd_t *pgd, pud_t *pud)
4765 {
4766- if (unlikely((mm)->context.pinned)) {
4767+ if (unlikely(PagePinned(virt_to_page((mm)->pgd)))) {
4768 BUG_ON(HYPERVISOR_update_va_mapping(
4769 (unsigned long)pud,
4770 pfn_pte(virt_to_phys(pud)>>PAGE_SHIFT,
4771Index: head-2008-12-01/include/asm-x86/mach-xen/asm/pgtable_64.h
4772===================================================================
4773--- head-2008-12-01.orig/include/asm-x86/mach-xen/asm/pgtable_64.h 2008-12-01 11:36:13.000000000 +0100
4774+++ head-2008-12-01/include/asm-x86/mach-xen/asm/pgtable_64.h 2008-12-01 11:36:47.000000000 +0100
4775@@ -302,7 +302,7 @@ static inline pte_t ptep_get_and_clear_f
4776 {
4777 if (full) {
4778 pte_t pte = *ptep;
4779- if (mm->context.pinned)
4780+ if (PagePinned(virt_to_page(mm->pgd)))
4781 xen_l1_entry_update(ptep, __pte(0));
4782 else
4783 *ptep = __pte(0);
4784@@ -331,21 +331,15 @@ static inline pte_t ptep_get_and_clear_f
4785 * Undefined behaviour if not..
4786 */
4787 #define __LARGE_PTE (_PAGE_PSE|_PAGE_PRESENT)
4788-static inline int pte_user(pte_t pte) { return __pte_val(pte) & _PAGE_USER; }
4789-static inline int pte_read(pte_t pte) { return __pte_val(pte) & _PAGE_USER; }
4790-static inline int pte_exec(pte_t pte) { return !(__pte_val(pte) & _PAGE_NX); }
4791 static inline int pte_dirty(pte_t pte) { return __pte_val(pte) & _PAGE_DIRTY; }
4792 static inline int pte_young(pte_t pte) { return __pte_val(pte) & _PAGE_ACCESSED; }
4793 static inline int pte_write(pte_t pte) { return __pte_val(pte) & _PAGE_RW; }
4794 static inline int pte_file(pte_t pte) { return __pte_val(pte) & _PAGE_FILE; }
4795 static inline int pte_huge(pte_t pte) { return __pte_val(pte) & _PAGE_PSE; }
4796
4797-static inline pte_t pte_rdprotect(pte_t pte) { __pte_val(pte) &= ~_PAGE_USER; return pte; }
4798-static inline pte_t pte_exprotect(pte_t pte) { __pte_val(pte) &= ~_PAGE_USER; return pte; }
4799 static inline pte_t pte_mkclean(pte_t pte) { __pte_val(pte) &= ~_PAGE_DIRTY; return pte; }
4800 static inline pte_t pte_mkold(pte_t pte) { __pte_val(pte) &= ~_PAGE_ACCESSED; return pte; }
4801 static inline pte_t pte_wrprotect(pte_t pte) { __pte_val(pte) &= ~_PAGE_RW; return pte; }
4802-static inline pte_t pte_mkread(pte_t pte) { __pte_val(pte) |= _PAGE_USER; return pte; }
4803 static inline pte_t pte_mkexec(pte_t pte) { __pte_val(pte) &= ~_PAGE_NX; return pte; }
4804 static inline pte_t pte_mkdirty(pte_t pte) { __pte_val(pte) |= _PAGE_DIRTY; return pte; }
4805 static inline pte_t pte_mkyoung(pte_t pte) { __pte_val(pte) |= _PAGE_ACCESSED; return pte; }
4806@@ -353,13 +347,6 @@ static inline pte_t pte_mkwrite(pte_t pt
4807 static inline pte_t pte_mkhuge(pte_t pte) { __pte_val(pte) |= _PAGE_PSE; return pte; }
4808 static inline pte_t pte_clrhuge(pte_t pte) { __pte_val(pte) &= ~_PAGE_PSE; return pte; }
4809
4810-static inline int ptep_test_and_clear_dirty(struct vm_area_struct *vma, unsigned long addr, pte_t *ptep)
4811-{
4812- if (!pte_dirty(*ptep))
4813- return 0;
4814- return test_and_clear_bit(_PAGE_BIT_DIRTY, &ptep->pte);
4815-}
4816-
4817 static inline int ptep_test_and_clear_young(struct vm_area_struct *vma, unsigned long addr, pte_t *ptep)
4818 {
4819 if (!pte_young(*ptep))
4820@@ -498,26 +485,13 @@ static inline pte_t pte_modify(pte_t pte
4821 __changed; \
4822 })
4823
4824-#define __HAVE_ARCH_PTEP_CLEAR_DIRTY_FLUSH
4825-#define ptep_clear_flush_dirty(vma, address, ptep) \
4826-({ \
4827- pte_t __pte = *(ptep); \
4828- int __dirty = pte_dirty(__pte); \
4829- __pte = pte_mkclean(__pte); \
4830- if ((vma)->vm_mm->context.pinned) \
4831- (void)ptep_set_access_flags(vma, address, ptep, __pte, __dirty); \
4832- else if (__dirty) \
4833- set_pte(ptep, __pte); \
4834- __dirty; \
4835-})
4836-
4837 #define __HAVE_ARCH_PTEP_CLEAR_YOUNG_FLUSH
4838 #define ptep_clear_flush_young(vma, address, ptep) \
4839 ({ \
4840 pte_t __pte = *(ptep); \
4841 int __young = pte_young(__pte); \
4842 __pte = pte_mkold(__pte); \
4843- if ((vma)->vm_mm->context.pinned) \
4844+ if (PagePinned(virt_to_page((vma)->vm_mm->pgd))) \
4845 (void)ptep_set_access_flags(vma, address, ptep, __pte, __young); \
4846 else if (__young) \
4847 set_pte(ptep, __pte); \
4848@@ -568,6 +542,8 @@ int xen_change_pte_range(struct mm_struc
4849 #define arch_change_pte_range(mm, pmd, addr, end, newprot, dirty_accountable) \
4850 xen_change_pte_range(mm, pmd, addr, end, newprot, dirty_accountable)
4851
4852+pte_t *lookup_address(unsigned long addr);
4853+
4854 #define io_remap_pfn_range(vma, vaddr, pfn, size, prot) \
4855 direct_remap_pfn_range(vma,vaddr,pfn,size,prot,DOMID_IO)
4856
4857@@ -585,7 +561,6 @@ int xen_change_pte_range(struct mm_struc
4858 (((o) & (1UL << (__VIRTUAL_MASK_SHIFT-1))) ? ((o) | (~__VIRTUAL_MASK)) : (o))
4859
4860 #define __HAVE_ARCH_PTEP_TEST_AND_CLEAR_YOUNG
4861-#define __HAVE_ARCH_PTEP_TEST_AND_CLEAR_DIRTY
4862 #define __HAVE_ARCH_PTEP_GET_AND_CLEAR
4863 #define __HAVE_ARCH_PTEP_GET_AND_CLEAR_FULL
4864 #define __HAVE_ARCH_PTEP_CLEAR_FLUSH
4865Index: head-2008-12-01/include/asm-x86/mach-xen/asm/processor_64.h
4866===================================================================
4867--- head-2008-12-01.orig/include/asm-x86/mach-xen/asm/processor_64.h 2008-12-01 11:36:13.000000000 +0100
4868+++ head-2008-12-01/include/asm-x86/mach-xen/asm/processor_64.h 2008-12-01 11:36:47.000000000 +0100
4869@@ -83,7 +83,6 @@ struct cpuinfo_x86 {
4870 #define X86_VENDOR_UMC 3
4871 #define X86_VENDOR_NEXGEN 4
4872 #define X86_VENDOR_CENTAUR 5
4873-#define X86_VENDOR_RISE 6
4874 #define X86_VENDOR_TRANSMETA 7
4875 #define X86_VENDOR_NUM 8
4876 #define X86_VENDOR_UNKNOWN 0xff
4877@@ -100,6 +99,7 @@ extern char ignore_irq13;
4878
4879 extern void identify_cpu(struct cpuinfo_x86 *);
4880 extern void print_cpu_info(struct cpuinfo_x86 *);
4881+extern void init_scattered_cpuid_features(struct cpuinfo_x86 *c);
4882 extern unsigned int init_intel_cacheinfo(struct cpuinfo_x86 *c);
4883 extern unsigned short num_cache_leaves;
4884
4885@@ -377,12 +377,10 @@ static inline void sync_core(void)
4886 asm volatile("cpuid" : "=a" (tmp) : "0" (1) : "ebx","ecx","edx","memory");
4887 }
4888
4889-#define cpu_has_fpu 1
4890-
4891 #define ARCH_HAS_PREFETCH
4892 static inline void prefetch(void *x)
4893 {
4894- asm volatile("prefetcht0 %0" :: "m" (*(unsigned long *)x));
4895+ asm volatile("prefetcht0 (%0)" :: "r" (x));
4896 }
4897
4898 #define ARCH_HAS_PREFETCHW 1
4899@@ -400,17 +398,6 @@ static inline void prefetchw(void *x)
4900
4901 #define cpu_relax() rep_nop()
4902
4903-/*
4904- * NSC/Cyrix CPU indexed register access macros
4905- */
4906-
4907-#define getCx86(reg) ({ outb((reg), 0x22); inb(0x23); })
4908-
4909-#define setCx86(reg, data) do { \
4910- outb((reg), 0x22); \
4911- outb((data), 0x23); \
4912-} while (0)
4913-
4914 static inline void serialize_cpu(void)
4915 {
4916 __asm__ __volatile__ ("cpuid" : : : "ax", "bx", "cx", "dx");
4917Index: head-2008-12-01/include/asm-x86/mach-xen/asm/system_64.h
4918===================================================================
4919--- head-2008-12-01.orig/include/asm-x86/mach-xen/asm/system_64.h 2008-12-01 11:36:13.000000000 +0100
4920+++ head-2008-12-01/include/asm-x86/mach-xen/asm/system_64.h 2008-12-01 11:36:47.000000000 +0100
4921@@ -79,12 +79,16 @@ static inline unsigned long read_cr0(voi
4922 unsigned long cr0;
4923 asm volatile("movq %%cr0,%0" : "=r" (cr0));
4924 return cr0;
4925-}
4926+}
4927
4928 static inline void write_cr0(unsigned long val)
4929 {
4930 asm volatile("movq %0,%%cr0" :: "r" (val));
4931-}
4932+}
4933+
4934+#define read_cr2() current_vcpu_info()->arch.cr2
4935+
4936+#define write_cr2(val) ((void)(current_vcpu_info()->arch.cr2 = (val)))
4937
4938 #define read_cr3() ({ \
4939 unsigned long __dummy; \
4940@@ -103,27 +107,28 @@ static inline unsigned long read_cr4(voi
4941 unsigned long cr4;
4942 asm("movq %%cr4,%0" : "=r" (cr4));
4943 return cr4;
4944-}
4945+}
4946
4947 static inline void write_cr4(unsigned long val)
4948 {
4949 asm volatile("movq %0,%%cr4" :: "r" (val) : "memory");
4950-}
4951-
4952-#define stts() (HYPERVISOR_fpu_taskswitch(1))
4953+}
4954
4955-#define wbinvd() \
4956- __asm__ __volatile__ ("wbinvd": : :"memory");
4957+static inline unsigned long read_cr8(void)
4958+{
4959+ return 0;
4960+}
4961
4962-/*
4963- * On SMP systems, when the scheduler does migration-cost autodetection,
4964- * it needs a way to flush as much of the CPU's caches as possible.
4965- */
4966-static inline void sched_cacheflush(void)
4967+static inline void write_cr8(unsigned long val)
4968 {
4969- wbinvd();
4970+ BUG_ON(val);
4971 }
4972
4973+#define stts() (HYPERVISOR_fpu_taskswitch(1))
4974+
4975+#define wbinvd() \
4976+ __asm__ __volatile__ ("wbinvd": : :"memory")
4977+
4978 #endif /* __KERNEL__ */
4979
4980 #define nop() __asm__ __volatile__ ("nop")
4981Index: head-2008-12-01/include/asm-x86/mach-xen/asm/tlbflush_64.h
4982===================================================================
4983--- head-2008-12-01.orig/include/asm-x86/mach-xen/asm/tlbflush_64.h 2008-12-01 11:36:13.000000000 +0100
4984+++ head-2008-12-01/include/asm-x86/mach-xen/asm/tlbflush_64.h 2008-12-01 11:36:47.000000000 +0100
4985@@ -89,7 +89,11 @@ static inline void flush_tlb_range(struc
4986
4987 #endif
4988
4989-#define flush_tlb_kernel_range(start, end) flush_tlb_all()
4990+static inline void flush_tlb_kernel_range(unsigned long start,
4991+ unsigned long end)
4992+{
4993+ flush_tlb_all();
4994+}
4995
4996 static inline void flush_tlb_pgtables(struct mm_struct *mm,
4997 unsigned long start, unsigned long end)
4998Index: head-2008-12-01/include/asm-x86/thread_info.h
4999===================================================================
5000--- head-2008-12-01.orig/include/asm-x86/thread_info.h 2008-12-01 11:28:55.000000000 +0100
5001+++ head-2008-12-01/include/asm-x86/thread_info.h 2008-12-01 11:36:47.000000000 +0100
5002@@ -150,7 +150,8 @@ struct thread_info {
5003 #define _TIF_WORK_CTXSW_PREV _TIF_WORK_CTXSW
5004 #define _TIF_WORK_CTXSW_NEXT (_TIF_WORK_CTXSW|_TIF_DEBUG)
5005 #else
5006-#define _TIF_WORK_CTXSW _TIF_DEBUG
5007+#define _TIF_WORK_CTXSW_NEXT (_TIF_NOTSC | _TIF_DEBUG)
5008+#define _TIF_WORK_CTXSW_PREV (_TIF_NOTSC)
5009 #endif
5010
5011 #define PREEMPT_ACTIVE 0x10000000
5012Index: head-2008-12-01/include/asm-x86/xen/interface.h
5013===================================================================
5014--- head-2008-12-01.orig/include/asm-x86/xen/interface.h 2008-12-01 10:53:14.000000000 +0100
5015+++ head-2008-12-01/include/asm-x86/xen/interface.h 2008-12-01 11:36:47.000000000 +0100
5016@@ -10,17 +10,17 @@
5017 #define __ASM_X86_XEN_INTERFACE_H
5018
5019 #ifdef __XEN__
5020-#define __DEFINE_GUEST_HANDLE(name, type) \
5021+#define __DEFINE_XEN_GUEST_HANDLE(name, type) \
5022 typedef struct { type *p; } __guest_handle_ ## name
5023 #else
5024-#define __DEFINE_GUEST_HANDLE(name, type) \
5025+#define __DEFINE_XEN_GUEST_HANDLE(name, type) \
5026 typedef type * __guest_handle_ ## name
5027 #endif
5028
5029-#define DEFINE_GUEST_HANDLE_STRUCT(name) \
5030- __DEFINE_GUEST_HANDLE(name, struct name)
5031-#define DEFINE_GUEST_HANDLE(name) __DEFINE_GUEST_HANDLE(name, name)
5032-#define GUEST_HANDLE(name) __guest_handle_ ## name
5033+#define DEFINE_XEN_GUEST_HANDLE_STRUCT(name) \
5034+ __DEFINE_XEN_GUEST_HANDLE(name, struct name)
5035+#define DEFINE_XEN_GUEST_HANDLE(name) __DEFINE_XEN_GUEST_HANDLE(name, name)
5036+#define XEN_GUEST_HANDLE(name) __guest_handle_ ## name
5037
5038 #ifdef __XEN__
5039 #if defined(__i386__)
5040@@ -47,14 +47,8 @@
5041 #endif
5042
5043 #ifndef __ASSEMBLY__
5044-/* Guest handles for primitive C types. */
5045-__DEFINE_GUEST_HANDLE(uchar, unsigned char);
5046-__DEFINE_GUEST_HANDLE(uint, unsigned int);
5047-__DEFINE_GUEST_HANDLE(ulong, unsigned long);
5048-DEFINE_GUEST_HANDLE(char);
5049-DEFINE_GUEST_HANDLE(int);
5050-DEFINE_GUEST_HANDLE(long);
5051-DEFINE_GUEST_HANDLE(void);
5052+typedef unsigned long xen_pfn_t;
5053+typedef unsigned long xen_ulong_t;
5054 #endif
5055
5056 #ifndef HYPERVISOR_VIRT_START
5057@@ -103,7 +97,7 @@ struct trap_info {
5058 uint16_t cs; /* code selector */
5059 unsigned long address; /* code offset */
5060 };
5061-DEFINE_GUEST_HANDLE_STRUCT(trap_info);
5062+DEFINE_XEN_GUEST_HANDLE_STRUCT(trap_info);
5063
5064 struct arch_shared_info {
5065 unsigned long max_pfn; /* max pfn that appears in table */
5066@@ -157,7 +151,7 @@ struct vcpu_guest_context {
5067 uint64_t gs_base_user;
5068 #endif
5069 };
5070-DEFINE_GUEST_HANDLE_STRUCT(vcpu_guest_context);
5071+DEFINE_XEN_GUEST_HANDLE_STRUCT(vcpu_guest_context);
5072 #endif /* !__ASSEMBLY__ */
5073
5074 /*
5075Index: head-2008-12-01/include/asm-x86/xen/interface_32.h
5076===================================================================
5077--- head-2008-12-01.orig/include/asm-x86/xen/interface_32.h 2008-12-01 10:53:14.000000000 +0100
5078+++ head-2008-12-01/include/asm-x86/xen/interface_32.h 2008-12-01 11:36:47.000000000 +0100
5079@@ -62,7 +62,7 @@ struct cpu_user_regs {
5080 uint16_t fs, _pad4;
5081 uint16_t gs, _pad5;
5082 };
5083-DEFINE_GUEST_HANDLE_STRUCT(cpu_user_regs);
5084+DEFINE_XEN_GUEST_HANDLE_STRUCT(cpu_user_regs);
5085
5086 typedef uint64_t tsc_timestamp_t; /* RDTSC timestamp */
5087
5088Index: head-2008-12-01/include/linux/elfnote.h
5089===================================================================
5090--- head-2008-12-01.orig/include/linux/elfnote.h 2008-12-01 10:53:14.000000000 +0100
5091+++ head-2008-12-01/include/linux/elfnote.h 2008-12-01 11:36:47.000000000 +0100
5092@@ -52,7 +52,7 @@
5093 4484:.balign 4 ; \
5094 .popsection ;
5095
5096-#define ELFNOTE(name, type, desc) \
5097+#define ELFNOTE(name, type, desc...) \
5098 ELFNOTE_START(name, type, "") \
5099 desc ; \
5100 ELFNOTE_END
5101Index: head-2008-12-01/include/linux/page-flags.h
5102===================================================================
5103--- head-2008-12-01.orig/include/linux/page-flags.h 2008-12-01 11:25:57.000000000 +0100
5104+++ head-2008-12-01/include/linux/page-flags.h 2008-12-01 11:36:47.000000000 +0100
5105@@ -99,6 +99,10 @@ enum pageflags {
5106 #endif
5107 #ifdef CONFIG_XEN
5108 PG_foreign, /* Page is owned by foreign allocator. */
5109+ PG_pinned, /* Cannot alias with PG_owner_priv_1 since
5110+ * bad_page() checks include this bit.
5111+ * Also cannot use PG_arch_1 since that now
5112+ * has a different purpose on x86. */
5113 #endif
5114 __NR_PAGEFLAGS,
5115
5116Index: head-2008-12-01/include/linux/skbuff.h
5117===================================================================
5118--- head-2008-12-01.orig/include/linux/skbuff.h 2008-12-01 11:29:05.000000000 +0100
5119+++ head-2008-12-01/include/linux/skbuff.h 2008-12-01 11:36:47.000000000 +0100
5120@@ -1772,7 +1772,7 @@ static inline void skb_forward_csum(stru
5121
5122 bool skb_partial_csum_set(struct sk_buff *skb, u16 start, u16 off);
5123
5124-#ifdef CONFIG_XEN
5125+#if defined(CONFIG_XEN) || defined(CONFIG_PARAVIRT_XEN)
5126 int skb_checksum_setup(struct sk_buff *skb);
5127 #else
5128 static inline int skb_checksum_setup(struct sk_buff *skb) { return 0; }
5129Index: head-2008-12-01/include/xen/driver_util.h
5130===================================================================
5131--- head-2008-12-01.orig/include/xen/driver_util.h 2007-06-12 13:14:19.000000000 +0200
5132+++ head-2008-12-01/include/xen/driver_util.h 2008-12-01 11:36:47.000000000 +0100
5133@@ -5,10 +5,6 @@
5134 #include <linux/vmalloc.h>
5135 #include <linux/device.h>
5136
5137-/* Allocate/destroy a 'vmalloc' VM area. */
5138-extern struct vm_struct *alloc_vm_area(unsigned long size);
5139-extern void free_vm_area(struct vm_struct *area);
5140-
5141 extern struct class *get_xen_class(void);
5142
5143 #endif /* __ASM_XEN_DRIVER_UTIL_H__ */
5144Index: head-2008-12-01/include/xen/features.h
5145===================================================================
5146--- head-2008-12-01.orig/include/xen/features.h 2008-12-01 10:53:14.000000000 +0100
5147+++ head-2008-12-01/include/xen/features.h 2008-12-01 11:36:47.000000000 +0100
5148@@ -10,6 +10,7 @@
5149 #define __XEN_FEATURES_H__
5150
5151 #include <xen/interface/features.h>
5152+#include <xen/interface/version.h>
5153
5154 void xen_setup_features(void);
5155
5156@@ -20,4 +21,4 @@ static inline int xen_feature(int flag)
5157 return xen_features[flag];
5158 }
5159
5160-#endif /* __ASM_XEN_FEATURES_H__ */
5161+#endif /* __XEN_FEATURES_H__ */
5162Index: head-2008-12-01/include/xen/interface/arch-x86/xen.h
5163===================================================================
5164--- head-2008-12-01.orig/include/xen/interface/arch-x86/xen.h 2008-09-01 12:07:31.000000000 +0200
5165+++ head-2008-12-01/include/xen/interface/arch-x86/xen.h 2008-12-01 11:36:47.000000000 +0100
5166@@ -49,6 +49,9 @@
5167 #define get_xen_guest_handle(val, hnd) do { val = (hnd).p; } while (0)
5168 #endif
5169
5170+/* Allow co-existing Linux 2.6.23+ Xen interface definitions. */
5171+#define DEFINE_XEN_GUEST_HANDLE_STRUCT(name) struct name
5172+
5173 #if defined(__i386__)
5174 #include "xen-x86_32.h"
5175 #elif defined(__x86_64__)
5176Index: head-2008-12-01/include/xen/interface/event_channel.h
5177===================================================================
5178--- head-2008-12-01.orig/include/xen/interface/event_channel.h 2008-12-01 11:22:58.000000000 +0100
5179+++ head-2008-12-01/include/xen/interface/event_channel.h 2008-12-01 11:36:47.000000000 +0100
5180@@ -248,6 +248,7 @@ struct evtchn_op {
5181 struct evtchn_unmask unmask;
5182 } u;
5183 };
5184+DEFINE_XEN_GUEST_HANDLE_STRUCT(evtchn_op);
5185 typedef struct evtchn_op evtchn_op_t;
5186 DEFINE_XEN_GUEST_HANDLE(evtchn_op_t);
5187
5188Index: head-2008-12-01/include/xen/interface/io/netif.h
5189===================================================================
5190--- head-2008-12-01.orig/include/xen/interface/io/netif.h 2008-12-01 11:22:58.000000000 +0100
5191+++ head-2008-12-01/include/xen/interface/io/netif.h 2008-12-01 11:36:47.000000000 +0100
5192@@ -183,8 +183,22 @@ typedef struct netif_rx_response netif_r
5193 * Generate netif ring structures and types.
5194 */
5195
5196+#if defined(CONFIG_XEN) || defined(HAVE_XEN_PLATFORM_COMPAT_H)
5197 DEFINE_RING_TYPES(netif_tx, struct netif_tx_request, struct netif_tx_response);
5198 DEFINE_RING_TYPES(netif_rx, struct netif_rx_request, struct netif_rx_response);
5199+#else
5200+#define xen_netif_tx_request netif_tx_request
5201+#define xen_netif_rx_request netif_rx_request
5202+#define xen_netif_tx_response netif_tx_response
5203+#define xen_netif_rx_response netif_rx_response
5204+DEFINE_RING_TYPES(xen_netif_tx,
5205+ struct xen_netif_tx_request,
5206+ struct xen_netif_tx_response);
5207+DEFINE_RING_TYPES(xen_netif_rx,
5208+ struct xen_netif_rx_request,
5209+ struct xen_netif_rx_response);
5210+#define xen_netif_extra_info netif_extra_info
5211+#endif
5212
5213 #define NETIF_RSP_DROPPED -2
5214 #define NETIF_RSP_ERROR -1
5215Index: head-2008-12-01/include/xen/interface/memory.h
5216===================================================================
5217--- head-2008-12-01.orig/include/xen/interface/memory.h 2008-12-01 11:22:59.000000000 +0100
5218+++ head-2008-12-01/include/xen/interface/memory.h 2008-12-01 11:36:47.000000000 +0100
5219@@ -82,6 +82,7 @@ struct xen_memory_reservation {
5220 domid_t domid;
5221
5222 };
5223+DEFINE_XEN_GUEST_HANDLE_STRUCT(xen_memory_reservation);
5224 typedef struct xen_memory_reservation xen_memory_reservation_t;
5225 DEFINE_XEN_GUEST_HANDLE(xen_memory_reservation_t);
5226
5227@@ -175,6 +176,7 @@ struct xen_machphys_mfn_list {
5228 */
5229 unsigned int nr_extents;
5230 };
5231+DEFINE_XEN_GUEST_HANDLE_STRUCT(xen_machphys_mfn_list);
5232 typedef struct xen_machphys_mfn_list xen_machphys_mfn_list_t;
5233 DEFINE_XEN_GUEST_HANDLE(xen_machphys_mfn_list_t);
5234
5235@@ -214,6 +216,7 @@ struct xen_add_to_physmap {
5236 /* GPFN where the source mapping page should appear. */
5237 xen_pfn_t gpfn;
5238 };
5239+DEFINE_XEN_GUEST_HANDLE_STRUCT(xen_add_to_physmap);
5240 typedef struct xen_add_to_physmap xen_add_to_physmap_t;
5241 DEFINE_XEN_GUEST_HANDLE(xen_add_to_physmap_t);
5242
5243@@ -254,6 +257,7 @@ struct xen_translate_gpfn_list {
5244 */
5245 XEN_GUEST_HANDLE(xen_pfn_t) mfn_list;
5246 };
5247+DEFINE_XEN_GUEST_HANDLE_STRUCT(xen_translate_gpfn_list);
5248 typedef struct xen_translate_gpfn_list xen_translate_gpfn_list_t;
5249 DEFINE_XEN_GUEST_HANDLE(xen_translate_gpfn_list_t);
5250
5251Index: head-2008-12-01/include/xen/interface/sched.h
5252===================================================================
5253--- head-2008-12-01.orig/include/xen/interface/sched.h 2008-12-01 11:22:59.000000000 +0100
5254+++ head-2008-12-01/include/xen/interface/sched.h 2008-12-01 11:36:47.000000000 +0100
5255@@ -67,6 +67,7 @@
5256 struct sched_shutdown {
5257 unsigned int reason; /* SHUTDOWN_* */
5258 };
5259+DEFINE_XEN_GUEST_HANDLE_STRUCT(sched_shutdown);
5260 typedef struct sched_shutdown sched_shutdown_t;
5261 DEFINE_XEN_GUEST_HANDLE(sched_shutdown_t);
5262
5263@@ -81,6 +82,7 @@ struct sched_poll {
5264 unsigned int nr_ports;
5265 uint64_t timeout;
5266 };
5267+DEFINE_XEN_GUEST_HANDLE_STRUCT(sched_poll);
5268 typedef struct sched_poll sched_poll_t;
5269 DEFINE_XEN_GUEST_HANDLE(sched_poll_t);
5270
5271Index: head-2008-12-01/include/xen/interface/version.h
5272===================================================================
5273--- head-2008-12-01.orig/include/xen/interface/version.h 2008-12-01 11:22:59.000000000 +0100
5274+++ head-2008-12-01/include/xen/interface/version.h 2008-12-01 11:36:47.000000000 +0100
5275@@ -36,6 +36,9 @@
5276 /* arg == xen_extraversion_t. */
5277 #define XENVER_extraversion 1
5278 typedef char xen_extraversion_t[16];
5279+struct xen_extraversion {
5280+ xen_extraversion_t extraversion;
5281+};
5282 #define XEN_EXTRAVERSION_LEN (sizeof(xen_extraversion_t))
5283
5284 /* arg == xen_compile_info_t. */
5285@@ -50,10 +53,16 @@ typedef struct xen_compile_info xen_comp
5286
5287 #define XENVER_capabilities 3
5288 typedef char xen_capabilities_info_t[1024];
5289+struct xen_capabilities_info {
5290+ xen_capabilities_info_t info;
5291+};
5292 #define XEN_CAPABILITIES_INFO_LEN (sizeof(xen_capabilities_info_t))
5293
5294 #define XENVER_changeset 4
5295 typedef char xen_changeset_info_t[64];
5296+struct xen_changeset_info {
5297+ xen_changeset_info_t info;
5298+};
5299 #define XEN_CHANGESET_INFO_LEN (sizeof(xen_changeset_info_t))
5300
5301 #define XENVER_platform_parameters 5
5302Index: head-2008-12-01/include/xen/interface/xen.h
5303===================================================================
5304--- head-2008-12-01.orig/include/xen/interface/xen.h 2008-12-01 11:22:59.000000000 +0100
5305+++ head-2008-12-01/include/xen/interface/xen.h 2008-12-01 11:36:47.000000000 +0100
5306@@ -32,7 +32,9 @@
5307 #include <asm/pvclock-abi.h>
5308 #endif
5309
5310-#if defined(__i386__) || defined(__x86_64__)
5311+#if defined(CONFIG_PARAVIRT_XEN) && !defined(HAVE_XEN_PLATFORM_COMPAT_H)
5312+#include <asm/xen/interface.h>
5313+#elif defined(__i386__) || defined(__x86_64__)
5314 #include "arch-x86/xen.h"
5315 #elif defined(__ia64__)
5316 #include "arch-ia64.h"
5317@@ -110,7 +112,7 @@ DEFINE_XEN_GUEST_HANDLE(xen_pfn_t);
5318 */
5319
5320 /* New sched_op hypercall introduced in 0x00030101. */
5321-#if __XEN_INTERFACE_VERSION__ < 0x00030101
5322+#if __XEN_INTERFACE_VERSION__ < 0x00030101 || (defined(CONFIG_PARAVIRT_XEN) && !defined(HAVE_XEN_PLATFORM_COMPAT_H))
5323 #undef __HYPERVISOR_sched_op
5324 #define __HYPERVISOR_sched_op __HYPERVISOR_sched_op_compat
5325 #endif
5326@@ -124,7 +126,7 @@ DEFINE_XEN_GUEST_HANDLE(xen_pfn_t);
5327 #endif
5328
5329 /* New platform_op hypercall introduced in 0x00030204. */
5330-#if __XEN_INTERFACE_VERSION__ < 0x00030204
5331+#if __XEN_INTERFACE_VERSION__ < 0x00030204 || (defined(CONFIG_PARAVIRT_XEN) && !defined(HAVE_XEN_PLATFORM_COMPAT_H))
5332 #define __HYPERVISOR_dom0_op __HYPERVISOR_platform_op
5333 #endif
5334
5335@@ -283,6 +285,7 @@ struct mmuext_op {
5336 xen_pfn_t src_mfn;
5337 } arg2;
5338 };
5339+DEFINE_XEN_GUEST_HANDLE_STRUCT(mmuext_op);
5340 typedef struct mmuext_op mmuext_op_t;
5341 DEFINE_XEN_GUEST_HANDLE(mmuext_op_t);
5342 #endif
5343@@ -365,6 +368,7 @@ struct mmu_update {
5344 uint64_t ptr; /* Machine address of PTE. */
5345 uint64_t val; /* New contents of PTE. */
5346 };
5347+DEFINE_XEN_GUEST_HANDLE_STRUCT(mmu_update);
5348 typedef struct mmu_update mmu_update_t;
5349 DEFINE_XEN_GUEST_HANDLE(mmu_update_t);
5350
5351@@ -373,9 +377,15 @@ DEFINE_XEN_GUEST_HANDLE(mmu_update_t);
5352 * NB. The fields are natural register size for this architecture.
5353 */
5354 struct multicall_entry {
5355- unsigned long op, result;
5356+ unsigned long op;
5357+#if !defined(CONFIG_PARAVIRT_XEN) || defined(HAVE_XEN_PLATFORM_COMPAT_H)
5358+ unsigned long result;
5359+#else
5360+ long result;
5361+#endif
5362 unsigned long args[6];
5363 };
5364+DEFINE_XEN_GUEST_HANDLE_STRUCT(multicall_entry);
5365 typedef struct multicall_entry multicall_entry_t;
5366 DEFINE_XEN_GUEST_HANDLE(multicall_entry_t);
5367
5368Index: head-2008-12-01/include/xen/xenbus.h
5369===================================================================
5370--- head-2008-12-01.orig/include/xen/xenbus.h 2008-12-01 11:36:07.000000000 +0100
5371+++ head-2008-12-01/include/xen/xenbus.h 2008-12-01 11:36:47.000000000 +0100
5372@@ -57,16 +57,20 @@ struct xenbus_watch
5373 void (*callback)(struct xenbus_watch *,
5374 const char **vec, unsigned int len);
5375
5376+#if defined(CONFIG_XEN) || defined(HAVE_XEN_PLATFORM_COMPAT_H)
5377 /* See XBWF_ definitions below. */
5378 unsigned long flags;
5379+#endif
5380 };
5381
5382+#if defined(CONFIG_XEN) || defined(HAVE_XEN_PLATFORM_COMPAT_H)
5383 /*
5384 * Execute callback in its own kthread. Useful if the callback is long
5385 * running or heavily serialised, to avoid taking out the main xenwatch thread
5386 * for a long period of time (or even unwittingly causing a deadlock).
5387 */
5388 #define XBWF_new_thread 1
5389+#endif
5390
5391 /* A xenbus device. */
5392 struct xenbus_device {
5393@@ -214,6 +218,7 @@ int xenbus_watch_path(struct xenbus_devi
5394 const char **, unsigned int));
5395
5396
5397+#if defined(CONFIG_XEN) || defined(HAVE_XEN_PLATFORM_COMPAT_H)
5398 /**
5399 * Register a watch on the given path/path2, using the given xenbus_watch
5400 * structure for storage, and the given callback function as the callback.
5401@@ -227,7 +232,13 @@ int xenbus_watch_path2(struct xenbus_dev
5402 const char *path2, struct xenbus_watch *watch,
5403 void (*callback)(struct xenbus_watch *,
5404 const char **, unsigned int));
5405-
5406+#else
5407+int xenbus_watch_pathfmt(struct xenbus_device *dev, struct xenbus_watch *watch,
5408+ void (*callback)(struct xenbus_watch *,
5409+ const char **, unsigned int),
5410+ const char *pathfmt, ...)
5411+ __attribute__ ((format (printf, 4, 5)));
5412+#endif
5413
5414 /**
5415 * Advertise in the store a change of the given driver to the given new_state.
5416Index: head-2008-12-01/net/core/dev.c
5417===================================================================
5418--- head-2008-12-01.orig/net/core/dev.c 2008-12-01 11:36:13.000000000 +0100
5419+++ head-2008-12-01/net/core/dev.c 2008-12-01 11:36:47.000000000 +0100
5420@@ -131,7 +131,7 @@
5421
5422 #include "net-sysfs.h"
5423
5424-#ifdef CONFIG_XEN
5425+#if defined(CONFIG_XEN) || defined(CONFIG_PARAVIRT_XEN)
5426 #include <net/ip.h>
5427 #include <linux/tcp.h>
5428 #include <linux/udp.h>
5429@@ -1740,42 +1740,54 @@ static struct netdev_queue *dev_pick_tx(
5430 return netdev_get_tx_queue(dev, queue_index);
5431 }
5432
5433-#ifdef CONFIG_XEN
5434+#if defined(CONFIG_XEN) || defined(CONFIG_PARAVIRT_XEN)
5435 inline int skb_checksum_setup(struct sk_buff *skb)
5436 {
5437- if (skb->proto_csum_blank) {
5438- struct iphdr *iph;
5439- unsigned char *th;
5440+ struct iphdr *iph;
5441+ unsigned char *th;
5442+ int err = -EPROTO;
5443
5444- if (skb->protocol != htons(ETH_P_IP))
5445- goto out;
5446- iph = ip_hdr(skb);
5447- th = skb_network_header(skb) + 4 * iph->ihl;
5448- if (th >= skb_tail_pointer(skb))
5449- goto out;
5450- skb->csum_start = th - skb->head;
5451- switch (iph->protocol) {
5452- case IPPROTO_TCP:
5453- skb->csum_offset = offsetof(struct tcphdr, check);
5454- break;
5455- case IPPROTO_UDP:
5456- skb->csum_offset = offsetof(struct udphdr, check);
5457- break;
5458- default:
5459- if (net_ratelimit())
5460- printk(KERN_ERR "Attempting to checksum a non-"
5461- "TCP/UDP packet, dropping a protocol"
5462- " %d packet", iph->protocol);
5463- goto out;
5464- }
5465- if ((th + skb->csum_offset + 2) > skb_tail_pointer(skb))
5466- goto out;
5467- skb->ip_summed = CHECKSUM_PARTIAL;
5468- skb->proto_csum_blank = 0;
5469+#ifdef CONFIG_XEN
5470+ if (!skb->proto_csum_blank)
5471+ return 0;
5472+#endif
5473+
5474+ if (skb->protocol != htons(ETH_P_IP))
5475+ goto out;
5476+
5477+ iph = ip_hdr(skb);
5478+ th = skb_network_header(skb) + 4 * iph->ihl;
5479+ if (th >= skb_tail_pointer(skb))
5480+ goto out;
5481+
5482+ skb->csum_start = th - skb->head;
5483+ switch (iph->protocol) {
5484+ case IPPROTO_TCP:
5485+ skb->csum_offset = offsetof(struct tcphdr, check);
5486+ break;
5487+ case IPPROTO_UDP:
5488+ skb->csum_offset = offsetof(struct udphdr, check);
5489+ break;
5490+ default:
5491+ if (net_ratelimit())
5492+ printk(KERN_ERR "Attempting to checksum a non-"
5493+ "TCP/UDP packet, dropping a protocol"
5494+ " %d packet", iph->protocol);
5495+ goto out;
5496 }
5497- return 0;
5498+
5499+ if ((th + skb->csum_offset + 2) > skb_tail_pointer(skb))
5500+ goto out;
5501+
5502+#ifdef CONFIG_XEN
5503+ skb->ip_summed = CHECKSUM_PARTIAL;
5504+ skb->proto_csum_blank = 0;
5505+#endif
5506+
5507+ err = 0;
5508+
5509 out:
5510- return -EPROTO;
5511+ return err;
5512 }
5513 EXPORT_SYMBOL(skb_checksum_setup);
5514 #endif