From nobody Tue Nov 26 06:56:45 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1709736073; cv=none; d=zohomail.com; s=zohoarc; b=RLrDoYkumOJF5MLBGl6tcNcX1hANHKU8273HCL45Ul9O0d5HLYXxC0JP8atGSorRPHtwjHrpfHcw4yhzclBeWE0rL/Alj+u12EW/f4PNKLQQs8T5a+lxV63H/R2AXRQqipdCu1qqRG8gjxWXJB8Ob/sVT7poEmKZPzNGWuZsdqs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709736073; 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=mCuo1I1x614Ggqxx0hsNU8XUHD4jpmgy247WPP2wLWU=; b=GAjB4SqoCPnaVR52pfjersmAV0L5zv6/700E8lIuUhGxUavLNJWybmUt4uJN+MKAwIUK5df7125AsY3nOd7Y9LMmdkXfHXgYmEtgMyzGEva6XqJuZpVLhSuQn9KqMEKfKMJNMOFpAmjxvM6kjk9Q2Bc4qTfLsCKFP/wDGsWjLeQ= 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 1709736073960389.9068852160499; Wed, 6 Mar 2024 06:41:13 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rhsSB-0007of-6Q; Wed, 06 Mar 2024 09:41:09 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rhsS8-0007hS-Fx for qemu-devel@nongnu.org; Wed, 06 Mar 2024 09:41:04 -0500 Received: from mail-wm1-x330.google.com ([2a00:1450:4864:20::330]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rhsRx-0001TG-90 for qemu-devel@nongnu.org; Wed, 06 Mar 2024 09:41:04 -0500 Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-412e6bdd454so22290275e9.1 for ; Wed, 06 Mar 2024 06:40:43 -0800 (PST) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id bu16-20020a056000079000b0033dc3f3d689sm17930874wrb.93.2024.03.06.06.40.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Mar 2024 06:40:42 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id A2B4B5F8A9; Wed, 6 Mar 2024 14:40:41 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1709736042; x=1710340842; 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=mCuo1I1x614Ggqxx0hsNU8XUHD4jpmgy247WPP2wLWU=; b=NcU48xwdRRiXMLoD2tJMMa0kY3DKVPB7ZKEFUS06+mAnd0vW/bH0mcGPuiGiGj/22J 3mOfCpi8Zai5EtLUptUCFRj/L51aYJXf30Bg5cdYDSQN2hVN8CfYgi9LC8/a8ATnhEtL tXdJVoq/f9u6RbUgRqtUmfQ0O7bKuykXOLgz4tgCuQdmGY2lvC2BJG7h/oBZENXHSysA 7V5y60B6eg/LG+xfdEkN4W53ypgtpVY9j4ByBam5ov4635lF5fcpPKEYCwEXDKzrAhLU SJ+94ENY4qCr/aSZKMd7gwful9o++WjP1H7eU9Z+ZYbke7okKWS85z2mNlLBQlafhV84 mcfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709736042; x=1710340842; 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=mCuo1I1x614Ggqxx0hsNU8XUHD4jpmgy247WPP2wLWU=; b=UacfjYcnm98jYlhhhu2KMHORbcjMWdzFVP+Gl/UJ0tBFV8M9wZ45ZEULWVvPLsp2k5 NSDbhe5aTnr5ZusjZS7lxLYK904EJlFoKjY653WmHk36zMiSN7OGbTzAvP3Zo9hHs5aQ 4cY8JcyrnvTa9nC55q/TyijtWsGGR26BNhKVfQv6Z0GiTna+UVIXVDEZMimuZT3vcXqF ZKiovmXyS47uYPRDXQCEaK3fm0RUvNCX5ItvWWQPTkOT/iCc6lsaMWzWyXS8eD6qwx7/ LWpXeoZ3PXvj3NxKBd5OIoxzIolr/5lLRc3VhbJQj/bBpeqzsyDVsmcCNVI9IZhorNdY N0LA== X-Gm-Message-State: AOJu0YwN1fp/YBXs2aPV82zmHF6+V1lvbkWzDB4s24fA6QMGKG6onFRK T32fAvGU+hBRAIfIqtcr33/0tINyEM5/DPw5YTIQ7DneC2KK2FIepTY45BB9z6s= X-Google-Smtp-Source: AGHT+IFX992rEZfKIGjAhXN01fY6cGqE0XDulcv68CHJDttNHtmXYV7CasoPkStWHGBxsIJAtq+JvQ== X-Received: by 2002:a5d:49ca:0:b0:33e:4750:2250 with SMTP id t10-20020a5d49ca000000b0033e47502250mr4489258wrs.62.1709736042452; Wed, 06 Mar 2024 06:40:42 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= , Thomas Huth , Laurent Vivier , Paolo Bonzini Subject: [PULL 01/29] tests: bump QOS_PATH_MAX_ELEMENT_SIZE again Date: Wed, 6 Mar 2024 14:40:13 +0000 Message-Id: <20240306144041.3787188-2-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240306144041.3787188-1-alex.bennee@linaro.org> References: <20240306144041.3787188-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_SCC_BODY_TEXT_LINE=-0.01, 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: 1709736075519100003 We "fixed" a bug with LTO builds with 100c459f194 (tests/qtest: bump up QOS_PATH_MAX_ELEMENT_SIZE) but it seems it has triggered again. The array is sized according to the maximum anticipated length of a path on the graph. However, the worst case for a depth-first search is to push all nodes on the graph. So it's not really LTO, it depends on the ordering of the constructors. Lets be more assertive raising QOS_PATH_MAX_ELEMENT_SIZE to make it go away again. Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1186 (again) Reviewed-by: Thomas Huth Signed-off-by: Alex Benn=C3=A9e Message-Id: <20240305121005.3528075-2-alex.bennee@linaro.org> diff --git a/tests/qtest/libqos/qgraph.h b/tests/qtest/libqos/qgraph.h index 287022a67c1..1b5de02e7be 100644 --- a/tests/qtest/libqos/qgraph.h +++ b/tests/qtest/libqos/qgraph.h @@ -24,7 +24,7 @@ #include "libqos-malloc.h" =20 /* maximum path length */ -#define QOS_PATH_MAX_ELEMENT_SIZE 64 +#define QOS_PATH_MAX_ELEMENT_SIZE 128 =20 typedef struct QOSGraphObject QOSGraphObject; typedef struct QOSGraphNode QOSGraphNode; --=20 2.39.2 From nobody Tue Nov 26 06:56:45 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1709736124; cv=none; d=zohomail.com; s=zohoarc; b=Mgj3vNs32/qE9OoMcZRiZUUZkGXyin0I5k89KrcbaiBY+yJbSSvxnZTUbMOawZ7sif3t9k4y985yK8qnFsZXgp/aUFdQ9JO80VZXGDmn4y1K9jI7c2c+FynrmnSeP8bALrgw00Wglrm+V6MR2mJyItEDUiWshvouMUd7nYYmoXQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709736124; 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=k2Ye6Zrq5ycHJhjf1w+zvDuLih/aI2ewQNO57VPgIhs=; b=KYxXSdfStENehg5UeiqZWSQcUjC6ytqCqiyk+tPVFj8MKCjFr0vj3ZFzE4Kpbu9yHnK+P36wyt8Pp6SwVoxodc4d87Nxwj4ITfBm/99cgEtu0Fr6hm5mRhLf2wG7UzTsQ7bXRZWASDnt3IGPKG9QdUPJBIzN9TVJu7lvCVGEr28= 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 1709736124276661.4285408880529; Wed, 6 Mar 2024 06:42:04 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rhsS3-0007Ij-0t; Wed, 06 Mar 2024 09:40:59 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rhsS0-00078A-Bp for qemu-devel@nongnu.org; Wed, 06 Mar 2024 09:40:56 -0500 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 1rhsRx-0001TJ-9C for qemu-devel@nongnu.org; Wed, 06 Mar 2024 09:40:56 -0500 Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-412e784060cso5720475e9.1 for ; Wed, 06 Mar 2024 06:40:44 -0800 (PST) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id d8-20020a05600c3ac800b00412e84e59d8sm7327075wms.44.2024.03.06.06.40.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Mar 2024 06:40:42 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id B71465F94F; Wed, 6 Mar 2024 14:40:41 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1709736043; x=1710340843; 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=k2Ye6Zrq5ycHJhjf1w+zvDuLih/aI2ewQNO57VPgIhs=; b=btNnCXZM20Nr3KsNk9UDxk57AOFcAn1Rqb+eJyngGJ5cpZApvJ4SIjY7kHG7RcRthI d9hKcAIBzzuClkPnymwpUJD8fKjiKVvSl6eeuPnzAhFvHxnqymqyL79CNjeN7f2DuFeq pyI+AkfqXPT8QhRedhzDE4ivrj2mQtl3MPBTF8Dm7w9KzvL4o8f/Mad7AnlfM07cfSUq EAQsMRRrH64+99eD8HbTElx35/WFw27tEzEMq/wcUD6dCZiu4K1sa5O2QCNsrXG2C/8V 4p5bjnxYXt9bsUpyysCT0HZUQJEK6FaH5idbl1HSZvy3glVbwp6Z1k1yfl2r4OFxhnWX qNWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709736043; x=1710340843; 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=k2Ye6Zrq5ycHJhjf1w+zvDuLih/aI2ewQNO57VPgIhs=; b=uEhhkKJZ5hiLuHYrYHSPEk3cXKPCCYIhwcS2s8Xzt7rhCWwsdyJwymb/egllckFJI2 WRoON4EBass75GNJCo4twd5dZxdW8kQmDFZpoEidTmFiQsZWmIkEuVJ0HXwqsUz4m9ku CytYaw1SxYK0hqfJTLR8eiDvSqb79GuWPvneHRgLcNsrM4Qs7XUI/c8s2P+3/bq8Mmwr 2gYIyuLUoXOOnFct10v0K4UDwqSMhcLWe59tysH6ZUS6VNfK0DDj0rYD45WGc2BYsues 7RCDXXndpQI2skXy6MRj1liAagmqvd/FNzm+StuM0lws7pTe5uxAKy3+31YSgnkvg+SC 0yYw== X-Gm-Message-State: AOJu0YwjKgB0B3zUwzRFZ4jNb739s/pj9Cp86mBNScnBTfb/7YsB/UkV VF4Ign/lHQ4wEWhK6vpvfstCpRU558Whi4WxmFCdvgjxcaQvyfa1MTKhls7PVHE= X-Google-Smtp-Source: AGHT+IHlz45Gn7ESMV/ctU8xgFgN0UC6JJJgTe8NnCAyoC/UUn26RqywWd+2E3SrpBEtB9FrXCLcDw== X-Received: by 2002:a05:600c:1d09:b0:412:c285:1091 with SMTP id l9-20020a05600c1d0900b00412c2851091mr4915995wms.7.1709736042789; Wed, 06 Mar 2024 06:40:42 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Ilya Leoshkevich , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PULL 02/29] gdbstub: Support disablement in a multi-threaded process Date: Wed, 6 Mar 2024 14:40:14 +0000 Message-Id: <20240306144041.3787188-3-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240306144041.3787188-1-alex.bennee@linaro.org> References: <20240306144041.3787188-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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1709736125764100003 From: Ilya Leoshkevich The upcoming follow-fork-mode child support will require disabling gdbstub in the parent process, which may have multiple threads (which are represented as CPUs). Loop over all CPUs in order to remove breakpoints and disable single-step. Move the respective code into a separate function. Reviewed-by: Alex Benn=C3=A9e Reviewed-by: Richard Henderson Signed-off-by: Ilya Leoshkevich Message-Id: <20240219141628.246823-2-iii@linux.ibm.com> Signed-off-by: Alex Benn=C3=A9e Message-Id: <20240305121005.3528075-3-alex.bennee@linaro.org> diff --git a/gdbstub/user.c b/gdbstub/user.c index 14918d1a217..3ce20b7bbfc 100644 --- a/gdbstub/user.c +++ b/gdbstub/user.c @@ -356,16 +356,27 @@ int gdbserver_start(const char *port_or_path) return -1; } =20 +static void disable_gdbstub(CPUState *thread_cpu) +{ + CPUState *cpu; + + close(gdbserver_user_state.fd); + gdbserver_user_state.fd =3D -1; + CPU_FOREACH(cpu) { + cpu_breakpoint_remove_all(cpu, BP_GDB); + /* no cpu_watchpoint_remove_all for user-mode */ + cpu_single_step(cpu, 0); + } + tb_flush(thread_cpu); +} + /* Disable gdb stub for child processes. */ void gdbserver_fork(CPUState *cpu) { if (!gdbserver_state.init || gdbserver_user_state.fd < 0) { return; } - close(gdbserver_user_state.fd); - gdbserver_user_state.fd =3D -1; - cpu_breakpoint_remove_all(cpu, BP_GDB); - /* no cpu_watchpoint_remove_all for user-mode */ + disable_gdbstub(cpu); } =20 /* --=20 2.39.2 From nobody Tue Nov 26 06:56:45 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1709736284; cv=none; d=zohomail.com; s=zohoarc; b=n50ODO5dyvOR4KoU0KlxB7797vY2nyrHPskoOwD1Go6PUzUEjHl6Kajd4Al1vVk10tP1uyX113BVTW+HYhwm01yOewWndNGzc8SqFwsKviMRUA19BSkstNHUHPa72IUOyA8W5Ak0jU6VEysNm/Vteahxvws8XIF2OvykX8mv1O4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709736284; 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=pBWw39x9Y3CEwJFUzLCHvRqlhcIeKghiDHEbNXeg0I0=; b=TSWqQ/Xb+Y1YEdKxaM1n0PDT2bGb5QInZ55Mn9WQA2c+uINqlp6jLqDxG1uuO27BsFCYsh9qljvqYeaLWvfiowGT5D4kRXipvp4yFcdpq7O26R9HrJ/q8yhjOsAK84JksGA5fsSrwlEMNEj+VIK7ZpplflOjplI18A8M7Lu6BsI= 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 1709736284441813.8134596367407; Wed, 6 Mar 2024 06:44:44 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rhsS8-0007i5-M3; Wed, 06 Mar 2024 09:41:04 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rhsS7-0007b8-7K for qemu-devel@nongnu.org; Wed, 06 Mar 2024 09:41:03 -0500 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rhsRx-0001TL-9F for qemu-devel@nongnu.org; Wed, 06 Mar 2024 09:41:02 -0500 Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-412f988b601so3441075e9.0 for ; Wed, 06 Mar 2024 06:40:44 -0800 (PST) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id hg5-20020a05600c538500b00412eeb017f0sm4759357wmb.34.2024.03.06.06.40.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Mar 2024 06:40:42 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id E84945F950; Wed, 6 Mar 2024 14:40:41 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1709736043; x=1710340843; 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=pBWw39x9Y3CEwJFUzLCHvRqlhcIeKghiDHEbNXeg0I0=; b=PDgOq6unfyUZfc2fQwWnkzFUH87cDrIbiEO+XD+B8Enjcz+AcSaoA3Xzypf+RtriTN JXb13kSqzdJsIfp/JFrBml53sJpnJ5Y/Rg+voMpp4r5Rdf0URGxi8APWgCC2ryGMbDTt er7Pecg7St8GV/aQXXGwRqU8j0gxe+BXuclcsV4L+b9Ou6jFcf93yvHOxzMTEpgGaFEh yCNi4geCwdnMHfa+xBbUdkoFjDG5uqjeED6cgDqDff2WkMiUq8/fJXbouI/diKchGhjh hUoc1ln7pj+uCybWhzX8BpGKJ4oUorH2Ys6ZHCK+JwF4dGrLmAJV+pHRgNCm9Yv0EI3p DuIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709736043; x=1710340843; 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=pBWw39x9Y3CEwJFUzLCHvRqlhcIeKghiDHEbNXeg0I0=; b=rThRo6PVbUI4yIxGk2QdmXS5iX+Numd685JPYd0kx1/7dacYHjymKRg2BPQ9oG8uaz 1qjyFPbxP5b5rP9uCrZ94yTMnL7st0SzVpLGarSxgfx2e8XX527D0+ipJzNMZHh+38iW 9xTk6dN8l8BGSBg/vAfMkpg9c7UpVLQJ591C4yzkNcCTYqCGYzlPBn/bhgkLGFc2wFOX o9Xnd7zn27n1QHQheNWNGyYAvnStceej22cx15PKNaR6WRDO/c87p/TZO6OHnhiuvHXY NSrY2sRl0onoKGreHNMzXwyZHmlG1k1sRB3K3Tlwtim5+ztJQeQXxaoKsQPOh98ZsHdW tksQ== X-Gm-Message-State: AOJu0YysHO6Kybo92rOvkopccWMgh8YkqKebZoLtms1VGvdSxsp4Zfvb 5J4dIbG9TgnXcT2MsXo5oeDS9HHY8iUhln0PoyVaPHmQa6ZVp61SBEjNgQYtq3E= X-Google-Smtp-Source: AGHT+IHefa31uMcVa9KeG8KWrVVbtvn9fp/vpOH4gQE5aZXM0jwpXUe3jLcQFnjWIngPdYQpBE0qjA== X-Received: by 2002:a05:600c:470f:b0:412:900e:84de with SMTP id v15-20020a05600c470f00b00412900e84demr11725288wmo.38.1709736043025; Wed, 06 Mar 2024 06:40:43 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Ilya Leoshkevich , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Warner Losh , Richard Henderson , Kyle Evans , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Riku Voipio , Laurent Vivier , Alexandre Iooss , Mahmoud Mandour , Pierrick Bouvier Subject: [PULL 03/29] {linux,bsd}-user: Introduce get_task_state() Date: Wed, 6 Mar 2024 14:40:15 +0000 Message-Id: <20240306144041.3787188-4-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240306144041.3787188-1-alex.bennee@linaro.org> References: <20240306144041.3787188-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::331; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x331.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=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: 1709736286667100001 From: Ilya Leoshkevich A CPU's TaskState is stored in the CPUState's void *opaque field, accessing which is somewhat awkward due to having to use a cast. Introduce a wrapper and use it everywhere. Suggested-by: Alex Benn=C3=A9e Signed-off-by: Ilya Leoshkevich Reviewed-by: Warner Losh Reviewed-by: Richard Henderson Message-Id: <20240219141628.246823-3-iii@linux.ibm.com> Signed-off-by: Alex Benn=C3=A9e Message-Id: <20240305121005.3528075-4-alex.bennee@linaro.org> diff --git a/bsd-user/bsd-file.h b/bsd-user/bsd-file.h index 3c00dc00567..6fa2c30b4de 100644 --- a/bsd-user/bsd-file.h +++ b/bsd-user/bsd-file.h @@ -641,7 +641,7 @@ static abi_long do_bsd_readlink(CPUArchState *env, abi_= long arg1, } if (strcmp(p1, "/proc/curproc/file") =3D=3D 0) { CPUState *cpu =3D env_cpu(env); - TaskState *ts =3D (TaskState *)cpu->opaque; + TaskState *ts =3D get_task_state(cpu); strncpy(p2, ts->bprm->fullpath, arg3); ret =3D MIN((abi_long)strlen(ts->bprm->fullpath), arg3); } else { diff --git a/bsd-user/qemu.h b/bsd-user/qemu.h index c05c5127676..4adb75d19ff 100644 --- a/bsd-user/qemu.h +++ b/bsd-user/qemu.h @@ -117,6 +117,11 @@ typedef struct TaskState { struct target_sigaltstack sigaltstack_used; } __attribute__((aligned(16))) TaskState; =20 +static inline TaskState *get_task_state(CPUState *cs) +{ + return cs->opaque; +} + void stop_all_tasks(void); extern const char *interp_prefix; extern const char *qemu_uname_release; diff --git a/include/user/safe-syscall.h b/include/user/safe-syscall.h index 27b71cdbd8e..aa075f4d5cd 100644 --- a/include/user/safe-syscall.h +++ b/include/user/safe-syscall.h @@ -134,7 +134,7 @@ extern char safe_syscall_start[]; extern char safe_syscall_end[]; =20 #define safe_syscall(...) \ - safe_syscall_base(&((TaskState *)thread_cpu->opaque)->signal_pending, \ + safe_syscall_base(&get_task_state(thread_cpu)->signal_pending, \ __VA_ARGS__) =20 #endif diff --git a/linux-user/m68k/target_cpu.h b/linux-user/m68k/target_cpu.h index c3f288dfe83..4b40c09a8d6 100644 --- a/linux-user/m68k/target_cpu.h +++ b/linux-user/m68k/target_cpu.h @@ -37,7 +37,7 @@ static inline void cpu_clone_regs_parent(CPUM68KState *en= v, unsigned flags) static inline void cpu_set_tls(CPUM68KState *env, target_ulong newtls) { CPUState *cs =3D env_cpu(env); - TaskState *ts =3D cs->opaque; + TaskState *ts =3D get_task_state(cs); =20 ts->tp_value =3D newtls; } diff --git a/linux-user/qemu.h b/linux-user/qemu.h index 4de9ec783f6..32cd43d9eff 100644 --- a/linux-user/qemu.h +++ b/linux-user/qemu.h @@ -162,6 +162,11 @@ typedef struct TaskState { uint64_t start_boottime; } TaskState; =20 +static inline TaskState *get_task_state(CPUState *cs) +{ + return cs->opaque; +} + abi_long do_brk(abi_ulong new_brk); int do_guest_openat(CPUArchState *cpu_env, int dirfd, const char *pathname, int flags, mode_t mode, bool safe); diff --git a/linux-user/signal-common.h b/linux-user/signal-common.h index 3e2dc604c2f..a7df12fc445 100644 --- a/linux-user/signal-common.h +++ b/linux-user/signal-common.h @@ -113,7 +113,7 @@ int process_sigsuspend_mask(sigset_t **pset, target_ulo= ng sigset, static inline void finish_sigsuspend_mask(int ret) { if (ret !=3D -QEMU_ERESTARTSYS) { - TaskState *ts =3D (TaskState *)thread_cpu->opaque; + TaskState *ts =3D get_task_state(thread_cpu); ts->in_sigsuspend =3D 1; } } diff --git a/bsd-user/signal.c b/bsd-user/signal.c index f4352e4530f..e9f80a06d32 100644 --- a/bsd-user/signal.c +++ b/bsd-user/signal.c @@ -319,7 +319,7 @@ void host_to_target_siginfo(target_siginfo_t *tinfo, co= nst siginfo_t *info) =20 int block_signals(void) { - TaskState *ts =3D (TaskState *)thread_cpu->opaque; + TaskState *ts =3D get_task_state(thread_cpu); sigset_t set; =20 /* @@ -359,7 +359,7 @@ void dump_core_and_abort(int target_sig) { CPUState *cpu =3D thread_cpu; CPUArchState *env =3D cpu_env(cpu); - TaskState *ts =3D cpu->opaque; + TaskState *ts =3D get_task_state(cpu); int core_dumped =3D 0; int host_sig; struct sigaction act; @@ -421,7 +421,7 @@ void queue_signal(CPUArchState *env, int sig, int si_ty= pe, target_siginfo_t *info) { CPUState *cpu =3D env_cpu(env); - TaskState *ts =3D cpu->opaque; + TaskState *ts =3D get_task_state(cpu); =20 trace_user_queue_signal(env, sig); =20 @@ -476,7 +476,7 @@ void force_sig_fault(int sig, int code, abi_ulong addr) static void host_signal_handler(int host_sig, siginfo_t *info, void *puc) { CPUState *cpu =3D thread_cpu; - TaskState *ts =3D cpu->opaque; + TaskState *ts =3D get_task_state(cpu); target_siginfo_t tinfo; ucontext_t *uc =3D puc; struct emulated_sigtable *k; @@ -585,7 +585,7 @@ static void host_signal_handler(int host_sig, siginfo_t= *info, void *puc) /* compare to kern/kern_sig.c sys_sigaltstack() and kern_sigaltstack() */ abi_long do_sigaltstack(abi_ulong uss_addr, abi_ulong uoss_addr, abi_ulong= sp) { - TaskState *ts =3D (TaskState *)thread_cpu->opaque; + TaskState *ts =3D get_task_state(thread_cpu); int ret; target_stack_t oss; =20 @@ -714,7 +714,7 @@ int do_sigaction(int sig, const struct target_sigaction= *act, static inline abi_ulong get_sigframe(struct target_sigaction *ka, CPUArchState *env, size_t frame_size) { - TaskState *ts =3D (TaskState *)thread_cpu->opaque; + TaskState *ts =3D get_task_state(thread_cpu); abi_ulong sp; =20 /* Use default user stack */ @@ -789,7 +789,7 @@ static int reset_signal_mask(target_ucontext_t *ucontex= t) int i; sigset_t blocked; target_sigset_t target_set; - TaskState *ts =3D (TaskState *)thread_cpu->opaque; + TaskState *ts =3D get_task_state(thread_cpu); =20 for (i =3D 0; i < TARGET_NSIG_WORDS; i++) { __get_user(target_set.__bits[i], &ucontext->uc_sigmask.__bits[i]); @@ -839,7 +839,7 @@ badframe: =20 void signal_init(void) { - TaskState *ts =3D (TaskState *)thread_cpu->opaque; + TaskState *ts =3D get_task_state(thread_cpu); struct sigaction act; struct sigaction oact; int i; @@ -878,7 +878,7 @@ static void handle_pending_signal(CPUArchState *env, in= t sig, struct emulated_sigtable *k) { CPUState *cpu =3D env_cpu(env); - TaskState *ts =3D cpu->opaque; + TaskState *ts =3D get_task_state(cpu); struct target_sigaction *sa; int code; sigset_t set; @@ -967,7 +967,7 @@ void process_pending_signals(CPUArchState *env) int sig; sigset_t *blocked_set, set; struct emulated_sigtable *k; - TaskState *ts =3D cpu->opaque; + TaskState *ts =3D get_task_state(cpu); =20 while (qatomic_read(&ts->signal_pending)) { sigfillset(&set); diff --git a/gdbstub/user-target.c b/gdbstub/user-target.c index b7d4c37cd81..6646684a4c6 100644 --- a/gdbstub/user-target.c +++ b/gdbstub/user-target.c @@ -204,7 +204,7 @@ int gdb_target_signal_to_gdb(int sig) =20 int gdb_get_cpu_index(CPUState *cpu) { - TaskState *ts =3D (TaskState *) cpu->opaque; + TaskState *ts =3D get_task_state(cpu); return ts ? ts->ts_tid : -1; } =20 @@ -399,7 +399,7 @@ void gdb_handle_query_xfer_exec_file(GArray *params, vo= id *user_ctx) return; } =20 - TaskState *ts =3D cpu->opaque; + TaskState *ts =3D get_task_state(cpu); if (!ts || !ts->bprm || !ts->bprm->filename) { gdb_put_packet("E00"); return; diff --git a/linux-user/aarch64/cpu_loop.c b/linux-user/aarch64/cpu_loop.c index 8c20dc8a39a..71cdc8be50c 100644 --- a/linux-user/aarch64/cpu_loop.c +++ b/linux-user/aarch64/cpu_loop.c @@ -189,7 +189,7 @@ void target_cpu_copy_regs(CPUArchState *env, struct tar= get_pt_regs *regs) { ARMCPU *cpu =3D env_archcpu(env); CPUState *cs =3D env_cpu(env); - TaskState *ts =3D cs->opaque; + TaskState *ts =3D get_task_state(cs); struct image_info *info =3D ts->info; int i; =20 diff --git a/linux-user/arm/cpu_loop.c b/linux-user/arm/cpu_loop.c index b404117ff30..db1a41e27f4 100644 --- a/linux-user/arm/cpu_loop.c +++ b/linux-user/arm/cpu_loop.c @@ -263,7 +263,7 @@ static bool insn_is_linux_bkpt(uint32_t opcode, bool is= _thumb) =20 static bool emulate_arm_fpa11(CPUARMState *env, uint32_t opcode) { - TaskState *ts =3D env_cpu(env)->opaque; + TaskState *ts =3D get_task_state(env_cpu(env)); int rc =3D EmulateAll(opcode, &ts->fpa, env); int raise, enabled; =20 @@ -514,7 +514,7 @@ void cpu_loop(CPUARMState *env) void target_cpu_copy_regs(CPUArchState *env, struct target_pt_regs *regs) { CPUState *cpu =3D env_cpu(env); - TaskState *ts =3D cpu->opaque; + TaskState *ts =3D get_task_state(cpu); struct image_info *info =3D ts->info; int i; =20 diff --git a/linux-user/arm/signal.c b/linux-user/arm/signal.c index f77f692c63f..59806335f5b 100644 --- a/linux-user/arm/signal.c +++ b/linux-user/arm/signal.c @@ -177,7 +177,7 @@ setup_return(CPUARMState *env, struct target_sigaction = *ka, int usig, abi_ulong handler =3D 0; abi_ulong handler_fdpic_GOT =3D 0; abi_ulong retcode; - bool is_fdpic =3D info_is_fdpic(((TaskState *)thread_cpu->opaque)->inf= o); + bool is_fdpic =3D info_is_fdpic(get_task_state(thread_cpu)->info); bool is_rt =3D ka->sa_flags & TARGET_SA_SIGINFO; bool thumb; =20 diff --git a/linux-user/cris/cpu_loop.c b/linux-user/cris/cpu_loop.c index 01e6ff16fc9..04c9086b6dc 100644 --- a/linux-user/cris/cpu_loop.c +++ b/linux-user/cris/cpu_loop.c @@ -72,7 +72,7 @@ void cpu_loop(CPUCRISState *env) void target_cpu_copy_regs(CPUArchState *env, struct target_pt_regs *regs) { CPUState *cpu =3D env_cpu(env); - TaskState *ts =3D cpu->opaque; + TaskState *ts =3D get_task_state(cpu); struct image_info *info =3D ts->info; =20 env->regs[0] =3D regs->r0; diff --git a/linux-user/elfload.c b/linux-user/elfload.c index 0c299a7c15e..4dbca056461 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -4404,7 +4404,7 @@ static int wmr_write_region(void *opaque, target_ulon= g start, static int elf_core_dump(int signr, const CPUArchState *env) { const CPUState *cpu =3D env_cpu((CPUArchState *)env); - const TaskState *ts =3D (const TaskState *)cpu->opaque; + const TaskState *ts =3D (const TaskState *)get_task_state((CPUState *)= cpu); struct rlimit dumpsize; CountAndSizeRegions css; off_t offset, note_offset, data_offset; diff --git a/linux-user/hppa/signal.c b/linux-user/hppa/signal.c index d08a97dae61..c84557e906a 100644 --- a/linux-user/hppa/signal.c +++ b/linux-user/hppa/signal.c @@ -112,7 +112,7 @@ void setup_rt_frame(int sig, struct target_sigaction *k= a, abi_ulong frame_addr, sp, haddr; struct target_rt_sigframe *frame; int i; - TaskState *ts =3D (TaskState *)thread_cpu->opaque; + TaskState *ts =3D get_task_state(thread_cpu); =20 sp =3D get_sp_from_cpustate(env); if ((ka->sa_flags & TARGET_SA_ONSTACK) && !sas_ss_flags(sp)) { diff --git a/linux-user/linuxload.c b/linux-user/linuxload.c index 4a794f8cea1..37f132be4af 100644 --- a/linux-user/linuxload.c +++ b/linux-user/linuxload.c @@ -89,7 +89,7 @@ static int prepare_binprm(struct linux_binprm *bprm) abi_ulong loader_build_argptr(int envc, int argc, abi_ulong sp, abi_ulong stringp, int push_ptr) { - TaskState *ts =3D (TaskState *)thread_cpu->opaque; + TaskState *ts =3D get_task_state(thread_cpu); int n =3D sizeof(abi_ulong); abi_ulong envp; abi_ulong argv; diff --git a/linux-user/m68k/cpu_loop.c b/linux-user/m68k/cpu_loop.c index caead1cb741..f79b8e4ab05 100644 --- a/linux-user/m68k/cpu_loop.c +++ b/linux-user/m68k/cpu_loop.c @@ -95,7 +95,7 @@ void cpu_loop(CPUM68KState *env) void target_cpu_copy_regs(CPUArchState *env, struct target_pt_regs *regs) { CPUState *cpu =3D env_cpu(env); - TaskState *ts =3D cpu->opaque; + TaskState *ts =3D get_task_state(cpu); struct image_info *info =3D ts->info; =20 env->pc =3D regs->pc; diff --git a/linux-user/mips/cpu_loop.c b/linux-user/mips/cpu_loop.c index 990b03e727b..462387a0737 100644 --- a/linux-user/mips/cpu_loop.c +++ b/linux-user/mips/cpu_loop.c @@ -214,7 +214,7 @@ done_syscall: void target_cpu_copy_regs(CPUArchState *env, struct target_pt_regs *regs) { CPUState *cpu =3D env_cpu(env); - TaskState *ts =3D cpu->opaque; + TaskState *ts =3D get_task_state(cpu); struct image_info *info =3D ts->info; int i; =20 diff --git a/linux-user/ppc/signal.c b/linux-user/ppc/signal.c index 7e7302823b0..c232424c1e8 100644 --- a/linux-user/ppc/signal.c +++ b/linux-user/ppc/signal.c @@ -486,7 +486,7 @@ void setup_rt_frame(int sig, struct target_sigaction *k= a, int i, err =3D 0; #if defined(TARGET_PPC64) struct target_sigcontext *sc =3D 0; - struct image_info *image =3D ((TaskState *)thread_cpu->opaque)->info; + struct image_info *image =3D get_task_state(thread_cpu)->info; #endif =20 rt_sf_addr =3D get_sigframe(ka, env, sizeof(*rt_sf)); @@ -673,7 +673,7 @@ abi_long do_swapcontext(CPUArchState *env, abi_ulong uo= ld_ctx, } =20 if (uold_ctx) { - TaskState *ts =3D (TaskState *)thread_cpu->opaque; + TaskState *ts =3D get_task_state(thread_cpu); =20 if (!lock_user_struct(VERIFY_WRITE, uctx, uold_ctx, 1)) { return -TARGET_EFAULT; diff --git a/linux-user/riscv/cpu_loop.c b/linux-user/riscv/cpu_loop.c index bffca7db127..52c49c2e426 100644 --- a/linux-user/riscv/cpu_loop.c +++ b/linux-user/riscv/cpu_loop.c @@ -97,7 +97,7 @@ void cpu_loop(CPURISCVState *env) void target_cpu_copy_regs(CPUArchState *env, struct target_pt_regs *regs) { CPUState *cpu =3D env_cpu(env); - TaskState *ts =3D cpu->opaque; + TaskState *ts =3D get_task_state(cpu); struct image_info *info =3D ts->info; =20 env->pc =3D regs->sepc; diff --git a/linux-user/signal.c b/linux-user/signal.c index d3e62ab030f..cc7dd78e41f 100644 --- a/linux-user/signal.c +++ b/linux-user/signal.c @@ -172,7 +172,7 @@ void target_to_host_old_sigset(sigset_t *sigset, =20 int block_signals(void) { - TaskState *ts =3D (TaskState *)thread_cpu->opaque; + TaskState *ts =3D get_task_state(thread_cpu); sigset_t set; =20 /* It's OK to block everything including SIGSEGV, because we won't @@ -194,7 +194,7 @@ int block_signals(void) */ int do_sigprocmask(int how, const sigset_t *set, sigset_t *oldset) { - TaskState *ts =3D (TaskState *)thread_cpu->opaque; + TaskState *ts =3D get_task_state(thread_cpu); =20 if (oldset) { *oldset =3D ts->signal_mask; @@ -237,7 +237,7 @@ int do_sigprocmask(int how, const sigset_t *set, sigset= _t *oldset) */ void set_sigmask(const sigset_t *set) { - TaskState *ts =3D (TaskState *)thread_cpu->opaque; + TaskState *ts =3D get_task_state(thread_cpu); =20 ts->signal_mask =3D *set; } @@ -246,7 +246,7 @@ void set_sigmask(const sigset_t *set) =20 int on_sig_stack(unsigned long sp) { - TaskState *ts =3D (TaskState *)thread_cpu->opaque; + TaskState *ts =3D get_task_state(thread_cpu); =20 return (sp - ts->sigaltstack_used.ss_sp < ts->sigaltstack_used.ss_size); @@ -254,7 +254,7 @@ int on_sig_stack(unsigned long sp) =20 int sas_ss_flags(unsigned long sp) { - TaskState *ts =3D (TaskState *)thread_cpu->opaque; + TaskState *ts =3D get_task_state(thread_cpu); =20 return (ts->sigaltstack_used.ss_size =3D=3D 0 ? SS_DISABLE : on_sig_stack(sp) ? SS_ONSTACK : 0); @@ -265,7 +265,7 @@ abi_ulong target_sigsp(abi_ulong sp, struct target_siga= ction *ka) /* * This is the X/Open sanctioned signal stack switching. */ - TaskState *ts =3D (TaskState *)thread_cpu->opaque; + TaskState *ts =3D get_task_state(thread_cpu); =20 if ((ka->sa_flags & TARGET_SA_ONSTACK) && !sas_ss_flags(sp)) { return ts->sigaltstack_used.ss_sp + ts->sigaltstack_used.ss_size; @@ -275,7 +275,7 @@ abi_ulong target_sigsp(abi_ulong sp, struct target_siga= ction *ka) =20 void target_save_altstack(target_stack_t *uss, CPUArchState *env) { - TaskState *ts =3D (TaskState *)thread_cpu->opaque; + TaskState *ts =3D get_task_state(thread_cpu); =20 __put_user(ts->sigaltstack_used.ss_sp, &uss->ss_sp); __put_user(sas_ss_flags(get_sp_from_cpustate(env)), &uss->ss_flags); @@ -284,7 +284,7 @@ void target_save_altstack(target_stack_t *uss, CPUArchS= tate *env) =20 abi_long target_restore_altstack(target_stack_t *uss, CPUArchState *env) { - TaskState *ts =3D (TaskState *)thread_cpu->opaque; + TaskState *ts =3D get_task_state(thread_cpu); size_t minstacksize =3D TARGET_MINSIGSTKSZ; target_stack_t ss; =20 @@ -571,7 +571,7 @@ static void signal_table_init(void) =20 void signal_init(void) { - TaskState *ts =3D (TaskState *)thread_cpu->opaque; + TaskState *ts =3D get_task_state(thread_cpu); struct sigaction act, oact; =20 /* initialize signal conversion tables */ @@ -730,7 +730,7 @@ static G_NORETURN void dump_core_and_abort(CPUArchState *env, int target_sig) { CPUState *cpu =3D env_cpu(env); - TaskState *ts =3D (TaskState *)cpu->opaque; + TaskState *ts =3D get_task_state(cpu); int host_sig, core_dumped =3D 0; =20 /* On exit, undo the remapping of SIGABRT. */ @@ -769,7 +769,7 @@ void queue_signal(CPUArchState *env, int sig, int si_ty= pe, target_siginfo_t *info) { CPUState *cpu =3D env_cpu(env); - TaskState *ts =3D cpu->opaque; + TaskState *ts =3D get_task_state(cpu); =20 trace_user_queue_signal(env, sig); =20 @@ -954,7 +954,7 @@ static void host_signal_handler(int host_sig, siginfo_t= *info, void *puc) { CPUState *cpu =3D thread_cpu; CPUArchState *env =3D cpu_env(cpu); - TaskState *ts =3D cpu->opaque; + TaskState *ts =3D get_task_state(cpu); target_siginfo_t tinfo; host_sigcontext *uc =3D puc; struct emulated_sigtable *k; @@ -1174,7 +1174,7 @@ static void handle_pending_signal(CPUArchState *cpu_e= nv, int sig, sigset_t set; target_sigset_t target_old_set; struct target_sigaction *sa; - TaskState *ts =3D cpu->opaque; + TaskState *ts =3D get_task_state(cpu); =20 trace_user_handle_signal(cpu_env, sig); /* dequeue signal */ @@ -1256,7 +1256,7 @@ void process_pending_signals(CPUArchState *cpu_env) { CPUState *cpu =3D env_cpu(cpu_env); int sig; - TaskState *ts =3D cpu->opaque; + TaskState *ts =3D get_task_state(cpu); sigset_t set; sigset_t *blocked_set; =20 @@ -1316,7 +1316,7 @@ void process_pending_signals(CPUArchState *cpu_env) int process_sigsuspend_mask(sigset_t **pset, target_ulong sigset, target_ulong sigsize) { - TaskState *ts =3D (TaskState *)thread_cpu->opaque; + TaskState *ts =3D get_task_state(thread_cpu); sigset_t *host_set =3D &ts->sigsuspend_mask; target_sigset_t *target_sigset; =20 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index bc8c06522f8..c233d4eb30a 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -6515,7 +6515,7 @@ static void *clone_func(void *arg) env =3D info->env; cpu =3D env_cpu(env); thread_cpu =3D cpu; - ts =3D (TaskState *)cpu->opaque; + ts =3D get_task_state(cpu); info->tid =3D sys_gettid(); task_settid(ts); if (info->child_tidptr) @@ -6557,7 +6557,7 @@ static int do_fork(CPUArchState *env, unsigned int fl= ags, abi_ulong newsp, flags &=3D ~(CLONE_VFORK | CLONE_VM); =20 if (flags & CLONE_VM) { - TaskState *parent_ts =3D (TaskState *)cpu->opaque; + TaskState *parent_ts =3D get_task_state(cpu); new_thread_info info; pthread_attr_t attr; =20 @@ -6680,7 +6680,7 @@ static int do_fork(CPUArchState *env, unsigned int fl= ags, abi_ulong newsp, put_user_u32(sys_gettid(), child_tidptr); if (flags & CLONE_PARENT_SETTID) put_user_u32(sys_gettid(), parent_tidptr); - ts =3D (TaskState *)cpu->opaque; + ts =3D get_task_state(cpu); if (flags & CLONE_SETTLS) cpu_set_tls (env, newtls); if (flags & CLONE_CHILD_CLEARTID) @@ -7946,7 +7946,7 @@ int host_to_target_waitstatus(int status) static int open_self_cmdline(CPUArchState *cpu_env, int fd) { CPUState *cpu =3D env_cpu(cpu_env); - struct linux_binprm *bprm =3D ((TaskState *)cpu->opaque)->bprm; + struct linux_binprm *bprm =3D get_task_state(cpu)->bprm; int i; =20 for (i =3D 0; i < bprm->argc; i++) { @@ -8146,7 +8146,7 @@ static int open_self_smaps(CPUArchState *cpu_env, int= fd) static int open_self_stat(CPUArchState *cpu_env, int fd) { CPUState *cpu =3D env_cpu(cpu_env); - TaskState *ts =3D cpu->opaque; + TaskState *ts =3D get_task_state(cpu); g_autoptr(GString) buf =3D g_string_new(NULL); int i; =20 @@ -8187,7 +8187,7 @@ static int open_self_stat(CPUArchState *cpu_env, int = fd) static int open_self_auxv(CPUArchState *cpu_env, int fd) { CPUState *cpu =3D env_cpu(cpu_env); - TaskState *ts =3D cpu->opaque; + TaskState *ts =3D get_task_state(cpu); abi_ulong auxv =3D ts->info->saved_auxv; abi_ulong len =3D ts->info->auxv_len; char *ptr; @@ -9012,7 +9012,7 @@ static abi_long do_syscall1(CPUArchState *cpu_env, in= t num, abi_long arg1, pthread_mutex_lock(&clone_lock); =20 if (CPU_NEXT(first_cpu)) { - TaskState *ts =3D cpu->opaque; + TaskState *ts =3D get_task_state(cpu); =20 if (ts->child_tidptr) { put_user_u32(0, ts->child_tidptr); @@ -9439,7 +9439,7 @@ static abi_long do_syscall1(CPUArchState *cpu_env, in= t num, abi_long arg1, #ifdef TARGET_NR_pause /* not on alpha */ case TARGET_NR_pause: if (!block_signals()) { - sigsuspend(&((TaskState *)cpu->opaque)->signal_mask); + sigsuspend(&get_task_state(cpu)->signal_mask); } return -TARGET_EINTR; #endif @@ -10005,7 +10005,7 @@ static abi_long do_syscall1(CPUArchState *cpu_env, = int num, abi_long arg1, sigset_t *set; =20 #if defined(TARGET_ALPHA) - TaskState *ts =3D cpu->opaque; + TaskState *ts =3D get_task_state(cpu); /* target_to_host_old_sigset will bswap back */ abi_ulong mask =3D tswapal(arg1); set =3D &ts->sigsuspend_mask; @@ -10406,7 +10406,7 @@ static abi_long do_syscall1(CPUArchState *cpu_env, = int num, abi_long arg1, case TARGET_NR_mprotect: arg1 =3D cpu_untagged_addr(cpu, arg1); { - TaskState *ts =3D cpu->opaque; + TaskState *ts =3D get_task_state(cpu); /* Special hack to detect libc making the stack executable. */ if ((arg3 & PROT_GROWSDOWN) && arg1 >=3D ts->info->stack_limit @@ -12537,7 +12537,7 @@ static abi_long do_syscall1(CPUArchState *cpu_env, = int num, abi_long arg1, return do_set_thread_area(cpu_env, arg1); #elif defined(TARGET_M68K) { - TaskState *ts =3D cpu->opaque; + TaskState *ts =3D get_task_state(cpu); ts->tp_value =3D arg1; return 0; } @@ -12551,7 +12551,7 @@ static abi_long do_syscall1(CPUArchState *cpu_env, = int num, abi_long arg1, return do_get_thread_area(cpu_env, arg1); #elif defined(TARGET_M68K) { - TaskState *ts =3D cpu->opaque; + TaskState *ts =3D get_task_state(cpu); return ts->tp_value; } #else @@ -12676,7 +12676,7 @@ static abi_long do_syscall1(CPUArchState *cpu_env, = int num, abi_long arg1, #if defined(TARGET_NR_set_tid_address) case TARGET_NR_set_tid_address: { - TaskState *ts =3D cpu->opaque; + TaskState *ts =3D get_task_state(cpu); ts->child_tidptr =3D arg1; /* do not call host set_tid_address() syscall, instead return tid(= ) */ return get_errno(sys_gettid()); diff --git a/linux-user/vm86.c b/linux-user/vm86.c index c2facf3fc2d..9f512a2242b 100644 --- a/linux-user/vm86.c +++ b/linux-user/vm86.c @@ -74,7 +74,7 @@ static inline unsigned int vm_getl(CPUX86State *env, void save_v86_state(CPUX86State *env) { CPUState *cs =3D env_cpu(env); - TaskState *ts =3D cs->opaque; + TaskState *ts =3D get_task_state(cs); struct target_vm86plus_struct * target_v86; =20 if (!lock_user_struct(VERIFY_WRITE, target_v86, ts->target_v86, 0)) @@ -134,7 +134,7 @@ static inline void return_to_32bit(CPUX86State *env, in= t retval) static inline int set_IF(CPUX86State *env) { CPUState *cs =3D env_cpu(env); - TaskState *ts =3D cs->opaque; + TaskState *ts =3D get_task_state(cs); =20 ts->v86flags |=3D VIF_MASK; if (ts->v86flags & VIP_MASK) { @@ -147,7 +147,7 @@ static inline int set_IF(CPUX86State *env) static inline void clear_IF(CPUX86State *env) { CPUState *cs =3D env_cpu(env); - TaskState *ts =3D cs->opaque; + TaskState *ts =3D get_task_state(cs); =20 ts->v86flags &=3D ~VIF_MASK; } @@ -165,7 +165,7 @@ static inline void clear_AC(CPUX86State *env) static inline int set_vflags_long(unsigned long eflags, CPUX86State *env) { CPUState *cs =3D env_cpu(env); - TaskState *ts =3D cs->opaque; + TaskState *ts =3D get_task_state(cs); =20 set_flags(ts->v86flags, eflags, ts->v86mask); set_flags(env->eflags, eflags, SAFE_MASK); @@ -179,7 +179,7 @@ static inline int set_vflags_long(unsigned long eflags,= CPUX86State *env) static inline int set_vflags_short(unsigned short flags, CPUX86State *env) { CPUState *cs =3D env_cpu(env); - TaskState *ts =3D cs->opaque; + TaskState *ts =3D get_task_state(cs); =20 set_flags(ts->v86flags, flags, ts->v86mask & 0xffff); set_flags(env->eflags, flags, SAFE_MASK); @@ -193,7 +193,7 @@ static inline int set_vflags_short(unsigned short flags= , CPUX86State *env) static inline unsigned int get_vflags(CPUX86State *env) { CPUState *cs =3D env_cpu(env); - TaskState *ts =3D cs->opaque; + TaskState *ts =3D get_task_state(cs); unsigned int flags; =20 flags =3D env->eflags & RETURN_MASK; @@ -210,7 +210,7 @@ static inline unsigned int get_vflags(CPUX86State *env) static void do_int(CPUX86State *env, int intno) { CPUState *cs =3D env_cpu(env); - TaskState *ts =3D cs->opaque; + TaskState *ts =3D get_task_state(cs); uint32_t int_addr, segoffs, ssp; unsigned int sp; =20 @@ -269,7 +269,7 @@ void handle_vm86_trap(CPUX86State *env, int trapno) void handle_vm86_fault(CPUX86State *env) { CPUState *cs =3D env_cpu(env); - TaskState *ts =3D cs->opaque; + TaskState *ts =3D get_task_state(cs); uint32_t csp, ssp; unsigned int ip, sp, newflags, newip, newcs, opcode, intno; int data32, pref_done; @@ -394,7 +394,7 @@ void handle_vm86_fault(CPUX86State *env) int do_vm86(CPUX86State *env, long subfunction, abi_ulong vm86_addr) { CPUState *cs =3D env_cpu(env); - TaskState *ts =3D cs->opaque; + TaskState *ts =3D get_task_state(cs); struct target_vm86plus_struct * target_v86; int ret; =20 diff --git a/linux-user/xtensa/signal.c b/linux-user/xtensa/signal.c index 32dcfa52291..003208a9161 100644 --- a/linux-user/xtensa/signal.c +++ b/linux-user/xtensa/signal.c @@ -157,7 +157,7 @@ void setup_rt_frame(int sig, struct target_sigaction *k= a, { abi_ulong frame_addr; struct target_rt_sigframe *frame; - int is_fdpic =3D info_is_fdpic(((TaskState *)thread_cpu->opaque)->info= ); + int is_fdpic =3D info_is_fdpic(get_task_state(thread_cpu)->info); abi_ulong handler =3D 0; abi_ulong handler_fdpic_GOT =3D 0; uint32_t ra; diff --git a/plugins/api.c b/plugins/api.c index 81f43c9ce8a..e905e995bd6 100644 --- a/plugins/api.c +++ b/plugins/api.c @@ -378,7 +378,7 @@ const char *qemu_plugin_path_to_binary(void) { char *path =3D NULL; #ifdef CONFIG_USER_ONLY - TaskState *ts =3D (TaskState *) current_cpu->opaque; + TaskState *ts =3D get_task_state(current_cpu); path =3D g_strdup(ts->bprm->filename); #endif return path; @@ -388,7 +388,7 @@ uint64_t qemu_plugin_start_code(void) { uint64_t start =3D 0; #ifdef CONFIG_USER_ONLY - TaskState *ts =3D (TaskState *) current_cpu->opaque; + TaskState *ts =3D get_task_state(current_cpu); start =3D ts->info->start_code; #endif return start; @@ -398,7 +398,7 @@ uint64_t qemu_plugin_end_code(void) { uint64_t end =3D 0; #ifdef CONFIG_USER_ONLY - TaskState *ts =3D (TaskState *) current_cpu->opaque; + TaskState *ts =3D get_task_state(current_cpu); end =3D ts->info->end_code; #endif return end; @@ -408,7 +408,7 @@ uint64_t qemu_plugin_entry_code(void) { uint64_t entry =3D 0; #ifdef CONFIG_USER_ONLY - TaskState *ts =3D (TaskState *) current_cpu->opaque; + TaskState *ts =3D get_task_state(current_cpu); entry =3D ts->info->entry; #endif return entry; diff --git a/semihosting/arm-compat-semi.c b/semihosting/arm-compat-semi.c index 329ea112607..d78c6428b90 100644 --- a/semihosting/arm-compat-semi.c +++ b/semihosting/arm-compat-semi.c @@ -214,7 +214,7 @@ static target_ulong syscall_err; static inline uint32_t get_swi_errno(CPUState *cs) { #ifdef CONFIG_USER_ONLY - TaskState *ts =3D cs->opaque; + TaskState *ts =3D get_task_state(cs); =20 return ts->swi_errno; #else @@ -226,7 +226,7 @@ static void common_semi_cb(CPUState *cs, uint64_t ret, = int err) { if (err) { #ifdef CONFIG_USER_ONLY - TaskState *ts =3D cs->opaque; + TaskState *ts =3D get_task_state(cs); ts->swi_errno =3D err; #else syscall_err =3D err; @@ -586,7 +586,7 @@ void do_common_semihosting(CPUState *cs) #if !defined(CONFIG_USER_ONLY) const char *cmdline; #else - TaskState *ts =3D cs->opaque; + TaskState *ts =3D get_task_state(cs); #endif GET_ARG(0); GET_ARG(1); @@ -664,7 +664,7 @@ void do_common_semihosting(CPUState *cs) target_ulong retvals[4]; int i; #ifdef CONFIG_USER_ONLY - TaskState *ts =3D cs->opaque; + TaskState *ts =3D get_task_state(cs); target_ulong limit; #else LayoutInfo info =3D common_semi_find_bases(cs); --=20 2.39.2 From nobody Tue Nov 26 06:56:45 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1709736229; cv=none; d=zohomail.com; s=zohoarc; b=kvyit7X+wVp3XPOx95dOJ/BtiiX1Vw/PJ9ws3g9ynTb7haQixVptyvNrNihr9a/FJDmtRSJtj0SuAPFUPZqOzDhnebWJipgQad89iYpjNtlnUZpCET0WSkTqbCOMTUeJDwX9sDDsaKESK8vacxzoSVGKTtokVMz6E2+U9f47Lb8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709736229; 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=gtRa7kRDjdE8sreaiOincZXchoFU4nQ40xW4Eh4gbzA=; b=LFt81oOnhKHyYW6kJ7VTu14+rzkZw54RNgigkHH50epx20Lb7GdR4yWG3NfrxO+OPF++QbA2hXQZgkNI6IQLSAaGHGBTlrIgvh9EMGXbFABTim/87S/KZaYbRKuZv4vtQbLki+TFEkh5LMTBYW01O79TSY5+Qov3qS1Xti6oSOk= 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 1709736229694504.14749829684615; Wed, 6 Mar 2024 06:43:49 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rhsS4-0007QN-Rv; Wed, 06 Mar 2024 09:41:00 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rhsS1-00076r-6r for qemu-devel@nongnu.org; Wed, 06 Mar 2024 09:40:57 -0500 Received: from mail-wr1-x42b.google.com ([2a00:1450:4864:20::42b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rhsRx-0001TY-9D for qemu-devel@nongnu.org; Wed, 06 Mar 2024 09:40:55 -0500 Received: by mail-wr1-x42b.google.com with SMTP id ffacd0b85a97d-33e17fc5aceso563758f8f.0 for ; Wed, 06 Mar 2024 06:40:46 -0800 (PST) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id u4-20020a056000038400b0033e456f6e7csm6195304wrf.1.2024.03.06.06.40.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Mar 2024 06:40:42 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 08F0E5F954; Wed, 6 Mar 2024 14:40:42 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1709736045; x=1710340845; 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=gtRa7kRDjdE8sreaiOincZXchoFU4nQ40xW4Eh4gbzA=; b=U4+fDTDUSvY0703hj3cU46/Yv4Nwr145UUQWIaC0AA1bGvE2m18GlB03G67q17y9EQ u3EHHJEkPXo6TikU1sab5svXlsIK9TkmrvwhD8/VWw1PSOxft+1cYWH2D4COktROp2qF yD4qRrv3BrwC6ya2KB0aTdQbDHCCpIW/9xS0NG2y11rdU/4OnDZ0y5r0vYX71PDPf2Ra QUO3DLbzwRxPKlJfFdpkasYCcRVKIkbt/e6ltsN36+xbEy1piMSyc8e/0TcReYbHANmM 0cfTSixSADTo/Mr77a5Bot6gKs6IuLaa+uyWVYEtshEbJk7T1Ybz5E+rcR8igxLCQ8hX PFgA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709736045; x=1710340845; 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=gtRa7kRDjdE8sreaiOincZXchoFU4nQ40xW4Eh4gbzA=; b=FEYJNF2C8yZu/2XW4k6AKXgw6A95pVUO4PpbXVW8kcKCnDa6Vf2c25ZGTaYCZ4NXft QKWi6Z2R8K9HgeNcZ4Aor3jPiXtElliQwxfhc3UPIr2gLVrUo1pWaJVuW7XsePGmYFPs w0BUwk0w1xJTAZBh2YKkMXXXiiDVUGLSWODdq/2RNtfDIOCWxetLJwZJdwdz019jy6Ca N0W6yRJLyG7YzcNa1YOpTBPU4H+GYJDhcOFzkt+sLQqu9Zn7YyWachWkno3O2y9kiI2F m2xDNMp6oBUCgZk4+5dlW+oj311Y8fbktlDsatCTYSOeF8FnMLEdV8pbAfBJ3DFLhWi+ gzAA== X-Gm-Message-State: AOJu0YxezjX4cqXDft3UAoOGo0asHL03NbPUvmW7oKvUNAJffvV9A9lc EDwRRKWG07wdFHYdXOjLCN1308XDY+W90slDgRoGsa8SjIT7NhmsmyTmL38KlBcUrBKu8WAhtX8 N X-Google-Smtp-Source: AGHT+IGSd9p4x/t2mW+GacMLuOYYe8vzFsp30MiWW3LfoWirOUwQiBhjZhJ5KTfVTuXSMpLwVFQnmg== X-Received: by 2002:adf:a3ce:0:b0:33e:2090:a439 with SMTP id m14-20020adfa3ce000000b0033e2090a439mr5161061wrb.10.1709736045137; Wed, 06 Mar 2024 06:40:45 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Ilya Leoshkevich , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Warner Losh , Richard Henderson , Kyle Evans , Laurent Vivier Subject: [PULL 04/29] {linux,bsd}-user: Update ts_tid after fork() Date: Wed, 6 Mar 2024 14:40:16 +0000 Message-Id: <20240306144041.3787188-5-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240306144041.3787188-1-alex.bennee@linaro.org> References: <20240306144041.3787188-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::42b; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x42b.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=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: 1709736230216100001 From: Ilya Leoshkevich Currently ts_tid contains the parent tid after fork(), which is not correct. So far it has not affected anything, but the upcoming follow-fork-mode child support relies on the correct value, so fix it. Reviewed-by: Alex Benn=C3=A9e Signed-off-by: Ilya Leoshkevich Reviewed-by: Warner Losh Message-Id: <20240219141628.246823-4-iii@linux.ibm.com> Reviewed-by: Richard Henderson Signed-off-by: Alex Benn=C3=A9e Message-Id: <20240305121005.3528075-5-alex.bennee@linaro.org> diff --git a/bsd-user/main.c b/bsd-user/main.c index 512d4ab69fc..e39eef3040f 100644 --- a/bsd-user/main.c +++ b/bsd-user/main.c @@ -134,6 +134,7 @@ void fork_end(int child) * state, so we don't need to end_exclusive() here. */ qemu_init_cpu_list(); + get_task_state(thread_cpu)->ts_tid =3D qemu_get_thread_id(); gdbserver_fork(thread_cpu); } else { mmap_fork_end(child); diff --git a/linux-user/main.c b/linux-user/main.c index 551acf16619..699da773714 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -161,6 +161,7 @@ void fork_end(int child) } } qemu_init_cpu_list(); + get_task_state(thread_cpu)->ts_tid =3D qemu_get_thread_id(); gdbserver_fork(thread_cpu); } else { cpu_list_unlock(); --=20 2.39.2 From nobody Tue Nov 26 06:56:45 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1709736062; cv=none; d=zohomail.com; s=zohoarc; b=dH5FB5SClqH+ENLT9nw7JScRmwEwL5HBTo9AVTArkCBJyDIxgLead6zRdnmHe0Ib1fpzRBlK8iDk7EhHoxH14Dl18T1sl6LGoSePIa1f5Rc7DcgO6SAkGqTrWxY9Z0MsTYdEsOSL3N/ENsE4sqRoyvHFMdMBxnYEfjKXAmfWAho= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709736062; 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=QMg0/P2uHBERFN7NdoTSBDJ9hxY6gx6OhA8rGKHoyIo=; b=MFl2x/lwOU3SObOQ+HB59u4vCEXom/gfgvQ1n/a35+cumS0xP3il2AGu11OGYScMeIKWpbDi5wW+eDlYCxIzpXIh53WlVk9ssXqMtDk7RgE8W9qjPbkCzVLyhI7qHbE18rK7+WRd6kulLU6fxOB2AbVQ20u1yiyQoNDJi3TF8/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 1709736062789570.9033499674617; Wed, 6 Mar 2024 06:41:02 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rhsS1-00079k-MY; Wed, 06 Mar 2024 09:40:57 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rhsRz-000718-0K for qemu-devel@nongnu.org; Wed, 06 Mar 2024 09:40:55 -0500 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rhsRx-0001Tc-7V for qemu-devel@nongnu.org; Wed, 06 Mar 2024 09:40:54 -0500 Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-412f0655d81so10619705e9.2 for ; Wed, 06 Mar 2024 06:40:46 -0800 (PST) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id j16-20020a05600c1c1000b00412d2dd4bb6sm14709099wms.42.2024.03.06.06.40.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Mar 2024 06:40:43 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 1F2355F956; Wed, 6 Mar 2024 14:40:42 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1709736045; x=1710340845; 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=QMg0/P2uHBERFN7NdoTSBDJ9hxY6gx6OhA8rGKHoyIo=; b=pbYOzzQhxj5t/Bsp4oUCC31YexBsdFaOwwxNQ/DI7o3SBxzKmg5iQOZ80lQzUfXU7g zjvafzvG8YynawWNWkmdvigvCiJtviGtwqn5fhFn4x8Kb8EuiTyyLVXgBwQWeqiXk4uA DKARvLxzzX7BptvQKxMS7TZ/uUngFUmdqB1kJAUB7ngJYy1mjJ/pwanJc0h8G6PEVRp2 IDzyUilfkpRTJftoscSYQ8PrWBIMB/Rkelnv04MGy851iwYtpmEdygXWqn6Wb7vnrpM0 +N7w2tqLYJyFWN9JJ+UyAR/0yXtKb5ROR/NRhE/XKGnRdT+7gX14QgScw4jLq34bf6Of 6aEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709736045; x=1710340845; 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=QMg0/P2uHBERFN7NdoTSBDJ9hxY6gx6OhA8rGKHoyIo=; b=GEp2ncxwWDeFgkIQrwqHBe8mIq2DPth3aAkEwbLFqa0OINSOEv8T6IciH0mtoxO03p ZOZUOXrcsAQhir1cPaDUM9UcXOLkaaHpVItNExo7OogY6/UM0lmuYliBiozu7Tz7JPiD K96gm94usyfWr9SpqOHWQU7Cmy7Q4dH+9pmHZ8QKf/Hh5oMpiEr1yeC8635f5jdbHvuy WYR+gvmUf+7POSDKnONuoN8Qe+aor6b2RZXN9anT/mUKBOd83A/VEu5XNax986+yQDJA +mZcBTuGea07nZ9XdUz2jGzRvjPhJXz9sR4YYS72A/g4m6i+2w3IPOwQv7E/z5hFtyFX GTJA== X-Gm-Message-State: AOJu0YyT96MBKfZrdTtruNI7uQnb4wFHtUec5Kk4FBY5DF76Wxk5P6L6 hQU3lTSn4qyqqZX+AnhpQv2FkmQs+LuTYKun2RCGeMwRAtIGQPNMJ/DNchbZ2TY= X-Google-Smtp-Source: AGHT+IFNcA719ohsRGcNOWS+K8o+GKrGFUzqDghvx6g8Ewm3Tl41VYh6oYDtPl17qOacUjaI0twZOQ== X-Received: by 2002:a05:600c:46ce:b0:412:ad6e:88cb with SMTP id q14-20020a05600c46ce00b00412ad6e88cbmr12472667wmo.36.1709736045501; Wed, 06 Mar 2024 06:40:45 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Ilya Leoshkevich , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Warner Losh , Kyle Evans , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Laurent Vivier Subject: [PULL 05/29] gdbstub: Introduce gdbserver_fork_start() Date: Wed, 6 Mar 2024 14:40:17 +0000 Message-Id: <20240306144041.3787188-6-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240306144041.3787188-1-alex.bennee@linaro.org> References: <20240306144041.3787188-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32e; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x32e.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1709736063625100003 From: Ilya Leoshkevich The upcoming follow-fork-mode child support requires knowing when fork() is about to happen in order to initialize its state. Add a hook for that. Reviewed-by: Alex Benn=C3=A9e Signed-off-by: Ilya Leoshkevich Message-Id: <20240219141628.246823-5-iii@linux.ibm.com> Signed-off-by: Alex Benn=C3=A9e Message-Id: <20240305121005.3528075-6-alex.bennee@linaro.org> diff --git a/include/gdbstub/user.h b/include/gdbstub/user.h index 68b6534130c..e33f8d9a9a6 100644 --- a/include/gdbstub/user.h +++ b/include/gdbstub/user.h @@ -45,6 +45,11 @@ static inline int gdb_handlesig(CPUState *cpu, int sig) */ void gdb_signalled(CPUArchState *as, int sig); =20 +/** + * gdbserver_fork_start() - inform gdb of the upcoming fork() + */ +void gdbserver_fork_start(void); + /** * gdbserver_fork() - disable gdb stub for child processes. * @cs: CPU diff --git a/bsd-user/main.c b/bsd-user/main.c index e39eef3040f..517c6b3ec2f 100644 --- a/bsd-user/main.c +++ b/bsd-user/main.c @@ -113,6 +113,7 @@ void fork_start(void) start_exclusive(); cpu_list_lock(); mmap_fork_start(); + gdbserver_fork_start(); } =20 void fork_end(int child) diff --git a/gdbstub/user.c b/gdbstub/user.c index 3ce20b7bbfc..536fb43b03e 100644 --- a/gdbstub/user.c +++ b/gdbstub/user.c @@ -356,6 +356,10 @@ int gdbserver_start(const char *port_or_path) return -1; } =20 +void gdbserver_fork_start(void) +{ +} + static void disable_gdbstub(CPUState *thread_cpu) { CPUState *cpu; diff --git a/linux-user/main.c b/linux-user/main.c index 699da773714..755c566d6d2 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -145,6 +145,7 @@ void fork_start(void) mmap_fork_start(); cpu_list_lock(); qemu_plugin_user_prefork_lock(); + gdbserver_fork_start(); } =20 void fork_end(int child) --=20 2.39.2 From nobody Tue Nov 26 06:56:45 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1709736241; cv=none; d=zohomail.com; s=zohoarc; b=nTGtgcZ0SH0QlcVKRsAgmHh6SR2akLyyrdcDEfQ48Xk3GCluUXTTebhd6GG/Tzap5WBYTiVkvvwaDoQpABHqV7cS295juw/zt6bDYFm31dYrcXRbJ1NCYKkl7Rr1EYZenMzbufVHmMXMNOVfOyXD2R+6MuPLmfbZ7kCWfUmVwKk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709736241; 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=Y0njWMdZJbPD5cZgXS+g7eH7Y9rT90hV9Vq0dFBAOsE=; b=IAdvCmAhWpbyquC/FKPMWwKX4V56GqdWqq5xcEBXdHfMNyIVnVNmWzX4saP1NiUt5PDc5UfiVtPlMeE3R3X97GW7jVcmf0pXI0w5qpN0G4+jBZYi5jatCEFpPn4LHf5RYSRVESWf5tYyEI9e7oT5V2vNWQZAgIxk7CkKajPaqg0= 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 1709736241446638.495465096848; Wed, 6 Mar 2024 06:44:01 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rhsS4-0007QO-Sx; Wed, 06 Mar 2024 09:41:00 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rhsS1-0007IK-Qq for qemu-devel@nongnu.org; Wed, 06 Mar 2024 09:40:57 -0500 Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rhsRx-0001TZ-9B for qemu-devel@nongnu.org; Wed, 06 Mar 2024 09:40:57 -0500 Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-412f5e905e2so5481805e9.3 for ; Wed, 06 Mar 2024 06:40:46 -0800 (PST) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id bq26-20020a5d5a1a000000b0033e2777f313sm12942842wrb.72.2024.03.06.06.40.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Mar 2024 06:40:43 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 373E25F958; Wed, 6 Mar 2024 14:40:42 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1709736045; x=1710340845; 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=Y0njWMdZJbPD5cZgXS+g7eH7Y9rT90hV9Vq0dFBAOsE=; b=FAOjv5bmqnLfHxjoJmra29Mo4KZa+DM5csDN0yPWUenYhLAFwALjZwITdgPpgaR8TP WMBAY1Wc+qq7lCr3BnehTypkAUBTpuWjw0vicD+SKKSS1Fov4XwG4kuZoov0kcwjFxzV JwsZkVXcz9pdNNW3/dXJGVF6yXkDLUtXrZi0LBFadr8BaaQyOaoqJx4Ns3DSpcBd+lsX uPZys1HsNu00FGFn+kdL364MSr4eRCmTjFXtoWSTVt3yGwE1PsU+mBEoV0j6Nr5omuqY d3cLrFreUbbF/xh+pLvgGAgQ2Z/0jRTjPanfnge2VjU2h27a23sYPq9a4GGoqdu108cB UcUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709736045; x=1710340845; 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=Y0njWMdZJbPD5cZgXS+g7eH7Y9rT90hV9Vq0dFBAOsE=; b=g6IhseXmBw935NskSp9TSrvLYb3XGe3Z6DbKiKUp4NclR/l7zZ4hBhX3R2wRaFO0B0 L+tsO8tFPbpD6TZurvhZsYPtwZvC+MfqJFntWO+PWHUV48IEgNweCKZO45IDnibZ+LG6 xc3kPgBP4N5UM8eBtgZdB06yzRT3ukC7dizk2KPurlP9GF/Cxk+anBtT/1Jg913bI0uE j+uSl0E6O60W+f5MR5w6ZsneYV0PABPgwrcYgiRFQ/sbM9Ov4TlqP1v47D2Eyy8aRGDH 4Ft932Xkm2Z+UtM8lS3yIax2x3XBHPBzo9zEfEfg2ErwEtOtTDd2sjPzeLGo3qbApXJG 2BHQ== X-Gm-Message-State: AOJu0YxSexefMc9FYc/YYID+CDTBfdUiLhAdwW4pOyZjHz7dM2mMXMT9 SkptTZDdGfU6X0dB3mqdBjNWZbzTjzoehjIr7umM+k4IZQQ1uB4BGFrZjpvG+ZU= X-Google-Smtp-Source: AGHT+IEPPa1Ecaqdsgx94fUWAtTx70U9UCQNfjgESyk/mob1TtsMjlSw+ffvvIri/MLIXUWTDqPRqA== X-Received: by 2002:a05:600c:a002:b0:412:e339:14d9 with SMTP id jg2-20020a05600ca00200b00412e33914d9mr6221735wmb.0.1709736045329; Wed, 06 Mar 2024 06:40:45 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Ilya Leoshkevich , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Richard Henderson , Warner Losh , Kyle Evans , Laurent Vivier Subject: [PULL 06/29] {linux,bsd}-user: Pass pid to fork_end() Date: Wed, 6 Mar 2024 14:40:18 +0000 Message-Id: <20240306144041.3787188-7-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240306144041.3787188-1-alex.bennee@linaro.org> References: <20240306144041.3787188-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::336; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x336.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=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: 1709736242323100001 From: Ilya Leoshkevich The upcoming follow-fork-mode child support requires knowing the child pid. Pass it down. Reviewed-by: Alex Benn=C3=A9e Reviewed-by: Richard Henderson Signed-off-by: Ilya Leoshkevich Message-Id: <20240219141628.246823-6-iii@linux.ibm.com> Signed-off-by: Alex Benn=C3=A9e Message-Id: <20240305121005.3528075-7-alex.bennee@linaro.org> diff --git a/bsd-user/freebsd/os-proc.h b/bsd-user/freebsd/os-proc.h index d6418780344..3003c8cb637 100644 --- a/bsd-user/freebsd/os-proc.h +++ b/bsd-user/freebsd/os-proc.h @@ -208,7 +208,7 @@ static inline abi_long do_freebsd_fork(void *cpu_env) */ set_second_rval(cpu_env, child_flag); =20 - fork_end(child_flag); + fork_end(ret); =20 return ret; } @@ -252,7 +252,7 @@ static inline abi_long do_freebsd_rfork(void *cpu_env, = abi_long flags) * value: 0 for parent process, 1 for child process. */ set_second_rval(cpu_env, child_flag); - fork_end(child_flag); + fork_end(ret); =20 return ret; =20 @@ -285,7 +285,7 @@ static inline abi_long do_freebsd_pdfork(void *cpu_env,= abi_ulong target_fdp, * value: 0 for parent process, 1 for child process. */ set_second_rval(cpu_env, child_flag); - fork_end(child_flag); + fork_end(ret); =20 return ret; } diff --git a/bsd-user/qemu.h b/bsd-user/qemu.h index 4adb75d19ff..1b0a591d2d2 100644 --- a/bsd-user/qemu.h +++ b/bsd-user/qemu.h @@ -192,7 +192,7 @@ void cpu_loop(CPUArchState *env); char *target_strerror(int err); int get_osversion(void); void fork_start(void); -void fork_end(int child); +void fork_end(pid_t pid); =20 #include "qemu/log.h" =20 diff --git a/linux-user/user-internals.h b/linux-user/user-internals.h index c63ef45fc78..ce11d9e21c1 100644 --- a/linux-user/user-internals.h +++ b/linux-user/user-internals.h @@ -71,7 +71,7 @@ const char *target_strerror(int err); int get_osversion(void); void init_qemu_uname_release(void); void fork_start(void); -void fork_end(int child); +void fork_end(pid_t pid); =20 /** * probe_guest_base: diff --git a/bsd-user/main.c b/bsd-user/main.c index 517c6b3ec2f..fca9b302043 100644 --- a/bsd-user/main.c +++ b/bsd-user/main.c @@ -116,8 +116,10 @@ void fork_start(void) gdbserver_fork_start(); } =20 -void fork_end(int child) +void fork_end(pid_t pid) { + bool child =3D pid =3D=3D 0; + if (child) { CPUState *cpu, *next_cpu; /* diff --git a/linux-user/main.c b/linux-user/main.c index 755c566d6d2..cab95f5b0aa 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -148,8 +148,10 @@ void fork_start(void) gdbserver_fork_start(); } =20 -void fork_end(int child) +void fork_end(pid_t pid) { + bool child =3D pid =3D=3D 0; + qemu_plugin_user_postfork(child); mmap_fork_end(child); if (child) { diff --git a/linux-user/syscall.c b/linux-user/syscall.c index c233d4eb30a..7f30defcb13 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -6669,7 +6669,7 @@ static int do_fork(CPUArchState *env, unsigned int fl= ags, abi_ulong newsp, if (ret =3D=3D 0) { /* Child Process. */ cpu_clone_regs_child(env, newsp, flags); - fork_end(1); + fork_end(ret); /* There is a race condition here. The parent process could theoretically read the TID in the child process before the = child tid is set. This would require using either ptrace @@ -6700,8 +6700,8 @@ static int do_fork(CPUArchState *env, unsigned int fl= ags, abi_ulong newsp, } #endif put_user_u32(pid_fd, parent_tidptr); - } - fork_end(0); + } + fork_end(ret); } g_assert(!cpu_in_exclusive_context(cpu)); } --=20 2.39.2 From nobody Tue Nov 26 06:56:45 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1709736260; cv=none; d=zohomail.com; s=zohoarc; b=Ux2Qiln1cwdmugl/An0dN58KFQGtU7mYw0DBR5XW3a7SdQVxwB73DatOAuURb4INvHJmD18kx0wq3DZkHcvM8J+3JiJ7/P0r/k0A1Tnawm3x4d8Aft2aL4t51YC86xZ09sHPwCzeFDFjZJHVOUpb8McRnAgFDCKRcAIw7el9u88= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709736260; 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=fupeVcwCDkBVKZ33Doy2sEKI/KbVAY0Qy8ZqQctJp/I=; b=dRbpKqtp+I/7CdrUew9pJ+YW7Ig5vkjLEHhj/lh2EU/dV2gGClWB8EgcR9GKYbTxClqOaUnv2Dv2s4PyabIPDGiG4b/pcQOxHL+4C8mu+gFp3mWxYQq7MAjJPKTLSxluOkr3cBv5SM1RoXX74mVwj4HcqM53sGMuPiRH+j1HPPE= 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 1709736260545968.2794619315691; Wed, 6 Mar 2024 06:44:20 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rhsS8-0007fk-6A; Wed, 06 Mar 2024 09:41:04 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rhsS6-0007VB-Hy for qemu-devel@nongnu.org; Wed, 06 Mar 2024 09:41:02 -0500 Received: from mail-wr1-x436.google.com ([2a00:1450:4864:20::436]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rhsRx-0001U2-9B for qemu-devel@nongnu.org; Wed, 06 Mar 2024 09:41:00 -0500 Received: by mail-wr1-x436.google.com with SMTP id ffacd0b85a97d-33da51fd636so3751129f8f.3 for ; Wed, 06 Mar 2024 06:40:51 -0800 (PST) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id bv16-20020a0560001f1000b0033e0523b829sm18239207wrb.13.2024.03.06.06.40.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Mar 2024 06:40:45 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 4DF0D5F95B; Wed, 6 Mar 2024 14:40:42 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1709736049; x=1710340849; 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=fupeVcwCDkBVKZ33Doy2sEKI/KbVAY0Qy8ZqQctJp/I=; b=GnJyQVAhsiRoBU59M1p680pB31XjYXajt4ziQ4cAi1kmwOolTJdZsTxv0+rhblMtxz grRCMEbqlEnO/EOcL4g1Askft4c/mjEI5PHIDteyZ42J3vTGnRr9NGk8IbiXbDQdDYrC DtXUmmaI5bpsbOq5C01bXWobNv4wmrlloQN/KbD8+wZZyaLsMUyZQCK9Jf/dPWLOkKxj yH4sGSOu9k1pcycMXrltoMzprIDaLr/EwEb30bj7ygAFvmyZb3adOIFKh1SEGoXsRVAJ 9MUaZGInNn/NIrEJpxRA8W+Rtu1ga4V+7h2tf8Oy/j6wxhw7XRuiVoEfcjgPSvdZ8EUA VBVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709736049; x=1710340849; 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=fupeVcwCDkBVKZ33Doy2sEKI/KbVAY0Qy8ZqQctJp/I=; b=pSzgQxnWV4JhoLtZsl27y+gPkLRtE6Qsf3/JjErj358LdLpq/TJkPgztv4NtK8QOjh oskGQub9IH0wKs2Q+ba4Q7+YLn5+IIJ6k0WyH71xe5GFzKU6YRLtwLocwLAxK4T/Ha7z BTBMr61LbgrUMcHWwxr7mp7exJBcvyljssUzO7jr/XdCrK3XI8/7W5RtpyIkxzv/OFvb ZLtJnupoe4aluR9I8DV6gCPRIKCFjVzURfM6Qs3Ph/8cQgM5NYjRqkfZ8eSc4AoFbGEO v7b4HaL17c6tif8XM2t/0eT0Y9TUZZxjCJq1jb8zOjSnVxKBc/YjsY+ejVN/pwS+As2S TSdg== X-Gm-Message-State: AOJu0Yy1UM68FfzU4X8UAihgQq/hOztmFnq5HbYzrrxV5HK4eBQpRcT1 bybqWdipCJH5HuV4W2ifuanoeiJOIMrCOuOOBvZaID6jEXqAgX2qT3jQhz60G1A= X-Google-Smtp-Source: AGHT+IF7PFiuN5R7mYMhzGksXx9+oFiv7PDyWO90+vgRlcEaIqnBUYXPB85loHtKZJIE/E3gE+pI9A== X-Received: by 2002:a5d:55c4:0:b0:33e:17fe:8c23 with SMTP id i4-20020a5d55c4000000b0033e17fe8c23mr10714673wrw.22.1709736049684; Wed, 06 Mar 2024 06:40:49 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Ilya Leoshkevich , Richard Henderson , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Warner Losh , Kyle Evans , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Laurent Vivier Subject: [PULL 07/29] {linux,bsd}-user: Pass pid to gdbserver_fork() Date: Wed, 6 Mar 2024 14:40:19 +0000 Message-Id: <20240306144041.3787188-8-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240306144041.3787188-1-alex.bennee@linaro.org> References: <20240306144041.3787188-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::436; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x436.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1709736262409100002 From: Ilya Leoshkevich The upcoming follow-fork-mode child support requires knowing the child pid. Pass it down. Reviewed-by: Richard Henderson Signed-off-by: Ilya Leoshkevich Message-Id: <20240219141628.246823-7-iii@linux.ibm.com> Signed-off-by: Alex Benn=C3=A9e Message-Id: <20240305121005.3528075-8-alex.bennee@linaro.org> diff --git a/include/gdbstub/user.h b/include/gdbstub/user.h index e33f8d9a9a6..3f9f45946e0 100644 --- a/include/gdbstub/user.h +++ b/include/gdbstub/user.h @@ -54,7 +54,7 @@ void gdbserver_fork_start(void); * gdbserver_fork() - disable gdb stub for child processes. * @cs: CPU */ -void gdbserver_fork(CPUState *cs); +void gdbserver_fork(CPUState *cs, pid_t pid); =20 /** * gdb_syscall_entry() - inform gdb of syscall entry and yield control to = it diff --git a/bsd-user/main.c b/bsd-user/main.c index fca9b302043..0dbd1cf8801 100644 --- a/bsd-user/main.c +++ b/bsd-user/main.c @@ -138,7 +138,7 @@ void fork_end(pid_t pid) */ qemu_init_cpu_list(); get_task_state(thread_cpu)->ts_tid =3D qemu_get_thread_id(); - gdbserver_fork(thread_cpu); + gdbserver_fork(thread_cpu, pid); } else { mmap_fork_end(child); cpu_list_unlock(); diff --git a/gdbstub/user.c b/gdbstub/user.c index 536fb43b03e..c61e1a0d1f6 100644 --- a/gdbstub/user.c +++ b/gdbstub/user.c @@ -375,7 +375,7 @@ static void disable_gdbstub(CPUState *thread_cpu) } =20 /* Disable gdb stub for child processes. */ -void gdbserver_fork(CPUState *cpu) +void gdbserver_fork(CPUState *cpu, pid_t pid) { if (!gdbserver_state.init || gdbserver_user_state.fd < 0) { return; diff --git a/linux-user/main.c b/linux-user/main.c index cab95f5b0aa..70314e0ab6a 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -165,7 +165,7 @@ void fork_end(pid_t pid) } qemu_init_cpu_list(); get_task_state(thread_cpu)->ts_tid =3D qemu_get_thread_id(); - gdbserver_fork(thread_cpu); + gdbserver_fork(thread_cpu, pid); } else { cpu_list_unlock(); } --=20 2.39.2 From nobody Tue Nov 26 06:56:45 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1709736143; cv=none; d=zohomail.com; s=zohoarc; b=mGaDzr0Eq/AphqR0hQEkoZWJWvprm5AyNrspYqR3Y13p0pvQawCA+89t5xVfdy+FJFnb81j1GvQDTLYbYd1LFIYp4M8f3xmdeHzGm7w7p481wJdU9bu4cPniGA720mdStjlVdiGzU+Vwi1IIR3O8ipidwz+o31fwQWrM6qrOUjI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709736143; 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=TfLkzlar7jFNAHdEcKzQrpi4P+XZLYByWr1iR6oEsZM=; b=I6HDuAMGBjZAcIIw+MDOZ3FT/HkZv7pY/uHivCqDVhr9luo8qPzO7KVvSDR75Lk2G4K8GZHDldxRhCmFEzpGzF6JyH3CmQYVcG9FEOgXyrDPxtvsu1S+e6A06hhJTq8Lh0V12TckHNOQR1ssr/tsIk4+jcKJs9BWLnnkfQWd/nA= 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 1709736143068912.6477946901806; Wed, 6 Mar 2024 06:42:23 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rhsS7-0007c0-Ef; Wed, 06 Mar 2024 09:41:03 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rhsS4-0007Po-2N for qemu-devel@nongnu.org; Wed, 06 Mar 2024 09:41:00 -0500 Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rhsRx-0001U1-9C for qemu-devel@nongnu.org; Wed, 06 Mar 2024 09:40:59 -0500 Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-412fe981ef1so2084735e9.1 for ; Wed, 06 Mar 2024 06:40:50 -0800 (PST) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id a14-20020a05600c348e00b00412f74d25b6sm1772554wmq.39.2024.03.06.06.40.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Mar 2024 06:40:45 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 639525F9CB; Wed, 6 Mar 2024 14:40:42 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1709736049; x=1710340849; 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=TfLkzlar7jFNAHdEcKzQrpi4P+XZLYByWr1iR6oEsZM=; b=nXCXTuQBXiNCzY5ypn5ei1gd47hbyLj0+HmiziBDqcZTRY86Oj/OKn62ON4fr2Z5a9 bgZGT+OjhclWsdEpHWoMAtUoT3YoX383q6xzm1bZiPkSdPxqfQdYnzm7ZW+IfmANMce8 Bi4dZFIiY5Rk5nd93m9/3JIEKpMsDo0LHMg4bqE3QzYplL35KouHt2o2ew2ReHssq6kY Kc1JZyGWE/V6BitRXrBCH7axMdaomvmo14s7xkwgJGb1HfPNopB1Ex1KzsRd+M2qiXxj PLMtEELg1PGtdNKbtKrBFZNoOmoy1vm497iylxq9Umxh3xSdagw3zYqFOnizzdLRcs8P NaAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709736049; x=1710340849; 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=TfLkzlar7jFNAHdEcKzQrpi4P+XZLYByWr1iR6oEsZM=; b=hrE32IyVaJRkSSgFnr227aNsOLz8bsTMy0lvEy3ZTCTaROaXaySYEuOFSq53XpF6jD AM9ofL0Tq/uq4KvLbJXFdTghnzBqtRAxb+GdlRW7PHLUmsmideXOF64iP+zhXvLyy1Na YzigakzeBADBTGqtLeYa579RzTrERkf/+0R3HlPxIZwCBboMZbvgiVpIIPFZ0kjY5fE+ znxPjguTVUPEXZNXb+rVLruUMSGoEBSiBM/hBbG39dywp0pkssyD07cqpdQ3MtxV0s2b ECa6YndVa6B8qI51bVxMdVV2HqGlnpi3Zzr111mqfaJf7r9X/3Bo9i+yq9V+m5MTtq44 QYWA== X-Gm-Message-State: AOJu0YyERXNrRneEzlFIA0psKZdnlrPwATdfX+INOvL82KqKBRBUMo8z UH/zqcsizkFyF/ek04xaWLowBV0r1zz5fPaz9/PevYTazPaG5fn502TAa9sIx4o= X-Google-Smtp-Source: AGHT+IEirMYpYkgI8PcKMl+C0xMEPlaAhgCfdkjRful75F6wVIbDp+l5gSmRhedvMyBjAlq4Q4BX2w== X-Received: by 2002:a05:600c:3589:b0:412:e992:6c32 with SMTP id p9-20020a05600c358900b00412e9926c32mr5486655wmq.11.1709736049525; Wed, 06 Mar 2024 06:40:49 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Ilya Leoshkevich , Richard Henderson , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Warner Losh , Kyle Evans , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Laurent Vivier Subject: [PULL 08/29] gdbstub: Call gdbserver_fork() both in parent and in child Date: Wed, 6 Mar 2024 14:40:20 +0000 Message-Id: <20240306144041.3787188-9-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240306144041.3787188-1-alex.bennee@linaro.org> References: <20240306144041.3787188-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32c; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x32c.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1709736143890100003 From: Ilya Leoshkevich The upcoming follow-fork-mode child support requires post-fork message exchange between the parent and the child. Prepare gdbserver_fork() for this purpose. Rename it to gdbserver_fork_end() to better reflect its purpose. Reviewed-by: Richard Henderson Signed-off-by: Ilya Leoshkevich Message-Id: <20240219141628.246823-8-iii@linux.ibm.com> Signed-off-by: Alex Benn=C3=A9e Message-Id: <20240305121005.3528075-9-alex.bennee@linaro.org> diff --git a/include/gdbstub/user.h b/include/gdbstub/user.h index 3f9f45946e0..4c4e5c4c582 100644 --- a/include/gdbstub/user.h +++ b/include/gdbstub/user.h @@ -51,10 +51,11 @@ void gdb_signalled(CPUArchState *as, int sig); void gdbserver_fork_start(void); =20 /** - * gdbserver_fork() - disable gdb stub for child processes. + * gdbserver_fork_end() - inform gdb of the completed fork() * @cs: CPU + * @pid: 0 if in child process, -1 if fork failed, child process pid other= wise */ -void gdbserver_fork(CPUState *cs, pid_t pid); +void gdbserver_fork_end(CPUState *cs, pid_t pid); =20 /** * gdb_syscall_entry() - inform gdb of syscall entry and yield control to = it diff --git a/bsd-user/main.c b/bsd-user/main.c index 0dbd1cf8801..3dc285e5b74 100644 --- a/bsd-user/main.c +++ b/bsd-user/main.c @@ -138,10 +138,11 @@ void fork_end(pid_t pid) */ qemu_init_cpu_list(); get_task_state(thread_cpu)->ts_tid =3D qemu_get_thread_id(); - gdbserver_fork(thread_cpu, pid); + gdbserver_fork_end(thread_cpu, pid); } else { mmap_fork_end(child); cpu_list_unlock(); + gdbserver_fork_end(thread_cpu, pid); end_exclusive(); } } diff --git a/gdbstub/user.c b/gdbstub/user.c index c61e1a0d1f6..866a25f9c06 100644 --- a/gdbstub/user.c +++ b/gdbstub/user.c @@ -374,10 +374,9 @@ static void disable_gdbstub(CPUState *thread_cpu) tb_flush(thread_cpu); } =20 -/* Disable gdb stub for child processes. */ -void gdbserver_fork(CPUState *cpu, pid_t pid) +void gdbserver_fork_end(CPUState *cpu, pid_t pid) { - if (!gdbserver_state.init || gdbserver_user_state.fd < 0) { + if (pid !=3D 0 || !gdbserver_state.init || gdbserver_user_state.fd < 0= ) { return; } disable_gdbstub(cpu); diff --git a/linux-user/main.c b/linux-user/main.c index 70314e0ab6a..41caa77cb52 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -165,10 +165,10 @@ void fork_end(pid_t pid) } qemu_init_cpu_list(); get_task_state(thread_cpu)->ts_tid =3D qemu_get_thread_id(); - gdbserver_fork(thread_cpu, pid); } else { cpu_list_unlock(); } + gdbserver_fork_end(thread_cpu, pid); /* * qemu_init_cpu_list() reinitialized the child exclusive state, but we * also need to keep current_cpu consistent, so call end_exclusive() f= or --=20 2.39.2 From nobody Tue Nov 26 06:56:45 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1709736197; cv=none; d=zohomail.com; s=zohoarc; b=fU4n8aRLZeW0b/ZChjjHV+V4VZB6B/+9VvQFtmoB3Ofgv47PwgFp+jEY5S1pGpx4qvV3p9mhtSoOwjim2iLJWB+lgusKNHLneUYVY+zi0+NcqeBuKreSb2HIoF15OQb3lOpgxNVhNDR+v/t2iQd5D+YyOnaiNeVFuc46HTyVGCM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709736197; 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=soJfHp369BNDgXM8MEutI1aVk/FtLr15JEFPPe/Y+aw=; b=b1Ah/8A6xkDjdnL22XO9pFxaDMlWHNrddneLZOgGEl+2iX8sNHjv4fiGm57oUctwtlBNqacZv5IIopZ8fjvDUYhdLihuPXPOG31BgLSy5YHqkrDdsVnuDp5z1677YiasGzUAH9WOAzoqLAwoRONc51UZkjUIvV+MJQNTPqgnEfA= 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 1709736197493462.02390011357454; Wed, 6 Mar 2024 06:43:17 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rhsS4-0007Q4-KR; Wed, 06 Mar 2024 09:41:00 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rhsS3-0007Or-If for qemu-devel@nongnu.org; Wed, 06 Mar 2024 09:40:59 -0500 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 1rhsRx-0001Tz-8z for qemu-devel@nongnu.org; Wed, 06 Mar 2024 09:40:59 -0500 Received: by mail-wr1-x42e.google.com with SMTP id ffacd0b85a97d-33d9c3f36c2so1158809f8f.2 for ; Wed, 06 Mar 2024 06:40:50 -0800 (PST) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id v7-20020a5d59c7000000b0033e475940fasm5392620wry.66.2024.03.06.06.40.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Mar 2024 06:40:45 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 78B705F9CE; Wed, 6 Mar 2024 14:40:42 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1709736049; x=1710340849; 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=soJfHp369BNDgXM8MEutI1aVk/FtLr15JEFPPe/Y+aw=; b=BN9ky0vGmQDhv6nUjiPsINkWHSt8zA3q8wcMkLECZOy10slKLaSW5ZEsqZpm69MVIC rdOWTDmaKmI9u+c5+hV81YEQjRaJTctmOFChnRGg7IS+jrEgrardBoEeLix/8aAiBGzQ lyU0bGPTSly9SlmtwSr3LofDDmBVyCdy0yMJ8S9cvTCuQqnJD4nrRrMNgcUk4863udkb 4Y+WJuUF5g4t2QsMkeFzFPugWfUF25yuHPDKixVENgwnxvNUdQmphginqKIJnqkUgrog 7QJXoQ9mep1BcWve5Xu4JzZb/Rr5C28NVpCkyxpvkRyqHYtJIpdbmjY2di6Lt9pJkTqV S9rg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709736049; x=1710340849; 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=soJfHp369BNDgXM8MEutI1aVk/FtLr15JEFPPe/Y+aw=; b=KiLUMb96W2ub1kuZvaoGx28dVb5YgeKxrUsY3hbR+fCQ2F/pnhUDGPSvAVvk5dISXz kGZw7QGRHd3jlkDIn6xFNIDpMq5r+rZjNfg1oCR3O3KB5OIVsmapK/PtHDiRYGy5vDlx 8Smf/R+qXVOf8Joy1QHzQRaEjVm7mC8SYz6HHbPf2Fvnz0FdBSceammVW4D22eFmlcPD TUOeaR9yKdoDoqdVFebt5BQDIvNXOHfWsCcNvGUf5Knm+Hdaki4jiBpM9s2hQUAI5KqK QU7/zIsQBXg0lPEmrforUyd5snqQtWfeRaW5SxBFgMEEoW/rfGi7HlkRVKcJE9UPW7mv VF9Q== X-Gm-Message-State: AOJu0YyjwE5RlaR1uJ+/wp9HAL5WDDv5x3sv8Tj4X3WwCOAE/XWSwA9Z m8DRV6TSxOBwO33PFWWMyvZQNRL8ufBW6Cl1oGQ6RRJ8WayMSkYuxN152g+9nqs= X-Google-Smtp-Source: AGHT+IGd1z+Vh9m+OUvvvf14GpCGogGRJepxf8zuguXq/e0sEOVfhrAcgxSwGi2m9JNmWpbQhbmTxg== X-Received: by 2002:adf:e60b:0:b0:33e:ed4:f9f6 with SMTP id p11-20020adfe60b000000b0033e0ed4f9f6mr11093285wrm.37.1709736049335; Wed, 06 Mar 2024 06:40:49 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Ilya Leoshkevich , Richard Henderson , =?UTF-8?q?Alex=20Benn=C3=A9e?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PULL 09/29] gdbstub: Introduce gdb_handle_query_supported_user() Date: Wed, 6 Mar 2024 14:40:21 +0000 Message-Id: <20240306144041.3787188-10-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240306144041.3787188-1-alex.bennee@linaro.org> References: <20240306144041.3787188-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, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01, 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: 1709736198151100001 From: Ilya Leoshkevich The upcoming follow-fork-mode child support requires advertising the fork-events feature, which is user-specific. Introduce a user-specific hook for this. Reviewed-by: Richard Henderson Signed-off-by: Ilya Leoshkevich Message-Id: <20240219141628.246823-9-iii@linux.ibm.com> Signed-off-by: Alex Benn=C3=A9e Message-Id: <20240305121005.3528075-10-alex.bennee@linaro.org> diff --git a/gdbstub/internals.h b/gdbstub/internals.h index 56b7c13b750..e6063835b1f 100644 --- a/gdbstub/internals.h +++ b/gdbstub/internals.h @@ -196,6 +196,7 @@ void gdb_handle_v_file_pread(GArray *params, void *user= _ctx); /* user */ void gdb_handle_v_file_readlink(GArray *params, void *user_ctx); /* user */ void gdb_handle_query_xfer_exec_file(GArray *params, void *user_ctx); /* u= ser */ void gdb_handle_set_catch_syscalls(GArray *params, void *user_ctx); /* use= r */ +void gdb_handle_query_supported_user(const char *gdb_supported); /* user */ =20 void gdb_handle_query_attached(GArray *params, void *user_ctx); /* both */ =20 diff --git a/gdbstub/gdbstub.c b/gdbstub/gdbstub.c index 2909bc8c69f..7be4418dcb5 100644 --- a/gdbstub/gdbstub.c +++ b/gdbstub/gdbstub.c @@ -1655,9 +1655,15 @@ static void handle_query_supported(GArray *params, v= oid *user_ctx) g_string_append(gdbserver_state.str_buf, ";qXfer:exec-file:read+"); #endif =20 - if (params->len && - strstr(get_param(params, 0)->data, "multiprocess+")) { - gdbserver_state.multiprocess =3D true; + if (params->len) { + const char *gdb_supported =3D get_param(params, 0)->data; + + if (strstr(gdb_supported, "multiprocess+")) { + gdbserver_state.multiprocess =3D true; + } +#if defined(CONFIG_USER_ONLY) + gdb_handle_query_supported_user(gdb_supported); +#endif } =20 g_string_append(gdbserver_state.str_buf, ";vContSupported+;multiproces= s+"); diff --git a/gdbstub/user.c b/gdbstub/user.c index 866a25f9c06..c9e8b83d720 100644 --- a/gdbstub/user.c +++ b/gdbstub/user.c @@ -382,6 +382,10 @@ void gdbserver_fork_end(CPUState *cpu, pid_t pid) disable_gdbstub(cpu); } =20 +void gdb_handle_query_supported_user(const char *gdb_supported) +{ +} + /* * Execution state helpers */ --=20 2.39.2 From nobody Tue Nov 26 06:56:45 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1709736367; cv=none; d=zohomail.com; s=zohoarc; b=gS9eSqIC/lsB3FWJGZInXOq/JwJnl8lj11FdueDkYmEtAt9csPlOVtDq/k4ULbzgOzqbSpmEi3eu7V4YRf43sPdl2ENDjtfq2xGN163pHcgduRLhYT05w5ZCjtf6VUwu4Re2SEwmO+mOI5evoANhlQhNu1G/zYf3BQ7ncqxxQEY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709736367; 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=Jj9/o2DyJDCE0FhDPwfUuDQ3010vyufY1i8QLxETkb8=; b=J5s0K/HkEoL4a0v22W9KBOmjO847fG6eeDao2tvR1AJ5rsRnKkfBOvN3to0JWHuECdBfRFuF1pPybMO10Av6/XVl8gB3kvebQff3GbEDAff+sM3AIWMuzXV5epyHHspFBL686YLvY6PdWbUEa/nH8rANT1rBGET28CHSnLESXC8= 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 1709736367923530.1359943455808; Wed, 6 Mar 2024 06:46:07 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rhsS5-0007RR-FK; Wed, 06 Mar 2024 09:41:01 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rhsS1-0007He-Mk for qemu-devel@nongnu.org; Wed, 06 Mar 2024 09:40:57 -0500 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rhsRx-0001U4-9P for qemu-devel@nongnu.org; Wed, 06 Mar 2024 09:40:57 -0500 Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-412f988d552so3111965e9.3 for ; Wed, 06 Mar 2024 06:40:51 -0800 (PST) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id p7-20020a05600c358700b00412b6fbb9b5sm12114412wmq.8.2024.03.06.06.40.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Mar 2024 06:40:45 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 8E3185F8A9; Wed, 6 Mar 2024 14:40:42 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1709736050; x=1710340850; 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=Jj9/o2DyJDCE0FhDPwfUuDQ3010vyufY1i8QLxETkb8=; b=EbAFzWgGn/cw08LVjK3s3PI367efrPXzGMpMLr5EaiWLLRu0HoKDcjhwk75lFrbAKV 4Ml5DLVrXUvyr3KNzpytC/Mgtxw76Hd+IqoIR9KDIyMEsB8oAX826RjSPwOSqt+7ZWqV 4jNNsfQZe9ffNudulaQBLVhxsl780HgLO5c9au+Ek0ZWoJ99kkjtQip35xuaDFP7JshB lrVaYA/F8jCmbudlbaz7FVN9nFHuk3p/U3sQ5hSbW+eGTevU9+axKAvoIR23iAabfojG hnUh5UfCDPFzEtRV7mqAscdcmG3STMIpaINQe13q5GAKpe3bXySBoKm7PdlmsDgyiPRK dZ4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709736050; x=1710340850; 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=Jj9/o2DyJDCE0FhDPwfUuDQ3010vyufY1i8QLxETkb8=; b=tyGzOpt4s56PnQ+/1u1NzipxPSSlH3QTPrj5/jOnb2qqA0mx2EnWxDAlo2WkIX8gZv +b4zvq9y+oN/wvBsdHoay4M0a04yal82r+GyXzRiAuoINb3rz/EWwMmEI//CgEuqn0UO osgq1j0YrP8GN4g20CVflgPXvWS7UsdHCROjQX/mXt4ATs6S8Amzwg5pHMfsHZXSgQNF dHigj4RK1ssTwNN6diNRC9swqr36Y1YBf5PW5osEM6+dU44vFxzLmzTXJ/DYAq2f9zYv Xrrp3HOd5do3Ocqg8MGBCwnyRDXuTukB+muTa8xW9aq8YqDd745dSN/gMk62tV75PMO7 q/oA== X-Gm-Message-State: AOJu0Yxq5PXz4QflJYBVzCrxWn4mOn2j4R5kjYiJkEWcQPxRa7yO6Yd6 qhNUlkKM0pySm8bSppQhFR/NkxELKRdfx7oUOYo/XfhKQSeRehGU3TXgsuHJi8A= X-Google-Smtp-Source: AGHT+IHlIqr1ytYFQnjbdF9zum9yzQ8P9Ri4gjI7w7e0QFrA9b0pFdcyQOlXgwEjgjbi8iSnV1pu3w== X-Received: by 2002:a05:600c:1d87:b0:412:e7d6:4464 with SMTP id p7-20020a05600c1d8700b00412e7d64464mr5534316wms.32.1709736049842; Wed, 06 Mar 2024 06:40:49 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Ilya Leoshkevich , =?UTF-8?q?Alex=20Benn=C3=A9e?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PULL 10/29] gdbstub: Introduce gdb_handle_set_thread_user() Date: Wed, 6 Mar 2024 14:40:22 +0000 Message-Id: <20240306144041.3787188-11-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240306144041.3787188-1-alex.bennee@linaro.org> References: <20240306144041.3787188-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::332; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x332.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1709736368900100001 From: Ilya Leoshkevich The upcoming follow-fork-mode child support needs to perform certain actions when GDB switches between the stopped parent and the stopped child. Introduce a user-specific hook for this. Signed-off-by: Ilya Leoshkevich Message-Id: <20240219141628.246823-10-iii@linux.ibm.com> Signed-off-by: Alex Benn=C3=A9e Message-Id: <20240305121005.3528075-11-alex.bennee@linaro.org> diff --git a/gdbstub/internals.h b/gdbstub/internals.h index e6063835b1f..b4905c7181a 100644 --- a/gdbstub/internals.h +++ b/gdbstub/internals.h @@ -197,6 +197,7 @@ void gdb_handle_v_file_readlink(GArray *params, void *u= ser_ctx); /* user */ void gdb_handle_query_xfer_exec_file(GArray *params, void *user_ctx); /* u= ser */ void gdb_handle_set_catch_syscalls(GArray *params, void *user_ctx); /* use= r */ void gdb_handle_query_supported_user(const char *gdb_supported); /* user */ +bool gdb_handle_set_thread_user(uint32_t pid, uint32_t tid); /* user */ =20 void gdb_handle_query_attached(GArray *params, void *user_ctx); /* both */ =20 diff --git a/gdbstub/gdbstub.c b/gdbstub/gdbstub.c index 7be4418dcb5..3eb93162aa8 100644 --- a/gdbstub/gdbstub.c +++ b/gdbstub/gdbstub.c @@ -1099,6 +1099,7 @@ static void handle_cont_with_sig(GArray *params, void= *user_ctx) =20 static void handle_set_thread(GArray *params, void *user_ctx) { + uint32_t pid, tid; CPUState *cpu; =20 if (params->len !=3D 2) { @@ -1116,8 +1117,14 @@ static void handle_set_thread(GArray *params, void *= user_ctx) return; } =20 - cpu =3D gdb_get_cpu(get_param(params, 1)->thread_id.pid, - get_param(params, 1)->thread_id.tid); + pid =3D get_param(params, 1)->thread_id.pid; + tid =3D get_param(params, 1)->thread_id.tid; +#ifdef CONFIG_USER_ONLY + if (gdb_handle_set_thread_user(pid, tid)) { + return; + } +#endif + cpu =3D gdb_get_cpu(pid, tid); if (!cpu) { gdb_put_packet("E22"); return; diff --git a/gdbstub/user.c b/gdbstub/user.c index c9e8b83d720..b048754c4f8 100644 --- a/gdbstub/user.c +++ b/gdbstub/user.c @@ -386,6 +386,11 @@ void gdb_handle_query_supported_user(const char *gdb_s= upported) { } =20 +bool gdb_handle_set_thread_user(uint32_t pid, uint32_t tid) +{ + return false; +} + /* * Execution state helpers */ --=20 2.39.2 From nobody Tue Nov 26 06:56:45 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1709736076; cv=none; d=zohomail.com; s=zohoarc; b=HVb42ElcSkmZjDbNPJ2JBP29UnlnwtazozyL+MXqQxV5GszUSnt42aHYZdno3gqLCWpHNCvfZnQQWg8fIoSyLyg3J/LhX3uV/Q+tciVGJd8YkZuaOpGkiMXQRNqsc2uu4hE9mUYMYCKpvHY4/xHHNXZMlZc0rQN/SGDM1XOyCa8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709736076; 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=nviOiWVWbJ3XjGVXW4/AZHv8DEOjXGh4DiERqDJEuQ4=; b=XWAlo3cnAeB0IjUp08Cj7JUsfU7MIrVTtNxayS3gWfAczBC0zn4f+O8X+BFfsc5Y9VJHb0v1TtNKN90PceMx9UoEEE1z2F2RJkXy2pEyzuhucGmlOkQq0EXJb81R8tF2BaT6hnVFBJsoBRvegQ3BRpYUfAkFEYCDpYduFPKFBlQ= 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 170973607611437.046248890757965; Wed, 6 Mar 2024 06:41:16 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rhsS7-0007co-Jk; Wed, 06 Mar 2024 09:41:03 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rhsS3-0007O6-BL for qemu-devel@nongnu.org; Wed, 06 Mar 2024 09:40:59 -0500 Received: from mail-wr1-x42d.google.com ([2a00:1450:4864:20::42d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rhsRx-0001Tt-9C for qemu-devel@nongnu.org; Wed, 06 Mar 2024 09:40:59 -0500 Received: by mail-wr1-x42d.google.com with SMTP id ffacd0b85a97d-33d90dfe73cso614845f8f.0 for ; Wed, 06 Mar 2024 06:40:48 -0800 (PST) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id bj1-20020a0560001e0100b0033e48db23bdsm4998270wrb.100.2024.03.06.06.40.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Mar 2024 06:40:45 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id A1D265F9CF; Wed, 6 Mar 2024 14:40:42 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1709736048; x=1710340848; 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=nviOiWVWbJ3XjGVXW4/AZHv8DEOjXGh4DiERqDJEuQ4=; b=lorAkO2b7j/zbXYiVsPKjOt3PZXMCY+mSZ7BULkeJkjXnr97ytVWR9k3tiv7VtUKqX sZ++j+lK/k0d9CStwhex7Ow2OPsYepXL+UaPPdMg0VVgqYf6WE/lSECTp1u4JK1XjuE9 ctVaYQOh4+W33IEODprBax72Wo+297vD4l39O2TPRW/6Jub0xx/BzBd+ifldgym39CHF P4e3L2MBs17/3FhY8Jbm8d2AKTP7fhq4DRZDOi/JUA1eOQXosmFO8ClY6QoScehRwZz4 l3lXFtVyi2dYoNAiNTZyTWXHNLULFnLkbXy68IbeZE2r6HD0qDrMVOg5+KGJp2Qq9td6 ZGqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709736048; x=1710340848; 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=nviOiWVWbJ3XjGVXW4/AZHv8DEOjXGh4DiERqDJEuQ4=; b=mPotsysm1R9R2zs0v5zqc85wqpCJ6EV67nyZa8Bb8L6HCBnXF+zMvZoce8LiSf3lw8 i4VWdhkBGfMcxMgI+PT1Uq4c7eG3WAGj2ZQWbQL9soT1m1FIpPAE+ePPyGrMED3w+QZI aOhMeKZaTU0JPxkMDE3Ns5lX1xSTW5Kl0+xEGBfqlRGikA9o9Dw9ZG7m4f0yNi2L+PhK gSVX6hSe3hOBKRBXEf06ytLDYB7YWj425CRi14hL2iY03w4qZ+btcMyfEeRyzLCHCcI0 7k7o48RZFDVku3Mo0Y2eCxt61tZWWdNuuih9i4fqq+Ilzvfw3u/G1TbHxd8RjQvTurv2 /aUg== X-Gm-Message-State: AOJu0YxUcNEevbfsa34HnBloI9XTxi72/OFkpu5X96dH2Lnq4S+q5w9R ngMW5S9WbQzlmtHSRKaXC84Z9IxaFbISZpAig6hSPzMtWmnKj7x17kSpyaqVltKzkZ+1W9aXrpe i X-Google-Smtp-Source: AGHT+IG5TcZEFOC0RNFcDJVYOC8ElAkOG7kdVOHHrhvegrEBII+k8NRpBqX2OOpejx3qi2ENgmWqdA== X-Received: by 2002:adf:8902:0:b0:33d:69c1:e7af with SMTP id s2-20020adf8902000000b0033d69c1e7afmr4427895wrs.9.1709736047766; Wed, 06 Mar 2024 06:40:47 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Ilya Leoshkevich , =?UTF-8?q?Alex=20Benn=C3=A9e?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PULL 11/29] gdbstub: Introduce gdb_handle_detach_user() Date: Wed, 6 Mar 2024 14:40:23 +0000 Message-Id: <20240306144041.3787188-12-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240306144041.3787188-1-alex.bennee@linaro.org> References: <20240306144041.3787188-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::42d; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x42d.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=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: 1709736077671100011 From: Ilya Leoshkevich The upcoming follow-fork-mode child support needs to perform certain actions when GDB detaches from the stopped parent or the stopped child. Introduce a user-specific hook for this. Signed-off-by: Ilya Leoshkevich Message-Id: <20240219141628.246823-11-iii@linux.ibm.com> Signed-off-by: Alex Benn=C3=A9e Message-Id: <20240305121005.3528075-12-alex.bennee@linaro.org> diff --git a/gdbstub/internals.h b/gdbstub/internals.h index b4905c7181a..b4724598384 100644 --- a/gdbstub/internals.h +++ b/gdbstub/internals.h @@ -198,6 +198,7 @@ void gdb_handle_query_xfer_exec_file(GArray *params, vo= id *user_ctx); /* user */ void gdb_handle_set_catch_syscalls(GArray *params, void *user_ctx); /* use= r */ void gdb_handle_query_supported_user(const char *gdb_supported); /* user */ bool gdb_handle_set_thread_user(uint32_t pid, uint32_t tid); /* user */ +bool gdb_handle_detach_user(uint32_t pid); /* user */ =20 void gdb_handle_query_attached(GArray *params, void *user_ctx); /* both */ =20 diff --git a/gdbstub/gdbstub.c b/gdbstub/gdbstub.c index 3eb93162aa8..17efcae0d0e 100644 --- a/gdbstub/gdbstub.c +++ b/gdbstub/gdbstub.c @@ -1024,6 +1024,12 @@ static void handle_detach(GArray *params, void *user= _ctx) pid =3D get_param(params, 0)->val_ul; } =20 +#ifdef CONFIG_USER_ONLY + if (gdb_handle_detach_user(pid)) { + return; + } +#endif + process =3D gdb_get_process(pid); gdb_process_breakpoint_remove_all(process); process->attached =3D false; diff --git a/gdbstub/user.c b/gdbstub/user.c index b048754c4f8..1a7b582a40d 100644 --- a/gdbstub/user.c +++ b/gdbstub/user.c @@ -391,6 +391,11 @@ bool gdb_handle_set_thread_user(uint32_t pid, uint32_t= tid) return false; } =20 +bool gdb_handle_detach_user(uint32_t pid) +{ + return false; +} + /* * Execution state helpers */ --=20 2.39.2 From nobody Tue Nov 26 06:56:45 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1709736132; cv=none; d=zohomail.com; s=zohoarc; b=JGmbwqGSWo+VKYNDXaBM9VaP3UtdCHspXziOUzTYeeQTptmKfpgxQNAKA9V9iZBIVRFX8bphZ+s9BPBOvlA+NXSwkkcoDQwLZJAX7NbJ7UzTjMOko0hFuScMpvur4ispncvZFTumm3UR51KUwUwhHK9RKRGL4ag3duLKhAE7Agw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709736132; 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=fFpozrhEXHVv7vPKY8mGoomu2zMrEYM+4yvjvxzqu7c=; b=VAXWj2sTz3uG0C5bWPMI3SYtIuNIY8i7CIciN7uixYbWj4LQebivtvMFxN79R30pNffiGxzC8yv8TZdsnawswsy/50qfcgj1fWh2FPIJfk11kaDjPaqWIbnqLfsMGE4Z6X4Bm0D7MnGcaIfLGt7ySnw20Kg595f4EORbKCq82WM= 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 1709736132540932.1659419260772; Wed, 6 Mar 2024 06:42:12 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rhsS6-0007Vn-Kj; Wed, 06 Mar 2024 09:41:02 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rhsS3-0007PA-Mh for qemu-devel@nongnu.org; Wed, 06 Mar 2024 09:40:59 -0500 Received: from mail-lf1-x12b.google.com ([2a00:1450:4864:20::12b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rhsRx-0001Tv-9Y for qemu-devel@nongnu.org; Wed, 06 Mar 2024 09:40:59 -0500 Received: by mail-lf1-x12b.google.com with SMTP id 2adb3069b0e04-5132010e5d1so2668545e87.0 for ; Wed, 06 Mar 2024 06:40:50 -0800 (PST) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id p26-20020a05600c1d9a00b00412f83e0c11sm1605253wms.22.2024.03.06.06.40.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Mar 2024 06:40:45 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id B5B715F9D3; Wed, 6 Mar 2024 14:40:42 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1709736048; x=1710340848; 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=fFpozrhEXHVv7vPKY8mGoomu2zMrEYM+4yvjvxzqu7c=; b=MQnAHmOBvC/w6wjSaqzG/lHDjb/RIrDWWIp5gA5f3DxIs6u/ptz1sveU1bztAiiYXF iAJ089A3D417yNQgMLvSxXslWmiAfI3VeuKOAQHIUF23KDLtrg5A5sbExYp33mBe+/xw hQ7fcbGS/O0n1f1+Z5tLiR0n4+p4W4a2N501EAkSjAmld708h1xbQH7dSABHXycfdI5U 2PMKiFpKru48GX3f/NeJoG4sDJBtAP4BMc+1lpcs1KcsTzwHq3ma8NPoYSm3bHMwBoFP P89Q8YdUMje9AIGiS9vr+JlCB3s7avrkTvfEcOvyDxn9P6KRxPOzs+LDb5wJliMyKJ2J Bp6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709736048; x=1710340848; 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=fFpozrhEXHVv7vPKY8mGoomu2zMrEYM+4yvjvxzqu7c=; b=dMVhZqCiXOhhRQrjaotMWbtcd+1zgha+voq8RXW0raaqecwXzIHXWpjrnwZ7dLZgWj Bbl2UfhxAJmPwLPR0L/R68M8vLdqR+NQnPu8JI7Rk4DN9mUUND/T3tgagpHsszmvvKIr YYuR1DvZ8RnmwYdW3Qtfm+Q5EuvV/w2jjCKq3zqU8NsqzU1ovwkS8LRMelgrc4jUa+V+ QFA1GS0vTxwV7Jjq9DyP3tpm5ZtLWv+mYvfSc9zc58mdWwr7RfXVCx3F2Fef62jcG44L WvHOKYzwi8sWTW6QZz26fgEh8MVM8l96ygQAuqh2YFgT2Us4+9V4XG7RcoYTbz9J+iuu haHA== X-Gm-Message-State: AOJu0YwbcWvX0psukLuVtvdXMwl+1sEHLnW3o0ESJSzkidYBOTPweHkE jZBceWN3G+f1BtaflKrRukXb2i3R+0USIm0XfIPBcOh5snvbbTN4nNX8dJyWC+cdKlLxwcpFLoo r X-Google-Smtp-Source: AGHT+IG5hBFOLuGp54pjqONU06LMsC2+6BiSMV91syOAbPaoTGw68yQZG4Cclcb8KpudemkhtvuVag== X-Received: by 2002:ac2:4c38:0:b0:513:f34:f4c1 with SMTP id u24-20020ac24c38000000b005130f34f4c1mr3271210lfq.20.1709736048027; Wed, 06 Mar 2024 06:40:48 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Ilya Leoshkevich , =?UTF-8?q?Alex=20Benn=C3=A9e?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PULL 12/29] gdbstub: Implement follow-fork-mode child Date: Wed, 6 Mar 2024 14:40:24 +0000 Message-Id: <20240306144041.3787188-13-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240306144041.3787188-1-alex.bennee@linaro.org> References: <20240306144041.3787188-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::12b; envelope-from=alex.bennee@linaro.org; helo=mail-lf1-x12b.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1709736133870100003 From: Ilya Leoshkevich Currently it's not possible to use gdbstub for debugging linux-user code that runs in a forked child, which is normally done using the `set follow-fork-mode child` GDB command. Purely on the protocol level, the missing piece is the fork-events feature. However, a deeper problem is supporting $Hg switching between different processes - right now it can do only threads. Implementing this for the general case would be quite complicated, but, fortunately, for the follow-fork-mode case there are a few factors that greatly simplify things: fork() happens in the exclusive section, there are only two processes involved, and before one of them is resumed, the second one is detached. This makes it possible to implement a simplified scheme: the parent and the child share the gdbserver socket, it's used only by one of them at any given time, which is coordinated through a separate socketpair. The processes can read from the gdbserver socket only one byte at a time, which is not great for performance, but, fortunately, the follow-fork-mode handling involves only a few messages. Advertise the fork-events support, and remember whether GDB has it as well. Implement the state machine that is initialized on fork(), decides the current owner of the gdbserver socket, and is terminated when one of the two processes is detached. The logic for the parent and the child is the same, only the initial state is different. Signed-off-by: Ilya Leoshkevich Message-Id: <20240219141628.246823-12-iii@linux.ibm.com> Signed-off-by: Alex Benn=C3=A9e Message-Id: <20240305121005.3528075-13-alex.bennee@linaro.org> diff --git a/gdbstub/user.c b/gdbstub/user.c index 1a7b582a40d..7f9f19a1249 100644 --- a/gdbstub/user.c +++ b/gdbstub/user.c @@ -25,6 +25,61 @@ #define GDB_NR_SYSCALLS 1024 typedef unsigned long GDBSyscallsMask[BITS_TO_LONGS(GDB_NR_SYSCALLS)]; =20 +/* + * Forked child talks to its parent in order to let GDB enforce the + * follow-fork-mode. This happens inside a start_exclusive() section, so t= hat + * the other threads, which may be forking too, do not interfere. The + * implementation relies on GDB not sending $vCont until it has detached + * either from the parent (follow-fork-mode child) or from the child + * (follow-fork-mode parent). + * + * The parent and the child share the GDB socket; at any given time only o= ne + * of them is allowed to use it, as is reflected in the respective fork_st= ate. + * This is negotiated via the fork_sockets pair as a reaction to $Hg. + * + * Below is a short summary of the possible state transitions: + * + * ENABLED : Terminal state. + * DISABLED : Terminal state. + * ACTIVE : Parent initial state. + * INACTIVE : Child initial state. + * ACTIVE -> DEACTIVATING: On $Hg. + * ACTIVE -> ENABLING : On $D. + * ACTIVE -> DISABLING : On $D. + * ACTIVE -> DISABLED : On communication error. + * DEACTIVATING -> INACTIVE : On gdb_read_byte() return. + * DEACTIVATING -> DISABLED : On communication error. + * INACTIVE -> ACTIVE : On $Hg in the peer. + * INACTIVE -> ENABLE : On $D in the peer. + * INACTIVE -> DISABLE : On $D in the peer. + * INACTIVE -> DISABLED : On communication error. + * ENABLING -> ENABLED : On gdb_read_byte() return. + * ENABLING -> DISABLED : On communication error. + * DISABLING -> DISABLED : On gdb_read_byte() return. + */ +enum GDBForkState { + /* Fully owning the GDB socket. */ + GDB_FORK_ENABLED, + /* Working with the GDB socket; the peer is inactive. */ + GDB_FORK_ACTIVE, + /* Handing off the GDB socket to the peer. */ + GDB_FORK_DEACTIVATING, + /* The peer is working with the GDB socket. */ + GDB_FORK_INACTIVE, + /* Asking the peer to close its GDB socket fd. */ + GDB_FORK_ENABLING, + /* Asking the peer to take over, closing our GDB socket fd. */ + GDB_FORK_DISABLING, + /* The peer has taken over, our GDB socket fd is closed. */ + GDB_FORK_DISABLED, +}; + +enum GDBForkMessage { + GDB_FORK_ACTIVATE =3D 'a', + GDB_FORK_ENABLE =3D 'e', + GDB_FORK_DISABLE =3D 'd', +}; + /* User-mode specific state */ typedef struct { int fd; @@ -36,6 +91,10 @@ typedef struct { */ bool catch_all_syscalls; GDBSyscallsMask catch_syscalls_mask; + bool fork_events; + enum GDBForkState fork_state; + int fork_sockets[2]; + pid_t fork_peer_pid, fork_peer_tid; } GDBUserState; =20 static GDBUserState gdbserver_user_state; @@ -358,6 +417,18 @@ int gdbserver_start(const char *port_or_path) =20 void gdbserver_fork_start(void) { + if (!gdbserver_state.init || gdbserver_user_state.fd < 0) { + return; + } + if (!gdbserver_user_state.fork_events || + qemu_socketpair(AF_UNIX, SOCK_STREAM, 0, + gdbserver_user_state.fork_sockets) < 0) { + gdbserver_user_state.fork_state =3D GDB_FORK_DISABLED; + return; + } + gdbserver_user_state.fork_state =3D GDB_FORK_INACTIVE; + gdbserver_user_state.fork_peer_pid =3D getpid(); + gdbserver_user_state.fork_peer_tid =3D qemu_get_thread_id(); } =20 static void disable_gdbstub(CPUState *thread_cpu) @@ -376,23 +447,160 @@ static void disable_gdbstub(CPUState *thread_cpu) =20 void gdbserver_fork_end(CPUState *cpu, pid_t pid) { - if (pid !=3D 0 || !gdbserver_state.init || gdbserver_user_state.fd < 0= ) { + char b; + int fd; + + if (!gdbserver_state.init || gdbserver_user_state.fd < 0) { return; } - disable_gdbstub(cpu); + + if (pid =3D=3D -1) { + if (gdbserver_user_state.fork_state !=3D GDB_FORK_DISABLED) { + g_assert(gdbserver_user_state.fork_state =3D=3D GDB_FORK_INACT= IVE); + close(gdbserver_user_state.fork_sockets[0]); + close(gdbserver_user_state.fork_sockets[1]); + } + return; + } + + if (gdbserver_user_state.fork_state =3D=3D GDB_FORK_DISABLED) { + if (pid =3D=3D 0) { + disable_gdbstub(cpu); + } + return; + } + + if (pid =3D=3D 0) { + close(gdbserver_user_state.fork_sockets[0]); + fd =3D gdbserver_user_state.fork_sockets[1]; + g_assert(gdbserver_state.process_num =3D=3D 1); + g_assert(gdbserver_state.processes[0].pid =3D=3D + gdbserver_user_state.fork_peer_pid); + g_assert(gdbserver_state.processes[0].attached); + gdbserver_state.processes[0].pid =3D getpid(); + } else { + close(gdbserver_user_state.fork_sockets[1]); + fd =3D gdbserver_user_state.fork_sockets[0]; + gdbserver_user_state.fork_state =3D GDB_FORK_ACTIVE; + gdbserver_user_state.fork_peer_pid =3D pid; + gdbserver_user_state.fork_peer_tid =3D pid; + + if (!gdbserver_state.allow_stop_reply) { + goto fail; + } + g_string_printf(gdbserver_state.str_buf, + "T%02xfork:p%02x.%02x;thread:p%02x.%02x;", + gdb_target_signal_to_gdb(gdb_target_sigtrap()), + pid, pid, (int)getpid(), qemu_get_thread_id()); + gdb_put_strbuf(); + } + + gdbserver_state.state =3D RS_IDLE; + gdbserver_state.allow_stop_reply =3D false; + gdbserver_user_state.running_state =3D 0; + for (;;) { + switch (gdbserver_user_state.fork_state) { + case GDB_FORK_ENABLED: + if (gdbserver_user_state.running_state) { + return; + } + QEMU_FALLTHROUGH; + case GDB_FORK_ACTIVE: + if (read(gdbserver_user_state.fd, &b, 1) !=3D 1) { + goto fail; + } + gdb_read_byte(b); + break; + case GDB_FORK_DEACTIVATING: + b =3D GDB_FORK_ACTIVATE; + if (write(fd, &b, 1) !=3D 1) { + goto fail; + } + gdbserver_user_state.fork_state =3D GDB_FORK_INACTIVE; + break; + case GDB_FORK_INACTIVE: + if (read(fd, &b, 1) !=3D 1) { + goto fail; + } + switch (b) { + case GDB_FORK_ACTIVATE: + gdbserver_user_state.fork_state =3D GDB_FORK_ACTIVE; + break; + case GDB_FORK_ENABLE: + close(fd); + gdbserver_user_state.fork_state =3D GDB_FORK_ENABLED; + break; + case GDB_FORK_DISABLE: + gdbserver_user_state.fork_state =3D GDB_FORK_DISABLED; + break; + default: + g_assert_not_reached(); + } + break; + case GDB_FORK_ENABLING: + b =3D GDB_FORK_DISABLE; + if (write(fd, &b, 1) !=3D 1) { + goto fail; + } + close(fd); + gdbserver_user_state.fork_state =3D GDB_FORK_ENABLED; + break; + case GDB_FORK_DISABLING: + b =3D GDB_FORK_ENABLE; + if (write(fd, &b, 1) !=3D 1) { + goto fail; + } + gdbserver_user_state.fork_state =3D GDB_FORK_DISABLED; + break; + case GDB_FORK_DISABLED: + close(fd); + disable_gdbstub(cpu); + return; + default: + g_assert_not_reached(); + } + } + +fail: + close(fd); + if (pid =3D=3D 0) { + disable_gdbstub(cpu); + } } =20 void gdb_handle_query_supported_user(const char *gdb_supported) { + if (strstr(gdb_supported, "fork-events+")) { + gdbserver_user_state.fork_events =3D true; + } + g_string_append(gdbserver_state.str_buf, ";fork-events+"); } =20 bool gdb_handle_set_thread_user(uint32_t pid, uint32_t tid) { + if (gdbserver_user_state.fork_state =3D=3D GDB_FORK_ACTIVE && + pid =3D=3D gdbserver_user_state.fork_peer_pid && + tid =3D=3D gdbserver_user_state.fork_peer_tid) { + gdbserver_user_state.fork_state =3D GDB_FORK_DEACTIVATING; + gdb_put_packet("OK"); + return true; + } return false; } =20 bool gdb_handle_detach_user(uint32_t pid) { + bool enable; + + if (gdbserver_user_state.fork_state =3D=3D GDB_FORK_ACTIVE) { + enable =3D pid =3D=3D gdbserver_user_state.fork_peer_pid; + if (enable || pid =3D=3D getpid()) { + gdbserver_user_state.fork_state =3D enable ? GDB_FORK_ENABLING= : + GDB_FORK_DISABLING; + gdb_put_packet("OK"); + return true; + } + } return false; } =20 --=20 2.39.2 From nobody Tue Nov 26 06:56:45 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1709736074; cv=none; d=zohomail.com; s=zohoarc; b=PDLj33JcyMjInz29988MUCtTwutJLztz+5K1KlSXYUSIjf0wmPIsbWGZLo4I3dM3LB+n+g37QU2KBT/So193cB6AZ7XGbO7I4zWkdgmOGvQoiUv/lHhu/eKFRsz7n7WycCT1yOshS79C0kDtiiv1UhrHChRTXMcM6bsgvgs38Lk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709736074; 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=M1lmVAwQWxhk52Kx07GGW6iRDF0OX21kw+KdP65AfDk=; b=mvwF++zp2pkrBW+Usli/4SR/C8Sz2XLjroKy6WtrAMLUTg3TICrjFG8l/APHg2TTiU3bkbKpRx0k6Yuc0cvt2p1No0cAWhgH6mx+ycFzdlyKxVexATpUA4EzL/7H9DgetHlu+B9nFahVRLksqfm2D09lUQar2lwYPOQYVfLfenc= 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 1709736074862482.6570831300089; Wed, 6 Mar 2024 06:41:14 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rhsS9-0007m0-V1; Wed, 06 Mar 2024 09:41:05 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rhsS8-0007h7-Dx for qemu-devel@nongnu.org; Wed, 06 Mar 2024 09:41:04 -0500 Received: from mail-wr1-x432.google.com ([2a00:1450:4864:20::432]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rhsS0-0001UP-HF for qemu-devel@nongnu.org; Wed, 06 Mar 2024 09:41:03 -0500 Received: by mail-wr1-x432.google.com with SMTP id ffacd0b85a97d-33e17fc5aceso563896f8f.0 for ; Wed, 06 Mar 2024 06:40:54 -0800 (PST) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id bv28-20020a0560001f1c00b0033d70dd0e04sm18074128wrb.8.2024.03.06.06.40.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Mar 2024 06:40:49 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id CCB115F891; Wed, 6 Mar 2024 14:40:42 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1709736054; x=1710340854; 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=M1lmVAwQWxhk52Kx07GGW6iRDF0OX21kw+KdP65AfDk=; b=RTvPlTHgtQYwu5QcxAuwdIdOcfLs+cThVHWD2ul8yxP3ZV1X1debIKcihOyh7hGqks VyZP5R8O6gfKp2mXQ9T03LuiLn052+zomz0RYOgHMpUmZ/np9+nSgauw3SnCExuKvAVo RC29PMnQ94yZblf3SAsvBByhJMNssJE6w66ExmKWq/frmXgjZ4Nc3zEOufnH4TA1ZeII MhSVUunDV25n4IoQvWN8Bd1yzYPlEu/QVbA76/N0hRdgbBQhO8+/tDR9df4abJcZNaiH d3NEN6VbqwHJza753ZhvmUueqJ8oQkWOV3u2eKLfilQxNkW7TkSNYQSsLXhZEGIOw+XH UxhA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709736054; x=1710340854; 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=M1lmVAwQWxhk52Kx07GGW6iRDF0OX21kw+KdP65AfDk=; b=wipSJGlqBQefF3ry+Uq2lIN29Cb2WBQg2B57y4E9yvoFIJFm83u+oUaHy6eeotY6ji pGMb0nYQfYkavJ+WwUS6KjJgOr97Q6hoZRIln7SgIUbso/S2qz4pqWKuvytczxG7Q4Uf bYN1HoMTasajWzH2ZXgRJ+Tjy4If8tA96dkpARZ9Sif/SqJ6G3K5/ZED1UQQ0uUy7i0J uFwEfiUN4mcNPSUKCyWKw3W6wFBD1c/Yc3PmT/E+529B8Ffx7LNh2TBe3d9BLKlloPMD wRJIaoMKqu1cL7zRhTSlwm9DIPOgXoCdfm2RNvbeYLAhMazZqhASva46XzI6SvFJxtuE fWSA== X-Gm-Message-State: AOJu0YxGMcK49H8j+G8A6mM2jOWuCi8oDrumjFSitFmCek2oDQdIqrxz CSjr8lwrvXTx3PT9lClugMm014c3SvcqewV6lMDlHulx97wEMM8UQUMNDUyTxEY= X-Google-Smtp-Source: AGHT+IEsw2v57NjebTTFet/5mGUXzIhAuzBbTabKj5dXO8wNgBW6a1sxWDKWEKFSQJtMeFIvmTtasA== X-Received: by 2002:a5d:4d82:0:b0:33d:f60c:53e2 with SMTP id b2-20020a5d4d82000000b0033df60c53e2mr5312132wru.11.1709736053824; Wed, 06 Mar 2024 06:40:53 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Ilya Leoshkevich , =?UTF-8?q?Alex=20Benn=C3=A9e?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PULL 13/29] tests/tcg: Add two follow-fork-mode tests Date: Wed, 6 Mar 2024 14:40:25 +0000 Message-Id: <20240306144041.3787188-14-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240306144041.3787188-1-alex.bennee@linaro.org> References: <20240306144041.3787188-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::432; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x432.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1709736075550100004 From: Ilya Leoshkevich Add follow-fork-mode child and and follow-fork-mode parent tests. Check for the obvious pitfalls, such as lingering breakpoints, catchpoints, and single-step mode. Signed-off-by: Ilya Leoshkevich Message-Id: <20240219141628.246823-13-iii@linux.ibm.com> Signed-off-by: Alex Benn=C3=A9e Message-Id: <20240305121005.3528075-14-alex.bennee@linaro.org> diff --git a/tests/tcg/multiarch/follow-fork-mode.c b/tests/tcg/multiarch/f= ollow-fork-mode.c new file mode 100644 index 00000000000..cb6b032b388 --- /dev/null +++ b/tests/tcg/multiarch/follow-fork-mode.c @@ -0,0 +1,56 @@ +/* + * Test GDB's follow-fork-mode. + * + * fork() a chain of processes. + * Parents sends one byte to their children, and children return their + * position in the chain, in order to prove that they survived GDB's fork() + * handling. + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ +#include +#include +#include +#include + +void break_after_fork(void) +{ +} + +int main(void) +{ + int depth =3D 42, err, i, fd[2], status; + pid_t child, pid; + ssize_t n; + char b; + + for (i =3D 0; i < depth; i++) { + err =3D pipe(fd); + assert(err =3D=3D 0); + child =3D fork(); + break_after_fork(); + assert(child !=3D -1); + if (child =3D=3D 0) { + close(fd[1]); + + n =3D read(fd[0], &b, 1); + close(fd[0]); + assert(n =3D=3D 1); + assert(b =3D=3D (char)i); + } else { + close(fd[0]); + + b =3D (char)i; + n =3D write(fd[1], &b, 1); + close(fd[1]); + assert(n =3D=3D 1); + + pid =3D waitpid(child, &status, 0); + assert(pid =3D=3D child); + assert(WIFEXITED(status)); + return WEXITSTATUS(status) - 1; + } + } + + return depth; +} diff --git a/tests/tcg/multiarch/Makefile.target b/tests/tcg/multiarch/Make= file.target index f11f3b084d7..979a0dd1bc2 100644 --- a/tests/tcg/multiarch/Makefile.target +++ b/tests/tcg/multiarch/Makefile.target @@ -106,6 +106,20 @@ run-gdbstub-catch-syscalls: catch-syscalls --bin $< --test $(MULTIARCH_SRC)/gdbstub/catch-syscalls.py, \ hitting a syscall catchpoint) =20 +run-gdbstub-follow-fork-mode-child: follow-fork-mode + $(call run-test, $@, $(GDB_SCRIPT) \ + --gdb $(GDB) \ + --qemu $(QEMU) --qargs "$(QEMU_OPTS)" \ + --bin $< --test $(MULTIARCH_SRC)/gdbstub/follow-fork-mode-child.py, \ + following children on fork) + +run-gdbstub-follow-fork-mode-parent: follow-fork-mode + $(call run-test, $@, $(GDB_SCRIPT) \ + --gdb $(GDB) \ + --qemu $(QEMU) --qargs "$(QEMU_OPTS)" \ + --bin $< --test $(MULTIARCH_SRC)/gdbstub/follow-fork-mode-parent.py, \ + following parents on fork) + else run-gdbstub-%: $(call skip-test, "gdbstub test $*", "need working gdb with $(patsubst -%= ,,$(TARGET_NAME)) support") @@ -113,7 +127,8 @@ endif EXTRA_RUNS +=3D run-gdbstub-sha1 run-gdbstub-qxfer-auxv-read \ run-gdbstub-proc-mappings run-gdbstub-thread-breakpoint \ run-gdbstub-registers run-gdbstub-prot-none \ - run-gdbstub-catch-syscalls + run-gdbstub-catch-syscalls run-gdbstub-follow-fork-mode-child \ + run-gdbstub-follow-fork-mode-parent =20 # ARM Compatible Semi Hosting Tests # diff --git a/tests/tcg/multiarch/gdbstub/follow-fork-mode-child.py b/tests/= tcg/multiarch/gdbstub/follow-fork-mode-child.py new file mode 100644 index 00000000000..72a6e440c08 --- /dev/null +++ b/tests/tcg/multiarch/gdbstub/follow-fork-mode-child.py @@ -0,0 +1,40 @@ +"""Test GDB's follow-fork-mode child. + +SPDX-License-Identifier: GPL-2.0-or-later +""" +from test_gdbstub import main, report + + +def run_test(): + """Run through the tests one by one""" + gdb.execute("set follow-fork-mode child") + # Check that the parent breakpoints are unset. + gdb.execute("break break_after_fork") + # Check that the parent syscall catchpoints are unset. + # Skip this check on the architectures that don't have them. + have_fork_syscall =3D False + for fork_syscall in ("fork", "clone", "clone2", "clone3"): + try: + gdb.execute("catch syscall {}".format(fork_syscall)) + except gdb.error: + pass + else: + have_fork_syscall =3D True + gdb.execute("continue") + for i in range(42): + if have_fork_syscall: + # syscall entry. + if i % 2 =3D=3D 0: + # Check that the parent single-stepping is turned off. + gdb.execute("si") + else: + gdb.execute("continue") + # syscall exit. + gdb.execute("continue") + # break_after_fork() + gdb.execute("continue") + exitcode =3D int(gdb.parse_and_eval("$_exitcode")) + report(exitcode =3D=3D 42, "{} =3D=3D 42".format(exitcode)) + + +main(run_test) diff --git a/tests/tcg/multiarch/gdbstub/follow-fork-mode-parent.py b/tests= /tcg/multiarch/gdbstub/follow-fork-mode-parent.py new file mode 100644 index 00000000000..5c2fe722088 --- /dev/null +++ b/tests/tcg/multiarch/gdbstub/follow-fork-mode-parent.py @@ -0,0 +1,16 @@ +"""Test GDB's follow-fork-mode parent. + +SPDX-License-Identifier: GPL-2.0-or-later +""" +from test_gdbstub import main, report + + +def run_test(): + """Run through the tests one by one""" + gdb.execute("set follow-fork-mode parent") + gdb.execute("continue") + exitcode =3D int(gdb.parse_and_eval("$_exitcode")) + report(exitcode =3D=3D 0, "{} =3D=3D 0".format(exitcode)) + + +main(run_test) --=20 2.39.2 From nobody Tue Nov 26 06:56:45 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1709736334; cv=none; d=zohomail.com; s=zohoarc; b=Jw5VbBZ2S6/alboL0uhV05PuKns5M4q/tW5KvnNhlGJ5r1IXFSuPOltOU1EwyQ5UTUNjSn1K8xROPYbNRdbLSd4y54O9ijHuo10j3tA9lpBm7/14tPvNwrCqQO2Zh5DZDLePorOGY1baQkAuQun2J2dZdKS6D1QXRqgaizYxMxE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709736334; 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=ki0eBwvVPbG3uY1pFngWxP/DBMoTpIxCU09HcH4vuZs=; b=QXDiBXhsoMCU3qqoFsJG35+mdqSGVR7nCmNo5M/L9bT1HPjKzw1Uk15eryRbQDuWjn9CutamUOwTqsQXUeuD6ZzbBOEy1vrYufy5vTBXdMTKlQvzZ1T1+jVejq2U8bocfTz4kf71Ijf+I6yAKdct4V61v1Ihe2lt3SxdMDRFdGA= 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 1709736334635436.9657320151314; Wed, 6 Mar 2024 06:45:34 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rhsSG-00087E-N5; Wed, 06 Mar 2024 09:41:12 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rhsSA-0007nz-Gn for qemu-devel@nongnu.org; Wed, 06 Mar 2024 09:41:06 -0500 Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rhsRz-0001UM-KG for qemu-devel@nongnu.org; Wed, 06 Mar 2024 09:41:06 -0500 Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-412e80e13abso22407205e9.3 for ; Wed, 06 Mar 2024 06:40:55 -0800 (PST) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id bd12-20020a05600c1f0c00b00412fb99be59sm1043634wmb.0.2024.03.06.06.40.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Mar 2024 06:40:45 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id E550B5F94F; Wed, 6 Mar 2024 14:40:42 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1709736053; x=1710340853; 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=ki0eBwvVPbG3uY1pFngWxP/DBMoTpIxCU09HcH4vuZs=; b=ETOdF7dj7X0xKk+J4uk3g5J/goOVz2yj02glMb84J3rRiu9HzlRYbJvPiFQHbTx/n6 i0n+qZFmRRya/jblUBw/Nru0koTpDJOg7gMH4D8ttpAmHi87bJN4rl6yAzM5ixQQlWcT gh/pvMcK3Iuc13cYIdWflbqNYRHx2LbFAdgdtJppUsGH1dSA6fQC6mP76099mcSD8+IZ TpJIfCvDmh0BxBAW2qb+lus2beoVa/prcM7Mj5ljyL2NP2daoDJVivJyMs+1wl5Pyv30 n9hV3ykxdqYeLw7aghGPkl80xLTyERmIDYYwBVjmgywAIH8HirDhST2y+rE8H7h03tDY NNew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709736053; x=1710340853; 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=ki0eBwvVPbG3uY1pFngWxP/DBMoTpIxCU09HcH4vuZs=; b=vy1tOogYGuXumRDtNArIDQbXfcwjWtLIkmJ4SK2IfzrGA5IPqrWwBIXPIxdwCPSp0n /fObdh8knJ0RYXEw11lfqGeRKr2/0YlfCw47gyE1moIwRx2tqagxWRIi1p0jTIeZwQlq Ru/4yzHLX7Jf5v9uaMJJMURIyJHv2KVRgQDJbJvQ844tuyy4JiAEbXVPK3SzkNU3KETF +DvivfmVvg0kBbenOY9RIaQBbMTTMHQrxxqrqC9k+3u6W+9XMEaEajQxwNOULot/gtBX 2dteBAlpF/COMH6P/GGLb0wPP4tu4N64BMhfTsfHDhAIaeku9Q8IlOZIvu1rWkWvBDde Ug/w== X-Gm-Message-State: AOJu0YzbaYauTjDa9SV+U9MdjGB0DUkvtDEFeWARg7uc30s9X7FlDywZ VveqIpGrmVDnK0ccmjBBBLTPnjaZ/V9nG1Uep1mlPCF2xUTf/BeKoy/PmsiboaY= X-Google-Smtp-Source: AGHT+IFMFiJzlGaul+b4YHRZqHk42rnrgAqQECslqJipcpMMvuk8aDmb/67oOp/Uv/+xbb3T3Lf2rQ== X-Received: by 2002:a05:600c:1911:b0:412:ca53:5ff6 with SMTP id j17-20020a05600c191100b00412ca535ff6mr11424131wmq.10.1709736052944; Wed, 06 Mar 2024 06:40:52 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Pierrick Bouvier , Richard Henderson , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Alexandre Iooss , Mahmoud Mandour Subject: [PULL 14/29] plugins: scoreboard API Date: Wed, 6 Mar 2024 14:40:26 +0000 Message-Id: <20240306144041.3787188-15-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240306144041.3787188-1-alex.bennee@linaro.org> References: <20240306144041.3787188-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, T_SCC_BODY_TEXT_LINE=-0.01, 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: 1709736336945100003 From: Pierrick Bouvier We introduce a cpu local storage, automatically managed (and extended) by QEMU itself. Plugin allocate a scoreboard, and don't have to deal with how many cpus are launched. This API will be used by new inline functions but callbacks can benefit from this as well. This way, they can operate without a global lock for simple operations. At any point during execution, any scoreboard will be dimensioned with at least qemu_plugin_num_vcpus entries. New functions: - qemu_plugin_scoreboard_find - qemu_plugin_scoreboard_free - qemu_plugin_scoreboard_new Reviewed-by: Richard Henderson Signed-off-by: Pierrick Bouvier Message-Id: <20240304130036.124418-2-pierrick.bouvier@linaro.org> Signed-off-by: Alex Benn=C3=A9e Message-Id: <20240305121005.3528075-15-alex.bennee@linaro.org> diff --git a/include/qemu/plugin.h b/include/qemu/plugin.h index b3c94a34aa4..bf96d2c2aa3 100644 --- a/include/qemu/plugin.h +++ b/include/qemu/plugin.h @@ -112,6 +112,12 @@ struct qemu_plugin_insn { bool mem_only; }; =20 +/* A scoreboard is an array of values, indexed by vcpu_index */ +struct qemu_plugin_scoreboard { + GArray *data; + QLIST_ENTRY(qemu_plugin_scoreboard) entry; +}; + /* * qemu_plugin_insn allocate and cleanup functions. We don't expect to * cleanup many of these structures. They are reused for each fresh diff --git a/include/qemu/qemu-plugin.h b/include/qemu/qemu-plugin.h index 45e2ebc8f8f..31c468ddb2c 100644 --- a/include/qemu/qemu-plugin.h +++ b/include/qemu/qemu-plugin.h @@ -222,6 +222,8 @@ void qemu_plugin_register_vcpu_resume_cb(qemu_plugin_id= _t id, struct qemu_plugin_tb; /** struct qemu_plugin_insn - Opaque handle for a translated instruction */ struct qemu_plugin_insn; +/** struct qemu_plugin_scoreboard - Opaque handle for a scoreboard */ +struct qemu_plugin_scoreboard; =20 /** * enum qemu_plugin_cb_flags - type of callback @@ -752,5 +754,34 @@ QEMU_PLUGIN_API int qemu_plugin_read_register(struct qemu_plugin_register *handle, GByteArray *buf); =20 +/** + * qemu_plugin_scoreboard_new() - alloc a new scoreboard + * + * @element_size: size (in bytes) for one entry + * + * Returns a pointer to a new scoreboard. It must be freed using + * qemu_plugin_scoreboard_free. + */ +QEMU_PLUGIN_API +struct qemu_plugin_scoreboard *qemu_plugin_scoreboard_new(size_t element_s= ize); + +/** + * qemu_plugin_scoreboard_free() - free a scoreboard + * @score: scoreboard to free + */ +QEMU_PLUGIN_API +void qemu_plugin_scoreboard_free(struct qemu_plugin_scoreboard *score); + +/** + * qemu_plugin_scoreboard_find() - get pointer to an entry of a scoreboard + * @score: scoreboard to query + * @vcpu_index: entry index + * + * Returns address of entry of a scoreboard matching a given vcpu_index. T= his + * address can be modified later if scoreboard is resized. + */ +QEMU_PLUGIN_API +void *qemu_plugin_scoreboard_find(struct qemu_plugin_scoreboard *score, + unsigned int vcpu_index); =20 #endif /* QEMU_QEMU_PLUGIN_H */ diff --git a/plugins/plugin.h b/plugins/plugin.h index 00b3509f708..043c740067d 100644 --- a/plugins/plugin.h +++ b/plugins/plugin.h @@ -31,6 +31,8 @@ struct qemu_plugin_state { * but with the HT we avoid adding a field to CPUState. */ GHashTable *cpu_ht; + QLIST_HEAD(, qemu_plugin_scoreboard) scoreboards; + size_t scoreboard_alloc_size; DECLARE_BITMAP(mask, QEMU_PLUGIN_EV_MAX); /* * @lock protects the struct as well as ctx->uninstalling. @@ -101,4 +103,8 @@ void exec_inline_op(struct qemu_plugin_dyn_cb *cb); =20 int plugin_num_vcpus(void); =20 +struct qemu_plugin_scoreboard *plugin_scoreboard_new(size_t element_size); + +void plugin_scoreboard_free(struct qemu_plugin_scoreboard *score); + #endif /* PLUGIN_H */ diff --git a/plugins/api.c b/plugins/api.c index e905e995bd6..76b2e652b9c 100644 --- a/plugins/api.c +++ b/plugins/api.c @@ -465,3 +465,22 @@ int qemu_plugin_read_register(struct qemu_plugin_regis= ter *reg, GByteArray *buf) =20 return gdb_read_register(current_cpu, buf, GPOINTER_TO_INT(reg)); } + +struct qemu_plugin_scoreboard *qemu_plugin_scoreboard_new(size_t element_s= ize) +{ + return plugin_scoreboard_new(element_size); +} + +void qemu_plugin_scoreboard_free(struct qemu_plugin_scoreboard *score) +{ + plugin_scoreboard_free(score); +} + +void *qemu_plugin_scoreboard_find(struct qemu_plugin_scoreboard *score, + unsigned int vcpu_index) +{ + g_assert(vcpu_index < qemu_plugin_num_vcpus()); + /* we can't use g_array_index since entry size is not statically known= */ + char *base_ptr =3D score->data->data; + return base_ptr + vcpu_index * g_array_get_element_size(score->data); +} diff --git a/plugins/core.c b/plugins/core.c index 2db4d31354b..63f4c6c6ce3 100644 --- a/plugins/core.c +++ b/plugins/core.c @@ -18,6 +18,7 @@ #include "qemu/lockable.h" #include "qemu/option.h" #include "qemu/plugin.h" +#include "qemu/queue.h" #include "qemu/rcu_queue.h" #include "qemu/xxhash.h" #include "qemu/rcu.h" @@ -215,6 +216,35 @@ CPUPluginState *qemu_plugin_create_vcpu_state(void) return g_new0(CPUPluginState, 1); } =20 +static void plugin_grow_scoreboards__locked(CPUState *cpu) +{ + if (cpu->cpu_index < plugin.scoreboard_alloc_size) { + return; + } + + bool need_realloc =3D FALSE; + while (cpu->cpu_index >=3D plugin.scoreboard_alloc_size) { + plugin.scoreboard_alloc_size *=3D 2; + need_realloc =3D TRUE; + } + + + if (!need_realloc || QLIST_EMPTY(&plugin.scoreboards)) { + /* nothing to do, we just updated sizes for future scoreboards */ + return; + } + + /* cpus must be stopped, as tb might still use an existing scoreboard.= */ + start_exclusive(); + struct qemu_plugin_scoreboard *score; + QLIST_FOREACH(score, &plugin.scoreboards, entry) { + g_array_set_size(score->data, plugin.scoreboard_alloc_size); + } + /* force all tb to be flushed, as scoreboard pointers were changed. */ + tb_flush(cpu); + end_exclusive(); +} + void qemu_plugin_vcpu_init_hook(CPUState *cpu) { bool success; @@ -225,6 +255,7 @@ void qemu_plugin_vcpu_init_hook(CPUState *cpu) success =3D g_hash_table_insert(plugin.cpu_ht, &cpu->cpu_index, &cpu->cpu_index); g_assert(success); + plugin_grow_scoreboards__locked(cpu); qemu_rec_mutex_unlock(&plugin.lock); =20 plugin_vcpu_cb__simple(cpu, QEMU_PLUGIN_EV_VCPU_INIT); @@ -578,6 +609,8 @@ static void __attribute__((__constructor__)) plugin_ini= t(void) qemu_rec_mutex_init(&plugin.lock); plugin.id_ht =3D g_hash_table_new(g_int64_hash, g_int64_equal); plugin.cpu_ht =3D g_hash_table_new(g_int_hash, g_int_equal); + QLIST_INIT(&plugin.scoreboards); + plugin.scoreboard_alloc_size =3D 16; /* avoid frequent reallocation */ QTAILQ_INIT(&plugin.ctxs); qht_init(&plugin.dyn_cb_arr_ht, plugin_dyn_cb_arr_cmp, 16, QHT_MODE_AUTO_RESIZE); @@ -588,3 +621,27 @@ int plugin_num_vcpus(void) { return plugin.num_vcpus; } + +struct qemu_plugin_scoreboard *plugin_scoreboard_new(size_t element_size) +{ + struct qemu_plugin_scoreboard *score =3D + g_malloc0(sizeof(struct qemu_plugin_scoreboard)); + score->data =3D g_array_new(FALSE, TRUE, element_size); + g_array_set_size(score->data, plugin.scoreboard_alloc_size); + + qemu_rec_mutex_lock(&plugin.lock); + QLIST_INSERT_HEAD(&plugin.scoreboards, score, entry); + qemu_rec_mutex_unlock(&plugin.lock); + + return score; +} + +void plugin_scoreboard_free(struct qemu_plugin_scoreboard *score) +{ + qemu_rec_mutex_lock(&plugin.lock); + QLIST_REMOVE(score, entry); + qemu_rec_mutex_unlock(&plugin.lock); + + g_array_free(score->data, TRUE); + g_free(score); +} diff --git a/plugins/qemu-plugins.symbols b/plugins/qemu-plugins.symbols index 27fe97239be..3f93e7d6b13 100644 --- a/plugins/qemu-plugins.symbols +++ b/plugins/qemu-plugins.symbols @@ -37,6 +37,9 @@ qemu_plugin_register_vcpu_tb_exec_inline; qemu_plugin_register_vcpu_tb_trans_cb; qemu_plugin_reset; + qemu_plugin_scoreboard_free; + qemu_plugin_scoreboard_find; + qemu_plugin_scoreboard_new; qemu_plugin_start_code; qemu_plugin_tb_get_insn; qemu_plugin_tb_n_insns; --=20 2.39.2 From nobody Tue Nov 26 06:56:45 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1709736156; cv=none; d=zohomail.com; s=zohoarc; b=Uz57sTecvD+PK6Q8LQcpsuE/y1yFYiy2Wi+L25AUV0BP3lXCkUXTx0WCZYgJh8QEpm5BOCCT1EnCBwSdiI8ZpCjfeT6wi55a0qjfLnJf79z6k6t7ykUL/UzjW7kQqTf8x4CKfAlPu3n7qp7IiDLOzVXt3Rrf0LXfXKWMsxscEg4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709736156; 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=7HiJVoF4HTxTyfZqmxfdNDwSSt/1/19ukV8tNZkwTQ4=; b=VioDIh490z/00Lf7UL2F2O8DlTc3wx7LeoFZ7Q2gF/X28eBQp6BMEviISx1hh1udHzFhgD4+EfepNrCNwVK1kM5uAeYKBzAgRTkV4OJ61l+kSmw94sNuTv66/r02Y9k17R219f41O9uby+YMj51qSWw+5vXLFIts0e/DR3K5WbI= 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 1709736156519513.2763586267132; Wed, 6 Mar 2024 06:42:36 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rhsSH-0008F9-Ui; Wed, 06 Mar 2024 09:41:13 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rhsSA-0007ny-Fv for qemu-devel@nongnu.org; Wed, 06 Mar 2024 09:41:06 -0500 Received: from mail-wr1-x434.google.com ([2a00:1450:4864:20::434]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rhsS2-0001Uz-Om for qemu-devel@nongnu.org; Wed, 06 Mar 2024 09:41:06 -0500 Received: by mail-wr1-x434.google.com with SMTP id ffacd0b85a97d-33e151a1434so2420205f8f.2 for ; Wed, 06 Mar 2024 06:40:58 -0800 (PST) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id i10-20020adff30a000000b0033b6e26f0f9sm17781896wro.42.2024.03.06.06.40.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Mar 2024 06:40:52 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 05FFA5F9DA; Wed, 6 Mar 2024 14:40:43 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1709736056; x=1710340856; 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=7HiJVoF4HTxTyfZqmxfdNDwSSt/1/19ukV8tNZkwTQ4=; b=W5Jlz7bgA1ug3WWitQJ9VZ+SfAhG8TaKjq4lu5H888Bv3U2NJKuRRmRwZJA5wJpzkR HvxyBB29CKEl+/o4/0rIEQ6Sc6vmrvAQAYXguuAP9mDPpVxsmIClMDjvkiJVOQOw8L8i 11xhewUhTM7eUFZ3UrZSDgTa2T2WpwDe76GSA2f/RaUvdOX0tia69AV6XFhTzb4T505Z ijVMeglW8xN4fb14PSmOGVGno7x37PSeJOc3O1SWBgE5d4I+xNkuRWuaRVHhCc5XTKMh cS2WO+8uhZ3DGy+e7HEONBbWF8IsqzMFgIDVgsLnbhva8UfQGDNpWwr5zQscyyJXqzvo 0mRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709736056; x=1710340856; 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=7HiJVoF4HTxTyfZqmxfdNDwSSt/1/19ukV8tNZkwTQ4=; b=t4dtUWuW1VMqH6cC00mUdggi8BeY0KZW/cSely9mWg9xT4kk5a/j5t8LugDu0fWpxq MOghM3bDKN6+T+ZJtPFvsOeOvn20TxEkpwhc3vLZoPHUfo6MkKyTw5mDFmsTOHbciUY5 A4Bg84H0JwEaY/m+YuB91IZmTkWqBht1aUymjGrXwYzoaRE5GFXptEcDWrJcKiBijelL TKa0yr33+JQ+umbBe7q82HpeGVqYNr9IMF4t5iULBC+cmDGkfwDJyOvU8iayjGm+WwRj 0xOMkEaFr1E24WeMHWIqKgF3ELSOcf2/N+Y0MKfIQyZ9XTfer+ThRJ4njV5DaGkbGBoA gsnw== X-Gm-Message-State: AOJu0YwDXcS8nQNa/3HYlK/I4MkTB4WD1YR2s7AGEitMsN41tZPafz2m 7yzRLeLRLmFZve5ZTPWHU3+R8gYlk/nSSIGqXTphmoWp49UgR243tX1jfHOp1aQ= X-Google-Smtp-Source: AGHT+IFN8t2VjrZaVQbbuC8QDjI8PuGZqOBDb6MkifpIbTkUR5kuiE/rtKD3pAr3dWymg64oFmUu5Q== X-Received: by 2002:adf:e84b:0:b0:33e:d0c:1ed0 with SMTP id d11-20020adfe84b000000b0033e0d0c1ed0mr10247148wrn.57.1709736056253; Wed, 06 Mar 2024 06:40:56 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Pierrick Bouvier , Richard Henderson , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Alexandre Iooss , Mahmoud Mandour Subject: [PULL 15/29] plugins: define qemu_plugin_u64 Date: Wed, 6 Mar 2024 14:40:27 +0000 Message-Id: <20240306144041.3787188-16-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240306144041.3787188-1-alex.bennee@linaro.org> References: <20240306144041.3787188-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::434; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x434.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1709736158081100006 From: Pierrick Bouvier Additionally to the scoreboard, we define a qemu_plugin_u64, which is a simple struct holding a pointer to a scoreboard, and a given offset. This allows to have a scoreboard containing structs, without having to bring offset to operate on a specific field. Since most of the plugins are simply collecting a sum of per-cpu values, qemu_plugin_u64 directly support this operation as well. All inline operations defined later will use a qemu_plugin_u64 as input. New functions: - qemu_plugin_u64_add - qemu_plugin_u64_get - qemu_plugin_u64_set - qemu_plugin_u64_sum New macros: - qemu_plugin_scoreboard_u64 - qemu_plugin_scoreboard_u64_in_struct Reviewed-by: Richard Henderson Signed-off-by: Pierrick Bouvier Message-Id: <20240304130036.124418-3-pierrick.bouvier@linaro.org> Signed-off-by: Alex Benn=C3=A9e Message-Id: <20240305121005.3528075-16-alex.bennee@linaro.org> diff --git a/include/qemu/qemu-plugin.h b/include/qemu/qemu-plugin.h index 31c468ddb2c..ebf9a645e15 100644 --- a/include/qemu/qemu-plugin.h +++ b/include/qemu/qemu-plugin.h @@ -225,6 +225,17 @@ struct qemu_plugin_insn; /** struct qemu_plugin_scoreboard - Opaque handle for a scoreboard */ struct qemu_plugin_scoreboard; =20 +/** + * typedef qemu_plugin_u64 - uint64_t member of an entry in a scoreboard + * + * This field allows to access a specific uint64_t member in one given ent= ry, + * located at a specified offset. Inline operations expect this as entry. + */ +typedef struct { + struct qemu_plugin_scoreboard *score; + size_t offset; +} qemu_plugin_u64; + /** * enum qemu_plugin_cb_flags - type of callback * @@ -784,4 +795,45 @@ QEMU_PLUGIN_API void *qemu_plugin_scoreboard_find(struct qemu_plugin_scoreboard *score, unsigned int vcpu_index); =20 +/* Macros to define a qemu_plugin_u64 */ +#define qemu_plugin_scoreboard_u64(score) \ + (qemu_plugin_u64) {score, 0} +#define qemu_plugin_scoreboard_u64_in_struct(score, type, member) \ + (qemu_plugin_u64) {score, offsetof(type, member)} + +/** + * qemu_plugin_u64_add() - add a value to a qemu_plugin_u64 for a given vc= pu + * @entry: entry to query + * @vcpu_index: entry index + * @added: value to add + */ +QEMU_PLUGIN_API +void qemu_plugin_u64_add(qemu_plugin_u64 entry, unsigned int vcpu_index, + uint64_t added); + +/** + * qemu_plugin_u64_get() - get value of a qemu_plugin_u64 for a given vcpu + * @entry: entry to query + * @vcpu_index: entry index + */ +QEMU_PLUGIN_API +uint64_t qemu_plugin_u64_get(qemu_plugin_u64 entry, unsigned int vcpu_inde= x); + +/** + * qemu_plugin_u64_set() - set value of a qemu_plugin_u64 for a given vcpu + * @entry: entry to query + * @vcpu_index: entry index + * @val: new value + */ +QEMU_PLUGIN_API +void qemu_plugin_u64_set(qemu_plugin_u64 entry, unsigned int vcpu_index, + uint64_t val); + +/** + * qemu_plugin_u64_sum() - return sum of all vcpu entries in a scoreboard + * @entry: entry to sum + */ +QEMU_PLUGIN_API +uint64_t qemu_plugin_u64_sum(qemu_plugin_u64 entry); + #endif /* QEMU_QEMU_PLUGIN_H */ diff --git a/plugins/api.c b/plugins/api.c index 76b2e652b9c..8910cbb2c46 100644 --- a/plugins/api.c +++ b/plugins/api.c @@ -484,3 +484,37 @@ void *qemu_plugin_scoreboard_find(struct qemu_plugin_s= coreboard *score, char *base_ptr =3D score->data->data; return base_ptr + vcpu_index * g_array_get_element_size(score->data); } + +static uint64_t *plugin_u64_address(qemu_plugin_u64 entry, + unsigned int vcpu_index) +{ + char *ptr =3D qemu_plugin_scoreboard_find(entry.score, vcpu_index); + return (uint64_t *)(ptr + entry.offset); +} + +void qemu_plugin_u64_add(qemu_plugin_u64 entry, unsigned int vcpu_index, + uint64_t added) +{ + *plugin_u64_address(entry, vcpu_index) +=3D added; +} + +uint64_t qemu_plugin_u64_get(qemu_plugin_u64 entry, + unsigned int vcpu_index) +{ + return *plugin_u64_address(entry, vcpu_index); +} + +void qemu_plugin_u64_set(qemu_plugin_u64 entry, unsigned int vcpu_index, + uint64_t val) +{ + *plugin_u64_address(entry, vcpu_index) =3D val; +} + +uint64_t qemu_plugin_u64_sum(qemu_plugin_u64 entry) +{ + uint64_t total =3D 0; + for (int i =3D 0, n =3D qemu_plugin_num_vcpus(); i < n; ++i) { + total +=3D qemu_plugin_u64_get(entry, i); + } + return total; +} diff --git a/plugins/qemu-plugins.symbols b/plugins/qemu-plugins.symbols index 3f93e7d6b13..6204453d0fd 100644 --- a/plugins/qemu-plugins.symbols +++ b/plugins/qemu-plugins.symbols @@ -44,6 +44,10 @@ qemu_plugin_tb_get_insn; qemu_plugin_tb_n_insns; qemu_plugin_tb_vaddr; + qemu_plugin_u64_add; + qemu_plugin_u64_get; + qemu_plugin_u64_set; + qemu_plugin_u64_sum; qemu_plugin_uninstall; qemu_plugin_vcpu_for_each; }; --=20 2.39.2 From nobody Tue Nov 26 06:56:45 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1709736094; cv=none; d=zohomail.com; s=zohoarc; b=L32cX2SBb00xn0ATVAla5H4Xu3GjgmzJr4I4mkeNGlKDdkwCwPEPuiYK/O5YqVjIJkNqQM6NCaKplypA0Fpqq9j5ie+6uuzyw4J7EpQ4slgsR8rB0liLWoevQMTGyca9VY6nUhmq6HfNYUyxLC5OIp4nHlWzWbYpsWGmPUxDKYI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709736094; 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=u7+jt6o7kz3/aqRrKxY2ocgaFJKGCRn1g3WUam5fQ0Y=; b=mBP5cmYz/8mWBErius6LqNsLpH6DomdqMCY9ZDSEv5o9vSKu//S6EXX2zSjPW05FVuc0hU0cceRpq2edPup9wcOjcyFQDEm8AvyXSVwmyjxcH3+D3oAZ0e5ENwZSnvzV6omUwMjiSzHiMPsXTSjzCQhd7lUNUISIFk1IjSKm3Os= 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 1709736094391792.6650173621695; Wed, 6 Mar 2024 06:41:34 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rhsS9-0007k4-G7; Wed, 06 Mar 2024 09:41:05 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rhsS6-0007W4-Jc for qemu-devel@nongnu.org; Wed, 06 Mar 2024 09:41:02 -0500 Received: from mail-wm1-x330.google.com ([2a00:1450:4864:20::330]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rhsRz-0001UR-HF for qemu-devel@nongnu.org; Wed, 06 Mar 2024 09:41:02 -0500 Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-412f1fc5613so8572795e9.2 for ; Wed, 06 Mar 2024 06:40:55 -0800 (PST) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id a14-20020a05600c348e00b00412f74d25b6sm1772674wmq.39.2024.03.06.06.40.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Mar 2024 06:40:52 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 1BC495F9DE; Wed, 6 Mar 2024 14:40:43 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1709736054; x=1710340854; 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=u7+jt6o7kz3/aqRrKxY2ocgaFJKGCRn1g3WUam5fQ0Y=; b=vGceSL6h/1qkl72t5S9OGzPwU76taEmq21CWH0O9s3ptfXNX+HKXr3tfx1A0R8ysBs gsJTUztOQCnNKL8AKkJAIEM+5zK2Aa4WgEvH7t8VbD/UBlujzA3h1fpQhvZuUiKq71gE Eur5+OoDlmm67Xuy0KKNXiOzk/Y/gRiN7VpdYQ+IDAJY7JZpHkQ8RvRhJFatVKRD8ffd BMlpeW2zx/+PN9QXVa9P/RacsgjXeGQgZP8C8PQMBL0CWT/7tvVBO1RsqG8S0n8+y4UK aoaBnkWNyORaRWtbSqjY0HjomJacwYem0t8u+czhUgu67WF5KD1qKzexW46xkzC7pGL6 xIKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709736054; x=1710340854; 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=u7+jt6o7kz3/aqRrKxY2ocgaFJKGCRn1g3WUam5fQ0Y=; b=UdFb99Op+0C5kBCuyyGSp/JzSuf35ODVbn2sAJitMHjYHLWoJIVrGJiqFPhZFDlFL6 BaO/7suVQTUMUczzB1tHcGH/DpNsZU3oRXD+LMdc5Pd3goblJQNbsj4KA8PEDyv9DCK+ qjtchGXJg3WkV26e8WQEiBT6Bnj4gbWzq5pAxFVAW8PGaZvwEFYjdLXmgtsqaxHZ9wr9 s+EPki+/qLId/EXHfGnxdnYlXkq6IjvSAAx0yhoUihYLtGMZ4F7ZZVC/iD6RMufzozbN 0ONw/TtTlq72zLngFm7K1nC23xRlBaHe6lZ+67BZ+hCEuSDqAR9cMscoEsyawm59UntZ KRFg== X-Gm-Message-State: AOJu0Yw/Ia6Xv0YI9sqfhQ7L/t9EBk8OYMf2OW73yDfXYKnZVEqSDlnL 8hHYh6Mn1fR0CT3c1XzobC5ynsAIy+bH0qd7ZXfaiLVptD1tBqBl0gWPoTBxc2M= X-Google-Smtp-Source: AGHT+IHKIQuxhqwm86v1aQJqUi+mDo0urmvXGYrxz1sUrw3l8GURDrPe5QWPzjmhkXw4SheFRwvLgw== X-Received: by 2002:a05:600c:4691:b0:411:fe7d:ac4 with SMTP id p17-20020a05600c469100b00411fe7d0ac4mr11264724wmo.24.1709736054084; Wed, 06 Mar 2024 06:40:54 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Pierrick Bouvier , Richard Henderson , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Paolo Bonzini , Alexandre Iooss , Mahmoud Mandour Subject: [PULL 16/29] plugins: implement inline operation relative to cpu_index Date: Wed, 6 Mar 2024 14:40:28 +0000 Message-Id: <20240306144041.3787188-17-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240306144041.3787188-1-alex.bennee@linaro.org> References: <20240306144041.3787188-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::330; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x330.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=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: 1709736095701100007 From: Pierrick Bouvier Instead of working on a fixed memory location, allow to address it based on cpu_index, an element size and a given offset. Result address: ptr + offset + cpu_index * element_size. With this, we can target a member in a struct array from a base pointer. Current semantic is not modified, thus inline operation still targets always the same memory location. Reviewed-by: Richard Henderson Signed-off-by: Pierrick Bouvier Message-Id: <20240304130036.124418-4-pierrick.bouvier@linaro.org> Signed-off-by: Alex Benn=C3=A9e Message-Id: <20240305121005.3528075-17-alex.bennee@linaro.org> diff --git a/plugins/plugin.h b/plugins/plugin.h index 043c740067d..3bf1aaf5c2d 100644 --- a/plugins/plugin.h +++ b/plugins/plugin.h @@ -99,7 +99,7 @@ void plugin_register_vcpu_mem_cb(GArray **arr, enum qemu_plugin_mem_rw rw, void *udata); =20 -void exec_inline_op(struct qemu_plugin_dyn_cb *cb); +void exec_inline_op(struct qemu_plugin_dyn_cb *cb, int cpu_index); =20 int plugin_num_vcpus(void); =20 diff --git a/accel/tcg/plugin-gen.c b/accel/tcg/plugin-gen.c index ac6b52b9ec9..0f8be53d394 100644 --- a/accel/tcg/plugin-gen.c +++ b/accel/tcg/plugin-gen.c @@ -133,16 +133,28 @@ static void gen_empty_udata_cb_no_rwg(void) */ static void gen_empty_inline_cb(void) { + TCGv_i32 cpu_index =3D tcg_temp_ebb_new_i32(); + TCGv_ptr cpu_index_as_ptr =3D tcg_temp_ebb_new_ptr(); TCGv_i64 val =3D tcg_temp_ebb_new_i64(); TCGv_ptr ptr =3D tcg_temp_ebb_new_ptr(); =20 + tcg_gen_ld_i32(cpu_index, tcg_env, + -offsetof(ArchCPU, env) + offsetof(CPUState, cpu_index)= ); + /* second operand will be replaced by immediate value */ + tcg_gen_mul_i32(cpu_index, cpu_index, cpu_index); + tcg_gen_ext_i32_ptr(cpu_index_as_ptr, cpu_index); + tcg_gen_movi_ptr(ptr, 0); + tcg_gen_add_ptr(ptr, ptr, cpu_index_as_ptr); tcg_gen_ld_i64(val, ptr, 0); - /* pass an immediate !=3D 0 so that it doesn't get optimized away */ - tcg_gen_addi_i64(val, val, 0xdeadface); + /* second operand will be replaced by immediate value */ + tcg_gen_add_i64(val, val, val); + tcg_gen_st_i64(val, ptr, 0); tcg_temp_free_ptr(ptr); tcg_temp_free_i64(val); + tcg_temp_free_ptr(cpu_index_as_ptr); + tcg_temp_free_i32(cpu_index); } =20 static void gen_empty_mem_cb(TCGv_i64 addr, uint32_t info) @@ -290,12 +302,37 @@ static TCGOp *copy_const_ptr(TCGOp **begin_op, TCGOp = *op, void *ptr) return op; } =20 +static TCGOp *copy_ld_i32(TCGOp **begin_op, TCGOp *op) +{ + return copy_op(begin_op, op, INDEX_op_ld_i32); +} + +static TCGOp *copy_ext_i32_ptr(TCGOp **begin_op, TCGOp *op) +{ + if (UINTPTR_MAX =3D=3D UINT32_MAX) { + op =3D copy_op(begin_op, op, INDEX_op_mov_i32); + } else { + op =3D copy_op(begin_op, op, INDEX_op_ext_i32_i64); + } + return op; +} + +static TCGOp *copy_add_ptr(TCGOp **begin_op, TCGOp *op) +{ + if (UINTPTR_MAX =3D=3D UINT32_MAX) { + op =3D copy_op(begin_op, op, INDEX_op_add_i32); + } else { + op =3D copy_op(begin_op, op, INDEX_op_add_i64); + } + return op; +} + static TCGOp *copy_ld_i64(TCGOp **begin_op, TCGOp *op) { if (TCG_TARGET_REG_BITS =3D=3D 32) { /* 2x ld_i32 */ - op =3D copy_op(begin_op, op, INDEX_op_ld_i32); - op =3D copy_op(begin_op, op, INDEX_op_ld_i32); + op =3D copy_ld_i32(begin_op, op); + op =3D copy_ld_i32(begin_op, op); } else { /* ld_i64 */ op =3D copy_op(begin_op, op, INDEX_op_ld_i64); @@ -331,6 +368,13 @@ static TCGOp *copy_add_i64(TCGOp **begin_op, TCGOp *op= , uint64_t v) return op; } =20 +static TCGOp *copy_mul_i32(TCGOp **begin_op, TCGOp *op, uint32_t v) +{ + op =3D copy_op(begin_op, op, INDEX_op_mul_i32); + op->args[2] =3D tcgv_i32_arg(tcg_constant_i32(v)); + return op; +} + static TCGOp *copy_st_ptr(TCGOp **begin_op, TCGOp *op) { if (UINTPTR_MAX =3D=3D UINT32_MAX) { @@ -396,18 +440,17 @@ static TCGOp *append_inline_cb(const struct qemu_plug= in_dyn_cb *cb, TCGOp *begin_op, TCGOp *op, int *unused) { - /* const_ptr */ - op =3D copy_const_ptr(&begin_op, op, cb->userp); - - /* ld_i64 */ + char *ptr =3D cb->userp; + size_t elem_size =3D 0; + size_t offset =3D 0; + op =3D copy_ld_i32(&begin_op, op); + op =3D copy_mul_i32(&begin_op, op, elem_size); + op =3D copy_ext_i32_ptr(&begin_op, op); + op =3D copy_const_ptr(&begin_op, op, ptr + offset); + op =3D copy_add_ptr(&begin_op, op); op =3D copy_ld_i64(&begin_op, op); - - /* add_i64 */ op =3D copy_add_i64(&begin_op, op, cb->inline_insn.imm); - - /* st_i64 */ op =3D copy_st_i64(&begin_op, op); - return op; } =20 diff --git a/plugins/api.c b/plugins/api.c index 8910cbb2c46..fa1daee8254 100644 --- a/plugins/api.c +++ b/plugins/api.c @@ -106,7 +106,8 @@ void qemu_plugin_register_vcpu_tb_exec_inline(struct qe= mu_plugin_tb *tb, void *ptr, uint64_t imm) { if (!tb->mem_only) { - plugin_register_inline_op(&tb->cbs[PLUGIN_CB_INLINE], 0, op, ptr, = imm); + plugin_register_inline_op(&tb->cbs[PLUGIN_CB_INLINE], + 0, op, ptr, imm); } } =20 diff --git a/plugins/core.c b/plugins/core.c index 63f4c6c6ce3..65d5611f797 100644 --- a/plugins/core.c +++ b/plugins/core.c @@ -318,7 +318,8 @@ static struct qemu_plugin_dyn_cb *plugin_get_dyn_cb(GAr= ray **arr) =20 void plugin_register_inline_op(GArray **arr, enum qemu_plugin_mem_rw rw, - enum qemu_plugin_op op, void *ptr, + enum qemu_plugin_op op, + void *ptr, uint64_t imm) { struct qemu_plugin_dyn_cb *dyn_cb; @@ -474,9 +475,12 @@ void qemu_plugin_flush_cb(void) plugin_cb__simple(QEMU_PLUGIN_EV_FLUSH); } =20 -void exec_inline_op(struct qemu_plugin_dyn_cb *cb) +void exec_inline_op(struct qemu_plugin_dyn_cb *cb, int cpu_index) { - uint64_t *val =3D cb->userp; + char *ptr =3D cb->userp; + size_t elem_size =3D 0; + size_t offset =3D 0; + uint64_t *val =3D (uint64_t *)(ptr + offset + cpu_index * elem_size); =20 switch (cb->inline_insn.op) { case QEMU_PLUGIN_INLINE_ADD_U64: @@ -509,7 +513,7 @@ void qemu_plugin_vcpu_mem_cb(CPUState *cpu, uint64_t va= ddr, vaddr, cb->userp); break; case PLUGIN_CB_INLINE: - exec_inline_op(cb); + exec_inline_op(cb, cpu->cpu_index); break; default: g_assert_not_reached(); --=20 2.39.2 From nobody Tue Nov 26 06:56:45 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1709736412; cv=none; d=zohomail.com; s=zohoarc; b=Geb9Akhy3j5XKBjrNIGAl1GcMo7DaoqT80UXJLHLl1QVGTt4/H378Q2jMbVb9osnwrKFG8qo7GFaSg212SH7jJ6R7ZIAstzewqnB4xJlRJPJmkZMU5szsQKoQ+zorzhzkXUqKSzf8YAkoY2n91YGEf1LWYIrcVPcM96K/v4NnQ0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709736412; 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=XMeTxKmqp9miHhSdB4IxGhpY7umFJf1vLBReY1fQxUM=; b=gWiEib932FGEYC8maXCsempVvhtFtD//dW/lwFOKd48rEVpZ2ajmzbvJRMPs48SXObnQBvY91arUE7uNNoIFgkSromRGavR0i8DSGeMs/waZXiHLPMDXOCQ7/K1A3n5Z9S94+JD4Jopzt6WNJVTVobAYa5FrdcDFtBMHdqVZI7g= 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 1709736412072438.4830731100408; Wed, 6 Mar 2024 06:46:52 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rhsSG-00085F-9s; Wed, 06 Mar 2024 09:41:12 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rhsSA-0007md-1U for qemu-devel@nongnu.org; Wed, 06 Mar 2024 09:41:06 -0500 Received: from mail-lf1-x131.google.com ([2a00:1450:4864:20::131]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rhsS1-0001Ua-F4 for qemu-devel@nongnu.org; Wed, 06 Mar 2024 09:41:05 -0500 Received: by mail-lf1-x131.google.com with SMTP id 2adb3069b0e04-5131f3fc695so7463897e87.1 for ; Wed, 06 Mar 2024 06:40:55 -0800 (PST) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id l22-20020a05600c4f1600b004128f41a13fsm21333759wmq.38.2024.03.06.06.40.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Mar 2024 06:40:52 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 3508D5F950; Wed, 6 Mar 2024 14:40:43 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1709736054; x=1710340854; 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=XMeTxKmqp9miHhSdB4IxGhpY7umFJf1vLBReY1fQxUM=; b=kMyfrYYkG5K8fLslQboPg4v3M+vOJ4tmrZoO3qdSVXYe2iCdAYOqzRxGh3ZXpsUJdu CL9XU8uuOW4zfOaYEDUYi36/1NG+GsFVDui/MjTs1WQmrg2R0Rr8oVNIt55k15xCJKVw TDgLBgRbJCrMcoiUT7r0ASZnuplygiAACe0UDfJNVLN3G1EkcnrtWwcmz893RrPmvl3B kSPFNUCtAgyHAjw+XSCvJxwgIj0ubElaye/h6EwPznqFFuXnxWbOYIWmel5i9UlMKAZv 4zOgst+4xB16+CDJ4ntZ1YWEznAZfeD2G9DjdhZ6uDjHotlMhZqVAs42G2+e9XmA+7Ha 6i0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709736054; x=1710340854; 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=XMeTxKmqp9miHhSdB4IxGhpY7umFJf1vLBReY1fQxUM=; b=YqWeT+6PzkaxBfIJYhBa9Sao1tHKcGOc1Wdpoqo4dZEnlPxmCAKLMjIKuOUoSwZ9sm YOFmEIkI8WLywwDeCRiXgJpw7Fpm8zF0al1J0+hAYLZQFcAOOBI2dcTeYfpC+ZnayrKL mqqxv5ZI/JmAtNuaMfNq+N7WZnx9c7lju+Ty6mhetrEdLC8YvJhoFoyoApf6wXhjCx1v lN4ZTPTR3dq3NOw7hkCzc4KFXIEkqCtrlllarHz0zHKnj+NbQvkEcLE+iMgbeyhyIQEx jmAAdUDe9y4cbU7Lm58a4D3gMySExErvzaOr8eTPgevBObWkUuUtRxSzHHBUe3NsW+4r 3vEg== X-Gm-Message-State: AOJu0YxBHwpv+1RXQ2WQJa5rqdrFFR7QFdQl+UQ2L6/3YYt98+bGDrYZ hPzCNN1EcN3lnd9r3E4dbKqAdPZ8mzz4pcFL1o83G0hv5upMgCsrpA43qUqTwPY= X-Google-Smtp-Source: AGHT+IH88djfTsQukZHQem79l5uPWMDDHR+GeWvB8mjr1ZWXOorxAaknPq70G6GCY6F5MJGvaGFGSg== X-Received: by 2002:a05:6512:3ee:b0:513:593e:12c3 with SMTP id n14-20020a05651203ee00b00513593e12c3mr2101098lfq.50.1709736054316; Wed, 06 Mar 2024 06:40:54 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Pierrick Bouvier , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Richard Henderson , Paolo Bonzini , Alexandre Iooss , Mahmoud Mandour Subject: [PULL 17/29] plugins: add inline operation per vcpu Date: Wed, 6 Mar 2024 14:40:29 +0000 Message-Id: <20240306144041.3787188-18-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240306144041.3787188-1-alex.bennee@linaro.org> References: <20240306144041.3787188-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::131; envelope-from=alex.bennee@linaro.org; helo=mail-lf1-x131.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1709736413256100001 From: Pierrick Bouvier Extends API with three new functions: qemu_plugin_register_vcpu_{tb, insn, mem}_exec_inline_per_vcpu(). Those functions takes a qemu_plugin_u64 as input. This allows to have a thread-safe and type-safe version of inline operations. Reviewed-by: Alex Benn=C3=A9e Reviewed-by: Richard Henderson Signed-off-by: Pierrick Bouvier Message-Id: <20240304130036.124418-5-pierrick.bouvier@linaro.org> Signed-off-by: Alex Benn=C3=A9e Message-Id: <20240305121005.3528075-18-alex.bennee@linaro.org> diff --git a/include/qemu/plugin.h b/include/qemu/plugin.h index bf96d2c2aa3..12a96cea2a4 100644 --- a/include/qemu/plugin.h +++ b/include/qemu/plugin.h @@ -92,6 +92,7 @@ struct qemu_plugin_dyn_cb { /* fields specific to each dyn_cb type go here */ union { struct { + qemu_plugin_u64 entry; enum qemu_plugin_op op; uint64_t imm; } inline_insn; diff --git a/include/qemu/qemu-plugin.h b/include/qemu/qemu-plugin.h index ebf9a645e15..6bbad068c01 100644 --- a/include/qemu/qemu-plugin.h +++ b/include/qemu/qemu-plugin.h @@ -328,6 +328,22 @@ void qemu_plugin_register_vcpu_tb_exec_inline(struct q= emu_plugin_tb *tb, enum qemu_plugin_op op, void *ptr, uint64_t imm); =20 +/** + * qemu_plugin_register_vcpu_tb_exec_inline_per_vcpu() - execution inline = op + * @tb: the opaque qemu_plugin_tb handle for the translation + * @op: the type of qemu_plugin_op (e.g. ADD_U64) + * @entry: entry to run op + * @imm: the op data (e.g. 1) + * + * Insert an inline op on a given scoreboard entry. + */ +QEMU_PLUGIN_API +void qemu_plugin_register_vcpu_tb_exec_inline_per_vcpu( + struct qemu_plugin_tb *tb, + enum qemu_plugin_op op, + qemu_plugin_u64 entry, + uint64_t imm); + /** * qemu_plugin_register_vcpu_insn_exec_cb() - register insn execution cb * @insn: the opaque qemu_plugin_insn handle for an instruction @@ -358,6 +374,22 @@ void qemu_plugin_register_vcpu_insn_exec_inline(struct= qemu_plugin_insn *insn, enum qemu_plugin_op op, void *ptr, uint64_t imm); =20 +/** + * qemu_plugin_register_vcpu_insn_exec_inline_per_vcpu() - insn exec inlin= e op + * @insn: the opaque qemu_plugin_insn handle for an instruction + * @op: the type of qemu_plugin_op (e.g. ADD_U64) + * @entry: entry to run op + * @imm: the op data (e.g. 1) + * + * Insert an inline op to every time an instruction executes. + */ +QEMU_PLUGIN_API +void qemu_plugin_register_vcpu_insn_exec_inline_per_vcpu( + struct qemu_plugin_insn *insn, + enum qemu_plugin_op op, + qemu_plugin_u64 entry, + uint64_t imm); + /** * qemu_plugin_tb_n_insns() - query helper for number of insns in TB * @tb: opaque handle to TB passed to callback @@ -583,7 +615,24 @@ void qemu_plugin_register_vcpu_mem_inline(struct qemu_= plugin_insn *insn, enum qemu_plugin_op op, void *pt= r, uint64_t imm); =20 - +/** + * qemu_plugin_register_vcpu_mem_inline_per_vcpu() - inline op for mem acc= ess + * @insn: handle for instruction to instrument + * @rw: apply to reads, writes or both + * @op: the op, of type qemu_plugin_op + * @entry: entry to run op + * @imm: immediate data for @op + * + * This registers a inline op every memory access generated by the + * instruction. + */ +QEMU_PLUGIN_API +void qemu_plugin_register_vcpu_mem_inline_per_vcpu( + struct qemu_plugin_insn *insn, + enum qemu_plugin_mem_rw rw, + enum qemu_plugin_op op, + qemu_plugin_u64 entry, + uint64_t imm); =20 typedef void (*qemu_plugin_vcpu_syscall_cb_t)(qemu_plugin_id_t id, unsigned int vcpu_in= dex, diff --git a/plugins/plugin.h b/plugins/plugin.h index 3bf1aaf5c2d..f6fa10a0f56 100644 --- a/plugins/plugin.h +++ b/plugins/plugin.h @@ -73,6 +73,12 @@ void plugin_register_inline_op(GArray **arr, enum qemu_plugin_op op, void *ptr, uint64_t imm); =20 +void plugin_register_inline_op_on_entry(GArray **arr, + enum qemu_plugin_mem_rw rw, + enum qemu_plugin_op op, + qemu_plugin_u64 entry, + uint64_t imm); + void plugin_reset_uninstall(qemu_plugin_id_t id, qemu_plugin_simple_cb_t cb, bool reset); diff --git a/accel/tcg/plugin-gen.c b/accel/tcg/plugin-gen.c index 0f8be53d394..47e05ec6347 100644 --- a/accel/tcg/plugin-gen.c +++ b/accel/tcg/plugin-gen.c @@ -443,6 +443,13 @@ static TCGOp *append_inline_cb(const struct qemu_plugi= n_dyn_cb *cb, char *ptr =3D cb->userp; size_t elem_size =3D 0; size_t offset =3D 0; + if (!ptr) { + /* use inline entry */ + ptr =3D cb->inline_insn.entry.score->data->data; + elem_size =3D g_array_get_element_size(cb->inline_insn.entry.score= ->data); + offset =3D cb->inline_insn.entry.offset; + } + op =3D copy_ld_i32(&begin_op, op); op =3D copy_mul_i32(&begin_op, op, elem_size); op =3D copy_ext_i32_ptr(&begin_op, op); diff --git a/plugins/api.c b/plugins/api.c index fa1daee8254..6470f1dc0f2 100644 --- a/plugins/api.c +++ b/plugins/api.c @@ -111,6 +111,18 @@ void qemu_plugin_register_vcpu_tb_exec_inline(struct q= emu_plugin_tb *tb, } } =20 +void qemu_plugin_register_vcpu_tb_exec_inline_per_vcpu( + struct qemu_plugin_tb *tb, + enum qemu_plugin_op op, + qemu_plugin_u64 entry, + uint64_t imm) +{ + if (!tb->mem_only) { + plugin_register_inline_op_on_entry( + &tb->cbs[PLUGIN_CB_INLINE], 0, op, entry, imm); + } +} + void qemu_plugin_register_vcpu_insn_exec_cb(struct qemu_plugin_insn *insn, qemu_plugin_vcpu_udata_cb_t cb, enum qemu_plugin_cb_flags flag= s, @@ -136,6 +148,18 @@ void qemu_plugin_register_vcpu_insn_exec_inline(struct= qemu_plugin_insn *insn, } } =20 +void qemu_plugin_register_vcpu_insn_exec_inline_per_vcpu( + struct qemu_plugin_insn *insn, + enum qemu_plugin_op op, + qemu_plugin_u64 entry, + uint64_t imm) +{ + if (!insn->mem_only) { + plugin_register_inline_op_on_entry( + &insn->cbs[PLUGIN_CB_INSN][PLUGIN_CB_INLINE], 0, op, entry, im= m); + } +} + =20 /* * We always plant memory instrumentation because they don't finalise until @@ -148,7 +172,7 @@ void qemu_plugin_register_vcpu_mem_cb(struct qemu_plugi= n_insn *insn, void *udata) { plugin_register_vcpu_mem_cb(&insn->cbs[PLUGIN_CB_MEM][PLUGIN_CB_REGULA= R], - cb, flags, rw, udata); + cb, flags, rw, udata); } =20 void qemu_plugin_register_vcpu_mem_inline(struct qemu_plugin_insn *insn, @@ -160,6 +184,17 @@ void qemu_plugin_register_vcpu_mem_inline(struct qemu_= plugin_insn *insn, rw, op, ptr, imm); } =20 +void qemu_plugin_register_vcpu_mem_inline_per_vcpu( + struct qemu_plugin_insn *insn, + enum qemu_plugin_mem_rw rw, + enum qemu_plugin_op op, + qemu_plugin_u64 entry, + uint64_t imm) +{ + plugin_register_inline_op_on_entry( + &insn->cbs[PLUGIN_CB_MEM][PLUGIN_CB_INLINE], rw, op, entry, imm); +} + void qemu_plugin_register_vcpu_tb_trans_cb(qemu_plugin_id_t id, qemu_plugin_vcpu_tb_trans_cb_t = cb) { diff --git a/plugins/core.c b/plugins/core.c index 65d5611f797..7852590da88 100644 --- a/plugins/core.c +++ b/plugins/core.c @@ -332,6 +332,23 @@ void plugin_register_inline_op(GArray **arr, dyn_cb->inline_insn.imm =3D imm; } =20 +void plugin_register_inline_op_on_entry(GArray **arr, + enum qemu_plugin_mem_rw rw, + enum qemu_plugin_op op, + qemu_plugin_u64 entry, + uint64_t imm) +{ + struct qemu_plugin_dyn_cb *dyn_cb; + + dyn_cb =3D plugin_get_dyn_cb(arr); + dyn_cb->userp =3D NULL; + dyn_cb->type =3D PLUGIN_CB_INLINE; + dyn_cb->rw =3D rw; + dyn_cb->inline_insn.entry =3D entry; + dyn_cb->inline_insn.op =3D op; + dyn_cb->inline_insn.imm =3D imm; +} + void plugin_register_dyn_cb__udata(GArray **arr, qemu_plugin_vcpu_udata_cb_t cb, enum qemu_plugin_cb_flags flags, @@ -480,6 +497,12 @@ void exec_inline_op(struct qemu_plugin_dyn_cb *cb, int= cpu_index) char *ptr =3D cb->userp; size_t elem_size =3D 0; size_t offset =3D 0; + if (!ptr) { + /* use inline entry */ + ptr =3D cb->inline_insn.entry.score->data->data; + elem_size =3D g_array_get_element_size(cb->inline_insn.entry.score= ->data); + offset =3D cb->inline_insn.entry.offset; + } uint64_t *val =3D (uint64_t *)(ptr + offset + cpu_index * elem_size); =20 switch (cb->inline_insn.op) { diff --git a/plugins/qemu-plugins.symbols b/plugins/qemu-plugins.symbols index 6204453d0fd..0d8141b85f1 100644 --- a/plugins/qemu-plugins.symbols +++ b/plugins/qemu-plugins.symbols @@ -28,13 +28,16 @@ qemu_plugin_register_vcpu_init_cb; qemu_plugin_register_vcpu_insn_exec_cb; qemu_plugin_register_vcpu_insn_exec_inline; + qemu_plugin_register_vcpu_insn_exec_inline_per_vcpu; qemu_plugin_register_vcpu_mem_cb; qemu_plugin_register_vcpu_mem_inline; + qemu_plugin_register_vcpu_mem_inline_per_vcpu; qemu_plugin_register_vcpu_resume_cb; qemu_plugin_register_vcpu_syscall_cb; qemu_plugin_register_vcpu_syscall_ret_cb; qemu_plugin_register_vcpu_tb_exec_cb; qemu_plugin_register_vcpu_tb_exec_inline; + qemu_plugin_register_vcpu_tb_exec_inline_per_vcpu; qemu_plugin_register_vcpu_tb_trans_cb; qemu_plugin_reset; qemu_plugin_scoreboard_free; --=20 2.39.2 From nobody Tue Nov 26 06:56:45 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1709736156; cv=none; d=zohomail.com; s=zohoarc; b=C9ztgXhlbUiMqi4eLIPwnNFRG3ooXDPPPx5Jf9/as/+3ghkg0uS0Favp1mERNVocVA8/zEHLwS1Dg2bSOApv7SmGIUsSdfg+JJ+8rYiNc8oRg0qy0kxPbBuP0hV9cFfAtPkDJJ9GUUUPY+fdvnkhg+gv075B1/LyiQxhhgErHFI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709736156; 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=cykYmUUqLXf57xKlQNA5GjOZ/DljTkuQISY2DO6GRAY=; b=TASc8i0/8NrrsOGqrx8QVv8B6WNKdhur1ZK7unte5Fy2YPm7cvqOV2GbfpTen1wkCGMDMtgn5Y4nzq5cBcKLPNnuO2AMxZzVb68du0VapaqGlJvNFAuvkFfDWSTyiCALfuyMXdtF2pkYwcFxs/xyJzK68zSgbVD6rESbgvDxsKE= 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 1709736156625811.1982290094928; Wed, 6 Mar 2024 06:42:36 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rhsSC-0007tN-Dn; Wed, 06 Mar 2024 09:41:08 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rhsSA-0007ml-2X for qemu-devel@nongnu.org; Wed, 06 Mar 2024 09:41:06 -0500 Received: from mail-wm1-x32d.google.com ([2a00:1450:4864:20::32d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rhsS2-0001V0-6S for qemu-devel@nongnu.org; Wed, 06 Mar 2024 09:41:05 -0500 Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-412fe981ef1so2085815e9.1 for ; Wed, 06 Mar 2024 06:40:57 -0800 (PST) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id e20-20020a05600c4e5400b00412f679bae1sm1989571wmq.26.2024.03.06.06.40.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Mar 2024 06:40:52 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 48E5B5F9DF; Wed, 6 Mar 2024 14:40:43 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1709736056; x=1710340856; 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=cykYmUUqLXf57xKlQNA5GjOZ/DljTkuQISY2DO6GRAY=; b=dOVRuAo5QVftcDBCwRtJQ9lEpvDTmEYeLDTPWM8F8h+rwpkj8WSay8nMCHRMld6eOB QFVfv5jBt3NkqCkFjS9hQ3Gu5hZqdoR+z0lq159Q0Jz625C6+aLprYY9uGbDfqSwkAaa hXKhjyrDTgGmHR3+4Nno0IU+P9Z86sC/ATVpLgdsrSnYs/BOaswvYEMetZrfiRBs33Yf 1h2+DfIsD/PKFHmWz3WwMKhnOnkQkZdJipAhVfqKkXRwiQHZY2oPVhrTk3PfDvF0lNOJ gAiBjzgPQ7QMpBtzMlEhUqdpXM9ZWVUAGzI6Qc3A7VCg8xc/REMyN3U8wN0f/+1tgjbo Pmfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709736056; x=1710340856; 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=cykYmUUqLXf57xKlQNA5GjOZ/DljTkuQISY2DO6GRAY=; b=M/j95pSKgI5Q6j+LgMr8Qcd8q6bOLRSIv5YrCP1kxsHKTXzyy1fN1WpmiRItaPMdoH kYFNqDD423t+0hlwv8ktZ2PVW0FplqsMO9z/NX7+1atRHX/3uvK0bfAKU+uyqz3nQ0iU udqdKNma6qo6eKJi+GocHLIKmjgtjS6uh+U2LeuOegHJ8RQWDciwQacg5IYwraA8IqB7 AQrmmfmpbrE53DpG4GKf6GqeeqBcGQOYHfYYIk+gIKBGw+6QXGHiTn8TKJqy/W4zSHb7 Cbi/KT4hdtukk7tMKK2Iqo9pRjRhpJDW00wtOgTLFiDeWgXezIeNlwOlouEK2O2l6v/W 7ivg== X-Gm-Message-State: AOJu0Yxh6s70272k4s212379KOTilTuaQ/7l3XSJwOa7QLX0P7b9oyNa LtYkfj/Ue1VaGYOzSJaUAEEYX+euzqr9Cl9ypkH1iZI1HLdpio+MJKJDQAvrrNA= X-Google-Smtp-Source: AGHT+IEeUr2nl4U/OMnLefXY8CLDjGE18xK4u7zW/1RaA/llVUs98vRXubxzKbIIhY7OA7z3wzhacA== X-Received: by 2002:a05:600c:5387:b0:412:f05a:9fb3 with SMTP id hg7-20020a05600c538700b00412f05a9fb3mr3453394wmb.9.1709736056470; Wed, 06 Mar 2024 06:40:56 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Pierrick Bouvier , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Alexandre Iooss , Mahmoud Mandour Subject: [PULL 18/29] tests/plugin: add test plugin for inline operations Date: Wed, 6 Mar 2024 14:40:30 +0000 Message-Id: <20240306144041.3787188-19-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240306144041.3787188-1-alex.bennee@linaro.org> References: <20240306144041.3787188-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32d; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x32d.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1709736158069100005 From: Pierrick Bouvier For now, it simply performs instruction, bb and mem count, and ensure that inline vs callback versions have the same result. Later, we'll extend it when new inline operations are added. Use existing plugins to test everything works is a bit cumbersome, as different events are treated in different plugins. Thus, this new one. Reviewed-by: Alex Benn=C3=A9e Signed-off-by: Pierrick Bouvier Message-Id: <20240304130036.124418-6-pierrick.bouvier@linaro.org> Signed-off-by: Alex Benn=C3=A9e Message-Id: <20240305121005.3528075-19-alex.bennee@linaro.org> diff --git a/tests/plugin/inline.c b/tests/plugin/inline.c new file mode 100644 index 00000000000..0163e9b51c5 --- /dev/null +++ b/tests/plugin/inline.c @@ -0,0 +1,186 @@ +/* + * Copyright (C) 2023, Pierrick Bouvier + * + * Demonstrates and tests usage of inline ops. + * + * License: GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ + +#include +#include +#include + +#include + +typedef struct { + uint64_t count_tb; + uint64_t count_tb_inline; + uint64_t count_insn; + uint64_t count_insn_inline; + uint64_t count_mem; + uint64_t count_mem_inline; +} CPUCount; + +static struct qemu_plugin_scoreboard *counts; +static qemu_plugin_u64 count_tb; +static qemu_plugin_u64 count_tb_inline; +static qemu_plugin_u64 count_insn; +static qemu_plugin_u64 count_insn_inline; +static qemu_plugin_u64 count_mem; +static qemu_plugin_u64 count_mem_inline; + +static uint64_t global_count_tb; +static uint64_t global_count_insn; +static uint64_t global_count_mem; +static unsigned int max_cpu_index; +static GMutex tb_lock; +static GMutex insn_lock; +static GMutex mem_lock; + +QEMU_PLUGIN_EXPORT int qemu_plugin_version =3D QEMU_PLUGIN_VERSION; + +static void stats_insn(void) +{ + const uint64_t expected =3D global_count_insn; + const uint64_t per_vcpu =3D qemu_plugin_u64_sum(count_insn); + const uint64_t inl_per_vcpu =3D + qemu_plugin_u64_sum(count_insn_inline); + printf("insn: %" PRIu64 "\n", expected); + printf("insn: %" PRIu64 " (per vcpu)\n", per_vcpu); + printf("insn: %" PRIu64 " (per vcpu inline)\n", inl_per_vcpu); + g_assert(expected > 0); + g_assert(per_vcpu =3D=3D expected); + g_assert(inl_per_vcpu =3D=3D expected); +} + +static void stats_tb(void) +{ + const uint64_t expected =3D global_count_tb; + const uint64_t per_vcpu =3D qemu_plugin_u64_sum(count_tb); + const uint64_t inl_per_vcpu =3D + qemu_plugin_u64_sum(count_tb_inline); + printf("tb: %" PRIu64 "\n", expected); + printf("tb: %" PRIu64 " (per vcpu)\n", per_vcpu); + printf("tb: %" PRIu64 " (per vcpu inline)\n", inl_per_vcpu); + g_assert(expected > 0); + g_assert(per_vcpu =3D=3D expected); + g_assert(inl_per_vcpu =3D=3D expected); +} + +static void stats_mem(void) +{ + const uint64_t expected =3D global_count_mem; + const uint64_t per_vcpu =3D qemu_plugin_u64_sum(count_mem); + const uint64_t inl_per_vcpu =3D + qemu_plugin_u64_sum(count_mem_inline); + printf("mem: %" PRIu64 "\n", expected); + printf("mem: %" PRIu64 " (per vcpu)\n", per_vcpu); + printf("mem: %" PRIu64 " (per vcpu inline)\n", inl_per_vcpu); + g_assert(expected > 0); + g_assert(per_vcpu =3D=3D expected); + g_assert(inl_per_vcpu =3D=3D expected); +} + +static void plugin_exit(qemu_plugin_id_t id, void *udata) +{ + const unsigned int num_cpus =3D qemu_plugin_num_vcpus(); + g_assert(num_cpus =3D=3D max_cpu_index + 1); + + for (int i =3D 0; i < num_cpus ; ++i) { + const uint64_t tb =3D qemu_plugin_u64_get(count_tb, i); + const uint64_t tb_inline =3D qemu_plugin_u64_get(count_tb_inline, = i); + const uint64_t insn =3D qemu_plugin_u64_get(count_insn, i); + const uint64_t insn_inline =3D qemu_plugin_u64_get(count_insn_inli= ne, i); + const uint64_t mem =3D qemu_plugin_u64_get(count_mem, i); + const uint64_t mem_inline =3D qemu_plugin_u64_get(count_mem_inline= , i); + printf("cpu %d: tb (%" PRIu64 ", %" PRIu64 ") | " + "insn (%" PRIu64 ", %" PRIu64 ") | " + "mem (%" PRIu64 ", %" PRIu64 ")" + "\n", + i, tb, tb_inline, insn, insn_inline, mem, mem_inline); + g_assert(tb =3D=3D tb_inline); + g_assert(insn =3D=3D insn_inline); + g_assert(mem =3D=3D mem_inline); + } + + stats_tb(); + stats_insn(); + stats_mem(); + + qemu_plugin_scoreboard_free(counts); +} + +static void vcpu_tb_exec(unsigned int cpu_index, void *udata) +{ + qemu_plugin_u64_add(count_tb, cpu_index, 1); + g_mutex_lock(&tb_lock); + max_cpu_index =3D MAX(max_cpu_index, cpu_index); + global_count_tb++; + g_mutex_unlock(&tb_lock); +} + +static void vcpu_insn_exec(unsigned int cpu_index, void *udata) +{ + qemu_plugin_u64_add(count_insn, cpu_index, 1); + g_mutex_lock(&insn_lock); + global_count_insn++; + g_mutex_unlock(&insn_lock); +} + +static void vcpu_mem_access(unsigned int cpu_index, + qemu_plugin_meminfo_t info, + uint64_t vaddr, + void *userdata) +{ + qemu_plugin_u64_add(count_mem, cpu_index, 1); + g_mutex_lock(&mem_lock); + global_count_mem++; + g_mutex_unlock(&mem_lock); +} + +static void vcpu_tb_trans(qemu_plugin_id_t id, struct qemu_plugin_tb *tb) +{ + qemu_plugin_register_vcpu_tb_exec_cb( + tb, vcpu_tb_exec, QEMU_PLUGIN_CB_NO_REGS, 0); + qemu_plugin_register_vcpu_tb_exec_inline_per_vcpu( + tb, QEMU_PLUGIN_INLINE_ADD_U64, count_tb_inline, 1); + + for (int idx =3D 0; idx < qemu_plugin_tb_n_insns(tb); ++idx) { + struct qemu_plugin_insn *insn =3D qemu_plugin_tb_get_insn(tb, idx); + qemu_plugin_register_vcpu_insn_exec_cb( + insn, vcpu_insn_exec, QEMU_PLUGIN_CB_NO_REGS, 0); + qemu_plugin_register_vcpu_insn_exec_inline_per_vcpu( + insn, QEMU_PLUGIN_INLINE_ADD_U64, count_insn_inline, 1); + qemu_plugin_register_vcpu_mem_cb(insn, &vcpu_mem_access, + QEMU_PLUGIN_CB_NO_REGS, + QEMU_PLUGIN_MEM_RW, 0); + qemu_plugin_register_vcpu_mem_inline_per_vcpu( + insn, QEMU_PLUGIN_MEM_RW, + QEMU_PLUGIN_INLINE_ADD_U64, + count_mem_inline, 1); + } +} + +QEMU_PLUGIN_EXPORT +int qemu_plugin_install(qemu_plugin_id_t id, const qemu_info_t *info, + int argc, char **argv) +{ + counts =3D qemu_plugin_scoreboard_new(sizeof(CPUCount)); + count_tb =3D qemu_plugin_scoreboard_u64_in_struct( + counts, CPUCount, count_tb); + count_insn =3D qemu_plugin_scoreboard_u64_in_struct( + counts, CPUCount, count_insn); + count_mem =3D qemu_plugin_scoreboard_u64_in_struct( + counts, CPUCount, count_mem); + count_tb_inline =3D qemu_plugin_scoreboard_u64_in_struct( + counts, CPUCount, count_tb_inline); + count_insn_inline =3D qemu_plugin_scoreboard_u64_in_struct( + counts, CPUCount, count_insn_inline); + count_mem_inline =3D qemu_plugin_scoreboard_u64_in_struct( + counts, CPUCount, count_mem_inline); + qemu_plugin_register_vcpu_tb_trans_cb(id, vcpu_tb_trans); + qemu_plugin_register_atexit_cb(id, plugin_exit, NULL); + + return 0; +} diff --git a/tests/plugin/meson.build b/tests/plugin/meson.build index e18183aaeda..9eece5bab51 100644 --- a/tests/plugin/meson.build +++ b/tests/plugin/meson.build @@ -1,6 +1,6 @@ t =3D [] if get_option('plugins') - foreach i : ['bb', 'empty', 'insn', 'mem', 'syscall'] + foreach i : ['bb', 'empty', 'inline', 'insn', 'mem', 'syscall'] if host_os =3D=3D 'windows' t +=3D shared_module(i, files(i + '.c') + '../../contrib/plugins/win= 32_linker.c', include_directories: '../../include/qemu', --=20 2.39.2 From nobody Tue Nov 26 06:56:45 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1709736094; cv=none; d=zohomail.com; s=zohoarc; b=fk3/pMwaj9QU2B5ouV/0HglARX0HiXhoNaPOF4rPVbYkCVsX13hriIk0aS7Ti8NM3XIlmui+58PZ+CGY0KLz2gx5Vuz0umVHrtIkR5y3tmXihOlteyYQVGhbIt6v5gcKbH2FkYPHc82XPjfiMa3D03T+n1Q8EQGNlq6NVJhI0bI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709736094; 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=WeX6qqRx0pytmE8w24sI4eHsdCeMyxlJGMKYFHwnPzA=; b=Xc1lhASjnDdZO8FRD/JE14uYe0gXZXVstP4JpmnLiM6AQu0JcpCPMyBEGUXEq5akWNzels1tbFwKfV3tIW3m4d1qHkVFgDIi0CuF6ENfwYBjzzKD2Lzj/syYO83Hdldea2wqAgsQlWG3k9yGoJn9js4Wzuotq2nIJALqVJiSJis= 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 1709736094350355.1158516783163; Wed, 6 Mar 2024 06:41:34 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rhsSF-00081X-6V; Wed, 06 Mar 2024 09:41:11 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rhsSA-0007mg-2O for qemu-devel@nongnu.org; Wed, 06 Mar 2024 09:41:06 -0500 Received: from mail-wm1-x32b.google.com ([2a00:1450:4864:20::32b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rhsS2-0001V3-DB for qemu-devel@nongnu.org; Wed, 06 Mar 2024 09:41:05 -0500 Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-412f8bf3718so3790335e9.0 for ; Wed, 06 Mar 2024 06:40:57 -0800 (PST) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id o39-20020a05600c512700b00412d60cb914sm14475022wms.5.2024.03.06.06.40.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Mar 2024 06:40:53 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 5CD1D5F9E0; Wed, 6 Mar 2024 14:40:43 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1709736057; x=1710340857; 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=WeX6qqRx0pytmE8w24sI4eHsdCeMyxlJGMKYFHwnPzA=; b=Jrl6vp6FJoF1hfOaItWg19v2bqoONNTZzRqhlV0Qgm70YZ9pUmP21i5Ibgzyu21wzm sgXdVsEvo5Aex7jcNXUUotcohsuKgGqSS08msI+z2OhrUCpVT4AxSzGVo4e38HIWB7oV C3822CCXxRMmYctOBV4ro1W+Jud4bAiW1th4GL74DGxUUCBZ4TkeaW6G/mtB9OxHw6o1 Wmowt2Jb6AXWidwTRvLaptbxUdqFuR/fSiplnMqfOw0C/b7b+AVDEm2my3KrvRtSKubO 1Bs2F78hI8mJjLtgSCjlKyNR63znSf5gsJ4FYojypI9AbZF3qgAy15lLLV8l4nH+gu/H LBQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709736057; x=1710340857; 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=WeX6qqRx0pytmE8w24sI4eHsdCeMyxlJGMKYFHwnPzA=; b=Orgfzvpgm3dKZZoClUM0oXMfFkNtW43j70Vb+NiaoYwwniQUTZag3900Pr0Emz/5xr Lh2UtqAiu3q7guaCcqCi/AjfmB1ocp+VrKU4tRzGKzAimMg74kx3qTJY059l5kw024Re 2Jl/gHf2QqRuYOKLB3F1KIyvj3kDhWkNXO206hgcn5yDoxdrlxtANYcA3EHFVPFaorsY PfTRZKqqwHuk+ehhtcRbWnt1EuzoReIL3njJvlTqnV/J741YxyU9oJTQdTuX1I06jqFH VFxIoqCS1hxsnHp9AMGB54PpG0ELfpiWroDll0MlvWML2f+9ragTTx8HjbA+4p6vBkHH jaeA== X-Gm-Message-State: AOJu0Yzm4GPVk3xBQShuRRxEWyb4J7WpABJh0oA51qEfsa9+OvPdagt+ r3xryeuNEEC9tHDHsDeNlpzSPWkbmN9VuiioQEmf/j49Vlt/VmPsqsxCXUGVGbul5bMhBSr5U5o a X-Google-Smtp-Source: AGHT+IGKjqxDyhYCDrBbE7jw8x5AzFB43vP4bKaS8fAN6f3X6A8yD93/9zXoml9lT4ckokQuBfftNQ== X-Received: by 2002:a05:600c:1c9c:b0:412:e675:f807 with SMTP id k28-20020a05600c1c9c00b00412e675f807mr5295062wms.31.1709736056647; Wed, 06 Mar 2024 06:40:56 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Pierrick Bouvier , Luc Michel , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Alexandre Iooss , Mahmoud Mandour , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PULL 19/29] tests/plugin/mem: migrate to new per_vcpu API Date: Wed, 6 Mar 2024 14:40:31 +0000 Message-Id: <20240306144041.3787188-20-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240306144041.3787188-1-alex.bennee@linaro.org> References: <20240306144041.3787188-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32b; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x32b.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1709736095627100005 From: Pierrick Bouvier Reviewed-by: Luc Michel Signed-off-by: Pierrick Bouvier Message-Id: <20240304130036.124418-7-pierrick.bouvier@linaro.org> Signed-off-by: Alex Benn=C3=A9e Message-Id: <20240305121005.3528075-20-alex.bennee@linaro.org> diff --git a/tests/plugin/mem.c b/tests/plugin/mem.c index 44e91065ba7..b650dddcce1 100644 --- a/tests/plugin/mem.c +++ b/tests/plugin/mem.c @@ -16,9 +16,14 @@ =20 QEMU_PLUGIN_EXPORT int qemu_plugin_version =3D QEMU_PLUGIN_VERSION; =20 -static uint64_t inline_mem_count; -static uint64_t cb_mem_count; -static uint64_t io_count; +typedef struct { + uint64_t mem_count; + uint64_t io_count; +} CPUCount; + +static struct qemu_plugin_scoreboard *counts; +static qemu_plugin_u64 mem_count; +static qemu_plugin_u64 io_count; static bool do_inline, do_callback; static bool do_haddr; static enum qemu_plugin_mem_rw rw =3D QEMU_PLUGIN_MEM_RW; @@ -27,16 +32,16 @@ static void plugin_exit(qemu_plugin_id_t id, void *p) { g_autoptr(GString) out =3D g_string_new(""); =20 - if (do_inline) { - g_string_printf(out, "inline mem accesses: %" PRIu64 "\n", inline_= mem_count); - } - if (do_callback) { - g_string_append_printf(out, "callback mem accesses: %" PRIu64 "\n"= , cb_mem_count); + if (do_inline || do_callback) { + g_string_printf(out, "mem accesses: %" PRIu64 "\n", + qemu_plugin_u64_sum(mem_count)); } if (do_haddr) { - g_string_append_printf(out, "io accesses: %" PRIu64 "\n", io_count= ); + g_string_append_printf(out, "io accesses: %" PRIu64 "\n", + qemu_plugin_u64_sum(io_count)); } qemu_plugin_outs(out->str); + qemu_plugin_scoreboard_free(counts); } =20 static void vcpu_mem(unsigned int cpu_index, qemu_plugin_meminfo_t meminfo, @@ -46,12 +51,12 @@ static void vcpu_mem(unsigned int cpu_index, qemu_plugi= n_meminfo_t meminfo, struct qemu_plugin_hwaddr *hwaddr; hwaddr =3D qemu_plugin_get_hwaddr(meminfo, vaddr); if (qemu_plugin_hwaddr_is_io(hwaddr)) { - io_count++; + qemu_plugin_u64_add(io_count, cpu_index, 1); } else { - cb_mem_count++; + qemu_plugin_u64_add(mem_count, cpu_index, 1); } } else { - cb_mem_count++; + qemu_plugin_u64_add(mem_count, cpu_index, 1); } } =20 @@ -64,9 +69,10 @@ static void vcpu_tb_trans(qemu_plugin_id_t id, struct qe= mu_plugin_tb *tb) struct qemu_plugin_insn *insn =3D qemu_plugin_tb_get_insn(tb, i); =20 if (do_inline) { - qemu_plugin_register_vcpu_mem_inline(insn, rw, - QEMU_PLUGIN_INLINE_ADD_U6= 4, - &inline_mem_count, 1); + qemu_plugin_register_vcpu_mem_inline_per_vcpu( + insn, rw, + QEMU_PLUGIN_INLINE_ADD_U64, + mem_count, 1); } if (do_callback) { qemu_plugin_register_vcpu_mem_cb(insn, vcpu_mem, @@ -117,6 +123,16 @@ QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin= _id_t id, } } =20 + if (do_inline && do_callback) { + fprintf(stderr, + "can't enable inline and callback counting at the same tim= e\n"); + return -1; + } + + counts =3D qemu_plugin_scoreboard_new(sizeof(CPUCount)); + mem_count =3D qemu_plugin_scoreboard_u64_in_struct( + counts, CPUCount, mem_count); + io_count =3D qemu_plugin_scoreboard_u64_in_struct(counts, CPUCount, io= _count); qemu_plugin_register_vcpu_tb_trans_cb(id, vcpu_tb_trans); qemu_plugin_register_atexit_cb(id, plugin_exit, NULL); return 0; diff --git a/tests/tcg/Makefile.target b/tests/tcg/Makefile.target index a4c25908fb7..f21be50d3b2 100644 --- a/tests/tcg/Makefile.target +++ b/tests/tcg/Makefile.target @@ -168,7 +168,7 @@ RUN_TESTS+=3D$(EXTRA_RUNS) =20 # Some plugins need additional arguments above the default to fully # exercise things. We can define them on a per-test basis here. -run-plugin-%-with-libmem.so: PLUGIN_ARGS=3D$(COMMA)inline=3Dtrue$(COMMA)ca= llback=3Dtrue +run-plugin-%-with-libmem.so: PLUGIN_ARGS=3D$(COMMA)inline=3Dtrue =20 ifeq ($(filter %-softmmu, $(TARGET)),) run-%: % --=20 2.39.2 From nobody Tue Nov 26 06:56:45 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1709736587; cv=none; d=zohomail.com; s=zohoarc; b=RksSFRzltoHU5Z/J2R/zaISsaDFAO3NxZ6x+lqvCvZibD2aMDVY89oD2phTa/eK6o9dI7cvM05gjsfDNz1eDrZfW8OC2CVoiZlDbhvvnRRMPdLdeu3GNlLgXk+lrbdw62wW9zrOpZjzVvr1u0wOit1BwBlFTBVNueUW2xIQHQrk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709736587; 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=2sGbd0lv/R8md3B/vm+P9fKxlwBCNXHR/trhpqI1z8Q=; b=bEeArO8lkzyPAHJjUBb3UvCF1sGyLT3c45ivRZ/YrsEadsj8a0KvKBOE5hcDWfAvXAbf7GHS/U4QyND3AFKHN+O5943MwLO8kT4nk9XJj3dAfD7koSvCGmNFl/ZU52mVZdDgLlksjp9k5P+tfy8TECIrf7sKY2c2cSdlFiRFcSw= 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 1709736587031157.78193010097505; Wed, 6 Mar 2024 06:49:47 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rhsZz-0006hE-I6; Wed, 06 Mar 2024 09:49:11 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rhsZv-0006eU-QZ for qemu-devel@nongnu.org; Wed, 06 Mar 2024 09:49:08 -0500 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rhsZr-0004Mv-0O for qemu-devel@nongnu.org; Wed, 06 Mar 2024 09:49:07 -0500 Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-412f62ee005so5467335e9.2 for ; Wed, 06 Mar 2024 06:49:01 -0800 (PST) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id o1-20020a05600c4fc100b00412e97127c0sm6683373wmq.24.2024.03.06.06.48.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Mar 2024 06:49:00 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 6F5975F9E2; Wed, 6 Mar 2024 14:40:43 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1709736540; x=1710341340; 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=2sGbd0lv/R8md3B/vm+P9fKxlwBCNXHR/trhpqI1z8Q=; b=vpsndotvJfyFQ8x8NoFNNS0JOLVn9C74lHBWvrtd3o2w4VFATijNNJYXFoLONW8x4E S3Wr4sYZ91j9K4i7SHKcKWmAx7yjeHF80NWWCD8ZolNQMnTJvrIcE3f6xa+6BVrGuQjl +9DZvmE/twa08TnUYXsCdN6IX1fHYlhvxCZ5UbscWA/LP90rgO1piXkScXzHpEaWK7My Ji/ltYuBUNq4SC8gf/psRijWaeMrN2Yh4f5tJaoOXKSymh5FahZjgHbIYoQV4HpchvIY PVQ9Eok8P9pd38KlUbLeVilkZz5uTgWHlsr13mafacyA6k5tcSnPVajSccA2B8IhwvGN U1tA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709736540; x=1710341340; 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=2sGbd0lv/R8md3B/vm+P9fKxlwBCNXHR/trhpqI1z8Q=; b=ILyu5Onv4CjDs6rdiYfPLuIBWzezHrf0MkV2BQ3NR+xAFQ2L+m2As7jrQxOeGZHZV5 myyj5yo2VTq+fZBd6zSMPT1OeUqgQaHq2A6VcbYHq3b3J3h4lFl4+MQKqDSYlYN4OI5s 1wmEWttD3qOFwFpqQAWdN1lH1aEXSvj+7YR/LvA9vARmHTm3lhCjmtzpeKQo88AlQWgk q8VIVQ9Fw0ED83YIFnDvc9nt7iyLPD0LuRGQB7V17VEAYmdqJT3OL+hMp95rsDmYi3g2 qPUwh8QoK5q1WqS18ZVMh69gEYKYzj0PY+akvEWtXkpirAjGrq2hLGQzu9yiOAXecd+N 225A== X-Gm-Message-State: AOJu0Yw4D1iHbHcaG7lEM3oi1BPych8g+59olc+ovk5Z5r7cOx2vZx3f QlZ6ixWrfm0JLgVaMb09YuP/cpcqMoOYnakvXUvxxgycq1NxN+BxDGuFcVYQdVs= X-Google-Smtp-Source: AGHT+IFZiIKq6k3KFoMveUdfFxyI6xavTuCSs7uPPeFHDS1SJuK3mwxO4Hmdg+vSVXPk/DeNoC3SxQ== X-Received: by 2002:a05:600c:5490:b0:412:ea93:230d with SMTP id iv16-20020a05600c549000b00412ea93230dmr4674917wmb.33.1709736540475; Wed, 06 Mar 2024 06:49:00 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Pierrick Bouvier , Luc Michel , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Alexandre Iooss , Mahmoud Mandour Subject: [PULL 20/29] tests/plugin/insn: migrate to new per_vcpu API Date: Wed, 6 Mar 2024 14:40:32 +0000 Message-Id: <20240306144041.3787188-21-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240306144041.3787188-1-alex.bennee@linaro.org> References: <20240306144041.3787188-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::334; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x334.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1709736588217100001 From: Pierrick Bouvier Reviewed-by: Luc Michel Signed-off-by: Pierrick Bouvier Message-Id: <20240304130036.124418-8-pierrick.bouvier@linaro.org> Signed-off-by: Alex Benn=C3=A9e Message-Id: <20240305121005.3528075-21-alex.bennee@linaro.org> diff --git a/tests/plugin/insn.c b/tests/plugin/insn.c index 54da06fcf26..5e0aa03223e 100644 --- a/tests/plugin/insn.c +++ b/tests/plugin/insn.c @@ -16,25 +16,21 @@ =20 QEMU_PLUGIN_EXPORT int qemu_plugin_version =3D QEMU_PLUGIN_VERSION; =20 -#define MAX_CPUS 8 /* lets not go nuts */ - -typedef struct { - uint64_t insn_count; -} InstructionCount; - -static InstructionCount counts[MAX_CPUS]; -static uint64_t inline_insn_count; +static qemu_plugin_u64 insn_count; =20 static bool do_inline; static bool do_size; static GArray *sizes; =20 +typedef struct { + uint64_t hits; + uint64_t last_hit; + uint64_t total_delta; +} MatchCount; + typedef struct { char *match_string; - uint64_t hits[MAX_CPUS]; - uint64_t last_hit[MAX_CPUS]; - uint64_t total_delta[MAX_CPUS]; - GPtrArray *history[MAX_CPUS]; + struct qemu_plugin_scoreboard *counts; /* MatchCount */ } Match; =20 static GArray *matches; @@ -67,41 +63,40 @@ static void vcpu_init(qemu_plugin_id_t id, unsigned int= vcpu_index) =20 static void vcpu_insn_exec_before(unsigned int cpu_index, void *udata) { - unsigned int i =3D cpu_index % MAX_CPUS; - InstructionCount *c =3D &counts[i]; - - c->insn_count++; + qemu_plugin_u64_add(insn_count, cpu_index, 1); } =20 static void vcpu_insn_matched_exec_before(unsigned int cpu_index, void *ud= ata) { - unsigned int i =3D cpu_index % MAX_CPUS; Instruction *insn =3D (Instruction *) udata; - Match *match =3D insn->match; + Match *insn_match =3D insn->match; + MatchCount *match =3D qemu_plugin_scoreboard_find(insn_match->counts, + cpu_index); + g_autoptr(GString) ts =3D g_string_new(""); =20 insn->hits++; g_string_append_printf(ts, "0x%" PRIx64 ", '%s', %"PRId64 " hits", insn->vaddr, insn->disas, insn->hits); =20 - uint64_t icount =3D counts[i].insn_count; - uint64_t delta =3D icount - match->last_hit[i]; + uint64_t icount =3D qemu_plugin_u64_get(insn_count, cpu_index); + uint64_t delta =3D icount - match->last_hit; =20 - match->hits[i]++; - match->total_delta[i] +=3D delta; + match->hits++; + match->total_delta +=3D delta; =20 g_string_append_printf(ts, - ", %"PRId64" match hits, " - "=CE=94+%"PRId64 " since last match," + " , cpu %u," + " %"PRId64" match hits," + " =CE=94+%"PRId64 " since last match," " %"PRId64 " avg insns/match\n", - match->hits[i], delta, - match->total_delta[i] / match->hits[i]); + cpu_index, + match->hits, delta, + match->total_delta / match->hits); =20 - match->last_hit[i] =3D icount; + match->last_hit =3D icount; =20 qemu_plugin_outs(ts->str); - - g_ptr_array_add(match->history[i], insn); } =20 static void vcpu_tb_trans(qemu_plugin_id_t id, struct qemu_plugin_tb *tb) @@ -113,8 +108,8 @@ static void vcpu_tb_trans(qemu_plugin_id_t id, struct q= emu_plugin_tb *tb) struct qemu_plugin_insn *insn =3D qemu_plugin_tb_get_insn(tb, i); =20 if (do_inline) { - qemu_plugin_register_vcpu_insn_exec_inline( - insn, QEMU_PLUGIN_INLINE_ADD_U64, &inline_insn_count, 1); + qemu_plugin_register_vcpu_insn_exec_inline_per_vcpu( + insn, QEMU_PLUGIN_INLINE_ADD_U64, insn_count, 1); } else { uint64_t vaddr =3D qemu_plugin_insn_vaddr(insn); qemu_plugin_register_vcpu_insn_exec_cb( @@ -136,10 +131,9 @@ static void vcpu_tb_trans(qemu_plugin_id_t id, struct = qemu_plugin_tb *tb) * information about the instruction which we also need to * save if there is a hit. */ - if (matches) { + if (matches->len) { char *insn_disas =3D qemu_plugin_insn_disas(insn); - int j; - for (j =3D 0; j < matches->len; j++) { + for (int j =3D 0; j < matches->len; j++) { Match *m =3D &g_array_index(matches, Match, j); if (g_str_has_prefix(insn_disas, m->match_string)) { Instruction *rec =3D g_new0(Instruction, 1); @@ -169,36 +163,33 @@ static void plugin_exit(qemu_plugin_id_t id, void *p) "len %d bytes: %ld insns\n", i, *cn= t); } } - } else if (do_inline) { - g_string_append_printf(out, "insns: %" PRIu64 "\n", inline_insn_co= unt); } else { - uint64_t total_insns =3D 0; - for (i =3D 0; i < MAX_CPUS; i++) { - InstructionCount *c =3D &counts[i]; - if (c->insn_count) { - g_string_append_printf(out, "cpu %d insns: %" PRIu64 "\n", - i, c->insn_count); - total_insns +=3D c->insn_count; - } + for (i =3D 0; i < qemu_plugin_num_vcpus(); i++) { + g_string_append_printf(out, "cpu %d insns: %" PRIu64 "\n", + i, qemu_plugin_u64_get(insn_count, i)); } g_string_append_printf(out, "total insns: %" PRIu64 "\n", - total_insns); + qemu_plugin_u64_sum(insn_count)); } qemu_plugin_outs(out->str); + + qemu_plugin_scoreboard_free(insn_count.score); + for (i =3D 0; i < matches->len; ++i) { + Match *m =3D &g_array_index(matches, Match, i); + g_free(m->match_string); + qemu_plugin_scoreboard_free(m->counts); + } + g_array_free(matches, TRUE); + g_array_free(sizes, TRUE); } =20 =20 /* Add a match to the array of matches */ static void parse_match(char *match) { - Match new_match =3D { .match_string =3D match }; - int i; - for (i =3D 0; i < MAX_CPUS; i++) { - new_match.history[i] =3D g_ptr_array_new(); - } - if (!matches) { - matches =3D g_array_new(false, true, sizeof(Match)); - } + Match new_match =3D { + .match_string =3D g_strdup(match), + .counts =3D qemu_plugin_scoreboard_new(sizeof(MatchCount)) }; g_array_append_val(matches, new_match); } =20 @@ -206,6 +197,10 @@ QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin= _id_t id, const qemu_info_t *info, int argc, char **argv) { + matches =3D g_array_new(false, true, sizeof(Match)); + /* null terminated so 0 is not a special case */ + sizes =3D g_array_new(true, true, sizeof(unsigned long)); + for (int i =3D 0; i < argc; i++) { char *opt =3D argv[i]; g_auto(GStrv) tokens =3D g_strsplit(opt, "=3D", 2); @@ -227,9 +222,8 @@ QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_= id_t id, } } =20 - if (do_size) { - sizes =3D g_array_new(true, true, sizeof(unsigned long)); - } + insn_count =3D qemu_plugin_scoreboard_u64( + qemu_plugin_scoreboard_new(sizeof(uint64_t))); =20 /* Register init, translation block and exit callbacks */ qemu_plugin_register_vcpu_init_cb(id, vcpu_init); --=20 2.39.2 From nobody Tue Nov 26 06:56:45 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1709736621; cv=none; d=zohomail.com; s=zohoarc; b=Ki9HShiRt4g11isq2LHTV1IxNb+6NTcAGUOPuh4uXOm04ZlADZr+YLf9C1t50LbfRLmMRb5gNGjc5DPtxvvB4Vb9sVuyNpHv1lhZHI6qYAP8naDGmYif6BktfLkqH0r4pigPtL3fWmrM+PEy8hLQFuv/Mjo5QZcMkpzH3b+PMZw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709736621; 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=gifdqyHFmpDZP+wxb+8YBxi+kUVbKDtu2FB/0Orwvkw=; b=EDmzltqmEizKkD3p7EFCvJIDkpOiFd21QgT4i8a5T0ySG/UlkHsOLF6dP8kxxyVDMSWvvh42GFQ6sw88ADz36edECaol7nxxMPFkU+OG6+1rA0zVRcDFmQgE4krY+8Ux6EA6L3lIzyrhZaWO+/NtpK6cLGMlTLTmdzT+aRRk/lE= 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 1709736621234242.03598824390303; Wed, 6 Mar 2024 06:50:21 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rhsZy-0006gm-9Y; Wed, 06 Mar 2024 09:49:10 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rhsZq-0006bm-Ae for qemu-devel@nongnu.org; Wed, 06 Mar 2024 09:49:04 -0500 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rhsZn-0004E8-Bi for qemu-devel@nongnu.org; Wed, 06 Mar 2024 09:49:02 -0500 Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-412e80e13abso22491725e9.3 for ; Wed, 06 Mar 2024 06:48:58 -0800 (PST) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id fk15-20020a05600c0ccf00b00412ff1acf05sm715566wmb.7.2024.03.06.06.48.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Mar 2024 06:48:57 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 819A55F9E4; Wed, 6 Mar 2024 14:40:43 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1709736537; x=1710341337; 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=gifdqyHFmpDZP+wxb+8YBxi+kUVbKDtu2FB/0Orwvkw=; b=FeMwaEDWFIEUAZ6E6GpHs0CuGQoSMT1OVozcJF2yqKPlV8BS3M9qe8dDwvgRcz59Up wVhS/2Wd9/7OaPpHRXORMMiBggZap6FjLcxzqRRCynywrXnm9SttwBc7FeHQAFcDo5JX oxNbZXSj6oz3czhr3ldvK9aX4mT6mklJCFdslxoe+iz8Ao+WOoR3eJ+UFbRBx/2hSIOF UChKfp5Myo7SgiLC41F8WZL2oT8t9ZWzF05R5aNBgTkYBqUNHNVntBanNa3YQ7XjLlGn Cn/r4pByne9tpI5ECkwBr8UVBQcsGciQbFyu+XynVkj05hQJs9OFe+rj808NSktUDAXb Z6ww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709736537; x=1710341337; 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=gifdqyHFmpDZP+wxb+8YBxi+kUVbKDtu2FB/0Orwvkw=; b=MmL9Bxn9TZHf7Uh1CbHBJIXGb2UecvCN5ttdmj/QWSx0kNd/Wax9Acvc9JkKwQY/Sa 4p6bcbPUfJVsUowZveaKOKyr4TITEvNMQbgVR+dTf0L4ZziAfgBVsKqTUyMj0223d3JH YTd7xoOeUZaPTVH391YZEN9XJmP4P7N1vBlKjQ4sW49sn+PgTPiDEImk5P5TPSg0PW56 +q9kqxpe7FpqqzZUIPe0gF82pqzfiCnIE/ZLh0+fHTvzVZDBSaURCVG0Vs7Y0v0Q0qfm tY4MqiqVnuizo27AjgePrnRWe8qIKhV/VDMURVELE0MrUzRsiMXNRNA34NbcyrZQcNJs 6lLA== X-Gm-Message-State: AOJu0YwmbbEztSyI+46SnBMhBGa5ZgpPo6zqDZ1wQMO/jSuRJ0ofsWbL bh0ABjmyCsoxJKGpj5rEuvb4+tHf5OYnpPZEoJw5DgRqyKdMZ1kP5tKY1GlhLGY= X-Google-Smtp-Source: AGHT+IFPZ2Mq6Jmn9F3p0pPkxbwTPa8cmOyFPmx0mzIeYIcBfEAQHP/E3YvZ2r8vkka0un1RkqEF6w== X-Received: by 2002:a05:600c:1da6:b0:412:e95f:51bb with SMTP id p38-20020a05600c1da600b00412e95f51bbmr4520679wms.32.1709736537548; Wed, 06 Mar 2024 06:48:57 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Pierrick Bouvier , Luc Michel , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Alexandre Iooss , Mahmoud Mandour Subject: [PULL 21/29] tests/plugin/bb: migrate to new per_vcpu API Date: Wed, 6 Mar 2024 14:40:33 +0000 Message-Id: <20240306144041.3787188-22-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240306144041.3787188-1-alex.bennee@linaro.org> References: <20240306144041.3787188-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::329; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x329.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1709736622332100001 From: Pierrick Bouvier Reviewed-by: Luc Michel Reviewed-by: Alex Benn=C3=A9e Signed-off-by: Pierrick Bouvier Message-Id: <20240304130036.124418-9-pierrick.bouvier@linaro.org> Signed-off-by: Alex Benn=C3=A9e Message-Id: <20240305121005.3528075-22-alex.bennee@linaro.org> diff --git a/tests/plugin/bb.c b/tests/plugin/bb.c index df50d1fd3bc..36776dee1e1 100644 --- a/tests/plugin/bb.c +++ b/tests/plugin/bb.c @@ -17,27 +17,25 @@ QEMU_PLUGIN_EXPORT int qemu_plugin_version =3D QEMU_PLUGIN_VERSION; =20 typedef struct { - GMutex lock; - int index; uint64_t bb_count; uint64_t insn_count; } CPUCount; =20 -/* Used by the inline & linux-user counts */ -static bool do_inline; -static CPUCount inline_count; +static struct qemu_plugin_scoreboard *counts; +static qemu_plugin_u64 bb_count; +static qemu_plugin_u64 insn_count; =20 +static bool do_inline; /* Dump running CPU total on idle? */ static bool idle_report; -static GPtrArray *counts; -static int max_cpus; =20 -static void gen_one_cpu_report(CPUCount *count, GString *report) +static void gen_one_cpu_report(CPUCount *count, GString *report, + unsigned int cpu_index) { if (count->bb_count) { g_string_append_printf(report, "CPU%d: " "bb's: %" PRIu64", insns: %" PRIu64 "\n", - count->index, + cpu_index, count->bb_count, count->insn_count); } } @@ -46,20 +44,23 @@ static void plugin_exit(qemu_plugin_id_t id, void *p) { g_autoptr(GString) report =3D g_string_new(""); =20 - if (do_inline || !max_cpus) { - g_string_printf(report, "bb's: %" PRIu64", insns: %" PRIu64 "\n", - inline_count.bb_count, inline_count.insn_count); - } else { - g_ptr_array_foreach(counts, (GFunc) gen_one_cpu_report, report); + for (int i =3D 0; i < qemu_plugin_num_vcpus(); ++i) { + CPUCount *count =3D qemu_plugin_scoreboard_find(counts, i); + gen_one_cpu_report(count, report, i); } + g_string_append_printf(report, "Total: " + "bb's: %" PRIu64", insns: %" PRIu64 "\n", + qemu_plugin_u64_sum(bb_count), + qemu_plugin_u64_sum(insn_count)); qemu_plugin_outs(report->str); + qemu_plugin_scoreboard_free(counts); } =20 static void vcpu_idle(qemu_plugin_id_t id, unsigned int cpu_index) { - CPUCount *count =3D g_ptr_array_index(counts, cpu_index); + CPUCount *count =3D qemu_plugin_scoreboard_find(counts, cpu_index); g_autoptr(GString) report =3D g_string_new(""); - gen_one_cpu_report(count, report); + gen_one_cpu_report(count, report, cpu_index); =20 if (report->len > 0) { g_string_prepend(report, "Idling "); @@ -69,14 +70,11 @@ static void vcpu_idle(qemu_plugin_id_t id, unsigned int= cpu_index) =20 static void vcpu_tb_exec(unsigned int cpu_index, void *udata) { - CPUCount *count =3D max_cpus ? - g_ptr_array_index(counts, cpu_index) : &inline_count; + CPUCount *count =3D qemu_plugin_scoreboard_find(counts, cpu_index); =20 uintptr_t n_insns =3D (uintptr_t)udata; - g_mutex_lock(&count->lock); count->insn_count +=3D n_insns; count->bb_count++; - g_mutex_unlock(&count->lock); } =20 static void vcpu_tb_trans(qemu_plugin_id_t id, struct qemu_plugin_tb *tb) @@ -84,11 +82,10 @@ static void vcpu_tb_trans(qemu_plugin_id_t id, struct q= emu_plugin_tb *tb) size_t n_insns =3D qemu_plugin_tb_n_insns(tb); =20 if (do_inline) { - qemu_plugin_register_vcpu_tb_exec_inline(tb, QEMU_PLUGIN_INLINE_AD= D_U64, - &inline_count.bb_count, 1= ); - qemu_plugin_register_vcpu_tb_exec_inline(tb, QEMU_PLUGIN_INLINE_AD= D_U64, - &inline_count.insn_count, - n_insns); + qemu_plugin_register_vcpu_tb_exec_inline_per_vcpu( + tb, QEMU_PLUGIN_INLINE_ADD_U64, bb_count, 1); + qemu_plugin_register_vcpu_tb_exec_inline_per_vcpu( + tb, QEMU_PLUGIN_INLINE_ADD_U64, insn_count, n_insns); } else { qemu_plugin_register_vcpu_tb_exec_cb(tb, vcpu_tb_exec, QEMU_PLUGIN_CB_NO_REGS, @@ -121,18 +118,10 @@ QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugi= n_id_t id, } } =20 - if (info->system_emulation && !do_inline) { - max_cpus =3D info->system.max_vcpus; - counts =3D g_ptr_array_new(); - for (i =3D 0; i < max_cpus; i++) { - CPUCount *count =3D g_new0(CPUCount, 1); - g_mutex_init(&count->lock); - count->index =3D i; - g_ptr_array_add(counts, count); - } - } else if (!do_inline) { - g_mutex_init(&inline_count.lock); - } + counts =3D qemu_plugin_scoreboard_new(sizeof(CPUCount)); + bb_count =3D qemu_plugin_scoreboard_u64_in_struct(counts, CPUCount, bb= _count); + insn_count =3D qemu_plugin_scoreboard_u64_in_struct( + counts, CPUCount, insn_count); =20 if (idle_report) { qemu_plugin_register_vcpu_idle_cb(id, vcpu_idle); --=20 2.39.2 From nobody Tue Nov 26 06:56:45 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1709736570; cv=none; d=zohomail.com; s=zohoarc; b=aIO1UpiAl2Mte2Qwjmm3rLAJqzbJvJOlV271Ij8bY+nZO1tI+zE4g4jXpgE1nyGhpgxS6ZFbexiZAiiTcm+YrokqqCiZ+cngapNeLxvz7bh2Adayx23qM5jJCLqyiaXqmFgPiUgEW7VZmB3nVL2D2qAZJiIpENIg9trr0YmOcbo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709736570; 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=hywCMkQ2+8lFixtPYqWIxK0iCOhK3WSJjT1Lu+td+xY=; b=cxdqsmtAQ5GXAcHwRNkof6OUxwIwX4SHT/W04PHVfZKgwqb82UsqaxrGXBVErkKEflqrwmdPHHbhjYL9pXYF8npvQglhiW2hrqlk/Z6DZ6kK18xQzIfhME/rpZlBMsnDsEw7H6B+d6dOzDYpBcT2/ghhErHCcUkLTKZsFnV383M= 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 1709736570140377.20678266287223; Wed, 6 Mar 2024 06:49:30 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rhsZy-0006gZ-03; Wed, 06 Mar 2024 09:49:10 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rhsZo-0006bd-QC for qemu-devel@nongnu.org; Wed, 06 Mar 2024 09:49:01 -0500 Received: from mail-wr1-x42a.google.com ([2a00:1450:4864:20::42a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rhsZn-0004E4-19 for qemu-devel@nongnu.org; Wed, 06 Mar 2024 09:49:00 -0500 Received: by mail-wr1-x42a.google.com with SMTP id ffacd0b85a97d-33d90dfe73cso621499f8f.0 for ; Wed, 06 Mar 2024 06:48:58 -0800 (PST) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id n3-20020adfe783000000b0033b79d385f6sm17590705wrm.47.2024.03.06.06.48.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Mar 2024 06:48:56 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 940825F9E6; Wed, 6 Mar 2024 14:40:43 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1709736537; x=1710341337; 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=hywCMkQ2+8lFixtPYqWIxK0iCOhK3WSJjT1Lu+td+xY=; b=hMW5dmogBIjc5EUrC3VNXIkaHjMM6xYGC9QpuCtV3izw3imu1cPMurfiqelRU3zEWB IG7yNTRhn9CgjrpgOij9xY+UzR5yrIP8cd1NQrnyCvl45mfxf+ARU+G2Qpokc5En5VWW a6K5w6VfI0QShPpdnZM0GEo6qv6Pwm/sosSufyV7mlxVr4Fn7505ezIwiFd3jUKfgqqA q+biAOa1eHzTZR/TImcnspw0uv+YM66VjPEz0nqJgjysVH0aKYMQ/gyaeTCyL+ayQnE2 NwV/UY45cetjQz1iywV+3zh+u4pcHwtuKl9n1tRuzB6FS7pmRmb0rQs9ekRxTYm1Kf6Z 6h9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709736537; x=1710341337; 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=hywCMkQ2+8lFixtPYqWIxK0iCOhK3WSJjT1Lu+td+xY=; b=CJjdmOynDHskkoe/8XkokD1V4W6jsu5a+GcMaMwflqLlmOzH2aMZcaHHAK88ue8vJl oDEV2zyY5jT8j9GoNt5js7lXJUcC2p3Xc3fHzY7ePDAZFetAIK1wup7mrtX6dZomkf+A RZVKMq8qXiS4PJ36dm1HJzxhpXX/mMk6y4MLhZLYsOYHQ5pU+0RjGYYGdX14Y6C6RKv/ DivVX7rth2DtU/KzA4kQkH7H6DqMPRXnixUD8v3GJ93xradUbbkKRk4g2Q9Gw7aH/mjK z5uEwOpyjHqvTLq051hADT969v9DNU1l1xLP7UeKHHYmnPkrng1ubK54Tu43oPjDoUOj 6y+w== X-Gm-Message-State: AOJu0YymubXMtJxtVlVZHnketCep86qiBPEg0rrQjU1PybegyWPTEu/v H1pNvl2VkSvlUMDM0QdsZHHzoDQW6EKbLeTyQ2bd44ek33nlYukdnxe9LR8tVBw= X-Google-Smtp-Source: AGHT+IG/H+ES/tSKZQVyuYvH4+qNDenyabEpbL7pWboqwIPMp3pSQR9Oc3K+Wbd5+cMiynk/o0HNPg== X-Received: by 2002:a5d:6446:0:b0:33d:754c:8daf with SMTP id d6-20020a5d6446000000b0033d754c8dafmr5147480wrw.10.1709736537173; Wed, 06 Mar 2024 06:48:57 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Pierrick Bouvier , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Alexandre Iooss , Mahmoud Mandour Subject: [PULL 22/29] contrib/plugins/hotblocks: migrate to new per_vcpu API Date: Wed, 6 Mar 2024 14:40:34 +0000 Message-Id: <20240306144041.3787188-23-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240306144041.3787188-1-alex.bennee@linaro.org> References: <20240306144041.3787188-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::42a; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x42a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=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: 1709736572036100003 From: Pierrick Bouvier Signed-off-by: Pierrick Bouvier Message-Id: <20240304130036.124418-10-pierrick.bouvier@linaro.org> Signed-off-by: Alex Benn=C3=A9e Message-Id: <20240305121005.3528075-23-alex.bennee@linaro.org> diff --git a/contrib/plugins/hotblocks.c b/contrib/plugins/hotblocks.c index 4de1b134944..02bc5078bdd 100644 --- a/contrib/plugins/hotblocks.c +++ b/contrib/plugins/hotblocks.c @@ -34,8 +34,8 @@ static guint64 limit =3D 20; */ typedef struct { uint64_t start_addr; - uint64_t exec_count; - int trans_count; + struct qemu_plugin_scoreboard *exec_count; + int trans_count; unsigned long insns; } ExecCount; =20 @@ -43,7 +43,17 @@ static gint cmp_exec_count(gconstpointer a, gconstpointe= r b) { ExecCount *ea =3D (ExecCount *) a; ExecCount *eb =3D (ExecCount *) b; - return ea->exec_count > eb->exec_count ? -1 : 1; + uint64_t count_a =3D + qemu_plugin_u64_sum(qemu_plugin_scoreboard_u64(ea->exec_count)); + uint64_t count_b =3D + qemu_plugin_u64_sum(qemu_plugin_scoreboard_u64(eb->exec_count)); + return count_a > count_b ? -1 : 1; +} + +static void exec_count_free(gpointer key, gpointer value, gpointer user_da= ta) +{ + ExecCount *cnt =3D value; + qemu_plugin_scoreboard_free(cnt->exec_count); } =20 static void plugin_exit(qemu_plugin_id_t id, void *p) @@ -52,7 +62,6 @@ static void plugin_exit(qemu_plugin_id_t id, void *p) GList *counts, *it; int i; =20 - g_mutex_lock(&lock); g_string_append_printf(report, "%d entries in the hash table\n", g_hash_table_size(hotblocks)); counts =3D g_hash_table_get_values(hotblocks); @@ -63,16 +72,21 @@ static void plugin_exit(qemu_plugin_id_t id, void *p) =20 for (i =3D 0; i < limit && it->next; i++, it =3D it->next) { ExecCount *rec =3D (ExecCount *) it->data; - g_string_append_printf(report, "0x%016"PRIx64", %d, %ld, %"PRI= d64"\n", - rec->start_addr, rec->trans_count, - rec->insns, rec->exec_count); + g_string_append_printf( + report, "0x%016"PRIx64", %d, %ld, %"PRId64"\n", + rec->start_addr, rec->trans_count, + rec->insns, + qemu_plugin_u64_sum( + qemu_plugin_scoreboard_u64(rec->exec_count))); } =20 g_list_free(it); } - g_mutex_unlock(&lock); =20 qemu_plugin_outs(report->str); + + g_hash_table_foreach(hotblocks, exec_count_free, NULL); + g_hash_table_destroy(hotblocks); } =20 static void plugin_init(void) @@ -82,15 +96,9 @@ static void plugin_init(void) =20 static void vcpu_tb_exec(unsigned int cpu_index, void *udata) { - ExecCount *cnt; - uint64_t hash =3D (uint64_t) udata; - - g_mutex_lock(&lock); - cnt =3D (ExecCount *) g_hash_table_lookup(hotblocks, (gconstpointer) h= ash); - /* should always succeed */ - g_assert(cnt); - cnt->exec_count++; - g_mutex_unlock(&lock); + ExecCount *cnt =3D (ExecCount *)udata; + qemu_plugin_u64_add(qemu_plugin_scoreboard_u64(cnt->exec_count), + cpu_index, 1); } =20 /* @@ -114,18 +122,20 @@ static void vcpu_tb_trans(qemu_plugin_id_t id, struct= qemu_plugin_tb *tb) cnt->start_addr =3D pc; cnt->trans_count =3D 1; cnt->insns =3D insns; + cnt->exec_count =3D qemu_plugin_scoreboard_new(sizeof(uint64_t)); g_hash_table_insert(hotblocks, (gpointer) hash, (gpointer) cnt); } =20 g_mutex_unlock(&lock); =20 if (do_inline) { - qemu_plugin_register_vcpu_tb_exec_inline(tb, QEMU_PLUGIN_INLINE_AD= D_U64, - &cnt->exec_count, 1); + qemu_plugin_register_vcpu_tb_exec_inline_per_vcpu( + tb, QEMU_PLUGIN_INLINE_ADD_U64, + qemu_plugin_scoreboard_u64(cnt->exec_count), 1); } else { qemu_plugin_register_vcpu_tb_exec_cb(tb, vcpu_tb_exec, QEMU_PLUGIN_CB_NO_REGS, - (void *)hash); + (void *)cnt); } } =20 --=20 2.39.2 From nobody Tue Nov 26 06:56:45 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1709736097; cv=none; d=zohomail.com; s=zohoarc; b=Snj4tKXPiVFhn4EW3R/e34VSDa2sBMGlEnqeUGzUOejjjnAU/UKr/dnGn2Wr9bcRuZEKIZULrwD/Hdl2nqY3wyoYBDSbkTGpE3ttsd+hNHNzDcr14tcjWrnhavebl7MKeM6CuxhhVv9VbbicrWdzKnK5CmijsZ64cYGn4pQzmfE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709736097; 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=Khdy+gbq2WXrU2jPe9cQ5CJlDOdXdCS5sbUj4LPn044=; b=BJduaNP+gLOQSGlUBRs1eTwhwCVou80Gd2V4NyUHZBTETFx6xvDUlJhVWXYsUFyC+stld6sBo81Xr/CKZDPDNVAIRtug/zdwoCUNza9E0YqA4HTbYCc284doKJJWr4CQ4W/ofWjy8MBsb6DWUsGeqZ1iCgKk4/sqzrdx23xTSjM= 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 1709736097444183.0599493072575; Wed, 6 Mar 2024 06:41:37 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rhsSJ-0008Nz-1m; Wed, 06 Mar 2024 09:41:15 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rhsSD-0007wY-CL for qemu-devel@nongnu.org; Wed, 06 Mar 2024 09:41:09 -0500 Received: from mail-wm1-x32d.google.com ([2a00:1450:4864:20::32d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rhsS4-0001Ve-Bs for qemu-devel@nongnu.org; Wed, 06 Mar 2024 09:41:09 -0500 Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-412e80e13abso22407995e9.3 for ; Wed, 06 Mar 2024 06:40:59 -0800 (PST) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id hg7-20020a05600c538700b00412fe0eb806sm776226wmb.14.2024.03.06.06.40.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Mar 2024 06:40:54 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id A60D75F9E8; Wed, 6 Mar 2024 14:40:43 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1709736058; x=1710340858; 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=Khdy+gbq2WXrU2jPe9cQ5CJlDOdXdCS5sbUj4LPn044=; b=JbZhFjazFhrTmQVIfvNvNq7U0fd2AU0/ZxucioIgS0QxdudOvkXwAf4Jj590CTQtbV lraZ/v9MJ4ERv1AymG86s0fuRN+VQyHUE1T1G3dQPyBZA2ty9Pf1G8N2bntYcr+nQONF QkJcyKpUNQOfIImt//K54y+ymfR/tCcgWiBhFXPPZOFQV7xL0KLSKqqI2Uigg7AA9XLE nRyHOQZCz0H8ksx1VPs2TpS4k/JwtwyvrZb7YNjgatpwqXnDIvgF/lMHdL+ByQfTqMpz KHo/SOukJ0EHmN2ABOAPd8a93ekfM8BdhJUEksIV0hmTdxm40kLL2sCa9/nEtHek260g 9pQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709736059; x=1710340859; 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=Khdy+gbq2WXrU2jPe9cQ5CJlDOdXdCS5sbUj4LPn044=; b=ucUF6k4zZBd699hAtHy85wAjtTjqqm7f5fwub/WNSeQovuueCHt3cRqLOoDo7HIhKs WCszwAfDSz5jLooX9X2r/9/tQMy6aXqzDlxF/s9KiJ74lhzUNkZPfkhwSIdLfmLHD3zE SIR2PgIZuRdp2xaqOcr39SNe2JO57azjT5M0oy+SFybGS+Mm39aV7MMJKaq+tutgqlK3 xfEMCzD5qsKTiGB5vxs3yfAcl+mgsr9JDAjxKJ7W5Yi8ATx/Cojexrhw9bH68sW+76bT 1AW2y3Hna9wdwdiXrj9ZsgrVL7opojsVJhdPejLK8xgCAvy3Os6AA2pd51hVVLnVey5g brqA== X-Gm-Message-State: AOJu0YyLgjNgX0r8Tb5pWUUuvQqUcYTPAVzMqdD10FPmefTQ2bvS2eAg URlT6UMVU/AzuDuHJBA2/aDNj0vWBkw7T5U1JmgD3DxRx75/rHxflKV8QuRRlW4= X-Google-Smtp-Source: AGHT+IFPRrlgs38YzJACJ+qqSZPBGADPC/s5lDcIZ701bovJUXYVbVWWeIUBHM2AM5IWkJDhqKWmGw== X-Received: by 2002:a05:600c:5252:b0:412:de1f:cdfb with SMTP id fc18-20020a05600c525200b00412de1fcdfbmr7342199wmb.20.1709736058567; Wed, 06 Mar 2024 06:40:58 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Pierrick Bouvier , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Alexandre Iooss , Mahmoud Mandour Subject: [PULL 23/29] contrib/plugins/howvec: migrate to new per_vcpu API Date: Wed, 6 Mar 2024 14:40:35 +0000 Message-Id: <20240306144041.3787188-24-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240306144041.3787188-1-alex.bennee@linaro.org> References: <20240306144041.3787188-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, T_SCC_BODY_TEXT_LINE=-0.01, 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: 1709736097793100001 From: Pierrick Bouvier Reviewed-by: Alex Benn=C3=A9e Tested-by: Alex Benn=C3=A9e Signed-off-by: Pierrick Bouvier Message-Id: <20240304130036.124418-11-pierrick.bouvier@linaro.org> Signed-off-by: Alex Benn=C3=A9e Message-Id: <20240305121005.3528075-24-alex.bennee@linaro.org> diff --git a/contrib/plugins/howvec.c b/contrib/plugins/howvec.c index 644a7856bb2..2d10c87e0fb 100644 --- a/contrib/plugins/howvec.c +++ b/contrib/plugins/howvec.c @@ -43,13 +43,13 @@ typedef struct { uint32_t mask; uint32_t pattern; CountType what; - uint64_t count; + qemu_plugin_u64 count; } InsnClassExecCount; =20 typedef struct { char *insn; uint32_t opcode; - uint64_t count; + qemu_plugin_u64 count; InsnClassExecCount *class; } InsnExecCount; =20 @@ -159,7 +159,9 @@ static gint cmp_exec_count(gconstpointer a, gconstpoint= er b) { InsnExecCount *ea =3D (InsnExecCount *) a; InsnExecCount *eb =3D (InsnExecCount *) b; - return ea->count > eb->count ? -1 : 1; + uint64_t count_a =3D qemu_plugin_u64_sum(ea->count); + uint64_t count_b =3D qemu_plugin_u64_sum(eb->count); + return count_a > count_b ? -1 : 1; } =20 static void free_record(gpointer data) @@ -167,12 +169,14 @@ static void free_record(gpointer data) InsnExecCount *rec =3D (InsnExecCount *) data; g_free(rec->insn); g_free(rec); + qemu_plugin_scoreboard_free(rec->count.score); } =20 static void plugin_exit(qemu_plugin_id_t id, void *p) { g_autoptr(GString) report =3D g_string_new("Instruction Classes:\n"); int i; + uint64_t total_count; GList *counts; InsnClassExecCount *class =3D NULL; =20 @@ -180,11 +184,12 @@ static void plugin_exit(qemu_plugin_id_t id, void *p) class =3D &class_table[i]; switch (class->what) { case COUNT_CLASS: - if (class->count || verbose) { + total_count =3D qemu_plugin_u64_sum(class->count); + if (total_count || verbose) { g_string_append_printf(report, "Class: %-24s\t(%" PRId64 " hits)\n= ", class->class, - class->count); + total_count); } break; case COUNT_INDIVIDUAL: @@ -212,7 +217,7 @@ static void plugin_exit(qemu_plugin_id_t id, void *p) "Instr: %-24s\t(%" PRId64 " hits)" "\t(op=3D0x%08x/%s)\n", rec->insn, - rec->count, + qemu_plugin_u64_sum(rec->count), rec->opcode, rec->class ? rec->class->class : "un-categorised"); @@ -221,6 +226,12 @@ static void plugin_exit(qemu_plugin_id_t id, void *p) } =20 g_hash_table_destroy(insns); + for (i =3D 0; i < ARRAY_SIZE(class_tables); i++) { + for (int j =3D 0; j < class_tables[i].table_sz; ++j) { + qemu_plugin_scoreboard_free(class_tables[i].table[j].count.sco= re); + } + } + =20 qemu_plugin_outs(report->str); } @@ -232,11 +243,12 @@ static void plugin_init(void) =20 static void vcpu_insn_exec_before(unsigned int cpu_index, void *udata) { - uint64_t *count =3D (uint64_t *) udata; - (*count)++; + struct qemu_plugin_scoreboard *score =3D udata; + qemu_plugin_u64_add(qemu_plugin_scoreboard_u64(score), cpu_index, 1); } =20 -static uint64_t *find_counter(struct qemu_plugin_insn *insn) +static struct qemu_plugin_scoreboard *find_counter( + struct qemu_plugin_insn *insn) { int i; uint64_t *cnt =3D NULL; @@ -265,7 +277,7 @@ static uint64_t *find_counter(struct qemu_plugin_insn *= insn) case COUNT_NONE: return NULL; case COUNT_CLASS: - return &class->count; + return class->count.score; case COUNT_INDIVIDUAL: { InsnExecCount *icount; @@ -279,13 +291,16 @@ static uint64_t *find_counter(struct qemu_plugin_insn= *insn) icount->opcode =3D opcode; icount->insn =3D qemu_plugin_insn_disas(insn); icount->class =3D class; + struct qemu_plugin_scoreboard *score =3D + qemu_plugin_scoreboard_new(sizeof(uint64_t)); + icount->count =3D qemu_plugin_scoreboard_u64(score); =20 g_hash_table_insert(insns, GUINT_TO_POINTER(opcode), (gpointer) icount); } g_mutex_unlock(&lock); =20 - return &icount->count; + return icount->count.score; } default: g_assert_not_reached(); @@ -300,14 +315,14 @@ static void vcpu_tb_trans(qemu_plugin_id_t id, struct= qemu_plugin_tb *tb) size_t i; =20 for (i =3D 0; i < n; i++) { - uint64_t *cnt; struct qemu_plugin_insn *insn =3D qemu_plugin_tb_get_insn(tb, i); - cnt =3D find_counter(insn); + struct qemu_plugin_scoreboard *cnt =3D find_counter(insn); =20 if (cnt) { if (do_inline) { - qemu_plugin_register_vcpu_insn_exec_inline( - insn, QEMU_PLUGIN_INLINE_ADD_U64, cnt, 1); + qemu_plugin_register_vcpu_insn_exec_inline_per_vcpu( + insn, QEMU_PLUGIN_INLINE_ADD_U64, + qemu_plugin_scoreboard_u64(cnt), 1); } else { qemu_plugin_register_vcpu_insn_exec_cb( insn, vcpu_insn_exec_before, QEMU_PLUGIN_CB_NO_REGS, c= nt); @@ -322,6 +337,14 @@ QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin= _id_t id, { int i; =20 + for (i =3D 0; i < ARRAY_SIZE(class_tables); i++) { + for (int j =3D 0; j < class_tables[i].table_sz; ++j) { + struct qemu_plugin_scoreboard *score =3D + qemu_plugin_scoreboard_new(sizeof(uint64_t)); + class_tables[i].table[j].count =3D qemu_plugin_scoreboard_u64(= score); + } + } + /* Select a class table appropriate to the guest architecture */ for (i =3D 0; i < ARRAY_SIZE(class_tables); i++) { ClassSelector *entry =3D &class_tables[i]; --=20 2.39.2 From nobody Tue Nov 26 06:56:45 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1709736111; cv=none; d=zohomail.com; s=zohoarc; b=MoJea/ANqr1I1iexU7wjpOAbx7PEOBhzBOLegy2nFavXF3b6+HFqqy10pSRttJ2SD76p8G8nqgjVe9lE4BTJSCyWr9YvTHBVVgL7KQge+g25oKLmNDA6wgGNo/4AUAiMvCJs6TUtJTXD+Q0eAeuFNbfc9hpK80zF17QMOi9JWgg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709736111; 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=YEf14uJYxbgFMCoXRLS0Jki4pRXZFLa5uR3yiXxdk30=; b=FV8bEAILrZqmCqB4JwknBA5VNybB8FpZ3/o3LH/0cJ75D90x6p07q90asgvzIAYGmpZbkXdN7mcovkmqymMeCFJIJiK8Nv30ZRexS23b/MMVFHlKM2O1Mk736zp4EciOLy3FnUCHxEl62c0xYmM8ADE3Y2bkrgvIszLAd7/jUXY= 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 1709736111201252.17894478888502; Wed, 6 Mar 2024 06:41:51 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rhsSJ-0008Qq-9q; Wed, 06 Mar 2024 09:41:15 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rhsSC-0007tV-Ah for qemu-devel@nongnu.org; Wed, 06 Mar 2024 09:41:08 -0500 Received: from mail-wr1-x42f.google.com ([2a00:1450:4864:20::42f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rhsS6-0001Vq-AK for qemu-devel@nongnu.org; Wed, 06 Mar 2024 09:41:07 -0500 Received: by mail-wr1-x42f.google.com with SMTP id ffacd0b85a97d-33d146737e6so5398563f8f.0 for ; Wed, 06 Mar 2024 06:41:00 -0800 (PST) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id g1-20020adfd1e1000000b0033e3a24f17esm9242234wrd.76.2024.03.06.06.40.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Mar 2024 06:40:56 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id BBE4A5F9EB; Wed, 6 Mar 2024 14:40:43 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1709736059; x=1710340859; 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=YEf14uJYxbgFMCoXRLS0Jki4pRXZFLa5uR3yiXxdk30=; b=B+k1MVf5wxQZR74Q36tRW2SIx8TPREdsxuP63ESt79CzCWLMK12cp1ov8hIY2lar0g tK8U5qTR2enQmF7++tyWyD6UDc2quUzdWnkmC6sshReqj5QhjRy9QD2FRFmeYdeHusvs Kiz2Kk32JdnBQPQNCZzp79q4fq7nunwdYKpmwOQPVr9yph/YdFKzZ+YnDRzPDydNM4du ydEPEOLWeZl3P1haUjtpeZdYkemDvsUL6+ah+FsZwtxN1KbS7+rqKfSDNvb1E4Ol2+rF s8rAgDl+OXAxfyU18K/P2JvgxDLmDXQ2ag+3CoSoFKuSY5oxjfcElTQGOvCsb1zssC90 Ildw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709736059; x=1710340859; 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=YEf14uJYxbgFMCoXRLS0Jki4pRXZFLa5uR3yiXxdk30=; b=I/ueC7BNib0UZg2vmgY9ZY98N3ki12S6cWgWLwBbPHhR2HPFlMRxU+6+ITt6I9OdTC l762mRZ2AQHqzVgSLB2/6wx190MIL02OY/chVbXxBCVxUyzwv3qpylGnD/y+NgKvkPDW pqMlE+tX8ZpyxOLSmjaedwFfHKkFFYiVEhN++ifwkLhR9LOk8Bno1IXTbTBw46v2orqW Bso95l2roEMjPAB4K4HXie63QzFI81nBJBBEQvS+CN4ZauPG2t5HfYmmV3gN5gwi5g4A iFshudlvbU6Riiy59WbcBYHkUoJB21bp+1THN6LBFxSY6B7dcK7BAAqc6rIPihkhi4H9 lWLg== X-Gm-Message-State: AOJu0Yy4ghxGG5As7DF+sHGGk+G4FOqt3tCVdOULR/uh8/2mtzSXHcmZ IDb5AhuIHXCiGdUFiYg+F3LQrotYvLZuBii9LBq7aeur8B3+PFnNxq2jMqcNIKo= X-Google-Smtp-Source: AGHT+IHAY9hcDxAgZ1GLN8woakH1H8WbjQe8m7RA1rxtNuD2wGywztTOjt8OkMafhypMKH6tlYqxUQ== X-Received: by 2002:adf:e44d:0:b0:33e:1629:651d with SMTP id t13-20020adfe44d000000b0033e1629651dmr10244734wrm.15.1709736058915; Wed, 06 Mar 2024 06:40:58 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Pierrick Bouvier , Richard Henderson , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Alexandre Iooss , Mahmoud Mandour Subject: [PULL 24/29] plugins: remove non per_vcpu inline operation from API Date: Wed, 6 Mar 2024 14:40:36 +0000 Message-Id: <20240306144041.3787188-25-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240306144041.3787188-1-alex.bennee@linaro.org> References: <20240306144041.3787188-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::42f; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x42f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1709736111903100003 From: Pierrick Bouvier Now we have a thread-safe equivalent of inline operation, and that all plugins were changed to use it, there is no point to keep the old API. In more, it will help when we implement more functionality (conditional callbacks), as we can assume that we operate on a scoreboard. API version bump was already done as part of this series. Reviewed-by: Richard Henderson Reviewed-by: Alex Benn=C3=A9e Signed-off-by: Pierrick Bouvier Message-Id: <20240304130036.124418-12-pierrick.bouvier@linaro.org> Signed-off-by: Alex Benn=C3=A9e Message-Id: <20240305121005.3528075-25-alex.bennee@linaro.org> diff --git a/include/qemu/qemu-plugin.h b/include/qemu/qemu-plugin.h index 6bbad068c01..4fc6c3739b2 100644 --- a/include/qemu/qemu-plugin.h +++ b/include/qemu/qemu-plugin.h @@ -52,7 +52,11 @@ typedef uint64_t qemu_plugin_id_t; * The plugins export the API they were built against by exposing the * symbol qemu_plugin_version which can be checked. * - * version 2: removed qemu_plugin_n_vcpus and qemu_plugin_n_max_vcpus + * version 2: + * - removed qemu_plugin_n_vcpus and qemu_plugin_n_max_vcpus + * - Remove qemu_plugin_register_vcpu_{tb, insn, mem}_exec_inline. + * Those functions are replaced by *_per_vcpu variants, which guarantee + * thread-safety for operations. */ =20 extern QEMU_PLUGIN_EXPORT int qemu_plugin_version; @@ -309,25 +313,6 @@ enum qemu_plugin_op { QEMU_PLUGIN_INLINE_ADD_U64, }; =20 -/** - * qemu_plugin_register_vcpu_tb_exec_inline() - execution inline op - * @tb: the opaque qemu_plugin_tb handle for the translation - * @op: the type of qemu_plugin_op (e.g. ADD_U64) - * @ptr: the target memory location for the op - * @imm: the op data (e.g. 1) - * - * Insert an inline op to every time a translated unit executes. - * Useful if you just want to increment a single counter somewhere in - * memory. - * - * Note: ops are not atomic so in multi-threaded/multi-smp situations - * you will get inexact results. - */ -QEMU_PLUGIN_API -void qemu_plugin_register_vcpu_tb_exec_inline(struct qemu_plugin_tb *tb, - enum qemu_plugin_op op, - void *ptr, uint64_t imm); - /** * qemu_plugin_register_vcpu_tb_exec_inline_per_vcpu() - execution inline = op * @tb: the opaque qemu_plugin_tb handle for the translation @@ -359,21 +344,6 @@ void qemu_plugin_register_vcpu_insn_exec_cb(struct qem= u_plugin_insn *insn, enum qemu_plugin_cb_flags flag= s, void *userdata); =20 -/** - * qemu_plugin_register_vcpu_insn_exec_inline() - insn execution inline op - * @insn: the opaque qemu_plugin_insn handle for an instruction - * @op: the type of qemu_plugin_op (e.g. ADD_U64) - * @ptr: the target memory location for the op - * @imm: the op data (e.g. 1) - * - * Insert an inline op to every time an instruction executes. Useful - * if you just want to increment a single counter somewhere in memory. - */ -QEMU_PLUGIN_API -void qemu_plugin_register_vcpu_insn_exec_inline(struct qemu_plugin_insn *i= nsn, - enum qemu_plugin_op op, - void *ptr, uint64_t imm); - /** * qemu_plugin_register_vcpu_insn_exec_inline_per_vcpu() - insn exec inlin= e op * @insn: the opaque qemu_plugin_insn handle for an instruction @@ -597,24 +567,6 @@ void qemu_plugin_register_vcpu_mem_cb(struct qemu_plug= in_insn *insn, enum qemu_plugin_mem_rw rw, void *userdata); =20 -/** - * qemu_plugin_register_vcpu_mem_inline() - register an inline op to any m= emory access - * @insn: handle for instruction to instrument - * @rw: apply to reads, writes or both - * @op: the op, of type qemu_plugin_op - * @ptr: pointer memory for the op - * @imm: immediate data for @op - * - * This registers a inline op every memory access generated by the - * instruction. This provides for a lightweight but not thread-safe - * way of counting the number of operations done. - */ -QEMU_PLUGIN_API -void qemu_plugin_register_vcpu_mem_inline(struct qemu_plugin_insn *insn, - enum qemu_plugin_mem_rw rw, - enum qemu_plugin_op op, void *pt= r, - uint64_t imm); - /** * qemu_plugin_register_vcpu_mem_inline_per_vcpu() - inline op for mem acc= ess * @insn: handle for instruction to instrument diff --git a/plugins/api.c b/plugins/api.c index 6470f1dc0f2..8fa5a600ac3 100644 --- a/plugins/api.c +++ b/plugins/api.c @@ -101,16 +101,6 @@ void qemu_plugin_register_vcpu_tb_exec_cb(struct qemu_= plugin_tb *tb, } } =20 -void qemu_plugin_register_vcpu_tb_exec_inline(struct qemu_plugin_tb *tb, - enum qemu_plugin_op op, - void *ptr, uint64_t imm) -{ - if (!tb->mem_only) { - plugin_register_inline_op(&tb->cbs[PLUGIN_CB_INLINE], - 0, op, ptr, imm); - } -} - void qemu_plugin_register_vcpu_tb_exec_inline_per_vcpu( struct qemu_plugin_tb *tb, enum qemu_plugin_op op, @@ -138,16 +128,6 @@ void qemu_plugin_register_vcpu_insn_exec_cb(struct qem= u_plugin_insn *insn, } } =20 -void qemu_plugin_register_vcpu_insn_exec_inline(struct qemu_plugin_insn *i= nsn, - enum qemu_plugin_op op, - void *ptr, uint64_t imm) -{ - if (!insn->mem_only) { - plugin_register_inline_op(&insn->cbs[PLUGIN_CB_INSN][PLUGIN_CB_INL= INE], - 0, op, ptr, imm); - } -} - void qemu_plugin_register_vcpu_insn_exec_inline_per_vcpu( struct qemu_plugin_insn *insn, enum qemu_plugin_op op, @@ -175,15 +155,6 @@ void qemu_plugin_register_vcpu_mem_cb(struct qemu_plug= in_insn *insn, cb, flags, rw, udata); } =20 -void qemu_plugin_register_vcpu_mem_inline(struct qemu_plugin_insn *insn, - enum qemu_plugin_mem_rw rw, - enum qemu_plugin_op op, void *pt= r, - uint64_t imm) -{ - plugin_register_inline_op(&insn->cbs[PLUGIN_CB_MEM][PLUGIN_CB_INLINE], - rw, op, ptr, imm); -} - void qemu_plugin_register_vcpu_mem_inline_per_vcpu( struct qemu_plugin_insn *insn, enum qemu_plugin_mem_rw rw, diff --git a/plugins/qemu-plugins.symbols b/plugins/qemu-plugins.symbols index 0d8141b85f1..a9fac056c7f 100644 --- a/plugins/qemu-plugins.symbols +++ b/plugins/qemu-plugins.symbols @@ -27,16 +27,13 @@ qemu_plugin_register_vcpu_idle_cb; qemu_plugin_register_vcpu_init_cb; qemu_plugin_register_vcpu_insn_exec_cb; - qemu_plugin_register_vcpu_insn_exec_inline; qemu_plugin_register_vcpu_insn_exec_inline_per_vcpu; qemu_plugin_register_vcpu_mem_cb; - qemu_plugin_register_vcpu_mem_inline; qemu_plugin_register_vcpu_mem_inline_per_vcpu; qemu_plugin_register_vcpu_resume_cb; qemu_plugin_register_vcpu_syscall_cb; qemu_plugin_register_vcpu_syscall_ret_cb; qemu_plugin_register_vcpu_tb_exec_cb; - qemu_plugin_register_vcpu_tb_exec_inline; qemu_plugin_register_vcpu_tb_exec_inline_per_vcpu; qemu_plugin_register_vcpu_tb_trans_cb; qemu_plugin_reset; --=20 2.39.2 From nobody Tue Nov 26 06:56:45 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1709736501; cv=none; d=zohomail.com; s=zohoarc; b=D4HELNfeqwPXnIbrQw1502s3Tt5PWUQeagbSx0FxXMY7K7Iv2z+X1racVvHqV/lqTO7reh3DHry8zoQzhPBjupmey57x9GPtujYg1/1XZVs/BsA+j5Nc9ScyBZmbUrHBxdL76u6N9Wa1MAyyM1BN/Czu+mfncFd/iuhXxH/R7+g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709736501; 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=CqDhKj9Df0B4Sja/HzIC1euLpFVBt6pAPlBKW6M2zkc=; b=dIHiaTmUpIrrUo4LOvmJkYvEh2w5AF9S/WATDMeVfjd8v8y9ebaGq0g/9GiPL3Fy9AfLYGGSXopTHzGd4nnkYaBHcQ73dwa2x7WZuBEYQ7vZu6ni9WQULnhT/6bYEnEv3/mLq1RY8C3GmK7RYHoy/MzUf6z36R+2zfZGiq5sN3s= 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 1709736501653506.0350838525801; Wed, 6 Mar 2024 06:48:21 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rhsSI-0008Lc-LF; Wed, 06 Mar 2024 09:41:14 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rhsSB-0007t0-G8 for qemu-devel@nongnu.org; Wed, 06 Mar 2024 09:41:08 -0500 Received: from mail-wr1-x42c.google.com ([2a00:1450:4864:20::42c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rhsS6-0001Vu-9z for qemu-devel@nongnu.org; Wed, 06 Mar 2024 09:41:07 -0500 Received: by mail-wr1-x42c.google.com with SMTP id ffacd0b85a97d-33d6f26ff33so767610f8f.0 for ; Wed, 06 Mar 2024 06:41:00 -0800 (PST) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id u20-20020adfcb14000000b0033b7ce8b496sm17645566wrh.108.2024.03.06.06.40.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Mar 2024 06:40:56 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id D0A385F9ED; Wed, 6 Mar 2024 14:40:43 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1709736059; x=1710340859; 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=CqDhKj9Df0B4Sja/HzIC1euLpFVBt6pAPlBKW6M2zkc=; b=hJu9GrDuHq2jnkNxhqdGl8eEbUJ6Z7Zxs3Uzk0/GGXVOpwy+A7dyESlruH8H5yGpbz KaceDbjNt1ETN6a8e08iYYkqs8WS1asnmBmmCQbLRaodPi6HgMYH3UwjOAaJom1uaWoi PnXif2/D8qs93yW3cgDVmUkEIIn3NoqPq9Cmui4ZybjWPeFPAYKcZDWbGeaejPkknZi1 KlsaB3koqqB4TQnaNLrVpTuYJ5oa0FyDROtrJyjbX8MqYjZeHN2VBHo51kX78Hxy9BIM RgRSbQkzN4Mlg7QtEv4Kuh59opDfhHVvMdoiEtn32r1xEGut+/8BOqH4bpDaz+nWGVxd OH/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709736059; x=1710340859; 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=CqDhKj9Df0B4Sja/HzIC1euLpFVBt6pAPlBKW6M2zkc=; b=xAXo91PwtVWuqNuwdT7k/EVfLWnNubPwHcidFMeqZa9rHXdq6IuzOkf17dES72wgd9 JTTiVlVRSg8SmjhIEiRHnABGNo6vmFlvN1u/hwNNgIbFHa2qrFzrSVPMOWbTZEtZhHsP xtg6ui8K+VCxyMv195UXadgaGVfA7tvhiD6zdoqt8BDc/eX8xkRzoLDJgX2fsi3vP0W9 Hct5gWxQjWtvftIE6vBUMrUaGfYqT8Ry46JhTqbiS2qu1fgMTSSpDfYY8RWX2Im1Z/dA MFNi4twPARA/J6atyz+v+GBBiYbIcp1alN6tfRnYQMZ4VbcmgheXr5ncQQNjLQVFuvIC +kRg== X-Gm-Message-State: AOJu0Yw0HKgJIKgUIRHsnX6D+zpxZMcSD8HQ+TB08L3JXIW4u+NJGSeK OPRwoUJp18d6MP5zTEtIhUiiZTyMXOkuV05O00osNuCiBKuOAvaLCqkZIRBOkBM= X-Google-Smtp-Source: AGHT+IFkLq+AqT+M+PUMa0e8K1Zd+mFBOiYG+QtM7+4MIMJYG0L1rOI5bR2r68BEpuGd41qa4ac2GQ== X-Received: by 2002:adf:e385:0:b0:33e:4b3c:787b with SMTP id e5-20020adfe385000000b0033e4b3c787bmr3312819wrm.26.1709736059104; Wed, 06 Mar 2024 06:40:59 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Pierrick Bouvier , Richard Henderson , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Paolo Bonzini , Alexandre Iooss , Mahmoud Mandour Subject: [PULL 25/29] plugins: cleanup codepath for previous inline operation Date: Wed, 6 Mar 2024 14:40:37 +0000 Message-Id: <20240306144041.3787188-26-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240306144041.3787188-1-alex.bennee@linaro.org> References: <20240306144041.3787188-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::42c; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x42c.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1709736503647100003 From: Pierrick Bouvier Reviewed-by: Richard Henderson Reviewed-by: Alex Benn=C3=A9e Signed-off-by: Pierrick Bouvier Message-Id: <20240304130036.124418-13-pierrick.bouvier@linaro.org> Signed-off-by: Alex Benn=C3=A9e Message-Id: <20240305121005.3528075-26-alex.bennee@linaro.org> diff --git a/plugins/plugin.h b/plugins/plugin.h index f6fa10a0f56..7c34f23cfcb 100644 --- a/plugins/plugin.h +++ b/plugins/plugin.h @@ -68,11 +68,6 @@ struct qemu_plugin_ctx { =20 struct qemu_plugin_ctx *plugin_id_to_ctx_locked(qemu_plugin_id_t id); =20 -void plugin_register_inline_op(GArray **arr, - enum qemu_plugin_mem_rw rw, - enum qemu_plugin_op op, void *ptr, - uint64_t imm); - void plugin_register_inline_op_on_entry(GArray **arr, enum qemu_plugin_mem_rw rw, enum qemu_plugin_op op, diff --git a/accel/tcg/plugin-gen.c b/accel/tcg/plugin-gen.c index 47e05ec6347..8028786c7bb 100644 --- a/accel/tcg/plugin-gen.c +++ b/accel/tcg/plugin-gen.c @@ -440,15 +440,10 @@ static TCGOp *append_inline_cb(const struct qemu_plug= in_dyn_cb *cb, TCGOp *begin_op, TCGOp *op, int *unused) { - char *ptr =3D cb->userp; - size_t elem_size =3D 0; - size_t offset =3D 0; - if (!ptr) { - /* use inline entry */ - ptr =3D cb->inline_insn.entry.score->data->data; - elem_size =3D g_array_get_element_size(cb->inline_insn.entry.score= ->data); - offset =3D cb->inline_insn.entry.offset; - } + char *ptr =3D cb->inline_insn.entry.score->data->data; + size_t elem_size =3D g_array_get_element_size( + cb->inline_insn.entry.score->data); + size_t offset =3D cb->inline_insn.entry.offset; =20 op =3D copy_ld_i32(&begin_op, op); op =3D copy_mul_i32(&begin_op, op, elem_size); diff --git a/plugins/core.c b/plugins/core.c index 7852590da88..11ca20e6267 100644 --- a/plugins/core.c +++ b/plugins/core.c @@ -316,22 +316,6 @@ static struct qemu_plugin_dyn_cb *plugin_get_dyn_cb(GA= rray **arr) return &g_array_index(cbs, struct qemu_plugin_dyn_cb, cbs->len - 1); } =20 -void plugin_register_inline_op(GArray **arr, - enum qemu_plugin_mem_rw rw, - enum qemu_plugin_op op, - void *ptr, - uint64_t imm) -{ - struct qemu_plugin_dyn_cb *dyn_cb; - - dyn_cb =3D plugin_get_dyn_cb(arr); - dyn_cb->userp =3D ptr; - dyn_cb->type =3D PLUGIN_CB_INLINE; - dyn_cb->rw =3D rw; - dyn_cb->inline_insn.op =3D op; - dyn_cb->inline_insn.imm =3D imm; -} - void plugin_register_inline_op_on_entry(GArray **arr, enum qemu_plugin_mem_rw rw, enum qemu_plugin_op op, @@ -494,15 +478,10 @@ void qemu_plugin_flush_cb(void) =20 void exec_inline_op(struct qemu_plugin_dyn_cb *cb, int cpu_index) { - char *ptr =3D cb->userp; - size_t elem_size =3D 0; - size_t offset =3D 0; - if (!ptr) { - /* use inline entry */ - ptr =3D cb->inline_insn.entry.score->data->data; - elem_size =3D g_array_get_element_size(cb->inline_insn.entry.score= ->data); - offset =3D cb->inline_insn.entry.offset; - } + char *ptr =3D cb->inline_insn.entry.score->data->data; + size_t elem_size =3D g_array_get_element_size( + cb->inline_insn.entry.score->data); + size_t offset =3D cb->inline_insn.entry.offset; uint64_t *val =3D (uint64_t *)(ptr + offset + cpu_index * elem_size); =20 switch (cb->inline_insn.op) { --=20 2.39.2 From nobody Tue Nov 26 06:56:45 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1709736617; cv=none; d=zohomail.com; s=zohoarc; b=ZaiNrje227n2CABdq3gyD8HucJ9oJTR6hl4BhkHx3Z8DdvTU/etaBkdObT40RKlGH20o5bj64XJZxLAtjauHCBXojQ14SiVQaHr4BxoGPXaRk4ZPNZMHqyOwSZsJ16ADX8LQ16D8+oiVJepx4eL8DwUqKQoWIqN/9JZv3+0rAmc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709736617; 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=jSaTEw7HdvNrh+oHFXPMzlQIiNjmc7BE8/LanxovJAc=; b=aUkGWtx9UlcO51uB2q5pdY0TnFcY8QpszrAp5j3sIbYh5DP8QW9OugNrZ6EcE0/i8RTr0fSD/dAtfqqFtt1qyDoAgIJ92hRNNYyCruqj619AhWwNVBuEy0EEcAFfsL+118W6q6/wdaEUNyJVUpPYhnku76nLShM6DphsFFtic8k= 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 170973661761142.66792344906173; Wed, 6 Mar 2024 06:50:17 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rhsa3-0006kc-2s; Wed, 06 Mar 2024 09:49:15 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rhsZy-0006h9-Nu for qemu-devel@nongnu.org; Wed, 06 Mar 2024 09:49:10 -0500 Received: from mail-wr1-x42b.google.com ([2a00:1450:4864:20::42b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rhsZp-0004Mf-WA for qemu-devel@nongnu.org; Wed, 06 Mar 2024 09:49:10 -0500 Received: by mail-wr1-x42b.google.com with SMTP id ffacd0b85a97d-33d90dfe73cso621532f8f.0 for ; Wed, 06 Mar 2024 06:49:01 -0800 (PST) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id cr11-20020a05600004eb00b0033dd2c3131fsm17580691wrb.65.2024.03.06.06.48.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Mar 2024 06:49:00 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id E358C5F9F3; Wed, 6 Mar 2024 14:40:43 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1709736540; x=1710341340; 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=jSaTEw7HdvNrh+oHFXPMzlQIiNjmc7BE8/LanxovJAc=; b=cFTWRlYHDd4S6pg8OOc3wIiZK70ccK+ru75QlQPg8eW4jvzHivzuJEbHzlGlFfNaNm 9CRrBFp2kP31RRWJ2fTTgZ2PEC0BO/t6QMGT9U5JVfCcqx966ognDKeo3vjyruMgnRtQ rvRnzieB2vqmBaKbUqyQiH5gZlPm1kssDmhfWK8YUdeiCJWK2Qz+iu72mD0eJ7QphM0f KBM6pWa61oO4vxw6tFMxPsULiL/1v98aQ7oZnPUADUVAMzf3nTZ+zlQvUSWdMjwegR+1 3BEtCKhhKTlUhXaiuDTtphF4YQE7w0COoo2dvzGSY1fa4U2dfSN9XLFO6I3+dws2u3u4 2+pg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709736540; x=1710341340; 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=jSaTEw7HdvNrh+oHFXPMzlQIiNjmc7BE8/LanxovJAc=; b=RXTXJP6FPDot2ilLF6lkElf2wFyUv/hAiylgK0omzj3Letlf+Fw2N6Cp1Id4Uiruyz k5/aL633SSi704MCiYu9KI9cYs3/sSrl1vO8nUdZkEUlpfDf/JuQuYsPBdqZFEIVAiG+ sce7JbtRvPBB9QuS50wNYqoRsLVybZFI4mHcauG0aurP4Gn9lZPdE++5JJjFLcG+lT2q KIXnxOVzIrnsGmnuw/tu+yD/M9VpLvo3ompOI51jaY2Efpe0zH0sNslALTELwTYgJfwL uYUwRYyRQI0JeSs6H9geEEI6B8TlXFd1GQJe0iBxP1rbd7Nk8hQXPlcNqljZ4gfJb0XH Zdmg== X-Gm-Message-State: AOJu0YyAD+QGlmWdtU3KTAertAcPN5ymnuSc84LVlfF45xYR8SgB1cLm uiks7zIZNb9vk4VbHKpF5SlzObFh/rhB9mn585LE4ySWHoY5tZRdOJVz/S7Hbc+E37R9mkQydQe K X-Google-Smtp-Source: AGHT+IHOW3aIAwxkRLfxwqMAuH940EfdHziP4jBHM/ilfN/PqPpdaqWZGmewI30bezUVMLG/d3BCow== X-Received: by 2002:a5d:4212:0:b0:33e:835:668b with SMTP id n18-20020a5d4212000000b0033e0835668bmr5030839wrq.22.1709736540304; Wed, 06 Mar 2024 06:49:00 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= , Richard Henderson Subject: [PULL 26/29] disas: introduce show_opcodes Date: Wed, 6 Mar 2024 14:40:38 +0000 Message-Id: <20240306144041.3787188-27-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240306144041.3787188-1-alex.bennee@linaro.org> References: <20240306144041.3787188-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::42b; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x42b.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=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: 1709736618687100001 For plugins we don't expect the raw opcodes in the disassembly. We already deal with this by hand crafting our capstone call but for other diassemblers we need a flag. Introduce show_opcodes which defaults to off. Reviewed-by: Richard Henderson Signed-off-by: Alex Benn=C3=A9e Message-Id: <20240305121005.3528075-27-alex.bennee@linaro.org> diff --git a/include/disas/dis-asm.h b/include/disas/dis-asm.h index 2324f6b1a46..b26867b6417 100644 --- a/include/disas/dis-asm.h +++ b/include/disas/dis-asm.h @@ -396,6 +396,14 @@ typedef struct disassemble_info { /* Command line options specific to the target disassembler. */ char * disassembler_options; =20 + /* + * When true instruct the disassembler it may preface the + * disassembly with the opcodes values if it wants to. This is + * mainly for the benefit of the plugin interface which doesn't want + * that. + */ + bool show_opcodes; + /* Field intended to be used by targets in any way they deem suitable. = */ void *target_info; =20 diff --git a/disas/disas.c b/disas/disas.c index 0d2d06c2ecc..17170d291ec 100644 --- a/disas/disas.c +++ b/disas/disas.c @@ -299,6 +299,7 @@ void disas(FILE *out, const void *code, size_t size) s.info.buffer =3D code; s.info.buffer_vma =3D (uintptr_t)code; s.info.buffer_length =3D size; + s.info.show_opcodes =3D true; =20 if (s.info.cap_arch >=3D 0 && cap_disas_host(&s.info, code, size)) { return; --=20 2.39.2 From nobody Tue Nov 26 06:56:45 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1709736593; cv=none; d=zohomail.com; s=zohoarc; b=nc5hPXL11ADRhiFaTJ3W4XDyx+RlWoigQRJ4MsoMGhJ09uaslvuymBduAmLvkEpKLapJ4qiiJe424DFWq4AIrGeqOinPQXPxj3vIiV/OhCJCaIXW+CNznPRJGE5IOeLpM9vuPSedonmc5n1I7NPnXmHLGMn7ymeOzdRx9qgj4Ns= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709736593; 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=1JocjxziTQra/6RBeDrs7o1Pv+xkFGssg8gkJHYaEJo=; b=UVH7cmGZ+tK3waXhW0cIyLxylu57/UnaIeS3XTnkeFrAyD+wYvDZhtERdedSUT+mivxBPYKTS6Eb9Z48dK+1+TSR6UTT8WDOLCeptSBZ9pqWfMKF+xEAEWVIvZARnKT0nMqw9noRO+zvjR9/6fq0iA4uiTJzhxCDp0kwYvPETWI= 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 1709736593703638.9803317363805; Wed, 6 Mar 2024 06:49:53 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rhsa4-0006nM-AH; Wed, 06 Mar 2024 09:49:16 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rhsZq-0006bk-1U for qemu-devel@nongnu.org; Wed, 06 Mar 2024 09:49:03 -0500 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rhsZn-0004E6-J9 for qemu-devel@nongnu.org; Wed, 06 Mar 2024 09:49:01 -0500 Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-412f8bf3718so3873115e9.0 for ; Wed, 06 Mar 2024 06:48:59 -0800 (PST) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id bg14-20020a05600c3c8e00b004122b7a680dsm21560544wmb.21.2024.03.06.06.48.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Mar 2024 06:48:57 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 0141B5F9F4; Wed, 6 Mar 2024 14:40:44 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1709736537; x=1710341337; 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=1JocjxziTQra/6RBeDrs7o1Pv+xkFGssg8gkJHYaEJo=; b=W6+HXhzf+Hu/xAMuF6Lgxo0UcX53JJzSzimSFIxe8g6x4kWWA9H++nilnvSiNjLsgf U6ziuCcsTPuTcrF/B6b3DpDd1+5MgmH0kTXAamUCsOgrS8ChXMcMrZdAzqIom0faGcSb 2RtqQpAbMWJIeopFX3iUH8/4GhIUJ0ejlEIuZiNZCCTFz1bsMHHoTbgw4Xp298a4Llft 45f82u8xJqlvNY88/G+BHnpCqwNdghVTiqMY56VNnRZwbZvw8qYS8jzs0u0Z8nRmn5dC WlRLqtJlavNXo4ETekvK8Cbzcf0ciSCCcJrSr/GnmY/6OMvOBd+sahHMPQNR7WbNeiJE DCug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709736537; x=1710341337; 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=1JocjxziTQra/6RBeDrs7o1Pv+xkFGssg8gkJHYaEJo=; b=kTekzTPaSMItb5wplsdSJtb0Ha+mOzba3sxVI94sdKG/RHftKQlKYk4C5fxQbx+bO5 ijCx6aPNeMNA/Tz9aWuyHxxyLmRjuiMd9JUYG53NLLMW9lsbgKYU0spb495/TyMrns8h E4lWRF3f+aADTwGJZbcd32HeyPGuJTaAZ3P9B4X0gNxOon+rVxGSY+W9MIB5T6U3dZb4 0dmOrbeFmBpBBGlhl1/Jn5uI/sHRNM18F+eeiyZet61ddH49YDbgI/7ri7Vn703dO/XI B6q/SIBLhHUC4mp0tp/4msTxT/MrT4i+rIFxavvk0uHf6SFhlE7HuC6gidg3Oj6+6iZ3 BOSg== X-Gm-Message-State: AOJu0YwhqLbVjzc5nf8RIc2AmyMtibvR4jmDNwxjTNg6tuErz8+UfWsM KDFW7iXyO9fqEQ/KPmhBcylWnnXfZopmtL6D8IC/GkLEHk/0X95mGFdKDodYECfG9AUnhqNslRD h X-Google-Smtp-Source: AGHT+IFXYoEebiF+4U26Zsyi+7OvJvDsbnJJD9Gbo+YjdlX27SRFYI97uT4iwbIfDxlAn0Gy7SWcmQ== X-Received: by 2002:a05:600c:190a:b0:412:c9e7:202d with SMTP id j10-20020a05600c190a00b00412c9e7202dmr10835994wmq.6.1709736537368; Wed, 06 Mar 2024 06:48:57 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= , Richard Henderson Subject: [PULL 27/29] disas/hppa: honour show_opcodes Date: Wed, 6 Mar 2024 14:40:39 +0000 Message-Id: <20240306144041.3787188-28-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240306144041.3787188-1-alex.bennee@linaro.org> References: <20240306144041.3787188-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::332; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x332.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1709736594369100001 Reviewed-by: Richard Henderson Signed-off-by: Alex Benn=C3=A9e Message-Id: <20240305121005.3528075-28-alex.bennee@linaro.org> diff --git a/disas/hppa.c b/disas/hppa.c index 22dce9b41bb..49e2231ae62 100644 --- a/disas/hppa.c +++ b/disas/hppa.c @@ -1972,9 +1972,11 @@ print_insn_hppa (bfd_vma memaddr, disassemble_info *= info) =20 insn =3D bfd_getb32 (buffer); =20 - info->fprintf_func(info->stream, " %02x %02x %02x %02x ", - (insn >> 24) & 0xff, (insn >> 16) & 0xff, - (insn >> 8) & 0xff, insn & 0xff); + if (info->show_opcodes) { + info->fprintf_func(info->stream, " %02x %02x %02x %02x ", + (insn >> 24) & 0xff, (insn >> 16) & 0xff, + (insn >> 8) & 0xff, insn & 0xff); + } =20 for (i =3D 0; i < NUMOPCODES; ++i) { --=20 2.39.2 From nobody Tue Nov 26 06:56:45 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1709736593; cv=none; d=zohomail.com; s=zohoarc; b=ATMul2otqCODENdCqBqDZ0nqG6VBmM6FM4VlQTdN3lAO+TWx/zBmmq81MElqv0vBfdizMPEvIBsJo/G1XGkkDut0Qj1CmetmjPXr6vRkNn5A5j+YGkG6b3T4AugohvTKJvIGSxVaCOOkwR0EeCVDBFHfKsCCh+y9lSDygSBAAtQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709736593; 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=6J3ZwnAK+ALQL60EUhgyEtMB8C5fHpZxHXot9QnmFTw=; b=gLe521UEgW3VIWgSc/MpAaW5o/Mce5e5CEl08jFJKeqDLEXWitC0LhrZy8jLzi0JoB+eTAu50Pslu6mV0olB5AUotO1p0GiQbWoylppMhCOhhe2ckzJopyQEWpfbB+KEDysCU8yKbsjIvAeArKSrzBch+v+S5wfnemUdCNTSMAA= 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 1709736593520692.2456888163039; Wed, 6 Mar 2024 06:49:53 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rhsZz-0006k1-Q4; Wed, 06 Mar 2024 09:49:11 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rhsZu-0006e9-Bx for qemu-devel@nongnu.org; Wed, 06 Mar 2024 09:49:08 -0500 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 1rhsZq-0004MF-Ez for qemu-devel@nongnu.org; Wed, 06 Mar 2024 09:49:06 -0500 Received: by mail-wr1-x435.google.com with SMTP id ffacd0b85a97d-33e17342ea7so3737227f8f.2 for ; Wed, 06 Mar 2024 06:49:02 -0800 (PST) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id az23-20020adfe197000000b0033e4403c6a9sm7039586wrb.22.2024.03.06.06.48.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Mar 2024 06:48:57 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 132365F9FA; Wed, 6 Mar 2024 14:40:44 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1709736540; x=1710341340; 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=6J3ZwnAK+ALQL60EUhgyEtMB8C5fHpZxHXot9QnmFTw=; b=TF2nCDUlt7aeRNT3pGcuXBa6/sleXVq7XSPXbrLGP7I4Gwk7cF9fdMzXsdqXMV2/u+ UXh7boYSVdLFJRL99MVH/tc5Buh2GXSW/LmcgNAq9jU+uNB5ujQ3Ht6/9Fgcr3vWnRKg 420EzTxoJHwCE2cBXyTpBdjM7lVFIfGiP4/f8PYOZXKv7UNAg9BrMlOMgjswiSlgHqGf KKy90BWtPfF2cPpGFVdLxslft12/0EFJ/mwGPww3U63/HY0jB5V+/ack+84nvMRfMAuY cMyJj0Ggq64c+ylxVIfS3iQb3Q7beqJ+lz+I1DgkMniZYA9p8PWgl3G5XEh0EUSVfAcY /GiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709736540; x=1710341340; 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=6J3ZwnAK+ALQL60EUhgyEtMB8C5fHpZxHXot9QnmFTw=; b=shZh2bvjnmBRFNYpBdhNRtR7Slc1XRD72pgXL8Bo5Bk3PEDPohecKZEYCniq9niZnf jAz8z+VoYwLnKYoAObDTcIY074iZHJ7StOio5bLIs0eAtvfSXrkvRMsI9fkONlKtco5n Scwbs2U4kXjveSjjzvrIprBtzPZpqcnmoco2asclPtOiMaDamShI0vFIgeVEPyJjilWl hDaZ2DqpM08OEAcm6o9jzs+CJy+ubBsv6Fbxn/oehichVhP1+Kyp6eaguo5k/SAH4Lo1 Cz19yDTstRZqvSR/KXXleThNIoysnleEBAg+dUPDXxMcMGbGePvwmU6HzQtc2i7oSZVs TVGA== X-Gm-Message-State: AOJu0Yya+vivNDkO0lNycBm0LswSU/SS4ThzvqrORndl/nGhgjfwlESP /NMmEcM7DxlLV+sE6356onrZOkydZAsgMVSysT+HKeMubluPVjPmIuGpars4jQlTFFVdCCZV2NY U X-Google-Smtp-Source: AGHT+IFey4MwKpp+UrR+vxXokP/QbnAq5N2iEXlOLcWGFIg/9c2BZA7GB/q/0Jr40Rf9Ygr/3HJNqw== X-Received: by 2002:adf:a1d2:0:b0:33e:5da6:36c3 with SMTP id v18-20020adfa1d2000000b0033e5da636c3mr222208wrv.5.1709736539990; Wed, 06 Mar 2024 06:48:59 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= , Richard Henderson , Song Gao Subject: [PULL 28/29] target/loongarch: honour show_opcodes when disassembling Date: Wed, 6 Mar 2024 14:40:40 +0000 Message-Id: <20240306144041.3787188-29-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240306144041.3787188-1-alex.bennee@linaro.org> References: <20240306144041.3787188-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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1709736594598100003 This makes the output suitable when used for plugins. Reviewed-by: Richard Henderson Signed-off-by: Alex Benn=C3=A9e Message-Id: <20240305121005.3528075-29-alex.bennee@linaro.org> diff --git a/target/loongarch/disas.c b/target/loongarch/disas.c index 2040f3e44db..63989a6282d 100644 --- a/target/loongarch/disas.c +++ b/target/loongarch/disas.c @@ -120,10 +120,15 @@ static const char *get_csr_name(unsigned num) csr_names[num] : "Undefined CSR"; } =20 -#define output(C, INSN, FMT, ...) \ -{ \ - (C)->info->fprintf_func((C)->info->stream, "%08x %-9s\t" FMT, \ - (C)->insn, INSN, ##__VA_ARGS__); \ +#define output(C, INSN, FMT, ...) \ + { \ + if ((C)->info->show_opcodes) { \ + (C)->info->fprintf_func((C)->info->stream, "%08x %-9s\t" FMT,\ + (C)->insn, INSN, ##__VA_ARGS__); \ + } else { \ + (C)->info->fprintf_func((C)->info->stream, "%-9s\t" FMT, \ + INSN, ##__VA_ARGS__); \ + } \ } =20 #include "decode-insns.c.inc" --=20 2.39.2 From nobody Tue Nov 26 06:56:45 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1709736561; cv=none; d=zohomail.com; s=zohoarc; b=EEquIXxcntMSgj/zA8ADzRA4rSJTpB5RZW1UcKhHmSiwYDfo95OVSbTbs3FqKgIpwZLzQy71TX2/X6JZ1pUT4NcsgFUcwg4TXc7JI84+EWFFysb1UNYYGnu4gKNBA0AoTAH2BZsgxhxc6uBmQdsTqA/qgfRqesO3ehsZGUKGruM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709736561; 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=wx2eJ+KDhes0tXleUJeO3uNoYSnGN+NK8RX0V99627k=; b=gIuO1YdXME0TL3l/+SY/Y9k0OhmRg8ORRPMPvsu7eGloCr2vGKXMgboYk+HQ8pm30/fWjQSDAYNXnMbozUro7QCfoBlznHvtCYa6XalBN6R2lU/NLl7PV5RpEJGWrTmQPCqLv9jzwm/dfje4SHlBYfh1gUwOAff3l4fB4HS+40w= 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 1709736561462714.4739813792662; Wed, 6 Mar 2024 06:49:21 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rhsZx-0006fq-6n; Wed, 06 Mar 2024 09:49:09 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rhsZo-0006bc-Pq for qemu-devel@nongnu.org; Wed, 06 Mar 2024 09:49:01 -0500 Received: from mail-wr1-x42d.google.com ([2a00:1450:4864:20::42d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rhsZn-0004EA-8h for qemu-devel@nongnu.org; Wed, 06 Mar 2024 09:49:00 -0500 Received: by mail-wr1-x42d.google.com with SMTP id ffacd0b85a97d-33d6f26ff33so775623f8f.0 for ; Wed, 06 Mar 2024 06:48:58 -0800 (PST) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id bp16-20020a5d5a90000000b0033e0567e90bsm18436009wrb.5.2024.03.06.06.48.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Mar 2024 06:48:57 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 2609A5F9FB; Wed, 6 Mar 2024 14:40:44 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1709736537; x=1710341337; 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=wx2eJ+KDhes0tXleUJeO3uNoYSnGN+NK8RX0V99627k=; b=bzN25o/3dQJz/IHglzntxjO2gU8qSzscQ0OiaZuzrh6/Xvc5ovZL65N1eTLFhR7Mc/ 1AIhjIoPa3o2yx8MyOxqeDViNcqanUuACJon5TgWi7KhMBY+1int7w2gP2RWAMIdKjPq +t7ci6OCFlgDSbunAo8mAeP67yt91Lll2Dk+0h242ZpJ2fqBbA/yZAjHqkvWne7v/f60 EnypX7q2P7lukKhDQaQ5v+vmXP+V7jGj88VVlnRpTyuHmP9XCfdOrWuy9jsuJHOZC3Pm U2FWBGWZ+Cp5dwhwTCsH4E+qtA42lI/8pGFl9fyx0yYE3pd5gjhaFLJNaGYCOjZD4OOm 9iOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709736537; x=1710341337; 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=wx2eJ+KDhes0tXleUJeO3uNoYSnGN+NK8RX0V99627k=; b=sLIgfQYjTPZi1bhHDCPmnzc1Dqd6LLMgZFhpTE8grwrtGAP6WGQ7n01uJ021f3sLGC 1kXnsnPndMgJYX2N1qr8b80ExmaiEJ2vYU4CigqqeReAZc70vVn9HgeAXK0ZW6GIVgsD Tz8XYq1nMcCstY6FeBlrVx+RYuLl1h/tRv3aLAHfk07B6k/CCPxFutnTdE2GY2oZvsSl /E0dd9CeG4a2Od6ENaYdacgE94CNdqvzGlSXUgS9rwadCtJY6kvt16McLFQWqLOA4trx 6pNh8OlIGjxZQFtK1cOgDsh8Tanx/5ovglBwUjBfGqGxwGJ/1JF74upEP9maJIoQ67n1 y9Ow== X-Gm-Message-State: AOJu0YxHAkFacspS2AD5spZ2y5P/t6wxy1tPJ70KE4gtSGlrmKseLm3Z M/ysg5BTqemMcl4DaNj0AqtBTr9XELgYMjZ5L/l/eEaNSAvx+n5Qdzl9WOpEqMg= X-Google-Smtp-Source: AGHT+IFTVngPAPsw1J8AaQ/GYWiUnrS87kLbRDO3qq/CDznmNsQ2muUiwI7c2gJZTpdy0BY54MsRqw== X-Received: by 2002:a5d:6145:0:b0:33e:187e:a5b1 with SMTP id y5-20020a5d6145000000b0033e187ea5b1mr10359305wrt.37.1709736537725; Wed, 06 Mar 2024 06:48:57 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= , Richard Henderson , Palmer Dabbelt , Alistair Francis , qemu-riscv@nongnu.org (open list:RISC-V TCG target) Subject: [PULL 29/29] target/riscv: honour show_opcodes when disassembling Date: Wed, 6 Mar 2024 14:40:41 +0000 Message-Id: <20240306144041.3787188-30-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240306144041.3787188-1-alex.bennee@linaro.org> References: <20240306144041.3787188-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::42d; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x42d.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=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: 1709736561855100001 This makes the output suitable when used for plugins. Reviewed-by: Richard Henderson Signed-off-by: Alex Benn=C3=A9e Message-Id: <20240305121005.3528075-30-alex.bennee@linaro.org> diff --git a/disas/riscv.c b/disas/riscv.c index 8a546d5ea53..e236c8b5b7c 100644 --- a/disas/riscv.c +++ b/disas/riscv.c @@ -5192,19 +5192,21 @@ print_insn_riscv(bfd_vma memaddr, struct disassembl= e_info *info, rv_isa isa) } } =20 - switch (len) { - case 2: - (*info->fprintf_func)(info->stream, INST_FMT_2, inst); - break; - case 4: - (*info->fprintf_func)(info->stream, INST_FMT_4, inst); - break; - case 6: - (*info->fprintf_func)(info->stream, INST_FMT_6, inst); - break; - default: - (*info->fprintf_func)(info->stream, INST_FMT_8, inst); - break; + if (info->show_opcodes) { + switch (len) { + case 2: + (*info->fprintf_func)(info->stream, INST_FMT_2, inst); + break; + case 4: + (*info->fprintf_func)(info->stream, INST_FMT_4, inst); + break; + case 6: + (*info->fprintf_func)(info->stream, INST_FMT_6, inst); + break; + default: + (*info->fprintf_func)(info->stream, INST_FMT_8, inst); + break; + } } =20 disasm_inst(buf, sizeof(buf), isa, memaddr, inst, --=20 2.39.2