]> git.baikalelectronics.ru Git - kernel.git/commitdiff
s390: move restart of execve() syscall
authorSven Schnelle <svens@linux.ibm.com>
Wed, 30 Jun 2021 11:50:55 +0000 (13:50 +0200)
committerVasily Gorbik <gor@linux.ibm.com>
Thu, 8 Jul 2021 20:12:17 +0000 (22:12 +0200)
On s390, execve might have to be restarted for PGSTE binaries
like kvm. In the past this was done via the PIF_SYSCALL_RESTART
bit. However, with the recent changes, syscalls are now restarted
differently. Now that execve() is the only call that might get
restarted via PIF_SYSCALL_RESTART, move the loop to do_syscall().
This also has the advantage that the restart is no longer visible
to userspace.

Signed-off-by: Sven Schnelle <svens@linux.ibm.com>
Reviewed-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
arch/s390/include/asm/ptrace.h
arch/s390/kernel/syscall.c

index c7850d649373f2ecc85a288c53e8f8391a4a432d..808da21235ab7ed5010d0d8eca5b5e51f2cc43e3 100644 (file)
@@ -162,6 +162,14 @@ static inline int test_pt_regs_flag(struct pt_regs *regs, int flag)
        return !!(regs->flags & (1UL << flag));
 }
 
+static inline int test_and_clear_pt_regs_flag(struct pt_regs *regs, int flag)
+{
+       int ret = test_pt_regs_flag(regs, flag);
+
+       clear_pt_regs_flag(regs, flag);
+       return ret;
+}
+
 /*
  * These are defined as per linux/ptrace.h, which see.
  */
index ec73d2c61e58ad808724e340ff366c00495cbf56..0322f00f84ac4e023d24ae7b3640781cc3969c00 100644 (file)
@@ -134,13 +134,15 @@ static void do_syscall(struct pt_regs *regs)
         * work, the ptrace code sets PIF_SYSCALL_RET_SET, which is checked here
         * and if set, the syscall will be skipped.
         */
-       if (!test_pt_regs_flag(regs, PIF_SYSCALL_RET_SET)) {
-               regs->gprs[2] = -ENOSYS;
-               if (likely(nr < NR_syscalls))
-                       regs->gprs[2] = current->thread.sys_call_table[nr](regs);
-       } else {
-               clear_pt_regs_flag(regs, PIF_SYSCALL_RET_SET);
-       }
+       if (unlikely(test_and_clear_pt_regs_flag(regs, PIF_SYSCALL_RET_SET)))
+               goto out;
+       regs->gprs[2] = -ENOSYS;
+       if (likely(nr >= NR_syscalls))
+               goto out;
+       do {
+               regs->gprs[2] = current->thread.sys_call_table[nr](regs);
+       } while (test_and_clear_pt_regs_flag(regs, PIF_SYSCALL_RESTART));
+out:
        syscall_exit_to_user_mode_work(regs);
 }
 
@@ -158,13 +160,8 @@ void noinstr __do_syscall(struct pt_regs *regs, int per_trap)
        if (per_trap)
                set_thread_flag(TIF_PER_TRAP);
 
-       for (;;) {
-               regs->flags = 0;
-               set_pt_regs_flag(regs, PIF_SYSCALL);
-               do_syscall(regs);
-               if (!test_pt_regs_flag(regs, PIF_SYSCALL_RESTART))
-                       break;
-               local_irq_enable();
-       }
+       regs->flags = 0;
+       set_pt_regs_flag(regs, PIF_SYSCALL);
+       do_syscall(regs);
        exit_to_user_mode();
 }