Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Will Deacon <will@kernel.org>
To: "Guilherme G. Piccoli" <gpiccoli@igalia.com>
Cc: linux-arm-kernel@lists.infradead.org, catalin.marinas@arm.com,
	mark.rutland@arm.com, robin.murphy@arm.com, gshan@redhat.com,
	kernel-dev@igalia.com, kernel@gpiccoli.net,
	Mark Brown <broonie@kernel.org>,
	Ryan Houdek <sonicadvance1@gmail.com>
Subject: Re: [PATCH] arm64/kernel: Expose the running CPU of a native task in TPIDRRO_EL0
Date: Sun, 16 Aug 2026 10:51:12 +0100	[thread overview]
Message-ID: <aoGIEEje1NIMTjyv@willie-the-truck> (raw)
In-Reply-To: <20260815152759.2046231-1-gpiccoli@igalia.com>

On Sat, Aug 15, 2026 at 12:19:32PM -0300, Guilherme G. Piccoli wrote:
> The register TPIDRRO_EL0 has 2 meanings / usages today, depending on
> the mode userspace is running:
> 
> - For native/arm64 mode, this register is always 0 from the userspace
>   perspective. In the kernel, it is used during ventry (entry.S) as
>   a scratch register, related to KPTI (stashes x30 in fact).
> 
> - For 32-bit compat tasks, this register holds the TLS userspace pointer,
>   and is not used for KPTI or anything else in entry.S. This is ABI and
>   userspace can count on having a valid TLS pointer there.
> 
> Happens that other operating systems follow a similar approach than 32-bit
> compat mode, even for arm64: in both Windows[0] and MacOS (xnu/darwin)[1],
> this register is used to hold the running CPU of the current task, hence
> offering a very fast / non-syscall way for a given task to figure its
> running CPU id.

I don't think we should allocate TPIDRRO_EL0 for this as it precludes us
using it for anything else in the future. If you want the current CPU,
then I think you're better off using either rseq (which I thought could
do this) or looking at reviving the vDSO work you mention (but that has
unresolved limitations iirc).

Will


  parent reply	other threads:[~2026-08-16  9:51 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-15 15:19 [PATCH] arm64/kernel: Expose the running CPU of a native task in TPIDRRO_EL0 Guilherme G. Piccoli
2026-08-15 16:52 ` Bradley Morgan
2026-08-17 14:51   ` Guilherme G. Piccoli
2026-08-17 14:56     ` Bradley Morgan
2026-08-16  9:51 ` Will Deacon [this message]
2026-08-17  8:51   ` Catalin Marinas
2026-08-17 12:53     ` Ryan Houdek
2026-08-17 14:48     ` Guilherme G. Piccoli

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=aoGIEEje1NIMTjyv@willie-the-truck \
    --to=will@kernel.org \
    --cc=broonie@kernel.org \
    --cc=catalin.marinas@arm.com \
    --cc=gpiccoli@igalia.com \
    --cc=gshan@redhat.com \
    --cc=kernel-dev@igalia.com \
    --cc=kernel@gpiccoli.net \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=mark.rutland@arm.com \
    --cc=robin.murphy@arm.com \
    --cc=sonicadvance1@gmail.com \
    /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