From patchwork Thu Jan 2 18:25:19 2025 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: 13924815 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A6D33E7718B for ; Thu, 2 Jan 2025 18:27:33 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tTPt2-0007yJ-Fx; Thu, 02 Jan 2025 13:25:37 -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 1tTPt0-0007s2-42 for qemu-devel@nongnu.org; Thu, 02 Jan 2025 13:25:34 -0500 Received: from mail-wr1-x436.google.com ([2a00:1450:4864:20::436]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tTPsx-0007sp-KH for qemu-devel@nongnu.org; Thu, 02 Jan 2025 13:25:33 -0500 Received: by mail-wr1-x436.google.com with SMTP id ffacd0b85a97d-385e27c75f4so8276227f8f.2 for ; Thu, 02 Jan 2025 10:25:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1735842329; x=1736447129; 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=kwDRyvTJZzNpnWnwx0B7XY3O+69910db4I16wox7BzU=; b=SlCsZmY5M42hv5Eg1fcSU//IgdsdQSAybBYIMX+O1oqIBOY/3eWeXHBtKJOIHG5YkJ UuoSoXGpdrgLasQsu1WQjAFEHRx6JYj0HmIJW0pJrIYoKovOwcg9+RaYKz/6/uNDjKnp Yeuo+igp4amaFoxj+60ZYx1hH7tNpXs0UwFI7yujm4sK9L0KWH4ZYeuPFOT1dMXwogs3 ZUqFIA+m6xVNNCZnNZ4EPW6B+DxWHhvEj1debyWeptyzD8+PttwkBzdadSlbzP01amgD ENRQ0xb/tE2lexx+uZ1YINdQJHy2U98lkh5c/KChOSifjpNHaTJ9rUiCLirtidLxzauI 1Ebw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735842329; x=1736447129; 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=kwDRyvTJZzNpnWnwx0B7XY3O+69910db4I16wox7BzU=; b=osCvLFJ2rhUyveXfvow7LoHeR72w859kUAGThhuKVVM4HdW8Zeiy5c0LCunognR9XJ vFjytDE4N1utvh6R/AJENCWyWE6CoOWdMf86ZWyOFroHi5cYb8RwlyS6CFKRbRpVpLsx 9uoCHv56+iXUJ/LjpZJp16GHImIz9JayeCO0bzmKKFaTDeyHfAPvelARUtfjbJ1QBDMX kXw15dIPldvaUJFVP64smYe6kHUTGGUSPzdcz3dZCHfvTMQ+2VOcMgtJHdfU5cU30qzM 2Afm02YCd8qpx4aX/W4TeugV7YXV3QVcXZx48+JaFud4HcZDoO27x0v1DBQYjidAV0sC RV+w== X-Gm-Message-State: AOJu0Yz7/fuVtUiA64wsX07BfiY3nFVr6wkcd3arpV4Fksr8tCRgwhIC bj9kWJq8ghRy9Sw2xrHMRalXPjQWTirPNIIj9sNrAJZeu/cgBYlpH0WanvZcPhx2A85Lu9CHSEq 1CbSQSw== X-Gm-Gg: ASbGncsJA+vp+6zmQUp0VEPrp9Xxri+rajrXQ6gphbC52gWwH37olX+t6U2yIDnwrSZ +2Mjlhv+S8ul7c6S61I5eRZxU5YFGLBRDua6cfCvCtwrXlajpQwgYWY0FYA6iCwPU9LX35ptrJP Dvna6v3KuBGRkxOQ0N/1k73kwP2OPpJYyyZ47wupBU5o7ZPdDt2b9mn1eKvzw5ZrkwUrv9U97gP ZFsq1HXucXx+9rU9E9GzoeMHr0+YZRfnDtYxCw+Jso3aJdzedhW6uUG90d6CeZuCgfVSYCjSNst 3RcK2Y6X3SdO/m6trhPWrYJU/lpWNWc= X-Google-Smtp-Source: AGHT+IEs2dh5EalLyOVlh1d+Em48iLhVk267HSINaUMWvVZzuLL5VmBAsRtby4EOJ/JHKZSbbvqbRQ== X-Received: by 2002:a05:6000:704:b0:385:e9ba:acda with SMTP id ffacd0b85a97d-38a221e2738mr36306420f8f.2.1735842328903; Thu, 02 Jan 2025 10:25:28 -0800 (PST) Received: from localhost.localdomain (88-187-86-199.subs.proxad.net. [88.187.86.199]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4366e210cecsm424125855e9.2.2025.01.02.10.25.27 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 02 Jan 2025 10:25:27 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Ilya Leoshkevich , =?utf-8?q?Alex_Benn=C3=A9e?= , Paolo Bonzini , Pierrick Bouvier , Riku Voipio , Richard Henderson , Laurent Vivier , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH 1/3] linux-user: Only include 'exec/tb-flush.h' header when necessary Date: Thu, 2 Jan 2025 19:25:19 +0100 Message-ID: <20250102182521.65428-2-philmd@linaro.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250102182521.65428-1-philmd@linaro.org> References: <20250102182521.65428-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::436; envelope-from=philmd@linaro.org; helo=mail-wr1-x436.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Very few source files require to access "exec/tb-flush.h" declarations, and except a pair, they all include it explicitly. No need to overload the generic "user-internals.h". Signed-off-by: Philippe Mathieu-Daudé --- linux-user/user-internals.h | 1 - linux-user/mmap.c | 1 + linux-user/syscall.c | 1 + 3 files changed, 2 insertions(+), 1 deletion(-) diff --git a/linux-user/user-internals.h b/linux-user/user-internals.h index b9b05c1d11f..4aa253b5663 100644 --- a/linux-user/user-internals.h +++ b/linux-user/user-internals.h @@ -20,7 +20,6 @@ #include "user/thunk.h" #include "exec/exec-all.h" -#include "exec/tb-flush.h" #include "qemu/log.h" extern char *exec_path; diff --git a/linux-user/mmap.c b/linux-user/mmap.c index 6828b17a63f..d1f36e6f16b 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -21,6 +21,7 @@ #include "trace.h" #include "exec/log.h" #include "exec/page-protection.h" +#include "exec/tb-flush.h" #include "exec/translation-block.h" #include "qemu.h" #include "user/page-protection.h" diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 78c7c0b34ef..cbbfcf10d28 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -26,6 +26,7 @@ #include "tcg/startup.h" #include "target_mman.h" #include "exec/page-protection.h" +#include "exec/tb-flush.h" #include "exec/translation-block.h" #include #include From patchwork Thu Jan 2 18:25:20 2025 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: 13924820 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C2908E77194 for ; Thu, 2 Jan 2025 18:28:30 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tTPtu-0008Op-PL; Thu, 02 Jan 2025 13:26:31 -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 1tTPt5-00082i-BW for qemu-devel@nongnu.org; Thu, 02 Jan 2025 13:25:41 -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 1tTPt3-0007uG-LS for qemu-devel@nongnu.org; Thu, 02 Jan 2025 13:25:39 -0500 Received: by mail-wr1-x434.google.com with SMTP id ffacd0b85a97d-385deda28b3so8027606f8f.0 for ; Thu, 02 Jan 2025 10:25:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1735842335; x=1736447135; 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=peARTf2/KC6klqYofRoAuLkEwM6US8QQU7qQEt05x1c=; b=SKO6p/2Z38NhBURzbzssUwzCiDschSx9YPnpO0lR8QMUqzjU6QevyleU2UCi8/lhqI F34QwStX2YbbuR+hT2/QPClzxZ9XFCvCQF4UxbGsLe1dQNbdUf3y8KuD+tyhJdDbhhK6 y8Hw5QqH8XiUpTf3EtksCmQzm3rYOgLBLhbrHvq//cUq9K1OsuRIXgOvykTKaWEbXGzG VAP2Nc+1Hl1xbimmudpAUWVIhTwIN4I9a3eitX5n8BhuxTUTf6KpLZLeD9y/+m/jrW30 4n4479pOA2kzANQBETY6TmVKMy9PpYsInejJlS2kFOCAvR0njLSfNewN5wgt2GwsKj2M /VEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735842335; x=1736447135; 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=peARTf2/KC6klqYofRoAuLkEwM6US8QQU7qQEt05x1c=; b=eqRvN8KhYjJ+6RefO9HlcNjoc+IlnR43SIvnJJ1ms0zsPnui1YuGdOp/jF3dzbc0dc dKH2X9QFesvT5xEkYm6ADk4pfloquC60BF+5ygswkJ65zhvdIs9n/xkVBxPzjzosSWeT j0MuAI9YAc1yhMYzuf0EYgrnr1wey28CPzjahGWPbQII2La4mcaIrYrk2j3TZznfmonY XCknj8hv6l0+sLytVoDvBlAG8zw+YlgoUaPC033jvWmRMmd3wG4WAg0SN95nxmW6uVvR eQofOZ9Tc6WftDOJwgDE7zXJWAWwNOX0r+sdWTXWNXVtSF/IQ75DKXhg+F4ClAiwzHzb 0vgw== X-Gm-Message-State: AOJu0YxTucXV1U/dqfeR0UiW5uay4rs2XOF2ytS9A0foywryll+FGxjx bLlDCHznCvxDfx2NTHyXzHvRqmsZmpLK+buJl5t4tS2TQsWOGbf1pw1jh+Nh8y1FRvgOJb3EjMr 9oSH9wQ== X-Gm-Gg: ASbGnctn26/ICfvWnQPgD/mDgAQRGMSbxR/XSbdqRsOzpk9Jw8OHTTWqFFFS6wlY8jO aeH5Nsp40DQcYztbwTtG2pyDSycykCctH/x8owwCMI6ODUiP105t9kzX6vgwHYv6TDBsKp5M0XZ pk2ThO0OJL4SLFpqujH9W03IWB3mkEmkAI31FgbquQEjFnzKEy/C6EUj2UOcmAFgcyEaUnlv6dz TeUg2xT282yHS+BJNrp4hHY/PHTySEwS53KFoZnGegS1B2bisTmDeUEWAuEGi/fg4inWQjee5dO kG033jtYTzijwUCrIliteuzLMWU/AS8= X-Google-Smtp-Source: AGHT+IEFSbuEYWrHAHLpFZr5TJFmKiZRap2XudEjMBUoAN08DHuam16HLDSAKCdq3J4qLd9JWjtHZA== X-Received: by 2002:a5d:6da3:0:b0:386:32ea:e70d with SMTP id ffacd0b85a97d-38a223fd30dmr29606830f8f.50.1735842335194; Thu, 02 Jan 2025 10:25:35 -0800 (PST) Received: from localhost.localdomain (88-187-86-199.subs.proxad.net. [88.187.86.199]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38a1c89e2f9sm39723531f8f.81.2025.01.02.10.25.33 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 02 Jan 2025 10:25:34 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Ilya Leoshkevich , =?utf-8?q?Alex_Benn=C3=A9e?= , Paolo Bonzini , Pierrick Bouvier , Riku Voipio , Richard Henderson , Laurent Vivier , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH 2/3] accel/tcg: Factor out common tcg_exec_reset() helper Date: Thu, 2 Jan 2025 19:25:20 +0100 Message-ID: <20250102182521.65428-3-philmd@linaro.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250102182521.65428-1-philmd@linaro.org> References: <20250102182521.65428-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::434; envelope-from=philmd@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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Since tcg_cpu_reset_hold() is a system emulation specific helper, factor tcg_exec_reset() out so we can use it from user emulation, similarly to the [un]realize() handlers. Signed-off-by: Philippe Mathieu-Daudé --- accel/tcg/internal-common.h | 1 + accel/tcg/cpu-exec-common.c | 6 ++++++ accel/tcg/tcg-accel-ops.c | 4 ++-- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/accel/tcg/internal-common.h b/accel/tcg/internal-common.h index c8d714256cb..8b474fc1256 100644 --- a/accel/tcg/internal-common.h +++ b/accel/tcg/internal-common.h @@ -55,6 +55,7 @@ void cpu_restore_state_from_tb(CPUState *cpu, TranslationBlock *tb, bool tcg_exec_realizefn(CPUState *cpu, Error **errp); void tcg_exec_unrealizefn(CPUState *cpu); +void tcg_exec_reset(CPUState *cpu); /* current cflags for hashing/comparison */ uint32_t curr_cflags(CPUState *cpu); diff --git a/accel/tcg/cpu-exec-common.c b/accel/tcg/cpu-exec-common.c index 6ecfc4e7c21..72ab9c3d977 100644 --- a/accel/tcg/cpu-exec-common.c +++ b/accel/tcg/cpu-exec-common.c @@ -21,6 +21,7 @@ #include "system/cpus.h" #include "system/tcg.h" #include "qemu/plugin.h" +#include "exec/tb-flush.h" #include "internal-common.h" bool tcg_allowed; @@ -56,3 +57,8 @@ void cpu_loop_exit_atomic(CPUState *cpu, uintptr_t pc) cpu->exception_index = EXCP_ATOMIC; cpu_loop_exit_restore(cpu, pc); } + +void tcg_exec_reset(CPUState *cpu) +{ + tcg_flush_jmp_cache(cpu); +} diff --git a/accel/tcg/tcg-accel-ops.c b/accel/tcg/tcg-accel-ops.c index 6e3f1fa92b2..4fe6821b017 100644 --- a/accel/tcg/tcg-accel-ops.c +++ b/accel/tcg/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/translation-block.h" #include "gdbstub/enums.h" @@ -44,6 +43,7 @@ #include "tcg-accel-ops-mttcg.h" #include "tcg-accel-ops-rr.h" #include "tcg-accel-ops-icount.h" +#include "internal-common.h" /* common functionality among all TCG variants */ @@ -83,7 +83,7 @@ int tcg_cpu_exec(CPUState *cpu) static void tcg_cpu_reset_hold(CPUState *cpu) { - tcg_flush_jmp_cache(cpu); + tcg_exec_reset(cpu); tlb_flush(cpu); } From patchwork Thu Jan 2 18:25:21 2025 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: 13924817 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B3E7DE77188 for ; Thu, 2 Jan 2025 18:28:06 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tTPtt-0008OJ-7R; Thu, 02 Jan 2025 13:26:31 -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 1tTPtC-0008It-EZ for qemu-devel@nongnu.org; Thu, 02 Jan 2025 13:25:57 -0500 Received: from mail-wm1-x32b.google.com ([2a00:1450:4864:20::32b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tTPtA-0007uf-Kh for qemu-devel@nongnu.org; Thu, 02 Jan 2025 13:25:46 -0500 Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-4361fe642ddso122670965e9.2 for ; Thu, 02 Jan 2025 10:25:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1735842341; x=1736447141; 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=i5MZZuqxD622nryIdDAIydJBHEZPb4zzJ2vYHU+DCJU=; b=bMnCqYdYWqB2o7ydaitSVSzD4oJ0StbMctbwe0+M7ZXEO17SKuClaS1VV6M3nBRz9w S8PIcBAA0qmHvU2r3F3A3HwybTDXKyDJNDSZGF6CxbyK3ALkiAbszHiVst9MK9k/zExC ONPlPp8kjUdlwBFdcuTsKY1A+lhq/rU4ugHnymmRwnXl+r1AkX21+J2E91h5ZFREE4KF gcvqAYUwYW4aMJ1iH72+k76oVZaqzAvCeSSi1NqLsUHXYqPjw3C9RCQB/yih/bH0bP8h otwh6ZWav0uGo2w1FutrqfjBlcsN7Uv2yWEZRJgM7SiK6HlL32IUR7FJf7NyTQhjRVh9 TsEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735842341; x=1736447141; 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=i5MZZuqxD622nryIdDAIydJBHEZPb4zzJ2vYHU+DCJU=; b=q3L9Ynt87Y55bg3rB2shYZ9g9PAo97YPt2ZCjtcCr4iA/9EKRDlzbXpNo3bGEKSO0D AKGvzoE7MV7Q3doNWoDW89HTdCpfwKK71AJUaRs35tSQZDzM5jkT4pc+MJv9K7VMmzF/ D3RmjYpXXWSFm4K5VJ5NYdcXIVZQxg6Wn7CDUtqj04uh7d0UGt+D4L+AfEhZ3zjvCHfR PnffqpElJEYu+F4M7Ci4s0gfA0bbl4jwKTxVWmgOTqaKhGRxIZ+wUR9HLe6dWOMoKNkk wLpHlpAJ4oz2y7c89vEBC55KohJ2T5Vi8wHaA19qxRl4zCzXTmTihufNqQWou+TmSGBu Vn4A== X-Gm-Message-State: AOJu0YwKawbzFopRFVsGlua2O88fOVBhqGTdieSO0rKL300o3rd77cie xiFSZKv8ddkDwM63JOsvJkH062OvFJlW1ju55j3PAu3KC7n9cXh2tVQt9vx6F3iv+XlobYPdRPN IzPV1Ug== X-Gm-Gg: ASbGncvSZbgkWKR/zqvp6gcPqde3NGcMD3JCdy/pDzlkUvomfXiYakdzn3YCdu4z9Dm 0KVD2yMd8WMckUKTLLqST1biUrsZ81Kq9OwQY+Iw8LD0MWrVA3fgh919UbPDuZdSpFClfFWfkWo MGrGUXbk8++pkHtnlpr6+enkRoZOZRwxdkYwtus7ej94HQ8929xPrvoKBNbgGFYIFfXJmxp3eAT AiHTP0ZAPR9M3PmWPKn5IaG4dEyTNPN/iV3x83VATfoGNwC0CGnAi6miR4IOh/bYw6QCZw09SbY jtcwM183eBCyoi2OzG0ZrVLg/AQ29ZI= X-Google-Smtp-Source: AGHT+IEid+qm5vVH4qUyy9pqL4bxIijQTa/68t6jVfi6GChVFRq2uySRM+CVnJyIev3pDH7z3GTo0g== X-Received: by 2002:a05:600c:468f:b0:434:a30b:5455 with SMTP id 5b1f17b1804b1-43668b78728mr375470475e9.27.1735842340670; Thu, 02 Jan 2025 10:25:40 -0800 (PST) Received: from localhost.localdomain (88-187-86-199.subs.proxad.net. [88.187.86.199]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4366127c488sm459203545e9.27.2025.01.02.10.25.38 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 02 Jan 2025 10:25:39 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Ilya Leoshkevich , =?utf-8?q?Alex_Benn=C3=A9e?= , Paolo Bonzini , Pierrick Bouvier , Riku Voipio , Richard Henderson , Laurent Vivier , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH 3/3] accel/tcg: Implement cpu_exec_reset_hold() on user emulation Date: Thu, 2 Jan 2025 19:25:21 +0100 Message-ID: <20250102182521.65428-4-philmd@linaro.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250102182521.65428-1-philmd@linaro.org> References: <20250102182521.65428-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32b; envelope-from=philmd@linaro.org; helo=mail-wm1-x32b.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Commit bb6cf6f0168 ("accel/tcg: Factor tcg_cpu_reset_hold() out") wanted to restrict tlb_flush() to system emulation, but inadvertently also restricted tcg_flush_jmp_cache(), which was before called on user emulation via: Realize -> Reset -> cpu_common_reset_hold() Since threads (vCPUs) use a common CPUJumpCache, when many threads are created / joined, they eventually end re-using a CPUJumpCache entry, which was cleared when the first vCPU was allocated (via Realize) but then stayed dirty, leading to: Thread 1 "qemu-s390x" received signal SIGABRT, Aborted. __pthread_kill_implementation (threadid=, signo=signo@entry=6, no_tid=no_tid@entry=0) at ./nptl/pthread_kill.c:44 44 ./nptl/pthread_kill.c: No such file or directory. (gdb) bt #0 __pthread_kill_implementation (threadid=, signo=signo@entry=6, no_tid=no_tid@entry=0) at ./nptl/pthread_kill.c:44 #1 0x00007ffff7c41e8f in __pthread_kill_internal (signo=6, threadid=) at ./nptl/pthread_kill.c:78 #2 0x00007ffff7bf2fb2 in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26 #3 0x00007ffff7bdd472 in __GI_abort () at ./stdlib/abort.c:79 #4 0x00007ffff7bdd395 in __assert_fail_base (fmt=0x7ffff7d51a90 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=assertion@entry=0x5555556d71b8 "cpu->accel", file=file@entry=0x5555556d70e0 "cpu-target.c", line=line@entry=158, function=function@entry=0x5555556d7260 <__PRETTY_FUNCTION__.3> "cpu_exec_realizefn") at ./assert/assert.c:92 #5 0x00007ffff7bebeb2 in __GI___assert_fail (assertion=assertion@entry=0x5555556d71b8 "cpu->accel", file=file@entry=0x5555556d70e0 "cpu-target.c", line=line@entry=158, function=function@entry=0x5555556d7260 <__PRETTY_FUNCTION__.3> "cpu_exec_realizefn") at ./assert/assert.c:101 #6 0x00005555555d44ca in cpu_exec_realizefn (cpu=cpu@entry=0x5555557c28c0, errp=errp@entry=0x7fffffffe140) at cpu-target.c:158 #7 0x000055555559f50b in s390_cpu_realizefn (dev=0x5555557c28c0, errp=0x7fffffffe1a0) at target/s390x/cpu.c:261 #8 0x000055555563f78b in device_set_realized (obj=, value=, errp=0x7fffffffe2e0) at hw/core/qdev.c:510 #9 0x000055555564365d in property_set_bool (obj=0x5555557c28c0, v=, name=, opaque=0x5555557a9140, errp=0x7fffffffe2e0) at qom/object.c:2362 #10 0x0000555555646bbb in object_property_set (obj=obj@entry=0x5555557c28c0, name=name@entry=0x5555556e8ae2 "realized", v=v@entry=0x5555557c6650, errp=errp@entry=0x7fffffffe2e0) at qom/object.c:1471 #11 0x000055555564a45f in object_property_set_qobject (obj=obj@entry=0x5555557c28c0, name=name@entry=0x5555556e8ae2 "realized", value=value@entry=0x5555557a7a90, errp=errp@entry=0x7fffffffe2e0) at qom/qom-qobject.c:28 #12 0x0000555555647224 in object_property_set_bool (obj=0x5555557c28c0, name=name@entry=0x5555556e8ae2 "realized", value=value@entry=true, errp=errp@entry=0x7fffffffe2e0) at qom/object.c:1541 #13 0x000055555564027c in qdev_realize (dev=, bus=bus@entry=0x0, errp=errp@entry=0x7fffffffe2e0) at hw/core/qdev.c:291 #14 0x000055555559bb54 in cpu_create (typename=) at hw/core/cpu-common.c:57 #15 0x000055555559a467 in main (argc=4, argv=0x7fffffffeaa8, envp=) at linux-user/main.c:811 Have cpu_exec_reset_hold() call the common tcg_exec_reset() helper on user emulation, eventually calling tcg_flush_jmp_cache(). Fixes: bb6cf6f0168 ("accel/tcg: Factor tcg_cpu_reset_hold() out") Reported-by: Ilya Leoshkevich Signed-off-by: Philippe Mathieu-Daudé --- accel/tcg/user-exec-stub.c | 4 ---- accel/tcg/user-exec.c | 5 +++++ 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/accel/tcg/user-exec-stub.c b/accel/tcg/user-exec-stub.c index 4fbe2dbdc88..2dc6fd9c4e8 100644 --- a/accel/tcg/user-exec-stub.c +++ b/accel/tcg/user-exec-stub.c @@ -14,10 +14,6 @@ void qemu_init_vcpu(CPUState *cpu) { } -void cpu_exec_reset_hold(CPUState *cpu) -{ -} - /* User mode emulation does not support record/replay yet. */ bool replay_exception(void) diff --git a/accel/tcg/user-exec.c b/accel/tcg/user-exec.c index 0561c4f6dc7..92640f07ed7 100644 --- a/accel/tcg/user-exec.c +++ b/accel/tcg/user-exec.c @@ -40,6 +40,11 @@ __thread uintptr_t helper_retaddr; //#define DEBUG_SIGNAL +void cpu_exec_reset_hold(CPUState *cpu) +{ + tcg_exec_reset(cpu); +} + void cpu_interrupt(CPUState *cpu, int mask) { g_assert(bql_locked());