From nobody Fri Nov 14 16:40:31 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=1761945403; cv=none; d=zohomail.com; s=zohoarc; b=MQeLbER1pHLzq075eRTFrFUI4ncalDmyKRpzvCPn8PgrOFcjnOJDCguLRAXDOSYBmJWG3EqFp6CVseYSNgkzfxutTs9ypnPMAZxjPZirbq1IyZIECgiSsRdHLzmOwkC7TBlRPME+ySoWmvsUVhlSk4HqaSJyAZ62X32DgZLlzqY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1761945403; h=Content-Type: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=HFZ3cOuhc8mkvqGRr8iMXyeFtjdCa5BH/GDXyvHjKUg=; b=KMStVTzOjzHARX8k2aZmqPnS9//iNWw9+/IlykNN1NFybqoFj1uOJYdkcnUHZRdxUY5NVpyfb8AaEH1rPVAIC0yoK91cW8K3zhygIg/f/q1s3ylH2+OO/bA+bv4PbUvWt/ZPyipN7mkN9SEVrtQss+yKTHyxrFshKBbs6C4AT54= 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 1761945403630876.7765424342042; Fri, 31 Oct 2025 14:16:43 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vEwTm-0000Q2-KN; Fri, 31 Oct 2025 17:16:15 -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 1vEwTf-0000L6-78 for qemu-devel@nongnu.org; Fri, 31 Oct 2025 17:16:07 -0400 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1vEwTX-0001z6-Nn for qemu-devel@nongnu.org; Fri, 31 Oct 2025 17:16:06 -0400 Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-47114a40161so30247775e9.3 for ; Fri, 31 Oct 2025 14:15:57 -0700 (PDT) Received: from pc56.home (adijon-656-1-155-31.w90-33.abo.wanadoo.fr. [90.33.190.31]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4772fd38c4esm28114095e9.12.2025.10.31.14.15.51 for (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 31 Oct 2025 14:15:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1761945353; x=1762550153; 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=HFZ3cOuhc8mkvqGRr8iMXyeFtjdCa5BH/GDXyvHjKUg=; b=BW7Yi++QISnKp/mB6lZv+ovAOc1tnmyDERn2fIkV4coA2kBRNope4qYvxjEpmriItl I/lpchfNrhKW/XJElCAdkURUn86btwnQpP712m8nD1wiJRKKAYim7QmZ4/ju8YcH/i4S ehLuN4LUxWUWyPjDuj5GOgLYoOOCo2lAG1PefqEirc5AiseEkTxxPleibIXZKOxhaJ/H oWN9XBMB21wJm3x4fs+9ptslU0BlLNDmg6sMpsr5CsHmYI55P/6Zojmg7P9qu67YoMmG MQqgH4kNo4SZr1ep6XlZoHqofkuWJqTC/SQflId505HZ5z7BVrUNUBcuZbBDfZw4/VFK zvvw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1761945353; x=1762550153; 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=HFZ3cOuhc8mkvqGRr8iMXyeFtjdCa5BH/GDXyvHjKUg=; b=cW0K+86vbmqTyYX4kuOGYQKP8+/oTooaYq8i58pqK5q1PDhuEDuYgU3T90is4WfsV8 yO403CAhcnoGUjh91Tm0asXZJ3Yvd/mOUpcBWpyp4oQl7Ux/+9fKSItbvZkcOmAnNodz rGX2FRDUZTKydf7v3n61nC4FmMm08NIpuWa7ATGTS160678WXflffCe2L+ykFzb8Au4I 8vMSMy/JGOnJgkh0NHV5iOQdZ8S4E/HSc5LroS5Yt9wEq7RgiADPmpIBkwsb5jSC1fey VYjh+wfEb5OmGhpH42ZhzmBwRjkF3AhVGk1Cq5+grm1egGifTwkKOR/NKpTTXc8eIvoE AZow== X-Gm-Message-State: AOJu0YylD5kBdP4iA0GkZxP0fdJtN+d5YsbIs3AAuaRhsmEJIJgR0kZw qzqqv/U/ogV+kwJERlxnqIyvpiamQfdTXeyHT5IBdLheGJV/NzVx3sWgnlzdRZsNe/qE8YDPMal 7rf2H9DBztQ== X-Gm-Gg: ASbGncvWytQuaUczEq9z/guSxo5OFj6na7rqbf/yzuL9ZA+2HI2AuSkR1NVjWtAHxO7 eKXlJymRI5s2a3gwgTCU1pKX21GY4mpA73gMn0F2hNUQxRpefMisgr8+Zpy7TJH4V0wtLc+0hRi mcxaAC9Os501eUKL3bBOgYeXClyRXfnD8I2IplBegft37DM2CcB8ec3tIop7tt7fPk7CXFCd9Sy MqNZKsU2yFa8PSa7ZWheexg/TuedxuE1BjpNP1P7wyN86b7KLTSZi8em7q+5pfOhB38qel5UL1m dzVKqll9lRAXhS3VXqfzYZNR2lQcrmLH1KVGJshKYfeZOtzMOQGTYA042tY1180pLI4nTB1zqHj XBeN/9AZroZTQLQ5NG8C8wihXl7cgSNwg9NMlILaKNSAppD8gV0fkXeqAW0jq9kbP2FBQ4wRd2P oLPctzSXQjL6Zq75DInY7g4Yg7ergCAbIMlJ61Rm/ZlzaLUzFelfa3XQVh59tcFtmf X-Google-Smtp-Source: AGHT+IHjug+um51Ev2IgrHFR0N/6rD4FjmdTDnTbuhjl6rFOV9bqbpaHIQQgGmg2Kl5MSW0/Ul1CEA== X-Received: by 2002:a05:600c:4591:b0:477:c37:2ea7 with SMTP id 5b1f17b1804b1-4773089c4acmr51129835e9.21.1761945353186; Fri, 31 Oct 2025 14:15:53 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PULL 1/9] cpus: Access CPUState::thread_kicked atomically Date: Fri, 31 Oct 2025 22:15:10 +0100 Message-ID: <20251031211518.38503-2-philmd@linaro.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251031211518.38503-1-philmd@linaro.org> References: <20251031211518.38503-1-philmd@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=2a00:1450:4864:20::335; envelope-from=philmd@linaro.org; helo=mail-wm1-x335.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: 1761945407645158500 cpus_kick_thread() is called via cpu_exit() -> qemu_cpu_kick(), and also via gdb_syscall_handling(). Access the CPUState field using atomic accesses. See commit 8ac2ca02744 ("accel: use atomic accesses for exit_request") for rationale. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Manos Pitsidianakis Message-Id: <20250925025520.71805-3-philmd@linaro.org> --- system/cpus.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/system/cpus.c b/system/cpus.c index aa7bfcf56e5..74f5a5bd4e2 100644 --- a/system/cpus.c +++ b/system/cpus.c @@ -480,10 +480,10 @@ void qemu_process_cpu_events(CPUState *cpu) =20 void cpus_kick_thread(CPUState *cpu) { - if (cpu->thread_kicked) { + if (qatomic_read(&cpu->thread_kicked)) { return; } - cpu->thread_kicked =3D true; + qatomic_set(&cpu->thread_kicked, true); =20 #ifndef _WIN32 int err =3D pthread_kill(cpu->thread->thread, SIG_IPI); --=20 2.51.0 From nobody Fri Nov 14 16:40:31 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=1761945445; cv=none; d=zohomail.com; s=zohoarc; b=CHL8CzWsraUZhd5zWuSfuFB0OKca6wzZInB6xRIuwX46iRKo+pD9UJqk2+egaWQ4PS+qdB8Cmq7CbiJXd4EAEtxYN7oBdpRKZVS5WLWUIZwFP46l1s0253CRgOck0ZeH37ceK6A6y8i3j1lS8pedmX4srZC3AF6jPhlBF3/VHxs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1761945445; h=Content-Type: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=+En8j9Horx8F5fWG7/X0L43+mjYCkQcMJZrOiGxXBhw=; b=Vn3s1A0ZFR8U7j/Lhgb31er8yKPJuwna7UW/JM3TJJ78feotCoQvtxLQG6jyrn5RrLzWjhL+EN+18y50tYKM6FK8QXYssWcsNggAIcySyK8BCb4xSrqr0SlfAUWntFvRuSTl3cMfFLanw5wr+TDRIZb3tbcwt0T7UBfoPm2zNLw= 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 1761945445497538.0569670062465; Fri, 31 Oct 2025 14:17:25 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vEwUN-0000mo-NJ; Fri, 31 Oct 2025 17:16:51 -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 1vEwUE-0000dY-2u for qemu-devel@nongnu.org; Fri, 31 Oct 2025 17:16:44 -0400 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1vEwU5-00021N-DX for qemu-devel@nongnu.org; Fri, 31 Oct 2025 17:16:41 -0400 Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-47721743fd0so14762425e9.2 for ; Fri, 31 Oct 2025 14:16:27 -0700 (PDT) Received: from pc56.home (adijon-656-1-155-31.w90-33.abo.wanadoo.fr. [90.33.190.31]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-429c6ac1645sm685947f8f.12.2025.10.31.14.16.24 for (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 31 Oct 2025 14:16:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1761945385; x=1762550185; 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=+En8j9Horx8F5fWG7/X0L43+mjYCkQcMJZrOiGxXBhw=; b=iYvpJ2FFwkS3el5hIx0bnA981081bl9Gc6453CXET7qjWQqyREh/oXcoez16ZPqLln 6O4ZRlQc+lTCVFkWHJk7lDpU5GG0RACqa/A/QPLfzmyuLlkRSMf4OL2dLYpBPFHRxB+s TOEA2Nv/g39MSjdpOtzFAan3nXjGaUmlbMZQsz3R1subTJ81hDgMGp6PM5tMzaP5pou6 TKwoyxHz0abxchaDhPqRojdhsOs5yxZGUvKv4wQME1Iq6AnEbXKwSdJPCjTMzeOYBRuY sSZyx9sKSjrlU1oWczae/zzcOzQ5/0ivyKXhiJApThEkDnb0r6XzCp4fTqvTaafjHfWQ ndTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1761945385; x=1762550185; 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=+En8j9Horx8F5fWG7/X0L43+mjYCkQcMJZrOiGxXBhw=; b=kwv/1S+GCNMeNMXcAc46YfcLnyubU+IZJ69x3Jx6Joh5LOPMCrhT5hOS2EH3t4Dd81 SV6dAliFgy+BuDSExrLu1TNnXE5MR4SCM4jszkwufSxozCUX1Aq0BSBDLqtN2w78wt8q tQ5ytm0gxFMl7COc6GQPE1RlY3Dsx04xZdQTPSBCbU/r1c7KVNu9V2q6FoYL0bXUnJ7g N8u5fPTwbDE6YRi+U4GOCUWMEtvhJCsfEigJJV+Cb/VNG08JtoN2y0jEdotqsZBkiQk7 ngREv0FuXbZTF5hLMu5xOXIHg8Lg8IgM9za7Gn3A+BM/Xs7KyR0RgRhwhI9dKTW+TirT nnlw== X-Gm-Message-State: AOJu0YwOfzogKFXVRrQ5YUk5bdb6EmgXLosFg3pUeWUXKElBgLCZ3kuL UUy/Po/KlQLh7DP3YcvbBOqhJEnDJXKy4GGgOmEnaEWA4yk4BmQK7Qza+Sw5Ph+1cE3wFokvYf0 TDb77WjujOA== X-Gm-Gg: ASbGncvVpd04YYF+0dZTNuIPEtocBXfHzjmsUHEq285eOlXnyTe9FiE23jJmPlKFLeZ C03YnFU2XD79C9cwO9706ZBhnaJ5ahIP4vQrXsSCokMYk9s29EuA0f8AcNQTy0vHQyrHYiRtUO8 wsaO2p49c9FKq0nKO7f/DQgQMbu09DdnmnN3bqekYxAzZCKPP7ehjM+7ek3u92NqhCWvyMZNfSC GDScpcTesGI7e79QWCJwDfM66fHm+rh62KaEQ842wbPLUrkc9jFp+/8ZQvMr3a3ipPmLRchAWWX XBeFS/ep/IFq/jkI/6bxx0wrTmqPQUoO6+KX7FWYXRBuPZN2Mu1c6jXOZ32k6FAuOsKURrFe1wb WQlifcWbJDF+p1zg3RP9xyg92Pb3wc6Y+2PN4oLliEX+nflm/IyVFTeXe/+7KVGB8yqNe5SsJBm WZTiyv9HutE4pAOwU7oS96lfOHLJHTbLl3O8mwO2mksQUA+viQvK079A== X-Google-Smtp-Source: AGHT+IF6C744bMV6wY/qkJsFvYPFAPbUT3styMIMthZDESQgt7s2+Qht/r3mGe8m2GnUatrfZd8Uqg== X-Received: by 2002:a05:600c:c4a7:b0:475:de81:563a with SMTP id 5b1f17b1804b1-477308b22a2mr48047455e9.33.1761945384845; Fri, 31 Oct 2025 14:16:24 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PULL 2/9] accel/hvf: Make async_safe_run_on_cpu() safe Date: Fri, 31 Oct 2025 22:15:11 +0100 Message-ID: <20251031211518.38503-3-philmd@linaro.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251031211518.38503-1-philmd@linaro.org> References: <20251031211518.38503-1-philmd@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=2a00:1450:4864:20::329; envelope-from=philmd@linaro.org; helo=mail-wm1-x329.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: 1761945448764154100 Wrap hv_vcpu_run() calls with cpu_exec_start/end() in order to have the main loop perform more exclusive sections while all vCPUs are quiescent. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson Message-Id: <20250925025520.71805-4-philmd@linaro.org> --- target/arm/hvf/hvf.c | 2 ++ target/i386/hvf/hvf.c | 2 ++ 2 files changed, 4 insertions(+) diff --git a/target/arm/hvf/hvf.c b/target/arm/hvf/hvf.c index 0658a99a2d1..1e50632557e 100644 --- a/target/arm/hvf/hvf.c +++ b/target/arm/hvf/hvf.c @@ -1803,7 +1803,9 @@ int hvf_vcpu_exec(CPUState *cpu) flush_cpu_state(cpu); =20 bql_unlock(); + cpu_exec_start(cpu); r =3D hv_vcpu_run(cpu->accel->fd); + cpu_exec_end(cpu); bql_lock(); switch (r) { case HV_SUCCESS: diff --git a/target/i386/hvf/hvf.c b/target/i386/hvf/hvf.c index 33f723a76a7..8cd1a800e0a 100644 --- a/target/i386/hvf/hvf.c +++ b/target/i386/hvf/hvf.c @@ -749,8 +749,10 @@ int hvf_vcpu_exec(CPUState *cpu) return EXCP_HLT; } =20 + cpu_exec_start(cpu); hv_return_t r =3D hv_vcpu_run_until(cpu->accel->fd, HV_DEADLINE_FO= REVER); assert_hvf_ok(r); + cpu_exec_end(cpu); =20 /* handle VMEXIT */ uint64_t exit_reason =3D rvmcs(cpu->accel->fd, VMCS_EXIT_REASON); --=20 2.51.0 From nobody Fri Nov 14 16:40:31 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=1761945466; cv=none; d=zohomail.com; s=zohoarc; b=DBSqjP/CH5ceNHowIayBuMscRw/90anxgLulnWkOmG9f3jgy52P/6lDqKQuwgZ5EpYfq2w1r4TEnvaSuRnGu+OJfAwNgCykEcgaW//lKUh91fAEQMsnodI5xZwqh/mNurMdJ9IuT0/qBAQh8QXQWPD6aVFUC9adm7OOnlZrDjvc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1761945466; h=Content-Type: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=BJHpf/Ud1QOlRd/7U6e5GwuRJK2wrW22e/TCzP2i1Oo=; b=XzKNMUspZoxQU2Ga08NiabUgO6MP3dNeLP73+ajuRFfxi/J3ieMpX+0DEQctvtOMJxBRD53p2DGpwSV40q9jvyo7BfdLA1AIrQcEBozIfmp4KlOu9JftHLfZZZMgfBxI8pMIM1cgUvT547hDNxfHrtcGJLvbRja1b3Bba7X+Xz0= 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 1761945466883384.5467067139158; Fri, 31 Oct 2025 14:17:46 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vEwUi-0001Pf-PW; Fri, 31 Oct 2025 17:17:12 -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 1vEwUe-0001K0-4e for qemu-devel@nongnu.org; Fri, 31 Oct 2025 17:17:08 -0400 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1vEwUY-000233-Dx for qemu-devel@nongnu.org; Fri, 31 Oct 2025 17:17:07 -0400 Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-471191ac79dso29540895e9.3 for ; Fri, 31 Oct 2025 14:17:00 -0700 (PDT) Received: from pc56.home (adijon-656-1-155-31.w90-33.abo.wanadoo.fr. [90.33.190.31]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-429c1406a45sm5298498f8f.47.2025.10.31.14.16.55 for (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 31 Oct 2025 14:16:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1761945416; x=1762550216; 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=BJHpf/Ud1QOlRd/7U6e5GwuRJK2wrW22e/TCzP2i1Oo=; b=Lyq9MOqFv0boQGrq8z3i76OobUlrwhYKGWgTMCkVo/ZBwtataDKuynhewhOzPEcykd 8lND/XbnEM3kZi2I1JUDgYtOUZkGQLIUDucPdRBNlScU4d0p7aAUsZko9cq56IqQ7vQG 4XdbEZrtp0N0msyS2JKynzriSxtZGGKWa8KasDl8sZWy03Jmg7wHqsWXV0ECXxAcYj3+ 3y+EyNcPtbYHAmQUKiW++Yl6N7kua6EvrTWRBFi2uL8BV2o8LDaejmIl8EMqILVAev/9 7VJGLIQd1OUT9SlW69nXHMzIvulIClu7sBWmCXuidDCs35+5htEQQgWXDO6Mv3mUjkzZ YFQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1761945416; x=1762550216; 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=BJHpf/Ud1QOlRd/7U6e5GwuRJK2wrW22e/TCzP2i1Oo=; b=bJaR+aJNH6+YUxL4m0kXHgxldKTS84lbRvnOGyHb/76Bo86AgNHRBuo7+RbndSgBUx oG4WrPEaTi7RfBWJ2zInqbiyqedmDSXJueeqzyOte3YVt4wCC/LC5mTsVmLcv1deUGs/ IqHiiRJJcvYhqwhKCUTD41A7d3Z5+heL+MKxKNzElx1Rf7ghft95Xr0JU9TidPDpB8dJ GheW2JRrpfspXDQ/I4D4GMKqTsOtimeHNI1NULcYNDcwc6rbaePEcZD1N4au5YRmDdDC +9VNZLX9RVr7fbQGODCGSGU7Eh2cXB9RUJP0fpcVAk+HB+Uao9s9Xvu56WMt0ztV4eU2 FdMw== X-Gm-Message-State: AOJu0Yywx8DL7AxxoNTaACCLuxdCtLArrDQRXiNl5PA30oUmT25qRG1h o0bFHdRbnCaUvM0zj3wZbBsUfxZ7b4FNcmhxXha7MaMZyxqt1mE0dvWvZwgwPZ/o3vijrNLepi0 3uJVAdm8ejw== X-Gm-Gg: ASbGncua+2vk83LCn2CQNUYPmdfMjVjhlURHBcoD/yrb1B/vHdzqz9jeGUMFwHqmTuh LPgU5hn53/o0UbfOLzMSvRU9QXbSTzzTZOnTEulxSs6iUkwGwkKkMRcaLCr7bgzhy0egq6+WRH3 99FhtZIlUf2HMzpNXCSy0Ud6yZPiKdgcr/yEaisr0A+t3bxDQcjnEl9t4xTFoKxyrQZQnYnDOuk 0Cbfm78UmdjjicIutZnUB0+dbU6jDbCKPwbDNgCbDT+H1ucYuGb9wiTAuNRDUPx0soygxkQY3iE n6PuYIPytlFwKUuosLlkxnfPfdDoaTgNtRRxm3epby8fH8t3XYDWiRYF8h0B9HwCuYvQLbZbFoT mGKkNFYkWY3EevxREwisteW/rKx+RvcHS2Lti8gug0BjyoSytwVTd/2RLMmUy5M5XabusSOaBSq juapMXHzc7KT0zxOW1iMvJjP3loNDtKxyAy3ElL46Xv41TheaXd6tWtDvxjui3EPB0 X-Google-Smtp-Source: AGHT+IFOmZX78ffQkn1JNO9R2lfzRfwKWyMaf5tybQ2657Fe3HyF1BJxuEjM/LcU92/0s93mQaiz7A== X-Received: by 2002:a05:600c:4e05:b0:46e:3550:9390 with SMTP id 5b1f17b1804b1-477308b60camr41389605e9.20.1761945416555; Fri, 31 Oct 2025 14:16:56 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PULL 3/9] accel/tcg: Use cpu_is_stopped() helper to access CPUState::stopped Date: Fri, 31 Oct 2025 22:15:12 +0100 Message-ID: <20251031211518.38503-4-philmd@linaro.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251031211518.38503-1-philmd@linaro.org> References: <20251031211518.38503-1-philmd@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=2a00:1450:4864:20::333; envelope-from=philmd@linaro.org; helo=mail-wm1-x333.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: 1761945468999154100 Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson Message-Id: <20250925025520.71805-5-philmd@linaro.org> --- accel/tcg/tcg-accel-ops-rr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/accel/tcg/tcg-accel-ops-rr.c b/accel/tcg/tcg-accel-ops-rr.c index 2fb46439971..f84342e0449 100644 --- a/accel/tcg/tcg-accel-ops-rr.c +++ b/accel/tcg/tcg-accel-ops-rr.c @@ -197,7 +197,7 @@ static void *rr_cpu_thread_fn(void *arg) qemu_guest_random_seed_thread_part2(cpu->random_seed); =20 /* wait for initial kick-off after machine start */ - while (first_cpu->stopped) { + while (cpu_is_stopped(first_cpu)) { qemu_cond_wait_bql(first_cpu->halt_cond); =20 /* process any pending work */ --=20 2.51.0 From nobody Fri Nov 14 16:40:31 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=1761945515; cv=none; d=zohomail.com; s=zohoarc; b=RwM8reEeoL+Ey0jxTjQqggPKHC/XGIPS5SkOOp82rIUBOpxWn0EuGoIHuLKH8VggCxTnFzF1mPRAY+c7j6Gbs6ngNc8M7iGU3IlEl1aqZj6lUDwfDDjOUDTrZgEsbCaXfe3wKHJm9HY0dgL0t1IL2Rz4muZED/QCWbU7ibEPi90= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1761945515; h=Content-Type: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=+hL1p9xHiljbn6FnSyNn5FKbD53Ap2Pki2ai6nICBPA=; b=fSLxuY5SdjfsxMv3d6y2N9iZrDtz95aJ7aoSScicUAbt6dNRLUSNh+mFVEmZOj+dsqYuJGkpI/TDE/UU1kumCpNd7jEVqvMbU7AGoD8sy1wJMaPJbq39domiye0t+Y8YH/aJ263LLEuomwr5xD2IHgxAqBJxYL/kbB5LBfa1ui4= 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 1761945514999354.2368018175141; Fri, 31 Oct 2025 14:18:34 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vEwVV-0001rb-OQ; Fri, 31 Oct 2025 17:18: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 1vEwVA-0001bj-Rs for qemu-devel@nongnu.org; Fri, 31 Oct 2025 17:17:43 -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 1vEwV4-000262-4d for qemu-devel@nongnu.org; Fri, 31 Oct 2025 17:17:40 -0400 Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-475dae5d473so21515525e9.2 for ; Fri, 31 Oct 2025 14:17:31 -0700 (PDT) Received: from pc56.home (adijon-656-1-155-31.w90-33.abo.wanadoo.fr. [90.33.190.31]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4773c383ba6sm14941555e9.10.2025.10.31.14.17.27 for (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 31 Oct 2025 14:17:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1761945448; x=1762550248; 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=+hL1p9xHiljbn6FnSyNn5FKbD53Ap2Pki2ai6nICBPA=; b=j3kwFGwPk9Aa45WdOq4MDSPUTgw1zztNtKn3SS4UkmArxArewOBZyCS0F3rxS48Mob DAV+3Kp336d9LTfZtzq4S/AEmNTl2Qs2WpI42zXGaqOG+tsR/YGnbpyhd6nJCWjSvpwL JdH0SDCiJi8WKRVJEcQIRYcZBff5tgiSTml7LZzNuTC7ojwKDAphhywLTJWPDOUGxi/q ptrlt7thft+Si7K7dzah1bEYg3bg86CaV5sQ/4MNcjy3+1FwY/xXmYEEJ97tGMPOlxxB EpL+PouCts24m3Zxq0hcc0z800oVU8r4TmY9XrAjCq62JccSdQuPOp6X9tbh86DNE55n owGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1761945448; x=1762550248; 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=+hL1p9xHiljbn6FnSyNn5FKbD53Ap2Pki2ai6nICBPA=; b=ZUA0bBxelf9eFKVjHbo7jIcwsAPUGTfr/tprv/D0r6ZtWNAjhXqVSKaRGIzSs/ll7W 6KAtjls00VTGauU9g/pPiHw6I6uLr3vbwQdh0LcrA+23P8c1Fa33B9ZrdSW68A2K+44e RtzoWXCYcO7Djimwjgv3m8l08z9pmcNFyRJ6swCmRU+7Khu+2QJRSvxQagkqHPa1fCxX jtBDEtugHOoSqTkv8Uu6BYX1vkHrzk3vhluL0uZEzzmTxXmoU4B6ryYlV2wKue1ZNzAM TD6S9Ii/yO/ZE4AJSijhJocCezwEqb19/jLxNykUuD0RqT78muA3ctJFrZLV0Nqn1uJf 6PXg== X-Gm-Message-State: AOJu0Yx0tt4JDi7+S3N5ZYnCxBP102lywJcIu2ayC+EcQIOZQRJhz/8V Jn21CvUol0SxgNJ7kPPvneZfF9h0oj3CuKke43o7WLr+yzO4B1yQ9anZBFI3sl8mxHrigZVZGwu P6hkFXkRgOA== X-Gm-Gg: ASbGncsDU2DFkVSmt38KEYYd7Qt0NTZKSBpNX2xHAVTUf1M13s25kIbSyCDlHAy1wQg k9luZPG+bcsodArn5S8BzH89rnHAfSoXHSMZ56uuF1+lQv0WbaBRrjUMF9Bqeo3AWK00PdnDIer 3zl/R7QmUSSIwOXbhQ2jEgMqag2LRYzOEMeDVOCmTfr5UTkTonUHim+50MkK8vVrXt5nLC8PYJY VifsOdaxw4zEMpEozlcjOOJFp2/nQEi1a3h/IingN5uwfUuE11Xcis2FgGEq+PtX7/icI9bQ2xE AgYnb5gWiJ0ldrC4scs7C/2MYwBk59gpTC92YYSV3axIwKh6ePhaBcXTfXFMUcUw2uhzbcrCNWl e+PxPre+QwjEssw33WNFoPxePt4AUIoT/gbZC0YSyHjPHZycJNu1gHaZLCqQMVJgtCZ5vsvDtmZ 12GlDofppyvDi7tT9u1MnMbUoxQwsWqiZhvHijcpMYAC95hiMlyQRK7He8wjbY1ciA X-Google-Smtp-Source: AGHT+IEMHz1YqJhZGGsNzIfMUO1GwtweBBw0SE+LjfqukBDKL57lfe5NC2HubPFy4Q5JqBUCRFrRNA== X-Received: by 2002:a05:600c:19d4:b0:475:dd59:d8da with SMTP id 5b1f17b1804b1-477308c8e97mr45147505e9.40.1761945448296; Fri, 31 Oct 2025 14:17:28 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PULL 4/9] bql: Fix bql_locked status with condvar APIs Date: Fri, 31 Oct 2025 22:15:13 +0100 Message-ID: <20251031211518.38503-5-philmd@linaro.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251031211518.38503-1-philmd@linaro.org> References: <20251031211518.38503-1-philmd@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=2a00:1450:4864:20::32c; envelope-from=philmd@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, 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: 1761945517598154100 From: Peter Xu QEMU has a per-thread "bql_locked" variable stored in TLS section, showing whether the current thread is holding the BQL lock. It's a pretty handy variable. Function-wise, QEMU have codes trying to conditionally take bql, relying on the var reflecting the locking status (e.g. BQL_LOCK_GUARD), or in a GDB debugging session, we could also look at the variable (in reality, co_tls_bql_locked), to see which thread is currently holding the bql. When using that as a debugging facility, sometimes we can observe multiple threads holding bql at the same time. It's because QEMU's condvar APIs bypassed the bql_*() API, hence they do not update bql_locked even if they have released the mutex while waiting. It can cause confusion if one does "thread apply all p co_tls_bql_locked" and see multiple threads reporting true. Fix this by moving the bql status updates into the mutex debug hooks. Now the variable should always reflect the reality. Signed-off-by: Peter Xu Reviewed-by: Stefan Hajnoczi Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-ID: <20250904223158.1276992-1-peterx@redhat.com> Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- include/qemu/main-loop.h | 18 ++++++++++++++++++ util/qemu-thread-common.h | 7 +++++++ stubs/iothread-lock.c | 9 +++++++++ system/cpus.c | 14 ++++++++++++-- 4 files changed, 46 insertions(+), 2 deletions(-) diff --git a/include/qemu/main-loop.h b/include/qemu/main-loop.h index 4e2436b1968..0d55c636b21 100644 --- a/include/qemu/main-loop.h +++ b/include/qemu/main-loop.h @@ -270,6 +270,24 @@ void rust_bql_mock_lock(void); */ bool bql_locked(void); =20 +/** + * mutex_is_bql: + * + * @mutex: the mutex pointer + * + * Returns whether the mutex is the BQL. + */ +bool mutex_is_bql(QemuMutex *mutex); + +/** + * bql_update_status: + * + * @locked: update status on whether the BQL is locked + * + * NOTE: this should normally only be invoked when the status changed. + */ +void bql_update_status(bool locked); + /** * bql_block: Allow/deny releasing the BQL * diff --git a/util/qemu-thread-common.h b/util/qemu-thread-common.h index 2af6b120853..09331843ba9 100644 --- a/util/qemu-thread-common.h +++ b/util/qemu-thread-common.h @@ -14,6 +14,7 @@ #define QEMU_THREAD_COMMON_H =20 #include "qemu/thread.h" +#include "qemu/main-loop.h" #include "trace.h" =20 static inline void qemu_mutex_post_init(QemuMutex *mutex) @@ -39,6 +40,9 @@ static inline void qemu_mutex_post_lock(QemuMutex *mutex, mutex->line =3D line; #endif trace_qemu_mutex_locked(mutex, file, line); + if (mutex_is_bql(mutex)) { + bql_update_status(true); + } } =20 static inline void qemu_mutex_pre_unlock(QemuMutex *mutex, @@ -49,6 +53,9 @@ static inline void qemu_mutex_pre_unlock(QemuMutex *mutex, mutex->line =3D 0; #endif trace_qemu_mutex_unlock(mutex, file, line); + if (mutex_is_bql(mutex)) { + bql_update_status(false); + } } =20 #endif diff --git a/stubs/iothread-lock.c b/stubs/iothread-lock.c index 6050c081f53..c89c9c7228f 100644 --- a/stubs/iothread-lock.c +++ b/stubs/iothread-lock.c @@ -34,3 +34,12 @@ void bql_block_unlock(bool increase) assert((new_value > bql_unlock_blocked) =3D=3D increase); bql_unlock_blocked =3D new_value; } + +bool mutex_is_bql(QemuMutex *mutex) +{ + return false; +} + +void bql_update_status(bool locked) +{ +} diff --git a/system/cpus.c b/system/cpus.c index 74f5a5bd4e2..ef2d2f241fa 100644 --- a/system/cpus.c +++ b/system/cpus.c @@ -524,6 +524,18 @@ bool qemu_in_vcpu_thread(void) =20 QEMU_DEFINE_STATIC_CO_TLS(bool, bql_locked) =20 +bool mutex_is_bql(QemuMutex *mutex) +{ + return mutex =3D=3D &bql; +} + +void bql_update_status(bool locked) +{ + /* This function should only be used when an update happened.. */ + assert(bql_locked() !=3D locked); + set_bql_locked(locked); +} + static uint32_t bql_unlock_blocked; =20 void bql_block_unlock(bool increase) @@ -564,14 +576,12 @@ void bql_lock_impl(const char *file, int line) =20 g_assert(!bql_locked()); bql_lock_fn(&bql, file, line); - set_bql_locked(true); } =20 void bql_unlock(void) { g_assert(bql_locked()); g_assert(!bql_unlock_blocked); - set_bql_locked(false); qemu_mutex_unlock(&bql); } =20 --=20 2.51.0 From nobody Fri Nov 14 16:40:31 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=1761945516; cv=none; d=zohomail.com; s=zohoarc; b=c8Sk0ch27+7oO2ndVr+q9Pm7nIIs4epV7J31edG4Pn4Bnc88pboi/HTo/yrhggri5HvCLJo3d7zUqDx2WppLlg3aFaHbtY/JLqv38ytzGxEY1I4p/rCkfWTXUHi/2vtXNwMRmGrO239UD8xSUfxAM2kmMrNdyIxc0f+wUeB+bS4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1761945516; h=Content-Type: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=vCOjpg0DOKIUCVHS8v6pFpe29I6DY9EE5LpTUoRlcOc=; b=VY+xrGG3mbSElC7uynn1oIxNXk/s/Px5Fgo6KJnwnk0kZ3hfAoSlVcOkSjOIRIR3TVzWWAo8sbhdi8ya/rmVX5gSRCz0lJnomw58u2Av7OKFvDdKQ8W9dLYBPXUIPpyCttE2FPgWUzCiRgk3tYKEZcoDngzUREbCE8Tn9ui1LKQ= 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 176194551604234.47643231801885; Fri, 31 Oct 2025 14:18:36 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vEwVi-0002Km-U0; Fri, 31 Oct 2025 17:18:15 -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 1vEwVe-0002JP-3B for qemu-devel@nongnu.org; Fri, 31 Oct 2025 17:18:10 -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 1vEwVY-00027z-KI for qemu-devel@nongnu.org; Fri, 31 Oct 2025 17:18:09 -0400 Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-475d9de970eso18534245e9.1 for ; Fri, 31 Oct 2025 14:18:03 -0700 (PDT) Received: from pc56.home (adijon-656-1-155-31.w90-33.abo.wanadoo.fr. [90.33.190.31]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-429c10ff4f6sm6402485f8f.4.2025.10.31.14.17.59 for (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 31 Oct 2025 14:17:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1761945480; x=1762550280; 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=vCOjpg0DOKIUCVHS8v6pFpe29I6DY9EE5LpTUoRlcOc=; b=Dvcxln/cKzkaAgCaAn3075idmupSFA5h/pWmxwyxFUvBViAS76b2Lqm/0qOlpcxsWY 9cWKnnizqaZkgNV7ezK5dXnIiE+WrS2Y/Rxrc6fVjL/guZT9yxHOYS/ci/WxNnjfZPsS DGozuRJi00QfDGSGp/Heu/fHv/HqQK1CiKsK/RNP7pfFE1dIDPOkcAde/XVetoAeGQRQ Cm2Qv1GiRzkqEh8+Vd+Kcu4zvKWUaEUITOqOfjQ0DSCHMPAU3R64dxVGH4XtAeCl7QE5 fGz+ugJju7jKrHpm0Fce0nYd1/hJBL8/dstkdXnfqJAbOT6q0nDQV08SjbqFifNQQhF1 8bgA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1761945480; x=1762550280; 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=vCOjpg0DOKIUCVHS8v6pFpe29I6DY9EE5LpTUoRlcOc=; b=o/7M0FCYH/KjQM1IWX4rWbBoAAmhHZO7EKFbAVM1OXjD6trrCQn+oBaKmkkfuFaWFt dwEnafsnlM6Ir1NyWUOsyJWX9lUy3jCTGLVp10wnhbuCjoHq55m/+zfnqNFUUXIUNs9U ED/cWVTr7uR7f+dCO3VP6JB4RQHDgW95MPZwE0MzmYGU2zKZHIIXkc52G4KNS8IjW+ja j+4o6s0Th18fxU2fqV8G3TOxvyPYv2BMc9nWkyPUFf7SgyLZmJTfSA7/Qv3EneXmH/zo UmwPffFaVUi5IIM3igco6Hs/RfZeaKpmlJYkVyh0k9+bR84lp3T7+4SOsSIsVaxomwZ3 R8Sw== X-Gm-Message-State: AOJu0YzakL3msrE6AguU25zUXkMKJirPas3yvsN+vOH2Z+9I9tf76thU 7gfhq81CtizpXvdYxhHzqXer9r7UFwFsnctpn2kvdpKyXCR9izLlm3Yy1CNkoCW1SxyUHsP/G5p PmBvGXuz2PQ== X-Gm-Gg: ASbGncuS8O3sD3Ags3/oKusYGffMzNCAz5YNZfuTJkP0dHV5wMgYjW4rFWkJJDCf7YP bYZqJwDIYRj+bXUKK17/j1SSwI5VJOppCAmL/d5/cMFhYYazOTlA8Nd1B80bR3oXKlz9gwRGC8Z G/YdksO5Fw1HUygvBqRnRELWGvxhljCXcQvLJy+S/kC6b7Og/xx+kZV3mcpxwQL1jGOuv7VErOO 1SYsRZ2WX+hZtsGt2UVFOQJGrPN2/IGTfohk+HnEuySQ0aE3OqLhXp3ddflg2D2h1KxYkIwA9mD hXzjP6VQKG1ThgkiWjYlyEKaUJyHP2dfGJOZM19Y9j3gMptajRSoNoN7uxdxv4VAy4oFWouVBnt phmuBpOCG/jBExSz1TUm36MQxhy4ISwXFnBePgH1fX7Z0kWmsbTr9POIujQskrgs3pkqTgAAKh1 p53htJ6GcqENu/+l7+dNgJSAyTqZ5tvXVlDTxpwPkhrGKQYOXBlkVDfA== X-Google-Smtp-Source: AGHT+IFUMGrys4WZX0Cz6In/7zIxMT/BTWXw9zZT3rl1ELFWpiJg7FQOTcPD415BVMjupgzxPcZd6A== X-Received: by 2002:a05:600c:468e:b0:475:dd59:d8d8 with SMTP id 5b1f17b1804b1-47730793c2amr57133855e9.8.1761945480089; Fri, 31 Oct 2025 14:18:00 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PULL 5/9] exec/cpu: Declare cpu_memory_rw_debug() in 'hw/core/cpu.h' and document Date: Fri, 31 Oct 2025 22:15:14 +0100 Message-ID: <20251031211518.38503-6-philmd@linaro.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251031211518.38503-1-philmd@linaro.org> References: <20251031211518.38503-1-philmd@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=2a00:1450:4864:20::32c; envelope-from=philmd@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, 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: 1761945519026158500 cpu_memory_rw_debug() dispatches to CPUClass::memory_rw_debug(), move its declaration closer to the CPU API. Document. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Zhao Liu Message-Id: <20251001150529.14122-22-philmd@linaro.org> --- include/exec/cpu-common.h | 4 ---- include/hw/core/cpu.h | 20 ++++++++++++++++++++ 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/include/exec/cpu-common.h b/include/exec/cpu-common.h index 67e15c8e507..e0be4ee2b8f 100644 --- a/include/exec/cpu-common.h +++ b/include/exec/cpu-common.h @@ -150,10 +150,6 @@ typedef int (RAMBlockIterFunc)(RAMBlock *rb, void *opa= que); =20 int qemu_ram_foreach_block(RAMBlockIterFunc func, void *opaque); =20 -/* Returns: 0 on success, -1 on error */ -int cpu_memory_rw_debug(CPUState *cpu, vaddr addr, - void *ptr, size_t len, bool is_write); - /* vl.c */ void list_cpus(void); =20 diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h index e79e8e0a8ee..9615051774d 100644 --- a/include/hw/core/cpu.h +++ b/include/hw/core/cpu.h @@ -688,6 +688,26 @@ int cpu_write_elf32_note(WriteCoreDumpFunction f, CPUS= tate *cpu, int cpu_write_elf32_qemunote(WriteCoreDumpFunction f, CPUState *cpu, void *opaque); =20 +/** + * cpu_memory_rw_debug: + * @cpu: The CPU whose memory is to be accessed + * @addr: guest virtual address + * @ptr: buffer with the data transferred + * @len: the number of bytes to read or write + * @is_write: indicates the transfer direction + * + * Take a virtual address, convert it to a physical address via + * an MMU lookup using the current settings of the specified CPU, + * and then perform the access (using address_space_rw() for + * reads or address_space_write_rom() for writes). + * + * This function is intended for use by the GDB stub and similar code. + * + * Returns: 0 on success, -1 on error + */ +int cpu_memory_rw_debug(CPUState *cpu, vaddr addr, + void *ptr, size_t len, bool is_write); + /** * cpu_get_crash_info: * @cpu: The CPU to get crash information for --=20 2.51.0 From nobody Fri Nov 14 16:40:31 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=1761945556; cv=none; d=zohomail.com; s=zohoarc; b=gUjeC0oO+GsHpva9iE3t9FenegYNymIkTPpMdIZUAD5ZHDNPQTUcRmbv/jWcc/gR1r0+vVEWJsjw2MrHoA76/uJ3uTEi0XRDbZJpks4hwRhHBf12YpA9fAjWn5TL0QqHKhLyXrzhXWirLMWPgJV0LHe8G2WdIQZzR53Ymcsz2hs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1761945556; h=Content-Type: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=Zb+lg8rKtYHqXOou6DMojkI7hCEEFWdJALRTKbhb5QU=; b=gA8tdFrMNksroS4lN0/z+qpbpbWcaWUzwLjI7i/0b7irwsjbWuCNMCQKTD1KufgPF8pRE0JrxyOHEVfeOImqUcqO+Ka9h+asJClrlqs1kA0ghm9sYdxL7gYREx05+5ZFP7LBR5AHXMWoE0P7lU4ih6cJRsiXdZGh12IgU3zfTx8= 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 176194555661960.15451009433525; Fri, 31 Oct 2025 14:19:16 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vEwWC-0002YS-1U; Fri, 31 Oct 2025 17:18:44 -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 1vEwWA-0002Xq-F0 for qemu-devel@nongnu.org; Fri, 31 Oct 2025 17:18:42 -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 1vEwW4-0002Cc-Nz for qemu-devel@nongnu.org; Fri, 31 Oct 2025 17:18:42 -0400 Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-475dbc3c9efso16572125e9.0 for ; Fri, 31 Oct 2025 14:18:35 -0700 (PDT) Received: from pc56.home (adijon-656-1-155-31.w90-33.abo.wanadoo.fr. [90.33.190.31]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4773c383ba6sm14974095e9.10.2025.10.31.14.18.31 for (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 31 Oct 2025 14:18:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1761945512; x=1762550312; 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=Zb+lg8rKtYHqXOou6DMojkI7hCEEFWdJALRTKbhb5QU=; b=Ux27czvs8RTAWw8tXX62SY2edDnqRM7WfdwB0ersuDEeorxx7wvlnEwF7AsJFZ2dQR Fk5O/18DxvfUJdZ2RpYS2mbzP12JKaeRo2xtUoIVvwzKvviRDOzTcir5lOytPWvlDnuS DqucseBhItPyUDvXO//UF39m+kpQF39RitIlorgkktvCuTOW5b3SLfZkHOUQMQpYP1ha EpyrX0/RGGA/ybyiCBTb+mRFVYry9DGPqONccNHlmeytFm9ZBiyR2buXJpc3W9aUuNBO hRKDBvkNH9oPin6Cmzit19apTNlscSsLYQDSJq5AsPKe/3aDzJesW9DqWNLUZOTrk98N fKig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1761945512; x=1762550312; 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=Zb+lg8rKtYHqXOou6DMojkI7hCEEFWdJALRTKbhb5QU=; b=irTv8RxCPIlsuZK9edDj+lU3cF39CrBEWqshYr3cw7TDwspHobabJGTRn8MmzURf4C dBV28mnAPXEWHEreA69r5w8Wwvd6GpeABVQP4xE4ZuRHB4Ip033rOAf+rgkfNmJx19mu fgDlO5dDW4XadppRpfBPRhiI9Fy65jlQ2I5ERXxY+VQqpPxnF/6VeYY3h7KnBnCXyTV7 OtVFVlK6zUguS7/SOA7cnZr6eutnFEJvY1OE6uYtWfUVudQ+jJNFTaQEUSmt+v/+WIjb vcfm1cUkOyecF2Z3zRcyT9Jfa6nRdlCi2xU4tSkOGXG8kpw0gTwXifCxaDYEwaRijEll WNaQ== X-Gm-Message-State: AOJu0YxDujzUh8dcK93ulS48HfCvUxnkxaLW/jBFRJgMe/b3hJ05ePYN OjnZdEEPvBPepAIdgQOn6NsqfgrFM1Kn2Z5olv8rvPMuctipJ8w54nPr8EXK8xdAec11lyU3COP Y5IyRG6QDKA== X-Gm-Gg: ASbGnctbRnlHNaxpuJuk4Nv0RSRYG8MLLfFAh8jDhWzdpiAl9DbfC2B9sGIBBGUDv6c 9QOy12i92i8aDUdDpUcGB94dukxd9JUiRFCqvd6OSVmpK7jWY/czoTpGMgrGtq2Z30ElGSbXa6n VQyPbETkcj6qSkJBbIl+zTs50Xh2LE6q5hkdgEld+pl+99bKiy/y13m3SqRpGJAtQMRsQpHYVqM iH6Llw+BTgob2IB9P9QhaLMnZ1all+tF6qnsTcJX2ct0Qugtbej5XcSFvc/5woDqUVnN71WLhTH CjkGwr8Ll7si1BreRxwBg2WL453tgqSL5gOs7ZR39ulzcZjfZznPyLdncNJb3Ww2850fJImUpDT y3uypuYzNROGuZqTiCBSEX2upEOJJoHElhKdL1qVmHEPjbdrXTN5eMQY8Iz/oELBcxrn4dlY3GK DlzyVrKrzrKDfDkAL3BN9OuR8McMJD825j69mwzJ03zUu6uqhWjNKnzCCtMMM= X-Google-Smtp-Source: AGHT+IFLnhyAA9CkWO0jrp8RSvBDbYJfUG83ahO8p7aSI3guDf1VA/xMFawUJsnM0M3SjIRGjDW4iA== X-Received: by 2002:a05:600c:3149:b0:477:942:7521 with SMTP id 5b1f17b1804b1-477307e285dmr49019015e9.14.1761945511933; Fri, 31 Oct 2025 14:18:31 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PULL 6/9] timers: properly prefix init_clocks() Date: Fri, 31 Oct 2025 22:15:15 +0100 Message-ID: <20251031211518.38503-7-philmd@linaro.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251031211518.38503-1-philmd@linaro.org> References: <20251031211518.38503-1-philmd@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=2a00:1450:4864:20::331; envelope-from=philmd@linaro.org; helo=mail-wm1-x331.google.com X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, DKIM_INVALID=0.1, DKIM_SIGNED=0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: 1761945558034154100 From: Alex Benn=C3=A9e Otherwise we run the risk of name clashing, for example with stm32l4x5_usart-test.c should we shuffle the includes. Signed-off-by: Alex Benn=C3=A9e Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-ID: <20251030173302.1379174-1-alex.bennee@linaro.org> Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- include/qemu/timer.h | 5 +++-- tests/unit/test-aio-multithread.c | 2 +- util/main-loop.c | 2 +- util/qemu-timer.c | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/include/qemu/timer.h b/include/qemu/timer.h index 406d7411203..8b561cd6960 100644 --- a/include/qemu/timer.h +++ b/include/qemu/timer.h @@ -786,11 +786,12 @@ static inline int64_t qemu_soonest_timeout(int64_t ti= meout1, int64_t timeout2) } =20 /** - * initclocks: + * qemu_init_clocks: + * @notify_cb: optional call-back for timer expiry * * Initialise the clock & timer infrastructure */ -void init_clocks(QEMUTimerListNotifyCB *notify_cb); +void qemu_init_clocks(QEMUTimerListNotifyCB *notify_cb); =20 static inline int64_t get_max_clock_jump(void) { diff --git a/tests/unit/test-aio-multithread.c b/tests/unit/test-aio-multit= hread.c index 0ead6bf34ad..c24200a7121 100644 --- a/tests/unit/test-aio-multithread.c +++ b/tests/unit/test-aio-multithread.c @@ -443,7 +443,7 @@ static void test_multi_mutex_10(void) =20 int main(int argc, char **argv) { - init_clocks(NULL); + qemu_init_clocks(NULL); =20 g_test_init(&argc, &argv, NULL); g_test_add_func("/aio/multi/lifecycle", test_lifecycle); diff --git a/util/main-loop.c b/util/main-loop.c index b8ddda8f5ee..b462598f76e 100644 --- a/util/main-loop.c +++ b/util/main-loop.c @@ -162,7 +162,7 @@ int qemu_init_main_loop(Error **errp) int ret; GSource *src; =20 - init_clocks(qemu_timer_notify_cb); + qemu_init_clocks(qemu_timer_notify_cb); =20 ret =3D qemu_signal_init(errp); if (ret) { diff --git a/util/qemu-timer.c b/util/qemu-timer.c index 56f11b6a641..2a6be4c7f95 100644 --- a/util/qemu-timer.c +++ b/util/qemu-timer.c @@ -637,7 +637,7 @@ static void qemu_virtual_clock_set_ns(int64_t time) return cpus_set_virtual_clock(time); } =20 -void init_clocks(QEMUTimerListNotifyCB *notify_cb) +void qemu_init_clocks(QEMUTimerListNotifyCB *notify_cb) { QEMUClockType type; for (type =3D 0; type < QEMU_CLOCK_MAX; type++) { --=20 2.51.0 From nobody Fri Nov 14 16:40:31 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=1761945570; cv=none; d=zohomail.com; s=zohoarc; b=foS51FNEC43H/e7v2LDRL+XCj3v1u8bQz1iX24DQws5ZcikPGo2xU+tQtdjBduYx3gEE0nTGLCMvnrFevvsXiD8tMHR2Mp5t+pta1e5i7FUbtVW2L2NXaBK5cUmK86qRi0QWZUpqkYtdT/6Wrrk+4IjqyW/TQDUBSTDS1tllMeQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1761945570; h=Content-Type: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=dtB18Pvc9S14eiCOzWzreWzk+lt1hMQZD4T89jMibmU=; b=GK1uJXCDnu0SaOb+txMFcJlYG1z1B9rhMHVwIC4wbPbsJqEthQJa6+/yd+S9lK8NGp1SI/7CIhLJx2bDn/4UMEdPVe+GBj4+yGxLKhS0HlSG6d0F5nvWsmHGlQY/ZAI6YQiAaUZ+0wRJ11cyuOWwi1VCfuaKsCobhWrYeHqSUY0= 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 1761945570853474.25462148222493; Fri, 31 Oct 2025 14:19:30 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vEwWm-0003OP-ON; Fri, 31 Oct 2025 17: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 1vEwWk-0003ND-U7 for qemu-devel@nongnu.org; Fri, 31 Oct 2025 17:19:19 -0400 Received: from mail-wr1-x434.google.com ([2a00:1450:4864:20::434]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1vEwWc-0002KD-Eu for qemu-devel@nongnu.org; Fri, 31 Oct 2025 17:19:18 -0400 Received: by mail-wr1-x434.google.com with SMTP id ffacd0b85a97d-429bf011e6cso1369135f8f.1 for ; Fri, 31 Oct 2025 14:19:09 -0700 (PDT) Received: from pc56.home (adijon-656-1-155-31.w90-33.abo.wanadoo.fr. [90.33.190.31]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-429c13ebfe8sm5401752f8f.35.2025.10.31.14.19.02 for (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 31 Oct 2025 14:19:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1761945545; x=1762550345; 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=dtB18Pvc9S14eiCOzWzreWzk+lt1hMQZD4T89jMibmU=; b=R/pQ2lNJcbHCGD6uCCLT4NHuafClw0Bp2meOR+G642VeyWv33e0LzByaRWqiDyCBgV L+JioqpniR3dg2pbmVmNGlbxMGXZZ8kYJkAj9HqpzgjrSyWOy2qZ/CUOm+HlKFx7Z+yL H0RKa1daISjeY+um126yWnoX7Jz2uWs8cuxAcUH6gvea4ky/ZuvXOloGAeYEjqssIp5i UnoVNSFpcCKZTCSyU9vKn1Dw0YwO/sSpjlozZmegUU7iJqiX5V48KAiZz3SOjdNSIAnR hPuvIkyP8GUN/AuNZsOQMJbzD5AXBN1aQmahesM/Tt4qAByNUkii0ceKy3boUxH+Turn 1KtA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1761945545; x=1762550345; 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=dtB18Pvc9S14eiCOzWzreWzk+lt1hMQZD4T89jMibmU=; b=HPeKmhosp/VsVRtWhi996o8PVCUl8mStrLO/Qi2+QSrXIXp4PgRCYHjR6zHFzQmLT5 SoZkt8N6DDhC4hRtBwnEN/qJfxNSEHlWNad3NQPw0M9h9cZMTehnKRm6ZZFK2s5ejB09 yPH0NPAmDfVPSnhYlSsQfiyoPaEgzi6hPK55uZzRTf4DcOZSkYz+2UiWQT1kcfyvMABB cWbLqWu8nY3r8sOSVwfuNVQAzRxxNhEFIymNLrzPnSDLuPaxKEz9A4PZ8x6k5tCVUQzG tUsj/BJbMjv7/wj5dlj0ZvmbXLZfRp5eWSJAu+FIUnNCiVmFIHcGu9qHHKgLqAwYbDA4 1ZFg== X-Gm-Message-State: AOJu0YwQdOpQQM3vNH7h7ch/GtUHGtcGhSFQjBh4Fnxwf/Z9NZ2vBnD0 I8ButJDWdEjXjjDv7WqbkjsTruBfQEu5owxWXX7N7btBNZV44LEqRnp2Q81DAAcSF+5mpMgv9Wj Zk1CYzhoSYA== X-Gm-Gg: ASbGncs/lCvA0qxFU+6c7dNE6h9a4O9WclEFxYHeZIVkpNphXpfv4hZMsfV+6aKt4YV BqP3ycdlrai5tAesC7riPqrv5Jy50DhfOONDO8Fqgg5sjV494QFosqlolehB26tryZwYqjDv0u6 okVInjnVWgEdxWNoMCaVAsiJ/HPwtN59DZW7KqS/+8njYUgVpLtrX4LULDd+uyqendpC31ijTEW xDqfZ+w4MVf/o+6AIvUA1GaEvo1v3Qoe1fmSWPhof3iB/CeA6N57XguKkmcG+7tbmE0AMccxSAU u/ql12pt0MYxRGU+L3zZVNTNjXGcz4GKWjWxe2+e+gceqcqD+ovlE5m/NAdg6SNRn3yfQye6/+H Je6eTTptGv8cCTk0CInd+CQFOGdRibsbx0lgHBcGqbLMNn53H+4/UQs7BMVY6IXBW0d+8U6jZ8a uGoX9nV0mZE/0ibCfuvm/CfDXe8FNCLLT2S6KlV8up18/D/2oa X-Google-Smtp-Source: AGHT+IFrsaJGgwF2yOSCmVBULDmoRt4zzlKIoCMbn1/VY9QQCfR1Fnnp10dBvo/w7b9XLjYpajJW3g== X-Received: by 2002:a5d:64e8:0:b0:429:8a40:e995 with SMTP id ffacd0b85a97d-429bd6ece4bmr5326479f8f.61.1761945544603; Fri, 31 Oct 2025 14:19:04 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PULL 7/9] util/hexdump: fix QEMU_HEXDUMP_LINE_WIDTH logic Date: Fri, 31 Oct 2025 22:15:16 +0100 Message-ID: <20251031211518.38503-8-philmd@linaro.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251031211518.38503-1-philmd@linaro.org> References: <20251031211518.38503-1-philmd@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=2a00:1450:4864:20::434; envelope-from=philmd@linaro.org; helo=mail-wr1-x434.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, 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: 1761945579429158500 From: Vladimir Sementsov-Ogievskiy QEMU_HEXDUMP_LINE_WIDTH calculation doesn't correspond to qemu_hexdump_line(). This leads to last line of the dump (when length is not multiply of 16) has badly aligned ASCII part. Let's calculate length the same way. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Philippe Mathieu-Daud=C3=A9 Tested-by: Philippe Mathieu-Daud=C3=A9 Message-ID: <20251031190246.257153-2-vsementsov@yandex-team.ru> Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- util/hexdump.c | 38 ++++++++++++++++++++++++-------------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/util/hexdump.c b/util/hexdump.c index f29ffceb746..7cfc5472613 100644 --- a/util/hexdump.c +++ b/util/hexdump.c @@ -22,6 +22,19 @@ static inline char hexdump_nibble(unsigned x) return (x < 10 ? '0' : 'a' - 10) + x; } =20 +static size_t hexdump_line_length(size_t buf_len, size_t unit_len, + size_t block_len) +{ + size_t est =3D buf_len * 2; + if (unit_len) { + est +=3D buf_len / unit_len; + } + if (block_len) { + est +=3D buf_len / block_len; + } + return est; +} + GString *qemu_hexdump_line(GString *str, const void *vbuf, size_t len, size_t unit_len, size_t block_len) { @@ -30,14 +43,8 @@ GString *qemu_hexdump_line(GString *str, const void *vbu= f, size_t len, =20 if (str =3D=3D NULL) { /* Estimate the length of the output to avoid reallocs. */ - size_t est =3D len * 2; - if (unit_len) { - est +=3D len / unit_len; - } - if (block_len) { - est +=3D len / block_len; - } - str =3D g_string_sized_new(est + 1); + str =3D g_string_sized_new(hexdump_line_length(len, unit_len, bloc= k_len) + + 1); } =20 for (u =3D 0, b =3D 0; len; u++, b++, len--, buf++) { @@ -76,13 +83,16 @@ static void asciidump_line(char *line, const void *bufp= tr, size_t len) } =20 #define QEMU_HEXDUMP_LINE_BYTES 16 -#define QEMU_HEXDUMP_LINE_WIDTH \ - (QEMU_HEXDUMP_LINE_BYTES * 2 + QEMU_HEXDUMP_LINE_BYTES / 4) +#define QEMU_HEXDUMP_UNIT 1 +#define QEMU_HEXDUMP_BLOCK 4 =20 void qemu_hexdump(FILE *fp, const char *prefix, const void *bufptr, size_t size) { - g_autoptr(GString) str =3D g_string_sized_new(QEMU_HEXDUMP_LINE_WIDTH = + 1); + int width =3D hexdump_line_length(QEMU_HEXDUMP_LINE_BYTES, + QEMU_HEXDUMP_UNIT, + QEMU_HEXDUMP_BLOCK); + g_autoptr(GString) str =3D g_string_sized_new(width + 1); char ascii[QEMU_HEXDUMP_LINE_BYTES + 1]; size_t b, len; =20 @@ -90,11 +100,11 @@ void qemu_hexdump(FILE *fp, const char *prefix, len =3D MIN(size - b, QEMU_HEXDUMP_LINE_BYTES); =20 g_string_truncate(str, 0); - qemu_hexdump_line(str, bufptr + b, len, 1, 4); + qemu_hexdump_line(str, bufptr + b, len, + QEMU_HEXDUMP_UNIT, QEMU_HEXDUMP_BLOCK); asciidump_line(ascii, bufptr + b, len); =20 - fprintf(fp, "%s: %04zx: %-*s %s\n", - prefix, b, QEMU_HEXDUMP_LINE_WIDTH, str->str, ascii); + fprintf(fp, "%s: %04zx: %-*s %s\n", prefix, b, width, str->str, as= cii); } =20 } --=20 2.51.0 From nobody Fri Nov 14 16:40:31 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=1761945616; cv=none; d=zohomail.com; s=zohoarc; b=TNgO5go4zFxf92YuidLGJCes3xqjpuhrCVV0lSRAKI6h1HXAyVvf/QX2LKEgDEoXhqemYta9YP5OHQA0ILT6Eh+l5R4Us6PT9huMtCbV8ntKsLaxWn80uoIedScrrtU3gzE12qXjkNk2gF43rMM74BoHZBeHYbEazFgXkLbZlV8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1761945616; h=Content-Type: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=EBWQEu+G6aZWeAXHylufENQApXkpCx0rf9wOYW18fhY=; b=HxvIYklhfFT1+FElLHxlFbkHLrvHZYm2IpTFPixI7pgMXiJ63i5E0LPvXCdCHnBkMmKwYMacPz+WdUqDlRJfprzqkkaHK6ZA8clbjEsvF51mbuM8FdjPr8aEMPoizQyLOCSdTzZxnIN6ERp7qClWIbyyMVUO3dxLE7sv31L5EzU= 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 1761945616635121.48203895476786; Fri, 31 Oct 2025 14:20:16 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vEwXD-0003m2-9Y; Fri, 31 Oct 2025 17:19:47 -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 1vEwXB-0003lP-Rp for qemu-devel@nongnu.org; Fri, 31 Oct 2025 17:19:45 -0400 Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1vEwX5-0002Nl-49 for qemu-devel@nongnu.org; Fri, 31 Oct 2025 17:19:45 -0400 Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-47109187c32so14177265e9.2 for ; Fri, 31 Oct 2025 14:19:38 -0700 (PDT) Received: from pc56.home (adijon-656-1-155-31.w90-33.abo.wanadoo.fr. [90.33.190.31]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4772fbeef62sm30578125e9.1.2025.10.31.14.19.35 for (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 31 Oct 2025 14:19:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1761945576; x=1762550376; 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=EBWQEu+G6aZWeAXHylufENQApXkpCx0rf9wOYW18fhY=; b=WF42dxxeUye2XYgkH2SqZBhY3M61XouhlqIsjGkOkS+M6brrx3TLnAjfb2axdHWcBz GY0Ca+W6opHtHSLWSJWy/25fvjpSYgyQR98cstzyjTGbPRIPS0ZxQvinlFBW9JHkAPs5 BuglfcF6bFnpAvMGzKRPdH6QcCPoMEoPGnasbAHxVLkopORfgDhaKjVsZ1Yo0od5EkUX HP59qvPbDPuVVJfT5qZ5uNWgd/vdBtTHWb8JNvsUCuRTJcGxFVFtmwn587uzd7oIhrKM KihF625QhISGLDspFHV8ReYgtTW9M194bOabK1q1TeOz6B3rJfB8rVI1JSIWBAwDiSTC /m2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1761945576; x=1762550376; 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=EBWQEu+G6aZWeAXHylufENQApXkpCx0rf9wOYW18fhY=; b=Gdb0Xz+OkxaGc1+HuVE1Z02fhO5dOBygjpmtf+kNfOpe+RLRuLYmHtKqpORj8yUEOm 6p5mZqIfIffO6ApcBdcgjMH4q2ejrUgbtVexBPWfxYesr5X4y5p5IvzFSmPSjW6Z0W6T /qupwj2FSZie988qQilMcODhDpLS9R5igBDmM9IsuLqW4oNebKxjR+5ukBtSlQBigPLG erlajgTnjP1wZaD2u1/vo5FvJf52PK4tIfP4c/TZmmOf7I2AuVCLz+FvbybS+XFVuVeJ S+V+negVrnxYPzDqW0YJnedrsk+Pu/npcbKdRR+ytcuhQyvRsQ0VPgdFF1INfLA9TmF/ 99FA== X-Gm-Message-State: AOJu0YyQSJOgL7747KVEu9NW7LeMH2ON6U4XDn0RJ9oI5Iedsrimf2ZC 1qcXRuRldya768Hbk18fK1yDsxmvvoFTVgWIeVHgetuSGwheX4llXAxWMIFtHl1s8RdGYQNtYOu 4Wg2K8Uw+xQ== X-Gm-Gg: ASbGnct79RDmBoUg2O06js0RLsrY6wFztLwDdu12yquMyM4145zfQrImYyTyiPLSsx8 SPYpXVViVn9Is3Or0wdmZeI26bUNSwUNRGwTBYilSFP9vCYi29RI0ByH2ShCe9GgjKwQoIyj44p U6feJA4/9eSStK+gyNjSFCw6eSWxHcv5DRy7BJwTq9YtfW9kiFMuhQImy+WFjUXMRyvpNTMu8/g enRVHuMQcv9Rba+fLDS8lRd8sejOGSUfqR34q0xfTYVs9VGEfygC/18Qm5efCwptfn3EWqfLV8U SJY0qcqYtQ+AUpKawuIfiUwrztWFHwYHj6zU2lynrejKWyc1FxGaikLIEDYT/PPByHQpUTV7A2/ Bp2BlS4m4292Z3f8erVH0PfeSwJ9zI6Lhwm9uzTDDajXUF1bMMduF1ykvAtLIr+eka+XuVQyXec QDprr/cKHKnaonLkh0ZoaXxG6jGgZYK1Qj+ZRljJSK5SI1w+n1xqmYa8EKf3M= X-Google-Smtp-Source: AGHT+IEYbSHSR5e9FmjDsV0sS9jOFHeFfpqhjswQ9b5Rqs6AVwRVv8+H9vL84svkddbk+bb+LKhCqA== X-Received: by 2002:a05:600c:3e06:b0:475:dc58:39e5 with SMTP id 5b1f17b1804b1-4773089b541mr45267795e9.27.1761945576398; Fri, 31 Oct 2025 14:19:36 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PULL 8/9] tests/unit: add unit test for qemu_hexdump() Date: Fri, 31 Oct 2025 22:15:17 +0100 Message-ID: <20251031211518.38503-9-philmd@linaro.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251031211518.38503-1-philmd@linaro.org> References: <20251031211518.38503-1-philmd@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=2a00:1450:4864:20::336; envelope-from=philmd@linaro.org; helo=mail-wm1-x336.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: 1761945618715154100 From: Vladimir Sementsov-Ogievskiy Test, that fix in previous commit make sense. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Philippe Mathieu-Daud=C3=A9 Tested-by: Philippe Mathieu-Daud=C3=A9 Message-ID: <20251031190246.257153-3-vsementsov@yandex-team.ru> [PMD: Wrap long lines] Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- tests/unit/test-cutils.c | 45 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/tests/unit/test-cutils.c b/tests/unit/test-cutils.c index 227acc59955..67b1cded64a 100644 --- a/tests/unit/test-cutils.c +++ b/tests/unit/test-cutils.c @@ -3626,6 +3626,46 @@ static void test_si_prefix(void) g_assert_cmpstr(si_prefix(18), =3D=3D, "E"); } =20 +static void test_qemu_hexdump_alignment(void) +{ + /* + * Test that ASCII part is properly aligned for incomplete lines. + * This test catches the bug that was fixed in previous commit + * "util/hexdump: fix QEMU_HEXDUMP_LINE_WIDTH logic". + * + * We use data that is not aligned to 16 bytes, so last line + * is incomplete. + */ + const uint8_t data[] =3D { + /* First line: 16 bytes */ + 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x20, 0x57, 0x6f, /* "Hello Wo" */ + 0x72, 0x6c, 0x64, 0x21, 0x20, 0x54, 0x68, 0x69, /* "rld! Thi" */ + /* Second line: 5 bytes (incomplete) */ + 0x73, 0x20, 0x69, 0x73, 0x20 /* "s is " */ + }; + char *output =3D NULL; + size_t size; + FILE *stream =3D open_memstream(&output, &size); + + g_assert_nonnull(stream); + + qemu_hexdump(stream, "test", data, sizeof(data)); + fclose(stream); + + g_assert_nonnull(output); + + /* We expect proper alignment of "s is" part on the second line */ + const char *expected =3D + "test: 0000: 48 65 6c 6c 6f 20 57 6f 72 6c 64 21 20 54 68 69 " + "Hello World! Thi\n" + "test: 0010: 73 20 69 73 20 " + "s is \n"; + + g_assert_cmpstr(output, =3D=3D, expected); + + free(output); +} + int main(int argc, char **argv) { g_test_init(&argc, &argv, NULL); @@ -3995,5 +4035,10 @@ int main(int argc, char **argv) test_iec_binary_prefix); g_test_add_func("/cutils/si_prefix", test_si_prefix); + + /* qemu_hexdump() test */ + g_test_add_func("/cutils/qemu_hexdump/alignment", + test_qemu_hexdump_alignment); + return g_test_run(); } --=20 2.51.0 From nobody Fri Nov 14 16:40:31 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=1761945644; cv=none; d=zohomail.com; s=zohoarc; b=H/vT7EAU/rEgwnJQPhvyQM+LzxsBTFjDih4x5dpaXA3tlClBIx6tg0Kmc6jIhtJVVMTQFoF/Jkk95M1qnocV5j8JWw+hENKf2uOLVpxgKJlQeemPReQTAAiiFQj8oZQWoHdhWLOShaPktlMiLrDq4yxTJLpzMJftxkUS1Q3zyXo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1761945644; h=Content-Type: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=TRkWFU/aapO0FF6y9Y4J4SN7vpy3bH8aWYMTVG70Hn8=; b=SP/eWEHfGlZGISVIIhG0rvh0iTxhLrvj2WGojtqhrJibqb0WBkmOq96MU1+LvpVRVGf1c1hAAOg/Laef1nott11M1Orpq4THf0AtXAJfSzI/Ztsb28S8NNBPTXBodHvTtVR9wHkJmDt8FM6OZg9tyv6nCQErW4ntpuu76GpdYdE= 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 1761945644520431.72549526069474; Fri, 31 Oct 2025 14:20:44 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vEwXm-0004Kp-W7; Fri, 31 Oct 2025 17:20:23 -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 1vEwXj-0004KA-U5 for qemu-devel@nongnu.org; Fri, 31 Oct 2025 17:20:20 -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 1vEwXb-0002aW-F6 for qemu-devel@nongnu.org; Fri, 31 Oct 2025 17:20:19 -0400 Received: by mail-wr1-x435.google.com with SMTP id ffacd0b85a97d-3ecdf2b1751so1769673f8f.0 for ; Fri, 31 Oct 2025 14:20:10 -0700 (PDT) Received: from pc56.home (adijon-656-1-155-31.w90-33.abo.wanadoo.fr. [90.33.190.31]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-429c13e16f4sm5639277f8f.27.2025.10.31.14.20.07 for (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 31 Oct 2025 14:20:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1761945608; x=1762550408; 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=TRkWFU/aapO0FF6y9Y4J4SN7vpy3bH8aWYMTVG70Hn8=; b=IkTlWL1z3PVjSKCJeaqvDUIsu38aEd7FI60q3RN127YVMnqsytGzNQzX7HkiNV5PGf 9AS7NrZ5+g794PeZQMJdtAMmghiloMthvZAHzS3nW1XwVS4PbrD9ELrMAp4t68DPDzgw aIx3/DQJYAk9wMN8yiBYzQYo3+QxFxQyGl6jj/D814CD42IASlB2G6HKEf/nldnQ5D5s lHUWMWlxCj0bziRboCsC32z2jugb7CmrKmF8FApDrUc3uGWtkr3uIOa12mulK4YWKDD0 KJuRCiMzs9jn9M9WWF8UHZLQN/Mzu9vPT3D+MeauJo4nDX+kHblHbYY0tdxBEH3YutR3 V5FA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1761945608; x=1762550408; 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=TRkWFU/aapO0FF6y9Y4J4SN7vpy3bH8aWYMTVG70Hn8=; b=Vssx/nZXPv8asu+yM2GMS1yUv0O+4hjD3Zd0gcLNlaRZCxBN0fdbtKEgYouZ2h/dKv lkM/F48Ef+q8d036TSz9o6jxyV2p94r0KhTfzhDGTwRDPBWa6eaPF/k4eiTSWOG2eQhs 9oIslRLytWDKn3EW6uBjmpwvMNsodd7EuGP//SH2KVHd1aSjVxOMMHKFkEhnQFlI4ZP0 r8tUPB5kvlNnoBFggPQYgmGsQW1yNtbqdzuw8/UTCE2/np3IKa0V0PPVI/TA55VCtGJG JX6XsgWRtq2M3sAwHqr/88ExLyhJ/XvvuvpdqMf8kZ96VZ//oVLLsgCXMUhtQ5kPYmBn q/+Q== X-Gm-Message-State: AOJu0YxDuu/lRgI1U/5Wd3FcwminiUzGwDMYi3meOaaEZZxbKwknem2U FLoP3Hff30/xwOUl/DhCu20BxaAOmWyb2nw3xfkl7EiLpP6yNPnDolUxiDeRMCWBJqXJzPe0qj1 jUj/9mfrKkg== X-Gm-Gg: ASbGnctLEJ9gnAUedccr83j/Z1EsVO5Or5Jj4iGeclkephqLwZ+ZXzhmwl7D6Tysj7s XIvqwhruJGQCgSYcvkRJb3tB4DuGTuPP9Ym/wv70nE+ct7nXt8tXav+HISQIB6lPcXb+n0VtKWG JsQFH4zuD/nLFrlHHbGqAfS9QTEdVU0jwqBGc5wVjPPAzasSJcUIn5ZBMl512JGRploHYMXH3al EQwAtQMO9Znnj6D9bQyuv4OKaZn6dnESpIUCVViEyOjwVV2J70o0db0bfEI89AwagtttJQxNrTB KDyMwwhASdj/bVzif8tAun6nl2BWKRxVlYXuxU2GcnLmsySkTvGgs76apJR0N4pbGWMbBzREsHW VDCiD7U50zlWLKZ9gFncXuAuf516+7wg8nSDdlArxd4QNS2ieICfyy7QFZFc1MTAu1xlEyMvSs9 f2PyqwaKu8sI21dOhK4Q5zPBgQmqEXSYL3MXr9oTqPW3H6HNoV X-Google-Smtp-Source: AGHT+IEcvUahVrXqdQpda5Jmzh00TDRKdk7K7n7yUy3kWYWRimLq4lodPyYuNRcgonQioDY8GNflkA== X-Received: by 2002:a05:6000:1acb:b0:425:75c6:7125 with SMTP id ffacd0b85a97d-429bd680bb9mr4527610f8f.16.1761945608366; Fri, 31 Oct 2025 14:20:08 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PULL 9/9] rx: cpu: fix interrupts check in rx_cpu_do_interrupt() Date: Fri, 31 Oct 2025 22:15:18 +0100 Message-ID: <20251031211518.38503-10-philmd@linaro.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251031211518.38503-1-philmd@linaro.org> References: <20251031211518.38503-1-philmd@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=2a00:1450:4864:20::435; envelope-from=philmd@linaro.org; helo=mail-wr1-x435.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1761945646979154100 From: Igor Mammedov Commit 87511341c30 broke interrupt handling, replacing interrupts fetch with a bool and then the remaining code attempting to check individual bits on that bool value, which effectively masked those interrupts. Fix it by checking individual interrupt bits directly instead of old 'fetch then check' approach. Fixes: 87511341c30d ("add cpu_test_interrupt()/cpu_set_interrupt() helpers = and use them tree wide") Reported-by: Thomas Huth Signed-off-by: Igor Mammedov Reviewed-by: Philippe Mathieu-Daud=C3=A9 Tested-by: Thomas Huth Reviewed-by: Thomas Huth Message-ID: <20251030165932.138512-1-imammedo@redhat.com> [PMD: Rebased on commit dde21df2393 "call plugin trap callbacks"] Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- target/rx/helper.c | 45 ++++++++++++++++++++------------------------- 1 file changed, 20 insertions(+), 25 deletions(-) diff --git a/target/rx/helper.c b/target/rx/helper.c index ef47e32add8..e9a7aaf610d 100644 --- a/target/rx/helper.c +++ b/target/rx/helper.c @@ -41,11 +41,9 @@ void rx_cpu_unpack_psw(CPURXState *env, uint32_t psw, in= t rte) env->psw_c =3D FIELD_EX32(psw, PSW, C); } =20 -#define INT_FLAGS (CPU_INTERRUPT_HARD | CPU_INTERRUPT_FIR) void rx_cpu_do_interrupt(CPUState *cs) { CPURXState *env =3D cpu_env(cs); - int do_irq =3D cpu_test_interrupt(cs, INT_FLAGS); uint32_t save_psw; uint64_t last_pc =3D env->pc; =20 @@ -59,29 +57,26 @@ void rx_cpu_do_interrupt(CPUState *cs) save_psw =3D rx_cpu_pack_psw(env); env->psw_pm =3D env->psw_i =3D env->psw_u =3D 0; =20 - if (do_irq) { - if (do_irq & CPU_INTERRUPT_FIR) { - env->bpc =3D env->pc; - env->bpsw =3D save_psw; - env->pc =3D env->fintv; - env->psw_ipl =3D 15; - cpu_reset_interrupt(cs, CPU_INTERRUPT_FIR); - qemu_set_irq(env->ack, env->ack_irq); - qemu_plugin_vcpu_interrupt_cb(cs, last_pc); - qemu_log_mask(CPU_LOG_INT, "fast interrupt raised\n"); - } else if (do_irq & CPU_INTERRUPT_HARD) { - env->isp -=3D 4; - cpu_stl_data(env, env->isp, save_psw); - env->isp -=3D 4; - cpu_stl_data(env, env->isp, env->pc); - env->pc =3D cpu_ldl_data(env, env->intb + env->ack_irq * 4); - env->psw_ipl =3D env->ack_ipl; - cpu_reset_interrupt(cs, CPU_INTERRUPT_HARD); - qemu_set_irq(env->ack, env->ack_irq); - qemu_plugin_vcpu_interrupt_cb(cs, last_pc); - qemu_log_mask(CPU_LOG_INT, - "interrupt 0x%02x raised\n", env->ack_irq); - } + if (cpu_test_interrupt(cs, CPU_INTERRUPT_FIR)) { + env->bpc =3D env->pc; + env->bpsw =3D save_psw; + env->pc =3D env->fintv; + env->psw_ipl =3D 15; + cpu_reset_interrupt(cs, CPU_INTERRUPT_FIR); + qemu_set_irq(env->ack, env->ack_irq); + qemu_plugin_vcpu_interrupt_cb(cs, last_pc); + qemu_log_mask(CPU_LOG_INT, "fast interrupt raised\n"); + } else if (cpu_test_interrupt(cs, CPU_INTERRUPT_HARD)) { + env->isp -=3D 4; + cpu_stl_data(env, env->isp, save_psw); + env->isp -=3D 4; + cpu_stl_data(env, env->isp, env->pc); + env->pc =3D cpu_ldl_data(env, env->intb + env->ack_irq * 4); + env->psw_ipl =3D env->ack_ipl; + cpu_reset_interrupt(cs, CPU_INTERRUPT_HARD); + qemu_set_irq(env->ack, env->ack_irq); + qemu_plugin_vcpu_interrupt_cb(cs, last_pc); + qemu_log_mask(CPU_LOG_INT, "interrupt 0x%02x raised\n", env->ack_i= rq); } else { uint32_t vec =3D cs->exception_index; const char *expname =3D "unknown exception"; --=20 2.51.0