From patchwork Mon May 19 04:05:29 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 891101 Delivered-To: patch@linaro.org Received: by 2002:adf:e88a:0:b0:3a3:61c9:c5d4 with SMTP id d10csp899144wrm; Sun, 18 May 2025 21:27:50 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVnWjSpKrp+7RSM4TH8bLDxogKGXp5zP/zIDcmOJPRjLfPs3/7GvS3Tdpp7XRknQpVWHDX/Lw==@linaro.org X-Google-Smtp-Source: AGHT+IHDmdLpQdx+122LGj677Y1AIkK+Z2fy4MVXqIQReYRmaUiHwpx/O/SFRt4eFyemZAlEk1Xk X-Received: by 2002:ac8:6f16:0:b0:476:add4:d2cf with SMTP id d75a77b69052e-494b0781d7fmr192484501cf.16.1747628759335; Sun, 18 May 2025 21:25:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1747628759; cv=none; d=google.com; s=arc-20240605; b=BRWCNbkutwyASH1tnzSY+nGn2hFxfm1TySaPwT1RVKD6EptNUz763Z1FFEyP34AWpM mBoeNXiGRtWujc7JE/ZoP/c3CVOKQ8gzo3JQfsK8CmOqfUgegx2MtnMk6zD1xTCPE6mc oYk1OOCQknnRLrwPbyQMqwgdFoIwuNmTW33I+F5tSLX4eqlqZvr/CBOOPSzu1Epw/jDY 93uPtFBmklUU0AQEG16z8GJCZUJ3mPPpm/vWiJAu54og2m3mXL4gjXs7kYNt5dF0Pw3U VYGDiV6JPK6eQo6zYGJ7JSuWvW6hksy/qHlK9+wy3Qe6H77cv4ShZHAPYKdKzMzbmxck boQg== 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=wmUgwEfoQhqxtFyJjDXjMNdBeEt/DbzUtpPXfwQzoz4=; fh=HDQYu5lPAnkQefrBKmRl4cF3eYSeew0dhs6uIHrlDww=; b=f1hg1vOwYBNrE7S5tG2xek4rVTwYxjkJEJVXwW9dcdxGMEJc+74U99H4pvKY9gevGK YVCkIRcVUiC5Iedo5Kcrk5onKrMEla+AYeRIT5Sq7jXo+2YYRaj/rMxNbZrHRLlOz1O7 /PiImURYLjJW9Ea+kZ/tjwmhf3zWMoybdiiecvc/grINFxVMLPTl7IqJ0hZx9I0y1ONn LgJ82W/ci/UJyB8GXLTK8KGuQUAu/JVpwvfavXW4Vix61/4mBuw94jSbocLaG/3KYM5E jejkhhkhnXwKM428Z6qeEy3FuldE1xm6/+FmAo2+sewfn2abNVoCBQizFeiRT+AKzX9P tC6A==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=CUjrSVvc; 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=QUARANTINE dis=NONE) header.from=gmail.com; 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-494ae57af3csi79160451cf.421.2025.05.18.21.25.59 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 18 May 2025 21:25:59 -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=@gmail.com header.s=20230601 header.b=CUjrSVvc; 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=QUARANTINE dis=NONE) header.from=gmail.com; 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 1uGs3T-0000g3-Mt; Mon, 19 May 2025 00:24:47 -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 1uGro7-00072G-Lz for qemu-devel@nongnu.org; Mon, 19 May 2025 00:08:56 -0400 Received: from mail-pg1-x529.google.com ([2607:f8b0:4864:20::529]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uGro3-0004H6-NA for qemu-devel@nongnu.org; Mon, 19 May 2025 00:08:55 -0400 Received: by mail-pg1-x529.google.com with SMTP id 41be03b00d2f7-b26f67f10ddso1526261a12.3 for ; Sun, 18 May 2025 21:08:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1747627730; x=1748232530; 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=wmUgwEfoQhqxtFyJjDXjMNdBeEt/DbzUtpPXfwQzoz4=; b=CUjrSVvcXl9djOHdzvokGctQj/Ix6uDnnmvPp85YTpYE16td6O8vP9ADKwEktHvFRe bOuxltKLzB5wNjsiClNdVXnysQeWRg5V3nQqjTjrJnLYO7QrkGKf6+qYqjNfHh8OsqYD iaihIF/EzQoyOCc6dciwSimxBjgcZqHUO7HRIbxvJAtO7BO8sROn30DARHRstIvFJB7G hBdzWk2ZpBUUKVOfd3axiGKcb8N9ChJ9XVpRomDSe7iHMUXWR0fpOS+TRmVlVSPm0IDF mBqtYPxxd/WcStJhmqs2dzDRSYYRYSFou9PNUmz4m4plVnM1GRRBVpmcdVLoyXnpLh2v xqqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1747627730; x=1748232530; 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=wmUgwEfoQhqxtFyJjDXjMNdBeEt/DbzUtpPXfwQzoz4=; b=Y7rVlsull2hjQ+XjUYS7yjJ3+EUFvOHNhHvkzrvTNv7Czby9O2PUUVam98uDMayvRT 6IsqrMvLn4MBSh62n66RUJqf+r4o+dYaEeSBZImxWDBfegfiFtVfdE3eRjPSYCwGf92q AQbkEHczDfRMUbLm1LEQ47uc3qB8cYUbuZV3D3HI2p0kWhO7c0SbjBXt1OkpSpcRpCsg csE5rBow4EKdjRLbT6tiOKFwcnYaqLvd7Zmkp5izpMO8I/fSANerIHCBJ9Zjkz7MB1pB FtbYhw0j1n81IaIx1S9+icjPcHDn8ojj4FpEPZEt0ofZy/7sEjBlbyYxRZQd31AYhqha vA4Q== X-Gm-Message-State: AOJu0YzSlpT8S0GNLB7DVuxq+M+l2oFIc/KF4wJ+8T6ydOeJvjQ/3bKk eMVl5A8sLt9xlyxnLBpkTF3uuW7E6qUynbZ1JfhbZOc2hWIft92oBVxK5feY0A== X-Gm-Gg: ASbGncuvLaHHu6tlTPhUk3T1xB3sNhxlsNspcb1Ft7KKtlJ2vv+72QFQot/hy1LRy3B 5ktx3q7GxqgwwtplfLmplyuRznW1x02ArwT34aiimdA7HKvJM2ginuuQXrKfj3csPEQbEcME1Wb j9pkFJZq2u2v3Vsjh+jc5k9x6EsaJSMZrayhVJezAJvvGeGzY2fD2PsXshWgwGXokCph4+Jz8/u +5PWHU2wrjbzd/rg2T/Nc+QARTQaP688cLrxBMacyIN93e/j2f2N7Mpg0/geW9jKODH+MXlSSFg BM5HpYTh8d+UsgSYQKRQcy6jQrIA0P6rN135TzxEgDHlTcGm+19fjbiSdxWZseo7t1fG4Bh8oZy VUnVlcJRy36Lx0UHRAIjAyaUY0S2hCTV8dJWm/mLCUEArCo2gCsG71T17 X-Received: by 2002:a17:902:c411:b0:224:1ec0:8a1d with SMTP id d9443c01a7336-231de376684mr139458035ad.30.1747627729914; Sun, 18 May 2025 21:08:49 -0700 (PDT) Received: from toolbx.alistair23.me (2403-580b-97e8-0-82ce-f179-8a79-69f4.ip6.aussiebb.net. [2403:580b:97e8:0:82ce:f179:8a79:69f4]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-231ecd5ea41sm41750035ad.228.2025.05.18.21.08.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 May 2025 21:08:49 -0700 (PDT) From: alistair23@gmail.com X-Google-Original-From: alistair.francis@wdc.com To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Richard Henderson , Alistair Francis , Daniel Henrique Barboza , =?utf-8?q?Philippe_Mat?= =?utf-8?q?hieu-Daud=C3=A9?= Subject: [PULL 32/56] target/riscv: Pass ra to riscv_csr_write_fn Date: Mon, 19 May 2025 14:05:29 +1000 Message-ID: <20250519040555.3797167-33-alistair.francis@wdc.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250519040555.3797167-1-alistair.francis@wdc.com> References: <20250519040555.3797167-1-alistair.francis@wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::529; envelope-from=alistair23@gmail.com; helo=mail-pg1-x529.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Richard Henderson Signed-off-by: Richard Henderson Reviewed-by: Alistair Francis Reviewed-by: Daniel Henrique Barboza Reviewed-by: Philippe Mathieu-Daudé Message-ID: <20250425152311.804338-2-richard.henderson@linaro.org> Signed-off-by: Alistair Francis --- 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 c66ac3bc27..4265ce06ee 100644 --- a/target/riscv/cpu.h +++ b/target/riscv/cpu.h @@ -838,7 +838,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 a32e1455c9..ba7620ef3d 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 Mon May 19 04:05:30 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 891099 Delivered-To: patch@linaro.org Received: by 2002:adf:e88a:0:b0:3a3:61c9:c5d4 with SMTP id d10csp896170wrm; Sun, 18 May 2025 21:13:40 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUXg+6ufOthH26NNaYzVCp0EkTQs8FTttVed7ljjZcMGxQIn7O2/33xxf4bRyGmYyl6DT6lDg==@linaro.org X-Google-Smtp-Source: AGHT+IEo9T+PNDlApsYDBSaNcWyzUeob7sfJ4gRW4U6i6/Y8LVqJV2AhukPB0clZvHlVeyyfob+A X-Received: by 2002:a05:622a:5589:b0:477:e78:5a14 with SMTP id d75a77b69052e-494ae355501mr209584891cf.3.1747628020372; Sun, 18 May 2025 21:13:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1747628020; cv=none; d=google.com; s=arc-20240605; b=DuHYbbdSk2gVdXFL38x/OuTc2JXtfOQ/3UrEyUkWHnRRgRR+DItktwUWuqs+RHy1aA 5f5bwAZZuwvzp+oWR8cM4eBxvpQcI2hXpX/sec78TrKF+JRJ49nj1UrZm6lww4cL8juq 9TGpqNQDylBsbCbYO/K6MDIg/k8+nC6zs4962o+uPkBVmNkcfZQ4UgXBqbt7MLjQ71Bi Uw2mdjD0pChpkoLaUhV8T2O4SVlGGQO7sZS3NbBcmv3eKDir7C+Xaq3vtxsREzEr/Pk+ 6EfKyEVrxxbEoHLaDwIwxr9WOhxVNioTD+KEH4jyIHOaRl5+C/fFzLSNINKEAyXF1MrE mYUA== 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=Bla8g+U6Fu/GyWaUtIRMYDNw5MNMh+RuvFK1htVI4VU=; fh=HDQYu5lPAnkQefrBKmRl4cF3eYSeew0dhs6uIHrlDww=; b=LgIvFYxmlIMcOPT/KySmqIFIGHCYgLWuL2UNczesoJrwAGWJt19o5RJdYKaE8dlFvZ lip5TpiPNQ2yRhanHrUYQlWNkJ8r91Qg+U6tABtW916CskI4w0d0OyBKheXG8vE1sWKv oiPSKkUfOU10f8aNeOk5hVv6AOGoLYtpXCHlTb9+T4CCylGaq8EBNpJGsFrvhDGs41Nx x6WG7cnAiuTWi37mkoAH2MZLpon1BQ1oxkaJUZodv/HwvSHXKRyiDtvH3sMKu5dOiifI 8rxCT1z0u9VNVT8I9dsLzpfOoj1IiIStYivVgUTimYq2FmUbYxoWFL/WwVDPQMgy/MhR fFVA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=D9bToCUH; 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=QUARANTINE dis=NONE) header.from=gmail.com; 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-494ae565559si77047151cf.282.2025.05.18.21.13.40 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 18 May 2025 21:13:40 -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=@gmail.com header.s=20230601 header.b=D9bToCUH; 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=QUARANTINE dis=NONE) header.from=gmail.com; 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 1uGrpI-0000DC-Ik; Mon, 19 May 2025 00:10:09 -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 1uGro8-000749-Nv for qemu-devel@nongnu.org; Mon, 19 May 2025 00:08:56 -0400 Received: from mail-pl1-x62d.google.com ([2607:f8b0:4864:20::62d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uGro6-0004HV-Uq for qemu-devel@nongnu.org; Mon, 19 May 2025 00:08:56 -0400 Received: by mail-pl1-x62d.google.com with SMTP id d9443c01a7336-23198fcdeb0so34432445ad.2 for ; Sun, 18 May 2025 21:08:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1747627733; x=1748232533; 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=Bla8g+U6Fu/GyWaUtIRMYDNw5MNMh+RuvFK1htVI4VU=; b=D9bToCUHS+Vi3Z/Hr0gfKPQ0BLvdSL8F9Jp3ONKNjJSSl14QXJEVmk/RTBuM8JY5ND G+q9fOhGCQNy0jKXhf4FS0/P4PAO87cce8wHVd5/1nDHeXSOhRhCJPU7wljKptqImd9R r71dVT21X9HEAkcjI4xUMD4cU7VfvrbBCS27LuN1km+kCTsMJEzQgKf608v87+uXXiQm 1y0Air0ckoRmx+Xf0PG80jYgz5j5hVopZgm6ivomsxyyky+iea1rGOtB/+wESBEmy0uv 5NviKhytqxVDWtLcRIqN4KuR3o/l8+VDyDAuIOTNrvW+ya7zNLArsM/a36D7MV++rHyq YNxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1747627733; x=1748232533; 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=Bla8g+U6Fu/GyWaUtIRMYDNw5MNMh+RuvFK1htVI4VU=; b=w1yFgAYLlKG/A0zRn72y/mftTxwZdwqFqpB+3y9xIyhMG1o1hfC09mHQimuLRepSMQ k1xYm7PATKAswhnSfh3e/XF91ZCknpX6R5PTBnH2b4FXe9prtLubBBqJClGvZq9NcOc1 rjiPuFEoDT0+G+UkvAGMO0HmKY7pJBP2lupDwsesotmxZ4TaZxvVrHe9MzLnGX3GTr2T hnnSmfR+g0sJWgU/4juGHZ/aYLBhBws6F03Uu+XC22D2ehKm87P5ZaggaldkISQJlbIV sv0AL7kI89lIYYX2U6bGdY3g0jk8uqJBXt0ZewKchnOEgb4YLLFo0mWA+Afic1mn+QKL umjA== X-Gm-Message-State: AOJu0Yw2eXFGOiTtlalkpbD+AF4RkOgaEAXZRKLBxpYMEywA79XUVWRk UgSAuS9O8Yqdmxax5az+u8Gk0SjAa0S3R7lxIJkLzkfZW+8s3IK0ogYe5TbBKg== X-Gm-Gg: ASbGncvX1IiKBSlefn1UOJaBfqpnLWoQ/67CSrk4G6o1Spk9T5zOCQubXFDMjW2YEmq vXW7HYFBfCvRzafLitiv4jiUbuzH5zxs2s6VDd3aCJ1mP5GzX6am50tZ7bnC/4CDXbhkZOmb6E3 Jr3Ig+UvPi+4eKLl3YWzrie17f7iINtzedMkhHtk89qBXcTeQNVknmm9DtaSPEQ+7bMXsuYPcwy unvai2kuhx2kiZvtoi5PCK8I2IzLLLDlBnDO/IBPbXERkAGBtE6AcctNc2VZ74xiFrf5k5S3Emp HPpZSy1fkCTdv8DpQkAZ6NprIsYyXL0bpZDVXyaccfdfqHjN8qEYhSLXiH7ZvTkTAI3d4r8YOCu pV80jPUz+kSZYqAZXwrd+XSdkS/UaJMak5pDBLzB6l5bdmGrRr6ajDYYI X-Received: by 2002:a17:903:2bcb:b0:215:b75f:a1cb with SMTP id d9443c01a7336-231d43d99bamr161657375ad.9.1747627733211; Sun, 18 May 2025 21:08:53 -0700 (PDT) Received: from toolbx.alistair23.me (2403-580b-97e8-0-82ce-f179-8a79-69f4.ip6.aussiebb.net. [2403:580b:97e8:0:82ce:f179:8a79:69f4]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-231ecd5ea41sm41750035ad.228.2025.05.18.21.08.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 May 2025 21:08:52 -0700 (PDT) From: alistair23@gmail.com X-Google-Original-From: alistair.francis@wdc.com To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Richard Henderson , Alistair Francis , Daniel Henrique Barboza , =?utf-8?q?Philippe_Mat?= =?utf-8?q?hieu-Daud=C3=A9?= Subject: [PULL 33/56] target/riscv: Pass ra to riscv_csrrw_do64 Date: Mon, 19 May 2025 14:05:30 +1000 Message-ID: <20250519040555.3797167-34-alistair.francis@wdc.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250519040555.3797167-1-alistair.francis@wdc.com> References: <20250519040555.3797167-1-alistair.francis@wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62d; envelope-from=alistair23@gmail.com; helo=mail-pl1-x62d.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Richard Henderson Signed-off-by: Richard Henderson Reviewed-by: Alistair Francis Reviewed-by: Daniel Henrique Barboza Reviewed-by: Philippe Mathieu-Daudé Message-ID: <20250425152311.804338-3-richard.henderson@linaro.org> Signed-off-by: Alistair Francis --- 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 ba7620ef3d..22149bd3fc 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 Mon May 19 04:05:31 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 891100 Delivered-To: patch@linaro.org Received: by 2002:adf:e88a:0:b0:3a3:61c9:c5d4 with SMTP id d10csp898610wrm; Sun, 18 May 2025 21:25:13 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUA0Mhcpdl5ijh44rrnUpPG4w6nyUVNq5tzLbYHtid/pZb/SQHIcRXmX/5HqVblsqRz2I6FQw==@linaro.org X-Google-Smtp-Source: AGHT+IEzMlbzZTlqOMiUfex2bGCZrg6gS+eT6CpwsqIz5da4FmQFktxrEY7w5XLENXq8Ma0jglj9 X-Received: by 2002:a05:6214:f23:b0:6f8:aa6f:438b with SMTP id 6a1803df08f44-6f8b08352f5mr199597906d6.3.1747628713075; Sun, 18 May 2025 21:25:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1747628713; cv=none; d=google.com; s=arc-20240605; b=SRz3cnmySBU8rOfMQCUIaBkcHtIYNN6uG52f/O7xJ0Hb8LkWxO6riUfQ4N2szCUt8x uPagPBl0Wgn2K117wQwP6za4KEFIf3eDvX5piTHLFjn2TvTVspXlNhbVqfO9ARUpLSP6 wYc+7pxMca1kVwle1O2UFCD3bOhnYZlaEWpWsaFNk4Oq9Wl+cY1LjZtB4JJrxamq+YAj MeThSXFiwSOyLLT1ucxus1FDqS7Q6TI4c4Sr7EIv+PCQZ/9i1/fMXGax6X7Dg1z/uoLK x6RIH4mMUTJ5LnrcLBe/W/O7iVrTgrMUSMFYpvjX2g/yhJtXpExGVYsciB3Ka4QLEDGd h+2A== 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=YIo9lWxZ4TjsB8FoVA9uJ0EOvUm7HwUR23Lv43bqgeg=; fh=HDQYu5lPAnkQefrBKmRl4cF3eYSeew0dhs6uIHrlDww=; b=imaDcJo/+MXRZ5vLHdxANEYpc1RBNICu8yza4WiL2TLxuGWiTdpDWhOlaCd94vvO6/ 6iyHR7no73wU28ZcvW4smFgva4ggFKL3xpNDhBKVQt3lXTkh7eiee3+XWb2HoYGruDSj T+fPOV6P07PJmdhadTRAQ2w8UuqV1pKUHfynD1iST2t7CPJCDzMhPQty/fCKc3NsuymS 1Utc1Tr8Yha62AFcEokMZyW1H1YvYNxUErV4L4Nrj+7JUEKDvZU/KGeEjOGkVr1Wtmiq znt9OJZuNEujxa69mm8PHvGkRTaZ/fX213n7lkS/3/u6/MD22oCzVslhoayHjg8bj3B1 FsoA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=nk2Q365p; 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=QUARANTINE dis=NONE) header.from=gmail.com; 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-6f8b09d1bd7si78327836d6.475.2025.05.18.21.25.12 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 18 May 2025 21:25:13 -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=@gmail.com header.s=20230601 header.b=nk2Q365p; 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=QUARANTINE dis=NONE) header.from=gmail.com; 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 1uGs3N-0000cD-Nv; Mon, 19 May 2025 00:24:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uGroC-0007Bl-2I for qemu-devel@nongnu.org; Mon, 19 May 2025 00:09:00 -0400 Received: from mail-pj1-x102f.google.com ([2607:f8b0:4864:20::102f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uGroA-0004IC-BP for qemu-devel@nongnu.org; Mon, 19 May 2025 00:08:59 -0400 Received: by mail-pj1-x102f.google.com with SMTP id 98e67ed59e1d1-30ec226b7d6so1022261a91.2 for ; Sun, 18 May 2025 21:08:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1747627737; x=1748232537; 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=YIo9lWxZ4TjsB8FoVA9uJ0EOvUm7HwUR23Lv43bqgeg=; b=nk2Q365ptujq+pd5aBuVR0GvUQ71viSXik2R8zfU0VOxdQuX++yv+/3hIMfxiAmylT ST4igzn/se/6u1lpXC33iL/VwnIzXiKSv/eWl70YFX3epXuzZr3ERHJYivXaYp+49FY3 mfKg9yP+XvM93L8wHGR+HfhZP63VXQl14ab9cF4IJtg3Ty/ELpGHYgnWFO60g/7VptmV N+0g/wSZwXi/WEWupADdJyDcrC2ctvAmidCgk/wqLr0XWBUkHcN3pKr4gU3dEfI177gq u5gpSckaFMI0CF7DySB8z4p8xKPY4ZbRrVhwC0I5yJhGH0aNPqJmv23s8yS4ZJT2FMSG iFZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1747627737; x=1748232537; 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=YIo9lWxZ4TjsB8FoVA9uJ0EOvUm7HwUR23Lv43bqgeg=; b=kEIXe5PZXCLn4uaKHZkUp3X9H7IqhOwVAmAwUTSH0hLfRVq/pX9VUaDRR8G0QAZsOv CSa3sCwotU8QeGRvOZ+QGFVSHfuizQb31L2YPMNLLzb8q5CTjeovLuYbnazC+8XaWj02 HYcF1YvI5wvLRs1oZRCFzB+EEyIUdbsmJPbRF/8GUsShhl4pC5jQv6YKfXQ72+XmXyhD Mgqf2p1GYJ0cuR5Rd9urwCcPEVsBgL2xLB9w6yzViEem+DUF50OUnoVZUB3/FGvnfUIu wdxKjjgHFV5v2juDtlDTuh5Eig4mvUS7RCQ4mIBIL7oMP/D6lSlG69zYH+P5+6T/+wPp gpcQ== X-Gm-Message-State: AOJu0YzNJQ0qLdQeURO9hphvxDtupaAc0f33vMtolqw+RuGWvzwqAGzf QFrnjKFUJH2NJqJ7nEXP6dRDmjIZZSXAhtx5yx/vc8oRAel6d0B2vAYBrvIxkg== X-Gm-Gg: ASbGncsWycUN0u6wP8BnTQhaAtg2Y4WdSNp8PelXUYErV18Pfp4ZUvL9kdY0+KdR9yG VDVNucHl+G/K2GuV+usFojFgI2vmZV+HYOxT8VI6TmZXgjgnfV1Du8RLzy7drTrMXu+8cw7Exp+ KdZJs50EDXG95jiWGHXEifqGRPBfgwow5Pqidmdi1dPsR79xvbAESs0KGeze07tQ+Q6DxhCm7eK zyUp4eB+t6gdgzSidGBgtB2YdsgvQ1z6/yySHz0amYnOWcEFao/OfNj0gFE3q7kCEUVuz7DdiFP 0rE/Al6f0cJF0mSSTwZiv3G6n5MVu4DUn2fGM0DtfLDNa77rAqnWDnypISooRmjk1GVCji2awZT E1mauHljhvrBpTrsYR7x6vNrB2wP/+Ya5MFApnZ2wColauj8hEtWADrlq X-Received: by 2002:a17:903:2bcb:b0:215:b75f:a1cb with SMTP id d9443c01a7336-231d43d99bamr161659835ad.9.1747627736595; Sun, 18 May 2025 21:08:56 -0700 (PDT) Received: from toolbx.alistair23.me (2403-580b-97e8-0-82ce-f179-8a79-69f4.ip6.aussiebb.net. [2403:580b:97e8:0:82ce:f179:8a79:69f4]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-231ecd5ea41sm41750035ad.228.2025.05.18.21.08.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 May 2025 21:08:55 -0700 (PDT) From: alistair23@gmail.com X-Google-Original-From: alistair.francis@wdc.com To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Richard Henderson , Alistair Francis , Daniel Henrique Barboza , =?utf-8?q?Philippe_Mat?= =?utf-8?q?hieu-Daud=C3=A9?= Subject: [PULL 34/56] target/riscv: Pass ra to riscv_csrrw_do128 Date: Mon, 19 May 2025 14:05:31 +1000 Message-ID: <20250519040555.3797167-35-alistair.francis@wdc.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250519040555.3797167-1-alistair.francis@wdc.com> References: <20250519040555.3797167-1-alistair.francis@wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::102f; envelope-from=alistair23@gmail.com; helo=mail-pj1-x102f.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Richard Henderson Signed-off-by: Richard Henderson Reviewed-by: Alistair Francis Reviewed-by: Daniel Henrique Barboza Reviewed-by: Philippe Mathieu-Daudé Message-ID: <20250425152311.804338-4-richard.henderson@linaro.org> Signed-off-by: Alistair Francis --- 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 22149bd3fc..8af0304a36 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 Mon May 19 04:05:32 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 891102 Delivered-To: patch@linaro.org Received: by 2002:adf:e88a:0:b0:3a3:61c9:c5d4 with SMTP id d10csp899434wrm; Sun, 18 May 2025 21:29:20 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUundcwphHRPa93h9/49Z6n8Sop1t+8JW45sla4RhbwotYWPnVdSgU0fA30XSYBgvKvr+EQ6A==@linaro.org X-Google-Smtp-Source: AGHT+IEHPzrhsUv+jsb0VrmJV7lkmx0gLMzF3bzdc+sV2qXG4JSdWrUmmsPFnJm9xxeY1qUMPdGZ X-Received: by 2002:a05:620a:240e:b0:7ca:cb02:7942 with SMTP id af79cd13be357-7cd46718a7dmr1302480485a.1.1747628960389; Sun, 18 May 2025 21:29:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1747628960; cv=none; d=google.com; s=arc-20240605; b=cQjq2hPzIsJSCrCcmRcyk3ubc9KnLg6nKUTjhtqNA/WOz6opypne3/fokY6OSsZpRd uvzSF9jrY1gxPYm9ya9A0plhXZ5XMTMidrec9HcCMo1WMMxfKm5k9iYJBmh96nyZfO4Q pmDJO5WqmSj3SdJlbtuQzo79u0H39VIbcChTrV5GvaR31vaHC6HJQMG9UaX5FjkZ7llv bh5dUdzhGKMnsm/2t4TSASDZv8s4YB0gdM9ZdhGnZetlUL3c9IVixxzbYl8PTqna3bsu QPFEG+qAz8Kq8GkW2H/wM6k/yJjD62BEBnqhplGGsW1k9brrfLhFuID+WGIkPzh2PF06 2nfw== 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=Zo1oQ2uJiz4wOuR0JFtGbTn7SBFfTYZmSnIf0cck79k=; fh=HDQYu5lPAnkQefrBKmRl4cF3eYSeew0dhs6uIHrlDww=; b=aJ2lfKSvm+YAjfCJXMwdtIoZhSjhzAIl6+iK0/6RLLWKW4krzJtz4al2jQ/e+SobGw wLEuG4TXlZDsRYaIBshHC4F9MG0yOKMW18nyVmvDoXekbu8BTeFKi0H59c6DaUYaroAk DEZwXecPdicZYj3oO8oiWaboThr7azQu6iDdHXw6t0Wl+YjNrFP0klrF2KL6zgxNLk5m tERqTEevl9Au9H1jKUGhCHhJ2QSu0i7FwyLrwxjk73zMEPW7Ga17owI5bOO8wyU/ZGSS tg515AWBNCWNQ5TdpWLDraoqZNQLGm/q0pGNncO16oKO8eq+BZwPvPHd5yF+iU5SBSLS r7Vw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=BDFn6eNd; 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=QUARANTINE dis=NONE) header.from=gmail.com; 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-7cd468cc905si802150985a.477.2025.05.18.21.29.20 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 18 May 2025 21:29:20 -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=@gmail.com header.s=20230601 header.b=BDFn6eNd; 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=QUARANTINE dis=NONE) header.from=gmail.com; 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 1uGs3S-0000fa-HY; Mon, 19 May 2025 00:24:46 -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 1uGroF-0007It-Hf for qemu-devel@nongnu.org; Mon, 19 May 2025 00:09:04 -0400 Received: from mail-pl1-x62c.google.com ([2607:f8b0:4864:20::62c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uGroD-0004Is-Mm for qemu-devel@nongnu.org; Mon, 19 May 2025 00:09:03 -0400 Received: by mail-pl1-x62c.google.com with SMTP id d9443c01a7336-231d4679580so21983805ad.1 for ; Sun, 18 May 2025 21:09:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1747627740; x=1748232540; 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=Zo1oQ2uJiz4wOuR0JFtGbTn7SBFfTYZmSnIf0cck79k=; b=BDFn6eNdu5vt1WCiXIjak+3cbJeguoRfn5qaMxgXB7WY6e1xtSfHPrVdNrG+tmuSZY nEg54B8a66hQn1Ywx48wycoOXZMSs+2LsAuZibKNwSTqidvqPm91P2MGs9pmvqKWdzeb DGX2Sg+Y6eywOqAVAlrah3qBIgk0lfYpOr3lkMoRZifqCpm1jeWyxKJX3ui83v6aho0k jk/qdtChWGtsr3wkbOYtuqi2Xt4V71+ipT6ErU+4Py6LHdgWYfKikDOFNSZOR/4duqUF ltN3pXjbvSmm2BuxDJs/C4KbftS2MYyuqtGu2kYKigBme1/ntmQM5rnoTzd1fBPOSFcK LnWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1747627740; x=1748232540; 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=Zo1oQ2uJiz4wOuR0JFtGbTn7SBFfTYZmSnIf0cck79k=; b=FENKGQ7muhCcY3D1rsqhDmYz/a1081eXaDYCWJeW0oHjdqzpl3i51d6CrmsuOI/mSq KHMTP9Vt2gpt5n4AFVcIjFaowKrA70BGT3/DJcp69ncLBQ3y8TCQUa4k9DZgQ7l+U0Qw qpRYewXkN82E/AGrCWYb2a06FuR0yIWpTJio02V18+7vbfZwkW/6kznFJkaowgXM+vic w0QJENGT1iPMzbTUTezVhREpQhuMMYfhK3NSbN27C9a46mBGbXu2JHnHuAEw/y8fP5kF 9sODwpz9pv8iwCmMwN8Ysep9Jt+n1hFaHD3w8FYouulP70FzeRxuUHXUnPBWmwfDSfs8 4CsA== X-Gm-Message-State: AOJu0YxAfySYmzD5F8se+8ZK5q8F2YkEVO6ZsfP+qjOU1zxmUogsIIFp AwUPOoEsYzsVuIb0Dbh2olmmk9TPQVOLK8BeOzuDh7uPQ6tIBdtGc70zsFxrFQ== X-Gm-Gg: ASbGnctdOy193Z30cx9rxlzRsYEs4ftb+8fs06VUxJsgCwBF4spYfe/GtOfejv9Ye+Y DkD/Os0YcHEMDCt2k7gzLBXh0LYIVyg5O3oqunUPUe/9Tk2EBaoTY98imHNcnCUuZ9dB80cLHbF RSnnodxGpg/0R3nE0ZC9MSS1BrJm9fK7qiIdqLHhs/aoQK1AEeHCLwmT8jtzPsFb5GcVtE4ipIq VuZHf/A/pIwUvFioIP71LCA2YbUCWzRD/spflrDCeDplwJxVUAV52sAkonQLmcrvrseVU1lWZkN qD3BUGytyBUkmT6m30ipyuA/q/qp/JtJJbkgDMjRWRsuJ+TBN+3FyEUqr/RNuO5O9TSxOFNUuAL AEKLdBJ1Cy7wfqIEXzQcnx65XEK/F/B52ZcdeVWyUVhGDDw3CmULSacrU X-Received: by 2002:a17:903:19ce:b0:224:a74:28cd with SMTP id d9443c01a7336-231d454b072mr171571575ad.31.1747627739917; Sun, 18 May 2025 21:08:59 -0700 (PDT) Received: from toolbx.alistair23.me (2403-580b-97e8-0-82ce-f179-8a79-69f4.ip6.aussiebb.net. [2403:580b:97e8:0:82ce:f179:8a79:69f4]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-231ecd5ea41sm41750035ad.228.2025.05.18.21.08.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 May 2025 21:08:59 -0700 (PDT) From: alistair23@gmail.com X-Google-Original-From: alistair.francis@wdc.com To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Richard Henderson , Alistair Francis , Daniel Henrique Barboza , =?utf-8?q?Philippe_Mat?= =?utf-8?q?hieu-Daud=C3=A9?= Subject: [PULL 35/56] target/riscv: Pass ra to riscv_csrrw Date: Mon, 19 May 2025 14:05:32 +1000 Message-ID: <20250519040555.3797167-36-alistair.francis@wdc.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250519040555.3797167-1-alistair.francis@wdc.com> References: <20250519040555.3797167-1-alistair.francis@wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62c; envelope-from=alistair23@gmail.com; helo=mail-pl1-x62c.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Richard Henderson Signed-off-by: Richard Henderson Reviewed-by: Alistair Francis Reviewed-by: Daniel Henrique Barboza Reviewed-by: Philippe Mathieu-Daudé Message-ID: <20250425152311.804338-5-richard.henderson@linaro.org> Signed-off-by: Alistair Francis --- 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 4265ce06ee..f674e93a4f 100644 --- a/target/riscv/cpu.h +++ b/target/riscv/cpu.h @@ -813,8 +813,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, @@ -823,13 +823,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 333083a4f1..7f2676008c 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 8af0304a36..807a891e7d 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 05316f2088..0672101637 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 Mon May 19 04:05:33 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 891105 Delivered-To: patch@linaro.org Received: by 2002:adf:e88a:0:b0:3a3:61c9:c5d4 with SMTP id d10csp900074wrm; Sun, 18 May 2025 21:32:16 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCW+NsfyLIBkmYrd+utNbMziXLv42pL96e+l3NHmxMKb6wof5vbTxawgTswslxusufrJ4sKKtQ==@linaro.org X-Google-Smtp-Source: AGHT+IEpYPNzx5KaVYGkBlAsmodR1TQq2k7wEFeZtNa1ju2Mhd+Ic6NhfW82K2a5PKo6cDAtz5pk X-Received: by 2002:ad4:5f8e:0:b0:6f2:b551:a65 with SMTP id 6a1803df08f44-6f8b094f396mr207132146d6.38.1747629136768; Sun, 18 May 2025 21:32:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1747629136; cv=none; d=google.com; s=arc-20240605; b=QGiplmf4ik/SPJ+bcwCuycXpxrZCf2LYhrr7pvryXtuWWO/O8ORq28z93ta2TaQT9k VbUPw7pImT5LlR7oiGFGdgCoRtjiXOLLV8EzXIYy2NyblcAjDtrGxk8Pj3cfLNg97QpD Wb8GZEppmpYLi72+H3FsIw6XM2CEJluPv9zbitU5v835JUOYFaVRFtBN515Af4k97XMX YZqX6k2M3snY/qIZvidLfoZOJIU0/Wx/2iypA5ijxDKnXDl1WI2svw3AmRbjkKvbWGJ5 I086Xi5YkcOTlEpNHs7NLIzbI2LvnZckRF1EzV4j527Z6VJ7Hq9LvPOfw1XAN1TFpUWR b+0w== 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=6B8XcozBhKUSaO2IzZDRk0dCZYzeMARm9IqAu7+vN/0=; fh=HDQYu5lPAnkQefrBKmRl4cF3eYSeew0dhs6uIHrlDww=; b=FRiW2zHxOGO5u/JileoUHbHNdsX6qaAuYnIV+cQaaxXTvAfopuR89PkXfgf1m28bW3 jG/aV8BnTg0vTBNRDjVs9I5LLA5VT6lJsEnI8zISrG7xDTQjEA1nOE1busAeMT6f77qO WJ3Xz+/D8pMd4nfzlSaVmO6sanRGygd2nhpOPzk+V+HtZplzys2rt8AfchSv8tQlSK5O fF73/+dBYG1zXGnszQ+qfADDvx5UZuvfY/Y8O4M42KhIN2GMDiuH6NbmmfXlax5gEI4Y iCmmNMgEl+JV53+KOX5huVZUm/9G6G3UcvxQp8Nw4q7YAoneblcDLR/o6Xlp/lRKOl4L XDiw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=iWNjZ50O; 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=QUARANTINE dis=NONE) header.from=gmail.com; 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-6f8b099ba1esi74013676d6.198.2025.05.18.21.32.16 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 18 May 2025 21:32:16 -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=@gmail.com header.s=20230601 header.b=iWNjZ50O; 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=QUARANTINE dis=NONE) header.from=gmail.com; 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 1uGs3Y-0000vf-Do; Mon, 19 May 2025 00:24:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uGroJ-0007Q2-7x for qemu-devel@nongnu.org; Mon, 19 May 2025 00:09:07 -0400 Received: from mail-pl1-x62e.google.com ([2607:f8b0:4864:20::62e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uGroG-0004JI-Q1 for qemu-devel@nongnu.org; Mon, 19 May 2025 00:09:06 -0400 Received: by mail-pl1-x62e.google.com with SMTP id d9443c01a7336-2302d90c7f7so50605145ad.3 for ; Sun, 18 May 2025 21:09:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1747627743; x=1748232543; 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=6B8XcozBhKUSaO2IzZDRk0dCZYzeMARm9IqAu7+vN/0=; b=iWNjZ50OF373nsxgsmByysBHjAtDCeMHjvgOGBRMSeIRiWcMvjTLp4LG269fowXQCB UWx7EO+5IotsZ9gNc1Ftyfw/jcOL67CLPj8Cjh8FeYRCAZ/+4KS+uQoeKXwd5vPmMxvJ QY9hwgRRpFOGepCu5y8o2ziUw5xlo2KGPk4wCOaPlY+nCW2rnO5QKsx8lZkjo8RqBCl6 nGfyyQ9aAYUV+R8WM0/6AD3K/J3ynBxRd232124AkRDY0W0KZUY3TCKyVex16lXNpUwH q14gfLXkpuxu1trJ6Z6GlHjUg9c6qyWn8UEf7480KKLvZr0KW89uXCPjR+8MA8n9RYQb bgBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1747627743; x=1748232543; 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=6B8XcozBhKUSaO2IzZDRk0dCZYzeMARm9IqAu7+vN/0=; b=aZDAZ/lBc047JQa57Pp2x+1Lh3S0qnOCsaVy/VqJQqdDM2YNdXtKwGDHmi/uDK2GfD oaNGnhaeTEJcgRoJOq1U29iiPav3u44JbpvmYEG6Gs8OAJvh2KaGKwBdvHJYrA7YpBXI EQJ640Axz7MppULqa5u8c+760f+/qNtYlQNoG3d+kCIGkOf61LID5YkanQWbP6qzzHLE Gqk3moiD/rYf0dZNU3zParbgPZUcJCFQ3/aYhVMlM1qCDanrWg1kd4YkbAxj6Jm45cWO tm8hsokIMi6zl7S/x4M0yTYDhIvSsB9Kul4pVDxpLXnzolPFK1zRlKGM+J/YPdfAMLt3 JNgg== X-Gm-Message-State: AOJu0YxfwZiGfYm9zJ5JfU8zAkHwQlq0Ez0G3qVEfnxqm0PtbIyAmfue GB9D9ufsUOxa6LJ8iCevq0nmzx9aVZ2DjpOXynk6xEyXe8Mva1890lle9/el2Q== X-Gm-Gg: ASbGncueUlgPyxn/UoQ9FmHGKUdWz/oSuzZJnU2whWxN6SfRY40hKHD0S0gkf6ubfKx C1klK9YCJKhyRhno/w380ssqB49HUDIbn4VG6ogUCxc63bn8OQeftF74uI/QK8BIzol7NoUjNj7 xV7F8bNk+LOSsyVszeEM86qQ3wchXVb5GQbwgVsHl3Pe3vau4Wepp87rDO/qZZX048xWtI2uCjt V9mJI7TiHW3wOiKb3OEFFTI2j+ke4LcqIrguOqwzpquLjs4kcCbOYC/SuKrfzThumXmjI9BJLZ1 a+BH8+BPjRBvfvosuYupdETcqQhJ4kihKVrPwUk2M+2Om9hN6XRfigHr4P6otMrkMBiMbyaKAIj p6v08IFEa5ccSDLP+4qgfx+8mULvUwjDZR/ZhW5xsLlzYqUPnQCo+oHH8 X-Received: by 2002:a17:903:1ce:b0:223:5a6e:b16 with SMTP id d9443c01a7336-231d438b45emr182939015ad.5.1747627743202; Sun, 18 May 2025 21:09:03 -0700 (PDT) Received: from toolbx.alistair23.me (2403-580b-97e8-0-82ce-f179-8a79-69f4.ip6.aussiebb.net. [2403:580b:97e8:0:82ce:f179:8a79:69f4]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-231ecd5ea41sm41750035ad.228.2025.05.18.21.09.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 May 2025 21:09:02 -0700 (PDT) From: alistair23@gmail.com X-Google-Original-From: alistair.francis@wdc.com To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Richard Henderson , Alistair Francis , Daniel Henrique Barboza , =?utf-8?q?Philippe_Mat?= =?utf-8?q?hieu-Daud=C3=A9?= Subject: [PULL 36/56] target/riscv: Pass ra to riscv_csrrw_i128 Date: Mon, 19 May 2025 14:05:33 +1000 Message-ID: <20250519040555.3797167-37-alistair.francis@wdc.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250519040555.3797167-1-alistair.francis@wdc.com> References: <20250519040555.3797167-1-alistair.francis@wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62e; envelope-from=alistair23@gmail.com; helo=mail-pl1-x62e.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Richard Henderson Signed-off-by: Richard Henderson Reviewed-by: Alistair Francis Reviewed-by: Daniel Henrique Barboza Reviewed-by: Philippe Mathieu-Daudé Message-ID: <20250425152311.804338-6-richard.henderson@linaro.org> Signed-off-by: Alistair Francis --- 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 f674e93a4f..ff7ba2a0a1 100644 --- a/target/riscv/cpu.h +++ b/target/riscv/cpu.h @@ -848,8 +848,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 807a891e7d..53458491da 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 0672101637..557807ba4b 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 Mon May 19 04:05:34 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 891104 Delivered-To: patch@linaro.org Received: by 2002:adf:e88a:0:b0:3a3:61c9:c5d4 with SMTP id d10csp899978wrm; Sun, 18 May 2025 21:31:48 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCU+3wNjKC78vbz3Foy+0Jtf8xqiCo0n+O6bgZ1Q0pntbPEsIFhh/Ek8trWcksRFvGRbdM8qAw==@linaro.org X-Google-Smtp-Source: AGHT+IEdeXOUpoEdWeB2RV3cv2ayHboqjycZ2epbRrvWxnzPsgUmmuXRPUfrRj5lm5PuabHQXSaO X-Received: by 2002:a05:620a:424d:b0:7c5:47c6:b886 with SMTP id af79cd13be357-7cd47fc5851mr1591973785a.43.1747629108762; Sun, 18 May 2025 21:31:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1747629108; cv=none; d=google.com; s=arc-20240605; b=RLokyw+rDP0rCgOI253FscfRAqWdM6tz+CsowO8Dr29Hs1Ve6cIrgwd//gK769P0th N9KNexFsljPA6VHouIyOYdgvBXN47Y3YIsDNfwUTajREbgLxNwnmFy9eQSMI0LZoRscr nLV0IyjLQIHw+uk0DhY61Uu2sWeUQZ2Zr2y8EP/I/Ln/gXPmOLcedI91GnbSVgikYM7O wK6yrAeG3O5Ip6sb3dqbh9FW99+Lk/jlUWxubjhI/wp6J9IesodcW7YHNVlGAQWnRhbt qWCiOyz4Tjso2IbhKOrCEs0An0z8J/FoZQFeratI95iarPOcMljIgpp9zHcdzecXeDpw zCuQ== 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=Hd86zRGeQ+HNxBDexFTf6eP4HL08/wwze9zOl4z9vq0=; fh=HDQYu5lPAnkQefrBKmRl4cF3eYSeew0dhs6uIHrlDww=; b=K7lxyGb1c38IGgxIK51rH58jP1kAf+6ovJIJ2PHWvm45AVNl8tu02J3YeowERo3czu Q4zymaWmkPFoLKF7evm8twMeCfFGoQNDGvcCO+73+to+sB9YhbTCIY6KJFw/MBDkZtze whxzEPsoE4FnT89+WEqE2Q1suo9IrZ2TuthZS4LHK+sqS6wrcrSo7PZIS3L9qT+dMR7c lk5mnxxYbycYHJ006bJjwMkD0Nvvo/HKiW1VPBbK2ED+4EZUgdNu2Mr14yIYPSE3Pb8h ZFsXAP+LDk8ka8V3KroypcUvqfpfM1B4T79MtBvq2fHQ8ITSFapnB8xQQdx9lW58WpPn jpQg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=GCaIygWF; 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=QUARANTINE dis=NONE) header.from=gmail.com; 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-7cd467ce2f0si768835185a.18.2025.05.18.21.31.48 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 18 May 2025 21:31:48 -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=@gmail.com header.s=20230601 header.b=GCaIygWF; 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=QUARANTINE dis=NONE) header.from=gmail.com; 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 1uGs3q-0001AA-Nq; Mon, 19 May 2025 00:25:11 -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 1uGroM-0007ao-1N for qemu-devel@nongnu.org; Mon, 19 May 2025 00:09:10 -0400 Received: from mail-pl1-x633.google.com ([2607:f8b0:4864:20::633]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uGroK-0004JV-7n for qemu-devel@nongnu.org; Mon, 19 May 2025 00:09:09 -0400 Received: by mail-pl1-x633.google.com with SMTP id d9443c01a7336-231ecd4f2a5so18044905ad.0 for ; Sun, 18 May 2025 21:09:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1747627746; x=1748232546; 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=Hd86zRGeQ+HNxBDexFTf6eP4HL08/wwze9zOl4z9vq0=; b=GCaIygWFzoiqQ9h9gaiVe6Zf6/GiXf2WJMKpI3dxfAbDbs5ecL+pf+11LGbzY6IcbG Q2cbMej51SwsdH8p7/MiPKA5qzHXk6iLgiyBOqi3uy03t7VfseY4Qts7JZjbmDkqg/au Ag8hwq0EdVlhNX4cXxXVG1citRBvFYZ4C9qAZwiL8I/cLPU/5946An+L4O0jvnL/ieB8 T0SvvGvIgnFswXDRPp38iWUJ8/hCiSRdEBw6oOoks0liLKEgFvHlc6RQWkmlWbk/wptp kcsoH3bfjh2LvYmNdwnIzyMjr5uvAjE34QfJka1v8pGp7il6FyPg3CUNF0TzwxxJmAyz HBMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1747627746; x=1748232546; 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=Hd86zRGeQ+HNxBDexFTf6eP4HL08/wwze9zOl4z9vq0=; b=S6F+BSPt1H8DYF3IxHox3miygkN5dzn2TPwktnPmmy+bCx0+ml2BmxL4w64IqNvGUG YsyLRBPuch3/qfXFl4Zb94i9Yan9Th7RY61C+HEWQ6HoLSJFmcvGripeR5OC0Jw7beWV 9snF8wEQ8n4AyI7gU80kpxjjc9ybWF8jrY1R/ge2C1tVpcT0SWdjBNfkr8UHZIAIU14W djfAw6x7USCd1lrzX7vBhEMxMfNQjvjMGYiMJ6OkrX5WMFkr/11gPvNdntWvDsg0Pxe4 E6xnLOhT4yj1Z3rAJLzZnpoi+tkqqQYF2B8CSotpUf7GtktROBS7CwBILS5mrJWBxki1 QbjA== X-Gm-Message-State: AOJu0YxJPruBfzzH2oayIzxEhg7XDVYdQywwNUF2LgBqVgulFGTTVYUK 9CslOCtl8KCgo9H0Xq4qV/yfyCNLsI9JWvaAU+G5Xg0WvX3yjqsR2prLscS1uQ== X-Gm-Gg: ASbGncuFJ1jheQhYgsATsyHhf0GhgeMgDA8YpiLmJs/e1T87C8SPYNPIOY/0naS1Z49 y3Lx/JzzltjUQjzA1sJssxeHVPwaGL2tpX1Fp20cJCsNs/edVIZdj9krycEI6cUNtYbcpTJsc28 hv9csDGQW2JbeWjNyJxORvYZN9JHItz2LFuRen+UoORLPJCrSp8DG7HPo2cQB5sILpRgnL70sL9 1B50WlmMOqnSKdYl3FgsLXBllEqkK8ZWWzjRitIphlSSl7RiZYAauFCCyIowmB38Sdjf5SmYEti M3ApR+//A0PLRWqHttWtnHXDj7hPkZY/x1KsUHmEKBbThYnoxc/qRrhYvkSRxqZPcpFuOR5BXsn tbWhS2kFnUPTEjCmJEpxYySzqTM5Ij/gyvIy1UGRJ4IukP/uPvmjN1f4a X-Received: by 2002:a17:902:ec89:b0:224:93e:b5d7 with SMTP id d9443c01a7336-231de370eb9mr154482585ad.34.1747627746512; Sun, 18 May 2025 21:09:06 -0700 (PDT) Received: from toolbx.alistair23.me (2403-580b-97e8-0-82ce-f179-8a79-69f4.ip6.aussiebb.net. [2403:580b:97e8:0:82ce:f179:8a79:69f4]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-231ecd5ea41sm41750035ad.228.2025.05.18.21.09.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 May 2025 21:09:05 -0700 (PDT) From: alistair23@gmail.com X-Google-Original-From: alistair.francis@wdc.com To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Richard Henderson , Alistair Francis , Daniel Henrique Barboza , =?utf-8?q?Philippe_Mat?= =?utf-8?q?hieu-Daud=C3=A9?= Subject: [PULL 37/56] target/riscv: Move insn_len to internals.h Date: Mon, 19 May 2025 14:05:34 +1000 Message-ID: <20250519040555.3797167-38-alistair.francis@wdc.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250519040555.3797167-1-alistair.francis@wdc.com> References: <20250519040555.3797167-1-alistair.francis@wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::633; envelope-from=alistair23@gmail.com; helo=mail-pl1-x633.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Richard Henderson Signed-off-by: Richard Henderson Reviewed-by: Alistair Francis Reviewed-by: Daniel Henrique Barboza Reviewed-by: Philippe Mathieu-Daudé Message-ID: <20250425152311.804338-7-richard.henderson@linaro.org> Signed-off-by: Alistair Francis --- 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 85128f997b..0d4f7d601c 100644 --- a/target/riscv/translate.c +++ b/target/riscv/translate.c @@ -1209,11 +1209,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 Mon May 19 04:05:35 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 891103 Delivered-To: patch@linaro.org Received: by 2002:adf:e88a:0:b0:3a3:61c9:c5d4 with SMTP id d10csp899547wrm; Sun, 18 May 2025 21:29:54 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVDJ+xox/8r/3lXrwm7X/KaOkpXv5/0mSq3owFVwrY2jhuMrkTo+tjs72OeS0Tvrfc0lE86eg==@linaro.org X-Google-Smtp-Source: AGHT+IF692kMxnBEnT4bAuIHaBOpe1WXrItTqt0ffaVWgGUbUy6+TzfrR21JDapaOD0euWFGrATM X-Received: by 2002:a05:6214:20c7:b0:6f8:923a:d5a9 with SMTP id 6a1803df08f44-6f8b05d7417mr207410146d6.0.1747628983399; Sun, 18 May 2025 21:29:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1747628983; cv=none; d=google.com; s=arc-20240605; b=k6/sICJYe0VL4qgUJ1rbNuOKypbc1P0x7FJuiVkZhGVJQHURW2clp2A7FdSIWt+aUy NwzsgNug1x+19TlzQpRSuf9r8z8px5SaE4k4WzoaxsDrS/buPp9EQ79XvY3kCdfF4iaK a2zdmdJQMVoXmWiRGJl7rBmzFSuA/2LvXNnOsJHnctrBNgmj3W7zZ9g1FBRW3IWbwf6a qM1Rh13Noy3GKLByLCY0NkknrgC6P2DnbQFN2VGnDFpFGIVw6749SnD2S3gRvreqkH66 9S2tquQTCdlZShfJUccPjFNrSw8CecOsxda0BMjARH3BRksi7FfYsxmXrdxTFxDgxrBp ybNw== 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=9+8m5dgUHffTrvncW6hBDGM/ivLaHuneNLED/QiZRAg=; fh=HDQYu5lPAnkQefrBKmRl4cF3eYSeew0dhs6uIHrlDww=; b=OyMZ7aNGbKZ1zgPC3F/T75AClKm7PxGi2/X4ST4gAyN4uMzPwt4Q0gJ8Bw+oaudblW sQ+jDVvVdzvHTwmbaIndQQzVjKUtEylDxuLHNATk6vog6iyfPPHUd6jjuU3ZEVfQSTvQ EFSmV3wVh+bL44iWMsioMqIEF2/sU94jvP8u5dMubE/D0P++P5nQ25+MSkf+usKWIcaD l7QnfrueaKPHB2CJDgHp3gV/pkXgfytoJy1NGqsRp8pZMGLWaejwstEDYm9D+eLfm3ff fKRVINiT9KWbq287tVeAbQRVfkJSoJ5VXxw+KDoV8sFKXxDzbKwFWZtbryhE4xSMKDGS 8ouQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=f75CQJLz; 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=QUARANTINE dis=NONE) header.from=gmail.com; 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-6f8b09c1226si76599576d6.382.2025.05.18.21.29.43 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 18 May 2025 21:29:43 -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=@gmail.com header.s=20230601 header.b=f75CQJLz; 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=QUARANTINE dis=NONE) header.from=gmail.com; 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 1uGs3t-0001Ou-TB; Mon, 19 May 2025 00:25:14 -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 1uGroQ-0007m2-Bv for qemu-devel@nongnu.org; Mon, 19 May 2025 00:09:15 -0400 Received: from mail-pl1-x634.google.com ([2607:f8b0:4864:20::634]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uGroO-0004K2-EC for qemu-devel@nongnu.org; Mon, 19 May 2025 00:09:13 -0400 Received: by mail-pl1-x634.google.com with SMTP id d9443c01a7336-22d95f0dda4so42468885ad.2 for ; Sun, 18 May 2025 21:09:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1747627750; x=1748232550; 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=9+8m5dgUHffTrvncW6hBDGM/ivLaHuneNLED/QiZRAg=; b=f75CQJLz5+OjZSeeqJJeRkmRUQ+dp/L3kctCxmx7qyQWHl+1itMeY5QslMCEWY70xo HIP0wtTPkKIoFGFgz3Y3Uh+YjEGqoBubUyBAPmpcFP2KH8GJixUsNyjEG3wL/2GBm6mL 5ugUkMv2abGZi2hv4mMAo/lgpY2DyMZpF1TM2GKRMA9c017aTeMcKwcko07ZFWv/HHeT CtyGCopAUjIg/YKT+768RBdk/C9aFgx6FvmpnT74k6lwK1tmOKkqqh8+SAtPM0SUBNs4 7cK4rR0Y8kTxsnB07qlph4lNeZj1nG5FGb0FgO6K5uDAlVTnkjR7ImGWgdBslkKtsEKu tAFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1747627750; x=1748232550; 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=9+8m5dgUHffTrvncW6hBDGM/ivLaHuneNLED/QiZRAg=; b=VyybapadvmEu8arF3bXUsqaNySL1jHh0Mv4/RJg3CR/htB9M6UQr6crZ4vVV+zhoHf eW6lm2rjEiKS7tPWuuMkpdpXnNEXN+oEFXRX8FfywmFFETP6cMSOzx1h6R2NEKK4kLea e2l/GnTO23KNNtx7x1ryKDLzhzoSFL4lrZlKIDZMr0MPAgloCBaZzzvXCOXOPh+vDZT4 EnMo+3uHdapRFGx6HIKy/DAUVomM6ogc+oDoDu8IRwrcXyA2DprnKnS4yaUBg05WgjfR yqjE7F7FqRrB8CcBi6EYKm+904/iTJq0hV6gYpMvXvQWjSeoR1Mceu1k3u+u3cPd5F6E fhKg== X-Gm-Message-State: AOJu0YxGyB4m7A2tB/nSjn82Z7HzE56wClwJtcD7koX7YPXbsA8k5r63 ljcs8ocJ53j2pM5kYz36lzlPgo6Tfmsoz9fSX073g47b8j1C9AauFFloImDuZg== X-Gm-Gg: ASbGncsr3p/gy5x2bGA8ReKgHZWfseSs1hCvNmMNLHeZSjOjhn7OiaFkT4AMqwbkVd7 HPACNOgUS2RNciP/pyub8811eZUV4dQk/qTjRSqQmnIdTEzVHhEj8klwmNexYHo9hlwCeKAlB+p xDbt5eu9z6TIUKGbqqAwJy65hF2atZWNCTZR4ORiTHusO4k2VONFK3r2KxU8Tor1neHrsSSGVOx uAL+2/YQWl/n6SvBlEMQWm+4AcnWJV+yZMVCTatYg4PlmYdBxxH3c4ovhcFYagK0MgHH78+PlSe 4dKR/JZjqDVgEQZyIQRfOaaGOhmynqmQTWHcA+txrbk85ZZdnP1IGx7N45PgBAQAHz+c+B0mAEx 1wfcVN8K98b+3jahAZUZbQ8XDGUXfKgbuHdum3wXbQ9iezq9ch/BZkKyz X-Received: by 2002:a17:903:3d0f:b0:220:faa2:c911 with SMTP id d9443c01a7336-231d44e8833mr163446435ad.14.1747627749827; Sun, 18 May 2025 21:09:09 -0700 (PDT) Received: from toolbx.alistair23.me (2403-580b-97e8-0-82ce-f179-8a79-69f4.ip6.aussiebb.net. [2403:580b:97e8:0:82ce:f179:8a79:69f4]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-231ecd5ea41sm41750035ad.228.2025.05.18.21.09.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 May 2025 21:09:09 -0700 (PDT) From: alistair23@gmail.com X-Google-Original-From: alistair.francis@wdc.com To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Richard Henderson , Alistair Francis , Daniel Henrique Barboza , =?utf-8?q?Philippe_Mat?= =?utf-8?q?hieu-Daud=C3=A9?= Subject: [PULL 38/56] target/riscv: Fix write_misa vs aligned next_pc Date: Mon, 19 May 2025 14:05:35 +1000 Message-ID: <20250519040555.3797167-39-alistair.francis@wdc.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250519040555.3797167-1-alistair.francis@wdc.com> References: <20250519040555.3797167-1-alistair.francis@wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::634; envelope-from=alistair23@gmail.com; helo=mail-pl1-x634.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Richard Henderson 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: Alistair Francis Reviewed-by: Daniel Henrique Barboza Reviewed-by: Philippe Mathieu-Daudé Message-ID: <20250425152311.804338-8-richard.henderson@linaro.org> [ Changes by AF: - Change `& ~3` to `& 3` ] Signed-off-by: Alistair Francis --- 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 53458491da..288edeedea 100644 --- a/target/riscv/csr.c +++ b/target/riscv/csr.c @@ -30,6 +30,8 @@ #include "accel/tcg/getpc.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[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; }