From patchwork Fri Oct 22 13:37:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 1544920 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=wdc.com header.i=@wdc.com header.a=rsa-sha256 header.s=dkim.wdc.com header.b=MhrEbVoE; dkim=pass (2048-bit key; unprotected) header.d=opensource.wdc.com header.i=@opensource.wdc.com header.a=rsa-sha256 header.s=dkim header.b=CAeXPHj/; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4HbQSV22qxz9sXN for ; Sat, 23 Oct 2021 00:39:38 +1100 (AEDT) Received: from localhost ([::1]:43248 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mdulj-0007KY-P5 for incoming@patchwork.ozlabs.org; Fri, 22 Oct 2021 09:39:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56844) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mdukv-0007JP-R1 for qemu-devel@nongnu.org; Fri, 22 Oct 2021 09:38:46 -0400 Received: from esa4.hgst.iphmx.com ([216.71.154.42]:64363) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mduks-0000pC-IW for qemu-devel@nongnu.org; Fri, 22 Oct 2021 09:38:45 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1634909922; x=1666445922; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=H0DxmPXPRGiIWpgCTG3BUTm4GzNm0MlpIqrRajhd3Xk=; b=MhrEbVoE37o9S2VdyBstofb8MpUFl9CrCTCM6DjzeSo/xpw4tjSTRQfs zc3+1ibzjriiFHw3CTzsOlgp8ZEDe2JbTYU0MFFcQ+8J8FXxi0iBGav3u SaOPCOaO4z6823GIe13KxkPSgr3W42LxGLXrylvK/iNWqbdjmjd38vDD4 ir6L/HTHDECmALF0mTee0LHzCm36cONh9L04gVJt95zbJcqyM4DlgFtds opf8qY/cMmHBREqj8C+9Mrba0nRHZtqvUVm+g9aqpsdLQvsBmpV/NBhoH HCGIjvKi+GBDSPU+KW3snzqQUJ4ebmmgxf2vzn/lwMsiY2qctAuk9DVTq A==; X-IronPort-AV: E=Sophos;i="5.87,172,1631548800"; d="scan'208";a="182632547" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 22 Oct 2021 21:38:41 +0800 IronPort-SDR: qJGPd0cCm8FbI9aFhKlCqvCC30onqUyv5IDUsdrP63+Pyo/JKAxEorANtb/Vy15bjWkk8kLEUi jvu6+t+xh1M11g3XsOsLxzzCAkg0X/2xjIZR9WtrgAh9ZufbOmBn54elZXmaWsthN8ZN16A3Yh Pn+lwVHO3KlSmCa0NJfhaTXQJUVkXQK3Gpm6qlarNvR5pUT53LAf0wPbTQHShcNZh9GwLzakb8 coxislWQF5r0tmEM7ocE2O0IQsh7JKi7is0bRG0Pwej2HJaAA6PQ2yCpMCxkoi+vuYFIk+n0UT jMAXUAdFjJ1f96/ZMNSa7QH3 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Oct 2021 06:12:43 -0700 IronPort-SDR: JWGfZ1wdLeieIhjndmayH2YOiP4Rq305/x8T63UjdFNNyCXCyVPr0J/LOVcN7kTyiXjfnkdn9/ HOXArnni7zSh4DlIRXUz1NRV5vjLAalMMcTVWtQBmzC5u0xYTMbTTULSO/cYdk1eB27dZlf5z8 +z2adHdypwq4Kz3qsNqTRR1T+0esGjPNnDBhkRqKmjboA37mT3p13k8a0Ct28Im6tn1wz3fw8j Nh3spAZfvw1tRpkbd3rkqSpVrE0SxECGT7pqDv0Ond2CfOutUXWFMLB33Yn0a2gg0cdpexuYf4 gyY= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Oct 2021 06:38:41 -0700 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4HbQRP0Rbhz1RtVl for ; Fri, 22 Oct 2021 06:38:41 -0700 (PDT) Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1634909920; x=1637501921; bh=H0DxmPXPRGiIWpgCTG 3BUTm4GzNm0MlpIqrRajhd3Xk=; b=CAeXPHj/nWSPrS4aIoKLkdfZ/WG86nBLJx kb7A5FU68OTE7hJuYN8cplWXnDNSzNAqmNcFqqftTe+irXrYKTmXnj8DFEKXK1kb LURgke2MX39GRdYDjs3WhWqIbprM0b0tFfMgq+nSSGncR//kg3Hs/c8vcZ7Oi+Yw 2EpJqc96pcOGB+hDE2QWb/o/NO38ePx2ju3x6cZJBQog8mpDd/lOt7ijhFbuIiSq 0IHCw3psZtAJlu1aWBjuUe9AaRs3cvMUC5N/FQGmtlBbilf4uO00LouRjaNqU48d lLswLeMkQmvfx+XD/BZOwDshvj8XtNJkS3skgCP8u56P7qWDwfnQ== X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id Af2-eEOZ7mNS for ; Fri, 22 Oct 2021 06:38:40 -0700 (PDT) Received: from toolbox.wdc.com (unknown [10.225.165.39]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4HbQRJ3sM6z1RtVt; Fri, 22 Oct 2021 06:38:35 -0700 (PDT) From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Frank Chang , Richard Henderson , Alistair Francis Subject: [PULL 01/33] target/riscv: Pass the same value to oprsz and maxsz for vmv.v.v Date: Fri, 22 Oct 2021 23:37:40 +1000 Message-Id: <20211022133812.3972903-2-alistair.francis@opensource.wdc.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211022133812.3972903-1-alistair.francis@opensource.wdc.com> References: <20211022133812.3972903-1-alistair.francis@opensource.wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=216.71.154.42; envelope-from=prvs=9222bbd82=alistair.francis@opensource.wdc.com; helo=esa4.hgst.iphmx.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, SPF_HELO_PASS=-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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Frank Chang oprsz and maxsz are passed with the same value in commit: eee2d61e202. However, vmv.v.v was missed in that commit and should pass the same value as well in its tcg_gen_gvec_2_ptr() call. Signed-off-by: Frank Chang Reviewed-by: Richard Henderson Message-id: 20211007081803.1705656-1-frank.chang@sifive.com Signed-off-by: Alistair Francis --- target/riscv/insn_trans/trans_rvv.c.inc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/target/riscv/insn_trans/trans_rvv.c.inc b/target/riscv/insn_trans/trans_rvv.c.inc index 081a5ca34d..45be491ed4 100644 --- a/target/riscv/insn_trans/trans_rvv.c.inc +++ b/target/riscv/insn_trans/trans_rvv.c.inc @@ -1619,7 +1619,8 @@ static bool trans_vmv_v_v(DisasContext *s, arg_vmv_v_v *a) tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_vl, 0, over); tcg_gen_gvec_2_ptr(vreg_ofs(s, a->rd), vreg_ofs(s, a->rs1), - cpu_env, 0, s->vlen / 8, data, fns[s->sew]); + cpu_env, s->vlen / 8, s->vlen / 8, data, + fns[s->sew]); gen_set_label(over); } return true; From patchwork Fri Oct 22 13:37:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 1544921 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=wdc.com header.i=@wdc.com header.a=rsa-sha256 header.s=dkim.wdc.com header.b=hU01OtyM; dkim=pass (2048-bit key; unprotected) header.d=opensource.wdc.com header.i=@opensource.wdc.com header.a=rsa-sha256 header.s=dkim header.b=ZIfRZxqD; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4HbQSj3qTWz9sXN for ; Sat, 23 Oct 2021 00:39:49 +1100 (AEDT) Received: from localhost ([::1]:43374 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mdulv-0007PZ-As for incoming@patchwork.ozlabs.org; Fri, 22 Oct 2021 09:39:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56870) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mdul1-0007N7-If for qemu-devel@nongnu.org; Fri, 22 Oct 2021 09:38:51 -0400 Received: from esa4.hgst.iphmx.com ([216.71.154.42]:64367) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mduky-0000rC-EN for qemu-devel@nongnu.org; Fri, 22 Oct 2021 09:38:51 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1634909928; x=1666445928; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=vOJS78NbHpnmrcqVr968CGJJySNmBZqEkreTUXN66s0=; b=hU01OtyMC7AMYpOOIDEbOyaphvwX51ni33zQZZh/p6InV8p03ZrexeOt nGyNeLBEVESnKq5+ilu+dsPLS7m9UdLtqq3rpiEhOc197s0F/Jlo+A1eN 3UUDQiP81vym9/eC7StVI/nDHSyuGESG41kPjL17encbCEd/7IZ1dNONo dVN0pIgz6fa9tXgH4jV126aNlLQdh/6QzIBxosXGlw14xyZVK7MrQZThw dGlJM6m5qCQ9ehpbs4pJHxWqyg16L4nnCJ0CH381GDwl+LSFNFcRzyEoq CfT9ZgvlmOb7WAS8/8n0dIzoamqwd81B7Z20snLqmJuSu4CMtc2f9xv/h Q==; X-IronPort-AV: E=Sophos;i="5.87,172,1631548800"; d="scan'208";a="182632553" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 22 Oct 2021 21:38:45 +0800 IronPort-SDR: EhozFbUT9evHqXvwt4NIYjWQ6875YPWi9HBzSIrrSe8WLHbZgDNVOjZnEZ3RnXe8WLTAPEorP9 V3SWg1NZYVYD8ZkskSGXcxwPOC8xXloHtt2yRxhiVMgF5KvY59xdSgST+ZqgSc+/l21kBlz2Bo wyxam8tsoqjWQIBly6w+EpQ72NI9JJwZLpv0lGFQTGNS/unmE9PsHBEewtN44vbxMflwTLOBwQ OuP/ID9KuisxX4+U/2/fDcD6STVkdjWvFiowMaMjW3/pm7WWbLpPocJMkYdQtgj2vwfgGMGVSq +jpOmLTiuARfCS+v01A+B6w2 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Oct 2021 06:12:47 -0700 IronPort-SDR: bGSoAts47iY/0kfdHd2n8FFPAU4005kENBCYl0PwSPHX8zYgL8yYtKc1gvcq+ksh54N3kJzWcu 31ZPMJNKDu9Nr5YWs1YfxH6UYU/sqrq7uRC1ucPqkyqc/i094GTz6woNX2ydZt5fJUvRQXu4db hiD/LgQnipvdk0TdBW1PP/CgPRy15bEwcTcYM1+rBiNSEiHmftGyosrCBZPRk9L/hrbhXZpXFs pcDYkU8Sk3LcJgL5wuB8Am+pEO3sg1dv2BK/bDKLwOPahWh2/jKtJLCGSeva0Wa1Qr4YpH+BPF lCc= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Oct 2021 06:38:46 -0700 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4HbQRT4TRqz1RtVm for ; Fri, 22 Oct 2021 06:38:45 -0700 (PDT) Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1634909925; x=1637501926; bh=vOJS78NbHpnmrcqVr9 68CGJJySNmBZqEkreTUXN66s0=; b=ZIfRZxqD2o5iWWwzyJtJ4TpV9n0n8RF1Cj TiUfDPnWZEbHjVYfhIQMOH78qUbwbKmsW9Yt9nwiJIvMdjihlIysB1IeMoh32R42 AXqUQdRTAHUSbYs5u1MgGZREeYges6y4LGdopV16WgZ/OYvFrAKovxbvMqUFTxNU Jhc/K0zwsa/nlhYA8d+0y4iMj2bB40EzPb8aiHIWNslPC/O8MVBRp+/gnq7KbkjS 0uwY93wpV68HhxZ3H2Cv7M56koE2/Y4VnzMShvbMXwkeAkt3ajc8sLZoDDvObl3D lAJX4CIL6quV+ZyFeThmZixuREyi4rRBHI3VILYYUhwrFjYJlUhA== X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id w19EY_hGu0D4 for ; Fri, 22 Oct 2021 06:38:45 -0700 (PDT) Received: from toolbox.wdc.com (unknown [10.225.165.39]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4HbQRP66h1z1RtVl; Fri, 22 Oct 2021 06:38:41 -0700 (PDT) From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Travis Geiselbrecht , Alistair Francis Subject: [PULL 02/33] target/riscv: line up all of the registers in the info register dump Date: Fri, 22 Oct 2021 23:37:41 +1000 Message-Id: <20211022133812.3972903-3-alistair.francis@opensource.wdc.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211022133812.3972903-1-alistair.francis@opensource.wdc.com> References: <20211022133812.3972903-1-alistair.francis@opensource.wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=216.71.154.42; envelope-from=prvs=9222bbd82=alistair.francis@opensource.wdc.com; helo=esa4.hgst.iphmx.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, SPF_HELO_PASS=-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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Travis Geiselbrecht Ensure the columns for all of the register names and values line up. No functional change, just a minor tweak to the output. Signed-off-by: Travis Geiselbrecht Reviewed-by: Alistair Francis Message-id: 20211009055019.545153-1-travisg@gmail.com Signed-off-by: Alistair Francis --- target/riscv/cpu.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 1d69d1887e..660f9ce131 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -258,7 +258,7 @@ static void riscv_cpu_dump_state(CPUState *cs, FILE *f, int flags) } if (riscv_has_ext(env, RVH)) { qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "hstatus ", env->hstatus); - qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "vsstatus ", + qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "vsstatus", (target_ulong)env->vsstatus); } qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "mip ", env->mip); @@ -289,8 +289,8 @@ static void riscv_cpu_dump_state(CPUState *cs, FILE *f, int flags) qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "mtval ", env->mtval); qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "stval ", env->stval); if (riscv_has_ext(env, RVH)) { - qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "htval ", env->htval); - qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "mtval2 ", env->mtval2); + qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "htval ", env->htval); + qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "mtval2 ", env->mtval2); } qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "mscratch", env->mscratch); qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "sscratch", env->sscratch); @@ -298,7 +298,7 @@ static void riscv_cpu_dump_state(CPUState *cs, FILE *f, int flags) #endif for (i = 0; i < 32; i++) { - qemu_fprintf(f, " %s " TARGET_FMT_lx, + qemu_fprintf(f, " %-8s " TARGET_FMT_lx, riscv_int_regnames[i], env->gpr[i]); if ((i & 3) == 3) { qemu_fprintf(f, "\n"); @@ -306,7 +306,7 @@ static void riscv_cpu_dump_state(CPUState *cs, FILE *f, int flags) } if (flags & CPU_DUMP_FPU) { for (i = 0; i < 32; i++) { - qemu_fprintf(f, " %s %016" PRIx64, + qemu_fprintf(f, " %-8s %016" PRIx64, riscv_fpr_regnames[i], env->fpr[i]); if ((i & 3) == 3) { qemu_fprintf(f, "\n"); From patchwork Fri Oct 22 13:37:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 1544922 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=wdc.com header.i=@wdc.com header.a=rsa-sha256 header.s=dkim.wdc.com header.b=Q4Ki8afJ; dkim=pass (2048-bit key; unprotected) header.d=opensource.wdc.com header.i=@opensource.wdc.com header.a=rsa-sha256 header.s=dkim header.b=Fr/CIzMb; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4HbQSx0QRCz9sRN for ; Sat, 23 Oct 2021 00:40:01 +1100 (AEDT) Received: from localhost ([::1]:43622 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mdum6-0007ZL-Ry for incoming@patchwork.ozlabs.org; Fri, 22 Oct 2021 09:39:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56886) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mdul5-0007TZ-Ti for qemu-devel@nongnu.org; Fri, 22 Oct 2021 09:38:55 -0400 Received: from esa6.hgst.iphmx.com ([216.71.154.45]:47438) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mdul3-0000sy-Cq for qemu-devel@nongnu.org; Fri, 22 Oct 2021 09:38:55 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1634909934; x=1666445934; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=szAfsi9iOOnmaHfqJoFbbAAQvYUhSU363U/hFVz8fHc=; b=Q4Ki8afJAqFFISOTxvl5zV6tjzWNriBtSwWZq2Y+D8ZBIoJ7GbfoFzo3 Xz5ilcSaVxa07LMOFT/gf8B/YtTgCDROZcLqWHSZ4d6JQQDOyoOr8zdp2 ky99rZlSSKi5k6MednsLRYG7CII0XsqLTKcJhnCromXeOx7mEGv3i1pl4 Vp/K4iVANsMNRTxDr1UlfVp9vw7vSB0mmrIBrgfWtH6Gsyi00gXOuJ9S6 h8xJM21TVy4jcZzTUO/hr58qcN33si5BwUI+35qaZRSSj7ODi+8N3GtS0 l7T6/fA4UIR4vWNZ9wJsaM/V09y0psKqe/A4zNubiFjdf3Ax0OtuYhjx0 Q==; X-IronPort-AV: E=Sophos;i="5.87,172,1631548800"; d="scan'208";a="184556244" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 22 Oct 2021 21:38:52 +0800 IronPort-SDR: lBstfdQV8zGvcWbO/9CUw0YeEJ/krlAtM99U8ETDqGutUNBDCqODT+4HUjzHJfmvNytg5PL1JT 4mx77KZKxsc8A2NYgrtSXnh1ALe7Avh83/VaBD9tl7U3upLfWVnTJyZGDeg/TIsdnYDPWkgorz pVdJ2MDCTn7yiYE2Gal/vx6BEvrKLlJP/OBH3giNUAkvruHx6Cu8WACcnGLZ2y3mbDYACd8OlF YVYAWZDVTOSdVfuM81epT1KS60x/rC6Q5K9RN8HyYoKHJfNqnVpvH687AO7JeaHC3y3sDACXLa EpoT91/I9sLGbJSW4M0HEdoQ Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Oct 2021 06:14:26 -0700 IronPort-SDR: faXr2qzr+DjSv5LG5YFw+8rMHIQLKylrogDpzzipHMt7MU37h0dWh2CMGCJYMu/WKW2RfwQAKH e5B73woe5qjmGZMDjYhifRCLQKGv0ATU6d4auCBpLkr6MBkRhAgO6qMMgSCfZGOMFt5Z0L7M27 4EZx/qDwki0bihZUBhLI/8cQKROKYoenHWdbUOVgDQhc0DBWvb/Y8HLaxKThYrgVc2xfO7AdBU aJW1t2Pkfn6ATkRVBWVm41qTCm8sEZzYEL8uyEg14kg0FZz5uRnZa3K6U93wYM1hDGIxXKA1d8 rxY= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Oct 2021 06:38:51 -0700 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4HbQRb2xXKz1RtVv for ; Fri, 22 Oct 2021 06:38:51 -0700 (PDT) Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1634909930; x=1637501931; bh=szAfsi9iOOnmaHfqJo FbbAAQvYUhSU363U/hFVz8fHc=; b=Fr/CIzMbr6JKGLkhpA38hEni5rI3jhl+H6 D3jG0otIdwej9M7C7ZkbGqf/n/TCfH4WI1/wOUcx8I9OSVZpe0zg1zlMPWhrkJSs ZNkiVosv+zjjuQs+8sN+sabyDA0CTh3fIN3Msxz7XrfTuapc/sn6Ja7mbIL1ndqh +Q+3oJSEKg22TWdG03zQXiCZmLZqTVHHU4NKkqPCMq27hAXQ6hf3aAoOA0jJ34BF Up3hnoht9m+tLTDh0DDre8UK5C9KeP6bjVkhJGuYaB7vn2MtsVAJkOOk6IeBTm/X NXGT3sRmN2XwWJQL0CsOGDDB8UA3ZgzfOzq8h5948vTbZhpm3ZMg== X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id HC-I0MPKuThU for ; Fri, 22 Oct 2021 06:38:50 -0700 (PDT) Received: from toolbox.wdc.com (unknown [10.225.165.39]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4HbQRV2W1Mz1RtVl; Fri, 22 Oct 2021 06:38:45 -0700 (PDT) From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Philipp Tomsich , Vincent Palatin , Richard Henderson , Alistair Francis Subject: [PULL 03/33] target/riscv: Fix orc.b implementation Date: Fri, 22 Oct 2021 23:37:42 +1000 Message-Id: <20211022133812.3972903-4-alistair.francis@opensource.wdc.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211022133812.3972903-1-alistair.francis@opensource.wdc.com> References: <20211022133812.3972903-1-alistair.francis@opensource.wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=216.71.154.45; envelope-from=prvs=9222bbd82=alistair.francis@opensource.wdc.com; helo=esa6.hgst.iphmx.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, SPF_HELO_PASS=-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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Philipp Tomsich The earlier implementation fell into a corner case for bytes that were 0x01, giving a wrong result (but not affecting our application test cases for strings, as an ASCII value 0x01 is rare in those...). This changes the algorithm to: 1. Mask out the high-bit of each bytes (so that each byte is <= 127). 2. Add 127 to each byte (i.e. if the low 7 bits are not 0, this will overflow into the highest bit of each byte). 3. Bitwise-or the original value back in (to cover those cases where the source byte was exactly 128) to saturate the high-bit. 4. Shift-and-mask (implemented as a mask-and-shift) to extract the MSB of each byte into its LSB. 5. Multiply with 0xff to fan out the LSB to all bits of each byte. Fixes: d7a4fcb034 ("target/riscv: Add orc.b instruction for Zbb, removing gorc/gorci") Signed-off-by: Philipp Tomsich Reported-by: Vincent Palatin Tested-by: Vincent Palatin Reviewed-by: Richard Henderson Message-id: 20211013184125.2010897-1-philipp.tomsich@vrull.eu Signed-off-by: Alistair Francis --- target/riscv/insn_trans/trans_rvb.c.inc | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/target/riscv/insn_trans/trans_rvb.c.inc b/target/riscv/insn_trans/trans_rvb.c.inc index 185c3e9a60..3095624f32 100644 --- a/target/riscv/insn_trans/trans_rvb.c.inc +++ b/target/riscv/insn_trans/trans_rvb.c.inc @@ -249,13 +249,16 @@ static bool trans_rev8_64(DisasContext *ctx, arg_rev8_64 *a) static void gen_orc_b(TCGv ret, TCGv source1) { TCGv tmp = tcg_temp_new(); - TCGv ones = tcg_constant_tl(dup_const_tl(MO_8, 0x01)); + TCGv low7 = tcg_constant_tl(dup_const_tl(MO_8, 0x7f)); - /* Set lsb in each byte if the byte was zero. */ - tcg_gen_sub_tl(tmp, source1, ones); - tcg_gen_andc_tl(tmp, tmp, source1); + /* Set msb in each byte if the byte was non-zero. */ + tcg_gen_and_tl(tmp, source1, low7); + tcg_gen_add_tl(tmp, tmp, low7); + tcg_gen_or_tl(tmp, tmp, source1); + + /* Extract the msb to the lsb in each byte */ + tcg_gen_andc_tl(tmp, tmp, low7); tcg_gen_shri_tl(tmp, tmp, 7); - tcg_gen_andc_tl(tmp, ones, tmp); /* Replicate the lsb of each byte across the byte. */ tcg_gen_muli_tl(ret, tmp, 0xff); From patchwork Fri Oct 22 13:37:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 1544923 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=wdc.com header.i=@wdc.com header.a=rsa-sha256 header.s=dkim.wdc.com header.b=mlP4xo5g; dkim=pass (2048-bit key; unprotected) header.d=opensource.wdc.com header.i=@opensource.wdc.com header.a=rsa-sha256 header.s=dkim header.b=iBvK4AVW; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4HbQWm6nXqz9sRN for ; Sat, 23 Oct 2021 00:42:28 +1100 (AEDT) Received: from localhost ([::1]:51560 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mduoU-0004pN-O7 for incoming@patchwork.ozlabs.org; Fri, 22 Oct 2021 09:42:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56902) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mdulA-0007gT-Ay for qemu-devel@nongnu.org; Fri, 22 Oct 2021 09:39:00 -0400 Received: from esa4.hgst.iphmx.com ([216.71.154.42]:64377) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mdul8-0000u0-Aj for qemu-devel@nongnu.org; Fri, 22 Oct 2021 09:39:00 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1634909938; x=1666445938; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=B8fyculkXMWel6zy4Nw9UZR6Llei6JBtt8WxRZ5YIFM=; b=mlP4xo5gvzAsPt9mCisUt7WavPGgiE8/Wca6NJksdUWgvCnrRdpmg9oG rIyqAw3r2nv1XY07xO76y9M/MVMv0x9XB9ByGKMMjwnIzvv/D6N+hEMTb xQ8ZvRDzKzNJ/GoTmaSKFSECgQnLba2VqLsinKzN+1RxbHuC/lPOqSYDc i8PhhLzus+WqPXj0IlcUPLYuJCX0Qt87HbESs23/7jis8y+I1oMeaag7w IGrzbzA4QsqWMX4G7tpbJnUDPULw8liTSr5RO7rdIj72cyE8pkNRL1zrs tU+sRfeyn34gKS2ePV7XRfg8KqSAZtkCFnXshVt9J/FpaomqhrZq6XHT9 w==; X-IronPort-AV: E=Sophos;i="5.87,172,1631548800"; d="scan'208";a="182632566" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 22 Oct 2021 21:38:56 +0800 IronPort-SDR: BGKX4XH/IWGMvuho5bPHRlUOeUbgidsPFVlkv7Z6XtSGq8DvVLLVjDvzfsUw8ON7eNtXidmuzI CSyCDmGtlycntfh8a2SdxpSgxCyUM2DQ0jC92OssA0AIZ1PxphXhe5K+udZ9X67BsYqJZgjBhB 5bT/0j57rux+N9bYmuxPiZKWBCRCzmTbgjlIqYPaIVMVeUe9alxrzCYRZ02yyZaf2XaK81iZiU aZ4J9/je6Aa4SPlfK2iMCnY9u15IEO76Rsk5e6kZASNK4KTSImZFHgbY1rZ0v+RSoFn1Le1DuH 2cKZ9/r/zicuXYDy7O580rAk Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Oct 2021 06:14:31 -0700 IronPort-SDR: L5TjzZZsWsW5jc6OMWoM8npF+ONVImEXTuoAdYquo2mhBOmQubosmaKUHsE3uZ2rZ+aNTVnXAe VfcrAiLewYYWujkYgZPHv/+gQO/rjCQ76u3OagW8OfrdBS8RhNd4sTIQH9sE0htnO13rTZyiBE BANwkfOpwcbSD5ZTI6nAWLDD3YoFU1J2gxKYgFISWujhy1GtkGeHriW4XBVc7KtMdu6AKnO9++ HzZo2Z1xnYnTlvu23oNk+OeOu5Vvuj5N/9/4ykw86qdFX07wzwj8AST+vMZgkqVNwwzgQMHMn8 MpM= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Oct 2021 06:38:57 -0700 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4HbQRh6DnYz1RtVv for ; Fri, 22 Oct 2021 06:38:56 -0700 (PDT) Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1634909936; x=1637501937; bh=B8fyculkXMWel6zy4N w9UZR6Llei6JBtt8WxRZ5YIFM=; b=iBvK4AVW7FUZ0HoPkqGRmpzH1AcbJ10265 EYBtikx3smzZ9EcvaunP7Awg57MF0NgUgA5mvWO667JSrZ/1JvS6bwAhOwFExeTD pdI1yTIi0LAgGuKU7JP+gOK1KBOfwJ88aAjrcaz2urljTDBl680Rfv1sY3ojkJuA 3AwkkDX8/GDMFWUw89CD8zB0Qjmcr6vyYLXNgKPmUJygxY8YWTv5zoOFakDN1YVz 5mWJmB5lfsaV68y3dTSsqg4SOV4c51nkyLvP+zht2R007FslPGYSL2dEyIii3bsP J76pcmtzEdw80HW2JlXYrwvwAGDrTLW5FywZGWkPLPEyoH3LQs7g== X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id fGNQAl6gepeD for ; Fri, 22 Oct 2021 06:38:56 -0700 (PDT) Received: from toolbox.wdc.com (unknown [10.225.165.39]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4HbQRb6xd1z1RtVl; Fri, 22 Oct 2021 06:38:51 -0700 (PDT) From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Mingwang Li , Yifei Jiang , Alistair Francis Subject: [PULL 04/33] hw/riscv: virt: Use machine->ram as the system memory Date: Fri, 22 Oct 2021 23:37:43 +1000 Message-Id: <20211022133812.3972903-5-alistair.francis@opensource.wdc.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211022133812.3972903-1-alistair.francis@opensource.wdc.com> References: <20211022133812.3972903-1-alistair.francis@opensource.wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=216.71.154.42; envelope-from=prvs=9222bbd82=alistair.francis@opensource.wdc.com; helo=esa4.hgst.iphmx.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, SPF_HELO_PASS=-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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Mingwang Li If default main_mem is used to be registered as the system memory, other memory cannot be initialized. Therefore, the system memory should be initialized to the machine->ram, which consists of the default main_mem and other possible memory required by applications, such as shared hugepage memory in DPDK. Also, the mc->defaul_ram_id should be set to the default main_mem, such as "riscv_virt_board.ram" for the virt machine. Signed-off-by: Mingwang Li Signed-off-by: Yifei Jiang Reviewed-by: Alistair Francis Message-id: 20211016030908.40480-1-limingwang@huawei.com Signed-off-by: Alistair Francis --- hw/riscv/virt.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/hw/riscv/virt.c b/hw/riscv/virt.c index ec0cb69b8c..b3b431c847 100644 --- a/hw/riscv/virt.c +++ b/hw/riscv/virt.c @@ -771,7 +771,6 @@ static void virt_machine_init(MachineState *machine) const MemMapEntry *memmap = virt_memmap; RISCVVirtState *s = RISCV_VIRT_MACHINE(machine); MemoryRegion *system_memory = get_system_memory(); - MemoryRegion *main_mem = g_new(MemoryRegion, 1); MemoryRegion *mask_rom = g_new(MemoryRegion, 1); char *plic_hart_config, *soc_name; target_ulong start_addr = memmap[VIRT_DRAM].base; @@ -890,10 +889,8 @@ static void virt_machine_init(MachineState *machine) } /* register system main memory (actual RAM) */ - memory_region_init_ram(main_mem, NULL, "riscv_virt_board.ram", - machine->ram_size, &error_fatal); memory_region_add_subregion(system_memory, memmap[VIRT_DRAM].base, - main_mem); + machine->ram); /* create device tree */ create_fdt(s, memmap, machine->ram_size, machine->kernel_cmdline, @@ -1032,6 +1029,7 @@ static void virt_machine_class_init(ObjectClass *oc, void *data) mc->cpu_index_to_instance_props = riscv_numa_cpu_index_to_props; mc->get_default_cpu_node_id = riscv_numa_get_default_cpu_node_id; mc->numa_mem_supported = true; + mc->default_ram_id = "riscv_virt_board.ram"; machine_class_allow_dynamic_sysbus_dev(mc, TYPE_RAMFB_DEVICE); From patchwork Fri Oct 22 13:37:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 1544928 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=wdc.com header.i=@wdc.com header.a=rsa-sha256 header.s=dkim.wdc.com header.b=qY/8H5NL; dkim=pass (2048-bit key; unprotected) header.d=opensource.wdc.com header.i=@opensource.wdc.com header.a=rsa-sha256 header.s=dkim header.b=NJnHSN3s; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4HbQZR3nX8z9sRN for ; Sat, 23 Oct 2021 00:44:45 +1100 (AEDT) Received: from localhost ([::1]:60040 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mduqg-00027y-HM for incoming@patchwork.ozlabs.org; Fri, 22 Oct 2021 09:44:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56942) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mdulF-0007z1-QQ for qemu-devel@nongnu.org; Fri, 22 Oct 2021 09:39:05 -0400 Received: from esa6.hgst.iphmx.com ([216.71.154.45]:60325) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mdulD-0000vk-Fv for qemu-devel@nongnu.org; Fri, 22 Oct 2021 09:39:05 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1634909944; x=1666445944; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=XYdaywEPe4fL/1Ff2mytu134Il7CC9k0MP9aLw/zd2o=; b=qY/8H5NLRqbHLoj1N5dtVGpDccTAOUpuUkpH+SeeoAbA6P5rt3Cp0bGe XhX6fRmKYcrX+Z571RLJx/cdRUozC1C5Y4q3dv3SmmDf5862Ku8hSEJw2 IswRlO60oWmqUlmSSHvG/X4TFzPNeehc7TZM+vCJHURGI3+8MwraSUFMX R3lV1my4UHYiazUARtLB2r0swSmw5cNpXn9/d7y3r05H05Rea8pT7Rf6W m7ZmA63asS2d87enrdnt004qRCchWVXZVD6kI0LniepalZkudv2WHHCJL VhjKFWVmQ+meRTPm+ZB1ZfwsCS57TAaHAiQrAv3ceUdKnLG8ff2Fjj7Li w==; X-IronPort-AV: E=Sophos;i="5.87,172,1631548800"; d="scan'208";a="184556253" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 22 Oct 2021 21:39:03 +0800 IronPort-SDR: TTHHlUzXaHD6SPsbkdpm5KrC/wkprUOB21pqQ5++YEPR/xTAi+WWH9ny25kM3AxIV3Mat5FMKW YNx0v75Hf59euIvJAy7EYd7XbPQVMrbYHxhzjNvLt0L9mSy01JyCAIvQ6mTamWrCm42vRZp86F aEinAxH2P+IUzQ6+4qj5hzZkl4kgL2K1szsXIvWzniAnT6fhbB1OuK/0I0aNKGyBrutQyBzwA8 QNmAhYJgxhaCKeEdD7K3X53E69BeSrdVnTGhIklyqTYl2EeHiqlzRV4JvIQM+wC9ekJN6T6g0P 3UUp2YMrImlgFeF2EMgPedi0 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Oct 2021 06:14:37 -0700 IronPort-SDR: 9PYm1anEc05j3XtIJqZ0WuqIe20Gqv89BEX5snedAAPzJYZSZKP1BgaHd1jUz+DAd76+DhbA0t Zn48JqJQ2hecuVfZcGfmEfLxNXmAnynkMrzTRYNMKVQnff8MdJ9BIFNZtuLjp/AM5yFBDKVkdK QZ/K9fy27b/D3hYZ6P7YVNVwlSIJ1X6XbqqwAZ+doDqoyqyGbOx8hsQht2viw6fPVt26RMvArD gSk+pSIzAnpgmKiQtrUuhinixpqjEUrF/xbqqw1hKPzPUwdFyoiBeI0IqLmoTHADW69NGuJ+Yt S9A= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Oct 2021 06:39:02 -0700 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4HbQRn73kWz1RtVm for ; Fri, 22 Oct 2021 06:39:01 -0700 (PDT) Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1634909941; x=1637501942; bh=XYdaywEPe4fL/1Ff2m ytu134Il7CC9k0MP9aLw/zd2o=; b=NJnHSN3sVI2+JVDRGfIvzC5rdpPXZyGHkT mUoV/kvlCgLNSTvZ8BT4i4WkqqCiXtdReuov838J8aDc+6gC6uFX2HnBiUZZBS0L MBGp43zpWS754MgSZittqiyhRGQjik/1xpTXFsYw67oktVNl2vPbsCrxZzovvJDt Mv5DVS2TAxKHQLn5bWPInX19DpAWRE2XUTZaj7esn8LiWmYVWbGw5NqMLyzMW+px 1v/Zvv4Z7FdgJNWA3hVQgyPg9kzQiyQWvpBORbu5ANux5TiUquRGPnaW4TVFT2gX HpQr2MvtUca8Sk4craztML9aGmr1dTCNeCEoJV286w2t8320Oy8Q== X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id 64fm03kJE9du for ; Fri, 22 Oct 2021 06:39:01 -0700 (PDT) Received: from toolbox.wdc.com (unknown [10.225.165.39]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4HbQRj4YDRz1RtVl; Fri, 22 Oct 2021 06:38:57 -0700 (PDT) From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Frank Chang , Richard Henderson , Alistair Francis Subject: [PULL 05/33] target/riscv: fix TB_FLAGS bits overlapping bug for rvv/rvh Date: Fri, 22 Oct 2021 23:37:44 +1000 Message-Id: <20211022133812.3972903-6-alistair.francis@opensource.wdc.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211022133812.3972903-1-alistair.francis@opensource.wdc.com> References: <20211022133812.3972903-1-alistair.francis@opensource.wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=216.71.154.45; envelope-from=prvs=9222bbd82=alistair.francis@opensource.wdc.com; helo=esa6.hgst.iphmx.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, SPF_HELO_PASS=-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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Frank Chang TB_FLAGS mem_idx bits was extended from 2 bits to 3 bits in commit: c445593, but other TB_FLAGS bits for rvv and rvh were not shift as well so these bits may overlap with each other when rvv is enabled. Signed-off-by: Frank Chang Reviewed-by: Richard Henderson Reviewed-by: Alistair Francis Message-Id: <20211015074627.3957162-2-frank.chang@sifive.com> Signed-off-by: Alistair Francis --- target/riscv/cpu.h | 14 +++++++------- target/riscv/translate.c | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h index 9e55b2f5b1..ce42c83bda 100644 --- a/target/riscv/cpu.h +++ b/target/riscv/cpu.h @@ -378,7 +378,6 @@ void QEMU_NORETURN riscv_raise_exception(CPURISCVState *env, target_ulong riscv_cpu_get_fflags(CPURISCVState *env); void riscv_cpu_set_fflags(CPURISCVState *env, target_ulong); -#define TB_FLAGS_MMU_MASK 7 #define TB_FLAGS_PRIV_MMU_MASK 3 #define TB_FLAGS_PRIV_HYP_ACCESS_MASK (1 << 2) #define TB_FLAGS_MSTATUS_FS MSTATUS_FS @@ -387,13 +386,14 @@ typedef CPURISCVState CPUArchState; typedef RISCVCPU ArchCPU; #include "exec/cpu-all.h" -FIELD(TB_FLAGS, VL_EQ_VLMAX, 2, 1) -FIELD(TB_FLAGS, LMUL, 3, 2) -FIELD(TB_FLAGS, SEW, 5, 3) -FIELD(TB_FLAGS, VILL, 8, 1) +FIELD(TB_FLAGS, MEM_IDX, 0, 3) +FIELD(TB_FLAGS, VL_EQ_VLMAX, 3, 1) +FIELD(TB_FLAGS, LMUL, 4, 2) +FIELD(TB_FLAGS, SEW, 6, 3) +FIELD(TB_FLAGS, VILL, 9, 1) /* Is a Hypervisor instruction load/store allowed? */ -FIELD(TB_FLAGS, HLSX, 9, 1) -FIELD(TB_FLAGS, MSTATUS_HS_FS, 10, 2) +FIELD(TB_FLAGS, HLSX, 10, 1) +FIELD(TB_FLAGS, MSTATUS_HS_FS, 11, 2) bool riscv_cpu_is_32bit(CPURISCVState *env); diff --git a/target/riscv/translate.c b/target/riscv/translate.c index 6d7fbca1fa..62214e97fa 100644 --- a/target/riscv/translate.c +++ b/target/riscv/translate.c @@ -501,7 +501,7 @@ static void riscv_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs) uint32_t tb_flags = ctx->base.tb->flags; ctx->pc_succ_insn = ctx->base.pc_first; - ctx->mem_idx = tb_flags & TB_FLAGS_MMU_MASK; + ctx->mem_idx = FIELD_EX32(tb_flags, TB_FLAGS, MEM_IDX); ctx->mstatus_fs = tb_flags & TB_FLAGS_MSTATUS_FS; ctx->priv_ver = env->priv_ver; #if !defined(CONFIG_USER_ONLY) From patchwork Fri Oct 22 13:37:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 1544934 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=wdc.com header.i=@wdc.com header.a=rsa-sha256 header.s=dkim.wdc.com header.b=ltcbgyKs; dkim=pass (2048-bit key; unprotected) header.d=opensource.wdc.com header.i=@opensource.wdc.com header.a=rsa-sha256 header.s=dkim header.b=SBTmyJ0z; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4HbQfR4fGXz9sRN for ; Sat, 23 Oct 2021 00:48:15 +1100 (AEDT) Received: from localhost ([::1]:40302 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mduu5-0007qk-BU for incoming@patchwork.ozlabs.org; Fri, 22 Oct 2021 09:48:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56964) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mdulM-00089M-9q for qemu-devel@nongnu.org; Fri, 22 Oct 2021 09:39:13 -0400 Received: from esa2.hgst.iphmx.com ([68.232.143.124]:13246) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mdulJ-0000xx-Qk for qemu-devel@nongnu.org; Fri, 22 Oct 2021 09:39:12 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1634909949; x=1666445949; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=XLkjPH1Pk1fNoGQSHYmS/4f1zxx0xDys1xNOCrOTxvs=; b=ltcbgyKs84euXIZixtNqVVunxEgMQVftu/qv1Pu+gaGL/bhbGaIp7i4i 5B0rAge0hO3xOnDoeqx+Gp9HdH94aWVK5ZM24qLZPpb2i0nnlvBHIJeZK dbJx0QlfqUnZbpKXA30FDxn8glXP8cBcYWDDR7lvMKvU1K5ePDjSKkDGX uA0BM1hTR/vSpKuOThtUtGIBx9UI0GKdkyhIgoiSTqSQ4CmyRdm2NHD3z 5oiEMN34OpTIpaNgZI21arNAPEcEXm3loKx7GrwKZfRbsW82mmgSI/fk3 SH/M3400RHdsRq7CU+9U9bk/xrWosp9NjOU2pXzI5pp0ExRiEPylrE9/g g==; X-IronPort-AV: E=Sophos;i="5.87,172,1631548800"; d="scan'208";a="287492680" Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 22 Oct 2021 21:39:07 +0800 IronPort-SDR: efzdi3cCYoMSV5tfA7ZAQJtkk4jor4u9ZHWDPlOXP1m6pEvK83D1Q6K3Vl8MWoOJwSm2Ws8bim Oc8vTXiDwikKkT5ils0pCnADcTW6mBtE5g9TCBoVlTW1QD0YlCELYLi3BRVHaCY0eQLX3jY2lS Q3i9NLuBQT7AXCiBkeQN74j2RUQloVFwrn+3WVZhoqcgPvEEXC8OzXtaIkltGOsKcOAc6rhFe6 qtu7sBDUiLtP7VCzgtqIl7i0aGrElmAbx81rv8asxMW5P4pp0ZVd+JObxMWaGZeJz8uv76qp2o Hag8/twpssbfkDoLkD+tOVfB Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Oct 2021 06:13:10 -0700 IronPort-SDR: xO2k4QPiN1TS5uxYil0uRbja3RT1uEwJhpOSgHGmuPTJNQmMiwh4whOducKSn8A6xll1iD2s7w k6JDQAj3jvDTnH1rscIkQLX3npMp29FfzVAb7uL6rIUud2nF3bBm5h1pNZG8oHIz1eej3GFJNT A/Pxc/D3/2fGIiwzIWgCWuN3b5GzMHu4649xrinI271qVXBVxSLl4XU+AVbx3I8/21hqPYg+TF +blAOO7QRu0RRfPOdc0J5lmuxOFUmsXzi3RoaqWm1b/BSHEy7SydBnH8aPSrTQXs5oC2Le98p+ H1I= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Oct 2021 06:39:08 -0700 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4HbQRv5Hs7z1RtVn for ; Fri, 22 Oct 2021 06:39:07 -0700 (PDT) Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:content-type :mime-version:references:in-reply-to:x-mailer:message-id:date :subject:to:from; s=dkim; t=1634909947; x=1637501948; bh=XLkjPH1 Pk1fNoGQSHYmS/4f1zxx0xDys1xNOCrOTxvs=; b=SBTmyJ0zEzBQJ8U5bUrGhkr lKHYBFnWHkwh1a4RoqXlmm0ncAzsFEwEI5Z/hPzhtHFU3lY2CD1zTNH9SjcM62Ub Oriod7Q4A4QWshDv34bO6obUzL0jTp73BWr1a0ikyIGxzbbhJHLBWaqWLW7w803B FDIGkKAu0lINaYipkrpjV4nmY0jHChyRMUIrLnYQM8IHgG16uH8+NNlBkG6S7/Kc acqJX51M8XBimfHrophhX9/1hjlXnUWDzfarsrr36i0BiYSB/pPeJxmdp5nccj1H kmJJRxfpgS2a0ROpZMdmKlgo9sQS/dzfRG5OvOYO1O+4dCgeZR7f5al2JrSy/qw= = X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id QhpWwc6LSYEb for ; Fri, 22 Oct 2021 06:39:07 -0700 (PDT) Received: from toolbox.wdc.com (unknown [10.225.165.39]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4HbQRp5LQJz1RtVl; Fri, 22 Oct 2021 06:39:02 -0700 (PDT) From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Alistair Francis , Frank Chang , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Bin Meng Subject: [PULL 06/33] target/riscv: Remove some unused macros Date: Fri, 22 Oct 2021 23:37:45 +1000 Message-Id: <20211022133812.3972903-7-alistair.francis@opensource.wdc.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211022133812.3972903-1-alistair.francis@opensource.wdc.com> References: <20211022133812.3972903-1-alistair.francis@opensource.wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=68.232.143.124; envelope-from=prvs=9222bbd82=alistair.francis@opensource.wdc.com; helo=esa2.hgst.iphmx.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, SPF_HELO_PASS=-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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Alistair Francis Since commit 1a9540d1f1a ("target/riscv: Drop support for ISA spec version 1.09.1") these definitions are unused, remove them. Signed-off-by: Alistair Francis Reviewed-by: Frank Chang Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Bin Meng Message-id: f4d8a7a035f39c0a35d44c1e371c5c99cc2fa15a.1634531504.git.alistair.francis@wdc.com --- target/riscv/cpu_bits.h | 8 -------- 1 file changed, 8 deletions(-) diff --git a/target/riscv/cpu_bits.h b/target/riscv/cpu_bits.h index 999187a9ee..3aa2512d13 100644 --- a/target/riscv/cpu_bits.h +++ b/target/riscv/cpu_bits.h @@ -427,14 +427,6 @@ #define SATP64_ASID 0x0FFFF00000000000ULL #define SATP64_PPN 0x00000FFFFFFFFFFFULL -/* VM modes (mstatus.vm) privileged ISA 1.9.1 */ -#define VM_1_09_MBARE 0 -#define VM_1_09_MBB 1 -#define VM_1_09_MBBID 2 -#define VM_1_09_SV32 8 -#define VM_1_09_SV39 9 -#define VM_1_09_SV48 10 - /* VM modes (satp.mode) privileged ISA 1.10 */ #define VM_1_10_MBARE 0 #define VM_1_10_SV32 1 From patchwork Fri Oct 22 13:37:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 1544926 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=wdc.com header.i=@wdc.com header.a=rsa-sha256 header.s=dkim.wdc.com header.b=o2deabj3; dkim=pass (2048-bit key; unprotected) header.d=opensource.wdc.com header.i=@opensource.wdc.com header.a=rsa-sha256 header.s=dkim header.b=Uk5b41DP; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4HbQX06dyrz9sRN for ; Sat, 23 Oct 2021 00:42:40 +1100 (AEDT) Received: from localhost ([::1]:52348 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mduog-0005Mq-Ml for incoming@patchwork.ozlabs.org; Fri, 22 Oct 2021 09:42:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57022) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mdulS-0008KB-6g for qemu-devel@nongnu.org; Fri, 22 Oct 2021 09:39:18 -0400 Received: from esa1.hgst.iphmx.com ([68.232.141.245]:33487) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mdulP-000107-K5 for qemu-devel@nongnu.org; Fri, 22 Oct 2021 09:39:17 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1634909955; x=1666445955; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=/EsC/RTOkV2XvnHOFKOA1r14eC57yHygNPuQQZky8l0=; b=o2deabj3rV30YGS5RvAsSioxKfTB6UbmdEra/DwsRvPLtV45dlXfszps fWzAOpjT7XlFfCisAkHkAtsMURfm4mx6jYPf5bYjZPspBAhAH47KU/raL CYjvsINy44fXtmlNS2z7/5MMd5D0zt/98A2AxwnZ/dsjSP+FsiagADdlI VpTPRdQ/mkmuEvSVJ6qVYaLE8SuHIxRKO2lYs5f6rRxjUE/4bF8RjUGOk RfLNRJOw1tPxmhJwrxdcG5iAaMwXmmVHqgsj4qwmGKJEVQEe5Hpb1b/Bx CCPSacFPrGFSNOVXnLdsXCaYCjcWzDDB86DeHcwSbPxhD71nYEMXvFOjo g==; X-IronPort-AV: E=Sophos;i="5.87,172,1631548800"; d="scan'208";a="295350940" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 22 Oct 2021 21:39:13 +0800 IronPort-SDR: 1h7n7AfO7MHsgO4MIheCUrO9bLyixyJ/NmlFr3erXhWB9zQsOa8v1xKUd+sUABmKPyQmxg580B 4Z9/RFefmnk/+nxh4nCmk2GJNcSGrLh1rYmxX+LadnCvcurd699mgapn34m4Nn25yBRUrtGuga 9CTtiyuns7g1LBvw+cqm7cqpvV05ageBEq4bZxoBsbo1Asn0F8nUUtY4Hyd/5PpQLU5nS8YThu qLrh8tERgCOJBdPwmNv44eHyAVFLcYQGAUt+6xV9Lk/0kMGzgt4EnQeMC1EpvFGiC3pVQQqWeg QLYfjmw0NQVgiEMJwdxgXzMG Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Oct 2021 06:13:15 -0700 IronPort-SDR: vgIUfkidJ7mzd7JfDzj54CAc511SG+vSMIGF7oUnUXp3/nO5q9gZ5y6e9RcQVJ8gQzNJyDPFSg ONhlS9HQxaiDY1CDd1ckUuHe5Y1rar9VKMB4hhfGkVA3RO6JGIlE8m2cV8gyfmNbthBljZy6mC GXMvEyB888QDtvP0/IES91TrVOh3AhTDtYjmLHYqSz3AixVBIl9SdU75kTcuXL2q3Hm8FSkqc7 P8VKA6Mk0UV4tUI+dZEhJaG/7nHqlIBNVqGFtRk7zItrHuqMXspLxMe6gC2r/sqifTvNEbnOGY R5c= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Oct 2021 06:39:13 -0700 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4HbQS11rXFz1RtVn for ; Fri, 22 Oct 2021 06:39:13 -0700 (PDT) Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1634909952; x=1637501953; bh=/EsC/RTOkV2XvnHOFK OA1r14eC57yHygNPuQQZky8l0=; b=Uk5b41DPDohBhuIbACBYG1tWZw5Y4ukJFJ xn9KENIyFfhBbbOCiiNywKV3/gufP06BYVsOocMZQ8yGPDp6O7KK3t1Xfux5pWBj 677o23uyVr6Nldi6P5uEZNXbEVQHr8CdioS5FPDC9gc0FQckxz9qHpNBq62YOsyk gAagV6cyn+cQc2pvXYbAE+VQO05afpLz7zzqNGTUDi4tjqKH1FvwurpZQCec9bDl d3AMEO9fkq6Vgvh0Na/KWfs/uCcJFq01xLOXyLnB7u1e/YO/7nTBgVT+iM5Ee9vI AUdRp+I4BMdwtfqcHm5LlO15zfTMjlcfkvxoeZaeRrkj4zcJtQlg== X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id 5yjrg7n0FgjW for ; Fri, 22 Oct 2021 06:39:12 -0700 (PDT) Received: from toolbox.wdc.com (unknown [10.225.165.39]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4HbQRw4DvZz1RtVl; Fri, 22 Oct 2021 06:39:07 -0700 (PDT) From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Alistair Francis , Frank Chang , Bin Meng Subject: [PULL 07/33] target/riscv: Organise the CPU properties Date: Fri, 22 Oct 2021 23:37:46 +1000 Message-Id: <20211022133812.3972903-8-alistair.francis@opensource.wdc.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211022133812.3972903-1-alistair.francis@opensource.wdc.com> References: <20211022133812.3972903-1-alistair.francis@opensource.wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=68.232.141.245; envelope-from=prvs=9222bbd82=alistair.francis@opensource.wdc.com; helo=esa1.hgst.iphmx.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, SPF_HELO_PASS=-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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Alistair Francis Organise the CPU properties so that standard extensions come first then followed by experimental extensions. Signed-off-by: Alistair Francis Reviewed-by: Frank Chang Reviewed-by: Bin Meng Message-id: b6598570f60c5ee7f402be56d837bb44b289cc4d.1634531504.git.alistair.francis@wdc.com --- target/riscv/cpu.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 660f9ce131..11bb59ac6d 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -581,6 +581,7 @@ static void riscv_cpu_init(Object *obj) } static Property riscv_cpu_properties[] = { + /* Defaults for standard extensions */ DEFINE_PROP_BOOL("i", RISCVCPU, cfg.ext_i, true), DEFINE_PROP_BOOL("e", RISCVCPU, cfg.ext_e, false), DEFINE_PROP_BOOL("g", RISCVCPU, cfg.ext_g, true), @@ -591,22 +592,24 @@ static Property riscv_cpu_properties[] = { DEFINE_PROP_BOOL("c", RISCVCPU, cfg.ext_c, true), DEFINE_PROP_BOOL("s", RISCVCPU, cfg.ext_s, true), DEFINE_PROP_BOOL("u", RISCVCPU, cfg.ext_u, true), - /* This is experimental so mark with 'x-' */ + DEFINE_PROP_BOOL("Counters", RISCVCPU, cfg.ext_counters, true), + DEFINE_PROP_BOOL("Zifencei", RISCVCPU, cfg.ext_ifencei, true), + DEFINE_PROP_BOOL("Zicsr", RISCVCPU, cfg.ext_icsr, true), + DEFINE_PROP_BOOL("mmu", RISCVCPU, cfg.mmu, true), + DEFINE_PROP_BOOL("pmp", RISCVCPU, cfg.pmp, true), + + DEFINE_PROP_STRING("priv_spec", RISCVCPU, cfg.priv_spec), + + /* These are experimental so mark with 'x-' */ DEFINE_PROP_BOOL("x-zba", RISCVCPU, cfg.ext_zba, false), DEFINE_PROP_BOOL("x-zbb", RISCVCPU, cfg.ext_zbb, false), DEFINE_PROP_BOOL("x-zbc", RISCVCPU, cfg.ext_zbc, false), DEFINE_PROP_BOOL("x-zbs", RISCVCPU, cfg.ext_zbs, false), DEFINE_PROP_BOOL("x-h", RISCVCPU, cfg.ext_h, false), DEFINE_PROP_BOOL("x-v", RISCVCPU, cfg.ext_v, false), - DEFINE_PROP_BOOL("Counters", RISCVCPU, cfg.ext_counters, true), - DEFINE_PROP_BOOL("Zifencei", RISCVCPU, cfg.ext_ifencei, true), - DEFINE_PROP_BOOL("Zicsr", RISCVCPU, cfg.ext_icsr, true), - DEFINE_PROP_STRING("priv_spec", RISCVCPU, cfg.priv_spec), DEFINE_PROP_STRING("vext_spec", RISCVCPU, cfg.vext_spec), DEFINE_PROP_UINT16("vlen", RISCVCPU, cfg.vlen, 128), DEFINE_PROP_UINT16("elen", RISCVCPU, cfg.elen, 64), - DEFINE_PROP_BOOL("mmu", RISCVCPU, cfg.mmu, true), - DEFINE_PROP_BOOL("pmp", RISCVCPU, cfg.pmp, true), /* ePMP 0.9.3 */ DEFINE_PROP_BOOL("x-epmp", RISCVCPU, cfg.epmp, false), From patchwork Fri Oct 22 13:37:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 1544925 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=wdc.com header.i=@wdc.com header.a=rsa-sha256 header.s=dkim.wdc.com header.b=R6+lEQVI; dkim=pass (2048-bit key; unprotected) header.d=opensource.wdc.com header.i=@opensource.wdc.com header.a=rsa-sha256 header.s=dkim header.b=eSmcvAMY; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4HbQWy32znz9sRN for ; Sat, 23 Oct 2021 00:42:38 +1100 (AEDT) Received: from localhost ([::1]:52186 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mduoe-0005H3-6k for incoming@patchwork.ozlabs.org; Fri, 22 Oct 2021 09:42:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57040) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mdulW-0008QP-Hx for qemu-devel@nongnu.org; Fri, 22 Oct 2021 09:39:23 -0400 Received: from esa4.hgst.iphmx.com ([216.71.154.42]:64417) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mdulU-00013i-DT for qemu-devel@nongnu.org; Fri, 22 Oct 2021 09:39:22 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1634909960; x=1666445960; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=EV/G3/L/beuAoU7qjn9Sh1uqgs8o/FR+FSpTeGAQbZA=; b=R6+lEQVI0Pi0IcTBMANX+2XMfhu/nL9kTIT5SwgZtKeOLXaS0uKdXXJs 18AYDuJYAm9DKWzxCkk83FLf+inio5Qu01fHRtsXTGN5lfEnrEuHWC5UL Wyr2Uv7n2HRAy9pBttWXUTlFWKv+GDzEb55qNrwA8b1Cw/mq3FrUwC7Et qi/F93yBK+YBtT1X5RS908oSbunkjs14uedilwnoAk/+TzN+y8B+P8Bu2 BjEX4fkcB2XFKTOkZvDVS1n/JTwYM1MF3dG5lBg70h431es/e37rBJWwS HvqLhOnBWwyq3az7JzsD1rINYUulBC6v1aY7hfjIBGSNbJnCr+6wUh0zO g==; X-IronPort-AV: E=Sophos;i="5.87,172,1631548800"; d="scan'208";a="182632586" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 22 Oct 2021 21:39:18 +0800 IronPort-SDR: x5DI2Fw6IOYTLWf4ZlWNrI7uOiFH+KZ9Fi3k8aFEPZ0DQ2eggiKN+QV3pZjU8Ee6KNA+pt64P7 E3RLycBP+qojJz5HUjkAqC0SZM5LfaK77d4yMmlIjgma8els4ZHZ++Efn8jJ0LZIFJ/FzHPgxm 1yirARm+LgRUf7ZrugVybkRZ2au0vtbXDcgLtWUySGmW/nVixGHa+2zvobpig5KduKkxvq5O8i bU1DBw8kODjhFltLYPBJaN/eoMVuNpc051prvSOg6sPwaraiAHuFKtq7v76nMwc6nuOrUn7GgS zdXWfIYpgX0jMX8zfRGrmeBu Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Oct 2021 06:14:53 -0700 IronPort-SDR: h5T3uCsCkJ6kvplS/1IZ7kqPA9OdrnySAtFY5qDwXhbdOuGlHDZ/eBCbg3XM67QOKpGD9i8ae6 /tbpdeOFtGQUy1hVvFNu+OPmpc7pQ7RJlfQL84YXMx+hz1sk+xZsvgae1e+NyXseVkjE5nKJSD jih5zHyKCjgT79/PsIhZ7Jlt21PlP8yYXrpgo2Z9rmVjcG8OutRb2nSyfTthWXj/BwQUxaWR+Z ibm2MlFpTUShwHlHI9mRy7W41MV2BbBkE8v+1vDJOEsEoe6OrWXtP0gS5lxmgmXrt47lTr584t 89I= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Oct 2021 06:39:19 -0700 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4HbQS63KWwz1RtVm for ; Fri, 22 Oct 2021 06:39:18 -0700 (PDT) Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1634909958; x=1637501959; bh=EV/G3/L/beuAoU7qjn 9Sh1uqgs8o/FR+FSpTeGAQbZA=; b=eSmcvAMYjEYzMW0nYHYvQ4FGP8hppIFK/O EloH1MVSM/SIelx7v5p8x3GdJff7JydP8PcV95yyrzrcBGiOh2Y4bv2HCV3KoXy9 JbjCcd8bN6ptxEYtokk7zAfPQZxvmkaLJF+1euTM6yBL9F4YgyLeWvu3MKAA1sRU 5dEchZdoDX39OphF1oxc+UaCtXu6pS0RVhsJ5iTMbbyUmrlFhNB69XnBhW0C/40S E2DPsWFqDjYpjJ7SiMsEV5ddvlMEMqvg0s0AZPiH76b1RaY8uxXA+PQ7fpLkD2ha aKF57JTlfKXppi3MbWu7ei5mxVY716hw0JISUk8EZAsgCu/VYTAA== X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id kwnkmqmr8nOw for ; Fri, 22 Oct 2021 06:39:18 -0700 (PDT) Received: from toolbox.wdc.com (unknown [10.225.165.39]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4HbQS206llz1RtVl; Fri, 22 Oct 2021 06:39:13 -0700 (PDT) From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Richard Henderson , LIU Zhiwei , Alistair Francis Subject: [PULL 08/33] target/riscv: Move cpu_get_tb_cpu_state out of line Date: Fri, 22 Oct 2021 23:37:47 +1000 Message-Id: <20211022133812.3972903-9-alistair.francis@opensource.wdc.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211022133812.3972903-1-alistair.francis@opensource.wdc.com> References: <20211022133812.3972903-1-alistair.francis@opensource.wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=216.71.154.42; envelope-from=prvs=9222bbd82=alistair.francis@opensource.wdc.com; helo=esa4.hgst.iphmx.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, SPF_HELO_PASS=-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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson Move the function to cpu_helper.c, as it is large and growing. Reviewed-by: LIU Zhiwei Reviewed-by: Alistair Francis Signed-off-by: Richard Henderson Message-id: 20211020031709.359469-2-richard.henderson@linaro.org Signed-off-by: Alistair Francis --- target/riscv/cpu.h | 47 ++------------------------------------- target/riscv/cpu_helper.c | 46 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+), 45 deletions(-) diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h index ce42c83bda..f543364d51 100644 --- a/target/riscv/cpu.h +++ b/target/riscv/cpu.h @@ -413,51 +413,8 @@ static inline uint32_t vext_get_vlmax(RISCVCPU *cpu, target_ulong vtype) return cpu->cfg.vlen >> (sew + 3 - lmul); } -static inline void cpu_get_tb_cpu_state(CPURISCVState *env, target_ulong *pc, - target_ulong *cs_base, uint32_t *pflags) -{ - uint32_t flags = 0; - - *pc = env->pc; - *cs_base = 0; - - if (riscv_has_ext(env, RVV)) { - uint32_t vlmax = vext_get_vlmax(env_archcpu(env), env->vtype); - bool vl_eq_vlmax = (env->vstart == 0) && (vlmax == env->vl); - flags = FIELD_DP32(flags, TB_FLAGS, VILL, - FIELD_EX64(env->vtype, VTYPE, VILL)); - flags = FIELD_DP32(flags, TB_FLAGS, SEW, - FIELD_EX64(env->vtype, VTYPE, VSEW)); - flags = FIELD_DP32(flags, TB_FLAGS, LMUL, - FIELD_EX64(env->vtype, VTYPE, VLMUL)); - flags = FIELD_DP32(flags, TB_FLAGS, VL_EQ_VLMAX, vl_eq_vlmax); - } else { - flags = FIELD_DP32(flags, TB_FLAGS, VILL, 1); - } - -#ifdef CONFIG_USER_ONLY - flags |= TB_FLAGS_MSTATUS_FS; -#else - flags |= cpu_mmu_index(env, 0); - if (riscv_cpu_fp_enabled(env)) { - flags |= env->mstatus & MSTATUS_FS; - } - - if (riscv_has_ext(env, RVH)) { - if (env->priv == PRV_M || - (env->priv == PRV_S && !riscv_cpu_virt_enabled(env)) || - (env->priv == PRV_U && !riscv_cpu_virt_enabled(env) && - get_field(env->hstatus, HSTATUS_HU))) { - flags = FIELD_DP32(flags, TB_FLAGS, HLSX, 1); - } - - flags = FIELD_DP32(flags, TB_FLAGS, MSTATUS_HS_FS, - get_field(env->mstatus_hs, MSTATUS_FS)); - } -#endif - - *pflags = flags; -} +void cpu_get_tb_cpu_state(CPURISCVState *env, target_ulong *pc, + target_ulong *cs_base, uint32_t *pflags); RISCVException riscv_csrrw(CPURISCVState *env, int csrno, target_ulong *ret_value, diff --git a/target/riscv/cpu_helper.c b/target/riscv/cpu_helper.c index d41d5cd27c..14d1d3cb72 100644 --- a/target/riscv/cpu_helper.c +++ b/target/riscv/cpu_helper.c @@ -35,6 +35,52 @@ int riscv_cpu_mmu_index(CPURISCVState *env, bool ifetch) #endif } +void cpu_get_tb_cpu_state(CPURISCVState *env, target_ulong *pc, + target_ulong *cs_base, uint32_t *pflags) +{ + uint32_t flags = 0; + + *pc = env->pc; + *cs_base = 0; + + if (riscv_has_ext(env, RVV)) { + uint32_t vlmax = vext_get_vlmax(env_archcpu(env), env->vtype); + bool vl_eq_vlmax = (env->vstart == 0) && (vlmax == env->vl); + flags = FIELD_DP32(flags, TB_FLAGS, VILL, + FIELD_EX64(env->vtype, VTYPE, VILL)); + flags = FIELD_DP32(flags, TB_FLAGS, SEW, + FIELD_EX64(env->vtype, VTYPE, VSEW)); + flags = FIELD_DP32(flags, TB_FLAGS, LMUL, + FIELD_EX64(env->vtype, VTYPE, VLMUL)); + flags = FIELD_DP32(flags, TB_FLAGS, VL_EQ_VLMAX, vl_eq_vlmax); + } else { + flags = FIELD_DP32(flags, TB_FLAGS, VILL, 1); + } + +#ifdef CONFIG_USER_ONLY + flags |= TB_FLAGS_MSTATUS_FS; +#else + flags |= cpu_mmu_index(env, 0); + if (riscv_cpu_fp_enabled(env)) { + flags |= env->mstatus & MSTATUS_FS; + } + + if (riscv_has_ext(env, RVH)) { + if (env->priv == PRV_M || + (env->priv == PRV_S && !riscv_cpu_virt_enabled(env)) || + (env->priv == PRV_U && !riscv_cpu_virt_enabled(env) && + get_field(env->hstatus, HSTATUS_HU))) { + flags = FIELD_DP32(flags, TB_FLAGS, HLSX, 1); + } + + flags = FIELD_DP32(flags, TB_FLAGS, MSTATUS_HS_FS, + get_field(env->mstatus_hs, MSTATUS_FS)); + } +#endif + + *pflags = flags; +} + #ifndef CONFIG_USER_ONLY static int riscv_cpu_local_irq_pending(CPURISCVState *env) { From patchwork Fri Oct 22 13:37:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 1544931 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=wdc.com header.i=@wdc.com header.a=rsa-sha256 header.s=dkim.wdc.com header.b=EUjBOBeT; dkim=pass (2048-bit key; unprotected) header.d=opensource.wdc.com header.i=@opensource.wdc.com header.a=rsa-sha256 header.s=dkim header.b=QLOYhqHn; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4HbQZW5pk3z9sXN for ; Sat, 23 Oct 2021 00:44:51 +1100 (AEDT) Received: from localhost ([::1]:60758 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mduqn-0002az-IT for incoming@patchwork.ozlabs.org; Fri, 22 Oct 2021 09:44:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57056) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mdula-0008UJ-7f for qemu-devel@nongnu.org; Fri, 22 Oct 2021 09:39:27 -0400 Received: from esa4.hgst.iphmx.com ([216.71.154.42]:64417) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mdulY-00013i-9W for qemu-devel@nongnu.org; Fri, 22 Oct 2021 09:39:25 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1634909964; x=1666445964; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=+blsV58pE8V4aRd/mxoZFyuWTYmOcGZcMQW8lUPKM0I=; b=EUjBOBeT70AjjKvThp80Ije72NplgsoBLEDb3dU46JwYL2kqtig2yJFU ehrHvZJSy7uH90mjduW34m99YL2LGZLGMyj8/Zk1D1ciDvwLp0AxyHzjF 1x49TdawUDaTlAiApyDQP4E3Wyir3pPpv5jIv0ttW/+xfGUgXq1pKdwxL bwxYtZsLef8ALAHAnux10TU9ns/VmB9LehnWkfqMeJXPbLDY9FZ2EErXZ QtHiMwzKgfUXOe2ymrtr3qz6EWuvyvht1RAXxFGmNwbyIUa4FAU/Ph9Ko cOVayv4EHgGGPuOJOSL2Es2ymjr1vmdtcuworTIo6aVhcdGrWnPkCQZPY w==; X-IronPort-AV: E=Sophos;i="5.87,172,1631548800"; d="scan'208";a="182632591" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 22 Oct 2021 21:39:23 +0800 IronPort-SDR: gjJVSfMVly8jH2ssUFxBm3eEOBlCIxdoSgn3yt0xUlMo5TeLdFUTMYiYf70Qr+ZhaAiC5MOytL YWfATodomDIg+iSdpjcE7UYNSV5kU9vGntV6cDmV9tq1HP7ry6s6IDLqFfjaj7dNL3QnxFIRDc K3/AA/+KPePHRFeutTIq7wTRfdQXEnw3D5xGXdyMO6MY5rYMp33iBnGzVGbot+8uNf2jvzKGkX MEu3T3oBLpjZIwXHp8plxLRtn4zqQIrAbtbWztQaBTIErS1MYElqx1Zmio8Byarhij1xYso4y7 bcgDl8NLEiEOQy+eWkpE+lfC Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Oct 2021 06:14:58 -0700 IronPort-SDR: qR9fQ1XchViRqVUj3gPtkNCfP5bcin58N3OE1BW7utGDwO5DxMrUsJVichHl90NU4RfQ4kdWpf nPkVgPpO+lOQ1mN/E0xyvFiAOODWXK4TNbMYPHgV/yzcAjsPAuI3iUTrvZg2VSLGBMGp7bCxw7 fQoAUwJqgXfCeSDq7OE/7BJq4E4u0zbi7qJKi7hf0Z2fFDpzHrRv91l0K/K5wMyQuFIK4sBAtE vQpnVScQwcn/CDyXSFXggPhcmXb6dLXgmmHuuG34LVxO7Jx5RQLoV8qQ1MxXjkMTWN4qQlPreO /Tw= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Oct 2021 06:39:24 -0700 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4HbQSC3mMkz1RtVt for ; Fri, 22 Oct 2021 06:39:23 -0700 (PDT) Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1634909963; x=1637501964; bh=+blsV58pE8V4aRd/mx oZFyuWTYmOcGZcMQW8lUPKM0I=; b=QLOYhqHndwV8/fOrLN8CQAIw2cBs58Y32m KKgKjBD0NqZj57LNGXw57tj5twUdHLf1o0eqX4y6AjiLBi68afQ0iidd4r9vGpNH yeZw60hmu2hXsudIwtDCLoIaBFloP/pVfbTFsKenwvgzcLu04SL1g+nmLhrp/pEp l633Yi8Md3humvEKuwbBsJ4ufXZs4gxqq/PBdgXwlBTF3xhmqNAv5YRkqi1/kYCt eTijSedsxHf/rb6FLBuAzIXlba392eRNhTKulygk2/TbntN8zSj+dheDYYSbvqn0 JCo1utgWbxHXk45hmiSPrTxVq0vaQ196VKmQYviFrOumF9NGjTrQ== X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id 0t4sExo3TpLH for ; Fri, 22 Oct 2021 06:39:23 -0700 (PDT) Received: from toolbox.wdc.com (unknown [10.225.165.39]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4HbQS70y07z1RtVl; Fri, 22 Oct 2021 06:39:18 -0700 (PDT) From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Richard Henderson , LIU Zhiwei , Alistair Francis Subject: [PULL 09/33] target/riscv: Create RISCVMXL enumeration Date: Fri, 22 Oct 2021 23:37:48 +1000 Message-Id: <20211022133812.3972903-10-alistair.francis@opensource.wdc.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211022133812.3972903-1-alistair.francis@opensource.wdc.com> References: <20211022133812.3972903-1-alistair.francis@opensource.wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=216.71.154.42; envelope-from=prvs=9222bbd82=alistair.francis@opensource.wdc.com; helo=esa4.hgst.iphmx.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, SPF_HELO_PASS=-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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson Move the MXL_RV* defines to enumerators. Reviewed-by: LIU Zhiwei Reviewed-by: Alistair Francis Signed-off-by: Richard Henderson Message-id: 20211020031709.359469-3-richard.henderson@linaro.org Signed-off-by: Alistair Francis --- target/riscv/cpu_bits.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/target/riscv/cpu_bits.h b/target/riscv/cpu_bits.h index 3aa2512d13..cffcd3a5df 100644 --- a/target/riscv/cpu_bits.h +++ b/target/riscv/cpu_bits.h @@ -364,9 +364,11 @@ #define MISA32_MXL 0xC0000000 #define MISA64_MXL 0xC000000000000000ULL -#define MXL_RV32 1 -#define MXL_RV64 2 -#define MXL_RV128 3 +typedef enum { + MXL_RV32 = 1, + MXL_RV64 = 2, + MXL_RV128 = 3, +} RISCVMXL; /* sstatus CSR bits */ #define SSTATUS_UIE 0x00000001 From patchwork Fri Oct 22 13:37:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 1544938 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=wdc.com header.i=@wdc.com header.a=rsa-sha256 header.s=dkim.wdc.com header.b=K+3M56LW; dkim=pass (2048-bit key; unprotected) header.d=opensource.wdc.com header.i=@opensource.wdc.com header.a=rsa-sha256 header.s=dkim header.b=dDlYTPsz; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4HbQfw0YGlz9sRN for ; Sat, 23 Oct 2021 00:48:40 +1100 (AEDT) Received: from localhost ([::1]:41036 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mduuT-0008K5-Qa for incoming@patchwork.ozlabs.org; Fri, 22 Oct 2021 09:48:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57110) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mdulj-0000SR-R8 for qemu-devel@nongnu.org; Fri, 22 Oct 2021 09:39:35 -0400 Received: from esa3.hgst.iphmx.com ([216.71.153.141]:41478) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mdulg-00016n-JT for qemu-devel@nongnu.org; Fri, 22 Oct 2021 09:39:35 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1634909971; x=1666445971; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=4gXm8UB4FAu5jTuLfbf6TuIDFO9o6od/N/ACPlI6XJI=; b=K+3M56LWtVp7bA6hIWuG0DZne4vd0RIfHq68fqwRRzuYOHvgo0aV+yI4 XB8Mva4zik6Ct/NNYG4+zGh3teWBI60GvYgfcPUI1rxzp8HRUmgJ3nVvC 4qF3bPckPcjt9o7jq9qcANsJzdCkvWeU+iHVmB2+9zRkh47at/SFfL9CL mHAB9NZQ990cZ2nxFtH6VYFXM/IdrmqzexZyjOC3odZUiDtdO0gMbokKa jsF/F3ATgoG0hkiMROKSCYP1NZN5P+O1u3be6UzlzkjWTHpFbvPSLU5RY D5zLCQbcsxuRh1z4XcXvmAklEAt1/Ln9KdN0RGchKD+eIc86p3xIrZDQW A==; X-IronPort-AV: E=Sophos;i="5.87,172,1631548800"; d="scan'208";a="188392129" Received: from h199-255-45-14.hgst.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 22 Oct 2021 21:39:29 +0800 IronPort-SDR: TlEgXu+9+5PBCyz1cZ4Zp+nF9PAr/Cx9PVMsh+WOf9sG5zGiIxN5FgxRUG1Wt6QitKXYTH1ftw Fe9U6ILrGwEOK3I3YaImIRMibMtuLKpFYK0kMIwDeI8a9RfYQo5SxKDc4nPt9CcBmyxmjVKclv JRmCjCEjCPve7ZOvoD9M6VarJXZErgzGw9IqvtjHmB49LChYhVgNtgqNAWPydBNnvpLqZWYQxG H38H89whGvk7GzoFqMmHlgnF0hNXPLc80mXN5ZRamPkGlxMHdDUUodjMuYnjKmzzx/tDl7WpsB zoi21auuWsOhIetRuYQNPACa Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Oct 2021 06:15:05 -0700 IronPort-SDR: CjhiaFVFZqY5IHDeFAbsUNSII4hK+/fKjKLOlawdeZywr6YQY15muB7PeChVs7/KLNiysVV7iO 7OaIaKah153R7ogt1up6SbWp29Bc6d+zOvu//cXU4nhkqr38WiI58uzMEA545e9kNKo4/kxlsX 1Rk1+fLNNyP8nUnPradjI+pNYMrrmec9uH1iM+pmNnDoS+3Z0rcxhtaJSw/d7b79EiuUlJGXjb M+SsiXcpmI7yy0bkNj+J5eji9P+xYNitIl01snJLlFwhw8IpbUSgwYWLtHJyJe2rR6jgAtwVYM /vk= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Oct 2021 06:39:30 -0700 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4HbQSL203Mz1RtVn for ; Fri, 22 Oct 2021 06:39:30 -0700 (PDT) Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1634909969; x=1637501970; bh=4gXm8UB4FAu5jTuLfb f6TuIDFO9o6od/N/ACPlI6XJI=; b=dDlYTPszvPPKfe6HwHykguwW4d0CrhJtSr IZCMgwSy5FsWuW7HApLkgFUqSdN13aSV0mMHFn3wSZIoppb2MzWVTr3yf2SE9wGb bcd+o/3Po+RdCO2rXMxA4w1qwn8SFOOv/4TF3EBeac/oYyLl5ZpZ/umLb+YZ7UUM I1TzC/uLKxiRXhE2ZDhHEFp3p9gq+cH558Mxf0WLqSUgZszsy3EJ/3myBrzTFxov GbzgXwMYMChWV2NMZCv8QYSpKn5o0G9jADNWt8rfg/qqQv65BHX5e3+6TqqWwLiX wzMQT0fskCDvLbfhwS5hK2ob2GXvSs77LNGSsnrRDVI51jjcEk4w== X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id wxzAp1hRMNmT for ; Fri, 22 Oct 2021 06:39:29 -0700 (PDT) Received: from toolbox.wdc.com (unknown [10.225.165.39]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4HbQSD2Y6jz1RtVl; Fri, 22 Oct 2021 06:39:23 -0700 (PDT) From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Richard Henderson , LIU Zhiwei , Alistair Francis Subject: [PULL 10/33] target/riscv: Split misa.mxl and misa.ext Date: Fri, 22 Oct 2021 23:37:49 +1000 Message-Id: <20211022133812.3972903-11-alistair.francis@opensource.wdc.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211022133812.3972903-1-alistair.francis@opensource.wdc.com> References: <20211022133812.3972903-1-alistair.francis@opensource.wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=216.71.153.141; envelope-from=prvs=9222bbd82=alistair.francis@opensource.wdc.com; helo=esa3.hgst.iphmx.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson The hw representation of misa.mxl is at the high bits of the misa csr. Representing this in the same way inside QEMU results in overly complex code trying to check that field. Reviewed-by: LIU Zhiwei Reviewed-by: Alistair Francis Signed-off-by: Richard Henderson Message-id: 20211020031709.359469-4-richard.henderson@linaro.org Signed-off-by: Alistair Francis --- target/riscv/cpu.h | 15 +++---- linux-user/elfload.c | 2 +- linux-user/riscv/cpu_loop.c | 2 +- target/riscv/cpu.c | 78 +++++++++++++++++++++---------------- target/riscv/csr.c | 44 ++++++++++++++------- target/riscv/gdbstub.c | 8 ++-- target/riscv/machine.c | 10 +++-- target/riscv/translate.c | 10 +++-- 8 files changed, 100 insertions(+), 69 deletions(-) diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h index f543364d51..90d11e3c2a 100644 --- a/target/riscv/cpu.h +++ b/target/riscv/cpu.h @@ -25,6 +25,7 @@ #include "exec/cpu-defs.h" #include "fpu/softfloat-types.h" #include "qom/object.h" +#include "cpu_bits.h" #define TCG_GUEST_DEFAULT_MO 0 @@ -51,9 +52,6 @@ # define TYPE_RISCV_CPU_BASE TYPE_RISCV_CPU_BASE64 #endif -#define RV32 ((target_ulong)1 << (TARGET_LONG_BITS - 2)) -#define RV64 ((target_ulong)2 << (TARGET_LONG_BITS - 2)) - #define RV(x) ((target_ulong)1 << (x - 'A')) #define RVI RV('I') @@ -133,8 +131,12 @@ struct CPURISCVState { target_ulong priv_ver; target_ulong bext_ver; target_ulong vext_ver; - target_ulong misa; - target_ulong misa_mask; + + /* RISCVMXL, but uint32_t for vmstate migration */ + uint32_t misa_mxl; /* current mxl */ + uint32_t misa_mxl_max; /* max mxl for this cpu */ + uint32_t misa_ext; /* current extensions */ + uint32_t misa_ext_mask; /* max ext for this cpu */ uint32_t features; @@ -313,7 +315,7 @@ struct RISCVCPU { static inline int riscv_has_ext(CPURISCVState *env, target_ulong ext) { - return (env->misa & ext) != 0; + return (env->misa_ext & ext) != 0; } static inline bool riscv_feature(CPURISCVState *env, int feature) @@ -322,7 +324,6 @@ static inline bool riscv_feature(CPURISCVState *env, int feature) } #include "cpu_user.h" -#include "cpu_bits.h" extern const char * const riscv_int_regnames[]; extern const char * const riscv_fpr_regnames[]; diff --git a/linux-user/elfload.c b/linux-user/elfload.c index eb32f3e2cb..f9b8261692 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -1448,7 +1448,7 @@ static uint32_t get_elf_hwcap(void) uint32_t mask = MISA_BIT('I') | MISA_BIT('M') | MISA_BIT('A') | MISA_BIT('F') | MISA_BIT('D') | MISA_BIT('C'); - return cpu->env.misa & mask; + return cpu->env.misa_ext & mask; #undef MISA_BIT } diff --git a/linux-user/riscv/cpu_loop.c b/linux-user/riscv/cpu_loop.c index 9859a366e4..e5bb6d908a 100644 --- a/linux-user/riscv/cpu_loop.c +++ b/linux-user/riscv/cpu_loop.c @@ -133,7 +133,7 @@ void target_cpu_copy_regs(CPUArchState *env, struct target_pt_regs *regs) env->gpr[xSP] = regs->sp; env->elf_flags = info->elf_flags; - if ((env->misa & RVE) && !(env->elf_flags & EF_RISCV_RVE)) { + if ((env->misa_ext & RVE) && !(env->elf_flags & EF_RISCV_RVE)) { error_report("Incompatible ELF: RVE cpu requires RVE ABI binary"); exit(EXIT_FAILURE); } diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 11bb59ac6d..f18bb4b21e 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -110,16 +110,13 @@ const char *riscv_cpu_get_trap_name(target_ulong cause, bool async) bool riscv_cpu_is_32bit(CPURISCVState *env) { - if (env->misa & RV64) { - return false; - } - - return true; + return env->misa_mxl == MXL_RV32; } -static void set_misa(CPURISCVState *env, target_ulong misa) +static void set_misa(CPURISCVState *env, RISCVMXL mxl, uint32_t ext) { - env->misa_mask = env->misa = misa; + env->misa_mxl_max = env->misa_mxl = mxl; + env->misa_ext_mask = env->misa_ext = ext; } static void set_priv_version(CPURISCVState *env, int priv_ver) @@ -148,9 +145,9 @@ static void riscv_any_cpu_init(Object *obj) { CPURISCVState *env = &RISCV_CPU(obj)->env; #if defined(TARGET_RISCV32) - set_misa(env, RV32 | RVI | RVM | RVA | RVF | RVD | RVC | RVU); + set_misa(env, MXL_RV32, RVI | RVM | RVA | RVF | RVD | RVC | RVU); #elif defined(TARGET_RISCV64) - set_misa(env, RV64 | RVI | RVM | RVA | RVF | RVD | RVC | RVU); + set_misa(env, MXL_RV64, RVI | RVM | RVA | RVF | RVD | RVC | RVU); #endif set_priv_version(env, PRIV_VERSION_1_11_0); } @@ -160,20 +157,20 @@ static void rv64_base_cpu_init(Object *obj) { CPURISCVState *env = &RISCV_CPU(obj)->env; /* We set this in the realise function */ - set_misa(env, RV64); + set_misa(env, MXL_RV64, 0); } static void rv64_sifive_u_cpu_init(Object *obj) { CPURISCVState *env = &RISCV_CPU(obj)->env; - set_misa(env, RV64 | RVI | RVM | RVA | RVF | RVD | RVC | RVS | RVU); + set_misa(env, MXL_RV64, RVI | RVM | RVA | RVF | RVD | RVC | RVS | RVU); set_priv_version(env, PRIV_VERSION_1_10_0); } static void rv64_sifive_e_cpu_init(Object *obj) { CPURISCVState *env = &RISCV_CPU(obj)->env; - set_misa(env, RV64 | RVI | RVM | RVA | RVC | RVU); + set_misa(env, MXL_RV64, RVI | RVM | RVA | RVC | RVU); set_priv_version(env, PRIV_VERSION_1_10_0); qdev_prop_set_bit(DEVICE(obj), "mmu", false); } @@ -182,20 +179,20 @@ static void rv32_base_cpu_init(Object *obj) { CPURISCVState *env = &RISCV_CPU(obj)->env; /* We set this in the realise function */ - set_misa(env, RV32); + set_misa(env, MXL_RV32, 0); } static void rv32_sifive_u_cpu_init(Object *obj) { CPURISCVState *env = &RISCV_CPU(obj)->env; - set_misa(env, RV32 | RVI | RVM | RVA | RVF | RVD | RVC | RVS | RVU); + set_misa(env, MXL_RV32, RVI | RVM | RVA | RVF | RVD | RVC | RVS | RVU); set_priv_version(env, PRIV_VERSION_1_10_0); } static void rv32_sifive_e_cpu_init(Object *obj) { CPURISCVState *env = &RISCV_CPU(obj)->env; - set_misa(env, RV32 | RVI | RVM | RVA | RVC | RVU); + set_misa(env, MXL_RV32, RVI | RVM | RVA | RVC | RVU); set_priv_version(env, PRIV_VERSION_1_10_0); qdev_prop_set_bit(DEVICE(obj), "mmu", false); } @@ -203,7 +200,7 @@ static void rv32_sifive_e_cpu_init(Object *obj) static void rv32_ibex_cpu_init(Object *obj) { CPURISCVState *env = &RISCV_CPU(obj)->env; - set_misa(env, RV32 | RVI | RVM | RVC | RVU); + set_misa(env, MXL_RV32, RVI | RVM | RVC | RVU); set_priv_version(env, PRIV_VERSION_1_10_0); qdev_prop_set_bit(DEVICE(obj), "mmu", false); qdev_prop_set_bit(DEVICE(obj), "x-epmp", true); @@ -212,7 +209,7 @@ static void rv32_ibex_cpu_init(Object *obj) static void rv32_imafcu_nommu_cpu_init(Object *obj) { CPURISCVState *env = &RISCV_CPU(obj)->env; - set_misa(env, RV32 | RVI | RVM | RVA | RVF | RVC | RVU); + set_misa(env, MXL_RV32, RVI | RVM | RVA | RVF | RVC | RVU); set_priv_version(env, PRIV_VERSION_1_10_0); set_resetvec(env, DEFAULT_RSTVEC); qdev_prop_set_bit(DEVICE(obj), "mmu", false); @@ -360,6 +357,7 @@ static void riscv_cpu_reset(DeviceState *dev) mcc->parent_reset(dev); #ifndef CONFIG_USER_ONLY + env->misa_mxl = env->misa_mxl_max; env->priv = PRV_M; env->mstatus &= ~(MSTATUS_MIE | MSTATUS_MPRV); env->mcause = 0; @@ -388,7 +386,6 @@ static void riscv_cpu_realize(DeviceState *dev, Error **errp) CPURISCVState *env = &cpu->env; RISCVCPUClass *mcc = RISCV_CPU_GET_CLASS(dev); int priv_version = 0; - target_ulong target_misa = env->misa; Error *local_err = NULL; cpu_exec_realizefn(cs, &local_err); @@ -434,8 +431,23 @@ static void riscv_cpu_realize(DeviceState *dev, Error **errp) set_resetvec(env, cpu->cfg.resetvec); - /* If only XLEN is set for misa, then set misa from properties */ - if (env->misa == RV32 || env->misa == RV64) { + /* Validate that MISA_MXL is set properly. */ + switch (env->misa_mxl_max) { +#ifdef TARGET_RISCV64 + case MXL_RV64: + break; +#endif + case MXL_RV32: + break; + default: + g_assert_not_reached(); + } + assert(env->misa_mxl_max == env->misa_mxl); + + /* If only MISA_EXT is unset for misa, then set it from properties */ + if (env->misa_ext == 0) { + uint32_t ext = 0; + /* Do some ISA extension error checking */ if (cpu->cfg.ext_i && cpu->cfg.ext_e) { error_setg(errp, @@ -462,38 +474,38 @@ static void riscv_cpu_realize(DeviceState *dev, Error **errp) /* Set the ISA extensions, checks should have happened above */ if (cpu->cfg.ext_i) { - target_misa |= RVI; + ext |= RVI; } if (cpu->cfg.ext_e) { - target_misa |= RVE; + ext |= RVE; } if (cpu->cfg.ext_m) { - target_misa |= RVM; + ext |= RVM; } if (cpu->cfg.ext_a) { - target_misa |= RVA; + ext |= RVA; } if (cpu->cfg.ext_f) { - target_misa |= RVF; + ext |= RVF; } if (cpu->cfg.ext_d) { - target_misa |= RVD; + ext |= RVD; } if (cpu->cfg.ext_c) { - target_misa |= RVC; + ext |= RVC; } if (cpu->cfg.ext_s) { - target_misa |= RVS; + ext |= RVS; } if (cpu->cfg.ext_u) { - target_misa |= RVU; + ext |= RVU; } if (cpu->cfg.ext_h) { - target_misa |= RVH; + ext |= RVH; } if (cpu->cfg.ext_v) { int vext_version = VEXT_VERSION_0_07_1; - target_misa |= RVV; + ext |= RVV; if (!is_power_of_2(cpu->cfg.vlen)) { error_setg(errp, "Vector extension VLEN must be power of 2"); @@ -532,7 +544,7 @@ static void riscv_cpu_realize(DeviceState *dev, Error **errp) set_vext_version(env, vext_version); } - set_misa(env, target_misa); + set_misa(env, env->misa_mxl, ext); } riscv_cpu_register_gdb_regs_for_features(cs); @@ -708,7 +720,7 @@ char *riscv_isa_string(RISCVCPU *cpu) char *isa_str = g_new(char, maxlen); char *p = isa_str + snprintf(isa_str, maxlen, "rv%d", TARGET_LONG_BITS); for (i = 0; i < sizeof(riscv_exts); i++) { - if (cpu->env.misa & RV(riscv_exts[i])) { + if (cpu->env.misa_ext & RV(riscv_exts[i])) { *p++ = qemu_tolower(riscv_exts[i]); } } diff --git a/target/riscv/csr.c b/target/riscv/csr.c index 23fbbd3216..d0c86a300d 100644 --- a/target/riscv/csr.c +++ b/target/riscv/csr.c @@ -39,7 +39,7 @@ static RISCVException fs(CPURISCVState *env, int csrno) { #if !defined(CONFIG_USER_ONLY) /* loose check condition for fcsr in vector extension */ - if ((csrno == CSR_FCSR) && (env->misa & RVV)) { + if ((csrno == CSR_FCSR) && (env->misa_ext & RVV)) { return RISCV_EXCP_NONE; } if (!env->debugger && !riscv_cpu_fp_enabled(env)) { @@ -51,7 +51,7 @@ static RISCVException fs(CPURISCVState *env, int csrno) static RISCVException vs(CPURISCVState *env, int csrno) { - if (env->misa & RVV) { + if (env->misa_ext & RVV) { return RISCV_EXCP_NONE; } return RISCV_EXCP_ILLEGAL_INST; @@ -557,7 +557,22 @@ static RISCVException write_mstatush(CPURISCVState *env, int csrno, static RISCVException read_misa(CPURISCVState *env, int csrno, target_ulong *val) { - *val = env->misa; + target_ulong misa; + + switch (env->misa_mxl) { + case MXL_RV32: + misa = (target_ulong)MXL_RV32 << 30; + break; +#ifdef TARGET_RISCV64 + case MXL_RV64: + misa = (target_ulong)MXL_RV64 << 62; + break; +#endif + default: + g_assert_not_reached(); + } + + *val = misa | env->misa_ext; return RISCV_EXCP_NONE; } @@ -583,8 +598,13 @@ static RISCVException write_misa(CPURISCVState *env, int csrno, return RISCV_EXCP_NONE; } + /* + * misa.MXL writes are not supported by QEMU. + * Drop writes to those bits. + */ + /* Mask extensions that are not supported by this hart */ - val &= env->misa_mask; + val &= env->misa_ext_mask; /* Mask extensions that are not supported by QEMU */ val &= (RVI | RVE | RVM | RVA | RVF | RVD | RVC | RVS | RVU); @@ -601,20 +621,14 @@ static RISCVException write_misa(CPURISCVState *env, int csrno, val &= ~RVC; } - /* misa.MXL writes are not supported by QEMU */ - if (riscv_cpu_is_32bit(env)) { - val = (env->misa & MISA32_MXL) | (val & ~MISA32_MXL); - } else { - val = (env->misa & MISA64_MXL) | (val & ~MISA64_MXL); + /* If nothing changed, do nothing. */ + if (val == env->misa_ext) { + return RISCV_EXCP_NONE; } /* flush translation cache */ - if (val != env->misa) { - tb_flush(env_cpu(env)); - } - - env->misa = val; - + tb_flush(env_cpu(env)); + env->misa_ext = val; return RISCV_EXCP_NONE; } diff --git a/target/riscv/gdbstub.c b/target/riscv/gdbstub.c index a7a9c0b1fe..5257df0217 100644 --- a/target/riscv/gdbstub.c +++ b/target/riscv/gdbstub.c @@ -54,10 +54,10 @@ int riscv_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n) static int riscv_gdb_get_fpu(CPURISCVState *env, GByteArray *buf, int n) { if (n < 32) { - if (env->misa & RVD) { + if (env->misa_ext & RVD) { return gdb_get_reg64(buf, env->fpr[n]); } - if (env->misa & RVF) { + if (env->misa_ext & RVF) { return gdb_get_reg32(buf, env->fpr[n]); } /* there is hole between ft11 and fflags in fpu.xml */ @@ -191,10 +191,10 @@ void riscv_cpu_register_gdb_regs_for_features(CPUState *cs) { RISCVCPU *cpu = RISCV_CPU(cs); CPURISCVState *env = &cpu->env; - if (env->misa & RVD) { + if (env->misa_ext & RVD) { gdb_register_coprocessor(cs, riscv_gdb_get_fpu, riscv_gdb_set_fpu, 36, "riscv-64bit-fpu.xml", 0); - } else if (env->misa & RVF) { + } else if (env->misa_ext & RVF) { gdb_register_coprocessor(cs, riscv_gdb_get_fpu, riscv_gdb_set_fpu, 36, "riscv-32bit-fpu.xml", 0); } diff --git a/target/riscv/machine.c b/target/riscv/machine.c index 16a08302da..f64b2a96c1 100644 --- a/target/riscv/machine.c +++ b/target/riscv/machine.c @@ -140,8 +140,8 @@ static const VMStateDescription vmstate_hyper = { const VMStateDescription vmstate_riscv_cpu = { .name = "cpu", - .version_id = 2, - .minimum_version_id = 2, + .version_id = 3, + .minimum_version_id = 3, .fields = (VMStateField[]) { VMSTATE_UINTTL_ARRAY(env.gpr, RISCVCPU, 32), VMSTATE_UINT64_ARRAY(env.fpr, RISCVCPU, 32), @@ -153,8 +153,10 @@ const VMStateDescription vmstate_riscv_cpu = { VMSTATE_UINTTL(env.guest_phys_fault_addr, RISCVCPU), VMSTATE_UINTTL(env.priv_ver, RISCVCPU), VMSTATE_UINTTL(env.vext_ver, RISCVCPU), - VMSTATE_UINTTL(env.misa, RISCVCPU), - VMSTATE_UINTTL(env.misa_mask, RISCVCPU), + VMSTATE_UINT32(env.misa_mxl, RISCVCPU), + VMSTATE_UINT32(env.misa_ext, RISCVCPU), + VMSTATE_UINT32(env.misa_mxl_max, RISCVCPU), + VMSTATE_UINT32(env.misa_ext_mask, RISCVCPU), VMSTATE_UINT32(env.features, RISCVCPU), VMSTATE_UINTTL(env.priv, RISCVCPU), VMSTATE_UINTTL(env.virt, RISCVCPU), diff --git a/target/riscv/translate.c b/target/riscv/translate.c index 62214e97fa..0aa2122529 100644 --- a/target/riscv/translate.c +++ b/target/riscv/translate.c @@ -55,7 +55,8 @@ typedef struct DisasContext { /* pc_succ_insn points to the instruction following base.pc_next */ target_ulong pc_succ_insn; target_ulong priv_ver; - target_ulong misa; + RISCVMXL xl; + uint32_t misa_ext; uint32_t opcode; uint32_t mstatus_fs; uint32_t mstatus_hs_fs; @@ -86,7 +87,7 @@ typedef struct DisasContext { static inline bool has_ext(DisasContext *ctx, uint32_t ext) { - return ctx->misa & ext; + return ctx->misa_ext & ext; } #ifdef TARGET_RISCV32 @@ -96,7 +97,7 @@ static inline bool has_ext(DisasContext *ctx, uint32_t ext) #else static inline bool is_32bit(DisasContext *ctx) { - return (ctx->misa & RV32) == RV32; + return ctx->xl == MXL_RV32; } #endif @@ -513,7 +514,8 @@ static void riscv_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs) #else ctx->virt_enabled = false; #endif - ctx->misa = env->misa; + ctx->xl = env->misa_mxl; + ctx->misa_ext = env->misa_ext; ctx->frm = -1; /* unknown rounding mode */ ctx->ext_ifencei = cpu->cfg.ext_ifencei; ctx->vlen = cpu->cfg.vlen; From patchwork Fri Oct 22 13:37:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 1544929 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=wdc.com header.i=@wdc.com header.a=rsa-sha256 header.s=dkim.wdc.com header.b=rLgoPZFy; dkim=pass (2048-bit key; unprotected) header.d=opensource.wdc.com header.i=@opensource.wdc.com header.a=rsa-sha256 header.s=dkim header.b=eH7ySAKW; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4HbQZS4d1vz9sXN for ; Sat, 23 Oct 2021 00:44:48 +1100 (AEDT) Received: from localhost ([::1]:60394 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mduqk-0002LL-E1 for incoming@patchwork.ozlabs.org; Fri, 22 Oct 2021 09:44:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57178) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mdult-0000bu-FF for qemu-devel@nongnu.org; Fri, 22 Oct 2021 09:39:47 -0400 Received: from esa1.hgst.iphmx.com ([68.232.141.245]:33520) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mdulq-0001BK-L4 for qemu-devel@nongnu.org; Fri, 22 Oct 2021 09:39:45 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1634909982; x=1666445982; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ZmBoEQcaBqP9upU6L/cyleplbpuztrg5gek4KZJqoak=; b=rLgoPZFyk5uVf1U0ydl5LqNPKm9TPOJQX22YR6/kd406Ft22SRQGzJxf nXLP7x34odD+i4H2LGvSVbJbxw+kUvAVCXBq5/+F4seK8p6j9eo2W80xa rkAOBd/7gxVWToWRkBf4GBMkOO+cx7Q8Hhk3PAU4LgN3a5dzSfi0fzydw 3qElJ0bicpGdLyR53KdPz3YvUTiV0r8UiB7LQp32b1g/TL5MUQzne01Vf 53Sh5dAzbMhE/vyj1O4QQ6dFOob/QsTpZh+uWRytBord6WCQH7D8lAaq7 9K25YEhO6eQrMLnhMGdi6bhuFVeLGyOYc9d9+bUPb1Rn8/Vx+9WLq6/D4 Q==; X-IronPort-AV: E=Sophos;i="5.87,173,1631548800"; d="scan'208";a="295350957" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 22 Oct 2021 21:39:35 +0800 IronPort-SDR: HldqZRD8werzSJPpTrkKpAn0jLs1o7BKVDN0HoO4O1BuCWU62E+u3tIVP/0dRBcPqHt+OmmBFq 4fovJC6O1TMfINr7h6gl0kWNkY94xHp23B5RGbjNBGUEJXX1yTHGwYCa1gV8vR5PqtlDLWgOJF A8PuR3dLj37wnEJzM2dx7UUL25aK0m0L4wUMHF1rUJ6N+jz3LyNlcAny5Jx+udsXQ+p9hcJS49 Fd0CNbeHBnoBx7GZkLzNS9RxlZJ+Cd6zeNZxUtdVZk1kUSFX597YWF0WgfAcyrZXt+vDVCDwbU HZsyE9CM/EpiutJDBhjARgkd Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Oct 2021 06:15:10 -0700 IronPort-SDR: R0ISrLHYDO46ifk0P9d36EztzjRgKRuVPziQrOAVZgjHcN7yBwK56W14DHxOR4ys4XmAYAyeen a93vIu3oJL4vgTcJkHk+JyaqeRSpL51nKleLnRa/AZLJozyLfARd82jzFggnIr+/j6zdMpqsmi I2qXSN10fAj+uzWtLEBQxTvlEQt+MxW3lsWHRg8E+Ymx8jHS4+h1407jvHfGvYrujOsLINrMb3 YeeplGdlXU6beyxvilTR3xIP31MSGSi54ISTujqypgShWHhzXhiBzIJWn/n8uEutT1ssi3gxTg fZ0= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Oct 2021 06:39:35 -0700 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4HbQSR3GP7z1RtVp for ; Fri, 22 Oct 2021 06:39:35 -0700 (PDT) Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1634909974; x=1637501975; bh=ZmBoEQcaBqP9upU6L/ cyleplbpuztrg5gek4KZJqoak=; b=eH7ySAKWxHT+qux+0k1uM+gfUrLNPvy5V8 cuuKNVQV4NraHXr+LgrQfW/ozPmbbV79lh6iTMNVvHfYUEjrhgF2PduY0eEaYiqT jLFbhaeAxdzzoIipelLvF7N4LLgg+3S4xh0+0lea/0uSUuIAl27m73aBbWw8qR+j Bt1j44SGvH2Wb11/wS1yNqwKF9sCFd4zMtECoRfUIYYtlfakuk7ZpdmtVQrDy96r P7MQUmRY2Qkax51GHCDd7+TKhKIUFwbWSeTPxBOEX8hN7K1yiy7OCF3TmGy/LNDD QvxpBpgTJjkG64bxqgGiFKrPanklSDgvFCFrqyTrsoh1aKtkwL8Q== X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id NEltexWhWTXF for ; Fri, 22 Oct 2021 06:39:34 -0700 (PDT) Received: from toolbox.wdc.com (unknown [10.225.165.39]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4HbQSL2wBGz1RtVl; Fri, 22 Oct 2021 06:39:29 -0700 (PDT) From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Richard Henderson , LIU Zhiwei , Alistair Francis Subject: [PULL 11/33] target/riscv: Replace riscv_cpu_is_32bit with riscv_cpu_mxl Date: Fri, 22 Oct 2021 23:37:50 +1000 Message-Id: <20211022133812.3972903-12-alistair.francis@opensource.wdc.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211022133812.3972903-1-alistair.francis@opensource.wdc.com> References: <20211022133812.3972903-1-alistair.francis@opensource.wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=68.232.141.245; envelope-from=prvs=9222bbd82=alistair.francis@opensource.wdc.com; helo=esa1.hgst.iphmx.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, SPF_HELO_PASS=-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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson Shortly, the set of supported XL will not be just 32 and 64, and representing that properly using the enumeration will be imperative. Two places, booting and gdb, intentionally use misa_mxl_max to emphasize the use of the reset value of misa.mxl, and not the current cpu state. Reviewed-by: LIU Zhiwei Reviewed-by: Alistair Francis Signed-off-by: Richard Henderson Message-id: 20211020031709.359469-5-richard.henderson@linaro.org Signed-off-by: Alistair Francis --- target/riscv/cpu.h | 9 ++++++++- hw/riscv/boot.c | 2 +- semihosting/arm-compat-semi.c | 2 +- target/riscv/cpu.c | 24 ++++++++++++++---------- target/riscv/cpu_helper.c | 12 ++++++------ target/riscv/csr.c | 24 ++++++++++++------------ target/riscv/gdbstub.c | 2 +- target/riscv/monitor.c | 4 ++-- 8 files changed, 45 insertions(+), 34 deletions(-) diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h index 90d11e3c2a..e23157b05c 100644 --- a/target/riscv/cpu.h +++ b/target/riscv/cpu.h @@ -396,7 +396,14 @@ FIELD(TB_FLAGS, VILL, 9, 1) FIELD(TB_FLAGS, HLSX, 10, 1) FIELD(TB_FLAGS, MSTATUS_HS_FS, 11, 2) -bool riscv_cpu_is_32bit(CPURISCVState *env); +#ifdef TARGET_RISCV32 +#define riscv_cpu_mxl(env) ((void)(env), MXL_RV32) +#else +static inline RISCVMXL riscv_cpu_mxl(CPURISCVState *env) +{ + return env->misa_mxl; +} +#endif /* * A simplification for VLMAX diff --git a/hw/riscv/boot.c b/hw/riscv/boot.c index 993bf89064..d1ffc7b56c 100644 --- a/hw/riscv/boot.c +++ b/hw/riscv/boot.c @@ -35,7 +35,7 @@ bool riscv_is_32bit(RISCVHartArrayState *harts) { - return riscv_cpu_is_32bit(&harts->harts[0].env); + return harts->harts[0].env.misa_mxl_max == MXL_RV32; } target_ulong riscv_calc_kernel_start_addr(RISCVHartArrayState *harts, diff --git a/semihosting/arm-compat-semi.c b/semihosting/arm-compat-semi.c index 01badea99c..37963becae 100644 --- a/semihosting/arm-compat-semi.c +++ b/semihosting/arm-compat-semi.c @@ -775,7 +775,7 @@ static inline bool is_64bit_semihosting(CPUArchState *env) #if defined(TARGET_ARM) return is_a64(env); #elif defined(TARGET_RISCV) - return !riscv_cpu_is_32bit(env); + return riscv_cpu_mxl(env) != MXL_RV32; #else #error un-handled architecture #endif diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index f18bb4b21e..3d144af1ab 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -108,11 +108,6 @@ const char *riscv_cpu_get_trap_name(target_ulong cause, bool async) } } -bool riscv_cpu_is_32bit(CPURISCVState *env) -{ - return env->misa_mxl == MXL_RV32; -} - static void set_misa(CPURISCVState *env, RISCVMXL mxl, uint32_t ext) { env->misa_mxl_max = env->misa_mxl = mxl; @@ -249,7 +244,7 @@ static void riscv_cpu_dump_state(CPUState *cs, FILE *f, int flags) #ifndef CONFIG_USER_ONLY qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "mhartid ", env->mhartid); qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "mstatus ", (target_ulong)env->mstatus); - if (riscv_cpu_is_32bit(env)) { + if (riscv_cpu_mxl(env) == MXL_RV32) { qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "mstatush ", (target_ulong)(env->mstatus >> 32)); } @@ -372,10 +367,16 @@ static void riscv_cpu_reset(DeviceState *dev) static void riscv_cpu_disas_set_info(CPUState *s, disassemble_info *info) { RISCVCPU *cpu = RISCV_CPU(s); - if (riscv_cpu_is_32bit(&cpu->env)) { + + switch (riscv_cpu_mxl(&cpu->env)) { + case MXL_RV32: info->print_insn = print_insn_riscv32; - } else { + break; + case MXL_RV64: info->print_insn = print_insn_riscv64; + break; + default: + g_assert_not_reached(); } } @@ -634,10 +635,13 @@ static gchar *riscv_gdb_arch_name(CPUState *cs) RISCVCPU *cpu = RISCV_CPU(cs); CPURISCVState *env = &cpu->env; - if (riscv_cpu_is_32bit(env)) { + switch (riscv_cpu_mxl(env)) { + case MXL_RV32: return g_strdup("riscv:rv32"); - } else { + case MXL_RV64: return g_strdup("riscv:rv64"); + default: + g_assert_not_reached(); } } diff --git a/target/riscv/cpu_helper.c b/target/riscv/cpu_helper.c index 14d1d3cb72..403f54171d 100644 --- a/target/riscv/cpu_helper.c +++ b/target/riscv/cpu_helper.c @@ -152,7 +152,7 @@ bool riscv_cpu_fp_enabled(CPURISCVState *env) void riscv_cpu_swap_hypervisor_regs(CPURISCVState *env) { - uint64_t sd = riscv_cpu_is_32bit(env) ? MSTATUS32_SD : MSTATUS64_SD; + uint64_t sd = riscv_cpu_mxl(env) == MXL_RV32 ? MSTATUS32_SD : MSTATUS64_SD; uint64_t mstatus_mask = MSTATUS_MXR | MSTATUS_SUM | MSTATUS_FS | MSTATUS_SPP | MSTATUS_SPIE | MSTATUS_SIE | MSTATUS64_UXL | sd; @@ -447,7 +447,7 @@ static int get_physical_address(CPURISCVState *env, hwaddr *physical, if (first_stage == true) { if (use_background) { - if (riscv_cpu_is_32bit(env)) { + if (riscv_cpu_mxl(env) == MXL_RV32) { base = (hwaddr)get_field(env->vsatp, SATP32_PPN) << PGSHIFT; vm = get_field(env->vsatp, SATP32_MODE); } else { @@ -455,7 +455,7 @@ static int get_physical_address(CPURISCVState *env, hwaddr *physical, vm = get_field(env->vsatp, SATP64_MODE); } } else { - if (riscv_cpu_is_32bit(env)) { + if (riscv_cpu_mxl(env) == MXL_RV32) { base = (hwaddr)get_field(env->satp, SATP32_PPN) << PGSHIFT; vm = get_field(env->satp, SATP32_MODE); } else { @@ -465,7 +465,7 @@ static int get_physical_address(CPURISCVState *env, hwaddr *physical, } widened = 0; } else { - if (riscv_cpu_is_32bit(env)) { + if (riscv_cpu_mxl(env) == MXL_RV32) { base = (hwaddr)get_field(env->hgatp, SATP32_PPN) << PGSHIFT; vm = get_field(env->hgatp, SATP32_MODE); } else { @@ -558,7 +558,7 @@ restart: } target_ulong pte; - if (riscv_cpu_is_32bit(env)) { + if (riscv_cpu_mxl(env) == MXL_RV32) { pte = address_space_ldl(cs->as, pte_addr, attrs, &res); } else { pte = address_space_ldq(cs->as, pte_addr, attrs, &res); @@ -678,7 +678,7 @@ static void raise_mmu_exception(CPURISCVState *env, target_ulong address, int page_fault_exceptions, vm; uint64_t stap_mode; - if (riscv_cpu_is_32bit(env)) { + if (riscv_cpu_mxl(env) == MXL_RV32) { stap_mode = SATP32_MODE; } else { stap_mode = SATP64_MODE; diff --git a/target/riscv/csr.c b/target/riscv/csr.c index d0c86a300d..9c0753bc8b 100644 --- a/target/riscv/csr.c +++ b/target/riscv/csr.c @@ -95,7 +95,7 @@ static RISCVException ctr(CPURISCVState *env, int csrno) } break; } - if (riscv_cpu_is_32bit(env)) { + if (riscv_cpu_mxl(env) == MXL_RV32) { switch (csrno) { case CSR_CYCLEH: if (!get_field(env->hcounteren, COUNTEREN_CY) && @@ -130,7 +130,7 @@ static RISCVException ctr(CPURISCVState *env, int csrno) static RISCVException ctr32(CPURISCVState *env, int csrno) { - if (!riscv_cpu_is_32bit(env)) { + if (riscv_cpu_mxl(env) != MXL_RV32) { return RISCV_EXCP_ILLEGAL_INST; } @@ -145,7 +145,7 @@ static RISCVException any(CPURISCVState *env, int csrno) static RISCVException any32(CPURISCVState *env, int csrno) { - if (!riscv_cpu_is_32bit(env)) { + if (riscv_cpu_mxl(env) != MXL_RV32) { return RISCV_EXCP_ILLEGAL_INST; } @@ -180,7 +180,7 @@ static RISCVException hmode(CPURISCVState *env, int csrno) static RISCVException hmode32(CPURISCVState *env, int csrno) { - if (!riscv_cpu_is_32bit(env)) { + if (riscv_cpu_mxl(env) != MXL_RV32) { if (riscv_cpu_virt_enabled(env)) { return RISCV_EXCP_ILLEGAL_INST; } else { @@ -486,7 +486,7 @@ static RISCVException read_mstatus(CPURISCVState *env, int csrno, static int validate_vm(CPURISCVState *env, target_ulong vm) { - if (riscv_cpu_is_32bit(env)) { + if (riscv_cpu_mxl(env) == MXL_RV32) { return valid_vm_1_10_32[vm & 0xf]; } else { return valid_vm_1_10_64[vm & 0xf]; @@ -510,7 +510,7 @@ static RISCVException write_mstatus(CPURISCVState *env, int csrno, MSTATUS_MPP | MSTATUS_MXR | MSTATUS_TVM | MSTATUS_TSR | MSTATUS_TW; - if (!riscv_cpu_is_32bit(env)) { + if (riscv_cpu_mxl(env) != MXL_RV32) { /* * RV32: MPV and GVA are not in mstatus. The current plan is to * add them to mstatush. For now, we just don't support it. @@ -522,7 +522,7 @@ static RISCVException write_mstatus(CPURISCVState *env, int csrno, dirty = ((mstatus & MSTATUS_FS) == MSTATUS_FS) | ((mstatus & MSTATUS_XS) == MSTATUS_XS); - if (riscv_cpu_is_32bit(env)) { + if (riscv_cpu_mxl(env) == MXL_RV32) { mstatus = set_field(mstatus, MSTATUS32_SD, dirty); } else { mstatus = set_field(mstatus, MSTATUS64_SD, dirty); @@ -795,7 +795,7 @@ static RISCVException read_sstatus(CPURISCVState *env, int csrno, { target_ulong mask = (sstatus_v1_10_mask); - if (riscv_cpu_is_32bit(env)) { + if (riscv_cpu_mxl(env) == MXL_RV32) { mask |= SSTATUS32_SD; } else { mask |= SSTATUS64_SD; @@ -1006,7 +1006,7 @@ static RISCVException write_satp(CPURISCVState *env, int csrno, return RISCV_EXCP_NONE; } - if (riscv_cpu_is_32bit(env)) { + if (riscv_cpu_mxl(env) == MXL_RV32) { vm = validate_vm(env, get_field(val, SATP32_MODE)); mask = (val ^ env->satp) & (SATP32_MODE | SATP32_ASID | SATP32_PPN); asid = (val ^ env->satp) & SATP32_ASID; @@ -1034,7 +1034,7 @@ static RISCVException read_hstatus(CPURISCVState *env, int csrno, target_ulong *val) { *val = env->hstatus; - if (!riscv_cpu_is_32bit(env)) { + if (riscv_cpu_mxl(env) != MXL_RV32) { /* We only support 64-bit VSXL */ *val = set_field(*val, HSTATUS_VSXL, 2); } @@ -1047,7 +1047,7 @@ static RISCVException write_hstatus(CPURISCVState *env, int csrno, target_ulong val) { env->hstatus = val; - if (!riscv_cpu_is_32bit(env) && get_field(val, HSTATUS_VSXL) != 2) { + if (riscv_cpu_mxl(env) != MXL_RV32 && get_field(val, HSTATUS_VSXL) != 2) { qemu_log_mask(LOG_UNIMP, "QEMU does not support mixed HSXLEN options."); } if (get_field(val, HSTATUS_VSBE) != 0) { @@ -1215,7 +1215,7 @@ static RISCVException write_htimedelta(CPURISCVState *env, int csrno, return RISCV_EXCP_ILLEGAL_INST; } - if (riscv_cpu_is_32bit(env)) { + if (riscv_cpu_mxl(env) == MXL_RV32) { env->htimedelta = deposit64(env->htimedelta, 0, 32, (uint64_t)val); } else { env->htimedelta = val; diff --git a/target/riscv/gdbstub.c b/target/riscv/gdbstub.c index 5257df0217..23429179e2 100644 --- a/target/riscv/gdbstub.c +++ b/target/riscv/gdbstub.c @@ -161,7 +161,7 @@ static int riscv_gen_dynamic_csr_xml(CPUState *cs, int base_reg) CPURISCVState *env = &cpu->env; GString *s = g_string_new(NULL); riscv_csr_predicate_fn predicate; - int bitsize = riscv_cpu_is_32bit(env) ? 32 : 64; + int bitsize = 16 << env->misa_mxl_max; int i; g_string_printf(s, ""); diff --git a/target/riscv/monitor.c b/target/riscv/monitor.c index f7e6ea72b3..7efb4b62c1 100644 --- a/target/riscv/monitor.c +++ b/target/riscv/monitor.c @@ -150,7 +150,7 @@ static void mem_info_svxx(Monitor *mon, CPUArchState *env) target_ulong last_size; int last_attr; - if (riscv_cpu_is_32bit(env)) { + if (riscv_cpu_mxl(env) == MXL_RV32) { base = (hwaddr)get_field(env->satp, SATP32_PPN) << PGSHIFT; vm = get_field(env->satp, SATP32_MODE); } else { @@ -220,7 +220,7 @@ void hmp_info_mem(Monitor *mon, const QDict *qdict) return; } - if (riscv_cpu_is_32bit(env)) { + if (riscv_cpu_mxl(env) == MXL_RV32) { if (!(env->satp & SATP32_MODE)) { monitor_printf(mon, "No translation or protection\n"); return; From patchwork Fri Oct 22 13:37:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 1544924 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=wdc.com header.i=@wdc.com header.a=rsa-sha256 header.s=dkim.wdc.com header.b=THqtcj3O; dkim=pass (2048-bit key; unprotected) header.d=opensource.wdc.com header.i=@opensource.wdc.com header.a=rsa-sha256 header.s=dkim header.b=uQCzIyWJ; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4HbQWs61LKz9sRN for ; Sat, 23 Oct 2021 00:42:33 +1100 (AEDT) Received: from localhost ([::1]:51778 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mduoZ-00050R-J8 for incoming@patchwork.ozlabs.org; Fri, 22 Oct 2021 09:42:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57174) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mdult-0000bT-96 for qemu-devel@nongnu.org; Fri, 22 Oct 2021 09:39:45 -0400 Received: from esa5.hgst.iphmx.com ([216.71.153.144]:39644) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mdulq-0001BC-9f for qemu-devel@nongnu.org; Fri, 22 Oct 2021 09:39:45 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1634909981; x=1666445981; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=HPH4y0KADeR+UCUJfkmTvGU2wlH4unltnWuH24SuZPw=; b=THqtcj3Og3y3G+XhdnVVEDcBHffNLdgzsce6VEcvXVVFVvx+gwjoA+aB CMIILd6SzKa6teq+0JKCr/YZvE7iHOqjJ94ByyeHB3tk+llvWVKvtUteT WytZSvMHBG0PiQetfTDpawO3wR7Ma7lxv/J94gtE8S8UeKT5HoYVqACIx +1zynY52YP50m7wwx/mgl7cmJ9cFR0HMWLGmgmgjoRghz9jVWo0g7e/r6 CddviP4MoEJf7M36Dl6YWHh7EwToeJQJoJjXjKXhPixUzJHXNpL7dSvIE hXTTLNDF2rthFShfc7OXsYOoQlZLDyQc/BXD25t5hxjti99QNjufN/p8E w==; X-IronPort-AV: E=Sophos;i="5.87,172,1631548800"; d="scan'208";a="183617847" Received: from h199-255-45-14.hgst.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 22 Oct 2021 21:39:39 +0800 IronPort-SDR: Aoqd10DiDdzVJF/ARYEFqRirOwNj6iRbmfIYCVG/D+ulbaKsIbQNAPZvOav28WlPUd7+9p2/Ca kpgDsjSvms/+i3ACZvVDBaIxrOLqKakZS6vTUZVA/mUpvvVBunVBrcVJw7uOOqBSp1tVQ1ZXtA IQ6cNY0JEnNCmfWYRdpW4IfVRveRClmz7dZgQCsM23HUyg9FNbh3tRDgwroa3YN6CGosrqSi5o rplpCHCvPjMGeIBx3CONxAmfZNY2YzlqvwrWkhR5bzAdYfbn25vMLenAe++i0Ho2fzZsnAA4ZW yuy2PRmpbe7EQF46EjmL6R+X Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Oct 2021 06:15:15 -0700 IronPort-SDR: 2O/DpZX0cdp/59uiyTyYAwr1xhpVzNCpd7OqJIfg/Fz0sggoxIXvEFVeSvDcQn+yPZOdGgfvh/ S+NJNMruINtEWtEbg1l6olnxn5yaJ/N8GtSON5ItKF+7FNlxVXBk8viN79EXBHXXhaJHkfb/tS CdwrT39rm4cldmwLJCxoUIjyZevBxLDR503uomrGSVQEHpcslANs1dw6qgzdRtPweICkKbdD4/ 1Z4RdT4j7/sfef0e/eFUW/j6ssjqEUMyfNLtOfc784xXxYa2IIe/glf4x9jNvwaJ63/XuR1pIJ Yv8= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Oct 2021 06:39:40 -0700 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4HbQSX1Bhkz1RtVm for ; Fri, 22 Oct 2021 06:39:40 -0700 (PDT) Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1634909979; x=1637501980; bh=HPH4y0KADeR+UCUJfk mTvGU2wlH4unltnWuH24SuZPw=; b=uQCzIyWJXU3lRIKiL0HUJar+FQG+UAdYG9 EjOhkbm/kBUWx5AqfDsW4aZf23+lH09goMrx6dPuU35YvlcDJSl89puKZif9q/gC GVOHkFm/aI4176Run/4L9cxwZ2xhGH6VS9Jzm4It2v+rb0T4tVPF4L4QtesT68MU FEI31ievqtubuS9p7nE1sqmrq1dF2x5zRGeAwQGrqFZQNUmpUs3yXKbudPfy3cOR 3hqlV571Zvo317w+BE6Pw3OllbWe0Nc0sDTc06EzWy5pKH/ZE8bNuaYe5MpY62w1 8X0nwQbdqOfA+0Achd2DwUTFCo46pvz8uDWYunpdw9uYzYyOBZow== X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id 3-Wenk9Q1952 for ; Fri, 22 Oct 2021 06:39:39 -0700 (PDT) Received: from toolbox.wdc.com (unknown [10.225.165.39]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4HbQSR59jpz1RtVl; Fri, 22 Oct 2021 06:39:35 -0700 (PDT) From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Richard Henderson , LIU Zhiwei , Alistair Francis Subject: [PULL 12/33] target/riscv: Add MXL/SXL/UXL to TB_FLAGS Date: Fri, 22 Oct 2021 23:37:51 +1000 Message-Id: <20211022133812.3972903-13-alistair.francis@opensource.wdc.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211022133812.3972903-1-alistair.francis@opensource.wdc.com> References: <20211022133812.3972903-1-alistair.francis@opensource.wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=216.71.153.144; envelope-from=prvs=9222bbd82=alistair.francis@opensource.wdc.com; helo=esa5.hgst.iphmx.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, SPF_HELO_PASS=-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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson Begin adding support for switching XLEN at runtime. Extract the effective XLEN from MISA and MSTATUS and store for use during translation. Reviewed-by: LIU Zhiwei Reviewed-by: Alistair Francis Signed-off-by: Richard Henderson Message-id: 20211020031709.359469-6-richard.henderson@linaro.org Signed-off-by: Alistair Francis --- target/riscv/cpu.h | 2 ++ target/riscv/cpu.c | 8 ++++++++ target/riscv/cpu_helper.c | 33 +++++++++++++++++++++++++++++++++ target/riscv/csr.c | 3 +++ target/riscv/translate.c | 2 +- 5 files changed, 47 insertions(+), 1 deletion(-) diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h index e23157b05c..a33dc30be8 100644 --- a/target/riscv/cpu.h +++ b/target/riscv/cpu.h @@ -395,6 +395,8 @@ FIELD(TB_FLAGS, VILL, 9, 1) /* Is a Hypervisor instruction load/store allowed? */ FIELD(TB_FLAGS, HLSX, 10, 1) FIELD(TB_FLAGS, MSTATUS_HS_FS, 11, 2) +/* The combination of MXL/SXL/UXL that applies to the current cpu mode. */ +FIELD(TB_FLAGS, XL, 13, 2) #ifdef TARGET_RISCV32 #define riscv_cpu_mxl(env) ((void)(env), MXL_RV32) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 3d144af1ab..dd9eccd68e 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -355,6 +355,14 @@ static void riscv_cpu_reset(DeviceState *dev) env->misa_mxl = env->misa_mxl_max; env->priv = PRV_M; env->mstatus &= ~(MSTATUS_MIE | MSTATUS_MPRV); + if (env->misa_mxl > MXL_RV32) { + /* + * The reset status of SXL/UXL is undefined, but mstatus is WARL + * and we must ensure that the value after init is valid for read. + */ + env->mstatus = set_field(env->mstatus, MSTATUS64_SXL, env->misa_mxl); + env->mstatus = set_field(env->mstatus, MSTATUS64_UXL, env->misa_mxl); + } env->mcause = 0; env->pc = env->resetvec; env->two_stage_lookup = false; diff --git a/target/riscv/cpu_helper.c b/target/riscv/cpu_helper.c index 403f54171d..429afd1f48 100644 --- a/target/riscv/cpu_helper.c +++ b/target/riscv/cpu_helper.c @@ -35,6 +35,37 @@ int riscv_cpu_mmu_index(CPURISCVState *env, bool ifetch) #endif } +static RISCVMXL cpu_get_xl(CPURISCVState *env) +{ +#if defined(TARGET_RISCV32) + return MXL_RV32; +#elif defined(CONFIG_USER_ONLY) + return MXL_RV64; +#else + RISCVMXL xl = riscv_cpu_mxl(env); + + /* + * When emulating a 32-bit-only cpu, use RV32. + * When emulating a 64-bit cpu, and MXL has been reduced to RV32, + * MSTATUSH doesn't have UXL/SXL, therefore XLEN cannot be widened + * back to RV64 for lower privs. + */ + if (xl != MXL_RV32) { + switch (env->priv) { + case PRV_M: + break; + case PRV_U: + xl = get_field(env->mstatus, MSTATUS64_UXL); + break; + default: /* PRV_S | PRV_H */ + xl = get_field(env->mstatus, MSTATUS64_SXL); + break; + } + } + return xl; +#endif +} + void cpu_get_tb_cpu_state(CPURISCVState *env, target_ulong *pc, target_ulong *cs_base, uint32_t *pflags) { @@ -78,6 +109,8 @@ void cpu_get_tb_cpu_state(CPURISCVState *env, target_ulong *pc, } #endif + flags = FIELD_DP32(flags, TB_FLAGS, XL, cpu_get_xl(env)); + *pflags = flags; } diff --git a/target/riscv/csr.c b/target/riscv/csr.c index 9c0753bc8b..c4a479ddd2 100644 --- a/target/riscv/csr.c +++ b/target/riscv/csr.c @@ -526,6 +526,9 @@ static RISCVException write_mstatus(CPURISCVState *env, int csrno, mstatus = set_field(mstatus, MSTATUS32_SD, dirty); } else { mstatus = set_field(mstatus, MSTATUS64_SD, dirty); + /* SXL and UXL fields are for now read only */ + mstatus = set_field(mstatus, MSTATUS64_SXL, MXL_RV64); + mstatus = set_field(mstatus, MSTATUS64_UXL, MXL_RV64); } env->mstatus = mstatus; diff --git a/target/riscv/translate.c b/target/riscv/translate.c index 0aa2122529..77cad9bc45 100644 --- a/target/riscv/translate.c +++ b/target/riscv/translate.c @@ -514,7 +514,6 @@ static void riscv_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs) #else ctx->virt_enabled = false; #endif - ctx->xl = env->misa_mxl; ctx->misa_ext = env->misa_ext; ctx->frm = -1; /* unknown rounding mode */ ctx->ext_ifencei = cpu->cfg.ext_ifencei; @@ -526,6 +525,7 @@ static void riscv_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs) ctx->lmul = FIELD_EX32(tb_flags, TB_FLAGS, LMUL); ctx->mlen = 1 << (ctx->sew + 3 - ctx->lmul); ctx->vl_eq_vlmax = FIELD_EX32(tb_flags, TB_FLAGS, VL_EQ_VLMAX); + ctx->xl = FIELD_EX32(tb_flags, TB_FLAGS, XL); ctx->cs = cs; ctx->w = false; ctx->ntemp = 0; From patchwork Fri Oct 22 13:37:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 1544930 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=wdc.com header.i=@wdc.com header.a=rsa-sha256 header.s=dkim.wdc.com header.b=IxDL0TOo; dkim=pass (2048-bit key; unprotected) header.d=opensource.wdc.com header.i=@opensource.wdc.com header.a=rsa-sha256 header.s=dkim header.b=TKwtD/FM; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4HbQZW5bBMz9sRN for ; Sat, 23 Oct 2021 00:44:51 +1100 (AEDT) Received: from localhost ([::1]:60850 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mduqn-0002dr-It for incoming@patchwork.ozlabs.org; Fri, 22 Oct 2021 09:44:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57284) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mdum2-0000hz-Nr for qemu-devel@nongnu.org; Fri, 22 Oct 2021 09:39:55 -0400 Received: from esa5.hgst.iphmx.com ([216.71.153.144]:39644) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mdulu-0001BC-M3 for qemu-devel@nongnu.org; Fri, 22 Oct 2021 09:39:54 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1634909985; x=1666445985; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=gsNRy12OxPmsaBEkJDWQD9vc2OEoJ0pt5OX5v6VjZ8Y=; b=IxDL0TOofQWQcg5/FON5FNGXbtFMe2t30EnrzqqFcYZZJMnsRQ09zZE4 LoURHDlRBRTURFMmxYRo2QN2zemUcZi6C3K2d119PfCYpFn9OXnSUDbjv 6DO5miUS03VwHiRhws0mJp46X+SUCpZxProDl58PcP4SyaGd16pHpOI/w y7cCygE6Eoi7KELgwoVDzZVPCF2qXAIpH3U/zz33TexFbYaBxzAOwZD5L dRUdjBVhs1j2VPxld8ivQnJrABPcPQuQjhD/dUVSNbIHImbofApeGoY5Z yNKcR8Bm//x4mhPg70VcRBUvygzhC+GwfCavbiZzILdA0iBMa4Ak1VTWW g==; X-IronPort-AV: E=Sophos;i="5.87,172,1631548800"; d="scan'208";a="183617854" Received: from h199-255-45-14.hgst.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 22 Oct 2021 21:39:44 +0800 IronPort-SDR: 4GE891NVBN5ySSQfxDkBFD3kNZNz+sl+kGPXT17qACPgAwKHXzbd8vnZXB2ZQ6W5ezTIjk70ZB ku1PEdiHiH7o5BLLxgutEDdV0pYGlXfDqNwO+/nCIWRguI+ZB2CODbsIEx6N8N89fOQztOkRM6 5bw5eiXPIGHwwNnXCb2QjLy8hlZMWI5hLSCYtTnANUopUieKK6P0D5vo6blNLzABCINoVa+MST 1BhyBVbqwYBotwqpx2uRKKh9zH6XRvlRmNWl3o4V3cStap6IP5W22Lhoi3dist7CVmJZ0gww6F tWVEYje2qx1Es3TMy5SHcIUz Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Oct 2021 06:15:20 -0700 IronPort-SDR: BdCWWWkoJ4jaDspi3k1q8b1xznZ6IA07aHKsiG2UDikeT/EMvtuY6/TF5aLoIIEODmh7pvR8Hy FNbgEAYavU9gqEljsyQwlr92XUD/qsUvP6eBqr6Luouxlhq4v0YHDIt4o9a3xlJsUNXWujmXSx ffFLwlJb4Ur3VaTh4ktZbVUNFmyQ0BZX4MuYYSHBy4+0zQtFDrYMtKJoSsvpiizv4lN1I7AcP8 R2NhqudZc2yRpVSwEr/kl0g1kAhpQXPqdWZVCslG3xU0FEZJt6jG/jUcyzjVd+ocP2u8Cx9W5d Ivo= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Oct 2021 06:39:45 -0700 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4HbQSd1kkwz1RtVv for ; Fri, 22 Oct 2021 06:39:45 -0700 (PDT) Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1634909984; x=1637501985; bh=gsNRy12OxPmsaBEkJD WQD9vc2OEoJ0pt5OX5v6VjZ8Y=; b=TKwtD/FMcxI8pUZy15vy6ymlHcqhvXCNgk BKylbjnOangCv0l+j7G2dVFhQypd7Uu/w9AlWhecY9HpGAVLUFU4ku66j035TQZ9 KT3oovKnhXF3n76BH4VsaXe+WN5972L5WEDHTFZXdJxugcQ+RLUuVybr9wDWNbpC fvnyvXtSnGOpbZNwVVmGqrXyj/qvQcMZg7XzkrICVL26ZYirH6Sb8d7waafQAcCQ bYdlZAoCv6svFzodLIpReMKWUu80I9DFYQ+L05ldmtSiZNGg695pivVq5dOvipQV C0XHA8Au373DtHKbRqEbNtCjAOJuXIDW5emUrHvat4K8LfyfHaMQ== X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id UfB6Kr-wjBxp for ; Fri, 22 Oct 2021 06:39:44 -0700 (PDT) Received: from toolbox.wdc.com (unknown [10.225.165.39]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4HbQSX62zbz1RtVl; Fri, 22 Oct 2021 06:39:40 -0700 (PDT) From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Richard Henderson , LIU Zhiwei , Alistair Francis Subject: [PULL 13/33] target/riscv: Use REQUIRE_64BIT in amo_check64 Date: Fri, 22 Oct 2021 23:37:52 +1000 Message-Id: <20211022133812.3972903-14-alistair.francis@opensource.wdc.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211022133812.3972903-1-alistair.francis@opensource.wdc.com> References: <20211022133812.3972903-1-alistair.francis@opensource.wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=216.71.153.144; envelope-from=prvs=9222bbd82=alistair.francis@opensource.wdc.com; helo=esa5.hgst.iphmx.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, SPF_HELO_PASS=-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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson Use the same REQUIRE_64BIT check that we use elsewhere, rather than open-coding the use of is_32bit. Reviewed-by: LIU Zhiwei Reviewed-by: Alistair Francis Signed-off-by: Richard Henderson Message-id: 20211020031709.359469-7-richard.henderson@linaro.org Signed-off-by: Alistair Francis --- target/riscv/insn_trans/trans_rvv.c.inc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/target/riscv/insn_trans/trans_rvv.c.inc b/target/riscv/insn_trans/trans_rvv.c.inc index 45be491ed4..233131bae1 100644 --- a/target/riscv/insn_trans/trans_rvv.c.inc +++ b/target/riscv/insn_trans/trans_rvv.c.inc @@ -743,7 +743,8 @@ static bool amo_check(DisasContext *s, arg_rwdvm* a) static bool amo_check64(DisasContext *s, arg_rwdvm* a) { - return !is_32bit(s) && amo_check(s, a); + REQUIRE_64BIT(s); + return amo_check(s, a); } GEN_VEXT_TRANS(vamoswapw_v, 0, rwdvm, amo_op, amo_check) From patchwork Fri Oct 22 13:37:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 1544941 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=wdc.com header.i=@wdc.com header.a=rsa-sha256 header.s=dkim.wdc.com header.b=WkkIV5rU; dkim=pass (2048-bit key; unprotected) header.d=opensource.wdc.com header.i=@opensource.wdc.com header.a=rsa-sha256 header.s=dkim header.b=rFM3rcm6; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4HbQgV1WWSz9sRN for ; Sat, 23 Oct 2021 00:49:10 +1100 (AEDT) Received: from localhost ([::1]:43856 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mduux-0001kL-VS for incoming@patchwork.ozlabs.org; Fri, 22 Oct 2021 09:49:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57280) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mdum2-0000ht-5f for qemu-devel@nongnu.org; Fri, 22 Oct 2021 09:39:55 -0400 Received: from esa4.hgst.iphmx.com ([216.71.154.42]:64459) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mdum0-0001F7-11 for qemu-devel@nongnu.org; Fri, 22 Oct 2021 09:39:53 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1634909991; x=1666445991; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=rzduVeyxrhftLxj7Bxhixy7X2Ux7Xte9hpgfqqHpb84=; b=WkkIV5rUvpEP0KlcgPe7FvgUcj/c2YUPTmNmuCia2xougjZepzrBDq1t 6kvl5J+PnMZ59Bar7/grNzwtj/Egg/0qAUhT6JBHrUKgXrEvTBT3iJhNi QGd4BpI8yLGp4F+6FRCfakP/eP9nkC9qOXIEps1m3a9nVnLiSf9OeLPOX guOiT8+/fST5Pfmj1uTL/s57fqOIysGKUX/Lo0ve4wamEWjyI92buNYEN 35WAddEv3Mo1asQnO0MVu3xe1H1THlvwfPunmG1LzWKTNAOqx+hU83NGW bGzfrUUjUN7ZrJqU024hjGJqJh3ZGNF+65LLJmbND1QW4ljhXmfmPJZQz w==; X-IronPort-AV: E=Sophos;i="5.87,172,1631548800"; d="scan'208";a="182632611" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 22 Oct 2021 21:39:50 +0800 IronPort-SDR: shulwBmTF0B7nO/1ZmUwxq8yjFdiAxXFBi3LiASEBVEH2OQoSRcSleiRNXP7g8Ay9xD9uXCEdA aa9Fs0VH8dlibG3bQ0GqmsfnxeyD97pPXz8w51RijdYqkswYaHMtMjkW8qSSZG0Ohsv0X9y3Cr vOK9VPVzQOGXUy+A07KUdHvxYeOLHdcwkeRkFWVz6IK6JJmgByrI4t5FVyp9Qb3lwvP5EBysKQ g2ypJICZVRokiUyLNuawkitr+o65nxg7025hEVmQRuZtM/EfzG9DnBYsHf2CWwLu5Kma4zU20N 6YJa9v0bGvkqRH4dSG+2nnTl Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Oct 2021 06:13:52 -0700 IronPort-SDR: 0kndYi0gUD4FyaKKPH0++EbMU875lsoqdUb3pPqSQXqCBn03+32/XmiVw3w9xRxLNt/i6fROVn +4Gh3EaKWLljTcEK+vFFCP4GGsvw65SEc1Z1DxSkXGXeKL9aFej2eFONLOhSvdcx2x20LNOZZT eb2ZdBds2EdXtwlLVCPbHp337cVjcpEIXyCuO2kEdmQ37HaEVuJVB1+rib1DjrKEC+rDGvf2iH 91BuGQkEsoc8V/XgDbRQFUTmbtHWjysVjbP4lVJzEssRcunCbswMcUK2jOyrgldmbW+uDropgv MqI= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Oct 2021 06:39:51 -0700 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4HbQSk4Hfjz1RtVv for ; Fri, 22 Oct 2021 06:39:50 -0700 (PDT) Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1634909990; x=1637501991; bh=rzduVeyxrhftLxj7Bx hixy7X2Ux7Xte9hpgfqqHpb84=; b=rFM3rcm65t922PYV0+SO4FAcR+50Wt3CEf +kt6hkrT9mev/dVTfCNgIIJnr1XZ4xBiMWzc9WUder2E0jSxvOrAVNzXJoKLjuba eNNMqgUKfnw0K3YtoguYRMdwX1eV5ORkAEKscyYnqEKI8HfmKQdG3Wqk8RVkrJnJ wymRst+wDRRvlyHzc9l7sWzgr4TbhXEJX7G5xMokA1Jv6UfvVWDEeH9mB2bNQNBT OCo+F2S6PIEOnh7X/X80enJt6NDD+6NfRkmsHQqEhF6crQuUq16lqaIxuzGqVQur Ue+t4Lo8bIAXxbwulQLey6+eOZ0bYfHHkiFO1oKVh+foir1fhvZw== X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id Vb4mHW0atVLl for ; Fri, 22 Oct 2021 06:39:50 -0700 (PDT) Received: from toolbox.wdc.com (unknown [10.225.165.39]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4HbQSf0VGbz1RtVl; Fri, 22 Oct 2021 06:39:45 -0700 (PDT) From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Richard Henderson , LIU Zhiwei , Alistair Francis Subject: [PULL 14/33] target/riscv: Properly check SEW in amo_op Date: Fri, 22 Oct 2021 23:37:53 +1000 Message-Id: <20211022133812.3972903-15-alistair.francis@opensource.wdc.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211022133812.3972903-1-alistair.francis@opensource.wdc.com> References: <20211022133812.3972903-1-alistair.francis@opensource.wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=216.71.154.42; envelope-from=prvs=9222bbd82=alistair.francis@opensource.wdc.com; helo=esa4.hgst.iphmx.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, SPF_HELO_PASS=-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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson We're currently assuming SEW <= 3, and the "else" from the SEW == 3 must be less. Use a switch and explicitly bound both SEW and SEQ for all cases. Reviewed-by: LIU Zhiwei Reviewed-by: Alistair Francis Signed-off-by: Richard Henderson Message-id: 20211020031709.359469-8-richard.henderson@linaro.org Signed-off-by: Alistair Francis --- target/riscv/insn_trans/trans_rvv.c.inc | 26 +++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/target/riscv/insn_trans/trans_rvv.c.inc b/target/riscv/insn_trans/trans_rvv.c.inc index 233131bae1..17ee3babef 100644 --- a/target/riscv/insn_trans/trans_rvv.c.inc +++ b/target/riscv/insn_trans/trans_rvv.c.inc @@ -704,18 +704,20 @@ static bool amo_op(DisasContext *s, arg_rwdvm *a, uint8_t seq) gen_helper_exit_atomic(cpu_env); s->base.is_jmp = DISAS_NORETURN; return true; - } else { - if (s->sew == 3) { - if (!is_32bit(s)) { - fn = fnsd[seq]; - } else { - /* Check done in amo_check(). */ - g_assert_not_reached(); - } - } else { - assert(seq < ARRAY_SIZE(fnsw)); - fn = fnsw[seq]; - } + } + + switch (s->sew) { + case 0 ... 2: + assert(seq < ARRAY_SIZE(fnsw)); + fn = fnsw[seq]; + break; + case 3: + /* XLEN check done in amo_check(). */ + assert(seq < ARRAY_SIZE(fnsd)); + fn = fnsd[seq]; + break; + default: + g_assert_not_reached(); } data = FIELD_DP32(data, VDATA, MLEN, s->mlen); From patchwork Fri Oct 22 13:37:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 1544948 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=wdc.com header.i=@wdc.com header.a=rsa-sha256 header.s=dkim.wdc.com header.b=hyB8KPVd; dkim=pass (2048-bit key; unprotected) header.d=opensource.wdc.com header.i=@opensource.wdc.com header.a=rsa-sha256 header.s=dkim header.b=oXHwcdJ/; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4HbQhn4bDqz9sRN for ; Sat, 23 Oct 2021 00:50:16 +1100 (AEDT) Received: from localhost ([::1]:48864 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mduw0-00051v-Sn for incoming@patchwork.ozlabs.org; Fri, 22 Oct 2021 09:50:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57312) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mdum8-0000tx-5G for qemu-devel@nongnu.org; Fri, 22 Oct 2021 09:40:00 -0400 Received: from esa2.hgst.iphmx.com ([68.232.143.124]:13324) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mdum5-0001H7-Mw for qemu-devel@nongnu.org; Fri, 22 Oct 2021 09:39:59 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1634909997; x=1666445997; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=2QOUfuXhwj9dDf+TI04dXQNMSlWjVmPOclj4YlckYTk=; b=hyB8KPVd/oLF8q70FYF+U8xy2DwGks43wncYMmu7YM/jBmVP1WskRD49 MKkabCcsiCUFvNCATL1L2MZmCPHb7TsgdqCumm7W41mwpwihNCaVG/kuX uaEK2lFP8oFC1ek8q3ksK4EfLGoT4ZCBrC3hGaEq8cxRM7hYeRFesf8W9 KKe0XYFge5pnSn0F8O17RkKEeHvKr2dywmbLus7bhrEOYUE4vAQYo+AQn UiIhD289Ok/TvmmWrmnm4ArjZA4yPYy87vzZ/+s2QTqV7caaHCmxMWymf TBotUGKbnLYYso6L1Rrgct2anh2c1txQGHij2Ck3FJ3cuclrTzc1x5foL g==; X-IronPort-AV: E=Sophos;i="5.87,172,1631548800"; d="scan'208";a="287492716" Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 22 Oct 2021 21:39:55 +0800 IronPort-SDR: Lai/Ti3VfK3RNKdrViH2dJDkF6ZQzerZyNzBpC6M1JKRLbC5x8WGF+JhSXk5BDERdyq61GmAbR fCvk9y/ASX/24BLDSfVqifsCDvxYaGifyuWCw298Vior0WKneqzvCydAsyjqanTxH10LbYiAND uSd2tLEocUIhSMpScHhvLe49dLeocwTwfp/XEvCFkaG0DM+iLYyf1ueCjgYF69cDGfT8+h4azh r1qEOLhBV1a6eujYYJHYJ2Mr9DBXybOiCwkNqIfAeev8RkcuRAEPZzb4fJ6yqelj/Y7eJRu2Ai LhzpSDS5BGIhTvRslyKcvTYX Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Oct 2021 06:13:58 -0700 IronPort-SDR: yjo3QRUlJyNoMzCoRRZIDY1ZWKzLALihLfJYEJ368zKVJGWIM28ghdjGdy1/QEyqhxqO0o/kCs PBnq4mLM0hFbUUX2l7Vfy/p2jcsjckEayBRyb7k3NSrQAwpy6Mg8E1Ky0UL3o9B2duXBjA3oa6 r8sX979uNfv/BFXorC7xSxyIiOPebtO23dFbOyxjct9zADeivKBouiumqcLf+OozZKtz1U+fug TcqzmpU82+vKpqgEQNXaUjmdpxpMclCjxj2gRNcYQ8keKoV1kePAJbrmkGKYjQWfikPIzOZSJB pgk= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Oct 2021 06:39:56 -0700 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4HbQSq4rTTz1RtVm for ; Fri, 22 Oct 2021 06:39:55 -0700 (PDT) Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1634909995; x=1637501996; bh=2QOUfuXhwj9dDf+TI0 4dXQNMSlWjVmPOclj4YlckYTk=; b=oXHwcdJ/bo2ea9k7MWew9wQrYc2aNkWuyO ElR0QRh/Mox/Bd6JxiwJy8uNOh7ZOoplXDi7+pZLTcjRCm6KF3ysoaZWnjA3VmbC ZJWeMGG6uuuxewkT5QQmuSsuhva3+ArQ1vIkSo2c2TTg41eYIiQxOvPwoCTryGoT KioGow0SHrOh2B47FpWxNybGLgoRqsCSsMXdlbojJUDTa1bRRzvKTMU8RRukAFtn 9lbRAk8be5+vKlp2zMCwSBjhPfdhL8cKvb0930GzVXPkOqDlIB7iWHWOgDaFrvAf vzuD9BzwD0vc7Kl+gLXeoLp7OuMXm2WuKDWCbZzgIEQwpxm1hukw== X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id 7jYQH1NzrK-R for ; Fri, 22 Oct 2021 06:39:55 -0700 (PDT) Received: from toolbox.wdc.com (unknown [10.225.165.39]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4HbQSl1xDMz1RtVl; Fri, 22 Oct 2021 06:39:50 -0700 (PDT) From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Richard Henderson , LIU Zhiwei , Alistair Francis Subject: [PULL 15/33] target/riscv: Replace is_32bit with get_xl/get_xlen Date: Fri, 22 Oct 2021 23:37:54 +1000 Message-Id: <20211022133812.3972903-16-alistair.francis@opensource.wdc.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211022133812.3972903-1-alistair.francis@opensource.wdc.com> References: <20211022133812.3972903-1-alistair.francis@opensource.wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=68.232.143.124; envelope-from=prvs=9222bbd82=alistair.francis@opensource.wdc.com; helo=esa2.hgst.iphmx.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, SPF_HELO_PASS=-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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson In preparation for RV128, replace a simple predicate with a more versatile test. Reviewed-by: LIU Zhiwei Reviewed-by: Alistair Francis Signed-off-by: Richard Henderson Message-id: 20211020031709.359469-9-richard.henderson@linaro.org Signed-off-by: Alistair Francis --- target/riscv/translate.c | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/target/riscv/translate.c b/target/riscv/translate.c index 77cad9bc45..d0ba54091e 100644 --- a/target/riscv/translate.c +++ b/target/riscv/translate.c @@ -91,15 +91,18 @@ static inline bool has_ext(DisasContext *ctx, uint32_t ext) } #ifdef TARGET_RISCV32 -# define is_32bit(ctx) true +#define get_xl(ctx) MXL_RV32 #elif defined(CONFIG_USER_ONLY) -# define is_32bit(ctx) false +#define get_xl(ctx) MXL_RV64 #else -static inline bool is_32bit(DisasContext *ctx) +#define get_xl(ctx) ((ctx)->xl) +#endif + +/* The word size for this machine mode. */ +static inline int __attribute__((unused)) get_xlen(DisasContext *ctx) { - return ctx->xl == MXL_RV32; + return 16 << get_xl(ctx); } -#endif /* The word size for this operation. */ static inline int oper_len(DisasContext *ctx) @@ -257,7 +260,7 @@ static void gen_jal(DisasContext *ctx, int rd, target_ulong imm) static void mark_fs_dirty(DisasContext *ctx) { TCGv tmp; - target_ulong sd = is_32bit(ctx) ? MSTATUS32_SD : MSTATUS64_SD; + target_ulong sd = get_xl(ctx) == MXL_RV32 ? MSTATUS32_SD : MSTATUS64_SD; if (ctx->mstatus_fs != MSTATUS_FS) { /* Remember the state change for the rest of the TB. */ @@ -316,16 +319,16 @@ EX_SH(12) } \ } while (0) -#define REQUIRE_32BIT(ctx) do { \ - if (!is_32bit(ctx)) { \ - return false; \ - } \ +#define REQUIRE_32BIT(ctx) do { \ + if (get_xl(ctx) != MXL_RV32) { \ + return false; \ + } \ } while (0) -#define REQUIRE_64BIT(ctx) do { \ - if (is_32bit(ctx)) { \ - return false; \ - } \ +#define REQUIRE_64BIT(ctx) do { \ + if (get_xl(ctx) < MXL_RV64) { \ + return false; \ + } \ } while (0) static int ex_rvc_register(DisasContext *ctx, int reg) From patchwork Fri Oct 22 13:37:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 1544936 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=wdc.com header.i=@wdc.com header.a=rsa-sha256 header.s=dkim.wdc.com header.b=WVoAi1bI; dkim=pass (2048-bit key; unprotected) header.d=opensource.wdc.com header.i=@opensource.wdc.com header.a=rsa-sha256 header.s=dkim header.b=XrDrR0VL; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4HbQft2gkDz9sRN for ; Sat, 23 Oct 2021 00:48:38 +1100 (AEDT) Received: from localhost ([::1]:41070 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mduuS-0008L3-3x for incoming@patchwork.ozlabs.org; Fri, 22 Oct 2021 09:48:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57352) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mdumF-0001Cq-0p for qemu-devel@nongnu.org; Fri, 22 Oct 2021 09:40:07 -0400 Received: from esa6.hgst.iphmx.com ([216.71.154.45]:36402) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mdumC-0001Id-41 for qemu-devel@nongnu.org; Fri, 22 Oct 2021 09:40:06 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1634910004; x=1666446004; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=CD7GpwFieZlpWbU34RcvkwJja7SFwA9K9hD87Zyczec=; b=WVoAi1bIBmshsylH0Ktc/J01z/UZlXDUu7kvoyT1X0EsjtCm9kv7QkU5 i4xj3CubuVC6fjaNfzkInq3Mv7si+JEW9lygocDlZ4SU9CJA2bSg4wQ+N z+XN8cbSdswPdL4N37OZNo7HbOwUHAE15ST7EjinFXFM3uDtvMY37OccF I/iKpzrN+A+Q6fucz6WvZajtobCgnPDRWfwlZ+kz5lU6XM5UJfiEe2ng+ oj0XkBN0Am2k3jx6FF8WVzExEok4n97ewsoaSNiHU3uDuRnzOgYxKOeyF yvTci2qbUPXPyfHP2w+7iZ2OuEpnE8IelFL5VUgRIgvC1LGSYLgmnKfso w==; X-IronPort-AV: E=Sophos;i="5.87,172,1631548800"; d="scan'208";a="184556313" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 22 Oct 2021 21:40:02 +0800 IronPort-SDR: 9Lz0qTaOgQi/LwqeVFlHvQpJ4QMx5fBzvx8g1u/WkZHNLykkJ1ep9J51idNb2QbCx+I1axAwnm 9gVWHz6sVwLJqKAu4dwotwhDuXBvhlVzjaJDUfANrswXnSDVdRIXRJTeh9lO1riF13PvTt2SIa cVcVhMp+NFVFBLhH2TIHOTTVPnGvy/jjiZGKYC0gqZIh80AhwJB876vtoa7nCRQkzoNxU4eS2X p8ETcZB+VdVf7aIBtKPDUKU7ZD69CWgMDunvtPYBWX0vfvByOHaqjSjAbJ/ZtOuM/Jj/9rJARW vWdf6MQ9zqoygCXuw1KgJpcI Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Oct 2021 06:15:36 -0700 IronPort-SDR: 29fApXyiiy7duCerSO/UdXyiU9QI9Rj2IjxU4mqSG0gIvf/yKRivTVJBjNa450q3/l05aGG4Ef VnXR9e+o20WCBzmgfpyYlAn45YTt/5QFU1UFq3EeLB/jfR7QpYLsgtAPa2btXBsGiRubMoE1+2 nqoJtyV9anFAv1MXoUqSvU0K6cYBC6/0JFdtTcQIBNUmgK9TJ5uGbW31+GWvABCq6k6HetX7Ww u99Jh6OoKM/5lRREXShnJbA6PQVDF99c+7gdyo/G97P3ljIBm5mKSNUVzSXq0S3blEo4YVeFAH xso= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Oct 2021 06:40:02 -0700 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4HbQSx3k4Xz1RtVm for ; Fri, 22 Oct 2021 06:40:01 -0700 (PDT) Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1634910000; x=1637502001; bh=CD7GpwFieZlpWbU34R cvkwJja7SFwA9K9hD87Zyczec=; b=XrDrR0VLgKeaC/L6PR9OBZcOL3IqfkdLBE SgGvQXkDZ9RY6DI/Sdz/v1KV6UezP6hv9o6tZa4cr9m61N1UYpgE5Cq99ochJXfB 9cFbwGtgGP6FpBcuO+emSM6nPyPM+opZ6rTbsELfu+w4mKTGX/m4TgsPxsfp15/q pmuT4BSAdVakU22fghV//7I5r0O56Xhpecjvz10N4i34QFl0V36dR3Y4+joSccwW D35ue7PEJVfdnc0bQD4ZTu13Byh9XR2M/GdiCkXVcWcjQJlH579lWDSXGZQq1DTY GnACKYyCej6Xi3zOzfvzp1cQAThkjuDq+x5O7c50cmUruO1OXyLw== X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id Rnsdly6MaNz7 for ; Fri, 22 Oct 2021 06:40:00 -0700 (PDT) Received: from toolbox.wdc.com (unknown [10.225.165.39]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4HbQSr4P50z1RtVl; Fri, 22 Oct 2021 06:39:55 -0700 (PDT) From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Richard Henderson , LIU Zhiwei , Alistair Francis Subject: [PULL 16/33] target/riscv: Replace DisasContext.w with DisasContext.ol Date: Fri, 22 Oct 2021 23:37:55 +1000 Message-Id: <20211022133812.3972903-17-alistair.francis@opensource.wdc.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211022133812.3972903-1-alistair.francis@opensource.wdc.com> References: <20211022133812.3972903-1-alistair.francis@opensource.wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=216.71.154.45; envelope-from=prvs=9222bbd82=alistair.francis@opensource.wdc.com; helo=esa6.hgst.iphmx.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, SPF_HELO_PASS=-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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson In preparation for RV128, consider more than just "w" for operand size modification. This will be used for the "d" insns from RV128 as well. Rename oper_len to get_olen to better match get_xlen. Reviewed-by: LIU Zhiwei Reviewed-by: Alistair Francis Signed-off-by: Richard Henderson Message-id: 20211020031709.359469-10-richard.henderson@linaro.org Signed-off-by: Alistair Francis --- target/riscv/translate.c | 69 ++++++++++++++++--------- target/riscv/insn_trans/trans_rvb.c.inc | 8 +-- target/riscv/insn_trans/trans_rvi.c.inc | 18 +++---- target/riscv/insn_trans/trans_rvm.c.inc | 10 ++-- 4 files changed, 62 insertions(+), 43 deletions(-) diff --git a/target/riscv/translate.c b/target/riscv/translate.c index d0ba54091e..afd59ef690 100644 --- a/target/riscv/translate.c +++ b/target/riscv/translate.c @@ -67,7 +67,7 @@ typedef struct DisasContext { to any system register, which includes CSR_FRM, so we do not have to reset this known value. */ int frm; - bool w; + RISCVMXL ol; bool virt_enabled; bool ext_ifencei; bool hlsx; @@ -104,13 +104,18 @@ static inline int __attribute__((unused)) get_xlen(DisasContext *ctx) return 16 << get_xl(ctx); } -/* The word size for this operation. */ -static inline int oper_len(DisasContext *ctx) +/* The operation length, as opposed to the xlen. */ +#ifdef TARGET_RISCV32 +#define get_ol(ctx) MXL_RV32 +#else +#define get_ol(ctx) ((ctx)->ol) +#endif + +static inline int get_olen(DisasContext *ctx) { - return ctx->w ? 32 : TARGET_LONG_BITS; + return 16 << get_ol(ctx); } - /* * RISC-V requires NaN-boxing of narrower width floating point values. * This applies when a 32-bit value is assigned to a 64-bit FP register. @@ -197,24 +202,34 @@ static TCGv get_gpr(DisasContext *ctx, int reg_num, DisasExtend ext) return ctx->zero; } - switch (ctx->w ? ext : EXT_NONE) { - case EXT_NONE: - return cpu_gpr[reg_num]; - case EXT_SIGN: - t = temp_new(ctx); - tcg_gen_ext32s_tl(t, cpu_gpr[reg_num]); - return t; - case EXT_ZERO: - t = temp_new(ctx); - tcg_gen_ext32u_tl(t, cpu_gpr[reg_num]); - return t; + switch (get_ol(ctx)) { + case MXL_RV32: + switch (ext) { + case EXT_NONE: + break; + case EXT_SIGN: + t = temp_new(ctx); + tcg_gen_ext32s_tl(t, cpu_gpr[reg_num]); + return t; + case EXT_ZERO: + t = temp_new(ctx); + tcg_gen_ext32u_tl(t, cpu_gpr[reg_num]); + return t; + default: + g_assert_not_reached(); + } + break; + case MXL_RV64: + break; + default: + g_assert_not_reached(); } - g_assert_not_reached(); + return cpu_gpr[reg_num]; } static TCGv dest_gpr(DisasContext *ctx, int reg_num) { - if (reg_num == 0 || ctx->w) { + if (reg_num == 0 || get_olen(ctx) < TARGET_LONG_BITS) { return temp_new(ctx); } return cpu_gpr[reg_num]; @@ -223,10 +238,15 @@ static TCGv dest_gpr(DisasContext *ctx, int reg_num) static void gen_set_gpr(DisasContext *ctx, int reg_num, TCGv t) { if (reg_num != 0) { - if (ctx->w) { + switch (get_ol(ctx)) { + case MXL_RV32: tcg_gen_ext32s_tl(cpu_gpr[reg_num], t); - } else { + break; + case MXL_RV64: tcg_gen_mov_tl(cpu_gpr[reg_num], t); + break; + default: + g_assert_not_reached(); } } } @@ -387,7 +407,7 @@ static bool gen_shift_imm_fn(DisasContext *ctx, arg_shift *a, DisasExtend ext, void (*func)(TCGv, TCGv, target_long)) { TCGv dest, src1; - int max_len = oper_len(ctx); + int max_len = get_olen(ctx); if (a->shamt >= max_len) { return false; @@ -406,7 +426,7 @@ static bool gen_shift_imm_tl(DisasContext *ctx, arg_shift *a, DisasExtend ext, void (*func)(TCGv, TCGv, TCGv)) { TCGv dest, src1, src2; - int max_len = oper_len(ctx); + int max_len = get_olen(ctx); if (a->shamt >= max_len) { return false; @@ -430,7 +450,7 @@ static bool gen_shift(DisasContext *ctx, arg_r *a, DisasExtend ext, TCGv src2 = get_gpr(ctx, a->rs2, EXT_NONE); TCGv ext2 = tcg_temp_new(); - tcg_gen_andi_tl(ext2, src2, oper_len(ctx) - 1); + tcg_gen_andi_tl(ext2, src2, get_olen(ctx) - 1); func(dest, src1, ext2); gen_set_gpr(ctx, a->rd, dest); @@ -530,7 +550,6 @@ static void riscv_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs) ctx->vl_eq_vlmax = FIELD_EX32(tb_flags, TB_FLAGS, VL_EQ_VLMAX); ctx->xl = FIELD_EX32(tb_flags, TB_FLAGS, XL); ctx->cs = cs; - ctx->w = false; ctx->ntemp = 0; memset(ctx->temp, 0, sizeof(ctx->temp)); @@ -554,9 +573,9 @@ static void riscv_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu) CPURISCVState *env = cpu->env_ptr; uint16_t opcode16 = translator_lduw(env, &ctx->base, ctx->base.pc_next); + ctx->ol = ctx->xl; decode_opc(env, ctx, opcode16); ctx->base.pc_next = ctx->pc_succ_insn; - ctx->w = false; for (int i = ctx->ntemp - 1; i >= 0; --i) { tcg_temp_free(ctx->temp[i]); diff --git a/target/riscv/insn_trans/trans_rvb.c.inc b/target/riscv/insn_trans/trans_rvb.c.inc index 3095624f32..9ef8ab94ad 100644 --- a/target/riscv/insn_trans/trans_rvb.c.inc +++ b/target/riscv/insn_trans/trans_rvb.c.inc @@ -344,7 +344,7 @@ static bool trans_cpopw(DisasContext *ctx, arg_cpopw *a) { REQUIRE_64BIT(ctx); REQUIRE_ZBB(ctx); - ctx->w = true; + ctx->ol = MXL_RV32; return gen_unary(ctx, a, EXT_ZERO, tcg_gen_ctpop_tl); } @@ -370,7 +370,7 @@ static bool trans_rorw(DisasContext *ctx, arg_rorw *a) { REQUIRE_64BIT(ctx); REQUIRE_ZBB(ctx); - ctx->w = true; + ctx->ol = MXL_RV32; return gen_shift(ctx, a, EXT_NONE, gen_rorw); } @@ -378,7 +378,7 @@ static bool trans_roriw(DisasContext *ctx, arg_roriw *a) { REQUIRE_64BIT(ctx); REQUIRE_ZBB(ctx); - ctx->w = true; + ctx->ol = MXL_RV32; return gen_shift_imm_tl(ctx, a, EXT_NONE, gen_rorw); } @@ -404,7 +404,7 @@ static bool trans_rolw(DisasContext *ctx, arg_rolw *a) { REQUIRE_64BIT(ctx); REQUIRE_ZBB(ctx); - ctx->w = true; + ctx->ol = MXL_RV32; return gen_shift(ctx, a, EXT_NONE, gen_rolw); } diff --git a/target/riscv/insn_trans/trans_rvi.c.inc b/target/riscv/insn_trans/trans_rvi.c.inc index a6a57c94bb..9cf0383cfb 100644 --- a/target/riscv/insn_trans/trans_rvi.c.inc +++ b/target/riscv/insn_trans/trans_rvi.c.inc @@ -331,14 +331,14 @@ static bool trans_and(DisasContext *ctx, arg_and *a) static bool trans_addiw(DisasContext *ctx, arg_addiw *a) { REQUIRE_64BIT(ctx); - ctx->w = true; + ctx->ol = MXL_RV32; return gen_arith_imm_fn(ctx, a, EXT_NONE, tcg_gen_addi_tl); } static bool trans_slliw(DisasContext *ctx, arg_slliw *a) { REQUIRE_64BIT(ctx); - ctx->w = true; + ctx->ol = MXL_RV32; return gen_shift_imm_fn(ctx, a, EXT_NONE, tcg_gen_shli_tl); } @@ -350,7 +350,7 @@ static void gen_srliw(TCGv dst, TCGv src, target_long shamt) static bool trans_srliw(DisasContext *ctx, arg_srliw *a) { REQUIRE_64BIT(ctx); - ctx->w = true; + ctx->ol = MXL_RV32; return gen_shift_imm_fn(ctx, a, EXT_NONE, gen_srliw); } @@ -362,42 +362,42 @@ static void gen_sraiw(TCGv dst, TCGv src, target_long shamt) static bool trans_sraiw(DisasContext *ctx, arg_sraiw *a) { REQUIRE_64BIT(ctx); - ctx->w = true; + ctx->ol = MXL_RV32; return gen_shift_imm_fn(ctx, a, EXT_NONE, gen_sraiw); } static bool trans_addw(DisasContext *ctx, arg_addw *a) { REQUIRE_64BIT(ctx); - ctx->w = true; + ctx->ol = MXL_RV32; return gen_arith(ctx, a, EXT_NONE, tcg_gen_add_tl); } static bool trans_subw(DisasContext *ctx, arg_subw *a) { REQUIRE_64BIT(ctx); - ctx->w = true; + ctx->ol = MXL_RV32; return gen_arith(ctx, a, EXT_NONE, tcg_gen_sub_tl); } static bool trans_sllw(DisasContext *ctx, arg_sllw *a) { REQUIRE_64BIT(ctx); - ctx->w = true; + ctx->ol = MXL_RV32; return gen_shift(ctx, a, EXT_NONE, tcg_gen_shl_tl); } static bool trans_srlw(DisasContext *ctx, arg_srlw *a) { REQUIRE_64BIT(ctx); - ctx->w = true; + ctx->ol = MXL_RV32; return gen_shift(ctx, a, EXT_ZERO, tcg_gen_shr_tl); } static bool trans_sraw(DisasContext *ctx, arg_sraw *a) { REQUIRE_64BIT(ctx); - ctx->w = true; + ctx->ol = MXL_RV32; return gen_shift(ctx, a, EXT_SIGN, tcg_gen_sar_tl); } diff --git a/target/riscv/insn_trans/trans_rvm.c.inc b/target/riscv/insn_trans/trans_rvm.c.inc index b89a85ad3a..9a1fe3c799 100644 --- a/target/riscv/insn_trans/trans_rvm.c.inc +++ b/target/riscv/insn_trans/trans_rvm.c.inc @@ -214,7 +214,7 @@ static bool trans_mulw(DisasContext *ctx, arg_mulw *a) { REQUIRE_64BIT(ctx); REQUIRE_EXT(ctx, RVM); - ctx->w = true; + ctx->ol = MXL_RV32; return gen_arith(ctx, a, EXT_NONE, tcg_gen_mul_tl); } @@ -222,7 +222,7 @@ static bool trans_divw(DisasContext *ctx, arg_divw *a) { REQUIRE_64BIT(ctx); REQUIRE_EXT(ctx, RVM); - ctx->w = true; + ctx->ol = MXL_RV32; return gen_arith(ctx, a, EXT_SIGN, gen_div); } @@ -230,7 +230,7 @@ static bool trans_divuw(DisasContext *ctx, arg_divuw *a) { REQUIRE_64BIT(ctx); REQUIRE_EXT(ctx, RVM); - ctx->w = true; + ctx->ol = MXL_RV32; return gen_arith(ctx, a, EXT_ZERO, gen_divu); } @@ -238,7 +238,7 @@ static bool trans_remw(DisasContext *ctx, arg_remw *a) { REQUIRE_64BIT(ctx); REQUIRE_EXT(ctx, RVM); - ctx->w = true; + ctx->ol = MXL_RV32; return gen_arith(ctx, a, EXT_SIGN, gen_rem); } @@ -246,6 +246,6 @@ static bool trans_remuw(DisasContext *ctx, arg_remuw *a) { REQUIRE_64BIT(ctx); REQUIRE_EXT(ctx, RVM); - ctx->w = true; + ctx->ol = MXL_RV32; return gen_arith(ctx, a, EXT_ZERO, gen_remu); } From patchwork Fri Oct 22 13:37:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 1544952 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=wdc.com header.i=@wdc.com header.a=rsa-sha256 header.s=dkim.wdc.com header.b=eWohdzkB; dkim=pass (2048-bit key; unprotected) header.d=opensource.wdc.com header.i=@opensource.wdc.com header.a=rsa-sha256 header.s=dkim header.b=XGaH7CmH; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4HbQjY6xSSz9sRN for ; Sat, 23 Oct 2021 00:50:57 +1100 (AEDT) Received: from localhost ([::1]:49966 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mduwh-0005jf-Pr for incoming@patchwork.ozlabs.org; Fri, 22 Oct 2021 09:50:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57368) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mdumH-0001J2-NN for qemu-devel@nongnu.org; Fri, 22 Oct 2021 09:40:10 -0400 Received: from esa6.hgst.iphmx.com ([216.71.154.45]:36402) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mdumF-0001Id-9P for qemu-devel@nongnu.org; Fri, 22 Oct 2021 09:40:09 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1634910007; x=1666446007; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=C84ZQjMLJZ9ncphVskN1oKWmyWx4zQATr9d7mAt+hyw=; b=eWohdzkBThLlyIzExYMVwj0q7VJWOiKcC1MAemopAyyqTd0ZEQWH9P55 BjO2XPAjFRLwQxbZDvCvQ958c7G4RATlu5OdsE8Z3QGisuv/HZ5T1jiJE TVcDCssf0OMCwAeDcq+jZ46I24ItpNoFTcJROhN89YMfsgSBpluygrzDb os9rCu/H1FhcjY0ilsnGI1woXG5L3rE7iwCWdRPEzFJFz421lIoQW3Nhd CIkQyb3HqTmnSG74nayMVygiXWvmYHP9YDnvNDPYP6RT1FhmXglMHZfIr OylH7FHSTYP1vAF2Psn9o9397Ztb1/RKx/S+dsg74qeigvIUpON5wDe96 A==; X-IronPort-AV: E=Sophos;i="5.87,172,1631548800"; d="scan'208";a="184556322" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 22 Oct 2021 21:40:07 +0800 IronPort-SDR: BYpirgh/mQpcdr2gp5ZXrm3gSOy1da7m8H8W0JiCezMoPt6FYLZmp/AjHTeHs+cQDuVYPuxHIw nux6x8L/FbD5oWSb4OR7EYSNHkvcTcE2TfiVsfNQZSGQ29aVl64pt9Xj2+dv44BXZJWBeotUEP wy+ji+FXBnZOKQlKD8Q0p27UZKnEgHZbQRinYe4052oLREsiz5+Ml6lfRjbP4yj4SuL3KBMN9k LCeq6JaqJ5Y26gTib9MQZ6Knbh3SpWDGCIcnvT0aowFxHpH0+k8+Fc+9TCb1oRlKPwI93Ot5Ru q6H88OhU6PSHeLISj2FwoaIf Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Oct 2021 06:15:41 -0700 IronPort-SDR: bBaaoMDPqJU4Q/PbWwZjCkOXFbbd99XSa05YNKG1c9ybc4JD3WOwdS7oOicaRqPRT3PaoDwEJK GLMZhWtoCCPFx+D1bLRfOGNpt29Ifd9QzXCCN/xh8tKaZ+LzV8QkNgwOT5mJLk80rrJ9mjTl0z xMNgjruhmQqxMpLWRQGCMKceJxvQ8t3Z5cbWgjc9oZ8vJM5mnqKxDMRQB09IuwDDcV43QtDNDq 7OcmmoxjM4W0pFUVH+eFjtmlbm9c9ILtTGpqePx5e7eIXJKDdElVoO6sSjem+tii9N43BPte62 Y5Q= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Oct 2021 06:40:06 -0700 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4HbQT22WT4z1RtVm for ; Fri, 22 Oct 2021 06:40:06 -0700 (PDT) Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1634910005; x=1637502006; bh=C84ZQjMLJZ9ncphVsk N1oKWmyWx4zQATr9d7mAt+hyw=; b=XGaH7CmHYyK5R1Pp9Sgkm9ifMNG+M0Gusq L1icjiAD5wGYfZfoZDeB9Sge2H52sSwtXnQuxPlonESZeozVEPzjPXuF/vfc6Oez kPtcvllDPj6m0/sUW2ufVH9tnyh4OYdZzsb03bUN3qv2uYPu6RZjAT2X97vbOZrL v9UgkTqy1L+9L2HSiNIfiKumgeIvJRLEIE9kApSp2xJ1aV9j5y3P73fN8v+0aiYA rGF8m1osyKzfcULCNr1juYufIS1V7W9/1vPftmvWoQAxPKMtkgnFze+o4PA/dt0C SqdID5Y7xwSdEiYaWsuQRH2UHx6Om7/sNXUDjKstC8ki2gbX4XQw== X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id dmlYkQoMBL3W for ; Fri, 22 Oct 2021 06:40:05 -0700 (PDT) Received: from toolbox.wdc.com (unknown [10.225.165.39]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4HbQSx5vhnz1RtVl; Fri, 22 Oct 2021 06:40:01 -0700 (PDT) From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Richard Henderson , LIU Zhiwei , Alistair Francis Subject: [PULL 17/33] target/riscv: Use gen_arith_per_ol for RVM Date: Fri, 22 Oct 2021 23:37:56 +1000 Message-Id: <20211022133812.3972903-18-alistair.francis@opensource.wdc.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211022133812.3972903-1-alistair.francis@opensource.wdc.com> References: <20211022133812.3972903-1-alistair.francis@opensource.wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=216.71.154.45; envelope-from=prvs=9222bbd82=alistair.francis@opensource.wdc.com; helo=esa6.hgst.iphmx.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, SPF_HELO_PASS=-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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson The multiply high-part instructions require a separate implementation for RV32 when TARGET_LONG_BITS == 64. Reviewed-by: LIU Zhiwei Reviewed-by: Alistair Francis Signed-off-by: Richard Henderson Message-id: 20211020031709.359469-11-richard.henderson@linaro.org Signed-off-by: Alistair Francis --- target/riscv/translate.c | 16 +++++++++++++++ target/riscv/insn_trans/trans_rvm.c.inc | 26 ++++++++++++++++++++++--- 2 files changed, 39 insertions(+), 3 deletions(-) diff --git a/target/riscv/translate.c b/target/riscv/translate.c index afd59ef690..cb515e2a3c 100644 --- a/target/riscv/translate.c +++ b/target/riscv/translate.c @@ -403,6 +403,22 @@ static bool gen_arith(DisasContext *ctx, arg_r *a, DisasExtend ext, return true; } +static bool gen_arith_per_ol(DisasContext *ctx, arg_r *a, DisasExtend ext, + void (*f_tl)(TCGv, TCGv, TCGv), + void (*f_32)(TCGv, TCGv, TCGv)) +{ + int olen = get_olen(ctx); + + if (olen != TARGET_LONG_BITS) { + if (olen == 32) { + f_tl = f_32; + } else { + g_assert_not_reached(); + } + } + return gen_arith(ctx, a, ext, f_tl); +} + static bool gen_shift_imm_fn(DisasContext *ctx, arg_shift *a, DisasExtend ext, void (*func)(TCGv, TCGv, target_long)) { diff --git a/target/riscv/insn_trans/trans_rvm.c.inc b/target/riscv/insn_trans/trans_rvm.c.inc index 9a1fe3c799..2af0e5c139 100644 --- a/target/riscv/insn_trans/trans_rvm.c.inc +++ b/target/riscv/insn_trans/trans_rvm.c.inc @@ -33,10 +33,16 @@ static void gen_mulh(TCGv ret, TCGv s1, TCGv s2) tcg_temp_free(discard); } +static void gen_mulh_w(TCGv ret, TCGv s1, TCGv s2) +{ + tcg_gen_mul_tl(ret, s1, s2); + tcg_gen_sari_tl(ret, ret, 32); +} + static bool trans_mulh(DisasContext *ctx, arg_mulh *a) { REQUIRE_EXT(ctx, RVM); - return gen_arith(ctx, a, EXT_NONE, gen_mulh); + return gen_arith_per_ol(ctx, a, EXT_SIGN, gen_mulh, gen_mulh_w); } static void gen_mulhsu(TCGv ret, TCGv arg1, TCGv arg2) @@ -54,10 +60,23 @@ static void gen_mulhsu(TCGv ret, TCGv arg1, TCGv arg2) tcg_temp_free(rh); } +static void gen_mulhsu_w(TCGv ret, TCGv arg1, TCGv arg2) +{ + TCGv t1 = tcg_temp_new(); + TCGv t2 = tcg_temp_new(); + + tcg_gen_ext32s_tl(t1, arg1); + tcg_gen_ext32u_tl(t2, arg2); + tcg_gen_mul_tl(ret, t1, t2); + tcg_temp_free(t1); + tcg_temp_free(t2); + tcg_gen_sari_tl(ret, ret, 32); +} + static bool trans_mulhsu(DisasContext *ctx, arg_mulhsu *a) { REQUIRE_EXT(ctx, RVM); - return gen_arith(ctx, a, EXT_NONE, gen_mulhsu); + return gen_arith_per_ol(ctx, a, EXT_NONE, gen_mulhsu, gen_mulhsu_w); } static void gen_mulhu(TCGv ret, TCGv s1, TCGv s2) @@ -71,7 +90,8 @@ static void gen_mulhu(TCGv ret, TCGv s1, TCGv s2) static bool trans_mulhu(DisasContext *ctx, arg_mulhu *a) { REQUIRE_EXT(ctx, RVM); - return gen_arith(ctx, a, EXT_NONE, gen_mulhu); + /* gen_mulh_w works for either sign as input. */ + return gen_arith_per_ol(ctx, a, EXT_ZERO, gen_mulhu, gen_mulh_w); } static void gen_div(TCGv ret, TCGv source1, TCGv source2) From patchwork Fri Oct 22 13:37:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 1544954 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=wdc.com header.i=@wdc.com header.a=rsa-sha256 header.s=dkim.wdc.com header.b=fr5iIOpS; dkim=pass (2048-bit key; unprotected) header.d=opensource.wdc.com header.i=@opensource.wdc.com header.a=rsa-sha256 header.s=dkim header.b=AESo0g2B; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4HbQpC5VLkz9sRN for ; Sat, 23 Oct 2021 00:54:59 +1100 (AEDT) Received: from localhost ([::1]:57396 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mdv0b-0002Pg-Ft for incoming@patchwork.ozlabs.org; Fri, 22 Oct 2021 09:54:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57386) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mdumO-0001XW-VW for qemu-devel@nongnu.org; Fri, 22 Oct 2021 09:40:17 -0400 Received: from esa2.hgst.iphmx.com ([68.232.143.124]:13351) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mdumL-0001MX-3e for qemu-devel@nongnu.org; Fri, 22 Oct 2021 09:40:16 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1634910012; x=1666446012; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=dat5VN+pElCksEeUs1CTWymeVP0zYztbyu2XnGjIbS0=; b=fr5iIOpS9ARVImtTt0L8/T4QgMPImPDjvCm47MzgHabsKWAWF7FASV6f 5LU9kEKQ0gQr0+QHbPQ/ilg1Y7QPazLFPpCD37/XHxeOfhbwSBobh3CxH eoiwd0AJ9JyK63E7YYPvKlsJEj6SWw/vEU6C+yZUnxisTP/iVmkWPhqg9 pZXeHJsG5h5+HZC97MX6xS52qmrZQBv3IzVZkhbkMCtD3l+nazaIo2XeO uhCXAi3LlHa0fE1dE3ecBOOvk+y2HSq3DnAYX2NcK5yNa4Mn7jYrt1wRf vpQsJ34fRIdlJmEZo/gKrTk6sMPJrTG0X9z7Swie9ieEZFeuSH7D4RjBi w==; X-IronPort-AV: E=Sophos;i="5.87,172,1631548800"; d="scan'208";a="287492731" Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 22 Oct 2021 21:40:11 +0800 IronPort-SDR: m7PKwFUp4iNpprab/3SWxtSfJDjQGOBbqivyhfrWPNLv5RyetImd6KGLDofZmZNGnyCS4OAXyF MbdaZcLbiGp9NMRAKX1QrMK7O1RK6cMZjn5Ut7X7sxdr+M51bn5o6nHOkm76e1+7FmudDh7DJ7 KgyaU6Pdp2A4B3NEprSvz3oTD/ygIH7SDgoauvmNesZdRq7qBGhoI4Rred9BZa8Ss7XhsPSHOi ddOxu3CEm9sTEnd8VE2SCsYQf0397Z83THngpGn/T5N2leHjPSQWwoRUX3eev3J1MwYfTaKt4W XqOIBBOtCWBNsOV/VsNZ0SHt Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Oct 2021 06:14:13 -0700 IronPort-SDR: GzpR1HUxCNZV8isPYP5igRk2VdbBeL7bsVwodUxXLlgjRpbGmQDHTuxwiCVp5aiC+s3BodDbzb xO4OleDnO0r/JOyqF5c3LMTnGH/QbtjB1CNDL7SYr5smWt593D/3722akXxgXeNjpZH/WlkL2b 7QQ4UqvcCIKtqKBDurjiPtc12cAvNnB0ryD5Q7tqUqo3/ibU70AtEdlxrCvUoISNf98vc74dq0 8Q2MKUwE6aLzPRTExFyn6mQpEpuPZTLZG7TS4mCxzjFBYD+/e5DRcI4k6+WHzgau6ZWL3wUQxr jRY= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Oct 2021 06:40:12 -0700 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4HbQT74SdWz1RtVm for ; Fri, 22 Oct 2021 06:40:11 -0700 (PDT) Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1634910011; x=1637502012; bh=dat5VN+pElCksEeUs1 CTWymeVP0zYztbyu2XnGjIbS0=; b=AESo0g2BBV2DDmSIv/7YYKd83+gGAqjr4s SxY9YFPcmvguup6frERSR8IbzbyIb3t652vAgVv4tMXxHCwt8S0C8tkMSefOnRAI qDdegoVfjH/fwk6NmOkPJFwhbYNV/sWcmWu8WmA6Pvnu5vTO22ENLHW3G0+EWU7a o1f/PbBsu3LyBMqohvMI2HbRsuZBCX8R8nbgwibqrbWWzQISfBpUHuzTzJxI/fBP 5THX4GokeI5L31JY4FJyVvTUr1ebvJ4hirEL8TV4WIRSgN+iP5pJjilsVARcDjln qQw7kxRpGLUmaqSlroFRKMhorGtPQoZxEXcCzAmpneW/oy84qVAg== X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id gKKzoLuQi4gL for ; Fri, 22 Oct 2021 06:40:11 -0700 (PDT) Received: from toolbox.wdc.com (unknown [10.225.165.39]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4HbQT30WjDz1RtVl; Fri, 22 Oct 2021 06:40:06 -0700 (PDT) From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Richard Henderson , Alistair Francis , LIU Zhiwei Subject: [PULL 18/33] target/riscv: Adjust trans_rev8_32 for riscv64 Date: Fri, 22 Oct 2021 23:37:57 +1000 Message-Id: <20211022133812.3972903-19-alistair.francis@opensource.wdc.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211022133812.3972903-1-alistair.francis@opensource.wdc.com> References: <20211022133812.3972903-1-alistair.francis@opensource.wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=68.232.143.124; envelope-from=prvs=9222bbd82=alistair.francis@opensource.wdc.com; helo=esa2.hgst.iphmx.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, SPF_HELO_PASS=-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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson When target_long is 64-bit, we still want a 32-bit bswap for rev8. Since this opcode is specific to RV32, we need not conditionalize. Acked-by: Alistair Francis Reviewed-by: LIU Zhiwei Signed-off-by: Richard Henderson Message-id: 20211020031709.359469-12-richard.henderson@linaro.org Signed-off-by: Alistair Francis --- target/riscv/insn_trans/trans_rvb.c.inc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/target/riscv/insn_trans/trans_rvb.c.inc b/target/riscv/insn_trans/trans_rvb.c.inc index 9ef8ab94ad..d6f9e9fc83 100644 --- a/target/riscv/insn_trans/trans_rvb.c.inc +++ b/target/riscv/insn_trans/trans_rvb.c.inc @@ -232,11 +232,16 @@ static bool trans_rol(DisasContext *ctx, arg_rol *a) return gen_shift(ctx, a, EXT_NONE, tcg_gen_rotl_tl); } +static void gen_rev8_32(TCGv ret, TCGv src1) +{ + tcg_gen_bswap32_tl(ret, src1, TCG_BSWAP_OS); +} + static bool trans_rev8_32(DisasContext *ctx, arg_rev8_32 *a) { REQUIRE_32BIT(ctx); REQUIRE_ZBB(ctx); - return gen_unary(ctx, a, EXT_NONE, tcg_gen_bswap_tl); + return gen_unary(ctx, a, EXT_NONE, gen_rev8_32); } static bool trans_rev8_64(DisasContext *ctx, arg_rev8_64 *a) From patchwork Fri Oct 22 13:37:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 1544958 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=wdc.com header.i=@wdc.com header.a=rsa-sha256 header.s=dkim.wdc.com header.b=T2noL6VD; dkim=pass (2048-bit key; unprotected) header.d=opensource.wdc.com header.i=@opensource.wdc.com header.a=rsa-sha256 header.s=dkim header.b=WOpRbcJk; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4HbQsH4XSWz9sRR for ; Sat, 23 Oct 2021 00:57:39 +1100 (AEDT) Received: from localhost ([::1]:37562 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mdv3B-0008Ch-DU for incoming@patchwork.ozlabs.org; Fri, 22 Oct 2021 09:57:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57424) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mdumU-0001hf-0N for qemu-devel@nongnu.org; Fri, 22 Oct 2021 09:40:22 -0400 Received: from esa4.hgst.iphmx.com ([216.71.154.42]:64491) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mdumQ-0001Nq-Fg for qemu-devel@nongnu.org; Fri, 22 Oct 2021 09:40:21 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1634910018; x=1666446018; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=TUoz6MM0riwXJiwPWUxO3Fkw9oaATPa48MO1HdT5yLs=; b=T2noL6VDN1SW06YZ2mxTSWGLY329mzVo1L2TIddzFycHUxVNFHJ+P8M5 T8ooRjwmwPRF8l+W5MyCufsdMMae8NZJlGfhhXTeRyMfKr4BEcybS9SSr 9aIpbype0eKpyj6qKVQ2RV5HJUdoIzOvbj2QOItpjtuH1oSs2uyDtjjTm tVGXg4k5x9lrtI7UAtaC/eSFB368gHCDx2UiIaH/8SD9s6qqN/L5HWrrc XCpIi2+TSGd88XcSCdRbYhxMVPJNI7Cka0vcN9WWbSty+Hy1eDx2T/noU 4q2ASgQn2PScalJHvhQiMedlQaWzxX/WEWBLQfbfinyvASzdSeh8w3v0b w==; X-IronPort-AV: E=Sophos;i="5.87,172,1631548800"; d="scan'208";a="182632632" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 22 Oct 2021 21:40:17 +0800 IronPort-SDR: SWlF7fdLyC9zZb12XKko2GaxxLOOg8jhNbCb9I5VMHE1xfI1nJ/srxhRLEUfxVVL83lacFdvot nS92Y71D+Fk1Rt//iso4/WkBC+YFU/2Kc8GkfM7RmAeQ+NLwDr9fg2BndQKQ/PBscyXe/wweH4 9pU3k/AgeIEZZnefCSLqt9xdB10FZkUCEHkhbOdaWODeLx3RYz6hHLBoOjhoro3y4jS6WpaTfh bq/XM1ool306QTIwT0WYe8tl4RgXdUeV/n9MOqNoF0Z9bIp7akYjOqCB12YkAB3sfwqXzB+9ut JAay2GY0QD4JOxL8X7RilCeY Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Oct 2021 06:14:19 -0700 IronPort-SDR: B8VJtWWnqYd/9qF4lRp1gbJ/NdVysuE8DFCsfqo8OeBsO19Vuw3wX3oGtd9DLgHUkWoBOCHKuu nUh4yCxdT231jtr2jvgfxUU0XoB4ZRQLWz6CQ3PB3xN5HnnIMKyjaEXqBLSwb+3PvsgygpPf1N w+IjlrFm4OkHFNl+EGiYLV9QbZXBVBAiOWYSLmdBkf7wIFe6Qiz2PnZ81JFs2fCHDFmtaQhJ61 3bziM+762m9qAxv6sr2mmkb/lJhIEgqm3jssuzewCIsWpiS0x37GsnYfoA/54ULUXS7/wSdr0C 4TQ= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Oct 2021 06:40:17 -0700 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4HbQTF02dFz1RtVt for ; Fri, 22 Oct 2021 06:40:17 -0700 (PDT) Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1634910016; x=1637502017; bh=TUoz6MM0riwXJiwPWU xO3Fkw9oaATPa48MO1HdT5yLs=; b=WOpRbcJkDnrmZn4wAmXr4pIOkS0Ld1TAyA TrY2qGaq7hZXkKEOofRSVf1svvHsW39iUPja1f1lN8YhtRO6YlL9lJhCtDL2yJ6G kdfyG9trsBMgi8rhN9uwHzQyaM74jcV72r7KAxIQHprmvd/wLnjWnTLoQTAWFvdf K2pfV9uTBPTqFkop0qiJzbY/kvtm2BqBlr7Ky1HAAfwdBnWaNjhbV4KV42bkJhkw NWGld2hiXnYMzSiq4C2VKbQoDpd4oOnn0OwDo0LcqlUDFDd8p9+iwGNrlgS0AO4o TP4IRmEJmq23gzkXMscbOKmQxFjMO/pViS57mOdarpd2sqbykYYQ== X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id AFwoGCLh_bO9 for ; Fri, 22 Oct 2021 06:40:16 -0700 (PDT) Received: from toolbox.wdc.com (unknown [10.225.165.39]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4HbQT82lNQz1RtVl; Fri, 22 Oct 2021 06:40:11 -0700 (PDT) From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Richard Henderson , LIU Zhiwei , Alistair Francis Subject: [PULL 19/33] target/riscv: Use gen_unary_per_ol for RVB Date: Fri, 22 Oct 2021 23:37:58 +1000 Message-Id: <20211022133812.3972903-20-alistair.francis@opensource.wdc.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211022133812.3972903-1-alistair.francis@opensource.wdc.com> References: <20211022133812.3972903-1-alistair.francis@opensource.wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=216.71.154.42; envelope-from=prvs=9222bbd82=alistair.francis@opensource.wdc.com; helo=esa4.hgst.iphmx.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, SPF_HELO_PASS=-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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson The count zeros instructions require a separate implementation for RV32 when TARGET_LONG_BITS == 64. Reviewed-by: LIU Zhiwei Reviewed-by: Alistair Francis Signed-off-by: Richard Henderson Message-id: 20211020031709.359469-13-richard.henderson@linaro.org Signed-off-by: Alistair Francis --- target/riscv/translate.c | 16 ++++++++++++ target/riscv/insn_trans/trans_rvb.c.inc | 33 ++++++++++++------------- 2 files changed, 32 insertions(+), 17 deletions(-) diff --git a/target/riscv/translate.c b/target/riscv/translate.c index cb515e2a3c..f3a5870ad0 100644 --- a/target/riscv/translate.c +++ b/target/riscv/translate.c @@ -486,6 +486,22 @@ static bool gen_unary(DisasContext *ctx, arg_r2 *a, DisasExtend ext, return true; } +static bool gen_unary_per_ol(DisasContext *ctx, arg_r2 *a, DisasExtend ext, + void (*f_tl)(TCGv, TCGv), + void (*f_32)(TCGv, TCGv)) +{ + int olen = get_olen(ctx); + + if (olen != TARGET_LONG_BITS) { + if (olen == 32) { + f_tl = f_32; + } else { + g_assert_not_reached(); + } + } + return gen_unary(ctx, a, ext, f_tl); +} + static uint32_t opcode_at(DisasContextBase *dcbase, target_ulong pc) { DisasContext *ctx = container_of(dcbase, DisasContext, base); diff --git a/target/riscv/insn_trans/trans_rvb.c.inc b/target/riscv/insn_trans/trans_rvb.c.inc index d6f9e9fc83..4eb41756fa 100644 --- a/target/riscv/insn_trans/trans_rvb.c.inc +++ b/target/riscv/insn_trans/trans_rvb.c.inc @@ -47,10 +47,18 @@ static void gen_clz(TCGv ret, TCGv arg1) tcg_gen_clzi_tl(ret, arg1, TARGET_LONG_BITS); } +static void gen_clzw(TCGv ret, TCGv arg1) +{ + TCGv t = tcg_temp_new(); + tcg_gen_shli_tl(t, arg1, 32); + tcg_gen_clzi_tl(ret, t, 32); + tcg_temp_free(t); +} + static bool trans_clz(DisasContext *ctx, arg_clz *a) { REQUIRE_ZBB(ctx); - return gen_unary(ctx, a, EXT_ZERO, gen_clz); + return gen_unary_per_ol(ctx, a, EXT_NONE, gen_clz, gen_clzw); } static void gen_ctz(TCGv ret, TCGv arg1) @@ -58,10 +66,15 @@ static void gen_ctz(TCGv ret, TCGv arg1) tcg_gen_ctzi_tl(ret, arg1, TARGET_LONG_BITS); } +static void gen_ctzw(TCGv ret, TCGv arg1) +{ + tcg_gen_ctzi_tl(ret, arg1, 32); +} + static bool trans_ctz(DisasContext *ctx, arg_ctz *a) { REQUIRE_ZBB(ctx); - return gen_unary(ctx, a, EXT_ZERO, gen_ctz); + return gen_unary_per_ol(ctx, a, EXT_ZERO, gen_ctz, gen_ctzw); } static bool trans_cpop(DisasContext *ctx, arg_cpop *a) @@ -317,14 +330,6 @@ static bool trans_zext_h_64(DisasContext *ctx, arg_zext_h_64 *a) return gen_unary(ctx, a, EXT_NONE, tcg_gen_ext16u_tl); } -static void gen_clzw(TCGv ret, TCGv arg1) -{ - TCGv t = tcg_temp_new(); - tcg_gen_shli_tl(t, arg1, 32); - tcg_gen_clzi_tl(ret, t, 32); - tcg_temp_free(t); -} - static bool trans_clzw(DisasContext *ctx, arg_clzw *a) { REQUIRE_64BIT(ctx); @@ -332,17 +337,11 @@ static bool trans_clzw(DisasContext *ctx, arg_clzw *a) return gen_unary(ctx, a, EXT_NONE, gen_clzw); } -static void gen_ctzw(TCGv ret, TCGv arg1) -{ - tcg_gen_ori_tl(ret, arg1, (target_ulong)MAKE_64BIT_MASK(32, 32)); - tcg_gen_ctzi_tl(ret, ret, 64); -} - static bool trans_ctzw(DisasContext *ctx, arg_ctzw *a) { REQUIRE_64BIT(ctx); REQUIRE_ZBB(ctx); - return gen_unary(ctx, a, EXT_NONE, gen_ctzw); + return gen_unary(ctx, a, EXT_ZERO, gen_ctzw); } static bool trans_cpopw(DisasContext *ctx, arg_cpopw *a) From patchwork Fri Oct 22 13:37:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 1544953 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=wdc.com header.i=@wdc.com header.a=rsa-sha256 header.s=dkim.wdc.com header.b=e+XtIcm2; dkim=pass (2048-bit key; unprotected) header.d=opensource.wdc.com header.i=@opensource.wdc.com header.a=rsa-sha256 header.s=dkim header.b=GYF2ntz5; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4HbQkW5Gnbz9sRN for ; Sat, 23 Oct 2021 00:51:47 +1100 (AEDT) Received: from localhost ([::1]:52278 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mduxV-0007HN-HW for incoming@patchwork.ozlabs.org; Fri, 22 Oct 2021 09:51:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57442) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mdumY-0001n9-VA for qemu-devel@nongnu.org; Fri, 22 Oct 2021 09:40:27 -0400 Received: from esa5.hgst.iphmx.com ([216.71.153.144]:39690) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mdumW-0001Qs-JO for qemu-devel@nongnu.org; Fri, 22 Oct 2021 09:40:26 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1634910023; x=1666446023; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=5kMdTeCvBsa3k7CM+RKKt2ZHdP1vD9O2pkGibwmxjiY=; b=e+XtIcm2Rj9+XrpqWAlL8D4Gwx9HJjHiU7+iMKTEgfm4/4qkAQf0vZsp yqjom2Y1J3tIKM5COsUPikxwAx3MU35PPHsLTEyug9Atbu1FiVkVI/pfR 6CYRmh/CfTZXcMNHD/qJbRjhNF8De8hqBqON2BqAdUAvLIcBjU+fejPCS IvmFfDcFCJhpVnIu4b3cFz1Dez0W1IJBiNwOsYInTzifNHGd3fzriPzcf Xqz5XTOPi9fkM/Qo/q79GZNC4ELBfFtX61LW/Vu0lDmMkS5zSeyC3Hmol +cB4o018CeZ54fymqPANlVIHFzi8ae1/2vdJBM+34jkQwt1K2c3TndKFp Q==; X-IronPort-AV: E=Sophos;i="5.87,172,1631548800"; d="scan'208";a="183617887" Received: from h199-255-45-14.hgst.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 22 Oct 2021 21:40:21 +0800 IronPort-SDR: 42lw84A79B3jsR1lZZuBxBNXoOBLh8xWOC4jHOfNqmkF8cn+hAcSvsrNM2E1XF1embbQqy5+bB Rfyodd1PmL9tP263cXOWJCbjDTShglOi6wCb/mUbZBjjjTHe+fp0SDTTM417JeugWjmwZcmwud HUiAqPlqH3ll6wrzvaWSKmslSAfANSS3GBE7pdsa3JExXf3Vn6E7kfzLHMESUavLai1AvmCSdh m3WYShBcu2trpK+6D4t7XEr/rpMWaZ5uoP95xxHmWc7DCR1Q/YMKaAVlWK4BRsuTOF+04KKBJx DlH6wUl2ieyj50c0Zkvo9RR9 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Oct 2021 06:15:57 -0700 IronPort-SDR: kl8znKX8E1Dny5O1Cgp1JI0I+vLV7V9DO7ife3qcSgzp/iuRvoF+nY223p6SsTgvDSEC5TAKwr B9G+ce4rzbdhOV/oQmJxmqmaDgo3WH+5lpF+pwCIFSRR0X3oVLu5tgoBXYLM2VDuWpuSAVDQ9P 946UgzPZy2cKQbzeUDNCgUX+iUc2ATgqFvQNJN62jFmcmVk/wJR3/DGk63YH0vGPnrycJhmEuU X7wsgbVnwHP8Bt3R36hUsfQe0nH1RxrgTjYWo2srp/h+SSbYcPoYXHYWEwq2XnU6uTnjkl29v8 OJE= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Oct 2021 06:40:22 -0700 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4HbQTL2kfZz1RtVn for ; Fri, 22 Oct 2021 06:40:22 -0700 (PDT) Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1634910021; x=1637502022; bh=5kMdTeCvBsa3k7CM+R KKt2ZHdP1vD9O2pkGibwmxjiY=; b=GYF2ntz5M+fJ7tn7kwfKgW9ERhz2EQQsam LH6rLcicsepVH1PcG1zfhplxqd1kmP8MqFRKM1yf10EdDylURHGBST9up41TAYtU kbMC5is8ITlhJTX1IHf39e9n1/Q1E9w7NBafNRI6ZzmsCkP6V5RmAbr1GQGCSm/Q yO2/5fpLu9PIBeQrtAm+wYNSEd38nBL/xslHqYcf/1a8GNe054jAVNHXQHzd4NGo T6SlSw5hICaHo2/a1tTr8jFW+GsVmUWyZWECOL/dEunhnAvYRM8Ij6QBlaQtN3Um XKWA6Fo94A7OmHkgrj2vJIdSaNmqsqzhi/mMnS1hLyJxKxmQlraw== X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id 1Jh0RxgJORVL for ; Fri, 22 Oct 2021 06:40:21 -0700 (PDT) Received: from toolbox.wdc.com (unknown [10.225.165.39]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4HbQTF4MVWz1RtVl; Fri, 22 Oct 2021 06:40:17 -0700 (PDT) From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Richard Henderson , LIU Zhiwei , Alistair Francis Subject: [PULL 20/33] target/riscv: Use gen_shift*_per_ol for RVB, RVI Date: Fri, 22 Oct 2021 23:37:59 +1000 Message-Id: <20211022133812.3972903-21-alistair.francis@opensource.wdc.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211022133812.3972903-1-alistair.francis@opensource.wdc.com> References: <20211022133812.3972903-1-alistair.francis@opensource.wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=216.71.153.144; envelope-from=prvs=9222bbd82=alistair.francis@opensource.wdc.com; helo=esa5.hgst.iphmx.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, SPF_HELO_PASS=-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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson Most shift instructions require a separate implementation for RV32 when TARGET_LONG_BITS == 64. Reviewed-by: LIU Zhiwei Reviewed-by: Alistair Francis Signed-off-by: Richard Henderson Message-id: 20211020031709.359469-14-richard.henderson@linaro.org Signed-off-by: Alistair Francis --- target/riscv/translate.c | 31 +++++++++ target/riscv/insn_trans/trans_rvb.c.inc | 92 ++++++++++++++----------- target/riscv/insn_trans/trans_rvi.c.inc | 26 +++---- 3 files changed, 97 insertions(+), 52 deletions(-) diff --git a/target/riscv/translate.c b/target/riscv/translate.c index f3a5870ad0..bed1c2174e 100644 --- a/target/riscv/translate.c +++ b/target/riscv/translate.c @@ -438,6 +438,22 @@ static bool gen_shift_imm_fn(DisasContext *ctx, arg_shift *a, DisasExtend ext, return true; } +static bool gen_shift_imm_fn_per_ol(DisasContext *ctx, arg_shift *a, + DisasExtend ext, + void (*f_tl)(TCGv, TCGv, target_long), + void (*f_32)(TCGv, TCGv, target_long)) +{ + int olen = get_olen(ctx); + if (olen != TARGET_LONG_BITS) { + if (olen == 32) { + f_tl = f_32; + } else { + g_assert_not_reached(); + } + } + return gen_shift_imm_fn(ctx, a, ext, f_tl); +} + static bool gen_shift_imm_tl(DisasContext *ctx, arg_shift *a, DisasExtend ext, void (*func)(TCGv, TCGv, TCGv)) { @@ -474,6 +490,21 @@ static bool gen_shift(DisasContext *ctx, arg_r *a, DisasExtend ext, return true; } +static bool gen_shift_per_ol(DisasContext *ctx, arg_r *a, DisasExtend ext, + void (*f_tl)(TCGv, TCGv, TCGv), + void (*f_32)(TCGv, TCGv, TCGv)) +{ + int olen = get_olen(ctx); + if (olen != TARGET_LONG_BITS) { + if (olen == 32) { + f_tl = f_32; + } else { + g_assert_not_reached(); + } + } + return gen_shift(ctx, a, ext, f_tl); +} + static bool gen_unary(DisasContext *ctx, arg_r2 *a, DisasExtend ext, void (*func)(TCGv, TCGv)) { diff --git a/target/riscv/insn_trans/trans_rvb.c.inc b/target/riscv/insn_trans/trans_rvb.c.inc index 4eb41756fa..c8d31907c5 100644 --- a/target/riscv/insn_trans/trans_rvb.c.inc +++ b/target/riscv/insn_trans/trans_rvb.c.inc @@ -227,22 +227,70 @@ static bool trans_bexti(DisasContext *ctx, arg_bexti *a) return gen_shift_imm_tl(ctx, a, EXT_NONE, gen_bext); } +static void gen_rorw(TCGv ret, TCGv arg1, TCGv arg2) +{ + TCGv_i32 t1 = tcg_temp_new_i32(); + TCGv_i32 t2 = tcg_temp_new_i32(); + + /* truncate to 32-bits */ + tcg_gen_trunc_tl_i32(t1, arg1); + tcg_gen_trunc_tl_i32(t2, arg2); + + tcg_gen_rotr_i32(t1, t1, t2); + + /* sign-extend 64-bits */ + tcg_gen_ext_i32_tl(ret, t1); + + tcg_temp_free_i32(t1); + tcg_temp_free_i32(t2); +} + static bool trans_ror(DisasContext *ctx, arg_ror *a) { REQUIRE_ZBB(ctx); - return gen_shift(ctx, a, EXT_NONE, tcg_gen_rotr_tl); + return gen_shift_per_ol(ctx, a, EXT_NONE, tcg_gen_rotr_tl, gen_rorw); +} + +static void gen_roriw(TCGv ret, TCGv arg1, target_long shamt) +{ + TCGv_i32 t1 = tcg_temp_new_i32(); + + tcg_gen_trunc_tl_i32(t1, arg1); + tcg_gen_rotri_i32(t1, t1, shamt); + tcg_gen_ext_i32_tl(ret, t1); + + tcg_temp_free_i32(t1); } static bool trans_rori(DisasContext *ctx, arg_rori *a) { REQUIRE_ZBB(ctx); - return gen_shift_imm_fn(ctx, a, EXT_NONE, tcg_gen_rotri_tl); + return gen_shift_imm_fn_per_ol(ctx, a, EXT_NONE, + tcg_gen_rotri_tl, gen_roriw); +} + +static void gen_rolw(TCGv ret, TCGv arg1, TCGv arg2) +{ + TCGv_i32 t1 = tcg_temp_new_i32(); + TCGv_i32 t2 = tcg_temp_new_i32(); + + /* truncate to 32-bits */ + tcg_gen_trunc_tl_i32(t1, arg1); + tcg_gen_trunc_tl_i32(t2, arg2); + + tcg_gen_rotl_i32(t1, t1, t2); + + /* sign-extend 64-bits */ + tcg_gen_ext_i32_tl(ret, t1); + + tcg_temp_free_i32(t1); + tcg_temp_free_i32(t2); } static bool trans_rol(DisasContext *ctx, arg_rol *a) { REQUIRE_ZBB(ctx); - return gen_shift(ctx, a, EXT_NONE, tcg_gen_rotl_tl); + return gen_shift_per_ol(ctx, a, EXT_NONE, tcg_gen_rotl_tl, gen_rolw); } static void gen_rev8_32(TCGv ret, TCGv src1) @@ -352,24 +400,6 @@ static bool trans_cpopw(DisasContext *ctx, arg_cpopw *a) return gen_unary(ctx, a, EXT_ZERO, tcg_gen_ctpop_tl); } -static void gen_rorw(TCGv ret, TCGv arg1, TCGv arg2) -{ - TCGv_i32 t1 = tcg_temp_new_i32(); - TCGv_i32 t2 = tcg_temp_new_i32(); - - /* truncate to 32-bits */ - tcg_gen_trunc_tl_i32(t1, arg1); - tcg_gen_trunc_tl_i32(t2, arg2); - - tcg_gen_rotr_i32(t1, t1, t2); - - /* sign-extend 64-bits */ - tcg_gen_ext_i32_tl(ret, t1); - - tcg_temp_free_i32(t1); - tcg_temp_free_i32(t2); -} - static bool trans_rorw(DisasContext *ctx, arg_rorw *a) { REQUIRE_64BIT(ctx); @@ -383,25 +413,7 @@ static bool trans_roriw(DisasContext *ctx, arg_roriw *a) REQUIRE_64BIT(ctx); REQUIRE_ZBB(ctx); ctx->ol = MXL_RV32; - return gen_shift_imm_tl(ctx, a, EXT_NONE, gen_rorw); -} - -static void gen_rolw(TCGv ret, TCGv arg1, TCGv arg2) -{ - TCGv_i32 t1 = tcg_temp_new_i32(); - TCGv_i32 t2 = tcg_temp_new_i32(); - - /* truncate to 32-bits */ - tcg_gen_trunc_tl_i32(t1, arg1); - tcg_gen_trunc_tl_i32(t2, arg2); - - tcg_gen_rotl_i32(t1, t1, t2); - - /* sign-extend 64-bits */ - tcg_gen_ext_i32_tl(ret, t1); - - tcg_temp_free_i32(t1); - tcg_temp_free_i32(t2); + return gen_shift_imm_fn(ctx, a, EXT_NONE, gen_roriw); } static bool trans_rolw(DisasContext *ctx, arg_rolw *a) diff --git a/target/riscv/insn_trans/trans_rvi.c.inc b/target/riscv/insn_trans/trans_rvi.c.inc index 9cf0383cfb..91dc438a3a 100644 --- a/target/riscv/insn_trans/trans_rvi.c.inc +++ b/target/riscv/insn_trans/trans_rvi.c.inc @@ -268,14 +268,26 @@ static bool trans_slli(DisasContext *ctx, arg_slli *a) return gen_shift_imm_fn(ctx, a, EXT_NONE, tcg_gen_shli_tl); } +static void gen_srliw(TCGv dst, TCGv src, target_long shamt) +{ + tcg_gen_extract_tl(dst, src, shamt, 32 - shamt); +} + static bool trans_srli(DisasContext *ctx, arg_srli *a) { - return gen_shift_imm_fn(ctx, a, EXT_ZERO, tcg_gen_shri_tl); + return gen_shift_imm_fn_per_ol(ctx, a, EXT_NONE, + tcg_gen_shri_tl, gen_srliw); +} + +static void gen_sraiw(TCGv dst, TCGv src, target_long shamt) +{ + tcg_gen_sextract_tl(dst, src, shamt, 32 - shamt); } static bool trans_srai(DisasContext *ctx, arg_srai *a) { - return gen_shift_imm_fn(ctx, a, EXT_SIGN, tcg_gen_sari_tl); + return gen_shift_imm_fn_per_ol(ctx, a, EXT_NONE, + tcg_gen_sari_tl, gen_sraiw); } static bool trans_add(DisasContext *ctx, arg_add *a) @@ -342,11 +354,6 @@ static bool trans_slliw(DisasContext *ctx, arg_slliw *a) return gen_shift_imm_fn(ctx, a, EXT_NONE, tcg_gen_shli_tl); } -static void gen_srliw(TCGv dst, TCGv src, target_long shamt) -{ - tcg_gen_extract_tl(dst, src, shamt, 32 - shamt); -} - static bool trans_srliw(DisasContext *ctx, arg_srliw *a) { REQUIRE_64BIT(ctx); @@ -354,11 +361,6 @@ static bool trans_srliw(DisasContext *ctx, arg_srliw *a) return gen_shift_imm_fn(ctx, a, EXT_NONE, gen_srliw); } -static void gen_sraiw(TCGv dst, TCGv src, target_long shamt) -{ - tcg_gen_sextract_tl(dst, src, shamt, 32 - shamt); -} - static bool trans_sraiw(DisasContext *ctx, arg_sraiw *a) { REQUIRE_64BIT(ctx); From patchwork Fri Oct 22 13:38:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 1544956 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=wdc.com header.i=@wdc.com header.a=rsa-sha256 header.s=dkim.wdc.com header.b=CQTS8kCu; dkim=pass (2048-bit key; unprotected) header.d=opensource.wdc.com header.i=@opensource.wdc.com header.a=rsa-sha256 header.s=dkim header.b=ePzcD/Jc; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4HbQpL3t7Jz9sXN for ; Sat, 23 Oct 2021 00:55:06 +1100 (AEDT) Received: from localhost ([::1]:58282 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mdv0i-00031d-6g for incoming@patchwork.ozlabs.org; Fri, 22 Oct 2021 09:55:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57458) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mdumc-0001oF-Cy for qemu-devel@nongnu.org; Fri, 22 Oct 2021 09:40:30 -0400 Received: from esa5.hgst.iphmx.com ([216.71.153.144]:39690) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mdumZ-0001Qs-UT for qemu-devel@nongnu.org; Fri, 22 Oct 2021 09:40:30 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1634910026; x=1666446026; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=NukPHe0iX3t5gd8afqd9RhYtpIE/sHpPRoxsNoRCGq4=; b=CQTS8kCuq5Cioi2N89Sf77dKIG/lposRux1oFyLOtZuBIHk5rCLvjxs5 uj2cFzMiaxFZeJwF3fevOCeu9y7dwUqeGuCJAqCm8O5Tbn5iRXXjnJ9vt kWkgLmaj30RDXMJeCZ181QFzM6sRFGRnv1YmW6y4lSIVxvonnqjurGWBh 2IPEvW9saUwmShVggjuppHto7rqb7UyCwNiGHKYmMRxWNZMiadsCajYCw 8S2MHjpdIIZDXOZFGS8VAN7hYAu6R17l2XpnaNDks47BfAeCumtABTyLA P7RNTev32PawtA/PYI5j/ROR6A+BJATYz4+magW0k+M27AZyA0Ih0Em7X g==; X-IronPort-AV: E=Sophos;i="5.87,172,1631548800"; d="scan'208";a="183617893" Received: from h199-255-45-14.hgst.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 22 Oct 2021 21:40:25 +0800 IronPort-SDR: oRV9JD/ZVhgo439QA30m3U+KGztaWZg/uYH/Rkjqv2eO3yqMC9uOjctD3hrRiwA70EJ4S2l/I3 jXG7dtBG7hvooYmLqKSAKx9ZGFMoa1C8sgGPFFqGyurTnh75fIO5uUq/LAqPUg6nxpRzdBwpQZ h3JOg5JW/tTNyepoWLOPpWj57fOiP5qy5D99lGdyFFYQnk7eViAvPRfZpCXCo7v2tQLvspjsY8 O+0GOVCeR37p8G9oileb57FtDNlpyIB8oijd4DaB9Yw+cv9sIV7CP3F8bDUQlObYzDUBi+YvPa L6Cs/L0EKobAle+e76C29YN/ Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Oct 2021 06:16:01 -0700 IronPort-SDR: REF48Jri0nfK6XtJs+MMf7YG/l0UWpe/Bu7Ddsibnp29zDy4flbJI2Pl+KTiUBIUvYh3dA0BUk fbuVBugWJYh5AiIW8vqkCSd00Kpkrh2I97wl7uS2TMmA4lJ4Zybz75UfzP1NoT/FlKZ9Bx/rIN 8FQ2MMLMC3uCCOThKkLghwedBBap4ISJgcmjc3oGDcGcf+THE9fRLBk41WREaez/awKyHp6OIy wnGXuGjcz5T/ogIVh4wv/1nzfWbNI8aEdGhSkrF735TWpF2Cvmlmpjn3A9ntQARlkr1/fzraV9 phs= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Oct 2021 06:40:27 -0700 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4HbQTQ69rQz1RtVm for ; Fri, 22 Oct 2021 06:40:26 -0700 (PDT) Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1634910026; x=1637502027; bh=NukPHe0iX3t5gd8afq d9RhYtpIE/sHpPRoxsNoRCGq4=; b=ePzcD/Jc3FfE9X5DTSGPF/PTzU8K0LZzT4 pGWQ7HPaRwJjrN2GxPFCMWv79LABAuH28Cft4Di+Et0QEbVIFAv3s6azq7jtAjQi a6Xnd1Jo/oJj7E5r/I+pE6DhruRVhGFuDL4xF+HCEQeWihI4HtrjDMfWhLD6gwra ncacOQ73xuLOAz23YjaUR5sGTFwdGX3M8ONzKcM8jnWAbXI6egmLT6GwJFF5w69c +hn96+l/ZlMMTYhIcysTkmwId8xBvhGP7qvmTlwFWQ+AuPndzp6NFPOZwVXYo5QP aC9fYFqdq4zH+nQe/IKDiT+dx94jgGRvPp5f+rUrp8k8tnjQj2dA== X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id 5Xr-a8PHU_3E for ; Fri, 22 Oct 2021 06:40:26 -0700 (PDT) Received: from toolbox.wdc.com (unknown [10.225.165.39]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4HbQTL6PVxz1RtVl; Fri, 22 Oct 2021 06:40:22 -0700 (PDT) From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Richard Henderson , Alistair Francis Subject: [PULL 21/33] target/riscv: Use riscv_csrrw_debug for cpu_dump Date: Fri, 22 Oct 2021 23:38:00 +1000 Message-Id: <20211022133812.3972903-22-alistair.francis@opensource.wdc.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211022133812.3972903-1-alistair.francis@opensource.wdc.com> References: <20211022133812.3972903-1-alistair.francis@opensource.wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=216.71.153.144; envelope-from=prvs=9222bbd82=alistair.francis@opensource.wdc.com; helo=esa5.hgst.iphmx.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, SPF_HELO_PASS=-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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson Use the official debug read interface to the csrs, rather than referencing the env slots directly. Put the list of csrs to dump into a table. Reviewed-by: Alistair Francis Signed-off-by: Richard Henderson Message-id: 20211020031709.359469-15-richard.henderson@linaro.org Signed-off-by: Alistair Francis --- target/riscv/cpu.c | 89 +++++++++++++++++++++++----------------------- 1 file changed, 45 insertions(+), 44 deletions(-) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index dd9eccd68e..788fa0b11c 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -242,51 +242,52 @@ static void riscv_cpu_dump_state(CPUState *cs, FILE *f, int flags) #endif qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "pc ", env->pc); #ifndef CONFIG_USER_ONLY - qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "mhartid ", env->mhartid); - qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "mstatus ", (target_ulong)env->mstatus); - if (riscv_cpu_mxl(env) == MXL_RV32) { - qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "mstatush ", - (target_ulong)(env->mstatus >> 32)); - } - if (riscv_has_ext(env, RVH)) { - qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "hstatus ", env->hstatus); - qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "vsstatus", - (target_ulong)env->vsstatus); - } - qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "mip ", env->mip); - qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "mie ", env->mie); - qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "mideleg ", env->mideleg); - if (riscv_has_ext(env, RVH)) { - qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "hideleg ", env->hideleg); - } - qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "medeleg ", env->medeleg); - if (riscv_has_ext(env, RVH)) { - qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "hedeleg ", env->hedeleg); - } - qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "mtvec ", env->mtvec); - qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "stvec ", env->stvec); - if (riscv_has_ext(env, RVH)) { - qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "vstvec ", env->vstvec); - } - qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "mepc ", env->mepc); - qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "sepc ", env->sepc); - if (riscv_has_ext(env, RVH)) { - qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "vsepc ", env->vsepc); - } - qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "mcause ", env->mcause); - qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "scause ", env->scause); - if (riscv_has_ext(env, RVH)) { - qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "vscause ", env->vscause); - } - qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "mtval ", env->mtval); - qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "stval ", env->stval); - if (riscv_has_ext(env, RVH)) { - qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "htval ", env->htval); - qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "mtval2 ", env->mtval2); + { + static const int dump_csrs[] = { + CSR_MHARTID, + CSR_MSTATUS, + CSR_MSTATUSH, + CSR_HSTATUS, + CSR_VSSTATUS, + CSR_MIP, + CSR_MIE, + CSR_MIDELEG, + CSR_HIDELEG, + CSR_MEDELEG, + CSR_HEDELEG, + CSR_MTVEC, + CSR_STVEC, + CSR_VSTVEC, + CSR_MEPC, + CSR_SEPC, + CSR_VSEPC, + CSR_MCAUSE, + CSR_SCAUSE, + CSR_VSCAUSE, + CSR_MTVAL, + CSR_STVAL, + CSR_HTVAL, + CSR_MTVAL2, + CSR_MSCRATCH, + CSR_SSCRATCH, + CSR_SATP, + }; + + for (int i = 0; i < ARRAY_SIZE(dump_csrs); ++i) { + int csrno = dump_csrs[i]; + target_ulong val = 0; + RISCVException res = riscv_csrrw_debug(env, csrno, &val, 0, 0); + + /* + * Rely on the smode, hmode, etc, predicates within csr.c + * to do the filtering of the registers that are present. + */ + if (res == RISCV_EXCP_NONE) { + qemu_fprintf(f, " %-8s " TARGET_FMT_lx "\n", + csr_ops[csrno].name, val); + } + } } - qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "mscratch", env->mscratch); - qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "sscratch", env->sscratch); - qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "satp ", env->satp); #endif for (i = 0; i < 32; i++) { From patchwork Fri Oct 22 13:38:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 1544962 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=wdc.com header.i=@wdc.com header.a=rsa-sha256 header.s=dkim.wdc.com header.b=ovx/MyhX; dkim=pass (2048-bit key; unprotected) header.d=opensource.wdc.com header.i=@opensource.wdc.com header.a=rsa-sha256 header.s=dkim header.b=PasnbfC1; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4HbQxY6DSLz9sRR for ; Sat, 23 Oct 2021 01:01:21 +1100 (AEDT) Received: from localhost ([::1]:44958 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mdv6l-0004oP-Ip for incoming@patchwork.ozlabs.org; Fri, 22 Oct 2021 10:01:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57484) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mdumg-0001pO-TP for qemu-devel@nongnu.org; Fri, 22 Oct 2021 09:40:35 -0400 Received: from esa5.hgst.iphmx.com ([216.71.153.144]:39690) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mdume-0001Qs-Hd for qemu-devel@nongnu.org; Fri, 22 Oct 2021 09:40:34 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1634910031; x=1666446031; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=4DS/XWr3pNjpqgLBujVnjAyIdXduE58PjNTGgxFTWEo=; b=ovx/MyhXjkXaaIREObIcW6B+oYIPxNmFSnwYkD835IRzeaYnSKoQG8Gq Nik80ikYGAzXLutBGjfVc1LlSnBzJvP+gMeaEqXlNRPb5vbNku/0ZqmKc tTrQh9D2XAeSRufjJsv65wYmP3uMXX6IRQF+9g3h8D6Kr4BK8yeXrkhio oMx2ns6g6ZB9OfP8AR4yzVQ4SAkGmYK29VAwwnkvOpwLnZHUmS7zU3hCh kmrHnb5Ybf0+IZZ6CtCToIfHrQ3vYGU5fH9HkMXDqwQcfqOU7pRuKvBFX GGqZ8JxXAnD6tAY6An4Q9FR0WcaQbAJNXFS7PE04S3NmZhp8ExQyz24tt A==; X-IronPort-AV: E=Sophos;i="5.87,172,1631548800"; d="scan'208";a="183617898" Received: from h199-255-45-14.hgst.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 22 Oct 2021 21:40:30 +0800 IronPort-SDR: cFGNN7LcRtIkp4P5ecpbyJ/xLy3P27nrpkiS22V08EJgmchafsxgFIrBVEQ3v2cpzk0KIQIdqF wRGICq0mieQ2T5FqB0kfMaZBDp/x0npXvvTs0Ym+WFicVSZHa8K28HUjbgY/UyksCTzD8wKXMh 9I46edgN5fD6z7izn5bXCGhYbXwrOS6vgPu5eWo1HG1Ksd4hQq0ItHiPYlOV9cF4hYi1ODELJS MAscFhBBdTVVBZ4fVkep5VwyaNN3srzNRTWP/J6mdfdTlNdvN415Wq4e+dSpVTlQGT5H9SEWFe SxPCgBV7KWpUv4RmuIfXo6iT Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Oct 2021 06:16:06 -0700 IronPort-SDR: 3bF9b45U+KdAanXmGFFBZYQE/pIoOjZZ1WLlA0hVdzj/g1Lr+7ceGfCXeMceHqXf6MQvZ1idjW hD7BPvgs/wDpdj/yJVCVHqi4bulDGevsZ+1bMHzx+N8tbkBpIIU+u4d5Ugpjkwt8BDBYSQcWv2 MABN1sGGO3ugb66Sg0w8AUhA4f4PSd87sIj3O0DXX04JtHu2nWShdfd7XendnMEr9SQwxxD/Sz +VWwxaCm7XfdMOqkquqt8md3AJei1uAQKoFmKnTfuTWKsdN+7ag1hZVmJEsRjymf6WFIeOAyHE Q9s= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Oct 2021 06:40:32 -0700 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4HbQTW4DCnz1RtVn for ; Fri, 22 Oct 2021 06:40:31 -0700 (PDT) Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1634910031; x=1637502032; bh=4DS/XWr3pNjpqgLBuj VnjAyIdXduE58PjNTGgxFTWEo=; b=PasnbfC18qRHh3IvS73qg3+V1KN8SrzdOb 9w71ySwTpm00kzXc+YYVZL39R2F+Ki2oWJO3/OO4P3qPjnoo+y2VvuIZ8nErB7e/ bUSC8M08JR738BeZJIj+WXTbUr5YnTLw3pZOYlupCP9D2w2yjQ+I9goNgxkQZC9o 89iZ23JRCm6efg+L1YnxKncoesQ4sWFL0fjR8ZCLHcobCywKGIvhbMRgaqFW2/dj UXY0cHg8sO9TF/3kVi9i7ILq1nBeOK1/Qd+N/Hd4VV/ADPfWH/fJGqrObpluSHeg /4OGQ2p1v1Evu/4602FUjCJ6tipKBTKCbFatZXpqU4ORzj/+EQQA== X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id oUlvDIMJA908 for ; Fri, 22 Oct 2021 06:40:31 -0700 (PDT) Received: from toolbox.wdc.com (unknown [10.225.165.39]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4HbQTR4c5rz1RtVl; Fri, 22 Oct 2021 06:40:27 -0700 (PDT) From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Richard Henderson , Alistair Francis Subject: [PULL 22/33] target/riscv: Compute mstatus.sd on demand Date: Fri, 22 Oct 2021 23:38:01 +1000 Message-Id: <20211022133812.3972903-23-alistair.francis@opensource.wdc.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211022133812.3972903-1-alistair.francis@opensource.wdc.com> References: <20211022133812.3972903-1-alistair.francis@opensource.wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=216.71.153.144; envelope-from=prvs=9222bbd82=alistair.francis@opensource.wdc.com; helo=esa5.hgst.iphmx.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, SPF_HELO_PASS=-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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson The position of this read-only field is dependent on the current xlen. Rather than having to compute that difference in many places, compute it only on read. Reviewed-by: Alistair Francis Signed-off-by: Richard Henderson Message-id: 20211020031709.359469-16-richard.henderson@linaro.org Signed-off-by: Alistair Francis --- target/riscv/cpu_helper.c | 3 +-- target/riscv/csr.c | 37 ++++++++++++++++++++++--------------- target/riscv/translate.c | 5 ++--- 3 files changed, 25 insertions(+), 20 deletions(-) diff --git a/target/riscv/cpu_helper.c b/target/riscv/cpu_helper.c index 429afd1f48..0d1132f39d 100644 --- a/target/riscv/cpu_helper.c +++ b/target/riscv/cpu_helper.c @@ -185,10 +185,9 @@ bool riscv_cpu_fp_enabled(CPURISCVState *env) void riscv_cpu_swap_hypervisor_regs(CPURISCVState *env) { - uint64_t sd = riscv_cpu_mxl(env) == MXL_RV32 ? MSTATUS32_SD : MSTATUS64_SD; uint64_t mstatus_mask = MSTATUS_MXR | MSTATUS_SUM | MSTATUS_FS | MSTATUS_SPP | MSTATUS_SPIE | MSTATUS_SIE | - MSTATUS64_UXL | sd; + MSTATUS64_UXL; bool current_virt = riscv_cpu_virt_enabled(env); g_assert(riscv_has_ext(env, RVH)); diff --git a/target/riscv/csr.c b/target/riscv/csr.c index c4a479ddd2..69e4d65fcd 100644 --- a/target/riscv/csr.c +++ b/target/riscv/csr.c @@ -477,10 +477,28 @@ static RISCVException read_mhartid(CPURISCVState *env, int csrno, } /* Machine Trap Setup */ + +/* We do not store SD explicitly, only compute it on demand. */ +static uint64_t add_status_sd(RISCVMXL xl, uint64_t status) +{ + if ((status & MSTATUS_FS) == MSTATUS_FS || + (status & MSTATUS_XS) == MSTATUS_XS) { + switch (xl) { + case MXL_RV32: + return status | MSTATUS32_SD; + case MXL_RV64: + return status | MSTATUS64_SD; + default: + g_assert_not_reached(); + } + } + return status; +} + static RISCVException read_mstatus(CPURISCVState *env, int csrno, target_ulong *val) { - *val = env->mstatus; + *val = add_status_sd(riscv_cpu_mxl(env), env->mstatus); return RISCV_EXCP_NONE; } @@ -498,7 +516,6 @@ static RISCVException write_mstatus(CPURISCVState *env, int csrno, { uint64_t mstatus = env->mstatus; uint64_t mask = 0; - int dirty; /* flush tlb on mstatus fields that affect VM */ if ((val ^ mstatus) & (MSTATUS_MXR | MSTATUS_MPP | MSTATUS_MPV | @@ -520,12 +537,7 @@ static RISCVException write_mstatus(CPURISCVState *env, int csrno, mstatus = (mstatus & ~mask) | (val & mask); - dirty = ((mstatus & MSTATUS_FS) == MSTATUS_FS) | - ((mstatus & MSTATUS_XS) == MSTATUS_XS); - if (riscv_cpu_mxl(env) == MXL_RV32) { - mstatus = set_field(mstatus, MSTATUS32_SD, dirty); - } else { - mstatus = set_field(mstatus, MSTATUS64_SD, dirty); + if (riscv_cpu_mxl(env) == MXL_RV64) { /* SXL and UXL fields are for now read only */ mstatus = set_field(mstatus, MSTATUS64_SXL, MXL_RV64); mstatus = set_field(mstatus, MSTATUS64_UXL, MXL_RV64); @@ -798,13 +810,8 @@ static RISCVException read_sstatus(CPURISCVState *env, int csrno, { target_ulong mask = (sstatus_v1_10_mask); - if (riscv_cpu_mxl(env) == MXL_RV32) { - mask |= SSTATUS32_SD; - } else { - mask |= SSTATUS64_SD; - } - - *val = env->mstatus & mask; + /* TODO: Use SXL not MXL. */ + *val = add_status_sd(riscv_cpu_mxl(env), env->mstatus & mask); return RISCV_EXCP_NONE; } diff --git a/target/riscv/translate.c b/target/riscv/translate.c index bed1c2174e..d38f87d718 100644 --- a/target/riscv/translate.c +++ b/target/riscv/translate.c @@ -280,7 +280,6 @@ static void gen_jal(DisasContext *ctx, int rd, target_ulong imm) static void mark_fs_dirty(DisasContext *ctx) { TCGv tmp; - target_ulong sd = get_xl(ctx) == MXL_RV32 ? MSTATUS32_SD : MSTATUS64_SD; if (ctx->mstatus_fs != MSTATUS_FS) { /* Remember the state change for the rest of the TB. */ @@ -288,7 +287,7 @@ static void mark_fs_dirty(DisasContext *ctx) tmp = tcg_temp_new(); tcg_gen_ld_tl(tmp, cpu_env, offsetof(CPURISCVState, mstatus)); - tcg_gen_ori_tl(tmp, tmp, MSTATUS_FS | sd); + tcg_gen_ori_tl(tmp, tmp, MSTATUS_FS); tcg_gen_st_tl(tmp, cpu_env, offsetof(CPURISCVState, mstatus)); tcg_temp_free(tmp); } @@ -299,7 +298,7 @@ static void mark_fs_dirty(DisasContext *ctx) tmp = tcg_temp_new(); tcg_gen_ld_tl(tmp, cpu_env, offsetof(CPURISCVState, mstatus_hs)); - tcg_gen_ori_tl(tmp, tmp, MSTATUS_FS | sd); + tcg_gen_ori_tl(tmp, tmp, MSTATUS_FS); tcg_gen_st_tl(tmp, cpu_env, offsetof(CPURISCVState, mstatus_hs)); tcg_temp_free(tmp); } From patchwork Fri Oct 22 13:38:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 1544965 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=wdc.com header.i=@wdc.com header.a=rsa-sha256 header.s=dkim.wdc.com header.b=K+9ukvZN; dkim=pass (2048-bit key; unprotected) header.d=opensource.wdc.com header.i=@opensource.wdc.com header.a=rsa-sha256 header.s=dkim header.b=EeKLqG8P; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4HbR0l116hz9sRR for ; Sat, 23 Oct 2021 01:04:07 +1100 (AEDT) Received: from localhost ([::1]:52782 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mdv9Q-0001lL-S7 for incoming@patchwork.ozlabs.org; Fri, 22 Oct 2021 10:04:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57512) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mduml-0001rI-HR for qemu-devel@nongnu.org; Fri, 22 Oct 2021 09:40:39 -0400 Received: from esa5.hgst.iphmx.com ([216.71.153.144]:39690) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mdumj-0001Qs-7I for qemu-devel@nongnu.org; Fri, 22 Oct 2021 09:40:39 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1634910036; x=1666446036; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=dwlquLthjZX05TmT+2s13vlTEdXzJHoYR1quCMUbtY8=; b=K+9ukvZNOcT0Jw86KoTfq2BRPMyKqBBvHKEvYafFbMAx4XNpVtEAVxbl 9t1Q4ZqYgNM6RuI8LZGZ+VUFXyA+CCnAqFjVEK+x0nP/NCe5X90B2ucIf M5glzCp5MOXxWcplcNTRfACQEPwnUSwNUa682NgbSrCjqUUGcFsK33E1c nIqpfD+0uvOn0LOWZnG+3VdsBUKJLARJ/Q7sq4In50d9vsZM6zMIE1CEN YfOfJDAvew4+qxTkK+cGTcfS/katogGIc7nhHZHZA896hnQ520wis5RAc YuM0ICFNXdobyFLjwi7JUvypFYSz1SYlFNMqAtF5Xt2UCD2UhvTlgja5k Q==; X-IronPort-AV: E=Sophos;i="5.87,172,1631548800"; d="scan'208";a="183617900" Received: from h199-255-45-14.hgst.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 22 Oct 2021 21:40:35 +0800 IronPort-SDR: tbHUpoc90/rJXWocGQVOpGS5nvIAvkgFRjUb2ugnY+LmEh6ckPPZ+HjTSJHQcYx98g1/fm1mjb rrW6hiAKSMXujnzZwpIVRYRM0pOjiErIFUNSt25QxSZjbrBLZNnHKE09k2/KSgMhcLxm+8Lpsi de6y51TeK+xF7cs3qclAdSdQsN//5kWj6ThFD+gw9AXWz+egx/v1AtGwj1nfFKpf47+wPBfCHo hYJMabb2IYmoceQL1+DzZGdRvl+8Sn852hLYRcIUecjEcUgM+1LST7rsk9TZP8bWbqiEykhTLy 5UDIeag9rOYkR9JDjHWnFAVc Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Oct 2021 06:16:11 -0700 IronPort-SDR: dj4KRTpx8JURfM+uTVNmTL0gBCYddmQAfr6s/nsu9ZnEkPJjyHETHZC7C5ru96K4Lv3SqkE/8N z2RYLL2hehN0ZK+xASbhnNALzD2VaJK2wSah2KSsIk7usYud8xpeMiqk3wqVZWC8BJJuxbX2yT gT9IIULEaN1GG5VuNWKox/skeGBeoSzJzTVrjDMhNGQaVuY+nCUFv1LWCWpWVvhTNoakf39GUj HiexS8oM5Y216qyuweJPasb8ZFTkf8c9byzQnuu5ZOpKqdU2MCn1Y9gilw7ZDN3VYbkejpLWPW 9aE= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Oct 2021 06:40:36 -0700 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4HbQTc1RZVz1RtVt for ; Fri, 22 Oct 2021 06:40:36 -0700 (PDT) Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1634910035; x=1637502036; bh=dwlquLthjZX05TmT+2 s13vlTEdXzJHoYR1quCMUbtY8=; b=EeKLqG8PV3ddB1bCn8ZEzxlfQJOTe/aXUS 6iZfCDpvS27CWH4v6dSIBNMpAT+8RWLvwHoga3ZniEJt08wS077jaYD+AIejJWfq qpWH0Ec98viFn6HkNCTWC0bGiDs7GKcg8C84d75qjaC+AIRV2ceu6TohadS8aqqf z5vZPUgkwCd9QNGN5KsiYzLPkhs1nELgVKndNro7ZnvTzjcwgzl2+5cu6s2Is8Dr 7f7j8jL/LnTRUUgxABJaTz6Y1Bt5NLMsHRU3nev0if1z+7wi6foeImaQu3hLGWII 8zf3bx3zpDLlqXx4bMsrHB/DWBccG4vJdrKMrJdx+kbzeBXWvIlA== X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id UrYcejofUIyr for ; Fri, 22 Oct 2021 06:40:35 -0700 (PDT) Received: from toolbox.wdc.com (unknown [10.225.165.39]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4HbQTX28MNz1RtVl; Fri, 22 Oct 2021 06:40:31 -0700 (PDT) From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Alistair Francis , Bin Meng Subject: [PULL 23/33] hw/riscv: opentitan: Update to the latest build Date: Fri, 22 Oct 2021 23:38:02 +1000 Message-Id: <20211022133812.3972903-24-alistair.francis@opensource.wdc.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211022133812.3972903-1-alistair.francis@opensource.wdc.com> References: <20211022133812.3972903-1-alistair.francis@opensource.wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=216.71.153.144; envelope-from=prvs=9222bbd82=alistair.francis@opensource.wdc.com; helo=esa5.hgst.iphmx.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, SPF_HELO_PASS=-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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Alistair Francis Update the OpenTitan machine model to match the latest OpenTitan FPGA design. Signed-off-by: Alistair Francis Reviewed-by: Bin Meng Message-id: 18b1b681b0f8dd2461e819d1217bf0b530812680.1634524691.git.alistair.francis@wdc.com --- include/hw/riscv/opentitan.h | 6 +++--- hw/riscv/opentitan.c | 22 +++++++++++++++++----- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/include/hw/riscv/opentitan.h b/include/hw/riscv/opentitan.h index 9f93bebdac..eac35ef590 100644 --- a/include/hw/riscv/opentitan.h +++ b/include/hw/riscv/opentitan.h @@ -20,7 +20,7 @@ #define HW_OPENTITAN_H #include "hw/riscv/riscv_hart.h" -#include "hw/intc/ibex_plic.h" +#include "hw/intc/sifive_plic.h" #include "hw/char/ibex_uart.h" #include "hw/timer/ibex_timer.h" #include "qom/object.h" @@ -34,7 +34,7 @@ struct LowRISCIbexSoCState { /*< public >*/ RISCVHartArrayState cpus; - IbexPlicState plic; + SiFivePLICState plic; IbexUartState uart; IbexTimerState timer; @@ -87,7 +87,7 @@ enum { }; enum { - IBEX_TIMER_TIMEREXPIRED0_0 = 125, + IBEX_TIMER_TIMEREXPIRED0_0 = 126, IBEX_UART0_RX_PARITY_ERR_IRQ = 8, IBEX_UART0_RX_TIMEOUT_IRQ = 7, IBEX_UART0_RX_BREAK_ERR_IRQ = 6, diff --git a/hw/riscv/opentitan.c b/hw/riscv/opentitan.c index 9803ae6d70..601f8deebe 100644 --- a/hw/riscv/opentitan.c +++ b/hw/riscv/opentitan.c @@ -46,19 +46,19 @@ static const MemMapEntry ibex_memmap[] = { [IBEX_DEV_PINMUX] = { 0x40460000, 0x1000 }, [IBEX_DEV_PADCTRL] = { 0x40470000, 0x1000 }, [IBEX_DEV_FLASH_CTRL] = { 0x41000000, 0x1000 }, - [IBEX_DEV_PLIC] = { 0x41010000, 0x1000 }, [IBEX_DEV_AES] = { 0x41100000, 0x1000 }, [IBEX_DEV_HMAC] = { 0x41110000, 0x1000 }, [IBEX_DEV_KMAC] = { 0x41120000, 0x1000 }, - [IBEX_DEV_KEYMGR] = { 0x41130000, 0x1000 }, + [IBEX_DEV_OTBN] = { 0x41130000, 0x10000 }, + [IBEX_DEV_KEYMGR] = { 0x41140000, 0x1000 }, [IBEX_DEV_CSRNG] = { 0x41150000, 0x1000 }, [IBEX_DEV_ENTROPY] = { 0x41160000, 0x1000 }, [IBEX_DEV_EDNO] = { 0x41170000, 0x1000 }, [IBEX_DEV_EDN1] = { 0x41180000, 0x1000 }, [IBEX_DEV_ALERT_HANDLER] = { 0x411b0000, 0x1000 }, [IBEX_DEV_NMI_GEN] = { 0x411c0000, 0x1000 }, - [IBEX_DEV_OTBN] = { 0x411d0000, 0x10000 }, [IBEX_DEV_PERI] = { 0x411f0000, 0x10000 }, + [IBEX_DEV_PLIC] = { 0x48000000, 0x4005000 }, [IBEX_DEV_FLASH_VIRTUAL] = { 0x80000000, 0x80000 }, }; @@ -105,7 +105,7 @@ static void lowrisc_ibex_soc_init(Object *obj) object_initialize_child(obj, "cpus", &s->cpus, TYPE_RISCV_HART_ARRAY); - object_initialize_child(obj, "plic", &s->plic, TYPE_IBEX_PLIC); + object_initialize_child(obj, "plic", &s->plic, TYPE_SIFIVE_PLIC); object_initialize_child(obj, "uart", &s->uart, TYPE_IBEX_UART); @@ -145,6 +145,18 @@ static void lowrisc_ibex_soc_realize(DeviceState *dev_soc, Error **errp) &s->flash_alias); /* PLIC */ + qdev_prop_set_string(DEVICE(&s->plic), "hart-config", "M"); + qdev_prop_set_uint32(DEVICE(&s->plic), "hartid-base", 0); + qdev_prop_set_uint32(DEVICE(&s->plic), "num-sources", 180); + qdev_prop_set_uint32(DEVICE(&s->plic), "num-priorities", 3); + qdev_prop_set_uint32(DEVICE(&s->plic), "priority-base", 0x00); + qdev_prop_set_uint32(DEVICE(&s->plic), "pending-base", 0x1000); + qdev_prop_set_uint32(DEVICE(&s->plic), "enable-base", 0x2000); + qdev_prop_set_uint32(DEVICE(&s->plic), "enable-stride", 0x18); + qdev_prop_set_uint32(DEVICE(&s->plic), "context-base", 0x200004); + qdev_prop_set_uint32(DEVICE(&s->plic), "context-stride", 4); + qdev_prop_set_uint32(DEVICE(&s->plic), "aperture-size", memmap[IBEX_DEV_PLIC].size); + if (!sysbus_realize(SYS_BUS_DEVICE(&s->plic), errp)) { return; } @@ -153,7 +165,7 @@ static void lowrisc_ibex_soc_realize(DeviceState *dev_soc, Error **errp) for (i = 0; i < ms->smp.cpus; i++) { CPUState *cpu = qemu_get_cpu(i); - qdev_connect_gpio_out(DEVICE(&s->plic), i, + qdev_connect_gpio_out(DEVICE(&s->plic), ms->smp.cpus + i, qdev_get_gpio_in(DEVICE(cpu), IRQ_M_EXT)); } From patchwork Fri Oct 22 13:38:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 1544955 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=wdc.com header.i=@wdc.com header.a=rsa-sha256 header.s=dkim.wdc.com header.b=gpwvdncl; dkim=pass (2048-bit key; unprotected) header.d=opensource.wdc.com header.i=@opensource.wdc.com header.a=rsa-sha256 header.s=dkim header.b=a/0OdOtQ; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4HbQpH4dTHz9sRN for ; Sat, 23 Oct 2021 00:55:03 +1100 (AEDT) Received: from localhost ([::1]:57862 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mdv0f-0002kY-DR for incoming@patchwork.ozlabs.org; Fri, 22 Oct 2021 09:55:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57804) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mdunZ-0003jQ-P9 for qemu-devel@nongnu.org; Fri, 22 Oct 2021 09:41:30 -0400 Received: from esa5.hgst.iphmx.com ([216.71.153.144]:39747) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mdunJ-0001mq-3s for qemu-devel@nongnu.org; Fri, 22 Oct 2021 09:41:29 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1634910072; x=1666446072; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=LCcE0zjgkxwj+gyc4Q8A5JZOBrGg2809Z4KHmI2jDN8=; b=gpwvdnclu8xg8NaFn4dU1NR20xigNmT3vQABuq3Fjx/EZJhp1LrdbMxL TwpuYAZSKyAIXFaebkPiaftq/sxt+gW2XGsPFPgb7gWu8OCPsZysSjQ2V pwr2GPVOeC8hkV0APJJN3vawMlBuXF8jOo59wAbO+D3Ou3S936hmOmu3c 752j9HMchpm80x4fqUKaae5KfVfx8WqlDV4PCk2FghGcjtk0mTngwj8Zf av45ak+YPH5DKuESupRTMHBHfaQvYVn6G54dIgY4vqoNpS/6AKLi3z6BL zXuk2KrhRNbnv74rzjoyjy2GFdz/lzISmQ23FKjqHRvun/Ds8UQYpxSbt Q==; X-IronPort-AV: E=Sophos;i="5.87,173,1631548800"; d="scan'208";a="183617908" Received: from h199-255-45-14.hgst.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 22 Oct 2021 21:40:42 +0800 IronPort-SDR: y6+6u8gwkBluEelXnjQd5Ga/MRsVXYV4muQnrVAlLRJFpVKJ3FHM64IUBI8h405qUDLBYE+Pof Lz6rBjxZS9ilDCQGLLY7DzCDPQAFldnQH3br4I8s7o01O9m4WKkxnak0iToFpgD+ZF2DAGuJQr Ae+PPEAgfeFaMia32FQp+tsC7fTG7NtmkYDEBcwtSt7yf+RYlauKN1abVtaofMOjbKbqV8pfnT CYYNQlq/beTiS8msiMzT5JTthThxT5c37+fElxThgv7H3XDcehuDSUq4ibArHvVflOikTB1IO5 /fqYfqsGJuDWEzfNRH1g2+UE Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Oct 2021 06:16:18 -0700 IronPort-SDR: ua1M0WDcF2PG6qBe7NDJGVdD0YM2HN2igFZdQtxKefPV/msl8K6bqebUX53eR2PqcmBqcTvAGK rSK0zGEiDHPq7p/ymJY7BkMD59BFGEec6EdGPV/cR/SAqvPev0XF6c+kZNcNMhNEw/YkxRtHMt LlbNcJbIf05QvK1Y4ummHVCW+YEmKELBY4SNQaupa830UBznvqjTItXAi2mFtl3Bo5E9qHmNze A4IB/ziWc8mb7MsXoTfT1zuTO92wFTuMH7qjsJXlvweu6UV2QFWHbtwq5//QZode7WRqr50s/u J78= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Oct 2021 06:40:43 -0700 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4HbQTl0snSz1RtVn for ; Fri, 22 Oct 2021 06:40:43 -0700 (PDT) Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1634910040; x=1637502041; bh=LCcE0zjgkxwj+gyc4Q 8A5JZOBrGg2809Z4KHmI2jDN8=; b=a/0OdOtQfNKaSmagcorCG1tuByEfls+UWY xpKMxrUZIwaiG08HBnR/bXxYHPErTjQJEMAl7nyXpfMgg1dLF+4S7uZeal9HZoCn RrjnOr0qSjkWbPiFUSPwdvVlVjwYWujzR48IqWY8I0DjonKRllz281PlA/m1deQd 6eCy4BluzzFsiXquCF/GE92g1qKnxWOukyhq8jZ76BLwGd0AQ14c/Ld5fq4Prhqv Z//DCrTp28Kd2f1M28P7MEKEedQG+CxL5BxaDZRH5pABT5qrE5X0d1jewBspDwIC KBn+jGw+TQ6nGShDGbeA8LmtSVv3PPZMFaRKpTvcwNodAoggZD/g== X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id mLxCb0wT9Suv for ; Fri, 22 Oct 2021 06:40:40 -0700 (PDT) Received: from toolbox.wdc.com (unknown [10.225.165.39]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4HbQTc6TT8z1RtVl; Fri, 22 Oct 2021 06:40:36 -0700 (PDT) From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Alistair Francis , Bin Meng Subject: [PULL 24/33] hw/intc: Remove the Ibex PLIC Date: Fri, 22 Oct 2021 23:38:03 +1000 Message-Id: <20211022133812.3972903-25-alistair.francis@opensource.wdc.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211022133812.3972903-1-alistair.francis@opensource.wdc.com> References: <20211022133812.3972903-1-alistair.francis@opensource.wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=216.71.153.144; envelope-from=prvs=9222bbd82=alistair.francis@opensource.wdc.com; helo=esa5.hgst.iphmx.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, SPF_HELO_PASS=-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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Alistair Francis The Ibex PLIC is now spec compliant. Let's remove the Ibex PLIC and instead use the SiFive PLIC. Signed-off-by: Alistair Francis Reviewed-by: Bin Meng Message-id: 5557935c2660c5e6281b6d21e6514e019593662e.1634524691.git.alistair.francis@wdc.com --- hw/intc/ibex_plic.c | 307 -------------------------------------------- hw/intc/meson.build | 1 - 2 files changed, 308 deletions(-) delete mode 100644 hw/intc/ibex_plic.c diff --git a/hw/intc/ibex_plic.c b/hw/intc/ibex_plic.c deleted file mode 100644 index ff430356f8..0000000000 --- a/hw/intc/ibex_plic.c +++ /dev/null @@ -1,307 +0,0 @@ -/* - * QEMU RISC-V lowRISC Ibex PLIC - * - * Copyright (c) 2020 Western Digital - * - * Documentation avaliable: https://docs.opentitan.org/hw/ip/rv_plic/doc/ - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2 or later, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program. If not, see . - */ - -#include "qemu/osdep.h" -#include "qemu/log.h" -#include "hw/qdev-properties.h" -#include "hw/core/cpu.h" -#include "hw/boards.h" -#include "hw/pci/msi.h" -#include "target/riscv/cpu_bits.h" -#include "target/riscv/cpu.h" -#include "hw/intc/ibex_plic.h" -#include "hw/irq.h" - -static bool addr_between(uint32_t addr, uint32_t base, uint32_t num) -{ - uint32_t end = base + (num * 0x04); - - if (addr >= base && addr < end) { - return true; - } - - return false; -} - -static void ibex_plic_irqs_set_pending(IbexPlicState *s, int irq, bool level) -{ - int pending_num = irq / 32; - - if (!level) { - /* - * If the level is low make sure we clear the hidden_pending. - */ - s->hidden_pending[pending_num] &= ~(1 << (irq % 32)); - } - - if (s->claimed[pending_num] & 1 << (irq % 32)) { - /* - * The interrupt has been claimed, but not completed. - * The pending bit can't be set. - * Save the pending level for after the interrupt is completed. - */ - s->hidden_pending[pending_num] |= level << (irq % 32); - } else { - s->pending[pending_num] |= level << (irq % 32); - } -} - -static bool ibex_plic_irqs_pending(IbexPlicState *s, uint32_t context) -{ - int i; - uint32_t max_irq = 0; - uint32_t max_prio = s->threshold; - - for (i = 0; i < s->pending_num; i++) { - uint32_t irq_num = ctz64(s->pending[i]) + (i * 32); - - if (!(s->pending[i] & s->enable[i])) { - /* No pending and enabled IRQ */ - continue; - } - - if (s->priority[irq_num] > max_prio) { - max_irq = irq_num; - max_prio = s->priority[irq_num]; - } - } - - if (max_irq) { - s->claim = max_irq; - return true; - } - - return false; -} - -static void ibex_plic_update(IbexPlicState *s) -{ - int i; - - for (i = 0; i < s->num_cpus; i++) { - qemu_set_irq(s->external_irqs[i], ibex_plic_irqs_pending(s, 0)); - } -} - -static void ibex_plic_reset(DeviceState *dev) -{ - IbexPlicState *s = IBEX_PLIC(dev); - - s->threshold = 0x00000000; - s->claim = 0x00000000; -} - -static uint64_t ibex_plic_read(void *opaque, hwaddr addr, - unsigned int size) -{ - IbexPlicState *s = opaque; - int offset; - uint32_t ret = 0; - - if (addr_between(addr, s->pending_base, s->pending_num)) { - offset = (addr - s->pending_base) / 4; - ret = s->pending[offset]; - } else if (addr_between(addr, s->source_base, s->source_num)) { - qemu_log_mask(LOG_UNIMP, - "%s: Interrupt source mode not supported\n", __func__); - } else if (addr_between(addr, s->priority_base, s->priority_num)) { - offset = (addr - s->priority_base) / 4; - ret = s->priority[offset]; - } else if (addr_between(addr, s->enable_base, s->enable_num)) { - offset = (addr - s->enable_base) / 4; - ret = s->enable[offset]; - } else if (addr_between(addr, s->threshold_base, 1)) { - ret = s->threshold; - } else if (addr_between(addr, s->claim_base, 1)) { - int pending_num = s->claim / 32; - s->pending[pending_num] &= ~(1 << (s->claim % 32)); - - /* Set the interrupt as claimed, but not completed */ - s->claimed[pending_num] |= 1 << (s->claim % 32); - - /* Return the current claimed interrupt */ - ret = s->claim; - - /* Clear the claimed interrupt */ - s->claim = 0x00000000; - - /* Update the interrupt status after the claim */ - ibex_plic_update(s); - } - - return ret; -} - -static void ibex_plic_write(void *opaque, hwaddr addr, - uint64_t value, unsigned int size) -{ - IbexPlicState *s = opaque; - - if (addr_between(addr, s->pending_base, s->pending_num)) { - qemu_log_mask(LOG_GUEST_ERROR, - "%s: Pending registers are read only\n", __func__); - } else if (addr_between(addr, s->source_base, s->source_num)) { - qemu_log_mask(LOG_UNIMP, - "%s: Interrupt source mode not supported\n", __func__); - } else if (addr_between(addr, s->priority_base, s->priority_num)) { - uint32_t irq = ((addr - s->priority_base) >> 2) + 1; - s->priority[irq] = value & 7; - ibex_plic_update(s); - } else if (addr_between(addr, s->enable_base, s->enable_num)) { - uint32_t enable_reg = (addr - s->enable_base) / 4; - - s->enable[enable_reg] = value; - } else if (addr_between(addr, s->threshold_base, 1)) { - s->threshold = value & 3; - } else if (addr_between(addr, s->claim_base, 1)) { - if (s->claim == value) { - /* Interrupt was completed */ - s->claim = 0; - } - if (s->claimed[value / 32] & 1 << (value % 32)) { - int pending_num = value / 32; - - /* This value was already claimed, clear it. */ - s->claimed[pending_num] &= ~(1 << (value % 32)); - - if (s->hidden_pending[pending_num] & (1 << (value % 32))) { - /* - * If the bit in hidden_pending is set then that means we - * received an interrupt between claiming and completing - * the interrupt that hasn't since been de-asserted. - * On hardware this would trigger an interrupt, so let's - * trigger one here as well. - */ - s->pending[pending_num] |= 1 << (value % 32); - } - } - } - - ibex_plic_update(s); -} - -static const MemoryRegionOps ibex_plic_ops = { - .read = ibex_plic_read, - .write = ibex_plic_write, - .endianness = DEVICE_NATIVE_ENDIAN, - .valid = { - .min_access_size = 4, - .max_access_size = 4 - } -}; - -static void ibex_plic_irq_request(void *opaque, int irq, int level) -{ - IbexPlicState *s = opaque; - - ibex_plic_irqs_set_pending(s, irq, level > 0); - ibex_plic_update(s); -} - -static Property ibex_plic_properties[] = { - DEFINE_PROP_UINT32("num-cpus", IbexPlicState, num_cpus, 1), - DEFINE_PROP_UINT32("num-sources", IbexPlicState, num_sources, 176), - - DEFINE_PROP_UINT32("pending-base", IbexPlicState, pending_base, 0), - DEFINE_PROP_UINT32("pending-num", IbexPlicState, pending_num, 6), - - DEFINE_PROP_UINT32("source-base", IbexPlicState, source_base, 0x18), - DEFINE_PROP_UINT32("source-num", IbexPlicState, source_num, 6), - - DEFINE_PROP_UINT32("priority-base", IbexPlicState, priority_base, 0x30), - DEFINE_PROP_UINT32("priority-num", IbexPlicState, priority_num, 177), - - DEFINE_PROP_UINT32("enable-base", IbexPlicState, enable_base, 0x300), - DEFINE_PROP_UINT32("enable-num", IbexPlicState, enable_num, 6), - - DEFINE_PROP_UINT32("threshold-base", IbexPlicState, threshold_base, 0x318), - - DEFINE_PROP_UINT32("claim-base", IbexPlicState, claim_base, 0x31c), - DEFINE_PROP_END_OF_LIST(), -}; - -static void ibex_plic_init(Object *obj) -{ - IbexPlicState *s = IBEX_PLIC(obj); - - memory_region_init_io(&s->mmio, obj, &ibex_plic_ops, s, - TYPE_IBEX_PLIC, 0x400); - sysbus_init_mmio(SYS_BUS_DEVICE(obj), &s->mmio); -} - -static void ibex_plic_realize(DeviceState *dev, Error **errp) -{ - IbexPlicState *s = IBEX_PLIC(dev); - int i; - - s->pending = g_new0(uint32_t, s->pending_num); - s->hidden_pending = g_new0(uint32_t, s->pending_num); - s->claimed = g_new0(uint32_t, s->pending_num); - s->source = g_new0(uint32_t, s->source_num); - s->priority = g_new0(uint32_t, s->priority_num); - s->enable = g_new0(uint32_t, s->enable_num); - - qdev_init_gpio_in(dev, ibex_plic_irq_request, s->num_sources); - - s->external_irqs = g_malloc(sizeof(qemu_irq) * s->num_cpus); - qdev_init_gpio_out(dev, s->external_irqs, s->num_cpus); - - /* - * We can't allow the supervisor to control SEIP as this would allow the - * supervisor to clear a pending external interrupt which will result in - * a lost interrupt in the case a PLIC is attached. The SEIP bit must be - * hardware controlled when a PLIC is attached. - */ - MachineState *ms = MACHINE(qdev_get_machine()); - unsigned int smp_cpus = ms->smp.cpus; - for (i = 0; i < smp_cpus; i++) { - RISCVCPU *cpu = RISCV_CPU(qemu_get_cpu(i)); - if (riscv_cpu_claim_interrupts(cpu, MIP_SEIP) < 0) { - error_report("SEIP already claimed"); - exit(1); - } - } - - msi_nonbroken = true; -} - -static void ibex_plic_class_init(ObjectClass *klass, void *data) -{ - DeviceClass *dc = DEVICE_CLASS(klass); - - dc->reset = ibex_plic_reset; - device_class_set_props(dc, ibex_plic_properties); - dc->realize = ibex_plic_realize; -} - -static const TypeInfo ibex_plic_info = { - .name = TYPE_IBEX_PLIC, - .parent = TYPE_SYS_BUS_DEVICE, - .instance_size = sizeof(IbexPlicState), - .instance_init = ibex_plic_init, - .class_init = ibex_plic_class_init, -}; - -static void ibex_plic_register_types(void) -{ - type_register_static(&ibex_plic_info); -} - -type_init(ibex_plic_register_types) diff --git a/hw/intc/meson.build b/hw/intc/meson.build index a1d00aa48d..c89d2ca180 100644 --- a/hw/intc/meson.build +++ b/hw/intc/meson.build @@ -32,7 +32,6 @@ specific_ss.add(when: 'CONFIG_ARM_V7M', if_true: files('armv7m_nvic.c')) specific_ss.add(when: 'CONFIG_ASPEED_SOC', if_true: files('aspeed_vic.c')) specific_ss.add(when: 'CONFIG_EXYNOS4', if_true: files('exynos4210_gic.c', 'exynos4210_combiner.c')) specific_ss.add(when: 'CONFIG_GRLIB', if_true: files('grlib_irqmp.c')) -specific_ss.add(when: 'CONFIG_IBEX', if_true: files('ibex_plic.c')) specific_ss.add(when: 'CONFIG_IOAPIC', if_true: files('ioapic.c')) specific_ss.add(when: 'CONFIG_LOONGSON_LIOINTC', if_true: files('loongson_liointc.c')) specific_ss.add(when: 'CONFIG_MIPS_CPS', if_true: files('mips_gic.c')) From patchwork Fri Oct 22 13:38:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 1544960 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=wdc.com header.i=@wdc.com header.a=rsa-sha256 header.s=dkim.wdc.com header.b=GSCVLix3; dkim=pass (2048-bit key; unprotected) header.d=opensource.wdc.com header.i=@opensource.wdc.com header.a=rsa-sha256 header.s=dkim header.b=uleJMEWM; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4HbQsT1ln1z9sRR for ; Sat, 23 Oct 2021 00:57:49 +1100 (AEDT) Received: from localhost ([::1]:38214 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mdv3K-0000BD-F0 for incoming@patchwork.ozlabs.org; Fri, 22 Oct 2021 09:57:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57662) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mdunI-0002pl-9n for qemu-devel@nongnu.org; Fri, 22 Oct 2021 09:41:12 -0400 Received: from esa5.hgst.iphmx.com ([216.71.153.144]:39739) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mdunB-0001jp-CL for qemu-devel@nongnu.org; Fri, 22 Oct 2021 09:41:11 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1634910064; x=1666446064; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=OIRNQEuTsAzhuizridf3dL2aLX8GN/u3fr6aSFULvKk=; b=GSCVLix3EvN//q9yIxHIQOdWD+Ku4mEwj83D0jOVbIS/0/M9Q70x7wLd vaw/FgYPZmvR5awgbU7hA/LeYGHTFSAhClAJo6N0WbsctQ0k2+RG56reL qLM2QoyNqDal7xdJKdCFhDEZAWD90c7VecMEgkzC/yrd+R/mRtm4xMklN m9BZazbwE8PmrI+5gnFdovU1VFS5sUX8P/RX7I24QFv2MRifLMXPBa1le ksY7Z1nQgJ5lu99vJ4wXuN4NrsOXW2xioykCTRdXBxYeXygQKu5kONo8r zjBrnoi7JNdd7BW4ySvOqaNDP3AUnDVmZiq9Rf68onl7wjfN+BeSQFA7t A==; X-IronPort-AV: E=Sophos;i="5.87,173,1631548800"; d="scan'208";a="183617911" Received: from h199-255-45-14.hgst.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 22 Oct 2021 21:40:45 +0800 IronPort-SDR: pmWjmbzUsWfSK+/uEskYhA8yovuuSIIpx6xzgmTUUOC4E1YJUjHBWJ1siTAI/R9+8HFakJEGyp 1FFPJZJJrGKsFhtSF8bk8zwQL0tzxZUPDHvwBbY9b2y+OhEOhCjM3srHFsoWDrK4MfPwCqJxXb Ulrac98RWsepRdaAL1XMIOaQJO7Hfkukh78R/PkGPR/3JZuCdEO8cV55NxmxKQp6om9Df3pAKC kGzmyL9k1eDxzgY+cn6PGcICawKLRyQQRrGDdPGejJHowaSOop4VMUEDvD0j+zHKkGiVeKNk6I dFomXEoOVmyjUL5BFPQR1cRP Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Oct 2021 06:16:20 -0700 IronPort-SDR: 2VZBxA/QC/wAwuXixHaoru2IRYGP6HDpxzZkqvWfUoeybq9z8gc/sOY0Sw8JyP9jMF77fcM+uK oRHceSNnIRTy564zqLVpHW5tXaMimY9PxCQe7M9KFBg/v+fepx8KSRy5cPydp5Rvi8pBy5E5Cn ZyHRUAsSyPCNdwQ8d2lEqTpH4nucYUHln9c9140qE02fnqhxLNJCopvzZ+rGQNkwDp6EnfCp6a jjFBKzb1xHptsyuOoRIEWfUVVaKBmzxnSBw/stU6g2YzYIXUq8lKO1ttNzLMNEWoGNr9Auk14/ eKQ= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Oct 2021 06:40:46 -0700 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4HbQTn48WXz1RtVp for ; Fri, 22 Oct 2021 06:40:45 -0700 (PDT) Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1634910045; x=1637502046; bh=OIRNQEuTsAzhuizrid f3dL2aLX8GN/u3fr6aSFULvKk=; b=uleJMEWMEU7brhYBDkm21u3neHCxY1R59l VQTpFOUp4bjb9BG8nZHF/dATy53IP8QLEN9nWDLJwtEpHmdLiFCPB2kp4H7sYr3s OytMK/pi2qgxD5/tMmFLjos0s7+ztvYVPIdMX2R3JdcXF5tGoIpEx1H5BX5v0a01 56919O1QFmUM8red6Pbz2nWNU36eYMqBEnIGtb9iDItZvYcAxE97kgi3gdj2ZWsZ zokbIHRn0FhtRmYxVmeqeT7p4IEN2wRCYHlB2xeS05O/M6LwucJiQ8F+2ZIS51Pz qBs75CZP2zSO0ov6S3iil0Zu0zDrkIMEl3HNX4MT39wV9iixsJBQ== X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id MbHyydkavQNw for ; Fri, 22 Oct 2021 06:40:45 -0700 (PDT) Received: from toolbox.wdc.com (unknown [10.225.165.39]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4HbQTj4qg4z1RtVm; Fri, 22 Oct 2021 06:40:41 -0700 (PDT) From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Alistair Francis , Bin Meng Subject: [PULL 25/33] hw/intc: sifive_plic: Move the properties Date: Fri, 22 Oct 2021 23:38:04 +1000 Message-Id: <20211022133812.3972903-26-alistair.francis@opensource.wdc.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211022133812.3972903-1-alistair.francis@opensource.wdc.com> References: <20211022133812.3972903-1-alistair.francis@opensource.wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=216.71.153.144; envelope-from=prvs=9222bbd82=alistair.francis@opensource.wdc.com; helo=esa5.hgst.iphmx.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, SPF_HELO_PASS=-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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Alistair Francis Signed-off-by: Alistair Francis Reviewed-by: Bin Meng Message-id: 3c125e27c49a4969df82bf8b197535ccd1996939.1634524691.git.alistair.francis@wdc.com --- hw/intc/sifive_plic.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/hw/intc/sifive_plic.c b/hw/intc/sifive_plic.c index 9ba36dc0b3..f0e2799efc 100644 --- a/hw/intc/sifive_plic.c +++ b/hw/intc/sifive_plic.c @@ -355,21 +355,6 @@ static const MemoryRegionOps sifive_plic_ops = { } }; -static Property sifive_plic_properties[] = { - DEFINE_PROP_STRING("hart-config", SiFivePLICState, hart_config), - DEFINE_PROP_UINT32("hartid-base", SiFivePLICState, hartid_base, 0), - DEFINE_PROP_UINT32("num-sources", SiFivePLICState, num_sources, 0), - DEFINE_PROP_UINT32("num-priorities", SiFivePLICState, num_priorities, 0), - DEFINE_PROP_UINT32("priority-base", SiFivePLICState, priority_base, 0), - DEFINE_PROP_UINT32("pending-base", SiFivePLICState, pending_base, 0), - DEFINE_PROP_UINT32("enable-base", SiFivePLICState, enable_base, 0), - DEFINE_PROP_UINT32("enable-stride", SiFivePLICState, enable_stride, 0), - DEFINE_PROP_UINT32("context-base", SiFivePLICState, context_base, 0), - DEFINE_PROP_UINT32("context-stride", SiFivePLICState, context_stride, 0), - DEFINE_PROP_UINT32("aperture-size", SiFivePLICState, aperture_size, 0), - DEFINE_PROP_END_OF_LIST(), -}; - /* * parse PLIC hart/mode address offset config * @@ -496,6 +481,21 @@ static const VMStateDescription vmstate_sifive_plic = { } }; +static Property sifive_plic_properties[] = { + DEFINE_PROP_STRING("hart-config", SiFivePLICState, hart_config), + DEFINE_PROP_UINT32("hartid-base", SiFivePLICState, hartid_base, 0), + DEFINE_PROP_UINT32("num-sources", SiFivePLICState, num_sources, 0), + DEFINE_PROP_UINT32("num-priorities", SiFivePLICState, num_priorities, 0), + DEFINE_PROP_UINT32("priority-base", SiFivePLICState, priority_base, 0), + DEFINE_PROP_UINT32("pending-base", SiFivePLICState, pending_base, 0), + DEFINE_PROP_UINT32("enable-base", SiFivePLICState, enable_base, 0), + DEFINE_PROP_UINT32("enable-stride", SiFivePLICState, enable_stride, 0), + DEFINE_PROP_UINT32("context-base", SiFivePLICState, context_base, 0), + DEFINE_PROP_UINT32("context-stride", SiFivePLICState, context_stride, 0), + DEFINE_PROP_UINT32("aperture-size", SiFivePLICState, aperture_size, 0), + DEFINE_PROP_END_OF_LIST(), +}; + static void sifive_plic_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); From patchwork Fri Oct 22 13:38:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 1544963 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=wdc.com header.i=@wdc.com header.a=rsa-sha256 header.s=dkim.wdc.com header.b=nHkhgu09; dkim=pass (2048-bit key; unprotected) header.d=opensource.wdc.com header.i=@opensource.wdc.com header.a=rsa-sha256 header.s=dkim header.b=Vs0oUL5c; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4HbQxn3QZVz9sRR for ; Sat, 23 Oct 2021 01:01:33 +1100 (AEDT) Received: from localhost ([::1]:45478 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mdv6w-00059I-Em for incoming@patchwork.ozlabs.org; Fri, 22 Oct 2021 10:01:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57712) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mdunK-0002yD-Tp for qemu-devel@nongnu.org; Fri, 22 Oct 2021 09:41:15 -0400 Received: from esa5.hgst.iphmx.com ([216.71.153.144]:39739) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mdunI-0001jp-NN for qemu-devel@nongnu.org; Fri, 22 Oct 2021 09:41:14 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1634910071; x=1666446071; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=LDtzvFTXogtSDklUC9GZ7SxOxa/2dHjq0OoxLJZf4cs=; b=nHkhgu09wx3v15mATT/7drvZ9UcOOk52QdKcEpag/g6zglJwAZw/K3pc kEV6w4AB7SdpX/6Anzg1jwXBoOTqycJYW+uvf5YtualABNwffJeNlQUsY 0nJo7//8RkorbWMOhHSdwgqwwzG7oS49cm20Goc8u6AYpCQP0PuTUhk3v sPqxZscatoS0ByI9pKnK9NWHc5kM8Yov/pYEtD8BItglAyKfm2g1eQyV4 yoJOzHwaxy3NT5tCgkC7RVoe/SnMLQ2YdhngoxqgjjUttfiQhxM5aKdcE oDq5qiXFmsCVqgkuoTMT6nktjlno2YKBkR1PFhgNKh88LWPgfq2jHZ01p g==; X-IronPort-AV: E=Sophos;i="5.87,173,1631548800"; d="scan'208";a="183617912" Received: from h199-255-45-14.hgst.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 22 Oct 2021 21:40:49 +0800 IronPort-SDR: jO1ZrvICwWtE4ihnz58NTMFiPS54/MxOUP6kX4Nh8fhj2sMAar2LL+9wgq6O+tyP9+GgnWnEfc tkpXpp58JxDEMjjA0tL6OsNMKIgiVkgE2SKjRtNV7LPFvkQaJbt5KP2lB0IzR0CaGJfd/btkwr qt7taezX5uRVdLnKkUSnrPLSLRT+cPWbvtRWaIYrYs902bU9/pjiZJZG2RsG/ZLY7ENdZN8MTL JoxQHIpROeaKsk0wWehZn80nYrBKn0XHWmWb5oThblLAud0k7iRQEZChXGWaL7YeIUmCDddzO2 Dn8lUCX2LwjE7l7xWR7QYo0K Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Oct 2021 06:16:25 -0700 IronPort-SDR: bJFF2/TEHWj4VKKLRll+IFShKhDHppWWMqOtH2aOvZalWVDx7+TIHbzg7ynbEkqGiHsUWwXwu9 tEHtxYTrKyMFuCEDJwECN4j7xe5iV6weizhc9o2tBHKvHBEYHKNFwZvTFboBzN2wv3/92yHPzy 4jddvg0dvB95x7vdaxOz7j+nkA7hycIhtdcoaKGL/wK48QO2WkovbcYqKjLhq4u6mVFrXLwylN WTHpfXwEHkyD3YxW2V0xXiHsYJhEkGZrnYCxhaxCLrQdi9R+9LCJ/4UajIgIQAs2y5deMMVhEQ 9y8= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Oct 2021 06:40:50 -0700 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4HbQTt1mqcz1RtVt for ; Fri, 22 Oct 2021 06:40:50 -0700 (PDT) Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1634910049; x=1637502050; bh=LDtzvFTXogtSDklUC9 GZ7SxOxa/2dHjq0OoxLJZf4cs=; b=Vs0oUL5cGj56NWDfpjlQobLOK3zzShVkeR DAyanXYnqN9HIaoiH2xSwh1CMw6czT7yzyQoUHU5AwlOISWoVuCCGs/U0JevO5RI F0yzBoow0nXql2rrqzZgniUREcKNFfb8PCFF1KErDU+haNfowissYi0baOfvNd3j varmFUg5QiyonLnVt7HfoXrxTCZJ9xLT+IYs/zsTYfbhoFtfnp4z6ehahDPflG6x zycVHlDs7INC2LlCn66qf1aP6aNSewGoHNwrdPgjBCsV5Pr6eXNBWz6VyGdan30e MwlG6bXwYAP4BjHw+4HxSaISg6dfuVhc9nkeHf3xNHEXFNEI9DuA== X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id 0k5Lv7ZbH82W for ; Fri, 22 Oct 2021 06:40:49 -0700 (PDT) Received: from toolbox.wdc.com (unknown [10.225.165.39]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4HbQTp2BfJz1RtVl; Fri, 22 Oct 2021 06:40:45 -0700 (PDT) From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Alistair Francis , Bin Meng Subject: [PULL 26/33] hw/intc: sifive_plic: Cleanup the realize function Date: Fri, 22 Oct 2021 23:38:05 +1000 Message-Id: <20211022133812.3972903-27-alistair.francis@opensource.wdc.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211022133812.3972903-1-alistair.francis@opensource.wdc.com> References: <20211022133812.3972903-1-alistair.francis@opensource.wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=216.71.153.144; envelope-from=prvs=9222bbd82=alistair.francis@opensource.wdc.com; helo=esa5.hgst.iphmx.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, SPF_HELO_PASS=-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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Alistair Francis Signed-off-by: Alistair Francis Reviewed-by: Bin Meng Message-id: b94c098cb221e744683349b1ac794c23102ef471.1634524691.git.alistair.francis@wdc.com --- hw/intc/sifive_plic.c | 45 +++++++++++++++++++++++-------------------- 1 file changed, 24 insertions(+), 21 deletions(-) diff --git a/hw/intc/sifive_plic.c b/hw/intc/sifive_plic.c index f0e2799efc..d77a5ced23 100644 --- a/hw/intc/sifive_plic.c +++ b/hw/intc/sifive_plic.c @@ -422,35 +422,38 @@ static void sifive_plic_irq_request(void *opaque, int irq, int level) static void sifive_plic_realize(DeviceState *dev, Error **errp) { - SiFivePLICState *plic = SIFIVE_PLIC(dev); + SiFivePLICState *s = SIFIVE_PLIC(dev); int i; - memory_region_init_io(&plic->mmio, OBJECT(dev), &sifive_plic_ops, plic, - TYPE_SIFIVE_PLIC, plic->aperture_size); - parse_hart_config(plic); - plic->bitfield_words = (plic->num_sources + 31) >> 5; - plic->num_enables = plic->bitfield_words * plic->num_addrs; - plic->source_priority = g_new0(uint32_t, plic->num_sources); - plic->target_priority = g_new(uint32_t, plic->num_addrs); - plic->pending = g_new0(uint32_t, plic->bitfield_words); - plic->claimed = g_new0(uint32_t, plic->bitfield_words); - plic->enable = g_new0(uint32_t, plic->num_enables); - sysbus_init_mmio(SYS_BUS_DEVICE(dev), &plic->mmio); - qdev_init_gpio_in(dev, sifive_plic_irq_request, plic->num_sources); - - plic->s_external_irqs = g_malloc(sizeof(qemu_irq) * plic->num_harts); - qdev_init_gpio_out(dev, plic->s_external_irqs, plic->num_harts); - - plic->m_external_irqs = g_malloc(sizeof(qemu_irq) * plic->num_harts); - qdev_init_gpio_out(dev, plic->m_external_irqs, plic->num_harts); + memory_region_init_io(&s->mmio, OBJECT(dev), &sifive_plic_ops, s, + TYPE_SIFIVE_PLIC, s->aperture_size); + sysbus_init_mmio(SYS_BUS_DEVICE(dev), &s->mmio); + + parse_hart_config(s); + + s->bitfield_words = (s->num_sources + 31) >> 5; + s->num_enables = s->bitfield_words * s->num_addrs; + s->source_priority = g_new0(uint32_t, s->num_sources); + s->target_priority = g_new(uint32_t, s->num_addrs); + s->pending = g_new0(uint32_t, s->bitfield_words); + s->claimed = g_new0(uint32_t, s->bitfield_words); + s->enable = g_new0(uint32_t, s->num_enables); + + qdev_init_gpio_in(dev, sifive_plic_irq_request, s->num_sources); + + s->s_external_irqs = g_malloc(sizeof(qemu_irq) * s->num_harts); + qdev_init_gpio_out(dev, s->s_external_irqs, s->num_harts); + + s->m_external_irqs = g_malloc(sizeof(qemu_irq) * s->num_harts); + qdev_init_gpio_out(dev, s->m_external_irqs, s->num_harts); /* We can't allow the supervisor to control SEIP as this would allow the * supervisor to clear a pending external interrupt which will result in * lost a interrupt in the case a PLIC is attached. The SEIP bit must be * hardware controlled when a PLIC is attached. */ - for (i = 0; i < plic->num_harts; i++) { - RISCVCPU *cpu = RISCV_CPU(qemu_get_cpu(plic->hartid_base + i)); + for (i = 0; i < s->num_harts; i++) { + RISCVCPU *cpu = RISCV_CPU(qemu_get_cpu(s->hartid_base + i)); if (riscv_cpu_claim_interrupts(cpu, MIP_SEIP) < 0) { error_report("SEIP already claimed"); exit(1); From patchwork Fri Oct 22 13:38:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 1544970 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=wdc.com header.i=@wdc.com header.a=rsa-sha256 header.s=dkim.wdc.com header.b=gfe0LDFi; dkim=pass (2048-bit key; unprotected) header.d=opensource.wdc.com header.i=@opensource.wdc.com header.a=rsa-sha256 header.s=dkim header.b=LnJ5wxQD; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4HbR4m5z3Wz9sRR for ; Sat, 23 Oct 2021 01:07:36 +1100 (AEDT) Received: from localhost ([::1]:59436 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mdvCo-0006Fn-Kn for incoming@patchwork.ozlabs.org; Fri, 22 Oct 2021 10:07:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57760) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mdunN-00035R-CM for qemu-devel@nongnu.org; Fri, 22 Oct 2021 09:41:17 -0400 Received: from esa5.hgst.iphmx.com ([216.71.153.144]:39739) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mdunL-0001jp-5m for qemu-devel@nongnu.org; Fri, 22 Oct 2021 09:41:17 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1634910074; x=1666446074; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=qBaB/YIUyNKJ3Gukdg5PeIIi3JOIfMFicRvc0MZlu/s=; b=gfe0LDFiDdAgH1CO2SyO2AecANQ281zXoKax1hay373Y0PM7zrXGvck6 kjDwXk9fN3LzuvuIwqt9FM1r1Lt+Tz4iEU2lq+Z50rYrp58WD5AgpIG+N vtUfc2G6bnuL9LgyKfhd9medpMJLZrbs/E2if84jJNm4VqRoIOIRhyjl3 1DfnMvU509E8bW1Nu9wRM8iJ90av+lOr6t1XjuQgdBZpJvuistsUghj+X gNoXMmCdAMaUbzWxBRuC39y38gcksMPMsj3qXCkvxSFokd9x7SB5Cy9vy Mp2W6yAW/vTO4UHqv4X30X/VjQwqKH7IxJGaKO/+jbKZpGbN6gqTnTtgY g==; X-IronPort-AV: E=Sophos;i="5.87,173,1631548800"; d="scan'208";a="183617917" Received: from h199-255-45-14.hgst.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 22 Oct 2021 21:40:54 +0800 IronPort-SDR: WaCnUH2hTmLLKigpgIA6hbXdiESqM+DxkSgerdFRlu0qj2WZMkvsnx5o6AGyyq33zsn3qbVX3X BZBKAHR6YgePL/ZggGE0sLo7AEb02TTvlZGK3Ip/tKP9lQugYMrAAEpz47FAcYXT6ixTIRKz44 A2QqPfAw/fpE0+prOMC5skwa87XjnRQjqOwkss/HRZZl1Eax4z60kRezeNWicK/QJAtyFpgUpX 9zFWaWGCJ4xz9uFCHYR5ieBJKTc6okc/Y7+oVC4dag8iT4iGnZx8oQf91C+lg7EmZXyq7+rcTH b+5FkNdikWDkWguIDgH06xdE Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Oct 2021 06:16:29 -0700 IronPort-SDR: Cax6qIpEQZii2wsXh0LJg7ilyjtjSBL+iR7j6ku4zfEbr6qa2b0qvoEdYbM4B3ZhlssV/PhlFE rs08wEW1BNJa77nak9Qm2cWorqtrBz6deLdFxy852+E2h0qf4Tf+fdgZBgGUkIjvyhXR5YPd5o TwyJOMvDTCo8KZ4OtEMeoV6kULKdOItzbkemHF9E9l7C/z0DhHa/D30O7cbtzkR35povbBf18l kXg03hiYLGpOleqp7YiYc9meSCd/SLOona0E8zcExE0AvsS61prxXKUJtFx53sk/PX8qUIgGbC 3tY= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Oct 2021 06:40:55 -0700 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4HbQTy51mVz1RtVm for ; Fri, 22 Oct 2021 06:40:54 -0700 (PDT) Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1634910054; x=1637502055; bh=qBaB/YIUyNKJ3Gukdg 5PeIIi3JOIfMFicRvc0MZlu/s=; b=LnJ5wxQDE/dfWLiyvI6UKZ/sXM0QBKfWzm pLajWdWUOak0F3TTrbUd98S2dr1StKWgK04Z2wDSe6zVTzM/uPsrWKKslan+i5uy GUtY4+belQc9YVKq917xIC+ikSQUiaO4QjxpTRYaleIBY1/IMttwSlRMZp74pBlI QOhXBaS8TWttYdm65emMR/47kapBT7qX0b4TOr/v6nEvFXekOkFgv5r7kGY7abgH oG2kp6vtiv/fx0v18QTUirO8c0BW99krUB6YcMAxRWBU4vnoQTAxbQJYxr4syZhh Xj+s3iNDtQrU829y4dhcWGTuxoR2sat6H0pY6ky3dwpU4KRXzTPQ== X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id 39F8PtUzVytz for ; Fri, 22 Oct 2021 06:40:54 -0700 (PDT) Received: from toolbox.wdc.com (unknown [10.225.165.39]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4HbQTt6Z62z1RtVl; Fri, 22 Oct 2021 06:40:50 -0700 (PDT) From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Alistair Francis , Bin Meng Subject: [PULL 27/33] hw/intc: sifive_plic: Cleanup the irq_request function Date: Fri, 22 Oct 2021 23:38:06 +1000 Message-Id: <20211022133812.3972903-28-alistair.francis@opensource.wdc.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211022133812.3972903-1-alistair.francis@opensource.wdc.com> References: <20211022133812.3972903-1-alistair.francis@opensource.wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=216.71.153.144; envelope-from=prvs=9222bbd82=alistair.francis@opensource.wdc.com; helo=esa5.hgst.iphmx.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, SPF_HELO_PASS=-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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Alistair Francis Signed-off-by: Alistair Francis Reviewed-by: Bin Meng Message-id: 4200da222a65c89ed1ba35f754dcca7fdd9f08d6.1634524691.git.alistair.francis@wdc.com --- hw/intc/sifive_plic.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/hw/intc/sifive_plic.c b/hw/intc/sifive_plic.c index d77a5ced23..877e76877c 100644 --- a/hw/intc/sifive_plic.c +++ b/hw/intc/sifive_plic.c @@ -412,12 +412,10 @@ static void parse_hart_config(SiFivePLICState *plic) static void sifive_plic_irq_request(void *opaque, int irq, int level) { - SiFivePLICState *plic = opaque; - if (RISCV_DEBUG_PLIC) { - qemu_log("sifive_plic_irq_request: irq=%d level=%d\n", irq, level); - } - sifive_plic_set_pending(plic, irq, level > 0); - sifive_plic_update(plic); + SiFivePLICState *s = opaque; + + sifive_plic_set_pending(s, irq, level > 0); + sifive_plic_update(s); } static void sifive_plic_realize(DeviceState *dev, Error **errp) From patchwork Fri Oct 22 13:38:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 1544961 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=wdc.com header.i=@wdc.com header.a=rsa-sha256 header.s=dkim.wdc.com header.b=CUa8yJKi; dkim=pass (2048-bit key; unprotected) header.d=opensource.wdc.com header.i=@opensource.wdc.com header.a=rsa-sha256 header.s=dkim header.b=jztSdakT; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4HbQvl0cNXz9sRR for ; Sat, 23 Oct 2021 00:59:47 +1100 (AEDT) Received: from localhost ([::1]:42402 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mdv5E-00033H-P5 for incoming@patchwork.ozlabs.org; Fri, 22 Oct 2021 09:59:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57770) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mdunO-00039A-F1 for qemu-devel@nongnu.org; Fri, 22 Oct 2021 09:41:18 -0400 Received: from esa3.hgst.iphmx.com ([216.71.153.141]:41600) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mdunA-0001ji-F7 for qemu-devel@nongnu.org; Fri, 22 Oct 2021 09:41:18 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1634910064; x=1666446064; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=aGJ3aI7BtSmdzZPh815//XcOeA+5kBpT/UXT2swWg9E=; b=CUa8yJKi4E0U4uAMVBTAMA8t1M52nTmMZ/o61hbm0+BiHir+cjzDSjxE MWcl1/KZnWz+CO2TOohtz0Y2CkA1OGMjFo7QpH0ghSxp6pNpv10hSSjA3 ar5AiuHdRhDolvaqMKhpg3yvpD9TYPX1+GUguWhUmFe/LFblcj/C++27u Rl7bdKgZjRUs4Dfr+EAQvBFMmYChCvMy0JbL3bHQll4AZ7LKO9DL4fIDx XP/i/zlilTtLYoXzmfAkxHpWw8zsZ8+DrOVvJ7G5cy90jAyAeSbqseipt ATnMgYfgMAFuUnSRCJFDnJjOUdrhR6I/1orLfueGmILsE6b2nsAVdJo/Q A==; X-IronPort-AV: E=Sophos;i="5.87,173,1631548800"; d="scan'208";a="188392204" Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 22 Oct 2021 21:41:00 +0800 IronPort-SDR: nDzT75xKaJ5YkzaZRYQT33h6jeAOKGzcFKBW0VuzFS1mV1miA+ltc035TN70VImZInDe1jhc6Q FbySTRoHlNcS49hMC/tGLqSLMs9h9B6B/ijXjXXSPADo83PQWULxx42B8/bY6A/kEBM37urZb+ VWKf6aDvUwW58NBYMSv/HrYdF8ikKkvTmuA74s+JvFOzuyQewenba55JKzByFGXFADgJY7vtDW /JAA8emaDyPOkjem4P4l8qvboiAhTuORDh+RLUfVHTIsIqPpIj832IL7IReM+uvHvo9eNfNMB/ N3FFPtkaEtzYlJqITtrPmlxE Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Oct 2021 06:15:02 -0700 IronPort-SDR: t8oEuB+ShDP3VPJhiPw00wqgMiavX4n5RZMNCARLoFNeiadoIbrnFt1zRG1nj13c/RQvyroT6K RVKv8g8k7w5JaSVQ32D9a2i8YHc4Yyn5ykUdiRVTyqTew1uA1bH5uoXgmEMHYhG+E1N6FHwkq3 kFPbMOB7YaGj0+xG3k2KrXVT5T3G0pZCA1S1ZYFyHCiqBcXylJGatALea/bO18+kBulUFvTREd Tgt9LgSySaJQAlFnrbeGJf4C/28Vyz5mofsP4CSHOI7rYrt4BvoG5oDXN3pMW3rpWjBPs5BXyj A+U= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Oct 2021 06:41:00 -0700 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4HbQV4254nz1RtVt for ; Fri, 22 Oct 2021 06:41:00 -0700 (PDT) Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1634910059; x=1637502060; bh=aGJ3aI7BtSmdzZPh81 5//XcOeA+5kBpT/UXT2swWg9E=; b=jztSdakTBoP5pZT7W4HgbXI4AHAmx591UW s+cx9mD4bZg56DePSHin6xL8G8atO7wc+9iHeiv3YZzk+GHqneT9+PlsAdN1pQHZ Lgt4aEkAZT7w2Ppbo1sE3sM+DhfLsUAIugfrq1Qo1coUSJt4uKHFP9sfOK4qifBi 418CcmVJ+8TW0AVhvETnPJ/22bAi9hDNYEqqohxA293ibKoGpVjR/DW5mhqyEOZq VFAGA2k68pFBnSTB14WdSASMqXhxvpVeJN6Qa9nvQS7rGeZEEnoGSHI+VFgIbrb+ iXnwr1QBSDuVtCfn098nip7Hkc3lgEp94KJg2UJRs0Dz0QTBoxDw== X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id 5J8SWuZR8S_Z for ; Fri, 22 Oct 2021 06:40:59 -0700 (PDT) Received: from toolbox.wdc.com (unknown [10.225.165.39]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4HbQTz51CDz1RtVl; Fri, 22 Oct 2021 06:40:55 -0700 (PDT) From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Bin Meng , Alistair Francis , Igor Mammedov Subject: [PULL 28/33] hw/riscv: microchip_pfsoc: Use MachineState::ram and MachineClass::default_ram_id Date: Fri, 22 Oct 2021 23:38:07 +1000 Message-Id: <20211022133812.3972903-29-alistair.francis@opensource.wdc.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211022133812.3972903-1-alistair.francis@opensource.wdc.com> References: <20211022133812.3972903-1-alistair.francis@opensource.wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=216.71.153.141; envelope-from=prvs=9222bbd82=alistair.francis@opensource.wdc.com; helo=esa3.hgst.iphmx.com X-Spam_score_int: -1 X-Spam_score: -0.2 X-Spam_bar: / X-Spam_report: (-0.2 / 5.0 requ) DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_PASS=-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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Bin Meng Using memory_region_init_ram(), which can't possibly handle vhost-user, and can't work as expected with '-numa node,memdev' options. Use MachineState::ram instead of manually initializing RAM memory region, as well as by providing MachineClass::default_ram_id to opt in to memdev scheme. Signed-off-by: Bin Meng Reviewed-by: Alistair Francis Reviewed-by: Igor Mammedov Message-id: 20211020014112.7336-2-bmeng.cn@gmail.com Signed-off-by: Alistair Francis --- hw/riscv/microchip_pfsoc.c | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/hw/riscv/microchip_pfsoc.c b/hw/riscv/microchip_pfsoc.c index e475b6d511..3fc8545562 100644 --- a/hw/riscv/microchip_pfsoc.c +++ b/hw/riscv/microchip_pfsoc.c @@ -463,7 +463,7 @@ static void microchip_icicle_kit_machine_init(MachineState *machine) MemoryRegion *mem_low_alias = g_new(MemoryRegion, 1); MemoryRegion *mem_high = g_new(MemoryRegion, 1); MemoryRegion *mem_high_alias = g_new(MemoryRegion, 1); - uint64_t mem_high_size; + uint64_t mem_low_size, mem_high_size; hwaddr firmware_load_addr; const char *firmware_name; bool kernel_as_payload = false; @@ -485,31 +485,34 @@ static void microchip_icicle_kit_machine_init(MachineState *machine) TYPE_MICROCHIP_PFSOC); qdev_realize(DEVICE(&s->soc), NULL, &error_abort); + /* Split RAM into low and high regions using aliases to machine->ram */ + mem_low_size = memmap[MICROCHIP_PFSOC_DRAM_LO].size; + mem_high_size = machine->ram_size - mem_low_size; + memory_region_init_alias(mem_low, NULL, + "microchip.icicle.kit.ram_low", machine->ram, + 0, mem_low_size); + memory_region_init_alias(mem_high, NULL, + "microchip.icicle.kit.ram_high", machine->ram, + mem_low_size, mem_high_size); + /* Register RAM */ - memory_region_init_ram(mem_low, NULL, "microchip.icicle.kit.ram_low", - memmap[MICROCHIP_PFSOC_DRAM_LO].size, - &error_fatal); - memory_region_init_alias(mem_low_alias, NULL, - "microchip.icicle.kit.ram_low.alias", - mem_low, 0, - memmap[MICROCHIP_PFSOC_DRAM_LO_ALIAS].size); memory_region_add_subregion(system_memory, memmap[MICROCHIP_PFSOC_DRAM_LO].base, mem_low); + memory_region_add_subregion(system_memory, + memmap[MICROCHIP_PFSOC_DRAM_HI].base, + mem_high); + + /* Create aliases for the low and high RAM regions */ + memory_region_init_alias(mem_low_alias, NULL, + "microchip.icicle.kit.ram_low.alias", + mem_low, 0, mem_low_size); memory_region_add_subregion(system_memory, memmap[MICROCHIP_PFSOC_DRAM_LO_ALIAS].base, mem_low_alias); - - mem_high_size = machine->ram_size - 1 * GiB; - - memory_region_init_ram(mem_high, NULL, "microchip.icicle.kit.ram_high", - mem_high_size, &error_fatal); memory_region_init_alias(mem_high_alias, NULL, "microchip.icicle.kit.ram_high.alias", mem_high, 0, mem_high_size); - memory_region_add_subregion(system_memory, - memmap[MICROCHIP_PFSOC_DRAM_HI].base, - mem_high); memory_region_add_subregion(system_memory, memmap[MICROCHIP_PFSOC_DRAM_HI_ALIAS].base, mem_high_alias); @@ -606,6 +609,7 @@ static void microchip_icicle_kit_machine_class_init(ObjectClass *oc, void *data) MICROCHIP_PFSOC_COMPUTE_CPU_COUNT; mc->min_cpus = MICROCHIP_PFSOC_MANAGEMENT_CPU_COUNT + 1; mc->default_cpus = mc->min_cpus; + mc->default_ram_id = "microchip.icicle.kit.ram"; /* * Map 513 MiB high memory, the mimimum required high memory size, because From patchwork Fri Oct 22 13:38:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 1544950 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=wdc.com header.i=@wdc.com header.a=rsa-sha256 header.s=dkim.wdc.com header.b=Brp6KA1A; dkim=pass (2048-bit key; unprotected) header.d=opensource.wdc.com header.i=@opensource.wdc.com header.a=rsa-sha256 header.s=dkim header.b=Uk04V4Nf; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4HbQhx0wkBz9sRN for ; Sat, 23 Oct 2021 00:50:25 +1100 (AEDT) Received: from localhost ([::1]:49418 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mduwA-0005NS-R4 for incoming@patchwork.ozlabs.org; Fri, 22 Oct 2021 09:50:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57732) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mdunL-00030h-Lr for qemu-devel@nongnu.org; Fri, 22 Oct 2021 09:41:15 -0400 Received: from esa1.hgst.iphmx.com ([68.232.141.245]:33650) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mdunD-0001kp-VS for qemu-devel@nongnu.org; Fri, 22 Oct 2021 09:41:15 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1634910067; x=1666446067; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=1XoLP9T0j3NMHmF4QLtlFon7IH733bYp6g2ve9HWsLM=; b=Brp6KA1AdyVdiLe7Q4FzM39dP1djjRfKZ2mnXfADvl84FvsprFoFV93g sX/eT+0vEY+xN4K656fKGEMboCyw2Lwy809tzc2Y9sWGLsQZOdaTTQiNX PiFIKkYeqePrF5MtMtOv1G2DgG5SQNtvBDnAFvHRd0Ke7blzerrGDhpDy aXV6RW3o+86oyR8p+tijpYLd3VJcTeeTeQLkQviHxtiR6xeG04w2SEqQe j3K0zZqvL7rvz7iZmh7rSiXV6MBIObCy9Eb8FqRBpLm0tppgO/2D9dd4S P8wrs1KlcqrSUbBfhy+hSXyJj1IZKX+/No8HBaTt0zojWqw3y5Tlc0Oh+ Q==; X-IronPort-AV: E=Sophos;i="5.87,173,1631548800"; d="scan'208";a="295351019" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 22 Oct 2021 21:41:06 +0800 IronPort-SDR: qpJHzDsSXiiZrp2gg02E8nDo9GJIqMODIogLcc2z+pynQ/AuSI0V6NTrBfIXXe0UPpu9j+zr4z TG/6dcjbyx6mhczF24lywKAEnpZh41pcMXYqIbuxy1YhW3iHpbmQFg0/paBSB+no/Pd66rL9eX nk05goUA0+b9qv59W+t2R/Z4bn7d3m40vGMz7bToTW6aryYHK706O3scJHDt8GSe4qIOvv4TWO uubuVCXnpwR53K5robXOVV9lWJ+B4OhaPrYe01Lm+VAyc2uP5ejhhazCClGS+OTOFT5MITNwWp Fw99ZIXgE/vjIZic8Zp0VzpD Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Oct 2021 06:16:41 -0700 IronPort-SDR: KB9fw5OM8pDKSthlm33oajlJhzXvxuZ+DAVFZWWabsThGfwnaLyjjElytZP7IL+srzWvDFtL1g 0jqw2rALIx3V7VugEeGewqnmfhwzGeJqlWN8vncQkrLkp6Ky29+HeHbWk6u+Gd7XpbMLSIDHgN L2Pc28IQj8xAEZtRySGlw4ni+HjUq7QIGtIgkRUjsBwILy6hk241RgdmcMfMeEpVXdgNaOZzIS QE74VUJtvl6lcLiQnK7vV9FWuoZf+fgnQgTwtYfpWERxWvvxUqVVPsOlqshHKDaLADez0t7b/N NBA= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Oct 2021 06:41:06 -0700 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4HbQVB0hMxz1RtVv for ; Fri, 22 Oct 2021 06:41:06 -0700 (PDT) Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:content-type :mime-version:references:in-reply-to:x-mailer:message-id:date :subject:to:from; s=dkim; t=1634910065; x=1637502066; bh=1XoLP9T 0j3NMHmF4QLtlFon7IH733bYp6g2ve9HWsLM=; b=Uk04V4Nfd9wHvBsxQnHpDW9 ZNddN+0QqsIpylDWGnavLAajthxknYRgr/NRxlCC2wHfTnHZ4EHmOxWcW7D6jhL5 j/GHrfuC7W4N2xPbpnXOjaa19lOXydCd1qqK4MRidYZRE2LUALlnroOHnSoxEdJy u1zoke51BUzqGE5f+5uUyqDzXwWFBMAFjmzT4rOyCwEMjuQgjPA8LqUAl6qlm7mP JqLUJTEzHV3Ud6FVDOoq6nEM5oLXZUauA9v6kOfWo5S2Pt6axpO66w1hJQBXVtVJ m7RT+6ABgT254JthZ901ARYZkvwqUmrTmvUC0Vo/1wdolneK0A0ALIMX5otxxSg= = X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id CeCUGwkugSk5 for ; Fri, 22 Oct 2021 06:41:05 -0700 (PDT) Received: from toolbox.wdc.com (unknown [10.225.165.39]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4HbQV46QkSz1RtVl; Fri, 22 Oct 2021 06:41:00 -0700 (PDT) From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Bin Meng , =?utf-8?q?Philippe_?= =?utf-8?q?Mathieu-Daud=C3=A9?= , Alistair Francis , Igor Mammedov Subject: [PULL 29/33] hw/riscv: opentitan: Use MachineState::ram and MachineClass::default_ram_id Date: Fri, 22 Oct 2021 23:38:08 +1000 Message-Id: <20211022133812.3972903-30-alistair.francis@opensource.wdc.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211022133812.3972903-1-alistair.francis@opensource.wdc.com> References: <20211022133812.3972903-1-alistair.francis@opensource.wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=68.232.141.245; envelope-from=prvs=9222bbd82=alistair.francis@opensource.wdc.com; helo=esa1.hgst.iphmx.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_PASS=-0.001, T_SPF_TEMPERROR=0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Bin Meng Using memory_region_init_ram(), which can't possibly handle vhost-user, and can't work as expected with '-numa node,memdev' options. Use MachineState::ram instead of manually initializing RAM memory region, as well as by providing MachineClass::default_ram_id to opt in to memdev scheme. While at it add check for user supplied RAM size and error out if it mismatches board expected value. Signed-off-by: Bin Meng Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Alistair Francis Reviewed-by: Igor Mammedov Message-id: 20211020014112.7336-3-bmeng.cn@gmail.com Signed-off-by: Alistair Francis --- hw/riscv/opentitan.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/hw/riscv/opentitan.c b/hw/riscv/opentitan.c index 601f8deebe..83e1511f28 100644 --- a/hw/riscv/opentitan.c +++ b/hw/riscv/opentitan.c @@ -19,6 +19,7 @@ */ #include "qemu/osdep.h" +#include "qemu/cutils.h" #include "hw/riscv/opentitan.h" #include "qapi/error.h" #include "hw/boards.h" @@ -64,20 +65,25 @@ static const MemMapEntry ibex_memmap[] = { static void opentitan_board_init(MachineState *machine) { + MachineClass *mc = MACHINE_GET_CLASS(machine); const MemMapEntry *memmap = ibex_memmap; OpenTitanState *s = g_new0(OpenTitanState, 1); MemoryRegion *sys_mem = get_system_memory(); - MemoryRegion *main_mem = g_new(MemoryRegion, 1); + + if (machine->ram_size != mc->default_ram_size) { + char *sz = size_to_str(mc->default_ram_size); + error_report("Invalid RAM size, should be %s", sz); + g_free(sz); + exit(EXIT_FAILURE); + } /* Initialize SoC */ object_initialize_child(OBJECT(machine), "soc", &s->soc, TYPE_RISCV_IBEX_SOC); qdev_realize(DEVICE(&s->soc), NULL, &error_abort); - memory_region_init_ram(main_mem, NULL, "riscv.lowrisc.ibex.ram", - memmap[IBEX_DEV_RAM].size, &error_fatal); memory_region_add_subregion(sys_mem, - memmap[IBEX_DEV_RAM].base, main_mem); + memmap[IBEX_DEV_RAM].base, machine->ram); if (machine->firmware) { riscv_load_firmware(machine->firmware, memmap[IBEX_DEV_RAM].base, NULL); @@ -95,6 +101,8 @@ static void opentitan_machine_init(MachineClass *mc) mc->init = opentitan_board_init; mc->max_cpus = 1; mc->default_cpu_type = TYPE_RISCV_CPU_IBEX; + mc->default_ram_id = "riscv.lowrisc.ibex.ram"; + mc->default_ram_size = ibex_memmap[IBEX_DEV_RAM].size; } DEFINE_MACHINE("opentitan", opentitan_machine_init) From patchwork Fri Oct 22 13:38:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 1544957 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=wdc.com header.i=@wdc.com header.a=rsa-sha256 header.s=dkim.wdc.com header.b=mLsJcQ0b; dkim=pass (2048-bit key; unprotected) header.d=opensource.wdc.com header.i=@opensource.wdc.com header.a=rsa-sha256 header.s=dkim header.b=VbI73JmM; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4HbQrn1GCZz9sRR for ; Sat, 23 Oct 2021 00:57:11 +1100 (AEDT) Received: from localhost ([::1]:35424 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mdv2i-0006il-6O for incoming@patchwork.ozlabs.org; Fri, 22 Oct 2021 09:57:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57748) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mdunM-000334-G8 for qemu-devel@nongnu.org; Fri, 22 Oct 2021 09:41:16 -0400 Received: from esa6.hgst.iphmx.com ([216.71.154.45]:41273) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mdunJ-0001mw-CU for qemu-devel@nongnu.org; Fri, 22 Oct 2021 09:41:16 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1634910074; x=1666446074; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=rPjjK1gvg0RMuW22DWI8n00ZARjgB6RxXQcqp1EYboU=; b=mLsJcQ0bhAB+WZsQJAgJZ+vfUdVj8jCvZFqCVqSmFLD6IlYtPwZXCMOn f6pOliKa9yezI6LsYaqIyJVpG0jX4raqwnRhzEuA8e1Sk0x31ZHo09B8R kANpKJcbWBkzpOaezukg7Ty/phMb6dBp5vKB+FdomuMKZ1V/CJfBR0Nj5 Hab5Mb0o/xBgw1VfgDlDWdReV5b7Yp+7yFoE4kIioS3sbHDu20lksXLQR TgPnOXmqD4/Jlgf38NGKghVqWOCUQIM9qo6xGIoSFPa0yPmG9vEF4gg0Y /G+WNBj5ZfeX1h3zKWBLowRpOxIFniWYhxKPh2zMuWqxebujG6tQruRPo A==; X-IronPort-AV: E=Sophos;i="5.87,172,1631548800"; d="scan'208";a="184556419" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 22 Oct 2021 21:41:12 +0800 IronPort-SDR: FTzo2A7aXDjDdqvlzG4zbeCw8YAlV0X5whTF5ip5Bc+03njngQGrIAymifMHdOWRSd0vo6aVaU mU40PxWTW54H1L1qeZvLgRh+X/65PRFR5usPRXl0+v1K/vBX+90MEtFjDa1x9/4nhVHy7hRaTG CC+CwEv0ETQkesxikBEnGQ5obpGJzlKH9yINdRVYPp+r2ptZbYLwMF9tT6fLYoY5UxqzNwZqcL CY6BlKNJXdOPPw6BHNZejYUVBfD6xE3jx6oT1DI+J02GjuUVL39Tg9LjXZsv79j5ka4Axme+Uq Iq6orHlV8nZ4N8is4KlfqoVo Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Oct 2021 06:16:46 -0700 IronPort-SDR: EEYevrvArfGlkX8o4xUOUPGdSnbpvjPOOLRHPnAn+pv8HWe9KPZ5NuLo/j/wXWly3TDhznERhM WgfNioVzbQ7vNFa1qrnPO00fDGyLpHCZW2HuEDfuyO9hlg1oQDiGKE0c37T8zJnLZedGzEhsTH ERlmrrAA5z+gE5lDiqOL81mlp2MJd+y34r2w+Sto0oSrSNZD0JfKhj3F5XHIC5rtyQzmGST80f sCy/4zm8uBdN8s6e5LXv41fLSaR1cOLiNd5u8mWEk/LWjO/N1SkM4K5mxUHMN7rIYqmMsdDyXC nHc= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Oct 2021 06:41:12 -0700 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4HbQVH5sSfz1RtVt for ; Fri, 22 Oct 2021 06:41:11 -0700 (PDT) Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:content-type :mime-version:references:in-reply-to:x-mailer:message-id:date :subject:to:from; s=dkim; t=1634910071; x=1637502072; bh=rPjjK1g vg0RMuW22DWI8n00ZARjgB6RxXQcqp1EYboU=; b=VbI73JmM72K1bbPn8xZulBV rkg5s/Kif5lvmpPdjOH+FaIEW23SSjsy9ax90N7OUF8AiqhP7TCyuHLbOMyqliI0 TDJOsFije9/QAtjRRh6CuelgYVswPekO+iymocdEghYxyYZOeGx5t6CpuzJvJgA7 wKwzFPgYmRp9zuhgG4eaHgAUDvpStXrtjqHBj2XlPjLYeIj1SFvYC4Q9tt0BGby7 deSvf5ZApzi9gdad4Vj8t9sf3725Y41j91kBWlcDEJYNqHnO42lFtuUpK79XYGYt wDK9x7DPmNQkmzVlpAlZRUyc/7PYyov8lGlBp8PUc3g0o5BWm1N6KvAZ7mod2xQ= = X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id 10HbcwNhF_Do for ; Fri, 22 Oct 2021 06:41:11 -0700 (PDT) Received: from toolbox.wdc.com (unknown [10.225.165.39]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4HbQVB5RhTz1RtVl; Fri, 22 Oct 2021 06:41:06 -0700 (PDT) From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Bin Meng , =?utf-8?q?Philippe_?= =?utf-8?q?Mathieu-Daud=C3=A9?= , Igor Mammedov , Alistair Francis Subject: [PULL 30/33] hw/riscv: shakti_c: Use MachineState::ram and MachineClass::default_ram_id Date: Fri, 22 Oct 2021 23:38:09 +1000 Message-Id: <20211022133812.3972903-31-alistair.francis@opensource.wdc.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211022133812.3972903-1-alistair.francis@opensource.wdc.com> References: <20211022133812.3972903-1-alistair.francis@opensource.wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=216.71.154.45; envelope-from=prvs=9222bbd82=alistair.francis@opensource.wdc.com; helo=esa6.hgst.iphmx.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, SPF_HELO_PASS=-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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Bin Meng Using memory_region_init_ram(), which can't possibly handle vhost-user, and can't work as expected with '-numa node,memdev' options. Use MachineState::ram instead of manually initializing RAM memory region, as well as by providing MachineClass::default_ram_id to opt in to memdev scheme. Signed-off-by: Bin Meng Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Igor Mammedov Reviewed-by: Alistair Francis Message-id: 20211020014112.7336-4-bmeng.cn@gmail.com Signed-off-by: Alistair Francis --- hw/riscv/shakti_c.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/hw/riscv/shakti_c.c b/hw/riscv/shakti_c.c index d7d1f91fa5..90e2cf609f 100644 --- a/hw/riscv/shakti_c.c +++ b/hw/riscv/shakti_c.c @@ -45,7 +45,6 @@ static void shakti_c_machine_state_init(MachineState *mstate) { ShaktiCMachineState *sms = RISCV_SHAKTI_MACHINE(mstate); MemoryRegion *system_memory = get_system_memory(); - MemoryRegion *main_mem = g_new(MemoryRegion, 1); /* Allow only Shakti C CPU for this platform */ if (strcmp(mstate->cpu_type, TYPE_RISCV_CPU_SHAKTI_C) != 0) { @@ -59,11 +58,9 @@ static void shakti_c_machine_state_init(MachineState *mstate) qdev_realize(DEVICE(&sms->soc), NULL, &error_abort); /* register RAM */ - memory_region_init_ram(main_mem, NULL, "riscv.shakti.c.ram", - mstate->ram_size, &error_fatal); memory_region_add_subregion(system_memory, shakti_c_memmap[SHAKTI_C_RAM].base, - main_mem); + mstate->ram); /* ROM reset vector */ riscv_setup_rom_reset_vec(mstate, &sms->soc.cpus, @@ -88,6 +85,7 @@ static void shakti_c_machine_class_init(ObjectClass *klass, void *data) mc->desc = "RISC-V Board compatible with Shakti SDK"; mc->init = shakti_c_machine_state_init; mc->default_cpu_type = TYPE_RISCV_CPU_SHAKTI_C; + mc->default_ram_id = "riscv.shakti.c.ram"; } static const TypeInfo shakti_c_machine_type_info = { From patchwork Fri Oct 22 13:38:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 1544964 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=wdc.com header.i=@wdc.com header.a=rsa-sha256 header.s=dkim.wdc.com header.b=WlYSyRfZ; dkim=pass (2048-bit key; unprotected) header.d=opensource.wdc.com header.i=@opensource.wdc.com header.a=rsa-sha256 header.s=dkim header.b=sEVIS1Nk; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4HbQzm3VQ6z9sRR for ; Sat, 23 Oct 2021 01:03:14 +1100 (AEDT) Received: from localhost ([::1]:50378 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mdv8Z-00009U-IC for incoming@patchwork.ozlabs.org; Fri, 22 Oct 2021 10:03:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57786) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mdunR-0003K4-51 for qemu-devel@nongnu.org; Fri, 22 Oct 2021 09:41:21 -0400 Received: from esa3.hgst.iphmx.com ([216.71.153.141]:41600) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mdunO-0001ji-SE for qemu-devel@nongnu.org; Fri, 22 Oct 2021 09:41:20 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1634910078; x=1666446078; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Q3J/9ZfAtD6dGQ6glAPWxRW9vcBMGsNnHZ+BYS9jqwo=; b=WlYSyRfZVF+LvL6ys0/xAnq7j7JNFn7xPZC4z6Bydc5Dr+dspo4Bf9Yp J1be5Q/fJ64t3WRLmfQmzTcKvqkMem7nONKzzUkbdNw84t5cVfsjmVn9b m6iRer3FV8yVM1oAfI2AcQksnBPA2YB2jxe8/tXUkvjWpqJpCX3AOwXLe nB1YETQscdwnm9uc+CdKCJn9sB5VNl6QYx+xz3A1rEljnTqDNUJMqQm0o ARLP1RCpq6tCsaLEVlkpyke0uVIDaVdnDbyYCu9AbG8O3BXIoRV9vmcKH A3nHy5QkZTMdXzoMD0YvC53zQWzjaBpoyCSsoxzz3xCZ+2BnpDq+Bz+8N A==; X-IronPort-AV: E=Sophos;i="5.87,173,1631548800"; d="scan'208";a="188392268" Received: from h199-255-45-14.hgst.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 22 Oct 2021 21:41:17 +0800 IronPort-SDR: K4H+mYu31Gbzo6rfDM2t7WI442Wuq7pOAFV93pmUbz8C23xgHVHFQz6Zjn8qWtapVrZKTlSZ0E LaGWMOwc2jevSh2XXfqowyz+G86D3MgBqKQuz/NCARDJnayysWLCXu+F7WLVx0aWWQZRn/rcAT xioI5Z1k9ck5FfrVCuANailzZlgtZWjIDmjS8nAAoDr0niDjDeaRx0cn0Z9Fhp0KayZfZZGof1 Vxlp9MFWywsuILkN9wW7AA8XmkL70SWTGD8pNskJBVisDtNXnjrJ7WLLBs4gkULg/g/s1BAVIW NhJ6PZ/mQI7nOp80yhvWorfC Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Oct 2021 06:16:52 -0700 IronPort-SDR: ResNTv/sf5ZNLhq9+oVhNY76IqNudpaCvVGT3Vfo6oF/vyNmEAy10TJyA2u/gNRJam7JRcTXN+ 0317OgjPTSlBLpzejI6aScKA7jQcO9EK+8q1SsZobNAUegLCO7jDgOBZGdCg2mToN2QR9FNlFo 5lTnUnD4EHfyxzvfqMAbow+qQjloEG67PPcb51LuANFY9HZitBN+VX+QCCInG/K2ut8JQfv57f ay9xx/eeV4ahV0rifvAMdzFMco8R602AC0BZDevRoe7Y/+KdB7pIjXkaT7+BXsA6sD6SxOHxFI SJs= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Oct 2021 06:41:18 -0700 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4HbQVP5KVXz1RtVp for ; Fri, 22 Oct 2021 06:41:17 -0700 (PDT) Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:content-type :mime-version:references:in-reply-to:x-mailer:message-id:date :subject:to:from; s=dkim; t=1634910077; x=1637502078; bh=Q3J/9Zf AtD6dGQ6glAPWxRW9vcBMGsNnHZ+BYS9jqwo=; b=sEVIS1Nkp3/9CWBfC6xP6md 2JtfX2ftpKsIS55olO39awvVQCAj2G8K7zXy0A3GjYNSDxPTueeHdq2H7U06itvB ZrHbkiW7GDo3evkXrHlkrhIfcX4DQ5eIKMHoEGmKv8mc+xLmAqeeE2FekaIO3QPt Zr0Bi3V80k2W7vgZX74GYjbjBcepwNJSNF05OU9NH/NERPWNyaAtKbqQ4skeDGDm 482ujtAhMQ9lmoYQPsc8BYnugooqyweHevh7dgsW9cu7+LK6otPDiBzsdM4+awD6 KGCnre3euU89SJbD0WrQBxNhsoj62rJSPAtGs8iKoMAHeVTFoUYhU/jsow1tqfw= = X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id XMvEXIEUDfG1 for ; Fri, 22 Oct 2021 06:41:17 -0700 (PDT) Received: from toolbox.wdc.com (unknown [10.225.165.39]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4HbQVJ3Rf7z1RtVl; Fri, 22 Oct 2021 06:41:11 -0700 (PDT) From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Bin Meng , =?utf-8?q?Philippe_?= =?utf-8?q?Mathieu-Daud=C3=A9?= , Alistair Francis , Igor Mammedov Subject: [PULL 31/33] hw/riscv: sifive_e: Use MachineState::ram and MachineClass::default_ram_id Date: Fri, 22 Oct 2021 23:38:10 +1000 Message-Id: <20211022133812.3972903-32-alistair.francis@opensource.wdc.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211022133812.3972903-1-alistair.francis@opensource.wdc.com> References: <20211022133812.3972903-1-alistair.francis@opensource.wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=216.71.153.141; envelope-from=prvs=9222bbd82=alistair.francis@opensource.wdc.com; helo=esa3.hgst.iphmx.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Bin Meng Using memory_region_init_ram(), which can't possibly handle vhost-user, and can't work as expected with '-numa node,memdev' options. Use MachineState::ram instead of manually initializing RAM memory region, as well as by providing MachineClass::default_ram_id to opt in to memdev scheme. While at it add check for user supplied RAM size and error out if it mismatches board expected value. Signed-off-by: Bin Meng Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Alistair Francis Reviewed-by: Igor Mammedov Message-id: 20211020014112.7336-5-bmeng.cn@gmail.com Signed-off-by: Alistair Francis --- hw/riscv/sifive_e.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/hw/riscv/sifive_e.c b/hw/riscv/sifive_e.c index 6e95ea5896..9b206407a6 100644 --- a/hw/riscv/sifive_e.c +++ b/hw/riscv/sifive_e.c @@ -29,6 +29,7 @@ */ #include "qemu/osdep.h" +#include "qemu/cutils.h" #include "qemu/error-report.h" #include "qapi/error.h" #include "hw/boards.h" @@ -71,22 +72,27 @@ static const MemMapEntry sifive_e_memmap[] = { static void sifive_e_machine_init(MachineState *machine) { + MachineClass *mc = MACHINE_GET_CLASS(machine); const MemMapEntry *memmap = sifive_e_memmap; SiFiveEState *s = RISCV_E_MACHINE(machine); MemoryRegion *sys_mem = get_system_memory(); - MemoryRegion *main_mem = g_new(MemoryRegion, 1); int i; + if (machine->ram_size != mc->default_ram_size) { + char *sz = size_to_str(mc->default_ram_size); + error_report("Invalid RAM size, should be %s", sz); + g_free(sz); + exit(EXIT_FAILURE); + } + /* Initialize SoC */ object_initialize_child(OBJECT(machine), "soc", &s->soc, TYPE_RISCV_E_SOC); qdev_realize(DEVICE(&s->soc), NULL, &error_abort); /* Data Tightly Integrated Memory */ - memory_region_init_ram(main_mem, NULL, "riscv.sifive.e.ram", - memmap[SIFIVE_E_DEV_DTIM].size, &error_fatal); memory_region_add_subregion(sys_mem, - memmap[SIFIVE_E_DEV_DTIM].base, main_mem); + memmap[SIFIVE_E_DEV_DTIM].base, machine->ram); /* Mask ROM reset vector */ uint32_t reset_vec[4]; @@ -142,6 +148,8 @@ static void sifive_e_machine_class_init(ObjectClass *oc, void *data) mc->init = sifive_e_machine_init; mc->max_cpus = 1; mc->default_cpu_type = SIFIVE_E_CPU; + mc->default_ram_id = "riscv.sifive.e.ram"; + mc->default_ram_size = sifive_e_memmap[SIFIVE_E_DEV_DTIM].size; object_class_property_add_bool(oc, "revb", sifive_e_machine_get_revb, sifive_e_machine_set_revb); From patchwork Fri Oct 22 13:38:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 1544967 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=wdc.com header.i=@wdc.com header.a=rsa-sha256 header.s=dkim.wdc.com header.b=CcMW0MlQ; dkim=pass (2048-bit key; unprotected) header.d=opensource.wdc.com header.i=@opensource.wdc.com header.a=rsa-sha256 header.s=dkim header.b=jWeEGMOh; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4HbR3F2wGtz9sRR for ; Sat, 23 Oct 2021 01:06:17 +1100 (AEDT) Received: from localhost ([::1]:56910 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mdvBX-0004Ur-4O for incoming@patchwork.ozlabs.org; Fri, 22 Oct 2021 10:06:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57802) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mdunZ-0003jC-Ko for qemu-devel@nongnu.org; Fri, 22 Oct 2021 09:41:30 -0400 Received: from esa3.hgst.iphmx.com ([216.71.153.141]:41600) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mdunV-0001ji-Ao for qemu-devel@nongnu.org; Fri, 22 Oct 2021 09:41:28 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1634910084; x=1666446084; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=cKiPzn9XfyE4z6ZkvhnZQVtENZ+U0d4S4Ry0tMgp2TQ=; b=CcMW0MlQy8VfOyaN/yJOejP1SVM3YZ+lQNaB6CAIGNuGrHQVoHSV6f6z e4CzzepXo3gbGyYW1DV+sknUoEIrwj7d4Mrt5HOe2Q+ACnRG46ov4bBqC Gkz/8eDXT6Rzb9uA+paxq88pCh3A+oA4R2gRfICjsnpVa7upyXA6UFLv1 9tLLmekk3W448UyplcGB86Rmvk42Ual/RPvY3VSdBnstI2QbAzAtyXRSg CZGtn7/nEkw8En+oX20T6dm3UDMHwd2V2R41+/BxiD9W/x90G/uDTHNbj 5ikC49HexwzBHbX+/VvRc0f3AIRU4wQcuJzbbv0davaREOLFysf3lUVqa Q==; X-IronPort-AV: E=Sophos;i="5.87,173,1631548800"; d="scan'208";a="188392271" Received: from h199-255-45-14.hgst.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 22 Oct 2021 21:41:24 +0800 IronPort-SDR: IoUfJ/G9P7Cv2aAv0qZrkl4pIaEE6vxV3k+Ziz+20db6/e/qBU5OqKpvWYjShJWLNomsLukRhb OZJmSuwMY93V2XzBdpNar6MH+FW29JOBWiVZKL9JUzqwQAHq/NvSRk1tsRHarJQYEt9KGKB9wK Kr1P8RW8DemNe3TGMmOpjgK0NIF5fa14LSlL0u4Sa6/yVeokCiox48Y41fLri8ZKURXCAxwgys OYxYMRDIB1arX0hxorY5b5/BX7iaIPBs6InVWz7lSAkEgasjaZ+allhzJBqCJFPIkZ5F1+gSOY jbUwGX9KdpWsv5v/GwFN5FMU Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Oct 2021 06:16:59 -0700 IronPort-SDR: rWsxN0vNkTs8MqnugBPUcDywv7clZkp606ekjbZhowcG5XXUAIIhgwbCSINzxZjp7mEdMWAmru gA0MLcPNslCCXasfzjBvsDVmNKG2OojMORLpbLhOjeG0yydeCwaSXv7iaHbENxuPL7cGDM0Lks 6UzwI2Ov1ESVZsMOYN7prlhCXwheNGTKdnZ04yHXnQ86VHdTMFP0jDVq8z0wbhMuKNpvb4jHJ8 lI4cSQIMqNh57fg6ffL7NUfLk1ZjiKUs9PCfg/UHqp9zsZr/AlM2oSAzcGtOpDTicUVvw3sJIa 7lI= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Oct 2021 06:41:24 -0700 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4HbQVW5GTSz1RtVw for ; Fri, 22 Oct 2021 06:41:23 -0700 (PDT) Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:content-type :mime-version:references:in-reply-to:x-mailer:message-id:date :subject:to:from; s=dkim; t=1634910083; x=1637502084; bh=cKiPzn9 XfyE4z6ZkvhnZQVtENZ+U0d4S4Ry0tMgp2TQ=; b=jWeEGMOhXq1fFeEqD68utQv lSuUYwZLIOOQPw4WcLynW4JfA4DVYyo42yw1PAjM+jJ1fzicOB0DP0AkzwF4Ljoi cwWn7YElXZ6ouSU/iMrEeVTa3l8CLTBYQk7rni/+aLFoJXzK2LXS0vzkSEldPd5g bUwkvjOBTywmS7r2NN0b4GX7LkSYJLUWOjq9DyL/bGOIQgs0VF0JP9JlfTsk/OA1 jpDlTjnyds/B+4cNr4XnpJpe9Ak4xVWk7zMAkISifS6chKpMvh8jOYVSUNF56bwJ /+UpdBUcupzg8GBFAe8ePA9L6icoCMTHCQ47TSDV2elSbLn0JQ1kx5qGiHIWEzA= = X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id j0yrwlch-N3c for ; Fri, 22 Oct 2021 06:41:23 -0700 (PDT) Received: from toolbox.wdc.com (unknown [10.225.165.39]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4HbQVQ2XBpz1RtVl; Fri, 22 Oct 2021 06:41:17 -0700 (PDT) From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Bin Meng , =?utf-8?q?Philippe_?= =?utf-8?q?Mathieu-Daud=C3=A9?= , Igor Mammedov , Alistair Francis Subject: [PULL 32/33] hw/riscv: sifive_u: Use MachineState::ram and MachineClass::default_ram_id Date: Fri, 22 Oct 2021 23:38:11 +1000 Message-Id: <20211022133812.3972903-33-alistair.francis@opensource.wdc.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211022133812.3972903-1-alistair.francis@opensource.wdc.com> References: <20211022133812.3972903-1-alistair.francis@opensource.wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=216.71.153.141; envelope-from=prvs=9222bbd82=alistair.francis@opensource.wdc.com; helo=esa3.hgst.iphmx.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Bin Meng Using memory_region_init_ram(), which can't possibly handle vhost-user, and can't work as expected with '-numa node,memdev' options. Use MachineState::ram instead of manually initializing RAM memory region, as well as by providing MachineClass::default_ram_id to opt in to memdev scheme. Signed-off-by: Bin Meng Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Igor Mammedov Reviewed-by: Alistair Francis Message-id: 20211020014112.7336-6-bmeng.cn@gmail.com Signed-off-by: Alistair Francis --- hw/riscv/sifive_u.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/hw/riscv/sifive_u.c b/hw/riscv/sifive_u.c index fc5790b8ce..0217006c27 100644 --- a/hw/riscv/sifive_u.c +++ b/hw/riscv/sifive_u.c @@ -528,7 +528,6 @@ static void sifive_u_machine_init(MachineState *machine) const MemMapEntry *memmap = sifive_u_memmap; SiFiveUState *s = RISCV_U_MACHINE(machine); MemoryRegion *system_memory = get_system_memory(); - MemoryRegion *main_mem = g_new(MemoryRegion, 1); MemoryRegion *flash0 = g_new(MemoryRegion, 1); target_ulong start_addr = memmap[SIFIVE_U_DEV_DRAM].base; target_ulong firmware_end_addr, kernel_start_addr; @@ -549,10 +548,8 @@ static void sifive_u_machine_init(MachineState *machine) qdev_realize(DEVICE(&s->soc), NULL, &error_abort); /* register RAM */ - memory_region_init_ram(main_mem, NULL, "riscv.sifive.u.ram", - machine->ram_size, &error_fatal); memory_region_add_subregion(system_memory, memmap[SIFIVE_U_DEV_DRAM].base, - main_mem); + machine->ram); /* register QSPI0 Flash */ memory_region_init_ram(flash0, NULL, "riscv.sifive.u.flash0", @@ -748,6 +745,7 @@ static void sifive_u_machine_class_init(ObjectClass *oc, void *data) mc->min_cpus = SIFIVE_U_MANAGEMENT_CPU_COUNT + 1; mc->default_cpu_type = SIFIVE_U_CPU; mc->default_cpus = mc->min_cpus; + mc->default_ram_id = "riscv.sifive.u.ram"; object_class_property_add_bool(oc, "start-in-flash", sifive_u_machine_get_start_in_flash, From patchwork Fri Oct 22 13:38:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 1544966 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=wdc.com header.i=@wdc.com header.a=rsa-sha256 header.s=dkim.wdc.com header.b=cojeybXh; dkim=pass (2048-bit key; unprotected) header.d=opensource.wdc.com header.i=@opensource.wdc.com header.a=rsa-sha256 header.s=dkim header.b=JWSzgrcg; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4HbR0s42tdz9sRR for ; Sat, 23 Oct 2021 01:04:13 +1100 (AEDT) Received: from localhost ([::1]:53344 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mdv9X-00027h-CD for incoming@patchwork.ozlabs.org; Fri, 22 Oct 2021 10:04:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57848) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mduno-00048K-RR for qemu-devel@nongnu.org; Fri, 22 Oct 2021 09:41:44 -0400 Received: from esa3.hgst.iphmx.com ([216.71.153.141]:41600) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mduna-0001ji-RA for qemu-devel@nongnu.org; Fri, 22 Oct 2021 09:41:44 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1634910090; x=1666446090; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=aE7fjaVrt+fTk3k4mC1U/oRpRWRe6TR3bXJiDmVNzj8=; b=cojeybXhK7HKjd5bbvPKTjZfOuIpxjoyw31GYXaZmhwbn9dXS/DBLsKi p8oLFUFBWLu+0lWCHS9n7hk7AmKzhr4WA3+En9g+oSvbgey8N2goo2445 LZa9/S4HKbCYaDo6xFQiZQmMLGtHsRD4BL+KSZSEuX0PfNUhVqSngSLAt J8hgl1VB1QovGvbvtUtCa9/UEfo/C8sYy/x3oRK8thvJg1DSGY48mi0q8 vfA8tZctICOsPYTIGCUszhQElm+bbQYFc0pbYLUSyZGWCk/k+0bogh/6+ gcRpn7JM109zqlf0pBeLvftQK/TBbpayFwYt89Veo/pFXxG0/mni3Su2h A==; X-IronPort-AV: E=Sophos;i="5.87,173,1631548800"; d="scan'208";a="188392281" Received: from h199-255-45-14.hgst.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 22 Oct 2021 21:41:29 +0800 IronPort-SDR: hv93oYRH6u8KOOwbzlJzHMqDkEesdL+m76LNwCiM6b27gZUk4fIglmYFAEGTVpaJ2vNwmVFoMH AmpiNWXLlTSzSZRJhieMblryH1tU04a7B8viFEtMzydI8FnZYQHT5Cb2zyiZmFClHLqRPtdwtE 5ZCCnTlERxJ/t/m6yLOrnTlNEXTDWNvF17i2TexMR/WZku3P0c6f9/9kWpGz6ZOrpSJHbED1MG kthc3CDYBA42/UB04KiwSU1BAZGJS5iMmg2p14w/VrXGchUqwNLD1z7WyD64+T60fmFVy+pkFv fvaxVhOrg3ZMxTJEUPlxrW4v Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Oct 2021 06:17:04 -0700 IronPort-SDR: INk61Zq0hudvZusD9wk9xI/3I/6LMcUjWgD8Bkj6CT8upG+iaDizOpX73KvrlDQlRZ7zVIq9Ih RZhawCxUcdU3onfUNIjGaYtOwt2tHXn3pI5xVwse8jO/zHnmDUPWFYb6oSHB6yLbvyVdB/Kdnj QH/IOctJBoOfjedPDlVaGZZJcCQle756+POktjmRAC+Aa+JbH5XfPi8+ChyFeAa/n/PmYvKN0s tdQxGoGJ4nqq67CKj0sIJ0bpnYWcDYBSYNYjCnj0QYEo7+lH9wl0Vh6qk2mB6NlV0jubBgAU3W h+o= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Oct 2021 06:41:30 -0700 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4HbQVd4rS6z1RtVt for ; Fri, 22 Oct 2021 06:41:29 -0700 (PDT) Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:content-type :mime-version:references:in-reply-to:x-mailer:message-id:date :subject:to:from; s=dkim; t=1634910089; x=1637502090; bh=aE7fjaV rt+fTk3k4mC1U/oRpRWRe6TR3bXJiDmVNzj8=; b=JWSzgrcgHwBAeoP964nvZpy d3yEy48RLme1Qf+0lDr3xpwi3vX5Z8CgYgnx0+yi+eot9v3H1AawMOJg4nhg9/Zq EKtEl2tjE129fBL1bP3avisCwjO3FzzaV1F+2OONe11DSggZNFQ0VMb6p55f8rrq FrxHP21QuexX2utVLka+/MX+S5CKf5Dts/ss/L+rpVbCsH+qZQ03kuE6SyU2M/Iz R8OpgDiHqe+ioeT0vJLsXttxknCkIDNZ4g0/9P5aDogt2gtJYOeWeGWPE8LGLMDD JUe0LIRuSX6wyQP3B49gLxGOr/dKi2/+4HOS8tJxHYVW/XC6tO9fPGnKC+096yw= = X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id 2mPcicF7uZpP for ; Fri, 22 Oct 2021 06:41:29 -0700 (PDT) Received: from toolbox.wdc.com (unknown [10.225.165.39]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4HbQVX28p7z1RtVl; Fri, 22 Oct 2021 06:41:23 -0700 (PDT) From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Bin Meng , =?utf-8?q?Philippe_?= =?utf-8?q?Mathieu-Daud=C3=A9?= , Igor Mammedov , Alistair Francis Subject: [PULL 33/33] hw/riscv: spike: Use MachineState::ram and MachineClass::default_ram_id Date: Fri, 22 Oct 2021 23:38:12 +1000 Message-Id: <20211022133812.3972903-34-alistair.francis@opensource.wdc.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211022133812.3972903-1-alistair.francis@opensource.wdc.com> References: <20211022133812.3972903-1-alistair.francis@opensource.wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=216.71.153.141; envelope-from=prvs=9222bbd82=alistair.francis@opensource.wdc.com; helo=esa3.hgst.iphmx.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, SPF_HELO_PASS=-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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Bin Meng Using memory_region_init_ram(), which can't possibly handle vhost-user, and can't work as expected with '-numa node,memdev' options. Use MachineState::ram instead of manually initializing RAM memory region, as well as by providing MachineClass::default_ram_id to opt in to memdev scheme. Signed-off-by: Bin Meng Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Igor Mammedov Reviewed-by: Alistair Francis Message-id: 20211020014112.7336-7-bmeng.cn@gmail.com Signed-off-by: Alistair Francis --- hw/riscv/spike.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/hw/riscv/spike.c b/hw/riscv/spike.c index 79ae355ae2..288d69cd9f 100644 --- a/hw/riscv/spike.c +++ b/hw/riscv/spike.c @@ -180,7 +180,6 @@ static void spike_board_init(MachineState *machine) const MemMapEntry *memmap = spike_memmap; SpikeState *s = SPIKE_MACHINE(machine); MemoryRegion *system_memory = get_system_memory(); - MemoryRegion *main_mem = g_new(MemoryRegion, 1); MemoryRegion *mask_rom = g_new(MemoryRegion, 1); target_ulong firmware_end_addr, kernel_start_addr; uint32_t fdt_load_addr; @@ -239,10 +238,8 @@ static void spike_board_init(MachineState *machine) } /* register system main memory (actual RAM) */ - memory_region_init_ram(main_mem, NULL, "riscv.spike.ram", - machine->ram_size, &error_fatal); memory_region_add_subregion(system_memory, memmap[SPIKE_DRAM].base, - main_mem); + machine->ram); /* create device tree */ create_fdt(s, memmap, machine->ram_size, machine->kernel_cmdline, @@ -326,6 +323,7 @@ static void spike_machine_class_init(ObjectClass *oc, void *data) mc->cpu_index_to_instance_props = riscv_numa_cpu_index_to_props; mc->get_default_cpu_node_id = riscv_numa_get_default_cpu_node_id; mc->numa_mem_supported = true; + mc->default_ram_id = "riscv.spike.ram"; } static const TypeInfo spike_machine_typeinfo = {