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 AA8AFC47422 for ; Thu, 25 Jan 2024 18:26:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2D4158D0005; Thu, 25 Jan 2024 13:26:29 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 2831C8D0002; Thu, 25 Jan 2024 13:26:29 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0D62F8D0005; Thu, 25 Jan 2024 13:26:29 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id ED70D8D0002 for ; Thu, 25 Jan 2024 13:26:28 -0500 (EST) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id A51F7120CDE for ; Thu, 25 Jan 2024 18:26:28 +0000 (UTC) X-FDA: 81718663656.11.9378FC3 Received: from mail-pg1-f171.google.com (mail-pg1-f171.google.com [209.85.215.171]) by imf10.hostedemail.com (Postfix) with ESMTP id BDF1EC0008 for ; Thu, 25 Jan 2024 18:26:25 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=WlwwTN4V; dmarc=none; spf=pass (imf10.hostedemail.com: domain of debug@rivosinc.com designates 209.85.215.171 as permitted sender) smtp.mailfrom=debug@rivosinc.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1706207185; 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=xyuZ0gVdBuvlPmtjlhSz8uJtD77t/nVDJ3cBvemqEj0=; b=Z19N67IMyKPqbkYfqMoY5i2OGk/owCk6zenPXG4ruJASuVr6QVlXzMivpLx/5P4xiA6Iba 0Sm9vH4UiAT1jON5mEh/MhYYJ9zPlEBGl/I2IdE7Ydh+ciF+F5NvbL94wy3pUVFxwio1L8 sMxmvUtCuq2a1APbl6lUuS6nW1hwaWg= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=WlwwTN4V; dmarc=none; spf=pass (imf10.hostedemail.com: domain of debug@rivosinc.com designates 209.85.215.171 as permitted sender) smtp.mailfrom=debug@rivosinc.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1706207185; a=rsa-sha256; cv=none; b=fExKJWA1Pl36hUlonV1KFaWVCCFnctFrDgO8BECJ6yzWJDpMMfQfUzc1h8Kd0qeeZfvwau 0aq3H1PjgD+syNKdIX8eXPRCP4I6ry6NoZk8S9X/QiGQuTj+4pLuJwWTzOMmHpkxpFwbU3 HQAHHCoUrw0Ee8Es5uwAW/68TLEpTTI= Received: by mail-pg1-f171.google.com with SMTP id 41be03b00d2f7-5cf450eba00so5726144a12.0 for ; Thu, 25 Jan 2024 10:26:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1706207184; x=1706811984; darn=kvack.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=xyuZ0gVdBuvlPmtjlhSz8uJtD77t/nVDJ3cBvemqEj0=; b=WlwwTN4VYMUOT3TTXi7RjbpQJeTrU8gDzI7s7pmrtTVBXfqjlvjo/KVteaQShuBA7b 8/ZbRBc34zODczBICfmkdoCuOF+yb1mIM94FOjpJUe3pxp/S5cZuhm99WLsx8Dni7oy/ 9tduKpXk9dvpmbPt3SmjfAbgxjVUvwF50d7X4LtT8NVi5LYul/Lal+3nH1d14EPHR1yj cuXsiAzvczSNNs/x4Nspl9hf8dwsgs6fi/GdFj52NT6Gcicodc+Yiu4d9zlt1ngczdK7 eEA4qhtdx1750EEAh/rJc+4yRwuwXCvClUzX0h1lKa4zcXmDUrolsHh0H7r4JuWGgzX6 QKkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706207184; x=1706811984; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=xyuZ0gVdBuvlPmtjlhSz8uJtD77t/nVDJ3cBvemqEj0=; b=AuELFEyXeEjfz1jM8oYMcQbz/ozFh5HvOSQFhu0IgUtn6zZD/SPRXEkvc+lgbGRjj6 ng8jcNhtvev7p4Ue5yOs5GV43gLx2dqIUO2l1sj3vx0WSNq9i8ocVvEbtZxHStznNCmA x+Sm/ZULg61MgVboKlE0CikrqIrdIBegZzOB2PAk4DNInKpJ/CsijFN781Aa8wJ4BjtB j1w1j7bkyN52DMzwsF/ekqkn5q4ECHRkLFFLiXFGUewKmWRyGd8eCYakWotSBSVnbSKc OhnjdcaT6jyxj8NxYqNFGmg/X7KK2U9592OxgikZ7WPE1P0nHFFWb0UZ6HEmQcRBIycN U9SA== X-Gm-Message-State: AOJu0YyoJVKEeAyPYNljHZABt8n+zL/o782D1Zyn7J/DjIGVmY4rcJUb uQOujJUdf+JOuLO1m+3JcFFNjDJJeiaAy39V04wyg7RtVsnFbKuhnPMzFj+YP5o= X-Google-Smtp-Source: AGHT+IFBV2oC78chsLzac9k77DXS5/WbnhoEAPatEDRZ6lhNeqqRGgEsUCPUu1zeHuG1e8R3Jwt8hg== X-Received: by 2002:a05:6a20:1453:b0:199:ad49:ea79 with SMTP id a19-20020a056a20145300b00199ad49ea79mr78878pzi.63.1706207184482; Thu, 25 Jan 2024 10:26:24 -0800 (PST) Received: from debug.ba.rivosinc.com ([64.71.180.162]) by smtp.gmail.com with ESMTPSA id j38-20020a635526000000b005cf7c4bb938sm13685563pgb.94.2024.01.25.10.26.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Jan 2024 10:26:24 -0800 (PST) Date: Thu, 25 Jan 2024 10:26:19 -0800 From: Deepak Gupta To: Conor Dooley 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, 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: References: <20240125062739.1339782-1-debug@rivosinc.com> <20240125062739.1339782-6-debug@rivosinc.com> <20240125-unscathed-coeditor-31f04e811489@spud> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <20240125-unscathed-coeditor-31f04e811489@spud> X-Rspamd-Queue-Id: BDF1EC0008 X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: m56odzip3oae58pwsptbgr6h7yu7p4ft X-HE-Tag: 1706207185-223363 X-HE-Meta: U2FsdGVkX19Akuehx4ZiErIy9mTJR0tfec3lnX7hv8eyylntUrztDSL3zz0SUGa9nvozvosHqBu9ktQtL1jyeLna2Gw7kntSGpsJi8mHOwhJWaD413LeVvjZPt2EMkWwgUwp/uCSYTIfGR/k+UHb8yOrKxqt2WLmhpP0x2TOYxEFVLqnkTOAyiXjY+wYRQ53vR9rir+HcU96ldW8cnD1KCwuxk30ShlpC0vjkqmlwnQFO6XHKD+p9OaI4seYAgVd2+ijtZ9vK+EDhdpjPlhjQA6dFdwq6ZF7GGhxTPU30g3olMm/3ikhHfUmKqtWv9yCpF7+3ggI9XC64wTZRtT/bvIZ4a3f1QCNjrJMxtFKjWFQLMg4gO9/ryf7A0WWQpRPE4T7OiELf1AZSV31syenVIQ/Lx6eLvonkSULoKg1NBimR67MHvx7gjp4F0waL4iOwXDrJA7Gl0W1uPWFRSzObCs2ZRIh8Fjp/ftiQQ063SR79I2fQvMw+nGi8CYG+iRhZM9M334SrwzH3vUPW4eao9ju1qYnYdBmBMj1G6+nR+ALbiOh684hyZL8au1VGXFbC56aomQKWR+RiiAXLyLA/TtVYIhNh4EsqpejaToaLAxyQzb/QNeo/8mo14xymlEbgfpsX0jsyzUsKumfsuvEojVJ3IzPdjdrSVt7RBsWgnOstd47HetWwaNLTReWHZbvzcIbRhjDaOxNgYy3kJlFtZ5r1h3xP6/mf7wA/RY8oQVWc3i+zeQ4vQtKRcYzK6t5L9AbCtOLhIlfWXAYz6RMgIvC59IWU8x3k2qlqfNCuJscBAO4qbRJMNcmCXLKZxK8rCLVrxXWvVi6+6c6SWc5pL+8kJJ84BJbfbMQrTAnqYsbMUHhZGAKAEaBD9riqGiX/CsIlXtybGoxj2eRIua93ab+X2XjdgeQiNN/Ept4bEHPPivlpIwvwRn5tTZFr8/uTFiC4CRW+ZJIFVYO1ki apbOf5jc yW4vdMMtdoTkVzq8Qwb28scQnkKSB6VrAlrZHuq4rwhuBmHbqZ7fiPyxSPa5ilU1sKQxWOKRFLUPBkAi3TXTFdL8sv5OJdgM7ZarpI+wby5GOC8Akv3QiCFSuDMgiKXP52E+ger4agxH22370CjFiC4J1mymWjxGy2KhWYwzdjtGyg3MG6BZnkpAYMrnk1F+C7ArrQXCc+6qjP+g90T2YkA0HkVsllvdpMI3Ytjlb8ksKu+sML0Ln1vcMvRUsCg7R8BRqQ/2y3v30g4fduuD9yxsrtTf8Up3Vl3aouEZwAzQF7yqVKU/MZKGVownPKt48CDrq4lDIJgidUvqK3kLH0ZgO6CjDQ8KqGnEe15H2proGHtAXcsdwYvViYLotMub1FzH6feGre8gnMx8DO/KjwOfUpSQ9Du4ymjY3XEb34DnvtSleZEJWqlSscdukX7iD1CS8rEFZeWu/VpUq7JdGP7VgSKno3Mm2WpwzgK4P3Quent77ndn2hIyQbXBCjeOsZvrAogTw2oRlAIM= 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: On Thu, Jan 25, 2024 at 05:59:24PM +0000, Conor Dooley wrote: >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 >> >> This patch adds support for detecting zicfiss and zicfilp. zicfiss and zicfilp >> stands for unprivleged integer spec extension for shadow stack and branch >> tracking on indirect branches, respectively. >> >> This patch looks for zicfiss and zicfilp in device tree and accordinlgy lights >> up bit in cpu feature bitmap. Furthermore this patch adds detection utility >> functions to return whether shadow stack or landing pads are supported by >> cpu. >> >> 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(+) >> >> 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); >> } >> >> +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. No reason. I should probably do that. More readable. Thanks. > >> + 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/hwcap.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 >> >> #define RISCV_ISA_EXT_MAX 64 >> >> 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 >> >> #include >> +#include >> >> #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/cpufeature.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[] = { >> __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. You mean Documentation/devicetree/bindings/riscv/extensions.yaml (or possibly any other yaml if needed?) >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. I see the comment. In my defense, looks like I missed it when I was rebasing. Will fix it. > >Thanks, >Conor. > > >> }; >> >> const size_t riscv_isa_ext_count = ARRAY_SIZE(riscv_isa_ext); >> -- >> 2.43.0 >> >> >> _______________________________________________ >> linux-riscv mailing list >> linux-riscv@lists.infradead.org >> http://lists.infradead.org/mailman/listinfo/linux-riscv