From nobody Sat Feb 7 06:45:11 2026 Received: from mail-pf1-f176.google.com (mail-pf1-f176.google.com [209.85.210.176]) (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 011443101B0 for ; Sun, 25 Jan 2026 05:48:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769320115; cv=none; b=pZdmcdKGm0c4ty8oMDHkC7aEZTW9KfsJNFgcvLD0IQWbhI1C+xlkm0JizO8G2Jx/QNxRBidsE7KlY4jA9ptMf0Lxf4OGDXn1qrWMjqu2WQrq6WFm/mLjGSqdEIwLoucVEsBENTGaw1q6yYoIc3NbPLlDOKFTct0cKeq2L1V8VOA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769320115; c=relaxed/simple; bh=MggLumQq1x29FlbN8dhuDp+k2EL5u3F4d+5kR9T5TFY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=C/ZRGn9Txbt9zNrRYeAKdnTDEnd9i1akvk2M1ZXdP1j0/uXr01aFy7vxaAs7RKzSzw6CfBW2UyvDiUPnDO92YV2BbKdGz4XyrlLTdJbLZ7uX08eyp0XonibSIDjn9wzTcy9A3tJIXm8fByQffWzrWmXOK7EFl/RgXowU4XyMiCQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=riscstar.com; spf=pass smtp.mailfrom=riscstar.com; dkim=pass (2048-bit key) header.d=riscstar-com.20230601.gappssmtp.com header.i=@riscstar-com.20230601.gappssmtp.com header.b=RtnK43jV; arc=none smtp.client-ip=209.85.210.176 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=riscstar.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=riscstar.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=riscstar-com.20230601.gappssmtp.com header.i=@riscstar-com.20230601.gappssmtp.com header.b="RtnK43jV" Received: by mail-pf1-f176.google.com with SMTP id d2e1a72fcca58-8230c2d3128so1343767b3a.0 for ; Sat, 24 Jan 2026 21:48:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=riscstar-com.20230601.gappssmtp.com; s=20230601; t=1769320111; x=1769924911; 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=gQeXE83sx7gap+YTDZDQSdBwe9aoYbsG4akyTawLjBk=; b=RtnK43jVQRfemUyaa4UoMArkRPVshdZTGUHZBwHZhofxhvrprvu4dbU1zaXpuYJIHS RFv2Z3XzmitVC98nxBgH2xHwtxe0WSOLHyZLh5tcZrPalJron/YrzeRM++MDWW4EjumN xRMws3n9pgqu8eaJ6dWvD9zbklLGTAVxTl9e9wersilWfydNWa+SF4lC1uV697bEL90w iVRHIDsKLGtpggmtq7bXYu3ApHeQSzfEpKGUp3tedoihE1uUZhdmL9uiikwh2TQ9uz7e zvu0nfN6OvZ6osBLpLL0vOqrjQB8cOuDoDqUcDOnjQTgaxzov+DU00fsuNLHOl8gp4N1 l0Mg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1769320111; x=1769924911; 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=gQeXE83sx7gap+YTDZDQSdBwe9aoYbsG4akyTawLjBk=; b=uyFkKtON7ytox1BKKuADzb4Q1qDiw4vw6m5IlnH1XkUIoNd2h7a4Yzr04+Z6A9QV+4 dPaCO8J/VpKZwvw63lnEvDeqs2nROCmwH5RfdRuoMVLd0nls5ectClwYQyrZYe9WFrIW TT7RL+WmClq9477qgHu8S2al3wa/0Ht3SuZJ7dIj0nIDN7Y/fnLHa+12ndXhiOfM5B2T BLrX9LsUx/YWblOwb1WcV5cZx0GA1fEc/cQWRNdOzKdWD96OsYzs37vD36BOEPQ0Tj0L izDrNLcQLrFoZqhXu2MCs8OEjlnN0i2XLb2WzjlhsAjV3CdJKx6wEsmMlkySUUEWmJSe Shjg== X-Forwarded-Encrypted: i=1; AJvYcCWT9n9ZNcjWbkAytnVi2zgMk+zBWzm75bwAqNPMBC2KnIRg0M5QrF90ocUX0by3AQmCDSv2uEy21INPKYU=@vger.kernel.org X-Gm-Message-State: AOJu0Yy0nvL2fxJLRVjTEA+AXBk9+E0ko3Hpj7munZNXHFEbsd+pu5fv OT64mqNfNAJqIvdZbe3k2ZJvr4zYigQJy9SG6W2Ly4rI6KlbWCgyOcZMZI8VjbMYje0= X-Gm-Gg: AZuq6aKKIxtVkicZpROt2Hc8Q4M6wc5lYtrEEgV9Gl65SzlAdyfDtG3GJwPxfv6jWYN M/npWI1l0m7ep0RX2ASxX0dVHLQm1wETS7raMYMjj9RYfF+cB7ToQ+SCf6U/LESoNzjw57q1KzO kIJoI51kP2Q193qkajQtdvfqG0Pi+fH7y2CoDbTOoaI/BhynxU/7e/gdVeT9qwTVAuu+59YWYbk PQLC5uhblJU0GkjFX6XXWHx+s8Ii6uvvJsx4KtnOnLWO6EkfMKSzcrVKeIJoE0eAdOtr9dPfzBw rosw+CN2SARQm5Ki6AETMFJrvXHuum001MjoNzPhNs8pUDHwMPQ/RvvStXxVyxBSm0em9q1kpeV JX+VzpcLG56qGo9HDM/taFV4dyCe35N7Q0WiS2yDHn5/LSuPPp+HN7dxrf5vxVlISVX6mqC3Qvm zp2ZAPIHmyuuGC4tVbf5/mAU4yF2UNiWZ0gpBLUg5ggg== X-Received: by 2002:a05:6a00:9511:b0:823:135e:7336 with SMTP id d2e1a72fcca58-823412a3382mr712548b3a.53.1769320111277; Sat, 24 Jan 2026 21:48:31 -0800 (PST) Received: from [127.0.1.1] ([2a12:a305:4::30fc]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-c635a3f1ebesm5680016a12.19.2026.01.24.21.48.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 24 Jan 2026 21:48:30 -0800 (PST) From: Guodong Xu Date: Sun, 25 Jan 2026 09:36:07 +0800 Subject: [PATCH v2 2/3] riscv: cpufeature: Add ISA extension parsing for Supm 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: quoted-printable Message-Id: <20260125-supm-ext-id-v2-2-1e3b9714c860@riscstar.com> References: <20260125-supm-ext-id-v2-0-1e3b9714c860@riscstar.com> In-Reply-To: <20260125-supm-ext-id-v2-0-1e3b9714c860@riscstar.com> To: Rob Herring , Krzysztof Kozlowski , Conor Dooley , Samuel Holland , Heinrich Schuchardt , Paul Walmsley , Palmer Dabbelt , Albert Ou , Alexandre Ghiti , Evan Green , Andrew Jones , Conor Dooley Cc: Paul Walmsley , Conor Dooley , devicetree@vger.kernel.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Guodong Xu X-Mailer: b4 0.14.3 Supm has been ratified in the RISC-V Pointer Masking specification (Version 1.0, 10/2024) and is mandated in RVA23 Profiles (Version 1.0, 2024-10-17) for RVA23U64. Supm indicates userspace pointer masking support. Remove the previous macro aliasing of Supm to Ssnpm/Smnpm in hwcap.h, treating Supm as a distinct RISC-V ISA extension ID. Add ISA parsing logic for Supm, and implement a validator to ensure that Supm is only reported as available if Kconfig allows it and the underlying Ssnpm (for supervisor mode) or Smnpm (for machine mode) extension is present. Supm relies on Ssnpm or Smnpm to provide the underlying hardware implementation. With this change, "supm" will be reported (when available) in /proc/cpuinfo as part of the "isa" and "hart isa" string. Reviewed-by: Conor Dooley Link: https://lore.kernel.org/lkml/20260101-legume-engraved-0fae8282cfbe@sp= ud/#r [1] Link: https://lore.kernel.org/all/4ebbe14b-2579-4ba6-808d-d50c24641d04@sifi= ve.com/#r [2] Signed-off-by: Guodong Xu --- v2: Add Reviewed-by from Conor. Update RISCV_ISA_EXT_SUPM id to solve rebase conflict. --- arch/riscv/include/asm/hwcap.h | 3 +-- arch/riscv/kernel/cpufeature.c | 35 +++++++++++++++++++++++++++++++++-- 2 files changed, 34 insertions(+), 4 deletions(-) diff --git a/arch/riscv/include/asm/hwcap.h b/arch/riscv/include/asm/hwcap.h index 7ef8e5f55c8d..aa2af21f3bd3 100644 --- a/arch/riscv/include/asm/hwcap.h +++ b/arch/riscv/include/asm/hwcap.h @@ -112,6 +112,7 @@ #define RISCV_ISA_EXT_ZCLSD 103 #define RISCV_ISA_EXT_ZICFILP 104 #define RISCV_ISA_EXT_ZICFISS 105 +#define RISCV_ISA_EXT_SUPM 106 =20 #define RISCV_ISA_EXT_XLINUXENVCFG 127 =20 @@ -120,10 +121,8 @@ =20 #ifdef CONFIG_RISCV_M_MODE #define RISCV_ISA_EXT_SxAIA RISCV_ISA_EXT_SMAIA -#define RISCV_ISA_EXT_SUPM RISCV_ISA_EXT_SMNPM #else #define RISCV_ISA_EXT_SxAIA RISCV_ISA_EXT_SSAIA -#define RISCV_ISA_EXT_SUPM RISCV_ISA_EXT_SSNPM #endif =20 #endif /* _ASM_RISCV_HWCAP_H */ diff --git a/arch/riscv/kernel/cpufeature.c b/arch/riscv/kernel/cpufeature.c index 1734f9a4c2fd..e1f7ad882289 100644 --- a/arch/riscv/kernel/cpufeature.c +++ b/arch/riscv/kernel/cpufeature.c @@ -317,6 +317,27 @@ static int riscv_cfiss_validate(const struct riscv_isa= _ext_data *data, return 0; } =20 +static int riscv_ext_supm_validate(const struct riscv_isa_ext_data *data, + const unsigned long *isa_bitmap) +{ + if (!IS_ENABLED(CONFIG_RISCV_ISA_SUPM)) + return -EINVAL; + + /* + * Supm requires Ssnpm for S-mode or Smnpm for M-mode to provide + * pointer masking for the U-mode execution environment. + */ + if (IS_ENABLED(CONFIG_RISCV_M_MODE)) { + if (__riscv_isa_extension_available(isa_bitmap, RISCV_ISA_EXT_SMNPM)) + return 0; + } else { + if (__riscv_isa_extension_available(isa_bitmap, RISCV_ISA_EXT_SSNPM)) + return 0; + } + + return -EPROBE_DEFER; +} + static const unsigned int riscv_a_exts[] =3D { RISCV_ISA_EXT_ZAAMO, RISCV_ISA_EXT_ZALRSC, @@ -450,6 +471,15 @@ static const unsigned int riscv_c_exts[] =3D { RISCV_ISA_EXT_ZCD, }; =20 +/* + * Smnpm and Ssnpm provide pointer masking for the next lower privilege mo= de + * (U-mode), thus enabling Supm. Both extensions imply the same subset. + */ +static const unsigned int riscv_supm_exts[] =3D { + RISCV_ISA_EXT_XLINUXENVCFG, + RISCV_ISA_EXT_SUPM +}; + /* * The canonical order of ISA extension names in the ISA string is defined= in * chapter 27 of the unprivileged specification. @@ -577,12 +607,13 @@ const struct riscv_isa_ext_data riscv_isa_ext[] =3D { __RISCV_ISA_EXT_DATA_VALIDATE(zvkt, RISCV_ISA_EXT_ZVKT, riscv_ext_vector_= crypto_validate), __RISCV_ISA_EXT_DATA(smaia, RISCV_ISA_EXT_SMAIA), __RISCV_ISA_EXT_DATA(smmpm, RISCV_ISA_EXT_SMMPM), - __RISCV_ISA_EXT_SUPERSET(smnpm, RISCV_ISA_EXT_SMNPM, riscv_xlinuxenvcfg_e= xts), + __RISCV_ISA_EXT_SUPERSET(smnpm, RISCV_ISA_EXT_SMNPM, riscv_supm_exts), __RISCV_ISA_EXT_DATA(smstateen, RISCV_ISA_EXT_SMSTATEEN), __RISCV_ISA_EXT_DATA(ssaia, RISCV_ISA_EXT_SSAIA), __RISCV_ISA_EXT_DATA(sscofpmf, RISCV_ISA_EXT_SSCOFPMF), - __RISCV_ISA_EXT_SUPERSET(ssnpm, RISCV_ISA_EXT_SSNPM, riscv_xlinuxenvcfg_e= xts), + __RISCV_ISA_EXT_SUPERSET(ssnpm, RISCV_ISA_EXT_SSNPM, riscv_supm_exts), __RISCV_ISA_EXT_DATA(sstc, RISCV_ISA_EXT_SSTC), + __RISCV_ISA_EXT_DATA_VALIDATE(supm, RISCV_ISA_EXT_SUPM, riscv_ext_supm_va= lidate), __RISCV_ISA_EXT_DATA(svade, RISCV_ISA_EXT_SVADE), __RISCV_ISA_EXT_DATA_VALIDATE(svadu, RISCV_ISA_EXT_SVADU, riscv_ext_svadu= _validate), __RISCV_ISA_EXT_DATA(svinval, RISCV_ISA_EXT_SVINVAL), --=20 2.43.0