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