espfix code cleanup
PATCH 1/1 espfix code cleanup
Hi.
The current espfix code used to make problem for some people by its uglyness and the stack switching. The attached patch removes about 2/3 of the mess by utilizing the 32bit stack instead of the 16bit one. I simply patch the base address at gdt so that the kernel esp have the same high word as the user esp.
In case there are no objections - Andrew, could you please apply?
-----
Clean up the espfix code by utilizing the 32bit stack instead of the 16bit one.
Signed-off-by Stas Sergeev <[email protected]>
include/asm-i386/desc.h +0 -4
@@ -4,8 +4,6 @@#include <asm/ldt.h> #include <asm/segment.h> -#define CPU_16BIT_STACK_SIZE 1024 -#ifndef __ASSEMBLY__#include <linux/preempt.h>
@@ -16,8 +14,6 @@extern struct desc_struct cpu_gdt_table[GDT_ENTRIES ]; -DECLARE_PER_CPU(unsigned char, cpu_16bit_stack[CPU_16BIT_STACK_SIZE]); -struct Xgt_desc_struct {unsigned short size;unsigned long address __attribute__((packed));
arch/i386/kernel/head.S +1 -1
@@ -590,7 +590,7 @@ .quad 0x00009a000000ffff /* 0xc0 APM CS 16 code (16 bit) */ .quad 0x004092000000ffff /* 0xc8 APM DS data */ - .quad 0x0000920000000000 /* 0xd0 - ESPFIX 16-bit SS */ + .quad 0x00cf92000000ffff /* 0xd0 - ESPFIX SS */ .quad 0x0000000000000000 /* 0xd8 - unused */ .quad 0x0000000000000000 /* 0xe0 - unused */ .quad 0x0000000000000000 /* 0xe8 - unused */
arch/i386/kernel/traps.c +22 -41
71 lines not on this page · raw message
arch/i386/kernel/entry.S +24 -38
135 lines not on this page · raw message
arch/i386/kernel/cpu/common.c +0 -11
@@ -24,9 +24,6 @@ DEFINE_PER_CPU(struct Xgt_desc_struct, cpu_gdt_descr);EXPORT_PER_CPU_SYMBOL (cpu_gdt_descr); -DEFINE_PER_CPU(unsigned char, cpu_16bit_stack[CPU_16BIT_STACK_SIZE]); -EXPORT_PER_CPU_SYMBOL (cpu_16bit_stack); -static int cachesize_override__cpuinitdata =-1 ;static int disable_x86_fxsr__cpuinitdata ;static int disable_x86_serial_nr__cpuinitdata =1 ;
@@ -594,7 +591,6 @@struct tss_struct * t = &per_cpu (init_tss, cpu);struct thread_struct *thread = ¤t->thread;struct desc_struct *gdt; -__u32 stk16_off = (__u32)&per_cpu (cpu_16bit_stack, cpu);struct Xgt_desc_struct *cpu_gdt_descr = &per_cpu (cpu_gdt_descr, cpu);if (cpu_test_and_set (cpu, cpu_initialized)) {
@@ -642,13 +638,6 @@* and set up the GDT descriptor: */ memcpy (gdt, cpu_gdt_table,GDT_SIZE ); - -/* Set up GDT entry for 16bit stack */ - *(__u64 *)(&gdt[GDT_ENTRY_ESPFIX_SS ]) |= - ((((__u64 )stk16_off) <<16 ) &0x000000ffffff0000ULL ) | - ((((__u64 )stk16_off) <<32 ) &0xff00000000000000ULL ) | - (CPU_16BIT_STACK_SIZE -1 ); - cpu_gdt_descr->size =GDT_SIZE -1 ; cpu_gdt_descr->address = (unsigned long )gdt;