Imported xen patches.
[people/pmueller/ipfire-2.x.git] / src / patches / 60061_xen-x86-no-lapic.patch1
1 From: jbeulich@novell.com
2 Subject: Disallow all accesses to the local APIC page
3 Patch-mainline: obsolete
4 References: 191115
5
6 Index: head-2008-10-21/arch/x86/kernel/Makefile
7 ===================================================================
8 --- head-2008-10-21.orig/arch/x86/kernel/Makefile 2008-10-21 13:44:06.000000000 +0200
9 +++ head-2008-10-21/arch/x86/kernel/Makefile 2008-10-21 13:44:08.000000000 +0200
10 @@ -119,9 +119,11 @@ ifeq ($(CONFIG_X86_64),y)
11
12 obj-$(CONFIG_PCI_MMCONFIG) += mmconf-fam10h_64.o
13
14 + apic_64-$(CONFIG_XEN) += apic_32.o
15 time_64-$(CONFIG_XEN) += time_32.o
16 endif
17
18 -disabled-obj-$(CONFIG_XEN) := bios_uv.o early-quirks.o hpet.o i8253.o \
19 - i8259.o irqinit_$(BITS).o pci-swiotlb_64.o reboot.o smpboot.o \
20 - tlb_$(BITS).o tsc.o tsc_sync.o vsmp_64.o
21 +disabled-obj-$(CONFIG_XEN) := bios_uv.o early-quirks.o genapic_flat_64.o \
22 + genx2apic_%.o hpet.o i8253.o i8259.o irqinit_$(BITS).o \
23 + pci-swiotlb_64.o reboot.o smpboot.o tlb_$(BITS).o tlb_uv.o tsc.o \
24 + tsc_sync.o vsmp_64.o
25 Index: head-2008-10-21/arch/x86/kernel/acpi/boot.c
26 ===================================================================
27 --- head-2008-10-21.orig/arch/x86/kernel/acpi/boot.c 2008-10-21 13:30:34.000000000 +0200
28 +++ head-2008-10-21/arch/x86/kernel/acpi/boot.c 2008-10-21 13:44:08.000000000 +0200
29 @@ -89,7 +89,7 @@ int acpi_sci_override_gsi __initdata;
30 int acpi_skip_timer_override __initdata;
31 int acpi_use_timer_override __initdata;
32
33 -#ifdef CONFIG_X86_LOCAL_APIC
34 +#if defined(CONFIG_X86_LOCAL_APIC) && !defined(CONFIG_XEN)
35 static u64 acpi_lapic_addr __initdata = APIC_DEFAULT_PHYS_BASE;
36 #endif
37
38 @@ -237,12 +237,14 @@ static int __init acpi_parse_madt(struct
39 return -ENODEV;
40 }
41
42 +#ifndef CONFIG_XEN
43 if (madt->address) {
44 acpi_lapic_addr = (u64) madt->address;
45
46 printk(KERN_DEBUG PREFIX "Local APIC address 0x%08x\n",
47 madt->address);
48 }
49 +#endif
50
51 acpi_madt_oem_check(madt->header.oem_id, madt->header.oem_table_id);
52
53 @@ -317,6 +319,7 @@ static int __init
54 acpi_parse_lapic_addr_ovr(struct acpi_subtable_header * header,
55 const unsigned long end)
56 {
57 +#ifndef CONFIG_XEN
58 struct acpi_madt_local_apic_override *lapic_addr_ovr = NULL;
59
60 lapic_addr_ovr = (struct acpi_madt_local_apic_override *)header;
61 @@ -325,6 +328,7 @@ acpi_parse_lapic_addr_ovr(struct acpi_su
62 return -EINVAL;
63
64 acpi_lapic_addr = lapic_addr_ovr->address;
65 +#endif
66
67 return 0;
68 }
69 @@ -904,10 +908,12 @@ static int mp_find_ioapic(int gsi)
70 static u8 __init uniq_ioapic_id(u8 id)
71 {
72 #ifdef CONFIG_X86_32
73 +#ifndef CONFIG_XEN
74 if ((boot_cpu_data.x86_vendor == X86_VENDOR_INTEL) &&
75 !APIC_XAPIC(apic_version[boot_cpu_physical_apicid]))
76 return io_apic_get_unique_id(nr_ioapics, id);
77 else
78 +#endif
79 return id;
80 #else
81 int i;
82 @@ -1139,7 +1145,7 @@ int mp_register_gsi(u32 gsi, int trigger
83
84 ioapic_pin = gsi - mp_ioapic_routing[ioapic].gsi_base;
85
86 -#ifdef CONFIG_X86_32
87 +#if defined(CONFIG_X86_32) && !defined(CONFIG_XEN)
88 if (ioapic_renumber_irq)
89 gsi = ioapic_renumber_irq(ioapic, gsi);
90 #endif
91 Index: head-2008-10-21/arch/x86/kernel/apic_32-xen.c
92 ===================================================================
93 --- head-2008-10-21.orig/arch/x86/kernel/apic_32-xen.c 2008-10-21 13:30:34.000000000 +0200
94 +++ head-2008-10-21/arch/x86/kernel/apic_32-xen.c 2008-10-21 13:44:08.000000000 +0200
95 @@ -1,60 +1,11 @@
96 /*
97 - * Local APIC handling, local APIC timers
98 - *
99 - * (c) 1999, 2000 Ingo Molnar <mingo@redhat.com>
100 - *
101 - * Fixes
102 - * Maciej W. Rozycki : Bits for genuine 82489DX APICs;
103 - * thanks to Eric Gilmore
104 - * and Rolf G. Tews
105 - * for testing these extensively.
106 - * Maciej W. Rozycki : Various updates and fixes.
107 - * Mikael Pettersson : Power Management for UP-APIC.
108 - * Pavel Machek and
109 - * Mikael Pettersson : PM converted to driver model.
110 + * Local APIC handling stubs
111 */
112
113 #include <linux/init.h>
114 -
115 -#include <linux/mm.h>
116 -#include <linux/delay.h>
117 -#include <linux/bootmem.h>
118 #include <linux/interrupt.h>
119 -#include <linux/mc146818rtc.h>
120 -#include <linux/kernel_stat.h>
121 -#include <linux/sysdev.h>
122 -#include <linux/cpu.h>
123 -#include <linux/clockchips.h>
124 -#include <linux/acpi_pmtmr.h>
125 -#include <linux/module.h>
126
127 -#include <asm/atomic.h>
128 #include <asm/smp.h>
129 -#include <asm/mtrr.h>
130 -#include <asm/mpspec.h>
131 -#include <asm/desc.h>
132 -#include <asm/arch_hooks.h>
133 -#include <asm/hpet.h>
134 -#include <asm/i8253.h>
135 -#include <asm/nmi.h>
136 -
137 -#include <mach_apic.h>
138 -#include <mach_apicdef.h>
139 -#include <mach_ipi.h>
140 -
141 -#include "io_ports.h"
142 -
143 -#ifndef CONFIG_XEN
144 -/*
145 - * cpu_mask that denotes the CPUs that needs timer interrupt coming in as
146 - * IPIs in place of local APIC timers
147 - */
148 -static cpumask_t timer_bcast_ipi;
149 -#endif
150 -
151 -/*
152 - * Knob to control our willingness to enable the local APIC.
153 - */
154
155 /*
156 * Debug level, exported for io_apic.c
157 @@ -64,21 +15,16 @@ unsigned int apic_verbosity;
158 /* Have we found an MP table */
159 int smp_found_config;
160
161 -#ifndef CONFIG_XEN
162 -static int modern_apic(void)
163 +static int __init apic_set_verbosity(char *str)
164 {
165 - /* AMD systems use old APIC versions, so check the CPU */
166 - if (boot_cpu_data.x86_vendor == X86_VENDOR_AMD &&
167 - boot_cpu_data.x86 >= 0xf)
168 - return 1;
169 - return lapic_get_version() >= 0x14;
170 + if (strcmp("debug", str) == 0)
171 + apic_verbosity = APIC_DEBUG;
172 + else if (strcmp("verbose", str) == 0)
173 + apic_verbosity = APIC_VERBOSE;
174 + return 1;
175 }
176 -#endif /* !CONFIG_XEN */
177
178 -int get_physical_broadcast(void)
179 -{
180 - return 0xff;
181 -}
182 +__setup("apic=", apic_set_verbosity);
183
184 int setup_profiling_timer(unsigned int multiplier)
185 {
186 Index: head-2008-10-21/arch/x86/kernel/apic_64-xen.c
187 ===================================================================
188 --- head-2008-10-21.orig/arch/x86/kernel/apic_64-xen.c 2008-10-21 13:30:34.000000000 +0200
189 +++ /dev/null 1970-01-01 00:00:00.000000000 +0000
190 @@ -1,188 +0,0 @@
191 -/*
192 - * Local APIC handling, local APIC timers
193 - *
194 - * (c) 1999, 2000 Ingo Molnar <mingo@redhat.com>
195 - *
196 - * Fixes
197 - * Maciej W. Rozycki : Bits for genuine 82489DX APICs;
198 - * thanks to Eric Gilmore
199 - * and Rolf G. Tews
200 - * for testing these extensively.
201 - * Maciej W. Rozycki : Various updates and fixes.
202 - * Mikael Pettersson : Power Management for UP-APIC.
203 - * Pavel Machek and
204 - * Mikael Pettersson : PM converted to driver model.
205 - */
206 -
207 -#include <linux/init.h>
208 -
209 -#include <linux/mm.h>
210 -#include <linux/delay.h>
211 -#include <linux/bootmem.h>
212 -#include <linux/interrupt.h>
213 -#include <linux/mc146818rtc.h>
214 -#include <linux/kernel_stat.h>
215 -#include <linux/sysdev.h>
216 -#include <linux/module.h>
217 -
218 -#include <asm/atomic.h>
219 -#include <asm/smp.h>
220 -#include <asm/mtrr.h>
221 -#include <asm/mpspec.h>
222 -#include <asm/desc.h>
223 -#include <asm/arch_hooks.h>
224 -#include <asm/hpet.h>
225 -#include <asm/idle.h>
226 -
227 -int disable_apic;
228 -
229 -/*
230 - * Debug level, exported for io_apic.c
231 - */
232 -unsigned int apic_verbosity;
233 -
234 -/* Have we found an MP table */
235 -int smp_found_config;
236 -
237 -/*
238 - * The guts of the apic timer interrupt
239 - */
240 -static void local_apic_timer_interrupt(void)
241 -{
242 -#ifndef CONFIG_XEN
243 - int cpu = smp_processor_id();
244 - struct clock_event_device *evt = &per_cpu(lapic_events, cpu);
245 -
246 - /*
247 - * Normally we should not be here till LAPIC has been initialized but
248 - * in some cases like kdump, its possible that there is a pending LAPIC
249 - * timer interrupt from previous kernel's context and is delivered in
250 - * new kernel the moment interrupts are enabled.
251 - *
252 - * Interrupts are enabled early and LAPIC is setup much later, hence
253 - * its possible that when we get here evt->event_handler is NULL.
254 - * Check for event_handler being NULL and discard the interrupt as
255 - * spurious.
256 - */
257 - if (!evt->event_handler) {
258 - printk(KERN_WARNING
259 - "Spurious LAPIC timer interrupt on cpu %d\n", cpu);
260 - /* Switch it off */
261 - lapic_timer_setup(CLOCK_EVT_MODE_SHUTDOWN, evt);
262 - return;
263 - }
264 -#endif
265 -
266 - /*
267 - * the NMI deadlock-detector uses this.
268 - */
269 - add_pda(apic_timer_irqs, 1);
270 -
271 -#ifndef CONFIG_XEN
272 - evt->event_handler(evt);
273 -#endif
274 -}
275 -
276 -/*
277 - * Local APIC timer interrupt. This is the most natural way for doing
278 - * local interrupts, but local timer interrupts can be emulated by
279 - * broadcast interrupts too. [in case the hw doesn't support APIC timers]
280 - *
281 - * [ if a single-CPU system runs an SMP kernel then we call the local
282 - * interrupt as well. Thus we cannot inline the local irq ... ]
283 - */
284 -void smp_apic_timer_interrupt(struct pt_regs *regs)
285 -{
286 - struct pt_regs *old_regs = set_irq_regs(regs);
287 -
288 - /*
289 - * NOTE! We'd better ACK the irq immediately,
290 - * because timer handling can be slow.
291 - */
292 - ack_APIC_irq();
293 - /*
294 - * update_process_times() expects us to have done irq_enter().
295 - * Besides, if we don't timer interrupts ignore the global
296 - * interrupt lock, which is the WrongThing (tm) to do.
297 - */
298 - exit_idle();
299 - irq_enter();
300 - local_apic_timer_interrupt();
301 - irq_exit();
302 - set_irq_regs(old_regs);
303 -}
304 -
305 -int setup_profiling_timer(unsigned int multiplier)
306 -{
307 - return -EINVAL;
308 -}
309 -
310 -/*
311 - * This initializes the IO-APIC and APIC hardware if this is
312 - * a UP kernel.
313 - */
314 -int __init APIC_init_uniprocessor(void)
315 -{
316 -#ifdef CONFIG_X86_IO_APIC
317 - if (smp_found_config && !skip_ioapic_setup && nr_ioapics)
318 - setup_IO_APIC();
319 -#endif
320 -
321 - return 1;
322 -}
323 -
324 -/*
325 - * Local APIC interrupts
326 - */
327 -
328 -/*
329 - * This interrupt should _never_ happen with our APIC/SMP architecture
330 - */
331 -asmlinkage void smp_spurious_interrupt(void)
332 -{
333 - unsigned int v;
334 - exit_idle();
335 - irq_enter();
336 - /*
337 - * Check if this really is a spurious interrupt and ACK it
338 - * if it is a vectored one. Just in case...
339 - * Spurious interrupts should not be ACKed.
340 - */
341 - v = apic_read(APIC_ISR + ((SPURIOUS_APIC_VECTOR & ~0x1f) >> 1));
342 - if (v & (1 << (SPURIOUS_APIC_VECTOR & 0x1f)))
343 - ack_APIC_irq();
344 -
345 - add_pda(irq_spurious_count, 1);
346 - irq_exit();
347 -}
348 -
349 -/*
350 - * This interrupt should never happen with our APIC/SMP architecture
351 - */
352 -asmlinkage void smp_error_interrupt(void)
353 -{
354 - unsigned int v, v1;
355 -
356 - exit_idle();
357 - irq_enter();
358 - /* First tickle the hardware, only then report what went on. -- REW */
359 - v = apic_read(APIC_ESR);
360 - apic_write(APIC_ESR, 0);
361 - v1 = apic_read(APIC_ESR);
362 - ack_APIC_irq();
363 - atomic_inc(&irq_err_count);
364 -
365 - /* Here is what the APIC error bits mean:
366 - 0: Send CS error
367 - 1: Receive CS error
368 - 2: Send accept error
369 - 3: Receive accept error
370 - 4: Reserved
371 - 5: Send illegal vector
372 - 6: Received illegal vector
373 - 7: Illegal register address
374 - */
375 - printk (KERN_DEBUG "APIC error on CPU%d: %02x(%02x)\n",
376 - smp_processor_id(), v , v1);
377 - irq_exit();
378 -}
379 Index: head-2008-10-21/arch/x86/kernel/cpu/common-xen.c
380 ===================================================================
381 --- head-2008-10-21.orig/arch/x86/kernel/cpu/common-xen.c 2008-10-21 13:30:34.000000000 +0200
382 +++ head-2008-10-21/arch/x86/kernel/cpu/common-xen.c 2008-10-21 13:44:08.000000000 +0200
383 @@ -18,10 +18,6 @@
384 #include <asm/mpspec.h>
385 #include <asm/apic.h>
386 #include <mach_apic.h>
387 -#else
388 -#ifdef CONFIG_XEN
389 -#define phys_pkg_id(a,b) a
390 -#endif
391 #endif
392 #include <asm/hypervisor.h>
393
394 Index: head-2008-10-21/arch/x86/kernel/genapic_64-xen.c
395 ===================================================================
396 --- head-2008-10-21.orig/arch/x86/kernel/genapic_64-xen.c 2008-10-21 13:30:34.000000000 +0200
397 +++ head-2008-10-21/arch/x86/kernel/genapic_64-xen.c 2008-10-21 13:44:08.000000000 +0200
398 @@ -18,7 +18,6 @@
399 #include <linux/hardirq.h>
400
401 #include <asm/smp.h>
402 -#include <asm/ipi.h>
403 #include <asm/genapic.h>
404
405 #ifdef CONFIG_ACPI
406 @@ -73,7 +72,7 @@ void __init setup_apic_routing(void)
407 /* Same for both flat and physical. */
408
409 #ifdef CONFIG_XEN
410 -extern void xen_send_IPI_shortcut(unsigned int shortcut, int vector, unsigned int dest);
411 +extern void xen_send_IPI_shortcut(unsigned int shortcut, int vector);
412 #endif
413
414 void send_IPI_self(int vector)
415 @@ -81,7 +80,7 @@ void send_IPI_self(int vector)
416 #ifndef CONFIG_XEN
417 __send_IPI_shortcut(APIC_DEST_SELF, vector, APIC_DEST_PHYSICAL);
418 #else
419 - xen_send_IPI_shortcut(APIC_DEST_SELF, vector, APIC_DEST_PHYSICAL);
420 + xen_send_IPI_shortcut(APIC_DEST_SELF, vector);
421 #endif
422 }
423
424 Index: head-2008-10-21/arch/x86/kernel/genapic_xen_64.c
425 ===================================================================
426 --- head-2008-10-21.orig/arch/x86/kernel/genapic_xen_64.c 2008-10-21 13:30:34.000000000 +0200
427 +++ head-2008-10-21/arch/x86/kernel/genapic_xen_64.c 2008-10-21 13:44:08.000000000 +0200
428 @@ -18,7 +18,6 @@
429 #include <linux/init.h>
430 #ifdef CONFIG_XEN_PRIVILEGED_GUEST
431 #include <asm/smp.h>
432 -#include <asm/ipi.h>
433 #else
434 #include <asm/apic.h>
435 #endif
436 @@ -34,7 +33,7 @@ static inline void __send_IPI_one(unsign
437 notify_remote_via_irq(irq);
438 }
439
440 -void xen_send_IPI_shortcut(unsigned int shortcut, int vector, unsigned int dest)
441 +void xen_send_IPI_shortcut(unsigned int shortcut, int vector)
442 {
443 int cpu;
444
445 @@ -91,12 +90,12 @@ static void xen_send_IPI_allbutself(int
446 * thus we have to avoid sending IPIs in this case.
447 */
448 if (num_online_cpus() > 1)
449 - xen_send_IPI_shortcut(APIC_DEST_ALLBUT, vector, APIC_DEST_LOGICAL);
450 + xen_send_IPI_shortcut(APIC_DEST_ALLBUT, vector);
451 }
452
453 static void xen_send_IPI_all(int vector)
454 {
455 - xen_send_IPI_shortcut(APIC_DEST_ALLINC, vector, APIC_DEST_LOGICAL);
456 + xen_send_IPI_shortcut(APIC_DEST_ALLINC, vector);
457 }
458
459 static void xen_send_IPI_mask(cpumask_t cpumask, int vector)
460 @@ -126,7 +125,7 @@ static int xen_apic_id_registered(void)
461
462 static unsigned int xen_cpu_mask_to_apicid(cpumask_t cpumask)
463 {
464 - return cpus_addr(cpumask)[0] & APIC_ALL_CPUS;
465 + return cpus_addr(cpumask)[0];
466 }
467
468 static unsigned int phys_pkg_id(int index_msb)
469 @@ -142,7 +141,7 @@ struct genapic apic_xen = {
470 #ifdef CONFIG_XEN_PRIVILEGED_GUEST
471 .int_delivery_mode = dest_LowestPrio,
472 #endif
473 - .int_dest_mode = (APIC_DEST_LOGICAL != 0),
474 + .int_dest_mode = 1,
475 .target_cpus = xen_target_cpus,
476 .vector_allocation_domain = xen_vector_allocation_domain,
477 #ifdef CONFIG_XEN_PRIVILEGED_GUEST
478 Index: head-2008-10-21/arch/x86/kernel/io_apic_32-xen.c
479 ===================================================================
480 --- head-2008-10-21.orig/arch/x86/kernel/io_apic_32-xen.c 2008-10-21 13:43:37.000000000 +0200
481 +++ head-2008-10-21/arch/x86/kernel/io_apic_32-xen.c 2008-10-21 13:44:08.000000000 +0200
482 @@ -48,7 +48,6 @@
483 #include <asm/hypertransport.h>
484
485 #include <mach_apic.h>
486 -#include <mach_apicdef.h>
487
488 #ifdef CONFIG_XEN
489 #include <xen/interface/xen.h>
490 @@ -63,10 +62,10 @@
491 unsigned long io_apic_irqs;
492
493 #define clear_IO_APIC() ((void)0)
494 -#endif /* CONFIG_XEN */
495 -
496 +#else
497 int (*ioapic_renumber_irq)(int ioapic, int irq);
498 atomic_t irq_mis_count;
499 +#endif /* CONFIG_XEN */
500
501 /* Where if anywhere is the i8259 connect in external int mode */
502 static struct { int pin, apic; } ioapic_i8259 = { -1, -1 };
503 @@ -74,7 +73,9 @@ static struct { int pin, apic; } ioapic_
504 static DEFINE_SPINLOCK(ioapic_lock);
505 static DEFINE_SPINLOCK(vector_lock);
506
507 +#ifndef CONFIG_XEN
508 int timer_through_8259 __initdata;
509 +#endif
510
511 /*
512 * Is the SiS APIC rmw bug present ?
513 @@ -103,7 +104,9 @@ int mp_bus_id_to_type[MAX_MP_BUSSES];
514
515 DECLARE_BITMAP(mp_bus_not_pci, MAX_MP_BUSSES);
516
517 +#ifndef CONFIG_XEN
518 static int disable_timer_pin_1 __initdata;
519 +#endif
520
521 /*
522 * Rough estimation of how many shared IRQs there are, can
523 @@ -1171,11 +1174,13 @@ static int pin_2_irq(int idx, int apic,
524 irq += nr_ioapic_registers[i++];
525 irq += pin;
526
527 +#ifndef CONFIG_XEN
528 /*
529 * For MPS mode, so far only needed by ES7000 platform
530 */
531 if (ioapic_renumber_irq)
532 irq = ioapic_renumber_irq(apic, irq);
533 +#endif
534 }
535
536 /*
537 @@ -2918,6 +2923,7 @@ int acpi_get_override_irq(int bus_irq, i
538
539 #endif /* CONFIG_ACPI */
540
541 +#ifndef CONFIG_XEN
542 static int __init parse_disable_timer_pin_1(char *arg)
543 {
544 disable_timer_pin_1 = 1;
545 @@ -2931,6 +2937,7 @@ static int __init parse_enable_timer_pin
546 return 0;
547 }
548 early_param("enable_timer_pin_1", parse_enable_timer_pin_1);
549 +#endif
550
551 static int __init parse_noapic(char *arg)
552 {
553 Index: head-2008-10-21/arch/x86/kernel/io_apic_64-xen.c
554 ===================================================================
555 --- head-2008-10-21.orig/arch/x86/kernel/io_apic_64-xen.c 2008-10-21 13:30:34.000000000 +0200
556 +++ head-2008-10-21/arch/x86/kernel/io_apic_64-xen.c 2008-10-21 13:44:08.000000000 +0200
557 @@ -78,10 +78,6 @@ char system_vectors[NR_VECTORS] = { [0 .
558
559 int sis_apic_bug; /* not actually supported, dummy for compile */
560
561 -static int no_timer_check;
562 -
563 -static int disable_timer_pin_1 __initdata;
564 -
565 #ifdef CONFIG_XEN
566 #include <xen/interface/xen.h>
567 #include <xen/interface/physdev.h>
568 @@ -96,6 +92,10 @@ unsigned long io_apic_irqs;
569
570 #define clear_IO_APIC() ((void)0)
571 #else
572 +static int no_timer_check;
573 +
574 +static int disable_timer_pin_1 __initdata;
575 +
576 int timer_through_8259 __initdata;
577
578 /* Where if anywhere is the i8259 connect in external int mode */
579 @@ -485,6 +485,7 @@ static int __init parse_noapic(char *str
580 }
581 early_param("noapic", parse_noapic);
582
583 +#ifndef CONFIG_XEN
584 /* Actually the next is obsolete, but keep it for paranoid reasons -AK */
585 static int __init disable_timer_pin_setup(char *arg)
586 {
587 @@ -492,6 +493,7 @@ static int __init disable_timer_pin_setu
588 return 1;
589 }
590 __setup("disable_timer_pin_1", disable_timer_pin_setup);
591 +#endif
592
593
594 /*
595 @@ -1814,10 +1816,6 @@ static inline void __init check_timer(vo
596 out:
597 local_irq_restore(flags);
598 }
599 -#else
600 -#define check_timer() ((void)0)
601 -int timer_uses_ioapic_pin_0 = 0;
602 -#endif /* !CONFIG_XEN */
603
604 static int __init notimercheck(char *s)
605 {
606 @@ -1825,6 +1823,10 @@ static int __init notimercheck(char *s)
607 return 1;
608 }
609 __setup("no_timer_check", notimercheck);
610 +#else
611 +#define check_timer() ((void)0)
612 +int timer_uses_ioapic_pin_0 = 0;
613 +#endif /* !CONFIG_XEN */
614
615 /*
616 *
617 Index: head-2008-10-21/arch/x86/kernel/irq_32-xen.c
618 ===================================================================
619 --- head-2008-10-21.orig/arch/x86/kernel/irq_32-xen.c 2008-10-21 13:30:34.000000000 +0200
620 +++ head-2008-10-21/arch/x86/kernel/irq_32-xen.c 2008-10-21 13:44:08.000000000 +0200
621 @@ -252,7 +252,9 @@ unsigned int do_IRQ(struct pt_regs *regs
622 * Interrupt statistics:
623 */
624
625 +#ifndef CONFIG_XEN
626 atomic_t irq_err_count;
627 +#endif
628
629 /*
630 * /proc/interrupts printing:
631 @@ -308,7 +310,7 @@ skip:
632 for_each_online_cpu(j)
633 seq_printf(p, "%10u ", nmi_count(j));
634 seq_printf(p, " Non-maskable interrupts\n");
635 -#ifdef CONFIG_X86_LOCAL_APIC
636 +#if defined(CONFIG_X86_LOCAL_APIC) && !defined(CONFIG_XEN)
637 seq_printf(p, "LOC: ");
638 for_each_online_cpu(j)
639 seq_printf(p, "%10u ",
640 @@ -341,6 +343,7 @@ skip:
641 per_cpu(irq_stat,j).irq_thermal_count);
642 seq_printf(p, " Thermal event interrupts\n");
643 #endif
644 +#ifndef CONFIG_XEN
645 #ifdef CONFIG_X86_LOCAL_APIC
646 seq_printf(p, "SPU: ");
647 for_each_online_cpu(j)
648 @@ -352,6 +355,7 @@ skip:
649 #if defined(CONFIG_X86_IO_APIC)
650 seq_printf(p, "MIS: %10u\n", atomic_read(&irq_mis_count));
651 #endif
652 +#endif
653 }
654 return 0;
655 }
656 @@ -384,12 +388,16 @@ u64 arch_irq_stat_cpu(unsigned int cpu)
657
658 u64 arch_irq_stat(void)
659 {
660 +#ifndef CONFIG_XEN
661 u64 sum = atomic_read(&irq_err_count);
662
663 #ifdef CONFIG_X86_IO_APIC
664 sum += atomic_read(&irq_mis_count);
665 #endif
666 return sum;
667 +#else
668 + return 0;
669 +#endif
670 }
671
672 #ifdef CONFIG_HOTPLUG_CPU
673 Index: head-2008-10-21/arch/x86/kernel/irq_64-xen.c
674 ===================================================================
675 --- head-2008-10-21.orig/arch/x86/kernel/irq_64-xen.c 2008-10-21 13:30:34.000000000 +0200
676 +++ head-2008-10-21/arch/x86/kernel/irq_64-xen.c 2008-10-21 13:44:08.000000000 +0200
677 @@ -18,7 +18,9 @@
678 #include <asm/idle.h>
679 #include <asm/smp.h>
680
681 +#ifndef CONFIG_XEN
682 atomic_t irq_err_count;
683 +#endif
684
685 /*
686 * 'what should we do if we get a hw irq event on an illegal vector'.
687 @@ -27,19 +29,6 @@ atomic_t irq_err_count;
688 void ack_bad_irq(unsigned int irq)
689 {
690 printk(KERN_WARNING "unexpected IRQ trap at irq %02x\n", irq);
691 -#ifdef CONFIG_X86_LOCAL_APIC
692 - /*
693 - * Currently unexpected vectors happen only on SMP and APIC.
694 - * We _must_ ack these because every local APIC has only N
695 - * irq slots per priority level, and a 'hanging, unacked' IRQ
696 - * holds up an irq slot - in excessive cases (when multiple
697 - * unexpected vectors occur) that might lock up the APIC
698 - * completely.
699 - * But don't ack when the APIC is disabled. -AK
700 - */
701 - if (!disable_apic)
702 - ack_APIC_irq();
703 -#endif
704 }
705
706 #ifdef CONFIG_DEBUG_STACKOVERFLOW
707 @@ -119,7 +108,7 @@ skip:
708 for_each_online_cpu(j)
709 seq_printf(p, "%10u ", cpu_pda(j)->__nmi_count);
710 seq_printf(p, " Non-maskable interrupts\n");
711 -#ifdef CONFIG_X86_LOCAL_APIC
712 +#ifndef CONFIG_XEN
713 seq_printf(p, "LOC: ");
714 for_each_online_cpu(j)
715 seq_printf(p, "%10u ", cpu_pda(j)->apic_timer_irqs);
716 @@ -151,13 +140,13 @@ skip:
717 seq_printf(p, "%10u ", cpu_pda(j)->irq_threshold_count);
718 seq_printf(p, " Threshold APIC interrupts\n");
719 #endif
720 -#ifdef CONFIG_X86_LOCAL_APIC
721 +#ifndef CONFIG_XEN
722 seq_printf(p, "SPU: ");
723 for_each_online_cpu(j)
724 seq_printf(p, "%10u ", cpu_pda(j)->irq_spurious_count);
725 seq_printf(p, " Spurious interrupts\n");
726 -#endif
727 seq_printf(p, "ERR: %10u\n", atomic_read(&irq_err_count));
728 +#endif
729 }
730 return 0;
731 }
732 @@ -187,7 +176,11 @@ u64 arch_irq_stat_cpu(unsigned int cpu)
733
734 u64 arch_irq_stat(void)
735 {
736 +#ifndef CONFIG_XEN
737 return atomic_read(&irq_err_count);
738 +#else
739 + return 0;
740 +#endif
741 }
742
743 /*
744 Index: head-2008-10-21/arch/x86/kernel/mpparse-xen.c
745 ===================================================================
746 --- head-2008-10-21.orig/arch/x86/kernel/mpparse-xen.c 2008-10-21 13:30:34.000000000 +0200
747 +++ head-2008-10-21/arch/x86/kernel/mpparse-xen.c 2008-10-21 13:44:08.000000000 +0200
748 @@ -31,7 +31,6 @@
749
750 #include <mach_apic.h>
751 #ifdef CONFIG_X86_32
752 -#include <mach_apicdef.h>
753 #include <mach_mpparse.h>
754 #endif
755
756 @@ -285,7 +284,9 @@ static int __init smp_check_mpc(struct m
757
758 printk(KERN_INFO "MPTABLE: Product ID: %s\n", str);
759
760 +#ifndef CONFIG_XEN
761 printk(KERN_INFO "MPTABLE: APIC at: 0x%X\n", mpc->mpc_lapic);
762 +#endif
763
764 return 1;
765 }
766 @@ -313,9 +314,11 @@ static int __init smp_read_mpc(struct mp
767 } else
768 mps_oem_check(mpc, oem, str);
769 #endif
770 +#ifndef CONFIG_XEN
771 /* save the local APIC address, it might be non-default */
772 if (!acpi_lapic)
773 mp_lapic_addr = mpc->mpc_lapic;
774 +#endif
775
776 if (early)
777 return 1;
778 @@ -546,10 +549,12 @@ static inline void __init construct_defa
779 int linttypes[2] = { mp_ExtINT, mp_NMI };
780 int i;
781
782 +#ifndef CONFIG_XEN
783 /*
784 * local APIC has default address
785 */
786 mp_lapic_addr = APIC_DEFAULT_PHYS_BASE;
787 +#endif
788
789 /*
790 * 2 CPUs, numbered 0 & 1.
791 @@ -625,10 +630,12 @@ static void __init __get_smp_config(unsi
792 */
793 if (mpf->mpf_feature1 != 0) {
794 if (early) {
795 +#ifndef CONFIG_XEN
796 /*
797 * local APIC has default address
798 */
799 mp_lapic_addr = APIC_DEFAULT_PHYS_BASE;
800 +#endif
801 return;
802 }
803
804 Index: head-2008-10-21/arch/x86/kernel/traps_64-xen.c
805 ===================================================================
806 --- head-2008-10-21.orig/arch/x86/kernel/traps_64-xen.c 2008-10-21 13:44:06.000000000 +0200
807 +++ head-2008-10-21/arch/x86/kernel/traps_64-xen.c 2008-10-21 13:44:08.000000000 +0200
808 @@ -1170,15 +1170,15 @@ asmlinkage void do_spurious_interrupt_bu
809 {
810 }
811
812 -#if 0
813 +#ifndef CONFIG_XEN
814 asmlinkage void __attribute__((weak)) smp_thermal_interrupt(void)
815 {
816 }
817 -#endif
818
819 asmlinkage void __attribute__((weak)) mce_threshold_interrupt(void)
820 {
821 }
822 +#endif
823
824 /*
825 * 'math_state_restore()' saves the current math information in the
826 Index: head-2008-10-21/include/asm-x86/apic.h
827 ===================================================================
828 --- head-2008-10-21.orig/include/asm-x86/apic.h 2008-10-21 13:25:32.000000000 +0200
829 +++ head-2008-10-21/include/asm-x86/apic.h 2008-10-21 13:44:08.000000000 +0200
830 @@ -5,7 +5,9 @@
831 #include <linux/delay.h>
832
833 #include <asm/alternative.h>
834 +#ifndef CONFIG_XEN
835 #include <asm/fixmap.h>
836 +#endif
837 #include <asm/apicdef.h>
838 #include <asm/processor.h>
839 #include <asm/system.h>
840 @@ -40,6 +42,7 @@ extern void generic_apic_probe(void);
841 #ifdef CONFIG_X86_LOCAL_APIC
842
843 extern unsigned int apic_verbosity;
844 +#ifndef CONFIG_XEN
845 extern int local_apic_timer_c2_ok;
846
847 extern int ioapic_force;
848 @@ -141,6 +144,7 @@ static inline void ack_APIC_irq(void)
849 /* Docs say use 0 for future compatibility */
850 apic_write(APIC_EOI, 0);
851 }
852 +#endif
853
854 extern int lapic_get_maxlvt(void);
855 extern void clear_local_APIC(void);
856 Index: head-2008-10-21/include/asm-x86/apicdef.h
857 ===================================================================
858 --- head-2008-10-21.orig/include/asm-x86/apicdef.h 2008-10-21 12:57:02.000000000 +0200
859 +++ head-2008-10-21/include/asm-x86/apicdef.h 2008-10-21 13:44:08.000000000 +0200
860 @@ -1,6 +1,8 @@
861 #ifndef _ASM_X86_APICDEF_H
862 #define _ASM_X86_APICDEF_H
863
864 +#ifndef CONFIG_XEN
865 +
866 /*
867 * Constants for various Intel APICs. (local APIC, IOAPIC, etc.)
868 *
869 @@ -132,6 +134,16 @@
870 #define APIC_BASE_MSR 0x800
871 #define X2APIC_ENABLE (1UL << 10)
872
873 +#else /* CONFIG_XEN */
874 +
875 +enum {
876 + APIC_DEST_ALLBUT = 0x1,
877 + APIC_DEST_SELF,
878 + APIC_DEST_ALLINC
879 +};
880 +
881 +#endif /* CONFIG_XEN */
882 +
883 #ifdef CONFIG_X86_32
884 # define MAX_IO_APICS 64
885 #else
886 @@ -139,6 +151,8 @@
887 # define MAX_LOCAL_APIC 32768
888 #endif
889
890 +#ifndef CONFIG_XEN
891 +
892 /*
893 * All x86-64 systems are xAPIC compatible.
894 * In the following, "apicid" is a physical APIC ID.
895 @@ -409,6 +423,8 @@ struct local_apic {
896
897 #undef u32
898
899 +#endif /* CONFIG_XEN */
900 +
901 #ifdef CONFIG_X86_32
902 #define BAD_APICID 0xFFu
903 #else
904 Index: head-2008-10-21/include/asm-x86/ipi.h
905 ===================================================================
906 --- head-2008-10-21.orig/include/asm-x86/ipi.h 2008-10-21 12:57:02.000000000 +0200
907 +++ head-2008-10-21/include/asm-x86/ipi.h 2008-10-21 13:44:08.000000000 +0200
908 @@ -1,6 +1,8 @@
909 #ifndef __ASM_IPI_H
910 #define __ASM_IPI_H
911
912 +#ifndef CONFIG_XEN
913 +
914 /*
915 * Copyright 2004 James Cleverdon, IBM.
916 * Subject to the GNU Public License, v.2
917 @@ -135,4 +137,6 @@ static inline void send_IPI_mask_sequenc
918 local_irq_restore(flags);
919 }
920
921 +#endif /* CONFIG_XEN */
922 +
923 #endif /* __ASM_IPI_H */
924 Index: head-2008-10-21/include/asm-x86/mach-xen/asm/fixmap_32.h
925 ===================================================================
926 --- head-2008-10-21.orig/include/asm-x86/mach-xen/asm/fixmap_32.h 2008-10-21 13:30:34.000000000 +0200
927 +++ head-2008-10-21/include/asm-x86/mach-xen/asm/fixmap_32.h 2008-10-21 13:44:08.000000000 +0200
928 @@ -55,10 +55,10 @@ enum fixed_addresses {
929 FIX_VDSO,
930 FIX_DBGP_BASE,
931 FIX_EARLYCON_MEM_BASE,
932 +#ifndef CONFIG_XEN
933 #ifdef CONFIG_X86_LOCAL_APIC
934 FIX_APIC_BASE, /* local (CPU) APIC) -- required for SMP or not */
935 #endif
936 -#ifndef CONFIG_XEN
937 #ifdef CONFIG_X86_IO_APIC
938 FIX_IO_APIC_BASE_0,
939 FIX_IO_APIC_BASE_END = FIX_IO_APIC_BASE_0 + MAX_IO_APICS-1,
940 Index: head-2008-10-21/include/asm-x86/mach-xen/asm/fixmap_64.h
941 ===================================================================
942 --- head-2008-10-21.orig/include/asm-x86/mach-xen/asm/fixmap_64.h 2008-10-21 13:30:34.000000000 +0200
943 +++ head-2008-10-21/include/asm-x86/mach-xen/asm/fixmap_64.h 2008-10-21 13:44:08.000000000 +0200
944 @@ -13,7 +13,6 @@
945
946 #include <linux/kernel.h>
947 #include <asm/acpi.h>
948 -#include <asm/apicdef.h>
949 #include <asm/page.h>
950 #include <asm/vsyscall.h>
951 #include <asm/efi.h>
952 @@ -41,10 +40,8 @@ enum fixed_addresses {
953 VSYSCALL_HPET,
954 FIX_DBGP_BASE,
955 FIX_EARLYCON_MEM_BASE,
956 -#ifdef CONFIG_X86_LOCAL_APIC
957 - FIX_APIC_BASE, /* local (CPU) APIC) -- required for SMP or not */
958 -#endif
959 #ifndef CONFIG_XEN
960 + FIX_APIC_BASE, /* local (CPU) APIC) -- required for SMP or not */
961 FIX_IO_APIC_BASE_0,
962 FIX_IO_APIC_BASE_END = FIX_IO_APIC_BASE_0 + MAX_IO_APICS - 1,
963 #endif
964 Index: head-2008-10-21/include/asm-x86/mach-xen/asm/smp.h
965 ===================================================================
966 --- head-2008-10-21.orig/include/asm-x86/mach-xen/asm/smp.h 2008-10-21 13:30:34.000000000 +0200
967 +++ head-2008-10-21/include/asm-x86/mach-xen/asm/smp.h 2008-10-21 13:44:08.000000000 +0200
968 @@ -16,7 +16,7 @@
969 # endif
970 #endif
971 #include <asm/pda.h>
972 -#include <asm/thread_info.h>
973 +#include <linux/thread_info.h>
974
975 #define cpu_callout_map cpu_possible_map
976 extern cpumask_t cpu_initialized;
977 @@ -178,7 +178,7 @@ DECLARE_PER_CPU(int, cpu_number);
978 #define stack_smp_processor_id() 0
979 #endif
980
981 -#ifdef CONFIG_X86_LOCAL_APIC
982 +#if defined(CONFIG_X86_LOCAL_APIC) && !defined(CONFIG_XEN)
983
984 static inline int logical_smp_processor_id(void)
985 {
986 Index: head-2008-10-21/include/asm-x86/mach-xen/mach_apic.h
987 ===================================================================
988 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
989 +++ head-2008-10-21/include/asm-x86/mach-xen/mach_apic.h 2008-10-21 13:44:08.000000000 +0200
990 @@ -0,0 +1,56 @@
991 +#ifndef __ASM_MACH_APIC_H
992 +#define __ASM_MACH_APIC_H
993 +
994 +#include <linux/cpumask.h>
995 +
996 +#ifdef CONFIG_X86_64
997 +
998 +#include <asm/genapic.h>
999 +#define INT_DELIVERY_MODE (genapic->int_delivery_mode)
1000 +#define INT_DEST_MODE (genapic->int_dest_mode)
1001 +#define TARGET_CPUS (genapic->target_cpus())
1002 +#define apic_id_registered (genapic->apic_id_registered)
1003 +#define init_apic_ldr (genapic->init_apic_ldr)
1004 +#define cpu_mask_to_apicid (genapic->cpu_mask_to_apicid)
1005 +#define phys_pkg_id (genapic->phys_pkg_id)
1006 +#define vector_allocation_domain (genapic->vector_allocation_domain)
1007 +extern void setup_apic_routing(void);
1008 +
1009 +#else
1010 +
1011 +#ifdef CONFIG_SMP
1012 +#define TARGET_CPUS cpu_online_map
1013 +#else
1014 +#define TARGET_CPUS cpumask_of_cpu(0)
1015 +#endif
1016 +
1017 +#define INT_DELIVERY_MODE dest_LowestPrio
1018 +#define INT_DEST_MODE 1
1019 +
1020 +static inline u32 phys_pkg_id(u32 cpuid_apic, int index_msb)
1021 +{
1022 + return cpuid_apic;
1023 +}
1024 +
1025 +static inline void setup_apic_routing(void)
1026 +{
1027 +}
1028 +
1029 +static inline int multi_timer_check(int apic, int irq)
1030 +{
1031 + return 0;
1032 +}
1033 +
1034 +static inline int apicid_to_node(int logical_apicid)
1035 +{
1036 + return 0;
1037 +}
1038 +
1039 +static inline unsigned int cpu_mask_to_apicid(cpumask_t cpumask)
1040 +{
1041 + return cpus_addr(cpumask)[0];
1042 +}
1043 +
1044 +#endif /* CONFIG_X86_64 */
1045 +
1046 +#endif /* __ASM_MACH_APIC_H */