From patchwork Fri Aug 23 18:47:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Deepak Gupta X-Patchwork-Id: 1976210 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=oSjhrJJQ; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=rivosinc-com.20230601.gappssmtp.com header.i=@rivosinc-com.20230601.gappssmtp.com header.a=rsa-sha256 header.s=20230601 header.b=SwpYEEeV; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=patchwork.ozlabs.org) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Wr8GG6Cbjz1yNm for ; Sat, 24 Aug 2024 04:48:04 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=CJyPG712ab5YUqxZ7+dD3fNTzYP3fcV66Oo4HebZqcA=; b=oSjhrJJQX7Ha6T JZbB4sBtNRemPhUJJmyEZsr1dHH6rbv0f/b25r1TwLajfloUYvBBLrki8TV3/LCDIA2NN984Ch3Cw 23G/8bj/NYR4S97e4+BD6phTm8meTksxjzYNZbl6cDKaM8ax/bfm1erYjuUd4/Ua6wavHamjbIO8E mWBNDOqa8hNmkYUk1kGlSNA0TgJqzH54M8QHJRzPSYs535mWToM7efMKhV3Mo7WNBmMTDGL8oHEKP lPHEEPS+7rZLG0AzxYjGOa2ti7vP99llKZkvBNkBRiNugt1Y4xRf948/CE2OGWp5wUueESEiOHD+d CK7Ub1oWXIVQgWQbY3+Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1shZKF-00000000KhC-0XTg; Fri, 23 Aug 2024 18:47:55 +0000 Received: from mail-pl1-x630.google.com ([2607:f8b0:4864:20::630]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1shZK1-00000000Kf1-3xsg for opensbi@lists.infradead.org; Fri, 23 Aug 2024 18:47:52 +0000 Received: by mail-pl1-x630.google.com with SMTP id d9443c01a7336-20202df1c2fso22545385ad.1 for ; Fri, 23 Aug 2024 11:47:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1724438860; x=1725043660; darn=lists.infradead.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=ep+etXyj4ZEjmB65w14NCAa5202msQUfrG/DIIPz76s=; b=SwpYEEeVOfIN2mPWcbhsDf8QtMGxWOk0S8/ebHBkhxL90+u0KxJ8NzKGZGoFgTGB42 B+8zzZdvKFeMFayGykKe2OxbzLnes7dnp/pVYx+PyVGwPhlBLr5z5skmxkHlQUb0Cy/D 7pWwSmzg39mIsWvrbreVLR7qy1bMoWD1TRgZ99kJaAYDJuKBZeSN+Vk2rtDysIoU/BvP 5ox/VT36vjGWEOsgr7f8A7VKYz7chlA54+m/B89CMWHOkdZmrhgKsaUo+M1XT+bcpaS+ 1wZWL20qwYqHtnOUYO1KbBOFqRLTTyeY0RKkNNMize7Js0rNqslCidfIpdyESUfw1Au+ 5tQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724438860; x=1725043660; 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=ep+etXyj4ZEjmB65w14NCAa5202msQUfrG/DIIPz76s=; b=kh8CRi44PkUD++LOAqWd6QGGJjsJHNBCCTMLK5ffkFcpB+oK16C5vqzgGWHTpZzGNO l1cnBh73mn58zxTARZtd+3qVZHXwG+fXoOkli7l/mUEliuuemqYGCJVQtohxPpW5i59p b4qsuVTXL1sMOh+mwluIhM2KK0AGI9fgusuRXeYupVfV3MOK+e5Y+R2/wzprkVE9LyZ6 hG3/igjnhjLpmk6QjKcO6s/WuTjOqGiEfb5NlXxh+IWvRGpfY6OQihvySHMuDIfS89sg 4uoKBn+4XHt/gGM/xptfyE/Cu/2YOUjK0ZbTKjl1UNNy+shLL8f+6V0N+BoavIaroNNZ 7j8g== X-Gm-Message-State: AOJu0YyMORmuJr6WVxhAgDgn9Qkg5PrGfOUAQRldTGBdOQv2ZiVdRU6V X6LLe7Lb41E96/4cv8Tv2zeE2UWxCAdmCJxnyyvUt7d3/aJjkxHvhGiCSZArKahTVkMFow6V6p+ Q X-Google-Smtp-Source: AGHT+IFkcY9NC4+53DSnbnjZwalFgSYeBBD7tGU21Ee8UQhvEpap+UsZppLK9hT5dVRlzCv8I+UYvg== X-Received: by 2002:a17:903:32c8:b0:1fb:2ebc:d17a with SMTP id d9443c01a7336-2039c50a20amr67023645ad.23.1724438860199; Fri, 23 Aug 2024 11:47:40 -0700 (PDT) Received: from debug.ba.rivosinc.com ([64.71.180.162]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20385fcf6b3sm31507705ad.302.2024.08.23.11.47.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Aug 2024 11:47:39 -0700 (PDT) From: Deepak Gupta To: opensbi@lists.infradead.org Subject: [PATCH v4 1/4] include: adding support for Zicfilp / Zicfiss encodings Date: Fri, 23 Aug 2024 11:47:32 -0700 Message-ID: <20240823184735.4154272-2-debug@rivosinc.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240823184735.4154272-1-debug@rivosinc.com> References: <20240823184735.4154272-1-debug@rivosinc.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240823_114741_991936_B981A934 X-CRM114-Status: UNSURE ( 7.26 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -1.9 (-) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Zicfilp / Zicfiss extension (see link) introduces b2 (LPE) in menvcfg CSR to enable landing pads and b3 (SSE) in menvcfg CSR to enable shadow stack and landing pad for privilege less than M. Additiona [...] Content analysis details: (-1.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:630 listed in] [list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.0 T_SCC_BODY_TEXT_LINE No description available. X-BeenThere: opensbi@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: apatel@ventanamicro.com, anup@brainfault.org, atishp@rivosinc.com, cleger@rivosinc.com, Deepak Gupta Sender: "opensbi" Errors-To: opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Zicfilp / Zicfiss extension (see link) introduces b2 (LPE) in menvcfg CSR to enable landing pads and b3 (SSE) in menvcfg CSR to enable shadow stack and landing pad for privilege less than M. Additionally extension introduces new bits in *status for recording landing pad state and a new exception type `software check exception` with cause=0x12. Link: https://github.com/riscv/riscv-cfi Signed-off-by: Deepak Gupta Reviewed-by: Atish Patra --- include/sbi/riscv_encoding.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/include/sbi/riscv_encoding.h b/include/sbi/riscv_encoding.h index 2ed05f2..fa1d373 100644 --- a/include/sbi/riscv_encoding.h +++ b/include/sbi/riscv_encoding.h @@ -32,6 +32,7 @@ #define MSTATUS_TVM _UL(0x00100000) #define MSTATUS_TW _UL(0x00200000) #define MSTATUS_TSR _UL(0x00400000) +#define MSTATUS_SPELP _UL(0x00800000) #define MSTATUS32_SD _UL(0x80000000) #if __riscv_xlen == 64 #define MSTATUS_UXL _ULL(0x0000000300000000) @@ -41,12 +42,14 @@ #define MSTATUS_GVA _ULL(0x0000004000000000) #define MSTATUS_GVA_SHIFT 38 #define MSTATUS_MPV _ULL(0x0000008000000000) +#define MSTATUS_MPELP _ULL(0x0000020000000000) #else #define MSTATUSH_SBE _UL(0x00000010) #define MSTATUSH_MBE _UL(0x00000020) #define MSTATUSH_GVA _UL(0x00000040) #define MSTATUSH_GVA_SHIFT 6 #define MSTATUSH_MPV _UL(0x00000080) +#define MSTATUSH_MPELP _UL(0x00000200) #endif #define MSTATUS32_SD _UL(0x80000000) #define MSTATUS64_SD _ULL(0x8000000000000000) @@ -220,6 +223,8 @@ #define ENVCFG_CBIE_ILL _UL(0x0) #define ENVCFG_CBIE_FLUSH _UL(0x1) #define ENVCFG_CBIE_INV _UL(0x3) +#define ENVCFG_SSE (_UL(1) << 3) +#define ENVCFG_LPE (_UL(1) << 2) #define ENVCFG_FIOM _UL(0x1) /* ===== User-level CSRs ===== */ @@ -228,6 +233,7 @@ #define CSR_USTATUS 0x000 #define CSR_UIE 0x004 #define CSR_UTVEC 0x005 +#define CSR_SSP 0x011 /* User Trap Handling (N-extension) */ #define CSR_USCRATCH 0x040 @@ -763,6 +769,7 @@ #define CAUSE_FETCH_PAGE_FAULT 0xc #define CAUSE_LOAD_PAGE_FAULT 0xd #define CAUSE_STORE_PAGE_FAULT 0xf +#define CAUSE_SW_CHECK_EXCP 0x12 #define CAUSE_FETCH_GUEST_PAGE_FAULT 0x14 #define CAUSE_LOAD_GUEST_PAGE_FAULT 0x15 #define CAUSE_VIRTUAL_INST_FAULT 0x16