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