Linux Kernel Selftest development
 help / color / mirror / Atom feed
From: Kevin Brodsky <kevin.brodsky@arm.com>
To: Jeff Xu <jeffxu@chromium.org>
Cc: linux-arm-kernel@lists.infradead.org, akpm@linux-foundation.org,
	anshuman.khandual@arm.com, aruna.ramakrishna@oracle.com,
	broonie@kernel.org, catalin.marinas@arm.com,
	dave.hansen@linux.intel.com, Dave.Martin@arm.com,
	joey.gouly@arm.com, keith.lucas@oracle.com,
	pierre.langlois@arm.com, shuah@kernel.org, sroettger@google.com,
	tglx@linutronix.de, will@kernel.org, yury.khrustalev@arm.com,
	linux-kselftest@vger.kernel.org, x86@kernel.org,
	Kees Cook <keescook@chromium.org>,
	Jorge Lucangeli Obes <jorgelo@chromium.org>,
	Jann Horn <jannh@google.com>
Subject: Re: [PATCH v3 0/5] Improve arm64 pkeys handling in signal delivery
Date: Thu, 31 Oct 2024 14:00:04 +0100	[thread overview]
Message-ID: <8dcc7e49-ec95-4d7d-8ded-d4f7202d623d@arm.com> (raw)
In-Reply-To: <CABi2SkW4Utuo3qGKodTQn7VuFrRa4hpwrik7WaorS4=wm_cS2g@mail.gmail.com>

On 30/10/2024 22:59, Jeff Xu wrote:
> Apologize in advance that I'm unfamiliar with ARM's POR, up to review
> this patch series, so I might ask silly questions or based on wrong
> understanding.

That's no problem, your input is very welcome! There is no fundamental
difference between POR and PKRU AFAIK - the encoding is different, but
the principle is the same. The main thing to keep in mind is that POE
(the arm64 extension) allows restricting execution in addition to
read/write.

> It seems that the patch has the same logic as Aruna Ramakrishna
> proposed for X86, is this correct ?

Yes, patch 1 aims at aligning arm64 with x86 (same behaviour). Going
forward I think we should try and keep the arm64 and x86 handling of
pkeys as consistent as possible.

> In the latest version of x86 change [1], I have a comment if we want
> to consider adding a new flag SS_PKEYALTSTACK (see SS_AUTODISARM as an
> example) in sigaltstack, and restrict this mechanism (overwriting
> PKRU/POR_EL0 and sigframe)  to sigaltstack() with SS_PKEYALTSTACK.
> There is a subtle difference if we do that, i.e. the existing
> signaling handling user might not care or do not use PKEY/POE, and
> overwriting PKRU/POR_EL0 and  sigframe every time will add extra CPU
> time on the signaling delivery, which could be real-time sensitive.

From a purely functional perspective, resetting POR to allow access to
all pkeys before writing the signal frame should be safe in any context,
and allows keeping the handling simple (no conditional code). The
performance aspect is a fair point though, as we are adding an ISB
(synchronisation barrier) on the signal delivery path if POE is supported.

> Since I raised this comment on X86, I think raising it for ARM for
> discussion would be ok,
> it might make sense to have consistent API experience for arm/x86 here.

And indeed this is what I think is most important at this point.
Considering that Aruna's series resets PKRU unconditionally (sigaltstack
or not) and has already been pulled into mainline during 6.12-rc1 [2], I
still believe that patch 1 is doing the right thing, i.e. aligning arm64
with x86. If the concern with performance is confirmed, and there is an
agreement to reset POR/PKRU less eagerly on both architectures, this
could potentially be revisited.

- Kevin

[2]
https://lore.kernel.org/lkml/172656199227.2471820.13578261908219597067.tglx@xen13/

> [1] https://lore.kernel.org/lkml/CABi2SkWjF2Sicrr71=a6H8XJyf9q9L_Nd5FPp0CJ2mvB46Rrrg@mail.gmail.com/


  reply	other threads:[~2024-10-31 13:00 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-29 14:45 [PATCH v3 0/5] Improve arm64 pkeys handling in signal delivery Kevin Brodsky
2024-10-29 14:45 ` [PATCH v3 1/5] arm64: signal: Improve POR_EL0 handling to avoid uaccess failures Kevin Brodsky
2024-10-30 22:01   ` Jeff Xu
2024-10-31  8:45     ` Kevin Brodsky
2024-10-31 18:43       ` Jeff Xu
2024-10-31  9:33     ` Will Deacon
2024-10-31 10:23       ` Kevin Brodsky
2024-10-29 14:45 ` [PATCH v3 2/5] arm64: signal: Remove unnecessary check when saving POE state Kevin Brodsky
2024-10-29 14:45 ` [PATCH v3 3/5] arm64: signal: Remove unused macro Kevin Brodsky
2024-10-29 14:45 ` [PATCH v3 4/5] selftests/mm: Use generic pkey register manipulation Kevin Brodsky
2024-10-29 17:42   ` Dave Hansen
2024-10-29 14:45 ` [PATCH v3 5/5] selftests/mm: Enable pkey_sighandler_tests on arm64 Kevin Brodsky
2024-10-29 18:28 ` [PATCH v3 0/5] Improve arm64 pkeys handling in signal delivery Will Deacon
2024-10-30 21:59 ` Jeff Xu
2024-10-31 13:00   ` Kevin Brodsky [this message]
2024-10-31 16:52     ` Jeff Xu
2024-11-04 17:12 ` (subset) " 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=8dcc7e49-ec95-4d7d-8ded-d4f7202d623d@arm.com \
    --to=kevin.brodsky@arm.com \
    --cc=Dave.Martin@arm.com \
    --cc=akpm@linux-foundation.org \
    --cc=anshuman.khandual@arm.com \
    --cc=aruna.ramakrishna@oracle.com \
    --cc=broonie@kernel.org \
    --cc=catalin.marinas@arm.com \
    --cc=dave.hansen@linux.intel.com \
    --cc=jannh@google.com \
    --cc=jeffxu@chromium.org \
    --cc=joey.gouly@arm.com \
    --cc=jorgelo@chromium.org \
    --cc=keescook@chromium.org \
    --cc=keith.lucas@oracle.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=pierre.langlois@arm.com \
    --cc=shuah@kernel.org \
    --cc=sroettger@google.com \
    --cc=tglx@linutronix.de \
    --cc=will@kernel.org \
    --cc=x86@kernel.org \
    --cc=yury.khrustalev@arm.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