From nobody Sun Sep 28 15:30:20 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1758533963; cv=none; d=zohomail.com; s=zohoarc; b=OMGKlst62qYRFv5l4J8/yG707ghZVFxtGyjVO/RQB86dZByPzzs37b4mZ3BiOwC6+GkHRzNzcZ3i3Zl/KS6mqGos/xtXG8+dpXqS8XrwQelXRW234ZRlMLWbsBmxzcl1k24NO2vPrkDHe+e8PyS0Gq5uRkdyo9summCoToMsygg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1758533963; 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=tABHb0SIUKkh6uzz0t7I0iXZ4IfcRn4F5NgGsBOTZrw=; b=WNHW+cT8GHXVMN6hvikJvrGtWowCq7uk6r+qiBZ1o0HM4t/Xs8QgfkePyUXleOBo6LRWro1DmRK47awVXKYctCW1CzNURVXugjH4dcGhuWLK+nF4uGYoxn4SdGeGdCqHoLSX0uzeuj1wjfndAbWivtjnHFnNJzsJeqW0rrh+4cE= 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 1758533963345816.7720398094611; Mon, 22 Sep 2025 02:39:23 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v0czE-00022d-5q; Mon, 22 Sep 2025 05:37:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v0cz6-0001tM-3h for qemu-devel@nongnu.org; Mon, 22 Sep 2025 05:37:24 -0400 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1v0cyz-0000c8-Ma for qemu-devel@nongnu.org; Mon, 22 Sep 2025 05:37:22 -0400 Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-46b7bf21fceso13542265e9.3 for ; Mon, 22 Sep 2025 02:37:16 -0700 (PDT) Received: from draig.lan ([185.126.160.19]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4613d14d212sm259930315e9.12.2025.09.22.02.37.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Sep 2025 02:37:12 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 987D25F8B9; Mon, 22 Sep 2025 10:37:11 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1758533833; x=1759138633; 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=tABHb0SIUKkh6uzz0t7I0iXZ4IfcRn4F5NgGsBOTZrw=; b=Khl+jliPAIywrHBFL75d+hjNd6bWBdoDKxzkPYuizrb/jOPBhdiSSkW8NoPfbYDjIs CkfRdZkbGAEj2nJD6Dy/TP9tqFXfO36kUDWjm7j2sO4WDoNWhq2gMENGw/i0XL+t/RIT ER9HKiTH8mw/wTiMdYMQR95a+pVxbontKvNdhe3kv1DPARgs1ku0hE2EkQX0qsxv+JDk lOblMQ7ssKYgzNL6hEyXLGlRsaRMuMYMl4bP8CC1izsli7XqTJZsi0WG0vSc+dT3c2Ow Fyt6rlrggwXSmeC1dTgnv+BLus7SOxaffy+dC2MK0c0PXYxINDhVQefhksjVWkTN4R/M edPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1758533833; x=1759138633; 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=tABHb0SIUKkh6uzz0t7I0iXZ4IfcRn4F5NgGsBOTZrw=; b=viywd8qm+78ZT8X2nHOUuX9ij00Dj7jdtKGExcTzTbyB0EjB6UIZ2RwX+HGBU835k/ zdpPRCGzzTVO7xLUCH3OkJU77pOUeXD6abDCL4Vj12VMzxkPzxPL0nA/ZEt1V45uKBfC Xn+pzOk9gTA1VYZCXI/7tezpFbrFPOgMmIhxJ+mYLZo0rh0WprlG4Wc0/gu3ppAs/jMK 7V1EOhz3b6NWBoRBwqy2cRbyNFEauOXOO058WXUQvhRc81xN2QIw98d/F9sW1BKUDuoO 2wtfbnHRAqHTiuWm1MUAuMbya6VEqCrrPjW/p1uNyYOgRjdhQFbp5AR/PvI5+pUyXWjP 6IBA== X-Gm-Message-State: AOJu0YyUxUeKDzlCJYCcd+K9AtZnZA9RMCYFzLJzIe725CSHSogNkre6 OiBIcr5uESi2yfE08Gswwop/m/9sYzMHC+e3WuTL5Q47xd1bcAv4vfoWbcIVr/ezPH0= X-Gm-Gg: ASbGncu6+ZtI2QLdjsBlZMfbdOn6b7uOUlM83qVpZuXrzPeFRpaOTvFLZjDrj6GDTv5 NCIiLVPAc5LlfzAnJX/yv1eLbwHrYEF0Sa1Hql/hlfVNk4S+xLrNAPl/B7ZblUQSdArgyMtVd/K kAQuj0gs/asQMe9yRaaOx59pWHNYdymumfi9iPbBvJz1wnDYmqZyHQOKmyVRvllYBgIOZuVnLpq jUPijwvosX9dAq/0CxQTysLrzDz8Uc7Sdgna37Rjh24ubbHu1Bh4+C6/OWsaQBW3N3jGkbyXkDn sqRvmjDjchUHOKnc8vU5MG1LjtF0GdvSy+ZaiWRFD+gexZKsMgW/i133Nq7aOyC4h+zH4erF+ZT E2ghpy6ijQGXlf/QjHPUBMoA= X-Google-Smtp-Source: AGHT+IGKYLCqTBbnTaHG0WoqROvB3mb3XtAIclhYxe32fQ7dUvSfxGOnGECyX9UUbZkMBeFeQmxJtQ== X-Received: by 2002:a05:600c:1c0a:b0:45c:8e6d:a45f with SMTP id 5b1f17b1804b1-467ee3057e3mr113776025e9.5.1758533833241; Mon, 22 Sep 2025 02:37:13 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Palmer Dabbelt , Alexandre Iooss , Mahmoud Mandour , qemu-riscv@nongnu.org, Daniel Henrique Barboza , Thomas Huth , Peter Maydell , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Alistair Francis , qemu-arm@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Weiwei Li , Pierrick Bouvier , Liu Zhiwei Subject: [PATCH 01/25] docs/devel: fix typo in code-provenance.rst Date: Mon, 22 Sep 2025 10:36:46 +0100 Message-ID: <20250922093711.2768983-2-alex.bennee@linaro.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20250922093711.2768983-1-alex.bennee@linaro.org> References: <20250922093711.2768983-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 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: 1758533965270116600 Signed-off-by: Alex Benn=C3=A9e Reviewed-by: Richard Henderson Reviewed-by: Thomas Huth --- docs/devel/code-provenance.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/devel/code-provenance.rst b/docs/devel/code-provenance.rst index b5aae2e2532..af5d7349e12 100644 --- a/docs/devel/code-provenance.rst +++ b/docs/devel/code-provenance.rst @@ -331,7 +331,7 @@ ChatGPT, Anthropic's Claude, and Meta's Code Llama, and= code/content generation agents which are built on top of such tools. =20 This policy may evolve as AI tools mature and the legal situation is -clarifed. In the meanwhile, requests for exceptions to this policy will be +clarified. In the meanwhile, requests for exceptions to this policy will be evaluated by the QEMU project on a case by case basis. To be granted an exception, a contributor will need to demonstrate clarity of the license a= nd copyright status for the tool's output in relation to its training model a= nd --=20 2.47.3 From nobody Sun Sep 28 15:30:20 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1758534129; cv=none; d=zohomail.com; s=zohoarc; b=ThGwVdcjG3nQ1W2O+WOgWK0IskU7ZYNlDZpOpVSAPdD7L+CRRaxrF5s5++MQLVZOIxp1h4QXK06Mm+vK/VnqlGmPbRhydqZxgSicdSXWCtpoMMykjwSHoh1S6IM6u6im6GYrVe4D5T4asQZoPZbjNogXsZh2vlDm6CVUzun/dog= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1758534129; 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=HsKBSNXGouODjqFbzXtr6MHfNWWtyiLAciJxtw6gymY=; b=MZjzxvB0OkjcotIJmLi+ybDJcdzA585pRV3EPxBEnIyRCIfnadlnwWWSpw0JC6TdhYWUBKDKS8Ypg/ZjCskf57uDc7IPWYZyBFSCH1ofP9Rrm12raxs3ho1gWjWiZBmDmu0ePHch5yhupuAxQOEi8IAgMDZLSa4miqQGHYdTNpc= 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 1758534129714764.7007887407287; Mon, 22 Sep 2025 02:42:09 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v0d0e-0003yb-P5; Mon, 22 Sep 2025 05:39:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v0czH-0002An-UE for qemu-devel@nongnu.org; Mon, 22 Sep 2025 05:37:40 -0400 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1v0cz4-0000dF-2z for qemu-devel@nongnu.org; Mon, 22 Sep 2025 05:37:33 -0400 Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-45dfb8e986aso37501895e9.0 for ; Mon, 22 Sep 2025 02:37:19 -0700 (PDT) Received: from draig.lan ([185.126.160.19]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-464f190721esm192810625e9.10.2025.09.22.02.37.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Sep 2025 02:37:12 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id AD75A5F8FC; Mon, 22 Sep 2025 10:37:11 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1758533837; x=1759138637; 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=HsKBSNXGouODjqFbzXtr6MHfNWWtyiLAciJxtw6gymY=; b=W14YmG0MU6pRZxRSJ//7UCm8M0lxzH03+U3gfPI68YjEdUH2Jq6Bpx7i1PMSE7qqw0 qZomsVQfAEY0B+pi6chGiZwOEIB/tRLnPfDgBL8wQbee6x+57Oi3fPsOGKajz0f8wH9z MNGXiOJAzOFdD3LZjjDpGY8gjWUQLz1ZNJd3y7zX5YPQruJDzVsA4g+bJMrNJOGBksCo 2wa9njZLe0Aks0g2nkv9XJwdnvU5ZaNjyJX0uQzq21A1qyVEhQeff7f2El5jLn3YUrhK 5uI4ci6VpxwhZhz4zSZMbh6UNA7/QwM2K6iAaTJtgbd3L7TpGhyhQW1IyosntETnTyNH nhqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1758533837; x=1759138637; 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=HsKBSNXGouODjqFbzXtr6MHfNWWtyiLAciJxtw6gymY=; b=fItiIZEE3LhfJQT6NSfnNJSHJtP039OVTtBF+ejPmudQUD+i720z/hgCrN2fPPiRS7 7co+V25joDTQ1Npi2y55QA1KrIF6ajYh6OJbctbawkRMMjSU0a0UrG3zQ1eUsxQbYNx1 S0UJM2kvLVlmM4ty6PegWI/ZXpyWaDZ1rEzoYNl3tEbVRCZeMODE0UFtX+gDcpJr8aUW T6Ud8j3rn40Hk2+b4Py3tU43rWI2cokOnRnv5QsihqYjnurY3fNJeC1Y55rVgyyTRW9S anmJb9vP0CgnujwoxnktSJuhkl8TBiCH4+IY1jybpNtpz7ztK1cfA7xRA6086bTuHewG Zn2A== X-Gm-Message-State: AOJu0YxqFlfz8XZfD9Xx6vFlRS1yFzRcZVjAZ0SxIXQIanbNegtMCrBV TOfbZ/c4SIdegiFHZFkiY+cCCB7v2mh8+S/59XwiWlF5UPV+SJzifmsm0RPAYSKEBeM= X-Gm-Gg: ASbGnctaK9PJdX8WaxFwt3WQjis1o5IH57qiPerFCPypk8yBeSdeoKHDUWTwIz61hAe 6nX0/x56q88OMPJxhVwhbsI/1SY9VqcfoMpDjqTetNKxGuuMPn7/y9lRrWWQvuUVnPGe1LGh//h kSp7oz+0Ugbz+OV2yLa4FkQ4mhK3KOcfmMNuuv2emnQOQLSS7syNYqL4brf1rDlB5k8fDzdzHyi 0tVR2nOrVzKwxfbI2QhV3Wa5mvFnEuv0JTKGWkfJURIuXN7RFPvYX0+ORX8jcjAow4y2H6/96P9 u0hqROktsNhAA1a0+2pimKiAIVq4QF7eeFdpZlV8EFJ8pp4xTnMPoahkvPv9pjoLy9h61X0n9Zz nuLfxYGx66eqPCo63dBS61eE= X-Google-Smtp-Source: AGHT+IFIypwEWr8DwwXRt9q2058GETFtcA5IwQgWAc8iWw9WAXe+GbJKhxpFivk3Jk0kSuTLOE/8xw== X-Received: by 2002:a05:600c:45d2:b0:45b:7d77:b592 with SMTP id 5b1f17b1804b1-467e6f36218mr115147425e9.12.1758533837185; Mon, 22 Sep 2025 02:37:17 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Palmer Dabbelt , Alexandre Iooss , Mahmoud Mandour , qemu-riscv@nongnu.org, Daniel Henrique Barboza , Thomas Huth , Peter Maydell , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Alistair Francis , qemu-arm@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Weiwei Li , Pierrick Bouvier , Liu Zhiwei Subject: [PATCH 02/25] scripts/ci: add gitlab-failure-analysis script Date: Mon, 22 Sep 2025 10:36:47 +0100 Message-ID: <20250922093711.2768983-3-alex.bennee@linaro.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20250922093711.2768983-1-alex.bennee@linaro.org> References: <20250922093711.2768983-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 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: 1758534131403116600 This is a script designed to collect data from multiple pipelines and analyse the failure modes they have. By default it will probe the last 3 failed jobs on the staging branch. However this can all be controlled by the CLI: ./scripts/ci/gitlab-failure-analysis --count 2 --branch=3Dtesting/next --= id 39915562 --status=3D running pipeline 2028486060, total jobs 125, skipped 5, failed 0, 39742 = tests, 0 failed tests success pipeline 2015018135, total jobs 125, skipped 5, failed 0, 49219 = tests, 0 failed tests You can also skip failing jobs and just dump the tests: ./scripts/ci/gitlab-failure-analysis --branch=3D --id 39915562 --status= =3D --skip-jobs --pipeline 1946202491 1919542960 failed pipeline 1946202491, total jobs 127, skipped 5, failed 26, 38742 = tests, 278 skipped tests, 2 failed tests Failed test qemu.qemu:qtest+qtest-s390x / qtest-s390x/boot-serial-test,= check-system-opensuse, 1 /s390x/boot-serial/s390-ccw-virtio - FATAL-ERROR:= Failed to find expected string. Please check '/tmp/qtest-boot-serial-sW77E= A3' Failed test qemu.qemu:qtest+qtest-aarch64 / qtest-aarch64/arm-cpu-featu= res, check-system-opensuse, 1 /aarch64/arm/query-cpu-model-expansion - ERRO= R:../tests/qtest/arm-cpu-features.c:459:test_query_cpu_model_expansion: ass= ertion failed (_error =3D=3D "The CPU type 'host' requires KVM"): ("The CPU= type 'host' requires hardware accelerator" =3D=3D "The CPU type 'host' req= uires KVM") failed pipeline 1919542960, total jobs 127, skipped 5, failed 2, 48753 t= ests, 441 skipped tests, 1 failed tests Failed test qemu.qemu:unit / test-aio, msys2-64bit, 12 /aio/timer/sched= ule - ERROR:../tests/unit/test-aio.c:413:test_timer_schedule: assertion fai= led: (aio_poll(ctx, true)) Signed-off-by: Alex Benn=C3=A9e --- v2 - allow status selection, handle empty strings as None - allow individual pipeline selection - extract individual tests - allow skipping of jobs --- scripts/ci/gitlab-failure-analysis | 117 +++++++++++++++++++++++++++++ 1 file changed, 117 insertions(+) create mode 100755 scripts/ci/gitlab-failure-analysis diff --git a/scripts/ci/gitlab-failure-analysis b/scripts/ci/gitlab-failure= -analysis new file mode 100755 index 00000000000..906725be973 --- /dev/null +++ b/scripts/ci/gitlab-failure-analysis @@ -0,0 +1,117 @@ +#!/usr/bin/env python3 +# +# A script to analyse failures in the gitlab pipelines. It requires an +# API key from gitlab with the following permissions: +# - api +# - read_repository +# - read_user +# + +import argparse +import gitlab +import os + +# +# Arguments +# +class NoneForEmptyStringAction(argparse.Action): + def __call__(self, parser, namespace, value, option_string=3DNone): + if value =3D=3D '': + setattr(namespace, self.dest, None) + else: + setattr(namespace, self.dest, value) + + +parser =3D argparse.ArgumentParser(description=3D"Analyse failed GitLab CI= runs.") + +parser.add_argument("--gitlab", + default=3D"https://gitlab.com", + help=3D"GitLab instance URL (default: https://gitlab.c= om).") +parser.add_argument("--id", default=3D11167699, + type=3Dint, + help=3D"GitLab project id (default: 11167699 for qemu-= project/qemu)") +parser.add_argument("--token", + default=3Dos.getenv("GITLAB_TOKEN"), + help=3D"Your personal access token with 'api' scope.") +parser.add_argument("--branch", + type=3Dstr, + default=3D"staging", + action=3DNoneForEmptyStringAction, + help=3D"The name of the branch (default: 'staging')") +parser.add_argument("--status", + type=3Dstr, + action=3DNoneForEmptyStringAction, + default=3D"failed", + help=3D"Filter by branch status (default: 'failed')") +parser.add_argument("--count", type=3Dint, + default=3D3, + help=3D"The number of failed runs to fetch.") +parser.add_argument("--skip-jobs", + default=3DFalse, + action=3D'store_true', + help=3D"Skip dumping the job info") +parser.add_argument("--pipeline", type=3Dint, + nargs=3D"+", + default=3DNone, + help=3D"Explicit pipeline ID(s) to fetch.") + + +if __name__ =3D=3D "__main__": + args =3D parser.parse_args() + + gl =3D gitlab.Gitlab(url=3Dargs.gitlab, private_token=3Dargs.token) + project =3D gl.projects.get(args.id) + + + pipelines_to_process =3D [] + + # Use explicit pipeline IDs if provided, otherwise fetch a list + if args.pipeline: + args.count =3D len(args.pipeline) + for p_id in args.pipeline: + pipelines_to_process.append(project.pipelines.get(p_id)) + else: + # Use an iterator to fetch the pipelines + pipe_iter =3D project.pipelines.list(iterator=3DTrue, + status=3Dargs.status, + ref=3Dargs.branch) + # Check each failed pipeline + pipelines_to_process =3D [next(pipe_iter) for _ in range(args.coun= t)] + + # Check each pipeline + for p in pipelines_to_process: + + jobs =3D p.jobs.list(get_all=3DTrue) + failed_jobs =3D [j for j in jobs if j.status =3D=3D "failed"] + skipped_jobs =3D [j for j in jobs if j.status =3D=3D "skipped"] + manual_jobs =3D [j for j in jobs if j.status =3D=3D "manual"] + + trs =3D p.test_report_summary.get() + total =3D trs.total["count"] + skipped =3D trs.total["skipped"] + failed =3D trs.total["failed"] + + print(f"{p.status} pipeline {p.id}, total jobs {len(jobs)}, " + f"skipped {len(skipped_jobs)}, " + f"failed {len(failed_jobs)}, ", + f"{total} tests, " + f"{skipped} skipped tests, " + f"{failed} failed tests") + + if not args.skip_jobs: + for j in failed_jobs: + print(f" Failed job {j.id}, {j.name}, {j.web_url}") + + # It seems we can only extract failing tests from the full + # test report, maybe there is some way to filter it. + + if failed > 0: + ftr =3D p.test_report.get() + failed_suites =3D [s for s in ftr.test_suites if + s["failed_count"] > 0] + for fs in failed_suites: + name =3D fs["name"] + tests =3D fs["test_cases"] + failed_tests =3D [t for t in tests if t["status"] =3D=3D '= failed'] + for t in failed_tests: + print(f" Failed test {t["classname"]}, {name}, {t["na= me"]}") --=20 2.47.3 From nobody Sun Sep 28 15:30:20 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1758533982; cv=none; d=zohomail.com; s=zohoarc; b=E43jqWawJBr19tuEr+vPjJBlye9ljVG6wSerUvH28Lo6oItaUPNump47lwZx12GNw7QMbASG3hSOkYAZpAXtg39L0N5NWJtxjxwpiUa39pa4T22OUC7/8ypNdTML7l6cRa7GwWLUwLf8QP0V9WQWIeDPACvi4rgEnmdQOQ/Lok0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1758533982; 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=p7AJahUMqP4H52ZjgDIGUlzyg5ExoTqCJvWrQsOM+Os=; b=DAE4AJ3XKrqnqSV9RtSCXe6ZeY0rtFM26PncWQ0fzOM1ZYCvd0gISUQliotyCb2Kl50oqvF29FcHHlEZa+miCQbhhC7KguzSLGxgAwr7L0bbifUnpiGFFrxpWYxbjPN230O4R+8LfIHCf/QM4YZqVLoPA2/AqhVzLf9PUl6oXq4= 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 1758533982491117.34271036129599; Mon, 22 Sep 2025 02:39:42 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v0d0C-0002eU-DU; Mon, 22 Sep 2025 05:38:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v0czH-0002Ao-3i for qemu-devel@nongnu.org; Mon, 22 Sep 2025 05:37:37 -0400 Received: from mail-wr1-x42e.google.com ([2a00:1450:4864:20::42e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1v0cz3-0000cP-S8 for qemu-devel@nongnu.org; Mon, 22 Sep 2025 05:37:34 -0400 Received: by mail-wr1-x42e.google.com with SMTP id ffacd0b85a97d-3f2ae6fadb4so2163859f8f.1 for ; Mon, 22 Sep 2025 02:37:17 -0700 (PDT) Received: from draig.lan ([185.126.160.19]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3ee0fbd63a2sm19048919f8f.48.2025.09.22.02.37.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Sep 2025 02:37:12 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id C3D4D5F90D; Mon, 22 Sep 2025 10:37:11 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1758533835; x=1759138635; 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=p7AJahUMqP4H52ZjgDIGUlzyg5ExoTqCJvWrQsOM+Os=; b=Bg/SRRFWdo1eoN1rrUiX+oMyQW5KptzRh/TvTfXBdhYWtscq65fuWo4pfjWACOWc0G MuEvFRbVQZ2CeQOJtSlBe09oJuiF4og/q2AEL9lAo+dAVSh9CKejD1XM9zKQWIF9FHt0 IbEW/KERg5mq1LEJVdj9lYPxp9Gt2VXM6zpN9g/jEKejFJsZKzETa0dIGPhVpfqjMHmN lnI3DbL3mBVrn6zVTmmo7tOwXZBfeDuRe9R3Q6joQ3AXVRm1/KQUeZICju66YiH0PDvF TRa4di5yce/gtTtpzrJ/bB+aGTRO+azqbJk76AJoRlB9Lqt6vkegECf/HG8CAWeS4oou 03MQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1758533835; x=1759138635; 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=p7AJahUMqP4H52ZjgDIGUlzyg5ExoTqCJvWrQsOM+Os=; b=mwUIzkpJDp50vi1wJ+X2V/4kaHIA/lN1iD4qGJd/U9urtZeTWTLPnBUFC8ydWyis5g Gc+Nb6xcpZiOEfzJ6rYPS5TtKjHU9XGKD23TZ+D9VrQvVKVtlWchUPw/2es6HmJB4nPz Wh+/mxWDkrQYfevb7ngcXkM1B7ANdsU+ARDBGfkNo9mSlew3FqDnnskqq/O0wiuuTWLn qKCT0G/x61A7ZTcmt9IKkB8MNI6ZS/ZV4BLzAYXHZJOHIPQKeeRc7PscMddd8K5yNVGN PCjHj0DNM0TtC/i5k2HbyQCVs59b6wgxhEo4C60m6NVXMEi2Rqu3WZacVNkuZp7HLWPx uJlQ== X-Gm-Message-State: AOJu0YyXPOxfFQz1tLPVyr+YQXhRA5rxetnR+uECqjGYpkN6jPoUlImi CsS3Bn+0aC428skRNxnezvHO40f2+hfx6S0cmS7jwvW1F84GhsBdkJxCQrONadw1Qt8= X-Gm-Gg: ASbGncvJ37+4SNiItuNxSD7u18hzaG4in8QTYUbnHzVEy/1hRp5fg+mCx7MlkQan9Cx A4hG+sDzP9Mkj7UWUx1jYtusIGJ3ypThuycFxr3Wn2C9gW9bHVyB8a1LxfyFRVpcMptU6kVl/Ny FD3WHeD3BnZEzUaJjr66qYnAEOvJB+IkEmEOAHTg7eGQ5npR85mV9NN3pr1zk0tafNNUep6FPrz WKB9aNzOayO5Y3JWBrAgIcVE7OAUTdUfNnCsf6Qdf6zKuRsAnEqqxUoUp7WJ9ay2Frmm7PLnOVg t4Lr+j6rlluEMETzfqcP1qhoMZ3OoI1EeVeBS0MJ5hF32KsSWUNv2fhlV0aVJ/amksZ79myuD+G VZ76esCyTky8xC76tTCRs1NQ= X-Google-Smtp-Source: AGHT+IEKJ52MYarnP5WeS3Ssw0avY2ayMO6o3vcUndbtS7T5aj3s7MrMaJEPUYVs8MIw5X3I4Ev1pw== X-Received: by 2002:a05:6000:2c05:b0:3eb:2428:4a05 with SMTP id ffacd0b85a97d-3ee7bad11fdmr11043020f8f.3.1758533834747; Mon, 22 Sep 2025 02:37:14 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Palmer Dabbelt , Alexandre Iooss , Mahmoud Mandour , qemu-riscv@nongnu.org, Daniel Henrique Barboza , Thomas Huth , Peter Maydell , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Alistair Francis , qemu-arm@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Weiwei Li , Pierrick Bouvier , Liu Zhiwei , Nabih Estefan , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= Subject: [PATCH 03/25] checkpatch: Ignore removed lines in license check Date: Mon, 22 Sep 2025 10:36:48 +0100 Message-ID: <20250922093711.2768983-4-alex.bennee@linaro.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20250922093711.2768983-1-alex.bennee@linaro.org> References: <20250922093711.2768983-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::42e; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x42e.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, T_SPF_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: 1758533983427116600 From: Nabih Estefan When running the license check, if we are updating a license it is possible for the checkpatch script to test against old license lines instead of newer ones, since the removal lines appear before the addition lines in a .patch file. Fix this by skipping over lines that start with "-" in the checkpatch script. Signed-off-by: Nabih Estefan Reviewed-by: Daniel P. Berrang=C3=A9 Reviewed-by: Alex Benn=C3=A9e Message-ID: <20250916165928.10048-1-nabihestefan@google.com> Signed-off-by: Alex Benn=C3=A9e --- scripts/checkpatch.pl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 91616c974f2..40b6955c698 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -1816,7 +1816,8 @@ sub process { } =20 # Check SPDX-License-Identifier references a permitted license - if ($rawline =3D~ m,SPDX-License-Identifier: (.*?)(\*/)?\s*$,) { + if (($rawline =3D~ m,SPDX-License-Identifier: (.*?)(\*/)?\s*$,) && + $rawline !~ /^-/) { $fileinfo->{facts}->{sawspdx} =3D 1; &checkspdx($realfile, $1); } --=20 2.47.3 From nobody Sun Sep 28 15:30:20 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1758533966; cv=none; d=zohomail.com; s=zohoarc; b=J1c7NDyjn1PJtqz0vpcbqWRmOVBFZsYlQAkfasB3+/RWcnDWmFbxbOKXkfKsA0/ylj/xbarOgrCnceXJYiDCvUUMTXSAtfUlAUfR5gmeOOtJYeLJGCiksoH2GMHE2EeLl48oM53pUFKmelAqdXzu6GuY9zLF5ubWakrW5Lp1e68= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1758533966; 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=JuTHznpE8Nv2cEQuqc+lME7L4mMR06xxi1Vz6Eb3vrU=; b=mfS1pfXq8uXXbHfu9cbCzNjXyh3zGXGDarFOgOd4EaddhlaLW8OJEVXTE7Ac9tBbq6NC44dHK42H/KjoqtquoSzb4F6tO8bkVrNbZUxyol+sB4v0e3fyoOjIwdR6shifYhwRShZ6yMv93mzHByes8+Uv5ZFEOvx6Gn1pdjZNK40= 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 1758533966182296.6195633386409; Mon, 22 Sep 2025 02:39:26 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v0d0a-0003LG-Eh; Mon, 22 Sep 2025 05:38:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v0czK-0002By-3V for qemu-devel@nongnu.org; Mon, 22 Sep 2025 05:37:40 -0400 Received: from mail-wr1-x433.google.com ([2a00:1450:4864:20::433]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1v0cz4-0000d6-E6 for qemu-devel@nongnu.org; Mon, 22 Sep 2025 05:37:36 -0400 Received: by mail-wr1-x433.google.com with SMTP id ffacd0b85a97d-3f0ae439b56so1928184f8f.3 for ; Mon, 22 Sep 2025 02:37:18 -0700 (PDT) Received: from draig.lan ([185.126.160.19]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3fcdbc4374csm4735397f8f.13.2025.09.22.02.37.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Sep 2025 02:37:12 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id DE3535F9E3; Mon, 22 Sep 2025 10:37:11 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1758533836; x=1759138636; 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=JuTHznpE8Nv2cEQuqc+lME7L4mMR06xxi1Vz6Eb3vrU=; b=dsBPIxBOxjXUHDj9jU6wJnVCD8WamH5FCqb0GDSajCqGdppyknDTn5l7Gd0F+dTph7 Kr2UXIR5oHuY47zsUuMVVFTSAi9aqMxvXkGpdzytFu/k04Lk9utoNG1yMI36txwB7l9T DbQpDpFOPK9s75eYE5gizbxv4eCkJ8pCCZH4+RGelHqCAfZreJKSFvOGj4vzDv9NnKMn YlsF9A3/UPuEoVSo6bqpwKCbXF5mRfs/VI3xzWtTf8xX7AAJxzCsi9d856OTf8u83bsp nvYrtO27BTytM+Elr8o66DKIDkzG55V+K460IhvOWB9YkVZi10RDWWKBbQYj3mfHx64z qWCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1758533836; x=1759138636; 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=JuTHznpE8Nv2cEQuqc+lME7L4mMR06xxi1Vz6Eb3vrU=; b=TyRF5O6fo0XDW53L3BnfevszAHF78BaTTuE2ReqbskKFYN9nIlSYC2tsmnSRnWGdFq 2GA2l41RWJk2I+lRrRa3m/VSRNb4ud1Jlqoc4XmbYvMjF8uMei1v6n/SAeTsiq1E0aBA HEcbIPDPhlk/dtb6HeLoGAuCD5tc7XN3oIoLNj4py0AQKVQYg+A/wx+IlnB8VGgtzvbc LWE10lfnlh1oyjYLhKw3W9YYlCZnJIRgxPJ2/Ja/HxcviG58MbFGQ87tpIls8dy0sX85 LrF2njN5H7BRaHlozVCaId3xNiTLtEeh4Hi4AWdl/feceQyLS6IbFTKjGt+GoTDicttP bvkA== X-Gm-Message-State: AOJu0YyQWoZN+AXGYUuLnhyAUaVLZ8mrcA701iX+K8NxSd18oMNkHs+A vMIki9p88IqsI1oai7mXayZJQIisvCll/RCS6Na6ckcPl1MpDne+Lxbrc7PUBexGggs= X-Gm-Gg: ASbGncsW41vJQ7UIl+Gp4IvgL6SElqlZics8dODvlR+Oq1ifZwIQZrUQw/8kuvSulir 6KstTSE2aWHRYifPnGMRsESQuIPebFo8lXH3/ipdQNLLzDqxg6mlG2Ef0uQ4jCbdNbcKpZzpwkS 9ybWClQiYbY+KeY5AEPOMPLozDNyeWdydxZ83hVxEvtaCecxU+auI5KuJKRni5q2glwe04j5VEH ngGOeFQYzq/hVd9DBGAAzmL0JVeL+gwsB7XZ5/BkzrazDQdDcfMdRnDvpff/JdLzSXlaYiqQ/Fb //F1xdy5QZZ+USq3Z6FTBUKCFejvUUQtqRcKbcwbUIjb1T5npZMfYlnXzcEGm9JhUfUg0Zxd78k 7pcR3Ol+hukvQf0HLv2IptSRbggQBD+uc0g== X-Google-Smtp-Source: AGHT+IHy0gzWZ9QdEaoFBB3wH3A3eTrKtrgsEUBXSm3FMxTV46WTmcVgwv7zDGbWGd2uokV9g/iOHg== X-Received: by 2002:a05:6000:2083:b0:3c7:df1d:3d9 with SMTP id ffacd0b85a97d-3ee83da051amr9151368f8f.39.1758533835777; Mon, 22 Sep 2025 02:37:15 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Palmer Dabbelt , Alexandre Iooss , Mahmoud Mandour , qemu-riscv@nongnu.org, Daniel Henrique Barboza , Thomas Huth , Peter Maydell , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Alistair Francis , qemu-arm@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Weiwei Li , Pierrick Bouvier , Liu Zhiwei , Richard Henderson Subject: [PATCH 04/25] semihosting/syscalls: compile once in system and per target for user mode Date: Mon, 22 Sep 2025 10:36:49 +0100 Message-ID: <20250922093711.2768983-5-alex.bennee@linaro.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20250922093711.2768983-1-alex.bennee@linaro.org> References: <20250922093711.2768983-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::433; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x433.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=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: 1758533967295116600 From: Pierrick Bouvier We replace target_ulong mechanically by uint64_t. We can't compile (easily) this code once for user, as it relies on various target/function types, so leave it in specific_ss for user mode. Reviewed-by: Richard Henderson Signed-off-by: Pierrick Bouvier Message-ID: <20250822150058.18692-2-pierrick.bouvier@linaro.org> Signed-off-by: Alex Benn=C3=A9e --- include/semihosting/syscalls.h | 30 ++++++------ semihosting/arm-compat-semi.c | 1 + semihosting/syscalls.c | 89 +++++++++++++++++----------------- semihosting/meson.build | 4 +- 4 files changed, 63 insertions(+), 61 deletions(-) diff --git a/include/semihosting/syscalls.h b/include/semihosting/syscalls.h index 6627c45fb28..03aa45b7bb9 100644 --- a/include/semihosting/syscalls.h +++ b/include/semihosting/syscalls.h @@ -9,7 +9,7 @@ #ifndef SEMIHOSTING_SYSCALLS_H #define SEMIHOSTING_SYSCALLS_H =20 -#include "exec/cpu-defs.h" +#include "exec/vaddr.h" #include "gdbstub/syscalls.h" =20 /* @@ -24,23 +24,23 @@ typedef struct GuestFD GuestFD; =20 void semihost_sys_open(CPUState *cs, gdb_syscall_complete_cb complete, - target_ulong fname, target_ulong fname_len, + vaddr fname, uint64_t fname_len, int gdb_flags, int mode); =20 void semihost_sys_close(CPUState *cs, gdb_syscall_complete_cb complete, int fd); =20 void semihost_sys_read(CPUState *cs, gdb_syscall_complete_cb complete, - int fd, target_ulong buf, target_ulong len); + int fd, vaddr buf, uint64_t len); =20 void semihost_sys_read_gf(CPUState *cs, gdb_syscall_complete_cb complete, - GuestFD *gf, target_ulong buf, target_ulong len); + GuestFD *gf, vaddr buf, uint64_t len); =20 void semihost_sys_write(CPUState *cs, gdb_syscall_complete_cb complete, - int fd, target_ulong buf, target_ulong len); + int fd, vaddr buf, uint64_t len); =20 void semihost_sys_write_gf(CPUState *cs, gdb_syscall_complete_cb complete, - GuestFD *gf, target_ulong buf, target_ulong len= ); + GuestFD *gf, vaddr buf, uint64_t len); =20 void semihost_sys_lseek(CPUState *cs, gdb_syscall_complete_cb complete, int fd, int64_t off, int gdb_whence); @@ -50,27 +50,27 @@ void semihost_sys_isatty(CPUState *cs, gdb_syscall_comp= lete_cb complete, =20 void semihost_sys_flen(CPUState *cs, gdb_syscall_complete_cb fstat_cb, gdb_syscall_complete_cb flen_cb, - int fd, target_ulong fstat_addr); + int fd, vaddr fstat_addr); =20 void semihost_sys_fstat(CPUState *cs, gdb_syscall_complete_cb complete, - int fd, target_ulong addr); + int fd, vaddr addr); =20 void semihost_sys_stat(CPUState *cs, gdb_syscall_complete_cb complete, - target_ulong fname, target_ulong fname_len, - target_ulong addr); + vaddr fname, uint64_t fname_len, + vaddr addr); =20 void semihost_sys_remove(CPUState *cs, gdb_syscall_complete_cb complete, - target_ulong fname, target_ulong fname_len); + vaddr fname, uint64_t fname_len); =20 void semihost_sys_rename(CPUState *cs, gdb_syscall_complete_cb complete, - target_ulong oname, target_ulong oname_len, - target_ulong nname, target_ulong nname_len); + vaddr oname, uint64_t oname_len, + vaddr nname, uint64_t nname_len); =20 void semihost_sys_system(CPUState *cs, gdb_syscall_complete_cb complete, - target_ulong cmd, target_ulong cmd_len); + vaddr cmd, uint64_t cmd_len); =20 void semihost_sys_gettimeofday(CPUState *cs, gdb_syscall_complete_cb compl= ete, - target_ulong tv_addr, target_ulong tz_addr); + vaddr tv_addr, vaddr tz_addr); =20 void semihost_sys_poll_one(CPUState *cs, gdb_syscall_complete_cb complete, int fd, GIOCondition cond, int timeout); diff --git a/semihosting/arm-compat-semi.c b/semihosting/arm-compat-semi.c index bcd13cd6dfd..64ddc749bf8 100644 --- a/semihosting/arm-compat-semi.c +++ b/semihosting/arm-compat-semi.c @@ -34,6 +34,7 @@ #include "qemu/osdep.h" #include "qemu/timer.h" #include "exec/gdbstub.h" +#include "cpu.h" #include "gdbstub/syscalls.h" #include "semihosting/semihost.h" #include "semihosting/console.h" diff --git a/semihosting/syscalls.c b/semihosting/syscalls.c index f6451d9bb0e..f072d919193 100644 --- a/semihosting/syscalls.c +++ b/semihosting/syscalls.c @@ -8,7 +8,6 @@ =20 #include "qemu/osdep.h" #include "qemu/log.h" -#include "cpu.h" #include "gdbstub/syscalls.h" #include "semihosting/guestfd.h" #include "semihosting/syscalls.h" @@ -23,7 +22,7 @@ /* * Validate or compute the length of the string (including terminator). */ -static int validate_strlen(CPUState *cs, target_ulong str, target_ulong tl= en) +static int validate_strlen(CPUState *cs, uint64_t str, uint64_t tlen) { CPUArchState *env G_GNUC_UNUSED =3D cpu_env(cs); char c; @@ -52,7 +51,7 @@ static int validate_strlen(CPUState *cs, target_ulong str= , target_ulong tlen) } =20 static int validate_lock_user_string(char **pstr, CPUState *cs, - target_ulong tstr, target_ulong tlen) + uint64_t tstr, uint64_t tlen) { int ret =3D validate_strlen(cs, tstr, tlen); CPUArchState *env G_GNUC_UNUSED =3D cpu_env(cs); @@ -72,7 +71,7 @@ static int validate_lock_user_string(char **pstr, CPUStat= e *cs, * big-endian. Until we do something with gdb, also produce the * same big-endian result from the host. */ -static int copy_stat_to_user(CPUState *cs, target_ulong addr, +static int copy_stat_to_user(CPUState *cs, uint64_t addr, const struct stat *s) { CPUArchState *env G_GNUC_UNUSED =3D cpu_env(cs); @@ -129,7 +128,7 @@ static void gdb_open_cb(CPUState *cs, uint64_t ret, int= err) } =20 static void gdb_open(CPUState *cs, gdb_syscall_complete_cb complete, - target_ulong fname, target_ulong fname_len, + uint64_t fname, uint64_t fname_len, int gdb_flags, int mode) { int len =3D validate_strlen(cs, fname, fname_len); @@ -151,14 +150,14 @@ static void gdb_close(CPUState *cs, gdb_syscall_compl= ete_cb complete, } =20 static void gdb_read(CPUState *cs, gdb_syscall_complete_cb complete, - GuestFD *gf, target_ulong buf, target_ulong len) + GuestFD *gf, uint64_t buf, uint64_t len) { gdb_do_syscall(complete, "read,%x,%lx,%lx", (uint32_t)gf->hostfd, (uint64_t)buf, (uint64_t)len); } =20 static void gdb_write(CPUState *cs, gdb_syscall_complete_cb complete, - GuestFD *gf, target_ulong buf, target_ulong len) + GuestFD *gf, uint64_t buf, uint64_t len) { gdb_do_syscall(complete, "write,%x,%lx,%lx", (uint32_t)gf->hostfd, (uint64_t)buf, (uint64_t)len); @@ -178,15 +177,15 @@ static void gdb_isatty(CPUState *cs, gdb_syscall_comp= lete_cb complete, } =20 static void gdb_fstat(CPUState *cs, gdb_syscall_complete_cb complete, - GuestFD *gf, target_ulong addr) + GuestFD *gf, uint64_t addr) { gdb_do_syscall(complete, "fstat,%x,%lx", (uint32_t)gf->hostfd, (uint64_t)addr); } =20 static void gdb_stat(CPUState *cs, gdb_syscall_complete_cb complete, - target_ulong fname, target_ulong fname_len, - target_ulong addr) + uint64_t fname, uint64_t fname_len, + uint64_t addr) { int len =3D validate_strlen(cs, fname, fname_len); if (len < 0) { @@ -199,7 +198,7 @@ static void gdb_stat(CPUState *cs, gdb_syscall_complete= _cb complete, } =20 static void gdb_remove(CPUState *cs, gdb_syscall_complete_cb complete, - target_ulong fname, target_ulong fname_len) + uint64_t fname, uint64_t fname_len) { int len =3D validate_strlen(cs, fname, fname_len); if (len < 0) { @@ -211,8 +210,8 @@ static void gdb_remove(CPUState *cs, gdb_syscall_comple= te_cb complete, } =20 static void gdb_rename(CPUState *cs, gdb_syscall_complete_cb complete, - target_ulong oname, target_ulong oname_len, - target_ulong nname, target_ulong nname_len) + uint64_t oname, uint64_t oname_len, + uint64_t nname, uint64_t nname_len) { int olen, nlen; =20 @@ -233,7 +232,7 @@ static void gdb_rename(CPUState *cs, gdb_syscall_comple= te_cb complete, } =20 static void gdb_system(CPUState *cs, gdb_syscall_complete_cb complete, - target_ulong cmd, target_ulong cmd_len) + uint64_t cmd, uint64_t cmd_len) { int len =3D validate_strlen(cs, cmd, cmd_len); if (len < 0) { @@ -245,7 +244,7 @@ static void gdb_system(CPUState *cs, gdb_syscall_comple= te_cb complete, } =20 static void gdb_gettimeofday(CPUState *cs, gdb_syscall_complete_cb complet= e, - target_ulong tv_addr, target_ulong tz_addr) + uint64_t tv_addr, uint64_t tz_addr) { gdb_do_syscall(complete, "gettimeofday,%lx,%lx", (uint64_t)tv_addr, (uint64_t)tz_addr); @@ -256,7 +255,7 @@ static void gdb_gettimeofday(CPUState *cs, gdb_syscall_= complete_cb complete, */ =20 static void host_open(CPUState *cs, gdb_syscall_complete_cb complete, - target_ulong fname, target_ulong fname_len, + uint64_t fname, uint64_t fname_len, int gdb_flags, int mode) { CPUArchState *env G_GNUC_UNUSED =3D cpu_env(cs); @@ -316,7 +315,7 @@ static void host_close(CPUState *cs, gdb_syscall_comple= te_cb complete, } =20 static void host_read(CPUState *cs, gdb_syscall_complete_cb complete, - GuestFD *gf, target_ulong buf, target_ulong len) + GuestFD *gf, uint64_t buf, uint64_t len) { CPUArchState *env G_GNUC_UNUSED =3D cpu_env(cs); void *ptr =3D lock_user(VERIFY_WRITE, buf, len, 0); @@ -337,7 +336,7 @@ static void host_read(CPUState *cs, gdb_syscall_complet= e_cb complete, } =20 static void host_write(CPUState *cs, gdb_syscall_complete_cb complete, - GuestFD *gf, target_ulong buf, target_ulong len) + GuestFD *gf, uint64_t buf, uint64_t len) { CPUArchState *env G_GNUC_UNUSED =3D cpu_env(cs); void *ptr =3D lock_user(VERIFY_READ, buf, len, 1); @@ -395,7 +394,7 @@ static void host_flen(CPUState *cs, gdb_syscall_complet= e_cb complete, } =20 static void host_fstat(CPUState *cs, gdb_syscall_complete_cb complete, - GuestFD *gf, target_ulong addr) + GuestFD *gf, uint64_t addr) { struct stat buf; int ret; @@ -410,8 +409,8 @@ static void host_fstat(CPUState *cs, gdb_syscall_comple= te_cb complete, } =20 static void host_stat(CPUState *cs, gdb_syscall_complete_cb complete, - target_ulong fname, target_ulong fname_len, - target_ulong addr) + uint64_t fname, uint64_t fname_len, + uint64_t addr) { CPUArchState *env G_GNUC_UNUSED =3D cpu_env(cs); struct stat buf; @@ -440,7 +439,7 @@ static void host_stat(CPUState *cs, gdb_syscall_complet= e_cb complete, } =20 static void host_remove(CPUState *cs, gdb_syscall_complete_cb complete, - target_ulong fname, target_ulong fname_len) + uint64_t fname, uint64_t fname_len) { CPUArchState *env G_GNUC_UNUSED =3D cpu_env(cs); char *p; @@ -458,8 +457,8 @@ static void host_remove(CPUState *cs, gdb_syscall_compl= ete_cb complete, } =20 static void host_rename(CPUState *cs, gdb_syscall_complete_cb complete, - target_ulong oname, target_ulong oname_len, - target_ulong nname, target_ulong nname_len) + uint64_t oname, uint64_t oname_len, + uint64_t nname, uint64_t nname_len) { CPUArchState *env G_GNUC_UNUSED =3D cpu_env(cs); char *ostr, *nstr; @@ -484,7 +483,7 @@ static void host_rename(CPUState *cs, gdb_syscall_compl= ete_cb complete, } =20 static void host_system(CPUState *cs, gdb_syscall_complete_cb complete, - target_ulong cmd, target_ulong cmd_len) + uint64_t cmd, uint64_t cmd_len) { CPUArchState *env G_GNUC_UNUSED =3D cpu_env(cs); char *p; @@ -502,7 +501,7 @@ static void host_system(CPUState *cs, gdb_syscall_compl= ete_cb complete, } =20 static void host_gettimeofday(CPUState *cs, gdb_syscall_complete_cb comple= te, - target_ulong tv_addr, target_ulong tz_addr) + uint64_t tv_addr, uint64_t tz_addr) { CPUArchState *env G_GNUC_UNUSED =3D cpu_env(cs); struct gdb_timeval *p; @@ -547,10 +546,10 @@ static void host_poll_one(CPUState *cs, gdb_syscall_c= omplete_cb complete, */ =20 static void staticfile_read(CPUState *cs, gdb_syscall_complete_cb complete, - GuestFD *gf, target_ulong buf, target_ulong le= n) + GuestFD *gf, uint64_t buf, uint64_t len) { CPUArchState *env G_GNUC_UNUSED =3D cpu_env(cs); - target_ulong rest =3D gf->staticfile.len - gf->staticfile.off; + uint64_t rest =3D gf->staticfile.len - gf->staticfile.off; void *ptr; =20 if (len > rest) { @@ -605,7 +604,7 @@ static void staticfile_flen(CPUState *cs, gdb_syscall_c= omplete_cb complete, */ =20 static void console_read(CPUState *cs, gdb_syscall_complete_cb complete, - GuestFD *gf, target_ulong buf, target_ulong len) + GuestFD *gf, uint64_t buf, uint64_t len) { CPUArchState *env G_GNUC_UNUSED =3D cpu_env(cs); char *ptr; @@ -622,7 +621,7 @@ static void console_read(CPUState *cs, gdb_syscall_comp= lete_cb complete, } =20 static void console_write(CPUState *cs, gdb_syscall_complete_cb complete, - GuestFD *gf, target_ulong buf, target_ulong len) + GuestFD *gf, uint64_t buf, uint64_t len) { CPUArchState *env G_GNUC_UNUSED =3D cpu_env(cs); char *ptr =3D lock_user(VERIFY_READ, buf, len, 1); @@ -638,7 +637,7 @@ static void console_write(CPUState *cs, gdb_syscall_com= plete_cb complete, } =20 static void console_fstat(CPUState *cs, gdb_syscall_complete_cb complete, - GuestFD *gf, target_ulong addr) + GuestFD *gf, uint64_t addr) { static const struct stat tty_buf =3D { .st_mode =3D 020666, /* S_IFCHR, ugo+rw */ @@ -683,7 +682,7 @@ static void console_poll_one(CPUState *cs, gdb_syscall_= complete_cb complete, */ =20 void semihost_sys_open(CPUState *cs, gdb_syscall_complete_cb complete, - target_ulong fname, target_ulong fname_len, + vaddr fname, uint64_t fname_len, int gdb_flags, int mode) { if (use_gdb_syscalls()) { @@ -719,7 +718,7 @@ void semihost_sys_close(CPUState *cs, gdb_syscall_compl= ete_cb complete, int fd) } =20 void semihost_sys_read_gf(CPUState *cs, gdb_syscall_complete_cb complete, - GuestFD *gf, target_ulong buf, target_ulong len) + GuestFD *gf, vaddr buf, uint64_t len) { /* * Bound length for 64-bit guests on 32-bit hosts, not overflowing ssi= ze_t. @@ -748,7 +747,7 @@ void semihost_sys_read_gf(CPUState *cs, gdb_syscall_com= plete_cb complete, } =20 void semihost_sys_read(CPUState *cs, gdb_syscall_complete_cb complete, - int fd, target_ulong buf, target_ulong len) + int fd, vaddr buf, uint64_t len) { GuestFD *gf =3D get_guestfd(fd); =20 @@ -760,7 +759,7 @@ void semihost_sys_read(CPUState *cs, gdb_syscall_comple= te_cb complete, } =20 void semihost_sys_write_gf(CPUState *cs, gdb_syscall_complete_cb complete, - GuestFD *gf, target_ulong buf, target_ulong len) + GuestFD *gf, vaddr buf, uint64_t len) { /* * Bound length for 64-bit guests on 32-bit hosts, not overflowing ssi= ze_t. @@ -790,7 +789,7 @@ void semihost_sys_write_gf(CPUState *cs, gdb_syscall_co= mplete_cb complete, } =20 void semihost_sys_write(CPUState *cs, gdb_syscall_complete_cb complete, - int fd, target_ulong buf, target_ulong len) + int fd, vaddr buf, uint64_t len) { GuestFD *gf =3D get_guestfd(fd); =20 @@ -856,7 +855,7 @@ void semihost_sys_isatty(CPUState *cs, gdb_syscall_comp= lete_cb complete, int fd) =20 void semihost_sys_flen(CPUState *cs, gdb_syscall_complete_cb fstat_cb, gdb_syscall_complete_cb flen_cb, int fd, - target_ulong fstat_addr) + vaddr fstat_addr) { GuestFD *gf =3D get_guestfd(fd); =20 @@ -881,7 +880,7 @@ void semihost_sys_flen(CPUState *cs, gdb_syscall_comple= te_cb fstat_cb, } =20 void semihost_sys_fstat(CPUState *cs, gdb_syscall_complete_cb complete, - int fd, target_ulong addr) + int fd, vaddr addr) { GuestFD *gf =3D get_guestfd(fd); =20 @@ -906,8 +905,8 @@ void semihost_sys_fstat(CPUState *cs, gdb_syscall_compl= ete_cb complete, } =20 void semihost_sys_stat(CPUState *cs, gdb_syscall_complete_cb complete, - target_ulong fname, target_ulong fname_len, - target_ulong addr) + vaddr fname, uint64_t fname_len, + vaddr addr) { if (use_gdb_syscalls()) { gdb_stat(cs, complete, fname, fname_len, addr); @@ -917,7 +916,7 @@ void semihost_sys_stat(CPUState *cs, gdb_syscall_comple= te_cb complete, } =20 void semihost_sys_remove(CPUState *cs, gdb_syscall_complete_cb complete, - target_ulong fname, target_ulong fname_len) + vaddr fname, uint64_t fname_len) { if (use_gdb_syscalls()) { gdb_remove(cs, complete, fname, fname_len); @@ -927,8 +926,8 @@ void semihost_sys_remove(CPUState *cs, gdb_syscall_comp= lete_cb complete, } =20 void semihost_sys_rename(CPUState *cs, gdb_syscall_complete_cb complete, - target_ulong oname, target_ulong oname_len, - target_ulong nname, target_ulong nname_len) + vaddr oname, uint64_t oname_len, + vaddr nname, uint64_t nname_len) { if (use_gdb_syscalls()) { gdb_rename(cs, complete, oname, oname_len, nname, nname_len); @@ -938,7 +937,7 @@ void semihost_sys_rename(CPUState *cs, gdb_syscall_comp= lete_cb complete, } =20 void semihost_sys_system(CPUState *cs, gdb_syscall_complete_cb complete, - target_ulong cmd, target_ulong cmd_len) + vaddr cmd, uint64_t cmd_len) { if (use_gdb_syscalls()) { gdb_system(cs, complete, cmd, cmd_len); @@ -948,7 +947,7 @@ void semihost_sys_system(CPUState *cs, gdb_syscall_comp= lete_cb complete, } =20 void semihost_sys_gettimeofday(CPUState *cs, gdb_syscall_complete_cb compl= ete, - target_ulong tv_addr, target_ulong tz_addr) + vaddr tv_addr, vaddr tz_addr) { if (use_gdb_syscalls()) { gdb_gettimeofday(cs, complete, tv_addr, tz_addr); diff --git a/semihosting/meson.build b/semihosting/meson.build index b1ab2506c6e..77200a7f27b 100644 --- a/semihosting/meson.build +++ b/semihosting/meson.build @@ -1,6 +1,5 @@ specific_ss.add(when: 'CONFIG_SEMIHOSTING', if_true: files( 'guestfd.c', - 'syscalls.c', )) =20 common_ss.add(when: 'CONFIG_SEMIHOSTING', if_false: files('stubs-all.c')) @@ -9,9 +8,12 @@ system_ss.add(when: 'CONFIG_SEMIHOSTING', if_true: files( 'config.c', 'console.c', 'uaccess.c', + 'syscalls.c', ), if_false: files( 'stubs-system.c', )) =20 +specific_ss.add(when: ['CONFIG_SEMIHOSTING', 'CONFIG_USER_ONLY'], + if_true: files('syscalls.c')) specific_ss.add(when: ['CONFIG_ARM_COMPATIBLE_SEMIHOSTING'], if_true: files('arm-compat-semi.c')) --=20 2.47.3 From nobody Sun Sep 28 15:30:20 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1758533986; cv=none; d=zohomail.com; s=zohoarc; b=ESVIfaEkjsyohFmNnL1trwSjFQidh3ARydpg0gShfBh67tA5iwA93+PEOSuBFTR9+etfci35+8eyjqLiqxwvWJeJ9fs/yr0w/4RXAns78VadzummRjXmqoArllBIQ8G5m7lYvML9tRuHxH/VeGDRgNthlbAkOG1WcASEUHqfhXI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1758533986; 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=pcPukW9mtIUHAUBp8jxaYoUAYF89W1SMYnteBY4oBnY=; b=IEIW0tX/sXwWBkUSPMAV+7nsXATP+HQ/e0gyn/+YP+w3xFx7RrDnEsj/kyA7yABJ+HBSM6KhWlPpqAkulgHfs38CsWkz5Hy3urfXhfS80Qc4EBIgG70pqvsdDOg6tJmIT1ZRQhxvO1XfDsf0reu6GeA2JW94QXjOmwqx3K57cgQ= 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 175853398682381.12748655179973; Mon, 22 Sep 2025 02:39:46 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v0d0p-0004e2-S7; Mon, 22 Sep 2025 05:39:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v0czc-0002Qf-NQ for qemu-devel@nongnu.org; Mon, 22 Sep 2025 05:38:03 -0400 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1v0cz9-0000fo-Ki for qemu-devel@nongnu.org; Mon, 22 Sep 2025 05:37:56 -0400 Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-45dd5e24d16so40131425e9.3 for ; Mon, 22 Sep 2025 02:37:26 -0700 (PDT) Received: from draig.lan ([185.126.160.19]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3ee1227cc37sm17817268f8f.7.2025.09.22.02.37.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Sep 2025 02:37:17 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 0112A5F9EB; Mon, 22 Sep 2025 10:37:12 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1758533844; x=1759138644; 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=pcPukW9mtIUHAUBp8jxaYoUAYF89W1SMYnteBY4oBnY=; b=m22+zmulqqKV1+4/jESIxTzHuJboLqMz0/h40d5HSPS2KtoTxG4pm08q44Q5NClz+k ovGZC38R4qwAjOnOMWHjcBaVLFYn71+Rhkf10T8rtVHGDushlCITNP9XYzBx+61eGinS sQc82UCIEKCeYaMuQHJdlUuQilRugMDlfz/xun2e+NaqYx7Pham4cnANA8J5Mkn8gaKJ GZuRPRFM9yJC34uXBv7uIXEUiEStZcD2iNiluSeIix5swGnSkk6o0VHwDhYwJ/XCB+OY cLhGZZUEZbSbBXbTF/jwPEiSOafl1nMb67Rz3sfyR7a7EHERUDreHFgmeF8UDWZiJPyg MqtA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1758533844; x=1759138644; 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=pcPukW9mtIUHAUBp8jxaYoUAYF89W1SMYnteBY4oBnY=; b=n9Ai6A8brr87ZGBibsj7maOThJfFtb9/QcS3ud76nEpWDAxaKi61muyKWj9UWthPyg Q+a7NYuJfp/z9n31ck58O0FDMXVvWiUre+mI69wgEKlQO4a2FxzQ1OTc0YmdDR52+4eZ gim7Tgm7vQ6/IBKdKOqObmOtSiZbsbXXO9zD7BIqy+vtYiCJ8NAwNve2rCtoL6Blz5mz BJvSby6dPNh/U7pKMnoonsVqpYqiKxPvnLoH5xx6cqJFVvW5NyyiHwKKA679XU1rh75V EWVGXOnghsw0YV8qn34R3BmXv9R8wJWJxG0bcrRLCTty5XhKoDo7apwKMWOLgpQciDQ0 sAEA== X-Gm-Message-State: AOJu0YyVcRw6V6/jn3yqVNMljR0Tp8LrX1zjhwMexfW+vkQDOW20BT2R Sk7j98TIL2vXl+QHqXfqbaAnxc+m0jsr53zj6cQ2KiKA6nlRNfoUMbqFiCsDdAF3wEo= X-Gm-Gg: ASbGnctFSkaJ1SZaQqq3DGqPdkpbXvhxK8Iu5PgTux4zadPzmEGEb9og7u/lEIqfLU9 o62HbN5RQ+iczgS1SwSBAnVZxzudCvY2EWxseTIGrfJscSFb3QjZPAf399x7zHK3VmUzydzNhh4 mUDO4v+JLZ3F5JamRm0/4dzk7nANGrVHOMNWkprSTZQ0sRCFJk+KFj4ZF17kMevc7C7b4LZjnrc Otmvv0knPXlc/3SLJjnCsiQY8ZDImA+4Vnnibx//1WbhkRlVIwxL8v5ZwUW/2QsBaLrFCnA2YKQ Fxla1ly3fA/HGArBL+g1bwiaKAgZcFbieS9o+eS7wP9Cxc75SelYTpON1jEA3gsMoolke7PW07c 2dS1yYaS9fSKIGWn5+68VcTA= X-Google-Smtp-Source: AGHT+IGsUBp1NqafwcbALwg7UwDN4rTjCYc92dl7M1piUEbdRsb5ea8yuyhueyCJpDcb+0E7dS+OzQ== X-Received: by 2002:a05:600c:3593:b0:459:e398:ed89 with SMTP id 5b1f17b1804b1-467e6b64adbmr110656125e9.1.1758533843575; Mon, 22 Sep 2025 02:37:23 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Palmer Dabbelt , Alexandre Iooss , Mahmoud Mandour , qemu-riscv@nongnu.org, Daniel Henrique Barboza , Thomas Huth , Peter Maydell , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Alistair Francis , qemu-arm@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Weiwei Li , Pierrick Bouvier , Liu Zhiwei , Richard Henderson Subject: [PATCH 05/25] semihosting/syscalls: replace uint64_t with vaddr where appropriate Date: Mon, 22 Sep 2025 10:36:50 +0100 Message-ID: <20250922093711.2768983-6-alex.bennee@linaro.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20250922093711.2768983-1-alex.bennee@linaro.org> References: <20250922093711.2768983-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::333; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x333.google.com X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, DKIM_INVALID=0.1, DKIM_SIGNED=0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1758533987196116600 From: Pierrick Bouvier Reviewed-by: Richard Henderson Signed-off-by: Pierrick Bouvier Message-ID: <20250822150058.18692-3-pierrick.bouvier@linaro.org> Signed-off-by: Alex Benn=C3=A9e --- semihosting/syscalls.c | 78 +++++++++++++++++++++--------------------- 1 file changed, 39 insertions(+), 39 deletions(-) diff --git a/semihosting/syscalls.c b/semihosting/syscalls.c index f072d919193..20f155f869a 100644 --- a/semihosting/syscalls.c +++ b/semihosting/syscalls.c @@ -22,7 +22,7 @@ /* * Validate or compute the length of the string (including terminator). */ -static int validate_strlen(CPUState *cs, uint64_t str, uint64_t tlen) +static int validate_strlen(CPUState *cs, vaddr str, uint64_t tlen) { CPUArchState *env G_GNUC_UNUSED =3D cpu_env(cs); char c; @@ -51,7 +51,7 @@ static int validate_strlen(CPUState *cs, uint64_t str, ui= nt64_t tlen) } =20 static int validate_lock_user_string(char **pstr, CPUState *cs, - uint64_t tstr, uint64_t tlen) + vaddr tstr, uint64_t tlen) { int ret =3D validate_strlen(cs, tstr, tlen); CPUArchState *env G_GNUC_UNUSED =3D cpu_env(cs); @@ -71,7 +71,7 @@ static int validate_lock_user_string(char **pstr, CPUStat= e *cs, * big-endian. Until we do something with gdb, also produce the * same big-endian result from the host. */ -static int copy_stat_to_user(CPUState *cs, uint64_t addr, +static int copy_stat_to_user(CPUState *cs, vaddr addr, const struct stat *s) { CPUArchState *env G_GNUC_UNUSED =3D cpu_env(cs); @@ -128,7 +128,7 @@ static void gdb_open_cb(CPUState *cs, uint64_t ret, int= err) } =20 static void gdb_open(CPUState *cs, gdb_syscall_complete_cb complete, - uint64_t fname, uint64_t fname_len, + vaddr fname, uint64_t fname_len, int gdb_flags, int mode) { int len =3D validate_strlen(cs, fname, fname_len); @@ -139,7 +139,7 @@ static void gdb_open(CPUState *cs, gdb_syscall_complete= _cb complete, =20 gdb_open_complete =3D complete; gdb_do_syscall(gdb_open_cb, "open,%s,%x,%x", - (uint64_t)fname, (uint32_t)len, + (vaddr)fname, (uint32_t)len, (uint32_t)gdb_flags, (uint32_t)mode); } =20 @@ -150,17 +150,17 @@ static void gdb_close(CPUState *cs, gdb_syscall_compl= ete_cb complete, } =20 static void gdb_read(CPUState *cs, gdb_syscall_complete_cb complete, - GuestFD *gf, uint64_t buf, uint64_t len) + GuestFD *gf, vaddr buf, uint64_t len) { gdb_do_syscall(complete, "read,%x,%lx,%lx", - (uint32_t)gf->hostfd, (uint64_t)buf, (uint64_t)len); + (uint32_t)gf->hostfd, (vaddr)buf, (uint64_t)len); } =20 static void gdb_write(CPUState *cs, gdb_syscall_complete_cb complete, - GuestFD *gf, uint64_t buf, uint64_t len) + GuestFD *gf, vaddr buf, uint64_t len) { gdb_do_syscall(complete, "write,%x,%lx,%lx", - (uint32_t)gf->hostfd, (uint64_t)buf, (uint64_t)len); + (uint32_t)gf->hostfd, (vaddr)buf, (uint64_t)len); } =20 static void gdb_lseek(CPUState *cs, gdb_syscall_complete_cb complete, @@ -177,15 +177,15 @@ static void gdb_isatty(CPUState *cs, gdb_syscall_comp= lete_cb complete, } =20 static void gdb_fstat(CPUState *cs, gdb_syscall_complete_cb complete, - GuestFD *gf, uint64_t addr) + GuestFD *gf, vaddr addr) { gdb_do_syscall(complete, "fstat,%x,%lx", - (uint32_t)gf->hostfd, (uint64_t)addr); + (uint32_t)gf->hostfd, (vaddr)addr); } =20 static void gdb_stat(CPUState *cs, gdb_syscall_complete_cb complete, - uint64_t fname, uint64_t fname_len, - uint64_t addr) + vaddr fname, uint64_t fname_len, + vaddr addr) { int len =3D validate_strlen(cs, fname, fname_len); if (len < 0) { @@ -194,11 +194,11 @@ static void gdb_stat(CPUState *cs, gdb_syscall_comple= te_cb complete, } =20 gdb_do_syscall(complete, "stat,%s,%lx", - (uint64_t)fname, (uint32_t)len, (uint64_t)addr); + (vaddr)fname, (uint32_t)len, (vaddr)addr); } =20 static void gdb_remove(CPUState *cs, gdb_syscall_complete_cb complete, - uint64_t fname, uint64_t fname_len) + vaddr fname, uint64_t fname_len) { int len =3D validate_strlen(cs, fname, fname_len); if (len < 0) { @@ -206,12 +206,12 @@ static void gdb_remove(CPUState *cs, gdb_syscall_comp= lete_cb complete, return; } =20 - gdb_do_syscall(complete, "unlink,%s", (uint64_t)fname, (uint32_t)len); + gdb_do_syscall(complete, "unlink,%s", (vaddr)fname, (uint32_t)len); } =20 static void gdb_rename(CPUState *cs, gdb_syscall_complete_cb complete, - uint64_t oname, uint64_t oname_len, - uint64_t nname, uint64_t nname_len) + vaddr oname, uint64_t oname_len, + vaddr nname, uint64_t nname_len) { int olen, nlen; =20 @@ -227,12 +227,12 @@ static void gdb_rename(CPUState *cs, gdb_syscall_comp= lete_cb complete, } =20 gdb_do_syscall(complete, "rename,%s,%s", - (uint64_t)oname, (uint32_t)olen, - (uint64_t)nname, (uint32_t)nlen); + (vaddr)oname, (uint32_t)olen, + (vaddr)nname, (uint32_t)nlen); } =20 static void gdb_system(CPUState *cs, gdb_syscall_complete_cb complete, - uint64_t cmd, uint64_t cmd_len) + vaddr cmd, uint64_t cmd_len) { int len =3D validate_strlen(cs, cmd, cmd_len); if (len < 0) { @@ -240,14 +240,14 @@ static void gdb_system(CPUState *cs, gdb_syscall_comp= lete_cb complete, return; } =20 - gdb_do_syscall(complete, "system,%s", (uint64_t)cmd, (uint32_t)len); + gdb_do_syscall(complete, "system,%s", (vaddr)cmd, (uint32_t)len); } =20 static void gdb_gettimeofday(CPUState *cs, gdb_syscall_complete_cb complet= e, - uint64_t tv_addr, uint64_t tz_addr) + vaddr tv_addr, vaddr tz_addr) { gdb_do_syscall(complete, "gettimeofday,%lx,%lx", - (uint64_t)tv_addr, (uint64_t)tz_addr); + (vaddr)tv_addr, (vaddr)tz_addr); } =20 /* @@ -255,7 +255,7 @@ static void gdb_gettimeofday(CPUState *cs, gdb_syscall_= complete_cb complete, */ =20 static void host_open(CPUState *cs, gdb_syscall_complete_cb complete, - uint64_t fname, uint64_t fname_len, + vaddr fname, uint64_t fname_len, int gdb_flags, int mode) { CPUArchState *env G_GNUC_UNUSED =3D cpu_env(cs); @@ -315,7 +315,7 @@ static void host_close(CPUState *cs, gdb_syscall_comple= te_cb complete, } =20 static void host_read(CPUState *cs, gdb_syscall_complete_cb complete, - GuestFD *gf, uint64_t buf, uint64_t len) + GuestFD *gf, vaddr buf, uint64_t len) { CPUArchState *env G_GNUC_UNUSED =3D cpu_env(cs); void *ptr =3D lock_user(VERIFY_WRITE, buf, len, 0); @@ -336,7 +336,7 @@ static void host_read(CPUState *cs, gdb_syscall_complet= e_cb complete, } =20 static void host_write(CPUState *cs, gdb_syscall_complete_cb complete, - GuestFD *gf, uint64_t buf, uint64_t len) + GuestFD *gf, vaddr buf, uint64_t len) { CPUArchState *env G_GNUC_UNUSED =3D cpu_env(cs); void *ptr =3D lock_user(VERIFY_READ, buf, len, 1); @@ -394,7 +394,7 @@ static void host_flen(CPUState *cs, gdb_syscall_complet= e_cb complete, } =20 static void host_fstat(CPUState *cs, gdb_syscall_complete_cb complete, - GuestFD *gf, uint64_t addr) + GuestFD *gf, vaddr addr) { struct stat buf; int ret; @@ -409,8 +409,8 @@ static void host_fstat(CPUState *cs, gdb_syscall_comple= te_cb complete, } =20 static void host_stat(CPUState *cs, gdb_syscall_complete_cb complete, - uint64_t fname, uint64_t fname_len, - uint64_t addr) + vaddr fname, uint64_t fname_len, + vaddr addr) { CPUArchState *env G_GNUC_UNUSED =3D cpu_env(cs); struct stat buf; @@ -439,7 +439,7 @@ static void host_stat(CPUState *cs, gdb_syscall_complet= e_cb complete, } =20 static void host_remove(CPUState *cs, gdb_syscall_complete_cb complete, - uint64_t fname, uint64_t fname_len) + vaddr fname, uint64_t fname_len) { CPUArchState *env G_GNUC_UNUSED =3D cpu_env(cs); char *p; @@ -457,8 +457,8 @@ static void host_remove(CPUState *cs, gdb_syscall_compl= ete_cb complete, } =20 static void host_rename(CPUState *cs, gdb_syscall_complete_cb complete, - uint64_t oname, uint64_t oname_len, - uint64_t nname, uint64_t nname_len) + vaddr oname, uint64_t oname_len, + vaddr nname, uint64_t nname_len) { CPUArchState *env G_GNUC_UNUSED =3D cpu_env(cs); char *ostr, *nstr; @@ -483,7 +483,7 @@ static void host_rename(CPUState *cs, gdb_syscall_compl= ete_cb complete, } =20 static void host_system(CPUState *cs, gdb_syscall_complete_cb complete, - uint64_t cmd, uint64_t cmd_len) + vaddr cmd, uint64_t cmd_len) { CPUArchState *env G_GNUC_UNUSED =3D cpu_env(cs); char *p; @@ -501,7 +501,7 @@ static void host_system(CPUState *cs, gdb_syscall_compl= ete_cb complete, } =20 static void host_gettimeofday(CPUState *cs, gdb_syscall_complete_cb comple= te, - uint64_t tv_addr, uint64_t tz_addr) + vaddr tv_addr, vaddr tz_addr) { CPUArchState *env G_GNUC_UNUSED =3D cpu_env(cs); struct gdb_timeval *p; @@ -546,7 +546,7 @@ static void host_poll_one(CPUState *cs, gdb_syscall_com= plete_cb complete, */ =20 static void staticfile_read(CPUState *cs, gdb_syscall_complete_cb complete, - GuestFD *gf, uint64_t buf, uint64_t len) + GuestFD *gf, vaddr buf, uint64_t len) { CPUArchState *env G_GNUC_UNUSED =3D cpu_env(cs); uint64_t rest =3D gf->staticfile.len - gf->staticfile.off; @@ -604,7 +604,7 @@ static void staticfile_flen(CPUState *cs, gdb_syscall_c= omplete_cb complete, */ =20 static void console_read(CPUState *cs, gdb_syscall_complete_cb complete, - GuestFD *gf, uint64_t buf, uint64_t len) + GuestFD *gf, vaddr buf, uint64_t len) { CPUArchState *env G_GNUC_UNUSED =3D cpu_env(cs); char *ptr; @@ -621,7 +621,7 @@ static void console_read(CPUState *cs, gdb_syscall_comp= lete_cb complete, } =20 static void console_write(CPUState *cs, gdb_syscall_complete_cb complete, - GuestFD *gf, uint64_t buf, uint64_t len) + GuestFD *gf, vaddr buf, uint64_t len) { CPUArchState *env G_GNUC_UNUSED =3D cpu_env(cs); char *ptr =3D lock_user(VERIFY_READ, buf, len, 1); @@ -637,7 +637,7 @@ static void console_write(CPUState *cs, gdb_syscall_com= plete_cb complete, } =20 static void console_fstat(CPUState *cs, gdb_syscall_complete_cb complete, - GuestFD *gf, uint64_t addr) + GuestFD *gf, vaddr addr) { static const struct stat tty_buf =3D { .st_mode =3D 020666, /* S_IFCHR, ugo+rw */ --=20 2.47.3 From nobody Sun Sep 28 15:30:20 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1758534216; cv=none; d=zohomail.com; s=zohoarc; b=d8wMSM+unIbrpwP1rNJ9U3jiecXbnQVnHb7eXNZ/Y14zc80D+0pdF5Jsxafv8NnNE7VQeuzF5iBJUYHPXv8ynhFxBD5w2umVTflNYzy7UUAQZyamcLoY7DaEkDJu3hW1fQA5tNrbyZBfD8X39XuvtI1Pv2tG199sgMZCEzbu2mA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1758534216; 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=JSjEVFuFYZn/BZ8ABzOt09gLvPSy+iL1wdNE+B6ErNg=; b=iH9uAMcD5vmjfZ5Ibs8akaInCdqylclrKvBOsZjMTQBOtMZuDjKEroWIGtH0RsMSxN1lfOsQRG+mjJrh+ICWt7lBrdkecqMb/WeaSm/RWghYj0PDqu5H+szABg4p139xO0GU4AJkPlJXLzijKmqT3zRZIUFZ9V4rXMtZs+ciwuA= 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 1758534216333987.7506560810419; Mon, 22 Sep 2025 02:43:36 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v0d0m-0004TG-IZ; Mon, 22 Sep 2025 05:39:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v0czQ-0002F9-3d for qemu-devel@nongnu.org; Mon, 22 Sep 2025 05:37:45 -0400 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1v0cz5-0000ea-Pt for qemu-devel@nongnu.org; Mon, 22 Sep 2025 05:37:42 -0400 Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-45f2acb5f42so31194875e9.1 for ; Mon, 22 Sep 2025 02:37:23 -0700 (PDT) Received: from draig.lan ([185.126.160.19]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-46dd9a69466sm16427455e9.1.2025.09.22.02.37.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Sep 2025 02:37:17 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 1F7A85F9ED; Mon, 22 Sep 2025 10:37:12 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1758533841; x=1759138641; 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=JSjEVFuFYZn/BZ8ABzOt09gLvPSy+iL1wdNE+B6ErNg=; b=JgCidCzgdXmVUdaQuWvNEcmtRszb8B8VS+54uis+3QYTcfYWZQcy51wt32xAGHKdqj SKKZc0aBJJuceIgB/5CToRrpWVVl2kHxv0h80tOdpbTbTcG6V5dZKJnjzivLjyhbbWb3 LbCmR55NrUv4kzIjRLaQxDE0aPf+1BK95bbt5vv6LeTvjKRoBfNrsG4YxFstSm4CZcH+ MXnmT0d9WJ6oEDvgAOlXlTHNLdlDir9fjx+UsyjdOAyF1hRZpzgTnBbaNqD3O63CyXqz AqLTZjASadKrsIwwK8DFQimrKJaVY5bob6GO4phE481AMMCesD2DvNXXdy0K6hnBY1Cm pCgg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1758533841; x=1759138641; 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=JSjEVFuFYZn/BZ8ABzOt09gLvPSy+iL1wdNE+B6ErNg=; b=MUwDBBbH1f3z24rQ2kbt5mM8YrQBNja7/eZSUyckTadIx/6Vps+CYXWi9Lh0N96Vft YrC+RvjKGep97PV+AstOXqt26Lh6A7C6/AkhbXPkk9cc1LNFa46MS90j2yT/IyjbvwDZ f+EDcWScUVjs+OLRGjmvX1ZXGUa05GcL8l4yFK1Z5xbyJYRyKJSCCjiv83NCr1/gt/UZ Oa5YAAzeiCA3e7eO/LmzNHUjJOKQtHmjXBpaLfCiIPj6hL4dB5Ne08iEpvIe/06uKoBc IMDJ4lxpAXOjjZ1qY/A0zm0owbKy85uUGMV3ouXiiqIPp6agHyuQAUzkrpHLvcLVnwbV dwKA== X-Gm-Message-State: AOJu0Yyh3M73+ElxSdd40Ip+6EhBx4/r7IFEKFszxvM4BX5j4sLx9MVv fcepf1KquxHHHVmI+aQ3vwCrU60cXOoMtoJrWrwnHS303TsMaz7DKuYEx1aEyNBRbS8= X-Gm-Gg: ASbGncs367UbV8KF2B+RZrEffBhNv3p4PTHuCU7vMY74RRHyJSPLRfR5XGOQKwguW+B z2Rx2u4hRlTjaUCdHPuHuOx+DvNSQjBYPjwD02nXagG2XyCZfBuMZnhacicn960BxeW1x1E/vYD NGyQyPxHHTJ9Z7iQFpQ9IHHgWonehuHophzYS/x2+7XRir8SILkyKzRswoSpy6ThCv/WrFWyYnm O+pC8gtx4M/ms/QAeXuI8/MxMq13BPIv7AvmXtca6hEcU84L5jghpwsVDGF3XdWePPU6wK711pm XqSUgfxet69UCRb4CzP2yfEwsQjw4r1MQSvs9NiEDarycX9b+t8gCOYYnSHEm0lE1yiCoe9w369 iUKJno4wXAEeGuBt08Un7fpQ= X-Google-Smtp-Source: AGHT+IHdc+761hu/BrQJYWwM4R1nbzRtw7bblEZsdThCt7pG6nhnQJr5UG8J581AlrZgKbb36QCFzw== X-Received: by 2002:a05:600c:b99:b0:45d:d79c:7503 with SMTP id 5b1f17b1804b1-467aaefd912mr119068195e9.12.1758533840883; Mon, 22 Sep 2025 02:37:20 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Palmer Dabbelt , Alexandre Iooss , Mahmoud Mandour , qemu-riscv@nongnu.org, Daniel Henrique Barboza , Thomas Huth , Peter Maydell , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Alistair Francis , qemu-arm@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Weiwei Li , Pierrick Bouvier , Liu Zhiwei , Richard Henderson Subject: [PATCH 06/25] semihosting/guestfd: compile once for system/user Date: Mon, 22 Sep 2025 10:36:51 +0100 Message-ID: <20250922093711.2768983-7-alex.bennee@linaro.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20250922093711.2768983-1-alex.bennee@linaro.org> References: <20250922093711.2768983-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: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, DKIM_INVALID=0.1, DKIM_SIGNED=0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1758534218483116600 From: Pierrick Bouvier We move relevant code to semihosting/arm-compat-semi.c, and add functions to query CONFIG_ARM_COMPATIBLE_SEMIHOSTING at runtime. Reviewed-by: Richard Henderson Signed-off-by: Pierrick Bouvier Message-ID: <20250822150058.18692-4-pierrick.bouvier@linaro.org> Signed-off-by: Alex Benn=C3=A9e --- include/semihosting/guestfd.h | 7 ------- include/semihosting/semihost.h | 2 ++ semihosting/arm-compat-semi-stub.c | 19 +++++++++++++++++++ semihosting/arm-compat-semi.c | 26 ++++++++++++++++++++++++++ semihosting/guestfd.c | 26 +++++--------------------- semihosting/meson.build | 11 ++++++----- 6 files changed, 58 insertions(+), 33 deletions(-) create mode 100644 semihosting/arm-compat-semi-stub.c diff --git a/include/semihosting/guestfd.h b/include/semihosting/guestfd.h index 3d426fedab3..a7ea1041ea0 100644 --- a/include/semihosting/guestfd.h +++ b/include/semihosting/guestfd.h @@ -35,13 +35,6 @@ typedef struct GuestFD { }; } GuestFD; =20 -/* - * For ARM semihosting, we have a separate structure for routing - * data for the console which is outside the guest fd address space. - */ -extern GuestFD console_in_gf; -extern GuestFD console_out_gf; - /** * alloc_guestfd: * diff --git a/include/semihosting/semihost.h b/include/semihosting/semihost.h index b03e6375787..231dc890395 100644 --- a/include/semihosting/semihost.h +++ b/include/semihosting/semihost.h @@ -33,6 +33,8 @@ typedef enum SemihostingTarget { * Return true if guest code is allowed to make semihosting calls. */ bool semihosting_enabled(bool is_user); +bool semihosting_arm_compatible(void); +void semihosting_arm_compatible_init(void); =20 SemihostingTarget semihosting_get_target(void); const char *semihosting_get_arg(int i); diff --git a/semihosting/arm-compat-semi-stub.c b/semihosting/arm-compat-se= mi-stub.c new file mode 100644 index 00000000000..bfa3681e267 --- /dev/null +++ b/semihosting/arm-compat-semi-stub.c @@ -0,0 +1,19 @@ +/* + * Stubs for platforms different from ARM + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include "qemu/osdep.h" +#include "semihosting/semihost.h" +#include + +bool semihosting_arm_compatible(void) +{ + return false; +} + +void semihosting_arm_compatible_init(void) +{ + g_assert_not_reached(); +} diff --git a/semihosting/arm-compat-semi.c b/semihosting/arm-compat-semi.c index 64ddc749bf8..a239cfc5a9d 100644 --- a/semihosting/arm-compat-semi.c +++ b/semihosting/arm-compat-semi.c @@ -101,6 +101,13 @@ static int gdb_open_modeflags[12] =3D { GDB_O_RDWR | GDB_O_CREAT | GDB_O_APPEND, }; =20 +/* + * For ARM semihosting, we have a separate structure for routing + * data for the console which is outside the guest fd address space. + */ +static GuestFD console_in_gf; +static GuestFD console_out_gf; + #ifndef CONFIG_USER_ONLY =20 /** @@ -353,6 +360,25 @@ static const uint8_t featurefile_data[] =3D { SH_EXT_EXIT_EXTENDED | SH_EXT_STDOUT_STDERR, /* Feature byte 0 */ }; =20 +bool semihosting_arm_compatible(void) +{ + return true; +} + +void semihosting_arm_compatible_init(void) +{ + /* For ARM-compat, the console is in a separate namespace. */ + if (use_gdb_syscalls()) { + console_in_gf.type =3D GuestFDGDB; + console_in_gf.hostfd =3D 0; + console_out_gf.type =3D GuestFDGDB; + console_out_gf.hostfd =3D 2; + } else { + console_in_gf.type =3D GuestFDConsole; + console_out_gf.type =3D GuestFDConsole; + } +} + /* * Do a semihosting call. * diff --git a/semihosting/guestfd.c b/semihosting/guestfd.c index d3241434c51..e8f236c690c 100644 --- a/semihosting/guestfd.c +++ b/semihosting/guestfd.c @@ -12,35 +12,20 @@ #include "gdbstub/syscalls.h" #include "semihosting/semihost.h" #include "semihosting/guestfd.h" -#ifndef CONFIG_USER_ONLY -#include CONFIG_DEVICES -#endif =20 static GArray *guestfd_array; =20 -#ifdef CONFIG_ARM_COMPATIBLE_SEMIHOSTING -GuestFD console_in_gf; -GuestFD console_out_gf; -#endif - void qemu_semihosting_guestfd_init(void) { /* New entries zero-initialized, i.e. type GuestFDUnused */ guestfd_array =3D g_array_new(FALSE, TRUE, sizeof(GuestFD)); =20 -#ifdef CONFIG_ARM_COMPATIBLE_SEMIHOSTING - /* For ARM-compat, the console is in a separate namespace. */ - if (use_gdb_syscalls()) { - console_in_gf.type =3D GuestFDGDB; - console_in_gf.hostfd =3D 0; - console_out_gf.type =3D GuestFDGDB; - console_out_gf.hostfd =3D 2; - } else { - console_in_gf.type =3D GuestFDConsole; - console_out_gf.type =3D GuestFDConsole; + if (semihosting_arm_compatible()) { + semihosting_arm_compatible_init(); + return; } -#else - /* Otherwise, the stdio file descriptors apply. */ + + /* Out of ARM, the stdio file descriptors apply. */ guestfd_array =3D g_array_set_size(guestfd_array, 3); #ifndef CONFIG_USER_ONLY if (!use_gdb_syscalls()) { @@ -54,7 +39,6 @@ void qemu_semihosting_guestfd_init(void) associate_guestfd(0, 0); associate_guestfd(1, 1); associate_guestfd(2, 2); -#endif } =20 /* diff --git a/semihosting/meson.build b/semihosting/meson.build index 77200a7f27b..bb0db323937 100644 --- a/semihosting/meson.build +++ b/semihosting/meson.build @@ -1,17 +1,18 @@ -specific_ss.add(when: 'CONFIG_SEMIHOSTING', if_true: files( - 'guestfd.c', -)) - common_ss.add(when: 'CONFIG_SEMIHOSTING', if_false: files('stubs-all.c')) -user_ss.add(when: 'CONFIG_SEMIHOSTING', if_true: files('user.c')) +user_ss.add(when: 'CONFIG_SEMIHOSTING', if_true: files( + 'user.c', + 'guestfd.c')) system_ss.add(when: 'CONFIG_SEMIHOSTING', if_true: files( 'config.c', 'console.c', + 'guestfd.c', 'uaccess.c', 'syscalls.c', ), if_false: files( 'stubs-system.c', )) +system_ss.add(when: 'CONFIG_ARM_COMPATIBLE_SEMIHOSTING', + if_false: files('arm-compat-semi-stub.c')) =20 specific_ss.add(when: ['CONFIG_SEMIHOSTING', 'CONFIG_USER_ONLY'], if_true: files('syscalls.c')) --=20 2.47.3 From nobody Sun Sep 28 15:30:20 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1758534070; cv=none; d=zohomail.com; s=zohoarc; b=gzJQ+nmP53RZ4Pd2c3+vzztoqit6dArZf9AhZWddpapGZzvCv+BaEKW6TuyyjSpLTfn80agz7j/DCCx/hHdSZwstgEVfBD2L6Y7wsR9Hu/btDTf61elmBeRKjJpcXWtonuZv6jKYd6i2qPKN9R5hdwb0yOMSgzYB9u989d3uvPo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1758534070; 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=1iOqbIE2K4YSn24nejTWVSAedyV/jyzH66EOGDnjiAU=; b=MGxSmQS70M9sgWSOx11zkqYiCbt6SqgaNsGYdJsgj+IWilk+KO1PPq8mQ/pNom8hYpvqqqN7UX/0qpMTrewQh9HY/wRNNxnkPd86tFhSJE2yYYxBJyO+IK1GTDQfCwoSZ//mUUeLPZoN6hX0Fjf7xq5t1CJuhM31X9C6FW5c4P4= 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 17585340709501023.4416713873923; Mon, 22 Sep 2025 02:41:10 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v0d0t-0004mN-DD; Mon, 22 Sep 2025 05:39:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v0czl-0002Ug-Ua for qemu-devel@nongnu.org; Mon, 22 Sep 2025 05:38:13 -0400 Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1v0czC-0000fe-9r for qemu-devel@nongnu.org; Mon, 22 Sep 2025 05:38:04 -0400 Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-46cf7bbfda8so5847875e9.2 for ; Mon, 22 Sep 2025 02:37:26 -0700 (PDT) Received: from draig.lan ([185.126.160.19]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4613d42bee6sm241384845e9.15.2025.09.22.02.37.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Sep 2025 02:37:17 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 3896B5F9F7; Mon, 22 Sep 2025 10:37:12 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1758533844; x=1759138644; 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=1iOqbIE2K4YSn24nejTWVSAedyV/jyzH66EOGDnjiAU=; b=C6RdRDhhZjUh8/0q/UifG+yJmpMyFxPToMKDssfXrAcXBu4qzMVaGr7xqNAwuQ1L57 6iBBcD3xluqjxxgyr1uGFa5OyNd48yNCYpNRNUZezseNELGVCRknGpPt8Re3KChzpIfa 81VCqpkt5dIyTDKB0/APHBpmKyh+kIw9ccfav4PNpETa/MvOWcBHl18t5H05SYi2Hgv7 LED7dY+Q094d74kG8vdccHJk+JiMpPlhfkv4gBGwlACDvoEEvpeOcVkw2E33NDcbBbGO /w2Kz+rkTQ+g8XdNKBuBC0t6HVtpSi5Ee4ll7CvRCZeKAhCh/S7GipQSmRjnL7Jffh7p mBVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1758533844; x=1759138644; 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=1iOqbIE2K4YSn24nejTWVSAedyV/jyzH66EOGDnjiAU=; b=Y2m1uLtYcT+e5wrJW0IydnSHUgH/07odTd6jvDpaIC9MROIjAG7Rn5U4aABk4l2oPo TN93YWazVSvzFx6GhbzjBWJ8/hu7VtLX4DtVYuISdDVHeJT9RaqcJj25Pt9o4kNXygIa I4OpGHshdVyf903C0ntn8l5r7Wugh2q2oeAEG3oCY/pG80FH+ijwKhGL0PIUFrzn8xo5 1PExWPWZGJQd6pqBEg0HcDEnbe1TISYnU46wJ7qQvjY7BEzO67++2/7l28rrbfSHq22u /FHC5M4kfHOhrpzCNwqiIhiB9KviPPFRyqR5pGk2CL/P34mRsKncLOpXh8abL/JJQV1S rgfA== X-Gm-Message-State: AOJu0YyIAZexivSiL9Jg6aqwAy0i7GBui4OiC5Ch+xLAIFhSjdxYDg8I ZbieMa747tlG4CFlxZPpEweo+Cuzn5ci8JkJ0vPvm7dNkpYJyv4hQHrCOkRzXGKlZb0= X-Gm-Gg: ASbGncsYktG+chIARJBOMWqsot7Ku8ulR57FajvrN3Wp7fa3paUWy5DTYwNqCKY9IId dQbbhQJsS0hsZp6sOi5AhCPOZh7v+5t3y9YRXKwWKCzQSZQV6+HbS7Phfa3ocrawvOKVfm090zg x58R33Q/gYO+KpBozVTQKP5DZSRe+G2E8yavfo8g9BDjZ8N36Jr/5Si40xjs0Po1aDIqaDocBsb MgTNYws1iD80x+Pm9zjlLnKLKUFej7Wv94TnbZiLrXrL7F9aqHWTwitT5VR92pUvLvTVpTM4m/l m9jT7anVjSCQ8fLwXiVSSTUwcgzl10XhBYmFXg6G5RLDiiZFHe/NHlTo4d5Ialzst0x+59rHgg0 /bCUNZ9W6zYpO9rpJSl6vi7I= X-Google-Smtp-Source: AGHT+IFkZwvxSmVDmxgSasMbzlLFLbhVkG8wbrFW9ZSpxWsVrcMe5RBVXVH9Wp5gPkJf08/UW7+0Xw== X-Received: by 2002:a05:600c:3b11:b0:45d:d5fb:185b with SMTP id 5b1f17b1804b1-467eaf51178mr99398715e9.20.1758533844252; Mon, 22 Sep 2025 02:37:24 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Palmer Dabbelt , Alexandre Iooss , Mahmoud Mandour , qemu-riscv@nongnu.org, Daniel Henrique Barboza , Thomas Huth , Peter Maydell , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Alistair Francis , qemu-arm@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Weiwei Li , Pierrick Bouvier , Liu Zhiwei , Richard Henderson Subject: [PATCH 07/25] semihosting/arm-compat-semi: change common_semi_sys_exit_extended Date: Mon, 22 Sep 2025 10:36:52 +0100 Message-ID: <20250922093711.2768983-8-alex.bennee@linaro.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20250922093711.2768983-1-alex.bennee@linaro.org> References: <20250922093711.2768983-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 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: 1758534072546116600 From: Pierrick Bouvier We now check only is sys_exit is extended. This allows to break dependency to TARGET_SYS_EXIT_EXTENDED which will not be available anymore from this code. Reviewed-by: Richard Henderson Signed-off-by: Pierrick Bouvier Message-ID: <20250822150058.18692-5-pierrick.bouvier@linaro.org> Signed-off-by: Alex Benn=C3=A9e --- target/arm/common-semi-target.h | 4 ++-- target/riscv/common-semi-target.h | 4 ++-- semihosting/arm-compat-semi.c | 3 ++- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/target/arm/common-semi-target.h b/target/arm/common-semi-targe= t.h index da51f2d7f54..7bb442f24ca 100644 --- a/target/arm/common-semi-target.h +++ b/target/arm/common-semi-target.h @@ -34,9 +34,9 @@ static inline void common_semi_set_ret(CPUState *cs, targ= et_ulong ret) } } =20 -static inline bool common_semi_sys_exit_extended(CPUState *cs, int nr) +static inline bool common_semi_sys_exit_is_extended(CPUState *cs) { - return nr =3D=3D TARGET_SYS_EXIT_EXTENDED || is_a64(cpu_env(cs)); + return is_a64(cpu_env(cs)); } =20 static inline bool is_64bit_semihosting(CPUArchState *env) diff --git a/target/riscv/common-semi-target.h b/target/riscv/common-semi-t= arget.h index 7c8a59e0cc3..ba40e794dcc 100644 --- a/target/riscv/common-semi-target.h +++ b/target/riscv/common-semi-target.h @@ -25,9 +25,9 @@ static inline void common_semi_set_ret(CPUState *cs, targ= et_ulong ret) env->gpr[xA0] =3D ret; } =20 -static inline bool common_semi_sys_exit_extended(CPUState *cs, int nr) +static inline bool common_semi_sys_exit_is_extended(CPUState *cs) { - return (nr =3D=3D TARGET_SYS_EXIT_EXTENDED || sizeof(target_ulong) =3D= =3D 8); + return sizeof(target_ulong) =3D=3D 8; } =20 static inline bool is_64bit_semihosting(CPUArchState *env) diff --git a/semihosting/arm-compat-semi.c b/semihosting/arm-compat-semi.c index a239cfc5a9d..26263a06b7a 100644 --- a/semihosting/arm-compat-semi.c +++ b/semihosting/arm-compat-semi.c @@ -755,7 +755,8 @@ void do_common_semihosting(CPUState *cs) { uint32_t ret; =20 - if (common_semi_sys_exit_extended(cs, nr)) { + if (nr =3D=3D TARGET_SYS_EXIT_EXTENDED || + common_semi_sys_exit_is_extended(cs)) { /* * The A64 version of SYS_EXIT takes a parameter block, * so the application-exit type can return a subcode which --=20 2.47.3 From nobody Sun Sep 28 15:30:20 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1758533984; cv=none; d=zohomail.com; s=zohoarc; b=f6eaCRDjCbsYKna3GRw/Cxzl+nOy4Y30sUKRdJ5Zx2L0u6jvyV0n6n1O7Db0ZNNyFTknjqc+iXGPaV0a2ucWr2g9vRUazCHc0EV3/GZUzpZAfvBWNNqnDe6GoLBd0ft6VICa5vv4unu6pRMse3Cq5rgeHbzaEhubKcm492ORbOQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1758533984; 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=zR6vtj5zFWpC3fy91sWeOSp7fMJNhRDmtEpW8GYt8DQ=; b=PPAw4KHegQT8FNmm20nGBKpHXFxh8efRvQQMfjQ5qLgoJvfNuN0skfs9W205Tt1yVe+3V+33VxkdP8w+runFXPwHsT81eH4OovHdjprMtLTNEVVHP7OEHCUxu5GUYl7iLBscidNiK3FuiEUwSQ6H46VWTrZx2IfXuVg/J2CRuQY= 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 1758533984283974.3933287871297; Mon, 22 Sep 2025 02:39:44 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v0d0b-0003S0-Fe; Mon, 22 Sep 2025 05:38:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v0czQ-0002Gy-Dr for qemu-devel@nongnu.org; Mon, 22 Sep 2025 05:37:45 -0400 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1v0cz6-0000dg-1I for qemu-devel@nongnu.org; Mon, 22 Sep 2025 05:37:44 -0400 Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-46c889b310dso10739095e9.0 for ; Mon, 22 Sep 2025 02:37:21 -0700 (PDT) Received: from draig.lan ([185.126.160.19]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-46dd9a69466sm16427965e9.1.2025.09.22.02.37.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Sep 2025 02:37:17 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 4F8405F9F9; Mon, 22 Sep 2025 10:37:12 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1758533839; x=1759138639; 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=zR6vtj5zFWpC3fy91sWeOSp7fMJNhRDmtEpW8GYt8DQ=; b=GZLFsd5q2hzwMjYeo7a5zxhZsrVKTp864ytAEUBIKusigWiVay7X72iliE09KuKQkc Td+hxfuhZM60yccXNCpNecxlq/KB23CL6OJnPGgp0h72wo1WFLcMrcBzdrjd19u4vnAG 2XO6uQ0YoO9Ms4ILfvQp3ConFf6qf/Kw5BYHZIqri1/XEFfQ4VwIBN3gh2QXptr3BddD HqZv9xnvJTHoM83HcfjLKGuOuF8go/RmsibPHqTJ2eUzuegW/ZK2zppVvOCueFez+l1K 8bmtzDfG03DRc8887V8Vl90RceIuKq2IKVmLJT3kFYWgc3Cq8v2K7pidzjXg5jE4zAkf E/fQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1758533839; x=1759138639; 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=zR6vtj5zFWpC3fy91sWeOSp7fMJNhRDmtEpW8GYt8DQ=; b=e1chgzU61eWCSGmxaELK/zDA4shXBZJHKr15s4rRQB09QVy02dPk3f7t8OS/r3vbE+ TVF9FM0VnCJAd35l3qtiIVWm8pjzfsuAE7u2L1u4z9OrQIVSfpV0rQHQcbQ/EXkE4WEh zJ+GyoqMQnR8CpuYSzFfv7JPa0eCj6N277fQ+/mKf3ylx5L3xqkChcWFhvU/4xsoH3jf EDuZW0ReKECy79AyJUs3CRUkY3Qz5nBWvaF7QwvenIeFD+erFJva8BVHUA36WdTb6mo0 ScTcfDb8H3WPq0YggbaM6P7xHFe8VRslPnl+SYKsRStVe9mE81lSgoyxg9iNNwQMUbin jzPw== X-Gm-Message-State: AOJu0YyutDWBHGPfEzw7BeU+3G3lI+3krFXReCyaxJMYer+MsnyoaNEZ lI+NWEPCek4/pjGFF8l++SNAXvI4lvG2BHFvVKkVzap/8XncE/yldS0D4ryrJrku2AU= X-Gm-Gg: ASbGnctbzI0LYQo9dgFxzGr3KQF2MZUkhrvQLt07U6b2zZKWPPiGU1YRXOb5u/tOIy5 5WsE/IUQWYWciEGkxfcVOyDXlWO09UpgctrAD+WvPXtHGeHrjaAluLkBG21eQJf/OU8s//QQKt3 MuZ3r1WZ1Ex2NVB+7zf9Q6/Bv1P0XmFtWKm7EbpojniZi0EUVAlPvvmadsWzjAC2KAiAFrftTha thPxEM9Lp5HW3Du6MhUWUj8+XjEVv6SXzfJT9oWdrFjst3eapoldf0jwNy25qJwHaPTongwWVnI CKK/ENWmtWMcrkJ+MmbrmPC5X6Jfj/A0qwFwY+MhsVEjlQSgPsxOFwHKp8pGwtYMznTSCS+LrX+ V052oS6AFL+OPfWI4WSDkM/E= X-Google-Smtp-Source: AGHT+IEJT7U7eTozaOeVqApP8mTlpbGFsV3G/6F0gpdjxUhOb9NmKsPTJDmEH9mCywmoMo5fm4DQJQ== X-Received: by 2002:a05:600c:5246:b0:45d:98be:eea6 with SMTP id 5b1f17b1804b1-467a72a66b4mr113831185e9.3.1758533838693; Mon, 22 Sep 2025 02:37:18 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Palmer Dabbelt , Alexandre Iooss , Mahmoud Mandour , qemu-riscv@nongnu.org, Daniel Henrique Barboza , Thomas Huth , Peter Maydell , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Alistair Francis , qemu-arm@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Weiwei Li , Pierrick Bouvier , Liu Zhiwei , Richard Henderson Subject: [PATCH 08/25] target/riscv/common-semi-target: remove sizeof(target_ulong) Date: Mon, 22 Sep 2025 10:36:53 +0100 Message-ID: <20250922093711.2768983-9-alex.bennee@linaro.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20250922093711.2768983-1-alex.bennee@linaro.org> References: <20250922093711.2768983-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_PASS=-0.001, 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: 1758533985454116600 From: Pierrick Bouvier Only riscv64 extends SYS_EXIT, similar to aarch64. Reviewed-by: Richard Henderson Signed-off-by: Pierrick Bouvier Message-ID: <20250822150058.18692-6-pierrick.bouvier@linaro.org> Signed-off-by: Alex Benn=C3=A9e --- target/riscv/common-semi-target.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/target/riscv/common-semi-target.h b/target/riscv/common-semi-t= arget.h index ba40e794dcc..7e6ea8da02c 100644 --- a/target/riscv/common-semi-target.h +++ b/target/riscv/common-semi-target.h @@ -25,14 +25,14 @@ static inline void common_semi_set_ret(CPUState *cs, ta= rget_ulong ret) env->gpr[xA0] =3D ret; } =20 -static inline bool common_semi_sys_exit_is_extended(CPUState *cs) +static inline bool is_64bit_semihosting(CPUArchState *env) { - return sizeof(target_ulong) =3D=3D 8; + return riscv_cpu_mxl(env) !=3D MXL_RV32; } =20 -static inline bool is_64bit_semihosting(CPUArchState *env) +static inline bool common_semi_sys_exit_is_extended(CPUState *cs) { - return riscv_cpu_mxl(env) !=3D MXL_RV32; + return is_64bit_semihosting(cpu_env(cs)); } =20 static inline target_ulong common_semi_stack_bottom(CPUState *cs) --=20 2.47.3 From nobody Sun Sep 28 15:30:20 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1758534079; cv=none; d=zohomail.com; s=zohoarc; b=hPc+w8MgFcb/MK6aHwBh7crwEOkFHx8VA419JCKA1txYPyTelVr+7QRMBMSlMS0unAVW6vQOqg0vvmCTMb46LKzhmuRQWSM0MogrEkrpx05STzBdlxRoByqNssqNYXTarZiG20mwsRJtAELOQ4YahYzezOCqrcNL4rpirTtJZ74= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1758534079; 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=rN+UABDX33GElLhpMxpOfn/bxSt0jF+QLakS0yUkPiM=; b=REoHUZ/fsdBz3TGTRv+ksJUlwHZuwXPoBq1nc70f4epfnfsY/AwU+PJBzz6N5hn1k7wCTmqHPzbPKqBqDtJ6gfjhoIZ5rG43Qgs82RETUfU+1I/wzJE0LFSYZTG8gah1OOKeOCEjMFoAPTa5Gw9liBTzxkaPN+VLUKWN4G8Lpiw= 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 1758534079574604.0709054092632; Mon, 22 Sep 2025 02:41:19 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v0d0i-00047e-II; Mon, 22 Sep 2025 05:39:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v0czW-0002Oe-3M for qemu-devel@nongnu.org; Mon, 22 Sep 2025 05:37:51 -0400 Received: from mail-wr1-x435.google.com ([2a00:1450:4864:20::435]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1v0cz8-0000f3-LB for qemu-devel@nongnu.org; Mon, 22 Sep 2025 05:37:49 -0400 Received: by mail-wr1-x435.google.com with SMTP id ffacd0b85a97d-3eebc513678so2628889f8f.1 for ; Mon, 22 Sep 2025 02:37:24 -0700 (PDT) Received: from draig.lan ([185.126.160.19]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3ee0fbd63a2sm19049094f8f.48.2025.09.22.02.37.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Sep 2025 02:37:17 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 683855F9FF; Mon, 22 Sep 2025 10:37:12 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1758533842; x=1759138642; 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=rN+UABDX33GElLhpMxpOfn/bxSt0jF+QLakS0yUkPiM=; b=csUCUzthCrfiTPGLeshqpcGSNkBzKLAskM6fghiccJrFkm/2d12UAN/TKuD+6FfmAE wGBQIpvZIbLrlnzSIpS29OvFn0SAlndx1Pu3sl3MpvfR7ZryuIAhk41MOWo6++snSVm2 cG0/dWlkaWNYo3/ta0Ys5aF3w4Q8UmGHgrVq+VA2Zhft+fF3P38nt1APUf/jhXnsO+rG 1Sd3lpL7ld95KphkXHr8OTNmRULKbBPzc0J2ALIvQ5UHB80dAay1hEalskXrmeL5RwH/ FxGE1ClHbFBCmRJQUfTC6caba333PcbXJrgeOv/VMXMWR3zMQToMmotX65+VSQPzhwUa fAkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1758533842; x=1759138642; 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=rN+UABDX33GElLhpMxpOfn/bxSt0jF+QLakS0yUkPiM=; b=v2jDiCSlZfdGULNXXRMDeknQlCiCfEmqicwCKfyvYGKoMTh8t6g63oQWwIZsjof6FL GvV6UTifnHvw4ciFhbxgkHDLE9RU3z0QjPTXkdVVGAOW9sI1+BL/7oPU+0cZhD9MsU0i YeCJeKO+2JE3LVMBjOKH8AGZ5zRL4JsGcZDNXPw+BNJN7PvTG3d9m6fLwwwN1KPSGAId SYGYbty6fvgjPJZ503l322P82GefIZOx9WQeZyZm4wCMSZi8zzS0hfzeZ7cNmf4YA+sr L5adz1dmLfuwAB2lVzLkCA1S2k/PLim2KvSVF7VEP3y1MR2fsITBsJtY6PY0/zGlF56o KoPA== X-Gm-Message-State: AOJu0YxLCST3YJZX8l2kjFapCJcPLNt2X4yanNBbRcfiGnkYBmrLj+ul U5tFJZf+5CkXuqc3TvTVAEUUQ51ivPk91dCvqMhtL2XleKz3k0yvExhs52rioTzZbDI= X-Gm-Gg: ASbGncvil6R2JGHr69RNO6vhvTSVU2L7sw0zNN23ltvQ3jEU/E9pRmsHAJk2CVS5Ra/ MPvtqkZ9hANJL7i0wCaUK4HVOW+HJH2xkXiuLPD4bH0cIP/nv6RL772Z+1dN0zeHuT3QQOJDLzV jEOGW17uXt7nfgEsKrTk1+yMdWachw+mgBEkTxZ0qs/JoN+hSiPDYvA5z0YxvQc5FJ5/ut9E+qT vidEoKhGTDB40yARtHnzg57TVoovJdCUrGN6/GUQpxypax03nb3+RchkfTft3SxlRqbH+FThzEv dW5ClB8jfuRFUetKN7cXYh5faMJoWLX0HpB6ztUToZ9ZQNcZobHN1wgn86Oc6YwE12YRgMgJUyb M5oyVhN9bf3sqmptFCgKo5yw= X-Google-Smtp-Source: AGHT+IGXplVmD3OLqQHoKMQjJiyf0VDSnMaQcgJSVKAaJgaw9ilpZyoJrTJgqViPJpdsOBDUn8fHSA== X-Received: by 2002:a05:6000:22c7:b0:3eb:df84:62e with SMTP id ffacd0b85a97d-3ee7c5535d9mr10926109f8f.3.1758533842377; Mon, 22 Sep 2025 02:37:22 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Palmer Dabbelt , Alexandre Iooss , Mahmoud Mandour , qemu-riscv@nongnu.org, Daniel Henrique Barboza , Thomas Huth , Peter Maydell , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Alistair Francis , qemu-arm@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Weiwei Li , Pierrick Bouvier , Liu Zhiwei , Richard Henderson Subject: [PATCH 09/25] target/{arm, riscv}/common-semi-target: eradicate target_ulong Date: Mon, 22 Sep 2025 10:36:54 +0100 Message-ID: <20250922093711.2768983-10-alex.bennee@linaro.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20250922093711.2768983-1-alex.bennee@linaro.org> References: <20250922093711.2768983-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::435; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x435.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=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: 1758534080527116600 From: Pierrick Bouvier We replace mechanically with uint64_t. There is no semantic change, and allows us to extract a proper API from this set of functions. Reviewed-by: Richard Henderson Signed-off-by: Pierrick Bouvier Message-ID: <20250822150058.18692-7-pierrick.bouvier@linaro.org> Signed-off-by: Alex Benn=C3=A9e --- target/arm/common-semi-target.h | 6 +++--- target/riscv/common-semi-target.h | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/target/arm/common-semi-target.h b/target/arm/common-semi-targe= t.h index 7bb442f24ca..6775a270aaa 100644 --- a/target/arm/common-semi-target.h +++ b/target/arm/common-semi-target.h @@ -12,7 +12,7 @@ =20 #include "target/arm/cpu-qom.h" =20 -static inline target_ulong common_semi_arg(CPUState *cs, int argno) +static inline uint64_t common_semi_arg(CPUState *cs, int argno) { ARMCPU *cpu =3D ARM_CPU(cs); CPUARMState *env =3D &cpu->env; @@ -23,7 +23,7 @@ static inline target_ulong common_semi_arg(CPUState *cs, = int argno) } } =20 -static inline void common_semi_set_ret(CPUState *cs, target_ulong ret) +static inline void common_semi_set_ret(CPUState *cs, uint64_t ret) { ARMCPU *cpu =3D ARM_CPU(cs); CPUARMState *env =3D &cpu->env; @@ -44,7 +44,7 @@ static inline bool is_64bit_semihosting(CPUArchState *env) return is_a64(env); } =20 -static inline target_ulong common_semi_stack_bottom(CPUState *cs) +static inline uint64_t common_semi_stack_bottom(CPUState *cs) { ARMCPU *cpu =3D ARM_CPU(cs); CPUARMState *env =3D &cpu->env; diff --git a/target/riscv/common-semi-target.h b/target/riscv/common-semi-t= arget.h index 7e6ea8da02c..663dedfdad2 100644 --- a/target/riscv/common-semi-target.h +++ b/target/riscv/common-semi-target.h @@ -11,14 +11,14 @@ #ifndef TARGET_RISCV_COMMON_SEMI_TARGET_H #define TARGET_RISCV_COMMON_SEMI_TARGET_H =20 -static inline target_ulong common_semi_arg(CPUState *cs, int argno) +static inline uint64_t common_semi_arg(CPUState *cs, int argno) { RISCVCPU *cpu =3D RISCV_CPU(cs); CPURISCVState *env =3D &cpu->env; return env->gpr[xA0 + argno]; } =20 -static inline void common_semi_set_ret(CPUState *cs, target_ulong ret) +static inline void common_semi_set_ret(CPUState *cs, uint64_t ret) { RISCVCPU *cpu =3D RISCV_CPU(cs); CPURISCVState *env =3D &cpu->env; @@ -35,7 +35,7 @@ static inline bool common_semi_sys_exit_is_extended(CPUSt= ate *cs) return is_64bit_semihosting(cpu_env(cs)); } =20 -static inline target_ulong common_semi_stack_bottom(CPUState *cs) +static inline uint64_t common_semi_stack_bottom(CPUState *cs) { RISCVCPU *cpu =3D RISCV_CPU(cs); CPURISCVState *env =3D &cpu->env; --=20 2.47.3 From nobody Sun Sep 28 15:30:20 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1758534216; cv=none; d=zohomail.com; s=zohoarc; b=IxKB6Im+A1gLSSKBdAiAzz/DvwuhC2oBBh61/bL8kBQziogUFjvHppm7UqrQHLRbuOsCXuo26bIrTe9eRiaLxUT5fGf3QWTki9gSQkkeDtT31aL326QI+Sa6PeuT0S15eLKv43IbVXuxF+piIubwXGQpyVjCfVZ0308+iqTNQVs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1758534216; 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=S68QpsHReykX2B9M0K/3nvL5iS+xqDJkvSo3if0s2aI=; b=AXHRsdaUvfI+R0NL+n+Wgkpk3wTHnmfOxwCKM1/Uq2iQ6Vvv6Ahja7i0VS2uSXtKcU+Lp45OletRC2hGXahgoahRK1d8YX89iJCr//letvVGFv73fh1jzbgsJCd15ZixK+JkXa2arBkJ4o2ZUOgGXEGXQ7J9xLWtlcABtXByO4o= 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 1758534216469984.4391691137358; Mon, 22 Sep 2025 02:43:36 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v0d0l-0004NV-02; Mon, 22 Sep 2025 05:39:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v0czN-0002Ea-QA for qemu-devel@nongnu.org; Mon, 22 Sep 2025 05:37:45 -0400 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1v0cz5-0000dw-CN for qemu-devel@nongnu.org; Mon, 22 Sep 2025 05:37:41 -0400 Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-46c889b310dso10739185e9.0 for ; Mon, 22 Sep 2025 02:37:21 -0700 (PDT) Received: from draig.lan ([185.126.160.19]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3ee073f4f3csm18495792f8f.2.2025.09.22.02.37.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Sep 2025 02:37:17 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 865CF5FA02; Mon, 22 Sep 2025 10:37:12 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1758533839; x=1759138639; 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=S68QpsHReykX2B9M0K/3nvL5iS+xqDJkvSo3if0s2aI=; b=vsHsKGJkAXOMb4sNYH1hNwGMxUzlmntw3zgbQrq0p4MOnwdFJILHSnaWPKO9edMJQC u6m+OAG4IxN4ZAilJPUc9RfTm7W9o39VIR8/6j96BypKofS7S86wtbqgP/HEnwUNDsXz U5BX885a12/B5ImRlZiaQWdSBfFyjuAI4aKDwIAS5VDeXEsbksFUkmI/25rApeeRO6+k fVZoWSaY407LUKXur30DFxupmR+AlzHp5ZO7cFRkAWAUR8V543CNcvmmgX8npG75dEob vJfmX/Oij55dCuh9WHgGBXu8iokwnoVyUQy7dpXNipFDa0FRRGkITAg4e3q2MGdC3r9b hItA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1758533839; x=1759138639; 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=S68QpsHReykX2B9M0K/3nvL5iS+xqDJkvSo3if0s2aI=; b=kvJfoUr0nNF1SxQ3jUiDT2RF41XB8P7dFN9XFOcukvzVK9Fq5GjSvjJZq7RD03gL6a O/vfkYzIl6OOuPa2q9MCXKY5/LkVwOtw1lBW0BCsjmaXEmli27PbzdqpGnT+csohyp5p QTCPh98F8oVTZMUB/WuN5Nj4+A+0bhvpgdOtIvp+wA9x/4ySWmgQuDraHDKn3VfC+9Qk UrFeVPC3QtWe0Dj6xQrWiESzAHmpUyNro6JwVaEl7C23406shvxthQ6e6TgGrjuTPcsa w/gbUXLbILcBvBlWbq6YtcFI/+tK080lXOsemSmSuXLwUyx8sf8sHDBO2ApkhB2BLt0w +zuQ== X-Gm-Message-State: AOJu0YyFaxkk5TTfH/EIbCf4RjGZHE8Iszg7Mw1FarAVWMHP5kFp/+hA fPK4SP/9woJpuHX5wkdwidtMubvGxXUf76tWybEqxdnsffiESNndzmu0uhSWp5uiv4I= X-Gm-Gg: ASbGncu2ICmdNWFuDr2McALRa5ojU8vXLlSOtZkrdpTKJQedRBTE6Zp+9qt8V/4qRiO LRWm2scleIQIHFBhujOYExk8kfA7RxFSGPAsWnmV1CVkUx+OrQ9Hg7Y7wO+2h+AHJHhTuDq/kpF FV4jjtnP1YOE9GmFK6gKBvRfusE7vet+hg/V8wu5lYfuz2qvahfFPPTFt+yHEP81sMYGgjSX9dA DXssvhlO8tTNNcKfkHFRtiLXE0T2wfqA+p4Z8s3iUUT8zHjyhmaybGV8jTzPnIg5PzCySgE0AoM 763Gu5nC3rv8iVm7cU71yisyyze1rb9aYq9sIaO3A0vvRmbmDQKko62ZXd1lZtHST9fUDM2hSzf tFmmpP1wnFD8f+ITxA/g2V95cWzIiM/5wNQ== X-Google-Smtp-Source: AGHT+IFeOPrdmQ+WxCpZ0rgHiwmsA1CiCsZW8Euy1LaxjPRW6FsGah+A6P4UMQbCmou9rE1npfhClA== X-Received: by 2002:a05:600c:4ec9:b0:46e:1a60:c995 with SMTP id 5b1f17b1804b1-46e1a60cb3amr6265615e9.2.1758533839278; Mon, 22 Sep 2025 02:37:19 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Palmer Dabbelt , Alexandre Iooss , Mahmoud Mandour , qemu-riscv@nongnu.org, Daniel Henrique Barboza , Thomas Huth , Peter Maydell , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Alistair Francis , qemu-arm@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Weiwei Li , Pierrick Bouvier , Liu Zhiwei , Richard Henderson Subject: [PATCH 10/25] include/semihosting/common-semi: extract common_semi API Date: Mon, 22 Sep 2025 10:36:55 +0100 Message-ID: <20250922093711.2768983-11-alex.bennee@linaro.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20250922093711.2768983-1-alex.bennee@linaro.org> References: <20250922093711.2768983-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::32f; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x32f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, T_SPF_TEMPERROR=0.01 autolearn=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: 1758534218587116600 From: Pierrick Bouvier We transform target/{arm,riscv}/common-semi-target.h headers to proper compilation units, and use them in arm-compat-semi.c. This way, we can include only the declaration header (which is target agnostic), and selectively link the appropriate implementation based on current target. Reviewed-by: Richard Henderson Signed-off-by: Pierrick Bouvier Message-ID: <20250822150058.18692-8-pierrick.bouvier@linaro.org> Signed-off-by: Alex Benn=C3=A9e --- include/semihosting/common-semi.h | 6 ++++++ semihosting/arm-compat-semi.c | 3 +-- ...mon-semi-target.h =3D> common-semi-target.c} | 20 +++++++++---------- ...mon-semi-target.h =3D> common-semi-target.c} | 19 +++++++++--------- target/arm/meson.build | 4 ++++ target/riscv/meson.build | 4 ++++ 6 files changed, 33 insertions(+), 23 deletions(-) rename target/arm/{common-semi-target.h =3D> common-semi-target.c} (64%) rename target/riscv/{common-semi-target.h =3D> common-semi-target.c} (59%) diff --git a/include/semihosting/common-semi.h b/include/semihosting/common= -semi.h index 0a91db7c414..aa511a46f42 100644 --- a/include/semihosting/common-semi.h +++ b/include/semihosting/common-semi.h @@ -35,5 +35,11 @@ #define COMMON_SEMI_H =20 void do_common_semihosting(CPUState *cs); +uint64_t common_semi_arg(CPUState *cs, int argno); +void common_semi_set_ret(CPUState *cs, uint64_t ret); +bool is_64bit_semihosting(CPUArchState *env); +bool common_semi_sys_exit_is_extended(CPUState *cs); +uint64_t common_semi_stack_bottom(CPUState *cs); +bool common_semi_has_synccache(CPUArchState *env); =20 #endif /* COMMON_SEMI_H */ diff --git a/semihosting/arm-compat-semi.c b/semihosting/arm-compat-semi.c index 26263a06b7a..604a69e3646 100644 --- a/semihosting/arm-compat-semi.c +++ b/semihosting/arm-compat-semi.c @@ -174,8 +174,7 @@ static LayoutInfo common_semi_find_bases(CPUState *cs) =20 #endif =20 -#include "cpu.h" -#include "common-semi-target.h" +#include "semihosting/common-semi.h" =20 /* * Read the input value from the argument block; fail the semihosting diff --git a/target/arm/common-semi-target.h b/target/arm/common-semi-targe= t.c similarity index 64% rename from target/arm/common-semi-target.h rename to target/arm/common-semi-target.c index 6775a270aaa..2b77ce9c17b 100644 --- a/target/arm/common-semi-target.h +++ b/target/arm/common-semi-target.c @@ -7,12 +7,12 @@ * SPDX-License-Identifier: GPL-2.0-or-later */ =20 -#ifndef TARGET_ARM_COMMON_SEMI_TARGET_H -#define TARGET_ARM_COMMON_SEMI_TARGET_H - +#include "qemu/osdep.h" +#include "cpu.h" +#include "semihosting/common-semi.h" #include "target/arm/cpu-qom.h" =20 -static inline uint64_t common_semi_arg(CPUState *cs, int argno) +uint64_t common_semi_arg(CPUState *cs, int argno) { ARMCPU *cpu =3D ARM_CPU(cs); CPUARMState *env =3D &cpu->env; @@ -23,7 +23,7 @@ static inline uint64_t common_semi_arg(CPUState *cs, int = argno) } } =20 -static inline void common_semi_set_ret(CPUState *cs, uint64_t ret) +void common_semi_set_ret(CPUState *cs, uint64_t ret) { ARMCPU *cpu =3D ARM_CPU(cs); CPUARMState *env =3D &cpu->env; @@ -34,27 +34,25 @@ static inline void common_semi_set_ret(CPUState *cs, ui= nt64_t ret) } } =20 -static inline bool common_semi_sys_exit_is_extended(CPUState *cs) +bool common_semi_sys_exit_is_extended(CPUState *cs) { return is_a64(cpu_env(cs)); } =20 -static inline bool is_64bit_semihosting(CPUArchState *env) +bool is_64bit_semihosting(CPUArchState *env) { return is_a64(env); } =20 -static inline uint64_t common_semi_stack_bottom(CPUState *cs) +uint64_t common_semi_stack_bottom(CPUState *cs) { ARMCPU *cpu =3D ARM_CPU(cs); CPUARMState *env =3D &cpu->env; return is_a64(env) ? env->xregs[31] : env->regs[13]; } =20 -static inline bool common_semi_has_synccache(CPUArchState *env) +bool common_semi_has_synccache(CPUArchState *env) { /* Ok for A64, invalid for A32/T32 */ return is_a64(env); } - -#endif diff --git a/target/riscv/common-semi-target.h b/target/riscv/common-semi-t= arget.c similarity index 59% rename from target/riscv/common-semi-target.h rename to target/riscv/common-semi-target.c index 663dedfdad2..aeaeb88d536 100644 --- a/target/riscv/common-semi-target.h +++ b/target/riscv/common-semi-target.c @@ -8,43 +8,42 @@ * SPDX-License-Identifier: GPL-2.0-or-later */ =20 -#ifndef TARGET_RISCV_COMMON_SEMI_TARGET_H -#define TARGET_RISCV_COMMON_SEMI_TARGET_H +#include "qemu/osdep.h" +#include "cpu.h" +#include "semihosting/common-semi.h" =20 -static inline uint64_t common_semi_arg(CPUState *cs, int argno) +uint64_t common_semi_arg(CPUState *cs, int argno) { RISCVCPU *cpu =3D RISCV_CPU(cs); CPURISCVState *env =3D &cpu->env; return env->gpr[xA0 + argno]; } =20 -static inline void common_semi_set_ret(CPUState *cs, uint64_t ret) +void common_semi_set_ret(CPUState *cs, uint64_t ret) { RISCVCPU *cpu =3D RISCV_CPU(cs); CPURISCVState *env =3D &cpu->env; env->gpr[xA0] =3D ret; } =20 -static inline bool is_64bit_semihosting(CPUArchState *env) +bool is_64bit_semihosting(CPUArchState *env) { return riscv_cpu_mxl(env) !=3D MXL_RV32; } =20 -static inline bool common_semi_sys_exit_is_extended(CPUState *cs) +bool common_semi_sys_exit_is_extended(CPUState *cs) { return is_64bit_semihosting(cpu_env(cs)); } =20 -static inline uint64_t common_semi_stack_bottom(CPUState *cs) +uint64_t common_semi_stack_bottom(CPUState *cs) { RISCVCPU *cpu =3D RISCV_CPU(cs); CPURISCVState *env =3D &cpu->env; return env->gpr[xSP]; } =20 -static inline bool common_semi_has_synccache(CPUArchState *env) +bool common_semi_has_synccache(CPUArchState *env) { return true; } - -#endif diff --git a/target/arm/meson.build b/target/arm/meson.build index 914f1498fc5..638ee62525f 100644 --- a/target/arm/meson.build +++ b/target/arm/meson.build @@ -28,12 +28,16 @@ arm_user_ss.add(files( 'vfp_fpscr.c', 'el2-stubs.c', )) +arm_user_ss.add(when: 'CONFIG_ARM_COMPATIBLE_SEMIHOSTING', + if_true: files('common-semi-target.c')) =20 arm_common_system_ss.add(files('cpu.c')) arm_common_system_ss.add(when: 'TARGET_AARCH64', if_false: files( 'cpu32-stubs.c')) arm_common_system_ss.add(when: 'CONFIG_KVM', if_false: files('kvm-stub.c')) arm_common_system_ss.add(when: 'CONFIG_HVF', if_false: files('hvf-stub.c')) +arm_common_system_ss.add(when: 'CONFIG_ARM_COMPATIBLE_SEMIHOSTING', + if_true: files('common-semi-target.c')) arm_common_system_ss.add(files( 'arch_dump.c', 'arm-powerctl.c', diff --git a/target/riscv/meson.build b/target/riscv/meson.build index a4bd61e52a9..fdefe88ccdd 100644 --- a/target/riscv/meson.build +++ b/target/riscv/meson.build @@ -8,6 +8,10 @@ gen =3D [ =20 riscv_ss =3D ss.source_set() riscv_ss.add(gen) + +riscv_ss.add(when: 'CONFIG_ARM_COMPATIBLE_SEMIHOSTING', + if_true: files('common-semi-target.c')) + riscv_ss.add(files( 'cpu.c', 'cpu_helper.c', --=20 2.47.3 From nobody Sun Sep 28 15:30:20 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1758534340; cv=none; d=zohomail.com; s=zohoarc; b=E0LlQ4dUqTow1l3I9kr3TAr65YVMhD2tYKBs0w+ffY5hjnOiXnQgseXTI+ouJ0AE/wLAjs5F5Lp2UY764vPuez0wSOPAq2b/1v0CQdebAVmRWNHGDQelQB4JqdHaLQ4wQRqp1glqFBEM/MX9LCjWQMHrlgO70Vz8CTav8O0qskg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1758534340; 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=68wbma/YcKI1TwJYc3fIO/8B8AyrFhnJSIMXhgyet+0=; b=i8skBzmHMNhTnI+F74ZxggQWD7Knbx1f0OlCkquclATOzEO4fitnH/CRn5uvP3V+TSIJzmT2PL+ZdoI6Onn+C9wpOiX8bCxu7odF+O+CFPzz/Mh9Tjc7YY8s2422qhLWzmJwbj9MuDfpCpHNIrUU4wAlBpC5OYEzTcg9cEyLza8= 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 17585343401836.9524362923156104; Mon, 22 Sep 2025 02:45:40 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v0d67-0006j6-Sg; Mon, 22 Sep 2025 05:44:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v0d53-0005MR-J3 for qemu-devel@nongnu.org; Mon, 22 Sep 2025 05:43:37 -0400 Received: from mail-wr1-x431.google.com ([2a00:1450:4864:20::431]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1v0d4o-0001zP-Sg for qemu-devel@nongnu.org; Mon, 22 Sep 2025 05:43:33 -0400 Received: by mail-wr1-x431.google.com with SMTP id ffacd0b85a97d-3f42b54d1b9so1472286f8f.0 for ; Mon, 22 Sep 2025 02:43:15 -0700 (PDT) Received: from draig.lan ([185.126.160.19]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-46566f72354sm193693225e9.3.2025.09.22.02.43.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Sep 2025 02:43:09 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 997ED5FA07; Mon, 22 Sep 2025 10:37:12 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1758534193; x=1759138993; 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=68wbma/YcKI1TwJYc3fIO/8B8AyrFhnJSIMXhgyet+0=; b=UFUxenMH5RYBLb53SomAZHn1PnotInnTEyJzibeRchh2cS603uHJm6XWS7C7yA5dGX ICNJ6nC0XvdNI6FnJdUWeXAVyMmjTrqiaVhQEF+27Q9aSZroLg7DNIQc5xwQB/NjqyYo qQ1KeQ8N8ZsWhpuxjMtck5gQ1fac3qYGHP6GK55PL6QDopaScTTFmaCQMfIi/U1Dnnw2 JAH+G0VDR5X1MkRtD7Go6eZNhcR4THYy0fBkZbm/bjqQ1O4pRJDLSfIZVTS10kOlfzMt 7LjFTaR7MO6v2rYXq6ggfo+TntUEl5tA8Kh0Zy4UMnrOSFfun32PZBSN/+POZGdp5Hv9 sTCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1758534193; x=1759138993; 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=68wbma/YcKI1TwJYc3fIO/8B8AyrFhnJSIMXhgyet+0=; b=C/u/9K8MloUWl4azF6qTLRe8Sk7INjpD7/PTMuk6sW6/cKo2uwP3ugEzn+4Vn6Gb1O nIOYgIhq6HYFot/kIudpN+mT9HRw1CBferjeuwjIiprc0rJL19wDf6GigAt560K3EsM6 HU+lJ/+yttYB1awbvL59oW6TQg9LjQgK7z/io6NqRr+AGQs/Dd6bXS4PaMq5wuwZV5CI WbH5hlrY35n04dYG55fouie476hoGk7VFTCqTP/wTVqvmr9j5QKIXjExYE/sPcCyf6YE SzG3emOzcSPOS4haesdcJphHche0vf77NVk8G93gktdkNsyGU+jVq77F3hP5aa6MjSR9 jncA== X-Gm-Message-State: AOJu0YyVm3+/FlIQ0XzOQh42UWCYvbXSPsoABy47ygx2rfU48CISS19a +Q4Xyhj970O2hQqilp/kx6TBBFP5zhtWj3p7tPtfGM2w/fqH9U9ZbuAGgopqggzEvV8= X-Gm-Gg: ASbGncu2w3cQ5EsaUzRWSd628eBfQfm++SGZJKPeyRrVwBPL9KSHhZFcWLV9KX4efci VgQ2ebZU4trJtYYLM2lr0IADGUHImhzKmM7KHAyttVT6mlO/ZCnn5inC/HsKs/QIPcT8H+P/jcl vvFJSH7tuJIF4y85sFanWG9Ww79umIUu2zbJPCQOzSaFH+Jlk+ODPCS4sKVlOn7LJdK5399B7dg Q4EEn6Nw69QEN2Y6JuoBTyxKdGr0G9JrZdvRDQAo+eh2C4yKXhZZRXXdFbl62iAZEH13ZU5NBYb XTKeQrYio9y56C+Npub9/Uecq9dkq7kAZiyDYvka3bZcGXteXuuAeUr3rDeXmZ49MYfVfxkdlg+ xmgvsmOzZ3kDFl50sGMO6ez0= X-Google-Smtp-Source: AGHT+IFpjqJHRrNaIVglNlSJIofFd6QodqeBxiHyAVpa6HQccGp7WPW9KWukBOfY8HXKK2HWR8JSyA== X-Received: by 2002:a05:6000:1843:b0:3f7:9dcf:c066 with SMTP id ffacd0b85a97d-3f79dcfc487mr5309325f8f.51.1758534192583; Mon, 22 Sep 2025 02:43:12 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Palmer Dabbelt , Alexandre Iooss , Mahmoud Mandour , qemu-riscv@nongnu.org, Daniel Henrique Barboza , Thomas Huth , Peter Maydell , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Alistair Francis , qemu-arm@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Weiwei Li , Pierrick Bouvier , Liu Zhiwei , Richard Henderson Subject: [PATCH 11/25] semihosting/arm-compat-semi: eradicate sizeof(target_ulong) Date: Mon, 22 Sep 2025 10:36:56 +0100 Message-ID: <20250922093711.2768983-12-alex.bennee@linaro.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20250922093711.2768983-1-alex.bennee@linaro.org> References: <20250922093711.2768983-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::431; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x431.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=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: 1758534341820116600 From: Pierrick Bouvier No semantic change. Reviewed-by: Richard Henderson Signed-off-by: Pierrick Bouvier Message-ID: <20250822150058.18692-9-pierrick.bouvier@linaro.org> Signed-off-by: Alex Benn=C3=A9e Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- semihosting/arm-compat-semi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/semihosting/arm-compat-semi.c b/semihosting/arm-compat-semi.c index 604a69e3646..6725dcf4ba7 100644 --- a/semihosting/arm-compat-semi.c +++ b/semihosting/arm-compat-semi.c @@ -786,7 +786,7 @@ void do_common_semihosting(CPUState *cs) =20 case TARGET_SYS_ELAPSED: elapsed =3D get_clock() - clock_start; - if (sizeof(target_ulong) =3D=3D 8) { + if (is_64bit_semihosting(env)) { if (SET_ARG(0, elapsed)) { goto do_fault; } --=20 2.47.3 From nobody Sun Sep 28 15:30:20 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1758534197; cv=none; d=zohomail.com; s=zohoarc; b=iFXLEgAUm6auLhH3UMf48mQWhuoORXCk3bsWCp1yj+t10765bUrAMnfqy6yYn38nK9Gc2+FGQLRCyViXnm1cgeFptuIuGVlyDAvvROf3mTE13pjfRZFS/sRohLnrbDoJ1+a5zAGXwt3odGkLkverE0Tyx4bttdnJbc0h8qNY7Vk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1758534197; 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=Kmav6an//5t3AYixPg5kMb65gCXejU84QEdCr46snK0=; b=ZSqOgxCCk6DL/kJkIfMYPKlfLndPsAl/C59DS7276HH8/OmC2KV+nxgq+0VU3KZGeq4m4ArVhC+nq3wtgMO/d3fR7B3jl8h0tBFpCA2a+Q3IpPao7gzC+2tXSdH4BvXTX3JL7kn/Y2bLdyGzI2PJjayqyp4pykjIG/1HL5RoqsU= 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 1758534197768947.8623226054824; Mon, 22 Sep 2025 02:43:17 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v0d0l-0004Mf-JS; Mon, 22 Sep 2025 05:39:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v0cze-0002Tt-IY for qemu-devel@nongnu.org; Mon, 22 Sep 2025 05:38:03 -0400 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 1v0cz9-0000eh-EN for qemu-devel@nongnu.org; Mon, 22 Sep 2025 05:37:58 -0400 Received: by mail-wr1-x42b.google.com with SMTP id ffacd0b85a97d-3f0134ccc0cso2954094f8f.1 for ; Mon, 22 Sep 2025 02:37:25 -0700 (PDT) Received: from draig.lan ([185.126.160.19]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3ee073f4f3csm18495855f8f.2.2025.09.22.02.37.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Sep 2025 02:37:17 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id B12F75FA12; Mon, 22 Sep 2025 10:37:12 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1758533842; x=1759138642; 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=Kmav6an//5t3AYixPg5kMb65gCXejU84QEdCr46snK0=; b=tVSgAefPrxKrPFqVyNm0Ygwsr5K+x6rCpPwphEoNBdu1gt4FY1iEr5XuLXFixCYww5 +N8hCNDrWaRWaQ+1XgGY600OH5+TiztS2Zp1wo2Ms6sL3uVfjjZ7bjnb/2qFis0SYcty wxLi3hZsYqHqBTeATiPjgoJz6PQmjNTrlqUOU8gDShuoDX9+h3bUNc6+25qmRdAULZeN OJPvMdt/NFb7iASIt0G3lEP4iiqolA28TbU2lr4XVod0Ti/fg24guWYl25F0hza3jrXj gNvSxWo5Ezs5BNx4Psjrk1x13yqgUeKL6VudUFYM7PgY96iEL5kwABBVqw4FkeWzczip 47xQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1758533842; x=1759138642; 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=Kmav6an//5t3AYixPg5kMb65gCXejU84QEdCr46snK0=; b=RiKMyK+kjbEHChRNKbo/VSN0vkiQH+uqZ8HuMkr4oI2ifTPCqLThMKJYtKTRUZ6DQx UGmb24mPt4gEvC7kiGphLqMfWRfWVqHN6thVJ45smrdLL027ZFruI8Jw6roEJpF4mTE+ V18abawdokn2RqxipjfcVrSrsAZ2LZOJC0j5DMlnXiZW2MS1WaD71MfwXp5/1OjbBw7H H/rM35CNpVpRFr53G9fSDoh1oSQ7N7r8CPiTJA9TtJJfuPvna617aB1TECevR4JY1Htk gCSqYMPTksMnjxJueDDpPALAIiCLHJhAhUYCmAL+fx1OrGuwIt9Q5w7Kj/CdqFwfM4NE ukrQ== X-Gm-Message-State: AOJu0YzT9vRSti0jtSNwG3IIQIJANKbIK0EybuGcyD5j4Ya4P9YWt9sC qx4/rt8lltO9QRKmK0f1+gYAcl7DFjBChLeODcYWvie+2TKDxVoM5wVMaFisGibWQKc= X-Gm-Gg: ASbGnctP24M9xHGo6wJ1vDcSAbhQ2Iz+K3+I5vHZV28u7hvjOzlip/t0pGVRrCSxVwS 05Z1i5InTZRN8POjtjhETXhiA80/pBQPDzyvV4ioakJovquDPF19PGoOF4Js+iCSBIBibn55sR5 F0eRnO7ziQVMxT2mofbXBPHrWweRNljBJr9aYWdbGtKF08X+6d6YXmbmEMXzRXpMqVBq/+1DLVk 5V2RuwDZ5KTkeHUZ6m/rKKXJN8EI55QlLcvGc476Hfb2J5nfMEcKnAxgcwJWjM/r3WVHd6SmBoj kREBzTdD1MwkK6w4TYBjPe3TzAkH7ALRYBfDEgpF0gOauFbBgErzVmL5VEqNgvNwmRoiC5VZQPx v+1fjgpmbF3FFnWMAyZC3GpI= X-Google-Smtp-Source: AGHT+IE0mvUYSZigoWjc6qHUaYblt7fJ0hhAfjIqLVQUbFvAugta/Ux9kuFsoNExJ+cpo0Pi3lyZhQ== X-Received: by 2002:a05:6000:2509:b0:3ec:1fff:3b25 with SMTP id ffacd0b85a97d-3ee7082057fmr9500958f8f.0.1758533841568; Mon, 22 Sep 2025 02:37:21 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Palmer Dabbelt , Alexandre Iooss , Mahmoud Mandour , qemu-riscv@nongnu.org, Daniel Henrique Barboza , Thomas Huth , Peter Maydell , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Alistair Francis , qemu-arm@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Weiwei Li , Pierrick Bouvier , Liu Zhiwei , Richard Henderson Subject: [PATCH 12/25] semihosting/arm-compat-semi: replace target_ulong with vaddr Date: Mon, 22 Sep 2025 10:36:57 +0100 Message-ID: <20250922093711.2768983-13-alex.bennee@linaro.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20250922093711.2768983-1-alex.bennee@linaro.org> References: <20250922093711.2768983-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 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: 1758534200091116600 From: Pierrick Bouvier Reviewed-by: Richard Henderson Signed-off-by: Pierrick Bouvier Message-ID: <20250822150058.18692-10-pierrick.bouvier@linaro.org> Signed-off-by: Alex Benn=C3=A9e --- semihosting/arm-compat-semi.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/semihosting/arm-compat-semi.c b/semihosting/arm-compat-semi.c index 6725dcf4ba7..29cdab66f73 100644 --- a/semihosting/arm-compat-semi.c +++ b/semihosting/arm-compat-semi.c @@ -123,7 +123,7 @@ static GuestFD console_out_gf; */ =20 typedef struct LayoutInfo { - target_ulong rambase; + vaddr rambase; size_t ramsize; hwaddr heapbase; hwaddr heaplimit; @@ -214,7 +214,7 @@ static LayoutInfo common_semi_find_bases(CPUState *cs) * global, and we assume that the guest takes care of avoiding any races. */ #ifndef CONFIG_USER_ONLY -static target_ulong syscall_err; +static uint64_t syscall_err; =20 #include "semihosting/uaccess.h" #endif @@ -260,8 +260,8 @@ static void common_semi_rw_cb(CPUState *cs, uint64_t re= t, int err) { /* Recover the original length from the third argument. */ CPUArchState *env G_GNUC_UNUSED =3D cpu_env(cs); - target_ulong args =3D common_semi_arg(cs, 1); - target_ulong arg2; + uint64_t args =3D common_semi_arg(cs, 1); + uint64_t arg2; GET_ARG(2); =20 if (err) { @@ -300,9 +300,9 @@ static void common_semi_seek_cb(CPUState *cs, uint64_t = ret, int err) * is defined by GDB's remote protocol and is not target-specific.) * We put this on the guest's stack just below SP. */ -static target_ulong common_semi_flen_buf(CPUState *cs) +static uint64_t common_semi_flen_buf(CPUState *cs) { - target_ulong sp =3D common_semi_stack_bottom(cs); + vaddr sp =3D common_semi_stack_bottom(cs); return sp - 64; } =20 @@ -389,9 +389,9 @@ void semihosting_arm_compatible_init(void) void do_common_semihosting(CPUState *cs) { CPUArchState *env =3D cpu_env(cs); - target_ulong args; - target_ulong arg0, arg1, arg2, arg3; - target_ulong ul_ret; + uint64_t args; + uint64_t arg0, arg1, arg2, arg3; + uint64_t ul_ret; char * s; int nr; int64_t elapsed; @@ -462,7 +462,7 @@ void do_common_semihosting(CPUState *cs) =20 case TARGET_SYS_WRITEC: /* - * FIXME: the byte to be written is in a target_ulong slot, + * FIXME: the byte to be written is in a uint64_t slot, * which means this is wrong for a big-endian guest. */ semihost_sys_write_gf(cs, common_semi_dead_cb, @@ -688,7 +688,7 @@ void do_common_semihosting(CPUState *cs) =20 case TARGET_SYS_HEAPINFO: { - target_ulong retvals[4]; + uint64_t retvals[4]; int i; #ifdef CONFIG_USER_ONLY TaskState *ts =3D get_task_state(cs); --=20 2.47.3 From nobody Sun Sep 28 15:30:20 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1758534058; cv=none; d=zohomail.com; s=zohoarc; b=DA82eQhvE0U+lZTDDmAqalGFyv3W8skn+fbqtloA/IeWSaSf1SUi8QRAa3YewVsdIsglut/6iGcuhLQ+dTxLKtOAgxP+4X1TNxZddEnW/OCjm7ARfkL6j95MdaZrrl1/xWkT83Zjc4V56M2tfoqA33NJzIwvqmOhi4TIhuB4Eqo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1758534058; 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=S4WNTy7QbDl7ReDD5PUvCAXuciU8b39SjZqZspkFta4=; b=Cpz+GSyL9P1J1RiW6psEnRZR6i1S1PGI0GC4hVbZ1ee5Uh+zkqsO/Utbhy1T6YZdI+nim1VUR/U2JrrFZUWEq2sSpNAc+AHEPYvgJ0UDN+KlzTQwN3FHhlNPSIkuNRjQgYoz0Xv1X9403O9aEfhOLHFrgxld3bvjYJJfAUdITLQ= 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 175853405835759.22563719764969; Mon, 22 Sep 2025 02:40:58 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v0d0s-0004jO-IH; Mon, 22 Sep 2025 05:39:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v0czg-0002U0-2l for qemu-devel@nongnu.org; Mon, 22 Sep 2025 05:38:06 -0400 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1v0czC-0000gA-Ql for qemu-devel@nongnu.org; Mon, 22 Sep 2025 05:37:59 -0400 Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-45b9a856dc2so27643415e9.0 for ; Mon, 22 Sep 2025 02:37:29 -0700 (PDT) Received: from draig.lan ([185.126.160.19]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-460942b6c3csm131375925e9.1.2025.09.22.02.37.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Sep 2025 02:37:24 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id C4F2D5FA14; Mon, 22 Sep 2025 10:37:12 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1758533846; x=1759138646; 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=S4WNTy7QbDl7ReDD5PUvCAXuciU8b39SjZqZspkFta4=; b=n4iXFapDqjeBYZkvriC0g4xEVvmtxf38qkhnvbVIF80WiBsVE1KHBKJJoLnsRssTL3 s5NDCbLXuwB07WR4Eq2KfrZVEn5mjRK2AcvYQkBBWaCvMV58XkzH3hbyUqjVE0wp00TK bXryvpOOwEssa+pVGshIgGmEYLgg6WBM8vrRjujUg7GcMjbfymM4PgsBMhwc9/kzuIup L4h+7wMVtwQ0w574tziTvdbJIGA8I2lJKAjWnuO57dkYalTzgvcyHMMytxFQ0J0ErgQu scMHevg2lwT+ChlX33O9jOCid+ObLdX+fNGJNcFSnqACvgJXs6AGGSps+8qivaHe6wfh JcyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1758533846; x=1759138646; 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=S4WNTy7QbDl7ReDD5PUvCAXuciU8b39SjZqZspkFta4=; b=TFUwkJFKC5Baa4+0gr8xOKFuZRCsETPb0eJazoPlZZ7E3nepp2oLLGmwQRe1lNsGML dFBtU9FYrVn7gssz1Q28enW8g/4T28UqHiX8mcpPgkEux3Up275bnWRAgtyS5UyW6byh 21PmnbuOG29VkUC/G0PkMNhyZ2zhY9xRXzTuHG+MV8ihRh6PZLDMVol1eeBylbEjeeKB zJQg6xQfuGY8cDGSGoX/7ciPv0ZNmlBWj8l7iFW7jSVGWSHCJxiZZTphe+X6s7FIaMzx 85tkzTiLLPpTSx9V/rD9yO9+WRcZzp0dKu0b5aTIx38V/l2X+IasewpTS8MBBVmZIIDL ijXA== X-Gm-Message-State: AOJu0Yzn5AeE/8ucd+VMFqBvs/bLNkI/QhEKcweU3LxNidsL3lE+9MR4 05XJIOQm09vaLPysPmGoGZgpQ/mqkf271WeLZ3hnKgX03BK83RtJuQZL1DzeAePcFxM= X-Gm-Gg: ASbGncv+ZzNv0upbM6TOejnKlmEAcxFnepSUNGwKPx/w1p0WB09LlAyAltxGu0Cs6hS RFfVWSNqZzViKGvyp3A+72ojk+636D9OZZEsaOXQSM9Sbg+XSaXnR74iFd0GHmjbyVlHoSd1gFU UcWudpZzPd4z8jRkhhgAqrytrwaPFPYczFKAid3CKo2+9ijwQSMk2ZFR5mEZYaR3XW7c0gtZXyV 1pV915RHRKiBXe5oLjwIVyqJElE042e9qpCj+PKfNSB21NrfnFYmrK5o2cvdW86jCnmYEVMadUI dynEnbFQYl5asJxdPoHG+OJisOvGzWjlHBRxfPBVY0pSivsQete34RVSYEfb3Jk5OfbXisn757I lxpfg/MhAsbzOfGEd3VX/wHA= X-Google-Smtp-Source: AGHT+IEfOfsj70NV5OJ38BPB3oBvQ/TSHt5ZiCzF66U4ZGiQdrLGPQXZxesF+PGJ4gx11C67PFSoyA== X-Received: by 2002:a05:600c:1c05:b0:45b:7a93:f108 with SMTP id 5b1f17b1804b1-4684c13ea94mr118734105e9.3.1758533845869; Mon, 22 Sep 2025 02:37:25 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Palmer Dabbelt , Alexandre Iooss , Mahmoud Mandour , qemu-riscv@nongnu.org, Daniel Henrique Barboza , Thomas Huth , Peter Maydell , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Alistair Francis , qemu-arm@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Weiwei Li , Pierrick Bouvier , Liu Zhiwei , Richard Henderson Subject: [PATCH 13/25] semihosting/arm-compat-semi: eradicate target_long Date: Mon, 22 Sep 2025 10:36:58 +0100 Message-ID: <20250922093711.2768983-14-alex.bennee@linaro.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20250922093711.2768983-1-alex.bennee@linaro.org> References: <20250922093711.2768983-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::333; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x333.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1758534061142116600 From: Pierrick Bouvier We use int64_t or int32_t depending on ret size. Reviewed-by: Richard Henderson Signed-off-by: Pierrick Bouvier Message-ID: <20250822150058.18692-11-pierrick.bouvier@linaro.org> Signed-off-by: Alex Benn=C3=A9e --- semihosting/arm-compat-semi.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/semihosting/arm-compat-semi.c b/semihosting/arm-compat-semi.c index 29cdab66f73..3c9192d8684 100644 --- a/semihosting/arm-compat-semi.c +++ b/semihosting/arm-compat-semi.c @@ -501,10 +501,13 @@ void do_common_semihosting(CPUState *cs) break; =20 case TARGET_SYS_ISERROR: + { GET_ARG(0); - common_semi_set_ret(cs, (target_long)arg0 < 0); + bool ret =3D is_64bit_semihosting(env) ? + (int64_t)arg0 < 0 : (int32_t)arg0 < 0; + common_semi_set_ret(cs, ret); break; - + } case TARGET_SYS_ISTTY: GET_ARG(0); semihost_sys_isatty(cs, common_semi_istty_cb, arg0); --=20 2.47.3 From nobody Sun Sep 28 15:30:20 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1758534061; cv=none; d=zohomail.com; s=zohoarc; b=K9bLCNMk8Luf2EnAGN5ohTmeWrNy9JpSE+hdQ1I2kfaf5Yk7WjHqwY8/Kl+iHf2DD0LkvkTSqsRAqSnnOMWCTn5jXLriS3ZOpmqyqMXc3S5yNVvYtLGqU9Hdb6tsmtwoMJ3OF82dXA8o0u4pwDcUitWublKwq3F74jkSxLAZ0FU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1758534061; 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=HhK8fyrcFTNAXAyMAUB3RJqIdZ7kdSjQMi97UpXe69Y=; b=h2YaMMVOaICCMCidgpT9iPhwLFsfLC2C2hM1U+8Zf7aYtIOIU67jBeoPcxxf0TxsPplYaBm4wK7jZJF/DJ4hYfpJTAFJu+IKU6NgwI4x2peqxr3aR9NUNoyZj2tZfMc7lL6jXhxNXNxH6XMhzbuziwhfoZt6IbqkbYQDzcNp0q4= 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 1758534061758733.0570879404249; Mon, 22 Sep 2025 02:41:01 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v0d0u-0004o6-O8; Mon, 22 Sep 2025 05:39:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v0czw-0002Z6-Gr for qemu-devel@nongnu.org; Mon, 22 Sep 2025 05:38:18 -0400 Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1v0czE-0000h0-3Z for qemu-devel@nongnu.org; Mon, 22 Sep 2025 05:38:16 -0400 Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-46d25f99d5aso5249715e9.0 for ; Mon, 22 Sep 2025 02:37:30 -0700 (PDT) Received: from draig.lan ([185.126.160.19]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3ee074121b2sm19130261f8f.27.2025.09.22.02.37.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Sep 2025 02:37:24 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id D9C655FA16; Mon, 22 Sep 2025 10:37:12 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1758533847; x=1759138647; 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=HhK8fyrcFTNAXAyMAUB3RJqIdZ7kdSjQMi97UpXe69Y=; b=X7LpoajZW+Rw2cWLMTTqy4HXpPLkYIY3ypSaeEMiTr7H4vKai4EZ/bU5aNVxOhFKCq pRqYGmaSY0JPhKgBbVEoEMJS2MiuDa0I8yj+8fKGCpAbdEKa++QRD6cCeAM0+52hfGv3 eYwcWgIq/8vx9rl35SrM5OPGbgllYReg2l9hth5U0kA1G06BYpwb2ePsl3cUf2FiEbSd h0nsgObv2V0gCY7xHzzkdUZB61hCiFI1OsAGFWk1duaB5oo35Yx9YKZHWux8/gj8+nZ2 /tDGCJyTKbPlm3ZhSjBLcEQE6S1zH+YI7QgVZiyjQAFhiVVx5RA+4r62D2SJFgDeKv1K S1pA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1758533847; x=1759138647; 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=HhK8fyrcFTNAXAyMAUB3RJqIdZ7kdSjQMi97UpXe69Y=; b=oeaBLhqjI9oUax42WAZyw9GGMhRNALjbOYsYEuQSopzCRO4aaBpLdfw/nQh6X15LeS rU6APEQGKsQYL88oTw1DybYBxa/bJp8BMX34QMAx4gEQ7IAIRA7Wz32yS/BsiV7eHtYl LY/f5TtrqIrMDmdxcTW2IraYAWTS9RRftVX89ydBuKYieshdDJJvEgdPzZmCo8deBS2v UnI8hmckesPMTjCAf8nP/t0VVn3YdmKWJGmBbfAUShfddpjdnP164YTHmeANxyjJSE/M +AHExhFaxDWEH+bYC29Bxlv0/TimSzfLkgJ0pv6C8R+eg7LRRsNcvqS6aHn+ytfWIaS3 8wqw== X-Gm-Message-State: AOJu0YziPCpEDHSBMmMGYyva6eUvNhoibB6M0tfp/W0EH23gd9E2yHVO 5uvj3casP3tXu+FkBan54FfRXzSiE8GzpBD6tXRzaWLRmpnOrv7fCSAlT4D4MkU6PBA= X-Gm-Gg: ASbGnctmk9jpd3ZRAGLjYHVPQ7+Xx124YPknKnZ1pVyU30WYyOeBKKEl9trcrkjoo2Q pbefHX14BKfyY770/2CJ5wFvfR7fQkwzmY/QyO4Po/jSRnpkVZ/SUdsDbh8aXiSpB6k4CnYpok8 js3ctt/40ABavWkMWSmEBVaTmgVgd+LAN6xLw9LxZB7y/SFpyfY084xk/gweilHfrgVaAH8cmyF MAy4MhBHKc3yNvb8zPJpsXIU/5yCxTOXUDKceAeBuqXCPcmYTWgxBDy8usfp/egG7Rj0Xv8+pl2 Ub0izj74kd8awMJBP98rdAR6Cvy7XRdFiQJbTDYrP+TMURYoi5tXquCRanicqbJeDWNXjiTvbry 5dVvJNh2cDt66GK89vv9pSV4= X-Google-Smtp-Source: AGHT+IGvQykugjERs1DlA2LnPsomQf1DGNlnVD8bMHEgKSQkEZejic/RFQxHWt2Vc5BbiDz5w/FJrg== X-Received: by 2002:a05:600c:a415:b0:45b:92a6:63e3 with SMTP id 5b1f17b1804b1-4652c9ee679mr123352865e9.9.1758533847227; Mon, 22 Sep 2025 02:37:27 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Palmer Dabbelt , Alexandre Iooss , Mahmoud Mandour , qemu-riscv@nongnu.org, Daniel Henrique Barboza , Thomas Huth , Peter Maydell , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Alistair Francis , qemu-arm@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Weiwei Li , Pierrick Bouvier , Liu Zhiwei , Richard Henderson Subject: [PATCH 14/25] semihosting/arm-compat-semi: remove dependency on cpu.h Date: Mon, 22 Sep 2025 10:36:59 +0100 Message-ID: <20250922093711.2768983-15-alex.bennee@linaro.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20250922093711.2768983-1-alex.bennee@linaro.org> References: <20250922093711.2768983-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, TVD_SPACE_RATIO=0.001, T_SPF_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: 1758534062192116600 From: Pierrick Bouvier Reviewed-by: Richard Henderson Signed-off-by: Pierrick Bouvier Message-ID: <20250822150058.18692-12-pierrick.bouvier@linaro.org> Signed-off-by: Alex Benn=C3=A9e --- semihosting/arm-compat-semi.c | 1 - 1 file changed, 1 deletion(-) diff --git a/semihosting/arm-compat-semi.c b/semihosting/arm-compat-semi.c index 3c9192d8684..61001267965 100644 --- a/semihosting/arm-compat-semi.c +++ b/semihosting/arm-compat-semi.c @@ -34,7 +34,6 @@ #include "qemu/osdep.h" #include "qemu/timer.h" #include "exec/gdbstub.h" -#include "cpu.h" #include "gdbstub/syscalls.h" #include "semihosting/semihost.h" #include "semihosting/console.h" --=20 2.47.3 From nobody Sun Sep 28 15:30:20 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1758534219; cv=none; d=zohomail.com; s=zohoarc; b=cEaaTgwZt/Ckfd+HiJIzRuff7Jw+ysRk2TL7jihhu6ZVq0JNCPQUU90sbMNXPdpOQcnnlJgNxNXchDytam+05El20OR1/Ghp+RBrJgWTfWBJAFnM1f7x8QvHcIoqspB0KgWkPUR4M5EKXbnLCVAnu8k32vI1rwmtiRnYpybwGu8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1758534219; 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=FpyzDIWQ5ZoXKAzqSyc2elMY1EE9GCHDwM8UA7OBlS8=; b=LOJpVf0m/KBOZNw+yVGHnp08RQUy7fa6x2SYN36XS7VJdT5oCQVQ5XSMlBWY50Df42SIQI7NW8T4KSR7fM+wsyhFlFEIhRTxvDjBIGWZWpQJZZjKYEnVW9Q8z0u9DAxtbeoF8pU1Llsydw0G4fiwM0jmZxiBUuE2VgCAoLO6NmQ= 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 1758534219928398.4102271314215; Mon, 22 Sep 2025 02:43:39 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v0d0n-0004W2-Fi; Mon, 22 Sep 2025 05:39:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v0czq-0002VA-0Z for qemu-devel@nongnu.org; Mon, 22 Sep 2025 05:38:14 -0400 Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1v0czD-0000fx-Bv for qemu-devel@nongnu.org; Mon, 22 Sep 2025 05:38:06 -0400 Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-45de56a042dso26099475e9.3 for ; Mon, 22 Sep 2025 02:37:26 -0700 (PDT) Received: from draig.lan ([185.126.160.19]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4613dccb5e2sm233400715e9.17.2025.09.22.02.37.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Sep 2025 02:37:24 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id F23A45FA18; Mon, 22 Sep 2025 10:37:12 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1758533845; x=1759138645; 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=FpyzDIWQ5ZoXKAzqSyc2elMY1EE9GCHDwM8UA7OBlS8=; b=f06tm7k3NwPN0zO9Gi1LFZpDdHj2DeuJr5L8ry/USP25GeLiQC1e9+SOGQemQoc2U3 qAm37dwy4tkjEhwPfJ5A83SBx+YX10yC+Iby1OcwNsfddnDyqyq5g6Ql2tPZh8L8h2z4 OccjcjoL+blmj83PdxCsOfzSQ2f65imjibvOr/d5s1czkeV0THVMCghwUQBa6kewCoIc 5n5gxbrpfvdmAGh+sliuVcTJELsaiLgNGLE557eh+xEsE01PoYKlXVH7nbq5cfXxlDTC hO85x/LcrSjbZM4VHWCRRJyOs0qFMkuWG9V/QcRALkC9mvkaNuY7n2RxO7PC32hizND7 oxHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1758533845; x=1759138645; 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=FpyzDIWQ5ZoXKAzqSyc2elMY1EE9GCHDwM8UA7OBlS8=; b=fvVLBsSMxafgCp5MpY8tQJDXr5EP5B3cJJM3ySVoHPDajt5riOdhMzxNSk7Y4D1VVT rS232tCNS8vNRKdcItNNzKMjVfC75J8XZ05XzLofnndbNF1bOpO9BSO/OFynO+3UFyUu fpf08epQymSDXEOOjbjLXQQtsVYfvMtQ1NiUGXpLB2cJe6JN48aeKPKSr3o1XZzWyu/m KFdRb8A2DqzqGoT9l+Yj2Mrep2i+kfcpZLoOvn0V/DB1pVsbfGIRc3CeN7VRR5mRifeY rHNX/hHwn3B8LXLa/j1nhM05KnzE0JFlOA3YZoIIgQJMnE1beSY6fSnskNl/TbI1zCLT FVyA== X-Gm-Message-State: AOJu0YxhHOOBTxeFbCZVXPSrG6s+XaCG3ifJoOk2wi36q7oogxKYGc8E 0WOZCdUnscTocdTudMSnYtiCT843XoD2Tima4mVPHgXjs98VxQ9oweBfYmB0g2l+LLo= X-Gm-Gg: ASbGnctZ5wFyGwdIILxFfAfzlPcWpzXJgwJIsOF1ZsVjTnnFreYir3Dq6xJru6gCPvN zFwoZkBZgdJbvXeZTc03lnuhLhukPQVou5Wrr+quxDZy70LQfIH4WiQ/xpQ5LOcYH3EyVZlcq+P ynAsVAWNER+NfqEJgVKODUesOgrXqS1JINvm5SblktQt0R6iEoHY98Ot19cWkixXMQtpGvcfePo Tp+e6N1nS5uehVk2P/jsTxyj58Hf4xumkrzpjtBW/5CBRoo3RNLVmtbjEtDltuxKwFalxmFuiCd zSlIbpVY2fWjVt3+h6pwAaBx5gFTeysjYHByhll5luoRnLIIrdhLyM1OGVPBxN/C/BTU0w1wwgB zGQ6MnAlR5WZADXJ2WhjE+fPorHRBP6tOgA== X-Google-Smtp-Source: AGHT+IETT8Vq/rVcS+uTMt32M+EaHEz3SHHsDUWgNHeMwBTMpLOGts4+upLnLj8sq+C7fMc28zMlxA== X-Received: by 2002:a05:600c:198b:b0:46d:996b:826d with SMTP id 5b1f17b1804b1-46d996b8a43mr12581515e9.34.1758533845258; Mon, 22 Sep 2025 02:37:25 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Palmer Dabbelt , Alexandre Iooss , Mahmoud Mandour , qemu-riscv@nongnu.org, Daniel Henrique Barboza , Thomas Huth , Peter Maydell , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Alistair Francis , qemu-arm@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Weiwei Li , Pierrick Bouvier , Liu Zhiwei , Richard Henderson Subject: [PATCH 15/25] semihosting/arm-compat-semi: compile once in system and per target for user mode Date: Mon, 22 Sep 2025 10:37:00 +0100 Message-ID: <20250922093711.2768983-16-alex.bennee@linaro.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20250922093711.2768983-1-alex.bennee@linaro.org> References: <20250922093711.2768983-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 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: 1758534222291116601 From: Pierrick Bouvier We don't have any target dependency left in system mode, so we can compile once. User mode depends on qemu.h, which is duplicated between linux and bsd, so we can't easily compile it once. Reviewed-by: Richard Henderson Signed-off-by: Pierrick Bouvier Message-ID: <20250822150058.18692-13-pierrick.bouvier@linaro.org> Signed-off-by: Alex Benn=C3=A9e --- semihosting/meson.build | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/semihosting/meson.build b/semihosting/meson.build index bb0db323937..99f10e2e2bb 100644 --- a/semihosting/meson.build +++ b/semihosting/meson.build @@ -12,9 +12,10 @@ system_ss.add(when: 'CONFIG_SEMIHOSTING', if_true: files( 'stubs-system.c', )) system_ss.add(when: 'CONFIG_ARM_COMPATIBLE_SEMIHOSTING', + if_true: files('arm-compat-semi.c'), if_false: files('arm-compat-semi-stub.c')) =20 specific_ss.add(when: ['CONFIG_SEMIHOSTING', 'CONFIG_USER_ONLY'], if_true: files('syscalls.c')) -specific_ss.add(when: ['CONFIG_ARM_COMPATIBLE_SEMIHOSTING'], +specific_ss.add(when: ['CONFIG_ARM_COMPATIBLE_SEMIHOSTING', 'CONFIG_USER_O= NLY'], if_true: files('arm-compat-semi.c')) --=20 2.47.3 From nobody Sun Sep 28 15:30:20 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1758534202; cv=none; d=zohomail.com; s=zohoarc; b=Ufvqf2/pn6wUmBgX7PkzBCJBnKFnoW/nrn3gekaPdDK/q6LboyXmkp0RcZxFR+JnjBHV+tgYmXlgFG1MMhu22TrhmYp5RjYOT1Elfv9FntIYYEz5OWd8Th2Fqai9sFmYOAAYQaf+OpxxRjL9DebdhP4jWYktNxF+WFourzahklI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1758534202; 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=+a3CcA7uLenSBTz2VMDBFRvLVHxH8fqsvjG7VIzS+i8=; b=GXrxMBiaqKy2+lE8Q+gvYzLtjjK2toMriMQcBnpdazYwymz4DFYi3kM9VqjwJMjpJWV6IKahfKNYokWXXoih6aEK19RkmJVaLKQsAMcchpeJ6H+bbv8v93XbgpGime33NVng4tMp7SL5WSwOj2dvstyVB/O62AbW4xBC3AKUCV0= 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 17585342020861011.117604598323; Mon, 22 Sep 2025 02:43:22 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v0d11-0004wi-9Y; Mon, 22 Sep 2025 05:39:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v0czw-0002Z4-Dk for qemu-devel@nongnu.org; Mon, 22 Sep 2025 05:38:19 -0400 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1v0czF-0000h8-Pp for qemu-devel@nongnu.org; Mon, 22 Sep 2025 05:38:13 -0400 Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-46b303f7469so10933715e9.1 for ; Mon, 22 Sep 2025 02:37:32 -0700 (PDT) Received: from draig.lan ([185.126.160.19]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3f61703b206sm8925031f8f.6.2025.09.22.02.37.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Sep 2025 02:37:24 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 15CBF5FA1B; Mon, 22 Sep 2025 10:37:13 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1758533849; x=1759138649; 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=+a3CcA7uLenSBTz2VMDBFRvLVHxH8fqsvjG7VIzS+i8=; b=slf88DH95zqEECNUrRazB52Lmp233bhb3NvOSOT1VGZiC85DbYfwDBp1g/HefOPaGq naJiwha6eI/I8WBSTo11XSsWMH4yFQ15/mZDoXbW+lokAs+uD0wEuWUtjs47v9uamL3/ 0fOlAPKvsxpmBf/u9VFx9yAyCo7ZUweLyRbcibNnORX7qGYAXIYG+saSHqucqL3k1u1/ 6FnHOn7Rd3IC0r7zYe0btLOsPDrYPhE0y+mfy76uiY3lNzk7Yk/m1N9xkP/MUsSCXFYW 18nYAWx/8KLEI6RvXdkswsqeyyIWIHCsyBLSZFGU7KInWSUHrPgBRIy7k33fb0iQn0A2 Pfvw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1758533849; x=1759138649; 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=+a3CcA7uLenSBTz2VMDBFRvLVHxH8fqsvjG7VIzS+i8=; b=b3EtdlI8DvxI+GOLTeIUsxojpZIlbRICRDG+ge1sqYnq2mIdTdGAs8mVjky7IoKuaP nQmnOl7EcqU8u31UcP/KhZezFfb6zgTw03eC/NmrdkzB7oV6w4YI8IsmI1a7Oxa6xFwV b+bnUWqETBWBYecJaHhgXSsJ1oMCaRsHnicKwrP83fpEY42WrkOk+3IP/1a0PBSdaOPE RKnm/WEcqmegBCYtZFFIcNp6ra8ia+QoMHGORSDMFkN8hGpY99040I27EJXxNZyCB9NB unbVqMFKkSO9tHrKO7Gc9pgyfhTqJ0EJTgsjcDSPFnc3/YdXFw0mNibo+x6DffA43XdP iswQ== X-Gm-Message-State: AOJu0YzeBLKAn5vGm4ENdoZQMMq1ySVgOAnabSxbxJA22RjOQNjVx1PA aqYOtzZe2JJ/D76Nyu+S5xlMSozZwf8R3nPaM0iDmPOj0a+74P+FRDH1yRQh2P36YUI= X-Gm-Gg: ASbGncurkMHxelx50VryZn0WDJXLQjws6n8YlBE0yYRZY21dFJFx+Ok+zZAFwQ4m07k sIOFfEomHgdqEp3OWfR7Ukc9F8l9XU+UpGncJtaJTdr+RaQ+tKatWZaZ43iE3Xvouqpp0C2883X qDbPAzzjvv6tmxcfTq2D9Jzf/UiorMKUuJiYE0wmMtpqnnIX2boQ7x+OStbaC6qyOjgyctvSghy jzpMl+FejRD7wGiZ44HCDtCkxeSSyePKSWfjSj2YHqysfUsSjnhd4FId3GXyJFXhEVCAZDuvh4A Q74znv6uXoR35SN5hSZBs4dAy+O4rMCY+7H0OOoM41LPqLKWMcMk1vXgwuzrDDaVNN3PM4JHAHf c9xDJUSm7fLj9PiUjw/hQXQm+NVTu23DpGg== X-Google-Smtp-Source: AGHT+IG3ndmsjU4bbWOAnoNWNzTnJGA31mG1EG0SJnedwU7MQSfWvmNHUqcLH2HPNn1H1Dx3vzcDVg== X-Received: by 2002:a05:6000:2c06:b0:3ec:d78d:8fcc with SMTP id ffacd0b85a97d-3ee7e1059d7mr10967822f8f.14.1758533848798; Mon, 22 Sep 2025 02:37:28 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Palmer Dabbelt , Alexandre Iooss , Mahmoud Mandour , qemu-riscv@nongnu.org, Daniel Henrique Barboza , Thomas Huth , Peter Maydell , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Alistair Francis , qemu-arm@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Weiwei Li , Pierrick Bouvier , Liu Zhiwei Subject: [PATCH 16/25] contrib/plugins/execlog: Explicitly check for qemu_plugin_read_register() failure Date: Mon, 22 Sep 2025 10:37:01 +0100 Message-ID: <20250922093711.2768983-17-alex.bennee@linaro.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20250922093711.2768983-1-alex.bennee@linaro.org> References: <20250922093711.2768983-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, T_SPF_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: 1758534204273116600 From: Peter Maydell In insn_check_regs() we don't explicitly check whether qemu_plugin_read_register() failed, which confuses Coverity into thinking that sz can be -1 in the memcmp(). In fact the assertion that sz =3D=3D reg->last->len means this can't happen, but it's clearer to both humans and Coverity if we explicitly assert that sz > 0, as we already do in init_vcpu_register(). Coverity: CID 1611901, 1611902 Fixes: af6e4e0a22c1 ("contrib/plugins: extend execlog to track register cha= nges") Signed-off-by: Peter Maydell Reviewed-by: Pierrick Bouvier Message-ID: <20250710144543.1187715-1-peter.maydell@linaro.org> Signed-off-by: Alex Benn=C3=A9e --- contrib/plugins/execlog.c | 1 + 1 file changed, 1 insertion(+) diff --git a/contrib/plugins/execlog.c b/contrib/plugins/execlog.c index 06ec76d6e9a..811f3203199 100644 --- a/contrib/plugins/execlog.c +++ b/contrib/plugins/execlog.c @@ -95,6 +95,7 @@ static void insn_check_regs(CPU *cpu) =20 g_byte_array_set_size(reg->new, 0); sz =3D qemu_plugin_read_register(reg->handle, reg->new); + g_assert(sz > 0); g_assert(sz =3D=3D reg->last->len); =20 if (memcmp(reg->last->data, reg->new->data, sz)) { --=20 2.47.3 From nobody Sun Sep 28 15:30:20 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1758534013; cv=none; d=zohomail.com; s=zohoarc; b=SZ2Wqlj7OomPd8WDnoc0+vZNEetp9EWQ2vC8RXnQKSwml8jeVvZBj4/iocheQ2DBnb6IDEEn34h3D/N8EYpOxWIwE6WDVRBEW15HHUqcPJoLNQ8lCG4d5sbp/QHPuNeiOZQcfWTUVqkHJeIF3wZBUh7rKL+AUpagYN9geg5ZSjI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1758534013; 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=6IMWbDFgDEMOUiMUfT2TDkGRm3klPMgO+lre4zsnFwM=; b=ci/jtd6AE0gAI5rE/Ivuh2ews85qNuPAd0g2EAS8jmDFcTu8pZIo5dKhR9KqSwKqss5cSOPplJrXifE4V+k3FBiDqSWsrOE5/8A/c6jhKIGvGRdaUVA7cWM2kA35DURpJ/EgNXw2w2HWA2pWvvz9269yB5yGEXhIbSfELhyph+g= 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 1758534013218235.03070245273614; Mon, 22 Sep 2025 02:40:13 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v0d0y-0004rR-Mn; Mon, 22 Sep 2025 05:39:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v0czs-0002Vm-DQ for qemu-devel@nongnu.org; Mon, 22 Sep 2025 05:38:14 -0400 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 1v0czG-0000gs-El for qemu-devel@nongnu.org; Mon, 22 Sep 2025 05:38:11 -0400 Received: by mail-wr1-x42b.google.com with SMTP id ffacd0b85a97d-3eebc513678so2628968f8f.1 for ; Mon, 22 Sep 2025 02:37:31 -0700 (PDT) Received: from draig.lan ([185.126.160.19]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3fd84338ca2sm4200856f8f.42.2025.09.22.02.37.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Sep 2025 02:37:24 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 2C5255FA29; Mon, 22 Sep 2025 10:37:13 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1758533848; x=1759138648; 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=6IMWbDFgDEMOUiMUfT2TDkGRm3klPMgO+lre4zsnFwM=; b=ylLRNwcsrOhMLbtImmXvXmGlCCW+qQj8xvLlirvqN9JgzkiRd9b2YoFfSbrQ8/w9Ib 8ZcK1JGpazrFwwaUEfbBa2Cgzr4k29u76bF+S2C1uMZ52Q1pkWIWVYFsK4oHumHspEZn WQEi0PCRwGER/U92RIXnmxzvi98EAr5GAOynSFUjgxKcfnuJCWfaQf6mCxMd84vl5Hqc VECnUtF+1Fb1MpQCww7VlRyXSj5EgYvphtOk9OLbw2bfO1pDbtEAS8+9s19wesXc35t7 K2XD0lXCeRPTa2EqyWlTKjg52ri8ZUbKBHsotzLTVu0sJwGpYF0mo7goQX7EWc/YTk0+ Lvsw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1758533848; x=1759138648; 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=6IMWbDFgDEMOUiMUfT2TDkGRm3klPMgO+lre4zsnFwM=; b=nc3HvlMgI6luas33AxOvGG2gEBDDEDXD+EqeT9tyKIA0EnuA65Mj7hGqXcWpUAVn6b LGN3XR34PnvGYJ04/le8CYQL0Z9QUiasmFvdyvfw4PoB6fI3/LiwlR5P3iGOESoB91ti qzAKc0/CoaOoamKAFJ5sIKJqINw9XgCSXq1OK681GLPCbIt9ucDZQGZC2Ll33vVasJoB 9hW2Zai/bFYHS1Cv9VHlty6WiZzxr7j1zCp/XwcStndNJrS+YG/x+rdrwqto7GS6V9a5 AuDRxn4WlYc4tdi6i3d7IY8eAIeQZPs1IssIuNJoKb4vNaELHCZEfvKdewk8eLuRki/T UGhw== X-Gm-Message-State: AOJu0YwBiCTQJ2gRiw3th9NUfe9QVPywS2APvzhkS6BpLNGn0V+dGd9y 8bsNizcKnpBrlVMf9zNibMC54/r6UloajxYxgoy/nmeU8/f+nrjcQ9KmoYZKpknSGHY= X-Gm-Gg: ASbGncvbznGBzevl5HuZCZAGAPsILPTv/KFmlXHR6hGzzGev2QMZZqSDmpgWa8/RIbX r7hXmXTYKrgzByFRAyOhj88/KQtUCeSDh6s7QKP+2+xUYeuqn+Zh8bPuNoJR3ZQDoTFwEqLh69J xnluhD2rfJ/hnpo0XVyLN0cggvO9N0QMWxTM8zAS8hkpYghcCx/TkpoKCBpWEm6fpAL7/YiiwP4 20mfIV7tVVhmSTizRZKjWGBLWjSIOIZzaGpJ921nWTStLdIXC6zECveKJ8A22UqdqbR3TwOCvIq vCWjR1dwnt7oxy3EXxZUflYsQkjybEF3GvyandLDeQ+xBAZEfXWN8khjZFXh2AFdaoA0F+7JZiX WiNqslppupp8aDT9NVai5J/M= X-Google-Smtp-Source: AGHT+IHzcbP4ZgAQ4czQX/WUR2ZTlhWheiedH3ZK+CqlCjpak/wZDsCWom84WogTfvuujwoB7Ghnwg== X-Received: by 2002:a05:6000:42c9:b0:3f7:b7ac:f3aa with SMTP id ffacd0b85a97d-3f7b7acf7e9mr3396731f8f.29.1758533847808; Mon, 22 Sep 2025 02:37:27 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Palmer Dabbelt , Alexandre Iooss , Mahmoud Mandour , qemu-riscv@nongnu.org, Daniel Henrique Barboza , Thomas Huth , Peter Maydell , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Alistair Francis , qemu-arm@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Weiwei Li , Pierrick Bouvier , Liu Zhiwei , Manos Pitsidianakis Subject: [PATCH 17/25] contrib/plugins/uftrace: skeleton file Date: Mon, 22 Sep 2025 10:37:02 +0100 Message-ID: <20250922093711.2768983-18-alex.bennee@linaro.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20250922093711.2768983-1-alex.bennee@linaro.org> References: <20250922093711.2768983-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 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: 1758534015631116600 From: Pierrick Bouvier We define a scoreboard that will hold our data per cpu. As well, we define a buffer per cpu that will be used to read registers and memories in a thread-safe way. For now, we just instrument all instructions with an empty callback. Reviewed-by: Manos Pitsidianakis Signed-off-by: Pierrick Bouvier Message-ID: <20250902075042.223990-2-pierrick.bouvier@linaro.org> Signed-off-by: Alex Benn=C3=A9e --- contrib/plugins/uftrace.c | 73 +++++++++++++++++++++++++++++++++++++ contrib/plugins/meson.build | 3 +- 2 files changed, 75 insertions(+), 1 deletion(-) create mode 100644 contrib/plugins/uftrace.c diff --git a/contrib/plugins/uftrace.c b/contrib/plugins/uftrace.c new file mode 100644 index 00000000000..4af0130b159 --- /dev/null +++ b/contrib/plugins/uftrace.c @@ -0,0 +1,73 @@ +/* + * Copyright (C) 2025, Pierrick Bouvier + * + * Generates a trace compatible with uftrace (similar to uftrace record). + * https://github.com/namhyung/uftrace + * + * See docs/about/emulation.rst|Uftrace for details and examples. + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include +#include + +QEMU_PLUGIN_EXPORT int qemu_plugin_version =3D QEMU_PLUGIN_VERSION; + +typedef struct Cpu { + GByteArray *buf; +} Cpu; + +static struct qemu_plugin_scoreboard *score; + +static void track_callstack(unsigned int cpu_index, void *udata) +{ +} + +static void vcpu_tb_trans(qemu_plugin_id_t id, struct qemu_plugin_tb *tb) +{ + size_t n_insns =3D qemu_plugin_tb_n_insns(tb); + + for (size_t i =3D 0; i < n_insns; i++) { + struct qemu_plugin_insn *insn =3D qemu_plugin_tb_get_insn(tb, i); + + uintptr_t pc =3D qemu_plugin_insn_vaddr(insn); + qemu_plugin_register_vcpu_insn_exec_cb(insn, track_callstack, + QEMU_PLUGIN_CB_R_REGS, + (void *) pc); + } +} + +static void vcpu_init(qemu_plugin_id_t id, unsigned int vcpu_index) +{ + Cpu *cpu =3D qemu_plugin_scoreboard_find(score, vcpu_index); + cpu->buf =3D g_byte_array_new(); +} + +static void vcpu_end(unsigned int vcpu_index) +{ + Cpu *cpu =3D qemu_plugin_scoreboard_find(score, vcpu_index); + g_byte_array_free(cpu->buf, true); + memset(cpu, 0, sizeof(Cpu)); +} + +static void at_exit(qemu_plugin_id_t id, void *data) +{ + for (size_t i =3D 0; i < qemu_plugin_num_vcpus(); ++i) { + vcpu_end(i); + } + + qemu_plugin_scoreboard_free(score); +} + +QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_id_t id, + const qemu_info_t *info, + int argc, char **argv) +{ + score =3D qemu_plugin_scoreboard_new(sizeof(Cpu)); + qemu_plugin_register_vcpu_init_cb(id, vcpu_init); + qemu_plugin_register_atexit_cb(id, at_exit, NULL); + qemu_plugin_register_vcpu_tb_trans_cb(id, vcpu_tb_trans); + + return 0; +} diff --git a/contrib/plugins/meson.build b/contrib/plugins/meson.build index 1876bc78438..7eb3629c95d 100644 --- a/contrib/plugins/meson.build +++ b/contrib/plugins/meson.build @@ -1,5 +1,6 @@ contrib_plugins =3D ['bbv', 'cache', 'cflow', 'drcov', 'execlog', 'hotbloc= ks', - 'hotpages', 'howvec', 'hwprofile', 'ips', 'stoptrigger'] + 'hotpages', 'howvec', 'hwprofile', 'ips', 'stoptrigger', + 'uftrace'] if host_os !=3D 'windows' # lockstep uses socket.h contrib_plugins +=3D 'lockstep' --=20 2.47.3 From nobody Sun Sep 28 15:30:20 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1758534446; cv=none; d=zohomail.com; s=zohoarc; b=liztKcD2fKI2SGp64c2sS3fJUc7O8pkKFLkwsYT0pDnpbOO12dOE3YrbIUVGrpMQeI3TLWAx2ExA0iVx/UfsTHGYabK1/ll0UeAywatVGnmOYacxVRBCbCr2lmbWrPrPhMEZs9iitxqviAiqcVhxR8ZS7eCDn9dwBob7ckhoP70= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1758534446; 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=7GRsJV0VAPOLcd8y8nlS+oqJKDqNktygqxz6o8+pfd4=; b=BIhDnN7ZtOwiPj7CB2FUka74+HVmexPP693lvXq6Ro7TjMMmntiPD0i3ERhWWg11T4RQ35zrFKz9ByEI/doIFoM0nnQHj4pvUWJQjIboxFlOqg+tkODFFEGgJqZSOy1dylwmqbw36mdwHK2dhnJe2ByO1nTYbtgNxASYXGeLOvI= 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 1758534446813576.2021896667203; Mon, 22 Sep 2025 02:47:26 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v0d62-0006Gx-7b; Mon, 22 Sep 2025 05:44:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v0d59-0005Qp-0B for qemu-devel@nongnu.org; Mon, 22 Sep 2025 05:43:39 -0400 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 1v0d4p-0001zy-Il for qemu-devel@nongnu.org; Mon, 22 Sep 2025 05:43:38 -0400 Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-46de78b595dso2364315e9.1 for ; Mon, 22 Sep 2025 02:43:16 -0700 (PDT) Received: from draig.lan ([185.126.160.19]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-464f527d6cdsm220145955e9.12.2025.09.22.02.43.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Sep 2025 02:43:09 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 42BE95FA2E; Mon, 22 Sep 2025 10:37:13 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1758534193; x=1759138993; 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=7GRsJV0VAPOLcd8y8nlS+oqJKDqNktygqxz6o8+pfd4=; b=JQz1DxL8QuRXlkOTtdHivr6qOQRQ7jVEHe1DNBfmnTl2u98Pz36JnbO/Kc0h+pM+Ge iZFjfhckIpEoBmCKj8BnH0/uCGbJ4k0k0+w3xQHOXXlTHwhWx7eNNXx0WHfy0HThXamb LbLlD1Ej5Nrv+R6gQVfk2lRo1/4BnkdjT/7iI3UgFl5gdXZNBBh5tfxplOvA6rEmwmSg zE8McGCoqnUHwex2UIgAgvscTM8tgQWq2Ijs+UBQQSPynoxcxm0oGYVug9I+McQsAXkV h5+s/J/rCy7NxJtPeWtKV834svC6NGFVOW3XErVsdxSBU5xkwZikwZ6i/s/FJKYa7bWU J20g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1758534193; x=1759138993; 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=7GRsJV0VAPOLcd8y8nlS+oqJKDqNktygqxz6o8+pfd4=; b=g6rgVyn1Z2eJAwnGKBMHDO2t+IFQFYvzrYDcey5dZme3GvToo0yBUxKlSFoROqF4oq DAl+gdNbSvnSTYO6rNjlp1Cwrm/AtZ1E/mXT73dhb0Az0ExWDFHu075bBLRGHX7BldKZ lr6zZFo41RUmvdlr7nyPxyqaJGGTfJphVf+8bvokTKQE3ibL+J0e9DqVAODTKhuOX8Pw l6bTaD2xbPcygOpY3K0T0SIpU2+9lje6iv5RFNibn9dtcDVty3fMmOHYcoS1uH5f1sJV h5SZnuT+XeYEN2ePyrESNqEwTeZYFBgAASNQHJZC2USgvFvld1G8aH7YRXeTF+7MSWux iDtg== X-Gm-Message-State: AOJu0Yxn3is+VCJLlb6h9kyOTJ5EXMewa0xbsgxIKNGTYc2t/SyfqmsX 7TLH7f2/pQNElAjbvKV/B1OsAZgTrl/38R9jnlE0OTHtts9VDhm53V0XPpirBrgczMA= X-Gm-Gg: ASbGncsxISy6WL5b+pvWCK/DI6dtJUZYOV2YxT9QRTZPPJO1mIBRtpJ7s3ASNkjCeh7 5IRr3KHtEzMhLYd7VrI73NgPfEYLpwBFgL5iZmER7iu7U9KaDGfjlOCyIOi3FNYjuw0AucEQQaa FeDdYdobr/VhfOXXXG2wxY2lBj6uJ2021Ny7BH1UVghNHAxkAZhKiu6/HZLs2ajatH7RpLuHXmC wGBTHU80KOFHCOTvVO2slXOwsxXqA/ZY2g8awhliJKZ7XZwIMVoHP7T+lEitwwCHsVGi0oYWFbW HQs/ayeKA/Wt7EnEpMB5jwn1xxSY/rjBHDPNKHSXjlV3Fd65lw2RU6Q5982AytqgCK/C0fvmj/m 2rnuazFylXvRF9ftl2NQLjNw= X-Google-Smtp-Source: AGHT+IGog4+Y0WnU5KswDpjQ1MvsxTCEtNhvD3dapvSYl1WAcp7YJ15rUMx6prxALge0mIrPKtA+PA== X-Received: by 2002:a05:600c:3593:b0:45b:8477:de1a with SMTP id 5b1f17b1804b1-467ead67316mr122960165e9.7.1758534193220; Mon, 22 Sep 2025 02:43:13 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Palmer Dabbelt , Alexandre Iooss , Mahmoud Mandour , qemu-riscv@nongnu.org, Daniel Henrique Barboza , Thomas Huth , Peter Maydell , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Alistair Francis , qemu-arm@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Weiwei Li , Pierrick Bouvier , Liu Zhiwei , Manos Pitsidianakis Subject: [PATCH 18/25] contrib/plugins/uftrace: define cpu operations and implement aarch64 Date: Mon, 22 Sep 2025 10:37:03 +0100 Message-ID: <20250922093711.2768983-19-alex.bennee@linaro.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20250922093711.2768983-1-alex.bennee@linaro.org> References: <20250922093711.2768983-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, T_SPF_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: 1758534449284116600 From: Pierrick Bouvier We define a new CpuOps structure that will be used to implement tracking independently of guest architecture. As well, we now instrument only instructions following ones that might have touched the frame pointer. Reviewed-by: Manos Pitsidianakis Signed-off-by: Pierrick Bouvier Message-ID: <20250902075042.223990-3-pierrick.bouvier@linaro.org> Signed-off-by: Alex Benn=C3=A9e --- contrib/plugins/uftrace.c | 114 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 110 insertions(+), 4 deletions(-) diff --git a/contrib/plugins/uftrace.c b/contrib/plugins/uftrace.c index 4af0130b159..d060513446c 100644 --- a/contrib/plugins/uftrace.c +++ b/contrib/plugins/uftrace.c @@ -11,14 +11,94 @@ =20 #include #include +#include =20 QEMU_PLUGIN_EXPORT int qemu_plugin_version =3D QEMU_PLUGIN_VERSION; =20 +typedef struct Cpu Cpu; + +typedef struct { + void (*init)(Cpu *cpu); + void (*end)(Cpu *cpu); + uint64_t (*get_frame_pointer)(Cpu *cpu); + bool (*does_insn_modify_frame_pointer)(const char *disas); +} CpuOps; + typedef struct Cpu { GByteArray *buf; + CpuOps ops; + void *arch; } Cpu; =20 +typedef struct { + struct qemu_plugin_register *reg_fp; +} Aarch64Cpu; + static struct qemu_plugin_scoreboard *score; +static CpuOps arch_ops; + +static uint64_t cpu_read_register64(Cpu *cpu, struct qemu_plugin_register = *reg) +{ + GByteArray *buf =3D cpu->buf; + g_byte_array_set_size(buf, 0); + size_t sz =3D qemu_plugin_read_register(reg, buf); + g_assert(sz =3D=3D 8); + g_assert(buf->len =3D=3D 8); + return *((uint64_t *) buf->data); +} + +static struct qemu_plugin_register *plugin_find_register(const char *name) +{ + g_autoptr(GArray) regs =3D qemu_plugin_get_registers(); + for (int i =3D 0; i < regs->len; ++i) { + qemu_plugin_reg_descriptor *reg; + reg =3D &g_array_index(regs, qemu_plugin_reg_descriptor, i); + if (!strcmp(reg->name, name)) { + return reg->handle; + } + } + return NULL; +} + +static uint64_t aarch64_get_frame_pointer(Cpu *cpu_) +{ + Aarch64Cpu *cpu =3D cpu_->arch; + return cpu_read_register64(cpu_, cpu->reg_fp); +} + +static void aarch64_init(Cpu *cpu_) +{ + Aarch64Cpu *cpu =3D g_new0(Aarch64Cpu, 1); + cpu_->arch =3D cpu; + cpu->reg_fp =3D plugin_find_register("x29"); + if (!cpu->reg_fp) { + fprintf(stderr, "uftrace plugin: frame pointer register (x29) is n= ot " + "available. Please use an AArch64 cpu (or -cpu max= ).\n"); + g_abort(); + } +} + +static void aarch64_end(Cpu *cpu) +{ + g_free(cpu->arch); +} + +static bool aarch64_does_insn_modify_frame_pointer(const char *disas) +{ + /* + * Check if current instruction concerns fp register "x29". + * We add a prefix space to make sure we don't match addresses dump + * in disassembly. + */ + return strstr(disas, " x29"); +} + +static CpuOps aarch64_ops =3D { + .init =3D aarch64_init, + .end =3D aarch64_end, + .get_frame_pointer =3D aarch64_get_frame_pointer, + .does_insn_modify_frame_pointer =3D aarch64_does_insn_modify_frame_poi= nter, +}; =20 static void track_callstack(unsigned int cpu_index, void *udata) { @@ -28,19 +108,37 @@ static void vcpu_tb_trans(qemu_plugin_id_t id, struct = qemu_plugin_tb *tb) { size_t n_insns =3D qemu_plugin_tb_n_insns(tb); =20 + /* + * Callbacks and inline instrumentation are inserted before an instruc= tion. + * Thus, to see instruction effect, we need to wait for next one. + * Potentially, the last instruction of a block could modify the frame + * pointer. Thus, we need to always instrument first instruction in a = tb. + */ + bool instrument_insn =3D true; for (size_t i =3D 0; i < n_insns; i++) { struct qemu_plugin_insn *insn =3D qemu_plugin_tb_get_insn(tb, i); =20 - uintptr_t pc =3D qemu_plugin_insn_vaddr(insn); - qemu_plugin_register_vcpu_insn_exec_cb(insn, track_callstack, - QEMU_PLUGIN_CB_R_REGS, - (void *) pc); + if (instrument_insn) { + uintptr_t pc =3D qemu_plugin_insn_vaddr(insn); + qemu_plugin_register_vcpu_insn_exec_cb(insn, track_callstack, + QEMU_PLUGIN_CB_R_REGS, + (void *) pc); + instrument_insn =3D false; + } + + char *disas =3D qemu_plugin_insn_disas(insn); + if (arch_ops.does_insn_modify_frame_pointer(disas)) { + instrument_insn =3D true; + } } } =20 static void vcpu_init(qemu_plugin_id_t id, unsigned int vcpu_index) { Cpu *cpu =3D qemu_plugin_scoreboard_find(score, vcpu_index); + cpu->ops =3D arch_ops; + + cpu->ops.init(cpu); cpu->buf =3D g_byte_array_new(); } =20 @@ -64,6 +162,14 @@ QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_= id_t id, const qemu_info_t *info, int argc, char **argv) { + if (!strcmp(info->target_name, "aarch64")) { + arch_ops =3D aarch64_ops; + } else { + fprintf(stderr, "plugin uftrace: %s target is not supported\n", + info->target_name); + return 1; + } + score =3D qemu_plugin_scoreboard_new(sizeof(Cpu)); qemu_plugin_register_vcpu_init_cb(id, vcpu_init); qemu_plugin_register_atexit_cb(id, at_exit, NULL); --=20 2.47.3 From nobody Sun Sep 28 15:30:20 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1758534338; cv=none; d=zohomail.com; s=zohoarc; b=mBcBDw6aa4jZbzdRgoWtJ/baNKS7I5atKqpr/P/068LXyoF9gNluiikMn+6bhg6PXSraiOA1QtyMnJ28zYH+4o6KaUzZVRGddF/A6TN/1Y4o6VYAECUCIXdMnYRrIGk+E665vEdJ01VqDcFp625EuqGbg0ogaRnpzdAfTs2IuWs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1758534338; 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=wwmopQy5poKTlF9P1QjQmB8FAMOd4qFHdrOJJCzmIwA=; b=DbN6UKh7vDC/WMNQ6FoV4jE3feN45iaBAFxj/OZGsPHziuy2ik9gAAOCA/gpoSVHVc8Ntl+QNx2BU7vjbj+rhRECPfEkhdCtqiAoGp9QYsYyWbNq8AeO2DYAWG+vYQVw4qo6/ZMivAPwtlwz1H+3/Y+wXeTI6vsZ4GZOP7Wc7sY= 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 1758534338234654.6268613279656; Mon, 22 Sep 2025 02:45:38 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v0d69-0006sR-Bc; Mon, 22 Sep 2025 05:44:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v0d50-0005GA-B6 for qemu-devel@nongnu.org; Mon, 22 Sep 2025 05:43:31 -0400 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 1v0d4p-0001zr-0k for qemu-devel@nongnu.org; Mon, 22 Sep 2025 05:43:30 -0400 Received: by mail-wr1-x42d.google.com with SMTP id ffacd0b85a97d-3f0ae439b56so1933637f8f.3 for ; Mon, 22 Sep 2025 02:43:16 -0700 (PDT) Received: from draig.lan ([185.126.160.19]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3ee0fbefd5csm20259833f8f.51.2025.09.22.02.43.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Sep 2025 02:43:09 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 5A0265F8B9; Mon, 22 Sep 2025 10:37:13 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1758534194; x=1759138994; 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=wwmopQy5poKTlF9P1QjQmB8FAMOd4qFHdrOJJCzmIwA=; b=TgCHgNuO7FPyalq3hLwOu9mLbNY4Yn5+9r2FxqQrG62oKz1FZgpJiF313rgEAj2SVH R+qaFY977hlXqS/gyXUfW6nnMQh9ptBpWZN2iTxI47nacVNcQqldxlRm/qGoIJybu5AL dx43dhsChvn3L1ZroI3cyk5zKq7qx4lxjHO4KAQMMOtuSPwGEto6HGbRiAngmVmZNESg rPoPgWu+DU0vWwPQjTNN5y1D0aonfjLTcjyY7wqKp3QoqaiLzR47OMopQNn0LFXW5GCa z5M9dXxon4lYqwzEylnYDXKcquZB4g+aEYdMid2AQpp419bFmM+cHTSDv5d/uMNWHbLs 9n1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1758534194; x=1759138994; 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=wwmopQy5poKTlF9P1QjQmB8FAMOd4qFHdrOJJCzmIwA=; b=ZMr0aXJxeDkWzu8bH7BxHrI5+ox/MWb7AFFXtKmyRzMKEl3b5o5wr2Pnqnpsk2K2zE bzXptkDWF8DIkpI+tPuDo5ZQITbAtbTBdn6r7KVq2ukygmRInmyR3PW6ljVuRuhoEiy4 3DQVcaXa1zx8YPlR8vSdk8WHA74qnjSFphQj+mX+q5LCHGKakL2JL713CKGuC3LJE8Nn 7WKDeolW4iyhrNB5RwLMsLTseQWN3lCRfOXaD9wj/5jGqi9BA5LN5zkoGFE/foIy8W5e TJDe0MCq1gLZuHZ5Hkzu583DLAFD2YTQwEBBVk55t11Dv6c6wmH3PwTW/G0Su7ouW/FG IPZA== X-Gm-Message-State: AOJu0YxVXJyI73qCUBEdA9zlChgKnLZXZ0zd7YOG/JXPn66iHFlqGC2A uYJdpsDrcQrvqeS+V7Tdvt5MAEQfbYSaYn5EGEo4fvc1Joo5AiAj7GoRxSg9dskxrTU= X-Gm-Gg: ASbGncu657Qa1W7Fzu/xBUB5tvE3QulrmAT/EK+I7BKfd+dIRA9B+jsyJ6CHCMM3WD5 nAf2D6vf1IlIKli1+kaPM0vaN/4jOZLVHyn2+Uk41rKsBj5tkIQ18DNs9p1VHTNE9OSNAUSTWoJ 5o5OkPSCLUaE5H5FNB7765ZvAVI+3tQbnSl+hbXRiKwElWx6YjwlPGxNSHThcnVGXnSHYbk/TCW uR/62CZ8J+cj7a7ciiGgEyAcZ5l9iL6N85AnjpTEVqBwh3K2K27C7ewzcZgtfIK61fW1La7nIRf 7VpCLhRduvKgPD26C19bYc4iYipNOmUtpO6aWBuWOK2xOOZVFTl/sDYzWKBsRaai6m4jf4E0adJ PMPUj4EA0tiStba0uezEdIA0= X-Google-Smtp-Source: AGHT+IHMb7n8NgsSwTEBDg3Np3NqZkfBfUKE8Q9bExmdMOlV/5F5WjvCwT/FYoiST7DXBexP9nLiFQ== X-Received: by 2002:a05:6000:18a8:b0:3e7:ff32:1ab with SMTP id ffacd0b85a97d-3ee852a42a5mr10908154f8f.50.1758534194033; Mon, 22 Sep 2025 02:43:14 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Palmer Dabbelt , Alexandre Iooss , Mahmoud Mandour , qemu-riscv@nongnu.org, Daniel Henrique Barboza , Thomas Huth , Peter Maydell , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Alistair Francis , qemu-arm@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Weiwei Li , Pierrick Bouvier , Liu Zhiwei , Manos Pitsidianakis Subject: [PATCH 19/25] contrib/plugins/uftrace: track callstack Date: Mon, 22 Sep 2025 10:37:04 +0100 Message-ID: <20250922093711.2768983-20-alex.bennee@linaro.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20250922093711.2768983-1-alex.bennee@linaro.org> References: <20250922093711.2768983-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 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: 1758534339916116600 From: Pierrick Bouvier We now track callstack, based on frame pointer analysis. We can detect function calls, returns, and discontinuities. We implement a frame pointer based unwinding that is used for discontinuities. Reviewed-by: Manos Pitsidianakis Signed-off-by: Pierrick Bouvier Message-ID: <20250902075042.223990-4-pierrick.bouvier@linaro.org> Signed-off-by: Alex Benn=C3=A9e --- contrib/plugins/uftrace.c | 160 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 160 insertions(+) diff --git a/contrib/plugins/uftrace.c b/contrib/plugins/uftrace.c index d060513446c..bb775916270 100644 --- a/contrib/plugins/uftrace.c +++ b/contrib/plugins/uftrace.c @@ -15,6 +15,15 @@ =20 QEMU_PLUGIN_EXPORT int qemu_plugin_version =3D QEMU_PLUGIN_VERSION; =20 +typedef struct { + GArray *s; +} Callstack; + +typedef struct { + uint64_t pc; + uint64_t frame_pointer; +} CallstackEntry; + typedef struct Cpu Cpu; =20 typedef struct { @@ -25,6 +34,7 @@ typedef struct { } CpuOps; =20 typedef struct Cpu { + Callstack *cs; GByteArray *buf; CpuOps ops; void *arch; @@ -37,6 +47,71 @@ typedef struct { static struct qemu_plugin_scoreboard *score; static CpuOps arch_ops; =20 +static Callstack *callstack_new(void) +{ + Callstack *cs =3D g_new0(Callstack, 1); + cs->s =3D g_array_new(false, false, sizeof(CallstackEntry)); + return cs; +} + +static void callstack_free(Callstack *cs) +{ + g_array_free(cs->s, true); + cs->s =3D NULL; + g_free(cs); +} + +static size_t callstack_depth(const Callstack *cs) +{ + return cs->s->len; +} + +static size_t callstack_empty(const Callstack *cs) +{ + return callstack_depth(cs) =3D=3D 0; +} + +static void callstack_clear(Callstack *cs) +{ + g_array_set_size(cs->s, 0); +} + +static const CallstackEntry *callstack_at(const Callstack *cs, size_t dept= h) +{ + g_assert(depth > 0); + g_assert(depth <=3D callstack_depth(cs)); + return &g_array_index(cs->s, CallstackEntry, depth - 1); +} + +static CallstackEntry callstack_top(const Callstack *cs) +{ + if (callstack_depth(cs) >=3D 1) { + return *callstack_at(cs, callstack_depth(cs)); + } + return (CallstackEntry){}; +} + +static CallstackEntry callstack_caller(const Callstack *cs) +{ + if (callstack_depth(cs) >=3D 2) { + return *callstack_at(cs, callstack_depth(cs) - 1); + } + return (CallstackEntry){}; +} + +static void callstack_push(Callstack *cs, CallstackEntry e) +{ + g_array_append_val(cs->s, e); +} + +static CallstackEntry callstack_pop(Callstack *cs) +{ + g_assert(!callstack_empty(cs)); + CallstackEntry e =3D callstack_top(cs); + g_array_set_size(cs->s, callstack_depth(cs) - 1); + return e; +} + static uint64_t cpu_read_register64(Cpu *cpu, struct qemu_plugin_register = *reg) { GByteArray *buf =3D cpu->buf; @@ -47,6 +122,50 @@ static uint64_t cpu_read_register64(Cpu *cpu, struct qe= mu_plugin_register *reg) return *((uint64_t *) buf->data); } =20 +static uint64_t cpu_read_memory64(Cpu *cpu, uint64_t addr) +{ + g_assert(addr); + GByteArray *buf =3D cpu->buf; + g_byte_array_set_size(buf, 0); + bool read =3D qemu_plugin_read_memory_vaddr(addr, buf, 8); + if (!read) { + return 0; + } + g_assert(buf->len =3D=3D 8); + return *((uint64_t *) buf->data); +} + +static void cpu_unwind_stack(Cpu *cpu, uint64_t frame_pointer, uint64_t pc) +{ + g_assert(callstack_empty(cpu->cs)); + + #define UNWIND_STACK_MAX_DEPTH 1024 + CallstackEntry unwind[UNWIND_STACK_MAX_DEPTH]; + size_t depth =3D 0; + do { + /* check we don't have an infinite stack */ + for (size_t i =3D 0; i < depth; ++i) { + if (frame_pointer =3D=3D unwind[i].frame_pointer) { + break; + } + } + CallstackEntry e =3D {.frame_pointer =3D frame_pointer, .pc =3D pc= }; + unwind[depth] =3D e; + depth++; + if (frame_pointer) { + frame_pointer =3D cpu_read_memory64(cpu, frame_pointer); + } + pc =3D cpu_read_memory64(cpu, frame_pointer + 8); /* read previous= lr */ + } while (frame_pointer && pc && depth < UNWIND_STACK_MAX_DEPTH); + #undef UNWIND_STACK_MAX_DEPTH + + /* push it from bottom to top */ + while (depth) { + callstack_push(cpu->cs, unwind[depth - 1]); + --depth; + } +} + static struct qemu_plugin_register *plugin_find_register(const char *name) { g_autoptr(GArray) regs =3D qemu_plugin_get_registers(); @@ -102,6 +221,43 @@ static CpuOps aarch64_ops =3D { =20 static void track_callstack(unsigned int cpu_index, void *udata) { + uint64_t pc =3D (uintptr_t) udata; + Cpu *cpu =3D qemu_plugin_scoreboard_find(score, cpu_index); + Callstack *cs =3D cpu->cs; + + uint64_t fp =3D cpu->ops.get_frame_pointer(cpu); + if (!fp && callstack_empty(cs)) { + /* + * We simply push current pc. Note that we won't detect symbol cha= nge as + * long as a proper call does not happen. + */ + callstack_push(cs, (CallstackEntry){.frame_pointer =3D fp, .pc =3D= pc}); + return; + } + + CallstackEntry top =3D callstack_top(cs); + if (fp =3D=3D top.frame_pointer) { + /* same function */ + return; + } + + CallstackEntry caller =3D callstack_caller(cs); + if (fp =3D=3D caller.frame_pointer) { + /* return */ + callstack_pop(cs); + return; + } + + uint64_t caller_fp =3D fp ? cpu_read_memory64(cpu, fp) : 0; + if (caller_fp =3D=3D top.frame_pointer) { + /* call */ + callstack_push(cs, (CallstackEntry){.frame_pointer =3D fp, .pc =3D= pc}); + return; + } + + /* discontinuity, exit current stack and unwind new one */ + callstack_clear(cs); + cpu_unwind_stack(cpu, fp, pc); } =20 static void vcpu_tb_trans(qemu_plugin_id_t id, struct qemu_plugin_tb *tb) @@ -140,12 +296,16 @@ static void vcpu_init(qemu_plugin_id_t id, unsigned i= nt vcpu_index) =20 cpu->ops.init(cpu); cpu->buf =3D g_byte_array_new(); + + cpu->cs =3D callstack_new(); } =20 static void vcpu_end(unsigned int vcpu_index) { Cpu *cpu =3D qemu_plugin_scoreboard_find(score, vcpu_index); g_byte_array_free(cpu->buf, true); + + callstack_free(cpu->cs); memset(cpu, 0, sizeof(Cpu)); } =20 --=20 2.47.3 From nobody Sun Sep 28 15:30:20 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1758534411; cv=none; d=zohomail.com; s=zohoarc; b=OwgHIB57d/sTodTWX3vEw2e6mtBVAmSYUev7wCr1WyR5ulzqTCI1fXxPA8wW7hhyJluvBhtdyFZX4pmaCjW2kGIcRBTCYVzDuucYP4D9RpEVK5lrEU0ytq45E3gzGDyPuQq9Qh1vuZrq3dzxMNjd96akSlXKu0MXO9b6FUzHRME= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1758534411; 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=COW9Y8xwuzCyUVpCahD7I0T5DWgjtjyjaT4BE1jdt0E=; b=Y4QVxbRpSJvqH1OuSw6Mq+4UiKKmDs8m34VThRuCzd3Ao/efz39Tni5yVtogjGzC3zw7SPs3RB0FbCC+JpuQqmLeLqqbcIHya3pdax501/vRbIDix+khYaRBPICNPii6T/dX536DTl0MIiFHbGU8vihfNRyn3GytRJ+qH79919Y= 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 1758534411680224.36463194534394; Mon, 22 Sep 2025 02:46:51 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v0d65-0006ZU-KM; Mon, 22 Sep 2025 05:44:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v0d4z-0005Do-QM for qemu-devel@nongnu.org; Mon, 22 Sep 2025 05:43:31 -0400 Received: from mail-wr1-x435.google.com ([2a00:1450:4864:20::435]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1v0d4m-0001yo-Qa for qemu-devel@nongnu.org; Mon, 22 Sep 2025 05:43:24 -0400 Received: by mail-wr1-x435.google.com with SMTP id ffacd0b85a97d-3f2cf786abeso1430878f8f.3 for ; Mon, 22 Sep 2025 02:43:12 -0700 (PDT) Received: from draig.lan ([185.126.160.19]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-464f5a2850csm194393615e9.19.2025.09.22.02.43.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Sep 2025 02:43:09 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 73C535FA31; Mon, 22 Sep 2025 10:37:13 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1758534191; x=1759138991; 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=COW9Y8xwuzCyUVpCahD7I0T5DWgjtjyjaT4BE1jdt0E=; b=DXtx0A9bqs5FjoJS3pFUV4NgOPfSWArZfvkcbWmCqtGe0y/X6lUqFW87p08sPZB4kV pgCpIuCMhXqUzSY5aDtOa854GfwJSRLI/Q0X0nFpoxRm4Wrcno2PSslCAbV68VC6+zF9 DcUr77JXlMlg16V/4/WWhUOeoC+V0XVCKVNIyRb9N7RcsiIlJwJLry9xVYqchrotzvgZ fHnZIidbdIy1bn7H5sAq9WO9sVUFmOYUQs4k2/4ZeqzVfcAPMjV3J1/MnUtK6bqZt+ub 6LD0JrrsRKUIl6181y1POHvw4WopvTit5/FUZgw2NlCu+RaBdk0xHrnUgrkmPxLkM4+a rGcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1758534191; x=1759138991; 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=COW9Y8xwuzCyUVpCahD7I0T5DWgjtjyjaT4BE1jdt0E=; b=o63Fg289D5YGrCkzfwtYxlTPSnWV8/PQ9OR6v78WkbH9EDlwjOe37OgvyfG7BtC9eA 5YCd0cZhIbZrvhfAq4uukt7gYBNSAVFR9zXi9V4Fkw2iHEHRteqaOwvbujEnZa3ZTEyT rKJYcwSQlafNg/3BjQuA5UopB7pH92bgbxCW8FDcxTj+8LMyVyFDtQ5X6ujhaWsbRYPo Pjih5SXxAKKJnquZRDftV6hc/q85GcXCS6N3u13yaxKpL0WCGsQyDxQIRdnsyzi2p984 C7p0SiAGs1GzcxYf9xPQfxGcgRg5xmlhBOemcjhC2VFtvYqQZbbUYYWqoMMHgQOKVZeB u3Vw== X-Gm-Message-State: AOJu0YzzqVJ1G5IY2owr1ridFlu0NwmPskkWvCNhLxqWZlJnHdHYQlYK Cz2hkC4taJQIZYcs5CNACHT4XgwArncuU4HGFTJ/Xd2YunBE7wjV/LnSPiCF2UMz5A8= X-Gm-Gg: ASbGnctevpEpuV349fgiX/58x/RUS608Mag5y6lqiPh+kbIFUzVK5W2DLAtEqf5ZlcU lNlHWMEQvgUqY1MxXCcBYJ+uEBExug4gMfPJaTZatt5UzTBi/y4ZKVPSvANqneHOKHD+sRILgi4 P8aCACIYa9Y74RpwyudIffn98OLW/Z+icRpsyGxPPLw89btK+vS1GYjYXeffl73YII651+i24rH dTYLYJyjSV5Ik2hERn2dyVZu7yIiIn4VhU+Y/Rfc1qxpGJNHc3Xjq1mgktZRv7u/cAuhhoMpay7 iVHi5dm6XD5XXc5+SpwayBdW/KsxYZtckodXk+U1q1ddjKqf/Aa1pGXzWhrMCRaYw7bTibjtu43 vDpGZojXXJTB0aqtRQEu+uxw= X-Google-Smtp-Source: AGHT+IHLbjUF8i0k/tPt7x/Uu2eYY7Q6S0uvgkPi5mtaus/cinWWpe0hTy804rS6nd6Sv5iO7mnudw== X-Received: by 2002:a05:6000:4210:b0:3e7:6197:9947 with SMTP id ffacd0b85a97d-3ee868a74bamr10869516f8f.53.1758534191147; Mon, 22 Sep 2025 02:43:11 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Palmer Dabbelt , Alexandre Iooss , Mahmoud Mandour , qemu-riscv@nongnu.org, Daniel Henrique Barboza , Thomas Huth , Peter Maydell , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Alistair Francis , qemu-arm@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Weiwei Li , Pierrick Bouvier , Liu Zhiwei Subject: [PATCH 20/25] contrib/plugins/uftrace: implement tracing Date: Mon, 22 Sep 2025 10:37:05 +0100 Message-ID: <20250922093711.2768983-21-alex.bennee@linaro.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20250922093711.2768983-1-alex.bennee@linaro.org> References: <20250922093711.2768983-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::435; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x435.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=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: 1758534412680116600 From: Pierrick Bouvier We implement tracing, following uftrace format. Trace is flushed every 32 MB, so file operations don't impact performance at runtime. A different trace is generated per cpu, and we ensure they have a unique name, based on vcpu_index, while keeping room for privilege level coming in next commit. Uftrace format is not officially documented, but it can be found here: https://github.com/namhyung/uftrace/blob/v0.18/libmcount/record.c#L909 Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Pierrick Bouvier Message-ID: <20250902075042.223990-5-pierrick.bouvier@linaro.org> Signed-off-by: Alex Benn=C3=A9e --- contrib/plugins/uftrace.c | 152 +++++++++++++++++++++++++++++++++++++- 1 file changed, 151 insertions(+), 1 deletion(-) diff --git a/contrib/plugins/uftrace.c b/contrib/plugins/uftrace.c index bb775916270..b9dcd531987 100644 --- a/contrib/plugins/uftrace.c +++ b/contrib/plugins/uftrace.c @@ -12,6 +12,15 @@ #include #include #include +#include +#include +#include +#include + +#define MiB (INT64_C(1) << 20) +#define NANOSECONDS_PER_SECOND 1000000000LL +#define TRACE_FLUSH_SIZE (32 * MiB) +#define TRACE_ID_SCALE 100 =20 QEMU_PLUGIN_EXPORT int qemu_plugin_version =3D QEMU_PLUGIN_VERSION; =20 @@ -24,6 +33,13 @@ typedef struct { uint64_t frame_pointer; } CallstackEntry; =20 +typedef struct { + GArray *t; + GString *path; + GString *name; + uint32_t id; +} Trace; + typedef struct Cpu Cpu; =20 typedef struct { @@ -34,6 +50,7 @@ typedef struct { } CpuOps; =20 typedef struct Cpu { + Trace *trace; Callstack *cs; GByteArray *buf; CpuOps ops; @@ -44,9 +61,41 @@ typedef struct { struct qemu_plugin_register *reg_fp; } Aarch64Cpu; =20 +typedef struct { + uint64_t timestamp; + uint64_t data; +} UftraceEntry; + +typedef enum { + UFTRACE_ENTRY, + UFTRACE_EXIT, + UFTRACE_LOST, + UFTRACE_EVENT, +} UftraceRecordType; + static struct qemu_plugin_scoreboard *score; static CpuOps arch_ops; =20 +static uint64_t gettime_ns(void) +{ +#ifdef _WIN32 + /* + * On Windows, timespec_get is available only with UCRT, but not with + * MinGW64 environment. Simplify by using only gettimeofday on this + * platform. This may result in a precision loss. + */ + struct timeval tv; + gettimeofday(&tv, NULL); + uint64_t now_ns =3D tv.tv_sec * NANOSECONDS_PER_SECOND + tv.tv_usec * = 1000; +#else + /* We need nanosecond precision for short lived functions. */ + struct timespec ts; + timespec_get(&ts, TIME_UTC); + uint64_t now_ns =3D ts.tv_sec * NANOSECONDS_PER_SECOND + ts.tv_nsec; +#endif + return now_ns; +} + static Callstack *callstack_new(void) { Callstack *cs =3D g_new0(Callstack, 1); @@ -112,6 +161,86 @@ static CallstackEntry callstack_pop(Callstack *cs) return e; } =20 +static Trace *trace_new(uint32_t id, GString *name) +{ + Trace *t =3D g_new0(Trace, 1); + t->t =3D g_array_new(false, false, sizeof(UftraceEntry)); + t->path =3D g_string_new(NULL); + g_string_append_printf(t->path, "./uftrace.data/%"PRIu32".dat", id); + t->name =3D g_string_new(name->str); + t->id =3D id; + return t; +} + +static void trace_free(Trace *t) +{ + g_assert(t->t->len =3D=3D 0); + g_array_free(t->t, true); + t->t =3D NULL; + g_string_free(t->path, true); + t->path =3D NULL; + g_string_free(t->name, true); + t->name =3D NULL; + g_free(t); +} + +static void trace_flush(Trace *t, bool append) +{ + int create_dir =3D g_mkdir_with_parents("./uftrace.data", + S_IRWXU | S_IRWXG | S_IRWXO); + g_assert(create_dir =3D=3D 0); + FILE *dat =3D fopen(t->path->str, append ? "a" : "w"); + g_assert(dat); + GArray *data =3D t->t; + if (data->len) { + size_t wrote =3D fwrite(data->data, sizeof(UftraceEntry), data->le= n, dat); + g_assert(wrote =3D=3D data->len); + } + fclose(dat); + g_array_set_size(data, 0); +} + +static void trace_add_entry(Trace *t, uint64_t timestamp, uint64_t pc, + size_t depth, UftraceRecordType type) +{ + /* https://github.com/namhyung/uftrace/blob/v0.18/libmcount/record.c#L= 909 */ + const uint64_t record_magic =3D 0x5; + uint64_t data =3D type | (record_magic << 3); + data +=3D depth << 6; + data +=3D pc << 16; + UftraceEntry e =3D {.timestamp =3D timestamp, .data =3D data}; + g_array_append_val(t->t, e); + if (t->t->len * sizeof(UftraceEntry) > TRACE_FLUSH_SIZE) { + trace_flush(t, true); + } +} + +static void trace_enter_function(Trace *t, uint64_t timestamp, + uint64_t pc, size_t depth) +{ + trace_add_entry(t, timestamp, pc, depth, UFTRACE_ENTRY); +} + +static void trace_exit_function(Trace *t, uint64_t timestamp, + uint64_t pc, size_t depth) +{ + trace_add_entry(t, timestamp, pc, depth, UFTRACE_EXIT); +} + +static void trace_enter_stack(Trace *t, Callstack *cs, uint64_t timestamp) +{ + for (size_t depth =3D 1; depth <=3D callstack_depth(cs); ++depth) { + trace_enter_function(t, timestamp, callstack_at(cs, depth)->pc, de= pth); + } +} + +static void trace_exit_stack(Trace *t, Callstack *cs, uint64_t timestamp) +{ + for (size_t depth =3D callstack_depth(cs); depth > 0; --depth) { + trace_exit_function(t, timestamp, callstack_at(cs, depth)->pc, dep= th); + } +} + static uint64_t cpu_read_register64(Cpu *cpu, struct qemu_plugin_register = *reg) { GByteArray *buf =3D cpu->buf; @@ -223,7 +352,9 @@ static void track_callstack(unsigned int cpu_index, voi= d *udata) { uint64_t pc =3D (uintptr_t) udata; Cpu *cpu =3D qemu_plugin_scoreboard_find(score, cpu_index); + uint64_t timestamp =3D gettime_ns(); Callstack *cs =3D cpu->cs; + Trace *t =3D cpu->trace; =20 uint64_t fp =3D cpu->ops.get_frame_pointer(cpu); if (!fp && callstack_empty(cs)) { @@ -232,6 +363,7 @@ static void track_callstack(unsigned int cpu_index, voi= d *udata) * long as a proper call does not happen. */ callstack_push(cs, (CallstackEntry){.frame_pointer =3D fp, .pc =3D= pc}); + trace_enter_function(t, timestamp, pc, callstack_depth(cs)); return; } =20 @@ -244,7 +376,8 @@ static void track_callstack(unsigned int cpu_index, voi= d *udata) CallstackEntry caller =3D callstack_caller(cs); if (fp =3D=3D caller.frame_pointer) { /* return */ - callstack_pop(cs); + CallstackEntry e =3D callstack_pop(cs); + trace_exit_function(t, timestamp, e.pc, callstack_depth(cs)); return; } =20 @@ -252,12 +385,16 @@ static void track_callstack(unsigned int cpu_index, v= oid *udata) if (caller_fp =3D=3D top.frame_pointer) { /* call */ callstack_push(cs, (CallstackEntry){.frame_pointer =3D fp, .pc =3D= pc}); + trace_enter_function(t, timestamp, pc, callstack_depth(cs)); return; } =20 /* discontinuity, exit current stack and unwind new one */ + trace_exit_stack(t, cs, timestamp); callstack_clear(cs); + cpu_unwind_stack(cpu, fp, pc); + trace_enter_stack(t, cs, timestamp); } =20 static void vcpu_tb_trans(qemu_plugin_id_t id, struct qemu_plugin_tb *tb) @@ -297,6 +434,16 @@ static void vcpu_init(qemu_plugin_id_t id, unsigned in= t vcpu_index) cpu->ops.init(cpu); cpu->buf =3D g_byte_array_new(); =20 + g_assert(vcpu_index < UINT32_MAX / TRACE_ID_SCALE); + /* trace_id is: cpu_number * TRACE_ID_SCALE */ + uint32_t trace_id =3D (vcpu_index + 1) * TRACE_ID_SCALE; + + g_autoptr(GString) trace_name =3D g_string_new(NULL); + g_string_append_printf(trace_name, "cpu%u", vcpu_index); + cpu->trace =3D trace_new(trace_id, trace_name); + /* create/truncate trace file */ + trace_flush(cpu->trace, false); + cpu->cs =3D callstack_new(); } =20 @@ -305,6 +452,7 @@ static void vcpu_end(unsigned int vcpu_index) Cpu *cpu =3D qemu_plugin_scoreboard_find(score, vcpu_index); g_byte_array_free(cpu->buf, true); =20 + trace_free(cpu->trace); callstack_free(cpu->cs); memset(cpu, 0, sizeof(Cpu)); } @@ -312,6 +460,8 @@ static void vcpu_end(unsigned int vcpu_index) static void at_exit(qemu_plugin_id_t id, void *data) { for (size_t i =3D 0; i < qemu_plugin_num_vcpus(); ++i) { + Cpu *cpu =3D qemu_plugin_scoreboard_find(score, i); + trace_flush(cpu->trace, true); vcpu_end(i); } =20 --=20 2.47.3 From nobody Sun Sep 28 15:30:20 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1758534241; cv=none; d=zohomail.com; s=zohoarc; b=jxm5FyL/kLilBZ9mkR9mmdNPJ3GW8G1l7t0pLMfTVDDhailFcPTIXQujEulFe5UqJi4gUmVwmZHbEdeimCNTNR6pgav6ZcNa5UcX1IoHF/yQraOJfIf28KGHRW40rxLyfZ2HCROAnlxz0YYNFDgo14sIF9kstspPHuirjPwDKSI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1758534241; 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=RYNYIu8+be0QQyu0ldhaTLfitOR3vF9PsleMTTGuEfw=; b=YlR4uhGbbNcDjHbv5mq94Ue8r0nQqZQqkRcIFxRO+trGRWwalQqqXa+Cqm5EOPVd+Zg0QcF1Uj3rsd4yKHOdEth91thpYZyvgZnhw8EIMiTcVM3kCkU1oqA1znWV0uSKDHaLF+eLOf5bjNwWLComiB4oqiCrwHwLvUuUNqvJfIM= 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 1758534241028732.7493209853121; Mon, 22 Sep 2025 02:44:01 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v0d5E-0005OS-SK; Mon, 22 Sep 2025 05:43:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v0d4r-0004yO-BM for qemu-devel@nongnu.org; Mon, 22 Sep 2025 05:43:21 -0400 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1v0d4k-0001z1-2e for qemu-devel@nongnu.org; Mon, 22 Sep 2025 05:43:21 -0400 Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-45dd505a1dfso28895605e9.2 for ; Mon, 22 Sep 2025 02:43:13 -0700 (PDT) Received: from draig.lan ([185.126.160.19]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3f88de2d075sm7646723f8f.35.2025.09.22.02.43.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Sep 2025 02:43:09 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 8B9625FA42; Mon, 22 Sep 2025 10:37:13 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1758534191; x=1759138991; 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=RYNYIu8+be0QQyu0ldhaTLfitOR3vF9PsleMTTGuEfw=; b=QlUR6aWrxBIamxUjH9CfoX2boQLIvSjBIykw/foq2nF918GMOOQNMKRWG8x9M7E+8m EmD1pe29f8CxTQvJkL2XDy1xjVSqiKBzxh7jFBJ12IHcnb8IAWzzmI5W/E+5sGISlJY6 1wD7sVSJ7wQp/MAwAElJchM2OK/MZPxvucONxBEiS/jk+r0CCPipMvEq/f4SN2Q8MCde m6IHLxJhYvFJ1nI6q0+vNgkQ4bcroAH4NU/zvPUbKLH1MBTKm6H6f4mCBEHEID9oti/x PN4/WlYfWL01DJTxhkdJFswGr5dtPDq1I7WMze7ZyuTH+ACX3cPwdYV7/wAhmWS4r1db 3uxQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1758534191; x=1759138991; 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=RYNYIu8+be0QQyu0ldhaTLfitOR3vF9PsleMTTGuEfw=; b=dMrz1NmEj13KGQWC27emidxZntIqOqmB/wGTyFfMmlOEfDvkIoesxJnedZy+uwuK8G LDJWdjybEbhXd1RquihXmCw4CtkBQONKSW3MpNDi5G6fEsDjhuHHcSuCvHncwHlfLGFT 2hfpGnr3i4GLNVG0w86mnVApQ4mWGPKQbe6GdANJjMGHgWSkA66njg39PcO41nttdaOJ aplJqOTuu8VBjJloAxRZbbuL+hxYj1f1LX9rlK7yXW4fDCQxiquBvjLrMhJHESDQViyM BfR/wEowPaMdvSENLObe0jiI6/boJjiMkV+L1XcD7+38bQWybCbTio0VyxvuiMODehbD IohA== X-Gm-Message-State: AOJu0YxPEJPW4m88teBR6TJri4Llh3Tgch5ojSLXtrIBPvFKP9mHPnGZ H51FLMQX+ThG02egLa3eHkR2t/L5xRs1eR+fnATKrsMxVUlgD5bRPshGUVBhPfZ0tT4= X-Gm-Gg: ASbGncsjjhR4Z1mdkAJmRUxpMwqoQAKTWSa+LG+Y30M3CCsIypjK0p6wB2jJWQVOlms O1ZHKpQbrVhB8lA14SOsr/XbxrF5gCrRhz+bQvEC/i1RkB8Ji+GIQTH7jYxZwkD6LvdbWWBCDqN p1iDp5Y/Ufniz1xJeb3IcFetpv2YyyC9cY0rJwU9jFb1xqfZ6BW/4coCKspj5tHJ1J+mRXjAXQq 7rGxNbTE35W7vfc3hVakbV3EqZPH/ufnpZfmpLJyy3hkjdswhotQoSbauTjWYPboljybnHg14MF ttLcgyS+vIQ6o65M9jwXCPHA88NxU/jZEZPKU55dMGEIgdovCO8Im1Fd0VIC8kuVSd8gKLNS/go Ffwm+syTNetKGW+SynObYhN4= X-Google-Smtp-Source: AGHT+IExuMgweMVP/T0fvHwaQ5QkiR/+Ix4PHNwiAEGgURlJdab8SAdPCwyJqTNcH210HOl/5/+8Yg== X-Received: by 2002:a05:600c:4748:b0:456:1b6f:c888 with SMTP id 5b1f17b1804b1-467f2242a87mr118994405e9.23.1758534190744; Mon, 22 Sep 2025 02:43:10 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Palmer Dabbelt , Alexandre Iooss , Mahmoud Mandour , qemu-riscv@nongnu.org, Daniel Henrique Barboza , Thomas Huth , Peter Maydell , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Alistair Francis , qemu-arm@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Weiwei Li , Pierrick Bouvier , Liu Zhiwei , Manos Pitsidianakis Subject: [PATCH 21/25] contrib/plugins/uftrace: implement privilege level tracing Date: Mon, 22 Sep 2025 10:37:06 +0100 Message-ID: <20250922093711.2768983-22-alex.bennee@linaro.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20250922093711.2768983-1-alex.bennee@linaro.org> References: <20250922093711.2768983-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 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: 1758534242793116600 From: Pierrick Bouvier We add new option trace-privilege-level=3Dbool, which will create a separate trace for each privilege level. This allows to follow changes of privilege during execution. We implement aarch64 operations to track current privilege level accordingly. Reviewed-by: Manos Pitsidianakis Signed-off-by: Pierrick Bouvier Message-ID: <20250902075042.223990-6-pierrick.bouvier@linaro.org> Signed-off-by: Alex Benn=C3=A9e --- contrib/plugins/uftrace.c | 190 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 182 insertions(+), 8 deletions(-) diff --git a/contrib/plugins/uftrace.c b/contrib/plugins/uftrace.c index b9dcd531987..10abad0673c 100644 --- a/contrib/plugins/uftrace.c +++ b/contrib/plugins/uftrace.c @@ -46,19 +46,40 @@ typedef struct { void (*init)(Cpu *cpu); void (*end)(Cpu *cpu); uint64_t (*get_frame_pointer)(Cpu *cpu); + uint8_t (*get_privilege_level)(Cpu *cpu); + uint8_t (*num_privilege_levels)(void); + const char *(*get_privilege_level_name)(uint8_t pl); bool (*does_insn_modify_frame_pointer)(const char *disas); } CpuOps; =20 typedef struct Cpu { Trace *trace; Callstack *cs; + uint8_t privilege_level; + GArray *traces; /* Trace *traces [] */ GByteArray *buf; CpuOps ops; void *arch; } Cpu; =20 +typedef enum { + AARCH64_EL0_SECURE, + AARCH64_EL0_NONSECURE, + AARCH64_EL0_REALM, + AARCH64_EL1_SECURE, + AARCH64_EL1_NONSECURE, + AARCH64_EL1_REALM, + AARCH64_EL2_SECURE, + AARCH64_EL2_NONSECURE, + AARCH64_EL2_REALM, + AARCH64_EL3, + AARCH64_PRIVILEGE_LEVEL_MAX, +} Aarch64PrivilegeLevel; + typedef struct { struct qemu_plugin_register *reg_fp; + struct qemu_plugin_register *reg_cpsr; + struct qemu_plugin_register *reg_scr_el3; } Aarch64Cpu; =20 typedef struct { @@ -74,6 +95,7 @@ typedef enum { } UftraceRecordType; =20 static struct qemu_plugin_scoreboard *score; +static bool trace_privilege_level; static CpuOps arch_ops; =20 static uint64_t gettime_ns(void) @@ -251,6 +273,16 @@ static uint64_t cpu_read_register64(Cpu *cpu, struct q= emu_plugin_register *reg) return *((uint64_t *) buf->data); } =20 +static uint32_t cpu_read_register32(Cpu *cpu, struct qemu_plugin_register = *reg) +{ + GByteArray *buf =3D cpu->buf; + g_byte_array_set_size(buf, 0); + size_t sz =3D qemu_plugin_read_register(reg, buf); + g_assert(sz =3D=3D 4); + g_assert(buf->len =3D=3D 4); + return *((uint32_t *) buf->data); +} + static uint64_t cpu_read_memory64(Cpu *cpu, uint64_t addr) { g_assert(addr); @@ -308,6 +340,68 @@ static struct qemu_plugin_register *plugin_find_regist= er(const char *name) return NULL; } =20 +static uint8_t aarch64_num_privilege_levels(void) +{ + return AARCH64_PRIVILEGE_LEVEL_MAX; +} + +static const char *aarch64_get_privilege_level_name(uint8_t pl) +{ + switch (pl) { + case AARCH64_EL0_SECURE: return "S-EL0"; + case AARCH64_EL0_NONSECURE: return "NS-EL0"; + case AARCH64_EL0_REALM: return "R-EL0"; + case AARCH64_EL1_SECURE: return "S-EL1"; + case AARCH64_EL1_NONSECURE: return "NS-EL1"; + case AARCH64_EL1_REALM: return "R-EL1"; + case AARCH64_EL2_SECURE: return "S-EL2"; + case AARCH64_EL2_NONSECURE: return "NS-EL2"; + case AARCH64_EL2_REALM: return "R-EL2"; + case AARCH64_EL3: return "EL3"; + default: + g_assert_not_reached(); + } +} + +static uint8_t aarch64_get_privilege_level(Cpu *cpu_) +{ + Aarch64Cpu *cpu =3D cpu_->arch; + /* + * QEMU gdbstub does not provide access to CurrentEL, + * so we use CPSR instead. + */ + uint8_t el =3D cpu_read_register32(cpu_, cpu->reg_cpsr) >> 2 & 0b11; + + if (el =3D=3D 3) { + return AARCH64_EL3; + } + + uint8_t ss =3D AARCH64_EL0_SECURE; + if (!cpu->reg_scr_el3) { + ss =3D AARCH64_EL0_NONSECURE; + } + uint64_t scr_el3 =3D cpu_read_register64(cpu_, cpu->reg_scr_el3); + uint64_t ns =3D (scr_el3 >> 0) & 0b1; + uint64_t nse =3D (scr_el3 >> 62) & 0b1; + switch (nse << 1 | ns) { + case 0b00: + ss =3D AARCH64_EL0_SECURE; + break; + case 0b01: + ss =3D AARCH64_EL0_NONSECURE; + break; + case 0b11: + ss =3D AARCH64_EL0_REALM; + break; + default: + g_assert_not_reached(); + } + + const uint8_t num_ss =3D 3; + Aarch64PrivilegeLevel pl =3D el * num_ss + ss; + return pl; +} + static uint64_t aarch64_get_frame_pointer(Cpu *cpu_) { Aarch64Cpu *cpu =3D cpu_->arch; @@ -324,6 +418,10 @@ static void aarch64_init(Cpu *cpu_) "available. Please use an AArch64 cpu (or -cpu max= ).\n"); g_abort(); } + cpu->reg_cpsr =3D plugin_find_register("cpsr"); + g_assert(cpu->reg_cpsr); + cpu->reg_scr_el3 =3D plugin_find_register("SCR_EL3"); + /* scr_el3 is optional */ } =20 static void aarch64_end(Cpu *cpu) @@ -345,9 +443,34 @@ static CpuOps aarch64_ops =3D { .init =3D aarch64_init, .end =3D aarch64_end, .get_frame_pointer =3D aarch64_get_frame_pointer, + .get_privilege_level =3D aarch64_get_privilege_level, + .num_privilege_levels =3D aarch64_num_privilege_levels, + .get_privilege_level_name =3D aarch64_get_privilege_level_name, .does_insn_modify_frame_pointer =3D aarch64_does_insn_modify_frame_poi= nter, }; =20 +static void track_privilege_change(unsigned int cpu_index, void *udata) +{ + Cpu *cpu =3D qemu_plugin_scoreboard_find(score, cpu_index); + uint8_t new_pl =3D cpu->ops.get_privilege_level(cpu); + + if (new_pl =3D=3D cpu->privilege_level) { + return; + } + + uint64_t pc =3D (uintptr_t) udata; + uint64_t timestamp =3D gettime_ns(); + + trace_exit_stack(cpu->trace, cpu->cs, timestamp); + callstack_clear(cpu->cs); + + cpu->privilege_level =3D new_pl; + cpu->trace =3D g_array_index(cpu->traces, Trace*, new_pl); + + cpu_unwind_stack(cpu, cpu->ops.get_frame_pointer(cpu), pc); + trace_enter_stack(cpu->trace, cpu->cs, timestamp); +} + static void track_callstack(unsigned int cpu_index, void *udata) { uint64_t pc =3D (uintptr_t) udata; @@ -400,6 +523,13 @@ static void track_callstack(unsigned int cpu_index, vo= id *udata) static void vcpu_tb_trans(qemu_plugin_id_t id, struct qemu_plugin_tb *tb) { size_t n_insns =3D qemu_plugin_tb_n_insns(tb); + uintptr_t tb_pc =3D qemu_plugin_tb_vaddr(tb); + + if (trace_privilege_level) { + qemu_plugin_register_vcpu_tb_exec_cb(tb, track_privilege_change, + QEMU_PLUGIN_CB_R_REGS, + (void *) tb_pc); + } =20 /* * Callbacks and inline instrumentation are inserted before an instruc= tion. @@ -433,18 +563,36 @@ static void vcpu_init(qemu_plugin_id_t id, unsigned i= nt vcpu_index) =20 cpu->ops.init(cpu); cpu->buf =3D g_byte_array_new(); + cpu->traces =3D g_array_new(0, 0, sizeof(Trace *)); =20 g_assert(vcpu_index < UINT32_MAX / TRACE_ID_SCALE); - /* trace_id is: cpu_number * TRACE_ID_SCALE */ + g_assert(cpu->ops.num_privilege_levels() < TRACE_ID_SCALE); + /* trace_id is: cpu_number * TRACE_ID_SCALE + privilege_level */ uint32_t trace_id =3D (vcpu_index + 1) * TRACE_ID_SCALE; =20 - g_autoptr(GString) trace_name =3D g_string_new(NULL); - g_string_append_printf(trace_name, "cpu%u", vcpu_index); - cpu->trace =3D trace_new(trace_id, trace_name); - /* create/truncate trace file */ - trace_flush(cpu->trace, false); + if (trace_privilege_level) { + for (uint8_t pl =3D 0; pl < cpu->ops.num_privilege_levels(); ++pl)= { + g_autoptr(GString) trace_name =3D g_string_new(NULL); + g_string_append_printf(trace_name, "cpu%u %s", vcpu_index, + cpu->ops.get_privilege_level_name(pl)); + Trace *t =3D trace_new(trace_id + pl, trace_name); + g_array_append_val(cpu->traces, t); + } + } else { + g_autoptr(GString) trace_name =3D g_string_new(NULL); + g_string_append_printf(trace_name, "cpu%u", vcpu_index); + Trace *t =3D trace_new(trace_id, trace_name); + g_array_append_val(cpu->traces, t); + } + + for (size_t i =3D 0; i < cpu->traces->len; ++i) { + /* create/truncate trace files */ + Trace *t =3D g_array_index(cpu->traces, Trace*, i); + trace_flush(t, false); + } =20 cpu->cs =3D callstack_new(); + cpu->trace =3D g_array_index(cpu->traces, Trace*, cpu->privilege_level= ); } =20 static void vcpu_end(unsigned int vcpu_index) @@ -452,7 +600,12 @@ static void vcpu_end(unsigned int vcpu_index) Cpu *cpu =3D qemu_plugin_scoreboard_find(score, vcpu_index); g_byte_array_free(cpu->buf, true); =20 - trace_free(cpu->trace); + for (size_t i =3D 0; i < cpu->traces->len; ++i) { + Trace *t =3D g_array_index(cpu->traces, Trace*, i); + trace_free(t); + } + + g_array_free(cpu->traces, true); callstack_free(cpu->cs); memset(cpu, 0, sizeof(Cpu)); } @@ -461,7 +614,13 @@ static void at_exit(qemu_plugin_id_t id, void *data) { for (size_t i =3D 0; i < qemu_plugin_num_vcpus(); ++i) { Cpu *cpu =3D qemu_plugin_scoreboard_find(score, i); - trace_flush(cpu->trace, true); + for (size_t j =3D 0; j < cpu->traces->len; ++j) { + Trace *t =3D g_array_index(cpu->traces, Trace*, j); + trace_flush(t, true); + } + } + + for (size_t i =3D 0; i < qemu_plugin_num_vcpus(); ++i) { vcpu_end(i); } =20 @@ -472,6 +631,21 @@ QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin= _id_t id, const qemu_info_t *info, int argc, char **argv) { + for (int i =3D 0; i < argc; i++) { + char *opt =3D argv[i]; + g_auto(GStrv) tokens =3D g_strsplit(opt, "=3D", 2); + if (g_strcmp0(tokens[0], "trace-privilege-level") =3D=3D 0) { + if (!qemu_plugin_bool_parse(tokens[0], tokens[1], + &trace_privilege_level)) { + fprintf(stderr, "boolean argument parsing failed: %s\n", o= pt); + return -1; + } + } else { + fprintf(stderr, "option parsing failed: %s\n", opt); + return -1; + } + } + if (!strcmp(info->target_name, "aarch64")) { arch_ops =3D aarch64_ops; } else { --=20 2.47.3 From nobody Sun Sep 28 15:30:20 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1758534329; cv=none; d=zohomail.com; s=zohoarc; b=cHHWn9SJClRBFkXDCaABGYYkcx/VK/YWDfZqPfddbKl7zx/tFnsjABXCMQVTRdxN4xgia9yTAnV/IQ0ICieZMPhPuDu5m1KSvUyrJ9f9dHrC/K5Dmcs6z536SAU2zPq67a9sLK2y/jvAO2TQBfeS2nT4W0WN0MhRzhXXX5zZMXk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1758534329; 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=FJwj+j8eqB6M9mWpUpDVKvrulXK41G81FN8FC0P+tiM=; b=TGzijLiethbH0geEHrmlHAwM0XWqUTYfyRFIDXrFe07zp5/t2s21MWlw3jyGUqT3STmpwRYAZ0CnPwJCRHSjg48IhT7Hk7sszRrwdoppP5MoUh+RX6d7yyn7ZYIJvNb16qDcc+Dbpa+iw4+Oy2keHRaCP8o1eeKXRRQNm+3GbB0= 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 1758534329905959.0086278019741; Mon, 22 Sep 2025 02:45:29 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v0d62-0006HA-8Y; Mon, 22 Sep 2025 05:44:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v0d5D-0005Tf-Hs for qemu-devel@nongnu.org; Mon, 22 Sep 2025 05:43:44 -0400 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 1v0d4p-00020m-Ko for qemu-devel@nongnu.org; Mon, 22 Sep 2025 05:43:42 -0400 Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-45f2c9799a3so31048105e9.0 for ; Mon, 22 Sep 2025 02:43:18 -0700 (PDT) Received: from draig.lan ([185.126.160.19]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-46d5d437b90sm30823985e9.13.2025.09.22.02.43.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Sep 2025 02:43:14 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id A1D6B5FA53; Mon, 22 Sep 2025 10:37:13 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1758534196; x=1759138996; 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=FJwj+j8eqB6M9mWpUpDVKvrulXK41G81FN8FC0P+tiM=; b=cwnwBw1GD1DQRI8GNGXHNuuUG+pLGOdAmMAUBjvFMpReofIh3+1SYn8Q2Wgts9+iZp GRXw7TlPWY0ZXC6cqsBqC1hw0k/bj2Zvr8SyOMZoK3X/fInNA1rrCIiUb8DPsHcYMhVl VLqkiTuFykViqnxZa6stEtKN//alvdfhNGdMJHq6NsUnbvFpkNAuVova2yZLfIyVNuhL 5ijh0uELCEZ4L2OFHwp96Bh3L7wi4DkX8HSPDdShcV9Byzw0oD40TWL+0RWe7VJGnvV6 qziG0mht5Eh5IHEISc9Cax+TV8VbfuSiYLcwIrG3WaE++HzW6LCY2OefIk7a14cGlG7y gINA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1758534196; x=1759138996; 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=FJwj+j8eqB6M9mWpUpDVKvrulXK41G81FN8FC0P+tiM=; b=WcIkr3ZuFqnaCnaBDFw1REXm8CAGGhsV8HHkidTNhWdNZ4+WFQ17ixSjMfMf6vKRKw 8GM82Q9nDmnWunDfwo6FzlSfXmNg/qHGIdyBdqM6KNkVRu6UuDapdv6VggGOcGUb7GX0 HKVKcU1Vf16Dvee2rk/K7WV/o7ST0ASoCPqtzKod15p5N5YLGZ8RhBHy1/q4RXoQqu0u //SiL4fo8swLdWxE5J17Zo56dRG1AlxyajdP7lj4YWgsVP+sH7PaM9yMpkkjIyo/sk1j x5u5FW3zRFvgnnAhSwPnIWF0PBWQ+RuW5noCUSuYT4jZoxiCISWIFj1U11u3ik5ssLu6 2qNA== X-Gm-Message-State: AOJu0YyMxM2us+JeL9tIqPK4MsrhMrk/+RHwNW10H1CY9KjT7iwoZRp9 wilCW93nWpJ6E+WNdLvbuodKJNpdkh4TVpnuxytB2XwTybvb8xO/Nh11snnKTmY5Yu4= X-Gm-Gg: ASbGncteiwcgJiRk+P6RgcMVlszCM1tJAVG9xvBj6K7pEAlFJgOyO96UaaWLh4ni1T+ IIJw9H2r3nhhuHL74i4wsEjWaRwI0bZLfX7R+SVBsl6FixDP4J0O8Qr3neIJdZ/KsZc2H0jjB8z DIoizyc7NRi7Xc49t5z5HukVJKt8BhEKURizDyyMMeNCcj0SNBcpfD9bsDydxnui3P8CihxYhwu TiZ+PMICHNKG+UJnnA/JHsjST92HWYtOUGBXUthNG9g1l8JRmPWXfmajoSXilq3mV9dDb19U5Ht aAfUS3U2ruY36aXbPdjwqny8D5N24WxT0Z8YrVhPEnG1dEns4Sia8B/kVEQ+g/7rdoduEX6j695 WGHuTuzTHHR8SPyeZ7mp9jCE= X-Google-Smtp-Source: AGHT+IGDoTsFYJdgqoZIMublxEAaaaQBctARQxcyPBtmde2Zdg4+BEMqIAp5Ohna5qgwCyNPjQuYuQ== X-Received: by 2002:a05:600c:a02:b0:459:d645:bff7 with SMTP id 5b1f17b1804b1-467e7f7d5bamr120743635e9.12.1758534196412; Mon, 22 Sep 2025 02:43:16 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Palmer Dabbelt , Alexandre Iooss , Mahmoud Mandour , qemu-riscv@nongnu.org, Daniel Henrique Barboza , Thomas Huth , Peter Maydell , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Alistair Francis , qemu-arm@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Weiwei Li , Pierrick Bouvier , Liu Zhiwei , Manos Pitsidianakis Subject: [PATCH 22/25] contrib/plugins/uftrace: generate additional files for uftrace Date: Mon, 22 Sep 2025 10:37:07 +0100 Message-ID: <20250922093711.2768983-23-alex.bennee@linaro.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20250922093711.2768983-1-alex.bennee@linaro.org> References: <20250922093711.2768983-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 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: 1758534331957116600 From: Pierrick Bouvier Beyond traces per cpu, uftrace expect to find some specific files. - info: contains information about machine/program run those values are not impacting uftrace behaviour (only reported by uftrace info), and we simply added empty strings. - memory mapping: how every binary is mapped in memory. For system mode, we generate an empty mapping (uftrace_symbols.py, coming in future commit, will take care of that). For user mode, we copy current /proc/self/maps. We don't need to do any special filtering, as reported addresses will necessarily concern guest program, and not QEMU and its libraries. - task: list of tasks. We present every vcpu/privilege level as a separate process, as it's the best view we can have when generating a (visual) chrome trace. Using threads is less convenient in terms of UI. Reviewed-by: Manos Pitsidianakis Signed-off-by: Pierrick Bouvier Message-ID: <20250902075042.223990-7-pierrick.bouvier@linaro.org> Signed-off-by: Alex Benn=C3=A9e --- contrib/plugins/uftrace.c | 131 +++++++++++++++++++++++++++++++++++++- 1 file changed, 130 insertions(+), 1 deletion(-) diff --git a/contrib/plugins/uftrace.c b/contrib/plugins/uftrace.c index 10abad0673c..2386cc723bc 100644 --- a/contrib/plugins/uftrace.c +++ b/contrib/plugins/uftrace.c @@ -118,6 +118,127 @@ static uint64_t gettime_ns(void) return now_ns; } =20 +static void uftrace_write_map(bool system_emulation) +{ + const char *path =3D "./uftrace.data/sid-0.map"; + + if (system_emulation && access(path, F_OK) =3D=3D 0) { + /* do not erase existing map in system emulation, as a custom one = might + * already have been generated by uftrace_symbols.py */ + return; + } + + FILE *sid_map =3D fopen(path, "w"); + g_assert(sid_map); + + if (system_emulation) { + fprintf(sid_map, + "# map stack on highest address possible, to prevent uftra= ce\n" + "# from considering any kernel address\n"); + fprintf(sid_map, + "ffffffffffff-ffffffffffff rw-p 00000000 00:00 0 [stack]\n"); + } else { + /* in user mode, copy /proc/self/maps instead */ + FILE *self_map =3D fopen("/proc/self/maps", "r"); + g_assert(self_map); + for (;;) { + int c =3D fgetc(self_map); + if (c =3D=3D EOF) { + break; + } + fputc(c, sid_map); + } + fclose(self_map); + } + fclose(sid_map); +} + +static void uftrace_write_task(const GArray *traces) +{ + FILE *task =3D fopen("./uftrace.data/task.txt", "w"); + g_assert(task); + for (int i =3D 0; i < traces->len; ++i) { + Trace *t =3D g_array_index(traces, Trace*, i); + fprintf(task, "SESS timestamp=3D0.0 pid=3D%"PRIu32" sid=3D0 exenam= e=3D\"%s\"\n", + t->id, t->name->str); + fprintf(task, "TASK timestamp=3D0.0 tid=3D%"PRIu32" pid=3D%"PRIu32= "\n", + t->id, t->id); + } + fclose(task); +} + +static void uftrace_write_info(const GArray *traces) +{ + g_autoptr(GString) taskinfo_tids =3D g_string_new("taskinfo:tids=3D"); + for (int i =3D 0; i < traces->len; ++i) { + Trace *t =3D g_array_index(traces, Trace*, i); + const char *delim =3D i > 0 ? "," : ""; + g_string_append_printf(taskinfo_tids, "%s%"PRIu32, delim, t->id); + } + + g_autoptr(GString) taskinfo_nr_tid =3D g_string_new("taskinfo:nr_tid= =3D"); + g_string_append_printf(taskinfo_nr_tid, "%d", traces->len); + + FILE *info =3D fopen("./uftrace.data/info", "w"); + g_assert(info); + /* + * $ uftrace dump --debug + * uftrace file header: magic =3D 4674726163652100 + * uftrace file header: version =3D 4 + * uftrace file header: header size =3D 40 + * uftrace file header: endian =3D 1 (little) + * uftrace file header: class =3D 2 (64 bit) + * uftrace file header: features =3D 0x1263 (PLTHOOK | ... + * uftrace file header: info =3D 0x7bff (EXE_NAME | ... + * <0000000000000000>: 46 74 72 61 63 65 21 00 04 00 00 00 28 00 01 = 02 + * <0000000000000010>: 63 12 00 00 00 00 00 00 ff 7b 00 00 00 00 00 = 00 + * <0000000000000020>: 00 04 00 00 00 00 00 00 + */ + const uint8_t header[] =3D {0x46, 0x74, 0x72, 0x61, 0x63, 0x65, 0x21, = 0x00, + 0x04, 0x00, 0x00, 0x00, 0x28, 0x00, 0x01, 0x= 02, + 0x63, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x= 00, + 0xff, 0x7b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x= 00, + 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x= 00}; + size_t wrote =3D fwrite(header, sizeof(header), 1, info); + g_assert(wrote =3D=3D 1); + const char *info_data[] =3D { + "exename:", + "build_id:0000000000000000000000000000000000000000", + "exit_status:", + "cmdline:", + "cpuinfo:lines=3D2", + "cpuinfo:nr_cpus=3D", + "cpuinfo:desc=3D", + "meminfo:", + "osinfo:lines=3D3", + "osinfo:kernel=3D", + "osinfo:hostname=3D", + "osinfo:distro=3D", + "taskinfo:lines=3D2", + taskinfo_nr_tid->str, + taskinfo_tids->str, + "usageinfo:lines=3D6", + "usageinfo:systime=3D", + "usageinfo:usrtime=3D", + "usageinfo:ctxsw=3D", + "usageinfo:maxrss=3D", + "usageinfo:pagefault=3D", + "usageinfo:iops=3D", + "loadinfo:", + "record_date:", + "elapsed_time:", + "pattern_type:regex", + "uftrace_version:", + "utc_offset:", + 0}; + const char **info_data_it =3D info_data; + while (*(info_data_it)) { + fprintf(info, "%s\n", *info_data_it); + ++info_data_it; + } + fclose(info); +} + static Callstack *callstack_new(void) { Callstack *cs =3D g_new0(Callstack, 1); @@ -612,14 +733,22 @@ static void vcpu_end(unsigned int vcpu_index) =20 static void at_exit(qemu_plugin_id_t id, void *data) { + bool system_emulation =3D (bool) data; + g_autoptr(GArray) traces =3D g_array_new(0, 0, sizeof(Trace *)); + for (size_t i =3D 0; i < qemu_plugin_num_vcpus(); ++i) { Cpu *cpu =3D qemu_plugin_scoreboard_find(score, i); for (size_t j =3D 0; j < cpu->traces->len; ++j) { Trace *t =3D g_array_index(cpu->traces, Trace*, j); trace_flush(t, true); + g_array_append_val(traces, t); } } =20 + uftrace_write_map(system_emulation); + uftrace_write_info(traces); + uftrace_write_task(traces); + for (size_t i =3D 0; i < qemu_plugin_num_vcpus(); ++i) { vcpu_end(i); } @@ -656,7 +785,7 @@ QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_= id_t id, =20 score =3D qemu_plugin_scoreboard_new(sizeof(Cpu)); qemu_plugin_register_vcpu_init_cb(id, vcpu_init); - qemu_plugin_register_atexit_cb(id, at_exit, NULL); + qemu_plugin_register_atexit_cb(id, at_exit, (void *) info->system_emul= ation); qemu_plugin_register_vcpu_tb_trans_cb(id, vcpu_tb_trans); =20 return 0; --=20 2.47.3 From nobody Sun Sep 28 15:30:20 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1758534323; cv=none; d=zohomail.com; s=zohoarc; b=YV/QVwav4nKCrkCKLMgZv/JpDiNQ0OHw3SE997Qv0kZ13r6a272TdVL9NMWvtL9LP8VVgUBlZ8zfoijbXK6HUZIjiUiiISXRxr3xz6w2t9GKE79+eOfJ9Gw+MhCaLKGrxz9rtvgfcKl2psTZmRS9YQcA3d7atbQjhI5GxclE8TQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1758534323; 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=Xka3pneMH2qFxqRVxyDw79VsTx+gMXoNji+Y4GSMTqs=; b=m5AUgdFPrFM9tLaxE0QXSuCOliW+Yx7gWxBNDbOfun7XGU0hQXESKoPGmcd1kXEFP1Oj0XPJOC3FT5R45yWP98qISFdlpZyZdSIuo8bAQj6SVQHXlH5DovR7/r3dJcDXvjvTDvrf0ociAIuzCBog1EY5EMKPnoUUBgKM3VV0tYY= 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 175853432389817.266728550986613; Mon, 22 Sep 2025 02:45:23 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v0d6B-000708-WC; Mon, 22 Sep 2025 05:44:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v0d5W-0005id-M0 for qemu-devel@nongnu.org; Mon, 22 Sep 2025 05:44:08 -0400 Received: from mail-wr1-x431.google.com ([2a00:1450:4864:20::431]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1v0d4p-00020P-6d for qemu-devel@nongnu.org; Mon, 22 Sep 2025 05:43:49 -0400 Received: by mail-wr1-x431.google.com with SMTP id ffacd0b85a97d-3b9edf4cf6cso3582871f8f.3 for ; Mon, 22 Sep 2025 02:43:18 -0700 (PDT) Received: from draig.lan ([185.126.160.19]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-464eadd7e11sm205573335e9.0.2025.09.22.02.43.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Sep 2025 02:43:14 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id B93785FA5C; Mon, 22 Sep 2025 10:37:13 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1758534196; x=1759138996; 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=Xka3pneMH2qFxqRVxyDw79VsTx+gMXoNji+Y4GSMTqs=; b=tEyTOQfbIqxEBM68XpojlbCSsx5xe383/w1q5GxhNL1kmVFswctE1z/JUYMuuyl8HA PovVGMNtb9evrn4TVV2YvPsZPkjXQNvKVR9RaTlOGheaV87mWa+hY+dFpGgXI+jCpusV bZlb0YDqO7EL7ZvTXKc3fdYi+hDCzwkjUbI5uuBU/dt0SJ/Bvy8DJyTVdJY8nLd+t6iw /vTbmIAIXujUuN5bNKOkT8fgLilygFAkOUgBPs7dH7dy+t/KIWrt96MYTVOlayfRj2F0 /RCWSDKLzUFHr6FCTVTwWQeoLfo4FMiyumcD4QB/IjxQ6uhXvfYrsl0K8UJmvO2WFABg SMpg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1758534196; x=1759138996; 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=Xka3pneMH2qFxqRVxyDw79VsTx+gMXoNji+Y4GSMTqs=; b=oLzjDDX3ZaEhuF0gItLhuGisg+3wAQpppWuDabzwkaZ4OpJPJO+HuN5u6v8OBa7BBn LTHyYEfcZQcU+ifWFSg7g6ji+lsYm/VPihFA5sxqSXwPnvTxHbjb/VQJPggmtdQ+MEOa 6dBtrVzWR1mpkPJVRV+nXtgsV/HgvZCbTzGWymGzvP1AS40gSGKoUifYMwhfl8HypUor X/kEdt4shVyf0rrWNhWsQFlnkdN2g4S2uUO/LJ84/te2gXJ4gxH54w/Um/XI2p+tM5Vf 1MFK/w7ILGJ3aNwC/r1236p9pP4XR0Hu1f3f3Cr/LsVJ/aowrzLgDWOXhz077Dro2mxc 5S9g== X-Gm-Message-State: AOJu0Yw7nAVipP9FcS8lCbuxpY7fJss0Xpc1+SgJ0fAvc3WdETUG2wuV KJ4tMAKyZCUSOkRxV6BC2xtNKFqBGsYxCcr66t85xhP9y25mSLSlThhNYM/XNPs9TAo= X-Gm-Gg: ASbGncsv7v3QLVDu50j324pITc/HmeiZKtsEPaO+fXDF/BQj5bqgueJpb3jrNkrVtu3 RJiaMK9bV37E1NJq0x3XHjKwiabVPMk548NM0SZEHJnlLlmteYP+BbwwgF/eJhIrQ5lDlmZpNCH fPWeGKd4GtBcMetdkPYvyMRtsuIRqQ3EO71AZNylAjKCwQiawEYzXgL0tOowb1tj273zqFR+dUf 5K5bogoYamePcvdFRfWxt1Vos7tyZVzLBZcYF6FTPsVFe0NS4eG/REf61h+SrDmkrqzp9E2tW07 MNwViKNWSruo9rloXEf484mQYaP3VIbi7x4DRrsuDWiY8O1ZVa/MatFSfQ0nVAJ/XsADeDRmR+4 86/fV378CSsfbTTxRCq0k0J8= X-Google-Smtp-Source: AGHT+IF9euK6P/jVSKmTMYqDnTu7Pa+8D/t3miko6mM1UHE+U/WgS/i4aGQZMAkNCSbkFIvJ9QqFQw== X-Received: by 2002:a5d:5d0b:0:b0:400:c7c0:52af with SMTP id ffacd0b85a97d-400c7c052d6mr1177801f8f.1.1758534195638; Mon, 22 Sep 2025 02:43:15 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Palmer Dabbelt , Alexandre Iooss , Mahmoud Mandour , qemu-riscv@nongnu.org, Daniel Henrique Barboza , Thomas Huth , Peter Maydell , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Alistair Francis , qemu-arm@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Weiwei Li , Pierrick Bouvier , Liu Zhiwei , Manos Pitsidianakis Subject: [PATCH 23/25] contrib/plugins/uftrace: implement x64 support Date: Mon, 22 Sep 2025 10:37:08 +0100 Message-ID: <20250922093711.2768983-24-alex.bennee@linaro.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20250922093711.2768983-1-alex.bennee@linaro.org> References: <20250922093711.2768983-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::431; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x431.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=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: 1758534325622116600 From: Pierrick Bouvier It's trivial to implement x64 support, as it's the same stack layout as aarch64. Reviewed-by: Manos Pitsidianakis Signed-off-by: Pierrick Bouvier Message-ID: <20250902075042.223990-8-pierrick.bouvier@linaro.org> Signed-off-by: Alex Benn=C3=A9e --- contrib/plugins/uftrace.c | 86 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) diff --git a/contrib/plugins/uftrace.c b/contrib/plugins/uftrace.c index 2386cc723bc..b7d6124d2f5 100644 --- a/contrib/plugins/uftrace.c +++ b/contrib/plugins/uftrace.c @@ -82,6 +82,21 @@ typedef struct { struct qemu_plugin_register *reg_scr_el3; } Aarch64Cpu; =20 +typedef enum { + X64_RING0, + X64_RING1, + X64_RING2, + X64_RING3, + X64_REAL_MODE, + X64_PRIVILEGE_LEVEL_MAX, +} X64PrivilegeLevel; + +typedef struct { + struct qemu_plugin_register *reg_rbp; + struct qemu_plugin_register *reg_cs; + struct qemu_plugin_register *reg_cr0; +} X64Cpu; + typedef struct { uint64_t timestamp; uint64_t data; @@ -570,6 +585,75 @@ static CpuOps aarch64_ops =3D { .does_insn_modify_frame_pointer =3D aarch64_does_insn_modify_frame_poi= nter, }; =20 +static uint8_t x64_num_privilege_levels(void) +{ + return X64_PRIVILEGE_LEVEL_MAX; +} + +static const char *x64_get_privilege_level_name(uint8_t pl) +{ + switch (pl) { + case X64_RING0: return "Ring0"; + case X64_RING1: return "Ring1"; + case X64_RING2: return "Ring2"; + case X64_RING3: return "Ring3"; + case X64_REAL_MODE: return "RealMode"; + default: + g_assert_not_reached(); + } +} + +static uint8_t x64_get_privilege_level(Cpu *cpu_) +{ + X64Cpu *cpu =3D cpu_->arch; + uint64_t cr0 =3D cpu_read_register64(cpu_, cpu->reg_cr0); + uint64_t protected_mode =3D (cr0 >> 0) & 0b1; + if (!protected_mode) { + return X64_REAL_MODE; + } + uint32_t cs =3D cpu_read_register32(cpu_, cpu->reg_cs); + uint32_t ring_level =3D (cs >> 0) & 0b11; + return ring_level; +} + +static uint64_t x64_get_frame_pointer(Cpu *cpu_) +{ + X64Cpu *cpu =3D cpu_->arch; + return cpu_read_register64(cpu_, cpu->reg_rbp); +} + +static void x64_init(Cpu *cpu_) +{ + X64Cpu *cpu =3D g_new0(X64Cpu, 1); + cpu_->arch =3D cpu; + cpu->reg_rbp =3D plugin_find_register("rbp"); + g_assert(cpu->reg_rbp); + cpu->reg_cs =3D plugin_find_register("cs"); + g_assert(cpu->reg_cs); + cpu->reg_cr0 =3D plugin_find_register("cr0"); + g_assert(cpu->reg_cr0); +} + +static void x64_end(Cpu *cpu) +{ + g_free(cpu->arch); +} + +static bool x64_does_insn_modify_frame_pointer(const char *disas) +{ + return strstr(disas, "rbp"); +} + +static CpuOps x64_ops =3D { + .init =3D x64_init, + .end =3D x64_end, + .get_frame_pointer =3D x64_get_frame_pointer, + .get_privilege_level =3D x64_get_privilege_level, + .num_privilege_levels =3D x64_num_privilege_levels, + .get_privilege_level_name =3D x64_get_privilege_level_name, + .does_insn_modify_frame_pointer =3D x64_does_insn_modify_frame_pointer, +}; + static void track_privilege_change(unsigned int cpu_index, void *udata) { Cpu *cpu =3D qemu_plugin_scoreboard_find(score, cpu_index); @@ -777,6 +861,8 @@ QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_= id_t id, =20 if (!strcmp(info->target_name, "aarch64")) { arch_ops =3D aarch64_ops; + } else if (!strcmp(info->target_name, "x86_64")) { + arch_ops =3D x64_ops; } else { fprintf(stderr, "plugin uftrace: %s target is not supported\n", info->target_name); --=20 2.47.3 From nobody Sun Sep 28 15:30:20 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1758534290; cv=none; d=zohomail.com; s=zohoarc; b=JhTKWG/Cd7wunFhCBcBdwvuZSS0MPYwct/lCs5Ves9f8dlS3RrSRyvmTNS2OXPhKMIApwZrm4Jz2oQ7kTIh+ENuUvUQJmLuKByAcqitN6WoELUg0XqBM0WhQB7gK9p9bupEqvcjETj2Pr1xQEmtJBgKnB8oMxJIM2IpJJ8wnVA0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1758534290; 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=iqiiGjBNvtYaKdQTe1DwRjyIG78iRIOiYHfJlvRqfHA=; b=SVN4DeryJPXs56oNufIcM4O/52+kML7sn5AC5lSdjdOap3QyaqlvpYj4MmDWZDfNG01fBQtsOneFnl1ChWPdbJwjW7WP4XdumRLvu/PLMWNHbedU39m0bZFhxpWT7RZxU4QeeY6xa0/vx3ualsWbDg2EnvfKC1Zbh/WdUdqw0ws= 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 1758534290367254.32454484282846; Mon, 22 Sep 2025 02:44:50 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v0d5P-0005bs-38; Mon, 22 Sep 2025 05:44:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v0d56-0005O5-OE for qemu-devel@nongnu.org; Mon, 22 Sep 2025 05:43:37 -0400 Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1v0d4p-00020F-46 for qemu-devel@nongnu.org; Mon, 22 Sep 2025 05:43:36 -0400 Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-45ed646b656so36530645e9.3 for ; Mon, 22 Sep 2025 02:43:17 -0700 (PDT) Received: from draig.lan ([185.126.160.19]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3ee073f3d8csm18283021f8f.9.2025.09.22.02.43.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Sep 2025 02:43:14 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id D219E5FA60; Mon, 22 Sep 2025 10:37:13 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1758534195; x=1759138995; 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=iqiiGjBNvtYaKdQTe1DwRjyIG78iRIOiYHfJlvRqfHA=; b=BSvTKnjNonf/Neo7vcVsTUeoX4GUJC6hCAXul/qjbYQ9xT26PWeKeTWRh5nSJKNiNv xUGxz+eUHgl35hmJs8j/JraPkRlXnOkbLWwLpDqT3LDrjRaG1QpksQjg+ittg8nVqKoR uQ9xiXT2RYwI3WcO4duYsLJXYs/HhIAOuaFd/kGroTtZHNW44N0f7Uv1AVZY1GS7IxcB Dv/1Ok7QIRx9Cmbj0z/BSP9SIZ2rBZJcu9eGVWeaIiMYLW9E2Qc7COTHtGzs/nWlcmBg aTwTECYhznTMDCockBdO3bRbchPHwc1ATipl1e1xE2OxhHYrfXkLcrFEPBsSK0bqHcwz jG7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1758534195; x=1759138995; 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=iqiiGjBNvtYaKdQTe1DwRjyIG78iRIOiYHfJlvRqfHA=; b=ZYCj9YSmfBb1Fl6r842u4eIAiR6RuoI9YGrMpc4YBU86eADdmbtDTvBLWgNq9hCL+f lJwWGdYUcUIX6abVwbUJave+g9hiSMQz+f+eyN6JgpFQZuOLVYlppJNBKw0ZEEO0q4ty Tzn9eXLTQPKYYrwFvAk3d1OI59OAxr6rwnfnnBiO/FiTkxUJuNPqM5g8QX+TbDz5JFTf S+0TIQyfwPJ4mboi4Bcw5+COgd3eqxIY+w3meJzHfOjAXNRM5QpgtM04HBocwrk3cNqQ nxeM9VneeIit5NzePe1I9YL6CZRvd/oIUUiyDyXEWa+yf7RlfgPyl+PTODKvwOSqsbYz TUZg== X-Gm-Message-State: AOJu0Yz5HUq3srMp1red0bjNrENkhPlO8CZHKQbQzkFfEPRf85V0s5Qb bO/pBlWDBVVbaWLkUC4X8BXIVOE8i09grKgAsApOwbq9a2oJ51Tuejp2J/tU1ONL7+Y= X-Gm-Gg: ASbGnctS6jW/nY19421c6GRsesE+tie3IQo0cXVZjSRetezjobJC9+ovJoPzpL3e+o/ 8RjcFeTc0eBeSi3K9LPxfzsEslVDNnqu6K+flrKiJzep137XY5vFS0iePAC7apQbVqN43uh6+1U hBerUA9fDUgNM3w8pdO9tfbiHXxHf05YcP6O/zchqQdUqS4+ghz0LohEUhkHg2ggnNxmZICmqG7 t/EdhauoOTGCYuGl00bKILOMtVDR/QzirEGK84MmyUSGvz53zN1dxL5cpLOA6+gs9Kh86LAlwwW euNR7WeWXZnx8yvFZtXE3+nbC+9o78IjHs0h0a7VsD7U/JfYpDrqPcMGOue/cXQbYnEOhy2fJ0m ukDlR4VMsZTF2NkvycWAOu58= X-Google-Smtp-Source: AGHT+IGCo15ZaMp32c22dqH1B5nXWehe70gVLCv9IxMmziyOEJbVn3lp3L8zFn5gf9xkJndgRd+BQg== X-Received: by 2002:a05:600c:a44:b0:45d:f650:376f with SMTP id 5b1f17b1804b1-467efedab3cmr128676865e9.23.1758534194921; Mon, 22 Sep 2025 02:43:14 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Palmer Dabbelt , Alexandre Iooss , Mahmoud Mandour , qemu-riscv@nongnu.org, Daniel Henrique Barboza , Thomas Huth , Peter Maydell , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Alistair Francis , qemu-arm@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Weiwei Li , Pierrick Bouvier , Liu Zhiwei Subject: [PATCH 24/25] contrib/plugins/uftrace_symbols.py Date: Mon, 22 Sep 2025 10:37:09 +0100 Message-ID: <20250922093711.2768983-25-alex.bennee@linaro.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20250922093711.2768983-1-alex.bennee@linaro.org> References: <20250922093711.2768983-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, T_SPF_TEMPERROR=0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1758534291285116600 From: Pierrick Bouvier usage: contrib/plugins/uftrace_symbols.py \ --prefix-symbols \ arm-trusted-firmware/build/qemu/debug/bl1/bl1.elf \ arm-trusted-firmware/build/qemu/debug/bl2/bl2.elf \ arm-trusted-firmware/build/qemu/debug/bl31/bl31.elf \ u-boot/u-boot:0x60000000 \ u-boot/u-boot.relocated:0x000000023f6b6000 \ linux/vmlinux Will generate symbols and memory mapping files for uftrace, allowing to have an enhanced trace, instead of raw addresses. It takes a collection of elf files, and automatically find all their symbols, and generate an ordered memory map based on that. This script uses the python (native) pyelftools module. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Pierrick Bouvier Acked-by: Alex Benn=C3=A9e Message-ID: <20250902075042.223990-9-pierrick.bouvier@linaro.org> Signed-off-by: Alex Benn=C3=A9e --- contrib/plugins/uftrace_symbols.py | 152 +++++++++++++++++++++++++++++ 1 file changed, 152 insertions(+) create mode 100755 contrib/plugins/uftrace_symbols.py diff --git a/contrib/plugins/uftrace_symbols.py b/contrib/plugins/uftrace_s= ymbols.py new file mode 100755 index 00000000000..b49e03203c8 --- /dev/null +++ b/contrib/plugins/uftrace_symbols.py @@ -0,0 +1,152 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# +# Create symbols and mapping files for uftrace. +# +# Copyright 2025 Linaro Ltd +# Author: Pierrick Bouvier +# +# SPDX-License-Identifier: GPL-2.0-or-later + +import argparse +import elftools # pip install pyelftools +import os + +from elftools.elf.elffile import ELFFile +from elftools.elf.sections import SymbolTableSection + +def elf_func_symbols(elf): + symbol_tables =3D [(idx, s) for idx, s in enumerate(elf.iter_sections(= )) + if isinstance(s, SymbolTableSection)] + symbols =3D [] + for _, section in symbol_tables: + for _, symbol in enumerate(section.iter_symbols()): + if symbol_size(symbol) =3D=3D 0: + continue + type =3D symbol['st_info']['type'] + if type =3D=3D 'STT_FUNC' or type =3D=3D 'STT_NOTYPE': + symbols.append(symbol) + symbols.sort(key =3D lambda x: symbol_addr(x)) + return symbols + +def symbol_size(symbol): + return symbol['st_size'] + +def symbol_addr(symbol): + addr =3D symbol['st_value'] + # clamp addr to 48 bits, like uftrace entries + return addr & 0xffffffffffff + +def symbol_name(symbol): + return symbol.name + +class BinaryFile: + def __init__(self, path, map_offset): + self.fullpath =3D os.path.realpath(path) + self.map_offset =3D map_offset + with open(path, 'rb') as f: + self.elf =3D ELFFile(f) + self.symbols =3D elf_func_symbols(self.elf) + + def path(self): + return self.fullpath + + def addr_start(self): + return self.map_offset + + def addr_end(self): + last_sym =3D self.symbols[-1] + return symbol_addr(last_sym) + symbol_size(last_sym) + self.map_of= fset + + def generate_symbol_file(self, prefix_symbols): + binary_name =3D os.path.basename(self.fullpath) + sym_file_path =3D f'./uftrace.data/{binary_name}.sym' + print(f'{sym_file_path} ({len(self.symbols)} symbols)') + with open(sym_file_path, 'w') as sym_file: + # print hexadecimal addresses on 48 bits + addrx =3D "0>12x" + for s in self.symbols: + addr =3D symbol_addr(s) + addr =3D f'{addr:{addrx}}' + size =3D f'{symbol_size(s):{addrx}}' + name =3D symbol_name(s) + if prefix_symbols: + name =3D f'{binary_name}:{name}' + print(addr, size, 'T', name, file=3Dsym_file) + +def parse_parameter(p): + s =3D p.split(":") + path =3D s[0] + if len(s) =3D=3D 1: + return path, 0 + if len(s) > 2: + raise ValueError('only one offset can be set') + offset =3D s[1] + if not offset.startswith('0x'): + err =3D f'offset "{offset}" is not an hexadecimal constant. ' + err +=3D 'It should starts with "0x".' + raise ValueError(err) + offset =3D int(offset, 16) + return path, offset + +def is_from_user_mode(map_file_path): + if os.path.exists(map_file_path): + with open(map_file_path, 'r') as map_file: + if not map_file.readline().startswith('# map stack on'): + return True + return False + +def generate_map(binaries): + map_file_path =3D './uftrace.data/sid-0.map' + + if is_from_user_mode(map_file_path): + print(f'do not overwrite {map_file_path} generated from qemu-user') + return + + mappings =3D [] + + # print hexadecimal addresses on 48 bits + addrx =3D "0>12x" + + mappings +=3D ['# map stack on highest address possible, to prevent uf= trace'] + mappings +=3D ['# from considering any kernel address'] + mappings +=3D ['ffffffffffff-ffffffffffff rw-p 00000000 00:00 0 [stack= ]'] + + for b in binaries: + m =3D f'{b.addr_start():{addrx}}-{b.addr_end():{addrx}}' + m +=3D f' r--p 00000000 00:00 0 {b.path()}' + mappings.append(m) + + with open(map_file_path, 'w') as map_file: + print('\n'.join(mappings), file=3Dmap_file) + print(f'{map_file_path}') + print('\n'.join(mappings)) + +def main(): + parser =3D argparse.ArgumentParser(description=3D + 'generate symbol files for uftrace') + parser.add_argument('elf_file', nargs=3D'+', + help=3D'path to an ELF file. ' + 'Use /path/to/file:0xdeadbeef to add a mapping off= set.') + parser.add_argument('--prefix-symbols', + help=3D'prepend binary name to symbols', + action=3Dargparse.BooleanOptionalAction) + args =3D parser.parse_args() + + if not os.path.exists('./uftrace.data'): + os.mkdir('./uftrace.data') + + binaries =3D [] + for file in args.elf_file: + path, offset =3D parse_parameter(file) + b =3D BinaryFile(path, offset) + binaries.append(b) + binaries.sort(key =3D lambda b: b.addr_end()); + + for b in binaries: + b.generate_symbol_file(args.prefix_symbols) + + generate_map(binaries) + +if __name__ =3D=3D '__main__': + main() --=20 2.47.3 From nobody Sun Sep 28 15:30:20 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1758534312; cv=none; d=zohomail.com; s=zohoarc; b=hHZtSf5R41z0lQp/uwNFO8NdSWz/4UCmj7deBF/5ybpf2HaPf5LOY4Ny07AbJaNeku2a43HLACUL9x7w2rYpLw0vQZ4+mkhi6zWdpO5v5xg27+uaWAXw5ULR/CHsM1cUTd5x/ObFtYZROsTp8/w7pDTf0HEmS/e32HEIeO1+ihI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1758534312; 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=30/Sw7/xAd9JXNBC4JguewcrlL8rhREEZz71xctzWtw=; b=Mxo+RaSNrd/UXnNCqjEwQx6Psh/bEc4skLOEZICJvKfFOrDC+zze4I3fm0EIBEt5CrwyFztuZTNc29r4kXyNtiml2m3moHqvkBcENieu4lUkwZYkqjWZdJBcc3LZnLybBDojxGhs9IX2O1rJ2u48WIcH0Yxsz+383ZzWYCvbAOc= 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 1758534312526337.42914488421536; Mon, 22 Sep 2025 02:45:12 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v0d5z-0006DQ-SO; Mon, 22 Sep 2025 05:44:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v0d5A-0005Sa-8S for qemu-devel@nongnu.org; Mon, 22 Sep 2025 05:43:43 -0400 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1v0d4p-000219-Kw for qemu-devel@nongnu.org; Mon, 22 Sep 2025 05:43:38 -0400 Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-46b7bf21fceso13604645e9.3 for ; Mon, 22 Sep 2025 02:43:19 -0700 (PDT) Received: from draig.lan ([185.126.160.19]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3ee07407d33sm19370945f8f.18.2025.09.22.02.43.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Sep 2025 02:43:14 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id EBA335FA6C; Mon, 22 Sep 2025 10:37:13 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1758534197; x=1759138997; 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=30/Sw7/xAd9JXNBC4JguewcrlL8rhREEZz71xctzWtw=; b=K8PYXxe96pRYX8Fcz/B4YzSUpoJtA+WLySxAmEP6sP1DPYIhhGCfqrK3/pJyh3+GuF awKaGNzdBaoCk9RS9IqjsjNCY0SfS3M7b1j4Fs6BKmq6ob+XxagwWL3TPlRMTjOID9WU MvlMOf7PwPGTb6vnqnx3KCg1b0KwFJmj0TUS/Ot2aZVgXH37fDSyAFbPYC6XFC4o6Qz6 WovH1MO/o6qK9C1apJiLpkfRJBvg9bWNQGsIVWm6G/rBpDvnf4qMb1ygfZ7HVKKXf5uf lU+M8lviXif+z5npSVH2rLHVKFY9P4J9UmOv5HQcxIZI8x/TMl0cJTE2KkEqZJjvsnuN w4iQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1758534197; x=1759138997; 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=30/Sw7/xAd9JXNBC4JguewcrlL8rhREEZz71xctzWtw=; b=wdiV5cS2mZoslGMs+YmALwkhmegV9R9PDEXHgo3IFpqX12UJ/ctiLrs1XmZvy5iJhg yL4tGwYKgo2dKoOGLV6seFCR9ff0qelq9fww3XyUzEVeMOJX2RLiLIcSIWq9ZBuiXORF oZQfTIt9TdJ6A6vGIeg2tKoJXED9fb05Gek0BmdjlsxeFsaiVWlOsFVlo72RW9kPCQde cxBjf1NxV4DKpnCPsm7iynmf7jpK0ZWGZXp/tzZXOFCaHrzn1ZcmU+p+lg2VjXbfQpwC M67P3iIUseWOJRpm/J89pwEcRNJxpV09yTGYH/UNHpF2u4SqqWt7nQ4i7Jk3yGNjVRN3 vVJQ== X-Gm-Message-State: AOJu0YxNltLxSvylqeolS781944tapozEEBt9EW7PHlzkHPIv82P5eC5 swyVXwhzLuGDMSLEhg9czZeQusS9PiYpL3gzu5hNfLy454/HtWKDFawk3zeK3JPsTIw= X-Gm-Gg: ASbGnct8kPhlF0hdi3KtcH3nwISJkcZIY2+CGu8eYjiYL+kckKOTBR4Dh0wimktr4fr kfCilNGwzxw5++OHJFc5TdRa6VfZX9W1Wg6OjuD8zX9O2j9NrIbEplxFpcIZvparMsCDAPOWxHx jpq4yli5rPC5SPosr6g6K3hrBXmRh9u5utk9UEhLiLk1WN+DhLzpOjm+yIXrEuGO8UpqZNZomiL D7FEgC8VZwxbO4FWgZmEjrg9VoJlDhU1D4rD3URCq1i5Zhksyovqd3zcZKgMc7dPitwEjCusc2l aAiLEKhoLpTx/AZdcyylIbTT79VAcMm6zZ7B5cUcKr6ooM2EhoDhGX9feQ3eUUe6+s1ZumoeVyk ZO1DHqb+LbxbLYkSsRc7eitQ= X-Google-Smtp-Source: AGHT+IEr4H07owG+xBQBwEkJEDkgU6g+J+fTCesMM1MjRJs0OT/DRbC4Ba+MvUjyq+UGC2HTtIP2Tg== X-Received: by 2002:a05:600c:1c03:b0:46d:fe0b:d55a with SMTP id 5b1f17b1804b1-46dfe0bd756mr11149635e9.33.1758534197144; Mon, 22 Sep 2025 02:43:17 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Palmer Dabbelt , Alexandre Iooss , Mahmoud Mandour , qemu-riscv@nongnu.org, Daniel Henrique Barboza , Thomas Huth , Peter Maydell , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Alistair Francis , qemu-arm@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Weiwei Li , Pierrick Bouvier , Liu Zhiwei , Manos Pitsidianakis Subject: [PATCH 25/25] contrib/plugins/uftrace: add documentation Date: Mon, 22 Sep 2025 10:37:10 +0100 Message-ID: <20250922093711.2768983-26-alex.bennee@linaro.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20250922093711.2768983-1-alex.bennee@linaro.org> References: <20250922093711.2768983-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::333; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x333.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1758534314013116600 From: Pierrick Bouvier This documentation summarizes how to use the plugin, and present two examples of the possibilities offered by it, in system and user mode. As well, it explains how to rebuild and reproduce those examples. Reviewed-by: Manos Pitsidianakis Signed-off-by: Pierrick Bouvier Message-ID: <20250902075042.223990-10-pierrick.bouvier@linaro.org> Signed-off-by: Alex Benn=C3=A9e --- docs/about/emulation.rst | 199 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 199 insertions(+) diff --git a/docs/about/emulation.rst b/docs/about/emulation.rst index 456d01d5b08..8a5e128f677 100644 --- a/docs/about/emulation.rst +++ b/docs/about/emulation.rst @@ -816,6 +816,205 @@ This plugin can limit the number of Instructions Per = Second that are executed:: The lower the number the more accurate time will be, but the less ef= ficient the plugin. Defaults to ips/10 =20 +Uftrace +....... + +``contrib/plugins/uftrace.c`` + +This plugin generates a binary trace compatible with +`uftrace `_. + +Plugin supports aarch64 and x64, and works in user and system mode, allowi= ng to +trace a system boot, which is not something possible usually. + +In user mode, the memory mapping is directly copied from ``/proc/self/maps= `` at +the end of execution. Uftrace should be able to retrieve symbols by itself, +without any additional step. +In system mode, the default memory mapping is empty, and you can generate +one (and associated symbols) using ``contrib/plugins/uftrace_symbols.py``. +Symbols must be present in ELF binaries. + +It tracks the call stack (based on frame pointer analysis). Thus, your pro= gram +and its dependencies must be compiled using ``-fno-omit-frame-pointer +-mno-omit-leaf-frame-pointer``. In 2024, `Ubuntu and Fedora enabled it by +default again on x64 +`_. +On aarch64, this is less of a problem, as they are usually part of the ABI, +except for leaf functions. That's true for user space applications, but not +necessarily for bare metal code. You can read this `section +` to easily build a system with frame pointe= rs. + +When tracing long scenarios (> 1 min), the generated trace can become very= long, +making it hard to extract data from it. In this case, a simple solution is= to +trace execution while generating a timestamped output log using +``qemu-system-aarch64 ... | ts "%s"``. Then, ``uftrace --time-range=3Dstar= t~end`` +can be used to reduce trace for only this part of execution. + +Performance wise, overhead compared to normal tcg execution is around x5-x= 15. + +.. list-table:: Uftrace plugin arguments + :widths: 20 80 + :header-rows: 1 + + * - Option + - Description + * - trace-privilege-level=3D[on|off] + - Generate separate traces for each privilege level (Exception Level + + Security State on aarch64, Rings on x64). + +.. list-table:: uftrace_symbols.py arguments + :widths: 20 80 + :header-rows: 1 + + * - Option + - Description + * - elf_file [elf_file ...] + - path to an ELF file. Use /path/to/file:0xdeadbeef to add a mapping o= ffset. + * - --prefix-symbols + - prepend binary name to symbols + +Example user trace +++++++++++++++++++ + +As an example, we can trace qemu itself running git:: + + $ ./build/qemu-aarch64 -plugin \ + build/contrib/plugins/libuftrace.so \ + ./build/qemu-aarch64 /usr/bin/git --help + + # and generate a chrome trace directly + $ uftrace dump --chrome | gzip > ~/qemu_aarch64_git_help.json.gz + +For convenience, you can download this trace `qemu_aarch64_git_help.json.gz +`_. +Download it and open this trace on https://ui.perfetto.dev/. You can zoom = in/out +using :kbd:`W`, :kbd:`A`, :kbd:`S`, :kbd:`D` keys. +Some sequences taken from this trace: + +- Loading program and its interpreter + +.. image:: https://fileserver.linaro.org/s/fie8JgX76yyL5cq/preview + :height: 200px + +- open syscall + +.. image:: https://fileserver.linaro.org/s/rsXPTeZZPza4PcE/preview + :height: 200px + +- TB creation + +.. image:: https://fileserver.linaro.org/s/GXY6NKMw5EeRCew/preview + :height: 200px + +It's usually better to use ``uftrace record`` directly. However, tracing +binaries through qemu-user can be convenient when you don't want to recomp= ile +them (``uftrace record`` requires instrumentation), as long as symbols are +present. + +Example system trace +++++++++++++++++++++ + +A full trace example (chrome trace, from instructions below) generated fro= m a +system boot can be found `here +`_. +Download it and open this trace on https://ui.perfetto.dev/. You can see c= ode +executed for all privilege levels, and zoom in/out using +:kbd:`W`, :kbd:`A`, :kbd:`S`, :kbd:`D` keys. You can find below some seque= nces +taken from this trace: + +- Two first stages of boot sequence in Arm Trusted Firmware (EL3 and S-EL1) + +.. image:: https://fileserver.linaro.org/s/kkxBS552W7nYESX/preview + :height: 200px + +- U-boot initialization (until code relocation, after which we can't track= it) + +.. image:: https://fileserver.linaro.org/s/LKTgsXNZFi5GFNC/preview + :height: 200px + +- Stat and open syscalls in kernel + +.. image:: https://fileserver.linaro.org/s/dXe4MfraKg2F476/preview + :height: 200px + +- Timer interrupt + +.. image:: https://fileserver.linaro.org/s/TM5yobYzJtP7P3C/preview + :height: 200px + +- Poweroff sequence (from kernel back to firmware, NS-EL2 to EL3) + +.. image:: https://fileserver.linaro.org/s/oR2PtyGKJrqnfRf/preview + :height: 200px + +Build and run system example +++++++++++++++++++++++++++++ + +.. _uftrace_build_system_example: + +Building a full system image with frame pointers is not trivial. + +We provide a `simple way `= _ to +build an aarch64 system, combining Arm Trusted firmware, U-boot, Linux ker= nel +and debian userland. It's based on containers (``podman`` only) and +``qemu-user-static (binfmt)`` to make sure it's easily reproducible and do= es not depend +on machine where you build it. + +You can follow the exact same instructions for a x64 system, combining edk= 2, +Linux, and Ubuntu, simply by switching to +`x86_64 `_ bra= nch. + +To build the system:: + + # Install dependencies + $ sudo apt install -y podman qemu-user-static + + $ git clone https://github.com/pbo-linaro/qemu-linux-stack + $ cd qemu-linux-stack + $ ./build.sh + + # system can be started using: + $ ./run.sh /path/to/qemu-system-aarch64 + +To generate a uftrace for a system boot from that:: + + # run true and poweroff the system + $ env INIT=3Dtrue ./run.sh path/to/qemu-system-aarch64 \ + -plugin path/to/contrib/plugins/libuftrace.so,trace-privilege-level= =3Don + + # generate symbols and memory mapping + $ path/to/contrib/plugins/uftrace_symbols.py \ + --prefix-symbols \ + arm-trusted-firmware/build/qemu/debug/bl1/bl1.elf \ + arm-trusted-firmware/build/qemu/debug/bl2/bl2.elf \ + arm-trusted-firmware/build/qemu/debug/bl31/bl31.elf \ + u-boot/u-boot:0x60000000 \ + linux/vmlinux + + # inspect trace with + $ uftrace replay + +Uftrace allows to filter the trace, and dump flamegraphs, or a chrome trac= e. +This last one is very interesting to see visually the boot process:: + + $ uftrace dump --chrome > boot.json + # Open your browser, and load boot.json on https://ui.perfetto.dev/. + +Long visual chrome traces can't be easily opened, thus, it might be +interesting to generate them around a particular point of execution:: + + # execute qemu and timestamp output log + $ env INIT=3Dtrue ./run.sh path/to/qemu-system-aarch64 \ + -plugin path/to/contrib/plugins/libuftrace.so,trace-privilege-level= =3Don |& + ts "%s" | tee exec.log + + $ cat exec.log | grep 'Run /init' + 1753122320 [ 11.834391] Run /init as init process + # init was launched at 1753122320 + + # generate trace around init execution (2 seconds): + $ uftrace dump --chrome --time-range=3D1753122320~1753122322 > init.js= on + Other emulation features ------------------------ =20 --=20 2.47.3