From patchwork Thu Jan 26 11:22:47 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: 647091 Delivered-To: patch@linaro.org Received: by 2002:a17:522:b9de:b0:4b9:b062:db3b with SMTP id fj30csp185684pvb; Thu, 26 Jan 2023 03:23:54 -0800 (PST) X-Google-Smtp-Source: AK7set8dCT726iBlUx1rAK+SEUObhYxXsTYP0W7qo1MGFwPjPoblwLAWof56A9UdOi/OscZURhgT X-Received: by 2002:a05:6214:598a:b0:537:7e93:2265 with SMTP id ll10-20020a056214598a00b005377e932265mr2360131qvb.40.1674732234126; Thu, 26 Jan 2023 03:23:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674732234; cv=none; d=google.com; s=arc-20160816; b=p2fYNOV/8uMskWjEX6MOyL53wc6qWDz7+e8yHRdAk/Aufn/AOc9c9CcW8Owzs+uEmG zDTPu8/D5WPoghHZ6zvxEeXYbOczpCv3pVAlwXSLTgUBXz9TjGBqXtaAHJyKajmG743/ IcM/T+XvQin7NGidmiN6kk/SamAJWfdF+6PquWYc0BhMPFhCPf9+DXTvEaWZcWx/xsZN VRm/9r8Rml5uo3/FKwMOSoGjEBQSQmF9fBG8ozph5Er4k4E9ZKoFLMzNqGI1Pm17IHf5 kxKMAZC3rytKNw8y4sSut4l/yOydoH2b0tKfNfzRjP4BiM8JXJgZnhlvN3ETA+ng/bWM +tkA== 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=vuHIkf4e6GqtJJGRDN7Gz8dOSuK3Oawb4EIUEUIUh9o=; b=vGXqs+CtnSoD3zBFDHfEgarXgpC1pDkpVJKiOwJOx9Tf55t4cUD/geM7hl/92MdPHA hjRoMSUeDodnjyVxY4iEJhg4qZkm33UO06qUY2dgjECIoaRwt6RA9uko8HrnGs8XgBle 28pavmFlM+h4cRAKOyBTY2qiCYFa27H/9x9fiClGatmwYp1QwPQUnk7L4vKBS3aW8Giz /eHI7JyfIEO5XOIppVk1WvMIeNj1n+PxVs3PFUwEj1q3bcwDa9zgPuRBpBrLWPQpqHqj /poGtOJDyGfxozBnarSSSO8gA4ELi6DZX9Nnz5IXIxMGUh8jq8sZfVx75pfNpJN9eNzH 0xag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=B8K0411T; 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 f12-20020a05620a12ec00b006fc2db94a39si753542qkl.661.2023.01.26.03.23.54 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 26 Jan 2023 03:23:54 -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=B8K0411T; 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 1pL0LY-0003Ev-A8; Thu, 26 Jan 2023 06:23:13 -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 1pL0LU-0002xI-V3 for qemu-devel@nongnu.org; Thu, 26 Jan 2023 06:23:09 -0500 Received: from mail-wr1-x435.google.com ([2a00:1450:4864:20::435]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pL0LS-0003eA-PX for qemu-devel@nongnu.org; Thu, 26 Jan 2023 06:23:08 -0500 Received: by mail-wr1-x435.google.com with SMTP id m14so969078wrg.13 for ; Thu, 26 Jan 2023 03:23:06 -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=vuHIkf4e6GqtJJGRDN7Gz8dOSuK3Oawb4EIUEUIUh9o=; b=B8K0411TdwY+DKBgVJXc7IYNsW9FyFIzT3N6xfcBP91n5xTPuf0/FfqZXLIFa4glHh gcmQ3e7Ztrf8PeFrdXKG8AkXfJtV9uqGz2ItJma69QhA+bdQTfHLwkSevxkPaxN1oUjx EkjHJUMM/JWpx4TEsxgBiD/XPMNDW11S50d3hLfH+x79lE2aP+fbsJnibsZkS0t5vRY/ 3OFoskaYpUH/KMGCRzcw/nUg2fVpJrRiKmvE1xX3LJoVpFaSQOuPDfYYgxHi9HeeWnHd eoOKtw5aStXtd8bRx3cOQbBrbkAJjEJ7MFzUg1j50BnNrVJEkgUw23fJKoxgb3DM+JB1 9D5A== 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=vuHIkf4e6GqtJJGRDN7Gz8dOSuK3Oawb4EIUEUIUh9o=; b=dd3hdK7iyAG0lObeKl0AWz9H6aTWHY27XCdZgxCiRqwIYkJZlXWmC5zKfdFImeKI9z 2a/usD+kxYeEdfBRl/U5aUIqQKT1UUiqCrF/rDgOVL3nYOwA/yIR60VId278EyU44/FR /kkfWqztkRNPPDgIFiUMk/qsI0pIZIakTwF8FVaKajI5sTGpoQxKMngt3rJsmXtCX+h+ PluPrpO/4BvSeKJdmSzLUrqQxiJmputBLncV0mK+T1IGxiIG6/K17pAakLN9/eE2l0kj 6yZFZfyT7sb7Yc0SyopQe5+mfI+hTmEuVw71ppnLfuv8kIM7RUhVaZDB3FgmqEVio7PN vF5w== X-Gm-Message-State: AO0yUKUFGuBA7w0wXuYcQqfmqu3PTsnZ20YPHA3jpdjFyoBna6YzAchb OQ2mJeACwSuxoHLSp9R3c8PduQ== X-Received: by 2002:a05:6000:1f05:b0:2bf:bc38:17c1 with SMTP id bv5-20020a0560001f0500b002bfbc3817c1mr4802157wrb.4.1674732185848; Thu, 26 Jan 2023 03:23:05 -0800 (PST) Received: from zen.linaroharston ([185.81.254.11]) by smtp.gmail.com with ESMTPSA id q3-20020adff503000000b002bfae1398bbsm1042967wro.42.2023.01.26.03.23.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Jan 2023 03:23:01 -0800 (PST) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id A6C111FFCF; Thu, 26 Jan 2023 11:22:59 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, Emilio Cota , =?utf-8?q?Philip?= =?utf-8?q?pe_Mathieu-Daud=C3=A9?= , Richard Henderson , =?utf-8?q?Alex_Benn=C3=A9?= =?utf-8?q?e?= , Paolo Bonzini Subject: [PULL 32/35] translator: always pair plugin_gen_insn_{start, end} calls Date: Thu, 26 Jan 2023 11:22:47 +0000 Message-Id: <20230126112250.2584701-33-alex.bennee@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230126112250.2584701-1-alex.bennee@linaro.org> References: <20230126112250.2584701-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::435; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x435.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.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 Message-Id: <20230124180127.1881110-33-alex.bennee@linaro.org> 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) {