From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f169.google.com (mail-pl1-f169.google.com [209.85.214.169]) (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 B544139891F for ; Thu, 11 Jun 2026 20:14:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.169 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781208863; cv=none; b=jFPIXKaDqRomzlOLCT7kG2rqoX1ptpRc8ooGkAmHZoqTueG1bhSyAuLBDQems5r8BJ8POASnOdJ+PkXNzbYYaEX7va5dc6rcmfTQHVd9Cbo14f0FNH+6H1S6up7GDgc22pQ7vPSV1FNt8qvfszPNheENEMTzbXQKOpIebqYwt1M= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781208863; c=relaxed/simple; bh=GUC8kvko49SeLpQio5c73u8anxlTnIalYE6ydi19kAw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=uvCTwsXwvqs15MaIzn4COk0+WlBaaLudyNNxmui/EOQ1EqzGnl7bs0N8GW1E5f63wm1n6PtPUB6x6UjfteL+221W+ow1pUmIW7Y1oVAvHqSDYEqRGeLYeEmfIZUNFa1UveyGxBUT7ovGnnLPtJe4ocCtAM5oFolpK6umDZVKFNs= 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=LoM+XRG8; arc=none smtp.client-ip=209.85.214.169 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="LoM+XRG8" Received: by mail-pl1-f169.google.com with SMTP id d9443c01a7336-2c0c2d8b95bso2079875ad.1 for ; Thu, 11 Jun 2026 13:14:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1781208860; x=1781813660; 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=yMGfGczB0NxDEd0np6M2cDGmk32GLLRpI8e709o6daA=; b=LoM+XRG8lvBBzFVFAJmFYWBzxkoQP7Sg8Zus5HBBmvJoBlIjj8NfvrsqYAlwDbslip UwUFlfV7nfb0OwHWze2ipX81Ev+St77Ukwjcib2fOC82orRbJTFQTi2oRz7maRDONgs+ CPIQnUwBdUQd9eC7qRRlVE0IE8CRxh1v+GICXJFyIhYDLAXiQrwdZrKgYkX/wyZQgYez xGXHvq8nn8PobIh5dgweUGCS1tePrK+1fMK6QutuIZ8yENzgy+OOrTP2JtHqH7i1Rv5P tEyOlpwz0WnUHucnajj2MS46n3P2BJ7F9Cf4lHjnVvacElyolHUGI4hZlGVXo/ol78C7 in/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781208860; x=1781813660; 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=yMGfGczB0NxDEd0np6M2cDGmk32GLLRpI8e709o6daA=; b=maBNtls1OBPG1iK4lemjVRQsR8Zk5xbFYtO2LWaqv/g5XcrW6Eh2/U8aceS6qzQHd3 mLxVtkM0IZjnXfQYX23QPD1hhNNZ+6G94afsacJLVbwjqKiq8wOhrime7YEc1olbVeHX yYZXEsMYNszG3M39GfTAgjucvKYJnMO8riOoz/4KS1R1/ATQyTOSB1U8McXTy94Not3X oukh20a6FTOJ4CTrE7ingQIu/WAlRJ4B4TqhCI5mO/sB2j7Sa2WseErQDTNp1R0YcSpu fVdLvlvGoJmO+pbQAH0GUcmf/0q0D+WMu4iNXaGON7kQHPJnG+WC9niPOQL9GqeoAqzE bqig== X-Forwarded-Encrypted: i=1; AFNElJ9VIf/dZ14RpyjuGBj9iUE38l8SReVb2lgF8LJzEwFbI4KQIhQC6qSfgx7pl6APeKjS6drIiwTFb6YWmbk=@vger.kernel.org X-Gm-Message-State: AOJu0YzZKwEtlGw2vKxOS7lCWM+9MIdLnKCeCCdFn8YglgmZBussk5NN VsLgbtYz8th3UqDCoTlmQZmuX4Ac1ohuGH8HcU8PzXCD/2QUBXGbV21k X-Gm-Gg: Acq92OHbnahQhyoqZsr9v7bYkEXyy1Wbk9YxUQVNcchGCYpb6xCAlN6s1k8uV86zJa1 jlvXfjbOCnYenR/qeaIA9FfuOoZeZNM1WUa/JEPQaA6s6VlBqG02C5zqKSvOXeacyXUnAx6KDjt 55MOISw8QjeNk1wQ0v1JaKRxAhXdXRNHSpII1KVs3cyXJ2myu10BKzN2ySEgZy5mXjAY7+4QkFx MbkA7dFfXXuRpl0CsB2drtK039QNSV4UJTxLS91OPZNJjGqFugXQfi09bZPzi7TWDRBwryg4ixq B93jTgpAht6YzFunjH6KB4oGXZinuVDnbsyJ/HeJKTOZnwurJnrUfbZIIAQuIR8ZypJZVUDPL3D EPq2sfluvJlWiYH6tpxz0SUlQI9BIyzBRRaF7nUTC4pGIGIwFhePeKM6L0V78tWTGi/WhFZGwXg == X-Received: by 2002:a17:903:1a06:b0:2c0:e5ee:f56c with SMTP id d9443c01a7336-2c2f21a0ademr49861065ad.20.1781208860004; Thu, 11 Jun 2026 13:14:20 -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.14.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Jun 2026 13:14:19 -0700 (PDT) From: Guodong Xu Date: Thu, 11 Jun 2026 16:12:46 -0400 Subject: [PATCH v4 09/16] riscv: Add Zic64b to cpufeature 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-9-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 , Qingwei Hu X-Mailer: b4 0.15.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=5498; i=docular.xu@gmail.com; h=from:subject:message-id; bh=nGcs7EOITyjoy7uSccUTn+y3G2TeXfDwFJQsTGZZRmY=; b=owGbwMvMwCXWtEl1Z3CGpCDjabUkhixtsUPmOxf9nXjyoMnC1vs5VV/yvwq8uZhwmOPzB2/lR w8uh2z51lHKwiDGxSArpshy+GhL9tZXPtG+zzl/wMxhZQIZwsDFKQATuRHDyNC+8ZLz+e1PLxQG PeDeacx92vPirw9eCru37O0+63JQWJyD4Q+Xmn6uoIng/eC0tWdzPFyk35ySKTl26hUbx4kFh7P 8jPgA X-Developer-Key: i=docular.xu@gmail.com; a=openpgp; fpr=90B1DC3DF0BD10FD1227BD6344F254AF42F143EE From: Qingwei Hu Zic64b mandates 64-byte naturally aligned cache blocks and is a mandatory extension of the RVA22 and RVA23 profiles. Allocate a RISCV_ISA_EXT_ZIC64B id, parse "zic64b" from the ISA string with a validate callback that requires each cbom/cbop/cboz cache block size to be 64 bytes when it is present, and export it through hwprobe. Link: https://lists.riscv.org/g/tech-unprivileged/topic/question_about_zic64b_and/119631059 Signed-off-by: Qingwei Hu Co-developed-by: Guodong Xu Signed-off-by: Guodong Xu --- v4: - Credit Qingwei Hu's earlier Zic64b cpufeature patch: set him as author, with Co-developed-by (Guodong Xu). - Validate only the cbom/cbop/cboz block sizes that are present; Zic64b does not imply the CMO extensions (Conor, Qingwei, Greg). - Add a Link: to Greg's confirmation on the tech-unprivileged list. - Add the missing blank line before the ZIC64B hwprobe.rst entry (Andrew). - Did not carry Andrew Jones's v3 Reviewed-by: the validation was rewritten (present block sizes only) and the patch is now authored by Qingwei, so it warrants a fresh review. v3: New patch. --- Documentation/arch/riscv/hwprobe.rst | 4 ++++ arch/riscv/include/asm/hwcap.h | 1 + arch/riscv/include/uapi/asm/hwprobe.h | 1 + arch/riscv/kernel/cpufeature.c | 19 +++++++++++++++++++ arch/riscv/kernel/sys_hwprobe.c | 1 + 5 files changed, 26 insertions(+) diff --git a/Documentation/arch/riscv/hwprobe.rst b/Documentation/arch/riscv/hwprobe.rst index fc68dea397aae..32a14331eb9de 100644 --- a/Documentation/arch/riscv/hwprobe.rst +++ b/Documentation/arch/riscv/hwprobe.rst @@ -425,3 +425,7 @@ The following keys are defined: * :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. + + * :c:macro:`RISCV_HWPROBE_EXT_ZIC64B`: The Zic64b extension is supported, + as defined in the RISC-V Profiles specification starting from commit + b1d80660 ("Updated to ratified state.") diff --git a/arch/riscv/include/asm/hwcap.h b/arch/riscv/include/asm/hwcap.h index 58523b3a1998a..36572c1ff438a 100644 --- a/arch/riscv/include/asm/hwcap.h +++ b/arch/riscv/include/asm/hwcap.h @@ -117,6 +117,7 @@ #define RISCV_ISA_EXT_ZICCAMOA 107 #define RISCV_ISA_EXT_ZICCIF 108 #define RISCV_ISA_EXT_ZA64RS 109 +#define RISCV_ISA_EXT_ZIC64B 110 #define RISCV_ISA_EXT_XLINUXENVCFG 127 diff --git a/arch/riscv/include/uapi/asm/hwprobe.h b/arch/riscv/include/uapi/asm/hwprobe.h index 430dc49a82863..36ec8ab470423 100644 --- a/arch/riscv/include/uapi/asm/hwprobe.h +++ b/arch/riscv/include/uapi/asm/hwprobe.h @@ -122,6 +122,7 @@ struct riscv_hwprobe { #define RISCV_HWPROBE_EXT_ZICCRSE (1ULL << 4) #define RISCV_HWPROBE_EXT_ZA64RS (1ULL << 5) #define RISCV_HWPROBE_EXT_B (1ULL << 6) +#define RISCV_HWPROBE_EXT_ZIC64B (1ULL << 7) /* Increase RISCV_HWPROBE_MAX_KEY when adding items. */ diff --git a/arch/riscv/kernel/cpufeature.c b/arch/riscv/kernel/cpufeature.c index e0197160af6dd..29dff41313e65 100644 --- a/arch/riscv/kernel/cpufeature.c +++ b/arch/riscv/kernel/cpufeature.c @@ -154,6 +154,24 @@ static int riscv_ext_zicbop_validate(const struct riscv_isa_ext_data *data, return 0; } +static int riscv_ext_zic64b_validate(const struct riscv_isa_ext_data *data, + const unsigned long *isa_bitmap) +{ + /* + * Zic64b mandates 64-byte naturally aligned cache blocks; cross-check the + * cbom/cbop/cboz block-size (when declared) device-tree properties to + * avoid inconsistency. + */ + if ((riscv_cbom_block_size && riscv_cbom_block_size != 64) || + (riscv_cbop_block_size && riscv_cbop_block_size != 64) || + (riscv_cboz_block_size && riscv_cboz_block_size != 64)) { + pr_err("Zic64b detected in ISA string, disabling as a CBO block size is not 64 bytes\n"); + return -EINVAL; + } + + return 0; +} + static int riscv_ext_f_validate(const struct riscv_isa_ext_data *data, const unsigned long *isa_bitmap) { @@ -524,6 +542,7 @@ const struct riscv_isa_ext_data riscv_isa_ext[] = { __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_DATA_VALIDATE(zic64b, RISCV_ISA_EXT_ZIC64B, riscv_ext_zic64b_validate), __RISCV_ISA_EXT_SUPERSET_VALIDATE(zicbom, RISCV_ISA_EXT_ZICBOM, riscv_xlinuxenvcfg_exts, riscv_ext_zicbom_validate), __RISCV_ISA_EXT_DATA_VALIDATE(zicbop, RISCV_ISA_EXT_ZICBOP, riscv_ext_zicbop_validate), __RISCV_ISA_EXT_SUPERSET_VALIDATE(zicboz, RISCV_ISA_EXT_ZICBOZ, riscv_xlinuxenvcfg_exts, riscv_ext_zicboz_validate), diff --git a/arch/riscv/kernel/sys_hwprobe.c b/arch/riscv/kernel/sys_hwprobe.c index dcc102bf8f183..3e80e5551ae0d 100644 --- a/arch/riscv/kernel/sys_hwprobe.c +++ b/arch/riscv/kernel/sys_hwprobe.c @@ -211,6 +211,7 @@ static void hwprobe_isa_ext1(struct riscv_hwprobe *pair, EXT_KEY(isainfo->isa, ZICCRSE, pair->value, missing); EXT_KEY(isainfo->isa, ZA64RS, pair->value, missing); EXT_KEY(isainfo->isa, B, pair->value, missing); + EXT_KEY(isainfo->isa, ZIC64B, pair->value, missing); } /* Now turn off reporting features if any CPU is missing it. */ -- 2.43.0