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