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