From patchwork Tue Oct 19 15:24:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 515969 Delivered-To: patch@linaro.org Received: by 2002:ac0:cd8c:0:0:0:0:0 with SMTP id d12csp833782imp; Tue, 19 Oct 2021 09:34:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxo0ZNdi18j5h2eIXXBfKOqhLb0CrR6JXCIr1FpXB3z1aVPZ1e56sPwe1jmsuZUDYnJRk3D X-Received: by 2002:a9d:6c91:: with SMTP id c17mr6098794otr.114.1634661258781; Tue, 19 Oct 2021 09:34:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634661258; cv=none; d=google.com; s=arc-20160816; b=Uhoxh3nERSaJovErX34o0Slkob8hHokslRaSWn3m2lCEjzr9xrkaqZk8do8L0gOghX iN6WqoHNJAParRkzyTRS+539RtpmppRxX0WlUUWT8dsf9dFp46bNcu6BwdxE+2oGirZ8 0rnrnTkCuUVfUCxO4/5GLo4JrZJtOKbshdiKO/aliCWWns33sEgkkXXdQSNOi0N7AtwQ 3Cp/SkCFW0F7l2INTbgm6YS3nmdzHdJl+mdMnpkwUegPhAvL8qB9/YBKupu0weXuEkrK fSW5weoTgv+mfxoTNkPmk1nALdkjlWYsTqQhGVewo21rab/Uvv7+EYQPgmI3kjsf3G42 O5XA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc: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:to:from :dkim-signature; bh=Ur4NYkKvb4IwfCVRQ66xGSUcq2q0ktl5nOkYZP/fju8=; b=0IGMw3xZM8rYpVpSebbOsyEKX+E5gwbpIl9jUd3Qbm0M4XZ0BPVS995smHNg2ewZvW +bvFgnUB9LmoD6CYqBHtGtUyXB+3f1SmwUtxd+18bCqV3A1lMU9W3KGm/6w/L2//kfgt 8Fq97vsXTQedYQo1nIA5w2nWOytbh97JrQjXOjqny8avVDtyTa28Tk3fulZMuPI2VXtI ptARC7aa+rjN211+9yu6pZpVjAKxjUF36Py9jpYY9y6pgagCJIbPLiG0XTcNoy5TxP2c +ZO5+5XDmpEu1gDWBrWdBkLU8tqDFeeRZnbog5trXCHRM2Te+i6p4HHTL25HszGY9M0L CxeA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=mDeCoX00; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id w65si19888041oib.291.2021.10.19.09.34.18 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 19 Oct 2021 09:34:18 -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=@linaro.org header.s=google header.b=mDeCoX00; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:52600 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mcs4A-0003aW-3d for patch@linaro.org; Tue, 19 Oct 2021 12:34:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54120) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mcqyr-0004lJ-Cw for qemu-devel@nongnu.org; Tue, 19 Oct 2021 11:24:45 -0400 Received: from mail-pl1-x633.google.com ([2607:f8b0:4864:20::633]:34660) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mcqyo-0007Se-4E for qemu-devel@nongnu.org; Tue, 19 Oct 2021 11:24:44 -0400 Received: by mail-pl1-x633.google.com with SMTP id g5so13920638plg.1 for ; Tue, 19 Oct 2021 08:24:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Ur4NYkKvb4IwfCVRQ66xGSUcq2q0ktl5nOkYZP/fju8=; b=mDeCoX00cF4NTV/f1IQTb6N1EdKjmgcRY/IdoRiiz8WNve5tk8AGlIlwyfr2FkTAjK 9iUIOPHWCvE3xzoF18ibWnK7+UyXxijekwMR+YG34il+rBRrmuk0LOOyoTh0Nq7BKGMP 8EVTrObFM+a/5mwcVZF3GJEiPlsWyQ3uT/DVS7O3eliTgMsik0rf2ibnedl+ojd35bZx ZWAdI0HNyNkz6MGPLtUklh99n6NSpSEOVTgVDTeYtjcFFlUAdxOK1Pp4roip/jTGdrsX mBptRk99fq5/jeJkGpTRq2bCGM0O6lFzaFuPBgsmyQaewqwvez8Za5GzcQlbNi5Bm4+D EKtw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Ur4NYkKvb4IwfCVRQ66xGSUcq2q0ktl5nOkYZP/fju8=; b=Cy3k+7wcTsNNtRW4BH7Rf9zvWk2VxpC/cCmyXzBmPJxZBDDqX50DsGrs0u5zKykMGL 3r/MVkLn3uHlIvT7GUOS6c2x6U2Srzigu334Tvqw3O0/yoSIgIn1j5kVBhFBWqLp1pzD zij+IrfQ7nYuUatQyPJTDf1xlmJ/K8Kts7n9FSUAXk4aXipG9GzyO9aG38OEbdS94FNQ TI1h2fUxHqqULI4b/MfkR+MKmKmFx6/vWueovtaWahcz8NjT15+eEEPEEgOCFzP2dQmn eNMXQrXaG6+EXHxa+DbR33FcuOTp6E0QmM3Vt6SmT3ZXQt7NrUrC0sBvQY4OX1LwV/q2 gQHg== X-Gm-Message-State: AOAM530y+qQ9t5UyTikiJFPp5b/9eIfonXOHwP5+wTcuiHCiHwh1QGws +UlFi62zuOGt5TU+8Ih28fz22AFM3FPrcQ== X-Received: by 2002:a17:902:f281:b0:13f:3be8:b160 with SMTP id k1-20020a170902f28100b0013f3be8b160mr34074439plc.32.1634657080340; Tue, 19 Oct 2021 08:24:40 -0700 (PDT) Received: from localhost.localdomain ([71.212.134.125]) by smtp.gmail.com with ESMTPSA id i2sm3293814pjt.19.2021.10.19.08.24.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Oct 2021 08:24:40 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v5 01/16] target/riscv: Move cpu_get_tb_cpu_state out of line Date: Tue, 19 Oct 2021 08:24:23 -0700 Message-Id: <20211019152438.269077-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211019152438.269077-1-richard.henderson@linaro.org> References: <20211019152438.269077-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::633; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x633.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alistair.francis@wdc.com, qemu-riscv@nongnu.org, zhiwei_liu@c-sky.com Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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 --- target/riscv/cpu.h | 47 ++------------------------------------- target/riscv/cpu_helper.c | 46 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+), 45 deletions(-) -- 2.25.1 diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h index 9e55b2f5b1..7084efc452 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) {