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