revised pda patches
Subsystems (4)
Hi Andi,
Here's an updated series of PDA patches based on your tree. They're intended to replace these:
i386-pda-basics
i386-pda-init-pda
i386-pda-use-gs
i386-pda-user-abi
i386-pda-vm86
i386-pda-smp-processorid
i386-pda-current
with these:
i386-pda-definitions.patch
i386-pda-init.patch
i386-pda-use-gs.patch
i386-pda-fix-abi.patch
i386-pda-fix-vm86.patch
i386-pda-smp_processor_id.patch
i386-pda-current.patch
Thanks,
J
Basic definitions for i386-pda
This patch has the basic definitions of struct i386_pda, and the segment selector in the GDT.
asm-i386/pda.h is more or less a direct copy of asm-x86_64/pda.h. The most interesting difference is the use of _proxy_pda, which is used to give gcc a model for the actual memory operations on the real pda structure. No actual reference is ever made to _proxy_pda, so it is never defined.
--- arch/i386/kernel/asm-offsets.c | 4 + arch/i386/kernel/head.S | 2 include/asm-i386/pda.h | 86 ++++++++++++++++++++++++++++++++++++++++ include/asm-i386/segment.h | 5 +- 4 files changed, 95 insertions(+), 2 deletions(-)
arch/i386/kernel/asm-offsets.c +4 -0
@@ -15,6 +15,7 @@#include <asm/processor.h> #include <asm/thread_info.h> #include <asm/elf.h> +#include <asm/pda.h> #define DEFINE (sym, val) \ asm volatile("\n->" #sym " %0 " #val : : "i" (val))
@@ -91,4 +92,7 @@ void foo(void)DEFINE (VDSO_PRELINK ,VDSO_PRELINK );OFFSET (crypto_tfm_ctx_offset, crypto_tfm, __crt_ctx); + +BLANK (); +OFFSET (PDA_pcurrent, i386_pda, pcurrent); }
arch/i386/kernel/head.S +1 -1
@@ -518,7 +518,7 @@ ENTRY(cpu_gdt_table) .quad 0x004092000000ffff /* 0xc8 APM DS data */ .quad 0x0000920000000000 /* 0xd0 - ESPFIX 16-bit SS */ - .quad 0x0000000000000000 /* 0xd8 - unused */ + .quad 0x0000000000000000 /* 0xd8 - PDA */ .quad 0x0000000000000000 /* 0xe0 - unused */ .quad 0x0000000000000000 /* 0xe8 - unused */ .quad 0x0000000000000000 /* 0xf0 - unused */
include/asm-i386/pda.h new file +98 -0
98 lines not on this page · raw message
include/asm-i386/segment.h +4 -1
@@ -39,7 +39,7 @@* 25 - APM BIOS support * * 26 - ESPFIX small SS -* 27 - unused +* 27 - PDA [ per-cpu private data area ] * 28 - unused * 29 - unused * 30 - unused
@@ -73,6 +73,9 @@#define GDT_ENTRY_ESPFIX_SS (GDT_ENTRY_KERNEL_BASE + 14)#define __ESPFIX_SS (GDT_ENTRY_ESPFIX_SS * 8) + +#define GDT_ENTRY_PDA (GDT_ENTRY_KERNEL_BASE + 15) +#define __KERNEL_PDA (GDT_ENTRY_PDA * 8)#define GDT_ENTRY_DOUBLEFAULT_TSS 31
Initialize the per-CPU data area.
When a CPU is brought up, a PDA and GDT are allocated for it. The GDT's __KERNEL_PDA entry is pointed to the allocated PDA memory, so that all references using this segment descriptor will refer to the PDA.
This patch rearranges CPU initialization a bit, so that the GDT/PDA are set up as early as possible in cpu_init(). Also for secondary CPUs, GDT+PDA are preallocated and initialized so all the secondary CPU needs to do is set up the ldt and load %gs. This will be important once smp_processor_id() and current use the PDA.
In all cases, the PDA is set up in head.S, before a CPU starts running C code, so the PDA is always available.
--- arch/i386/kernel/cpu/common.c | 293 +++++++++++++++++++++++++++-------------- arch/i386/kernel/smpboot.c | 31 +++- include/asm-i386/pda.h | 20 ++ include/asm-i386/processor.h | 3 4 files changed, 239 insertions(+), 108 deletions(-)
arch/i386/kernel/cpu/common.c +193 -100
317 lines not on this page · raw message
arch/i386/kernel/smpboot.c +23 -8
@@ -534,11 +534,11 @@ static void __devinit start_secondary(vostatic void __devinit start_secondary (void *unused) {/* -* Dont put anything before smp_callin(), SMP +* Don't put *anything* before secondary_cpu_init(), SMP * booting is too fragile that we want to limit the * things done here to the most necessary things. */ -cpu_init (); +secondary_cpu_init ();preempt_disable ();smp_callin ();while (!cpu_isset (smp_processor_id (), smp_commenced_mask))
@@ -597,13 +597,16 @@ void __devinit initialize_secondary(void "movl %0,%%esp\n\t" "jmp *%1" : - :"r" (current->thread.esp),"r" (current->thread.eip)); -} - + :"m" (current->thread.esp),"m" (current->thread.eip)); +} + +/* Static state in head.S used to set up a CPU */ extern struct {void * esp;unsigned short ss; } stack_start; +extern struct i386_pda *start_pda; +extern struct Xgt_desc_struct cpu_gdt_descr;#ifdef CONFIG_NUMA
@@ -929,9 +932,6 @@ static int __devinit do_boot_cpu(int apiunsigned long start_eip;unsigned short nmi_high =0 , nmi_low =0 ; - ++cpucount; -alternatives_smp_switch (1 ); -/* * We can't use kernel_thread since we must avoid to * reschedule the child.
@@ -939,14 +939,29 @@ static int __devinit do_boot_cpu(int api idle =alloc_idle_task (cpu);if (IS_ERR (idle))panic ("failed fork for CPU %d" , cpu); + +/* Pre-allocate and initialize the CPU's GDT and PDA so it +doesn't have to do any memory allocation during the +delicate CPU-bringup phase. */ +if (!init_gdt (cpu, idle)) { +printk (KERN_INFO "Couldn't allocate GDT/PDA for CPU %d\n" , cpu); +return -1 ;/* ? */ + } + idle->thread.eip = (unsigned long ) start_secondary;/* start_eip had better be page-aligned! */ start_eip =setup_trampoline (); + + ++cpucount; +alternatives_smp_switch (1 );/* So we see what's up */ printk ("Booting processor %d/%d eip %lx\n" , cpu, apicid, start_eip);/* Stack for startup_32 can be just as for start_secondary onwards */ stack_start.esp = (void *) idle->thread.esp; + + start_pda =cpu_pda (cpu); + cpu_gdt_descr =per_cpu (cpu_gdt_descr, cpu);irq_ctx_init (cpu);
include/asm-i386/processor.h +3 -0
@@ -731,4 +731,7 @@ extern void enable_sep_cpu(void);extern void enable_sep_cpu (void );extern int sysenter_setup (void ); +extern int init_gdt (int cpu,struct task_struct *idle); +extern void secondary_cpu_init (void ); +#endif /* __ASM_I386_PROCESSOR_H */
Use %gs as the PDA base-segment in the kernel.
This patch is the meat of the PDA change. This patch makes several related changes:
1: Most significantly, %gs is now used in the kernel. This means that on
entry, the old value of %gs is saved away, and it is reloaded with __KERNEL_PDA.
2: entry.S constructs the stack in the shape of struct pt_regs, and this
is passed around the kernel so that the process's saved register state can be accessed.
Unfortunately struct pt_regs doesn't currently have space for %gs (or %fs). This patch extends pt_regs to add space for gs (no space is allocated for %fs, since it won't be used, and it would just complicate the code in entry.S to work around the space).
3: Because %gs is now saved on the stack like %ds, %es and the integer
registers, there are a number of places where it no longer needs to be handled specially; namely context switch, and saving/restoring the register state in a signal context.
4: And since kernel threads run in kernel space and call normal kernel
code, they need to be created with their %gs == __KERNEL_PDA.
NOTE: even though it's called "ptrace-abi.h", this file does not define a user-space visible ABI.
--- arch/i386/kernel/asm-offsets.c | 1 arch/i386/kernel/cpu/common.c | 21 +++++++++- arch/i386/kernel/entry.S | 81 +++++++++++++++++++++++----------------- arch/i386/kernel/head.S | 33 +++++++++++++--- arch/i386/kernel/process.c | 27 ++++++------- arch/i386/kernel/signal.c | 6 -- include/asm-i386/mmu_context.h | 4 - include/asm-i386/processor.h | 4 + include/asm-i386/ptrace.h | 2 kernel/fork.c | 2 10 files changed, 119 insertions(+), 62 deletions(-)
arch/i386/kernel/asm-offsets.c +1 -0
@@ -68,6 +68,7 @@ void foo(void)OFFSET (PT_EAX , pt_regs, eax);OFFSET (PT_DS , pt_regs, xds);OFFSET (PT_ES , pt_regs, xes); +OFFSET (PT_GS , pt_regs, xgs);OFFSET (PT_ORIG_EAX , pt_regs, orig_eax);OFFSET (PT_EIP , pt_regs, eip);OFFSET (PT_CS , pt_regs, xcs);
arch/i386/kernel/cpu/common.c +19 -2
@@ -587,6 +587,14 @@ void __init early_cpu_init(void)#endif } +/* Make sure %gs is initialized properly in idle threads */ +struct pt_regs *__devinit idle_regs (struct pt_regs *regs) +{ +memset (regs,0 ,sizeof (struct pt_regs )); + regs->xgs = __KERNEL_PDA; +return regs; +} +__cpuinit int alloc_gdt (int cpu) {struct Xgt_desc_struct *cpu_gdt_descr = &per_cpu (cpu_gdt_descr, cpu);
@@ -640,6 +648,14 @@ struct i386_pda boot_pda = { .pcurrent = &init_task, }; +static inline void set_kernel_gs (void ) +{ +/* Set %gs for this CPU's PDA. Memory clobber is to create a +barrier with respect to any PDA operations, so the compiler +doesn't move any before here. */ + asmvolatile ("mov %0, %%gs" : :"r" (__KERNEL_PDA) :"memory" ); +} +/* Initialize the CPU's GDT and PDA. The boot CPU does this for itself, but secondaries find this done for them. */ __cpuinit int init_gdt (int cpu,struct task_struct *idle)
@@ -698,6 +714,7 @@ static void __cpuinit _cpu_init(int cpu,the boot CPU, this will transition from the boot gdt+pda to the real ones). */ load_gdt (cpu_gdt_descr); +set_kernel_gs ();if (cpu_test_and_set (cpu, cpu_initialized)) {printk (KERN_WARNING "CPU#%d already initialized!\n" , cpu);
@@ -736,8 +753,8 @@ static void __cpuinit _cpu_init(int cpu,__set_tss_desc (cpu,GDT_ENTRY_DOUBLEFAULT_TSS , &doublefault_tss);#endif -/* Clear %fs and %gs. */ - asmvolatile ("movl %0, %%fs; movl %0, %%gs" : :"r" (0 )); +/* Clear %fs. */ + asmvolatile ("mov %0, %%fs" : :"r" (0 ));/* Clear all 6 debug registers: */ set_debugreg (0 ,0 );
arch/i386/kernel/entry.S +47 -33
168 lines not on this page · raw message
arch/i386/kernel/head.S +28 -5
@@ -302,6 +302,7 @@ 2: movl %cr0,%eax movl %eax,%cr0 call check_x87 + call setup_pda lgdt cpu_gdt_descr lidt idt_descr ljmp $(__KERNEL_CS),$1f
@@ -312,10 +313,13 @@ 1: movl $(__KERNEL_DS),%eax # reload all movl %eax,%ds movl %eax,%es - xorl %eax,%eax # Clear FS/GS and LDT + xorl %eax,%eax # Clear FS and LDT movl %eax,%fs - movl %eax,%gs lldt %ax + + movl $(__KERNEL_PDA),%eax + mov %eax,%gs + cld # gcc2 wants the direction flag cleared at all times pushl %eax # fake return address #ifdef CONFIG_SMP
@@ -345,6 +349,23 @@ 1: movb $1,X86_HARD_MATH .byte 0xDB,0xE4 /* fsetpm for 287, ignored by 387 */ ret +/* + * Point the GDT at this CPU's PDA. On boot this will be + * cpu_gdt_table and boot_pda; for secondary CPUs, these will be + * that CPU's GDT and PDA. + */ +setup_pda: + /* get the PDA pointer */ + movl start_pda, %eax + + /* slot the PDA address into the GDT */ + mov cpu_gdt_descr+2, %ecx + mov %ax, (__KERNEL_PDA+0+2)(%ecx) /* base & 0x0000ffff */ + shr $16, %eax + mov %al, (__KERNEL_PDA+4+0)(%ecx) /* base & 0x00ff0000 */ + mov %ah, (__KERNEL_PDA+4+3)(%ecx) /* base & 0xff000000 */ + ret + /* * setup_idt *
@@ -424,7 +445,9 @@ ENTRY(empty_zero_page) * This starts the data section. */ .data - +ENTRY(start_pda) + .long boot_pda + ENTRY(stack_start) .long init_thread_union+THREAD_SIZE .long __BOOT_DS
@@ -458,7 +481,7 @@ idt_descr: # boot GDT descriptor (later on used by CPU#0): .word 0 # 32 bit align gdt_desc.address -cpu_gdt_descr: +ENTRY(cpu_gdt_descr) .word GDT_ENTRIES*8-1 .long cpu_gdt_table
@@ -518,7 +541,7 @@ ENTRY(cpu_gdt_table) .quad 0x004092000000ffff /* 0xc8 APM DS data */ .quad 0x0000920000000000 /* 0xd0 - ESPFIX 16-bit SS */ - .quad 0x0000000000000000 /* 0xd8 - PDA */ + .quad 0x00cf92000000ffff /* 0xd8 - PDA */ .quad 0x0000000000000000 /* 0xe0 - unused */ .quad 0x0000000000000000 /* 0xe8 - unused */ .quad 0x0000000000000000 /* 0xf0 - unused */
arch/i386/kernel/process.c +13 -14
@@ -56,6 +56,7 @@#include <asm/tlbflush.h> #include <asm/cpu.h> +#include <asm/pda.h> asmlinkage void ret_from_fork(void) __asm__("ret_from_fork");
@@ -336,6 +337,7 @@ int kernel_thread(int (*fn)(void *), voi regs.xds = __USER_DS; regs.xes = __USER_DS; + regs.xgs = __KERNEL_PDA; regs.orig_eax =-1 ; regs.eip = (unsigned long ) kernel_thread_helper; regs.xcs = __KERNEL_CS |get_kernel_rpl ();
@@ -421,7 +423,6 @@ int copy_thread(int nr, unsigned long cl p->thread.eip = (unsigned long ) ret_from_fork;savesegment (fs,p->thread.fs); -savesegment (gs,p->thread.gs); tsk = current;if (unlikely (test_tsk_thread_flag (tsk,TIF_IO_BITMAP ))) {
@@ -645,16 +646,16 @@ struct task_struct fastcall * __switch_tload_esp0 (tss, next);/* -* Save away %fs and %gs. No need to save %es and %ds, as -* those are always kernel segments while inside the kernel. -* Doing this before setting the new TLS descriptors avoids -* the situation where we temporarily have non-reloadable -* segments in %fs and %gs. This could be an issue if the -* NMI handler ever used %fs or %gs (it does not today), or -* if the kernel is running inside of a hypervisor layer. +* Save away %fs. No need to save %gs, as it was saved on the +* stack on entry. No need to save %es and %ds, as those are +* always kernel segments while inside the kernel. Doing this +* before setting the new TLS descriptors avoids the situation +* where we temporarily have non-reloadable segments in %fs +* and %gs. This could be an issue if the NMI handler ever +* used %fs or %gs (it does not today), or if the kernel is +* running inside of a hypervisor layer. */ savesegment (fs, prev->fs); -savesegment (gs, prev->gs);/* * Load the per-thread Thread-Local Storage descriptor.
@@ -662,16 +663,14 @@ struct task_struct fastcall * __switch_tload_TLS (next, cpu);/* -* Restore %fs and %gs if needed. +* Restore %fs if needed. * -* Glibc normally makes %fs be zero, and %gs is one of -* the TLS segments. +* Glibc normally makes %fs be zero. */ if (unlikely (prev->fs | next->fs))loadsegment (fs, next->fs); -if (prev->gs | next->gs) -loadsegment (gs, next->gs); +write_pda (pcurrent, next_p);/* * Restore IOPL if needed.
arch/i386/kernel/signal.c +2 -4
@@ -128,7 +128,7 @@ restore_sigcontext(struct pt_regs *regs, X86_EFLAGS_TF | X86_EFLAGS_SF | X86_EFLAGS_ZF | \ X86_EFLAGS_AF | X86_EFLAGS_PF | X86_EFLAGS_CF) -GET_SEG (gs); +COPY_SEG (gs);GET_SEG (fs);COPY_SEG (es);COPY_SEG (ds);
@@ -244,9 +244,7 @@ setup_sigcontext(struct sigcontext __use {int tmp, err =0 ; - tmp =0 ; -savesegment (gs, tmp); - err |=__put_user (tmp, (unsigned int __user *)&sc->gs); + err |=__put_user (regs->xgs, (unsigned int __user *)&sc->gs);savesegment (fs, tmp); err |=__put_user (tmp, (unsigned int __user *)&sc->fs);
include/asm-i386/mmu_context.h +2 -2
@@ -62,8 +62,8 @@ static inline void switch_mm(struct mm_s#endif } -#define deactivate_mm (tsk, mm) \ - asm("movl %0,%%fs ; movl %0,%%gs": :"r" (0)) +#define deactivate_mm (tsk, mm) \ + asm("movl %0,%%fs": :"r" (0));#define activate_mm (prev, next) \ switch_mm((prev),(next),NULL)
include/asm-i386/processor.h +3 -1
@@ -477,6 +477,7 @@ struct thread_struct { .vm86_info = NULL, \ .sysenter_cs = __KERNEL_CS, \ .io_bitmap_ptr = NULL, \ + .gs = __KERNEL_PDA, \ }/*
@@ -504,7 +505,8 @@ static inline void load_esp0(struct tss_ }#define start_thread (regs, new_eip, new_esp) do { \ - __asm__("movl %0,%%fs ; movl %0,%%gs": :"r" (0)); \ + __asm__("movl %0,%%fs": :"r" (0)); \ + regs->xgs = 0; \ set_fs(USER_DS); \ regs->xds = __USER_DS; \ regs->xes = __USER_DS; \
include/asm-i386/ptrace.h +2 -0
@@ -33,6 +33,8 @@ struct pt_regs {long eax;int xds;int xes; +/* int xfs; */ +int xgs;long orig_eax;long eip;int xcs;
kernel/fork.c +1 -1
@@ -1299,7 +1299,7 @@ fork_out:return ERR_PTR (retval); } -struct pt_regs * __devinit __attribute__((weak)) idle_regs(struct pt_regs *regs) +noinline struct pt_regs * __devinit __attribute__((weak)) idle_regs(struct pt_regs *regs) {memset (regs,0 ,sizeof (struct pt_regs ));return regs;
Fix places where using %gs changes the usermode ABI.
There are a few places where the change in struct pt_regs and the use of %gs affect the userspace ABI. These are primarily debugging interfaces where thread state can be inspected or extracted.
--- arch/i386/kernel/process.c | 6 +++--- arch/i386/kernel/ptrace.c | 18 ++++++------------ include/asm-i386/elf.h | 2 +- include/asm-i386/unwind.h | 1 + 4 files changed, 11 insertions(+), 16 deletions(-)
===================================================================
arch/i386/kernel/process.c +3 -3
@@ -309,8 +309,8 @@ void show_regs(struct pt_regs * regs) regs->eax,regs->ebx,regs->ecx,regs->edx);printk ("ESI: %08lx EDI: %08lx EBP: %08lx" , regs->esi, regs->edi, regs->ebp); -printk (" DS: %04x ES: %04x\n" , -0xffff & regs->xds,0xffff & regs->xes); +printk (" DS: %04x ES: %04x GS: %04x\n" , +0xffff & regs->xds,0xffff & regs->xes,0xffff & regs->xgs); cr0 =read_cr0 (); cr2 =read_cr2 ();
@@ -504,7 +504,7 @@ void dump_thread(struct pt_regs * regs, dump->regs.ds = regs->xds; dump->regs.es = regs->xes;savesegment (fs,dump->regs.fs); -savesegment (gs,dump->regs.gs); + dump->regs.gs = regs->xgs; dump->regs.orig_eax = regs->orig_eax; dump->regs.eip = regs->eip; dump->regs.cs = regs->xcs;
===================================================================
arch/i386/kernel/ptrace.c +6 -12
@@ -94,13 +94,9 @@ static int putreg(struct task_struct *chreturn -EIO ; child->thread.fs = value;return 0 ; -case GS : -if (value && (value &3 ) !=3 ) -return -EIO ; - child->thread.gs = value; -return 0 ;case DS :case ES : +case GS :if (value && (value &3 ) !=3 )return -EIO ; value &=0xffff ;
@@ -116,8 +112,8 @@ static int putreg(struct task_struct *ch value |=get_stack_long (child,EFL_OFFSET ) & ~FLAG_MASK ;break ; } -if (regno >GS *4 ) - regno -=2 *4 ; +if (regno >ES *4 ) + regno -=1 *4 ;put_stack_long (child, regno -sizeof (struct pt_regs ), value);return 0 ; }
@@ -131,18 +127,16 @@ static unsigned long getreg(struct task_case FS : retval = child->thread.fs;break ; -case GS : - retval = child->thread.gs; -break ;case DS :case ES : +case GS :case SS :case CS : retval =0xffff ;/* fall through */ default : -if (regno >GS *4 ) - regno -=2 *4 ; +if (regno >ES *4 ) + regno -=1 *4 ; regno = regno -sizeof (struct pt_regs ); retval &=get_stack_long (child, regno); }
===================================================================
include/asm-i386/elf.h +1 -1
@@ -88,7 +88,7 @@ typedef struct user_fxsr_struct elf_fpxr pr_reg[7 ] = regs->xds; \ pr_reg[8 ] = regs->xes; \savesegment (fs,pr_reg[9 ]); \ -savesegment (gs,pr_reg[10 ]); \ + pr_reg[10 ] = regs->xgs; \ pr_reg[11 ] = regs->orig_eax; \ pr_reg[12 ] = regs->eip; \ pr_reg[13 ] = regs->xcs; \
===================================================================
include/asm-i386/unwind.h +1 -0
@@ -64,6 +64,7 @@ static inline void arch_unw_init_blocked info->regs.xss = __KERNEL_DS; info->regs.xds = __USER_DS; info->regs.xes = __USER_DS; + info->regs.xgs = __KERNEL_PDA; } extern asmlinkage int arch_unwind_init_running(struct unwind_frame_info *,
Update sys_vm86 to cope with changed pt_regs and %gs usage.
sys_vm86 uses a struct kernel_vm86_regs, which is identical to pt_regs, but adds an extra space for all the segment registers. Previously this structure was completely independent, so changes in pt_regs had to be reflected in kernel_vm86_regs. This changes just embeds pt_regs in kernel_vm86_regs, and makes the appropriate changes to vm86.c to deal with the new naming.
Also, since %gs is dealt with differently in the kernel, this change adjusts vm86.c to reflect this.
While making these changes, I also cleaned up some frankly bizarre code which was added when auditing was added to sys_vm86.
--- arch/i386/kernel/vm86.c | 125 ++++++++++++++++++++++++++++------------------- include/asm-i386/vm86.h | 17 ------ 2 files changed, 78 insertions(+), 64 deletions(-)
arch/i386/kernel/vm86.c +76 -49
263 lines not on this page · raw message
include/asm-i386/vm86.h +2 -15
@@ -145,26 +145,13 @@ struct vm86plus_struct {* at the end of the structure. Look at ptrace.h to see the "normal" * setup. For user space layout see 'struct vm86_regs' above. */ +#include <asm/ptrace.h> struct kernel_vm86_regs {/* * normal regs, with special meaning for the segment descriptors.. */ -long ebx; -long ecx; -long edx; -long esi; -long edi; -long ebp; -long eax; -long __null_ds; -long __null_es; -long orig_eax; -long eip; -unsigned short cs, __csh; -long eflags; -long esp; -unsigned short ss, __ssh; +struct pt_regs pt;/* * these are specific to v86 mode: */
Implement smp_processor_id() with the PDA.
Use the cpu_number in the PDA to implement raw_smp_processor_id. This is a little simpler than using thread_info, though the cpu field in thread_info cannot be removed since it is used for things other than getting the current CPU in common code.
--- arch/i386/kernel/asm-offsets.c | 2 +- include/asm-i386/smp.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-)
arch/i386/kernel/asm-offsets.c +1 -1
@@ -52,7 +52,6 @@ void foo(void)OFFSET (TI_exec_domain, thread_info, exec_domain);OFFSET (TI_flags, thread_info, flags);OFFSET (TI_status, thread_info, status); -OFFSET (TI_cpu, thread_info, cpu);OFFSET (TI_preempt_count, thread_info, preempt_count);OFFSET (TI_addr_limit, thread_info, addr_limit);OFFSET (TI_restart_block, thread_info, restart_block);
@@ -96,4 +95,5 @@ void foo(void)BLANK ();OFFSET (PDA_pcurrent, i386_pda, pcurrent); +OFFSET (PDA_cpu, i386_pda, cpu_number); }
include/asm-i386/smp.h +2 -1
@@ -8,6 +8,7 @@#include <linux/kernel.h> #include <linux/threads.h> #include <linux/cpumask.h> +#include <asm/pda.h> #endif #ifdef CONFIG_X86_LOCAL_APIC
@@ -56,7 +57,7 @@ extern void cpu_uninit(void);* from the initial startup. We map APIC_BASE very early in page_setup(), * so this is correct in the x86 case. */ -#define raw_smp_processor_id () (current_thread_info()->cpu) +#define raw_smp_processor_id () (read_pda(cpu_number))extern cpumask_t cpu_callout_map;extern cpumask_t cpu_callin_map;
Implement "current" with the PDA.
Use the pcurrent field in the PDA to implement the "current" macro. This ends up compiling down to a single instruction to get the current task.
--- include/asm-i386/current.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
include/asm-i386/current.h +4 -3
@@ -1,13 +1,14 @@#ifndef _I386_CURRENT_H#define _I386_CURRENT_H -#include <linux/thread_info.h> +#include <asm/pda.h> +#include <linux/compiler.h> struct task_struct ; -static __always_inline struct task_struct * get_current(void) +static __always_inline struct task_struct *get_current(void) { -return current_thread_info ()->task; +return read_pda (pcurrent); }#define current get_current()
Quoted 15 lines · Jeremy Fitzhardinge
Hi Andi,
Here's an updated series of PDA patches based on your tree. They're intended to replace these:
i386-pda-basics i386-pda-init-pda i386-pda-use-gs i386-pda-user-abi i386-pda-vm86 i386-pda-smp-processorid i386-pda-currentwith these:
Quoted 7 lines
i386-pda-definitions.patch i386-pda-init.patch i386-pda-use-gs.patch i386-pda-fix-abi.patch i386-pda-fix-vm86.patch i386-pda-smp_processor_id.patch i386-pda-current.patch
I added them now, thanks.
At least one seemed to assume that asm-offsets.c already has entries for all the registers, which wasn't the case. I fixed that up from the patch context, but some double checking might be useful.
-Andi
Quoted 6 lines · Andi Kleen
I added them now, thanks.
At least one seemed to assume that
asm-offsets.calready has entries for all the registers, which wasn't the case. I fixed that up from the patch context, but some double checking might be useful.
Eh? They patch+compile cleanly against your patch queue of the other day. -use-gs adds PT_GS to asm-offsets, assuming that "i386-pda-asm-offsets" has already been applied. Did you accidentally remove that from your queue too; it was just before the old "i386-pda-basics"?
J
Quoted 8 lines · Jeremy Fitzhardinge
Quoted 6 lines · Andi Kleen
I added them now, thanks.
At least one seemed to assume that
asm-offsets.calready has entries for all the registers, which wasn't the case. I fixed that up from the patch context, but some double checking might be useful.
Quoted 5 lines
Eh? They patch+compile cleanly against your patch queue of the other day. -use-gs adds
PT_GSto asm-offsets, assuming that "i386-pda-asm-offsets" has already been applied. Did you accidentally remove that from your queue too; it was just before the old "i386-pda-basics"?
Yes I dropped all i386-pda-* patches earlier.
Also BTW the result didn't boot. Ok will try with that old patch too.
-Andi
Quoted 2 lines · Andi Kleen
Yes I dropped all i386-pda-* patches earlier.
"i386-pda-asm-offsets" doesn't really have anything to do with the PDA stuff; it's just a generic cleanup. It got posted as a prereq, but I don't consider it part of the same patch series (locally it doesn't have the i386-pda- prefix).
Quoted 2 lines
Also BTW the result didn't boot. Ok will try with that old patch too.
How did it fail?
J
Quoted 8 lines · Jeremy Fitzhardinge
Quoted 2 lines · Andi Kleen
Yes I dropped all i386-pda-* patches earlier.
"i386-pda-asm-offsets" doesn't really have anything to do with the PDA stuff; it's just a generic cleanup. It got posted as a prereq, but I don't consider it part of the same patch series (locally it doesn't have the i386-pda- prefix).
Ok I readded it now.
Quoted 5 lines
Quoted 3 lines
Also BTW the result didn't boot. Ok will try with that old patch too.
How did it fail?
It hangs after "Checking if processor honors the WP bit ..." That was in qemu, didn't try it on a real box
-Andi