From patchwork Tue Jan 10 17:39:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 640881 Delivered-To: patch@linaro.org Received: by 2002:a17:522:f3c4:b0:4b4:3859:abed with SMTP id in4csp2871715pvb; Tue, 10 Jan 2023 11:04:56 -0800 (PST) X-Google-Smtp-Source: AMrXdXtY1eSuheLjSuebIX+xKwonjJimQ3yWBwWVaKgWal4odjWXSOR/V+TD74efTZXN42xQZS9J X-Received: by 2002:a81:a43:0:b0:4c2:1fc5:1e96 with SMTP id 64-20020a810a43000000b004c21fc51e96mr16170161ywk.8.1673377496089; Tue, 10 Jan 2023 11:04:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673377496; cv=none; d=google.com; s=arc-20160816; b=0Bm9TAvxxRYaHZWjTg/DnercOs02NhaTdVmDGlZNzrpd/OEBYMhZOF+HdVv7RFu48d 8UP1ev1oDxe67ISFzgvd05xU5WekBFvJJ0uihSbo5XHOVeuT8WuA8LwOSKnEy8+axW1P jT44lJfD+I463UnoeJpFxLcV31uR1hgHROfpzvBY74JYp47hheIaRW+abz7PuTAPa3Ah S2GJQ+Hi7TpjNyY97egU2xJZmvcmjiymtS6el0YS2OrdPV8JpLmOGYoEDWIsSlI1GI7q GqBnzovEx2DY/wXKoGIhJuANMXQxLAwEGrrEB70DqihYoNhKogNF1erMOgMpoad17kye vxVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=hF/3DoG9owY2pD8TEHjkZ0ZRm2+7IOUIANxR5871mgM=; b=zikBDru5AKvj2a8ReHvzkkn4dSCdycYhuCkhpoODRJHv1j/UQAj8lhKkZlWGPvc/Nr Ly4QcjXpA3/p4Oo+gT6wEsVUzdrrOv8WADHiRzjpivv2xRkjNKuIKjNZ5sFxvA44DHRI vh/DXxEQ/9W4ZpoA4UaTPjIfsiwidd15ff1+qAYaE5rpfCy+2/BtDu0AOBpUPw+9acJO Hy8/41U/Fn5M/ubsUVP+UFKxN96VivWA+6cO4PqYyRw3fzrC1YS0kEwHecXJF6FD5K2t +QbDVDLGI0EeCkIKaDgwZZsBmTxHk4ZwcjaoSfcYnwRZSn3kxv3z+D/5KZr3ESKWQ7CC KLeQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=GldqPs40; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id k5-20020a05620a414500b006ed88c5e84asi7525583qko.228.2023.01.10.11.04.55 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 10 Jan 2023 11:04:56 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=GldqPs40; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pFIbN-0003nD-Du; Tue, 10 Jan 2023 12:39:57 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pFIb9-0003Zb-Fr for qemu-devel@nongnu.org; Tue, 10 Jan 2023 12:39:43 -0500 Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pFIb4-0001FK-02 for qemu-devel@nongnu.org; Tue, 10 Jan 2023 12:39:43 -0500 Received: by mail-wm1-x336.google.com with SMTP id k26-20020a05600c1c9a00b003d972646a7dso12506074wms.5 for ; Tue, 10 Jan 2023 09:39:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=hF/3DoG9owY2pD8TEHjkZ0ZRm2+7IOUIANxR5871mgM=; b=GldqPs404+eL0NDoRaW6NC1GQgQQDsnqVKpLVsodyTn9cw0oLXa3XX12eZtNIu0rmx 0RM44NfM+JwUhWs3Ivkwq72EIaWrz2CZZB5eh4QiSe4xoiKBAOzmw8tnWbOJKLAu0yEL 6anRTGXbhJbb4YqCPau8UiQRRgHIt/lih3ojGnid048kLj5P/5kUaGHlygoPHCpowUsc nNybVQLGxqWDD08meEaJgGbjKDR/ahsa7hWEuFK3q7s/60qZrM8dtM4RZII7N/0gJfPC VYkCxSOBMwEjghDisRqqxBwAPZJRd/JFCJkCKe/pkz0X6WahBPaDHT+4rXe5hLn3bssE 3Tgg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=hF/3DoG9owY2pD8TEHjkZ0ZRm2+7IOUIANxR5871mgM=; b=tdn+ryAORBGqB187GLt2mDebj7h6nsYu4zQlf4WVd88XwTIAk/FU4gI5gCQ/zaVklv 5nbGoI9hscu6vzUnFNsG3mVqQp8ebYpdcJNebLcAFzUu6tV5ujqnDlY/wQr9zF9TQnKM 3n35UbFzpTQSkaM9KvWfu1OiLw6OKklM06GXRevVReZKsETulNQNGNDFzWYBCOYo6KTE wxtLL1UTp4aF6PhG0t1JKe3I0SQnYW95eBQs39xEu2ZL8L4hDBoeC/lxmayQaUFSvB/L B9eoR/+8wHweNPR+YXMYKaOtKMlUOujUtV4MHVfa5nfkB+3W6veLasTiUMRoNuN+BMu8 JLRQ== X-Gm-Message-State: AFqh2kpH46/EYhzLqImzMgms6uNZCwRK539C9YSR2xMP0bT29OxrBIxL MaNlL6eNr/nh7RNQ7gvMKZgHLA== X-Received: by 2002:a05:600c:5399:b0:3d9:c6f5:c643 with SMTP id hg25-20020a05600c539900b003d9c6f5c643mr18786079wmb.29.1673372377327; Tue, 10 Jan 2023 09:39:37 -0800 (PST) Received: from zen.linaroharston ([185.81.254.11]) by smtp.gmail.com with ESMTPSA id z12-20020a05600c0a0c00b003cfa81e2eb4sm15551258wmp.38.2023.01.10.09.39.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Jan 2023 09:39:36 -0800 (PST) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id E34FC1FFCD; Tue, 10 Jan 2023 17:39:25 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Richard Henderson , Alexandre Iooss , Beraldo Leal , Thomas Huth , John Snow , Eduardo Habkost , Elena Ufimtseva , Ed Maste , Yanan Wang , Cleber Rosa , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Li-Wen Hsu , Markus Armbruster , Jagannathan Raman , =?utf-8?q?Daniel_P=2E_Berrang?= =?utf-8?q?=C3=A9?= , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , Michael Roth , Wainer dos Santos Moschetta , =?utf-8?q?Alex_Benn?= =?utf-8?q?=C3=A9e?= , qemu-arm@nongnu.org, Marcel Apfelbaum , Peter Maydell , Paolo Bonzini , Mahmoud Mandour , John G Johnson , Emilio Cota Subject: [PATCH 24/26] translator: always pair plugin_gen_insn_{start, end} calls Date: Tue, 10 Jan 2023 17:39:20 +0000 Message-Id: <20230110173922.265055-25-alex.bennee@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230110173922.265055-1-alex.bennee@linaro.org> References: <20230110173922.265055-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::336; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x336.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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Emilio Cota Related: #1381 Signed-off-by: Emilio Cota Reviewed-by: Philippe Mathieu-Daudé Message-Id: <20230108164731.61469-3-cota@braap.org> Signed-off-by: Alex Bennée Reviewed-by: Richard Henderson --- accel/tcg/translator.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/accel/tcg/translator.c b/accel/tcg/translator.c index 061519691f..ef5193c67e 100644 --- a/accel/tcg/translator.c +++ b/accel/tcg/translator.c @@ -100,19 +100,24 @@ void translator_loop(CPUState *cpu, TranslationBlock *tb, int max_insns, ops->translate_insn(db, cpu); } - /* Stop translation if translate_insn so indicated. */ - if (db->is_jmp != DISAS_NEXT) { - break; - } - /* * We can't instrument after instructions that change control * flow although this only really affects post-load operations. + * + * Calling plugin_gen_insn_end() before we possibly stop translation + * is important. Even if this ends up as dead code, plugin generation + * needs to see a matching plugin_gen_insn_{start,end}() pair in order + * to accurately track instrumented helpers that might access memory. */ if (plugin_enabled) { plugin_gen_insn_end(); } + /* Stop translation if translate_insn so indicated. */ + if (db->is_jmp != DISAS_NEXT) { + break; + } + /* Stop translation if the output buffer is full, or we have executed all of the allowed instructions. */ if (tcg_op_buf_full() || db->num_insns >= db->max_insns) {