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