From nobody Sun Sep 28 16:28:05 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1758664538; cv=none; d=zohomail.com; s=zohoarc; b=MsJXlDak1kzlzIu1VTSUZfRqNBU5RZGolTuLKuO1NJSYGtsw7SewFrLDXUIBvta2tbKRLA+kU3+lNVqO/5u8SZwztMZkvbIPSuXCvV3NAQnH73EPA/YLhgfia+3GdRhFOxKCiNjrMu9C962FS6C+k121m6dmukEya9I8Ne7loDw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1758664538; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=tkajwB0LkhYnqCNRGrXzrsBCk6tFlVZCMEBA7S1wExk=; b=YVFgHS3jyxqcwMqjtPjtnbrScrPccVclaMfuXYZLimKk4mPHqLQIXnCMXXxRdYIXtoCirOGz6r7suuxXOvyide78Yntn3V1xUzmBdnrRyWFOpPzuf4Tk47r0RoeNx61Zgi3T7PZ6mqB6aqZIlJaWDsdRyh2DivpOWzfuwvllXjE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1758664538757262.217992466543; Tue, 23 Sep 2025 14:55:38 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v1Ay0-0006IE-SR; Tue, 23 Sep 2025 17:54:32 -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 1v1Axz-0006HK-D6 for qemu-devel@nongnu.org; Tue, 23 Sep 2025 17:54:31 -0400 Received: from mail-pl1-x630.google.com ([2607:f8b0:4864:20::630]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1v1Axx-0003i5-Aw for qemu-devel@nongnu.org; Tue, 23 Sep 2025 17:54:31 -0400 Received: by mail-pl1-x630.google.com with SMTP id d9443c01a7336-27d3540a43fso14420055ad.3 for ; Tue, 23 Sep 2025 14:54:28 -0700 (PDT) Received: from stoup.. ([71.212.157.132]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-269802e14f1sm168294035ad.71.2025.09.23.14.54.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Sep 2025 14:54:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1758664467; x=1759269267; 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=tkajwB0LkhYnqCNRGrXzrsBCk6tFlVZCMEBA7S1wExk=; b=JhDSt0f8eBFqqStdB35fEZ5T+mfDmbtS2GeENRHs8ek9woPzLYvpDW4v9dQ0o17Tb/ I+l43R91nAHbMn7hwPBeYRYWh/TOx912K1t2BX2+OY6QksFbKqNLZrY+dQpHCwbDknzs CYRWS/XaoIhoryL1hpd5B2YRU2+AE9DpKEtpXkVBL3Zm7t7urmCU3YikjU1fkGjPlofj w9KTtZ8BS1S4YQ3cslzyCiUqnx2Ltxnm106+LmlAdTPvomTEqyQhAr6w6XqOeavYaCde qQcWHkLyRCuBZldIz3sX8Gsv8H03ZHk3hmgG+r/WsyX55zfOBwjIjHfdpN7PTJti2m+E nL4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1758664467; x=1759269267; 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=tkajwB0LkhYnqCNRGrXzrsBCk6tFlVZCMEBA7S1wExk=; b=Ql67K1SQrOkSDqG6e3tvOqjaHHp8xLlWtdQPsGhB83dX87c5egiyeQ9G5bYH/T5K2H l6/mOqp+UbcMMgJNe0onzR3VbHCXPTZ641j1//Rq5k5mRQNR2lWo7rDHo2jBwEMDisEd Lm1ECrD/I7vMgtG8aHbdx7ml7LdlOUZCQBoiae8Oo7WFk+duDPbvARLKDadTkJC1WgtA oIuiKvmPU4+4mzfwbp89HIMBrqgCqYzqqIpnIw1/rLzw4Oq3HL5VLXQOT3qxrqt2CCn/ zwPQeRNn/Z2sTWk571vG8thmpTI0QYGiJR++Ve7dtEPtvQyWl6GzLXrsmWJ1SlisE6Sx 08TQ== X-Gm-Message-State: AOJu0YzLqvtT83ESUFy4/ZA6Ljazk7i5p9MtBvcvMbKtYVplRhkof/Qp qYASuyMSIz5bEFolcxou78GRfUwCMfpJqv5OowcFTJ6uT1ofRXYqNcbKlUMtKgpZ/EKQaZl6SiX 9JduB X-Gm-Gg: ASbGncup0Rqzjr5jz1sQH1GDDzf9TxSBJjIxrEr+/NlIaHqgYliMMgr5RKbxWeLqZNa ZvTJ3ZEsJZ/2FezDfaLchBFAtWwmZMQfq5qSvPRWIZHI+zbOQbFSG4tdgZSlOL879phq9H+uIuL K47uEMPAEYYADkzz1e4E1lstmnXdy+VU1FBElj3XP7y5/f6L1NEDKLAX3DjxtCGKqbErJsKF3q0 BN8RETwZErekAM0zHPYa6BN4raMvkt3fUfKIjEHAgngRcohqzJb1VZyHU4OwfJ3jdwJTRfZPVgF lyV1sWRYKVZc222EjxTyQWAXj5SfzyTTJlV8GSPfCzNEF3U5E8E6Uzb/xgXngC3AUMqZR0FvpJd 2ySSuYJhxR4TQ7/GgN1G2ju38vqMI X-Google-Smtp-Source: AGHT+IF4e25HHdHJP6TzFOqjb9YsyfUad9ing6qbxJI5i0wA8W92TtkHxS17NU2WHQK+hZ+H7XXcew== X-Received: by 2002:a17:902:e951:b0:25c:76f1:b024 with SMTP id d9443c01a7336-27cc24e015cmr45815735ad.25.1758664467465; Tue, 23 Sep 2025 14:54:27 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Pierrick Bouvier Subject: [PATCH v3 01/10] gdbstub: Remove tb_flush uses Date: Tue, 23 Sep 2025 14:54:15 -0700 Message-ID: <20250923215425.3685950-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250923215425.3685950-1-richard.henderson@linaro.org> References: <20250923215425.3685950-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::630; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x630.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1758664539735116600 Content-Type: text/plain; charset="utf-8" This hasn't been needed since d828b92b8a6 ("accel/tcg: Introduce CF_BP_PAGE"). Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- gdbstub/system.c | 5 ----- gdbstub/user.c | 3 --- 2 files changed, 8 deletions(-) diff --git a/gdbstub/system.c b/gdbstub/system.c index 5be0d3c58c..5221c579d9 100644 --- a/gdbstub/system.c +++ b/gdbstub/system.c @@ -18,13 +18,11 @@ #include "gdbstub/syscalls.h" #include "gdbstub/commands.h" #include "exec/hwaddr.h" -#include "exec/tb-flush.h" #include "accel/accel-ops.h" #include "accel/accel-cpu-ops.h" #include "system/cpus.h" #include "system/runstate.h" #include "system/replay.h" -#include "system/tcg.h" #include "hw/core/cpu.h" #include "hw/cpu/cluster.h" #include "hw/boards.h" @@ -174,9 +172,6 @@ static void gdb_vm_state_change(void *opaque, bool runn= ing, RunState state) } else { trace_gdbstub_hit_break(); } - if (tcg_enabled()) { - tb_flush(cpu); - } ret =3D GDB_SIGNAL_TRAP; break; case RUN_STATE_PAUSED: diff --git a/gdbstub/user.c b/gdbstub/user.c index 67403e5a25..2e14ded3f0 100644 --- a/gdbstub/user.c +++ b/gdbstub/user.c @@ -15,7 +15,6 @@ #include "qemu/sockets.h" #include "qapi/error.h" #include "exec/hwaddr.h" -#include "exec/tb-flush.h" #include "exec/gdbstub.h" #include "gdbstub/commands.h" #include "gdbstub/syscalls.h" @@ -220,7 +219,6 @@ int gdb_handlesig(CPUState *cpu, int sig, const char *r= eason, void *siginfo, =20 /* disable single step if it was enabled */ cpu_single_step(cpu, 0); - tb_flush(cpu); =20 if (sig !=3D 0) { gdb_set_stop_cpu(cpu); @@ -539,7 +537,6 @@ static void disable_gdbstub(CPUState *thread_cpu) /* no cpu_watchpoint_remove_all for user-mode */ cpu_single_step(cpu, 0); } - tb_flush(thread_cpu); } =20 void gdbserver_fork_end(CPUState *cpu, pid_t pid) --=20 2.43.0 From nobody Sun Sep 28 16:28:05 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1758664543; cv=none; d=zohomail.com; s=zohoarc; b=PuUngfgM2IDN+CDuBRzwtgGABI9vrGi7Ywb/1kgnqSIPiSbN5etNGexRH9BqE15ZmVPN9uKYWIs6VVDW3Qat837ANO93WdW9voSPYLT2ZXat9QTjQNlQXanoQoy1mzIeQaJWrF9coBZ38Aed+YtotWyWJbr1/Ia0m+LJd+TcYzs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1758664543; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=ZamIB9qOqLDXfHWztLFTsDY1Wf4aDJfUVKiJDrru8TA=; b=VAdUjST1SZAZkvO92nE3eUmFQj4ofJSV3QzB/78tK1Io2EApxISo0d1cNJv9erLMGxw9U42aivmbY7v8IoEueHxCfHeqdQVCjLSdu/6lXQHioiVYuFuHOeicTazwEvXP/pW78njK7QlIDj/YkKOsohdSx17IGJu/R55x+/a5Qbw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1758664543525790.8261277768609; Tue, 23 Sep 2025 14:55:43 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v1Ay2-0006Iq-A8; Tue, 23 Sep 2025 17:54:34 -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 1v1Ay0-0006Ha-De for qemu-devel@nongnu.org; Tue, 23 Sep 2025 17:54:32 -0400 Received: from mail-pl1-x629.google.com ([2607:f8b0:4864:20::629]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1v1Axx-0003i8-WB for qemu-devel@nongnu.org; Tue, 23 Sep 2025 17:54:31 -0400 Received: by mail-pl1-x629.google.com with SMTP id d9443c01a7336-267fac63459so57534235ad.1 for ; Tue, 23 Sep 2025 14:54:29 -0700 (PDT) Received: from stoup.. ([71.212.157.132]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-269802e14f1sm168294035ad.71.2025.09.23.14.54.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Sep 2025 14:54:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1758664468; x=1759269268; 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=ZamIB9qOqLDXfHWztLFTsDY1Wf4aDJfUVKiJDrru8TA=; b=NP3LyLsc82v/I5+Hjom25xl/WszN0Z4g84X+yiQW/Wbx5SkbA3BcYgiY3hNBUciyrA Xt+fITrASCb7FdkJJZSszdV8FQ+zuvOMxc8WD6c6GcN1ocJG6IkQrfkW0xYA8AQGs6II fZI2NpQebQ6knUleT2ZA/wBRHjo0gxp2IcR7AY4VKrEI5wqicoGHcSrdZogKDEvVvnki c1McIFvgoeM4SWkIrVg9MJePqCDNxnC8eRpK/R6jMa6GwO5snTRfzmLqRhGeCr5UdWjE 0MbEJqV9hsNNwsYl7iLVQoP3MSK2+YpMHFRp5vL9DMnvhEvKbfb4KoTE3bTfs1MNJFbE 9Qag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1758664468; x=1759269268; 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=ZamIB9qOqLDXfHWztLFTsDY1Wf4aDJfUVKiJDrru8TA=; b=CDil/fAm6DDoxzGRKvGXToxPasMfC02mbVNSVypf24jfp7Huyu266tCbCvmxAH98Jq 4BRnbGtWOtK+xoSMpJUvkkUeOksHbpniHYNe0UQqFpaifscZQ939tQE2SEZxZ1HyJj62 xCAE7P4+jOFW6V/SlM3Kmt7H5IubuIg9b7U9DzbOEvVz7pMziOUEIGaeC/xu8tGg3Fmb 9Jt2q6RmiZiRZBmpSqb5Kctw5rlodhWWznOtDwpmBwk6u9mZVcntErlRbEJuC8PHozDg QEoZrWcmzDgQjW5cq6fZVT9g475m0xYLJRBg0VoEjIrCKofQ/yFOMo9nrXSt26DmlKc6 hXjQ== X-Gm-Message-State: AOJu0YwF6uNqO9RunRyP/oWIY+bwXPb3kmY+9dE3RHmV0wLE1dxkahAI g1YIiDnUJWIjnIeYgm2BpPZCXpCuuhZJIZd5lLWpSoSHK+r1xnLXzfc53yqao24jWFKFn7uu3IU B1PCr X-Gm-Gg: ASbGnct/EaM9hgtlRXxM42gM5ZFWwI2GVSJMhJ959QLZQtqZckhrZ6MTDK6UIpnB3+F 0cRRt/c8Ll9rIwYcpGMI8Ca4yeV32C+2uJAOYUdqg8L/7zgvk+IL1tCpDk0Pd/DJnT40jT2rWwG VKdUTWdHUcAKXzh3Ce32cJxyJ8LBv+yH+cPWfDSdqChTrSQw8V65DlO9UK4NnRry7SxoDyTXied JQ+8lXbBrFclddCfnL8m+bztix2dClMvEX3hzXmBl9fXOgFiRzwMN0Ehi4zhLr8k2rQjP1py51X yPyTF4M1q6KFq+/PG1jHQDjJINStHWO+nnit9yzvujUguKOlc6UFCf6o1XZJi+cuIHOh9RYXYT/ 5/YhNZ05zGBimxWul6wWFOcx+G92v X-Google-Smtp-Source: AGHT+IH+c5Yk+YV6LrcH+gh1k70ihRRGyDu721kqleWbyAhx5u+mjm0kl0vz6F5eZByJEj6mfD1GRQ== X-Received: by 2002:a17:903:1107:b0:267:b0e4:314e with SMTP id d9443c01a7336-27cc2c9a0c3mr51670835ad.23.1758664468282; Tue, 23 Sep 2025 14:54:28 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v3 02/10] target/alpha: Simplify call_pal implementation Date: Tue, 23 Sep 2025 14:54:16 -0700 Message-ID: <20250923215425.3685950-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250923215425.3685950-1-richard.henderson@linaro.org> References: <20250923215425.3685950-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::629; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x629.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1758664545671116600 Since 288a5fe980f, we don't link translation blocks directly to palcode entry points. If we load palbr from env instead of encoding the constant, we avoid all need for tb_flush(). Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson --- target/alpha/helper.h | 1 - linux-user/alpha/cpu_loop.c | 5 ----- target/alpha/sys_helper.c | 6 ------ target/alpha/translate.c | 21 ++++++--------------- 4 files changed, 6 insertions(+), 27 deletions(-) diff --git a/target/alpha/helper.h b/target/alpha/helper.h index d60f208703..788d2fbf28 100644 --- a/target/alpha/helper.h +++ b/target/alpha/helper.h @@ -90,7 +90,6 @@ DEF_HELPER_FLAGS_2(ieee_input_s, TCG_CALL_NO_WG, void, en= v, i64) #if !defined (CONFIG_USER_ONLY) DEF_HELPER_FLAGS_1(tbia, TCG_CALL_NO_RWG, void, env) DEF_HELPER_FLAGS_2(tbis, TCG_CALL_NO_RWG, void, env, i64) -DEF_HELPER_FLAGS_1(tb_flush, TCG_CALL_NO_RWG, void, env) =20 DEF_HELPER_1(halt, void, i64) =20 diff --git a/linux-user/alpha/cpu_loop.c b/linux-user/alpha/cpu_loop.c index bb8346b509..f93597c400 100644 --- a/linux-user/alpha/cpu_loop.c +++ b/linux-user/alpha/cpu_loop.c @@ -94,11 +94,6 @@ void cpu_loop(CPUAlphaState *env) break; case 0x86: /* IMB */ - /* ??? We can probably elide the code using page_unprotect - that is checking for self-modifying code. Instead we - could simply call tb_flush here. Until we work out the - changes required to turn off the extra write protection, - this can be a no-op. */ break; case 0x9E: /* RDUNIQUE */ diff --git a/target/alpha/sys_helper.c b/target/alpha/sys_helper.c index 51e3254428..87e37605c1 100644 --- a/target/alpha/sys_helper.c +++ b/target/alpha/sys_helper.c @@ -20,7 +20,6 @@ #include "qemu/osdep.h" #include "cpu.h" #include "exec/cputlb.h" -#include "exec/tb-flush.h" #include "exec/helper-proto.h" #include "system/runstate.h" #include "system/system.h" @@ -38,11 +37,6 @@ void helper_tbis(CPUAlphaState *env, uint64_t p) tlb_flush_page(env_cpu(env), p); } =20 -void helper_tb_flush(CPUAlphaState *env) -{ - tb_flush(env_cpu(env)); -} - void helper_halt(uint64_t restart) { if (restart) { diff --git a/target/alpha/translate.c b/target/alpha/translate.c index cebab0318c..f11b382438 100644 --- a/target/alpha/translate.c +++ b/target/alpha/translate.c @@ -48,8 +48,6 @@ struct DisasContext { =20 #ifdef CONFIG_USER_ONLY MemOp unalign; -#else - uint64_t palbr; #endif uint32_t tbflags; int mem_idx; @@ -1155,7 +1153,6 @@ static DisasJumpType gen_call_pal(DisasContext *ctx, = int palcode) #else { TCGv tmp =3D tcg_temp_new(); - uint64_t entry; =20 gen_pc_disp(ctx, tmp, 0); if (ctx->tbflags & ENV_FLAG_PAL_MODE) { @@ -1165,12 +1162,11 @@ static DisasJumpType gen_call_pal(DisasContext *ctx= , int palcode) } tcg_gen_st_i64(tmp, tcg_env, offsetof(CPUAlphaState, exc_addr)); =20 - entry =3D ctx->palbr; - entry +=3D (palcode & 0x80 - ? 0x2000 + (palcode - 0x80) * 64 - : 0x1000 + palcode * 64); - - tcg_gen_movi_i64(cpu_pc, entry); + tcg_gen_ld_i64(cpu_pc, tcg_env, offsetof(CPUAlphaState, palbr)); + tcg_gen_addi_i64(cpu_pc, cpu_pc, + palcode & 0x80 + ? 0x2000 + (palcode - 0x80) * 64 + : 0x1000 + palcode * 64); return DISAS_PC_UPDATED; } #endif @@ -1292,11 +1288,7 @@ static DisasJumpType gen_mtpr(DisasContext *ctx, TCG= v vb, int regno) case 7: /* PALBR */ tcg_gen_st_i64(vb, tcg_env, offsetof(CPUAlphaState, palbr)); - /* Changing the PAL base register implies un-chaining all of the T= Bs - that ended with a CALL_PAL. Since the base register usually on= ly - changes during boot, flushing everything works well. */ - gen_helper_tb_flush(tcg_env); - return DISAS_PC_STALE; + break; =20 case 32 ... 39: /* Accessing the "non-shadow" general registers. */ @@ -2874,7 +2866,6 @@ static void alpha_tr_init_disas_context(DisasContextB= ase *dcbase, CPUState *cpu) ctx->ir =3D cpu_std_ir; ctx->unalign =3D (ctx->tbflags & TB_FLAG_UNALIGN ? MO_UNALN : MO_ALIGN= ); #else - ctx->palbr =3D env->palbr; ctx->ir =3D (ctx->tbflags & ENV_FLAG_PAL_MODE ? cpu_pal_ir : cpu_std_i= r); #endif =20 --=20 2.43.0 From nobody Sun Sep 28 16:28:05 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1758664517; cv=none; d=zohomail.com; s=zohoarc; b=ejgfYtNJDE8gvyYgnCEr79OrNK4zM030naFPAZr/gTO86YlVbZ32yUCSivvZCH5u3X8I7UOrNghVeBT6npR+e2omCn6Ku3phc7WdowqzB/T9vhVrKBbhfcVjHciOBmJNqwrmjtDpHjmv9wHzUYGsv5NYJ39t4wY5+kjDV/CJ06I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1758664517; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=hhvyGjhjUkCNEHZh1gnQZUsirw8YiHVeIFO9VlHtSAY=; b=BjPq4IOMP349CsR+x/ufbXrrFahJGfzRGPJcEZf6xXjx3rZw5rStUMMz3eBX2ErJBxWhziEqo1zLU4a5veAm+GT4+lF1XtknHfHHNWbTfRbPGA8lHpivnztjixmYNvTJotBx6nHy4X9kuMM+ri2fu6zvGlTfQCtU6RluGwiV75w= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1758664517797502.78779311161395; Tue, 23 Sep 2025 14:55:17 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v1Ay5-0006KG-OD; Tue, 23 Sep 2025 17:54:37 -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 1v1Ay0-0006Hg-Hn for qemu-devel@nongnu.org; Tue, 23 Sep 2025 17:54:32 -0400 Received: from mail-pl1-x62f.google.com ([2607:f8b0:4864:20::62f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1v1Axy-0003iB-OT for qemu-devel@nongnu.org; Tue, 23 Sep 2025 17:54:32 -0400 Received: by mail-pl1-x62f.google.com with SMTP id d9443c01a7336-267facf9b58so44832705ad.2 for ; Tue, 23 Sep 2025 14:54:30 -0700 (PDT) Received: from stoup.. ([71.212.157.132]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-269802e14f1sm168294035ad.71.2025.09.23.14.54.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Sep 2025 14:54:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1758664469; x=1759269269; 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=hhvyGjhjUkCNEHZh1gnQZUsirw8YiHVeIFO9VlHtSAY=; b=AWk+E3MJVypdb0Q8LFQSvRnrbHSoT61Rg7Rgfs/OSpKa1nHAn8dHKILfurr/S2Mc6Z 3mIet07bHVU3F4cSuUrgLngi/jferYln0ERyW90k6W0l+NCTqIBZCCfXcdmcbgYEoFMz QhOo2H5G6PnLjN6y8Osz0pCXbtTW6OEo/Z4s9szT0xPMyToTgl63DyBS7ffoRLPPVkbZ /xf7FJ0TEmZ6Ldv87IBQsiX4TC5JrwIVv8/2V9SfKMjv6lPI0716vsebOJwCtyW7P29f 2t+ueoMfngFlTrNtpdstFj48yp4b9n15QXqOaC30bSov2lN6SP31qVLEQdF5m4XTA+A3 pP6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1758664469; x=1759269269; 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=hhvyGjhjUkCNEHZh1gnQZUsirw8YiHVeIFO9VlHtSAY=; b=F1GmlrzTXvxEhoXcPw+J3a3ngM7tIc5NfD/sEtqcLbeGNos5x+xGPEDZM6C1fh7GHe HMvx5H1hX68KHrNTKKqUnX2JKdhtJxbS+taoChQPQ2369uSQKrDovlwKbMTWJ+83u6Ox 9b30ZkzFbBpEOD6l/5KajIrJeywTvUswRN6wp2I2lvgb1DzzvR4dk8GBeGhzwKUx+Z2X VeUbuQREJo4NxZ3TmmeOM/3ItF7WPDc1hMuEGz/5tqX91YMShMenR6e3xYXjPmdQYim2 tAq7f3ZtKpJizY/eTKFR3dLrnKJsf2TeJNn6QOGSFFqRTksMJQDBYLO7dJFgdt6nvuEL fz8w== X-Gm-Message-State: AOJu0YwCETh13yEJ4s3OrAlRvCzEq0OrIsjWAtGtQJgfYkUR7GMycO0i hjFPZ7QPZWIffTVZNsdJmmBw2PU1jw9HURLb8/ThtCF7qoexmaiveiwGqmLjYoGMFLZ6Q4KiovE 0W0ZR X-Gm-Gg: ASbGncvyKyd1hup34UliwFWW03eFH3I0xQT0aryOJGUqimCDhjxWkEduAp4lbbgzyeV I2Rfr9MGQmciT+XzQyirHELm/Ha8xQi/zXk/EMKnj+8pIaxqpNQXncmtkave9XzsIwnHI/YhSFk 2zsZrfUL8GJ0+SnF3YSScuSKHRV7/rbTlVrFqoTWUFqandOXyFRODjE1ZlW2s6/iAh5j26N8EsM xAoXZMmS5oXkVsOCKajJlZi6SeIpffSAJR6td9xIH1xSbthAwuYFTcuxaGPKBz3W4v/qV1XfM3B 2hkcm26B6OsIyevdQXqxaSGkDwp+Q60bpjsF7fAWOqblh5DW39c9wU+ZW3pyQG/eU8F3uS65Tmb GIv2bs8gjLSKdFZ5H9v1trEZWvq9m X-Google-Smtp-Source: AGHT+IEn5Oxb4i7FOn1Fa1bspf261Rtx1+QilAne9nm+qkS/xMq3hv8VeYEzqIOg+U/w2wEG5n8rpA== X-Received: by 2002:a17:902:e84f:b0:26a:589b:cf11 with SMTP id d9443c01a7336-27cc678387amr56335895ad.43.1758664469096; Tue, 23 Sep 2025 14:54:29 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Pierrick Bouvier Subject: [PATCH v3 03/10] target/riscv: Record misa_ext in TCGTBCPUState.cs_base Date: Tue, 23 Sep 2025 14:54:17 -0700 Message-ID: <20250923215425.3685950-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250923215425.3685950-1-richard.henderson@linaro.org> References: <20250923215425.3685950-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::62f; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62f.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1758664519642116600 Content-Type: text/plain; charset="utf-8" The tb_flush within write_misa was incorrect. It assumed that we could adjust the ISA of the current processor and discard all TB and all would be well. But MISA is per vcpu, so globally flushing TB does not mean that the TB matches the MISA of any given vcpu. By recording misa in the tb state, we ensure that the code generated matches the vcpu. Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- target/riscv/csr.c | 3 --- target/riscv/tcg/tcg-cpu.c | 3 ++- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/target/riscv/csr.c b/target/riscv/csr.c index 8842e07a73..3c8989f522 100644 --- a/target/riscv/csr.c +++ b/target/riscv/csr.c @@ -25,7 +25,6 @@ #include "pmu.h" #include "time_helper.h" #include "exec/cputlb.h" -#include "exec/tb-flush.h" #include "exec/icount.h" #include "accel/tcg/getpc.h" #include "qemu/guest-random.h" @@ -2173,8 +2172,6 @@ static RISCVException write_misa(CPURISCVState *env, = int csrno, env->mstatus &=3D ~MSTATUS_FS; } =20 - /* flush translation cache */ - tb_flush(env_cpu(env)); env->xl =3D riscv_cpu_mxl(env); return RISCV_EXCP_NONE; } diff --git a/target/riscv/tcg/tcg-cpu.c b/target/riscv/tcg/tcg-cpu.c index 78fb279184..143ab079d4 100644 --- a/target/riscv/tcg/tcg-cpu.c +++ b/target/riscv/tcg/tcg-cpu.c @@ -191,7 +191,8 @@ static TCGTBCPUState riscv_get_tb_cpu_state(CPUState *c= s) =20 return (TCGTBCPUState){ .pc =3D env->xl =3D=3D MXL_RV32 ? env->pc & UINT32_MAX : env->pc, - .flags =3D flags + .flags =3D flags, + .cs_base =3D env->misa_ext, }; } =20 --=20 2.43.0 From nobody Sun Sep 28 16:28:05 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1758664571; cv=none; d=zohomail.com; s=zohoarc; b=kw2a7rkIg4lteJEIiXdZutFNS0rZjm/b5chpOjgzO3gsP+g7wxqGeXS6S7SI2g6htk4YnAs5CY0gisJFfpZIxD8lLNTr+ptXXn3/OOPOvGlQKVd3sJKjnJsncGwaUqj816iWXlmK/+e+ERN0ZUv0oleGQNA6xDR6CkpkGTM9Hp4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1758664571; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=bI01yo0kUGWJmBVW9EA2Eo0iWFIm1s7La1lCDq4SBkA=; b=Hhu7morWZVtiS57N9dQ6x6LouUm7ioyeI3v9phLpWPaxry/7/G1zBQfu5KdwL4KHQGkS6X39Y/AueOE4f8tEEWvIaXqjA9JI1Z7moUrQmr3Erksqgyt9IKmAjUZk3SoB8Mq2iv2F9woFkrgHWGQnlUPX42rJt9ozYqgFeOFZ3ps= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1758664571212263.1859517258713; Tue, 23 Sep 2025 14:56:11 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v1Ay3-0006JL-Pd; Tue, 23 Sep 2025 17:54:35 -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 1v1Ay0-0006IK-Qq for qemu-devel@nongnu.org; Tue, 23 Sep 2025 17:54:32 -0400 Received: from mail-pl1-x631.google.com ([2607:f8b0:4864:20::631]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1v1Axz-0003iG-6m for qemu-devel@nongnu.org; Tue, 23 Sep 2025 17:54:32 -0400 Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-2570bf6058aso82387525ad.0 for ; Tue, 23 Sep 2025 14:54:30 -0700 (PDT) Received: from stoup.. ([71.212.157.132]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-269802e14f1sm168294035ad.71.2025.09.23.14.54.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Sep 2025 14:54:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1758664470; x=1759269270; 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=bI01yo0kUGWJmBVW9EA2Eo0iWFIm1s7La1lCDq4SBkA=; b=qdOAGKq7VMRi2rtVVHF6ehiP0tuEl6ke3+5CsTA7/c9ls/rKj+ySkKYMyazZmIgYj0 DId5UsrtCezR/W+cLLh7dqqM9geW6pJGoEpQho/IlX2VUCBilrP+wWNRj0yn4hMCPRhG BHfZhuGAT0r/YeyBI1gDJFQkoZ8gTXjZkWSF9t7gkrNX2MykDCUfBlVPuWSdrmqEJOZF d0hKB4xuAkp5faegKjuPam6xfhF4D9GqsvTnu+rxsoZq/Copgy35bi6exnNtOK9xsp7P V1xW8T8qEsmyG3XzMNjEHxc14UJ6UnT65hDMlaAYMk9c3R0cA/wfGe/lgs8gKGHlhDuX zkHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1758664470; x=1759269270; 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=bI01yo0kUGWJmBVW9EA2Eo0iWFIm1s7La1lCDq4SBkA=; b=rS3AQEkV4I7SuLPsgwm6myKdmh2twnJa5+ycqDK5/YUtDlKzr/fDXOuskHHoJDMPMC d2fgGFn4HWzRLKQN4CzACtDH1hno9heu5+2SAylo2Qq9ckFmBGUjX+F+jI/9xgx5Y5vX igS7k9qt2CJxqAWZU45HBQ3/4MpH0O6olIBQEUeE0yvhnBerOVp4OplRNYnMEMbBLiTH LY1jTUPKEgkpiCY7PATbjL3i7RhguoMr8Nz/zNXJ9PUD1O1ShPj5UW+LjU+H9enJSm/g 6z/nU5hsiv8xpodRYjQCfC+NH3DWr4GKDrlJEsNVY0/lpa8vCGg2R4h3Prf3mLpEXIMZ TemQ== X-Gm-Message-State: AOJu0YxHeIxke/itiK4aBddYSwY86sS3BFNlvlTYIdx+/raew2JU+26u 1860+yAO6fTh2cGzyHGkVdSRFMkYWG/vPZ4bS5x9FS7UsR/KQKuvgmxOSPEhpLPZ4AOEgSq//yc swAQB X-Gm-Gg: ASbGncubHzsyMvRGBtSsqp/frpIkd4APA64qY79sdikB8I+QJWUHCdRAWzxvY4DhtE8 +MjnO+VPZJhujrmlS+7ZtkSnSsjhU6BAn8aEl+LrbHURWnEG0FCtqhoOgQVrUejCBEYekAwUO/N hC0Ws4Tqwcp0B9Wvoc56kkz+JCmqUKwCUDfFcBqpIMYPNV0j5/Yqq9OVGA/lpoVa6oHLvVvtCsJ elQedmpMLYI7zfKXmYPrsSAj8T36LdZmPTqJG20aADWQUrA4fyniGqAiuG2S2/6DbmPfrCQlYzz +wKtFiOwem/Nc1lHzVRBzUwTyV249PtcIPnBqYv9FyXTkxNMHaDdr87Vo8/ZKMG+OxMOqw40YX6 X9HlJbLCfqimZpMixY+2WrBjhZdGm X-Google-Smtp-Source: AGHT+IHcYuBbcewqNEI3mRL74jOEb3uZRLQBgpWk7nlFGZ6+LNRdunme5Cfzda+pGBZh40NHotPVxg== X-Received: by 2002:a17:903:3c25:b0:26b:3aab:f6b8 with SMTP id d9443c01a7336-27cc98a13f3mr54679475ad.58.1758664469764; Tue, 23 Sep 2025 14:54:29 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Harsh Prateek Bora Subject: [PATCH v3 04/10] hw/ppc/spapr: Use tb_invalidate_phys_range in h_page_init Date: Tue, 23 Sep 2025 14:54:18 -0700 Message-ID: <20250923215425.3685950-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250923215425.3685950-1-richard.henderson@linaro.org> References: <20250923215425.3685950-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::631; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x631.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1758664571763116600 Content-Type: text/plain; charset="utf-8" We only need invalidate tbs from a single page, not flush all translations. Reviewed-by: Harsh Prateek Bora Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hw/ppc/spapr_hcall.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/ppc/spapr_hcall.c b/hw/ppc/spapr_hcall.c index c594d4b916..8c1e0a4817 100644 --- a/hw/ppc/spapr_hcall.c +++ b/hw/ppc/spapr_hcall.c @@ -8,7 +8,7 @@ #include "qemu/main-loop.h" #include "qemu/module.h" #include "qemu/error-report.h" -#include "exec/tb-flush.h" +#include "exec/translation-block.h" #include "exec/target_page.h" #include "helper_regs.h" #include "hw/ppc/ppc.h" @@ -301,7 +301,7 @@ static target_ulong h_page_init(PowerPCCPU *cpu, SpaprM= achineState *spapr, if (kvm_enabled()) { kvmppc_icbi_range(cpu, pdst, len); } else if (tcg_enabled()) { - tb_flush(CPU(cpu)); + tb_invalidate_phys_range(CPU(cpu), dst, dst + len - 1); } else { g_assert_not_reached(); } --=20 2.43.0 From nobody Sun Sep 28 16:28:05 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1758664517; cv=none; d=zohomail.com; s=zohoarc; b=BTvYUO5zaCy+546deL3gEXTPOx0pi+11CGpzlQcx886LcNMDrG5xbi6CSM9HYx/ZfsZS7gHG372mFA4DtrpgRpdgPLdOL6FJ/47xJ47EKOujhwvRv4odP1LIBpbeSjPAYaXKjpMqeNeIPT/lgs5sDcENPgBtXR7HXehAu99Oa+c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1758664517; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=bUBd7tS/TsoOS8gEfUczns3Sij2rmJYe3yGqDRcLhFc=; b=Coe3eIBuQwOSxllcbiXc+T9bH8nu/bjEcl0CNbgeij9k/qLsnSlalfXA36Ugpdl0fKEzN/Bvc5TtcIQq4dWOx54taQTkZ6YVFTr68zJ2HkQXhoB6t6h97lY/bnOU5bd/SYIJh8M22PUEUAsLNItTTYQtgYYBqEwGEcAx1apisV4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1758664517412838.3637492157486; Tue, 23 Sep 2025 14:55:17 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v1Ay4-0006Js-Fy; Tue, 23 Sep 2025 17:54:36 -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 1v1Ay2-0006Ih-0Z for qemu-devel@nongnu.org; Tue, 23 Sep 2025 17:54:34 -0400 Received: from mail-pg1-x534.google.com ([2607:f8b0:4864:20::534]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1v1Ay0-0003iV-5o for qemu-devel@nongnu.org; Tue, 23 Sep 2025 17:54:33 -0400 Received: by mail-pg1-x534.google.com with SMTP id 41be03b00d2f7-b555b0fb839so1556845a12.3 for ; Tue, 23 Sep 2025 14:54:31 -0700 (PDT) Received: from stoup.. ([71.212.157.132]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-269802e14f1sm168294035ad.71.2025.09.23.14.54.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Sep 2025 14:54:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1758664470; x=1759269270; 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=bUBd7tS/TsoOS8gEfUczns3Sij2rmJYe3yGqDRcLhFc=; b=dDwvkof6Nd04Pa4pcCJM/pFa23sx+sZzHV36E8Xg5x0esQS3L54j0ZSnnjTMTMtelx /JYEgvZjjv69lOfwqTAgKADTtKxTmQT28/iqLv6Ibquy1iL9oCVcYNLrmMtoUc0Uboyd FuTOA59HzKOLuTvdGpNgPd8KQYEQucnJJI8wuP2ZBvUge+mI6GNWsHxUCp7UB6+lxJJN n5cMcfVqILEi8TrZZTuP0Fs40RZUancs7Rcdp+wWkNOSN+DvEir+w3OWVVjVqfXNhEv8 PRS8xbH8BCzO8OqMDYKvgVrLE3gzoHyiz+K7Q3FFvtSTjaBvfVhD5aCMvToqhWBZKA7Q 5Stw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1758664470; x=1759269270; 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=bUBd7tS/TsoOS8gEfUczns3Sij2rmJYe3yGqDRcLhFc=; b=v3b70KWwFygSJTKF1XGWiV2/h+jxFipd93sImWqoAYVIOo/sW0ho+BCNcfdWfBg2cK PcwskOUZ5jqTIx8EIn9AyC87552icrK78zVzD93mWFKY/+KTcasawyXWgD097kT6tkDP a53o1/KZaPODPva4m8lMv5XSmbrpWpqnV50PaxLgdlP0/HVVe9swi6HRY4aZQQPh5OOz Gu82msYOcWIZzMSsV+yCTUVQjk6ezkSOMWm0GKQdspCrJ09Cop60EpTMJKpHM5JUezmF E/CeIBGZrqXgMkeoeH+5IAnSU3uNM14+PSYypKU00Uj1BTxo5/G98m3900oZ2s81Dfal l59Q== X-Gm-Message-State: AOJu0Yxc+Dholy24wxqBiaVUf05OEgIA6zUueXrrPstG/4zcMl2AjBVY 2OFnd0Rf4VUKSZp0u5o0Ne08+m0CpTQmWt5ofDVpoA2HkzgGzcbQ+fYANAMJCBRSDMDNr83C6Ag 0w38C X-Gm-Gg: ASbGncu0EpPVkbKqJBL9aJWrWLpvhPdQv8VASUSjABZnLPMXNJdk5kPSPRQTms7Ll6N 2rhTq7sjAhqfofKCEGimyRbWupXH6D2kfwXPjk1rqi+vdSjt1R1n/pTYYj1gL9fFAAMNoHu6RsE soh4MzOdBubvT/6Y5A/n8vXWhD80E2fMQAU7bLnKlZlqybg4RTkex+9iIDMa2b/av0bVTvFxsj5 Q3GfR9OS/0tKG9GmZpmBKypHEfVo00bXxvRVapbQRiSvQb1WEjDZFD2pfYVeO2GyMbKYpxFH0sB LxD9j+dY9DMBg4Wbyl02GBEyFUXLwfEm1oSw3ZRwnlS5wPatmLs4isW5JQjk/bA4gvqJPwACasC OelXjxcmge0yf1x5za2d3QdmzHnSu X-Google-Smtp-Source: AGHT+IEhHgnBjwlDLeIy4g++0rZqmNsZg4l2sAa4hSJA2xaRjwZ/Dvbgyw/f+ZgsB6TUWAxDYivMfg== X-Received: by 2002:a17:903:190:b0:277:9193:f2da with SMTP id d9443c01a7336-27cc0dbb137mr51075005ad.5.1758664470467; Tue, 23 Sep 2025 14:54:30 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Pierrick Bouvier Subject: [PATCH v3 05/10] accel/tcg: Split out tb_flush__exclusive_or_serial Date: Tue, 23 Sep 2025 14:54:19 -0700 Message-ID: <20250923215425.3685950-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250923215425.3685950-1-richard.henderson@linaro.org> References: <20250923215425.3685950-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::534; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x534.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1758664519706116600 Content-Type: text/plain; charset="utf-8" Expose a routine to be called when no cpus are running. Simplify the do_tb_flush run_on_cpu callback, because that is explicitly called with start_exclusive; there is no need for the mmap_lock as well. Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- include/exec/tb-flush.h | 15 +++++++++++++++ accel/tcg/tb-maint.c | 39 +++++++++++++++++++++++++-------------- 2 files changed, 40 insertions(+), 14 deletions(-) diff --git a/include/exec/tb-flush.h b/include/exec/tb-flush.h index 142c240d94..090ffc8818 100644 --- a/include/exec/tb-flush.h +++ b/include/exec/tb-flush.h @@ -8,6 +8,21 @@ #ifndef _TB_FLUSH_H_ #define _TB_FLUSH_H_ =20 +/** + * tb_flush__exclusive_or_serial() + * + * Used to flush all the translation blocks in the system. Mostly this is + * used to empty the code generation buffer after it is full. Sometimes it + * is used when it is simpler to flush everything than work out which + * individual translations are now invalid. + * + * Must be called from an exclusive or serial context, e.g. start_exclusiv= e, + * vm_stop, or when there is only one vcpu. Note that start_exclusive can= not + * be called from within the cpu run loop, so this cannot be called from + * within target code. + */ +void tb_flush__exclusive_or_serial(void); + /** * tb_flush() - flush all translation blocks * @cs: CPUState (must be valid, but treated as anonymous pointer) diff --git a/accel/tcg/tb-maint.c b/accel/tcg/tb-maint.c index 0048316f99..7be9a1c4de 100644 --- a/accel/tcg/tb-maint.c +++ b/accel/tcg/tb-maint.c @@ -36,6 +36,9 @@ #include "internal-common.h" #ifdef CONFIG_USER_ONLY #include "user/page-protection.h" +#define runstate_is_running() true +#else +#include "system/runstate.h" #endif =20 =20 @@ -88,7 +91,10 @@ static IntervalTreeRoot tb_root; =20 static void tb_remove_all(void) { - assert_memory_lock(); + /* + * Only called from tb_flush__exclusive_or_serial, where we have alrea= dy + * asserted that we're in an exclusive state. + */ memset(&tb_root, 0, sizeof(tb_root)); } =20 @@ -756,17 +762,19 @@ static void tb_remove(TranslationBlock *tb) } #endif /* CONFIG_USER_ONLY */ =20 -/* flush all the translation blocks */ -static void do_tb_flush(CPUState *cpu, run_on_cpu_data tb_flush_count) +/* + * Flush all the translation blocks. + * Must be called from a context in which no cpus are running, + * e.g. start_exclusive() or vm_stop(). + */ +void tb_flush__exclusive_or_serial(void) { - bool did_flush =3D false; + CPUState *cpu; =20 - mmap_lock(); - /* If it is already been done on request of another CPU, just retry. */ - if (tb_ctx.tb_flush_count !=3D tb_flush_count.host_int) { - goto done; - } - did_flush =3D true; + assert(tcg_enabled()); + /* Note that cpu_in_serial_context checks cpu_in_exclusive_context. */ + assert(!runstate_is_running() || + (current_cpu && cpu_in_serial_context(current_cpu))); =20 CPU_FOREACH(cpu) { tcg_flush_jmp_cache(cpu); @@ -778,11 +786,14 @@ static void do_tb_flush(CPUState *cpu, run_on_cpu_dat= a tb_flush_count) tcg_region_reset_all(); /* XXX: flush processor icache at this point if cache flush is expensi= ve */ qatomic_inc(&tb_ctx.tb_flush_count); + qemu_plugin_flush_cb(); +} =20 -done: - mmap_unlock(); - if (did_flush) { - qemu_plugin_flush_cb(); +static void do_tb_flush(CPUState *cpu, run_on_cpu_data tb_flush_count) +{ + /* If it is already been done on request of another CPU, just retry. */ + if (tb_ctx.tb_flush_count =3D=3D tb_flush_count.host_int) { + tb_flush__exclusive_or_serial(); } } =20 --=20 2.43.0 From nobody Sun Sep 28 16:28:05 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1758664531; cv=none; d=zohomail.com; s=zohoarc; b=Y8LnVscgzGZRgo9zfXM1xTCm1NFGtacI6/2hdeE7MOa8NFKytA24Ksa22wJPhK8BYX5MfJNjIExWz6fhjJt4uIF5vJO9JS1B1UPIThjEruNAbnpWtIFarLcyp9kqK+7cFsZmNqpbx+UusPkmxuGm6ateNNPOh7ui50JuYi1FQHs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1758664531; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=cyCevuOZBxjdSdzWhJH69VXeS030D/A2jQgzyM1Qqts=; b=HravaYCz+fQPKTplzcm1PjcofXjp5cfKjO4gTmWW4pYIt2qwIoxbTFypH+GtdD8oFHBKt5xc0KQLgX6pOR9QsWGrTkIuspMcrsrXelOgkp0xYdjEm+AgJu46/bXyzVHOsyCYIICNxnx/4gL069vLzJi9X2lDC9uIuA1NkjsOlbg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1758664531041315.49437549905645; Tue, 23 Sep 2025 14:55:31 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v1Ay7-0006Kx-Sm; Tue, 23 Sep 2025 17:54:39 -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 1v1Ay3-0006JJ-OB for qemu-devel@nongnu.org; Tue, 23 Sep 2025 17:54:35 -0400 Received: from mail-pl1-x62e.google.com ([2607:f8b0:4864:20::62e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1v1Ay1-0003ie-0E for qemu-devel@nongnu.org; Tue, 23 Sep 2025 17:54:35 -0400 Received: by mail-pl1-x62e.google.com with SMTP id d9443c01a7336-279e2554b5fso3463645ad.1 for ; Tue, 23 Sep 2025 14:54:32 -0700 (PDT) Received: from stoup.. ([71.212.157.132]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-269802e14f1sm168294035ad.71.2025.09.23.14.54.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Sep 2025 14:54:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1758664471; x=1759269271; 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=cyCevuOZBxjdSdzWhJH69VXeS030D/A2jQgzyM1Qqts=; b=FSH9XLuVVLy4NYY603pw7fDI/XocqrL2tmHgfqpqCeOZ+H8W+IGNmO0/CHkgxjKAlF KckV4EG0zfTkpDIXq+s/CnhOnO+vCA9jImhN+FKD3bNmWNcWQfWC8aI1kxlsqMuBxkZ6 RC9fv43QePUJhHJHEIFboOyJFQzWcqIv2dEqH68aUVdGvFNrjfWNW7uB/1sEPAXDTyF4 XuZwo8kDsKzopW+c8CuYJk2TBtXM7VscHEM38gTEkUqdyMUMK+6NbaNPvA9ZsS0FTZRB 7RmKZG4bTMkncojeoyGTyLsNEAcSo0NoiiZFqCV6Mxlg9rlLxd7C3wFds67YioI7tGS4 aOmw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1758664471; x=1759269271; 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=cyCevuOZBxjdSdzWhJH69VXeS030D/A2jQgzyM1Qqts=; b=w3b57C7CDY35dFCBF9Nk30noPnhitzgkG0I6hUCePHzD72neayudCVJjc1pR7iCUY8 1u6Gg/3VVGaY3cCqTL2UwXQ6hpdwGXyRxkbu1DpExVYBy4DhxoMj3Tu6awNtpcFN9MlV WlDhC/TbVA+xOcf8ItVMsIUeXdVe961aLCJlKwejUCu3fo8FaVIAKotVZTsJpn3TWMp+ HtSHhBAEfciZehNzp0js2m1kWtYtFOyC0CZu64ekYn6ZMxkd96Sv+kwSKWg8pCyCPl+A BeJCH6NR5BVnZE83o5Son5j3sRzsNe+3+/AWx+VekRDoM6ZOCP7Y7PZ2m68zmUwKuHXW 3pQg== X-Gm-Message-State: AOJu0Yz7h6AtUP50bcdY74DQCGP6Zctaki/0okMix7kPwch0ZpLZIGvT fZ+XHm/xHIjaTWinBCuMOrB0TTnnjH6u2K4j1ymUK9r9tlgDDzv6+B/VtHpNJFz8PRS8aScb4RT D5Csg X-Gm-Gg: ASbGncvl/dcci943Pp+l20naQs64B0UqXw7FI4Y02xLQ4eiVKuv/2mfGDAz+cahdE/M /rblXjE1TDJP5CKCDd04fUpPTGVynGxZKma+atdPkpH2PZcDSaRAdP/WQsVmZHBp1wcNsbH7wkG A4afnOkDY91cvNw/A9Nm6qcKQENNYRcc7cM8REZROETC+95GlYiQYkD8UiMLg3O1hehRJmG/a+9 CZ2ZZUFMkeu2uQskydR5hvh29ZHy/1YpiqY2wy1JqGIhZ1elNbMNbNAnHBbfig5t4V3mc/KUvRj V40l+DcIFoCLsMKdTN6PW7CBynbsvTcblSDX6mmMGjzQFBubr5UFTgiMX8uDR7jmW3d9iNn8qoD 8wev+Pt2agpg3EePNCnNexGFkXnek X-Google-Smtp-Source: AGHT+IFzzV/MEWIj7fjPW8nwQCJZO/2VGgCI3t1y/MiNQVrW6WH+QNjzbxT/ls5IPSjLTzx80U4a8A== X-Received: by 2002:a17:902:e752:b0:267:44e6:11d6 with SMTP id d9443c01a7336-27ec114dca0mr2219105ad.6.1758664471243; Tue, 23 Sep 2025 14:54:31 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Pierrick Bouvier Subject: [PATCH v3 06/10] accel/tcg: Move post-load tb_flush to vm_change_state hook Date: Tue, 23 Sep 2025 14:54:20 -0700 Message-ID: <20250923215425.3685950-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250923215425.3685950-1-richard.henderson@linaro.org> References: <20250923215425.3685950-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::62e; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62e.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1758664531479116600 We need not call tb_flush once per cpu, only once per vmload. By moving the call from cpu_common_post_load to a tcg-specific vm_change_state_handler, we do even better than that: we only flush when called from HMP triggered loadvm, when we had old state to flush. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- accel/tcg/tcg-all.c | 21 +++++++++++++++++++++ hw/core/cpu-system.c | 9 --------- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/accel/tcg/tcg-all.c b/accel/tcg/tcg-all.c index 5125e1a4e2..18ea0c58b0 100644 --- a/accel/tcg/tcg-all.c +++ b/accel/tcg/tcg-all.c @@ -38,6 +38,8 @@ #include "qemu/target-info.h" #ifndef CONFIG_USER_ONLY #include "hw/boards.h" +#include "exec/tb-flush.h" +#include "system/runstate.h" #endif #include "accel/accel-ops.h" #include "accel/accel-cpu-ops.h" @@ -82,6 +84,23 @@ static void tcg_accel_instance_init(Object *obj) =20 bool one_insn_per_tb; =20 +#ifndef CONFIG_USER_ONLY +static void tcg_vm_change_state(void *opaque, bool running, RunState state) +{ + if (state =3D=3D RUN_STATE_RESTORE_VM) { + /* + * loadvm will update the content of RAM, bypassing the usual + * mechanisms that ensure we flush TBs for writes to memory + * we've translated code from, so we must flush all TBs. + * + * vm_stop() has just stopped all cpus, so we are exclusive. + */ + assert(!running); + tb_flush__exclusive_or_serial(); + } +} +#endif + static int tcg_init_machine(AccelState *as, MachineState *ms) { TCGState *s =3D TCG_STATE(as); @@ -124,6 +143,8 @@ static int tcg_init_machine(AccelState *as, MachineStat= e *ms) default: g_assert_not_reached(); } + + qemu_add_vm_change_state_handler(tcg_vm_change_state, NULL); #endif =20 tcg_allowed =3D true; diff --git a/hw/core/cpu-system.c b/hw/core/cpu-system.c index 09c928c1f9..f601a083d1 100644 --- a/hw/core/cpu-system.c +++ b/hw/core/cpu-system.c @@ -23,7 +23,6 @@ #include "system/address-spaces.h" #include "exec/cputlb.h" #include "system/memory.h" -#include "exec/tb-flush.h" #include "qemu/target-info.h" #include "hw/qdev-core.h" #include "hw/qdev-properties.h" @@ -207,14 +206,6 @@ static int cpu_common_post_load(void *opaque, int vers= ion_id) cpu_reset_interrupt(cpu, 0x01); =20 tlb_flush(cpu); - - /* - * loadvm has just updated the content of RAM, bypassing the - * usual mechanisms that ensure we flush TBs for writes to - * memory we've translated code from. So we must flush all TBs, - * which will now be stale. - */ - tb_flush(cpu); } =20 return 0; --=20 2.43.0 From nobody Sun Sep 28 16:28:05 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1758664584; cv=none; d=zohomail.com; s=zohoarc; b=g8Aywj/b/kqbeE1g7iVzcV3VkuhOU+wH7ve7ZmTHddoBvR9Ll8UW50b5OaX/AcOSHrGcqkragBqiBaVdTs3DY4iGbFPM2+x35HqerLjcBeQRjQ+skEKthnRlq/+tIBpvzcTuXBF8AUTfLA8T0JXTxastaRBJ+wWOXFgG3PdkMLs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1758664584; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=agxaWfpnEWArDK9o57t/fXwGBS1U1BVOfgrXUxLn8BM=; b=OrK2SpDzJfyozyPKpfF7k6JPaPNgdXRid92DfbOJ9KA6A7R8vlUF9XgjL237Ca33l06+VPwOfzaq0+siyhQrRYNCGq+c/QUsy/4RPCuzOZPmYxPJhkPA0qkheU4Pe61VzdTtSgf0i6QsvuaHCr13COvj7odyrQ5dXARMjl53rho= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1758664584069873.8535734005376; Tue, 23 Sep 2025 14:56:24 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v1Ay6-0006Kb-F3; Tue, 23 Sep 2025 17:54:38 -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 1v1Ay3-0006JK-OV for qemu-devel@nongnu.org; Tue, 23 Sep 2025 17:54:35 -0400 Received: from mail-pl1-x62b.google.com ([2607:f8b0:4864:20::62b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1v1Ay1-0003iq-Kr for qemu-devel@nongnu.org; Tue, 23 Sep 2025 17:54:35 -0400 Received: by mail-pl1-x62b.google.com with SMTP id d9443c01a7336-25669596921so66114935ad.1 for ; Tue, 23 Sep 2025 14:54:33 -0700 (PDT) Received: from stoup.. ([71.212.157.132]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-269802e14f1sm168294035ad.71.2025.09.23.14.54.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Sep 2025 14:54:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1758664472; x=1759269272; 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=agxaWfpnEWArDK9o57t/fXwGBS1U1BVOfgrXUxLn8BM=; b=vwXymSI78IiAI2AxtCUS+jznz8GWLTDekjMSCYOwxoAmqAMzJWV5U0ElbLENRthYSM yn8by/1klWEiSK/nqdBGwHFVt9MvcRtrEwJBhodrMZbmW43ssR23bg+zKiPDnRlg8sHI NTAn1z7X/6BL1Ufs+2P03Q4oPbpBUBo5LnCL31P0k/qDVP94cexQTRhtA235OjwAlOmX E9xcYvLrhEFslyusVtwzDtho6Qf6wkQ620RtYO0Xfa0/OYFEo22M2xtBP8TRQCr0zBuU bvLvXI4+AE1H5eJtCbPrpxsjHRzTCgPrQockn63LfxtlooZ5vRVptyRSWAUdJzCxVez7 XPNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1758664472; x=1759269272; 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=agxaWfpnEWArDK9o57t/fXwGBS1U1BVOfgrXUxLn8BM=; b=BQjuqiWCE12cRZghkYpNq6J3b1SFbq+jV0O4Z1KOr1cAdbNVdMFEHCw11ZVyEOuvnu d/8YODhazU5/gKVfEaC5dyqFVHngYxVlZYC0ubcG1OpKuHhg9gc26UEnrmvzcFTzxq7w 89IOBdNk49kjnxmNP9MrvMTEznTaWZ/JgrYmfBFue2IcARQ15XO9FnfOglblnLA/jylJ GPG8CQdUjigQS5xcDw9X+kdnJ66nNxWkshJ8E9nIWrbQszAKsuE6HdK4qOmojyFUkrpD 4WuZvUXKwZF1KPQikd5c/lqlbJj/BDv0tOc8EZC4Vkzc726etpT4+87M+R2T/Q6HmY+S phpA== X-Gm-Message-State: AOJu0YwKKxLPff4TZeSFFMqdhhDSPbW0N1YVvUMkprN4sVnC06QMvNaR x1N1ImKol9h9Zc1Ri+PjuTrUsNR8sPeECqTzntxewOmVEy6z9uU3tAVyl1gEU079S/TB8g2KGnW e0hkt X-Gm-Gg: ASbGncvbqK0MTxRzLKcCu0Pk76bMiNhesaj6Hv6IjxlrzNd8Xw3hjtdgzXNYAo6P3h4 TG4NNVuCUsFzQVfAXYDRZW0r/H97MqcGubHiWuPcf/HxfuYnSJNMolJu2aPNrqGDBBGsiH+ACe0 0mXNgnJ6W+DrZxsOIv/MIRdPUdkUviau0hFDqthiMppTrWgHBBv12q2YzQoRjdXimT9Q7Kz7/KT Cs4lQqtRfkc3IgLgEsyOirMLpAkPlQUBcArEm2QSUDJNQyOvGPyb9VjUUxENd/8z37BfDVXHLVp IDpFFH370VFzjMuwFzYn39oVfDxWRjTDHAmoktHYgDoCp7VRX5aB98vf0ip27mINpCTwNr4R1rc jiAwKjyXWUCuV0zRxwpyi5mfARCEW X-Google-Smtp-Source: AGHT+IFN1KQmevhSJzTkMXAQS3kwzeKmbbwBoUbN9ZX/MarJ5D1El0pGkznTm2Llh1bvT3QwGEbLLQ== X-Received: by 2002:a17:902:e5d0:b0:267:a231:34d0 with SMTP id d9443c01a7336-27cc5623567mr45497615ad.42.1758664471926; Tue, 23 Sep 2025 14:54:31 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v3 07/10] plugins: Use tb_flush__exclusive_or_serial Date: Tue, 23 Sep 2025 14:54:21 -0700 Message-ID: <20250923215425.3685950-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250923215425.3685950-1-richard.henderson@linaro.org> References: <20250923215425.3685950-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::62b; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62b.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1758664585980116600 In all cases, we are already within start_exclusive. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson --- accel/tcg/plugin-gen.c | 4 ++-- plugins/core.c | 6 ++---- plugins/loader.c | 3 +-- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/accel/tcg/plugin-gen.c b/accel/tcg/plugin-gen.c index 9920381a84..1ffcb4b2d2 100644 --- a/accel/tcg/plugin-gen.c +++ b/accel/tcg/plugin-gen.c @@ -102,8 +102,8 @@ static TCGv_i32 gen_cpu_index(void) /* * Optimize when we run with a single vcpu. All values using cpu_index, * including scoreboard index, will be optimized out. - * User-mode calls tb_flush when setting this flag. In system-mode, all - * vcpus are created before generating code. + * User-mode flushes all TBs when setting this flag. + * In system-mode, all vcpus are created before generating code. */ if (!tcg_cflags_has(current_cpu, CF_PARALLEL)) { return tcg_constant_i32(current_cpu->cpu_index); diff --git a/plugins/core.c b/plugins/core.c index c6e9ef1478..ead09fd2f1 100644 --- a/plugins/core.c +++ b/plugins/core.c @@ -248,7 +248,7 @@ static void plugin_grow_scoreboards__locked(CPUState *c= pu) } plugin.scoreboard_alloc_size =3D scoreboard_size; /* force all tb to be flushed, as scoreboard pointers were changed= . */ - tb_flush(cpu); + tb_flush__exclusive_or_serial(); } end_exclusive(); } @@ -684,8 +684,6 @@ void qemu_plugin_user_exit(void) * with the one in fork_start(). That is: * - start_exclusive(), which acquires qemu_cpu_list_lock, * must be called before acquiring plugin.lock. - * - tb_flush(), which acquires mmap_lock(), must be called - * while plugin.lock is not held. */ start_exclusive(); =20 @@ -705,7 +703,7 @@ void qemu_plugin_user_exit(void) } qemu_rec_mutex_unlock(&plugin.lock); =20 - tb_flush(current_cpu); + tb_flush__exclusive_or_serial(); end_exclusive(); =20 /* now it's safe to handle the exit case */ diff --git a/plugins/loader.c b/plugins/loader.c index 8f0d75c904..ba10ebac99 100644 --- a/plugins/loader.c +++ b/plugins/loader.c @@ -377,8 +377,7 @@ static void plugin_flush_destroy(CPUState *cpu, run_on_= cpu_data arg) { struct qemu_plugin_reset_data *data =3D arg.host_ptr; =20 - g_assert(cpu_in_exclusive_context(cpu)); - tb_flush(cpu); + tb_flush__exclusive_or_serial(); plugin_reset_destroy(data); } =20 --=20 2.43.0 From nobody Sun Sep 28 16:28:05 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1758664580; cv=none; d=zohomail.com; s=zohoarc; b=i4WpsYSUpo6rFJzEkiyHhpbVpGR2ikx9focAxykv/CC9zE4QrhqAuCaGzCOu42Y3JJGqmp7FLILGNJ7nzm89ICvh+j4PpiHf4qgF66SDiUvC47pWyjhTpEzFSM5oJqEG8mCH+alN9y7oDSlVOY5JkfVat2XqxjMYOcsV0+bOkCY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1758664580; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=eQTsRUAq4JwFxeRITx6gawdeUeSfrBkGrxQoOoMpUjE=; b=blD+Vtd2+VFapZcekRRL/seyMXNwRURNZL3Ol42Mb0Z8o94yvLxmLx9S45c03PQQUtluuHeL5YIFmt797wQFx63zA8dQy9oUPyF33RLtmy9u72MnOmakhvyxJT/wU9OKn5b6Acphmpolv3MD01igYr4IWhN0ewZbDoWM5EBFDPE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1758664580874686.731730152605; Tue, 23 Sep 2025 14:56:20 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v1Ay7-0006Kf-5x; Tue, 23 Sep 2025 17:54:39 -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 1v1Ay4-0006Ji-9r for qemu-devel@nongnu.org; Tue, 23 Sep 2025 17:54:36 -0400 Received: from mail-pl1-x62a.google.com ([2607:f8b0:4864:20::62a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1v1Ay2-0003j2-8N for qemu-devel@nongnu.org; Tue, 23 Sep 2025 17:54:36 -0400 Received: by mail-pl1-x62a.google.com with SMTP id d9443c01a7336-26a0a694ea8so41627695ad.3 for ; Tue, 23 Sep 2025 14:54:33 -0700 (PDT) Received: from stoup.. ([71.212.157.132]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-269802e14f1sm168294035ad.71.2025.09.23.14.54.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Sep 2025 14:54:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1758664473; x=1759269273; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=eQTsRUAq4JwFxeRITx6gawdeUeSfrBkGrxQoOoMpUjE=; b=iB7670TGB4bTyBcuv+uNPaNI1iEbxJ4dzeIp91e62zVm1XMSlliySnu1Sx5nUNoeK3 zVB8yM/KIK/q1yO/FEl47EEFIBcUVecNoHkooJm4HJVXLCI9Dr2ld7Ajah8MSrmvpBbj cTSzc1JXlNxLw5QzJlwB1UjybN32gR9+IF6Ha18HjsB0Q+0H2wT1CMoukfYjfwcP6J52 bFyuNxheRCPP5BkJu7+Xie7BY+sn57wAjiXFX8v+dAyDGhhbIIIi5YWXz2thgY7+7xM6 gXTk5PO/w/dGkdrFYfwl3HpBLI17PYYE5P4+uea/x9UDWxQtH/KfIUUWAP25B2c9BJRG Fr8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1758664473; x=1759269273; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=eQTsRUAq4JwFxeRITx6gawdeUeSfrBkGrxQoOoMpUjE=; b=X7SGZbOCOu5TOR8UM9lCHgzdwxgW32U2yizo3nid9UeF58VBBVhCKa/CAMgjEphCbE BuRAyuOcDkAkC+4RyDEjmWpeo2IZtmzRIa4lH0iGbvmCEUMzzLhnm8Hn3QEtsx/Rt13y 6FwFVnZhvQQNZCnvSsHYp/ZDXM+0OPLGM/trrtwtzdveTTEEr7jR4oGa9F7/acdrgH8C fLtNn2mHODnRGsWhw7UqoQY7mCYf6NBTYR931hXQhMnZJGTK6LpwEOQm0+obfilbtfAL pUI7h5mwQzuphJuV7P1Ot6AoWyAlHXqpZ/BRno8KyLN9BP0oo2VIMsZ/1IMuJIuxp9xd EBfw== X-Gm-Message-State: AOJu0YyWe3S7jv71rwKaIBXB5Cfs6IoMKRwI2nSS/VTcQaJYuiXeYWty KyujAtupnqPY8ZlaI4S2UK7fFkGSyV9++w1BNB2LQ/4Yni0UW7cgE0EC+gQHcZjawb/PjkkcOpv 6aS4Q X-Gm-Gg: ASbGncu+fE0wCmca5FLtewiprUFD++QKP9qA7SBEWdVp8ePMhxv7EOHTErW/GJYSbaI zR8SyCDvkAImSSngMFDu5jbBc6ysB87BKG7wRJq84yEJzo+kChpx2gwQlRFQvhLPkmS+esVIQcW skX9j/GLSRt+jcEbegIC93c7GtyaZPKfh/+rClB8l01NYP2UBbcN5f7LnXSb36JJJmyW6PPBlW7 RtYCVqeUOgOGba4JovTeO2p3rWSZH7ZrkXYd7zyt3MHYqow4Qeow6V/ci1TvSksjtieO3oKO0ul /2xZa8RhfpAqT9yoWReYfmzs7idXwOA8JGPxDNRSwCwzmE3JizgXNcUPYxbyCft2ZNX6nUpDcJ3 9l6VSd/bu21gZ7eaZtPKnUbgxDmixOAgvk/7OM4c= X-Google-Smtp-Source: AGHT+IGy1sCykf7uLICFyhn8NSutJ1hRTgj/U9dwxQoLSGMMRgs7sQFQw/BZ+zrJVl6Ro0CrfuvIyg== X-Received: by 2002:a17:903:1a43:b0:267:ba92:4d19 with SMTP id d9443c01a7336-27cbab337f3mr45872725ad.0.1758664472672; Tue, 23 Sep 2025 14:54:32 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 08/10] linux-user: Split out begin_parallel_context Date: Tue, 23 Sep 2025 14:54:22 -0700 Message-ID: <20250923215425.3685950-9-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250923215425.3685950-1-richard.henderson@linaro.org> References: <20250923215425.3685950-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::62a; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62a.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1758664581962116600 Content-Type: text/plain; charset="utf-8" Move the test/flush/set block to a new function. Use tb_flush__exclusive_or_serial while we're at it. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- linux-user/user-internals.h | 16 ++++++++++++++++ linux-user/mmap.c | 13 ++----------- linux-user/syscall.c | 7 +------ 3 files changed, 19 insertions(+), 17 deletions(-) diff --git a/linux-user/user-internals.h b/linux-user/user-internals.h index 691b9a1775..7099349ec8 100644 --- a/linux-user/user-internals.h +++ b/linux-user/user-internals.h @@ -20,6 +20,8 @@ =20 #include "user/thunk.h" #include "qemu/log.h" +#include "exec/tb-flush.h" +#include "exec/translation-block.h" =20 extern char *exec_path; void init_task_state(TaskState *ts); @@ -172,6 +174,20 @@ static inline int regpairs_aligned(CPUArchState *cpu_e= nv, int num) { return 0; } */ void preexit_cleanup(CPUArchState *env, int code); =20 +/** + * begin_parallel_context + * @cs: the CPU context + * + * Called when starting the second vcpu, or joining shared memory. + */ +static inline void begin_parallel_context(CPUState *cs) +{ + if (!tcg_cflags_has(cs, CF_PARALLEL)) { + tb_flush__exclusive_or_serial(); + tcg_cflags_set(cs, CF_PARALLEL); + } +} + /* * Include target-specific struct and function definitions; * they may need access to the target-independent structures diff --git a/linux-user/mmap.c b/linux-user/mmap.c index 002e1e668e..847092a28a 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -22,8 +22,6 @@ #include "exec/log.h" #include "exec/page-protection.h" #include "exec/mmap-lock.h" -#include "exec/tb-flush.h" -#include "exec/translation-block.h" #include "qemu.h" #include "user/page-protection.h" #include "user-internals.h" @@ -1007,11 +1005,7 @@ abi_long target_mmap(abi_ulong start, abi_ulong len,= int target_prot, * be atomic with respect to an external process. */ if (ret !=3D -1 && (flags & MAP_TYPE) !=3D MAP_PRIVATE) { - CPUState *cpu =3D thread_cpu; - if (!tcg_cflags_has(cpu, CF_PARALLEL)) { - tcg_cflags_set(cpu, CF_PARALLEL); - tb_flush(cpu); - } + begin_parallel_context(thread_cpu); } =20 return ret; @@ -1448,10 +1442,7 @@ abi_ulong target_shmat(CPUArchState *cpu_env, int sh= mid, * supported by the host -- anything that requires EXCP_ATOMIC will not * be atomic with respect to an external process. */ - if (!tcg_cflags_has(cpu, CF_PARALLEL)) { - tcg_cflags_set(cpu, CF_PARALLEL); - tb_flush(cpu); - } + begin_parallel_context(cpu); =20 if (qemu_loglevel_mask(CPU_LOG_PAGE)) { FILE *f =3D qemu_log_trylock(); diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 91360a072c..101dc427a4 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -27,8 +27,6 @@ #include "target_mman.h" #include "exec/page-protection.h" #include "exec/mmap-lock.h" -#include "exec/tb-flush.h" -#include "exec/translation-block.h" #include #include #include @@ -6631,10 +6629,7 @@ static int do_fork(CPUArchState *env, unsigned int f= lags, abi_ulong newsp, * generate code for parallel execution and flush old translations. * Do this now so that the copy gets CF_PARALLEL too. */ - if (!tcg_cflags_has(cpu, CF_PARALLEL)) { - tcg_cflags_set(cpu, CF_PARALLEL); - tb_flush(cpu); - } + begin_parallel_context(cpu); =20 /* we create a new CPU instance. */ new_env =3D cpu_copy(env); --=20 2.43.0 From nobody Sun Sep 28 16:28:05 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1758664557; cv=none; d=zohomail.com; s=zohoarc; b=QlsMFsF1yt9W8EFmUHzUMZlDnJ+a7x/9Q273XeM+TScWPigmQPwSoKv2qpfdMp5iucuj4wbTZBtNdzG9VR+QO6G1HsNTBGntkAwKckni9Hw+b4ciooJtXbYNwuJElC271c5lxhhVJ6T/TAY1rdOA316LVJfg6HfWgsSjWbgWsEk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1758664557; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=H70urNHQexc8XRiqcQIbAPa7e6Ad5kGXAtjgrs13aaQ=; b=eQIl+HWo6e82RNGGCgrcHpY5PpmSgD9ngnZ+By6Ikt5UPMBh6RxbtMUwpuw9LpTeYhMovXC3ygewHR6oBbj1vi8KLXSDcWIn3YGjVVN0ji4BsrHBJvLMsvz0uFWUNrAHlXw3ROkFRg5TrCyJQvekFL02CiWE5au9QvTsu4JBsq4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1758664557290659.2746254977993; Tue, 23 Sep 2025 14:55:57 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v1Ay8-0006L4-FZ; Tue, 23 Sep 2025 17:54:40 -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 1v1Ay4-0006KE-Pq for qemu-devel@nongnu.org; Tue, 23 Sep 2025 17:54:37 -0400 Received: from mail-pl1-x62e.google.com ([2607:f8b0:4864:20::62e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1v1Ay2-0003jC-SD for qemu-devel@nongnu.org; Tue, 23 Sep 2025 17:54:36 -0400 Received: by mail-pl1-x62e.google.com with SMTP id d9443c01a7336-279e2554b6fso21093095ad.2 for ; Tue, 23 Sep 2025 14:54:34 -0700 (PDT) Received: from stoup.. ([71.212.157.132]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-269802e14f1sm168294035ad.71.2025.09.23.14.54.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Sep 2025 14:54:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1758664473; x=1759269273; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=H70urNHQexc8XRiqcQIbAPa7e6Ad5kGXAtjgrs13aaQ=; b=xeSp5pi9r4tp+K8RQupdFZPEkZ05QFJ2wslvv4ltkNpFZAf0UXY0raacdD94cye8pq eoLMkh6cKpR6iRtPiZqo8nymCz6IvGWn+xUiztEhGBMNXqLAZm443+qjQkJIx6ISWOOH G86LN/SZ5/PW13dmCOod4IQuycFgvKUPABINTpvqJt+3BsQwMpVa8Of6eZCItXTXCvRI qbhmyDyLrnMshnWSr+4ff51vC1oLxEG0m1bI0QhBQEWaUQSeGeB+12XkRLdKVg4xdkra AH34NpXhg789oBdgsJvOI3K9cm7nZBiRtpWvkdFYMkwQLU7/ZVLU0c10x9ci/GhiSb6W wMdA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1758664473; x=1759269273; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=H70urNHQexc8XRiqcQIbAPa7e6Ad5kGXAtjgrs13aaQ=; b=tmg0Rx997XaKva0L/qta7XHsOJtC3/apFnntIoSbhWiLtjLrmgR92xpPQhwG/eGzMz KMso17eW+1uY646k52Ik74gfZOBVgGRKbP7Kbzb9ifHj+sdpfF08b+69XYBxLbkSE7rT N5CcSzZ33MAe0v8iV9VLzs2FdWw/R/aLu0AsvMXRp9D+mj5KAsOf4DGKZLXuDX/7S81w CVVZvZ3KmAZKTcD2J8fh2/ToqtY6lKDd5lnzV5ZhSV7BI8pEzvxyFOUMblRzAoHffBYv fkVOYFlWhqCijc7GYUFDnLoPphZFLMImAk5iJuYC/Y92vzhEe/D+L6prMBdLkdokVtRt e7rA== X-Gm-Message-State: AOJu0YykRZ2PjxIoGVIGCAI5YgTs+anYCQXvSD9VdDjem1GjzyNDUQ/X KFL7AHUv9a9Dn2i8Q6oYao2aXLhUh4U+05BVVsmvX+4T75Q5VwaklfGaNbUkPCqT7ViB+7bXS0s Pi4Hc X-Gm-Gg: ASbGncvao3NorhEcztV5Pp+JpawPTPZZbbRTi0bT7NtH5/53YDVKWI2VVgQyw3iVa8r 3efjM/HdGph664V21aI87N8tXPaj9kztkLI2QqRfxpRHWxm4ugdVr/8sLMzVrp/6aRsaVvfW2iD ooRSqTcW+l/dmjpQumXAKwC/dxd3l4tW23O+oUM5v6qrq9CEkko8cvQK1CvSHM5qzNAD5uhl+Ge wSjR/oHJnG9e0lZt9zHn52j/GopCY7oPP1AL7as8oGMH2Juadv5/sAcAJGEGTFoljQnVIjrrV9k A4AEmW0WYtvvak9sOj6JJyxftUi4HGt0+yeA95Ij5J62PQFWY70zv4a69vbEyQ4Q+eTzGe9HmB2 dt1cAkC5ePJiwe0ZDvgfk9OLlsszg X-Google-Smtp-Source: AGHT+IE4VnkWCZPZB5EluoVwlER8YTxdkUD+SnXUSxSQZpZHz1svfYsZXI8xOLj77okZbqgJnvxjGA== X-Received: by 2002:a17:902:ce0a:b0:27b:472e:3a23 with SMTP id d9443c01a7336-27cc1858b01mr48890545ad.14.1758664473543; Tue, 23 Sep 2025 14:54:33 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 09/10] accel/tcg: Create queue_tb_flush from tb_flush Date: Tue, 23 Sep 2025 14:54:23 -0700 Message-ID: <20250923215425.3685950-10-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250923215425.3685950-1-richard.henderson@linaro.org> References: <20250923215425.3685950-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::62e; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62e.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1758664557677116600 Content-Type: text/plain; charset="utf-8" Rename the function and remove the path which performs the flush immediately. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- include/exec/tb-flush.h | 17 ++++++----------- accel/tcg/tb-maint.c | 11 +++-------- accel/tcg/translate-all.c | 2 +- 3 files changed, 10 insertions(+), 20 deletions(-) diff --git a/include/exec/tb-flush.h b/include/exec/tb-flush.h index 090ffc8818..e971d4ba6d 100644 --- a/include/exec/tb-flush.h +++ b/include/exec/tb-flush.h @@ -24,19 +24,14 @@ void tb_flush__exclusive_or_serial(void); =20 /** - * tb_flush() - flush all translation blocks - * @cs: CPUState (must be valid, but treated as anonymous pointer) + * queue_tb_flush() - add flush to the cpu work queue + * @cs: CPUState * - * Used to flush all the translation blocks in the system. Sometimes - * it is simpler to flush everything than work out which individual - * translations are now invalid and ensure they are not called - * anymore. - * - * tb_flush() takes care of running the flush in an exclusive context - * if it is not already running in one. This means no guest code will - * run until this complete. + * Flush all translation blocks the next time @cs processes the work queue. + * This should generally be followed by cpu_loop_exit(), so that the work + * queue is processed promptly. */ -void tb_flush(CPUState *cs); +void queue_tb_flush(CPUState *cs); =20 void tcg_flush_jmp_cache(CPUState *cs); =20 diff --git a/accel/tcg/tb-maint.c b/accel/tcg/tb-maint.c index 7be9a1c4de..5b1a5b599e 100644 --- a/accel/tcg/tb-maint.c +++ b/accel/tcg/tb-maint.c @@ -797,17 +797,12 @@ static void do_tb_flush(CPUState *cpu, run_on_cpu_dat= a tb_flush_count) } } =20 -void tb_flush(CPUState *cpu) +void queue_tb_flush(CPUState *cs) { if (tcg_enabled()) { unsigned tb_flush_count =3D qatomic_read(&tb_ctx.tb_flush_count); - - if (cpu_in_serial_context(cpu)) { - do_tb_flush(cpu, RUN_ON_CPU_HOST_INT(tb_flush_count)); - } else { - async_safe_run_on_cpu(cpu, do_tb_flush, - RUN_ON_CPU_HOST_INT(tb_flush_count)); - } + async_safe_run_on_cpu(cs, do_tb_flush, + RUN_ON_CPU_HOST_INT(tb_flush_count)); } } =20 diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index d468667b0d..31bc0f8bc5 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -289,7 +289,7 @@ TranslationBlock *tb_gen_code(CPUState *cpu, TCGTBCPUSt= ate s) tb =3D tcg_tb_alloc(tcg_ctx); if (unlikely(!tb)) { /* flush must be done */ - tb_flush(cpu); + queue_tb_flush(cpu); mmap_unlock(); /* Make the execution loop process the flush as soon as possible. = */ cpu->exception_index =3D EXCP_INTERRUPT; --=20 2.43.0 From nobody Sun Sep 28 16:28:05 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1758664517; cv=none; d=zohomail.com; s=zohoarc; b=Y6TRPOcJT4oOTRdzdV0GKojjQ11SFYitc6hrvh1LCn0FoOS+Yx3oDY5djiLLj2EWa5Fu7kHcIIUwhES/K004lF6KZTUmuodFSO5aG8tcpcpFuGdLZ+jrxl69b2N181L18IeE6BK6bjBjS3OoTKFWNWIAyLvYmxeYWk/gYEhge3U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1758664517; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=3tkOqHK5ejgU7JIInVN+rKgDfoWboky6FhXhkFrd/5A=; b=BEJaUGkfh5bS5jLUmRckzkozHx0rBJd8gPhkX5nwSN4D5sE896i1BVtsgnNA2FGRY5kjpWsD28ZpnhuIw9vBqGWHm7i68ItJAetbE/YJBMblbWjhAYvaigYN4Nh28s9HM7MwzCYNYQWtYZbsWXtOO1iolW6uKx+DvP/EARJIoi8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1758664517769768.1554379699794; Tue, 23 Sep 2025 14:55:17 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v1Ay9-0006Lo-8S; Tue, 23 Sep 2025 17:54:41 -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 1v1Ay6-0006KT-3o for qemu-devel@nongnu.org; Tue, 23 Sep 2025 17:54:38 -0400 Received: from mail-pl1-x633.google.com ([2607:f8b0:4864:20::633]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1v1Ay4-0003jN-DZ for qemu-devel@nongnu.org; Tue, 23 Sep 2025 17:54:37 -0400 Received: by mail-pl1-x633.google.com with SMTP id d9443c01a7336-24457f581aeso60505845ad.0 for ; Tue, 23 Sep 2025 14:54:35 -0700 (PDT) Received: from stoup.. ([71.212.157.132]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-269802e14f1sm168294035ad.71.2025.09.23.14.54.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Sep 2025 14:54:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1758664475; x=1759269275; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=3tkOqHK5ejgU7JIInVN+rKgDfoWboky6FhXhkFrd/5A=; b=IiPHP9Ws22ffgZ0/bs2NfR+x+igKL5hLp8ArkBclhXKUw2bxQzHdGZI4860DU3Qn71 ag84k8r3hhzmGOln9uGMfBaD82lMoJfoHqW6V9ArRLimiKGCqeX8gTlgesO9Tc+rqszt DCmpVAAdW4DEY6qjs3nbnzsSymwKCwscVqzTmVdyrgK4cxBJG2ZV0ePuaown/nE+qirt GHs79o78gD+UweDRCRYvW2tP8WUFnPTRtm55igTV3XNynR2nN7NZxhlp7raApZqo3tmz tmoMABhgT37Tkynqoa+zwF4QclQsyLGl2yyeUL2CihqlfCICrU6eBDQaQwi8AHpIRmn9 T0EQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1758664475; x=1759269275; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=3tkOqHK5ejgU7JIInVN+rKgDfoWboky6FhXhkFrd/5A=; b=lXDc5htdIvOhE1tT2VFv9EqUvyCdcN3YRJQAb/fiUX1p7fplv4SVKGeN7xxvYr33vn s2dRSSGcYSLSR3n5ghRzcGA67ClsWQyQer66Nxy7G6vxjfkBdF/GqHKmhj/wYm/elPRI nV/2lUmAui8owD9bTv7Vw1f7Ot86iWDiNV5DMEkht/+ZZ7JR8Mq2U2LgQkcOpH+X2MgW cNfKaV8Cq+4duq+7a4p/4tutniYN0CxltEXntT9R/q6/7o0qrowFoGLtyu0tGZleTlSV GvZyLT9lwUPl8Xpj2PTo/J5VbGqN0gvfr/19sjatljQz5o857V5W6womZ+nc4NBW/sjI n5qg== X-Gm-Message-State: AOJu0Yz7jde7NLxzuZ6idR7C+L/RikfeeDQRHM/F2jchvyIZ9X8r4R5T i78FjEJgO4S1wpuiT8OpLjD7kdlxod5FaPUP6TcftfhrFM+engPTaWx+1b68PfnVEGNGe9EYJTP m7Qf5 X-Gm-Gg: ASbGncv+R2gPdJzOjz3ZLYsv/+BbOoJoONe5r78h4Mww1r/laHxlpIZMTV76wdKVtOH 5qTsqQT127B2XABJo5iPNrMkpd809CWfKEhU7wtu7093zLR6PJnaqsMfiffELjaJ6vIVwe1wQMz eHfB6qQswVKxWaa9O+hUGCGSoJGGyCBvsuPkQN1RVxPLFFW5tFuzSPsE+fu18nOgIMo2cHaqgiW Ib6FJR+0vkJz+2IOetFuxQSxZiR94QmysvtjkfTTqwLIG69UYnoPwCu99GTOWezNIz3KDPb9TAB U/uDkzqVONpJ3oLvWVtAPK5aYHDyf/sOsbW5zSj8J2skLSkpOpAqe79PZAJlN21dpZcgjoqM0Wy pmfzT/YTV1lP6cBWAFoiBptiaJede X-Google-Smtp-Source: AGHT+IHRJgiKIW6ISvVJIrNpGL51FXSlJ3tm6v5g1PhoZ/EziWy+Ll9Q46Db0pJGvBxKrMVWYwzj5Q== X-Received: by 2002:a17:903:22d0:b0:248:ff5a:b768 with SMTP id d9443c01a7336-27cc09e4465mr40093885ad.10.1758664474299; Tue, 23 Sep 2025 14:54:34 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 10/10] accel/tcg: Improve buffer overflow in tb_gen_code Date: Tue, 23 Sep 2025 14:54:24 -0700 Message-ID: <20250923215425.3685950-11-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250923215425.3685950-1-richard.henderson@linaro.org> References: <20250923215425.3685950-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::633; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x633.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1758664519606116600 Content-Type: text/plain; charset="utf-8" If we only have one vcpu, or within cpu_exec_step_atomic, we needn't jump all the way back out to the cpu loop to empty the code gen buffer. Signed-off-by: Richard Henderson --- accel/tcg/translate-all.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index 31bc0f8bc5..da9d7f1675 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -289,6 +289,10 @@ TranslationBlock *tb_gen_code(CPUState *cpu, TCGTBCPUS= tate s) tb =3D tcg_tb_alloc(tcg_ctx); if (unlikely(!tb)) { /* flush must be done */ + if (cpu_in_serial_context(cpu)) { + tb_flush__exclusive_or_serial(); + goto buffer_overflow; + } queue_tb_flush(cpu); mmap_unlock(); /* Make the execution loop process the flush as soon as possible. = */ --=20 2.43.0