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