^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0-or-later */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * Access to the shared data page by the vDSO & syscall map
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * Copyright (C) 2004 Benjamin Herrenschmuidt (benh@kernel.crashing.org), IBM Corp.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) #include <asm/processor.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) #include <asm/ppc_asm.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include <asm/asm-offsets.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <asm/unistd.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <asm/vdso.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include <asm/vdso_datapage.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) .text
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) .global __kernel_datapage_offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) __kernel_datapage_offset:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) .long 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) * void *__kernel_get_syscall_map(unsigned int *syscall_count) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) * returns a pointer to the syscall map. the map is agnostic to the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) * size of "long", unlike kernel bitops, it stores bits from top to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) * bottom so that memory actually contains a linear bitmap
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) * check for syscall N by testing bit (0x80000000 >> (N & 0x1f)) of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) * 32 bits int at N >> 5.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) V_FUNCTION_BEGIN(__kernel_get_syscall_map)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) .cfi_startproc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) mflr r12
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) .cfi_register lr,r12
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) mr r4,r3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) get_datapage r3, r0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) mtlr r12
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) addi r3,r3,CFG_SYSCALL_MAP64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) cmpldi cr0,r4,0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) crclr cr0*4+so
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) beqlr
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) li r0,NR_syscalls
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) stw r0,0(r4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) blr
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) .cfi_endproc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) V_FUNCTION_END(__kernel_get_syscall_map)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) * void unsigned long __kernel_get_tbfreq(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) * returns the timebase frequency in HZ
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) V_FUNCTION_BEGIN(__kernel_get_tbfreq)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) .cfi_startproc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) mflr r12
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) .cfi_register lr,r12
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) get_datapage r3, r0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) ld r3,CFG_TB_TICKS_PER_SEC(r3)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) mtlr r12
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) crclr cr0*4+so
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) blr
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) .cfi_endproc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) V_FUNCTION_END(__kernel_get_tbfreq)