public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
From: Mark Rutland <mark.rutland@arm.com>
To: "Liao, Chang" <liaochang1@huawei.com>
Cc: linux-arm-kernel@lists.infradead.org, broonie@kernel.org,
	Catalin Marinas <catalin.marinas@arm.com>,
	james.morse@arm.com, Will Deacon <will@kernel.org>
Subject: Re: [PATCH 2/3] arm64: Move do_notify_resume() to entry-common.c
Date: Tue, 27 Feb 2024 10:24:12 +0000	[thread overview]
Message-ID: <Zd24TD0YiVCp0wAa@FVFF77S0Q05N> (raw)
In-Reply-To: <70050ddf-d3ed-70c0-d27d-bbf6910ab95a@huawei.com>

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.

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2024-02-27 10:24 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-06 12:38 [PATCH 0/3] arm64: cleanup DAIF handling for EL0 returns Mark Rutland
2024-02-06 12:38 ` [PATCH 1/3] arm64: Simplify do_notify_resume() DAIF masking Mark Rutland
2024-02-08 14:04   ` Mark Brown
2024-02-06 12:38 ` [PATCH 2/3] arm64: Move do_notify_resume() to entry-common.c Mark Rutland
2024-02-06 12:52   ` Mark Brown
2024-02-27  3:25   ` Liao, Chang
2024-02-27 10:24     ` Mark Rutland [this message]
2024-02-06 12:38 ` [PATCH 3/3] arm64: Unmask Debug + SError in do_notify_resume() Mark Rutland
2024-02-08 14:08   ` Mark Brown
2024-02-08  2:28 ` [PATCH 0/3] arm64: cleanup DAIF handling for EL0 returns Itaru Kitayama
2024-02-08 12:38   ` Mark Rutland
2024-02-08 20:53     ` Itaru Kitayama
2024-02-20 18:19 ` Catalin Marinas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Zd24TD0YiVCp0wAa@FVFF77S0Q05N \
    --to=mark.rutland@arm.com \
    --cc=broonie@kernel.org \
    --cc=catalin.marinas@arm.com \
    --cc=james.morse@arm.com \
    --cc=liaochang1@huawei.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=will@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox