Commit fbcee2eb authored by Christophe Leroy's avatar Christophe Leroy Committed by Michael Ellerman
Browse files

powerpc/32: Always save non volatile GPRs at syscall entry



In preparation for porting syscall entry/exit to C, inconditionally
save non volatile general purpose registers.

Commit 965dd3ad ("powerpc/64/syscall: Remove non-volatile GPR save
optimisation") provides detailed explanation.

This increases the number of cycles by 24 cycles on 8xx with
null_syscall benchmark (280 => 304 cycles)

Signed-off-by: default avatarChristophe Leroy <christophe.leroy@csgroup.eu>
Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/21c08162b83655195fe9ead78ff2cfd28508d023.1612796617.git.christophe.leroy@csgroup.eu
parent c01b9166
Loading
Loading
Loading
Loading
+1 −45
Original line number Diff line number Diff line
@@ -351,6 +351,7 @@ trace_syscall_entry_irq_off:

	.globl	transfer_to_syscall
transfer_to_syscall:
	SAVE_NVGPRS(r1)
#ifdef CONFIG_PPC_BOOK3S_32
	kuep_lock r11, r12
#endif
@@ -614,51 +615,6 @@ ret_from_kernel_syscall:
#endif
_ASM_NOKPROBE_SYMBOL(ret_from_kernel_syscall)

/*
 * The fork/clone functions need to copy the full register set into
 * the child process. Therefore we need to save all the nonvolatile
 * registers (r13 - r31) before calling the C code.
 */
	.globl	ppc_fork
ppc_fork:
	SAVE_NVGPRS(r1)
	lwz	r0,_TRAP(r1)
	rlwinm	r0,r0,0,0,30		/* clear LSB to indicate full */
	stw	r0,_TRAP(r1)		/* register set saved */
	b	sys_fork

	.globl	ppc_vfork
ppc_vfork:
	SAVE_NVGPRS(r1)
	lwz	r0,_TRAP(r1)
	rlwinm	r0,r0,0,0,30		/* clear LSB to indicate full */
	stw	r0,_TRAP(r1)		/* register set saved */
	b	sys_vfork

	.globl	ppc_clone
ppc_clone:
	SAVE_NVGPRS(r1)
	lwz	r0,_TRAP(r1)
	rlwinm	r0,r0,0,0,30		/* clear LSB to indicate full */
	stw	r0,_TRAP(r1)		/* register set saved */
	b	sys_clone

	.globl	ppc_clone3
ppc_clone3:
	SAVE_NVGPRS(r1)
	lwz	r0,_TRAP(r1)
	rlwinm	r0,r0,0,0,30		/* clear LSB to indicate full */
	stw	r0,_TRAP(r1)		/* register set saved */
	b	sys_clone3

	.globl	ppc_swapcontext
ppc_swapcontext:
	SAVE_NVGPRS(r1)
	lwz	r0,_TRAP(r1)
	rlwinm	r0,r0,0,0,30		/* clear LSB to indicate full */
	stw	r0,_TRAP(r1)		/* register set saved */
	b	sys_swapcontext

/*
 * Top-level page fault handling.
 * This is in assembler because if do_page_fault tells us that
+1 −1
Original line number Diff line number Diff line
@@ -148,7 +148,7 @@
	stw	r2,GPR2(r11)
	addi	r10,r10,STACK_FRAME_REGS_MARKER@l
	stw	r9,_MSR(r11)
	li	r2, \trapno + 1
	li	r2, \trapno
	stw	r10,8(r11)
	stw	r2,_TRAP(r11)
	SAVE_GPR(0, r11)
+1 −1
Original line number Diff line number Diff line
@@ -124,7 +124,7 @@ ALT_FTR_SECTION_END_IFSET(CPU_FTR_EMB_HV)
	stw	r2,GPR2(r11)
	addi	r12, r12, STACK_FRAME_REGS_MARKER@l
	stw	r9,_MSR(r11)
	li	r2, \trapno + 1
	li	r2, \trapno
	stw	r12, 8(r11)
	stw	r2,_TRAP(r11)
	SAVE_GPR(0, r11)
+5 −15
Original line number Diff line number Diff line
@@ -9,9 +9,7 @@
#
0	nospu	restart_syscall			sys_restart_syscall
1	nospu	exit				sys_exit
2	32	fork				ppc_fork			sys_fork
2	64	fork				sys_fork
2	spu	fork				sys_ni_syscall
2	nospu	fork				sys_fork
3	common	read				sys_read
4	common	write				sys_write
5	common	open				sys_open			compat_sys_open
@@ -160,9 +158,7 @@
119	32	sigreturn			sys_sigreturn			compat_sys_sigreturn
119	64	sigreturn			sys_ni_syscall
119	spu	sigreturn			sys_ni_syscall
120	32	clone				ppc_clone			sys_clone
120	64	clone				sys_clone
120	spu	clone				sys_ni_syscall
120	nospu	clone				sys_clone
121	common	setdomainname			sys_setdomainname
122	common	uname				sys_newuname
123	common	modify_ldt			sys_ni_syscall
@@ -244,9 +240,7 @@
186	spu	sendfile			sys_sendfile64
187	common	getpmsg				sys_ni_syscall
188	common 	putpmsg				sys_ni_syscall
189	32	vfork				ppc_vfork			sys_vfork
189	64	vfork				sys_vfork
189	spu	vfork				sys_ni_syscall
189	nospu	vfork				sys_vfork
190	common	ugetrlimit			sys_getrlimit			compat_sys_getrlimit
191	common	readahead			sys_readahead			compat_sys_readahead
192	32	mmap2				sys_mmap2			compat_sys_mmap2
@@ -322,9 +316,7 @@
248	32	clock_nanosleep			sys_clock_nanosleep_time32
248	64	clock_nanosleep			sys_clock_nanosleep
248	spu	clock_nanosleep			sys_clock_nanosleep
249	32	swapcontext			ppc_swapcontext			compat_sys_swapcontext
249	64	swapcontext			sys_swapcontext
249	spu	swapcontext			sys_ni_syscall
249	nospu	swapcontext			sys_swapcontext			compat_sys_swapcontext
250	common	tgkill				sys_tgkill
251	32	utimes				sys_utimes_time32
251	64	utimes				sys_utimes
@@ -522,9 +514,7 @@
432	common	fsmount				sys_fsmount
433	common	fspick				sys_fspick
434	common	pidfd_open			sys_pidfd_open
435	32	clone3				ppc_clone3			sys_clone3
435	64	clone3				sys_clone3
435	spu	clone3				sys_ni_syscall
435	nospu	clone3				sys_clone3
436	common	close_range			sys_close_range
437	common	openat2				sys_openat2
438	common	pidfd_getfd			sys_pidfd_getfd