Skip to content

Commit 7a61d35

Browse files
jsgfAndi Kleen
authored andcommitted
[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>
1 parent 39b7ee0 commit 7a61d35

File tree

5 files changed

+13
-8
lines changed

5 files changed

+13
-8
lines changed

arch/i386/kernel/cpu/common.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
#include "cpu.h"
2424

25-
DEFINE_PER_CPU(struct desc_struct, cpu_gdt[GDT_ENTRIES]) = {
25+
DEFINE_PER_CPU(struct gdt_page, gdt_page) = { .gdt = {
2626
[GDT_ENTRY_KERNEL_CS] = { 0x0000ffff, 0x00cf9a00 },
2727
[GDT_ENTRY_KERNEL_DS] = { 0x0000ffff, 0x00cf9200 },
2828
[GDT_ENTRY_DEFAULT_USER_CS] = { 0x0000ffff, 0x00cffa00 },
@@ -48,8 +48,8 @@ DEFINE_PER_CPU(struct desc_struct, cpu_gdt[GDT_ENTRIES]) = {
4848

4949
[GDT_ENTRY_ESPFIX_SS] = { 0x00000000, 0x00c09200 },
5050
[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);
5353

5454
DEFINE_PER_CPU(struct i386_pda, _cpu_pda);
5555
EXPORT_PER_CPU_SYMBOL(_cpu_pda);

arch/i386/kernel/entry.S

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -557,7 +557,7 @@ END(syscall_badsys)
557557
#define FIXUP_ESPFIX_STACK \
558558
/* since we are on a wrong stack, we cant make it a C code :( */ \
559559
movl %fs:PDA_cpu, %ebx; \
560-
PER_CPU(cpu_gdt, %ebx); \
560+
PER_CPU(gdt_page, %ebx); \
561561
GET_DESC_BASE(GDT_ENTRY_ESPFIX_SS, %ebx, %eax, %ax, %al, %ah); \
562562
addl %esp, %eax; \
563563
pushl $__KERNEL_DS; \

arch/i386/kernel/head.S

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -598,7 +598,7 @@ idt_descr:
598598
.word 0 # 32 bit align gdt_desc.address
599599
ENTRY(early_gdt_descr)
600600
.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 */
602602

603603
/*
604604
* The boot_gdt must mirror the equivalent in setup.S and is

arch/i386/kernel/traps.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1030,7 +1030,7 @@ fastcall void do_spurious_interrupt_bug(struct pt_regs * regs,
10301030
fastcall unsigned long patch_espfix_desc(unsigned long uesp,
10311031
unsigned long kesp)
10321032
{
1033-
struct desc_struct *gdt = __get_cpu_var(cpu_gdt);
1033+
struct desc_struct *gdt = __get_cpu_var(gdt_page).gdt;
10341034
unsigned long base = (kesp - uesp) & -THREAD_SIZE;
10351035
unsigned long new_kesp = kesp - base;
10361036
unsigned long lim_pages = (new_kesp | (THREAD_SIZE - 1)) >> PAGE_SHIFT;

include/asm-i386/desc.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,15 @@ struct Xgt_desc_struct {
1818
unsigned short pad;
1919
} __attribute__ ((packed));
2020

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+
2227
static inline struct desc_struct *get_cpu_gdt_table(unsigned int cpu)
2328
{
24-
return per_cpu(cpu_gdt, cpu);
29+
return per_cpu(gdt_page, cpu).gdt;
2530
}
2631

2732
extern struct Xgt_desc_struct idt_descr;

0 commit comments

Comments
 (0)