From patchwork Tue Feb 9 18:27:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 379371 Delivered-To: patch@linaro.org Received: by 2002:a02:b18a:0:0:0:0:0 with SMTP id t10csp486074jah; Tue, 9 Feb 2021 10:32:08 -0800 (PST) X-Google-Smtp-Source: ABdhPJzE6OQnCtVxhpjEjQ5uFg21YRxHhCdDjrDxAXuko+RKUmcOua/zUbOYfjxkCsLo9g4weI5h X-Received: by 2002:a25:d711:: with SMTP id o17mr36541862ybg.113.1612895528442; Tue, 09 Feb 2021 10:32:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612895528; cv=none; d=google.com; s=arc-20160816; b=FLRQI7c2k/zmAE7IwaVgmj00vuAuSCM9e0boUeqcnp5e1J5zQjpW+BIPrcHpoeWkc9 O6pJ+WMkholgd4baRys50Weku8pRBQtrzo0oy2H3r9o6mpDIlKbn8oi+eNrnSsYewhek UOdirYxK4TkjtHUwQhV6q7uRiqSMptjo9cFbg9lEzGfs6YLiZ3kmox/jPuZlPRHjVhl0 QD9nJlemXKfW8Z9+6mXWxhPEAlHnXKoRWrLqxKzLYiYA0hX9/X8O5zhiUJj8x4bEXVGn mKndO4TyFPQwGvXBkRjEz0yw4mHckmxF28YgpNhcMGgGZH39KH5YjHXhhCuwWMf8TDLH U1Aw== 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=TPpkuVowT3XsKdUIr+oG7/FvD0rzuMPKtWzVkORBqZU=; b=MS1CKH6fC723U/PBwKsZLUUZ5j55zCJJwjkDHHQ0iOZPC+EXuZuP0Zmz1948Nwu1Cs /ACmp8OwRhIq8x7Gt6tOaTKghiRGGqAUmDtn9rNCL044sMoEK8Kr6ExBgBvq8zzC4rvI Kfnt4R8VcX1zsMeqoIECPunSsE2xGQaooVGw/3DyFOnuU+jOABN4NsODhqysvlYxxkx0 h1HxeMrchx++Z1TKH/sDxh3B3Ccuj1iNr45hhz8WYskqzBAZPlI53/gVU8n9XIm4D+FU beGyjazdQNJP01eLxTxucC/81SMq0YIHT9Pt9e4m/6iWW8WscPfuWdof7YaPAHnDTZb0 lvdA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=iALTTT+A; 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 h66si20593668ybh.54.2021.02.09.10.32.08 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 09 Feb 2021 10:32:08 -0800 (PST) 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=iALTTT+A; 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]:37350 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l9Xnz-00067f-NV for patch@linaro.org; Tue, 09 Feb 2021 13:32:07 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:43228) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l9Xjw-0002kR-Ma for qemu-devel@nongnu.org; Tue, 09 Feb 2021 13:27:56 -0500 Received: from mail-wr1-x42c.google.com ([2a00:1450:4864:20::42c]:33176) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1l9Xju-0007lS-JW for qemu-devel@nongnu.org; Tue, 09 Feb 2021 13:27:56 -0500 Received: by mail-wr1-x42c.google.com with SMTP id 7so23274571wrz.0 for ; Tue, 09 Feb 2021 10:27:54 -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=TPpkuVowT3XsKdUIr+oG7/FvD0rzuMPKtWzVkORBqZU=; b=iALTTT+AvLXMnAdpbzE1niXlnHVH7Se0qef9oAy4hwM1Y125fB1x+7HzTmJs/Uo+ZU 1c6tKu3gw5y9s/M1E8R2kaxEd2IGBXMWEsd8XCrqjDcn3/cIjhCCSlab0kt/b3kdv2rE q4Uugo5v403szdPslyO/oWo64H8tFAr5SlkuGpNouf5dsrVFKqYP6L+rF+tMIFLhAsYl n103RCPvGHLkySjfV1Xs9aBQUkRNoMshwTWGEy0yjf5rOsVWTfKZdxEnQ3tzB3W2e03g x5w9VM6r0geLknxOzeowafSqij6MciMwNSO3bX0kd89eOF8Ab2yWvd2rdHAkv/n6/Q5p b7ZA== 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=TPpkuVowT3XsKdUIr+oG7/FvD0rzuMPKtWzVkORBqZU=; b=WFp4+R3NP0L/xpyvkXGTyYgn8FpBi5goE+WWxhk+lUcHbHADJfad77oE5YRBi6Gf9b KDRsMmZjEAtnnQTq4g39eQRyzMZcHMmA8X1RLF66WBzzPsSB9iycqMuhOGGZVd0FAyJz /VeMgoG1lnYeMPRXxoGS4m2Mn6/tSDjR0DWUW1/HqKVY8J9VEML86cCzxhceqKliF3iy E7OB5kq/u6S6j3EQMhY6whh4G236IODJicfUaCwPZujqViv1QUX3Zo6UXGaLcdvV4vxx PqbJNJNOu6EIvuMNPZZ3SVemyHAXCqQ+YO8uFLfG4RgZNZp4t1yAtHuqiT2hyV8OUK4m D3aA== X-Gm-Message-State: AOAM530nYEIHifU2HGfNBQnDXZw++pwVKOCBQ1vJE2cUL+KvMhSXXP1b mIPaYi6P/GmkMinfoYWlDDVxZQ== X-Received: by 2002:a5d:54ce:: with SMTP id x14mr18133736wrv.182.1612895272952; Tue, 09 Feb 2021 10:27:52 -0800 (PST) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id h14sm4976510wmq.39.2021.02.09.10.27.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Feb 2021 10:27:50 -0800 (PST) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 979EC1FF87; Tue, 9 Feb 2021 18:27:49 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v1 01/12] exec: Move TranslationBlock typedef to qemu/typedefs.h Date: Tue, 9 Feb 2021 18:27:37 +0000 Message-Id: <20210209182749.31323-2-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210209182749.31323-1-alex.bennee@linaro.org> References: <20210209182749.31323-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42c; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x42c.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: Peter Maydell , Eduardo Habkost , Anthony Green , Richard Henderson , Michael Walle , robhenry@microsoft.com, aaron@os.amperecomputing.com, cota@braap.org, Paolo Bonzini , kuhn.chenqun@huawei.com, Guan Xuetao , =?utf-8?q?Alex_Benn=C3=A9e?= , "Edgar E. Iglesias" , "open list:ARM TCG CPUs" Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson This also means we don't need an extra declaration of the structure in hw/core/cpu.h. Signed-off-by: Richard Henderson Message-Id: <20210208233906.479571-2-richard.henderson@linaro.org> Reviewed-by: Alex Bennée Signed-off-by: Alex Bennée --- 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(-) -- 2.20.1 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 Tue Feb 9 18:27:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 379369 Delivered-To: patch@linaro.org Received: by 2002:a02:b18a:0:0:0:0:0 with SMTP id t10csp484770jah; Tue, 9 Feb 2021 10:30:31 -0800 (PST) X-Google-Smtp-Source: ABdhPJwcRXjtV+dvQjhKAO1NPbA1cnsgcf5D7CpUfzPTT3m3OlwOWtISQFF59xhfAhaY2cWetGBa X-Received: by 2002:a25:cbc8:: with SMTP id b191mr15626916ybg.61.1612895431860; Tue, 09 Feb 2021 10:30:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612895431; cv=none; d=google.com; s=arc-20160816; b=OHF2mh7SlJRAzvTldIrw2p7YIh/ckNYdTn40vTW5ns1NWyXthhchnrGo+hZYJ0xUFG 05nZGbMlnjT7jyyaZvjkcnSZ1SWqo1yLd9KtiO23BkA16J6CBKTl5+XfJTHG86iTC+an UGOj0OQYqt2AG4dQrbTkAA73y6jjy9nQryIgUglebx5axwJ0Up37QYmK+/H+PNo9R7P1 FHUli+6D659pJ7TggHyAmCNz4VJU9DiwS/X4PLO72/B1ingvzYoOHfmWLV5729m4xxKt T7h1uLdA9PrroOWg4tCMAavR8PTbLPp5ick1Pf4XsG3ghZLmx3ZH2gb+Il0e12yvhsOW lobQ== 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=zNliwCPKaSP1eGW/lpkDIX8h4kiIJ0I84O8E5iALOHU=; b=geFV1j5LncNH3yqmzMH3VXPmQY1ScoP0xFRb2Zcoz8TD1l2ywf50iW3uu/zC/exx1u f9bOp6QVWJr+ZiibgNzNddZNutmWaP8uP76btAkA+pS3drEzYAc+DJ8MkmvvD2Dprvud z0cqvFZKPx6QHDRzCxiA/I30YxcmRIOZMXdGtPN8zUzlTExBmeUVn/A5ZQFVHARUz1cz 4QwaXPeC2mtTPXB1R0cuEKEZp969uF1zl3j936x0rCs60tHphcHBwdiNU+HEW4zgn7mT Ad0xOXKdpC/uBLVL0eW20oeiCs76I/CvNTPm1HY+o+qx4bNxz4WT44n4vhLoD4VGefpy CPsQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=egZKsiFm; 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 v2si14915077ybp.204.2021.02.09.10.30.31 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 09 Feb 2021 10:30:31 -0800 (PST) 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=egZKsiFm; 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]:37718 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l9XmR-0006Gc-As for patch@linaro.org; Tue, 09 Feb 2021 13:30:31 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:43292) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l9Xk0-0002sY-Ed for qemu-devel@nongnu.org; Tue, 09 Feb 2021 13:28:00 -0500 Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]:38690) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1l9Xjy-0007nb-QH for qemu-devel@nongnu.org; Tue, 09 Feb 2021 13:28:00 -0500 Received: by mail-wm1-x32a.google.com with SMTP id y134so4455548wmd.3 for ; Tue, 09 Feb 2021 10:27:58 -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=zNliwCPKaSP1eGW/lpkDIX8h4kiIJ0I84O8E5iALOHU=; b=egZKsiFmjWI9Gf7ZlfrFZRPtI4ko0Gjo7AUplfJhqP+bw31B9oDPRcZjnjbiKvaKnb nPHrZmHxu+BQUB6WZJ0zBVZEcTgV2zd/yO3B91cVyhinF0OyJtgBB+luwP5JcXO+tQD0 GLircg+1e0o1w/GgBMUEZu9rUFsvs1gZh+a0slzCv2u/w2ooftISorZPdlYYzmkN1bUo ysCqD9qwIP52UtPci/OzCKgztSPkIk1D6khT//GGmESvB2wZLP+fxpS7gFbDF21A2IUR +gz+gXgiOBq0kh261isPKKcnkeMRJI9Ia7Bdbn6ktReKfu3oF9pgGV20sGPm3EfG1eSo zwkg== 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=zNliwCPKaSP1eGW/lpkDIX8h4kiIJ0I84O8E5iALOHU=; b=Z2H4YHm01KkakoBoI7qoykBjbYfAG5oof/fBU3yrkR+Acm4yR6J+r5psZxoNCfIYrW GUZmlCeFSbPYZByvFJChz7IdTucbQjHVx+QI3egVp4JfNb+Jrqe7eFA6zCUe08Kv0jox qfVTXEkSsddARHcUTaofqcwCiHNIqeCUt+bKHEbb0GQmh7k9xOv06e3FDIgPj75kUQuq uJ2ffO9dry8phTucffJqiaGOWZKzvRU5oVt/elHyGcm5wQ1QbmQRdI6X+Zx0+m8IWam2 3TfbHmkomzF8n3D0rUPecmVo9/YHmMOZGC55yCJnlz7EeAiP2f77nnyyHM0nfiMTCUFu b8Ow== X-Gm-Message-State: AOAM531PPvZnBQthY+aFYzVHYBIqGG3JhhZTMv6TcWXDBKeG5NLVWpgU qghSUuG4Pji28MXniHT2kNis4Q== X-Received: by 2002:a7b:c842:: with SMTP id c2mr4762511wml.100.1612895277381; Tue, 09 Feb 2021 10:27:57 -0800 (PST) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id v1sm5663986wmj.31.2021.02.09.10.27.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Feb 2021 10:27:50 -0800 (PST) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id BCEDB1FF8C; Tue, 9 Feb 2021 18:27:49 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v1 02/12] accel/tcg: Create io_recompile_replay_branch hook Date: Tue, 9 Feb 2021 18:27:38 +0000 Message-Id: <20210209182749.31323-3-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210209182749.31323-1-alex.bennee@linaro.org> References: <20210209182749.31323-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32a; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x32a.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: Richard Henderson , robhenry@microsoft.com, aaron@os.amperecomputing.com, cota@braap.org, Paolo Bonzini , kuhn.chenqun@huawei.com, =?utf-8?q?Alex_Benn?= =?utf-8?b?w6ll?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson Create a hook in which to split out the mips and sh4 ifdefs from cpu_io_recompile. Signed-off-by: Richard Henderson Message-Id: <20210208233906.479571-3-richard.henderson@linaro.org> Reviewed-by: Alex Bennée [AJB: s/stoped/stopped/] Signed-off-by: Alex Bennée --- include/hw/core/tcg-cpu-ops.h | 10 ++++++++++ accel/tcg/translate-all.c | 17 +++++++++++++---- 2 files changed, 23 insertions(+), 4 deletions(-) -- 2.20.1 diff --git a/include/hw/core/tcg-cpu-ops.h b/include/hw/core/tcg-cpu-ops.h index ac3bb051f2..72d791438c 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 stopped, 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 Tue Feb 9 18:27:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 379379 Delivered-To: patch@linaro.org Received: by 2002:a02:b18a:0:0:0:0:0 with SMTP id t10csp490140jah; Tue, 9 Feb 2021 10:37:22 -0800 (PST) X-Google-Smtp-Source: ABdhPJyUXf/SxfrpMlbgb31X8VesPfhRlK8KSFjysf/dbm6eK9Fzm6dZf8QW41vvRtnG9EirrXb/ X-Received: by 2002:a25:1002:: with SMTP id 2mr35408937ybq.410.1612895842854; Tue, 09 Feb 2021 10:37:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612895842; cv=none; d=google.com; s=arc-20160816; b=sSc07mNMVgN+WtwH84sb6UCipRfcWX1ncLFnnxRY851oBtJZjF7MKphS2q7lEsbVoX 93djG51VHHOyzu3ea1p869Qxz289kVMMuZgivq3P5q18BbHnuJGAfZGVY5jtF1oOpszS c04iT+3QpON23ut9PY+fJ0Mb90fk/VxcJqvZNxf+D+gSNDMc7XXBcxJQHR0cV9eSShCB 5GvAEkE1gkyxGPdpOiE9hyQtGyd1p7nBHKT6kfiR1V8Set71hrttq+gvRNrZ2FQ0p+Pb dowUkcAv9y34vcArVkp+QL06LBrPTF4w9qmB7FWu/F7uTYj+oavT60+Z3KuUtn7RiN/k pGPA== 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=/09yZXBu/IIBdtGKto41tx2iEh/nEfZf6dGwHzi/lkI=; b=T+fkV6sMuikPiQ5KAIHF/GImXbRoKCEuk2nYmRgyuR3a4USWCBuig27T+sNk8WtB9M FZIUNjG1DXZnKe+i0a9Zai9RT3Wv35NYDuhyClZu3EzqRVHoI/NEa/Dzjbd9AqomjVTy /Fx2EtETE4uVZLWDW4Lz6/mwj1Be5AOZcS7HEaKMCjre1Zu/y3hb+APe2in1g6FQD0cx gJmBR3k39G0es4s+1uJFgSuhADrK1dvDa/ixmGpLfdLyCMFUpb+nmmMRIvdYxFOW/8Wf dvLKpicA9gkLjmqX+hLxSTjBATrA5hK94wVOtjMcDyrRESLjrhSGZpP3aW+TVro1b2tJ LyUQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=XAICnjr5; 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 f76si26597126ybg.189.2021.02.09.10.37.22 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 09 Feb 2021 10:37:22 -0800 (PST) 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=XAICnjr5; 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]:54568 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l9Xt4-0005TM-9q for patch@linaro.org; Tue, 09 Feb 2021 13:37:22 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:43282) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l9Xjz-0002pY-BA for qemu-devel@nongnu.org; Tue, 09 Feb 2021 13:27:59 -0500 Received: from mail-wr1-x432.google.com ([2a00:1450:4864:20::432]:42665) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1l9Xjx-0007mc-2z for qemu-devel@nongnu.org; Tue, 09 Feb 2021 13:27:59 -0500 Received: by mail-wr1-x432.google.com with SMTP id r21so6986815wrr.9 for ; Tue, 09 Feb 2021 10:27:56 -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=/09yZXBu/IIBdtGKto41tx2iEh/nEfZf6dGwHzi/lkI=; b=XAICnjr5aUDi2vKoKu3eqA52NHh2FT2ysPULfHaECaTigveQaCW34PjBbDGJ0W3PxB IP1Unjnug85UpFZfHGiBE7WDGc6Q1fkn+1+c0ukr+xWZpLrjO4WsCkU/nmUrKOtjn1cR mWx3UMPrKJysrLLntYNIu0uFTxw4G7GFYvtHJfQlq6ej45yOnIP0vZQTiTMzGHKOZfWe C2XtLZgzramSJoqx2/3BfqXEnBk08wlt2VSzGQPDs7elAN4T60gkZhma3BWxNfhy28HB hXmfu/Lwh3ayJEndMiU4DwoGR+zmyzMmheqhWaf/wSADVK8SlMg+qkaiSwVWFIaQ5ECi CbWA== 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=/09yZXBu/IIBdtGKto41tx2iEh/nEfZf6dGwHzi/lkI=; b=Spm9VSHm59vk+o2dKnzl5rWI8T0FHoSsSFrcP66ifaLaqB/BUM2yAQrc+qGO6gFTdW UzWO9TGF5zusc6kUZD06RU2Z+hyrJjlirTUgxcKy3kPEcgLsCk/tQvAQ1rRguNs8A9JF 7Isek/JzP01vHhS0mrt/rePyKYr44f0SlesXQkesDawGB9zCRAHr0BkKiBsPn2hwiNpX NP259O1YRMaftnsTg66JkFnriNvrNwHmbOfeMwrm/L65yO/YGmNGamMMdtFJe6LUl8G1 XlLSpynmvS89eIOecNoLwRRprRP+qRJfJStNuRGq/FFbY9I+fqY50lMAQGSGSqJ1MYvh 4gRg== X-Gm-Message-State: AOAM533bxtZoViX5f0on3QDSCa4loyQz7lXDrXNZGoAHqPY8DwhY+xS0 20MU/EODp9IEbINdwKqo9kzDV/VTRPx/yifq X-Received: by 2002:adf:dd10:: with SMTP id a16mr27236303wrm.207.1612895275667; Tue, 09 Feb 2021 10:27:55 -0800 (PST) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id s23sm5670539wmc.29.2021.02.09.10.27.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Feb 2021 10:27:50 -0800 (PST) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 014631FF8F; Tue, 9 Feb 2021 18:27:50 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v1 03/12] target/mips: Create mips_io_recompile_replay_branch Date: Tue, 9 Feb 2021 18:27:39 +0000 Message-Id: <20210209182749.31323-4-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210209182749.31323-1-alex.bennee@linaro.org> References: <20210209182749.31323-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::432; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x432.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: Aleksandar Rikalo , Richard Henderson , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , robhenry@microsoft.com, aaron@os.amperecomputing.com, cota@braap.org, Paolo Bonzini , kuhn.chenqun@huawei.com, =?utf-8?q?Alex_Benn=C3=A9e?= , Aurelien Jarno Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson Move the code from accel/tcg/translate-all.c to target/mips/cpu.c. Signed-off-by: Richard Henderson Message-Id: <20210208233906.479571-4-richard.henderson@linaro.org> Reviewed-by: Alex Bennée Signed-off-by: Alex Bennée --- accel/tcg/translate-all.c | 12 ++---------- target/mips/cpu.c | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 10 deletions(-) -- 2.20.1 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 Tue Feb 9 18:27:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 379375 Delivered-To: patch@linaro.org Received: by 2002:a02:b18a:0:0:0:0:0 with SMTP id t10csp487856jah; Tue, 9 Feb 2021 10:34:24 -0800 (PST) X-Google-Smtp-Source: ABdhPJxuamNxIV+oP9R3UmYPvXMpRuehVV1vZ7XNRMLLpJoXsxJegWNWGDVr0ePOxm7yUl7+SoFY X-Received: by 2002:a25:3c44:: with SMTP id j65mr48055yba.323.1612895664234; Tue, 09 Feb 2021 10:34:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612895664; cv=none; d=google.com; s=arc-20160816; b=G7S1AwlNi3atBZnxmBvU5aIVg98OZo5EnFq4qIcV6JJFU+IQ3MsWhx8l8GnMMr6NOS 2bJnUelwVoAnpL16Okgo5QpUGz1r3pYk9JkTESfTHFoLAEIdUOTYXcu2O/uKhusY3klM 7o+SCcdVo8ulqwIY7hJAlD3hXZVnkP693oizsfELMVE55vPlKCtgEz6RH6WV02vRA2Y9 co4r4nzA7yCtIZWryCHMv8c7QiDydhSOAdzcuCr72zXiB55Qa7OMHQz2Czppxugarmuu M8yWOPog6LioTuw+eGSH76TOtOcCTcWGqrYW33L1ptV8wedRv+ItsU0w/Njk2LwfzSLL /VWA== 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=DCYLKD8lKHBC7zqZxsTt0jNxWwRKIBBIOHuXIK5gJKg=; b=sXgj8H73v+l6K8CbpNaAh/xNYa4JTRrALTG859oWYaXpocsGmxyXWGKg9TcZQPHblf qfwbdFyqiePIRZY2UyDTPKsRTrexc7gaJlCLykKyNogcOIp4TpTy/lQC8DftS4je2Z/+ BVpvc4zHqSH3bvlluRNCi1EzgPhfwLjpKZqKHOuNkpwlgtj0LHQ60lRQRPunVWzy5aVY U5GkGzee6PqyVT66BgkN1KdnL2qlgPAGHV8wkSbD6EGp/vDWWzxeixa091tffWvDrdNz A7GlL7ubpnoRTpniBaI/gor36oQpcoaovfV11piuNps2a34ckCkZOyK474Qwjw3pKtUj iqsg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=ZT+jFby6; 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 x4si21074772ybo.323.2021.02.09.10.34.24 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 09 Feb 2021 10:34:24 -0800 (PST) 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=ZT+jFby6; 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]:45984 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l9XqB-0001fB-HD for patch@linaro.org; Tue, 09 Feb 2021 13:34:23 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:43266) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l9Xjx-0002mS-U1 for qemu-devel@nongnu.org; Tue, 09 Feb 2021 13:27:57 -0500 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]:50782) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1l9Xjw-0007mO-27 for qemu-devel@nongnu.org; Tue, 09 Feb 2021 13:27:57 -0500 Received: by mail-wm1-x333.google.com with SMTP id 190so4176221wmz.0 for ; Tue, 09 Feb 2021 10:27:55 -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=DCYLKD8lKHBC7zqZxsTt0jNxWwRKIBBIOHuXIK5gJKg=; b=ZT+jFby6CcB/HaeXekybKcyT8N1uK8Tc69ilxcaQv0BcLI8N2QLBrGIrltXQyfDmcl 4w9L3WV6wD02OA0m0XDvLDxYwr+3hAQ0e7s5/IOgBxl29uRQTU6gTfxRfe+Fh7sKR7IC JuObPYX9Awt2twZKss0KRsrakWq2Sd4TmN/51xq0VMKen7iC79yUdjDJV8wc+L43Rq3h k43Cb3sgT4qOGeAvjlVa6EvKGwobKk8sCP3qLNxCHHdMZKfvFlrI/pV3GJq5uKZnzB0n ngXxEivwOreb4JYGcSsJ5IfmH2Nhtn325NXVUbiRxsH1X2GrizKlPZz+xJddqjTbyzLw FeUQ== 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=DCYLKD8lKHBC7zqZxsTt0jNxWwRKIBBIOHuXIK5gJKg=; b=taoiPOFm35jAZRgsTPc7JEIB/6rn4fE95rO/ajG6r+0hkQDcXWmMTt6voR9fif+2yz N6ZrHubB3NMtNa29hcaCkSk6S6dhaHe3MpYsfmGgGFZltWxgrUqi02eeEy7BHkK5afyv pvjetRZoMZwgmVxN0s1Mhukw70BiFdHtO+WpP3kKzGALZb7EJb35ldBL17pL/JIOPppx 7qqny3JzOyfUsBFo4RDRcGB1ZBeMmy6/2RZcLiwP5TFvzO7+mS61O6BnrRR0e7sVd6W1 dE423nhq9U/OuYZ0w7y5uWW3aZBQCW+ls56sLbUpSMR0UzQrHS9MmyoTGl22Nl9S5m9N omLQ== X-Gm-Message-State: AOAM530BIkZWJbirK/f5pbExe2dBga0KmRv1VIekE4blu/rtQY6rMOw5 2sQyxM6qkny2ZbmQqYQiDxshOA== X-Received: by 2002:a05:600c:47d7:: with SMTP id l23mr4833252wmo.16.1612895274745; Tue, 09 Feb 2021 10:27:54 -0800 (PST) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id e4sm37194265wrw.96.2021.02.09.10.27.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Feb 2021 10:27:51 -0800 (PST) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 3564D1FF90; Tue, 9 Feb 2021 18:27:50 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v1 04/12] target/sh4: Create superh_io_recompile_replay_branch Date: Tue, 9 Feb 2021 18:27:40 +0000 Message-Id: <20210209182749.31323-5-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210209182749.31323-1-alex.bennee@linaro.org> References: <20210209182749.31323-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::333; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x333.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: Yoshinori Sato , Richard Henderson , robhenry@microsoft.com, aaron@os.amperecomputing.com, cota@braap.org, Paolo Bonzini , kuhn.chenqun@huawei.com, =?utf-8?q?Alex_Benn?= =?utf-8?b?w6ll?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson Move the code from accel/tcg/translate-all.c to target/sh4/cpu.c. Signed-off-by: Richard Henderson Message-Id: <20210208233906.479571-5-richard.henderson@linaro.org> Reviewed-by: Alex Bennée Signed-off-by: Alex Bennée --- accel/tcg/translate-all.c | 12 ------------ target/sh4/cpu.c | 18 ++++++++++++++++++ 2 files changed, 18 insertions(+), 12 deletions(-) -- 2.20.1 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 */ }; From patchwork Tue Feb 9 18:27:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 379367 Delivered-To: patch@linaro.org Received: by 2002:a02:b18a:0:0:0:0:0 with SMTP id t10csp483908jah; Tue, 9 Feb 2021 10:29:24 -0800 (PST) X-Google-Smtp-Source: ABdhPJwFqmY5NWSW7VdEYShHGulMEb6G090pRUmL0Cgw75P32Ve7af8HLRIFl7imfz8nBi/qT8hx X-Received: by 2002:a25:5843:: with SMTP id m64mr20313532ybb.155.1612895364086; Tue, 09 Feb 2021 10:29:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612895364; cv=none; d=google.com; s=arc-20160816; b=ghiC4mYAe4BOy2EYA+M/nAB2sLMB+j7WIcqhprXX4fXBCA2zAME2dSYwKDWypXndBU Zsxp2Lm1lyfIKJsZYcsgUkBpqj0568T/tgxNvwSH7eQ8mUY4BkAHVq92wvqEcwdfW3+1 s6Vx2p8+ei9BmkOOAOONpNZ5MdDcDTt042RhdrNqHCd/oS8+QvRu0wbHWZ3nd9GHbCqH mqySB9H1Zt4ccJwHw0ndlFLrg6li8AT8u2zpWlvuXt/ArtX+9VpRDB0eo413jmsteyAW mHXr+WiUp9g/046P92H8kBGSrkoDqTSVbg00TDyXx+Xw5gDXcmz0M4Te3g1wkGL+Gk7Z 8yNQ== 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=XTJA1LO8Z0+7BgtkAor7hGRdE1VoRrWN9y3S3XEnRWI=; b=YHS6BCyRv4XgFJQPkbY9tkGBIGJpmdahjFtvaQ0Ua4BcsHzHNV2kiFcrSqIPTSThYW +IkMd5iIzjV1yv88y+B+mKgvMO2d3OO0asllgihzWypRVNoOfZHXC0xcxYqsA0ASk6Tp 8CK9iw5SFO99S1aDWJfzjeC+t8rP/AqFp0opQxc2VMigSCdX2qVxbxWgpuqQ70Iaaiu8 /a0UtWpqQhYafX9OwbX87+CubjIPKcgTE6Gr/YpXqY+S3EigKtxqgh6RpSPpWFVxuCxW x18nJlNRR29NNqb7Z2hKedFlW7Z//OVPl7mWkElKB9dr0867FriAFtkwyqCmxK5MKG5L qFIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=fFwbh0XW; 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 e3si22024699ybi.413.2021.02.09.10.29.23 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 09 Feb 2021 10:29:24 -0800 (PST) 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=fFwbh0XW; 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]:33146 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l9XlL-0004OV-CP for patch@linaro.org; Tue, 09 Feb 2021 13:29:23 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:43320) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l9Xk2-0002x8-DO for qemu-devel@nongnu.org; Tue, 09 Feb 2021 13:28:02 -0500 Received: from mail-wr1-x434.google.com ([2a00:1450:4864:20::434]:46787) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1l9Xk0-0007oy-RQ for qemu-devel@nongnu.org; Tue, 09 Feb 2021 13:28:02 -0500 Received: by mail-wr1-x434.google.com with SMTP id q8so883020wru.13 for ; Tue, 09 Feb 2021 10:28:00 -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=XTJA1LO8Z0+7BgtkAor7hGRdE1VoRrWN9y3S3XEnRWI=; b=fFwbh0XWSo/LK+qGFnzqeQf5yzBNoJpZONNhqzYAqz+UbOSHkNr6Ze5YUIdlaQcTp0 76ZMOG/izSrJwxV/ciJW10qopNJ/hEUBjNcaUnTyuaieJfXp1oB0xifvgbKgZwG5esfE ms9YmUrR97b4dqoBogTUGAWVwA+fBluZ4hLPF1d61fazpBwnDSJDxjusLYbYrICyJ8uD ZtMLG8/TNnNIt0NFiSlU4CdcfbNfbHeUpTWRVjmW7gs9U2jMNlFp079I5+toWQ+08s0r 2btou0vXOH85pOh6KJ2awaJtH9hnWyq+jMFf8GtGkp2GyM4YaIIhmDzP+TQS24rIbTmB eQ5w== 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=XTJA1LO8Z0+7BgtkAor7hGRdE1VoRrWN9y3S3XEnRWI=; b=RXl8ngEW6RzCG1oBRoyzGgu72AQy5zQq4tp5VqV0H5TmwPGVb0tNWZvVYRIXyxA04h 1fCiwKHSTcUcMVIPsBeRkwYbdr4BuXVf/6JwioDqcZF9izlPvQYD01nxa6NMNw4CNacB aIZ7il23pNYuwqp5SNmCSJfD6ZYVkILjjtO1vwfJxqFhSH44p15H6R7DnX83BtYOhiCV OWX1beJCGuqaXtnBF/YOaAEDa926JwIBl2SPUfABOFCig2pM6wWXvDshgEVN1qBwW0zr 1ORR53KQBGREmWCj/W16HVf13QtX6o/NY5dn61idiXkbXThmq9AFwgwrpLPdHX1aXPHp lAUw== X-Gm-Message-State: AOAM533TnxBstba9IEgt7aY+74L3+ZeZIL+G5NZYR4LwvQUla8dKHTvW EFpTpA+pXaL3Ex5fBhPqRcsAxw== X-Received: by 2002:adf:e3cd:: with SMTP id k13mr5882598wrm.289.1612895279586; Tue, 09 Feb 2021 10:27:59 -0800 (PST) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id 67sm6088550wmz.46.2021.02.09.10.27.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Feb 2021 10:27:57 -0800 (PST) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 732FE1FF91; Tue, 9 Feb 2021 18:27:50 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v1 05/12] tests/plugin: expand insn test to detect duplicate instructions Date: Tue, 9 Feb 2021 18:27:41 +0000 Message-Id: <20210209182749.31323-6-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210209182749.31323-1-alex.bennee@linaro.org> References: <20210209182749.31323-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::434; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x434.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: kuhn.chenqun@huawei.com, aaron@os.amperecomputing.com, cota@braap.org, =?utf-8?q?Alex_Benn=C3=A9e?= , robhenry@microsoft.com Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" A duplicate insn is one that is appears to be executed twice in a row. This is currently possible due to -icount and cpu_io_recompile() causing a re-translation of a block. On it's own this won't trigger any tests though. Signed-off-by: Alex Bennée --- [AJB: well not quite, the x86_64 test trips over this due to some weirdness in the way we handle rep insns, e.g. rep movsb (%esi), %es:(%edi) in the x86 bios code] --- tests/plugin/insn.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) -- 2.20.1 diff --git a/tests/plugin/insn.c b/tests/plugin/insn.c index a9a6e41237..c253980ec8 100644 --- a/tests/plugin/insn.c +++ b/tests/plugin/insn.c @@ -21,6 +21,14 @@ static bool do_inline; static void vcpu_insn_exec_before(unsigned int cpu_index, void *udata) { + static uint64_t last_pc; + uint64_t this_pc = GPOINTER_TO_UINT(udata); + if (this_pc == last_pc) { + g_autofree gchar *out = g_strdup_printf("detected repeat execution @ 0x%" + PRIx64 "\n", this_pc); + qemu_plugin_outs(out); + } + last_pc = this_pc; insn_count++; } @@ -36,8 +44,10 @@ static void vcpu_tb_trans(qemu_plugin_id_t id, struct qemu_plugin_tb *tb) qemu_plugin_register_vcpu_insn_exec_inline( insn, QEMU_PLUGIN_INLINE_ADD_U64, &insn_count, 1); } else { + uint64_t vaddr = qemu_plugin_insn_vaddr(insn); qemu_plugin_register_vcpu_insn_exec_cb( - insn, vcpu_insn_exec_before, QEMU_PLUGIN_CB_NO_REGS, NULL); + insn, vcpu_insn_exec_before, QEMU_PLUGIN_CB_NO_REGS, + GUINT_TO_POINTER(vaddr)); } } } From patchwork Tue Feb 9 18:27:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 379376 Delivered-To: patch@linaro.org Received: by 2002:a02:b18a:0:0:0:0:0 with SMTP id t10csp488026jah; Tue, 9 Feb 2021 10:34:36 -0800 (PST) X-Google-Smtp-Source: ABdhPJxbii/JwSneR4xkFb0NBy8rtccCsBus6r8sa5FQ1lIvUVkPoUXg2xodQicZWoqfr9asAQqc X-Received: by 2002:a25:cf88:: with SMTP id f130mr13318592ybg.476.1612895676448; Tue, 09 Feb 2021 10:34:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612895676; cv=none; d=google.com; s=arc-20160816; b=S4kD3ckaJH4YHRPJkYm+Fnwa+IohgpBR91bHz4ThI38txW4JCs4f6xfXD07LFlsTiS a0jeEAK+2+8IEMlhqdkkHSDtpBNOmwEXYIasLDMDntdItoI+gLb5iQV+W0K51+NOgXHb ZIgdiOJzA/EEM9IICqN6TQD523rt8PWWILjvuSYUUihRHr7V8dYLKtWIGcuc55FKJDzI KCug1iSf2EFOWE8Sqxs0E4MOxMijOBZ6CeK8x+7v9uM4JfGieFhMfNIKtPUeazKKcMsu 8m7FEKgcoe3d8smNLlH8Q3EoFiaupJfXBI/XDSkwOFZ7Zuw7cSZPB6Q5lQ6Qpa17PBZe qF5w== 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=QEIjvY3Wkc2WIeF8s4uxzLxZhJzabaYoCUAadrDeVZE=; b=Ak7keuP4t8WK99OgDTCDIpfQ+wpxafifLS0m12RTAMarAOLv5U3V+8SOGZPbdzo5j3 Ot1Jy5uwXJTMRaq3WXK7+pRevyU+/nYeALJKU3pB+6HV3qP4+gUSAchjPyso7Qf2NB7K dtB883EOMftx4UzVwDGkCQA7rZ+efH1u3e28evUDGI4G2LZB3txG6tJ8IgKGQNABJeUq atGGFygDn24jK0CD7UNn9sLHID1be/S5gu1gATwi6Yltlwwa6fqEQS28OJB9RW0GnhE+ 9HgFEppeps/LmgPI6eXGI35bXFBWVl2XmGCts6kIC/u3dWo6+qz4KoYlOBhze2VvXBZg 2pag== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=KliXru9u; 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 u6si25946617ybc.379.2021.02.09.10.34.36 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 09 Feb 2021 10:34:36 -0800 (PST) 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=KliXru9u; 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]:46426 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l9XqN-0001qy-Uk for patch@linaro.org; Tue, 09 Feb 2021 13:34:35 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:43426) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l9XkB-0003Kn-Be for qemu-devel@nongnu.org; Tue, 09 Feb 2021 13:28:11 -0500 Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]:35319) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1l9Xk9-0007rt-GD for qemu-devel@nongnu.org; Tue, 09 Feb 2021 13:28:11 -0500 Received: by mail-wm1-x32a.google.com with SMTP id j21so4466656wmj.0 for ; Tue, 09 Feb 2021 10:28:09 -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=QEIjvY3Wkc2WIeF8s4uxzLxZhJzabaYoCUAadrDeVZE=; b=KliXru9u15xBMEQw+4hAdOmtBHJ8ZGifwxmLu0rMZ9CSLdzjp80aaRWbK+VPHXDkJa geLxag8vbe7grek6tVlCfepqw8km0gpQ2qc1X0kXZ1fg6QQjL+PSTbyU3F6lGPTS/NdR MzLAa3kTRZUS8jJpm3lKqwHqM44b3v94ruxhTQqHRouMxTUeraOvZiMtWkV0Tz0xqH4V UDZR3w5m6GS7lALIYDpfTB7ZdWo1UngariYrV7qBg0Hc2WKNm8hE2TBYKeBHQA0xRnGt wAAjSQFiSiMh0V+1UsI+AU1etyjAO4ioBjs2qw3iJmUOdX3lgOi28ywUB3IbBloQouNR D/Jg== 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=QEIjvY3Wkc2WIeF8s4uxzLxZhJzabaYoCUAadrDeVZE=; b=ISlwE7mHCaeBs+EZXxUyu0iR+DiOQ5vTWXbm4OI7X/LWdRlXQ/zf7AdosGxzxDr0b9 4H7q7Tr3ZZ8HX99yMVODZh1cB6dUlfug7rdL24nJbhQPFaqAyiJ9toqIo0ZKwkhz41x+ WTMIeOPSn4PoKqAs+5h2uP86ExhDf+heX8kSZccLwRgF5vFTVIO+cfklaK8LkfZiwfVY 3AryQ2KSI0AE0jR8h+3NNgQZMXUv2Rt/e5YeR0S/WdnfhU/Obd/a2PSwSjcf1dLCIzjH 9fPItur+f59kPaK8BbXnA76iUy0NCg4XfkW4vgVfBRU+EazaSatVS7gt1wdq8dFph3qz S4OQ== X-Gm-Message-State: AOAM530fnkkvtYKTF2uCUMBhqvEGs+AyGS7T3cF4L2crgKq66t2+0etV l+5Q49d0Db2zSETsRZu3kvsQ/A== X-Received: by 2002:a05:600c:354b:: with SMTP id i11mr4698374wmq.72.1612895288086; Tue, 09 Feb 2021 10:28:08 -0800 (PST) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id w25sm5678434wmc.42.2021.02.09.10.27.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Feb 2021 10:27:57 -0800 (PST) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id A22FC1FF92; Tue, 9 Feb 2021 18:27:50 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v1 06/12] tests/acceptance: add a new set of tests to exercise plugins Date: Tue, 9 Feb 2021 18:27:42 +0000 Message-Id: <20210209182749.31323-7-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210209182749.31323-1-alex.bennee@linaro.org> References: <20210209182749.31323-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32a; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x32a.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: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , robhenry@microsoft.com, aaron@os.amperecomputing.com, cota@braap.org, Wainer dos Santos Moschetta , Cleber Rosa , kuhn.chenqun@huawei.com, =?utf-8?q?Alex_Benn?= =?utf-8?b?w6ll?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" This is just a simple test to count the instructions executed by a kernel. However a later test will detect a failure condition when icount is enabled. Signed-off-by: Alex Bennée --- tests/acceptance/tcg_plugins.py | 103 ++++++++++++++++++++++++++++++++ 1 file changed, 103 insertions(+) create mode 100644 tests/acceptance/tcg_plugins.py -- 2.20.1 diff --git a/tests/acceptance/tcg_plugins.py b/tests/acceptance/tcg_plugins.py new file mode 100644 index 0000000000..b512979769 --- /dev/null +++ b/tests/acceptance/tcg_plugins.py @@ -0,0 +1,103 @@ +# TCG Plugins tests +# +# These are a little more involved than the basic tests run by check-tcg. +# +# Copyright (c) 2021 Linaro +# +# Author: +# Alex Bennée +# +# SPDX-License-Identifier: GPL-2.0-or-later + +import logging +import time +import tempfile +import mmap +import re + +from boot_linux_console import LinuxKernelTest + + +class PluginKernelBase(LinuxKernelTest): + """ + Boots a Linux kernel with a TCG plugin enabled. + """ + + timeout = 120 + KERNEL_COMMON_COMMAND_LINE = 'printk.time=1 panic=-1 ' + + def run_vm(self, kernel_path, kernel_command_line, + plugin, plugin_log, console_pattern, args): + + logger = logging.getLogger('plugin') + start_time = time.time() + vm = self.get_vm() + vm.set_console() + vm.add_args('-kernel', kernel_path, + '-append', kernel_command_line, + '-plugin', plugin, + '-d', 'plugin', + '-D', plugin_log, + '-net', 'none', + '-no-reboot') + if args: + vm.add_args(*args) + + try: + vm.launch() + except: + # fails if plugins not enabled + self.cancel("TCG Plugins not enabled") + + self.wait_for_console_pattern(console_pattern, vm) + elapsed = time.time() - start_time + logger.info('elapsed time %.2f sec' % elapsed) + # ensure logs are flushed + vm.shutdown() + return elapsed + + +class PluginKernelNormal(PluginKernelBase): + + def _grab_aarch64_kernel(self): + kernel_url = ('http://security.debian.org/' + 'debian-security/pool/updates/main/l/linux-signed-arm64/' + 'linux-image-4.19.0-12-arm64_4.19.152-1_arm64.deb') + kernel_sha1 = '2036c2792f80ac9c4ccaae742b2e0a28385b6010' + kernel_deb = self.fetch_asset(kernel_url, asset_hash=kernel_sha1) + kernel_path = self.extract_from_deb(kernel_deb, + "/boot/vmlinuz-4.19.0-12-arm64") + return kernel_path + + def test_aarch64_virt_insn(self): + """ + :avocado: tags=accel:tcg + :avocado: tags=arch:aarch64 + :avocado: tags=machine:virt + :avocado: tags=cpu:cortex-a57 + """ + kernel_path = self._grab_aarch64_kernel() + kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE + + 'console=ttyAMA0') + console_pattern = 'Kernel panic - not syncing: VFS:' + + plugin_log = tempfile.NamedTemporaryFile(mode="r+t", prefix="plugin", + suffix=".log") + + self.run_vm(kernel_path, kernel_command_line, + "tests/plugin/libinsn.so", plugin_log.name, + console_pattern, + args=('-cpu', 'cortex-a53')) + + logger = logging.getLogger() + + with plugin_log as lf, \ + mmap.mmap(lf.fileno(), 0, access=mmap.ACCESS_READ) as s: + + m = re.search(br"insns: (?P\d+)", s) + if "count" in m.groupdict(): + logger.debug("reported %d instructions", + int(m.group("count"))) + else: + logger.debug("Failed to find instruction count") + self.fail From patchwork Tue Feb 9 18:27:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 379380 Delivered-To: patch@linaro.org Received: by 2002:a02:b18a:0:0:0:0:0 with SMTP id t10csp495440jah; Tue, 9 Feb 2021 10:44:13 -0800 (PST) X-Google-Smtp-Source: ABdhPJyVmNHsd0bqppPaDtlwExlVSM211tzKQyr2MlTHBySVrXhlHcf2oEbTbHmusXvafSldm8DY X-Received: by 2002:a25:782:: with SMTP id 124mr32072621ybh.53.1612896253199; Tue, 09 Feb 2021 10:44:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612896253; cv=none; d=google.com; s=arc-20160816; b=Izmy3k4iIDh2C65fjfZYxygfp560TXEwJAAxyvQV4UNgZs8RLjqGpej+rdxlEjrUsv VapwVpO7cNDnMPynICphnalEErBT/PucgJ9Nixadrfb/Taee1M/aCH79m03wfiOTMpJj RxL0LRRGHVk3cs9wtPCdv/pdnMhKRb0kM8OoCp3xz46cLcKxtrWqZZe1Un3yS1aam/lR 2fNk7V/kh62iZbVm8GyhogIXeU8IFKjdMSyC5WnYUgbP3DpzJfGCIED4Z4tvd1o9hsiH StFjP3vuJPkAOmy5lDj7A2K23UqTVWFEKYdoLpLAN45DTULYJkl95i3XVKdgYrmpomHT 2scQ== 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=uLoHyoIh1M9yTgnlc4zbWUCZ8MEEKdj0MabvYTrqb/0=; b=QbrNwl5fDWHk+xuQT6zYKKpC+i9T1sGjztweMiD0vGQCFdbnMrZVqi+0dapTobQiTf h4Flp8AG4guWSv34oz6Cgp/GpZlCJuspaCOJuRScLL9nflHAk5aIwl6nH8W0u4fb57bA v3Y59MO3qKpbXiEIYfTWkxGTfJFvkebQvTrtdToLqTGDLIMBfkQeOXHlz2JX87dAXRdP qg8t8jWC6I63f/4JwLT93QMUEZUnt083UUo3lQZk3krpT7SzF4jnaDGNpaBNHaXyFmQF gxmguY+SKuzzI9hRMbQF5m925LNRvzgjoXUDIiCi7hhl2F+RTWziNuqyYhsS7gSrkHqs Zaeg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="Hn67e/YG"; 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 j133si20205071ybb.145.2021.02.09.10.44.13 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 09 Feb 2021 10:44:13 -0800 (PST) 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="Hn67e/YG"; 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]:35234 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l9Xzg-0001Re-LH for patch@linaro.org; Tue, 09 Feb 2021 13:44:12 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:43402) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l9Xk8-0003CS-D9 for qemu-devel@nongnu.org; Tue, 09 Feb 2021 13:28:08 -0500 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]:53488) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1l9Xk6-0007r3-R8 for qemu-devel@nongnu.org; Tue, 09 Feb 2021 13:28:08 -0500 Received: by mail-wm1-x333.google.com with SMTP id j11so4158095wmi.3 for ; Tue, 09 Feb 2021 10:28:06 -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=uLoHyoIh1M9yTgnlc4zbWUCZ8MEEKdj0MabvYTrqb/0=; b=Hn67e/YGVD27SZi5AWZq2SgTKq0p4yhaYsrRFTKCYYTNcVO4eWjaZytEqxzTGgOCFN Cd3QBqxUB/Re8BP5XTSRqdBU2OUeayPOY+UVFxbo260NujHPxPaPJyEt6bBsjsSM2qgF EP7GOdB+gYgUoT5uL5PzF18oA+dmMh+kn9UTjrPkf8ax8IJzTnlteaV2ZVEIscVRSE1h vBNP4MjZctY1W8A6u064wufX++kyf8127Wwk+tkD/TXNLOnrbJqQGcuSRWH1qfW4fEwA 8PQQvCZVtJ6HYJHdAbgdt/EkvEPGO6vYvHTXRmltITBRCrKYDcqdBWbcA8FHeVgCre/Q icVw== 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=uLoHyoIh1M9yTgnlc4zbWUCZ8MEEKdj0MabvYTrqb/0=; b=coXSW84/UcL9lPkCxNCF1yZh/IOzflRxZHueDfaGgbc80snwuQRkujEySojd8W53U7 MA6bib5U9IUq3G4J+gD9ZmZFIGC4WJp6qZjqqxtjp/mHJjTu5WYDQvV671DycnLUfiuE RaEWsQM8y2/5TgbdafBzGnerYO/n11zxyYRPVbirPBWfU0hzQ9beL8nZ26wDBlnZUxGD yPAm6vMdXYeo2Vw4pwfCMwX7YbsBpEpHe5NXUwFuZVTJ74jyGtbcWPt0tiZJ8NwJPVz4 ZPuFeroQkYenyckJiZtZ4yGTs9zNxEyttQ3NLW2ZOdfvMTF/B5JnebOeu4w+LekDuL6j oOcg== X-Gm-Message-State: AOAM533z2XkAF1OsBHlX/9MuBQwu+qfRtX3WElAMUUAoFcG06GuWbT6A 0lD3yv5BePzO1rwwb/zuXgOexA== X-Received: by 2002:a7b:c3ce:: with SMTP id t14mr4727349wmj.175.1612895285458; Tue, 09 Feb 2021 10:28:05 -0800 (PST) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id c18sm9554487wmk.0.2021.02.09.10.27.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Feb 2021 10:27:57 -0800 (PST) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id DAA841FF93; Tue, 9 Feb 2021 18:27:50 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v1 07/12] accel/tcg: actually cache our partial icount TB Date: Tue, 9 Feb 2021 18:27:43 +0000 Message-Id: <20210209182749.31323-8-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210209182749.31323-1-alex.bennee@linaro.org> References: <20210209182749.31323-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::333; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x333.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: Richard Henderson , robhenry@microsoft.com, aaron@os.amperecomputing.com, cota@braap.org, Paolo Bonzini , kuhn.chenqun@huawei.com, =?utf-8?q?Alex_Benn?= =?utf-8?b?w6ll?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" When we exit a block under icount with instructions left to execute we might need a shorter than normal block to take us to the next deterministic event. Instead of creating a throwaway block on demand we use the existing compile flags mechanism to ensure we fetch (or compile and fetch) a block with exactly the number of instructions we need. Signed-off-by: Alex Bennée --- accel/tcg/cpu-exec.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) -- 2.20.1 diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c index d9ef69121c..7f477af891 100644 --- a/accel/tcg/cpu-exec.c +++ b/accel/tcg/cpu-exec.c @@ -730,16 +730,18 @@ static inline void cpu_loop_exec_tb(CPUState *cpu, TranslationBlock *tb, /* Ensure global icount has gone forward */ icount_update(cpu); /* Refill decrementer and continue execution. */ - insns_left = MIN(0xffff, cpu->icount_budget); + insns_left = MIN(CF_COUNT_MASK, cpu->icount_budget); cpu_neg(cpu)->icount_decr.u16.low = insns_left; cpu->icount_extra = cpu->icount_budget - insns_left; - if (!cpu->icount_extra && insns_left < tb->icount) { - /* Execute any remaining instructions, then let the main loop - * handle the next event. - */ - if (insns_left > 0) { - cpu_exec_nocache(cpu, insns_left, tb, false); - } + + /* + * If the next tb has more instructions than we have left to + * execute we need to ensure we find/generate a TB with exactly + * insns_left instructions in it. + */ + if (!cpu->icount_extra && insns_left > 0 && insns_left < tb->icount) { + g_assert(insns_left < CF_COUNT_MASK); + cpu->cflags_next_tb = (tb->cflags & ~CF_COUNT_MASK) | insns_left; } #endif } From patchwork Tue Feb 9 18:27:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 379377 Delivered-To: patch@linaro.org Received: by 2002:a02:b18a:0:0:0:0:0 with SMTP id t10csp488845jah; Tue, 9 Feb 2021 10:35:39 -0800 (PST) X-Google-Smtp-Source: ABdhPJyKdwg8jCT7vefPtbOUe8qaJJpGEp8uVWeHw6nLZl5QClcEBYqe85/cpVxj8+pcPz8zqX/M X-Received: by 2002:a25:1182:: with SMTP id 124mr32454610ybr.154.1612895739740; Tue, 09 Feb 2021 10:35:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612895739; cv=none; d=google.com; s=arc-20160816; b=XL/RzvdFepFBZCG3G7sd4iLjc8aUv7BBHbIZ5ghh/8wz604xasZooXWEm13sb7UjX3 F/Pz1NZ5/hVI+Uw7ALyvvNBZ6lnT7o4+/huj3Jrdj64XGVLAOFAhEygXIHEprIuWfvBC SAmouz8XZc0jX8ZqSqdpR0fbRU69lstFm0Psn6Ke9qcJHBGDP1VIRpimF5peVJIsmrx3 WD7P9hd4jWKVx7fw0o2forDcZQgO0Ydbe9Slq3/zhEad0X6eDQmd8bfQ29zAMWPWAKAH kIEiWzfcWts7DSdOc+s7KdAg+TShmhkfOOahLRSoBQ3He2f00t1gMCp7xlrIEUlJNSUh 77tg== 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=egNb1Ho5wTfDlHsUr/B5unXhMEO0vBcjIkXluBAwDPY=; b=AKKy/6VkcC4JPZS681I7zaXSM80pkmcNyifGpw8CgmlNmucJGmppkmcui9Suq9VLH2 GKr3amKyA9Q/UP/q/8VAekOq0dGjbRCyTVGZ3+b5Nq1M8GHJ8RnoJC2pa3uL3Y1RoJvG TwWHr1K95GGiPplBDn2Z3Hn0pdfGvfWpfU4urUMQ3xeLq5ZHpXNEybdobDhyOcaOG+FB ZHyYxzSAQN/7innGMkOGXFjA8iOpfS6y5M/UY5lu+C3aIFKnRDQ+AObruChOya8C9CX2 iup0kLbpxCC0UNonsN+680mzGdQpCOpljf3WH4FjFpisVDrCxjfb2J1cIA4rkLYnCHgk SJkQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="w1hOVB/s"; 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 f7si20088872ybb.37.2021.02.09.10.35.39 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 09 Feb 2021 10:35:39 -0800 (PST) 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="w1hOVB/s"; 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]:50332 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l9XrP-0003Ys-6w for patch@linaro.org; Tue, 09 Feb 2021 13:35:39 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:43416) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l9Xk9-0003Fr-Jw for qemu-devel@nongnu.org; Tue, 09 Feb 2021 13:28:09 -0500 Received: from mail-wr1-x42f.google.com ([2a00:1450:4864:20::42f]:36397) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1l9Xk7-0007rl-V4 for qemu-devel@nongnu.org; Tue, 09 Feb 2021 13:28:09 -0500 Received: by mail-wr1-x42f.google.com with SMTP id u14so23265242wri.3 for ; Tue, 09 Feb 2021 10:28:07 -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=egNb1Ho5wTfDlHsUr/B5unXhMEO0vBcjIkXluBAwDPY=; b=w1hOVB/s/vDvQ76fvHe3Mbf/VoMG5VTufjOolPoykVN/I/8fu2zKzbEqVzBWCO5YjW wbX8vJA4A8C2ZPHYMTLrJUPXPGU81lyMFheNtKpxE63CpuT1CerKpcTTzLPLZ4twQDu0 HuA9aCDnIPKPCL4FeQDrXyx/wYMRv9knzVlnuZOj9GcDtogELMaTc9HqgkbwGJrQ3+li uHx88iSWtvpJ0n5n7hB3O8VO6QqDO5Uf26LerIwEPbSGxVsG4bY0V83CC4YcyL+6S4oO HCJyalwACJO8LkqrMsZfETvH4AsAqeAnzB7iaL7Yt6HU8HF65WO9ukNXtSuininpFklx 4ADA== 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=egNb1Ho5wTfDlHsUr/B5unXhMEO0vBcjIkXluBAwDPY=; b=f6fnXHjmJPdA8Q4vwuPIeUC20TY4/dl+dkUYC5aVDq+/zQpw4knKkG0KEQQqruhDkz Icrku3Qv932RxVUtPQMWq8uWmQn8eGTumXDBOO283HspW3EvOTK53ragjNptt9HDpevB fkM9K/EUYD80mMsEpqecoau5gJUI5x7EFilO6tgO/GGC2RvHlQlyv2EKyia2VJubv4ea vZGWUU3KT1so3HbLrjxFoLJ3cXdSK3ix4F7rQSu+nU4BGcijc17c06G0+eMZmn+ZJu17 /zhTwKeYm4SERyD262STh0ewtbiuq/APrkpntAIHKfEM49pD3JwxwJi4fqfzzy7IpmVX TPjQ== X-Gm-Message-State: AOAM531POtLl00oXMZMP+KzjHka6bYeXGjuPiEUdazUopaZGtFQzsAY3 HM3oaoUIXxbxla/ueeTw9KC0Xw== X-Received: by 2002:adf:a1d6:: with SMTP id v22mr18444568wrv.372.1612895286553; Tue, 09 Feb 2021 10:28:06 -0800 (PST) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id b13sm16305808wrs.35.2021.02.09.10.27.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Feb 2021 10:27:57 -0800 (PST) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 2170B1FF7E; Tue, 9 Feb 2021 18:27:51 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v1 08/12] accel/tcg: cache single instruction TB on pending replay exception Date: Tue, 9 Feb 2021 18:27:44 +0000 Message-Id: <20210209182749.31323-9-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210209182749.31323-1-alex.bennee@linaro.org> References: <20210209182749.31323-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42f; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x42f.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: Richard Henderson , robhenry@microsoft.com, aaron@os.amperecomputing.com, cota@braap.org, Paolo Bonzini , kuhn.chenqun@huawei.com, =?utf-8?q?Alex_Benn?= =?utf-8?b?w6ll?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Again there is no reason to jump through the nocache hoops to execute a single instruction block. We do have to add an additional wrinkle to the cpu_handle_interrupt case to ensure we let through a TB where we have specifically disabled icount for the block. As the last user of cpu_exec_nocache we can now remove the function. Further clean-up will follow in subsequent patches. Signed-off-by: Alex Bennée --- accel/tcg/cpu-exec.c | 44 ++++---------------------------------------- 1 file changed, 4 insertions(+), 40 deletions(-) -- 2.20.1 diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c index 7f477af891..609a68a3ae 100644 --- a/accel/tcg/cpu-exec.c +++ b/accel/tcg/cpu-exec.c @@ -224,40 +224,6 @@ cpu_tb_exec(CPUState *cpu, TranslationBlock *itb, int *tb_exit) return last_tb; } -#ifndef CONFIG_USER_ONLY -/* Execute the code without caching the generated code. An interpreter - could be used if available. */ -static void cpu_exec_nocache(CPUState *cpu, int max_cycles, - TranslationBlock *orig_tb, bool ignore_icount) -{ - TranslationBlock *tb; - uint32_t cflags = curr_cflags() | CF_NOCACHE; - int tb_exit; - - if (ignore_icount) { - cflags &= ~CF_USE_ICOUNT; - } - - /* Should never happen. - We only end up here when an existing TB is too long. */ - cflags |= MIN(max_cycles, CF_COUNT_MASK); - - mmap_lock(); - tb = tb_gen_code(cpu, orig_tb->pc, orig_tb->cs_base, - orig_tb->flags, cflags); - tb->orig_tb = orig_tb; - mmap_unlock(); - - /* execute the generated code */ - trace_exec_tb_nocache(tb, tb->pc); - cpu_tb_exec(cpu, tb, &tb_exit); - - mmap_lock(); - tb_phys_invalidate(tb, -1); - mmap_unlock(); - tcg_tb_remove(tb); -} -#endif static void cpu_exec_enter(CPUState *cpu) { @@ -524,15 +490,12 @@ static inline bool cpu_handle_exception(CPUState *cpu, int *ret) #ifndef CONFIG_USER_ONLY if (replay_has_exception() && cpu_neg(cpu)->icount_decr.u16.low + cpu->icount_extra == 0) { - /* try to cause an exception pending in the log */ - cpu_exec_nocache(cpu, 1, tb_find(cpu, NULL, 0, curr_cflags()), true); + /* Execute just one insn to trigger exception pending in the log */ + cpu->cflags_next_tb = (curr_cflags() & ~CF_USE_ICOUNT) | 1; } #endif - if (cpu->exception_index < 0) { - return false; - } + return false; } - if (cpu->exception_index >= EXCP_INTERRUPT) { /* exit request from the cpu execution loop */ *ret = cpu->exception_index; @@ -688,6 +651,7 @@ static inline bool cpu_handle_interrupt(CPUState *cpu, /* Finally, check if we need to exit to the main loop. */ if (unlikely(qatomic_read(&cpu->exit_request)) || (icount_enabled() + && (cpu->cflags_next_tb == -1 || cpu->cflags_next_tb & CF_USE_ICOUNT) && cpu_neg(cpu)->icount_decr.u16.low + cpu->icount_extra == 0)) { qatomic_set(&cpu->exit_request, 0); if (cpu->exception_index == -1) { From patchwork Tue Feb 9 18:27:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 379366 Delivered-To: patch@linaro.org Received: by 2002:a02:b18a:0:0:0:0:0 with SMTP id t10csp483169jah; Tue, 9 Feb 2021 10:28:16 -0800 (PST) X-Google-Smtp-Source: ABdhPJxHuvv3dURcwWfTWICJddo3WkM8YSc53jt7GIEwP4evB0cxwZWlCTrG0gMDkitAqlHxewhW X-Received: by 2002:a25:f804:: with SMTP id u4mr3405333ybd.427.1612895296804; Tue, 09 Feb 2021 10:28:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612895296; cv=none; d=google.com; s=arc-20160816; b=jds1TQgtXp9BaM39ajn0DGEP54fwAdNWAuQ+wJeRD5PafpZ41MPsAc7kRRofmTx2eK jsY7mePlmEh77Qfh4nbVyngMWNZ9ZBY/XJw3b1n3XLGqrfGs/vIfNv9lfYBwUI+ETCSy 5LyNtj8ck4Vvf3E2ud5jtplgrHjuSUfT695riiUtbFjkGos91wd7PsxnVwpxKpb/Dz9S 162ivoXJF3PoigqgcdFUpmp5DDvzdihOG4e+ooyr04/tfCbECVCbBU0PFPlHWp64Xr6g L3g1T0OT9D0EiJHycS+wJsDxxHhd8BUc++aWspvcYkRUZUcg7GUhh418JNRIS5qaITQ0 kxJw== 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=SJ+CxGQUMbX25NLlEOpaUwde946vo4PY/BH+Jix+NZA=; b=JGfRg9tttTKlYcGGA7j5e+8JbXkxKa3e0D8n8lnORNvRhOk0lFLiBkWfuVlBwASVLx 3+SzoGeGoadh1O1CKaLCLcthAFpD458lnqcEbuhTKwnnv2dhyC1IlK8ofjbU59Rk66bM fZkv1595Fn0ZjWjBgbh6PoNn0fhEdBgr8UhMSNx9gCkUK/NZ62hfB7X8MvGmcrBSltC6 19bQwebpzuSo8NMjAcG42uCz6jU7GLq5GuywgttfkDAdwYsiR7LTQxWiCfE+Q/sTJIIS zfCJQ6pbfaQpZrxZmk9itKGcok1QRPVsMqzhlhSVHhyBdqCdRe2rcrr6ov/P2tHmIik1 lj9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=igdrfzzy; 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 j127si20819234ybj.140.2021.02.09.10.28.16 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 09 Feb 2021 10:28:16 -0800 (PST) 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=igdrfzzy; 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]:58164 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l9XkG-00033o-9P for patch@linaro.org; Tue, 09 Feb 2021 13:28:16 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:43328) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l9Xk3-0002zF-Cy for qemu-devel@nongnu.org; Tue, 09 Feb 2021 13:28:03 -0500 Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]:56270) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1l9Xk1-0007pj-QR for qemu-devel@nongnu.org; Tue, 09 Feb 2021 13:28:03 -0500 Received: by mail-wm1-x32c.google.com with SMTP id f16so4146092wmq.5 for ; Tue, 09 Feb 2021 10:28:01 -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=SJ+CxGQUMbX25NLlEOpaUwde946vo4PY/BH+Jix+NZA=; b=igdrfzzyPKB/xTgeqROmTYO/dqzrtm+VcHLHBpoiogjflHT8kfTC6fhnjjsZ1WChsN rfY//jscd/f7ox7U6TyResYLdYyqYe429CEXbFnwG8vDegxfoYIixdu3TVH2lui6rD4l 4CQC9u3IGqqepiXEZQY9bMF0Rpm3cLAW1sU2cgkIOVWviwsnohnrDFw5TMAG4KvqMkZQ dD8FvvqIUdifgjP2+njzEjCzVmBZIS0M+rcB8sG3lYL8J5gIeQAe/n5zxn0EB7EWDcGU v41+WW/Cbf3W7Ljb7/l3fIA01gj7YQOfE6UciwuzWepAemGrPavYpALcG3BCq0k8Xc0V rvzg== 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=SJ+CxGQUMbX25NLlEOpaUwde946vo4PY/BH+Jix+NZA=; b=cGJPVMcFlIdMr8oQD0vDKfX6DHAPe/gYpvGg+8AaiLLzxQ/rRBqjB7hYBvPcGupTBM nk7TQTPq0Kh8SusCqb9TbPvbiGHop+HhTGQRVfJ+zKorPq3o3bU16Tzf6k9fF/0YgQrd EsC6SrZltfSoDE2ASccgUowr1BWe0s5C0nFb5DUEkafKK4T8fqPEyLynGczYvIJ50HUd 5epuMcJEjwpU6sedfvi5dlady4RD4LgY6GF3G5wiopGaFup2T53oucwZ1anreybgo6Ga ntEmxgVg4DiHJBm7Y2KR+erjFaKbcYo2a1SWUsqHF3T6pUk/tphd72SZHqTd6bE9mf7F zaMg== X-Gm-Message-State: AOAM530i5SDFZUOo9vU41WmdzR+Br3XtLWZEEB1ktlsxQixvQaMmpVdS D8VrZa3XxGUgPTJCGk6DNcbXY/EJf8PxVq9n X-Received: by 2002:a7b:ce8c:: with SMTP id q12mr4606297wmj.127.1612895280527; Tue, 09 Feb 2021 10:28:00 -0800 (PST) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id z15sm5296124wmi.38.2021.02.09.10.27.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Feb 2021 10:27:57 -0800 (PST) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 585B21FF96; Tue, 9 Feb 2021 18:27:51 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v1 09/12] accel/tcg: re-factor non-RAM execution code Date: Tue, 9 Feb 2021 18:27:45 +0000 Message-Id: <20210209182749.31323-10-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210209182749.31323-1-alex.bennee@linaro.org> References: <20210209182749.31323-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32c; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x32c.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: Richard Henderson , robhenry@microsoft.com, aaron@os.amperecomputing.com, cota@braap.org, Paolo Bonzini , kuhn.chenqun@huawei.com, =?utf-8?q?Alex_Benn?= =?utf-8?b?w6ll?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" There is no real need to use CF_NOCACHE here. As long as the TB isn't linked to other TBs or included in the QHT or jump cache then it will only get executed once. Signed-off-by: Alex Bennée --- accel/tcg/translate-all.c | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) -- 2.20.1 diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index b8ad95aa1b..b2c5003829 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -1778,7 +1778,7 @@ static inline void tb_page_add(PageDesc *p, TranslationBlock *tb, #endif } -/* add a new TB and link it to the physical page tables. phys_page2 is +/* Add a new TB and link it to the physical page tables. phys_page2 is * (-1) to indicate that only one page contains the TB. * * Called with mmap_lock held for user-mode emulation. @@ -1797,17 +1797,6 @@ tb_link_page(TranslationBlock *tb, tb_page_addr_t phys_pc, assert_memory_lock(); - if (phys_pc == -1) { - /* - * If the TB is not associated with a physical RAM page then - * it must be a temporary one-insn TB, and we have nothing to do - * except fill in the page_addr[] fields. - */ - assert(tb->cflags & CF_NOCACHE); - tb->page_addr[0] = tb->page_addr[1] = -1; - return tb; - } - /* * Add the TB to the page list, acquiring first the pages's locks. * We keep the locks held until after inserting the TB in the hash table, @@ -1880,9 +1869,8 @@ TranslationBlock *tb_gen_code(CPUState *cpu, phys_pc = get_page_addr_code(env, pc); if (phys_pc == -1) { - /* Generate a temporary TB with 1 insn in it */ - cflags &= ~CF_COUNT_MASK; - cflags |= CF_NOCACHE | 1; + /* Generate a one-shot TB with 1 insn in it */ + cflags = (cflags & ~CF_COUNT_MASK) | 1; } cflags &= ~CF_CLUSTER_MASK; @@ -2096,6 +2084,17 @@ TranslationBlock *tb_gen_code(CPUState *cpu, tb_reset_jump(tb, 1); } + /* + * If the TB is not associated with a physical RAM page then + * it must be a temporary one-insn TB, and we have nothing to do + * except fill in the page_addr[] fields. Return early before + * attempting to link to other TBs or add to the lookup table. + */ + if (phys_pc == -1) { + tb->page_addr[0] = tb->page_addr[1] = -1; + return tb; + } + /* check next page if needed */ virt_page2 = (pc + tb->size - 1) & TARGET_PAGE_MASK; phys_page2 = -1; From patchwork Tue Feb 9 18:27:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 379381 Delivered-To: patch@linaro.org Received: by 2002:a02:b18a:0:0:0:0:0 with SMTP id t10csp497759jah; Tue, 9 Feb 2021 10:47:24 -0800 (PST) X-Google-Smtp-Source: ABdhPJwVRAFJPvev9PXmcOzapL28HJ+L1I8bKIGkLyhA95Tb3LNMBCTIDC17dxIdxAyAHhVhsGsr X-Received: by 2002:a25:c407:: with SMTP id u7mr34178677ybf.449.1612896444736; Tue, 09 Feb 2021 10:47:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612896444; cv=none; d=google.com; s=arc-20160816; b=T4PJ4VoDFLAkUG9EnRHIqdQM/7nuT8k32ggbtjxgD8QstQFv9vkkE9gIIkTT89S7LQ 0qsGEVbH4CEXmIuDzq0ceuQKZWEf5yhNSyb8pOatKcxy0PjNo8XSiPa4J+tP8tdtwg5s IRp4KHw7g8pGD9YQ6VZk1cFznevyLpxA6NUSUQrQJXxbTUj6lfmEabBybwLgpD1RnQtQ Aj2DD0GM8U2Kk3T+o5p09U22bFFPvpH38jGLS8KeXAlAbJ4OxIy8plKalzqt5HmRD/Jv HLbF85n3E+nUzobp7pgpTNqywqaUpZ9EvA4lm8ERkfi6zJpQ8a150hTrwqk3BCUlhDpy Gsqw== 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=xVvEwjwvlErjN28dnMMVJVw5XumleZ7dCVSrng6Ywq8=; b=wspQ7NBAzFaIonxAxdlgdnQbTg/jJAqZRh2gWo0MwNGCiSJxQX/I/+s4vIySNFB6XB 4f1/CbK2D6m0s2E9EZpJ4R6bApG7/7cNf2zfD9gvCPYdeaEFNfcGRcPyQ6WNuZoaz16Q 17pRk5Ya4iyMxfW/gD66aIvs+XCX6jvSnCg/Y0vyrboecuyjzIAPsWqIq+yT9bQgNt8s RqjJiOuPQWsQ8QgpoFh4qz+0m8IDOp4PYA/zdStZ/J3dCmN4yVCwWGZwRq8l2Gr0B/3j u3g7EAbIHgG6k3pSLOe7Lsiya/P1f4aJHtjyyfQ7XpMnS3Isw3ACcllBy1y7rnreZf2b UonA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=PPp2xEU9; 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 x13si23305552ybk.73.2021.02.09.10.47.24 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 09 Feb 2021 10:47:24 -0800 (PST) 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=PPp2xEU9; 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]:42536 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l9Y2m-0005OP-7A for patch@linaro.org; Tue, 09 Feb 2021 13:47:24 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:44568) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l9Xqn-00038m-0K for qemu-devel@nongnu.org; Tue, 09 Feb 2021 13:35:01 -0500 Received: from mail-wr1-x42f.google.com ([2a00:1450:4864:20::42f]:35137) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1l9Xql-0001ER-6Q for qemu-devel@nongnu.org; Tue, 09 Feb 2021 13:35:00 -0500 Received: by mail-wr1-x42f.google.com with SMTP id l12so23294751wry.2 for ; Tue, 09 Feb 2021 10:34:58 -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=xVvEwjwvlErjN28dnMMVJVw5XumleZ7dCVSrng6Ywq8=; b=PPp2xEU9+YPpv2HrLD/8RbqBTRYCOVzwMeAg92gyM0lToejtaFimggEhmpBdfskNkL 11A4rFzbBYybDl20HLS1ZmjPVPRVJsT0IHnNI2G1T4womuAgdjtTLKq2VDEj7BZ96noy IGbPOOCxVzoR1I7n49n1ojyqBP4GSvmeFCxRN4cd71w2MSyAvf0KMFRnicqLQDHKpSFz mj98iCdRQr+7HUtDmyCNBYxwkBEPABHOeBDW4ap2K7qFZq0r+p6TAvRPcQ4B9BS+jMyn 6Brh57+y96ETryAnQc7yCCg6n1n39zcmPqMyoRyrIbwLEZ0vYDRWG/5nEiNh4IZyrwiQ tMAw== 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=xVvEwjwvlErjN28dnMMVJVw5XumleZ7dCVSrng6Ywq8=; b=ugbTMZUCRSTuhbT2xLCjRgCbZco8pt6q7Lxn1rSn0loIt8Zvz1qxKabZhxCB9HEoXG i+GGR7Xoog12zkvUU4pNklAt8JcyJyomTBa5ceo1KtsHuCW3pe56exgPUnQ6SaTqSX3V 85NNxByyf6Yot7WKNgpTysBed/eyV6x5X9aa+6HeCbukA4/L1aGDK2JVfPm7M/UcSE+y FM17KaqRPYZa+I/E4gA88XdFCIlJjdmL7MbpkQEzM4lHyeCXnVLOU7i7whCzyF/nv0tb SzZcofYyd1IIS0GNBl1i2ThsY8pfUcRP20iAwwBvv/wBhjM0prFD2RN+66OOStJ0iyBH eL5w== X-Gm-Message-State: AOAM530uJQ5SP93F9GDgrs0JsXZ7OyyQWchBvVZKcuZYBQiojuY0eX5u H0kbbPgBwyr51if5DJm0hN8Vug== X-Received: by 2002:a5d:6883:: with SMTP id h3mr3630486wru.90.1612895697799; Tue, 09 Feb 2021 10:34:57 -0800 (PST) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id c9sm6153728wmb.33.2021.02.09.10.34.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Feb 2021 10:34:56 -0800 (PST) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 9922B1FF98; Tue, 9 Feb 2021 18:27:51 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v1 10/12] accel/tcg: remove CF_NOCACHE and special cases Date: Tue, 9 Feb 2021 18:27:46 +0000 Message-Id: <20210209182749.31323-11-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210209182749.31323-1-alex.bennee@linaro.org> References: <20210209182749.31323-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42f; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x42f.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: Richard Henderson , robhenry@microsoft.com, aaron@os.amperecomputing.com, cota@braap.org, Paolo Bonzini , kuhn.chenqun@huawei.com, =?utf-8?q?Alex_Benn?= =?utf-8?b?w6ll?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Now we no longer generate CF_NOCACHE blocks we can remove a bunch of the special case handling for them. While we are at it we can remove the unused tb->orig_tb field and save a few bytes on the TB structure. Signed-off-by: Alex Bennée --- include/exec/exec-all.h | 3 --- accel/tcg/translate-all.c | 51 ++++++++++++--------------------------- 2 files changed, 15 insertions(+), 39 deletions(-) -- 2.20.1 Reviewed-by: Richard Henderson diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h index f933c74c44..e08179de34 100644 --- a/include/exec/exec-all.h +++ b/include/exec/exec-all.h @@ -454,7 +454,6 @@ struct TranslationBlock { uint32_t cflags; /* compile flags */ #define CF_COUNT_MASK 0x00007fff #define CF_LAST_IO 0x00008000 /* Last insn may be an IO access. */ -#define CF_NOCACHE 0x00010000 /* To be freed after execution */ #define CF_USE_ICOUNT 0x00020000 #define CF_INVALID 0x00040000 /* TB is stale. Set with @jmp_lock held */ #define CF_PARALLEL 0x00080000 /* Generate code for a parallel context */ @@ -469,8 +468,6 @@ struct TranslationBlock { struct tb_tc tc; - /* original tb when cflags has CF_NOCACHE */ - struct TranslationBlock *orig_tb; /* first and second physical page containing code. The lower bit of the pointer tells the index in page_next[]. The list is protected by the TB's page('s) lock(s) */ diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index b2c5003829..27b3042f1d 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -409,12 +409,6 @@ bool cpu_restore_state(CPUState *cpu, uintptr_t host_pc, bool will_exit) TranslationBlock *tb = tcg_tb_lookup(host_pc); if (tb) { cpu_restore_state_from_tb(cpu, tb, host_pc, will_exit); - if (tb_cflags(tb) & CF_NOCACHE) { - /* one-shot translation, invalidate it immediately */ - tb_phys_invalidate(tb, -1); - tcg_tb_remove(tb); - tb_destroy(tb); - } return true; } } @@ -1633,8 +1627,7 @@ static void do_tb_phys_invalidate(TranslationBlock *tb, bool rm_from_page_list) phys_pc = tb->page_addr[0] + (tb->pc & ~TARGET_PAGE_MASK); h = tb_hash_func(phys_pc, tb->pc, tb->flags, tb_cflags(tb) & CF_HASH_MASK, tb->trace_vcpu_dstate); - if (!(tb->cflags & CF_NOCACHE) && - !qht_remove(&tb_ctx.htable, tb, h)) { + if (!qht_remove(&tb_ctx.htable, tb, h)) { return; } @@ -1794,6 +1787,8 @@ tb_link_page(TranslationBlock *tb, tb_page_addr_t phys_pc, { PageDesc *p; PageDesc *p2 = NULL; + void *existing_tb = NULL; + uint32_t h; assert_memory_lock(); @@ -1813,25 +1808,20 @@ tb_link_page(TranslationBlock *tb, tb_page_addr_t phys_pc, tb->page_addr[1] = -1; } - if (!(tb->cflags & CF_NOCACHE)) { - void *existing_tb = NULL; - uint32_t h; - - /* add in the hash table */ - h = tb_hash_func(phys_pc, tb->pc, tb->flags, tb->cflags & CF_HASH_MASK, - tb->trace_vcpu_dstate); - qht_insert(&tb_ctx.htable, tb, h, &existing_tb); + /* add in the hash table */ + h = tb_hash_func(phys_pc, tb->pc, tb->flags, tb->cflags & CF_HASH_MASK, + tb->trace_vcpu_dstate); + qht_insert(&tb_ctx.htable, tb, h, &existing_tb); - /* remove TB from the page(s) if we couldn't insert it */ - if (unlikely(existing_tb)) { - tb_page_remove(p, tb); - invalidate_page_bitmap(p); - if (p2) { - tb_page_remove(p2, tb); - invalidate_page_bitmap(p2); - } - tb = existing_tb; + /* remove TB from the page(s) if we couldn't insert it */ + if (unlikely(existing_tb)) { + tb_page_remove(p, tb); + invalidate_page_bitmap(p); + if (p2) { + tb_page_remove(p2, tb); + invalidate_page_bitmap(p2); } + tb = existing_tb; } if (p2 && p2 != p) { @@ -1904,7 +1894,6 @@ TranslationBlock *tb_gen_code(CPUState *cpu, tb->cs_base = cs_base; tb->flags = flags; tb->cflags = cflags; - tb->orig_tb = NULL; tb->trace_vcpu_dstate = *cpu->trace_dstate; tcg_ctx->tb_cflags = cflags; tb_overflow: @@ -2443,16 +2432,6 @@ void cpu_io_recompile(CPUState *cpu, uintptr_t retaddr) /* Generate a new TB executing the I/O insn. */ cpu->cflags_next_tb = curr_cflags() | CF_LAST_IO | n; - if (tb_cflags(tb) & CF_NOCACHE) { - if (tb->orig_tb) { - /* Invalidate original TB if this TB was generated in - * cpu_exec_nocache() */ - tb_phys_invalidate(tb->orig_tb, -1); - } - tcg_tb_remove(tb); - tb_destroy(tb); - } - qemu_log_mask_and_addr(CPU_LOG_EXEC, tb->pc, "cpu_io_recompile: rewound execution of TB to " TARGET_FMT_lx "\n", tb->pc); From patchwork Tue Feb 9 18:27:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 379370 Delivered-To: patch@linaro.org Received: by 2002:a02:b18a:0:0:0:0:0 with SMTP id t10csp485434jah; Tue, 9 Feb 2021 10:31:23 -0800 (PST) X-Google-Smtp-Source: ABdhPJwx+1H0pB2nHWfWsvYbaWNhwafuv/xNxeNdlpP+jk4KvfUPm0K8zQJhR0/BFx+nkLIuYSFC X-Received: by 2002:a25:81c7:: with SMTP id n7mr34166105ybm.171.1612895483464; Tue, 09 Feb 2021 10:31:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612895483; cv=none; d=google.com; s=arc-20160816; b=LQHnzpEKuyl0gUm2xwwcGFPfn+q89Yb2KtOlPxDwO2c1yW3FeF01PCQiXFkuX1AuOR GwmM4fT2b0JbjIDnByUk+51ZH1/McKftUJ9khZxzQ8eAs2WPUBEpjZSTPQAPnphF2BOR 2nBfSMyPU6YezfX7t5vnhbpy+9MOTTY0XSGVPdxf8hH8sdFZG3H7908d/C+Zy8nTFojx 7MvjHocaCP3Re0CjWAuSz/T+7MqEZO4u/rGis6z1chrJDUZ8Rx3UoQNyneUvsW+5d2ER bdHM9lgVRrTE2vGKquMadXoAW/81TSbUYHuTgYjSpocMBjHKlz8JzIU6bIcDZI0tIlbh xkmQ== 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=ejLSBmEQiH4mLxCrVBrlwMdu2X7JBwiJC91YTaurGZo=; b=RnCsI8IgVT9/cHGg1nBN4KjX71YKX0oaaffKDEUNTkIj+430iyjp4tS4JdJ5z8+bdP ybqe3VVvWjcRYavRutcEYP6Yt6EfOZBtFUMe+Fd/sAv2qIxG7kIweriAfMMi612319Rk 4Gv6wFe4j58JqFbO/yVXHiK9tmKYhjP2b/aEEp+82tXrqz+JDQ1bJduaaYaXj0MiRBAI oLmK/UrMJGhUY/aVrqA1CPgf00NBh/cHnxNOpMShthKQzWRv2RKC7jVNBMUzKMfuOfFF cAa4lP3Wk2XvXAxPNBvKr8rt/Ccxkb1SHTq2OR0K7677zImfPhtFfBsV0Ckn3mDcSRPu B9nw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=v4Xmtq1g; 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 x3si21871540ybn.333.2021.02.09.10.31.23 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 09 Feb 2021 10:31:23 -0800 (PST) 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=v4Xmtq1g; 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]:38690 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l9XnG-0006np-UT for patch@linaro.org; Tue, 09 Feb 2021 13:31:22 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:43384) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l9Xk6-00038l-Vl for qemu-devel@nongnu.org; Tue, 09 Feb 2021 13:28:07 -0500 Received: from mail-wr1-x431.google.com ([2a00:1450:4864:20::431]:39818) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1l9Xk4-0007qk-MM for qemu-devel@nongnu.org; Tue, 09 Feb 2021 13:28:06 -0500 Received: by mail-wr1-x431.google.com with SMTP id h12so6941456wrw.6 for ; Tue, 09 Feb 2021 10:28:04 -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=ejLSBmEQiH4mLxCrVBrlwMdu2X7JBwiJC91YTaurGZo=; b=v4Xmtq1gJdLVt3rca/xSQKRIVOBb3Y3fQ2RPC5hYgNysb+D7mDKuL5cbb8EHSSHwC6 i8L4E/XO7bD8NHpCVwg1I91wukMQItLHncmQ1je4LfmVfnP4ajENSenjBvkglcGQrGyS L9h1WUXgaoI9tSHHnNEp2DbKu75C3YK9Nnx+aFzyXD4N9mcn6OkLjD4O+NLbFMUCMaMI 3We6TVc/KDr0K/mZn9LecgsyqCMswqShvT5G3Sc2aES16qItEkjCh17wssHX/RxVB5Wc OGmI6yfxKjp1cc5/abLt8o/BMJjbB4xG5czwWoUlV4QImiHJdYi+LZVErrC1bqB1wExq ZO3Q== 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=ejLSBmEQiH4mLxCrVBrlwMdu2X7JBwiJC91YTaurGZo=; b=UaNZy0F1EzBeni0mPk9h1F923CFmIuPk+AHyWyxnjeiZbzcZg5Gzr06KvvUZX3cLyM ejKisHVAHDt6v0zdE9LGUS9OytB+JAmIhX5xgJHD4pveRNDN+kFgTJ/s+txTZAusbMRc qRQFs3IeYDi0KXI8HRSjkEMo8IvlN3d5ZdnP+Q6fPqpAZkBpSC/7qrInn3XO1SkwUEVg Rz3FPlX3YETHzTt/81W7msHMh3Sw5b0KavFzkiwgmiYwFDmE9h3qkdgqmukUn6yiXtqc B0uE03isHzJ/dHyoiRm5EkEH+7yaujqOIGX4XPhhxvemWfugaMjnISq4IgPhw9BMS4qy SD6w== X-Gm-Message-State: AOAM533Pwt0fcd00FVKlos6lSqi9a/7SjIXV5m7ffD+3oeVWAb96P4z+ 5+T0Z1NnRpA8AHc7m50Urd0ZPQ== X-Received: by 2002:adf:f68e:: with SMTP id v14mr26750428wrp.273.1612895283368; Tue, 09 Feb 2021 10:28:03 -0800 (PST) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id c22sm180528wrb.91.2021.02.09.10.27.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Feb 2021 10:27:57 -0800 (PST) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id D236A1FF99; Tue, 9 Feb 2021 18:27:51 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v1 11/12] accel/tcg: allow plugin instrumentation to be disable via cflags Date: Tue, 9 Feb 2021 18:27:47 +0000 Message-Id: <20210209182749.31323-12-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210209182749.31323-1-alex.bennee@linaro.org> References: <20210209182749.31323-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::431; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x431.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: Richard Henderson , robhenry@microsoft.com, aaron@os.amperecomputing.com, cota@braap.org, Paolo Bonzini , kuhn.chenqun@huawei.com, =?utf-8?q?Alex_Benn?= =?utf-8?b?w6ll?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" When icount is enabled and we recompile an MMIO access we end up double counting the instruction execution. To avoid this we introduce the CF_NOINSTR cflag which disables instrumentation for the next TB. As this is part of the hashed compile flags we will only execute the generated TB while coming out of a cpu_io_recompile. While we are at it delete the old TODO. We might as well keep the translation handy as it's likely you will repeatedly hit it on each MMIO access. Reported-by: Aaron Lindsay Signed-off-by: Alex Bennée --- include/exec/exec-all.h | 3 ++- accel/tcg/translate-all.c | 17 ++++++++--------- accel/tcg/translator.c | 2 +- 3 files changed, 11 insertions(+), 11 deletions(-) -- 2.20.1 Reviewed-by: Richard Henderson diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h index e08179de34..ebf015e22d 100644 --- a/include/exec/exec-all.h +++ b/include/exec/exec-all.h @@ -454,6 +454,7 @@ struct TranslationBlock { uint32_t cflags; /* compile flags */ #define CF_COUNT_MASK 0x00007fff #define CF_LAST_IO 0x00008000 /* Last insn may be an IO access. */ +#define CF_NOINSTR 0x00010000 /* Disable instrumentation of TB */ #define CF_USE_ICOUNT 0x00020000 #define CF_INVALID 0x00040000 /* TB is stale. Set with @jmp_lock held */ #define CF_PARALLEL 0x00080000 /* Generate code for a parallel context */ @@ -461,7 +462,7 @@ struct TranslationBlock { #define CF_CLUSTER_SHIFT 24 /* cflags' mask for hashing/comparison */ #define CF_HASH_MASK \ - (CF_COUNT_MASK | CF_LAST_IO | CF_USE_ICOUNT | CF_PARALLEL | CF_CLUSTER_MASK) + (CF_COUNT_MASK | CF_LAST_IO | CF_NOINSTR | CF_USE_ICOUNT | CF_PARALLEL | CF_CLUSTER_MASK) /* Per-vCPU dynamic tracing state used to generate this TB */ uint32_t trace_vcpu_dstate; diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index 27b3042f1d..3dee698457 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -2398,7 +2398,8 @@ void tb_check_watchpoint(CPUState *cpu, uintptr_t retaddr) } #ifndef CONFIG_USER_ONLY -/* in deterministic execution mode, instructions doing device I/Os +/* + * In deterministic execution mode, instructions doing device I/Os * must be at the end of the TB. * * Called by softmmu_template.h, with iothread mutex not held. @@ -2429,19 +2430,17 @@ void cpu_io_recompile(CPUState *cpu, uintptr_t retaddr) n = 2; } - /* Generate a new TB executing the I/O insn. */ - cpu->cflags_next_tb = curr_cflags() | CF_LAST_IO | n; + /* + * Exit the loop and potentially generate a new TB executing the + * just the I/O insns. We also disable instrumentation so we don't + * double count the instruction. + */ + cpu->cflags_next_tb = curr_cflags() | CF_NOINSTR | CF_LAST_IO | n; qemu_log_mask_and_addr(CPU_LOG_EXEC, tb->pc, "cpu_io_recompile: rewound execution of TB to " TARGET_FMT_lx "\n", tb->pc); - /* TODO: If env->pc != tb->pc (i.e. the faulting instruction was not - * the first in the TB) then we end up generating a whole new TB and - * repeating the fault, which is horribly inefficient. - * Better would be to execute just this insn uncached, or generate a - * second new TB. - */ cpu_loop_exit_noexc(cpu); } diff --git a/accel/tcg/translator.c b/accel/tcg/translator.c index a49a794065..14d1ea795d 100644 --- a/accel/tcg/translator.c +++ b/accel/tcg/translator.c @@ -58,7 +58,7 @@ void translator_loop(const TranslatorOps *ops, DisasContextBase *db, ops->tb_start(db, cpu); tcg_debug_assert(db->is_jmp == DISAS_NEXT); /* no early exit */ - plugin_enabled = plugin_gen_tb_start(cpu, tb); + plugin_enabled = !(tb_cflags(db->tb) & CF_NOINSTR) && plugin_gen_tb_start(cpu, tb); while (true) { db->num_insns++; From patchwork Tue Feb 9 18:27:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 379373 Delivered-To: patch@linaro.org Received: by 2002:a02:b18a:0:0:0:0:0 with SMTP id t10csp486437jah; Tue, 9 Feb 2021 10:32:33 -0800 (PST) X-Google-Smtp-Source: ABdhPJzFch6gdhEBeQ3jgQdhGOsPoO6dz4lYCA5aE5+lXecrof0y5mI99nv6fW6TPl+LURduuASs X-Received: by 2002:a25:33d5:: with SMTP id z204mr34604809ybz.78.1612895553808; Tue, 09 Feb 2021 10:32:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612895553; cv=none; d=google.com; s=arc-20160816; b=D7Cg2nQG2kRcjHd7944Rgc/Lxl65g2NAUhxKRDQQn5k0E7JBBD/L9fjEow4V0iSqNi p6ljd530wvmnQuY3xm9ZOudxEZfUiN65WAVYBURbEkGj1yg2dD62d+jhCnlVL9kWOorq I2fUcdGBX7LPp/I9oozRPvobnKp17NgSkpBoMd5ii81ZlwtRfPIaYwp+RqTh1eLEDIfk 2fELQOzUCuIfXyFTDM3kA/Bg5mOmzaMYNMM7EO91/XhlQnnp7Tle2j9Bau0DEEKoq17X liCDFOz9vY1UPRGFyvCCnTYq6ZUHiKVPzruuPNdzRTB97Jo3yZHsOPDOXkp4/N6vgHQq fGPQ== 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=a7e1FwTBjDma5YBYDcW8fs7cDFozA2L932geu4P/T6s=; b=d7QTJPVw1wuXYDNla1/foDzN0b/LWVVqQebGgsQpmbW/mIfMGk36Fz4Pbl6i16wDuD 2vgsBSuUjRl0UccP/IDcFoEG1ZujYEDhIuv6OiYDZHar2CTgjK/nNSgLtyHaKPLTP17k DcI5p52BRFD/7XuAIWkQmJKyeM9U0KOCcSanhg3JlugnaRqVzZXmEuKgOwc+tVQuQTrl x1pOtqG2mANVGl9hM3RCOEm28SuMoYChxQFhyevFnSJv7C4rcAI45fijyUu4w24/zF4M gc9gwGldiPabBTvXbGN8Qf1jHbZ0cKrqWW4Tss16qy7I115B+EW+iH8ZRDM5d2dtZJ1r fD/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=tdVD6HkT; 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 66si23101227ybo.149.2021.02.09.10.32.33 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 09 Feb 2021 10:32:33 -0800 (PST) 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=tdVD6HkT; 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]:41716 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l9XoP-0008Em-Af for patch@linaro.org; Tue, 09 Feb 2021 13:32:33 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:43362) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l9Xk5-00033u-90 for qemu-devel@nongnu.org; Tue, 09 Feb 2021 13:28:05 -0500 Received: from mail-wr1-x42d.google.com ([2a00:1450:4864:20::42d]:41951) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1l9Xk3-0007pv-II for qemu-devel@nongnu.org; Tue, 09 Feb 2021 13:28:04 -0500 Received: by mail-wr1-x42d.google.com with SMTP id n6so10386851wrv.8 for ; Tue, 09 Feb 2021 10:28:03 -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=a7e1FwTBjDma5YBYDcW8fs7cDFozA2L932geu4P/T6s=; b=tdVD6HkTknlvSqlFhHboH6AzQ1hVbJTfi1C/deNM96ggpcc5O+cTB+W2mkN74vHBer twQIiUFfQwZqRT+/gHS2CbZWwj0wx+7EQijv0LhDIQY2SioYdWDPyPOtwhv6NBwVKf/G 5IwL+WdFegkAl8mygWiRkCgT0feLEqkNWhpHjTYBXZCo1EMjbRJYeUGf1qG1uQXiWoza CrugkjL9wmf4iK4BvIFKb2b4Lz6YSb3qcxNYAj4fnmFUOqFHHetZaPKRBen+Dwem6EWk oP5nhNwa6I/lA9HSzGAxqW24DWZNL0MZN4mfTchsv3kbP3BJM1h15FpoTi9hc6irRn4s sCeg== 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=a7e1FwTBjDma5YBYDcW8fs7cDFozA2L932geu4P/T6s=; b=LMrjKooDNPcVLMs6ITlGC1dDlQ6AWxBx3RX7c7NIygD/RLOEKusNJmj5elaa2IjOdD 8/w/mljhrERpugfHvN0xxgVl9KdU0e1LqIR1hLrnFEOwtLTEv/dj6jHXlH3hlec76qVc NUPHJuKa2/Aoy1xT2my4F6/aOayFj3eDgkVFlmaTpuMfBn5RLnUBMWg6SotnWxD6sXr/ rAzoynn5QV4sotnnvp/Busb7S9yO6Lu6MTL2iR+O3g+DfgcAkhNSMJM4JLngLw+8vJAV XDT4aXE49/u93jaoIlVxMU1CHqB9AD8rslPeKvUC5u1HkLN9iOr7kWHGWXeB8JRMEdG9 MjRQ== X-Gm-Message-State: AOAM530FBEVadO7qeIZuGDh1hKpvozOdn4hbakqccQrahuEd/JlhjTiF j/t/8RsdUNzsCaDkJghiC6WENA== X-Received: by 2002:a5d:6947:: with SMTP id r7mr26916368wrw.150.1612895282211; Tue, 09 Feb 2021 10:28:02 -0800 (PST) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id i8sm40854951wry.90.2021.02.09.10.27.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Feb 2021 10:27:57 -0800 (PST) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 0D9FE1FF9A; Tue, 9 Feb 2021 18:27:52 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v1 12/12] tests/acceptance: add a new tests to detect counting errors Date: Tue, 9 Feb 2021 18:27:48 +0000 Message-Id: <20210209182749.31323-13-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210209182749.31323-1-alex.bennee@linaro.org> References: <20210209182749.31323-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42d; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x42d.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: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , robhenry@microsoft.com, aaron@os.amperecomputing.com, cota@braap.org, Wainer dos Santos Moschetta , Cleber Rosa , kuhn.chenqun@huawei.com, =?utf-8?q?Alex_Benn?= =?utf-8?b?w6ll?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" The insn plugin has a simple heuristic to detect if an instruction is detected running twice in a row. Check the plugin log after the run and pass accordingly. Signed-off-by: Alex Bennée --- tests/acceptance/tcg_plugins.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) -- 2.20.1 diff --git a/tests/acceptance/tcg_plugins.py b/tests/acceptance/tcg_plugins.py index b512979769..acab599505 100644 --- a/tests/acceptance/tcg_plugins.py +++ b/tests/acceptance/tcg_plugins.py @@ -101,3 +101,34 @@ class PluginKernelNormal(PluginKernelBase): else: logger.debug("Failed to find instruction count") self.fail + + def test_aarch64_virt_insn_icount(self): + """ + :avocado: tags=accel:tcg + :avocado: tags=arch:aarch64 + :avocado: tags=machine:virt + :avocado: tags=cpu:cortex-a57 + """ + kernel_path = self._grab_aarch64_kernel() + kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE + + 'console=ttyAMA0') + console_pattern = 'Kernel panic - not syncing: VFS:' + + plugin_log = tempfile.NamedTemporaryFile(mode="r+t", prefix="plugin", + suffix=".log", delete=False) + + self.run_vm(kernel_path, kernel_command_line, + "tests/plugin/libinsn.so", plugin_log.name, + console_pattern, + args=('-cpu', 'cortex-a53', '-icount', 'shift=1')) + + logger = logging.getLogger() + + with plugin_log as lf, \ + mmap.mmap(lf.fileno(), 0, access=mmap.ACCESS_READ) as s: + m = re.search(br"detected repeat execution @ (?P0x[0-9A-Fa-f]+)", s) + if m is not None and "addr" in m.groupdict(): + logger.debug("detected repeat instructions") + self.fail("detected repeated instructions") + else: + logger.debug("no repeats detected: %s", m)