Skip to content

Commit 939b7cb

Browse files
committed
Merge tag 'riscv-for-linus-5.13-mw0' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux
Pull RISC-V updates from Palmer Dabbelt: - Support for the memtest= kernel command-line argument. - Support for building the kernel with FORTIFY_SOURCE. - Support for generic clockevent broadcasts. - Support for the buildtar build target. - Some build system cleanups to pass more LLVM-friendly arguments. - Support for kprobes. - A rearranged kernel memory map, the first part of supporting sv48 systems. - Improvements to kexec, along with support for kdump and crash kernels. - An alternatives-based errata framework, along with support for handling a pair of errata that manifest on some SiFive designs (including the HiFive Unmatched). - Support for XIP. - A device tree for the Microchip PolarFire ICICLE SoC and associated dev board. ... along with a bunch of cleanups. There are already a handful of fixes on the list so there will likely be a part 2. * tag 'riscv-for-linus-5.13-mw0' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux: (45 commits) RISC-V: Always define XIP_FIXUP riscv: Remove 32b kernel mapping from page table dump riscv: Fix 32b kernel build with CONFIG_DEBUG_VIRTUAL=y RISC-V: Fix error code returned by riscv_hartid_to_cpuid() RISC-V: Enable Microchip PolarFire ICICLE SoC RISC-V: Initial DTS for Microchip ICICLE board dt-bindings: riscv: microchip: Add YAML documentation for the PolarFire SoC RISC-V: Add Microchip PolarFire SoC kconfig option RISC-V: enable XIP RISC-V: Add crash kernel support RISC-V: Add kdump support RISC-V: Improve init_resources() RISC-V: Add kexec support RISC-V: Add EM_RISCV to kexec UAPI header riscv: vdso: fix and clean-up Makefile riscv/mm: Use BUG_ON instead of if condition followed by BUG. riscv/kprobe: fix kernel panic when invoking sys_read traced by kprobe riscv: Set ARCH_HAS_STRICT_MODULE_RWX if MMU riscv: module: Create module allocations without exec permissions riscv: bpf: Avoid breaking W^X ...
2 parents 5e5948e + f54c7b5 commit 939b7cb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+2635
-216
lines changed

Documentation/admin-guide/kernel-parameters.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2821,7 +2821,7 @@
28212821
Note that even when enabled, there are a few cases where
28222822
the feature is not effective.
28232823

2824-
memtest= [KNL,X86,ARM,PPC] Enable memtest
2824+
memtest= [KNL,X86,ARM,PPC,RISCV] Enable memtest
28252825
Format: <integer>
28262826
default : 0 <disable>
28272827
Specifies the number of memtest passes to be
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
2+
%YAML 1.2
3+
---
4+
$id: http://devicetree.org/schemas/riscv/microchip.yaml#
5+
$schema: http://devicetree.org/meta-schemas/core.yaml#
6+
7+
title: Microchip PolarFire SoC-based boards device tree bindings
8+
9+
maintainers:
10+
- Cyril Jean <Cyril.Jean@microchip.com>
11+
- Lewis Hanly <lewis.hanly@microchip.com>
12+
13+
description:
14+
Microchip PolarFire SoC-based boards
15+
16+
properties:
17+
$nodename:
18+
const: '/'
19+
compatible:
20+
items:
21+
- enum:
22+
- microchip,mpfs-icicle-kit
23+
- const: microchip,mpfs
24+
25+
additionalProperties: true
26+
27+
...

Documentation/riscv/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ RISC-V architecture
66
:maxdepth: 1
77

88
boot-image-header
9+
vm-layout
910
pmu
1011
patch-acceptance
1112

Documentation/riscv/vm-layout.rst

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
.. SPDX-License-Identifier: GPL-2.0
2+
3+
=====================================
4+
Virtual Memory Layout on RISC-V Linux
5+
=====================================
6+
7+
:Author: Alexandre Ghiti <alex@ghiti.fr>
8+
:Date: 12 February 2021
9+
10+
This document describes the virtual memory layout used by the RISC-V Linux
11+
Kernel.
12+
13+
RISC-V Linux Kernel 32bit
14+
=========================
15+
16+
RISC-V Linux Kernel SV32
17+
------------------------
18+
19+
TODO
20+
21+
RISC-V Linux Kernel 64bit
22+
=========================
23+
24+
The RISC-V privileged architecture document states that the 64bit addresses
25+
"must have bits 63–48 all equal to bit 47, or else a page-fault exception will
26+
occur.": that splits the virtual address space into 2 halves separated by a very
27+
big hole, the lower half is where the userspace resides, the upper half is where
28+
the RISC-V Linux Kernel resides.
29+
30+
RISC-V Linux Kernel SV39
31+
------------------------
32+
33+
::
34+
35+
========================================================================================================================
36+
Start addr | Offset | End addr | Size | VM area description
37+
========================================================================================================================
38+
| | | |
39+
0000000000000000 | 0 | 0000003fffffffff | 256 GB | user-space virtual memory, different per mm
40+
__________________|____________|__________________|_________|___________________________________________________________
41+
| | | |
42+
0000004000000000 | +256 GB | ffffffbfffffffff | ~16M TB | ... huge, almost 64 bits wide hole of non-canonical
43+
| | | | virtual memory addresses up to the -256 GB
44+
| | | | starting offset of kernel mappings.
45+
__________________|____________|__________________|_________|___________________________________________________________
46+
|
47+
| Kernel-space virtual memory, shared between all processes:
48+
____________________________________________________________|___________________________________________________________
49+
| | | |
50+
ffffffc000000000 | -256 GB | ffffffc7ffffffff | 32 GB | kasan
51+
ffffffcefee00000 | -196 GB | ffffffcefeffffff | 2 MB | fixmap
52+
ffffffceff000000 | -196 GB | ffffffceffffffff | 16 MB | PCI io
53+
ffffffcf00000000 | -196 GB | ffffffcfffffffff | 4 GB | vmemmap
54+
ffffffd000000000 | -192 GB | ffffffdfffffffff | 64 GB | vmalloc/ioremap space
55+
ffffffe000000000 | -128 GB | ffffffff7fffffff | 124 GB | direct mapping of all physical memory
56+
__________________|____________|__________________|_________|____________________________________________________________
57+
|
58+
|
59+
____________________________________________________________|____________________________________________________________
60+
| | | |
61+
ffffffff00000000 | -4 GB | ffffffff7fffffff | 2 GB | modules
62+
ffffffff80000000 | -2 GB | ffffffffffffffff | 2 GB | kernel, BPF
63+
__________________|____________|__________________|_________|____________________________________________________________

arch/riscv/Kconfig

Lines changed: 86 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,17 @@ config RISCV
2020
select ARCH_HAS_DEBUG_VM_PGTABLE
2121
select ARCH_HAS_DEBUG_VIRTUAL if MMU
2222
select ARCH_HAS_DEBUG_WX
23+
select ARCH_HAS_FORTIFY_SOURCE
2324
select ARCH_HAS_GCOV_PROFILE_ALL
2425
select ARCH_HAS_GIGANTIC_PAGE
2526
select ARCH_HAS_KCOV
2627
select ARCH_HAS_MMIOWB
2728
select ARCH_HAS_PTE_SPECIAL
2829
select ARCH_HAS_SET_DIRECT_MAP
2930
select ARCH_HAS_SET_MEMORY
30-
select ARCH_HAS_STRICT_KERNEL_RWX 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
3134
select ARCH_OPTIONAL_KERNEL_RWX if ARCH_HAS_STRICT_KERNEL_RWX
3235
select ARCH_OPTIONAL_KERNEL_RWX_DEFAULT
3336
select ARCH_SUPPORTS_HUGETLBFS if MMU
@@ -41,6 +44,7 @@ config RISCV
4144
select EDAC_SUPPORT
4245
select GENERIC_ARCH_TOPOLOGY if SMP
4346
select GENERIC_ATOMIC64 if !64BIT
47+
select GENERIC_CLOCKEVENTS_BROADCAST if SMP
4448
select GENERIC_EARLY_IOREMAP
4549
select GENERIC_GETTIMEOFDAY if HAVE_GENERIC_VDSO
4650
select GENERIC_IOREMAP
@@ -202,6 +206,7 @@ config LOCKDEP_SUPPORT
202206
def_bool y
203207

204208
source "arch/riscv/Kconfig.socs"
209+
source "arch/riscv/Kconfig.erratas"
205210

206211
menu "Platform type"
207212

@@ -225,7 +230,7 @@ config ARCH_RV64I
225230
bool "RV64I"
226231
select 64BIT
227232
select ARCH_SUPPORTS_INT128 if CC_HAS_INT128 && GCC_VERSION >= 50000
228-
select HAVE_DYNAMIC_FTRACE if MMU
233+
select HAVE_DYNAMIC_FTRACE if MMU && $(cc-option,-fpatchable-function-entry=8)
229234
select HAVE_DYNAMIC_FTRACE_WITH_REGS if HAVE_DYNAMIC_FTRACE
230235
select HAVE_FTRACE_MCOUNT_RECORD
231236
select HAVE_FUNCTION_GRAPH_TRACER
@@ -384,6 +389,31 @@ config RISCV_SBI_V01
384389
help
385390
This config allows kernel to use SBI v0.1 APIs. This will be
386391
deprecated in future once legacy M-mode software are no longer in use.
392+
393+
config KEXEC
394+
bool "Kexec system call"
395+
select KEXEC_CORE
396+
select HOTPLUG_CPU if SMP
397+
depends on MMU
398+
help
399+
kexec is a system call that implements the ability to shutdown your
400+
current kernel, and to start another kernel. It is like a reboot
401+
but it is independent of the system firmware. And like a reboot
402+
you can start any kernel with it, not just Linux.
403+
404+
The name comes from the similarity to the exec system call.
405+
406+
config CRASH_DUMP
407+
bool "Build kdump crash kernel"
408+
help
409+
Generate crash dump after being started by kexec. This should
410+
be normally only set in special crash dump kernels which are
411+
loaded in the main kernel with kexec-tools into a specially
412+
reserved region and then later executed after a crash by
413+
kdump/kexec.
414+
415+
For more details see Documentation/admin-guide/kdump/kdump.rst
416+
387417
endmenu
388418

389419
menu "Boot options"
@@ -436,7 +466,7 @@ config EFI_STUB
436466

437467
config EFI
438468
bool "UEFI runtime support"
439-
depends on OF
469+
depends on OF && !XIP_KERNEL
440470
select LIBFDT
441471
select UCS2_STRING
442472
select EFI_PARAMS_FROM_FDT
@@ -460,11 +490,63 @@ config STACKPROTECTOR_PER_TASK
460490
def_bool y
461491
depends on STACKPROTECTOR && CC_HAVE_STACKPROTECTOR_TLS
462492

493+
config PHYS_RAM_BASE_FIXED
494+
bool "Explicitly specified physical RAM address"
495+
default n
496+
497+
config PHYS_RAM_BASE
498+
hex "Platform Physical RAM address"
499+
depends on PHYS_RAM_BASE_FIXED
500+
default "0x80000000"
501+
help
502+
This is the physical address of RAM in the system. It has to be
503+
explicitly specified to run early relocations of read-write data
504+
from flash to RAM.
505+
506+
config XIP_KERNEL
507+
bool "Kernel Execute-In-Place from ROM"
508+
depends on MMU && SPARSEMEM
509+
# This prevents XIP from being enabled by all{yes,mod}config, which
510+
# fail to build since XIP doesn't support large kernels.
511+
depends on !COMPILE_TEST
512+
select PHYS_RAM_BASE_FIXED
513+
help
514+
Execute-In-Place allows the kernel to run from non-volatile storage
515+
directly addressable by the CPU, such as NOR flash. This saves RAM
516+
space since the text section of the kernel is not loaded from flash
517+
to RAM. Read-write sections, such as the data section and stack,
518+
are still copied to RAM. The XIP kernel is not compressed since
519+
it has to run directly from flash, so it will take more space to
520+
store it. The flash address used to link the kernel object files,
521+
and for storing it, is configuration dependent. Therefore, if you
522+
say Y here, you must know the proper physical address where to
523+
store the kernel image depending on your own flash memory usage.
524+
525+
Also note that the make target becomes "make xipImage" rather than
526+
"make zImage" or "make Image". The final kernel binary to put in
527+
ROM memory will be arch/riscv/boot/xipImage.
528+
529+
SPARSEMEM is required because the kernel text and rodata that are
530+
flash resident are not backed by memmap, then any attempt to get
531+
a struct page on those regions will trigger a fault.
532+
533+
If unsure, say N.
534+
535+
config XIP_PHYS_ADDR
536+
hex "XIP Kernel Physical Location"
537+
depends on XIP_KERNEL
538+
default "0x21000000"
539+
help
540+
This is the physical address in your flash memory the kernel will
541+
be linked for and stored to. This address is dependent on your
542+
own flash usage.
543+
463544
endmenu
464545

465546
config BUILTIN_DTB
466-
def_bool n
547+
bool
467548
depends on OF
549+
default y if XIP_KERNEL
468550

469551
menu "Power management options"
470552

arch/riscv/Kconfig.erratas

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
menu "CPU errata selection"
2+
3+
config RISCV_ERRATA_ALTERNATIVE
4+
bool "RISC-V alternative scheme"
5+
default y
6+
help
7+
This Kconfig allows the kernel to automatically patch the
8+
errata required by the execution platform at run time. The
9+
code patching is performed once in the boot stages. It means
10+
that the overhead from this mechanism is just taken once.
11+
12+
config ERRATA_SIFIVE
13+
bool "SiFive errata"
14+
depends on RISCV_ERRATA_ALTERNATIVE
15+
help
16+
All SiFive errata Kconfig depend on this Kconfig. Disabling
17+
this Kconfig will disable all SiFive errata. Please say "Y"
18+
here if your platform uses SiFive CPU cores.
19+
20+
Otherwise, please say "N" here to avoid unnecessary overhead.
21+
22+
config ERRATA_SIFIVE_CIP_453
23+
bool "Apply SiFive errata CIP-453"
24+
depends on ERRATA_SIFIVE
25+
default y
26+
help
27+
This will apply the SiFive CIP-453 errata to add sign extension
28+
to the $badaddr when exception type is instruction page fault
29+
and instruction access fault.
30+
31+
If you don't know what to do here, say "Y".
32+
33+
config ERRATA_SIFIVE_CIP_1200
34+
bool "Apply SiFive errata CIP-1200"
35+
depends on ERRATA_SIFIVE
36+
default y
37+
help
38+
This will apply the SiFive CIP-1200 errata to repalce all
39+
"sfence.vma addr" with "sfence.vma" to ensure that the addr
40+
has been flushed from TLB.
41+
42+
If you don't know what to do here, say "Y".
43+
44+
endmenu

arch/riscv/Kconfig.socs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,20 @@
11
menu "SoC selection"
22

3+
config SOC_MICROCHIP_POLARFIRE
4+
bool "Microchip PolarFire SoCs"
5+
select MCHP_CLK_MPFS
6+
select SIFIVE_PLIC
7+
help
8+
This enables support for Microchip PolarFire SoC platforms.
9+
310
config SOC_SIFIVE
411
bool "SiFive SoCs"
512
select SERIAL_SIFIVE if TTY
613
select SERIAL_SIFIVE_CONSOLE if TTY
714
select CLK_SIFIVE
815
select CLK_SIFIVE_PRCI
916
select SIFIVE_PLIC
17+
select ERRATA_SIFIVE
1018
help
1119
This enables support for SiFive SoC platform hardware.
1220

arch/riscv/Makefile

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,16 @@ CHECKFLAGS += -D__riscv -D__riscv_xlen=$(BITS)
8282

8383
# Default target when executing plain make
8484
boot := arch/riscv/boot
85+
ifeq ($(CONFIG_XIP_KERNEL),y)
86+
KBUILD_IMAGE := $(boot)/xipImage
87+
else
8588
KBUILD_IMAGE := $(boot)/Image.gz
89+
endif
8690

8791
head-y := arch/riscv/kernel/head.o
8892

8993
core-y += arch/riscv/
94+
core-$(CONFIG_RISCV_ERRATA_ALTERNATIVE) += arch/riscv/errata/
9095

9196
libs-y += arch/riscv/lib/
9297
libs-$(CONFIG_EFI_STUB) += $(objtree)/drivers/firmware/efi/libstub/lib.a
@@ -95,12 +100,14 @@ PHONY += vdso_install
95100
vdso_install:
96101
$(Q)$(MAKE) $(build)=arch/riscv/kernel/vdso $@
97102

103+
ifneq ($(CONFIG_XIP_KERNEL),y)
98104
ifeq ($(CONFIG_RISCV_M_MODE)$(CONFIG_SOC_CANAAN),yy)
99105
KBUILD_IMAGE := $(boot)/loader.bin
100106
else
101107
KBUILD_IMAGE := $(boot)/Image.gz
102108
endif
103-
BOOT_TARGETS := Image Image.gz loader loader.bin
109+
endif
110+
BOOT_TARGETS := Image Image.gz loader loader.bin xipImage
104111

105112
all: $(notdir $(KBUILD_IMAGE))
106113

arch/riscv/boot/Makefile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,21 @@
1717
KCOV_INSTRUMENT := n
1818

1919
OBJCOPYFLAGS_Image :=-O binary -R .note -R .note.gnu.build-id -R .comment -S
20+
OBJCOPYFLAGS_xipImage :=-O binary -R .note -R .note.gnu.build-id -R .comment -S
2021

2122
targets := Image Image.* loader loader.o loader.lds loader.bin
23+
targets := Image Image.* loader loader.o loader.lds loader.bin xipImage
24+
25+
ifeq ($(CONFIG_XIP_KERNEL),y)
26+
27+
quiet_cmd_mkxip = $(quiet_cmd_objcopy)
28+
cmd_mkxip = $(cmd_objcopy)
29+
30+
$(obj)/xipImage: vmlinux FORCE
31+
$(call if_changed,mkxip)
32+
@$(kecho) ' Physical Address of xipImage: $(CONFIG_XIP_PHYS_ADDR)'
33+
34+
endif
2235

2336
$(obj)/Image: vmlinux FORCE
2437
$(call if_changed,objcopy)

arch/riscv/boot/dts/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# SPDX-License-Identifier: GPL-2.0
22
subdir-y += sifive
33
subdir-$(CONFIG_SOC_CANAAN_K210_DTB_BUILTIN) += canaan
4+
subdir-y += microchip
45

56
obj-$(CONFIG_BUILTIN_DTB) := $(addsuffix /, $(subdir-y))
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# SPDX-License-Identifier: GPL-2.0
2+
dtb-$(CONFIG_SOC_MICROCHIP_POLARFIRE) += microchip-mpfs-icicle-kit.dtb

0 commit comments

Comments
 (0)