Skip to contentSkip to conversation

vDSO for ppc64 : Preliminary release #4

PATCH Benjamin Herrenschmidt 2 participants 2 messages Sep 10, 2004

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Here's the fourth drop... See previous for details, this one adds some CFI informations to the signal trampoline (non tested) and a function to retreive a bitmap of implemented syscalls (see comments in arch/ppc64/kernel/vdso*/datapage.S for details) to help glibc at process launch.

(Note to Sam Ravnborg: I would appreciate if you could have a look at the Makefiles in arch/ppc64/kernel/vdso*/Makefile added by this patch, I'm not sure they are completely correct. I will fix myself the part that is choosing the proper compiler for 32 bits, but I think some of my rules will not work with split obj/src trees, thanks !)

The calling conventions didn't change yet. I successfully tested writing userland wrappers for ppc64 of the form:

	ld 11,._v_gettimeofday@got(2)
	mtctr 11
	bctr

To call the functions directly bypassing the desriptor though, so glibc could use that and avoid relocation, though it's sad that for what are supposed to be performance critical calls to things like gettimeofday, memcpy, etc... we end up going through a call trampoline to get to glibc, which will then call again through the above trampoline to the vdso.

One option I had in mind would be to add a special reloc type to ppc64 for the vdso, and have ld.so "hack" the branch trampolines from the app to {memcpy,gettimeofday,...} to go to the vdso directly, but I'd rather let glibc experts deal with those things.

Anyways, that's my last drop for now, I'll be busy next week and back on that the week after, it would be great if glibc could start adapting to what we have now already in the meantime.

Ben.

arch/ppc64/Makefile +2 -0
diff -urN linux-2.5/arch/ppc64/Makefile linux-vdso/arch/ppc64/Makefile
@@ -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
diff -urN linux-2.5/arch/ppc64/kernel/Makefile linux-vdso/arch/ppc64/kernel/Makefile
@@ -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
diff -urN linux-2.5/arch/ppc64/kernel/asm-offsets.c linux-vdso/arch/ppc64/kernel/asm-offsets.c
@@ -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
diff -urN linux-2.5/arch/ppc64/kernel/setup.c linux-vdso/arch/ppc64/kernel/setup.c
@@ -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
diff -urN linux-2.5/arch/ppc64/kernel/signal.c linux-vdso/arch/ppc64/kernel/signal.c
@@ -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
diff -urN linux-2.5/arch/ppc64/kernel/signal32.c linux-vdso/arch/ppc64/kernel/signal32.c
@@ -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
diff -urN linux-2.5/arch/ppc64/kernel/smp.c linux-vdso/arch/ppc64/kernel/smp.c
@@ -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 +51 -0

51 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 +127 -0

127 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
diff -urN linux-2.5/arch/ppc64/kernel/vdso32/vdso32_wrapper.S linux-vdso/arch/ppc64/kernel/vdso32/vdso32_wrapper.S
@@ -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 +38 -0
diff -urN linux-2.5/arch/ppc64/kernel/vdso64/Makefile linux-vdso/arch/ppc64/kernel/vdso64/Makefile
@@ -0,0 +1,38 @@
+# 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)))
+obj-vdso64 := $(addprefix $(obj)/, $(obj-vdso64))
+src-vdso64 := $(addprefix $(src)/, $(src-vdso64))
+
+VDSO64_CFLAGS := -shared -s -fno-common -Iinclude -fno-builtin -nostdlib
+VDSO64_CFLAGS += -Wl,-soname=linux-vdso64.so.1
+VDSO64_AFLAGS := -D__ASSEMBLY__ -D__KERNEL__ -D__VDSO64__ -s -nostdinc -Iinclude
+
+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
+# This is probably wrong with split src & obj trees
+$(obj-vdso64): %.o: %.S
+	$(call if_changed_dep,vdso64as)
+
+# actual build commands
+quiet_cmd_vdso64ld = VDSO64L $@
+      cmd_vdso64ld = $(CC) -Wp,-MD,$(depfile) $(VDSO64_CFLAGS) \
+	-Wl,-T $^ -o $@
+quiet_cmd_vdso64as = VDSO64A $@
+      cmd_vdso64as = $(CC) -Wp,-MD,$(depfile) $(VDSO64_AFLAGS) -c -o $@ $^
+
+targets += vdso64.so
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 +126 -0

126 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
diff -urN linux-2.5/arch/ppc64/kernel/vdso64/vdso64_wrapper.S linux-vdso/arch/ppc64/kernel/vdso64/vdso64_wrapper.S
@@ -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
diff -urN linux-2.5/arch/ppc64/mm/init.c linux-vdso/arch/ppc64/mm/init.c
@@ -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;
@@ -706,6 +707,8 @@
 #ifdef CONFIG_PPC_ISERIES
 	iommu_vio_init();
 #endif
+	/* Initialize the vDSO */
+	vdso_init();
 }
 
 /*
fs/binfmt_elf.c +8 -0
diff -urN linux-2.5/fs/binfmt_elf.c linux-vdso/fs/binfmt_elf.c
@@ -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
diff -urN linux-2.5/include/asm-ppc64/a.out.h linux-vdso/include/asm-ppc64/a.out.h
@@ -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
diff -urN linux-2.5/include/asm-ppc64/elf.h linux-vdso/include/asm-ppc64/elf.h
@@ -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
diff -urN linux-2.5/include/asm-ppc64/page.h linux-vdso/include/asm-ppc64/page.h
@@ -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
diff -urN linux-2.5/include/asm-ppc64/processor.h linux-vdso/include/asm-ppc64/processor.h
@@ -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
diff -urN linux-2.5/include/asm-ppc64/systemcfg.h linux-vdso/include/asm-ppc64/systemcfg.h
@@ -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
diff -urN linux-2.5/include/asm-ppc64/time.h linux-vdso/include/asm-ppc64/time.h
@@ -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

#1 lore raw

Hi Ben.

I would prefer to use a bit more core kbuild stuff.
Could you please try my version below (needs to be applied manually).

Let me know how it turns out.

Sam

Quoted 15 lines · Benjamin Herrenschmidt

diff -urN linux-2.5/arch/ppc64/kernel/vdso32/Makefile linux-vdso/arch/ppc64/kernel/vdso32/Makefile

arch/ppc64/kernel/vdso32/Makefile new file +10 -0
@@ -0,0 +1,51 @@
+# Choose compiler
 
+#
+# XXX FIXME: We probably want to enforce using a biarch compiler by default
+#             and thus use (CC) with -m64, while letting the user pass a
+#             CROSS32_COMPILE prefix if wanted. Same goes for the zImage
+#             wrappers
+#
+
+CROSS32_COMPILE ?=
+

arch/ppc64/kernel/vdso32/Makefile

Quoted 10 lines
arch/ppc64/kernel/vdso32/Makefile new file +10 -0
+CROSS32CC		:= $(CROSS32_COMPILE)gcc
+CROSS32AS		:= $(CROSS32_COMPILE)as
+
+# List of files in the vdso, has to be asm only for now
+
+src-vdso32 = sigtramp.S gettimeofday.S datapage.S
+
+# Build rules
+
+obj-vdso32 := $(addsuffix .o, $(basename $(src-vdso32))

targets := $(obj-vdso32)
-> So they get removed by make clean

arch/ppc64/kernel/vdso32/Makefile line 22

Quoted 2 lines
arch/ppc64/kernel/vdso32/Makefile new file +2 -0
+obj-vdso32 := $(addprefix $(obj)/, $(obj-vdso32))
+src-vdso32 := $(addprefix $(src)/, $(src-vdso32))

OK.

arch/ppc64/kernel/vdso32/Makefile line 26

Quoted 4 lines
arch/ppc64/kernel/vdso32/Makefile new file +4 -0
+
+VDSO32_CFLAGS := -shared -s -fno-common -Iinclude -fno-builtin -nostdlib
+VDSO32_CFLAGS += -Wl,-soname=linux-vdso32.so.1
+VDSO32_AFLAGS := -D__ASSEMBLY__ -D__KERNEL__ -D__VDSO32__ -s -nostdinc -Iinclude

Replace with:
EXTRA_CFLAGS := -shared -s -fno-common -fno-builtin EXTRA_CFLAGS += -nostdlib -Wl,-soname=linux-vdso32.so.1

EXTRA_AFLAGS := -D__VDSO32__ -s

Quoted 1 line

+obj-y += vdso32_wrapper.o

-> This causes built-in.o to be generated, which is fine.

arch/ppc64/kernel/vdso32/Makefile line 30

Quoted 2 lines
arch/ppc64/kernel/vdso32/Makefile new file +2 -0
+extra-y += vdso32.lds
+CPPFLAGS_vdso32.lds += -P -C -U$(ARCH)

OK

Quoted 2 lines

+# Force dependency (incbin is bad)
+$(obj)/vdso32_wrapper.o : $(obj)/vdso32.so

OK

arch/ppc64/kernel/vdso32/Makefile line 37

Quoted 3 lines
arch/ppc64/kernel/vdso32/Makefile new file +3 -0
+# link rule for the .so file, .lds has to be first
+$(obj)/vdso32.so: $(src)/vdso32.lds $(obj-vdso32)
+	$(call if_changed,vdso32ld)

OK

arch/ppc64/kernel/vdso32/Makefile line 42

Quoted 5 lines
arch/ppc64/kernel/vdso32/Makefile new file +5 -0
+
+# assembly rules for the .S files
+# This is probably wrong with split src & obj trees
+$(obj-vdso32): %.o: %.S
+	$(call if_changed_dep,vdso32as)

OK - but see below

arch/ppc64/kernel/vdso32/Makefile line 45

Quoted 2 lines
arch/ppc64/kernel/vdso32/Makefile new file +2 -0
+# actual build commands
+quiet_cmd_vdso32ld = VDSO32L $@
      cmd_vdso32ld = $(CROSS32CC) $(cflags) -Wl,-T $^ -o $@

Utilising $(cflags) gives:
-> Correct $(depfile)
-> Expanded include paths

arch/ppc64/kernel/vdso32/Makefile

Quoted 2 lines
arch/ppc64/kernel/vdso32/Makefile new file +2 -0
+quiet_cmd_vdso32as = VDSO32A $@
+      cmd_vdso32as = $(CROSS32CC) $(aflags) -c -o $@ $^

Same here.

arch/ppc64/kernel/vdso32/Makefile line 51

Quoted 2 lines
arch/ppc64/kernel/vdso32/Makefile new file +2 -0
+
+targets += vdso32.so

OK - but put it closer to the rule that generates it.