Skip to content

Commit bb4b0f8

Browse files
aleksapaunovic-htecPaul Walmsley
authored andcommitted
riscv: hwprobe: Add MIPS vendor extension probing
Add a new hwprobe key "RISCV_HWPROBE_KEY_VENDOR_EXT_MIPS_0" which allows userspace to probe for the new 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-4-a6cbbe1c3412@htecgroup.com [pjw@kernel.org: fixed some checkpatch issues] Signed-off-by: Paul Walmsley <pjw@kernel.org>
1 parent 1d4ce63 commit bb4b0f8

7 files changed

Lines changed: 56 additions & 1 deletion

File tree

arch/riscv/include/asm/hwprobe.h

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

99
#include <uapi/asm/hwprobe.h>
1010

11-
#define RISCV_HWPROBE_MAX_KEY 13
11+
#define RISCV_HWPROBE_MAX_KEY 14
1212

1313
static inline bool riscv_hwprobe_key_is_valid(__s64 key)
1414
{
@@ -22,6 +22,7 @@ static inline bool hwprobe_key_is_bitmask(__s64 key)
2222
case RISCV_HWPROBE_KEY_IMA_EXT_0:
2323
case RISCV_HWPROBE_KEY_CPUPERF_0:
2424
case RISCV_HWPROBE_KEY_VENDOR_EXT_THEAD_0:
25+
case RISCV_HWPROBE_KEY_VENDOR_EXT_MIPS_0:
2526
case RISCV_HWPROBE_KEY_VENDOR_EXT_SIFIVE_0:
2627
return true;
2728
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/* SPDX-License-Identifier: GPL-2.0-only */
2+
/*
3+
* Copyright (C) 2025 MIPS.
4+
*/
5+
6+
#ifndef _ASM_RISCV_VENDOR_EXTENSIONS_MIPS_HWPROBE_H_
7+
#define _ASM_RISCV_VENDOR_EXTENSIONS_MIPS_HWPROBE_H_
8+
9+
#include <linux/cpumask.h>
10+
#include <uapi/asm/hwprobe.h>
11+
12+
#ifdef CONFIG_RISCV_ISA_VENDOR_EXT_MIPS
13+
void hwprobe_isa_vendor_ext_mips_0(struct riscv_hwprobe *pair, const struct cpumask *cpus);
14+
#else
15+
static inline void hwprobe_isa_vendor_ext_mips_0(struct riscv_hwprobe *pair,
16+
const struct cpumask *cpus)
17+
{
18+
pair->value = 0;
19+
}
20+
#endif
21+
22+
#endif // _ASM_RISCV_VENDOR_EXTENSIONS_MIPS_HWPROBE_H_

arch/riscv/include/uapi/asm/hwprobe.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ struct riscv_hwprobe {
106106
#define RISCV_HWPROBE_KEY_VENDOR_EXT_THEAD_0 11
107107
#define RISCV_HWPROBE_KEY_ZICBOM_BLOCK_SIZE 12
108108
#define RISCV_HWPROBE_KEY_VENDOR_EXT_SIFIVE_0 13
109+
#define RISCV_HWPROBE_KEY_VENDOR_EXT_MIPS_0 14
109110
/* Increase RISCV_HWPROBE_MAX_KEY when adding items. */
110111

111112
/* Flags */
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2+
3+
#define RISCV_HWPROBE_VENDOR_EXT_XMIPSEXECTL BIT(0)

arch/riscv/kernel/sys_hwprobe.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include <asm/uaccess.h>
1616
#include <asm/unistd.h>
1717
#include <asm/vector.h>
18+
#include <asm/vendor_extensions/mips_hwprobe.h>
1819
#include <asm/vendor_extensions/sifive_hwprobe.h>
1920
#include <asm/vendor_extensions/thead_hwprobe.h>
2021
#include <vdso/vsyscall.h>
@@ -307,6 +308,9 @@ static void hwprobe_one_pair(struct riscv_hwprobe *pair,
307308
case RISCV_HWPROBE_KEY_VENDOR_EXT_THEAD_0:
308309
hwprobe_isa_vendor_ext_thead_0(pair, cpus);
309310
break;
311+
case RISCV_HWPROBE_KEY_VENDOR_EXT_MIPS_0:
312+
hwprobe_isa_vendor_ext_mips_0(pair, cpus);
313+
break;
310314

311315
/*
312316
* For forward compatibility, unknown keys don't fail the whole

arch/riscv/kernel/vendor_extensions/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
obj-$(CONFIG_RISCV_ISA_VENDOR_EXT_ANDES) += andes.o
44
obj-$(CONFIG_RISCV_ISA_VENDOR_EXT_MIPS) += mips.o
5+
obj-$(CONFIG_RISCV_ISA_VENDOR_EXT_MIPS) += mips_hwprobe.o
56
obj-$(CONFIG_RISCV_ISA_VENDOR_EXT_SIFIVE) += sifive.o
67
obj-$(CONFIG_RISCV_ISA_VENDOR_EXT_SIFIVE) += sifive_hwprobe.o
78
obj-$(CONFIG_RISCV_ISA_VENDOR_EXT_THEAD) += thead.o
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// SPDX-License-Identifier: GPL-2.0-only
2+
/*
3+
* Copyright (C) 2025 MIPS.
4+
*/
5+
6+
#include <asm/vendor_extensions.h>
7+
#include <asm/vendor_extensions/mips.h>
8+
#include <asm/vendor_extensions/mips_hwprobe.h>
9+
#include <asm/vendor_extensions/vendor_hwprobe.h>
10+
11+
#include <linux/cpumask.h>
12+
#include <linux/types.h>
13+
14+
#include <uapi/asm/hwprobe.h>
15+
#include <uapi/asm/vendor/mips.h>
16+
17+
void hwprobe_isa_vendor_ext_mips_0(struct riscv_hwprobe *pair,
18+
const struct cpumask *cpus)
19+
{
20+
VENDOR_EXTENSION_SUPPORTED(pair, cpus,
21+
riscv_isa_vendor_ext_list_mips.per_hart_isa_bitmap,
22+
{ VENDOR_EXT_KEY(XMIPSEXECTL); });
23+
}

0 commit comments

Comments
 (0)