Skip to content

Commit 9d93d78

Browse files
committed
s390/syscall: Merge __do_syscall() and do_syscall()
JIRA: https://issues.redhat.com/browse/RHEL-113440 commit a0f2a8d Author: Heiko Carstens <hca@linux.ibm.com> Date: Mon Mar 10 10:33:42 2025 +0100 s390/syscall: Merge __do_syscall() and do_syscall() The compiler inlines do_syscall() into __do_syscall(). Therefore do this in C code as well, since this makes the code easier to understand. Also adjust and add various unlikely() and likely() annotations. Furthermore this allows to replace the separate exit_to_user_mode() and syscall_exit_to_user_mode_work() calls with a combined syscall_exit_to_user_mode() call which results in slightly better code. Acked-by: Vasily Gorbik <gor@linux.ibm.com> Signed-off-by: Heiko Carstens <hca@linux.ibm.com> Signed-off-by: Vasily Gorbik <gor@linux.ibm.com> Signed-off-by: Thomas Huth <thuth@redhat.com>
1 parent 0b80c44 commit 9d93d78

File tree

1 file changed

+17
-30
lines changed

1 file changed

+17
-30
lines changed

arch/s390/kernel/syscall.c

Lines changed: 17 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -81,63 +81,50 @@ SYSCALL_DEFINE0(ni_syscall)
8181
return -ENOSYS;
8282
}
8383

84-
static void do_syscall(struct pt_regs *regs)
84+
void noinstr __do_syscall(struct pt_regs *regs, int per_trap)
8585
{
8686
unsigned long nr;
8787

88+
add_random_kstack_offset();
89+
enter_from_user_mode(regs);
90+
regs->psw = get_lowcore()->svc_old_psw;
91+
regs->int_code = get_lowcore()->svc_int_code;
92+
update_timer_sys();
93+
if (static_branch_likely(&cpu_has_bear))
94+
current->thread.last_break = regs->last_break;
95+
local_irq_enable();
96+
regs->orig_gpr2 = regs->gprs[2];
97+
if (unlikely(per_trap))
98+
set_thread_flag(TIF_PER_TRAP);
99+
regs->flags = 0;
100+
set_pt_regs_flag(regs, PIF_SYSCALL);
88101
nr = regs->int_code & 0xffff;
89-
if (!nr) {
102+
if (likely(!nr)) {
90103
nr = regs->gprs[1] & 0xffff;
91104
regs->int_code &= ~0xffffUL;
92105
regs->int_code |= nr;
93106
}
94-
95107
regs->gprs[2] = nr;
96-
97108
if (nr == __NR_restart_syscall && !(current->restart_block.arch_data & 1)) {
98109
regs->psw.addr = current->restart_block.arch_data;
99110
current->restart_block.arch_data = 1;
100111
}
101112
nr = syscall_enter_from_user_mode_work(regs, nr);
102-
103113
/*
104114
* In the s390 ptrace ABI, both the syscall number and the return value
105115
* use gpr2. However, userspace puts the syscall number either in the
106116
* svc instruction itself, or uses gpr1. To make at least skipping syscalls
107117
* work, the ptrace code sets PIF_SYSCALL_RET_SET, which is checked here
108118
* and if set, the syscall will be skipped.
109119
*/
110-
111120
if (unlikely(test_and_clear_pt_regs_flag(regs, PIF_SYSCALL_RET_SET)))
112121
goto out;
113122
regs->gprs[2] = -ENOSYS;
114-
if (likely(nr >= NR_syscalls))
123+
if (unlikely(nr >= NR_syscalls))
115124
goto out;
116125
do {
117126
regs->gprs[2] = current->thread.sys_call_table[nr](regs);
118127
} while (test_and_clear_pt_regs_flag(regs, PIF_EXECVE_PGSTE_RESTART));
119128
out:
120-
syscall_exit_to_user_mode_work(regs);
121-
}
122-
123-
void noinstr __do_syscall(struct pt_regs *regs, int per_trap)
124-
{
125-
add_random_kstack_offset();
126-
enter_from_user_mode(regs);
127-
regs->psw = get_lowcore()->svc_old_psw;
128-
regs->int_code = get_lowcore()->svc_int_code;
129-
update_timer_sys();
130-
if (static_branch_likely(&cpu_has_bear))
131-
current->thread.last_break = regs->last_break;
132-
133-
local_irq_enable();
134-
regs->orig_gpr2 = regs->gprs[2];
135-
136-
if (per_trap)
137-
set_thread_flag(TIF_PER_TRAP);
138-
139-
regs->flags = 0;
140-
set_pt_regs_flag(regs, PIF_SYSCALL);
141-
do_syscall(regs);
142-
exit_to_user_mode();
129+
syscall_exit_to_user_mode(regs);
143130
}

0 commit comments

Comments
 (0)