]> git.baikalelectronics.ru Git - kernel.git/commitdiff
powerpc/vdso: augment VDSO32 functions to support 64 bits build
authorChristophe Leroy <christophe.leroy@csgroup.eu>
Fri, 21 Jan 2022 16:30:21 +0000 (16:30 +0000)
committerMichael Ellerman <mpe@ellerman.id.au>
Sat, 12 Feb 2022 11:47:43 +0000 (22:47 +1100)
VDSO64 cacheflush.S datapage.S gettimeofday.S and vgettimeofday.c
are very similar to their VDSO32 counterpart.

VDSO32 counterpart is already more complete than the VDSO64 version
as it supports both PPC32 vdso and 32 bits VDSO for PPC64.

Use compat macros wherever necessary in PPC32 files
so that they can also be used to build VDSO64.

vdso64/note.S is already a link to vdso32/note.S so
no change is required.

Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/c2cbb8f046b7efc251053521dc39b752795e26b7.1642782130.git.christophe.leroy@csgroup.eu
arch/powerpc/include/asm/asm-compat.h
arch/powerpc/kernel/vdso32/cacheflush.S
arch/powerpc/kernel/vdso32/datapage.S
arch/powerpc/kernel/vdso32/getcpu.S
arch/powerpc/kernel/vdso32/gettimeofday.S
arch/powerpc/kernel/vdso32/vgettimeofday.c

index 2b736d9fbb1b905caa2e2c741d739e3f984ef5a7..2bc53c646ccd7d80666c02615f5ac01aa4fc0263 100644 (file)
@@ -21,6 +21,7 @@
 #define PPC_STLCX      stringify_in_c(stdcx.)
 #define PPC_CNTLZL     stringify_in_c(cntlzd)
 #define PPC_MTOCRF(FXM, RS) MTOCRF((FXM), RS)
+#define PPC_SRL                stringify_in_c(srd)
 #define PPC_LR_STKOFF  16
 #define PPC_MIN_STKFRM 112
 
@@ -54,6 +55,7 @@
 #define PPC_STLCX      stringify_in_c(stwcx.)
 #define PPC_CNTLZL     stringify_in_c(cntlzw)
 #define PPC_MTOCRF     stringify_in_c(mtcrf)
+#define PPC_SRL                stringify_in_c(srw)
 #define PPC_LR_STKOFF  4
 #define PPC_MIN_STKFRM 16
 
index f340e82d1981a19a69b1644f1e1fc4c0f1e1f4d8..d4e43ab2d5df55fd1ebb196acbcebf50bca49c97 100644 (file)
@@ -46,7 +46,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_COHERENT_ICACHE)
        add     r8,r8,r5                /* ensure we get enough */
 #ifdef CONFIG_PPC64
        lwz     r9,CFG_DCACHE_LOGBLOCKSZ(r10)
-       srw.    r8,r8,r9                /* compute line count */
+       PPC_SRL.        r8,r8,r9                /* compute line count */
 #else
        srwi.   r8, r8, L1_CACHE_SHIFT
        mr      r7, r6
@@ -72,7 +72,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_COHERENT_ICACHE)
        subf    r8,r6,r4                /* compute length */
        add     r8,r8,r5
        lwz     r9,CFG_ICACHE_LOGBLOCKSZ(r10)
-       srw.    r8,r8,r9                /* compute line count */
+       PPC_SRL.        r8,r8,r9                /* compute line count */
        crclr   cr0*4+so
        beqlr                           /* nothing to do? */
 #endif
index 65244416ab94b932cb44152b01339034ba8149d8..db8e167f01667eb95b3dc74f6771e610411bba90 100644 (file)
@@ -30,11 +30,15 @@ V_FUNCTION_BEGIN(__kernel_get_syscall_map)
        mr.     r4,r3
        get_datapage    r3
        mtlr    r12
+#ifdef __powerpc64__
+       addi    r3,r3,CFG_SYSCALL_MAP64
+#else
        addi    r3,r3,CFG_SYSCALL_MAP32
+#endif
+       crclr   cr0*4+so
        beqlr
        li      r0,NR_syscalls
        stw     r0,0(r4)
-       crclr   cr0*4+so
        blr
   .cfi_endproc
 V_FUNCTION_END(__kernel_get_syscall_map)
@@ -49,8 +53,10 @@ V_FUNCTION_BEGIN(__kernel_get_tbfreq)
        mflr    r12
   .cfi_register lr,r12
        get_datapage    r3
+#ifndef __powerpc64__
        lwz     r4,(CFG_TB_TICKS_PER_SEC + 4)(r3)
-       lwz     r3,CFG_TB_TICKS_PER_SEC(r3)
+#endif
+       PPC_LL  r3,CFG_TB_TICKS_PER_SEC(r3)
        mtlr    r12
        crclr   cr0*4+so
        blr
index ff5e214fec415ef51accb450af88683b13c61687..8e08ccf19062194a944e1ed7946b528fa22fdd32 100644 (file)
@@ -19,8 +19,8 @@
 V_FUNCTION_BEGIN(__kernel_getcpu)
   .cfi_startproc
        mfspr   r5,SPRN_SPRG_VDSO_READ
-       cmpwi   cr0,r3,0
-       cmpwi   cr1,r4,0
+       PPC_LCMPI       cr0,r3,0
+       PPC_LCMPI       cr1,r4,0
        clrlwi  r6,r5,16
        rlwinm  r7,r5,16,31-15,31-0
        beq     cr0,1f
index d21d08140a5eba1fa03abf691d431bfb3076cf66..c875312274aa705e0db8b733f6c50c75a4590c89 100644 (file)
@@ -1,7 +1,7 @@
 /* SPDX-License-Identifier: GPL-2.0-or-later */
 /*
- * Userland implementation of gettimeofday() for 32 bits processes in a
- * ppc64 kernel for use in the vDSO
+ * Userland implementation of gettimeofday() for processes
+ * for use in the vDSO
  *
  * Copyright (C) 2004 Benjamin Herrenschmuidt (benh@kernel.crashing.org,
  *                    IBM Corp.
@@ -41,9 +41,11 @@ V_FUNCTION_END(__kernel_clock_gettime)
  * int __kernel_clock_gettime64(clockid_t clock_id, struct __timespec64 *ts);
  *
  */
+#ifndef __powerpc64__
 V_FUNCTION_BEGIN(__kernel_clock_gettime64)
        cvdso_call __c_kernel_clock_gettime64
 V_FUNCTION_END(__kernel_clock_gettime64)
+#endif
 
 /*
  * Exact prototype of clock_getres()
@@ -69,6 +71,7 @@ V_FUNCTION_END(__kernel_time)
 /* Routines for restoring integer registers, called by the compiler.  */
 /* Called with r11 pointing to the stack header word of the caller of the */
 /* function, just beyond the end of the integer restore area.  */
+#ifndef __powerpc64__
 _GLOBAL(_restgpr_31_x)
 _GLOBAL(_rest32gpr_31_x)
        lwz     r0,4(r11)
@@ -76,3 +79,4 @@ _GLOBAL(_rest32gpr_31_x)
        mtlr    r0
        mr      r1,r11
        blr
+#endif
index 65fb03fb1731ae9e7ce32f37088a890c77b7a12e..55a287c9a7366aa59ab4af1e760a8995f588a4d5 100644 (file)
@@ -2,8 +2,22 @@
 /*
  * Powerpc userspace implementations of gettimeofday() and similar.
  */
+#include <linux/time.h>
 #include <linux/types.h>
 
+#ifdef __powerpc64__
+int __c_kernel_clock_gettime(clockid_t clock, struct __kernel_timespec *ts,
+                            const struct vdso_data *vd)
+{
+       return __cvdso_clock_gettime_data(vd, clock, ts);
+}
+
+int __c_kernel_clock_getres(clockid_t clock_id, struct __kernel_timespec *res,
+                           const struct vdso_data *vd)
+{
+       return __cvdso_clock_getres_data(vd, clock_id, res);
+}
+#else
 int __c_kernel_clock_gettime(clockid_t clock, struct old_timespec32 *ts,
                             const struct vdso_data *vd)
 {
@@ -16,16 +30,17 @@ int __c_kernel_clock_gettime64(clockid_t clock, struct __kernel_timespec *ts,
        return __cvdso_clock_gettime_data(vd, clock, ts);
 }
 
-int __c_kernel_gettimeofday(struct __kernel_old_timeval *tv, struct timezone *tz,
+int __c_kernel_clock_getres(clockid_t clock_id, struct old_timespec32 *res,
                            const struct vdso_data *vd)
 {
-       return __cvdso_gettimeofday_data(vd, tv, tz);
+       return __cvdso_clock_getres_time32_data(vd, clock_id, res);
 }
+#endif
 
-int __c_kernel_clock_getres(clockid_t clock_id, struct old_timespec32 *res,
+int __c_kernel_gettimeofday(struct __kernel_old_timeval *tv, struct timezone *tz,
                            const struct vdso_data *vd)
 {
-       return __cvdso_clock_getres_time32_data(vd, clock_id, res);
+       return __cvdso_gettimeofday_data(vd, tv, tz);
 }
 
 __kernel_old_time_t __c_kernel_time(__kernel_old_time_t *time, const struct vdso_data *vd)