From patchwork Tue Jan 24 18:01:24 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: 646045 Delivered-To: patch@linaro.org Received: by 2002:a17:522:b9de:b0:4b9:b062:db3b with SMTP id fj30csp341358pvb; Tue, 24 Jan 2023 10:07:56 -0800 (PST) X-Google-Smtp-Source: AK7set8qvDyZk/trEC4gRU7AUbuLF2pamt9fp6X8DGKgIUejrAUgYeiO3zlbIvnmELSxoBcLdrzs X-Received: by 2002:a0c:e003:0:b0:537:6a1e:d822 with SMTP id j3-20020a0ce003000000b005376a1ed822mr4333650qvk.14.1674583676577; Tue, 24 Jan 2023 10:07:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674583676; cv=none; d=google.com; s=arc-20160816; b=g3ujoUtJna0C18M04HxHRkwYQH3ZdYb1X0TtzKg7icish5BJYeWX2/TOy068vl4J5j cAfdm7WQw54lvz58KVvsYPGGqXHoYrRg+piyquvTdf+yr7z3JRWQYoopdqtoYNq0RD76 uyyItFCNGzP0mcleGeJFASLJD3B517PVuvbJcilvD8Iq5us7lxz7RDIziw1nLmsaDSBz Iyjc2zpxB3ulzQXX52vgb/RTnt3IkjT2y7HDPJs1+huITG5BELmYOy7RtJnApBMoZlEL hUlLri5xDgRRnZtgaAzZrOc2Pu623LvtgMFXnoiZSdnA66rwlTYVLDxomRVZrJtGV+UW ifXQ== 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=yF79W/oG8BIP2TY7X/k2rfY64Zx5JTk5QXqtO8k21/c=; b=jVoiBTzOBpyg1MIpxp13w0hyFYRQf4EljJqfZC47GsCipk6aUgPbKH/Ht+seR4CeJT 5rb3BxYkz/94/FmO7DMtWSA9QUoVg15ySEOxOYbZLtvqJe4FG3gIDrx4AkRI725cuS74 HBvOL8LO7PhXPZcJCOuBhTJA9xGpHjn/qRUcXnGFwYtuvX+/+TBLLj7McV2ZNiIS5Imd 6tohHcLQNRJVzAfwevRiNFznJ2GtiGZtXJs2VrmPi3uBKo/ZeZMV6juygvzftG9sfKp9 akMjyrF8X6yn60MC67PqTtimcetnYBSCclb5I8oIAGDGudX1agCHA0nNc9EvrbAezKEl Ehyw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ekgFWCiA; 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 fi1-20020a0562141a4100b005376598a70asi2030484qvb.271.2023.01.24.10.07.56 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 24 Jan 2023 10:07: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=ekgFWCiA; 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 1pKNhc-0005Gv-83; Tue, 24 Jan 2023 13:07:24 -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 1pKNhF-0004yh-3X for qemu-devel@nongnu.org; Tue, 24 Jan 2023 13:07:03 -0500 Received: from mail-wr1-x434.google.com ([2a00:1450:4864:20::434]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pKNhD-00073e-CE for qemu-devel@nongnu.org; Tue, 24 Jan 2023 13:07:00 -0500 Received: by mail-wr1-x434.google.com with SMTP id b7so14737599wrt.3 for ; Tue, 24 Jan 2023 10:06:58 -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=yF79W/oG8BIP2TY7X/k2rfY64Zx5JTk5QXqtO8k21/c=; b=ekgFWCiAljHyOA3AgWNH51A0FrWr/r1mG5jZkolFJgUjIjqCcWLQ9SViPOMIc0DnBA hHZWBgk1xmcDcEO9ghLc6LIJqrug0hwwG1llL39Pqrl1IhCuf3oEZgzSsAMTZxDqxb9s dm/81BCOmU03h5jtAi90NU3GnPtgHkQ5tMG5L2eZilaAW7tvAlyWmgMAJUYqGQsJvR8+ Z7WMFdRCOl0NWe2tPKEzPxlEiAf1IXDTrnrmYO6u4iiDFoJhdK+yju+RXYg6T7xkfORM baS4MFHdUwxlfQFm5OwLVH91jWBXh/1pXNROjCAcAZ1u4rNsEdCyQ6bOpqyYYx6FixBC e9HA== 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=yF79W/oG8BIP2TY7X/k2rfY64Zx5JTk5QXqtO8k21/c=; b=NzHz0S514NUN/T2aY58YSnkvRJvXzg+RW+ZYFq5hktu+47FMob1hDLNaiDY6xvWZTw uldeVItO9EvpG3AZTkiINqos0sMtet//5Va8r5VNNvV4bwR25qugMOlHUI4zmAbeFhCC 14W43QAUM0OoKFBt0xee+OI4XpBGpHPqtOGhMwR4dHNPFvE1sADTE/vre9KLZS/2fVRJ pcIdyAHynspW1tQfwqgjBMr/EmgDurrmPEnTCqc475b92UUgN74IbIOQoHzAqVR7pn7Z Yn7O3gywKVpDMg2K/1837mZE3YvzCSVTXyOLF0vtqDsMk5Ducfx8Hy3mnO2kXy2lWCUg rYvQ== X-Gm-Message-State: AFqh2kqagfyeQLqEYbwKslOFQzvcxKuY0oCWqfJwGHQSS7L9lfuLho7q jt3PWqzPCUmmz004FeYUYwpgbg== X-Received: by 2002:adf:e9d2:0:b0:257:15b9:8b66 with SMTP id l18-20020adfe9d2000000b0025715b98b66mr24864437wrn.62.1674583616765; Tue, 24 Jan 2023 10:06:56 -0800 (PST) Received: from zen.linaroharston ([185.81.254.11]) by smtp.gmail.com with ESMTPSA id q14-20020adff78e000000b002be07cbefb2sm2902794wrp.18.2023.01.24.10.06.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Jan 2023 10:06:56 -0800 (PST) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 6D4C21FFD2; Tue, 24 Jan 2023 18:01:31 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Richard Henderson , Ed Maste , Thomas Huth , Alexandre Iooss , Markus Armbruster , Jagannathan Raman , John G Johnson , Mahmoud Mandour , =?utf-8?q?Daniel_P=2E_Berrang?= =?utf-8?q?=C3=A9?= , Bandan Das , Elena Ufimtseva , Michael Roth , Eduardo Habkost , Beraldo Leal , =?utf-8?q?Alex_Benn=C3=A9e?= , =?utf-8?q?Marc-Andr?= =?utf-8?q?=C3=A9_Lureau?= , Qiuhao Li , Stefan Hajnoczi , Alexander Bulekov , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , John Snow , Paolo Bonzini , Darren Kenny , qemu-arm@nongnu.org, Yanan Wang , Cleber Rosa , Wainer dos Santos Moschetta , Marcel Apfelbaum , Li-Wen Hsu , Peter Maydell , Emilio Cota Subject: [PATCH v2 32/35] translator: always pair plugin_gen_insn_{start, end} calls Date: Tue, 24 Jan 2023 18:01:24 +0000 Message-Id: <20230124180127.1881110-33-alex.bennee@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230124180127.1881110-1-alex.bennee@linaro.org> References: <20230124180127.1881110-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::434; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x434.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable 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é Reviewed-by: Richard Henderson Message-Id: <20230108164731.61469-3-cota@braap.org> Signed-off-by: Alex Bennée --- 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) {