powerpc vdso updates
PATCH 1/1 powerpc vdso updates
This patch cleans up some locking & error handling in the ppc vdso and moves the vdso base pointer from the thread struct to the mm context where it more logically belongs. It brings the powerpc implementation closer to Ingo's new x86 one and also adds an arch_vma_name() function allowing to print [vsdo] in /proc/<pid>/maps if Ingo's x86 vdso patch is also applied.
---
This is 2.6.18 material, hopefully should go along with Ingo's x86 vdso updates. Ingo, if you change something to arch_vma_name(), please let me know.
arch/powerpc/kernel/signal_32.c +4 -4
@@ -757,10 +757,10 @@ static int handle_rt_signal(unsigned lon/* Save user registers on the stack */ frame = &rt_sf->uc.uc_mcontext; -if (vdso32_rt_sigtramp && current->thread.vdso_base) { +if (vdso32_rt_sigtramp && current->mm->context.vdso_base) {if (save_user_regs (regs, frame,0 )) goto badframe; - regs->link = current->thread.vdso_base + vdso32_rt_sigtramp; + regs->link = current->mm->context.vdso_base + vdso32_rt_sigtramp; }else {if (save_user_regs (regs, frame, __NR_rt_sigreturn)) goto badframe;
@@ -1029,10 +1029,10 @@ static int handle_signal(unsigned long s || __put_user(sig, &sc->signal)) goto badframe; -if (vdso32_sigtramp && current->thread.vdso_base) { +if (vdso32_sigtramp && current->mm->context.vdso_base) {if (save_user_regs (regs, &frame->mctx,0 )) goto badframe; - regs->link = current->thread.vdso_base + vdso32_sigtramp; + regs->link = current->mm->context.vdso_base + vdso32_sigtramp; }else {if (save_user_regs (regs, &frame->mctx, __NR_sigreturn)) goto badframe;
arch/powerpc/kernel/signal_64.c +2 -2
@@ -394,8 +394,8 @@ static int setup_rt_frame(int signr, str current->thread.fpscr.val =0 ;/* Set up to return from userspace. */ -if (vdso64_rt_sigtramp && current->thread.vdso_base) { - regs->link = current->thread.vdso_base + vdso64_rt_sigtramp; +if (vdso64_rt_sigtramp && current->mm->context.vdso_base) { + regs->link = current->mm->context.vdso_base + vdso64_rt_sigtramp; }else { err |=setup_trampoline (__NR_rt_sigreturn, &frame->tramp[0 ]);if (err)
arch/powerpc/kernel/vdso.c +36 -21
102 lines not on this page · raw message
include/asm-powerpc/elf.h +1 -1
@@ -294,7 +294,7 @@ do { \NEW_AUX_ENT (AT_DCACHEBSIZE , dcache_bsize); \NEW_AUX_ENT (AT_ICACHEBSIZE , icache_bsize); \NEW_AUX_ENT (AT_UCACHEBSIZE , ucache_bsize); \ - VDSO_AUX_ENT(AT_SYSINFO_EHDR, current->thread.vdso_base) \ + VDSO_AUX_ENT(AT_SYSINFO_EHDR, current->mm->context.vdso_base) \ }while (0 )/* PowerPC64 relocations defined by the ABIs */
include/asm-powerpc/mmu.h +1 -0
@@ -360,6 +360,7 @@ typedef struct {#ifdef CONFIG_HUGETLB_PAGE u16 low_htlb_areas, high_htlb_areas;#endif +unsigned long vdso_base; } mm_context_t;
include/asm-powerpc/page.h +3 -0
@@ -198,6 +198,9 @@ extern void copy_user_page(void *to, voi struct page *p);extern int page_is_ram (unsigned long pfn); +struct vm_area_struct ; +extern const char *arch_vma_name (struct vm_area_struct *vma); +#include <asm-generic/memory_model.h> #endif /* __ASSEMBLY__ */
include/asm-powerpc/processor.h +0 -1
@@ -153,7 +153,6 @@ struct thread_struct {unsigned long start_tb;/* Start purr when proc switched in */ unsigned long accum_tb;/* Total accumilated purr for process */ #endif -unsigned long vdso_base;/* base of the vDSO library */ unsigned long dabr;/* Data address breakpoint register */ #ifdef CONFIG_ALTIVEC /* Complete AltiVec register set */
Quoted 6 lines · Benjamin Herrenschmidt
This patch cleans up some locking & error handling in the ppc vdso and moves the vdso base pointer from the thread struct to the mm context where it more logically belongs. It brings the powerpc implementation closer to Ingo's new x86 one and also adds an
arch_vma_name()function allowing to print [vsdo] in /proc/<pid>/maps if Ingo's x86 vdso patch is also applied.
looks good to me.
Quoted 1 line
Signed-off-by Benjamin Herrenschmidt <[email protected]>
Quoted 3 lines
This is 2.6.18 material, hopefully should go along with Ingo's x86 vdso updates. Ingo, if you change something to
arch_vma_name(), please let me know.
ok. There's one bit that could potentially be 2.6.17 material:
arch/powerpc/kernel/vdso.c int arch_setup_additional_pages(struct l · line 258
Quoted 6 lines
arch/powerpc/kernel/vdso.c +1
-0* at vdso_base which is the "natural" base for it, but we might fail * and end up putting it elsewhere. */ +down_write (&mm->mmap_sem); vdso_base =get_unmapped_area (NULL , vdso_base, vdso_pages <<PAGE_SHIFT ,0 ,0 );
get_unmapped_area() without holding the mmap semaphore seems dangerous. The VDSO setup itself should be 'private' to the process, but i'm not totally sure that no other kernel code could get access to this mm. For example the swapout code? Am i missing something?
Ingo
Quoted 5 lines
get_unmapped_area()without holding the mmap semaphore seems dangerous. The VDSO setup itself should be 'private' to the process, but i'm not totally sure that no other kernel code could get access to this mm. For example the swapout code? Am i missing something?
Well, all of this happens so early, I doubt anything will cause actual harm, for get_unmapped_area to be a problem, something would have to concurrently allocate a VMA (or dispose of) I think that can't happen at this point before we even run the binary but yes, better safe than sorry... I supose the whole patch could get in 2.6.17 even without the arch_vma_name (that is it can be there, it wont be used though until your patch gets in).
Ben.
Hi Ben,
Quoted 6 lines
This patch cleans up some locking & error handling in the ppc vdso and moves the vdso base pointer from the thread struct to the mm context where it more logically belongs. It brings the powerpc implementation closer to Ingo's new x86 one and also adds an
arch_vma_name()function allowing to print [vsdo] in /proc/<pid>/maps if Ingo's x86 vdso patch is also applied.
Im getting this on the current powerpc git tree:
arch/powerpc/kernel/signal_32.c: In function 'handle_rt_signal':arch/powerpc/kernel/signal_32.c:763: error: request for member 'vdso_base' in something not a structure or union
It looks like we use the mm_context_t definition in asm-ppc/mmu.h for 32bit ARCH=powerpc builds and need vdso_base there too.
Anton
Quoted 9 lines · Anton Blanchard
Hi Ben,
Quoted 6 lines
This patch cleans up some locking & error handling in the ppc vdso and moves the vdso base pointer from the thread struct to the mm context where it more logically belongs. It brings the powerpc implementation closer to Ingo's new x86 one and also adds an
arch_vma_name()function allowing to print [vsdo] in /proc/<pid>/maps if Ingo's x86 vdso patch is also applied.
Quoted 8 lines
Im getting this on the current powerpc git tree:
arch/powerpc/kernel/signal_32.c: In function 'handle_rt_signal':arch/powerpc/kernel/signal_32.c:763: error: request for member 'vdso_base' in something not a structure or unionIt looks like we use the
mm_context_tdefinition inasm-ppc/mmu.hfor 32bit ARCH=powerpc builds and needvdso_basethere too.
Yes, I have a patch almost ready for that.
Ben.