From patchwork Wed Oct 20 03:16:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 515984 Delivered-To: patch@linaro.org Received: by 2002:adf:a11e:0:0:0:0:0 with SMTP id o30csp1320749wro; Tue, 19 Oct 2021 20:23:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxCm23x75sGs7/zKrKGFOq+yGcyYYouj81EVHTvA+MVH5b6w8F58Cpop1nTMTScQZpgDr98 X-Received: by 2002:a05:6830:4428:: with SMTP id q40mr8579112otv.184.1634700232228; Tue, 19 Oct 2021 20:23:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634700232; cv=none; d=google.com; s=arc-20160816; b=P0JVWJD8XnaWVbmWUbJ5rfDCFq2FdTdDrlpqL4bgFXmw9tc1V7ZRlTYxPyjxwDMkuE I0MYuo2Pz7T1ZFQCOaOf6YTASjbT4+d3gwOew56v4gZMZlmIy7x+C138HeQtc3lfr/Or FooGZtlEwP2TFgov8WITXYeUoDxgbK8mncjTRnkAH3q5d3o1RvjWoYWe7jF14y992M6J ikl+JBm1hub58vGx+YIZ5/RpUaub2IkblavB4Ac52F2DPTIKG2VsKljYk0vbxb4dYuNF PWaOsDCxkTfkHTayvmUSRmvpV19kuzqD/F9wkH6zFki22+vJGhhTtoHhwcc4iPUXLWQ0 30Wg== 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=WEPMb5M/pfBDGmAGna82u4nvo55Uu196V9hMEA/1GyJKXLazhiIfCFAkDP5KaEBXQI +Jc6Q1eLGkOsxQJnjOkNgc4bpUvCRcCiGvSnth11PTl0CdUz9Aqe+HfRgEUnprechYE8 zRKhcheD0HyQ6CEbNhYrHuRT4CeUFJpd8B1pf5k94VxD9uJ4l6Y2+jC14evl0flR2TK+ ya91NZfXyl0/xKISBhRM+w9M4WPap4RYnaEy137p5LixmLe+QvJj1Lh4bDImDYR9DjHF X01U80ii1WWAtUjEyDglX02lhN6ILelT/nhEu+RCJU+GU+sBwC8h4Q9ACJckEkukmN94 cG4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=EQ45ZpCs; 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 j26si992304ota.83.2021.10.19.20.23.52 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 19 Oct 2021 20:23:52 -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=EQ45ZpCs; 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]:39184 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1md2Cl-0000De-E0 for patch@linaro.org; Tue, 19 Oct 2021 23:23:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46924) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1md26O-0006e5-LK for qemu-devel@nongnu.org; Tue, 19 Oct 2021 23:17:16 -0400 Received: from mail-pg1-x52f.google.com ([2607:f8b0:4864:20::52f]:44712) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1md26L-0000xC-5L for qemu-devel@nongnu.org; Tue, 19 Oct 2021 23:17:15 -0400 Received: by mail-pg1-x52f.google.com with SMTP id c4so14192138pgv.11 for ; Tue, 19 Oct 2021 20:17:12 -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=EQ45ZpCss11u9/H9zCTM1UlxDR2TGB5KJirQvX8fhq663PGxaAASGAUs9PTiCUFdxL 68enrZz6TMy7yIAxgbPZ0BRWwkSL3OWobI8pHl2oy4AJOd59JvAiKs06I512REplpcdj zhxp75iVha4rpBND+caFTsPd+0eKSH0fdRbep0eXfsl1ibw1VK0M6On+9HJqeZldyn5o fAzEqvNs28zq6Y3dbzt1dMnQDJfyReN43myv3cKqsqyzazbJxwQ+LrRnUcuVILzmmNgp N5G6OZQAfrVY5Uci1youjFF/j2hxpSLU/zIOBtPdTDlpM0xfLwl6L5NalGsD5ohDMj2b BL0A== 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=jVrBGEsUWGDeBn7oIY8nrIePZ/Hbox7wZgk+w6cauv4zv6sExdjxpewvvkHYB7NEvG btiwGzgD1KDmEwoy+t7FsBf+xqkfb9tIYwAOktDvYBjkqK9ilCHIED6xk0pUUSaowVHw CCHNBhaquW5CaxIlYI74fdwQk8W19nem7IOp3mdrW51/xs0IFzzLjCXPKoFrmNipX7/k pix/93Z/ZeNxSXKByZwWDhIoGUiw8FQf2KAtIe+GmTSOTNaDF8GEuTxkcL7DA6KxGIKC NDoV4g12NnNTbGOAXeWoOF6W4t3cjEYVk0wYrux8nlJFjKHnRFicVRsPgyntuwAJTwpA TwbA== X-Gm-Message-State: AOAM532LZSE9uE/8jTPNRUs3GOYhzWOPSb8GocxVilPrSS9ItXhz4vAb ixip/ZOqNN0kqvcHmBsyB/0qivQQiA9VxQ== X-Received: by 2002:a62:77d8:0:b0:44c:8618:1bed with SMTP id s207-20020a6277d8000000b0044c86181bedmr3734409pfc.27.1634699831758; Tue, 19 Oct 2021 20:17:11 -0700 (PDT) Received: from localhost.localdomain ([71.212.134.125]) by smtp.gmail.com with ESMTPSA id c8sm505364pjr.38.2021.10.19.20.17.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Oct 2021 20:17:11 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v6 01/15] target/riscv: Move cpu_get_tb_cpu_state out of line Date: Tue, 19 Oct 2021 20:16:55 -0700 Message-Id: <20211020031709.359469-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211020031709.359469-1-richard.henderson@linaro.org> References: <20211020031709.359469-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::52f; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x52f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.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) {