Skip to content

Commit 1b37a0a

Browse files
committed
Merge tag 'riscv-for-linus-6.6-mw2-2' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux
Pull more RISC-V updates from Palmer Dabbelt: - The kernel now dynamically probes for misaligned access speed, as opposed to relying on a table of known implementations. - Support for non-coherent devices on systems using the Andes AX45MP core, including the RZ/Five SoCs. - Support for the V extension in ptrace(), again. - Support for KASLR. - Support for the BPF prog pack allocator in RISC-V. - A handful of bug fixes and cleanups. * tag 'riscv-for-linus-6.6-mw2-2' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux: (25 commits) soc: renesas: Kconfig: For ARCH_R9A07G043 select the required configs if dependencies are met riscv: Kconfig.errata: Add dependency for RISCV_SBI in ERRATA_ANDES config riscv: Kconfig.errata: Drop dependency for MMU in ERRATA_ANDES_CMO config riscv: Kconfig: Select DMA_DIRECT_REMAP only if MMU is enabled bpf, riscv: use prog pack allocator in the BPF JIT riscv: implement a memset like function for text riscv: extend patch_text_nosync() for multiple pages bpf: make bpf_prog_pack allocator portable riscv: libstub: Implement KASLR by using generic functions libstub: Fix compilation warning for rv32 arm64: libstub: Move KASLR handling functions to kaslr.c riscv: Dump out kernel offset information on panic riscv: Introduce virtual kernel mapping KASLR RISC-V: Add ptrace support for vectors soc: renesas: Kconfig: Select the required configs for RZ/Five SoC cache: Add L2 cache management for Andes AX45MP RISC-V core dt-bindings: cache: andestech,ax45mp-cache: Add DT binding documentation for L2 cache controller riscv: mm: dma-noncoherent: nonstandard cache operations support riscv: errata: Add Andes alternative ports riscv: asm: vendorid_list: Add Andes Technology to the vendors list ...
2 parents 2a5a432 + c6a906c commit 1b37a0a

Some content is hidden

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

51 files changed

+1440
-216
lines changed
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
2+
# Copyright (C) 2023 Renesas Electronics Corp.
3+
%YAML 1.2
4+
---
5+
$id: http://devicetree.org/schemas/cache/andestech,ax45mp-cache.yaml#
6+
$schema: http://devicetree.org/meta-schemas/core.yaml#
7+
8+
title: Andestech AX45MP L2 Cache Controller
9+
10+
maintainers:
11+
- Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
12+
13+
description:
14+
A level-2 cache (L2C) is used to improve the system performance by providing
15+
a large amount of cache line entries and reasonable access delays. The L2C
16+
is shared between cores, and a non-inclusive non-exclusive policy is used.
17+
18+
select:
19+
properties:
20+
compatible:
21+
contains:
22+
enum:
23+
- andestech,ax45mp-cache
24+
25+
required:
26+
- compatible
27+
28+
properties:
29+
compatible:
30+
items:
31+
- const: andestech,ax45mp-cache
32+
- const: cache
33+
34+
reg:
35+
maxItems: 1
36+
37+
interrupts:
38+
maxItems: 1
39+
40+
cache-line-size:
41+
const: 64
42+
43+
cache-level:
44+
const: 2
45+
46+
cache-sets:
47+
const: 1024
48+
49+
cache-size:
50+
enum: [131072, 262144, 524288, 1048576, 2097152]
51+
52+
cache-unified: true
53+
54+
next-level-cache: true
55+
56+
additionalProperties: false
57+
58+
required:
59+
- compatible
60+
- reg
61+
- interrupts
62+
- cache-line-size
63+
- cache-level
64+
- cache-sets
65+
- cache-size
66+
- cache-unified
67+
68+
examples:
69+
- |
70+
#include <dt-bindings/interrupt-controller/irq.h>
71+
72+
cache-controller@2010000 {
73+
compatible = "andestech,ax45mp-cache", "cache";
74+
reg = <0x13400000 0x100000>;
75+
interrupts = <508 IRQ_TYPE_LEVEL_HIGH>;
76+
cache-line-size = <64>;
77+
cache-level = <2>;
78+
cache-sets = <1024>;
79+
cache-size = <262144>;
80+
cache-unified;
81+
};

Documentation/riscv/hwprobe.rst

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,13 +87,12 @@ The following keys are defined:
8787
emulated via software, either in or below the kernel. These accesses are
8888
always extremely slow.
8989

90-
* :c:macro:`RISCV_HWPROBE_MISALIGNED_SLOW`: Misaligned accesses are supported
91-
in hardware, but are slower than the corresponding aligned accesses
92-
sequences.
90+
* :c:macro:`RISCV_HWPROBE_MISALIGNED_SLOW`: Misaligned accesses are slower
91+
than equivalent byte accesses. Misaligned accesses may be supported
92+
directly in hardware, or trapped and emulated by software.
9393

94-
* :c:macro:`RISCV_HWPROBE_MISALIGNED_FAST`: Misaligned accesses are supported
95-
in hardware and are faster than the corresponding aligned accesses
96-
sequences.
94+
* :c:macro:`RISCV_HWPROBE_MISALIGNED_FAST`: Misaligned accesses are faster
95+
than equivalent byte accesses.
9796

9897
* :c:macro:`RISCV_HWPROBE_MISALIGNED_UNSUPPORTED`: Misaligned accesses are
9998
not supported at all and will generate a misaligned address fault.

MAINTAINERS

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20406,6 +20406,13 @@ S: Supported
2040620406
T: git git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git
2040720407
F: drivers/staging/
2040820408

20409+
STANDALONE CACHE CONTROLLER DRIVERS
20410+
M: Conor Dooley <conor@kernel.org>
20411+
L: linux-riscv@lists.infradead.org
20412+
S: Maintained
20413+
T: git https://git.kernel.org/pub/scm/linux/kernel/git/conor/linux.git/
20414+
F: drivers/cache
20415+
2040920416
STARFIRE/DURALAN NETWORK DRIVER
2041020417
M: Ion Badulescu <ionut@badula.org>
2041120418
S: Odd Fixes

arch/arm64/include/asm/efi.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,4 +156,6 @@ static inline void efi_capsule_flush_cache_range(void *addr, int size)
156156

157157
efi_status_t efi_handle_corrupted_x18(efi_status_t s, const char *f);
158158

159+
void efi_icache_sync(unsigned long start, unsigned long end);
160+
159161
#endif /* _ASM_EFI_H */

arch/riscv/Kconfig

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,14 @@ config RISCV_DMA_NONCOHERENT
273273
select ARCH_HAS_SYNC_DMA_FOR_CPU
274274
select ARCH_HAS_SYNC_DMA_FOR_DEVICE
275275
select DMA_BOUNCE_UNALIGNED_KMALLOC if SWIOTLB
276-
select DMA_DIRECT_REMAP
276+
select DMA_DIRECT_REMAP if MMU
277+
278+
config RISCV_NONSTANDARD_CACHE_OPS
279+
bool
280+
depends on RISCV_DMA_NONCOHERENT
281+
help
282+
This enables function pointer support for non-standard noncoherent
283+
systems to handle cache management.
277284

278285
config AS_HAS_INSN
279286
def_bool $(as-instr,.insn r 51$(comma) 0$(comma) 0$(comma) t0$(comma) t0$(comma) zero)
@@ -713,6 +720,25 @@ config RELOCATABLE
713720

714721
If unsure, say N.
715722

723+
config RANDOMIZE_BASE
724+
bool "Randomize the address of the kernel image"
725+
select RELOCATABLE
726+
depends on MMU && 64BIT && !XIP_KERNEL
727+
help
728+
Randomizes the virtual address at which the kernel image is
729+
loaded, as a security feature that deters exploit attempts
730+
relying on knowledge of the location of kernel internals.
731+
732+
It is the bootloader's job to provide entropy, by passing a
733+
random u64 value in /chosen/kaslr-seed at kernel entry.
734+
735+
When booting via the UEFI stub, it will invoke the firmware's
736+
EFI_RNG_PROTOCOL implementation (if available) to supply entropy
737+
to the kernel proper. In addition, it will randomise the physical
738+
location of the kernel Image as well.
739+
740+
If unsure, say N.
741+
716742
endmenu # "Kernel features"
717743

718744
menu "Boot options"

arch/riscv/Kconfig.errata

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,26 @@
11
menu "CPU errata selection"
22

3+
config ERRATA_ANDES
4+
bool "Andes AX45MP errata"
5+
depends on RISCV_ALTERNATIVE && RISCV_SBI
6+
help
7+
All Andes errata Kconfig depend on this Kconfig. Disabling
8+
this Kconfig will disable all Andes errata. Please say "Y"
9+
here if your platform uses Andes CPU cores.
10+
11+
Otherwise, please say "N" here to avoid unnecessary overhead.
12+
13+
config ERRATA_ANDES_CMO
14+
bool "Apply Andes cache management errata"
15+
depends on ERRATA_ANDES && ARCH_R9A07G043
16+
select RISCV_DMA_NONCOHERENT
17+
default y
18+
help
19+
This will apply the cache management errata to handle the
20+
non-standard handling on non-coherent operations on Andes cores.
21+
22+
If you don't know what to do here, say "Y".
23+
324
config ERRATA_SIFIVE
425
bool "SiFive errata"
526
depends on RISCV_ALTERNATIVE

arch/riscv/errata/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@ ifdef CONFIG_RELOCATABLE
22
KBUILD_CFLAGS += -fno-pie
33
endif
44

5+
obj-$(CONFIG_ERRATA_ANDES) += andes/
56
obj-$(CONFIG_ERRATA_SIFIVE) += sifive/
67
obj-$(CONFIG_ERRATA_THEAD) += thead/

arch/riscv/errata/andes/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
obj-y += errata.o

arch/riscv/errata/andes/errata.c

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
// SPDX-License-Identifier: GPL-2.0-only
2+
/*
3+
* Erratas to be applied for Andes CPU cores
4+
*
5+
* Copyright (C) 2023 Renesas Electronics Corporation.
6+
*
7+
* Author: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
8+
*/
9+
10+
#include <linux/memory.h>
11+
#include <linux/module.h>
12+
13+
#include <asm/alternative.h>
14+
#include <asm/cacheflush.h>
15+
#include <asm/errata_list.h>
16+
#include <asm/patch.h>
17+
#include <asm/processor.h>
18+
#include <asm/sbi.h>
19+
#include <asm/vendorid_list.h>
20+
21+
#define ANDESTECH_AX45MP_MARCHID 0x8000000000008a45UL
22+
#define ANDESTECH_AX45MP_MIMPID 0x500UL
23+
#define ANDESTECH_SBI_EXT_ANDES 0x0900031E
24+
25+
#define ANDES_SBI_EXT_IOCP_SW_WORKAROUND 1
26+
27+
static long ax45mp_iocp_sw_workaround(void)
28+
{
29+
struct sbiret ret;
30+
31+
/*
32+
* ANDES_SBI_EXT_IOCP_SW_WORKAROUND SBI EXT checks if the IOCP is missing and
33+
* cache is controllable only then CMO will be applied to the platform.
34+
*/
35+
ret = sbi_ecall(ANDESTECH_SBI_EXT_ANDES, ANDES_SBI_EXT_IOCP_SW_WORKAROUND,
36+
0, 0, 0, 0, 0, 0);
37+
38+
return ret.error ? 0 : ret.value;
39+
}
40+
41+
static bool errata_probe_iocp(unsigned int stage, unsigned long arch_id, unsigned long impid)
42+
{
43+
if (!IS_ENABLED(CONFIG_ERRATA_ANDES_CMO))
44+
return false;
45+
46+
if (arch_id != ANDESTECH_AX45MP_MARCHID || impid != ANDESTECH_AX45MP_MIMPID)
47+
return false;
48+
49+
if (!ax45mp_iocp_sw_workaround())
50+
return false;
51+
52+
/* Set this just to make core cbo code happy */
53+
riscv_cbom_block_size = 1;
54+
riscv_noncoherent_supported();
55+
56+
return true;
57+
}
58+
59+
void __init_or_module andes_errata_patch_func(struct alt_entry *begin, struct alt_entry *end,
60+
unsigned long archid, unsigned long impid,
61+
unsigned int stage)
62+
{
63+
errata_probe_iocp(stage, archid, impid);
64+
65+
/* we have nothing to patch here ATM so just return back */
66+
}

arch/riscv/errata/thead/errata.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -120,11 +120,3 @@ void thead_errata_patch_func(struct alt_entry *begin, struct alt_entry *end,
120120
if (stage == RISCV_ALTERNATIVES_EARLY_BOOT)
121121
local_flush_icache_all();
122122
}
123-
124-
void thead_feature_probe_func(unsigned int cpu,
125-
unsigned long archid,
126-
unsigned long impid)
127-
{
128-
if ((archid == 0) && (impid == 0))
129-
per_cpu(misaligned_access_speed, cpu) = RISCV_HWPROBE_MISALIGNED_FAST;
130-
}

0 commit comments

Comments
 (0)