Subject: Disallow all accesses to the IO-APIC pages Index: 2006-07-27/arch/i386/kernel/io_apic-xen.c =================================================================== --- 2006-07-27.orig/arch/i386/kernel/io_apic-xen.c 2006-07-27 15:39:18.838609544 +0200 +++ 2006-07-27/arch/i386/kernel/io_apic-xen.c 2006-07-27 15:41:37.676502976 +0200 @@ -45,9 +45,6 @@ #ifdef CONFIG_XEN -#include -#include - /* Fake i8259 */ #define make_8259A_irq(_irq) (io_apic_irqs &= ~(1UL<<(_irq))) #define disable_8259A_irq(_irq) ((void)0) @@ -55,32 +52,6 @@ unsigned long io_apic_irqs; -static inline unsigned int xen_io_apic_read(unsigned int apic, unsigned int reg) -{ - struct physdev_apic apic_op; - int ret; - - apic_op.apic_physbase = mp_ioapics[apic].mpc_apicaddr; - apic_op.reg = reg; - ret = HYPERVISOR_physdev_op(PHYSDEVOP_apic_read, &apic_op); - if (ret) - return ret; - return apic_op.value; -} - -static inline void xen_io_apic_write(unsigned int apic, unsigned int reg, unsigned int value) -{ - struct physdev_apic apic_op; - - apic_op.apic_physbase = mp_ioapics[apic].mpc_apicaddr; - apic_op.reg = reg; - apic_op.value = value; - HYPERVISOR_physdev_op(PHYSDEVOP_apic_write, &apic_op); -} - -#define io_apic_read(a,r) xen_io_apic_read(a,r) -#define io_apic_write(a,r,v) xen_io_apic_write(a,r,v) - #endif /* CONFIG_XEN */ int (*ioapic_renumber_irq)(int ioapic, int irq); Index: 2006-07-27/arch/x86_64/kernel/io_apic-xen.c =================================================================== --- 2006-07-27.orig/arch/x86_64/kernel/io_apic-xen.c 2006-07-27 15:39:18.866605288 +0200 +++ 2006-07-27/arch/x86_64/kernel/io_apic-xen.c 2006-07-27 15:43:06.571988808 +0200 @@ -92,9 +92,6 @@ int vector_irq[NR_VECTORS] __read_mostly #ifdef CONFIG_XEN -#include -#include - /* Fake i8259 */ #define make_8259A_irq(_irq) (io_apic_irqs &= ~(1UL<<(_irq))) #define disable_8259A_irq(_irq) ((void)0) @@ -102,32 +99,6 @@ int vector_irq[NR_VECTORS] __read_mostly unsigned long io_apic_irqs; -static inline unsigned int xen_io_apic_read(unsigned int apic, unsigned int reg) -{ - struct physdev_apic apic_op; - int ret; - - apic_op.apic_physbase = mp_ioapics[apic].mpc_apicaddr; - apic_op.reg = reg; - ret = HYPERVISOR_physdev_op(PHYSDEVOP_apic_read, &apic_op); - if (ret) - return ret; - return apic_op.value; -} - -static inline void xen_io_apic_write(unsigned int apic, unsigned int reg, unsigned int value) -{ - struct physdev_apic apic_op; - - apic_op.apic_physbase = mp_ioapics[apic].mpc_apicaddr; - apic_op.reg = reg; - apic_op.value = value; - HYPERVISOR_physdev_op(PHYSDEVOP_apic_write, &apic_op); -} - -#define io_apic_read(a,r) xen_io_apic_read(a,r) -#define io_apic_write(a,r,v) xen_io_apic_write(a,r,v) - #define clear_IO_APIC() ((void)0) #else Index: 2006-07-27/include/asm-i386/io_apic.h =================================================================== --- 2006-07-27.orig/include/asm-i386/io_apic.h 2006-03-20 06:53:29.000000000 +0100 +++ 2006-07-27/include/asm-i386/io_apic.h 2006-07-27 15:41:28.782855016 +0200 @@ -53,9 +53,14 @@ static inline void end_edge_ioapic_irq ( #define end_edge_ioapic end_edge_ioapic_irq #endif +#ifndef CONFIG_XEN #define IO_APIC_BASE(idx) \ ((volatile int *)(__fix_to_virt(FIX_IO_APIC_BASE_0 + idx) \ + (mp_ioapics[idx].mpc_apicaddr & ~PAGE_MASK))) +#else +#include +#include +#endif /* * The structure of the IO-APIC: @@ -162,14 +167,35 @@ extern int mpc_default_type; static inline unsigned int io_apic_read(unsigned int apic, unsigned int reg) { +#ifndef CONFIG_XEN *IO_APIC_BASE(apic) = reg; return *(IO_APIC_BASE(apic)+4); +#else + struct physdev_apic apic_op; + int ret; + + apic_op.apic_physbase = mp_ioapics[apic].mpc_apicaddr; + apic_op.reg = reg; + ret = HYPERVISOR_physdev_op(PHYSDEVOP_apic_read, &apic_op); + if (ret) + return ret; + return apic_op.value; +#endif } static inline void io_apic_write(unsigned int apic, unsigned int reg, unsigned int value) { +#ifndef CONFIG_XEN *IO_APIC_BASE(apic) = reg; *(IO_APIC_BASE(apic)+4) = value; +#else + struct physdev_apic apic_op; + + apic_op.apic_physbase = mp_ioapics[apic].mpc_apicaddr; + apic_op.reg = reg; + apic_op.value = value; + HYPERVISOR_physdev_op(PHYSDEVOP_apic_write, &apic_op); +#endif } /* @@ -179,12 +205,16 @@ static inline void io_apic_write(unsigne * Older SiS APIC requires we rewrite the index regiser */ extern int sis_apic_bug; +#ifndef CONFIG_XEN static inline void io_apic_modify(unsigned int apic, unsigned int reg, unsigned int value) { if (sis_apic_bug) *IO_APIC_BASE(apic) = reg; *(IO_APIC_BASE(apic)+4) = value; } +#else +#define io_apic_modify io_apic_write +#endif /* 1 if "noapic" boot option passed */ extern int skip_ioapic_setup; Index: 2006-07-27/include/asm-i386/mach-xen/asm/fixmap.h =================================================================== --- 2006-07-27.orig/include/asm-i386/mach-xen/asm/fixmap.h 2006-07-27 15:39:18.880603160 +0200 +++ 2006-07-27/include/asm-i386/mach-xen/asm/fixmap.h 2006-07-27 15:39:21.141259488 +0200 @@ -53,13 +53,15 @@ extern unsigned long __FIXADDR_TOP; */ enum fixed_addresses { FIX_HOLE, -#if defined(CONFIG_X86_LOCAL_APIC) && !defined(CONFIG_XEN) +#ifndef CONFIG_XEN +#ifdef CONFIG_X86_LOCAL_APIC FIX_APIC_BASE, /* local (CPU) APIC) -- required for SMP or not */ #endif #ifdef CONFIG_X86_IO_APIC FIX_IO_APIC_BASE_0, FIX_IO_APIC_BASE_END = FIX_IO_APIC_BASE_0 + MAX_IO_APICS-1, #endif +#endif #ifdef CONFIG_X86_VISWS_APIC FIX_CO_CPU, /* Cobalt timer */ FIX_CO_APIC, /* Cobalt APIC Redirection Table */ Index: 2006-07-27/include/asm-x86_64/io_apic.h =================================================================== --- 2006-07-27.orig/include/asm-x86_64/io_apic.h 2006-03-20 06:53:29.000000000 +0100 +++ 2006-07-27/include/asm-x86_64/io_apic.h 2006-07-27 15:42:44.014418080 +0200 @@ -55,9 +55,14 @@ static inline void end_edge_ioapic_irq ( #define APIC_MISMATCH_DEBUG +#ifndef CONFIG_XEN #define IO_APIC_BASE(idx) \ ((volatile int *)(__fix_to_virt(FIX_IO_APIC_BASE_0 + idx) \ + (mp_ioapics[idx].mpc_apicaddr & ~PAGE_MASK))) +#else +#include +#include +#endif /* * The structure of the IO-APIC: @@ -164,16 +169,39 @@ extern int mpc_default_type; static inline unsigned int io_apic_read(unsigned int apic, unsigned int reg) { +#ifndef CONFIG_XEN *IO_APIC_BASE(apic) = reg; return *(IO_APIC_BASE(apic)+4); +#else + struct physdev_apic apic_op; + int ret; + + apic_op.apic_physbase = mp_ioapics[apic].mpc_apicaddr; + apic_op.reg = reg; + ret = HYPERVISOR_physdev_op(PHYSDEVOP_apic_read, &apic_op); + if (ret) + return ret; + return apic_op.value; +#endif } static inline void io_apic_write(unsigned int apic, unsigned int reg, unsigned int value) { +#ifndef CONFIG_XEN *IO_APIC_BASE(apic) = reg; *(IO_APIC_BASE(apic)+4) = value; +#else + struct physdev_apic apic_op; + + apic_op.apic_physbase = mp_ioapics[apic].mpc_apicaddr; + apic_op.reg = reg; + apic_op.value = value; + HYPERVISOR_physdev_op(PHYSDEVOP_apic_write, &apic_op); +#endif } +#ifndef CONFIG_XEN + /* * Re-write a value: to be used for read-modify-write * cycles where the read already set up the index register. @@ -192,6 +220,10 @@ static inline void io_apic_sync(unsigned (void) *(IO_APIC_BASE(apic)+4); } +#else +#define io_apic_modify io_apic_write +#endif + /* 1 if "noapic" boot option passed */ extern int skip_ioapic_setup; Index: 2006-07-27/include/asm-x86_64/mach-xen/asm/fixmap.h =================================================================== --- 2006-07-27.orig/include/asm-x86_64/mach-xen/asm/fixmap.h 2006-07-27 15:39:18.890601640 +0200 +++ 2006-07-27/include/asm-x86_64/mach-xen/asm/fixmap.h 2006-07-27 15:39:21.178253864 +0200 @@ -40,13 +40,15 @@ enum fixed_addresses { VSYSCALL_FIRST_PAGE = VSYSCALL_LAST_PAGE + ((VSYSCALL_END-VSYSCALL_START) >> PAGE_SHIFT) - 1, VSYSCALL_HPET, FIX_HPET_BASE, -#if defined(CONFIG_X86_LOCAL_APIC) && !defined(CONFIG_XEN) +#ifndef CONFIG_XEN +#ifdef CONFIG_X86_LOCAL_APIC FIX_APIC_BASE, /* local (CPU) APIC) -- required for SMP or not */ #endif #ifdef CONFIG_X86_IO_APIC FIX_IO_APIC_BASE_0, FIX_IO_APIC_BASE_END = FIX_IO_APIC_BASE_0 + MAX_IO_APICS-1, #endif +#endif #ifdef CONFIG_ACPI FIX_ACPI_BEGIN, FIX_ACPI_END = FIX_ACPI_BEGIN + FIX_ACPI_PAGES - 1,