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