From nobody Sat Nov 23 15:25:05 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; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1715422350; cv=none; d=zohomail.com; s=zohoarc; b=X/z/G8c0C/gbM8zeXcJ9+buY2czCrlpkD87TyaGt6y56D7XnWKuMcgnNhs5CD1jUGXaYQ1H9shd4O8rkNiVWLcWyQhM8UHl0ELzAyNyz4hNblTnjFUaCXxgfIWWnDv4MN/0qHHAXUi6HBBKc2fV/qJf0KmbOJ30GNJzJi1lsNEY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1715422350; h=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:Message-Id:Reply-To:To; bh=13IqUkrTdnG3QfUVHYTAXzXsHnIMfV9aXHxifSAJZyw=; b=PZ3ynBpOeVTt1IUaGSKeyPT+9V0eTIvz+/LUi5XBsVMq6g2DuAn0HECBN27+PuL7l8L/zTCYPf2XnjVU1hfi4Ssv0cNNpVxC7KWE1kc3UE21bOTg4lPZS/qurjbuJORP40t9PJSm4vlHzFl3Bjvk0tNtEBV51X3G4B/pVQICOpU= 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 171542235093689.78429857256879; Sat, 11 May 2024 03:12:30 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s5jhE-0005Ru-II; Sat, 11 May 2024 06:11: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 1s5jhB-0005Qw-9h; Sat, 11 May 2024 06:11:13 -0400 Received: from mail-ej1-x635.google.com ([2a00:1450:4864:20::635]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s5jh4-00029g-NP; Sat, 11 May 2024 06:11:12 -0400 Received: by mail-ej1-x635.google.com with SMTP id a640c23a62f3a-a59a609dd3fso493496566b.0; Sat, 11 May 2024 03:11:05 -0700 (PDT) Received: from freya.midgard (broadband-188-255-126-251.ip.moscow.rt.ru. [188.255.126.251]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a5a1781d27bsm301687166b.21.2024.05.11.03.11.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 11 May 2024 03:11:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1715422265; x=1716027065; 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=13IqUkrTdnG3QfUVHYTAXzXsHnIMfV9aXHxifSAJZyw=; b=krBHqpGix2bOkeFKOom48p3QM8no2W9PLBCav7mF+LfBxHJys9ci0fMcyI83bHzla+ qWQtVu2+KEJxLpGFKsn/JwohLwBa2MAeLIyOLsrHDPS1IBFuS9h8rD9ifqvXOCvhh17F L0ZEVL6e8EYCQDYd0wRPOkHgR6fpzIgsHanjRBXLsHVJs15H3530p7UQ7lWjMDUvaiFP Phmj3H0M9u8zyDrGH3wOZhGZykEh3jEvtYsyCBQGv/O9lRiAk+I/4Iog/R3zSAjs1fpC 7svBexUtMtrPdGPqmTtqgIqPATKQWBuYFDfkXS3Tie0mCzTJ6+Kr8g9I1IJ9A63mxlZE 9LUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715422265; x=1716027065; 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=13IqUkrTdnG3QfUVHYTAXzXsHnIMfV9aXHxifSAJZyw=; b=ktoBn37WdS5cltnMzV9INo31B0EuI5TxB5LULBYSIPzZxdFeUpotjG9XJnT5kwlERR RGeFDNSnDaC3++tdzLoAuXb8jmnErGXQ6QHXHo65m27WNr2MazN47uwGU5zmYuMIKCWh sLau4PucKZDAuSyglHT5Y7m3FSm0xGWe5ENCcxxtG8wXnu+sBMJLyHRzckPhcD4iG9UG j4A8bTMsUs7d8m5lZjxdMyEPvMhdkHGyVdoUoeqJKxmoK7PNwFzYk7tfqmhQ8JfAmEI/ OEmnVpWoAXWcVblJVZ0luHrc2rBc8L0Cv69Zr//RzadHE4S6na3FcB5rf1NshccCGKeI KZ0w== X-Forwarded-Encrypted: i=1; AJvYcCXQrcSdXqG4yTxUxmSc1bSEFMBpnyU8B3zStnEi61j0v1lijkt+MlUIXq5EJ6Z+5kouOmuTTCW5Ak8jFuu4uv19xpmeBkAqw/0fr+g8HDgSXpMuyEKegTGky0VWGQ== X-Gm-Message-State: AOJu0YyKesHpcR8DKIQIQi3DQzqP7sVhfg3vQI4c/RAw/9o6BbjdPLvi smREXgZMPR0EBsb981UO0sf5kwzJiBRc/cgDbkYV44XsI1hBwC2R X-Google-Smtp-Source: AGHT+IH90KeoP53DKUyoTyXOGtaMNvaFFeIx/Xsy5gkk8MDNQGKDdPZP2GAc6U7/zse63BwHcYgiMQ== X-Received: by 2002:a17:906:b7c4:b0:a59:bb24:a61 with SMTP id a640c23a62f3a-a5a2d292a23mr421152366b.30.1715422264665; Sat, 11 May 2024 03:11:04 -0700 (PDT) From: Alexey Baturo X-Google-Original-From: Alexey Baturo To: Cc: baturo.alexey@gmail.com, richard.henderson@linaro.org, space.monkey.delivers@gmail.com, palmer@dabbelt.com, Alistair.Francis@wdc.com, sagark@eecs.berkeley.edu, kbastian@mail.uni-paderborn.de, qemu-devel@nongnu.org, qemu-riscv@nongnu.org, Alistair Francis Subject: [PATCH v9 1/6] target/riscv: Remove obsolete pointer masking extension code. Date: Sat, 11 May 2024 13:10:48 +0300 Message-Id: <20240511101053.1875596-2-me@deliversmonkey.space> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240511101053.1875596-1-me@deliversmonkey.space> References: <20240511101053.1875596-1-me@deliversmonkey.space> MIME-Version: 1.0 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::635; envelope-from=baturo.alexey@gmail.com; helo=mail-ej1-x635.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, 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 @gmail.com) X-ZM-MESSAGEID: 1715422352767100010 Content-Type: text/plain; charset="utf-8" From: Alexey Baturo Zjpm v0.8 is almost frozen and it's much simplier compared to the existing = one: The newer version doesn't allow to specify custom mask or base for masking. Instead it allows only certain options for masking top bits. Signed-off-by: Alexey Baturo Acked-by: Alistair Francis --- target/riscv/cpu.c | 13 +- target/riscv/cpu.h | 30 +--- target/riscv/cpu_bits.h | 87 ---------- target/riscv/cpu_helper.c | 52 ------ target/riscv/csr.c | 326 ----------------------------------- target/riscv/machine.c | 14 +- target/riscv/tcg/tcg-cpu.c | 5 +- target/riscv/translate.c | 27 +-- target/riscv/vector_helper.c | 2 +- 9 files changed, 13 insertions(+), 543 deletions(-) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index a74f0eb29c..1e350e9bd8 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -42,7 +42,7 @@ /* RISC-V CPU definitions */ static const char riscv_single_letter_exts[] =3D "IEMAFDQCBPVH"; const uint32_t misa_bits[] =3D {RVI, RVE, RVM, RVA, RVF, RVD, RVV, - RVC, RVS, RVU, RVH, RVJ, RVG, RVB, 0}; + RVC, RVS, RVU, RVH, RVG, RVB, 0}; =20 /* * From vector_helper.c @@ -795,13 +795,6 @@ static void riscv_cpu_dump_state(CPUState *cs, FILE *f= , int flags) CSR_MSCRATCH, CSR_SSCRATCH, CSR_SATP, - CSR_MMTE, - CSR_UPMBASE, - CSR_UPMMASK, - CSR_SPMBASE, - CSR_SPMMASK, - CSR_MPMBASE, - CSR_MPMMASK, }; =20 for (i =3D 0; i < ARRAY_SIZE(dump_csrs); ++i) { @@ -981,8 +974,6 @@ static void riscv_cpu_reset_hold(Object *obj, ResetType= type) } i++; } - /* mmte is supposed to have pm.current hardwired to 1 */ - env->mmte |=3D (EXT_STATUS_INITIAL | MMTE_M_PM_CURRENT); =20 /* * Bits 10, 6, 2 and 12 of mideleg are read only 1 when the Hypervisor @@ -1004,7 +995,6 @@ static void riscv_cpu_reset_hold(Object *obj, ResetTyp= e type) pmp_unlock_entries(env); #endif env->xl =3D riscv_cpu_mxl(env); - riscv_cpu_update_mask(env); cs->exception_index =3D RISCV_EXCP_NONE; env->load_res =3D -1; set_default_nan_mode(1, &env->fp_status); @@ -1395,7 +1385,6 @@ static const MISAExtInfo misa_ext_info_arr[] =3D { MISA_EXT_INFO(RVS, "s", "Supervisor-level instructions"), MISA_EXT_INFO(RVU, "u", "User-level instructions"), MISA_EXT_INFO(RVH, "h", "Hypervisor"), - MISA_EXT_INFO(RVJ, "x-j", "Dynamic translated languages"), MISA_EXT_INFO(RVV, "v", "Vector operations"), MISA_EXT_INFO(RVG, "g", "General purpose (IMAFD_Zicsr_Zifencei)"), MISA_EXT_INFO(RVB, "x-b", "Bit manipulation (Zba_Zbb_Zbs)") diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h index e0dd1828b5..232521bb87 100644 --- a/target/riscv/cpu.h +++ b/target/riscv/cpu.h @@ -66,7 +66,6 @@ typedef struct CPUArchState CPURISCVState; #define RVS RV('S') #define RVU RV('U') #define RVH RV('H') -#define RVJ RV('J') #define RVG RV('G') #define RVB RV('B') =20 @@ -393,17 +392,6 @@ struct CPUArchState { /* True if in debugger mode. */ bool debugger; =20 - /* - * CSRs for PointerMasking extension - */ - target_ulong mmte; - target_ulong mpmmask; - target_ulong mpmbase; - target_ulong spmmask; - target_ulong spmbase; - target_ulong upmmask; - target_ulong upmbase; - /* CSRs for execution environment configuration */ uint64_t menvcfg; uint64_t mstateen[SMSTATEEN_MAX_COUNT]; @@ -412,9 +400,6 @@ struct CPUArchState { target_ulong senvcfg; uint64_t henvcfg; #endif - target_ulong cur_pmmask; - target_ulong cur_pmbase; - /* Fields from here on are preserved across CPU reset. */ QEMUTimer *stimer; /* Internal timer for S-mode interrupt */ QEMUTimer *vstimer; /* Internal timer for VS-mode interrupt */ @@ -563,16 +548,14 @@ FIELD(TB_FLAGS, VSTART_EQ_ZERO, 15, 1) /* The combination of MXL/SXL/UXL that applies to the current cpu mode. */ FIELD(TB_FLAGS, XL, 16, 2) /* If PointerMasking should be applied */ -FIELD(TB_FLAGS, PM_MASK_ENABLED, 18, 1) -FIELD(TB_FLAGS, PM_BASE_ENABLED, 19, 1) -FIELD(TB_FLAGS, VTA, 20, 1) -FIELD(TB_FLAGS, VMA, 21, 1) +FIELD(TB_FLAGS, VTA, 18, 1) +FIELD(TB_FLAGS, VMA, 19, 1) /* Native debug itrigger */ -FIELD(TB_FLAGS, ITRIGGER, 22, 1) +FIELD(TB_FLAGS, ITRIGGER, 20, 1) /* Virtual mode enabled */ -FIELD(TB_FLAGS, VIRT_ENABLED, 23, 1) -FIELD(TB_FLAGS, PRIV, 24, 2) -FIELD(TB_FLAGS, AXL, 26, 2) +FIELD(TB_FLAGS, VIRT_ENABLED, 21, 1) +FIELD(TB_FLAGS, PRIV, 22, 2) +FIELD(TB_FLAGS, AXL, 24, 2) =20 #ifdef TARGET_RISCV32 #define riscv_cpu_mxl(env) ((void)(env), MXL_RV32) @@ -705,7 +688,6 @@ static inline uint32_t vext_get_vlmax(uint32_t vlenb, u= int32_t vsew, void cpu_get_tb_cpu_state(CPURISCVState *env, vaddr *pc, uint64_t *cs_base, uint32_t *pflags); =20 -void riscv_cpu_update_mask(CPURISCVState *env); bool riscv_cpu_is_32bit(RISCVCPU *cpu); =20 RISCVException riscv_csrr(CPURISCVState *env, int csrno, diff --git a/target/riscv/cpu_bits.h b/target/riscv/cpu_bits.h index 74318a925c..da16ba236a 100644 --- a/target/riscv/cpu_bits.h +++ b/target/riscv/cpu_bits.h @@ -484,37 +484,6 @@ #define CSR_MHPMCOUNTER30H 0xb9e #define CSR_MHPMCOUNTER31H 0xb9f =20 -/* - * User PointerMasking registers - * NB: actual CSR numbers might be changed in future - */ -#define CSR_UMTE 0x4c0 -#define CSR_UPMMASK 0x4c1 -#define CSR_UPMBASE 0x4c2 - -/* - * Machine PointerMasking registers - * NB: actual CSR numbers might be changed in future - */ -#define CSR_MMTE 0x3c0 -#define CSR_MPMMASK 0x3c1 -#define CSR_MPMBASE 0x3c2 - -/* - * Supervisor PointerMaster registers - * NB: actual CSR numbers might be changed in future - */ -#define CSR_SMTE 0x1c0 -#define CSR_SPMMASK 0x1c1 -#define CSR_SPMBASE 0x1c2 - -/* - * Hypervisor PointerMaster registers - * NB: actual CSR numbers might be changed in future - */ -#define CSR_VSMTE 0x2c0 -#define CSR_VSPMMASK 0x2c1 -#define CSR_VSPMBASE 0x2c2 #define CSR_SCOUNTOVF 0xda0 =20 /* Crypto Extension */ @@ -734,11 +703,6 @@ typedef enum RISCVException { #define VS_MODE_INTERRUPTS ((uint64_t)(MIP_VSSIP | MIP_VSTIP | MIP_VSEIP)) #define HS_MODE_INTERRUPTS ((uint64_t)(MIP_SGEIP | VS_MODE_INTERRUPTS)) =20 -/* General PointerMasking CSR bits */ -#define PM_ENABLE 0x00000001ULL -#define PM_CURRENT 0x00000002ULL -#define PM_INSN 0x00000004ULL - /* Execution environment configuration bits */ #define MENVCFG_FIOM BIT(0) #define MENVCFG_CBIE (3UL << 4) @@ -771,57 +735,6 @@ typedef enum RISCVException { #define HENVCFGH_PBMTE MENVCFGH_PBMTE #define HENVCFGH_STCE MENVCFGH_STCE =20 -/* Offsets for every pair of control bits per each priv level */ -#define XS_OFFSET 0ULL -#define U_OFFSET 2ULL -#define S_OFFSET 5ULL -#define M_OFFSET 8ULL - -#define PM_XS_BITS (EXT_STATUS_MASK << XS_OFFSET) -#define U_PM_ENABLE (PM_ENABLE << U_OFFSET) -#define U_PM_CURRENT (PM_CURRENT << U_OFFSET) -#define U_PM_INSN (PM_INSN << U_OFFSET) -#define S_PM_ENABLE (PM_ENABLE << S_OFFSET) -#define S_PM_CURRENT (PM_CURRENT << S_OFFSET) -#define S_PM_INSN (PM_INSN << S_OFFSET) -#define M_PM_ENABLE (PM_ENABLE << M_OFFSET) -#define M_PM_CURRENT (PM_CURRENT << M_OFFSET) -#define M_PM_INSN (PM_INSN << M_OFFSET) - -/* mmte CSR bits */ -#define MMTE_PM_XS_BITS PM_XS_BITS -#define MMTE_U_PM_ENABLE U_PM_ENABLE -#define MMTE_U_PM_CURRENT U_PM_CURRENT -#define MMTE_U_PM_INSN U_PM_INSN -#define MMTE_S_PM_ENABLE S_PM_ENABLE -#define MMTE_S_PM_CURRENT S_PM_CURRENT -#define MMTE_S_PM_INSN S_PM_INSN -#define MMTE_M_PM_ENABLE M_PM_ENABLE -#define MMTE_M_PM_CURRENT M_PM_CURRENT -#define MMTE_M_PM_INSN M_PM_INSN -#define MMTE_MASK (MMTE_U_PM_ENABLE | MMTE_U_PM_CURRENT | MMTE_U_PM_INS= N | \ - MMTE_S_PM_ENABLE | MMTE_S_PM_CURRENT | MMTE_S_PM_INS= N | \ - MMTE_M_PM_ENABLE | MMTE_M_PM_CURRENT | MMTE_M_PM_INS= N | \ - MMTE_PM_XS_BITS) - -/* (v)smte CSR bits */ -#define SMTE_PM_XS_BITS PM_XS_BITS -#define SMTE_U_PM_ENABLE U_PM_ENABLE -#define SMTE_U_PM_CURRENT U_PM_CURRENT -#define SMTE_U_PM_INSN U_PM_INSN -#define SMTE_S_PM_ENABLE S_PM_ENABLE -#define SMTE_S_PM_CURRENT S_PM_CURRENT -#define SMTE_S_PM_INSN S_PM_INSN -#define SMTE_MASK (SMTE_U_PM_ENABLE | SMTE_U_PM_CURRENT | SMTE_U_PM_INS= N | \ - SMTE_S_PM_ENABLE | SMTE_S_PM_CURRENT | SMTE_S_PM_INS= N | \ - SMTE_PM_XS_BITS) - -/* umte CSR bits */ -#define UMTE_U_PM_ENABLE U_PM_ENABLE -#define UMTE_U_PM_CURRENT U_PM_CURRENT -#define UMTE_U_PM_INSN U_PM_INSN -#define UMTE_MASK (UMTE_U_PM_ENABLE | MMTE_U_PM_CURRENT | UMTE_U_PM_IN= SN) - /* MISELECT, SISELECT, and VSISELECT bits (AIA) */ #define ISELECT_IPRIO0 0x30 #define ISELECT_IPRIO15 0x3f diff --git a/target/riscv/cpu_helper.c b/target/riscv/cpu_helper.c index 2097a26ca0..bf58350669 100644 --- a/target/riscv/cpu_helper.c +++ b/target/riscv/cpu_helper.c @@ -138,61 +138,10 @@ void cpu_get_tb_cpu_state(CPURISCVState *env, vaddr *= pc, flags =3D FIELD_DP32(flags, TB_FLAGS, VS, vs); flags =3D FIELD_DP32(flags, TB_FLAGS, XL, env->xl); flags =3D FIELD_DP32(flags, TB_FLAGS, AXL, cpu_address_xl(env)); - if (env->cur_pmmask !=3D 0) { - flags =3D FIELD_DP32(flags, TB_FLAGS, PM_MASK_ENABLED, 1); - } - if (env->cur_pmbase !=3D 0) { - flags =3D FIELD_DP32(flags, TB_FLAGS, PM_BASE_ENABLED, 1); - } =20 *pflags =3D flags; } =20 -void riscv_cpu_update_mask(CPURISCVState *env) -{ - target_ulong mask =3D 0, base =3D 0; - RISCVMXL xl =3D env->xl; - /* - * TODO: Current RVJ spec does not specify - * how the extension interacts with XLEN. - */ -#ifndef CONFIG_USER_ONLY - int mode =3D cpu_address_mode(env); - xl =3D cpu_get_xl(env, mode); - if (riscv_has_ext(env, RVJ)) { - switch (mode) { - case PRV_M: - if (env->mmte & M_PM_ENABLE) { - mask =3D env->mpmmask; - base =3D env->mpmbase; - } - break; - case PRV_S: - if (env->mmte & S_PM_ENABLE) { - mask =3D env->spmmask; - base =3D env->spmbase; - } - break; - case PRV_U: - if (env->mmte & U_PM_ENABLE) { - mask =3D env->upmmask; - base =3D env->upmbase; - } - break; - default: - g_assert_not_reached(); - } - } -#endif - if (xl =3D=3D MXL_RV32) { - env->cur_pmmask =3D mask & UINT32_MAX; - env->cur_pmbase =3D base & UINT32_MAX; - } else { - env->cur_pmmask =3D mask; - env->cur_pmbase =3D base; - } -} - #ifndef CONFIG_USER_ONLY =20 /* @@ -724,7 +673,6 @@ void riscv_cpu_set_mode(CPURISCVState *env, target_ulon= g newpriv) /* tlb_flush is unnecessary as mode is contained in mmu_idx */ env->priv =3D newpriv; env->xl =3D cpu_recompute_xl(env); - riscv_cpu_update_mask(env); =20 /* * Clear the load reservation - otherwise a reservation placed in one diff --git a/target/riscv/csr.c b/target/riscv/csr.c index 6b460ee0e8..4b2c932564 100644 --- a/target/riscv/csr.c +++ b/target/riscv/csr.c @@ -486,16 +486,6 @@ static RISCVException hgatp(CPURISCVState *env, int cs= rno) return hmode(env, csrno); } =20 -/* Checks if PointerMasking registers could be accessed */ -static RISCVException pointer_masking(CPURISCVState *env, int csrno) -{ - /* Check if j-ext is present */ - if (riscv_has_ext(env, RVJ)) { - return RISCV_EXCP_NONE; - } - return RISCV_EXCP_ILLEGAL_INST; -} - static RISCVException aia_hmode(CPURISCVState *env, int csrno) { if (!riscv_cpu_cfg(env)->ext_ssaia) { @@ -1404,7 +1394,6 @@ static RISCVException write_mstatus(CPURISCVState *en= v, int csrno, env->xl =3D cpu_recompute_xl(env); } =20 - riscv_cpu_update_mask(env); return RISCV_EXCP_NONE; } =20 @@ -3971,302 +3960,6 @@ static RISCVException write_mcontext(CPURISCVState = *env, int csrno, return RISCV_EXCP_NONE; } =20 -/* - * Functions to access Pointer Masking feature registers - * We have to check if current priv lvl could modify - * csr in given mode - */ -static bool check_pm_current_disabled(CPURISCVState *env, int csrno) -{ - int csr_priv =3D get_field(csrno, 0x300); - int pm_current; - - if (env->debugger) { - return false; - } - /* - * If priv lvls differ that means we're accessing csr from higher priv= lvl, - * so allow the access - */ - if (env->priv !=3D csr_priv) { - return false; - } - switch (env->priv) { - case PRV_M: - pm_current =3D get_field(env->mmte, M_PM_CURRENT); - break; - case PRV_S: - pm_current =3D get_field(env->mmte, S_PM_CURRENT); - break; - case PRV_U: - pm_current =3D get_field(env->mmte, U_PM_CURRENT); - break; - default: - g_assert_not_reached(); - } - /* It's same priv lvl, so we allow to modify csr only if pm.current=3D= =3D1 */ - return !pm_current; -} - -static RISCVException read_mmte(CPURISCVState *env, int csrno, - target_ulong *val) -{ - *val =3D env->mmte & MMTE_MASK; - return RISCV_EXCP_NONE; -} - -static RISCVException write_mmte(CPURISCVState *env, int csrno, - target_ulong val) -{ - uint64_t mstatus; - target_ulong wpri_val =3D val & MMTE_MASK; - - if (val !=3D wpri_val) { - qemu_log_mask(LOG_GUEST_ERROR, "%s" TARGET_FMT_lx " %s" - TARGET_FMT_lx "\n", "MMTE: WPRI violation written 0x= ", - val, "vs expected 0x", wpri_val); - } - /* for machine mode pm.current is hardwired to 1 */ - wpri_val |=3D MMTE_M_PM_CURRENT; - - /* hardwiring pm.instruction bit to 0, since it's not supported yet */ - wpri_val &=3D ~(MMTE_M_PM_INSN | MMTE_S_PM_INSN | MMTE_U_PM_INSN); - env->mmte =3D wpri_val | EXT_STATUS_DIRTY; - riscv_cpu_update_mask(env); - - /* Set XS and SD bits, since PM CSRs are dirty */ - mstatus =3D env->mstatus | MSTATUS_XS; - write_mstatus(env, csrno, mstatus); - return RISCV_EXCP_NONE; -} - -static RISCVException read_smte(CPURISCVState *env, int csrno, - target_ulong *val) -{ - *val =3D env->mmte & SMTE_MASK; - return RISCV_EXCP_NONE; -} - -static RISCVException write_smte(CPURISCVState *env, int csrno, - target_ulong val) -{ - target_ulong wpri_val =3D val & SMTE_MASK; - - if (val !=3D wpri_val) { - qemu_log_mask(LOG_GUEST_ERROR, "%s" TARGET_FMT_lx " %s" - TARGET_FMT_lx "\n", "SMTE: WPRI violation written 0x= ", - val, "vs expected 0x", wpri_val); - } - - /* if pm.current=3D=3D0 we can't modify current PM CSRs */ - if (check_pm_current_disabled(env, csrno)) { - return RISCV_EXCP_NONE; - } - - wpri_val |=3D (env->mmte & ~SMTE_MASK); - write_mmte(env, csrno, wpri_val); - return RISCV_EXCP_NONE; -} - -static RISCVException read_umte(CPURISCVState *env, int csrno, - target_ulong *val) -{ - *val =3D env->mmte & UMTE_MASK; - return RISCV_EXCP_NONE; -} - -static RISCVException write_umte(CPURISCVState *env, int csrno, - target_ulong val) -{ - target_ulong wpri_val =3D val & UMTE_MASK; - - if (val !=3D wpri_val) { - qemu_log_mask(LOG_GUEST_ERROR, "%s" TARGET_FMT_lx " %s" - TARGET_FMT_lx "\n", "UMTE: WPRI violation written 0x= ", - val, "vs expected 0x", wpri_val); - } - - if (check_pm_current_disabled(env, csrno)) { - return RISCV_EXCP_NONE; - } - - wpri_val |=3D (env->mmte & ~UMTE_MASK); - write_mmte(env, csrno, wpri_val); - return RISCV_EXCP_NONE; -} - -static RISCVException read_mpmmask(CPURISCVState *env, int csrno, - target_ulong *val) -{ - *val =3D env->mpmmask; - return RISCV_EXCP_NONE; -} - -static RISCVException write_mpmmask(CPURISCVState *env, int csrno, - target_ulong val) -{ - uint64_t mstatus; - - env->mpmmask =3D val; - if ((cpu_address_mode(env) =3D=3D PRV_M) && (env->mmte & M_PM_ENABLE))= { - env->cur_pmmask =3D val; - } - env->mmte |=3D EXT_STATUS_DIRTY; - - /* Set XS and SD bits, since PM CSRs are dirty */ - mstatus =3D env->mstatus | MSTATUS_XS; - write_mstatus(env, csrno, mstatus); - return RISCV_EXCP_NONE; -} - -static RISCVException read_spmmask(CPURISCVState *env, int csrno, - target_ulong *val) -{ - *val =3D env->spmmask; - return RISCV_EXCP_NONE; -} - -static RISCVException write_spmmask(CPURISCVState *env, int csrno, - target_ulong val) -{ - uint64_t mstatus; - - /* if pm.current=3D=3D0 we can't modify current PM CSRs */ - if (check_pm_current_disabled(env, csrno)) { - return RISCV_EXCP_NONE; - } - env->spmmask =3D val; - if ((cpu_address_mode(env) =3D=3D PRV_S) && (env->mmte & S_PM_ENABLE))= { - env->cur_pmmask =3D val; - if (cpu_get_xl(env, PRV_S) =3D=3D MXL_RV32) { - env->cur_pmmask &=3D UINT32_MAX; - } - } - env->mmte |=3D EXT_STATUS_DIRTY; - - /* Set XS and SD bits, since PM CSRs are dirty */ - mstatus =3D env->mstatus | MSTATUS_XS; - write_mstatus(env, csrno, mstatus); - return RISCV_EXCP_NONE; -} - -static RISCVException read_upmmask(CPURISCVState *env, int csrno, - target_ulong *val) -{ - *val =3D env->upmmask; - return RISCV_EXCP_NONE; -} - -static RISCVException write_upmmask(CPURISCVState *env, int csrno, - target_ulong val) -{ - uint64_t mstatus; - - /* if pm.current=3D=3D0 we can't modify current PM CSRs */ - if (check_pm_current_disabled(env, csrno)) { - return RISCV_EXCP_NONE; - } - env->upmmask =3D val; - if ((cpu_address_mode(env) =3D=3D PRV_U) && (env->mmte & U_PM_ENABLE))= { - env->cur_pmmask =3D val; - if (cpu_get_xl(env, PRV_U) =3D=3D MXL_RV32) { - env->cur_pmmask &=3D UINT32_MAX; - } - } - env->mmte |=3D EXT_STATUS_DIRTY; - - /* Set XS and SD bits, since PM CSRs are dirty */ - mstatus =3D env->mstatus | MSTATUS_XS; - write_mstatus(env, csrno, mstatus); - return RISCV_EXCP_NONE; -} - -static RISCVException read_mpmbase(CPURISCVState *env, int csrno, - target_ulong *val) -{ - *val =3D env->mpmbase; - return RISCV_EXCP_NONE; -} - -static RISCVException write_mpmbase(CPURISCVState *env, int csrno, - target_ulong val) -{ - uint64_t mstatus; - - env->mpmbase =3D val; - if ((cpu_address_mode(env) =3D=3D PRV_M) && (env->mmte & M_PM_ENABLE))= { - env->cur_pmbase =3D val; - } - env->mmte |=3D EXT_STATUS_DIRTY; - - /* Set XS and SD bits, since PM CSRs are dirty */ - mstatus =3D env->mstatus | MSTATUS_XS; - write_mstatus(env, csrno, mstatus); - return RISCV_EXCP_NONE; -} - -static RISCVException read_spmbase(CPURISCVState *env, int csrno, - target_ulong *val) -{ - *val =3D env->spmbase; - return RISCV_EXCP_NONE; -} - -static RISCVException write_spmbase(CPURISCVState *env, int csrno, - target_ulong val) -{ - uint64_t mstatus; - - /* if pm.current=3D=3D0 we can't modify current PM CSRs */ - if (check_pm_current_disabled(env, csrno)) { - return RISCV_EXCP_NONE; - } - env->spmbase =3D val; - if ((cpu_address_mode(env) =3D=3D PRV_S) && (env->mmte & S_PM_ENABLE))= { - env->cur_pmbase =3D val; - if (cpu_get_xl(env, PRV_S) =3D=3D MXL_RV32) { - env->cur_pmbase &=3D UINT32_MAX; - } - } - env->mmte |=3D EXT_STATUS_DIRTY; - - /* Set XS and SD bits, since PM CSRs are dirty */ - mstatus =3D env->mstatus | MSTATUS_XS; - write_mstatus(env, csrno, mstatus); - return RISCV_EXCP_NONE; -} - -static RISCVException read_upmbase(CPURISCVState *env, int csrno, - target_ulong *val) -{ - *val =3D env->upmbase; - return RISCV_EXCP_NONE; -} - -static RISCVException write_upmbase(CPURISCVState *env, int csrno, - target_ulong val) -{ - uint64_t mstatus; - - /* if pm.current=3D=3D0 we can't modify current PM CSRs */ - if (check_pm_current_disabled(env, csrno)) { - return RISCV_EXCP_NONE; - } - env->upmbase =3D val; - if ((cpu_address_mode(env) =3D=3D PRV_U) && (env->mmte & U_PM_ENABLE))= { - env->cur_pmbase =3D val; - if (cpu_get_xl(env, PRV_U) =3D=3D MXL_RV32) { - env->cur_pmbase &=3D UINT32_MAX; - } - } - env->mmte |=3D EXT_STATUS_DIRTY; - - /* Set XS and SD bits, since PM CSRs are dirty */ - mstatus =3D env->mstatus | MSTATUS_XS; - write_mstatus(env, csrno, mstatus); - return RISCV_EXCP_NONE; -} - #endif =20 /* Crypto Extension */ @@ -4925,25 +4618,6 @@ riscv_csr_operations csr_ops[CSR_TABLE_SIZE] =3D { [CSR_TINFO] =3D { "tinfo", debug, read_tinfo, write_ignore = }, [CSR_MCONTEXT] =3D { "mcontext", debug, read_mcontext, write_mcontex= t }, =20 - /* User Pointer Masking */ - [CSR_UMTE] =3D { "umte", pointer_masking, read_umte, write_u= mte }, - [CSR_UPMMASK] =3D { "upmmask", pointer_masking, read_upmmask, - write_upmmask = }, - [CSR_UPMBASE] =3D { "upmbase", pointer_masking, read_upmbase, - write_upmbase = }, - /* Machine Pointer Masking */ - [CSR_MMTE] =3D { "mmte", pointer_masking, read_mmte, write_m= mte }, - [CSR_MPMMASK] =3D { "mpmmask", pointer_masking, read_mpmmask, - write_mpmmask = }, - [CSR_MPMBASE] =3D { "mpmbase", pointer_masking, read_mpmbase, - write_mpmbase = }, - /* Supervisor Pointer Masking */ - [CSR_SMTE] =3D { "smte", pointer_masking, read_smte, write_s= mte }, - [CSR_SPMMASK] =3D { "spmmask", pointer_masking, read_spmmask, - write_spmmask = }, - [CSR_SPMBASE] =3D { "spmbase", pointer_masking, read_spmbase, - write_spmbase = }, - /* Performance Counters */ [CSR_HPMCOUNTER3] =3D { "hpmcounter3", ctr, read_hpmcounter }, [CSR_HPMCOUNTER4] =3D { "hpmcounter4", ctr, read_hpmcounter }, diff --git a/target/riscv/machine.c b/target/riscv/machine.c index 76f2150f78..64ab66e332 100644 --- a/target/riscv/machine.c +++ b/target/riscv/machine.c @@ -152,10 +152,7 @@ static const VMStateDescription vmstate_vector =3D { =20 static bool pointermasking_needed(void *opaque) { - RISCVCPU *cpu =3D opaque; - CPURISCVState *env =3D &cpu->env; - - return riscv_has_ext(env, RVJ); + return false; } =20 static const VMStateDescription vmstate_pointermasking =3D { @@ -164,14 +161,6 @@ static const VMStateDescription vmstate_pointermasking= =3D { .minimum_version_id =3D 1, .needed =3D pointermasking_needed, .fields =3D (const VMStateField[]) { - VMSTATE_UINTTL(env.mmte, RISCVCPU), - VMSTATE_UINTTL(env.mpmmask, RISCVCPU), - VMSTATE_UINTTL(env.mpmbase, RISCVCPU), - VMSTATE_UINTTL(env.spmmask, RISCVCPU), - VMSTATE_UINTTL(env.spmbase, RISCVCPU), - VMSTATE_UINTTL(env.upmmask, RISCVCPU), - VMSTATE_UINTTL(env.upmbase, RISCVCPU), - VMSTATE_END_OF_LIST() } }; @@ -266,7 +255,6 @@ static int riscv_cpu_post_load(void *opaque, int versio= n_id) CPURISCVState *env =3D &cpu->env; =20 env->xl =3D cpu_recompute_xl(env); - riscv_cpu_update_mask(env); return 0; } =20 diff --git a/target/riscv/tcg/tcg-cpu.c b/target/riscv/tcg/tcg-cpu.c index 4ebebebe09..f64316ef17 100644 --- a/target/riscv/tcg/tcg-cpu.c +++ b/target/riscv/tcg/tcg-cpu.c @@ -998,7 +998,6 @@ static const RISCVCPUMisaExtConfig misa_ext_cfgs[] =3D { MISA_CFG(RVS, true), MISA_CFG(RVU, true), MISA_CFG(RVH, true), - MISA_CFG(RVJ, false), MISA_CFG(RVV, false), MISA_CFG(RVG, false), MISA_CFG(RVB, false), @@ -1285,8 +1284,8 @@ static void riscv_init_max_cpu_extensions(Object *obj) CPURISCVState *env =3D &cpu->env; const RISCVCPUMultiExtConfig *prop; =20 - /* Enable RVG, RVJ and RVV that are disabled by default */ - riscv_cpu_set_misa_ext(env, env->misa_ext | RVG | RVJ | RVV); + /* Enable RVG and RVV that are disabled by default */ + riscv_cpu_set_misa_ext(env, env->misa_ext | RVG | RVV); =20 for (prop =3D riscv_cpu_extensions; prop && prop->name; prop++) { isa_ext_update_enabled(cpu, prop->offset, true); diff --git a/target/riscv/translate.c b/target/riscv/translate.c index 9ff09ebdb6..e5b339b1fa 100644 --- a/target/riscv/translate.c +++ b/target/riscv/translate.c @@ -42,9 +42,6 @@ static TCGv cpu_gpr[32], cpu_gprh[32], cpu_pc, cpu_vl, cp= u_vstart; static TCGv_i64 cpu_fpr[32]; /* assume F and D extensions */ static TCGv load_res; static TCGv load_val; -/* globals for PM CSRs */ -static TCGv pm_mask; -static TCGv pm_base; =20 /* * If an operation is being performed on less than TARGET_LONG_BITS, @@ -106,9 +103,6 @@ typedef struct DisasContext { bool vl_eq_vlmax; CPUState *cs; TCGv zero; - /* PointerMasking extension */ - bool pm_mask_enabled; - bool pm_base_enabled; /* Ztso */ bool ztso; /* Use icount trigger for native debug */ @@ -583,14 +577,9 @@ static TCGv get_address(DisasContext *ctx, int rs1, in= t imm) TCGv src1 =3D get_gpr(ctx, rs1, EXT_NONE); =20 tcg_gen_addi_tl(addr, src1, imm); - if (ctx->pm_mask_enabled) { - tcg_gen_andc_tl(addr, addr, pm_mask); - } else if (get_address_xl(ctx) =3D=3D MXL_RV32) { + if (get_address_xl(ctx) =3D=3D MXL_RV32) { tcg_gen_ext32u_tl(addr, addr); } - if (ctx->pm_base_enabled) { - tcg_gen_or_tl(addr, addr, pm_base); - } =20 return addr; } @@ -602,14 +591,9 @@ static TCGv get_address_indexed(DisasContext *ctx, int= rs1, TCGv offs) TCGv src1 =3D get_gpr(ctx, rs1, EXT_NONE); =20 tcg_gen_add_tl(addr, src1, offs); - if (ctx->pm_mask_enabled) { - tcg_gen_andc_tl(addr, addr, pm_mask); - } else if (get_xl(ctx) =3D=3D MXL_RV32) { + if (get_xl(ctx) =3D=3D MXL_RV32) { tcg_gen_ext32u_tl(addr, addr); } - if (ctx->pm_base_enabled) { - tcg_gen_or_tl(addr, addr, pm_base); - } return addr; } =20 @@ -1201,8 +1185,6 @@ static void riscv_tr_init_disas_context(DisasContextB= ase *dcbase, CPUState *cs) ctx->xl =3D FIELD_EX32(tb_flags, TB_FLAGS, XL); ctx->address_xl =3D FIELD_EX32(tb_flags, TB_FLAGS, AXL); ctx->cs =3D cs; - ctx->pm_mask_enabled =3D FIELD_EX32(tb_flags, TB_FLAGS, PM_MASK_ENABLE= D); - ctx->pm_base_enabled =3D FIELD_EX32(tb_flags, TB_FLAGS, PM_BASE_ENABLE= D); ctx->ztso =3D cpu->cfg.ext_ztso; ctx->itrigger =3D FIELD_EX32(tb_flags, TB_FLAGS, ITRIGGER); ctx->zero =3D tcg_constant_tl(0); @@ -1335,9 +1317,4 @@ void riscv_translate_init(void) "load_res"); load_val =3D tcg_global_mem_new(tcg_env, offsetof(CPURISCVState, load_= val), "load_val"); - /* Assign PM CSRs to tcg globals */ - pm_mask =3D tcg_global_mem_new(tcg_env, offsetof(CPURISCVState, cur_pm= mask), - "pmmask"); - pm_base =3D tcg_global_mem_new(tcg_env, offsetof(CPURISCVState, cur_pm= base), - "pmbase"); } diff --git a/target/riscv/vector_helper.c b/target/riscv/vector_helper.c index fa139040f8..39ba2a09dd 100644 --- a/target/riscv/vector_helper.c +++ b/target/riscv/vector_helper.c @@ -104,7 +104,7 @@ static inline uint32_t vext_max_elems(uint32_t desc, ui= nt32_t log2_esz) =20 static inline target_ulong adjust_addr(CPURISCVState *env, target_ulong ad= dr) { - return (addr & ~env->cur_pmmask) | env->cur_pmbase; + return addr; } =20 /* --=20 2.34.1 From nobody Sat Nov 23 15:25:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1715422350892458.24750125979733; Sat, 11 May 2024 03:12:30 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s5jhF-0005Sy-DB; Sat, 11 May 2024 06:11: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 1s5jhC-0005RX-RS; Sat, 11 May 2024 06:11:14 -0400 Received: from mail-ej1-x636.google.com ([2a00:1450:4864:20::636]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s5jh6-00029n-5u; Sat, 11 May 2024 06:11:14 -0400 Received: by mail-ej1-x636.google.com with SMTP id a640c23a62f3a-a59a352bbd9so471002066b.1; Sat, 11 May 2024 03:11:07 -0700 (PDT) Received: from freya.midgard (broadband-188-255-126-251.ip.moscow.rt.ru. [188.255.126.251]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a5a1781d27bsm301687166b.21.2024.05.11.03.11.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 11 May 2024 03:11:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1715422266; x=1716027066; 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=A1Ntzu9BEFtLKcUtz+NFIzasN3U9L0YdUu0S1V4wh0A=; b=i+tex6Srd8Uiwgeb149WNBUZnc2MvweWUJUmIgZ2OYdVMdHSkgfNtgX/ZKiYqs0gGt JwIxIZL1hzey5VtPx0HIpO1a8oM9QXT0FcazA6RU0M/z+JRDbXPjjYypIIkfDeZArj5z K8Jr4TdTPhjwz9H0p4WrpTm4BDrXrxKegVAq/5QVA0pdA5LVDx8zngPNqVOlhddyMy1r ff185k1oWpNsDVjD5Exuk/u7iWkBR7aqSpICO6pEfxALSHrwZRabvVYYe2sLsBqKz0vu 6MNPm4YBhxdKBbcsXPrNpfhmrHxbnwenLNinoMtIfrRBIMw93/hyN+BpwrDxnT2lBIzp Oo8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715422266; x=1716027066; 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=A1Ntzu9BEFtLKcUtz+NFIzasN3U9L0YdUu0S1V4wh0A=; b=Z+a6eJji8H5vtShBGIpbFTZ73+russF50VcWbSHmEaOB/365c3Yk1ebvOYYaXtrih/ 07gCkmc+tOT/MdggSJtQ93xQM5P1MGElTbryBzUtbos7pbyvZAkjPHHHafuR2C3yDNGe TjzXr6Bst4XKk3kuf6LpkTslt/vDREdDm5UQA6UMDuyzJw0GJyHcaJOO35cLKdyOEqfB CeCcdWci7kFuLC9s6jWD9RxwJPM1D/hBL2Z7IE+9IfLZnha0h2D8HKWJ6liYzqIzqauk AEX2w1QjWpXBex0DmfGNEvMEhEb2XJ4M+BVfugWoe9SO1NOfVQkqKdP/Y7OTzbDKb8zJ DsSA== X-Forwarded-Encrypted: i=1; AJvYcCVh1F7iOb/LP0XmX8zqTAsr++IunYSLW4lrl05E+CNWrHdQ7WooaaZxMzv6v+PCGmTiO3wk1AbaJYHjvkixzMvHOM3y9joMoBHfMQ00g5EoA8jlmmqtDiYxZrR5tQ== X-Gm-Message-State: AOJu0YwSoOjcotnBLMcGUIZjLGsXQzs8ZkBJt9m+e31/r1Ks+w+uhvah iTDKMQDxBuVgUainHZYoxsBF37FozvM1e5qA45zEShBUcwugwunU X-Google-Smtp-Source: AGHT+IGIONM+/KBADhWaOhM3t3cipfY70vjEIXSkS9qGUSjof9wS30MuHSDJfWgO3DtVd1NWR0k+VA== X-Received: by 2002:a17:907:2d09:b0:a55:5520:f43f with SMTP id a640c23a62f3a-a5a115ef93dmr823636266b.10.1715422266388; Sat, 11 May 2024 03:11:06 -0700 (PDT) From: Alexey Baturo X-Google-Original-From: Alexey Baturo To: Cc: baturo.alexey@gmail.com, richard.henderson@linaro.org, space.monkey.delivers@gmail.com, palmer@dabbelt.com, Alistair.Francis@wdc.com, sagark@eecs.berkeley.edu, kbastian@mail.uni-paderborn.de, qemu-devel@nongnu.org, qemu-riscv@nongnu.org, Alistair Francis Subject: [PATCH v9 2/6] target/riscv: Add new CSR fields for S{sn, mn, m}pm extensions as part of Zjpm v0.8 Date: Sat, 11 May 2024 13:10:49 +0300 Message-Id: <20240511101053.1875596-3-me@deliversmonkey.space> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240511101053.1875596-1-me@deliversmonkey.space> References: <20240511101053.1875596-1-me@deliversmonkey.space> MIME-Version: 1.0 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::636; envelope-from=baturo.alexey@gmail.com; helo=mail-ej1-x636.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, 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: fail (Header signature does not verify) X-ZM-MESSAGEID: 1715422352755100007 Content-Type: text/plain; charset="utf-8" From: Alexey Baturo Signed-off-by: Alexey Baturo Reviewed-by: Alistair Francis --- target/riscv/cpu.h | 8 ++++++++ target/riscv/cpu_bits.h | 3 +++ target/riscv/cpu_cfg.h | 3 +++ target/riscv/csr.c | 11 +++++++++++ target/riscv/machine.c | 10 +++++++--- target/riscv/pmp.c | 13 ++++++++++--- target/riscv/pmp.h | 11 ++++++----- 7 files changed, 48 insertions(+), 11 deletions(-) diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h index 232521bb87..52b6ba73c8 100644 --- a/target/riscv/cpu.h +++ b/target/riscv/cpu.h @@ -121,6 +121,14 @@ typedef enum { EXT_STATUS_DIRTY, } RISCVExtStatus; =20 +/* Enum holds PMM field values for Zjpm v0.8 extension */ +typedef enum { + PMM_FIELD_DISABLED =3D 0, + PMM_FIELD_RESERVED =3D 1, + PMM_FIELD_PMLEN7 =3D 2, + PMM_FIELD_PMLEN16 =3D 3, +} RISCVPmPmm; + #define MMU_USER_IDX 3 =20 #define MAX_RISCV_PMPS (16) diff --git a/target/riscv/cpu_bits.h b/target/riscv/cpu_bits.h index da16ba236a..13ce2218d1 100644 --- a/target/riscv/cpu_bits.h +++ b/target/riscv/cpu_bits.h @@ -708,6 +708,7 @@ typedef enum RISCVException { #define MENVCFG_CBIE (3UL << 4) #define MENVCFG_CBCFE BIT(6) #define MENVCFG_CBZE BIT(7) +#define MENVCFG_PMM (3ULL << 32) #define MENVCFG_ADUE (1ULL << 61) #define MENVCFG_PBMTE (1ULL << 62) #define MENVCFG_STCE (1ULL << 63) @@ -721,11 +722,13 @@ typedef enum RISCVException { #define SENVCFG_CBIE MENVCFG_CBIE #define SENVCFG_CBCFE MENVCFG_CBCFE #define SENVCFG_CBZE MENVCFG_CBZE +#define SENVCFG_PMM MENVCFG_PMM =20 #define HENVCFG_FIOM MENVCFG_FIOM #define HENVCFG_CBIE MENVCFG_CBIE #define HENVCFG_CBCFE MENVCFG_CBCFE #define HENVCFG_CBZE MENVCFG_CBZE +#define HENVCFG_PMM MENVCFG_PMM #define HENVCFG_ADUE MENVCFG_ADUE #define HENVCFG_PBMTE MENVCFG_PBMTE #define HENVCFG_STCE MENVCFG_STCE diff --git a/target/riscv/cpu_cfg.h b/target/riscv/cpu_cfg.h index e1e4f32698..9ecdc792c5 100644 --- a/target/riscv/cpu_cfg.h +++ b/target/riscv/cpu_cfg.h @@ -120,6 +120,9 @@ struct RISCVCPUConfig { bool ext_ssaia; bool ext_sscofpmf; bool ext_smepmp; + bool ext_ssnpm; + bool ext_smnpm; + bool ext_smmpm; bool rvv_ta_all_1s; bool rvv_ma_all_1s; =20 diff --git a/target/riscv/csr.c b/target/riscv/csr.c index 4b2c932564..45b548eb0b 100644 --- a/target/riscv/csr.c +++ b/target/riscv/csr.c @@ -530,6 +530,9 @@ static RISCVException have_mseccfg(CPURISCVState *env, = int csrno) if (riscv_cpu_cfg(env)->ext_zkr) { return RISCV_EXCP_NONE; } + if (riscv_cpu_cfg(env)->ext_smmpm) { + return RISCV_EXCP_NONE; + } =20 return RISCV_EXCP_ILLEGAL_INST; } @@ -2083,6 +2086,10 @@ static RISCVException write_menvcfg(CPURISCVState *e= nv, int csrno, (cfg->ext_sstc ? MENVCFG_STCE : 0) | (cfg->ext_svadu ? MENVCFG_ADUE : 0); } + /* Update PMM field only if the value is valid according to Zjpm v0.8 = */ + if (((val & MENVCFG_PMM) >> 32) !=3D PMM_FIELD_RESERVED) { + mask |=3D MENVCFG_PMM; + } env->menvcfg =3D (env->menvcfg & ~mask) | (val & mask); =20 return RISCV_EXCP_NONE; @@ -2127,6 +2134,10 @@ static RISCVException write_senvcfg(CPURISCVState *e= nv, int csrno, target_ulong val) { uint64_t mask =3D SENVCFG_FIOM | SENVCFG_CBIE | SENVCFG_CBCFE | SENVCF= G_CBZE; + /* Update PMM field only if the value is valid according to Zjpm v0.8 = */ + if (((val & SENVCFG_PMM) >> 32) !=3D PMM_FIELD_RESERVED) { + mask |=3D SENVCFG_PMM; + } RISCVException ret; =20 ret =3D smstateen_acc_ok(env, 0, SMSTATEEN0_HSENVCFG); diff --git a/target/riscv/machine.c b/target/riscv/machine.c index 64ab66e332..bbbb28f373 100644 --- a/target/riscv/machine.c +++ b/target/riscv/machine.c @@ -152,15 +152,19 @@ static const VMStateDescription vmstate_vector =3D { =20 static bool pointermasking_needed(void *opaque) { - return false; + RISCVCPU *cpu =3D opaque; + return cpu->cfg.ext_ssnpm || cpu->cfg.ext_smnpm || cpu->cfg.ext_smmpm; } =20 static const VMStateDescription vmstate_pointermasking =3D { .name =3D "cpu/pointer_masking", - .version_id =3D 1, - .minimum_version_id =3D 1, + .version_id =3D 2, + .minimum_version_id =3D 2, .needed =3D pointermasking_needed, .fields =3D (const VMStateField[]) { + VMSTATE_UINTTL(env.mseccfg, RISCVCPU), + VMSTATE_UINTTL(env.senvcfg, RISCVCPU), + VMSTATE_UINTTL(env.menvcfg, RISCVCPU), VMSTATE_END_OF_LIST() } }; diff --git a/target/riscv/pmp.c b/target/riscv/pmp.c index 2a76b611a0..7ddb9dbf0b 100644 --- a/target/riscv/pmp.c +++ b/target/riscv/pmp.c @@ -574,6 +574,12 @@ target_ulong pmpaddr_csr_read(CPURISCVState *env, uint= 32_t addr_index) void mseccfg_csr_write(CPURISCVState *env, target_ulong val) { int i; + uint64_t mask =3D MSECCFG_MMWP | MSECCFG_MML; + + /* Update PMM field only if the value is valid according to Zjpm v0.8 = */ + if (((val & MSECCFG_PMM) >> 32) !=3D PMM_FIELD_RESERVED) { + mask |=3D MSECCFG_PMM; + } =20 trace_mseccfg_csr_write(env->mhartid, val); =20 @@ -589,12 +595,13 @@ void mseccfg_csr_write(CPURISCVState *env, target_ulo= ng val) =20 if (riscv_cpu_cfg(env)->ext_smepmp) { /* Sticky bits */ - val |=3D (env->mseccfg & (MSECCFG_MMWP | MSECCFG_MML)); - if ((val ^ env->mseccfg) & (MSECCFG_MMWP | MSECCFG_MML)) { + val |=3D (env->mseccfg & mask); + if ((val ^ env->mseccfg) & mask) { tlb_flush(env_cpu(env)); } } else { - val &=3D ~(MSECCFG_MMWP | MSECCFG_MML | MSECCFG_RLB); + mask |=3D MSECCFG_RLB; + val &=3D ~(mask); } =20 env->mseccfg =3D val; diff --git a/target/riscv/pmp.h b/target/riscv/pmp.h index f5c10ce85c..ccff0eb9b6 100644 --- a/target/riscv/pmp.h +++ b/target/riscv/pmp.h @@ -40,11 +40,12 @@ typedef enum { } pmp_am_t; =20 typedef enum { - MSECCFG_MML =3D 1 << 0, - MSECCFG_MMWP =3D 1 << 1, - MSECCFG_RLB =3D 1 << 2, - MSECCFG_USEED =3D 1 << 8, - MSECCFG_SSEED =3D 1 << 9 + MSECCFG_MML =3D 1 << 0, + MSECCFG_MMWP =3D 1 << 1, + MSECCFG_RLB =3D 1 << 2, + MSECCFG_USEED =3D 1 << 8, + MSECCFG_SSEED =3D 1 << 9, + MSECCFG_PMM =3D 3UL << 32, } mseccfg_field_t; =20 typedef struct { --=20 2.34.1 From nobody Sat Nov 23 15:25:05 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; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1715422399; cv=none; d=zohomail.com; s=zohoarc; b=e/sZSedhkMg0yXbK5U1iyUPxE41Vjn2872dz97Tpt0SwZ0bKPw6hUghFTJJiQOXL+YYqHkwMMYc8Z0rm3xEKJKaSkSM9tWn57OL2nmCMyNqsXtcttjvSD1KpldQnIWr2sqLufXWmglRjCrV6W9ciRLD4RnQwOsDLleRM3vcofAY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1715422399; h=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:Message-Id:Reply-To:To; bh=0m567lbtMWX/Xqv2X9vHS/gn97bjDpzEPZiou0M2OMo=; b=f7XCHL0sk3mI7OFpf40EbxUflu1mFPxF4Zi+ndAwFQy04rQw6l3edQlxMqjwNybGIA1tyQXQmBgG2JzNFIRT2L8Ak2e8JjyiKMZxANWyG7SriOkMwhyK6e2hnkgbnbjGKHF2/ZvlbXjE/uq6Te9BSoO+Nv7DS2bcjUz1ycyDGkI= 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1715422399385583.758776457404; Sat, 11 May 2024 03:13:19 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s5jhH-0005UH-1m; Sat, 11 May 2024 06:11:19 -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 1s5jhF-0005Th-VN; Sat, 11 May 2024 06:11:17 -0400 Received: from mail-ej1-x62d.google.com ([2a00:1450:4864:20::62d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s5jh7-00029u-LJ; Sat, 11 May 2024 06:11:17 -0400 Received: by mail-ej1-x62d.google.com with SMTP id a640c23a62f3a-a59ab4f60a6so610761666b.0; Sat, 11 May 2024 03:11:08 -0700 (PDT) Received: from freya.midgard (broadband-188-255-126-251.ip.moscow.rt.ru. [188.255.126.251]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a5a1781d27bsm301687166b.21.2024.05.11.03.11.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 11 May 2024 03:11:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1715422268; x=1716027068; 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=0m567lbtMWX/Xqv2X9vHS/gn97bjDpzEPZiou0M2OMo=; b=SwUrSPHI7dn1kPj2pTjwdepYecQ45MLsgvZ4TWgI957SYWiVIgiuO3LkTeLwQZJ6HR f/5tvlC9ezVKMWiTZMwwT12exlk/DI3zm2N7/R+8B5Ii8zvMIuer+78/x7P8pJAtg1Bo zYggYZCNq2BorwEDgHggMI6aAJ1ETtRJ3xstgGNeSmWkN/Q34lL6uvpgHtUWW/xvhYek qsne19AoPG2/VRTVjY8lkR/QCJiDW0hEvbmFBp0ibeSTV+5FAMyaRIBjMyQIdvpITOaY m1Ng/dWVFkVuzhqB7YTMCatJQhYwmKCHdRNXfEQ9sZN7DyMdoj/2BJYPTLmpOn1h3k9L D/zQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715422268; x=1716027068; 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=0m567lbtMWX/Xqv2X9vHS/gn97bjDpzEPZiou0M2OMo=; b=EYGoC6uOilNcCfqAydwzRiqBblQXxzG0MgNOXD6Sq9Gie9EcDL6ab2Z1NMRcvHCkhr Dd2D2s7ZYrDqB5r5Q7g8lo/xRRcFxqF3P9lKkZFrI/2FjT00Pj298nKJ0D8syf/qvObB cLFOrgGk3Bg5+K2UgYJWQ/U0/CRxOdgYzvRgU5PmAbflb/xJl0dakGKqTivVJQpus5hS Z41F5t2b1RYt1WD86mcJrsEjp9TI//qYNhUNvmRwINlM+ena4fAnTVtv7Cz9kTlCx/XR r/1cySv4HhJQufcpPrT6zhcdZddUBnnYtEkEfZLe5++84afMsIKACaaduLMduajgOwZB MQrA== X-Forwarded-Encrypted: i=1; AJvYcCWJ6+eRJupRc+iU0AhLR8/2OFZECD29Bv46FZ+RIwHV2yzJ0ifyEAfjushYGFrWk43Fr/CtDmTnVQmahJcF1JhVfwxjzSZU8lVVaGoPqVh/22BQhTis3iFxO9at5g== X-Gm-Message-State: AOJu0Yzu1NGNHZLvPLgtCzfHlIDNQOohQ83NrtviSSrIztlJU9u5nuEf MHLHOHQpWgsw1QqWfoiQgxnH9jXfZeiecAhxU2nD4rFJN45JvA7z0zNPYoZC X-Google-Smtp-Source: AGHT+IFdT9cDLFVcHRNlQvygTKU4p+sq3M83Z3ao/UmmHiGvnpCgM7fX0OLI7QzQIeaxd4GOm2wFeg== X-Received: by 2002:a17:906:af0c:b0:a5a:2737:a3e8 with SMTP id a640c23a62f3a-a5a2d65989emr483784466b.59.1715422267704; Sat, 11 May 2024 03:11:07 -0700 (PDT) From: Alexey Baturo X-Google-Original-From: Alexey Baturo To: Cc: baturo.alexey@gmail.com, richard.henderson@linaro.org, space.monkey.delivers@gmail.com, palmer@dabbelt.com, Alistair.Francis@wdc.com, sagark@eecs.berkeley.edu, kbastian@mail.uni-paderborn.de, qemu-devel@nongnu.org, qemu-riscv@nongnu.org, Alistair Francis Subject: [PATCH v9 3/6] target/riscv: Add helper functions to calculate current number of masked bits for pointer masking Date: Sat, 11 May 2024 13:10:50 +0300 Message-Id: <20240511101053.1875596-4-me@deliversmonkey.space> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240511101053.1875596-1-me@deliversmonkey.space> References: <20240511101053.1875596-1-me@deliversmonkey.space> MIME-Version: 1.0 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::62d; envelope-from=baturo.alexey@gmail.com; helo=mail-ej1-x62d.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, 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 @gmail.com) X-ZM-MESSAGEID: 1715422400849100003 Content-Type: text/plain; charset="utf-8" From: Alexey Baturo Signed-off-by: Alexey Baturo Reviewed-by: Alistair Francis --- target/riscv/cpu.h | 5 ++++ target/riscv/cpu_helper.c | 58 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+) diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h index 52b6ba73c8..9cac723b19 100644 --- a/target/riscv/cpu.h +++ b/target/riscv/cpu.h @@ -698,8 +698,13 @@ void cpu_get_tb_cpu_state(CPURISCVState *env, vaddr *p= c, =20 bool riscv_cpu_is_32bit(RISCVCPU *cpu); =20 +bool riscv_cpu_virt_mem_enabled(CPURISCVState *env); +RISCVPmPmm riscv_pm_get_pmm(CPURISCVState *env); +int riscv_pm_get_pmlen(RISCVPmPmm pmm); + RISCVException riscv_csrr(CPURISCVState *env, int csrno, target_ulong *ret_value); + RISCVException riscv_csrrw(CPURISCVState *env, int csrno, target_ulong *ret_value, target_ulong new_value, target_ulong write_mask= ); diff --git a/target/riscv/cpu_helper.c b/target/riscv/cpu_helper.c index bf58350669..e4a127ca84 100644 --- a/target/riscv/cpu_helper.c +++ b/target/riscv/cpu_helper.c @@ -142,6 +142,64 @@ void cpu_get_tb_cpu_state(CPURISCVState *env, vaddr *p= c, *pflags =3D flags; } =20 +RISCVPmPmm riscv_pm_get_pmm(CPURISCVState *env) +{ + int pmm =3D 0; +#ifndef CONFIG_USER_ONLY + int priv_mode =3D cpu_address_mode(env); + /* Get current PMM field */ + switch (priv_mode) { + case PRV_M: + pmm =3D riscv_cpu_cfg(env)->ext_smmpm ? + get_field(env->mseccfg, MSECCFG_PMM) : PMM_FIELD_DISABLE= D; + break; + case PRV_S: + pmm =3D riscv_cpu_cfg(env)->ext_smnpm ? + get_field(env->menvcfg, MENVCFG_PMM) : PMM_FIELD_DISABLE= D; + break; + case PRV_U: + pmm =3D riscv_cpu_cfg(env)->ext_ssnpm ? + get_field(env->senvcfg, SENVCFG_PMM) : PMM_FIELD_DISABLE= D; + break; + default: + g_assert_not_reached(); + } +#endif + return pmm; +} + +bool riscv_cpu_virt_mem_enabled(CPURISCVState *env) +{ + bool virt_mem_en =3D false; +#ifndef CONFIG_USER_ONLY + int satp_mode =3D 0; + int priv_mode =3D cpu_address_mode(env); + /* Get current PMM field */ + if (riscv_cpu_mxl(env) =3D=3D MXL_RV32) { + satp_mode =3D get_field(env->satp, SATP32_MODE); + } else { + satp_mode =3D get_field(env->satp, SATP64_MODE); + } + virt_mem_en =3D ((satp_mode !=3D VM_1_10_MBARE) && (priv_mode !=3D PRV= _M)); +#endif + return virt_mem_en; +} + +int riscv_pm_get_pmlen(RISCVPmPmm pmm) +{ + switch (pmm) { + case PMM_FIELD_DISABLED: + return 0; + case PMM_FIELD_PMLEN7: + return 7; + case PMM_FIELD_PMLEN16: + return 16; + default: + g_assert_not_reached(); + } + return -1; +} + #ifndef CONFIG_USER_ONLY =20 /* --=20 2.34.1 From nobody Sat Nov 23 15:25:05 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; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1715422386; cv=none; d=zohomail.com; s=zohoarc; b=JfYNvZg0RmyhdIvS48rV29RsTTXXeMxdAC+dW5iQbae4yThIWNXfFtPbu9ukE3pEeAPjSzV9hbIkoZ4TLBbrMTXLQ39cRri9Nukt/kAuNIqxWFI8Rm6YBX0f6nbLr40qkUtXnxlCnd7kwldj7IfW40ksmwKOUFdWL7HcBr2LDTo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1715422386; h=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:Message-Id:Reply-To:To; bh=juU2xycHeW7Q1yXn6YtlScNAZLbvDxdXRmaW9Wgj+5A=; b=S9m0NzYcWaxLAM7TJGc9gDQH66R0RuxP6qPA53fdcJOtEIcG+/PyICqfupsjcKTeNKHp0Dbq/3Y7f92SdUGVlzGh7DyBXoNU0huIU7dtw+3h66ie3nS4reHI206ByYEJ0XQKChsQZ+O9PlGHmdutm2pKZyDn+baOrnfPayFUJMk= 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1715422386652492.76451190091166; Sat, 11 May 2024 03:13:06 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s5jhG-0005U5-Fn; Sat, 11 May 2024 06:11: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 1s5jhC-0005RQ-HC; Sat, 11 May 2024 06:11:14 -0400 Received: from mail-ej1-x62d.google.com ([2a00:1450:4864:20::62d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s5jh9-0002A4-7t; Sat, 11 May 2024 06:11:14 -0400 Received: by mail-ej1-x62d.google.com with SMTP id a640c23a62f3a-a59a17fcc6bso667140666b.1; Sat, 11 May 2024 03:11:10 -0700 (PDT) Received: from freya.midgard (broadband-188-255-126-251.ip.moscow.rt.ru. [188.255.126.251]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a5a1781d27bsm301687166b.21.2024.05.11.03.11.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 11 May 2024 03:11:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1715422269; x=1716027069; 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=juU2xycHeW7Q1yXn6YtlScNAZLbvDxdXRmaW9Wgj+5A=; b=RiAl3H38EuIbBJu57cTS0357wKkAUPwvkDKXBhIdq/ujo7Ag2Pl8fEii4LMh12jKPD hHviz2GC35T2ZXR5eiqT539V1jQnycSSutjhaPoSShgXMfTasNBV0Lki3oNI78tTO/lM X5gcCGnYWj5aWj8kFK7QKq+ky2s6S+6XkJujx/IbDOlnHmXtRWgJCELDh21d+Io5eSvh A/pfCSnxIT/F0sdgDen+cW9U8JAzVmDN+t0G5O8MzE4s/GD03ZriCLV+yeqfY9s7FwiG mReM7JW+YTXBlNa3BeHSJ5L/sLSrC5D7nOMTDuoSv/SwWr+AHHu5cB+rGfVBIAUzoH46 OWhg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715422269; x=1716027069; 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=juU2xycHeW7Q1yXn6YtlScNAZLbvDxdXRmaW9Wgj+5A=; b=OH8I/kayA1kU5cbAxqu4Qemw6E9l51CO/MSJCuUuZaUcwcakqEYv0Y8NM+C42TSYB3 j+kxAwchSEXzh9J8Mg2O/oABDGM7bKb3tiUv5dS7OUuBvHLqr4APuejYNja0OUePXJSw sXKTntEKhya4IUTjIhx0ZOXQMXnYJrigSwuQ6ZxLLghdvWzTX9UwMnpWtR5xG9M6YTcq 8JSozgbfMnsDIE/a//yOLsRe/PXLcMPS18FF/tk4+woqdQ9q4wnsWm7roKSnxHvWf8bt Sh0iCaHQ65Oou/W/aDcuwKSNbqezSKUnJ5AhGAWfLyHq11dPFQ0LyEy65ByI3UMvkpgK nZcw== X-Forwarded-Encrypted: i=1; AJvYcCU+8Dc/WPZzsGtuVH0aPSjbWgX3XWL8N6V10fkx74YEJKRR3xEbnV4J3THMgKv0Y73mIfgSxbGIT/elQLpK9HQRH8laKfmV9I4OjHm+9Sd220krsk7GxCv55LjRdQ== X-Gm-Message-State: AOJu0YwBBCIr9LTUprpNx3y9yAbPyNoKM6+1XOoc4wdithKQb9kc27uL Vo/qdAWeUmwR9XcyitQwPlCmq9a85IM3fG61ZBUpj7UxmCuuWIBe X-Google-Smtp-Source: AGHT+IE6MV9YOgyHM5TzSaHKzR7gyYIm941wvWykOVlhUg18VNUWSWgO9MGiY0heZiGkk4CGiobYaQ== X-Received: by 2002:a17:907:3208:b0:a59:c367:560c with SMTP id a640c23a62f3a-a5a2d665e1emr359203566b.60.1715422269020; Sat, 11 May 2024 03:11:09 -0700 (PDT) From: Alexey Baturo X-Google-Original-From: Alexey Baturo To: Cc: baturo.alexey@gmail.com, richard.henderson@linaro.org, space.monkey.delivers@gmail.com, palmer@dabbelt.com, Alistair.Francis@wdc.com, sagark@eecs.berkeley.edu, kbastian@mail.uni-paderborn.de, qemu-devel@nongnu.org, qemu-riscv@nongnu.org, Alistair Francis Subject: [PATCH v9 4/6] target/riscv: Add pointer masking tb flags Date: Sat, 11 May 2024 13:10:51 +0300 Message-Id: <20240511101053.1875596-5-me@deliversmonkey.space> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240511101053.1875596-1-me@deliversmonkey.space> References: <20240511101053.1875596-1-me@deliversmonkey.space> MIME-Version: 1.0 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::62d; envelope-from=baturo.alexey@gmail.com; helo=mail-ej1-x62d.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, 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 @gmail.com) X-ZM-MESSAGEID: 1715422386809100001 Content-Type: text/plain; charset="utf-8" From: Alexey Baturo Signed-off-by: Alexey Baturo Reviewed-by: Richard Henderson Reviewed-by: Alistair Francis Reviewed-by: LIU Zhiwei --- target/riscv/cpu.h | 3 +++ target/riscv/cpu_helper.c | 3 +++ target/riscv/translate.c | 5 +++++ 3 files changed, 11 insertions(+) diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h index 9cac723b19..bbf3a0f64e 100644 --- a/target/riscv/cpu.h +++ b/target/riscv/cpu.h @@ -564,6 +564,9 @@ FIELD(TB_FLAGS, ITRIGGER, 20, 1) FIELD(TB_FLAGS, VIRT_ENABLED, 21, 1) FIELD(TB_FLAGS, PRIV, 22, 2) FIELD(TB_FLAGS, AXL, 24, 2) +/* If pointer masking should be applied and address sign extended */ +FIELD(TB_FLAGS, PM_PMM, 26, 2) +FIELD(TB_FLAGS, PM_SIGNEXTEND, 28, 1) =20 #ifdef TARGET_RISCV32 #define riscv_cpu_mxl(env) ((void)(env), MXL_RV32) diff --git a/target/riscv/cpu_helper.c b/target/riscv/cpu_helper.c index e4a127ca84..3f2473bd73 100644 --- a/target/riscv/cpu_helper.c +++ b/target/riscv/cpu_helper.c @@ -68,6 +68,7 @@ void cpu_get_tb_cpu_state(CPURISCVState *env, vaddr *pc, RISCVCPU *cpu =3D env_archcpu(env); RISCVExtStatus fs, vs; uint32_t flags =3D 0; + bool pm_signext =3D riscv_cpu_virt_mem_enabled(env); =20 *pc =3D env->xl =3D=3D MXL_RV32 ? env->pc & UINT32_MAX : env->pc; *cs_base =3D 0; @@ -138,6 +139,8 @@ void cpu_get_tb_cpu_state(CPURISCVState *env, vaddr *pc, flags =3D FIELD_DP32(flags, TB_FLAGS, VS, vs); flags =3D FIELD_DP32(flags, TB_FLAGS, XL, env->xl); flags =3D FIELD_DP32(flags, TB_FLAGS, AXL, cpu_address_xl(env)); + flags =3D FIELD_DP32(flags, TB_FLAGS, PM_PMM, riscv_pm_get_pmm(env)); + flags =3D FIELD_DP32(flags, TB_FLAGS, PM_SIGNEXTEND, pm_signext); =20 *pflags =3D flags; } diff --git a/target/riscv/translate.c b/target/riscv/translate.c index e5b339b1fa..3f578d6dd8 100644 --- a/target/riscv/translate.c +++ b/target/riscv/translate.c @@ -103,6 +103,9 @@ typedef struct DisasContext { bool vl_eq_vlmax; CPUState *cs; TCGv zero; + /* actual address width */ + uint8_t addr_width; + bool addr_signed; /* Ztso */ bool ztso; /* Use icount trigger for native debug */ @@ -1185,6 +1188,8 @@ static void riscv_tr_init_disas_context(DisasContextB= ase *dcbase, CPUState *cs) ctx->xl =3D FIELD_EX32(tb_flags, TB_FLAGS, XL); ctx->address_xl =3D FIELD_EX32(tb_flags, TB_FLAGS, AXL); ctx->cs =3D cs; + ctx->addr_width =3D 0; + ctx->addr_signed =3D false; ctx->ztso =3D cpu->cfg.ext_ztso; ctx->itrigger =3D FIELD_EX32(tb_flags, TB_FLAGS, ITRIGGER); ctx->zero =3D tcg_constant_tl(0); --=20 2.34.1 From nobody Sat Nov 23 15:25:05 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; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1715422352; cv=none; d=zohomail.com; s=zohoarc; b=JZvvnm7xvSqhTyXHrEYcMfDREOh6oCEKFKNBXmTDA4xYEv1/ovFVEcHeqXUcsgQDRbT0uXmGRMLztfimDCcLa861H0rvxErFfGIbFbtRQZheI2lTFUXJxN/UZYKwg2RtUVBrYHI76O1O3hM+fSZdI/0935F8B6MTGNPA3n/kmU0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1715422352; h=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:Message-Id:Reply-To:To; bh=NChut3Wu3U+/heFB1RR2XoMpJXwZZWmP15KDXMsEMrE=; b=WUL3aG0dO/Kv5BFthcBrIBEO8uNdHDH1oQkJYNowpUpidNUCAJKsXIJ+iX7f0CHZO2JUd9bALjZb9+AkxwabU+sJO3zH4zkSVtk2ANAmwjHa7J+EnX6lrv+dD0kzRxuBbcnwxEMlRDiGUZ0Wc/ZIxwEXtYMYGLWeT7RQIxazM1k= 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1715422352423684.4948338338485; Sat, 11 May 2024 03:12:32 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s5jhI-0005VF-N7; Sat, 11 May 2024 06:11:20 -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 1s5jhF-0005TS-M3; Sat, 11 May 2024 06:11:17 -0400 Received: from mail-ej1-x635.google.com ([2a00:1450:4864:20::635]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s5jhA-0002AQ-5o; Sat, 11 May 2024 06:11:15 -0400 Received: by mail-ej1-x635.google.com with SMTP id a640c23a62f3a-a5a157a1cd1so703841866b.0; Sat, 11 May 2024 03:11:11 -0700 (PDT) Received: from freya.midgard (broadband-188-255-126-251.ip.moscow.rt.ru. [188.255.126.251]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a5a1781d27bsm301687166b.21.2024.05.11.03.11.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 11 May 2024 03:11:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1715422270; x=1716027070; 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=NChut3Wu3U+/heFB1RR2XoMpJXwZZWmP15KDXMsEMrE=; b=Az+Q8f/FFKbNJerkTHZVCPp/xWfayPHyR+maaU0AcyRaARB1GSRspppiXjsvNm4HNP 0Zot4mHDc9jzhiKWRIIbTF04VP0KDjl6pscY913F2yz2E1e1K0+VeA3CKvwISwPZsE1I rE6un5wCvRf1exu0boRDl0EzE/e4KTwfkqE36fbFOUWd9LTiR8KD/d6iJ0wCG1pDUUJD JGZBCcgcn4sP6OwGeU9l5BE7Y9O88Q0kIzm70XoHaPlhFVsont+6cRVRJulitVnjdetH GL+i9PNVUHIudb/DheeC5aGiKpnAxnhJ3squHlHobLOTOhDIK6O2QxzXdvXjrsSIT6/H bCCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715422270; x=1716027070; 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=NChut3Wu3U+/heFB1RR2XoMpJXwZZWmP15KDXMsEMrE=; b=nc/1Oth/2wvvLL1B9zWBabv/QV7dDydgYwUYuiKlJfhf58AdWni52H6It0FCAikVI4 zldVs8HFwLLudB9ygx5yKBrbWzutjwy7DLqL+kDf64Rib3dfxwp084QHIgJF14L80v3b ZUk+EvzV53z6nwhlsa93S2ZCJx74kFewzHo4iWUEeiacUigL9vHs0M+scnygcxloHVxa /nQoZmJvQQe+wcsCrr9xQBvBItAQ01p+zCiUzzuTSvphws/Jtdue2jO+HePD9pu8Ccgb 5y6YwBbEj38qoobxzWKOJv5XJunqM3iyRtqEG9vDpKLqiP2Gg8ZxpMXEsdGspv5wKo4E xX3A== X-Forwarded-Encrypted: i=1; AJvYcCUkJS6qSowkK9ITXnsyTnc5FptYZdj/cgVRpSEDprMdBHy9JhElC41dwbVmMl5g8UMxKo2hZVYTeyegpLuZOwxdWHhKds60lJQh6rwa8P8q0Zguy0O9Tc2HmC9FzA== X-Gm-Message-State: AOJu0YxML0AonAOSqil3MCL7HY9CQUFEB9nIsIfs7ZguRzvSvM03MQ58 HwlrB1Oj4jaAI2rJrxeJ0jyyZqF5NOGM2osAku6dzPjPfXdthJ6B X-Google-Smtp-Source: AGHT+IEl+4bjH/eB2wdq7558gezfPyTy7IojHcKilEbUxFydJuMZsDJQbS5H3MCz/68tLY+lt2lZrw== X-Received: by 2002:a17:906:70c:b0:a59:c28a:7eb4 with SMTP id a640c23a62f3a-a5a2d5d3d2dmr296692166b.44.1715422270505; Sat, 11 May 2024 03:11:10 -0700 (PDT) From: Alexey Baturo X-Google-Original-From: Alexey Baturo To: Cc: baturo.alexey@gmail.com, richard.henderson@linaro.org, space.monkey.delivers@gmail.com, palmer@dabbelt.com, Alistair.Francis@wdc.com, sagark@eecs.berkeley.edu, kbastian@mail.uni-paderborn.de, qemu-devel@nongnu.org, qemu-riscv@nongnu.org, Alistair Francis Subject: [PATCH v9 5/6] target/riscv: Update address modify functions to take into account pointer masking Date: Sat, 11 May 2024 13:10:52 +0300 Message-Id: <20240511101053.1875596-6-me@deliversmonkey.space> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240511101053.1875596-1-me@deliversmonkey.space> References: <20240511101053.1875596-1-me@deliversmonkey.space> MIME-Version: 1.0 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::635; envelope-from=baturo.alexey@gmail.com; helo=mail-ej1-x635.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, 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 @gmail.com) X-ZM-MESSAGEID: 1715422352759100008 Content-Type: text/plain; charset="utf-8" From: Alexey Baturo Signed-off-by: Alexey Baturo Reviewed-by: Richard Henderson Reviewed-by: Alistair Francis --- target/riscv/translate.c | 22 ++++++++++++++++------ target/riscv/vector_helper.c | 13 +++++++++++++ 2 files changed, 29 insertions(+), 6 deletions(-) diff --git a/target/riscv/translate.c b/target/riscv/translate.c index 3f578d6dd8..da46e636f8 100644 --- a/target/riscv/translate.c +++ b/target/riscv/translate.c @@ -580,8 +580,10 @@ static TCGv get_address(DisasContext *ctx, int rs1, in= t imm) TCGv src1 =3D get_gpr(ctx, rs1, EXT_NONE); =20 tcg_gen_addi_tl(addr, src1, imm); - if (get_address_xl(ctx) =3D=3D MXL_RV32) { - tcg_gen_ext32u_tl(addr, addr); + if (ctx->addr_signed) { + tcg_gen_sextract_tl(addr, addr, 0, ctx->addr_width); + } else { + tcg_gen_extract_tl(addr, addr, 0, ctx->addr_width); } =20 return addr; @@ -594,8 +596,10 @@ static TCGv get_address_indexed(DisasContext *ctx, int= rs1, TCGv offs) TCGv src1 =3D get_gpr(ctx, rs1, EXT_NONE); =20 tcg_gen_add_tl(addr, src1, offs); - if (get_xl(ctx) =3D=3D MXL_RV32) { - tcg_gen_ext32u_tl(addr, addr); + if (ctx->addr_signed) { + tcg_gen_sextract_tl(addr, addr, 0, ctx->addr_width); + } else { + tcg_gen_extract_tl(addr, addr, 0, ctx->addr_width); } return addr; } @@ -1188,8 +1192,14 @@ static void riscv_tr_init_disas_context(DisasContext= Base *dcbase, CPUState *cs) ctx->xl =3D FIELD_EX32(tb_flags, TB_FLAGS, XL); ctx->address_xl =3D FIELD_EX32(tb_flags, TB_FLAGS, AXL); ctx->cs =3D cs; - ctx->addr_width =3D 0; - ctx->addr_signed =3D false; + if (get_xl(ctx) =3D=3D MXL_RV32) { + ctx->addr_width =3D 32; + ctx->addr_signed =3D false; + } else { + int pm_pmm =3D FIELD_EX32(tb_flags, TB_FLAGS, PM_PMM); + ctx->addr_width =3D 64 - riscv_pm_get_pmlen(pm_pmm); + ctx->addr_signed =3D FIELD_EX32(tb_flags, TB_FLAGS, PM_SIGNEXTEND); + } ctx->ztso =3D cpu->cfg.ext_ztso; ctx->itrigger =3D FIELD_EX32(tb_flags, TB_FLAGS, ITRIGGER); ctx->zero =3D tcg_constant_tl(0); diff --git a/target/riscv/vector_helper.c b/target/riscv/vector_helper.c index 39ba2a09dd..28861cc509 100644 --- a/target/riscv/vector_helper.c +++ b/target/riscv/vector_helper.c @@ -104,6 +104,19 @@ static inline uint32_t vext_max_elems(uint32_t desc, u= int32_t log2_esz) =20 static inline target_ulong adjust_addr(CPURISCVState *env, target_ulong ad= dr) { + RISCVPmPmm pmm =3D riscv_pm_get_pmm(env); + if (pmm =3D=3D PMM_FIELD_DISABLED) { + return addr; + } + int pmlen =3D riscv_pm_get_pmlen(pmm); + bool signext =3D riscv_cpu_virt_mem_enabled(env); + addr =3D addr << pmlen; + /* sign/zero extend masked address by N-1 bit */ + if (signext) { + addr =3D (target_long)addr >> pmlen; + } else { + addr =3D addr >> pmlen; + } return addr; } =20 --=20 2.34.1 From nobody Sat Nov 23 15:25:05 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; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1715422381; cv=none; d=zohomail.com; s=zohoarc; b=gROZR+qLsbUDq9CincdfkuNs2dnXl7VTHp+nPyoCMkktsKxUUXrGhuFtCG5XfwjA5cEQStglwS++e3x0FXy4Wq8Y2AaAJ4fQrPwVwuXzrxTBG/qOJo+tUBc/luqXdn9tlDUn6FskKMvxn4axm9NokfJephhfbOL5btKSSQlls4A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1715422381; h=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:Message-Id:Reply-To:To; bh=JcjfiQqdszD/zdWCJfe58zMToJNsLVZqVDYZoGGq41I=; b=WVqe118Y9tRX98jMReRheMHaRGp0gmXDPAGIKFuEkQdvbnm1K2vagZc55iKSzdnmqAeMJjG3qQG5jsS9MHFn5lBgkKJP4V8X1Yjs1h6mR7yZpI9D6/qTHr4QCcrhY+smxEfp5cCsooG+ZYzG7KX32m8Vpluj3F9zcsRPPJ/6yRk= 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1715422381154210.30874612849743; Sat, 11 May 2024 03:13:01 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s5jhH-0005V0-Vt; Sat, 11 May 2024 06:11:20 -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 1s5jhD-0005SK-Ub; Sat, 11 May 2024 06:11:15 -0400 Received: from mail-ej1-x632.google.com ([2a00:1450:4864:20::632]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s5jhB-0002Ah-Mo; Sat, 11 May 2024 06:11:15 -0400 Received: by mail-ej1-x632.google.com with SMTP id a640c23a62f3a-a599a298990so681352466b.2; Sat, 11 May 2024 03:11:12 -0700 (PDT) Received: from freya.midgard (broadband-188-255-126-251.ip.moscow.rt.ru. [188.255.126.251]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a5a1781d27bsm301687166b.21.2024.05.11.03.11.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 11 May 2024 03:11:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1715422272; x=1716027072; 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=JcjfiQqdszD/zdWCJfe58zMToJNsLVZqVDYZoGGq41I=; b=I3GX4H4Q5zewIu3Os11Gz9VLZ3eS6wBbEYvF4ysfFg2QJ6vKPE+9ClskxaA25WcCKa ozr6jFm5f7VllDiyzfILh5FoTp2u9mNi2QNytEce1J2vWBNAc9kfH7ZceaFwquMph/DO P63UoMfmXjMAfle7nE4Mxj0euimcGLtLLZcLBYVJFxkIlVFe2dxg00DcrwkdMYP/zP9H Ddjr4ahmVUmPjR7G5IFPwXxHIlHALRhE7o5eS/xcegxQvuRpjbzhzC5DZmsOYaht3VvZ gKAXJSgh4RnhSXtWTgo92NPmguKWt8H2BOWOMTXX1Bo4770kV9JrghGQfw4x9TFnGIDg 3vLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715422272; x=1716027072; 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=JcjfiQqdszD/zdWCJfe58zMToJNsLVZqVDYZoGGq41I=; b=LVWQHcIffTMIL/9DR/ylIjvtLdZFixMX9DskcDKk6vslqoxB7IWH7ARYxzLcw+8wC5 LehfkoQbtqAWoVXuvyX43DyJriWGChIvcCK56Rc+A02G+Tle3neyfkDuxzdk23zVFcXB mN1kI0mrVbiMkT5l3Rub00eDOHMZRIIVT5DPmFVBAIR4DJcuJ9rjis+4rzYCxdbCUb1x eWqN3wzZd3M8GNXfHBhAcHw57W/znWa6AzlVuBYHCIvPOlSDKmHTmgyC2ZEQiYyoOUco y3+GmzcxHNCmTbAz6xPjRrYIOGxvchImCqGzNEn1SGRdsWfZMjP70IXCb07TgbLow3Ic u76w== X-Forwarded-Encrypted: i=1; AJvYcCXCXFngu5sXvOXsN/kbHfowT0roGjHjjdQkFER14l8tcWxG1C7b22Q3sE2Psi56zfLqBpoO5eVlNZBfiLuxto3oQ2LBRe3mureBS9pXQjAZmVV80zpJ+Fy8kDDBCw== X-Gm-Message-State: AOJu0YwnVQCw1lboI+/PmvT3i40zKHM+PtIpzRMCFMum4kmSxlF7HPKh acfMcM5Ysk724WbkNmHQd1+hlbnic6uX+8l2xfW5Zx/1Pwj1jjJ4 X-Google-Smtp-Source: AGHT+IHug6BV5TDF5TUi77yCbX10LzsD5H9oymYIOhNHlZu++vmMVp/oemS4IBT0Q8dOtR80+4hc5w== X-Received: by 2002:a17:906:d9d9:b0:a59:b807:330a with SMTP id a640c23a62f3a-a5a2d55e4b8mr343451166b.32.1715422271976; Sat, 11 May 2024 03:11:11 -0700 (PDT) From: Alexey Baturo X-Google-Original-From: Alexey Baturo To: Cc: baturo.alexey@gmail.com, richard.henderson@linaro.org, space.monkey.delivers@gmail.com, palmer@dabbelt.com, Alistair.Francis@wdc.com, sagark@eecs.berkeley.edu, kbastian@mail.uni-paderborn.de, qemu-devel@nongnu.org, qemu-riscv@nongnu.org, Alistair Francis Subject: [PATCH v9 6/6] target/riscv: Enable updates for pointer masking variables and thus enable pointer masking extension Date: Sat, 11 May 2024 13:10:53 +0300 Message-Id: <20240511101053.1875596-7-me@deliversmonkey.space> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240511101053.1875596-1-me@deliversmonkey.space> References: <20240511101053.1875596-1-me@deliversmonkey.space> MIME-Version: 1.0 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::632; envelope-from=baturo.alexey@gmail.com; helo=mail-ej1-x632.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, 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 @gmail.com) X-ZM-MESSAGEID: 1715422382779100003 Content-Type: text/plain; charset="utf-8" From: Alexey Baturo Signed-off-by: Alexey Baturo Reviewed-by: Alistair Francis --- target/riscv/cpu.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 1e350e9bd8..b3b3a6275f 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -192,6 +192,9 @@ const RISCVIsaExtData isa_edata_arr[] =3D { ISA_EXT_DATA_ENTRY(svinval, PRIV_VERSION_1_12_0, ext_svinval), ISA_EXT_DATA_ENTRY(svnapot, PRIV_VERSION_1_12_0, ext_svnapot), ISA_EXT_DATA_ENTRY(svpbmt, PRIV_VERSION_1_12_0, ext_svpbmt), + ISA_EXT_DATA_ENTRY(ssnpm, PRIV_VERSION_1_12_0, ext_ssnpm), + ISA_EXT_DATA_ENTRY(smnpm, PRIV_VERSION_1_12_0, ext_smnpm), + ISA_EXT_DATA_ENTRY(smmpm, PRIV_VERSION_1_12_0, ext_smmpm), ISA_EXT_DATA_ENTRY(xtheadba, PRIV_VERSION_1_11_0, ext_xtheadba), ISA_EXT_DATA_ENTRY(xtheadbb, PRIV_VERSION_1_11_0, ext_xtheadbb), ISA_EXT_DATA_ENTRY(xtheadbs, PRIV_VERSION_1_11_0, ext_xtheadbs), @@ -1565,6 +1568,11 @@ const RISCVCPUMultiExtConfig riscv_cpu_vendor_exts[]= =3D { =20 /* These are experimental so mark with 'x-' */ const RISCVCPUMultiExtConfig riscv_cpu_experimental_exts[] =3D { + /* Zjpm v0.8 extensions */ + MULTI_EXT_CFG_BOOL("x-ssnpm", ext_ssnpm, false), + MULTI_EXT_CFG_BOOL("x-smnpm", ext_smnpm, false), + MULTI_EXT_CFG_BOOL("x-smmpm", ext_smmpm, false), + DEFINE_PROP_END_OF_LIST(), }; =20 --=20 2.34.1