From patchwork Thu Sep 12 23:16:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Deepak Gupta X-Patchwork-Id: 13802832 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 519B9EEE270 for ; Thu, 12 Sep 2024 23:17:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D6A016B00A1; Thu, 12 Sep 2024 19:17:48 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CF1946B00A2; Thu, 12 Sep 2024 19:17:48 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B43B86B00A3; Thu, 12 Sep 2024 19:17:48 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 945CA6B00A1 for ; Thu, 12 Sep 2024 19:17:48 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 633BC1C5307 for ; Thu, 12 Sep 2024 23:17:48 +0000 (UTC) X-FDA: 82557650616.02.7B69B40 Received: from mail-pj1-f47.google.com (mail-pj1-f47.google.com [209.85.216.47]) by imf16.hostedemail.com (Postfix) with ESMTP id 8FF6B180004 for ; Thu, 12 Sep 2024 23:17:46 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=EMKyZrQ9; dmarc=none; spf=pass (imf16.hostedemail.com: domain of debug@rivosinc.com designates 209.85.216.47 as permitted sender) smtp.mailfrom=debug@rivosinc.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1726182988; a=rsa-sha256; cv=none; b=X3c3YuSRub1M8PNRk3FCYqhy6hqsbX0Zq83r0L3AaFcEldmi2HGzcxn05TulDsvZfp5Uga 0BPfLtcCMG08oZqQwmY2/k+expnlKbrMAeFeFEGorHE1Dt/HyxhPk3crMHcLborPLLvCtB dv6enzjGL9oZ5e6XG6CS6GQB2QI0TBM= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=EMKyZrQ9; dmarc=none; spf=pass (imf16.hostedemail.com: domain of debug@rivosinc.com designates 209.85.216.47 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=1726182988; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=L4VD0pn+7fxYAYMmu2vkxqQSkT8TrKqfbPDKikIcbYI=; b=7hN1elbWef+DXEEQMnvIyrBPaEuHsJDqmBf91WnUhXh/wU838NcykoFYGhHD+KrjnMXtdW pB9nSQhTPZusSzmuCIDCTwMKnLaJWqkgy1nmpVequSxjfqQOfxkcfUKID3+q1OAWOw1vLo 4YTuSWPhal3ypjPd1e0FM2hhDhx4X+o= Received: by mail-pj1-f47.google.com with SMTP id 98e67ed59e1d1-2d86f71353dso1108181a91.2 for ; Thu, 12 Sep 2024 16:17:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1726183065; x=1726787865; darn=kvack.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=L4VD0pn+7fxYAYMmu2vkxqQSkT8TrKqfbPDKikIcbYI=; b=EMKyZrQ9us1oNBnBEeJN2qOLAyphikeC39ynJBFd8k0U2R2YEnmP5EkH8STLHpN08f z1Nw664SSF0it+hU1ZaXBc6V4YXxWXmvZdmnn1orSjFdBpcBFFyjb53iQ5Vrk5P1DeXa TnqYXzm5MfCq2H5bOtq6IN44thmLfXuUlG7HOzFtS65Dud/OQ1nzPyP4i3xv6cGSJVoj +2zK+t8mVH+nQLOw2Ayp7jzpSfQejYEkpwqdaAWakccpKvx7bgTgZZv2UChQsMZpkCfz L+nGXPxPNtXzmL1kPgo+f4SNL4YuvVPTJpEMRKrfkZNDV7KacjGNe7QiyNYgq7l7TYn+ RSLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726183065; x=1726787865; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=L4VD0pn+7fxYAYMmu2vkxqQSkT8TrKqfbPDKikIcbYI=; b=Dkz09wC6oqGIbXiPr+GhhMHWWQ/qaX0MBxwT5zW3XS0fNvj4xfauvXfc4h0PIdV5Fv ee97jR1Ny7UAAniWPR8HebylV+RR2j3SwH0pnkaYB1D/tFD9fHCCpY2QZTJDqEjjbpvG 1+pD0SMPUYQ7kGQXwMshINtUyI27CeOf0LJinhzPj7B7BfiJvv9cD2dB/kYUqoiWT2AN 9fxXIhPTT8pufaTXtY580bCNTCY6iATMRHZB9E4jkqjVVsCP6R7Iy1pmTc+CkaOVMRdO Zvp6iBuuWpHPFNAY91LEu56VF2Fki0yP2PFVXBVOXq+aojIpHsfmfkOE+XRx5wfUaewY 8fxA== X-Forwarded-Encrypted: i=1; AJvYcCUtn7mMUypJyuWMPufdF+4k4gUvO0IKGRtk6kvnSh7P48uPx02jQqBjqWddC45fqkROYQJTxoNIHg==@kvack.org X-Gm-Message-State: AOJu0YyYiib1vPptB0wWs9bBY29oJfTKRrGop1vrYSCmaVJIZVZO5blk UN64KONv4VZUVce1sM9ig7hxqyRyfx8CuJ0TwwWastfV+tVPemESewB5odHEXNc= X-Google-Smtp-Source: AGHT+IHE2/uUipG3AbFYQLbtsQ6XTH0oLyDxTmTJL8HOpmNqW0hVQmxkI0Zi8FntOLvceExzi1MfEA== X-Received: by 2002:a17:90a:c10:b0:2d8:f7e2:eff with SMTP id 98e67ed59e1d1-2dba006821cmr4395000a91.36.1726183065339; Thu, 12 Sep 2024 16:17:45 -0700 (PDT) Received: from debug.ba.rivosinc.com ([64.71.180.162]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2db6c1ac69asm3157591a91.0.2024.09.12.16.17.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Sep 2024 16:17:45 -0700 (PDT) From: Deepak Gupta To: paul.walmsley@sifive.com, palmer@sifive.com, conor@kernel.org, linux-doc@vger.kernel.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-kselftest@vger.kernel.org Cc: corbet@lwn.net, palmer@dabbelt.com, aou@eecs.berkeley.edu, robh@kernel.org, krzk+dt@kernel.org, oleg@redhat.com, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org, hpa@zytor.com, peterz@infradead.org, akpm@linux-foundation.org, arnd@arndb.de, ebiederm@xmission.com, kees@kernel.org, Liam.Howlett@oracle.com, vbabka@suse.cz, lorenzo.stoakes@oracle.com, shuah@kernel.org, brauner@kernel.org, samuel.holland@sifive.com, debug@rivosinc.com, andy.chiu@sifive.com, jerry.shih@sifive.com, greentime.hu@sifive.com, charlie@rivosinc.com, evan@rivosinc.com, cleger@rivosinc.com, xiao.w.wang@intel.com, ajones@ventanamicro.com, anup@brainfault.org, mchitale@ventanamicro.com, atishp@rivosinc.com, sameo@rivosinc.com, bjorn@rivosinc.com, alexghiti@rivosinc.com, david@redhat.com, libang.li@antgroup.com, jszhang@kernel.org, leobras@redhat.com, guoren@kernel.org, samitolvanen@google.com, songshuaishuai@tinylab.org, costa.shul@redhat.com, bhe@redhat.com, zong.li@sifive.com, puranjay@kernel.org, namcaov@gmail.com, antonb@tenstorrent.com, sorear@fastmail.com, quic_bjorande@quicinc.com, ancientmodern4@gmail.com, ben.dooks@codethink.co.uk, quic_zhonhan@quicinc.com, cuiyunhui@bytedance.com, yang.lee@linux.alibaba.com, ke.zhao@shingroup.cn, sunilvl@ventanamicro.com, tanzhasanwork@gmail.com, schwab@suse.de, dawei.li@shingroup.cn, rppt@kernel.org, willy@infradead.org, usama.anjum@collabora.com, osalvador@suse.de, ryan.roberts@arm.com, andrii@kernel.org, alx@kernel.org, catalin.marinas@arm.com, broonie@kernel.org, revest@chromium.org, bgray@linux.ibm.com, deller@gmx.de, zev@bewilderbeest.net Subject: [PATCH v4 09/30] riscv: zicfiss / zicfilp extension csr and bit definitions Date: Thu, 12 Sep 2024 16:16:28 -0700 Message-ID: <20240912231650.3740732-10-debug@rivosinc.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240912231650.3740732-1-debug@rivosinc.com> References: <20240912231650.3740732-1-debug@rivosinc.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 8FF6B180004 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: tiiyrxssmg8uxmx4t9ctn6q4wiqdgdow X-HE-Tag: 1726183066-838063 X-HE-Meta: U2FsdGVkX1+4ToJGq0qlJ35bpeSc+/hLtJCO/6X5wnK4w1XWE9anVmlPGRXbVEzjqldH2lANOvWwrQtBpNyUysELOk4E5nI3FaQQM+zoLyyDLrGjQPp8c+XWnTRU1lM60Cjuf9FoCsHsn3wH3Ygtm6hJJTl0kOKklbeoSxWHimg8S12qIqZG2GidvOAB2X/3qCoxI76kj+nzaffDPYIML7Abs7yn0gKJ5sX2mXlRYnIYs7JkQKnyEPEHuhWtr60S+1B9yBbxZIWb3v2geUAMhMSohze7E98ohxjFCrEHQUhZKuqcPnE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VXAuse4XRz+dJxsssOEy+NI= 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: zicfiss and zicfilp extension gets enabled via b3 and b2 in *envcfg CSR. menvcfg controls enabling for S/HS mode. henvcfg control enabling for VS while senvcfg controls enabling for U/VU mode. zicfilp extension extends *status CSR to hold `expected landing pad` bit. A trap or interrupt can occur between an indirect jmp/call and target instr. `expected landing pad` bit from CPU is recorded into xstatus CSR so that when supervisor performs xret, `expected landing pad` state of CPU can be restored. zicfiss adds one new CSR - CSR_SSP: CSR_SSP contains current shadow stack pointer. Signed-off-by: Deepak Gupta Reviewed-by: Charlie Jenkins --- arch/riscv/include/asm/csr.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/arch/riscv/include/asm/csr.h b/arch/riscv/include/asm/csr.h index 25966995da04..af7ed9bedaee 100644 --- a/arch/riscv/include/asm/csr.h +++ b/arch/riscv/include/asm/csr.h @@ -18,6 +18,15 @@ #define SR_MPP _AC(0x00001800, UL) /* Previously Machine */ #define SR_SUM _AC(0x00040000, UL) /* Supervisor User Memory Access */ +/* zicfilp landing pad status bit */ +#define SR_SPELP _AC(0x00800000, UL) +#define SR_MPELP _AC(0x020000000000, UL) +#ifdef CONFIG_RISCV_M_MODE +#define SR_ELP SR_MPELP +#else +#define SR_ELP SR_SPELP +#endif + #define SR_FS _AC(0x00006000, UL) /* Floating-point Status */ #define SR_FS_OFF _AC(0x00000000, UL) #define SR_FS_INITIAL _AC(0x00002000, UL) @@ -197,6 +206,8 @@ #define ENVCFG_PBMTE (_AC(1, ULL) << 62) #define ENVCFG_CBZE (_AC(1, UL) << 7) #define ENVCFG_CBCFE (_AC(1, UL) << 6) +#define ENVCFG_LPE (_AC(1, UL) << 2) +#define ENVCFG_SSE (_AC(1, UL) << 3) #define ENVCFG_CBIE_SHIFT 4 #define ENVCFG_CBIE (_AC(0x3, UL) << ENVCFG_CBIE_SHIFT) #define ENVCFG_CBIE_ILL _AC(0x0, UL) @@ -215,6 +226,11 @@ #define SMSTATEEN0_HSENVCFG (_ULL(1) << SMSTATEEN0_HSENVCFG_SHIFT) #define SMSTATEEN0_SSTATEEN0_SHIFT 63 #define SMSTATEEN0_SSTATEEN0 (_ULL(1) << SMSTATEEN0_SSTATEEN0_SHIFT) +/* + * zicfiss user mode csr + * CSR_SSP holds current shadow stack pointer. + */ +#define CSR_SSP 0x011 /* symbolic CSR names: */ #define CSR_CYCLE 0xc00