From nobody Tue Dec 16 13:33:17 2025 Received: from mail-pg1-f175.google.com (mail-pg1-f175.google.com [209.85.215.175]) (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 9943134A3D8 for ; Fri, 5 Dec 2025 18:36:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764959822; cv=none; b=poCiCVga5USCEzmOFQBIcS7yDrXIiVzlqTWw6VbUlMnitzVe4kIlBQw1fgbCbe1og7dWlprpwAfXRng/FyQij6A7z8O2+716duLLqD6T0yoRQLJP3qDOxG0uaYbA1KVUL45DYleIXHID9sme/DWqIAz9hZMU90h4ReMyBWMj4C4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764959822; c=relaxed/simple; bh=n7bR1NnVFI/AqRJ5DRrpGqIuuKL5t/EAGbECncFah4k=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=DJi85268UPyBqiRiCfGBN6qNlQPcxqW7ZTePe11sUHbgLNVWLHmS+oyaZ04g17LmomgipPj8OaYFv0Zq1952JBCy0dDKYvxjz8BRf5r3pMcucmY8zBqJdf+Z1TFLZsq1mN5vOdZTYvGZ6Me+rZiAHcC/dVHv6KxJV1L2RO/yJZI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=rivosinc.com; spf=pass smtp.mailfrom=rivosinc.com; dkim=pass (2048-bit key) header.d=rivosinc.com header.i=@rivosinc.com header.b=OdGPP9gv; arc=none smtp.client-ip=209.85.215.175 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=rivosinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=rivosinc.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=rivosinc.com header.i=@rivosinc.com header.b="OdGPP9gv" Received: by mail-pg1-f175.google.com with SMTP id 41be03b00d2f7-bc8ceb76c04so1631136a12.1 for ; Fri, 05 Dec 2025 10:36:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc.com; s=google; t=1764959819; x=1765564619; 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=cETj36wQ9Li8D++iY1PBxUMbJIR6wBVZ7mUW8zqZ2ak=; b=OdGPP9gvMqICkHUNxjestrW16p8dgTnCgBtRmRY5Q1AZCcE0lvQgCKlmbRzkXJzCjt XE08kZYI+ycosead7s8QVubf289JEBL3DvCmcs+8T4i3AAgS0zRxdFQqeHQWMYIl65Tq c38Ac8mYiCcmhsYqnMn5z0EVJdgtKHenDqxXGMoAU+AyECVzDWYD/5N3JILx1MdSaHHy R11+C2yiaFh7tMYQd8KwaumQcsTjulOVHmYa30bIFQDZZ2gL8aqUWTAh/JBMLLnEyfia Ufv4ua2jME1UsuSmRUeXfehkWnAWEfQvFx82ccbO9GuSro+Uwd3958JS2z+ZKSFflM7N Dk6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764959819; x=1765564619; 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=cETj36wQ9Li8D++iY1PBxUMbJIR6wBVZ7mUW8zqZ2ak=; b=EXB4OmXWkJ/xOOkxEioLIRNo4yxiwWL9olkEL8zTa7jhNSXHJBAiBKqlCXHP7cFUtU BGzA4nrx8XGYCEe2AD//XN6ActrXy8HRDAOTBKCP2wWEl7Pvz3/P0/TW3BPi5jsjhqFZ +RUf930csbK+6bWBBUsmuM5V//ZcQe/R4gfTs8ZdWiqjj0CThL5z6IqcrxWsgaCOo9ga uAea03BomQXUPzNrRgxxB8P8LgzxeTKcUQn86PQWFdJs/v9ElJF8AZbsFmezH7dPJHBU A0gy5cWMRCV3wL2g1oMG5xhi6URahCMkWbUsKDOBLamr29qdCNZZRwQcV5kY6r5bb47v m9PA== X-Gm-Message-State: AOJu0YzxlsMg3prVhojCHiM4lOvQIxqk+OngnGEfz8f3KAvHmvV0WX7Y ncz3dFJ9FqyM3UGGkcvEyr4UnCDhZe+Xrde77IjePYIIFZFAx4eSJVScozGyznz/LRc= X-Gm-Gg: ASbGnculFaUIQPhOLdpCpPo/AuwbMDamMZE2a7eIqg/Nsv3P+UwK1p14uqXp2GJhsxa BEEjbSWqPWvt/730InhqzPbfSpqjNpscob5KlIeNTbrxOvgqF0wiFEJQUAwQIGmNiupkTEagr35 UcYNVFLYei2H+OhGNkfMX6yjECFQw4QlWWaOVDiRO1GSVlom2yvUC9SXOVtlShi08KPXSB8cwCa 3TJS7KQFDiuzHMJYPE4p+itrfKVYm2d8+WBiNEqQMe+bloR9EdoqmcADQeKWb3PsOnXMU+mVQs/ tbUkiYtd3MIFBI7vQB7HiPhGKHLVR7fHWlySC5esJZ7rdeKJCNj90FbaWeA8f4l08+cZGpWEbk8 S/ZmGdDgTzvykxNaC+yWzzEyQQxDB8KTlW89D0RhBpE2gfkDoWxYV0WsREhuDxfm4CKUZmLuq/y RuBHT9WD57GhCDTldIBVFb X-Google-Smtp-Source: AGHT+IEkzbnT/WgOlempvP3hpilfiz+Q71aHJSWUM26fnmV95b/U/OPvqEShn/bm1V+eS1bH7ZJBNQ== X-Received: by 2002:a05:7301:7389:b0:2a4:6488:7a91 with SMTP id 5a478bee46e88-2abc721e3aemr63588eec.37.1764959818484; Fri, 05 Dec 2025 10:36:58 -0800 (PST) Received: from debug.ba.rivosinc.com ([64.71.180.162]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-2aba8395d99sm23933342eec.1.2025.12.05.10.36.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Dec 2025 10:36:57 -0800 (PST) From: Deepak Gupta Date: Fri, 05 Dec 2025 10:36:50 -0800 Subject: [PATCH v25 04/28] riscv: zicfiss / zicfilp extension csr and bit definitions 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: <20251205-v5_user_cfi_series-v25-4-8a3570c3e145@rivosinc.com> References: <20251205-v5_user_cfi_series-v25-0-8a3570c3e145@rivosinc.com> In-Reply-To: <20251205-v5_user_cfi_series-v25-0-8a3570c3e145@rivosinc.com> To: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Andrew Morton , "Liam R. Howlett" , Vlastimil Babka , Lorenzo Stoakes , Paul Walmsley , Palmer Dabbelt , Albert Ou , Conor Dooley , Rob Herring , Krzysztof Kozlowski , Arnd Bergmann , Christian Brauner , Peter Zijlstra , Oleg Nesterov , Eric Biederman , Kees Cook , Jonathan Corbet , Shuah Khan , Jann Horn , Conor Dooley , Miguel Ojeda , Alex Gaynor , Boqun Feng , Gary Guo , =?utf-8?q?Bj=C3=B6rn_Roy_Baron?= , Andreas Hindborg , Alice Ryhl , Trevor Gross , Benno Lossin Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-riscv@lists.infradead.org, devicetree@vger.kernel.org, linux-arch@vger.kernel.org, linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org, alistair.francis@wdc.com, richard.henderson@linaro.org, jim.shu@sifive.com, andybnac@gmail.com, kito.cheng@sifive.com, charlie@rivosinc.com, atishp@rivosinc.com, evan@rivosinc.com, cleger@rivosinc.com, alexghiti@rivosinc.com, samitolvanen@google.com, broonie@kernel.org, rick.p.edgecombe@intel.com, rust-for-linux@vger.kernel.org, Andreas Korb , Valentin Haudiquet , Deepak Gupta X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1764959808; l=2422; i=debug@rivosinc.com; s=20251023; h=from:subject:message-id; bh=n7bR1NnVFI/AqRJ5DRrpGqIuuKL5t/EAGbECncFah4k=; b=31A6j7PC6Y5du6FtyG1Tip5TQTReoqkkZmO7mrZz/KN+VapztQ/ClG5jXhF8oJEHAJfpgvSh7 Wdgdq2HWZ/wBlxT7xVvM72WWT8CT9lmclkSWtwU4fMwFZ3NA1iNoLlQ X-Developer-Key: i=debug@rivosinc.com; a=ed25519; pk=O37GQv1thBhZToXyQKdecPDhtWVbEDRQ0RIndijvpjk= 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. Reviewed-by: Charlie Jenkins Tested-by: Andreas Korb Tested-by: Valentin Haudiquet Signed-off-by: Deepak Gupta --- 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 4a37a98398ad..78f573ab4c53 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 */ =20 +/* 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) @@ -212,6 +221,8 @@ #define ENVCFG_PMM_PMLEN_16 (_AC(0x3, ULL) << 32) #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) @@ -230,6 +241,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 =20 /* mseccfg bits */ #define MSECCFG_PMM ENVCFG_PMM --=20 2.45.0