From: jbeulich@novell.com Subject: Disallow all accesses to the local APIC page Patch-mainline: obsolete References: 191115 Index: head-2008-03-11/arch/x86/kernel/Makefile =================================================================== --- head-2008-03-11.orig/arch/x86/kernel/Makefile 2008-03-13 12:24:15.000000000 +0100 +++ head-2008-03-11/arch/x86/kernel/Makefile 2008-03-11 17:16:47.000000000 +0100 @@ -100,9 +100,10 @@ ifeq ($(CONFIG_X86_64),y) obj-$(CONFIG_CALGARY_IOMMU) += pci-calgary_64.o tce_64.o obj-$(CONFIG_SWIOTLB) += pci-swiotlb_64.o + apic_64-$(CONFIG_XEN) += apic_32.o time_64-$(CONFIG_XEN) += time_32.o pci-dma_64-$(CONFIG_XEN) += pci-dma_32.o endif -disabled-obj-$(CONFIG_XEN) := early-quirks.o hpet.o i8253.o i8259_$(BITS).o reboot.o \ - smpboot_$(BITS).o tsc_$(BITS).o tsc_sync.o +disabled-obj-$(CONFIG_XEN) := early-quirks.o genapic_flat_$(BITS).o hpet.o i8253.o \ + i8259_$(BITS).o reboot.o smpboot_$(BITS).o tsc_$(BITS).o tsc_sync.o Index: head-2008-03-11/arch/x86/kernel/acpi/boot.c =================================================================== --- head-2008-03-11.orig/arch/x86/kernel/acpi/boot.c 2008-03-13 12:24:15.000000000 +0100 +++ head-2008-03-11/arch/x86/kernel/acpi/boot.c 2008-03-07 09:29:44.000000000 +0100 @@ -85,7 +85,7 @@ int acpi_sci_override_gsi __initdata; int acpi_skip_timer_override __initdata; int acpi_use_timer_override __initdata; -#ifdef CONFIG_X86_LOCAL_APIC +#if defined(CONFIG_X86_LOCAL_APIC) && !defined(CONFIG_XEN) static u64 acpi_lapic_addr __initdata = APIC_DEFAULT_PHYS_BASE; #endif @@ -230,12 +230,14 @@ static int __init acpi_parse_madt(struct return -ENODEV; } +#ifndef CONFIG_XEN if (madt->address) { acpi_lapic_addr = (u64) madt->address; printk(KERN_DEBUG PREFIX "Local APIC address 0x%08x\n", madt->address); } +#endif acpi_madt_oem_check(madt->header.oem_id, madt->header.oem_table_id); @@ -271,6 +273,7 @@ static int __init acpi_parse_lapic_addr_ovr(struct acpi_subtable_header * header, const unsigned long end) { +#ifndef CONFIG_XEN struct acpi_madt_local_apic_override *lapic_addr_ovr = NULL; lapic_addr_ovr = (struct acpi_madt_local_apic_override *)header; @@ -279,6 +282,7 @@ acpi_parse_lapic_addr_ovr(struct acpi_su return -EINVAL; acpi_lapic_addr = lapic_addr_ovr->address; +#endif return 0; } @@ -758,7 +762,9 @@ static int __init acpi_parse_madt_lapic_ return count; } +#ifndef CONFIG_XEN mp_register_lapic_address(acpi_lapic_addr); +#endif count = acpi_table_parse_madt(ACPI_MADT_TYPE_LOCAL_APIC, acpi_parse_lapic, MAX_APICS); Index: head-2008-03-11/arch/x86/kernel/apic_32-xen.c =================================================================== --- head-2008-03-11.orig/arch/x86/kernel/apic_32-xen.c 2008-03-13 12:24:15.000000000 +0100 +++ head-2008-03-11/arch/x86/kernel/apic_32-xen.c 2008-03-03 14:54:20.000000000 +0100 @@ -1,81 +1,27 @@ /* - * Local APIC handling, local APIC timers - * - * (c) 1999, 2000 Ingo Molnar - * - * Fixes - * Maciej W. Rozycki : Bits for genuine 82489DX APICs; - * thanks to Eric Gilmore - * and Rolf G. Tews - * for testing these extensively. - * Maciej W. Rozycki : Various updates and fixes. - * Mikael Pettersson : Power Management for UP-APIC. - * Pavel Machek and - * Mikael Pettersson : PM converted to driver model. + * Local APIC handling stubs */ #include - -#include -#include -#include #include -#include -#include -#include -#include -#include -#include -#include -#include #include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include "io_ports.h" - -#ifndef CONFIG_XEN -/* - * cpu_mask that denotes the CPUs that needs timer interrupt coming in as - * IPIs in place of local APIC timers - */ -static cpumask_t timer_bcast_ipi; -#endif - -/* - * Knob to control our willingness to enable the local APIC. - */ /* * Debug level, exported for io_apic.c */ int apic_verbosity; -#ifndef CONFIG_XEN -static int modern_apic(void) +static int __init apic_set_verbosity(char *str) { - /* AMD systems use old APIC versions, so check the CPU */ - if (boot_cpu_data.x86_vendor == X86_VENDOR_AMD && - boot_cpu_data.x86 >= 0xf) - return 1; - return lapic_get_version() >= 0x14; + if (strcmp("debug", str) == 0) + apic_verbosity = APIC_DEBUG; + else if (strcmp("verbose", str) == 0) + apic_verbosity = APIC_VERBOSE; + return 1; } -#endif /* !CONFIG_XEN */ -int get_physical_broadcast(void) -{ - return 0xff; -} +__setup("apic=", apic_set_verbosity); int setup_profiling_timer(unsigned int multiplier) { Index: head-2008-03-11/arch/x86/kernel/apic_64-xen.c =================================================================== --- head-2008-03-11.orig/arch/x86/kernel/apic_64-xen.c 2008-03-13 12:24:15.000000000 +0100 +++ /dev/null 1970-01-01 00:00:00.000000000 +0000 @@ -1,185 +0,0 @@ -/* - * Local APIC handling, local APIC timers - * - * (c) 1999, 2000 Ingo Molnar - * - * Fixes - * Maciej W. Rozycki : Bits for genuine 82489DX APICs; - * thanks to Eric Gilmore - * and Rolf G. Tews - * for testing these extensively. - * Maciej W. Rozycki : Various updates and fixes. - * Mikael Pettersson : Power Management for UP-APIC. - * Pavel Machek and - * Mikael Pettersson : PM converted to driver model. - */ - -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -int disable_apic; - -/* - * Debug level, exported for io_apic.c - */ -int apic_verbosity; - -/* - * The guts of the apic timer interrupt - */ -static void local_apic_timer_interrupt(void) -{ -#ifndef CONFIG_XEN - int cpu = smp_processor_id(); - struct clock_event_device *evt = &per_cpu(lapic_events, cpu); - - /* - * Normally we should not be here till LAPIC has been initialized but - * in some cases like kdump, its possible that there is a pending LAPIC - * timer interrupt from previous kernel's context and is delivered in - * new kernel the moment interrupts are enabled. - * - * Interrupts are enabled early and LAPIC is setup much later, hence - * its possible that when we get here evt->event_handler is NULL. - * Check for event_handler being NULL and discard the interrupt as - * spurious. - */ - if (!evt->event_handler) { - printk(KERN_WARNING - "Spurious LAPIC timer interrupt on cpu %d\n", cpu); - /* Switch it off */ - lapic_timer_setup(CLOCK_EVT_MODE_SHUTDOWN, evt); - return; - } -#endif - - /* - * the NMI deadlock-detector uses this. - */ - add_pda(apic_timer_irqs, 1); - -#ifndef CONFIG_XEN - evt->event_handler(evt); -#endif -} - -/* - * Local APIC timer interrupt. This is the most natural way for doing - * local interrupts, but local timer interrupts can be emulated by - * broadcast interrupts too. [in case the hw doesn't support APIC timers] - * - * [ if a single-CPU system runs an SMP kernel then we call the local - * interrupt as well. Thus we cannot inline the local irq ... ] - */ -void smp_apic_timer_interrupt(struct pt_regs *regs) -{ - struct pt_regs *old_regs = set_irq_regs(regs); - - /* - * NOTE! We'd better ACK the irq immediately, - * because timer handling can be slow. - */ - ack_APIC_irq(); - /* - * update_process_times() expects us to have done irq_enter(). - * Besides, if we don't timer interrupts ignore the global - * interrupt lock, which is the WrongThing (tm) to do. - */ - exit_idle(); - irq_enter(); - local_apic_timer_interrupt(); - irq_exit(); - set_irq_regs(old_regs); -} - -int setup_profiling_timer(unsigned int multiplier) -{ - return -EINVAL; -} - -/* - * This initializes the IO-APIC and APIC hardware if this is - * a UP kernel. - */ -int __init APIC_init_uniprocessor(void) -{ -#ifdef CONFIG_X86_IO_APIC - if (smp_found_config && !skip_ioapic_setup && nr_ioapics) - setup_IO_APIC(); -#endif - - return 1; -} - -/* - * Local APIC interrupts - */ - -/* - * This interrupt should _never_ happen with our APIC/SMP architecture - */ -asmlinkage void smp_spurious_interrupt(void) -{ - unsigned int v; - exit_idle(); - irq_enter(); - /* - * Check if this really is a spurious interrupt and ACK it - * if it is a vectored one. Just in case... - * Spurious interrupts should not be ACKed. - */ - v = apic_read(APIC_ISR + ((SPURIOUS_APIC_VECTOR & ~0x1f) >> 1)); - if (v & (1 << (SPURIOUS_APIC_VECTOR & 0x1f))) - ack_APIC_irq(); - - add_pda(irq_spurious_count, 1); - irq_exit(); -} - -/* - * This interrupt should never happen with our APIC/SMP architecture - */ -asmlinkage void smp_error_interrupt(void) -{ - unsigned int v, v1; - - exit_idle(); - irq_enter(); - /* First tickle the hardware, only then report what went on. -- REW */ - v = apic_read(APIC_ESR); - apic_write(APIC_ESR, 0); - v1 = apic_read(APIC_ESR); - ack_APIC_irq(); - atomic_inc(&irq_err_count); - - /* Here is what the APIC error bits mean: - 0: Send CS error - 1: Receive CS error - 2: Send accept error - 3: Receive accept error - 4: Reserved - 5: Send illegal vector - 6: Received illegal vector - 7: Illegal register address - */ - printk (KERN_DEBUG "APIC error on CPU%d: %02x(%02x)\n", - smp_processor_id(), v , v1); - irq_exit(); -} Index: head-2008-03-11/arch/x86/kernel/cpu/amd.c =================================================================== --- head-2008-03-11.orig/arch/x86/kernel/cpu/amd.c 2008-03-13 12:24:15.000000000 +0100 +++ head-2008-03-11/arch/x86/kernel/cpu/amd.c 2008-03-03 14:54:20.000000000 +0100 @@ -24,7 +24,7 @@ extern void vide(void); __asm__(".align 4\nvide: ret"); -#ifdef CONFIG_X86_LOCAL_APIC +#if defined(CONFIG_X86_LOCAL_APIC) && !defined(CONFIG_XEN) #define ENABLE_C1E_MASK 0x18000000 #define CPUID_PROCESSOR_SIGNATURE 1 #define CPUID_XFAM 0x0ff00000 @@ -295,7 +295,7 @@ static void __cpuinit init_amd(struct cp num_cache_leaves = 3; } -#ifdef CONFIG_X86_LOCAL_APIC +#if defined(CONFIG_X86_LOCAL_APIC) && !defined(CONFIG_XEN) if (amd_apic_timer_broken()) local_apic_timer_disabled = 1; #endif Index: head-2008-03-11/arch/x86/kernel/genapic_64-xen.c =================================================================== --- head-2008-03-11.orig/arch/x86/kernel/genapic_64-xen.c 2008-03-13 12:24:15.000000000 +0100 +++ head-2008-03-11/arch/x86/kernel/genapic_64-xen.c 2008-03-03 14:54:20.000000000 +0100 @@ -17,7 +17,6 @@ #include #include -#include #include #ifdef CONFIG_ACPI @@ -74,7 +73,7 @@ void __init setup_apic_routing(void) /* Same for both flat and physical. */ #ifdef CONFIG_XEN -extern void xen_send_IPI_shortcut(unsigned int shortcut, int vector, unsigned int dest); +extern void xen_send_IPI_shortcut(unsigned int shortcut, int vector); #endif void send_IPI_self(int vector) @@ -82,6 +81,6 @@ void send_IPI_self(int vector) #ifndef CONFIG_XEN __send_IPI_shortcut(APIC_DEST_SELF, vector, APIC_DEST_PHYSICAL); #else - xen_send_IPI_shortcut(APIC_DEST_SELF, vector, APIC_DEST_PHYSICAL); + xen_send_IPI_shortcut(APIC_DEST_SELF, vector); #endif } Index: head-2008-03-11/arch/x86/kernel/genapic_xen_64.c =================================================================== --- head-2008-03-11.orig/arch/x86/kernel/genapic_xen_64.c 2008-03-13 12:24:15.000000000 +0100 +++ head-2008-03-11/arch/x86/kernel/genapic_xen_64.c 2008-03-05 14:31:39.000000000 +0100 @@ -18,7 +18,6 @@ #include #ifdef CONFIG_XEN_PRIVILEGED_GUEST #include -#include #else #include #endif @@ -34,7 +33,7 @@ static inline void __send_IPI_one(unsign notify_remote_via_irq(irq); } -void xen_send_IPI_shortcut(unsigned int shortcut, int vector, unsigned int dest) +void xen_send_IPI_shortcut(unsigned int shortcut, int vector) { int cpu; @@ -96,13 +95,13 @@ static void xen_send_IPI_allbutself(int */ Dprintk("%s\n", __FUNCTION__); if (num_online_cpus() > 1) - xen_send_IPI_shortcut(APIC_DEST_ALLBUT, vector, APIC_DEST_LOGICAL); + xen_send_IPI_shortcut(APIC_DEST_ALLBUT, vector); } static void xen_send_IPI_all(int vector) { Dprintk("%s\n", __FUNCTION__); - xen_send_IPI_shortcut(APIC_DEST_ALLINC, vector, APIC_DEST_LOGICAL); + xen_send_IPI_shortcut(APIC_DEST_ALLINC, vector); } static void xen_send_IPI_mask(cpumask_t cpumask, int vector) @@ -135,7 +134,7 @@ static int xen_apic_id_registered(void) static unsigned int xen_cpu_mask_to_apicid(cpumask_t cpumask) { Dprintk("%s\n", __FUNCTION__); - return cpus_addr(cpumask)[0] & APIC_ALL_CPUS; + return cpus_addr(cpumask)[0]; } static unsigned int phys_pkg_id(int index_msb) @@ -152,7 +151,7 @@ struct genapic apic_xen = { #ifdef CONFIG_XEN_PRIVILEGED_GUEST .int_delivery_mode = dest_LowestPrio, #endif - .int_dest_mode = (APIC_DEST_LOGICAL != 0), + .int_dest_mode = 1, .target_cpus = xen_target_cpus, .vector_allocation_domain = xen_vector_allocation_domain, #ifdef CONFIG_XEN_PRIVILEGED_GUEST Index: head-2008-03-11/arch/x86/kernel/io_apic_32-xen.c =================================================================== --- head-2008-03-11.orig/arch/x86/kernel/io_apic_32-xen.c 2008-03-13 12:24:15.000000000 +0100 +++ head-2008-03-11/arch/x86/kernel/io_apic_32-xen.c 2008-03-03 14:54:20.000000000 +0100 @@ -47,7 +47,6 @@ #include #include -#include #ifdef CONFIG_XEN #include @@ -61,10 +60,10 @@ unsigned long io_apic_irqs; #define clear_IO_APIC() ((void)0) -#endif /* CONFIG_XEN */ - +#else int (*ioapic_renumber_irq)(int ioapic, int irq); atomic_t irq_mis_count; +#endif /* CONFIG_XEN */ /* Where if anywhere is the i8259 connect in external int mode */ static struct { int pin, apic; } ioapic_i8259 = { -1, -1 }; @@ -72,7 +71,9 @@ static struct { int pin, apic; } ioapic_ static DEFINE_SPINLOCK(ioapic_lock); static DEFINE_SPINLOCK(vector_lock); +#ifndef CONFIG_XEN int timer_over_8254 __initdata = 1; +#endif /* * Is the SiS APIC rmw bug present ? @@ -85,7 +86,9 @@ int sis_apic_bug = -1; */ int nr_ioapic_registers[MAX_IO_APICS]; +#ifndef CONFIG_XEN static int disable_timer_pin_1 __initdata; +#endif /* * Rough estimation of how many shared IRQs there are, can @@ -1188,12 +1191,13 @@ static int pin_2_irq(int idx, int apic, irq += nr_ioapic_registers[i++]; irq += pin; +#ifndef CONFIG_XEN /* * For MPS mode, so far only needed by ES7000 platform */ if (ioapic_renumber_irq) irq = ioapic_renumber_irq(apic, irq); - +#endif break; } default: @@ -2383,6 +2387,7 @@ void __init setup_IO_APIC(void) print_IO_APIC(); } +#ifndef CONFIG_XEN static int __init setup_disable_8254_timer(char *s) { timer_over_8254 = -1; @@ -2396,6 +2401,7 @@ static int __init setup_enable_8254_time __setup("disable_8254_timer", setup_disable_8254_timer); __setup("enable_8254_timer", setup_enable_8254_timer); +#endif /* * Called after all the initialization is done. If we didnt find any @@ -2924,6 +2930,7 @@ int acpi_get_override_irq(int bus_irq, i #endif /* CONFIG_ACPI */ +#ifndef CONFIG_XEN static int __init parse_disable_timer_pin_1(char *arg) { disable_timer_pin_1 = 1; @@ -2937,6 +2944,7 @@ static int __init parse_enable_timer_pin return 0; } early_param("enable_timer_pin_1", parse_enable_timer_pin_1); +#endif static int __init parse_noapic(char *arg) { Index: head-2008-03-11/arch/x86/kernel/io_apic_64-xen.c =================================================================== --- head-2008-03-11.orig/arch/x86/kernel/io_apic_64-xen.c 2008-03-13 12:24:15.000000000 +0100 +++ head-2008-03-11/arch/x86/kernel/io_apic_64-xen.c 2008-03-03 14:54:20.000000000 +0100 @@ -69,10 +69,6 @@ static int assign_irq_vector(int irq, cp int sis_apic_bug; /* not actually supported, dummy for compile */ -static int no_timer_check; - -static int disable_timer_pin_1 __initdata; - #ifdef CONFIG_XEN #include #include @@ -86,6 +82,10 @@ unsigned long io_apic_irqs; #define clear_IO_APIC() ((void)0) #else +static int no_timer_check; + +static int disable_timer_pin_1 __initdata; + int timer_over_8254 __initdata = 1; /* Where if anywhere is the i8259 connect in external int mode */ @@ -439,6 +439,7 @@ static int __init parse_noapic(char *str } early_param("noapic", parse_noapic); +#ifndef CONFIG_XEN /* Actually the next is obsolete, but keep it for paranoid reasons -AK */ static int __init disable_timer_pin_setup(char *arg) { @@ -447,7 +448,6 @@ static int __init disable_timer_pin_setu } __setup("disable_timer_pin_1", disable_timer_pin_setup); -#ifndef CONFIG_XEN static int __init setup_disable_8254_timer(char *s) { timer_over_8254 = -1; @@ -1769,10 +1769,6 @@ static inline void __init check_timer(vo out: local_irq_restore(flags); } -#else -#define check_timer() ((void)0) -int timer_uses_ioapic_pin_0 = 0; -#endif /* !CONFIG_XEN */ static int __init notimercheck(char *s) { @@ -1780,6 +1776,10 @@ static int __init notimercheck(char *s) return 1; } __setup("no_timer_check", notimercheck); +#else +#define check_timer() ((void)0) +int timer_uses_ioapic_pin_0 = 0; +#endif /* !CONFIG_XEN */ /* * Index: head-2008-03-11/arch/x86/kernel/irq_32-xen.c =================================================================== --- head-2008-03-11.orig/arch/x86/kernel/irq_32-xen.c 2008-03-13 12:24:15.000000000 +0100 +++ head-2008-03-11/arch/x86/kernel/irq_32-xen.c 2008-03-03 14:54:20.000000000 +0100 @@ -235,7 +235,9 @@ asmlinkage void do_softirq(void) * Interrupt statistics: */ +#ifndef CONFIG_XEN atomic_t irq_err_count; +#endif /* * /proc/interrupts printing: @@ -291,7 +293,7 @@ skip: for_each_online_cpu(j) seq_printf(p, "%10u ", nmi_count(j)); seq_printf(p, " Non-maskable interrupts\n"); -#ifdef CONFIG_X86_LOCAL_APIC +#if defined(CONFIG_X86_LOCAL_APIC) && !defined(CONFIG_XEN) seq_printf(p, "LOC: "); for_each_online_cpu(j) seq_printf(p, "%10u ", @@ -324,6 +326,7 @@ skip: per_cpu(irq_stat,j).irq_thermal_count); seq_printf(p, " Thermal event interrupts\n"); #endif +#ifndef CONFIG_XEN #ifdef CONFIG_X86_LOCAL_APIC seq_printf(p, "SPU: "); for_each_online_cpu(j) @@ -335,6 +338,7 @@ skip: #if defined(CONFIG_X86_IO_APIC) seq_printf(p, "MIS: %10u\n", atomic_read(&irq_mis_count)); #endif +#endif } return 0; } Index: head-2008-03-11/arch/x86/kernel/irq_64-xen.c =================================================================== --- head-2008-03-11.orig/arch/x86/kernel/irq_64-xen.c 2008-03-13 12:24:15.000000000 +0100 +++ head-2008-03-11/arch/x86/kernel/irq_64-xen.c 2008-03-03 14:58:47.000000000 +0100 @@ -18,7 +18,9 @@ #include #include +#ifndef CONFIG_XEN atomic_t irq_err_count; +#endif /* * 'what should we do if we get a hw irq event on an illegal vector'. @@ -27,19 +29,6 @@ atomic_t irq_err_count; void ack_bad_irq(unsigned int irq) { printk(KERN_WARNING "unexpected IRQ trap at irq %02x\n", irq); -#ifdef CONFIG_X86_LOCAL_APIC - /* - * Currently unexpected vectors happen only on SMP and APIC. - * We _must_ ack these because every local APIC has only N - * irq slots per priority level, and a 'hanging, unacked' IRQ - * holds up an irq slot - in excessive cases (when multiple - * unexpected vectors occur) that might lock up the APIC - * completely. - * But don't ack when the APIC is disabled. -AK - */ - if (!disable_apic) - ack_APIC_irq(); -#endif } #ifdef CONFIG_DEBUG_STACKOVERFLOW @@ -119,7 +108,7 @@ skip: for_each_online_cpu(j) seq_printf(p, "%10u ", cpu_pda(j)->__nmi_count); seq_printf(p, " Non-maskable interrupts\n"); -#ifdef CONFIG_X86_LOCAL_APIC +#if defined(CONFIG_X86_LOCAL_APIC) && !defined(CONFIG_XEN) seq_printf(p, "LOC: "); for_each_online_cpu(j) seq_printf(p, "%10u ", cpu_pda(j)->apic_timer_irqs); @@ -151,6 +140,7 @@ skip: seq_printf(p, "%10u ", cpu_pda(j)->irq_threshold_count); seq_printf(p, " Threshold APIC interrupts\n"); #endif +#ifndef CONFIG_XEN #ifdef CONFIG_X86_LOCAL_APIC seq_printf(p, "SPU: "); for_each_online_cpu(j) @@ -158,6 +148,7 @@ skip: seq_printf(p, " Spurious interrupts\n"); #endif seq_printf(p, "ERR: %10u\n", atomic_read(&irq_err_count)); +#endif } return 0; } Index: head-2008-03-11/arch/x86/kernel/mpparse_32-xen.c =================================================================== --- head-2008-03-11.orig/arch/x86/kernel/mpparse_32-xen.c 2008-03-13 12:24:15.000000000 +0100 +++ head-2008-03-11/arch/x86/kernel/mpparse_32-xen.c 2008-03-10 13:19:37.000000000 +0100 @@ -29,7 +29,6 @@ #include #include -#include #include #include @@ -61,7 +60,9 @@ int mp_irq_entries; int nr_ioapics; int pic_mode; +#ifndef CONFIG_XEN unsigned long mp_lapic_addr; +#endif unsigned int def_to_bigsmp = 0; @@ -412,6 +413,7 @@ static int __init smp_read_mpc(struct mp mps_oem_check(mpc, oem, str); +#ifndef CONFIG_XEN printk("APIC at: 0x%X\n", mpc->mpc_lapic); /* @@ -420,6 +422,7 @@ static int __init smp_read_mpc(struct mp */ if (!acpi_lapic) mp_lapic_addr = mpc->mpc_lapic; +#endif /* * Now process the configuration blocks. @@ -572,10 +575,12 @@ static inline void __init construct_defa int linttypes[2] = { mp_ExtINT, mp_NMI }; int i; +#ifndef CONFIG_XEN /* * local APIC has default address */ mp_lapic_addr = APIC_DEFAULT_PHYS_BASE; +#endif /* * 2 CPUs, numbered 0 & 1. @@ -827,9 +832,9 @@ int es7000_plat; #ifdef CONFIG_ACPI +#ifndef CONFIG_XEN void __init mp_register_lapic_address(u64 address) { -#ifndef CONFIG_XEN mp_lapic_addr = (unsigned long) address; set_fixmap_nocache(FIX_APIC_BASE, mp_lapic_addr); @@ -838,8 +843,8 @@ void __init mp_register_lapic_address(u6 boot_cpu_physical_apicid = GET_APIC_ID(apic_read(APIC_ID)); Dprintk("Boot CPU = %d\n", boot_cpu_physical_apicid); -#endif } +#endif void __cpuinit mp_register_lapic (u8 id, u8 enabled) { @@ -923,11 +928,11 @@ void __init mp_register_ioapic(u8 id, u3 #ifndef CONFIG_XEN set_fixmap_nocache(FIX_IO_APIC_BASE_0 + idx, address); -#endif if ((boot_cpu_data.x86_vendor == X86_VENDOR_INTEL) && !APIC_XAPIC(apic_version[boot_cpu_physical_apicid])) tmpid = io_apic_get_unique_id(idx, id); else +#endif tmpid = id; if (tmpid == -1) { nr_ioapics--; @@ -1092,8 +1097,10 @@ int mp_register_gsi(u32 gsi, int trigger ioapic_pin = gsi - mp_ioapic_routing[ioapic].gsi_base; +#ifndef CONFIG_XEN if (ioapic_renumber_irq) gsi = ioapic_renumber_irq(ioapic, gsi); +#endif /* * Avoid pin reprogramming. PRTs typically include entries Index: head-2008-03-11/arch/x86/kernel/mpparse_64-xen.c =================================================================== --- head-2008-03-11.orig/arch/x86/kernel/mpparse_64-xen.c 2008-03-13 12:24:15.000000000 +0100 +++ head-2008-03-11/arch/x86/kernel/mpparse_64-xen.c 2008-03-03 14:54:20.000000000 +0100 @@ -51,8 +51,9 @@ struct mpc_config_intsrc mp_irqs[MAX_IRQ int mp_irq_entries; int nr_ioapics; +#ifndef CONFIG_XEN unsigned long mp_lapic_addr = 0; - +#endif /* Processor that is doing the boot up */ @@ -262,11 +263,13 @@ static int __init smp_read_mpc(struct mp str[12] = 0; printk("MPTABLE: Product ID: %s ",str); +#ifndef CONFIG_XEN printk("MPTABLE: APIC at: 0x%X\n",mpc->mpc_lapic); /* save the local APIC address, it might be non-default */ if (!acpi_lapic) mp_lapic_addr = mpc->mpc_lapic; +#endif /* * Now process the configuration blocks. @@ -411,10 +414,12 @@ static inline void __init construct_defa int linttypes[2] = { mp_ExtINT, mp_NMI }; int i; +#ifndef CONFIG_XEN /* * local APIC has default address */ mp_lapic_addr = APIC_DEFAULT_PHYS_BASE; +#endif /* * 2 CPUs, numbered 0 & 1. @@ -615,15 +620,15 @@ void __init find_smp_config(void) #ifdef CONFIG_ACPI +#ifndef CONFIG_XEN void __init mp_register_lapic_address(u64 address) { -#ifndef CONFIG_XEN mp_lapic_addr = (unsigned long) address; set_fixmap_nocache(FIX_APIC_BASE, mp_lapic_addr); if (boot_cpu_id == -1U) boot_cpu_id = GET_APIC_ID(apic_read(APIC_ID)); -#endif } +#endif void __cpuinit mp_register_lapic (u8 id, u8 enabled) { Index: head-2008-03-11/arch/x86/kernel/smp_32-xen.c =================================================================== --- head-2008-03-11.orig/arch/x86/kernel/smp_32-xen.c 2008-03-13 12:24:15.000000000 +0100 +++ head-2008-03-11/arch/x86/kernel/smp_32-xen.c 2008-03-03 14:54:20.000000000 +0100 @@ -115,6 +115,7 @@ DEFINE_PER_CPU(struct tlb_state, cpu_tlb * We use 'broadcast', CPU->CPU IPIs and self-IPIs too. */ +#ifndef CONFIG_XEN static inline int __prepare_ICR (unsigned int shortcut, int vector) { unsigned int icr = shortcut | APIC_DEST_LOGICAL; @@ -134,6 +135,7 @@ static inline int __prepare_ICR2 (unsign { return SET_APIC_DEST_FIELD(mask); } +#endif DECLARE_PER_CPU(int, ipi_to_irq[NR_IPIS]); Index: head-2008-03-11/arch/x86/kernel/traps_64-xen.c =================================================================== --- head-2008-03-11.orig/arch/x86/kernel/traps_64-xen.c 2008-03-06 10:52:57.000000000 +0100 +++ head-2008-03-11/arch/x86/kernel/traps_64-xen.c 2008-03-03 14:54:20.000000000 +0100 @@ -1160,15 +1160,15 @@ asmlinkage void do_spurious_interrupt_bu { } -#if 0 +#ifndef CONFIG_XEN asmlinkage void __attribute__((weak)) smp_thermal_interrupt(void) { } -#endif asmlinkage void __attribute__((weak)) mce_threshold_interrupt(void) { } +#endif /* * 'math_state_restore()' saves the current math information in the Index: head-2008-03-11/include/asm-x86/apic.h =================================================================== --- head-2008-03-11.orig/include/asm-x86/apic.h 2008-03-13 12:24:15.000000000 +0100 +++ head-2008-03-11/include/asm-x86/apic.h 2008-03-03 15:17:31.000000000 +0100 @@ -3,7 +3,9 @@ #include #include +#ifndef CONFIG_XEN #include +#endif #include #include #include @@ -38,6 +40,7 @@ extern void generic_apic_probe(void); #ifdef CONFIG_X86_LOCAL_APIC extern int apic_verbosity; +#ifndef CONFIG_XEN extern int timer_over_8254; extern int local_apic_timer_c2_ok; extern int local_apic_timer_disabled; @@ -102,6 +105,7 @@ static inline void ack_APIC_irq(void) /* Docs say use 0 for future compatibility */ apic_write_around(APIC_EOI, 0); } +#endif extern int lapic_get_maxlvt(void); extern void clear_local_APIC(void); Index: head-2008-03-11/include/asm-x86/apicdef.h =================================================================== --- head-2008-03-11.orig/include/asm-x86/apicdef.h 2008-03-13 12:24:15.000000000 +0100 +++ head-2008-03-11/include/asm-x86/apicdef.h 2008-03-04 14:23:56.000000000 +0100 @@ -1,6 +1,8 @@ #ifndef _ASM_X86_APICDEF_H #define _ASM_X86_APICDEF_H +#ifndef CONFIG_XEN + /* * Constants for various Intel APICs. (local APIC, IOAPIC, etc.) * @@ -131,6 +133,16 @@ #define APIC_BASE (fix_to_virt(FIX_APIC_BASE)) +#else /* CONFIG_XEN */ + +enum { + APIC_DEST_ALLBUT = 0x1, + APIC_DEST_SELF, + APIC_DEST_ALLINC +}; + +#endif /* CONFIG_XEN */ + #ifdef CONFIG_X86_32 # define MAX_IO_APICS 64 #else @@ -138,6 +150,8 @@ # define MAX_LOCAL_APIC 256 #endif +#ifndef CONFIG_XEN + /* * All x86-64 systems are xAPIC compatible. * In the following, "apicid" is a physical APIC ID. @@ -408,6 +422,8 @@ struct local_apic { #undef u32 +#endif /* CONFIG_XEN */ + #define BAD_APICID 0xFFu #endif Index: head-2008-03-11/include/asm-x86/ipi.h =================================================================== --- head-2008-03-11.orig/include/asm-x86/ipi.h 2008-01-24 23:58:37.000000000 +0100 +++ head-2008-03-11/include/asm-x86/ipi.h 2008-03-03 14:54:20.000000000 +0100 @@ -1,6 +1,8 @@ #ifndef __ASM_IPI_H #define __ASM_IPI_H +#ifndef CONFIG_XEN + /* * Copyright 2004 James Cleverdon, IBM. * Subject to the GNU Public License, v.2 @@ -125,4 +127,6 @@ static inline void send_IPI_mask_sequenc local_irq_restore(flags); } +#endif /* CONFIG_XEN */ + #endif /* __ASM_IPI_H */ Index: head-2008-03-11/include/asm-x86/mach-xen/asm/fixmap_32.h =================================================================== --- head-2008-03-11.orig/include/asm-x86/mach-xen/asm/fixmap_32.h 2008-03-13 12:24:15.000000000 +0100 +++ head-2008-03-11/include/asm-x86/mach-xen/asm/fixmap_32.h 2008-03-03 14:54:20.000000000 +0100 @@ -55,13 +55,15 @@ enum fixed_addresses { FIX_VDSO, FIX_DBGP_BASE, FIX_EARLYCON_MEM_BASE, +#ifndef CONFIG_XEN #ifdef CONFIG_X86_LOCAL_APIC FIX_APIC_BASE, /* local (CPU) APIC) -- required for SMP or not */ #endif -#if defined(CONFIG_X86_IO_APIC) && !defined(CONFIG_XEN) +#ifdef CONFIG_X86_IO_APIC FIX_IO_APIC_BASE_0, FIX_IO_APIC_BASE_END = FIX_IO_APIC_BASE_0 + MAX_IO_APICS-1, #endif +#endif #ifdef CONFIG_X86_VISWS_APIC FIX_CO_CPU, /* Cobalt timer */ FIX_CO_APIC, /* Cobalt APIC Redirection Table */ Index: head-2008-03-11/include/asm-x86/mach-xen/asm/fixmap_64.h =================================================================== --- head-2008-03-11.orig/include/asm-x86/mach-xen/asm/fixmap_64.h 2008-03-13 12:24:15.000000000 +0100 +++ head-2008-03-11/include/asm-x86/mach-xen/asm/fixmap_64.h 2008-03-13 12:24:37.000000000 +0100 @@ -12,7 +12,6 @@ #define _ASM_FIXMAP_H #include -#include #include #include #include @@ -40,10 +39,8 @@ enum fixed_addresses { FIX_DBGP_BASE, FIX_EARLYCON_MEM_BASE, FIX_HPET_BASE, -#ifdef CONFIG_X86_LOCAL_APIC - FIX_APIC_BASE, /* local (CPU) APIC) -- required for SMP or not */ -#endif #ifndef CONFIG_XEN + FIX_APIC_BASE, /* local (CPU) APIC) -- required for SMP or not */ FIX_IO_APIC_BASE_0, FIX_IO_APIC_BASE_END = FIX_IO_APIC_BASE_0 + MAX_IO_APICS-1, #endif Index: head-2008-03-11/include/asm-x86/mach-xen/asm/hw_irq_32.h =================================================================== --- head-2008-03-11.orig/include/asm-x86/mach-xen/asm/hw_irq_32.h 2008-03-13 12:24:15.000000000 +0100 +++ head-2008-03-11/include/asm-x86/mach-xen/asm/hw_irq_32.h 2008-03-03 14:54:20.000000000 +0100 @@ -17,8 +17,6 @@ #include #include -#define NMI_VECTOR 0x02 - /* * Various low-level irq details needed by irq.c, process.c, * time.c, io_apic.c and smp.c @@ -58,9 +56,6 @@ void setup_ioapic_dest(void); extern unsigned long io_apic_irqs; -extern atomic_t irq_err_count; -extern atomic_t irq_mis_count; - #define IO_APIC_IRQ(x) (((x) >= 16) || ((1<<(x)) & io_apic_irqs)) #endif /* _ASM_HW_IRQ_H */ Index: head-2008-03-11/include/asm-x86/mach-xen/asm/hw_irq_64.h =================================================================== --- head-2008-03-11.orig/include/asm-x86/mach-xen/asm/hw_irq_64.h 2008-03-13 12:24:15.000000000 +0100 +++ head-2008-03-11/include/asm-x86/mach-xen/asm/hw_irq_64.h 2008-03-03 14:54:20.000000000 +0100 @@ -22,7 +22,6 @@ #include #endif -#define NMI_VECTOR 0x02 /* * IDT vectors usable for external interrupt sources start * at 0x20: @@ -147,9 +146,6 @@ extern void native_init_IRQ(void); extern unsigned long io_apic_irqs; -extern atomic_t irq_err_count; -extern atomic_t irq_mis_count; - #define IO_APIC_IRQ(x) (((x) >= 16) || ((1<<(x)) & io_apic_irqs)) #include Index: head-2008-03-11/include/asm-x86/mach-xen/asm/smp_32.h =================================================================== --- head-2008-03-11.orig/include/asm-x86/mach-xen/asm/smp_32.h 2008-03-13 12:24:15.000000000 +0100 +++ head-2008-03-11/include/asm-x86/mach-xen/asm/smp_32.h 2008-03-11 18:01:40.000000000 +0100 @@ -147,7 +147,7 @@ static inline int num_booting_cpus(void) #endif /* !CONFIG_SMP */ -#ifdef CONFIG_X86_LOCAL_APIC +#if defined(CONFIG_X86_LOCAL_APIC) && !defined(CONFIG_XEN) static __inline int logical_smp_processor_id(void) { Index: head-2008-03-11/include/asm-x86/mach-xen/asm/smp_64.h =================================================================== --- head-2008-03-11.orig/include/asm-x86/mach-xen/asm/smp_64.h 2008-03-13 12:24:15.000000000 +0100 +++ head-2008-03-11/include/asm-x86/mach-xen/asm/smp_64.h 2008-03-03 15:14:55.000000000 +0100 @@ -3,6 +3,7 @@ #include #include +#include #ifdef CONFIG_X86_LOCAL_APIC /* @@ -15,7 +16,6 @@ #include #endif #include -#include extern cpumask_t cpu_initialized; @@ -85,7 +85,7 @@ extern unsigned int boot_cpu_id; #define safe_smp_processor_id() smp_processor_id() -#ifdef CONFIG_X86_LOCAL_APIC +#if defined(CONFIG_X86_LOCAL_APIC) && !defined(CONFIG_XEN) static __inline int logical_smp_processor_id(void) { /* we don't want to mark this access volatile - bad code generation */ Index: head-2008-03-11/include/asm-x86/mach-xen/irq_vectors.h =================================================================== --- head-2008-03-11.orig/include/asm-x86/mach-xen/irq_vectors.h 2008-03-13 12:24:15.000000000 +0100 +++ head-2008-03-11/include/asm-x86/mach-xen/irq_vectors.h 2008-03-03 14:54:20.000000000 +0100 @@ -34,7 +34,7 @@ * Vectors 0x20-0x2f are used for ISA interrupts. */ -#if 0 +#ifndef CONFIG_XEN /* * Special IRQ vectors used by the SMP architecture, 0xf0-0xff * @@ -57,7 +57,6 @@ * sources per level' errata. */ #define LOCAL_TIMER_VECTOR 0xef -#endif #define SPURIOUS_APIC_VECTOR 0xff #define ERROR_APIC_VECTOR 0xfe @@ -79,6 +78,7 @@ * Since vectors 0x00-0x1f are used/reserved for the CPU, * the usable vector space is 0x20-0xff (224 vectors) */ +#endif #define RESCHEDULE_VECTOR 0 #define CALL_FUNCTION_VECTOR 1 Index: head-2008-03-11/include/asm-x86/mach-xen/mach_apic.h =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 +++ head-2008-03-11/include/asm-x86/mach-xen/mach_apic.h 2008-03-05 14:55:03.000000000 +0100 @@ -0,0 +1,34 @@ +#ifndef __ASM_MACH_APIC_H +#define __ASM_MACH_APIC_H + +#include + +#ifdef CONFIG_SMP +#define TARGET_CPUS cpu_online_map +#else +#define TARGET_CPUS cpumask_of_cpu(0) +#endif + +#define INT_DELIVERY_MODE dest_LowestPrio +#define INT_DEST_MODE 1 + +static inline void setup_apic_routing(void) +{ +} + +static inline int multi_timer_check(int apic, int irq) +{ + return 0; +} + +static inline int apicid_to_node(int logical_apicid) +{ + return 0; +} + +static inline unsigned int cpu_mask_to_apicid(cpumask_t cpumask) +{ + return cpus_addr(cpumask)[0]; +} + +#endif /* __ASM_MACH_APIC_H */