From patchwork Mon Feb 8 23:39:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 12076903 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EF7A9C433E6 for ; Tue, 9 Feb 2021 00:27:03 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 77A7964E28 for ; Tue, 9 Feb 2021 00:27:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 77A7964E28 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:35876 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l9Gru-0007CY-Ck for qemu-devel@archiver.kernel.org; Mon, 08 Feb 2021 19:27:02 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:44094) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l9G7c-0004zX-Kk for qemu-devel@nongnu.org; Mon, 08 Feb 2021 18:39:12 -0500 Received: from mail-pg1-x530.google.com ([2607:f8b0:4864:20::530]:35155) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1l9G7a-0000zN-SI for qemu-devel@nongnu.org; Mon, 08 Feb 2021 18:39:12 -0500 Received: by mail-pg1-x530.google.com with SMTP id t25so11297101pga.2 for ; Mon, 08 Feb 2021 15:39:10 -0800 (PST) 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=/4OvZ/z8zgs+Zk4nXR9BgeBunVL67Ul7jA+wIZOB714=; b=VG7PcQvJ4VX8D6VAVxKrn7wbhNBalrA3j8geyB01s1RBhwZWbE78HjedcQr9gD11JP fbid8Zx/iWO7nagnQtdPrKKxePAWqzuMDbGvxeEBZz+MwoNsuTAgnwP1Db+mm6rzAFL+ WPy1K/yCByV8OM25Jvi7dCEnOEErPhHa2AsEybBMG7eJKWf0F76aJyMJM6Y6PGmNNmrp LEViBLo+RJnA9xxkFccbnMdWhq/uPDGqJ4+prhFQUBH/DXzhDdtikrcpToVZNdkFdPeC WzUU4++CihRqzNkFXOm++JuBYOcBr3uUIQd6IRLtbb+SmX56pGAD94oNOb9Ac9lt7/gU QfrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=/4OvZ/z8zgs+Zk4nXR9BgeBunVL67Ul7jA+wIZOB714=; b=VxMODxdrrfhNPfhlB44eE9VuYbN4DwTFSqfPwuzLuZ2SlIICM9quOk6t4mdKNiu4xA 7zdDpDd667wShK6ixgWGkhxg5HhV1GNhJwzmO4LxjcJ9satNUNQF2li1I3dtAqfwdiZx n8REfkULaIg6aWkx/4dEd9iX9p2RzExwvsTpWB7GGOSTHINTgUBuq31PY6Jq3i+ujg82 1wqv+k0g43a5RdoPGWN5W7Ari6oguH3PW514TlTo7L1RtaIGlOoUpVMJfwFi8oavlv0n ZUvs+QbP0xIktcLPXO0MzutZYO+s0PdzPvUEa6cZIOOjOnnvrBOrfOe6Oq7O6glhvHU7 89rA== X-Gm-Message-State: AOAM533JdS/ztGw5ozxOKiS/GpyLEz6LTf154XTDtDg9wkxjVAbnbmFg R4723+ytrYtOiFK79j4wlFwZBeLGWUEUjA== X-Google-Smtp-Source: ABdhPJyTeWjbjqFteNmcmhWHc2ESCh4se9vJtkJWwHJo/zmwPuhCWS+/i7WfZhcztjVLdfCsief0JA== X-Received: by 2002:a63:574c:: with SMTP id h12mr19467486pgm.79.1612827549574; Mon, 08 Feb 2021 15:39:09 -0800 (PST) Received: from localhost.localdomain (174-21-150-71.tukw.qwest.net. [174.21.150.71]) by smtp.gmail.com with ESMTPSA id k15sm13483489pgt.35.2021.02.08.15.39.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Feb 2021 15:39:08 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 1/4] exec: Move TranslationBlock typedef to qemu/typedefs.h Date: Mon, 8 Feb 2021 15:39:03 -0800 Message-Id: <20210208233906.479571-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210208233906.479571-1-richard.henderson@linaro.org> References: <20210208233906.479571-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::530; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x530.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: alex.bennee@linaro.org, cfontana@suse.de Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" This also means we don't need an extra declaration of the structure in hw/core/cpu.h. Signed-off-by: Richard Henderson --- include/exec/tb-context.h | 1 - include/hw/core/cpu.h | 4 +--- include/hw/core/tcg-cpu-ops.h | 3 +-- include/qemu/typedefs.h | 1 + target/arm/internals.h | 3 +-- target/cris/translate.c | 2 +- target/lm32/translate.c | 2 +- target/moxie/translate.c | 2 +- target/unicore32/translate.c | 2 +- 9 files changed, 8 insertions(+), 12 deletions(-) diff --git a/include/exec/tb-context.h b/include/exec/tb-context.h index ec4c13b455..cc33979113 100644 --- a/include/exec/tb-context.h +++ b/include/exec/tb-context.h @@ -26,7 +26,6 @@ #define CODE_GEN_HTABLE_BITS 15 #define CODE_GEN_HTABLE_SIZE (1 << CODE_GEN_HTABLE_BITS) -typedef struct TranslationBlock TranslationBlock; typedef struct TBContext TBContext; struct TBContext { diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h index 38d813c389..c005d3dc2d 100644 --- a/include/hw/core/cpu.h +++ b/include/hw/core/cpu.h @@ -74,8 +74,6 @@ typedef enum MMUAccessType { typedef struct CPUWatchpoint CPUWatchpoint; -struct TranslationBlock; - /* see tcg-cpu-ops.h */ struct TCGCPUOps; @@ -375,7 +373,7 @@ struct CPUState { IcountDecr *icount_decr_ptr; /* Accessed in parallel; all accesses must be atomic */ - struct TranslationBlock *tb_jmp_cache[TB_JMP_CACHE_SIZE]; + TranslationBlock *tb_jmp_cache[TB_JMP_CACHE_SIZE]; struct GDBRegisterState *gdb_regs; int gdb_num_regs; diff --git a/include/hw/core/tcg-cpu-ops.h b/include/hw/core/tcg-cpu-ops.h index ccc97d1894..ac3bb051f2 100644 --- a/include/hw/core/tcg-cpu-ops.h +++ b/include/hw/core/tcg-cpu-ops.h @@ -30,8 +30,7 @@ struct TCGCPUOps { * If more state needs to be restored, the target must implement a * function to restore all the state, and register it here. */ - void (*synchronize_from_tb)(CPUState *cpu, - const struct TranslationBlock *tb); + void (*synchronize_from_tb)(CPUState *cpu, const TranslationBlock *tb); /** @cpu_exec_enter: Callback for cpu_exec preparation */ void (*cpu_exec_enter)(CPUState *cpu); /** @cpu_exec_exit: Callback for cpu_exec cleanup */ diff --git a/include/qemu/typedefs.h b/include/qemu/typedefs.h index dc39b05c30..ee60eb3de4 100644 --- a/include/qemu/typedefs.h +++ b/include/qemu/typedefs.h @@ -120,6 +120,7 @@ typedef struct ReservedRegion ReservedRegion; typedef struct SavedIOTLB SavedIOTLB; typedef struct SHPCDevice SHPCDevice; typedef struct SSIBus SSIBus; +typedef struct TranslationBlock TranslationBlock; typedef struct VirtIODevice VirtIODevice; typedef struct Visitor Visitor; typedef struct VMChangeStateEntry VMChangeStateEntry; diff --git a/target/arm/internals.h b/target/arm/internals.h index 448982dd2f..7d26ce0c9d 100644 --- a/target/arm/internals.h +++ b/target/arm/internals.h @@ -172,8 +172,7 @@ void arm_cpu_register_gdb_regs_for_features(ARMCPU *cpu); void arm_translate_init(void); #ifdef CONFIG_TCG -void arm_cpu_synchronize_from_tb(CPUState *cs, - const struct TranslationBlock *tb); +void arm_cpu_synchronize_from_tb(CPUState *cs, const TranslationBlock *tb); #endif /* CONFIG_TCG */ diff --git a/target/cris/translate.c b/target/cris/translate.c index c893f877ab..65c168c0c7 100644 --- a/target/cris/translate.c +++ b/target/cris/translate.c @@ -132,7 +132,7 @@ typedef struct DisasContext { int delayed_branch; - struct TranslationBlock *tb; + TranslationBlock *tb; int singlestep_enabled; } DisasContext; diff --git a/target/lm32/translate.c b/target/lm32/translate.c index 030b232d66..20c70d03f1 100644 --- a/target/lm32/translate.c +++ b/target/lm32/translate.c @@ -93,7 +93,7 @@ typedef struct DisasContext { unsigned int tb_flags, synced_flags; /* tb dependent flags. */ int is_jmp; - struct TranslationBlock *tb; + TranslationBlock *tb; int singlestep_enabled; uint32_t features; diff --git a/target/moxie/translate.c b/target/moxie/translate.c index d5fb27dfb8..24a742b25e 100644 --- a/target/moxie/translate.c +++ b/target/moxie/translate.c @@ -36,7 +36,7 @@ /* This is the state at translation time. */ typedef struct DisasContext { - struct TranslationBlock *tb; + TranslationBlock *tb; target_ulong pc, saved_pc; uint32_t opcode; uint32_t fp_status; diff --git a/target/unicore32/translate.c b/target/unicore32/translate.c index 962f9877a0..370709c9ea 100644 --- a/target/unicore32/translate.c +++ b/target/unicore32/translate.c @@ -34,7 +34,7 @@ typedef struct DisasContext { int condjmp; /* The label that will be jumped to when the instruction is skipped. */ TCGLabel *condlabel; - struct TranslationBlock *tb; + TranslationBlock *tb; int singlestep_enabled; #ifndef CONFIG_USER_ONLY int user; From patchwork Mon Feb 8 23:39:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 12076907 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A841FC433DB for ; Tue, 9 Feb 2021 00:29:26 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0956164E59 for ; Tue, 9 Feb 2021 00:29:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0956164E59 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:42670 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l9GuC-0001Xt-T8 for qemu-devel@archiver.kernel.org; Mon, 08 Feb 2021 19:29:24 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:44172) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l9G7i-00055q-UD for qemu-devel@nongnu.org; Mon, 08 Feb 2021 18:39:18 -0500 Received: from mail-pf1-x435.google.com ([2607:f8b0:4864:20::435]:43242) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1l9G7c-00010E-Dn for qemu-devel@nongnu.org; Mon, 08 Feb 2021 18:39:18 -0500 Received: by mail-pf1-x435.google.com with SMTP id q131so10719681pfq.10 for ; Mon, 08 Feb 2021 15:39:11 -0800 (PST) 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=DqDS++ASKRz2BpCakcktMBnc/QXED2AN0Q9nieRwrbQ=; b=u3xF5UPOm10jLoMEaWGYABTmMgunkc7m3/+K++5qMoq96rTXD6k1fb4nX99eBixENC ZReNA5ERd4OEcuODIBuTYK8iE6KHG0sT6rtz2TPc63RPB0xmhsjNFHDFiUlZZAQFyYTT lC/9zIon4XDQtmJgq+3gh1ZsQf1U4ZpWlLnS4piKmZB02OviIIp5QPe3mduAN8Oa0qJg 1xRkkcu2Gdil1PQmPw0LAiVMTSWW2nRC8cDjZSS9QaY1Lg/TdPC5CDumEMcdatOJy3QT Olg2PHq86RZ9EktDaIsn9aBpDWdP5/s2GIsxpoJbBUsofYtexvaX9KOjXJDFvkJ07yhU ZSpg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=DqDS++ASKRz2BpCakcktMBnc/QXED2AN0Q9nieRwrbQ=; b=uXMl20JgH8ZmZkzA2bud4n9woWDlymi+wCz+OJspbEtJ6eudpI8NxVahVqIv111re3 sFdZCiED10J7u/hlQHYOluHjwRBWcqgGBhuQHN+2xzKG1Fx4BABRdMTS+1Jmu3U0b/6B WU8sI06kB0ATwzx8gLVnlq949/B6jQ73TJBF15ZQ6B4RL7EHsliUzOHTvvS/e6eN3VXJ liae9oBVYY7JoKj4OS+Ipqqw/mwmVUffPrPdI8VUgAAS3IRWUrBjmv6ROY7M3yHTxMh8 FSo6jOwPwYIe1FuXaD9e8u7prRFOlyyRSsosXDL0IUAZsN/L2UW+iRUXd92LQS0Mx/Gf 9x4w== X-Gm-Message-State: AOAM531tglxbwmDgJV8YkFuRStyFR1rydSesgLYpGJ0sIlC02aNpprV3 QUG3n8F0/fuw/PCCVObOEjeHy3UeA1VBKQ== X-Google-Smtp-Source: ABdhPJyU6FeshSrgguVtTQHQMFQqwPXwmu6qDIyVzIq7P6/sV9AvtqDP2Hkcr9vzARm4NFjWoBJ5Fw== X-Received: by 2002:a63:1a1d:: with SMTP id a29mr5955497pga.236.1612827551111; Mon, 08 Feb 2021 15:39:11 -0800 (PST) Received: from localhost.localdomain (174-21-150-71.tukw.qwest.net. [174.21.150.71]) by smtp.gmail.com with ESMTPSA id k15sm13483489pgt.35.2021.02.08.15.39.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Feb 2021 15:39:10 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 2/4] accel/tcg: Create io_recompile_replay_branch hook Date: Mon, 8 Feb 2021 15:39:04 -0800 Message-Id: <20210208233906.479571-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210208233906.479571-1-richard.henderson@linaro.org> References: <20210208233906.479571-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::435; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x435.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: alex.bennee@linaro.org, cfontana@suse.de Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Create a hook in which to split out the mips and sh4 ifdefs from cpu_io_recompile. Signed-off-by: Richard Henderson --- include/hw/core/tcg-cpu-ops.h | 10 ++++++++++ accel/tcg/translate-all.c | 17 +++++++++++++---- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/include/hw/core/tcg-cpu-ops.h b/include/hw/core/tcg-cpu-ops.h index ac3bb051f2..ddf334411f 100644 --- a/include/hw/core/tcg-cpu-ops.h +++ b/include/hw/core/tcg-cpu-ops.h @@ -88,6 +88,16 @@ struct TCGCPUOps { */ bool (*debug_check_watchpoint)(CPUState *cpu, CPUWatchpoint *wp); + /** + * @io_recompile_replay_branch: Callback for cpu_io_recompile. + * + * The cpu has been stoped, and cpu_restore_state_from_tb has been + * called. If the faulting instruction is in a delay slot, and the + * target architecture requires re-execution of the branch, then + * adjust the cpu state as required and return true. + */ + bool (*io_recompile_replay_branch)(CPUState *cpu, + const TranslationBlock *tb); #endif /* CONFIG_SOFTMMU */ #endif /* NEED_CPU_H */ diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index 81d4c83f22..6eb37883bd 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -60,6 +60,7 @@ #include "sysemu/cpu-timers.h" #include "sysemu/tcg.h" #include "qapi/error.h" +#include "hw/core/tcg-cpu-ops.h" #include "internal.h" /* #define DEBUG_TB_INVALIDATE */ @@ -2420,6 +2421,7 @@ void cpu_io_recompile(CPUState *cpu, uintptr_t retaddr) CPUArchState *env = cpu->env_ptr; #endif TranslationBlock *tb; + CPUClass *cc; uint32_t n; tb = tcg_tb_lookup(retaddr); @@ -2429,11 +2431,18 @@ void cpu_io_recompile(CPUState *cpu, uintptr_t retaddr) } cpu_restore_state_from_tb(cpu, tb, retaddr, true); - /* On MIPS and SH, delay slot instructions can only be restarted if - they were already the first instruction in the TB. If this is not - the first instruction in a TB then re-execute the preceding - branch. */ + /* + * Some guests must re-execute the branch when re-executing a delay + * slot instruction. When this is the case, adjust icount and N + * to account for the re-execution of the branch. + */ n = 1; + cc = CPU_GET_CLASS(cpu); + if (cc->tcg_ops->io_recompile_replay_branch && + cc->tcg_ops->io_recompile_replay_branch(cpu, tb)) { + cpu_neg(cpu)->icount_decr.u16.low++; + n = 2; + } #if defined(TARGET_MIPS) if ((env->hflags & MIPS_HFLAG_BMASK) != 0 && env->active_tc.PC != tb->pc) { From patchwork Mon Feb 8 23:39:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 12076901 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A6612C433E0 for ; Tue, 9 Feb 2021 00:26:17 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3B20464DF0 for ; Tue, 9 Feb 2021 00:26:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3B20464DF0 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:33578 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l9GrA-00068v-8q for qemu-devel@archiver.kernel.org; Mon, 08 Feb 2021 19:26:16 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:44206) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l9G7s-000591-Mc for qemu-devel@nongnu.org; Mon, 08 Feb 2021 18:39:28 -0500 Received: from mail-pl1-x62c.google.com ([2607:f8b0:4864:20::62c]:33120) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1l9G7f-00010w-9B for qemu-devel@nongnu.org; Mon, 08 Feb 2021 18:39:26 -0500 Received: by mail-pl1-x62c.google.com with SMTP id d13so8717587plg.0 for ; Mon, 08 Feb 2021 15:39:13 -0800 (PST) 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=bvXiadaSGeRqxaWd2p/qsJeoAY+3ssYrogfEW/VR4Cw=; b=xshexf772AvOiOP2ZXOXWBH6IHeu2VIQlPPGeZgtZ9IUEi/jFIqYRrGmko81vgrJaz Mq2KqYn1OsqlefrYt0S8OTn36g0OB3VLRn7orjSPTl40sjo2tWKlt56pTTGy+FAYDiKi 0CGSl1zH3UxyNaWEbzhxgzF3VDMIwapK2bMRURQpjgzCi9/0Za37XpAZn+28Lv0bpXqH NFONim0xRSI0ucTobvxQUR/gvTxgDPNg6lQ0i5OtFQFonmqG/c3toVpNQ43NENg++Sla gEey5kOxPQ5G98kPJQyOqGva1CeM78kIALTI51EkgcxP+CdFWDPZexLWuTTuQatXqs+4 XanQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=bvXiadaSGeRqxaWd2p/qsJeoAY+3ssYrogfEW/VR4Cw=; b=F+aD/YgcQ8Ap/YbVsWH83qFzcJDZpADtkCX2ov+A5LTVreuaCEgyKSiZXWUAU8RqEJ pOeHl4GhQ0h7Vl1br1URTCxzf5v0IgwI55tDIzNeQjmkHxfCfZ8zCEH7J60LmfEBLbyt IG0AnNb3KEZW5e2SOEa1DUXstV/nw3uewtMIdZxSkvJiF64yxpZn8Rw5wHk3dP92c/k2 EKul/eKANVXnug1p0ns+vdEf+BsYCwbkOvltOmPto1zWoeW1Q4/NlXvNc6RCs8jh5R9n plOCPw9+2vdWuijpFuonoMviRf92xeLZ+T7AYzTtsFSBrJv9f+ik0XrsaHEfZX33gBFt XHbA== X-Gm-Message-State: AOAM531wsonzf7iIkDCfjJsm7qT2O3RwulochVA7Jmj0qOiPz318+fOs OP/JIaqLSWDxVljB2aQsZdGhNUloTPp+AQ== X-Google-Smtp-Source: ABdhPJzJK1+g0OIDMiiqO0JD9pjTm1/v42SNI8NeayJmSQ89H/DCFJsxn99C6c5+OxkFa/bKhV2KQw== X-Received: by 2002:a17:902:6ac2:b029:de:3560:391e with SMTP id i2-20020a1709026ac2b02900de3560391emr18011505plt.60.1612827552268; Mon, 08 Feb 2021 15:39:12 -0800 (PST) Received: from localhost.localdomain (174-21-150-71.tukw.qwest.net. [174.21.150.71]) by smtp.gmail.com with ESMTPSA id k15sm13483489pgt.35.2021.02.08.15.39.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Feb 2021 15:39:11 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 3/4] target/mips: Create mips_io_recompile_replay_branch Date: Mon, 8 Feb 2021 15:39:05 -0800 Message-Id: <20210208233906.479571-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210208233906.479571-1-richard.henderson@linaro.org> References: <20210208233906.479571-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62c; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62c.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: alex.bennee@linaro.org, cfontana@suse.de, Aurelien Jarno , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Move the code from accel/tcg/translate-all.c to target/mips/cpu.c. Signed-off-by: Richard Henderson --- Cc: Philippe Mathieu-Daudé Cc: Aurelien Jarno Cc: Jiaxun Yang --- accel/tcg/translate-all.c | 12 ++---------- target/mips/cpu.c | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index 6eb37883bd..470657b02a 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -2417,7 +2417,7 @@ void tb_check_watchpoint(CPUState *cpu, uintptr_t retaddr) */ void cpu_io_recompile(CPUState *cpu, uintptr_t retaddr) { -#if defined(TARGET_MIPS) || defined(TARGET_SH4) +#if defined(TARGET_SH4) CPUArchState *env = cpu->env_ptr; #endif TranslationBlock *tb; @@ -2443,15 +2443,7 @@ void cpu_io_recompile(CPUState *cpu, uintptr_t retaddr) cpu_neg(cpu)->icount_decr.u16.low++; n = 2; } -#if defined(TARGET_MIPS) - if ((env->hflags & MIPS_HFLAG_BMASK) != 0 - && env->active_tc.PC != tb->pc) { - env->active_tc.PC -= (env->hflags & MIPS_HFLAG_B16 ? 2 : 4); - cpu_neg(cpu)->icount_decr.u16.low++; - env->hflags &= ~MIPS_HFLAG_BMASK; - n = 2; - } -#elif defined(TARGET_SH4) +#if defined(TARGET_SH4) if ((env->flags & ((DELAY_SLOT | DELAY_SLOT_CONDITIONAL))) != 0 && env->pc != tb->pc) { env->pc -= 2; diff --git a/target/mips/cpu.c b/target/mips/cpu.c index ad163ead62..bf70c77295 100644 --- a/target/mips/cpu.c +++ b/target/mips/cpu.c @@ -268,6 +268,23 @@ static void mips_cpu_synchronize_from_tb(CPUState *cs, env->hflags &= ~MIPS_HFLAG_BMASK; env->hflags |= tb->flags & MIPS_HFLAG_BMASK; } + +# ifndef CONFIG_USER_ONLY +static bool mips_io_recompile_replay_branch(CPUState *cs, + const TranslationBlock *tb) +{ + MIPSCPU *cpu = MIPS_CPU(cs); + CPUMIPSState *env = &cpu->env; + + if ((env->hflags & MIPS_HFLAG_BMASK) != 0 + && env->active_tc.PC != tb->pc) { + env->active_tc.PC -= (env->hflags & MIPS_HFLAG_B16 ? 2 : 4); + env->hflags &= ~MIPS_HFLAG_BMASK; + return true; + } + return false; +} +# endif /* !CONFIG_USER_ONLY */ #endif /* CONFIG_TCG */ static bool mips_cpu_has_work(CPUState *cs) @@ -679,6 +696,7 @@ static struct TCGCPUOps mips_tcg_ops = { .do_interrupt = mips_cpu_do_interrupt, .do_transaction_failed = mips_cpu_do_transaction_failed, .do_unaligned_access = mips_cpu_do_unaligned_access, + .io_recompile_replay_branch = mips_io_recompile_replay_branch, #endif /* !CONFIG_USER_ONLY */ }; #endif /* CONFIG_TCG */ From patchwork Mon Feb 8 23:39:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 12076797 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2F1B7C433E0 for ; Mon, 8 Feb 2021 23:41:19 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C767E64D9D for ; Mon, 8 Feb 2021 23:41:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C767E64D9D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:56602 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l9G9d-0006ja-QI for qemu-devel@archiver.kernel.org; Mon, 08 Feb 2021 18:41:17 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:44188) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l9G7m-00056Z-P7 for qemu-devel@nongnu.org; Mon, 08 Feb 2021 18:39:22 -0500 Received: from mail-pg1-x52c.google.com ([2607:f8b0:4864:20::52c]:45100) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1l9G7f-00011I-9x for qemu-devel@nongnu.org; Mon, 08 Feb 2021 18:39:21 -0500 Received: by mail-pg1-x52c.google.com with SMTP id o21so9877012pgn.12 for ; Mon, 08 Feb 2021 15:39:14 -0800 (PST) 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=eL4WqFDBuNtlcGfpllQU5OAqdTK3sQa+xgiSdwASR9g=; b=mKokqLWpckqZtMQ+8XiqgwyOgeBd5uyfFW1HD/NErNsLvZdkMYY2JD+qI/QGq7o7tv 7/vzBNIi9+Za6ZlU+HwnmclCbzhGPW8bfMYmc3MghQYAucvsjJ1pwato145aPTT21wyv iUat8hv48V2lWt7nwZRlLoqanRh1gPFwAzkaos/W4Y4FUqMxENx1XEHGefpeh1FzZOOk h/VwaTH0ncDW/O3nvUh2zcbYT76+LNWrzP7I9tUlF6VEmgJMXdUTNM6F09fxJUYBOsm1 MKWk7K2uKReGtvG/ETlxQ01pHf7lVC3LTZyNslQaaFKXMmwwt4Q0jk/hk+wE/70zdiR0 1nQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=eL4WqFDBuNtlcGfpllQU5OAqdTK3sQa+xgiSdwASR9g=; b=ZAyQCHATAeazobMlvKoHvRWTI6kOfsKhnDeeE97ocxco2F5kB2wg0aEKVicAEaXl7R 6jUi8btDpDrEwRiFE2HHBh7eQrxbHpYhOMJkGit5QPnxbuNI0fsqh1h89eQGOChF6sjf pNrmSr4VPGbMFFquxdCrz/Sm4MiSMUJUwinjWjU5UL75jrHFKeKbusXjv9KE7GkiJ+63 0ZZekImkxjXZms1KtdZAWkpTI+AHRJmOKWxXgQc+6+hb1gdbfJ5XlYYRCooFmfJemOwp e5yprTYP1sC9nmNcr+TF8tFzryBladb43uSZrq0kNaErlkHaStt/+glk686cHVdb1yJv 0oNA== X-Gm-Message-State: AOAM5308tprr03jLuHreP8j28Ucy9T3TKq7H9G+/ahZ8QDvfiQfNvXB7 MC6UcsCiusGZkm3AC3zldPFYXsBlEJCL0A== X-Google-Smtp-Source: ABdhPJy4/Z5nfjdnchwdDLJpNVv/qkLRiMp09zM2HO8hGFsfRECHCUO/RUW0KKc0cYd2Uvwz1ensUA== X-Received: by 2002:a05:6a00:22d6:b029:1cb:35ac:d8e0 with SMTP id f22-20020a056a0022d6b02901cb35acd8e0mr19392584pfj.17.1612827553355; Mon, 08 Feb 2021 15:39:13 -0800 (PST) Received: from localhost.localdomain (174-21-150-71.tukw.qwest.net. [174.21.150.71]) by smtp.gmail.com with ESMTPSA id k15sm13483489pgt.35.2021.02.08.15.39.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Feb 2021 15:39:12 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 4/4] target/sh4: Create superh_io_recompile_replay_branch Date: Mon, 8 Feb 2021 15:39:06 -0800 Message-Id: <20210208233906.479571-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210208233906.479571-1-richard.henderson@linaro.org> References: <20210208233906.479571-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::52c; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x52c.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: alex.bennee@linaro.org, cfontana@suse.de, Yoshinori Sato Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Move the code from accel/tcg/translate-all.c to target/sh4/cpu.c. Signed-off-by: Richard Henderson --- Cc: Yoshinori Sato --- accel/tcg/translate-all.c | 12 ------------ target/sh4/cpu.c | 18 ++++++++++++++++++ 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index 470657b02a..b8ad95aa1b 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -2417,9 +2417,6 @@ void tb_check_watchpoint(CPUState *cpu, uintptr_t retaddr) */ void cpu_io_recompile(CPUState *cpu, uintptr_t retaddr) { -#if defined(TARGET_SH4) - CPUArchState *env = cpu->env_ptr; -#endif TranslationBlock *tb; CPUClass *cc; uint32_t n; @@ -2443,15 +2440,6 @@ void cpu_io_recompile(CPUState *cpu, uintptr_t retaddr) cpu_neg(cpu)->icount_decr.u16.low++; n = 2; } -#if defined(TARGET_SH4) - if ((env->flags & ((DELAY_SLOT | DELAY_SLOT_CONDITIONAL))) != 0 - && env->pc != tb->pc) { - env->pc -= 2; - cpu_neg(cpu)->icount_decr.u16.low++; - env->flags &= ~(DELAY_SLOT | DELAY_SLOT_CONDITIONAL); - n = 2; - } -#endif /* Generate a new TB executing the I/O insn. */ cpu->cflags_next_tb = curr_cflags() | CF_LAST_IO | n; diff --git a/target/sh4/cpu.c b/target/sh4/cpu.c index a78d283bc8..ac65c88f1f 100644 --- a/target/sh4/cpu.c +++ b/target/sh4/cpu.c @@ -43,6 +43,23 @@ static void superh_cpu_synchronize_from_tb(CPUState *cs, cpu->env.flags = tb->flags & TB_FLAG_ENVFLAGS_MASK; } +#ifndef CONFIG_USER_ONLY +static bool superh_io_recompile_replay_branch(CPUState *cs, + const TranslationBlock *tb) +{ + SuperHCPU *cpu = SUPERH_CPU(cs); + CPUSH4State *env = &cpu->env; + + if ((env->flags & ((DELAY_SLOT | DELAY_SLOT_CONDITIONAL))) != 0 + && env->pc != tb->pc) { + env->pc -= 2; + env->flags &= ~(DELAY_SLOT | DELAY_SLOT_CONDITIONAL); + return true; + } + return false; +} +#endif + static bool superh_cpu_has_work(CPUState *cs) { return cs->interrupt_request & CPU_INTERRUPT_HARD; @@ -217,6 +234,7 @@ static struct TCGCPUOps superh_tcg_ops = { #ifndef CONFIG_USER_ONLY .do_interrupt = superh_cpu_do_interrupt, .do_unaligned_access = superh_cpu_do_unaligned_access, + .io_recompile_replay_branch = superh_io_recompile_replay_branch, #endif /* !CONFIG_USER_ONLY */ };