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: 516124 Delivered-To: patch@linaro.org Received: by 2002:ac0:bf50:0:0:0:0:0 with SMTP id o16csp1097691imj; Fri, 22 Oct 2021 06:42:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzotMijiw7oEgp01Yv5r7QDYKM7jBN6VBkA3MJWK905HNN6BR2yFsC5ATBlWo1qFAyFZj2Y X-Received: by 2002:a9d:424:: with SMTP id 33mr10083285otc.340.1634910169529; Fri, 22 Oct 2021 06:42:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634910169; cv=none; d=google.com; s=arc-20160816; b=LzqpafyCxj2CNZwj0PEp/AYRPvZQezWKI/J8GlMEo37Hag+ctgAT2rIczm36JIxIjx b/cDG3uMYs/eZHKo0xzAYxpKTYfKAIbDfnpMmtQIyZmCjfCdtFNHNTZOgWhaaz6IgWNB e13P0OPlY4GBo3ZYMADmnFObwIhwwwslKv+t7nHDyQTMzFo4M3T6eMbDbU+mbEXNbwsj AiAZOJV2042EkQHd5O1SoJ06pnmVyTAOXxlsv+bf7b6wlCTJ0nqDNaWZ7XnSYiA2EqDq 5AR7AYjXhqfHNu1MeAuJstxSQFikaPxLxoetlpaP5fhDrPskPPwJY+nzY3ym2qMRXltn DM8Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature:wdcironportexception:ironport-sdr:ironport-sdr :dkim-signature; bh=WRG+KRwXkA8eRWLbxBEwJSz01O/FNI7z7TYQOcrLQHg=; b=lwI+RmP2jCy9w7DnLP7eQ++2p5cDuoP9FUG3DPug6jXhu/UAT0yxBdD2S5DNdCkeYU Cn58o7m/SaY/u05Bo8p0WEkksikwvN2PqpmA027BakNeLgmpbxuFworonKPxceytMhNb Ib5WWRwF+ZOeNmqrOcGusO57p9JXfKzRgF0J0uXV+BwxdNbUdj2hl8Xi5UW3MLni5f7s /xtg+EVf7uQZ4ZHD6b24iONa+f3TaKR8JvV3fPlZDAafXBoy/U3lWSsZnJyGZgvNSNK2 WCrYusqzgj5/RrXQjFZ5TTs8NjuqvcYm6LPMEznuWdS9l0sXGYleUpDWZgGZ+xw7WUB5 I/ag== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=R6+lEQVI; dkim=pass header.i=@opensource.wdc.com header.s=dkim header.b=eSmcvAMY; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=opensource.wdc.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id l2si848425otl.324.2021.10.22.06.42.49 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 22 Oct 2021 06:42:49 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=R6+lEQVI; dkim=pass header.i=@opensource.wdc.com header.s=dkim header.b=eSmcvAMY; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=opensource.wdc.com Received: from localhost ([::1]:52186 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mduoq-0005H3-O6 for patch@linaro.org; Fri, 22 Oct 2021 09:42:48 -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+patch=linaro.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(-) -- 2.31.1 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: 516126 Delivered-To: patch@linaro.org Received: by 2002:ac0:bf50:0:0:0:0:0 with SMTP id o16csp1100311imj; Fri, 22 Oct 2021 06:45:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyjWX1eq7SpEGlVnXzUmr9XfWu9aXC6+iUPsPHCce+qvHNst1jMork481n27y9bbO0W9EEc X-Received: by 2002:a05:6808:2393:: with SMTP id bp19mr9783542oib.149.1634910322262; Fri, 22 Oct 2021 06:45:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634910322; cv=none; d=google.com; s=arc-20160816; b=gWxRbRH58lHdm1dpKu8EbZKhPFsP6MqWyAU4n8KAlBg0S6NNGcQbUixnETC0kU+duv APaFXRNCyPeefs+kq2zt2WEMFErdJjl9VEJ2HKu7XFcI9D16I88/feIQ6HlvDZrXEy8B 2O88XTN4st3y30xevxZ2RncKbM9o36Y8ZZEJ6ZadvmkMt4UYC6gxZ1kZJM9PnjjMibRV eF/PUboxC0Blb92QdOms7cD3R5F/zOUBn4V59qVYa+ZhZVOa6iGcwzPO8gA3/9EZfzuz Fng+BJsPOk1dmWzwE9ujiqGlizU3eJSt4wIPCu4S4GdQy7fXltC52X2laXz/idjrhM5I 2kuw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature:wdcironportexception:ironport-sdr:ironport-sdr :dkim-signature; bh=Za6NsnQoFZ6n/UCMo5DXLwLAIiV8ZxsRPWxOjUFhUbA=; b=qvphjai0xWDhG4TD/uGtGf6rYpLToG7Z5WFwAHLFezA9u4uc17Lshk69bx9F1Ntvr4 AgNfq+3kRXXeX64In0CGYKE87Tpj/yYf9Zdc84V6l8vwqsV8+KLqPfFIy//uJkcuYQiG JzjbyDhMmTRzUYm7CrSqt1vEX+adrcUaOMZufqLWf3Z7OioiteZmCXNkZvRj66sQY8P+ C/qlX9yAYBvNq0jBLeuKd9x7zgBEBDjvhTiFdG/YvE0xLDl9dSrlUdN8bEpxdnvMP9xL hXWU33sNNGZ1WZM3HY9XN3NLgrqUpDbGsyIwCxJwRVNViDlz9WdP2b952yIWVyetlPx7 4Qfg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=EUjBOBeT; dkim=pass header.i=@opensource.wdc.com header.s=dkim header.b=QLOYhqHn; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=opensource.wdc.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id j75si10128544otj.126.2021.10.22.06.45.22 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 22 Oct 2021 06:45:22 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=EUjBOBeT; dkim=pass header.i=@opensource.wdc.com header.s=dkim header.b=QLOYhqHn; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=opensource.wdc.com Received: from localhost ([::1]:60758 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mdurJ-0002az-Ex for patch@linaro.org; Fri, 22 Oct 2021 09:45:21 -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+patch=linaro.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(-) -- 2.31.1 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: 516129 Delivered-To: patch@linaro.org Received: by 2002:ac0:bf50:0:0:0:0:0 with SMTP id o16csp1104022imj; Fri, 22 Oct 2021 06:48:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxMunaf/+wRZW8Bzk2kNRD/pQ0TWHDNU+gMMifvCkaqrOZUmGer1GaWc9I9h0BkxQOlnAFF X-Received: by 2002:a9d:6f06:: with SMTP id n6mr6461otq.228.1634910533968; Fri, 22 Oct 2021 06:48:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634910533; cv=none; d=google.com; s=arc-20160816; b=VArp4motUq4/5LkLue9OieuSMuzhue6kudvtVs0bcBXGecXyWRStuy4R/zGLO8vV0X qb3SGod6XJNFiTZs9+fVrg4IYaq9ySFiiCKOY3DAMWvY9fXKvF5AsS9Lm0a0bs5m7J3p 8jkiku4x9u3tZyjM5p4e8YCPRJrhabiSbaGPnyy3YYc8aiNL/cgnOYY+NvSoiZX1wNYo BvNkOwF2uXOcvTGVp7kfTMtuvdlhEIUarsVt21zhbI79XYer9vl7U4zyBM4gbIomF6Fh rXOkGk1/A1pmkagAoVeyfwKk7lsYwDCm3CDwcw6TrI7NAF98F9DSx35setvzLVtEnnTD DK6w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature:wdcironportexception:ironport-sdr:ironport-sdr :dkim-signature; bh=+odRnVRPcmw9nP3tjjVjcTiQiJtDQaHnGi3hONARio0=; b=N219fvUFZNBPKFhLLzbKUEXJPmzLEn3wVohCH2z9fSLS/pKeSjRCFE2aqV1CVUdRBt dDQ8DJNmuaUSUegMU/dtsT2HDPd9py9Vm6BQu4kQQ/cu1nJJvMlDSoqDHe8u1fxvtdVn QpwKJbBcHxWPWvyrjvhX5b2Zrt1h4K8RUCAchFvaei9kHMP/T+jd+qnVa43dbzi+v7v2 0o4g8oaA0XB4nOP0ndRQCnmRTRh08WxJ4Hx2+/BL81Vsuh1Zw2PO4ArGF3QsVXG4GVti dp9tB5HOUBLFGdhFJxgQxSo2i9bUYhpWJx0HVkRgeIugjn7agDHOPaUwYpQFdAR7hjeI UFlg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=K+3M56LW; dkim=pass header.i=@opensource.wdc.com header.s=dkim header.b=dDlYTPsz; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=opensource.wdc.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id bb6si9359664oib.48.2021.10.22.06.48.53 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 22 Oct 2021 06:48:53 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=K+3M56LW; dkim=pass header.i=@opensource.wdc.com header.s=dkim header.b=dDlYTPsz; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=opensource.wdc.com Received: from localhost ([::1]:41036 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mduuj-0008K5-3i for patch@linaro.org; Fri, 22 Oct 2021 09:48:53 -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+patch=linaro.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(-) -- 2.31.1 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: 516125 Delivered-To: patch@linaro.org Received: by 2002:ac0:bf50:0:0:0:0:0 with SMTP id o16csp1100221imj; Fri, 22 Oct 2021 06:45:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxKpAMR6TwLQOOQC8E1vmKhRN2z5347wqs0YBeQisptyCeLGf7hWy1NSM76JFKBDebmogGb X-Received: by 2002:a4a:b881:: with SMTP id z1mr82987ooo.68.1634910317940; Fri, 22 Oct 2021 06:45:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634910317; cv=none; d=google.com; s=arc-20160816; b=n+h/waUt5ucOSFIF4lmduHde9iNDtN7gJaFG5R8cu1DVVdh2C1zjqj5rzts7HOdZ+L /TaXOBlnhwqKiLaXhXTs3rj+aS1c2ngzkjtJjjgFogOU9Gvs8mt34oJBFYa5IOVB1/ed CeUlZWx2FewCzzL4Mu7SgSdjWUerEVatSfh2QAXRXcuJZHSfTubho1q4tz1lmA4Ql4Y3 rMxJnXqwacfljTvp59KPjXdOh8h5ZrxzWAHOMK2+FYkXVDNRZQnP0E0DAlDoy/E2t6zp mdLnnUtryJqMDE+9T09Tt8Lj/CHAPLu4WVdIIuKlRar5DEK4zDwn3geaiXxzLy3tQzMQ 4FSQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature:wdcironportexception:ironport-sdr:ironport-sdr :dkim-signature; bh=euA8hTfoHivkUchC7yb0yzU5IekP2RL40H3qmYxhXG4=; b=QlQecTKdHZUuu0tcgLgilHWjtyKiGrx9I0q2cz05pax5/O8qfB5KLjefn7+z+9EM9V dsen2MaHRo6h3eqGRDr5RuUaMQVVCNQzaOpe7mjdF0wzR8CbhlIPkN4I7JlLXbyGikSh 79oT8VeGph5WIdUa/yhU9eJwFkBdyhejnmdfnBRylXff5L9rxjm3JhCOhrd4UMYnPujr ea4Iy0fjbSGrtY3R0+mmfXwBg98HfnBYDenSi/omEJfqVx+fcS3g2FdzYIwDmgpwfNn+ 1w9yIcuN+m3YUWTqZNcQRxjbQdyaq8Gn8jEgNCUTf7y1qseuvGNXosCFY5LNM2PRKDrz gkWQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=rLgoPZFy; dkim=pass header.i=@opensource.wdc.com header.s=dkim header.b=eH7ySAKW; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=opensource.wdc.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d21si11133152oti.241.2021.10.22.06.45.17 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 22 Oct 2021 06:45:17 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=rLgoPZFy; dkim=pass header.i=@opensource.wdc.com header.s=dkim header.b=eH7ySAKW; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=opensource.wdc.com Received: from localhost ([::1]:60394 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mdurF-0002LL-5j for patch@linaro.org; Fri, 22 Oct 2021 09:45:17 -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+patch=linaro.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(-) -- 2.31.1 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: 516123 Delivered-To: patch@linaro.org Received: by 2002:ac0:bf50:0:0:0:0:0 with SMTP id o16csp1097657imj; Fri, 22 Oct 2021 06:42:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzeO5dI1avz9DwOdMvXUANKUCaYuLCJPNB0+jEyeLj4bNz46IPxbvzHK5b/My2ivbl6A81j X-Received: by 2002:a05:6214:1370:: with SMTP id c16mr11726795qvw.36.1634910167594; Fri, 22 Oct 2021 06:42:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634910167; cv=none; d=google.com; s=arc-20160816; b=V0z1tP3o/kkc3dZgoJDYpSD6IbeOhzkXXrLtnpxxEaQSUe1KDbg/SCEryeWAlgq+EK 6V/uZyUn2tayV69b+IgcxI3ok9D+U8AWYAudEMPbqoRcwassdhGk6FVKhDtMG9BRVwFf 5Wg3UYDClpIK+4MVxkCXazQCEOtGWUoJJ+6E1qznSXLmpAi+l4ArrYJLqUWzssVtgB1i 14ifFIA91rkShf1Ru/D0iiT6s/yGqQIOzBYwT5vi/hggh2w4KDjNgsqbnl2vX+vnSiEW +RPTWIPsjqjs4GoQwBMLVXfd8n5HWTzEcq4l/oGXL/gDZSsZdNjnB6w97nr8LOJWw26d CXnQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature:wdcironportexception:ironport-sdr:ironport-sdr :dkim-signature; bh=YW4YzOR0uksULT2OD1VI+PDEV2GRLJsRzOQBkyNjFYg=; b=nYusQHRThZyl/l9mNaw5oc4H3ov6o89tkzzzN0rOoPuQScP6uaX5r10laC35ua567L QG3iLVa4EO4ZkYPyeuQZ790wntgBE/cRGwTKikjqoZ6f7Go7W5ZJVy6vpuTz661Oac9D w1pAbpVz9ycWt3+/bOSvlssHkL9PZjgR5fC2vID4f48tSHzw0mWs6J1iNCdAKM+7MqrH 5LJ2jPAGxc9DyzlyZGQp3xgz+iDj2qF+3pBtPjQX8ueSQDoG0S//KYbRmrmScGN6GYQx ZnDjzcsq9bMR2vZ/LSbyc0PQsG5cG0tPJHLaS9l2ZbJqMb6HNbw0j8AW6v5a/dr69hlk zq7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=THqtcj3O; dkim=pass header.i=@opensource.wdc.com header.s=dkim header.b=uQCzIyWJ; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=opensource.wdc.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id s15si9112788vsh.49.2021.10.22.06.42.47 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 22 Oct 2021 06:42:47 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=THqtcj3O; dkim=pass header.i=@opensource.wdc.com header.s=dkim header.b=uQCzIyWJ; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=opensource.wdc.com Received: from localhost ([::1]:51778 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mduoo-00050R-Li for patch@linaro.org; Fri, 22 Oct 2021 09:42:46 -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+patch=linaro.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(-) -- 2.31.1 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: 516127 Delivered-To: patch@linaro.org Received: by 2002:ac0:bf50:0:0:0:0:0 with SMTP id o16csp1100333imj; Fri, 22 Oct 2021 06:45:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwyKMLZjJQ8eSzD9mGmHhpx3sQLItFEsaTIgxpM68VgFqPdvmGBfyVwEFY2PnEVM5HWO050 X-Received: by 2002:a05:6830:410d:: with SMTP id w13mr10198285ott.292.1634910323236; Fri, 22 Oct 2021 06:45:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634910323; cv=none; d=google.com; s=arc-20160816; b=JsrZJX4itbRsU5E0CasAkAYaon41e+nlx6Z6nWF0hJvUEiVH/86zAUzuSsMxQuvhf9 xXicdB9DxR4svgjzsGK/MyELE9RA94oZm5YmiDzMxFmTvRWaXAYfvyfK3V5boTRe2s3s 02m2HXNW6ZleDjnrWZv7B9LB1NwaNAghN91IeHZPj5RkchqbqYujRd2PLUW9aGwpPf6K +Ao1mKK+ZAtdDc/le3rxKV0gCXu4h4c/63XsxOA7DbD/4RKOkGFSBe0UK4Dwr8JwyF1w vcEaXSVVA8j61G9Dk80pULXgTu7BiZphRH9X0et7hFg/s8Q7bmd+l627GFF6HelmWDEr rE9Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature:wdcironportexception:ironport-sdr:ironport-sdr :dkim-signature; bh=B4zynxb8Pgnbr5miWYqfrnVK/BZUFDr5g2B/k86wjcc=; b=CmoH8UqZARTSUlgrKVADWYHuti5CunOQUpgP4Ls70at6D38BWRGbYI7szubKx9wbG6 O4gKIoFKCq4PyEoRjoxcTHfnUjk8CBumFgSCAN8p4y6ZQ3bfonKecmE5WMTTb2GIFT0T nP6u6L9RAvtN+wIdjxybawri/qsDco7OwKTFKyG+S1MK5fEoR1GZfry4LtBmp/BvDbTY c6zC6UG2EtTnDhIwjnBoMpC/p6jPA6ru3asTHUsyYLvgfguCB/kVvARqAJ/c7HzswbOi IeBGOMkFlsYiEk76pc5YrkMj/RPazr3Tb+Cp4Kn+eX+nmhQnIF+1uzlmZDRfXq6TaehR tVtw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=IxDL0TOo; dkim=pass header.i=@opensource.wdc.com header.s=dkim header.b="TKwtD/FM"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=opensource.wdc.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d17si3571645oos.23.2021.10.22.06.45.23 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 22 Oct 2021 06:45:23 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=IxDL0TOo; dkim=pass header.i=@opensource.wdc.com header.s=dkim header.b="TKwtD/FM"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=opensource.wdc.com Received: from localhost ([::1]:60850 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mdurK-0002dr-H2 for patch@linaro.org; Fri, 22 Oct 2021 09:45:22 -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+patch=linaro.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(-) -- 2.31.1 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: 516130 Delivered-To: patch@linaro.org Received: by 2002:ac0:bf50:0:0:0:0:0 with SMTP id o16csp1104448imj; Fri, 22 Oct 2021 06:49:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzpts+9FCCE4fFH/ilWqxbQSt/FK16w5+vI4WZFUbJjiIG+49y1eAKASAj16JXkzXMnDQr6 X-Received: by 2002:a05:6808:1187:: with SMTP id j7mr9812587oil.135.1634910562817; Fri, 22 Oct 2021 06:49:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634910562; cv=none; d=google.com; s=arc-20160816; b=nr8FEZdgahTfKioE5mnBFEbKP+l50XzxXl26HrpkeBMZRgSCp7Ug0FTzLsG+e+lZeb W2tIH2AB8WyHnLRUQEAXkfSngvkOZ2JUzAFc1GvrCQD84cvnEleBGZyHqfLkFsqJBy8X X8ywYCxYysB7lZ1M97UCPjYcRZkbQrCh8W9KOM/4A7b60s1vT10L8/beEfbH5++FZF+6 SdvIsX2xnLMeg1YctJvi6K7ju1kYXUw3zZYpR74nd9EzHuOKDQV2E/idbXj0WieWe+NO /0Ni13U734faFF0uNwrGceI3nyy/oO1flVXXApomMgvJwLsZJ+surHb+IRmy+2kmooq4 s08A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature:wdcironportexception:ironport-sdr:ironport-sdr :dkim-signature; bh=y/i77g8wGC2Mcr/pQ9P34Rksze4tMRRroEd7SeRHYXw=; b=HtZrg4nROdeis15m2DDezw8MfP5c5Gjz9urFqAa4WmrAGy8Exag6ISGZaeMyCh3hjQ bwcy1HPDJ7oJ/WbSMSCfONPE1oZ2PHvpIOQQ65qeq2SiwX76IygtlSnQ38ldtzENmuDU aFCv1iLXa38BR/KvfSXublDckQn9dt1Q7033OwcjGDl6D00DM+tq9m4/8wb6VYiiNuSF gMlh0l14s0CvlEG2vCouTXeqEIUEogZLD4ZCg2yAnSklx+mEAKCd68TxMFQr8RpY75CD mq3MoU5tyYqKo14qDm//op/mYCnT7AiET92GAkkFhTnCt37kyM0UZL8W5znhpENhNVQW 1KUw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=WkkIV5rU; dkim=pass header.i=@opensource.wdc.com header.s=dkim header.b=rFM3rcm6; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=opensource.wdc.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id z63si7846334ota.287.2021.10.22.06.49.22 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 22 Oct 2021 06:49:22 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=WkkIV5rU; dkim=pass header.i=@opensource.wdc.com header.s=dkim header.b=rFM3rcm6; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=opensource.wdc.com Received: from localhost ([::1]:43856 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mduvC-0001kL-4h for patch@linaro.org; Fri, 22 Oct 2021 09:49:22 -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+patch=linaro.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(-) -- 2.31.1 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: 516131 Delivered-To: patch@linaro.org Received: by 2002:ac0:bf50:0:0:0:0:0 with SMTP id o16csp1106109imj; Fri, 22 Oct 2021 06:51:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxnAFuNQYU4U3GTruhDL6l6rZsAtL3GQiW3ZVUruh8aDj4UxAiXr+h/1IjxtNRCyFVOMxyX X-Received: by 2002:a05:6808:f8f:: with SMTP id o15mr6443594oiw.38.1634910664777; Fri, 22 Oct 2021 06:51:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634910664; cv=none; d=google.com; s=arc-20160816; b=tdX+fG29+pOFl8Xc+YxdwflQ+MqfNSobUucR2XUlkAJIEcmFrwEHSxwcyMR56xRl7h TYbq2+v2t9I+ZpSlMLSfI7+qTDlHoTU90pzF6YgaUXPH2xS035lF/Uo9TWejEz/gYxt4 PvTdx1FpwFGOoIilY+oRA47e7aZgXou2+0yny7YStPDr04UCYvs3hKMKbA6pos2jEJpl YcUD7H5ZciOyL09ExzfLM5XMK2IitIyYEdFQiaim8z2olU7kb55Rn4IVfxiz8Y6+RqJo 2WMm/eAmCpdiyWSejs2AdvwBHeoGrdckX8iRsRMpR7F0LNdOlJ0HaKfZDrBDcC9KGS5G 7yPw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature:wdcironportexception:ironport-sdr:ironport-sdr :dkim-signature; bh=5gWT83B5U8F7K7IJpAsZe8lv9jEsapPiiNUrFERF5kw=; b=DVTu+QFqhYUstHYx153793iWpPjM2WGGML2nIIZvAK8RQWAa+zuHLMOeHVl/099GG8 FylUSPE821uYBQ/QgPCtkkjiPwyStXNd9JA12XKP0dTOyYULJQA3M6Ux25XalsXbkPb5 xKfe7XM05RpC2VMo38wTqn3o8odG9UuHNEk4NqaTC6a/w5ui46qHjIer608gnHS/BFY8 0xvjoM2OykqHjR1SNgcbQXaIJuZzEqzR9mTnBi0VjqopGyOPd8SXfmiXDwHHwc44BKYX 7L+Iut7NqmGhaE7P2v6nT2BEpHjjZY5UyMGynPUK4Da/qUSMkAmMsCerJ5fvwD2KEK6E HYDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=hyB8KPVd; dkim=pass header.i=@opensource.wdc.com header.s=dkim header.b="oXHwcdJ/"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=opensource.wdc.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id k25si9636562ooh.75.2021.10.22.06.51.04 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 22 Oct 2021 06:51:04 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=hyB8KPVd; dkim=pass header.i=@opensource.wdc.com header.s=dkim header.b="oXHwcdJ/"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=opensource.wdc.com Received: from localhost ([::1]:48864 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mduwp-00051v-Dw for patch@linaro.org; Fri, 22 Oct 2021 09:51:04 -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+patch=linaro.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(-) -- 2.31.1 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: 516128 Delivered-To: patch@linaro.org Received: by 2002:ac0:bf50:0:0:0:0:0 with SMTP id o16csp1103936imj; Fri, 22 Oct 2021 06:48:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxbT/NQ3U0QNAzk3AJHHXMcKtIEa7mWguXJmHMXWMYD7cKBrmKFPbqe0nrDiCSYr527I1y2 X-Received: by 2002:a05:6808:df1:: with SMTP id g49mr2263723oic.111.1634910530048; Fri, 22 Oct 2021 06:48:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634910530; cv=none; d=google.com; s=arc-20160816; b=SqgkjlMsC9RLU4cCtTDSwBTGo5WOQQM0WUYvDa64AiXhp6iT0kiwOhlbkUPMpAPVCK F3jveiDUqiJoBVRZIgogpfodf81Trouf3d4Z3ONWBwcE83gqXhctbTzXvSPTw4Uc4ing j4kT3RjBqh4Ojh4hFvrkF4PH6W/JmvSF+v9CXl7rs9JxbyPKjkC5N5Xl5L7VbGJlYUQe ib6k7aPDDwEeH6TASc6BradvtX5l051D0uG0xsu1yIQ+CZEGMr3QPWh5vQk4NBW7nfF9 EI2T5tdR95XvwynP7O6csBqXGpq5FuAonYYtL+o+K0qyt4qnDextzIbm3SzPgiu77dW2 Tr8g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature:wdcironportexception:ironport-sdr:ironport-sdr :dkim-signature; bh=5ixxZg+8POQ+paITrzoREg5IzyTHGVsTNgeX4JjQHHc=; b=PUmbrq+SFlavjs8id5N82QQxc9mH/tulK5Up4UcgFLMPIQDUjmg6sV2qIkf17xotZu wI+42jm9AlOfvcF7GFJqk1d0dijKAcf2lGfLrr0PTCbgP8BAWfxg2ihPH8SkCVh2kths Q8DuJBxs4wBgzWapvSYP5We8KZqXbhCXrVy41AR8GHiJ7ADgkvLVAsBVoIuwFXjwqMsC CDRFzKpK4vIfAFmLXpD+aCU6rYpig7JxFISCS5pO3X3DKWjaH3C289i8mFEYPnzgFN1s i4lbDLIWP29X81+nWlsK72/zglyXrwdsl56y+YTNVa4DCYK34/Sgk1duRVZcZGU3zULc sEmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=WVoAi1bI; dkim=pass header.i=@opensource.wdc.com header.s=dkim header.b=XrDrR0VL; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=opensource.wdc.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id m8si14249299oiw.311.2021.10.22.06.48.49 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 22 Oct 2021 06:48:50 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=WVoAi1bI; dkim=pass header.i=@opensource.wdc.com header.s=dkim header.b=XrDrR0VL; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=opensource.wdc.com Received: from localhost ([::1]:41070 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mduuf-0008L3-BD for patch@linaro.org; Fri, 22 Oct 2021 09:48:49 -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+patch=linaro.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(-) -- 2.31.1 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: 516132 Delivered-To: patch@linaro.org Received: by 2002:ac0:bf50:0:0:0:0:0 with SMTP id o16csp1106356imj; Fri, 22 Oct 2021 06:51:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxovX17rZaZAi0a0+gtLru55gbmH/jRGM8WIgW8E4IQsRgpB8CIBoR25ls9DSRFPeG0AAtr X-Received: by 2002:a4a:a68b:: with SMTP id f11mr131824oom.16.1634910680184; Fri, 22 Oct 2021 06:51:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634910680; cv=none; d=google.com; s=arc-20160816; b=yRQrH98DZS4CE9jqzdSPpLXuUL8x6bjGC6+4Vqu4ZU60/yYWXZVQA8bx4umE0HsQQU TPeNg6UCwANsFvbrvFp6gCD+rOiIaUvozufWxHmPcSSED8R3RVIbWrN2fmSBFp+6b1uG e808FOcyA71Vr7BRrKeXNuyy7qyYKnZWvj1NxnT13UFdBKHK+BN97JKpeTH9fA8Qmbzo tyvmmF4VTFpdmqbRFtTTiSaechl61fxZbUcSMiUqWC/VHIZseivsHJ6j16FuZp4aZJdY VDBTL+zz1VZr+zfNWhz1JI0x3OylMBZSTzByfxpEn6EwRhCX9xZUO3arT3K6h56VFE4E OCaw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature:wdcironportexception:ironport-sdr:ironport-sdr :dkim-signature; bh=NuQhW3fvBny7Oh89pzYYxRRRsUQSzbLdF/nEmR22N5U=; b=b6weNiistBRW0e/BKiiMSn11l2nncZR9TlhreZWQqmCgUqqcKawS0t70P2HSB97iGx remxHP6CZz+A5OSYhrsW80KnIEUoYPjT51QW0/JDKS85jqwxcBgZEtuBaJascT3TQy6X /YJKcJLdHkQsGQrGmWWkSDZgPf/r9K+IKQuhAmDCpXMosaKN0vazgalL+D9XSSjCDoNd 8Z8XwhrfCD/0zDJzJFP6kbdlhoc6b23ZO/yFw0E6txmQ9fPsPOWRNQeqTQ0YVZySgaRg I1daDXFwj6R0Bikkwa61nDtYut/RFS7JSYemJZ8v9qUUsa5aIrNgU/mg732360DSboU/ 9RGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=eWohdzkB; dkim=pass header.i=@opensource.wdc.com header.s=dkim header.b=XGaH7CmH; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=opensource.wdc.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id bd22si13983336oib.271.2021.10.22.06.51.20 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 22 Oct 2021 06:51:20 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=eWohdzkB; dkim=pass header.i=@opensource.wdc.com header.s=dkim header.b=XGaH7CmH; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=opensource.wdc.com Received: from localhost ([::1]:49966 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mdux5-0005jf-CX for patch@linaro.org; Fri, 22 Oct 2021 09:51:19 -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+patch=linaro.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(-) -- 2.31.1 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: 516134 Delivered-To: patch@linaro.org Received: by 2002:ac0:bf50:0:0:0:0:0 with SMTP id o16csp1110046imj; Fri, 22 Oct 2021 06:55:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzclnr4dXSFfqxJjZsdSUVc8L+rA/4bxKntA/NX61THzLYtP90sbpuMTJxFKyyOx3hsylCR X-Received: by 2002:a05:6808:f8f:: with SMTP id o15mr6460842oiw.38.1634910915858; Fri, 22 Oct 2021 06:55:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634910915; cv=none; d=google.com; s=arc-20160816; b=ref1scQChkcWACJHLEYfqAN5BxQe3ZCUdLqmFhml5I0uihfmZpcUk8Zwm0CrY2wjM+ nEqbTi5n0BagRM6eA5rF96wfsLZxcXorACbJwmzaO6hsxqI8Vk7sVdWh6jr5yZnYj2mh AucW/W3F+B8oq8gBdHeiwtbl44KXNt4iigUTVqK5+Xpx2NCdI5NXxAEX83olK6aUJ1dk b9wDrLvfI/czb6EURmSWIZLYSOnvenYMEBtKLDnoMSn6dmgXBocwe9LI9NVrhWw0h9/n wc/HeMWOkQutmfyDtx8QkMjw22nyxIZ3+lUAzVN6Blj7RJx/NuAn4q1gzdCgfpU5gxcG FK3Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature:wdcironportexception:ironport-sdr:ironport-sdr :dkim-signature; bh=kaStvUcP/92ekrB44gxNuTfp2WMGXPBPHXm25tixDqA=; b=exv27f++m0a/FEYAxwZQIdVM7hopMwqFHUoX9Lhiu1Pm6hVtBDtexG3QLWogQUN1L8 fSMDypFubUoTnBIZa74vMWiGubkU7phZXvm/squxHbZDNh4RLarDaymNHv+/X4Sizpgx vZB5MzXzgO7hHoenV+dfZcGZF1QDzH4xxR1OEAWhbau2J+t5wGLzJPSVw6QdThLcQCqt IozplhR+b4Ukzy4usF1icEQLM/yQ+FNa8HCAQxB7AD71G3xY/N98xsWfDmgSuvjMBptr l4vdctBXTCeO7tLkK3ku2iOR3XAkrdUa6ZYmT0s8n6Se5PW2iP4CefqnBr1U8Ga66ZZQ Z5dg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=fr5iIOpS; dkim=pass header.i=@opensource.wdc.com header.s=dkim header.b=AESo0g2B; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=opensource.wdc.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id y17si8937304oie.265.2021.10.22.06.55.15 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 22 Oct 2021 06:55:15 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=fr5iIOpS; dkim=pass header.i=@opensource.wdc.com header.s=dkim header.b=AESo0g2B; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=opensource.wdc.com Received: from localhost ([::1]:57396 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mdv0t-0002Pg-63 for patch@linaro.org; Fri, 22 Oct 2021 09:55:15 -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+patch=linaro.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(-) -- 2.31.1 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: 516136 Delivered-To: patch@linaro.org Received: by 2002:ac0:bf50:0:0:0:0:0 with SMTP id o16csp1112592imj; Fri, 22 Oct 2021 06:58:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxpw1H10TeEbmFnnRfoEV4Y5Wz9JECFSK9aEL9GRfAQo6y66wIGjMHwZOc6ya396MWK/2Nl X-Received: by 2002:a9d:12b2:: with SMTP id g47mr5479otg.227.1634911083990; Fri, 22 Oct 2021 06:58:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634911083; cv=none; d=google.com; s=arc-20160816; b=FeHOTJTAITGYvAHGr9qjcwdH1wbBgzRlaj5MawqVpbp1QSJx9KehZrd4B67hj7lJw6 glEbjOATaoGkGMvJIj4IdMNP6ST78XvXgqo/2zJ+2Hqr83qBEvzWO2bQSkEhX91tSUiW a4IwkCeM4RiN7Fx9TXyNHe/E5rgB+FkETk1yfE/zuhB5JoocCB2BScga6Vk4wPSL4zx+ u0foAjyTpjAZe3BYmfNGGFpSPK1dzOCCTbTgPkGBnH9TFtVvsUn9p5tS5qmGLzTjDUYS Yt3binHk13PrayDLCv4+JY7jq9+kEzQuzbAvvXg9rETqceSnhK7zSVf5jqOQsfov639X 3Wkg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature:wdcironportexception:ironport-sdr:ironport-sdr :dkim-signature; bh=U0jUuE8nU5jzpZFFFHEOJShpRiKC2JbxI39lf/bsBxA=; b=E8KV+FQKgv2f47+SExG/ymJpwEM1DB+LDTqwVlMU1SFP1i9Epffqs7CrVALB+sqhGP IFvlwkOVuHts/kjLwDfqELnIJCF0ni8QKS+tZ8p2EM5inCCoQy/LGzKVAFVEMt3yQzR9 Tc6XUMQ20ILzDqevlglGo0Ahco2G/eJM8DqFN2pg1cJbe9w0hc6SbVR/c04V/qXCdFj1 1dbr/PQ3nzoULghRXsDvcgc1pT3vdoVfKKmelVmDayVa4iUaAeElyWTWuexc0/a+iGcD zV0jl1mIhuPoC27sxZy4ZvC9lLbyUn7rIhNcztCStUSc6/hGcYDU1GcMADlSxDQnGosq TDsA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=T2noL6VD; dkim=pass header.i=@opensource.wdc.com header.s=dkim header.b=WOpRbcJk; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=opensource.wdc.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 5si11339790oty.297.2021.10.22.06.58.03 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 22 Oct 2021 06:58:03 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=T2noL6VD; dkim=pass header.i=@opensource.wdc.com header.s=dkim header.b=WOpRbcJk; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=opensource.wdc.com Received: from localhost ([::1]:37562 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mdv3a-0008Ch-3Y for patch@linaro.org; Fri, 22 Oct 2021 09:58:02 -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+patch=linaro.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(-) -- 2.31.1 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: 516133 Delivered-To: patch@linaro.org Received: by 2002:ac0:bf50:0:0:0:0:0 with SMTP id o16csp1107544imj; Fri, 22 Oct 2021 06:52:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwzWxMO9qzw1vT66stgu1C6gl0zi/OVhsBcFev/Y7QHA/f6Dq4IM1w2Tqz69SeMAYYw4+u5 X-Received: by 2002:a9d:1ca2:: with SMTP id l34mr10091522ota.365.1634910758155; Fri, 22 Oct 2021 06:52:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634910758; cv=none; d=google.com; s=arc-20160816; b=oNAEj/+aQOgWsCTea974IH15MkIvTL/JtqiDTppseHS3F1PfbuP8vnMSg91E/L0JF6 LI5iWGI3jDy2NLIU72Yw82mnCXUUGW/zX7jsl+0e8do+37xL/4M+9DRFdG6oEvBU93K5 oWE3F8ufj/PyWbULJNz+E2rVpSyWm7SOF/nCMwXMvnXICtN5aUw/7/itglaMDWDS8wie wWhCXJKU87O6wqfAaP6A+DQ45NeMbp5dotkjIfDe8hNNnsfDKTxX6PxG9Noyr+8M2GDG cJxjZNln5QHxw5a4xOsJ2RVXgPHMcLHu4GIVm4EbFVmaIwLQMY+LxvTLHYCbh7DNTaQ/ LF1w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature:wdcironportexception:ironport-sdr:ironport-sdr :dkim-signature; bh=PYpPHI6a7RlVNjU5tLOAAafrup/ue8Y6IF0h7RX+VN0=; b=UtIqjeOxuNgmQ7Q6xhtH9q2/+miXZgBdYAuDqJ41U5Cg8XuWNLMlBnkt2RsfzmEEhP udDzDJOQZHWuY5Y7gy144pIqi3U5dHy0siprnEibDMT7ndnxBd2OteYvfjLdubCQZObL QZOxkgfAieNWL9yYikvssbw/GotiWh9a/nyMnwfQl/pCvWu2996IM8wK5A810H2vqNth S4ATD5NoAB/IaYaa/dGgz8+t2d4OGbW7AZkPm3WECXSJiTzNMX1xxrUXe7YHMMANMIGo vtGqGYWf83YhK7nRNRtK0fqLS/1d7fi28OtjJ0Yvc/Li/7LXRdfVVyOch6W46Iy2ZnpA 9Q0g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=e+XtIcm2; dkim=pass header.i=@opensource.wdc.com header.s=dkim header.b=GYF2ntz5; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=opensource.wdc.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id g22si9724048ooc.20.2021.10.22.06.52.38 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 22 Oct 2021 06:52:38 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=e+XtIcm2; dkim=pass header.i=@opensource.wdc.com header.s=dkim header.b=GYF2ntz5; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=opensource.wdc.com Received: from localhost ([::1]:52278 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mduyL-0007HN-CZ for patch@linaro.org; Fri, 22 Oct 2021 09:52:37 -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+patch=linaro.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(-) -- 2.31.1 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: 516135 Delivered-To: patch@linaro.org Received: by 2002:ac0:bf50:0:0:0:0:0 with SMTP id o16csp1110179imj; Fri, 22 Oct 2021 06:55:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy1HvNOZcAExqXCznxhNeoLieTuJvbuJdAlDNlYvQ0edWRPUbENfKsaMWQ+nN/oxQM0QWx5 X-Received: by 2002:a9d:5911:: with SMTP id t17mr53373oth.30.1634910925392; Fri, 22 Oct 2021 06:55:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634910925; cv=none; d=google.com; s=arc-20160816; b=P5bsnQQsieMJrPjQKUNrgzdlYovo0E+nZ+2uhQDc7AhPs2a3D5jC0ZzoIDnTUKJRm0 ikXY1/H1JGXmNUiZsTfeeYNZOOKOQBRu+CRGLDKfoXOMlfMR7AR05Ce9HjreiKhUwhdg UdqlwyT3961z2e6h5lj+1sDgw4UcplJwutjY3yZxaqWdVA9UaFYj8Opk4CKH2LSQ2iMx P/DTRhfP30xWF7tsEzbEcsljADJdYMRiyP+gctwvEYAzdZ0vQeqczENTSBlNdJpu8RFg vcFvpZf79f+clFno/1WZn3MfQEZ8dSTmOiewXG7n6xN2MaUmF+GSOKt0M4/38dlTmOq6 1U/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature:wdcironportexception:ironport-sdr:ironport-sdr :dkim-signature; bh=0UQlTjnmqRZ9o7iuUbZ/RqMe4FAyqREmV8iYMUViXuQ=; b=s2loUskaix3nokL1Yh2L2NYp70wKA5YahPzeyx3q49K/h1cEPfdgHlrN0yyhN459M2 paicvGYogGIw749/ndMJ/vmAIRDcXqDC1SlkIrh6B0at6iXTW+A+reLOo3SzmNs7468b 5NiitJE/lXgUMMU6VImDUjxrcWTkSYPeKL/sxuNn8IRFm1BInYPkqMPA5rutkoil6+GZ NXkzjlQP3bPglxS5dXxlg8uuDG7rjnxU40i3aWPrRhi6i+j5w/RJIh72oJsj4iTDmTuZ uNCGfciDj2T6LezECWyX8gpHRAlAFxsUXWwFeNUHQMG+U8A4ydmmi3vvJU/WGzYV1vze WDQw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=CQTS8kCu; dkim=pass header.i=@opensource.wdc.com header.s=dkim header.b="ePzcD/Jc"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=opensource.wdc.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id x28si9094006ott.81.2021.10.22.06.55.25 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 22 Oct 2021 06:55:25 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=CQTS8kCu; dkim=pass header.i=@opensource.wdc.com header.s=dkim header.b="ePzcD/Jc"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=opensource.wdc.com Received: from localhost ([::1]:58282 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mdv12-00031d-J4 for patch@linaro.org; Fri, 22 Oct 2021 09:55:24 -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+patch=linaro.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(-) -- 2.31.1 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: 516137 Delivered-To: patch@linaro.org Received: by 2002:ac0:bf50:0:0:0:0:0 with SMTP id o16csp1116148imj; Fri, 22 Oct 2021 07:01:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwIpMmSP+fyN7GrNkise1DEH/gDAz8QcLQooAIPprEPqOFYkKk7ssm2bCXnFN4P/ewgI+Zo X-Received: by 2002:a4a:3315:: with SMTP id q21mr175081ooq.12.1634911301652; Fri, 22 Oct 2021 07:01:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634911301; cv=none; d=google.com; s=arc-20160816; b=NXazUSOhEpHsqSh1Yi33ofLe6zkPRvmOJ0uoeSlRHckt4AU2GJfG/pvQTSZz6Kg1Ig /OUfUVe5crolGBRN7xw++quW1EOQVHJ8PTGUz5kq+ukgojA1Z4CDJIVtUHQOm4nJM5Ro lunHndBRz+BlegzA8ZEeqQdGet8WJxO3vQXhvblbakryQ7tC19itF9EPbfBodhQo7bYY 6zQqallf7kwnJX9cxL54baI9+PCAiiWxsZ6D3Yi82c52/KAk3UYp1vze03AZ8Vk2ab4k YF4+2L9w9tBbaR8GFp8jpRbdpWdBmUbjaHUAtaiatAa5oRv8FTO0Nvg0a1vL4q6hZQ6v MyBA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature:wdcironportexception:ironport-sdr:ironport-sdr :dkim-signature; bh=pRDoh7tc+GJUsi6XlCXCMSC95KZJiko+Ndby7lWiGKU=; b=G8usiCzwqHa8SiF1AeHhCclS/qknAG1qwCAg9XZIE+YkaH1QqS0pwJYF9/q6qYA2wY fc1RriXtmTXy4BlWveZ0Zl7ci2WPFm9wXcW6VEEreLBtYteRFzT6dc/WbKBz+Bij6EgB iPPB9bbtWZuPo8Xblg72yQ5L4MqibGLBVsbF2+rPNUE6KsJcHjRyvGvkuTVASYlW1H6M HaEIzNIDNeItLWRXtCt2mjqOIcm4kPr0V09xGH95S89lxf9/tJjHRR6v8wntoAyGscKm EUUSLZ0H/Cpes4019JjuploFo7XZKo9Ngcuo6Ci/IYxQD9tbcaMAsdqs/Tj4X5+Zs+Xy zptw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b="ovx/MyhX"; dkim=pass header.i=@opensource.wdc.com header.s=dkim header.b=PasnbfC1; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=opensource.wdc.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id b12si15305128ots.285.2021.10.22.07.01.41 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 22 Oct 2021 07:01:41 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b="ovx/MyhX"; dkim=pass header.i=@opensource.wdc.com header.s=dkim header.b=PasnbfC1; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=opensource.wdc.com Received: from localhost ([::1]:44958 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mdv76-0004oP-Gk for patch@linaro.org; Fri, 22 Oct 2021 10:01:40 -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+patch=linaro.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(-) -- 2.31.1 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); }