From nobody Tue Nov 26 04:50:36 2024 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=1709640696; cv=none; d=zohomail.com; s=zohoarc; b=j67NGqF+OvApzL2TYPc0SuIDz013XoEMaEPz3fmPmrGXcNirpeQGY55KS8qQ7StcIVUt46RNUTXmobui4HZFt8mDO4TNrp8I18c7DaS//138X4rg5QbgeJrqIphpgGmEvs9v/1XNvRFoZMnqZhVXFW/CusQBXdSF3fv7T0T5YKw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709640696; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=7ZN0Cc6U7kZmDYYmwDnkR5eJs9jrLVG4XEoadrQPyUk=; b=IIBAIsE5z38OTeinTOI5wb1oMFil1ZxGF5NF1Y+N5HKGsnHNLotzLVYzT4/3wX/YridsQGKbQOZtHpH8rpAhbFs6L3FfvIMf5pjgJ6+zwGCDsDk9h9vht/n7WcuaDXO4blJU0fI5Hzd9puF2drrhKDJV+dPOVxqH3gQ2FaA00pk= 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 1709640695991232.11773173583288; Tue, 5 Mar 2024 04:11:35 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rhTcs-0001an-3u; Tue, 05 Mar 2024 07:10:30 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rhTcb-0001Rr-Cd for qemu-devel@nongnu.org; Tue, 05 Mar 2024 07:10:15 -0500 Received: from mail-wm1-x330.google.com ([2a00:1450:4864:20::330]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rhTcY-0001Bz-VG for qemu-devel@nongnu.org; Tue, 05 Mar 2024 07:10:13 -0500 Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-412eddd14b9so3213705e9.2 for ; Tue, 05 Mar 2024 04:10:09 -0800 (PST) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id r15-20020a05600c35cf00b00412e3717ae6sm6193958wmq.36.2024.03.05.04.10.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Mar 2024 04:10:06 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 7F1E45F8E5; Tue, 5 Mar 2024 12:10:05 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1709640608; x=1710245408; 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=7ZN0Cc6U7kZmDYYmwDnkR5eJs9jrLVG4XEoadrQPyUk=; b=kfpgOXLnJNQAzZuByzuLYabru7PL1RCKr4GbiOtspygcx64QLp/QYLug0cABIYYInb Yx+k2iwuHaqfSDxq44p1M1/zDHiqpNLdZEASJRPSxVW/eaKV6ETE7Rhux3GqpyHxdq8J dMTgAmqRREvbTaNQBjWVX+SLTsjFxZdyMy4Y2MLnbrvRmGSJzlN2gPRWfmxtGFcV3xzw jH/eRQcGCJ5c0UbSUEVxCCvaxKVkgjIMFjEjOLmXKbdW4ZxnhFkJquEq5xgf/rNpWj3E 4yujLsS9sViVMEdbSeufl+de4LQw6/q2OpVZ0wzdwT/MBgEU0yVL+LTZS9nNfXmZhT4k j7FA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709640608; x=1710245408; 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=7ZN0Cc6U7kZmDYYmwDnkR5eJs9jrLVG4XEoadrQPyUk=; b=Fk8poJSlzrk3mvVhDKTvbO7vDdCtEOIt0fWy7m8S1IbcV/w7zNJiB4Aqjf4KblfqFo q9m+8Ja94hu1qWlSpm7ypNV4PEPX54Wa/bV3zbKf6iuSG0GJt+PvQqmfTpuTMUeUUrbv 8EW6nVHd2aOO5eFg02iU85n01gzp+VQtO5PtVnH6W0p1dehcawZC7jgrW7ShOYjDSK+b 1eoKaS50uE2wKpxpnyLha0L6SX36mZ9k9oTkutHJ3yy8Nvzh4aJN8gDk3swlKiyynOv5 95Guh5lyTxx+thdCcwdSPD9+gvrwtfhJB0i0JAq9O7EL3pV35VOGbeYlDGHQtBmhBSAb wA5Q== X-Gm-Message-State: AOJu0Yz3aL/tfNrhqX9ohayl1s7eF30AXrD8tubxoMY3LD0VZRPd6Mya jLEsKDi5w+jYcc/JieSOWKdcgO/1heVzHsoAtCSWxWsdBC01Mu78xUGJVo40aX8= X-Google-Smtp-Source: AGHT+IH/W+ykW1GNkMl2JLVL3L6gE85bzXmXTMA16C/kgMcjWXhBlpstz70b2VrLWp+WgQcxWy/g/w== X-Received: by 2002:a05:600c:4e0c:b0:412:eddd:12c2 with SMTP id b12-20020a05600c4e0c00b00412eddd12c2mr1009970wmq.6.1709640608336; Tue, 05 Mar 2024 04:10:08 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Wainer dos Santos Moschetta , Alistair Francis , Nicholas Piggin , Liu Zhiwei , Richard Henderson , Yanan Wang , qemu-s390x@nongnu.org, "Edgar E. Iglesias" , Eduardo Habkost , Daniel Henrique Barboza , Michael Rolnik , Daniel Henrique Barboza , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Laurent Vivier , Yoshinori Sato , Laurent Vivier , Thomas Huth , Peter Maydell , Mahmoud Mandour , Brad Smith , Alistair Francis , Brian Cain , Cleber Rosa , John Snow , Marcel Apfelbaum , Pierrick Bouvier , Palmer Dabbelt , Riku Voipio , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, Weiwei Li , Bin Meng , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Beraldo Leal , Kyle Evans , David Hildenbrand , Song Gao , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Paolo Bonzini , Alexandre Iooss , Warner Losh , qemu-riscv@nongnu.org, Ilya Leoshkevich Subject: [PATCH 01/29] tests: bump QOS_PATH_MAX_ELEMENT_SIZE again Date: Tue, 5 Mar 2024 12:09:37 +0000 Message-Id: <20240305121005.3528075-2-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240305121005.3528075-1-alex.bennee@linaro.org> References: <20240305121005.3528075-1-alex.bennee@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::330; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x330.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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1709640697690100007 We "fixed" a bug with LTO builds with 100c459f194 (tests/qtest: bump up QOS_PATH_MAX_ELEMENT_SIZE) but it seems it has triggered again. The array is sized according to the maximum anticipated length of a path on the graph. However, the worst case for a depth-first search is to push all nodes on the graph. So it's not really LTO, it depends on the ordering of the constructors. Lets be more assertive raising QOS_PATH_MAX_ELEMENT_SIZE to make it go away again. Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1186 (again) Reviewed-by: Thomas Huth Signed-off-by: Alex Benn=C3=A9e Message-Id: <20240304193702.3195255-1-alex.bennee@linaro.org> --- tests/qtest/libqos/qgraph.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/qtest/libqos/qgraph.h b/tests/qtest/libqos/qgraph.h index 287022a67c1..1b5de02e7be 100644 --- a/tests/qtest/libqos/qgraph.h +++ b/tests/qtest/libqos/qgraph.h @@ -24,7 +24,7 @@ #include "libqos-malloc.h" =20 /* maximum path length */ -#define QOS_PATH_MAX_ELEMENT_SIZE 64 +#define QOS_PATH_MAX_ELEMENT_SIZE 128 =20 typedef struct QOSGraphObject QOSGraphObject; typedef struct QOSGraphNode QOSGraphNode; --=20 2.39.2 From nobody Tue Nov 26 04:50:36 2024 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=1709640718; cv=none; d=zohomail.com; s=zohoarc; b=lx2wWrtRvVZkIEiRI85KTD0vPeeS2EnsC3+OEUxAvaa5iEse6/sKvRVPH0hShD264Xau/T30ru7x8APXRnJkPuzSg62O8jGb6d0Nl92v1wXnd3DTbY0aJGIQSFWv5k/Wib8k3IOBz8m5sHICiHkK+f6gdOwa+xj/1L0DyaxTRY0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709640718; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=1AT7cxGTPpcWYG5sWFRMol9k8JFzimRlPNRIRTYHRNg=; b=SjGtUhBzTGnTzL+VNNHN27Nym0MyJGBqeVsME5/jyBPTNZRwe4NGfum6zy1j2GT84hmgkr+86efyN5TlSZiPVuO4SQbRuIU2KGNKFunjEkaRvtJF+IgQF7t+ZF6c22wqry3C77K/iTef8QUHt7X7PA1IEayIbVXHsM++2mnoKfY= 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 1709640718342360.5701458128118; Tue, 5 Mar 2024 04:11:58 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rhTdd-0002Me-9U; Tue, 05 Mar 2024 07:11:17 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rhTci-0001Yn-Qi for qemu-devel@nongnu.org; Tue, 05 Mar 2024 07:10:22 -0500 Received: from mail-lj1-x236.google.com ([2a00:1450:4864:20::236]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rhTcZ-0001C8-2S for qemu-devel@nongnu.org; Tue, 05 Mar 2024 07:10:20 -0500 Received: by mail-lj1-x236.google.com with SMTP id 38308e7fff4ca-2d24a727f78so68310941fa.0 for ; Tue, 05 Mar 2024 04:10:10 -0800 (PST) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id n37-20020a05600c3ba500b00412e58be350sm5058056wms.1.2024.03.05.04.10.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Mar 2024 04:10:05 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 92CA65F94F; Tue, 5 Mar 2024 12:10:05 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1709640608; x=1710245408; 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=1AT7cxGTPpcWYG5sWFRMol9k8JFzimRlPNRIRTYHRNg=; b=PSXDaX0HveSCBlvqTy56KKU4A+Ckn5NB8GfSmvbBC3+r/M31oRox+YCZRozqzORLb2 ix037KNkIUeJfhvWiPoeuVqmLnxttjxtjhsxuihPFk6cAFIN+Cc02D8qV6g43gNTAAyg u34Vd9LoLOPzzjci2LXlqu4U59U4FmPgvzRH/wXIS9hgXgMPD5iK8lKF5KBPHpzBirDe yU9iSSgCmuUA1ncu6hEBVdauHt5I2+Z0IwWP+p/6vZDqC7DhW/zuzSCh5Mjbvn1HR+sb osX2TFWfPS39K6Z33yot2zLg0jm2O4FuAJDhAigAi2+ev4JWDoIXTWl/v9IZ92kF5PrJ zYqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709640608; x=1710245408; 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=1AT7cxGTPpcWYG5sWFRMol9k8JFzimRlPNRIRTYHRNg=; b=CRYELGmZB0Zn3ap+O9t9bNd6EuAvayLhoXkIoD2EzBkkwLd0jlFjyTT1Su/MmF2ABs Yqxu+p90wFU11zekswxGYReW6QdQUdv3DDGwXZYTZnAgVaquHg0U3TRijCHlO6uo55z3 E7VIzBnlZ/OVKBbX4OXANetF6G/yF1JZpVqVFarnrMknrOL1Yggq981h4IoAwHDxFy6/ 6iYyLKjEGNaNKVYWCUxlgkcW+dr6Ves3n8O0C/5+/1RSw1S6PW97bE1m9TrBaHCtoasx LljsGNC7CuEXwptoKZ8U+G9UaBcQQZWzUDP+rb0LQ7K0AN6cP7xvWVZ2xczD2FadyGGC QSPg== X-Gm-Message-State: AOJu0YxLybRb9DYqg8obgJx8fFIBNAxiPlmtUPRC2+oOxm3sJWUbVcOZ /mE9a2LCcw/SnChOVVKJOzaKR2fpQSE+8N4z20FCWUsCy1YXoH70zdZq+YfAEFxiQGUp2hy1WWW M X-Google-Smtp-Source: AGHT+IF7OjgwwH0OGzJT5fr931L4iISERtzu8u1PLjCYvKPLQj6s0B2xjag31JWn8x1LwJ0EhfAgkg== X-Received: by 2002:a05:651c:150:b0:2d3:56df:ea4b with SMTP id c16-20020a05651c015000b002d356dfea4bmr1388334ljd.41.1709640608205; Tue, 05 Mar 2024 04:10:08 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Wainer dos Santos Moschetta , Alistair Francis , Nicholas Piggin , Liu Zhiwei , Richard Henderson , Yanan Wang , qemu-s390x@nongnu.org, "Edgar E. Iglesias" , Eduardo Habkost , Daniel Henrique Barboza , Michael Rolnik , Daniel Henrique Barboza , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Laurent Vivier , Yoshinori Sato , Laurent Vivier , Thomas Huth , Peter Maydell , Mahmoud Mandour , Brad Smith , Alistair Francis , Brian Cain , Cleber Rosa , John Snow , Marcel Apfelbaum , Pierrick Bouvier , Palmer Dabbelt , Riku Voipio , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, Weiwei Li , Bin Meng , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Beraldo Leal , Kyle Evans , David Hildenbrand , Song Gao , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Paolo Bonzini , Alexandre Iooss , Warner Losh , qemu-riscv@nongnu.org, Ilya Leoshkevich Subject: [PATCH 02/29] gdbstub: Support disablement in a multi-threaded process Date: Tue, 5 Mar 2024 12:09:38 +0000 Message-Id: <20240305121005.3528075-3-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240305121005.3528075-1-alex.bennee@linaro.org> References: <20240305121005.3528075-1-alex.bennee@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::236; envelope-from=alex.bennee@linaro.org; helo=mail-lj1-x236.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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1709640719787100007 From: Ilya Leoshkevich The upcoming follow-fork-mode child support will require disabling gdbstub in the parent process, which may have multiple threads (which are represented as CPUs). Loop over all CPUs in order to remove breakpoints and disable single-step. Move the respective code into a separate function. Reviewed-by: Alex Benn=C3=A9e Reviewed-by: Richard Henderson Signed-off-by: Ilya Leoshkevich Message-Id: <20240219141628.246823-2-iii@linux.ibm.com> Signed-off-by: Alex Benn=C3=A9e --- gdbstub/user.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/gdbstub/user.c b/gdbstub/user.c index 14918d1a217..3ce20b7bbfc 100644 --- a/gdbstub/user.c +++ b/gdbstub/user.c @@ -356,16 +356,27 @@ int gdbserver_start(const char *port_or_path) return -1; } =20 +static void disable_gdbstub(CPUState *thread_cpu) +{ + CPUState *cpu; + + close(gdbserver_user_state.fd); + gdbserver_user_state.fd =3D -1; + CPU_FOREACH(cpu) { + cpu_breakpoint_remove_all(cpu, BP_GDB); + /* no cpu_watchpoint_remove_all for user-mode */ + cpu_single_step(cpu, 0); + } + tb_flush(thread_cpu); +} + /* Disable gdb stub for child processes. */ void gdbserver_fork(CPUState *cpu) { if (!gdbserver_state.init || gdbserver_user_state.fd < 0) { return; } - close(gdbserver_user_state.fd); - gdbserver_user_state.fd =3D -1; - cpu_breakpoint_remove_all(cpu, BP_GDB); - /* no cpu_watchpoint_remove_all for user-mode */ + disable_gdbstub(cpu); } =20 /* --=20 2.39.2 From nobody Tue Nov 26 04:50:36 2024 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=1709640756; cv=none; d=zohomail.com; s=zohoarc; b=n43y3KmmzatviYPwVkc+dF/cR9429UjIX7FJpIRHja5I3NfiVKLJsEuiTNj3r4rmG0TLHr/3Eck9ImcN/fkVO3YJA6CSagIQPkBWsUBSYvOwFr3ITGVvuALLcWplx7oymgF2Adu9qapZPT57Ey6hbCEqS0uHRn05UYnNsOLphlc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709640756; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=NQce98qJEyJHk/DsO8BnMbADDzmjEz9JOc/CPq8YOck=; b=PPv5puSX3+IJvd10d+zpZfBZNoUGmTHWIbOporzoK5Vi7So6KHVH6fBV0pW2o5Pr3CnViKs/Qwds4olFTUlnG70rxVp3/VCvUPLRUcblFViG5A/quU/TEQdnjx9iYpMWmSzONZ+NXsJ8++lxuT7wNUtT1W+bcnuMv2K6bXj6vsg= 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 1709640756204860.2271993929863; Tue, 5 Mar 2024 04:12:36 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rhTdn-0002qy-57; Tue, 05 Mar 2024 07:11:27 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rhTct-0001ca-3M for qemu-devel@nongnu.org; Tue, 05 Mar 2024 07:10:32 -0500 Received: from mail-wm1-x32d.google.com ([2a00:1450:4864:20::32d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rhTcd-0001QT-Di for qemu-devel@nongnu.org; Tue, 05 Mar 2024 07:10:30 -0500 Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-412e783c94fso12230595e9.1 for ; Tue, 05 Mar 2024 04:10:13 -0800 (PST) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id k4-20020a05600c1c8400b00412e556d4besm5248221wms.48.2024.03.05.04.10.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Mar 2024 04:10:08 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id C68645F950; Tue, 5 Mar 2024 12:10:05 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1709640612; x=1710245412; 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=NQce98qJEyJHk/DsO8BnMbADDzmjEz9JOc/CPq8YOck=; b=gJ4iwIgjmd2O5FnlzSRNaM8XdQGotZO5eilFYHfoJgE5fsw2E5cIDSHauA0BV4By1L 5PRB+JCIOoKisnKclA9tBH2GzgvbKsfwA1QiaXv2IVgUQorWte3rz5FPBz0yNhPP9K7q 5oNqrqpco2q8o2yBqwgiQn+4/4qO+LVn6RT5huD7oICOgdcpLp03RoA7l5oAb/GtGDkA i+rxQA92VX2K9cn4bSocQLmXbsewJVenmxbC9JMEsV46VGQAGFAKc09h0MyNaoJTqtrO IRg2Cl14FoVH/wETz/LgwVPypn5BYxf+ufOEyub/R4XUhIUo9I7yPCTTfBLs46rp31uz O/UQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709640612; x=1710245412; 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=NQce98qJEyJHk/DsO8BnMbADDzmjEz9JOc/CPq8YOck=; b=wF/Ek71eRucsM5b+qPRSlmqR/f4RtAyqj07xRajJ5KYlrPXsxIR1rLi21QWj93G7Oh yfmt2bBca9CDenqHQ03jlk2OTHAYdQwypxj42PTwXIYIyNle2IMzxTui7j15xhKtPwFf Pn/iYYGVYDLm/AH/pisz5txWotBxrHknzqKHZHdrSp3rjIGt2ROftEOUMIQRiUX4+6Z/ wyp0oC27WdCNcYv0zbdm4erR5hOApmyL0BX3hb/dAac+UF1MwW9+Ld2/6OuOdfPiZlI2 GwH9+KfugTYO7YO45iw+3wPkB825TSW3T0i7NmTOVHcz9rtJGm/nYBjynkO06a2ViyVP QKcg== X-Gm-Message-State: AOJu0YwRmBCEE8Vm/33sDQ6QOFYDKiAzqhBn9vbe61kNw4+quruJ7Peg NnlIRTDQJZ6ieh+jy/5pQNlqMX/LNnU9ziAau6Zg3LRcaYkdnYSt6xrEzGzvS2c= X-Google-Smtp-Source: AGHT+IHupt0qcpOJj0SIQLFcIyMz8Hyj8VllcouPhlZKUwvjs09k/K4XCmZlScyHdHo+GEsuLbhsNQ== X-Received: by 2002:a05:600c:198c:b0:412:c7d9:bd96 with SMTP id t12-20020a05600c198c00b00412c7d9bd96mr9590907wmq.8.1709640612224; Tue, 05 Mar 2024 04:10:12 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Wainer dos Santos Moschetta , Alistair Francis , Nicholas Piggin , Liu Zhiwei , Richard Henderson , Yanan Wang , qemu-s390x@nongnu.org, "Edgar E. Iglesias" , Eduardo Habkost , Daniel Henrique Barboza , Michael Rolnik , Daniel Henrique Barboza , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Laurent Vivier , Yoshinori Sato , Laurent Vivier , Thomas Huth , Peter Maydell , Mahmoud Mandour , Brad Smith , Alistair Francis , Brian Cain , Cleber Rosa , John Snow , Marcel Apfelbaum , Pierrick Bouvier , Palmer Dabbelt , Riku Voipio , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, Weiwei Li , Bin Meng , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Beraldo Leal , Kyle Evans , David Hildenbrand , Song Gao , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Paolo Bonzini , Alexandre Iooss , Warner Losh , qemu-riscv@nongnu.org, Ilya Leoshkevich Subject: [PATCH 03/29] {linux,bsd}-user: Introduce get_task_state() Date: Tue, 5 Mar 2024 12:09:39 +0000 Message-Id: <20240305121005.3528075-4-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240305121005.3528075-1-alex.bennee@linaro.org> References: <20240305121005.3528075-1-alex.bennee@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::32d; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x32d.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, T_SCC_BODY_TEXT_LINE=-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: 1709640758010100003 From: Ilya Leoshkevich A CPU's TaskState is stored in the CPUState's void *opaque field, accessing which is somewhat awkward due to having to use a cast. Introduce a wrapper and use it everywhere. Suggested-by: Alex Benn=C3=A9e Signed-off-by: Ilya Leoshkevich Reviewed-by: Warner Losh Reviewed-by: Richard Henderson Message-Id: <20240219141628.246823-3-iii@linux.ibm.com> Signed-off-by: Alex Benn=C3=A9e --- bsd-user/bsd-file.h | 2 +- bsd-user/qemu.h | 5 +++++ include/user/safe-syscall.h | 2 +- linux-user/m68k/target_cpu.h | 2 +- linux-user/qemu.h | 5 +++++ linux-user/signal-common.h | 2 +- bsd-user/signal.c | 20 ++++++++++---------- gdbstub/user-target.c | 4 ++-- linux-user/aarch64/cpu_loop.c | 2 +- linux-user/arm/cpu_loop.c | 4 ++-- linux-user/arm/signal.c | 2 +- linux-user/cris/cpu_loop.c | 2 +- linux-user/elfload.c | 2 +- linux-user/hppa/signal.c | 2 +- linux-user/linuxload.c | 2 +- linux-user/m68k/cpu_loop.c | 2 +- linux-user/mips/cpu_loop.c | 2 +- linux-user/ppc/signal.c | 4 ++-- linux-user/riscv/cpu_loop.c | 2 +- linux-user/signal.c | 30 +++++++++++++++--------------- linux-user/syscall.c | 26 +++++++++++++------------- linux-user/vm86.c | 18 +++++++++--------- linux-user/xtensa/signal.c | 2 +- plugins/api.c | 8 ++++---- semihosting/arm-compat-semi.c | 8 ++++---- 25 files changed, 85 insertions(+), 75 deletions(-) diff --git a/bsd-user/bsd-file.h b/bsd-user/bsd-file.h index 3c00dc00567..6fa2c30b4de 100644 --- a/bsd-user/bsd-file.h +++ b/bsd-user/bsd-file.h @@ -641,7 +641,7 @@ static abi_long do_bsd_readlink(CPUArchState *env, abi_= long arg1, } if (strcmp(p1, "/proc/curproc/file") =3D=3D 0) { CPUState *cpu =3D env_cpu(env); - TaskState *ts =3D (TaskState *)cpu->opaque; + TaskState *ts =3D get_task_state(cpu); strncpy(p2, ts->bprm->fullpath, arg3); ret =3D MIN((abi_long)strlen(ts->bprm->fullpath), arg3); } else { diff --git a/bsd-user/qemu.h b/bsd-user/qemu.h index c05c5127676..4adb75d19ff 100644 --- a/bsd-user/qemu.h +++ b/bsd-user/qemu.h @@ -117,6 +117,11 @@ typedef struct TaskState { struct target_sigaltstack sigaltstack_used; } __attribute__((aligned(16))) TaskState; =20 +static inline TaskState *get_task_state(CPUState *cs) +{ + return cs->opaque; +} + void stop_all_tasks(void); extern const char *interp_prefix; extern const char *qemu_uname_release; diff --git a/include/user/safe-syscall.h b/include/user/safe-syscall.h index 27b71cdbd8e..aa075f4d5cd 100644 --- a/include/user/safe-syscall.h +++ b/include/user/safe-syscall.h @@ -134,7 +134,7 @@ extern char safe_syscall_start[]; extern char safe_syscall_end[]; =20 #define safe_syscall(...) \ - safe_syscall_base(&((TaskState *)thread_cpu->opaque)->signal_pending, \ + safe_syscall_base(&get_task_state(thread_cpu)->signal_pending, \ __VA_ARGS__) =20 #endif diff --git a/linux-user/m68k/target_cpu.h b/linux-user/m68k/target_cpu.h index c3f288dfe83..4b40c09a8d6 100644 --- a/linux-user/m68k/target_cpu.h +++ b/linux-user/m68k/target_cpu.h @@ -37,7 +37,7 @@ static inline void cpu_clone_regs_parent(CPUM68KState *en= v, unsigned flags) static inline void cpu_set_tls(CPUM68KState *env, target_ulong newtls) { CPUState *cs =3D env_cpu(env); - TaskState *ts =3D cs->opaque; + TaskState *ts =3D get_task_state(cs); =20 ts->tp_value =3D newtls; } diff --git a/linux-user/qemu.h b/linux-user/qemu.h index 4de9ec783f6..32cd43d9eff 100644 --- a/linux-user/qemu.h +++ b/linux-user/qemu.h @@ -162,6 +162,11 @@ typedef struct TaskState { uint64_t start_boottime; } TaskState; =20 +static inline TaskState *get_task_state(CPUState *cs) +{ + return cs->opaque; +} + abi_long do_brk(abi_ulong new_brk); int do_guest_openat(CPUArchState *cpu_env, int dirfd, const char *pathname, int flags, mode_t mode, bool safe); diff --git a/linux-user/signal-common.h b/linux-user/signal-common.h index 3e2dc604c2f..a7df12fc445 100644 --- a/linux-user/signal-common.h +++ b/linux-user/signal-common.h @@ -113,7 +113,7 @@ int process_sigsuspend_mask(sigset_t **pset, target_ulo= ng sigset, static inline void finish_sigsuspend_mask(int ret) { if (ret !=3D -QEMU_ERESTARTSYS) { - TaskState *ts =3D (TaskState *)thread_cpu->opaque; + TaskState *ts =3D get_task_state(thread_cpu); ts->in_sigsuspend =3D 1; } } diff --git a/bsd-user/signal.c b/bsd-user/signal.c index f4352e4530f..e9f80a06d32 100644 --- a/bsd-user/signal.c +++ b/bsd-user/signal.c @@ -319,7 +319,7 @@ void host_to_target_siginfo(target_siginfo_t *tinfo, co= nst siginfo_t *info) =20 int block_signals(void) { - TaskState *ts =3D (TaskState *)thread_cpu->opaque; + TaskState *ts =3D get_task_state(thread_cpu); sigset_t set; =20 /* @@ -359,7 +359,7 @@ void dump_core_and_abort(int target_sig) { CPUState *cpu =3D thread_cpu; CPUArchState *env =3D cpu_env(cpu); - TaskState *ts =3D cpu->opaque; + TaskState *ts =3D get_task_state(cpu); int core_dumped =3D 0; int host_sig; struct sigaction act; @@ -421,7 +421,7 @@ void queue_signal(CPUArchState *env, int sig, int si_ty= pe, target_siginfo_t *info) { CPUState *cpu =3D env_cpu(env); - TaskState *ts =3D cpu->opaque; + TaskState *ts =3D get_task_state(cpu); =20 trace_user_queue_signal(env, sig); =20 @@ -476,7 +476,7 @@ void force_sig_fault(int sig, int code, abi_ulong addr) static void host_signal_handler(int host_sig, siginfo_t *info, void *puc) { CPUState *cpu =3D thread_cpu; - TaskState *ts =3D cpu->opaque; + TaskState *ts =3D get_task_state(cpu); target_siginfo_t tinfo; ucontext_t *uc =3D puc; struct emulated_sigtable *k; @@ -585,7 +585,7 @@ static void host_signal_handler(int host_sig, siginfo_t= *info, void *puc) /* compare to kern/kern_sig.c sys_sigaltstack() and kern_sigaltstack() */ abi_long do_sigaltstack(abi_ulong uss_addr, abi_ulong uoss_addr, abi_ulong= sp) { - TaskState *ts =3D (TaskState *)thread_cpu->opaque; + TaskState *ts =3D get_task_state(thread_cpu); int ret; target_stack_t oss; =20 @@ -714,7 +714,7 @@ int do_sigaction(int sig, const struct target_sigaction= *act, static inline abi_ulong get_sigframe(struct target_sigaction *ka, CPUArchState *env, size_t frame_size) { - TaskState *ts =3D (TaskState *)thread_cpu->opaque; + TaskState *ts =3D get_task_state(thread_cpu); abi_ulong sp; =20 /* Use default user stack */ @@ -789,7 +789,7 @@ static int reset_signal_mask(target_ucontext_t *ucontex= t) int i; sigset_t blocked; target_sigset_t target_set; - TaskState *ts =3D (TaskState *)thread_cpu->opaque; + TaskState *ts =3D get_task_state(thread_cpu); =20 for (i =3D 0; i < TARGET_NSIG_WORDS; i++) { __get_user(target_set.__bits[i], &ucontext->uc_sigmask.__bits[i]); @@ -839,7 +839,7 @@ badframe: =20 void signal_init(void) { - TaskState *ts =3D (TaskState *)thread_cpu->opaque; + TaskState *ts =3D get_task_state(thread_cpu); struct sigaction act; struct sigaction oact; int i; @@ -878,7 +878,7 @@ static void handle_pending_signal(CPUArchState *env, in= t sig, struct emulated_sigtable *k) { CPUState *cpu =3D env_cpu(env); - TaskState *ts =3D cpu->opaque; + TaskState *ts =3D get_task_state(cpu); struct target_sigaction *sa; int code; sigset_t set; @@ -967,7 +967,7 @@ void process_pending_signals(CPUArchState *env) int sig; sigset_t *blocked_set, set; struct emulated_sigtable *k; - TaskState *ts =3D cpu->opaque; + TaskState *ts =3D get_task_state(cpu); =20 while (qatomic_read(&ts->signal_pending)) { sigfillset(&set); diff --git a/gdbstub/user-target.c b/gdbstub/user-target.c index b7d4c37cd81..6646684a4c6 100644 --- a/gdbstub/user-target.c +++ b/gdbstub/user-target.c @@ -204,7 +204,7 @@ int gdb_target_signal_to_gdb(int sig) =20 int gdb_get_cpu_index(CPUState *cpu) { - TaskState *ts =3D (TaskState *) cpu->opaque; + TaskState *ts =3D get_task_state(cpu); return ts ? ts->ts_tid : -1; } =20 @@ -399,7 +399,7 @@ void gdb_handle_query_xfer_exec_file(GArray *params, vo= id *user_ctx) return; } =20 - TaskState *ts =3D cpu->opaque; + TaskState *ts =3D get_task_state(cpu); if (!ts || !ts->bprm || !ts->bprm->filename) { gdb_put_packet("E00"); return; diff --git a/linux-user/aarch64/cpu_loop.c b/linux-user/aarch64/cpu_loop.c index 8c20dc8a39a..71cdc8be50c 100644 --- a/linux-user/aarch64/cpu_loop.c +++ b/linux-user/aarch64/cpu_loop.c @@ -189,7 +189,7 @@ void target_cpu_copy_regs(CPUArchState *env, struct tar= get_pt_regs *regs) { ARMCPU *cpu =3D env_archcpu(env); CPUState *cs =3D env_cpu(env); - TaskState *ts =3D cs->opaque; + TaskState *ts =3D get_task_state(cs); struct image_info *info =3D ts->info; int i; =20 diff --git a/linux-user/arm/cpu_loop.c b/linux-user/arm/cpu_loop.c index b404117ff30..db1a41e27f4 100644 --- a/linux-user/arm/cpu_loop.c +++ b/linux-user/arm/cpu_loop.c @@ -263,7 +263,7 @@ static bool insn_is_linux_bkpt(uint32_t opcode, bool is= _thumb) =20 static bool emulate_arm_fpa11(CPUARMState *env, uint32_t opcode) { - TaskState *ts =3D env_cpu(env)->opaque; + TaskState *ts =3D get_task_state(env_cpu(env)); int rc =3D EmulateAll(opcode, &ts->fpa, env); int raise, enabled; =20 @@ -514,7 +514,7 @@ void cpu_loop(CPUARMState *env) void target_cpu_copy_regs(CPUArchState *env, struct target_pt_regs *regs) { CPUState *cpu =3D env_cpu(env); - TaskState *ts =3D cpu->opaque; + TaskState *ts =3D get_task_state(cpu); struct image_info *info =3D ts->info; int i; =20 diff --git a/linux-user/arm/signal.c b/linux-user/arm/signal.c index f77f692c63f..59806335f5b 100644 --- a/linux-user/arm/signal.c +++ b/linux-user/arm/signal.c @@ -177,7 +177,7 @@ setup_return(CPUARMState *env, struct target_sigaction = *ka, int usig, abi_ulong handler =3D 0; abi_ulong handler_fdpic_GOT =3D 0; abi_ulong retcode; - bool is_fdpic =3D info_is_fdpic(((TaskState *)thread_cpu->opaque)->inf= o); + bool is_fdpic =3D info_is_fdpic(get_task_state(thread_cpu)->info); bool is_rt =3D ka->sa_flags & TARGET_SA_SIGINFO; bool thumb; =20 diff --git a/linux-user/cris/cpu_loop.c b/linux-user/cris/cpu_loop.c index 01e6ff16fc9..04c9086b6dc 100644 --- a/linux-user/cris/cpu_loop.c +++ b/linux-user/cris/cpu_loop.c @@ -72,7 +72,7 @@ void cpu_loop(CPUCRISState *env) void target_cpu_copy_regs(CPUArchState *env, struct target_pt_regs *regs) { CPUState *cpu =3D env_cpu(env); - TaskState *ts =3D cpu->opaque; + TaskState *ts =3D get_task_state(cpu); struct image_info *info =3D ts->info; =20 env->regs[0] =3D regs->r0; diff --git a/linux-user/elfload.c b/linux-user/elfload.c index 0c299a7c15e..4dbca056461 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -4404,7 +4404,7 @@ static int wmr_write_region(void *opaque, target_ulon= g start, static int elf_core_dump(int signr, const CPUArchState *env) { const CPUState *cpu =3D env_cpu((CPUArchState *)env); - const TaskState *ts =3D (const TaskState *)cpu->opaque; + const TaskState *ts =3D (const TaskState *)get_task_state((CPUState *)= cpu); struct rlimit dumpsize; CountAndSizeRegions css; off_t offset, note_offset, data_offset; diff --git a/linux-user/hppa/signal.c b/linux-user/hppa/signal.c index d08a97dae61..c84557e906a 100644 --- a/linux-user/hppa/signal.c +++ b/linux-user/hppa/signal.c @@ -112,7 +112,7 @@ void setup_rt_frame(int sig, struct target_sigaction *k= a, abi_ulong frame_addr, sp, haddr; struct target_rt_sigframe *frame; int i; - TaskState *ts =3D (TaskState *)thread_cpu->opaque; + TaskState *ts =3D get_task_state(thread_cpu); =20 sp =3D get_sp_from_cpustate(env); if ((ka->sa_flags & TARGET_SA_ONSTACK) && !sas_ss_flags(sp)) { diff --git a/linux-user/linuxload.c b/linux-user/linuxload.c index 4a794f8cea1..37f132be4af 100644 --- a/linux-user/linuxload.c +++ b/linux-user/linuxload.c @@ -89,7 +89,7 @@ static int prepare_binprm(struct linux_binprm *bprm) abi_ulong loader_build_argptr(int envc, int argc, abi_ulong sp, abi_ulong stringp, int push_ptr) { - TaskState *ts =3D (TaskState *)thread_cpu->opaque; + TaskState *ts =3D get_task_state(thread_cpu); int n =3D sizeof(abi_ulong); abi_ulong envp; abi_ulong argv; diff --git a/linux-user/m68k/cpu_loop.c b/linux-user/m68k/cpu_loop.c index caead1cb741..f79b8e4ab05 100644 --- a/linux-user/m68k/cpu_loop.c +++ b/linux-user/m68k/cpu_loop.c @@ -95,7 +95,7 @@ void cpu_loop(CPUM68KState *env) void target_cpu_copy_regs(CPUArchState *env, struct target_pt_regs *regs) { CPUState *cpu =3D env_cpu(env); - TaskState *ts =3D cpu->opaque; + TaskState *ts =3D get_task_state(cpu); struct image_info *info =3D ts->info; =20 env->pc =3D regs->pc; diff --git a/linux-user/mips/cpu_loop.c b/linux-user/mips/cpu_loop.c index 990b03e727b..462387a0737 100644 --- a/linux-user/mips/cpu_loop.c +++ b/linux-user/mips/cpu_loop.c @@ -214,7 +214,7 @@ done_syscall: void target_cpu_copy_regs(CPUArchState *env, struct target_pt_regs *regs) { CPUState *cpu =3D env_cpu(env); - TaskState *ts =3D cpu->opaque; + TaskState *ts =3D get_task_state(cpu); struct image_info *info =3D ts->info; int i; =20 diff --git a/linux-user/ppc/signal.c b/linux-user/ppc/signal.c index 7e7302823b0..c232424c1e8 100644 --- a/linux-user/ppc/signal.c +++ b/linux-user/ppc/signal.c @@ -486,7 +486,7 @@ void setup_rt_frame(int sig, struct target_sigaction *k= a, int i, err =3D 0; #if defined(TARGET_PPC64) struct target_sigcontext *sc =3D 0; - struct image_info *image =3D ((TaskState *)thread_cpu->opaque)->info; + struct image_info *image =3D get_task_state(thread_cpu)->info; #endif =20 rt_sf_addr =3D get_sigframe(ka, env, sizeof(*rt_sf)); @@ -673,7 +673,7 @@ abi_long do_swapcontext(CPUArchState *env, abi_ulong uo= ld_ctx, } =20 if (uold_ctx) { - TaskState *ts =3D (TaskState *)thread_cpu->opaque; + TaskState *ts =3D get_task_state(thread_cpu); =20 if (!lock_user_struct(VERIFY_WRITE, uctx, uold_ctx, 1)) { return -TARGET_EFAULT; diff --git a/linux-user/riscv/cpu_loop.c b/linux-user/riscv/cpu_loop.c index bffca7db127..52c49c2e426 100644 --- a/linux-user/riscv/cpu_loop.c +++ b/linux-user/riscv/cpu_loop.c @@ -97,7 +97,7 @@ void cpu_loop(CPURISCVState *env) void target_cpu_copy_regs(CPUArchState *env, struct target_pt_regs *regs) { CPUState *cpu =3D env_cpu(env); - TaskState *ts =3D cpu->opaque; + TaskState *ts =3D get_task_state(cpu); struct image_info *info =3D ts->info; =20 env->pc =3D regs->sepc; diff --git a/linux-user/signal.c b/linux-user/signal.c index d3e62ab030f..cc7dd78e41f 100644 --- a/linux-user/signal.c +++ b/linux-user/signal.c @@ -172,7 +172,7 @@ void target_to_host_old_sigset(sigset_t *sigset, =20 int block_signals(void) { - TaskState *ts =3D (TaskState *)thread_cpu->opaque; + TaskState *ts =3D get_task_state(thread_cpu); sigset_t set; =20 /* It's OK to block everything including SIGSEGV, because we won't @@ -194,7 +194,7 @@ int block_signals(void) */ int do_sigprocmask(int how, const sigset_t *set, sigset_t *oldset) { - TaskState *ts =3D (TaskState *)thread_cpu->opaque; + TaskState *ts =3D get_task_state(thread_cpu); =20 if (oldset) { *oldset =3D ts->signal_mask; @@ -237,7 +237,7 @@ int do_sigprocmask(int how, const sigset_t *set, sigset= _t *oldset) */ void set_sigmask(const sigset_t *set) { - TaskState *ts =3D (TaskState *)thread_cpu->opaque; + TaskState *ts =3D get_task_state(thread_cpu); =20 ts->signal_mask =3D *set; } @@ -246,7 +246,7 @@ void set_sigmask(const sigset_t *set) =20 int on_sig_stack(unsigned long sp) { - TaskState *ts =3D (TaskState *)thread_cpu->opaque; + TaskState *ts =3D get_task_state(thread_cpu); =20 return (sp - ts->sigaltstack_used.ss_sp < ts->sigaltstack_used.ss_size); @@ -254,7 +254,7 @@ int on_sig_stack(unsigned long sp) =20 int sas_ss_flags(unsigned long sp) { - TaskState *ts =3D (TaskState *)thread_cpu->opaque; + TaskState *ts =3D get_task_state(thread_cpu); =20 return (ts->sigaltstack_used.ss_size =3D=3D 0 ? SS_DISABLE : on_sig_stack(sp) ? SS_ONSTACK : 0); @@ -265,7 +265,7 @@ abi_ulong target_sigsp(abi_ulong sp, struct target_siga= ction *ka) /* * This is the X/Open sanctioned signal stack switching. */ - TaskState *ts =3D (TaskState *)thread_cpu->opaque; + TaskState *ts =3D get_task_state(thread_cpu); =20 if ((ka->sa_flags & TARGET_SA_ONSTACK) && !sas_ss_flags(sp)) { return ts->sigaltstack_used.ss_sp + ts->sigaltstack_used.ss_size; @@ -275,7 +275,7 @@ abi_ulong target_sigsp(abi_ulong sp, struct target_siga= ction *ka) =20 void target_save_altstack(target_stack_t *uss, CPUArchState *env) { - TaskState *ts =3D (TaskState *)thread_cpu->opaque; + TaskState *ts =3D get_task_state(thread_cpu); =20 __put_user(ts->sigaltstack_used.ss_sp, &uss->ss_sp); __put_user(sas_ss_flags(get_sp_from_cpustate(env)), &uss->ss_flags); @@ -284,7 +284,7 @@ void target_save_altstack(target_stack_t *uss, CPUArchS= tate *env) =20 abi_long target_restore_altstack(target_stack_t *uss, CPUArchState *env) { - TaskState *ts =3D (TaskState *)thread_cpu->opaque; + TaskState *ts =3D get_task_state(thread_cpu); size_t minstacksize =3D TARGET_MINSIGSTKSZ; target_stack_t ss; =20 @@ -571,7 +571,7 @@ static void signal_table_init(void) =20 void signal_init(void) { - TaskState *ts =3D (TaskState *)thread_cpu->opaque; + TaskState *ts =3D get_task_state(thread_cpu); struct sigaction act, oact; =20 /* initialize signal conversion tables */ @@ -730,7 +730,7 @@ static G_NORETURN void dump_core_and_abort(CPUArchState *env, int target_sig) { CPUState *cpu =3D env_cpu(env); - TaskState *ts =3D (TaskState *)cpu->opaque; + TaskState *ts =3D get_task_state(cpu); int host_sig, core_dumped =3D 0; =20 /* On exit, undo the remapping of SIGABRT. */ @@ -769,7 +769,7 @@ void queue_signal(CPUArchState *env, int sig, int si_ty= pe, target_siginfo_t *info) { CPUState *cpu =3D env_cpu(env); - TaskState *ts =3D cpu->opaque; + TaskState *ts =3D get_task_state(cpu); =20 trace_user_queue_signal(env, sig); =20 @@ -954,7 +954,7 @@ static void host_signal_handler(int host_sig, siginfo_t= *info, void *puc) { CPUState *cpu =3D thread_cpu; CPUArchState *env =3D cpu_env(cpu); - TaskState *ts =3D cpu->opaque; + TaskState *ts =3D get_task_state(cpu); target_siginfo_t tinfo; host_sigcontext *uc =3D puc; struct emulated_sigtable *k; @@ -1174,7 +1174,7 @@ static void handle_pending_signal(CPUArchState *cpu_e= nv, int sig, sigset_t set; target_sigset_t target_old_set; struct target_sigaction *sa; - TaskState *ts =3D cpu->opaque; + TaskState *ts =3D get_task_state(cpu); =20 trace_user_handle_signal(cpu_env, sig); /* dequeue signal */ @@ -1256,7 +1256,7 @@ void process_pending_signals(CPUArchState *cpu_env) { CPUState *cpu =3D env_cpu(cpu_env); int sig; - TaskState *ts =3D cpu->opaque; + TaskState *ts =3D get_task_state(cpu); sigset_t set; sigset_t *blocked_set; =20 @@ -1316,7 +1316,7 @@ void process_pending_signals(CPUArchState *cpu_env) int process_sigsuspend_mask(sigset_t **pset, target_ulong sigset, target_ulong sigsize) { - TaskState *ts =3D (TaskState *)thread_cpu->opaque; + TaskState *ts =3D get_task_state(thread_cpu); sigset_t *host_set =3D &ts->sigsuspend_mask; target_sigset_t *target_sigset; =20 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index bc8c06522f8..c233d4eb30a 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -6515,7 +6515,7 @@ static void *clone_func(void *arg) env =3D info->env; cpu =3D env_cpu(env); thread_cpu =3D cpu; - ts =3D (TaskState *)cpu->opaque; + ts =3D get_task_state(cpu); info->tid =3D sys_gettid(); task_settid(ts); if (info->child_tidptr) @@ -6557,7 +6557,7 @@ static int do_fork(CPUArchState *env, unsigned int fl= ags, abi_ulong newsp, flags &=3D ~(CLONE_VFORK | CLONE_VM); =20 if (flags & CLONE_VM) { - TaskState *parent_ts =3D (TaskState *)cpu->opaque; + TaskState *parent_ts =3D get_task_state(cpu); new_thread_info info; pthread_attr_t attr; =20 @@ -6680,7 +6680,7 @@ static int do_fork(CPUArchState *env, unsigned int fl= ags, abi_ulong newsp, put_user_u32(sys_gettid(), child_tidptr); if (flags & CLONE_PARENT_SETTID) put_user_u32(sys_gettid(), parent_tidptr); - ts =3D (TaskState *)cpu->opaque; + ts =3D get_task_state(cpu); if (flags & CLONE_SETTLS) cpu_set_tls (env, newtls); if (flags & CLONE_CHILD_CLEARTID) @@ -7946,7 +7946,7 @@ int host_to_target_waitstatus(int status) static int open_self_cmdline(CPUArchState *cpu_env, int fd) { CPUState *cpu =3D env_cpu(cpu_env); - struct linux_binprm *bprm =3D ((TaskState *)cpu->opaque)->bprm; + struct linux_binprm *bprm =3D get_task_state(cpu)->bprm; int i; =20 for (i =3D 0; i < bprm->argc; i++) { @@ -8146,7 +8146,7 @@ static int open_self_smaps(CPUArchState *cpu_env, int= fd) static int open_self_stat(CPUArchState *cpu_env, int fd) { CPUState *cpu =3D env_cpu(cpu_env); - TaskState *ts =3D cpu->opaque; + TaskState *ts =3D get_task_state(cpu); g_autoptr(GString) buf =3D g_string_new(NULL); int i; =20 @@ -8187,7 +8187,7 @@ static int open_self_stat(CPUArchState *cpu_env, int = fd) static int open_self_auxv(CPUArchState *cpu_env, int fd) { CPUState *cpu =3D env_cpu(cpu_env); - TaskState *ts =3D cpu->opaque; + TaskState *ts =3D get_task_state(cpu); abi_ulong auxv =3D ts->info->saved_auxv; abi_ulong len =3D ts->info->auxv_len; char *ptr; @@ -9012,7 +9012,7 @@ static abi_long do_syscall1(CPUArchState *cpu_env, in= t num, abi_long arg1, pthread_mutex_lock(&clone_lock); =20 if (CPU_NEXT(first_cpu)) { - TaskState *ts =3D cpu->opaque; + TaskState *ts =3D get_task_state(cpu); =20 if (ts->child_tidptr) { put_user_u32(0, ts->child_tidptr); @@ -9439,7 +9439,7 @@ static abi_long do_syscall1(CPUArchState *cpu_env, in= t num, abi_long arg1, #ifdef TARGET_NR_pause /* not on alpha */ case TARGET_NR_pause: if (!block_signals()) { - sigsuspend(&((TaskState *)cpu->opaque)->signal_mask); + sigsuspend(&get_task_state(cpu)->signal_mask); } return -TARGET_EINTR; #endif @@ -10005,7 +10005,7 @@ static abi_long do_syscall1(CPUArchState *cpu_env, = int num, abi_long arg1, sigset_t *set; =20 #if defined(TARGET_ALPHA) - TaskState *ts =3D cpu->opaque; + TaskState *ts =3D get_task_state(cpu); /* target_to_host_old_sigset will bswap back */ abi_ulong mask =3D tswapal(arg1); set =3D &ts->sigsuspend_mask; @@ -10406,7 +10406,7 @@ static abi_long do_syscall1(CPUArchState *cpu_env, = int num, abi_long arg1, case TARGET_NR_mprotect: arg1 =3D cpu_untagged_addr(cpu, arg1); { - TaskState *ts =3D cpu->opaque; + TaskState *ts =3D get_task_state(cpu); /* Special hack to detect libc making the stack executable. */ if ((arg3 & PROT_GROWSDOWN) && arg1 >=3D ts->info->stack_limit @@ -12537,7 +12537,7 @@ static abi_long do_syscall1(CPUArchState *cpu_env, = int num, abi_long arg1, return do_set_thread_area(cpu_env, arg1); #elif defined(TARGET_M68K) { - TaskState *ts =3D cpu->opaque; + TaskState *ts =3D get_task_state(cpu); ts->tp_value =3D arg1; return 0; } @@ -12551,7 +12551,7 @@ static abi_long do_syscall1(CPUArchState *cpu_env, = int num, abi_long arg1, return do_get_thread_area(cpu_env, arg1); #elif defined(TARGET_M68K) { - TaskState *ts =3D cpu->opaque; + TaskState *ts =3D get_task_state(cpu); return ts->tp_value; } #else @@ -12676,7 +12676,7 @@ static abi_long do_syscall1(CPUArchState *cpu_env, = int num, abi_long arg1, #if defined(TARGET_NR_set_tid_address) case TARGET_NR_set_tid_address: { - TaskState *ts =3D cpu->opaque; + TaskState *ts =3D get_task_state(cpu); ts->child_tidptr =3D arg1; /* do not call host set_tid_address() syscall, instead return tid(= ) */ return get_errno(sys_gettid()); diff --git a/linux-user/vm86.c b/linux-user/vm86.c index c2facf3fc2d..9f512a2242b 100644 --- a/linux-user/vm86.c +++ b/linux-user/vm86.c @@ -74,7 +74,7 @@ static inline unsigned int vm_getl(CPUX86State *env, void save_v86_state(CPUX86State *env) { CPUState *cs =3D env_cpu(env); - TaskState *ts =3D cs->opaque; + TaskState *ts =3D get_task_state(cs); struct target_vm86plus_struct * target_v86; =20 if (!lock_user_struct(VERIFY_WRITE, target_v86, ts->target_v86, 0)) @@ -134,7 +134,7 @@ static inline void return_to_32bit(CPUX86State *env, in= t retval) static inline int set_IF(CPUX86State *env) { CPUState *cs =3D env_cpu(env); - TaskState *ts =3D cs->opaque; + TaskState *ts =3D get_task_state(cs); =20 ts->v86flags |=3D VIF_MASK; if (ts->v86flags & VIP_MASK) { @@ -147,7 +147,7 @@ static inline int set_IF(CPUX86State *env) static inline void clear_IF(CPUX86State *env) { CPUState *cs =3D env_cpu(env); - TaskState *ts =3D cs->opaque; + TaskState *ts =3D get_task_state(cs); =20 ts->v86flags &=3D ~VIF_MASK; } @@ -165,7 +165,7 @@ static inline void clear_AC(CPUX86State *env) static inline int set_vflags_long(unsigned long eflags, CPUX86State *env) { CPUState *cs =3D env_cpu(env); - TaskState *ts =3D cs->opaque; + TaskState *ts =3D get_task_state(cs); =20 set_flags(ts->v86flags, eflags, ts->v86mask); set_flags(env->eflags, eflags, SAFE_MASK); @@ -179,7 +179,7 @@ static inline int set_vflags_long(unsigned long eflags,= CPUX86State *env) static inline int set_vflags_short(unsigned short flags, CPUX86State *env) { CPUState *cs =3D env_cpu(env); - TaskState *ts =3D cs->opaque; + TaskState *ts =3D get_task_state(cs); =20 set_flags(ts->v86flags, flags, ts->v86mask & 0xffff); set_flags(env->eflags, flags, SAFE_MASK); @@ -193,7 +193,7 @@ static inline int set_vflags_short(unsigned short flags= , CPUX86State *env) static inline unsigned int get_vflags(CPUX86State *env) { CPUState *cs =3D env_cpu(env); - TaskState *ts =3D cs->opaque; + TaskState *ts =3D get_task_state(cs); unsigned int flags; =20 flags =3D env->eflags & RETURN_MASK; @@ -210,7 +210,7 @@ static inline unsigned int get_vflags(CPUX86State *env) static void do_int(CPUX86State *env, int intno) { CPUState *cs =3D env_cpu(env); - TaskState *ts =3D cs->opaque; + TaskState *ts =3D get_task_state(cs); uint32_t int_addr, segoffs, ssp; unsigned int sp; =20 @@ -269,7 +269,7 @@ void handle_vm86_trap(CPUX86State *env, int trapno) void handle_vm86_fault(CPUX86State *env) { CPUState *cs =3D env_cpu(env); - TaskState *ts =3D cs->opaque; + TaskState *ts =3D get_task_state(cs); uint32_t csp, ssp; unsigned int ip, sp, newflags, newip, newcs, opcode, intno; int data32, pref_done; @@ -394,7 +394,7 @@ void handle_vm86_fault(CPUX86State *env) int do_vm86(CPUX86State *env, long subfunction, abi_ulong vm86_addr) { CPUState *cs =3D env_cpu(env); - TaskState *ts =3D cs->opaque; + TaskState *ts =3D get_task_state(cs); struct target_vm86plus_struct * target_v86; int ret; =20 diff --git a/linux-user/xtensa/signal.c b/linux-user/xtensa/signal.c index 32dcfa52291..003208a9161 100644 --- a/linux-user/xtensa/signal.c +++ b/linux-user/xtensa/signal.c @@ -157,7 +157,7 @@ void setup_rt_frame(int sig, struct target_sigaction *k= a, { abi_ulong frame_addr; struct target_rt_sigframe *frame; - int is_fdpic =3D info_is_fdpic(((TaskState *)thread_cpu->opaque)->info= ); + int is_fdpic =3D info_is_fdpic(get_task_state(thread_cpu)->info); abi_ulong handler =3D 0; abi_ulong handler_fdpic_GOT =3D 0; uint32_t ra; diff --git a/plugins/api.c b/plugins/api.c index 81f43c9ce8a..e905e995bd6 100644 --- a/plugins/api.c +++ b/plugins/api.c @@ -378,7 +378,7 @@ const char *qemu_plugin_path_to_binary(void) { char *path =3D NULL; #ifdef CONFIG_USER_ONLY - TaskState *ts =3D (TaskState *) current_cpu->opaque; + TaskState *ts =3D get_task_state(current_cpu); path =3D g_strdup(ts->bprm->filename); #endif return path; @@ -388,7 +388,7 @@ uint64_t qemu_plugin_start_code(void) { uint64_t start =3D 0; #ifdef CONFIG_USER_ONLY - TaskState *ts =3D (TaskState *) current_cpu->opaque; + TaskState *ts =3D get_task_state(current_cpu); start =3D ts->info->start_code; #endif return start; @@ -398,7 +398,7 @@ uint64_t qemu_plugin_end_code(void) { uint64_t end =3D 0; #ifdef CONFIG_USER_ONLY - TaskState *ts =3D (TaskState *) current_cpu->opaque; + TaskState *ts =3D get_task_state(current_cpu); end =3D ts->info->end_code; #endif return end; @@ -408,7 +408,7 @@ uint64_t qemu_plugin_entry_code(void) { uint64_t entry =3D 0; #ifdef CONFIG_USER_ONLY - TaskState *ts =3D (TaskState *) current_cpu->opaque; + TaskState *ts =3D get_task_state(current_cpu); entry =3D ts->info->entry; #endif return entry; diff --git a/semihosting/arm-compat-semi.c b/semihosting/arm-compat-semi.c index 329ea112607..d78c6428b90 100644 --- a/semihosting/arm-compat-semi.c +++ b/semihosting/arm-compat-semi.c @@ -214,7 +214,7 @@ static target_ulong syscall_err; static inline uint32_t get_swi_errno(CPUState *cs) { #ifdef CONFIG_USER_ONLY - TaskState *ts =3D cs->opaque; + TaskState *ts =3D get_task_state(cs); =20 return ts->swi_errno; #else @@ -226,7 +226,7 @@ static void common_semi_cb(CPUState *cs, uint64_t ret, = int err) { if (err) { #ifdef CONFIG_USER_ONLY - TaskState *ts =3D cs->opaque; + TaskState *ts =3D get_task_state(cs); ts->swi_errno =3D err; #else syscall_err =3D err; @@ -586,7 +586,7 @@ void do_common_semihosting(CPUState *cs) #if !defined(CONFIG_USER_ONLY) const char *cmdline; #else - TaskState *ts =3D cs->opaque; + TaskState *ts =3D get_task_state(cs); #endif GET_ARG(0); GET_ARG(1); @@ -664,7 +664,7 @@ void do_common_semihosting(CPUState *cs) target_ulong retvals[4]; int i; #ifdef CONFIG_USER_ONLY - TaskState *ts =3D cs->opaque; + TaskState *ts =3D get_task_state(cs); target_ulong limit; #else LayoutInfo info =3D common_semi_find_bases(cs); --=20 2.39.2 From nobody Tue Nov 26 04:50:36 2024 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=1709640694; cv=none; d=zohomail.com; s=zohoarc; b=C1n4QpeBMprXPGG6TCc6LzSHnW2uzckr6SZKStQYGJZJowSkzolB26FQwB+fJEf23bE6obvRa3CmnSH79B4I0QqPlX8C7JNbgFIn5L3evyFKyuqMLU9Y8nE3IK5z/YZEa8M5S0mf2HnmesTvcpCnMha1vdqlltJV7LVNFKJbioY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709640694; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=9H0BMxEgsfnIN4tKkXQ7XYD/lXb/KI0pXeZKCUMOmAM=; b=EAfE/SNX2tmidlGVquMjeHxQFAT5FhfKNDR4EdgvZUBuWtvj69/zQ84TFOTaW6QAbiqkdV1ZHoKInZ2HzY5ziQzRc1lt3WJngOwfXJWtyBDvF3LyH1FiJ3uEcDMwvkz/jnDKTVZXdvFPpCcgRwe5i0vCVEtb4ZLfemyklZ/voj4= 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 1709640694070761.428381021856; Tue, 5 Mar 2024 04:11:34 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rhTch-0001We-SH; Tue, 05 Mar 2024 07:10:19 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rhTcb-0001TB-O1 for qemu-devel@nongnu.org; Tue, 05 Mar 2024 07:10:14 -0500 Received: from mail-wm1-x32b.google.com ([2a00:1450:4864:20::32b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rhTcZ-0001CH-10 for qemu-devel@nongnu.org; Tue, 05 Mar 2024 07:10:13 -0500 Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-412e92deb18so9313395e9.1 for ; Tue, 05 Mar 2024 04:10:09 -0800 (PST) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id h3-20020adfa4c3000000b0033dd2a7167fsm14970270wrb.29.2024.03.05.04.10.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Mar 2024 04:10:08 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id DC55A5F954; Tue, 5 Mar 2024 12:10:05 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1709640609; x=1710245409; 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=9H0BMxEgsfnIN4tKkXQ7XYD/lXb/KI0pXeZKCUMOmAM=; b=D9I5h71KchVGxSNvPNAFdg4kSMww74Nr7tIyWcbu/hxQZRTWSpaWLZlw2c5ZRowuqm q3SjJOeG0MhNH8zdBTtPrsWWCB5uJBPS6WHJqusVvDghR8In+GiIj8v6R7WsLuhBGOQ1 iRqUP4gukkT7UzG2t5kydDdEudD2cSVwH0ocBbgzAVITv3ZOiAUHrz98PV5zfbm2IAwJ ybgOWDS3UY7AYcwXtBKedcqF/KWoAYG7UZDHjr1qv0j5gFc8JtlvUk+Eajixj4Q2pdPz YDGW4UyUlJVQ3WZ5xZpJ4UzJZAjjoEVqhqUvKhO+mT/i2S5TnIx8MAxDbPsO/ZHH9g6L HX8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709640609; x=1710245409; 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=9H0BMxEgsfnIN4tKkXQ7XYD/lXb/KI0pXeZKCUMOmAM=; b=HwtZQHY4srJ2j+I9L06QOHjLlsGaDrPzlAwArCPIv0jxZTHduEkbjswiwxVdQqRGZS us7VS2ICq5HxnpeHyHtNB6HmCENeXrxUa9y7hdwJE+qCm+FidjV7e+3vhytyprbn1Ogy /uNhJ7LQcZfZvWx30mHikiGnnP629M6YrIS/hI3LHQuTeTiBJQ3EVZI34rrd+l/vy3Qr RpoXCeqT45mXiqSC3aUg85Sp+Q1RMlWfnI7CzqYzw7FM7q/FLcAiy65DQcsWsWkeGflU wjaY9MfKhMX9hJJihLzbjDlNAh7OAWRv3HhiMTDCvDKl6WS3nOv5sbRoLwW+YbaPt1ik e6mA== X-Gm-Message-State: AOJu0Yw6XbeA+6DwP6JcdHClFlzfmgrZ1q/MNe6d7ER6i6tff/fuN+EP lqnKmlgJ1030K04y4DCbrDXpk3vo+CFVgsbcGhZoTNLqT08lcm0La8y6xyh1sss= X-Google-Smtp-Source: AGHT+IGeU37dEB9VMX1i10U5L657uyrlThfe3V68/Dnvly41cIxf2sIZkoM4cHEMD1mOp4S6icF9MQ== X-Received: by 2002:a5d:674b:0:b0:33d:82a9:206e with SMTP id l11-20020a5d674b000000b0033d82a9206emr8033114wrw.28.1709640608641; Tue, 05 Mar 2024 04:10:08 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Wainer dos Santos Moschetta , Alistair Francis , Nicholas Piggin , Liu Zhiwei , Richard Henderson , Yanan Wang , qemu-s390x@nongnu.org, "Edgar E. Iglesias" , Eduardo Habkost , Daniel Henrique Barboza , Michael Rolnik , Daniel Henrique Barboza , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Laurent Vivier , Yoshinori Sato , Laurent Vivier , Thomas Huth , Peter Maydell , Mahmoud Mandour , Brad Smith , Alistair Francis , Brian Cain , Cleber Rosa , John Snow , Marcel Apfelbaum , Pierrick Bouvier , Palmer Dabbelt , Riku Voipio , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, Weiwei Li , Bin Meng , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Beraldo Leal , Kyle Evans , David Hildenbrand , Song Gao , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Paolo Bonzini , Alexandre Iooss , Warner Losh , qemu-riscv@nongnu.org, Ilya Leoshkevich Subject: [PATCH 04/29] {linux,bsd}-user: Update ts_tid after fork() Date: Tue, 5 Mar 2024 12:09:40 +0000 Message-Id: <20240305121005.3528075-5-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240305121005.3528075-1-alex.bennee@linaro.org> References: <20240305121005.3528075-1-alex.bennee@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::32b; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x32b.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-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: 1709640695705100003 From: Ilya Leoshkevich Currently ts_tid contains the parent tid after fork(), which is not correct. So far it has not affected anything, but the upcoming follow-fork-mode child support relies on the correct value, so fix it. Reviewed-by: Alex Benn=C3=A9e Signed-off-by: Ilya Leoshkevich Reviewed-by: Warner Losh Message-Id: <20240219141628.246823-4-iii@linux.ibm.com> Signed-off-by: Alex Benn=C3=A9e Reviewed-by: Richard Henderson --- bsd-user/main.c | 1 + linux-user/main.c | 1 + 2 files changed, 2 insertions(+) diff --git a/bsd-user/main.c b/bsd-user/main.c index 512d4ab69fc..e39eef3040f 100644 --- a/bsd-user/main.c +++ b/bsd-user/main.c @@ -134,6 +134,7 @@ void fork_end(int child) * state, so we don't need to end_exclusive() here. */ qemu_init_cpu_list(); + get_task_state(thread_cpu)->ts_tid =3D qemu_get_thread_id(); gdbserver_fork(thread_cpu); } else { mmap_fork_end(child); diff --git a/linux-user/main.c b/linux-user/main.c index 551acf16619..699da773714 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -161,6 +161,7 @@ void fork_end(int child) } } qemu_init_cpu_list(); + get_task_state(thread_cpu)->ts_tid =3D qemu_get_thread_id(); gdbserver_fork(thread_cpu); } else { cpu_list_unlock(); --=20 2.39.2 From nobody Tue Nov 26 04:50:36 2024 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=1709640667; cv=none; d=zohomail.com; s=zohoarc; b=dK/BFzl7A2v9jI8oxWpFBfqUQMxEew16ZFSJIsZhC1TrKlzJsMdLHbKhykyRR61KeeD61TxHYeYg5qDKe/W/cxIrzeH9BlfAcvhuyp+lw3s4wk5MVN9MsdY9Q2xiWO5eXw+k7lD22H/8CyvimaHgTYXpOYLf4/DaHJ754TkSkv8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709640667; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=eXVZ712kv8O0GudxyxBx9w6g4YMMrljfTMdLsClf+YA=; b=WjEoMqkBTItu1DkyJks8UeaWvSXeJXXfs4mQQinY8poFDjGGPP0icDT7SN8KO6SqEdRXh2dYtCRYBsvQR0t1n5N6mnO0SevenIfnvD8LUR5o86SOq4Jw2Ys3/4o/T9nWSvetMGzvwav/Le7muhwLh34WPW7/shY3+pX6i/t3jpI= 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 1709640667737357.1351193255538; Tue, 5 Mar 2024 04:11:07 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rhTck-0001Yl-FP; Tue, 05 Mar 2024 07:10:24 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rhTce-0001Uo-TM for qemu-devel@nongnu.org; Tue, 05 Mar 2024 07:10:17 -0500 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 1rhTcZ-0001CO-24 for qemu-devel@nongnu.org; Tue, 05 Mar 2024 07:10:15 -0500 Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-412eb6e15ceso5331625e9.0 for ; Tue, 05 Mar 2024 04:10:09 -0800 (PST) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id a12-20020a05600c348c00b00412ef5a0c78sm758146wmq.43.2024.03.05.04.10.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Mar 2024 04:10:08 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 009A65F956; Tue, 5 Mar 2024 12:10:06 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1709640609; x=1710245409; 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=eXVZ712kv8O0GudxyxBx9w6g4YMMrljfTMdLsClf+YA=; b=RcINmoG+xMHt9q/k+fAZ8LS0fjeBljWIr4vE7yejfzIcLiy4EDXIQWu4wgzso6JaAh uAzoj1QkErBlHgWww87wPtYbRcDPeD1MRqv4rpEpB5RoK7ZnzdpM+gXDlgOakkDE1cRT rx1bADQs0UgF1g7X/gwT2rMNpLqJiOqRA/ZTIjBiLqmJnXabyacRneeGw3CW3EE40dLi 71GsG4u5izvSbkCcKiRCm7hRcYPf7Ha0CYnTBtWjqB0WTXM9iCmdaUUGLoo0kyjzPsQI si8Q+9oRIi+awF2dS1CZ82ueE9d0nCNLSTyHUXUP3zR/o3Egj0LwkAMzegaV0p4c4kRQ JfvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709640609; x=1710245409; 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=eXVZ712kv8O0GudxyxBx9w6g4YMMrljfTMdLsClf+YA=; b=itms4X9ZxrfW+S+rD4LDp1HI2ECcGnU5v9TG3jMU/sAAunjkmoB3hLOPzqW4V2cy4t H8Dj0AWcsmr7N06fRsKgW5lLYvQ+MIRuwa/MZp/Qih9z3NqKoj8+NF7US41b6Gq4gGmI EVDATVn/pbhwFx6IZBCGmvsvvp4TApuL/TKwoY2TIxHIi+VrFLp8sJVf+pTaemG8dY/G Cmmt5NfIB65JAJX9tYak+6juITTVtOlAokSMHIuiqiRnrQZOq9ut3ZeiU/hM/GKBa45e ZMzUeGGFDx5doSwC90FeLHiXUO66icgHLF/6vDkgn6Z83eFDxUko9sOQwXFUdBEozsAg M+TA== X-Gm-Message-State: AOJu0Ywx/Bad/IhSWGxKgzQtOZnSQqkm0EbQEhEnmQzzE7rh4XIgL65T CX9dTr2zHsN68EsvLwvhE8cx0numrH2dveuONrV8msFM3BqBTVa6N1PmP/gPD0M= X-Google-Smtp-Source: AGHT+IHQ4i0dFCyKCBlBz10LPdPw3naUXzQQwwBcn89plaep75sEakGwaM/+QbeQmq87VPUT584+Ww== X-Received: by 2002:a05:600c:1da6:b0:412:e95f:51bb with SMTP id p38-20020a05600c1da600b00412e95f51bbmr1999744wms.32.1709640608816; Tue, 05 Mar 2024 04:10:08 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Wainer dos Santos Moschetta , Alistair Francis , Nicholas Piggin , Liu Zhiwei , Richard Henderson , Yanan Wang , qemu-s390x@nongnu.org, "Edgar E. Iglesias" , Eduardo Habkost , Daniel Henrique Barboza , Michael Rolnik , Daniel Henrique Barboza , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Laurent Vivier , Yoshinori Sato , Laurent Vivier , Thomas Huth , Peter Maydell , Mahmoud Mandour , Brad Smith , Alistair Francis , Brian Cain , Cleber Rosa , John Snow , Marcel Apfelbaum , Pierrick Bouvier , Palmer Dabbelt , Riku Voipio , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, Weiwei Li , Bin Meng , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Beraldo Leal , Kyle Evans , David Hildenbrand , Song Gao , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Paolo Bonzini , Alexandre Iooss , Warner Losh , qemu-riscv@nongnu.org, Ilya Leoshkevich Subject: [PATCH 05/29] gdbstub: Introduce gdbserver_fork_start() Date: Tue, 5 Mar 2024 12:09:41 +0000 Message-Id: <20240305121005.3528075-6-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240305121005.3528075-1-alex.bennee@linaro.org> References: <20240305121005.3528075-1-alex.bennee@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=alex.bennee@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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1709640669849100005 From: Ilya Leoshkevich The upcoming follow-fork-mode child support requires knowing when fork() is about to happen in order to initialize its state. Add a hook for that. Reviewed-by: Alex Benn=C3=A9e Signed-off-by: Ilya Leoshkevich Message-Id: <20240219141628.246823-5-iii@linux.ibm.com> Signed-off-by: Alex Benn=C3=A9e --- include/gdbstub/user.h | 5 +++++ bsd-user/main.c | 1 + gdbstub/user.c | 4 ++++ linux-user/main.c | 1 + 4 files changed, 11 insertions(+) diff --git a/include/gdbstub/user.h b/include/gdbstub/user.h index 68b6534130c..e33f8d9a9a6 100644 --- a/include/gdbstub/user.h +++ b/include/gdbstub/user.h @@ -45,6 +45,11 @@ static inline int gdb_handlesig(CPUState *cpu, int sig) */ void gdb_signalled(CPUArchState *as, int sig); =20 +/** + * gdbserver_fork_start() - inform gdb of the upcoming fork() + */ +void gdbserver_fork_start(void); + /** * gdbserver_fork() - disable gdb stub for child processes. * @cs: CPU diff --git a/bsd-user/main.c b/bsd-user/main.c index e39eef3040f..517c6b3ec2f 100644 --- a/bsd-user/main.c +++ b/bsd-user/main.c @@ -113,6 +113,7 @@ void fork_start(void) start_exclusive(); cpu_list_lock(); mmap_fork_start(); + gdbserver_fork_start(); } =20 void fork_end(int child) diff --git a/gdbstub/user.c b/gdbstub/user.c index 3ce20b7bbfc..536fb43b03e 100644 --- a/gdbstub/user.c +++ b/gdbstub/user.c @@ -356,6 +356,10 @@ int gdbserver_start(const char *port_or_path) return -1; } =20 +void gdbserver_fork_start(void) +{ +} + static void disable_gdbstub(CPUState *thread_cpu) { CPUState *cpu; diff --git a/linux-user/main.c b/linux-user/main.c index 699da773714..755c566d6d2 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -145,6 +145,7 @@ void fork_start(void) mmap_fork_start(); cpu_list_lock(); qemu_plugin_user_prefork_lock(); + gdbserver_fork_start(); } =20 void fork_end(int child) --=20 2.39.2 From nobody Tue Nov 26 04:50:37 2024 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=1709641113; cv=none; d=zohomail.com; s=zohoarc; b=FPKprk0b3vxztIWW8laMXhMlOY88DyclkwqRsUogIn9A04PA2P/H9+N0D20tQJ6/UiQfDq0MpsJdlVtKUfbF5vAUGJLfoBLvaz6QTBxewpWF0vZ8XM37XC11v0758RpAigAVHhUIT19nuMPCKlbjAzjcc1BhJKsTVf8JS6J13Do= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709641113; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=BXkKB6oKUyrrNS5PAFHEEy/nZhjQotVShPfjRJSJXXY=; b=Yxvxb251NNvhlwv0/BLyUUidVrhYBqYd95mRT6nIsBMTYkcbZog6oPyrAkq3pGqLVRB05A11E+OuWP+NFiDY5AbbZhbBNOG62GIM9nrDpJoLak4dgxisAQQ2HMcIz9hWYG8RkjFev1a/lEOLwQKdsQ8b0vwYscZ+hAWImRBLLs0= 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 1709641113765134.50387911351288; Tue, 5 Mar 2024 04:18:33 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rhTdg-0002dB-JI; Tue, 05 Mar 2024 07:11:20 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rhTcq-0001bG-Ht for qemu-devel@nongnu.org; Tue, 05 Mar 2024 07:10:30 -0500 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 1rhTcc-0001P0-QA for qemu-devel@nongnu.org; Tue, 05 Mar 2024 07:10:28 -0500 Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-412e6bdd454so12021035e9.1 for ; Tue, 05 Mar 2024 04:10:12 -0800 (PST) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id fa10-20020a05600c518a00b00412e17d5f83sm7151450wmb.14.2024.03.05.04.10.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Mar 2024 04:10:08 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 1A3755F958; Tue, 5 Mar 2024 12:10:06 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1709640612; x=1710245412; 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=BXkKB6oKUyrrNS5PAFHEEy/nZhjQotVShPfjRJSJXXY=; b=Cd0XR8YCyPXAwU7YhKdrMMPiB4LFjPYcIO/reS7phUVFI7RmFGi8QCr33diLWthxkP eDeTj6AYUBUeJB1f8P7ezCWi6VkRY1MwCeap3wybZek7jWCfbdVkK/udU8CiRFWxXDkq Yom+iQIxdyRLL4MQC0XXZoF4xzbQZX7CoIZffBCtK0JYS9715xO6zX3RE6WQKirvOqP+ bVLl4U+U0V2EyJOIE9d/y2SLC8kY0x+CV9Rgz3G1rTYIuYMrc+gQi0vDOsiUyL/NlWT5 wWlHc9z5SWfpCY+YRVghqokV77AvleMXMJS1UGvXMuXHBj+bQp4u1qDdqV9kky9tQtH9 OOSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709640612; x=1710245412; 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=BXkKB6oKUyrrNS5PAFHEEy/nZhjQotVShPfjRJSJXXY=; b=qLSJ0TS2bKOOot4N6KblqN15zGXUp7ooPvXGd57vAT6uXB7TvNg3vOrKcEja/s8UaQ uaeEogT08I9/7PR4I8KA2mFuQMZhVOx4zg7ijNVsQbzVHfEgm0M57pQH0w4i51Os2lqY 2TOreiTw9MDrEebfw1IUYgOoDPMXq11qPfEXXKfg5z3m85y6LwoHD9wtBPj2z7bM3/Wn PJMDr0fU6dzFYBaaxMqlSh6zLvq68cUBpOjP30UijGEc/n003E/E2nyvO1JlMmKnhzcY 32HBnm7SlCLg09eoepJwpBB6BalClnfuZyvl3P5uhIZa13vxhaXuD2ThlBX5kI/IOCew T4gw== X-Gm-Message-State: AOJu0Yykts20vowHiLJAnnlWkRhBq1cuQx35t6T+lpwhUjnpp8oIYUYL rk0eaju+0R/V1ivntcvgDZDotgCTavf7fokRkLN4vX0WgkHUPThKO85mSGm/VCk= X-Google-Smtp-Source: AGHT+IFihsx+QOfv8tfwnYUEolqlOO1XCnU8T0HLsKzH+rxO+pVVFFd6wvVuGPOcCe38TlOUvrZ8lQ== X-Received: by 2002:a05:600c:5249:b0:412:e59e:da2c with SMTP id fc9-20020a05600c524900b00412e59eda2cmr3295051wmb.37.1709640611931; Tue, 05 Mar 2024 04:10:11 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Wainer dos Santos Moschetta , Alistair Francis , Nicholas Piggin , Liu Zhiwei , Richard Henderson , Yanan Wang , qemu-s390x@nongnu.org, "Edgar E. Iglesias" , Eduardo Habkost , Daniel Henrique Barboza , Michael Rolnik , Daniel Henrique Barboza , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Laurent Vivier , Yoshinori Sato , Laurent Vivier , Thomas Huth , Peter Maydell , Mahmoud Mandour , Brad Smith , Alistair Francis , Brian Cain , Cleber Rosa , John Snow , Marcel Apfelbaum , Pierrick Bouvier , Palmer Dabbelt , Riku Voipio , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, Weiwei Li , Bin Meng , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Beraldo Leal , Kyle Evans , David Hildenbrand , Song Gao , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Paolo Bonzini , Alexandre Iooss , Warner Losh , qemu-riscv@nongnu.org, Ilya Leoshkevich Subject: [PATCH 06/29] {linux,bsd}-user: Pass pid to fork_end() Date: Tue, 5 Mar 2024 12:09:42 +0000 Message-Id: <20240305121005.3528075-7-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240305121005.3528075-1-alex.bennee@linaro.org> References: <20240305121005.3528075-1-alex.bennee@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::32a; envelope-from=alex.bennee@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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1709641115698100001 From: Ilya Leoshkevich The upcoming follow-fork-mode child support requires knowing the child pid. Pass it down. Reviewed-by: Alex Benn=C3=A9e Reviewed-by: Richard Henderson Signed-off-by: Ilya Leoshkevich Message-Id: <20240219141628.246823-6-iii@linux.ibm.com> Signed-off-by: Alex Benn=C3=A9e --- bsd-user/freebsd/os-proc.h | 6 +++--- bsd-user/qemu.h | 2 +- linux-user/user-internals.h | 2 +- bsd-user/main.c | 4 +++- linux-user/main.c | 4 +++- linux-user/syscall.c | 6 +++--- 6 files changed, 14 insertions(+), 10 deletions(-) diff --git a/bsd-user/freebsd/os-proc.h b/bsd-user/freebsd/os-proc.h index d6418780344..3003c8cb637 100644 --- a/bsd-user/freebsd/os-proc.h +++ b/bsd-user/freebsd/os-proc.h @@ -208,7 +208,7 @@ static inline abi_long do_freebsd_fork(void *cpu_env) */ set_second_rval(cpu_env, child_flag); =20 - fork_end(child_flag); + fork_end(ret); =20 return ret; } @@ -252,7 +252,7 @@ static inline abi_long do_freebsd_rfork(void *cpu_env, = abi_long flags) * value: 0 for parent process, 1 for child process. */ set_second_rval(cpu_env, child_flag); - fork_end(child_flag); + fork_end(ret); =20 return ret; =20 @@ -285,7 +285,7 @@ static inline abi_long do_freebsd_pdfork(void *cpu_env,= abi_ulong target_fdp, * value: 0 for parent process, 1 for child process. */ set_second_rval(cpu_env, child_flag); - fork_end(child_flag); + fork_end(ret); =20 return ret; } diff --git a/bsd-user/qemu.h b/bsd-user/qemu.h index 4adb75d19ff..1b0a591d2d2 100644 --- a/bsd-user/qemu.h +++ b/bsd-user/qemu.h @@ -192,7 +192,7 @@ void cpu_loop(CPUArchState *env); char *target_strerror(int err); int get_osversion(void); void fork_start(void); -void fork_end(int child); +void fork_end(pid_t pid); =20 #include "qemu/log.h" =20 diff --git a/linux-user/user-internals.h b/linux-user/user-internals.h index c63ef45fc78..ce11d9e21c1 100644 --- a/linux-user/user-internals.h +++ b/linux-user/user-internals.h @@ -71,7 +71,7 @@ const char *target_strerror(int err); int get_osversion(void); void init_qemu_uname_release(void); void fork_start(void); -void fork_end(int child); +void fork_end(pid_t pid); =20 /** * probe_guest_base: diff --git a/bsd-user/main.c b/bsd-user/main.c index 517c6b3ec2f..fca9b302043 100644 --- a/bsd-user/main.c +++ b/bsd-user/main.c @@ -116,8 +116,10 @@ void fork_start(void) gdbserver_fork_start(); } =20 -void fork_end(int child) +void fork_end(pid_t pid) { + bool child =3D pid =3D=3D 0; + if (child) { CPUState *cpu, *next_cpu; /* diff --git a/linux-user/main.c b/linux-user/main.c index 755c566d6d2..cab95f5b0aa 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -148,8 +148,10 @@ void fork_start(void) gdbserver_fork_start(); } =20 -void fork_end(int child) +void fork_end(pid_t pid) { + bool child =3D pid =3D=3D 0; + qemu_plugin_user_postfork(child); mmap_fork_end(child); if (child) { diff --git a/linux-user/syscall.c b/linux-user/syscall.c index c233d4eb30a..7f30defcb13 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -6669,7 +6669,7 @@ static int do_fork(CPUArchState *env, unsigned int fl= ags, abi_ulong newsp, if (ret =3D=3D 0) { /* Child Process. */ cpu_clone_regs_child(env, newsp, flags); - fork_end(1); + fork_end(ret); /* There is a race condition here. The parent process could theoretically read the TID in the child process before the = child tid is set. This would require using either ptrace @@ -6700,8 +6700,8 @@ static int do_fork(CPUArchState *env, unsigned int fl= ags, abi_ulong newsp, } #endif put_user_u32(pid_fd, parent_tidptr); - } - fork_end(0); + } + fork_end(ret); } g_assert(!cpu_in_exclusive_context(cpu)); } --=20 2.39.2 From nobody Tue Nov 26 04:50:37 2024 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=1709640865; cv=none; d=zohomail.com; s=zohoarc; b=NwLQKbOOVSQccqkUjM0R8QSQsU/FMtFeFVgjeVUuD9bP2esFkud2ePkcbOq+lNQf0buqriIXPx1UbKGY0fAvxVM2MOO9fVArCygPM0LS7ry+arL8dAETFHr19nKKSmybH4OjFqAvUbY1pGM9224rys1fewotLvASAlD5JcCbnL4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709640865; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=z3nYyAloWCoquTZDPSpE+htB2DaRlvaFvDRPXpKYUIk=; b=Y70QeCNiANBoH1WYGyEjzqqBQ5irELN05jEzs2ZXA9d8O9g2Jy7oZVpRrbRwOxPzM8boBrHnf8g9YnYCDwSXiPqZH+QrhxvNuRFCYSIlx/F4xCKRqQ2XfAjEpqgS25KzR7M7KD3BG2fbeRegNJt7559V+5AUPLnVZojadPVNBVU= 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 1709640865310718.4732208274725; Tue, 5 Mar 2024 04:14:25 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rhTel-0005PB-It; Tue, 05 Mar 2024 07:12:27 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rhTdJ-0001uW-GG for qemu-devel@nongnu.org; Tue, 05 Mar 2024 07:11:03 -0500 Received: from mail-wr1-x42a.google.com ([2a00:1450:4864:20::42a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rhTch-0001RA-6F for qemu-devel@nongnu.org; Tue, 05 Mar 2024 07:10:48 -0500 Received: by mail-wr1-x42a.google.com with SMTP id ffacd0b85a97d-33e17342ea7so2937944f8f.2 for ; Tue, 05 Mar 2024 04:10:16 -0800 (PST) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id i10-20020a05600011ca00b0033b60bad2fcsm14828243wrx.113.2024.03.05.04.10.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Mar 2024 04:10:12 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 314165F95B; Tue, 5 Mar 2024 12:10:06 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1709640613; x=1710245413; 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=z3nYyAloWCoquTZDPSpE+htB2DaRlvaFvDRPXpKYUIk=; b=YlFCKI8D4IjhTyxkzLiRopaNtPIX37FxRBi1OzfI+a2AT1584F69fMVJ3KKOqx7QjF opGcuuKMB+fqM+Zxu14VpLoaqh5q5RwaaWRb2BewYcV48M0nbJY5cSu84AzHqw7tUxSu JfHaF8T/UJ4XsAINnvuGx1JOcIOhNd+LIbx1Ssp3SzcuTKsUWScOUn49pN62ERdQtL+9 RjkzGORywaC+fweFJP6JvoLgSzMULbFUDolRUhNQtZv0afdCtPuO9zwhPIn4fF2iWkVz Mu2OGYh23Io5P9ixAGmDNOF2kB7cYeZIkJA8Kg8rxZz1gwDq9lmq1VGYzd7msGmAlw2x bQEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709640613; x=1710245413; 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=z3nYyAloWCoquTZDPSpE+htB2DaRlvaFvDRPXpKYUIk=; b=GvOoWiKGkthPFkXKrCtnJ6VAtFfPVGjB3Mb51eAAmDkn8LvdX+DLDdIba/sCke/ht4 hi+nJUTnrf76mzAuUw823mQK80jHVTEXtZBWenqB63nFCRHdHBG4fF5XeNGk78WWxG74 4Ewb406I0M6+2H1z1mCAoVMrKoQIH4B4NGFCL0ObP5iVnrdXOZ5xnDwIGICyN0d4TNDk JkgyhMVAGfBaLDBY55v8O0t+QZOpx4pz3PU+UWBCZUGnbI8BYqAPg31FtiEA4ALNCJ2T RLGBFRHBCyMQe0GvRKaSNGsorT7fGMTgOnyHUmUwnh8vbydKZcNX0PV6XHqzu1HBevMT +v8Q== X-Gm-Message-State: AOJu0YzMsgXZQlSxWLfIMO/92H1cjy8GoCcB5+le5awOX0HqxhKJP5Dd Hj68lZkP30Ah44PhYLWoUnSGnaUE+pwTf0504zhWhEsNuQTYZMQ/d+fN3hoaWMU= X-Google-Smtp-Source: AGHT+IGxzfpc7Is8XIMk/vDb0IbU6uTaw89SmYiDYHhlZ4rm1tdamaAIUJBzXb/EBdpD9hAZjm5PWQ== X-Received: by 2002:a5d:55c4:0:b0:33e:854:8b24 with SMTP id i4-20020a5d55c4000000b0033e08548b24mr7488915wrw.12.1709640613497; Tue, 05 Mar 2024 04:10:13 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Wainer dos Santos Moschetta , Alistair Francis , Nicholas Piggin , Liu Zhiwei , Richard Henderson , Yanan Wang , qemu-s390x@nongnu.org, "Edgar E. Iglesias" , Eduardo Habkost , Daniel Henrique Barboza , Michael Rolnik , Daniel Henrique Barboza , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Laurent Vivier , Yoshinori Sato , Laurent Vivier , Thomas Huth , Peter Maydell , Mahmoud Mandour , Brad Smith , Alistair Francis , Brian Cain , Cleber Rosa , John Snow , Marcel Apfelbaum , Pierrick Bouvier , Palmer Dabbelt , Riku Voipio , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, Weiwei Li , Bin Meng , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Beraldo Leal , Kyle Evans , David Hildenbrand , Song Gao , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Paolo Bonzini , Alexandre Iooss , Warner Losh , qemu-riscv@nongnu.org, Ilya Leoshkevich Subject: [PATCH 07/29] {linux,bsd}-user: Pass pid to gdbserver_fork() Date: Tue, 5 Mar 2024 12:09:43 +0000 Message-Id: <20240305121005.3528075-8-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240305121005.3528075-1-alex.bennee@linaro.org> References: <20240305121005.3528075-1-alex.bennee@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::42a; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x42a.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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1709640866387100001 From: Ilya Leoshkevich The upcoming follow-fork-mode child support requires knowing the child pid. Pass it down. Reviewed-by: Richard Henderson Signed-off-by: Ilya Leoshkevich Message-Id: <20240219141628.246823-7-iii@linux.ibm.com> Signed-off-by: Alex Benn=C3=A9e --- include/gdbstub/user.h | 2 +- bsd-user/main.c | 2 +- gdbstub/user.c | 2 +- linux-user/main.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/gdbstub/user.h b/include/gdbstub/user.h index e33f8d9a9a6..3f9f45946e0 100644 --- a/include/gdbstub/user.h +++ b/include/gdbstub/user.h @@ -54,7 +54,7 @@ void gdbserver_fork_start(void); * gdbserver_fork() - disable gdb stub for child processes. * @cs: CPU */ -void gdbserver_fork(CPUState *cs); +void gdbserver_fork(CPUState *cs, pid_t pid); =20 /** * gdb_syscall_entry() - inform gdb of syscall entry and yield control to = it diff --git a/bsd-user/main.c b/bsd-user/main.c index fca9b302043..0dbd1cf8801 100644 --- a/bsd-user/main.c +++ b/bsd-user/main.c @@ -138,7 +138,7 @@ void fork_end(pid_t pid) */ qemu_init_cpu_list(); get_task_state(thread_cpu)->ts_tid =3D qemu_get_thread_id(); - gdbserver_fork(thread_cpu); + gdbserver_fork(thread_cpu, pid); } else { mmap_fork_end(child); cpu_list_unlock(); diff --git a/gdbstub/user.c b/gdbstub/user.c index 536fb43b03e..c61e1a0d1f6 100644 --- a/gdbstub/user.c +++ b/gdbstub/user.c @@ -375,7 +375,7 @@ static void disable_gdbstub(CPUState *thread_cpu) } =20 /* Disable gdb stub for child processes. */ -void gdbserver_fork(CPUState *cpu) +void gdbserver_fork(CPUState *cpu, pid_t pid) { if (!gdbserver_state.init || gdbserver_user_state.fd < 0) { return; diff --git a/linux-user/main.c b/linux-user/main.c index cab95f5b0aa..70314e0ab6a 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -165,7 +165,7 @@ void fork_end(pid_t pid) } qemu_init_cpu_list(); get_task_state(thread_cpu)->ts_tid =3D qemu_get_thread_id(); - gdbserver_fork(thread_cpu); + gdbserver_fork(thread_cpu, pid); } else { cpu_list_unlock(); } --=20 2.39.2 From nobody Tue Nov 26 04:50:37 2024 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=1709640879; cv=none; d=zohomail.com; s=zohoarc; b=ij9kTIImHNWCBc5t6bRMdimyGfuy2TVU3Im0LuEzzGlj5l3n2PI3nBZ3v3oZ/N0WCjRnm0TiJowF6bvTMX3xV6CpiR/mX8dYv2g8LvjE8MiIPsBib5cx8cClUdc1SwR/XDGFi732Kf83OijlLQFmYZuO8jQ+wsl/Uxh/U7lTRnM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709640879; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=ZqnQ8XijekxyIBL7Xx6BaJyRk5an5hw3I1N1rasyLAw=; b=RFvILHMnWsUyIW4cDtNRSgM1d0EwaaW92QkIWxuCqCnZQT9HbIE8VjV/AJ/AHPylEC1raicecGi0eT/9uL8F53PKhkMZpT+b4Cm4NBfxAubWqfyt2Bq2AGdqrS6HQlCOEs93tdHQOUZe0xbuGI/rrY+uhc+Wba6IRShDUpkyK30= 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 1709640879068631.7174026948722; Tue, 5 Mar 2024 04:14:39 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rhTee-0004ry-Su; Tue, 05 Mar 2024 07:12:20 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rhTdN-0001x2-HW for qemu-devel@nongnu.org; Tue, 05 Mar 2024 07:11:05 -0500 Received: from mail-wr1-x42b.google.com ([2a00:1450:4864:20::42b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rhTci-0001Sf-J7 for qemu-devel@nongnu.org; Tue, 05 Mar 2024 07:10:59 -0500 Received: by mail-wr1-x42b.google.com with SMTP id ffacd0b85a97d-33e4d36f288so236858f8f.1 for ; Tue, 05 Mar 2024 04:10:19 -0800 (PST) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id i10-20020a05600011ca00b0033b60bad2fcsm14828244wrx.113.2024.03.05.04.10.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Mar 2024 04:10:12 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 496475F9CB; Tue, 5 Mar 2024 12:10:06 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1709640616; x=1710245416; 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=ZqnQ8XijekxyIBL7Xx6BaJyRk5an5hw3I1N1rasyLAw=; b=SNT8Biws1so53AURPPYtJTpSUkquhCfCQQ5aX9S4+TRjdDkz8JRDWFj2qNgp83688Q STusXn+KR9JfTCJSBFT1FqKph5egXIMFE+YPcYv/coY0pql4zen4evn+fVF4DFEH6dWz bVIdYJV2+vs3HOxxZ5HRgINA9ZV+WRiQG0SnrVyWFubX2Q3t7hO9Y4aRXJ4CozZyGYCX vjJmF59KOaQ2srb9XgXuFJosvcVUEzCuVMLV8CShrqQIkuGQ/nvwNoC5XYNx1s9gu+3G X7hjEm5dV2VCdzx2+tNxWGpkzVbQQ8FAxUi5WFV2Uo0SRuUkyPmRcFTMh3oEutuZLy56 fw7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709640616; x=1710245416; 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=ZqnQ8XijekxyIBL7Xx6BaJyRk5an5hw3I1N1rasyLAw=; b=NgBDEtjbC7cotgc6BvABGlMFcJLtSQJPum9UY6ckqCgw8/L+4Up+1DMRqF9CJbhXkY Dxm6sekMcHXqbYhn2l/DjyxBtvze8EwJWR7l7Grbtf6dpzjt1o70Fh1gMJjCU+Js0tOR j74Pmhi+LF7fmgb2LRSBauNbOCe2AuIcr6GsJx5Ipfr1BjAThxys+LgCu9HWiuGPLan9 LPa+UC0CTMG43bSWwxTNHpnGXOdAWsz5KGb6sYlhDv+YALBXIf2o0JmwyaMZZZNgkjF8 JhfZs8ujl+EMIegOiVzhzcmVf77/QMCFqU4sFOlgR54KwgdgRs5OKy/W46LGrfSCR6NH C/zA== X-Gm-Message-State: AOJu0YxgQYIql22f3XgB77lwWqe3nyvBpr9EeycBc/XMysct/0WArEY2 MmORVo8mtDuUKbMrwTaKOwpIovNnkPp05EW7GMke5UOaC4jqCOD8POYNuwR4DEw= X-Google-Smtp-Source: AGHT+IHFTyPejUIURcNk9BVacfFz4duAbKnfNHNZfVjg4uLkBpbZE3sIi9/Mzh5DMg6sBUfe0ye9hA== X-Received: by 2002:adf:b212:0:b0:33e:21ac:b89d with SMTP id u18-20020adfb212000000b0033e21acb89dmr2303195wra.6.1709640616176; Tue, 05 Mar 2024 04:10:16 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Wainer dos Santos Moschetta , Alistair Francis , Nicholas Piggin , Liu Zhiwei , Richard Henderson , Yanan Wang , qemu-s390x@nongnu.org, "Edgar E. Iglesias" , Eduardo Habkost , Daniel Henrique Barboza , Michael Rolnik , Daniel Henrique Barboza , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Laurent Vivier , Yoshinori Sato , Laurent Vivier , Thomas Huth , Peter Maydell , Mahmoud Mandour , Brad Smith , Alistair Francis , Brian Cain , Cleber Rosa , John Snow , Marcel Apfelbaum , Pierrick Bouvier , Palmer Dabbelt , Riku Voipio , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, Weiwei Li , Bin Meng , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Beraldo Leal , Kyle Evans , David Hildenbrand , Song Gao , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Paolo Bonzini , Alexandre Iooss , Warner Losh , qemu-riscv@nongnu.org, Ilya Leoshkevich Subject: [PATCH 08/29] gdbstub: Call gdbserver_fork() both in parent and in child Date: Tue, 5 Mar 2024 12:09:44 +0000 Message-Id: <20240305121005.3528075-9-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240305121005.3528075-1-alex.bennee@linaro.org> References: <20240305121005.3528075-1-alex.bennee@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::42b; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x42b.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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1709640880444100001 From: Ilya Leoshkevich The upcoming follow-fork-mode child support requires post-fork message exchange between the parent and the child. Prepare gdbserver_fork() for this purpose. Rename it to gdbserver_fork_end() to better reflect its purpose. Reviewed-by: Richard Henderson Signed-off-by: Ilya Leoshkevich Message-Id: <20240219141628.246823-8-iii@linux.ibm.com> Signed-off-by: Alex Benn=C3=A9e --- include/gdbstub/user.h | 5 +++-- bsd-user/main.c | 3 ++- gdbstub/user.c | 5 ++--- linux-user/main.c | 2 +- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/include/gdbstub/user.h b/include/gdbstub/user.h index 3f9f45946e0..4c4e5c4c582 100644 --- a/include/gdbstub/user.h +++ b/include/gdbstub/user.h @@ -51,10 +51,11 @@ void gdb_signalled(CPUArchState *as, int sig); void gdbserver_fork_start(void); =20 /** - * gdbserver_fork() - disable gdb stub for child processes. + * gdbserver_fork_end() - inform gdb of the completed fork() * @cs: CPU + * @pid: 0 if in child process, -1 if fork failed, child process pid other= wise */ -void gdbserver_fork(CPUState *cs, pid_t pid); +void gdbserver_fork_end(CPUState *cs, pid_t pid); =20 /** * gdb_syscall_entry() - inform gdb of syscall entry and yield control to = it diff --git a/bsd-user/main.c b/bsd-user/main.c index 0dbd1cf8801..3dc285e5b74 100644 --- a/bsd-user/main.c +++ b/bsd-user/main.c @@ -138,10 +138,11 @@ void fork_end(pid_t pid) */ qemu_init_cpu_list(); get_task_state(thread_cpu)->ts_tid =3D qemu_get_thread_id(); - gdbserver_fork(thread_cpu, pid); + gdbserver_fork_end(thread_cpu, pid); } else { mmap_fork_end(child); cpu_list_unlock(); + gdbserver_fork_end(thread_cpu, pid); end_exclusive(); } } diff --git a/gdbstub/user.c b/gdbstub/user.c index c61e1a0d1f6..866a25f9c06 100644 --- a/gdbstub/user.c +++ b/gdbstub/user.c @@ -374,10 +374,9 @@ static void disable_gdbstub(CPUState *thread_cpu) tb_flush(thread_cpu); } =20 -/* Disable gdb stub for child processes. */ -void gdbserver_fork(CPUState *cpu, pid_t pid) +void gdbserver_fork_end(CPUState *cpu, pid_t pid) { - if (!gdbserver_state.init || gdbserver_user_state.fd < 0) { + if (pid !=3D 0 || !gdbserver_state.init || gdbserver_user_state.fd < 0= ) { return; } disable_gdbstub(cpu); diff --git a/linux-user/main.c b/linux-user/main.c index 70314e0ab6a..41caa77cb52 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -165,10 +165,10 @@ void fork_end(pid_t pid) } qemu_init_cpu_list(); get_task_state(thread_cpu)->ts_tid =3D qemu_get_thread_id(); - gdbserver_fork(thread_cpu, pid); } else { cpu_list_unlock(); } + gdbserver_fork_end(thread_cpu, pid); /* * qemu_init_cpu_list() reinitialized the child exclusive state, but we * also need to keep current_cpu consistent, so call end_exclusive() f= or --=20 2.39.2 From nobody Tue Nov 26 04:50:37 2024 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=1709641016; cv=none; d=zohomail.com; s=zohoarc; b=c6qP6o/H/pa5vWTEpXtgcfqJih8a/KRfXs+Ral8oi/8c6U9T/Afoq0x9PpIi+AqxrPyYZgcqy0VFb6KDtmd9q+FDEDBelYDA8K6CQdpr+IILvrgthwwC+8CcWhieafZEXf93qWLrxT0SqXJWuhdKE2gfiqvPKp2NYHZAcK9R1iU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709641016; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=h/FvadGGUwctE1IWDDn0kVOXWDaUBwNAKUX6TCu5fDg=; b=I7a3dPm0i3zbqgIN4t6BGDzVso8Be9/sceJTtPRts9dkY6IWBnM44c9mMsSKc1ePSLHP0bQ/KJI9xvorpyZjteiXI//txlNMrkDvxu1U9EVNQHATzH9rpHLRE7GePuf8nIx8h+dCh9csAEc+LI7a3i1KMQR2857qWZhSaeBjReg= 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 1709641016958789.0235426616837; Tue, 5 Mar 2024 04:16:56 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rhTe8-0003Ft-UW; Tue, 05 Mar 2024 07:11:49 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rhTd5-0001iZ-M4 for qemu-devel@nongnu.org; Tue, 05 Mar 2024 07:10:53 -0500 Received: from mail-wm1-x330.google.com ([2a00:1450:4864:20::330]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rhTcf-0001RG-CH for qemu-devel@nongnu.org; Tue, 05 Mar 2024 07:10:42 -0500 Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-412e1b52934so13547985e9.1 for ; Tue, 05 Mar 2024 04:10:14 -0800 (PST) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id hg5-20020a05600c538500b00412eeb017f0sm1196785wmb.34.2024.03.05.04.10.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Mar 2024 04:10:12 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 5EDF65F7B5; Tue, 5 Mar 2024 12:10:06 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1709640614; x=1710245414; 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=h/FvadGGUwctE1IWDDn0kVOXWDaUBwNAKUX6TCu5fDg=; b=AALiLh2n7Byt94/QX+on1G8T0EIoEUKhThgE9yVhdNKuRyRbnRIFO/tl8BJssx0c8u asUD29Fe4hEODqA9pX/kUT1asUo1UN4ECNor0drAidRU64otNj06ept7Mvz7c7zA4AL6 FRBBsU8WTHq6Ry5h0EkJCQszD6PYx1CKSuFo3WPUAeTNOGy4rVUSIrDbl7gKUg0dVJhv JdgmUa/YGLvB/9EGKrETofa54NBy3mDvuLruvDJWnjvFK2jHtBq0fghLUiWVvymgfZn8 VQ7xd83VOX6EFyzsZqqpHzIHoq/FrQVa811mkadT24PZXp732DECAgcbwS8/zuHGXD08 5ACw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709640614; x=1710245414; 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=h/FvadGGUwctE1IWDDn0kVOXWDaUBwNAKUX6TCu5fDg=; b=Yc8ECGeDzUYGmEwexW9XIwFqsgYpeq1UY4Yk3+scyOeHQvNOlLD/NWVscY+q9Y6ncS AXm6L3R+Y7RlkGwqLaigCCzCPczgPUNw1FjspEfK4kJPVXrMtk8DzM2IAwTkCpr63O5U ZPUWWVwp1yCI9TfsRENRUX2Q85ILPeuRjRUXicYNWRNUscgQd7nAUi5YoCoXmZRXg92v kN7CnAA8JwY7VI53tQP2vJZ1NDZhSePkPU30xlQ8AK2rfgy4dgOuqs8LT2Jd3f2rTMkG ney/eAjMNxVt53BLeXSCIUoRTAJxEVWu5qhGYTaPckKz/x4eELQoLRusrOwTIs8Gu9ez gqRw== X-Gm-Message-State: AOJu0Yw8pN3eXLsoez5ad9cbD/GfovaYYBuMNGxzA1u/CCXVVWBt79YL RtHg3B6Mk/Te+UPSmA0Mi+J90Za/XXpgvsf/WkHzpgW9ME7osDjvDnsQfsoOH+0= X-Google-Smtp-Source: AGHT+IFRlWeZuoNQT4394axMB4M5A4PeGV9EvrVU80583K6WJL53zjPB2OtrAYcpUDFxlDs/3LsTvw== X-Received: by 2002:a7b:cd05:0:b0:412:eaac:968a with SMTP id f5-20020a7bcd05000000b00412eaac968amr2114430wmj.16.1709640613787; Tue, 05 Mar 2024 04:10:13 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Wainer dos Santos Moschetta , Alistair Francis , Nicholas Piggin , Liu Zhiwei , Richard Henderson , Yanan Wang , qemu-s390x@nongnu.org, "Edgar E. Iglesias" , Eduardo Habkost , Daniel Henrique Barboza , Michael Rolnik , Daniel Henrique Barboza , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Laurent Vivier , Yoshinori Sato , Laurent Vivier , Thomas Huth , Peter Maydell , Mahmoud Mandour , Brad Smith , Alistair Francis , Brian Cain , Cleber Rosa , John Snow , Marcel Apfelbaum , Pierrick Bouvier , Palmer Dabbelt , Riku Voipio , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, Weiwei Li , Bin Meng , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Beraldo Leal , Kyle Evans , David Hildenbrand , Song Gao , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Paolo Bonzini , Alexandre Iooss , Warner Losh , qemu-riscv@nongnu.org, Ilya Leoshkevich Subject: [PATCH 09/29] gdbstub: Introduce gdb_handle_query_supported_user() Date: Tue, 5 Mar 2024 12:09:45 +0000 Message-Id: <20240305121005.3528075-10-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240305121005.3528075-1-alex.bennee@linaro.org> References: <20240305121005.3528075-1-alex.bennee@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::330; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x330.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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1709641019035100007 From: Ilya Leoshkevich The upcoming follow-fork-mode child support requires advertising the fork-events feature, which is user-specific. Introduce a user-specific hook for this. Reviewed-by: Richard Henderson Signed-off-by: Ilya Leoshkevich Message-Id: <20240219141628.246823-9-iii@linux.ibm.com> Signed-off-by: Alex Benn=C3=A9e --- gdbstub/internals.h | 1 + gdbstub/gdbstub.c | 12 +++++++++--- gdbstub/user.c | 4 ++++ 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/gdbstub/internals.h b/gdbstub/internals.h index 56b7c13b750..e6063835b1f 100644 --- a/gdbstub/internals.h +++ b/gdbstub/internals.h @@ -196,6 +196,7 @@ void gdb_handle_v_file_pread(GArray *params, void *user= _ctx); /* user */ void gdb_handle_v_file_readlink(GArray *params, void *user_ctx); /* user */ void gdb_handle_query_xfer_exec_file(GArray *params, void *user_ctx); /* u= ser */ void gdb_handle_set_catch_syscalls(GArray *params, void *user_ctx); /* use= r */ +void gdb_handle_query_supported_user(const char *gdb_supported); /* user */ =20 void gdb_handle_query_attached(GArray *params, void *user_ctx); /* both */ =20 diff --git a/gdbstub/gdbstub.c b/gdbstub/gdbstub.c index 2909bc8c69f..7be4418dcb5 100644 --- a/gdbstub/gdbstub.c +++ b/gdbstub/gdbstub.c @@ -1655,9 +1655,15 @@ static void handle_query_supported(GArray *params, v= oid *user_ctx) g_string_append(gdbserver_state.str_buf, ";qXfer:exec-file:read+"); #endif =20 - if (params->len && - strstr(get_param(params, 0)->data, "multiprocess+")) { - gdbserver_state.multiprocess =3D true; + if (params->len) { + const char *gdb_supported =3D get_param(params, 0)->data; + + if (strstr(gdb_supported, "multiprocess+")) { + gdbserver_state.multiprocess =3D true; + } +#if defined(CONFIG_USER_ONLY) + gdb_handle_query_supported_user(gdb_supported); +#endif } =20 g_string_append(gdbserver_state.str_buf, ";vContSupported+;multiproces= s+"); diff --git a/gdbstub/user.c b/gdbstub/user.c index 866a25f9c06..c9e8b83d720 100644 --- a/gdbstub/user.c +++ b/gdbstub/user.c @@ -382,6 +382,10 @@ void gdbserver_fork_end(CPUState *cpu, pid_t pid) disable_gdbstub(cpu); } =20 +void gdb_handle_query_supported_user(const char *gdb_supported) +{ +} + /* * Execution state helpers */ --=20 2.39.2 From nobody Tue Nov 26 04:50:37 2024 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=1709641015; cv=none; d=zohomail.com; s=zohoarc; b=izGZA6dSW6Q5S7zXSY7QHxzfBqd7tBCx7BAE1/sOAAdi7YvVf67Ty7YNa0jCfbZY+vxmfYcGPLb4UQstnrDingYWJU+6zHba9hSd4XXjSGDn0/J3bhHlnCny9yHHpbT4lzotaOJ5sKKA9PJsnSo1yaKN0pMCsZ8zsff/HxFlut4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709641015; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=aJzWza4vI5yWejE/TYAdmrx2G3TCvmG5gLCl8zQLNCk=; b=bhWrtg2KvbBcyaGzxhkaENoaIsHlDDn7r/FU5wXz0Lp+d4bN2X5nbXSeD/C0oPG3zYASBVKp6JTtWagpnpLdWEuHH8CGJpIj2kBXiis08fMzV3YRMoDhr/5uwclBqJ8/JJqf8Izxmxe0ndjp2tTdEzjo4cY0/r2OuUne+a5f5g0= 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 1709641015410509.16027359978295; Tue, 5 Mar 2024 04:16:55 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rhTeZ-00048B-It; Tue, 05 Mar 2024 07:12:15 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rhTdJ-0001uV-GG for qemu-devel@nongnu.org; Tue, 05 Mar 2024 07:11:03 -0500 Received: from mail-lj1-x22d.google.com ([2a00:1450:4864:20::22d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rhTch-0001SW-8i for qemu-devel@nongnu.org; Tue, 05 Mar 2024 07:10:48 -0500 Received: by mail-lj1-x22d.google.com with SMTP id 38308e7fff4ca-2d26227d508so64868261fa.2 for ; Tue, 05 Mar 2024 04:10:17 -0800 (PST) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id l22-20020a05600c4f1600b004128f41a13fsm17794983wmq.38.2024.03.05.04.10.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Mar 2024 04:10:12 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 755565F9CE; Tue, 5 Mar 2024 12:10:06 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1709640616; x=1710245416; 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=aJzWza4vI5yWejE/TYAdmrx2G3TCvmG5gLCl8zQLNCk=; b=yUKXzgXmMloK5w6WEn88L/LaegaWwKuVmI6/BeQjXSxHBxt48WsvsIox6KAgfQesNW q8zPsU2MoTgY0+lDQMgPp+xw99ldvcMlmK6wkOSwWjf+G7H8GNUlmlMP9wo7XkJELEE4 7m1fi0fuEkQJVNK6SOalbfr2QRbMFXlocsDTlofaYdl+cYk2ceu9SwFeGckLyEo61RRY 7WqAOPVjqA9QuJXGcxk8wC3wjFxheoKDWxaW2eT65ymkjWbAQpr+HGtZl1nVnYX/FGfP gh+kEgKkHNNHKboYb0TOd194l+eiyNjY49HrnLoYMxsu0LZKGA7vD/4uPiHmrmIisc3X VpFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709640616; x=1710245416; 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=aJzWza4vI5yWejE/TYAdmrx2G3TCvmG5gLCl8zQLNCk=; b=mPZILIJufqDE1RBphbFrp6yD9NNEKNMXm8BDfygv10WOKXX33Pzb/H3jo9Kbq4xikc CuPgSAXzKu+E9gDkh1RQ2OGMRdjT2V2m+m9ovPW1J7mI1F2gwv81oim+HbYoQUpXVSB+ nA6EBVwJTMjMyRjKHlHQMcpsqjOw25VII7hGPM8Z6fwVh1sNfyZXyUyvHXOm6lJjP8qI ItFGoHH2BtPhfMHaktRW5DnYFG/05bqklQVNORS4JfkXHEsJJWddRaM4Q4f8/dx+o8qm iPJbdvLW17FfmNI9XIRfBG1mmyJa59x6jV1SG7jcaVMv9byOxfEfyPNly8aPhRO+7CNd Zjhw== X-Gm-Message-State: AOJu0YxbNIurlq+RMhMSRQ3F4MQgKKa0HZ4R2wuIfnawR4wqMpO5XbW7 E5Tu1oLrju1JWGFkUjiTCvtxx/o+PJx62BEvGc3wm9yDA3UspB+uCjlyLYwiLZI= X-Google-Smtp-Source: AGHT+IGtvfi5YTHGExZQ/HVfvB/kBsA0r2Osi15Bw5ChEcGTzPSLzircQ+DfYNa7xka4HyfK+AilSA== X-Received: by 2002:a05:6512:1054:b0:513:4ad9:a7ef with SMTP id c20-20020a056512105400b005134ad9a7efmr1316093lfb.52.1709640615995; Tue, 05 Mar 2024 04:10:15 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Wainer dos Santos Moschetta , Alistair Francis , Nicholas Piggin , Liu Zhiwei , Richard Henderson , Yanan Wang , qemu-s390x@nongnu.org, "Edgar E. Iglesias" , Eduardo Habkost , Daniel Henrique Barboza , Michael Rolnik , Daniel Henrique Barboza , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Laurent Vivier , Yoshinori Sato , Laurent Vivier , Thomas Huth , Peter Maydell , Mahmoud Mandour , Brad Smith , Alistair Francis , Brian Cain , Cleber Rosa , John Snow , Marcel Apfelbaum , Pierrick Bouvier , Palmer Dabbelt , Riku Voipio , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, Weiwei Li , Bin Meng , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Beraldo Leal , Kyle Evans , David Hildenbrand , Song Gao , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Paolo Bonzini , Alexandre Iooss , Warner Losh , qemu-riscv@nongnu.org, Ilya Leoshkevich Subject: [PATCH 10/29] gdbstub: Introduce gdb_handle_set_thread_user() Date: Tue, 5 Mar 2024 12:09:46 +0000 Message-Id: <20240305121005.3528075-11-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240305121005.3528075-1-alex.bennee@linaro.org> References: <20240305121005.3528075-1-alex.bennee@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::22d; envelope-from=alex.bennee@linaro.org; helo=mail-lj1-x22d.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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1709641017088100001 From: Ilya Leoshkevich The upcoming follow-fork-mode child support needs to perform certain actions when GDB switches between the stopped parent and the stopped child. Introduce a user-specific hook for this. Signed-off-by: Ilya Leoshkevich Message-Id: <20240219141628.246823-10-iii@linux.ibm.com> Signed-off-by: Alex Benn=C3=A9e --- gdbstub/internals.h | 1 + gdbstub/gdbstub.c | 11 +++++++++-- gdbstub/user.c | 5 +++++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/gdbstub/internals.h b/gdbstub/internals.h index e6063835b1f..b4905c7181a 100644 --- a/gdbstub/internals.h +++ b/gdbstub/internals.h @@ -197,6 +197,7 @@ void gdb_handle_v_file_readlink(GArray *params, void *u= ser_ctx); /* user */ void gdb_handle_query_xfer_exec_file(GArray *params, void *user_ctx); /* u= ser */ void gdb_handle_set_catch_syscalls(GArray *params, void *user_ctx); /* use= r */ void gdb_handle_query_supported_user(const char *gdb_supported); /* user */ +bool gdb_handle_set_thread_user(uint32_t pid, uint32_t tid); /* user */ =20 void gdb_handle_query_attached(GArray *params, void *user_ctx); /* both */ =20 diff --git a/gdbstub/gdbstub.c b/gdbstub/gdbstub.c index 7be4418dcb5..3eb93162aa8 100644 --- a/gdbstub/gdbstub.c +++ b/gdbstub/gdbstub.c @@ -1099,6 +1099,7 @@ static void handle_cont_with_sig(GArray *params, void= *user_ctx) =20 static void handle_set_thread(GArray *params, void *user_ctx) { + uint32_t pid, tid; CPUState *cpu; =20 if (params->len !=3D 2) { @@ -1116,8 +1117,14 @@ static void handle_set_thread(GArray *params, void *= user_ctx) return; } =20 - cpu =3D gdb_get_cpu(get_param(params, 1)->thread_id.pid, - get_param(params, 1)->thread_id.tid); + pid =3D get_param(params, 1)->thread_id.pid; + tid =3D get_param(params, 1)->thread_id.tid; +#ifdef CONFIG_USER_ONLY + if (gdb_handle_set_thread_user(pid, tid)) { + return; + } +#endif + cpu =3D gdb_get_cpu(pid, tid); if (!cpu) { gdb_put_packet("E22"); return; diff --git a/gdbstub/user.c b/gdbstub/user.c index c9e8b83d720..b048754c4f8 100644 --- a/gdbstub/user.c +++ b/gdbstub/user.c @@ -386,6 +386,11 @@ void gdb_handle_query_supported_user(const char *gdb_s= upported) { } =20 +bool gdb_handle_set_thread_user(uint32_t pid, uint32_t tid) +{ + return false; +} + /* * Execution state helpers */ --=20 2.39.2 From nobody Tue Nov 26 04:50:37 2024 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=1709640944; cv=none; d=zohomail.com; s=zohoarc; b=RJ08OfGAT4CXPN6pat8SUNFRfEF0zTrwrOvJM8YBwRFYZKG0tDVoPH/MjeT65/XzK6tb1ifoXfJVhZo7p7qjqd1h/9WnJ1PGRHHuTQ2qFuEo7bDzMVuknqjHa7b4PhOLNmV4OfxKvzFdfaReuj4Efb1eSbwoZaGYmRGhv315TdY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709640944; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=eN1w3VZA32Wi8fJgCeFoCtnvrPmKwuzv+ibyU3+3o6o=; b=kXE0UyQ3aL8H8oGRjpdrOJVGH/oR6WpKBiRvxc9JYwWPq9bSR1ofCbvMkfbOb1Tow5J9dSriUOfTEek25n2AexdGCFrl1j1Z3isJf0FUfjLfgi+y6JmfPuUEMiCsN1ogca8YtGr0Rk/N4zeb6btz57oQFi36gzgBAP3XwVr4VCY= 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 1709640944703459.54676726666446; Tue, 5 Mar 2024 04:15:44 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rhTe2-00038u-5e; Tue, 05 Mar 2024 07:11:42 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rhTd5-0001iV-MR for qemu-devel@nongnu.org; Tue, 05 Mar 2024 07:10:53 -0500 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 1rhTcf-0001RQ-EM for qemu-devel@nongnu.org; Tue, 05 Mar 2024 07:10:40 -0500 Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-412ecc1064cso4581355e9.2 for ; Tue, 05 Mar 2024 04:10:15 -0800 (PST) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id d8-20020a05600c3ac800b00412e84e59d8sm3851590wms.44.2024.03.05.04.10.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Mar 2024 04:10:12 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 8A5E65F9CF; Tue, 5 Mar 2024 12:10:06 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1709640614; x=1710245414; 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=eN1w3VZA32Wi8fJgCeFoCtnvrPmKwuzv+ibyU3+3o6o=; b=BYZvPV/POC2s7JrzoSfCGWx4C2ATR+TzSETRejEefvUV9xkw2+trUwz1DT55H2+6tt BebBE4fz/8Z5duJmZKK+XoVvHVBcy3DoV35pzku8nqXufhwEh3yubslIYxiUku+DVOf8 DxZQzZD5mos9p6PYwxxvkLtyBLwRJ4mdO1G14LPClRMc30o5NDchhQRpje4t5UuiU0rb 1QKT+nt4usCqEuaEfiY8rAvdHgD+SxfuNtg9iykBP8ZI/6hxxqRVoGF9mbhuR3sAwj32 dt55YwrGmhtz/Gm+UFTk9Y83tuAI0ns8WnGY9wRaSrUAIj6mgH3I0iEcJQ7kdVbykr0H SDUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709640614; x=1710245414; 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=eN1w3VZA32Wi8fJgCeFoCtnvrPmKwuzv+ibyU3+3o6o=; b=RFNu/6EJ67/n7Oz77oFIUBtG9gsvioNsHGeB+eBehgrcN05K3CVQolMSeJMghIB3i+ BWUScmgMigYKLyeSdzpYtfj30KnCv9xgQ4cRdiwccGsLePLHaDRWl6zBgj14NXWZ+hZI RXinlFJstKjaqXrDVcbm+FZb2p0Z2cygD6BZvF5roQMiGBGIv623/i1DAcVQNI/aJs+M VIZW/XmeIYTQTufCX2ZuKe5Xcg9sjHLnprY1xIEJ/k/ngEVqRyHtDuV1n/oJqG2qH7d4 nAZvKpEU+6T6u1TFrPWOgUjAajTc1kxqjWfQQ9NRYURpc4rk4VrYza2Qyt0UK/9+mShz vyOw== X-Gm-Message-State: AOJu0Yz2R5Ec06bgnUgX2R8EYGsHAjLVRosjaxBT1WcgaK4UciMm/0kg d4piLckg3sVfIbIXqZqYSAimL7NXbmOdPJKxuXmhovSb88I8iD3omKCaxq/ipGg= X-Google-Smtp-Source: AGHT+IEVuEapc/2m/rYMnypstBHkreGm3a0DZAqtHtnVmJWeGeXufNpTmF9IPZPtexy/OrRqPDeUBw== X-Received: by 2002:a05:600c:4fcf:b0:412:ebfe:68fe with SMTP id o15-20020a05600c4fcf00b00412ebfe68femr1410832wmq.35.1709640614053; Tue, 05 Mar 2024 04:10:14 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Wainer dos Santos Moschetta , Alistair Francis , Nicholas Piggin , Liu Zhiwei , Richard Henderson , Yanan Wang , qemu-s390x@nongnu.org, "Edgar E. Iglesias" , Eduardo Habkost , Daniel Henrique Barboza , Michael Rolnik , Daniel Henrique Barboza , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Laurent Vivier , Yoshinori Sato , Laurent Vivier , Thomas Huth , Peter Maydell , Mahmoud Mandour , Brad Smith , Alistair Francis , Brian Cain , Cleber Rosa , John Snow , Marcel Apfelbaum , Pierrick Bouvier , Palmer Dabbelt , Riku Voipio , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, Weiwei Li , Bin Meng , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Beraldo Leal , Kyle Evans , David Hildenbrand , Song Gao , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Paolo Bonzini , Alexandre Iooss , Warner Losh , qemu-riscv@nongnu.org, Ilya Leoshkevich Subject: [PATCH 11/29] gdbstub: Introduce gdb_handle_detach_user() Date: Tue, 5 Mar 2024 12:09:47 +0000 Message-Id: <20240305121005.3528075-12-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240305121005.3528075-1-alex.bennee@linaro.org> References: <20240305121005.3528075-1-alex.bennee@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=alex.bennee@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_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01, T_SPF_HELO_TEMPERROR=0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1709640946830100003 From: Ilya Leoshkevich The upcoming follow-fork-mode child support needs to perform certain actions when GDB detaches from the stopped parent or the stopped child. Introduce a user-specific hook for this. Signed-off-by: Ilya Leoshkevich Message-Id: <20240219141628.246823-11-iii@linux.ibm.com> Signed-off-by: Alex Benn=C3=A9e --- gdbstub/internals.h | 1 + gdbstub/gdbstub.c | 6 ++++++ gdbstub/user.c | 5 +++++ 3 files changed, 12 insertions(+) diff --git a/gdbstub/internals.h b/gdbstub/internals.h index b4905c7181a..b4724598384 100644 --- a/gdbstub/internals.h +++ b/gdbstub/internals.h @@ -198,6 +198,7 @@ void gdb_handle_query_xfer_exec_file(GArray *params, vo= id *user_ctx); /* user */ void gdb_handle_set_catch_syscalls(GArray *params, void *user_ctx); /* use= r */ void gdb_handle_query_supported_user(const char *gdb_supported); /* user */ bool gdb_handle_set_thread_user(uint32_t pid, uint32_t tid); /* user */ +bool gdb_handle_detach_user(uint32_t pid); /* user */ =20 void gdb_handle_query_attached(GArray *params, void *user_ctx); /* both */ =20 diff --git a/gdbstub/gdbstub.c b/gdbstub/gdbstub.c index 3eb93162aa8..17efcae0d0e 100644 --- a/gdbstub/gdbstub.c +++ b/gdbstub/gdbstub.c @@ -1024,6 +1024,12 @@ static void handle_detach(GArray *params, void *user= _ctx) pid =3D get_param(params, 0)->val_ul; } =20 +#ifdef CONFIG_USER_ONLY + if (gdb_handle_detach_user(pid)) { + return; + } +#endif + process =3D gdb_get_process(pid); gdb_process_breakpoint_remove_all(process); process->attached =3D false; diff --git a/gdbstub/user.c b/gdbstub/user.c index b048754c4f8..1a7b582a40d 100644 --- a/gdbstub/user.c +++ b/gdbstub/user.c @@ -391,6 +391,11 @@ bool gdb_handle_set_thread_user(uint32_t pid, uint32_t= tid) return false; } =20 +bool gdb_handle_detach_user(uint32_t pid) +{ + return false; +} + /* * Execution state helpers */ --=20 2.39.2 From nobody Tue Nov 26 04:50:37 2024 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=1709641081; cv=none; d=zohomail.com; s=zohoarc; b=JMC0XkGyHStIdeQLeKapgZ8aMZYFLayDFNq06oCZ/bu9RuCVcN0JbSC1DyphlI6Dax8mc/5+3msbpvj4kjOjicXqLHuCeCD8W1j60US5WxaKggaj04xC0HBjgrHvTjx7C2dKzsnpXaTEJU2gqHlElu3DRm+mNxrJZiAidtV+ZKs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709641081; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=FBFGDsBcYD+JP9yYVswciAAzuKJ4opwX8kvXoDHdqq0=; b=MF1fBkmHGDfEkI0Tv2h+czLhFMBIAsD7U7uON30zWBi9jjDVvFH+okUp+QeB41PQM2m+U3nu+mM3F3PmVFlryRnUhGbR3wFFMJK2QDKGbPAa3U2jrc/6bhdxkrXlmOOXhxRG9Jwkkv8suZV+8qcmUVtohpbDG+5w+WoXRMgSjXY= 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 1709641081931596.2668317810995; Tue, 5 Mar 2024 04:18:01 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rhTdm-0002ni-Ke; Tue, 05 Mar 2024 07:11:26 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rhTd4-0001iU-K3 for qemu-devel@nongnu.org; Tue, 05 Mar 2024 07:10:53 -0500 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 1rhTcg-0001T8-DJ for qemu-devel@nongnu.org; Tue, 05 Mar 2024 07:10:40 -0500 Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-412e8c63f23so10146655e9.0 for ; Tue, 05 Mar 2024 04:10:17 -0800 (PST) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id u20-20020adfcb14000000b0033b7ce8b496sm14732205wrh.108.2024.03.05.04.10.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Mar 2024 04:10:12 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 9FDDD5F9D3; Tue, 5 Mar 2024 12:10:06 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1709640617; x=1710245417; 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=FBFGDsBcYD+JP9yYVswciAAzuKJ4opwX8kvXoDHdqq0=; b=qE5e/VwAT8kONqORRKFnYNJUHP0ghVUts/F9GxCp8d4KXkpACvADST+02ffd4OfHR2 4q/gSblilrIJHw4sDpenoukNgQXVaccmh7RR7pwlbsjFrHvtoSDLbkxSv4fao7KCYJ7+ wihU8HVd+YjhGuaA1E2N/eSPTFV+0MzmfHU87COOJalqTlMcaLszp3aCeAocAHWyDZce dYhBXcP5VFNKakt4b4gOM6p0Ng10f75viQW3Ro67MAhJl9i1Rwk2OT3p9+/dhuPn1KFP IPmgst+YGORKI/TKiPYu2TGACVPOHoVGcyA7fMo1POWLc7fuXhb0WQX66tybcml4ysDg qBjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709640617; x=1710245417; 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=FBFGDsBcYD+JP9yYVswciAAzuKJ4opwX8kvXoDHdqq0=; b=RylM2vLFiDWSK7ASVdim/S/x11rSX18Hyvk3bdIyb5oqW8eHxxJkKsY/7+x7t7uF0b n5pdI5c3AD1ovMze/GS+Ba8uchMH5AMYdM+DBuUMNh1u2zbSpgOEWr3HsWed1wnFdhCj S6+pRPv5YTtnDTSI06tiMShkFPr46xc+/Qhi7X/ed+2HcdiiRoaqwlZSKZiGIrYhqDX9 BN2SxcUCXY0wF01oMIoi1yqoyucKC4eFI0VhjVsoTxD67oS2kbVyvttyMS8SOFvjLXZu AjG0iQ213YbtGVEhpzTy1tinAbZvc1V13CQ6GI1XmQsdHRgoegSnnqA3bDrU0WTdKjlx hi3A== X-Gm-Message-State: AOJu0YxSeSyy0KzIqmkkHHruFeFv8618XWyHfIBNZTyi9/MgYBV/akNN mXnZSrhg17yNhGgJRjFxztY8mFegxUkuVQMWpEb3OXtxqfPptifJ6eqpvXuaZ0o= X-Google-Smtp-Source: AGHT+IHims0YVu0GdqE5LnWHhikrSCK/ucLVqfvhymbwIXB42724DOEZ1ysUvwWkLQ7sPlQRaafPEg== X-Received: by 2002:a05:600c:1c9c:b0:412:e675:f807 with SMTP id k28-20020a05600c1c9c00b00412e675f807mr2966432wms.31.1709640616665; Tue, 05 Mar 2024 04:10:16 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Wainer dos Santos Moschetta , Alistair Francis , Nicholas Piggin , Liu Zhiwei , Richard Henderson , Yanan Wang , qemu-s390x@nongnu.org, "Edgar E. Iglesias" , Eduardo Habkost , Daniel Henrique Barboza , Michael Rolnik , Daniel Henrique Barboza , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Laurent Vivier , Yoshinori Sato , Laurent Vivier , Thomas Huth , Peter Maydell , Mahmoud Mandour , Brad Smith , Alistair Francis , Brian Cain , Cleber Rosa , John Snow , Marcel Apfelbaum , Pierrick Bouvier , Palmer Dabbelt , Riku Voipio , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, Weiwei Li , Bin Meng , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Beraldo Leal , Kyle Evans , David Hildenbrand , Song Gao , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Paolo Bonzini , Alexandre Iooss , Warner Losh , qemu-riscv@nongnu.org, Ilya Leoshkevich Subject: [PATCH 12/29] gdbstub: Implement follow-fork-mode child Date: Tue, 5 Mar 2024 12:09:48 +0000 Message-Id: <20240305121005.3528075-13-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240305121005.3528075-1-alex.bennee@linaro.org> References: <20240305121005.3528075-1-alex.bennee@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=alex.bennee@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, T_SCC_BODY_TEXT_LINE=-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: 1709641083431100003 From: Ilya Leoshkevich Currently it's not possible to use gdbstub for debugging linux-user code that runs in a forked child, which is normally done using the `set follow-fork-mode child` GDB command. Purely on the protocol level, the missing piece is the fork-events feature. However, a deeper problem is supporting $Hg switching between different processes - right now it can do only threads. Implementing this for the general case would be quite complicated, but, fortunately, for the follow-fork-mode case there are a few factors that greatly simplify things: fork() happens in the exclusive section, there are only two processes involved, and before one of them is resumed, the second one is detached. This makes it possible to implement a simplified scheme: the parent and the child share the gdbserver socket, it's used only by one of them at any given time, which is coordinated through a separate socketpair. The processes can read from the gdbserver socket only one byte at a time, which is not great for performance, but, fortunately, the follow-fork-mode handling involves only a few messages. Advertise the fork-events support, and remember whether GDB has it as well. Implement the state machine that is initialized on fork(), decides the current owner of the gdbserver socket, and is terminated when one of the two processes is detached. The logic for the parent and the child is the same, only the initial state is different. Signed-off-by: Ilya Leoshkevich Message-Id: <20240219141628.246823-12-iii@linux.ibm.com> Signed-off-by: Alex Benn=C3=A9e --- gdbstub/user.c | 212 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 210 insertions(+), 2 deletions(-) diff --git a/gdbstub/user.c b/gdbstub/user.c index 1a7b582a40d..7f9f19a1249 100644 --- a/gdbstub/user.c +++ b/gdbstub/user.c @@ -25,6 +25,61 @@ #define GDB_NR_SYSCALLS 1024 typedef unsigned long GDBSyscallsMask[BITS_TO_LONGS(GDB_NR_SYSCALLS)]; =20 +/* + * Forked child talks to its parent in order to let GDB enforce the + * follow-fork-mode. This happens inside a start_exclusive() section, so t= hat + * the other threads, which may be forking too, do not interfere. The + * implementation relies on GDB not sending $vCont until it has detached + * either from the parent (follow-fork-mode child) or from the child + * (follow-fork-mode parent). + * + * The parent and the child share the GDB socket; at any given time only o= ne + * of them is allowed to use it, as is reflected in the respective fork_st= ate. + * This is negotiated via the fork_sockets pair as a reaction to $Hg. + * + * Below is a short summary of the possible state transitions: + * + * ENABLED : Terminal state. + * DISABLED : Terminal state. + * ACTIVE : Parent initial state. + * INACTIVE : Child initial state. + * ACTIVE -> DEACTIVATING: On $Hg. + * ACTIVE -> ENABLING : On $D. + * ACTIVE -> DISABLING : On $D. + * ACTIVE -> DISABLED : On communication error. + * DEACTIVATING -> INACTIVE : On gdb_read_byte() return. + * DEACTIVATING -> DISABLED : On communication error. + * INACTIVE -> ACTIVE : On $Hg in the peer. + * INACTIVE -> ENABLE : On $D in the peer. + * INACTIVE -> DISABLE : On $D in the peer. + * INACTIVE -> DISABLED : On communication error. + * ENABLING -> ENABLED : On gdb_read_byte() return. + * ENABLING -> DISABLED : On communication error. + * DISABLING -> DISABLED : On gdb_read_byte() return. + */ +enum GDBForkState { + /* Fully owning the GDB socket. */ + GDB_FORK_ENABLED, + /* Working with the GDB socket; the peer is inactive. */ + GDB_FORK_ACTIVE, + /* Handing off the GDB socket to the peer. */ + GDB_FORK_DEACTIVATING, + /* The peer is working with the GDB socket. */ + GDB_FORK_INACTIVE, + /* Asking the peer to close its GDB socket fd. */ + GDB_FORK_ENABLING, + /* Asking the peer to take over, closing our GDB socket fd. */ + GDB_FORK_DISABLING, + /* The peer has taken over, our GDB socket fd is closed. */ + GDB_FORK_DISABLED, +}; + +enum GDBForkMessage { + GDB_FORK_ACTIVATE =3D 'a', + GDB_FORK_ENABLE =3D 'e', + GDB_FORK_DISABLE =3D 'd', +}; + /* User-mode specific state */ typedef struct { int fd; @@ -36,6 +91,10 @@ typedef struct { */ bool catch_all_syscalls; GDBSyscallsMask catch_syscalls_mask; + bool fork_events; + enum GDBForkState fork_state; + int fork_sockets[2]; + pid_t fork_peer_pid, fork_peer_tid; } GDBUserState; =20 static GDBUserState gdbserver_user_state; @@ -358,6 +417,18 @@ int gdbserver_start(const char *port_or_path) =20 void gdbserver_fork_start(void) { + if (!gdbserver_state.init || gdbserver_user_state.fd < 0) { + return; + } + if (!gdbserver_user_state.fork_events || + qemu_socketpair(AF_UNIX, SOCK_STREAM, 0, + gdbserver_user_state.fork_sockets) < 0) { + gdbserver_user_state.fork_state =3D GDB_FORK_DISABLED; + return; + } + gdbserver_user_state.fork_state =3D GDB_FORK_INACTIVE; + gdbserver_user_state.fork_peer_pid =3D getpid(); + gdbserver_user_state.fork_peer_tid =3D qemu_get_thread_id(); } =20 static void disable_gdbstub(CPUState *thread_cpu) @@ -376,23 +447,160 @@ static void disable_gdbstub(CPUState *thread_cpu) =20 void gdbserver_fork_end(CPUState *cpu, pid_t pid) { - if (pid !=3D 0 || !gdbserver_state.init || gdbserver_user_state.fd < 0= ) { + char b; + int fd; + + if (!gdbserver_state.init || gdbserver_user_state.fd < 0) { return; } - disable_gdbstub(cpu); + + if (pid =3D=3D -1) { + if (gdbserver_user_state.fork_state !=3D GDB_FORK_DISABLED) { + g_assert(gdbserver_user_state.fork_state =3D=3D GDB_FORK_INACT= IVE); + close(gdbserver_user_state.fork_sockets[0]); + close(gdbserver_user_state.fork_sockets[1]); + } + return; + } + + if (gdbserver_user_state.fork_state =3D=3D GDB_FORK_DISABLED) { + if (pid =3D=3D 0) { + disable_gdbstub(cpu); + } + return; + } + + if (pid =3D=3D 0) { + close(gdbserver_user_state.fork_sockets[0]); + fd =3D gdbserver_user_state.fork_sockets[1]; + g_assert(gdbserver_state.process_num =3D=3D 1); + g_assert(gdbserver_state.processes[0].pid =3D=3D + gdbserver_user_state.fork_peer_pid); + g_assert(gdbserver_state.processes[0].attached); + gdbserver_state.processes[0].pid =3D getpid(); + } else { + close(gdbserver_user_state.fork_sockets[1]); + fd =3D gdbserver_user_state.fork_sockets[0]; + gdbserver_user_state.fork_state =3D GDB_FORK_ACTIVE; + gdbserver_user_state.fork_peer_pid =3D pid; + gdbserver_user_state.fork_peer_tid =3D pid; + + if (!gdbserver_state.allow_stop_reply) { + goto fail; + } + g_string_printf(gdbserver_state.str_buf, + "T%02xfork:p%02x.%02x;thread:p%02x.%02x;", + gdb_target_signal_to_gdb(gdb_target_sigtrap()), + pid, pid, (int)getpid(), qemu_get_thread_id()); + gdb_put_strbuf(); + } + + gdbserver_state.state =3D RS_IDLE; + gdbserver_state.allow_stop_reply =3D false; + gdbserver_user_state.running_state =3D 0; + for (;;) { + switch (gdbserver_user_state.fork_state) { + case GDB_FORK_ENABLED: + if (gdbserver_user_state.running_state) { + return; + } + QEMU_FALLTHROUGH; + case GDB_FORK_ACTIVE: + if (read(gdbserver_user_state.fd, &b, 1) !=3D 1) { + goto fail; + } + gdb_read_byte(b); + break; + case GDB_FORK_DEACTIVATING: + b =3D GDB_FORK_ACTIVATE; + if (write(fd, &b, 1) !=3D 1) { + goto fail; + } + gdbserver_user_state.fork_state =3D GDB_FORK_INACTIVE; + break; + case GDB_FORK_INACTIVE: + if (read(fd, &b, 1) !=3D 1) { + goto fail; + } + switch (b) { + case GDB_FORK_ACTIVATE: + gdbserver_user_state.fork_state =3D GDB_FORK_ACTIVE; + break; + case GDB_FORK_ENABLE: + close(fd); + gdbserver_user_state.fork_state =3D GDB_FORK_ENABLED; + break; + case GDB_FORK_DISABLE: + gdbserver_user_state.fork_state =3D GDB_FORK_DISABLED; + break; + default: + g_assert_not_reached(); + } + break; + case GDB_FORK_ENABLING: + b =3D GDB_FORK_DISABLE; + if (write(fd, &b, 1) !=3D 1) { + goto fail; + } + close(fd); + gdbserver_user_state.fork_state =3D GDB_FORK_ENABLED; + break; + case GDB_FORK_DISABLING: + b =3D GDB_FORK_ENABLE; + if (write(fd, &b, 1) !=3D 1) { + goto fail; + } + gdbserver_user_state.fork_state =3D GDB_FORK_DISABLED; + break; + case GDB_FORK_DISABLED: + close(fd); + disable_gdbstub(cpu); + return; + default: + g_assert_not_reached(); + } + } + +fail: + close(fd); + if (pid =3D=3D 0) { + disable_gdbstub(cpu); + } } =20 void gdb_handle_query_supported_user(const char *gdb_supported) { + if (strstr(gdb_supported, "fork-events+")) { + gdbserver_user_state.fork_events =3D true; + } + g_string_append(gdbserver_state.str_buf, ";fork-events+"); } =20 bool gdb_handle_set_thread_user(uint32_t pid, uint32_t tid) { + if (gdbserver_user_state.fork_state =3D=3D GDB_FORK_ACTIVE && + pid =3D=3D gdbserver_user_state.fork_peer_pid && + tid =3D=3D gdbserver_user_state.fork_peer_tid) { + gdbserver_user_state.fork_state =3D GDB_FORK_DEACTIVATING; + gdb_put_packet("OK"); + return true; + } return false; } =20 bool gdb_handle_detach_user(uint32_t pid) { + bool enable; + + if (gdbserver_user_state.fork_state =3D=3D GDB_FORK_ACTIVE) { + enable =3D pid =3D=3D gdbserver_user_state.fork_peer_pid; + if (enable || pid =3D=3D getpid()) { + gdbserver_user_state.fork_state =3D enable ? GDB_FORK_ENABLING= : + GDB_FORK_DISABLING; + gdb_put_packet("OK"); + return true; + } + } return false; } =20 --=20 2.39.2 From nobody Tue Nov 26 04:50:37 2024 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=1709641077; cv=none; d=zohomail.com; s=zohoarc; b=JdFb7bMdI/aKqnD5SWfiPDlNCCA2tVUjj5gZNVeGHEOQSRC7kd9q04mDayK0EYAzkJv0qyZsJdNiKy1LC7V1ifFCYz0GinOXB5a3V0lf+CpK0aD1k6iSFde+btCLmw1FngbBdrq9AV/gAlix7K7MZVu0cqZCL5yyjLjw4gR7Qug= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709641077; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=WooNzOV/us8bLuMeAwrWGnmqqnwveEN5CVxp1t3KKRI=; b=IMhaWuhsS782A9KJrOWKnBhlzIP5YfOhJnUMQ+UX96R86V27rRgXhdASB8ftxBxFaUhbPic78OR8E2p5WaVN5QCvwTw8N5lMhG20IxseDcGxxE8L1wu+fy175/WWHhvjSGJmmS4Zh462vWEdWoc6sWT8JtSLgFBgMDNGbTvI3Cs= 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 1709641077616529.069397395678; Tue, 5 Mar 2024 04:17:57 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rhTeb-0004V9-TJ; Tue, 05 Mar 2024 07:12:17 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rhTdL-0001wH-PB for qemu-devel@nongnu.org; Tue, 05 Mar 2024 07:11:04 -0500 Received: from mail-wr1-x434.google.com ([2a00:1450:4864:20::434]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rhTch-0001UI-Vz for qemu-devel@nongnu.org; Tue, 05 Mar 2024 07:10:57 -0500 Received: by mail-wr1-x434.google.com with SMTP id ffacd0b85a97d-33e2268ed96so3532900f8f.3 for ; Tue, 05 Mar 2024 04:10:19 -0800 (PST) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id f10-20020a5d58ea000000b0033d4cf751b2sm14731989wrd.33.2024.03.05.04.10.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Mar 2024 04:10:12 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id B6EA15F9DA; Tue, 5 Mar 2024 12:10:06 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1709640618; x=1710245418; 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=WooNzOV/us8bLuMeAwrWGnmqqnwveEN5CVxp1t3KKRI=; b=ewhbZIQa42obNozwJyQmBs70PDQ1JmFoxR5gSo0sbtIn6lbPgkTcTlhPwX7ZtuWJ6I aJC2+ofUmMi2iOehRDiP/6oQjS+O+4MpslM/ILkrGEXWZ2XLZeH8xiOAFYytdbM0lK2M eAdHfJ9DyjZsmKpnndqOQzeuW8iTxloxU4mrf2scIEQPtzLq+oBXTpVLc8UiB8IGB2lc EN5Hlf7JLWz62/08Ci0qbAFxdFI+TXRoBIrfnMd8U+9tlErnOJthYKT7AJAli9OUUM8L vt8q6nnR59cEacKeeuPRgWNLon6PWXMgZ7baZ9mDY1Ala0a4Fm7udCI+hXM3+c7iv9Mv /hdA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709640618; x=1710245418; 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=WooNzOV/us8bLuMeAwrWGnmqqnwveEN5CVxp1t3KKRI=; b=Ynwg7GVRyoPjU4erHtIG4oiQ3xLBxJmSD2aK9nJwzOn7ET6q3NtB2dAdiostM2pbwX v5zT9zucmG1uLG4YxPA68bdn7/49RxXEMgjwdaeJBa5fjk59ZcNxh4zh9xJfUJaS8egb 5RQQQ3Sx1hXhRxxMsoq8XrYZFWlkI+OJx1A5GLYJ53Edk2LCD96Z9dUQk9pIBKD28UNM 9b4KjlAF6mj9xGoZwEb44tomHfBl4QErg2tADCfHQHZeFPhCy1lmPWviLn2E2UruW8HZ TVnEmCvApDX0NPIJWbC0JPkT/wnkIC6K9g9O30OuFhLR3NviD8vyz8lWgnOffo2lvt89 No3w== X-Gm-Message-State: AOJu0YzAKtsWfTwolJUZ1fiVY+lDkVEpUSvBw+XWzSVzDAZw+O1jhsoZ 2IXHc0y5xS0xidB/ss4hXvNtEbE6uL5G3VZ4DCjNNAIJjRf5G9r3bK8Dr8fGC5A= X-Google-Smtp-Source: AGHT+IH/bFZkJLW9C0nEA6geVUtEWC+DP7m7ABlvX9K83JZCZItT7nWbkFN3prZoThSKDfhWw1SWAw== X-Received: by 2002:a5d:6986:0:b0:33d:d792:c7c7 with SMTP id g6-20020a5d6986000000b0033dd792c7c7mr7907924wru.10.1709640618264; Tue, 05 Mar 2024 04:10:18 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Wainer dos Santos Moschetta , Alistair Francis , Nicholas Piggin , Liu Zhiwei , Richard Henderson , Yanan Wang , qemu-s390x@nongnu.org, "Edgar E. Iglesias" , Eduardo Habkost , Daniel Henrique Barboza , Michael Rolnik , Daniel Henrique Barboza , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Laurent Vivier , Yoshinori Sato , Laurent Vivier , Thomas Huth , Peter Maydell , Mahmoud Mandour , Brad Smith , Alistair Francis , Brian Cain , Cleber Rosa , John Snow , Marcel Apfelbaum , Pierrick Bouvier , Palmer Dabbelt , Riku Voipio , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, Weiwei Li , Bin Meng , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Beraldo Leal , Kyle Evans , David Hildenbrand , Song Gao , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Paolo Bonzini , Alexandre Iooss , Warner Losh , qemu-riscv@nongnu.org, Ilya Leoshkevich Subject: [PATCH 13/29] tests/tcg: Add two follow-fork-mode tests Date: Tue, 5 Mar 2024 12:09:49 +0000 Message-Id: <20240305121005.3528075-14-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240305121005.3528075-1-alex.bennee@linaro.org> References: <20240305121005.3528075-1-alex.bennee@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=alex.bennee@linaro.org; helo=mail-wr1-x434.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-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: 1709641079354100007 From: Ilya Leoshkevich Add follow-fork-mode child and and follow-fork-mode parent tests. Check for the obvious pitfalls, such as lingering breakpoints, catchpoints, and single-step mode. Signed-off-by: Ilya Leoshkevich Message-Id: <20240219141628.246823-13-iii@linux.ibm.com> Signed-off-by: Alex Benn=C3=A9e --- tests/tcg/multiarch/follow-fork-mode.c | 56 +++++++++++++++++++ tests/tcg/multiarch/Makefile.target | 17 +++++- .../gdbstub/follow-fork-mode-child.py | 40 +++++++++++++ .../gdbstub/follow-fork-mode-parent.py | 16 ++++++ 4 files changed, 128 insertions(+), 1 deletion(-) create mode 100644 tests/tcg/multiarch/follow-fork-mode.c create mode 100644 tests/tcg/multiarch/gdbstub/follow-fork-mode-child.py create mode 100644 tests/tcg/multiarch/gdbstub/follow-fork-mode-parent.py diff --git a/tests/tcg/multiarch/follow-fork-mode.c b/tests/tcg/multiarch/f= ollow-fork-mode.c new file mode 100644 index 00000000000..cb6b032b388 --- /dev/null +++ b/tests/tcg/multiarch/follow-fork-mode.c @@ -0,0 +1,56 @@ +/* + * Test GDB's follow-fork-mode. + * + * fork() a chain of processes. + * Parents sends one byte to their children, and children return their + * position in the chain, in order to prove that they survived GDB's fork() + * handling. + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ +#include +#include +#include +#include + +void break_after_fork(void) +{ +} + +int main(void) +{ + int depth =3D 42, err, i, fd[2], status; + pid_t child, pid; + ssize_t n; + char b; + + for (i =3D 0; i < depth; i++) { + err =3D pipe(fd); + assert(err =3D=3D 0); + child =3D fork(); + break_after_fork(); + assert(child !=3D -1); + if (child =3D=3D 0) { + close(fd[1]); + + n =3D read(fd[0], &b, 1); + close(fd[0]); + assert(n =3D=3D 1); + assert(b =3D=3D (char)i); + } else { + close(fd[0]); + + b =3D (char)i; + n =3D write(fd[1], &b, 1); + close(fd[1]); + assert(n =3D=3D 1); + + pid =3D waitpid(child, &status, 0); + assert(pid =3D=3D child); + assert(WIFEXITED(status)); + return WEXITSTATUS(status) - 1; + } + } + + return depth; +} diff --git a/tests/tcg/multiarch/Makefile.target b/tests/tcg/multiarch/Make= file.target index f11f3b084d7..979a0dd1bc2 100644 --- a/tests/tcg/multiarch/Makefile.target +++ b/tests/tcg/multiarch/Makefile.target @@ -106,6 +106,20 @@ run-gdbstub-catch-syscalls: catch-syscalls --bin $< --test $(MULTIARCH_SRC)/gdbstub/catch-syscalls.py, \ hitting a syscall catchpoint) =20 +run-gdbstub-follow-fork-mode-child: follow-fork-mode + $(call run-test, $@, $(GDB_SCRIPT) \ + --gdb $(GDB) \ + --qemu $(QEMU) --qargs "$(QEMU_OPTS)" \ + --bin $< --test $(MULTIARCH_SRC)/gdbstub/follow-fork-mode-child.py, \ + following children on fork) + +run-gdbstub-follow-fork-mode-parent: follow-fork-mode + $(call run-test, $@, $(GDB_SCRIPT) \ + --gdb $(GDB) \ + --qemu $(QEMU) --qargs "$(QEMU_OPTS)" \ + --bin $< --test $(MULTIARCH_SRC)/gdbstub/follow-fork-mode-parent.py, \ + following parents on fork) + else run-gdbstub-%: $(call skip-test, "gdbstub test $*", "need working gdb with $(patsubst -%= ,,$(TARGET_NAME)) support") @@ -113,7 +127,8 @@ endif EXTRA_RUNS +=3D run-gdbstub-sha1 run-gdbstub-qxfer-auxv-read \ run-gdbstub-proc-mappings run-gdbstub-thread-breakpoint \ run-gdbstub-registers run-gdbstub-prot-none \ - run-gdbstub-catch-syscalls + run-gdbstub-catch-syscalls run-gdbstub-follow-fork-mode-child \ + run-gdbstub-follow-fork-mode-parent =20 # ARM Compatible Semi Hosting Tests # diff --git a/tests/tcg/multiarch/gdbstub/follow-fork-mode-child.py b/tests/= tcg/multiarch/gdbstub/follow-fork-mode-child.py new file mode 100644 index 00000000000..72a6e440c08 --- /dev/null +++ b/tests/tcg/multiarch/gdbstub/follow-fork-mode-child.py @@ -0,0 +1,40 @@ +"""Test GDB's follow-fork-mode child. + +SPDX-License-Identifier: GPL-2.0-or-later +""" +from test_gdbstub import main, report + + +def run_test(): + """Run through the tests one by one""" + gdb.execute("set follow-fork-mode child") + # Check that the parent breakpoints are unset. + gdb.execute("break break_after_fork") + # Check that the parent syscall catchpoints are unset. + # Skip this check on the architectures that don't have them. + have_fork_syscall =3D False + for fork_syscall in ("fork", "clone", "clone2", "clone3"): + try: + gdb.execute("catch syscall {}".format(fork_syscall)) + except gdb.error: + pass + else: + have_fork_syscall =3D True + gdb.execute("continue") + for i in range(42): + if have_fork_syscall: + # syscall entry. + if i % 2 =3D=3D 0: + # Check that the parent single-stepping is turned off. + gdb.execute("si") + else: + gdb.execute("continue") + # syscall exit. + gdb.execute("continue") + # break_after_fork() + gdb.execute("continue") + exitcode =3D int(gdb.parse_and_eval("$_exitcode")) + report(exitcode =3D=3D 42, "{} =3D=3D 42".format(exitcode)) + + +main(run_test) diff --git a/tests/tcg/multiarch/gdbstub/follow-fork-mode-parent.py b/tests= /tcg/multiarch/gdbstub/follow-fork-mode-parent.py new file mode 100644 index 00000000000..5c2fe722088 --- /dev/null +++ b/tests/tcg/multiarch/gdbstub/follow-fork-mode-parent.py @@ -0,0 +1,16 @@ +"""Test GDB's follow-fork-mode parent. + +SPDX-License-Identifier: GPL-2.0-or-later +""" +from test_gdbstub import main, report + + +def run_test(): + """Run through the tests one by one""" + gdb.execute("set follow-fork-mode parent") + gdb.execute("continue") + exitcode =3D int(gdb.parse_and_eval("$_exitcode")) + report(exitcode =3D=3D 0, "{} =3D=3D 0".format(exitcode)) + + +main(run_test) --=20 2.39.2 From nobody Tue Nov 26 04:50:37 2024 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=1709641053; cv=none; d=zohomail.com; s=zohoarc; b=JD8uNNiUy66oIy4BT2i8QO2n3dKL3ADypUX/Ch3A4o+mkS3ppLSskaqqA7jgr9xJs709WU6DH8L4cKaNcYkNHta9/knsbzomNxu2lQQ2RTVEUgsG1MzF2pZYa9eWZfsMB8JuvJrwFNIHxnsKVsNb89SaPpthO4HEFt0SXI4h0c4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709641053; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=VG+vqVHI2D8wuj5SiQHhSx5sLWIahnozHpwqdxtQshU=; b=OXGXGonScACR74jw9j1NSll775V7GEGjeC6s1mC2zxeG9vtytVN1A4DyXJwqZ/Dxs3simEaMjK/XqJUt+esw/ZDwghjJfhbjHrHaDxB+97y0tnLXfFyG47/iTWoFBWBTJvT2hVvo4MgX2saPoMaqyv9/HjsyFDqe++J4lIvQqtc= 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 1709641053470871.0990679917052; Tue, 5 Mar 2024 04:17:33 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rhTeA-0003K7-Ez; Tue, 05 Mar 2024 07:11:50 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rhTdL-0001wJ-RP for qemu-devel@nongnu.org; Tue, 05 Mar 2024 07:11:04 -0500 Received: from mail-lj1-x235.google.com ([2a00:1450:4864:20::235]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rhTch-0001Sn-Im for qemu-devel@nongnu.org; Tue, 05 Mar 2024 07:10:57 -0500 Received: by mail-lj1-x235.google.com with SMTP id 38308e7fff4ca-2d3f962a9dfso1389221fa.1 for ; Tue, 05 Mar 2024 04:10:18 -0800 (PST) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id d7-20020adf9c87000000b0033d640c8942sm14870192wre.10.2024.03.05.04.10.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Mar 2024 04:10:12 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id D029E5F9DE; Tue, 5 Mar 2024 12:10:06 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1709640616; x=1710245416; 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=VG+vqVHI2D8wuj5SiQHhSx5sLWIahnozHpwqdxtQshU=; b=k9VYLTJHcMSt7lJHxnp5NHbHU/ASoXrvFu/4CEP1nQA8u3HtmJL/uO+RfPdIwHANMt saJhf2MCdiKFfrN3aOhdDgSADWO0qqHWRHA1jz3ZqTaGJXcuelYpw9+CQSWvT4P0IaPp oOx1MuDoYvGEGatoPdKQoPiodBY0gwCEuootQWzs/Jh1aLznvmxMYLke1411AbqGdmsO JCgzLF8MtFilGWwzG0L5yTyhqOtLkFXmPlGcbYfcoJpb7rcoFXWKNKdEg2Uhx2JB/ifc p4vNHTunk8o9Vke/G0GAVT21Txp0+pPscSZqX07KrVSzkvb3JgtUI0w0k+uTLm3tITI/ tpHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709640616; x=1710245416; 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=VG+vqVHI2D8wuj5SiQHhSx5sLWIahnozHpwqdxtQshU=; b=kCU5UXn8dBl+P5P380lBN9P5ZaBk4MaQXZkaWndBAAQjnADcGbPQ1lbnK/cggEHcKD 5vNukwJs/VBzexEL3knfhGvaUmPUauHY5PFk2qCjLgFtRNhY7v1UHpvHWGa+DHTBrot3 eQD4hjBiIlr/nKlEnwPy6VTrDcEURYswXeJY1FbdHGWSRv7FzjcDKR8NBAZX0LUOXJS+ dxPSUcPNpg1c3c9KwcZjUCpRbFANjVQftnAfMwPr8vvmQ6d9/Y7IH99OmAypGG0caAek j6P20lwFIWoap+9d8Z6YQoU/8Yo7YLSmARPIN3H7DPBPNbewrSzR2E5Z3y4rMYgmjhzN QoKQ== X-Gm-Message-State: AOJu0Yw9CELJXdeid3mK2jJkIxiwEEN04SiJM96EsOKqmdlW6e7G1Iwn hwemRG6+jrCBk3IG/cDRpr4Xsr4weQI32BYPm1WnsdKm4S8xzdbtkraWjnEgc/k= X-Google-Smtp-Source: AGHT+IHbLe9dOlxbowVsYb7gvtIWO+DzHonkmvTsNX+vIbGtpKbA/Y1Ai2t8AtXAboR/VoVHdJ0i8g== X-Received: by 2002:ac2:4306:0:b0:513:1cae:4783 with SMTP id l6-20020ac24306000000b005131cae4783mr1104721lfh.60.1709640616394; Tue, 05 Mar 2024 04:10:16 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Wainer dos Santos Moschetta , Alistair Francis , Nicholas Piggin , Liu Zhiwei , Richard Henderson , Yanan Wang , qemu-s390x@nongnu.org, "Edgar E. Iglesias" , Eduardo Habkost , Daniel Henrique Barboza , Michael Rolnik , Daniel Henrique Barboza , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Laurent Vivier , Yoshinori Sato , Laurent Vivier , Thomas Huth , Peter Maydell , Mahmoud Mandour , Brad Smith , Alistair Francis , Brian Cain , Cleber Rosa , John Snow , Marcel Apfelbaum , Pierrick Bouvier , Palmer Dabbelt , Riku Voipio , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, Weiwei Li , Bin Meng , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Beraldo Leal , Kyle Evans , David Hildenbrand , Song Gao , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Paolo Bonzini , Alexandre Iooss , Warner Losh , qemu-riscv@nongnu.org, Ilya Leoshkevich Subject: [PATCH 14/29] plugins: scoreboard API Date: Tue, 5 Mar 2024 12:09:50 +0000 Message-Id: <20240305121005.3528075-15-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240305121005.3528075-1-alex.bennee@linaro.org> References: <20240305121005.3528075-1-alex.bennee@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::235; envelope-from=alex.bennee@linaro.org; helo=mail-lj1-x235.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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1709641055272100003 From: Pierrick Bouvier We introduce a cpu local storage, automatically managed (and extended) by QEMU itself. Plugin allocate a scoreboard, and don't have to deal with how many cpus are launched. This API will be used by new inline functions but callbacks can benefit from this as well. This way, they can operate without a global lock for simple operations. At any point during execution, any scoreboard will be dimensioned with at least qemu_plugin_num_vcpus entries. New functions: - qemu_plugin_scoreboard_find - qemu_plugin_scoreboard_free - qemu_plugin_scoreboard_new Reviewed-by: Richard Henderson Signed-off-by: Pierrick Bouvier Message-Id: <20240304130036.124418-2-pierrick.bouvier@linaro.org> Signed-off-by: Alex Benn=C3=A9e --- include/qemu/plugin.h | 6 ++++ include/qemu/qemu-plugin.h | 31 ++++++++++++++++++++ plugins/plugin.h | 6 ++++ plugins/api.c | 19 ++++++++++++ plugins/core.c | 57 ++++++++++++++++++++++++++++++++++++ plugins/qemu-plugins.symbols | 3 ++ 6 files changed, 122 insertions(+) diff --git a/include/qemu/plugin.h b/include/qemu/plugin.h index b3c94a34aa4..bf96d2c2aa3 100644 --- a/include/qemu/plugin.h +++ b/include/qemu/plugin.h @@ -112,6 +112,12 @@ struct qemu_plugin_insn { bool mem_only; }; =20 +/* A scoreboard is an array of values, indexed by vcpu_index */ +struct qemu_plugin_scoreboard { + GArray *data; + QLIST_ENTRY(qemu_plugin_scoreboard) entry; +}; + /* * qemu_plugin_insn allocate and cleanup functions. We don't expect to * cleanup many of these structures. They are reused for each fresh diff --git a/include/qemu/qemu-plugin.h b/include/qemu/qemu-plugin.h index 45e2ebc8f8f..31c468ddb2c 100644 --- a/include/qemu/qemu-plugin.h +++ b/include/qemu/qemu-plugin.h @@ -222,6 +222,8 @@ void qemu_plugin_register_vcpu_resume_cb(qemu_plugin_id= _t id, struct qemu_plugin_tb; /** struct qemu_plugin_insn - Opaque handle for a translated instruction */ struct qemu_plugin_insn; +/** struct qemu_plugin_scoreboard - Opaque handle for a scoreboard */ +struct qemu_plugin_scoreboard; =20 /** * enum qemu_plugin_cb_flags - type of callback @@ -752,5 +754,34 @@ QEMU_PLUGIN_API int qemu_plugin_read_register(struct qemu_plugin_register *handle, GByteArray *buf); =20 +/** + * qemu_plugin_scoreboard_new() - alloc a new scoreboard + * + * @element_size: size (in bytes) for one entry + * + * Returns a pointer to a new scoreboard. It must be freed using + * qemu_plugin_scoreboard_free. + */ +QEMU_PLUGIN_API +struct qemu_plugin_scoreboard *qemu_plugin_scoreboard_new(size_t element_s= ize); + +/** + * qemu_plugin_scoreboard_free() - free a scoreboard + * @score: scoreboard to free + */ +QEMU_PLUGIN_API +void qemu_plugin_scoreboard_free(struct qemu_plugin_scoreboard *score); + +/** + * qemu_plugin_scoreboard_find() - get pointer to an entry of a scoreboard + * @score: scoreboard to query + * @vcpu_index: entry index + * + * Returns address of entry of a scoreboard matching a given vcpu_index. T= his + * address can be modified later if scoreboard is resized. + */ +QEMU_PLUGIN_API +void *qemu_plugin_scoreboard_find(struct qemu_plugin_scoreboard *score, + unsigned int vcpu_index); =20 #endif /* QEMU_QEMU_PLUGIN_H */ diff --git a/plugins/plugin.h b/plugins/plugin.h index 00b3509f708..043c740067d 100644 --- a/plugins/plugin.h +++ b/plugins/plugin.h @@ -31,6 +31,8 @@ struct qemu_plugin_state { * but with the HT we avoid adding a field to CPUState. */ GHashTable *cpu_ht; + QLIST_HEAD(, qemu_plugin_scoreboard) scoreboards; + size_t scoreboard_alloc_size; DECLARE_BITMAP(mask, QEMU_PLUGIN_EV_MAX); /* * @lock protects the struct as well as ctx->uninstalling. @@ -101,4 +103,8 @@ void exec_inline_op(struct qemu_plugin_dyn_cb *cb); =20 int plugin_num_vcpus(void); =20 +struct qemu_plugin_scoreboard *plugin_scoreboard_new(size_t element_size); + +void plugin_scoreboard_free(struct qemu_plugin_scoreboard *score); + #endif /* PLUGIN_H */ diff --git a/plugins/api.c b/plugins/api.c index e905e995bd6..76b2e652b9c 100644 --- a/plugins/api.c +++ b/plugins/api.c @@ -465,3 +465,22 @@ int qemu_plugin_read_register(struct qemu_plugin_regis= ter *reg, GByteArray *buf) =20 return gdb_read_register(current_cpu, buf, GPOINTER_TO_INT(reg)); } + +struct qemu_plugin_scoreboard *qemu_plugin_scoreboard_new(size_t element_s= ize) +{ + return plugin_scoreboard_new(element_size); +} + +void qemu_plugin_scoreboard_free(struct qemu_plugin_scoreboard *score) +{ + plugin_scoreboard_free(score); +} + +void *qemu_plugin_scoreboard_find(struct qemu_plugin_scoreboard *score, + unsigned int vcpu_index) +{ + g_assert(vcpu_index < qemu_plugin_num_vcpus()); + /* we can't use g_array_index since entry size is not statically known= */ + char *base_ptr =3D score->data->data; + return base_ptr + vcpu_index * g_array_get_element_size(score->data); +} diff --git a/plugins/core.c b/plugins/core.c index 2db4d31354b..63f4c6c6ce3 100644 --- a/plugins/core.c +++ b/plugins/core.c @@ -18,6 +18,7 @@ #include "qemu/lockable.h" #include "qemu/option.h" #include "qemu/plugin.h" +#include "qemu/queue.h" #include "qemu/rcu_queue.h" #include "qemu/xxhash.h" #include "qemu/rcu.h" @@ -215,6 +216,35 @@ CPUPluginState *qemu_plugin_create_vcpu_state(void) return g_new0(CPUPluginState, 1); } =20 +static void plugin_grow_scoreboards__locked(CPUState *cpu) +{ + if (cpu->cpu_index < plugin.scoreboard_alloc_size) { + return; + } + + bool need_realloc =3D FALSE; + while (cpu->cpu_index >=3D plugin.scoreboard_alloc_size) { + plugin.scoreboard_alloc_size *=3D 2; + need_realloc =3D TRUE; + } + + + if (!need_realloc || QLIST_EMPTY(&plugin.scoreboards)) { + /* nothing to do, we just updated sizes for future scoreboards */ + return; + } + + /* cpus must be stopped, as tb might still use an existing scoreboard.= */ + start_exclusive(); + struct qemu_plugin_scoreboard *score; + QLIST_FOREACH(score, &plugin.scoreboards, entry) { + g_array_set_size(score->data, plugin.scoreboard_alloc_size); + } + /* force all tb to be flushed, as scoreboard pointers were changed. */ + tb_flush(cpu); + end_exclusive(); +} + void qemu_plugin_vcpu_init_hook(CPUState *cpu) { bool success; @@ -225,6 +255,7 @@ void qemu_plugin_vcpu_init_hook(CPUState *cpu) success =3D g_hash_table_insert(plugin.cpu_ht, &cpu->cpu_index, &cpu->cpu_index); g_assert(success); + plugin_grow_scoreboards__locked(cpu); qemu_rec_mutex_unlock(&plugin.lock); =20 plugin_vcpu_cb__simple(cpu, QEMU_PLUGIN_EV_VCPU_INIT); @@ -578,6 +609,8 @@ static void __attribute__((__constructor__)) plugin_ini= t(void) qemu_rec_mutex_init(&plugin.lock); plugin.id_ht =3D g_hash_table_new(g_int64_hash, g_int64_equal); plugin.cpu_ht =3D g_hash_table_new(g_int_hash, g_int_equal); + QLIST_INIT(&plugin.scoreboards); + plugin.scoreboard_alloc_size =3D 16; /* avoid frequent reallocation */ QTAILQ_INIT(&plugin.ctxs); qht_init(&plugin.dyn_cb_arr_ht, plugin_dyn_cb_arr_cmp, 16, QHT_MODE_AUTO_RESIZE); @@ -588,3 +621,27 @@ int plugin_num_vcpus(void) { return plugin.num_vcpus; } + +struct qemu_plugin_scoreboard *plugin_scoreboard_new(size_t element_size) +{ + struct qemu_plugin_scoreboard *score =3D + g_malloc0(sizeof(struct qemu_plugin_scoreboard)); + score->data =3D g_array_new(FALSE, TRUE, element_size); + g_array_set_size(score->data, plugin.scoreboard_alloc_size); + + qemu_rec_mutex_lock(&plugin.lock); + QLIST_INSERT_HEAD(&plugin.scoreboards, score, entry); + qemu_rec_mutex_unlock(&plugin.lock); + + return score; +} + +void plugin_scoreboard_free(struct qemu_plugin_scoreboard *score) +{ + qemu_rec_mutex_lock(&plugin.lock); + QLIST_REMOVE(score, entry); + qemu_rec_mutex_unlock(&plugin.lock); + + g_array_free(score->data, TRUE); + g_free(score); +} diff --git a/plugins/qemu-plugins.symbols b/plugins/qemu-plugins.symbols index 27fe97239be..3f93e7d6b13 100644 --- a/plugins/qemu-plugins.symbols +++ b/plugins/qemu-plugins.symbols @@ -37,6 +37,9 @@ qemu_plugin_register_vcpu_tb_exec_inline; qemu_plugin_register_vcpu_tb_trans_cb; qemu_plugin_reset; + qemu_plugin_scoreboard_free; + qemu_plugin_scoreboard_find; + qemu_plugin_scoreboard_new; qemu_plugin_start_code; qemu_plugin_tb_get_insn; qemu_plugin_tb_n_insns; --=20 2.39.2 From nobody Tue Nov 26 04:50:37 2024 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=1709641121; cv=none; d=zohomail.com; s=zohoarc; b=hki7SEK0UxQ7Ja8pt6Mql/xWvQ1boG86Rw+gLV4W14qW/knaxMHfWq2n78CCPJVZfRkuPh6Og9ofqkvzdhk38ObjK8cMNI9LvhPq160BebYNXsncEigUe6UZUK4RBHpzXspfHq9kCC0th69Z9+K1v6/kWJgAPi5UwLSHKjjhNdI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709641121; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=UqNj0COIQuCCXg0hZT7WW42rxn79Q0Rei6wd0zzibZM=; b=jg+YwfHtU2WlaokGFBdOStnurddoKolQNYEIzMEGyo2GSr7Yb7ZN4vCQ9zlmv2rnnSGyR5D47TOgJDWNr1yrimMfoKvrAfcntKmUMokGpg0nxYyJur9Jc8pK078WMrMyQ0XdRR/3sR0pLXLTC7WemW4v9/2OnrMjIh1WUqN9G6M= 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 1709641121186705.5615896167453; Tue, 5 Mar 2024 04:18:41 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rhTeu-0006FW-Bm; Tue, 05 Mar 2024 07:12:36 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rhTdh-0002gy-Uk for qemu-devel@nongnu.org; Tue, 05 Mar 2024 07:11:22 -0500 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 1rhTcr-0001VG-Fg for qemu-devel@nongnu.org; Tue, 05 Mar 2024 07:11:20 -0500 Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-412de18edcaso17025045e9.3 for ; Tue, 05 Mar 2024 04:10:21 -0800 (PST) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id k40-20020a05600c1ca800b00412b643b5a3sm17627256wms.11.2024.03.05.04.10.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Mar 2024 04:10:16 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id E54B75F9DF; Tue, 5 Mar 2024 12:10:06 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1709640620; x=1710245420; 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=UqNj0COIQuCCXg0hZT7WW42rxn79Q0Rei6wd0zzibZM=; b=QEiKOBRz+cu1icMi/mXn8vteHRi2/VIxGbfHCbDcSSFWUcPDqZJh/Mt2dC5fNZ9r/2 u5fMltc7OApY5sHa/d4FEw4GoYkRP4BlV6JRvmgRE3vMFuW4PdNL/bv2AtPyXVDasTD/ /ndXSaCQkh22Z1j2u94i7BJ/EuaabAZb1MajmT8oP1EOXbNtBMITTgRBeRmbgulz8SVk ygJ0sX4cZ2nhi0AZ84HQUvFgNkvaiE7ijOiNJhYVP++ObuXkNx88nvdfue1mw5jvLlhC o8Qy5dH1ZzyjUBGsn3wJSKPvC4HJsiC86vuoUPAtdbyRwzyfsCoYyseacCCrSB0VeH7t 46rA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709640620; x=1710245420; 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=UqNj0COIQuCCXg0hZT7WW42rxn79Q0Rei6wd0zzibZM=; b=ECONR1wCMzXzEPIotWRhT+tsqXyT58X22QKycDsOLZypo/CUVEQ5BsdiqpS/a9Q0S0 Czpjrs/H47wvFqCzpVfXVbE6fajpFzXh8+VDLjOOK1eL/8qdQJonUuJRh0FsgtT4FcWJ g0FdtGqDoHAVcIpDQDq60Rm1nuNazaLgANZGkzzegZduNgqAmDGzwI7zexYRi5Qab6W9 xop5lrwaqomZjpGzLEFzDHyuTw2u8O7CMmGGGzUGEdWbGwH8bBtQlLn2Iy44YnJBrXvy MmCN2v56XUcXg6BLhxyaA8u0oztOA9MDalU/9dZIk0ARwDXqg/+faffprbFluSWbNdl0 zI5Q== X-Gm-Message-State: AOJu0Yy7p0IUxP7MMlu5URD51aBXVx+YiSGyufKKGsb4pBobKpVV4EWS QS6zEC4ub4gNi6UlPnjtr1MfrMaB6znZ8jZXjfjrL4oTijNKmp2Xp7TwpskykzE= X-Google-Smtp-Source: AGHT+IEqVG6j+NSW1otiPJgcGPmMZvnShCR4A9sLFt8NX4RKuQuujLXaq43uqssyg5ssOHVIvgapgA== X-Received: by 2002:a05:600c:1546:b0:412:e7e1:b5c with SMTP id f6-20020a05600c154600b00412e7e10b5cmr2930430wmg.15.1709640620050; Tue, 05 Mar 2024 04:10:20 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Wainer dos Santos Moschetta , Alistair Francis , Nicholas Piggin , Liu Zhiwei , Richard Henderson , Yanan Wang , qemu-s390x@nongnu.org, "Edgar E. Iglesias" , Eduardo Habkost , Daniel Henrique Barboza , Michael Rolnik , Daniel Henrique Barboza , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Laurent Vivier , Yoshinori Sato , Laurent Vivier , Thomas Huth , Peter Maydell , Mahmoud Mandour , Brad Smith , Alistair Francis , Brian Cain , Cleber Rosa , John Snow , Marcel Apfelbaum , Pierrick Bouvier , Palmer Dabbelt , Riku Voipio , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, Weiwei Li , Bin Meng , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Beraldo Leal , Kyle Evans , David Hildenbrand , Song Gao , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Paolo Bonzini , Alexandre Iooss , Warner Losh , qemu-riscv@nongnu.org, Ilya Leoshkevich Subject: [PATCH 15/29] plugins: define qemu_plugin_u64 Date: Tue, 5 Mar 2024 12:09:51 +0000 Message-Id: <20240305121005.3528075-16-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240305121005.3528075-1-alex.bennee@linaro.org> References: <20240305121005.3528075-1-alex.bennee@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::32a; envelope-from=alex.bennee@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, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1709641123521100003 From: Pierrick Bouvier Additionally to the scoreboard, we define a qemu_plugin_u64, which is a simple struct holding a pointer to a scoreboard, and a given offset. This allows to have a scoreboard containing structs, without having to bring offset to operate on a specific field. Since most of the plugins are simply collecting a sum of per-cpu values, qemu_plugin_u64 directly support this operation as well. All inline operations defined later will use a qemu_plugin_u64 as input. New functions: - qemu_plugin_u64_add - qemu_plugin_u64_get - qemu_plugin_u64_set - qemu_plugin_u64_sum New macros: - qemu_plugin_scoreboard_u64 - qemu_plugin_scoreboard_u64_in_struct Reviewed-by: Richard Henderson Signed-off-by: Pierrick Bouvier Message-Id: <20240304130036.124418-3-pierrick.bouvier@linaro.org> Signed-off-by: Alex Benn=C3=A9e --- include/qemu/qemu-plugin.h | 52 ++++++++++++++++++++++++++++++++++++ plugins/api.c | 34 +++++++++++++++++++++++ plugins/qemu-plugins.symbols | 4 +++ 3 files changed, 90 insertions(+) diff --git a/include/qemu/qemu-plugin.h b/include/qemu/qemu-plugin.h index 31c468ddb2c..ebf9a645e15 100644 --- a/include/qemu/qemu-plugin.h +++ b/include/qemu/qemu-plugin.h @@ -225,6 +225,17 @@ struct qemu_plugin_insn; /** struct qemu_plugin_scoreboard - Opaque handle for a scoreboard */ struct qemu_plugin_scoreboard; =20 +/** + * typedef qemu_plugin_u64 - uint64_t member of an entry in a scoreboard + * + * This field allows to access a specific uint64_t member in one given ent= ry, + * located at a specified offset. Inline operations expect this as entry. + */ +typedef struct { + struct qemu_plugin_scoreboard *score; + size_t offset; +} qemu_plugin_u64; + /** * enum qemu_plugin_cb_flags - type of callback * @@ -784,4 +795,45 @@ QEMU_PLUGIN_API void *qemu_plugin_scoreboard_find(struct qemu_plugin_scoreboard *score, unsigned int vcpu_index); =20 +/* Macros to define a qemu_plugin_u64 */ +#define qemu_plugin_scoreboard_u64(score) \ + (qemu_plugin_u64) {score, 0} +#define qemu_plugin_scoreboard_u64_in_struct(score, type, member) \ + (qemu_plugin_u64) {score, offsetof(type, member)} + +/** + * qemu_plugin_u64_add() - add a value to a qemu_plugin_u64 for a given vc= pu + * @entry: entry to query + * @vcpu_index: entry index + * @added: value to add + */ +QEMU_PLUGIN_API +void qemu_plugin_u64_add(qemu_plugin_u64 entry, unsigned int vcpu_index, + uint64_t added); + +/** + * qemu_plugin_u64_get() - get value of a qemu_plugin_u64 for a given vcpu + * @entry: entry to query + * @vcpu_index: entry index + */ +QEMU_PLUGIN_API +uint64_t qemu_plugin_u64_get(qemu_plugin_u64 entry, unsigned int vcpu_inde= x); + +/** + * qemu_plugin_u64_set() - set value of a qemu_plugin_u64 for a given vcpu + * @entry: entry to query + * @vcpu_index: entry index + * @val: new value + */ +QEMU_PLUGIN_API +void qemu_plugin_u64_set(qemu_plugin_u64 entry, unsigned int vcpu_index, + uint64_t val); + +/** + * qemu_plugin_u64_sum() - return sum of all vcpu entries in a scoreboard + * @entry: entry to sum + */ +QEMU_PLUGIN_API +uint64_t qemu_plugin_u64_sum(qemu_plugin_u64 entry); + #endif /* QEMU_QEMU_PLUGIN_H */ diff --git a/plugins/api.c b/plugins/api.c index 76b2e652b9c..8910cbb2c46 100644 --- a/plugins/api.c +++ b/plugins/api.c @@ -484,3 +484,37 @@ void *qemu_plugin_scoreboard_find(struct qemu_plugin_s= coreboard *score, char *base_ptr =3D score->data->data; return base_ptr + vcpu_index * g_array_get_element_size(score->data); } + +static uint64_t *plugin_u64_address(qemu_plugin_u64 entry, + unsigned int vcpu_index) +{ + char *ptr =3D qemu_plugin_scoreboard_find(entry.score, vcpu_index); + return (uint64_t *)(ptr + entry.offset); +} + +void qemu_plugin_u64_add(qemu_plugin_u64 entry, unsigned int vcpu_index, + uint64_t added) +{ + *plugin_u64_address(entry, vcpu_index) +=3D added; +} + +uint64_t qemu_plugin_u64_get(qemu_plugin_u64 entry, + unsigned int vcpu_index) +{ + return *plugin_u64_address(entry, vcpu_index); +} + +void qemu_plugin_u64_set(qemu_plugin_u64 entry, unsigned int vcpu_index, + uint64_t val) +{ + *plugin_u64_address(entry, vcpu_index) =3D val; +} + +uint64_t qemu_plugin_u64_sum(qemu_plugin_u64 entry) +{ + uint64_t total =3D 0; + for (int i =3D 0, n =3D qemu_plugin_num_vcpus(); i < n; ++i) { + total +=3D qemu_plugin_u64_get(entry, i); + } + return total; +} diff --git a/plugins/qemu-plugins.symbols b/plugins/qemu-plugins.symbols index 3f93e7d6b13..6204453d0fd 100644 --- a/plugins/qemu-plugins.symbols +++ b/plugins/qemu-plugins.symbols @@ -44,6 +44,10 @@ qemu_plugin_tb_get_insn; qemu_plugin_tb_n_insns; qemu_plugin_tb_vaddr; + qemu_plugin_u64_add; + qemu_plugin_u64_get; + qemu_plugin_u64_set; + qemu_plugin_u64_sum; qemu_plugin_uninstall; qemu_plugin_vcpu_for_each; }; --=20 2.39.2 From nobody Tue Nov 26 04:50:37 2024 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=1709641077; cv=none; d=zohomail.com; s=zohoarc; b=ZYCgbG42WazlQd4gdT8TruusflFLX6TuO0Gy/chfWaBJymWEBZ3U7nqtZnlhiuvQN31DKlNV53e1ZJm99pZEeyRl7+qBhmTgpnvWv6RKAq1G/kLSWc99xErTs2UbpcI2G7lT9LN+eCfhaZltcJ9GsglVuu3cGZEFhjMqC70vkeI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709641077; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=LZ5YOQP0/kNKuw0pdbpFKUIj/5LzNegIm91JdMI6gJ8=; b=V83XNkpjAufbymwm/B4Y+TGLiz2I5BUFu3LHIAstoEQdrn535rO1bivpxiwcUJsWigBasaDRE5QKhco9wKpnllw/ZgLdy5fcj1wzR9cYcM9pXLRVsAZgrlEXA6inwdfKxAjybfXbAFdNigY9ysNiGbHmz0CxnLJUFEtogQ7fWws= 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 1709641077818214.04912303251467; Tue, 5 Mar 2024 04:17:57 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rhTeo-0005je-EC; Tue, 05 Mar 2024 07:12:30 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rhTdR-0001zo-HQ for qemu-devel@nongnu.org; Tue, 05 Mar 2024 07:11:08 -0500 Received: from mail-lf1-x12d.google.com ([2a00:1450:4864:20::12d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rhTcm-0001VU-Ra for qemu-devel@nongnu.org; Tue, 05 Mar 2024 07:11:05 -0500 Received: by mail-lf1-x12d.google.com with SMTP id 2adb3069b0e04-512bde3d197so5474523e87.0 for ; Tue, 05 Mar 2024 04:10:21 -0800 (PST) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id n37-20020a05600c3ba500b00412e58be350sm5058355wms.1.2024.03.05.04.10.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Mar 2024 04:10:16 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 082A95F9E0; Tue, 5 Mar 2024 12:10:07 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1709640620; x=1710245420; 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=LZ5YOQP0/kNKuw0pdbpFKUIj/5LzNegIm91JdMI6gJ8=; b=FDWKB5wJ0B46M8XhSomsFIYqKAP/8X87qCKDqKtJpS4t0QZ+ANAPk6zPyp6FMxFIyH FabeG9DgbALr3X+e6/hd6peJ/BrpA1LM/C24UPHCdc/XPdYTbUol1wB0v8mBYU4lPQSm 1LDUzRpVzby4iZRgIuT3MVQwFg+QpiZbKK+8Q/NFfFStvOgoaX9mqGuiLNuPGfIK0KsS u+2X6On5S8Fma2l9UjJB7z3isH6Cd5G0AhYz4YkOX/+l9EsL/XMpGtswbc9g0uinuc7X psR1cditVXLKIZCmATV1s3lld0dL0OuHKTqP9TJ8eE1LcHjnrVgupcKaopbxD3x/SLOR rsRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709640620; x=1710245420; 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=LZ5YOQP0/kNKuw0pdbpFKUIj/5LzNegIm91JdMI6gJ8=; b=tx2xrjRRUznTez8K9ubqSzTMmYICNEmbjQHdzpolAsT68u4s1vX/YrzmAxTi5mBUhH MLxUKU1XJNoxioSXrlWYgo13WzFORe2pnGSPpIKbB1v343f1KK8FIFYKDMzaLN+ffCjp KJoXpgI6Il9S88EcBal7nOlpJYd38i1QSnx61TsmhH6tCN8hCcWJfqmT2YW2Guh6CQo0 ZxzRjjVQvTs/enZwkoFfY+E0595J+8IpHUl1vRsZ4DK7mfHaKyGuvs6yF83wbIoKK40s abspuxFPIxaBwiYZZQEIkI3hVHGXKUpipnGNC/Bt+FsexVIDkfhxYGMcII/8n3X03B2z I5Eg== X-Gm-Message-State: AOJu0YzDmGeFOPyaDEEq/qdausHwfAxRGdL1h+7K4FcRc7o2Zm29iedc NEo1WOIsocCfXROmxHSLgXvGt2rXiXMzzJqlV8GxsCqoSUdmLGJf+D3w1aJbNjQ= X-Google-Smtp-Source: AGHT+IEe/HVl4sVZaRhh3RJCWXaysR/Mhpi9KzKVehL9dMuH96z4xl/43q58BAFxTe8NY5QXZ3KpDw== X-Received: by 2002:a05:6512:3ba0:b0:513:3f16:25d6 with SMTP id g32-20020a0565123ba000b005133f1625d6mr1539795lfv.34.1709640619821; Tue, 05 Mar 2024 04:10:19 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Wainer dos Santos Moschetta , Alistair Francis , Nicholas Piggin , Liu Zhiwei , Richard Henderson , Yanan Wang , qemu-s390x@nongnu.org, "Edgar E. Iglesias" , Eduardo Habkost , Daniel Henrique Barboza , Michael Rolnik , Daniel Henrique Barboza , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Laurent Vivier , Yoshinori Sato , Laurent Vivier , Thomas Huth , Peter Maydell , Mahmoud Mandour , Brad Smith , Alistair Francis , Brian Cain , Cleber Rosa , John Snow , Marcel Apfelbaum , Pierrick Bouvier , Palmer Dabbelt , Riku Voipio , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, Weiwei Li , Bin Meng , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Beraldo Leal , Kyle Evans , David Hildenbrand , Song Gao , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Paolo Bonzini , Alexandre Iooss , Warner Losh , qemu-riscv@nongnu.org, Ilya Leoshkevich Subject: [PATCH 16/29] plugins: implement inline operation relative to cpu_index Date: Tue, 5 Mar 2024 12:09:52 +0000 Message-Id: <20240305121005.3528075-17-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240305121005.3528075-1-alex.bennee@linaro.org> References: <20240305121005.3528075-1-alex.bennee@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::12d; envelope-from=alex.bennee@linaro.org; helo=mail-lf1-x12d.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, T_SCC_BODY_TEXT_LINE=-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: 1709641079313100005 From: Pierrick Bouvier Instead of working on a fixed memory location, allow to address it based on cpu_index, an element size and a given offset. Result address: ptr + offset + cpu_index * element_size. With this, we can target a member in a struct array from a base pointer. Current semantic is not modified, thus inline operation still targets always the same memory location. Reviewed-by: Richard Henderson Signed-off-by: Pierrick Bouvier Message-Id: <20240304130036.124418-4-pierrick.bouvier@linaro.org> Signed-off-by: Alex Benn=C3=A9e --- plugins/plugin.h | 2 +- accel/tcg/plugin-gen.c | 69 ++++++++++++++++++++++++++++++++++-------- plugins/api.c | 3 +- plugins/core.c | 12 +++++--- 4 files changed, 67 insertions(+), 19 deletions(-) diff --git a/plugins/plugin.h b/plugins/plugin.h index 043c740067d..3bf1aaf5c2d 100644 --- a/plugins/plugin.h +++ b/plugins/plugin.h @@ -99,7 +99,7 @@ void plugin_register_vcpu_mem_cb(GArray **arr, enum qemu_plugin_mem_rw rw, void *udata); =20 -void exec_inline_op(struct qemu_plugin_dyn_cb *cb); +void exec_inline_op(struct qemu_plugin_dyn_cb *cb, int cpu_index); =20 int plugin_num_vcpus(void); =20 diff --git a/accel/tcg/plugin-gen.c b/accel/tcg/plugin-gen.c index ac6b52b9ec9..0f8be53d394 100644 --- a/accel/tcg/plugin-gen.c +++ b/accel/tcg/plugin-gen.c @@ -133,16 +133,28 @@ static void gen_empty_udata_cb_no_rwg(void) */ static void gen_empty_inline_cb(void) { + TCGv_i32 cpu_index =3D tcg_temp_ebb_new_i32(); + TCGv_ptr cpu_index_as_ptr =3D tcg_temp_ebb_new_ptr(); TCGv_i64 val =3D tcg_temp_ebb_new_i64(); TCGv_ptr ptr =3D tcg_temp_ebb_new_ptr(); =20 + tcg_gen_ld_i32(cpu_index, tcg_env, + -offsetof(ArchCPU, env) + offsetof(CPUState, cpu_index)= ); + /* second operand will be replaced by immediate value */ + tcg_gen_mul_i32(cpu_index, cpu_index, cpu_index); + tcg_gen_ext_i32_ptr(cpu_index_as_ptr, cpu_index); + tcg_gen_movi_ptr(ptr, 0); + tcg_gen_add_ptr(ptr, ptr, cpu_index_as_ptr); tcg_gen_ld_i64(val, ptr, 0); - /* pass an immediate !=3D 0 so that it doesn't get optimized away */ - tcg_gen_addi_i64(val, val, 0xdeadface); + /* second operand will be replaced by immediate value */ + tcg_gen_add_i64(val, val, val); + tcg_gen_st_i64(val, ptr, 0); tcg_temp_free_ptr(ptr); tcg_temp_free_i64(val); + tcg_temp_free_ptr(cpu_index_as_ptr); + tcg_temp_free_i32(cpu_index); } =20 static void gen_empty_mem_cb(TCGv_i64 addr, uint32_t info) @@ -290,12 +302,37 @@ static TCGOp *copy_const_ptr(TCGOp **begin_op, TCGOp = *op, void *ptr) return op; } =20 +static TCGOp *copy_ld_i32(TCGOp **begin_op, TCGOp *op) +{ + return copy_op(begin_op, op, INDEX_op_ld_i32); +} + +static TCGOp *copy_ext_i32_ptr(TCGOp **begin_op, TCGOp *op) +{ + if (UINTPTR_MAX =3D=3D UINT32_MAX) { + op =3D copy_op(begin_op, op, INDEX_op_mov_i32); + } else { + op =3D copy_op(begin_op, op, INDEX_op_ext_i32_i64); + } + return op; +} + +static TCGOp *copy_add_ptr(TCGOp **begin_op, TCGOp *op) +{ + if (UINTPTR_MAX =3D=3D UINT32_MAX) { + op =3D copy_op(begin_op, op, INDEX_op_add_i32); + } else { + op =3D copy_op(begin_op, op, INDEX_op_add_i64); + } + return op; +} + static TCGOp *copy_ld_i64(TCGOp **begin_op, TCGOp *op) { if (TCG_TARGET_REG_BITS =3D=3D 32) { /* 2x ld_i32 */ - op =3D copy_op(begin_op, op, INDEX_op_ld_i32); - op =3D copy_op(begin_op, op, INDEX_op_ld_i32); + op =3D copy_ld_i32(begin_op, op); + op =3D copy_ld_i32(begin_op, op); } else { /* ld_i64 */ op =3D copy_op(begin_op, op, INDEX_op_ld_i64); @@ -331,6 +368,13 @@ static TCGOp *copy_add_i64(TCGOp **begin_op, TCGOp *op= , uint64_t v) return op; } =20 +static TCGOp *copy_mul_i32(TCGOp **begin_op, TCGOp *op, uint32_t v) +{ + op =3D copy_op(begin_op, op, INDEX_op_mul_i32); + op->args[2] =3D tcgv_i32_arg(tcg_constant_i32(v)); + return op; +} + static TCGOp *copy_st_ptr(TCGOp **begin_op, TCGOp *op) { if (UINTPTR_MAX =3D=3D UINT32_MAX) { @@ -396,18 +440,17 @@ static TCGOp *append_inline_cb(const struct qemu_plug= in_dyn_cb *cb, TCGOp *begin_op, TCGOp *op, int *unused) { - /* const_ptr */ - op =3D copy_const_ptr(&begin_op, op, cb->userp); - - /* ld_i64 */ + char *ptr =3D cb->userp; + size_t elem_size =3D 0; + size_t offset =3D 0; + op =3D copy_ld_i32(&begin_op, op); + op =3D copy_mul_i32(&begin_op, op, elem_size); + op =3D copy_ext_i32_ptr(&begin_op, op); + op =3D copy_const_ptr(&begin_op, op, ptr + offset); + op =3D copy_add_ptr(&begin_op, op); op =3D copy_ld_i64(&begin_op, op); - - /* add_i64 */ op =3D copy_add_i64(&begin_op, op, cb->inline_insn.imm); - - /* st_i64 */ op =3D copy_st_i64(&begin_op, op); - return op; } =20 diff --git a/plugins/api.c b/plugins/api.c index 8910cbb2c46..fa1daee8254 100644 --- a/plugins/api.c +++ b/plugins/api.c @@ -106,7 +106,8 @@ void qemu_plugin_register_vcpu_tb_exec_inline(struct qe= mu_plugin_tb *tb, void *ptr, uint64_t imm) { if (!tb->mem_only) { - plugin_register_inline_op(&tb->cbs[PLUGIN_CB_INLINE], 0, op, ptr, = imm); + plugin_register_inline_op(&tb->cbs[PLUGIN_CB_INLINE], + 0, op, ptr, imm); } } =20 diff --git a/plugins/core.c b/plugins/core.c index 63f4c6c6ce3..65d5611f797 100644 --- a/plugins/core.c +++ b/plugins/core.c @@ -318,7 +318,8 @@ static struct qemu_plugin_dyn_cb *plugin_get_dyn_cb(GAr= ray **arr) =20 void plugin_register_inline_op(GArray **arr, enum qemu_plugin_mem_rw rw, - enum qemu_plugin_op op, void *ptr, + enum qemu_plugin_op op, + void *ptr, uint64_t imm) { struct qemu_plugin_dyn_cb *dyn_cb; @@ -474,9 +475,12 @@ void qemu_plugin_flush_cb(void) plugin_cb__simple(QEMU_PLUGIN_EV_FLUSH); } =20 -void exec_inline_op(struct qemu_plugin_dyn_cb *cb) +void exec_inline_op(struct qemu_plugin_dyn_cb *cb, int cpu_index) { - uint64_t *val =3D cb->userp; + char *ptr =3D cb->userp; + size_t elem_size =3D 0; + size_t offset =3D 0; + uint64_t *val =3D (uint64_t *)(ptr + offset + cpu_index * elem_size); =20 switch (cb->inline_insn.op) { case QEMU_PLUGIN_INLINE_ADD_U64: @@ -509,7 +513,7 @@ void qemu_plugin_vcpu_mem_cb(CPUState *cpu, uint64_t va= ddr, vaddr, cb->userp); break; case PLUGIN_CB_INLINE: - exec_inline_op(cb); + exec_inline_op(cb, cpu->cpu_index); break; default: g_assert_not_reached(); --=20 2.39.2 From nobody Tue Nov 26 04:50:37 2024 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=1709640950; cv=none; d=zohomail.com; s=zohoarc; b=iLyfT7AEiEwX3II+ty+KxGDfKVS9q7HFG1Ipvv7d2dl2saaOjtWNM7hNcJpYXtbUmypGjRXmooOd7py/JqK0oS/0t0I6tNq5LYUNrYGpWzuUkmyxqOCIRZ9DuZNZ3FGB3AWYyyGnim23UEXfc7iWfOLiH0a0SHa0vIPz2Sug2sc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709640950; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=VIcFUMFR8l8AdO4VO4aK3T+8dAGB+Lm2FLrmrkejrpQ=; b=mLyrnNPImdwWZL4T9LnYIrVAiBUCLccfXYmYJMSOMNtiPwoU9yMLiIHchCxL9sS3Zk2Y2V8gq9SNX2aiCjGOF/GLsop+yD3sbK+nHVqaGwSZr/6K48m2HpmQWqSuhxNbNhaj9hNfCt4D3kwH6FR/k3t8GXS9tpAat45PM1uZC74= 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 1709640950127204.05621326402377; Tue, 5 Mar 2024 04:15:50 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rhTec-0004Vn-4q; Tue, 05 Mar 2024 07:12:18 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rhTdV-00027R-8a for qemu-devel@nongnu.org; Tue, 05 Mar 2024 07:11:09 -0500 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 1rhTcr-0001Vm-F4 for qemu-devel@nongnu.org; Tue, 05 Mar 2024 07:11:08 -0500 Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-412e68b8594so13695825e9.1 for ; Tue, 05 Mar 2024 04:10:22 -0800 (PST) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id h5-20020adf9cc5000000b0033dd9b050f9sm14657874wre.14.2024.03.05.04.10.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Mar 2024 04:10:18 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 2234C5F9E2; Tue, 5 Mar 2024 12:10:07 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1709640620; x=1710245420; 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=VIcFUMFR8l8AdO4VO4aK3T+8dAGB+Lm2FLrmrkejrpQ=; b=uhug2XDSn1JSjIGxqC6Q2vUpLWNCpXAqRLiWReZnE2SurvNRpOT1ymAAVqr/8ap/1T ngTYOWCQLiAb3ELovdy894AcKZ0BPGnFFbtbb+EE3Dgiks+ea4Kq3mffS4ZStI8JF/6H lf5+F3Gfyvemt3mnmZ/Idpn/vemq4xvWryFqKCwtxRLgU26mDza0hnHtfj23UmkrOlMu IMpmUA8wibqVPTeQy3EHrrhENewzyYZbH8Mz0GfHiZcjUUICfBf4WN1QaR1JVm9nEiAG Ebiqwi2658WHogGUJZVBNpRUORTKbwOGCyZeGDtcqtasIGBQPitUa01TTm6mL0LNq1hZ quiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709640620; x=1710245420; 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=VIcFUMFR8l8AdO4VO4aK3T+8dAGB+Lm2FLrmrkejrpQ=; b=bZRihmUeixDmhIRbZMp/Kgc8CgRDrp9qkAOe1H7rndjI37eUumLhEmUFH4RIqxzE2z KVaXruHmlr6EEbBrNwX8m+1OW4Wv2aVOhRGTgSFNVi3CocpAujvB757FhxV1Ycv3RXJ6 +cogWwtSwugj9t2a/p5eVoGsZhSjVXEhebJ+KyprK0J61e4wjRhJMpn96t7HaQwEV7H9 hWV0xzP3Dmjcrs5IEYDLXuWxF9yJAaDDsnci4kzTR3oLnNeYoz4pmuLIbQVEQlNu3FVH WnYlvqgBfwnlETRjiqon3EisG63cMvm7IHhHK+BTIZt0U34jCBPLl5NB/IzbTxHbvs3u fnmA== X-Gm-Message-State: AOJu0Yw+T0X7O6WWMQN0xyUYu3uQ1p0QZh/kDM0sTXOUD+eCEaBudorR yDu7c8Oa+Be/quSdYFzJLSGlrvcqhvbU+Wlzo/xxrXgEOhEklt9M/g7PicGSsVw= X-Google-Smtp-Source: AGHT+IFjCeMtWgA+j8gDbHxFGwMV2Nr9SqNrT+WkzlaxJmoXUVMOBCmP6QtzdfYFB85G+30bmPnMyg== X-Received: by 2002:a05:600c:b89:b0:412:ea5c:20cb with SMTP id fl9-20020a05600c0b8900b00412ea5c20cbmr1787146wmb.11.1709640620256; Tue, 05 Mar 2024 04:10:20 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Wainer dos Santos Moschetta , Alistair Francis , Nicholas Piggin , Liu Zhiwei , Richard Henderson , Yanan Wang , qemu-s390x@nongnu.org, "Edgar E. Iglesias" , Eduardo Habkost , Daniel Henrique Barboza , Michael Rolnik , Daniel Henrique Barboza , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Laurent Vivier , Yoshinori Sato , Laurent Vivier , Thomas Huth , Peter Maydell , Mahmoud Mandour , Brad Smith , Alistair Francis , Brian Cain , Cleber Rosa , John Snow , Marcel Apfelbaum , Pierrick Bouvier , Palmer Dabbelt , Riku Voipio , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, Weiwei Li , Bin Meng , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Beraldo Leal , Kyle Evans , David Hildenbrand , Song Gao , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Paolo Bonzini , Alexandre Iooss , Warner Losh , qemu-riscv@nongnu.org, Ilya Leoshkevich Subject: [PATCH 17/29] plugins: add inline operation per vcpu Date: Tue, 5 Mar 2024 12:09:53 +0000 Message-Id: <20240305121005.3528075-18-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240305121005.3528075-1-alex.bennee@linaro.org> References: <20240305121005.3528075-1-alex.bennee@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=alex.bennee@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, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1709640950767100001 From: Pierrick Bouvier Extends API with three new functions: qemu_plugin_register_vcpu_{tb, insn, mem}_exec_inline_per_vcpu(). Those functions takes a qemu_plugin_u64 as input. This allows to have a thread-safe and type-safe version of inline operations. Reviewed-by: Alex Benn=C3=A9e Reviewed-by: Richard Henderson Signed-off-by: Pierrick Bouvier Message-Id: <20240304130036.124418-5-pierrick.bouvier@linaro.org> Signed-off-by: Alex Benn=C3=A9e --- include/qemu/plugin.h | 1 + include/qemu/qemu-plugin.h | 51 +++++++++++++++++++++++++++++++++++- plugins/plugin.h | 6 +++++ accel/tcg/plugin-gen.c | 7 +++++ plugins/api.c | 37 +++++++++++++++++++++++++- plugins/core.c | 23 ++++++++++++++++ plugins/qemu-plugins.symbols | 3 +++ 7 files changed, 126 insertions(+), 2 deletions(-) diff --git a/include/qemu/plugin.h b/include/qemu/plugin.h index bf96d2c2aa3..12a96cea2a4 100644 --- a/include/qemu/plugin.h +++ b/include/qemu/plugin.h @@ -92,6 +92,7 @@ struct qemu_plugin_dyn_cb { /* fields specific to each dyn_cb type go here */ union { struct { + qemu_plugin_u64 entry; enum qemu_plugin_op op; uint64_t imm; } inline_insn; diff --git a/include/qemu/qemu-plugin.h b/include/qemu/qemu-plugin.h index ebf9a645e15..6bbad068c01 100644 --- a/include/qemu/qemu-plugin.h +++ b/include/qemu/qemu-plugin.h @@ -328,6 +328,22 @@ void qemu_plugin_register_vcpu_tb_exec_inline(struct q= emu_plugin_tb *tb, enum qemu_plugin_op op, void *ptr, uint64_t imm); =20 +/** + * qemu_plugin_register_vcpu_tb_exec_inline_per_vcpu() - execution inline = op + * @tb: the opaque qemu_plugin_tb handle for the translation + * @op: the type of qemu_plugin_op (e.g. ADD_U64) + * @entry: entry to run op + * @imm: the op data (e.g. 1) + * + * Insert an inline op on a given scoreboard entry. + */ +QEMU_PLUGIN_API +void qemu_plugin_register_vcpu_tb_exec_inline_per_vcpu( + struct qemu_plugin_tb *tb, + enum qemu_plugin_op op, + qemu_plugin_u64 entry, + uint64_t imm); + /** * qemu_plugin_register_vcpu_insn_exec_cb() - register insn execution cb * @insn: the opaque qemu_plugin_insn handle for an instruction @@ -358,6 +374,22 @@ void qemu_plugin_register_vcpu_insn_exec_inline(struct= qemu_plugin_insn *insn, enum qemu_plugin_op op, void *ptr, uint64_t imm); =20 +/** + * qemu_plugin_register_vcpu_insn_exec_inline_per_vcpu() - insn exec inlin= e op + * @insn: the opaque qemu_plugin_insn handle for an instruction + * @op: the type of qemu_plugin_op (e.g. ADD_U64) + * @entry: entry to run op + * @imm: the op data (e.g. 1) + * + * Insert an inline op to every time an instruction executes. + */ +QEMU_PLUGIN_API +void qemu_plugin_register_vcpu_insn_exec_inline_per_vcpu( + struct qemu_plugin_insn *insn, + enum qemu_plugin_op op, + qemu_plugin_u64 entry, + uint64_t imm); + /** * qemu_plugin_tb_n_insns() - query helper for number of insns in TB * @tb: opaque handle to TB passed to callback @@ -583,7 +615,24 @@ void qemu_plugin_register_vcpu_mem_inline(struct qemu_= plugin_insn *insn, enum qemu_plugin_op op, void *pt= r, uint64_t imm); =20 - +/** + * qemu_plugin_register_vcpu_mem_inline_per_vcpu() - inline op for mem acc= ess + * @insn: handle for instruction to instrument + * @rw: apply to reads, writes or both + * @op: the op, of type qemu_plugin_op + * @entry: entry to run op + * @imm: immediate data for @op + * + * This registers a inline op every memory access generated by the + * instruction. + */ +QEMU_PLUGIN_API +void qemu_plugin_register_vcpu_mem_inline_per_vcpu( + struct qemu_plugin_insn *insn, + enum qemu_plugin_mem_rw rw, + enum qemu_plugin_op op, + qemu_plugin_u64 entry, + uint64_t imm); =20 typedef void (*qemu_plugin_vcpu_syscall_cb_t)(qemu_plugin_id_t id, unsigned int vcpu_in= dex, diff --git a/plugins/plugin.h b/plugins/plugin.h index 3bf1aaf5c2d..f6fa10a0f56 100644 --- a/plugins/plugin.h +++ b/plugins/plugin.h @@ -73,6 +73,12 @@ void plugin_register_inline_op(GArray **arr, enum qemu_plugin_op op, void *ptr, uint64_t imm); =20 +void plugin_register_inline_op_on_entry(GArray **arr, + enum qemu_plugin_mem_rw rw, + enum qemu_plugin_op op, + qemu_plugin_u64 entry, + uint64_t imm); + void plugin_reset_uninstall(qemu_plugin_id_t id, qemu_plugin_simple_cb_t cb, bool reset); diff --git a/accel/tcg/plugin-gen.c b/accel/tcg/plugin-gen.c index 0f8be53d394..47e05ec6347 100644 --- a/accel/tcg/plugin-gen.c +++ b/accel/tcg/plugin-gen.c @@ -443,6 +443,13 @@ static TCGOp *append_inline_cb(const struct qemu_plugi= n_dyn_cb *cb, char *ptr =3D cb->userp; size_t elem_size =3D 0; size_t offset =3D 0; + if (!ptr) { + /* use inline entry */ + ptr =3D cb->inline_insn.entry.score->data->data; + elem_size =3D g_array_get_element_size(cb->inline_insn.entry.score= ->data); + offset =3D cb->inline_insn.entry.offset; + } + op =3D copy_ld_i32(&begin_op, op); op =3D copy_mul_i32(&begin_op, op, elem_size); op =3D copy_ext_i32_ptr(&begin_op, op); diff --git a/plugins/api.c b/plugins/api.c index fa1daee8254..6470f1dc0f2 100644 --- a/plugins/api.c +++ b/plugins/api.c @@ -111,6 +111,18 @@ void qemu_plugin_register_vcpu_tb_exec_inline(struct q= emu_plugin_tb *tb, } } =20 +void qemu_plugin_register_vcpu_tb_exec_inline_per_vcpu( + struct qemu_plugin_tb *tb, + enum qemu_plugin_op op, + qemu_plugin_u64 entry, + uint64_t imm) +{ + if (!tb->mem_only) { + plugin_register_inline_op_on_entry( + &tb->cbs[PLUGIN_CB_INLINE], 0, op, entry, imm); + } +} + void qemu_plugin_register_vcpu_insn_exec_cb(struct qemu_plugin_insn *insn, qemu_plugin_vcpu_udata_cb_t cb, enum qemu_plugin_cb_flags flag= s, @@ -136,6 +148,18 @@ void qemu_plugin_register_vcpu_insn_exec_inline(struct= qemu_plugin_insn *insn, } } =20 +void qemu_plugin_register_vcpu_insn_exec_inline_per_vcpu( + struct qemu_plugin_insn *insn, + enum qemu_plugin_op op, + qemu_plugin_u64 entry, + uint64_t imm) +{ + if (!insn->mem_only) { + plugin_register_inline_op_on_entry( + &insn->cbs[PLUGIN_CB_INSN][PLUGIN_CB_INLINE], 0, op, entry, im= m); + } +} + =20 /* * We always plant memory instrumentation because they don't finalise until @@ -148,7 +172,7 @@ void qemu_plugin_register_vcpu_mem_cb(struct qemu_plugi= n_insn *insn, void *udata) { plugin_register_vcpu_mem_cb(&insn->cbs[PLUGIN_CB_MEM][PLUGIN_CB_REGULA= R], - cb, flags, rw, udata); + cb, flags, rw, udata); } =20 void qemu_plugin_register_vcpu_mem_inline(struct qemu_plugin_insn *insn, @@ -160,6 +184,17 @@ void qemu_plugin_register_vcpu_mem_inline(struct qemu_= plugin_insn *insn, rw, op, ptr, imm); } =20 +void qemu_plugin_register_vcpu_mem_inline_per_vcpu( + struct qemu_plugin_insn *insn, + enum qemu_plugin_mem_rw rw, + enum qemu_plugin_op op, + qemu_plugin_u64 entry, + uint64_t imm) +{ + plugin_register_inline_op_on_entry( + &insn->cbs[PLUGIN_CB_MEM][PLUGIN_CB_INLINE], rw, op, entry, imm); +} + void qemu_plugin_register_vcpu_tb_trans_cb(qemu_plugin_id_t id, qemu_plugin_vcpu_tb_trans_cb_t = cb) { diff --git a/plugins/core.c b/plugins/core.c index 65d5611f797..7852590da88 100644 --- a/plugins/core.c +++ b/plugins/core.c @@ -332,6 +332,23 @@ void plugin_register_inline_op(GArray **arr, dyn_cb->inline_insn.imm =3D imm; } =20 +void plugin_register_inline_op_on_entry(GArray **arr, + enum qemu_plugin_mem_rw rw, + enum qemu_plugin_op op, + qemu_plugin_u64 entry, + uint64_t imm) +{ + struct qemu_plugin_dyn_cb *dyn_cb; + + dyn_cb =3D plugin_get_dyn_cb(arr); + dyn_cb->userp =3D NULL; + dyn_cb->type =3D PLUGIN_CB_INLINE; + dyn_cb->rw =3D rw; + dyn_cb->inline_insn.entry =3D entry; + dyn_cb->inline_insn.op =3D op; + dyn_cb->inline_insn.imm =3D imm; +} + void plugin_register_dyn_cb__udata(GArray **arr, qemu_plugin_vcpu_udata_cb_t cb, enum qemu_plugin_cb_flags flags, @@ -480,6 +497,12 @@ void exec_inline_op(struct qemu_plugin_dyn_cb *cb, int= cpu_index) char *ptr =3D cb->userp; size_t elem_size =3D 0; size_t offset =3D 0; + if (!ptr) { + /* use inline entry */ + ptr =3D cb->inline_insn.entry.score->data->data; + elem_size =3D g_array_get_element_size(cb->inline_insn.entry.score= ->data); + offset =3D cb->inline_insn.entry.offset; + } uint64_t *val =3D (uint64_t *)(ptr + offset + cpu_index * elem_size); =20 switch (cb->inline_insn.op) { diff --git a/plugins/qemu-plugins.symbols b/plugins/qemu-plugins.symbols index 6204453d0fd..0d8141b85f1 100644 --- a/plugins/qemu-plugins.symbols +++ b/plugins/qemu-plugins.symbols @@ -28,13 +28,16 @@ qemu_plugin_register_vcpu_init_cb; qemu_plugin_register_vcpu_insn_exec_cb; qemu_plugin_register_vcpu_insn_exec_inline; + qemu_plugin_register_vcpu_insn_exec_inline_per_vcpu; qemu_plugin_register_vcpu_mem_cb; qemu_plugin_register_vcpu_mem_inline; + qemu_plugin_register_vcpu_mem_inline_per_vcpu; qemu_plugin_register_vcpu_resume_cb; qemu_plugin_register_vcpu_syscall_cb; qemu_plugin_register_vcpu_syscall_ret_cb; qemu_plugin_register_vcpu_tb_exec_cb; qemu_plugin_register_vcpu_tb_exec_inline; + qemu_plugin_register_vcpu_tb_exec_inline_per_vcpu; qemu_plugin_register_vcpu_tb_trans_cb; qemu_plugin_reset; qemu_plugin_scoreboard_free; --=20 2.39.2 From nobody Tue Nov 26 04:50:37 2024 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=1709641212; cv=none; d=zohomail.com; s=zohoarc; b=QKLCShHOV3q12VW49FI3TEPXt/P4qp2u5Od15vV5bJCbeSx25GKuslMJUizXCBlS5MdWaK2HNnCYM0EJpSQ79FqXJoe/kk7/J37TVJdYNNUaO0yR1o+h9O5NA5nCZo4XFbPHK+fUTKfmOvc7diJm6lqV4rlwvCep6cNwNjYhl5I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709641212; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=1Q6z2XfIeMWCEhbEBjQ3EoV1Q07C8fVhTLWW7QaYwTo=; b=Id3l+rejLU1NRlgtaqHrnrwwcfMTKwVU45x3mNKgTOA7ignYsRq8rhc7E2N+0iIGJfut1BJKYXGAmUY+hoJr7kIMQlOPSKwQYzMQ+6jV9ysz1WLFEFfo1OulbwF6UVNRRy0w+tsvYvwPjP1kRw6/PD80+2qda5FYUZP2I9icPkA= 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 1709641212722163.43243667348645; Tue, 5 Mar 2024 04:20:12 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rhTlQ-0001Km-A6; Tue, 05 Mar 2024 07:19:20 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rhTl1-0008Oy-2Y for qemu-devel@nongnu.org; Tue, 05 Mar 2024 07:18:58 -0500 Received: from mail-wm1-x32b.google.com ([2a00:1450:4864:20::32b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rhTks-0003Dr-Bs for qemu-devel@nongnu.org; Tue, 05 Mar 2024 07:18:54 -0500 Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-412ee276dc9so3111205e9.1 for ; Tue, 05 Mar 2024 04:18:45 -0800 (PST) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id q13-20020a05600c46cd00b00412ebd587ebsm2115488wmo.3.2024.03.05.04.18.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Mar 2024 04:18:43 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 37A5D5F9E4; Tue, 5 Mar 2024 12:10:07 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1709641125; x=1710245925; 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=1Q6z2XfIeMWCEhbEBjQ3EoV1Q07C8fVhTLWW7QaYwTo=; b=C4hb9L1i4X4op+bj66Nf6ySvXmCwh8ZrnDBJl8V2WYBNpQdmMVYACU2knUt7gsXaLS ZIxs4CAkMg8tPpYKx0LphxXFl9GNYfxe72M+UGqpV6PphRnL55KlSMSNdCFRwRgmX2xg gDCp3bTtzDIvJBOKaf3ogsBdKcyt5rLUnbTLEHF+Q0wjZ+uAdkeZsKGZ4yIzfsBGnElw Ei8RZl5xCi7685IMHklq8++BRPA1UIn77ZXGR/EfpPwH9abXlhmV/eKjx/xhShxjYWHp 1zCapC4fcTaHZ6j8RV9X04QGIDRi0QYNle5geymZHa2Fu2e2eTc8hVTQsD7d0NZMVklN j6ig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709641125; x=1710245925; 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=1Q6z2XfIeMWCEhbEBjQ3EoV1Q07C8fVhTLWW7QaYwTo=; b=aTNybHkQM0H4qmeCuTLUafyGL2uuNkBEA6kJtjwiW94TfBFux/4VTtaAfq66YNXCho 7f53uq7V24QHTe+taVXNItyX7BtaHfBiUTb0TI73EwdnXlAV8Tc74iPETL9vsG0X1JXp WGDpIL7Hlyg6OlB4EdTsvUZ1wx8EoovkYsJc9QYiqr60jJtLRSThoOYFPt8D5SpoJ/4C VMaSLO06xM0pX0ekIBfc+Uxvtg8ZgRvVIkdmQVg89wiRXo2QOTS9BYmbCf+39VXeVgSd XdMlU1wHcexDR+TSN6FhiKw1Q4DJAtZyZUhw4L4wwzNZ+sEp+Q27+uHKOKqRrc3oAp0G SZAQ== X-Gm-Message-State: AOJu0YwTmm5PmP1mmRlel91wDm9RmkcTX+EgA8dbHh7V4/mC+roMKWRV rje5Y7JtKbvoXxnq5DSxWv+A5FPPlnPgqANO4qX+LPDK6KCPtHNiqRd+eOtZ1m4= X-Google-Smtp-Source: AGHT+IEFRj2k6ymwj3aH8m1DmVV4O8TFL0RBA9AlzHT9bhhJLpp1WAN7/tMuaMyZR7yOAyChFmPhCQ== X-Received: by 2002:a05:600c:1912:b0:412:e79f:3f8e with SMTP id j18-20020a05600c191200b00412e79f3f8emr3004101wmq.15.1709641124629; Tue, 05 Mar 2024 04:18:44 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Wainer dos Santos Moschetta , Alistair Francis , Nicholas Piggin , Liu Zhiwei , Richard Henderson , Yanan Wang , qemu-s390x@nongnu.org, "Edgar E. Iglesias" , Eduardo Habkost , Daniel Henrique Barboza , Michael Rolnik , Daniel Henrique Barboza , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Laurent Vivier , Yoshinori Sato , Laurent Vivier , Thomas Huth , Peter Maydell , Mahmoud Mandour , Brad Smith , Alistair Francis , Brian Cain , Cleber Rosa , John Snow , Marcel Apfelbaum , Pierrick Bouvier , Palmer Dabbelt , Riku Voipio , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, Weiwei Li , Bin Meng , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Beraldo Leal , Kyle Evans , David Hildenbrand , Song Gao , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Paolo Bonzini , Alexandre Iooss , Warner Losh , qemu-riscv@nongnu.org, Ilya Leoshkevich Subject: [PATCH 18/29] tests/plugin: add test plugin for inline operations Date: Tue, 5 Mar 2024 12:09:54 +0000 Message-Id: <20240305121005.3528075-19-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240305121005.3528075-1-alex.bennee@linaro.org> References: <20240305121005.3528075-1-alex.bennee@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::32b; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x32b.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1709641214140100001 From: Pierrick Bouvier For now, it simply performs instruction, bb and mem count, and ensure that inline vs callback versions have the same result. Later, we'll extend it when new inline operations are added. Use existing plugins to test everything works is a bit cumbersome, as different events are treated in different plugins. Thus, this new one. Reviewed-by: Alex Benn=C3=A9e Signed-off-by: Pierrick Bouvier Message-Id: <20240304130036.124418-6-pierrick.bouvier@linaro.org> Signed-off-by: Alex Benn=C3=A9e --- tests/plugin/inline.c | 186 +++++++++++++++++++++++++++++++++++++++ tests/plugin/meson.build | 2 +- 2 files changed, 187 insertions(+), 1 deletion(-) create mode 100644 tests/plugin/inline.c diff --git a/tests/plugin/inline.c b/tests/plugin/inline.c new file mode 100644 index 00000000000..0163e9b51c5 --- /dev/null +++ b/tests/plugin/inline.c @@ -0,0 +1,186 @@ +/* + * Copyright (C) 2023, Pierrick Bouvier + * + * Demonstrates and tests usage of inline ops. + * + * License: GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ + +#include +#include +#include + +#include + +typedef struct { + uint64_t count_tb; + uint64_t count_tb_inline; + uint64_t count_insn; + uint64_t count_insn_inline; + uint64_t count_mem; + uint64_t count_mem_inline; +} CPUCount; + +static struct qemu_plugin_scoreboard *counts; +static qemu_plugin_u64 count_tb; +static qemu_plugin_u64 count_tb_inline; +static qemu_plugin_u64 count_insn; +static qemu_plugin_u64 count_insn_inline; +static qemu_plugin_u64 count_mem; +static qemu_plugin_u64 count_mem_inline; + +static uint64_t global_count_tb; +static uint64_t global_count_insn; +static uint64_t global_count_mem; +static unsigned int max_cpu_index; +static GMutex tb_lock; +static GMutex insn_lock; +static GMutex mem_lock; + +QEMU_PLUGIN_EXPORT int qemu_plugin_version =3D QEMU_PLUGIN_VERSION; + +static void stats_insn(void) +{ + const uint64_t expected =3D global_count_insn; + const uint64_t per_vcpu =3D qemu_plugin_u64_sum(count_insn); + const uint64_t inl_per_vcpu =3D + qemu_plugin_u64_sum(count_insn_inline); + printf("insn: %" PRIu64 "\n", expected); + printf("insn: %" PRIu64 " (per vcpu)\n", per_vcpu); + printf("insn: %" PRIu64 " (per vcpu inline)\n", inl_per_vcpu); + g_assert(expected > 0); + g_assert(per_vcpu =3D=3D expected); + g_assert(inl_per_vcpu =3D=3D expected); +} + +static void stats_tb(void) +{ + const uint64_t expected =3D global_count_tb; + const uint64_t per_vcpu =3D qemu_plugin_u64_sum(count_tb); + const uint64_t inl_per_vcpu =3D + qemu_plugin_u64_sum(count_tb_inline); + printf("tb: %" PRIu64 "\n", expected); + printf("tb: %" PRIu64 " (per vcpu)\n", per_vcpu); + printf("tb: %" PRIu64 " (per vcpu inline)\n", inl_per_vcpu); + g_assert(expected > 0); + g_assert(per_vcpu =3D=3D expected); + g_assert(inl_per_vcpu =3D=3D expected); +} + +static void stats_mem(void) +{ + const uint64_t expected =3D global_count_mem; + const uint64_t per_vcpu =3D qemu_plugin_u64_sum(count_mem); + const uint64_t inl_per_vcpu =3D + qemu_plugin_u64_sum(count_mem_inline); + printf("mem: %" PRIu64 "\n", expected); + printf("mem: %" PRIu64 " (per vcpu)\n", per_vcpu); + printf("mem: %" PRIu64 " (per vcpu inline)\n", inl_per_vcpu); + g_assert(expected > 0); + g_assert(per_vcpu =3D=3D expected); + g_assert(inl_per_vcpu =3D=3D expected); +} + +static void plugin_exit(qemu_plugin_id_t id, void *udata) +{ + const unsigned int num_cpus =3D qemu_plugin_num_vcpus(); + g_assert(num_cpus =3D=3D max_cpu_index + 1); + + for (int i =3D 0; i < num_cpus ; ++i) { + const uint64_t tb =3D qemu_plugin_u64_get(count_tb, i); + const uint64_t tb_inline =3D qemu_plugin_u64_get(count_tb_inline, = i); + const uint64_t insn =3D qemu_plugin_u64_get(count_insn, i); + const uint64_t insn_inline =3D qemu_plugin_u64_get(count_insn_inli= ne, i); + const uint64_t mem =3D qemu_plugin_u64_get(count_mem, i); + const uint64_t mem_inline =3D qemu_plugin_u64_get(count_mem_inline= , i); + printf("cpu %d: tb (%" PRIu64 ", %" PRIu64 ") | " + "insn (%" PRIu64 ", %" PRIu64 ") | " + "mem (%" PRIu64 ", %" PRIu64 ")" + "\n", + i, tb, tb_inline, insn, insn_inline, mem, mem_inline); + g_assert(tb =3D=3D tb_inline); + g_assert(insn =3D=3D insn_inline); + g_assert(mem =3D=3D mem_inline); + } + + stats_tb(); + stats_insn(); + stats_mem(); + + qemu_plugin_scoreboard_free(counts); +} + +static void vcpu_tb_exec(unsigned int cpu_index, void *udata) +{ + qemu_plugin_u64_add(count_tb, cpu_index, 1); + g_mutex_lock(&tb_lock); + max_cpu_index =3D MAX(max_cpu_index, cpu_index); + global_count_tb++; + g_mutex_unlock(&tb_lock); +} + +static void vcpu_insn_exec(unsigned int cpu_index, void *udata) +{ + qemu_plugin_u64_add(count_insn, cpu_index, 1); + g_mutex_lock(&insn_lock); + global_count_insn++; + g_mutex_unlock(&insn_lock); +} + +static void vcpu_mem_access(unsigned int cpu_index, + qemu_plugin_meminfo_t info, + uint64_t vaddr, + void *userdata) +{ + qemu_plugin_u64_add(count_mem, cpu_index, 1); + g_mutex_lock(&mem_lock); + global_count_mem++; + g_mutex_unlock(&mem_lock); +} + +static void vcpu_tb_trans(qemu_plugin_id_t id, struct qemu_plugin_tb *tb) +{ + qemu_plugin_register_vcpu_tb_exec_cb( + tb, vcpu_tb_exec, QEMU_PLUGIN_CB_NO_REGS, 0); + qemu_plugin_register_vcpu_tb_exec_inline_per_vcpu( + tb, QEMU_PLUGIN_INLINE_ADD_U64, count_tb_inline, 1); + + for (int idx =3D 0; idx < qemu_plugin_tb_n_insns(tb); ++idx) { + struct qemu_plugin_insn *insn =3D qemu_plugin_tb_get_insn(tb, idx); + qemu_plugin_register_vcpu_insn_exec_cb( + insn, vcpu_insn_exec, QEMU_PLUGIN_CB_NO_REGS, 0); + qemu_plugin_register_vcpu_insn_exec_inline_per_vcpu( + insn, QEMU_PLUGIN_INLINE_ADD_U64, count_insn_inline, 1); + qemu_plugin_register_vcpu_mem_cb(insn, &vcpu_mem_access, + QEMU_PLUGIN_CB_NO_REGS, + QEMU_PLUGIN_MEM_RW, 0); + qemu_plugin_register_vcpu_mem_inline_per_vcpu( + insn, QEMU_PLUGIN_MEM_RW, + QEMU_PLUGIN_INLINE_ADD_U64, + count_mem_inline, 1); + } +} + +QEMU_PLUGIN_EXPORT +int qemu_plugin_install(qemu_plugin_id_t id, const qemu_info_t *info, + int argc, char **argv) +{ + counts =3D qemu_plugin_scoreboard_new(sizeof(CPUCount)); + count_tb =3D qemu_plugin_scoreboard_u64_in_struct( + counts, CPUCount, count_tb); + count_insn =3D qemu_plugin_scoreboard_u64_in_struct( + counts, CPUCount, count_insn); + count_mem =3D qemu_plugin_scoreboard_u64_in_struct( + counts, CPUCount, count_mem); + count_tb_inline =3D qemu_plugin_scoreboard_u64_in_struct( + counts, CPUCount, count_tb_inline); + count_insn_inline =3D qemu_plugin_scoreboard_u64_in_struct( + counts, CPUCount, count_insn_inline); + count_mem_inline =3D qemu_plugin_scoreboard_u64_in_struct( + counts, CPUCount, count_mem_inline); + qemu_plugin_register_vcpu_tb_trans_cb(id, vcpu_tb_trans); + qemu_plugin_register_atexit_cb(id, plugin_exit, NULL); + + return 0; +} diff --git a/tests/plugin/meson.build b/tests/plugin/meson.build index e18183aaeda..9eece5bab51 100644 --- a/tests/plugin/meson.build +++ b/tests/plugin/meson.build @@ -1,6 +1,6 @@ t =3D [] if get_option('plugins') - foreach i : ['bb', 'empty', 'insn', 'mem', 'syscall'] + foreach i : ['bb', 'empty', 'inline', 'insn', 'mem', 'syscall'] if host_os =3D=3D 'windows' t +=3D shared_module(i, files(i + '.c') + '../../contrib/plugins/win= 32_linker.c', include_directories: '../../include/qemu', --=20 2.39.2 From nobody Tue Nov 26 04:50:37 2024 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=1709641321; cv=none; d=zohomail.com; s=zohoarc; b=ArTlbVQJ5Ho/VTlq7aaCa+IKP10NddrSf4fZ1V5rtAt8Nt/2/v3yqxD4nbnqZwiLkBR4R8Lt+EcFVs9k8B63UITMr871PPpO5YYWuJXMGCTF7yfq4sU0zMYSJuOEw5CK0Q9mpXUmSe4twLezdQdBYdEpsMqiZpSaejFtR8AYgn0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709641321; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Jva0UhCUVM5PrwiNrRfr0W8ZD8H77VctOx99a/dGefo=; b=fXa1Uhf+Ox+vdtA0SE5oIgNotedPfZD12tIYe5CUmvmQv1fp1sxYL9DLI64T48e69E4ZxO18SOeaDBLSusdRKt2cukvqIqXMzyZ1AfGWBsikTtOFTJaVhn/TEvUJ5jX1ub6K7TBpjZIhKsBqSnzYx2x6jU27M7l5tExBwEQkuaI= 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 1709641320993883.628235826011; Tue, 5 Mar 2024 04:22:00 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rhTnO-0004yR-Gy; Tue, 05 Mar 2024 07:21:24 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rhTlJ-0000lh-By for qemu-devel@nongnu.org; Tue, 05 Mar 2024 07:19:13 -0500 Received: from mail-wr1-x429.google.com ([2a00:1450:4864:20::429]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rhTky-0003Gr-K9 for qemu-devel@nongnu.org; Tue, 05 Mar 2024 07:19:13 -0500 Received: by mail-wr1-x429.google.com with SMTP id ffacd0b85a97d-33e4d36f288so243459f8f.1 for ; Tue, 05 Mar 2024 04:18:50 -0800 (PST) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id bi25-20020a05600c3d9900b00412e84e96ffsm3912412wmb.40.2024.03.05.04.18.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Mar 2024 04:18:47 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 4CC305F9E6; Tue, 5 Mar 2024 12:10:07 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1709641129; x=1710245929; 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=Jva0UhCUVM5PrwiNrRfr0W8ZD8H77VctOx99a/dGefo=; b=dnl08MoI3lEFJ66xmrtGAPwl6c0WgbVa6CIGWJuFRRHJxF1T3z4H0j36DmCH+DhuNm AEgeuUHHB5iKdVJ5BkD+WWrt6cbjcctNrBHVaBt0W635xLyVj83wHwKbac0dhLC4ve3p RjVEVS3ufPPXtCwccmGwuVsmiL2UL3IBWVa/eEGumHQmIsS28/kHcvE9Kha2GpMVqf6B 93DxPZKYDjDeLdjBkpa6YDaX610LA4crv6W0RffRydr6tsKREEMsEueHN+MYurXHqjGp 7O6x+wMcJFc8xj5uVk677dESZ/8bskmaPJEDS06rF5pDIz0bQCLcIk9NEtFZfftphVta HcIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709641129; x=1710245929; 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=Jva0UhCUVM5PrwiNrRfr0W8ZD8H77VctOx99a/dGefo=; b=wdysPdStj71EelG7o3cYVLG5FeDCmqs5xIs+2pE5+P5fWQobEiUAWwePthWjj2xFmu 1DK2FC66xlGq1BtR5CpVDBIW6PuXTrIsqDWOMi6UnS1+t5jfxO4CjDtWXDD+39HYSiub dYG6Oi5A2EiZOYz7+SlrPOQR+SH04nO7WBfYZOKVAauSKO2+ZS5U6kDIpg2K5+LC6Kmw QgZIBSQc9S9bWLXOie3Nkbu7/PjOf5YxG0cmnJbR8YWexV3y78wjQjVhIvoD/+IA2kIp eMl52QMOz6sXqsR7s50bE9rUvxQCoasf1pNd/1pnozUgRlrurMSp2jXrm7mCMILVvyKS 1rlQ== X-Gm-Message-State: AOJu0YwDI3O7lLZCR4ulnzK2m064gCK8LaCMwvJn8GXl2tagj0l0ZHBz KHrQv2PvSUPzjpu3xWw7ImxKK4FTX0vXP+ouqoMZBe93bA1OOKXIhNSEaVI0A1E= X-Google-Smtp-Source: AGHT+IHTATgThPGnyM45aOi2TznZZmQxxf8YawWswvZPAvtQY/ayQcuvuoLNGIo44swjuTImztdpaA== X-Received: by 2002:a05:6000:1e11:b0:33e:47fa:912a with SMTP id bj17-20020a0560001e1100b0033e47fa912amr2968670wrb.27.1709641129428; Tue, 05 Mar 2024 04:18:49 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Wainer dos Santos Moschetta , Alistair Francis , Nicholas Piggin , Liu Zhiwei , Richard Henderson , Yanan Wang , qemu-s390x@nongnu.org, "Edgar E. Iglesias" , Eduardo Habkost , Daniel Henrique Barboza , Michael Rolnik , Daniel Henrique Barboza , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Laurent Vivier , Yoshinori Sato , Laurent Vivier , Thomas Huth , Peter Maydell , Mahmoud Mandour , Brad Smith , Alistair Francis , Brian Cain , Cleber Rosa , John Snow , Marcel Apfelbaum , Pierrick Bouvier , Palmer Dabbelt , Riku Voipio , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, Weiwei Li , Bin Meng , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Beraldo Leal , Kyle Evans , David Hildenbrand , Song Gao , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Paolo Bonzini , Alexandre Iooss , Warner Losh , qemu-riscv@nongnu.org, Ilya Leoshkevich , Luc Michel Subject: [PATCH 19/29] tests/plugin/mem: migrate to new per_vcpu API Date: Tue, 5 Mar 2024 12:09:55 +0000 Message-Id: <20240305121005.3528075-20-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240305121005.3528075-1-alex.bennee@linaro.org> References: <20240305121005.3528075-1-alex.bennee@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::429; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x429.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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1709641322591100005 From: Pierrick Bouvier Reviewed-by: Luc Michel Signed-off-by: Pierrick Bouvier Message-Id: <20240304130036.124418-7-pierrick.bouvier@linaro.org> Signed-off-by: Alex Benn=C3=A9e --- tests/plugin/mem.c | 46 ++++++++++++++++++++++++++------------- tests/tcg/Makefile.target | 2 +- 2 files changed, 32 insertions(+), 16 deletions(-) diff --git a/tests/plugin/mem.c b/tests/plugin/mem.c index 44e91065ba7..b650dddcce1 100644 --- a/tests/plugin/mem.c +++ b/tests/plugin/mem.c @@ -16,9 +16,14 @@ =20 QEMU_PLUGIN_EXPORT int qemu_plugin_version =3D QEMU_PLUGIN_VERSION; =20 -static uint64_t inline_mem_count; -static uint64_t cb_mem_count; -static uint64_t io_count; +typedef struct { + uint64_t mem_count; + uint64_t io_count; +} CPUCount; + +static struct qemu_plugin_scoreboard *counts; +static qemu_plugin_u64 mem_count; +static qemu_plugin_u64 io_count; static bool do_inline, do_callback; static bool do_haddr; static enum qemu_plugin_mem_rw rw =3D QEMU_PLUGIN_MEM_RW; @@ -27,16 +32,16 @@ static void plugin_exit(qemu_plugin_id_t id, void *p) { g_autoptr(GString) out =3D g_string_new(""); =20 - if (do_inline) { - g_string_printf(out, "inline mem accesses: %" PRIu64 "\n", inline_= mem_count); - } - if (do_callback) { - g_string_append_printf(out, "callback mem accesses: %" PRIu64 "\n"= , cb_mem_count); + if (do_inline || do_callback) { + g_string_printf(out, "mem accesses: %" PRIu64 "\n", + qemu_plugin_u64_sum(mem_count)); } if (do_haddr) { - g_string_append_printf(out, "io accesses: %" PRIu64 "\n", io_count= ); + g_string_append_printf(out, "io accesses: %" PRIu64 "\n", + qemu_plugin_u64_sum(io_count)); } qemu_plugin_outs(out->str); + qemu_plugin_scoreboard_free(counts); } =20 static void vcpu_mem(unsigned int cpu_index, qemu_plugin_meminfo_t meminfo, @@ -46,12 +51,12 @@ static void vcpu_mem(unsigned int cpu_index, qemu_plugi= n_meminfo_t meminfo, struct qemu_plugin_hwaddr *hwaddr; hwaddr =3D qemu_plugin_get_hwaddr(meminfo, vaddr); if (qemu_plugin_hwaddr_is_io(hwaddr)) { - io_count++; + qemu_plugin_u64_add(io_count, cpu_index, 1); } else { - cb_mem_count++; + qemu_plugin_u64_add(mem_count, cpu_index, 1); } } else { - cb_mem_count++; + qemu_plugin_u64_add(mem_count, cpu_index, 1); } } =20 @@ -64,9 +69,10 @@ static void vcpu_tb_trans(qemu_plugin_id_t id, struct qe= mu_plugin_tb *tb) struct qemu_plugin_insn *insn =3D qemu_plugin_tb_get_insn(tb, i); =20 if (do_inline) { - qemu_plugin_register_vcpu_mem_inline(insn, rw, - QEMU_PLUGIN_INLINE_ADD_U6= 4, - &inline_mem_count, 1); + qemu_plugin_register_vcpu_mem_inline_per_vcpu( + insn, rw, + QEMU_PLUGIN_INLINE_ADD_U64, + mem_count, 1); } if (do_callback) { qemu_plugin_register_vcpu_mem_cb(insn, vcpu_mem, @@ -117,6 +123,16 @@ QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin= _id_t id, } } =20 + if (do_inline && do_callback) { + fprintf(stderr, + "can't enable inline and callback counting at the same tim= e\n"); + return -1; + } + + counts =3D qemu_plugin_scoreboard_new(sizeof(CPUCount)); + mem_count =3D qemu_plugin_scoreboard_u64_in_struct( + counts, CPUCount, mem_count); + io_count =3D qemu_plugin_scoreboard_u64_in_struct(counts, CPUCount, io= _count); qemu_plugin_register_vcpu_tb_trans_cb(id, vcpu_tb_trans); qemu_plugin_register_atexit_cb(id, plugin_exit, NULL); return 0; diff --git a/tests/tcg/Makefile.target b/tests/tcg/Makefile.target index a4c25908fb7..f21be50d3b2 100644 --- a/tests/tcg/Makefile.target +++ b/tests/tcg/Makefile.target @@ -168,7 +168,7 @@ RUN_TESTS+=3D$(EXTRA_RUNS) =20 # Some plugins need additional arguments above the default to fully # exercise things. We can define them on a per-test basis here. -run-plugin-%-with-libmem.so: PLUGIN_ARGS=3D$(COMMA)inline=3Dtrue$(COMMA)ca= llback=3Dtrue +run-plugin-%-with-libmem.so: PLUGIN_ARGS=3D$(COMMA)inline=3Dtrue =20 ifeq ($(filter %-softmmu, $(TARGET)),) run-%: % --=20 2.39.2 From nobody Tue Nov 26 04:50:37 2024 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=1709641320; cv=none; d=zohomail.com; s=zohoarc; b=T1CuDCbKN1W4jGRO0PjDjGlYRVX6LCgO+d+7kwT4kWoCB8sc0U6eSz/gwZGJzOwanDkZDc1O/R7M44Hr5yb+kNGRighL/PivTINgSdHcXA1dg4+ZcpNgvV0ln2iZ04nSnv3KXEhR8X15nuRx/WzT18b9y53J/zF/JQKdbVGfP8w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709641320; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=LhUxtBkvb4r+WsD7JiENu61BSWgpCAqrg2uG7NyPqfA=; b=A6WOQrqHEG6fH/crJIvSgk6jURxAz3cYbC49wlYbqkeT5e3BbPhTIcesHKTJxA602hNYa4PdV3slRYVS4y7iwBrBeCZ77YrQTzCx/ECMQYj/RSybEClX0QqEsLrbv4NK0Ksdc79JWKiwo4xfAFFk6hgVUnugd2F4ez7/6k0Mses= 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 1709641320007470.9482162157544; Tue, 5 Mar 2024 04:22:00 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rhTnV-0005U3-UL; Tue, 05 Mar 2024 07:21:30 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rhTlL-0000pj-Nt for qemu-devel@nongnu.org; Tue, 05 Mar 2024 07:19:15 -0500 Received: from mail-wm1-x330.google.com ([2a00:1450:4864:20::330]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rhTky-0003I9-KZ for qemu-devel@nongnu.org; Tue, 05 Mar 2024 07:19:13 -0500 Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-412cf3c5cdeso26916925e9.2 for ; Tue, 05 Mar 2024 04:18:51 -0800 (PST) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id bd23-20020a05600c1f1700b00412ef097c27sm1030453wmb.16.2024.03.05.04.18.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Mar 2024 04:18:47 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 607455F9E8; Tue, 5 Mar 2024 12:10:07 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1709641131; x=1710245931; 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=LhUxtBkvb4r+WsD7JiENu61BSWgpCAqrg2uG7NyPqfA=; b=clwEcMGRWYKHvtKj+70fbOgaQKK20FklUtukLfYS/LQOvNxLJNpMQorkocYwtl9y/Z j0pYADPC/WWQ0dwJFAHmJgH5qw2axP0Uh+rBHl0P1bX6MAfzoYZoG5MyFPSNUXP5/HrU qLnTQQpVGZ7jSwwc+VFWAERpbpKRpMmKZVwJ6ZxRIXrfP3wu5YZyRUNxY4UOp+NKS/B5 72udO5633emb+QjYUHzPzT8HVUhTiRQ0S/QZdlLlIPE39g7rXOfj7+MdnsSCgT0L1NLB MY3gs9WFbn2sHOcSaBovcDzpkJEdpdyiyzP8f4xyWtSqv8TrVf6VhjesnlT4xYnFwC3F iDPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709641131; x=1710245931; 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=LhUxtBkvb4r+WsD7JiENu61BSWgpCAqrg2uG7NyPqfA=; b=GgvwfHxHyl4nC01IbTEtDkWh+BN00MdD284dUu9ugC30U3GE+pBJLa/ncpxWfod/rr aY389s3rF4iQkT411G7hex45cM4YN/Ml9dDZLlilk8R5qpM9ZAiqIV/3rVs7E+VUKCAt y/REMcY/h2JsRImlqLOMi1hv5+hY5je0SeLbk7t1bVAmZNxJYPj12m9BWIoUGrvaKJhL zNDhkWXKnAXleUawvS9ZCfZ+xl1BDMv7E2cbAsHyW9Wp+svhAYbxzHqWX+QPzG2ITJfA Ed4DTNHvHx0CrYwsyWuXCrhoXU7SUb8XjtZiSs3QL+qxRQKh2AQ9D7iFYL90uod6uWjS Ftog== X-Gm-Message-State: AOJu0Yzic0VEm9v5nTva3rPoK+2nyZvoTgz3Ef+pjsdcNyAq2zAUo2z8 5WZEgeHCCDEog0kIjpbWyphwDTzAolSqG4d5FeVmCoo0HVN3auLWernrK8O0SwA= X-Google-Smtp-Source: AGHT+IEdQdKDDAy5Vi6EQDojoPdqGfrlX279HocnRF1Zd6b/Qc6DrKhOLoNmh0GmqG7GjkeTZF9B6Q== X-Received: by 2002:a05:600c:1e05:b0:412:e90e:54b7 with SMTP id ay5-20020a05600c1e0500b00412e90e54b7mr2602225wmb.33.1709641130835; Tue, 05 Mar 2024 04:18:50 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Wainer dos Santos Moschetta , Alistair Francis , Nicholas Piggin , Liu Zhiwei , Richard Henderson , Yanan Wang , qemu-s390x@nongnu.org, "Edgar E. Iglesias" , Eduardo Habkost , Daniel Henrique Barboza , Michael Rolnik , Daniel Henrique Barboza , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Laurent Vivier , Yoshinori Sato , Laurent Vivier , Thomas Huth , Peter Maydell , Mahmoud Mandour , Brad Smith , Alistair Francis , Brian Cain , Cleber Rosa , John Snow , Marcel Apfelbaum , Pierrick Bouvier , Palmer Dabbelt , Riku Voipio , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, Weiwei Li , Bin Meng , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Beraldo Leal , Kyle Evans , David Hildenbrand , Song Gao , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Paolo Bonzini , Alexandre Iooss , Warner Losh , qemu-riscv@nongnu.org, Ilya Leoshkevich , Luc Michel Subject: [PATCH 20/29] tests/plugin/insn: migrate to new per_vcpu API Date: Tue, 5 Mar 2024 12:09:56 +0000 Message-Id: <20240305121005.3528075-21-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240305121005.3528075-1-alex.bennee@linaro.org> References: <20240305121005.3528075-1-alex.bennee@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::330; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x330.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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1709641320710100001 From: Pierrick Bouvier Reviewed-by: Luc Michel Signed-off-by: Pierrick Bouvier Message-Id: <20240304130036.124418-8-pierrick.bouvier@linaro.org> Signed-off-by: Alex Benn=C3=A9e --- tests/plugin/insn.c | 106 +++++++++++++++++++++----------------------- 1 file changed, 50 insertions(+), 56 deletions(-) diff --git a/tests/plugin/insn.c b/tests/plugin/insn.c index 54da06fcf26..5e0aa03223e 100644 --- a/tests/plugin/insn.c +++ b/tests/plugin/insn.c @@ -16,25 +16,21 @@ =20 QEMU_PLUGIN_EXPORT int qemu_plugin_version =3D QEMU_PLUGIN_VERSION; =20 -#define MAX_CPUS 8 /* lets not go nuts */ - -typedef struct { - uint64_t insn_count; -} InstructionCount; - -static InstructionCount counts[MAX_CPUS]; -static uint64_t inline_insn_count; +static qemu_plugin_u64 insn_count; =20 static bool do_inline; static bool do_size; static GArray *sizes; =20 +typedef struct { + uint64_t hits; + uint64_t last_hit; + uint64_t total_delta; +} MatchCount; + typedef struct { char *match_string; - uint64_t hits[MAX_CPUS]; - uint64_t last_hit[MAX_CPUS]; - uint64_t total_delta[MAX_CPUS]; - GPtrArray *history[MAX_CPUS]; + struct qemu_plugin_scoreboard *counts; /* MatchCount */ } Match; =20 static GArray *matches; @@ -67,41 +63,40 @@ static void vcpu_init(qemu_plugin_id_t id, unsigned int= vcpu_index) =20 static void vcpu_insn_exec_before(unsigned int cpu_index, void *udata) { - unsigned int i =3D cpu_index % MAX_CPUS; - InstructionCount *c =3D &counts[i]; - - c->insn_count++; + qemu_plugin_u64_add(insn_count, cpu_index, 1); } =20 static void vcpu_insn_matched_exec_before(unsigned int cpu_index, void *ud= ata) { - unsigned int i =3D cpu_index % MAX_CPUS; Instruction *insn =3D (Instruction *) udata; - Match *match =3D insn->match; + Match *insn_match =3D insn->match; + MatchCount *match =3D qemu_plugin_scoreboard_find(insn_match->counts, + cpu_index); + g_autoptr(GString) ts =3D g_string_new(""); =20 insn->hits++; g_string_append_printf(ts, "0x%" PRIx64 ", '%s', %"PRId64 " hits", insn->vaddr, insn->disas, insn->hits); =20 - uint64_t icount =3D counts[i].insn_count; - uint64_t delta =3D icount - match->last_hit[i]; + uint64_t icount =3D qemu_plugin_u64_get(insn_count, cpu_index); + uint64_t delta =3D icount - match->last_hit; =20 - match->hits[i]++; - match->total_delta[i] +=3D delta; + match->hits++; + match->total_delta +=3D delta; =20 g_string_append_printf(ts, - ", %"PRId64" match hits, " - "=CE=94+%"PRId64 " since last match," + " , cpu %u," + " %"PRId64" match hits," + " =CE=94+%"PRId64 " since last match," " %"PRId64 " avg insns/match\n", - match->hits[i], delta, - match->total_delta[i] / match->hits[i]); + cpu_index, + match->hits, delta, + match->total_delta / match->hits); =20 - match->last_hit[i] =3D icount; + match->last_hit =3D icount; =20 qemu_plugin_outs(ts->str); - - g_ptr_array_add(match->history[i], insn); } =20 static void vcpu_tb_trans(qemu_plugin_id_t id, struct qemu_plugin_tb *tb) @@ -113,8 +108,8 @@ static void vcpu_tb_trans(qemu_plugin_id_t id, struct q= emu_plugin_tb *tb) struct qemu_plugin_insn *insn =3D qemu_plugin_tb_get_insn(tb, i); =20 if (do_inline) { - qemu_plugin_register_vcpu_insn_exec_inline( - insn, QEMU_PLUGIN_INLINE_ADD_U64, &inline_insn_count, 1); + qemu_plugin_register_vcpu_insn_exec_inline_per_vcpu( + insn, QEMU_PLUGIN_INLINE_ADD_U64, insn_count, 1); } else { uint64_t vaddr =3D qemu_plugin_insn_vaddr(insn); qemu_plugin_register_vcpu_insn_exec_cb( @@ -136,10 +131,9 @@ static void vcpu_tb_trans(qemu_plugin_id_t id, struct = qemu_plugin_tb *tb) * information about the instruction which we also need to * save if there is a hit. */ - if (matches) { + if (matches->len) { char *insn_disas =3D qemu_plugin_insn_disas(insn); - int j; - for (j =3D 0; j < matches->len; j++) { + for (int j =3D 0; j < matches->len; j++) { Match *m =3D &g_array_index(matches, Match, j); if (g_str_has_prefix(insn_disas, m->match_string)) { Instruction *rec =3D g_new0(Instruction, 1); @@ -169,36 +163,33 @@ static void plugin_exit(qemu_plugin_id_t id, void *p) "len %d bytes: %ld insns\n", i, *cn= t); } } - } else if (do_inline) { - g_string_append_printf(out, "insns: %" PRIu64 "\n", inline_insn_co= unt); } else { - uint64_t total_insns =3D 0; - for (i =3D 0; i < MAX_CPUS; i++) { - InstructionCount *c =3D &counts[i]; - if (c->insn_count) { - g_string_append_printf(out, "cpu %d insns: %" PRIu64 "\n", - i, c->insn_count); - total_insns +=3D c->insn_count; - } + for (i =3D 0; i < qemu_plugin_num_vcpus(); i++) { + g_string_append_printf(out, "cpu %d insns: %" PRIu64 "\n", + i, qemu_plugin_u64_get(insn_count, i)); } g_string_append_printf(out, "total insns: %" PRIu64 "\n", - total_insns); + qemu_plugin_u64_sum(insn_count)); } qemu_plugin_outs(out->str); + + qemu_plugin_scoreboard_free(insn_count.score); + for (i =3D 0; i < matches->len; ++i) { + Match *m =3D &g_array_index(matches, Match, i); + g_free(m->match_string); + qemu_plugin_scoreboard_free(m->counts); + } + g_array_free(matches, TRUE); + g_array_free(sizes, TRUE); } =20 =20 /* Add a match to the array of matches */ static void parse_match(char *match) { - Match new_match =3D { .match_string =3D match }; - int i; - for (i =3D 0; i < MAX_CPUS; i++) { - new_match.history[i] =3D g_ptr_array_new(); - } - if (!matches) { - matches =3D g_array_new(false, true, sizeof(Match)); - } + Match new_match =3D { + .match_string =3D g_strdup(match), + .counts =3D qemu_plugin_scoreboard_new(sizeof(MatchCount)) }; g_array_append_val(matches, new_match); } =20 @@ -206,6 +197,10 @@ QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin= _id_t id, const qemu_info_t *info, int argc, char **argv) { + matches =3D g_array_new(false, true, sizeof(Match)); + /* null terminated so 0 is not a special case */ + sizes =3D g_array_new(true, true, sizeof(unsigned long)); + for (int i =3D 0; i < argc; i++) { char *opt =3D argv[i]; g_auto(GStrv) tokens =3D g_strsplit(opt, "=3D", 2); @@ -227,9 +222,8 @@ QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_= id_t id, } } =20 - if (do_size) { - sizes =3D g_array_new(true, true, sizeof(unsigned long)); - } + insn_count =3D qemu_plugin_scoreboard_u64( + qemu_plugin_scoreboard_new(sizeof(uint64_t))); =20 /* Register init, translation block and exit callbacks */ qemu_plugin_register_vcpu_init_cb(id, vcpu_init); --=20 2.39.2 From nobody Tue Nov 26 04:50:37 2024 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=1709641303; cv=none; d=zohomail.com; s=zohoarc; b=bW/xPZ2jzPQFwkfh7om0fu2p19YSzjstnnFOU5hWFy/WE2h+O3eAwXr/S7DNNiXZ8jCs7Tj3wrI6qpy9MSY/0goEjp/obRQnDOnJaGcUftWV/Yc9Hrx6GNWz6JG9DK7IwUNAqWDBIoMatCMjh+ap9wrHhj5QwiFvniP9EVJit+M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709641303; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=0DbWEIw6HJ+uey+RCD8YTAnKD0TfXpa90qc4hKJ7nSE=; b=N8A72+mjsIunidB9ADCe3g40Fqpd9XmF7oAygMMgmaq0Uhd/rtgAwYVImnqZScTjfm60xCIJ5TqIMAA41LdMVk78xTshYxB36sw/vPUyqCtVSVuOHs6/Dyfike/fosiw9QdcSuWbAvH6hfHipf6uU/KK7klCMWD1AhjGhiz9nJE= 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 1709641303046882.2382943820488; Tue, 5 Mar 2024 04:21:43 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rhTnE-0004jg-Sy; Tue, 05 Mar 2024 07:21:13 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rhTlH-0000lR-VQ for qemu-devel@nongnu.org; Tue, 05 Mar 2024 07:19:13 -0500 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 1rhTky-0003GU-Hx for qemu-devel@nongnu.org; Tue, 05 Mar 2024 07:19:11 -0500 Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-412ecc1064cso4654475e9.2 for ; Tue, 05 Mar 2024 04:18:50 -0800 (PST) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id o14-20020a05600c510e00b00412aff7874esm17909157wms.48.2024.03.05.04.18.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Mar 2024 04:18:47 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 745EA5F9EB; Tue, 5 Mar 2024 12:10:07 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1709641129; x=1710245929; 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=0DbWEIw6HJ+uey+RCD8YTAnKD0TfXpa90qc4hKJ7nSE=; b=KWKcKfJzKqBBucjYSsJ5A2c9BXeBXRO8B+4p4RZZofN4nnAjCSxoj+vLv82yVIgZkr owOuhjRXoVsXi5clnFaCed2K1ej418maCJM7h25+ZQQgEt87c0cp6hhuUr4ocYZ+2evA 15TU9OCUiztfN+3tYfw1nxVD161AZmfqlTufR+Zy/92Dw+AraMzxgMLMTuJyOjHGUxYx uZ2A89U5k0RzGThrMCFE04xc5qnOzxUteqM2jq565wKee2h2zCLPjwqrk9UdybVkfjgS RAmyxcdkXYGYCRWqJF8Xy5FFP1hHcTPVWZh5xHs039AjsqFmYMMCjWq9tiKxQ+p4kN26 jIvw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709641129; x=1710245929; 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=0DbWEIw6HJ+uey+RCD8YTAnKD0TfXpa90qc4hKJ7nSE=; b=LemkFSOjxgKf1ofmCSI9rmkqc6xZNRHxGsJZejx3JZ78m8S/mS0/hNPOQA8fnQsgm7 BSPlPie6EFrVVcc3gkhlIuZ8J+Dnn+AXxd0uhjbZRy5uqpQe0LaxFEzqVGujSVqz8w9h Vk1noAbCUVjTUSjP9zZF6uxTHSfHol2sIolInqV0tKTj5GxPHHQtyt6pdUOgiLfCWizm zjmM4IJfjKfovhj79200cTvylVkddjMnXE9KCwWXGasrNL19Fmbdd1AiuWtlHixVSz7u 1i4d/h2sHJAvYY22oi9URO5BzZQO8J1UzrDuhA9Q9sFYIB5j9Px1kzjMLGHOWCwEMmRO nOEg== X-Gm-Message-State: AOJu0Ywlocbw2Gc4U7ZV2a5bPCgoJw3c5NTAb7+kGYGvE/NXJhIUzF6k O6nzYqLzFvDWO/E4eiWc4B0iTWzDedkRj+IN48EDpw4MkbxyHe/Kvm10M+nUj2E= X-Google-Smtp-Source: AGHT+IGfyy+dD2vdSUvdl9WkKm29wASBydjUohaSp1SjKoA9U9LJjqipZCm5xHC/sVcSl1NaJU59kw== X-Received: by 2002:a05:600c:5253:b0:40e:d30b:6129 with SMTP id fc19-20020a05600c525300b0040ed30b6129mr9771561wmb.13.1709641129102; Tue, 05 Mar 2024 04:18:49 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Wainer dos Santos Moschetta , Alistair Francis , Nicholas Piggin , Liu Zhiwei , Richard Henderson , Yanan Wang , qemu-s390x@nongnu.org, "Edgar E. Iglesias" , Eduardo Habkost , Daniel Henrique Barboza , Michael Rolnik , Daniel Henrique Barboza , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Laurent Vivier , Yoshinori Sato , Laurent Vivier , Thomas Huth , Peter Maydell , Mahmoud Mandour , Brad Smith , Alistair Francis , Brian Cain , Cleber Rosa , John Snow , Marcel Apfelbaum , Pierrick Bouvier , Palmer Dabbelt , Riku Voipio , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, Weiwei Li , Bin Meng , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Beraldo Leal , Kyle Evans , David Hildenbrand , Song Gao , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Paolo Bonzini , Alexandre Iooss , Warner Losh , qemu-riscv@nongnu.org, Ilya Leoshkevich , Luc Michel Subject: [PATCH 21/29] tests/plugin/bb: migrate to new per_vcpu API Date: Tue, 5 Mar 2024 12:09:57 +0000 Message-Id: <20240305121005.3528075-22-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240305121005.3528075-1-alex.bennee@linaro.org> References: <20240305121005.3528075-1-alex.bennee@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=alex.bennee@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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1709641304511100001 From: Pierrick Bouvier Reviewed-by: Luc Michel Reviewed-by: Alex Benn=C3=A9e Signed-off-by: Pierrick Bouvier Message-Id: <20240304130036.124418-9-pierrick.bouvier@linaro.org> Signed-off-by: Alex Benn=C3=A9e --- tests/plugin/bb.c | 63 +++++++++++++++++++---------------------------- 1 file changed, 26 insertions(+), 37 deletions(-) diff --git a/tests/plugin/bb.c b/tests/plugin/bb.c index df50d1fd3bc..36776dee1e1 100644 --- a/tests/plugin/bb.c +++ b/tests/plugin/bb.c @@ -17,27 +17,25 @@ QEMU_PLUGIN_EXPORT int qemu_plugin_version =3D QEMU_PLUGIN_VERSION; =20 typedef struct { - GMutex lock; - int index; uint64_t bb_count; uint64_t insn_count; } CPUCount; =20 -/* Used by the inline & linux-user counts */ -static bool do_inline; -static CPUCount inline_count; +static struct qemu_plugin_scoreboard *counts; +static qemu_plugin_u64 bb_count; +static qemu_plugin_u64 insn_count; =20 +static bool do_inline; /* Dump running CPU total on idle? */ static bool idle_report; -static GPtrArray *counts; -static int max_cpus; =20 -static void gen_one_cpu_report(CPUCount *count, GString *report) +static void gen_one_cpu_report(CPUCount *count, GString *report, + unsigned int cpu_index) { if (count->bb_count) { g_string_append_printf(report, "CPU%d: " "bb's: %" PRIu64", insns: %" PRIu64 "\n", - count->index, + cpu_index, count->bb_count, count->insn_count); } } @@ -46,20 +44,23 @@ static void plugin_exit(qemu_plugin_id_t id, void *p) { g_autoptr(GString) report =3D g_string_new(""); =20 - if (do_inline || !max_cpus) { - g_string_printf(report, "bb's: %" PRIu64", insns: %" PRIu64 "\n", - inline_count.bb_count, inline_count.insn_count); - } else { - g_ptr_array_foreach(counts, (GFunc) gen_one_cpu_report, report); + for (int i =3D 0; i < qemu_plugin_num_vcpus(); ++i) { + CPUCount *count =3D qemu_plugin_scoreboard_find(counts, i); + gen_one_cpu_report(count, report, i); } + g_string_append_printf(report, "Total: " + "bb's: %" PRIu64", insns: %" PRIu64 "\n", + qemu_plugin_u64_sum(bb_count), + qemu_plugin_u64_sum(insn_count)); qemu_plugin_outs(report->str); + qemu_plugin_scoreboard_free(counts); } =20 static void vcpu_idle(qemu_plugin_id_t id, unsigned int cpu_index) { - CPUCount *count =3D g_ptr_array_index(counts, cpu_index); + CPUCount *count =3D qemu_plugin_scoreboard_find(counts, cpu_index); g_autoptr(GString) report =3D g_string_new(""); - gen_one_cpu_report(count, report); + gen_one_cpu_report(count, report, cpu_index); =20 if (report->len > 0) { g_string_prepend(report, "Idling "); @@ -69,14 +70,11 @@ static void vcpu_idle(qemu_plugin_id_t id, unsigned int= cpu_index) =20 static void vcpu_tb_exec(unsigned int cpu_index, void *udata) { - CPUCount *count =3D max_cpus ? - g_ptr_array_index(counts, cpu_index) : &inline_count; + CPUCount *count =3D qemu_plugin_scoreboard_find(counts, cpu_index); =20 uintptr_t n_insns =3D (uintptr_t)udata; - g_mutex_lock(&count->lock); count->insn_count +=3D n_insns; count->bb_count++; - g_mutex_unlock(&count->lock); } =20 static void vcpu_tb_trans(qemu_plugin_id_t id, struct qemu_plugin_tb *tb) @@ -84,11 +82,10 @@ static void vcpu_tb_trans(qemu_plugin_id_t id, struct q= emu_plugin_tb *tb) size_t n_insns =3D qemu_plugin_tb_n_insns(tb); =20 if (do_inline) { - qemu_plugin_register_vcpu_tb_exec_inline(tb, QEMU_PLUGIN_INLINE_AD= D_U64, - &inline_count.bb_count, 1= ); - qemu_plugin_register_vcpu_tb_exec_inline(tb, QEMU_PLUGIN_INLINE_AD= D_U64, - &inline_count.insn_count, - n_insns); + qemu_plugin_register_vcpu_tb_exec_inline_per_vcpu( + tb, QEMU_PLUGIN_INLINE_ADD_U64, bb_count, 1); + qemu_plugin_register_vcpu_tb_exec_inline_per_vcpu( + tb, QEMU_PLUGIN_INLINE_ADD_U64, insn_count, n_insns); } else { qemu_plugin_register_vcpu_tb_exec_cb(tb, vcpu_tb_exec, QEMU_PLUGIN_CB_NO_REGS, @@ -121,18 +118,10 @@ QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugi= n_id_t id, } } =20 - if (info->system_emulation && !do_inline) { - max_cpus =3D info->system.max_vcpus; - counts =3D g_ptr_array_new(); - for (i =3D 0; i < max_cpus; i++) { - CPUCount *count =3D g_new0(CPUCount, 1); - g_mutex_init(&count->lock); - count->index =3D i; - g_ptr_array_add(counts, count); - } - } else if (!do_inline) { - g_mutex_init(&inline_count.lock); - } + counts =3D qemu_plugin_scoreboard_new(sizeof(CPUCount)); + bb_count =3D qemu_plugin_scoreboard_u64_in_struct(counts, CPUCount, bb= _count); + insn_count =3D qemu_plugin_scoreboard_u64_in_struct( + counts, CPUCount, insn_count); =20 if (idle_report) { qemu_plugin_register_vcpu_idle_cb(id, vcpu_idle); --=20 2.39.2 From nobody Tue Nov 26 04:50:37 2024 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=1709641299; cv=none; d=zohomail.com; s=zohoarc; b=Tp03gg6rL5ov2rkFgYgIrUJz9DvnedHOjkrj6drPg7I+/YHlUi6vyHz4Z4XQwd4xf2zBLIIQt/y0WpsIrvrKhkSe9vNU9vKdtm1QvhtMURKYbjE4TVm7Uiy3lOMf1e/L037wJk1MWojqLbBD7bvMwVIcrAjQEhZwXND0svnYsHA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709641299; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=gYxkfjxE/ujF2xkNpfNd0jj3/ppsExy9PCxHQTHLuH4=; b=YskJHwHTT+GilYyyssLAhnxB99sDOf+aMW/h2L95GSZhCjmK1aJo+ofIeFgROulcOlk19wY2OWif/QPFffnN4AQYNPhxSIjwS7aXCCEgRWZciRL1jsBWT9SfiZVaLw/cDB9slfWxYvFcM5NrIikbiAAAbv9jQqBBM4nL3HOD6uo= 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 1709641299440935.286826305949; Tue, 5 Mar 2024 04:21:39 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rhTmm-0003Xx-BV; Tue, 05 Mar 2024 07:20:44 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rhTl0-0008Oq-2g for qemu-devel@nongnu.org; Tue, 05 Mar 2024 07:18:56 -0500 Received: from mail-wr1-x42d.google.com ([2a00:1450:4864:20::42d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rhTks-0003DT-BB for qemu-devel@nongnu.org; Tue, 05 Mar 2024 07:18:53 -0500 Received: by mail-wr1-x42d.google.com with SMTP id ffacd0b85a97d-33dd2f0a0c4so3222095f8f.0 for ; Tue, 05 Mar 2024 04:18:45 -0800 (PST) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id bt12-20020a056000080c00b0033e3a110d7fsm6390168wrb.71.2024.03.05.04.18.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Mar 2024 04:18:43 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 87D885F9ED; Tue, 5 Mar 2024 12:10:07 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1709641124; x=1710245924; 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=gYxkfjxE/ujF2xkNpfNd0jj3/ppsExy9PCxHQTHLuH4=; b=d9Ep0UtD3Gmu9ol9jrsnif8iCdyyXxMcWc5ddD4dL0W7CIXLzoXmgtIg97JrT02KOh TKRc/Uu8uCe/GMa8C+IAUmz2Di3a7CEWQjT+hKAdMaJnPYH9VrcvnmEH940amKKkcPHH qI83/4mRWqctxCuU8Si1kZrA3nyJI8hjWJsNl+qsLAD2wf8ECYtcmvlAq4vL0QVxprwi 3YfakmRgBqIbNk2/NmWD2e2IEMr4MquzmhbDIJxUYYbDJMlzXqxpCWTc+kBxt+SQpMEP +42WRjw5lXH2OuM57eqK09q4DmB7QKmzWb9YBocynuIxrX0k24A9w+vkux94DDOzepkv uE8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709641124; x=1710245924; 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=gYxkfjxE/ujF2xkNpfNd0jj3/ppsExy9PCxHQTHLuH4=; b=p/O16MF2Yr9YNqN4SApTAsKY4zZgEXBhGcqzToK486f5YKUbxsn61DPX8RsKpaRLHc C0wwt/1EItW7Cp+3a4tymJbEbY4cYfvbZlwAo+6HsY6bHUPEjoKXSKQXlElpQR76FLwn sSBKN9q8myLrTlzC8bCgHJUqMfNv9tN6jkr7fhy/einNDVM9KQ03OCbyn7ay/A2RXnJH ALj6A1JLRqdiF+K8N38Ngosd7vw0t9S4ea3gyshWI87IMzga3V8qQvSwvBNHQ/cKocfP GtkO//ShDeouEu6xP7Rm7N85rlKYrkU7qNAq1d5rA8gje/oixevHndwtavGLWFHS2bXH kkmQ== X-Gm-Message-State: AOJu0YzgmLMq6i7J8npKwvzGEgLApvqm7GiRHD1Ox/OSug5cUl3Lpu42 sO3YJT5NedOPkYFPSB5xwOZZd4ZwQnRi4NX49PvhXCeo7HvVdDcFm4ZmmR793GefKt/gjDK0w4W y X-Google-Smtp-Source: AGHT+IE3XgG2lbmjNAvKm7fVyZM8ZkhcVQl2Ky6f/FBuP8lHb+dy0y7ryzA9hyngqhRSbQAg49HgeA== X-Received: by 2002:adf:ab07:0:b0:33d:2071:9b85 with SMTP id q7-20020adfab07000000b0033d20719b85mr7415109wrc.19.1709641124024; Tue, 05 Mar 2024 04:18:44 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Wainer dos Santos Moschetta , Alistair Francis , Nicholas Piggin , Liu Zhiwei , Richard Henderson , Yanan Wang , qemu-s390x@nongnu.org, "Edgar E. Iglesias" , Eduardo Habkost , Daniel Henrique Barboza , Michael Rolnik , Daniel Henrique Barboza , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Laurent Vivier , Yoshinori Sato , Laurent Vivier , Thomas Huth , Peter Maydell , Mahmoud Mandour , Brad Smith , Alistair Francis , Brian Cain , Cleber Rosa , John Snow , Marcel Apfelbaum , Pierrick Bouvier , Palmer Dabbelt , Riku Voipio , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, Weiwei Li , Bin Meng , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Beraldo Leal , Kyle Evans , David Hildenbrand , Song Gao , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Paolo Bonzini , Alexandre Iooss , Warner Losh , qemu-riscv@nongnu.org, Ilya Leoshkevich Subject: [PATCH 22/29] contrib/plugins/hotblocks: migrate to new per_vcpu API Date: Tue, 5 Mar 2024 12:09:58 +0000 Message-Id: <20240305121005.3528075-23-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240305121005.3528075-1-alex.bennee@linaro.org> References: <20240305121005.3528075-1-alex.bennee@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::42d; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x42d.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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1709641300487100001 From: Pierrick Bouvier Signed-off-by: Pierrick Bouvier Message-Id: <20240304130036.124418-10-pierrick.bouvier@linaro.org> Signed-off-by: Alex Benn=C3=A9e --- contrib/plugins/hotblocks.c | 50 ++++++++++++++++++++++--------------- 1 file changed, 30 insertions(+), 20 deletions(-) diff --git a/contrib/plugins/hotblocks.c b/contrib/plugins/hotblocks.c index 4de1b134944..02bc5078bdd 100644 --- a/contrib/plugins/hotblocks.c +++ b/contrib/plugins/hotblocks.c @@ -34,8 +34,8 @@ static guint64 limit =3D 20; */ typedef struct { uint64_t start_addr; - uint64_t exec_count; - int trans_count; + struct qemu_plugin_scoreboard *exec_count; + int trans_count; unsigned long insns; } ExecCount; =20 @@ -43,7 +43,17 @@ static gint cmp_exec_count(gconstpointer a, gconstpointe= r b) { ExecCount *ea =3D (ExecCount *) a; ExecCount *eb =3D (ExecCount *) b; - return ea->exec_count > eb->exec_count ? -1 : 1; + uint64_t count_a =3D + qemu_plugin_u64_sum(qemu_plugin_scoreboard_u64(ea->exec_count)); + uint64_t count_b =3D + qemu_plugin_u64_sum(qemu_plugin_scoreboard_u64(eb->exec_count)); + return count_a > count_b ? -1 : 1; +} + +static void exec_count_free(gpointer key, gpointer value, gpointer user_da= ta) +{ + ExecCount *cnt =3D value; + qemu_plugin_scoreboard_free(cnt->exec_count); } =20 static void plugin_exit(qemu_plugin_id_t id, void *p) @@ -52,7 +62,6 @@ static void plugin_exit(qemu_plugin_id_t id, void *p) GList *counts, *it; int i; =20 - g_mutex_lock(&lock); g_string_append_printf(report, "%d entries in the hash table\n", g_hash_table_size(hotblocks)); counts =3D g_hash_table_get_values(hotblocks); @@ -63,16 +72,21 @@ static void plugin_exit(qemu_plugin_id_t id, void *p) =20 for (i =3D 0; i < limit && it->next; i++, it =3D it->next) { ExecCount *rec =3D (ExecCount *) it->data; - g_string_append_printf(report, "0x%016"PRIx64", %d, %ld, %"PRI= d64"\n", - rec->start_addr, rec->trans_count, - rec->insns, rec->exec_count); + g_string_append_printf( + report, "0x%016"PRIx64", %d, %ld, %"PRId64"\n", + rec->start_addr, rec->trans_count, + rec->insns, + qemu_plugin_u64_sum( + qemu_plugin_scoreboard_u64(rec->exec_count))); } =20 g_list_free(it); } - g_mutex_unlock(&lock); =20 qemu_plugin_outs(report->str); + + g_hash_table_foreach(hotblocks, exec_count_free, NULL); + g_hash_table_destroy(hotblocks); } =20 static void plugin_init(void) @@ -82,15 +96,9 @@ static void plugin_init(void) =20 static void vcpu_tb_exec(unsigned int cpu_index, void *udata) { - ExecCount *cnt; - uint64_t hash =3D (uint64_t) udata; - - g_mutex_lock(&lock); - cnt =3D (ExecCount *) g_hash_table_lookup(hotblocks, (gconstpointer) h= ash); - /* should always succeed */ - g_assert(cnt); - cnt->exec_count++; - g_mutex_unlock(&lock); + ExecCount *cnt =3D (ExecCount *)udata; + qemu_plugin_u64_add(qemu_plugin_scoreboard_u64(cnt->exec_count), + cpu_index, 1); } =20 /* @@ -114,18 +122,20 @@ static void vcpu_tb_trans(qemu_plugin_id_t id, struct= qemu_plugin_tb *tb) cnt->start_addr =3D pc; cnt->trans_count =3D 1; cnt->insns =3D insns; + cnt->exec_count =3D qemu_plugin_scoreboard_new(sizeof(uint64_t)); g_hash_table_insert(hotblocks, (gpointer) hash, (gpointer) cnt); } =20 g_mutex_unlock(&lock); =20 if (do_inline) { - qemu_plugin_register_vcpu_tb_exec_inline(tb, QEMU_PLUGIN_INLINE_AD= D_U64, - &cnt->exec_count, 1); + qemu_plugin_register_vcpu_tb_exec_inline_per_vcpu( + tb, QEMU_PLUGIN_INLINE_ADD_U64, + qemu_plugin_scoreboard_u64(cnt->exec_count), 1); } else { qemu_plugin_register_vcpu_tb_exec_cb(tb, vcpu_tb_exec, QEMU_PLUGIN_CB_NO_REGS, - (void *)hash); + (void *)cnt); } } =20 --=20 2.39.2 From nobody Tue Nov 26 04:50:37 2024 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=1709640764; cv=none; d=zohomail.com; s=zohoarc; b=cMQVTGOwf4s2h2Q0jmuqkm8pjGEKuemxcNMl3idISOtzhNWauPb6ThJlGl5RVVlcJQkt81Hwnhz4Cmib/BYSkWN/MAv7jRFD/QPbyynlg+yHuj56FvL/Q2w8Oxc2zkbztSlNccEIZAyun+JZzRym9R+NzHg9LMJHJCPvD2ogMZY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709640764; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=si4aR9NfjrmIkwaCSp8Q5XtDAxgYAPx/w5B7UtqWjho=; b=XE6ogIehTdjaIe0EIh22TMg9+jocLOf+QXgumQZaFLigqaARso46QWn9C1gVPizljE5rCpmEBZY1mwbqQXIVc9mTbV42y8elgHagjZWCdNxb5emAbpxFxECHWZOjRLsGlpduNxPilmf7HQ9qAIAfItaRu+KAc5xidP2oee1b78g= 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 1709640764688203.04211251619927; Tue, 5 Mar 2024 04:12:44 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rhTeF-0003c8-2L; Tue, 05 Mar 2024 07:11:55 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rhTdT-00023c-Ko for qemu-devel@nongnu.org; Tue, 05 Mar 2024 07:11:08 -0500 Received: from mail-lj1-x231.google.com ([2a00:1450:4864:20::231]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rhTcr-0001Wj-Ap for qemu-devel@nongnu.org; Tue, 05 Mar 2024 07:11:06 -0500 Received: by mail-lj1-x231.google.com with SMTP id 38308e7fff4ca-2d22b8801b9so79370241fa.0 for ; Tue, 05 Mar 2024 04:10:24 -0800 (PST) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id bu16-20020a056000079000b0033dc3f3d689sm14939377wrb.93.2024.03.05.04.10.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Mar 2024 04:10:19 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 9BEBA5F9F3; Tue, 5 Mar 2024 12:10:07 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1709640623; x=1710245423; 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=si4aR9NfjrmIkwaCSp8Q5XtDAxgYAPx/w5B7UtqWjho=; b=DjAAfgbkXid8Jvq6ps+FrrYz/20f0pvH+z/1MU9sm2QKSYxp/aj83sYZPpHkcGj9zB jwp3PilAYwnV4fvio7ZQ49VyPPriPuOLzsPINkXrhg63/IzIzeXlEK65rF3OIZhy4IJ/ wGa0kkCk5NWYfKbGVXX4Et0s8NEL022922HTkGXO45B4KL0nMcbf9rlqMDAhaWjacaJ+ X75Ydri2WX42KY52i30S6GmokH2pVpHTgaZ3l9LnoAMJNX3wDzEF2kn/+COD7XubdjDD Zng3Au8eeJIWyplOAJ/EJZnlkxLGs2y1GPKJHBMowfEG1QuuYhH6sxhE36HO4RPZUXN6 oZaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709640623; x=1710245423; 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=si4aR9NfjrmIkwaCSp8Q5XtDAxgYAPx/w5B7UtqWjho=; b=a0lCFYwmQOqnPTdVqBRQSrjcsbfc062KjGxCDW9T/LgZIP8LxCfkAQfcEl1J777vpX pv1V6f5ITXipeylYUh3OjEl6WkrQ7bH5CDBseKPeuAKkp/ArqXbrFm0vVv5Oz7BOaw/B COnm7En8oDfNOWm0ZuI6Jodyo8NgWu9jvkzyVKoRgwcfNEcDzRISKB/I5TY1kf4lw9dE aNe6XZ97GJquN0C+qa7IoWYXJy4yurvWSUL1ceDURXWL4N8ZSAWHsLwJl7pAxRFH3bUq xy4I4fbgIXHPqxX4AUKTsigFoQVq+OxM8cflksqfO8w1uzGU//g3PvZJ6imVukC6zSyP agQA== X-Gm-Message-State: AOJu0Yw+eQNOpWGZn4T+qxeHZGMjTV1k1DD2NQ2ZD/+5STAcJ+HepbFA S/erLCZJ1C1POlltI5XAvcoF8I0Vk0n4VxZvBKVcYqGYeriOsJVOQhfNtEB5adg= X-Google-Smtp-Source: AGHT+IGGF4YSwijsmfFzPsi+Kumnb9yXuKRux5ssF5J9Y8pyMD69wuVgpPZpBxiLmtDbzc66aVpc1A== X-Received: by 2002:a05:6512:78:b0:512:a966:eb5 with SMTP id i24-20020a056512007800b00512a9660eb5mr1030745lfo.21.1709640622984; Tue, 05 Mar 2024 04:10:22 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Wainer dos Santos Moschetta , Alistair Francis , Nicholas Piggin , Liu Zhiwei , Richard Henderson , Yanan Wang , qemu-s390x@nongnu.org, "Edgar E. Iglesias" , Eduardo Habkost , Daniel Henrique Barboza , Michael Rolnik , Daniel Henrique Barboza , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Laurent Vivier , Yoshinori Sato , Laurent Vivier , Thomas Huth , Peter Maydell , Mahmoud Mandour , Brad Smith , Alistair Francis , Brian Cain , Cleber Rosa , John Snow , Marcel Apfelbaum , Pierrick Bouvier , Palmer Dabbelt , Riku Voipio , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, Weiwei Li , Bin Meng , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Beraldo Leal , Kyle Evans , David Hildenbrand , Song Gao , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Paolo Bonzini , Alexandre Iooss , Warner Losh , qemu-riscv@nongnu.org, Ilya Leoshkevich Subject: [PATCH 23/29] contrib/plugins/howvec: migrate to new per_vcpu API Date: Tue, 5 Mar 2024 12:09:59 +0000 Message-Id: <20240305121005.3528075-24-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240305121005.3528075-1-alex.bennee@linaro.org> References: <20240305121005.3528075-1-alex.bennee@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::231; envelope-from=alex.bennee@linaro.org; helo=mail-lj1-x231.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, T_SCC_BODY_TEXT_LINE=-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: 1709640766006100001 From: Pierrick Bouvier Reviewed-by: Alex Benn=C3=A9e Tested-by: Alex Benn=C3=A9e Signed-off-by: Pierrick Bouvier Message-Id: <20240304130036.124418-11-pierrick.bouvier@linaro.org> Signed-off-by: Alex Benn=C3=A9e --- contrib/plugins/howvec.c | 53 ++++++++++++++++++++++++++++------------ 1 file changed, 38 insertions(+), 15 deletions(-) diff --git a/contrib/plugins/howvec.c b/contrib/plugins/howvec.c index 644a7856bb2..2d10c87e0fb 100644 --- a/contrib/plugins/howvec.c +++ b/contrib/plugins/howvec.c @@ -43,13 +43,13 @@ typedef struct { uint32_t mask; uint32_t pattern; CountType what; - uint64_t count; + qemu_plugin_u64 count; } InsnClassExecCount; =20 typedef struct { char *insn; uint32_t opcode; - uint64_t count; + qemu_plugin_u64 count; InsnClassExecCount *class; } InsnExecCount; =20 @@ -159,7 +159,9 @@ static gint cmp_exec_count(gconstpointer a, gconstpoint= er b) { InsnExecCount *ea =3D (InsnExecCount *) a; InsnExecCount *eb =3D (InsnExecCount *) b; - return ea->count > eb->count ? -1 : 1; + uint64_t count_a =3D qemu_plugin_u64_sum(ea->count); + uint64_t count_b =3D qemu_plugin_u64_sum(eb->count); + return count_a > count_b ? -1 : 1; } =20 static void free_record(gpointer data) @@ -167,12 +169,14 @@ static void free_record(gpointer data) InsnExecCount *rec =3D (InsnExecCount *) data; g_free(rec->insn); g_free(rec); + qemu_plugin_scoreboard_free(rec->count.score); } =20 static void plugin_exit(qemu_plugin_id_t id, void *p) { g_autoptr(GString) report =3D g_string_new("Instruction Classes:\n"); int i; + uint64_t total_count; GList *counts; InsnClassExecCount *class =3D NULL; =20 @@ -180,11 +184,12 @@ static void plugin_exit(qemu_plugin_id_t id, void *p) class =3D &class_table[i]; switch (class->what) { case COUNT_CLASS: - if (class->count || verbose) { + total_count =3D qemu_plugin_u64_sum(class->count); + if (total_count || verbose) { g_string_append_printf(report, "Class: %-24s\t(%" PRId64 " hits)\n= ", class->class, - class->count); + total_count); } break; case COUNT_INDIVIDUAL: @@ -212,7 +217,7 @@ static void plugin_exit(qemu_plugin_id_t id, void *p) "Instr: %-24s\t(%" PRId64 " hits)" "\t(op=3D0x%08x/%s)\n", rec->insn, - rec->count, + qemu_plugin_u64_sum(rec->count), rec->opcode, rec->class ? rec->class->class : "un-categorised"); @@ -221,6 +226,12 @@ static void plugin_exit(qemu_plugin_id_t id, void *p) } =20 g_hash_table_destroy(insns); + for (i =3D 0; i < ARRAY_SIZE(class_tables); i++) { + for (int j =3D 0; j < class_tables[i].table_sz; ++j) { + qemu_plugin_scoreboard_free(class_tables[i].table[j].count.sco= re); + } + } + =20 qemu_plugin_outs(report->str); } @@ -232,11 +243,12 @@ static void plugin_init(void) =20 static void vcpu_insn_exec_before(unsigned int cpu_index, void *udata) { - uint64_t *count =3D (uint64_t *) udata; - (*count)++; + struct qemu_plugin_scoreboard *score =3D udata; + qemu_plugin_u64_add(qemu_plugin_scoreboard_u64(score), cpu_index, 1); } =20 -static uint64_t *find_counter(struct qemu_plugin_insn *insn) +static struct qemu_plugin_scoreboard *find_counter( + struct qemu_plugin_insn *insn) { int i; uint64_t *cnt =3D NULL; @@ -265,7 +277,7 @@ static uint64_t *find_counter(struct qemu_plugin_insn *= insn) case COUNT_NONE: return NULL; case COUNT_CLASS: - return &class->count; + return class->count.score; case COUNT_INDIVIDUAL: { InsnExecCount *icount; @@ -279,13 +291,16 @@ static uint64_t *find_counter(struct qemu_plugin_insn= *insn) icount->opcode =3D opcode; icount->insn =3D qemu_plugin_insn_disas(insn); icount->class =3D class; + struct qemu_plugin_scoreboard *score =3D + qemu_plugin_scoreboard_new(sizeof(uint64_t)); + icount->count =3D qemu_plugin_scoreboard_u64(score); =20 g_hash_table_insert(insns, GUINT_TO_POINTER(opcode), (gpointer) icount); } g_mutex_unlock(&lock); =20 - return &icount->count; + return icount->count.score; } default: g_assert_not_reached(); @@ -300,14 +315,14 @@ static void vcpu_tb_trans(qemu_plugin_id_t id, struct= qemu_plugin_tb *tb) size_t i; =20 for (i =3D 0; i < n; i++) { - uint64_t *cnt; struct qemu_plugin_insn *insn =3D qemu_plugin_tb_get_insn(tb, i); - cnt =3D find_counter(insn); + struct qemu_plugin_scoreboard *cnt =3D find_counter(insn); =20 if (cnt) { if (do_inline) { - qemu_plugin_register_vcpu_insn_exec_inline( - insn, QEMU_PLUGIN_INLINE_ADD_U64, cnt, 1); + qemu_plugin_register_vcpu_insn_exec_inline_per_vcpu( + insn, QEMU_PLUGIN_INLINE_ADD_U64, + qemu_plugin_scoreboard_u64(cnt), 1); } else { qemu_plugin_register_vcpu_insn_exec_cb( insn, vcpu_insn_exec_before, QEMU_PLUGIN_CB_NO_REGS, c= nt); @@ -322,6 +337,14 @@ QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin= _id_t id, { int i; =20 + for (i =3D 0; i < ARRAY_SIZE(class_tables); i++) { + for (int j =3D 0; j < class_tables[i].table_sz; ++j) { + struct qemu_plugin_scoreboard *score =3D + qemu_plugin_scoreboard_new(sizeof(uint64_t)); + class_tables[i].table[j].count =3D qemu_plugin_scoreboard_u64(= score); + } + } + /* Select a class table appropriate to the guest architecture */ for (i =3D 0; i < ARRAY_SIZE(class_tables); i++) { ClassSelector *entry =3D &class_tables[i]; --=20 2.39.2 From nobody Tue Nov 26 04:50:37 2024 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=1709641341; cv=none; d=zohomail.com; s=zohoarc; b=Vg4MgVBo5/IrMdlBCIJ/0n0fCS9iYVFHXMMIyZgBdgF2CafbDMuV82TC3GoYtmHPL14K94C6c24u5dqo7tI7ua9zmTnbFCr8i5fvQJYR4zN8gwFruGHeOYTWiSiVvcGc/cr33xirylZKAU3pnUCVwtQTJU3iqxZxbTqCUqX5Go8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709641341; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Kw6JUcERnGErKtDrZC0R6JilUy4T39Q2xkp4LDaFvz4=; b=epQ3Bny+WJjlVWQ3tu743aFiMj7BLxrQv9VeYSeBTTv91HUf0ESTFcBP4EDKTyAF9awyj63dZ4XtWwTMVyyfyPuHOjcb9mRQtFVcTEmYO6oGBrZ+zpb8TezI0szPdBqN5IFxjHov5iYk5yZiX1YL5yZBiTD5zI2HDbwuEax/Wb4= 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 1709641341428577.9174541135976; Tue, 5 Mar 2024 04:22:21 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rhTne-0006LW-8I; Tue, 05 Mar 2024 07:21:38 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rhTlI-0000lW-Eo for qemu-devel@nongnu.org; Tue, 05 Mar 2024 07:19:13 -0500 Received: from mail-lf1-x12c.google.com ([2a00:1450:4864:20::12c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rhTky-0003H1-I0 for qemu-devel@nongnu.org; Tue, 05 Mar 2024 07:19:12 -0500 Received: by mail-lf1-x12c.google.com with SMTP id 2adb3069b0e04-51320ca689aso6735112e87.2 for ; Tue, 05 Mar 2024 04:18:50 -0800 (PST) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id o14-20020a05600c510e00b00412aff7874esm17909166wms.48.2024.03.05.04.18.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Mar 2024 04:18:47 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id B32FA5F9F4; Tue, 5 Mar 2024 12:10:07 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1709641129; x=1710245929; 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=Kw6JUcERnGErKtDrZC0R6JilUy4T39Q2xkp4LDaFvz4=; b=c0MDYANBj3tUv90G2HbytfS7TrzCFzxUcIJ2HDJWtncNOVtJzXAEP4jb+3DXYUcNqX zjrtOwfzc4p5LxlipaeE2rQQqJ+VFXM6gIvLABufKiUXfzdQ9m4Q0XxABpeHbFOw9JUD Or4WB3oKGZ0Keknk5R5UuMLFkYdxP9PX064STdeABMbisAL/magIKm0uptWMj4aAzGPs inWP9Hb92ziS7AuFGwIRUCNBUG7VmhQhT4gzCC8R/vutaIltso6qosiUIybT+0BLJ5Do ujT8eGgt6sHuBKVXxOUp5zZGse+QpKJkYy72wNn+xvxyPw7UK9OZFAh61MqpPZSr+2Ou U66A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709641129; x=1710245929; 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=Kw6JUcERnGErKtDrZC0R6JilUy4T39Q2xkp4LDaFvz4=; b=hvkAY73dMb2ck2wvg9wVKyXIU5/obdaRrxmbI0eaLNyysNbe2rv8GmPlSLeqbg9a4H vsKu5YB0NLx4V1SaI3sWGitZabEYFv12NI4zgfxTLGvgKajU6BEq3Pv+LIP7KQL12IBU KgpKlgiKvz2qjhtbPunAkflA1R5WUUT40EiKS8zbKGW9dqnVGq49PFqCI8RP+Ia76DNF a8IE47X9mhS1oPxBv/l3BDbNOtC2w/SSVmOp3g8IYI6z8fAiZSkQmj1Q5JOA5EVsOn3T 2uSs6SQy82hfcejr30NuUw15R0RYC9j/I6ChTPcNEpDuIQTv7amMGeb1IEPDvkj272Cq +asQ== X-Gm-Message-State: AOJu0YxXA4JRxZFHpoZ8IuE3EBHLqw1nHYMEaPZI9eBcokeIWe6Imr5t M/ZNWm7gcPexNBsLrdHpwgpGVkZrPMGOFB7c0/83JGhX2hP5XukzOn8vCufpApBQ1KU5yZpKHjX U X-Google-Smtp-Source: AGHT+IGIgDyo78sr5q2yjB4OUiehbcjF4u/5+NyYwrnbTpZz9MSK4VzX9BR2yEV5+DSxn2Z8+q4wBg== X-Received: by 2002:ac2:5a49:0:b0:513:1cfd:14b2 with SMTP id r9-20020ac25a49000000b005131cfd14b2mr1215139lfn.33.1709641129284; Tue, 05 Mar 2024 04:18:49 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Wainer dos Santos Moschetta , Alistair Francis , Nicholas Piggin , Liu Zhiwei , Richard Henderson , Yanan Wang , qemu-s390x@nongnu.org, "Edgar E. Iglesias" , Eduardo Habkost , Daniel Henrique Barboza , Michael Rolnik , Daniel Henrique Barboza , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Laurent Vivier , Yoshinori Sato , Laurent Vivier , Thomas Huth , Peter Maydell , Mahmoud Mandour , Brad Smith , Alistair Francis , Brian Cain , Cleber Rosa , John Snow , Marcel Apfelbaum , Pierrick Bouvier , Palmer Dabbelt , Riku Voipio , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, Weiwei Li , Bin Meng , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Beraldo Leal , Kyle Evans , David Hildenbrand , Song Gao , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Paolo Bonzini , Alexandre Iooss , Warner Losh , qemu-riscv@nongnu.org, Ilya Leoshkevich Subject: [PATCH 24/29] plugins: remove non per_vcpu inline operation from API Date: Tue, 5 Mar 2024 12:10:00 +0000 Message-Id: <20240305121005.3528075-25-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240305121005.3528075-1-alex.bennee@linaro.org> References: <20240305121005.3528075-1-alex.bennee@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::12c; envelope-from=alex.bennee@linaro.org; helo=mail-lf1-x12c.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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1709641342791100001 From: Pierrick Bouvier Now we have a thread-safe equivalent of inline operation, and that all plugins were changed to use it, there is no point to keep the old API. In more, it will help when we implement more functionality (conditional callbacks), as we can assume that we operate on a scoreboard. API version bump was already done as part of this series. Reviewed-by: Richard Henderson Reviewed-by: Alex Benn=C3=A9e Signed-off-by: Pierrick Bouvier Message-Id: <20240304130036.124418-12-pierrick.bouvier@linaro.org> Signed-off-by: Alex Benn=C3=A9e --- include/qemu/qemu-plugin.h | 58 ++++-------------------------------- plugins/api.c | 29 ------------------ plugins/qemu-plugins.symbols | 3 -- 3 files changed, 5 insertions(+), 85 deletions(-) diff --git a/include/qemu/qemu-plugin.h b/include/qemu/qemu-plugin.h index 6bbad068c01..4fc6c3739b2 100644 --- a/include/qemu/qemu-plugin.h +++ b/include/qemu/qemu-plugin.h @@ -52,7 +52,11 @@ typedef uint64_t qemu_plugin_id_t; * The plugins export the API they were built against by exposing the * symbol qemu_plugin_version which can be checked. * - * version 2: removed qemu_plugin_n_vcpus and qemu_plugin_n_max_vcpus + * version 2: + * - removed qemu_plugin_n_vcpus and qemu_plugin_n_max_vcpus + * - Remove qemu_plugin_register_vcpu_{tb, insn, mem}_exec_inline. + * Those functions are replaced by *_per_vcpu variants, which guarantee + * thread-safety for operations. */ =20 extern QEMU_PLUGIN_EXPORT int qemu_plugin_version; @@ -309,25 +313,6 @@ enum qemu_plugin_op { QEMU_PLUGIN_INLINE_ADD_U64, }; =20 -/** - * qemu_plugin_register_vcpu_tb_exec_inline() - execution inline op - * @tb: the opaque qemu_plugin_tb handle for the translation - * @op: the type of qemu_plugin_op (e.g. ADD_U64) - * @ptr: the target memory location for the op - * @imm: the op data (e.g. 1) - * - * Insert an inline op to every time a translated unit executes. - * Useful if you just want to increment a single counter somewhere in - * memory. - * - * Note: ops are not atomic so in multi-threaded/multi-smp situations - * you will get inexact results. - */ -QEMU_PLUGIN_API -void qemu_plugin_register_vcpu_tb_exec_inline(struct qemu_plugin_tb *tb, - enum qemu_plugin_op op, - void *ptr, uint64_t imm); - /** * qemu_plugin_register_vcpu_tb_exec_inline_per_vcpu() - execution inline = op * @tb: the opaque qemu_plugin_tb handle for the translation @@ -359,21 +344,6 @@ void qemu_plugin_register_vcpu_insn_exec_cb(struct qem= u_plugin_insn *insn, enum qemu_plugin_cb_flags flag= s, void *userdata); =20 -/** - * qemu_plugin_register_vcpu_insn_exec_inline() - insn execution inline op - * @insn: the opaque qemu_plugin_insn handle for an instruction - * @op: the type of qemu_plugin_op (e.g. ADD_U64) - * @ptr: the target memory location for the op - * @imm: the op data (e.g. 1) - * - * Insert an inline op to every time an instruction executes. Useful - * if you just want to increment a single counter somewhere in memory. - */ -QEMU_PLUGIN_API -void qemu_plugin_register_vcpu_insn_exec_inline(struct qemu_plugin_insn *i= nsn, - enum qemu_plugin_op op, - void *ptr, uint64_t imm); - /** * qemu_plugin_register_vcpu_insn_exec_inline_per_vcpu() - insn exec inlin= e op * @insn: the opaque qemu_plugin_insn handle for an instruction @@ -597,24 +567,6 @@ void qemu_plugin_register_vcpu_mem_cb(struct qemu_plug= in_insn *insn, enum qemu_plugin_mem_rw rw, void *userdata); =20 -/** - * qemu_plugin_register_vcpu_mem_inline() - register an inline op to any m= emory access - * @insn: handle for instruction to instrument - * @rw: apply to reads, writes or both - * @op: the op, of type qemu_plugin_op - * @ptr: pointer memory for the op - * @imm: immediate data for @op - * - * This registers a inline op every memory access generated by the - * instruction. This provides for a lightweight but not thread-safe - * way of counting the number of operations done. - */ -QEMU_PLUGIN_API -void qemu_plugin_register_vcpu_mem_inline(struct qemu_plugin_insn *insn, - enum qemu_plugin_mem_rw rw, - enum qemu_plugin_op op, void *pt= r, - uint64_t imm); - /** * qemu_plugin_register_vcpu_mem_inline_per_vcpu() - inline op for mem acc= ess * @insn: handle for instruction to instrument diff --git a/plugins/api.c b/plugins/api.c index 6470f1dc0f2..8fa5a600ac3 100644 --- a/plugins/api.c +++ b/plugins/api.c @@ -101,16 +101,6 @@ void qemu_plugin_register_vcpu_tb_exec_cb(struct qemu_= plugin_tb *tb, } } =20 -void qemu_plugin_register_vcpu_tb_exec_inline(struct qemu_plugin_tb *tb, - enum qemu_plugin_op op, - void *ptr, uint64_t imm) -{ - if (!tb->mem_only) { - plugin_register_inline_op(&tb->cbs[PLUGIN_CB_INLINE], - 0, op, ptr, imm); - } -} - void qemu_plugin_register_vcpu_tb_exec_inline_per_vcpu( struct qemu_plugin_tb *tb, enum qemu_plugin_op op, @@ -138,16 +128,6 @@ void qemu_plugin_register_vcpu_insn_exec_cb(struct qem= u_plugin_insn *insn, } } =20 -void qemu_plugin_register_vcpu_insn_exec_inline(struct qemu_plugin_insn *i= nsn, - enum qemu_plugin_op op, - void *ptr, uint64_t imm) -{ - if (!insn->mem_only) { - plugin_register_inline_op(&insn->cbs[PLUGIN_CB_INSN][PLUGIN_CB_INL= INE], - 0, op, ptr, imm); - } -} - void qemu_plugin_register_vcpu_insn_exec_inline_per_vcpu( struct qemu_plugin_insn *insn, enum qemu_plugin_op op, @@ -175,15 +155,6 @@ void qemu_plugin_register_vcpu_mem_cb(struct qemu_plug= in_insn *insn, cb, flags, rw, udata); } =20 -void qemu_plugin_register_vcpu_mem_inline(struct qemu_plugin_insn *insn, - enum qemu_plugin_mem_rw rw, - enum qemu_plugin_op op, void *pt= r, - uint64_t imm) -{ - plugin_register_inline_op(&insn->cbs[PLUGIN_CB_MEM][PLUGIN_CB_INLINE], - rw, op, ptr, imm); -} - void qemu_plugin_register_vcpu_mem_inline_per_vcpu( struct qemu_plugin_insn *insn, enum qemu_plugin_mem_rw rw, diff --git a/plugins/qemu-plugins.symbols b/plugins/qemu-plugins.symbols index 0d8141b85f1..a9fac056c7f 100644 --- a/plugins/qemu-plugins.symbols +++ b/plugins/qemu-plugins.symbols @@ -27,16 +27,13 @@ qemu_plugin_register_vcpu_idle_cb; qemu_plugin_register_vcpu_init_cb; qemu_plugin_register_vcpu_insn_exec_cb; - qemu_plugin_register_vcpu_insn_exec_inline; qemu_plugin_register_vcpu_insn_exec_inline_per_vcpu; qemu_plugin_register_vcpu_mem_cb; - qemu_plugin_register_vcpu_mem_inline; qemu_plugin_register_vcpu_mem_inline_per_vcpu; qemu_plugin_register_vcpu_resume_cb; qemu_plugin_register_vcpu_syscall_cb; qemu_plugin_register_vcpu_syscall_ret_cb; qemu_plugin_register_vcpu_tb_exec_cb; - qemu_plugin_register_vcpu_tb_exec_inline; qemu_plugin_register_vcpu_tb_exec_inline_per_vcpu; qemu_plugin_register_vcpu_tb_trans_cb; qemu_plugin_reset; --=20 2.39.2 From nobody Tue Nov 26 04:50:37 2024 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=1709641281; cv=none; d=zohomail.com; s=zohoarc; b=XrEoUxTn1bsGNhXYc40jSccsSjsmrHXaLcaDw7Ve8vs+VRA3mjIZOqr3mQnyCH9H+VzLxangBNe/5v44C9ko7lGWhG+PbMtSWM5ODjXQcriwFIifPn8LC4IJFPya76B6VLw/hASOhdp47lJl08FJVIPMIG4s8BIxjGuBzQaHnw8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709641281; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=HTlUHz/zzEA+4dY7VR66jAMvQofhd2ytbNOVYam0lP4=; b=N3pgtB3bnrC02AmJXY51JXyvw+7MYJBXfvSlBhY7Z24PJfBNrX45lCONpt46qkAwIZ+XGxq2KTTb6VTjQ9arEiwBzFiZcHlv0+sp69BHrxpkrsCwZYzz2m5IcCqsLrp/nSwzk47C7Ltjq4+2gQviljcsW2i++EGjiXASiRk+ifI= 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 1709641281254651.1012514660493; Tue, 5 Mar 2024 04:21:21 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rhTlo-000216-Sp; Tue, 05 Mar 2024 07:19:47 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rhTlC-0000VJ-7t for qemu-devel@nongnu.org; Tue, 05 Mar 2024 07:19:07 -0500 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 1rhTkx-0003GT-28 for qemu-devel@nongnu.org; Tue, 05 Mar 2024 07:19:04 -0500 Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-412e66bc492so11906055e9.0 for ; Tue, 05 Mar 2024 04:18:50 -0800 (PST) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id ck4-20020a5d5e84000000b0033e431950c5sm1119001wrb.97.2024.03.05.04.18.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Mar 2024 04:18:47 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id C954F5F9FA; Tue, 5 Mar 2024 12:10:07 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1709641129; x=1710245929; 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=HTlUHz/zzEA+4dY7VR66jAMvQofhd2ytbNOVYam0lP4=; b=seuoJ+fveKWfvkRyKiL0wojf14LWb8M/g3lbbt/immUTRNWqSbKBR6aOFak6Zj1ZmD i6Bs+Lg8/fjwEW+qQ+CVvDrpY8MWu3pFsU81HXcGRJZOQ0+Z4fZaLKmgzeAjWzz3gQJ/ yuJrH3t3THpbGoe/egKXjaYClMpcDzIRyfg0xPpMAybjUduXwrbvTIy3JzHBZveRdFH3 upha149wxeqItubtjHEE1fYS4XjSdSorPN6gewJL2C5Km2pqBgS3aqRuauFs4M1w7K2B GlZPEiCdmHzCOU4cTrNeVBuTEZzL/qML05BM965zI1z8G9smP9rLb/tb/v5NqJ9U0Hdd 7r8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709641129; x=1710245929; 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=HTlUHz/zzEA+4dY7VR66jAMvQofhd2ytbNOVYam0lP4=; b=q2VTOq36qkN6jNrXa6EzWClqiK8hyJxTMp4m/MJQjZImbwrF4MMqhIC9/mBL0+S3R+ wHTQZR2vIOCXKd/rdDSjTjRTB3LWDFRTB+JB2FYcKQJ/9M8Kvj8rG878mxokCH8GKGpk lxlnabDaY9Q5qZmoJGG3VdMXtTk5glLBm0IK4kH2gvn3gsUB19eh6RuqCo+8P3zgn0yT kwcLW2Nu0jcUk6gFsgq77VYJP1n0fPzwQBWdn80QbYrAzCnog6oPxkjg+HxvafeiYd5s mkiS2bSpk7u5+nxNYubIgMES7iCjrGDVKVF1aWA8Qe1Fk1YcpP6oRIL+gajhiQi0bJXa 1CdA== X-Gm-Message-State: AOJu0YxaW0Qwrp5XGy6Xlwgfu1ticsafVk8VciHi0Pgjz79wu05vzIlJ 9O+auPUDexv/aBMafeOtnqIU4nb3Wmnfi5w6pagrsaDK+v9tOcRCI4kYPV/CpSA= X-Google-Smtp-Source: AGHT+IGPLa83unvzaHEFRsDi8vlTQkhtloNhPgsJ1xAFKV+ZZDRwNnlPHFgxZrTxfM9gf1RWrICDzQ== X-Received: by 2002:a05:600c:c1a:b0:412:b8ce:fa32 with SMTP id fm26-20020a05600c0c1a00b00412b8cefa32mr9113006wmb.11.1709641128899; Tue, 05 Mar 2024 04:18:48 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Wainer dos Santos Moschetta , Alistair Francis , Nicholas Piggin , Liu Zhiwei , Richard Henderson , Yanan Wang , qemu-s390x@nongnu.org, "Edgar E. Iglesias" , Eduardo Habkost , Daniel Henrique Barboza , Michael Rolnik , Daniel Henrique Barboza , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Laurent Vivier , Yoshinori Sato , Laurent Vivier , Thomas Huth , Peter Maydell , Mahmoud Mandour , Brad Smith , Alistair Francis , Brian Cain , Cleber Rosa , John Snow , Marcel Apfelbaum , Pierrick Bouvier , Palmer Dabbelt , Riku Voipio , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, Weiwei Li , Bin Meng , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Beraldo Leal , Kyle Evans , David Hildenbrand , Song Gao , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Paolo Bonzini , Alexandre Iooss , Warner Losh , qemu-riscv@nongnu.org, Ilya Leoshkevich Subject: [PATCH 25/29] plugins: cleanup codepath for previous inline operation Date: Tue, 5 Mar 2024 12:10:01 +0000 Message-Id: <20240305121005.3528075-26-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240305121005.3528075-1-alex.bennee@linaro.org> References: <20240305121005.3528075-1-alex.bennee@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::32e; envelope-from=alex.bennee@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, T_SCC_BODY_TEXT_LINE=-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: 1709641282559100001 From: Pierrick Bouvier Reviewed-by: Richard Henderson Reviewed-by: Alex Benn=C3=A9e Signed-off-by: Pierrick Bouvier Message-Id: <20240304130036.124418-13-pierrick.bouvier@linaro.org> Signed-off-by: Alex Benn=C3=A9e --- plugins/plugin.h | 5 ----- accel/tcg/plugin-gen.c | 13 ++++--------- plugins/core.c | 29 ++++------------------------- 3 files changed, 8 insertions(+), 39 deletions(-) diff --git a/plugins/plugin.h b/plugins/plugin.h index f6fa10a0f56..7c34f23cfcb 100644 --- a/plugins/plugin.h +++ b/plugins/plugin.h @@ -68,11 +68,6 @@ struct qemu_plugin_ctx { =20 struct qemu_plugin_ctx *plugin_id_to_ctx_locked(qemu_plugin_id_t id); =20 -void plugin_register_inline_op(GArray **arr, - enum qemu_plugin_mem_rw rw, - enum qemu_plugin_op op, void *ptr, - uint64_t imm); - void plugin_register_inline_op_on_entry(GArray **arr, enum qemu_plugin_mem_rw rw, enum qemu_plugin_op op, diff --git a/accel/tcg/plugin-gen.c b/accel/tcg/plugin-gen.c index 47e05ec6347..8028786c7bb 100644 --- a/accel/tcg/plugin-gen.c +++ b/accel/tcg/plugin-gen.c @@ -440,15 +440,10 @@ static TCGOp *append_inline_cb(const struct qemu_plug= in_dyn_cb *cb, TCGOp *begin_op, TCGOp *op, int *unused) { - char *ptr =3D cb->userp; - size_t elem_size =3D 0; - size_t offset =3D 0; - if (!ptr) { - /* use inline entry */ - ptr =3D cb->inline_insn.entry.score->data->data; - elem_size =3D g_array_get_element_size(cb->inline_insn.entry.score= ->data); - offset =3D cb->inline_insn.entry.offset; - } + char *ptr =3D cb->inline_insn.entry.score->data->data; + size_t elem_size =3D g_array_get_element_size( + cb->inline_insn.entry.score->data); + size_t offset =3D cb->inline_insn.entry.offset; =20 op =3D copy_ld_i32(&begin_op, op); op =3D copy_mul_i32(&begin_op, op, elem_size); diff --git a/plugins/core.c b/plugins/core.c index 7852590da88..11ca20e6267 100644 --- a/plugins/core.c +++ b/plugins/core.c @@ -316,22 +316,6 @@ static struct qemu_plugin_dyn_cb *plugin_get_dyn_cb(GA= rray **arr) return &g_array_index(cbs, struct qemu_plugin_dyn_cb, cbs->len - 1); } =20 -void plugin_register_inline_op(GArray **arr, - enum qemu_plugin_mem_rw rw, - enum qemu_plugin_op op, - void *ptr, - uint64_t imm) -{ - struct qemu_plugin_dyn_cb *dyn_cb; - - dyn_cb =3D plugin_get_dyn_cb(arr); - dyn_cb->userp =3D ptr; - dyn_cb->type =3D PLUGIN_CB_INLINE; - dyn_cb->rw =3D rw; - dyn_cb->inline_insn.op =3D op; - dyn_cb->inline_insn.imm =3D imm; -} - void plugin_register_inline_op_on_entry(GArray **arr, enum qemu_plugin_mem_rw rw, enum qemu_plugin_op op, @@ -494,15 +478,10 @@ void qemu_plugin_flush_cb(void) =20 void exec_inline_op(struct qemu_plugin_dyn_cb *cb, int cpu_index) { - char *ptr =3D cb->userp; - size_t elem_size =3D 0; - size_t offset =3D 0; - if (!ptr) { - /* use inline entry */ - ptr =3D cb->inline_insn.entry.score->data->data; - elem_size =3D g_array_get_element_size(cb->inline_insn.entry.score= ->data); - offset =3D cb->inline_insn.entry.offset; - } + char *ptr =3D cb->inline_insn.entry.score->data->data; + size_t elem_size =3D g_array_get_element_size( + cb->inline_insn.entry.score->data); + size_t offset =3D cb->inline_insn.entry.offset; uint64_t *val =3D (uint64_t *)(ptr + offset + cpu_index * elem_size); =20 switch (cb->inline_insn.op) { --=20 2.39.2 From nobody Tue Nov 26 04:50:37 2024 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=1709641161; cv=none; d=zohomail.com; s=zohoarc; b=ECXKSxD6eHcmuRb0gml5i1BTi6BFCzp3fj79LvlGRzeysYsfYOSF4MZNanAz/c0lMv++0Ju2MYAXhnsoHqo/0UuTX8572uqHt/F/KXEMZoHI3aF11wYXilCzH7umn868HqYq3h1BRKdCrFt9MgTzovqS72ylMUXTqPheVkk6Idw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709641161; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=UcgWSPHavk3jnzeArpwVhpqUMOHkHAZLH3BaPdead8s=; b=GKbpSAwf8dyCqpIzwC8YOerhrxrHApHLCZ3LuQ765suVCsN/yew+cyobAszJlyTezOzn1ZoVirwUmWOJff67OntugM2OT4uJKpG98b7cdhAX1zAhVTv4CCqxp02Qjx/4RgwVDhCd+p/7M5KAr8WqjMMdpecJkh8HRzwAR6l9lFM= 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 1709641161183141.80944151877316; Tue, 5 Mar 2024 04:19:21 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rhTlJ-0000hX-EV; Tue, 05 Mar 2024 07:19:15 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rhTl3-0008PV-7C for qemu-devel@nongnu.org; Tue, 05 Mar 2024 07:18:58 -0500 Received: from mail-lj1-x230.google.com ([2a00:1450:4864:20::230]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rhTkv-0003Ey-8r for qemu-devel@nongnu.org; Tue, 05 Mar 2024 07:18:56 -0500 Received: by mail-lj1-x230.google.com with SMTP id 38308e7fff4ca-2d382a78c38so34208051fa.1 for ; Tue, 05 Mar 2024 04:18:48 -0800 (PST) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id k4-20020a05600c1c8400b00412e556d4besm5271799wms.48.2024.03.05.04.18.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Mar 2024 04:18:47 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id DE1675F9FB; Tue, 5 Mar 2024 12:10:07 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1709641127; x=1710245927; 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=UcgWSPHavk3jnzeArpwVhpqUMOHkHAZLH3BaPdead8s=; b=QKwwoS0ayhUEegS00UJTOCSR29nMBAaWYEnKDZgXZLp9GRvjXbeqhuKq55QxUBIOCN y4DYcA6Pv2BLswRfqtb8TXNLbao1KV8yL+gtRxpQgWJ6hADfbK3kqL8IeOcskWww6pxb ulds9KF/8DTVKVQrPqrRnJgIKYWQaiKQodQw3mA+nW7pY/LXjFIyGBJdc8+Lu3CFzoT9 PBHcs6zJX/ExkIaLj7QdgOckCqCfeRQCOlyYukyuOXncwOXQ/F4lUwK1NVpaD1ati8Wv uSOniV9BVqTVgpwWBC0MOEnsFLWFC5GBfALzyaZnDmLKPn5uz5ZAD8ITp2xzTM5hjnAJ ZaFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709641127; x=1710245927; 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=UcgWSPHavk3jnzeArpwVhpqUMOHkHAZLH3BaPdead8s=; b=t+hO2/cyWbdZVzTAwwi1FzyScxJ6sBRhoVyNdk5u2Knbw1M9owEfKQwRKy9zBqRvq4 SJ6r0hevHL50Fw5WC5azuVUrY2HBCy8TQxEnJJnUIguuG73DZYMmyEYNkqtBOOTrPUfp XQjUyXO+XWww6XfU8SVOWO9Uz8zqfeE8hppBP0sIBPFIniV8+zkeQ78Xg/saGpwd4WsQ MFnb2OokD7e8SfHjCCN8LR7/s6z64/PnLYmjNlfJBqUTzQBnHOsDeUM9A/hvPX8rEJr0 bWSrWTxkFA7RcoHoFVXegqTJ4n6A145yfYJtelNzxkRKNArJotsb2n+34z0UzpTv7RZT ul/Q== X-Gm-Message-State: AOJu0YwhoRFFf8OzHiPBfF/9914v+rGxa5zdTYBwclfcNGibeQEjXOio xyq0T83ALejl6Ts7fbOjT/QoTELbFKdS7wXQ1TviA3/T/jRr75B775TeX4FDjPU= X-Google-Smtp-Source: AGHT+IH9KwVJTQeQEslJG89+vmGjqmmhWGi0+6NQxtwTOFdi4QGrRO1QXgsNsRlyY8haRvYRTzihfw== X-Received: by 2002:a05:6512:36c7:b0:513:3738:f831 with SMTP id e7-20020a05651236c700b005133738f831mr960024lfs.32.1709641127409; Tue, 05 Mar 2024 04:18:47 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Wainer dos Santos Moschetta , Alistair Francis , Nicholas Piggin , Liu Zhiwei , Richard Henderson , Yanan Wang , qemu-s390x@nongnu.org, "Edgar E. Iglesias" , Eduardo Habkost , Daniel Henrique Barboza , Michael Rolnik , Daniel Henrique Barboza , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Laurent Vivier , Yoshinori Sato , Laurent Vivier , Thomas Huth , Peter Maydell , Mahmoud Mandour , Brad Smith , Alistair Francis , Brian Cain , Cleber Rosa , John Snow , Marcel Apfelbaum , Pierrick Bouvier , Palmer Dabbelt , Riku Voipio , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, Weiwei Li , Bin Meng , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Beraldo Leal , Kyle Evans , David Hildenbrand , Song Gao , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Paolo Bonzini , Alexandre Iooss , Warner Losh , qemu-riscv@nongnu.org, Ilya Leoshkevich Subject: [PATCH 26/29] disas: introduce show_opcodes Date: Tue, 5 Mar 2024 12:10:02 +0000 Message-Id: <20240305121005.3528075-27-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240305121005.3528075-1-alex.bennee@linaro.org> References: <20240305121005.3528075-1-alex.bennee@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::230; envelope-from=alex.bennee@linaro.org; helo=mail-lj1-x230.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, T_SCC_BODY_TEXT_LINE=-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: 1709641161791100001 For plugins we don't expect the raw opcodes in the disassembly. We already deal with this by hand crafting our capstone call but for other diassemblers we need a flag. Introduce show_opcodes which defaults to off. Signed-off-by: Alex Benn=C3=A9e Reviewed-by: Richard Henderson --- include/disas/dis-asm.h | 8 ++++++++ disas/disas.c | 1 + 2 files changed, 9 insertions(+) diff --git a/include/disas/dis-asm.h b/include/disas/dis-asm.h index 2324f6b1a46..b26867b6417 100644 --- a/include/disas/dis-asm.h +++ b/include/disas/dis-asm.h @@ -396,6 +396,14 @@ typedef struct disassemble_info { /* Command line options specific to the target disassembler. */ char * disassembler_options; =20 + /* + * When true instruct the disassembler it may preface the + * disassembly with the opcodes values if it wants to. This is + * mainly for the benefit of the plugin interface which doesn't want + * that. + */ + bool show_opcodes; + /* Field intended to be used by targets in any way they deem suitable. = */ void *target_info; =20 diff --git a/disas/disas.c b/disas/disas.c index 0d2d06c2ecc..17170d291ec 100644 --- a/disas/disas.c +++ b/disas/disas.c @@ -299,6 +299,7 @@ void disas(FILE *out, const void *code, size_t size) s.info.buffer =3D code; s.info.buffer_vma =3D (uintptr_t)code; s.info.buffer_length =3D size; + s.info.show_opcodes =3D true; =20 if (s.info.cap_arch >=3D 0 && cap_disas_host(&s.info, code, size)) { return; --=20 2.39.2 From nobody Tue Nov 26 04:50:37 2024 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=1709641283; cv=none; d=zohomail.com; s=zohoarc; b=N7HrAYZPrHsyi7N4NAEZIeBP2KZSoIOP9YDaUpygphKVNRcS1VFbFcj7463Ep6PHD1LXQbC1VB9q/M+Vu6YUhG78Syq5Xk3snMs6Rg57bKJZUufnDtQrDp4/ozjQUVRIrV/xebrvIb0v3LWnhI4ERorKBJRgYyrAmV4k6KLz5gg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709641283; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=1ibtd8j2iIFl1RCVEa98L1O8fLydOmPGUu0P3W6zXxE=; b=N1WxKIBcVMEai9JZGHhgSg21dqKZsmXtkyQRl1o+4fdlrm4qK6fMAfrk3oIbxw5ANDWEpT92HXfPp19y0WJIlBkYGni0M80ArtOUnDXVCcXyZWjxtGBy11tALS1b9IkHklYY/sscOXjpZZQ2nSv+jgR8Uvv5AKZvuljKjBVenyY= 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 1709641283007173.63788295524273; Tue, 5 Mar 2024 04:21:23 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rhTmK-0002pL-Kv; Tue, 05 Mar 2024 07:20:16 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rhTky-0008Oj-QZ for qemu-devel@nongnu.org; Tue, 05 Mar 2024 07:18:56 -0500 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 1rhTks-0003DN-B6 for qemu-devel@nongnu.org; Tue, 05 Mar 2024 07:18:52 -0500 Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-412ebda8772so4899755e9.3 for ; Tue, 05 Mar 2024 04:18:45 -0800 (PST) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id q13-20020a05600c46cd00b00412ebd587ebsm2115487wmo.3.2024.03.05.04.18.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Mar 2024 04:18:43 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id F10295F9FF; Tue, 5 Mar 2024 12:10:07 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1709641124; x=1710245924; 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=1ibtd8j2iIFl1RCVEa98L1O8fLydOmPGUu0P3W6zXxE=; b=fqsQLDin4//iDhHTmNzLHZWSFoi9GPkZjTQoJzl6JtwzLtLzp9yaZQOViT+8YKwx8N q/qLp9vDHKqSizcDzyj6eKxEkIekr2vWW2HgiLel5WQ69xw8spnaA7C7fkbIOrwkj1qy 7dzIrTU+B0uUeHoAYfQ+wiaXPYbADnOARay9Nnz3dT1X6TydVyj5sbdQXx7E/UpyZzzd s7l8AjK5rcSb5BnAyJOf2cBt6OmzdPSZU+4X7JFb1wbQ13BhWy39IsVhQRmnfdXCmuP+ 3LR9C8fKcE7eY9YgW0MqQr2YkW5SHsEop7JXNT8WA0qyV+kbFP4Pft6eK2rgOLssTrlY 0VsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709641124; x=1710245924; 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=1ibtd8j2iIFl1RCVEa98L1O8fLydOmPGUu0P3W6zXxE=; b=d56qzNgUGagm0lAdCHxyv50QtV3QFl+IJmLj5QozP5uRasYpdC+OuAPJATmGdkuu+k V/t+fQk15lX0C1oVZ8v3neu5n94FuRBdJxDUD1fhQBjZzDYCBwnkz8mfXjuuLMPNUzpD d616+Acgzl6sEX9YCl+eM9hT9eZaped0wWzkjWvWWb9gXj5WEUAC+7U6CM9il6neCJUd 9O2nZIncjPjvyvIaeBrfgrrt4nkByU7uMfqACaTQefxuHp4Wu/G0w5d3VzU5wTXdaSYm K0EZMR1LlQQsBx/4IsDoWDAiBYKw26JClpLt52OuI+O3oO8mXre9bYRB/hSNz66qUKdP A2MQ== X-Gm-Message-State: AOJu0YwlfTyj1V44TtBwebhlSmoqSGb+PAp7rfBdfBuO9ftWQ28k7c+e Ljy34a5r2URG+LK6cxe5xhlYGiw0RbzPfqvV/3u/DK4fKcTYmd8KOA1V8Gr4UA4= X-Google-Smtp-Source: AGHT+IHt+GJyylRvf3ZnELcku1HmppBPkHdkuOG4oZm43grjxf4V+Db1DsOmEgWaKJydViUM5V9Y3w== X-Received: by 2002:a05:600c:3148:b0:412:bf53:51b0 with SMTP id h8-20020a05600c314800b00412bf5351b0mr8992277wmo.20.1709641124182; Tue, 05 Mar 2024 04:18:44 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Wainer dos Santos Moschetta , Alistair Francis , Nicholas Piggin , Liu Zhiwei , Richard Henderson , Yanan Wang , qemu-s390x@nongnu.org, "Edgar E. Iglesias" , Eduardo Habkost , Daniel Henrique Barboza , Michael Rolnik , Daniel Henrique Barboza , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Laurent Vivier , Yoshinori Sato , Laurent Vivier , Thomas Huth , Peter Maydell , Mahmoud Mandour , Brad Smith , Alistair Francis , Brian Cain , Cleber Rosa , John Snow , Marcel Apfelbaum , Pierrick Bouvier , Palmer Dabbelt , Riku Voipio , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, Weiwei Li , Bin Meng , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Beraldo Leal , Kyle Evans , David Hildenbrand , Song Gao , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Paolo Bonzini , Alexandre Iooss , Warner Losh , qemu-riscv@nongnu.org, Ilya Leoshkevich Subject: [PATCH 27/29] disas/hppa: honour show_opcodes Date: Tue, 5 Mar 2024 12:10:03 +0000 Message-Id: <20240305121005.3528075-28-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240305121005.3528075-1-alex.bennee@linaro.org> References: <20240305121005.3528075-1-alex.bennee@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=alex.bennee@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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1709641284405100005 Signed-off-by: Alex Benn=C3=A9e Reviewed-by: Richard Henderson --- disas/hppa.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/disas/hppa.c b/disas/hppa.c index 22dce9b41bb..49e2231ae62 100644 --- a/disas/hppa.c +++ b/disas/hppa.c @@ -1972,9 +1972,11 @@ print_insn_hppa (bfd_vma memaddr, disassemble_info *= info) =20 insn =3D bfd_getb32 (buffer); =20 - info->fprintf_func(info->stream, " %02x %02x %02x %02x ", - (insn >> 24) & 0xff, (insn >> 16) & 0xff, - (insn >> 8) & 0xff, insn & 0xff); + if (info->show_opcodes) { + info->fprintf_func(info->stream, " %02x %02x %02x %02x ", + (insn >> 24) & 0xff, (insn >> 16) & 0xff, + (insn >> 8) & 0xff, insn & 0xff); + } =20 for (i =3D 0; i < NUMOPCODES; ++i) { --=20 2.39.2 From nobody Tue Nov 26 04:50:37 2024 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=1709641304; cv=none; d=zohomail.com; s=zohoarc; b=E56qAQp/12qgjXT858P2uo7Z+4KL0/NQBrhdnYF4oEh/KR854WxyZuvfwMsm/Qn3pkN8dilAn5CjAPiyBYZtHXvXF6n/rYPrJglrSzsVnmgKfW/5oRHTqaVI+jAWcv3LUIsW24BsOAB8Lc0aUzjg/NwMFAmcv+2aBjasKUTpnRE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709641304; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=tcGhMUUI29octnVG5H2YHZPrevHON91YqWS8nudtIe0=; b=XmtfcuUV8Q9cGA791YaENM4693PkgBzNybAZZSDvClYxJ/1yREsiKjUB8jgILp+/l4ZBBDusNoiszB5GVKUGvOeQtMzxRZ59GNdCjjgiLxar8PgTPg9TGvox6Y9NlQsbbrwhWnLrm6Zl1S5pgNURs7YF7RpPW+iTVh4ksg1xriA= 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 1709641304830752.5610191406174; Tue, 5 Mar 2024 04:21:44 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rhTmX-0003IO-Lb; Tue, 05 Mar 2024 07:20:33 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rhTl2-0008P4-Ai for qemu-devel@nongnu.org; Tue, 05 Mar 2024 07:18:58 -0500 Received: from mail-wm1-x32b.google.com ([2a00:1450:4864:20::32b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rhTkv-0003Ej-1s for qemu-devel@nongnu.org; Tue, 05 Mar 2024 07:18:56 -0500 Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-412e993a82eso5096315e9.0 for ; Tue, 05 Mar 2024 04:18:47 -0800 (PST) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id r12-20020adfe68c000000b0033df5710fabsm14790096wrm.44.2024.03.05.04.18.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Mar 2024 04:18:44 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 1054F5FA01; Tue, 5 Mar 2024 12:10:08 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1709641127; x=1710245927; 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=tcGhMUUI29octnVG5H2YHZPrevHON91YqWS8nudtIe0=; b=LCHDsld4djC4wq+RTNvwesUkZSXs1h7mLOWZx3jawgZAq0kxl60KOvysQgcAWGQKEc 3jpBJ2tw5BXjxmdWA9wCE/daTLW23Mvb+v8Gy5dPzGgXd6szo9RgMbGRQy2DODMsOd48 UJLVS0OQeMssYaHSxsGlrMrxUujpm7F9Grp+oFG0bDeb07SCoxbz+0V6hinnYpkr+Sby 0gE8CWkorM+bzxz8v65o+jbB1iIzQTNHPoOZ4kwbVyJu/RLba86hueS3ddzHIGoRo/F1 bLk8r4ctN4UjGzyWwK6t8ftjuVaSWjMutlJpBXHln5CU3sM4bs0zHDKrvtMvkZ5B7FY+ 4+4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709641127; x=1710245927; 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=tcGhMUUI29octnVG5H2YHZPrevHON91YqWS8nudtIe0=; b=rtLIlnaHuixDrr5PiGsMGPsDIJRWI6AGl3Gcz0kaUGpnsZLzd2WVT6UzbXalnFpX8z U+18koM/egJ2ZiVOc4FH4xTtTfSH2kIcP46jvJvcrrRQj4Hk9wDEP25gAoFQObJtYAyk L6RM8WFqYC3c1JkQTWJBf6k3orfNxh63MHTx1Rk/EyWu/7v1PEW+Srzv++ceCXvlC9UX A7HwukMdzve1y58DHAW+TQw5GhAgdrvp/bOTl+RGzxBtIsId7/TiFrwmIjf8OFbPvW2h 7pTqppWSn1aq0nT7TYA0IBfMArgc8JCDP3TJDFC+TLX/or+ZKE2DL2jpPaQdnnHHduWy Hvhg== X-Gm-Message-State: AOJu0YxWbn8kh7IEGsfCDofrI3vSUCjxIqQu/Ed6SGTm+LLXIYvaCtAh RUdcnP3uw/5HiJBkzwwzlTcoFHWbiF1jr2B5Va5IV8bwIanUMB/ehOB5VY39i/4= X-Google-Smtp-Source: AGHT+IHCs/ghXyQJVPqZj0z2XFAwPBjrv76lPlvMp4lOf5ox0BmEwTP7SW0AzruVtBk1uNWhaGDeRw== X-Received: by 2002:adf:a153:0:b0:33d:9d46:c16c with SMTP id r19-20020adfa153000000b0033d9d46c16cmr8850175wrr.44.1709641127111; Tue, 05 Mar 2024 04:18:47 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Wainer dos Santos Moschetta , Alistair Francis , Nicholas Piggin , Liu Zhiwei , Richard Henderson , Yanan Wang , qemu-s390x@nongnu.org, "Edgar E. Iglesias" , Eduardo Habkost , Daniel Henrique Barboza , Michael Rolnik , Daniel Henrique Barboza , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Laurent Vivier , Yoshinori Sato , Laurent Vivier , Thomas Huth , Peter Maydell , Mahmoud Mandour , Brad Smith , Alistair Francis , Brian Cain , Cleber Rosa , John Snow , Marcel Apfelbaum , Pierrick Bouvier , Palmer Dabbelt , Riku Voipio , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, Weiwei Li , Bin Meng , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Beraldo Leal , Kyle Evans , David Hildenbrand , Song Gao , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Paolo Bonzini , Alexandre Iooss , Warner Losh , qemu-riscv@nongnu.org, Ilya Leoshkevich Subject: [PATCH 28/29] target/loongarch: honour show_opcodes when disassembling Date: Tue, 5 Mar 2024 12:10:04 +0000 Message-Id: <20240305121005.3528075-29-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240305121005.3528075-1-alex.bennee@linaro.org> References: <20240305121005.3528075-1-alex.bennee@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::32b; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x32b.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1709641306576100007 This makes the output suitable when used for plugins. Signed-off-by: Alex Benn=C3=A9e Reviewed-by: Richard Henderson --- target/loongarch/disas.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/target/loongarch/disas.c b/target/loongarch/disas.c index 2040f3e44db..63989a6282d 100644 --- a/target/loongarch/disas.c +++ b/target/loongarch/disas.c @@ -120,10 +120,15 @@ static const char *get_csr_name(unsigned num) csr_names[num] : "Undefined CSR"; } =20 -#define output(C, INSN, FMT, ...) \ -{ \ - (C)->info->fprintf_func((C)->info->stream, "%08x %-9s\t" FMT, \ - (C)->insn, INSN, ##__VA_ARGS__); \ +#define output(C, INSN, FMT, ...) \ + { \ + if ((C)->info->show_opcodes) { \ + (C)->info->fprintf_func((C)->info->stream, "%08x %-9s\t" FMT,\ + (C)->insn, INSN, ##__VA_ARGS__); \ + } else { \ + (C)->info->fprintf_func((C)->info->stream, "%-9s\t" FMT, \ + INSN, ##__VA_ARGS__); \ + } \ } =20 #include "decode-insns.c.inc" --=20 2.39.2 From nobody Tue Nov 26 04:50:37 2024 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=1709641154; cv=none; d=zohomail.com; s=zohoarc; b=kIli1syLHiyo7ps9aHHEZ4A6V/6CB2MuNsjuIFYeNWl6c4wgIATi6hraxxwsydv8Ur609/NIepIGeLVZk4TH/Iu2Qeu8ULzKPpFCw7IaclwDykSAVQp3tKK6S/J8VEPfVNg7NHh1pufaDd08JdUXt1z8aFZRZ4QDfmZm9t0I/mw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709641154; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=y1lN+fUrX1yI6hMkThPuuG28B1/LgsqaW0mrtGfmT/8=; b=FPK6RJNZrQdSTT+1PfI4ZeJ0B4BG4b/DF85b6lwVvg2GJLlg4Ltdu+5BL60zqY8k7UiWlba7i2ktTSO0wCdHEWNQk1y7XrbvwcyNOaxnvfRbfZicJjOJnfrZuAgYWXRu5HkmNZijD1st7DCwHHUlzrXiwkHHEvaR0gO6+Diqyr4= 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 1709641154817550.1334126984908; Tue, 5 Mar 2024 04:19:14 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rhTl9-0000I8-Ji; Tue, 05 Mar 2024 07:19:07 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rhTkz-0008Oo-UK for qemu-devel@nongnu.org; Tue, 05 Mar 2024 07:18:56 -0500 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 1rhTks-0003Da-Bp for qemu-devel@nongnu.org; Tue, 05 Mar 2024 07:18:53 -0500 Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-412e4619e5eso14088275e9.2 for ; Tue, 05 Mar 2024 04:18:45 -0800 (PST) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id l21-20020a05600c4f1500b004101543e843sm20823499wmq.10.2024.03.05.04.18.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Mar 2024 04:18:43 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 239F45FA03; Tue, 5 Mar 2024 12:10:08 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1709641124; x=1710245924; 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=y1lN+fUrX1yI6hMkThPuuG28B1/LgsqaW0mrtGfmT/8=; b=JggpSdqGJPnsOvVpGO/8SEOliK6if/zOBmGhPpah1ogblTql9c1em+2Nj///He7RMj wFsEqrg9g9rARWf4GGaNNhPwipcLwEsy1Abs+rHDAp0g9NL4jlXrQdR8ffCDZM7Wjc2l RCJWk+4r+g8HHjv76RK1dXCqonf/tv2P573HTL92fkwYyTKQt756j+tvsvNEy7jv0A6I ZKwtCozlnJ78c8KJ57CHgc35gCvCIlxi72GUfXdumUw0cpFxYh4fCD+/5N0iuVu5Uj8i SsNaj1GvslAoNkkCBgNQi3/WdjObyQ9JRiQmuCg7VLFKJ3bqRtFwN00RLL0PaDPyDK6r cYjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709641124; x=1710245924; 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=y1lN+fUrX1yI6hMkThPuuG28B1/LgsqaW0mrtGfmT/8=; b=t/+rZ5PqySVRDISg3LQ6DtB5sqlsOQTh20mW10QhMwfefUx7ZiQjAWSi7gHusjXed+ UoK3mJMIxxdfmtCTG4iEWptkfkENcMbkbWO+xk/JSQsx8ZD1b0Yyew8pG1/cDVWNoK6/ bLIblzuCKUFuKZ4BvCdbgYlgSzG+Qaq9cZ9pzphmOOYedSDfWFoZVY7nDFWQsJI3IMBI vQSoCkTDgANwt0UZAacpRzwH8FayllUp0qGhTMKBwAQOun/Ln4X2NdUTUUA1Ygh0Lq69 tOVRSVoC6eKNB5pEZ5k8xZ5lAJe8bVMO2dUixh1FNJLxZ5MxVRfTkEXvtm9zYWdb3mTt qljQ== X-Gm-Message-State: AOJu0YwaXkoHTSDTx0kcBRQgR9Scx/+otsNo6y2kG1/2FKRNeGLJqxIi wRtjJhqHMI+8bV+aTvH1ZiRNON8r8lbMJvZqZ68z9I+HD7DkeDZpL3B1S20MZx4= X-Google-Smtp-Source: AGHT+IFIxNu71j7Y2KVErvOFS2FGyXwefyeOtJLrmxDxFA0pddvyB2e6Oh1Znch+jL/wsSubC4XxIw== X-Received: by 2002:a05:600c:4f0d:b0:412:beee:36b3 with SMTP id l13-20020a05600c4f0d00b00412beee36b3mr9351811wmq.7.1709641124451; Tue, 05 Mar 2024 04:18:44 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Wainer dos Santos Moschetta , Alistair Francis , Nicholas Piggin , Liu Zhiwei , Richard Henderson , Yanan Wang , qemu-s390x@nongnu.org, "Edgar E. Iglesias" , Eduardo Habkost , Daniel Henrique Barboza , Michael Rolnik , Daniel Henrique Barboza , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Laurent Vivier , Yoshinori Sato , Laurent Vivier , Thomas Huth , Peter Maydell , Mahmoud Mandour , Brad Smith , Alistair Francis , Brian Cain , Cleber Rosa , John Snow , Marcel Apfelbaum , Pierrick Bouvier , Palmer Dabbelt , Riku Voipio , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, Weiwei Li , Bin Meng , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Beraldo Leal , Kyle Evans , David Hildenbrand , Song Gao , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Paolo Bonzini , Alexandre Iooss , Warner Losh , qemu-riscv@nongnu.org, Ilya Leoshkevich Subject: [PATCH 29/29] target/riscv: honour show_opcodes when disassembling Date: Tue, 5 Mar 2024 12:10:05 +0000 Message-Id: <20240305121005.3528075-30-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240305121005.3528075-1-alex.bennee@linaro.org> References: <20240305121005.3528075-1-alex.bennee@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::32e; envelope-from=alex.bennee@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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1709641155807100001 This makes the output suitable when used for plugins. Signed-off-by: Alex Benn=C3=A9e Reviewed-by: Richard Henderson --- disas/riscv.c | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/disas/riscv.c b/disas/riscv.c index 8a546d5ea53..9dec8fa966f 100644 --- a/disas/riscv.c +++ b/disas/riscv.c @@ -5192,19 +5192,21 @@ print_insn_riscv(bfd_vma memaddr, struct disassembl= e_info *info, rv_isa isa) } } =20 - switch (len) { - case 2: - (*info->fprintf_func)(info->stream, INST_FMT_2, inst); - break; - case 4: - (*info->fprintf_func)(info->stream, INST_FMT_4, inst); - break; - case 6: - (*info->fprintf_func)(info->stream, INST_FMT_6, inst); - break; - default: - (*info->fprintf_func)(info->stream, INST_FMT_8, inst); - break; + if (!info->show_opcodes) { + switch (len) { + case 2: + (*info->fprintf_func)(info->stream, INST_FMT_2, inst); + break; + case 4: + (*info->fprintf_func)(info->stream, INST_FMT_4, inst); + break; + case 6: + (*info->fprintf_func)(info->stream, INST_FMT_6, inst); + break; + default: + (*info->fprintf_func)(info->stream, INST_FMT_8, inst); + break; + } } =20 disasm_inst(buf, sizeof(buf), isa, memaddr, inst, --=20 2.39.2