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