From patchwork Fri Apr 25 15:23:05 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 884354 Delivered-To: patch@linaro.org Received: by 2002:a5d:474d:0:b0:38f:210b:807b with SMTP id o13csp4022109wrs; Fri, 25 Apr 2025 08:25:02 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXw0kozstgoJJ8LJ64kEASLjkBxaiKfrIrubmcda1tWjZNk7NmDz2r+MRqSIKMpFTG8J8t8Xw==@linaro.org X-Google-Smtp-Source: AGHT+IHaqq95Dle3gubx+edMyXm/i9IuHo4vx2TH9OfypjB1V5V3gGWAW45VC9YAyhPaFWVUPZtU X-Received: by 2002:a05:6214:d03:b0:6f2:a457:19a with SMTP id 6a1803df08f44-6f4cb9edb20mr49053426d6.25.1745594702567; Fri, 25 Apr 2025 08:25:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1745594702; cv=none; d=google.com; s=arc-20240605; b=Xt/7ICmvbtOOpNVUAPEX91DRG+GKO1j+VRwGzD5Vc1rbn3KwL4uOwA42fwOpBzaXJW h/AcCpOUxXgVCLXN/c3XQx5ZtIsXyu11dNoDb8TyiAcTfl5G8urXAooCtMGZzr3M0+ku NS/8/4SkluP/P964nnhp2uYtrB62kcGelKWJQ1tKWSQEnE7/R5v4NM+T5ygFgzYNgT3g CztFjtNW7kXpoDDONXRUkwvo6dCz+qP6Lp87sUxsaO0gO7xQIIJPN4rbAE/3mICB0DnJ hglZQq84pAue5V4m2ufPhDC63c0cipUoqeFXnYgoZn0QPNqYSOHGBVe78Xj5yh1bODR/ c/Wg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=8adwHX+SAkE5xMAAQJAqugfv8f/9gTNgG6uA6MYASjY=; fh=tbsDrCdppOEjIVmMhMa/fTPU8DqwnjNG7rxGE3k2FrY=; b=eEQckcAY7k44ZHxGVyVJeKFCdbQ3VQjYLG75doOWhyGgx/T94CCLy//IlaFVHPvMs6 ouliw9Sja/kcNTvNiHNmaRlqG/haZ6c6rX7rXBpIGN7dTofPi1AAMXUi8e9jz9cf4wEZ wAApQYR8pyr2jRldgTm0CtzOovd8TVfcxaNXKNFE8EAYTees95u+g+6L9e5YX6k8sKRU hz1xbn6p1rXupPWCkZuXcQ5Fwo4Gu9djWs8rNEBjQWZSkqdaKgZXAlxlCzUGlfhBnsM4 q/e1cv6MJvXDh8CFcn75WoOzX225arbtYx7R/2zvpblSXc3Y8+uqccvdCgp1D9k36YdT pTkw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Of2Rr7JL; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 6a1803df08f44-6f4c08d29b8si38710866d6.60.2025.04.25.08.25.02 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 25 Apr 2025 08:25:02 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Of2Rr7JL; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1u8Ktf-0001fA-7j; Fri, 25 Apr 2025 11:23:23 -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 1u8Ktc-0001dW-NJ for qemu-devel@nongnu.org; Fri, 25 Apr 2025 11:23:20 -0400 Received: from mail-pg1-x52e.google.com ([2607:f8b0:4864:20::52e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1u8KtX-0002oc-Lx for qemu-devel@nongnu.org; Fri, 25 Apr 2025 11:23:20 -0400 Received: by mail-pg1-x52e.google.com with SMTP id 41be03b00d2f7-b170c99aa49so899353a12.1 for ; Fri, 25 Apr 2025 08:23:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1745594594; x=1746199394; 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=8adwHX+SAkE5xMAAQJAqugfv8f/9gTNgG6uA6MYASjY=; b=Of2Rr7JL8zH16FT8igIP9xtvb8giEB73qAni1kG62/sGGk+oxxcB7b0BRMfyAnJXm1 S7zA9nmsmz4ubE3HBmuem7iCbRwdxyiAViTnZyxqWyqzKVvRRRys0n4yT3ZsM0sbZwWt BopIUJZra2DB9O/GqqAeYems/k0IGK0kmWtI1NN+n/5OGZq7xXb7n2+5dUscH2su3XFV k01v89OPwuRrHsu+ip4yJibGzKcNyUFv9pz6QPL+gg/hUEkXGRNzG6uGZMjoCw7NnAXD 7Qh5sVaAbHpYJFn7yemJNJGT4BCMu1FvnYTESDMQmFGCQEtcDycs0Tf2+tb08SRjHq5W rRXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1745594594; x=1746199394; 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=8adwHX+SAkE5xMAAQJAqugfv8f/9gTNgG6uA6MYASjY=; b=OschVHeC5Msj5RIzPAJDSbnZ8aNjkMpb/cPBzHyUQwGgRdfZOhteJ8bjvMDIP9jNnX f0+ojF0fTqjiuXuKpaSc5uj0VeIXCpNtoN2L6wVdRihNK6Nllv/iXEoBw3nwStpZhwGi moG8z1nFT9kbwTDkM4fKImEDDMLmUCMRDqF9Kz53oIAXgYSGgO1+AIXcVGxsNdwEN1rY JcsrF3ybhob1/K8VNyVqg1rKJgskHz2p0Ez//pMmrePOki/zdjQIYsswSMRdsnQ1sDfH k2FXDYFwkydsFI0/3cLktQd++YdH9HutpixJW2ATry29t3pBOTlBV/TvsjM7QFz1FNJB aj6Q== X-Gm-Message-State: AOJu0Yz6hK95owqEIuec6ULzpXnmmX0wBtHFkrkblvF9PMQtqlQCKOKe IeWSY+7PFpG8eqE+2ed+ynnHq92NwJU8lgPlMTc5PkdGZbk+VfKIa7y8o08H+iYksPJNiXH/jWO 8 X-Gm-Gg: ASbGncuaJNLB0u/FBaZQT2gU0ZszS2fAHkXtTKFAySB30ql2DTnzL2Ai1AOavrPQCTf KVZZvLB0u5EytRMCOCxhoBrYJEX8ddB+EaliRNx7Kk2mCORDaP7N5pJfKTLuaGvL/JAYta4wEX5 t+KB+E2YGf85T5MSxz1vCFlGqMBPIeZYv/3UaBN4A1uAz9e0m0/1+1LyaYxKx9PBeDobFEhIloW 6Ky2CaRXwKNSAEe5pQJyFjsx2ZBzwvVdATEHI3z3zbD01/VIo1hxVctrgfRowICoLglBAdZwHik yuyYzWwGB8C9GtRj5WAZoKcY/r5m6xHG3P4QVEGUbNWdR2pXS4m7xKvbq5d5h2waU/NcywrUbts = X-Received: by 2002:a05:6a21:920a:b0:1f5:591b:4f73 with SMTP id adf61e73a8af0-2045b99e1a8mr4432790637.34.1745594594022; Fri, 25 Apr 2025 08:23:14 -0700 (PDT) Received: from stoup.. (71-212-47-143.tukw.qwest.net. [71.212.47.143]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-73e25a6a49esm3390466b3a.106.2025.04.25.08.23.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Apr 2025 08:23:13 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-riscv@nongnu.org, alistair.francis@wdc.com, dbarboza@ventanamicro.com Subject: [PATCH 1/7] target/riscv: Pass ra to riscv_csr_write_fn Date: Fri, 25 Apr 2025 08:23:05 -0700 Message-ID: <20250425152311.804338-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250425152311.804338-1-richard.henderson@linaro.org> References: <20250425152311.804338-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::52e; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x52e.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, 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- target/riscv/cpu.h | 3 +- target/riscv/csr.c | 226 +++++++++++++++++++++++---------------------- 2 files changed, 118 insertions(+), 111 deletions(-) diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h index 167909c89b..4d41a66d72 100644 --- a/target/riscv/cpu.h +++ b/target/riscv/cpu.h @@ -841,7 +841,8 @@ typedef RISCVException (*riscv_csr_predicate_fn)(CPURISCVState *env, typedef RISCVException (*riscv_csr_read_fn)(CPURISCVState *env, int csrno, target_ulong *ret_value); typedef RISCVException (*riscv_csr_write_fn)(CPURISCVState *env, int csrno, - target_ulong new_value); + target_ulong new_value, + uintptr_t ra); typedef RISCVException (*riscv_csr_op_fn)(CPURISCVState *env, int csrno, target_ulong *ret_value, target_ulong new_value, diff --git a/target/riscv/csr.c b/target/riscv/csr.c index c52c87faae..6f1f69eba6 100644 --- a/target/riscv/csr.c +++ b/target/riscv/csr.c @@ -830,13 +830,15 @@ static RISCVException seed(CPURISCVState *env, int csrno) } /* zicfiss CSR_SSP read and write */ -static int read_ssp(CPURISCVState *env, int csrno, target_ulong *val) +static RISCVException read_ssp(CPURISCVState *env, int csrno, + target_ulong *val) { *val = env->ssp; return RISCV_EXCP_NONE; } -static int write_ssp(CPURISCVState *env, int csrno, target_ulong val) +static RISCVException write_ssp(CPURISCVState *env, int csrno, + target_ulong val, uintptr_t ra) { env->ssp = val; return RISCV_EXCP_NONE; @@ -851,7 +853,7 @@ static RISCVException read_fflags(CPURISCVState *env, int csrno, } static RISCVException write_fflags(CPURISCVState *env, int csrno, - target_ulong val) + target_ulong val, uintptr_t ra) { #if !defined(CONFIG_USER_ONLY) if (riscv_has_ext(env, RVF)) { @@ -870,7 +872,7 @@ static RISCVException read_frm(CPURISCVState *env, int csrno, } static RISCVException write_frm(CPURISCVState *env, int csrno, - target_ulong val) + target_ulong val, uintptr_t ra) { #if !defined(CONFIG_USER_ONLY) if (riscv_has_ext(env, RVF)) { @@ -890,7 +892,7 @@ static RISCVException read_fcsr(CPURISCVState *env, int csrno, } static RISCVException write_fcsr(CPURISCVState *env, int csrno, - target_ulong val) + target_ulong val, uintptr_t ra) { #if !defined(CONFIG_USER_ONLY) if (riscv_has_ext(env, RVF)) { @@ -942,7 +944,7 @@ static RISCVException read_vxrm(CPURISCVState *env, int csrno, } static RISCVException write_vxrm(CPURISCVState *env, int csrno, - target_ulong val) + target_ulong val, uintptr_t ra) { #if !defined(CONFIG_USER_ONLY) env->mstatus |= MSTATUS_VS; @@ -959,7 +961,7 @@ static RISCVException read_vxsat(CPURISCVState *env, int csrno, } static RISCVException write_vxsat(CPURISCVState *env, int csrno, - target_ulong val) + target_ulong val, uintptr_t ra) { #if !defined(CONFIG_USER_ONLY) env->mstatus |= MSTATUS_VS; @@ -976,7 +978,7 @@ static RISCVException read_vstart(CPURISCVState *env, int csrno, } static RISCVException write_vstart(CPURISCVState *env, int csrno, - target_ulong val) + target_ulong val, uintptr_t ra) { #if !defined(CONFIG_USER_ONLY) env->mstatus |= MSTATUS_VS; @@ -997,7 +999,7 @@ static RISCVException read_vcsr(CPURISCVState *env, int csrno, } static RISCVException write_vcsr(CPURISCVState *env, int csrno, - target_ulong val) + target_ulong val, uintptr_t ra) { #if !defined(CONFIG_USER_ONLY) env->mstatus |= MSTATUS_VS; @@ -1055,7 +1057,7 @@ static RISCVException read_mcyclecfg(CPURISCVState *env, int csrno, } static RISCVException write_mcyclecfg(CPURISCVState *env, int csrno, - target_ulong val) + target_ulong val, uintptr_t ra) { uint64_t inh_avail_mask; @@ -1084,7 +1086,7 @@ static RISCVException read_mcyclecfgh(CPURISCVState *env, int csrno, } static RISCVException write_mcyclecfgh(CPURISCVState *env, int csrno, - target_ulong val) + target_ulong val, uintptr_t ra) { target_ulong inh_avail_mask = (target_ulong)(~MHPMEVENTH_FILTER_MASK | MCYCLECFGH_BIT_MINH); @@ -1109,7 +1111,7 @@ static RISCVException read_minstretcfg(CPURISCVState *env, int csrno, } static RISCVException write_minstretcfg(CPURISCVState *env, int csrno, - target_ulong val) + target_ulong val, uintptr_t ra) { uint64_t inh_avail_mask; @@ -1136,7 +1138,7 @@ static RISCVException read_minstretcfgh(CPURISCVState *env, int csrno, } static RISCVException write_minstretcfgh(CPURISCVState *env, int csrno, - target_ulong val) + target_ulong val, uintptr_t ra) { target_ulong inh_avail_mask = (target_ulong)(~MHPMEVENTH_FILTER_MASK | MINSTRETCFGH_BIT_MINH); @@ -1163,7 +1165,7 @@ static RISCVException read_mhpmevent(CPURISCVState *env, int csrno, } static RISCVException write_mhpmevent(CPURISCVState *env, int csrno, - target_ulong val) + target_ulong val, uintptr_t ra) { int evt_index = csrno - CSR_MCOUNTINHIBIT; uint64_t mhpmevt_val = val; @@ -1201,7 +1203,7 @@ static RISCVException read_mhpmeventh(CPURISCVState *env, int csrno, } static RISCVException write_mhpmeventh(CPURISCVState *env, int csrno, - target_ulong val) + target_ulong val, uintptr_t ra) { int evt_index = csrno - CSR_MHPMEVENT3H + 3; uint64_t mhpmevth_val; @@ -1343,14 +1345,16 @@ static RISCVException riscv_pmu_write_ctrh(CPURISCVState *env, target_ulong val, return RISCV_EXCP_NONE; } -static int write_mhpmcounter(CPURISCVState *env, int csrno, target_ulong val) +static RISCVException write_mhpmcounter(CPURISCVState *env, int csrno, + target_ulong val, uintptr_t ra) { int ctr_idx = csrno - CSR_MCYCLE; return riscv_pmu_write_ctr(env, val, ctr_idx); } -static int write_mhpmcounterh(CPURISCVState *env, int csrno, target_ulong val) +static RISCVException write_mhpmcounterh(CPURISCVState *env, int csrno, + target_ulong val, uintptr_t ra) { int ctr_idx = csrno - CSR_MCYCLEH; @@ -1661,7 +1665,7 @@ static RISCVException read_vstimecmph(CPURISCVState *env, int csrno, } static RISCVException write_vstimecmp(CPURISCVState *env, int csrno, - target_ulong val) + target_ulong val, uintptr_t ra) { if (riscv_cpu_mxl(env) == MXL_RV32) { env->vstimecmp = deposit64(env->vstimecmp, 0, 32, (uint64_t)val); @@ -1676,7 +1680,7 @@ static RISCVException write_vstimecmp(CPURISCVState *env, int csrno, } static RISCVException write_vstimecmph(CPURISCVState *env, int csrno, - target_ulong val) + target_ulong val, uintptr_t ra) { env->vstimecmp = deposit64(env->vstimecmp, 32, 32, (uint64_t)val); riscv_timer_write_timecmp(env, env->vstimer, env->vstimecmp, @@ -1710,13 +1714,13 @@ static RISCVException read_stimecmph(CPURISCVState *env, int csrno, } static RISCVException write_stimecmp(CPURISCVState *env, int csrno, - target_ulong val) + target_ulong val, uintptr_t ra) { if (env->virt_enabled) { if (env->hvictl & HVICTL_VTI) { return RISCV_EXCP_VIRT_INSTRUCTION_FAULT; } - return write_vstimecmp(env, csrno, val); + return write_vstimecmp(env, csrno, val, ra); } if (riscv_cpu_mxl(env) == MXL_RV32) { @@ -1731,13 +1735,13 @@ static RISCVException write_stimecmp(CPURISCVState *env, int csrno, } static RISCVException write_stimecmph(CPURISCVState *env, int csrno, - target_ulong val) + target_ulong val, uintptr_t ra) { if (env->virt_enabled) { if (env->hvictl & HVICTL_VTI) { return RISCV_EXCP_VIRT_INSTRUCTION_FAULT; } - return write_vstimecmph(env, csrno, val); + return write_vstimecmph(env, csrno, val, ra); } env->stimecmp = deposit64(env->stimecmp, 32, 32, (uint64_t)val); @@ -1842,7 +1846,7 @@ static RISCVException read_zero(CPURISCVState *env, int csrno, } static RISCVException write_ignore(CPURISCVState *env, int csrno, - target_ulong val) + target_ulong val, uintptr_t ra) { return RISCV_EXCP_NONE; } @@ -1963,7 +1967,7 @@ static target_ulong legalize_mpp(CPURISCVState *env, target_ulong old_mpp, } static RISCVException write_mstatus(CPURISCVState *env, int csrno, - target_ulong val) + target_ulong val, uintptr_t ra) { uint64_t mstatus = env->mstatus; uint64_t mask = 0; @@ -2042,7 +2046,7 @@ static RISCVException read_mstatush(CPURISCVState *env, int csrno, } static RISCVException write_mstatush(CPURISCVState *env, int csrno, - target_ulong val) + target_ulong val, uintptr_t ra) { uint64_t valh = (uint64_t)val << 32; uint64_t mask = riscv_has_ext(env, RVH) ? MSTATUS_MPV | MSTATUS_GVA : 0; @@ -2096,7 +2100,7 @@ static RISCVException read_misa(CPURISCVState *env, int csrno, } static RISCVException write_misa(CPURISCVState *env, int csrno, - target_ulong val) + target_ulong val, uintptr_t ra) { RISCVCPU *cpu = env_archcpu(env); uint32_t orig_misa_ext = env->misa_ext; @@ -2160,7 +2164,7 @@ static RISCVException read_medeleg(CPURISCVState *env, int csrno, } static RISCVException write_medeleg(CPURISCVState *env, int csrno, - target_ulong val) + target_ulong val, uintptr_t ra) { env->medeleg = (env->medeleg & ~DELEGABLE_EXCPS) | (val & DELEGABLE_EXCPS); return RISCV_EXCP_NONE; @@ -2955,7 +2959,7 @@ static RISCVException read_mtvec(CPURISCVState *env, int csrno, } static RISCVException write_mtvec(CPURISCVState *env, int csrno, - target_ulong val) + target_ulong val, uintptr_t ra) { /* bits [1:0] encode mode; 0 = direct, 1 = vectored, 2 >= reserved */ if ((val & 3) < 2) { @@ -2974,7 +2978,7 @@ static RISCVException read_mcountinhibit(CPURISCVState *env, int csrno, } static RISCVException write_mcountinhibit(CPURISCVState *env, int csrno, - target_ulong val) + target_ulong val, uintptr_t ra) { int cidx; PMUCTRState *counter; @@ -3049,10 +3053,9 @@ static RISCVException read_scountinhibit(CPURISCVState *env, int csrno, } static RISCVException write_scountinhibit(CPURISCVState *env, int csrno, - target_ulong val) + target_ulong val, uintptr_t ra) { - write_mcountinhibit(env, csrno, val & env->mcounteren); - return RISCV_EXCP_NONE; + return write_mcountinhibit(env, csrno, val & env->mcounteren, ra); } static RISCVException read_mcounteren(CPURISCVState *env, int csrno, @@ -3063,7 +3066,7 @@ static RISCVException read_mcounteren(CPURISCVState *env, int csrno, } static RISCVException write_mcounteren(CPURISCVState *env, int csrno, - target_ulong val) + target_ulong val, uintptr_t ra) { RISCVCPU *cpu = env_archcpu(env); @@ -3097,7 +3100,7 @@ static RISCVException read_mscratch(CPURISCVState *env, int csrno, } static RISCVException write_mscratch(CPURISCVState *env, int csrno, - target_ulong val) + target_ulong val, uintptr_t ra) { env->mscratch = val; return RISCV_EXCP_NONE; @@ -3111,7 +3114,7 @@ static RISCVException read_mepc(CPURISCVState *env, int csrno, } static RISCVException write_mepc(CPURISCVState *env, int csrno, - target_ulong val) + target_ulong val, uintptr_t ra) { env->mepc = val; return RISCV_EXCP_NONE; @@ -3125,7 +3128,7 @@ static RISCVException read_mcause(CPURISCVState *env, int csrno, } static RISCVException write_mcause(CPURISCVState *env, int csrno, - target_ulong val) + target_ulong val, uintptr_t ra) { env->mcause = val; return RISCV_EXCP_NONE; @@ -3139,7 +3142,7 @@ static RISCVException read_mtval(CPURISCVState *env, int csrno, } static RISCVException write_mtval(CPURISCVState *env, int csrno, - target_ulong val) + target_ulong val, uintptr_t ra) { env->mtval = val; return RISCV_EXCP_NONE; @@ -3154,9 +3157,9 @@ static RISCVException read_menvcfg(CPURISCVState *env, int csrno, } static RISCVException write_henvcfg(CPURISCVState *env, int csrno, - target_ulong val); + target_ulong val, uintptr_t ra); static RISCVException write_menvcfg(CPURISCVState *env, int csrno, - target_ulong val) + target_ulong val, uintptr_t ra) { const RISCVCPUConfig *cfg = riscv_cpu_cfg(env); uint64_t mask = MENVCFG_FIOM | MENVCFG_CBIE | MENVCFG_CBCFE | @@ -3188,9 +3191,7 @@ static RISCVException write_menvcfg(CPURISCVState *env, int csrno, } } env->menvcfg = (env->menvcfg & ~mask) | (val & mask); - write_henvcfg(env, CSR_HENVCFG, env->henvcfg); - - return RISCV_EXCP_NONE; + return write_henvcfg(env, CSR_HENVCFG, env->henvcfg, ra); } static RISCVException read_menvcfgh(CPURISCVState *env, int csrno, @@ -3201,9 +3202,9 @@ static RISCVException read_menvcfgh(CPURISCVState *env, int csrno, } static RISCVException write_henvcfgh(CPURISCVState *env, int csrno, - target_ulong val); + target_ulong val, uintptr_t ra); static RISCVException write_menvcfgh(CPURISCVState *env, int csrno, - target_ulong val) + target_ulong val, uintptr_t ra) { const RISCVCPUConfig *cfg = riscv_cpu_cfg(env); uint64_t mask = (cfg->ext_svpbmt ? MENVCFG_PBMTE : 0) | @@ -3218,9 +3219,7 @@ static RISCVException write_menvcfgh(CPURISCVState *env, int csrno, } env->menvcfg = (env->menvcfg & ~mask) | (valh & mask); - write_henvcfgh(env, CSR_HENVCFGH, env->henvcfg >> 32); - - return RISCV_EXCP_NONE; + return write_henvcfgh(env, CSR_HENVCFGH, env->henvcfg >> 32, ra); } static RISCVException read_senvcfg(CPURISCVState *env, int csrno, @@ -3238,7 +3237,7 @@ static RISCVException read_senvcfg(CPURISCVState *env, int csrno, } static RISCVException write_senvcfg(CPURISCVState *env, int csrno, - target_ulong val) + target_ulong val, uintptr_t ra) { uint64_t mask = SENVCFG_FIOM | SENVCFG_CBIE | SENVCFG_CBCFE | SENVCFG_CBZE; RISCVException ret; @@ -3295,7 +3294,7 @@ static RISCVException read_henvcfg(CPURISCVState *env, int csrno, } static RISCVException write_henvcfg(CPURISCVState *env, int csrno, - target_ulong val) + target_ulong val, uintptr_t ra) { uint64_t mask = HENVCFG_FIOM | HENVCFG_CBIE | HENVCFG_CBCFE | HENVCFG_CBZE; RISCVException ret; @@ -3350,7 +3349,7 @@ static RISCVException read_henvcfgh(CPURISCVState *env, int csrno, } static RISCVException write_henvcfgh(CPURISCVState *env, int csrno, - target_ulong val) + target_ulong val, uintptr_t ra) { uint64_t mask = env->menvcfg & (HENVCFG_PBMTE | HENVCFG_STCE | HENVCFG_ADUE | HENVCFG_DTE); @@ -3388,7 +3387,7 @@ static RISCVException write_mstateen(CPURISCVState *env, int csrno, } static RISCVException write_mstateen0(CPURISCVState *env, int csrno, - target_ulong new_val) + target_ulong new_val, uintptr_t ra) { uint64_t wr_mask = SMSTATEEN_STATEEN | SMSTATEEN0_HSENVCFG; if (!riscv_has_ext(env, RVF)) { @@ -3420,7 +3419,7 @@ static RISCVException write_mstateen0(CPURISCVState *env, int csrno, } static RISCVException write_mstateen_1_3(CPURISCVState *env, int csrno, - target_ulong new_val) + target_ulong new_val, uintptr_t ra) { return write_mstateen(env, csrno, SMSTATEEN_STATEEN, new_val); } @@ -3447,7 +3446,7 @@ static RISCVException write_mstateenh(CPURISCVState *env, int csrno, } static RISCVException write_mstateen0h(CPURISCVState *env, int csrno, - target_ulong new_val) + target_ulong new_val, uintptr_t ra) { uint64_t wr_mask = SMSTATEEN_STATEEN | SMSTATEEN0_HSENVCFG; @@ -3463,7 +3462,7 @@ static RISCVException write_mstateen0h(CPURISCVState *env, int csrno, } static RISCVException write_mstateenh_1_3(CPURISCVState *env, int csrno, - target_ulong new_val) + target_ulong new_val, uintptr_t ra) { return write_mstateenh(env, csrno, SMSTATEEN_STATEEN, new_val); } @@ -3492,7 +3491,7 @@ static RISCVException write_hstateen(CPURISCVState *env, int csrno, } static RISCVException write_hstateen0(CPURISCVState *env, int csrno, - target_ulong new_val) + target_ulong new_val, uintptr_t ra) { uint64_t wr_mask = SMSTATEEN_STATEEN | SMSTATEEN0_HSENVCFG; @@ -3521,7 +3520,7 @@ static RISCVException write_hstateen0(CPURISCVState *env, int csrno, } static RISCVException write_hstateen_1_3(CPURISCVState *env, int csrno, - target_ulong new_val) + target_ulong new_val, uintptr_t ra) { return write_hstateen(env, csrno, SMSTATEEN_STATEEN, new_val); } @@ -3552,7 +3551,7 @@ static RISCVException write_hstateenh(CPURISCVState *env, int csrno, } static RISCVException write_hstateen0h(CPURISCVState *env, int csrno, - target_ulong new_val) + target_ulong new_val, uintptr_t ra) { uint64_t wr_mask = SMSTATEEN_STATEEN | SMSTATEEN0_HSENVCFG; @@ -3564,7 +3563,7 @@ static RISCVException write_hstateen0h(CPURISCVState *env, int csrno, } static RISCVException write_hstateenh_1_3(CPURISCVState *env, int csrno, - target_ulong new_val) + target_ulong new_val, uintptr_t ra) { return write_hstateenh(env, csrno, SMSTATEEN_STATEEN, new_val); } @@ -3603,7 +3602,7 @@ static RISCVException write_sstateen(CPURISCVState *env, int csrno, } static RISCVException write_sstateen0(CPURISCVState *env, int csrno, - target_ulong new_val) + target_ulong new_val, uintptr_t ra) { uint64_t wr_mask = SMSTATEEN_STATEEN | SMSTATEEN0_HSENVCFG; @@ -3615,7 +3614,7 @@ static RISCVException write_sstateen0(CPURISCVState *env, int csrno, } static RISCVException write_sstateen_1_3(CPURISCVState *env, int csrno, - target_ulong new_val) + target_ulong new_val, uintptr_t ra) { return write_sstateen(env, csrno, SMSTATEEN_STATEEN, new_val); } @@ -3866,7 +3865,7 @@ static RISCVException read_sstatus(CPURISCVState *env, int csrno, } static RISCVException write_sstatus(CPURISCVState *env, int csrno, - target_ulong val) + target_ulong val, uintptr_t ra) { target_ulong mask = (sstatus_v1_10_mask); @@ -3883,7 +3882,7 @@ static RISCVException write_sstatus(CPURISCVState *env, int csrno, mask |= SSTATUS_SDT; } target_ulong newval = (env->mstatus & ~mask) | (val & mask); - return write_mstatus(env, CSR_MSTATUS, newval); + return write_mstatus(env, CSR_MSTATUS, newval, ra); } static RISCVException rmw_vsie64(CPURISCVState *env, int csrno, @@ -4035,7 +4034,7 @@ static RISCVException read_stvec(CPURISCVState *env, int csrno, } static RISCVException write_stvec(CPURISCVState *env, int csrno, - target_ulong val) + target_ulong val, uintptr_t ra) { /* bits [1:0] encode mode; 0 = direct, 1 = vectored, 2 >= reserved */ if ((val & 3) < 2) { @@ -4054,7 +4053,7 @@ static RISCVException read_scounteren(CPURISCVState *env, int csrno, } static RISCVException write_scounteren(CPURISCVState *env, int csrno, - target_ulong val) + target_ulong val, uintptr_t ra) { RISCVCPU *cpu = env_archcpu(env); @@ -4088,7 +4087,7 @@ static RISCVException read_sscratch(CPURISCVState *env, int csrno, } static RISCVException write_sscratch(CPURISCVState *env, int csrno, - target_ulong val) + target_ulong val, uintptr_t ra) { env->sscratch = val; return RISCV_EXCP_NONE; @@ -4102,7 +4101,7 @@ static RISCVException read_sepc(CPURISCVState *env, int csrno, } static RISCVException write_sepc(CPURISCVState *env, int csrno, - target_ulong val) + target_ulong val, uintptr_t ra) { env->sepc = val; return RISCV_EXCP_NONE; @@ -4116,7 +4115,7 @@ static RISCVException read_scause(CPURISCVState *env, int csrno, } static RISCVException write_scause(CPURISCVState *env, int csrno, - target_ulong val) + target_ulong val, uintptr_t ra) { env->scause = val; return RISCV_EXCP_NONE; @@ -4130,7 +4129,7 @@ static RISCVException read_stval(CPURISCVState *env, int csrno, } static RISCVException write_stval(CPURISCVState *env, int csrno, - target_ulong val) + target_ulong val, uintptr_t ra) { env->stval = val; return RISCV_EXCP_NONE; @@ -4270,7 +4269,7 @@ static RISCVException read_satp(CPURISCVState *env, int csrno, } static RISCVException write_satp(CPURISCVState *env, int csrno, - target_ulong val) + target_ulong val, uintptr_t ra) { if (!riscv_cpu_cfg(env)->mmu) { return RISCV_EXCP_NONE; @@ -4492,7 +4491,7 @@ static RISCVException read_hstatus(CPURISCVState *env, int csrno, } static RISCVException write_hstatus(CPURISCVState *env, int csrno, - target_ulong val) + target_ulong val, uintptr_t ra) { uint64_t mask = (target_ulong)-1; if (!env_archcpu(env)->cfg.ext_svukte) { @@ -4524,7 +4523,7 @@ static RISCVException read_hedeleg(CPURISCVState *env, int csrno, } static RISCVException write_hedeleg(CPURISCVState *env, int csrno, - target_ulong val) + target_ulong val, uintptr_t ra) { env->hedeleg = val & vs_delegable_excps; return RISCV_EXCP_NONE; @@ -4545,7 +4544,7 @@ static RISCVException read_hedelegh(CPURISCVState *env, int csrno, } static RISCVException write_hedelegh(CPURISCVState *env, int csrno, - target_ulong val) + target_ulong val, uintptr_t ra) { RISCVException ret; ret = smstateen_acc_ok(env, 0, SMSTATEEN0_P1P13); @@ -4808,7 +4807,7 @@ static RISCVException read_hcounteren(CPURISCVState *env, int csrno, } static RISCVException write_hcounteren(CPURISCVState *env, int csrno, - target_ulong val) + target_ulong val, uintptr_t ra) { RISCVCPU *cpu = env_archcpu(env); @@ -4828,7 +4827,7 @@ static RISCVException read_hgeie(CPURISCVState *env, int csrno, } static RISCVException write_hgeie(CPURISCVState *env, int csrno, - target_ulong val) + target_ulong val, uintptr_t ra) { /* Only GEILEN:1 bits implemented and BIT0 is never implemented */ val &= ((((target_ulong)1) << env->geilen) - 1) << 1; @@ -4847,7 +4846,7 @@ static RISCVException read_htval(CPURISCVState *env, int csrno, } static RISCVException write_htval(CPURISCVState *env, int csrno, - target_ulong val) + target_ulong val, uintptr_t ra) { env->htval = val; return RISCV_EXCP_NONE; @@ -4861,7 +4860,7 @@ static RISCVException read_htinst(CPURISCVState *env, int csrno, } static RISCVException write_htinst(CPURISCVState *env, int csrno, - target_ulong val) + target_ulong val, uintptr_t ra) { return RISCV_EXCP_NONE; } @@ -4883,7 +4882,7 @@ static RISCVException read_hgatp(CPURISCVState *env, int csrno, } static RISCVException write_hgatp(CPURISCVState *env, int csrno, - target_ulong val) + target_ulong val, uintptr_t ra) { env->hgatp = legalize_xatp(env, env->hgatp, val); return RISCV_EXCP_NONE; @@ -4901,7 +4900,7 @@ static RISCVException read_htimedelta(CPURISCVState *env, int csrno, } static RISCVException write_htimedelta(CPURISCVState *env, int csrno, - target_ulong val) + target_ulong val, uintptr_t ra) { if (!env->rdtime_fn) { return RISCV_EXCP_ILLEGAL_INST; @@ -4933,7 +4932,7 @@ static RISCVException read_htimedeltah(CPURISCVState *env, int csrno, } static RISCVException write_htimedeltah(CPURISCVState *env, int csrno, - target_ulong val) + target_ulong val, uintptr_t ra) { if (!env->rdtime_fn) { return RISCV_EXCP_ILLEGAL_INST; @@ -4957,7 +4956,7 @@ static RISCVException read_hvictl(CPURISCVState *env, int csrno, } static RISCVException write_hvictl(CPURISCVState *env, int csrno, - target_ulong val) + target_ulong val, uintptr_t ra) { env->hvictl = val & HVICTL_VALID_MASK; return RISCV_EXCP_NONE; @@ -5022,7 +5021,7 @@ static RISCVException read_hviprio1(CPURISCVState *env, int csrno, } static RISCVException write_hviprio1(CPURISCVState *env, int csrno, - target_ulong val) + target_ulong val, uintptr_t ra) { return write_hvipriox(env, 0, env->hviprio, val); } @@ -5034,7 +5033,7 @@ static RISCVException read_hviprio1h(CPURISCVState *env, int csrno, } static RISCVException write_hviprio1h(CPURISCVState *env, int csrno, - target_ulong val) + target_ulong val, uintptr_t ra) { return write_hvipriox(env, 4, env->hviprio, val); } @@ -5046,7 +5045,7 @@ static RISCVException read_hviprio2(CPURISCVState *env, int csrno, } static RISCVException write_hviprio2(CPURISCVState *env, int csrno, - target_ulong val) + target_ulong val, uintptr_t ra) { return write_hvipriox(env, 8, env->hviprio, val); } @@ -5058,7 +5057,7 @@ static RISCVException read_hviprio2h(CPURISCVState *env, int csrno, } static RISCVException write_hviprio2h(CPURISCVState *env, int csrno, - target_ulong val) + target_ulong val, uintptr_t ra) { return write_hvipriox(env, 12, env->hviprio, val); } @@ -5072,7 +5071,7 @@ static RISCVException read_vsstatus(CPURISCVState *env, int csrno, } static RISCVException write_vsstatus(CPURISCVState *env, int csrno, - target_ulong val) + target_ulong val, uintptr_t ra) { uint64_t mask = (target_ulong)-1; if ((val & VSSTATUS64_UXL) == 0) { @@ -5097,7 +5096,7 @@ static RISCVException read_vstvec(CPURISCVState *env, int csrno, } static RISCVException write_vstvec(CPURISCVState *env, int csrno, - target_ulong val) + target_ulong val, uintptr_t ra) { /* bits [1:0] encode mode; 0 = direct, 1 = vectored, 2 >= reserved */ if ((val & 3) < 2) { @@ -5116,7 +5115,7 @@ static RISCVException read_vsscratch(CPURISCVState *env, int csrno, } static RISCVException write_vsscratch(CPURISCVState *env, int csrno, - target_ulong val) + target_ulong val, uintptr_t ra) { env->vsscratch = val; return RISCV_EXCP_NONE; @@ -5130,7 +5129,7 @@ static RISCVException read_vsepc(CPURISCVState *env, int csrno, } static RISCVException write_vsepc(CPURISCVState *env, int csrno, - target_ulong val) + target_ulong val, uintptr_t ra) { env->vsepc = val; return RISCV_EXCP_NONE; @@ -5144,7 +5143,7 @@ static RISCVException read_vscause(CPURISCVState *env, int csrno, } static RISCVException write_vscause(CPURISCVState *env, int csrno, - target_ulong val) + target_ulong val, uintptr_t ra) { env->vscause = val; return RISCV_EXCP_NONE; @@ -5158,7 +5157,7 @@ static RISCVException read_vstval(CPURISCVState *env, int csrno, } static RISCVException write_vstval(CPURISCVState *env, int csrno, - target_ulong val) + target_ulong val, uintptr_t ra) { env->vstval = val; return RISCV_EXCP_NONE; @@ -5172,7 +5171,7 @@ static RISCVException read_vsatp(CPURISCVState *env, int csrno, } static RISCVException write_vsatp(CPURISCVState *env, int csrno, - target_ulong val) + target_ulong val, uintptr_t ra) { env->vsatp = legalize_xatp(env, env->vsatp, val); return RISCV_EXCP_NONE; @@ -5186,7 +5185,7 @@ static RISCVException read_mtval2(CPURISCVState *env, int csrno, } static RISCVException write_mtval2(CPURISCVState *env, int csrno, - target_ulong val) + target_ulong val, uintptr_t ra) { env->mtval2 = val; return RISCV_EXCP_NONE; @@ -5200,7 +5199,7 @@ static RISCVException read_mtinst(CPURISCVState *env, int csrno, } static RISCVException write_mtinst(CPURISCVState *env, int csrno, - target_ulong val) + target_ulong val, uintptr_t ra) { env->mtinst = val; return RISCV_EXCP_NONE; @@ -5215,7 +5214,7 @@ static RISCVException read_mseccfg(CPURISCVState *env, int csrno, } static RISCVException write_mseccfg(CPURISCVState *env, int csrno, - target_ulong val) + target_ulong val, uintptr_t ra) { mseccfg_csr_write(env, val); return RISCV_EXCP_NONE; @@ -5231,7 +5230,7 @@ static RISCVException read_pmpcfg(CPURISCVState *env, int csrno, } static RISCVException write_pmpcfg(CPURISCVState *env, int csrno, - target_ulong val) + target_ulong val, uintptr_t ra) { uint32_t reg_index = csrno - CSR_PMPCFG0; @@ -5247,7 +5246,7 @@ static RISCVException read_pmpaddr(CPURISCVState *env, int csrno, } static RISCVException write_pmpaddr(CPURISCVState *env, int csrno, - target_ulong val) + target_ulong val, uintptr_t ra) { pmpaddr_csr_write(env, csrno - CSR_PMPADDR0, val); return RISCV_EXCP_NONE; @@ -5261,7 +5260,7 @@ static RISCVException read_tselect(CPURISCVState *env, int csrno, } static RISCVException write_tselect(CPURISCVState *env, int csrno, - target_ulong val) + target_ulong val, uintptr_t ra) { tselect_csr_write(env, val); return RISCV_EXCP_NONE; @@ -5285,7 +5284,7 @@ static RISCVException read_tdata(CPURISCVState *env, int csrno, } static RISCVException write_tdata(CPURISCVState *env, int csrno, - target_ulong val) + target_ulong val, uintptr_t ra) { if (!tdata_available(env, csrno - CSR_TDATA1)) { return RISCV_EXCP_ILLEGAL_INST; @@ -5310,7 +5309,7 @@ static RISCVException read_mcontext(CPURISCVState *env, int csrno, } static RISCVException write_mcontext(CPURISCVState *env, int csrno, - target_ulong val) + target_ulong val, uintptr_t ra) { bool rv32 = riscv_cpu_mxl(env) == MXL_RV32 ? true : false; int32_t mask; @@ -5334,43 +5333,50 @@ static RISCVException read_mnscratch(CPURISCVState *env, int csrno, return RISCV_EXCP_NONE; } -static int write_mnscratch(CPURISCVState *env, int csrno, target_ulong val) +static RISCVException write_mnscratch(CPURISCVState *env, int csrno, + target_ulong val, uintptr_t ra) { env->mnscratch = val; return RISCV_EXCP_NONE; } -static int read_mnepc(CPURISCVState *env, int csrno, target_ulong *val) +static RISCVException read_mnepc(CPURISCVState *env, int csrno, + target_ulong *val) { *val = env->mnepc; return RISCV_EXCP_NONE; } -static int write_mnepc(CPURISCVState *env, int csrno, target_ulong val) +static RISCVException write_mnepc(CPURISCVState *env, int csrno, + target_ulong val, uintptr_t ra) { env->mnepc = val; return RISCV_EXCP_NONE; } -static int read_mncause(CPURISCVState *env, int csrno, target_ulong *val) +static RISCVException read_mncause(CPURISCVState *env, int csrno, + target_ulong *val) { *val = env->mncause; return RISCV_EXCP_NONE; } -static int write_mncause(CPURISCVState *env, int csrno, target_ulong val) +static RISCVException write_mncause(CPURISCVState *env, int csrno, + target_ulong val, uintptr_t ra) { env->mncause = val; return RISCV_EXCP_NONE; } -static int read_mnstatus(CPURISCVState *env, int csrno, target_ulong *val) +static RISCVException read_mnstatus(CPURISCVState *env, int csrno, + target_ulong *val) { *val = env->mnstatus; return RISCV_EXCP_NONE; } -static int write_mnstatus(CPURISCVState *env, int csrno, target_ulong val) +static RISCVException write_mnstatus(CPURISCVState *env, int csrno, + target_ulong val, uintptr_t ra) { target_ulong mask = (MNSTATUS_NMIE | MNSTATUS_MNPP); @@ -5540,7 +5546,7 @@ static RISCVException riscv_csrrw_do64(CPURISCVState *env, int csrno, if (write_mask) { new_value = (old_value & ~write_mask) | (new_value & write_mask); if (csr_ops[csrno].write) { - ret = csr_ops[csrno].write(env, csrno, new_value); + ret = csr_ops[csrno].write(env, csrno, new_value, 0); if (ret != RISCV_EXCP_NONE) { return ret; } @@ -5603,7 +5609,7 @@ static RISCVException riscv_csrrw_do128(CPURISCVState *env, int csrno, } } else if (csr_ops[csrno].write) { /* avoids having to write wrappers for all registers */ - ret = csr_ops[csrno].write(env, csrno, int128_getlo(new_value)); + ret = csr_ops[csrno].write(env, csrno, int128_getlo(new_value), 0); if (ret != RISCV_EXCP_NONE) { return ret; } @@ -5714,7 +5720,7 @@ static RISCVException read_jvt(CPURISCVState *env, int csrno, } static RISCVException write_jvt(CPURISCVState *env, int csrno, - target_ulong val) + target_ulong val, uintptr_t ra) { env->jvt = val; return RISCV_EXCP_NONE; From patchwork Fri Apr 25 15:23:06 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 884351 Delivered-To: patch@linaro.org Received: by 2002:a5d:474d:0:b0:38f:210b:807b with SMTP id o13csp4021803wrs; Fri, 25 Apr 2025 08:24:27 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXDPeS3DV6gjT2wZANH4o/paclTyA62PGd8uQO+hXY59z+OmMwATY07NIjsgw1XPfuFouWxEA==@linaro.org X-Google-Smtp-Source: AGHT+IHfWL9S1UyNeEimobf+w4X+Y7ub5xmNChREc4W1CrMI48NtKR08Zo7iZXgTlG3VDADbXzob X-Received: by 2002:a05:620a:254d:b0:7c5:4463:29a8 with SMTP id af79cd13be357-7c96685c31cmr982385a.11.1745594667557; Fri, 25 Apr 2025 08:24:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1745594667; cv=none; d=google.com; s=arc-20240605; b=OM5EG3ugmWZf3qtM5tPequCFKf0vWtdLH0NNEQ7+zgY77mbdFc2kmeFkY3p1VEQwdZ KMVyTo3BEopvaJM94S+rjs7haf0D6eAy2m1MAoylV56usAr7ggRAeyyYtMPgNXHFn8xR LceaO0f23E4wRcQ+Ya6VNcx8uCmX+tfFRHJBB4e4hiwdAzivV5uo8jfNnt0oaEGaQNNA DCdjrsCFxjsf+HolN5F50UYsybWDpJf/PFzD+H3IeTQqY61Pl81etPjhCj9LU/AHP678 g9HiIcvEjxVkoHpimyjk0gpUn2PtWSJaSkrg+X39goyZOBHCyvakEZuC09i8Swk7sbLk nvqw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=8BkGqEuOn61y/rqWawhxPHU+tldQWor40BhhDmmwEXQ=; fh=tbsDrCdppOEjIVmMhMa/fTPU8DqwnjNG7rxGE3k2FrY=; b=MudryyznkUZbP7GjXgRLnieadGkQ/Xt/Pgtkd+AhWWlqYYjqxxF/Q5yK/sSz2amnuX KS3lXitu3v0YG6VKSPSShc58gQSKcV5uqHBcR/bItpfNo6yx2PH4wAUoCivS2HDIUGLa Vy4jGrR1ugTZgbjxu/Wb4RcvpHEl7Lrl03txvKlV9gC3fIdDzF4DwKVcl5iJClQZDrBM 4yw6qUcgEc0z0n4WyZ6D2rBdrKPkKgIHmEwL6z8q75Sj/Mpit3abSW/x4725Ydy4Q8PV XX4CH8b98lWl2vSzzjOYYArPJlia+C8hMlF7SgzMgl1Z9RXZm0bPLiDBlqQ0uILj0xpk fLig==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=SsBbCtFI; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-7c958c9e306si377685085a.54.2025.04.25.08.24.27 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 25 Apr 2025 08:24:27 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=SsBbCtFI; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1u8Ktc-0001dL-QB; Fri, 25 Apr 2025 11:23: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 1u8Kta-0001cR-PO for qemu-devel@nongnu.org; Fri, 25 Apr 2025 11:23:18 -0400 Received: from mail-pf1-x434.google.com ([2607:f8b0:4864:20::434]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1u8KtY-0002oh-4K for qemu-devel@nongnu.org; Fri, 25 Apr 2025 11:23:18 -0400 Received: by mail-pf1-x434.google.com with SMTP id d2e1a72fcca58-736c1138ae5so2394907b3a.3 for ; Fri, 25 Apr 2025 08:23:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1745594595; x=1746199395; 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=8BkGqEuOn61y/rqWawhxPHU+tldQWor40BhhDmmwEXQ=; b=SsBbCtFIw5iTUa0ymAkHo66jiTp5kKdO9N01HHUXtHnfwNJbkNqI6i6RstPmmyFDnT aSVhvlbHW+Yjt6NdJk8So55h0cY17MRmT5B01w4ASRm8ZGW1PF6FAnOlqYXLk5I/8JWZ n2iVgKNrT7QY26YPJIb/7YQhueq07XsxJ/X3gBSl/y0X/HO5KDB2u7NYEPGrzIrpxJAO 4rEcKHqPR/Y0GuFP89jO+rSk6ON4PnwFiASILyr4kLbXVXE3kKk6siau7SyeESE98C8U jer68v5Wyay7R5YruE6m0dRjflcSj70vgvtu9N9yJa42SRE0SWuBTTnCkjgHt07POKQP X6sQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1745594595; x=1746199395; 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=8BkGqEuOn61y/rqWawhxPHU+tldQWor40BhhDmmwEXQ=; b=Pu4MqJ+y3SC2g+jxrOoyX68QHGq+eLnL7kJILvErLd7eKIejTDsCBaD5vKPDfptEUR 5EE0woga+XAFZBoo62R5S45GjVYZNMMlQ+lDjmOnp/qXvWbCwYe4VVwAkyPvBqeDKlFO LyWFPSf+WWZaRuBssXk53zbc4Zx4YoBw31BydzVJPwi0scTURVYbVo5zYA4iKqcqAqq7 Ku9lmuqE1KfLNODwDxlhPpqTBNIViUVCTQLhpmfPDls1ji8xV3+B56Huetr8o65Cl3Bi 7KwH3ixaNmCB0gEnoz1LVLX9kak86/bgPVieTEQC/fcf4yrxu3IjPJFTmkWmsprwgyZ0 DPiA== X-Gm-Message-State: AOJu0YyWui5h1S4dqa51KYLUkDUsva13lz1OnpMh+IfTgqb/zUnse8+7 np5orDcs4q43PVCT0XzfbYGXY/MwTv2xgHLVEVpiPL/5vGT7KkLVVP48zdo+JlQRDaFJwWt59uO t X-Gm-Gg: ASbGncuHQ44QlfMUsVKUZEoZgT7ycjHjINa58Ulb/amR2/e+Wv5ge7a4fQ5Kepz2miZ hBOuBnvMGM0aGG32SdbC6P3ngU/hzTaZDNxYjLEZrxpTVMSlLsfzc9ncu/0VPZywISLfKICXb+E W2WlBwdVwlFxf0Aa6F0oNmNMOiURj4tNOUBMx+OSlEXFJ7iC3eODCOpxzpALjMzI438ByF/M0ZR 0ywCV4uNb+4TNLf4Ndn0jsIailE5pXhbhQU7tg8IQV3V4zXXJVc43HdDbGKr8Twf/PDZ5ogI9tu Mc1L1LRyHmASptGoDeoQhrOfU8mnfhH1VSGLT71321/VjYFoB5ilxn6tgtVAF8uBDfcgULz//JQ = X-Received: by 2002:a05:6a00:18a2:b0:73e:598:7e5b with SMTP id d2e1a72fcca58-73fd6af4105mr3402564b3a.1.1745594594677; Fri, 25 Apr 2025 08:23:14 -0700 (PDT) Received: from stoup.. (71-212-47-143.tukw.qwest.net. [71.212.47.143]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-73e25a6a49esm3390466b3a.106.2025.04.25.08.23.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Apr 2025 08:23:14 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-riscv@nongnu.org, alistair.francis@wdc.com, dbarboza@ventanamicro.com Subject: [PATCH 2/7] target/riscv: Pass ra to riscv_csrrw_do64 Date: Fri, 25 Apr 2025 08:23:06 -0700 Message-ID: <20250425152311.804338-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250425152311.804338-1-richard.henderson@linaro.org> References: <20250425152311.804338-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::434; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x434.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, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- target/riscv/csr.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/target/riscv/csr.c b/target/riscv/csr.c index 6f1f69eba6..e9c2f95b6e 100644 --- a/target/riscv/csr.c +++ b/target/riscv/csr.c @@ -5516,7 +5516,8 @@ static inline RISCVException riscv_csrrw_check(CPURISCVState *env, static RISCVException riscv_csrrw_do64(CPURISCVState *env, int csrno, target_ulong *ret_value, target_ulong new_value, - target_ulong write_mask) + target_ulong write_mask, + uintptr_t ra) { RISCVException ret; target_ulong old_value = 0; @@ -5546,7 +5547,7 @@ static RISCVException riscv_csrrw_do64(CPURISCVState *env, int csrno, if (write_mask) { new_value = (old_value & ~write_mask) | (new_value & write_mask); if (csr_ops[csrno].write) { - ret = csr_ops[csrno].write(env, csrno, new_value, 0); + ret = csr_ops[csrno].write(env, csrno, new_value, ra); if (ret != RISCV_EXCP_NONE) { return ret; } @@ -5569,7 +5570,7 @@ RISCVException riscv_csrr(CPURISCVState *env, int csrno, return ret; } - return riscv_csrrw_do64(env, csrno, ret_value, 0, 0); + return riscv_csrrw_do64(env, csrno, ret_value, 0, 0, 0); } RISCVException riscv_csrrw(CPURISCVState *env, int csrno, @@ -5581,7 +5582,7 @@ RISCVException riscv_csrrw(CPURISCVState *env, int csrno, return ret; } - return riscv_csrrw_do64(env, csrno, ret_value, new_value, write_mask); + return riscv_csrrw_do64(env, csrno, ret_value, new_value, write_mask, 0); } static RISCVException riscv_csrrw_do128(CPURISCVState *env, int csrno, @@ -5647,9 +5648,7 @@ RISCVException riscv_csrr_i128(CPURISCVState *env, int csrno, * accesses */ target_ulong old_value; - ret = riscv_csrrw_do64(env, csrno, &old_value, - (target_ulong)0, - (target_ulong)0); + ret = riscv_csrrw_do64(env, csrno, &old_value, 0, 0, 0); if (ret == RISCV_EXCP_NONE && ret_value) { *ret_value = int128_make64(old_value); } @@ -5681,7 +5680,7 @@ RISCVException riscv_csrrw_i128(CPURISCVState *env, int csrno, target_ulong old_value; ret = riscv_csrrw_do64(env, csrno, &old_value, int128_getlo(new_value), - int128_getlo(write_mask)); + int128_getlo(write_mask), 0); if (ret == RISCV_EXCP_NONE && ret_value) { *ret_value = int128_make64(old_value); } From patchwork Fri Apr 25 15:23:07 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 884358 Delivered-To: patch@linaro.org Received: by 2002:a5d:474d:0:b0:38f:210b:807b with SMTP id o13csp4022389wrs; Fri, 25 Apr 2025 08:25:37 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXgs8ZDLMIskD2V5Lo8OFf3YmzHAE0m93g6rXPPxt/GdeeHR4Glk68VTh/3YUYfpibmjT7HuA==@linaro.org X-Google-Smtp-Source: AGHT+IGn6e2BdKViJm9ly/gehwrEgYzrVIBOotAqJtEQxcF5k+d5tePV+PFkKvoUspz+IiPASbg+ X-Received: by 2002:a05:6102:3f8c:b0:4bb:d062:430 with SMTP id ada2fe7eead31-4d5404faea1mr2235745137.0.1745594737708; Fri, 25 Apr 2025 08:25:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1745594737; cv=none; d=google.com; s=arc-20240605; b=jJawrMyz2uJ09mFeO5SB/sXIj1FM5rUD9C+0/uLWct7LO06aS7T7nm89kpJvZg+kGI E2ixnHq29hICxAHBI1THcwkDTbO7etvGR4sRmcpF31b5vcpLeyI/mOBamVZrfb/7Bj99 exur54kwe8hDxEo7mo1XvqLHwGp9X9ux6tnqGo8EECvlQ+MVtvmuQ8SPCfH1OQSclAXJ pfTDdehxv9YiHlf0Nvuguzfy0yvOUUdoeaF3LBfpm6YSbPEO74LyfiJ7US6AY5BsCOlF D6vnaBAL6mQgFC0H8wz9AXOPwAUdjlQOIpDrYb42rfyWaO2G/37+MzKxtXla+gW1vs0Z Sw/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=DFIjN5FugvOLKOwxhVcNRX7EfVOZPbGYkwA/+pKFgdA=; fh=tbsDrCdppOEjIVmMhMa/fTPU8DqwnjNG7rxGE3k2FrY=; b=gmmqWH+42yVTdv04K2hJX5h35IWtwhV1GIb1aoxJ5HXmE+MOmXlMRF9X64G9rYFkOU qWlNn1ja+PyAcNI675BRkammcRkIsBRsGMd+yXJxgyDq8N20/qhfU6v1v459UWshJhTC Ns2ybNY4Dr2h/A11BZu01oinSeSNQ9piJ3cKpzocsfNs/6/sqEBxgCM4QPD+gdRU4gvR ka1QZ6iEYh2TSyYHDykb9wscKgNN5JVCkH+J4tSNrhrym8pz4AjMd3zu/eO1nbl/UTJ6 AgpVda6VzGpbgWYPDiAbM/b1TU57YI9MyTNQNZoLVLUwB/Sh4+B5IUuKXYdP4hSUE980 lfTA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=oOeCT9xF; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id a1e0cc1a2514c-877aee86fb5si1181813241.110.2025.04.25.08.25.37 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 25 Apr 2025 08:25:37 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=oOeCT9xF; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1u8Ktd-0001eR-R6; Fri, 25 Apr 2025 11:23:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1u8Ktc-0001dE-5p for qemu-devel@nongnu.org; Fri, 25 Apr 2025 11:23:20 -0400 Received: from mail-pg1-x536.google.com ([2607:f8b0:4864:20::536]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1u8KtZ-0002p0-Fw for qemu-devel@nongnu.org; Fri, 25 Apr 2025 11:23:19 -0400 Received: by mail-pg1-x536.google.com with SMTP id 41be03b00d2f7-af523f4511fso2284078a12.0 for ; Fri, 25 Apr 2025 08:23:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1745594595; x=1746199395; 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=DFIjN5FugvOLKOwxhVcNRX7EfVOZPbGYkwA/+pKFgdA=; b=oOeCT9xFE3Eq5oxqEdjHH4jqrIZUsaWlxl1zXzFGDxtyiXdNk0b5RD20mzqkZiDVrV 2V9VCsC/Pv+TwgA0IQM8KCAV4wxj53ZQXLpNDG3bha7xiO1QudCqlj7X2vMmVUxyrNIg GTUW5dp3VlrlseHjHh2suKvr8liLCynXPpdol++hIUFSuwnp8JhEegMfANqYhIIFnESa ahCcxmPBKDvLJ71cyk2STd1k/Dn4vIecscgkjKw0EizOAUJdykQcxIV8phERBHYtGNNO 8fGJLdmXGbQ9kotBg295lRf5Oooi17M5Khm57dcQLa0y5YcXxweDuUcRT+xduUuwtndK CfwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1745594595; x=1746199395; 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=DFIjN5FugvOLKOwxhVcNRX7EfVOZPbGYkwA/+pKFgdA=; b=Q4g0aA9rxs2IefNOuhYRSIyuZJuApDjNFgAB5gE9zz93uyHqzLrJND5O39KfixrTEg bMBl/hOMlHcMWD3T4B2tx/slIS8RPRjR6S2JdJfYKKKgKmoa+VDBquMlsn2AuxngvePz jaCV82QIvDRMwi9Uvu0P8JOiWf+7lZsvM+xZqnp4+5kq/rkjU5PYVDv3drBDbl9+xYdj YEFeYJVV1dAMY6+if2fpMfUIFhjRY9LPIhbUBtelDMwPPkfJCEsn9HwiYlN8c0KbXzK/ zdcjAljamV5yZaIT+SE8fslDK/wBNuyuQIdpqYigjbxllhOPoFmEzdpEtLFpRIFRVS2Z 4o/w== X-Gm-Message-State: AOJu0YyIMDF5TsO9QkzJN3+DtV2KwoysvShv+NrjqMCet5maLyOL29TR SqF/BwryQjQeFx36ZJ5APsUdV1btA2FSCb4m/+JcZIx5Ee5xzO2far6BBsOchEIsyw6I4SwL7kG k X-Gm-Gg: ASbGncvO6eCj0e+gXRL8nyM+bYu4QGJgYG3MD9oZ4w5SopYHpzG2LgOIbPjKewXs7l9 +9BX5toaWFXxDrHUWS5WqCUqOpHOByxSZZ2n3Teau5nz3ladYZDZ5+tDeVcBzUVWhqei70UNxrp 56s7iw6SXRb/2G9/ozmKZtkMm3CpNu7T9c9hVBKtObGlVGpxSRyn/hgvOF0M/6l9UmCCxsWxf/K 1opUDSY4GRcgZoroqJyfds3a5R+te1h1cB8TjarMFCoPy3oQMqyolrK82OdS8vWBOYf7kZsIeXC st/mZ3mHiARF8UkSfoI6l9ehaQnJKu186/Sr/Pg6hrwBGhjpTaWJeuNddLHjY0+b6Tkv1s/uizo = X-Received: by 2002:a05:6a21:920b:b0:1f5:8655:3287 with SMTP id adf61e73a8af0-2045b9f6f37mr4592429637.40.1745594595499; Fri, 25 Apr 2025 08:23:15 -0700 (PDT) Received: from stoup.. (71-212-47-143.tukw.qwest.net. [71.212.47.143]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-73e25a6a49esm3390466b3a.106.2025.04.25.08.23.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Apr 2025 08:23:15 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-riscv@nongnu.org, alistair.francis@wdc.com, dbarboza@ventanamicro.com Subject: [PATCH 3/7] target/riscv: Pass ra to riscv_csrrw_do128 Date: Fri, 25 Apr 2025 08:23:07 -0700 Message-ID: <20250425152311.804338-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250425152311.804338-1-richard.henderson@linaro.org> References: <20250425152311.804338-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::536; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x536.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, 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- target/riscv/csr.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/target/riscv/csr.c b/target/riscv/csr.c index e9c2f95b6e..d62d1aaaee 100644 --- a/target/riscv/csr.c +++ b/target/riscv/csr.c @@ -5588,7 +5588,7 @@ RISCVException riscv_csrrw(CPURISCVState *env, int csrno, static RISCVException riscv_csrrw_do128(CPURISCVState *env, int csrno, Int128 *ret_value, Int128 new_value, - Int128 write_mask) + Int128 write_mask, uintptr_t ra) { RISCVException ret; Int128 old_value; @@ -5610,7 +5610,7 @@ static RISCVException riscv_csrrw_do128(CPURISCVState *env, int csrno, } } else if (csr_ops[csrno].write) { /* avoids having to write wrappers for all registers */ - ret = csr_ops[csrno].write(env, csrno, int128_getlo(new_value), 0); + ret = csr_ops[csrno].write(env, csrno, int128_getlo(new_value), ra); if (ret != RISCV_EXCP_NONE) { return ret; } @@ -5637,7 +5637,7 @@ RISCVException riscv_csrr_i128(CPURISCVState *env, int csrno, if (csr_ops[csrno].read128) { return riscv_csrrw_do128(env, csrno, ret_value, - int128_zero(), int128_zero()); + int128_zero(), int128_zero(), 0); } /* @@ -5667,7 +5667,8 @@ RISCVException riscv_csrrw_i128(CPURISCVState *env, int csrno, } if (csr_ops[csrno].read128) { - return riscv_csrrw_do128(env, csrno, ret_value, new_value, write_mask); + return riscv_csrrw_do128(env, csrno, ret_value, + new_value, write_mask, 0); } /* From patchwork Fri Apr 25 15:23:08 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 884353 Delivered-To: patch@linaro.org Received: by 2002:a5d:474d:0:b0:38f:210b:807b with SMTP id o13csp4022111wrs; Fri, 25 Apr 2025 08:25:02 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWNLnGl+4t6gjrn/3JLrsjWlXqC2U1GV/xmdZKoQ6/nLx86iTPTsK004DCESoZob2fsD/9hUg==@linaro.org X-Google-Smtp-Source: AGHT+IE1PmsKZPF4oKxyb8QgBQl19lbZ6gb/o0mHefRm0eTEKgN1pqYQdbGY+xyV2evgJE4ojKQb X-Received: by 2002:ac8:7d96:0:b0:478:f76c:191d with SMTP id d75a77b69052e-4801eada17amr42443381cf.52.1745594702736; Fri, 25 Apr 2025 08:25:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1745594702; cv=none; d=google.com; s=arc-20240605; b=ad4EFcySnTGLfnjMiKNdQFIQTX2Sy1MQcJDM2ek4kh6KZNKAln5O2afgobtwTYJ0zR gOh+AT80ZoppdUAywH2rdEXedeoMDtpwekpwZI6FqwmwKxOz5303kYdeuAV8U5S9OsY/ WOdGtP3P+XAexickmrl0jALQ7lWIaT3PeF/EnJNWfP3+EPYh9vGsCsdn8GVv9m5aw3DD sxmt68lmxEQsapme6rvikT7tgLSKNhhxEDRiVDolgTZk/0TsRM9gHDvA3nn/Hq1YMhAs C+Z5MeLiWBK1oKv4GwhoLxWBBi0seNZbdaY4Qqye2eScVKaVllgLBtk3AxLp62gFlpQC 6Rhg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=2+F3AGtcq0LBY9UzRHTX0Z+/0ocsWmI8LW9rY6+lCBw=; fh=tbsDrCdppOEjIVmMhMa/fTPU8DqwnjNG7rxGE3k2FrY=; b=B0lwLVITBiZT9YaJtVRLNtLDL29NiK9FJQ9KDGm5QyEIWTEl1C/ehkq+jR9/RqRMin btGkcyWQkt6CBsUJtcNgWDkevlriwmcQDmcMy1sgWt3X2NdLTBC1mKs0AaYBpGV67iHd Sfg+ONUPdBR8gdj/bdfuQJWPh2oDlenviVtvkwCI7sR2qczwskXNU0g9UvkMdq5xOctm KUlSnCH4SLbSn3nNQtRq7P6ZpBynxkiLVr9CgPZos3lglUn7HoTp18qX13egU/LI7MsP 9gaTff6Lhg6uo/rKgoNhm3tZKn+VuXdn+uZIvuUVbfUvFy3VhDhFTf5v3cU9wWepvItx TOPA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PXvBxxKf; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d75a77b69052e-47e9f2ca824si43110811cf.112.2025.04.25.08.25.02 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 25 Apr 2025 08:25:02 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PXvBxxKf; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1u8Ktj-0001iz-GL; Fri, 25 Apr 2025 11:23:27 -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 1u8Kte-0001fQ-Vt for qemu-devel@nongnu.org; Fri, 25 Apr 2025 11:23:23 -0400 Received: from mail-pf1-x430.google.com ([2607:f8b0:4864:20::430]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1u8KtZ-0002p9-Mw for qemu-devel@nongnu.org; Fri, 25 Apr 2025 11:23:22 -0400 Received: by mail-pf1-x430.google.com with SMTP id d2e1a72fcca58-72d3b48d2ffso2347731b3a.2 for ; Fri, 25 Apr 2025 08:23:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1745594596; x=1746199396; 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=2+F3AGtcq0LBY9UzRHTX0Z+/0ocsWmI8LW9rY6+lCBw=; b=PXvBxxKfIyF8K24W4IVUvymO0X8dhTAPpKItVUU549tV+zdy6NJI5MnENllzGxgKNU Ll7X9idmYUg2GjdiBH4ZDg/gk1N+GWPqL+J+YD7pwCdH57mz4WhsNqpNKaWTPhMFQyjF uSjnhmCKeAVAiqiYKh6CEt14vBrtWMH9wKKaQI/Q2QLu0yVnC5VjzpNZJwdKsPqkvtAG jjMXR7K4tysv4BEkkgjOfJcr63aZmT9XWRHK5XoDIqDqhxO6FFTY5i5WwQ3Z6squtKUe nkKXtozimFOK7rLNL8XOWIS4500/Rsjl7G8eBICc98nlIMk8ZZd9yi54xLcoIf7SMnk5 B7HQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1745594596; x=1746199396; 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=2+F3AGtcq0LBY9UzRHTX0Z+/0ocsWmI8LW9rY6+lCBw=; b=j/Fev1jDAzqp39fVa0EdvmvP9UMOgK2/O9K9yh3SzgyxTVeT//iSZarwTgZs/fKzmJ zQS7l95sN0TXkOPoWSl9IZQAIoaz7Z1CGkcdGSzqNnwinaO8/np6nps4zqiXT9Ec/uTb zJn2O7gObcSwhnJiGle8XVXTSuXvYRLMpLI4AyelguCT1MUVDC1ruME8usjtuFm2/2LZ Rxj4tyJvijZApglzK4ExCOYHQLAQ7xOyjK1XzRSdrkSJI6KFhYkraXV3zslr2eTSY8eq TkjqpnBRbjlzVSiIgwZRPM65RUnsK+QdUD2A35sbeVxzrjEZD/nXF/XznU26FFR6P0bZ dosQ== X-Gm-Message-State: AOJu0Ywd1/CYaEhqPHN9eFSW8fQ3Ad9qRjAx5oMSk60TXMR/W+/9d6B/ covsJBqlbReJw+OJLBW0zwiEH8JxXUh4lpLB69pLSFmK4lYiyme/UxaNh20UEmwQswQkk2XPHeM B X-Gm-Gg: ASbGncv0lZCNawEbbt6zM3BOTYPctaBc37QocMF85/g/CqG1SeTE21Sd4cn8DPzR1/4 04m6VhdO06k/29e/esHBrMPl5SeGqmhCEPDDXiJMVbGoiMNU8LokLqHxFxjqt1ygOg8Xx/GrCgv qHlDnP72QAIu4imh83/1QQCxla3MuUONeyQtbrPeZNniIWCD+gFHJ2JfQ3UWCNeE+Sb8AS6Duox dYqf3WG8kSWMiFAeXcDMhzIm++Mb4Vc48nXYD8fPr2djZmg0y6bWKq7wI8SFm6tQVOuEZ3/P1ZX 2cCUHKn31IAmt6qruxVxCnCw9EDlrj1x8fGXO9Vs+NJj+XHJgu/F5Z4eeF+b41t+CCyijPXme0A = X-Received: by 2002:a05:6a00:b84:b0:736:4fe0:2661 with SMTP id d2e1a72fcca58-73fd73c7ff1mr3260845b3a.11.1745594596099; Fri, 25 Apr 2025 08:23:16 -0700 (PDT) Received: from stoup.. (71-212-47-143.tukw.qwest.net. [71.212.47.143]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-73e25a6a49esm3390466b3a.106.2025.04.25.08.23.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Apr 2025 08:23:15 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-riscv@nongnu.org, alistair.francis@wdc.com, dbarboza@ventanamicro.com Subject: [PATCH 4/7] target/riscv: Pass ra to riscv_csrrw Date: Fri, 25 Apr 2025 08:23:08 -0700 Message-ID: <20250425152311.804338-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250425152311.804338-1-richard.henderson@linaro.org> References: <20250425152311.804338-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::430; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x430.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, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- target/riscv/cpu.h | 8 ++++---- hw/riscv/riscv_hart.c | 2 +- target/riscv/csr.c | 8 ++++---- target/riscv/op_helper.c | 4 ++-- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h index 4d41a66d72..2c0524d0be 100644 --- a/target/riscv/cpu.h +++ b/target/riscv/cpu.h @@ -816,8 +816,8 @@ 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); + target_ulong *ret_value, target_ulong new_value, + target_ulong write_mask, uintptr_t ra); RISCVException riscv_csrrw_debug(CPURISCVState *env, int csrno, target_ulong *ret_value, target_ulong new_value, @@ -826,13 +826,13 @@ RISCVException riscv_csrrw_debug(CPURISCVState *env, int csrno, static inline void riscv_csr_write(CPURISCVState *env, int csrno, target_ulong val) { - riscv_csrrw(env, csrno, NULL, val, MAKE_64BIT_MASK(0, TARGET_LONG_BITS)); + riscv_csrrw(env, csrno, NULL, val, MAKE_64BIT_MASK(0, TARGET_LONG_BITS), 0); } static inline target_ulong riscv_csr_read(CPURISCVState *env, int csrno) { target_ulong val = 0; - riscv_csrrw(env, csrno, &val, 0, 0); + riscv_csrrw(env, csrno, &val, 0, 0, 0); return val; } diff --git a/hw/riscv/riscv_hart.c b/hw/riscv/riscv_hart.c index a55d156668..2ebbf41b18 100644 --- a/hw/riscv/riscv_hart.c +++ b/hw/riscv/riscv_hart.c @@ -72,7 +72,7 @@ static void csr_call(char *cmd, uint64_t cpu_num, int csrno, uint64_t *val) ret = riscv_csrr(env, csrno, (target_ulong *)val); } else if (strcmp(cmd, "set_csr") == 0) { ret = riscv_csrrw(env, csrno, NULL, *(target_ulong *)val, - MAKE_64BIT_MASK(0, TARGET_LONG_BITS)); + MAKE_64BIT_MASK(0, TARGET_LONG_BITS), 0); } g_assert(ret == RISCV_EXCP_NONE); diff --git a/target/riscv/csr.c b/target/riscv/csr.c index d62d1aaaee..097640e25d 100644 --- a/target/riscv/csr.c +++ b/target/riscv/csr.c @@ -5574,15 +5574,15 @@ RISCVException riscv_csrr(CPURISCVState *env, int csrno, } RISCVException riscv_csrrw(CPURISCVState *env, int csrno, - target_ulong *ret_value, - target_ulong new_value, target_ulong write_mask) + target_ulong *ret_value, target_ulong new_value, + target_ulong write_mask, uintptr_t ra) { RISCVException ret = riscv_csrrw_check(env, csrno, true); if (ret != RISCV_EXCP_NONE) { return ret; } - return riscv_csrrw_do64(env, csrno, ret_value, new_value, write_mask, 0); + return riscv_csrrw_do64(env, csrno, ret_value, new_value, write_mask, ra); } static RISCVException riscv_csrrw_do128(CPURISCVState *env, int csrno, @@ -5704,7 +5704,7 @@ RISCVException riscv_csrrw_debug(CPURISCVState *env, int csrno, if (!write_mask) { ret = riscv_csrr(env, csrno, ret_value); } else { - ret = riscv_csrrw(env, csrno, ret_value, new_value, write_mask); + ret = riscv_csrrw(env, csrno, ret_value, new_value, write_mask, 0); } #if !defined(CONFIG_USER_ONLY) env->debugger = false; diff --git a/target/riscv/op_helper.c b/target/riscv/op_helper.c index 5b0db2c45a..aee16e2e3a 100644 --- a/target/riscv/op_helper.c +++ b/target/riscv/op_helper.c @@ -71,7 +71,7 @@ target_ulong helper_csrr(CPURISCVState *env, int csr) void helper_csrw(CPURISCVState *env, int csr, target_ulong src) { target_ulong mask = env->xl == MXL_RV32 ? UINT32_MAX : (target_ulong)-1; - RISCVException ret = riscv_csrrw(env, csr, NULL, src, mask); + RISCVException ret = riscv_csrrw(env, csr, NULL, src, mask, GETPC()); if (ret != RISCV_EXCP_NONE) { riscv_raise_exception(env, ret, GETPC()); @@ -82,7 +82,7 @@ target_ulong helper_csrrw(CPURISCVState *env, int csr, target_ulong src, target_ulong write_mask) { target_ulong val = 0; - RISCVException ret = riscv_csrrw(env, csr, &val, src, write_mask); + RISCVException ret = riscv_csrrw(env, csr, &val, src, write_mask, GETPC()); if (ret != RISCV_EXCP_NONE) { riscv_raise_exception(env, ret, GETPC()); From patchwork Fri Apr 25 15:23:09 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 884355 Delivered-To: patch@linaro.org Received: by 2002:a5d:474d:0:b0:38f:210b:807b with SMTP id o13csp4022316wrs; Fri, 25 Apr 2025 08:25:27 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVML+WpCwCjgOShVwh11Wgi31O8xFlVoHHVCBTWajWJuvOk21/KgFj87Co+A35fF0bBWhdVgA==@linaro.org X-Google-Smtp-Source: AGHT+IEiCd02QaVk6L75oru1oLieP54PU353p+3LyLrTSFUAfrH2iCJV3viVOWhV9fEZeLLO5xf/ X-Received: by 2002:a05:6214:3015:b0:6e8:f88f:b96b with SMTP id 6a1803df08f44-6f4cb99d3d8mr44599206d6.9.1745594726988; Fri, 25 Apr 2025 08:25:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1745594726; cv=none; d=google.com; s=arc-20240605; b=BM9g7IkR6gLn43JOIeGs+OdYjlZz5J9VF3X2J34r/3qDMWaA/muEr4HteU4wH49/pH qU3GCKPgYuhY242O3zhZJZK37n0ibIRUq3SiRJhmHz7VT4t0+TChJnAHaBah1HahsqXE 2uoXMOh/00HdfeGfhDNixLzOdl9OObySQojCRHj5O+6M71kdk01CDx1PpAd/fcanU3A/ /ei3RH3I9ttswqSXSUhrNw1rI1hmSMs0rfBDZVsTwlUPKlkWAcOrOBy3DBzZ/aPMKTU9 Fcyp044F+e6X2tXV1iNA0HPz3cmh5s6YeKSBVRuLF/Xm2+b4CjLGLegZ7er6jGHtlpFe BzdA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=xNi29cUmvbhQyUeV6Au09yg4HVFM1Boo5sSDPMUFN5U=; fh=tbsDrCdppOEjIVmMhMa/fTPU8DqwnjNG7rxGE3k2FrY=; b=YFbeQswEHYEfYDP8gzBvSGn+Mc3C2PyNZHxmUnWlqynneHzvlU6JbjkW7DerSPiUTd R2eSewTbU0Csn49XRNcrO1sGFjsc3xfGkRsx/SJkrro0lJBUgv+Sr7t4KBsHq80/2kKm KeVswpAGFAb8sDVJN8TinBmfwqzWIlTaaYz8IqNB4kiEK9YqVGR5hwFpgCAGDE45pPxF JyjdI4g9EJ6YBtHiBDeHtkoPuROoUJabNqF+8pqGDIUpT/1RSxn9qySVsJ4U+p2uqr12 BEOKqonwe4zoxsAMYJPMiepoW7R5tt+F3hhSjJAUeC8au/KnmxtzSZBz7UYGSeI5XJBI tHXA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=rx9gA6NV; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 6a1803df08f44-6f4c08d287asi39188846d6.94.2025.04.25.08.25.26 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 25 Apr 2025 08:25:26 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=rx9gA6NV; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1u8Kth-0001hX-Sw; Fri, 25 Apr 2025 11:23:25 -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 1u8Kte-0001ea-25 for qemu-devel@nongnu.org; Fri, 25 Apr 2025 11:23:22 -0400 Received: from mail-pf1-x42c.google.com ([2607:f8b0:4864:20::42c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1u8Kta-0002pg-9w for qemu-devel@nongnu.org; Fri, 25 Apr 2025 11:23:21 -0400 Received: by mail-pf1-x42c.google.com with SMTP id d2e1a72fcca58-7376e311086so3238026b3a.3 for ; Fri, 25 Apr 2025 08:23:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1745594597; x=1746199397; 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=xNi29cUmvbhQyUeV6Au09yg4HVFM1Boo5sSDPMUFN5U=; b=rx9gA6NV10zGWYMDPQU5OVoiUC+3/KcF6utX5+3pkPZlD1rFMnV9NpOGNWsX0fOLpZ DfDB+3KyFQe15xQGzUquIiio7rnMCdJucRujH7MJhWGDN92rD9ahRFyBH7SISCKSb0QF /MnWQtKL9cCi4vPNwEASYvnY1ZcWckaJFBTCEsZAnCUA6/e4y4UNU9enfCYNhz+86/jb TrlOd9KRaaUMPMfWWeHM+3ugAvYIhxQYSpEz9wdm1eqD+QWNR6ZOOpx/PDBMwEuYn5bv RlZJGNevGD7Y2Kdi7pHvufXD8uye6K6ZesIbJVhUhl3f1UEa2Ex206MHw5rEqLh/tWFU tSsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1745594597; x=1746199397; 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=xNi29cUmvbhQyUeV6Au09yg4HVFM1Boo5sSDPMUFN5U=; b=oECiPlJLCQYSCe9gFKma1XrNHtq0OGSprWcHMG2UcpT0c3fW3QkaYfZvyB4ab3nX08 potK+6QQOnpwxRxqZBbLo4ObSWdCaMNk3m8d0yzNjWd0n3Koe1hW4erv5z13HaiP5Ifi amhkb6S+JozQKTo8BSKqIsEyVNUQys3RcXAKaJRWezJ7pPkKON7dyoOgxeAX7mBZHip+ G7HgbddrEqRP1YVgiWCXFvpB0aStwipbRl/ceJzPVSEqjG3smRos92ObG8OU8xhdnmmu jaRsTEKj8euIYzXp0srhxWy8P8klN43Trfl+ShwO8gQ3ihr7CRxRHGHAfgqiaFhkrBSo K3AQ== X-Gm-Message-State: AOJu0YxNRQGzdQSiGKlq3t4hIsAHEx1QPczGfdfmbheNA8EGInHI1jjW zCSgMRzCLhTa9rCISmCGn8Rqh4Xh3hhs7ZaJ6uEe7lihwGhqeM67sJ1xxfGJMdFzBiNr+8YZE5P s X-Gm-Gg: ASbGncsMOX0YRp/XL1FpsArXC3n8lk3N2q5u8eHhe9kzQZmZ0jgdpAsRvRehADpAz5D r9Z4FcyJ3P5gSlnQ1clxC+NrWb2xva7ZOBgcmURTStJjxme0CS+9Oc0Ly2R9/h2oZZOuWa3OLDL i2P9FtT6nynfn2mFWk4G/DwPz1vXKDZx1iv8xBqko2GzlqKHukcqZT26ZPzWZTDZ5EYF4sx1Vsc UMjtZU0A/ZKwTDZFulf846VfKKjY8vJ8yRNfOloQaOImiDtL1IM/rwEcd314VCWXoQidQRFnfTw ttCD1v4YNgXeGH50hEb5n4qAWjYqysu6nrqTAJ4MMDyci3EFtXhZGAaJzMLXNGBMS9q211s47fM = X-Received: by 2002:a05:6a00:1150:b0:736:692e:129 with SMTP id d2e1a72fcca58-73fd8f4f0a7mr4483681b3a.24.1745594596919; Fri, 25 Apr 2025 08:23:16 -0700 (PDT) Received: from stoup.. (71-212-47-143.tukw.qwest.net. [71.212.47.143]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-73e25a6a49esm3390466b3a.106.2025.04.25.08.23.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Apr 2025 08:23:16 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-riscv@nongnu.org, alistair.francis@wdc.com, dbarboza@ventanamicro.com Subject: [PATCH 5/7] target/riscv: Pass ra to riscv_csrrw_i128 Date: Fri, 25 Apr 2025 08:23:09 -0700 Message-ID: <20250425152311.804338-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250425152311.804338-1-richard.henderson@linaro.org> References: <20250425152311.804338-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::42c; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42c.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, 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- target/riscv/cpu.h | 4 ++-- target/riscv/csr.c | 8 ++++---- target/riscv/op_helper.c | 9 +++++---- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h index 2c0524d0be..8b84793b15 100644 --- a/target/riscv/cpu.h +++ b/target/riscv/cpu.h @@ -851,8 +851,8 @@ typedef RISCVException (*riscv_csr_op_fn)(CPURISCVState *env, int csrno, RISCVException riscv_csrr_i128(CPURISCVState *env, int csrno, Int128 *ret_value); RISCVException riscv_csrrw_i128(CPURISCVState *env, int csrno, - Int128 *ret_value, - Int128 new_value, Int128 write_mask); + Int128 *ret_value, Int128 new_value, + Int128 write_mask, uintptr_t ra); typedef RISCVException (*riscv_csr_read128_fn)(CPURISCVState *env, int csrno, Int128 *ret_value); diff --git a/target/riscv/csr.c b/target/riscv/csr.c index 097640e25d..a663f527a4 100644 --- a/target/riscv/csr.c +++ b/target/riscv/csr.c @@ -5656,8 +5656,8 @@ RISCVException riscv_csrr_i128(CPURISCVState *env, int csrno, } RISCVException riscv_csrrw_i128(CPURISCVState *env, int csrno, - Int128 *ret_value, - Int128 new_value, Int128 write_mask) + Int128 *ret_value, Int128 new_value, + Int128 write_mask, uintptr_t ra) { RISCVException ret; @@ -5668,7 +5668,7 @@ RISCVException riscv_csrrw_i128(CPURISCVState *env, int csrno, if (csr_ops[csrno].read128) { return riscv_csrrw_do128(env, csrno, ret_value, - new_value, write_mask, 0); + new_value, write_mask, ra); } /* @@ -5681,7 +5681,7 @@ RISCVException riscv_csrrw_i128(CPURISCVState *env, int csrno, target_ulong old_value; ret = riscv_csrrw_do64(env, csrno, &old_value, int128_getlo(new_value), - int128_getlo(write_mask), 0); + int128_getlo(write_mask), ra); if (ret == RISCV_EXCP_NONE && ret_value) { *ret_value = int128_make64(old_value); } diff --git a/target/riscv/op_helper.c b/target/riscv/op_helper.c index aee16e2e3a..e3770a2655 100644 --- a/target/riscv/op_helper.c +++ b/target/riscv/op_helper.c @@ -108,7 +108,7 @@ void helper_csrw_i128(CPURISCVState *env, int csr, { RISCVException ret = riscv_csrrw_i128(env, csr, NULL, int128_make128(srcl, srch), - UINT128_MAX); + UINT128_MAX, GETPC()); if (ret != RISCV_EXCP_NONE) { riscv_raise_exception(env, ret, GETPC()); @@ -116,13 +116,14 @@ void helper_csrw_i128(CPURISCVState *env, int csr, } target_ulong helper_csrrw_i128(CPURISCVState *env, int csr, - target_ulong srcl, target_ulong srch, - target_ulong maskl, target_ulong maskh) + target_ulong srcl, target_ulong srch, + target_ulong maskl, target_ulong maskh) { Int128 rv = int128_zero(); RISCVException ret = riscv_csrrw_i128(env, csr, &rv, int128_make128(srcl, srch), - int128_make128(maskl, maskh)); + int128_make128(maskl, maskh), + GETPC()); if (ret != RISCV_EXCP_NONE) { riscv_raise_exception(env, ret, GETPC()); From patchwork Fri Apr 25 15:23:10 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 884352 Delivered-To: patch@linaro.org Received: by 2002:a5d:474d:0:b0:38f:210b:807b with SMTP id o13csp4022091wrs; Fri, 25 Apr 2025 08:25:02 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXzbWpYtwaeTJNr37aX6pPpefPvRqpZFClQkjc2tEpDV2Kf0q+OJlytK0wx5MMLUGcgV40cWg==@linaro.org X-Google-Smtp-Source: AGHT+IGysFh//8KrBxVv7TOzxw0BtvdnjXW9byH1jO68U3+NusQR1r+Ui6JaH1/VSwZCFY+YRVZd X-Received: by 2002:ad4:5c83:0:b0:6eb:2f30:55cd with SMTP id 6a1803df08f44-6f4cbd3f954mr46469996d6.45.1745594701858; Fri, 25 Apr 2025 08:25:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1745594701; cv=none; d=google.com; s=arc-20240605; b=Nc9XWtxwi9B0W43AlJ4buxlkx9cSbbNKEwQ+E13H/DZWO7XWefk3tXrhekhWEQvcEO AcIuAH859pOn2sY8DTiLB7ht0NDyBqhSFccaxsAnTM0+ORawapvmP2fVNOvouBwPkOPT UzQbkLASzC9Akfa+PGs52zati2MD1JxShKn0mxHJn/c1HgIfpdM+AoQskq5olYbF0FLQ vbnag961/Tf/XOxzQdcCd5iNM8xC9AO0QUKdtcoqdIF35wGPVPGvcIfVaOL4T9GYOFCe 1RLZyAJezeqR4ES7zLE66XYc+3cSP4FWfKdyfK6CyCfzTLWxLhnv8O3YoNfRqOqu2gJj XfWw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=dwV8Ejbv3c17F+/2R9Q76cf7TrkhsGo+NtylDvgP+1E=; fh=tbsDrCdppOEjIVmMhMa/fTPU8DqwnjNG7rxGE3k2FrY=; b=k43sW0tFqbjl5TiB9yyecczspjmNfb8XEnpEKRLwIJByCeqLWxfvPtNOTpa/8VgDDH GZOAasRNkURqiU4kYT97EY9eGvj+AfkqXBCZecqpmHn4/Y0dAqS5itGJ3g6wrGJsXop7 9wEXZg8xcxS0iAFWFO5P/M4VlbLdcDdcZByJ++ikBjozig2lWQtxNrOE/Ty0v989n2m5 v4TaO/9eJiT2CPdNiqqzyZg6h2RjlUBrSMpOQU0He4xrUsSla/3paIV+6/VBH53HK36L hl24vlOcAuN5Kkrr4ClMkAwcKplTSSLg8yabiM/g77cNE4c8zuhqJ0EdZPfigy5uHrlX o/nA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=y4T1WAKa; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 6a1803df08f44-6f4c08d27b5si40627496d6.52.2025.04.25.08.25.01 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 25 Apr 2025 08:25:01 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=y4T1WAKa; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1u8Ktj-0001jH-HZ; Fri, 25 Apr 2025 11:23:27 -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 1u8Kte-0001fR-WF for qemu-devel@nongnu.org; Fri, 25 Apr 2025 11:23:23 -0400 Received: from mail-pg1-x52b.google.com ([2607:f8b0:4864:20::52b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1u8Ktb-0002ps-0c for qemu-devel@nongnu.org; Fri, 25 Apr 2025 11:23:22 -0400 Received: by mail-pg1-x52b.google.com with SMTP id 41be03b00d2f7-ae727e87c26so1597901a12.0 for ; Fri, 25 Apr 2025 08:23:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1745594597; x=1746199397; 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=dwV8Ejbv3c17F+/2R9Q76cf7TrkhsGo+NtylDvgP+1E=; b=y4T1WAKaY5FQDggR/Yg3D5BwRLn+HBbnlLQcgjwlQz4/nyheUxjpV5HyzBHEVFZS/r HAyfLmbj56xnGl2uiZXll3kpRlvACjHIAoXhSQf4D4H49AzUF1Rp+v59FoRuH6l13am5 r579Vg2roKaYyTkpzNJIaou5Rl83hux8E7ntFAU2Wz37g6etc5jDPlslJ4HHIf9lELvi 11ybf7555lsAC+0bf5Ojnqm1LnIpttVp379pE4nUOXbVRVNSVLPFeMhDVQvFfKsOijpe xJSGHXQY3CzzhBCkiV3fe1qyqG53QMj1eRqTwolun5d3nDaxVw5K78VCD//cIJI6IerK 50pw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1745594597; x=1746199397; 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=dwV8Ejbv3c17F+/2R9Q76cf7TrkhsGo+NtylDvgP+1E=; b=AK6LSOR33NoMJVxiD4+DBDljzVG8W+zude16G5stvJIvOlpQPIy+DJQoovimVWtvFk TOvXv+GmzsmNwIC5ObD0MlYcv5Ipj52sM53BBZcr8WVPXIANLON5McTRHGxnYGv+IXki VrxkoeUuhuShZFMt0Gwr6CW3brE71mR10qoVZxdjVbANoyBkKn3A5mOdwbGVdqpqViDs 6ykPJWh7aYZlqvsB7/RlGtNhgWMyW6WUaYLrKUlLKoYMM5j3blt/420zYqOQHCZGB8ge PKG5Ims+CTK3ojrIK2lJbs7fPlYglZc4hrw2CcwWBSLzVoNorfzOZZ6wO3HFb9/2HCqg OhqQ== X-Gm-Message-State: AOJu0YwcEP1JwU5P0bS77OuU0jEjwNmU081X88n9P5dOme5lN9qTLwcU pH4RggT2KEts7vSOZQI3BkNHESIaU0qLGAbOE11elMgXh8zm/j1wUw9MZs32o0RxrhU8elMkDd3 q X-Gm-Gg: ASbGnctFqApKPDKmf1HkYDj3mKWz55nfhIeNSEnCqyNR6ZrSVRERF1i/9fX16qQuccN rmA0JjgUCXY8mJMOakKCrJ6C1eJQ6H9oTnfQkpPK0XKQL63EjnNDpj4gXhfVurf47TR6DPxk/VL 9g/r58w38HpuB0AY2C8ie1aq0+TW5SXet48POzsvftddnVnpK73n4f84DYu4XZQaAIuaCtCrbQ5 nHAMoclIG8qraJcSq1SNJWTDTEYVt43yS5ALmUpDLX0AY1zI+W3Nht/R9MhggCv1N33Jq7LStNA +fPuU4r3F4ZVKllXyQ4Ow3yX9XFTctVqdqNzwuLrdgYpTJADYNlJueGO+p4Eoxoe5sPM17S76y4 = X-Received: by 2002:a05:6a21:3401:b0:203:9660:9e4a with SMTP id adf61e73a8af0-2045b9fa3f7mr3856001637.41.1745594597634; Fri, 25 Apr 2025 08:23:17 -0700 (PDT) Received: from stoup.. (71-212-47-143.tukw.qwest.net. [71.212.47.143]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-73e25a6a49esm3390466b3a.106.2025.04.25.08.23.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Apr 2025 08:23:17 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-riscv@nongnu.org, alistair.francis@wdc.com, dbarboza@ventanamicro.com Subject: [PATCH 6/7] target/riscv: Move insn_len to internals.h Date: Fri, 25 Apr 2025 08:23:10 -0700 Message-ID: <20250425152311.804338-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250425152311.804338-1-richard.henderson@linaro.org> References: <20250425152311.804338-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::52b; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x52b.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, 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- target/riscv/internals.h | 5 +++++ target/riscv/translate.c | 5 ----- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/target/riscv/internals.h b/target/riscv/internals.h index 213aff31d8..4570bd50be 100644 --- a/target/riscv/internals.h +++ b/target/riscv/internals.h @@ -201,4 +201,9 @@ static inline target_ulong adjust_addr_virt(CPURISCVState *env, return adjust_addr_body(env, addr, true); } +static inline int insn_len(uint16_t first_word) +{ + return (first_word & 3) == 3 ? 4 : 2; +} + #endif diff --git a/target/riscv/translate.c b/target/riscv/translate.c index cef61b5b29..9836ab8c20 100644 --- a/target/riscv/translate.c +++ b/target/riscv/translate.c @@ -1210,11 +1210,6 @@ static uint32_t opcode_at(DisasContextBase *dcbase, target_ulong pc) /* The specification allows for longer insns, but not supported by qemu. */ #define MAX_INSN_LEN 4 -static inline int insn_len(uint16_t first_word) -{ - return (first_word & 3) == 3 ? 4 : 2; -} - const RISCVDecoder decoder_table[] = { { always_true_p, decode_insn32 }, { has_xthead_p, decode_xthead}, From patchwork Fri Apr 25 15:23:11 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 884357 Delivered-To: patch@linaro.org Received: by 2002:a5d:474d:0:b0:38f:210b:807b with SMTP id o13csp4022321wrs; Fri, 25 Apr 2025 08:25:28 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXPvXL5gCwPM2D/BwfFwoGYpbM/W8pxx7qKSI+D4dBQwMy+8quZJh+vNW3Hh1sVSMNkLnmwEA==@linaro.org X-Google-Smtp-Source: AGHT+IEkHt5lij1cMNxEROUpjse26om+1X+Uw8BD9kslmvPQTM1RUay8GWouiw5meTwnMj0yXNbQ X-Received: by 2002:a05:6214:1cca:b0:6ea:c5be:f21b with SMTP id 6a1803df08f44-6f4cc35e640mr37197996d6.13.1745594728267; Fri, 25 Apr 2025 08:25:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1745594728; cv=none; d=google.com; s=arc-20240605; b=ieFDw3nyZ7SqEEllKNXEzV8ckTnZs8wkTGUgC14i9sKOsAaXCY3xg18N92OSCMj21j F+0SqvjEwED5kUNUvmJpo8GytT/l3fAk7smwmlC+JMnaBZ/FSOIIJ1hpeUsYWhA4naBW Zm9PqSh9ZzFhbtjcJIQiDAQHgt18nfDAeyEpN7SEY+lez3EnwyuCRZ3OyykH8NQ6jLzV ZK6/VHHmRlvLpy2Elinp7Uk/pRdUUx+qokVCFFcI51TrpZyPfgRRbd438QYQ0zyDpFVp cLUbOFF/7BXdXeTDGGm1KsB+kkf2BzXKXXmPks4j4NxHfCw3PPt2iVNyWf9h+oagvVkZ uuqQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Gj1TznuRCvGs0CqAqeiTcoQslN5U+5zXVdqj/kfvErI=; fh=tbsDrCdppOEjIVmMhMa/fTPU8DqwnjNG7rxGE3k2FrY=; b=apv48CUKCLfzsQgvXt+cZ+O3v7Av03JaFhiJqqahDg5W4u7aBa8p5SSkNZYYp3Vzmd ArUZx61c4MF9Zl0zSgGR1WLi/BwdTV/mAx+SZ2sWLv/w7dfcI7pAe5GICpHFR7EZMVQN cKv63GtIbOKGOiI59SaWsQY/sdLISHOabFzWv3fLVINqEATtRNjq2jB9OtJAZYn0VT13 HCSp1guOE2weF3IrbwehBUf9BSrix7Tdp9cDPleyLl0JXv0ROpPlSAroICxFwH0oipkW lkC1PYBUvN31Mfb4jnRYyc2jD3gbTEIuIQFF+YW/Y/JvPRI0pTbNoRFfLEVC+YpnYFel OK1A==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KB1mvoOp; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 6a1803df08f44-6f4c093359csi40561166d6.157.2025.04.25.08.25.28 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 25 Apr 2025 08:25:28 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KB1mvoOp; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1u8Kth-0001h0-B4; Fri, 25 Apr 2025 11:23:25 -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 1u8Ktf-0001fT-Cr for qemu-devel@nongnu.org; Fri, 25 Apr 2025 11:23:23 -0400 Received: from mail-pf1-x42b.google.com ([2607:f8b0:4864:20::42b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1u8Ktc-0002qS-6r for qemu-devel@nongnu.org; Fri, 25 Apr 2025 11:23:23 -0400 Received: by mail-pf1-x42b.google.com with SMTP id d2e1a72fcca58-7398d65476eso2015966b3a.1 for ; Fri, 25 Apr 2025 08:23:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1745594598; x=1746199398; 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=Gj1TznuRCvGs0CqAqeiTcoQslN5U+5zXVdqj/kfvErI=; b=KB1mvoOpcahpai4bRzMx2zi3n+pKeW82PlJawGwMV7yXEYgnPB5u6q2wLkTT9i/O/Z EVEZDfAEcQwIO51tF527kmhU8T9gO1JBnA0N0+9saNJGCICPog7R9ONsWHuejILn6DI/ Ez5Ai1Xfz/kyUPMLFlhGMXH2okXPcYmDbeRRdOd248reC8bbwytnsS0qOJcphg0+JLt6 x8n2tF4ZtFWUkR3H+q1XYMzEr2LflNP2MoC4sO6QdIQwZqIfxqJUmAGsiZY27qtQi6bc Tt4aMSKKqyQPHXvHM2A3R7HUWYx42K620n4Tzf/oDF151Q2Cz0lbLkKRLfCKyD1AMzwZ kt0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1745594598; x=1746199398; 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=Gj1TznuRCvGs0CqAqeiTcoQslN5U+5zXVdqj/kfvErI=; b=eGrI5VBq4QfWspNYtVx4HYgdcjLHAyUi9MeWGNpABy0UNM0lzay64t53ym9GyP4XRy Ga+7PzTqWOxy0dLLMLK15R7UlijCzdXSTczdG9+qstuH+MzJOgmo55kJcp/8iW9LsAqW jz4jU2jmjQNsTNIuHSiJZo2Ds9ii/gmItH/okkjMF+8lH0fHpx7eM6OD7ae2oIaxVniy aXrxW4XVQDo0loaNs2wGnYShtRuaB9/+lAuz0+f0sfgTJejIUEQpi2O8LDeKH851n/oC WLQHwxgkBaWap60EZdzu6RBxZCwBi5rv2lww8vsTyq1L/X5JeWVu1nv3wLWP2KftR19q S3+A== X-Gm-Message-State: AOJu0YwnCsXgjWscCHyNVbq7j4Dd0xn/ZSBCQTFbmpgmmR26ExKljYWM CieV5F6qWBzD6h4N7D+m5chiI/d1gYyTO/Cq95JZqjw+Owv+Yse2wiawPFnZP0GIyhLgHbCfCxM f X-Gm-Gg: ASbGncuExrPOXriO8ToLEevUdBHzIw7ZI5UAxDx+aORvQo5ru4XGJmi/rnLt/zioglZ eEdeUas91zdDQBQt8sZ0A6oILyzsA15fjFEz9gE+vk/7fPQPOy1hP1x081/ZyRG+yDgRiDLPAEY L4aybNuf5KbI9rE7KzSyvEtP1LdKuueorelpVRdY0sAUhjXuvHTLIevLXpUb2ClgYXlEII/SQPJ /nJ2gOE5o7yDGj65tfotlB3GFtT6VrVt3NlGo3buN92gy95KKLa03DGYQqD8rntunY0ompvOTDh bsCLPFVvjrKL3BHOZjA3AXpqtGesJJLf5AkGoWziYUSQEB2LLcMbyviAp1bf2eUXvWlkrjbHS8A = X-Received: by 2002:aa7:880a:0:b0:736:b923:5323 with SMTP id d2e1a72fcca58-73e268ef417mr8849538b3a.10.1745594598552; Fri, 25 Apr 2025 08:23:18 -0700 (PDT) Received: from stoup.. (71-212-47-143.tukw.qwest.net. [71.212.47.143]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-73e25a6a49esm3390466b3a.106.2025.04.25.08.23.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Apr 2025 08:23:18 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-riscv@nongnu.org, alistair.francis@wdc.com, dbarboza@ventanamicro.com Subject: [PATCH 7/7] target/riscv: Fix write_misa vs aligned next_pc Date: Fri, 25 Apr 2025 08:23:11 -0700 Message-ID: <20250425152311.804338-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250425152311.804338-1-richard.henderson@linaro.org> References: <20250425152311.804338-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::42b; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42b.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, 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Do not examine a random host return address, but properly compute the next pc for the guest cpu. Fixes: f18637cd611 ("RISC-V: Add misa runtime write support") Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- target/riscv/csr.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/target/riscv/csr.c b/target/riscv/csr.c index a663f527a4..85f9b4c3d2 100644 --- a/target/riscv/csr.c +++ b/target/riscv/csr.c @@ -30,6 +30,8 @@ #include "exec/icount.h" #include "qemu/guest-random.h" #include "qapi/error.h" +#include "tcg/insn-start-words.h" +#include "internals.h" #include /* CSR function table public API */ @@ -2099,6 +2101,19 @@ static RISCVException read_misa(CPURISCVState *env, int csrno, return RISCV_EXCP_NONE; } +static target_ulong get_next_pc(CPURISCVState *env, uintptr_t ra) +{ + uint64_t data[TARGET_INSN_START_WORDS]; + + /* Outside of a running cpu, env contains the next pc. */ + if (ra == 0 || !cpu_unwind_state_data(env_cpu(env), ra, data)) { + return env->pc; + } + + /* Within unwind data, [0] is pc and [1] is the opcode. */ + return data[0] + insn_len(data[1]); +} + static RISCVException write_misa(CPURISCVState *env, int csrno, target_ulong val, uintptr_t ra) { @@ -2114,11 +2129,8 @@ static RISCVException write_misa(CPURISCVState *env, int csrno, /* Mask extensions that are not supported by this hart */ val &= env->misa_ext_mask; - /* - * Suppress 'C' if next instruction is not aligned - * TODO: this should check next_pc - */ - if ((val & RVC) && (GETPC() & ~3) != 0) { + /* Suppress 'C' if next instruction is not aligned. */ + if ((val & RVC) && (get_next_pc(env, ra) & ~3) != 0) { val &= ~RVC; }