Skip to content

Commit e0a5049

Browse files
yaozihongPaul Walmsley
authored andcommitted
riscv: hwprobe: Expose Zicbop extension and its block size
- Add `RISCV_HWPROBE_EXT_ZICBOP` to report the presence of the Zicbop extension. - Add `RISCV_HWPROBE_KEY_ZICBOP_BLOCK_SIZE` to expose the block size (in bytes) when Zicbop is supported. - Update hwprobe.rst to document the new extension bit and block size key, following the existing Zicbom/Zicboz style. Reviewed-by: Andrew Jones <ajones@ventanamicro.com> Signed-off-by: Yao Zihong <zihong.plct@isrc.iscas.ac.cn> Link: https://patch.msgid.link/20251118162436.15485-2-zihong.plct@isrc.iscas.ac.cn [pjw@kernel.org: updated to apply] Signed-off-by: Paul Walmsley <pjw@kernel.org>
1 parent ad1bb4b commit e0a5049

4 files changed

Lines changed: 15 additions & 1 deletion

File tree

Documentation/arch/riscv/hwprobe.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,9 @@ The following keys are defined:
278278
ratified in commit 49f49c842ff9 ("Update to Rafified state") of
279279
riscv-zabha.
280280

281+
* :c:macro:`RISCV_HWPROBE_EXT_ZICBOP`: The Zicbop extension is supported, as
282+
ratified in commit 3dd606f ("Create cmobase-v1.0.pdf") of riscv-CMOs.
283+
281284
* :c:macro:`RISCV_HWPROBE_KEY_CPUPERF_0`: Deprecated. Returns similar values to
282285
:c:macro:`RISCV_HWPROBE_KEY_MISALIGNED_SCALAR_PERF`, but the key was
283286
mistakenly classified as a bitmask rather than a value.
@@ -373,3 +376,6 @@ The following keys are defined:
373376
* :c:macro:`RISCV_HWPROBE_VENDOR_EXT_XSFVFWMACCQQQ`: The Xsfvfwmaccqqq
374377
vendor extension is supported in version 1.0 of Matrix Multiply Accumulate
375378
Instruction Extensions Specification.
379+
380+
* :c:macro:`RISCV_HWPROBE_KEY_ZICBOP_BLOCK_SIZE`: An unsigned int which
381+
represents the size of the Zicbop block in bytes.

arch/riscv/include/asm/hwprobe.h

Lines changed: 1 addition & 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 14
11+
#define RISCV_HWPROBE_MAX_KEY 15
1212

1313
static inline bool riscv_hwprobe_key_is_valid(__s64 key)
1414
{

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ struct riscv_hwprobe {
8383
#define RISCV_HWPROBE_EXT_ZALRSC (1ULL << 57)
8484
#define RISCV_HWPROBE_EXT_ZABHA (1ULL << 58)
8585
#define RISCV_HWPROBE_EXT_ZALASR (1ULL << 59)
86+
#define RISCV_HWPROBE_EXT_ZICBOP (1ULL << 60)
8687
#define RISCV_HWPROBE_KEY_CPUPERF_0 5
8788
#define RISCV_HWPROBE_MISALIGNED_UNKNOWN (0 << 0)
8889
#define RISCV_HWPROBE_MISALIGNED_EMULATED (1 << 0)
@@ -108,6 +109,7 @@ struct riscv_hwprobe {
108109
#define RISCV_HWPROBE_KEY_ZICBOM_BLOCK_SIZE 12
109110
#define RISCV_HWPROBE_KEY_VENDOR_EXT_SIFIVE_0 13
110111
#define RISCV_HWPROBE_KEY_VENDOR_EXT_MIPS_0 14
112+
#define RISCV_HWPROBE_KEY_ZICBOP_BLOCK_SIZE 15
111113
/* Increase RISCV_HWPROBE_MAX_KEY when adding items. */
112114

113115
/* Flags */

arch/riscv/kernel/sys_hwprobe.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ static void hwprobe_isa_ext0(struct riscv_hwprobe *pair,
123123
EXT_KEY(ZCB);
124124
EXT_KEY(ZCMOP);
125125
EXT_KEY(ZICBOM);
126+
EXT_KEY(ZICBOP);
126127
EXT_KEY(ZICBOZ);
127128
EXT_KEY(ZICNTR);
128129
EXT_KEY(ZICOND);
@@ -303,6 +304,11 @@ static void hwprobe_one_pair(struct riscv_hwprobe *pair,
303304
if (hwprobe_ext0_has(cpus, RISCV_HWPROBE_EXT_ZICBOM))
304305
pair->value = riscv_cbom_block_size;
305306
break;
307+
case RISCV_HWPROBE_KEY_ZICBOP_BLOCK_SIZE:
308+
pair->value = 0;
309+
if (hwprobe_ext0_has(cpus, RISCV_HWPROBE_EXT_ZICBOP))
310+
pair->value = riscv_cbop_block_size;
311+
break;
306312
case RISCV_HWPROBE_KEY_HIGHEST_VIRT_ADDRESS:
307313
pair->value = user_max_virt_addr();
308314
break;

0 commit comments

Comments
 (0)