xref: /linux/arch/riscv/Kconfig (revision 3a6455d56bd7c4cfb1ea35ddae052943065e338e)
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_RIMT if ACPI
20	select ACPI_SPCR_TABLE if ACPI
21	select ARCH_DMA_DEFAULT_COHERENT
22	select ARCH_ENABLE_HUGEPAGE_MIGRATION if HUGETLB_PAGE && MIGRATION
23	select ARCH_ENABLE_MEMORY_HOTPLUG if SPARSEMEM_VMEMMAP
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_CURRENT_STACK_POINTER
28	select ARCH_HAS_DEBUG_VIRTUAL if MMU
29	select ARCH_HAS_DEBUG_VM_PGTABLE
30	select ARCH_HAS_DEBUG_WX
31	select ARCH_HAS_ELF_CORE_EFLAGS if BINFMT_ELF && ELF_CORE
32	select ARCH_HAS_FAST_MULTIPLIER
33	select ARCH_HAS_FORTIFY_SOURCE
34	select ARCH_HAS_GCOV_PROFILE_ALL
35	select ARCH_HAS_GIGANTIC_PAGE
36	select ARCH_HAS_HW_PTE_YOUNG
37	select ARCH_HAS_KCOV
38	select ARCH_HAS_KERNEL_FPU_SUPPORT if 64BIT && FPU
39	select ARCH_HAS_MEMBARRIER_CALLBACKS
40	select ARCH_HAS_MEMBARRIER_SYNC_CORE
41	select ARCH_HAS_MMIOWB
42	select ARCH_HAS_NON_OVERLAPPING_ADDRESS_SPACE
43	select ARCH_HAS_PMEM_API
44	select ARCH_HAS_PREEMPT_LAZY
45	select ARCH_HAS_PREPARE_SYNC_CORE_CMD
46	select ARCH_HAS_PTDUMP if MMU
47	select ARCH_HAS_PTE_SPECIAL
48	select ARCH_HAS_SET_DIRECT_MAP if MMU
49	select ARCH_HAS_SET_MEMORY if MMU
50	select ARCH_HAS_STRICT_KERNEL_RWX if MMU && !XIP_KERNEL
51	select ARCH_HAS_STRICT_MODULE_RWX if MMU && !XIP_KERNEL
52	select ARCH_HAS_SYNC_CORE_BEFORE_USERMODE
53	select ARCH_HAS_SYSCALL_WRAPPER
54	select ARCH_HAS_TICK_BROADCAST if GENERIC_CLOCKEVENTS_BROADCAST
55	select ARCH_HAS_UBSAN
56	select ARCH_HAS_VDSO_ARCH_DATA if HAVE_GENERIC_VDSO
57	select ARCH_HAVE_NMI_SAFE_CMPXCHG
58	select ARCH_KEEP_MEMBLOCK if ACPI
59	select ARCH_MHP_MEMMAP_ON_MEMORY_ENABLE	if 64BIT && MMU
60	select ARCH_OPTIONAL_KERNEL_RWX if ARCH_HAS_STRICT_KERNEL_RWX
61	select ARCH_OPTIONAL_KERNEL_RWX_DEFAULT
62	select ARCH_STACKWALK
63	select ARCH_SUPPORTS_ATOMIC_RMW
64	# clang >= 17: https://github.com/llvm/llvm-project/commit/62fa708ceb027713b386c7e0efda994f8bdc27e2
65	select ARCH_SUPPORTS_CFI if (!CC_IS_CLANG || CLANG_VERSION >= 170000)
66	select ARCH_SUPPORTS_DEBUG_PAGEALLOC if MMU
67	select ARCH_SUPPORTS_HUGE_PFNMAP if TRANSPARENT_HUGEPAGE
68	select ARCH_SUPPORTS_HUGETLBFS if MMU
69	select ARCH_SUPPORTS_LTO_CLANG if CMODEL_MEDANY
70	select ARCH_SUPPORTS_LTO_CLANG_THIN
71	select ARCH_SUPPORTS_MSEAL_SYSTEM_MAPPINGS if 64BIT && MMU
72	select ARCH_SUPPORTS_PAGE_TABLE_CHECK if MMU
73	select ARCH_SUPPORTS_PER_VMA_LOCK if MMU
74	select ARCH_SUPPORTS_RT
75	select ARCH_SUPPORTS_SHADOW_CALL_STACK if HAVE_SHADOW_CALL_STACK
76	select ARCH_SUPPORTS_SCHED_MC if SMP
77	select ARCH_USE_CMPXCHG_LOCKREF if 64BIT
78	select ARCH_USE_MEMTEST
79	select ARCH_USE_QUEUED_RWLOCKS
80	select ARCH_USE_SYM_ANNOTATIONS
81	select ARCH_USES_CFI_TRAPS if CFI
82	select ARCH_WANT_BATCHED_UNMAP_TLB_FLUSH if MMU
83	select ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT if MMU
84	select ARCH_WANT_FRAME_POINTERS
85	select ARCH_WANT_GENERAL_HUGETLB if !RISCV_ISA_SVNAPOT
86	select ARCH_WANT_HUGE_PMD_SHARE if 64BIT
87	select ARCH_WANT_LD_ORPHAN_WARN if !XIP_KERNEL
88	select ARCH_WANT_OPTIMIZE_DAX_VMEMMAP
89	select ARCH_WANT_OPTIMIZE_HUGETLB_VMEMMAP
90	select ARCH_WANTS_NO_INSTR
91	select ARCH_WANTS_THP_SWAP if HAVE_ARCH_TRANSPARENT_HUGEPAGE
92	select ARCH_WEAK_RELEASE_ACQUIRE if ARCH_USE_QUEUED_SPINLOCKS
93	select BINFMT_FLAT_NO_DATA_START_OFFSET if !MMU
94	select BUILDTIME_TABLE_SORT if MMU
95	select CLINT_TIMER if RISCV_M_MODE
96	select CLONE_BACKWARDS
97	select COMMON_CLK
98	select CPU_NO_EFFICIENT_FFS if !RISCV_ISA_ZBB
99	select CPU_PM if CPU_IDLE || HIBERNATION || SUSPEND
100	select DYNAMIC_FTRACE if FUNCTION_TRACER
101	select EDAC_SUPPORT
102	select FRAME_POINTER if PERF_EVENTS || (FUNCTION_TRACER && !DYNAMIC_FTRACE)
103	select FTRACE_MCOUNT_USE_PATCHABLE_FUNCTION_ENTRY if DYNAMIC_FTRACE
104	select FUNCTION_ALIGNMENT_8B if DYNAMIC_FTRACE_WITH_CALL_OPS
105	select GENERIC_ARCH_TOPOLOGY
106	select GENERIC_ATOMIC64 if !64BIT
107	select GENERIC_CLOCKEVENTS_BROADCAST if SMP
108	select GENERIC_CPU_DEVICES
109	select GENERIC_CPU_VULNERABILITIES
110	select GENERIC_EARLY_IOREMAP
111	select GENERIC_ENTRY
112	select GENERIC_GETTIMEOFDAY if HAVE_GENERIC_VDSO && 64BIT
113	select GENERIC_IDLE_POLL_SETUP
114	select GENERIC_IOREMAP if MMU
115	select GENERIC_IRQ_IPI if SMP
116	select GENERIC_IRQ_IPI_MUX if SMP
117	select GENERIC_IRQ_MULTI_HANDLER
118	select GENERIC_IRQ_SHOW
119	select GENERIC_IRQ_SHOW_LEVEL
120	select GENERIC_LIB_DEVMEM_IS_ALLOWED
121	select GENERIC_PENDING_IRQ if SMP
122	select GENERIC_PCI_IOMAP
123	select GENERIC_SCHED_CLOCK
124	select GENERIC_SMP_IDLE_THREAD
125	select GENERIC_TIME_VSYSCALL if GENERIC_GETTIMEOFDAY
126	select HARDIRQS_SW_RESEND
127	select HAS_IOPORT if MMU
128	select HAVE_ALIGNED_STRUCT_PAGE
129	select HAVE_ARCH_AUDITSYSCALL
130	select HAVE_ARCH_HUGE_VMALLOC if HAVE_ARCH_HUGE_VMAP
131	select HAVE_ARCH_HUGE_VMAP if MMU && 64BIT
132	select HAVE_ARCH_JUMP_LABEL if !XIP_KERNEL
133	select HAVE_ARCH_JUMP_LABEL_RELATIVE if !XIP_KERNEL
134	select HAVE_ARCH_KASAN if MMU && 64BIT
135	select HAVE_ARCH_KASAN_VMALLOC if MMU && 64BIT
136	select HAVE_ARCH_KFENCE if MMU && 64BIT
137	select HAVE_ARCH_KSTACK_ERASE
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_SOFT_DIRTY if 64BIT && MMU && RISCV_ISA_SVRSW60T59B
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_USERFAULTFD_WP if 64BIT && MMU && USERFAULTFD && RISCV_ISA_SVRSW60T59B
151	select HAVE_ARCH_VMAP_STACK if MMU && 64BIT
152	select HAVE_ASM_MODVERSIONS
153	select HAVE_CONTEXT_TRACKING_USER
154	select HAVE_DEBUG_KMEMLEAK
155	select HAVE_DMA_CONTIGUOUS if MMU
156	select HAVE_DYNAMIC_FTRACE if !XIP_KERNEL && MMU && (CLANG_SUPPORTS_DYNAMIC_FTRACE || GCC_SUPPORTS_DYNAMIC_FTRACE)
157	select FUNCTION_ALIGNMENT_4B if HAVE_DYNAMIC_FTRACE && RISCV_ISA_C
158	select HAVE_DYNAMIC_FTRACE_WITH_DIRECT_CALLS if HAVE_DYNAMIC_FTRACE_WITH_CALL_OPS
159	select HAVE_DYNAMIC_FTRACE_WITH_CALL_OPS if (DYNAMIC_FTRACE_WITH_ARGS && !CFI)
160	select HAVE_DYNAMIC_FTRACE_WITH_ARGS if HAVE_DYNAMIC_FTRACE
161	select HAVE_FTRACE_GRAPH_FUNC
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 && HAVE_DYNAMIC_FTRACE
165	select HAVE_EBPF_JIT if MMU
166	select HAVE_GENERIC_TIF_BITS
167	select HAVE_GUP_FAST if MMU
168	select HAVE_FUNCTION_ARG_ACCESS_API
169	select HAVE_FUNCTION_ERROR_INJECTION
170	select HAVE_GCC_PLUGINS
171	select HAVE_GENERIC_VDSO if MMU
172	select HAVE_IRQ_TIME_ACCOUNTING
173	select HAVE_KERNEL_BZIP2 if !XIP_KERNEL && !EFI_ZBOOT
174	select HAVE_KERNEL_GZIP if !XIP_KERNEL && !EFI_ZBOOT
175	select HAVE_KERNEL_LZ4 if !XIP_KERNEL && !EFI_ZBOOT
176	select HAVE_KERNEL_LZMA if !XIP_KERNEL && !EFI_ZBOOT
177	select HAVE_KERNEL_LZO if !XIP_KERNEL && !EFI_ZBOOT
178	select HAVE_KERNEL_UNCOMPRESSED if !XIP_KERNEL && !EFI_ZBOOT
179	select HAVE_KERNEL_ZSTD if !XIP_KERNEL && !EFI_ZBOOT
180	select HAVE_KERNEL_XZ if !XIP_KERNEL && !EFI_ZBOOT
181	select HAVE_KPROBES if !XIP_KERNEL
182	select HAVE_KRETPROBES if !XIP_KERNEL
183	# https://github.com/ClangBuiltLinux/linux/issues/1881
184	select HAVE_LD_DEAD_CODE_DATA_ELIMINATION if !LD_IS_LLD
185	select HAVE_MOVE_PMD
186	select HAVE_MOVE_PUD
187	select HAVE_PAGE_SIZE_4KB
188	select HAVE_PCI
189	select HAVE_PERF_EVENTS
190	select HAVE_PERF_REGS
191	select HAVE_PERF_USER_STACK_DUMP
192	select HAVE_POSIX_CPU_TIMERS_TASK_WORK
193	select HAVE_PREEMPT_DYNAMIC_KEY if !XIP_KERNEL
194	select HAVE_REGS_AND_STACK_ACCESS_API
195	select HAVE_RETHOOK if !XIP_KERNEL
196	select HAVE_RSEQ
197	select HAVE_RUST if RUSTC_SUPPORTS_RISCV && CC_IS_CLANG
198	select HAVE_SAMPLE_FTRACE_DIRECT
199	select HAVE_SAMPLE_FTRACE_DIRECT_MULTI
200	select HAVE_STACKPROTECTOR
201	select HAVE_SYSCALL_TRACEPOINTS
202	select HOTPLUG_PARALLEL if HOTPLUG_CPU
203	select IRQ_DOMAIN
204	select IRQ_FORCED_THREADING
205	select KASAN_VMALLOC if KASAN
206	select LOCK_MM_AND_FIND_VMA
207	select MMU_GATHER_RCU_TABLE_FREE if SMP && MMU
208	select MODULES_USE_ELF_RELA if MODULES
209	select OF
210	select OF_EARLY_FLATTREE
211	select OF_IRQ
212	select PCI_DOMAINS_GENERIC if PCI
213	select PCI_ECAM if (ACPI && PCI)
214	select PCI_MSI if PCI
215	select RELOCATABLE if !MMU && !PHYS_RAM_BASE_FIXED
216	select RISCV_ALTERNATIVE if !XIP_KERNEL
217	select RISCV_APLIC
218	select RISCV_IMSIC
219	select RISCV_INTC
220	select RISCV_TIMER if RISCV_SBI
221	select SIFIVE_PLIC
222	select SPARSE_IRQ
223	select SYSCTL_EXCEPTION_TRACE
224	select THREAD_INFO_IN_TASK
225	select TRACE_IRQFLAGS_SUPPORT
226	select UACCESS_MEMCPY if !MMU
227	select VDSO_GETRANDOM if HAVE_GENERIC_VDSO && 64BIT
228	select USER_STACKTRACE_SUPPORT
229	select ZONE_DMA32 if 64BIT
230
231config RUSTC_SUPPORTS_RISCV
232	def_bool y
233	depends on 64BIT
234	# Shadow call stack requires rustc version 1.82+ due to use of the
235	# -Zsanitizer=shadow-call-stack flag.
236	depends on !SHADOW_CALL_STACK || RUSTC_VERSION >= 108200
237
238config CLANG_SUPPORTS_DYNAMIC_FTRACE
239	def_bool CC_IS_CLANG
240	# https://github.com/ClangBuiltLinux/linux/issues/1817
241	depends on AS_IS_GNU || (AS_IS_LLVM && (LD_IS_LLD || LD_VERSION >= 23600))
242
243config GCC_SUPPORTS_DYNAMIC_FTRACE
244	def_bool CC_IS_GCC
245	depends on $(cc-option,-fpatchable-function-entry=8)
246	depends on CC_HAS_MIN_FUNCTION_ALIGNMENT || !RISCV_ISA_C
247
248config HAVE_SHADOW_CALL_STACK
249	def_bool $(cc-option,-fsanitize=shadow-call-stack)
250	# https://github.com/riscv-non-isa/riscv-elf-psabi-doc/commit/a484e843e6eeb51f0cb7b8819e50da6d2444d769
251	depends on $(ld-option,--no-relax-gp)
252
253# https://github.com/llvm/llvm-project/commit/bbc0f99f3bc96f1db16f649fc21dd18e5b0918f6
254config ARCH_HAS_BROKEN_DWARF5
255	def_bool y
256	# https://github.com/llvm/llvm-project/commit/1df5ea29b43690b6622db2cad7b745607ca4de6a
257	depends on AS_IS_LLVM && AS_VERSION < 180000
258	# https://github.com/llvm/llvm-project/commit/7ffabb61a5569444b5ac9322e22e5471cc5e4a77
259	depends on LD_IS_LLD && LLD_VERSION < 180000
260
261config ARCH_MMAP_RND_BITS_MIN
262	default 18 if 64BIT
263	default 8
264
265config ARCH_MMAP_RND_COMPAT_BITS_MIN
266	default 8
267
268# max bits determined by the following formula:
269#  VA_BITS - PAGE_SHIFT - 3
270config ARCH_MMAP_RND_BITS_MAX
271	default 24 if 64BIT # SV39 based
272	default 17
273
274config ARCH_MMAP_RND_COMPAT_BITS_MAX
275	default 17
276
277# set if we run in machine mode, cleared if we run in supervisor mode
278config RISCV_M_MODE
279	bool "Build a kernel that runs in machine mode"
280	depends on !MMU
281	default y
282	help
283	  Select this option if you want to run the kernel in M-mode,
284	  without the assistance of any other firmware.
285
286# set if we are running in S-mode and can use SBI calls
287config RISCV_SBI
288	bool
289	depends on !RISCV_M_MODE
290	default y
291
292config MMU
293	bool "MMU-based Paged Memory Management Support"
294	default y
295	help
296	  Select if you want MMU-based virtualised addressing space
297	  support by paged memory management. If unsure, say 'Y'.
298
299config KASAN_SHADOW_OFFSET
300	hex
301	depends on KASAN_GENERIC
302	default 0xdfffffff00000000 if 64BIT
303	default 0xffffffff if 32BIT
304
305config ARCH_FLATMEM_ENABLE
306	def_bool !NUMA
307
308config ARCH_SPARSEMEM_ENABLE
309	def_bool y
310	depends on MMU
311	select SPARSEMEM_STATIC if 32BIT && SPARSEMEM
312	select SPARSEMEM_VMEMMAP_ENABLE if 64BIT
313
314config ARCH_SELECT_MEMORY_MODEL
315	def_bool ARCH_SPARSEMEM_ENABLE
316
317config ARCH_SUPPORTS_UPROBES
318	def_bool y
319
320config STACKTRACE_SUPPORT
321	def_bool y
322
323config GENERIC_BUG
324	def_bool y
325	depends on BUG
326	select GENERIC_BUG_RELATIVE_POINTERS if 64BIT
327
328config GENERIC_BUG_RELATIVE_POINTERS
329	bool
330
331config GENERIC_CALIBRATE_DELAY
332	def_bool y
333
334config GENERIC_CSUM
335	def_bool y
336
337config GENERIC_HWEIGHT
338	def_bool y
339
340config FIX_EARLYCON_MEM
341	def_bool MMU
342
343config ILLEGAL_POINTER_VALUE
344	hex
345	default 0 if 32BIT
346	default 0xdead000000000000 if 64BIT
347
348config PGTABLE_LEVELS
349	int
350	default 5 if 64BIT
351	default 2
352
353config LOCKDEP_SUPPORT
354	def_bool y
355
356config RISCV_DMA_NONCOHERENT
357	bool
358	select ARCH_HAS_DMA_PREP_COHERENT
359	select ARCH_HAS_SETUP_DMA_OPS
360	select ARCH_HAS_SYNC_DMA_FOR_CPU
361	select ARCH_HAS_SYNC_DMA_FOR_DEVICE
362	select DMA_BOUNCE_UNALIGNED_KMALLOC if SWIOTLB
363
364config RISCV_NONSTANDARD_CACHE_OPS
365	bool
366	help
367	  This enables function pointer support for non-standard noncoherent
368	  systems to handle cache management.
369
370config AS_HAS_INSN
371	def_bool $(as-instr,.insn 0x100000f)
372
373config AS_HAS_OPTION_ARCH
374	# https://github.com/llvm/llvm-project/commit/9e8ed3403c191ab9c4903e8eeb8f732ff8a43cb4
375	def_bool y
376	depends on $(as-instr, .option arch$(comma) +m)
377
378source "arch/riscv/Kconfig.socs"
379source "arch/riscv/Kconfig.errata"
380
381menu "Platform type"
382
383config NONPORTABLE
384	bool "Allow configurations that result in non-portable kernels"
385	help
386	  RISC-V kernel binaries are compatible between all known systems
387	  whenever possible, but there are some use cases that can only be
388	  satisfied by configurations that result in kernel binaries that are
389	  not portable between systems.
390
391	  Selecting N does not guarantee kernels will be portable to all known
392	  systems.  Selecting any of the options guarded by NONPORTABLE will
393	  result in kernel binaries that are unlikely to be portable between
394	  systems.
395
396	  If unsure, say N.
397
398choice
399	prompt "Base ISA"
400	default ARCH_RV64I
401	help
402	  This selects the base ISA that this kernel will target and must match
403	  the target platform.
404
405config ARCH_RV32I
406	bool "RV32I"
407	depends on NONPORTABLE
408	select 32BIT
409	select GENERIC_LIB_ASHLDI3
410	select GENERIC_LIB_ASHRDI3
411	select GENERIC_LIB_LSHRDI3
412	select GENERIC_LIB_UCMPDI2
413
414config ARCH_RV64I
415	bool "RV64I"
416	select 64BIT
417	select ARCH_SUPPORTS_INT128 if CC_HAS_INT128
418	select SWIOTLB if MMU
419
420endchoice
421
422# We must be able to map all physical memory into the kernel, but the compiler
423# is still a bit more efficient when generating code if it's setup in a manner
424# such that it can only map 2GiB of memory.
425choice
426	prompt "Kernel Code Model"
427	default CMODEL_MEDLOW if 32BIT
428	default CMODEL_MEDANY if 64BIT
429
430	config CMODEL_MEDLOW
431		bool "medium low code model"
432	config CMODEL_MEDANY
433		bool "medium any code model"
434endchoice
435
436config MODULE_SECTIONS
437	bool
438	select HAVE_MOD_ARCH_SPECIFIC
439
440config SMP
441	bool "Symmetric Multi-Processing"
442	help
443	  This enables support for systems with more than one CPU.  If
444	  you say N here, the kernel will run on single and
445	  multiprocessor machines, but will use only one CPU of a
446	  multiprocessor machine. If you say Y here, the kernel will run
447	  on many, but not all, single processor machines. On a single
448	  processor machine, the kernel will run faster if you say N
449	  here.
450
451	  If you don't know what to do here, say N.
452
453config NR_CPUS
454	int "Maximum number of CPUs (2-512)"
455	depends on SMP
456	range 2 512 if !RISCV_SBI_V01
457	range 2 32 if RISCV_SBI_V01 && 32BIT
458	range 2 64 if RISCV_SBI_V01 && 64BIT
459	default "32" if 32BIT
460	default "64" if 64BIT
461
462config HOTPLUG_CPU
463	bool "Support for hot-pluggable CPUs"
464	depends on SMP
465	select GENERIC_IRQ_MIGRATION
466	help
467
468	  Say Y here to experiment with turning CPUs off and on.  CPUs
469	  can be controlled through /sys/devices/system/cpu.
470
471	  Say N if you want to disable CPU hotplug.
472
473choice
474	prompt "CPU Tuning"
475	default TUNE_GENERIC
476
477config TUNE_GENERIC
478	bool "generic"
479
480endchoice
481
482# Common NUMA Features
483config NUMA
484	bool "NUMA Memory Allocation and Scheduler Support"
485	depends on SMP && MMU
486	select ARCH_SUPPORTS_NUMA_BALANCING
487	select GENERIC_ARCH_NUMA
488	select HAVE_SETUP_PER_CPU_AREA
489	select NEED_PER_CPU_EMBED_FIRST_CHUNK
490	select NEED_PER_CPU_PAGE_FIRST_CHUNK
491	select OF_NUMA
492	select USE_PERCPU_NUMA_NODE_ID
493	help
494	  Enable NUMA (Non-Uniform Memory Access) support.
495
496	  The kernel will try to allocate memory used by a CPU on the
497	  local memory of the CPU and add some more NUMA awareness to the kernel.
498
499config NODES_SHIFT
500	int "Maximum NUMA Nodes (as a power of 2)"
501	range 1 10
502	default "2"
503	depends on NUMA
504	help
505	  Specify the maximum number of NUMA Nodes available on the target
506	  system.  Increases memory reserved to accommodate various tables.
507
508choice
509	prompt "RISC-V spinlock type"
510	default RISCV_COMBO_SPINLOCKS
511
512config RISCV_TICKET_SPINLOCKS
513	bool "Using ticket spinlock"
514
515config RISCV_QUEUED_SPINLOCKS
516	bool "Using queued spinlock"
517	depends on SMP && MMU && NONPORTABLE
518	select ARCH_USE_QUEUED_SPINLOCKS
519	help
520	  The queued spinlock implementation requires the forward progress
521	  guarantee of cmpxchg()/xchg() atomic operations: CAS with Zabha or
522	  LR/SC with Ziccrse provide such guarantee.
523
524	  Select this if and only if Zabha or Ziccrse is available on your
525	  platform, RISCV_QUEUED_SPINLOCKS must not be selected for platforms
526	  without one of those extensions.
527
528	  If unsure, select RISCV_COMBO_SPINLOCKS, which will use qspinlocks
529	  when supported and otherwise ticket spinlocks.
530
531config RISCV_COMBO_SPINLOCKS
532	bool "Using combo spinlock"
533	depends on SMP && MMU
534	select ARCH_USE_QUEUED_SPINLOCKS
535	help
536	  Embed both queued spinlock and ticket lock so that the spinlock
537	  implementation can be chosen at runtime.
538
539endchoice
540
541config RISCV_ALTERNATIVE
542	bool
543	depends on !XIP_KERNEL
544	help
545	  This Kconfig allows the kernel to automatically patch the
546	  erratum or cpufeature required by the execution platform at run
547	  time. The code patching overhead is minimal, as it's only done
548	  once at boot and once on each module load.
549
550config RISCV_ALTERNATIVE_EARLY
551	bool
552	depends on RISCV_ALTERNATIVE
553	help
554	  Allows early patching of the kernel for special errata
555
556config RISCV_ISA_C
557	bool "Emit compressed instructions when building Linux"
558	default y
559	help
560	  Adds "C" to the ISA subsets that the toolchain is allowed to emit
561	  when building Linux, which results in compressed instructions in the
562	  Linux binary. This option produces a kernel that will not run on
563	  systems that do not support compressed instructions.
564
565	  If you don't know what to do here, say Y.
566
567config RISCV_ISA_SUPM
568	bool "Supm extension for userspace pointer masking"
569	depends on 64BIT
570	default y
571	help
572	  Add support for pointer masking in userspace (Supm) when the
573	  underlying hardware extension (Smnpm or Ssnpm) is detected at boot.
574
575	  If this option is disabled, userspace will be unable to use
576	  the prctl(PR_{SET,GET}_TAGGED_ADDR_CTRL) API.
577
578config RISCV_ISA_SVNAPOT
579	bool "Svnapot extension support for supervisor mode NAPOT pages"
580	depends on 64BIT && MMU
581	depends on RISCV_ALTERNATIVE
582	default y
583	help
584	  Enable support for the Svnapot ISA-extension when it is detected
585	  at boot.
586
587	  The Svnapot extension is used to mark contiguous PTEs as a range
588	  of contiguous virtual-to-physical translations for a naturally
589	  aligned power-of-2 (NAPOT) granularity larger than the base 4KB page
590	  size. When HUGETLBFS is also selected this option unconditionally
591	  allocates some memory for each NAPOT page size supported by the kernel.
592	  When optimizing for low memory consumption and for platforms without
593	  the Svnapot extension, it may be better to say N here.
594
595	  If you don't know what to do here, say Y.
596
597config RISCV_ISA_SVPBMT
598	bool "Svpbmt extension support for supervisor mode page-based memory types"
599	depends on 64BIT && MMU
600	depends on RISCV_ALTERNATIVE
601	default y
602	help
603	   Add support for the Svpbmt ISA-extension (Supervisor-mode:
604	   page-based memory types) in the kernel when it is detected at boot.
605
606	   The memory type for a page contains a combination of attributes
607	   that indicate the cacheability, idempotency, and ordering
608	   properties for access to that page.
609
610	   The Svpbmt extension is only available on 64-bit cpus.
611
612	   If you don't know what to do here, say Y.
613
614config TOOLCHAIN_HAS_V
615	bool
616	default y
617	depends on !64BIT || $(cc-option,-mabi=lp64 -march=rv64imv)
618	depends on !32BIT || $(cc-option,-mabi=ilp32 -march=rv32imv)
619	depends on LD_IS_LLD || LD_VERSION >= 23800
620	depends on AS_HAS_OPTION_ARCH
621
622config RISCV_ISA_V
623	bool "Vector extension support"
624	depends on TOOLCHAIN_HAS_V
625	depends on FPU
626	select DYNAMIC_SIGFRAME
627	default y
628	help
629	  Add support for the Vector extension when it is detected at boot.
630	  When this option is disabled, neither the kernel nor userspace may
631	  use vector procedures.
632
633	  If you don't know what to do here, say Y.
634
635config RISCV_ISA_V_DEFAULT_ENABLE
636	bool "Enable userspace Vector by default"
637	depends on RISCV_ISA_V
638	default y
639	help
640	  Say Y here if you want to enable Vector in userspace by default.
641	  Otherwise, userspace has to make explicit prctl() call to enable
642	  Vector, or enable it via the sysctl interface.
643
644	  If you don't know what to do here, say Y.
645
646config RISCV_ISA_V_UCOPY_THRESHOLD
647	int "Threshold size for vectorized user copies"
648	depends on RISCV_ISA_V
649	default 768
650	help
651	  Prefer using vectorized copy_to_user()/copy_from_user() when the
652	  workload size exceeds this value.
653
654config RISCV_ISA_V_PREEMPTIVE
655	bool "Run kernel-mode Vector with kernel preemption"
656	depends on PREEMPTION
657	depends on RISCV_ISA_V
658	default y
659	help
660	  Usually, in-kernel SIMD routines are run with preemption disabled.
661	  Functions which invoke long running SIMD thus must yield the core's
662	  vector unit to prevent blocking other tasks for too long.
663
664	  This config allows the kernel to run SIMD without explicitly disabling
665	  preemption. Enabling this config will result in higher memory consumption
666	  due to the allocation of per-task's kernel Vector context.
667
668config RISCV_ISA_ZAWRS
669	bool "Zawrs extension support for more efficient busy waiting"
670	depends on RISCV_ALTERNATIVE
671	default y
672	help
673	  The Zawrs extension defines instructions to be used in polling loops
674	  which allow a hart to enter a low-power state or to trap to the
675	  hypervisor while waiting on a store to a memory location. Enable the
676	  use of these instructions in the kernel when the Zawrs extension is
677	  detected at boot.
678
679config TOOLCHAIN_HAS_ZABHA
680	bool
681	default y
682	depends on !64BIT || $(cc-option,-mabi=lp64 -march=rv64ima_zabha)
683	depends on !32BIT || $(cc-option,-mabi=ilp32 -march=rv32ima_zabha)
684	depends on AS_HAS_OPTION_ARCH
685
686config RISCV_ISA_ZABHA
687	bool "Zabha extension support for atomic byte/halfword operations"
688	depends on TOOLCHAIN_HAS_ZABHA
689	depends on RISCV_ALTERNATIVE
690	default y
691	help
692	  Enable the use of the Zabha ISA-extension to implement kernel
693	  byte/halfword atomic memory operations when it is detected at boot.
694
695	  If you don't know what to do here, say Y.
696
697config TOOLCHAIN_HAS_ZACAS
698	bool
699	default y
700	depends on !64BIT || $(cc-option,-mabi=lp64 -march=rv64ima_zacas)
701	depends on !32BIT || $(cc-option,-mabi=ilp32 -march=rv32ima_zacas)
702	depends on AS_HAS_OPTION_ARCH
703
704config RISCV_ISA_ZACAS
705	bool "Zacas extension support for atomic CAS"
706	depends on RISCV_ALTERNATIVE
707	default y
708	help
709	  Enable the use of the Zacas ISA-extension to implement kernel atomic
710	  cmpxchg operations when it is detected at boot.
711
712	  If you don't know what to do here, say Y.
713
714config TOOLCHAIN_HAS_ZBB
715	bool
716	default y
717	depends on !64BIT || $(cc-option,-mabi=lp64 -march=rv64ima_zbb)
718	depends on !32BIT || $(cc-option,-mabi=ilp32 -march=rv32ima_zbb)
719	depends on LD_IS_LLD || LD_VERSION >= 23900
720	depends on AS_HAS_OPTION_ARCH
721
722# This symbol indicates that the toolchain supports all v1.0 vector crypto
723# extensions, including Zvk*, Zvbb, and Zvbc.  LLVM added all of these at once.
724# binutils added all except Zvkb, then added Zvkb.  So we just check for Zvkb.
725config TOOLCHAIN_HAS_VECTOR_CRYPTO
726	def_bool $(as-instr, .option arch$(comma) +v$(comma) +zvkb)
727	depends on AS_HAS_OPTION_ARCH
728
729config TOOLCHAIN_HAS_ZBA
730	bool
731	default y
732	depends on !64BIT || $(cc-option,-mabi=lp64 -march=rv64ima_zba)
733	depends on !32BIT || $(cc-option,-mabi=ilp32 -march=rv32ima_zba)
734	depends on LD_IS_LLD || LD_VERSION >= 23900
735	depends on AS_HAS_OPTION_ARCH
736
737config RISCV_ISA_ZBA
738	bool "Zba extension support for bit manipulation instructions"
739	default y
740	help
741	   Add support for enabling optimisations in the kernel when the Zba
742	   extension is detected at boot.
743
744	   The Zba extension provides instructions to accelerate the generation
745	   of addresses that index into arrays of basic data types.
746
747	   If you don't know what to do here, say Y.
748
749config RISCV_ISA_ZBB
750	bool "Zbb extension support for bit manipulation instructions"
751	depends on RISCV_ALTERNATIVE
752	default y
753	help
754	   Add support for enabling optimisations in the kernel when the
755	   Zbb extension is detected at boot. Some optimisations may
756	   additionally depend on toolchain support for Zbb.
757
758	   The Zbb extension provides instructions to accelerate a number
759	   of bit-specific operations (count bit population, sign extending,
760	   bitrotation, etc).
761
762	   If you don't know what to do here, say Y.
763
764config TOOLCHAIN_HAS_ZBC
765	bool
766	default y
767	depends on !64BIT || $(cc-option,-mabi=lp64 -march=rv64ima_zbc)
768	depends on !32BIT || $(cc-option,-mabi=ilp32 -march=rv32ima_zbc)
769	depends on LD_IS_LLD || LD_VERSION >= 23900
770	depends on AS_HAS_OPTION_ARCH
771
772config RISCV_ISA_ZBC
773	bool "Zbc extension support for carry-less multiplication instructions"
774	depends on TOOLCHAIN_HAS_ZBC
775	depends on MMU
776	depends on RISCV_ALTERNATIVE
777	default y
778	help
779	   Adds support to dynamically detect the presence of the Zbc
780	   extension (carry-less multiplication) and enable its usage.
781
782	   The Zbc extension could accelerate CRC (cyclic redundancy check)
783	   calculations.
784
785	   If you don't know what to do here, say Y.
786
787config TOOLCHAIN_HAS_ZBKB
788	bool
789	default y
790	depends on !64BIT || $(cc-option,-mabi=lp64 -march=rv64ima_zbkb)
791	depends on !32BIT || $(cc-option,-mabi=ilp32 -march=rv32ima_zbkb)
792	depends on LD_IS_LLD || LD_VERSION >= 23900
793	depends on AS_HAS_OPTION_ARCH
794
795config RISCV_ISA_ZBKB
796	bool "Zbkb extension support for bit manipulation instructions"
797	depends on TOOLCHAIN_HAS_ZBKB
798	depends on RISCV_ALTERNATIVE
799	default y
800	help
801	   Adds support to dynamically detect the presence of the ZBKB
802	   extension (bit manipulation for cryptography) and enable its usage.
803
804	   The Zbkb extension provides instructions to accelerate a number
805	   of common cryptography operations (pack, zip, etc).
806
807	   If you don't know what to do here, say Y.
808
809config RISCV_ISA_ZICBOM
810	bool "Zicbom extension support for non-coherent DMA operation"
811	depends on MMU
812	depends on RISCV_ALTERNATIVE
813	default y
814	select RISCV_DMA_NONCOHERENT
815	select DMA_DIRECT_REMAP
816	help
817	   Add support for the Zicbom extension (Cache Block Management
818	   Operations) and enable its use in the kernel when it is detected
819	   at boot.
820
821	   The Zicbom extension can be used to handle for example
822	   non-coherent DMA support on devices that need it.
823
824	   If you don't know what to do here, say Y.
825
826config RISCV_ISA_ZICBOZ
827	bool "Zicboz extension support for faster zeroing of memory"
828	depends on RISCV_ALTERNATIVE
829	default y
830	help
831	   Enable the use of the Zicboz extension (cbo.zero instruction)
832	   in the kernel when it is detected at boot.
833
834	   The Zicboz extension is used for faster zeroing of memory.
835
836	   If you don't know what to do here, say Y.
837
838config RISCV_ISA_ZICBOP
839	bool "Zicbop extension support for cache block prefetch"
840	depends on MMU
841	depends on RISCV_ALTERNATIVE
842	default y
843	help
844	  Adds support to dynamically detect the presence of the ZICBOP
845	  extension (Cache Block Prefetch Operations) and enable its
846	  usage.
847
848	  The Zicbop extension can be used to prefetch cache blocks for
849	  read/write fetch.
850
851	  If you don't know what to do here, say Y.
852
853config RISCV_ISA_SVRSW60T59B
854	bool "Svrsw60t59b extension support for using PTE bits 60 and 59"
855	depends on MMU && 64BIT
856	depends on RISCV_ALTERNATIVE
857	default y
858	help
859	  Adds support to dynamically detect the presence of the Svrsw60t59b
860	  extension and enable its usage.
861
862	  The Svrsw60t59b extension allows to free the PTE reserved bits 60
863	  and 59 for software to use.
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	select HAVE_PV_STEAL_CLOCK_GEN
1114	help
1115	  This changes the kernel so it can modify itself when it is run
1116	  under a hypervisor, potentially improving performance significantly
1117	  over full virtualization.
1118
1119config PARAVIRT_TIME_ACCOUNTING
1120	bool "Paravirtual steal time accounting"
1121	depends on PARAVIRT
1122	help
1123	  Select this option to enable fine granularity task steal time
1124	  accounting. Time spent executing other tasks in parallel with
1125	  the current vCPU is discounted from the vCPU power. To account for
1126	  that, there can be a small performance impact.
1127
1128	  If in doubt, say N here.
1129
1130config RELOCATABLE
1131	bool "Build a relocatable kernel"
1132	depends on !XIP_KERNEL
1133	select MODULE_SECTIONS if MODULES
1134	select ARCH_VMLINUX_NEEDS_RELOCS
1135	help
1136          This builds a kernel as a Position Independent Executable (PIE),
1137          which retains all relocation metadata required to relocate the
1138          kernel binary at runtime to a different virtual address than the
1139          address it was linked at.
1140          Since RISCV uses the RELA relocation format, this requires a
1141          relocation pass at runtime even if the kernel is loaded at the
1142          same address it was linked at.
1143
1144          If unsure, say N.
1145
1146config RANDOMIZE_BASE
1147        bool "Randomize the address of the kernel image"
1148        select RELOCATABLE
1149        depends on MMU && 64BIT && !XIP_KERNEL
1150        help
1151          Randomizes the virtual address at which the kernel image is
1152          loaded, as a security feature that deters exploit attempts
1153          relying on knowledge of the location of kernel internals.
1154
1155          It is the bootloader's job to provide entropy, by passing a
1156          random u64 value in /chosen/kaslr-seed at kernel entry.
1157
1158          When booting via the UEFI stub, it will invoke the firmware's
1159          EFI_RNG_PROTOCOL implementation (if available) to supply entropy
1160          to the kernel proper. In addition, it will randomise the physical
1161          location of the kernel Image as well.
1162
1163          If unsure, say N.
1164
1165config RISCV_USER_CFI
1166	def_bool y
1167	bool "riscv userspace control flow integrity"
1168	depends on 64BIT && MMU && \
1169		$(cc-option,-mabi=lp64 -march=rv64ima_zicfiss_zicfilp -fcf-protection=full)
1170	depends on RISCV_ALTERNATIVE
1171	select RISCV_SBI
1172	select ARCH_HAS_USER_SHADOW_STACK
1173	select ARCH_USES_HIGH_VMA_FLAGS
1174	select DYNAMIC_SIGFRAME
1175	help
1176	  Provides CPU-assisted control flow integrity to userspace tasks.
1177	  Control flow integrity is provided by implementing shadow stack for
1178	  backward edge and indirect branch tracking for forward edge.
1179	  Shadow stack protection is a hardware feature that detects function
1180	  return address corruption. This helps mitigate ROP attacks.
1181	  Indirect branch tracking enforces that all indirect branches must land
1182	  on a landing pad instruction else CPU will fault. This mitigates against
1183	  JOP / COP attacks. Applications must be enabled to use it, and old userspace
1184	  does not get protection "for free".
1185	  default y.
1186
1187endmenu # "Kernel features"
1188
1189menu "Boot options"
1190
1191config CMDLINE
1192	string "Built-in kernel command line"
1193	help
1194	  For most platforms, the arguments for the kernel's command line
1195	  are provided at run-time, during boot. However, there are cases
1196	  where either no arguments are being provided or the provided
1197	  arguments are insufficient or even invalid.
1198
1199	  When that occurs, it is possible to define a built-in command
1200	  line here and choose how the kernel should use it later on.
1201
1202choice
1203	prompt "Built-in command line usage"
1204	depends on CMDLINE != ""
1205	default CMDLINE_FALLBACK
1206	help
1207	  Choose how the kernel will handle the provided built-in command
1208	  line.
1209
1210config CMDLINE_FALLBACK
1211	bool "Use bootloader kernel arguments if available"
1212	help
1213	  Use the built-in command line as fallback in case we get nothing
1214	  during boot. This is the default behaviour.
1215
1216config CMDLINE_EXTEND
1217	bool "Extend bootloader kernel arguments"
1218	help
1219	  The built-in command line will be appended to the command-
1220	  line arguments provided during boot. This is useful in
1221	  cases where the provided arguments are insufficient and
1222	  you don't want to or cannot modify them.
1223
1224config CMDLINE_FORCE
1225	bool "Always use the default kernel command string"
1226	help
1227	  Always use the built-in command line, even if we get one during
1228	  boot. This is useful in case you need to override the provided
1229	  command line on systems where you don't have or want control
1230	  over it.
1231
1232endchoice
1233
1234config EFI_STUB
1235	bool
1236
1237config EFI
1238	bool "UEFI runtime support"
1239	depends on OF && !XIP_KERNEL
1240	depends on MMU
1241	default y
1242	select ARCH_SUPPORTS_ACPI if 64BIT
1243	select EFI_GENERIC_STUB
1244	select EFI_PARAMS_FROM_FDT
1245	select EFI_RUNTIME_WRAPPERS
1246	select EFI_STUB
1247	select LIBFDT
1248	select RISCV_ISA_C
1249	select UCS2_STRING
1250	help
1251	  This option provides support for runtime services provided
1252	  by UEFI firmware (such as non-volatile variables, realtime
1253	  clock, and platform reset). A UEFI stub is also provided to
1254	  allow the kernel to be booted as an EFI application. This
1255	  is only useful on systems that have UEFI firmware.
1256
1257config DMI
1258	bool "Enable support for SMBIOS (DMI) tables"
1259	depends on EFI
1260	default y
1261	help
1262	  This enables SMBIOS/DMI feature for systems.
1263
1264	  This option is only useful on systems that have UEFI firmware.
1265	  However, even with this option, the resultant kernel should
1266	  continue to boot on existing non-UEFI platforms.
1267
1268config CC_HAVE_STACKPROTECTOR_TLS
1269	def_bool $(cc-option,-mstack-protector-guard=tls -mstack-protector-guard-reg=tp -mstack-protector-guard-offset=0)
1270
1271config STACKPROTECTOR_PER_TASK
1272	def_bool y
1273	depends on !RANDSTRUCT
1274	depends on STACKPROTECTOR && CC_HAVE_STACKPROTECTOR_TLS
1275
1276config PHYS_RAM_BASE_FIXED
1277	bool "Explicitly specified physical RAM address"
1278	depends on NONPORTABLE
1279	default n
1280
1281config PHYS_RAM_BASE
1282	hex "Platform Physical RAM address"
1283	depends on PHYS_RAM_BASE_FIXED
1284	default "0x80000000"
1285	help
1286	  This is the physical address of RAM in the system. It has to be
1287	  explicitly specified to run early relocations of read-write data
1288	  from flash to RAM.
1289
1290config XIP_KERNEL
1291	bool "Kernel Execute-In-Place from ROM"
1292	depends on MMU && SPARSEMEM && NONPORTABLE
1293	# This prevents XIP from being enabled by all{yes,mod}config, which
1294	# fail to build since XIP doesn't support large kernels.
1295	depends on !COMPILE_TEST
1296	select PHYS_RAM_BASE_FIXED
1297	help
1298	  Execute-In-Place allows the kernel to run from non-volatile storage
1299	  directly addressable by the CPU, such as NOR flash. This saves RAM
1300	  space since the text section of the kernel is not loaded from flash
1301	  to RAM.  Read-write sections, such as the data section and stack,
1302	  are still copied to RAM.  The XIP kernel is not compressed since
1303	  it has to run directly from flash, so it will take more space to
1304	  store it.  The flash address used to link the kernel object files,
1305	  and for storing it, is configuration dependent. Therefore, if you
1306	  say Y here, you must know the proper physical address where to
1307	  store the kernel image depending on your own flash memory usage.
1308
1309	  Also note that the make target becomes "make xipImage" rather than
1310	  "make zImage" or "make Image".  The final kernel binary to put in
1311	  ROM memory will be arch/riscv/boot/xipImage.
1312
1313	  SPARSEMEM is required because the kernel text and rodata that are
1314	  flash resident are not backed by memmap, then any attempt to get
1315	  a struct page on those regions will trigger a fault.
1316
1317	  If unsure, say N.
1318
1319config XIP_PHYS_ADDR
1320	hex "XIP Kernel Physical Location"
1321	depends on XIP_KERNEL
1322	default "0x21000000"
1323	help
1324	  This is the physical address in your flash memory the kernel will
1325	  be linked for and stored to.  This address is dependent on your
1326	  own flash usage.
1327
1328config RISCV_ISA_FALLBACK
1329	bool "Permit falling back to parsing riscv,isa for extension support by default"
1330	default y
1331	help
1332	  Parsing the "riscv,isa" devicetree property has been deprecated and
1333	  replaced by a list of explicitly defined strings. For compatibility
1334	  with existing platforms, the kernel will fall back to parsing the
1335	  "riscv,isa" property if the replacements are not found.
1336
1337	  Selecting N here will result in a kernel that does not use the
1338	  fallback, unless the commandline "riscv_isa_fallback" parameter is
1339	  present.
1340
1341	  Please see the dt-binding, located at
1342	  Documentation/devicetree/bindings/riscv/extensions.yaml for details
1343	  on the replacement properties, "riscv,isa-base" and
1344	  "riscv,isa-extensions".
1345
1346config BUILTIN_DTB
1347	bool "Built-in device tree"
1348	depends on OF && NONPORTABLE
1349	select GENERIC_BUILTIN_DTB
1350	help
1351	  Build a device tree into the Linux image.
1352	  This option should be selected if no bootloader is being used.
1353	  If unsure, say N.
1354
1355
1356config BUILTIN_DTB_NAME
1357	string "Built-in device tree source"
1358	depends on BUILTIN_DTB
1359	help
1360	  DTS file path (without suffix, relative to arch/riscv/boot/dts)
1361	  for the DTS file that will be used to produce the DTB linked into the
1362	  kernel.
1363
1364endmenu # "Boot options"
1365
1366config PORTABLE
1367	bool
1368	default !NONPORTABLE
1369	select EFI
1370	select MMU
1371	select OF
1372
1373config ARCH_PROC_KCORE_TEXT
1374	def_bool y
1375
1376menu "Power management options"
1377
1378source "kernel/power/Kconfig"
1379
1380config ARCH_HIBERNATION_POSSIBLE
1381	def_bool y
1382
1383config ARCH_HIBERNATION_HEADER
1384	def_bool HIBERNATION
1385
1386config ARCH_SUSPEND_POSSIBLE
1387	def_bool y
1388
1389endmenu # "Power management options"
1390
1391menu "CPU Power Management"
1392
1393source "drivers/cpuidle/Kconfig"
1394
1395source "drivers/cpufreq/Kconfig"
1396
1397endmenu # "CPU Power Management"
1398
1399source "arch/riscv/kvm/Kconfig"
1400
1401source "drivers/acpi/Kconfig"
1402