[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <7d830f4f-dccb-4055-8539-e97432e178eb@intel.com>
Date: Fri, 21 Feb 2025 13:45:13 -0800
From: Dave Hansen <dave.hansen@...el.com>
To: Mathieu Desnoyers <mathieu.desnoyers@...icios.com>,
Dmitry Vyukov <dvyukov@...gle.com>, peterz@...radead.org,
boqun.feng@...il.com, tglx@...utronix.de, mingo@...hat.com, bp@...en8.de,
dave.hansen@...ux.intel.com, hpa@...or.com, aruna.ramakrishna@...cle.com,
elver@...gle.com
Cc: "Paul E. McKenney" <paulmck@...nel.org>, x86@...nel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH 3/4] rseq: Make rseq work with protection keys
On 2/21/25 13:36, Mathieu Desnoyers wrote:
>>>
>>
>> Because the rseq return to userspace handler is called on every return
>> to userspace after a task is scheduled back after preemption, I am
>> concerned about the overhead that would be added by a WRPKRU on the
>> fast-path, given that it acts as as barrier against speculation. Issuing
>> WRPKRU only after checking that pkey-0 is not accessible appears to be
>> moving the overhead to a much less common case.
>
> Actually, we should distinguish between two accesses here:
>
> A) loads/stores from/to struct rseq
>
> B) loads from struct rseq_cs (only happens on rseq abort)
>
> (A) is a fast-path executed on return to userspace after a preemption.
> In order to make it fast, we could require that struct rseq is pkey-0
> and typically skip any WRPKRU for this access when pkey-0 is already
> accessible. We can add a check on rseq registration to make sure that
> struct rseq is indeed pkey-0, and reject it with an error if not. This
> should help make the ABI robust and less error-prone.
>
> Now for (B), it's a slow path. When we observe that rseq->rseq_cs is
> not NULL, we can simply override with a permissive pkey to make sure
> the rseq_cs access will work.
>
> Thoughts ?
I think this will be the first ABI which is explicitly pkey-0-only. I
suspect there are a few more of these that are implicit but we just
haven't found them yet.
I wouldn't have any objections about doing this, especially given
sanity checking at rseq registration.
Powered by blists - more mailing lists