Commit 7a61d35d4b4056e7711031202da7605e052f4137
Committed by
Andi Kleen
1 parent
39b7ee0685
Exists in
master
and in
20 other branches
[PATCH] i386: Page-align the GDT
Xen wants a dedicated page for the GDT. I believe VMI likes it too. lguest, KVM and native don't care. Simple transformation to page-aligned "struct gdt_page". Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> Signed-off-by: Andi Kleen <ak@suse.de> Acked-by: Jeremy Fitzhardinge <jeremy@xensource.com>
Showing 5 changed files with 13 additions and 8 deletions Side-by-side Diff
arch/i386/kernel/cpu/common.c
... | ... | @@ -22,7 +22,7 @@ |
22 | 22 | |
23 | 23 | #include "cpu.h" |
24 | 24 | |
25 | -DEFINE_PER_CPU(struct desc_struct, cpu_gdt[GDT_ENTRIES]) = { | |
25 | +DEFINE_PER_CPU(struct gdt_page, gdt_page) = { .gdt = { | |
26 | 26 | [GDT_ENTRY_KERNEL_CS] = { 0x0000ffff, 0x00cf9a00 }, |
27 | 27 | [GDT_ENTRY_KERNEL_DS] = { 0x0000ffff, 0x00cf9200 }, |
28 | 28 | [GDT_ENTRY_DEFAULT_USER_CS] = { 0x0000ffff, 0x00cffa00 }, |
... | ... | @@ -48,8 +48,8 @@ |
48 | 48 | |
49 | 49 | [GDT_ENTRY_ESPFIX_SS] = { 0x00000000, 0x00c09200 }, |
50 | 50 | [GDT_ENTRY_PDA] = { 0x00000000, 0x00c09200 }, /* set in setup_pda */ |
51 | -}; | |
52 | -EXPORT_PER_CPU_SYMBOL_GPL(cpu_gdt); | |
51 | +} }; | |
52 | +EXPORT_PER_CPU_SYMBOL_GPL(gdt_page); | |
53 | 53 | |
54 | 54 | DEFINE_PER_CPU(struct i386_pda, _cpu_pda); |
55 | 55 | EXPORT_PER_CPU_SYMBOL(_cpu_pda); |
arch/i386/kernel/entry.S
... | ... | @@ -557,7 +557,7 @@ |
557 | 557 | #define FIXUP_ESPFIX_STACK \ |
558 | 558 | /* since we are on a wrong stack, we cant make it a C code :( */ \ |
559 | 559 | movl %fs:PDA_cpu, %ebx; \ |
560 | - PER_CPU(cpu_gdt, %ebx); \ | |
560 | + PER_CPU(gdt_page, %ebx); \ | |
561 | 561 | GET_DESC_BASE(GDT_ENTRY_ESPFIX_SS, %ebx, %eax, %ax, %al, %ah); \ |
562 | 562 | addl %esp, %eax; \ |
563 | 563 | pushl $__KERNEL_DS; \ |
arch/i386/kernel/head.S
... | ... | @@ -598,7 +598,7 @@ |
598 | 598 | .word 0 # 32 bit align gdt_desc.address |
599 | 599 | ENTRY(early_gdt_descr) |
600 | 600 | .word GDT_ENTRIES*8-1 |
601 | - .long per_cpu__cpu_gdt /* Overwritten for secondary CPUs */ | |
601 | + .long per_cpu__gdt_page /* Overwritten for secondary CPUs */ | |
602 | 602 | |
603 | 603 | /* |
604 | 604 | * The boot_gdt must mirror the equivalent in setup.S and is |
arch/i386/kernel/traps.c
... | ... | @@ -1030,7 +1030,7 @@ |
1030 | 1030 | fastcall unsigned long patch_espfix_desc(unsigned long uesp, |
1031 | 1031 | unsigned long kesp) |
1032 | 1032 | { |
1033 | - struct desc_struct *gdt = __get_cpu_var(cpu_gdt); | |
1033 | + struct desc_struct *gdt = __get_cpu_var(gdt_page).gdt; | |
1034 | 1034 | unsigned long base = (kesp - uesp) & -THREAD_SIZE; |
1035 | 1035 | unsigned long new_kesp = kesp - base; |
1036 | 1036 | unsigned long lim_pages = (new_kesp | (THREAD_SIZE - 1)) >> PAGE_SHIFT; |
include/asm-i386/desc.h
... | ... | @@ -18,10 +18,15 @@ |
18 | 18 | unsigned short pad; |
19 | 19 | } __attribute__ ((packed)); |
20 | 20 | |
21 | -DECLARE_PER_CPU(struct desc_struct, cpu_gdt[GDT_ENTRIES]); | |
21 | +struct gdt_page | |
22 | +{ | |
23 | + struct desc_struct gdt[GDT_ENTRIES]; | |
24 | +} __attribute__((aligned(PAGE_SIZE))); | |
25 | +DECLARE_PER_CPU(struct gdt_page, gdt_page); | |
26 | + | |
22 | 27 | static inline struct desc_struct *get_cpu_gdt_table(unsigned int cpu) |
23 | 28 | { |
24 | - return per_cpu(cpu_gdt, cpu); | |
29 | + return per_cpu(gdt_page, cpu).gdt; | |
25 | 30 | } |
26 | 31 | |
27 | 32 | extern struct Xgt_desc_struct idt_descr; |