xref: /linux/arch/riscv/Kconfig (revision 119b1e61a769aa98e68599f44721661a4d8c55f3)
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
7config 64BIT
8	bool
9
10config 32BIT
11	bool
12
13config RISCV
14	def_bool y
15	select ACPI_GENERIC_GSI if ACPI
16	select ACPI_MCFG if (ACPI && PCI)
17	select ACPI_PPTT if ACPI
18	select ACPI_REDUCED_HARDWARE_ONLY if ACPI
19	select ACPI_SPCR_TABLE if ACPI
20	select ARCH_DMA_DEFAULT_COHERENT
21	select ARCH_ENABLE_HUGEPAGE_MIGRATION if HUGETLB_PAGE && MIGRATION
22	select ARCH_ENABLE_MEMORY_HOTPLUG if SPARSEMEM_VMEMMAP
23	select ARCH_ENABLE_MEMORY_HOTREMOVE if MEMORY_HOTPLUG
24	select ARCH_ENABLE_SPLIT_PMD_PTLOCK if PGTABLE_LEVELS > 2
25	select ARCH_ENABLE_THP_MIGRATION if TRANSPARENT_HUGEPAGE
26	select ARCH_HAS_BINFMT_FLAT
27	select ARCH_HAS_CRC32 if RISCV_ISA_ZBC
28	select ARCH_HAS_CRC64 if 64BIT && RISCV_ISA_ZBC
29	select ARCH_HAS_CRC_T10DIF if RISCV_ISA_ZBC
30	select ARCH_HAS_CURRENT_STACK_POINTER
31	select ARCH_HAS_DEBUG_VIRTUAL if MMU
32	select ARCH_HAS_DEBUG_VM_PGTABLE
33	select ARCH_HAS_DEBUG_WX
34	select ARCH_HAS_FAST_MULTIPLIER
35	select ARCH_HAS_FORTIFY_SOURCE
36	select ARCH_HAS_GCOV_PROFILE_ALL
37	select ARCH_HAS_GIGANTIC_PAGE
38	select ARCH_HAS_HW_PTE_YOUNG
39	select ARCH_HAS_KCOV
40	select ARCH_HAS_KERNEL_FPU_SUPPORT if 64BIT && FPU
41	select ARCH_HAS_MEMBARRIER_CALLBACKS
42	select ARCH_HAS_MEMBARRIER_SYNC_CORE
43	select ARCH_HAS_MMIOWB
44	select ARCH_HAS_NON_OVERLAPPING_ADDRESS_SPACE
45	select ARCH_HAS_PMEM_API
46	select ARCH_HAS_PREEMPT_LAZY
47	select ARCH_HAS_PREPARE_SYNC_CORE_CMD
48	select ARCH_HAS_PTDUMP if MMU
49	select ARCH_HAS_PTE_DEVMAP if 64BIT && MMU
50	select ARCH_HAS_PTE_SPECIAL
51	select ARCH_HAS_SET_DIRECT_MAP if MMU
52	select ARCH_HAS_SET_MEMORY if MMU
53	select ARCH_HAS_STRICT_KERNEL_RWX if MMU && !XIP_KERNEL
54	select ARCH_HAS_STRICT_MODULE_RWX if MMU && !XIP_KERNEL
55	select ARCH_HAS_SYNC_CORE_BEFORE_USERMODE
56	select ARCH_HAS_SYSCALL_WRAPPER
57	select ARCH_HAS_TICK_BROADCAST if GENERIC_CLOCKEVENTS_BROADCAST
58	select ARCH_HAS_UBSAN
59	select ARCH_HAS_VDSO_ARCH_DATA if GENERIC_VDSO_DATA_STORE
60	select ARCH_KEEP_MEMBLOCK if ACPI
61	select ARCH_MHP_MEMMAP_ON_MEMORY_ENABLE	if 64BIT && MMU
62	select ARCH_OPTIONAL_KERNEL_RWX if ARCH_HAS_STRICT_KERNEL_RWX
63	select ARCH_OPTIONAL_KERNEL_RWX_DEFAULT
64	select ARCH_STACKWALK
65	select ARCH_SUPPORTS_ATOMIC_RMW
66	select ARCH_SUPPORTS_CFI_CLANG
67	select ARCH_SUPPORTS_DEBUG_PAGEALLOC if MMU
68	select ARCH_SUPPORTS_HUGE_PFNMAP if TRANSPARENT_HUGEPAGE
69	select ARCH_SUPPORTS_HUGETLBFS if MMU
70	# LLD >= 14: https://github.com/llvm/llvm-project/issues/50505
71	select ARCH_SUPPORTS_LTO_CLANG if LLD_VERSION >= 140000
72	select ARCH_SUPPORTS_LTO_CLANG_THIN if LLD_VERSION >= 140000
73	select ARCH_SUPPORTS_MSEAL_SYSTEM_MAPPINGS if 64BIT && MMU
74	select ARCH_SUPPORTS_PAGE_TABLE_CHECK if MMU
75	select ARCH_SUPPORTS_PER_VMA_LOCK if MMU
76	select ARCH_SUPPORTS_RT
77	select ARCH_SUPPORTS_SHADOW_CALL_STACK if HAVE_SHADOW_CALL_STACK
78	select ARCH_USE_CMPXCHG_LOCKREF if 64BIT
79	select ARCH_USE_MEMTEST
80	select ARCH_USE_QUEUED_RWLOCKS
81	select ARCH_USE_SYM_ANNOTATIONS
82	select ARCH_USES_CFI_TRAPS if CFI_CLANG
83	select ARCH_WANT_BATCHED_UNMAP_TLB_FLUSH if MMU
84	select ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT if MMU
85	select ARCH_WANT_FRAME_POINTERS
86	select ARCH_WANT_GENERAL_HUGETLB if !RISCV_ISA_SVNAPOT
87	select ARCH_WANT_HUGE_PMD_SHARE if 64BIT
88	select ARCH_WANT_LD_ORPHAN_WARN if !XIP_KERNEL
89	select ARCH_WANT_OPTIMIZE_DAX_VMEMMAP
90	select ARCH_WANT_OPTIMIZE_HUGETLB_VMEMMAP
91	select ARCH_WANTS_NO_INSTR
92	select ARCH_WANTS_THP_SWAP if HAVE_ARCH_TRANSPARENT_HUGEPAGE
93	select ARCH_WEAK_RELEASE_ACQUIRE if ARCH_USE_QUEUED_SPINLOCKS
94	select BINFMT_FLAT_NO_DATA_START_OFFSET if !MMU
95	select BUILDTIME_TABLE_SORT if MMU
96	select CLINT_TIMER if RISCV_M_MODE
97	select CLONE_BACKWARDS
98	select COMMON_CLK
99	select CPU_PM if CPU_IDLE || HIBERNATION || SUSPEND
100	select EDAC_SUPPORT
101	select FRAME_POINTER if PERF_EVENTS || (FUNCTION_TRACER && !DYNAMIC_FTRACE)
102	select FTRACE_MCOUNT_USE_PATCHABLE_FUNCTION_ENTRY if DYNAMIC_FTRACE
103	select FUNCTION_ALIGNMENT_8B if DYNAMIC_FTRACE_WITH_CALL_OPS
104	select GENERIC_ARCH_TOPOLOGY
105	select GENERIC_ATOMIC64 if !64BIT
106	select GENERIC_CLOCKEVENTS_BROADCAST if SMP
107	select GENERIC_CPU_DEVICES
108	select GENERIC_CPU_VULNERABILITIES
109	select GENERIC_EARLY_IOREMAP
110	select GENERIC_ENTRY
111	select GENERIC_GETTIMEOFDAY if HAVE_GENERIC_VDSO
112	select GENERIC_IDLE_POLL_SETUP
113	select GENERIC_IOREMAP if MMU
114	select GENERIC_IRQ_IPI if SMP
115	select GENERIC_IRQ_IPI_MUX if SMP
116	select GENERIC_IRQ_MULTI_HANDLER
117	select GENERIC_IRQ_SHOW
118	select GENERIC_IRQ_SHOW_LEVEL
119	select GENERIC_LIB_DEVMEM_IS_ALLOWED
120	select GENERIC_PENDING_IRQ if SMP
121	select GENERIC_PCI_IOMAP
122	select GENERIC_SCHED_CLOCK
123	select GENERIC_SMP_IDLE_THREAD
124	select GENERIC_TIME_VSYSCALL if MMU && 64BIT
125	select GENERIC_VDSO_DATA_STORE if MMU
126	select GENERIC_VDSO_TIME_NS if HAVE_GENERIC_VDSO
127	select HARDIRQS_SW_RESEND
128	select HAS_IOPORT if MMU
129	select HAVE_ALIGNED_STRUCT_PAGE
130	select HAVE_ARCH_AUDITSYSCALL
131	select HAVE_ARCH_HUGE_VMALLOC if HAVE_ARCH_HUGE_VMAP
132	select HAVE_ARCH_HUGE_VMAP if MMU && 64BIT
133	select HAVE_ARCH_JUMP_LABEL if !XIP_KERNEL
134	select HAVE_ARCH_JUMP_LABEL_RELATIVE if !XIP_KERNEL
135	select HAVE_ARCH_KASAN if MMU && 64BIT
136	select HAVE_ARCH_KASAN_VMALLOC if MMU && 64BIT
137	select HAVE_ARCH_KFENCE if MMU && 64BIT
138	select HAVE_ARCH_KGDB if !XIP_KERNEL
139	select HAVE_ARCH_KGDB_QXFER_PKT
140	select HAVE_ARCH_MMAP_RND_BITS if MMU
141	select HAVE_ARCH_MMAP_RND_COMPAT_BITS if COMPAT
142	select HAVE_ARCH_RANDOMIZE_KSTACK_OFFSET
143	select HAVE_ARCH_SECCOMP_FILTER
144	select HAVE_ARCH_STACKLEAK
145	select HAVE_ARCH_THREAD_STRUCT_WHITELIST
146	select HAVE_ARCH_TRACEHOOK
147	select HAVE_ARCH_TRANSPARENT_HUGEPAGE if 64BIT && MMU
148	select HAVE_ARCH_TRANSPARENT_HUGEPAGE_PUD if 64BIT && MMU
149	select HAVE_ARCH_USERFAULTFD_MINOR if 64BIT && USERFAULTFD
150	select HAVE_ARCH_VMAP_STACK if MMU && 64BIT
151	select HAVE_ASM_MODVERSIONS
152	select HAVE_CONTEXT_TRACKING_USER
153	select HAVE_DEBUG_KMEMLEAK
154	select HAVE_DMA_CONTIGUOUS if MMU
155	select HAVE_DYNAMIC_FTRACE if !XIP_KERNEL && MMU && (CLANG_SUPPORTS_DYNAMIC_FTRACE || GCC_SUPPORTS_DYNAMIC_FTRACE)
156	select FUNCTION_ALIGNMENT_4B if HAVE_DYNAMIC_FTRACE && RISCV_ISA_C
157	select HAVE_DYNAMIC_FTRACE_WITH_DIRECT_CALLS if HAVE_DYNAMIC_FTRACE_WITH_CALL_OPS
158	select HAVE_DYNAMIC_FTRACE_WITH_CALL_OPS if (DYNAMIC_FTRACE_WITH_ARGS && !CFI_CLANG)
159	select HAVE_DYNAMIC_FTRACE_WITH_ARGS if HAVE_DYNAMIC_FTRACE
160	select HAVE_FTRACE_GRAPH_FUNC
161	select HAVE_FTRACE_MCOUNT_RECORD if !XIP_KERNEL
162	select HAVE_FUNCTION_GRAPH_TRACER if HAVE_DYNAMIC_FTRACE_WITH_ARGS
163	select HAVE_FUNCTION_GRAPH_FREGS
164	select HAVE_FUNCTION_TRACER if !XIP_KERNEL
165	select HAVE_EBPF_JIT if MMU
166	select HAVE_GUP_FAST if MMU
167	select HAVE_FUNCTION_ARG_ACCESS_API
168	select HAVE_FUNCTION_ERROR_INJECTION
169	select HAVE_GCC_PLUGINS
170	select HAVE_GENERIC_VDSO if MMU && 64BIT
171	select HAVE_IRQ_TIME_ACCOUNTING
172	select HAVE_KERNEL_BZIP2 if !XIP_KERNEL && !EFI_ZBOOT
173	select HAVE_KERNEL_GZIP if !XIP_KERNEL && !EFI_ZBOOT
174	select HAVE_KERNEL_LZ4 if !XIP_KERNEL && !EFI_ZBOOT
175	select HAVE_KERNEL_LZMA if !XIP_KERNEL && !EFI_ZBOOT
176	select HAVE_KERNEL_LZO if !XIP_KERNEL && !EFI_ZBOOT
177	select HAVE_KERNEL_UNCOMPRESSED if !XIP_KERNEL && !EFI_ZBOOT
178	select HAVE_KERNEL_ZSTD if !XIP_KERNEL && !EFI_ZBOOT
179	select HAVE_KERNEL_XZ if !XIP_KERNEL && !EFI_ZBOOT
180	select HAVE_KPROBES if !XIP_KERNEL
181	select HAVE_KRETPROBES if !XIP_KERNEL
182	# https://github.com/ClangBuiltLinux/linux/issues/1881
183	select HAVE_LD_DEAD_CODE_DATA_ELIMINATION if !LD_IS_LLD
184	select HAVE_MOVE_PMD
185	select HAVE_MOVE_PUD
186	select HAVE_PAGE_SIZE_4KB
187	select HAVE_PCI
188	select HAVE_PERF_EVENTS
189	select HAVE_PERF_REGS
190	select HAVE_PERF_USER_STACK_DUMP
191	select HAVE_POSIX_CPU_TIMERS_TASK_WORK
192	select HAVE_PREEMPT_DYNAMIC_KEY if !XIP_KERNEL
193	select HAVE_REGS_AND_STACK_ACCESS_API
194	select HAVE_RETHOOK if !XIP_KERNEL
195	select HAVE_RSEQ
196	select HAVE_RUST if RUSTC_SUPPORTS_RISCV && CC_IS_CLANG
197	select HAVE_SAMPLE_FTRACE_DIRECT
198	select HAVE_SAMPLE_FTRACE_DIRECT_MULTI
199	select HAVE_STACKPROTECTOR
200	select HAVE_SYSCALL_TRACEPOINTS
201	select HOTPLUG_CORE_SYNC_DEAD if HOTPLUG_CPU
202	select IRQ_DOMAIN
203	select IRQ_FORCED_THREADING
204	select KASAN_VMALLOC if KASAN
205	select LOCK_MM_AND_FIND_VMA
206	select MMU_GATHER_RCU_TABLE_FREE if SMP && MMU
207	select MODULES_USE_ELF_RELA if MODULES
208	select OF
209	select OF_EARLY_FLATTREE
210	select OF_IRQ
211	select PCI_DOMAINS_GENERIC if PCI
212	select PCI_ECAM if (ACPI && PCI)
213	select PCI_MSI if PCI
214	select RELOCATABLE if !MMU && !PHYS_RAM_BASE_FIXED
215	select RISCV_ALTERNATIVE if !XIP_KERNEL
216	select RISCV_APLIC
217	select RISCV_IMSIC
218	select RISCV_INTC
219	select RISCV_TIMER if RISCV_SBI
220	select SIFIVE_PLIC
221	select SPARSE_IRQ
222	select SYSCTL_EXCEPTION_TRACE
223	select THREAD_INFO_IN_TASK
224	select TRACE_IRQFLAGS_SUPPORT
225	select UACCESS_MEMCPY if !MMU
226	select VDSO_GETRANDOM if HAVE_GENERIC_VDSO
227	select USER_STACKTRACE_SUPPORT
228	select ZONE_DMA32 if 64BIT
229
230config RUSTC_SUPPORTS_RISCV
231	def_bool y
232	depends on 64BIT
233	# Shadow call stack requires rustc version 1.82+ due to use of the
234	# -Zsanitizer=shadow-call-stack flag.
235	depends on !SHADOW_CALL_STACK || RUSTC_VERSION >= 108200
236
237config CLANG_SUPPORTS_DYNAMIC_FTRACE
238	def_bool CC_IS_CLANG
239	# https://github.com/ClangBuiltLinux/linux/issues/1817
240	depends on AS_IS_GNU || (AS_IS_LLVM && (LD_IS_LLD || LD_VERSION >= 23600))
241
242config GCC_SUPPORTS_DYNAMIC_FTRACE
243	def_bool CC_IS_GCC
244	depends on $(cc-option,-fpatchable-function-entry=8)
245	depends on CC_HAS_MIN_FUNCTION_ALIGNMENT || !RISCV_ISA_C
246
247config HAVE_SHADOW_CALL_STACK
248	def_bool $(cc-option,-fsanitize=shadow-call-stack)
249	# https://github.com/riscv-non-isa/riscv-elf-psabi-doc/commit/a484e843e6eeb51f0cb7b8819e50da6d2444d769
250	depends on $(ld-option,--no-relax-gp)
251
252config RISCV_USE_LINKER_RELAXATION
253	def_bool y
254	# https://github.com/llvm/llvm-project/commit/6611d58f5bbcbec77262d392e2923e1d680f6985
255	depends on !LD_IS_LLD || LLD_VERSION >= 150000
256
257# https://github.com/llvm/llvm-project/commit/bbc0f99f3bc96f1db16f649fc21dd18e5b0918f6
258config ARCH_HAS_BROKEN_DWARF5
259	def_bool y
260	depends on RISCV_USE_LINKER_RELAXATION
261	# https://github.com/llvm/llvm-project/commit/1df5ea29b43690b6622db2cad7b745607ca4de6a
262	depends on AS_IS_LLVM && AS_VERSION < 180000
263	# https://github.com/llvm/llvm-project/commit/7ffabb61a5569444b5ac9322e22e5471cc5e4a77
264	depends on LD_IS_LLD && LLD_VERSION < 180000
265
266config ARCH_MMAP_RND_BITS_MIN
267	default 18 if 64BIT
268	default 8
269
270config ARCH_MMAP_RND_COMPAT_BITS_MIN
271	default 8
272
273# max bits determined by the following formula:
274#  VA_BITS - PAGE_SHIFT - 3
275config ARCH_MMAP_RND_BITS_MAX
276	default 24 if 64BIT # SV39 based
277	default 17
278
279config ARCH_MMAP_RND_COMPAT_BITS_MAX
280	default 17
281
282# set if we run in machine mode, cleared if we run in supervisor mode
283config RISCV_M_MODE
284	bool "Build a kernel that runs in machine mode"
285	depends on !MMU
286	default y
287	help
288	  Select this option if you want to run the kernel in M-mode,
289	  without the assistance of any other firmware.
290
291# set if we are running in S-mode and can use SBI calls
292config RISCV_SBI
293	bool
294	depends on !RISCV_M_MODE
295	default y
296
297config MMU
298	bool "MMU-based Paged Memory Management Support"
299	default y
300	help
301	  Select if you want MMU-based virtualised addressing space
302	  support by paged memory management. If unsure, say 'Y'.
303
304config KASAN_SHADOW_OFFSET
305	hex
306	depends on KASAN_GENERIC
307	default 0xdfffffff00000000 if 64BIT
308	default 0xffffffff if 32BIT
309
310config ARCH_FLATMEM_ENABLE
311	def_bool !NUMA
312
313config ARCH_SPARSEMEM_ENABLE
314	def_bool y
315	depends on MMU
316	select SPARSEMEM_STATIC if 32BIT && SPARSEMEM
317	select SPARSEMEM_VMEMMAP_ENABLE if 64BIT
318
319config ARCH_SELECT_MEMORY_MODEL
320	def_bool ARCH_SPARSEMEM_ENABLE
321
322config ARCH_SUPPORTS_UPROBES
323	def_bool y
324
325config STACKTRACE_SUPPORT
326	def_bool y
327
328config GENERIC_BUG
329	def_bool y
330	depends on BUG
331	select GENERIC_BUG_RELATIVE_POINTERS if 64BIT
332
333config GENERIC_BUG_RELATIVE_POINTERS
334	bool
335
336config GENERIC_CALIBRATE_DELAY
337	def_bool y
338
339config GENERIC_CSUM
340	def_bool y
341
342config GENERIC_HWEIGHT
343	def_bool y
344
345config FIX_EARLYCON_MEM
346	def_bool MMU
347
348config ILLEGAL_POINTER_VALUE
349	hex
350	default 0 if 32BIT
351	default 0xdead000000000000 if 64BIT
352
353config PGTABLE_LEVELS
354	int
355	default 5 if 64BIT
356	default 2
357
358config LOCKDEP_SUPPORT
359	def_bool y
360
361config RISCV_DMA_NONCOHERENT
362	bool
363	select ARCH_HAS_DMA_PREP_COHERENT
364	select ARCH_HAS_SETUP_DMA_OPS
365	select ARCH_HAS_SYNC_DMA_FOR_CPU
366	select ARCH_HAS_SYNC_DMA_FOR_DEVICE
367	select DMA_BOUNCE_UNALIGNED_KMALLOC if SWIOTLB
368
369config RISCV_NONSTANDARD_CACHE_OPS
370	bool
371	help
372	  This enables function pointer support for non-standard noncoherent
373	  systems to handle cache management.
374
375config AS_HAS_INSN
376	def_bool $(as-instr,.insn r 51$(comma) 0$(comma) 0$(comma) t0$(comma) t0$(comma) zero)
377
378config AS_HAS_OPTION_ARCH
379	# https://github.com/llvm/llvm-project/commit/9e8ed3403c191ab9c4903e8eeb8f732ff8a43cb4
380	def_bool y
381	depends on $(as-instr, .option arch$(comma) +m)
382
383source "arch/riscv/Kconfig.socs"
384source "arch/riscv/Kconfig.errata"
385
386menu "Platform type"
387
388config NONPORTABLE
389	bool "Allow configurations that result in non-portable kernels"
390	help
391	  RISC-V kernel binaries are compatible between all known systems
392	  whenever possible, but there are some use cases that can only be
393	  satisfied by configurations that result in kernel binaries that are
394	  not portable between systems.
395
396	  Selecting N does not guarantee kernels will be portable to all known
397	  systems.  Selecting any of the options guarded by NONPORTABLE will
398	  result in kernel binaries that are unlikely to be portable between
399	  systems.
400
401	  If unsure, say N.
402
403choice
404	prompt "Base ISA"
405	default ARCH_RV64I
406	help
407	  This selects the base ISA that this kernel will target and must match
408	  the target platform.
409
410config ARCH_RV32I
411	bool "RV32I"
412	depends on NONPORTABLE
413	select 32BIT
414	select GENERIC_LIB_ASHLDI3
415	select GENERIC_LIB_ASHRDI3
416	select GENERIC_LIB_LSHRDI3
417	select GENERIC_LIB_UCMPDI2
418
419config ARCH_RV64I
420	bool "RV64I"
421	select 64BIT
422	select ARCH_SUPPORTS_INT128 if CC_HAS_INT128
423	select SWIOTLB if MMU
424
425endchoice
426
427# We must be able to map all physical memory into the kernel, but the compiler
428# is still a bit more efficient when generating code if it's setup in a manner
429# such that it can only map 2GiB of memory.
430choice
431	prompt "Kernel Code Model"
432	default CMODEL_MEDLOW if 32BIT
433	default CMODEL_MEDANY if 64BIT
434
435	config CMODEL_MEDLOW
436		bool "medium low code model"
437	config CMODEL_MEDANY
438		bool "medium any code model"
439endchoice
440
441config MODULE_SECTIONS
442	bool
443	select HAVE_MOD_ARCH_SPECIFIC
444
445config SMP
446	bool "Symmetric Multi-Processing"
447	help
448	  This enables support for systems with more than one CPU.  If
449	  you say N here, the kernel will run on single and
450	  multiprocessor machines, but will use only one CPU of a
451	  multiprocessor machine. If you say Y here, the kernel will run
452	  on many, but not all, single processor machines. On a single
453	  processor machine, the kernel will run faster if you say N
454	  here.
455
456	  If you don't know what to do here, say N.
457
458config SCHED_MC
459	bool "Multi-core scheduler support"
460	depends on SMP
461	help
462	  Multi-core scheduler support improves the CPU scheduler's decision
463	  making when dealing with multi-core CPU chips at a cost of slightly
464	  increased overhead in some places. If unsure say N here.
465
466config NR_CPUS
467	int "Maximum number of CPUs (2-512)"
468	depends on SMP
469	range 2 512 if !RISCV_SBI_V01
470	range 2 32 if RISCV_SBI_V01 && 32BIT
471	range 2 64 if RISCV_SBI_V01 && 64BIT
472	default "32" if 32BIT
473	default "64" if 64BIT
474
475config HOTPLUG_CPU
476	bool "Support for hot-pluggable CPUs"
477	depends on SMP
478	select GENERIC_IRQ_MIGRATION
479	help
480
481	  Say Y here to experiment with turning CPUs off and on.  CPUs
482	  can be controlled through /sys/devices/system/cpu.
483
484	  Say N if you want to disable CPU hotplug.
485
486choice
487	prompt "CPU Tuning"
488	default TUNE_GENERIC
489
490config TUNE_GENERIC
491	bool "generic"
492
493endchoice
494
495# Common NUMA Features
496config NUMA
497	bool "NUMA Memory Allocation and Scheduler Support"
498	depends on SMP && MMU
499	select ARCH_SUPPORTS_NUMA_BALANCING
500	select GENERIC_ARCH_NUMA
501	select HAVE_SETUP_PER_CPU_AREA
502	select NEED_PER_CPU_EMBED_FIRST_CHUNK
503	select NEED_PER_CPU_PAGE_FIRST_CHUNK
504	select OF_NUMA
505	select USE_PERCPU_NUMA_NODE_ID
506	help
507	  Enable NUMA (Non-Uniform Memory Access) support.
508
509	  The kernel will try to allocate memory used by a CPU on the
510	  local memory of the CPU and add some more NUMA awareness to the kernel.
511
512config NODES_SHIFT
513	int "Maximum NUMA Nodes (as a power of 2)"
514	range 1 10
515	default "2"
516	depends on NUMA
517	help
518	  Specify the maximum number of NUMA Nodes available on the target
519	  system.  Increases memory reserved to accommodate various tables.
520
521choice
522	prompt "RISC-V spinlock type"
523	default RISCV_COMBO_SPINLOCKS
524
525config RISCV_TICKET_SPINLOCKS
526	bool "Using ticket spinlock"
527
528config RISCV_QUEUED_SPINLOCKS
529	bool "Using queued spinlock"
530	depends on SMP && MMU && NONPORTABLE
531	select ARCH_USE_QUEUED_SPINLOCKS
532	help
533	  The queued spinlock implementation requires the forward progress
534	  guarantee of cmpxchg()/xchg() atomic operations: CAS with Zabha or
535	  LR/SC with Ziccrse provide such guarantee.
536
537	  Select this if and only if Zabha or Ziccrse is available on your
538	  platform, RISCV_QUEUED_SPINLOCKS must not be selected for platforms
539	  without one of those extensions.
540
541	  If unsure, select RISCV_COMBO_SPINLOCKS, which will use qspinlocks
542	  when supported and otherwise ticket spinlocks.
543
544config RISCV_COMBO_SPINLOCKS
545	bool "Using combo spinlock"
546	depends on SMP && MMU
547	select ARCH_USE_QUEUED_SPINLOCKS
548	help
549	  Embed both queued spinlock and ticket lock so that the spinlock
550	  implementation can be chosen at runtime.
551
552endchoice
553
554config RISCV_ALTERNATIVE
555	bool
556	depends on !XIP_KERNEL
557	help
558	  This Kconfig allows the kernel to automatically patch the
559	  erratum or cpufeature required by the execution platform at run
560	  time. The code patching overhead is minimal, as it's only done
561	  once at boot and once on each module load.
562
563config RISCV_ALTERNATIVE_EARLY
564	bool
565	depends on RISCV_ALTERNATIVE
566	help
567	  Allows early patching of the kernel for special errata
568
569config RISCV_ISA_C
570	bool "Emit compressed instructions when building Linux"
571	default y
572	help
573	  Adds "C" to the ISA subsets that the toolchain is allowed to emit
574	  when building Linux, which results in compressed instructions in the
575	  Linux binary. This option produces a kernel that will not run on
576	  systems that do not support compressed instructions.
577
578	  If you don't know what to do here, say Y.
579
580config RISCV_ISA_SUPM
581	bool "Supm extension for userspace pointer masking"
582	depends on 64BIT
583	default y
584	help
585	  Add support for pointer masking in userspace (Supm) when the
586	  underlying hardware extension (Smnpm or Ssnpm) is detected at boot.
587
588	  If this option is disabled, userspace will be unable to use
589	  the prctl(PR_{SET,GET}_TAGGED_ADDR_CTRL) API.
590
591config RISCV_ISA_SVNAPOT
592	bool "Svnapot extension support for supervisor mode NAPOT pages"
593	depends on 64BIT && MMU
594	depends on RISCV_ALTERNATIVE
595	default y
596	help
597	  Enable support for the Svnapot ISA-extension when it is detected
598	  at boot.
599
600	  The Svnapot extension is used to mark contiguous PTEs as a range
601	  of contiguous virtual-to-physical translations for a naturally
602	  aligned power-of-2 (NAPOT) granularity larger than the base 4KB page
603	  size. When HUGETLBFS is also selected this option unconditionally
604	  allocates some memory for each NAPOT page size supported by the kernel.
605	  When optimizing for low memory consumption and for platforms without
606	  the Svnapot extension, it may be better to say N here.
607
608	  If you don't know what to do here, say Y.
609
610config RISCV_ISA_SVPBMT
611	bool "Svpbmt extension support for supervisor mode page-based memory types"
612	depends on 64BIT && MMU
613	depends on RISCV_ALTERNATIVE
614	default y
615	help
616	   Add support for the Svpbmt ISA-extension (Supervisor-mode:
617	   page-based memory types) in the kernel when it is detected at boot.
618
619	   The memory type for a page contains a combination of attributes
620	   that indicate the cacheability, idempotency, and ordering
621	   properties for access to that page.
622
623	   The Svpbmt extension is only available on 64-bit cpus.
624
625	   If you don't know what to do here, say Y.
626
627config TOOLCHAIN_HAS_V
628	bool
629	default y
630	depends on !64BIT || $(cc-option,-mabi=lp64 -march=rv64imv)
631	depends on !32BIT || $(cc-option,-mabi=ilp32 -march=rv32imv)
632	depends on LLD_VERSION >= 140000 || LD_VERSION >= 23800
633	depends on AS_HAS_OPTION_ARCH
634
635config RISCV_ISA_V
636	bool "Vector extension support"
637	depends on TOOLCHAIN_HAS_V
638	depends on FPU
639	select DYNAMIC_SIGFRAME
640	default y
641	help
642	  Add support for the Vector extension when it is detected at boot.
643	  When this option is disabled, neither the kernel nor userspace may
644	  use vector procedures.
645
646	  If you don't know what to do here, say Y.
647
648config RISCV_ISA_V_DEFAULT_ENABLE
649	bool "Enable userspace Vector by default"
650	depends on RISCV_ISA_V
651	default y
652	help
653	  Say Y here if you want to enable Vector in userspace by default.
654	  Otherwise, userspace has to make explicit prctl() call to enable
655	  Vector, or enable it via the sysctl interface.
656
657	  If you don't know what to do here, say Y.
658
659config RISCV_ISA_V_UCOPY_THRESHOLD
660	int "Threshold size for vectorized user copies"
661	depends on RISCV_ISA_V
662	default 768
663	help
664	  Prefer using vectorized copy_to_user()/copy_from_user() when the
665	  workload size exceeds this value.
666
667config RISCV_ISA_V_PREEMPTIVE
668	bool "Run kernel-mode Vector with kernel preemption"
669	depends on PREEMPTION
670	depends on RISCV_ISA_V
671	default y
672	help
673	  Usually, in-kernel SIMD routines are run with preemption disabled.
674	  Functions which invoke long running SIMD thus must yield the core's
675	  vector unit to prevent blocking other tasks for too long.
676
677	  This config allows the kernel to run SIMD without explicitly disabling
678	  preemption. Enabling this config will result in higher memory consumption
679	  due to the allocation of per-task's kernel Vector context.
680
681config RISCV_ISA_ZAWRS
682	bool "Zawrs extension support for more efficient busy waiting"
683	depends on RISCV_ALTERNATIVE
684	default y
685	help
686	  The Zawrs extension defines instructions to be used in polling loops
687	  which allow a hart to enter a low-power state or to trap to the
688	  hypervisor while waiting on a store to a memory location. Enable the
689	  use of these instructions in the kernel when the Zawrs extension is
690	  detected at boot.
691
692config TOOLCHAIN_HAS_ZABHA
693	bool
694	default y
695	depends on !64BIT || $(cc-option,-mabi=lp64 -march=rv64ima_zabha)
696	depends on !32BIT || $(cc-option,-mabi=ilp32 -march=rv32ima_zabha)
697	depends on AS_HAS_OPTION_ARCH
698
699config RISCV_ISA_ZABHA
700	bool "Zabha extension support for atomic byte/halfword operations"
701	depends on TOOLCHAIN_HAS_ZABHA
702	depends on RISCV_ALTERNATIVE
703	default y
704	help
705	  Enable the use of the Zabha ISA-extension to implement kernel
706	  byte/halfword atomic memory operations when it is detected at boot.
707
708	  If you don't know what to do here, say Y.
709
710config TOOLCHAIN_HAS_ZACAS
711	bool
712	default y
713	depends on !64BIT || $(cc-option,-mabi=lp64 -march=rv64ima_zacas)
714	depends on !32BIT || $(cc-option,-mabi=ilp32 -march=rv32ima_zacas)
715	depends on AS_HAS_OPTION_ARCH
716
717config RISCV_ISA_ZACAS
718	bool "Zacas extension support for atomic CAS"
719	depends on TOOLCHAIN_HAS_ZACAS
720	depends on RISCV_ALTERNATIVE
721	default y
722	help
723	  Enable the use of the Zacas ISA-extension to implement kernel atomic
724	  cmpxchg operations when it is detected at boot.
725
726	  If you don't know what to do here, say Y.
727
728config TOOLCHAIN_HAS_ZBB
729	bool
730	default y
731	depends on !64BIT || $(cc-option,-mabi=lp64 -march=rv64ima_zbb)
732	depends on !32BIT || $(cc-option,-mabi=ilp32 -march=rv32ima_zbb)
733	depends on LLD_VERSION >= 150000 || LD_VERSION >= 23900
734	depends on AS_HAS_OPTION_ARCH
735
736# This symbol indicates that the toolchain supports all v1.0 vector crypto
737# extensions, including Zvk*, Zvbb, and Zvbc.  LLVM added all of these at once.
738# binutils added all except Zvkb, then added Zvkb.  So we just check for Zvkb.
739config TOOLCHAIN_HAS_VECTOR_CRYPTO
740	def_bool $(as-instr, .option arch$(comma) +v$(comma) +zvkb)
741	depends on AS_HAS_OPTION_ARCH
742
743config TOOLCHAIN_HAS_ZBA
744	bool
745	default y
746	depends on !64BIT || $(cc-option,-mabi=lp64 -march=rv64ima_zba)
747	depends on !32BIT || $(cc-option,-mabi=ilp32 -march=rv32ima_zba)
748	depends on LLD_VERSION >= 150000 || LD_VERSION >= 23900
749	depends on AS_HAS_OPTION_ARCH
750
751config RISCV_ISA_ZBA
752	bool "Zba extension support for bit manipulation instructions"
753	default y
754	help
755	   Add support for enabling optimisations in the kernel when the Zba
756	   extension is detected at boot.
757
758	   The Zba extension provides instructions to accelerate the generation
759	   of addresses that index into arrays of basic data types.
760
761	   If you don't know what to do here, say Y.
762
763config RISCV_ISA_ZBB
764	bool "Zbb extension support for bit manipulation instructions"
765	depends on RISCV_ALTERNATIVE
766	default y
767	help
768	   Add support for enabling optimisations in the kernel when the
769	   Zbb extension is detected at boot. Some optimisations may
770	   additionally depend on toolchain support for Zbb.
771
772	   The Zbb extension provides instructions to accelerate a number
773	   of bit-specific operations (count bit population, sign extending,
774	   bitrotation, etc).
775
776	   If you don't know what to do here, say Y.
777
778config TOOLCHAIN_HAS_ZBC
779	bool
780	default y
781	depends on !64BIT || $(cc-option,-mabi=lp64 -march=rv64ima_zbc)
782	depends on !32BIT || $(cc-option,-mabi=ilp32 -march=rv32ima_zbc)
783	depends on LLD_VERSION >= 150000 || LD_VERSION >= 23900
784	depends on AS_HAS_OPTION_ARCH
785
786config RISCV_ISA_ZBC
787	bool "Zbc extension support for carry-less multiplication instructions"
788	depends on TOOLCHAIN_HAS_ZBC
789	depends on MMU
790	depends on RISCV_ALTERNATIVE
791	default y
792	help
793	   Adds support to dynamically detect the presence of the Zbc
794	   extension (carry-less multiplication) and enable its usage.
795
796	   The Zbc extension could accelerate CRC (cyclic redundancy check)
797	   calculations.
798
799	   If you don't know what to do here, say Y.
800
801config TOOLCHAIN_HAS_ZBKB
802	bool
803	default y
804	depends on !64BIT || $(cc-option,-mabi=lp64 -march=rv64ima_zbkb)
805	depends on !32BIT || $(cc-option,-mabi=ilp32 -march=rv32ima_zbkb)
806	depends on LLD_VERSION >= 150000 || LD_VERSION >= 23900
807	depends on AS_HAS_OPTION_ARCH
808
809config RISCV_ISA_ZBKB
810	bool "Zbkb extension support for bit manipulation instructions"
811	depends on TOOLCHAIN_HAS_ZBKB
812	depends on RISCV_ALTERNATIVE
813	default y
814	help
815	   Adds support to dynamically detect the presence of the ZBKB
816	   extension (bit manipulation for cryptography) and enable its usage.
817
818	   The Zbkb extension provides instructions to accelerate a number
819	   of common cryptography operations (pack, zip, etc).
820
821	   If you don't know what to do here, say Y.
822
823config RISCV_ISA_ZICBOM
824	bool "Zicbom extension support for non-coherent DMA operation"
825	depends on MMU
826	depends on RISCV_ALTERNATIVE
827	default y
828	select RISCV_DMA_NONCOHERENT
829	select DMA_DIRECT_REMAP
830	help
831	   Add support for the Zicbom extension (Cache Block Management
832	   Operations) and enable its use in the kernel when it is detected
833	   at boot.
834
835	   The Zicbom extension can be used to handle for example
836	   non-coherent DMA support on devices that need it.
837
838	   If you don't know what to do here, say Y.
839
840config RISCV_ISA_ZICBOZ
841	bool "Zicboz extension support for faster zeroing of memory"
842	depends on RISCV_ALTERNATIVE
843	default y
844	help
845	   Enable the use of the Zicboz extension (cbo.zero instruction)
846	   in the kernel when it is detected at boot.
847
848	   The Zicboz extension is used for faster zeroing of memory.
849
850	   If you don't know what to do here, say Y.
851
852config RISCV_ISA_ZICBOP
853	bool "Zicbop extension support for cache block prefetch"
854	depends on MMU
855	depends on RISCV_ALTERNATIVE
856	default y
857	help
858	  Adds support to dynamically detect the presence of the ZICBOP
859	  extension (Cache Block Prefetch Operations) and enable its
860	  usage.
861
862	  The Zicbop extension can be used to prefetch cache blocks for
863	  read/write fetch.
864
865	  If you don't know what to do here, say Y.
866
867config TOOLCHAIN_NEEDS_EXPLICIT_ZICSR_ZIFENCEI
868	def_bool y
869	# https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=aed44286efa8ae8717a77d94b51ac3614e2ca6dc
870	# https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=98416dbb0a62579d4a7a4a76bab51b5b52fec2cd
871	depends on AS_IS_GNU && AS_VERSION >= 23600
872	help
873	  Binutils-2.38 and GCC-12.1.0 bumped the default ISA spec to the newer
874	  20191213 version, which moves some instructions from the I extension to
875	  the Zicsr and Zifencei extensions. This requires explicitly specifying
876	  Zicsr and Zifencei when binutils >= 2.38 or GCC >= 12.1.0. Zicsr
877	  and Zifencei are supported in binutils from version 2.36 onwards.
878	  To make life easier, and avoid forcing toolchains that default to a
879	  newer ISA spec to version 2.2, relax the check to binutils >= 2.36.
880	  For clang < 17 or GCC < 11.3.0, for which this is not possible or need
881	  special treatment, this is dealt with in TOOLCHAIN_NEEDS_OLD_ISA_SPEC.
882
883config TOOLCHAIN_NEEDS_OLD_ISA_SPEC
884	def_bool y
885	depends on TOOLCHAIN_NEEDS_EXPLICIT_ZICSR_ZIFENCEI
886	# https://github.com/llvm/llvm-project/commit/22e199e6afb1263c943c0c0d4498694e15bf8a16
887	# https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=d29f5d6ab513c52fd872f532c492e35ae9fd6671
888	depends on (CC_IS_CLANG && CLANG_VERSION < 170000) || (CC_IS_GCC && GCC_VERSION < 110300)
889	help
890	  Certain versions of clang and GCC do not support zicsr and zifencei via
891	  -march. This option causes an older ISA spec compatible with these older
892	  versions of clang and GCC to be passed to GAS, which has the same result
893	  as passing zicsr and zifencei to -march.
894
895config FPU
896	bool "FPU support"
897	default y
898	help
899	  Add support for floating point operations when an FPU is detected at
900	  boot. When this option is disabled, neither the kernel nor userspace
901	  may use the floating point unit.
902
903	  If you don't know what to do here, say Y.
904
905config IRQ_STACKS
906	bool "Independent irq & softirq stacks" if EXPERT
907	default y
908	select HAVE_IRQ_EXIT_ON_IRQ_STACK
909	select HAVE_SOFTIRQ_ON_OWN_STACK
910	help
911	  Add independent irq & softirq stacks for percpu to prevent kernel stack
912	  overflows. We may save some memory footprint by disabling IRQ_STACKS.
913
914config THREAD_SIZE_ORDER
915	int "Kernel stack size (in power-of-two numbers of page size)" if VMAP_STACK && EXPERT
916	range 0 4
917	default 1 if 32BIT
918	default 2
919	help
920	  Specify the Pages of thread stack size (from 4KB to 64KB), which also
921	  affects irq stack size, which is equal to thread stack size.
922
923config RISCV_MISALIGNED
924	bool
925	help
926	  Embed support for detecting and emulating misaligned
927	  scalar or vector loads and stores.
928
929config RISCV_SCALAR_MISALIGNED
930	bool
931	select RISCV_MISALIGNED
932	select SYSCTL_ARCH_UNALIGN_ALLOW
933	help
934	  Embed support for emulating misaligned loads and stores.
935
936config RISCV_VECTOR_MISALIGNED
937	bool
938	select RISCV_MISALIGNED
939	depends on RISCV_ISA_V
940	help
941	  Enable detecting support for vector misaligned loads and stores.
942
943choice
944	prompt "Unaligned Accesses Support"
945	default RISCV_PROBE_UNALIGNED_ACCESS
946	help
947	  This determines the level of support for unaligned accesses. This
948	  information is used by the kernel to perform optimizations. It is also
949	  exposed to user space via the hwprobe syscall. The hardware will be
950	  probed at boot by default.
951
952config RISCV_PROBE_UNALIGNED_ACCESS
953	bool "Probe for hardware unaligned access support"
954	select RISCV_SCALAR_MISALIGNED
955	help
956	  During boot, the kernel will run a series of tests to determine the
957	  speed of unaligned accesses. This probing will dynamically determine
958	  the speed of unaligned accesses on the underlying system. If unaligned
959	  memory accesses trap into the kernel as they are not supported by the
960	  system, the kernel will emulate the unaligned accesses to preserve the
961	  UABI.
962
963config RISCV_EMULATED_UNALIGNED_ACCESS
964	bool "Emulate unaligned access where system support is missing"
965	select RISCV_SCALAR_MISALIGNED
966	help
967	  If unaligned memory accesses trap into the kernel as they are not
968	  supported by the system, the kernel will emulate the unaligned
969	  accesses to preserve the UABI. When the underlying system does support
970	  unaligned accesses, the unaligned accesses are assumed to be slow.
971
972config RISCV_SLOW_UNALIGNED_ACCESS
973	bool "Assume the system supports slow unaligned memory accesses"
974	depends on NONPORTABLE
975	help
976	  Assume that the system supports slow unaligned memory accesses. The
977	  kernel and userspace programs may not be able to run at all on systems
978	  that do not support unaligned memory accesses.
979
980config RISCV_EFFICIENT_UNALIGNED_ACCESS
981	bool "Assume the system supports fast unaligned memory accesses"
982	depends on NONPORTABLE
983	select DCACHE_WORD_ACCESS if MMU
984	select HAVE_EFFICIENT_UNALIGNED_ACCESS
985	help
986	  Assume that the system supports fast unaligned memory accesses. When
987	  enabled, this option improves the performance of the kernel on such
988	  systems. However, the kernel and userspace programs will run much more
989	  slowly, or will not be able to run at all, on systems that do not
990	  support efficient unaligned memory accesses.
991
992endchoice
993
994choice
995	prompt "Vector unaligned Accesses Support"
996	depends on RISCV_ISA_V
997	default RISCV_PROBE_VECTOR_UNALIGNED_ACCESS
998	help
999	  This determines the level of support for vector unaligned accesses. This
1000	  information is used by the kernel to perform optimizations. It is also
1001	  exposed to user space via the hwprobe syscall. The hardware will be
1002	  probed at boot by default.
1003
1004config RISCV_PROBE_VECTOR_UNALIGNED_ACCESS
1005	bool "Probe speed of vector unaligned accesses"
1006	select RISCV_VECTOR_MISALIGNED
1007	depends on RISCV_ISA_V
1008	help
1009	  During boot, the kernel will run a series of tests to determine the
1010	  speed of vector unaligned accesses if they are supported. This probing
1011	  will dynamically determine the speed of vector unaligned accesses on
1012	  the underlying system if they are supported.
1013
1014config RISCV_SLOW_VECTOR_UNALIGNED_ACCESS
1015	bool "Assume the system supports slow vector unaligned memory accesses"
1016	depends on NONPORTABLE
1017	help
1018	  Assume that the system supports slow vector unaligned memory accesses. The
1019	  kernel and userspace programs may not be able to run at all on systems
1020	  that do not support unaligned memory accesses.
1021
1022config RISCV_EFFICIENT_VECTOR_UNALIGNED_ACCESS
1023	bool "Assume the system supports fast vector unaligned memory accesses"
1024	depends on NONPORTABLE
1025	help
1026	  Assume that the system supports fast vector unaligned memory accesses. When
1027	  enabled, this option improves the performance of the kernel on such
1028	  systems. However, the kernel and userspace programs will run much more
1029	  slowly, or will not be able to run at all, on systems that do not
1030	  support efficient unaligned memory accesses.
1031
1032endchoice
1033
1034source "arch/riscv/Kconfig.vendor"
1035
1036endmenu # "Platform type"
1037
1038menu "Kernel features"
1039
1040source "kernel/Kconfig.hz"
1041
1042config RISCV_SBI_V01
1043	bool "SBI v0.1 support"
1044	depends on RISCV_SBI
1045	help
1046	  This config allows kernel to use SBI v0.1 APIs. This will be
1047	  deprecated in future once legacy M-mode software are no longer in use.
1048
1049config RISCV_BOOT_SPINWAIT
1050	bool "Spinwait booting method"
1051	depends on SMP
1052	default y if RISCV_SBI_V01 || RISCV_M_MODE
1053	help
1054	  This enables support for booting Linux via spinwait method. In the
1055	  spinwait method, all cores randomly jump to Linux. One of the cores
1056	  gets chosen via lottery and all other keep spinning on a percpu
1057	  variable. This method cannot support CPU hotplug and sparse hartid
1058	  scheme. It should be only enabled for M-mode Linux or platforms relying
1059	  on older firmware without SBI HSM extension. All other platforms should
1060	  rely on ordered booting via SBI HSM extension which gets chosen
1061	  dynamically at runtime if the firmware supports it.
1062
1063	  Since spinwait is incompatible with sparse hart IDs, it requires
1064	  NR_CPUS be large enough to contain the physical hart ID of the first
1065	  hart to enter Linux.
1066
1067	  If unsure what to do here, say N.
1068
1069config ARCH_SUPPORTS_KEXEC
1070	def_bool y
1071
1072config ARCH_SELECTS_KEXEC
1073	def_bool y
1074	depends on KEXEC
1075	select HOTPLUG_CPU if SMP
1076
1077config ARCH_SUPPORTS_KEXEC_FILE
1078	def_bool 64BIT
1079
1080config ARCH_SELECTS_KEXEC_FILE
1081	def_bool y
1082	depends on KEXEC_FILE
1083	select HAVE_IMA_KEXEC if IMA
1084	select KEXEC_ELF
1085
1086config ARCH_SUPPORTS_KEXEC_PURGATORY
1087	def_bool ARCH_SUPPORTS_KEXEC_FILE
1088
1089config ARCH_SUPPORTS_CRASH_DUMP
1090	def_bool y
1091
1092config ARCH_DEFAULT_CRASH_DUMP
1093	def_bool y
1094
1095config ARCH_HAS_GENERIC_CRASHKERNEL_RESERVATION
1096	def_bool CRASH_RESERVE
1097
1098config COMPAT
1099	bool "Kernel support for 32-bit U-mode"
1100	default 64BIT
1101	depends on 64BIT && MMU
1102	help
1103	  This option enables support for a 32-bit U-mode running under a 64-bit
1104	  kernel at S-mode. riscv32-specific components such as system calls,
1105	  the user helper functions (vdso), signal rt_frame functions and the
1106	  ptrace interface are handled appropriately by the kernel.
1107
1108	  If you want to execute 32-bit userspace applications, say Y.
1109
1110config PARAVIRT
1111	bool "Enable paravirtualization code"
1112	depends on RISCV_SBI
1113	help
1114	  This changes the kernel so it can modify itself when it is run
1115	  under a hypervisor, potentially improving performance significantly
1116	  over full virtualization.
1117
1118config PARAVIRT_TIME_ACCOUNTING
1119	bool "Paravirtual steal time accounting"
1120	depends on PARAVIRT
1121	help
1122	  Select this option to enable fine granularity task steal time
1123	  accounting. Time spent executing other tasks in parallel with
1124	  the current vCPU is discounted from the vCPU power. To account for
1125	  that, there can be a small performance impact.
1126
1127	  If in doubt, say N here.
1128
1129config RELOCATABLE
1130	bool "Build a relocatable kernel"
1131	depends on !XIP_KERNEL
1132	select MODULE_SECTIONS if MODULES
1133	select ARCH_VMLINUX_NEEDS_RELOCS
1134	help
1135          This builds a kernel as a Position Independent Executable (PIE),
1136          which retains all relocation metadata required to relocate the
1137          kernel binary at runtime to a different virtual address than the
1138          address it was linked at.
1139          Since RISCV uses the RELA relocation format, this requires a
1140          relocation pass at runtime even if the kernel is loaded at the
1141          same address it was linked at.
1142
1143          If unsure, say N.
1144
1145config RANDOMIZE_BASE
1146        bool "Randomize the address of the kernel image"
1147        select RELOCATABLE
1148        depends on MMU && 64BIT && !XIP_KERNEL
1149        help
1150          Randomizes the virtual address at which the kernel image is
1151          loaded, as a security feature that deters exploit attempts
1152          relying on knowledge of the location of kernel internals.
1153
1154          It is the bootloader's job to provide entropy, by passing a
1155          random u64 value in /chosen/kaslr-seed at kernel entry.
1156
1157          When booting via the UEFI stub, it will invoke the firmware's
1158          EFI_RNG_PROTOCOL implementation (if available) to supply entropy
1159          to the kernel proper. In addition, it will randomise the physical
1160          location of the kernel Image as well.
1161
1162          If unsure, say N.
1163
1164endmenu # "Kernel features"
1165
1166menu "Boot options"
1167
1168config CMDLINE
1169	string "Built-in kernel command line"
1170	help
1171	  For most platforms, the arguments for the kernel's command line
1172	  are provided at run-time, during boot. However, there are cases
1173	  where either no arguments are being provided or the provided
1174	  arguments are insufficient or even invalid.
1175
1176	  When that occurs, it is possible to define a built-in command
1177	  line here and choose how the kernel should use it later on.
1178
1179choice
1180	prompt "Built-in command line usage"
1181	depends on CMDLINE != ""
1182	default CMDLINE_FALLBACK
1183	help
1184	  Choose how the kernel will handle the provided built-in command
1185	  line.
1186
1187config CMDLINE_FALLBACK
1188	bool "Use bootloader kernel arguments if available"
1189	help
1190	  Use the built-in command line as fallback in case we get nothing
1191	  during boot. This is the default behaviour.
1192
1193config CMDLINE_EXTEND
1194	bool "Extend bootloader kernel arguments"
1195	help
1196	  The built-in command line will be appended to the command-
1197	  line arguments provided during boot. This is useful in
1198	  cases where the provided arguments are insufficient and
1199	  you don't want to or cannot modify them.
1200
1201config CMDLINE_FORCE
1202	bool "Always use the default kernel command string"
1203	help
1204	  Always use the built-in command line, even if we get one during
1205	  boot. This is useful in case you need to override the provided
1206	  command line on systems where you don't have or want control
1207	  over it.
1208
1209endchoice
1210
1211config EFI_STUB
1212	bool
1213
1214config EFI
1215	bool "UEFI runtime support"
1216	depends on OF && !XIP_KERNEL
1217	depends on MMU
1218	default y
1219	select ARCH_SUPPORTS_ACPI if 64BIT
1220	select EFI_GENERIC_STUB
1221	select EFI_PARAMS_FROM_FDT
1222	select EFI_RUNTIME_WRAPPERS
1223	select EFI_STUB
1224	select LIBFDT
1225	select RISCV_ISA_C
1226	select UCS2_STRING
1227	help
1228	  This option provides support for runtime services provided
1229	  by UEFI firmware (such as non-volatile variables, realtime
1230	  clock, and platform reset). A UEFI stub is also provided to
1231	  allow the kernel to be booted as an EFI application. This
1232	  is only useful on systems that have UEFI firmware.
1233
1234config DMI
1235	bool "Enable support for SMBIOS (DMI) tables"
1236	depends on EFI
1237	default y
1238	help
1239	  This enables SMBIOS/DMI feature for systems.
1240
1241	  This option is only useful on systems that have UEFI firmware.
1242	  However, even with this option, the resultant kernel should
1243	  continue to boot on existing non-UEFI platforms.
1244
1245config CC_HAVE_STACKPROTECTOR_TLS
1246	def_bool $(cc-option,-mstack-protector-guard=tls -mstack-protector-guard-reg=tp -mstack-protector-guard-offset=0)
1247
1248config STACKPROTECTOR_PER_TASK
1249	def_bool y
1250	depends on !RANDSTRUCT
1251	depends on STACKPROTECTOR && CC_HAVE_STACKPROTECTOR_TLS
1252
1253config PHYS_RAM_BASE_FIXED
1254	bool "Explicitly specified physical RAM address"
1255	depends on NONPORTABLE
1256	default n
1257
1258config PHYS_RAM_BASE
1259	hex "Platform Physical RAM address"
1260	depends on PHYS_RAM_BASE_FIXED
1261	default "0x80000000"
1262	help
1263	  This is the physical address of RAM in the system. It has to be
1264	  explicitly specified to run early relocations of read-write data
1265	  from flash to RAM.
1266
1267config XIP_KERNEL
1268	bool "Kernel Execute-In-Place from ROM"
1269	depends on MMU && SPARSEMEM && NONPORTABLE
1270	# This prevents XIP from being enabled by all{yes,mod}config, which
1271	# fail to build since XIP doesn't support large kernels.
1272	depends on !COMPILE_TEST
1273	select PHYS_RAM_BASE_FIXED
1274	help
1275	  Execute-In-Place allows the kernel to run from non-volatile storage
1276	  directly addressable by the CPU, such as NOR flash. This saves RAM
1277	  space since the text section of the kernel is not loaded from flash
1278	  to RAM.  Read-write sections, such as the data section and stack,
1279	  are still copied to RAM.  The XIP kernel is not compressed since
1280	  it has to run directly from flash, so it will take more space to
1281	  store it.  The flash address used to link the kernel object files,
1282	  and for storing it, is configuration dependent. Therefore, if you
1283	  say Y here, you must know the proper physical address where to
1284	  store the kernel image depending on your own flash memory usage.
1285
1286	  Also note that the make target becomes "make xipImage" rather than
1287	  "make zImage" or "make Image".  The final kernel binary to put in
1288	  ROM memory will be arch/riscv/boot/xipImage.
1289
1290	  SPARSEMEM is required because the kernel text and rodata that are
1291	  flash resident are not backed by memmap, then any attempt to get
1292	  a struct page on those regions will trigger a fault.
1293
1294	  If unsure, say N.
1295
1296config XIP_PHYS_ADDR
1297	hex "XIP Kernel Physical Location"
1298	depends on XIP_KERNEL
1299	default "0x21000000"
1300	help
1301	  This is the physical address in your flash memory the kernel will
1302	  be linked for and stored to.  This address is dependent on your
1303	  own flash usage.
1304
1305config RISCV_ISA_FALLBACK
1306	bool "Permit falling back to parsing riscv,isa for extension support by default"
1307	default y
1308	help
1309	  Parsing the "riscv,isa" devicetree property has been deprecated and
1310	  replaced by a list of explicitly defined strings. For compatibility
1311	  with existing platforms, the kernel will fall back to parsing the
1312	  "riscv,isa" property if the replacements are not found.
1313
1314	  Selecting N here will result in a kernel that does not use the
1315	  fallback, unless the commandline "riscv_isa_fallback" parameter is
1316	  present.
1317
1318	  Please see the dt-binding, located at
1319	  Documentation/devicetree/bindings/riscv/extensions.yaml for details
1320	  on the replacement properties, "riscv,isa-base" and
1321	  "riscv,isa-extensions".
1322
1323config BUILTIN_DTB
1324	bool "Built-in device tree"
1325	depends on OF && NONPORTABLE
1326	select GENERIC_BUILTIN_DTB
1327	help
1328	  Build a device tree into the Linux image.
1329	  This option should be selected if no bootloader is being used.
1330	  If unsure, say N.
1331
1332
1333config BUILTIN_DTB_NAME
1334	string "Built-in device tree source"
1335	depends on BUILTIN_DTB
1336	help
1337	  DTS file path (without suffix, relative to arch/riscv/boot/dts)
1338	  for the DTS file that will be used to produce the DTB linked into the
1339	  kernel.
1340
1341endmenu # "Boot options"
1342
1343config PORTABLE
1344	bool
1345	default !NONPORTABLE
1346	select EFI
1347	select MMU
1348	select OF
1349
1350config ARCH_PROC_KCORE_TEXT
1351	def_bool y
1352
1353menu "Power management options"
1354
1355source "kernel/power/Kconfig"
1356
1357config ARCH_HIBERNATION_POSSIBLE
1358	def_bool y
1359
1360config ARCH_HIBERNATION_HEADER
1361	def_bool HIBERNATION
1362
1363config ARCH_SUSPEND_POSSIBLE
1364	def_bool y
1365
1366endmenu # "Power management options"
1367
1368menu "CPU Power Management"
1369
1370source "drivers/cpuidle/Kconfig"
1371
1372source "drivers/cpufreq/Kconfig"
1373
1374endmenu # "CPU Power Management"
1375
1376source "arch/riscv/kvm/Kconfig"
1377
1378source "drivers/acpi/Kconfig"
1379