]> www.infradead.org Git - linux.git/commit
powerpc/64s/radix/kfence: map __kfence_pool at page granularity
authorHari Bathini <hbathini@linux.ibm.com>
Mon, 1 Jul 2024 13:00:21 +0000 (18:30 +0530)
committerMichael Ellerman <mpe@ellerman.id.au>
Thu, 4 Jul 2024 11:55:18 +0000 (21:55 +1000)
commit353d7a84c214f184d5a6b62acdec8b4424159b7c
treefb937a06009b256f5ed52cc04355ede08b870a5e
parentaf199e6ca29c77fb8fea9a78f18dfb165af37cd7
powerpc/64s/radix/kfence: map __kfence_pool at page granularity

When KFENCE is enabled, total system memory is mapped at page level
granularity. But in radix MMU mode, ~3GB additional memory is needed
to map 100GB of system memory at page level granularity when compared
to using 2MB direct mapping.This is not desired considering KFENCE is
designed to be enabled in production kernels [1].

Mapping only the memory allocated for KFENCE pool at page granularity is
sufficient to enable KFENCE support. So, allocate __kfence_pool during
bootup and map it at page granularity instead of mapping all system
memory at page granularity.

Without patch:
  # cat /proc/meminfo
  MemTotal:       101201920 kB

With patch:
  # cat /proc/meminfo
  MemTotal:       104483904 kB

Note that enabling KFENCE at runtime is disabled for radix MMU for now,
as it depends on the ability to split page table mappings and such APIs
are not currently implemented for radix MMU.

All kfence_test.c testcases passed with this patch.

[1] https://lore.kernel.org/all/20201103175841.3495947-2-elver@google.com/

Signed-off-by: Hari Bathini <hbathini@linux.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://msgid.link/20240701130021.578240-1-hbathini@linux.ibm.com
arch/powerpc/include/asm/kfence.h
arch/powerpc/mm/book3s64/radix_pgtable.c
arch/powerpc/mm/init-common.c