From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f181.google.com (mail-pl1-f181.google.com [209.85.214.181]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 621D1399D02 for ; Thu, 11 Jun 2026 20:14:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.181 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781208845; cv=none; b=q8xFYLi5wPyJRAYtVnD/BdEGtHmSpvDBWTve4RkR6QAbN/rtRg2LcJaWWXgZlQjX53PnUxwGwnVUxsUWmB9leuxNyYUtv0njsGxfv+3G8ym1Q8t6I1vb0pqFTBPN2ZUSx3shUmf7U6Dkb9u4nIfCm9o8/L6QjU+9B9fxD/nGeas= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781208845; c=relaxed/simple; bh=Z4SvLEe4IZzEFb+cAK8zmYNsxWif6BZPOJ1s9j1h5ok=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=APPWJzOF+SFB5Hq+ry4xEE6bw3bDrezenfHreXE8vz4HD2cEzpiPp9N6wl4+Tp5rofcAQAE7swtNPMwsQtxhsbq0K3C94yziVyVrdev5zZ8YHz1ShrquuCd/TR73MQ91cFjpDFpyP8y4kiK1j6pEXmlWXQf13SpdAueOymr4cuE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=subBRzxU; arc=none smtp.client-ip=209.85.214.181 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="subBRzxU" Received: by mail-pl1-f181.google.com with SMTP id d9443c01a7336-2c0b944f6edso2459505ad.2 for ; Thu, 11 Jun 2026 13:14:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1781208844; x=1781813644; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=uDWD971MMwJ6qHve2YOG8FRlEWvJHn1EivNT/6Ew/sE=; b=subBRzxU6wqEIMs10BPd4MrM9K2Km5PQZrfQ0rt/Q5tKppBSCCDb1Hf1fe/Q5fcixH gBIDtIh5ScwLEBOjxxQi60h48i5PgGrQIRM/r7BFqlyl6iMu2Fj2aIRNVyxi7phAL+Wl T2usjuYHg1hhtF0SyCtRoBf9NDfUet3o0aAKdQ7EspDxVKlODA9GQWma6NbKqgEW5i0S 2TptfM8VaTDS8lBTrIEREXuTFYVtJx3NbPOS+d5EdCoxgLZ/YPSeaJN6xhfRzmXPnjFq NftUt5ZC7s2ZuTouXSSvd67wkrDpjnMkewTT/BMtoN9Wn06mRACxsevnc0UHHBiJgV7s OLxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781208844; x=1781813644; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=uDWD971MMwJ6qHve2YOG8FRlEWvJHn1EivNT/6Ew/sE=; b=oWOXxPP6MXEl5auFhNu9en1foqJTc2DFrstzv0FpGwQZPWwBBo8Qn1LpGlu9vx7VZg 2kW64TX2Z463YBiTb1J8RZZtaAyAoGemaEjKbOAM8sMIEJUvvmxYBsdXtZSqDxes4U0f lWyQzYOnvzRf+b7TmepSRcpYBRY2worBgddq5ulUJgRf4T4+//8L/5jeBacbDGPf/y7X CqmUaLa0C5qZYT1lamwdkTFRBIiyu3FG+IFGRNmuGhN38++WZyFwGlwCOkDILPy30NS/ OGZv5BeyE6Mfbs2I68a19XoLoWh3joI239eW0+qKCPPuq3C//in0FvPCsoM/4W6QrCyh cerA== X-Forwarded-Encrypted: i=1; AFNElJ9yxNxLVP2eZcduyukPwr6Z4AmhPh8rIoFjrpxo1Izh/TrNL5L0RhH4Z7VAk0+2LHFY22oHbFgeA0QmPHs=@vger.kernel.org X-Gm-Message-State: AOJu0Yz11U88kHo09Y7vhgXlNILcNtDgwgKAHgRl3ohNLP9qsNdysmHw nCxK3UpjZJ1lY/NwXog+5DLGVSA6epKeIVI9+yZUBEjAWt5VT3muBpMg X-Gm-Gg: Acq92OGVGb0vX4YiPgYfgAx5K1zIEfJBrZqJbFeDJpBDTvzrZAGpOY6sphkuwKFKPwA bbmetjF/J1SRdvky9aBH+yULRS3injfhXyGYE/kKGyS9TtJ2M2uMoNH7LvxCIp47MIrMxMa5OF+ a+AUwuj/th1DjMNo2pOnb1flUNIC9gSXmsnGmKwOKFBGnCezAwXAKkfBaB3FhbSWQ9NSdbx+Ieg xCexogeVcHwt3GHzkYs1bbHePewaEjlNVSPJAoI63i7timAZkDtJZs/DXH3FypH6Igmvk2HaGSx /RrXrNn8rSjJ2AX/Gyf6ZnXJVdrAZUuJul7I1NyeB5ucUjJNqwzsQ3MnnMT2W6PZ00A7tHwP6xP FQQEyhqOXEuXQeWzc0uCtmGRqngYFsIyHSEVshOTxzoVTiYQ4bmt148ltwdLmkdFB353fjH0X/Q == X-Received: by 2002:a17:902:ce83:b0:2be:39bd:8dd8 with SMTP id d9443c01a7336-2c2f4cdfce1mr50813675ad.33.1781208843652; Thu, 11 Jun 2026 13:14:03 -0700 (PDT) Received: from [127.0.1.1] ([2a12:a305:4::302d]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2c164f875casm288730475ad.22.2026.06.11.13.13.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Jun 2026 13:14:03 -0700 (PDT) From: Guodong Xu Date: Thu, 11 Jun 2026 16:12:44 -0400 Subject: [PATCH v4 07/16] riscv: Add B to hwcap and hwprobe Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20260611-rva23u64-hwprobe-v2-v4-7-3f01a2449488@gmail.com> References: <20260611-rva23u64-hwprobe-v2-v4-0-3f01a2449488@gmail.com> In-Reply-To: <20260611-rva23u64-hwprobe-v2-v4-0-3f01a2449488@gmail.com> To: Jonathan Corbet , Shuah Khan , Paul Walmsley , Palmer Dabbelt , Albert Ou , Alexandre Ghiti , Zong Li , Deepak Gupta , Anup Patel , Atish Patra , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Yixun Lan , Chen Wang , Inochi Amaoto Cc: linux-doc@vger.kernel.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, kvm-riscv@lists.infradead.org, Paul Walmsley , Conor Dooley , devicetree@vger.kernel.org, spacemit@lists.linux.dev, sophgo@lists.linux.dev, linux-kselftest@vger.kernel.org, Palmer Dabbelt , Guodong Xu , Andrew Jones X-Mailer: b4 0.15.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=5372; i=docular.xu@gmail.com; h=from:subject:message-id; bh=b9UB3n6jmzaPS8rRQ79NB7tbcWOa+iWqyCC7BBkj9z0=; b=owGbwMvMwCXWtEl1Z3CGpCDjabUkhixtsYNXY26adu+oE13Ek8+VV5YZY2jT9kRVP/ofS+KVU 85Sd953lLIwiHExyIopshw+2pK99ZVPtO9zzh8wc1iZQIYwcHEKwET+bmJkOM5xtb45/4mHQtDm yM86/lGHdzCWTlksyJuTfojDfMXlZIb/uRv0z5/48uPwSxkh9UeORzZZHX4n57KI2SLxy4fXbaq XmQE= X-Developer-Key: i=docular.xu@gmail.com; a=openpgp; fpr=90B1DC3DF0BD10FD1227BD6344F254AF42F143EE From: Andrew Jones Add B to hwcap and ensure when B is present that Zba, Zbb, and Zbs are all set. Also expose B via hwprobe (RISCV_HWPROBE_EXT_B in RISCV_HWPROBE_KEY_IMA_EXT_1) so that userspace can probe B directly, mirroring the F/D/C/V pattern where each is reported via both hwcap and hwprobe. Signed-off-by: Andrew Jones [Add B to hwprobe] Signed-off-by: Guodong Xu --- v4: No change. v3: - Indent the added hwprobe.rst entry to match the normalized style. - Rebased onto v7.1-rc6: index isa2hwcap[] via RISCV_ISA_EXT_B to match the macro-ization in commit 41337097f2823. v2: - Rebased to v7.1-rc2 - Add B to hwprobe (RISCV_HWPROBE_EXT_B at IMA_EXT_1 bit 6) and document it in hwprobe.rst, so userspace can probe B directly. --- Documentation/arch/riscv/hwprobe.rst | 4 ++++ arch/riscv/include/asm/hwcap.h | 1 + arch/riscv/include/uapi/asm/hwcap.h | 1 + arch/riscv/include/uapi/asm/hwprobe.h | 1 + arch/riscv/kernel/cpufeature.c | 8 ++++++++ arch/riscv/kernel/sys_hwprobe.c | 1 + 6 files changed, 16 insertions(+) diff --git a/Documentation/arch/riscv/hwprobe.rst b/Documentation/arch/riscv/hwprobe.rst index 893e1a1215d23..fc68dea397aae 100644 --- a/Documentation/arch/riscv/hwprobe.rst +++ b/Documentation/arch/riscv/hwprobe.rst @@ -421,3 +421,7 @@ The following keys are defined: * :c:macro:`RISCV_HWPROBE_EXT_ZA64RS`: The Za64rs extension is supported, as defined in the RISC-V Profiles specification starting from commit b1d80660 ("Updated to ratified state.") + + * :c:macro:`RISCV_HWPROBE_EXT_B`: The B extension is supported, as defined + in version 1.0 of the Bit-Manipulation ISA extensions, and implies the + presence of the Zba, Zbb, and Zbs sub-extensions. diff --git a/arch/riscv/include/asm/hwcap.h b/arch/riscv/include/asm/hwcap.h index 0acb7a01ecc0f..58523b3a1998a 100644 --- a/arch/riscv/include/asm/hwcap.h +++ b/arch/riscv/include/asm/hwcap.h @@ -11,6 +11,7 @@ #include #define RISCV_ISA_EXT_A ('a' - 'a') +#define RISCV_ISA_EXT_B ('b' - 'a') #define RISCV_ISA_EXT_C ('c' - 'a') #define RISCV_ISA_EXT_D ('d' - 'a') #define RISCV_ISA_EXT_F ('f' - 'a') diff --git a/arch/riscv/include/uapi/asm/hwcap.h b/arch/riscv/include/uapi/asm/hwcap.h index c52bb7bbbabe9..96b7cf854e090 100644 --- a/arch/riscv/include/uapi/asm/hwcap.h +++ b/arch/riscv/include/uapi/asm/hwcap.h @@ -21,6 +21,7 @@ #define COMPAT_HWCAP_ISA_F (1 << ('F' - 'A')) #define COMPAT_HWCAP_ISA_D (1 << ('D' - 'A')) #define COMPAT_HWCAP_ISA_C (1 << ('C' - 'A')) +#define COMPAT_HWCAP_ISA_B (1 << ('B' - 'A')) #define COMPAT_HWCAP_ISA_V (1 << ('V' - 'A')) #endif /* _UAPI_ASM_RISCV_HWCAP_H */ diff --git a/arch/riscv/include/uapi/asm/hwprobe.h b/arch/riscv/include/uapi/asm/hwprobe.h index 58d1e86e47ae7..430dc49a82863 100644 --- a/arch/riscv/include/uapi/asm/hwprobe.h +++ b/arch/riscv/include/uapi/asm/hwprobe.h @@ -121,6 +121,7 @@ struct riscv_hwprobe { #define RISCV_HWPROBE_EXT_ZICCIF (1ULL << 3) #define RISCV_HWPROBE_EXT_ZICCRSE (1ULL << 4) #define RISCV_HWPROBE_EXT_ZA64RS (1ULL << 5) +#define RISCV_HWPROBE_EXT_B (1ULL << 6) /* Increase RISCV_HWPROBE_MAX_KEY when adding items. */ diff --git a/arch/riscv/kernel/cpufeature.c b/arch/riscv/kernel/cpufeature.c index b9538e69fa1b3..e0197160af6dd 100644 --- a/arch/riscv/kernel/cpufeature.c +++ b/arch/riscv/kernel/cpufeature.c @@ -468,6 +468,12 @@ static const unsigned int riscv_c_exts[] = { RISCV_ISA_EXT_ZCD, }; +static const unsigned int riscv_b_exts[] = { + RISCV_ISA_EXT_ZBA, + RISCV_ISA_EXT_ZBB, + RISCV_ISA_EXT_ZBS, +}; + /* * The canonical order of ISA extension names in the ISA string is defined in * chapter 27 of the unprivileged specification. @@ -515,6 +521,7 @@ const struct riscv_isa_ext_data riscv_isa_ext[] = { __RISCV_ISA_EXT_DATA_VALIDATE(d, RISCV_ISA_EXT_D, riscv_ext_d_validate), __RISCV_ISA_EXT_DATA(q, RISCV_ISA_EXT_Q), __RISCV_ISA_EXT_SUPERSET(c, RISCV_ISA_EXT_C, riscv_c_exts), + __RISCV_ISA_EXT_SUPERSET(b, RISCV_ISA_EXT_B, riscv_b_exts), __RISCV_ISA_EXT_SUPERSET_VALIDATE(v, RISCV_ISA_EXT_V, riscv_v_exts, riscv_ext_vector_float_validate), __RISCV_ISA_EXT_DATA(h, RISCV_ISA_EXT_H), __RISCV_ISA_EXT_SUPERSET_VALIDATE(zicbom, RISCV_ISA_EXT_ZICBOM, riscv_xlinuxenvcfg_exts, riscv_ext_zicbom_validate), @@ -1133,6 +1140,7 @@ void __init riscv_fill_hwcap(void) isa2hwcap[RISCV_ISA_EXT_F] = COMPAT_HWCAP_ISA_F; isa2hwcap[RISCV_ISA_EXT_D] = COMPAT_HWCAP_ISA_D; isa2hwcap[RISCV_ISA_EXT_C] = COMPAT_HWCAP_ISA_C; + isa2hwcap[RISCV_ISA_EXT_B] = COMPAT_HWCAP_ISA_B; isa2hwcap[RISCV_ISA_EXT_V] = COMPAT_HWCAP_ISA_V; if (!acpi_disabled) { diff --git a/arch/riscv/kernel/sys_hwprobe.c b/arch/riscv/kernel/sys_hwprobe.c index b15ac9adf7920..dcc102bf8f183 100644 --- a/arch/riscv/kernel/sys_hwprobe.c +++ b/arch/riscv/kernel/sys_hwprobe.c @@ -210,6 +210,7 @@ static void hwprobe_isa_ext1(struct riscv_hwprobe *pair, EXT_KEY(isainfo->isa, ZICCIF, pair->value, missing); EXT_KEY(isainfo->isa, ZICCRSE, pair->value, missing); EXT_KEY(isainfo->isa, ZA64RS, pair->value, missing); + EXT_KEY(isainfo->isa, B, pair->value, missing); } /* Now turn off reporting features if any CPU is missing it. */ -- 2.43.0