Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

RISC-V: hwprobe: Expose Zicbom extension and its block size

Expose Zicbom through hwprobe and also provide a key to extract its
respective block size.

[ alex: Fix merge conflicts and hwprobe numbering ]

Reviewed-by: Andrew Jones <ajones@ventanamicro.com>
Reviewed-by: Samuel Holland <samuel.holland@sifive.com>
Signed-off-by: Yunhui Cui <cuiyunhui@bytedance.com>
Link: https://lore.kernel.org/r/20250226063206.71216-3-cuiyunhui@bytedance.com
Signed-off-by: Alexandre Ghiti <alexghiti@rivosinc.com>

authored by

Yunhui Cui and committed by
Alexandre Ghiti
eb100397 de70b532

+16 -2
+6
Documentation/arch/riscv/hwprobe.rst
··· 260 260 defined in the RISC-V ISA manual starting from commit 4dc23d6229de 261 261 ("Added Chapter title to BF16"). 262 262 263 + * :c:macro:`RISCV_HWPROBE_EXT_ZICBOM`: The Zicbom extension is supported, as 264 + ratified in commit 3dd606f ("Create cmobase-v1.0.pdf") of riscv-CMOs. 265 + 263 266 * :c:macro:`RISCV_HWPROBE_KEY_CPUPERF_0`: Deprecated. Returns similar values to 264 267 :c:macro:`RISCV_HWPROBE_KEY_MISALIGNED_SCALAR_PERF`, but the key was 265 268 mistakenly classified as a bitmask rather than a value. ··· 324 321 * :c:macro:`RISCV_HWPROBE_VENDOR_EXT_XTHEADVECTOR`: The xtheadvector vendor 325 322 extension is supported in the T-Head ISA extensions spec starting from 326 323 commit a18c801634 ("Add T-Head VECTOR vendor extension. "). 324 + 325 + * :c:macro:`RISCV_HWPROBE_KEY_ZICBOM_BLOCK_SIZE`: An unsigned int which 326 + represents the size of the Zicbom block in bytes.
+1 -1
arch/riscv/include/asm/hwprobe.h
··· 8 8 9 9 #include <uapi/asm/hwprobe.h> 10 10 11 - #define RISCV_HWPROBE_MAX_KEY 11 11 + #define RISCV_HWPROBE_MAX_KEY 12 12 12 13 13 static inline bool riscv_hwprobe_key_is_valid(__s64 key) 14 14 {
+2
arch/riscv/include/uapi/asm/hwprobe.h
··· 78 78 #define RISCV_HWPROBE_EXT_ZFBFMIN (1ULL << 52) 79 79 #define RISCV_HWPROBE_EXT_ZVFBFMIN (1ULL << 53) 80 80 #define RISCV_HWPROBE_EXT_ZVFBFWMA (1ULL << 54) 81 + #define RISCV_HWPROBE_EXT_ZICBOM (1ULL << 55) 81 82 #define RISCV_HWPROBE_KEY_CPUPERF_0 5 82 83 #define RISCV_HWPROBE_MISALIGNED_UNKNOWN (0 << 0) 83 84 #define RISCV_HWPROBE_MISALIGNED_EMULATED (1 << 0) ··· 101 100 #define RISCV_HWPROBE_MISALIGNED_VECTOR_FAST 3 102 101 #define RISCV_HWPROBE_MISALIGNED_VECTOR_UNSUPPORTED 4 103 102 #define RISCV_HWPROBE_KEY_VENDOR_EXT_THEAD_0 11 103 + #define RISCV_HWPROBE_KEY_ZICBOM_BLOCK_SIZE 12 104 104 /* Increase RISCV_HWPROBE_MAX_KEY when adding items. */ 105 105 106 106 /* Flags */
+7 -1
arch/riscv/kernel/sys_hwprobe.c
··· 107 107 EXT_KEY(ZCA); 108 108 EXT_KEY(ZCB); 109 109 EXT_KEY(ZCMOP); 110 + EXT_KEY(ZICBOM); 110 111 EXT_KEY(ZICBOZ); 111 112 EXT_KEY(ZICNTR); 112 113 EXT_KEY(ZICOND); ··· 167 166 pair->value &= ~missing; 168 167 } 169 168 170 - static bool hwprobe_ext0_has(const struct cpumask *cpus, unsigned long ext) 169 + static bool hwprobe_ext0_has(const struct cpumask *cpus, u64 ext) 171 170 { 172 171 struct riscv_hwprobe pair; 173 172 ··· 284 283 pair->value = 0; 285 284 if (hwprobe_ext0_has(cpus, RISCV_HWPROBE_EXT_ZICBOZ)) 286 285 pair->value = riscv_cboz_block_size; 286 + break; 287 + case RISCV_HWPROBE_KEY_ZICBOM_BLOCK_SIZE: 288 + pair->value = 0; 289 + if (hwprobe_ext0_has(cpus, RISCV_HWPROBE_EXT_ZICBOM)) 290 + pair->value = riscv_cbom_block_size; 287 291 break; 288 292 case RISCV_HWPROBE_KEY_HIGHEST_VIRT_ADDRESS: 289 293 pair->value = user_max_virt_addr();