Commit bb4b0f8a authored by Aleksa Paunovic's avatar Aleksa Paunovic Committed by Paul Walmsley
Browse files

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: default avatarAleksa Paunovic <aleksa.paunovic@htecgroup.com>
Reviewed-by: default avatarAlexandre 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: default avatarPaul Walmsley <pjw@kernel.org>
parent 1d4ce63e
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -8,7 +8,7 @@

#include <uapi/asm/hwprobe.h>

#define RISCV_HWPROBE_MAX_KEY 13
#define RISCV_HWPROBE_MAX_KEY 14

static inline bool riscv_hwprobe_key_is_valid(__s64 key)
{
@@ -22,6 +22,7 @@ static inline bool hwprobe_key_is_bitmask(__s64 key)
	case RISCV_HWPROBE_KEY_IMA_EXT_0:
	case RISCV_HWPROBE_KEY_CPUPERF_0:
	case RISCV_HWPROBE_KEY_VENDOR_EXT_THEAD_0:
	case RISCV_HWPROBE_KEY_VENDOR_EXT_MIPS_0:
	case RISCV_HWPROBE_KEY_VENDOR_EXT_SIFIVE_0:
		return true;
	}
+22 −0
Original line number Diff line number Diff line
/* SPDX-License-Identifier: GPL-2.0-only */
/*
 * Copyright (C) 2025 MIPS.
 */

#ifndef _ASM_RISCV_VENDOR_EXTENSIONS_MIPS_HWPROBE_H_
#define _ASM_RISCV_VENDOR_EXTENSIONS_MIPS_HWPROBE_H_

#include <linux/cpumask.h>
#include <uapi/asm/hwprobe.h>

#ifdef CONFIG_RISCV_ISA_VENDOR_EXT_MIPS
void hwprobe_isa_vendor_ext_mips_0(struct riscv_hwprobe *pair, const struct cpumask *cpus);
#else
static inline void hwprobe_isa_vendor_ext_mips_0(struct riscv_hwprobe *pair,
						 const struct cpumask *cpus)
{
	pair->value = 0;
}
#endif

#endif // _ASM_RISCV_VENDOR_EXTENSIONS_MIPS_HWPROBE_H_
+1 −0
Original line number Diff line number Diff line
@@ -106,6 +106,7 @@ struct riscv_hwprobe {
#define RISCV_HWPROBE_KEY_VENDOR_EXT_THEAD_0	11
#define RISCV_HWPROBE_KEY_ZICBOM_BLOCK_SIZE	12
#define RISCV_HWPROBE_KEY_VENDOR_EXT_SIFIVE_0	13
#define RISCV_HWPROBE_KEY_VENDOR_EXT_MIPS_0	14
/* Increase RISCV_HWPROBE_MAX_KEY when adding items. */

/* Flags */
+3 −0
Original line number Diff line number Diff line
/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */

#define RISCV_HWPROBE_VENDOR_EXT_XMIPSEXECTL	BIT(0)
+4 −0
Original line number Diff line number Diff line
@@ -15,6 +15,7 @@
#include <asm/uaccess.h>
#include <asm/unistd.h>
#include <asm/vector.h>
#include <asm/vendor_extensions/mips_hwprobe.h>
#include <asm/vendor_extensions/sifive_hwprobe.h>
#include <asm/vendor_extensions/thead_hwprobe.h>
#include <vdso/vsyscall.h>
@@ -307,6 +308,9 @@ static void hwprobe_one_pair(struct riscv_hwprobe *pair,
	case RISCV_HWPROBE_KEY_VENDOR_EXT_THEAD_0:
		hwprobe_isa_vendor_ext_thead_0(pair, cpus);
		break;
	case RISCV_HWPROBE_KEY_VENDOR_EXT_MIPS_0:
		hwprobe_isa_vendor_ext_mips_0(pair, cpus);
		break;

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