s390/mm: use VM_FLUSH_RESET_PERMS in module_alloc()
authorHeiko Carstens <hca@linux.ibm.com>
Fri, 14 Apr 2023 12:30:46 +0000 (14:30 +0200)
committerVasily Gorbik <gor@linux.ibm.com>
Thu, 20 Apr 2023 09:36:29 +0000 (11:36 +0200)
commit34e4c79f3ba9e3d7de56be8ef1a514950915e0ee
treeb437fca5e2a275d45051454e75f9825d99d7c4c3
parent7608f70adcb1ea6957d7b9e1d5bd53584178fbbc
s390/mm: use VM_FLUSH_RESET_PERMS in module_alloc()

Make use of the set_direct_map() calls for module allocations.
In particular:

- All changes to read-only permissions in kernel VA mappings are also
  applied to the direct mapping. Note that execute permissions are
  intentionally not applied to the direct mapping in order to make
  sure that all allocated pages within the direct mapping stay
  non-executable

- module_alloc() passes the VM_FLUSH_RESET_PERMS to __vmalloc_node_range()
  to make sure that all implicit permission changes made to the direct
  mapping are reset when the allocated vm area is freed again

Side effects: the direct mapping will be fragmented depending on how many
vm areas with VM_FLUSH_RESET_PERMS and/or explicit page permission changes
are allocated and freed again.

For example, just after boot of a system the direct mapping statistics look
like:

$cat /proc/meminfo
...
DirectMap4k:      111628 kB
DirectMap1M:    16665600 kB
DirectMap2G:           0 kB

Acked-by: Alexander Gordeev <agordeev@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
arch/s390/kernel/module.c
arch/s390/mm/pageattr.c