Merge tag 'hardening-v6.9-rc1-fixes' of git://git.kernel.org/pub/scm/linux/kernel...
[sfrench/cifs-2.6.git] / arch / Kconfig
index c91917b508736d1fa0d37d5bf3b1e4bf5550e211..9f066785bb71d93ca5da01a22d15ed2effba5901 100644 (file)
@@ -673,6 +673,7 @@ config SHADOW_CALL_STACK
        bool "Shadow Call Stack"
        depends on ARCH_SUPPORTS_SHADOW_CALL_STACK
        depends on DYNAMIC_FTRACE_WITH_ARGS || DYNAMIC_FTRACE_WITH_REGS || !FUNCTION_GRAPH_TRACER
+       depends on MMU
        help
          This option enables the compiler's Shadow Call Stack, which
          uses a shadow stack to protect function return addresses from
@@ -798,7 +799,7 @@ config CFI_CLANG
        depends on ARCH_SUPPORTS_CFI_CLANG
        depends on $(cc-option,-fsanitize=kcfi)
        help
-         This option enables Clangs forward-edge Control Flow Integrity
+         This option enables Clang's forward-edge Control Flow Integrity
          (CFI) checking, where the compiler injects a runtime check to each
          indirect function call to ensure the target is a valid function with
          the correct static type. This restricts possible call targets and
@@ -1077,17 +1078,107 @@ config HAVE_ARCH_COMPAT_MMAP_BASES
          and vice-versa 32-bit applications to call 64-bit mmap().
          Required for applications doing different bitness syscalls.
 
+config HAVE_PAGE_SIZE_4KB
+       bool
+
+config HAVE_PAGE_SIZE_8KB
+       bool
+
+config HAVE_PAGE_SIZE_16KB
+       bool
+
+config HAVE_PAGE_SIZE_32KB
+       bool
+
+config HAVE_PAGE_SIZE_64KB
+       bool
+
+config HAVE_PAGE_SIZE_256KB
+       bool
+
+choice
+       prompt "MMU page size"
+
+config PAGE_SIZE_4KB
+       bool "4KiB pages"
+       depends on HAVE_PAGE_SIZE_4KB
+       help
+         This option select the standard 4KiB Linux page size and the only
+         available option on many architectures. Using 4KiB page size will
+         minimize memory consumption and is therefore recommended for low
+         memory systems.
+         Some software that is written for x86 systems makes incorrect
+         assumptions about the page size and only runs on 4KiB pages.
+
+config PAGE_SIZE_8KB
+       bool "8KiB pages"
+       depends on HAVE_PAGE_SIZE_8KB
+       help
+         This option is the only supported page size on a few older
+         processors, and can be slightly faster than 4KiB pages.
+
+config PAGE_SIZE_16KB
+       bool "16KiB pages"
+       depends on HAVE_PAGE_SIZE_16KB
+       help
+         This option is usually a good compromise between memory
+         consumption and performance for typical desktop and server
+         workloads, often saving a level of page table lookups compared
+         to 4KB pages as well as reducing TLB pressure and overhead of
+         per-page operations in the kernel at the expense of a larger
+         page cache.
+
+config PAGE_SIZE_32KB
+       bool "32KiB pages"
+       depends on HAVE_PAGE_SIZE_32KB
+       help
+         Using 32KiB page size will result in slightly higher performance
+         kernel at the price of higher memory consumption compared to
+         16KiB pages.  This option is available only on cnMIPS cores.
+         Note that you will need a suitable Linux distribution to
+         support this.
+
+config PAGE_SIZE_64KB
+       bool "64KiB pages"
+       depends on HAVE_PAGE_SIZE_64KB
+       help
+         Using 64KiB page size will result in slightly higher performance
+         kernel at the price of much higher memory consumption compared to
+         4KiB or 16KiB pages.
+         This is not suitable for general-purpose workloads but the
+         better performance may be worth the cost for certain types of
+         supercomputing or database applications that work mostly with
+         large in-memory data rather than small files.
+
+config PAGE_SIZE_256KB
+       bool "256KiB pages"
+       depends on HAVE_PAGE_SIZE_256KB
+       help
+         256KiB pages have little practical value due to their extreme
+         memory usage.  The kernel will only be able to run applications
+         that have been compiled with '-zmax-page-size' set to 256KiB
+         (the default is 64KiB or 4KiB on most architectures).
+
+endchoice
+
 config PAGE_SIZE_LESS_THAN_64KB
        def_bool y
-       depends on !ARM64_64K_PAGES
        depends on !PAGE_SIZE_64KB
-       depends on !PARISC_PAGE_SIZE_64KB
        depends on PAGE_SIZE_LESS_THAN_256KB
 
 config PAGE_SIZE_LESS_THAN_256KB
        def_bool y
        depends on !PAGE_SIZE_256KB
 
+config PAGE_SHIFT
+       int
+       default 12 if PAGE_SIZE_4KB
+       default 13 if PAGE_SIZE_8KB
+       default 14 if PAGE_SIZE_16KB
+       default 15 if PAGE_SIZE_32KB
+       default 16 if PAGE_SIZE_64KB
+       default 18 if PAGE_SIZE_256KB
+
 # This allows to use a set of generic functions to determine mmap base
 # address by giving priority to top-down scheme only if the process
 # is not in legacy mode (compat task, unlimited stack size or
@@ -1506,4 +1597,16 @@ config FUNCTION_ALIGNMENT
        default 4 if FUNCTION_ALIGNMENT_4B
        default 0
 
+config CC_HAS_MIN_FUNCTION_ALIGNMENT
+       # Detect availability of the GCC option -fmin-function-alignment which
+       # guarantees minimal alignment for all functions, unlike
+       # -falign-functions which the compiler ignores for cold functions.
+       def_bool $(cc-option, -fmin-function-alignment=8)
+
+config CC_HAS_SANE_FUNCTION_ALIGNMENT
+       # Set if the guaranteed alignment with -fmin-function-alignment is
+       # available or extra care is required in the kernel. Clang provides
+       # strict alignment always, even with -falign-functions.
+       def_bool CC_HAS_MIN_FUNCTION_ALIGNMENT || CC_IS_CLANG
+
 endmenu