[PATCH RFC v9 04/25] arm64: Introduce por_elx_set_pkey_perms() helper
Kevin Brodsky
kevin.brodsky at arm.com
Thu Sep 3 09:43:48 PDT 2026
On 01/09/2026 16:42, Linu Cherian wrote:
> Kevin,
>
> On Tue, Aug 18, 2026 at 03:08:46PM +0100, Kevin Brodsky wrote:
>> Introduce a helper that sets the permissions of a given pkey
>> (POIndex) in the POR_ELx format, and make use of it in
>> arch_set_user_pkey_access().
>>
>> new_por now represents the permissions of a single pkey, so rename
>> it to new_perms and change its type accordingly.
>>
>> Reviewed-by: David Hildenbrand (Arm) <david at kernel.org>
>> Signed-off-by: Kevin Brodsky <kevin.brodsky at arm.com>
>> ---
>> arch/arm64/include/asm/por.h | 7 +++++++
>> arch/arm64/mm/mmu.c | 26 ++++++++++----------------
>> 2 files changed, 17 insertions(+), 16 deletions(-)
>>
>> diff --git a/arch/arm64/include/asm/por.h b/arch/arm64/include/asm/por.h
>> index d913d5b529e4..19b3dd1d43a0 100644
>> --- a/arch/arm64/include/asm/por.h
>> +++ b/arch/arm64/include/asm/por.h
>> @@ -31,4 +31,11 @@ static inline bool por_elx_allows_exec(u64 por, u8 pkey)
>> return perm & POE_X;
>> }
>>
>> +static inline u64 por_elx_set_pkey_perms(u64 por, u8 pkey, u8 perms)
>> +{
>> + u64 shift = POR_ELx_PERM_SHIFT(pkey);
>> +
>> + return (por & ~(POE_MASK << shift)) | ((u64)perms << shift);
> We could use standard bit field access macros here ?
Good idea, will do.
- Kevin
More information about the linux-arm-kernel
mailing list