[PATCH RFC v8 01/24] mm: Introduce kpkeys

David Hildenbrand (Arm) david at kernel.org
Tue Jun 16 08:32:24 PDT 2026


>>> +static __always_inline u64 kpkeys_set_context(int ctx)
>> Should ctx be unsigned here? I'm nor sure what a negativ context
>> would mean.
>> kpkeys_set_context(unsigned int ctx)
> 
> That's a good point, now that we say "context" and not "level" an enum
> would be a better representation. I would directly use:
> 
>     u64 kpkeys_set_context(enum kpkeys_ctx ctx);
> 
> ... unless we really need another layer of abstraction.

Using an enum will also make it easier to just automatically update MIN and MAX
values. Although, arguably, you can just assume that MIN will always be 0.

enum kpkey_ctx {
    KPKEY_CTX_DEFAULT = 0,
    KPKEY_CTX_COUNT,
};

Then, just reject anything < 0 or >= KPKEY_CTX_COUNT.

-- 
Cheers,

David



More information about the linux-arm-kernel mailing list