vDSO for ppc64 : Preliminary release #5
Subsystems (2)
Here's a 5th drop of the ppc64 vdso, changes from #4 are fixed Makefile's and a new version of the CFI informations for signal trampolines by Alan.
I'm now waiting for something to happen on the glibc side...
Ben.
arch/ppc64/Makefile +2 -0
@@ -43,6 +43,8 @@ libs-y += arch/ppc64/lib/ core-y += arch/ppc64/kernel/ +core-y += arch/ppc64/kernel/vdso32/ +core-y += arch/ppc64/kernel/vdso64/ core-y += arch/ppc64/mm/ core-$(CONFIG_XMON) += arch/ppc64/xmon/ drivers-$(CONFIG_OPROFILE) += arch/ppc64/oprofile/
arch/ppc64/kernel/Makefile +1 -1
@@ -11,7 +11,7 @@ udbg.o binfmt_elf32.o sys_ppc32.o ioctl32.o \ ptrace32.o signal32.o rtc.o init_task.o \ lmb.o cputable.o cpu_setup_power4.o idle_power4.o \ - iommu.o sysfs.o vio.o + iommu.o sysfs.o vio.o vdso.o obj-$(CONFIG_PPC_OF) += of_device.o
arch/ppc64/kernel/asm-offsets.c +22 -0
@@ -22,6 +22,7 @@#include <linux/types.h> #include <linux/mman.h> #include <linux/mm.h> +#include <linux/time.h> #include <linux/hardirq.h> #include <asm/io.h> #include <asm/page.h>
@@ -36,6 +37,8 @@#include <asm/prom.h> #include <asm/rtas.h> #include <asm/cputable.h> +#include <asm/systemcfg.h> +#include <asm/compat.h> #define DEFINE (sym, val) \ asm volatile("\n->" #sym " %0 " #val : : "i" (val))
@@ -170,5 +173,24 @@DEFINE (CPU_SPEC_FEATURES , offsetof(struct cpu_spec , cpu_features));DEFINE (CPU_SPEC_SETUP , offsetof(struct cpu_spec , cpu_setup)); +/* systemcfg offsets for use by vdso */ +DEFINE (CFG_TB_ORIG_STAMP , offsetof(struct systemcfg , tb_orig_stamp)); +DEFINE (CFG_TB_TICKS_PER_SEC , offsetof(struct systemcfg , tb_ticks_per_sec)); +DEFINE (CFG_TB_TO_XS , offsetof(struct systemcfg , tb_to_xs)); +DEFINE (CFG_STAMP_XSEC , offsetof(struct systemcfg , stamp_xsec)); +DEFINE (CFG_TB_UPDATE_COUNT , offsetof(struct systemcfg , tb_update_count)); +DEFINE (CFG_TZ_MINUTEWEST , offsetof(struct systemcfg , tz_minuteswest)); +DEFINE (CFG_TZ_DSTTIME , offsetof(struct systemcfg , tz_dsttime)); +DEFINE (CFG_SYSCALL_MAP32 , offsetof(struct systemcfg , syscall_map_32)); +DEFINE (CFG_SYSCALL_MAP64 , offsetof(struct systemcfg , syscall_map_64)); + +/* timeval/timezone offsets for use by vdso */ +DEFINE (TVAL64_TV_SEC , offsetof(struct timeval , tv_sec)); +DEFINE (TVAL64_TV_USEC , offsetof(struct timeval , tv_usec)); +DEFINE (TVAL32_TV_SEC , offsetof(struct compat_timeval , tv_sec)); +DEFINE (TVAL32_TV_USEC , offsetof(struct compat_timeval , tv_usec)); +DEFINE (TZONE_TZ_MINWEST , offsetof(struct timezone , tz_minuteswest)); +DEFINE (TZONE_TZ_DSTTIME , offsetof(struct timezone , tz_dsttime)); +return 0 ; }
arch/ppc64/kernel/setup.c +33 -0
@@ -375,6 +375,7 @@printk ("naca->debug_switch = 0x%lx\n" , naca->debug_switch);printk ("naca->interrupt_controller = 0x%ld\n" , naca->interrupt_controller);printk ("systemcfg = 0x%p\n" , systemcfg); +printk ("systemcfg size = 0x%d\n" , (int )sizeof (struct systemcfg ));printk ("systemcfg->processorCount = 0x%lx\n" , systemcfg->processorCount);printk ("systemcfg->physicalMemorySize = 0x%lx\n" , systemcfg->physicalMemorySize);printk ("systemcfg->dCacheL1LineSize = 0x%x\n" , systemcfg->dCacheL1LineSize);
@@ -744,6 +745,34 @@ }/* +* Called from setup_arch to initialize the bitmap of available +* syscalls in the systemcfg page +*/ +void __init setup_syscall_map (void ) +{ +unsigned int i, count64 =0 , count32 =0 ; +extern unsigned long *sys_call_table; +extern unsigned long *sys_call_table32; +extern unsigned long sys_ni_syscall; + + +for (i =0 ; i < __NR_syscalls; i++) { +if (sys_call_table[i] == sys_ni_syscall) +continue ; + count64++; + systemcfg->syscall_map_64[i >>5 ] |=0x80000000UL >> (i &0x1f ); + } +for (i =0 ; i < __NR_syscalls; i++) { +if (sys_call_table32[i] == sys_ni_syscall) +continue ; + count32++; + systemcfg->syscall_map_32[i >>5 ] |=0x80000000UL >> (i &0x1f ); + } +printk (KERN_INFO "Syscall map setup, %d 32 bits and %d 64 bits syscalls\n" , + count32, count64); +} + +/* * Called into from start_kernel, after lock_kernel has been called. * Initializes bootmem, which is unsed to manage page allocation until * mem_init is called.
@@ -794,9 +823,13 @@/* set up the bootmem stuff with available memory */ do_init_bootmem (); +/* initialize the syscall map in systemcfg */ +setup_syscall_map (); + ppc_md.setup_arch ();paging_init (); +ppc64_boot_msg (0x15 ,"Setup Done" ); }
arch/ppc64/kernel/signal.c +9 -5
@@ -34,6 +34,7 @@#include <asm/ppcdebug.h> #include <asm/unistd.h> #include <asm/cacheflush.h> +#include <asm/vdso.h> #define DEBUG_SIG 0
@@ -412,10 +413,14 @@ goto badframe;/* Set up to return from userspace. */ - err |=setup_trampoline (__NR_rt_sigreturn, &frame->tramp[0 ]); -if (err) - goto badframe; - +if (vdso64_rt_sigtramp && current->thread.vdso_base) { + regs->link = current->thread.vdso_base + vdso64_rt_sigtramp; + }else { + err |=setup_trampoline (__NR_rt_sigreturn, &frame->tramp[0 ]); +if (err) + goto badframe; + regs->link = (unsigned long ) &frame->tramp[0 ]; + } funct_desc_ptr = (func_descr_t __user *) ka->sa.sa_handler;/* Allocate a dummy caller frame for the signal handler. */
@@ -424,7 +429,6 @@/* Set up "regs" so we "return" to the signal handler. */ err |=get_user (regs->nip, &funct_desc_ptr->entry); - regs->link = (unsigned long ) &frame->tramp[0 ]; regs->gpr[1 ] = newsp; err |=get_user (regs->gpr[2 ], &funct_desc_ptr->toc); regs->gpr[3 ] = signr;
arch/ppc64/kernel/signal32.c +20 -7
@@ -30,6 +30,7 @@#include <asm/ppcdebug.h> #include <asm/unistd.h> #include <asm/cacheflush.h> +#include <asm/vdso.h> #define DEBUG_SIG 0
@@ -677,18 +678,24 @@/* Save user registers on the stack */ frame = &rt_sf->uc.uc_mcontext; -if (save_user_regs (regs, frame, __NR_rt_sigreturn)) - goto badframe; -if (put_user (regs->gpr[1 ], (unsigned long __user *)newsp)) goto badframe; + +if (vdso32_rt_sigtramp && current->thread.vdso_base) { +if (save_user_regs (regs, frame,0 )) + goto badframe; + regs->link = current->thread.vdso_base + vdso32_rt_sigtramp; + }else { +if (save_user_regs (regs, frame, __NR_rt_sigreturn)) + goto badframe; + regs->link = (unsigned long ) frame->tramp; + } regs->gpr[1 ] = (unsigned long ) newsp; regs->gpr[3 ] = sig; regs->gpr[4 ] = (unsigned long ) &rt_sf->info; regs->gpr[5 ] = (unsigned long ) &rt_sf->uc; regs->gpr[6 ] = (unsigned long ) rt_sf; regs->nip = (unsigned long ) ka->sa.sa_handler; - regs->link = (unsigned long ) frame->tramp; regs->trap =0 ; regs->result =0 ;
@@ -842,8 +849,15 @@ || __put_user(sig, &sc->signal)) goto badframe; -if (save_user_regs (regs, &frame->mctx, __NR_sigreturn)) - goto badframe; +if (vdso32_sigtramp && current->thread.vdso_base) { +if (save_user_regs (regs, &frame->mctx,0 )) + goto badframe; + regs->link = current->thread.vdso_base + vdso32_sigtramp; + }else { +if (save_user_regs (regs, &frame->mctx, __NR_sigreturn)) + goto badframe; + regs->link = (unsigned long ) frame->mctx.tramp; + }if (put_user (regs->gpr[1 ], (unsigned long __user *)newsp)) goto badframe;
@@ -851,7 +865,6 @@ regs->gpr[3 ] = sig; regs->gpr[4 ] = (unsigned long ) sc; regs->nip = (unsigned long ) ka->sa.sa_handler; - regs->link = (unsigned long ) frame->mctx.tramp; regs->trap =0 ; regs->result =0 ;
arch/ppc64/kernel/smp.c +1 -1
@@ -784,7 +784,7 @@* For now we leave it which means the time can be some * number of msecs off until someone does a settimeofday() */ - do_gtod.tb_orig_stamp = tb_last_stamp; + do_gtod.varp->tb_orig_stamp = tb_last_stamp; systemcfg->tb_orig_stamp = tb_last_stamp;#endif
arch/ppc64/kernel/time.c +54 -6
109 lines not on this page · raw message
arch/ppc64/kernel/vdso.c new file +476 -0
476 lines not on this page · raw message
arch/ppc64/kernel/vdso32/Makefile new file +50 -0
50 lines not on this page · raw message
arch/ppc64/kernel/vdso32/datapage.S new file +53 -0
53 lines not on this page · raw message
arch/ppc64/kernel/vdso32/gettimeofday.S new file +137 -0
137 lines not on this page · raw message
arch/ppc64/kernel/vdso32/sigtramp.S new file +296 -0
296 lines not on this page · raw message
arch/ppc64/kernel/vdso32/vdso32.lds.S new file +91 -0
91 lines not on this page · raw message
arch/ppc64/kernel/vdso32/vdso32_wrapper.S new file +12 -0
@@ -0,0 +1,12 @@ +#include <linux/init.h> + + .section ".data" + + .globl vdso32_start, vdso32_end + .balign 4096 +vdso32_start: + .incbin "arch/ppc64/kernel/vdso32/vdso32.so" + .balign 4096 +vdso32_end: + + .previous
arch/ppc64/kernel/vdso64/Makefile new file +37 -0
@@ -0,0 +1,37 @@ +# List of files in the vdso, has to be asm only for now + +src-vdso64 = sigtramp.S gettimeofday.S datapage.S + +# Build rules + +obj-vdso64 := $(addsuffix .o, $(basename $(src-vdso64))) +targets := $(obj-vdso64) vdso64.so +obj-vdso64 := $(addprefix $(obj)/, $(obj-vdso64)) +src-vdso64 := $(addprefix $(src)/, $(src-vdso64)) + +EXTRA_CFLAGS := -shared -s -fno-common -fno-builtin +EXTRA_CFLAGS += -nostdlib -Wl,-soname=linux-vdso64.so.1 +EXTRA_AFLAGS := -D__VDSO64__ -s + +obj-y += vdso64_wrapper.o +extra-y += vdso64.lds +CPPFLAGS_vdso64.lds += -P -C -U$(ARCH) + +# Force dependency (incbin is bad) +$(obj)/vdso64_wrapper.o : $(obj)/vdso64.so + +# link rule for the .so file, .lds has to be first +$(obj)/vdso64.so: $(src)/vdso64.lds $(obj-vdso64) + $(call if_changed,vdso64ld) + +# assembly rules for the .S files +$(obj-vdso64): %.o: %.S + $(call if_changed_dep,vdso64as) + +# actual build commands +quiet_cmd_vdso64ld = VDSO64L $@ + cmd_vdso64ld = $(CC) $(c_flags) -Wl,-T $^ -o $@ +quiet_cmd_vdso64as = VDSO64A $@ + cmd_vdso64as = $(CC) $(a_flags) -c -o $@ $< + +
arch/ppc64/kernel/vdso64/datapage.S new file +53 -0
53 lines not on this page · raw message
arch/ppc64/kernel/vdso64/gettimeofday.S new file +88 -0
88 lines not on this page · raw message
arch/ppc64/kernel/vdso64/sigtramp.S new file +284 -0
284 lines not on this page · raw message
arch/ppc64/kernel/vdso64/vdso64.lds.S new file +93 -0
93 lines not on this page · raw message
arch/ppc64/kernel/vdso64/vdso64_wrapper.S new file +12 -0
@@ -0,0 +1,12 @@ +#include <linux/init.h> + + .section ".data" + + .globl vdso64_start, vdso64_end + .balign 4096 +vdso64_start: + .incbin "arch/ppc64/kernel/vdso64/vdso64.so" + .balign 4096 +vdso64_end: + + .previous
arch/ppc64/mm/init.c +3 -0
@@ -61,6 +61,7 @@#include <asm/system.h> #include <asm/iommu.h> #include <asm/abs_addr.h> +#include <asm/vdso.h> struct mmu_context_queue_t mmu_context_queue;
@@ -711,6 +712,8 @@#ifdef CONFIG_PPC_ISERIES iommu_vio_init ();#endif +/* Initialize the vDSO */ +vdso_init (); }/*
fs/binfmt_elf.c +8 -0
@@ -716,6 +716,14 @@ goto out_free_dentry; } +#ifdef ARCH_HAS_SETUP_ADDITIONAL_PAGES + retval =arch_setup_additional_pages (bprm, executable_stack); +if (retval <0 ) { +send_sig (SIGKILL , current,0 ); + goto out_free_dentry; + } +#endif /* ARCH_HAS_SETUP_ADDITIONAL_PAGES */ + current->mm->start_stack = bprm->p;/* Now we do a little grungy work by mmaping the ELF image into
include/asm-ppc64/a.out.h +4 -7
@@ -30,14 +30,11 @@#ifdef __KERNEL__ -#define STACK_TOP_USER64 (TASK_SIZE_USER64) +#define STACK_TOP_USER64 TASK_SIZE_USER64 +#define STACK_TOP_USER32 TASK_SIZE_USER32 -/* Give 32-bit user space a full 4G address space to live in. */ -#define STACK_TOP_USER32 (TASK_SIZE_USER32) - -#define STACK_TOP ((test_thread_flag(TIF_32BIT) || \ - (ppcdebugset(PPCDBG_BINFMT_32ADDR))) ? \ - STACK_TOP_USER32 : STACK_TOP_USER64) +#define STACK_TOP (test_thread_flag(TIF_32BIT) ? \ + STACK_TOP_USER32 : STACK_TOP_USER64)#endif /* __KERNEL__ */
include/asm-ppc64/elf.h +12 -0
@@ -238,10 +238,20 @@/* A special ignored type value for PPC, for glibc compatibility. */ #define AT_IGNOREPPC 22 +/* The vDSO location. We have to use the same value as x86 for glibc's +* sake :-) +*/ +#define AT_SYSINFO_EHDR 33 +extern int dcache_bsize;extern int icache_bsize;extern int ucache_bsize; +/* We do have an arch_setup_additional_pages for vDSO matters */ +#define ARCH_HAS_SETUP_ADDITIONAL_PAGES +struct linux_binprm ; +extern int arch_setup_additional_pages (struct linux_binprm *bprm,int executable_stack); +/* * The requirements here are: * - keep the final alignment of sp (sp & 0xf)
@@ -260,6 +270,8 @@NEW_AUX_ENT (AT_DCACHEBSIZE , dcache_bsize); \NEW_AUX_ENT (AT_ICACHEBSIZE , icache_bsize); \NEW_AUX_ENT (AT_UCACHEBSIZE , ucache_bsize); \ +/* vDSO base */ \ +NEW_AUX_ENT (AT_SYSINFO_EHDR , current->thread.vdso_base); \ }while (0 )/* PowerPC64 relocations defined by the ABIs */
include/asm-ppc64/page.h +5 -0
@@ -183,6 +183,11 @@extern int page_is_ram (unsigned long pfn); +/* We do define AT_SYSINFO_EHDR but don't use the gate mecanism */ +#define CONFIG_ARCH_GATE_AREA 1 +#define get_gate_vma (tsk) (NULL) +#define in_gate_area (task, addr) (0) +#endif /* __ASSEMBLY__ */ #ifdef MODULE
include/asm-ppc64/processor.h +4 -3
@@ -518,8 +518,8 @@/* This decides where the kernel will search for a free chunk of vm * space during mmap's. */ -#define TASK_UNMAPPED_BASE_USER32 (PAGE_ALIGN(STACK_TOP_USER32 / 4)) -#define TASK_UNMAPPED_BASE_USER64 (PAGE_ALIGN(STACK_TOP_USER64 / 4)) +#define TASK_UNMAPPED_BASE_USER32 (PAGE_ALIGN(TASK_SIZE_USER32 / 4)) +#define TASK_UNMAPPED_BASE_USER64 (PAGE_ALIGN(TASK_SIZE_USER64 / 4))#define TASK_UNMAPPED_BASE ((test_thread_flag(TIF_32BIT)||(ppcdebugset(PPCDBG_BINFMT_32ADDR))) ? \ TASK_UNMAPPED_BASE_USER32 : TASK_UNMAPPED_BASE_USER64 )
@@ -536,7 +536,8 @@double fpr[32 ];/* Complete floating point set */ unsigned long fpscr;/* Floating point status (plus pad) */ unsigned long fpexc_mode;/* Floating-point exception mode */ -unsigned long pad[3 ];/* was saved_msr, saved_softe */ +unsigned long pad[2 ];/* was saved_msr, saved_softe */ +unsigned long vdso_base;/* base of the vDSO library */ #ifdef CONFIG_ALTIVEC /* Complete AltiVec register set */ vector128 vr[32] __attribute((aligned(16)));
include/asm-ppc64/systemcfg.h +8 -28
@@ -15,23 +15,19 @@* End Change Activity */ - -#ifndef __KERNEL__ -#include <unistd.h> -#include <fcntl.h> -#include <sys/mman.h> -#include <linux/types.h> -#endif -/* * If the major version changes we are incompatible. * Minor version changes are a hint. */ #define SYSTEMCFG_MAJOR 1 -#define SYSTEMCFG_MINOR 0 +#define SYSTEMCFG_MINOR 1 #ifndef __ASSEMBLY__ +#include <linux/unistd.h> + +#define SYSCALL_MAP_SIZE ((__NR_syscalls + 31) / 32) + struct systemcfg { __u8 eye_catcher[16]; /* Eyecatcher: SYSTEMCFG:PPC64 0x00 */ struct { /* Systemcfg version numbers */
@@ -54,7 +50,9 @@__u32 dCacheL1LineSize;/* L1 d-cache line size 0x64 */ __u32 iCacheL1Size;/* L1 i-cache size 0x68 */ __u32 iCacheL1LineSize;/* L1 i-cache line size 0x6C */ -__u8 reserved0[3984 ];/* Reserve rest of page 0x70 */ +__u32 syscall_map_64[SYSCALL_MAP_SIZE ];/* map of available syscalls 0x70 */ +__u32 syscall_map_32[SYSCALL_MAP_SIZE ];/* map of available syscalls 0x70 */ +__u8 reserved0[3984 -2 *4 *SYSCALL_MAP_SIZE ];/* Reserve rest of page */ };#ifdef __KERNEL__
@@ -88,24 +86,6 @@#define _machine (systemcfg->platform)#define _MACH_Pmac PLATFORM_POWERMAC - -static inline volatile struct systemcfg *systemcfg_init (void ) -{ -int fd =open ("/proc/ppc64/systemcfg" ,O_RDONLY ); -volatile struct systemcfg *ret; - -if (fd ==-1 ) -return 0 ; - ret =mmap (0 ,sizeof (struct systemcfg ),PROT_READ ,MAP_SHARED , fd,0 ); -close (fd); -if (!ret) -return 0 ; -if (ret->version.major !=SYSTEMCFG_MAJOR || ret->version.minor <SYSTEMCFG_MINOR ) { -munmap ((void *)ret,sizeof (struct systemcfg )); -return 0 ; - } -return ret; -}#endif /* __KERNEL__ */ #endif /* __ASSEMBLY__ */
include/asm-ppc64/time.h +1 -1
@@ -43,10 +43,10 @@struct gettimeofday_vars {unsigned long tb_to_xs;unsigned long stamp_xsec; +unsigned long tb_orig_stamp; };struct gettimeofday_struct { -unsigned long tb_orig_stamp;unsigned long tb_ticks_per_sec;struct gettimeofday_vars vars[2 ];struct gettimeofday_vars *volatile varp;
include/asm-ppc64/vdso.h new file +60 -0
60 lines not on this page · raw message
Quoted 2 lines · Benjamin Herrenschmidt
and a new version of the CFI informations for signal trampolines by Alan.
Which is busted. I'm now generating .eh_frame directly, but you moved .cfi_startproc/.cfi_endproc into V_FUNCTION_BEGIN/V_FUNCTION_END.
Signature · 2 lines
Alan Modra IBM OzLabs - Linux Technology Centre
Quoted 6 lines · Alan Modra
Quoted 2 lines · Benjamin Herrenschmidt
and a new version of the CFI informations for signal trampolines by Alan.
Which is busted. I'm now generating .eh_frame directly, but you moved .cfi_startproc/.cfi_endproc into V_FUNCTION_BEGIN/V_FUNCTION_END.
Oh, ok, yes, I need to remove those I suppose and add them back manually to each individual function, right ?
Ben.
Quoted 10 lines · Benjamin Herrenschmidt
Quoted 6 lines · Alan Modra
Quoted 2 lines · Benjamin Herrenschmidt
and a new version of the CFI informations for signal trampolines by Alan.
Which is busted. I'm now generating .eh_frame directly, but you moved .cfi_startproc/.cfi_endproc into V_FUNCTION_BEGIN/V_FUNCTION_END.
Oh, ok, yes, I need to remove those I suppose and add them back manually to each individual function, right ?
Yes please.
Signature · 2 lines
Alan Modra IBM OzLabs - Linux Technology Centre