riscv: Move create_tmp_mapping() to init sections
[linux-block.git] / arch / riscv / Kconfig
1 # SPDX-License-Identifier: GPL-2.0-only
2 #
3 # For a description of the syntax of this configuration file,
4 # see Documentation/kbuild/kconfig-language.rst.
5 #
6
7 config 64BIT
8         bool
9
10 config 32BIT
11         bool
12
13 config RISCV
14         def_bool y
15         select ACPI_GENERIC_GSI if ACPI
16         select ACPI_REDUCED_HARDWARE_ONLY if ACPI
17         select ARCH_DMA_DEFAULT_COHERENT
18         select ARCH_ENABLE_HUGEPAGE_MIGRATION if HUGETLB_PAGE && MIGRATION
19         select ARCH_ENABLE_SPLIT_PMD_PTLOCK if PGTABLE_LEVELS > 2
20         select ARCH_ENABLE_THP_MIGRATION if TRANSPARENT_HUGEPAGE
21         select ARCH_HAS_BINFMT_FLAT
22         select ARCH_HAS_CURRENT_STACK_POINTER
23         select ARCH_HAS_DEBUG_VIRTUAL if MMU
24         select ARCH_HAS_DEBUG_VM_PGTABLE
25         select ARCH_HAS_DEBUG_WX
26         select ARCH_HAS_FORTIFY_SOURCE
27         select ARCH_HAS_GCOV_PROFILE_ALL
28         select ARCH_HAS_GIGANTIC_PAGE
29         select ARCH_HAS_KCOV
30         select ARCH_HAS_MMIOWB
31         select ARCH_HAS_NON_OVERLAPPING_ADDRESS_SPACE
32         select ARCH_HAS_PMEM_API
33         select ARCH_HAS_PTE_SPECIAL
34         select ARCH_HAS_SET_DIRECT_MAP if MMU
35         select ARCH_HAS_SET_MEMORY if MMU
36         select ARCH_HAS_STRICT_KERNEL_RWX if MMU && !XIP_KERNEL
37         select ARCH_HAS_STRICT_MODULE_RWX if MMU && !XIP_KERNEL
38         select ARCH_HAS_TICK_BROADCAST if GENERIC_CLOCKEVENTS_BROADCAST
39         select ARCH_HAS_UBSAN_SANITIZE_ALL
40         select ARCH_HAS_VDSO_DATA
41         select ARCH_OPTIONAL_KERNEL_RWX if ARCH_HAS_STRICT_KERNEL_RWX
42         select ARCH_OPTIONAL_KERNEL_RWX_DEFAULT
43         select ARCH_STACKWALK
44         select ARCH_SUPPORTS_ATOMIC_RMW
45         select ARCH_SUPPORTS_DEBUG_PAGEALLOC if MMU
46         select ARCH_SUPPORTS_HUGETLBFS if MMU
47         select ARCH_SUPPORTS_PAGE_TABLE_CHECK if MMU
48         select ARCH_SUPPORTS_PER_VMA_LOCK if MMU
49         select ARCH_USE_MEMTEST
50         select ARCH_USE_QUEUED_RWLOCKS
51         select ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT if MMU
52         select ARCH_WANT_FRAME_POINTERS
53         select ARCH_WANT_GENERAL_HUGETLB if !RISCV_ISA_SVNAPOT
54         select ARCH_WANT_HUGE_PMD_SHARE if 64BIT
55         select ARCH_WANT_LD_ORPHAN_WARN if !XIP_KERNEL
56         select ARCH_WANT_OPTIMIZE_VMEMMAP
57         select ARCH_WANTS_THP_SWAP if HAVE_ARCH_TRANSPARENT_HUGEPAGE
58         select BINFMT_FLAT_NO_DATA_START_OFFSET if !MMU
59         select BUILDTIME_TABLE_SORT if MMU
60         select CLINT_TIMER if !MMU
61         select CLONE_BACKWARDS
62         select COMMON_CLK
63         select CPU_PM if CPU_IDLE || HIBERNATION
64         select EDAC_SUPPORT
65         select FRAME_POINTER if PERF_EVENTS || (FUNCTION_TRACER && !DYNAMIC_FTRACE)
66         select GENERIC_ARCH_TOPOLOGY
67         select GENERIC_ATOMIC64 if !64BIT
68         select GENERIC_CLOCKEVENTS_BROADCAST if SMP
69         select GENERIC_EARLY_IOREMAP
70         select GENERIC_ENTRY
71         select GENERIC_GETTIMEOFDAY if HAVE_GENERIC_VDSO
72         select GENERIC_IDLE_POLL_SETUP
73         select GENERIC_IOREMAP if MMU
74         select GENERIC_IRQ_IPI if SMP
75         select GENERIC_IRQ_IPI_MUX if SMP
76         select GENERIC_IRQ_MULTI_HANDLER
77         select GENERIC_IRQ_SHOW
78         select GENERIC_IRQ_SHOW_LEVEL
79         select GENERIC_LIB_DEVMEM_IS_ALLOWED
80         select GENERIC_PCI_IOMAP
81         select GENERIC_PTDUMP if MMU
82         select GENERIC_SCHED_CLOCK
83         select GENERIC_SMP_IDLE_THREAD
84         select GENERIC_TIME_VSYSCALL if MMU && 64BIT
85         select GENERIC_VDSO_TIME_NS if HAVE_GENERIC_VDSO
86         select HARDIRQS_SW_RESEND
87         select HAS_IOPORT if MMU
88         select HAVE_ARCH_AUDITSYSCALL
89         select HAVE_ARCH_HUGE_VMALLOC if HAVE_ARCH_HUGE_VMAP
90         select HAVE_ARCH_HUGE_VMAP if MMU && 64BIT && !XIP_KERNEL
91         select HAVE_ARCH_JUMP_LABEL if !XIP_KERNEL
92         select HAVE_ARCH_JUMP_LABEL_RELATIVE if !XIP_KERNEL
93         select HAVE_ARCH_KASAN if MMU && 64BIT
94         select HAVE_ARCH_KASAN_VMALLOC if MMU && 64BIT
95         select HAVE_ARCH_KFENCE if MMU && 64BIT
96         select HAVE_ARCH_KGDB if !XIP_KERNEL
97         select HAVE_ARCH_KGDB_QXFER_PKT
98         select HAVE_ARCH_MMAP_RND_BITS if MMU
99         select HAVE_ARCH_MMAP_RND_COMPAT_BITS if COMPAT
100         select HAVE_ARCH_SECCOMP_FILTER
101         select HAVE_ARCH_THREAD_STRUCT_WHITELIST
102         select HAVE_ARCH_TRACEHOOK
103         select HAVE_ARCH_TRANSPARENT_HUGEPAGE if 64BIT && MMU
104         select HAVE_ARCH_USERFAULTFD_MINOR if 64BIT && USERFAULTFD
105         select HAVE_ARCH_VMAP_STACK if MMU && 64BIT
106         select HAVE_ASM_MODVERSIONS
107         select HAVE_CONTEXT_TRACKING_USER
108         select HAVE_DEBUG_KMEMLEAK
109         select HAVE_DMA_CONTIGUOUS if MMU
110         select HAVE_DYNAMIC_FTRACE if !XIP_KERNEL && MMU && (CLANG_SUPPORTS_DYNAMIC_FTRACE || GCC_SUPPORTS_DYNAMIC_FTRACE)
111         select HAVE_DYNAMIC_FTRACE_WITH_REGS if HAVE_DYNAMIC_FTRACE
112         select HAVE_FTRACE_MCOUNT_RECORD if !XIP_KERNEL
113         select HAVE_FUNCTION_GRAPH_TRACER
114         select HAVE_FUNCTION_GRAPH_RETVAL if HAVE_FUNCTION_GRAPH_TRACER
115         select HAVE_FUNCTION_TRACER if !XIP_KERNEL && !PREEMPTION
116         select HAVE_EBPF_JIT if MMU
117         select HAVE_FUNCTION_ARG_ACCESS_API
118         select HAVE_FUNCTION_ERROR_INJECTION
119         select HAVE_GCC_PLUGINS
120         select HAVE_GENERIC_VDSO if MMU && 64BIT
121         select HAVE_IRQ_TIME_ACCOUNTING
122         select HAVE_KPROBES if !XIP_KERNEL
123         select HAVE_KPROBES_ON_FTRACE if !XIP_KERNEL
124         select HAVE_KRETPROBES if !XIP_KERNEL
125         # https://github.com/ClangBuiltLinux/linux/issues/1881
126         select HAVE_LD_DEAD_CODE_DATA_ELIMINATION if !LD_IS_LLD
127         select HAVE_MOVE_PMD
128         select HAVE_MOVE_PUD
129         select HAVE_PCI
130         select HAVE_PERF_EVENTS
131         select HAVE_PERF_REGS
132         select HAVE_PERF_USER_STACK_DUMP
133         select HAVE_POSIX_CPU_TIMERS_TASK_WORK
134         select HAVE_REGS_AND_STACK_ACCESS_API
135         select HAVE_RETHOOK if !XIP_KERNEL
136         select HAVE_RSEQ
137         select HAVE_STACKPROTECTOR
138         select HAVE_SYSCALL_TRACEPOINTS
139         select HOTPLUG_CORE_SYNC_DEAD if HOTPLUG_CPU
140         select IRQ_DOMAIN
141         select IRQ_FORCED_THREADING
142         select KASAN_VMALLOC if KASAN
143         select LOCK_MM_AND_FIND_VMA
144         select MODULES_USE_ELF_RELA if MODULES
145         select MODULE_SECTIONS if MODULES
146         select OF
147         select OF_EARLY_FLATTREE
148         select OF_IRQ
149         select PCI_DOMAINS_GENERIC if PCI
150         select PCI_MSI if PCI
151         select RISCV_ALTERNATIVE if !XIP_KERNEL
152         select RISCV_INTC
153         select RISCV_TIMER if RISCV_SBI
154         select SIFIVE_PLIC
155         select SPARSE_IRQ
156         select SYSCTL_EXCEPTION_TRACE
157         select THREAD_INFO_IN_TASK
158         select TRACE_IRQFLAGS_SUPPORT
159         select UACCESS_MEMCPY if !MMU
160         select ZONE_DMA32 if 64BIT
161
162 config CLANG_SUPPORTS_DYNAMIC_FTRACE
163         def_bool CC_IS_CLANG
164         # https://github.com/llvm/llvm-project/commit/6ab8927931851bb42b2c93a00801dc499d7d9b1e
165         depends on CLANG_VERSION >= 130000
166         # https://github.com/ClangBuiltLinux/linux/issues/1817
167         depends on AS_IS_GNU || (AS_IS_LLVM && (LD_IS_LLD || LD_VERSION >= 23600))
168
169 config GCC_SUPPORTS_DYNAMIC_FTRACE
170         def_bool CC_IS_GCC
171         depends on $(cc-option,-fpatchable-function-entry=8)
172
173 config ARCH_MMAP_RND_BITS_MIN
174         default 18 if 64BIT
175         default 8
176
177 config ARCH_MMAP_RND_COMPAT_BITS_MIN
178         default 8
179
180 # max bits determined by the following formula:
181 #  VA_BITS - PAGE_SHIFT - 3
182 config ARCH_MMAP_RND_BITS_MAX
183         default 24 if 64BIT # SV39 based
184         default 17
185
186 config ARCH_MMAP_RND_COMPAT_BITS_MAX
187         default 17
188
189 # set if we run in machine mode, cleared if we run in supervisor mode
190 config RISCV_M_MODE
191         bool
192         default !MMU
193
194 # set if we are running in S-mode and can use SBI calls
195 config RISCV_SBI
196         bool
197         depends on !RISCV_M_MODE
198         default y
199
200 config MMU
201         bool "MMU-based Paged Memory Management Support"
202         default y
203         help
204           Select if you want MMU-based virtualised addressing space
205           support by paged memory management. If unsure, say 'Y'.
206
207 config PAGE_OFFSET
208         hex
209         default 0xC0000000 if 32BIT && MMU
210         default 0x80000000 if !MMU
211         default 0xff60000000000000 if 64BIT
212
213 config KASAN_SHADOW_OFFSET
214         hex
215         depends on KASAN_GENERIC
216         default 0xdfffffff00000000 if 64BIT
217         default 0xffffffff if 32BIT
218
219 config ARCH_FLATMEM_ENABLE
220         def_bool !NUMA
221
222 config ARCH_SPARSEMEM_ENABLE
223         def_bool y
224         depends on MMU
225         select SPARSEMEM_STATIC if 32BIT && SPARSEMEM
226         select SPARSEMEM_VMEMMAP_ENABLE if 64BIT
227
228 config ARCH_SELECT_MEMORY_MODEL
229         def_bool ARCH_SPARSEMEM_ENABLE
230
231 config ARCH_SUPPORTS_UPROBES
232         def_bool y
233
234 config STACKTRACE_SUPPORT
235         def_bool y
236
237 config GENERIC_BUG
238         def_bool y
239         depends on BUG
240         select GENERIC_BUG_RELATIVE_POINTERS if 64BIT
241
242 config GENERIC_BUG_RELATIVE_POINTERS
243         bool
244
245 config GENERIC_CALIBRATE_DELAY
246         def_bool y
247
248 config GENERIC_CSUM
249         def_bool y
250
251 config GENERIC_HWEIGHT
252         def_bool y
253
254 config FIX_EARLYCON_MEM
255         def_bool MMU
256
257 config PGTABLE_LEVELS
258         int
259         default 5 if 64BIT
260         default 2
261
262 config LOCKDEP_SUPPORT
263         def_bool y
264
265 config RISCV_DMA_NONCOHERENT
266         bool
267         select ARCH_HAS_DMA_PREP_COHERENT
268         select ARCH_HAS_SETUP_DMA_OPS
269         select ARCH_HAS_SYNC_DMA_FOR_CPU
270         select ARCH_HAS_SYNC_DMA_FOR_DEVICE
271         select DMA_DIRECT_REMAP
272
273 config AS_HAS_INSN
274         def_bool $(as-instr,.insn r 51$(comma) 0$(comma) 0$(comma) t0$(comma) t0$(comma) zero)
275
276 config AS_HAS_OPTION_ARCH
277         # https://reviews.llvm.org/D123515
278         def_bool y
279         depends on $(as-instr, .option arch$(comma) +m)
280         depends on !$(as-instr, .option arch$(comma) -i)
281
282 source "arch/riscv/Kconfig.socs"
283 source "arch/riscv/Kconfig.errata"
284
285 menu "Platform type"
286
287 config NONPORTABLE
288         bool "Allow configurations that result in non-portable kernels"
289         help
290           RISC-V kernel binaries are compatible between all known systems
291           whenever possible, but there are some use cases that can only be
292           satisfied by configurations that result in kernel binaries that are
293           not portable between systems.
294
295           Selecting N does not guarantee kernels will be portable to all known
296           systems.  Selecting any of the options guarded by NONPORTABLE will
297           result in kernel binaries that are unlikely to be portable between
298           systems.
299
300           If unsure, say N.
301
302 choice
303         prompt "Base ISA"
304         default ARCH_RV64I
305         help
306           This selects the base ISA that this kernel will target and must match
307           the target platform.
308
309 config ARCH_RV32I
310         bool "RV32I"
311         depends on NONPORTABLE
312         select 32BIT
313         select GENERIC_LIB_ASHLDI3
314         select GENERIC_LIB_ASHRDI3
315         select GENERIC_LIB_LSHRDI3
316         select GENERIC_LIB_UCMPDI2
317
318 config ARCH_RV64I
319         bool "RV64I"
320         select 64BIT
321         select ARCH_SUPPORTS_INT128 if CC_HAS_INT128
322         select SWIOTLB if MMU
323
324 endchoice
325
326 # We must be able to map all physical memory into the kernel, but the compiler
327 # is still a bit more efficient when generating code if it's setup in a manner
328 # such that it can only map 2GiB of memory.
329 choice
330         prompt "Kernel Code Model"
331         default CMODEL_MEDLOW if 32BIT
332         default CMODEL_MEDANY if 64BIT
333
334         config CMODEL_MEDLOW
335                 bool "medium low code model"
336         config CMODEL_MEDANY
337                 bool "medium any code model"
338 endchoice
339
340 config MODULE_SECTIONS
341         bool
342         select HAVE_MOD_ARCH_SPECIFIC
343
344 config SMP
345         bool "Symmetric Multi-Processing"
346         help
347           This enables support for systems with more than one CPU.  If
348           you say N here, the kernel will run on single and
349           multiprocessor machines, but will use only one CPU of a
350           multiprocessor machine. If you say Y here, the kernel will run
351           on many, but not all, single processor machines. On a single
352           processor machine, the kernel will run faster if you say N
353           here.
354
355           If you don't know what to do here, say N.
356
357 config SCHED_MC
358         bool "Multi-core scheduler support"
359         depends on SMP
360         help
361           Multi-core scheduler support improves the CPU scheduler's decision
362           making when dealing with multi-core CPU chips at a cost of slightly
363           increased overhead in some places. If unsure say N here.
364
365 config NR_CPUS
366         int "Maximum number of CPUs (2-512)"
367         depends on SMP
368         range 2 512 if !RISCV_SBI_V01
369         range 2 32 if RISCV_SBI_V01 && 32BIT
370         range 2 64 if RISCV_SBI_V01 && 64BIT
371         default "32" if 32BIT
372         default "64" if 64BIT
373
374 config HOTPLUG_CPU
375         bool "Support for hot-pluggable CPUs"
376         depends on SMP
377         select GENERIC_IRQ_MIGRATION
378         help
379
380           Say Y here to experiment with turning CPUs off and on.  CPUs
381           can be controlled through /sys/devices/system/cpu.
382
383           Say N if you want to disable CPU hotplug.
384
385 choice
386         prompt "CPU Tuning"
387         default TUNE_GENERIC
388
389 config TUNE_GENERIC
390         bool "generic"
391
392 endchoice
393
394 # Common NUMA Features
395 config NUMA
396         bool "NUMA Memory Allocation and Scheduler Support"
397         depends on SMP && MMU
398         select ARCH_SUPPORTS_NUMA_BALANCING
399         select GENERIC_ARCH_NUMA
400         select NEED_PER_CPU_EMBED_FIRST_CHUNK
401         select OF_NUMA
402         select USE_PERCPU_NUMA_NODE_ID
403         help
404           Enable NUMA (Non-Uniform Memory Access) support.
405
406           The kernel will try to allocate memory used by a CPU on the
407           local memory of the CPU and add some more NUMA awareness to the kernel.
408
409 config NODES_SHIFT
410         int "Maximum NUMA Nodes (as a power of 2)"
411         range 1 10
412         default "2"
413         depends on NUMA
414         help
415           Specify the maximum number of NUMA Nodes available on the target
416           system.  Increases memory reserved to accommodate various tables.
417
418 config RISCV_ALTERNATIVE
419         bool
420         depends on !XIP_KERNEL
421         help
422           This Kconfig allows the kernel to automatically patch the
423           erratum or cpufeature required by the execution platform at run
424           time. The code patching overhead is minimal, as it's only done
425           once at boot and once on each module load.
426
427 config RISCV_ALTERNATIVE_EARLY
428         bool
429         depends on RISCV_ALTERNATIVE
430         help
431           Allows early patching of the kernel for special errata
432
433 config RISCV_ISA_C
434         bool "Emit compressed instructions when building Linux"
435         default y
436         help
437           Adds "C" to the ISA subsets that the toolchain is allowed to emit
438           when building Linux, which results in compressed instructions in the
439           Linux binary.
440
441           If you don't know what to do here, say Y.
442
443 config RISCV_ISA_SVNAPOT
444         bool "Svnapot extension support for supervisor mode NAPOT pages"
445         depends on 64BIT && MMU
446         depends on RISCV_ALTERNATIVE
447         default y
448         help
449           Allow kernel to detect the Svnapot ISA-extension dynamically at boot
450           time and enable its usage.
451
452           The Svnapot extension is used to mark contiguous PTEs as a range
453           of contiguous virtual-to-physical translations for a naturally
454           aligned power-of-2 (NAPOT) granularity larger than the base 4KB page
455           size. When HUGETLBFS is also selected this option unconditionally
456           allocates some memory for each NAPOT page size supported by the kernel.
457           When optimizing for low memory consumption and for platforms without
458           the Svnapot extension, it may be better to say N here.
459
460           If you don't know what to do here, say Y.
461
462 config RISCV_ISA_SVPBMT
463         bool "Svpbmt extension support for supervisor mode page-based memory types"
464         depends on 64BIT && MMU
465         depends on RISCV_ALTERNATIVE
466         default y
467         help
468            Adds support to dynamically detect the presence of the Svpbmt
469            ISA-extension (Supervisor-mode: page-based memory types) and
470            enable its usage.
471
472            The memory type for a page contains a combination of attributes
473            that indicate the cacheability, idempotency, and ordering
474            properties for access to that page.
475
476            The Svpbmt extension is only available on 64-bit cpus.
477
478            If you don't know what to do here, say Y.
479
480 config TOOLCHAIN_HAS_V
481         bool
482         default y
483         depends on !64BIT || $(cc-option,-mabi=lp64 -march=rv64iv)
484         depends on !32BIT || $(cc-option,-mabi=ilp32 -march=rv32iv)
485         depends on LLD_VERSION >= 140000 || LD_VERSION >= 23800
486         depends on AS_HAS_OPTION_ARCH
487
488 config RISCV_ISA_V
489         bool "VECTOR extension support"
490         depends on TOOLCHAIN_HAS_V
491         depends on FPU
492         select DYNAMIC_SIGFRAME
493         default y
494         help
495           Say N here if you want to disable all vector related procedure
496           in the kernel.
497
498           If you don't know what to do here, say Y.
499
500 config RISCV_ISA_V_DEFAULT_ENABLE
501         bool "Enable userspace Vector by default"
502         depends on RISCV_ISA_V
503         default y
504         help
505           Say Y here if you want to enable Vector in userspace by default.
506           Otherwise, userspace has to make explicit prctl() call to enable
507           Vector, or enable it via the sysctl interface.
508
509           If you don't know what to do here, say Y.
510
511 config TOOLCHAIN_HAS_ZBB
512         bool
513         default y
514         depends on !64BIT || $(cc-option,-mabi=lp64 -march=rv64ima_zbb)
515         depends on !32BIT || $(cc-option,-mabi=ilp32 -march=rv32ima_zbb)
516         depends on LLD_VERSION >= 150000 || LD_VERSION >= 23900
517         depends on AS_HAS_OPTION_ARCH
518
519 config RISCV_ISA_ZBB
520         bool "Zbb extension support for bit manipulation instructions"
521         depends on TOOLCHAIN_HAS_ZBB
522         depends on MMU
523         depends on RISCV_ALTERNATIVE
524         default y
525         help
526            Adds support to dynamically detect the presence of the ZBB
527            extension (basic bit manipulation) and enable its usage.
528
529            The Zbb extension provides instructions to accelerate a number
530            of bit-specific operations (count bit population, sign extending,
531            bitrotation, etc).
532
533            If you don't know what to do here, say Y.
534
535 config RISCV_ISA_ZICBOM
536         bool "Zicbom extension support for non-coherent DMA operation"
537         depends on MMU
538         depends on RISCV_ALTERNATIVE
539         default y
540         select RISCV_DMA_NONCOHERENT
541         help
542            Adds support to dynamically detect the presence of the ZICBOM
543            extension (Cache Block Management Operations) and enable its
544            usage.
545
546            The Zicbom extension can be used to handle for example
547            non-coherent DMA support on devices that need it.
548
549            If you don't know what to do here, say Y.
550
551 config RISCV_ISA_ZICBOZ
552         bool "Zicboz extension support for faster zeroing of memory"
553         depends on MMU
554         depends on RISCV_ALTERNATIVE
555         default y
556         help
557            Enable the use of the Zicboz extension (cbo.zero instruction)
558            when available.
559
560            The Zicboz extension is used for faster zeroing of memory.
561
562            If you don't know what to do here, say Y.
563
564 config TOOLCHAIN_HAS_ZIHINTPAUSE
565         bool
566         default y
567         depends on !64BIT || $(cc-option,-mabi=lp64 -march=rv64ima_zihintpause)
568         depends on !32BIT || $(cc-option,-mabi=ilp32 -march=rv32ima_zihintpause)
569         depends on LLD_VERSION >= 150000 || LD_VERSION >= 23600
570
571 config TOOLCHAIN_NEEDS_EXPLICIT_ZICSR_ZIFENCEI
572         def_bool y
573         # https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=aed44286efa8ae8717a77d94b51ac3614e2ca6dc
574         depends on AS_IS_GNU && AS_VERSION >= 23800
575         help
576           Newer binutils versions default to ISA spec version 20191213 which
577           moves some instructions from the I extension to the Zicsr and Zifencei
578           extensions.
579
580 config TOOLCHAIN_NEEDS_OLD_ISA_SPEC
581         def_bool y
582         depends on TOOLCHAIN_NEEDS_EXPLICIT_ZICSR_ZIFENCEI
583         # https://github.com/llvm/llvm-project/commit/22e199e6afb1263c943c0c0d4498694e15bf8a16
584         depends on CC_IS_CLANG && CLANG_VERSION < 170000
585         help
586           Certain versions of clang do not support zicsr and zifencei via -march
587           but newer versions of binutils require it for the reasons noted in the
588           help text of CONFIG_TOOLCHAIN_NEEDS_EXPLICIT_ZICSR_ZIFENCEI. This
589           option causes an older ISA spec compatible with these older versions
590           of clang to be passed to GAS, which has the same result as passing zicsr
591           and zifencei to -march.
592
593 config FPU
594         bool "FPU support"
595         default y
596         help
597           Say N here if you want to disable all floating-point related procedure
598           in the kernel.
599
600           If you don't know what to do here, say Y.
601
602 config IRQ_STACKS
603         bool "Independent irq & softirq stacks" if EXPERT
604         default y
605         select HAVE_IRQ_EXIT_ON_IRQ_STACK
606         select HAVE_SOFTIRQ_ON_OWN_STACK
607         help
608           Add independent irq & softirq stacks for percpu to prevent kernel stack
609           overflows. We may save some memory footprint by disabling IRQ_STACKS.
610
611 config THREAD_SIZE_ORDER
612         int "Kernel stack size (in power-of-two numbers of page size)" if VMAP_STACK && EXPERT
613         range 0 4
614         default 1 if 32BIT && !KASAN
615         default 3 if 64BIT && KASAN
616         default 2
617         help
618           Specify the Pages of thread stack size (from 4KB to 64KB), which also
619           affects irq stack size, which is equal to thread stack size.
620
621 endmenu # "Platform type"
622
623 menu "Kernel features"
624
625 source "kernel/Kconfig.hz"
626
627 config RISCV_SBI_V01
628         bool "SBI v0.1 support"
629         depends on RISCV_SBI
630         help
631           This config allows kernel to use SBI v0.1 APIs. This will be
632           deprecated in future once legacy M-mode software are no longer in use.
633
634 config RISCV_BOOT_SPINWAIT
635         bool "Spinwait booting method"
636         depends on SMP
637         default y if RISCV_SBI_V01 || RISCV_M_MODE
638         help
639           This enables support for booting Linux via spinwait method. In the
640           spinwait method, all cores randomly jump to Linux. One of the cores
641           gets chosen via lottery and all other keep spinning on a percpu
642           variable. This method cannot support CPU hotplug and sparse hartid
643           scheme. It should be only enabled for M-mode Linux or platforms relying
644           on older firmware without SBI HSM extension. All other platforms should
645           rely on ordered booting via SBI HSM extension which gets chosen
646           dynamically at runtime if the firmware supports it.
647
648           Since spinwait is incompatible with sparse hart IDs, it requires
649           NR_CPUS be large enough to contain the physical hart ID of the first
650           hart to enter Linux.
651
652           If unsure what to do here, say N.
653
654 config KEXEC
655         bool "Kexec system call"
656         depends on MMU
657         select HOTPLUG_CPU if SMP
658         select KEXEC_CORE
659         help
660           kexec is a system call that implements the ability to shutdown your
661           current kernel, and to start another kernel. It is like a reboot
662           but it is independent of the system firmware. And like a reboot
663           you can start any kernel with it, not just Linux.
664
665           The name comes from the similarity to the exec system call.
666
667 config KEXEC_FILE
668         bool "kexec file based systmem call"
669         depends on 64BIT && MMU
670         select HAVE_IMA_KEXEC if IMA
671         select KEXEC_CORE
672         select KEXEC_ELF
673         help
674           This is new version of kexec system call. This system call is
675           file based and takes file descriptors as system call argument
676           for kernel and initramfs as opposed to list of segments as
677           accepted by previous system call.
678
679           If you don't know what to do here, say Y.
680
681 config ARCH_HAS_KEXEC_PURGATORY
682         def_bool KEXEC_FILE
683         depends on CRYPTO=y
684         depends on CRYPTO_SHA256=y
685
686 config CRASH_DUMP
687         bool "Build kdump crash kernel"
688         help
689           Generate crash dump after being started by kexec. This should
690           be normally only set in special crash dump kernels which are
691           loaded in the main kernel with kexec-tools into a specially
692           reserved region and then later executed after a crash by
693           kdump/kexec.
694
695           For more details see Documentation/admin-guide/kdump/kdump.rst
696
697 config COMPAT
698         bool "Kernel support for 32-bit U-mode"
699         default 64BIT
700         depends on 64BIT && MMU
701         help
702           This option enables support for a 32-bit U-mode running under a 64-bit
703           kernel at S-mode. riscv32-specific components such as system calls,
704           the user helper functions (vdso), signal rt_frame functions and the
705           ptrace interface are handled appropriately by the kernel.
706
707           If you want to execute 32-bit userspace applications, say Y.
708
709 config RELOCATABLE
710         bool "Build a relocatable kernel"
711         depends on MMU && 64BIT && !XIP_KERNEL
712         help
713           This builds a kernel as a Position Independent Executable (PIE),
714           which retains all relocation metadata required to relocate the
715           kernel binary at runtime to a different virtual address than the
716           address it was linked at.
717           Since RISCV uses the RELA relocation format, this requires a
718           relocation pass at runtime even if the kernel is loaded at the
719           same address it was linked at.
720
721           If unsure, say N.
722
723 endmenu # "Kernel features"
724
725 menu "Boot options"
726
727 config CMDLINE
728         string "Built-in kernel command line"
729         help
730           For most platforms, the arguments for the kernel's command line
731           are provided at run-time, during boot. However, there are cases
732           where either no arguments are being provided or the provided
733           arguments are insufficient or even invalid.
734
735           When that occurs, it is possible to define a built-in command
736           line here and choose how the kernel should use it later on.
737
738 choice
739         prompt "Built-in command line usage" if CMDLINE != ""
740         default CMDLINE_FALLBACK
741         help
742           Choose how the kernel will handle the provided built-in command
743           line.
744
745 config CMDLINE_FALLBACK
746         bool "Use bootloader kernel arguments if available"
747         help
748           Use the built-in command line as fallback in case we get nothing
749           during boot. This is the default behaviour.
750
751 config CMDLINE_EXTEND
752         bool "Extend bootloader kernel arguments"
753         help
754           The command-line arguments provided during boot will be
755           appended to the built-in command line. This is useful in
756           cases where the provided arguments are insufficient and
757           you don't want to or cannot modify them.
758
759 config CMDLINE_FORCE
760         bool "Always use the default kernel command string"
761         help
762           Always use the built-in command line, even if we get one during
763           boot. This is useful in case you need to override the provided
764           command line on systems where you don't have or want control
765           over it.
766
767 endchoice
768
769 config EFI_STUB
770         bool
771
772 config EFI
773         bool "UEFI runtime support"
774         depends on OF && !XIP_KERNEL
775         depends on MMU
776         default y
777         select ARCH_SUPPORTS_ACPI if 64BIT
778         select EFI_GENERIC_STUB
779         select EFI_PARAMS_FROM_FDT
780         select EFI_RUNTIME_WRAPPERS
781         select EFI_STUB
782         select LIBFDT
783         select RISCV_ISA_C
784         select UCS2_STRING
785         help
786           This option provides support for runtime services provided
787           by UEFI firmware (such as non-volatile variables, realtime
788           clock, and platform reset). A UEFI stub is also provided to
789           allow the kernel to be booted as an EFI application. This
790           is only useful on systems that have UEFI firmware.
791
792 config CC_HAVE_STACKPROTECTOR_TLS
793         def_bool $(cc-option,-mstack-protector-guard=tls -mstack-protector-guard-reg=tp -mstack-protector-guard-offset=0)
794
795 config STACKPROTECTOR_PER_TASK
796         def_bool y
797         depends on !RANDSTRUCT
798         depends on STACKPROTECTOR && CC_HAVE_STACKPROTECTOR_TLS
799
800 config PHYS_RAM_BASE_FIXED
801         bool "Explicitly specified physical RAM address"
802         depends on NONPORTABLE
803         default n
804
805 config PHYS_RAM_BASE
806         hex "Platform Physical RAM address"
807         depends on PHYS_RAM_BASE_FIXED
808         default "0x80000000"
809         help
810           This is the physical address of RAM in the system. It has to be
811           explicitly specified to run early relocations of read-write data
812           from flash to RAM.
813
814 config XIP_KERNEL
815         bool "Kernel Execute-In-Place from ROM"
816         depends on MMU && SPARSEMEM && NONPORTABLE
817         # This prevents XIP from being enabled by all{yes,mod}config, which
818         # fail to build since XIP doesn't support large kernels.
819         depends on !COMPILE_TEST
820         select PHYS_RAM_BASE_FIXED
821         help
822           Execute-In-Place allows the kernel to run from non-volatile storage
823           directly addressable by the CPU, such as NOR flash. This saves RAM
824           space since the text section of the kernel is not loaded from flash
825           to RAM.  Read-write sections, such as the data section and stack,
826           are still copied to RAM.  The XIP kernel is not compressed since
827           it has to run directly from flash, so it will take more space to
828           store it.  The flash address used to link the kernel object files,
829           and for storing it, is configuration dependent. Therefore, if you
830           say Y here, you must know the proper physical address where to
831           store the kernel image depending on your own flash memory usage.
832
833           Also note that the make target becomes "make xipImage" rather than
834           "make zImage" or "make Image".  The final kernel binary to put in
835           ROM memory will be arch/riscv/boot/xipImage.
836
837           SPARSEMEM is required because the kernel text and rodata that are
838           flash resident are not backed by memmap, then any attempt to get
839           a struct page on those regions will trigger a fault.
840
841           If unsure, say N.
842
843 config XIP_PHYS_ADDR
844         hex "XIP Kernel Physical Location"
845         depends on XIP_KERNEL
846         default "0x21000000"
847         help
848           This is the physical address in your flash memory the kernel will
849           be linked for and stored to.  This address is dependent on your
850           own flash usage.
851
852 config RISCV_ISA_FALLBACK
853         bool "Permit falling back to parsing riscv,isa for extension support by default"
854         default y
855         help
856           Parsing the "riscv,isa" devicetree property has been deprecated and
857           replaced by a list of explicitly defined strings. For compatibility
858           with existing platforms, the kernel will fall back to parsing the
859           "riscv,isa" property if the replacements are not found.
860
861           Selecting N here will result in a kernel that does not use the
862           fallback, unless the commandline "riscv_isa_fallback" parameter is
863           present.
864
865           Please see the dt-binding, located at
866           Documentation/devicetree/bindings/riscv/extensions.yaml for details
867           on the replacement properties, "riscv,isa-base" and
868           "riscv,isa-extensions".
869
870 endmenu # "Boot options"
871
872 config BUILTIN_DTB
873         bool
874         depends on OF && NONPORTABLE
875         default y if XIP_KERNEL
876
877 config PORTABLE
878         bool
879         default !NONPORTABLE
880         select EFI
881         select MMU
882         select OF
883
884 menu "Power management options"
885
886 source "kernel/power/Kconfig"
887
888 # Hibernation is only possible on systems where the SBI implementation has
889 # marked its reserved memory as not accessible from, or does not run
890 # from the same memory as, Linux
891 config ARCH_HIBERNATION_POSSIBLE
892         def_bool NONPORTABLE
893
894 config ARCH_HIBERNATION_HEADER
895         def_bool HIBERNATION
896
897 config ARCH_SUSPEND_POSSIBLE
898         def_bool y
899
900 endmenu # "Power management options"
901
902 menu "CPU Power Management"
903
904 source "drivers/cpuidle/Kconfig"
905
906 source "drivers/cpufreq/Kconfig"
907
908 endmenu # "CPU Power Management"
909
910 source "arch/riscv/kvm/Kconfig"
911
912 source "drivers/acpi/Kconfig"