Skip to content

Commit a0f2a8d

Browse files
hcahcaVasily Gorbik
authored andcommitted
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 <[email protected]> Signed-off-by: Heiko Carstens <[email protected]> Signed-off-by: Vasily Gorbik <[email protected]>
1 parent b465254 commit a0f2a8d

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
@@ -82,63 +82,50 @@ SYSCALL_DEFINE0(ni_syscall)
8282
return -ENOSYS;
8383
}
8484

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

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

0 commit comments

Comments
 (0)