Re: [PATCH 3/4] rseq: Make rseq work with protection keys

From: Mathieu Desnoyers
Date: Fri Feb 21 2025 - 14:39:06 EST


On 2025-02-21 12:17, Dave Hansen wrote:
On 2/17/25 03:07, Dmitry Vyukov wrote:
[...]
This code flow is a bit hard to follow with the retry and all.

I think the assumption here is that overwriting the pkey register is too
slow for the fast path. Instead, in the slow error path, there is a
one-time operation to make the register permissive and retry.

I guess it's your rseq code. But I'd probably just put the
switch_to_permissive_pkey_reg()/write_pkey_reg() in the fast/common path
for simplicity unless I knew it was causing a measurable performance
problem.

I agree that switching to permissive key in the fast path would be
simpler. AFAIU, the switch_to_permissive_pkey_reg() is only a pkey
read when the key is already permissive.

I'd favor the simpler approach unless performance end up being an
issue.

Thanks,

Mathieu


--
Mathieu Desnoyers
EfficiOS Inc.
https://www.efficios.com