From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9EF74C47258 for ; Thu, 25 Jan 2024 17:59:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1CC906B0075; Thu, 25 Jan 2024 12:59:44 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 17D196B0083; Thu, 25 Jan 2024 12:59:44 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0456E6B0089; Thu, 25 Jan 2024 12:59:44 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id E89B06B0075 for ; Thu, 25 Jan 2024 12:59:43 -0500 (EST) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 7F7551C18C8 for ; Thu, 25 Jan 2024 17:59:43 +0000 (UTC) X-FDA: 81718596246.03.114A4B2 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf15.hostedemail.com (Postfix) with ESMTP id BE1A8A0024 for ; Thu, 25 Jan 2024 17:59:40 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=OyAlRKVu; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf15.hostedemail.com: domain of conor@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=conor@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1706205580; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=ouCJFxiZ4Y+S0Pab1QUVyylQFr87LA1DpGKaJdWeMWs=; b=cEUdMhKlH0xWATip8reJpGgD55pZB9sQu8+sePJGQY7z4kLmXMuld1IpkBpO5Q0Thal3Se VvMvLz51HE2Z0KLUebMu00YsOpbHKpfgv5QuOdx0Q1t4VZz2CDdEhZereb5045mGsM/pte pa/fbxHGSogGYcQVPmZfW9ufRPwc4Zg= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=OyAlRKVu; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf15.hostedemail.com: domain of conor@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=conor@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1706205580; a=rsa-sha256; cv=none; b=fUWxwGCAyCNGVD/1IR8/MaSsNIDaH3t/9lkkbsP9wKsTDABxYR8DwhIN67jAFvsvQ3yRBQ kiIPcHEb0OoWOcpgV+cmYsrcukwCF24Ag0ZyDaYvN2EZ2RdlzB5TITUpM6WaNKZ+GHEeKT bLe3A4IucnUoUTdelkfKq6zTdAtCLHo= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 73B4C622A8; Thu, 25 Jan 2024 17:59:39 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CD0DDC433F1; Thu, 25 Jan 2024 17:59:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706205579; bh=rC+Q88vkvvSk69dujsUhGZueJ/t7Kyjxb3QFEdgOIJA=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=OyAlRKVuBCdCsxLTOqTqSdCeK/5SYgNvOoA3HyrTyOGXHWKWVH7aBanPrtSRIxVIk Y149mNGvNZ1J1PSJ6yBB85ggKz+qBB0Pd/asIXEEsZrVpj6EpjtcmRV/Q05YrW+wZh J2seaDdIXlIf5/w46PnlThKYxvad+h8w+C/L7Hs7EK0NAZRU0oTdqcq9ZaqpLilvSo 5RfrqumEvErBVFDhuC4P0/uwxjx7AGB4lbwzbrNOBB14T7jFBrBZ88i07XPRzAns36 cBi8U/5Hzcb0zby68VrjcnwkH3i3E1IFK/I6wH54MogiPMaidzrHF/IyP5HdNqMmFp aTxYOHfemvtmQ== Date: Thu, 25 Jan 2024 17:59:24 +0000 From: Conor Dooley To: debug@rivosinc.com Cc: rick.p.edgecombe@intel.com, broonie@kernel.org, Szabolcs.Nagy@arm.com, kito.cheng@sifive.com, keescook@chromium.org, ajones@ventanamicro.com, paul.walmsley@sifive.com, palmer@dabbelt.com, conor.dooley@microchip.com, cleger@rivosinc.com, atishp@atishpatra.org, alex@ghiti.fr, bjorn@rivosinc.com, alexghiti@rivosinc.com, corbet@lwn.net, aou@eecs.berkeley.edu, oleg@redhat.com, akpm@linux-foundation.org, arnd@arndb.de, ebiederm@xmission.com, shuah@kernel.org, brauner@kernel.org, guoren@kernel.org, samitolvanen@google.com, evan@rivosinc.com, xiao.w.wang@intel.com, apatel@ventanamicro.com, mchitale@ventanamicro.com, waylingii@gmail.com, greentime.hu@sifive.com, heiko@sntech.de, jszhang@kernel.org, shikemeng@huaweicloud.com, david@redhat.com, charlie@rivosinc.com, panqinglin2020@iscas.ac.cn, willy@infradead.org, vincent.chen@sifive.com, andy.chiu@sifive.com, gerg@kernel.org, jeeheng.sia@starfivetech.com, mason.huo@starfivetech.com, ancientmodern4@gmail.com, mathis.salmen@matsal.de, cuiyunhui@bytedance.com, bhe@redhat.com, chenjiahao16@huawei.com, ruscur@russell.cc, bgray@linux.ibm.com, alx@kernel.org, baruch@tkos.co.il, zhangqing@loongson.cn, catalin.marinas@arm.com, revest@chromium.org, josh@joshtriplett.org, joey.gouly@arm.com, shr@devkernel.io, omosnace@redhat.com, ojeda@kernel.org, jhubbard@nvidia.com, linux-doc@vger.kernel.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-kselftest@vger.kernel.org Subject: Re: [RFC PATCH v1 05/28] riscv: zicfiss/zicfilp enumeration Message-ID: <20240125-unscathed-coeditor-31f04e811489@spud> References: <20240125062739.1339782-1-debug@rivosinc.com> <20240125062739.1339782-6-debug@rivosinc.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="OJe+q/A6ibDUlSdl" Content-Disposition: inline In-Reply-To: <20240125062739.1339782-6-debug@rivosinc.com> X-Rspamd-Queue-Id: BE1A8A0024 X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: k5dwp83ug95n1hz7bc93nmu6eggkb7cj X-HE-Tag: 1706205580-917827 X-HE-Meta: U2FsdGVkX18q4jkJjDZSRstiognJOjecLNiSfndc61I4q/qh6/JIf9OTUG51392+4s2zQ8lCTPtgoeWm2E/gih9vcOxehne+giId7t61fF1CYt+mvoWkfuOzX3YBzE6n9GCvFQedrcc9OpSGqbxT8oiq58GgAndSfF3JvsYVtGcz6JylPW04KPlMLtJGnqVzPmHfjStBPPhHvtq4dXt+CUD8SRjlrw1G6+AwvAADvytZbwqYDIkqYSbJ+hPt6ab36gdujG3/Odryar3CV7D6YQRWnzzJ9QLzQZZWhOXUiOCBbonSni62FUoPZuROsPP8YMaeDRKJzp2X+msxx7x4fy91uaHcxV3zY9SaNLx3ohtSvrHmHho20GxesC9i2mOT1ghes8wG7m7GlrpzvmjW45lErmbS4Ka30CDF2foSocCT/nj7vkOuOFt4AZ0viD2hITDN6Gvo4AEPhmy9zoyzvz+2kbV2WpTEP/JxP8oe3y94oPf/R6N1nxkq57ySd41e6AXYMp59QF4fAIGFLyri21uldjMBYyW89EEPXJ9s/N0WBf4QWpgjPtKrU09fVzUpUIqEwOK6ofKrFC25H33ogc01ozjWytC7DAlryh5ghWk/JtE7QTod57vYBfJx5HUJbd3EpGURQjuHnWi/zBrFtgtDrDlYUOsElWvhYZsig6HMFZvujuDwviiSG2kGEWg8ldxHlsrPr1w32HeUWELsP7rz8i1f3c6nk2nEI1JzFCxHKFdGqD8FzqjxafG2XH9OcDY6xRSWjvIn12zvm0Ah5mc3pX7QCqCeaPuVgV6GwJYsNDr5XhUyVqCwt6DgQW1N7YYPBaqLzTsJ7wZ05PJwU8n8A58RlfWO9avojLgcv0Q3SwHq0nkq8eQ6vsukc/VbgtzyuNgBaEZFKOvCrCfoOd0W0WL/1PunF6srRxzqIpCVsATMoYJwgWUKXZbvkHemjzyJqSW1eOBl/Okmwfs sltGu/iU yu49v1xIce3DUpUujdvKofBgVhJey528YDXtYtDOZaLnB4UtEj9XjXKo+QWeQR8UIiGCb91zhb39gfUFkHfeHy58Mweq2JydHTbD/GDhhII769nOTK0JvOnt+71ky7c4Ev2pshbaZEPmj5YkGlvOwWVpITmLPjL+dX7m8mGXmpA6AimbYeD4fVm1uelmbR6QhoWDa4lSkOhrr7TS2VpVareXfk1/pg8TsFmG46cWgXgXQ12D2Wg3tzJ9sz2QAqyI75G3jvUVS9Y+4vzv5PcHAyNMnbkOp1ZddlGyzABUNZvflvCphahdfQUhdgLKtmYUcbqF3fZg8bno0c/qwvpPZq43bzIpMxyqkzykOcik5wxbSzs8Tnnse5nHyfMBSjWjQKSYTxneXMGCe6oYJKX4DTq6Vvg== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: --OJe+q/A6ibDUlSdl Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Yo, Series is RFC, so not gonna review it in depth, just wanted to comment on this particular patch. On Wed, Jan 24, 2024 at 10:21:30PM -0800, debug@rivosinc.com wrote: > From: Deepak Gupta >=20 > This patch adds support for detecting zicfiss and zicfilp. zicfiss and zi= cfilp > stands for unprivleged integer spec extension for shadow stack and branch > tracking on indirect branches, respectively. >=20 > This patch looks for zicfiss and zicfilp in device tree and accordinlgy l= ights > up bit in cpu feature bitmap. Furthermore this patch adds detection utili= ty > functions to return whether shadow stack or landing pads are supported by > cpu. >=20 > Signed-off-by: Deepak Gupta > --- > arch/riscv/include/asm/cpufeature.h | 18 ++++++++++++++++++ > arch/riscv/include/asm/hwcap.h | 2 ++ > arch/riscv/include/asm/processor.h | 1 + > arch/riscv/kernel/cpufeature.c | 2 ++ > 4 files changed, 23 insertions(+) >=20 > diff --git a/arch/riscv/include/asm/cpufeature.h b/arch/riscv/include/asm= /cpufeature.h > index a418c3112cd6..216190731c55 100644 > --- a/arch/riscv/include/asm/cpufeature.h > +++ b/arch/riscv/include/asm/cpufeature.h > @@ -133,4 +133,22 @@ static __always_inline bool riscv_cpu_has_extension_= unlikely(int cpu, const unsi > return __riscv_isa_extension_available(hart_isa[cpu].isa, ext); > } > =20 > +static inline bool cpu_supports_shadow_stack(void) > +{ > +#ifdef CONFIG_RISCV_USER_CFI In passing, I don't see any reason for not using IS_ENABLED() here. > + return riscv_isa_extension_available(NULL, ZICFISS); > +#else > + return false; > +#endif > +} > + > +static inline bool cpu_supports_indirect_br_lp_instr(void) > +{ > +#ifdef CONFIG_RISCV_USER_CFI > + return riscv_isa_extension_available(NULL, ZICFILP); > +#else > + return false; > +#endif > +} > + > #endif > diff --git a/arch/riscv/include/asm/hwcap.h b/arch/riscv/include/asm/hwca= p.h > index 06d30526ef3b..918165cfb4fa 100644 > --- a/arch/riscv/include/asm/hwcap.h > +++ b/arch/riscv/include/asm/hwcap.h > @@ -57,6 +57,8 @@ > #define RISCV_ISA_EXT_ZIHPM 42 > #define RISCV_ISA_EXT_SMSTATEEN 43 > #define RISCV_ISA_EXT_ZICOND 44 > +#define RISCV_ISA_EXT_ZICFISS 45 > +#define RISCV_ISA_EXT_ZICFILP 46 > =20 > #define RISCV_ISA_EXT_MAX 64 > =20 > diff --git a/arch/riscv/include/asm/processor.h b/arch/riscv/include/asm/= processor.h > index f19f861cda54..ee2f51787ff8 100644 > --- a/arch/riscv/include/asm/processor.h > +++ b/arch/riscv/include/asm/processor.h > @@ -13,6 +13,7 @@ > #include > =20 > #include > +#include > =20 > #ifdef CONFIG_64BIT > #define DEFAULT_MAP_WINDOW (UL(1) << (MMAP_VA_BITS - 1)) > diff --git a/arch/riscv/kernel/cpufeature.c b/arch/riscv/kernel/cpufeatur= e.c > index 98623393fd1f..16624bc9a46b 100644 > --- a/arch/riscv/kernel/cpufeature.c > +++ b/arch/riscv/kernel/cpufeature.c > @@ -185,6 +185,8 @@ const struct riscv_isa_ext_data riscv_isa_ext[] =3D { > __RISCV_ISA_EXT_DATA(svinval, RISCV_ISA_EXT_SVINVAL), > __RISCV_ISA_EXT_DATA(svnapot, RISCV_ISA_EXT_SVNAPOT), > __RISCV_ISA_EXT_DATA(svpbmt, RISCV_ISA_EXT_SVPBMT), > + __RISCV_ISA_EXT_DATA(zicfiss, RISCV_ISA_EXT_ZICFISS), > + __RISCV_ISA_EXT_DATA(zicfilp, RISCV_ISA_EXT_ZICFILP), Anything you add to this array, you need to document in a dt-binding. Also, you added these in the wrong place. There's a massive comment before the array describing the order entries must be in, please take a look. Thanks, Conor. > }; > =20 > const size_t riscv_isa_ext_count =3D ARRAY_SIZE(riscv_isa_ext); > --=20 > 2.43.0 >=20 >=20 > _______________________________________________ > linux-riscv mailing list > linux-riscv@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-riscv --OJe+q/A6ibDUlSdl Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iHUEABYIAB0WIQRh246EGq/8RLhDjO14tDGHoIJi0gUCZbKhfAAKCRB4tDGHoIJi 0m8PAP9eIW7UlxuUyWUsg6MGHXlv8ZtcBNP6yzYdPsHu14VjBgEA1jfEe577oIh+ woT0/0AyxBO9r6aPBEj0oGlTA2l5WAI= =Oe9E -----END PGP SIGNATURE----- --OJe+q/A6ibDUlSdl--