[PATCH 2/3] arm64: Move do_notify_resume() to entry-common.c

Mark Rutland mark.rutland at arm.com
Tue Feb 27 02:24:12 PST 2024


On Tue, Feb 27, 2024 at 11:25:32AM +0800, Liao, Chang wrote:
> Hi, Mark
> 
> 在 2024/2/6 20:38, Mark Rutland 写道:
> > +static void do_notify_resume(struct pt_regs *regs, unsigned long thread_flags)
> > +{
> > +	do {
> > +		local_daif_restore(DAIF_PROCCTX);
> > +
> > +		if (thread_flags & _TIF_NEED_RESCHED)
> > +			schedule();
> > +
> > +		if (thread_flags & _TIF_UPROBE)
> > +			uprobe_notify_resume(regs);
> > +
> > +		if (thread_flags & _TIF_MTE_ASYNC_FAULT) {
> > +			clear_thread_flag(TIF_MTE_ASYNC_FAULT);
> > +			send_sig_fault(SIGSEGV, SEGV_MTEAERR,
> > +				       (void __user *)NULL, current);
> > +		}
> > +
> > +		if (thread_flags & (_TIF_SIGPENDING | _TIF_NOTIFY_SIGNAL))
> > +			do_signal(regs);
> > +
> > +		if (thread_flags & _TIF_NOTIFY_RESUME)
> > +			resume_user_mode_work(regs);
> > +
> > +		if (thread_flags & _TIF_FOREIGN_FPSTATE)
> > +			fpsimd_restore_current_state();
> > +
> > +		local_daif_mask();
> > +		thread_flags = read_thread_flags();
> > +	} while (thread_flags & _TIF_WORK_MASK);
> > +}
> 
> What about moving load_daif_restore() and load_daif_mask() outside of the do-while loop?
> Invoking them repeatedlly within the loop is redundant, right?

It's not entirely redundant -- we don't want to take an interrupt between the
last read of the thread flags and the actual return to userspace.

The next patch moves the DAIF masking out, so that we only have to mask+unmask
IRQ+FIQ here, but masking those is necessary. That matches the logic in the
generic exit_to_user_mode_loop().

Mark.



More information about the linux-arm-kernel mailing list