From nobody Sun Nov 24 06:15:55 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1726130941; cv=none; d=zohomail.com; s=zohoarc; b=A6S2hBYiG+u6483PUpTn1F6ndzVaxOcRGByPn5mLsWcl4n5E2cLi5ULgAh0e/DLuHmgUOi0yFWEjz3X0qp9aUuGHPiSlMPLO8j+qQP9BayFTf/a9RA7tEZGZ1jz+XdgkCVG4GxKXUg5JDBAZlvG0sRW7eyxthRnqUtnQ6/f7yfY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1726130941; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=8GfbXR146ahHzfDRfP7yHw+LAlO/KwI1uO89UGrVWk8=; b=mb3RzvWnmk00DJZ/d2NjJLRpSUyuzkHiLmXwdG5xj4sCtLxMxXAs7/XRK6myFIaSoJd0IYxlMvkre60WVub/yXE4ukQUKwBywU9T8TxuPgNphrCCMpYVH1ff5XWLfHaAP0sRfUk6BfkqLM+YolDKhJnJx9OXbaPg8mCeXBr2E8g= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1726130941656962.4492491049067; Thu, 12 Sep 2024 01:49:01 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sofVQ-0001TY-RG; Thu, 12 Sep 2024 04:48:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sofVN-0001JA-HV for qemu-devel@nongnu.org; Thu, 12 Sep 2024 04:48:45 -0400 Received: from mail-wr1-x433.google.com ([2a00:1450:4864:20::433]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sofVJ-0000JH-VF for qemu-devel@nongnu.org; Thu, 12 Sep 2024 04:48:44 -0400 Received: by mail-wr1-x433.google.com with SMTP id ffacd0b85a97d-374c1120a32so545731f8f.1 for ; Thu, 12 Sep 2024 01:48:39 -0700 (PDT) Received: from carbon-x1.. ([2a01:e0a:e17:9700:16d2:7456:6634:9626]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42caeb33a92sm165637475e9.20.2024.09.12.01.48.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Sep 2024 01:48:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1726130918; x=1726735718; darn=nongnu.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=8GfbXR146ahHzfDRfP7yHw+LAlO/KwI1uO89UGrVWk8=; b=m8TgDE8zJRUZuZd/Du1W+gKJ1L3fhyRDDIUPeMlH59U8SDuPcucxSAbwEpgR3vJL+C QuxggJLXYxgmw13TkZIMuIrsbsgcSfiu+sg8FRxeOjF5quvEtO1lSdTszKesGWyLJZP0 5qisrGIR4Pama+z/s5UfFTErmDp91jqVwrFfzOMNYdkYMTEY8xujpIlTh75fpVw0/iL7 Wvr2bbM0VP8tbjCtrkGf2uD0lPhLwMvk6lNKyGDyg7E8ycWJr4tbagavIp2VbtZtZMBz fgVKcmkkl+TJDJe7wEJahORukT4UV6RdRr2tMnxCg6q+8rIcvGvPUYTBw3G45o1m+3ie HDSA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726130918; x=1726735718; 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=8GfbXR146ahHzfDRfP7yHw+LAlO/KwI1uO89UGrVWk8=; b=gxM1/82i6BRGZYPpEWqnzGkESoZk/zuH1MFZXWlspHfEIWpELbY9QaRFRWZ3rfFkT4 Cml7+Tn7RpIz6sy4zbzxEzZjQHH65CoZJGYvsSqm1H6nxxBI74CY/GC1Sp0LnfuACdGx GgCVTNlNywYkrON0PB1DbtY5AYDQOG26XELvK3KaJYNb+aI40oMBc11TBNejMESsj+J0 TRx0UmwiS6o/Bssai6bAfawHZr4CnEN6ErZx1UDSZX5enIXIbBQ1SMYBFESo1lT2oMyQ hP2yn02+UyIYA7vkkChw89s7dns6jGs+qFNsIPcpXKU2mzOsIsQCOvawg4qbx8uJnMA8 GREA== X-Forwarded-Encrypted: i=1; AJvYcCUbInUtVmQD1qluwexoj7ZdcDg4zbhHpJkTXYd2dm9nEQFXswsM/svaAi2EXjNlmHuFLubxwjrR13ro@nongnu.org X-Gm-Message-State: AOJu0YzWxIn81G25P3qmh5+FnqdKOeiElfbuh/UcrzVshf4J76QjBppr fy9iDtEAYT4K+s9zMx9cqMLlN6f+JfSqqHEggjIurMiGaj0cV/pb4VmtuwXFt2M= X-Google-Smtp-Source: AGHT+IE1GJ67/oyqOTeVwf5avAFQotgbBlyliT9pJf7zz3+QsgxhCfj33NQ6e640IfdrOyisLbOi1w== X-Received: by 2002:adf:cd8e:0:b0:366:eade:bfbb with SMTP id ffacd0b85a97d-378c2d4c76dmr1148455f8f.46.1726130918071; Thu, 12 Sep 2024 01:48:38 -0700 (PDT) From: =?UTF-8?q?Cl=C3=A9ment=20L=C3=A9ger?= To: qemu-riscv@nongnu.org, Palmer Dabbelt , Alistair Francis , Bin Meng Cc: =?UTF-8?q?Cl=C3=A9ment=20L=C3=A9ger?= , Weiwei Li , Daniel Henrique Barboza , Liu Zhiwei , Ved Shanbhogue , Atish Patra , qemu-devel@nongnu.org Subject: [PATCH 01/10] target/riscv: Add `ext_ssdbltrp` in RISCVCPUConfig. Date: Thu, 12 Sep 2024 10:48:20 +0200 Message-ID: <20240912084832.2906991-2-cleger@rivosinc.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240912084832.2906991-1-cleger@rivosinc.com> References: <20240912084832.2906991-1-cleger@rivosinc.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::433; envelope-from=cleger@rivosinc.com; helo=mail-wr1-x433.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @rivosinc-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1726130942353116600 This variable is used to determine if the Ssdbltrp extension is enabled. Signed-off-by: Cl=C3=A9ment L=C3=A9ger --- target/riscv/cpu_cfg.h | 1 + 1 file changed, 1 insertion(+) diff --git a/target/riscv/cpu_cfg.h b/target/riscv/cpu_cfg.h index ae2a945b5f..dd804f95d4 100644 --- a/target/riscv/cpu_cfg.h +++ b/target/riscv/cpu_cfg.h @@ -77,6 +77,7 @@ struct RISCVCPUConfig { bool ext_smstateen; bool ext_sstc; bool ext_smcntrpmf; + bool ext_ssdbltrp; bool ext_svadu; bool ext_svinval; bool ext_svnapot; --=20 2.45.2 From nobody Sun Nov 24 06:15:55 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1726130997; cv=none; d=zohomail.com; s=zohoarc; b=atuIPZGkeRB5QCHaifoV2o4x9zOp5Iq6cNbs5tAg9vNT/W8L1rBXnhQ/rV3HGq4mSHf4U6yO3FTI1fZY5JG1HTjWBhwnJZLkkMHQX9rv6dHQZ+1AMkCDT7slVe7M3u8nUOqeruABmrBVROgnzVSjsHzkT7Pq3Sup+l+WpDVgF8c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1726130997; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=2Q7zUVA3YeImHTytYVuv09gAKlWA0rSKOT0ww4Ea2dk=; b=moFzbxoS1d2Yo7Ny+EJzv4zmt/9ShSxuGOs0hV3BSP+DKDM06mrs48A80xqbuxkTqn5h5KfZW/xZZ7TkkZ1GDEn0WAiUiJZ3VfyPVCo46GGqzs0/ufNKoBRaV+41HUb/3Cn//MB/QG4EZCLsuTB3yO4rvjRNXua5nGtT9vFmkQk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 17261309976293.1310276815501084; Thu, 12 Sep 2024 01:49:57 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sofVR-0001b7-RA; Thu, 12 Sep 2024 04:48:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sofVN-0001KQ-Rz for qemu-devel@nongnu.org; Thu, 12 Sep 2024 04:48:45 -0400 Received: from mail-wm1-x32b.google.com ([2a00:1450:4864:20::32b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sofVJ-0000JW-VH for qemu-devel@nongnu.org; Thu, 12 Sep 2024 04:48:45 -0400 Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-42cae6bb895so6289215e9.1 for ; Thu, 12 Sep 2024 01:48:40 -0700 (PDT) Received: from carbon-x1.. ([2a01:e0a:e17:9700:16d2:7456:6634:9626]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42caeb33a92sm165637475e9.20.2024.09.12.01.48.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Sep 2024 01:48:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1726130920; x=1726735720; darn=nongnu.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=2Q7zUVA3YeImHTytYVuv09gAKlWA0rSKOT0ww4Ea2dk=; b=V+aMlYXnDAzUxbcJ1oAVAVmQF2HWA/BaoyKaG2zoCcSLI4LlrcRU36XyPYn3/813ck eD/tmk5wjnNrYTcH+c9bxomKk7oTMynivxqwoi2DheEjkaAv7JvB9kvPlneIbEa/6yyB zKnzJs+ESR9kEKIqUSrhWyA6kxZKO5xoFRqbuRlqWbWT2jlaAnM9/3iDBT5fm+nxFpdy bg0DECtHwhsAsFsN1fMvM9XcuCBRpzgNe71UqNv1D+e5BczCyUxkwZgLbN3fMWRBjx4v U4fPtQ63UeIDBcRjZAjqxOco9Ed14F+GmYwfcGSm4iI1ZVs9RANhphx6Jq85A6IRNHYe WaMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726130920; x=1726735720; 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=2Q7zUVA3YeImHTytYVuv09gAKlWA0rSKOT0ww4Ea2dk=; b=eRbyo/qErDp4Iff64GvY2OjEifgbjI08IaM54Zn5t7GPwAwizsSgM/GYCbY0jVw/O7 NyPtGh7aSe2AgzyvaCXZ1xJRsqVgm4ce9CywqAUffeWGWp6CfUyN1avSgoXbvrl91q/H FYMZIut3LVWLJpxpqAAuLAqskAHHbX3xorrPQZicfKhJ7elqfN6XWGECq0CoFT6NMiSt 305xjLMzsKmiAbaMiQYXMPo5JWaHzGYWgQJBlRRvv2F+6v4HV2Is4QTeFMPbFwswUTY0 OHARg6YaAIhuxNL4m/RZtZSc0LkXv5Vr2oV9n/615XUoZSVUULHBYoGkTZtwb4PLnTyN nc6Q== X-Forwarded-Encrypted: i=1; AJvYcCXqA4Mf1Z0qvDgGHpzlB13L5lqcgbrq6v5tpxcXSW9Vk8pHyv0K+hSCE8Ehu8UWOJigkUguxVw3YJLg@nongnu.org X-Gm-Message-State: AOJu0Yx2NkVDGhEdwYj0JOJNbW6YSO/dMWWiQrCNywc5fh/NWAXT23Os Eyn5t6jgwTrqsqxarGfhQJjhT2rOnAX3JNfDFVLZwHa81am35+HPtE28DXoRiIU= X-Google-Smtp-Source: AGHT+IHbcdULDcxn8lygJmAwebRCgNUdJEYYYfS2fYLbC9HqdQbd5IjXrMiTUjx1qmx+P37J1PAhuA== X-Received: by 2002:a05:600c:21d9:b0:42c:b1a4:c3ef with SMTP id 5b1f17b1804b1-42cdfb15de5mr6891695e9.33.1726130919405; Thu, 12 Sep 2024 01:48:39 -0700 (PDT) From: =?UTF-8?q?Cl=C3=A9ment=20L=C3=A9ger?= To: qemu-riscv@nongnu.org, Palmer Dabbelt , Alistair Francis , Bin Meng Cc: =?UTF-8?q?Cl=C3=A9ment=20L=C3=A9ger?= , Weiwei Li , Daniel Henrique Barboza , Liu Zhiwei , Ved Shanbhogue , Atish Patra , qemu-devel@nongnu.org Subject: [PATCH 02/10] target/riscv: Add Ssdbltrp CSRs handling Date: Thu, 12 Sep 2024 10:48:21 +0200 Message-ID: <20240912084832.2906991-3-cleger@rivosinc.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240912084832.2906991-1-cleger@rivosinc.com> References: <20240912084832.2906991-1-cleger@rivosinc.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32b; envelope-from=cleger@rivosinc.com; helo=mail-wm1-x32b.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @rivosinc-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1726130998436116600 Implement MSTATUS.SDT, {H|M}ENVCFG.DTE and modify the availability of MTVAL2 based on the presence of the Ssdbltrp ISA extension. Signed-off-by: Cl=C3=A9ment L=C3=A9ger --- target/riscv/cpu.h | 1 + target/riscv/cpu_bits.h | 6 ++++++ target/riscv/cpu_helper.c | 16 ++++++++++++++ target/riscv/csr.c | 45 ++++++++++++++++++++++++++++++--------- 4 files changed, 58 insertions(+), 10 deletions(-) diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h index a84e719d3f..ee984bf270 100644 --- a/target/riscv/cpu.h +++ b/target/riscv/cpu.h @@ -553,6 +553,7 @@ void riscv_cpu_set_geilen(CPURISCVState *env, target_ul= ong geilen); bool riscv_cpu_vector_enabled(CPURISCVState *env); void riscv_cpu_set_virt_enabled(CPURISCVState *env, bool enable); int riscv_env_mmu_index(CPURISCVState *env, bool ifetch); +bool riscv_env_smode_dbltrp_enabled(CPURISCVState *env, bool virt); G_NORETURN void riscv_cpu_do_unaligned_access(CPUState *cs, vaddr addr, MMUAccessType access_type, int mmu_idx, uintptr_t reta= ddr); diff --git a/target/riscv/cpu_bits.h b/target/riscv/cpu_bits.h index da1723496c..3a5588d4df 100644 --- a/target/riscv/cpu_bits.h +++ b/target/riscv/cpu_bits.h @@ -558,6 +558,7 @@ #define MSTATUS_TVM 0x00100000 /* since: priv-1.10 */ #define MSTATUS_TW 0x00200000 /* since: priv-1.10 */ #define MSTATUS_TSR 0x00400000 /* since: priv-1.10 */ +#define MSTATUS_SDT 0x01000000 #define MSTATUS_GVA 0x4000000000ULL #define MSTATUS_MPV 0x8000000000ULL =20 @@ -588,6 +589,7 @@ typedef enum { #define SSTATUS_XS 0x00018000 #define SSTATUS_SUM 0x00040000 /* since: priv-1.10 */ #define SSTATUS_MXR 0x00080000 +#define SSTATUS_SDT 0x01000000 =20 #define SSTATUS64_UXL 0x0000000300000000ULL =20 @@ -777,11 +779,13 @@ typedef enum RISCVException { #define MENVCFG_CBIE (3UL << 4) #define MENVCFG_CBCFE BIT(6) #define MENVCFG_CBZE BIT(7) +#define MENVCFG_DTE (1ULL << 59) #define MENVCFG_ADUE (1ULL << 61) #define MENVCFG_PBMTE (1ULL << 62) #define MENVCFG_STCE (1ULL << 63) =20 /* For RV32 */ +#define MENVCFGH_DTE BIT(27) #define MENVCFGH_ADUE BIT(29) #define MENVCFGH_PBMTE BIT(30) #define MENVCFGH_STCE BIT(31) @@ -795,11 +799,13 @@ typedef enum RISCVException { #define HENVCFG_CBIE MENVCFG_CBIE #define HENVCFG_CBCFE MENVCFG_CBCFE #define HENVCFG_CBZE MENVCFG_CBZE +#define HENVCFG_DTE MENVCFG_DTE #define HENVCFG_ADUE MENVCFG_ADUE #define HENVCFG_PBMTE MENVCFG_PBMTE #define HENVCFG_STCE MENVCFG_STCE =20 /* For RV32 */ +#define HENVCFGH_DTE MENVCFGH_DTE #define HENVCFGH_ADUE MENVCFGH_ADUE #define HENVCFGH_PBMTE MENVCFGH_PBMTE #define HENVCFGH_STCE MENVCFGH_STCE diff --git a/target/riscv/cpu_helper.c b/target/riscv/cpu_helper.c index 9d0400035f..395d8235ce 100644 --- a/target/riscv/cpu_helper.c +++ b/target/riscv/cpu_helper.c @@ -63,6 +63,22 @@ int riscv_env_mmu_index(CPURISCVState *env, bool ifetch) #endif } =20 +bool riscv_env_smode_dbltrp_enabled(CPURISCVState *env, bool virt) +{ +#ifdef CONFIG_USER_ONLY + return false; +#else + if (!riscv_cpu_cfg(env)->ext_ssdbltrp) { + return false; + } + if (virt) { + return (env->henvcfg & HENVCFG_DTE) !=3D 0; + } else { + return (env->menvcfg & MENVCFG_DTE) !=3D 0; + } +#endif +} + void cpu_get_tb_cpu_state(CPURISCVState *env, vaddr *pc, uint64_t *cs_base, uint32_t *pflags) { diff --git a/target/riscv/csr.c b/target/riscv/csr.c index e5de72453c..d8280ec956 100644 --- a/target/riscv/csr.c +++ b/target/riscv/csr.c @@ -540,6 +540,15 @@ static RISCVException aia_hmode32(CPURISCVState *env, = int csrno) return hmode32(env, csrno); } =20 +static RISCVException dbltrp_hmode(CPURISCVState *env, int csrno) +{ + if (riscv_cpu_cfg(env)->ext_ssdbltrp) { + return RISCV_EXCP_NONE; + } + + return hmode(env, csrno); +} + static RISCVException pmp(CPURISCVState *env, int csrno) { if (riscv_cpu_cfg(env)->pmp) { @@ -1402,7 +1411,7 @@ static const target_ulong vs_delegable_excps =3D DELE= GABLE_EXCPS & (1ULL << (RISCV_EXCP_STORE_GUEST_AMO_ACCESS_FAULT))); static const target_ulong sstatus_v1_10_mask =3D SSTATUS_SIE | SSTATUS_SPI= E | SSTATUS_UIE | SSTATUS_UPIE | SSTATUS_SPP | SSTATUS_FS | SSTATUS_XS | - SSTATUS_SUM | SSTATUS_MXR | SSTATUS_VS; + SSTATUS_SUM | SSTATUS_MXR | SSTATUS_VS | SSTATUS_SDT; =20 /* * Spec allows for bits 13:63 to be either read-only or writable. @@ -1600,6 +1609,14 @@ static RISCVException write_mstatus(CPURISCVState *e= nv, int csrno, mask |=3D MSTATUS_VS; } =20 + if (riscv_env_smode_dbltrp_enabled(env, env->virt_enabled)) { + mask |=3D MSTATUS_SDT; + if ((val & MSTATUS_SDT) !=3D 0) { + mstatus &=3D ~MSTATUS_SIE; + val &=3D ~MSTATUS_SIE; + } + } + if (xl !=3D MXL_RV32 || env->debugger) { if (riscv_has_ext(env, RVH)) { mask |=3D MSTATUS_MPV | MSTATUS_GVA; @@ -2354,7 +2371,8 @@ static RISCVException write_menvcfg(CPURISCVState *en= v, int csrno, if (riscv_cpu_mxl(env) =3D=3D MXL_RV64) { mask |=3D (cfg->ext_svpbmt ? MENVCFG_PBMTE : 0) | (cfg->ext_sstc ? MENVCFG_STCE : 0) | - (cfg->ext_svadu ? MENVCFG_ADUE : 0); + (cfg->ext_svadu ? MENVCFG_ADUE : 0) | + (cfg->ext_ssdbltrp ? MENVCFG_DTE : 0); } env->menvcfg =3D (env->menvcfg & ~mask) | (val & mask); =20 @@ -2374,7 +2392,8 @@ static RISCVException write_menvcfgh(CPURISCVState *e= nv, int csrno, const RISCVCPUConfig *cfg =3D riscv_cpu_cfg(env); uint64_t mask =3D (cfg->ext_svpbmt ? MENVCFG_PBMTE : 0) | (cfg->ext_sstc ? MENVCFG_STCE : 0) | - (cfg->ext_svadu ? MENVCFG_ADUE : 0); + (cfg->ext_svadu ? MENVCFG_ADUE : 0) | + (cfg->ext_ssdbltrp ? MENVCFG_DTE : 0); uint64_t valh =3D (uint64_t)val << 32; =20 env->menvcfg =3D (env->menvcfg & ~mask) | (valh & mask); @@ -2425,9 +2444,10 @@ static RISCVException read_henvcfg(CPURISCVState *en= v, int csrno, * henvcfg.pbmte is read_only 0 when menvcfg.pbmte =3D 0 * henvcfg.stce is read_only 0 when menvcfg.stce =3D 0 * henvcfg.adue is read_only 0 when menvcfg.adue =3D 0 + * henvcfg.dte is read_only 0 when menvcfg.dte =3D 0 */ - *val =3D env->henvcfg & (~(HENVCFG_PBMTE | HENVCFG_STCE | HENVCFG_ADUE= ) | - env->menvcfg); + *val =3D env->henvcfg & (~(HENVCFG_PBMTE | HENVCFG_STCE | HENVCFG_ADUE= | + HENVCFG_DTE) | env->menvcfg); return RISCV_EXCP_NONE; } =20 @@ -2435,6 +2455,7 @@ static RISCVException write_henvcfg(CPURISCVState *en= v, int csrno, target_ulong val) { uint64_t mask =3D HENVCFG_FIOM | HENVCFG_CBIE | HENVCFG_CBCFE | HENVCF= G_CBZE; + uint64_t menvcfg_mask; RISCVException ret; =20 ret =3D smstateen_acc_ok(env, 0, SMSTATEEN0_HSENVCFG); @@ -2443,7 +2464,11 @@ static RISCVException write_henvcfg(CPURISCVState *e= nv, int csrno, } =20 if (riscv_cpu_mxl(env) =3D=3D MXL_RV64) { - mask |=3D env->menvcfg & (HENVCFG_PBMTE | HENVCFG_STCE | HENVCFG_A= DUE); + menvcfg_mask =3D HENVCFG_PBMTE | HENVCFG_STCE | HENVCFG_ADUE; + if (riscv_cpu_cfg(env)->ext_ssdbltrp) { + menvcfg_mask |=3D HENVCFG_DTE; + } + mask |=3D env->menvcfg & menvcfg_mask; } =20 env->henvcfg =3D (env->henvcfg & ~mask) | (val & mask); @@ -2461,8 +2486,8 @@ static RISCVException read_henvcfgh(CPURISCVState *en= v, int csrno, return ret; } =20 - *val =3D (env->henvcfg & (~(HENVCFG_PBMTE | HENVCFG_STCE | HENVCFG_ADU= E) | - env->menvcfg)) >> 32; + *val =3D (env->henvcfg & (~(HENVCFG_PBMTE | HENVCFG_STCE | HENVCFG_ADU= E | + HENVCFG_DTE) | env->menvcfg)) >> 32; return RISCV_EXCP_NONE; } =20 @@ -2470,7 +2495,7 @@ static RISCVException write_henvcfgh(CPURISCVState *e= nv, int csrno, target_ulong val) { uint64_t mask =3D env->menvcfg & (HENVCFG_PBMTE | HENVCFG_STCE | - HENVCFG_ADUE); + HENVCFG_ADUE | HENVCFG_DTE); uint64_t valh =3D (uint64_t)val << 32; RISCVException ret; =20 @@ -5246,7 +5271,7 @@ riscv_csr_operations csr_ops[CSR_TABLE_SIZE] =3D { [CSR_VSATP] =3D { "vsatp", hmode, read_vsatp, write_v= satp, .min_priv_ver =3D PRIV_VERSION_1_12_0 = }, =20 - [CSR_MTVAL2] =3D { "mtval2", hmode, read_mtval2, write_m= tval2, + [CSR_MTVAL2] =3D { "mtval2", dbltrp_hmode, read_mtval2, write_mtv= al2, .min_priv_ver =3D PRIV_VERSION_1_12_0 = }, [CSR_MTINST] =3D { "mtinst", hmode, read_mtinst, write_m= tinst, .min_priv_ver =3D PRIV_VERSION_1_12_0 = }, --=20 2.45.2 From nobody Sun Nov 24 06:15:55 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1726131044; cv=none; d=zohomail.com; s=zohoarc; b=PZtXcN11Zhzb9IK3OLs/qV9656RxZSSlWjuDp47yUpngZ3MhVa4NvBjFyg/KcaecToRAheYtoCnInCzgywwe8UmgeArzxPj7ZtiOiJIb1k+CMJcI8629SsF8lZQo3k101ChkHxD5nG+EiB8eIawynlGguE6/5UZL8pOW/n6iSUM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1726131044; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=990Tx1Qy7IC4XWEHL20LmKjYVwPDG37slOaxsBSKYtM=; b=eHgy4MUp28RZNFzrO0gq0Ga5vHXmPLUYk5PshIjSWDlfyJkKc7DpOm+XZ/GGKx97j/ltu1QTwtXHjkiAqx1XxagzBBkrNzfysTXPmD8Y45Ji5n9Eo56wogKsurrylhoVXBZHB0Z28PidJ5l8hwBAKKlV3CAQdp3U5x6iDTj7a4A= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 172613104410858.81999582285653; Thu, 12 Sep 2024 01:50:44 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sofVV-0001hX-BR; Thu, 12 Sep 2024 04:48:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sofVN-0001Kt-Vm for qemu-devel@nongnu.org; Thu, 12 Sep 2024 04:48:46 -0400 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sofVL-0000Je-QT for qemu-devel@nongnu.org; Thu, 12 Sep 2024 04:48:45 -0400 Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-42cd74c0d16so6349165e9.1 for ; Thu, 12 Sep 2024 01:48:43 -0700 (PDT) Received: from carbon-x1.. ([2a01:e0a:e17:9700:16d2:7456:6634:9626]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42caeb33a92sm165637475e9.20.2024.09.12.01.48.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Sep 2024 01:48:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1726130922; x=1726735722; darn=nongnu.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=990Tx1Qy7IC4XWEHL20LmKjYVwPDG37slOaxsBSKYtM=; b=AE7NsHRFtRKo/dh4GXTrW3BrANANcMb2EBLpepBXSY7mQIaBchVZ4HffM0aLBfzoHs iFbtY4YBEgXnDBphrw/+nPxDvsWsOejcIFm/5/d+usrYTVkvKa962VXnLh4aPIk/5WvF cxPM/EXEs0wfUz8lHdVvhMN3mLvJXR9+CnCc4nhh+fBSOta2qJZ7qTUFEM9C7ZtDd1px g2bC1ILSLtflbGtfHh9b5h2RCfqm638zVFuPMfZZtHgWwVCVDvW0ELh084JvHIJc0I4+ VZC7f+LvLiZmnV/irCyODPvhcR/fStsCJ33901wqbWlVQ48I/a4cxjgqEzzOOnPhnU0w v2FQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726130922; x=1726735722; 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=990Tx1Qy7IC4XWEHL20LmKjYVwPDG37slOaxsBSKYtM=; b=snDxTqXX84L/7j/laLmKHVQei8cXrebGZmTd5XIW7MGBKdqJAYNCBbZb2xdcfqshbw 262gF0VxExdhoQkm0yDmRymYjhMZKYajMenfpAK3fC0m1zmYKRmPhXRoo/luBAk07Meq c8/0PJiS5qWO+reCYAA9FuwmiTm+ewH9+TRTBfVUAiYjfeGVKcFKLiJsOPkxtvQclJ0i RzhhNql0KKFvK3T8gjI+mrg1kra7NImvHRtnhKxWkj/RSv2QdLk8iekHak0IPRLZLPor 2go+/e4CHNrILpqQO4hJ9I8EuXi4AswmNjzN4W6A0Idie+luVj4Kn6hcG7tlRk254gVT 9Bdw== X-Forwarded-Encrypted: i=1; AJvYcCUjNINCsA1UjBCu2hLr5sZO19vaMdc3uZa0EjoMvN9j/6XfLw1h7+Eg97y9VjbHtWC0FaO41cOvO43E@nongnu.org X-Gm-Message-State: AOJu0YxevdjtxXNV0wZzqbMJ4o/xA3ujeVvhYt5WkzgIEPb2uMdFn+3l Df/zBneB6t+0JwYIj+AlfQh7fciEx+3xSHgxhrES36choSLuaB351h29QyMppoM= X-Google-Smtp-Source: AGHT+IHW2JEih895gu8DqoSbz+pLAUR1dMwyLOAQHA/mBXiE11NRo6WRI/Jfnw4UdIr3TX1pyHBjSQ== X-Received: by 2002:a05:600c:1c1b:b0:42c:acb0:dda5 with SMTP id 5b1f17b1804b1-42cdb511e6dmr17114765e9.1.1726130921196; Thu, 12 Sep 2024 01:48:41 -0700 (PDT) From: =?UTF-8?q?Cl=C3=A9ment=20L=C3=A9ger?= To: qemu-riscv@nongnu.org, Palmer Dabbelt , Alistair Francis , Bin Meng Cc: =?UTF-8?q?Cl=C3=A9ment=20L=C3=A9ger?= , Weiwei Li , Daniel Henrique Barboza , Liu Zhiwei , Ved Shanbhogue , Atish Patra , qemu-devel@nongnu.org Subject: [PATCH 03/10] target/riscv: Implement Ssdbltrp sret, mret and mnret behavior Date: Thu, 12 Sep 2024 10:48:22 +0200 Message-ID: <20240912084832.2906991-4-cleger@rivosinc.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240912084832.2906991-1-cleger@rivosinc.com> References: <20240912084832.2906991-1-cleger@rivosinc.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::329; envelope-from=cleger@rivosinc.com; helo=mail-wm1-x329.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @rivosinc-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1726131044627116600 When the Ssdbltrp extension is enabled, SSTATUS.SDT field is cleared when executing sret. When executing mret/mnret, SSTATUS.SDT is cleared when returning to U, VS or VU and VSSTATUS.SDT is cleared when returning to VU from HS. Signed-off-by: Cl=C3=A9ment L=C3=A9ger --- target/riscv/op_helper.c | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/target/riscv/op_helper.c b/target/riscv/op_helper.c index 6895c7596b..00b6f75102 100644 --- a/target/riscv/op_helper.c +++ b/target/riscv/op_helper.c @@ -287,6 +287,18 @@ target_ulong helper_sret(CPURISCVState *env) get_field(mstatus, MSTATUS_SPIE)); mstatus =3D set_field(mstatus, MSTATUS_SPIE, 1); mstatus =3D set_field(mstatus, MSTATUS_SPP, PRV_U); + + if (riscv_cpu_cfg(env)->ext_ssdbltrp) { + if (riscv_has_ext(env, RVH)) { + target_ulong prev_vu =3D get_field(env->hstatus, HSTATUS_SPV) = && + prev_priv =3D=3D PRV_U; + /* Returning to VU from HS, vsstatus.sdt =3D 0 */ + if (!env->virt_enabled && prev_vu) { + env->vsstatus =3D set_field(env->vsstatus, MSTATUS_SDT, 0); + } + } + mstatus =3D set_field(mstatus, MSTATUS_SDT, 0); + } if (env->priv_ver >=3D PRIV_VERSION_1_12_0) { mstatus =3D set_field(mstatus, MSTATUS_MPRV, 0); } @@ -297,7 +309,6 @@ target_ulong helper_sret(CPURISCVState *env) target_ulong hstatus =3D env->hstatus; =20 prev_virt =3D get_field(hstatus, HSTATUS_SPV); - hstatus =3D set_field(hstatus, HSTATUS_SPV, 0); =20 env->hstatus =3D hstatus; @@ -328,6 +339,22 @@ static void check_ret_from_m_mode(CPURISCVState *env, = target_ulong retpc, riscv_raise_exception(env, RISCV_EXCP_INST_ACCESS_FAULT, GETPC()); } } +static target_ulong ssdbltrp_mxret(CPURISCVState *env, target_ulong mstatu= s, + target_ulong prev_priv, + target_ulong prev_virt) +{ + /* If returning to U, VS or VU, sstatus.sdt =3D 0 */ + if (prev_priv =3D=3D PRV_U || (prev_virt && + (prev_priv =3D=3D PRV_S || prev_priv =3D=3D PRV_U))) { + mstatus =3D set_field(mstatus, MSTATUS_SDT, 0); + /* If returning to VU, vsstatus.sdt =3D 0 */ + if (prev_virt && prev_priv =3D=3D PRV_U) { + env->vsstatus =3D set_field(env->vsstatus, MSTATUS_SDT, 0); + } + } + + return mstatus; +} =20 target_ulong helper_mret(CPURISCVState *env) { @@ -345,6 +372,9 @@ target_ulong helper_mret(CPURISCVState *env) mstatus =3D set_field(mstatus, MSTATUS_MPP, riscv_has_ext(env, RVU) ? PRV_U : PRV_M); mstatus =3D set_field(mstatus, MSTATUS_MPV, 0); + if (riscv_cpu_cfg(env)->ext_ssdbltrp) { + mstatus =3D ssdbltrp_mxret(env, mstatus, prev_priv, prev_virt); + } if ((env->priv_ver >=3D PRIV_VERSION_1_12_0) && (prev_priv !=3D PRV_M)= ) { mstatus =3D set_field(mstatus, MSTATUS_MPRV, 0); } @@ -382,6 +412,9 @@ target_ulong helper_mnret(CPURISCVState *env) if (prev_priv < PRV_M) { env->mstatus =3D set_field(env->mstatus, MSTATUS_MPRV, false); } + if (riscv_cpu_cfg(env)->ext_ssdbltrp) { + env->mstatus =3D ssdbltrp_mxret(env, env->mstatus, prev_priv, prev= _virt); + } =20 if (riscv_has_ext(env, RVH) && prev_virt) { riscv_cpu_swap_hypervisor_regs(env); --=20 2.45.2 From nobody Sun Nov 24 06:15:55 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1726131012; cv=none; d=zohomail.com; s=zohoarc; b=CLHwTXe+lnZLMZo8Ig8EaRWkt/wQlMTFfSVZ9lz5Fzl0P5Hh0fHxc4JZ3IA8WBHTS3BKNq1kjKDUxIG57sk/JXW1ick4k3Ggg8Oefdf2bmcqI3G+llrZW/Q0bbOCPeEjZQ2o9+Ywapf5IwHbzwsDj1WyO3+xodeey9LxyeQUJ1A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1726131012; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=X3BYYtY0BUs2UMS0JDRthW597KCoJ873cB2cLz4S29w=; b=TOtAZgem88i8wvQYOtiRvNBbMCZ9dkxoRX7csNPBvId9jLtyq3UVefjBnuomCvjQKucx5J1NLO4WpVUUM5wGE3MbtUwH9VTp4Xn/RzKUIHBDu+3vBrgROuvmQFklXcPNW6+f6U+1e2ChtvrKd/0jWCvDzcmkOw15W5tXdfOHk78= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 172613101222774.8423953912818; Thu, 12 Sep 2024 01:50:12 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sofVW-0001uQ-Tu; Thu, 12 Sep 2024 04:48:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sofVO-0001N4-HD for qemu-devel@nongnu.org; Thu, 12 Sep 2024 04:48:46 -0400 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sofVL-0000Jh-T4 for qemu-devel@nongnu.org; Thu, 12 Sep 2024 04:48:46 -0400 Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-42cb9a0c300so5807165e9.0 for ; Thu, 12 Sep 2024 01:48:43 -0700 (PDT) Received: from carbon-x1.. ([2a01:e0a:e17:9700:16d2:7456:6634:9626]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42caeb33a92sm165637475e9.20.2024.09.12.01.48.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Sep 2024 01:48:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1726130922; x=1726735722; darn=nongnu.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=X3BYYtY0BUs2UMS0JDRthW597KCoJ873cB2cLz4S29w=; b=IT5TZp3N2Urgv8uJDQvfBkHbdR5unsZ557SkTzktbwNFndyQHeYvtI+QxMOR6k8O7a IPrD/AL/ZLTu5wmYlDyFVHJZDdS920zcJZdMPUCnGKb90r8UmNPy4ijWGw9GIUkxUAkN kvScG0FtToA2sk78lzLfPrQJ4ibYGbyLTiYc5Vk81zxvXtxAFR76JuoRTdjwaOkECeau zCvENRmvsA/4oDNKKZcpiH+v3FlAGK3t3SSbfzhFYXt7oYEJAuy6mLGwiMN1JE6tpdc+ /wgogJuXzP6cyL2z7YkxvFjoxXta5Ob6b0QAPjWq7ECS/w6+3Vpct95JP+6uuEvOqHhi UTZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726130922; x=1726735722; 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=X3BYYtY0BUs2UMS0JDRthW597KCoJ873cB2cLz4S29w=; b=J4Rbzn6DX6Cga3m1D19YsLniowwdUw1CRVxuRMFOt7NLsNdI+AI35/VmwuwKuZ5yen dQXbStmn6vTW4dLD3DLEXzyd+8b/qAvTjUjJq1G68d4/yqmmLQ6Jf3B0UeuVgVmtBKVC cGjptPhGH7yS/Ethv46yfX3dzUlkPa8+DT1d7MnQibdzY+tuMq697hkXetCkYnlPwa1V bJJ3lOKfcJTLfLP4xvt8rbAB7KHYw7tXPqIk26kuYLWcZLiha4GXZpVr21jK7WTbMRL6 P8uxNKcKJZHXIBrpBSfBoxmcBk+sS3mLjGcNDg706NjtR8+Ti5WKvPQz96tWlhyuMEJa 4gvw== X-Forwarded-Encrypted: i=1; AJvYcCWkyDeuzSJ9kEPuYWcE7RxrK9EHgDcibXXw8fCoxbKkGdAy/0UyfCUTCkINhwaLLMYSySvipQoEuFSL@nongnu.org X-Gm-Message-State: AOJu0YxLUgu4AwTj6lp3QUopH4DJodAxOoGpdczomkb3lhNLgSSXLUkM 8qF+nzUjmhHCTR0n7FE6u6RaiAMu/iEHYcbQmlc2vGpHEDvISZidAnKcjclaVlQ= X-Google-Smtp-Source: AGHT+IEP0FNcDix5TxlaJ/ervI2foMS791gTtYEqrH/baaKyoPUWwDTMAVX9cb7OnAgeBj2Y8eux9A== X-Received: by 2002:a05:600c:4fc3:b0:42c:bcc8:5877 with SMTP id 5b1f17b1804b1-42cdb522f2cmr15449165e9.13.1726130922252; Thu, 12 Sep 2024 01:48:42 -0700 (PDT) From: =?UTF-8?q?Cl=C3=A9ment=20L=C3=A9ger?= To: qemu-riscv@nongnu.org, Palmer Dabbelt , Alistair Francis , Bin Meng Cc: =?UTF-8?q?Cl=C3=A9ment=20L=C3=A9ger?= , Weiwei Li , Daniel Henrique Barboza , Liu Zhiwei , Ved Shanbhogue , Atish Patra , qemu-devel@nongnu.org Subject: [PATCH 04/10] target/riscv: Implement Ssdbltrp exception handling Date: Thu, 12 Sep 2024 10:48:23 +0200 Message-ID: <20240912084832.2906991-5-cleger@rivosinc.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240912084832.2906991-1-cleger@rivosinc.com> References: <20240912084832.2906991-1-cleger@rivosinc.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::329; envelope-from=cleger@rivosinc.com; helo=mail-wm1-x329.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @rivosinc-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1726131012745116600 When the Ssdbltrp ISA extension is enabled, if a trap happens in S-mode while SSTATUS.SDT isn't cleared, generate a double trap exception to M-mode. Signed-off-by: Cl=C3=A9ment L=C3=A9ger --- target/riscv/cpu.c | 2 +- target/riscv/cpu_bits.h | 1 + target/riscv/cpu_helper.c | 47 ++++++++++++++++++++++++++++++++++----- 3 files changed, 43 insertions(+), 7 deletions(-) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 7ee7b9c4ee..206736182a 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -284,7 +284,7 @@ static const char * const riscv_excp_names[] =3D { "load_page_fault", "reserved", "store_page_fault", - "reserved", + "double_trap", "reserved", "reserved", "reserved", diff --git a/target/riscv/cpu_bits.h b/target/riscv/cpu_bits.h index 3a5588d4df..5557a86348 100644 --- a/target/riscv/cpu_bits.h +++ b/target/riscv/cpu_bits.h @@ -699,6 +699,7 @@ typedef enum RISCVException { RISCV_EXCP_INST_PAGE_FAULT =3D 0xc, /* since: priv-1.10.0 */ RISCV_EXCP_LOAD_PAGE_FAULT =3D 0xd, /* since: priv-1.10.0 */ RISCV_EXCP_STORE_PAGE_FAULT =3D 0xf, /* since: priv-1.10.0 */ + RISCV_EXCP_DOUBLE_TRAP =3D 0x10, RISCV_EXCP_SW_CHECK =3D 0x12, /* since: priv-1.13.0 */ RISCV_EXCP_HW_ERR =3D 0x13, /* since: priv-1.13.0 */ RISCV_EXCP_INST_GUEST_PAGE_FAULT =3D 0x14, diff --git a/target/riscv/cpu_helper.c b/target/riscv/cpu_helper.c index 395d8235ce..69da3c3384 100644 --- a/target/riscv/cpu_helper.c +++ b/target/riscv/cpu_helper.c @@ -575,7 +575,9 @@ void riscv_cpu_swap_hypervisor_regs(CPURISCVState *env) mstatus_mask |=3D MSTATUS_FS; } bool current_virt =3D env->virt_enabled; - + if (riscv_env_smode_dbltrp_enabled(env, current_virt)) { + mstatus_mask |=3D MSTATUS_SDT; + } g_assert(riscv_has_ext(env, RVH)); =20 if (current_virt) { @@ -1707,6 +1709,7 @@ void riscv_cpu_do_interrupt(CPUState *cs) CPURISCVState *env =3D &cpu->env; bool virt =3D env->virt_enabled; bool write_gva =3D false; + bool vsmode_exc; uint64_t s; int mode; =20 @@ -1721,6 +1724,8 @@ void riscv_cpu_do_interrupt(CPUState *cs) !(env->mip & (1 << cause)); bool vs_injected =3D env->hvip & (1 << cause) & env->hvien && !(env->mip & (1 << cause)); + bool smode_double_trap =3D false; + uint64_t hdeleg =3D async ? env->hideleg : env->hedeleg; target_ulong tval =3D 0; target_ulong tinst =3D 0; target_ulong htval =3D 0; @@ -1837,13 +1842,35 @@ void riscv_cpu_do_interrupt(CPUState *cs) !async && mode =3D=3D PRV_M; =20 + vsmode_exc =3D env->virt_enabled && (((hdeleg >> cause) & 1) || vs_inj= ected); + /* + * Check double trap condition only if already in S-mode and targeting + * S-mode + */ + if (cpu->cfg.ext_ssdbltrp && env->priv =3D=3D PRV_S && mode =3D=3D PRV= _S) { + bool dte =3D (env->menvcfg & MENVCFG_DTE) !=3D 0; + bool sdt =3D (env->mstatus & MSTATUS_SDT) !=3D 0; + /* In VS or HS */ + if (riscv_has_ext(env, RVH)) { + if (vsmode_exc) { + /* VS -> VS */ + /* Stay in VS mode, use henvcfg instead of menvcfg*/ + dte =3D (env->henvcfg & HENVCFG_DTE) !=3D 0; + } else if (env->virt_enabled) { + /* VS -> HS */ + dte =3D false; + } + } + smode_double_trap =3D dte && sdt; + if (smode_double_trap) { + mode =3D PRV_M; + } + } + if (mode =3D=3D PRV_S) { /* handle the trap in S-mode */ if (riscv_has_ext(env, RVH)) { - uint64_t hdeleg =3D async ? env->hideleg : env->hedeleg; - - if (env->virt_enabled && - (((hdeleg >> cause) & 1) || vs_injected)) { + if (vsmode_exc) { /* Trap to VS mode */ /* * See if we need to adjust cause. Yes if its VS mode inte= rrupt @@ -1876,6 +1903,9 @@ void riscv_cpu_do_interrupt(CPUState *cs) s =3D set_field(s, MSTATUS_SPIE, get_field(s, MSTATUS_SIE)); s =3D set_field(s, MSTATUS_SPP, env->priv); s =3D set_field(s, MSTATUS_SIE, 0); + if (riscv_env_smode_dbltrp_enabled(env, virt)) { + s =3D set_field(s, MSTATUS_SDT, 1); + } env->mstatus =3D s; env->scause =3D cause | ((target_ulong)async << (TARGET_LONG_BITS = - 1)); env->sepc =3D env->pc; @@ -1909,9 +1939,14 @@ void riscv_cpu_do_interrupt(CPUState *cs) s =3D set_field(s, MSTATUS_MIE, 0); env->mstatus =3D s; env->mcause =3D cause | ~(((target_ulong)-1) >> async); + if (smode_double_trap) { + env->mtval2 =3D env->mcause; + env->mcause =3D RISCV_EXCP_DOUBLE_TRAP; + } else { + env->mtval2 =3D mtval2; + } env->mepc =3D env->pc; env->mtval =3D tval; - env->mtval2 =3D mtval2; env->mtinst =3D tinst; =20 if (cpu->cfg.ext_smrnmi && nmi_execp) { --=20 2.45.2 From nobody Sun Nov 24 06:15:55 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1726131041; cv=none; d=zohomail.com; s=zohoarc; b=SWOU3SAQTwoP0xn1ODRuM2MmH30L3isEA4KE2PBUyeDh8XU+9xsRKDWjmuRtXHEbLxp3Xxa2TmqQ92X/utOdzIY2HgWnvee4dLIGoveakpy3HYoeyUi0Gw3yCOUhdiqI2dWwkTk1f+pyhPCo48w9WfMLObYKasB8WLK+98cwy3g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1726131041; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Ij9UQ3ueFFesPCuwkY7Z0yakwufuTyK9/Ck/bkvrpOQ=; b=Lt44lS7CwzmMgnfF/VkvJicS2WdqpAE0OddHxHwfQ/9ABb2ROfW+vWfoXiCB9cRd59SvHMiCyOszcXpAijeAzapi2gjk+/LDmzW7p3eTanN+NwTRrMiX3q514wzCZOViTpr2kuCS5Xs0RNU91SpGI4a7rEZTP74VjO3CxP00CiA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1726131041663628.4868590398852; Thu, 12 Sep 2024 01:50:41 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sofVY-00020I-Lh; Thu, 12 Sep 2024 04:48:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sofVP-0001SW-Nt for qemu-devel@nongnu.org; Thu, 12 Sep 2024 04:48:47 -0400 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sofVN-0000K8-Ly for qemu-devel@nongnu.org; Thu, 12 Sep 2024 04:48:46 -0400 Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-42cc43454d5so5297905e9.3 for ; Thu, 12 Sep 2024 01:48:45 -0700 (PDT) Received: from carbon-x1.. ([2a01:e0a:e17:9700:16d2:7456:6634:9626]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42caeb33a92sm165637475e9.20.2024.09.12.01.48.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Sep 2024 01:48:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1726130924; x=1726735724; darn=nongnu.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=Ij9UQ3ueFFesPCuwkY7Z0yakwufuTyK9/Ck/bkvrpOQ=; b=1fo1GihGUPb38z94sfDvd8GfQnuxpmR1UUZlPrmG6OYtHtMIdyQ8qxPteBVlLM3i48 HkA8Y2R9fI2z+4qsda3wnbVBN1/l5b8Xef72iIEKoBlp9z9JlCmxiCItGhTQUqIAd9+1 mV+tcp8kPOPT7Gv4B7iHcCBtCI/O09VaAYLiS4R7wWt1qF4NEM1dqTOHTFIREoJFy0np FmHTkmG9QbFkwNfa3rGuzVT1Sx3UE2FsjOOkSuKR1bsahgp68HQkqJLTK9RAk8vE3zpS 9mqhNDeRSnxP4Mo+dRS4qB+qXE6SlSwZs5puwp6kMzBD+OXiLbGwcuSZq601cvRdIU0j LN3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726130924; x=1726735724; 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=Ij9UQ3ueFFesPCuwkY7Z0yakwufuTyK9/Ck/bkvrpOQ=; b=Ps3yaQhB1qdVWPqSVzKrdItElMg8/4m1D3/QRu5+5jtVNMjvFk3WCystLSN+Y75IyT KI1zOwuiYL3BecvUsiiMu8CSR6vIk7J0UUp5H8oB6hQfF4sZ4+lBxC2IzUNjCSjbYO+7 5ENTBhz0MHk2XIYmBmfuDSfzLlBBOBenIjMlSIUhcs5WaIZ5osF4zhnXWQ+vkpTl4w/a 94hYd9ozahzkHIgaI8UbGIPpPwSyDBuLJT/3t9JrYPDsLiB9rErx307wjZwpnhP/G/RS wIqF7i35Yv5uxS2VwBjqgh4HGwAmqKg3DZytPjVTukYVdm1MOk59FLlGkzqzlE3fUrro BkqA== X-Forwarded-Encrypted: i=1; AJvYcCUAEInSYxvSzro5oozxj/NfMJJU/+fRUFA95bKf7APHjDTpKArY1Lln9Q4C57guY6P7bQ/dnw6x65Ap@nongnu.org X-Gm-Message-State: AOJu0YxPyO37w7/C1VuVdXU23RuKGA94DN8K/RKgnrl5lwIiRqJkOxFw mrvi1sih2Oi7zzCoFAW1eNpT2UKDMDQ5uwDjtQrUNugSMhUl72PFjlXzXC4nZvg= X-Google-Smtp-Source: AGHT+IGdkbi8fsTe4KKZ+e+XMK6RPQ7XQDobuWyGnRI8uyhu+4PSzz3TOv3heyJrF8LKuaa5+24FUA== X-Received: by 2002:a05:600c:468a:b0:428:1b0d:8657 with SMTP id 5b1f17b1804b1-42cdfac9565mr6359765e9.22.1726130924000; Thu, 12 Sep 2024 01:48:44 -0700 (PDT) From: =?UTF-8?q?Cl=C3=A9ment=20L=C3=A9ger?= To: qemu-riscv@nongnu.org, Palmer Dabbelt , Alistair Francis , Bin Meng Cc: =?UTF-8?q?Cl=C3=A9ment=20L=C3=A9ger?= , Weiwei Li , Daniel Henrique Barboza , Liu Zhiwei , Ved Shanbhogue , Atish Patra , qemu-devel@nongnu.org Subject: [PATCH 05/10] target/riscv: Add Ssdbltrp ISA extension enable switch Date: Thu, 12 Sep 2024 10:48:24 +0200 Message-ID: <20240912084832.2906991-6-cleger@rivosinc.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240912084832.2906991-1-cleger@rivosinc.com> References: <20240912084832.2906991-1-cleger@rivosinc.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::331; envelope-from=cleger@rivosinc.com; helo=mail-wm1-x331.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @rivosinc-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1726131042654116600 Add the switch to enable the Ssdbltrp ISA extension. Signed-off-by: Cl=C3=A9ment L=C3=A9ger --- target/riscv/cpu.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 206736182a..75433a4359 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -190,6 +190,7 @@ const RISCVIsaExtData isa_edata_arr[] =3D { ISA_EXT_DATA_ENTRY(ssccptr, PRIV_VERSION_1_11_0, has_priv_1_11), ISA_EXT_DATA_ENTRY(sscofpmf, PRIV_VERSION_1_12_0, ext_sscofpmf), ISA_EXT_DATA_ENTRY(sscounterenw, PRIV_VERSION_1_12_0, has_priv_1_12), + ISA_EXT_DATA_ENTRY(ssdbltrp, PRIV_VERSION_1_12_0, ext_ssdbltrp), ISA_EXT_DATA_ENTRY(sstc, PRIV_VERSION_1_12_0, ext_sstc), ISA_EXT_DATA_ENTRY(sstvala, PRIV_VERSION_1_12_0, has_priv_1_12), ISA_EXT_DATA_ENTRY(sstvecd, PRIV_VERSION_1_12_0, has_priv_1_12), @@ -1518,6 +1519,7 @@ const RISCVCPUMultiExtConfig riscv_cpu_extensions[] = =3D { MULTI_EXT_CFG_BOOL("smrnmi", ext_smrnmi, false), MULTI_EXT_CFG_BOOL("smstateen", ext_smstateen, false), MULTI_EXT_CFG_BOOL("ssaia", ext_ssaia, false), + MULTI_EXT_CFG_BOOL("ssdbltrp", ext_ssdbltrp, false), MULTI_EXT_CFG_BOOL("svade", ext_svade, false), MULTI_EXT_CFG_BOOL("svadu", ext_svadu, true), MULTI_EXT_CFG_BOOL("svinval", ext_svinval, false), --=20 2.45.2 From nobody Sun Nov 24 06:15:55 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1726131056; cv=none; d=zohomail.com; s=zohoarc; b=D/skbZjx1Zz4cuRht7TsoZO1NsCznSFJHON/MNc9I7HDhU2ep2Q70ZwaDD+1KZhRfvLfvv3E73UI3MJCbJ0LZQnQ4rQBq2WejGgVIPZXLZlLHe2q8TEgwm4HtxTCPeHGdjTTEZsYPKRIuG3adJxP6Klxv8mV/vP3rV8NIW27ZgM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1726131056; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=zC1BgrRV5Dt8HdtJeR4S+Wxt3POJ06XSXjcQ2vYdTCg=; b=WdFnK9HkqyPyZ3Ppo5tboaOea9qkTyzR/v/gVbzp18y4mdYKendM7Iu6bvFP/90Mxyq9EDoyw6HfRiueaJbSXdwJ3WqaEBeGRu2DLXlnACGwKERRHiktcNuauk1KyEl/34JwMXEHPKfz+itwoi1XedZgNxTbQ5jn092DiZg1Oao= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1726131056397258.5905890911778; Thu, 12 Sep 2024 01:50:56 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sofVu-0003dC-UL; Thu, 12 Sep 2024 04:49:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sofVS-0001f9-N7 for qemu-devel@nongnu.org; Thu, 12 Sep 2024 04:48:50 -0400 Received: from mail-wm1-x32d.google.com ([2a00:1450:4864:20::32d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sofVP-0000Kj-FT for qemu-devel@nongnu.org; Thu, 12 Sep 2024 04:48:49 -0400 Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-42cb8dac900so6048545e9.3 for ; Thu, 12 Sep 2024 01:48:46 -0700 (PDT) Received: from carbon-x1.. ([2a01:e0a:e17:9700:16d2:7456:6634:9626]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42caeb33a92sm165637475e9.20.2024.09.12.01.48.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Sep 2024 01:48:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1726130926; x=1726735726; darn=nongnu.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=zC1BgrRV5Dt8HdtJeR4S+Wxt3POJ06XSXjcQ2vYdTCg=; b=O2gnmYjFmNIOe+nhP2lv+ofZnr4KYcnKDOqRw8KgFSDJOODcuLFfUg4R3d4MmMvj9p ZIo1OvN4t5ACRwXbSUnAtL/ovHvqCjvFtITQsVunxk/eOHVB+2rr3ay1CPjV6OjWno3N /z6WttxzqJlVBI40CtyaGYfwK6U9Z4IJ/uHj1uvlpXLRigZ3slgF8e9D22+0iBCGDStE CpPQFzPS8uuAmzNfhs5CLuxvb1EHqeAcL3I7qf82PqLpwHQwm1svbQbgYiz7N4ozulyv ORZ8LpihDv0/yiOegt9bUCKLjwLvKJEwJP0VwxEbXmkphH7Z5421kcaWEf9Q5/w/tA2R TRvw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726130926; x=1726735726; 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=zC1BgrRV5Dt8HdtJeR4S+Wxt3POJ06XSXjcQ2vYdTCg=; b=pNfCFoXD4ibOmYSpLtY8JKaFiuDFBJPX2pEdomOLxOzqm4XCaiEIIBjwaFROh2Tsz1 J5kN+Q8dGuICvnCorVC47ijN6WhRdBKaJWGelw2XALFboEHTIhmdzVJMB8fJiEhpX+Yl ezMUFxb8nPenf5ixE/7WLlFWoTvRhCIlePDdnFgfWsWj1bOErhpkdLi+CdEkF4l+GpK8 nMtmIushux4lvT52e5O2VGrFyBDlisMqquIQ90a978/dA9hP6nQKIqIDWaFwjDqbb02h i3nRSfumu3pFGgaS0BGIQPGFozfDoEzYxAZ6olfS6mkbcoWXV1pVvDNNd5G0/rokYhCm 9vog== X-Forwarded-Encrypted: i=1; AJvYcCVOjcoDyBjOW5tFUdQtr/hkfU0XepSS/E/rxUHIMns8Ut07hfrnxAWhZ4YGYe2ouVM6IIkbq/vTv0L2@nongnu.org X-Gm-Message-State: AOJu0Ywdt12AOf8QF5gRVu+3Qd4wU87ni66+tZhrrzCdWBOqVKaBz1xG e6+zdU3HCYGF9MchQive7EJtDEGX6ObOvJLO2OhYWQOiKGhb7y/FhDO8hFH40IU= X-Google-Smtp-Source: AGHT+IFn6kArx7+XH06GRcDXpDUfkDgPALhqwHSCE0usQjx7DspvXODg6LtSKxXRly6xWfTww5FSEw== X-Received: by 2002:a05:600c:470d:b0:42c:bbd5:af60 with SMTP id 5b1f17b1804b1-42cdb56aed1mr16553285e9.24.1726130925636; Thu, 12 Sep 2024 01:48:45 -0700 (PDT) From: =?UTF-8?q?Cl=C3=A9ment=20L=C3=A9ger?= To: qemu-riscv@nongnu.org, Palmer Dabbelt , Alistair Francis , Bin Meng Cc: =?UTF-8?q?Cl=C3=A9ment=20L=C3=A9ger?= , Weiwei Li , Daniel Henrique Barboza , Liu Zhiwei , Ved Shanbhogue , Atish Patra , qemu-devel@nongnu.org Subject: [PATCH 06/10] target/riscv: Add `ext_smdbltrp` in RISCVCPUConfig. Date: Thu, 12 Sep 2024 10:48:25 +0200 Message-ID: <20240912084832.2906991-7-cleger@rivosinc.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240912084832.2906991-1-cleger@rivosinc.com> References: <20240912084832.2906991-1-cleger@rivosinc.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32d; envelope-from=cleger@rivosinc.com; helo=mail-wm1-x32d.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @rivosinc-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1726131056668116600 This variable is used to determine if the Smdbltrp extension is enabled. Signed-off-by: Cl=C3=A9ment L=C3=A9ger --- target/riscv/cpu_cfg.h | 1 + 1 file changed, 1 insertion(+) diff --git a/target/riscv/cpu_cfg.h b/target/riscv/cpu_cfg.h index dd804f95d4..4c4caa2b39 100644 --- a/target/riscv/cpu_cfg.h +++ b/target/riscv/cpu_cfg.h @@ -78,6 +78,7 @@ struct RISCVCPUConfig { bool ext_sstc; bool ext_smcntrpmf; bool ext_ssdbltrp; + bool ext_smdbltrp; bool ext_svadu; bool ext_svinval; bool ext_svnapot; --=20 2.45.2 From nobody Sun Nov 24 06:15:55 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1726131048; cv=none; d=zohomail.com; s=zohoarc; b=WS/tP51tIPMHHj9WTVok2Kw2ugwNxQt4Imcy0eieHNRlrZEC0FQFGigrcoyDSZi0b9Q1bwkJ2qL/Jl5av28C1lkD7UNBsqasEWQ3nmk91WtWZYA+Yb6d0lVV1icvigFgFF3mkxcI/Ihw/bxz4ZEmtKy7IriucL0jTsCsmoVPpY4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1726131048; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=DbIiKpe94DikCsQx7ZUJ7hfk6G1VSudpYPlKpBAptb0=; b=QABkWH8ETbUhR43TmeDGSA3GhknRbDp72nw2DjYHptCY/PTb4K/cX3L9fVTs+fWPFdFAEP+kgFm49z2qdP310t0V76dtNqx5t3avEM7gXp5rRFrBRjq/n/s+WDNcOsq6VFWXZrBSS1wZ0glRwuxLE/1NzGhdqb12ZVl0O5HPEEM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1726131048307151.53809944646957; Thu, 12 Sep 2024 01:50:48 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sofVy-000417-Nw; Thu, 12 Sep 2024 04:49:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sofVV-0001rL-QK for qemu-devel@nongnu.org; Thu, 12 Sep 2024 04:48:54 -0400 Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sofVR-0000L0-EE for qemu-devel@nongnu.org; Thu, 12 Sep 2024 04:48:51 -0400 Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-42cb5b3c57eso6191635e9.2 for ; Thu, 12 Sep 2024 01:48:48 -0700 (PDT) Received: from carbon-x1.. ([2a01:e0a:e17:9700:16d2:7456:6634:9626]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42caeb33a92sm165637475e9.20.2024.09.12.01.48.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Sep 2024 01:48:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1726130927; x=1726735727; darn=nongnu.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=DbIiKpe94DikCsQx7ZUJ7hfk6G1VSudpYPlKpBAptb0=; b=QGw2KQ1WbuSxjw10jP+Egip5u7PbHQFlvafpc1qv5jarnRNHdoStUS9+o57Sw33fb/ +pwUR13TMEYLBqa0yPYgKoMu+J5A4LoN5ca29kiyEpcghzW2dNRjXKLxm/8/u7Ejbqdy ynvTHxHu5BQnOjUOqCIpiO3okYZklket/9L1nY/QSQUovencnlv5+o2n0sjhEwZzgpDZ ilSopZE2ARRLjeJgCICaATWHYgiuRnA8UIzVUBbkG/UAeKfC80nqT1mW8wJ+pd30vrHu v/yJwwR206Aw5D3ePz9lNG0mWneDFUgmK8ghB+e2UXB/TrSg8lURIw2WKTRJPN9Ihipe ugUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726130927; x=1726735727; 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=DbIiKpe94DikCsQx7ZUJ7hfk6G1VSudpYPlKpBAptb0=; b=kHM0V4I0thqKGd622I6LlBp+nYM3nWnXj46z1pgnwOsqw45IKAdpmzJHiXzHfTF2lA 6vTRADojAmYYNmX7PuYqCxe6dl555RsiIprbQUj/vc0edVnIbrE/937O7Boei6I+ppHG HY5HToZbrIgsbfLV0gMv2/Aae3Iw0qCSZyDq3SmGdGNQSWtGgnkyNeu+1HBI4izk98JR wtV6DoePUCvJ/TEexPCBhe5dPIL24dzN4uUT32mCyZmee94AzToemQJFj3D80LEBFGr+ fQVTSr7e2K97XM/Uh3brSdhCSb5MbpxqBjwzxs8OfFkOKk9EwZNgPD1+OkY5R7riIf5N Q8Ew== X-Forwarded-Encrypted: i=1; AJvYcCVJiPWBzz9pjf0685e1uMKFdHffRSbD89pzLIsAFSLd4Me2+itTv9bTlX3cEgDIWEx23NGbzO73tPg0@nongnu.org X-Gm-Message-State: AOJu0YwFSK7hKIP8WHl1V0AlHmMhjgACnVDatsuIrePiXjPCIMOi5xdc VnPuunwXDD+/EmWVBIQWR0qR3v7jdCTi9DeE+N22GIv0IUqFcWbx3o0xZJpDSJ0= X-Google-Smtp-Source: AGHT+IFWUjZI26GbDL//PYrrQU7Cb3DYVR0quXUykaBWdI9CJCnnvLaBJ+YPjR1xSFa28kyUaTNk0g== X-Received: by 2002:a05:600c:3b17:b0:42c:ba83:3f0e with SMTP id 5b1f17b1804b1-42cdb538c44mr16565485e9.7.1726130926723; Thu, 12 Sep 2024 01:48:46 -0700 (PDT) From: =?UTF-8?q?Cl=C3=A9ment=20L=C3=A9ger?= To: qemu-riscv@nongnu.org, Palmer Dabbelt , Alistair Francis , Bin Meng Cc: =?UTF-8?q?Cl=C3=A9ment=20L=C3=A9ger?= , Weiwei Li , Daniel Henrique Barboza , Liu Zhiwei , Ved Shanbhogue , Atish Patra , qemu-devel@nongnu.org Subject: [PATCH 07/10] target/riscv: Add Smdbltrp CSRs handling Date: Thu, 12 Sep 2024 10:48:26 +0200 Message-ID: <20240912084832.2906991-8-cleger@rivosinc.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240912084832.2906991-1-cleger@rivosinc.com> References: <20240912084832.2906991-1-cleger@rivosinc.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32a; envelope-from=cleger@rivosinc.com; helo=mail-wm1-x32a.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @rivosinc-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1726131048694116600 Implement MSTATUS.MDT behavior. Signed-off-by: Cl=C3=A9ment L=C3=A9ger --- target/riscv/cpu_bits.h | 1 + target/riscv/csr.c | 15 +++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/target/riscv/cpu_bits.h b/target/riscv/cpu_bits.h index 5557a86348..62bab1bf55 100644 --- a/target/riscv/cpu_bits.h +++ b/target/riscv/cpu_bits.h @@ -561,6 +561,7 @@ #define MSTATUS_SDT 0x01000000 #define MSTATUS_GVA 0x4000000000ULL #define MSTATUS_MPV 0x8000000000ULL +#define MSTATUS_MDT 0x40000000000ULL /* Smdbltrp extension */ =20 #define MSTATUS64_UXL 0x0000000300000000ULL #define MSTATUS64_SXL 0x0000000C00000000ULL diff --git a/target/riscv/csr.c b/target/riscv/csr.c index d8280ec956..cc1940447a 100644 --- a/target/riscv/csr.c +++ b/target/riscv/csr.c @@ -1617,6 +1617,14 @@ static RISCVException write_mstatus(CPURISCVState *e= nv, int csrno, } } =20 + if (riscv_cpu_cfg(env)->ext_smdbltrp) { + mask |=3D MSTATUS_MDT; + if ((val & MSTATUS_MDT) !=3D 0) { + mstatus &=3D ~MSTATUS_MIE; + val &=3D ~MSTATUS_MIE; + } + } + if (xl !=3D MXL_RV32 || env->debugger) { if (riscv_has_ext(env, RVH)) { mask |=3D MSTATUS_MPV | MSTATUS_GVA; @@ -1655,6 +1663,13 @@ static RISCVException write_mstatush(CPURISCVState *= env, int csrno, uint64_t valh =3D (uint64_t)val << 32; uint64_t mask =3D riscv_has_ext(env, RVH) ? MSTATUS_MPV | MSTATUS_GVA = : 0; =20 + if (riscv_cpu_cfg(env)->ext_smdbltrp) { + mask |=3D MSTATUS_MDT; + if ((val & MSTATUS_MDT) !=3D 0) { + env->mstatus &=3D ~MSTATUS_MIE; + val &=3D ~MSTATUS_MIE; + } + } env->mstatus =3D (env->mstatus & ~mask) | (valh & mask); =20 return RISCV_EXCP_NONE; --=20 2.45.2 From nobody Sun Nov 24 06:15:55 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1726131046; cv=none; d=zohomail.com; s=zohoarc; b=YBYGSpjq0sOl7ORAY1JZjy/1uoYxUeCWaJhID9D387g3ml4kVvZQehNixGPBCyqSD9vTnBhS1Wp/kPZSiHi2EAkSZE4edVWWfFJZ5zs7nXHQynu66jZHAKTCAK0xnEOat+F5G5FCGRYfXNG49Oa2r7EveEv/4pClKUmEVEsQMzE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1726131046; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=iLp4r6f6llKlFkIQR3exhrK8GnjMUvUuiR9NnPTHniw=; b=G9SVf6cz5XcLObSLu8AkKKSgvyQ1AEpX461krsFhypvan4374gQCubdJ+7Jkul2xeT9mzrYjorx1iAIZSaDwc2RymffaHMW3rl9z5O2xQ4c8vEfB9S/oncmOdGijSWr4PMEKkXFOmcIyaBT7poOqoAb2x4j+bj5kF4BrJuNKG+g= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1726131046441259.88990573384706; Thu, 12 Sep 2024 01:50:46 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sofVt-0003Sp-KH; Thu, 12 Sep 2024 04:49:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sofVV-0001rs-UM for qemu-devel@nongnu.org; Thu, 12 Sep 2024 04:48:54 -0400 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sofVS-0000LQ-FB for qemu-devel@nongnu.org; Thu, 12 Sep 2024 04:48:52 -0400 Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-42cbb08a1a5so6231975e9.3 for ; Thu, 12 Sep 2024 01:48:49 -0700 (PDT) Received: from carbon-x1.. ([2a01:e0a:e17:9700:16d2:7456:6634:9626]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42caeb33a92sm165637475e9.20.2024.09.12.01.48.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Sep 2024 01:48:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1726130928; x=1726735728; darn=nongnu.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=iLp4r6f6llKlFkIQR3exhrK8GnjMUvUuiR9NnPTHniw=; b=AYS1Pddq9/vBZAXbWjW5SMDBExYN5+scNE7h4yRmCOGPZ6X3QdiWfUPvCH7I/ULzB5 9WCTPGwXL5KMxP42WyKaX6HK0Lpl6nKRp/dz9fSwxkqzZzMRn85p97Ew/6f7yvxC1M3Q gUrnVuPHHNdqvY3T/z7MwFYcn2zjDxrUA1IBpBW1le01dOHjv6hqeYMotxy9ZhgGTqEa D+G6elOXJVOgmPd29SxMkpXLeXPUy6CEi/2sHTjqAnkMxVEX+V3bH6AEf/AL41h3nRCB BJBs4NcI/PLGzis0UEsw1BJAFesneYG74/da2CtWcJIqL+mi/K8UmzWCsoYnaUC+ysHz Cpeg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726130928; x=1726735728; 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=iLp4r6f6llKlFkIQR3exhrK8GnjMUvUuiR9NnPTHniw=; b=gBxxD87czxWj7nfgrFAlxL7xo5KsuXp+9B1eVHF6m9TqKwwaJJuKF1imTmQyplAyIo Og4IzRfk2Iu0WuCd/A78Vz2XtQpUEKxWL7yfFKHDI32q/D6i2pl1BeYfRs3kslPiTKMS m6GnH3F7uq5KizhoxJzzuLjL+2TWB4e45lyZY7qHIVplpZr+aiJ4Oo3U9JDEiDfbCpVA UdbX9CUuJX+BW1YG36CPb4k3yjBePg066GP3f53pC6SYV3HK66g4d+i7c2HRyCjgGXwV VT/1qjkESyYtB52ZYqJFDo3/vfudoFx8Ck1bRLEnQbk6yso2uLrYivCltm6knBlJB37o w1Tw== X-Forwarded-Encrypted: i=1; AJvYcCU3O/tda52E+bjcsZfC48uuiN3Uj9VVFMc4SEOlbu2eTp0+i7/nqx2xCb9A8fWyvYGc1RnPKcnWlcJa@nongnu.org X-Gm-Message-State: AOJu0YxSLqC7uTEr8SnqCH0ECUBiOQsU2F7StkpW/LmI/hlX1l+dXlJx VcPSrlqEW5GYCik8D/BtS7sXFtekiCP+g6aju4MwYgGG47QdHH3xqc0CjvxjdIs= X-Google-Smtp-Source: AGHT+IHBquSqPnlqqdkiF+kFXUuJDuWraYNQdq7vAriOAfcRap6bRouIlU1J2MGdiYd9ta24uFNpiQ== X-Received: by 2002:a05:600c:5251:b0:42c:b995:20d9 with SMTP id 5b1f17b1804b1-42cdb56dc28mr15917775e9.28.1726130927996; Thu, 12 Sep 2024 01:48:47 -0700 (PDT) From: =?UTF-8?q?Cl=C3=A9ment=20L=C3=A9ger?= To: qemu-riscv@nongnu.org, Palmer Dabbelt , Alistair Francis , Bin Meng Cc: =?UTF-8?q?Cl=C3=A9ment=20L=C3=A9ger?= , Weiwei Li , Daniel Henrique Barboza , Liu Zhiwei , Ved Shanbhogue , Atish Patra , qemu-devel@nongnu.org Subject: [PATCH 08/10] target/riscv: Implement Smdbltrp sret, mret and mnret behavior Date: Thu, 12 Sep 2024 10:48:27 +0200 Message-ID: <20240912084832.2906991-9-cleger@rivosinc.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240912084832.2906991-1-cleger@rivosinc.com> References: <20240912084832.2906991-1-cleger@rivosinc.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::329; envelope-from=cleger@rivosinc.com; helo=mail-wm1-x329.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @rivosinc-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1726131046657116600 When the Ssdbltrp extension is enabled, SSTATUS.MDT field is cleared when executing sret if executed in M-mode. When executing mret/mnret, SSTATUS.MDT is cleared. Signed-off-by: Cl=C3=A9ment L=C3=A9ger --- target/riscv/op_helper.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/target/riscv/op_helper.c b/target/riscv/op_helper.c index 00b6f75102..9d0911f697 100644 --- a/target/riscv/op_helper.c +++ b/target/riscv/op_helper.c @@ -299,6 +299,9 @@ target_ulong helper_sret(CPURISCVState *env) } mstatus =3D set_field(mstatus, MSTATUS_SDT, 0); } + if (riscv_cpu_cfg(env)->ext_smdbltrp && env->priv >=3D PRV_M) { + mstatus =3D set_field(mstatus, MSTATUS_MDT, 0); + } if (env->priv_ver >=3D PRIV_VERSION_1_12_0) { mstatus =3D set_field(mstatus, MSTATUS_MPRV, 0); } @@ -375,6 +378,9 @@ target_ulong helper_mret(CPURISCVState *env) if (riscv_cpu_cfg(env)->ext_ssdbltrp) { mstatus =3D ssdbltrp_mxret(env, mstatus, prev_priv, prev_virt); } + if (riscv_cpu_cfg(env)->ext_smdbltrp) { + mstatus =3D set_field(mstatus, MSTATUS_MDT, 0); + } if ((env->priv_ver >=3D PRIV_VERSION_1_12_0) && (prev_priv !=3D PRV_M)= ) { mstatus =3D set_field(mstatus, MSTATUS_MPRV, 0); } @@ -416,6 +422,12 @@ target_ulong helper_mnret(CPURISCVState *env) env->mstatus =3D ssdbltrp_mxret(env, env->mstatus, prev_priv, prev= _virt); } =20 + if (riscv_cpu_cfg(env)->ext_smdbltrp) { + if (prev_priv < PRV_M) { + env->mstatus =3D set_field(env->mstatus, MSTATUS_MDT, false); + } + } + if (riscv_has_ext(env, RVH) && prev_virt) { riscv_cpu_swap_hypervisor_regs(env); } --=20 2.45.2 From nobody Sun Nov 24 06:15:55 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1726131040; cv=none; d=zohomail.com; s=zohoarc; b=HePtrsPzVFoSMaD2bU/OHN75nX2xyDat1HCIjNUvJCs9JywuOlUnKxK6Lp+B0E8GRutJe4jgMKfwrKR0iLgXtqPUI2rk54K+OXeZ/KFlCVX5f9jsG0t2v7uBZSA5y1t1kYQMi/WropGILJvyv14Gw9ciSMcB7EFdWeCqARMYJeE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1726131040; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=o961jt+tkXgagOiy0R3at1ff5f3NvYQ/iAvwybcevIw=; b=J4u81Bsmi/9LMnq3nA1fdOzXu4GEo9/DmOEXoBBrKj/Qg1KxrFZQK4KwMaMS0F1hXKtjKUl39Q0j0obR3WidQoylvMxh4n9GLKO18wAR1wCxHZp1Msxb4DDYNbNBcabe25TA1qz+aQZIRX5T5ndYhhMzzFC/VTjNAFV4obVm+rs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1726131040984589.8441875454503; Thu, 12 Sep 2024 01:50:40 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sofVx-0003rE-BH; Thu, 12 Sep 2024 04:49:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sofVV-0001ri-Te for qemu-devel@nongnu.org; Thu, 12 Sep 2024 04:48:54 -0400 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sofVT-0000Li-BA for qemu-devel@nongnu.org; Thu, 12 Sep 2024 04:48:52 -0400 Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-42cb0f28bfbso5698315e9.1 for ; Thu, 12 Sep 2024 01:48:50 -0700 (PDT) Received: from carbon-x1.. ([2a01:e0a:e17:9700:16d2:7456:6634:9626]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42caeb33a92sm165637475e9.20.2024.09.12.01.48.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Sep 2024 01:48:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1726130930; x=1726735730; darn=nongnu.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=o961jt+tkXgagOiy0R3at1ff5f3NvYQ/iAvwybcevIw=; b=iJu+dML3PfePROlE8LYIf0nlgazZDLK4VNBGSESzXrnhL738QbdN5fi3QJW8T0yP3h vAYNg8GUg5Dy38B689GKC//4WWjZ4Kl1ZqXvcf/Frd1o9CXhxkwYdFSHik1ltODhF64C mWB3cnZK2iPICLM0grkDEc2qGXB5r+HAsVvSGtWJNhVDHFnSm5/3bLuE3CrhcZfLc3uj LF1s33aqlYhIK9BvMoUlPoyr41TPOPCdZ75eqja0AT5xrJWpwp6UbB8icouK/tGLTHFA oyhFgDTlymH2aNFtPObiDEEMubfjPqwNxpADJka0WwR6VRpFjFfU0DjnSwjwBop5OmmS 3kWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726130930; x=1726735730; 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=o961jt+tkXgagOiy0R3at1ff5f3NvYQ/iAvwybcevIw=; b=hAJv9/G9vb11PYNTvjbqyRLehwlN5I6tVeGKNn42ujJ9AYROJJwbLSGvRgPwjdNt// 56mA0B/CaNCuqn56UaWo6kDdUShvo0989cUwDjTUmv7zbKCjTNqhjc19/WaRBOYLriSv EdQhv+CCRRLedcypvsOLVQNAyTy855YDiJfUM9xHeyWr1gKLxJJ82Z+A0ReLzVOeBRfr FSj23P0aZ2/44KAeETLWFW9sO1GRrgSgMmUFQPOcblAh91qeo4xMHizvPxjg6+SXe4YW T/QGAqfHF3wMveQ6MZWWh3+6P0UtGjNdhcCa9NhiP0Xoko6rH51Fi18cxlMmJxJQvjsd pPVA== X-Forwarded-Encrypted: i=1; AJvYcCXBg+jqcEhIqkvUy/87XXfPBkw1IO+gUrcKTuPvxDl5FG5xoPnh6EPfOPhvOFId+Yd7mGQkXIRCF+4e@nongnu.org X-Gm-Message-State: AOJu0YzDz1bR4Apy2znZ5iqtb6+sQB6CAABGTTEZSx9kkq95iau53bRd 8PsgjZtXqCkGe3G6Dcfl9gKJjS9NBwScTShDyzpre49v7Ux8J2prGUjH6OGPLJw= X-Google-Smtp-Source: AGHT+IHphUWslHtupEwaJa9vFQCTAWPR4kYx9tku6ze9fkRoV8XzIBH1y3NBc0r4uAOX9bl7a4sVQA== X-Received: by 2002:a05:600c:4f4f:b0:428:1965:450d with SMTP id 5b1f17b1804b1-42cdb53bd22mr17219945e9.17.1726130929741; Thu, 12 Sep 2024 01:48:49 -0700 (PDT) From: =?UTF-8?q?Cl=C3=A9ment=20L=C3=A9ger?= To: qemu-riscv@nongnu.org, Palmer Dabbelt , Alistair Francis , Bin Meng Cc: =?UTF-8?q?Cl=C3=A9ment=20L=C3=A9ger?= , Weiwei Li , Daniel Henrique Barboza , Liu Zhiwei , Ved Shanbhogue , Atish Patra , qemu-devel@nongnu.org Subject: [PATCH 09/10] target/riscv: Implement Smdbltrp behavior Date: Thu, 12 Sep 2024 10:48:28 +0200 Message-ID: <20240912084832.2906991-10-cleger@rivosinc.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240912084832.2906991-1-cleger@rivosinc.com> References: <20240912084832.2906991-1-cleger@rivosinc.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32f; envelope-from=cleger@rivosinc.com; helo=mail-wm1-x32f.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @rivosinc-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1726131042665116600 When the Smsdbltrp ISA extension is enabled, MSTATUS.MDT bit is enabled at reset and set upon trap. If a trap happens while MSTATUS.MDT is already set, it will trigger an abort or an NMI is the Smrnmi extension is available. Signed-off-by: Cl=C3=A9ment L=C3=A9ger --- target/riscv/cpu.c | 3 +++ target/riscv/cpu_helper.c | 35 ++++++++++++++++++++++++++--------- 2 files changed, 29 insertions(+), 9 deletions(-) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 75433a4359..f9b2ce4463 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -967,6 +967,9 @@ static void riscv_cpu_reset_hold(Object *obj, ResetType= type) env->mstatus_hs =3D set_field(env->mstatus_hs, MSTATUS64_UXL, env->misa_mxl); } + if (riscv_cpu_cfg(env)->ext_smdbltrp) { + env->mstatus =3D set_field(env->mstatus, MSTATUS_MDT, 1); + } } env->mcause =3D 0; env->miclaim =3D MIP_SGEIP; diff --git a/target/riscv/cpu_helper.c b/target/riscv/cpu_helper.c index 69da3c3384..5a30d1b8a8 100644 --- a/target/riscv/cpu_helper.c +++ b/target/riscv/cpu_helper.c @@ -1697,6 +1697,17 @@ static target_ulong riscv_transformed_insn(CPURISCVS= tate *env, return xinsn; } =20 +static void riscv_do_nmi(CPURISCVState *env, target_ulong cause, bool virt) +{ + env->mnstatus =3D set_field(env->mnstatus, MNSTATUS_NMIE, false); + env->mnstatus =3D set_field(env->mnstatus, MNSTATUS_MNPV, virt); + env->mnstatus =3D set_field(env->mnstatus, MNSTATUS_MNPP, env->priv); + env->mncause =3D cause; + env->mnepc =3D env->pc; + env->pc =3D env->rnmi_irqvec; + riscv_cpu_set_mode(env, PRV_M, virt); +} + /* * Handle Traps * @@ -1733,15 +1744,8 @@ void riscv_cpu_do_interrupt(CPUState *cs) bool nmi_execp =3D false; =20 if (cpu->cfg.ext_smrnmi && env->rnmip && async) { - env->mnstatus =3D set_field(env->mnstatus, MNSTATUS_NMIE, false); - env->mnstatus =3D set_field(env->mnstatus, MNSTATUS_MNPV, - env->virt_enabled); - env->mnstatus =3D set_field(env->mnstatus, MNSTATUS_MNPP, - env->priv); - env->mncause =3D cause | ((target_ulong)1U << (TARGET_LONG_BITS - = 1)); - env->mnepc =3D env->pc; - env->pc =3D env->rnmi_irqvec; - riscv_cpu_set_mode(env, PRV_M, virt); + riscv_do_nmi(env, cause | ((target_ulong)1U << (TARGET_LONG_BITS -= 1)), + virt); return; } =20 @@ -1937,6 +1941,19 @@ void riscv_cpu_do_interrupt(CPUState *cs) s =3D set_field(s, MSTATUS_MPIE, get_field(s, MSTATUS_MIE)); s =3D set_field(s, MSTATUS_MPP, env->priv); s =3D set_field(s, MSTATUS_MIE, 0); + if (cpu->cfg.ext_smdbltrp) { + if (env->mstatus & MSTATUS_MDT) { + assert(env->priv =3D=3D PRV_M); + if (!cpu->cfg.ext_smrnmi || nmi_execp) { + cpu_abort(CPU(cpu), "M-mode double trap\n"); + } else { + riscv_do_nmi(env, cause, false); + return; + } + } + + s =3D set_field(s, MSTATUS_MDT, 1); + } env->mstatus =3D s; env->mcause =3D cause | ~(((target_ulong)-1) >> async); if (smode_double_trap) { --=20 2.45.2 From nobody Sun Nov 24 06:15:55 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1726130987; cv=none; d=zohomail.com; s=zohoarc; b=h5JXoEQMtpT+wvqv2QqqRr92oiw6oxIoEdIbLw1Jru6zKhRjaLwqsagcFwJGTUHM1JV0sEY50YEio5392E/bbqW3hvCVXxHGjtIiyigd/Bvh/jbN9iXlDWvdiM384qMadmkcTmufKRZWRaD9e2J81+j1uSDjdMG7AkkfL5oAXaI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1726130987; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=eLUH+r45114WMEvaAcjXsA6R1Njb1Sm2E3aFCFu9vyg=; b=hRa9z+eRzJ3ae5yFtjDWpws9OQxYF2rlB2T+fdRCcXjHgbRaf72tGB/mv1mNUAC3C0ftQpJ0GdmhT1WjBuCl+M28Dt35sUSxWEMiq1zf868Aof/g0Ou5cqkDW9RoNnAt41yBJW7BlzvmHKSAB02gxsmdYkcjllN4DaO//g659y8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1726130987403366.36352964117293; Thu, 12 Sep 2024 01:49:47 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sofWH-00058i-GQ; Thu, 12 Sep 2024 04:49:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sofVY-00022E-Eq for qemu-devel@nongnu.org; Thu, 12 Sep 2024 04:48:56 -0400 Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sofVV-0000M5-LP for qemu-devel@nongnu.org; Thu, 12 Sep 2024 04:48:56 -0400 Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-42cba6cdf32so5566805e9.1 for ; Thu, 12 Sep 2024 01:48:52 -0700 (PDT) Received: from carbon-x1.. ([2a01:e0a:e17:9700:16d2:7456:6634:9626]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42caeb33a92sm165637475e9.20.2024.09.12.01.48.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Sep 2024 01:48:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1726130931; x=1726735731; darn=nongnu.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=eLUH+r45114WMEvaAcjXsA6R1Njb1Sm2E3aFCFu9vyg=; b=ElV/01zMqUYpy39PL62iNPFmHUlxOFrGdwFFm84sT2lJp6+nXlBI+PBo7ykLlVAvwW nJEtAiAjMd7ndB9mjm9y6oI0MiHQIkuHf9j2ZoTPWxy6WLYE6USTlcvtLQlxSQ6orOgY UxvMmNl74a7WM+jEEW5/wdZv0swDGW1oakMrmfiWftjz9NZsWAs/QBf3UDGSZ7vWx2dB +A7JawwT4rC58+tAIvkvnkDu2SHCR3P3aJsuSaaaTKZHdM7BERJqcNOWkTBJfXel/xPZ HYmAjTFPOW7dfF2C75L+fAR8I2JTmdbC6TJADErs0cV0GZvvUWXTGcJtx5ZdL5OhlJin aQNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726130931; x=1726735731; 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=eLUH+r45114WMEvaAcjXsA6R1Njb1Sm2E3aFCFu9vyg=; b=YF8+RY0KxN85A5WzIH3YfQ6B/t79P6glLHEMnyjJFUCU9Bbl/wrKD6HcF95FCzgmet 7+FGLivT6xtW+NvNI5Uryx5ihpNk2RNxeIhEogZ7iXUKNgF85pMwVWhlp5u0wrv1xrXt VwyvHMiHsZHfTvgzNsQrRZv0XMlk7bIOX69XM2Z8nU/QLsU0ucOygJijR6Pu8ISwWC/5 Z3PKAIoWod7E5/oUgUikcQ9qtCd0zCKEHuYoLchL8NFU/fiW4YGBWCHwpQshcGN8P/dW M62HQwbjdtNTWt7Q4vX+VqjgM/xNcj17tvD/XQ9giuFxOjLLUrt/Ck3oEFSR6crM3m6u SWow== X-Forwarded-Encrypted: i=1; AJvYcCXxbbOC6aHLBUANXjD80NR2R03RoH1P5I7mhcpWfpMVLt7mgrwD04R85ViwE4svjDkTZCdhO+0R1N3b@nongnu.org X-Gm-Message-State: AOJu0YxldbmpJulP9WnOZtQKF9/Ugbx0XlyHQB4oOUOp6M5SOB/JI73+ fNab3kwogLE7QpzkJY3H2D+EWTlujj3gLt/3CDFymJcsDazAuyT55vr6AcTsEA0= X-Google-Smtp-Source: AGHT+IH1v+QbjLzkKBxfLPQ5n+gRUk1EJoFu/eydGhVZmoWOMghTMZsCRWGtrJSrkIZ1uZ1gAdGaCw== X-Received: by 2002:a05:600c:1d23:b0:428:eb6:2e73 with SMTP id 5b1f17b1804b1-42cdb58db62mr16088985e9.29.1726130931030; Thu, 12 Sep 2024 01:48:51 -0700 (PDT) From: =?UTF-8?q?Cl=C3=A9ment=20L=C3=A9ger?= To: qemu-riscv@nongnu.org, Palmer Dabbelt , Alistair Francis , Bin Meng Cc: =?UTF-8?q?Cl=C3=A9ment=20L=C3=A9ger?= , Weiwei Li , Daniel Henrique Barboza , Liu Zhiwei , Ved Shanbhogue , Atish Patra , qemu-devel@nongnu.org Subject: [PATCH 10/10] target/riscv: Add Smdbltrp ISA extension enable switch Date: Thu, 12 Sep 2024 10:48:29 +0200 Message-ID: <20240912084832.2906991-11-cleger@rivosinc.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240912084832.2906991-1-cleger@rivosinc.com> References: <20240912084832.2906991-1-cleger@rivosinc.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::336; envelope-from=cleger@rivosinc.com; helo=mail-wm1-x336.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @rivosinc-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1726130988591116600 Add the switch to enable the Smdbltrp ISA extension. Signed-off-by: Cl=C3=A9ment L=C3=A9ger --- target/riscv/cpu.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index f9b2ce4463..3a3009bd23 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -183,6 +183,7 @@ const RISCVIsaExtData isa_edata_arr[] =3D { ISA_EXT_DATA_ENTRY(zhinxmin, PRIV_VERSION_1_12_0, ext_zhinxmin), ISA_EXT_DATA_ENTRY(smaia, PRIV_VERSION_1_12_0, ext_smaia), ISA_EXT_DATA_ENTRY(smcntrpmf, PRIV_VERSION_1_12_0, ext_smcntrpmf), + ISA_EXT_DATA_ENTRY(smdbltrp, PRIV_VERSION_1_12_0, ext_smdbltrp), ISA_EXT_DATA_ENTRY(smepmp, PRIV_VERSION_1_12_0, ext_smepmp), ISA_EXT_DATA_ENTRY(smrnmi, PRIV_VERSION_1_12_0, ext_smrnmi), ISA_EXT_DATA_ENTRY(smstateen, PRIV_VERSION_1_12_0, ext_smstateen), @@ -1518,6 +1519,7 @@ const RISCVCPUMultiExtConfig riscv_cpu_extensions[] = =3D { MULTI_EXT_CFG_BOOL("sstc", ext_sstc, true), =20 MULTI_EXT_CFG_BOOL("smaia", ext_smaia, false), + MULTI_EXT_CFG_BOOL("smdbltrp", ext_smdbltrp, false), MULTI_EXT_CFG_BOOL("smepmp", ext_smepmp, false), MULTI_EXT_CFG_BOOL("smrnmi", ext_smrnmi, false), MULTI_EXT_CFG_BOOL("smstateen", ext_smstateen, false), --=20 2.45.2