1/* SPDX-License-Identifier: GPL-2.0-or-later */
2/*
3 *
4 * Copyright (C) IBM Corporation, 2012
5 *
6 * Author: Anton Blanchard <anton@au.ibm.com>
7 */
8#include <asm/ppc_asm.h>
9#include <asm/vdso.h>
10
11 .text
12/*
13 * Exact prototype of getcpu
14 *
15 * int __kernel_getcpu(unsigned *cpu, unsigned *node);
16 *
17 */
18#if defined(CONFIG_PPC64)
19V_FUNCTION_BEGIN(__kernel_getcpu)
20 .cfi_startproc
21 mfspr r5,SPRN_SPRG_VDSO_READ
22 PPC_LCMPI cr0,r3,0
23 PPC_LCMPI cr1,r4,0
24 clrlwi r6,r5,16
25 rlwinm r7,r5,16,31-15,31-0
26 beq cr0,1f
27 stw r6,0(r3)
281: crclr cr0*4+so
29 li r3,0 /* always success */
30 beqlr cr1
31 stw r7,0(r4)
32 blr
33 .cfi_endproc
34V_FUNCTION_END(__kernel_getcpu)
35#elif !defined(CONFIG_SMP)
36V_FUNCTION_BEGIN(__kernel_getcpu)
37 .cfi_startproc
38 cmpwi cr0, r3, 0
39 cmpwi cr1, r4, 0
40 li r5, 0
41 beq cr0, 1f
42 stw r5, 0(r3)
431: li r3, 0 /* always success */
44 crclr cr0*4+so
45 beqlr cr1
46 stw r5, 0(r4)
47 blr
48 .cfi_endproc
49V_FUNCTION_END(__kernel_getcpu)
50#endif
51

source code of linux/arch/powerpc/kernel/vdso/getcpu.S