kernel: add support for TIF_NOTIFY_SIGNAL
authorJens Axboe <axboe@kernel.dk>
Sat, 3 Oct 2020 13:18:19 +0000 (07:18 -0600)
committerJens Axboe <axboe@kernel.dk>
Mon, 26 Oct 2020 14:45:33 +0000 (08:45 -0600)
commita1a5bc3e8659ffc002cbb074c389b34632f0c5f3
tree69c87eccc133dd00dd215f9014473da9e0f01fc3
parentc0947f6b6ed220acd67a39795d74267c1bc21355
kernel: add support for TIF_NOTIFY_SIGNAL

This adds TIF_NOTIFY_SIGNAL handling in the generic code, which if set,
will return true if signal_pending() is used in a wait loop. That causes
an exit of the loop so that notify_signal tracehooks can be run. If the
wait loop is currently inside a system call, the system call is restarted
once task_work has been processed.

In preparation for only having arch_do_signal() handle syscall restarts
if _TIF_SIGPENDING isn't set, rename it to arch_do_signal_or_restart().
Pass in a boolean that tells the arch signal handler if it should attempt
to get a signal, or just process a potential syscall restart.

For !CONFIG_GENERIC_ENTRY archs, we add the TIF_NOTIFY_SIGNAL handling
to get_signal(). This is done to minimize the needed arch changes to
support this feature.

Reviewed-by: Oleg Nesterov <oleg@redhat.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
arch/x86/kernel/signal.c
include/linux/entry-common.h
include/linux/entry-kvm.h
include/linux/sched/signal.h
include/linux/tracehook.h
kernel/entry/common.c
kernel/entry/kvm.c
kernel/signal.c