scripts: add an option for building profiling kernel and PGO kernel
[platform/kernel/linux-rpi.git] / arch / Kconfig
1 # SPDX-License-Identifier: GPL-2.0
2 #
3 # General architecture dependent options
4 #
5
6 #
7 # Note: arch/$(SRCARCH)/Kconfig needs to be included first so that it can
8 # override the default values in this file.
9 #
10 source "arch/$(SRCARCH)/Kconfig"
11
12 menu "General architecture-dependent options"
13
14 config CRASH_CORE
15         bool
16
17 config KEXEC_CORE
18         select CRASH_CORE
19         bool
20
21 config KEXEC_ELF
22         bool
23
24 config HAVE_IMA_KEXEC
25         bool
26
27 config SET_FS
28         bool
29
30 config HOTPLUG_SMT
31         bool
32
33 config GENERIC_ENTRY
34        bool
35
36 config KPROBES
37         bool "Kprobes"
38         depends on MODULES
39         depends on HAVE_KPROBES
40         select KALLSYMS
41         help
42           Kprobes allows you to trap at almost any kernel address and
43           execute a callback function.  register_kprobe() establishes
44           a probepoint and specifies the callback.  Kprobes is useful
45           for kernel debugging, non-intrusive instrumentation and testing.
46           If in doubt, say "N".
47
48 config JUMP_LABEL
49         bool "Optimize very unlikely/likely branches"
50         depends on HAVE_ARCH_JUMP_LABEL
51         depends on CC_HAS_ASM_GOTO
52         help
53          This option enables a transparent branch optimization that
54          makes certain almost-always-true or almost-always-false branch
55          conditions even cheaper to execute within the kernel.
56
57          Certain performance-sensitive kernel code, such as trace points,
58          scheduler functionality, networking code and KVM have such
59          branches and include support for this optimization technique.
60
61          If it is detected that the compiler has support for "asm goto",
62          the kernel will compile such branches with just a nop
63          instruction. When the condition flag is toggled to true, the
64          nop will be converted to a jump instruction to execute the
65          conditional block of instructions.
66
67          This technique lowers overhead and stress on the branch prediction
68          of the processor and generally makes the kernel faster. The update
69          of the condition is slower, but those are always very rare.
70
71          ( On 32-bit x86, the necessary options added to the compiler
72            flags may increase the size of the kernel slightly. )
73
74 config STATIC_KEYS_SELFTEST
75         bool "Static key selftest"
76         depends on JUMP_LABEL
77         help
78           Boot time self-test of the branch patching code.
79
80 config STATIC_CALL_SELFTEST
81         bool "Static call selftest"
82         depends on HAVE_STATIC_CALL
83         help
84           Boot time self-test of the call patching code.
85
86 config OPTPROBES
87         def_bool y
88         depends on KPROBES && HAVE_OPTPROBES
89         select TASKS_RCU if PREEMPTION
90
91 config KPROBES_ON_FTRACE
92         def_bool y
93         depends on KPROBES && HAVE_KPROBES_ON_FTRACE
94         depends on DYNAMIC_FTRACE_WITH_REGS
95         help
96          If function tracer is enabled and the arch supports full
97          passing of pt_regs to function tracing, then kprobes can
98          optimize on top of function tracing.
99
100 config UPROBES
101         def_bool n
102         depends on ARCH_SUPPORTS_UPROBES
103         help
104           Uprobes is the user-space counterpart to kprobes: they
105           enable instrumentation applications (such as 'perf probe')
106           to establish unintrusive probes in user-space binaries and
107           libraries, by executing handler functions when the probes
108           are hit by user-space applications.
109
110           ( These probes come in the form of single-byte breakpoints,
111             managed by the kernel and kept transparent to the probed
112             application. )
113
114 config HAVE_64BIT_ALIGNED_ACCESS
115         def_bool 64BIT && !HAVE_EFFICIENT_UNALIGNED_ACCESS
116         help
117           Some architectures require 64 bit accesses to be 64 bit
118           aligned, which also requires structs containing 64 bit values
119           to be 64 bit aligned too. This includes some 32 bit
120           architectures which can do 64 bit accesses, as well as 64 bit
121           architectures without unaligned access.
122
123           This symbol should be selected by an architecture if 64 bit
124           accesses are required to be 64 bit aligned in this way even
125           though it is not a 64 bit architecture.
126
127           See Documentation/core-api/unaligned-memory-access.rst for
128           more information on the topic of unaligned memory accesses.
129
130 config HAVE_EFFICIENT_UNALIGNED_ACCESS
131         bool
132         help
133           Some architectures are unable to perform unaligned accesses
134           without the use of get_unaligned/put_unaligned. Others are
135           unable to perform such accesses efficiently (e.g. trap on
136           unaligned access and require fixing it up in the exception
137           handler.)
138
139           This symbol should be selected by an architecture if it can
140           perform unaligned accesses efficiently to allow different
141           code paths to be selected for these cases. Some network
142           drivers, for example, could opt to not fix up alignment
143           problems with received packets if doing so would not help
144           much.
145
146           See Documentation/core-api/unaligned-memory-access.rst for more
147           information on the topic of unaligned memory accesses.
148
149 config ARCH_USE_BUILTIN_BSWAP
150         bool
151         help
152          Modern versions of GCC (since 4.4) have builtin functions
153          for handling byte-swapping. Using these, instead of the old
154          inline assembler that the architecture code provides in the
155          __arch_bswapXX() macros, allows the compiler to see what's
156          happening and offers more opportunity for optimisation. In
157          particular, the compiler will be able to combine the byteswap
158          with a nearby load or store and use load-and-swap or
159          store-and-swap instructions if the architecture has them. It
160          should almost *never* result in code which is worse than the
161          hand-coded assembler in <asm/swab.h>.  But just in case it
162          does, the use of the builtins is optional.
163
164          Any architecture with load-and-swap or store-and-swap
165          instructions should set this. And it shouldn't hurt to set it
166          on architectures that don't have such instructions.
167
168 config KRETPROBES
169         def_bool y
170         depends on KPROBES && HAVE_KRETPROBES
171
172 config USER_RETURN_NOTIFIER
173         bool
174         depends on HAVE_USER_RETURN_NOTIFIER
175         help
176           Provide a kernel-internal notification when a cpu is about to
177           switch to user mode.
178
179 config HAVE_IOREMAP_PROT
180         bool
181
182 config HAVE_KPROBES
183         bool
184
185 config HAVE_KRETPROBES
186         bool
187
188 config HAVE_OPTPROBES
189         bool
190
191 config HAVE_KPROBES_ON_FTRACE
192         bool
193
194 config HAVE_FUNCTION_ERROR_INJECTION
195         bool
196
197 config HAVE_NMI
198         bool
199
200 config TRACE_IRQFLAGS_SUPPORT
201         bool
202
203 config TRACE_IRQFLAGS_NMI_SUPPORT
204         bool
205
206 #
207 # An arch should select this if it provides all these things:
208 #
209 #       task_pt_regs()          in asm/processor.h or asm/ptrace.h
210 #       arch_has_single_step()  if there is hardware single-step support
211 #       arch_has_block_step()   if there is hardware block-step support
212 #       asm/syscall.h           supplying asm-generic/syscall.h interface
213 #       linux/regset.h          user_regset interfaces
214 #       CORE_DUMP_USE_REGSET    #define'd in linux/elf.h
215 #       TIF_SYSCALL_TRACE       calls tracehook_report_syscall_{entry,exit}
216 #       TIF_NOTIFY_RESUME       calls tracehook_notify_resume()
217 #       signal delivery         calls tracehook_signal_handler()
218 #
219 config HAVE_ARCH_TRACEHOOK
220         bool
221
222 config HAVE_DMA_CONTIGUOUS
223         bool
224
225 config GENERIC_SMP_IDLE_THREAD
226         bool
227
228 config GENERIC_IDLE_POLL_SETUP
229         bool
230
231 config ARCH_HAS_FORTIFY_SOURCE
232         bool
233         help
234           An architecture should select this when it can successfully
235           build and run with CONFIG_FORTIFY_SOURCE.
236
237 #
238 # Select if the arch provides a historic keepinit alias for the retain_initrd
239 # command line option
240 #
241 config ARCH_HAS_KEEPINITRD
242         bool
243
244 # Select if arch has all set_memory_ro/rw/x/nx() functions in asm/cacheflush.h
245 config ARCH_HAS_SET_MEMORY
246         bool
247
248 # Select if arch has all set_direct_map_invalid/default() functions
249 config ARCH_HAS_SET_DIRECT_MAP
250         bool
251
252 #
253 # Select if the architecture provides the arch_dma_set_uncached symbol to
254 # either provide an uncached segment alias for a DMA allocation, or
255 # to remap the page tables in place.
256 #
257 config ARCH_HAS_DMA_SET_UNCACHED
258         bool
259
260 #
261 # Select if the architectures provides the arch_dma_clear_uncached symbol
262 # to undo an in-place page table remap for uncached access.
263 #
264 config ARCH_HAS_DMA_CLEAR_UNCACHED
265         bool
266
267 # Select if arch init_task must go in the __init_task_data section
268 config ARCH_TASK_STRUCT_ON_STACK
269         bool
270
271 # Select if arch has its private alloc_task_struct() function
272 config ARCH_TASK_STRUCT_ALLOCATOR
273         bool
274
275 config HAVE_ARCH_THREAD_STRUCT_WHITELIST
276         bool
277         depends on !ARCH_TASK_STRUCT_ALLOCATOR
278         help
279           An architecture should select this to provide hardened usercopy
280           knowledge about what region of the thread_struct should be
281           whitelisted for copying to userspace. Normally this is only the
282           FPU registers. Specifically, arch_thread_struct_whitelist()
283           should be implemented. Without this, the entire thread_struct
284           field in task_struct will be left whitelisted.
285
286 # Select if arch has its private alloc_thread_stack() function
287 config ARCH_THREAD_STACK_ALLOCATOR
288         bool
289
290 # Select if arch wants to size task_struct dynamically via arch_task_struct_size:
291 config ARCH_WANTS_DYNAMIC_TASK_STRUCT
292         bool
293
294 config ARCH_WANTS_NO_INSTR
295         bool
296         help
297           An architecture should select this if the noinstr macro is being used on
298           functions to denote that the toolchain should avoid instrumenting such
299           functions and is required for correctness.
300
301 config ARCH_32BIT_OFF_T
302         bool
303         depends on !64BIT
304         help
305           All new 32-bit architectures should have 64-bit off_t type on
306           userspace side which corresponds to the loff_t kernel type. This
307           is the requirement for modern ABIs. Some existing architectures
308           still support 32-bit off_t. This option is enabled for all such
309           architectures explicitly.
310
311 # Selected by 64 bit architectures which have a 32 bit f_tinode in struct ustat
312 config ARCH_32BIT_USTAT_F_TINODE
313         bool
314
315 config HAVE_ASM_MODVERSIONS
316         bool
317         help
318           This symbol should be selected by an architecture if it provides
319           <asm/asm-prototypes.h> to support the module versioning for symbols
320           exported from assembly code.
321
322 config HAVE_REGS_AND_STACK_ACCESS_API
323         bool
324         help
325           This symbol should be selected by an architecture if it supports
326           the API needed to access registers and stack entries from pt_regs,
327           declared in asm/ptrace.h
328           For example the kprobes-based event tracer needs this API.
329
330 config HAVE_RSEQ
331         bool
332         depends on HAVE_REGS_AND_STACK_ACCESS_API
333         help
334           This symbol should be selected by an architecture if it
335           supports an implementation of restartable sequences.
336
337 config HAVE_FUNCTION_ARG_ACCESS_API
338         bool
339         help
340           This symbol should be selected by an architecture if it supports
341           the API needed to access function arguments from pt_regs,
342           declared in asm/ptrace.h
343
344 config HAVE_HW_BREAKPOINT
345         bool
346         depends on PERF_EVENTS
347
348 config HAVE_MIXED_BREAKPOINTS_REGS
349         bool
350         depends on HAVE_HW_BREAKPOINT
351         help
352           Depending on the arch implementation of hardware breakpoints,
353           some of them have separate registers for data and instruction
354           breakpoints addresses, others have mixed registers to store
355           them but define the access type in a control register.
356           Select this option if your arch implements breakpoints under the
357           latter fashion.
358
359 config HAVE_USER_RETURN_NOTIFIER
360         bool
361
362 config HAVE_PERF_EVENTS_NMI
363         bool
364         help
365           System hardware can generate an NMI using the perf event
366           subsystem.  Also has support for calculating CPU cycle events
367           to determine how many clock cycles in a given period.
368
369 config HAVE_HARDLOCKUP_DETECTOR_PERF
370         bool
371         depends on HAVE_PERF_EVENTS_NMI
372         help
373           The arch chooses to use the generic perf-NMI-based hardlockup
374           detector. Must define HAVE_PERF_EVENTS_NMI.
375
376 config HAVE_NMI_WATCHDOG
377         depends on HAVE_NMI
378         bool
379         help
380           The arch provides a low level NMI watchdog. It provides
381           asm/nmi.h, and defines its own arch_touch_nmi_watchdog().
382
383 config HAVE_HARDLOCKUP_DETECTOR_ARCH
384         bool
385         select HAVE_NMI_WATCHDOG
386         help
387           The arch chooses to provide its own hardlockup detector, which is
388           a superset of the HAVE_NMI_WATCHDOG. It also conforms to config
389           interfaces and parameters provided by hardlockup detector subsystem.
390
391 config HAVE_PERF_REGS
392         bool
393         help
394           Support selective register dumps for perf events. This includes
395           bit-mapping of each registers and a unique architecture id.
396
397 config HAVE_PERF_USER_STACK_DUMP
398         bool
399         help
400           Support user stack dumps for perf event samples. This needs
401           access to the user stack pointer which is not unified across
402           architectures.
403
404 config HAVE_ARCH_JUMP_LABEL
405         bool
406
407 config HAVE_ARCH_JUMP_LABEL_RELATIVE
408         bool
409
410 config MMU_GATHER_TABLE_FREE
411         bool
412
413 config MMU_GATHER_RCU_TABLE_FREE
414         bool
415         select MMU_GATHER_TABLE_FREE
416
417 config MMU_GATHER_PAGE_SIZE
418         bool
419
420 config MMU_GATHER_NO_RANGE
421         bool
422
423 config MMU_GATHER_NO_GATHER
424         bool
425         depends on MMU_GATHER_TABLE_FREE
426
427 config ARCH_WANT_IRQS_OFF_ACTIVATE_MM
428         bool
429         help
430           Temporary select until all architectures can be converted to have
431           irqs disabled over activate_mm. Architectures that do IPI based TLB
432           shootdowns should enable this.
433
434 config ARCH_HAVE_NMI_SAFE_CMPXCHG
435         bool
436
437 config HAVE_ALIGNED_STRUCT_PAGE
438         bool
439         help
440           This makes sure that struct pages are double word aligned and that
441           e.g. the SLUB allocator can perform double word atomic operations
442           on a struct page for better performance. However selecting this
443           might increase the size of a struct page by a word.
444
445 config HAVE_CMPXCHG_LOCAL
446         bool
447
448 config HAVE_CMPXCHG_DOUBLE
449         bool
450
451 config ARCH_WEAK_RELEASE_ACQUIRE
452         bool
453
454 config ARCH_WANT_IPC_PARSE_VERSION
455         bool
456
457 config ARCH_WANT_COMPAT_IPC_PARSE_VERSION
458         bool
459
460 config ARCH_WANT_OLD_COMPAT_IPC
461         select ARCH_WANT_COMPAT_IPC_PARSE_VERSION
462         bool
463
464 config HAVE_ARCH_SECCOMP
465         bool
466         help
467           An arch should select this symbol to support seccomp mode 1 (the fixed
468           syscall policy), and must provide an overrides for __NR_seccomp_sigreturn,
469           and compat syscalls if the asm-generic/seccomp.h defaults need adjustment:
470           - __NR_seccomp_read_32
471           - __NR_seccomp_write_32
472           - __NR_seccomp_exit_32
473           - __NR_seccomp_sigreturn_32
474
475 config HAVE_ARCH_SECCOMP_FILTER
476         bool
477         select HAVE_ARCH_SECCOMP
478         help
479           An arch should select this symbol if it provides all of these things:
480           - all the requirements for HAVE_ARCH_SECCOMP
481           - syscall_get_arch()
482           - syscall_get_arguments()
483           - syscall_rollback()
484           - syscall_set_return_value()
485           - SIGSYS siginfo_t support
486           - secure_computing is called from a ptrace_event()-safe context
487           - secure_computing return value is checked and a return value of -1
488             results in the system call being skipped immediately.
489           - seccomp syscall wired up
490           - if !HAVE_SPARSE_SYSCALL_NR, have SECCOMP_ARCH_NATIVE,
491             SECCOMP_ARCH_NATIVE_NR, SECCOMP_ARCH_NATIVE_NAME defined. If
492             COMPAT is supported, have the SECCOMP_ARCH_COMPAT* defines too.
493
494 config SECCOMP
495         prompt "Enable seccomp to safely execute untrusted bytecode"
496         def_bool y
497         depends on HAVE_ARCH_SECCOMP
498         help
499           This kernel feature is useful for number crunching applications
500           that may need to handle untrusted bytecode during their
501           execution. By using pipes or other transports made available
502           to the process as file descriptors supporting the read/write
503           syscalls, it's possible to isolate those applications in their
504           own address space using seccomp. Once seccomp is enabled via
505           prctl(PR_SET_SECCOMP) or the seccomp() syscall, it cannot be
506           disabled and the task is only allowed to execute a few safe
507           syscalls defined by each seccomp mode.
508
509           If unsure, say Y.
510
511 config SECCOMP_FILTER
512         def_bool y
513         depends on HAVE_ARCH_SECCOMP_FILTER && SECCOMP && NET
514         help
515           Enable tasks to build secure computing environments defined
516           in terms of Berkeley Packet Filter programs which implement
517           task-defined system call filtering polices.
518
519           See Documentation/userspace-api/seccomp_filter.rst for details.
520
521 config SECCOMP_CACHE_DEBUG
522         bool "Show seccomp filter cache status in /proc/pid/seccomp_cache"
523         depends on SECCOMP_FILTER && !HAVE_SPARSE_SYSCALL_NR
524         depends on PROC_FS
525         help
526           This enables the /proc/pid/seccomp_cache interface to monitor
527           seccomp cache data. The file format is subject to change. Reading
528           the file requires CAP_SYS_ADMIN.
529
530           This option is for debugging only. Enabling presents the risk that
531           an adversary may be able to infer the seccomp filter logic.
532
533           If unsure, say N.
534
535 config HAVE_ARCH_STACKLEAK
536         bool
537         help
538           An architecture should select this if it has the code which
539           fills the used part of the kernel stack with the STACKLEAK_POISON
540           value before returning from system calls.
541
542 config HAVE_STACKPROTECTOR
543         bool
544         help
545           An arch should select this symbol if:
546           - it has implemented a stack canary (e.g. __stack_chk_guard)
547
548 config STACKPROTECTOR
549         bool "Stack Protector buffer overflow detection"
550         depends on HAVE_STACKPROTECTOR
551         depends on $(cc-option,-fstack-protector)
552         default y
553         help
554           This option turns on the "stack-protector" GCC feature. This
555           feature puts, at the beginning of functions, a canary value on
556           the stack just before the return address, and validates
557           the value just before actually returning.  Stack based buffer
558           overflows (that need to overwrite this return address) now also
559           overwrite the canary, which gets detected and the attack is then
560           neutralized via a kernel panic.
561
562           Functions will have the stack-protector canary logic added if they
563           have an 8-byte or larger character array on the stack.
564
565           This feature requires gcc version 4.2 or above, or a distribution
566           gcc with the feature backported ("-fstack-protector").
567
568           On an x86 "defconfig" build, this feature adds canary checks to
569           about 3% of all kernel functions, which increases kernel code size
570           by about 0.3%.
571
572 config STACKPROTECTOR_STRONG
573         bool "Strong Stack Protector"
574         depends on STACKPROTECTOR
575         depends on $(cc-option,-fstack-protector-strong)
576         default y
577         help
578           Functions will have the stack-protector canary logic added in any
579           of the following conditions:
580
581           - local variable's address used as part of the right hand side of an
582             assignment or function argument
583           - local variable is an array (or union containing an array),
584             regardless of array type or length
585           - uses register local variables
586
587           This feature requires gcc version 4.9 or above, or a distribution
588           gcc with the feature backported ("-fstack-protector-strong").
589
590           On an x86 "defconfig" build, this feature adds canary checks to
591           about 20% of all kernel functions, which increases the kernel code
592           size by about 2%.
593
594 config ARCH_SUPPORTS_SHADOW_CALL_STACK
595         bool
596         help
597           An architecture should select this if it supports Clang's Shadow
598           Call Stack and implements runtime support for shadow stack
599           switching.
600
601 config SHADOW_CALL_STACK
602         bool "Clang Shadow Call Stack"
603         depends on CC_IS_CLANG && ARCH_SUPPORTS_SHADOW_CALL_STACK
604         depends on DYNAMIC_FTRACE_WITH_REGS || !FUNCTION_GRAPH_TRACER
605         help
606           This option enables Clang's Shadow Call Stack, which uses a
607           shadow stack to protect function return addresses from being
608           overwritten by an attacker. More information can be found in
609           Clang's documentation:
610
611             https://clang.llvm.org/docs/ShadowCallStack.html
612
613           Note that security guarantees in the kernel differ from the
614           ones documented for user space. The kernel must store addresses
615           of shadow stacks in memory, which means an attacker capable of
616           reading and writing arbitrary memory may be able to locate them
617           and hijack control flow by modifying the stacks.
618
619 config LTO
620         bool
621         help
622           Selected if the kernel will be built using the compiler's LTO feature.
623
624 config LTO_CLANG
625         bool
626         select LTO
627         help
628           Selected if the kernel will be built using Clang's LTO feature.
629
630 config ARCH_SUPPORTS_LTO_CLANG
631         bool
632         help
633           An architecture should select this option if it supports:
634           - compiling with Clang,
635           - compiling inline assembly with Clang's integrated assembler,
636           - and linking with LLD.
637
638 config ARCH_SUPPORTS_LTO_CLANG_THIN
639         bool
640         help
641           An architecture should select this option if it can support Clang's
642           ThinLTO mode.
643
644 config HAS_LTO_CLANG
645         def_bool y
646         # Clang >= 11: https://github.com/ClangBuiltLinux/linux/issues/510
647         depends on CC_IS_CLANG && CLANG_VERSION >= 110000 && LD_IS_LLD && AS_IS_LLVM
648         depends on $(success,$(NM) --help | head -n 1 | grep -qi llvm)
649         depends on $(success,$(AR) --help | head -n 1 | grep -qi llvm)
650         depends on ARCH_SUPPORTS_LTO_CLANG
651         depends on !FTRACE_MCOUNT_USE_RECORDMCOUNT
652         depends on !KASAN || KASAN_HW_TAGS
653         depends on !GCOV_KERNEL
654         help
655           The compiler and Kconfig options support building with Clang's
656           LTO.
657
658 choice
659         prompt "Link Time Optimization (LTO)"
660         default LTO_NONE
661         help
662           This option enables Link Time Optimization (LTO), which allows the
663           compiler to optimize binaries globally.
664
665           If unsure, select LTO_NONE. Note that LTO is very resource-intensive
666           so it's disabled by default.
667
668 config LTO_NONE
669         bool "None"
670         help
671           Build the kernel normally, without Link Time Optimization (LTO).
672
673 config LTO_CLANG_FULL
674         bool "Clang Full LTO (EXPERIMENTAL)"
675         depends on HAS_LTO_CLANG
676         depends on !COMPILE_TEST
677         select LTO_CLANG
678         help
679           This option enables Clang's full Link Time Optimization (LTO), which
680           allows the compiler to optimize the kernel globally. If you enable
681           this option, the compiler generates LLVM bitcode instead of ELF
682           object files, and the actual compilation from bitcode happens at
683           the LTO link step, which may take several minutes depending on the
684           kernel configuration. More information can be found from LLVM's
685           documentation:
686
687             https://llvm.org/docs/LinkTimeOptimization.html
688
689           During link time, this option can use a large amount of RAM, and
690           may take much longer than the ThinLTO option.
691
692 config LTO_CLANG_THIN
693         bool "Clang ThinLTO (EXPERIMENTAL)"
694         depends on HAS_LTO_CLANG && ARCH_SUPPORTS_LTO_CLANG_THIN
695         select LTO_CLANG
696         help
697           This option enables Clang's ThinLTO, which allows for parallel
698           optimization and faster incremental compiles compared to the
699           CONFIG_LTO_CLANG_FULL option. More information can be found
700           from Clang's documentation:
701
702             https://clang.llvm.org/docs/ThinLTO.html
703
704           If unsure, say Y.
705 endchoice
706
707 config ARCH_SUPPORTS_CFI_CLANG
708         bool
709         help
710           An architecture should select this option if it can support Clang's
711           Control-Flow Integrity (CFI) checking.
712
713 config CFI_CLANG
714         bool "Use Clang's Control Flow Integrity (CFI)"
715         depends on LTO_CLANG && ARCH_SUPPORTS_CFI_CLANG
716         # Clang >= 12:
717         # - https://bugs.llvm.org/show_bug.cgi?id=46258
718         # - https://bugs.llvm.org/show_bug.cgi?id=47479
719         depends on CLANG_VERSION >= 120000
720         select KALLSYMS
721         help
722           This option enables Clang’s forward-edge Control Flow Integrity
723           (CFI) checking, where the compiler injects a runtime check to each
724           indirect function call to ensure the target is a valid function with
725           the correct static type. This restricts possible call targets and
726           makes it more difficult for an attacker to exploit bugs that allow
727           the modification of stored function pointers. More information can be
728           found from Clang's documentation:
729
730             https://clang.llvm.org/docs/ControlFlowIntegrity.html
731
732 config CFI_CLANG_SHADOW
733         bool "Use CFI shadow to speed up cross-module checks"
734         default y
735         depends on CFI_CLANG && MODULES
736         help
737           If you select this option, the kernel builds a fast look-up table of
738           CFI check functions in loaded modules to reduce performance overhead.
739
740           If unsure, say Y.
741
742 config CFI_PERMISSIVE
743         bool "Use CFI in permissive mode"
744         depends on CFI_CLANG
745         help
746           When selected, Control Flow Integrity (CFI) violations result in a
747           warning instead of a kernel panic. This option should only be used
748           for finding indirect call type mismatches during development.
749
750           If unsure, say N.
751
752 config HAVE_ARCH_WITHIN_STACK_FRAMES
753         bool
754         help
755           An architecture should select this if it can walk the kernel stack
756           frames to determine if an object is part of either the arguments
757           or local variables (i.e. that it excludes saved return addresses,
758           and similar) by implementing an inline arch_within_stack_frames(),
759           which is used by CONFIG_HARDENED_USERCOPY.
760
761 config HAVE_CONTEXT_TRACKING
762         bool
763         help
764           Provide kernel/user boundaries probes necessary for subsystems
765           that need it, such as userspace RCU extended quiescent state.
766           Syscalls need to be wrapped inside user_exit()-user_enter(), either
767           optimized behind static key or through the slow path using TIF_NOHZ
768           flag. Exceptions handlers must be wrapped as well. Irqs are already
769           protected inside rcu_irq_enter/rcu_irq_exit() but preemption or signal
770           handling on irq exit still need to be protected.
771
772 config HAVE_CONTEXT_TRACKING_OFFSTACK
773         bool
774         help
775           Architecture neither relies on exception_enter()/exception_exit()
776           nor on schedule_user(). Also preempt_schedule_notrace() and
777           preempt_schedule_irq() can't be called in a preemptible section
778           while context tracking is CONTEXT_USER. This feature reflects a sane
779           entry implementation where the following requirements are met on
780           critical entry code, ie: before user_exit() or after user_enter():
781
782           - Critical entry code isn't preemptible (or better yet:
783             not interruptible).
784           - No use of RCU read side critical sections, unless rcu_nmi_enter()
785             got called.
786           - No use of instrumentation, unless instrumentation_begin() got
787             called.
788
789 config HAVE_TIF_NOHZ
790         bool
791         help
792           Arch relies on TIF_NOHZ and syscall slow path to implement context
793           tracking calls to user_enter()/user_exit().
794
795 config HAVE_VIRT_CPU_ACCOUNTING
796         bool
797
798 config HAVE_VIRT_CPU_ACCOUNTING_IDLE
799         bool
800         help
801           Architecture has its own way to account idle CPU time and therefore
802           doesn't implement vtime_account_idle().
803
804 config ARCH_HAS_SCALED_CPUTIME
805         bool
806
807 config HAVE_VIRT_CPU_ACCOUNTING_GEN
808         bool
809         default y if 64BIT
810         help
811           With VIRT_CPU_ACCOUNTING_GEN, cputime_t becomes 64-bit.
812           Before enabling this option, arch code must be audited
813           to ensure there are no races in concurrent read/write of
814           cputime_t. For example, reading/writing 64-bit cputime_t on
815           some 32-bit arches may require multiple accesses, so proper
816           locking is needed to protect against concurrent accesses.
817
818 config HAVE_IRQ_TIME_ACCOUNTING
819         bool
820         help
821           Archs need to ensure they use a high enough resolution clock to
822           support irq time accounting and then call enable_sched_clock_irqtime().
823
824 config HAVE_MOVE_PUD
825         bool
826         help
827           Architectures that select this are able to move page tables at the
828           PUD level. If there are only 3 page table levels, the move effectively
829           happens at the PGD level.
830
831 config HAVE_MOVE_PMD
832         bool
833         help
834           Archs that select this are able to move page tables at the PMD level.
835
836 config HAVE_ARCH_TRANSPARENT_HUGEPAGE
837         bool
838
839 config HAVE_ARCH_TRANSPARENT_HUGEPAGE_PUD
840         bool
841
842 config HAVE_ARCH_HUGE_VMAP
843         bool
844
845 #
846 #  Archs that select this would be capable of PMD-sized vmaps (i.e.,
847 #  arch_vmap_pmd_supported() returns true), and they must make no assumptions
848 #  that vmalloc memory is mapped with PAGE_SIZE ptes. The VM_NO_HUGE_VMAP flag
849 #  can be used to prohibit arch-specific allocations from using hugepages to
850 #  help with this (e.g., modules may require it).
851 #
852 config HAVE_ARCH_HUGE_VMALLOC
853         depends on HAVE_ARCH_HUGE_VMAP
854         bool
855
856 config ARCH_WANT_HUGE_PMD_SHARE
857         bool
858
859 config HAVE_ARCH_SOFT_DIRTY
860         bool
861
862 config HAVE_MOD_ARCH_SPECIFIC
863         bool
864         help
865           The arch uses struct mod_arch_specific to store data.  Many arches
866           just need a simple module loader without arch specific data - those
867           should not enable this.
868
869 config MODULES_USE_ELF_RELA
870         bool
871         help
872           Modules only use ELF RELA relocations.  Modules with ELF REL
873           relocations will give an error.
874
875 config MODULES_USE_ELF_REL
876         bool
877         help
878           Modules only use ELF REL relocations.  Modules with ELF RELA
879           relocations will give an error.
880
881 config HAVE_IRQ_EXIT_ON_IRQ_STACK
882         bool
883         help
884           Architecture doesn't only execute the irq handler on the irq stack
885           but also irq_exit(). This way we can process softirqs on this irq
886           stack instead of switching to a new one when we call __do_softirq()
887           in the end of an hardirq.
888           This spares a stack switch and improves cache usage on softirq
889           processing.
890
891 config HAVE_SOFTIRQ_ON_OWN_STACK
892         bool
893         help
894           Architecture provides a function to run __do_softirq() on a
895           separate stack.
896
897 config PGTABLE_LEVELS
898         int
899         default 2
900
901 config ARCH_HAS_ELF_RANDOMIZE
902         bool
903         help
904           An architecture supports choosing randomized locations for
905           stack, mmap, brk, and ET_DYN. Defined functions:
906           - arch_mmap_rnd()
907           - arch_randomize_brk()
908
909 config HAVE_ARCH_MMAP_RND_BITS
910         bool
911         help
912           An arch should select this symbol if it supports setting a variable
913           number of bits for use in establishing the base address for mmap
914           allocations, has MMU enabled and provides values for both:
915           - ARCH_MMAP_RND_BITS_MIN
916           - ARCH_MMAP_RND_BITS_MAX
917
918 config HAVE_EXIT_THREAD
919         bool
920         help
921           An architecture implements exit_thread.
922
923 config ARCH_MMAP_RND_BITS_MIN
924         int
925
926 config ARCH_MMAP_RND_BITS_MAX
927         int
928
929 config ARCH_MMAP_RND_BITS_DEFAULT
930         int
931
932 config ARCH_MMAP_RND_BITS
933         int "Number of bits to use for ASLR of mmap base address" if EXPERT
934         range ARCH_MMAP_RND_BITS_MIN ARCH_MMAP_RND_BITS_MAX
935         default ARCH_MMAP_RND_BITS_DEFAULT if ARCH_MMAP_RND_BITS_DEFAULT
936         default ARCH_MMAP_RND_BITS_MIN
937         depends on HAVE_ARCH_MMAP_RND_BITS
938         help
939           This value can be used to select the number of bits to use to
940           determine the random offset to the base address of vma regions
941           resulting from mmap allocations. This value will be bounded
942           by the architecture's minimum and maximum supported values.
943
944           This value can be changed after boot using the
945           /proc/sys/vm/mmap_rnd_bits tunable
946
947 config HAVE_ARCH_MMAP_RND_COMPAT_BITS
948         bool
949         help
950           An arch should select this symbol if it supports running applications
951           in compatibility mode, supports setting a variable number of bits for
952           use in establishing the base address for mmap allocations, has MMU
953           enabled and provides values for both:
954           - ARCH_MMAP_RND_COMPAT_BITS_MIN
955           - ARCH_MMAP_RND_COMPAT_BITS_MAX
956
957 config ARCH_MMAP_RND_COMPAT_BITS_MIN
958         int
959
960 config ARCH_MMAP_RND_COMPAT_BITS_MAX
961         int
962
963 config ARCH_MMAP_RND_COMPAT_BITS_DEFAULT
964         int
965
966 config ARCH_MMAP_RND_COMPAT_BITS
967         int "Number of bits to use for ASLR of mmap base address for compatible applications" if EXPERT
968         range ARCH_MMAP_RND_COMPAT_BITS_MIN ARCH_MMAP_RND_COMPAT_BITS_MAX
969         default ARCH_MMAP_RND_COMPAT_BITS_DEFAULT if ARCH_MMAP_RND_COMPAT_BITS_DEFAULT
970         default ARCH_MMAP_RND_COMPAT_BITS_MIN
971         depends on HAVE_ARCH_MMAP_RND_COMPAT_BITS
972         help
973           This value can be used to select the number of bits to use to
974           determine the random offset to the base address of vma regions
975           resulting from mmap allocations for compatible applications This
976           value will be bounded by the architecture's minimum and maximum
977           supported values.
978
979           This value can be changed after boot using the
980           /proc/sys/vm/mmap_rnd_compat_bits tunable
981
982 config HAVE_ARCH_COMPAT_MMAP_BASES
983         bool
984         help
985           This allows 64bit applications to invoke 32-bit mmap() syscall
986           and vice-versa 32-bit applications to call 64-bit mmap().
987           Required for applications doing different bitness syscalls.
988
989 # This allows to use a set of generic functions to determine mmap base
990 # address by giving priority to top-down scheme only if the process
991 # is not in legacy mode (compat task, unlimited stack size or
992 # sysctl_legacy_va_layout).
993 # Architecture that selects this option can provide its own version of:
994 # - STACK_RND_MASK
995 config ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT
996         bool
997         depends on MMU
998         select ARCH_HAS_ELF_RANDOMIZE
999
1000 config HAVE_STACK_VALIDATION
1001         bool
1002         help
1003           Architecture supports the 'objtool check' host tool command, which
1004           performs compile-time stack metadata validation.
1005
1006 config HAVE_RELIABLE_STACKTRACE
1007         bool
1008         help
1009           Architecture has either save_stack_trace_tsk_reliable() or
1010           arch_stack_walk_reliable() function which only returns a stack trace
1011           if it can guarantee the trace is reliable.
1012
1013 config HAVE_ARCH_HASH
1014         bool
1015         default n
1016         help
1017           If this is set, the architecture provides an <asm/hash.h>
1018           file which provides platform-specific implementations of some
1019           functions in <linux/hash.h> or fs/namei.c.
1020
1021 config HAVE_ARCH_NVRAM_OPS
1022         bool
1023
1024 config ISA_BUS_API
1025         def_bool ISA
1026
1027 #
1028 # ABI hall of shame
1029 #
1030 config CLONE_BACKWARDS
1031         bool
1032         help
1033           Architecture has tls passed as the 4th argument of clone(2),
1034           not the 5th one.
1035
1036 config CLONE_BACKWARDS2
1037         bool
1038         help
1039           Architecture has the first two arguments of clone(2) swapped.
1040
1041 config CLONE_BACKWARDS3
1042         bool
1043         help
1044           Architecture has tls passed as the 3rd argument of clone(2),
1045           not the 5th one.
1046
1047 config ODD_RT_SIGACTION
1048         bool
1049         help
1050           Architecture has unusual rt_sigaction(2) arguments
1051
1052 config OLD_SIGSUSPEND
1053         bool
1054         help
1055           Architecture has old sigsuspend(2) syscall, of one-argument variety
1056
1057 config OLD_SIGSUSPEND3
1058         bool
1059         help
1060           Even weirder antique ABI - three-argument sigsuspend(2)
1061
1062 config OLD_SIGACTION
1063         bool
1064         help
1065           Architecture has old sigaction(2) syscall.  Nope, not the same
1066           as OLD_SIGSUSPEND | OLD_SIGSUSPEND3 - alpha has sigsuspend(2),
1067           but fairly different variant of sigaction(2), thanks to OSF/1
1068           compatibility...
1069
1070 config COMPAT_OLD_SIGACTION
1071         bool
1072
1073 config COMPAT_32BIT_TIME
1074         bool "Provide system calls for 32-bit time_t"
1075         default !64BIT || COMPAT
1076         help
1077           This enables 32 bit time_t support in addition to 64 bit time_t support.
1078           This is relevant on all 32-bit architectures, and 64-bit architectures
1079           as part of compat syscall handling.
1080
1081 config ARCH_NO_PREEMPT
1082         bool
1083
1084 config ARCH_EPHEMERAL_INODES
1085         def_bool n
1086         help
1087           An arch should select this symbol if it doesn't keep track of inode
1088           instances on its own, but instead relies on something else (e.g. the
1089           host kernel for an UML kernel).
1090
1091 config ARCH_SUPPORTS_RT
1092         bool
1093
1094 config CPU_NO_EFFICIENT_FFS
1095         def_bool n
1096
1097 config HAVE_ARCH_VMAP_STACK
1098         def_bool n
1099         help
1100           An arch should select this symbol if it can support kernel stacks
1101           in vmalloc space.  This means:
1102
1103           - vmalloc space must be large enough to hold many kernel stacks.
1104             This may rule out many 32-bit architectures.
1105
1106           - Stacks in vmalloc space need to work reliably.  For example, if
1107             vmap page tables are created on demand, either this mechanism
1108             needs to work while the stack points to a virtual address with
1109             unpopulated page tables or arch code (switch_to() and switch_mm(),
1110             most likely) needs to ensure that the stack's page table entries
1111             are populated before running on a possibly unpopulated stack.
1112
1113           - If the stack overflows into a guard page, something reasonable
1114             should happen.  The definition of "reasonable" is flexible, but
1115             instantly rebooting without logging anything would be unfriendly.
1116
1117 config VMAP_STACK
1118         default y
1119         bool "Use a virtually-mapped stack"
1120         depends on HAVE_ARCH_VMAP_STACK
1121         depends on !KASAN || KASAN_HW_TAGS || KASAN_VMALLOC
1122         help
1123           Enable this if you want the use virtually-mapped kernel stacks
1124           with guard pages.  This causes kernel stack overflows to be
1125           caught immediately rather than causing difficult-to-diagnose
1126           corruption.
1127
1128           To use this with software KASAN modes, the architecture must support
1129           backing virtual mappings with real shadow memory, and KASAN_VMALLOC
1130           must be enabled.
1131
1132 config HAVE_ARCH_RANDOMIZE_KSTACK_OFFSET
1133         def_bool n
1134         help
1135           An arch should select this symbol if it can support kernel stack
1136           offset randomization with calls to add_random_kstack_offset()
1137           during syscall entry and choose_random_kstack_offset() during
1138           syscall exit. Careful removal of -fstack-protector-strong and
1139           -fstack-protector should also be applied to the entry code and
1140           closely examined, as the artificial stack bump looks like an array
1141           to the compiler, so it will attempt to add canary checks regardless
1142           of the static branch state.
1143
1144 config RANDOMIZE_KSTACK_OFFSET_DEFAULT
1145         bool "Randomize kernel stack offset on syscall entry"
1146         depends on HAVE_ARCH_RANDOMIZE_KSTACK_OFFSET
1147         depends on INIT_STACK_NONE || !CC_IS_CLANG || CLANG_VERSION >= 140000
1148         help
1149           The kernel stack offset can be randomized (after pt_regs) by
1150           roughly 5 bits of entropy, frustrating memory corruption
1151           attacks that depend on stack address determinism or
1152           cross-syscall address exposures. This feature is controlled
1153           by kernel boot param "randomize_kstack_offset=on/off", and this
1154           config chooses the default boot state.
1155
1156 config ARCH_OPTIONAL_KERNEL_RWX
1157         def_bool n
1158
1159 config ARCH_OPTIONAL_KERNEL_RWX_DEFAULT
1160         def_bool n
1161
1162 config ARCH_HAS_STRICT_KERNEL_RWX
1163         def_bool n
1164
1165 config STRICT_KERNEL_RWX
1166         bool "Make kernel text and rodata read-only" if ARCH_OPTIONAL_KERNEL_RWX
1167         depends on ARCH_HAS_STRICT_KERNEL_RWX
1168         default !ARCH_OPTIONAL_KERNEL_RWX || ARCH_OPTIONAL_KERNEL_RWX_DEFAULT
1169         help
1170           If this is set, kernel text and rodata memory will be made read-only,
1171           and non-text memory will be made non-executable. This provides
1172           protection against certain security exploits (e.g. executing the heap
1173           or modifying text)
1174
1175           These features are considered standard security practice these days.
1176           You should say Y here in almost all cases.
1177
1178 config ARCH_HAS_STRICT_MODULE_RWX
1179         def_bool n
1180
1181 config STRICT_MODULE_RWX
1182         bool "Set loadable kernel module data as NX and text as RO" if ARCH_OPTIONAL_KERNEL_RWX
1183         depends on ARCH_HAS_STRICT_MODULE_RWX && MODULES
1184         default !ARCH_OPTIONAL_KERNEL_RWX || ARCH_OPTIONAL_KERNEL_RWX_DEFAULT
1185         help
1186           If this is set, module text and rodata memory will be made read-only,
1187           and non-text memory will be made non-executable. This provides
1188           protection against certain security exploits (e.g. writing to text)
1189
1190 # select if the architecture provides an asm/dma-direct.h header
1191 config ARCH_HAS_PHYS_TO_DMA
1192         bool
1193
1194 config HAVE_ARCH_COMPILER_H
1195         bool
1196         help
1197           An architecture can select this if it provides an
1198           asm/compiler.h header that should be included after
1199           linux/compiler-*.h in order to override macro definitions that those
1200           headers generally provide.
1201
1202 config HAVE_ARCH_PREL32_RELOCATIONS
1203         bool
1204         help
1205           May be selected by an architecture if it supports place-relative
1206           32-bit relocations, both in the toolchain and in the module loader,
1207           in which case relative references can be used in special sections
1208           for PCI fixup, initcalls etc which are only half the size on 64 bit
1209           architectures, and don't require runtime relocation on relocatable
1210           kernels.
1211
1212 config ARCH_USE_MEMREMAP_PROT
1213         bool
1214
1215 config LOCK_EVENT_COUNTS
1216         bool "Locking event counts collection"
1217         depends on DEBUG_FS
1218         help
1219           Enable light-weight counting of various locking related events
1220           in the system with minimal performance impact. This reduces
1221           the chance of application behavior change because of timing
1222           differences. The counts are reported via debugfs.
1223
1224 # Select if the architecture has support for applying RELR relocations.
1225 config ARCH_HAS_RELR
1226         bool
1227
1228 config RELR
1229         bool "Use RELR relocation packing"
1230         depends on ARCH_HAS_RELR && TOOLS_SUPPORT_RELR
1231         default y
1232         help
1233           Store the kernel's dynamic relocations in the RELR relocation packing
1234           format. Requires a compatible linker (LLD supports this feature), as
1235           well as compatible NM and OBJCOPY utilities (llvm-nm and llvm-objcopy
1236           are compatible).
1237
1238 config ARCH_HAS_MEM_ENCRYPT
1239         bool
1240
1241 config ARCH_HAS_CC_PLATFORM
1242         bool
1243
1244 config HAVE_SPARSE_SYSCALL_NR
1245        bool
1246        help
1247           An architecture should select this if its syscall numbering is sparse
1248           to save space. For example, MIPS architecture has a syscall array with
1249           entries at 4000, 5000 and 6000 locations. This option turns on syscall
1250           related optimizations for a given architecture.
1251
1252 config ARCH_HAS_VDSO_DATA
1253         bool
1254
1255 config HAVE_STATIC_CALL
1256         bool
1257
1258 config HAVE_STATIC_CALL_INLINE
1259         bool
1260         depends on HAVE_STATIC_CALL
1261
1262 config HAVE_PREEMPT_DYNAMIC
1263         bool
1264         depends on HAVE_STATIC_CALL
1265         depends on GENERIC_ENTRY
1266         help
1267            Select this if the architecture support boot time preempt setting
1268            on top of static calls. It is strongly advised to support inline
1269            static call to avoid any overhead.
1270
1271 config ARCH_WANT_LD_ORPHAN_WARN
1272         bool
1273         help
1274           An arch should select this symbol once all linker sections are explicitly
1275           included, size-asserted, or discarded in the linker scripts. This is
1276           important because we never want expected sections to be placed heuristically
1277           by the linker, since the locations of such sections can change between linker
1278           versions.
1279
1280 config HAVE_ARCH_PFN_VALID
1281         bool
1282
1283 config ARCH_SUPPORTS_DEBUG_PAGEALLOC
1284         bool
1285
1286 config ARCH_SPLIT_ARG64
1287         bool
1288         help
1289            If a 32-bit architecture requires 64-bit arguments to be split into
1290            pairs of 32-bit arguments, select this option.
1291
1292 config ARCH_HAS_ELFCORE_COMPAT
1293         bool
1294
1295 config ARCH_HAS_PARANOID_L1D_FLUSH
1296         bool
1297
1298 source "kernel/gcov/Kconfig"
1299
1300 source "scripts/gcc-plugins/Kconfig"
1301
1302 endmenu