[PATCH] powerpc: Make the vDSO functions set error code

Benjamin Herrenschmidt benh at kernel.crashing.org
Tue Nov 15 17:21:12 EST 2005


The vDSO functions should have the same calling convention as a syscall.
Unfortunately, they currently don't set the cr0.so bit which is used to
indicate an error. This patch makes them clear this bit unconditionally
since all functions currently succeed. The syscall fallback done by some
of them will eventually override this if the syscall fails.

This also changes the symbol version of all vdso exports to make sure
glibc can differenciate between old and fixed calls for existing ones
like __kernel_gettimeofday.

Signed-off-by: Benjamin Herrenschmidt <benh at kernel.crashing.org>
---

Tom, Steve: You'll have to write a wrapper macro to call the vdso
similar to the syscall one, that does something like:

   mtctr   %0 <--- function address
   bctrl
   mfcr    %1 <--- error indication in cr0.so 

With appropriate clobbers, similar to the syscall macro (the vDSO
clobbers all volatile register (r0, r3 ... r12, cr0, cr1 and XER)

The advantage of doing so is that you don't have to create fake
descriptors for ppc64 and thus avoid useless TOC reloads, you can even
have a single macro that works on both 32 and 64 bits.

Index: linux-work/arch/powerpc/kernel/vdso32/cacheflush.S
===================================================================
--- linux-work.orig/arch/powerpc/kernel/vdso32/cacheflush.S	2005-11-14 10:41:58.000000000 +1100
+++ linux-work/arch/powerpc/kernel/vdso32/cacheflush.S	2005-11-15 17:11:51.000000000 +1100
@@ -30,6 +30,7 @@
  */
 V_FUNCTION_BEGIN(__kernel_sync_dicache)
   .cfi_startproc
+	crclr	cr0*4+so
 	li	r5,127
 	andc	r6,r3,r5		/* round low to line bdy */
 	subf	r8,r6,r4		/* compute length */
@@ -58,6 +59,7 @@
  */
 V_FUNCTION_BEGIN(__kernel_sync_dicache_p5)
   .cfi_startproc
+	crclr	cr0*4+so
 	sync
 	isync
 	li	r3,0
Index: linux-work/arch/powerpc/kernel/vdso32/datapage.S
===================================================================
--- linux-work.orig/arch/powerpc/kernel/vdso32/datapage.S	2005-11-15 13:31:58.000000000 +1100
+++ linux-work/arch/powerpc/kernel/vdso32/datapage.S	2005-11-15 17:10:46.000000000 +1100
@@ -52,6 +52,7 @@
  */
 V_FUNCTION_BEGIN(__kernel_get_syscall_map)
   .cfi_startproc
+	crclr	cr0*4+so
 	mflr	r12
   .cfi_register lr,r12
 
@@ -74,6 +75,7 @@
  */
 V_FUNCTION_BEGIN(__kernel_get_tbfreq)
   .cfi_startproc
+	crclr	cr0*4+so
 	mflr	r12
   .cfi_register lr,r12
 	bl	__get_datapage at local
Index: linux-work/arch/powerpc/kernel/vdso32/gettimeofday.S
===================================================================
--- linux-work.orig/arch/powerpc/kernel/vdso32/gettimeofday.S	2005-11-15 13:31:58.000000000 +1100
+++ linux-work/arch/powerpc/kernel/vdso32/gettimeofday.S	2005-11-15 17:10:10.000000000 +1100
@@ -26,6 +26,7 @@
  */
 V_FUNCTION_BEGIN(__kernel_gettimeofday)
   .cfi_startproc
+	crclr	cr0*4+so
 	mflr	r12
   .cfi_register lr,r12
 
@@ -80,6 +81,7 @@
  */
 V_FUNCTION_BEGIN(__kernel_clock_gettime)
   .cfi_startproc
+	crclr	cr0*4+so
 	/* Check for supported clock IDs */
 	cmpli	cr0,r3,CLOCK_REALTIME
 	cmpli	cr1,r3,CLOCK_MONOTONIC
@@ -211,6 +213,7 @@
  */
 V_FUNCTION_BEGIN(__kernel_clock_getres)
   .cfi_startproc
+	crclr	cr0*4+so
 	/* Check for supported clock IDs */
 	cmpwi	cr0,r3,CLOCK_REALTIME
 	cmpwi	cr1,r3,CLOCK_MONOTONIC
Index: linux-work/arch/powerpc/kernel/vdso64/cacheflush.S
===================================================================
--- linux-work.orig/arch/powerpc/kernel/vdso64/cacheflush.S	2005-11-14 10:41:58.000000000 +1100
+++ linux-work/arch/powerpc/kernel/vdso64/cacheflush.S	2005-11-15 17:12:53.000000000 +1100
@@ -30,6 +30,7 @@
  */
 V_FUNCTION_BEGIN(__kernel_sync_dicache)
   .cfi_startproc
+	crclr	cr0*4+so
 	li	r5,127
 	andc	r6,r3,r5		/* round low to line bdy */
 	subf	r8,r6,r4		/* compute length */
@@ -58,6 +59,7 @@
  */
 V_FUNCTION_BEGIN(__kernel_sync_dicache_p5)
   .cfi_startproc
+	crclr	cr0*4+so
 	sync
 	isync
 	li	r3,0
Index: linux-work/arch/powerpc/kernel/vdso64/datapage.S
===================================================================
--- linux-work.orig/arch/powerpc/kernel/vdso64/datapage.S	2005-11-15 13:31:58.000000000 +1100
+++ linux-work/arch/powerpc/kernel/vdso64/datapage.S	2005-11-15 17:12:39.000000000 +1100
@@ -52,6 +52,7 @@
  */
 V_FUNCTION_BEGIN(__kernel_get_syscall_map)
   .cfi_startproc
+	crclr	cr0*4+so
 	mflr	r12
   .cfi_register lr,r12
 
@@ -75,6 +76,7 @@
  */
 V_FUNCTION_BEGIN(__kernel_get_tbfreq)
   .cfi_startproc
+	crclr	cr0*4+so
 	mflr	r12
   .cfi_register lr,r12
 	bl	V_LOCAL_FUNC(__get_datapage)
Index: linux-work/arch/powerpc/kernel/vdso64/gettimeofday.S
===================================================================
--- linux-work.orig/arch/powerpc/kernel/vdso64/gettimeofday.S	2005-11-15 13:31:58.000000000 +1100
+++ linux-work/arch/powerpc/kernel/vdso64/gettimeofday.S	2005-11-15 17:12:29.000000000 +1100
@@ -27,6 +27,7 @@
  */
 V_FUNCTION_BEGIN(__kernel_gettimeofday)
   .cfi_startproc
+	crclr	cr0*4+so
 	mflr	r12
   .cfi_register lr,r12
 
@@ -66,6 +67,7 @@
  */
 V_FUNCTION_BEGIN(__kernel_clock_gettime)
   .cfi_startproc
+	crclr	cr0*4+so
 	/* Check for supported clock IDs */
 	cmpwi	cr0,r3,CLOCK_REALTIME
 	cmpwi	cr1,r3,CLOCK_MONOTONIC
@@ -185,6 +187,7 @@
  */
 V_FUNCTION_BEGIN(__kernel_clock_getres)
   .cfi_startproc
+	crclr	cr0*4+so
 	/* Check for supported clock IDs */
 	cmpwi	cr0,r3,CLOCK_REALTIME
 	cmpwi	cr1,r3,CLOCK_MONOTONIC
Index: linux-work/include/asm-powerpc/vdso.h
===================================================================
--- linux-work.orig/include/asm-powerpc/vdso.h	2005-11-14 10:42:00.000000000 +1100
+++ linux-work/include/asm-powerpc/vdso.h	2005-11-15 17:17:20.000000000 +1100
@@ -11,7 +11,7 @@
 #define VDSO32_MBASE	VDSO32_LBASE
 #define VDSO64_MBASE	VDSO64_LBASE
 
-#define VDSO_VERSION_STRING	LINUX_2.6.12
+#define VDSO_VERSION_STRING	LINUX_2.6.15
 
 /* Define if 64 bits VDSO has procedure descriptors */
 #undef VDS64_HAS_DESCRIPTORS





More information about the Linuxppc64-dev mailing list