Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
RISC-V: Add a syscall for HW probing
We don't have enough space for these all in ELF_HWCAP{,2} and there's no system call that quite does this, so let's just provide an arch-specific one to probe for hardware capabilities. This currently just provides m{arch,imp,vendor}id, but with the key-value pairs we can pass more in the future. Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com> --- I havn't run this yet.
- Loading branch information
1 parent
568035b
commit e90cd87
Showing
9 changed files
with
264 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
.. SPDX-License-Identifier: GPL-2.0 | ||
RISC-V Hardware Probing Interface | ||
--------------------------------- | ||
|
||
The RISC-V hardware probing interface is based around a single syscall, which | ||
is defined in <asm/hwprobe.h>:: | ||
|
||
struct riscv_hwprobe { | ||
__u64 key, value; | ||
}; | ||
|
||
long sys_riscv_hwprobe(struct riscv_hwprobe *pairs, size_t pair_count, | ||
size_t base_key, size_t cpu_count, cpu_set_t *cpus, | ||
unsigned long flags); | ||
|
||
The arguments are split into three groups: an array of key-value pairs, a CPU | ||
set, and some flags. The key-value pairs are supplied with a count and an | ||
base, which is the first key that will be probed for. The CPU set is defined | ||
by CPU_SET(3), the indicated features will be supported on all CPUs in the set. | ||
There are currently no flags, this value must be zero for future compatibility. | ||
|
||
On success the number of filled out pairs is returned, on failure a negative | ||
error code is returned. | ||
|
||
The following keys are defined: | ||
|
||
* :RISCV_HWPROBE_KEY_MVENDORID:: Contains the value of :mvendorid:, as per the | ||
ISA specifications. | ||
* :RISCV_HWPROBE_KEY_MARCHID:: Contains the value of :marchid:, as per the ISA | ||
specifications. | ||
* :RISCV_HWPROBE_KEY_MIMPLID:: Contains the value of :mimplid:, as per the ISA | ||
specifications. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ RISC-V architecture | |
|
||
boot-image-header | ||
vm-layout | ||
hwprobe | ||
patch-acceptance | ||
|
||
features | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/* SPDX-License-Identifier: GPL-2.0-only */ | ||
/* | ||
* Copyright 2022 Rivos, Inc | ||
*/ | ||
|
||
#ifndef _ASM_CPUFEATURE_H | ||
#define _ASM_CPUFEATURE_H | ||
|
||
/* | ||
* These are probed via a device_initcall(), via either the SBI or directly | ||
* from the cooresponding CSRs. | ||
*/ | ||
struct riscv_cpuinfo { | ||
unsigned long mvendorid; | ||
unsigned long marchid; | ||
unsigned long mimpid; | ||
}; | ||
|
||
DECLARE_PER_CPU(struct riscv_cpuinfo, riscv_cpuinfo); | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ | ||
/* | ||
* Copyright 2022 Rivos, Inc | ||
*/ | ||
|
||
#ifndef _ASM_HWPROBE_H | ||
#define _ASM_HWPROBE_H | ||
|
||
#include <uapi/asm/hwprobe.h> | ||
|
||
#define RISCV_HWPROBE_MAX_KEY 2 | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ | ||
/* | ||
* Copyright 2022 Rivos, Inc | ||
*/ | ||
|
||
#ifndef _UAPI_ASM_HWPROBE_H | ||
#define _UAPI_ASM_HWPROBE_H | ||
|
||
#include <linux/types.h> | ||
|
||
/* | ||
* Interface for probing hardware capabilities from userspace, see | ||
* Documentation/riscv/hwprobe.rst for more information. | ||
*/ | ||
struct riscv_hwprobe { | ||
__u64 key, val; | ||
}; | ||
|
||
#define RISCV_HWPROBE_KEY_MVENDORID 0 | ||
#define RISCV_HWPROBE_KEY_MARCHID 1 | ||
#define RISCV_HWPROBE_KEY_MIMPID 2 | ||
/* Increase RISCV_HWPROBE_MAX_KEY when adding items. */ | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters