#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
 
 #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
 
 
        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
        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
 
        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)
        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
 
 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
 
 /* 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.
  * 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()
 /* 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)
        mtlr    r0
        mr      r1,r11
        blr
+#endif
 
 /*
  * 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)
 {
        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)