@@ -33,6 +33,7 @@
#include <linux/slab.h>
#include <linux/cacheinfo.h>
#include <linux/rcuwait.h>
+#include <linux/kpkeys.h>
struct mempolicy;
struct anon_vma;
@@ -3082,6 +3083,8 @@ static inline bool __pagetable_ctor(struct ptdesc *ptdesc)
__folio_set_pgtable(folio);
lruvec_stat_add_folio(folio, NR_PAGETABLE);
+ if (kpkeys_protect_pgtable_memory(folio))
+ return false;
return true;
}
@@ -3092,6 +3095,7 @@ static inline void pagetable_dtor(struct ptdesc *ptdesc)
ptlock_free(ptdesc);
__folio_clear_pgtable(folio);
lruvec_stat_sub_folio(folio, NR_PAGETABLE);
+ kpkeys_unprotect_pgtable_memory(folio);
}
static inline void pagetable_dtor_free(struct ptdesc *ptdesc)
If CONFIG_KPKEYS_HARDENED_PGTABLES is enabled, map allocated page table pages using a privileged pkey (KPKEYS_PKEY_PGTABLES), so that page tables can only be written under guard(kpkeys_hardened_pgtables). This patch is a no-op if CONFIG_KPKEYS_HARDENED_PGTABLES is disabled (default). Signed-off-by: Kevin Brodsky <kevin.brodsky@arm.com> --- include/linux/mm.h | 4 ++++ 1 file changed, 4 insertions(+)