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_REDUCED_HARDWARE_ONLY if ACPI 17 select ARCH_DMA_DEFAULT_COHERENT 18 select ARCH_ENABLE_HUGEPAGE_MIGRATION if HUGETLB_PAGE && MIGRATION 19 select ARCH_ENABLE_SPLIT_PMD_PTLOCK if PGTABLE_LEVELS > 2 20 select ARCH_ENABLE_THP_MIGRATION if TRANSPARENT_HUGEPAGE 21 select ARCH_HAS_BINFMT_FLAT 22 select ARCH_HAS_CURRENT_STACK_POINTER 23 select ARCH_HAS_DEBUG_VIRTUAL if MMU 24 select ARCH_HAS_DEBUG_VM_PGTABLE 25 select ARCH_HAS_DEBUG_WX 26 select ARCH_HAS_FAST_MULTIPLIER 27 select ARCH_HAS_FORTIFY_SOURCE 28 select ARCH_HAS_GCOV_PROFILE_ALL 29 select ARCH_HAS_GIGANTIC_PAGE 30 select ARCH_HAS_KCOV 31 select ARCH_HAS_KERNEL_FPU_SUPPORT if 64BIT && FPU 32 select ARCH_HAS_MEMBARRIER_CALLBACKS 33 select ARCH_HAS_MEMBARRIER_SYNC_CORE 34 select ARCH_HAS_MMIOWB 35 select ARCH_HAS_NON_OVERLAPPING_ADDRESS_SPACE 36 select ARCH_HAS_PMEM_API 37 select ARCH_HAS_PREPARE_SYNC_CORE_CMD 38 select ARCH_HAS_PTE_SPECIAL 39 select ARCH_HAS_SET_DIRECT_MAP if MMU 40 select ARCH_HAS_SET_MEMORY if MMU 41 select ARCH_HAS_STRICT_KERNEL_RWX if MMU && !XIP_KERNEL 42 select ARCH_HAS_STRICT_MODULE_RWX if MMU && !XIP_KERNEL 43 select ARCH_HAS_SYNC_CORE_BEFORE_USERMODE 44 select ARCH_HAS_SYSCALL_WRAPPER 45 select ARCH_HAS_TICK_BROADCAST if GENERIC_CLOCKEVENTS_BROADCAST 46 select ARCH_HAS_UBSAN 47 select ARCH_HAS_VDSO_DATA 48 select ARCH_KEEP_MEMBLOCK if ACPI 49 select ARCH_OPTIONAL_KERNEL_RWX if ARCH_HAS_STRICT_KERNEL_RWX 50 select ARCH_OPTIONAL_KERNEL_RWX_DEFAULT 51 select ARCH_STACKWALK 52 select ARCH_SUPPORTS_ATOMIC_RMW 53 select ARCH_SUPPORTS_CFI_CLANG 54 select ARCH_SUPPORTS_DEBUG_PAGEALLOC if MMU 55 select ARCH_SUPPORTS_HUGETLBFS if MMU 56 # LLD >= 14: https://github.com/llvm/llvm-project/issues/50505 57 select ARCH_SUPPORTS_LTO_CLANG if LLD_VERSION >= 140000 58 select ARCH_SUPPORTS_LTO_CLANG_THIN if LLD_VERSION >= 140000 59 select ARCH_SUPPORTS_PAGE_TABLE_CHECK if MMU 60 select ARCH_SUPPORTS_PER_VMA_LOCK if MMU 61 select ARCH_SUPPORTS_SHADOW_CALL_STACK if HAVE_SHADOW_CALL_STACK 62 select ARCH_USE_CMPXCHG_LOCKREF if 64BIT 63 select ARCH_USE_MEMTEST 64 select ARCH_USE_QUEUED_RWLOCKS 65 select ARCH_USES_CFI_TRAPS if CFI_CLANG 66 select ARCH_WANT_BATCHED_UNMAP_TLB_FLUSH if MMU 67 select ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT if MMU 68 select ARCH_WANT_FRAME_POINTERS 69 select ARCH_WANT_GENERAL_HUGETLB if !RISCV_ISA_SVNAPOT 70 select ARCH_WANT_HUGE_PMD_SHARE if 64BIT 71 select ARCH_WANT_LD_ORPHAN_WARN if !XIP_KERNEL 72 select ARCH_WANT_OPTIMIZE_HUGETLB_VMEMMAP 73 select ARCH_WANTS_NO_INSTR 74 select ARCH_WANTS_THP_SWAP if HAVE_ARCH_TRANSPARENT_HUGEPAGE 75 select BINFMT_FLAT_NO_DATA_START_OFFSET if !MMU 76 select BUILDTIME_TABLE_SORT if MMU 77 select CLINT_TIMER if RISCV_M_MODE 78 select CLONE_BACKWARDS 79 select COMMON_CLK 80 select CPU_PM if CPU_IDLE || HIBERNATION || SUSPEND 81 select EDAC_SUPPORT 82 select FRAME_POINTER if PERF_EVENTS || (FUNCTION_TRACER && !DYNAMIC_FTRACE) 83 select FTRACE_MCOUNT_USE_PATCHABLE_FUNCTION_ENTRY if DYNAMIC_FTRACE 84 select GENERIC_ARCH_TOPOLOGY 85 select GENERIC_ATOMIC64 if !64BIT 86 select GENERIC_CLOCKEVENTS_BROADCAST if SMP 87 select GENERIC_CPU_DEVICES 88 select GENERIC_EARLY_IOREMAP 89 select GENERIC_ENTRY 90 select GENERIC_GETTIMEOFDAY if HAVE_GENERIC_VDSO 91 select GENERIC_IDLE_POLL_SETUP 92 select GENERIC_IOREMAP if MMU 93 select GENERIC_IRQ_IPI if SMP 94 select GENERIC_IRQ_IPI_MUX if SMP 95 select GENERIC_IRQ_MULTI_HANDLER 96 select GENERIC_IRQ_SHOW 97 select GENERIC_IRQ_SHOW_LEVEL 98 select GENERIC_LIB_DEVMEM_IS_ALLOWED 99 select GENERIC_PCI_IOMAP 100 select GENERIC_PTDUMP if MMU 101 select GENERIC_SCHED_CLOCK 102 select GENERIC_SMP_IDLE_THREAD 103 select GENERIC_TIME_VSYSCALL if MMU && 64BIT 104 select GENERIC_VDSO_TIME_NS if HAVE_GENERIC_VDSO 105 select HARDIRQS_SW_RESEND 106 select HAS_IOPORT if MMU 107 select HAVE_ARCH_AUDITSYSCALL 108 select HAVE_ARCH_HUGE_VMALLOC if HAVE_ARCH_HUGE_VMAP 109 select HAVE_ARCH_HUGE_VMAP if MMU && 64BIT 110 select HAVE_ARCH_JUMP_LABEL if !XIP_KERNEL 111 select HAVE_ARCH_JUMP_LABEL_RELATIVE if !XIP_KERNEL 112 select HAVE_ARCH_KASAN if MMU && 64BIT 113 select HAVE_ARCH_KASAN_VMALLOC if MMU && 64BIT 114 select HAVE_ARCH_KFENCE if MMU && 64BIT 115 select HAVE_ARCH_KGDB if !XIP_KERNEL 116 select HAVE_ARCH_KGDB_QXFER_PKT 117 select HAVE_ARCH_MMAP_RND_BITS if MMU 118 select HAVE_ARCH_MMAP_RND_COMPAT_BITS if COMPAT 119 select HAVE_ARCH_RANDOMIZE_KSTACK_OFFSET 120 select HAVE_ARCH_SECCOMP_FILTER 121 select HAVE_ARCH_THREAD_STRUCT_WHITELIST 122 select HAVE_ARCH_TRACEHOOK 123 select HAVE_ARCH_TRANSPARENT_HUGEPAGE if 64BIT && MMU 124 select HAVE_ARCH_USERFAULTFD_MINOR if 64BIT && USERFAULTFD 125 select HAVE_ARCH_VMAP_STACK if MMU && 64BIT 126 select HAVE_ASM_MODVERSIONS 127 select HAVE_CONTEXT_TRACKING_USER 128 select HAVE_DEBUG_KMEMLEAK 129 select HAVE_DMA_CONTIGUOUS if MMU 130 select HAVE_DYNAMIC_FTRACE if !XIP_KERNEL && MMU && (CLANG_SUPPORTS_DYNAMIC_FTRACE || GCC_SUPPORTS_DYNAMIC_FTRACE) 131 select HAVE_DYNAMIC_FTRACE_WITH_DIRECT_CALLS 132 select HAVE_DYNAMIC_FTRACE_WITH_ARGS if HAVE_DYNAMIC_FTRACE 133 select HAVE_FTRACE_MCOUNT_RECORD if !XIP_KERNEL 134 select HAVE_FUNCTION_GRAPH_TRACER 135 select HAVE_FUNCTION_GRAPH_RETVAL if HAVE_FUNCTION_GRAPH_TRACER 136 select HAVE_FUNCTION_TRACER if !XIP_KERNEL && !PREEMPTION 137 select HAVE_EBPF_JIT if MMU 138 select HAVE_GUP_FAST if MMU 139 select HAVE_FUNCTION_ARG_ACCESS_API 140 select HAVE_FUNCTION_ERROR_INJECTION 141 select HAVE_GCC_PLUGINS 142 select HAVE_GENERIC_VDSO if MMU && 64BIT 143 select HAVE_IRQ_TIME_ACCOUNTING 144 select HAVE_KERNEL_BZIP2 if !XIP_KERNEL && !EFI_ZBOOT 145 select HAVE_KERNEL_GZIP if !XIP_KERNEL && !EFI_ZBOOT 146 select HAVE_KERNEL_LZ4 if !XIP_KERNEL && !EFI_ZBOOT 147 select HAVE_KERNEL_LZMA if !XIP_KERNEL && !EFI_ZBOOT 148 select HAVE_KERNEL_LZO if !XIP_KERNEL && !EFI_ZBOOT 149 select HAVE_KERNEL_UNCOMPRESSED if !XIP_KERNEL && !EFI_ZBOOT 150 select HAVE_KERNEL_ZSTD if !XIP_KERNEL && !EFI_ZBOOT 151 select HAVE_KPROBES if !XIP_KERNEL 152 select HAVE_KPROBES_ON_FTRACE if !XIP_KERNEL 153 select HAVE_KRETPROBES if !XIP_KERNEL 154 # https://github.com/ClangBuiltLinux/linux/issues/1881 155 select HAVE_LD_DEAD_CODE_DATA_ELIMINATION if !LD_IS_LLD 156 select HAVE_MOVE_PMD 157 select HAVE_MOVE_PUD 158 select HAVE_PAGE_SIZE_4KB 159 select HAVE_PCI 160 select HAVE_PERF_EVENTS 161 select HAVE_PERF_REGS 162 select HAVE_PERF_USER_STACK_DUMP 163 select HAVE_POSIX_CPU_TIMERS_TASK_WORK 164 select HAVE_PREEMPT_DYNAMIC_KEY if !XIP_KERNEL 165 select HAVE_REGS_AND_STACK_ACCESS_API 166 select HAVE_RETHOOK if !XIP_KERNEL 167 select HAVE_RSEQ 168 select HAVE_RUST if 64BIT 169 select HAVE_SAMPLE_FTRACE_DIRECT 170 select HAVE_SAMPLE_FTRACE_DIRECT_MULTI 171 select HAVE_STACKPROTECTOR 172 select HAVE_SYSCALL_TRACEPOINTS 173 select HOTPLUG_CORE_SYNC_DEAD if HOTPLUG_CPU 174 select IRQ_DOMAIN 175 select IRQ_FORCED_THREADING 176 select KASAN_VMALLOC if KASAN 177 select LOCK_MM_AND_FIND_VMA 178 select MMU_GATHER_RCU_TABLE_FREE if SMP && MMU 179 select MODULES_USE_ELF_RELA if MODULES 180 select OF 181 select OF_EARLY_FLATTREE 182 select OF_IRQ 183 select PCI_DOMAINS_GENERIC if PCI 184 select PCI_MSI if PCI 185 select RISCV_ALTERNATIVE if !XIP_KERNEL 186 select RISCV_APLIC 187 select RISCV_IMSIC 188 select RISCV_INTC 189 select RISCV_TIMER if RISCV_SBI 190 select SIFIVE_PLIC 191 select SPARSE_IRQ 192 select SYSCTL_EXCEPTION_TRACE 193 select THREAD_INFO_IN_TASK 194 select TRACE_IRQFLAGS_SUPPORT 195 select UACCESS_MEMCPY if !MMU 196 select ZONE_DMA32 if 64BIT 197 198config CLANG_SUPPORTS_DYNAMIC_FTRACE 199 def_bool CC_IS_CLANG 200 # https://github.com/ClangBuiltLinux/linux/issues/1817 201 depends on AS_IS_GNU || (AS_IS_LLVM && (LD_IS_LLD || LD_VERSION >= 23600)) 202 203config GCC_SUPPORTS_DYNAMIC_FTRACE 204 def_bool CC_IS_GCC 205 depends on $(cc-option,-fpatchable-function-entry=8) 206 207config HAVE_SHADOW_CALL_STACK 208 def_bool $(cc-option,-fsanitize=shadow-call-stack) 209 # https://github.com/riscv-non-isa/riscv-elf-psabi-doc/commit/a484e843e6eeb51f0cb7b8819e50da6d2444d769 210 depends on $(ld-option,--no-relax-gp) 211 212config RISCV_USE_LINKER_RELAXATION 213 def_bool y 214 # https://github.com/llvm/llvm-project/commit/6611d58f5bbcbec77262d392e2923e1d680f6985 215 depends on !LD_IS_LLD || LLD_VERSION >= 150000 216 217# https://github.com/llvm/llvm-project/commit/bbc0f99f3bc96f1db16f649fc21dd18e5b0918f6 218config ARCH_HAS_BROKEN_DWARF5 219 def_bool y 220 depends on RISCV_USE_LINKER_RELAXATION 221 # https://github.com/llvm/llvm-project/commit/1df5ea29b43690b6622db2cad7b745607ca4de6a 222 depends on AS_IS_LLVM && AS_VERSION < 180000 223 # https://github.com/llvm/llvm-project/commit/7ffabb61a5569444b5ac9322e22e5471cc5e4a77 224 depends on LD_IS_LLD && LLD_VERSION < 180000 225 226config ARCH_MMAP_RND_BITS_MIN 227 default 18 if 64BIT 228 default 8 229 230config ARCH_MMAP_RND_COMPAT_BITS_MIN 231 default 8 232 233# max bits determined by the following formula: 234# VA_BITS - PAGE_SHIFT - 3 235config ARCH_MMAP_RND_BITS_MAX 236 default 24 if 64BIT # SV39 based 237 default 17 238 239config ARCH_MMAP_RND_COMPAT_BITS_MAX 240 default 17 241 242# set if we run in machine mode, cleared if we run in supervisor mode 243config RISCV_M_MODE 244 bool "Build a kernel that runs in machine mode" 245 depends on !MMU 246 default y 247 help 248 Select this option if you want to run the kernel in M-mode, 249 without the assistance of any other firmware. 250 251# set if we are running in S-mode and can use SBI calls 252config RISCV_SBI 253 bool 254 depends on !RISCV_M_MODE 255 default y 256 257config MMU 258 bool "MMU-based Paged Memory Management Support" 259 default y 260 help 261 Select if you want MMU-based virtualised addressing space 262 support by paged memory management. If unsure, say 'Y'. 263 264config PAGE_OFFSET 265 hex 266 default 0x80000000 if !MMU && RISCV_M_MODE 267 default 0x80200000 if !MMU 268 default 0xc0000000 if 32BIT 269 default 0xff60000000000000 if 64BIT 270 271config KASAN_SHADOW_OFFSET 272 hex 273 depends on KASAN_GENERIC 274 default 0xdfffffff00000000 if 64BIT 275 default 0xffffffff if 32BIT 276 277config ARCH_FLATMEM_ENABLE 278 def_bool !NUMA 279 280config ARCH_SPARSEMEM_ENABLE 281 def_bool y 282 depends on MMU 283 select SPARSEMEM_STATIC if 32BIT && SPARSEMEM 284 select SPARSEMEM_VMEMMAP_ENABLE if 64BIT 285 286config ARCH_SELECT_MEMORY_MODEL 287 def_bool ARCH_SPARSEMEM_ENABLE 288 289config ARCH_SUPPORTS_UPROBES 290 def_bool y 291 292config STACKTRACE_SUPPORT 293 def_bool y 294 295config GENERIC_BUG 296 def_bool y 297 depends on BUG 298 select GENERIC_BUG_RELATIVE_POINTERS if 64BIT 299 300config GENERIC_BUG_RELATIVE_POINTERS 301 bool 302 303config GENERIC_CALIBRATE_DELAY 304 def_bool y 305 306config GENERIC_CSUM 307 def_bool y 308 309config GENERIC_HWEIGHT 310 def_bool y 311 312config FIX_EARLYCON_MEM 313 def_bool MMU 314 315config PGTABLE_LEVELS 316 int 317 default 5 if 64BIT 318 default 2 319 320config LOCKDEP_SUPPORT 321 def_bool y 322 323config RISCV_DMA_NONCOHERENT 324 bool 325 select ARCH_HAS_DMA_PREP_COHERENT 326 select ARCH_HAS_SETUP_DMA_OPS 327 select ARCH_HAS_SYNC_DMA_FOR_CPU 328 select ARCH_HAS_SYNC_DMA_FOR_DEVICE 329 select DMA_BOUNCE_UNALIGNED_KMALLOC if SWIOTLB 330 331config RISCV_NONSTANDARD_CACHE_OPS 332 bool 333 help 334 This enables function pointer support for non-standard noncoherent 335 systems to handle cache management. 336 337config AS_HAS_INSN 338 def_bool $(as-instr,.insn r 51$(comma) 0$(comma) 0$(comma) t0$(comma) t0$(comma) zero) 339 340config AS_HAS_OPTION_ARCH 341 # https://github.com/llvm/llvm-project/commit/9e8ed3403c191ab9c4903e8eeb8f732ff8a43cb4 342 def_bool y 343 depends on $(as-instr, .option arch$(comma) +m) 344 345source "arch/riscv/Kconfig.socs" 346source "arch/riscv/Kconfig.errata" 347 348menu "Platform type" 349 350config NONPORTABLE 351 bool "Allow configurations that result in non-portable kernels" 352 help 353 RISC-V kernel binaries are compatible between all known systems 354 whenever possible, but there are some use cases that can only be 355 satisfied by configurations that result in kernel binaries that are 356 not portable between systems. 357 358 Selecting N does not guarantee kernels will be portable to all known 359 systems. Selecting any of the options guarded by NONPORTABLE will 360 result in kernel binaries that are unlikely to be portable between 361 systems. 362 363 If unsure, say N. 364 365choice 366 prompt "Base ISA" 367 default ARCH_RV64I 368 help 369 This selects the base ISA that this kernel will target and must match 370 the target platform. 371 372config ARCH_RV32I 373 bool "RV32I" 374 depends on NONPORTABLE 375 select 32BIT 376 select GENERIC_LIB_ASHLDI3 377 select GENERIC_LIB_ASHRDI3 378 select GENERIC_LIB_LSHRDI3 379 select GENERIC_LIB_UCMPDI2 380 381config ARCH_RV64I 382 bool "RV64I" 383 select 64BIT 384 select ARCH_SUPPORTS_INT128 if CC_HAS_INT128 385 select SWIOTLB if MMU 386 387endchoice 388 389# We must be able to map all physical memory into the kernel, but the compiler 390# is still a bit more efficient when generating code if it's setup in a manner 391# such that it can only map 2GiB of memory. 392choice 393 prompt "Kernel Code Model" 394 default CMODEL_MEDLOW if 32BIT 395 default CMODEL_MEDANY if 64BIT 396 397 config CMODEL_MEDLOW 398 bool "medium low code model" 399 config CMODEL_MEDANY 400 bool "medium any code model" 401endchoice 402 403config MODULE_SECTIONS 404 bool 405 select HAVE_MOD_ARCH_SPECIFIC 406 407config SMP 408 bool "Symmetric Multi-Processing" 409 help 410 This enables support for systems with more than one CPU. If 411 you say N here, the kernel will run on single and 412 multiprocessor machines, but will use only one CPU of a 413 multiprocessor machine. If you say Y here, the kernel will run 414 on many, but not all, single processor machines. On a single 415 processor machine, the kernel will run faster if you say N 416 here. 417 418 If you don't know what to do here, say N. 419 420config SCHED_MC 421 bool "Multi-core scheduler support" 422 depends on SMP 423 help 424 Multi-core scheduler support improves the CPU scheduler's decision 425 making when dealing with multi-core CPU chips at a cost of slightly 426 increased overhead in some places. If unsure say N here. 427 428config NR_CPUS 429 int "Maximum number of CPUs (2-512)" 430 depends on SMP 431 range 2 512 if !RISCV_SBI_V01 432 range 2 32 if RISCV_SBI_V01 && 32BIT 433 range 2 64 if RISCV_SBI_V01 && 64BIT 434 default "32" if 32BIT 435 default "64" if 64BIT 436 437config HOTPLUG_CPU 438 bool "Support for hot-pluggable CPUs" 439 depends on SMP 440 select GENERIC_IRQ_MIGRATION 441 help 442 443 Say Y here to experiment with turning CPUs off and on. CPUs 444 can be controlled through /sys/devices/system/cpu. 445 446 Say N if you want to disable CPU hotplug. 447 448choice 449 prompt "CPU Tuning" 450 default TUNE_GENERIC 451 452config TUNE_GENERIC 453 bool "generic" 454 455endchoice 456 457# Common NUMA Features 458config NUMA 459 bool "NUMA Memory Allocation and Scheduler Support" 460 depends on SMP && MMU 461 select ARCH_SUPPORTS_NUMA_BALANCING 462 select GENERIC_ARCH_NUMA 463 select HAVE_SETUP_PER_CPU_AREA 464 select NEED_PER_CPU_EMBED_FIRST_CHUNK 465 select NEED_PER_CPU_PAGE_FIRST_CHUNK 466 select OF_NUMA 467 select USE_PERCPU_NUMA_NODE_ID 468 help 469 Enable NUMA (Non-Uniform Memory Access) support. 470 471 The kernel will try to allocate memory used by a CPU on the 472 local memory of the CPU and add some more NUMA awareness to the kernel. 473 474config NODES_SHIFT 475 int "Maximum NUMA Nodes (as a power of 2)" 476 range 1 10 477 default "2" 478 depends on NUMA 479 help 480 Specify the maximum number of NUMA Nodes available on the target 481 system. Increases memory reserved to accommodate various tables. 482 483config RISCV_ALTERNATIVE 484 bool 485 depends on !XIP_KERNEL 486 help 487 This Kconfig allows the kernel to automatically patch the 488 erratum or cpufeature required by the execution platform at run 489 time. The code patching overhead is minimal, as it's only done 490 once at boot and once on each module load. 491 492config RISCV_ALTERNATIVE_EARLY 493 bool 494 depends on RISCV_ALTERNATIVE 495 help 496 Allows early patching of the kernel for special errata 497 498config RISCV_ISA_C 499 bool "Emit compressed instructions when building Linux" 500 default y 501 help 502 Adds "C" to the ISA subsets that the toolchain is allowed to emit 503 when building Linux, which results in compressed instructions in the 504 Linux binary. 505 506 If you don't know what to do here, say Y. 507 508config RISCV_ISA_SVNAPOT 509 bool "Svnapot extension support for supervisor mode NAPOT pages" 510 depends on 64BIT && MMU 511 depends on RISCV_ALTERNATIVE 512 default y 513 help 514 Allow kernel to detect the Svnapot ISA-extension dynamically at boot 515 time and enable its usage. 516 517 The Svnapot extension is used to mark contiguous PTEs as a range 518 of contiguous virtual-to-physical translations for a naturally 519 aligned power-of-2 (NAPOT) granularity larger than the base 4KB page 520 size. When HUGETLBFS is also selected this option unconditionally 521 allocates some memory for each NAPOT page size supported by the kernel. 522 When optimizing for low memory consumption and for platforms without 523 the Svnapot extension, it may be better to say N here. 524 525 If you don't know what to do here, say Y. 526 527config RISCV_ISA_SVPBMT 528 bool "Svpbmt extension support for supervisor mode page-based memory types" 529 depends on 64BIT && MMU 530 depends on RISCV_ALTERNATIVE 531 default y 532 help 533 Adds support to dynamically detect the presence of the Svpbmt 534 ISA-extension (Supervisor-mode: page-based memory types) and 535 enable its usage. 536 537 The memory type for a page contains a combination of attributes 538 that indicate the cacheability, idempotency, and ordering 539 properties for access to that page. 540 541 The Svpbmt extension is only available on 64-bit cpus. 542 543 If you don't know what to do here, say Y. 544 545config TOOLCHAIN_HAS_V 546 bool 547 default y 548 depends on !64BIT || $(cc-option,-mabi=lp64 -march=rv64iv) 549 depends on !32BIT || $(cc-option,-mabi=ilp32 -march=rv32iv) 550 depends on LLD_VERSION >= 140000 || LD_VERSION >= 23800 551 depends on AS_HAS_OPTION_ARCH 552 553config RISCV_ISA_V 554 bool "VECTOR extension support" 555 depends on TOOLCHAIN_HAS_V 556 depends on FPU 557 select DYNAMIC_SIGFRAME 558 default y 559 help 560 Say N here if you want to disable all vector related procedure 561 in the kernel. 562 563 If you don't know what to do here, say Y. 564 565config RISCV_ISA_V_DEFAULT_ENABLE 566 bool "Enable userspace Vector by default" 567 depends on RISCV_ISA_V 568 default y 569 help 570 Say Y here if you want to enable Vector in userspace by default. 571 Otherwise, userspace has to make explicit prctl() call to enable 572 Vector, or enable it via the sysctl interface. 573 574 If you don't know what to do here, say Y. 575 576config RISCV_ISA_V_UCOPY_THRESHOLD 577 int "Threshold size for vectorized user copies" 578 depends on RISCV_ISA_V 579 default 768 580 help 581 Prefer using vectorized copy_to_user()/copy_from_user() when the 582 workload size exceeds this value. 583 584config RISCV_ISA_V_PREEMPTIVE 585 bool "Run kernel-mode Vector with kernel preemption" 586 depends on PREEMPTION 587 depends on RISCV_ISA_V 588 default y 589 help 590 Usually, in-kernel SIMD routines are run with preemption disabled. 591 Functions which envoke long running SIMD thus must yield core's 592 vector unit to prevent blocking other tasks for too long. 593 594 This config allows kernel to run SIMD without explicitly disable 595 preemption. Enabling this config will result in higher memory 596 consumption due to the allocation of per-task's kernel Vector context. 597 598config TOOLCHAIN_HAS_ZBB 599 bool 600 default y 601 depends on !64BIT || $(cc-option,-mabi=lp64 -march=rv64ima_zbb) 602 depends on !32BIT || $(cc-option,-mabi=ilp32 -march=rv32ima_zbb) 603 depends on LLD_VERSION >= 150000 || LD_VERSION >= 23900 604 depends on AS_HAS_OPTION_ARCH 605 606# This symbol indicates that the toolchain supports all v1.0 vector crypto 607# extensions, including Zvk*, Zvbb, and Zvbc. LLVM added all of these at once. 608# binutils added all except Zvkb, then added Zvkb. So we just check for Zvkb. 609config TOOLCHAIN_HAS_VECTOR_CRYPTO 610 def_bool $(as-instr, .option arch$(comma) +v$(comma) +zvkb) 611 depends on AS_HAS_OPTION_ARCH 612 613config RISCV_ISA_ZBA 614 bool "Zba extension support for bit manipulation instructions" 615 default y 616 help 617 Add support for enabling optimisations in the kernel when the Zba 618 extension is detected at boot. 619 620 The Zba extension provides instructions to accelerate the generation 621 of addresses that index into arrays of basic data types. 622 623 If you don't know what to do here, say Y. 624 625config RISCV_ISA_ZBB 626 bool "Zbb extension support for bit manipulation instructions" 627 depends on TOOLCHAIN_HAS_ZBB 628 depends on RISCV_ALTERNATIVE 629 default y 630 help 631 Adds support to dynamically detect the presence of the ZBB 632 extension (basic bit manipulation) and enable its usage. 633 634 The Zbb extension provides instructions to accelerate a number 635 of bit-specific operations (count bit population, sign extending, 636 bitrotation, etc). 637 638 If you don't know what to do here, say Y. 639 640config RISCV_ISA_ZICBOM 641 bool "Zicbom extension support for non-coherent DMA operation" 642 depends on MMU 643 depends on RISCV_ALTERNATIVE 644 default y 645 select RISCV_DMA_NONCOHERENT 646 select DMA_DIRECT_REMAP 647 help 648 Adds support to dynamically detect the presence of the ZICBOM 649 extension (Cache Block Management Operations) and enable its 650 usage. 651 652 The Zicbom extension can be used to handle for example 653 non-coherent DMA support on devices that need it. 654 655 If you don't know what to do here, say Y. 656 657config RISCV_ISA_ZICBOZ 658 bool "Zicboz extension support for faster zeroing of memory" 659 depends on RISCV_ALTERNATIVE 660 default y 661 help 662 Enable the use of the Zicboz extension (cbo.zero instruction) 663 when available. 664 665 The Zicboz extension is used for faster zeroing of memory. 666 667 If you don't know what to do here, say Y. 668 669config TOOLCHAIN_HAS_ZIHINTPAUSE 670 bool 671 default y 672 depends on !64BIT || $(cc-option,-mabi=lp64 -march=rv64ima_zihintpause) 673 depends on !32BIT || $(cc-option,-mabi=ilp32 -march=rv32ima_zihintpause) 674 depends on LLD_VERSION >= 150000 || LD_VERSION >= 23600 675 676config TOOLCHAIN_NEEDS_EXPLICIT_ZICSR_ZIFENCEI 677 def_bool y 678 # https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=aed44286efa8ae8717a77d94b51ac3614e2ca6dc 679 # https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=98416dbb0a62579d4a7a4a76bab51b5b52fec2cd 680 depends on AS_IS_GNU && AS_VERSION >= 23600 681 help 682 Binutils-2.38 and GCC-12.1.0 bumped the default ISA spec to the newer 683 20191213 version, which moves some instructions from the I extension to 684 the Zicsr and Zifencei extensions. This requires explicitly specifying 685 Zicsr and Zifencei when binutils >= 2.38 or GCC >= 12.1.0. Zicsr 686 and Zifencei are supported in binutils from version 2.36 onwards. 687 To make life easier, and avoid forcing toolchains that default to a 688 newer ISA spec to version 2.2, relax the check to binutils >= 2.36. 689 For clang < 17 or GCC < 11.3.0, for which this is not possible or need 690 special treatment, this is dealt with in TOOLCHAIN_NEEDS_OLD_ISA_SPEC. 691 692config TOOLCHAIN_NEEDS_OLD_ISA_SPEC 693 def_bool y 694 depends on TOOLCHAIN_NEEDS_EXPLICIT_ZICSR_ZIFENCEI 695 # https://github.com/llvm/llvm-project/commit/22e199e6afb1263c943c0c0d4498694e15bf8a16 696 # https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=d29f5d6ab513c52fd872f532c492e35ae9fd6671 697 depends on (CC_IS_CLANG && CLANG_VERSION < 170000) || (CC_IS_GCC && GCC_VERSION < 110300) 698 help 699 Certain versions of clang and GCC do not support zicsr and zifencei via 700 -march. This option causes an older ISA spec compatible with these older 701 versions of clang and GCC to be passed to GAS, which has the same result 702 as passing zicsr and zifencei to -march. 703 704config FPU 705 bool "FPU support" 706 default y 707 help 708 Say N here if you want to disable all floating-point related procedure 709 in the kernel. 710 711 If you don't know what to do here, say Y. 712 713config IRQ_STACKS 714 bool "Independent irq & softirq stacks" if EXPERT 715 default y 716 select HAVE_IRQ_EXIT_ON_IRQ_STACK 717 select HAVE_SOFTIRQ_ON_OWN_STACK 718 help 719 Add independent irq & softirq stacks for percpu to prevent kernel stack 720 overflows. We may save some memory footprint by disabling IRQ_STACKS. 721 722config THREAD_SIZE_ORDER 723 int "Kernel stack size (in power-of-two numbers of page size)" if VMAP_STACK && EXPERT 724 range 0 4 725 default 1 if 32BIT && !KASAN 726 default 3 if 64BIT && KASAN 727 default 2 728 help 729 Specify the Pages of thread stack size (from 4KB to 64KB), which also 730 affects irq stack size, which is equal to thread stack size. 731 732config RISCV_MISALIGNED 733 bool 734 select SYSCTL_ARCH_UNALIGN_ALLOW 735 help 736 Embed support for emulating misaligned loads and stores. 737 738choice 739 prompt "Unaligned Accesses Support" 740 default RISCV_PROBE_UNALIGNED_ACCESS 741 help 742 This determines the level of support for unaligned accesses. This 743 information is used by the kernel to perform optimizations. It is also 744 exposed to user space via the hwprobe syscall. The hardware will be 745 probed at boot by default. 746 747config RISCV_PROBE_UNALIGNED_ACCESS 748 bool "Probe for hardware unaligned access support" 749 select RISCV_MISALIGNED 750 help 751 During boot, the kernel will run a series of tests to determine the 752 speed of unaligned accesses. This probing will dynamically determine 753 the speed of unaligned accesses on the underlying system. If unaligned 754 memory accesses trap into the kernel as they are not supported by the 755 system, the kernel will emulate the unaligned accesses to preserve the 756 UABI. 757 758config RISCV_EMULATED_UNALIGNED_ACCESS 759 bool "Emulate unaligned access where system support is missing" 760 select RISCV_MISALIGNED 761 help 762 If unaligned memory accesses trap into the kernel as they are not 763 supported by the system, the kernel will emulate the unaligned 764 accesses to preserve the UABI. When the underlying system does support 765 unaligned accesses, the unaligned accesses are assumed to be slow. 766 767config RISCV_SLOW_UNALIGNED_ACCESS 768 bool "Assume the system supports slow unaligned memory accesses" 769 depends on NONPORTABLE 770 help 771 Assume that the system supports slow unaligned memory accesses. The 772 kernel and userspace programs may not be able to run at all on systems 773 that do not support unaligned memory accesses. 774 775config RISCV_EFFICIENT_UNALIGNED_ACCESS 776 bool "Assume the system supports fast unaligned memory accesses" 777 depends on NONPORTABLE 778 select DCACHE_WORD_ACCESS if MMU 779 select HAVE_EFFICIENT_UNALIGNED_ACCESS 780 help 781 Assume that the system supports fast unaligned memory accesses. When 782 enabled, this option improves the performance of the kernel on such 783 systems. However, the kernel and userspace programs will run much more 784 slowly, or will not be able to run at all, on systems that do not 785 support efficient unaligned memory accesses. 786 787endchoice 788 789endmenu # "Platform type" 790 791menu "Kernel features" 792 793source "kernel/Kconfig.hz" 794 795config RISCV_SBI_V01 796 bool "SBI v0.1 support" 797 depends on RISCV_SBI 798 help 799 This config allows kernel to use SBI v0.1 APIs. This will be 800 deprecated in future once legacy M-mode software are no longer in use. 801 802config RISCV_BOOT_SPINWAIT 803 bool "Spinwait booting method" 804 depends on SMP 805 default y if RISCV_SBI_V01 || RISCV_M_MODE 806 help 807 This enables support for booting Linux via spinwait method. In the 808 spinwait method, all cores randomly jump to Linux. One of the cores 809 gets chosen via lottery and all other keep spinning on a percpu 810 variable. This method cannot support CPU hotplug and sparse hartid 811 scheme. It should be only enabled for M-mode Linux or platforms relying 812 on older firmware without SBI HSM extension. All other platforms should 813 rely on ordered booting via SBI HSM extension which gets chosen 814 dynamically at runtime if the firmware supports it. 815 816 Since spinwait is incompatible with sparse hart IDs, it requires 817 NR_CPUS be large enough to contain the physical hart ID of the first 818 hart to enter Linux. 819 820 If unsure what to do here, say N. 821 822config ARCH_SUPPORTS_KEXEC 823 def_bool y 824 825config ARCH_SELECTS_KEXEC 826 def_bool y 827 depends on KEXEC 828 select HOTPLUG_CPU if SMP 829 830config ARCH_SUPPORTS_KEXEC_FILE 831 def_bool 64BIT 832 833config ARCH_SELECTS_KEXEC_FILE 834 def_bool y 835 depends on KEXEC_FILE 836 select HAVE_IMA_KEXEC if IMA 837 select KEXEC_ELF 838 839config ARCH_SUPPORTS_KEXEC_PURGATORY 840 def_bool ARCH_SUPPORTS_KEXEC_FILE 841 842config ARCH_SUPPORTS_CRASH_DUMP 843 def_bool y 844 845config ARCH_HAS_GENERIC_CRASHKERNEL_RESERVATION 846 def_bool CRASH_RESERVE 847 848config COMPAT 849 bool "Kernel support for 32-bit U-mode" 850 default 64BIT 851 depends on 64BIT && MMU 852 help 853 This option enables support for a 32-bit U-mode running under a 64-bit 854 kernel at S-mode. riscv32-specific components such as system calls, 855 the user helper functions (vdso), signal rt_frame functions and the 856 ptrace interface are handled appropriately by the kernel. 857 858 If you want to execute 32-bit userspace applications, say Y. 859 860config PARAVIRT 861 bool "Enable paravirtualization code" 862 depends on RISCV_SBI 863 help 864 This changes the kernel so it can modify itself when it is run 865 under a hypervisor, potentially improving performance significantly 866 over full virtualization. 867 868config PARAVIRT_TIME_ACCOUNTING 869 bool "Paravirtual steal time accounting" 870 depends on PARAVIRT 871 help 872 Select this option to enable fine granularity task steal time 873 accounting. Time spent executing other tasks in parallel with 874 the current vCPU is discounted from the vCPU power. To account for 875 that, there can be a small performance impact. 876 877 If in doubt, say N here. 878 879config RELOCATABLE 880 bool "Build a relocatable kernel" 881 depends on MMU && 64BIT && !XIP_KERNEL 882 select MODULE_SECTIONS if MODULES 883 help 884 This builds a kernel as a Position Independent Executable (PIE), 885 which retains all relocation metadata required to relocate the 886 kernel binary at runtime to a different virtual address than the 887 address it was linked at. 888 Since RISCV uses the RELA relocation format, this requires a 889 relocation pass at runtime even if the kernel is loaded at the 890 same address it was linked at. 891 892 If unsure, say N. 893 894config RANDOMIZE_BASE 895 bool "Randomize the address of the kernel image" 896 select RELOCATABLE 897 depends on MMU && 64BIT && !XIP_KERNEL 898 help 899 Randomizes the virtual address at which the kernel image is 900 loaded, as a security feature that deters exploit attempts 901 relying on knowledge of the location of kernel internals. 902 903 It is the bootloader's job to provide entropy, by passing a 904 random u64 value in /chosen/kaslr-seed at kernel entry. 905 906 When booting via the UEFI stub, it will invoke the firmware's 907 EFI_RNG_PROTOCOL implementation (if available) to supply entropy 908 to the kernel proper. In addition, it will randomise the physical 909 location of the kernel Image as well. 910 911 If unsure, say N. 912 913endmenu # "Kernel features" 914 915menu "Boot options" 916 917config CMDLINE 918 string "Built-in kernel command line" 919 help 920 For most platforms, the arguments for the kernel's command line 921 are provided at run-time, during boot. However, there are cases 922 where either no arguments are being provided or the provided 923 arguments are insufficient or even invalid. 924 925 When that occurs, it is possible to define a built-in command 926 line here and choose how the kernel should use it later on. 927 928choice 929 prompt "Built-in command line usage" if CMDLINE != "" 930 default CMDLINE_FALLBACK 931 help 932 Choose how the kernel will handle the provided built-in command 933 line. 934 935config CMDLINE_FALLBACK 936 bool "Use bootloader kernel arguments if available" 937 help 938 Use the built-in command line as fallback in case we get nothing 939 during boot. This is the default behaviour. 940 941config CMDLINE_EXTEND 942 bool "Extend bootloader kernel arguments" 943 help 944 The command-line arguments provided during boot will be 945 appended to the built-in command line. This is useful in 946 cases where the provided arguments are insufficient and 947 you don't want to or cannot modify them. 948 949config CMDLINE_FORCE 950 bool "Always use the default kernel command string" 951 help 952 Always use the built-in command line, even if we get one during 953 boot. This is useful in case you need to override the provided 954 command line on systems where you don't have or want control 955 over it. 956 957endchoice 958 959config EFI_STUB 960 bool 961 962config EFI 963 bool "UEFI runtime support" 964 depends on OF && !XIP_KERNEL 965 depends on MMU 966 default y 967 select ARCH_SUPPORTS_ACPI if 64BIT 968 select EFI_GENERIC_STUB 969 select EFI_PARAMS_FROM_FDT 970 select EFI_RUNTIME_WRAPPERS 971 select EFI_STUB 972 select LIBFDT 973 select RISCV_ISA_C 974 select UCS2_STRING 975 help 976 This option provides support for runtime services provided 977 by UEFI firmware (such as non-volatile variables, realtime 978 clock, and platform reset). A UEFI stub is also provided to 979 allow the kernel to be booted as an EFI application. This 980 is only useful on systems that have UEFI firmware. 981 982config CC_HAVE_STACKPROTECTOR_TLS 983 def_bool $(cc-option,-mstack-protector-guard=tls -mstack-protector-guard-reg=tp -mstack-protector-guard-offset=0) 984 985config STACKPROTECTOR_PER_TASK 986 def_bool y 987 depends on !RANDSTRUCT 988 depends on STACKPROTECTOR && CC_HAVE_STACKPROTECTOR_TLS 989 990config PHYS_RAM_BASE_FIXED 991 bool "Explicitly specified physical RAM address" 992 depends on NONPORTABLE 993 default n 994 995config PHYS_RAM_BASE 996 hex "Platform Physical RAM address" 997 depends on PHYS_RAM_BASE_FIXED 998 default "0x80000000" 999 help 1000 This is the physical address of RAM in the system. It has to be 1001 explicitly specified to run early relocations of read-write data 1002 from flash to RAM. 1003 1004config XIP_KERNEL 1005 bool "Kernel Execute-In-Place from ROM" 1006 depends on MMU && SPARSEMEM && NONPORTABLE 1007 # This prevents XIP from being enabled by all{yes,mod}config, which 1008 # fail to build since XIP doesn't support large kernels. 1009 depends on !COMPILE_TEST 1010 select PHYS_RAM_BASE_FIXED 1011 help 1012 Execute-In-Place allows the kernel to run from non-volatile storage 1013 directly addressable by the CPU, such as NOR flash. This saves RAM 1014 space since the text section of the kernel is not loaded from flash 1015 to RAM. Read-write sections, such as the data section and stack, 1016 are still copied to RAM. The XIP kernel is not compressed since 1017 it has to run directly from flash, so it will take more space to 1018 store it. The flash address used to link the kernel object files, 1019 and for storing it, is configuration dependent. Therefore, if you 1020 say Y here, you must know the proper physical address where to 1021 store the kernel image depending on your own flash memory usage. 1022 1023 Also note that the make target becomes "make xipImage" rather than 1024 "make zImage" or "make Image". The final kernel binary to put in 1025 ROM memory will be arch/riscv/boot/xipImage. 1026 1027 SPARSEMEM is required because the kernel text and rodata that are 1028 flash resident are not backed by memmap, then any attempt to get 1029 a struct page on those regions will trigger a fault. 1030 1031 If unsure, say N. 1032 1033config XIP_PHYS_ADDR 1034 hex "XIP Kernel Physical Location" 1035 depends on XIP_KERNEL 1036 default "0x21000000" 1037 help 1038 This is the physical address in your flash memory the kernel will 1039 be linked for and stored to. This address is dependent on your 1040 own flash usage. 1041 1042config RISCV_ISA_FALLBACK 1043 bool "Permit falling back to parsing riscv,isa for extension support by default" 1044 default y 1045 help 1046 Parsing the "riscv,isa" devicetree property has been deprecated and 1047 replaced by a list of explicitly defined strings. For compatibility 1048 with existing platforms, the kernel will fall back to parsing the 1049 "riscv,isa" property if the replacements are not found. 1050 1051 Selecting N here will result in a kernel that does not use the 1052 fallback, unless the commandline "riscv_isa_fallback" parameter is 1053 present. 1054 1055 Please see the dt-binding, located at 1056 Documentation/devicetree/bindings/riscv/extensions.yaml for details 1057 on the replacement properties, "riscv,isa-base" and 1058 "riscv,isa-extensions". 1059 1060config BUILTIN_DTB 1061 bool "Built-in device tree" 1062 depends on OF && NONPORTABLE 1063 help 1064 Build a device tree into the Linux image. 1065 This option should be selected if no bootloader is being used. 1066 If unsure, say N. 1067 1068 1069config BUILTIN_DTB_SOURCE 1070 string "Built-in device tree source" 1071 depends on BUILTIN_DTB 1072 help 1073 DTS file path (without suffix, relative to arch/riscv/boot/dts) 1074 for the DTS file that will be used to produce the DTB linked into the 1075 kernel. 1076 1077endmenu # "Boot options" 1078 1079config PORTABLE 1080 bool 1081 default !NONPORTABLE 1082 select EFI 1083 select MMU 1084 select OF 1085 1086config ARCH_PROC_KCORE_TEXT 1087 def_bool y 1088 1089menu "Power management options" 1090 1091source "kernel/power/Kconfig" 1092 1093config ARCH_HIBERNATION_POSSIBLE 1094 def_bool y 1095 1096config ARCH_HIBERNATION_HEADER 1097 def_bool HIBERNATION 1098 1099config ARCH_SUSPEND_POSSIBLE 1100 def_bool y 1101 1102endmenu # "Power management options" 1103 1104menu "CPU Power Management" 1105 1106source "drivers/cpuidle/Kconfig" 1107 1108source "drivers/cpufreq/Kconfig" 1109 1110endmenu # "CPU Power Management" 1111 1112source "arch/riscv/kvm/Kconfig" 1113 1114source "drivers/acpi/Kconfig" 1115