Re: [RFC PATCH v3 08/15] mm: Introduce kernel_pgtables_set_pkey()
From: Linus Walleij
Date: Thu Feb 06 2025 - 14:01:57 EST
Hi Kevin,
thanks for your patch!
On Mon, Feb 3, 2025 at 11:20 AM Kevin Brodsky <kevin.brodsky@xxxxxxx> wrote:
> kernel_pgtables_set_pkey() allows setting the pkey of all page table
> pages in swapper_pg_dir, recursively. This will be needed by
> kpkeys_hardened_pgtables, as it relies on all PTPs being mapped with
> a non-default pkey. Those initial kernel page tables cannot
> practically be assigned a non-default pkey right when they are
> allocated, so mutating them during (early) boot is required.
>
> Signed-off-by: Kevin Brodsky <kevin.brodsky@xxxxxxx>
(...)
> +static int set_page_pkey(void *p, int pkey)
> +static int set_pkey_pte(pmd_t *pmd, int pkey)
> +static int set_pkey_pmd(pud_t *pud, int pkey)
> +static int set_pkey_pud(p4d_t *p4d, int pkey)
> +static int set_pkey_p4d(pgd_t *pgd, int pkey)
> +int kernel_pgtables_set_pkey(int pkey)
Aren't these all discardable after boot, so the whole set should
be tagged with __init?
Other than that it LGTM.
Yours,
Linus Walleij