Skip to content

Commit cb7e366

Browse files
committed
Merge tag 'riscv-for-linus-6.18-mw1' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux
Pull RISC-V updates from Paul Walmsley - Replacement of __ASSEMBLY__ with __ASSEMBLER__ in header files (other architectures have already merged this type of cleanup) - The introduction of ioremap_wc() for RISC-V - Cleanup of the RISC-V kprobes code to use mostly-extant macros rather than open code - A RISC-V kprobes unit test - An architecture-specific endianness swap macro set implementation, leveraging some dedicated RISC-V instructions for this purpose if they are available - The ability to identity and communicate to userspace the presence of a MIPS P8700-specific ISA extension, and to leverage its MIPS-specific PAUSE implementation in cpu_relax() - Several other miscellaneous cleanups * tag 'riscv-for-linus-6.18-mw1' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux: (39 commits) riscv: errata: Fix the PAUSE Opcode for MIPS P8700 riscv: hwprobe: Document MIPS xmipsexectl vendor extension riscv: hwprobe: Add MIPS vendor extension probing riscv: Add xmipsexectl instructions riscv: Add xmipsexectl as a vendor extension dt-bindings: riscv: Add xmipsexectl ISA extension description riscv: cpufeature: add validation for zfa, zfh and zfhmin perf: riscv: skip empty batches in counter start selftests: riscv: Add README for RISC-V KSelfTest riscv: sbi: Switch to new sys-off handler API riscv: Move vendor errata definitions to new header RISC-V: ACPI: enable parsing the BGRT table riscv: Enable ARCH_HAVE_NMI_SAFE_CMPXCHG riscv: pi: use 'targets' instead of extra-y in Makefile riscv: introduce asm/swab.h riscv: mmap(): use unsigned offset type in riscv_sys_mmap drivers/perf: riscv: Remove redundant ternary operators riscv: mm: Use mmu-type from FDT to limit SATP mode riscv: mm: Return intended SATP mode for noXlvl options riscv: kprobes: Remove duplication of RV_EXTRACT_ITYPE_IMM ...
2 parents feafee2 + 0b0ca95 commit cb7e366

86 files changed

Lines changed: 1147 additions & 530 deletions

Some content is hidden

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

Documentation/arch/riscv/hwprobe.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,15 @@ The following keys are defined:
327327
* :c:macro:`RISCV_HWPROBE_MISALIGNED_VECTOR_UNSUPPORTED`: Misaligned vector accesses are
328328
not supported at all and will generate a misaligned address fault.
329329

330+
* :c:macro:`RISCV_HWPROBE_KEY_VENDOR_EXT_MIPS_0`: A bitmask containing the
331+
mips vendor extensions that are compatible with the
332+
:c:macro:`RISCV_HWPROBE_BASE_BEHAVIOR_IMA`: base system behavior.
333+
334+
* MIPS
335+
336+
* :c:macro:`RISCV_HWPROBE_VENDOR_EXT_XMIPSEXECTL`: The xmipsexectl vendor
337+
extension is supported in the MIPS ISA extensions spec.
338+
330339
* :c:macro:`RISCV_HWPROBE_KEY_VENDOR_EXT_THEAD_0`: A bitmask containing the
331340
thead vendor extensions that are compatible with the
332341
:c:macro:`RISCV_HWPROBE_BASE_BEHAVIOR_IMA`: base system behavior.

Documentation/devicetree/bindings/riscv/extensions.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -662,6 +662,12 @@ properties:
662662
Registers in the AX45MP datasheet.
663663
https://www.andestech.com/wp-content/uploads/AX45MP-1C-Rev.-5.0.0-Datasheet.pdf
664664

665+
# MIPS
666+
- const: xmipsexectl
667+
description:
668+
The MIPS extension for execution control as documented in
669+
https://mips.com/wp-content/uploads/2025/06/P8700_Programmers_Reference_Manual_Rev1.84_5-31-2025.pdf
670+
665671
# SiFive
666672
- const: xsfvqmaccdod
667673
description:

arch/riscv/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ config RISCV
5454
select ARCH_HAS_TICK_BROADCAST if GENERIC_CLOCKEVENTS_BROADCAST
5555
select ARCH_HAS_UBSAN
5656
select ARCH_HAS_VDSO_ARCH_DATA if GENERIC_VDSO_DATA_STORE
57+
select ARCH_HAVE_NMI_SAFE_CMPXCHG
5758
select ARCH_KEEP_MEMBLOCK if ACPI
5859
select ARCH_MHP_MEMMAP_ON_MEMORY_ENABLE if 64BIT && MMU
5960
select ARCH_OPTIONAL_KERNEL_RWX if ARCH_HAS_STRICT_KERNEL_RWX

arch/riscv/Kconfig.errata

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,29 @@ config ERRATA_ANDES_CMO
2121

2222
If you don't know what to do here, say "Y".
2323

24+
config ERRATA_MIPS
25+
bool "MIPS errata"
26+
depends on RISCV_ALTERNATIVE
27+
help
28+
All MIPS errata Kconfig depend on this Kconfig. Disabling
29+
this Kconfig will disable all MIPS errata. Please say "Y"
30+
here if your platform uses MIPS CPU cores.
31+
32+
Otherwise, please say "N" here to avoid unnecessary overhead.
33+
34+
config ERRATA_MIPS_P8700_PAUSE_OPCODE
35+
bool "Fix the PAUSE Opcode for MIPS P8700"
36+
depends on ERRATA_MIPS && 64BIT
37+
default n
38+
help
39+
The RISCV MIPS P8700 uses a different opcode for PAUSE.
40+
It is a 'hint' encoding of the SLLI instruction,
41+
with rd=0, rs1=0 and imm=5. It will behave as a NOP
42+
instruction if no additional behavior beyond that of
43+
SLLI is implemented.
44+
45+
If you are not using the P8700 processor, say n.
46+
2447
config ERRATA_SIFIVE
2548
bool "SiFive errata"
2649
depends on RISCV_ALTERNATIVE

arch/riscv/Kconfig.vendor

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,19 @@ config RISCV_ISA_VENDOR_EXT_ANDES
1616
If you don't know what to do here, say Y.
1717
endmenu
1818

19+
menu "MIPS"
20+
config RISCV_ISA_VENDOR_EXT_MIPS
21+
bool "MIPS vendor extension support"
22+
select RISCV_ISA_VENDOR_EXT
23+
default y
24+
help
25+
Say N here to disable detection of and support for all MIPS vendor
26+
extensions. Without this option enabled, MIPS vendor extensions will
27+
not be detected at boot and their presence not reported to userspace.
28+
29+
If you don't know what to do here, say Y.
30+
endmenu
31+
1932
menu "SiFive"
2033
config RISCV_ISA_VENDOR_EXT_SIFIVE
2134
bool "SiFive vendor extension support"

arch/riscv/errata/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,6 @@ endif
1313
endif
1414

1515
obj-$(CONFIG_ERRATA_ANDES) += andes/
16+
obj-$(CONFIG_ERRATA_MIPS) += mips/
1617
obj-$(CONFIG_ERRATA_SIFIVE) += sifive/
1718
obj-$(CONFIG_ERRATA_THEAD) += thead/

arch/riscv/errata/mips/Makefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
ifdef CONFIG_RISCV_ALTERNATIVE_EARLY
2+
CFLAGS_errata.o := -mcmodel=medany
3+
endif
4+
5+
obj-y += errata.o

arch/riscv/errata/mips/errata.c

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
// SPDX-License-Identifier: GPL-2.0-only
2+
/*
3+
* Copyright (C) 2025 MIPS.
4+
*/
5+
6+
#include <linux/memory.h>
7+
#include <linux/module.h>
8+
#include <asm/text-patching.h>
9+
#include <asm/alternative.h>
10+
#include <asm/errata_list.h>
11+
#include <asm/vendorid_list.h>
12+
#include <asm/vendor_extensions.h>
13+
#include <asm/vendor_extensions/mips.h>
14+
15+
static inline bool errata_probe_pause(void)
16+
{
17+
if (!IS_ENABLED(CONFIG_ERRATA_MIPS_P8700_PAUSE_OPCODE))
18+
return false;
19+
20+
if (!riscv_isa_vendor_extension_available(MIPS_VENDOR_ID, XMIPSEXECTL))
21+
return false;
22+
23+
return true;
24+
}
25+
26+
static u32 mips_errata_probe(void)
27+
{
28+
u32 cpu_req_errata = 0;
29+
30+
if (errata_probe_pause())
31+
cpu_req_errata |= BIT(ERRATA_MIPS_P8700_PAUSE_OPCODE);
32+
33+
return cpu_req_errata;
34+
}
35+
36+
void mips_errata_patch_func(struct alt_entry *begin, struct alt_entry *end,
37+
unsigned long archid, unsigned long impid,
38+
unsigned int stage)
39+
{
40+
struct alt_entry *alt;
41+
u32 cpu_req_errata = mips_errata_probe();
42+
u32 tmp;
43+
44+
BUILD_BUG_ON(ERRATA_MIPS_NUMBER >= RISCV_VENDOR_EXT_ALTERNATIVES_BASE);
45+
46+
if (stage == RISCV_ALTERNATIVES_EARLY_BOOT)
47+
return;
48+
49+
for (alt = begin; alt < end; alt++) {
50+
if (alt->vendor_id != MIPS_VENDOR_ID)
51+
continue;
52+
53+
if (alt->patch_id >= ERRATA_MIPS_NUMBER) {
54+
WARN(1, "MIPS errata id:%d not in kernel errata list\n",
55+
alt->patch_id);
56+
continue;
57+
}
58+
59+
tmp = (1U << alt->patch_id);
60+
if (cpu_req_errata && tmp) {
61+
mutex_lock(&text_mutex);
62+
patch_text_nosync(ALT_OLD_PTR(alt), ALT_ALT_PTR(alt),
63+
alt->alt_len);
64+
mutex_unlock(&text_mutex);
65+
}
66+
}
67+
}

arch/riscv/include/asm/alternative-macros.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
#ifdef CONFIG_RISCV_ALTERNATIVE
66

7-
#ifdef __ASSEMBLY__
7+
#ifdef __ASSEMBLER__
88

99
.macro ALT_ENTRY oldptr newptr vendor_id patch_id new_len
1010
.4byte \oldptr - .
@@ -53,7 +53,7 @@
5353
#define __ALTERNATIVE_CFG(...) ALTERNATIVE_CFG __VA_ARGS__
5454
#define __ALTERNATIVE_CFG_2(...) ALTERNATIVE_CFG_2 __VA_ARGS__
5555

56-
#else /* !__ASSEMBLY__ */
56+
#else /* !__ASSEMBLER__ */
5757

5858
#include <asm/asm.h>
5959
#include <linux/stringify.h>
@@ -98,7 +98,7 @@
9898
__ALTERNATIVE_CFG(old_c, new_c_1, vendor_id_1, patch_id_1, enable_1) \
9999
ALT_NEW_CONTENT(vendor_id_2, patch_id_2, enable_2, new_c_2)
100100

101-
#endif /* __ASSEMBLY__ */
101+
#endif /* __ASSEMBLER__ */
102102

103103
#define _ALTERNATIVE_CFG(old_c, new_c, vendor_id, patch_id, CONFIG_k) \
104104
__ALTERNATIVE_CFG(old_c, new_c, vendor_id, patch_id, IS_ENABLED(CONFIG_k))
@@ -109,7 +109,7 @@
109109
new_c_2, vendor_id_2, patch_id_2, IS_ENABLED(CONFIG_k_2))
110110

111111
#else /* CONFIG_RISCV_ALTERNATIVE */
112-
#ifdef __ASSEMBLY__
112+
#ifdef __ASSEMBLER__
113113

114114
.macro ALTERNATIVE_CFG old_c
115115
\old_c
@@ -118,12 +118,12 @@
118118
#define __ALTERNATIVE_CFG(old_c, ...) ALTERNATIVE_CFG old_c
119119
#define __ALTERNATIVE_CFG_2(old_c, ...) ALTERNATIVE_CFG old_c
120120

121-
#else /* !__ASSEMBLY__ */
121+
#else /* !__ASSEMBLER__ */
122122

123123
#define __ALTERNATIVE_CFG(old_c, ...) old_c "\n"
124124
#define __ALTERNATIVE_CFG_2(old_c, ...) old_c "\n"
125125

126-
#endif /* __ASSEMBLY__ */
126+
#endif /* __ASSEMBLER__ */
127127

128128
#define _ALTERNATIVE_CFG(old_c, ...) __ALTERNATIVE_CFG(old_c)
129129
#define _ALTERNATIVE_CFG_2(old_c, ...) __ALTERNATIVE_CFG_2(old_c)

arch/riscv/include/asm/alternative.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
#include <asm/alternative-macros.h>
1010

11-
#ifndef __ASSEMBLY__
11+
#ifndef __ASSEMBLER__
1212

1313
#ifdef CONFIG_RISCV_ALTERNATIVE
1414

@@ -48,6 +48,9 @@ struct alt_entry {
4848
void andes_errata_patch_func(struct alt_entry *begin, struct alt_entry *end,
4949
unsigned long archid, unsigned long impid,
5050
unsigned int stage);
51+
void mips_errata_patch_func(struct alt_entry *begin, struct alt_entry *end,
52+
unsigned long archid, unsigned long impid,
53+
unsigned int stage);
5154
void sifive_errata_patch_func(struct alt_entry *begin, struct alt_entry *end,
5255
unsigned long archid, unsigned long impid,
5356
unsigned int stage);

0 commit comments

Comments
 (0)