From nobody Mon Feb 9 17:34:48 2026 Received: from mail-pj1-f68.google.com (mail-pj1-f68.google.com [209.85.216.68]) (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 734EA339B43 for ; Fri, 16 Jan 2026 02:11:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.68 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768529465; cv=none; b=BOWhN5xFQ9I9gNUAJuQLJa7CAlcWRDNyYRmpFa++GnuMjfEtZNhr4Dr5kPsTAp0+h1MVsS2r8CTUOVFNntAwwsvpokuuGRPfPpEwvZeGN/7BwZDllEVwEu0IjIs/lgMzo7FzvIWsOxRbATwXqBr8HGJdILfXQUT29kVLl126W+c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768529465; c=relaxed/simple; bh=ong0g8BWW13j2+imyHoB4E24TMNHE1kNgiYLhqR3Y00=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=GvddscrNBaW1Es/lKw4plU0X9Jpp6M3t1wl5gRwvTZFBiiOq7YkQPA/C6P8pP7/57ZkxX5pSurZSB5FJZhBUA3bIq3hnjDu/ohhgu1R9BVKeCH094oXkkFk6FZl5Sja64+kO6QGIzLwr1Td22HBsP2Gba6QiCLHgItDFtw8BK5I= 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=T2tNuTft; arc=none smtp.client-ip=209.85.216.68 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="T2tNuTft" Received: by mail-pj1-f68.google.com with SMTP id 98e67ed59e1d1-34c2f52585fso804588a91.1 for ; Thu, 15 Jan 2026 18:11:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=riscstar-com.20230601.gappssmtp.com; s=20230601; t=1768529463; x=1769134263; 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=BXny++fuaUYh/9d0tAiw1EejR1b07lFNBxlkkPwo9D4=; b=T2tNuTftipbCkg3h+/OPUAHRxCb8UvzeS6VI5kffLByItNAnlMr2xKsPqP4ItHavp7 i6ld5jv9V8c2gKqcV5f3vRWm1gMZxTUHAAiw+Wp60FoO4tPSj3ICsQ1wV2RobkTt2f3j I1xU48xhmVAZphhqUkT1oheBVK2mPfjseqadloey2dwQgeAnglvrzXkl6rJOBPHy25VK VA4PGp9ml6i/AbTaOkRggTcYhlm03bnmrnzzuTP+BPt3WvHM0dFw90viBGzeZX9ZuzN6 NxXByEFrcubWFBjg0z2MObCLUv+xBNb8BD3DUihRA9PZyM84xrIyLECZqPY90MJOMEWE nxbg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1768529463; x=1769134263; 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=BXny++fuaUYh/9d0tAiw1EejR1b07lFNBxlkkPwo9D4=; b=o45j9stZ4lUCZFmebVvTEyT4NH6SNDaONzHRdPhMe+H+MOVOwKuBW3V8scFfmpbExN +Zwm8S+ANlJUqtQDq5o/WWL4Dx/SnlJ+2mS8Wbf8WstPlw8rkx1ebyzbyjAgu88iLwaH 7Eydq8LKUfkfIN7YC22PQoqvUIko2RgZ1VTAigLJ/vEv/GXh2UWvYYraAV8OkyerjQk+ VT2SNzV9a+sWNDynzJMKkIQuqVAbOQB7lDujcBS8xivpa8vtI1TolFYBkPwCyvdnSSh7 PqOIDn6/ito58cFbSj4LPCvtqULprpyYTIfloSO/c4exWWA56n/NlrDj4FExddHa0KPI Y9cg== X-Forwarded-Encrypted: i=1; AJvYcCVFnEaR0sYzw+ROsLZ8/mtwJLSYfO3i/1EGYR2phPTpoLqn7rNqrL4Arbp3yWsEESVypyKfxH31iM9sHvw=@vger.kernel.org X-Gm-Message-State: AOJu0Yx+nRr0fdkn3RgQwSWaoZFkoI96xQ6YNynfTE5SoEgQygg4lA05 pTCn1NDlOiBzzn7kLmCkbKhBpdfo7blw8Zm0ftApidtD5M4yQBz4me9DKxFx4rWqrjI= X-Gm-Gg: AY/fxX7gepjoLrgVWmWWe43taDT8E2QdbHnHShnA1mUVNsAG6ddfZoN7i6OmKBs1mJl xaPG4n4S6h93/cSoQJprVo0Kr3ad7dlLCp0lHeXiB4SUAL7CAVB+xMAmMmBe0nCA2a4S9KMOP9P xnu1go7L9KvGdzN34kgD9DDHHNQAi/XtBEQmAqGAZv05BVdBCqmDLA2Hc0nKLrk+Nb2Ojz5MTu2 ubYKihMn+P4lC9MizG7orvFkTjAxUAMyIqhwxsU10hWLCq7K2jzoALvHrIBNecKCAUZhidu+f4b rI/ET4N3gB6atl9A1KMD7I5Mnd749QFNpZDsMn2e580jeGGOQoe2G1CVAzzakPxyMcE6fMroaBE uhsnX1PkQo9R8HfN+iWxUGzsrUmEDgFDFHrKPLE5v/nObx2dmSsHa6icggZc8YNNLM/+FobF5Kp 0ZSK2qePaE0VI/0Bd/tu6pNrDD9p4FV0kaLyMUqVBphwfos1XHAqDHTA== X-Received: by 2002:a17:90b:1e0b:b0:34c:f5b5:c1b6 with SMTP id 98e67ed59e1d1-35272f028a0mr1410360a91.12.1768529462750; Thu, 15 Jan 2026 18:11:02 -0800 (PST) Received: from [127.0.1.1] ([45.8.220.151]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-35273298968sm364317a91.0.2026.01.15.18.10.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Jan 2026 18:11:02 -0800 (PST) From: Guodong Xu Date: Fri, 16 Jan 2026 10:10:32 +0800 Subject: [PATCH 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: <20260116-supm-ext-id-v1-2-5fcf778ba4a6@riscstar.com> References: <20260116-supm-ext-id-v1-0-5fcf778ba4a6@riscstar.com> In-Reply-To: <20260116-supm-ext-id-v1-0-5fcf778ba4a6@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 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. 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 Reviewed-by: Conor Dooley --- 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 4369a2338541..7653e5cff9ae 100644 --- a/arch/riscv/include/asm/hwcap.h +++ b/arch/riscv/include/asm/hwcap.h @@ -110,6 +110,7 @@ #define RISCV_ISA_EXT_ZALASR 101 #define RISCV_ISA_EXT_ZILSD 102 #define RISCV_ISA_EXT_ZCLSD 103 +#define RISCV_ISA_EXT_SUPM 104 =20 #define RISCV_ISA_EXT_XLINUXENVCFG 127 =20 @@ -118,10 +119,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 fa591aff9d33..39680280f858 100644 --- a/arch/riscv/kernel/cpufeature.c +++ b/arch/riscv/kernel/cpufeature.c @@ -296,6 +296,27 @@ static int riscv_ext_svadu_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, @@ -429,6 +450,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. @@ -552,12 +582,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