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