From patchwork Fri May 3 12:34:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 794375 Delivered-To: patch@linaro.org Received: by 2002:adf:a153:0:b0:34d:5089:5a9e with SMTP id r19csp711744wrr; Fri, 3 May 2024 05:36:11 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWVJLyxkvPJOvkbKwn7SIfsI+NztDcO3sMp7z2lHuTDtUdntSz7+y5ngdefZ21PF1JGeWvlZ1YTJvL3h12/MYMI X-Google-Smtp-Source: AGHT+IEcp+nefpJnaDXFdzH8/Cg05Rb6Ylc0SoTClbROI5Cy1Kg9U7yUUclhTIhGaBJZA2zO1HLM X-Received: by 2002:ac8:7f03:0:b0:43a:712c:f985 with SMTP id f3-20020ac87f03000000b0043a712cf985mr2812327qtk.56.1714739770846; Fri, 03 May 2024 05:36:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1714739770; cv=none; d=google.com; s=arc-20160816; b=ebG8rNZ3mrleYVttVarct/x+VY6OzAT99ATPyaY2CyZZQ1em98RyA0fs9Tf0UJRT91 EMPyvMLy8yoE557SY/kI6ylyj1sgMVlqzG1ZldbgW+TGwFKG11Ip8tSquWGB7VTnpQkS YebTYg7hraX2YW9sPMbnspHAQkVsQGHrTnJtC6D12F5Ncq7aCDfJzX9tzqITSF9IyLq0 s5/XMVeY8zpzf5AMcoLDU2/aiv/SagB2o/4XnqXfbwFJOqc1ev3DtdW/dkFohw6JD6Dj v/EvKAlriv+apekmN241IcT4BRqQ8xb1J4dZYB6w9V53hrGihu6rUtOHucBdml1fynf1 90SQ== 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=4Tb/CgMjRwAYjJGSlcjkSqdpYLQYMSWtat67VigpwVw=; fh=XMRXym02iLNKkh4CLdJ1KGbmlbC5N/mIofRY3czz1TM=; b=qRo0DQbsF0wJF+leHSSIY8Jm+9OC7KP33LBUqx+MfQ5lU+/k0oObCXek9bmLjboAs4 y3bNdIF4Ah6ZFjvyXkWgnLLc2PeDalMuIbzL4hCyHEJyBFrThX7eAH/iBY5mLRglqMX+ W7orlW+kmx/mjs2RTX8yIMsCMtE6L/35r3UV8AyJVOPuE1AwzNIBO8K2rKroB2HRp/jw uV4rphP/V6Oy3Nw7HTQWhcWQR9Y5G7Pcp5Ppk+qGipQvcQgZZeoo+KWLLqegOPyFQ1bC k1tluyjqg4nApBBuLZ1CdWWKIX+RQuXKWQ9uPR9MOyQngZ+wJ9CW29/KiADq04fdrim3 17+Q==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="U/FbBZDe"; 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 j16-20020a05622a039000b0043adc263ed1si3289518qtx.350.2024.05.03.05.36.10 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 03 May 2024 05:36:10 -0700 (PDT) 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="U/FbBZDe"; 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 1s2s8s-0007g0-Us; Fri, 03 May 2024 08:35:58 -0400 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 1s2s8X-0007Uv-B1 for qemu-devel@nongnu.org; Fri, 03 May 2024 08:35:41 -0400 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s2s8T-00037f-Jb for qemu-devel@nongnu.org; Fri, 03 May 2024 08:35:36 -0400 Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-41ba1ba5592so50089725e9.1 for ; Fri, 03 May 2024 05:35:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1714739732; x=1715344532; darn=nongnu.org; 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=4Tb/CgMjRwAYjJGSlcjkSqdpYLQYMSWtat67VigpwVw=; b=U/FbBZDerOkJ2rUe1UU3n5vYfq7NJSfEADoYTFXWpqaRWMHG3FFsrpnimltFrCnOtX 3lpzMEnUjDJ3nKoljxz2sY3N0a+e4Mun3nlwJ2Ydu5GZR+MhrD14x+pbrWwdxfVmLDN+ nwubSI3r3k6H08YZXDJKRNr9o0wPb4G1I3DrIL3Izt6jcI/OE6HRIPXXBJPTdpeib5Cu XBo5PvYBe2BlFqKCOu3vOFZbANfkPjUda82q1GxlHS/q8E2M/u2g+BgQU6lWI7SmSKkT HTEYE6QDwLcYq90Q4qO/6OgppB6iHPqz99zfAiOlcVPqdviWIJ+lBxiwviMpyMKvMooO DE1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714739732; x=1715344532; 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=4Tb/CgMjRwAYjJGSlcjkSqdpYLQYMSWtat67VigpwVw=; b=hmHygPzTtv2HXKumVJqLlFkmT5ngRfdApG6rj/dXdZM1HCuCcyU87KyQO+JfPLHotr AzPgYuxYlMNagabf7qKuzj66X8hy7/32jrugBUCfGJx65/frhhvqBgmbBIV7DAQK8X6J 29A7Q1KEHzJntj4S1J09/n+L6fiFKcQkPX4GSH8PtuxriQfCmUZJsiMZhyinUWj7El2b ZOw6yN6KJ7BrD4WBHHiKz5ZF7AbS0qxpnZXHgQoki0ceOSilDRReAdoiSws/zU/r6k0e aVMOZRX1fk4II70ygQvHdmyFMnYoAWS6cb9wm9f1l+LQgAUDPOC9f/69100Fjf4qmW9o 7KdA== X-Gm-Message-State: AOJu0YxNcCKM/xiwO1H7SS4JxiZyxuP4PXJghzS/yyz8yed75Gj7ssKY 2bMsdeelmvRGaGHT3xC1S1fMV/+U3cllphPjZpSjEpYBfm2ale5BdV81Ou6gs4k9Y47LUogmQpE A X-Received: by 2002:a05:600c:1d0a:b0:41c:2699:dd9d with SMTP id l10-20020a05600c1d0a00b0041c2699dd9dmr2273086wms.28.1714739731682; Fri, 03 May 2024 05:35:31 -0700 (PDT) Received: from m1x-phil.lan ([176.176.179.187]) by smtp.gmail.com with ESMTPSA id je8-20020a05600c1f8800b0041bf28aa11dsm5504533wmb.42.2024.05.03.05.35.29 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 03 May 2024 05:35:31 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Paolo Bonzini , Warner Losh , Richard Henderson , Kyle Evans , Ilya Leoshkevich , Riku Voipio , Laurent Vivier , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , qemu-stable@nongnu.org Subject: [PATCH v3 5/5] accel/tcg: Always call tcg_flush_jmp_cache() on reset Date: Fri, 3 May 2024 14:34:56 +0200 Message-ID: <20240503123456.28866-6-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240503123456.28866-1-philmd@linaro.org> References: <20240503123456.28866-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::331; envelope-from=philmd@linaro.org; helo=mail-wm1-x331.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 In commit bb6cf6f016 ("accel/tcg: Factor tcg_cpu_reset_hold() out") we unfortunately restricted the tcg_flush_jmp_cache() to system emulation. Move it to the common tcg_exec_cpu_reset_hold() handler so user emulation gets the jmp_cache initialized when threads are created. Remove the NULL check in tcg_flush_jmp_cache() from commit 4e4fa6c12d ("accel/tcg: Complete cpu initialization before registration") which was a band-aid fix for incorrect commit bb6cf6f016. Cc: qemu-stable@nongnu.org Fixes: bb6cf6f016 ("accel/tcg: Factor tcg_cpu_reset_hold() out") Signed-off-by: Philippe Mathieu-Daudé --- accel/tcg/cpu-exec.c | 2 ++ accel/tcg/sysemu/tcg-accel-ops.c | 2 -- accel/tcg/translate-all.c | 5 ----- 3 files changed, 2 insertions(+), 7 deletions(-) diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c index 1bf85c324d..7e04df2902 100644 --- a/accel/tcg/cpu-exec.c +++ b/accel/tcg/cpu-exec.c @@ -36,6 +36,7 @@ #include "exec/replay-core.h" #include "sysemu/tcg.h" #include "exec/helper-proto-common.h" +#include "exec/tb-flush.h" #include "tb-jmp-cache.h" #include "tb-hash.h" #include "tb-context.h" @@ -1099,4 +1100,5 @@ void tcg_exec_unrealizefn(CPUState *cpu) void tcg_exec_cpu_reset_hold(CPUState *cpu) { + tcg_flush_jmp_cache(cpu); } diff --git a/accel/tcg/sysemu/tcg-accel-ops.c b/accel/tcg/sysemu/tcg-accel-ops.c index 82c8368f87..13e450c088 100644 --- a/accel/tcg/sysemu/tcg-accel-ops.c +++ b/accel/tcg/sysemu/tcg-accel-ops.c @@ -34,7 +34,6 @@ #include "qemu/timer.h" #include "exec/exec-all.h" #include "exec/hwaddr.h" -#include "exec/tb-flush.h" #include "exec/gdbstub.h" #include "../internal-common.h" #include "hw/core/cpu.h" @@ -83,7 +82,6 @@ int tcg_cpu_exec(CPUState *cpu) static void tcg_cpu_reset_hold(CPUState *cpu) { tcg_exec_cpu_reset_hold(cpu); - tcg_flush_jmp_cache(cpu); tlb_flush(cpu); } diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index 83cc14fbde..93202fa3c1 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -663,11 +663,6 @@ void tcg_flush_jmp_cache(CPUState *cpu) { CPUJumpCache *jc = cpu->tb_jmp_cache; - /* During early initialization, the cache may not yet be allocated. */ - if (unlikely(jc == NULL)) { - return; - } - for (int i = 0; i < TB_JMP_CACHE_SIZE; i++) { qatomic_set(&jc->array[i].tb, NULL); }