]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
riscv: Add xmipsexectl as a vendor extension
authorAleksa Paunovic <aleksa.paunovic@htecgroup.com>
Thu, 24 Jul 2025 15:23:26 +0000 (17:23 +0200)
committerPaul Walmsley <pjw@kernel.org>
Fri, 19 Sep 2025 02:36:00 +0000 (20:36 -0600)
Add support for MIPS vendor extensions. Add support for the xmipsexectl
vendor extension.

Signed-off-by: Aleksa Paunovic <aleksa.paunovic@htecgroup.com>
Reviewed-by: Alexandre Ghiti <alexghiti@rivosinc.com>
Link: https://lore.kernel.org/r/20250724-p8700-pause-v5-2-a6cbbe1c3412@htecgroup.com
[pjw@kernel.org: added the MIPS vendor ID from another patch to fix the build]
Signed-off-by: Paul Walmsley <pjw@kernel.org>
arch/riscv/Kconfig.vendor
arch/riscv/include/asm/vendor_extensions/mips.h [new file with mode: 0644]
arch/riscv/include/asm/vendorid_list.h
arch/riscv/kernel/vendor_extensions.c
arch/riscv/kernel/vendor_extensions/Makefile
arch/riscv/kernel/vendor_extensions/mips.c [new file with mode: 0644]

index e14f26368963c178e3271e0f716b27fff7671e78..3c1f92e406c3f21481b56e61229716fd02ab81b2 100644 (file)
@@ -16,6 +16,19 @@ config RISCV_ISA_VENDOR_EXT_ANDES
          If you don't know what to do here, say Y.
 endmenu
 
+menu "MIPS"
+config RISCV_ISA_VENDOR_EXT_MIPS
+       bool "MIPS vendor extension support"
+       select RISCV_ISA_VENDOR_EXT
+       default y
+       help
+         Say N here to disable detection of and support for all MIPS vendor
+         extensions. Without this option enabled, MIPS vendor extensions will
+         not be detected at boot and their presence not reported to userspace.
+
+         If you don't know what to do here, say Y.
+endmenu
+
 menu "SiFive"
 config RISCV_ISA_VENDOR_EXT_SIFIVE
        bool "SiFive vendor extension support"
diff --git a/arch/riscv/include/asm/vendor_extensions/mips.h b/arch/riscv/include/asm/vendor_extensions/mips.h
new file mode 100644 (file)
index 0000000..133e559
--- /dev/null
@@ -0,0 +1,18 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * Copyright (C) 2025 MIPS.
+ */
+
+#ifndef _ASM_RISCV_VENDOR_EXTENSIONS_MIPS_H
+#define _ASM_RISCV_VENDOR_EXTENSIONS_MIPS_H
+
+#include <linux/types.h>
+
+#define RISCV_ISA_VENDOR_EXT_XMIPSEXECTL       0
+
+#ifndef __ASSEMBLER__
+struct riscv_isa_vendor_ext_data_list;
+extern struct riscv_isa_vendor_ext_data_list riscv_isa_vendor_ext_list_mips;
+#endif
+
+#endif // _ASM_RISCV_VENDOR_EXTENSIONS_MIPS_H
index a5150cdf34d87f01baf6d3ef843bc2d6d8d54095..3b09874d7a6dfb8f8aa45b0be41c20711d539e78 100644 (file)
@@ -9,5 +9,6 @@
 #define MICROCHIP_VENDOR_ID    0x029
 #define SIFIVE_VENDOR_ID       0x489
 #define THEAD_VENDOR_ID                0x5b7
+#define MIPS_VENDOR_ID         0x722
 
 #endif
index 92d8ff81f42c9ceba63bef0170ab134564a24a4e..bb4a7592368560ebacbcd8a5ce335eea6312ea5c 100644 (file)
@@ -6,6 +6,7 @@
 #include <asm/vendorid_list.h>
 #include <asm/vendor_extensions.h>
 #include <asm/vendor_extensions/andes.h>
+#include <asm/vendor_extensions/mips.h>
 #include <asm/vendor_extensions/sifive.h>
 #include <asm/vendor_extensions/thead.h>
 
@@ -16,6 +17,9 @@ struct riscv_isa_vendor_ext_data_list *riscv_isa_vendor_ext_list[] = {
 #ifdef CONFIG_RISCV_ISA_VENDOR_EXT_ANDES
        &riscv_isa_vendor_ext_list_andes,
 #endif
+#ifdef CONFIG_RISCV_ISA_VENDOR_EXT_MIPS
+       &riscv_isa_vendor_ext_list_mips,
+#endif
 #ifdef CONFIG_RISCV_ISA_VENDOR_EXT_SIFIVE
        &riscv_isa_vendor_ext_list_sifive,
 #endif
@@ -49,6 +53,12 @@ bool __riscv_isa_vendor_extension_available(int cpu, unsigned long vendor, unsig
                cpu_bmap = riscv_isa_vendor_ext_list_andes.per_hart_isa_bitmap;
                break;
        #endif
+       #ifdef CONFIG_RISCV_ISA_VENDOR_EXT_MIPS
+       case MIPS_VENDOR_ID:
+               bmap = &riscv_isa_vendor_ext_list_mips.all_harts_isa_bitmap;
+               cpu_bmap = riscv_isa_vendor_ext_list_mips.per_hart_isa_bitmap;
+               break;
+       #endif
        #ifdef CONFIG_RISCV_ISA_VENDOR_EXT_SIFIVE
        case SIFIVE_VENDOR_ID:
                bmap = &riscv_isa_vendor_ext_list_sifive.all_harts_isa_bitmap;
index a4eca96d1c8a2fd165220f6439a3884cf90a9593..ccad4ebafb43412e72e654da3bdb9face53b80c6 100644 (file)
@@ -1,6 +1,7 @@
 # SPDX-License-Identifier: GPL-2.0-only
 
 obj-$(CONFIG_RISCV_ISA_VENDOR_EXT_ANDES)       += andes.o
+obj-$(CONFIG_RISCV_ISA_VENDOR_EXT_MIPS)        += mips.o
 obj-$(CONFIG_RISCV_ISA_VENDOR_EXT_SIFIVE)      += sifive.o
 obj-$(CONFIG_RISCV_ISA_VENDOR_EXT_SIFIVE)      += sifive_hwprobe.o
 obj-$(CONFIG_RISCV_ISA_VENDOR_EXT_THEAD)       += thead.o
diff --git a/arch/riscv/kernel/vendor_extensions/mips.c b/arch/riscv/kernel/vendor_extensions/mips.c
new file mode 100644 (file)
index 0000000..f691129
--- /dev/null
@@ -0,0 +1,22 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Copyright (C) 2025 MIPS.
+ */
+
+#include <asm/cpufeature.h>
+#include <asm/vendor_extensions.h>
+#include <asm/vendor_extensions/mips.h>
+
+#include <linux/array_size.h>
+#include <linux/cpumask.h>
+#include <linux/types.h>
+
+/* All MIPS vendor extensions supported in Linux */
+static const struct riscv_isa_ext_data riscv_isa_vendor_ext_mips[] = {
+       __RISCV_ISA_EXT_DATA(xmipsexectl, RISCV_ISA_VENDOR_EXT_XMIPSEXECTL),
+};
+
+struct riscv_isa_vendor_ext_data_list riscv_isa_vendor_ext_list_mips = {
+       .ext_data_count = ARRAY_SIZE(riscv_isa_vendor_ext_mips),
+       .ext_data = riscv_isa_vendor_ext_mips,
+};