Re: [RFC PATCH 13/25] kvx: Add signal handling support

Mark Rutland
2023-01-04T11:28:12Z

On Tue, Jan 03, 2023 at 05:43:47PM +0100, Yann Sionneau wrote:
> Add sigcontext definition and signal handling support for
> kvx.

[...]

> +asmlinkage void do_work_pending(struct pt_regs *regs,
> + unsigned long thread_flags)
> +{
> + /* We are called with IRQs disabled */
> + trace_hardirqs_off();
> +
> + do {
> + if (thread_flags & _TIF_NEED_RESCHED) {
> + schedule();
> + } else {
> + local_irq_enable();
> + if (thread_flags & (_TIF_SIGPENDING | _TIF_NOTIFY_SIGNAL))
> + do_signal(regs);
> +
> + if (thread_flags & _TIF_NOTIFY_RESUME) {
> + clear_thread_flag(TIF_NOTIFY_RESUME);
> + resume_user_mode_work(regs);
> + }
> + }
> + /* Guarantee task flag atomic read */
> + local_irq_disable();
> + thread_flags = READ_ONCE(current_thread_info()->flags);

The comment here is a bit misleading; disabling IRQs doesn't affect the
atomicity of the read (and flags can be set by remote threads), so I'd
recommend removing it.

Please use read_thread_flags() to read the flags.

> + } while (thread_flags & _TIF_WORK_MASK);
> +}

Thanks,
Mark.