From: Zachary Amsden Make GDT page aligned and page padded to support running inside of a hypervisor. This prevents false sharing of the GDT page with other hot data, which is not allowed in Xen, and causes performance problems in VMware. Rather than go back to the old method of statically allocating the GDT (which wastes unneded space for non-present CPUs), the GDT for APs is allocated dynamically. Signed-off-by: Zachary Amsden Acked-by: Ingo Molnar Signed-off-by: Andrew Morton --- arch/i386/kernel/cpu/common.c | 3 --- arch/i386/kernel/head.S | 2 ++ arch/i386/kernel/i386_ksyms.c | 3 +-- arch/i386/kernel/smpboot.c | 1 + include/asm-i386/desc.h | 5 ++--- 5 files changed, 6 insertions(+), 8 deletions(-) diff -puN arch/i386/kernel/cpu/common.c~x86-gdt-page-isolation arch/i386/kernel/cpu/common.c --- devel/arch/i386/kernel/cpu/common.c~x86-gdt-page-isolation 2005-10-11 00:34:42.000000000 -0700 +++ devel-akpm/arch/i386/kernel/cpu/common.c 2005-10-11 00:34:42.000000000 -0700 @@ -18,9 +18,6 @@ #include "cpu.h" -DEFINE_PER_CPU(struct desc_struct, cpu_gdt_table[GDT_ENTRIES]); -EXPORT_PER_CPU_SYMBOL(cpu_gdt_table); - DEFINE_PER_CPU(unsigned char, cpu_16bit_stack[CPU_16BIT_STACK_SIZE]); EXPORT_PER_CPU_SYMBOL(cpu_16bit_stack); diff -puN arch/i386/kernel/head.S~x86-gdt-page-isolation arch/i386/kernel/head.S --- devel/arch/i386/kernel/head.S~x86-gdt-page-isolation 2005-10-11 00:34:42.000000000 -0700 +++ devel-akpm/arch/i386/kernel/head.S 2005-10-11 00:34:42.000000000 -0700 @@ -525,3 +525,5 @@ ENTRY(cpu_gdt_table) .quad 0x0000000000000000 /* 0xf0 - unused */ .quad 0x0000000000000000 /* 0xf8 - GDT entry 31: double-fault TSS */ + /* Be sure this is zeroed to avoid false validations in Xen */ + .fill PAGE_SIZE_asm / 8 - GDT_ENTRIES,8,0 diff -puN arch/i386/kernel/i386_ksyms.c~x86-gdt-page-isolation arch/i386/kernel/i386_ksyms.c --- devel/arch/i386/kernel/i386_ksyms.c~x86-gdt-page-isolation 2005-10-11 00:34:42.000000000 -0700 +++ devel-akpm/arch/i386/kernel/i386_ksyms.c 2005-10-11 00:34:42.000000000 -0700 @@ -3,8 +3,7 @@ #include #include -/* This is definitely a GPL-only symbol */ -EXPORT_SYMBOL_GPL(cpu_gdt_table); +EXPORT_SYMBOL_GPL(cpu_gdt_descr); EXPORT_SYMBOL(__down_failed); EXPORT_SYMBOL(__down_failed_interruptible); diff -puN arch/i386/kernel/smpboot.c~x86-gdt-page-isolation arch/i386/kernel/smpboot.c --- devel/arch/i386/kernel/smpboot.c~x86-gdt-page-isolation 2005-10-11 00:34:42.000000000 -0700 +++ devel-akpm/arch/i386/kernel/smpboot.c 2005-10-11 00:34:42.000000000 -0700 @@ -901,6 +901,7 @@ static int __devinit do_boot_cpu(int api * This grunge runs the startup process for * the targeted processor. */ + cpu_gdt_descr[cpu].address = __get_free_page(GFP_KERNEL|__GFP_ZERO); atomic_set(&init_deasserted, 0); diff -puN include/asm-i386/desc.h~x86-gdt-page-isolation include/asm-i386/desc.h --- devel/include/asm-i386/desc.h~x86-gdt-page-isolation 2005-10-11 00:34:42.000000000 -0700 +++ devel-akpm/include/asm-i386/desc.h 2005-10-11 00:34:42.000000000 -0700 @@ -15,9 +15,6 @@ #include extern struct desc_struct cpu_gdt_table[GDT_ENTRIES]; -DECLARE_PER_CPU(struct desc_struct, cpu_gdt_table[GDT_ENTRIES]); - -#define get_cpu_gdt_table(_cpu) (per_cpu(cpu_gdt_table,_cpu)) DECLARE_PER_CPU(unsigned char, cpu_16bit_stack[CPU_16BIT_STACK_SIZE]); @@ -29,6 +26,8 @@ struct Xgt_desc_struct { extern struct Xgt_desc_struct idt_descr, cpu_gdt_descr[NR_CPUS]; +#define get_cpu_gdt_table(_cpu) ((struct desc_struct *)cpu_gdt_descr[(_cpu)].address) + #define load_TR_desc() __asm__ __volatile__("ltr %w0"::"q" (GDT_ENTRY_TSS*8)) #define load_LDT_desc() __asm__ __volatile__("lldt %w0"::"q" (GDT_ENTRY_LDT*8)) _