From nobody Mon Feb 9 05:10:51 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1612895570; cv=none; d=zohomail.com; s=zohoarc; b=B54y+L32Dy96bKhpwXrK5ex52ZhHFJtcfpp1AU+7ylHjl8ia20FI9fedOEy8QpDAHu1NQZiVdAD7jKi3LlkorMANnPsexefBTKlUH4RDIC26FlgtA30K2aWzPKP0QnVohjS8+0AXKzYW/2hes1DNMteEW5R7f6kokgWCeUcqUoU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1612895570; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=TPpkuVowT3XsKdUIr+oG7/FvD0rzuMPKtWzVkORBqZU=; b=aRl1Z3ZAE6laOWtx+GoKfeI5bBs+NqdADSVli8sWYrqa066KNUTHjdgb0WObd/NLh7SHoDM/iIXnRqu5xu6zMPppoUO/+8q4u1SCHZSdwdFOy1+8pyDVvJEFp5CpdqKRmc/lcONwfum8XVWXd+R7NaLhTKEQfZcOIJYBIuy6Giw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1612895569785323.2640415772572; Tue, 9 Feb 2021 10:32:49 -0800 (PST) Received: from localhost ([::1]:41478 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l9Xoe-000889-OU for importer@patchew.org; Tue, 09 Feb 2021 13:32:48 -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) 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) 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-Google-Smtp-Source: ABdhPJyKQjP4iYfGhdMmmaaa/NLv1sZLgRQ87hKWScONmeKXp8+zO4N/Vz5JKdvdLnARDARbypfXjw== X-Received: by 2002:a5d:54ce:: with SMTP id x14mr18133736wrv.182.1612895272952; Tue, 09 Feb 2021 10:27:52 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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=20Benn=C3=A9e?= , "Edgar E. Iglesias" , "open list:ARM TCG CPUs" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) 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=C3=A9e Signed-off-by: Alex Benn=C3=A9e --- include/exec/tb-context.h | 1 - include/hw/core/cpu.h | 4 +--- include/hw/core/tcg-cpu-ops.h | 3 +-- include/qemu/typedefs.h | 1 + target/arm/internals.h | 3 +-- target/cris/translate.c | 2 +- target/lm32/translate.c | 2 +- target/moxie/translate.c | 2 +- target/unicore32/translate.c | 2 +- 9 files changed, 8 insertions(+), 12 deletions(-) diff --git a/include/exec/tb-context.h b/include/exec/tb-context.h index ec4c13b455..cc33979113 100644 --- a/include/exec/tb-context.h +++ b/include/exec/tb-context.h @@ -26,7 +26,6 @@ #define CODE_GEN_HTABLE_BITS 15 #define CODE_GEN_HTABLE_SIZE (1 << CODE_GEN_HTABLE_BITS) =20 -typedef struct TranslationBlock TranslationBlock; typedef struct TBContext TBContext; =20 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 { =20 typedef struct CPUWatchpoint CPUWatchpoint; =20 -struct TranslationBlock; - /* see tcg-cpu-ops.h */ struct TCGCPUOps; =20 @@ -375,7 +373,7 @@ struct CPUState { IcountDecr *icount_decr_ptr; =20 /* 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]; =20 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); =20 #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 */ =20 =20 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 { =20 int delayed_branch; =20 - struct TranslationBlock *tb; + TranslationBlock *tb; int singlestep_enabled; } DisasContext; =20 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; =20 - struct TranslationBlock *tb; + TranslationBlock *tb; int singlestep_enabled; =20 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 @@ =20 /* 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; --=20 2.20.1 From nobody Mon Feb 9 05:10:51 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1612895578; cv=none; d=zohomail.com; s=zohoarc; b=cAbQGAD/QK19OA8X1pi5phALNP38PihgWMEceiqyL8YzQyo63Xjxkr4o4PQBU9XBzgVoBavy7w8ObzZvt7umS1gaSJPI+C0LlELzZYZFcpfM4tOSBXWWzZeaWTZ+96VUnCcFeU0vtUSAmSXbAMhtn85SCub07du66h9dhoKUlyw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1612895578; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=zNliwCPKaSP1eGW/lpkDIX8h4kiIJ0I84O8E5iALOHU=; b=Nnc8sQHU+ELu6o4/nZaw0iKV4URWGX8ThCsIYBxIq+evKM50bKVSPwXdIbSSXqYdVTyhbZ1OFTz6oHo5pEKYCiLmNOcFt8Pyv4gYWmpOzogYM1pEKJK3aIJMIF70P+yQxxJKZjh33pnMDFEAxglMZ7tBCecya+EAdFMB3l0mmt8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1612895577657378.24406469706094; Tue, 9 Feb 2021 10:32:57 -0800 (PST) Received: from localhost ([::1]:41784 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l9Xom-0008GI-IM for importer@patchew.org; Tue, 09 Feb 2021 13:32:56 -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) 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) 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-Google-Smtp-Source: ABdhPJxEGDeWtCdJbYxF6KnWPjcRhBKDN8EzZgB9dwVVlSS5owtXPP4S2TiR2kL7KSDvnuyUB9Il8w== X-Received: by 2002:a7b:c842:: with SMTP id c2mr4762511wml.100.1612895277381; Tue, 09 Feb 2021 10:27:57 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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=20Benn=C3=A9e?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) 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=C3=A9e [AJB: s/stoped/stopped/] Signed-off-by: Alex Benn=C3=A9e --- include/hw/core/tcg-cpu-ops.h | 10 ++++++++++ accel/tcg/translate-all.c | 17 +++++++++++++---- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/include/hw/core/tcg-cpu-ops.h b/include/hw/core/tcg-cpu-ops.h index ac3bb051f2..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); =20 + /** + * @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 */ =20 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" =20 /* #define DEBUG_TB_INVALIDATE */ @@ -2420,6 +2421,7 @@ void cpu_io_recompile(CPUState *cpu, uintptr_t retadd= r) CPUArchState *env =3D cpu->env_ptr; #endif TranslationBlock *tb; + CPUClass *cc; uint32_t n; =20 tb =3D tcg_tb_lookup(retaddr); @@ -2429,11 +2431,18 @@ void cpu_io_recompile(CPUState *cpu, uintptr_t reta= ddr) } cpu_restore_state_from_tb(cpu, tb, retaddr, true); =20 - /* 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 =3D 1; + cc =3D 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 =3D 2; + } #if defined(TARGET_MIPS) if ((env->hflags & MIPS_HFLAG_BMASK) !=3D 0 && env->active_tc.PC !=3D tb->pc) { --=20 2.20.1 From nobody Mon Feb 9 05:10:51 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1612896054; cv=none; d=zohomail.com; s=zohoarc; b=VW6Cgf18x2JpsVPFAtNy2JaqIAZHqsdAb7mGpR8ahBVz0QWaHntpBRkTuqr5ez9JgCD0FKz73apA/rNeMFXikMQZ3b7/hiWV56dTLiYFkAAmoMzPgVyJlCbSw+nsM+M1wj59GJVKrE14yMHkke4t5kE0KTVh0lszrUwAaS40Doc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1612896054; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=/09yZXBu/IIBdtGKto41tx2iEh/nEfZf6dGwHzi/lkI=; b=EytqZE3FzGsbY614q0Ob3x3Rn/zgSnwwMMi6IHVJN3snoDA14rq5AZdDnUyHbAeUMOaeS1+ODhNo4uWuoJPUfcukG3KZS9mRzkWe4ZkRklP9JcV8YV+jQIrMITRQfOiJVUr9HKkjHpQa3igrtyUUqJzUDoUY/NKqXQ4oESbRBdg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1612896054470853.1768271361809; Tue, 9 Feb 2021 10:40:54 -0800 (PST) Received: from localhost ([::1]:58674 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l9XwT-0007JP-5N for importer@patchew.org; Tue, 09 Feb 2021 13:40:53 -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) 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) 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-Google-Smtp-Source: ABdhPJxbg/S6oGucAEZBm88tfZCRu0kbc0AkcUDUsIScQD1Gn7yO3j8tv1sziNifSbfpJqbR8al/wA== X-Received: by 2002:adf:dd10:: with SMTP id a16mr27236303wrm.207.1612895275667; Tue, 09 Feb 2021 10:27:55 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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=20Mathieu-Daud=C3=A9?= , robhenry@microsoft.com, aaron@os.amperecomputing.com, cota@braap.org, Paolo Bonzini , kuhn.chenqun@huawei.com, =?UTF-8?q?Alex=20Benn=C3=A9e?= , Aurelien Jarno Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) 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=C3=A9e Signed-off-by: Alex Benn=C3=A9e --- accel/tcg/translate-all.c | 12 ++---------- target/mips/cpu.c | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index 6eb37883bd..470657b02a 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -2417,7 +2417,7 @@ void tb_check_watchpoint(CPUState *cpu, uintptr_t ret= addr) */ void cpu_io_recompile(CPUState *cpu, uintptr_t retaddr) { -#if defined(TARGET_MIPS) || defined(TARGET_SH4) +#if defined(TARGET_SH4) CPUArchState *env =3D cpu->env_ptr; #endif TranslationBlock *tb; @@ -2443,15 +2443,7 @@ void cpu_io_recompile(CPUState *cpu, uintptr_t retad= dr) cpu_neg(cpu)->icount_decr.u16.low++; n =3D 2; } -#if defined(TARGET_MIPS) - if ((env->hflags & MIPS_HFLAG_BMASK) !=3D 0 - && env->active_tc.PC !=3D tb->pc) { - env->active_tc.PC -=3D (env->hflags & MIPS_HFLAG_B16 ? 2 : 4); - cpu_neg(cpu)->icount_decr.u16.low++; - env->hflags &=3D ~MIPS_HFLAG_BMASK; - n =3D 2; - } -#elif defined(TARGET_SH4) +#if defined(TARGET_SH4) if ((env->flags & ((DELAY_SLOT | DELAY_SLOT_CONDITIONAL))) !=3D 0 && env->pc !=3D tb->pc) { env->pc -=3D 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 &=3D ~MIPS_HFLAG_BMASK; env->hflags |=3D tb->flags & MIPS_HFLAG_BMASK; } + +# ifndef CONFIG_USER_ONLY +static bool mips_io_recompile_replay_branch(CPUState *cs, + const TranslationBlock *tb) +{ + MIPSCPU *cpu =3D MIPS_CPU(cs); + CPUMIPSState *env =3D &cpu->env; + + if ((env->hflags & MIPS_HFLAG_BMASK) !=3D 0 + && env->active_tc.PC !=3D tb->pc) { + env->active_tc.PC -=3D (env->hflags & MIPS_HFLAG_B16 ? 2 : 4); + env->hflags &=3D ~MIPS_HFLAG_BMASK; + return true; + } + return false; +} +# endif /* !CONFIG_USER_ONLY */ #endif /* CONFIG_TCG */ =20 static bool mips_cpu_has_work(CPUState *cs) @@ -679,6 +696,7 @@ static struct TCGCPUOps mips_tcg_ops =3D { .do_interrupt =3D mips_cpu_do_interrupt, .do_transaction_failed =3D mips_cpu_do_transaction_failed, .do_unaligned_access =3D mips_cpu_do_unaligned_access, + .io_recompile_replay_branch =3D mips_io_recompile_replay_branch, #endif /* !CONFIG_USER_ONLY */ }; #endif /* CONFIG_TCG */ --=20 2.20.1 From nobody Mon Feb 9 05:10:51 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1612895757; cv=none; d=zohomail.com; s=zohoarc; b=fLyN0Hu3Y8bFUDG1ptYGKxocCV5PJobnIFtIwxXfKGr5NrOY8tQBXasySJbez4fBvKVb9XJiSj5YMjUz8V1wOF/XO6cX/uoxxITiN2BQ8XHVxNyX8fiKOQS0ALx4cIVPBQMeLU7khxN+1qCr7vB78oGy3YYyUNXwXzR/2+IGCAc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1612895757; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=DCYLKD8lKHBC7zqZxsTt0jNxWwRKIBBIOHuXIK5gJKg=; b=fbLOAEUcGo3jzHLnkjerpDlnSqLOuerxVSIiBMwvddF2b0Lf28ezM3+D5AMa/ngEHpmzB1K90/ZawWUHKNTLfm3I2iWpsaK/iSI87V1OIKKwjL2Py8Wx/G56qWqfUP+soA/6qGjA42daUVlJXRh0LkvfS7XzC5ObTycBlhrtB50= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1612895756963674.6349453524559; Tue, 9 Feb 2021 10:35:56 -0800 (PST) Received: from localhost ([::1]:50080 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l9Xre-0003Qj-Au for importer@patchew.org; Tue, 09 Feb 2021 13:35:54 -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) 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) 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-Google-Smtp-Source: ABdhPJyB2dj35Qlfj5W29Op62Ky2LXuf6BqhU9blDiupNynR+zIBXgLMv9Po7snNxdDiRIE6XhIZEw== X-Received: by 2002:a05:600c:47d7:: with SMTP id l23mr4833252wmo.16.1612895274745; Tue, 09 Feb 2021 10:27:54 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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=20Benn=C3=A9e?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) 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=C3=A9e Signed-off-by: Alex Benn=C3=A9e --- accel/tcg/translate-all.c | 12 ------------ target/sh4/cpu.c | 18 ++++++++++++++++++ 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index 470657b02a..b8ad95aa1b 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -2417,9 +2417,6 @@ void tb_check_watchpoint(CPUState *cpu, uintptr_t ret= addr) */ void cpu_io_recompile(CPUState *cpu, uintptr_t retaddr) { -#if defined(TARGET_SH4) - CPUArchState *env =3D cpu->env_ptr; -#endif TranslationBlock *tb; CPUClass *cc; uint32_t n; @@ -2443,15 +2440,6 @@ void cpu_io_recompile(CPUState *cpu, uintptr_t retad= dr) cpu_neg(cpu)->icount_decr.u16.low++; n =3D 2; } -#if defined(TARGET_SH4) - if ((env->flags & ((DELAY_SLOT | DELAY_SLOT_CONDITIONAL))) !=3D 0 - && env->pc !=3D tb->pc) { - env->pc -=3D 2; - cpu_neg(cpu)->icount_decr.u16.low++; - env->flags &=3D ~(DELAY_SLOT | DELAY_SLOT_CONDITIONAL); - n =3D 2; - } -#endif =20 /* Generate a new TB executing the I/O insn. */ cpu->cflags_next_tb =3D 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 =3D tb->flags & TB_FLAG_ENVFLAGS_MASK; } =20 +#ifndef CONFIG_USER_ONLY +static bool superh_io_recompile_replay_branch(CPUState *cs, + const TranslationBlock *tb) +{ + SuperHCPU *cpu =3D SUPERH_CPU(cs); + CPUSH4State *env =3D &cpu->env; + + if ((env->flags & ((DELAY_SLOT | DELAY_SLOT_CONDITIONAL))) !=3D 0 + && env->pc !=3D tb->pc) { + env->pc -=3D 2; + env->flags &=3D ~(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 =3D { #ifndef CONFIG_USER_ONLY .do_interrupt =3D superh_cpu_do_interrupt, .do_unaligned_access =3D superh_cpu_do_unaligned_access, + .io_recompile_replay_branch =3D superh_io_recompile_replay_branch, #endif /* !CONFIG_USER_ONLY */ }; =20 --=20 2.20.1 From nobody Mon Feb 9 05:10:51 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1612895438; cv=none; d=zohomail.com; s=zohoarc; b=Ui6D/VwbAtjPl7dvxIHfwUNiwRiFb7EEKspkMN+mBOqW3qwHq3cTm0idAkXIvYE5aw06O5zRkFfTze5vmLpG8OaizTBZyerYV4zVVBnVzHLrJ4MaaRRQqs5GRxgtgEUZdeJWRCMc6bmkEBhZxtFwpehZK89CJgVjBHHep6L1NPo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1612895438; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=XTJA1LO8Z0+7BgtkAor7hGRdE1VoRrWN9y3S3XEnRWI=; b=O/8XB/y/EsO6yb/CxJ3kfxX7cD5KyPAkPzejrODbG4k8ukjJAFjAv1fREX9kCjtJtsuqfDkdFoC0kXsxoatbZD5aP2dWj/+eCJTKjc/qAWeORF6zscF5YImJYXpXVRULL+Cnx3XH7idupSYHb/h9HmvouLHBW2EVD2vYtyWlt3I= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1612895438451413.82114628943043; Tue, 9 Feb 2021 10:30:38 -0800 (PST) Received: from localhost ([::1]:37114 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l9XmX-00061i-7F for importer@patchew.org; Tue, 09 Feb 2021 13:30:37 -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) 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) 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-Google-Smtp-Source: ABdhPJwoW104d4pX4pMpks0FHsXWM3y6jJD1eEbffAPUpht7qmCHP/WJq3AYXm3DyOzjj+/UHajxUA== X-Received: by 2002:adf:e3cd:: with SMTP id k13mr5882598wrm.289.1612895279586; Tue, 09 Feb 2021 10:27:59 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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=20Benn=C3=A9e?= , robhenry@microsoft.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) 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=C3=A9e --- [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(-) 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; =20 static void vcpu_insn_exec_before(unsigned int cpu_index, void *udata) { + static uint64_t last_pc; + uint64_t this_pc =3D GPOINTER_TO_UINT(udata); + if (this_pc =3D=3D last_pc) { + g_autofree gchar *out =3D g_strdup_printf("detected repeat executi= on @ 0x%" + PRIx64 "\n", this_pc); + qemu_plugin_outs(out); + } + last_pc =3D this_pc; insn_count++; } =20 @@ -36,8 +44,10 @@ static void vcpu_tb_trans(qemu_plugin_id_t id, struct qe= mu_plugin_tb *tb) qemu_plugin_register_vcpu_insn_exec_inline( insn, QEMU_PLUGIN_INLINE_ADD_U64, &insn_count, 1); } else { + uint64_t vaddr =3D 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)); } } } --=20 2.20.1 From nobody Mon Feb 9 05:10:51 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1612895762; cv=none; d=zohomail.com; s=zohoarc; b=G1a9DBboH6GGSi95jutufYjZNT7H1xKUBKTbD0bQw/iP4lCXQyIwx4vyI9e/wm9DFuMg46xttcIX7YmDRfPFfR+XCOf0ewKAQJjpb+y3Ox0qweo7TZ3reKqH4bBqPUDvp897rMabs6XCDa1BrOx4SzZpOnqvUdQTQ6+JobpexFg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1612895762; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=QEIjvY3Wkc2WIeF8s4uxzLxZhJzabaYoCUAadrDeVZE=; b=Spnr5YvURQZKvxj2nN71W1h7fuWd85PD47BJ2meHvav3QPrgrEkTB4U2vexgkL1UJ+Tvx2ALyqJ0bkzFvt6tW1YBgGXDN+jpAIP9v9g2IUbgTj3mQp9ZsSEC/Rxt+Wdlcr7gUlMJzvh1c4oHDUf1+fkGlJkUP0+b0XhmjDHn/0k= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1612895762071219.0795973401946; Tue, 9 Feb 2021 10:36:02 -0800 (PST) Received: from localhost ([::1]:50464 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l9Xrl-0003cH-1D for importer@patchew.org; Tue, 09 Feb 2021 13:36:01 -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) 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) 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-Google-Smtp-Source: ABdhPJwnWXDgY43mx8oHByXUypUcqv6ZqKYD6LjoXyl6zsWxye93BMnrhmgsam0sayRdoD2kjlnSFA== X-Received: by 2002:a05:600c:354b:: with SMTP id i11mr4698374wmq.72.1612895288086; Tue, 09 Feb 2021 10:28:08 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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=20Mathieu-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=20Benn=C3=A9e?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) 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=C3=A9e --- tests/acceptance/tcg_plugins.py | 103 ++++++++++++++++++++++++++++++++ 1 file changed, 103 insertions(+) create mode 100644 tests/acceptance/tcg_plugins.py 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=C3=A9e +# +# 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 =3D 120 + KERNEL_COMMON_COMMAND_LINE =3D 'printk.time=3D1 panic=3D-1 ' + + def run_vm(self, kernel_path, kernel_command_line, + plugin, plugin_log, console_pattern, args): + + logger =3D logging.getLogger('plugin') + start_time =3D time.time() + vm =3D 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 =3D 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 =3D ('http://security.debian.org/' + 'debian-security/pool/updates/main/l/linux-signed-ar= m64/' + 'linux-image-4.19.0-12-arm64_4.19.152-1_arm64.deb') + kernel_sha1 =3D '2036c2792f80ac9c4ccaae742b2e0a28385b6010' + kernel_deb =3D self.fetch_asset(kernel_url, asset_hash=3Dkernel_sh= a1) + kernel_path =3D self.extract_from_deb(kernel_deb, + "/boot/vmlinuz-4.19.0-12-arm64= ") + return kernel_path + + def test_aarch64_virt_insn(self): + """ + :avocado: tags=3Daccel:tcg + :avocado: tags=3Darch:aarch64 + :avocado: tags=3Dmachine:virt + :avocado: tags=3Dcpu:cortex-a57 + """ + kernel_path =3D self._grab_aarch64_kernel() + kernel_command_line =3D (self.KERNEL_COMMON_COMMAND_LINE + + 'console=3DttyAMA0') + console_pattern =3D 'Kernel panic - not syncing: VFS:' + + plugin_log =3D tempfile.NamedTemporaryFile(mode=3D"r+t", prefix=3D= "plugin", + suffix=3D".log") + + self.run_vm(kernel_path, kernel_command_line, + "tests/plugin/libinsn.so", plugin_log.name, + console_pattern, + args=3D('-cpu', 'cortex-a53')) + + logger =3D logging.getLogger() + + with plugin_log as lf, \ + mmap.mmap(lf.fileno(), 0, access=3Dmmap.ACCESS_READ) as s: + + m =3D 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 --=20 2.20.1 From nobody Mon Feb 9 05:10:51 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1612896291; cv=none; d=zohomail.com; s=zohoarc; b=JxC5ejQx0DWs9FPblC3ebRJWX/k9O8MjVcEGCRNRBbT/5YgT+P1yY0vwQHNz2PmkXeBt30JoF8O84qfHGKmE8ZnMpxDdLWb6/9HZpyT0n6CvOJOEn5BSoV+JkskWgyvIFJVPbBapQjSMR0hbzW1SgeAxdaDnSldqylC4UqZggbo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1612896291; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=uLoHyoIh1M9yTgnlc4zbWUCZ8MEEKdj0MabvYTrqb/0=; b=n7YxoOPdQAHEFgKvb1dBbeyojRVhg87dkGtI5m4XIwEbMnVV0gadNKMLKcqG37MZ9nZIbD27FIkEquWNP6iUhPkpDRy68ryvF34Ch1MIY4EqlD5mij0/TCI+VqkdZ0HXMg9VPn2Xpuhfz9cMQbZuWkYCGt9qQ32UKcHM3Q1OqIE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1612896291307530.7042286261416; Tue, 9 Feb 2021 10:44:51 -0800 (PST) Received: from localhost ([::1]:39042 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l9Y0I-0003ZB-7D for importer@patchew.org; Tue, 09 Feb 2021 13:44:50 -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) 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) 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-Google-Smtp-Source: ABdhPJykNrgr53AS9c2JgwrCOXcqR0yJDEUMhBCOCK2GFLRs2wekemRGutyZD+W9GsEn2ngQJjcpuQ== X-Received: by 2002:a7b:c3ce:: with SMTP id t14mr4727349wmj.175.1612895285458; Tue, 09 Feb 2021 10:28:05 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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=20Benn=C3=A9e?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) 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=C3=A9e --- accel/tcg/cpu-exec.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) 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, Tr= anslationBlock *tb, /* Ensure global icount has gone forward */ icount_update(cpu); /* Refill decrementer and continue execution. */ - insns_left =3D MIN(0xffff, cpu->icount_budget); + insns_left =3D MIN(CF_COUNT_MASK, cpu->icount_budget); cpu_neg(cpu)->icount_decr.u16.low =3D insns_left; cpu->icount_extra =3D 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 =3D (tb->cflags & ~CF_COUNT_MASK) | insns_left; } #endif } --=20 2.20.1 From nobody Mon Feb 9 05:10:51 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1612895853; cv=none; d=zohomail.com; s=zohoarc; b=UFUgeDFy6MdH33VsxzYBg0SVAkv9oFBpbJIllP4EgNWRLAdxum2VAJWiLfl1aHZjH+H8jr2mKFkY4fnUsSzEfFWel1rl01R4kyxZQIVyfgYZBwgW2OY9sZHXL7ep5VZg6ZOBuernD2L/tYs/fkeK5CG0CQUcCC5uO6M576/8/Y4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1612895853; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=egNb1Ho5wTfDlHsUr/B5unXhMEO0vBcjIkXluBAwDPY=; b=DZ0jtqzJ1x/jWlVtUk4n6nIzrwwjnABY8WyPgtNXfSoN4xldQ8c+MirAHrlHvJrcyya6xdWUJvr+FYSkGRBKpmc0DQn3DjXinJS/BpnnFkDWpmftCwKuxL87r3YS8ABZmF9LmicumEE1CYqV4iz6gBFEefTZ7aeYxIgH/wNhBnU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1612895852929180.001916444985; Tue, 9 Feb 2021 10:37:32 -0800 (PST) Received: from localhost ([::1]:54330 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l9XtD-0005M3-SE for importer@patchew.org; Tue, 09 Feb 2021 13:37:31 -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) 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) 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-Google-Smtp-Source: ABdhPJwX2jL0nVjfdmkI+FBbgcPiqFCu1xU2wfLQdBzdb94y6MfpBS9HZwE8V/b6VoKOzUQEHEfM7A== X-Received: by 2002:adf:a1d6:: with SMTP id v22mr18444568wrv.372.1612895286553; Tue, 09 Feb 2021 10:28:06 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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=20Benn=C3=A9e?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) 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=C3=A9e --- accel/tcg/cpu-exec.c | 44 ++++---------------------------------------- 1 file changed, 4 insertions(+), 40 deletions(-) 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; } =20 -#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 =3D curr_cflags() | CF_NOCACHE; - int tb_exit; - - if (ignore_icount) { - cflags &=3D ~CF_USE_ICOUNT; - } - - /* Should never happen. - We only end up here when an existing TB is too long. */ - cflags |=3D MIN(max_cycles, CF_COUNT_MASK); - - mmap_lock(); - tb =3D tb_gen_code(cpu, orig_tb->pc, orig_tb->cs_base, - orig_tb->flags, cflags); - tb->orig_tb =3D 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 =20 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 =3D= =3D 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 l= og */ + cpu->cflags_next_tb =3D (curr_cflags() & ~CF_USE_ICOUNT) | 1; } #endif - if (cpu->exception_index < 0) { - return false; - } + return false; } - if (cpu->exception_index >=3D EXCP_INTERRUPT) { /* exit request from the cpu execution loop */ *ret =3D 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 =3D=3D -1 || cpu->cflags_next_tb & CF_= USE_ICOUNT) && cpu_neg(cpu)->icount_decr.u16.low + cpu->icount_extra =3D= =3D 0)) { qatomic_set(&cpu->exit_request, 0); if (cpu->exception_index =3D=3D -1) { --=20 2.20.1 From nobody Mon Feb 9 05:10:51 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1612895381; cv=none; d=zohomail.com; s=zohoarc; b=QYC0qLhnuOd47AGN+K6ebqXDQxRDzFZ4FbZy32NPe92nRc/ARUYmu3SUtmXxl1dPPK6VZWkj2bNAe+3z4Wc1PNzh+lz1CCJQsFMzJvJgbLfEW+XUsX01qNqlkgWeGIqyGE6GJvdMkEeGvBq+AhuSxjyv1qcXRSIyr2Xtj10f044= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1612895381; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=SJ+CxGQUMbX25NLlEOpaUwde946vo4PY/BH+Jix+NZA=; b=JDFtb1XAQB/Id1VyC7zY3FC8o1WORsmvKzq87ypnDvRPPjQgnN9U84KsjpNHOwz6caDkNTRh+oXe1m+YPa7eQzmwCJajuRd2f+frMBtU1kzAuBmuujUltq/yTOKc6nU/o96agxJJEHPvKd6qKarKHO2vNsBHoDMdo7vOTh/UnSM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1612895381050111.16336426361829; Tue, 9 Feb 2021 10:29:41 -0800 (PST) Received: from localhost ([::1]:34074 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l9Xlc-0004nN-12 for importer@patchew.org; Tue, 09 Feb 2021 13:29:40 -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) 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) 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-Google-Smtp-Source: ABdhPJznXJuodcfQb6g9XHTJAbht1T1G/+ockUgzHF5jwOxjhDE8RwKwkO1edSUfc1cKnvldoCvaQw== X-Received: by 2002:a7b:ce8c:: with SMTP id q12mr4606297wmj.127.1612895280527; Tue, 09 Feb 2021 10:28:00 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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=20Benn=C3=A9e?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) 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=C3=A9e --- accel/tcg/translate-all.c | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) 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, Translati= onBlock *tb, #endif } =20 -/* 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 ph= ys_pc, =20 assert_memory_lock(); =20 - if (phys_pc =3D=3D -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] =3D tb->page_addr[1] =3D -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 tab= le, @@ -1880,9 +1869,8 @@ TranslationBlock *tb_gen_code(CPUState *cpu, phys_pc =3D get_page_addr_code(env, pc); =20 if (phys_pc =3D=3D -1) { - /* Generate a temporary TB with 1 insn in it */ - cflags &=3D ~CF_COUNT_MASK; - cflags |=3D CF_NOCACHE | 1; + /* Generate a one-shot TB with 1 insn in it */ + cflags =3D (cflags & ~CF_COUNT_MASK) | 1; } =20 cflags &=3D ~CF_CLUSTER_MASK; @@ -2096,6 +2084,17 @@ TranslationBlock *tb_gen_code(CPUState *cpu, tb_reset_jump(tb, 1); } =20 + /* + * 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 =3D=3D -1) { + tb->page_addr[0] =3D tb->page_addr[1] =3D -1; + return tb; + } + /* check next page if needed */ virt_page2 =3D (pc + tb->size - 1) & TARGET_PAGE_MASK; phys_page2 =3D -1; --=20 2.20.1 From nobody Mon Feb 9 05:10:51 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1612896514; cv=none; d=zohomail.com; s=zohoarc; b=Y8Pwnmh4wifnIM8ZhkUfuGPflDZgpp595bmYiCcAm/OPvVP7tKyL8uCZXusl+hPT9w6cmq49ci+EwMcKptHZt3isiMNEQaTRJLOkO/OcMHBBXfvkWIeSPSR0S5IOhjKI8I4vAC5NgfDyIPLhUVzkmWYVIWG/a+OCURtyEo23gI0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1612896514; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=xVvEwjwvlErjN28dnMMVJVw5XumleZ7dCVSrng6Ywq8=; b=kBz/72OFIbJaxRmEaMZAB4YgzMQO6429DlwR4uCTOy4Jca57fANLY6aextqqE9tnoYTzB82atdLC5uAEpV54YVqVBxWu+32d1uu3Ny6y6epRKnxq7OPrDqrGdr7FmSD7k3Fn977S+BkOvAPtJgvNyKKyhnXBrlf3AnV3DwPOt1o= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1612896514648689.861818229199; Tue, 9 Feb 2021 10:48:34 -0800 (PST) Received: from localhost ([::1]:46030 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l9Y3t-0006xU-Lm for importer@patchew.org; Tue, 09 Feb 2021 13:48:33 -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) 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) 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-Google-Smtp-Source: ABdhPJxZYR9vjglCyM1qWeWcHEf/4DRwic9nF/v/lKMfWjpJBcvHdVp4K7Xsjv/zhjn+84gHkx8/Hw== X-Received: by 2002:a5d:6883:: with SMTP id h3mr3630486wru.90.1612895697799; Tue, 09 Feb 2021 10:34:57 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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=20Benn=C3=A9e?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) 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=C3=A9e --- include/exec/exec-all.h | 3 --- accel/tcg/translate-all.c | 51 ++++++++++++--------------------------- 2 files changed, 15 insertions(+), 39 deletions(-) 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 { =20 struct tb_tc tc; =20 - /* 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_p= c, bool will_exit) TranslationBlock *tb =3D 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 *t= b, bool rm_from_page_list) phys_pc =3D tb->page_addr[0] + (tb->pc & ~TARGET_PAGE_MASK); h =3D 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; } =20 @@ -1794,6 +1787,8 @@ tb_link_page(TranslationBlock *tb, tb_page_addr_t phy= s_pc, { PageDesc *p; PageDesc *p2 =3D NULL; + void *existing_tb =3D NULL; + uint32_t h; =20 assert_memory_lock(); =20 @@ -1813,25 +1808,20 @@ tb_link_page(TranslationBlock *tb, tb_page_addr_t p= hys_pc, tb->page_addr[1] =3D -1; } =20 - if (!(tb->cflags & CF_NOCACHE)) { - void *existing_tb =3D NULL; - uint32_t h; - - /* add in the hash table */ - h =3D tb_hash_func(phys_pc, tb->pc, tb->flags, tb->cflags & CF_HAS= H_MASK, - tb->trace_vcpu_dstate); - qht_insert(&tb_ctx.htable, tb, h, &existing_tb); + /* add in the hash table */ + h =3D tb_hash_func(phys_pc, tb->pc, tb->flags, tb->cflags & CF_HASH_MA= SK, + tb->trace_vcpu_dstate); + qht_insert(&tb_ctx.htable, tb, h, &existing_tb); =20 - /* 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 =3D 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 =3D existing_tb; } =20 if (p2 && p2 !=3D p) { @@ -1904,7 +1894,6 @@ TranslationBlock *tb_gen_code(CPUState *cpu, tb->cs_base =3D cs_base; tb->flags =3D flags; tb->cflags =3D cflags; - tb->orig_tb =3D NULL; tb->trace_vcpu_dstate =3D *cpu->trace_dstate; tcg_ctx->tb_cflags =3D cflags; tb_overflow: @@ -2443,16 +2432,6 @@ void cpu_io_recompile(CPUState *cpu, uintptr_t retad= dr) /* Generate a new TB executing the I/O insn. */ cpu->cflags_next_tb =3D curr_cflags() | CF_LAST_IO | n; =20 - 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); --=20 2.20.1 From nobody Mon Feb 9 05:10:51 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1612895604; cv=none; d=zohomail.com; s=zohoarc; b=Xcnvbws2T987+44XVINS9KKoDnXdJfBFMkJFvCjfb+3YJNNgGoo6QCpOXRnnCXlAZkdRgCkU7Ej/YUJBz7ohY7JKLN/byTROYy0idyAFooOriie+sZUWcSR6fbIcgagBnVr8x4D4EIGbme324+3IShJeGcgf2TbojEezyxgeCAU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1612895604; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ejLSBmEQiH4mLxCrVBrlwMdu2X7JBwiJC91YTaurGZo=; b=KvlQU5sEfF1VU1EZJA6/iS1Adky4Ax8rUUhGwh2AeefJvg0/9w6wwwYVytVvXQPoZtERWM3DGNQOEK78RDQ+a9mhZpQaO6GXrw55ZRRB63gBEmT+/3IrEu1i9d1IOV3TSo7pCCFE5TPOOvnDTJ2cnypwLzYwA32GvJ7VXS3wccY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1612895604327281.4113815420935; Tue, 9 Feb 2021 10:33:24 -0800 (PST) Received: from localhost ([::1]:42760 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l9XpD-0000EG-2G for importer@patchew.org; Tue, 09 Feb 2021 13:33:23 -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) 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) 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-Google-Smtp-Source: ABdhPJw9CH28g3a0LXcl6kJba93mm+NOA5lVAnY+oIRbY2OU/T6txORT0wUdGXREFSFLNTAyWUzK+A== X-Received: by 2002:adf:f68e:: with SMTP id v14mr26750428wrp.273.1612895283368; Tue, 09 Feb 2021 10:28:03 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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=20Benn=C3=A9e?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) 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=C3=A9e --- include/exec/exec-all.h | 3 ++- accel/tcg/translate-all.c | 17 ++++++++--------- accel/tcg/translator.c | 2 +- 3 files changed, 11 insertions(+), 11 deletions(-) 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) =20 /* 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 ret= addr) } =20 #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 reta= ddr) n =3D 2; } =20 - /* Generate a new TB executing the I/O insn. */ - cpu->cflags_next_tb =3D 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 =3D curr_cflags() | CF_NOINSTR | CF_LAST_IO | n; =20 qemu_log_mask_and_addr(CPU_LOG_EXEC, tb->pc, "cpu_io_recompile: rewound execution of TB to " TARGET_FMT_lx "\n", tb->pc); =20 - /* TODO: If env->pc !=3D 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); } =20 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, DisasConte= xtBase *db, ops->tb_start(db, cpu); tcg_debug_assert(db->is_jmp =3D=3D DISAS_NEXT); /* no early exit */ =20 - plugin_enabled =3D plugin_gen_tb_start(cpu, tb); + plugin_enabled =3D !(tb_cflags(db->tb) & CF_NOINSTR) && plugin_gen_tb_= start(cpu, tb); =20 while (true) { db->num_insns++; --=20 2.20.1 From nobody Mon Feb 9 05:10:51 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1612895677; cv=none; d=zohomail.com; s=zohoarc; b=aMB+BtS7KmeRJGr7k6W/vUxytlMNmXmNmCk4p2hJmd142eeHXI1OarPZIjC2YBvGVpwpHzuUjU1/ViY2JvvhIOv6JW6jUDXDBUJvkVNvGWm7v6xqpwID24x4QPX8WoZ6w48NwwXHNuGab0WLw24hK8E13ee+Amyo+amUZ1QKkHw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1612895677; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=a7e1FwTBjDma5YBYDcW8fs7cDFozA2L932geu4P/T6s=; b=HO/jzV0w9KL6UPjpyicQTDqTFAKvSruhQ/NuFrihVtpaUPxK121bvKwG5PHia5J27xhE9L9r1py+XS+ySmc+u2yaI3r3hbx4HJ9SUsLVJ2uXGAah7Dv20o9MMNwhYaLF4KHBl8MbzdSCrV8JoFm2Oa4kgPhsjFvzKKnKVSukt8o= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1612895676779164.06625670578626; Tue, 9 Feb 2021 10:34:36 -0800 (PST) Received: from localhost ([::1]:45688 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l9XqN-0001Xj-PR for importer@patchew.org; Tue, 09 Feb 2021 13:34:35 -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) 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) 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-Google-Smtp-Source: ABdhPJxqQghwiX/e6wCIB2e1++ViPqGD1PvLHQHCOqEoHgvc4joznKEzPmj+8aCioxM4zisGy+WmFw== X-Received: by 2002:a5d:6947:: with SMTP id r7mr26916368wrw.150.1612895282211; Tue, 09 Feb 2021 10:28:02 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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=20Mathieu-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=20Benn=C3=A9e?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) 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=C3=A9e --- tests/acceptance/tcg_plugins.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) 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=3Daccel:tcg + :avocado: tags=3Darch:aarch64 + :avocado: tags=3Dmachine:virt + :avocado: tags=3Dcpu:cortex-a57 + """ + kernel_path =3D self._grab_aarch64_kernel() + kernel_command_line =3D (self.KERNEL_COMMON_COMMAND_LINE + + 'console=3DttyAMA0') + console_pattern =3D 'Kernel panic - not syncing: VFS:' + + plugin_log =3D tempfile.NamedTemporaryFile(mode=3D"r+t", prefix=3D= "plugin", + suffix=3D".log", delete= =3DFalse) + + self.run_vm(kernel_path, kernel_command_line, + "tests/plugin/libinsn.so", plugin_log.name, + console_pattern, + args=3D('-cpu', 'cortex-a53', '-icount', 'shift=3D1')) + + logger =3D logging.getLogger() + + with plugin_log as lf, \ + mmap.mmap(lf.fileno(), 0, access=3Dmmap.ACCESS_READ) as s: + m =3D re.search(br"detected repeat execution @ (?P0x[0-9= A-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) --=20 2.20.1