From nobody Sat Nov 23 15:09:24 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=1732169716; cv=none; d=zohomail.com; s=zohoarc; b=aIZyYIFZbbRk064PEUa+Byp6uKrKUAHuKn1uroTvsVBp7nGS2qPJtAOgdQuWIkdSHFT7DYXhZ5IM2/ITcj0fvsp5Ng4i39G59KsTLzb2fgeGaHb2PmzyfUK3EW892XS5RwWM9so11wpdc8nVowW8Lzb2bM0pVrg4Z+CDLit2RfU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1732169716; 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=UJPLKmO4yX5nRNegJ+opszOwLCqOg7QrhJiCBSbbZDw=; b=WaLqnq+pAfznffsWRB6AfhxaiMTX8LEGbMkT1oJKpDnFsvM92KGKB8kPa9oIi7Nr4oEAmARMv+rPXnJIGtOq7dYibfOUbSC+tud971lUP1lgjbCrGjwk6zHOoBaN54I3LWIle4SYui09n/GE7sA9N0C2YYBTqS0QLnAVGMG/c7k= 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 1732169716838675.9257718326937; Wed, 20 Nov 2024 22:15:16 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tE0RE-0004UB-4V; Thu, 21 Nov 2024 01:13:12 -0500 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 1tE0RC-0004TN-5Y; Thu, 21 Nov 2024 01:13:10 -0500 Received: from mail-lj1-x236.google.com ([2a00:1450:4864:20::236]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tE0R8-0006J1-Vx; Thu, 21 Nov 2024 01:13:09 -0500 Received: by mail-lj1-x236.google.com with SMTP id 38308e7fff4ca-2fb5a9c7420so5910881fa.3; Wed, 20 Nov 2024 22:13:06 -0800 (PST) Received: from vmdev.asgard ([81.200.11.243]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-53dbd4726c3sm840443e87.205.2024.11.20.22.13.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Nov 2024 22:13:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1732169585; x=1732774385; 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=UJPLKmO4yX5nRNegJ+opszOwLCqOg7QrhJiCBSbbZDw=; b=ccsm4X5PO3OBn9BONdd4s0hSJrc6IHVv6hkCPY323vQtaA8j5LalVrJggKy2G+gekA VGv/aWqamhiBFJ01VEjqglrdovTwN6H0EKmtOYh4wffOsrsgYKuutW39k1JAyPxuMlqO CVCsNxhkbbjyZJh0vajRflxlg5JfEoXx3yLItbCiuQSWOL0cHVPHx9lDsu4ocqbCxxrY AeLRsE4mDutQXkXyWCxblZSuqeXAQfx4Uiev5OPGW/k1Aruuzj+rcaM0r7W7yNDAIgbK 2No3heDU52rtM33lfwbrjayYIVr47/B5+n2nsZtyuDH1U3FVQky7XNhYuDOj3rPe7Oz7 pnKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732169585; x=1732774385; 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=UJPLKmO4yX5nRNegJ+opszOwLCqOg7QrhJiCBSbbZDw=; b=K7Qz6AfR9W9SxTiO50wY4Tj6kewwKdy+veDjq7T+UhBwEqPzZkha16v8N1JCMHFnOL b0f72zzQ6hNTjdNW7itEKQ7jvK3OKUQpCGnWbDF9f38OkcGupJGsSFMgK4x3afT41ls0 kFh4lyfNWBzZLwn8VBIENruPOY0uED8xUrt6a+8UAAVRJiG10IfVbl3KTonaSuuSEqR7 pB7hnwZMXUM45MfKkEXitu6KBJJSmAUiKDpeS9ymlDxgj4GCOyrjbxR0vtppxFLW4Lf0 ME+rgDajggqux8IZRVZ6o2B4tOCJUNRrmFcpMBRSSC67jR7+vgwwD6gSC2/na77YFsBl 978Q== X-Forwarded-Encrypted: i=1; AJvYcCUamaFx+DezqaYKzRSIA6N9ohOclOU2fac3v8WL9AVgEjdzUXQ3ewtQufmPMC7pQS2ab1pc6iVKzwyQ@nongnu.org, AJvYcCVUBuRwFyawuhHWMe+VU+kgxRtisdI21C7A++cG5UWAsK5fKZh19IpwTaTZX9NOgq32uaZjwC/xbF4cXw==@nongnu.org X-Gm-Message-State: AOJu0YwTK/zPbUHUtcBULYLSmMnhEaw6z3XKdE0Z6m8797u5fAVfMyjr vtXQCfm5lMR6TMeQEt0VxIuPy1vXJMTi0M5e6lQrKGaEJNT8F+PU X-Google-Smtp-Source: AGHT+IGzYDCtINlo7+eDK/PVJG84odyoCZTVYgmZl1CsMGR/sAQyewTySgsnbES0B5Q+2q5Q6gWMKw== X-Received: by 2002:ac2:464c:0:b0:53b:1fe4:3fb9 with SMTP id 2adb3069b0e04-53dc136f280mr1989143e87.49.1732169584202; Wed, 20 Nov 2024 22:13:04 -0800 (PST) From: baturo.alexey@gmail.com To: Cc: baturo.alexey@gmail.com, richard.henderson@linaro.org, zhiwei_liu@linux.alibaba.com, dbarboza@ventanamicro.com, liwei1518@gmail.com, alistair23@gmail.com, frank.chang@sifive.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 Subject: [PATCH v2 1/7] target/riscv: Remove obsolete pointer masking extension code. Date: Thu, 21 Nov 2024 09:12:53 +0300 Message-Id: <20241121061259.4043177-2-baturo.alexey@gmail.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241121061259.4043177-1-baturo.alexey@gmail.com> References: <20241121061259.4043177-1-baturo.alexey@gmail.com> 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::236; envelope-from=baturo.alexey@gmail.com; helo=mail-lj1-x236.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: 1732169718848116600 Content-Type: text/plain; charset="utf-8" From: Alexey Baturo Zjpm extension is finally ratified. And it's much simplier compared to the = experimental one. The newer version doesn't allow to specify custom mask or base for pointer = masking. Instead it allows only certain options for masking top bits. Signed-off-by: Alexey Baturo --- target/riscv/cpu.c | 13 +- target/riscv/cpu.h | 33 +--- target/riscv/cpu_bits.h | 87 ---------- target/riscv/cpu_helper.c | 52 ------ target/riscv/csr.c | 326 ----------------------------------- target/riscv/machine.c | 17 +- target/riscv/tcg/tcg-cpu.c | 5 +- target/riscv/translate.c | 28 +-- target/riscv/vector_helper.c | 2 +- 9 files changed, 19 insertions(+), 544 deletions(-) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index f219f0c3b5..4e80dcd2e6 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 @@ -793,13 +793,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) { @@ -985,8 +978,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 @@ -1018,7 +1009,6 @@ static void riscv_cpu_reset_hold(Object *obj, ResetTy= pe type) env->ssp =3D 0; =20 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); @@ -1406,7 +1396,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, "b", "Bit manipulation (Zba_Zbb_Zbs)") diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h index 284b112821..e11264231d 100644 --- a/target/riscv/cpu.h +++ b/target/riscv/cpu.h @@ -71,7 +71,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 @@ -451,24 +450,11 @@ 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; - uint64_t mstateen[SMSTATEEN_MAX_COUNT]; uint64_t hstateen[SMSTATEEN_MAX_COUNT]; uint64_t sstateen[SMSTATEEN_MAX_COUNT]; uint64_t henvcfg; #endif - target_ulong cur_pmmask; - target_ulong cur_pmbase; =20 /* Fields from here on are preserved across CPU reset. */ QEMUTimer *stimer; /* Internal timer for S-mode interrupt */ @@ -624,19 +610,19 @@ 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) /* zicfilp needs a TB flag to track indirect branches */ -FIELD(TB_FLAGS, FCFI_ENABLED, 28, 1) -FIELD(TB_FLAGS, FCFI_LP_EXPECTED, 29, 1) +FIELD(TB_FLAGS, FCFI_ENABLED, 26, 1) +FIELD(TB_FLAGS, FCFI_LP_EXPECTED, 27, 1) /* zicfiss needs a TB flag so that correct TB is located based on tb flags= */ -FIELD(TB_FLAGS, BCFI_ENABLED, 30, 1) +FIELD(TB_FLAGS, BCFI_ENABLED, 28, 1) =20 #ifdef TARGET_RISCV32 #define riscv_cpu_mxl(env) ((void)(env), MXL_RV32) @@ -772,7 +758,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 385a2c67c2..2a6aff63ed 100644 --- a/target/riscv/cpu_bits.h +++ b/target/riscv/cpu_bits.h @@ -497,37 +497,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 */ @@ -758,11 +727,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_LPE BIT(2) /* zicfilp */ @@ -801,57 +765,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 0a3ead69ea..696a17461b 100644 --- a/target/riscv/cpu_helper.c +++ b/target/riscv/cpu_helper.c @@ -210,61 +210,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 /* @@ -786,7 +735,6 @@ void riscv_cpu_set_mode(CPURISCVState *env, target_ulon= g newpriv, bool virt_en) /* 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 9846770820..941c9691da 100644 --- a/target/riscv/csr.c +++ b/target/riscv/csr.c @@ -531,16 +531,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) { @@ -1648,7 +1638,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 @@ -4351,302 +4340,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 */ @@ -5316,25 +5009,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 99f0af5077..e40dc73994 100644 --- a/target/riscv/machine.c +++ b/target/riscv/machine.c @@ -152,25 +152,15 @@ 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 { .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.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), =20 VMSTATE_END_OF_LIST() } @@ -266,7 +256,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 c62c221696..179428f3f0 100644 --- a/target/riscv/tcg/tcg-cpu.c +++ b/target/riscv/tcg/tcg-cpu.c @@ -1086,7 +1086,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), @@ -1373,8 +1372,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 | RVB | RVG | RVJ | RVV); + /* Enable RVG and RVV that are disabled by default */ + riscv_cpu_set_misa_ext(env, env->misa_ext | RVB | 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 bccaf8e89a..018be5504f 100644 --- a/target/riscv/translate.c +++ b/target/riscv/translate.c @@ -41,9 +41,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, @@ -105,9 +102,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 */ @@ -591,14 +585,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; } @@ -610,14 +599,10 @@ static TCGv get_address_indexed(DisasContext *ctx, in= t 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 @@ -1245,8 +1230,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->bcfi_enabled =3D FIELD_EX32(tb_flags, TB_FLAGS, BCFI_ENABLED); @@ -1385,9 +1368,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 a85dd1d200..3589e3ef28 100644 --- a/target/riscv/vector_helper.c +++ b/target/riscv/vector_helper.c @@ -107,7 +107,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.39.5 From nobody Sat Nov 23 15:09:24 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 1732169679447191.0753064995405; Wed, 20 Nov 2024 22:14:39 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tE0RD-0004Tw-SQ; Thu, 21 Nov 2024 01:13:11 -0500 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 1tE0RC-0004TM-5G; Thu, 21 Nov 2024 01:13:10 -0500 Received: from mail-lf1-x12f.google.com ([2a00:1450:4864:20::12f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tE0RA-0006J8-43; Thu, 21 Nov 2024 01:13:09 -0500 Received: by mail-lf1-x12f.google.com with SMTP id 2adb3069b0e04-53d9ff8ef3aso502600e87.1; Wed, 20 Nov 2024 22:13:07 -0800 (PST) Received: from vmdev.asgard ([81.200.11.243]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-53dbd4726c3sm840443e87.205.2024.11.20.22.13.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Nov 2024 22:13:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1732169586; x=1732774386; 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=vrCdLZ8Ddyr2Q8mjwb19Axqv6cumMVuY8X4Ma76BPPk=; b=g6sLpoliEa0C14eusIU9tzqBuobQX3zrS3bRSLSiqri1fhEJ4AiqSnVUhh6mc3ZzX+ Y9q3l4FIXlxGJc7qxoYtKetTbZlxR2Pw0mwY/menNPXPA2Ooqun+FtFKTPBZwmto9hiL 86I2NBhsLEMY08CvJ3jLQiFa8I3x2P6k8/hl74wQUiK/vWbF9FGMkOxoY2eSh0zFRASj H79b8OKL9/k/YfPgDW1hpn6rRZiu+GOuZXWJF9a4Hv7CmVKp6k/zw8Yli0RiSpruDPkA XstvH+glaCVXvPEpzSS+fbebFS+eUuKsxUHwmR95f12pdNdVkzx1+ISA+34HZUCKFsID o2pg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732169586; x=1732774386; 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=vrCdLZ8Ddyr2Q8mjwb19Axqv6cumMVuY8X4Ma76BPPk=; b=c1iEUguwddM6eTQucOlkoWEsKKQ1IOIUqOB7RpkAOys81NgpgwyEkILXqF3gMo95ph ObGgY1+l+7YeQoTcDAfuFmhZso2MRs+xr0nuZIyq+BdYQ3GLrhiP0T9mLTKlEednub8U f01DLRhNyQ19HHSrsJQWeaNBUl1lfrGZb1dlR8sQhZfe+S8Tmws0aV0f2oB9dGcRRIME xtCXrnYc3rQyN2c2qrpLK+Gd6knAAmMhRqr07oSFWUFN/5r4a4J4LyWps0cDQS8f8MIz EPpQYgXpBz8aOcB+OE6qlhf8yDHb4viArBIjFu1M137VRxcBN0QzblEqH/+ZEzVaMDGH Pvew== X-Forwarded-Encrypted: i=1; AJvYcCUi0u8nHqDmNu9TDI/SrlLXGeXdrGHDtQh1rDvvMtjolZJoYTsDb1HQQlLSj/Y+Z3jMypHblxt38rOt@nongnu.org, AJvYcCVd7Y6FMQI0e49USOjbo6MYnPLL6PtgVdiAPeEIfjKJYx3dqsnYoEh1t5ngNqf/UngzpU+rAJeqpg9yiA==@nongnu.org X-Gm-Message-State: AOJu0Yz4+MdEKLcqfjP7V+xn3XMwLhiE6MgS3vCyKlkBUybMKnWJpYd7 mv99H30/D0LwPJguIAI9GDjb067icNpNbYWQC7S9rdoLE+2NpOn0 X-Gm-Gg: ASbGnctJYTCLdWTxC/6ZfYJ48mDlVZX1341mVgQzh3P7uCQ9DE4WE108i1tVCf9/L9n om6VUHNr0MBUMDP6jrzzxx+/Bafz2KIe4SmDn2to+C58le3DfMvRKncyKpUtKsNBEjZvrqQBOUX bnwa8SMWx1pCX9ouHV4Uz+fxfLxUnoahw6JjbzvA6wezdhiScTT8puTKzisOfalDicxNpKzQz5u uzp3qp3PZDJe7y7/t+yPpv1Kt5wPBEs7wW5PKWtVDB5jeuI4UF3wxA= X-Google-Smtp-Source: AGHT+IEXYG+GE9fI8JrY+3tupfwK39mKOr7g8xUWqyRlF+q/O5Td9vX5cNwioEO9nZ9Q2H2Et1koSw== X-Received: by 2002:a05:6512:3da6:b0:539:da76:c77e with SMTP id 2adb3069b0e04-53dc1327509mr2456764e87.5.1732169585772; Wed, 20 Nov 2024 22:13:05 -0800 (PST) From: baturo.alexey@gmail.com To: Cc: baturo.alexey@gmail.com, richard.henderson@linaro.org, zhiwei_liu@linux.alibaba.com, dbarboza@ventanamicro.com, liwei1518@gmail.com, alistair23@gmail.com, frank.chang@sifive.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 Subject: [PATCH v2 2/7] target/riscv: Add new CSR fields for S{sn, mn, m}pm extensions as part of Zjpm v1.0 Date: Thu, 21 Nov 2024 09:12:54 +0300 Message-Id: <20241121061259.4043177-3-baturo.alexey@gmail.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241121061259.4043177-1-baturo.alexey@gmail.com> References: <20241121061259.4043177-1-baturo.alexey@gmail.com> 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::12f; envelope-from=baturo.alexey@gmail.com; helo=mail-lf1-x12f.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: 1732169680798116600 Content-Type: text/plain; charset="utf-8" From: Alexey Baturo Signed-off-by: Alexey Baturo --- target/riscv/cpu.h | 8 ++++++++ target/riscv/cpu_bits.h | 4 ++++ target/riscv/cpu_cfg.h | 3 +++ target/riscv/csr.c | 31 ++++++++++++++++++++++++++++++- target/riscv/pmp.c | 14 +++++++++++--- target/riscv/pmp.h | 1 + 6 files changed, 57 insertions(+), 4 deletions(-) diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h index e11264231d..417ff45544 100644 --- a/target/riscv/cpu.h +++ b/target/riscv/cpu.h @@ -128,6 +128,14 @@ typedef enum { EXT_STATUS_DIRTY, } RISCVExtStatus; =20 +/* Enum holds PMM field values for Zjpm v1.0 extension */ +typedef enum { + PMM_FIELD_DISABLED =3D 0, + PMM_FIELD_RESERVED =3D 1, + PMM_FIELD_PMLEN7 =3D 2, + PMM_FIELD_PMLEN16 =3D 3, +} RISCVPmPmm; + typedef struct riscv_cpu_implied_exts_rule { #ifndef CONFIG_USER_ONLY /* diff --git a/target/riscv/cpu_bits.h b/target/riscv/cpu_bits.h index 2a6aff63ed..d8f9bc68e3 100644 --- a/target/riscv/cpu_bits.h +++ b/target/riscv/cpu_bits.h @@ -574,6 +574,7 @@ typedef enum { #define HSTATUS_VTW 0x00200000 #define HSTATUS_VTSR 0x00400000 #define HSTATUS_VSXL 0x300000000 +#define HSTATUS_HUPMM 0x3000000000000 =20 #define HSTATUS32_WPRI 0xFF8FF87E #define HSTATUS64_WPRI 0xFFFFFFFFFF8FF87EULL @@ -734,6 +735,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) @@ -749,6 +751,7 @@ 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_LPE MENVCFG_LPE @@ -756,6 +759,7 @@ typedef enum RISCVException { #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 59d6fc445d..79a114eb07 100644 --- a/target/riscv/cpu_cfg.h +++ b/target/riscv/cpu_cfg.h @@ -128,6 +128,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; bool rvv_vl_half_avl; diff --git a/target/riscv/csr.c b/target/riscv/csr.c index 941c9691da..5389ccb983 100644 --- a/target/riscv/csr.c +++ b/target/riscv/csr.c @@ -575,6 +575,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; } @@ -2379,6 +2382,12 @@ static RISCVException write_menvcfg(CPURISCVState *e= nv, int csrno, if (env_archcpu(env)->cfg.ext_zicfiss) { mask |=3D MENVCFG_SSE; } + + /* Update PMM field only if the value is valid according to Zjpm v= 1.0 */ + if (env_archcpu(env)->cfg.ext_smnpm && + get_field(val, MENVCFG_PMM) !=3D PMM_FIELD_RESERVED) { + mask |=3D MENVCFG_PMM; + } } env->menvcfg =3D (env->menvcfg & ~mask) | (val & mask); =20 @@ -2425,6 +2434,12 @@ static RISCVException write_senvcfg(CPURISCVState *e= nv, int csrno, { uint64_t mask =3D SENVCFG_FIOM | SENVCFG_CBIE | SENVCFG_CBCFE | SENVCF= G_CBZE; RISCVException ret; + /* Update PMM field only if the value is valid according to Zjpm v1.0 = */ + if (env_archcpu(env)->cfg.ext_ssnpm && + riscv_cpu_mxl(env) =3D=3D MXL_RV64 && + get_field(val, SENVCFG_PMM) !=3D PMM_FIELD_RESERVED) { + mask |=3D SENVCFG_PMM; + } =20 ret =3D smstateen_acc_ok(env, 0, SMSTATEEN0_HSENVCFG); if (ret !=3D RISCV_EXCP_NONE) { @@ -2489,6 +2504,12 @@ static RISCVException write_henvcfg(CPURISCVState *e= nv, int csrno, get_field(env->menvcfg, MENVCFG_SSE)) { mask |=3D HENVCFG_SSE; } + + /* Update PMM field only if the value is valid according to Zjpm v= 1.0 */ + if (env_archcpu(env)->cfg.ext_ssnpm && + get_field(val, HENVCFG_PMM) !=3D PMM_FIELD_RESERVED) { + mask |=3D HENVCFG_PMM; + } } =20 env->henvcfg =3D (env->henvcfg & ~mask) | (val & mask); @@ -3525,7 +3546,15 @@ static RISCVException read_hstatus(CPURISCVState *en= v, int csrno, static RISCVException write_hstatus(CPURISCVState *env, int csrno, target_ulong val) { - env->hstatus =3D val; + uint64_t mask =3D (target_ulong)-1; + /* Update PMM field only if the value is valid according to Zjpm v1.0 = */ + if (!env_archcpu(env)->cfg.ext_ssnpm || + riscv_cpu_mxl(env) !=3D MXL_RV64 || + get_field(val, HSTATUS_HUPMM) =3D=3D PMM_FIELD_RESERVED) { + mask &=3D ~HSTATUS_HUPMM; + } + env->hstatus =3D (env->hstatus & ~mask) | (val & mask); + if (riscv_cpu_mxl(env) !=3D MXL_RV32 && get_field(val, HSTATUS_VSXL) != =3D 2) { qemu_log_mask(LOG_UNIMP, "QEMU does not support mixed HSXLEN options."); diff --git a/target/riscv/pmp.c b/target/riscv/pmp.c index a1b36664fc..a185c246d6 100644 --- a/target/riscv/pmp.c +++ b/target/riscv/pmp.c @@ -575,6 +575,13 @@ 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 v1.0 = */ + if (riscv_cpu_cfg(env)->ext_smmpm && + riscv_cpu_mxl(env) =3D=3D MXL_RV64 && + get_field(val, MSECCFG_PMM) !=3D PMM_FIELD_RESERVED) { + mask |=3D MSECCFG_PMM; + } =20 trace_mseccfg_csr_write(env->mhartid, val); =20 @@ -590,12 +597,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 /* M-mode forward cfi to be enabled if cfi extension is implemented */ diff --git a/target/riscv/pmp.h b/target/riscv/pmp.h index e0530a17a3..271cf24169 100644 --- a/target/riscv/pmp.h +++ b/target/riscv/pmp.h @@ -46,6 +46,7 @@ typedef enum { MSECCFG_USEED =3D 1 << 8, MSECCFG_SSEED =3D 1 << 9, MSECCFG_MLPE =3D 1 << 10, + MSECCFG_PMM =3D 3ULL << 32, } mseccfg_field_t; =20 typedef struct { --=20 2.39.5 From nobody Sat Nov 23 15:09:24 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=1732169626; cv=none; d=zohomail.com; s=zohoarc; b=l3VDS0oRx3vEJ2Q7UwhrqScdE94WnRRm8ukeM2heEIs88sW4PnS/yZJFM5XpF2qKRNn70n2lp6XG7vq0Y6v7zYKuEC1ZjWFfYSQQ721vz7dNHkZkrmwhqbvDuwlJG6e4Etuo+bQX6mmzxwyR8MIJpsHJG6aHYlaJKe1C61R//qw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1732169626; 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=ykBzviCP/aURtQhEtJqMDZCa/NEjG4aKeixd/MINorw=; b=iX5GP57BHBUlzCx5XE902qEQgZrrS3dzAdfc4RCbZJ1OMzVFurVdQxsLeWqF2z2vL3bcOuAP2qek3OkHFrsG4MGJJlUg578MKgolb//oaITLXWkaBATSwJezRzaI0pTG5vs7g8OqXATfW0cV5N+ebISfFkcashrB+gwPnyiqtDY= 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 1732169626257898.1763719007839; Wed, 20 Nov 2024 22:13:46 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tE0RJ-0004WK-Lz; Thu, 21 Nov 2024 01:13:19 -0500 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 1tE0RD-0004Tr-KL; Thu, 21 Nov 2024 01:13:11 -0500 Received: from mail-lf1-x129.google.com ([2a00:1450:4864:20::129]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tE0RB-0006JW-PL; Thu, 21 Nov 2024 01:13:11 -0500 Received: by mail-lf1-x129.google.com with SMTP id 2adb3069b0e04-53da5511f3cso464852e87.3; Wed, 20 Nov 2024 22:13:08 -0800 (PST) Received: from vmdev.asgard ([81.200.11.243]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-53dbd4726c3sm840443e87.205.2024.11.20.22.13.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Nov 2024 22:13:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1732169587; x=1732774387; 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=ykBzviCP/aURtQhEtJqMDZCa/NEjG4aKeixd/MINorw=; b=mv8VcpxC3sobBvwXzFUbCKsYEqNtYXlVphkr6Zxq9La8L88CReAY1tvyCyjzuUgTc8 c6h/yY9pUcn6Sb4KCfyZ7xE5vYh4EmxymwnW3y0cwWAo03CJx4cVZwEtji4Gjyy/hlYZ V2rorsgPnRUSFenXIgHxkcnk70VP2aT5W5mW0si3T/n/2LFCR9VRC1bGW3Tl2LRbLu0e RU3SOZ5TEmKLNjvkgedw931D4b9OxICStlOix6hCprYLfQ2m6ro6Niexw/eWzvjnZdK9 9cS5vPHWmAEF6aI6l7WvUb3ryRljlxKXFJqFd/ip9ElQST80PpHBvpI8Y32/RR4Mhd2k o7jg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732169587; x=1732774387; 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=ykBzviCP/aURtQhEtJqMDZCa/NEjG4aKeixd/MINorw=; b=CFHDcon65M0dRcCAOCxv5/OHojnAgyKbUATPW1tVS6ZWEAj0e9FUdLkBvmxtA8P5bs l4UIsFPKh6cg2vRz5kocxI/A0DwnXztwL8o0WBXFkXT4PqhXcT0pakD5uQczUmA/bOgS OJqyI+vBgEiXB1p4AhO+zwR6GiGxY8n+LdHcL4ME+g39j1rO5pk+cNG0DUDbwsb1ew1K T0R9PPIrDbVmhgfJlYQMgwY2XOpQW40NFqsyrxUMuwntkNKBlV6+C5N0+TUwRVs8KmAh ez5zU+dc3K3yg3tIwCMBvmbCU6+r3aEnmZLSKTNeI4wI6cnrbro/5C40ARlm3W7LlRCv xI4w== X-Forwarded-Encrypted: i=1; AJvYcCUmMVB2TU1bQ0yMD3Xja0coH7jpS4IDcFuJd3vCXdkq2DdKrhJ6pBHbkM/EK+5Ai8Ruh31s+6c0gH7QLw==@nongnu.org, AJvYcCX1QvvrLtrw7HRxnTPORbjJ/u1Nksvay3W4juPblcvtjbb+iuHLXqQrwl0y1mSItQXZvHLm9B4+7gEX@nongnu.org X-Gm-Message-State: AOJu0YxNP4khBa+1lEJ+enPMYjwYP2ydGL91x2FhMn+7O9heZ+TW7Pvi mXCTyoZ3pKgvoimtYLcStyQec1JeArY26c3y2bEjRVYGhZm6N6dX X-Google-Smtp-Source: AGHT+IHMmbNyHlVSjuUSR+t9o4CoQKnE37K1cJ+3uOfgvMHbuWD8cWCc5CFL0cKjnSk3DncCIS96eg== X-Received: by 2002:a05:6512:2385:b0:539:9490:7257 with SMTP id 2adb3069b0e04-53dc13478bamr2370680e87.30.1732169587421; Wed, 20 Nov 2024 22:13:07 -0800 (PST) From: baturo.alexey@gmail.com To: Cc: baturo.alexey@gmail.com, richard.henderson@linaro.org, zhiwei_liu@linux.alibaba.com, dbarboza@ventanamicro.com, liwei1518@gmail.com, alistair23@gmail.com, frank.chang@sifive.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 Subject: [PATCH v2 3/7] target/riscv: Add helper functions to calculate current number of masked bits for pointer masking Date: Thu, 21 Nov 2024 09:12:55 +0300 Message-Id: <20241121061259.4043177-4-baturo.alexey@gmail.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241121061259.4043177-1-baturo.alexey@gmail.com> References: <20241121061259.4043177-1-baturo.alexey@gmail.com> 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::129; envelope-from=baturo.alexey@gmail.com; helo=mail-lf1-x129.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: 1732169626889116600 Content-Type: text/plain; charset="utf-8" From: Alexey Baturo Signed-off-by: Alexey Baturo --- target/riscv/cpu.h | 5 +++ target/riscv/cpu_helper.c | 74 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 79 insertions(+) diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h index 417ff45544..74d7076f5a 100644 --- a/target/riscv/cpu.h +++ b/target/riscv/cpu.h @@ -768,8 +768,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 696a17461b..da2a10384a 100644 --- a/target/riscv/cpu_helper.c +++ b/target/riscv/cpu_helper.c @@ -214,6 +214,80 @@ void cpu_get_tb_cpu_state(CPURISCVState *env, vaddr *p= c, *pflags =3D flags; } =20 +RISCVPmPmm riscv_pm_get_pmm(CPURISCVState *env) +{ + RISCVPmPmm pmm =3D PMM_FIELD_DISABLED; +#ifndef CONFIG_USER_ONLY + if (get_field(env->mstatus, MSTATUS_MPRV) && + get_field(env->mstatus, MSTATUS_MXR)) { + return pmm; + } + int priv_mode =3D cpu_address_mode(env); + /* Get current PMM field */ + switch (priv_mode) { + case PRV_M: + if (riscv_cpu_cfg(env)->ext_smmpm) { + pmm =3D get_field(env->mseccfg, MSECCFG_PMM); + } + break; + case PRV_S: + if (riscv_cpu_cfg(env)->ext_smnpm) { + if (get_field(env->mstatus, MSTATUS_MPV)) { + pmm =3D get_field(env->henvcfg, HENVCFG_PMM); + } else { + pmm =3D get_field(env->menvcfg, MENVCFG_PMM); + } + } + break; + case PRV_U: + if (riscv_has_ext(env, RVS)) { + if (riscv_cpu_cfg(env)->ext_ssnpm) { + pmm =3D get_field(env->senvcfg, SENVCFG_PMM); + } + } else { + if (riscv_cpu_cfg(env)->ext_smnpm) { + pmm =3D get_field(env->menvcfg, MENVCFG_PMM); + } + } + 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); + 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.39.5 From nobody Sat Nov 23 15:09:24 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=1732169716; cv=none; d=zohomail.com; s=zohoarc; b=R4Iy1RfOEAaoXy0kMuDqJnGEBIsnRs6HAlwbnpfL3AjGbkEgf/NSnDX0VNYl+kNPu5oMd+xhtqR8w53rVkSxenpcSSXXe2ZAIJQLOm4t9Qy0UgKwDKQnhF6Ihl0p3i0J4azJFAq2s9/pw2qEo6W9Ku6zO2M2lFXqTkRncJn5wTM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1732169716; 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=rjQFE0vWqMf/ZtDxRzOt57Rq4yMHkB5JeBgxsCZwEu4=; b=Xd4YQ4802uyTbOLaxnCcHY9eHwH48Bqe2X2gxHxajmEuUk5GbLOIw88oQeNFcK/o0HjH+/PS2WFv1wTyW208Eiy8tTfEQVVDZ6dmSOXgvDoRHqzjbMYqZIvCnRHBFZOK+bYpxD9O7hTJnIdQmqOZmge4n2zK+F9L1pkYlAyCcjI= 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 1732169716468221.38299662704026; Wed, 20 Nov 2024 22:15:16 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tE0RR-0004Y7-Kj; Thu, 21 Nov 2024 01:13:27 -0500 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 1tE0RE-0004Uc-QG; Thu, 21 Nov 2024 01:13:12 -0500 Received: from mail-lj1-x22b.google.com ([2a00:1450:4864:20::22b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tE0RD-0006Jn-4E; Thu, 21 Nov 2024 01:13:12 -0500 Received: by mail-lj1-x22b.google.com with SMTP id 38308e7fff4ca-2ff589728e4so18555371fa.1; Wed, 20 Nov 2024 22:13:10 -0800 (PST) Received: from vmdev.asgard ([81.200.11.243]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-53dbd4726c3sm840443e87.205.2024.11.20.22.13.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Nov 2024 22:13:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1732169589; x=1732774389; 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=rjQFE0vWqMf/ZtDxRzOt57Rq4yMHkB5JeBgxsCZwEu4=; b=auvcku7jo9YVhJcxBW+BcZNLFhr0mvLvu/kZxovjKVIkrn04Bcz1kUIKbre2L3BQMg qyQVlhR2MBp2FMPHJpub13y9fZ1Ubm1YQXDpzXY4NqV3xvLfD31V/lH+N/mZFLH7ihTP mw/hkl7vkjJxdvIW+IvO65fy2/ThAFBlfOHbHgUn5FE25Ovf8brGpgsjj18w4JWyILt7 KRsG8dqOBufCQnpnSjxo1dtOvAnlqzcRolMNNmDxOLSEPbYktZOez6+Lm4f/Yx6RZ07+ AVGHUTYPq+0wV4M8FyBUL4fV1R/g78cVPUfHSUspfuPUKDyKM4Z/1/gyA90it3V6cNy6 iEOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732169589; x=1732774389; 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=rjQFE0vWqMf/ZtDxRzOt57Rq4yMHkB5JeBgxsCZwEu4=; b=q6iGs4lsqoCTcn6AwvGfe2yDVu7bvxkAbUfRnOGR3oQetc6dPoRayDt1YDHrHL2bK5 7VLl2FISi3sjTz4jzetXmdwdOWc/jrH1qJdpVf2zYbQXAF5hZJrZEU/FaIcxbSEMiq5w IJDKEjZX8CirDoWsGRmdrIBlOy7uv88eO9VDH5gKOoRZxzmV3UGWB/33lO2lW9xtJXf+ u3VNQS1nPfqt0G7DSTSbGD9GSuabGAb4nRa8tylw8oNatyq71T9vt/fBtE2I55OrSBtk eZacUmtTBg23QqSIqVT/Miquapl25LfaFNEd7dTd4FNXGni93mpM0qTcZ8Pfaln0Y37Z jnaw== X-Forwarded-Encrypted: i=1; AJvYcCXK7vkfNY9jNgFFmEI75GJ9zeE9MTINxWBGJx9FiUdJjUha5zq+TIXlHNWZQroUrZRoNsT3WY+dxzx2Lw==@nongnu.org, AJvYcCXy7mZtnQ2J4vtekhFdEW/19GvCu4ck5SFNJCeoC1zzCJmaQz06HrwjfV2xhlOksDNCl5ZRclXrWaRh@nongnu.org X-Gm-Message-State: AOJu0YyPR2ScKzEa56E2+w1dredoRbrc3danG1GRRuazYsSPYO5X6KZ6 Fsj/rPbsQjNCXw4W1ZZuqxTOR1g50DQJGJKBeBMI8AEuuqND9FGB X-Google-Smtp-Source: AGHT+IHRRDdyIMHZc6j5rPLh3Y7rB0X+J+RZYWAvF0v0yiBsC7zIYlG1moH17ATU8MsAeMv93FOpbA== X-Received: by 2002:a05:6512:3599:b0:53d:c646:f7ed with SMTP id 2adb3069b0e04-53dc646f7fbmr469461e87.24.1732169588937; Wed, 20 Nov 2024 22:13:08 -0800 (PST) From: baturo.alexey@gmail.com To: Cc: baturo.alexey@gmail.com, richard.henderson@linaro.org, zhiwei_liu@linux.alibaba.com, dbarboza@ventanamicro.com, liwei1518@gmail.com, alistair23@gmail.com, frank.chang@sifive.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 Subject: [PATCH v2 4/7] target/riscv: Add pointer masking tb flags Date: Thu, 21 Nov 2024 09:12:56 +0300 Message-Id: <20241121061259.4043177-5-baturo.alexey@gmail.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241121061259.4043177-1-baturo.alexey@gmail.com> References: <20241121061259.4043177-1-baturo.alexey@gmail.com> 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::22b; envelope-from=baturo.alexey@gmail.com; helo=mail-lj1-x22b.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: 1732169716968116600 Content-Type: text/plain; charset="utf-8" From: Alexey Baturo Signed-off-by: Alexey Baturo --- 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 74d7076f5a..11e3a6d647 100644 --- a/target/riscv/cpu.h +++ b/target/riscv/cpu.h @@ -631,6 +631,9 @@ FIELD(TB_FLAGS, FCFI_ENABLED, 26, 1) FIELD(TB_FLAGS, FCFI_LP_EXPECTED, 27, 1) /* zicfiss needs a TB flag so that correct TB is located based on tb flags= */ FIELD(TB_FLAGS, BCFI_ENABLED, 28, 1) +/* If pointer masking should be applied and address sign extended */ +FIELD(TB_FLAGS, PM_PMM, 29, 2) +FIELD(TB_FLAGS, PM_SIGNEXTEND, 31, 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 da2a10384a..78b461a5cf 100644 --- a/target/riscv/cpu_helper.c +++ b/target/riscv/cpu_helper.c @@ -126,6 +126,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; @@ -210,6 +211,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 018be5504f..bb92f36ba1 100644 --- a/target/riscv/translate.c +++ b/target/riscv/translate.c @@ -102,6 +102,9 @@ typedef struct DisasContext { bool vl_eq_vlmax; CPUState *cs; TCGv zero; + /* actual address width */ + uint8_t addr_xl; + bool addr_signed; /* Ztso */ bool ztso; /* Use icount trigger for native debug */ @@ -1230,6 +1233,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_xl =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->bcfi_enabled =3D FIELD_EX32(tb_flags, TB_FLAGS, BCFI_ENABLED); --=20 2.39.5 From nobody Sat Nov 23 15:09:24 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=1732169692; cv=none; d=zohomail.com; s=zohoarc; b=e/RYpD3DJDXA7pQ8TmK1T1HKb5gAXDWWyxAZJ7Czwame/aK45RqRE2J8kwWF7U+U6pRgqs1tpKGaaAXnTfWWO367Vbpgxekm5rGw9pZxeITpGHawJwqLTh23oEekJxe/kSVmqm5x6YWHmuQo08+c8dfiOGw40dWRmOJcy3/dr/M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1732169692; 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=d9Yx+m45Z3IA5MQqTq1nye6R+DqtOBMOd+bbwpRHyqM=; b=hedyJ+pVTP8o1hJsjvomlgOFJ3Eskah2pVOq1PMGzW5jQEDV/bezxd+DM9uproubKptfhGdS9S7jMdP0zn5nJYjZhER8KsDiKvjBSRM1UZpBDklOof8kyg8yngaMHvUNa/JkcbjBibJnuoMzfXW63Z919+F5clPPIXpY6ZFCdAE= 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 1732169692132844.6423882467495; Wed, 20 Nov 2024 22:14:52 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tE0RN-0004X9-Gj; Thu, 21 Nov 2024 01:13:21 -0500 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 1tE0RG-0004VR-KE; Thu, 21 Nov 2024 01:13:14 -0500 Received: from mail-lf1-x12b.google.com ([2a00:1450:4864:20::12b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tE0RE-0006KO-Sb; Thu, 21 Nov 2024 01:13:14 -0500 Received: by mail-lf1-x12b.google.com with SMTP id 2adb3069b0e04-539e8607c2aso506484e87.3; Wed, 20 Nov 2024 22:13:12 -0800 (PST) Received: from vmdev.asgard ([81.200.11.243]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-53dbd4726c3sm840443e87.205.2024.11.20.22.13.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Nov 2024 22:13:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1732169590; x=1732774390; 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=d9Yx+m45Z3IA5MQqTq1nye6R+DqtOBMOd+bbwpRHyqM=; b=X+twPG5kFQsKwdlWcr0qAZyh4FTQSwTgb/S0Wrz+COnahDCbe3etqanCV45Sg4I5/e awNNvHRfu23lKUzMTmcOEpSyaopJ2UniknjqN/j3oysAEbLm7dngP6W7O/hbW7ZH1txl 73rt2EWWyl05lOU6FXz/it6qnfHHv8mpu4+6HeImD6UWG/EBwcmzYHhJ/4Ii9rzdzBPb M3vtX267El44Ps/O42OtqY8H2xqo7VB03zmCzuGG4khkUiW/GySWnVI8mO9GuaSYPwoO QyxpJ1zOh8fQNT4pa9jqINuNbSU/iHuK3ruri4yaaHqn7LjN3tkUPJBVTgMKKwIwlI+Z AqXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732169590; x=1732774390; 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=d9Yx+m45Z3IA5MQqTq1nye6R+DqtOBMOd+bbwpRHyqM=; b=pgBcoD+OEr5wtLsjmMUpHOI6hD8q7+yS2DEfHth/LSBZCpEKybFiUlzRUaApqrXDCC NlIRHoWVNzvREqrvYz1qXcB4dFJY1qcEtJYT27yRT3USIBQAr3QgFAjUDmxsGHXJgdHI TcvwidKVoJkpkL3EJNL+RkT8tlZqTW+7RWa37BI9vXxxxqoWHW59j0BpL8gW+siLbQ9t 4SAE+cAjTk98Fiv0OueXWrc9KMKvbczkq4Q3Uhf1STaNae16u/FeG92GqPe2FuNtdTNB 04jUxjFb4pLSQOiodiIePiQskZkNbPAaMJtOf4N3YMHN6XXWgypd8mKsDhezirGsw9Ih ROUQ== X-Forwarded-Encrypted: i=1; AJvYcCUvNd2Cj0EuWFg9HE5LLN7Segxn6pIJJCFcNVjkQBzlm1oN1G+F7S3IQsa/mVNloBRWSjSFyrEgoWZt@nongnu.org, AJvYcCXPocTzASlMfsKnEkOMrfdsXzNo9mjxp8hQkz+tnv2TRcDMwAfUTV+CHfUaxqOHH8jPgvT6TKwLgnWD6g==@nongnu.org X-Gm-Message-State: AOJu0YwJLkO4JrJ+EFBMmPXcPiwv3FdUkgdtUpmKA5nOjfi+fZkn0UPV hSSiWKy3Q5cZtA69f51ZMqAPPs41XojnQKPjurY+id1sJ4EJqVOJ X-Gm-Gg: ASbGnctMudZE9Brg8TN+xGLIeqw5ZlkNNDZVK+0iwPlOMSSY8kYhAGuMdTP8UbH6iwM CK8AqzIB8NCUwpNPV7V+1BsLPANdw62osaZzFeawZEyFxIruHLGSmoWGPgFMsyazBSydA0VZO2v H4Z18ZbvAYDfIKvCRkvbmIiKOEK/nq5TFGrzEvAMEZGZuJRSNhpJvfflOUxOZdBSS506Nm8U/0j 1yRwYjKhCVNChxzQk2VVrtdDbnCPDTnGD3VNd54JAdS7Z1m6Yc5KT4= X-Google-Smtp-Source: AGHT+IGLq8XXL01oKHJQhFK0Fveunol4tNHf4LWp3y9sU6lSUXbfLcP+AHgLgXuYGylF2PmMFfMrug== X-Received: by 2002:ac2:48ba:0:b0:53d:ab10:234a with SMTP id 2adb3069b0e04-53dc1333888mr1786175e87.21.1732169590415; Wed, 20 Nov 2024 22:13:10 -0800 (PST) From: baturo.alexey@gmail.com To: Cc: baturo.alexey@gmail.com, richard.henderson@linaro.org, zhiwei_liu@linux.alibaba.com, dbarboza@ventanamicro.com, liwei1518@gmail.com, alistair23@gmail.com, frank.chang@sifive.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 Subject: [PATCH v2 5/7] target/riscv: Update address modify functions to take into account pointer masking Date: Thu, 21 Nov 2024 09:12:57 +0300 Message-Id: <20241121061259.4043177-6-baturo.alexey@gmail.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241121061259.4043177-1-baturo.alexey@gmail.com> References: <20241121061259.4043177-1-baturo.alexey@gmail.com> 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::12b; envelope-from=baturo.alexey@gmail.com; helo=mail-lf1-x12b.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: 1732169692879116600 Content-Type: text/plain; charset="utf-8" From: Alexey Baturo Signed-off-by: Alexey Baturo --- target/riscv/translate.c | 22 ++++++++++++++++------ target/riscv/vector_helper.c | 16 ++++++++++++++++ 2 files changed, 32 insertions(+), 6 deletions(-) diff --git a/target/riscv/translate.c b/target/riscv/translate.c index bb92f36ba1..32df295123 100644 --- a/target/riscv/translate.c +++ b/target/riscv/translate.c @@ -588,8 +588,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_xl); + } else { + tcg_gen_extract_tl(addr, addr, 0, ctx->addr_xl); } =20 return addr; @@ -602,8 +604,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_xl); + } else { + tcg_gen_extract_tl(addr, addr, 0, ctx->addr_xl); } =20 return addr; @@ -1233,8 +1237,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_xl =3D 0; - ctx->addr_signed =3D false; + if (get_xl(ctx) =3D=3D MXL_RV32) { + ctx->addr_xl =3D 32; + ctx->addr_signed =3D false; + } else { + int pm_pmm =3D FIELD_EX32(tb_flags, TB_FLAGS, PM_PMM); + ctx->addr_xl =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->bcfi_enabled =3D FIELD_EX32(tb_flags, TB_FLAGS, BCFI_ENABLED); diff --git a/target/riscv/vector_helper.c b/target/riscv/vector_helper.c index 3589e3ef28..37c6c198a5 100644 --- a/target/riscv/vector_helper.c +++ b/target/riscv/vector_helper.c @@ -107,6 +107,22 @@ 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) { + if (riscv_cpu_mxl(env) =3D=3D MXL_RV32) { + return addr; + } + 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.39.5 From nobody Sat Nov 23 15:09:24 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=1732169691; cv=none; d=zohomail.com; s=zohoarc; b=YgF8B6dV628+NhPIoVd5Tfhya5psFfmHik9baAaIEisLvE6Sf2gfiXRvMQ8fufLcDb51SgKDP/73p+m4Gc2qXhzmFWRKVk2MnxdemmG+Lun06B/9rYptmQ/s8uT6u++7i/P1QBv0/a2l3ANd3/lQnF9vUrmGhJikkEZ+h5dHwGU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1732169691; 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=gwcJT32j32KKKz/tCRrugf9yi6vjemEK7dj9TrpBfM8=; b=OksabF6bK4OwQzBmU69i7pkFEEtVq8Yf6K7yvmPRokGVUxDNhBrKBCOXlPs1/FDptgl4ntsSDKheoMxZDTc8pxW3jndBB7xYHtRD2HFvi4mXnwFlon22eK2pQhc6vwu2MOPMqDAgIfMJjCHEM4p2WLwe8tPnV51UgmLBpIe2hNI= 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 1732169691285869.5956799186891; Wed, 20 Nov 2024 22:14:51 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tE0Rc-0004Zm-Tl; Thu, 21 Nov 2024 01:13:36 -0500 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 1tE0RI-0004Wa-E1; Thu, 21 Nov 2024 01:13:17 -0500 Received: from mail-lf1-x134.google.com ([2a00:1450:4864:20::134]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tE0RG-0006Kp-J2; Thu, 21 Nov 2024 01:13:16 -0500 Received: by mail-lf1-x134.google.com with SMTP id 2adb3069b0e04-53c779ef19cso498787e87.3; Wed, 20 Nov 2024 22:13:13 -0800 (PST) Received: from vmdev.asgard ([81.200.11.243]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-53dbd4726c3sm840443e87.205.2024.11.20.22.13.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Nov 2024 22:13:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1732169592; x=1732774392; 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=gwcJT32j32KKKz/tCRrugf9yi6vjemEK7dj9TrpBfM8=; b=IIGyLunvs6FQupyldKfdXuXvw4/gAK5FpclSkKgZJfUHEcLY/y+GGKIlkxfgrLosmK 87hZfbQMaptN3Jp9wAv3CO3t8JQwPVVLcpM+uEJo2cfLyHR/Pue2nWID14B1N9dKdqMH pWS+Fng9n5lxLdZ63E61NqX/pR4ZI0k1oUvzcPDWWd1WUGvW+OaQG5jSDO4SyaEhg1UE VbVyiPbBSEB2bE38PO3nHvyTNmH32NONc2sEujWWZdH9ml4XLnCg8khLdGXDTO+l/qTD WpUdwxRw/b9ajvVmVUtC2V7pOGZWKuG/HqZepsi75LZb7yOX9d5T7JInws6RVTsK8YU/ 7xUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732169592; x=1732774392; 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=gwcJT32j32KKKz/tCRrugf9yi6vjemEK7dj9TrpBfM8=; b=CrqldzuMSnQmZG/0swNiCnGfqmGTfGNlSASJr5AqxP1A+CyTNVH0LCqqBy+L1WuZyu 1A+QdIYBw1pZebmOQzMJn362cCQD1LwdN0ghovpIQYqYdZzk7tZWq7d/YEKbkXhOzWU+ 7PbTInayJUu7q8do2ow0BEMzztplca+CLtBxajPZiNC/VyHDpplJ/pHOVSPNH9ksFX88 e670InBHkJbkdNdhxNKbXcxcnO7MPx8iT3L8tUYaNpoGJJnXqL3BQ/z7RiuNkpRrfRoD EUtW2Zy82Pg1M+x+3lmzE/US5MxDafMpDk5pqDfQLXWBY5HNidNbCRhlPssE9+hYR3xl X9Qg== X-Forwarded-Encrypted: i=1; AJvYcCVoB5HmF37uYANw3KWMSpc5EGAnvnPCTzMrFiHBeiEZJ1Bp3/sjMtIJ2b0kk1V/Rj2r16BZW3qQ+xpJ2Q==@nongnu.org, AJvYcCXjNTzyinUqkKH4soONRsZhLUzrZWtLmr9LhJce+yyPX5DaNwZ25E8JlsBMgW/RWkg/hzOWfz2hS+Qy@nongnu.org X-Gm-Message-State: AOJu0YzUNlKD18YxHs5wbKu2eRFaHa8FlbYT1H8HUv6LuJytxNW7dgzf 78JdkgkUxoEylkKNQkDCTaBAfHcEvdJiLObLsNGQFa2bBlyFHNbV X-Google-Smtp-Source: AGHT+IG6FfjP2NF19F0ASBrLYxaqH1b+MM5wn9wmBRoZxON33mvIkYXf+TV+S6GQJC9TzMWyZvq0NQ== X-Received: by 2002:a05:6512:3044:b0:539:f5a9:b224 with SMTP id 2adb3069b0e04-53dc1323555mr2207662e87.11.1732169592323; Wed, 20 Nov 2024 22:13:12 -0800 (PST) From: baturo.alexey@gmail.com To: Cc: baturo.alexey@gmail.com, richard.henderson@linaro.org, zhiwei_liu@linux.alibaba.com, dbarboza@ventanamicro.com, liwei1518@gmail.com, alistair23@gmail.com, frank.chang@sifive.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 Subject: [PATCH v2 6/7] target/riscv: Apply pointer masking for virtualized memory accesses Date: Thu, 21 Nov 2024 09:12:58 +0300 Message-Id: <20241121061259.4043177-7-baturo.alexey@gmail.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241121061259.4043177-1-baturo.alexey@gmail.com> References: <20241121061259.4043177-1-baturo.alexey@gmail.com> 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::134; envelope-from=baturo.alexey@gmail.com; helo=mail-lf1-x134.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: 1732169692883116600 Content-Type: text/plain; charset="utf-8" From: Alexey Baturo Signed-off-by: Alexey Baturo --- target/riscv/cpu.h | 2 ++ target/riscv/cpu_helper.c | 19 +++++++++++++++++++ target/riscv/insn_trans/trans_rvh.c.inc | 11 +++++++++++ target/riscv/translate.c | 4 ++++ 4 files changed, 36 insertions(+) diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h index 11e3a6d647..6bbd9c6c25 100644 --- a/target/riscv/cpu.h +++ b/target/riscv/cpu.h @@ -634,6 +634,7 @@ FIELD(TB_FLAGS, BCFI_ENABLED, 28, 1) /* If pointer masking should be applied and address sign extended */ FIELD(TB_FLAGS, PM_PMM, 29, 2) FIELD(TB_FLAGS, PM_SIGNEXTEND, 31, 1) +FIELD(TB_FLAGS, PM_VPMM, 32, 2) =20 #ifdef TARGET_RISCV32 #define riscv_cpu_mxl(env) ((void)(env), MXL_RV32) @@ -773,6 +774,7 @@ bool riscv_cpu_is_32bit(RISCVCPU *cpu); =20 bool riscv_cpu_virt_mem_enabled(CPURISCVState *env); RISCVPmPmm riscv_pm_get_pmm(CPURISCVState *env); +RISCVPmPmm riscv_pm_get_virt_pmm(CPURISCVState *env); int riscv_pm_get_pmlen(RISCVPmPmm pmm); =20 RISCVException riscv_csrr(CPURISCVState *env, int csrno, diff --git a/target/riscv/cpu_helper.c b/target/riscv/cpu_helper.c index 78b461a5cf..4065809d9f 100644 --- a/target/riscv/cpu_helper.c +++ b/target/riscv/cpu_helper.c @@ -213,6 +213,7 @@ void cpu_get_tb_cpu_state(CPURISCVState *env, vaddr *pc, 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); + flags =3D FIELD_DP64(flags, TB_FLAGS, PM_VPMM, riscv_pm_get_virt_pmm(e= nv)); =20 *pflags =3D flags; } @@ -260,6 +261,24 @@ RISCVPmPmm riscv_pm_get_pmm(CPURISCVState *env) return pmm; } =20 +RISCVPmPmm riscv_pm_get_virt_pmm(CPURISCVState *env) +{ + RISCVPmPmm pmm =3D PMM_FIELD_DISABLED; +#ifndef CONFIG_USER_ONLY + int priv_mode =3D cpu_address_mode(env); + if (priv_mode =3D=3D PRV_U) { + pmm =3D get_field(env->hstatus, HSTATUS_HUPMM); + } else { + if (get_field(env->hstatus, HSTATUS_SPVP)) { + pmm =3D get_field(env->henvcfg, HENVCFG_PMM); + } else { + pmm =3D get_field(env->senvcfg, SENVCFG_PMM); + } + } +#endif + return pmm; +} + bool riscv_cpu_virt_mem_enabled(CPURISCVState *env) { bool virt_mem_en =3D false; diff --git a/target/riscv/insn_trans/trans_rvh.c.inc b/target/riscv/insn_tr= ans/trans_rvh.c.inc index 03c6694430..ae067789d1 100644 --- a/target/riscv/insn_trans/trans_rvh.c.inc +++ b/target/riscv/insn_trans/trans_rvh.c.inc @@ -44,6 +44,14 @@ static bool do_hlv(DisasContext *ctx, arg_r2 *a, TCGv dest =3D dest_gpr(ctx, a->rd); TCGv addr =3D get_gpr(ctx, a->rs1, EXT_NONE); =20 + bool is_hlvx =3D (func =3D=3D gen_helper_hyp_hlvx_hu) || + (func =3D=3D gen_helper_hyp_hlvx_wu); + + /* Apply Zjpm pointer masking */ + if (!is_hlvx) { + tcg_gen_sextract_tl(addr, addr, 0, ctx->addr_vxl); + } + decode_save_opc(ctx, 0); func(dest, tcg_env, addr); gen_set_gpr(ctx, a->rd, dest); @@ -56,6 +64,9 @@ static bool do_hsv(DisasContext *ctx, arg_r2_s *a, TCGv addr =3D get_gpr(ctx, a->rs1, EXT_NONE); TCGv data =3D get_gpr(ctx, a->rs2, EXT_NONE); =20 + /* Apply Zjpm pointer masking */ + tcg_gen_sextract_tl(addr, addr, 0, ctx->addr_vxl); + decode_save_opc(ctx, 0); func(tcg_env, addr, data); return true; diff --git a/target/riscv/translate.c b/target/riscv/translate.c index 32df295123..d8f83315c6 100644 --- a/target/riscv/translate.c +++ b/target/riscv/translate.c @@ -104,6 +104,7 @@ typedef struct DisasContext { TCGv zero; /* actual address width */ uint8_t addr_xl; + uint8_t addr_vxl; bool addr_signed; /* Ztso */ bool ztso; @@ -1239,10 +1240,13 @@ static void riscv_tr_init_disas_context(DisasContex= tBase *dcbase, CPUState *cs) ctx->cs =3D cs; if (get_xl(ctx) =3D=3D MXL_RV32) { ctx->addr_xl =3D 32; + ctx->addr_vxl =3D 32; ctx->addr_signed =3D false; } else { int pm_pmm =3D FIELD_EX32(tb_flags, TB_FLAGS, PM_PMM); ctx->addr_xl =3D 64 - riscv_pm_get_pmlen(pm_pmm); + int pm_vpmm =3D FIELD_EX64(tb_flags, TB_FLAGS, PM_VPMM); + ctx->addr_vxl =3D 64 - riscv_pm_get_pmlen(pm_vpmm); ctx->addr_signed =3D FIELD_EX32(tb_flags, TB_FLAGS, PM_SIGNEXTEND); } ctx->ztso =3D cpu->cfg.ext_ztso; --=20 2.39.5 From nobody Sat Nov 23 15:09:24 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=1732169710; cv=none; d=zohomail.com; s=zohoarc; b=MUBOZEOCmnq8KSD6dAn5gRT37/LiT/b9Lm9K21QcTMrtTzSmPtLzNoT98V9GD5u4xkVYS1eLR/scRSaFZtQ1xMsPKdt16KCkqPPsPHfAAmVnGhFPtL9fQPfplH0sUNU36eTwu+7T1/POe2A8ZYvTuaWXobn7z5RB+VyVC5Zs8vs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1732169710; 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=S6HdRUuJyp9OYDKzo9dzY5iwJdwxmVhNSExq7zJVpB8=; b=mbBcjgwBO8StuXik0T0OUm7FjYby93OdpRA4yrK8LzSrNKpF4XXjgKXptlCsjpHslTuXZ2/6dWTpfyZPr2Gjk8Zjn1z+NG5c5LOhtuDdQRW4RTfluRo05W0h8pAvSs/bRRFYwMzI1Tti2EtjXWd966/6UZqVqu9ifAQFrbO1zeg= 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 1732169710202273.0367935982057; Wed, 20 Nov 2024 22:15:10 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tE0Rd-0004a0-GR; Thu, 21 Nov 2024 01:13:37 -0500 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 1tE0RJ-0004Wg-U6; Thu, 21 Nov 2024 01:13:19 -0500 Received: from mail-lf1-x132.google.com ([2a00:1450:4864:20::132]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tE0RI-0006L3-A9; Thu, 21 Nov 2024 01:13:17 -0500 Received: by mail-lf1-x132.google.com with SMTP id 2adb3069b0e04-539e63c8678so480782e87.0; Wed, 20 Nov 2024 22:13:15 -0800 (PST) Received: from vmdev.asgard ([81.200.11.243]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-53dbd4726c3sm840443e87.205.2024.11.20.22.13.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Nov 2024 22:13:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1732169594; x=1732774394; 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=S6HdRUuJyp9OYDKzo9dzY5iwJdwxmVhNSExq7zJVpB8=; b=W2ikawEWgGkS8pbPqS8EiJv5Rie0aocfPvbj4Y8QNM0rtdxoo15w0NMgUR5QZ0uV2l Sa7nRF1A2kD4SSAc596oz0unowFT8EwmPlFX4uBKof3/YjWOyiM2JAYhTFYZ06Mo1Bn6 qf1lJo/HLqezyxMteZhncNEFH4SbuOQ1wieI2f+3sqlVZeXRInpNkvCyLy4e7RZCVE1F BnXc8d40uPxs3gRptq/mELCbzG4mrjNpXhPcHbmq2gjlb9S7Hhl+j1FFNgk1V7Yr9Exp VsG8/gNFY5yCH/XOOBac3o86ZYeRlh04k2EA4FxXUAwwu6NlKb+qvXIX1oS1aMRyIljm bTcw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732169594; x=1732774394; 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=S6HdRUuJyp9OYDKzo9dzY5iwJdwxmVhNSExq7zJVpB8=; b=BTeoDlY0p55Wley2ORRx8aBKrvmxdpew9FaUG01Y6GVdNLlTk4krc9OqkdLVpoUSxR MmUNSE9ZHYQwFUpPmGZUuLJfTXBW/HH7DIp2uaih8WyaBe2YjvVFE+yPAtPKFFNydTUQ SYXB//4Gnk2cVlz2Z3caED6AzVPxtbwXQEmsP8kFMu7fNf6OqNmftUbp9NUUA8mkvl1d v4faLr0z6dFrfxXeGxsmx0ZnaUvnSykjgx7Cf/QzMwtuqfahmhjFtp/ZZKnUF2v1JeiT Wifi3m0Ernjlw4WeMoUwH0gowOcFeYNLtcYI9Z8imS9mtQGU2gRQhC+qBkVbnES1idGy pfwA== X-Forwarded-Encrypted: i=1; AJvYcCVcd7ttjGqoyEdXC7PIZ/FoxCxeozJ48WrIMgUIWW6lQcgcPHNUqGf+y89l5okakH1Sx6trya919qybRQ==@nongnu.org, AJvYcCW3pIO8aiF8y9UA7T7EngMhnEVZiQe+ggZ0MG32CWcVeMsmXJhbBKwlr/WhVjBLUxMQ3g1hMYwm4bmB@nongnu.org X-Gm-Message-State: AOJu0Yxoaz8c6l6K9DI08IGPQP6mY6ZStVsYSLbF2uNMWR8dBXSBmR5/ gvcaKAe1FyiWNoCLgiik7HPpeWnBybLDL1D/LXEqGvdFNWZNnQ9p X-Gm-Gg: ASbGncvOQ+4b4snFHVjV8IKrwqyeo0XzpswDoCzZpJQIxRnncsryPx7uUW9OjrTjk68 YHCy8BzLG+HsYdSsJllW7+NPFaWgOQag1pWMa0AjM+uIItWi5p8c7ysNn/X+kK/6S3a8un6NlMh RwxS+4B1PZS8qlgOi+TfwqGB5xKi2vzV8pxnePQaCBPm20FRpdgugfSjum+6sp51SWAize+F7hn e3/C3mC0drMpNohdJWuk+rAT5hy+voKw9y16ij9J1T7TWT+K8Kvtr8= X-Google-Smtp-Source: AGHT+IEi+AFFK9IFW7gPtXc1LGze8DKHyshV+/0QdB+nGrBOO8QhbZmEEFZu4r5vK+Q3UhBXOTJoUA== X-Received: by 2002:a05:6512:3054:b0:53d:a549:6eb7 with SMTP id 2adb3069b0e04-53dc13435cbmr2849546e87.30.1732169593845; Wed, 20 Nov 2024 22:13:13 -0800 (PST) From: baturo.alexey@gmail.com To: Cc: baturo.alexey@gmail.com, richard.henderson@linaro.org, zhiwei_liu@linux.alibaba.com, dbarboza@ventanamicro.com, liwei1518@gmail.com, alistair23@gmail.com, frank.chang@sifive.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 Subject: [PATCH v2 7/7] target/riscv: Enable updates for pointer masking variables and thus enable pointer masking extension Date: Thu, 21 Nov 2024 09:12:59 +0300 Message-Id: <20241121061259.4043177-8-baturo.alexey@gmail.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241121061259.4043177-1-baturo.alexey@gmail.com> References: <20241121061259.4043177-1-baturo.alexey@gmail.com> 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::132; envelope-from=baturo.alexey@gmail.com; helo=mail-lf1-x132.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: 1732169711030116600 Content-Type: text/plain; charset="utf-8" From: Alexey Baturo Signed-off-by: Alexey Baturo --- target/riscv/cpu.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 4e80dcd2e6..fd3ea9ce76 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -186,11 +186,14 @@ const RISCVIsaExtData isa_edata_arr[] =3D { 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(smepmp, PRIV_VERSION_1_12_0, ext_smepmp), + ISA_EXT_DATA_ENTRY(smmpm, PRIV_VERSION_1_13_0, ext_smmpm), + ISA_EXT_DATA_ENTRY(smnpm, PRIV_VERSION_1_13_0, ext_smnpm), ISA_EXT_DATA_ENTRY(smstateen, PRIV_VERSION_1_12_0, ext_smstateen), ISA_EXT_DATA_ENTRY(ssaia, PRIV_VERSION_1_12_0, ext_ssaia), 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(ssnpm, PRIV_VERSION_1_13_0, ext_ssnpm), 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), @@ -1490,9 +1493,12 @@ const RISCVCPUMultiExtConfig riscv_cpu_extensions[] = =3D { MULTI_EXT_CFG_BOOL("zvfh", ext_zvfh, false), MULTI_EXT_CFG_BOOL("zvfhmin", ext_zvfhmin, false), MULTI_EXT_CFG_BOOL("sstc", ext_sstc, true), + MULTI_EXT_CFG_BOOL("ssnpm", ext_ssnpm, false), =20 MULTI_EXT_CFG_BOOL("smaia", ext_smaia, false), MULTI_EXT_CFG_BOOL("smepmp", ext_smepmp, false), + MULTI_EXT_CFG_BOOL("smmpm", ext_smmpm, false), + MULTI_EXT_CFG_BOOL("smnpm", ext_smnpm, false), MULTI_EXT_CFG_BOOL("smstateen", ext_smstateen, false), MULTI_EXT_CFG_BOOL("ssaia", ext_ssaia, false), MULTI_EXT_CFG_BOOL("svade", ext_svade, false), --=20 2.39.5