[PATCH v2 01/21] arm64: entry: Defer setting of TPIDRRO_EL0 until exit to userspace

Linus Walleij linusw at kernel.org
Wed Sep 30 13:47:00 PDT 2026


Hi Will,

long time before I had a chance to look at this.

I wrote a similar patch at one time so I like the concept.

On Fri, Sep 18, 2026 at 6:14 PM Will Deacon <will at kernel.org> wrote:

> In preparation for using TPIDRRO_EL0 to point at 'current' while running
> inside the kernel, defer its userspace initialisation from the
> context-switch patch to exception return. This has the added benefit of
> not having to worry about keeping the in-memory value and the register
> value in-sync during preemptible sections.
>
> Cc: Mark Rutland <mark.rutland at arm.com>
> Reviewed-by: Jinjie Ruan <ruanjinjie at huawei.com>
> Signed-off-by: Will Deacon <will at kernel.org>

I would add some elaboration to the commit message as to what is going
on in the patch, and  correct me if I got it wrong!

- Userspace sees 0 in the TPIDRRO_EL0 when running native tasks
  so we just zero it when exiting to userspace for those.

- For compat mode, TPIDRRO_EL0 should contain
  current->thread.uw.tp_value, so in that case we just write that
  before exiting to userspace.

- Userspace can't modify the register so we don't care about
  saving it on entry.

These three seems to be what the patch is exploiting.

If this is correct, with the above description added:

Reviewed-by: Linus Walleij <linusw at kernel.org>

Yours,
Linus Walleij



More information about the linux-arm-kernel mailing list