xref: /linux/arch/riscv/Kconfig (revision 5a48b7433a5aee719ab242d2feadaf4c9e065989)
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_CLOCKSOURCE_INIT
16	select ARCH_ENABLE_HUGEPAGE_MIGRATION if HUGETLB_PAGE && MIGRATION
17	select ARCH_ENABLE_SPLIT_PMD_PTLOCK if PGTABLE_LEVELS > 2
18	select ARCH_HAS_BINFMT_FLAT
19	select ARCH_HAS_DEBUG_VM_PGTABLE
20	select ARCH_HAS_DEBUG_VIRTUAL if MMU
21	select ARCH_HAS_DEBUG_WX
22	select ARCH_HAS_FORTIFY_SOURCE
23	select ARCH_HAS_GCOV_PROFILE_ALL
24	select ARCH_HAS_GIGANTIC_PAGE
25	select ARCH_HAS_KCOV
26	select ARCH_HAS_MMIOWB
27	select ARCH_HAS_PTE_SPECIAL
28	select ARCH_HAS_SET_DIRECT_MAP if MMU
29	select ARCH_HAS_SET_MEMORY if MMU
30	select ARCH_HAS_STRICT_KERNEL_RWX if MMU && !XIP_KERNEL
31	select ARCH_HAS_STRICT_MODULE_RWX if MMU && !XIP_KERNEL
32	select ARCH_HAS_TICK_BROADCAST if GENERIC_CLOCKEVENTS_BROADCAST
33	select ARCH_HAS_UBSAN_SANITIZE_ALL
34	select ARCH_OPTIONAL_KERNEL_RWX if ARCH_HAS_STRICT_KERNEL_RWX
35	select ARCH_OPTIONAL_KERNEL_RWX_DEFAULT
36	select ARCH_STACKWALK
37	select ARCH_SUPPORTS_ATOMIC_RMW
38	select ARCH_SUPPORTS_DEBUG_PAGEALLOC if MMU
39	select ARCH_SUPPORTS_HUGETLBFS if MMU
40	select ARCH_USE_MEMTEST
41	select ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT if MMU
42	select ARCH_WANT_FRAME_POINTERS
43	select ARCH_WANT_GENERAL_HUGETLB
44	select ARCH_WANT_HUGE_PMD_SHARE if 64BIT
45	select BINFMT_FLAT_NO_DATA_START_OFFSET if !MMU
46	select BUILDTIME_TABLE_SORT if MMU
47	select CLONE_BACKWARDS
48	select CLINT_TIMER if !MMU
49	select COMMON_CLK
50	select EDAC_SUPPORT
51	select GENERIC_ARCH_TOPOLOGY if SMP
52	select GENERIC_ATOMIC64 if !64BIT
53	select GENERIC_CLOCKEVENTS_BROADCAST if SMP
54	select GENERIC_EARLY_IOREMAP
55	select GENERIC_GETTIMEOFDAY if HAVE_GENERIC_VDSO
56	select GENERIC_IDLE_POLL_SETUP
57	select GENERIC_IOREMAP if MMU
58	select GENERIC_IRQ_MULTI_HANDLER
59	select GENERIC_IRQ_SHOW
60	select GENERIC_IRQ_SHOW_LEVEL
61	select GENERIC_LIB_DEVMEM_IS_ALLOWED
62	select GENERIC_PCI_IOMAP
63	select GENERIC_PTDUMP if MMU
64	select GENERIC_SCHED_CLOCK
65	select GENERIC_SMP_IDLE_THREAD
66	select GENERIC_TIME_VSYSCALL if MMU && 64BIT
67	select GENERIC_VDSO_TIME_NS if HAVE_GENERIC_VDSO
68	select HAVE_ARCH_AUDITSYSCALL
69	select HAVE_ARCH_JUMP_LABEL if !XIP_KERNEL
70	select HAVE_ARCH_JUMP_LABEL_RELATIVE if !XIP_KERNEL
71	select HAVE_ARCH_KASAN if MMU && 64BIT
72	select HAVE_ARCH_KASAN_VMALLOC if MMU && 64BIT
73	select HAVE_ARCH_KFENCE if MMU && 64BIT
74	select HAVE_ARCH_KGDB if !XIP_KERNEL
75	select HAVE_ARCH_KGDB_QXFER_PKT
76	select HAVE_ARCH_MMAP_RND_BITS if MMU
77	select HAVE_ARCH_SECCOMP_FILTER
78	select HAVE_ARCH_TRACEHOOK
79	select HAVE_ARCH_TRANSPARENT_HUGEPAGE if 64BIT && MMU
80	select ARCH_ENABLE_THP_MIGRATION if TRANSPARENT_HUGEPAGE
81	select HAVE_ARCH_THREAD_STRUCT_WHITELIST
82	select HAVE_ARCH_VMAP_STACK if MMU && 64BIT
83	select HAVE_ASM_MODVERSIONS
84	select HAVE_CONTEXT_TRACKING
85	select HAVE_DEBUG_KMEMLEAK
86	select HAVE_DMA_CONTIGUOUS if MMU
87	select HAVE_EBPF_JIT if MMU
88	select HAVE_FUNCTION_ERROR_INJECTION
89	select HAVE_GCC_PLUGINS
90	select HAVE_GENERIC_VDSO if MMU && 64BIT
91	select HAVE_IRQ_TIME_ACCOUNTING
92	select HAVE_KPROBES if !XIP_KERNEL
93	select HAVE_KPROBES_ON_FTRACE if !XIP_KERNEL
94	select HAVE_KRETPROBES if !XIP_KERNEL
95	select HAVE_MOVE_PMD
96	select HAVE_MOVE_PUD
97	select HAVE_PCI
98	select HAVE_PERF_EVENTS
99	select HAVE_PERF_REGS
100	select HAVE_PERF_USER_STACK_DUMP
101	select HAVE_REGS_AND_STACK_ACCESS_API
102	select HAVE_FUNCTION_ARG_ACCESS_API
103	select HAVE_STACKPROTECTOR
104	select HAVE_SYSCALL_TRACEPOINTS
105	select HAVE_RSEQ
106	select IRQ_DOMAIN
107	select IRQ_FORCED_THREADING
108	select MODULES_USE_ELF_RELA if MODULES
109	select MODULE_SECTIONS if MODULES
110	select OF
111	select OF_EARLY_FLATTREE
112	select OF_IRQ
113	select PCI_DOMAINS_GENERIC if PCI
114	select PCI_MSI if PCI
115	select RISCV_INTC
116	select RISCV_TIMER if RISCV_SBI
117	select SPARSE_IRQ
118	select SYSCTL_EXCEPTION_TRACE
119	select THREAD_INFO_IN_TASK
120	select TRACE_IRQFLAGS_SUPPORT
121	select UACCESS_MEMCPY if !MMU
122	select ZONE_DMA32 if 64BIT
123
124config ARCH_MMAP_RND_BITS_MIN
125	default 18 if 64BIT
126	default 8
127
128# max bits determined by the following formula:
129#  VA_BITS - PAGE_SHIFT - 3
130config ARCH_MMAP_RND_BITS_MAX
131	default 24 if 64BIT # SV39 based
132	default 17
133
134# set if we run in machine mode, cleared if we run in supervisor mode
135config RISCV_M_MODE
136	bool
137	default !MMU
138
139# set if we are running in S-mode and can use SBI calls
140config RISCV_SBI
141	bool
142	depends on !RISCV_M_MODE
143	default y
144
145config MMU
146	bool "MMU-based Paged Memory Management Support"
147	default y
148	help
149	  Select if you want MMU-based virtualised addressing space
150	  support by paged memory management. If unsure, say 'Y'.
151
152config PAGE_OFFSET
153	hex
154	default 0xC0000000 if 32BIT
155	default 0x80000000 if 64BIT && !MMU
156	default 0xff60000000000000 if 64BIT
157
158config KASAN_SHADOW_OFFSET
159	hex
160	depends on KASAN_GENERIC
161	default 0xdfffffff00000000 if 64BIT
162	default 0xffffffff if 32BIT
163
164config ARCH_FLATMEM_ENABLE
165	def_bool !NUMA
166
167config ARCH_SPARSEMEM_ENABLE
168	def_bool y
169	depends on MMU
170	select SPARSEMEM_STATIC if 32BIT && SPARSEMEM
171	select SPARSEMEM_VMEMMAP_ENABLE if 64BIT
172
173config ARCH_SELECT_MEMORY_MODEL
174	def_bool ARCH_SPARSEMEM_ENABLE
175
176config ARCH_SUPPORTS_UPROBES
177	def_bool y
178
179config STACKTRACE_SUPPORT
180	def_bool y
181
182config GENERIC_BUG
183	def_bool y
184	depends on BUG
185	select GENERIC_BUG_RELATIVE_POINTERS if 64BIT
186
187config GENERIC_BUG_RELATIVE_POINTERS
188	bool
189
190config GENERIC_CALIBRATE_DELAY
191	def_bool y
192
193config GENERIC_CSUM
194	def_bool y
195
196config GENERIC_HWEIGHT
197	def_bool y
198
199config FIX_EARLYCON_MEM
200	def_bool MMU
201
202config PGTABLE_LEVELS
203	int
204	default 5 if 64BIT
205	default 2
206
207config LOCKDEP_SUPPORT
208	def_bool y
209
210source "arch/riscv/Kconfig.socs"
211source "arch/riscv/Kconfig.erratas"
212
213menu "Platform type"
214
215choice
216	prompt "Base ISA"
217	default ARCH_RV64I
218	help
219	  This selects the base ISA that this kernel will target and must match
220	  the target platform.
221
222config ARCH_RV32I
223	bool "RV32I"
224	select 32BIT
225	select GENERIC_LIB_ASHLDI3
226	select GENERIC_LIB_ASHRDI3
227	select GENERIC_LIB_LSHRDI3
228	select GENERIC_LIB_UCMPDI2
229	select MMU
230
231config ARCH_RV64I
232	bool "RV64I"
233	select 64BIT
234	select ARCH_SUPPORTS_INT128 if CC_HAS_INT128
235	select HAVE_DYNAMIC_FTRACE if !XIP_KERNEL && MMU && $(cc-option,-fpatchable-function-entry=8)
236	select HAVE_DYNAMIC_FTRACE_WITH_REGS if HAVE_DYNAMIC_FTRACE
237	select HAVE_FTRACE_MCOUNT_RECORD if !XIP_KERNEL
238	select HAVE_FUNCTION_GRAPH_TRACER
239	select HAVE_FUNCTION_TRACER if !XIP_KERNEL
240	select SWIOTLB if MMU
241
242endchoice
243
244# We must be able to map all physical memory into the kernel, but the compiler
245# is still a bit more efficient when generating code if it's setup in a manner
246# such that it can only map 2GiB of memory.
247choice
248	prompt "Kernel Code Model"
249	default CMODEL_MEDLOW if 32BIT
250	default CMODEL_MEDANY if 64BIT
251
252	config CMODEL_MEDLOW
253		bool "medium low code model"
254	config CMODEL_MEDANY
255		bool "medium any code model"
256endchoice
257
258config MODULE_SECTIONS
259	bool
260	select HAVE_MOD_ARCH_SPECIFIC
261
262config SMP
263	bool "Symmetric Multi-Processing"
264	help
265	  This enables support for systems with more than one CPU.  If
266	  you say N here, the kernel will run on single and
267	  multiprocessor machines, but will use only one CPU of a
268	  multiprocessor machine. If you say Y here, the kernel will run
269	  on many, but not all, single processor machines. On a single
270	  processor machine, the kernel will run faster if you say N
271	  here.
272
273	  If you don't know what to do here, say N.
274
275config NR_CPUS
276	int "Maximum number of CPUs (2-32)"
277	range 2 32
278	depends on SMP
279	default "8"
280
281config HOTPLUG_CPU
282	bool "Support for hot-pluggable CPUs"
283	depends on SMP
284	select GENERIC_IRQ_MIGRATION
285	help
286
287	  Say Y here to experiment with turning CPUs off and on.  CPUs
288	  can be controlled through /sys/devices/system/cpu.
289
290	  Say N if you want to disable CPU hotplug.
291
292choice
293	prompt "CPU Tuning"
294	default TUNE_GENERIC
295
296config TUNE_GENERIC
297	bool "generic"
298
299endchoice
300
301# Common NUMA Features
302config NUMA
303	bool "NUMA Memory Allocation and Scheduler Support"
304	depends on SMP && MMU
305	select GENERIC_ARCH_NUMA
306	select OF_NUMA
307	select ARCH_SUPPORTS_NUMA_BALANCING
308	select USE_PERCPU_NUMA_NODE_ID
309	select NEED_PER_CPU_EMBED_FIRST_CHUNK
310	help
311	  Enable NUMA (Non-Uniform Memory Access) support.
312
313	  The kernel will try to allocate memory used by a CPU on the
314	  local memory of the CPU and add some more NUMA awareness to the kernel.
315
316config NODES_SHIFT
317	int "Maximum NUMA Nodes (as a power of 2)"
318	range 1 10
319	default "2"
320	depends on NUMA
321	help
322	  Specify the maximum number of NUMA Nodes available on the target
323	  system.  Increases memory reserved to accommodate various tables.
324
325config RISCV_ISA_C
326	bool "Emit compressed instructions when building Linux"
327	default y
328	help
329	   Adds "C" to the ISA subsets that the toolchain is allowed to emit
330	   when building Linux, which results in compressed instructions in the
331	   Linux binary.
332
333	   If you don't know what to do here, say Y.
334
335config FPU
336	bool "FPU support"
337	default y
338	help
339	  Say N here if you want to disable all floating-point related procedure
340	  in the kernel.
341
342	  If you don't know what to do here, say Y.
343
344endmenu
345
346menu "Kernel features"
347
348source "kernel/Kconfig.hz"
349
350config RISCV_SBI_V01
351	bool "SBI v0.1 support"
352	depends on RISCV_SBI
353	help
354	  This config allows kernel to use SBI v0.1 APIs. This will be
355	  deprecated in future once legacy M-mode software are no longer in use.
356
357config RISCV_BOOT_SPINWAIT
358	bool "Spinwait booting method"
359	depends on SMP
360	default y
361	help
362	  This enables support for booting Linux via spinwait method. In the
363	  spinwait method, all cores randomly jump to Linux. One of the cores
364	  gets chosen via lottery and all other keep spinning on a percpu
365	  variable. This method cannot support CPU hotplug and sparse hartid
366	  scheme. It should be only enabled for M-mode Linux or platforms relying
367	  on older firmware without SBI HSM extension. All other platforms should
368	  rely on ordered booting via SBI HSM extension which gets chosen
369	  dynamically at runtime if the firmware supports it.
370
371config KEXEC
372	bool "Kexec system call"
373	select KEXEC_CORE
374	select HOTPLUG_CPU if SMP
375	depends on MMU
376	help
377	  kexec is a system call that implements the ability to shutdown your
378	  current kernel, and to start another kernel. It is like a reboot
379	  but it is independent of the system firmware. And like a reboot
380	  you can start any kernel with it, not just Linux.
381
382	  The name comes from the similarity to the exec system call.
383
384config CRASH_DUMP
385	bool "Build kdump crash kernel"
386	help
387	  Generate crash dump after being started by kexec. This should
388	  be normally only set in special crash dump kernels which are
389	  loaded in the main kernel with kexec-tools into a specially
390	  reserved region and then later executed after a crash by
391	  kdump/kexec.
392
393	  For more details see Documentation/admin-guide/kdump/kdump.rst
394
395endmenu
396
397menu "Boot options"
398
399config CMDLINE
400	string "Built-in kernel command line"
401	help
402	  For most platforms, the arguments for the kernel's command line
403	  are provided at run-time, during boot. However, there are cases
404	  where either no arguments are being provided or the provided
405	  arguments are insufficient or even invalid.
406
407	  When that occurs, it is possible to define a built-in command
408	  line here and choose how the kernel should use it later on.
409
410choice
411	prompt "Built-in command line usage" if CMDLINE != ""
412	default CMDLINE_FALLBACK
413	help
414	  Choose how the kernel will handle the provided built-in command
415	  line.
416
417config CMDLINE_FALLBACK
418	bool "Use bootloader kernel arguments if available"
419	help
420	  Use the built-in command line as fallback in case we get nothing
421	  during boot. This is the default behaviour.
422
423config CMDLINE_EXTEND
424	bool "Extend bootloader kernel arguments"
425	help
426	  The command-line arguments provided during boot will be
427	  appended to the built-in command line. This is useful in
428	  cases where the provided arguments are insufficient and
429	  you don't want to or cannot modify them.
430
431
432config CMDLINE_FORCE
433	bool "Always use the default kernel command string"
434	help
435	  Always use the built-in command line, even if we get one during
436	  boot. This is useful in case you need to override the provided
437	  command line on systems where you don't have or want control
438	  over it.
439
440endchoice
441
442config EFI_STUB
443	bool
444
445config EFI
446	bool "UEFI runtime support"
447	depends on OF && !XIP_KERNEL
448	select LIBFDT
449	select UCS2_STRING
450	select EFI_PARAMS_FROM_FDT
451	select EFI_STUB
452	select EFI_GENERIC_STUB
453	select EFI_RUNTIME_WRAPPERS
454	select RISCV_ISA_C
455	depends on MMU
456	default y
457	help
458	  This option provides support for runtime services provided
459	  by UEFI firmware (such as non-volatile variables, realtime
460	  clock, and platform reset). A UEFI stub is also provided to
461	  allow the kernel to be booted as an EFI application. This
462	  is only useful on systems that have UEFI firmware.
463
464config CC_HAVE_STACKPROTECTOR_TLS
465	def_bool $(cc-option,-mstack-protector-guard=tls -mstack-protector-guard-reg=tp -mstack-protector-guard-offset=0)
466
467config STACKPROTECTOR_PER_TASK
468	def_bool y
469	depends on !GCC_PLUGIN_RANDSTRUCT
470	depends on STACKPROTECTOR && CC_HAVE_STACKPROTECTOR_TLS
471
472config PHYS_RAM_BASE_FIXED
473	bool "Explicitly specified physical RAM address"
474	default n
475
476config PHYS_RAM_BASE
477	hex "Platform Physical RAM address"
478	depends on PHYS_RAM_BASE_FIXED
479	default "0x80000000"
480	help
481	  This is the physical address of RAM in the system. It has to be
482	  explicitly specified to run early relocations of read-write data
483	  from flash to RAM.
484
485config XIP_KERNEL
486	bool "Kernel Execute-In-Place from ROM"
487	depends on MMU && SPARSEMEM
488	# This prevents XIP from being enabled by all{yes,mod}config, which
489	# fail to build since XIP doesn't support large kernels.
490	depends on !COMPILE_TEST
491	select PHYS_RAM_BASE_FIXED
492	help
493	  Execute-In-Place allows the kernel to run from non-volatile storage
494	  directly addressable by the CPU, such as NOR flash. This saves RAM
495	  space since the text section of the kernel is not loaded from flash
496	  to RAM.  Read-write sections, such as the data section and stack,
497	  are still copied to RAM.  The XIP kernel is not compressed since
498	  it has to run directly from flash, so it will take more space to
499	  store it.  The flash address used to link the kernel object files,
500	  and for storing it, is configuration dependent. Therefore, if you
501	  say Y here, you must know the proper physical address where to
502	  store the kernel image depending on your own flash memory usage.
503
504	  Also note that the make target becomes "make xipImage" rather than
505	  "make zImage" or "make Image".  The final kernel binary to put in
506	  ROM memory will be arch/riscv/boot/xipImage.
507
508	  SPARSEMEM is required because the kernel text and rodata that are
509	  flash resident are not backed by memmap, then any attempt to get
510	  a struct page on those regions will trigger a fault.
511
512	  If unsure, say N.
513
514config XIP_PHYS_ADDR
515	hex "XIP Kernel Physical Location"
516	depends on XIP_KERNEL
517	default "0x21000000"
518	help
519	  This is the physical address in your flash memory the kernel will
520	  be linked for and stored to.  This address is dependent on your
521	  own flash usage.
522
523endmenu
524
525config BUILTIN_DTB
526	bool
527	depends on OF
528	default y if XIP_KERNEL
529
530menu "Power management options"
531
532source "kernel/power/Kconfig"
533
534endmenu
535
536source "arch/riscv/kvm/Kconfig"
537