From nobody Sat Sep 6 15:08:54 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=1757136135; cv=none; d=zohomail.com; s=zohoarc; b=ff5xMlHQ3cRCSEg5aRjJLd3rK1ofVqs3dJJjHFaUv29uaiP7HKGuD4d6kb614gsaDolbZjude3qjsnu/ASvmCSGBbaf+WzybxAPrYIdKku4OMbh/8uj+7T1WU4r2qFC8NfODBKfNG1UXv8R52fyp/GrJ4BQloYZTC8eYbYHqdUw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1757136135; 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=HNqFZV35YOrj/F9z9dCSnDx2HfCCFDbc6LDsUqT3M/g=; b=ef8+X4+DT1gnICsbUNOKjz2+aSCGW6YsIhInLRN1TXAhcl0qFWcCEOFwWwnQ0DTyt2459qyuA7pCeoalsW0loos8tUYacj7S3TfhXvPYdidE8SnpURhsJ5fpHBbc4XnywpxAt4fz7jPAWuRXwQCp+fieLW8zYJuX6+UL6f//5WQ= 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 1757136135591364.9334685844268; Fri, 5 Sep 2025 22:22:15 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uulK6-0000E7-KZ; Sat, 06 Sep 2025 01:18:50 -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 1uulK0-0000Bs-Kl for qemu-devel@nongnu.org; Sat, 06 Sep 2025 01:18:44 -0400 Received: from mail-wr1-x435.google.com ([2a00:1450:4864:20::435]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uulJo-0006oT-Qu for qemu-devel@nongnu.org; Sat, 06 Sep 2025 01:18:43 -0400 Received: by mail-wr1-x435.google.com with SMTP id ffacd0b85a97d-3c46686d1e6so1934194f8f.3 for ; Fri, 05 Sep 2025 22:18:26 -0700 (PDT) Received: from stoup.21wol.it (93-51-222-138.ip268.fastwebnet.it. [93.51.222.138]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-45b6f306c22sm441197735e9.13.2025.09.05.22.18.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Sep 2025 22:18:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1757135903; x=1757740703; 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=HNqFZV35YOrj/F9z9dCSnDx2HfCCFDbc6LDsUqT3M/g=; b=a5U9vOiPJLdU6NxidmKmqZrWV+VxgI+sprCPYxrMK9q2rOpZp88XkIIbAQxH9PQJQD rVcLO4A5kUFUwe3EJ80k3Bv23ef7Th37jZounM0Mw24leIGdw5ImJZN3uT8mwmT1cs+D nR6tpgknI9URQUYHXUYaiK4RKu/NFJYeH9khVtQzFzp1T6xL+G7DPy6hUlQ6vvPkTJqb mk69tkf4twK+mOg2e/azLAwYe1wj9wu3Mrak2wFiNLE1d5AnusNpn+7DysOAxALyCiw3 m9Yt79aaGlqb6ARdKnfeZVAjyx9DWZCAMn5MBxY9T6Z6PwzJ0wxxaymJOQYGiErquwHQ 1coQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757135903; x=1757740703; 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=HNqFZV35YOrj/F9z9dCSnDx2HfCCFDbc6LDsUqT3M/g=; b=V9brZLRz7wqbh4XS52+H4MdqhrHg/Kpvkz8pK7nprsAcKVzjZXxcHEWOzGSSwziiYK a0ZIQWlSBilN88JD6ZFhEO8f0GzHKCSy4J5rYgtKJmORjUWnn1oDB7wg5vAMh4p3hkNj Fr/2qup/1iqvlhKlNP6i8pSNquOQcB5tOYjUGY9h701/rXWEWx3cdEILxKQFD69t55ZL kIZJ80Iurj46cHrOJKo1us0XYXXCFMhKMSJxd6YNBei/EaXYLVXGgfs/5A29hs96wcET oOfNvrFpGwoH8rBSTelNKqBsEt82avnH+PrJhTrjOtglfvrq2Rxc9eqXEG3aBeBqd/6r 0MnA== X-Gm-Message-State: AOJu0YxxO8OnQD+tT/b6ajaz5K5ntIZfMKA5qfz3HXAOjHOuS68qWsYN lq2M5+cqFft223+CSp4v7DSgcGwCxQ5s9WXcCMbxnSYr5AbDXtD4nxkr/A5HroeT1dGQFYFiXrP AJl4QZrQ= X-Gm-Gg: ASbGncsByIJUjq5BDi8UgfxaWHQtb3syklQF8uCjXBbNrjC6tRfT658zGQr7xvEuc0b YMiWRzVEcJX5/MQo5FXSX7jSynq6FaZaRn1DN3uSuqy3vsASXnODf7x4NHtb5OASYpkAw0YO09Y SiQc2HgGD+z6bWxXNczJ+LTFx+txL0WFh8MHp4oHA9x3sHpQob2lrfEHqNmbjxOj/sJgU7kukyE 01SMTwNRW8JlztK4TLcLGtwvEDPUWMGokn46eoFsQAOmRai5Gtn25+XeNATZOGAjCvNIuFTD9TY hm1rDttg/AgbTtAhyaOBdelW1hYPtPxMcaVj5DjgcVD2srWZvMw181ty+CHLzRr23hlBMqFInl7 lI3UFooBJb4qJQExa0oK5nz9zMEMAsmcdh04GW+z3zqR7ScTX+UZ+ARvuegigPuw+FQzT9GAGlH q4oQwSOg8= X-Google-Smtp-Source: AGHT+IGtt5iyMs11Oc6J7K5A55NfbYz8ZigGo9LLRqb+A2698A9SnNL9xtaz5gvCXtH5IqlB1eoS+Q== X-Received: by 2002:a05:6000:2013:b0:3d4:a64:6754 with SMTP id ffacd0b85a97d-3e643ff3b6fmr566630f8f.62.1757135903251; Fri, 05 Sep 2025 22:18:23 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: alex.bennee@linaro.org, philmd@linaro.org Subject: [PATCH 01/11] gdbstub: Remove tb_flush uses Date: Sat, 6 Sep 2025 07:18:10 +0200 Message-ID: <20250906051820.160432-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250906051820.160432-1-richard.henderson@linaro.org> References: <20250906051820.160432-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=2a00:1450:4864:20::435; envelope-from=richard.henderson@linaro.org; helo=mail-wr1-x435.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, 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: 1757136136932116600 Content-Type: text/plain; charset="utf-8" This hasn't been needed since d828b92b8a6 ("accel/tcg: Introduce CF_BP_PAGE"). Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier --- gdbstub/system.c | 4 ---- gdbstub/user.c | 3 --- 2 files changed, 7 deletions(-) diff --git a/gdbstub/system.c b/gdbstub/system.c index 5be0d3c58c..df3514dc74 100644 --- a/gdbstub/system.c +++ b/gdbstub/system.c @@ -18,7 +18,6 @@ #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" @@ -174,9 +173,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 Sat Sep 6 15:08:54 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=1757136017; cv=none; d=zohomail.com; s=zohoarc; b=RROGl0Mxdgk849uWEAYIlA0DQ0MI4YLjxZLJvqvNE46YQrnFI4r8Q7V5uQD8tVQeHG/xbWKEJFHPHwfRGZUpMs4X7qRZZgvnwMBeeK3a5COwTn+gbXrLWb16HP4IXQo5TFEDN+MTsOaCGkFn0J2ZT3nBSeGHLRYUaSzE1yPbOFQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1757136017; 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=lVc9sQO+IQWwxU8Et06pJOtpCoTnc3nxzpEuyeramTo=; b=NMwE3wL7HKIQdlWpvi3V1GvZn9A1Jga6aCXEeEm16N6/iwW0/8f00p79Wnnrhtoa+ixkWbeZpSYSxuV9QmHFnPl3xlviJomX4iqPAOBL7pnXP9xToAajw5LtkeWkfY2K4vK8AaMJELD4Re06/CbJbox5XR/xWT7lGbUV9rXVtbY= 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 175713601745613.021772805534283; Fri, 5 Sep 2025 22:20:17 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uulJw-000098-Cx; Sat, 06 Sep 2025 01:18: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 1uulJt-00008c-8x for qemu-devel@nongnu.org; Sat, 06 Sep 2025 01:18:37 -0400 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uulJl-0006oS-4c for qemu-devel@nongnu.org; Sat, 06 Sep 2025 01:18:34 -0400 Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-45dd7b15a64so12184935e9.0 for ; Fri, 05 Sep 2025 22:18:28 -0700 (PDT) Received: from stoup.21wol.it (93-51-222-138.ip268.fastwebnet.it. [93.51.222.138]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-45b6f306c22sm441197735e9.13.2025.09.05.22.18.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Sep 2025 22:18:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1757135904; x=1757740704; 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=lVc9sQO+IQWwxU8Et06pJOtpCoTnc3nxzpEuyeramTo=; b=VUO1vi9utFEAVD8WfV2dAqWJxAzmq6TSSVGhonvxalC9LjoYPsaZabP/4w2VCHQsIc u7gh+Jau6fJxdOwt4cA8qbgJmPoH+U0lr4/IABSe2SSzX9bBZR1A9Q0n7v+mtbemcgYF KSZnU0yBfzJOpDNxZ6z5Q1t9a4JgPwFWpvPjJ2K2Lt4C7mxkFfOQWTJklyAwM5ybH3NR 5bvBkRz84QBPalUYNNRfn4rtae2OQZ9ZFs6obokhZ9ca4LXJLRDRaNJ8TepranVduQNU QvONqn9tzokW5yDAcpAxApedIrYQR9BxaD7Sn+2mrot6DzAm1rugnmFlkqwpBN6pM1pD 3vlg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757135904; x=1757740704; 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=lVc9sQO+IQWwxU8Et06pJOtpCoTnc3nxzpEuyeramTo=; b=R0wFP8qJ94h9CpirSXTVklArL5bbsxYe7vepqBy0UlOQNecoHEhm12vQh86DJYEczA Zh22mH6bm/uQRLn4RmD57lrNIIGz4tcv4dAXcwAlAX03OeSd+bFTzI/5AYlFye7U+Na5 TQNg18AbgNWdAO4mF2l+vJymL8HCjd58U5cNV5MhJQ5+yNer2xYdoqOme8YepjOrtn4N SWy171ieHc7LRqm8wrLn4dJFQxWz0Ozm1NdWvc2EYc0kGt3WSOCafW+N0DYM5BNzimus eriDE+5y0zd/xID+AdujQhDjc2oz+carHmbbRDIRy6CwiwxjTQZncN1DqNzt/fq+oIJF Rhcg== X-Gm-Message-State: AOJu0YzjJD+hpkUgIFieOOrGVPLApm1K1akhj15lzoqewMB/ZxoEV//A Qux5LbAk04nkJi+eTlNwCuff/mrCU70ceBEQbXrbX2BMzQGOlKd0cD3TZ9GFV6GbauoEsmYhznp 6kqDDAR4= X-Gm-Gg: ASbGncuchKiNHb0I+i9JfRPTnd2C90TiJ6ZWvr6sCasZ56rTSeOmu28lrbU3HtOGIh8 +gfn4aI43k3vNvgi/NNTmeGkbMZXucFCX/2hgI3RTGtCb2+5SMGLNAcrgAHdKBx0tA/oJq9HARA BKjHZTWISdIqLYvY/zEUKZApGBzFPyYO0aH6dfhsDeun1bFjOURrI4OGhADW62vTcbU2DKAURfv GVAF2ijDPc37ILUBouVPiDJy9QmsBZAFHKWekao09DSNqHd8t6yXJvG9Qm4oRbCcog57ILIwaNR y3RpL/ceBqzlaTLrg2/X606cRpiYLZD3TEYi6569yuRrxXEchLCflxMFkKn/4ljI8LqdOeJlLa1 V0+GKOUL4pM3mXeTSlTZc285xn/3304ApikOe4ArJiQ2mhOZfHu+ndRfZzkF9pW78lOgu9P8D X-Google-Smtp-Source: AGHT+IE8VPcTg0psR53FHGL2CcfbTMdO36D7dauVqPMWLDpcZNy0IdOT3xDkt2tP/o7Z4KzBDCdYNA== X-Received: by 2002:a05:600c:3b1d:b0:45b:8ac2:9761 with SMTP id 5b1f17b1804b1-45dde20e5c0mr7219475e9.13.1757135904236; Fri, 05 Sep 2025 22:18:24 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: alex.bennee@linaro.org, philmd@linaro.org Subject: [PATCH 02/11] accel/tcg: Split out tb_flush__exclusive Date: Sat, 6 Sep 2025 07:18:11 +0200 Message-ID: <20250906051820.160432-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250906051820.160432-1-richard.henderson@linaro.org> References: <20250906051820.160432-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=2a00:1450:4864:20::32e; envelope-from=richard.henderson@linaro.org; helo=mail-wm1-x32e.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: 1757136021470124100 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. Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier --- include/exec/tb-flush.h | 1 + accel/tcg/tb-maint.c | 28 ++++++++++++++-------------- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/include/exec/tb-flush.h b/include/exec/tb-flush.h index 142c240d94..f3898d1826 100644 --- a/include/exec/tb-flush.h +++ b/include/exec/tb-flush.h @@ -23,6 +23,7 @@ */ void tb_flush(CPUState *cs); =20 +void tb_flush__exclusive(void); void tcg_flush_jmp_cache(CPUState *cs); =20 #endif /* _TB_FLUSH_H_ */ diff --git a/accel/tcg/tb-maint.c b/accel/tcg/tb-maint.c index 0048316f99..d1695be00b 100644 --- a/accel/tcg/tb-maint.c +++ b/accel/tcg/tb-maint.c @@ -756,17 +756,14 @@ 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(void) { - bool did_flush =3D false; - - 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; + CPUState *cpu; =20 CPU_FOREACH(cpu) { tcg_flush_jmp_cache(cpu); @@ -778,11 +775,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(); } } =20 --=20 2.43.0 From nobody Sat Sep 6 15:08:54 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=1757136115; cv=none; d=zohomail.com; s=zohoarc; b=KWnABi/dT2jqK72A5ZuAG99NqbWijmCO+hOqxh7tu0JyoLib0vBn87zShIthxzBOI18YcqTEZiY0VKWjwHSUUOsMgk2eZVmqoEf2BeN3otn0O/tFDU+DN6+Qpgzh4qP2DOezZ3QPL6/NBtdUT6pbI21DmwqgrTr/1B2We66qaH8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1757136115; 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=I7FMx8ch25mi1HM2iSzOFbjlu0abcZfgeYT8ylr/T9c=; b=CNQuSJrsyDl+ABUVKTLB5DTXUNUfPh1i6KowBbOP7Yw8lbWyPbh2/vjz1Ng3bHV5fpPobYIyYTcCdOP+xMmCIm1wwyuaCAcRKXuTQ7BMKWcQPNK4VJdL4TFx3HBzQ/jnN6Rzq/Vsm2uzkdJLGurPzKd1UlsZwCWJVVFynIQlfZ8= 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 1757136115538188.60187276470936; Fri, 5 Sep 2025 22:21:55 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uulJx-00009t-Nr; Sat, 06 Sep 2025 01:18:42 -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 1uulJv-00009A-H6 for qemu-devel@nongnu.org; Sat, 06 Sep 2025 01:18:39 -0400 Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uulJo-0006oU-SY for qemu-devel@nongnu.org; Sat, 06 Sep 2025 01:18:39 -0400 Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-45b9a856dc2so17822675e9.0 for ; Fri, 05 Sep 2025 22:18:29 -0700 (PDT) Received: from stoup.21wol.it (93-51-222-138.ip268.fastwebnet.it. [93.51.222.138]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-45b6f306c22sm441197735e9.13.2025.09.05.22.18.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Sep 2025 22:18:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1757135905; x=1757740705; 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=I7FMx8ch25mi1HM2iSzOFbjlu0abcZfgeYT8ylr/T9c=; b=fhxX6H6F8vPPjijnk4SNV64D+EN4btdIPYviZ7pIdzTc1neOm7RDVZb7hooJ4JQ3EX eXUf8rNnTlutABlXb4l0LFrmGMkooeRihZkInq/kQ/YJDVwjkobAplThQqBZlOPJUJDc rsWmgpn6rKq/4s/siNrmxYcYOcZX8BCBB+OwnBZiILYOlmUUADktvl1NqWfPKYfcGA21 +MblaAPJfVUVX4XNU2RUoSADJedrM9xj1Hr0Vi0SjtFOvxxVJbYKhpQ6v52iI0cbMJP+ CdEJI8JHZPRJuqUuu2I6srVQX5gCN/Tje4UiSXI9x23+cLoTTBVDAIfYimhNEylRwj79 5mYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757135905; x=1757740705; 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=I7FMx8ch25mi1HM2iSzOFbjlu0abcZfgeYT8ylr/T9c=; b=RFMx9ubMMck1mzltMHeoU6vmP3qiBIlxRAYv6tdGPiN6j5stMQwZcA909f7Kf15F18 2fSDVvIzAaQMXIv/jgpJMi74RsHcWdjswy3JdBipY58pbvSC70Q2DuUslbBXtqVYDeXV 3fW7FRB8xlV4TKCwNMg5r5QxiyU9FPpzHJMmZdaSAqNt5PeB4Ft9ducGOvSFFoETI+uk 4wuh2unjlZZBtq7vD14/wdSbRw4LzXV+ZKq6aYjV78rhUNUpnBDy2swprr11g/J5xdQl 8mQ/CqK2skFGgvgYMOr0Gsv3oHobWOfWyXTERlDVf8VA70MjaQB1YII2Hj8PYw52bynk QhbA== X-Gm-Message-State: AOJu0YwumBAWcHxkfHcsRDLn96Hrs0Gtpuqa0MgCUVCwaftm/Y/CSnTb izDEwrgrXJEJZYu+A7odyt0gIqLD9yu/3mIu29T2KrEE1O0gRd2s7JZylataJRlvJMGuYZ5wvdi pTaP5v54= X-Gm-Gg: ASbGncu7qc7sOENr33ApWtB/QWnrgXQJcHHULpLxddta8Xv29KRJBbZKOS5QuJR7C4O 6lf/TNDl8SvCNipFj0VLGGHdXELASzrh6ThJ9I0Mp48hYv6frsMKYHpJv9D9Ex+iNBgRL1Xy6wh SwmDwtkvfd1sVmCqHuQIV8qaWKvARAKkFE8jeH9H3n2WPR305AWbP0vGLo8WmL40UUBdjgboL8+ MHpC597iXd03zRF6VSpkpgsWa1cF4lZxPZIKikhxHMd7zkMXmnKZzBzxgjdwSICzzxj2+R5cFPY Je2LdXrTp1ptDpaWa0Qvzd1dqEr/SAckaSLbuNiSh/Le/WcfFII7NBB2yNOZ1Bvjh8kTU/5L9hJ 7Ahf5QdTuNIVu05Dj5wWc+eAwrToecKV1NFPR/AbH31MppgYMiLeVpDaczc8DxqurvpIN8+joGl zMR9aWHhg= X-Google-Smtp-Source: AGHT+IF/ebYvzRSZdPi3EyzGmVx2QRqe0dxeAEHK2wiOa9MFKYtomYd5SobN7Vo9GE7My8943D/Zuw== X-Received: by 2002:a05:600c:1c8f:b0:45d:cfc6:5166 with SMTP id 5b1f17b1804b1-45dddeee8bamr7375255e9.23.1757135904991; Fri, 05 Sep 2025 22:18:24 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: alex.bennee@linaro.org, philmd@linaro.org Subject: [PATCH 03/11] target/alpha: Simplify call_pal implementation Date: Sat, 6 Sep 2025 07:18:12 +0200 Message-ID: <20250906051820.160432-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250906051820.160432-1-richard.henderson@linaro.org> References: <20250906051820.160432-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=2a00:1450:4864:20::32a; envelope-from=richard.henderson@linaro.org; helo=mail-wm1-x32a.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: 1757136117698124100 Content-Type: text/plain; charset="utf-8" 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(). Signed-off-by: Richard Henderson --- target/alpha/helper.h | 1 - target/alpha/sys_helper.c | 6 ------ target/alpha/translate.c | 21 ++++++--------------- 3 files changed, 6 insertions(+), 22 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/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 Sat Sep 6 15:08:54 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=1757136045; cv=none; d=zohomail.com; s=zohoarc; b=ciREccIM1YfHauTZKl/hxqiXK7xjBt0yp5UoSKqcprrGOTEE7Ug9QWOEhexQ9jdmYve74Vg4f/bLvo4zxCnRZ19v38eTx3YmBFtGVX07paX+PjYfV4H1qJRrGoNO5c/QPqhzAEASxWQ2ax0v7QY/T+MRdMyRNw3pd8YOrWkMXk0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1757136045; 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=BLmbMbf+HJtfOJ60NWtJJU5a0jMYYcgPpAt4Vz1/6OI=; b=EQRzCtOOlMCxTKtJu4Xp4p2HYCeLXNrAoX26jVUrO+PjU4TbTZDtGoiHi5194tjDysbdvMIxtlUZmYWtYWA0MdfnUgQV7H7p9jfdQIlDZ5eAMb6iO+Tum77Um81gdrn8Tdhd8UMvA5B7fk8nvnKns4qo1vmkZj0g9j66ou98XY0= 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 1757136045243566.9760959776023; Fri, 5 Sep 2025 22:20:45 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uulKE-0000Ny-5t; Sat, 06 Sep 2025 01:18:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uulK6-0000Kx-7g for qemu-devel@nongnu.org; Sat, 06 Sep 2025 01:18:50 -0400 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uulJt-0006oc-Ee for qemu-devel@nongnu.org; Sat, 06 Sep 2025 01:18:49 -0400 Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-45b7d485173so18287745e9.0 for ; Fri, 05 Sep 2025 22:18:29 -0700 (PDT) Received: from stoup.21wol.it (93-51-222-138.ip268.fastwebnet.it. [93.51.222.138]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-45b6f306c22sm441197735e9.13.2025.09.05.22.18.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Sep 2025 22:18:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1757135906; x=1757740706; 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=BLmbMbf+HJtfOJ60NWtJJU5a0jMYYcgPpAt4Vz1/6OI=; b=xhdskBiAOKzP2RSK4tZ6Rd9xhsiIcO6PwjnAm3P0XJQaFiotahuTdqWoGbNPDctp1a 7O1FFJEahTuwQhH9raPX3WJef2AYrm9pYgvRAmRxRYGkLbxipWDKGtt5rEHiNiycSdV6 ZUvYyaUcCusvW19RsabwbdkdRylAJBwx5g0HaXMYUHuPhQYwTPABly8ndLYb2BBuILHG 6NDM2+1p4lz4SxzcelDPedJxviUmBM//IoYZH84JruLnu6O7gi/+YevDTsL7/RqYdfDF uDij7sLYMbijTpFKmNanEAEHMam8FPJ8mI3RS1Ky1Dxs6LNNWqD4xWLULokqhATDiCqG 5Okg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757135906; x=1757740706; 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=BLmbMbf+HJtfOJ60NWtJJU5a0jMYYcgPpAt4Vz1/6OI=; b=QDJsOZnqEq9NGASKCnDMQ3V6061cC+92I88TW++zGuQ7Ol+G1OYgyeh9tNFQRe3+Qr 4ShBuaRRmwYAMt2pFobppihhVn/7PzIAMLdQWTFdwznX377UM4vFzkSelxvXR8symXMZ Fhu7Lfsead7FzKs699s/0Za/566iXfBwIVzBoGV0VdXl0Kydj3jvtLa09hsZCnMq5d6M 24ZWUdethuAODVUDbNnQrrRNTXtwzREdUq05s3gllEksrlpERDivVz8Teg4D+1tb+xcG xKYsWtK+FrrIruwGEyFsoUtF9BfB2NQQOTi4aytv8frIvminfjDYKb0cOpp+jzqFdk0A vT+Q== X-Gm-Message-State: AOJu0YxjRxpiLBnaiEXQJ3qkEVArnX8OQtjBH0/VFWJsyh5cOTVzPVoo 1JNEZ6RHmf+wbyFi472n9qyhODl4EWtPCZDsLRoJRvI5BEgTdSOc/lNOpb+TV2br/r944SMhoO2 lAetrkV4= X-Gm-Gg: ASbGncuKrPM8seP0XEK5xjN15ut5f3kfBDF3wFi3ZzhBUk1QKpX2x/kHD3Dw2WR/iA8 9QUjKDdgTCdJz2aBXUza4NAQJXtdxMi87oPFi8NX8RYe7UCz4bI/m6WPN5/dYjySmgi2z8SaYei OgRIEcTeTLFO60U8aKb9+XnKCvYDWs1DCOfH5Onyi9rVqjBJc0uZiBxWwXtw66E+KxFzNn3MOND lGALVpZuq6fCPl4aSq1OAclCmzNTlcrLbzR10ViNw9a8si4MxUBGp8ASo8fazo8bbTP3bPfrnTa 9s9K+2oyhxVegIEatoGb0tAfwx7u8NTNp3tg8beZkqPbiB/DO4yVBqrvpHo4Zi6s5LSlIlLXGB0 EJ0i34MMCFX3dYd9BfovoDyacI4MQ3HCCbS6wAM1r10fhhWC8YLduRiS7yUsv7P/kwUYXn1r1 X-Google-Smtp-Source: AGHT+IFSoU+hRjeRNMOJEJ0Faw9Fl/6ZcjIG+5rmIQy6fvKCLvhgeCcq6BmFxfutZ1IC9vRp4cLAQg== X-Received: by 2002:a05:600c:3b1d:b0:45d:dc85:c009 with SMTP id 5b1f17b1804b1-45ddde92816mr9450635e9.10.1757135905827; Fri, 05 Sep 2025 22:18:25 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: alex.bennee@linaro.org, philmd@linaro.org Subject: [PATCH 04/11] target/riscv: Record misa_ext in TCGTBCPUState.cs_base Date: Sat, 6 Sep 2025 07:18:13 +0200 Message-ID: <20250906051820.160432-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250906051820.160432-1-richard.henderson@linaro.org> References: <20250906051820.160432-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=2a00:1450:4864:20::332; envelope-from=richard.henderson@linaro.org; helo=mail-wm1-x332.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: 1757136047046124100 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. Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier --- 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 Sat Sep 6 15:08:54 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=1757136144; cv=none; d=zohomail.com; s=zohoarc; b=KQWqcrwU47X6FHE+FKJvWhPTfJArRAHs95KdDIkOwUCXAifOGWK2rIXsBCIUZsbUp8uOce15aNs8COcHnNAPL+NPKlmljh7NZrdWCV40m4TGN+vsgjP8RQJD7vV9Eqg79JbYwf0qrGIDu+xtDv3IqwB7JIwRk50py3ukqn2MzTU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1757136144; 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=jkAyCPDIiOkuBSXCSpnCNIWVLui0hP9Os+Bwwzusze0=; b=SMgzdzWbQi35fkvfjfDhcyjPOcrRFCMFtjKEiIkZF5LnKj+gsNOmuUfE9kvrHvS8cB7gqcWj9u6/xb01UnvGZBSEVuSIcDdOo9vFSFolUg2tidhezwIdN49aA0dqjeQC+0cKDTOBsLw4/6dw42/IhO8keCUkPYEU958AjxaHVXw= 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 175713614453685.05996408429178; Fri, 5 Sep 2025 22:22:24 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uulKC-0000ND-HR; Sat, 06 Sep 2025 01:18:56 -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 1uulK4-0000KA-Fz for qemu-devel@nongnu.org; Sat, 06 Sep 2025 01:18:49 -0400 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uulJs-0006oj-1y for qemu-devel@nongnu.org; Sat, 06 Sep 2025 01:18:47 -0400 Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-45dd7b15a64so12185095e9.0 for ; Fri, 05 Sep 2025 22:18:29 -0700 (PDT) Received: from stoup.21wol.it (93-51-222-138.ip268.fastwebnet.it. [93.51.222.138]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-45b6f306c22sm441197735e9.13.2025.09.05.22.18.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Sep 2025 22:18:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1757135907; x=1757740707; 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=jkAyCPDIiOkuBSXCSpnCNIWVLui0hP9Os+Bwwzusze0=; b=IeVvfYh6/75Np0dhkOrt9c9TaFleuAR1SGsK9UWpYEkFCIxIdAFQKsnhikAcoEgF31 wYcdCEWgYmlhOgN4Ypk48LmLs4vwVBVFw+I7OnV+m2Me3SFDikdOjf+3a4PhkLz7oMl9 kXmI7nrSuNqmzlTbzoBG7HY+XAPIX88JCWbox5nOyDhyfV4DOlohDlR2PVY+Pe2Fgznx FCvCgbWvuvpaZeSm4En+muPOC85kqd5o3JvuXrfeDR/mqfM+cTZRkTrFeA8HZde5ES5v MD+IkGrcBbuZ0/fZpi60Cgib5jFPYIuk1nxVvK2qHdl1x9YsTRsPaUAfKOYRBvAF4GQK jl2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757135907; x=1757740707; 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=jkAyCPDIiOkuBSXCSpnCNIWVLui0hP9Os+Bwwzusze0=; b=oCkf6SMgJLpPCXXqMaHPsZJU8K23nOBpVTy1Hx3uG79Z6lqs305v2z3CkYa/KdOZLG cHDHDz42U3A+9tVWtQjvWxnWJAAc/bg5bDWeUhBfDAau8FHdkJQokpZGweTLfPCmUMg9 E1WnwQRPuQxNWfbpJrhJCKuU/75jRKXS19SqIpt9r9nwuEfIA95ziFTG2ARvClbhAeI0 tXACxLkg1wAxvVOpJdsKbxTF/UGXv5pe0ILMhtNlZuRjoR5HYCnEPGvTxnquhoJBT4J7 b+E0qHrDfIsKz+j2gKT5aQmZDSkzzuL08o2QvqpuqSrcLFH/sqFsjn6HQXGXEkxvmEBI b3gQ== X-Gm-Message-State: AOJu0Yxypd3KweWDYNMdjQRoV5KzP8quteoLccKtj1n0w5y6T5lHTC9F fEuTPkK7sv1yM4kBwVImgntIOYNElUeby9g40TpswxOH6yQOmouyRuSfBDQmgYVCj0V7ReSmiZz fAv7q/Os= X-Gm-Gg: ASbGncsxVZZlsop8r8MyLzPuT4wPB7s1eB10Wt7+55DSdN1an07/EI+rpasRMcwnr4J Dokb7vCLsxtjDat98GDzcOCf/gd+VZOPDKXurgCWmCMYYjwMUnmKAutTWI3ISkgfIK988EKGxUH S5gnogpGfWdHhTf2YH8Hl1ZBG7cDeWk0agZCkndBGJvkmJmAWHzFUY3104fifVmvcKuLSxzP9gE qEs38KRaDMaJyd1P45VHKDs0esuHqe0l0ngcnrhglAoyk55OJ667nzuJAenDL670CoyIdJMZffq gnPBH3WFuqkGBIfSvPyL31EOlgctgTdm5b9JCxAuVAoUkda+nAnmvY8GDA+JJZFa2L/3ov36oS9 fupTks6XWPnVTWen8hwlry6mjdq9nyy96PHcrM9BunKapEW0F5yIi5oMt3fUvWvCgwlz+4DCP X-Google-Smtp-Source: AGHT+IGXpd6hXEUPXfBL/PndXzMtuesXiAmPhqA3jq+gaxOx2xdLg2rEVRYR106izpa5y+Oheky/3g== X-Received: by 2002:a05:600c:354f:b0:45c:b61a:b1bd with SMTP id 5b1f17b1804b1-45dde220a2emr7328645e9.18.1757135906611; Fri, 05 Sep 2025 22:18:26 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: alex.bennee@linaro.org, philmd@linaro.org Subject: [PATCH 05/11] accel/tcg: Move post-load tb_flush to vm_change_state hook Date: Sat, 6 Sep 2025 07:18:14 +0200 Message-ID: <20250906051820.160432-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250906051820.160432-1-richard.henderson@linaro.org> References: <20250906051820.160432-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=2a00:1450:4864:20::332; envelope-from=richard.henderson@linaro.org; helo=mail-wm1-x332.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, 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: 1757136146060124100 Content-Type: text/plain; charset="utf-8" We need not call tb_flush once per cpu, only once per vmload. Move the call from cpu_common_post_load to a tcg-specific vm_change_state_handler. Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier --- accel/tcg/tcg-all.c | 21 +++++++++++++++++++++ hw/core/cpu-system.c | 8 -------- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/accel/tcg/tcg-all.c b/accel/tcg/tcg-all.c index 5125e1a4e2..a0bc0e58c7 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(); + } +} +#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 a975405d3a..c9099c6e7a 100644 --- a/hw/core/cpu-system.c +++ b/hw/core/cpu-system.c @@ -207,14 +207,6 @@ static int cpu_common_post_load(void *opaque, int vers= ion_id) cpu->interrupt_request &=3D ~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 Sat Sep 6 15:08:54 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=1757136033; cv=none; d=zohomail.com; s=zohoarc; b=NKeTOp+4N148O/0ChedXohk/Diihwqyju9OOReN6RyKd8u07tt8WGdNCROf98wBiuLPcc3aPewDrS3yQ5q46SkSIDiO2NQisoRYmie6rV9lNsSgKCEykXYraA63ck/T58W6NJS2zKuGiiPaZEKNg6wT3/EFBI4ms0ZjrAGiaPAE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1757136033; 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=AkmKqMS8/SMg8ZwOM4TI4jWjmtGLf5UxJGwLaRP/AiM=; b=msg8EAbtMbCmZach3mIAmonkbj3n9Y0g0w+L6zR8nly/GhbOyqU3geyJV6Bo7I86xI/WVrl8Iry+GYrFbgWygStj1ZkKBl7bRarNw0yp+guhyhu9Q5QDfEoKjOmbzB+jMcIWcP1lPG5x7TQ2DUGw6VpWL2P6qSUSWQiH0uj/F+Y= 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 1757136033801548.7234674220215; Fri, 5 Sep 2025 22:20:33 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uulKJ-0000Pv-M2; Sat, 06 Sep 2025 01:19:03 -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 1uulK4-0000KB-Gv for qemu-devel@nongnu.org; Sat, 06 Sep 2025 01:18:51 -0400 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uulJp-0006og-U3 for qemu-devel@nongnu.org; Sat, 06 Sep 2025 01:18:47 -0400 Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-45ddddbe31fso1622455e9.1 for ; Fri, 05 Sep 2025 22:18:29 -0700 (PDT) Received: from stoup.21wol.it (93-51-222-138.ip268.fastwebnet.it. [93.51.222.138]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-45b6f306c22sm441197735e9.13.2025.09.05.22.18.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Sep 2025 22:18:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1757135907; x=1757740707; 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=AkmKqMS8/SMg8ZwOM4TI4jWjmtGLf5UxJGwLaRP/AiM=; b=AiBcYzUaek7hnyNgbU3CVuXUk9bZuISIi0pFfjI2otNkibWub9orOHG3Gq5xsD72bz jEZ982qk+nG9NzO8v4Eka60Q81aD9XudLuwkLNVUmr+E90twgE5g9EWNaQ5tM8voY0LK vVuWshi3zQ8nd4nhPT7YNzxObAx8/isDQVmjkEGwfLAhe0FERJ0IO/e83HrhzfhpQeOB 9RpGdHmtNnTQ1DFKp18hevuzDjkJyrSYvpV2ZMZELU+YUumD6Okcc85Pu2t0ZYM0OHgR X0zOxmQQMBr3wOhjmHCB91vS92LkAyEF4RQ00OCVNuDf5fECQLDWSQg/tYKwaqKf1oZT v1yA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757135907; x=1757740707; 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=AkmKqMS8/SMg8ZwOM4TI4jWjmtGLf5UxJGwLaRP/AiM=; b=cGXmMn+vEWR+fqK6tTz7AItj+P2skuaZUR2xNyU1IVEOfuQQoCFaMr5sLx3NVUP4WX D7hg8ZjAYI5JC3d2vwsgw4WEr4YLqoV45u1Ezi4DGneQw86HrwQxm0RnWvcWWQhwGqTC WVGVVdhaMTxx1ZOAZF3A1ii1TF1ja/cVBNJY1pmAnXTbxbZjZz9b33lfm9XxdAGXaSVo MYvQGIX8Pu3dULJu3d68VwXYTZT2okT5iQ8O1HQ2CzQZBIka0x9fUrmpKStuVNVo6gw7 3V475zueTHqBFPBEEeXz7wU8aUnjg9qimBhCZziu5G0qIa43LFjkiPXfaudoK0evaCfM Zfjg== X-Gm-Message-State: AOJu0YwjP4kX8k32wMPpuCnAtVJGWrYQY67MkUIF8+cQ08qi83nfbHkL I9nUASAR6rQROqMfvul4WnMjNWK7IPtdPWsMTOlIxYAVRkYN/vxK3AgpAKVBSDAC51HAILuyKYj qYClUWeg= X-Gm-Gg: ASbGnctjOXAa7Q49qUq2kaYjHVi5PrM0anJsNzyyMScEOSK5WhXdT14t5T8rYjOheSq kuDyU3xASDs6/GMPXUiIfmwz1ukekTdUEs7SODOtpDBtTTazZPBIRhYOeTv9j0bs+Mmvd4YvgrG PaBG+bDoKOqohmzN4hHeoxShXo0u2fLRjRZsSzZNTK1NZv/yHRMlP6BOTtWBkaor/PDzDkgZ6h1 QbEmU3+e8z0jTBybL4afaovu00gaH4YYmgWnDjtX8Jy+eduooe3mjCgOZAuFtE35NXscTNoxSmB ZqoNK3NFgYUytedSbwPo9v+jW/3iARVMD/SZiL9ozqJT3LXIqaM+qlkV7YM51gHDyRgtDU/n3zn vfEhMiDFELfaXYdPcHh9bX9jjNVpp+wLMwJtgFGM5p7VteFCREd6jPG/RkX2HbG3NnQNRhg+4 X-Google-Smtp-Source: AGHT+IEy7/CM0r5HDO0FepBaIknrHfRnjDQA4LiXCnECMp4tIhvEV5ZDhqLJua0VwrdObRfyNE63vw== X-Received: by 2002:a05:600c:358a:b0:45b:9322:43fc with SMTP id 5b1f17b1804b1-45ddded6b98mr6955555e9.29.1757135907357; Fri, 05 Sep 2025 22:18:27 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: alex.bennee@linaro.org, philmd@linaro.org Subject: [PATCH 06/11] hw/ppc/spapr: Use tb_invalidate_phys_range in h_page_init Date: Sat, 6 Sep 2025 07:18:15 +0200 Message-ID: <20250906051820.160432-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250906051820.160432-1-richard.henderson@linaro.org> References: <20250906051820.160432-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=2a00:1450:4864:20::334; envelope-from=richard.henderson@linaro.org; helo=mail-wm1-x334.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: 1757136034169116600 Content-Type: text/plain; charset="utf-8" We only need invalidate tbs from a single page, not flush all translations. Signed-off-by: Richard Henderson --- 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 1e936f35e4..aa2e5e1e84 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, len); } else { g_assert_not_reached(); } --=20 2.43.0 From nobody Sat Sep 6 15:08:54 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=1757136069; cv=none; d=zohomail.com; s=zohoarc; b=AH1HfSfiOmYo7CWyG5FddUwD0z52UiI+E+nD5/ByQpWtzgpdQlPDBKHOCyXWybljl01oGs3NRzos4tbxHlSxtxGbzGXHMjEYB393hTWmuMID0y3V9DXuCRSi6aRUnqPMReq4srtJoL40DDQoGKkn1TkPiv91jxxUqmPkvYuH9LY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1757136069; 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=tqfT+leZhy7Rg922mo2u8oPpLUYve9eJPBZJd2GWVis=; b=fOHpIEfUA5QLuz1hdjd9TvPMhvWfXMFV09lvfGRftfaKBNrEMZJsQ/sVEPzcykFnYv1MQqYZwckcmhe78nsoC80TxwSmtfT89+ed1MA5nlOG0fbTuF0k7/cUYj1+w/lzOVhEwghNqD6DSygVgBpwixJVCO53642yOy/Nso/JKc0= 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 1757136069123655.419048880664; Fri, 5 Sep 2025 22:21:09 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uulKj-0000Yc-3T; Sat, 06 Sep 2025 01:19:31 -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 1uulKA-0000Ma-JJ for qemu-devel@nongnu.org; Sat, 06 Sep 2025 01:18:54 -0400 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uulJt-0006or-1q for qemu-devel@nongnu.org; Sat, 06 Sep 2025 01:18:54 -0400 Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-45dde0c8254so2216055e9.3 for ; Fri, 05 Sep 2025 22:18:29 -0700 (PDT) Received: from stoup.21wol.it (93-51-222-138.ip268.fastwebnet.it. [93.51.222.138]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-45b6f306c22sm441197735e9.13.2025.09.05.22.18.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Sep 2025 22:18:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1757135908; x=1757740708; 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=tqfT+leZhy7Rg922mo2u8oPpLUYve9eJPBZJd2GWVis=; b=jFhYFvACYCZfmV3WR9gETNsHqGQQGD0iRt0GKkZZa+SRd6sIuKbSYXl1qyg66aK+pK gkTNIxATeWmVvb0oV08PA5hIvBUwsc3qTTpqJWdfppeuaAxc5WGawvu9hpydAdj1F9a7 G5+AZlVEZeJW3G4fpkkMIswgxCcrtOxfvw086KUA/M9dGIcX88kI8YESCii+sJ9tICc9 wfyCKUI/vpwTKZXaodznQlF8VAB7eQhuTSc/G/eA3GOUIwLUDYagadGbVwrDBFdjF1Ug 2VNF/w+7SR7ERlvWagPfzHO1tnCgQlqKjyFNAQP8805mwqV+uqbj2ilQkfHqz8jf5Jf6 erFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757135908; x=1757740708; 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=tqfT+leZhy7Rg922mo2u8oPpLUYve9eJPBZJd2GWVis=; b=ZcDQ+v6PU/xG67IarLIDwJ47TBHk4U7h7irPYZhLGIiHGGDDVIk61Wpc+jA8iJ1KeN qh1FwmMXBhy0YzVl99wfezHrWwIwWdukUOWnknIxSpyTwBgL3k8hRpxJ32kT0HCQA/9Z wZFlpbAcvwV+ZwJyT8f/ebwS8Rgva2HdoIaHvqCbU2xyuW5wHRaggsnJiREHtiNizB4W ug4fyr9YhPIDLpBE7NDuYmjZ6NXjR3scylLLo+/GcRkdy33h8LsiFxpC1Jmfj0k4hSSj Cp0C4ar0TzvGF0Mv4s779zFAwyjsfUNa3Pa+/v8UF2D8heVJ/0mIcVPSYRj86szayjBJ VFDw== X-Gm-Message-State: AOJu0Yzl3ItlWCoIA/jAVpcjkYv202slasxqjLkXQsdPAPPvJWhiVXHm 1tRadnlTq5QvFpgbd8XXV7lncBsV0QzM2s+g7nICbFcizO7exk/2Z+JccHxvflmngz85oqeY/6H MEjMerCE= X-Gm-Gg: ASbGncvVawxz55ZRHjingbsBhVjsECN/qYqrB2pytSv3nxkvbm3kZ3vfiVsGvQR2hEw QBx9NdPHznMyDRUESEj/kh7zwjCQJ/rZ6fTlywfKgmamBdZqPMM7Cxp1YSXtTXezKyUT+kHBbTG tsDssQrqdBBpmBNjCC7grbylo8567tqAoVZiJLpVw+Z5EO640BAXK78Ce4Bs5/kt0u38H/typvJ 6Rnkl+S4ACojdgEpKxbFKjcsgTe2I88FDqp/EpZNFT0JPrU71pfWqq2otfrBg5ha/u2gNKWlAEI VVYmTdPW+Isn+T8jY/0Yxa/c9ajzEwWKrc9gHqwL/yr9ut9QL9TtUtUKevv3kYaCjppXWuVxJjP Cxr4eKXPDdwRHLabyUDK3SnOG7FKD3kl8XCzc+I4Lfr/ArdlEwuS1jcHRxMdAjsg6RNu/t7GkDn Rji/jsO8k= X-Google-Smtp-Source: AGHT+IHn8pbOhFCIcFZb74BzVRbNrrbOOP8PeToenFp90YnkTqJiSML0XxFAWQPjl9Y+qZgU/kvILA== X-Received: by 2002:a05:600c:6995:b0:45d:ded8:3b6e with SMTP id 5b1f17b1804b1-45dded83cecmr5669825e9.17.1757135908035; Fri, 05 Sep 2025 22:18:28 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: alex.bennee@linaro.org, philmd@linaro.org Subject: [PATCH 07/11] linux-user: Use tb_flush_exclusive to start second thread Date: Sat, 6 Sep 2025 07:18:16 +0200 Message-ID: <20250906051820.160432-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250906051820.160432-1-richard.henderson@linaro.org> References: <20250906051820.160432-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=2a00:1450:4864:20::332; envelope-from=richard.henderson@linaro.org; helo=mail-wm1-x332.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: 1757136070322116600 Content-Type: text/plain; charset="utf-8" When we start the second thread, we discard all translations so that we can re-do them with CF_PARALLEL. Since there is as yet only one cpu, and we are processing a syscall, there are no live translation blocks and we have exclusivity. Signed-off-by: Richard Henderson --- linux-user/mmap.c | 4 ++-- linux-user/syscall.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/linux-user/mmap.c b/linux-user/mmap.c index 002e1e668e..bd2bbaf1f4 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -1010,7 +1010,7 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, = int target_prot, CPUState *cpu =3D thread_cpu; if (!tcg_cflags_has(cpu, CF_PARALLEL)) { tcg_cflags_set(cpu, CF_PARALLEL); - tb_flush(cpu); + tb_flush__exclusive(); } } =20 @@ -1450,7 +1450,7 @@ abi_ulong target_shmat(CPUArchState *cpu_env, int shm= id, */ if (!tcg_cflags_has(cpu, CF_PARALLEL)) { tcg_cflags_set(cpu, CF_PARALLEL); - tb_flush(cpu); + tb_flush__exclusive(); } =20 if (qemu_loglevel_mask(CPU_LOG_PAGE)) { diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 91360a072c..d9c394856f 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -6633,7 +6633,7 @@ static int do_fork(CPUArchState *env, unsigned int fl= ags, abi_ulong newsp, */ if (!tcg_cflags_has(cpu, CF_PARALLEL)) { tcg_cflags_set(cpu, CF_PARALLEL); - tb_flush(cpu); + tb_flush__exclusive(); } =20 /* we create a new CPU instance. */ --=20 2.43.0 From nobody Sat Sep 6 15:08:54 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=1757136082; cv=none; d=zohomail.com; s=zohoarc; b=VBjtKkzDZyU98k/KzQypOniJSem9LkqE+i4idXTxnz9b/H4kxVf8nLOKIUjwL3ptqtOhGwS8dYP5K90FuNjo1WrR5+GTOzeKdcZMTUlcxcidbXtd7/esNqgbPolQAuEcAEKIIVB5QHycahO7HeQOMa0WOrjNvdIRIBeySo8Oylo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1757136082; 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=RWFu/FOotqt+eEC1erBIyw/Wf7YECCKKISB9pmV9BoQ=; b=NFOgPNjpA96nwDwYaSthX01G3PDS6k4+MQdrfz5UTqWT655tJ0m0+rMoknW5tdRN9PPU1rzEUFZRCKSNXVXPJ+Ok3OY99hdVpCqs6v95uKIyeByfSzfo2BWNui1dwo6+RDI2zgSfxbVjew5zF2wQsI88Rd6B0Q3CXZUxuIy0swM= 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 1757136082492663.498328430881; Fri, 5 Sep 2025 22:21:22 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uulKW-0000VR-TS; Sat, 06 Sep 2025 01:19:18 -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 1uulK2-0000CX-55 for qemu-devel@nongnu.org; Sat, 06 Sep 2025 01:18:46 -0400 Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uulJp-0006oy-UF for qemu-devel@nongnu.org; Sat, 06 Sep 2025 01:18:45 -0400 Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-45ddc7d5731so4963115e9.1 for ; Fri, 05 Sep 2025 22:18:30 -0700 (PDT) Received: from stoup.21wol.it (93-51-222-138.ip268.fastwebnet.it. [93.51.222.138]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-45b6f306c22sm441197735e9.13.2025.09.05.22.18.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Sep 2025 22:18:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1757135909; x=1757740709; 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=RWFu/FOotqt+eEC1erBIyw/Wf7YECCKKISB9pmV9BoQ=; b=AcdprEV95CW04Vi96zV/7dYROmx+zp8IsU8MMruMayI42BTnUAHlJfOF7vNyPyK/Qn dxgQrz/5+6xnczCwzSvT7WbcdO5X6Q2TANa+h8RGoWwOz8sy2G1EWqjbAaP8jMLPlDEY iiHX6Mi73r5Jk4JnYkIGoqcrDJDyOSPk9/KsQm0GKC4u7f2GgmfQXGsia/odJ5ErLnf4 pLxRfLLBkdEpUqQBKlb1etGeBrZxEJtQcpLH77pUvF2sEbwxJHuMFUGu89ta2lxsuwGg BIXkfWLOOvldpAYyV1PB6BQpboxw6qOrZSG2Y6+aeqH4yA1z7mAkEvTGMFCTXpM2V6XQ u3nw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757135909; x=1757740709; 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=RWFu/FOotqt+eEC1erBIyw/Wf7YECCKKISB9pmV9BoQ=; b=bi8C85Y/uPwrUj2nUEvOl+z1CSAiQmzy1h0/nOXk7W08N2qjC09G3UzZEY0Op/v7Wj 1C1HpaN/d8az/0yu1C2452BxIK1HdvZkwlNc/hMXmXNvO7MYBukPsbK7hJYWUJNUwKAl GSv+BzUy8tq+fuMUtMg/vdDdvmsuwmqB9vU0aKCfbQ3psggilbb3YimUEW5nD7RDmxiI hEWhK8iChranijKo3RSS2gxWi4lzVpdANIqgz5gLsvzxnEzhgRQzwlRACNHoSyp2pzdR CIoZjk2GDBL2NiOX4zRkOoz3V5yJk9xVEllGxN3QWxf1o92qNSTx3WYbIbA9fh9VQGTJ 0y+w== X-Gm-Message-State: AOJu0Yx5VE6rpWuEMdv4B04CvzD/pmitO7jXCU1up87AgpdlQxBRZMYV ylygLG1P0O8cWlZs7BnPSMjh9R9iRNJA2TZ0aE2/b90ye9VxlTXgKM5JVkIgGNr1ewDjcnXJx0i e8XhrZ3Q= X-Gm-Gg: ASbGnctX4AmWQoNRYOIaAaCU7HSEWqb5P6vXQN4aT8lh7ibXo/LlXuP/jn4ZjWrcNqT vv1dLdg4j/P0jATzRtxbIl8jai2IlufLr3d2K2HmK2avPWjZ2I+xtm0vGd5nQnRbHHiPWTlghQm 23mBzG9+dOvDHfw+ylVO/nPGvbUXTwO6ZRYUWtQ4SwnBCoDzP7mBLVx2kRu/Jyw1R/y4xAdmVbG 3xSyQXLOxiNibx9dJ/HcrFFy7VfV0+Uwgwqut1H32AcbtPNBtS5KxZmVUmuR9pvWQ4P3m7UcNuu hrTknZwcF0gd2fdS6vhdkbrg0Lc9DnGJZX793hkZjVWAYF8Y4mmSMlzmE1HxC02YvT25i5q965N 9bcMGn0otHWpLAO0GEeRXgF0m4S/sEyekR9026Atir26oGESnqyi4Wv1BBjb+SM2s3hvygWEXtg YNGadu50o= X-Google-Smtp-Source: AGHT+IHBxE9W1OtcwdfWI8AuGrh/X5ENXub/MjIMfZMIDP+iHrqVsuNx8WGo3o/SmAWeNIAB9C+xtw== X-Received: by 2002:a05:600c:6298:b0:459:d451:3364 with SMTP id 5b1f17b1804b1-45dddecdaa7mr9221505e9.24.1757135908773; Fri, 05 Sep 2025 22:18:28 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: alex.bennee@linaro.org, philmd@linaro.org Subject: [PATCH 08/11] plugins: Use tb_flush__exclusive Date: Sat, 6 Sep 2025 07:18:17 +0200 Message-ID: <20250906051820.160432-9-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250906051820.160432-1-richard.henderson@linaro.org> References: <20250906051820.160432-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=2a00:1450:4864:20::32c; envelope-from=richard.henderson@linaro.org; helo=mail-wm1-x32c.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, 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: 1757136083402124100 Content-Type: text/plain; charset="utf-8" In all cases, we are already within start_exclusive. Signed-off-by: Richard Henderson --- plugins/core.c | 6 ++---- plugins/loader.c | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/plugins/core.c b/plugins/core.c index c6e9ef1478..4ae1a6ae17 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(); } 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(); end_exclusive(); =20 /* now it's safe to handle the exit case */ diff --git a/plugins/loader.c b/plugins/loader.c index 8f0d75c904..6849e1c518 100644 --- a/plugins/loader.c +++ b/plugins/loader.c @@ -378,7 +378,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(); plugin_reset_destroy(data); } =20 --=20 2.43.0 From nobody Sat Sep 6 15:08:54 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=1757136126; cv=none; d=zohomail.com; s=zohoarc; b=T6tgf+pfsEMMiT8a/4XMXKRM+E+HqzR4oynQHFTkjBesjJYwPhJJGgmxnDK9yzLn8HlBfvm7EYUg5QKdEG9WTA4Y1U1ihZyE1uTWIeQep9I38dmVNFizvEHB0/VdBVuBG83mjqy7lkY1C00qPxGJ232c0I2zA8cMnXjx3QLaL0c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1757136126; 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=si78m6k1/2WbkO3UQheH+as6HI/9NYY7KBL//tRndmo=; b=K/BbXyL7JOJzACDdSlSKK4GAa96WuY9hdaqIkNh0teDh2plqF0a3lxPrvMU9oGwIW3jZvph2XjHes6Yw/g1JwAdVAMf7HKoijuNhRti5p1bGwl9gV64M6jXyUMe9DhFjsiOL+e/fyyW7FvCznEN/v/ZHVuYiizUZhUJEFyph64s= 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 1757136126103198.67272786782144; Fri, 5 Sep 2025 22:22:06 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uulKA-0000ML-HK; Sat, 06 Sep 2025 01:18:54 -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 1uulK5-0000Ku-Mo for qemu-devel@nongnu.org; Sat, 06 Sep 2025 01:18:50 -0400 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 1uulJt-0006p8-1y for qemu-devel@nongnu.org; Sat, 06 Sep 2025 01:18:49 -0400 Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-45dd5e24d16so14961225e9.3 for ; Fri, 05 Sep 2025 22:18:31 -0700 (PDT) Received: from stoup.21wol.it (93-51-222-138.ip268.fastwebnet.it. [93.51.222.138]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-45b6f306c22sm441197735e9.13.2025.09.05.22.18.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Sep 2025 22:18:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1757135909; x=1757740709; 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=si78m6k1/2WbkO3UQheH+as6HI/9NYY7KBL//tRndmo=; b=BvB8/ev3YciUkNkE3cQSsdVl7ev+kME0QMLkoxVgMxGUpSmFsaePE6u0F77wFbtk2S nK5CIF0VIvvKCCr5Y31GdJIrivRvioWUqOKzwKdDhQVKhMETY+lbJgQchFhAMI89yLOK iaxdlUxGB2D7D/zuz8T95bVA7uyHacGueMAOe6M9lNN/kruBORU+1KfklpmiRww5vxzY PIxjfZey7RbthsUbMMH/eMIc4vTrg5SNF7oO9LT8TYlQWLsV6I0OwFPrSOJzefw6G28n YhAR39fevYZ8YPh5pfllZt3DMvcIFNsxXcOLdFjzOKbONvmLR2foFCGtl5b61fdaPkwD HMXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757135909; x=1757740709; 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=si78m6k1/2WbkO3UQheH+as6HI/9NYY7KBL//tRndmo=; b=w9mSxk2nMc88l3pHiuFURSx2kVaU/Q3XIGIfWpSsIBvColqdNs5z0D/HRknlUqRx0u 7axokhvTbGjGnWcqI/pT9ptGYrHLZingKOnBTVuq9iZd75XBOZOxlSqEfsmhUb7IZp5p hXf+A4KD9mw2vILksrOcUkvnxscqKZRvnhAzZS6d/iW/i73M9I963v3o93qazjQp8OCP PCNAKP4b987wtG+aWfRV5pJ3aj/T8ERMQCdM1dh6nhhC1YI7y5PE6obzKhhYxCYzn+1h 0+TcySZ17WzwO4E3Ez5FEBDBgiY10B6YEQS0UKuhJAIttTwmaZeTtBtCAEIsqJvE+dRJ 8+Og== X-Gm-Message-State: AOJu0YyAL3GG2cyEP1RGla43UkPvPRxKD/MpgG2GcPml/P886o2WQ/gZ hRRhoZ+ABkdXMgmS8Mq47jvSIEojdYgHT9N6AuzBqLAXpdRR9aAr4M0NQg4tmjItEpejIm5EDNB JMME+EKg= X-Gm-Gg: ASbGncsDF/NGx1WPf1AwYBScWrIN3XtWgviymjK28A9vzvWCL99RDUR5PTvv4DkLUFS CHZWuDahK16O8FyRaR+v8uUNfALlfwztAx2zP/+HSLndawv5cTQqzk6lpuC8ejeGu1L8vI/mI06 rU6a5AvVkJoiUV61wRPy973fszOqhmrvuUaYijgIIn8GIecSmbNz52dyWwbWE7R9zqqxhHKDNhk L/XqFd25bryC/ggIRoMDayYlKnZFSY6h9w3bqDV4f+CoBAu5iuoGFJf080Bdc55qI+3j1kWC+0y tpYefPNnYtCjLuTV9TO08o0Q6fJtDZktqr8Wd8iy6JzolwKCXX6q/KHh9WP4Qd8pxJka8HZR3Jt yr4Fly5CAYOwzoE/6gPuOKO5fH5rjcStGOwWF1X4YGk9DoNCAylweujnoi3GrQr9BjSQDh83C X-Google-Smtp-Source: AGHT+IHOQ0PxvYVG4jc+CmlT03Svxo6xfEZfCvrU0SodIDtu7O6oiqd6S6g/7rjChaRqvWpihPFT4Q== X-Received: by 2002:a05:600c:4e91:b0:45d:7d88:edcd with SMTP id 5b1f17b1804b1-45dddef8115mr9943125e9.30.1757135909498; Fri, 05 Sep 2025 22:18:29 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: alex.bennee@linaro.org, philmd@linaro.org Subject: [PATCH 09/11] accel/tcg: Introduce EXCP_TB_FLUSH Date: Sat, 6 Sep 2025 07:18:18 +0200 Message-ID: <20250906051820.160432-10-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250906051820.160432-1-richard.henderson@linaro.org> References: <20250906051820.160432-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=2a00:1450:4864:20::32b; envelope-from=richard.henderson@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, T_SPF_TEMPERROR=0.01 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: 1757136127858124100 Content-Type: text/plain; charset="utf-8" We are going to disallow tb_flush from within the context of a running cpu. Introduce a tcg-internal exception to return out of the cpu run loop and perform the flush there. Signed-off-by: Richard Henderson --- include/exec/cpu-common.h | 1 + accel/tcg/tcg-accel-ops-mttcg.c | 7 +++++++ accel/tcg/tcg-accel-ops-rr.c | 9 +++++++-- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/include/exec/cpu-common.h b/include/exec/cpu-common.h index 9b658a3f48..ce9f116ac3 100644 --- a/include/exec/cpu-common.h +++ b/include/exec/cpu-common.h @@ -20,6 +20,7 @@ #define EXCP_HALTED 0x10003 /* cpu is halted (waiting for external eve= nt) */ #define EXCP_YIELD 0x10004 /* cpu wants to yield timeslice to another= */ #define EXCP_ATOMIC 0x10005 /* stop-the-world and emulate atomic */ +#define EXCP_TB_FLUSH 0x10006 /* stop-the-world and flush all tb */ =20 void cpu_exec_init_all(void); void cpu_exec_step_atomic(CPUState *cpu); diff --git a/accel/tcg/tcg-accel-ops-mttcg.c b/accel/tcg/tcg-accel-ops-mttc= g.c index 337b993d3d..f21c86dc84 100644 --- a/accel/tcg/tcg-accel-ops-mttcg.c +++ b/accel/tcg/tcg-accel-ops-mttcg.c @@ -27,6 +27,7 @@ #include "system/tcg.h" #include "system/replay.h" #include "exec/icount.h" +#include "exec/tb-flush.h" #include "qemu/main-loop.h" #include "qemu/notify.h" #include "qemu/guest-random.h" @@ -107,6 +108,12 @@ static void *mttcg_cpu_thread_fn(void *arg) bql_unlock(); cpu_exec_step_atomic(cpu); bql_lock(); + break; + case EXCP_TB_FLUSH: + start_exclusive(); + tb_flush__exclusive(); + end_exclusive(); + break; default: /* Ignore everything else? */ break; diff --git a/accel/tcg/tcg-accel-ops-rr.c b/accel/tcg/tcg-accel-ops-rr.c index 6eec5c9eee..d4bf092736 100644 --- a/accel/tcg/tcg-accel-ops-rr.c +++ b/accel/tcg/tcg-accel-ops-rr.c @@ -32,6 +32,7 @@ #include "qemu/notify.h" #include "qemu/guest-random.h" #include "exec/cpu-common.h" +#include "exec/tb-flush.h" #include "tcg/startup.h" #include "tcg-accel-ops.h" #include "tcg-accel-ops-rr.h" @@ -264,14 +265,18 @@ static void *rr_cpu_thread_fn(void *arg) } bql_lock(); =20 - if (r =3D=3D EXCP_DEBUG) { + switch (r) { + case EXCP_DEBUG: cpu_handle_guest_debug(cpu); break; - } else if (r =3D=3D EXCP_ATOMIC) { + case EXCP_ATOMIC: bql_unlock(); cpu_exec_step_atomic(cpu); bql_lock(); break; + case EXCP_TB_FLUSH: + tb_flush__exclusive(); + break; } } else if (cpu->stop) { if (cpu->unplug) { --=20 2.43.0 From nobody Sat Sep 6 15:08:54 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=1757136078; cv=none; d=zohomail.com; s=zohoarc; b=QhTt/Kj+SdXNj+THCtQSBp9h4Jyz/NUPT+mFM25tAMsCOpdjAtGo1l/c8xGLMnepF4e6sqIWMFXafmlMiW+6i2x+dWzmIqgm/nIiuTpzIDsQECNYLy1U4p1gIWJtsXoF+ZL0v2fQM2DsaiEpXcDJnx9l+ss+bWjcT8VWLfNn90M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1757136078; 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=39nNiJA/IKE7T/FfjUB4iuqZYKXZFDWxmUchhyElphg=; b=Hwp11im4pFLmTdX84vXffNtrYNW/M3VSKg58cg6Fc/KHank0EU8G96kVi9VVQnbdUsn2yO83E3XkJW1Lh1YCCUXR62/9MuEjlFipzeUXBkQie8bp/bAVVrtqJys5VFF/LcdUTWrxq9JOF+uxMpEzmLUCvei72H1p+Y3KiSULxvI= 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 1757136078655948.1527957096545; Fri, 5 Sep 2025 22:21:18 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uulKa-0000WS-TE; Sat, 06 Sep 2025 01:19:20 -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 1uulK9-0000MK-MD for qemu-devel@nongnu.org; Sat, 06 Sep 2025 01:18:54 -0400 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 1uulJt-0006pB-2I for qemu-devel@nongnu.org; Sat, 06 Sep 2025 01:18:53 -0400 Received: by mail-wr1-x436.google.com with SMTP id ffacd0b85a97d-3db9641b725so2755142f8f.2 for ; Fri, 05 Sep 2025 22:18:32 -0700 (PDT) Received: from stoup.21wol.it (93-51-222-138.ip268.fastwebnet.it. [93.51.222.138]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-45b6f306c22sm441197735e9.13.2025.09.05.22.18.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Sep 2025 22:18:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1757135910; x=1757740710; 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=39nNiJA/IKE7T/FfjUB4iuqZYKXZFDWxmUchhyElphg=; b=aDbx/DvGHj5Nq58nWaFSsOkIaga8HSArs78P8fSD62u74sDaLcnYA63cS/tXQ9t7gO 8foXKJ3v7k1CqGQcUVWraJLDM2xiWkbtZttqDIkIIpwE1cszzrPswTM9B/K2Y15JmwCd lM5ZjrBQLwtSR2d4jDMGYrbaLGUPyH4DJxzN8tc22MplxBYW5tCuzU8uJorGgGASq7vB hXj8K2Mur+slc4vyE694MMp8PguPiZLOd01BHdOWwIGfUWDhnTAWTHlLcxnxQgp/G0T3 Px2BODmVY3ZdjjX+YDKov3Ji4Nbea+eruQNz0DFk6UWSUs6FUKAPC+l4N+QBB15zBy2C P7rg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757135910; x=1757740710; 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=39nNiJA/IKE7T/FfjUB4iuqZYKXZFDWxmUchhyElphg=; b=rGdG71+grlXB253usTl8Il9lSgHVm9/dV4BfDORqybgJCl8CCgHBFepIW+XhdLVHMw rpINc4i66irlqwO7yrsorIeiISZiQAJkYH/kzx3a78kcbYl6Cjsya/7/ljyHoiyuQ0Cb ZCjp8Jr9RpkPmauEUALFMIx0aDHkZ5wh0fsXcpMRoZrBYtJ1yekfmV5BMNvXNubOZu+V J9xl0+irsO4WBYHlGbqMwonwvCuEQLSW4O1TKyheQ7XfAsEDEVtzDrAGj/ruvPV5ozQp CsisJXEN71J39hVMfQqPXKSYnZqODnfD4cqE7ATxNa81h/Y7jSZaKUrCkPXRQymeBytJ Qhkw== X-Gm-Message-State: AOJu0YxXxtjj2LWjQhbWlbha4BgFg56QmX+OBxxQzli8pvI7DSfwigyw YTTiJT722RBgZaDr1Bl6vNCNIIldmZmbvUzveTxof6ORp89N43hITIBHXcr/g9vAW5lSPLJ+xZJ hsmxRRmo= X-Gm-Gg: ASbGnctHEAuhaQ+sP1qp/lCXeAid9uEh04OYfSP9oORm18Y3a3zXrkXBQTOugi7bd6P +DojS2778gHrw3nkQdRQVhEXZ/IRuOTwH2i67X6bgknVPUMZqJ2GkYV2cfV7MFT4Z6kWL68Llhc Qdc2AdwZ+nSNsrK6EDQOklaljkRcO1yTx8ZCPlxXV9TUjE/aerodUZU2EFjlsMhC0Qi7VJr/jAw dRiW/0fpxVOxroYDZ3t0DjWntTqfVPCQGS3fPUer3PjnIY7IFPDNDbSF1YL7iVEuF0wrHwpXUqB +cE4bXHfcWi+qgRO4gAooRkbcIUS5ucd8tOAgvPE0J1k2bOKfiPoKSvWtQw16klqt54//eR8Yte V2gLe3CFL6Ag62xfpm2crtY2R7SccrNEQLokYVHwHeA0XZlyWtmOGXx95Dl1tzo+QPG5iXc0/ X-Google-Smtp-Source: AGHT+IFeXpSU6PbUz7BFdRqx6nB7IJQnnZzwrICjQlcuCClhdgmjSK3KQQq9RkOgYD16/npluLjaQA== X-Received: by 2002:a05:6000:1acd:b0:3e4:f194:288f with SMTP id ffacd0b85a97d-3e643e09089mr605125f8f.62.1757135910317; Fri, 05 Sep 2025 22:18:30 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: alex.bennee@linaro.org, philmd@linaro.org Subject: [PATCH 10/11] accel/tcg: Use EXCP_TB_FLUSH in tb_gen_code Date: Sat, 6 Sep 2025 07:18:19 +0200 Message-ID: <20250906051820.160432-11-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250906051820.160432-1-richard.henderson@linaro.org> References: <20250906051820.160432-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=2a00:1450:4864:20::436; envelope-from=richard.henderson@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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1757136080352116600 Content-Type: text/plain; charset="utf-8" Signed-off-by: Richard Henderson --- accel/tcg/translate-all.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index d468667b0d..d7cc346414 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -288,11 +288,8 @@ TranslationBlock *tb_gen_code(CPUState *cpu, TCGTBCPUS= tate s) assert_no_pages_locked(); tb =3D tcg_tb_alloc(tcg_ctx); if (unlikely(!tb)) { - /* flush must be done */ - tb_flush(cpu); mmap_unlock(); - /* Make the execution loop process the flush as soon as possible. = */ - cpu->exception_index =3D EXCP_INTERRUPT; + cpu->exception_index =3D EXCP_TB_FLUSH; cpu_loop_exit(cpu); } =20 --=20 2.43.0 From nobody Sat Sep 6 15:08:54 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=1757136014; cv=none; d=zohomail.com; s=zohoarc; b=lA2rldCZWML83QhgeN2rCRqQKgAIUjgNDphWsmjzpCp/MmLBfEChG5/YU3MsJ6K7Z3KUlSN2q6jbrOSJfVFJJldwwvzAFsR/IPalOnq1kbEK0XaDO5u1WtCPehJTZ7b2L8Vw8Leu/yOFNv5ILhOJEfka8w5noGqCFS2+c7ve5EM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1757136014; 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=v0lsKCQL+YqSEvwOxx8MYwslyW+UoFwzM6ZVUUq2n68=; b=NZsonT9GcBDrFqxyclx/eV1wuzVJD6maYLsSfEgMN+FaL7+6bi3473sEwVxsc7LTL0nVAA45foPj3eHfm4U2Jrv4KzLLZ3EUe844fMIv68/VqvvrnMZlr4YVU+2jkDNitbmT3KhkZf/An0PrUMJgjsnbVM7lyMtzpYKZAjFXTrg= 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 1757136014191275.9563509109523; Fri, 5 Sep 2025 22:20:14 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uulKL-0000Pu-Hl; Sat, 06 Sep 2025 01:19:07 -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 1uulK9-0000MJ-Hb for qemu-devel@nongnu.org; Sat, 06 Sep 2025 01:18:54 -0400 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uulJt-0006pG-28 for qemu-devel@nongnu.org; Sat, 06 Sep 2025 01:18:53 -0400 Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-45cb6428c46so22902595e9.1 for ; Fri, 05 Sep 2025 22:18:34 -0700 (PDT) Received: from stoup.21wol.it (93-51-222-138.ip268.fastwebnet.it. [93.51.222.138]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-45b6f306c22sm441197735e9.13.2025.09.05.22.18.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Sep 2025 22:18:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1757135911; x=1757740711; 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=v0lsKCQL+YqSEvwOxx8MYwslyW+UoFwzM6ZVUUq2n68=; b=SazRQJIzLeP3tLxLQYQ4+U46bx8obuc+XTI6pIfMXXJ8no34Oma+jABNPLvmCwB7/I ddMquOdOxjh7aoSi8NyuTJDLqIuVXstXeZWfWvNHSSayPtk4P6eZBeG6AutHytsFcUJ7 fZfSUt1Y9WYGR7By++LVaAreckpTfHiKnmCGzcpnRqeEUKunBne4KaSGFSnF8xFVKXLC oC9PT7M8As4UM6FvniXYAAteUP/Z2cfNLc0X5Ii7gR/aVoqf+ASTVbIIWxSTDKuDYqrR Dtk7ImpNl+MYap3s7rlYJ5sLfTvEKye3PlRXvobT/QC40DmvL8wSY2UHp9AaO/F6cAFo 2C6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757135911; x=1757740711; 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=v0lsKCQL+YqSEvwOxx8MYwslyW+UoFwzM6ZVUUq2n68=; b=thhyCIKWByyPX9HYfuk1qx0zpmFxy4NcMfNI+oXFV//mCAJSB6X17SUNt9YuL+3MtY MUmh7ftJh2ld4H0/Z5bsRaMCkPUiyOxtjoYqWpHgp0U8YqYQtV+wvjZ+jcifcXC9sBHW U1tLOI6WZsOMzeiQBz7v5t6ld+l0bDXDfHrEsMd/e47TgWJZkTYuUoY3R4qzF+0/XznI MGF6sKJaY8HHXUuWf9Sh9/N4OivyCtQkPY9O9VygqQj2IQeGpOTAmLNYkAqPTfeRivIs HLBOwE5HpC/CL8mhzYpDA3GbVSBJ2cgVYUbLyypce/ddl2gbfXeU1FOZiVNlA1HLG3lo uhkw== X-Gm-Message-State: AOJu0Yx/TuNHTWF+ZqhprZA0txhclZrOAI55iaalZHWh5l2wF8ps5+JN V3qG6pT6iXoMbqX5yl098RtZUxRkoQebM2muL29zMnTxwKc9neCOsHucdAq77sACqmZ7XfM0pMF 6nYDBd5w= X-Gm-Gg: ASbGnctUVzwNzDQmpwz/8pSFVmrp8ZX4TiepByeoO6Y8YIOxdgnZY8rzTzbiJXBjnVz 9HehRrjqIvHrIRcamENCDUJH6GNI9cntimFkiXxkHFXRlvgiE9YMbLdnWSAcNE+R64fANGaOfyU 4Oqy5UrCT5jMojZijmSU1+2Opja3aO0UN5m5tKvDqmIlsDeRaBxuo/XErBdAqXSeNj9CyQSsxZH cOt0JQXx8Y5cxpMYBijaAVlDBFTnysIBmaO/CPN+IY31ua61eWNVuH9C74F7xry4jxc8LnQbfkb KW3jD9fdnqHx6kTLPP0i1yUJmYVn8ob0UDPXpjox7jvZ7UQEnEx0PX9v46b6N1AcLK01d6lBXOs /+4baWWWyhXlN4G/u/GhXmpKEs8wIY8VjJ8XQaBVKqTwaDfGLRnHwt+w6S/payM19Ri+DyedLYC r8mJxpnG8= X-Google-Smtp-Source: AGHT+IEdfjJblnOldJkH6fLe9Qi5fP1TuUCXHGlO3YEW8NIom8f8JUiORAArwcVBdicVFmb10ZKFAA== X-Received: by 2002:a05:600c:4683:b0:45b:83fe:9cf7 with SMTP id 5b1f17b1804b1-45ddde95a94mr9680615e9.6.1757135911124; Fri, 05 Sep 2025 22:18:31 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: alex.bennee@linaro.org, philmd@linaro.org Subject: [PATCH 11/11] accel/tcg: Remove tb_flush Date: Sat, 6 Sep 2025 07:18:20 +0200 Message-ID: <20250906051820.160432-12-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250906051820.160432-1-richard.henderson@linaro.org> References: <20250906051820.160432-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=2a00:1450:4864:20::331; envelope-from=richard.henderson@linaro.org; helo=mail-wm1-x331.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=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: 1757136016469116600 Content-Type: text/plain; charset="utf-8" All uses have been replaced with tb_flush__exclusive. Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier --- include/exec/tb-flush.h | 19 ++++++++----------- accel/tcg/tb-maint.c | 22 ---------------------- 2 files changed, 8 insertions(+), 33 deletions(-) diff --git a/include/exec/tb-flush.h b/include/exec/tb-flush.h index f3898d1826..d6586b9d5f 100644 --- a/include/exec/tb-flush.h +++ b/include/exec/tb-flush.h @@ -9,21 +9,18 @@ #define _TB_FLUSH_H_ =20 /** - * tb_flush() - flush all translation blocks - * @cs: CPUState (must be valid, but treated as anonymous pointer) + * tb_flush__exclusive() - flush all translation blocks * - * 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. + * 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. + * Must be called from an exclusive context, e.g. start_exclusive + * or vm_stop. */ -void tb_flush(CPUState *cs); - void tb_flush__exclusive(void); + void tcg_flush_jmp_cache(CPUState *cs); =20 #endif /* _TB_FLUSH_H_ */ diff --git a/accel/tcg/tb-maint.c b/accel/tcg/tb-maint.c index d1695be00b..0fe7a0de8a 100644 --- a/accel/tcg/tb-maint.c +++ b/accel/tcg/tb-maint.c @@ -778,28 +778,6 @@ void tb_flush__exclusive(void) qemu_plugin_flush_cb(); } =20 -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(); - } -} - -void tb_flush(CPUState *cpu) -{ - 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)); - } - } -} - /* remove @orig from its @n_orig-th jump list */ static inline void tb_remove_from_jmp_list(TranslationBlock *orig, int n_o= rig) { --=20 2.43.0