From nobody Tue May 14 23:39:56 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1677260826; cv=none; d=zohomail.com; s=zohoarc; b=g/6WiB+hyuvToJ3LgIQpbMw6hadFHqjMVXpTzoqwE7aQSoDU9vz2xJlaSgSWNOdHgPFOjnF9cpqs5fzMNsqJM3tqwb4q881BPcsLwSdWjYZbN32IB1JZuCiR3I7Mtknql1wo/yBdoW78bnzNimG65AOX1p6knoqwOlrGXlxRSBM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677260826; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Ve+oK6DIt6nul51LAxAHBdjaPLfE+Xv9z7OvakbVdd0=; b=Q9yZPuDBUQbMF8w92BQQHQnGbnBE7vcc1DCzY5a5eBOqqv+Fgnz01/yqXgHV6zKkgt/2iDkxkmcxOooxNaoREa0/qHg6BqqVWN7b0XcWN8DagVwpW+scziFB6Y8un9gwxfr8C6JXHFQmNhqLRV5HgIEqhTEV22qqgv6+j23MtYs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1677260825952301.40429531215887; Fri, 24 Feb 2023 09:47:05 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pVc8Z-0001nl-6e; Fri, 24 Feb 2023 12:45:39 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pVc8X-0001mi-VD for qemu-devel@nongnu.org; Fri, 24 Feb 2023 12:45:38 -0500 Received: from mail-oa1-x29.google.com ([2001:4860:4864:20::29]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pVc8V-0003q7-Nf for qemu-devel@nongnu.org; Fri, 24 Feb 2023 12:45:37 -0500 Received: by mail-oa1-x29.google.com with SMTP id 586e51a60fabf-172afa7bee2so291725fac.6 for ; Fri, 24 Feb 2023 09:45:30 -0800 (PST) Received: from grind.. ([189.110.112.117]) by smtp.gmail.com with ESMTPSA id zf48-20020a0568716ab000b001722c5625e2sm3604123oab.7.2023.02.24.09.45.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Feb 2023 09:45:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; 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=Ve+oK6DIt6nul51LAxAHBdjaPLfE+Xv9z7OvakbVdd0=; b=okm+iGUUgEDgY4Mv1sq+XI/lnNpCTaHgk5iGMyQlSfisIpuB9sAstgCmvAibvuAyQe ZsFLCLyIhRdSsLlDuRGPjP6QkPjhzJF2DvG+kazTYJxrZyQ5IzdpJ8SUZM2frN4IFxQZ lyhwzEhdcrLO2hCI2YSopePhZ1TS8gW/WJgISD6oa1vNqVxSVZzxNVkVBT9L6NAiNth+ r2SiOiFg92Se5kl6Q15S6pQD1IFMm5kNePHBnPRTapkawwRjUF+uGwNLnuGEK3oFRKrW EQbt+44f8XZyLzXvaMTHkZDSQZ1J1k13DbDNZEZ5kPItdTg+ferGsnidKWoE9PR3pcEH UUMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=Ve+oK6DIt6nul51LAxAHBdjaPLfE+Xv9z7OvakbVdd0=; b=cDRsJNMaOtUBxxY88cOhgC7u173UhDbVxirtHbEWiZ9fAky28L2HyKTjLJZwPgG00G sabM/5mSzuQlwvBoWXV1n1DeUm6hO+Ql5bqiL6U9GZx7AgCVIypKpMhcBM0f2lnoyM9v 22fJwXP+cY/cWv+F1qD4HzH1lQ/pLuR12ajIibz3zil/Vpjw4HnPkHO7UBztnGqgppDJ L1ictJDQcrHqgierwfE/QC1YjZpa5Nt9okdlJLkzjfDQvhD4KqzJQ00tLEtNgVqI0pWr Et6HPnRgQ0yGAuejylrAD1MZY5FkrmTu82/zFZtcGKRWorlgwBwmYQ9s83jI+KfjB+1A G7kA== X-Gm-Message-State: AO0yUKWHCeJLx+t3LvZkvnxW/2nSYNsg4TTxwNC4olMjM3fZVS3iCHPI Z6341BVFpBzn0CrkYYXTJz9o6smPbx2e15Ic X-Google-Smtp-Source: AK7set9xjk/8+hw0TwdipQK3bdxo8IsNfFRW+V2+5LUXKN5CalhXyE5uz9FwvBhUORKjk4X2VEwG+Q== X-Received: by 2002:a05:6870:20d:b0:172:c578:d798 with SMTP id j13-20020a056870020d00b00172c578d798mr266886oad.25.1677260729404; Fri, 24 Feb 2023 09:45:29 -0800 (PST) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Cc: qemu-riscv@nongnu.org, alistair.francis@wdc.com, bmeng@tinylab.org, liweiwei@iscas.ac.cn, zhiwei_liu@linux.alibaba.com, Daniel Henrique Barboza Subject: [PATCH 1/4] target/riscv/csr.c: use env_archcpu() in ctr() Date: Fri, 24 Feb 2023 14:45:17 -0300 Message-Id: <20230224174520.92490-2-dbarboza@ventanamicro.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230224174520.92490-1-dbarboza@ventanamicro.com> References: <20230224174520.92490-1-dbarboza@ventanamicro.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2001:4860:4864:20::29; envelope-from=dbarboza@ventanamicro.com; helo=mail-oa1-x29.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @ventanamicro.com) X-ZM-MESSAGEID: 1677260826342100001 Content-Type: text/plain; charset="utf-8" We don't need to use env_cpu() and CPUState(). Signed-off-by: Daniel Henrique Barboza Reviewed-by: Richard Henderson --- target/riscv/csr.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/target/riscv/csr.c b/target/riscv/csr.c index 75a540bfcb..3692617d13 100644 --- a/target/riscv/csr.c +++ b/target/riscv/csr.c @@ -108,8 +108,7 @@ static RISCVException vs(CPURISCVState *env, int csrno) static RISCVException ctr(CPURISCVState *env, int csrno) { #if !defined(CONFIG_USER_ONLY) - CPUState *cs =3D env_cpu(env); - RISCVCPU *cpu =3D RISCV_CPU(cs); + RISCVCPU *cpu =3D env_archcpu(env); int ctr_index; target_ulong ctr_mask; int base_csrno =3D CSR_CYCLE; --=20 2.39.2 From nobody Tue May 14 23:39:56 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1677260829; cv=none; d=zohomail.com; s=zohoarc; b=Hph6mYd5Oj/3QFYdBHlfBiKVHTWwMrZ65AfkNUf4WZ9Ak2eN6k5gxEHUipA4z0iKzQbzneddWHSkYSTxD3kMlJ9uCjWTTjMF0HsSV6tWP2pViQ/J0zoEnuAHUz4gbBLHCoYuroejI5lbHdAvWgvmvjeL/5FrOUPj/dBtWU+7q2U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677260829; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=1gVj1M/nMMH0BmloQmU2g5NSrvMNYo6IEPm887UKzGc=; b=DmwB2wpjuNnsBAQgsJ2vrzy/BBB4iZko3qcgU9uYQlgpYnxIEqcCUabjrJGKnhPQTTVCRmCaqJdfLy2pX3ClG8MHNzAXZt4GK7NfRPPh+pwmfVXVrCHnoG0ATNgWNwl5rsWHrfjFUkj9TV8+dzw6q14z+ykgFZtdKI2Xx8UhwyY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1677260829903142.71743763972222; Fri, 24 Feb 2023 09:47:09 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pVc8Z-0001nn-A6; Fri, 24 Feb 2023 12:45:39 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pVc8Y-0001mj-0e for qemu-devel@nongnu.org; Fri, 24 Feb 2023 12:45:38 -0500 Received: from mail-oa1-x33.google.com ([2001:4860:4864:20::33]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pVc8V-0003v1-Og for qemu-devel@nongnu.org; Fri, 24 Feb 2023 12:45:37 -0500 Received: by mail-oa1-x33.google.com with SMTP id 586e51a60fabf-172b0ba97b0so305947fac.4 for ; Fri, 24 Feb 2023 09:45:33 -0800 (PST) Received: from grind.. ([189.110.112.117]) by smtp.gmail.com with ESMTPSA id zf48-20020a0568716ab000b001722c5625e2sm3604123oab.7.2023.02.24.09.45.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Feb 2023 09:45:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; 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=1gVj1M/nMMH0BmloQmU2g5NSrvMNYo6IEPm887UKzGc=; b=eJY3xBwolzpInIB7rOU3kyaPTbjJB7++DPwsY5CttIs8rZHnrboU1mlhl2nCvDUyK0 cKaHd/v4xZEDBWcVg7z8TS81nkIPlKw91abwdbkPUY3P279JuhIluxjSPHxV1V5/YwKZ 3DXEv+ICnvsyKvvExFUYqTwD69ZRYyDRCrlAzDg9DOnvs8j0+09EZaRYI1qinSEpzMls YiIQnwOLBK5ZMS2jFyRLhkpUjOxeW0fCtA42r6LA54FzcAOO9geVMEEUMrL2pibFoLS8 hvxSPwGBbIGO77Nf+26pUfm17bPqg8N24bzaq25gbSwSF0mFC0Rnt1Zt1Zf7xPDGXQRg H22A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=1gVj1M/nMMH0BmloQmU2g5NSrvMNYo6IEPm887UKzGc=; b=oN346kFZv4RlS4Almf2jyDksXxGVE/BgOBFXRWR/3K6JW40s+Xt/DRYsUvYkGVYU++ v6xw2qIxQ2K7gZZqUaI0goq7bPakkDy/Bv5VE3UAvFDO7gWJj3U+DhnH8ohi/aAK3jJ9 dxg9+ekvqweU47HHfAbp1/QCMRlWX9b0+WlKGbzJ5wHpaDA2rypJQqxqsuvjImmy+Bjv aL19xDG4HZEaJpGLEdf3KdbsRhvn9UlQ1jiLs3ReCSnhTMmMSIpZQTREKBojSMdVucEl W2PBSdfFisToMcb5XjX8GT4xTHUoLqeonOOir1ooflg20Qf938AY9oXIIfiNZ2NTWl9r 6Kqw== X-Gm-Message-State: AO0yUKU+TwlWSE49phxqfLtzTojTJV0iWdt9uhfBhVRq+XQjTlQkiknh N/E0zFYbUI1hMWjRKhvt5mWTfXkFGRbl2B7A X-Google-Smtp-Source: AK7set/D0pwYYZjL58HKINwGMyDbioDkqwpNFsyhI6j89o0s7cP/Wcp7sTu1cc0nEfHqmoD9JaSDDA== X-Received: by 2002:a05:6870:8a2b:b0:163:51eb:b577 with SMTP id p43-20020a0568708a2b00b0016351ebb577mr13495298oaq.46.1677260732497; Fri, 24 Feb 2023 09:45:32 -0800 (PST) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Cc: qemu-riscv@nongnu.org, alistair.francis@wdc.com, bmeng@tinylab.org, liweiwei@iscas.ac.cn, zhiwei_liu@linux.alibaba.com, Daniel Henrique Barboza Subject: [PATCH 2/4] target/riscv/csr.c: simplify mctr() Date: Fri, 24 Feb 2023 14:45:18 -0300 Message-Id: <20230224174520.92490-3-dbarboza@ventanamicro.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230224174520.92490-1-dbarboza@ventanamicro.com> References: <20230224174520.92490-1-dbarboza@ventanamicro.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2001:4860:4864:20::33; envelope-from=dbarboza@ventanamicro.com; helo=mail-oa1-x33.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @ventanamicro.com) X-ZM-MESSAGEID: 1677260830364100007 Content-Type: text/plain; charset="utf-8" Use riscv_cpu_cfg() to retrieve pmu_num. Signed-off-by: Daniel Henrique Barboza Reviewed-by: Richard Henderson Reviewed-by: Weiwei Li --- target/riscv/csr.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/target/riscv/csr.c b/target/riscv/csr.c index 3692617d13..0f4aa22a0f 100644 --- a/target/riscv/csr.c +++ b/target/riscv/csr.c @@ -165,8 +165,7 @@ static RISCVException ctr32(CPURISCVState *env, int csr= no) #if !defined(CONFIG_USER_ONLY) static RISCVException mctr(CPURISCVState *env, int csrno) { - CPUState *cs =3D env_cpu(env); - RISCVCPU *cpu =3D RISCV_CPU(cs); + int pmu_num =3D riscv_cpu_cfg(env)->pmu_num; int ctr_index; int base_csrno =3D CSR_MHPMCOUNTER3; =20 @@ -175,7 +174,7 @@ static RISCVException mctr(CPURISCVState *env, int csrn= o) base_csrno +=3D 0x80; } ctr_index =3D csrno - base_csrno; - if (!cpu->cfg.pmu_num || ctr_index >=3D cpu->cfg.pmu_num) { + if (!pmu_num || ctr_index >=3D pmu_num) { /* The PMU is not enabled or counter is out of range*/ return RISCV_EXCP_ILLEGAL_INST; } --=20 2.39.2 From nobody Tue May 14 23:39:56 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1677260819; cv=none; d=zohomail.com; s=zohoarc; b=hO7JDLgBx4fSqzQq9NEcDVNoH+jg9IHrGd2Po8WaSaE3jBvq0URQcNIcIql5Qy/qujHkqEnFGHYR0J4m+znKBwEqHCZILt8+xiBt5I9aYcvSDGdjXuJeRqeRCeykokBGQy7y8imwj33qy0ApsBoFbqvMoFLRuwM0Is0Og7JkIlg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677260819; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Yq+sgSEsm/UWUCBr+CXkx2Nf6xLVC+0m9hNthdUCKgc=; b=e3hutQqSZ+u3K7LMcLGguJTkmcCNOIJJVFBJUpCCOkIed13gCP7i6CzEV11guhQWyIkH7+ucgQsDOYnd1X6Bew9e7qeweQQSg8SuGt2A7rQRTN6CW9+cx0YfArB5FDSaOuEuZDd958UuaFx5hKQRcVfgy/Cjlz1lmMM4LIFHsjY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1677260819383254.83558048601537; Fri, 24 Feb 2023 09:46:59 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pVc8Z-0001nq-SI; Fri, 24 Feb 2023 12:45:39 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pVc8Y-0001n4-Of for qemu-devel@nongnu.org; Fri, 24 Feb 2023 12:45:38 -0500 Received: from mail-oa1-x2f.google.com ([2001:4860:4864:20::2f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pVc8X-0003w4-0t for qemu-devel@nongnu.org; Fri, 24 Feb 2023 12:45:38 -0500 Received: by mail-oa1-x2f.google.com with SMTP id 586e51a60fabf-17213c961dfso366104fac.0 for ; Fri, 24 Feb 2023 09:45:36 -0800 (PST) Received: from grind.. ([189.110.112.117]) by smtp.gmail.com with ESMTPSA id zf48-20020a0568716ab000b001722c5625e2sm3604123oab.7.2023.02.24.09.45.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Feb 2023 09:45:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; 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=Yq+sgSEsm/UWUCBr+CXkx2Nf6xLVC+0m9hNthdUCKgc=; b=gduwjqQgB+5YL816A9MujgjLziGFVDHxtHX86mxk9XyU/4UajWq2LpeagHwZFTwAhf aYAhLnlnDa6y12gV8z59tufLVu3cg8jRgC8Gl/Vo+EHLr46s2rF+/UR2kWgVSJM26p7c r+IpRA8JECGajYpoZqsJXCPp1V6OIIFRgjUgsHLwck6LdHfgO/mVtfgObseDjgTMDefg y8Ntv+BInBi/mIYjYw6NCeXntennVpOcMek+2myy/WwpV1kTVOWQJykeYGgvlzwy0Kmb Elkf5viQVSlMXJOPfa9pQnBJpiF7PzsWpTt+tf2L27zNRMF36Dj4Oi4Bf2u7h8XUBI9d WNsw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=Yq+sgSEsm/UWUCBr+CXkx2Nf6xLVC+0m9hNthdUCKgc=; b=ddT0Hy5lFS4DaXrVqxmGrTQQbiXZ+yF8NC7bJY+phipKuOrM2b1kth3pfPaMLL2TWC OmwktIaNtN21uUa/tqrTmNqDSnCN+/y6EqvA4I9yyp3J0Wy9LPNemm7t9tpi/7hW1coP 7zjCFD2iAweZYYSfAL3d+yyUSpbCC+1VTc69nVrPG9T30KYZ4Hi/syS4c7TmdIlVrbQi Tagy6kD6mzTb3JnZkQ8PVKgp9g5GAwxQS9HKgKQ4KswSStBQIfWPHE4oYGUGqz5t7rYq RdUl29EqNUeJtV6u/O57mHcHizaVhu1EzAcm0mKr29ZgGh+BYdA6yGwfayBBDzj/R0vU WGNA== X-Gm-Message-State: AO0yUKXs3kY1227YB7Pf4UBYzES05tr489PWgdrUFbTXZLs/tveJd1rW vH6AFVfNzObA1Rhm0moVvgPhypDRVHQZvPcw X-Google-Smtp-Source: AK7set8IFvZ63XpGJ7g6fy4whTMRjmESPSvOE8tw2yjHTm4m3VdOeqw/WOVC4L9EDwPTKL51/XxnPA== X-Received: by 2002:a05:6871:b2a:b0:16e:29f3:df8f with SMTP id fq42-20020a0568710b2a00b0016e29f3df8fmr14674771oab.29.1677260735257; Fri, 24 Feb 2023 09:45:35 -0800 (PST) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Cc: qemu-riscv@nongnu.org, alistair.francis@wdc.com, bmeng@tinylab.org, liweiwei@iscas.ac.cn, zhiwei_liu@linux.alibaba.com, Daniel Henrique Barboza Subject: [PATCH 3/4] target/riscv/csr.c: use riscv_cpu_cfg() to avoid env_cpu() pointers Date: Fri, 24 Feb 2023 14:45:19 -0300 Message-Id: <20230224174520.92490-4-dbarboza@ventanamicro.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230224174520.92490-1-dbarboza@ventanamicro.com> References: <20230224174520.92490-1-dbarboza@ventanamicro.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2001:4860:4864:20::2f; envelope-from=dbarboza@ventanamicro.com; helo=mail-oa1-x2f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @ventanamicro.com) X-ZM-MESSAGEID: 1677260820321100003 Content-Type: text/plain; charset="utf-8" A common trend in this file is to retrieve a RISCVCPU pointer by first retrieving a CPUState pointer via env_cpu(). The CPU pointer is used only to access the RISCVCPUConfig object and nothing else. Let's use riscv_cpu_cfg() to access what we need directly without these 2 pointers. Suggested-by: LIU Zhiwei Signed-off-by: Daniel Henrique Barboza Reviewed-by: Richard Henderson Reviewed-by: Weiwei Li --- target/riscv/csr.c | 50 +++++++++++----------------------------------- 1 file changed, 12 insertions(+), 38 deletions(-) diff --git a/target/riscv/csr.c b/target/riscv/csr.c index 0f4aa22a0f..53f1a331f9 100644 --- a/target/riscv/csr.c +++ b/target/riscv/csr.c @@ -46,10 +46,8 @@ static RISCVException smstateen_acc_ok(CPURISCVState *en= v, int index, uint64_t bit) { bool virt =3D riscv_cpu_virt_enabled(env); - CPUState *cs =3D env_cpu(env); - RISCVCPU *cpu =3D RISCV_CPU(cs); =20 - if (env->priv =3D=3D PRV_M || !cpu->cfg.ext_smstateen) { + if (env->priv =3D=3D PRV_M || !riscv_cpu_cfg(env)->ext_smstateen) { return RISCV_EXCP_NONE; } =20 @@ -81,7 +79,7 @@ static RISCVException fs(CPURISCVState *env, int csrno) { #if !defined(CONFIG_USER_ONLY) if (!env->debugger && !riscv_cpu_fp_enabled(env) && - !RISCV_CPU(env_cpu(env))->cfg.ext_zfinx) { + !riscv_cpu_cfg(env)->ext_zfinx) { return RISCV_EXCP_ILLEGAL_INST; } #endif @@ -90,11 +88,9 @@ static RISCVException fs(CPURISCVState *env, int csrno) =20 static RISCVException vs(CPURISCVState *env, int csrno) { - CPUState *cs =3D env_cpu(env); - RISCVCPU *cpu =3D RISCV_CPU(cs); - if (env->misa_ext & RVV || - cpu->cfg.ext_zve32f || cpu->cfg.ext_zve64f) { + riscv_cpu_cfg(env)->ext_zve32f || + riscv_cpu_cfg(env)->ext_zve64f) { #if !defined(CONFIG_USER_ONLY) if (!env->debugger && !riscv_cpu_vector_enabled(env)) { return RISCV_EXCP_ILLEGAL_INST; @@ -193,10 +189,7 @@ static RISCVException mctr32(CPURISCVState *env, int c= srno) =20 static RISCVException sscofpmf(CPURISCVState *env, int csrno) { - CPUState *cs =3D env_cpu(env); - RISCVCPU *cpu =3D RISCV_CPU(cs); - - if (!cpu->cfg.ext_sscofpmf) { + if (!riscv_cpu_cfg(env)->ext_sscofpmf) { return RISCV_EXCP_ILLEGAL_INST; } =20 @@ -319,10 +312,7 @@ static RISCVException umode32(CPURISCVState *env, int = csrno) =20 static RISCVException mstateen(CPURISCVState *env, int csrno) { - CPUState *cs =3D env_cpu(env); - RISCVCPU *cpu =3D RISCV_CPU(cs); - - if (!cpu->cfg.ext_smstateen) { + if (!riscv_cpu_cfg(env)->ext_smstateen) { return RISCV_EXCP_ILLEGAL_INST; } =20 @@ -331,10 +321,7 @@ static RISCVException mstateen(CPURISCVState *env, int= csrno) =20 static RISCVException hstateen_pred(CPURISCVState *env, int csrno, int bas= e) { - CPUState *cs =3D env_cpu(env); - RISCVCPU *cpu =3D RISCV_CPU(cs); - - if (!cpu->cfg.ext_smstateen) { + if (!riscv_cpu_cfg(env)->ext_smstateen) { return RISCV_EXCP_ILLEGAL_INST; } =20 @@ -361,10 +348,8 @@ static RISCVException sstateen(CPURISCVState *env, int= csrno) { bool virt =3D riscv_cpu_virt_enabled(env); int index =3D csrno - CSR_SSTATEEN0; - CPUState *cs =3D env_cpu(env); - RISCVCPU *cpu =3D RISCV_CPU(cs); =20 - if (!cpu->cfg.ext_smstateen) { + if (!riscv_cpu_cfg(env)->ext_smstateen) { return RISCV_EXCP_ILLEGAL_INST; } =20 @@ -916,11 +901,9 @@ static RISCVException read_timeh(CPURISCVState *env, i= nt csrno, =20 static RISCVException sstc(CPURISCVState *env, int csrno) { - CPUState *cs =3D env_cpu(env); - RISCVCPU *cpu =3D RISCV_CPU(cs); bool hmode_check =3D false; =20 - if (!cpu->cfg.ext_sstc || !env->rdtime_fn) { + if (!riscv_cpu_cfg(env)->ext_sstc || !env->rdtime_fn) { return RISCV_EXCP_ILLEGAL_INST; } =20 @@ -1150,30 +1133,21 @@ static RISCVException write_ignore(CPURISCVState *e= nv, int csrno, static RISCVException read_mvendorid(CPURISCVState *env, int csrno, target_ulong *val) { - CPUState *cs =3D env_cpu(env); - RISCVCPU *cpu =3D RISCV_CPU(cs); - - *val =3D cpu->cfg.mvendorid; + *val =3D riscv_cpu_cfg(env)->mvendorid; return RISCV_EXCP_NONE; } =20 static RISCVException read_marchid(CPURISCVState *env, int csrno, target_ulong *val) { - CPUState *cs =3D env_cpu(env); - RISCVCPU *cpu =3D RISCV_CPU(cs); - - *val =3D cpu->cfg.marchid; + *val =3D riscv_cpu_cfg(env)->marchid; return RISCV_EXCP_NONE; } =20 static RISCVException read_mimpid(CPURISCVState *env, int csrno, target_ulong *val) { - CPUState *cs =3D env_cpu(env); - RISCVCPU *cpu =3D RISCV_CPU(cs); - - *val =3D cpu->cfg.mimpid; + *val =3D riscv_cpu_cfg(env)->mimpid; return RISCV_EXCP_NONE; } =20 --=20 2.39.2 From nobody Tue May 14 23:39:56 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1677260776; cv=none; d=zohomail.com; s=zohoarc; b=F9g1VRZs+1AhwjP0qRAM+Kj1dyNXoHyKncF1lwatgR6ZwC7vk/sF0eWZZapnq9tsyORA+t0K48iqkvNm5YqCprdxtFg6ZplzudYpDRsEZpJS0rDD00KoAXmaXfEUYSmaa4AegKkYF/1rLznMCo/fwYgKvizUfeO5wEdIpbJ8kVw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677260776; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=6d8NvIbXd3OTFEBOjLeLjQoPN4gqAkbvmVXDYpiY2cE=; b=dbt22zktddIC60kg0u6KS+twa+c9x7O5z8gRPL5vW1KM5YQuV9d6BCB4drMzpC3dogywi6svCW1O48h4MCx9QN+1kDp0sacPV99KspZZMD9hAbPl6NOx93SXW2eLpPtyFpHQPEbCr1K00G9RDLMZHpK7PYv438xQ1P81x6ZerwU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1677260776796675.8491731137534; Fri, 24 Feb 2023 09:46:16 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pVc8c-0001pg-L5; Fri, 24 Feb 2023 12:45:42 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pVc8a-0001og-KI for qemu-devel@nongnu.org; Fri, 24 Feb 2023 12:45:40 -0500 Received: from mail-oa1-x2a.google.com ([2001:4860:4864:20::2a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pVc8Z-0003vN-1l for qemu-devel@nongnu.org; Fri, 24 Feb 2023 12:45:40 -0500 Received: by mail-oa1-x2a.google.com with SMTP id 586e51a60fabf-172094e10e3so267272fac.10 for ; Fri, 24 Feb 2023 09:45:38 -0800 (PST) Received: from grind.. ([189.110.112.117]) by smtp.gmail.com with ESMTPSA id zf48-20020a0568716ab000b001722c5625e2sm3604123oab.7.2023.02.24.09.45.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Feb 2023 09:45:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; 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=6d8NvIbXd3OTFEBOjLeLjQoPN4gqAkbvmVXDYpiY2cE=; b=pG6VmqyPGDCCaKGj87nHCI89mJWMEUQAcu1Ag0urlnCNVAf+gFzK7ZnCzVuObbS67K kreRQkVHfhW6lZTlH3Gd4w8hBrzY0C1pXpOgm0YNFEG6LIhGCK50elSAhyGxYMmHJMzl VmGE7FFwH8dP0zvvIISd0HHO3RqkU16OV2ND6KPN4i0qr6v5tyvYWwsm2SkISAqaEYWe ZMkAzUX3eTnhAJmP3ZMECr4LrOM8A9eWj+rvs76Un+VB4YnIy+GfYqP6yhmeVnaZ7gqq ScCj8mxQvcq/im4Q+qndN1ZqvcK2zHZWt42n7m/wsEQ6cr6f0j6wmo7a0m65rhjAjrZf mYsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=6d8NvIbXd3OTFEBOjLeLjQoPN4gqAkbvmVXDYpiY2cE=; b=o8jbYtXbD22W6khsUJy/6xBYYEAlkZ2BW52NXLKQI0m+LB0OYskNTAYCDcduCgGvHl QCV7Uh7jyNc0b2Cx//PuC297SBPnMBpXta4/EL6ZdeclKau/v05ZmzX+3KcsrW8kTIQ1 gD+lgHWz/4DujqLptVnsgnEXwGUbJwqlsn1AC1W1zcXh8exBZmg2Gvf4e2Ehwn/yWj4K mIpk+OrMxPaawDRY+Sc5yA+OpiXMwFBa56y8804C3G/efLlksNJJ3nTdRipaP2I6fuv4 W4/vO+IAm8PY52CR2IHN9O3or8UbQciwLfLLYbnUCpA7DvrTGAedmlpxH9qkfhOPeKOk UO7A== X-Gm-Message-State: AO0yUKVZAGoEUKeyQHIkDlXhjPjIGvwriyFyvwc2HcihoAmeegF9+JjT 0hf/4GAUx0zd7aGDkGTcPh7dW+l702Y+smBE X-Google-Smtp-Source: AK7set/fmLzRsuAY8Tl++MGTnNZrgMfxNDS4jVZXy4WQwNL3dlP9VILSUTzyQd+6j/j6fVGFj/MhSA== X-Received: by 2002:a05:6870:469f:b0:16d:f3c8:cf8d with SMTP id a31-20020a056870469f00b0016df3c8cf8dmr14000949oap.29.1677260738080; Fri, 24 Feb 2023 09:45:38 -0800 (PST) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Cc: qemu-riscv@nongnu.org, alistair.francis@wdc.com, bmeng@tinylab.org, liweiwei@iscas.ac.cn, zhiwei_liu@linux.alibaba.com, Daniel Henrique Barboza Subject: [PATCH 4/4] target/riscv/csr.c: avoid env_archcpu() usages when reading RISCVCPUConfig Date: Fri, 24 Feb 2023 14:45:20 -0300 Message-Id: <20230224174520.92490-5-dbarboza@ventanamicro.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230224174520.92490-1-dbarboza@ventanamicro.com> References: <20230224174520.92490-1-dbarboza@ventanamicro.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2001:4860:4864:20::2a; envelope-from=dbarboza@ventanamicro.com; helo=mail-oa1-x2a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @ventanamicro.com) X-ZM-MESSAGEID: 1677260778767100001 Content-Type: text/plain; charset="utf-8" Retrieving the CPU pointer using env_archcpu() just to access cpu->cfg can be avoided by using riscv_cpu_cfg(). Suggested-by: LIU Zhiwei Signed-off-by: Daniel Henrique Barboza Reviewed-by: Richard Henderson Reviewed-by: Weiwei Li --- target/riscv/csr.c | 32 +++++++++----------------------- 1 file changed, 9 insertions(+), 23 deletions(-) diff --git a/target/riscv/csr.c b/target/riscv/csr.c index 53f1a331f9..ffa2d7b606 100644 --- a/target/riscv/csr.c +++ b/target/riscv/csr.c @@ -213,9 +213,7 @@ static RISCVException any32(CPURISCVState *env, int csr= no) =20 static int aia_any(CPURISCVState *env, int csrno) { - RISCVCPU *cpu =3D env_archcpu(env); - - if (!cpu->cfg.ext_smaia) { + if (!riscv_cpu_cfg(env)->ext_smaia) { return RISCV_EXCP_ILLEGAL_INST; } =20 @@ -224,9 +222,7 @@ static int aia_any(CPURISCVState *env, int csrno) =20 static int aia_any32(CPURISCVState *env, int csrno) { - RISCVCPU *cpu =3D env_archcpu(env); - - if (!cpu->cfg.ext_smaia) { + if (!riscv_cpu_cfg(env)->ext_smaia) { return RISCV_EXCP_ILLEGAL_INST; } =20 @@ -253,9 +249,7 @@ static int smode32(CPURISCVState *env, int csrno) =20 static int aia_smode(CPURISCVState *env, int csrno) { - RISCVCPU *cpu =3D env_archcpu(env); - - if (!cpu->cfg.ext_ssaia) { + if (!riscv_cpu_cfg(env)->ext_ssaia) { return RISCV_EXCP_ILLEGAL_INST; } =20 @@ -264,9 +258,7 @@ static int aia_smode(CPURISCVState *env, int csrno) =20 static int aia_smode32(CPURISCVState *env, int csrno) { - RISCVCPU *cpu =3D env_archcpu(env); - - if (!cpu->cfg.ext_ssaia) { + if (!riscv_cpu_cfg(env)->ext_ssaia) { return RISCV_EXCP_ILLEGAL_INST; } =20 @@ -380,9 +372,7 @@ static RISCVException pointer_masking(CPURISCVState *en= v, int csrno) =20 static int aia_hmode(CPURISCVState *env, int csrno) { - RISCVCPU *cpu =3D env_archcpu(env); - - if (!cpu->cfg.ext_ssaia) { + if (!riscv_cpu_cfg(env)->ext_ssaia) { return RISCV_EXCP_ILLEGAL_INST; } =20 @@ -391,9 +381,7 @@ static int aia_hmode(CPURISCVState *env, int csrno) =20 static int aia_hmode32(CPURISCVState *env, int csrno) { - RISCVCPU *cpu =3D env_archcpu(env); - - if (!cpu->cfg.ext_ssaia) { + if (!riscv_cpu_cfg(env)->ext_ssaia) { return RISCV_EXCP_ILLEGAL_INST; } =20 @@ -430,9 +418,7 @@ static RISCVException debug(CPURISCVState *env, int csr= no) =20 static RISCVException seed(CPURISCVState *env, int csrno) { - RISCVCPU *cpu =3D env_archcpu(env); - - if (!cpu->cfg.ext_zkr) { + if (!riscv_cpu_cfg(env)->ext_zkr) { return RISCV_EXCP_ILLEGAL_INST; } =20 @@ -555,7 +541,7 @@ static RISCVException read_vl(CPURISCVState *env, int c= srno, =20 static int read_vlenb(CPURISCVState *env, int csrno, target_ulong *val) { - *val =3D env_archcpu(env)->cfg.vlen >> 3; + *val =3D riscv_cpu_cfg(env)->vlen >> 3; return RISCV_EXCP_NONE; } =20 @@ -610,7 +596,7 @@ static RISCVException write_vstart(CPURISCVState *env, = int csrno, * The vstart CSR is defined to have only enough writable bits * to hold the largest element index, i.e. lg2(VLEN) bits. */ - env->vstart =3D val & ~(~0ULL << ctzl(env_archcpu(env)->cfg.vlen)); + env->vstart =3D val & ~(~0ULL << ctzl(riscv_cpu_cfg(env)->vlen)); return RISCV_EXCP_NONE; } =20 --=20 2.39.2