s390/mm: Add configurable STRICT_MM_TYPECHECKS
authorHeiko Carstens <hca@linux.ibm.com>
Tue, 4 Mar 2025 08:14:33 +0000 (09:14 +0100)
committerVasily Gorbik <gor@linux.ibm.com>
Tue, 11 Mar 2025 14:27:34 +0000 (15:27 +0100)
commit03544866df1bc78fe740fc9d17816874ba7bde5a
treefac59bee7baa505ea2731d24a2f434cd2a0ee9d9
parent94d553ce576acc5f01f4368bc5188f45b56b6168
s390/mm: Add configurable STRICT_MM_TYPECHECKS

Add support for configurable STRICT_MM_TYPECHECKS. The s390 ABI defines
that return values with complex types like structures and unions are
returned in a return value buffer allocated by the caller. This is also
true for small structures and unions which would fit into a register.  On
the other hand when such types are passed as arguments to functions they
are passed in registers, if they are small enough.
This leads to inefficient code when such a return value of a function call
is then passed as argument to a subsequent function call.

This is especially true for all mm types, like pte_t and others, which are
only for type checking reasons defined as a structure. This however can be
bypassed with the STRICT_MM_TYPECHECKS feature, which is used by a few
other architectures, which seem to have the same problem.

Add CONFIG_STRICT_MM_TYPECHECKS which can be used to change the type of
pte_t and other structures. If the config option is not enabled the types
are defined to unsigned long, allowing for better code generation, however
there is no type checking anymore. If it is enabled the types are
structures like before so that type checking is performed, but less
efficient code is generated.

The option is always enabled in debug_defconfig, and for convenience an
mmtypes.config topic target is added, which allows to easily enable it, in
case memory management code is changed.

CONFIG_STRICT_MM_TYPECHECKS and STRICT_MM_TYPECHECKS are kept separate,
since STRICT_MM_TYPECHECKS is common across architectures and common
code. Therefore use the same define also for s390 code.

Add CONFIG_STRICT_MM_TYPECHECKS to make it build time configurable.

Reviewed-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/Kconfig.debug
arch/s390/configs/debug_defconfig
arch/s390/configs/mmtypes.config [new file with mode: 0644]
arch/s390/include/asm/page.h