From nobody Sat Apr 27 22:25:51 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1544384426024251.02173271583092; Sun, 9 Dec 2018 11:40:26 -0800 (PST) Received: from localhost ([::1]:56399 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gW4wC-0002bV-Pp for importer@patchew.org; Sun, 09 Dec 2018 14:40:24 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33241) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gW4u0-0000Qi-W6 for qemu-devel@nongnu.org; Sun, 09 Dec 2018 14:38:09 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gW4tv-0004w5-TN for qemu-devel@nongnu.org; Sun, 09 Dec 2018 14:38:08 -0500 Received: from wout2-smtp.messagingengine.com ([64.147.123.25]:48825) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gW4tv-0004rS-HD for qemu-devel@nongnu.org; Sun, 09 Dec 2018 14:38:03 -0500 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id C864F9CA; Sun, 9 Dec 2018 14:38:01 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Sun, 09 Dec 2018 14:38:02 -0500 Received: from localhost (flamenco.cs.columbia.edu [128.59.20.216]) by mail.messagingengine.com (Postfix) with ESMTPA id 44AB1102ED; Sun, 9 Dec 2018 14:38:00 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=braap.org; h= from:to:cc:subject:date:message-id:in-reply-to:references; s= mesmtp; bh=7+9XeQHXavr0gaJxWBiVkbgbEdjq4rANuZZrJ5opD9E=; b=yjOPF F6+fNEf6JZHuZjT0TbmqV1Hop+7w3gILfjMrwv8NA6awk0WEytr16ZHCpZFAowM0 1GJfEWeshenIxJhf08qNfy2UWVgAKq4IQ6wbQ91DDp/MdhT9sBbJKyRncmdoUt58 vhBpbuZg35Box2wOKfOvBo50n/8pPU/ItCuI1c= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:date:from:in-reply-to:message-id :references:subject:to:x-me-proxy:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; bh=7+9XeQHXavr0gaJxWBiVkbgbEdjq4 rANuZZrJ5opD9E=; b=jJ7JFxKnurf4pSwTt5p5gQDQI63mUHXk9OTWS7vrW1vwo JoShZCwJaKK4gsFbGJh1dwSJ+QE7r4GveTa8K3kPML0JSR3Eg3vdQapKSsYjAlh5 LS4FOZ8aVKUq5BLvGtKxoPvIuKO1XzSwXjSEEFMwQG3bVzJ0MWdD2KNvok4JmYb4 p4ZQcqqxVZ7Io7U43E2JJSXO7kO9YQejV/AO9G7IaISsEKA0W4PstfPu79fhhtk8 nzPD1mIRTr95+NtDedwdNySiAx5m3Pk1i8ed5SnOHpgbIqL1/UXVJfU8W1ByrSVT 4N02Ya5kJvX/XhTOcBl+4NSt/b854HH8qsJ2fKa7g== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedtkedrudegfedguddvkecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfhuthenuceurghilhhouhhtmecu fedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvufffkf fojghfsedttdertdertddtnecuhfhrohhmpedfgfhmihhlihhoucfirdcuvehothgrfdcu oegtohhtrgessghrrggrphdrohhrgheqnecukfhppeduvdekrdehledrvddtrddvudeine curfgrrhgrmhepmhgrihhlfhhrohhmpegtohhtrgessghrrggrphdrohhrghenucevlhhu shhtvghrufhiiigvpedt X-ME-Proxy: From: "Emilio G. Cota" To: qemu-devel@nongnu.org Date: Sun, 9 Dec 2018 14:37:12 -0500 Message-Id: <20181209193749.12277-2-cota@braap.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181209193749.12277-1-cota@braap.org> References: <20181209193749.12277-1-cota@braap.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 64.147.123.25 Subject: [Qemu-devel] [RFC v2 01/38] trace: expand mem_info:size_shift to 3 bits X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Richard Henderson , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Pavel Dovgalyuk Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This will allow us to trace 16B-long memory accesses. While at it, add some defines for the mem_info bits and simplify trace_mem_get_info by making it a wrapper around trace_mem_build_info. Signed-off-by: Emilio G. Cota Reviewed-by: Alex Benn=C3=A9e --- trace-events | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/trace-events b/trace-events index 4fd2cb4b97..9d65d472d2 100644 --- a/trace-events +++ b/trace-events @@ -151,7 +151,7 @@ vcpu guest_cpu_reset(void) # Access information can be parsed as: # # struct mem_info { -# uint8_t size_shift : 2; /* interpreted as "1 << size_shift" bytes */ +# uint8_t size_shift : 3; /* interpreted as "1 << size_shift" bytes */ # bool sign_extend: 1; /* sign-extended */ # uint8_t endianness : 1; /* 0: little, 1: big */ # bool store : 1; /* wheter it's a store operation */ --=20 2.17.1 From nobody Sat Apr 27 22:25:51 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1544384588063731.2837484031352; Sun, 9 Dec 2018 11:43:08 -0800 (PST) Received: from localhost ([::1]:56414 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gW4yh-0004d3-ME for importer@patchew.org; Sun, 09 Dec 2018 14:42:59 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33234) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gW4u0-0000PS-OW for qemu-devel@nongnu.org; Sun, 09 Dec 2018 14:38:09 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gW4tv-0004wJ-Tq for qemu-devel@nongnu.org; Sun, 09 Dec 2018 14:38:08 -0500 Received: from wout2-smtp.messagingengine.com ([64.147.123.25]:33851) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gW4tv-0004rT-ID for qemu-devel@nongnu.org; Sun, 09 Dec 2018 14:38:03 -0500 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id C8BCB9F6; Sun, 9 Dec 2018 14:38:01 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Sun, 09 Dec 2018 14:38:02 -0500 Received: from localhost (flamenco.cs.columbia.edu [128.59.20.216]) by mail.messagingengine.com (Postfix) with ESMTPA id 76DE1102E4; Sun, 9 Dec 2018 14:38:00 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=braap.org; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; s=mesmtp; bh=RO6AdMeRzB8uXhmNVbOmisiwY7108bcPlFRL6HvBlvE=; b=RPc4u0PlWh/y UiRFxmJeiDA05Kt+nAcIYkJZ98CSuM6daW6Nqr3yYUWdq2mVkdTrCqp6LrZ826Lk bxR5745OtvYOb/UwIyBtnkQbNKNDJWRcNLdyy/CMpE0ZclCh7Bg00GPKITlU82AR bI7hmwa1Z7Uf94RbjbUVzbPL3KG1vg8= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; bh=RO6AdMeRzB8uXhmNVbOmisiwY7108bcPlFRL6HvBl vE=; b=vmGjPpG4gkW7gvvScfyTg45YedTbZxLS0BtIVYoWrkYRqrDCYSRbiyDpi 65vFRrMii5KpzUQeREyTZApwXyZRAYiX1jFfg0f+ipLJuPYo50qDAC/5owUvpAVT bgmpKgBaszRtyRWvH9CGISKRgjb18254GDcLtcoQqM7UfyFP48d5vbFppzJAhqTy jM6rACPq3pSXjWBezJVFLOTdAIwBuFle2OQeAfQTRmtvkAnU9BxzIopaE4i38v8W legms30+zr91mCmoJUBiJ5ZYuybxV9HrwKfEobjqtoP7oVGLe81InVkcRahYHhh8 L8LXiEuDblYTO1g4Rx+Fv2Eb+SUPQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedtkedrudegfedguddvkecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfhuthenuceurghilhhouhhtmecu fedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvufffkf fojghfgggtgfesthekredtredtjeenucfhrhhomhepfdfgmhhilhhiohcuifdrucevohht rgdfuceotghothgrsegsrhgrrghprdhorhhgqeenucfkphepuddvkedrheelrddvtddrvd duieenucfrrghrrghmpehmrghilhhfrhhomheptghothgrsegsrhgrrghprdhorhhgnecu vehluhhsthgvrhfuihiivgeptd X-ME-Proxy: From: "Emilio G. Cota" To: qemu-devel@nongnu.org Date: Sun, 9 Dec 2018 14:37:13 -0500 Message-Id: <20181209193749.12277-3-cota@braap.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181209193749.12277-1-cota@braap.org> References: <20181209193749.12277-1-cota@braap.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 64.147.123.25 Subject: [Qemu-devel] [RFC v2 02/38] tcg/README: fix typo s/afterwise/afterwards/ X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Richard Henderson , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Pavel Dovgalyuk Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Afterwise is "wise after the fact", as in "hindsight". Here we meant "afterwards" (as in "subsequently"). Fix it. Reviewed-by: Alex Benn=C3=A9e Signed-off-by: Emilio G. Cota --- tcg/README | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tcg/README b/tcg/README index d22ee084b8..3fa8a7059f 100644 --- a/tcg/README +++ b/tcg/README @@ -101,7 +101,7 @@ This can be overridden using the following function mod= ifiers: canonical locations before calling the helper. - TCG_CALL_NO_WRITE_GLOBALS means that the helper does not modify any glob= als. They will only be saved to their canonical location before calling helpe= rs, - but they won't be reloaded afterwise. + but they won't be reloaded afterwards. - TCG_CALL_NO_SIDE_EFFECTS means that the call to the function is removed = if the return value is not used. =20 --=20 2.17.1 From nobody Sat Apr 27 22:25:51 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1544384986236132.6585975199731; Sun, 9 Dec 2018 11:49:46 -0800 (PST) Received: from localhost ([::1]:56444 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gW557-0004N6-Dw for importer@patchew.org; Sun, 09 Dec 2018 14:49:37 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33236) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gW4u0-0000Pv-RE for qemu-devel@nongnu.org; Sun, 09 Dec 2018 14:38:10 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gW4tv-0004wA-Tr for qemu-devel@nongnu.org; Sun, 09 Dec 2018 14:38:08 -0500 Received: from wout2-smtp.messagingengine.com ([64.147.123.25]:59677) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gW4tv-0004rO-Gw for qemu-devel@nongnu.org; Sun, 09 Dec 2018 14:38:03 -0500 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id C9CFDC13; Sun, 9 Dec 2018 14:38:01 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Sun, 09 Dec 2018 14:38:02 -0500 Received: from localhost (flamenco.cs.columbia.edu [128.59.20.216]) by mail.messagingengine.com (Postfix) with ESMTPA id A9B8D102DD; Sun, 9 Dec 2018 14:38:00 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=braap.org; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; s=mesmtp; bh=9yclHz54Onv+ocU7NqoJlgPNmHuaw9IZTcgoqLlwMJY=; b=M7yOlbHKEK2T 2bQ+9M9+ScsrBNy4Lh9LHb15FEVVjO8rbqdcGO8MgqgVsNAxzzm/cwwbRTIuobuG Zpbz5i4DPaJzks5b23GGWJ05IFHUqEyeZFi0plHNN0DUnqtdbZovVZ4qCAGxVPFe WMgBiQCCaxBeUpB2uz83od7+u0DN0p4= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; bh=9yclHz54Onv+ocU7NqoJlgPNmHuaw9IZTcgoqLlwM JY=; b=D8jJY2FJZdhXvRNVTfm2RwQEyK4Ms2EIZnQV3kwkLBYbRqrJqKocdmCh4 7BhoyEMuzzDfTKGFVWYCVU+EFPXiEb0czm4Sbylz+8ybaET6VVCVPHblMr73Cn23 fbjcRCT5k6bHKdyB5UjJoeiVA/3AQHbIVhdZTLNII64w88QiIT8RT5wRN9jIZn1X MZrwMa9iV6dih1XB6s671loE5EKmEnl3CW0vPT0LRNsLr1k037QLR3AierRnmGx3 W4fJnFkB2O9m60o1jVDs4w1+zyj7mUHm7zFI9D603nFyou+YrhxLJK9a4U4cj6ls xQX8EQKVqzbpwHrcoAX3pWa4jyP4Q== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedtkedrudegfedguddvkecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfhuthenuceurghilhhouhhtmecu fedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvufffkf fojghfgggtgfesthekredtredtjeenucfhrhhomhepfdfgmhhilhhiohcuifdrucevohht rgdfuceotghothgrsegsrhgrrghprdhorhhgqeenucfkphepuddvkedrheelrddvtddrvd duieenucfrrghrrghmpehmrghilhhfrhhomheptghothgrsegsrhgrrghprdhorhhgnecu vehluhhsthgvrhfuihiivgeptd X-ME-Proxy: From: "Emilio G. Cota" To: qemu-devel@nongnu.org Date: Sun, 9 Dec 2018 14:37:14 -0500 Message-Id: <20181209193749.12277-4-cota@braap.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181209193749.12277-1-cota@braap.org> References: <20181209193749.12277-1-cota@braap.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 64.147.123.25 Subject: [Qemu-devel] [RFC v2 03/38] cpu: introduce cpu_in_exclusive_work_context() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Richard Henderson , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Pavel Dovgalyuk Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Suggested-by: Alex Benn=C3=A9e Signed-off-by: Emilio G. Cota Reviewed-by: Alex Benn=C3=A9e --- include/qom/cpu.h | 13 +++++++++++++ cpus-common.c | 2 ++ 2 files changed, 15 insertions(+) diff --git a/include/qom/cpu.h b/include/qom/cpu.h index 772cc960fe..fab18089db 100644 --- a/include/qom/cpu.h +++ b/include/qom/cpu.h @@ -349,6 +349,7 @@ struct CPUState { bool thread_kicked; bool crash_occurred; bool exit_request; + bool in_exclusive_work_context; uint32_t cflags_next_tb; /* updates protected by BQL */ uint32_t interrupt_request; @@ -913,6 +914,18 @@ void async_run_on_cpu_no_bql(CPUState *cpu, run_on_cpu= _func func, */ void async_safe_run_on_cpu(CPUState *cpu, run_on_cpu_func func, run_on_cpu= _data data); =20 +/** + * cpu_in_exclusive_work_context() + * @cpu: The vCPU to check + * + * Returns true if @cpu is an exclusive work context, which has + * previously been queued via async_safe_run_on_cpu(). + */ +static inline bool cpu_in_exclusive_work_context(const CPUState *cpu) +{ + return cpu->in_exclusive_work_context; +} + /** * qemu_get_cpu: * @index: The CPUState@cpu_index value of the CPU to obtain. diff --git a/cpus-common.c b/cpus-common.c index 232cb12c46..d6ea42c80c 100644 --- a/cpus-common.c +++ b/cpus-common.c @@ -370,7 +370,9 @@ static void process_queued_cpu_work_locked(CPUState *cp= u) qemu_mutex_unlock_iothread(); } start_exclusive(); + cpu->in_exclusive_work_context =3D true; wi->func(cpu, wi->data); + cpu->in_exclusive_work_context =3D false; end_exclusive(); if (has_bql) { qemu_mutex_lock_iothread(); --=20 2.17.1 From nobody Sat Apr 27 22:25:51 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1544384426368577.3351743734581; Sun, 9 Dec 2018 11:40:26 -0800 (PST) Received: from localhost ([::1]:56400 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gW4wD-0002bb-4D for importer@patchew.org; Sun, 09 Dec 2018 14:40:25 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33237) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gW4u0-0000Pz-RV for qemu-devel@nongnu.org; Sun, 09 Dec 2018 14:38:09 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gW4tv-0004wG-Tv for qemu-devel@nongnu.org; Sun, 09 Dec 2018 14:38:08 -0500 Received: from wout2-smtp.messagingengine.com ([64.147.123.25]:36937) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gW4tv-0004rR-Gv for qemu-devel@nongnu.org; Sun, 09 Dec 2018 14:38:03 -0500 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id CC218C33; Sun, 9 Dec 2018 14:38:01 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Sun, 09 Dec 2018 14:38:02 -0500 Received: from localhost (flamenco.cs.columbia.edu [128.59.20.216]) by mail.messagingengine.com (Postfix) with ESMTPA id DC978102F1; Sun, 9 Dec 2018 14:38:00 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=braap.org; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; s=mesmtp; bh=B6I+oQeWGARcQT8TFgq/ftgShWfGbi/NNk21D0P8nCo=; b=f972xp/TTa+3 hdCUyD3y1zU5s55C/q2j8DBgQp8MtceGuprm6tJQk5oX0/D6F0PJcqiSJkU1ybTf ieOzmsbupMowzmFGZGEcEG4f1lXDcQhyPr1eddyWRbozaK3UQPB4wL94623xqFxR aCkRXEaqGSX7yHB8CQzMnCVukolsivk= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; bh=B6I+oQeWGARcQT8TFgq/ftgShWfGbi/NNk21D0P8n Co=; b=Beq7PGZXLXIwuj6srbOCQDhvXaGY4KIlzvvJFIrSVHqVPnbmB+rwfLMlV rSvBBYNuuN4ox5jXejX84RXj1D3nh0LWsWpnx3LG0sUItNpRhDXud0J0EOhXpl+u ZhBv53UTl6l6QvuqhY93E9EAS+zvw/3lNGtQclk33DsGd9+B5fBY6zD10qlK9dgX 2Jiav3pGPXtpPtWs0EiEtOmXX5rDgsNZPrgpZhm1LTnLnHiYUdUa7UyPs1XTkOK0 oGLTA496AoQEqIYIbOmaidZydIsxx0wWwauWbh1yS++i8i/ALVMtz+ZoE71mAfXr ufaUV5nmBQ6sJi6uySTUqBfkgAqOQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedtkedrudegfedguddvkecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfhuthenuceurghilhhouhhtmecu fedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvufffkf fojghfgggtgfesthekredtredtjeenucfhrhhomhepfdfgmhhilhhiohcuifdrucevohht rgdfuceotghothgrsegsrhgrrghprdhorhhgqeenucfkphepuddvkedrheelrddvtddrvd duieenucfrrghrrghmpehmrghilhhfrhhomheptghothgrsegsrhgrrghprdhorhhgnecu vehluhhsthgvrhfuihiivgeptd X-ME-Proxy: From: "Emilio G. Cota" To: qemu-devel@nongnu.org Date: Sun, 9 Dec 2018 14:37:15 -0500 Message-Id: <20181209193749.12277-5-cota@braap.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181209193749.12277-1-cota@braap.org> References: <20181209193749.12277-1-cota@braap.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 64.147.123.25 Subject: [Qemu-devel] [RFC v2 04/38] translate-all: use cpu_in_exclusive_work_context() in tb_flush X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Richard Henderson , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Pavel Dovgalyuk Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" tb_flush will be called by the plugin module from a safe work environment. Prepare for that. Suggested-by: Alex Benn=C3=A9e Signed-off-by: Emilio G. Cota Reviewed-by: Alex Benn=C3=A9e --- accel/tcg/translate-all.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index 038d82fdb5..62d5e13185 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -1269,8 +1269,13 @@ void tb_flush(CPUState *cpu) { if (tcg_enabled()) { unsigned tb_flush_count =3D atomic_mb_read(&tb_ctx.tb_flush_count); - async_safe_run_on_cpu(cpu, do_tb_flush, - RUN_ON_CPU_HOST_INT(tb_flush_count)); + + if (cpu_in_exclusive_work_context(cpu)) { + do_tb_flush(cpu, RUN_ON_CPU_HOST_INT(tb_flush_count)); + } else { + async_safe_run_on_cpu(cpu, do_tb_flush, + RUN_ON_CPU_HOST_INT(tb_flush_count)); + } } } =20 --=20 2.17.1 From nobody Sat Apr 27 22:25:51 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1544384999922496.60256411436865; Sun, 9 Dec 2018 11:49:59 -0800 (PST) Received: from localhost ([::1]:56446 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gW55S-0005Bh-Li for importer@patchew.org; Sun, 09 Dec 2018 14:49:58 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33242) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gW4u0-0000Qk-WA for qemu-devel@nongnu.org; Sun, 09 Dec 2018 14:38:10 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gW4tw-0004zI-UB for qemu-devel@nongnu.org; Sun, 09 Dec 2018 14:38:08 -0500 Received: from wout2-smtp.messagingengine.com ([64.147.123.25]:56077) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gW4tw-0004wU-Ig for qemu-devel@nongnu.org; Sun, 09 Dec 2018 14:38:04 -0500 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id E599FC53; Sun, 9 Dec 2018 14:38:01 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Sun, 09 Dec 2018 14:38:02 -0500 Received: from localhost (flamenco.cs.columbia.edu [128.59.20.216]) by mail.messagingengine.com (Postfix) with ESMTPA id 0FBEF102F2; Sun, 9 Dec 2018 14:38:01 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=braap.org; h= from:to:cc:subject:date:message-id:in-reply-to:references; s= mesmtp; bh=rfJclI7NI++1IdufRjiP12517VE01MU8UhzVle4VSGA=; b=Wdz4D Gf8WFZ+TJFb4QKB3nptCCt4yYGI028a8xu2RUyUzaJYbq8OYWsOJAtXFrBHZedhH r/a0KYx1sGmuKzkodxIFIgF15lBsWAYy+VLTynjERyD9zWVIC4yBR7XSZQTjcSI+ uGwtQZAgekhyrlu43hogqq8PugF+FNu6b6hMxs= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:date:from:in-reply-to:message-id :references:subject:to:x-me-proxy:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; bh=rfJclI7NI++1IdufRjiP12517VE01 MU8UhzVle4VSGA=; b=cPu9K0zdnKHd08MSByvQYb/zs+568bF2u3GQj2PtVojeh jnJuVRXBM/vJb1CYuHtuOcfLjZhtjZRUYxo6lJJ8354nEGNNB5Yu2MT5A0NO+oNx hG4FakXXiY5Z8wUrZGwN8d2OM2MHzoTttZW/ox2oQb5Ey6lCiaWvzAVGBgu69Tob iVgy7XuVl+sMpqzndZZxfsbDxWD8v5/qS+BRloregbyGnE+aITDOVcOkV3ftNBLG MUfGJ2of1w8ppHTu1ENWkJm/yjbRfkgdJCUJadO0dGHjDY9eeuJ/WD43+4M9HmIm TUZNfChh2ITG1rv9sL88XP7Y6cr8fYn8KR35gqh6A== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedtkedrudegfedguddvkecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfhuthenuceurghilhhouhhtmecu fedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvufffkf fojghfsedttdertdertddtnecuhfhrohhmpedfgfhmihhlihhoucfirdcuvehothgrfdcu oegtohhtrgessghrrggrphdrohhrgheqnecuffhomhgrihhnpehgnhhurdhorhhgnecukf hppeduvdekrdehledrvddtrddvudeinecurfgrrhgrmhepmhgrihhlfhhrohhmpegtohht rgessghrrggrphdrohhrghenucevlhhushhtvghrufhiiigvpedt X-ME-Proxy: From: "Emilio G. Cota" To: qemu-devel@nongnu.org Date: Sun, 9 Dec 2018 14:37:16 -0500 Message-Id: <20181209193749.12277-6-cota@braap.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181209193749.12277-1-cota@braap.org> References: <20181209193749.12277-1-cota@braap.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 64.147.123.25 Subject: [Qemu-devel] [RFC v2 05/38] plugin: add user-facing API X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Richard Henderson , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Pavel Dovgalyuk Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Add the API first to ease review. Signed-off-by: Emilio G. Cota --- include/qemu/qemu-plugin.h | 241 +++++++++++++++++++++++++++++++++++++ 1 file changed, 241 insertions(+) create mode 100644 include/qemu/qemu-plugin.h diff --git a/include/qemu/qemu-plugin.h b/include/qemu/qemu-plugin.h new file mode 100644 index 0000000000..6c67211900 --- /dev/null +++ b/include/qemu/qemu-plugin.h @@ -0,0 +1,241 @@ +/* + * Copyright (C) 2017, Emilio G. Cota + * + * License: GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ +#ifndef QEMU_PLUGIN_API_H +#define QEMU_PLUGIN_API_H + +#include +#include + +/* + * For best performance, build the plugin with -fvisibility=3Dhidden so th= at + * QEMU_PLUGIN_LOCAL is implicit. Then, just mark qemu_plugin_install with + * QEMU_PLUGIN_EXPORT. For more info, see + * https://gcc.gnu.org/wiki/Visibility + */ +#if defined _WIN32 || defined __CYGWIN__ + #ifdef BUILDING_DLL + #define QEMU_PLUGIN_EXPORT __declspec(dllexport) + #else + #define QEMU_PLUGIN_EXPORT __declspec(dllimport) + #endif + #define QEMU_PLUGIN_LOCAL +#else + #if __GNUC__ >=3D 4 + #define QEMU_PLUGIN_EXPORT __attribute__((visibility("default"))) + #define QEMU_PLUGIN_LOCAL __attribute__((visibility("hidden"))) + #else + #define QEMU_PLUGIN_EXPORT + #define QEMU_PLUGIN_LOCAL + #endif +#endif + +typedef uint64_t qemu_plugin_id_t; + +/** + * qemu_plugin_install - Install a plugin + * @id: this plugin's opaque ID + * @argc: number of arguments + * @argv: array of arguments (@argc elements) + * + * All plugins must export this symbol. + * + * Note: @argv is freed after this function returns. + */ +QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_id_t id, int argc, + char **argv); + +typedef void (*qemu_plugin_uninstall_cb_t)(qemu_plugin_id_t id); + +/** + * qemu_plugin_uninstall - Uninstall a plugin + * @id: this plugin's opaque ID + * @cb: callback to be called once the plugin has been removed + * + * Do NOT assume that the plugin has been uninstalled once this + * function returns. Plugins are uninstalled asynchronously, + * and therefore the given plugin might still receive callbacks + * from prior subscriptions _until_ @cb is called. + */ +void qemu_plugin_uninstall(qemu_plugin_id_t id, qemu_plugin_uninstall_cb_t= cb); + +typedef void (*qemu_plugin_simple_cb_t)(qemu_plugin_id_t id); + +typedef void (*qemu_plugin_udata_cb_t)(qemu_plugin_id_t id, void *userdata= ); + +typedef void (*qemu_plugin_vcpu_simple_cb_t)(qemu_plugin_id_t id, + unsigned int vcpu_index); + +typedef void (*qemu_plugin_vcpu_udata_cb_t)(unsigned int vcpu_index, + void *userdata); + +/** + * qemu_plugin_register_vcpu_init_cb - register a vCPU initialization call= back + * @id: plugin ID + * @cb: callback function + * + * The @cb function is called every time a vCPU is initialized. + * + * See also: qemu_plugin_register_vcpu_exit_cb() + */ +void qemu_plugin_register_vcpu_init_cb(qemu_plugin_id_t id, + qemu_plugin_vcpu_simple_cb_t cb); + +/** + * qemu_plugin_register_vcpu_exit_cb - register a vCPU exit callback + * @id: plugin ID + * @cb: callback function + * + * The @cb function is called every time a vCPU exits. + * + * See also: qemu_plugin_register_vcpu_init_cb() + */ +void qemu_plugin_register_vcpu_exit_cb(qemu_plugin_id_t id, + qemu_plugin_vcpu_simple_cb_t cb); + +void qemu_plugin_register_vcpu_idle_cb(qemu_plugin_id_t id, + qemu_plugin_vcpu_simple_cb_t cb); + +void qemu_plugin_register_vcpu_resume_cb(qemu_plugin_id_t id, + qemu_plugin_vcpu_simple_cb_t cb); + +struct qemu_plugin_tb; +struct qemu_plugin_insn; + +enum qemu_plugin_cb_flags { + QEMU_PLUGIN_CB_NO_REGS, /* callback does not access the CPU's regs */ + QEMU_PLUGIN_CB_R_REGS, /* callback reads the CPU's regs */ + QEMU_PLUGIN_CB_RW_REGS, /* callback reads and writes the CPU's regs */ +}; + +enum qemu_plugin_mem_rw { + QEMU_PLUGIN_MEM_R =3D 1, + QEMU_PLUGIN_MEM_W, + QEMU_PLUGIN_MEM_RW, +}; + +typedef void (*qemu_plugin_vcpu_tb_trans_cb_t)(qemu_plugin_id_t id, + unsigned int vcpu_index, + struct qemu_plugin_tb *tb); + +void qemu_plugin_register_vcpu_tb_trans_cb(qemu_plugin_id_t id, + qemu_plugin_vcpu_tb_trans_cb_t = cb); + +/* can only call from tb_trans_cb callback */ +void qemu_plugin_register_vcpu_tb_exec_cb(struct qemu_plugin_tb *tb, + qemu_plugin_vcpu_udata_cb_t cb, + enum qemu_plugin_cb_flags flags, + void *userdata); + +enum qemu_plugin_op { + QEMU_PLUGIN_INLINE_ADD_U64, +}; + +void qemu_plugin_register_vcpu_tb_exec_inline(struct qemu_plugin_tb *tb, + enum qemu_plugin_op op, + void *ptr, uint64_t 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, + void *userdata); + +void qemu_plugin_register_vcpu_insn_exec_inline(struct qemu_plugin_insn *i= nsn, + enum qemu_plugin_op op, + void *ptr, uint64_t imm); + +typedef uint32_t qemu_plugin_meminfo_t; + +unsigned qemu_plugin_mem_size_shift(qemu_plugin_meminfo_t info); +bool qemu_plugin_mem_is_sign_extended(qemu_plugin_meminfo_t info); +bool qemu_plugin_mem_is_big_endian(qemu_plugin_meminfo_t info); +bool qemu_plugin_mem_is_store(qemu_plugin_meminfo_t info); + +typedef void +(*qemu_plugin_vcpu_mem_cb_t)(unsigned int vcpu_index, + qemu_plugin_meminfo_t info, uint64_t vaddr, + void *userdata); + +typedef void +(*qemu_plugin_vcpu_mem_haddr_cb_t)(unsigned int vcpu_index, + qemu_plugin_meminfo_t info, uint64_t va= ddr, + void *haddr, void *userdata); + +void qemu_plugin_register_vcpu_mem_cb(struct qemu_plugin_insn *insn, + qemu_plugin_vcpu_mem_cb_t cb, + enum qemu_plugin_cb_flags flags, + enum qemu_plugin_mem_rw rw, + void *userdata); + +void qemu_plugin_register_vcpu_mem_haddr_cb(struct qemu_plugin_insn *insn, + qemu_plugin_vcpu_mem_haddr_cb_= t cb, + enum qemu_plugin_cb_flags flag= s, + enum qemu_plugin_mem_rw rw, + void *userdata); + +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); + +uint64_t qemu_plugin_ram_addr_from_host(void *haddr); + +typedef void +(*qemu_plugin_vcpu_syscall_cb_t)(qemu_plugin_id_t id, unsigned int vcpu_in= dex, + int64_t num, uint64_t a1, uint64_t a2, + uint64_t a3, uint64_t a4, uint64_t a5, + uint64_t a6, uint64_t a7, uint64_t a8); + +void qemu_plugin_register_vcpu_syscall_cb(qemu_plugin_id_t id, + qemu_plugin_vcpu_syscall_cb_t cb= ); + +typedef void +(*qemu_plugin_vcpu_syscall_ret_cb_t)(qemu_plugin_id_t id, unsigned int vcp= u_idx, + int64_t num, int64_t ret); + +void +qemu_plugin_register_vcpu_syscall_ret_cb(qemu_plugin_id_t id, + qemu_plugin_vcpu_syscall_ret_cb_t= cb); + +size_t qemu_plugin_tb_n_insns(const struct qemu_plugin_tb *tb); + +uint64_t qemu_plugin_tb_vaddr(const struct qemu_plugin_tb *tb); + +struct qemu_plugin_insn * +qemu_plugin_tb_get_insn(const struct qemu_plugin_tb *tb, size_t idx); + +const void *qemu_plugin_insn_data(const struct qemu_plugin_insn *insn); + +size_t qemu_plugin_insn_size(const struct qemu_plugin_insn *insn); + +uint64_t qemu_plugin_insn_vaddr(const struct qemu_plugin_insn *insn); +void *qemu_plugin_insn_haddr(const struct qemu_plugin_insn *insn); + +/** + * qemu_plugin_vcpu_for_each - iterate over the existing vCPU + * @id: plugin ID + * @cb: callback function + * + * The @cb function is called once for each existing vCPU. + * + * See also: qemu_plugin_register_vcpu_init_cb() + */ +void qemu_plugin_vcpu_for_each(qemu_plugin_id_t id, + qemu_plugin_vcpu_simple_cb_t cb); + +void qemu_plugin_register_flush_cb(qemu_plugin_id_t id, + qemu_plugin_simple_cb_t cb); + +void qemu_plugin_register_atexit_cb(qemu_plugin_id_t id, + qemu_plugin_udata_cb_t cb, void *userd= ata); + +/* returns -1 in user-mode */ +int qemu_plugin_n_vcpus(void); + +/* returns -1 in user-mode */ +int qemu_plugin_n_max_vcpus(void); + +#endif /* QEMU_PLUGIN_API_H */ --=20 2.17.1 From nobody Sat Apr 27 22:25:51 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1544384620404350.12101168458605; Sun, 9 Dec 2018 11:43:40 -0800 (PST) Received: from localhost ([::1]:56417 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gW4zK-00057D-Q3 for importer@patchew.org; Sun, 09 Dec 2018 14:43:38 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33257) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gW4u1-0000SV-DM for qemu-devel@nongnu.org; Sun, 09 Dec 2018 14:38:13 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gW4tx-0004zm-5f for qemu-devel@nongnu.org; Sun, 09 Dec 2018 14:38:09 -0500 Received: from wout2-smtp.messagingengine.com ([64.147.123.25]:40805) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gW4tw-0004wX-Je for qemu-devel@nongnu.org; Sun, 09 Dec 2018 14:38:04 -0500 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id 644BDC64; Sun, 9 Dec 2018 14:38:02 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Sun, 09 Dec 2018 14:38:02 -0500 Received: from localhost (flamenco.cs.columbia.edu [128.59.20.216]) by mail.messagingengine.com (Postfix) with ESMTPA id 4B71E102F3; Sun, 9 Dec 2018 14:38:01 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=braap.org; h= from:to:cc:subject:date:message-id:in-reply-to:references; s= mesmtp; bh=C2ujIhph0qw0+irC5qYbJ+kOH9WvYsWPFjWc5kQ9Tk8=; b=VJRGH 8XayrmPx0k02+cXfo0LWX7fu5+m1YUoWvgniyHKhMfyCRDr5Ct/sNfw1Pinx9g93 DuYWGNIElRwtGT7hiTmOXzfN+lXMRUizdddM4yQzfd4RT+M6TqnqpE/lyM12Ts46 Ub1LY/+tExR6M1za/HPFZlKYBt8iWT1xaYcBps= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:date:from:in-reply-to:message-id :references:subject:to:x-me-proxy:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; bh=C2ujIhph0qw0+irC5qYbJ+kOH9WvY sWPFjWc5kQ9Tk8=; b=CH6vKX2at0PWl/i5zyEPv2SPspqeldcHJezJsKaxvtknL jIlzoqi0vtlJ8j9LW3flXSDw60NVXBZse37DgiYR1SKzuFzXIj4/fYCGYUiqWXbx XB64TkJ1k/Ms5rXgOTrrb1vlk0Q9sa2SWVc1uOLeX4mMnYTPE17YNoI2OPYpf2tC jdhA+EDgOJ6lhBj1P1/Ns7ed+DvXx3pZyAQ2plB4K8XczJRWvxhggJKSDkbESWPG xMaRL/f59X6Ohqs2k7YTtMC8MOnfoNKOfGhkzlPsRb0tXd5U30q7fVdKsrj0NZpU qianrAI4OwKq6sB7gWyANCXRxXuJENqs7lKxByD6Q== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedtkedrudegfedguddvkecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfhuthenuceurghilhhouhhtmecu fedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvufffkf fojghfsedttdertdertddtnecuhfhrohhmpedfgfhmihhlihhoucfirdcuvehothgrfdcu oegtohhtrgessghrrggrphdrohhrgheqnecuffhomhgrihhnpeifihhkihhpvgguihgrrd horhhgnecukfhppeduvdekrdehledrvddtrddvudeinecurfgrrhgrmhepmhgrihhlfhhr ohhmpegtohhtrgessghrrggrphdrohhrghenucevlhhushhtvghrufhiiigvpedt X-ME-Proxy: From: "Emilio G. Cota" To: qemu-devel@nongnu.org Date: Sun, 9 Dec 2018 14:37:17 -0500 Message-Id: <20181209193749.12277-7-cota@braap.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181209193749.12277-1-cota@braap.org> References: <20181209193749.12277-1-cota@braap.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 64.147.123.25 Subject: [Qemu-devel] [RFC v2 06/38] plugin: add core code X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Richard Henderson , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Pavel Dovgalyuk Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Some design requirements/goals: - Make sure we cannot deadlock, particularly under MTTCG. For this, we acquire a lock when called from plugin code, and keep RCU lists of callbacks so that we do not have to hold the lock when calling the callbacks. This is also for performance, since some callbacks (e.g. memory access callbacks) might be called very frequently. * A consequence of this is that we keep our own list of CPUs, so that we do not have to worry about locking order wrt cpu_list_lock. * Use a recursive lock, since we can get registration calls from callbacks. - Support as many plugins as the user wants (e.g. -plugin foo -plugin bar), just like other tools (e.g. dynamorio) do. - Support the uninstallation of a plugin at any time (e.g. from plugin callbacks). - Avoid malicious plugins from abusing the API. This is done by: * Adding a qemu_plugin_id_t that all calls need to use. This is a unique id per plugin. * Hiding CPUState * under cpu_index. Plugin code can keep per-vcpu data by using said index (say to index an array). * Only exporting the relevant qemu_plugin symbols to the plugins by passing --dynamic-file to the linker (when supported), instead of exporting all symbols with -rdynamic. - Performance: registering/unregistering callbacks is "slow", since it takes a lock. But this is very infrequent; we want performance when calling (or not calling) callbacks, not when registering them. Using RCU is great for this. The only difficulty is when uninstalling a plugin, where some callbacks might still be called after the uninstall returns. An alternative would be to use r/w locks, but that would complicate code quite a bit for very little gain. In any case, I suspect most plugins will just run until QEMU exits. Some design decisions: - I considered registering callbacks per-vcpu, but really I don't see the use case for it (would complicate the API and 99% of plugins won't care, = so I'd rather make that 1% slower by letting them discard unwanted callbacks= ). - Last, 'plugin' vs. 'instrumentation' naming: I think instrumentation is a subset of the functionality that plugins can provide. IOW, in the future not all plugins might be considered instrumentation, even if currently my goal is to use them for that purpose. Signed-off-by: Emilio G. Cota --- Makefile | 7 +- Makefile.target | 2 + include/qemu/plugin.h | 253 ++++++++++ include/qom/cpu.h | 6 + plugin.c | 1030 +++++++++++++++++++++++++++++++++++++++++ 5 files changed, 1297 insertions(+), 1 deletion(-) create mode 100644 include/qemu/plugin.h create mode 100644 plugin.c diff --git a/Makefile b/Makefile index f2947186a4..9cb3076d84 100644 --- a/Makefile +++ b/Makefile @@ -862,8 +862,10 @@ ifneq (,$(findstring qemu-ga,$(TOOLS))) endif endif =20 +install-includedir: + $(INSTALL_DIR) "$(DESTDIR)$(includedir)" =20 -install: all $(if $(BUILD_DOCS),install-doc) install-datadir install-local= statedir +install: all $(if $(BUILD_DOCS),install-doc) install-datadir install-local= statedir install-includedir ifneq ($(TOOLS),) $(call install-prog,$(subst qemu-ga,qemu-ga$(EXESUF),$(TOOLS)),$(DESTDIR)= $(bindir)) endif @@ -885,6 +887,9 @@ ifneq ($(BLOBS),) endif ifdef CONFIG_GTK $(MAKE) -C po $@ +endif +ifeq ($(CONFIG_PLUGIN),y) + $(INSTALL_DATA) $(SRC_PATH)/include/qemu/qemu-plugin.h "$(DESTDIR)$(inclu= dedir)/qemu-plugin.h" endif $(INSTALL_DIR) "$(DESTDIR)$(qemu_datadir)/keymaps" set -e; for x in $(KEYMAPS); do \ diff --git a/Makefile.target b/Makefile.target index 4d56298bbf..75637c285c 100644 --- a/Makefile.target +++ b/Makefile.target @@ -107,6 +107,8 @@ obj-y +=3D target/$(TARGET_BASE_ARCH)/ obj-y +=3D disas.o obj-$(call notempty,$(TARGET_XML_FILES)) +=3D gdbstub-xml.o =20 +obj-$(CONFIG_PLUGINS) +=3D plugin.o + ######################################################### # Linux user emulator target =20 diff --git a/include/qemu/plugin.h b/include/qemu/plugin.h new file mode 100644 index 0000000000..e483d0eaa8 --- /dev/null +++ b/include/qemu/plugin.h @@ -0,0 +1,253 @@ +/* + * Copyright (C) 2017, Emilio G. Cota + * + * License: GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ +#ifndef QEMU_PLUGIN_H +#define QEMU_PLUGIN_H + +#include "qemu/config-file.h" +#include "qemu/qemu-plugin.h" +#include "qemu/error-report.h" +#include "qemu/queue.h" +#include "qemu/option.h" + +/* + * Option parsing/processing. + * Note that we can load an arbitrary number of plugins. + */ +struct qemu_plugin_desc; +QTAILQ_HEAD(qemu_plugin_list, qemu_plugin_desc); + +#ifdef CONFIG_PLUGIN +extern QemuOptsList qemu_plugin_opts; + +static inline void qemu_plugin_add_opts(void) +{ + qemu_add_opts(&qemu_plugin_opts); +} + +void qemu_plugin_opt_parse(const char *optarg, struct qemu_plugin_list *he= ad); +int qemu_plugin_load_list(struct qemu_plugin_list *head); +#else /* !CONFIG_PLUGIN */ +static inline void qemu_plugin_add_opts(void) +{ } + +static inline void qemu_plugin_opt_parse(const char *optarg, + struct qemu_plugin_list *head) +{ + error_report("plugin interface not enabled in this build"); + exit(1); +} + +static inline int qemu_plugin_load_list(struct qemu_plugin_list *head) +{ + return 0; +} +#endif /* !CONFIG_PLUGIN */ + +/* + * Events that plugins can subscribe to. + */ +enum qemu_plugin_event { + QEMU_PLUGIN_EV_VCPU_INIT, + QEMU_PLUGIN_EV_VCPU_EXIT, + QEMU_PLUGIN_EV_VCPU_TB_TRANS, + QEMU_PLUGIN_EV_VCPU_IDLE, + QEMU_PLUGIN_EV_VCPU_RESUME, + QEMU_PLUGIN_EV_VCPU_SYSCALL, + QEMU_PLUGIN_EV_VCPU_SYSCALL_RET, + QEMU_PLUGIN_EV_FLUSH, + QEMU_PLUGIN_EV_ATEXIT, + QEMU_PLUGIN_EV_MAX, +}; + +union qemu_plugin_cb_sig { + qemu_plugin_simple_cb_t simple; + qemu_plugin_udata_cb_t udata; + qemu_plugin_vcpu_simple_cb_t vcpu_simple; + qemu_plugin_vcpu_udata_cb_t vcpu_udata; + qemu_plugin_vcpu_tb_trans_cb_t vcpu_tb_trans; + qemu_plugin_vcpu_mem_cb_t vcpu_mem; + qemu_plugin_vcpu_mem_haddr_cb_t vcpu_mem_haddr; + qemu_plugin_vcpu_syscall_cb_t vcpu_syscall; + qemu_plugin_vcpu_syscall_ret_cb_t vcpu_syscall_ret; + void *generic; +}; + +enum plugin_dyn_cb_type { + PLUGIN_CB_INSN, + PLUGIN_CB_MEM, + PLUGIN_CB_HADDR, + PLUGIN_N_CB_TYPES, +}; + +enum plugin_dyn_cb_subtype { + PLUGIN_CB_REGULAR, + PLUGIN_CB_INLINE, + PLUGIN_N_CB_SUBTYPES, +}; + +/* + * A dynamic callback has an insertion point that is determined at run-tim= e. + * Usually the insertion point is somewhere in the code cache; think for + * instance of a callback to be called upon the execution of a particular = TB. + */ +struct qemu_plugin_dyn_cb { + union qemu_plugin_cb_sig f; + void *userp; + unsigned tcg_flags; + enum plugin_dyn_cb_type type; + /* @rw applies to mem callbacks only (both regular and inline) */ + enum qemu_plugin_mem_rw rw; + /* fields specific to each dyn_cb type go here */ + union { + struct { + bool haddr; + } mem; + struct { + enum qemu_plugin_op op; + uint64_t imm; + } inline_insn; + }; +}; + +struct qemu_plugin_dyn_cb_arr { + struct qemu_plugin_dyn_cb *data; + size_t n; + size_t capacity; +}; + +struct qemu_plugin_insn { + void *data; + size_t size; + size_t capacity; + uint64_t vaddr; + void *haddr; + struct qemu_plugin_dyn_cb_arr cbs[PLUGIN_N_CB_TYPES][PLUGIN_N_CB_SUBTY= PES]; + bool calls_helpers; + bool mem_helper; +}; + +struct qemu_plugin_tb { + struct qemu_plugin_insn *insns; + size_t n; + size_t capacity; + uint64_t vaddr; + uint64_t vaddr2; + void *haddr1; + void *haddr2; + struct qemu_plugin_dyn_cb_arr cbs[PLUGIN_N_CB_SUBTYPES]; +}; + +static inline +void qemu_plugin_dyn_cb_arr_init(struct qemu_plugin_dyn_cb_arr *arr) +{ + arr->data =3D NULL; + arr->capacity =3D 0; +} + +static inline +struct qemu_plugin_insn *qemu_plugin_tb_insn_get(struct qemu_plugin_tb *tb) +{ + struct qemu_plugin_insn *insn; + int i, j; + + if (unlikely(tb->n =3D=3D tb->capacity)) { + tb->insns =3D g_renew(struct qemu_plugin_insn, tb->insns, ++tb->ca= pacity); + insn =3D &tb->insns[tb->capacity - 1]; + insn->data =3D NULL; + insn->capacity =3D 0; + for (i =3D 0; i < PLUGIN_N_CB_TYPES; i++) { + for (j =3D 0; j < PLUGIN_N_CB_SUBTYPES; j++) { + qemu_plugin_dyn_cb_arr_init(&insn->cbs[i][j]); + } + } + } + insn =3D &tb->insns[tb->n++]; + insn->size =3D 0; + insn->calls_helpers =3D false; + insn->mem_helper =3D false; + + for (i =3D 0; i < PLUGIN_N_CB_TYPES; i++) { + for (j =3D 0; j < PLUGIN_N_CB_SUBTYPES; j++) { + insn->cbs[i][j].n =3D 0; + } + } + + return insn; +} + +#ifdef CONFIG_PLUGIN + +void qemu_plugin_vcpu_init_hook(CPUState *cpu); +void qemu_plugin_vcpu_exit_hook(CPUState *cpu); +void qemu_plugin_tb_trans_cb(CPUState *cpu, struct qemu_plugin_tb *tb); +void qemu_plugin_vcpu_idle_cb(CPUState *cpu); +void qemu_plugin_vcpu_resume_cb(CPUState *cpu); +void +qemu_plugin_vcpu_syscall(CPUState *cpu, int64_t num, uint64_t a1, + uint64_t a2, uint64_t a3, uint64_t a4, uint64_t a= 5, + uint64_t a6, uint64_t a7, uint64_t a8); +void qemu_plugin_vcpu_syscall_ret(CPUState *cpu, int64_t num, int64_t ret); + +void qemu_plugin_vcpu_mem_cb(CPUState *cpu, uint64_t vaddr, void *haddr, + uint32_t meminfo); + +void qemu_plugin_flush_cb(void); + +void qemu_plugin_atexit_cb(void); + +void qemu_plugin_add_dyn_cb_arr(struct qemu_plugin_dyn_cb_arr *arr); + +void qemu_plugin_disable_mem_helpers(CPUState *cpu); + +#else /* !CONFIG_PLUGIN */ + +static inline void qemu_plugin_vcpu_init_hook(CPUState *cpu) +{ } + +static inline void qemu_plugin_vcpu_exit_hook(CPUState *cpu) +{ } + +static inline void qemu_plugin_tb_trans_cb(CPUState *cpu, + struct qemu_plugin_tb *tb) +{ } + +static inline void qemu_plugin_vcpu_idle_cb(CPUState *cpu) +{ } + +static inline void qemu_plugin_vcpu_resume_cb(CPUState *cpu) +{ } + +static inline void +qemu_plugin_vcpu_syscall(CPUState *cpu, int64_t num, uint64_t a1, uint64_t= a2, + uint64_t a3, uint64_t a4, uint64_t a5, uint64_t a= 6, + uint64_t a7, uint64_t a8) +{ } + +static inline +void qemu_plugin_vcpu_syscall_ret(CPUState *cpu, int64_t num, int64_t ret) +{ } + +static inline void qemu_plugin_vcpu_mem_cb(CPUState *cpu, uint64_t vaddr, + void *haddr, uint32_t meminfo) +{ } + +static inline void qemu_plugin_flush_cb(void) +{ } + +static inline void qemu_plugin_atexit_cb(void) +{ } + +static inline +void qemu_plugin_add_dyn_cb_arr(struct qemu_plugin_dyn_cb_arr *arr) +{ } + +static inline void qemu_plugin_disable_mem_helpers(CPUState *cpu) +{ } + +#endif /* !CONFIG_PLUGIN */ + +#endif /* QEMU_PLUGIN_H */ diff --git a/include/qom/cpu.h b/include/qom/cpu.h index fab18089db..4002a911af 100644 --- a/include/qom/cpu.h +++ b/include/qom/cpu.h @@ -30,6 +30,7 @@ #include "qemu/rcu_queue.h" #include "qemu/queue.h" #include "qemu/thread.h" +#include "qemu/plugin.h" =20 typedef int (*WriteCoreDumpFunction)(const void *buf, size_t size, void *opaque); @@ -326,6 +327,7 @@ struct qemu_work_item; * @trace_dstate_delayed: Delayed changes to trace_dstate (includes all ch= anges * to @trace_dstate). * @trace_dstate: Dynamic tracing state of events for this vCPU (bitmask). + * @plugin_mask: Plugin event bitmap. Modified only via async work. * @ignore_memory_transaction_failures: Cached copy of the MachineState * flag of the same name: allows the board to suppress calling of the * CPU do_transaction_failed hook function. @@ -412,6 +414,10 @@ struct CPUState { DECLARE_BITMAP(trace_dstate_delayed, CPU_TRACE_DSTATE_MAX_EVENTS); DECLARE_BITMAP(trace_dstate, CPU_TRACE_DSTATE_MAX_EVENTS); =20 + DECLARE_BITMAP(plugin_mask, QEMU_PLUGIN_EV_MAX); + + struct qemu_plugin_dyn_cb_arr *plugin_mem_cbs; + /* TODO Move common fields from CPUArchState here. */ int cpu_index; uint32_t can_do_io; diff --git a/plugin.c b/plugin.c new file mode 100644 index 0000000000..dade6dc39f --- /dev/null +++ b/plugin.c @@ -0,0 +1,1030 @@ +/* plugin.c - QEMU Plugin interface + * + * Copyright (C) 2017, Emilio G. Cota + * + * License: GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ +#include "qemu/osdep.h" +#include "qemu/error-report.h" +#include "qemu/config-file.h" +#include "qapi/error.h" +#include "qemu/option.h" +#include "qemu/rcu_queue.h" +#include "qemu/xxhash.h" +#include "qemu/rcu.h" +#include "qom/cpu.h" +#include "exec/cpu-common.h" +#include + +#include "cpu.h" +#include "exec/exec-all.h" +#include "exec/helper-proto.h" +#include "exec/plugin-gen.h" +#include "sysemu/sysemu.h" +#include "tcg/tcg.h" +#include "tcg/tcg-op.h" +#include "trace/mem-internal.h" /* mem_info macros */ + +struct qemu_plugin_cb { + struct qemu_plugin_ctx *ctx; + union qemu_plugin_cb_sig f; + void *udata; + QLIST_ENTRY(qemu_plugin_cb) entry; +}; + +QLIST_HEAD(qemu_plugin_cb_head, qemu_plugin_cb); + +struct qemu_plugin_ctx { + void *handle; /* dlopen */ + qemu_plugin_id_t id; + struct qemu_plugin_cb *callbacks[QEMU_PLUGIN_EV_MAX]; + QTAILQ_ENTRY(qemu_plugin_ctx) entry; + qemu_plugin_uninstall_cb_t uninstall_cb; + /* + * keep a reference to @desc until uninstall, so that plugins do not h= ave + * to strdup plugin args. + */ + struct qemu_plugin_desc *desc; + bool uninstalling; /* protected by plugin.lock */ +}; + +/* global state */ +struct qemu_plugin_state { + QTAILQ_HEAD(, qemu_plugin_ctx) ctxs; + QLIST_HEAD(, qemu_plugin_cb) cb_lists[QEMU_PLUGIN_EV_MAX]; + /* + * Use the HT as a hash map by inserting k =3D=3D v, which saves memor= y as + * documented by GLib. The parent struct is obtained with container_of= (). + */ + GHashTable *id_ht; + /* + * Use the HT as a hash map. Note that we could use a list here, + * but with the HT we avoid adding a field to CPUState. + */ + GHashTable *cpu_ht; + DECLARE_BITMAP(mask, QEMU_PLUGIN_EV_MAX); + /* + * @lock protects the struct as well as ctx->uninstalling. + * The lock must be acquired by all API ops. + * The lock is recursive, which greatly simplifies things, e.g. + * callback registration from qemu_plugin_vcpu_for_each(). + */ + QemuRecMutex lock; + /* + * HT of callbacks invoked from helpers. All entries are freed when + * the code cache is flushed. + */ + struct qht dyn_cb_arr_ht; +}; + +/* + * For convenience we use a bitmap for plugin.mask, but really all we need= is a + * u32, which is what we store in TranslationBlock. + */ +QEMU_BUILD_BUG_ON(QEMU_PLUGIN_EV_MAX > 32); + +struct qemu_plugin_desc { + char *path; + char **argv; + QTAILQ_ENTRY(qemu_plugin_desc) entry; + int argc; +}; + +struct qemu_plugin_parse_arg { + struct qemu_plugin_list *head; + struct qemu_plugin_desc *curr; +}; + +QemuOptsList qemu_plugin_opts =3D { + .name =3D "plugin", + .implied_opt_name =3D "file", + .head =3D QTAILQ_HEAD_INITIALIZER(qemu_plugin_opts.head), + .desc =3D { + /* do our own parsing to support multiple plugins */ + { /* end of list */ } + }, +}; + +typedef int (*qemu_plugin_install_func_t)(qemu_plugin_id_t, int, char **); + +static struct qemu_plugin_state plugin; + +static bool plugin_dyn_cb_arr_cmp(const void *ap, const void *bp) +{ + return ap =3D=3D bp; +} + +void qemu_plugin_add_dyn_cb_arr(struct qemu_plugin_dyn_cb_arr *arr) +{ + uint32_t hash =3D qemu_xxhash2((uint64_t)(uintptr_t)arr); + bool inserted; + + inserted =3D qht_insert(&plugin.dyn_cb_arr_ht, arr, hash, NULL); + g_assert(inserted); +} + +static bool free_dyn_cb_arr(void *p, uint32_t h, void *userp) +{ + struct qemu_plugin_dyn_cb_arr *arr =3D p; + + g_free(arr->data); + g_free(arr); + return true; +} + +static struct qemu_plugin_desc *plugin_find_desc(struct qemu_plugin_list *= head, + const char *path) +{ + struct qemu_plugin_desc *desc; + + QTAILQ_FOREACH(desc, head, entry) { + if (strcmp(desc->path, path) =3D=3D 0) { + return desc; + } + } + return NULL; +} + +static int plugin_add(void *opaque, const char *name, const char *value, + Error **errp) +{ + struct qemu_plugin_parse_arg *arg =3D opaque; + struct qemu_plugin_desc *p; + + if (strcmp(name, "file") =3D=3D 0) { + if (strcmp(value, "") =3D=3D 0) { + error_setg(errp, "requires a non-empty argument"); + return 1; + } + p =3D plugin_find_desc(arg->head, value); + if (p =3D=3D NULL) { + p =3D g_new0(struct qemu_plugin_desc, 1); + p->path =3D g_strdup(value); + QTAILQ_INSERT_TAIL(arg->head, p, entry); + } + arg->curr =3D p; + } else if (strcmp(name, "arg") =3D=3D 0) { + if (arg->curr =3D=3D NULL) { + error_setg(errp, "missing earlier '-plugin file=3D' option"); + return 1; + } + p =3D arg->curr; + p->argc++; + p->argv =3D g_realloc_n(p->argv, p->argc, sizeof(char *)); + p->argv[p->argc - 1] =3D g_strdup(value); + } else { + error_setg(errp, "-plugin: unexpected parameter '%s'; ignored", na= me); + } + return 0; +} + +void qemu_plugin_opt_parse(const char *optarg, struct qemu_plugin_list *he= ad) +{ + struct qemu_plugin_parse_arg arg; + QemuOpts *opts; + + opts =3D qemu_opts_parse_noisily(qemu_find_opts("plugin"), optarg, tru= e); + if (opts =3D=3D NULL) { + exit(1); + } + arg.head =3D head; + arg.curr =3D NULL; + qemu_opt_foreach(opts, plugin_add, &arg, &error_fatal); + qemu_opts_del(opts); +} + +/* + * From: https://en.wikipedia.org/wiki/Xorshift + * This is faster than rand_r(), and gives us a wider range (RAND_MAX is o= nly + * guaranteed to be >=3D INT_MAX). + */ +static uint64_t xorshift64star(uint64_t x) +{ + x ^=3D x >> 12; /* a */ + x ^=3D x << 25; /* b */ + x ^=3D x >> 27; /* c */ + return x * UINT64_C(2685821657736338717); +} + +static int plugin_load(struct qemu_plugin_desc *desc) +{ + qemu_plugin_install_func_t install; + struct qemu_plugin_ctx *ctx; + char *err; + int rc; + + ctx =3D qemu_memalign(qemu_dcache_linesize, sizeof(*ctx)); + memset(ctx, 0, sizeof(*ctx)); + ctx->desc =3D desc; + + ctx->handle =3D dlopen(desc->path, RTLD_NOW); + if (ctx->handle =3D=3D NULL) { + error_report("%s: %s", __func__, dlerror()); + goto err_dlopen; + } + + /* clear any previous dlerror, call dlsym, then check dlerror */ + dlerror(); + install =3D dlsym(ctx->handle, "qemu_plugin_install"); + err =3D dlerror(); + if (err) { + error_report("%s: %s", __func__, err); + goto err_symbol; + } + /* symbol was found; it could be NULL though */ + if (install =3D=3D NULL) { + error_report("%s: %s: qemu_plugin_install is NULL", + __func__, desc->path); + goto err_symbol; + } + + qemu_rec_mutex_lock(&plugin.lock); + + /* find an unused random id with &ctx as the seed */ + ctx->id =3D (uint64_t)(uintptr_t)ctx; + for (;;) { + void *existing; + + ctx->id =3D xorshift64star(ctx->id); + existing =3D g_hash_table_lookup(plugin.id_ht, &ctx->id); + if (likely(existing =3D=3D NULL)) { + bool success; + + success =3D g_hash_table_insert(plugin.id_ht, &ctx->id, &ctx->= id); + g_assert(success); + break; + } + } + QTAILQ_INSERT_TAIL(&plugin.ctxs, ctx, entry); + qemu_rec_mutex_unlock(&plugin.lock); + + rc =3D install(ctx->id, desc->argc, desc->argv); + if (rc) { + error_report("%s: qemu_plugin_install returned error code %d", + __func__, rc); + /* + * we cannot rely on the plugin doing its own cleanup, so + * call a full uninstall if the plugin did not already call it. + */ + qemu_rec_mutex_lock(&plugin.lock); + if (!ctx->uninstalling) { + qemu_plugin_uninstall(ctx->id, NULL); + } + qemu_rec_mutex_unlock(&plugin.lock); + return 1; + } + return 0; + + err_symbol: + if (dlclose(ctx->handle)) { + warn_report("%s: %s", __func__, dlerror()); + } + err_dlopen: + qemu_vfree(ctx); + return 1; +} + +/* call after having removed @desc from the list */ +static void plugin_desc_free(struct qemu_plugin_desc *desc) +{ + int i; + + for (i =3D 0; i < desc->argc; i++) { + g_free(desc->argv[i]); + } + g_free(desc->argv); + g_free(desc->path); + g_free(desc); +} + +/** + * qemu_plugin_load_list - load a list of plugins + * @head: head of the list of descriptors of the plugins to be loaded + * + * Returns 0 if all plugins in the list are installed, !0 otherwise. + * + * Note: the descriptor of each successfully installed plugin is removed + * from the list given by @head. + */ +int qemu_plugin_load_list(struct qemu_plugin_list *head) +{ + struct qemu_plugin_desc *desc, *next; + + QTAILQ_FOREACH_SAFE(desc, head, entry, next) { + int err; + + err =3D plugin_load(desc); + if (err) { + return err; + } + QTAILQ_REMOVE(head, desc, entry); + } + return 0; +} + +static struct qemu_plugin_ctx *id_to_ctx__locked(qemu_plugin_id_t id) +{ + struct qemu_plugin_ctx *ctx; + qemu_plugin_id_t *id_p; + + id_p =3D g_hash_table_lookup(plugin.id_ht, &id); + ctx =3D container_of(id_p, struct qemu_plugin_ctx, id); + if (ctx =3D=3D NULL) { + error_report("plugin: invalid plugin id %" PRIu64, id); + abort(); + } + return ctx; +} + +static void plugin_cpu_update__async(CPUState *cpu, run_on_cpu_data data) +{ + bitmap_copy(cpu->plugin_mask, &data.host_ulong, QEMU_PLUGIN_EV_MAX); + cpu_tb_jmp_cache_clear(cpu); +} + +static void plugin_cpu_update__locked(gpointer k, gpointer v, gpointer uda= ta) +{ + CPUState *cpu =3D container_of(k, CPUState, cpu_index); + run_on_cpu_data mask =3D RUN_ON_CPU_HOST_ULONG(*plugin.mask); + + if (cpu->created) { + async_run_on_cpu(cpu, plugin_cpu_update__async, mask); + } else { + plugin_cpu_update__async(cpu, mask); + } +} + +static void plugin_unregister_cb__locked(struct qemu_plugin_ctx *ctx, + enum qemu_plugin_event ev) +{ + struct qemu_plugin_cb *cb =3D ctx->callbacks[ev]; + + if (cb =3D=3D NULL) { + return; + } + QLIST_REMOVE_RCU(cb, entry); + g_free(cb); + ctx->callbacks[ev] =3D NULL; + if (QLIST_EMPTY_RCU(&plugin.cb_lists[ev])) { + clear_bit(ev, plugin.mask); + g_hash_table_foreach(plugin.cpu_ht, plugin_cpu_update__locked, NUL= L); + } +} + +struct qemu_plugin_uninstall_data { + struct qemu_plugin_ctx *ctx; + unsigned tb_flush_count; +}; + +static void plugin_destroy(CPUState *cpu, run_on_cpu_data arg) +{ + struct qemu_plugin_uninstall_data *data =3D arg.host_ptr; + struct qemu_plugin_ctx *ctx =3D data->ctx; + bool success; + + tb_flush(cpu); + + qemu_rec_mutex_lock(&plugin.lock); + g_assert(ctx->uninstalling); + success =3D g_hash_table_remove(plugin.id_ht, &ctx->id); + g_assert(success); + + QTAILQ_REMOVE(&plugin.ctxs, ctx, entry); + qemu_rec_mutex_unlock(&plugin.lock); + + if (ctx->uninstall_cb) { + ctx->uninstall_cb(ctx->id); + } + if (dlclose(ctx->handle)) { + warn_report("%s: %s", __func__, dlerror()); + } + plugin_desc_free(ctx->desc); + qemu_vfree(ctx); + g_free(data); +} + +void qemu_plugin_uninstall(qemu_plugin_id_t id, qemu_plugin_uninstall_cb_t= cb) +{ + struct qemu_plugin_uninstall_data *data; + struct qemu_plugin_ctx *ctx; + enum qemu_plugin_event ev; + + qemu_rec_mutex_lock(&plugin.lock); + ctx =3D id_to_ctx__locked(id); + if (unlikely(ctx->uninstalling)) { + qemu_rec_mutex_unlock(&plugin.lock); + return; + } + ctx->uninstalling =3D true; + ctx->uninstall_cb =3D cb; + /* + * Unregister all callbacks. This is an RCU list so it is possible tha= t some + * callbacks will still be called in this RCU grace period. For this r= eason + * we cannot yet uninstall the plugin. + */ + for (ev =3D 0; ev < QEMU_PLUGIN_EV_MAX; ev++) { + plugin_unregister_cb__locked(ctx, ev); + } + qemu_rec_mutex_unlock(&plugin.lock); + + /* XXX how to flush when we're not in a vCPU thread? */ + if (current_cpu) { + data =3D g_new(struct qemu_plugin_uninstall_data, 1); + data->ctx =3D ctx; + data->tb_flush_count =3D atomic_mb_read(&tb_ctx.tb_flush_count); + async_safe_run_on_cpu(current_cpu, plugin_destroy, + RUN_ON_CPU_HOST_PTR(data)); + } +} + +static void plugin_vcpu_cb__simple(CPUState *cpu, enum qemu_plugin_event e= v) +{ + struct qemu_plugin_cb *cb, *next; + + switch (ev) { + case QEMU_PLUGIN_EV_VCPU_INIT: + case QEMU_PLUGIN_EV_VCPU_EXIT: + case QEMU_PLUGIN_EV_VCPU_IDLE: + case QEMU_PLUGIN_EV_VCPU_RESUME: + /* iterate safely; plugins might uninstall themselves at any time = */ + QLIST_FOREACH_SAFE_RCU(cb, &plugin.cb_lists[ev], entry, next) { + qemu_plugin_vcpu_simple_cb_t func =3D cb->f.vcpu_simple; + + func(cb->ctx->id, cpu->cpu_index); + } + break; + default: + g_assert_not_reached(); + } +} + +static void plugin_cb__simple(enum qemu_plugin_event ev) +{ + struct qemu_plugin_cb *cb, *next; + + switch (ev) { + case QEMU_PLUGIN_EV_FLUSH: + QLIST_FOREACH_SAFE_RCU(cb, &plugin.cb_lists[ev], entry, next) { + qemu_plugin_simple_cb_t func =3D cb->f.simple; + + func(cb->ctx->id); + } + break; + default: + g_assert_not_reached(); + } +} + +static void plugin_cb__udata(enum qemu_plugin_event ev) +{ + struct qemu_plugin_cb *cb, *next; + + switch (ev) { + case QEMU_PLUGIN_EV_ATEXIT: + QLIST_FOREACH_SAFE_RCU(cb, &plugin.cb_lists[ev], entry, next) { + qemu_plugin_udata_cb_t func =3D cb->f.udata; + + func(cb->ctx->id, cb->udata); + } + break; + default: + g_assert_not_reached(); + } +} + +static void +do_plugin_register_cb(qemu_plugin_id_t id, enum qemu_plugin_event ev, + void *func, void *udata) +{ + struct qemu_plugin_ctx *ctx; + + qemu_rec_mutex_lock(&plugin.lock); + ctx =3D id_to_ctx__locked(id); + /* if the plugin is on its way out, ignore this request */ + if (unlikely(ctx->uninstalling)) { + goto out_unlock; + } + if (func) { + struct qemu_plugin_cb *cb =3D ctx->callbacks[ev]; + + if (cb) { + cb->f.generic =3D func; + cb->udata =3D udata; + } else { + cb =3D g_new(struct qemu_plugin_cb, 1); + cb->ctx =3D ctx; + cb->f.generic =3D func; + cb->udata =3D udata; + ctx->callbacks[ev] =3D cb; + QLIST_INSERT_HEAD_RCU(&plugin.cb_lists[ev], cb, entry); + if (!test_bit(ev, plugin.mask)) { + set_bit(ev, plugin.mask); + g_hash_table_foreach(plugin.cpu_ht, plugin_cpu_update__loc= ked, + NULL); + } + } + } else { + plugin_unregister_cb__locked(ctx, ev); + } + out_unlock: + qemu_rec_mutex_unlock(&plugin.lock); +} + +static void plugin_register_cb(qemu_plugin_id_t id, enum qemu_plugin_event= ev, + void *func) +{ + do_plugin_register_cb(id, ev, func, NULL); +} + +static void +plugin_register_cb_udata(qemu_plugin_id_t id, enum qemu_plugin_event ev, + void *func, void *udata) +{ + do_plugin_register_cb(id, ev, func, udata); +} + +void qemu_plugin_register_vcpu_init_cb(qemu_plugin_id_t id, + qemu_plugin_vcpu_simple_cb_t cb) +{ + plugin_register_cb(id, QEMU_PLUGIN_EV_VCPU_INIT, cb); +} + +void qemu_plugin_register_vcpu_exit_cb(qemu_plugin_id_t id, + qemu_plugin_vcpu_simple_cb_t cb) +{ + plugin_register_cb(id, QEMU_PLUGIN_EV_VCPU_EXIT, cb); +} + +void qemu_plugin_vcpu_init_hook(CPUState *cpu) +{ + bool success; + + qemu_rec_mutex_lock(&plugin.lock); + plugin_cpu_update__locked(&cpu->cpu_index, NULL, NULL); + success =3D g_hash_table_insert(plugin.cpu_ht, &cpu->cpu_index, + &cpu->cpu_index); + g_assert(success); + qemu_rec_mutex_unlock(&plugin.lock); + + plugin_vcpu_cb__simple(cpu, QEMU_PLUGIN_EV_VCPU_INIT); +} + +void qemu_plugin_vcpu_exit_hook(CPUState *cpu) +{ + bool success; + + plugin_vcpu_cb__simple(cpu, QEMU_PLUGIN_EV_VCPU_EXIT); + + qemu_rec_mutex_lock(&plugin.lock); + success =3D g_hash_table_remove(plugin.cpu_ht, &cpu->cpu_index); + g_assert(success); + qemu_rec_mutex_unlock(&plugin.lock); +} + +struct plugin_for_each_args { + struct qemu_plugin_ctx *ctx; + qemu_plugin_vcpu_simple_cb_t cb; +}; + +static void plugin_vcpu_for_each(gpointer k, gpointer v, gpointer udata) +{ + struct plugin_for_each_args *args =3D udata; + int cpu_index =3D *(int *)k; + + args->cb(args->ctx->id, cpu_index); +} + +void qemu_plugin_vcpu_for_each(qemu_plugin_id_t id, + qemu_plugin_vcpu_simple_cb_t cb) +{ + struct plugin_for_each_args args; + + if (cb =3D=3D NULL) { + return; + } + qemu_rec_mutex_lock(&plugin.lock); + args.ctx =3D id_to_ctx__locked(id); + args.cb =3D cb; + g_hash_table_foreach(plugin.cpu_ht, plugin_vcpu_for_each, &args); + qemu_rec_mutex_unlock(&plugin.lock); +} + +static struct qemu_plugin_dyn_cb * +plugin_get_dyn_cb(struct qemu_plugin_dyn_cb_arr *arr) +{ + if (arr->n =3D=3D arr->capacity) { + arr->data =3D g_renew(struct qemu_plugin_dyn_cb, arr->data, arr->n= + 1); + arr->capacity++; + } + + return &arr->data[arr->n++]; +} + +static void plugin_register_inline_op(struct qemu_plugin_dyn_cb_arr *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; +} + +static inline uint32_t cb_to_tcg_flags(enum qemu_plugin_cb_flags flags) +{ + uint32_t ret; + + switch (flags) { + case QEMU_PLUGIN_CB_RW_REGS: + ret =3D 0; + case QEMU_PLUGIN_CB_R_REGS: + ret =3D TCG_CALL_NO_WG; + break; + case QEMU_PLUGIN_CB_NO_REGS: + default: + ret =3D TCG_CALL_NO_RWG; + } + return ret; +} + +static inline void +plugin_register_dyn_cb__udata(struct qemu_plugin_dyn_cb_arr *arr, + qemu_plugin_vcpu_udata_cb_t cb, + enum qemu_plugin_cb_flags flags, void *udata) +{ + struct qemu_plugin_dyn_cb *dyn_cb =3D plugin_get_dyn_cb(arr); + + dyn_cb->userp =3D udata; + dyn_cb->tcg_flags =3D cb_to_tcg_flags(flags); + dyn_cb->f.vcpu_udata =3D cb; + dyn_cb->type =3D PLUGIN_CB_REGULAR; +} + +void qemu_plugin_register_vcpu_tb_exec_cb(struct qemu_plugin_tb *tb, + qemu_plugin_vcpu_udata_cb_t cb, + enum qemu_plugin_cb_flags flags, + void *udata) +{ + plugin_register_dyn_cb__udata(&tb->cbs[PLUGIN_CB_REGULAR], + cb, flags, udata); +} + +void qemu_plugin_register_vcpu_tb_exec_inline(struct qemu_plugin_tb *tb, + enum qemu_plugin_op op, + void *ptr, uint64_t imm) +{ + plugin_register_inline_op(&tb->cbs[PLUGIN_CB_INLINE], 0, op, ptr, 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, + void *udata) +{ + plugin_register_dyn_cb__udata(&insn->cbs[PLUGIN_CB_INSN][PLUGIN_CB_REG= ULAR], + cb, flags, udata); +} + +void qemu_plugin_register_vcpu_insn_exec_inline(struct qemu_plugin_insn *i= nsn, + enum qemu_plugin_op op, + void *ptr, uint64_t imm) +{ + plugin_register_inline_op(&insn->cbs[PLUGIN_CB_INSN][PLUGIN_CB_INLINE], + 0, op, ptr, imm); +} + +static void plugin_register_vcpu_mem_cb(struct qemu_plugin_dyn_cb_arr *arr, + void *cb, + enum qemu_plugin_cb_flags flags, + enum qemu_plugin_mem_rw rw, + void *udata, bool haddr) +{ + struct qemu_plugin_dyn_cb *dyn_cb; + + dyn_cb =3D plugin_get_dyn_cb(arr); + dyn_cb->userp =3D udata; + dyn_cb->tcg_flags =3D cb_to_tcg_flags(flags); + dyn_cb->type =3D PLUGIN_CB_REGULAR; + dyn_cb->rw =3D rw; + dyn_cb->mem.haddr =3D haddr; + dyn_cb->f.generic =3D cb; +} + +void qemu_plugin_register_vcpu_mem_cb(struct qemu_plugin_insn *insn, + qemu_plugin_vcpu_mem_cb_t cb, + enum qemu_plugin_cb_flags flags, + enum qemu_plugin_mem_rw rw, + void *udata) +{ + plugin_register_vcpu_mem_cb(&insn->cbs[PLUGIN_CB_MEM][PLUGIN_CB_REGULA= R], + cb, flags, rw, udata, false); +} + +void qemu_plugin_register_vcpu_mem_haddr_cb(struct qemu_plugin_insn *insn, + qemu_plugin_vcpu_mem_haddr_cb_= t cb, + enum qemu_plugin_cb_flags flag= s, + enum qemu_plugin_mem_rw rw, + void *udata) +{ + plugin_register_vcpu_mem_cb(&insn->cbs[PLUGIN_CB_HADDR][PLUGIN_CB_REGU= LAR], + cb, flags, rw, udata, true); +} + +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_tb_trans_cb(CPUState *cpu, struct qemu_plugin_tb *tb) +{ + struct qemu_plugin_cb *cb, *next; + enum qemu_plugin_event ev =3D QEMU_PLUGIN_EV_VCPU_TB_TRANS; + + /* no plugin_mask check here; caller should have checked */ + + QLIST_FOREACH_SAFE_RCU(cb, &plugin.cb_lists[ev], entry, next) { + qemu_plugin_vcpu_tb_trans_cb_t func =3D cb->f.vcpu_tb_trans; + + func(cb->ctx->id, cpu->cpu_index, tb); + } +} + +void qemu_plugin_register_vcpu_tb_trans_cb(qemu_plugin_id_t id, + qemu_plugin_vcpu_tb_trans_cb_t = cb) +{ + plugin_register_cb(id, QEMU_PLUGIN_EV_VCPU_TB_TRANS, cb); +} + +void +qemu_plugin_vcpu_syscall(CPUState *cpu, int64_t num, uint64_t a1, uint64_t= a2, + uint64_t a3, uint64_t a4, uint64_t a5, + uint64_t a6, uint64_t a7, uint64_t a8) +{ + struct qemu_plugin_cb *cb, *next; + enum qemu_plugin_event ev =3D QEMU_PLUGIN_EV_VCPU_SYSCALL; + + if (!test_bit(ev, cpu->plugin_mask)) { + return; + } + + QLIST_FOREACH_SAFE_RCU(cb, &plugin.cb_lists[ev], entry, next) { + qemu_plugin_vcpu_syscall_cb_t func =3D cb->f.vcpu_syscall; + + func(cb->ctx->id, cpu->cpu_index, num, a1, a2, a3, a4, a5, a6, a7,= a8); + } +} + +void qemu_plugin_register_vcpu_syscall_cb(qemu_plugin_id_t id, + qemu_plugin_vcpu_syscall_cb_t cb) +{ + plugin_register_cb(id, QEMU_PLUGIN_EV_VCPU_SYSCALL, cb); +} + +void qemu_plugin_vcpu_syscall_ret(CPUState *cpu, int64_t num, int64_t ret) +{ + struct qemu_plugin_cb *cb, *next; + enum qemu_plugin_event ev =3D QEMU_PLUGIN_EV_VCPU_SYSCALL_RET; + + if (!test_bit(ev, cpu->plugin_mask)) { + return; + } + + QLIST_FOREACH_SAFE_RCU(cb, &plugin.cb_lists[ev], entry, next) { + qemu_plugin_vcpu_syscall_ret_cb_t func =3D cb->f.vcpu_syscall_ret; + + func(cb->ctx->id, cpu->cpu_index, num, ret); + } +} + +void +qemu_plugin_register_vcpu_syscall_ret_cb(qemu_plugin_id_t id, + qemu_plugin_vcpu_syscall_ret_cb_t= cb) +{ + plugin_register_cb(id, QEMU_PLUGIN_EV_VCPU_SYSCALL_RET, cb); +} + +size_t qemu_plugin_tb_n_insns(const struct qemu_plugin_tb *tb) +{ + return tb->n; +} + +uint64_t qemu_plugin_tb_vaddr(const struct qemu_plugin_tb *tb) +{ + return tb->vaddr; +} + +struct qemu_plugin_insn * +qemu_plugin_tb_get_insn(const struct qemu_plugin_tb *tb, size_t idx) +{ + if (unlikely(idx >=3D tb->n)) { + return NULL; + } + return &tb->insns[idx]; +} + +const void *qemu_plugin_insn_data(const struct qemu_plugin_insn *insn) +{ + return insn->data; +} + +size_t qemu_plugin_insn_size(const struct qemu_plugin_insn *insn) +{ + return insn->size; +} + +uint64_t qemu_plugin_insn_vaddr(const struct qemu_plugin_insn *insn) +{ + return insn->vaddr; +} + +void *qemu_plugin_insn_haddr(const struct qemu_plugin_insn *insn) +{ + return insn->haddr; +} + +void qemu_plugin_vcpu_idle_cb(CPUState *cpu) +{ + plugin_vcpu_cb__simple(cpu, QEMU_PLUGIN_EV_VCPU_IDLE); +} + +void qemu_plugin_vcpu_resume_cb(CPUState *cpu) +{ + plugin_vcpu_cb__simple(cpu, QEMU_PLUGIN_EV_VCPU_RESUME); +} + +void qemu_plugin_register_vcpu_idle_cb(qemu_plugin_id_t id, + qemu_plugin_vcpu_simple_cb_t cb) +{ + plugin_register_cb(id, QEMU_PLUGIN_EV_VCPU_IDLE, cb); +} + +void qemu_plugin_register_vcpu_resume_cb(qemu_plugin_id_t id, + qemu_plugin_vcpu_simple_cb_t cb) +{ + plugin_register_cb(id, QEMU_PLUGIN_EV_VCPU_RESUME, cb); +} + +void qemu_plugin_register_flush_cb(qemu_plugin_id_t id, + qemu_plugin_simple_cb_t cb) +{ + plugin_register_cb(id, QEMU_PLUGIN_EV_FLUSH, cb); +} + +void qemu_plugin_flush_cb(void) +{ + qht_iter_remove(&plugin.dyn_cb_arr_ht, free_dyn_cb_arr, NULL); + qht_reset(&plugin.dyn_cb_arr_ht); + + plugin_cb__simple(QEMU_PLUGIN_EV_FLUSH); +} + +static void exec_inline_op(struct qemu_plugin_dyn_cb *cb) +{ + uint64_t *val =3D cb->userp; + + switch (cb->inline_insn.op) { + case QEMU_PLUGIN_INLINE_ADD_U64: + *val +=3D cb->inline_insn.imm; + break; + default: + g_assert_not_reached(); + } +} + +void qemu_plugin_vcpu_mem_cb(CPUState *cpu, uint64_t vaddr, void *haddr, + uint32_t info) +{ + struct qemu_plugin_dyn_cb_arr *arr =3D cpu->plugin_mem_cbs; + size_t i; + + if (arr =3D=3D NULL) { + return; + } + for (i =3D 0; i < arr->n; i++) { + struct qemu_plugin_dyn_cb *cb =3D &arr->data[i]; + int w =3D !!(info & TRACE_MEM_ST) + 1; + + if (!(w & cb->rw)) { + break; + } + switch (cb->type) { + case PLUGIN_CB_REGULAR: + + if (cb->mem.haddr) { + cb->f.vcpu_mem_haddr(cpu->cpu_index, info, vaddr, haddr, + cb->userp); + } else { + cb->f.vcpu_mem(cpu->cpu_index, info, vaddr, cb->userp); + } + break; + case PLUGIN_CB_INLINE: + exec_inline_op(cb); + break; + default: + g_assert_not_reached(); + } + } +} + +unsigned qemu_plugin_mem_size_shift(qemu_plugin_meminfo_t info) +{ + return info & TRACE_MEM_SZ_SHIFT_MASK; +} + +bool qemu_plugin_mem_is_sign_extended(qemu_plugin_meminfo_t info) +{ + return !!(info & TRACE_MEM_SE); +} + +bool qemu_plugin_mem_is_big_endian(qemu_plugin_meminfo_t info) +{ + return !!(info & TRACE_MEM_BE); +} + +bool qemu_plugin_mem_is_store(qemu_plugin_meminfo_t info) +{ + return !!(info & TRACE_MEM_ST); +} + +int qemu_plugin_n_vcpus(void) +{ +#ifdef CONFIG_USER_ONLY + return -1; +#else + return smp_cpus; +#endif +} + +int qemu_plugin_n_max_vcpus(void) +{ +#ifdef CONFIG_USER_ONLY + return -1; +#else + return max_cpus; +#endif +} + +void qemu_plugin_atexit_cb(void) +{ + plugin_cb__udata(QEMU_PLUGIN_EV_ATEXIT); +} + +void qemu_plugin_register_atexit_cb(qemu_plugin_id_t id, + qemu_plugin_udata_cb_t cb, + void *udata) +{ + plugin_register_cb_udata(id, QEMU_PLUGIN_EV_ATEXIT, cb, udata); +} + +uint64_t qemu_plugin_ram_addr_from_host(void *haddr) +{ +#ifdef CONFIG_SOFTMMU + ram_addr_t ram_addr; + + g_assert(haddr); + ram_addr =3D qemu_ram_addr_from_host(haddr); + if (ram_addr =3D=3D RAM_ADDR_INVALID) { + error_report("Bad ram pointer %p", haddr); + abort(); + } + return ram_addr; +#else + return 0; +#endif +} + +/* + * Call this function after longjmp'ing to the main loop. It's possible th= at the + * last instruction of a TB might have used helpers, and therefore the + * "disable" instruction will never execute because it ended up as dead co= de. + */ +void qemu_plugin_disable_mem_helpers(CPUState *cpu) +{ + cpu->plugin_mem_cbs =3D NULL; +} + +static void __attribute__((__constructor__)) plugin_init(void) +{ + int i; + + for (i =3D 0; i < QEMU_PLUGIN_EV_MAX; i++) { + QLIST_INIT(&plugin.cb_lists[i]); + } + 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); + QTAILQ_INIT(&plugin.ctxs); + qht_init(&plugin.dyn_cb_arr_ht, plugin_dyn_cb_arr_cmp, 16, + QHT_MODE_AUTO_RESIZE); + atexit(qemu_plugin_atexit_cb); +} --=20 2.17.1 From nobody Sat Apr 27 22:25:51 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 154438442215313.98927067057241; Sun, 9 Dec 2018 11:40:22 -0800 (PST) Received: from localhost ([::1]:56398 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gW4w8-0002Yf-R8 for importer@patchew.org; Sun, 09 Dec 2018 14:40:20 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33246) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gW4u1-0000Qr-16 for qemu-devel@nongnu.org; Sun, 09 Dec 2018 14:38:10 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gW4tx-0004zl-5g for qemu-devel@nongnu.org; Sun, 09 Dec 2018 14:38:08 -0500 Received: from wout2-smtp.messagingengine.com ([64.147.123.25]:49689) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gW4tw-0004wW-LN for qemu-devel@nongnu.org; Sun, 09 Dec 2018 14:38:04 -0500 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id 7017AC81; Sun, 9 Dec 2018 14:38:02 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Sun, 09 Dec 2018 14:38:02 -0500 Received: from localhost (flamenco.cs.columbia.edu [128.59.20.216]) by mail.messagingengine.com (Postfix) with ESMTPA id 91696102F4; Sun, 9 Dec 2018 14:38:01 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=braap.org; h= from:to:cc:subject:date:message-id:in-reply-to:references; s= mesmtp; bh=l18YvWC3Iyfbtx/7nxl07ZGsuyTH1iZ1h+rClBUl+sU=; b=orJVw isiTU6aANweR0FaMgmlkH0M/Ki2ELkytUoBa4EWNqmIGH2XVORdgNt2nuwAwB2JX SU2W/GOD1JlGvfGep6OBYO/gU6dIEWWIEkXbMbw8fYdUngxkgt7l/trTlc7e41ub 4GCFrzfUZsovUv3lBtPds52/FJzSK0RQK7gHVI= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:date:from:in-reply-to:message-id :references:subject:to:x-me-proxy:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; bh=l18YvWC3Iyfbtx/7nxl07ZGsuyTH1 iZ1h+rClBUl+sU=; b=VvhAIcLxbDa5d+SemGZ3NOiAgILETkOXq2jx3qcwJcHqx r7do+wvbnSs/4trXwc/AD3ra3+wXzqneKEA/Vk2YuDikU0xyWIrfmje1zWPvvxMR rIUsgpYd86gNC24fvq7kMm5qDnclIonk7y4FF/yJgqnZCA4wmvxyqP+98Ba7aMkP Zc//A2Gp34oSdwRB3/VKtqgnUkjAgNzSVXsmqcY9qGVkwYeSezdyRVhLKiYSMT0N zi6VOjt2O73t1jzyZAmQus9PHzMFmxKR2DaLzw0wd0qe8dgoSU6e4/MvK8V6b+qQ ay6pyOnxIKb4jOD30RxiHfZOhWk5mEbKjUN7cx9tw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedtkedrudegfedguddvkecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfhuthenuceurghilhhouhhtmecu fedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvufffkf fojghfsedttdertdertddtnecuhfhrohhmpedfgfhmihhlihhoucfirdcuvehothgrfdcu oegtohhtrgessghrrggrphdrohhrgheqnecukfhppeduvdekrdehledrvddtrddvudeine curfgrrhgrmhepmhgrihhlfhhrohhmpegtohhtrgessghrrggrphdrohhrghenucevlhhu shhtvghrufhiiigvpedt X-ME-Proxy: From: "Emilio G. Cota" To: qemu-devel@nongnu.org Date: Sun, 9 Dec 2018 14:37:18 -0500 Message-Id: <20181209193749.12277-8-cota@braap.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181209193749.12277-1-cota@braap.org> References: <20181209193749.12277-1-cota@braap.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 64.147.123.25 Subject: [Qemu-devel] [RFC v2 07/38] queue: add QTAILQ_REMOVE_SEVERAL X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Richard Henderson , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Pavel Dovgalyuk Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This is faster than removing elements one by one. Will gain a user soon. Signed-off-by: Emilio G. Cota --- include/qemu/queue.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/include/qemu/queue.h b/include/qemu/queue.h index ac418efc43..0283c2dd7d 100644 --- a/include/qemu/queue.h +++ b/include/qemu/queue.h @@ -419,6 +419,16 @@ struct { = \ (elm)->field.tqe_prev =3D NULL; \ } while (/*CONSTCOND*/0) =20 +/* remove @left, @right and all elements in between from @head */ +#define QTAILQ_REMOVE_SEVERAL(head, left, right, field) do { \ + if (((right)->field.tqe_next) !=3D NULL) \ + (right)->field.tqe_next->field.tqe_prev =3D \ + (left)->field.tqe_prev; \ + else \ + (head)->tqh_last =3D (left)->field.tqe_prev; \ + *(left)->field.tqe_prev =3D (right)->field.tqe_next; \ + } while (/*CONSTCOND*/0) + #define QTAILQ_FOREACH(var, head, field) \ for ((var) =3D ((head)->tqh_first); \ (var); \ --=20 2.17.1 From nobody Sat Apr 27 22:25:51 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1544385085004928.327058547714; Sun, 9 Dec 2018 11:51:25 -0800 (PST) Received: from localhost ([::1]:56455 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gW56l-0006Kr-Ke for importer@patchew.org; Sun, 09 Dec 2018 14:51:19 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33410) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gW4uF-0001SW-9S for qemu-devel@nongnu.org; Sun, 09 Dec 2018 14:38:26 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gW4uA-0005jJ-6n for qemu-devel@nongnu.org; Sun, 09 Dec 2018 14:38:23 -0500 Received: from wout2-smtp.messagingengine.com ([64.147.123.25]:41879) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gW4u6-0004wc-PS for qemu-devel@nongnu.org; Sun, 09 Dec 2018 14:38:16 -0500 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id 1B1EFD10; Sun, 9 Dec 2018 14:38:03 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Sun, 09 Dec 2018 14:38:03 -0500 Received: from localhost (flamenco.cs.columbia.edu [128.59.20.216]) by mail.messagingengine.com (Postfix) with ESMTPA id C74D1102F5; Sun, 9 Dec 2018 14:38:01 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=braap.org; h= from:to:cc:subject:date:message-id:in-reply-to:references; s= mesmtp; bh=w/H8JL4uM1Z2ZvLcygPKR91/TWlvBjPDlwKvVajFCXk=; b=fWqXH sVdEd/2bylsBIcB4GGtkx3geb2y4BytDviZ9pcDT9U3+Tr67qvwXuwqSG6wdswxo Z/L6gWU8lGDSNgwWyX2PYkBBhaHCJYMkX/mInxnZLXtGA4R1Lk1ardEw5fi5K17k 4BbOJi09YmntKL9qUXf5q53241n3iEZsOM29ZM= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:date:from:in-reply-to:message-id :references:subject:to:x-me-proxy:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; bh=w/H8JL4uM1Z2ZvLcygPKR91/TWlvB jPDlwKvVajFCXk=; b=C4Q24IFp844UGsUvp+Qb2m8gkQsnLs0oZGMsDpELjtR8w gTeMNECVq2HmB/0WovJlNVkpPiL6BfGfR9hyObsa1VJWSAb7qgJW7ENjkyEvC6H3 2yOfC6ie7f8MidB2+qGRJ/5cIGoA0an9pMXBaCE4xUuF0yC3QdDkf+ycW8q1IWB4 Jk+oMLNf035sKUxb7jpwas1JFq/ilDpLpqyo9LbsKPysfmmR8/36mLKQ+ZIO/5eJ 4dPj69L5spR8kltDSZ1ma1VCCydClDFMp+vMEoed1UvKjqIS8PQvQaapSwslb4fu YNKFuOHQbUt9BZPlKL251Dq9Mqg9MQrxzb5Sub/pA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedtkedrudegfedguddvkecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfhuthenuceurghilhhouhhtmecu fedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvufffkf fojghfsedttdertdertddtnecuhfhrohhmpedfgfhmihhlihhoucfirdcuvehothgrfdcu oegtohhtrgessghrrggrphdrohhrgheqnecukfhppeduvdekrdehledrvddtrddvudeine curfgrrhgrmhepmhgrihhlfhhrohhmpegtohhtrgessghrrggrphdrohhrghenucevlhhu shhtvghrufhiiigvpedt X-ME-Proxy: From: "Emilio G. Cota" To: qemu-devel@nongnu.org Date: Sun, 9 Dec 2018 14:37:19 -0500 Message-Id: <20181209193749.12277-9-cota@braap.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181209193749.12277-1-cota@braap.org> References: <20181209193749.12277-1-cota@braap.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 64.147.123.25 Subject: [Qemu-devel] [RFC v2 08/38] tcg: drop nargs from tcg_op_insert_{before, after} X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Richard Henderson , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Pavel Dovgalyuk Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" It's unused. Signed-off-by: Emilio G. Cota --- tcg/tcg.h | 4 ++-- tcg/optimize.c | 4 ++-- tcg/tcg.c | 10 ++++------ 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/tcg/tcg.h b/tcg/tcg.h index f4efbaa680..a745e926bb 100644 --- a/tcg/tcg.h +++ b/tcg/tcg.h @@ -1073,8 +1073,8 @@ void tcg_gen_callN(void *func, TCGTemp *ret, int narg= s, TCGTemp **args); =20 TCGOp *tcg_emit_op(TCGOpcode opc); void tcg_op_remove(TCGContext *s, TCGOp *op); -TCGOp *tcg_op_insert_before(TCGContext *s, TCGOp *op, TCGOpcode opc, int n= arg); -TCGOp *tcg_op_insert_after(TCGContext *s, TCGOp *op, TCGOpcode opc, int na= rg); +TCGOp *tcg_op_insert_before(TCGContext *s, TCGOp *op, TCGOpcode opc); +TCGOp *tcg_op_insert_after(TCGContext *s, TCGOp *op, TCGOpcode opc); =20 void tcg_optimize(TCGContext *s); =20 diff --git a/tcg/optimize.c b/tcg/optimize.c index 5dbe11c3c8..a2247f6de3 100644 --- a/tcg/optimize.c +++ b/tcg/optimize.c @@ -1249,7 +1249,7 @@ void tcg_optimize(TCGContext *s) uint64_t a =3D ((uint64_t)ah << 32) | al; uint64_t b =3D ((uint64_t)bh << 32) | bl; TCGArg rl, rh; - TCGOp *op2 =3D tcg_op_insert_before(s, op, INDEX_op_movi_i= 32, 2); + TCGOp *op2 =3D tcg_op_insert_before(s, op, INDEX_op_movi_i= 32); =20 if (opc =3D=3D INDEX_op_add2_i32) { a +=3D b; @@ -1271,7 +1271,7 @@ void tcg_optimize(TCGContext *s) uint32_t b =3D arg_info(op->args[3])->val; uint64_t r =3D (uint64_t)a * b; TCGArg rl, rh; - TCGOp *op2 =3D tcg_op_insert_before(s, op, INDEX_op_movi_i= 32, 2); + TCGOp *op2 =3D tcg_op_insert_before(s, op, INDEX_op_movi_i= 32); =20 rl =3D op->args[0]; rh =3D op->args[1]; diff --git a/tcg/tcg.c b/tcg/tcg.c index e85133ef05..e87c662a18 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -2203,16 +2203,14 @@ TCGOp *tcg_emit_op(TCGOpcode opc) return op; } =20 -TCGOp *tcg_op_insert_before(TCGContext *s, TCGOp *old_op, - TCGOpcode opc, int nargs) +TCGOp *tcg_op_insert_before(TCGContext *s, TCGOp *old_op, TCGOpcode opc) { TCGOp *new_op =3D tcg_op_alloc(opc); QTAILQ_INSERT_BEFORE(old_op, new_op, link); return new_op; } =20 -TCGOp *tcg_op_insert_after(TCGContext *s, TCGOp *old_op, - TCGOpcode opc, int nargs) +TCGOp *tcg_op_insert_after(TCGContext *s, TCGOp *old_op, TCGOpcode opc) { TCGOp *new_op =3D tcg_op_alloc(opc); QTAILQ_INSERT_AFTER(&s->ops, old_op, new_op, link); @@ -2550,7 +2548,7 @@ static bool liveness_pass_2(TCGContext *s) TCGOpcode lopc =3D (arg_ts->type =3D=3D TCG_TYPE_I32 ? INDEX_op_ld_i32 : INDEX_op_ld_i64); - TCGOp *lop =3D tcg_op_insert_before(s, op, lopc, 3); + TCGOp *lop =3D tcg_op_insert_before(s, op, lopc); =20 lop->args[0] =3D temp_arg(dir_ts); lop->args[1] =3D temp_arg(arg_ts->mem_base); @@ -2619,7 +2617,7 @@ static bool liveness_pass_2(TCGContext *s) TCGOpcode sopc =3D (arg_ts->type =3D=3D TCG_TYPE_I32 ? INDEX_op_st_i32 : INDEX_op_st_i64); - TCGOp *sop =3D tcg_op_insert_after(s, op, sopc, 3); + TCGOp *sop =3D tcg_op_insert_after(s, op, sopc); =20 sop->args[0] =3D temp_arg(dir_ts); sop->args[1] =3D temp_arg(arg_ts->mem_base); --=20 2.17.1 From nobody Sat Apr 27 22:25:51 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1544384608655345.743837197659; Sun, 9 Dec 2018 11:43:28 -0800 (PST) Received: from localhost ([::1]:56416 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gW4z9-00050n-ET for importer@patchew.org; Sun, 09 Dec 2018 14:43:27 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33297) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gW4u2-0000Xf-KM for qemu-devel@nongnu.org; Sun, 09 Dec 2018 14:38:11 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gW4tx-0004zv-6M for qemu-devel@nongnu.org; Sun, 09 Dec 2018 14:38:09 -0500 Received: from wout2-smtp.messagingengine.com ([64.147.123.25]:54735) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gW4tw-0004wd-O9 for qemu-devel@nongnu.org; Sun, 09 Dec 2018 14:38:04 -0500 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id 21A3FF22; Sun, 9 Dec 2018 14:38:03 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Sun, 09 Dec 2018 14:38:03 -0500 Received: from localhost (flamenco.cs.columbia.edu [128.59.20.216]) by mail.messagingengine.com (Postfix) with ESMTPA id 05572102F6; Sun, 9 Dec 2018 14:38:02 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=braap.org; h= from:to:cc:subject:date:message-id:in-reply-to:references; s= mesmtp; bh=XwOOnFQ5SzYFCm/1DleuIvKSzWPh2jCFxORFo7CnHt0=; b=EkwdX i5kSg0abADNnSUdID8LglDRnymgZL3FEyE9ktnw1U/bm44K6wsAS9IJ7XHGAkmA+ cUfBkgQ8nfnRhgdTC9o096QTVWwaeUOfEXjk3Ak2Te45bwzCr2aoO++C+LG1Ersq IkQyuZMHAEMG5ceFSwgBVWve/BsawkUJPpsqn4= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:date:from:in-reply-to:message-id :references:subject:to:x-me-proxy:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; bh=XwOOnFQ5SzYFCm/1DleuIvKSzWPh2 jCFxORFo7CnHt0=; b=qL54tvSYi9bgeeuP1F1CXcpEpNoYWsx76lodvlaRxYH4U Aq4GPeQWU0B9H7NxQxbqDWGnOc+JGrLhDRKVGDiMF0cyW3P0qsVmWEdC51V7f+O9 UinRwgc7K6xTQ9tYTnbvlfx2QYo33uCAsUIR10h/yezSPvzVy5wDSQWg39RKC1La PvhZD0/1zPVVfncF1CHgs1zzLctW/jKWq1PkxobyboKxhNoKerOIw+SJvFYnmKuI XvtE+Tf5LrQfZ7iQiw9BRk4Pt6EUAKKYoI5eoRJ7uXAm4lxOxEbVZsIzIGYyOdZt CKf/sU/N0Z8RHZjHplG6ql/s3qx6efb3rfhFgkH+g== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedtkedrudegfedguddvkecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfhuthenuceurghilhhouhhtmecu fedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvufffkf fojghfsedttdertdertddtnecuhfhrohhmpedfgfhmihhlihhoucfirdcuvehothgrfdcu oegtohhtrgessghrrggrphdrohhrgheqnecukfhppeduvdekrdehledrvddtrddvudeine curfgrrhgrmhepmhgrihhlfhhrohhmpegtohhtrgessghrrggrphdrohhrghenucevlhhu shhtvghrufhiiigvpedt X-ME-Proxy: From: "Emilio G. Cota" To: qemu-devel@nongnu.org Date: Sun, 9 Dec 2018 14:37:20 -0500 Message-Id: <20181209193749.12277-10-cota@braap.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181209193749.12277-1-cota@braap.org> References: <20181209193749.12277-1-cota@braap.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 64.147.123.25 Subject: [Qemu-devel] [RFC v2 09/38] cputlb: introduce get_page_addr_code_hostp X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Richard Henderson , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Pavel Dovgalyuk Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This will be used by plugins to get the host address of instructions. Signed-off-by: Emilio G. Cota --- include/exec/exec-all.h | 13 +++++++++++++ accel/tcg/cputlb.c | 14 +++++++++++++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h index 815e5b1e83..afcc01e0e3 100644 --- a/include/exec/exec-all.h +++ b/include/exec/exec-all.h @@ -22,6 +22,7 @@ =20 #include "qemu-common.h" #include "exec/tb-context.h" +#include "exec/cpu_ldst.h" #include "sysemu/cpus.h" =20 /* allow to see translation results - the slowdown should be negligible, s= o we leave it */ @@ -487,12 +488,24 @@ static inline tb_page_addr_t get_page_addr_code(CPUAr= chState *env1, target_ulong { return addr; } + +static inline tb_page_addr_t get_page_addr_code_hostp(CPUArchState *env1, + target_ulong addr, + void **hostp) +{ + if (hostp) { + *hostp =3D g2h(addr); + } + return addr; +} #else static inline void mmap_lock(void) {} static inline void mmap_unlock(void) {} =20 /* cputlb.c */ tb_page_addr_t get_page_addr_code(CPUArchState *env1, target_ulong addr); +tb_page_addr_t get_page_addr_code_hostp(CPUArchState *env1, target_ulong a= ddr, + void **hostp); =20 void tlb_reset_dirty(CPUState *cpu, ram_addr_t start1, ram_addr_t length); void tlb_set_dirty(CPUState *cpu, target_ulong vaddr); diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c index e3582f2f1d..5c61908084 100644 --- a/accel/tcg/cputlb.c +++ b/accel/tcg/cputlb.c @@ -1069,7 +1069,8 @@ static bool victim_tlb_hit(CPUArchState *env, size_t = mmu_idx, size_t index, * is actually a ram_addr_t (in system mode; the user mode emulation * version of this function returns a guest virtual address). */ -tb_page_addr_t get_page_addr_code(CPUArchState *env, target_ulong addr) +tb_page_addr_t get_page_addr_code_hostp(CPUArchState *env, target_ulong ad= dr, + void **hostp) { uintptr_t mmu_idx =3D cpu_mmu_index(env, true); uintptr_t index =3D tlb_index(env, mmu_idx, addr); @@ -1092,13 +1093,24 @@ tb_page_addr_t get_page_addr_code(CPUArchState *env= , target_ulong addr) * than a target page, so we must redo the MMU check every insn * - TLB_MMIO: region is not backed by RAM */ + if (hostp) { + *hostp =3D NULL; + } return -1; } =20 p =3D (void *)((uintptr_t)addr + entry->addend); + if (hostp) { + *hostp =3D p; + } return qemu_ram_addr_from_host_nofail(p); } =20 +tb_page_addr_t get_page_addr_code(CPUArchState *env, target_ulong addr) +{ + return get_page_addr_code_hostp(env, addr, NULL); +} + /* Probe for whether the specified guest write access is permitted. * If it is not permitted then an exception will be taken in the same * way as if this were a real write access (and we will not return). --=20 2.17.1 From nobody Sat Apr 27 22:25:51 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 154438594422476.77092657082142; Sun, 9 Dec 2018 12:05:44 -0800 (PST) Received: from localhost ([::1]:56529 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gW5Kg-0006Sp-Ok for importer@patchew.org; Sun, 09 Dec 2018 15:05:42 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33493) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gW4uH-0001Tp-JK for qemu-devel@nongnu.org; Sun, 09 Dec 2018 14:38:31 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gW4uC-0005pY-CZ for qemu-devel@nongnu.org; Sun, 09 Dec 2018 14:38:25 -0500 Received: from wout2-smtp.messagingengine.com ([64.147.123.25]:42171) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gW4u6-0004wh-QA for qemu-devel@nongnu.org; Sun, 09 Dec 2018 14:38:16 -0500 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id 42AAEF2C; Sun, 9 Dec 2018 14:38:03 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Sun, 09 Dec 2018 14:38:03 -0500 Received: from localhost (flamenco.cs.columbia.edu [128.59.20.216]) by mail.messagingengine.com (Postfix) with ESMTPA id 3923B102F8; Sun, 9 Dec 2018 14:38:02 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=braap.org; h= from:to:cc:subject:date:message-id:in-reply-to:references; s= mesmtp; bh=4BcY53+Z9r0R2HONrRwOrvdTClSSLKwo3SxUQp6BlMg=; b=gG4Td GeBOTjYaBDxnvRs4vl3zcZ1Jn67uaoQukkZ/q3CDLShlBlDEZQ8GhMjjq/4U/+bQ Goa+5DqlJbkL/2DCZHwXXpesPY5VH+Bm+FHERP6VReInI5SfM86fSP8c9OOZFYVb 35uTQVoIaJvOlHyvQxJ05tjDUiYMUHqr0Rr3iU= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:date:from:in-reply-to:message-id :references:subject:to:x-me-proxy:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; bh=4BcY53+Z9r0R2HONrRwOrvdTClSSL Kwo3SxUQp6BlMg=; b=cJ/S4s9+tuvQbDx5/4/HnWMbPm0eZxokOPYfNG3hsnI0T to1Zc0ji2g1w7+jcFefN9jDpnevSCxxNhyuxyBBESvVJR4x1Lmb15Yd4/fyhq0yv 9+AL7JInUG0SEBtPaXXbTHx0XdUe2OXqgd7AYF4rtqZ63osqPFMc0SazMKxpJbvo ftK1IWvyi9g3CcgjUdc7QK9Cl7yGn4hHclsEOwy4HhDUbVY9eNu8Y/79CIhnXSOR IzTt9+JzzTTK5VkTX5g25EJ3Mtmf32M+7BC632F/IBAiDaYF8J07EOZYRFumGzgs 4exB6oUy9XRomEqQa2DpyqyGoQvS553eFTwUkOPjw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedtkedrudegfedguddvkecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfhuthenuceurghilhhouhhtmecu fedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvufffkf fojghfsedttdertdertddtnecuhfhrohhmpedfgfhmihhlihhoucfirdcuvehothgrfdcu oegtohhtrgessghrrggrphdrohhrgheqnecukfhppeduvdekrdehledrvddtrddvudeine curfgrrhgrmhepmhgrihhlfhhrohhmpegtohhtrgessghrrggrphdrohhrghenucevlhhu shhtvghrufhiiigvpedt X-ME-Proxy: From: "Emilio G. Cota" To: qemu-devel@nongnu.org Date: Sun, 9 Dec 2018 14:37:21 -0500 Message-Id: <20181209193749.12277-11-cota@braap.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181209193749.12277-1-cota@braap.org> References: <20181209193749.12277-1-cota@braap.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 64.147.123.25 Subject: [Qemu-devel] [RFC v2 10/38] plugin-gen: add module for TCG-related code X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Richard Henderson , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Pavel Dovgalyuk Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" We first inject empty instrumentation from translator_loop. After translation, we go through the plugins to see what they want to register for, filling in the empty instrumentation. If if turns out that some instrumentation remains unused, we remove it. This approach supports the following features: - Inlining TCG code for simple operations. Note that we do not export TCG ops to plugins. Instead, we give them a C API to insert inlined ops. So far we only support adding an immediate to a u64, e.g. to count events. - "Direct" callbacks. These are callbacks that do not go via a helper. Instead, the helper is defined at run-time, so that the plugin code is directly called from TCG. This makes direct callbacks as efficient as possible; they are therefore used for very frequent events, e.g. memory callbacks. - Passing the host address to memory callbacks. Most of this is implemented in a later patch though. - Instrumentation of memory accesses performed from helpers. See the corresponding comment, as well as a later patch. Signed-off-by: Emilio G. Cota --- accel/tcg/plugin-helpers.h | 6 + include/exec/helper-gen.h | 1 + include/exec/helper-proto.h | 1 + include/exec/helper-tcg.h | 1 + include/exec/plugin-gen.h | 66 +++ tcg/tcg-op.h | 11 + tcg/tcg-opc.h | 3 + tcg/tcg.h | 20 + accel/tcg/plugin-gen.c | 1077 +++++++++++++++++++++++++++++++++++ tcg/tcg.c | 17 + accel/tcg/Makefile.objs | 1 + 11 files changed, 1204 insertions(+) create mode 100644 accel/tcg/plugin-helpers.h create mode 100644 include/exec/plugin-gen.h create mode 100644 accel/tcg/plugin-gen.c diff --git a/accel/tcg/plugin-helpers.h b/accel/tcg/plugin-helpers.h new file mode 100644 index 0000000000..5457a3a577 --- /dev/null +++ b/accel/tcg/plugin-helpers.h @@ -0,0 +1,6 @@ +#ifdef CONFIG_PLUGIN +/* Note: no TCG flags because those are overwritten later */ +DEF_HELPER_2(plugin_vcpu_udata_cb, void, i32, ptr) +DEF_HELPER_4(plugin_vcpu_mem_cb, void, i32, i32, i64, ptr) +DEF_HELPER_5(plugin_vcpu_mem_haddr_cb, void, i32, i32, i64, ptr, ptr) +#endif diff --git a/include/exec/helper-gen.h b/include/exec/helper-gen.h index 22381a1708..236ff40524 100644 --- a/include/exec/helper-gen.h +++ b/include/exec/helper-gen.h @@ -70,6 +70,7 @@ static inline void glue(gen_helper_, name)(dh_retvar_decl= (ret) \ #include "trace/generated-helpers.h" #include "trace/generated-helpers-wrappers.h" #include "tcg-runtime.h" +#include "plugin-helpers.h" =20 #undef DEF_HELPER_FLAGS_0 #undef DEF_HELPER_FLAGS_1 diff --git a/include/exec/helper-proto.h b/include/exec/helper-proto.h index 74943edb13..1c4ba9bc78 100644 --- a/include/exec/helper-proto.h +++ b/include/exec/helper-proto.h @@ -33,6 +33,7 @@ dh_ctype(ret) HELPER(name) (dh_ctype(t1), dh_ctype(t2), d= h_ctype(t3), \ #include "helper.h" #include "trace/generated-helpers.h" #include "tcg-runtime.h" +#include "plugin-helpers.h" =20 #undef DEF_HELPER_FLAGS_0 #undef DEF_HELPER_FLAGS_1 diff --git a/include/exec/helper-tcg.h b/include/exec/helper-tcg.h index b3bdb0c399..3977b4c606 100644 --- a/include/exec/helper-tcg.h +++ b/include/exec/helper-tcg.h @@ -48,6 +48,7 @@ #include "helper.h" #include "trace/generated-helpers.h" #include "tcg-runtime.h" +#include "plugin-helpers.h" =20 #undef str #undef DEF_HELPER_FLAGS_0 diff --git a/include/exec/plugin-gen.h b/include/exec/plugin-gen.h new file mode 100644 index 0000000000..449ea16034 --- /dev/null +++ b/include/exec/plugin-gen.h @@ -0,0 +1,66 @@ +/* + * Copyright (C) 2017, Emilio G. Cota + * + * License: GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + * + * plugin-gen.h - TCG-dependent definitions for generating plugin code + * + * This header should be included only from plugin.c and C files that emit + * TCG code. + */ +#ifndef QEMU_PLUGIN_GEN_H +#define QEMU_PLUGIN_GEN_H + +#include "qemu/plugin.h" +#include "tcg/tcg.h" + +/* used by plugin_callback_start and plugin_callback_end TCG ops */ +enum plugin_gen_from { + PLUGIN_GEN_FROM_TB, + PLUGIN_GEN_FROM_INSN, + PLUGIN_GEN_FROM_MEM, + PLUGIN_GEN_AFTER_INSN, + PLUGIN_GEN_N_FROMS, +}; + +struct DisasContextBase; + +#ifdef CONFIG_PLUGIN + +bool plugin_gen_tb_start(CPUState *cpu, const TranslationBlock *tb); +void plugin_gen_tb_end(CPUState *cpu); +void plugin_gen_insn_start(CPUState *cpu, const struct DisasContextBase *d= b); +void plugin_gen_insn_end(void); + +void plugin_gen_disable_mem_helpers(void); +void plugin_gen_empty_mem_callback(TCGv addr, uint8_t info); + +#else /* !CONFIG_PLUGIN */ + +static inline +bool plugin_gen_tb_start(CPUState *cpu, const TranslationBlock *tb) +{ + return false; +} + +static inline +void plugin_gen_insn_start(CPUState *cpu, const struct DisasContextBase *d= b) +{ } + +static inline void plugin_gen_insn_end(void) +{ } + +static inline void plugin_gen_tb_end(CPUState *cpu) +{ } + +static inline void plugin_gen_disable_mem_helpers(void) +{ } + +static inline void plugin_gen_empty_mem_callback(TCGv addr, uint8_t info) +{ } + +#endif /* CONFIG_PLUGIN */ + +#endif /* QEMU_PLUGIN_GEN_H */ + diff --git a/tcg/tcg-op.h b/tcg/tcg-op.h index 7513c1eb7c..e2948b10a2 100644 --- a/tcg/tcg-op.h +++ b/tcg/tcg-op.h @@ -822,6 +822,17 @@ void tcg_gen_goto_tb(unsigned idx); */ void tcg_gen_lookup_and_goto_ptr(void); =20 +static inline void tcg_gen_plugin_cb_start(unsigned from, unsigned type, + unsigned wr) +{ + tcg_gen_op3(INDEX_op_plugin_cb_start, from, type, wr); +} + +static inline void tcg_gen_plugin_cb_end(void) +{ + tcg_emit_op(INDEX_op_plugin_cb_end); +} + #if TARGET_LONG_BITS =3D=3D 32 #define tcg_temp_new() tcg_temp_new_i32() #define tcg_global_reg_new tcg_global_reg_new_i32 diff --git a/tcg/tcg-opc.h b/tcg/tcg-opc.h index e3a43aabb6..d15d0b9874 100644 --- a/tcg/tcg-opc.h +++ b/tcg/tcg-opc.h @@ -195,6 +195,9 @@ DEF(exit_tb, 0, 0, 1, TCG_OPF_BB_END) DEF(goto_tb, 0, 0, 1, TCG_OPF_BB_END) DEF(goto_ptr, 0, 1, 0, TCG_OPF_BB_END | IMPL(TCG_TARGET_HAS_goto_ptr)) =20 +DEF(plugin_cb_start, 0, 0, 3, TCG_OPF_NOT_PRESENT) +DEF(plugin_cb_end, 0, 0, 0, TCG_OPF_NOT_PRESENT) + DEF(qemu_ld_i32, 1, TLADDR_ARGS, 1, TCG_OPF_CALL_CLOBBER | TCG_OPF_SIDE_EFFECTS) DEF(qemu_st_i32, 0, TLADDR_ARGS + 1, 1, diff --git a/tcg/tcg.h b/tcg/tcg.h index a745e926bb..6fd525023b 100644 --- a/tcg/tcg.h +++ b/tcg/tcg.h @@ -615,6 +615,9 @@ typedef struct TCGOp { =20 /* Next and previous opcodes. */ QTAILQ_ENTRY(TCGOp) link; +#ifdef CONFIG_PLUGIN + QSIMPLEQ_ENTRY(TCGOp) plugin_link; +#endif =20 /* Arguments for the opcode. */ TCGArg args[MAX_OPC_PARAM]; @@ -712,6 +715,23 @@ struct TCGContext { =20 TCGLabel *exitreq_label; =20 +#ifdef CONFIG_PLUGIN + /* + * We keep one plugin_tb struct per TCGContext. Note that on every TB + * translation we clear but do not free its contents; this way we + * avoid a lot of malloc/free churn, since after a few TB's it's + * unlikely that we'll need to allocate either more instructions or mo= re + * space for instructions (for variable-instruction-length ISAs). + */ + struct qemu_plugin_tb *plugin_tb; + + /* descriptor of the instruction being translated */ + struct qemu_plugin_insn *plugin_insn; + + /* list to quickly access the injected ops */ + QSIMPLEQ_HEAD(, TCGOp) plugin_ops; +#endif + TCGTempSet free_temps[TCG_TYPE_COUNT * 2]; TCGTemp temps[TCG_MAX_TEMPS]; /* globals first, temps after */ =20 diff --git a/accel/tcg/plugin-gen.c b/accel/tcg/plugin-gen.c new file mode 100644 index 0000000000..06ec23e9f5 --- /dev/null +++ b/accel/tcg/plugin-gen.c @@ -0,0 +1,1077 @@ +/* + * plugin-gen.c - TCG-related bits of plugin infrastructure + * + * Copyright (C) 2018, Emilio G. Cota + * License: GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + * + * We support instrumentation at an instruction granularity. That is, + * if a plugin wants to instrument the memory accesses performed by a + * particular instruction, it can just do that instead of instrumenting + * all memory accesses. Thus, in order to do this we first have to + * translate a TB, so that plugins can decide what/where to instrument. + * + * Injecting the desired instrumentation could be done with a second + * translation pass that combined the instrumentation requests, but that + * would be ugly and inefficient since we would decode the guest code twic= e. + * Instead, during TB translation we add "empty" instrumentation calls for= all + * possible instrumentation events, and then once we collect the instrumen= tation + * requests from plugins, we either "fill in" those empty events or remove= them + * if they have no requests. + * + * When "filling in" an event we first copy the empty callback's TCG ops. = This + * might seem unnecessary, but it is done to support an arbitrary number + * of callbacks per event. Take for example a regular instruction callback. + * We first generate a callback to an empty helper function. Then, if two + * plugins register one callback each for this instruction, we make two co= pies + * of the TCG ops generated for the empty callback, substituting the funct= ion + * pointer that points to the empty helper function with the plugins' desi= red + * callback functions. After that we remove the empty callback's ops. + * + * Note that the location in TCGOp.args[] of the pointer to a helper funct= ion + * varies across different guest and host architectures. Instead of duplic= ating + * the logic that figures this out, we rely on the fact that the empty + * callbacks point to empty functions that are unique pointers in the prog= ram. + * Thus, to find the right location we just have to look for a match in + * TCGOp.args[]. This is the main reason why we first copy an empty callba= ck's + * TCG ops and then fill them in; regardless of whether we have one or many + * callbacks for that event, the logic to add all of them is the same. + * + * When generating more than one callback per event, we make a small + * optimization to avoid generating redundant operations. For instance, fo= r the + * second and all subsequent callbacks of an event, we do not need to relo= ad the + * CPU's index into a TCG temp, since the first callback did it already. + */ +#include "qemu/osdep.h" +#include "cpu.h" +#include "tcg/tcg.h" +#include "tcg/tcg-op.h" +#include "trace/mem.h" +#include "exec/exec-all.h" +#include "exec/plugin-gen.h" +#include "exec/translator.h" + +#ifdef CONFIG_SOFTMMU +# define CONFIG_SOFTMMU_GATE 1 +#else +# define CONFIG_SOFTMMU_GATE 0 +#endif + +/* + * plugin_cb_start TCG op args[]: + * 0: enum plugin_gen_from + * 1: enum plugin_gen_cb (defined below) + * 2: set to 1 if it's a mem callback and it's a write, 0 otherwise. + */ +enum plugin_gen_cb { + PLUGIN_GEN_CB_UDATA, + PLUGIN_GEN_CB_INLINE, + PLUGIN_GEN_CB_MEM, + PLUGIN_GEN_CB_HADDR, + PLUGIN_GEN_ENABLE_MEM_HELPER, + PLUGIN_GEN_DISABLE_MEM_HELPER, + PLUGIN_GEN_N_CBS, +}; + +void HELPER(plugin_vcpu_udata_cb)(uint32_t cpu_index, void *udata) +{ } + +void HELPER(plugin_vcpu_mem_cb)(unsigned int vcpu_index, + qemu_plugin_meminfo_t info, uint64_t vaddr, + void *userdata) +{ } + +void HELPER(plugin_vcpu_mem_haddr_cb)(unsigned int vcpu_index, + qemu_plugin_meminfo_t info, + uint64_t vaddr, void *haddr, + void *userdata) +{ } + +static void do_gen_mem_cb(TCGv vaddr, uint8_t info, bool is_haddr) +{ + TCGv_i32 cpu_index =3D tcg_temp_new_i32(); + TCGv_i32 meminfo =3D tcg_const_i32(info); + TCGv_i64 vaddr64 =3D tcg_temp_new_i64(); + TCGv_ptr udata =3D tcg_const_ptr(NULL); + TCGv_ptr haddr; + + tcg_gen_ld_i32(cpu_index, cpu_env, + -ENV_OFFSET + offsetof(CPUState, cpu_index)); + tcg_gen_extu_tl_i64(vaddr64, vaddr); + + if (is_haddr) { + /* + * Can't use CONFIG_SOFTMMU_GATE here because CPUArchState.hostaddr + * only exists in CONFIG_SOFTMMU. + */ +#ifdef CONFIG_SOFTMMU + haddr =3D tcg_temp_new_ptr(); + tcg_gen_ld_ptr(haddr, cpu_env, offsetof(CPUArchState, hostaddr)); +#else + haddr =3D tcg_const_ptr(NULL); +#endif + gen_helper_plugin_vcpu_mem_haddr_cb(cpu_index, meminfo, vaddr64, + haddr, udata); + tcg_temp_free_ptr(haddr); + } else { + gen_helper_plugin_vcpu_mem_cb(cpu_index, meminfo, vaddr64, udata); + } + + tcg_temp_free_ptr(udata); + tcg_temp_free_i64(vaddr64); + tcg_temp_free_i32(meminfo); + tcg_temp_free_i32(cpu_index); +} + +static void gen_empty_udata_cb(void) +{ + TCGv_i32 cpu_index =3D tcg_temp_new_i32(); + TCGv_ptr udata =3D tcg_const_ptr(NULL); /* will be overwritten later */ + + tcg_gen_ld_i32(cpu_index, cpu_env, + -ENV_OFFSET + offsetof(CPUState, cpu_index)); + gen_helper_plugin_vcpu_udata_cb(cpu_index, udata); + + tcg_temp_free_ptr(udata); + tcg_temp_free_i32(cpu_index); +} + +/* + * For now we only support addi_i64. + * When we support more ops, we can generate one empty inline cb for each. + */ +static void gen_empty_inline_cb(void) +{ + TCGv_i64 val =3D tcg_temp_new_i64(); + TCGv_ptr ptr =3D tcg_const_ptr(NULL); /* overwritten later */ + + 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); + tcg_gen_st_i64(val, ptr, 0); + tcg_temp_free_ptr(ptr); + tcg_temp_free_i64(val); +} + +static void gen_empty_mem_cb(TCGv addr, uint8_t info) +{ + do_gen_mem_cb(addr, info, false); +} + +static void gen_empty_haddr_cb(TCGv addr, uint8_t info) +{ + do_gen_mem_cb(addr, info, true); +} + +/* + * Share the same function for enable/disable. When enabling, the NULL + * pointer will be overwritten later. + */ +static void gen_empty_mem_helper(void) +{ + TCGv_ptr ptr; + + ptr =3D tcg_const_ptr(NULL); + tcg_gen_st_ptr(ptr, cpu_env, -ENV_OFFSET + offsetof(CPUState, + plugin_mem_cbs)); + tcg_temp_free_ptr(ptr); +} + +static inline +void gen_plugin_cb_start(enum plugin_gen_from from, + enum plugin_gen_cb type, unsigned wr) +{ + TCGOp *op; + + tcg_gen_plugin_cb_start(from, type, wr); + op =3D tcg_last_op(); + QSIMPLEQ_INSERT_TAIL(&tcg_ctx->plugin_ops, op, plugin_link); +} + +static void gen_wrapped(enum plugin_gen_from from, + enum plugin_gen_cb type, void (*func)(void)) +{ + gen_plugin_cb_start(from, type, 0); + func(); + tcg_gen_plugin_cb_end(); +} + +static inline void plugin_gen_empty_callback(enum plugin_gen_from from) +{ + switch (from) { + case PLUGIN_GEN_AFTER_INSN: + gen_wrapped(from, PLUGIN_GEN_DISABLE_MEM_HELPER, + gen_empty_mem_helper); + break; + case PLUGIN_GEN_FROM_INSN: + /* + * Note: plugin_gen_inject() relies on ENABLE_MEM_HELPER being + * the first callback of an instruction + */ + gen_wrapped(from, PLUGIN_GEN_ENABLE_MEM_HELPER, + gen_empty_mem_helper); + /* fall through */ + case PLUGIN_GEN_FROM_TB: + gen_wrapped(from, PLUGIN_GEN_CB_UDATA, gen_empty_udata_cb); + gen_wrapped(from, PLUGIN_GEN_CB_INLINE, gen_empty_inline_cb); + break; + default: + g_assert_not_reached(); + } +} + +union mem_gen_fn { + void (*mem_fn)(TCGv, uint8_t); + void (*inline_fn)(void); +}; + +static void gen_mem_wrapped(enum plugin_gen_cb type, + const union mem_gen_fn *f, TCGv addr, + uint8_t info, bool is_mem) +{ + int wr =3D !!(info & TRACE_MEM_ST); + + gen_plugin_cb_start(PLUGIN_GEN_FROM_MEM, type, wr); + if (is_mem) { + f->mem_fn(addr, info); + } else { + f->inline_fn(); + } + tcg_gen_plugin_cb_end(); +} + +void plugin_gen_empty_mem_callback(TCGv addr, uint8_t info) +{ + union mem_gen_fn fn; + + fn.mem_fn =3D gen_empty_mem_cb; + gen_mem_wrapped(PLUGIN_GEN_CB_MEM, &fn, addr, info, true); + + fn.mem_fn =3D gen_empty_haddr_cb; + gen_mem_wrapped(PLUGIN_GEN_CB_HADDR, &fn, addr, info, true); + + fn.inline_fn =3D gen_empty_inline_cb; + gen_mem_wrapped(PLUGIN_GEN_CB_INLINE, &fn, 0, info, false); +} + +static TCGOp *find_op(TCGOp *op, TCGOpcode opc) +{ + while (op) { + if (op->opc =3D=3D opc) { + return op; + } + op =3D QTAILQ_NEXT(op, link); + } + return NULL; +} + +static TCGOp *rm_ops_range(TCGOp *begin, TCGOp *end) +{ + TCGOp *ret =3D QTAILQ_NEXT(end, link); + + QTAILQ_REMOVE_SEVERAL(&tcg_ctx->ops, begin, end, link); + return ret; +} + +/* remove all ops until (and including) plugin_cb_end */ +static TCGOp *rm_ops(TCGOp *op) +{ + TCGOp *end_op =3D find_op(op, INDEX_op_plugin_cb_end); + + tcg_debug_assert(end_op); + return rm_ops_range(op, end_op); +} + +static TCGOp *copy_op_nocheck(TCGOp **begin_op, TCGOp *op) +{ + *begin_op =3D QTAILQ_NEXT(*begin_op, link); + tcg_debug_assert(*begin_op); + op =3D tcg_op_insert_after(tcg_ctx, op, (*begin_op)->opc); + memcpy(op->args, (*begin_op)->args, sizeof(op->args)); + return op; +} + +static TCGOp *copy_op(TCGOp **begin_op, TCGOp *op, TCGOpcode opc) +{ + op =3D copy_op_nocheck(begin_op, op); + tcg_debug_assert((*begin_op)->opc =3D=3D opc); + return op; +} + +static TCGOp *copy_extu_i32_i64(TCGOp **begin_op, TCGOp *op) +{ + if (TCG_TARGET_REG_BITS =3D=3D 32) { + /* mov_i32 */ + op =3D copy_op(begin_op, op, INDEX_op_mov_i32); + /* movi_i32 */ + op =3D copy_op(begin_op, op, INDEX_op_movi_i32); + } else { + /* extu_i32_i64 */ + op =3D copy_op(begin_op, op, INDEX_op_extu_i32_i64); + } + return op; +} + +static TCGOp *copy_mov_i64(TCGOp **begin_op, TCGOp *op) +{ + if (TCG_TARGET_REG_BITS =3D=3D 32) { + /* 2x mov_i32 */ + op =3D copy_op(begin_op, op, INDEX_op_mov_i32); + op =3D copy_op(begin_op, op, INDEX_op_mov_i32); + } else { + /* mov_i64 */ + op =3D copy_op(begin_op, op, INDEX_op_mov_i64); + } + return op; +} + +static TCGOp *copy_movi_i64(TCGOp **begin_op, TCGOp *op, uint64_t v) +{ + if (TCG_TARGET_REG_BITS =3D=3D 32) { + /* 2x movi_i32 */ + op =3D copy_op(begin_op, op, INDEX_op_movi_i32); + op->args[1] =3D v; + + op =3D copy_op(begin_op, op, INDEX_op_movi_i32); + op->args[1] =3D v >> 32; + } else { + /* movi_i64 */ + op =3D copy_op(begin_op, op, INDEX_op_movi_i64); + op->args[1] =3D v; + } + return op; +} + +static TCGOp *copy_const_ptr(TCGOp **begin_op, TCGOp *op, void *ptr) +{ + if (UINTPTR_MAX =3D=3D UINT32_MAX) { + /* movi_i32 */ + op =3D copy_op(begin_op, op, INDEX_op_movi_i32); + op->args[1] =3D (uintptr_t)ptr; + } else { + /* movi_i64 */ + op =3D copy_movi_i64(begin_op, op, (uint64_t)(uintptr_t)ptr); + } + return op; +} + +static TCGOp *copy_const_i64(TCGOp **begin_op, TCGOp *op, uint64_t v) +{ + return copy_movi_i64(begin_op, op, v); +} + +static TCGOp *copy_extu_tl_i64(TCGOp **begin_op, TCGOp *op) +{ + if (TARGET_LONG_BITS =3D=3D 32) { + /* extu_i32_i64 */ + op =3D copy_extu_i32_i64(begin_op, op); + } else { + /* mov_i64 */ + op =3D copy_mov_i64(begin_op, op); + } + 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); + } else { + /* ld_i64 */ + op =3D copy_op(begin_op, op, INDEX_op_ld_i64); + } + return op; +} + +static TCGOp *copy_ld_ptr(TCGOp **begin_op, TCGOp *op) +{ + if (UINTPTR_MAX =3D=3D UINT32_MAX) { + /* ld_i32 */ + op =3D copy_op(begin_op, op, INDEX_op_ld_i32); + } else { + /* ld_i64 */ + op =3D copy_ld_i64(begin_op, op); + } + return op; +} + +static TCGOp *skip_ld_i64(TCGOp *begin_op) +{ + TCGOp *op; + + if (TCG_TARGET_REG_BITS =3D=3D 32) { + /* 2x ld_i32 */ + op =3D QTAILQ_NEXT(begin_op, link); + tcg_debug_assert(op->opc =3D=3D INDEX_op_ld_i32); + op =3D QTAILQ_NEXT(op, link); + tcg_debug_assert(op->opc =3D=3D INDEX_op_ld_i32); + } else { + /* ld_i64 */ + op =3D QTAILQ_NEXT(begin_op, link); + tcg_debug_assert(op->opc =3D=3D INDEX_op_ld_i64); + } + return op; +} + +static TCGOp *skip_ld_ptr(TCGOp *begin_op) +{ + TCGOp *op; + + if (UINTPTR_MAX =3D=3D UINT32_MAX) { + /* ld_i32 */ + op =3D QTAILQ_NEXT(begin_op, link); + tcg_debug_assert(op->opc =3D=3D INDEX_op_ld_i32); + } else { + /* ld_i64 */ + op =3D skip_ld_i64(begin_op); + } + return op; +} + +static TCGOp *copy_st_i64(TCGOp **begin_op, TCGOp *op) +{ + if (TCG_TARGET_REG_BITS =3D=3D 32) { + /* 2x st_i32 */ + op =3D copy_op(begin_op, op, INDEX_op_st_i32); + op =3D copy_op(begin_op, op, INDEX_op_st_i32); + } else { + /* st_i64 */ + op =3D copy_op(begin_op, op, INDEX_op_st_i64); + } + return op; +} + +static TCGOp *copy_add_i64(TCGOp **begin_op, TCGOp *op) +{ + if (TCG_TARGET_REG_BITS =3D=3D 32) { + /* all 32-bit backends must implement add2_i32 */ + g_assert(TCG_TARGET_HAS_add2_i32); + op =3D copy_op(begin_op, op, INDEX_op_add2_i32); + } else { + op =3D copy_op(begin_op, op, INDEX_op_add_i64); + } + return op; +} + +static TCGOp *copy_st_ptr(TCGOp **begin_op, TCGOp *op) +{ + if (UINTPTR_MAX =3D=3D UINT32_MAX) { + /* st_i32 */ + op =3D copy_op(begin_op, op, INDEX_op_st_i32); + } else { + /* st_i64 */ + op =3D copy_st_i64(begin_op, op); + } + return op; +} + +static TCGOp *copy_call(TCGOp **begin_op, TCGOp *op, void *empty_func, + void *func, unsigned tcg_flags, int *cb_idx) +{ + /* copy all ops until the call */ + do { + op =3D copy_op_nocheck(begin_op, op); + } while (op->opc !=3D INDEX_op_call); + + /* fill in the op call */ + op->param1 =3D (*begin_op)->param1; + op->param2 =3D (*begin_op)->param2; + tcg_debug_assert(op->life =3D=3D 0); + if (*cb_idx =3D=3D -1) { + int i; + + /* + * Instead of working out the position of the callback in args[], = just + * look for @empty_func, since it should be a unique pointer. + */ + for (i =3D 0; i < MAX_OPC_PARAM_ARGS; i++) { + if ((uintptr_t)(*begin_op)->args[i] =3D=3D (uintptr_t)empty_fu= nc) { + *cb_idx =3D i; + break; + } + } + tcg_debug_assert(i < MAX_OPC_PARAM_ARGS); + } + op->args[*cb_idx] =3D (uintptr_t)func; + op->args[*cb_idx + 1] =3D tcg_flags; + + return op; +} + +static TCGOp *append_udata_cb(const struct qemu_plugin_dyn_cb *cb, + TCGOp *begin_op, TCGOp *op, int *cb_idx) +{ + /* const_ptr */ + op =3D copy_const_ptr(&begin_op, op, cb->userp); + + /* copy the ld_i32, but note that we only have to copy it once */ + begin_op =3D QTAILQ_NEXT(begin_op, link); + tcg_debug_assert(begin_op && begin_op->opc =3D=3D INDEX_op_ld_i32); + if (*cb_idx =3D=3D -1) { + op =3D tcg_op_insert_after(tcg_ctx, op, INDEX_op_ld_i32); + memcpy(op->args, begin_op->args, sizeof(op->args)); + } + + /* call */ + op =3D copy_call(&begin_op, op, HELPER(plugin_vcpu_udata_cb), + cb->f.vcpu_udata, cb->tcg_flags, cb_idx); + + return op; +} + +static TCGOp *append_inline_cb(const struct qemu_plugin_dyn_cb *cb, + TCGOp *begin_op, TCGOp *op, + int *unused) +{ + /* const_ptr */ + op =3D copy_const_ptr(&begin_op, op, cb->userp); + + /* ld_i64 */ + op =3D copy_ld_i64(&begin_op, op); + + /* const_i64 */ + op =3D copy_const_i64(&begin_op, op, cb->inline_insn.imm); + + /* add_i64 */ + op =3D copy_add_i64(&begin_op, op); + + /* st_i64 */ + op =3D copy_st_i64(&begin_op, op); + + return op; +} + +static void set_memop_haddr_ldst_i32(TCGOp *op) +{ + int idx; + + if (TARGET_LONG_BITS =3D=3D 32) { + idx =3D 2; + } else { + idx =3D TCG_TARGET_REG_BITS =3D=3D 32 ? 3 : 2; + } + op->args[idx] |=3D make_memop_idx(MO_HADDR, 0); +} + +static void set_memop_haddr_ldst_i64(TCGOp *op) +{ + int idx; + + if (TARGET_LONG_BITS =3D=3D 32) { + idx =3D TCG_TARGET_REG_BITS =3D=3D 32 ? 3 : 2; + } else { + idx =3D TCG_TARGET_REG_BITS =3D=3D 32 ? 4 : 2; + } + op->args[idx] |=3D make_memop_idx(MO_HADDR, 0); +} + +static void find_prev_and_set_memop_haddr(TCGOp *op) +{ + while ((op =3D QTAILQ_PREV(op, TCGOpHead, link))) { + switch (op->opc) { + case INDEX_op_qemu_ld_i32: + case INDEX_op_qemu_st_i32: + set_memop_haddr_ldst_i32(op); + return; + case INDEX_op_qemu_ld_i64: + case INDEX_op_qemu_st_i64: + set_memop_haddr_ldst_i64(op); + return; + default: + break; + } + } + g_assert_not_reached(); +} + +static TCGOp *append_mem_cb(const struct qemu_plugin_dyn_cb *cb, + TCGOp *begin_op, TCGOp *op, int *cb_idx) +{ + enum plugin_gen_cb type =3D begin_op->args[1]; + + tcg_debug_assert(type =3D=3D PLUGIN_GEN_CB_MEM || type =3D=3D PLUGIN_G= EN_CB_HADDR); + + /* const_i32 =3D=3D movi_i32 ("info", so it remains as is) */ + op =3D copy_op(&begin_op, op, INDEX_op_movi_i32); + + /* const_ptr */ + op =3D copy_const_ptr(&begin_op, op, cb->userp); + + /* copy the ld_i32, but note that we only have to copy it once */ + begin_op =3D QTAILQ_NEXT(begin_op, link); + tcg_debug_assert(begin_op && begin_op->opc =3D=3D INDEX_op_ld_i32); + if (*cb_idx =3D=3D -1) { + op =3D tcg_op_insert_after(tcg_ctx, op, INDEX_op_ld_i32); + memcpy(op->args, begin_op->args, sizeof(op->args)); + } + + /* extu_tl_i64 */ + op =3D copy_extu_tl_i64(&begin_op, op); + + if (type =3D=3D PLUGIN_GEN_CB_MEM) { + /* call */ + op =3D copy_call(&begin_op, op, HELPER(plugin_vcpu_mem_cb), + cb->f.vcpu_udata, cb->tcg_flags, cb_idx); + } else { + if (CONFIG_SOFTMMU_GATE) { + /* ld_ptr; note that we only have to copy it once */ + if (*cb_idx =3D=3D -1) { + op =3D copy_ld_ptr(&begin_op, op); + find_prev_and_set_memop_haddr(begin_op); + } else { + begin_op =3D skip_ld_ptr(begin_op); + } + } else { + /* const_ptr; set it to NULL */ + op =3D copy_const_ptr(&begin_op, op, NULL); + } + /* call */ + op =3D copy_call(&begin_op, op, HELPER(plugin_vcpu_mem_haddr_cb), + cb->f.vcpu_mem_haddr, cb->tcg_flags, cb_idx); + } + + return op; +} + +typedef TCGOp *(*inject_fn)(const struct qemu_plugin_dyn_cb *cb, + TCGOp *begin_op, TCGOp *op, int *intp); +typedef bool (*op_ok_fn)(const TCGOp *op, const struct qemu_plugin_dyn_cb = *cb); + +static bool op_ok(const TCGOp *op, const struct qemu_plugin_dyn_cb *cb) +{ + return true; +} + +static bool op_rw(const TCGOp *op, const struct qemu_plugin_dyn_cb *cb) +{ + int w; + + w =3D op->args[2]; + return !!(cb->rw & (w + 1)); +} + +static inline +void inject_cb_type(const struct qemu_plugin_dyn_cb_arr *cbs, TCGOp *begin= _op, + inject_fn inject, op_ok_fn ok) +{ + TCGOp *end_op; + TCGOp *op; + int cb_idx =3D -1; + int i; + + if (cbs->n =3D=3D 0) { + rm_ops(begin_op); + return; + } + + end_op =3D find_op(begin_op, INDEX_op_plugin_cb_end); + tcg_debug_assert(end_op); + + op =3D end_op; + for (i =3D 0; i < cbs->n; i++) { + struct qemu_plugin_dyn_cb *cb =3D &cbs->data[i]; + + if (!ok(begin_op, cb)) { + continue; + } + op =3D inject(cb, begin_op, op, &cb_idx); + } + rm_ops_range(begin_op, end_op); +} + +static void +inject_udata_cb(const struct qemu_plugin_dyn_cb_arr *cbs, TCGOp *begin_op) +{ + inject_cb_type(cbs, begin_op, append_udata_cb, op_ok); +} + +static void +inject_inline_cb(const struct qemu_plugin_dyn_cb_arr *cbs, TCGOp *begin_op, + op_ok_fn ok) +{ + inject_cb_type(cbs, begin_op, append_inline_cb, ok); +} + +static void +inject_mem_cb(const struct qemu_plugin_dyn_cb_arr *cbs, TCGOp *begin_op) +{ + inject_cb_type(cbs, begin_op, append_mem_cb, op_rw); +} + +/* we could change the ops in place, but we can reuse more code by copying= */ +static void inject_mem_helper(TCGOp *begin_op, + struct qemu_plugin_dyn_cb_arr *arr) +{ + TCGOp *orig_op =3D begin_op; + TCGOp *end_op; + TCGOp *op; + + end_op =3D find_op(begin_op, INDEX_op_plugin_cb_end); + tcg_debug_assert(end_op); + + /* const ptr */ + op =3D copy_const_ptr(&begin_op, end_op, arr); + + /* st_ptr */ + op =3D copy_st_ptr(&begin_op, op); + + rm_ops_range(orig_op, end_op); +} + +/* + * Tracking memory accesses performed from helpers requires extra work. + * If an instruction is emulated with helpers, we do two things: + * (1) copy the CB descriptors, and keep track of it so that they can be + * freed later on, and (2) point CPUState.plugin_mem_cbs to the descriptor= s, so + * that we can read them at run-time (i.e. when the helper executes). + * This run-time access is performed from qemu_plugin_vcpu_mem_cb. + * + * Note that plugin_gen_disable_mem_helpers undoes (2). Since it + * is possible that the code we generate after the instruction is + * dead, we also add checks before generating tb_exit etc. + */ +static void inject_mem_enable_helper(struct qemu_plugin_insn *plugin_insn, + TCGOp *begin_op) +{ + const struct qemu_plugin_dyn_cb_arr *cbs[3]; + struct qemu_plugin_dyn_cb_arr *arr; + size_t total, n_cbs, i; + + cbs[0] =3D &plugin_insn->cbs[PLUGIN_CB_MEM][PLUGIN_CB_REGULAR]; + cbs[1] =3D &plugin_insn->cbs[PLUGIN_CB_MEM][PLUGIN_CB_INLINE]; + cbs[2] =3D &plugin_insn->cbs[PLUGIN_CB_HADDR][PLUGIN_CB_REGULAR]; + + n_cbs =3D 0; + for (i =3D 0; i < ARRAY_SIZE(cbs); i++) { + n_cbs +=3D cbs[i]->n; + } + + plugin_insn->mem_helper =3D plugin_insn->calls_helpers && n_cbs; + if (likely(!plugin_insn->mem_helper)) { + rm_ops(begin_op); + return; + } + + arr =3D g_new(struct qemu_plugin_dyn_cb_arr, 1); + arr->capacity =3D n_cbs; + arr->n =3D n_cbs; + arr->data =3D g_new(struct qemu_plugin_dyn_cb, arr->n); + + total =3D 0; + for (i =3D 0; i < ARRAY_SIZE(cbs); i++) { + const struct qemu_plugin_dyn_cb_arr *from =3D cbs[i]; + + memcpy(arr->data + total, from->data, sizeof(*arr->data) * from->n= ); + total +=3D from->n; + } + + qemu_plugin_add_dyn_cb_arr(arr); + inject_mem_helper(begin_op, arr); +} + +static void inject_mem_disable_helper(struct qemu_plugin_insn *plugin_insn, + TCGOp *begin_op) +{ + if (likely(!plugin_insn->mem_helper)) { + rm_ops(begin_op); + return; + } + inject_mem_helper(begin_op, NULL); +} + +/* called before finishing a TB with exit_tb, goto_tb or goto_ptr */ +void plugin_gen_disable_mem_helpers(void) +{ + TCGv_ptr ptr; + + if (likely(tcg_ctx->plugin_insn =3D=3D NULL || + !tcg_ctx->plugin_insn->mem_helper)) { + return; + } + ptr =3D tcg_const_ptr(NULL); + tcg_gen_st_ptr(ptr, cpu_env, -ENV_OFFSET + offsetof(CPUState, + plugin_mem_cbs)); + tcg_temp_free_ptr(ptr); + tcg_ctx->plugin_insn->mem_helper =3D false; +} + +static void plugin_gen_tb_udata(const struct qemu_plugin_tb *ptb, + TCGOp *begin_op) +{ + inject_udata_cb(&ptb->cbs[PLUGIN_CB_REGULAR], begin_op); +} + +static void plugin_gen_tb_inline(const struct qemu_plugin_tb *ptb, + TCGOp *begin_op) +{ + inject_inline_cb(&ptb->cbs[PLUGIN_CB_INLINE], begin_op, op_ok); +} + +static void plugin_gen_insn_udata(const struct qemu_plugin_tb *ptb, + TCGOp *begin_op, int insn_idx) +{ + const struct qemu_plugin_dyn_cb_arr *cbs; + + cbs =3D &ptb->insns[insn_idx].cbs[PLUGIN_CB_INSN][PLUGIN_CB_REGULAR]; + inject_udata_cb(cbs, begin_op); +} + +static void plugin_gen_insn_inline(const struct qemu_plugin_tb *ptb, + TCGOp *begin_op, int insn_idx) +{ + const struct qemu_plugin_dyn_cb_arr *cbs; + + cbs =3D &ptb->insns[insn_idx].cbs[PLUGIN_CB_INSN][PLUGIN_CB_INLINE]; + inject_inline_cb(cbs, begin_op, op_ok); +} + +static void plugin_gen_mem_regular(const struct qemu_plugin_tb *ptb, + TCGOp *begin_op, int insn_idx) +{ + const struct qemu_plugin_dyn_cb_arr *cbs; + + cbs =3D &ptb->insns[insn_idx].cbs[PLUGIN_CB_MEM][PLUGIN_CB_REGULAR]; + inject_mem_cb(cbs, begin_op); +} + +static void plugin_gen_mem_inline(const struct qemu_plugin_tb *ptb, + TCGOp *begin_op, int insn_idx) +{ + const struct qemu_plugin_dyn_cb_arr *cbs; + + cbs =3D &ptb->insns[insn_idx].cbs[PLUGIN_CB_MEM][PLUGIN_CB_INLINE]; + inject_inline_cb(cbs, begin_op, op_rw); +} + +static void plugin_gen_haddr_regular(const struct qemu_plugin_tb *ptb, + TCGOp *begin_op, int insn_idx) +{ + const struct qemu_plugin_dyn_cb_arr *cbs; + + cbs =3D &ptb->insns[insn_idx].cbs[PLUGIN_CB_HADDR][PLUGIN_CB_REGULAR]; + inject_mem_cb(cbs, begin_op); +} + +static void plugin_gen_enable_mem_helper(const struct qemu_plugin_tb *ptb, + TCGOp *begin_op, int insn_idx) +{ + inject_mem_enable_helper(&ptb->insns[insn_idx], begin_op); +} + +static void plugin_gen_disable_mem_helper(const struct qemu_plugin_tb *ptb, + TCGOp *begin_op, int insn_idx) +{ + inject_mem_disable_helper(&ptb->insns[insn_idx], begin_op); +} + +static void plugin_inject_cb(const struct qemu_plugin_tb *ptb, TCGOp *begi= n_op, + int insn_idx) +{ + enum plugin_gen_from from =3D begin_op->args[0]; + enum plugin_gen_cb type =3D begin_op->args[1]; + + switch (from) { + case PLUGIN_GEN_FROM_TB: + switch (type) { + case PLUGIN_GEN_CB_UDATA: + plugin_gen_tb_udata(ptb, begin_op); + return; + case PLUGIN_GEN_CB_INLINE: + plugin_gen_tb_inline(ptb, begin_op); + return; + default: + g_assert_not_reached(); + } + case PLUGIN_GEN_FROM_INSN: + switch (type) { + case PLUGIN_GEN_CB_UDATA: + plugin_gen_insn_udata(ptb, begin_op, insn_idx); + return; + case PLUGIN_GEN_CB_INLINE: + plugin_gen_insn_inline(ptb, begin_op, insn_idx); + return; + case PLUGIN_GEN_ENABLE_MEM_HELPER: + plugin_gen_enable_mem_helper(ptb, begin_op, insn_idx); + return; + default: + g_assert_not_reached(); + } + case PLUGIN_GEN_FROM_MEM: + switch (type) { + case PLUGIN_GEN_CB_MEM: + plugin_gen_mem_regular(ptb, begin_op, insn_idx); + return; + case PLUGIN_GEN_CB_INLINE: + plugin_gen_mem_inline(ptb, begin_op, insn_idx); + return; + case PLUGIN_GEN_CB_HADDR: + plugin_gen_haddr_regular(ptb, begin_op, insn_idx); + return; + default: + g_assert_not_reached(); + } + case PLUGIN_GEN_AFTER_INSN: + switch (type) { + case PLUGIN_GEN_DISABLE_MEM_HELPER: + plugin_gen_disable_mem_helper(ptb, begin_op, insn_idx); + return; + default: + g_assert_not_reached(); + } + default: + g_assert_not_reached(); + } +} + +/* #define DEBUG_PLUGIN_GEN_OPS */ +static void pr_ops(void) +{ +#ifdef DEBUG_PLUGIN_GEN_OPS + TCGOp *op; + int i =3D 0; + + QTAILQ_FOREACH(op, &tcg_ctx->ops, link) { + const char *name =3D ""; + const char *type =3D ""; + + if (op->opc =3D=3D INDEX_op_plugin_cb_start) { + switch (op->args[0]) { + case PLUGIN_GEN_FROM_TB: + name =3D "tb"; + break; + case PLUGIN_GEN_FROM_INSN: + name =3D "insn"; + break; + case PLUGIN_GEN_FROM_MEM: + name =3D "mem"; + break; + case PLUGIN_GEN_AFTER_INSN: + name =3D "after insn"; + break; + default: + break; + } + switch (op->args[1]) { + case PLUGIN_GEN_CB_UDATA: + type =3D "udata"; + break; + case PLUGIN_GEN_CB_INLINE: + type =3D "inline"; + break; + case PLUGIN_GEN_CB_MEM: + type =3D "mem"; + break; + case PLUGIN_GEN_CB_HADDR: + type =3D "haddr"; + break; + case PLUGIN_GEN_ENABLE_MEM_HELPER: + type =3D "enable mem helper"; + break; + case PLUGIN_GEN_DISABLE_MEM_HELPER: + type =3D "disable mem helper"; + break; + default: + break; + } + } + printf("op[%2i]: %s %s %s\n", i, tcg_op_defs[op->opc].name, name, = type); + i++; + } +#endif +} + +static void plugin_gen_inject(const struct qemu_plugin_tb *plugin_tb) +{ + TCGOp *op; + int insn_idx; + + pr_ops(); + insn_idx =3D -1; + QSIMPLEQ_FOREACH(op, &tcg_ctx->plugin_ops, plugin_link) { + enum plugin_gen_from from =3D op->args[0]; + enum plugin_gen_cb type =3D op->args[1]; + + tcg_debug_assert(op->opc =3D=3D INDEX_op_plugin_cb_start); + /* ENABLE_MEM_HELPER is the first callback of an instruction */ + if (from =3D=3D PLUGIN_GEN_FROM_INSN && + type =3D=3D PLUGIN_GEN_ENABLE_MEM_HELPER) { + insn_idx++; + } + plugin_inject_cb(plugin_tb, op, insn_idx); + } + pr_ops(); +} + +bool plugin_gen_tb_start(CPUState *cpu, const TranslationBlock *tb) +{ + struct qemu_plugin_tb *ptb =3D tcg_ctx->plugin_tb; + bool ret =3D false; + + if (test_bit(QEMU_PLUGIN_EV_VCPU_TB_TRANS, cpu->plugin_mask)) { + ret =3D true; + + QSIMPLEQ_INIT(&tcg_ctx->plugin_ops); + ptb->vaddr =3D tb->pc; + ptb->vaddr2 =3D -1; + get_page_addr_code_hostp(cpu->env_ptr, tb->pc, &ptb->haddr1); + ptb->haddr2 =3D NULL; + + plugin_gen_empty_callback(PLUGIN_GEN_FROM_TB); + } + return ret; +} + +void plugin_gen_insn_start(CPUState *cpu, const DisasContextBase *db) +{ + struct qemu_plugin_tb *ptb =3D tcg_ctx->plugin_tb; + struct qemu_plugin_insn *pinsn; + + pinsn =3D qemu_plugin_tb_insn_get(ptb); + tcg_ctx->plugin_insn =3D pinsn; + pinsn->vaddr =3D db->pc_next; + plugin_gen_empty_callback(PLUGIN_GEN_FROM_INSN); + + /* + * Detect page crossing to get the new host address. + * Note that we skip this when haddr1 =3D=3D NULL, e.g. when we're + * fetching instructions from a region not backed by RAM. + */ + if (likely(ptb->haddr1 !=3D NULL && ptb->vaddr2 =3D=3D -1) && + unlikely((db->pc_next & TARGET_PAGE_MASK) !=3D + (db->pc_first & TARGET_PAGE_MASK))) { + get_page_addr_code_hostp(cpu->env_ptr, db->pc_next, + &ptb->haddr2); + ptb->vaddr2 =3D db->pc_next; + } + if (likely(ptb->vaddr2 =3D=3D -1)) { + pinsn->haddr =3D ptb->haddr1 + pinsn->vaddr - ptb->vaddr; + } else { + pinsn->haddr =3D ptb->haddr2 + pinsn->vaddr - ptb->vaddr2; + } +} + +void plugin_gen_insn_end(void) +{ + plugin_gen_empty_callback(PLUGIN_GEN_AFTER_INSN); +} + +void plugin_gen_tb_end(CPUState *cpu) +{ + struct qemu_plugin_tb *ptb =3D tcg_ctx->plugin_tb; + int i; + + /* collect instrumentation requests */ + qemu_plugin_tb_trans_cb(cpu, ptb); + + /* inject the instrumentation at the appropriate places */ + plugin_gen_inject(ptb); + + /* clean up */ + for (i =3D 0; i < PLUGIN_N_CB_SUBTYPES; i++) { + ptb->cbs[i].n =3D 0; + } + ptb->n =3D 0; + tcg_ctx->plugin_insn =3D NULL; +} diff --git a/tcg/tcg.c b/tcg/tcg.c index e87c662a18..9d72f35133 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -749,6 +749,12 @@ void tcg_register_thread(void) g_assert(n < max_cpus); atomic_set(&tcg_ctxs[n], s); =20 +#ifdef CONFIG_PLUGIN + if (n > 0) { + s->plugin_tb =3D g_new0(struct qemu_plugin_tb, 1); + } +#endif + tcg_ctx =3D s; qemu_mutex_lock(®ion.lock); err =3D tcg_region_initial_alloc__locked(tcg_ctx); @@ -945,6 +951,10 @@ void tcg_context_init(TCGContext *s) indirect_reg_alloc_order[i] =3D tcg_target_reg_alloc_order[i]; } =20 +#ifdef CONFIG_PLUGIN + s->plugin_tb =3D g_new0(struct qemu_plugin_tb, 1); +#endif + tcg_ctx =3D s; /* * In user-mode we simply share the init context among threads, since = we @@ -1626,6 +1636,13 @@ void tcg_gen_callN(void *func, TCGTemp *ret, int nar= gs, TCGTemp **args) flags =3D info->flags; sizemask =3D info->sizemask; =20 +#ifdef CONFIG_PLUGIN + /* detect non-plugin helpers */ + if (tcg_ctx->plugin_insn && unlikely(strncmp(info->name, "plugin_", 7)= )) { + tcg_ctx->plugin_insn->calls_helpers =3D true; + } +#endif + #if defined(__sparc__) && !defined(__arch64__) \ && !defined(CONFIG_TCG_INTERPRETER) /* We have 64-bit values in one register, but need to pass as two diff --git a/accel/tcg/Makefile.objs b/accel/tcg/Makefile.objs index d381a02f34..a92f2c454b 100644 --- a/accel/tcg/Makefile.objs +++ b/accel/tcg/Makefile.objs @@ -6,3 +6,4 @@ obj-y +=3D translator.o =20 obj-$(CONFIG_USER_ONLY) +=3D user-exec.o obj-$(call lnot,$(CONFIG_SOFTMMU)) +=3D user-exec-stub.o +obj-$(CONFIG_PLUGIN) +=3D plugin-gen.o --=20 2.17.1 From nobody Sat Apr 27 22:25:51 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1544384767683694.2847712154673; Sun, 9 Dec 2018 11:46:07 -0800 (PST) Received: from localhost ([::1]:56429 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gW51a-0000TI-Te for importer@patchew.org; Sun, 09 Dec 2018 14:45:59 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33240) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gW4u0-0000QY-VT for qemu-devel@nongnu.org; Sun, 09 Dec 2018 14:38:09 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gW4tw-0004zC-Rt for qemu-devel@nongnu.org; Sun, 09 Dec 2018 14:38:08 -0500 Received: from wout2-smtp.messagingengine.com ([64.147.123.25]:46029) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gW4tw-0004wY-KO for qemu-devel@nongnu.org; Sun, 09 Dec 2018 14:38:04 -0500 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id 25C1CF26; Sun, 9 Dec 2018 14:38:03 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Sun, 09 Dec 2018 14:38:03 -0500 Received: from localhost (flamenco.cs.columbia.edu [128.59.20.216]) by mail.messagingengine.com (Postfix) with ESMTPA id 705F4102DD; Sun, 9 Dec 2018 14:38:02 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=braap.org; h= from:to:cc:subject:date:message-id:in-reply-to:references; s= mesmtp; bh=hZQqr+5MOVSIw4b6LfzNojctEZKY0JDkDzB7FAxDiW0=; b=2mAA5 9FNW4DUVJG5Uo4drwjXvjvwXny6wK2WY0X9pvlFHI+VAy1dcrru8U8b1CGTWizyd 3/dkGqHZcklbrtJiAFaVkP9P4+y4bhj6x+f0uBtjad39xFTTQtxIyV2XPzYAE3y5 pxp7Q691gHhR4exZbOW/Tnn11S55Bzxos5PJgk= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:date:from:in-reply-to:message-id :references:subject:to:x-me-proxy:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; bh=hZQqr+5MOVSIw4b6LfzNojctEZKY0 JDkDzB7FAxDiW0=; b=Mv44hGN0ANdERX7X7pQcUabn1Gbd6RgLEejSjjswwe1JC VHTj+8WhAsW8Fo93i1WuG6neEDVgre7AMDslR/wAFlUcZvjEXf28CiIFEa3uoTig qMkAjUpOuw20ADu5OspYzgJINAS3vJ7ha89MWBbKivfSwJrN+uoU/tDfnvGEMOLb fzP6JYSzaUQQRnqvR9QN2Xz8hwM255zb7Zf6GS5QKhT/m335zBsOoe7XyTMwf2Oj Hc7rPpMi1IiP+Y3mrZ0zT7wUNM8GGol0qv7blK3fx29O6tUeNXP7eEsbk2Df5T4y Q7iMZ+0z6bGQnCR1ObJugkcAO2Ghs3VgYJ4FQz5Ow== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedtkedrudegfedguddvkecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfhuthenuceurghilhhouhhtmecu fedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvufffkf fojghfsedttdertdertddtnecuhfhrohhmpedfgfhmihhlihhoucfirdcuvehothgrfdcu oegtohhtrgessghrrggrphdrohhrgheqnecukfhppeduvdekrdehledrvddtrddvudeine curfgrrhgrmhepmhgrihhlfhhrohhmpegtohhtrgessghrrggrphdrohhrghenucevlhhu shhtvghrufhiiigvpedt X-ME-Proxy: From: "Emilio G. Cota" To: qemu-devel@nongnu.org Date: Sun, 9 Dec 2018 14:37:22 -0500 Message-Id: <20181209193749.12277-12-cota@braap.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181209193749.12277-1-cota@braap.org> References: <20181209193749.12277-1-cota@braap.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 64.147.123.25 Subject: [Qemu-devel] [RFC v2 11/38] tcg: add tcg_gen_st_ptr X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Richard Henderson , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Pavel Dovgalyuk Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Will gain a user soon. Signed-off-by: Emilio G. Cota Reviewed-by: Alex Benn=C3=A9e --- tcg/tcg-op.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tcg/tcg-op.h b/tcg/tcg-op.h index e2948b10a2..d3c79a6cb2 100644 --- a/tcg/tcg-op.h +++ b/tcg/tcg-op.h @@ -1219,6 +1219,11 @@ static inline void tcg_gen_ld_ptr(TCGv_ptr r, TCGv_p= tr a, intptr_t o) glue(tcg_gen_ld_,PTR)((NAT)r, a, o); } =20 +static inline void tcg_gen_st_ptr(TCGv_ptr r, TCGv_ptr a, intptr_t o) +{ + glue(tcg_gen_st_, PTR)((NAT)r, a, o); +} + static inline void tcg_gen_discard_ptr(TCGv_ptr a) { glue(tcg_gen_discard_,PTR)((NAT)a); --=20 2.17.1 From nobody Sat Apr 27 22:25:51 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1544384605588374.5800380833306; Sun, 9 Dec 2018 11:43:25 -0800 (PST) Received: from localhost ([::1]:56415 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gW4z6-0004uF-9v for importer@patchew.org; Sun, 09 Dec 2018 14:43:24 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33245) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gW4u1-0000Qs-0p for qemu-devel@nongnu.org; Sun, 09 Dec 2018 14:38:10 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gW4tw-0004zO-Ue for qemu-devel@nongnu.org; Sun, 09 Dec 2018 14:38:08 -0500 Received: from wout2-smtp.messagingengine.com ([64.147.123.25]:43571) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gW4tw-0004wi-MA for qemu-devel@nongnu.org; Sun, 09 Dec 2018 14:38:04 -0500 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id 62C05F3B; Sun, 9 Dec 2018 14:38:03 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Sun, 09 Dec 2018 14:38:03 -0500 Received: from localhost (flamenco.cs.columbia.edu [128.59.20.216]) by mail.messagingengine.com (Postfix) with ESMTPA id A9AE2102E4; Sun, 9 Dec 2018 14:38:02 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=braap.org; h= from:to:cc:subject:date:message-id:in-reply-to:references; s= mesmtp; bh=kHBCSMB+JxKer1zmrcUHgDnNC+U51vF2n01vbQXnCIs=; b=gzznQ JZeuaAWZZ6NN62xuxPBrDp94h6sATDRNpTxLlzaeYLIw4DqeiNUWAj08r1+rn7Kt Y+UWkZeMP4N2OKk/0janNobGWQ7D1WIvliZ8X+hvvjYpKAiiFuM1JRJRj8MKD4QU ivdSFxlzf8IGn+76D0FkWjS2U5LMt5jU4OMBqY= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:date:from:in-reply-to:message-id :references:subject:to:x-me-proxy:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; bh=kHBCSMB+JxKer1zmrcUHgDnNC+U51 vF2n01vbQXnCIs=; b=asKhRYq1+go6ku84BquOVXEfODlXUhQJ5gbn6pwQGb2z/ QRzrAywL1Zue0qwYEySkWJhcveFnh5MASKZ7VLLve3AwLWS2kMlS8WKdmjn7WWoL axo/NpN8sMauhpqDELiGIWk0gmsTtIvLSJV0SYlWpevExdCXlh5b1vG5qOLNlPBj eMbnG4vxCKCmx3Sx/dYW9GcD1AmFZULd7F1mvuCNqYttmKGwP1L2r8H/f23YegKS 4cUH5eOMXyZtxypofNDBzyE7rLSyqY210/QPPoT6DdDEFMXwgmFG0kzDmAG29VQa wPyw7JH0hAx3z4gOks6h8lY2uYTPQwj5t6vKNb8KQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedtkedrudegfedguddvkecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfhuthenuceurghilhhouhhtmecu fedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvufffkf fojghfsedttdertdertddtnecuhfhrohhmpedfgfhmihhlihhoucfirdcuvehothgrfdcu oegtohhtrgessghrrggrphdrohhrgheqnecuffhomhgrihhnpehhohhsthgruggurhdrmh honecukfhppeduvdekrdehledrvddtrddvudeinecurfgrrhgrmhepmhgrihhlfhhrohhm pegtohhtrgessghrrggrphdrohhrghenucevlhhushhtvghrufhiiigvpedt X-ME-Proxy: From: "Emilio G. Cota" To: qemu-devel@nongnu.org Date: Sun, 9 Dec 2018 14:37:23 -0500 Message-Id: <20181209193749.12277-13-cota@braap.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181209193749.12277-1-cota@braap.org> References: <20181209193749.12277-1-cota@braap.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 64.147.123.25 Subject: [Qemu-devel] [RFC v2 12/38] tcg: add MO_HADDR to TCGMemOp X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Richard Henderson , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Pavel Dovgalyuk Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" We will use this from plugins to mark mem accesses so that we can later obtain their host address. Signed-off-by: Emilio G. Cota --- tcg/tcg.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tcg/tcg.h b/tcg/tcg.h index 6fd525023b..a376f83ab6 100644 --- a/tcg/tcg.h +++ b/tcg/tcg.h @@ -359,6 +359,13 @@ typedef enum TCGMemOp { MO_ALIGN_32 =3D 5 << MO_ASHIFT, MO_ALIGN_64 =3D 6 << MO_ASHIFT, =20 + /* + * SoftMMU-only: if set, the TCG backend puts the corresponding host a= ddress + * in CPUArchState.hostaddr. + */ + MO_HSHIFT =3D MO_ASHIFT + 3, + MO_HADDR =3D 1 << MO_HSHIFT, + /* Combinations of the above, for ease of use. */ MO_UB =3D MO_8, MO_UW =3D MO_16, --=20 2.17.1 From nobody Sat Apr 27 22:25:51 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1544385176978590.1821722842847; Sun, 9 Dec 2018 11:52:56 -0800 (PST) Received: from localhost ([::1]:56463 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gW58J-0007WD-ND for importer@patchew.org; Sun, 09 Dec 2018 14:52:55 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33406) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gW4uF-0001SO-8f for qemu-devel@nongnu.org; Sun, 09 Dec 2018 14:38:24 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gW4uC-0005pp-L1 for qemu-devel@nongnu.org; Sun, 09 Dec 2018 14:38:23 -0500 Received: from wout2-smtp.messagingengine.com ([64.147.123.25]:58153) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gW4u8-0004xJ-Mf for qemu-devel@nongnu.org; Sun, 09 Dec 2018 14:38:18 -0500 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id 9637CF42; Sun, 9 Dec 2018 14:38:03 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Sun, 09 Dec 2018 14:38:03 -0500 Received: from localhost (flamenco.cs.columbia.edu [128.59.20.216]) by mail.messagingengine.com (Postfix) with ESMTPA id D9BEC102EA; Sun, 9 Dec 2018 14:38:02 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=braap.org; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; s=mesmtp; bh=T23cce7+EXTud7bt+JM4GcQJdz1o2eBcP1TX52ewLrE=; b=I/03zne5vM+x ELHfl2JrjAv2FisPLpfX3BN65681TGchx7CfyvrNaMkFyZOgzdO+oseH61O3e4K8 73r3k30NUmC1C9VtIWCt6VHOstBX0pxawbNsRl6HiNBXpFBRn9/yLS2ivde3BmFX iEl3DtaRiyK9RSoEjcQW4dD4v5+Jy5M= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; bh=T23cce7+EXTud7bt+JM4GcQJdz1o2eBcP1TX52ewL rE=; b=ZeYauphb0iBOpUmxM+gxRe2dnR5XqTR9I8pTqAUggaeIN4oJG33MrEqRI /5V5z/3vHvWLFjwpqGdiggzG7PrzlyIvUKJWoA2xxJvY6uwGioKkaLsvNuarKDWr grH2Zfyr1LFrasXpZmue1naUR+xD8VP5TC+utlGVmHpqB2205TwBS5xyvPXcnRRH m3n51LmmZIFfFKCIRC+uLe1Dbm7wKg62RV9DeTqNzjQsi/bLIRTxJ/BeEoWUeD2B L1ECHKo5aD5hLPtdYLhDKBcqY/YesBvy9HEw15TzdhEGtRzAa8E0923dRKYXojaV Jejr5jU1ixJCa7WfA7W0CCdidYhXg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedtkedrudegfedguddvkecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfhuthenuceurghilhhouhhtmecu fedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvufffkf fojghfgggtgfesthekredtredtjeenucfhrhhomhepfdfgmhhilhhiohcuifdrucevohht rgdfuceotghothgrsegsrhgrrghprdhorhhgqeenucfkphepuddvkedrheelrddvtddrvd duieenucfrrghrrghmpehmrghilhhfrhhomheptghothgrsegsrhgrrghprdhorhhgnecu vehluhhsthgvrhfuihiivgeptd X-ME-Proxy: From: "Emilio G. Cota" To: qemu-devel@nongnu.org Date: Sun, 9 Dec 2018 14:37:24 -0500 Message-Id: <20181209193749.12277-14-cota@braap.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181209193749.12277-1-cota@braap.org> References: <20181209193749.12277-1-cota@braap.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 64.147.123.25 Subject: [Qemu-devel] [RFC v2 13/38] atomic_template: fix indentation in GEN_ATOMIC_HELPER X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Richard Henderson , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Pavel Dovgalyuk Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Reviewed-by: Alex Benn=C3=A9e Signed-off-by: Emilio G. Cota --- accel/tcg/atomic_template.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/accel/tcg/atomic_template.h b/accel/tcg/atomic_template.h index efde12fdb2..8d177fefef 100644 --- a/accel/tcg/atomic_template.h +++ b/accel/tcg/atomic_template.h @@ -284,7 +284,7 @@ ABI_TYPE ATOMIC_NAME(xchg)(CPUArchState *env, target_ul= ong addr, =20 #define GEN_ATOMIC_HELPER(X) \ ABI_TYPE ATOMIC_NAME(X)(CPUArchState *env, target_ulong addr, \ - ABI_TYPE val EXTRA_ARGS) \ + ABI_TYPE val EXTRA_ARGS) \ { \ ATOMIC_MMU_DECLS; \ DATA_TYPE *haddr =3D ATOMIC_MMU_LOOKUP; \ --=20 2.17.1 From nobody Sat Apr 27 22:25:51 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1544385363923752.5973782630516; Sun, 9 Dec 2018 11:56:03 -0800 (PST) Received: from localhost ([::1]:56482 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gW5BK-0003Yl-MD for importer@patchew.org; Sun, 09 Dec 2018 14:56:02 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33409) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gW4uF-0001SV-9R for qemu-devel@nongnu.org; Sun, 09 Dec 2018 14:38:26 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gW4uD-0005rw-3k for qemu-devel@nongnu.org; Sun, 09 Dec 2018 14:38:23 -0500 Received: from wout2-smtp.messagingengine.com ([64.147.123.25]:38953) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gW4uC-0004yp-Lo for qemu-devel@nongnu.org; Sun, 09 Dec 2018 14:38:20 -0500 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id CE65BF45; Sun, 9 Dec 2018 14:38:03 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Sun, 09 Dec 2018 14:38:04 -0500 Received: from localhost (flamenco.cs.columbia.edu [128.59.20.216]) by mail.messagingengine.com (Postfix) with ESMTPA id 1E452102ED; Sun, 9 Dec 2018 14:38:03 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=braap.org; h= from:to:cc:subject:date:message-id:in-reply-to:references; s= mesmtp; bh=3Z8/ZrcbU1raTzyUPM2yAAr8zbTrDSy7j2rTtqIRoz8=; b=goxwa CStbDadkLtgcMYXvTehOUHsv+WuNqsUxR0roDSGzwkiOH0kqdsFKdVSqsJmcaSZ1 CXyF9Ufy9qOdVSUjMW1Sea9OV5L8Xzzglf8v3ysgp3aYfHFrF3yJzTa1jGhqlBfx XPOuqAra+KZpHfOkYFkEhWDBqQ8ey9LKa/0VQk= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:date:from:in-reply-to:message-id :references:subject:to:x-me-proxy:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; bh=3Z8/ZrcbU1raTzyUPM2yAAr8zbTrD Sy7j2rTtqIRoz8=; b=Glwh0EkEgH+M90owkWBRlLbAw4HH43cTibU1YzhkS7H5v UjSagCfWpQPJWoXQl5n2uhWVsOUti/tVex9bWgtZyF3ac8FuZ3pV/XHOOFx1iixX E3zA6hnEI94YQQeNY8+2xkaucTwOlM38pNUTHtH03G0oaih/t9FgrLpBsgNruct+ X8br/yQNrDuMmST/fJPWs2pW1nOUNOsqAwoMkno8Ze5K9p4OXY27yCIpjNJ7/CZR 5GHSMpVXVOopunP941EcKezaTozIDyutoVAGCznDodeYbGfhPZXqXuDLkmJkiORv vuCLybuhQRit4jtg3x8w4Rp2xurWACEKp6Q4MRsmw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedtkedrudegfedguddvkecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfhuthenuceurghilhhouhhtmecu fedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvufffkf fojghfsedttdertdertddtnecuhfhrohhmpedfgfhmihhlihhoucfirdcuvehothgrfdcu oegtohhtrgessghrrggrphdrohhrgheqnecukfhppeduvdekrdehledrvddtrddvudeine curfgrrhgrmhepmhgrihhlfhhrohhmpegtohhtrgessghrrggrphdrohhrghenucevlhhu shhtvghrufhiiigvpedt X-ME-Proxy: From: "Emilio G. Cota" To: qemu-devel@nongnu.org Date: Sun, 9 Dec 2018 14:37:25 -0500 Message-Id: <20181209193749.12277-15-cota@braap.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181209193749.12277-1-cota@braap.org> References: <20181209193749.12277-1-cota@braap.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 64.147.123.25 Subject: [Qemu-devel] [RFC v2 14/38] atomic_template: add inline trace/plugin helpers X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Richard Henderson , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Pavel Dovgalyuk Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" In preparation for plugin support. Signed-off-by: Emilio G. Cota --- accel/tcg/atomic_template.h | 110 ++++++++++++++++++++++++------------ 1 file changed, 75 insertions(+), 35 deletions(-) diff --git a/accel/tcg/atomic_template.h b/accel/tcg/atomic_template.h index 8d177fefef..2f7d5ee02a 100644 --- a/accel/tcg/atomic_template.h +++ b/accel/tcg/atomic_template.h @@ -59,25 +59,44 @@ # define ABI_TYPE uint32_t #endif =20 -#define ATOMIC_TRACE_RMW do { \ - uint8_t info =3D glue(trace_mem_build_info_no_se, MEND)(SHIFT, fal= se); \ - \ - trace_guest_mem_before_exec(ENV_GET_CPU(env), addr, info); \ - trace_guest_mem_before_exec(ENV_GET_CPU(env), addr, \ - info | TRACE_MEM_ST); \ - } while (0) - -#define ATOMIC_TRACE_LD do { \ - uint8_t info =3D glue(trace_mem_build_info_no_se, MEND)(SHIFT, fal= se); \ - \ - trace_guest_mem_before_exec(ENV_GET_CPU(env), addr, info); \ - } while (0) - -# define ATOMIC_TRACE_ST do { \ - uint8_t info =3D glue(trace_mem_build_info_no_se, MEND)(SHIFT, tru= e); \ - \ - trace_guest_mem_before_exec(ENV_GET_CPU(env), addr, info); \ - } while (0) +#ifndef ATOMIC_TEMPLATE_COMMON +#define ATOMIC_TEMPLATE_COMMON +static inline +void atomic_trace_rmw_pre(CPUArchState *env, target_ulong addr, uint8_t in= fo) +{ + CPUState *cpu =3D ENV_GET_CPU(env); + + trace_guest_mem_before_exec(cpu, addr, info); + trace_guest_mem_before_exec(cpu, addr, info | TRACE_MEM_ST); +} + +static inline void atomic_trace_rmw_post(CPUArchState *env, target_ulong a= ddr, + void *haddr, uint8_t info) +{ +} + +static inline +void atomic_trace_ld_pre(CPUArchState *env, target_ulong addr, uint8_t inf= o) +{ + trace_guest_mem_before_exec(ENV_GET_CPU(env), addr, info); +} + +static inline void atomic_trace_ld_post(CPUArchState *env, target_ulong ad= dr, + void *haddr, uint8_t info) +{ +} + +static inline +void atomic_trace_st_pre(CPUArchState *env, target_ulong addr, uint8_t inf= o) +{ + trace_guest_mem_before_exec(ENV_GET_CPU(env), addr, info); +} + +static inline void atomic_trace_st_post(CPUArchState *env, target_ulong ad= dr, + void *haddr, uint8_t info) +{ +} +#endif /* ATOMIC_TEMPLATE_COMMON */ =20 /* Define host-endian atomic operations. Note that END is used within the ATOMIC_NAME macro, and redefined below. */ @@ -98,14 +117,16 @@ ABI_TYPE ATOMIC_NAME(cmpxchg)(CPUArchState *env, targe= t_ulong addr, ATOMIC_MMU_DECLS; DATA_TYPE *haddr =3D ATOMIC_MMU_LOOKUP; DATA_TYPE ret; + uint8_t info =3D glue(trace_mem_build_info_no_se, MEND)(SHIFT, false); =20 - ATOMIC_TRACE_RMW; + atomic_trace_rmw_pre(env, addr, info); #if DATA_SIZE =3D=3D 16 ret =3D atomic16_cmpxchg(haddr, cmpv, newv); #else ret =3D atomic_cmpxchg__nocheck(haddr, cmpv, newv); #endif ATOMIC_MMU_CLEANUP; + atomic_trace_rmw_post(env, addr, haddr, info); return ret; } =20 @@ -115,10 +136,12 @@ ABI_TYPE ATOMIC_NAME(ld)(CPUArchState *env, target_ul= ong addr EXTRA_ARGS) { ATOMIC_MMU_DECLS; DATA_TYPE val, *haddr =3D ATOMIC_MMU_LOOKUP; + uint8_t info =3D glue(trace_mem_build_info_no_se, MEND)(SHIFT, false); =20 - ATOMIC_TRACE_LD; + atomic_trace_ld_pre(env, addr, info); val =3D atomic16_read(haddr); ATOMIC_MMU_CLEANUP; + atomic_trace_ld_post(env, addr, haddr, info); return val; } =20 @@ -127,10 +150,12 @@ void ATOMIC_NAME(st)(CPUArchState *env, target_ulong = addr, { ATOMIC_MMU_DECLS; DATA_TYPE *haddr =3D ATOMIC_MMU_LOOKUP; + uint8_t info =3D glue(trace_mem_build_info_no_se, MEND)(SHIFT, true); =20 - ATOMIC_TRACE_ST; + atomic_trace_st_pre(env, addr, info); atomic16_set(haddr, val); ATOMIC_MMU_CLEANUP; + atomic_trace_st_post(env, addr, haddr, info); } #endif #else @@ -140,10 +165,12 @@ ABI_TYPE ATOMIC_NAME(xchg)(CPUArchState *env, target_= ulong addr, ATOMIC_MMU_DECLS; DATA_TYPE *haddr =3D ATOMIC_MMU_LOOKUP; DATA_TYPE ret; + uint8_t info =3D glue(trace_mem_build_info_no_se, MEND)(SHIFT, false); =20 - ATOMIC_TRACE_RMW; + atomic_trace_rmw_pre(env, addr, info); ret =3D atomic_xchg__nocheck(haddr, val); ATOMIC_MMU_CLEANUP; + atomic_trace_rmw_post(env, addr, haddr, info); return ret; } =20 @@ -154,10 +181,12 @@ ABI_TYPE ATOMIC_NAME(X)(CPUArchState *env, target_ulo= ng addr, \ ATOMIC_MMU_DECLS; \ DATA_TYPE *haddr =3D ATOMIC_MMU_LOOKUP; \ DATA_TYPE ret; \ + uint8_t info =3D glue(trace_mem_build_info_no_se, MEND)(SHIFT, false);= \ \ - ATOMIC_TRACE_RMW; \ + atomic_trace_rmw_pre(env, addr, info); \ ret =3D atomic_##X(haddr, val); \ ATOMIC_MMU_CLEANUP; \ + atomic_trace_rmw_post(env, addr, haddr, info); \ return ret; \ } =20 @@ -186,8 +215,9 @@ ABI_TYPE ATOMIC_NAME(X)(CPUArchState *env, target_ulong= addr, \ ATOMIC_MMU_DECLS; \ XDATA_TYPE *haddr =3D ATOMIC_MMU_LOOKUP; \ XDATA_TYPE cmp, old, new, val =3D xval; \ + uint8_t info =3D glue(trace_mem_build_info_no_se, MEND)(SHIFT, false);= \ \ - ATOMIC_TRACE_RMW; \ + atomic_trace_rmw_pre(env, addr, info); \ smp_mb(); \ cmp =3D atomic_read__nocheck(haddr); \ do { \ @@ -195,6 +225,7 @@ ABI_TYPE ATOMIC_NAME(X)(CPUArchState *env, target_ulong= addr, \ cmp =3D atomic_cmpxchg__nocheck(haddr, old, new); \ } while (cmp !=3D old); \ ATOMIC_MMU_CLEANUP; \ + atomic_trace_rmw_post(env, addr, haddr, info); \ return RET; \ } =20 @@ -232,14 +263,16 @@ ABI_TYPE ATOMIC_NAME(cmpxchg)(CPUArchState *env, targ= et_ulong addr, ATOMIC_MMU_DECLS; DATA_TYPE *haddr =3D ATOMIC_MMU_LOOKUP; DATA_TYPE ret; + uint8_t info =3D glue(trace_mem_build_info_no_se, MEND)(SHIFT, false); =20 - ATOMIC_TRACE_RMW; + atomic_trace_rmw_pre(env, addr, info); #if DATA_SIZE =3D=3D 16 ret =3D atomic16_cmpxchg(haddr, BSWAP(cmpv), BSWAP(newv)); #else ret =3D atomic_cmpxchg__nocheck(haddr, BSWAP(cmpv), BSWAP(newv)); #endif ATOMIC_MMU_CLEANUP; + atomic_trace_rmw_post(env, addr, haddr, info); return BSWAP(ret); } =20 @@ -249,10 +282,12 @@ ABI_TYPE ATOMIC_NAME(ld)(CPUArchState *env, target_ul= ong addr EXTRA_ARGS) { ATOMIC_MMU_DECLS; DATA_TYPE val, *haddr =3D ATOMIC_MMU_LOOKUP; + uint8_t info =3D glue(trace_mem_build_info_no_se, MEND)(SHIFT, false); =20 - ATOMIC_TRACE_LD; + atomic_trace_ld_pre(env, addr, info); val =3D atomic16_read(haddr); ATOMIC_MMU_CLEANUP; + atomic_trace_ld_post(env, addr, haddr, info); return BSWAP(val); } =20 @@ -261,11 +296,14 @@ void ATOMIC_NAME(st)(CPUArchState *env, target_ulong = addr, { ATOMIC_MMU_DECLS; DATA_TYPE *haddr =3D ATOMIC_MMU_LOOKUP; + uint8_t info =3D glue(trace_mem_build_info_no_se, MEND)(SHIFT, true); =20 - ATOMIC_TRACE_ST; + val =3D BSWAP(val); + atomic_trace_st_pre(env, addr, info); val =3D BSWAP(val); atomic16_set(haddr, val); ATOMIC_MMU_CLEANUP; + atomic_trace_st_post(env, addr, haddr, info); } #endif #else @@ -275,10 +313,12 @@ ABI_TYPE ATOMIC_NAME(xchg)(CPUArchState *env, target_= ulong addr, ATOMIC_MMU_DECLS; DATA_TYPE *haddr =3D ATOMIC_MMU_LOOKUP; ABI_TYPE ret; + uint8_t info =3D glue(trace_mem_build_info_no_se, MEND)(SHIFT, false); =20 - ATOMIC_TRACE_RMW; + atomic_trace_rmw_pre(env, addr, info); ret =3D atomic_xchg__nocheck(haddr, BSWAP(val)); ATOMIC_MMU_CLEANUP; + atomic_trace_rmw_post(env, addr, haddr, info); return BSWAP(ret); } =20 @@ -289,10 +329,12 @@ ABI_TYPE ATOMIC_NAME(X)(CPUArchState *env, target_ulo= ng addr, \ ATOMIC_MMU_DECLS; \ DATA_TYPE *haddr =3D ATOMIC_MMU_LOOKUP; \ DATA_TYPE ret; \ + uint8_t info =3D glue(trace_mem_build_info_no_se, MEND)(SHIFT, false);= \ \ - ATOMIC_TRACE_RMW; \ + atomic_trace_rmw_pre(env, addr, info); \ ret =3D atomic_##X(haddr, BSWAP(val)); \ ATOMIC_MMU_CLEANUP; \ + atomic_trace_rmw_post(env, addr, haddr, info); \ return BSWAP(ret); \ } =20 @@ -319,8 +361,9 @@ ABI_TYPE ATOMIC_NAME(X)(CPUArchState *env, target_ulong= addr, \ ATOMIC_MMU_DECLS; \ XDATA_TYPE *haddr =3D ATOMIC_MMU_LOOKUP; \ XDATA_TYPE ldo, ldn, old, new, val =3D xval; \ + uint8_t info =3D glue(trace_mem_build_info_no_se, MEND)(SHIFT, false);= \ \ - ATOMIC_TRACE_RMW; \ + atomic_trace_rmw_pre(env, addr, info); \ smp_mb(); \ ldn =3D atomic_read__nocheck(haddr); \ do { \ @@ -328,6 +371,7 @@ ABI_TYPE ATOMIC_NAME(X)(CPUArchState *env, target_ulong= addr, \ ldn =3D atomic_cmpxchg__nocheck(haddr, ldo, BSWAP(new)); \ } while (ldo !=3D ldn); \ ATOMIC_MMU_CLEANUP; \ + atomic_trace_rmw_post(env, addr, haddr, info); \ return RET; \ } =20 @@ -355,10 +399,6 @@ GEN_ATOMIC_HELPER_FN(add_fetch, ADD, DATA_TYPE, new) #undef MEND #endif /* DATA_SIZE > 1 */ =20 -#undef ATOMIC_TRACE_ST -#undef ATOMIC_TRACE_LD -#undef ATOMIC_TRACE_RMW - #undef BSWAP #undef ABI_TYPE #undef DATA_TYPE --=20 2.17.1 From nobody Sat Apr 27 22:25:51 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1544385552276888.0523419281518; Sun, 9 Dec 2018 11:59:12 -0800 (PST) Received: from localhost ([::1]:56495 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gW5EF-0007uR-N5 for importer@patchew.org; Sun, 09 Dec 2018 14:59:03 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33500) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gW4uI-0001Tq-Ck for qemu-devel@nongnu.org; Sun, 09 Dec 2018 14:38:31 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gW4uD-0005tD-Bd for qemu-devel@nongnu.org; Sun, 09 Dec 2018 14:38:26 -0500 Received: from wout2-smtp.messagingengine.com ([64.147.123.25]:52277) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gW4uC-0004zS-TJ for qemu-devel@nongnu.org; Sun, 09 Dec 2018 14:38:21 -0500 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id 4B03AF57; Sun, 9 Dec 2018 14:38:04 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Sun, 09 Dec 2018 14:38:04 -0500 Received: from localhost (flamenco.cs.columbia.edu [128.59.20.216]) by mail.messagingengine.com (Postfix) with ESMTPA id 59CF4102F1; Sun, 9 Dec 2018 14:38:03 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=braap.org; h= from:to:cc:subject:date:message-id:in-reply-to:references; s= mesmtp; bh=j1NO7/wMrXozZSq6uUI6qv8sseCcVe2LAcm5UNK5keY=; b=pqmNt FlBOzyz49Ml9mPl8BRjazVepypd0b0wIGDC2BqoJv3+hoEpYyxswEq2cm9qSK6D8 O23R7puOv3bophWprIvyeDLMkGkt20xbODNWQZaS6Krq7luFdedVi79jEtF6X4Er q4S18S0EkMiVkUh+U1/J0SQHIxANaewmIks9yU= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:date:from:in-reply-to:message-id :references:subject:to:x-me-proxy:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; bh=j1NO7/wMrXozZSq6uUI6qv8sseCcV e2LAcm5UNK5keY=; b=htQMKhrjOLP2w/YTinLBGimHl+huBueS6ndHcZRPtGfZm SfRbECO5Tv86fAsdlifSf0Kgc2CgR1tR4JWw4xS/nQPKeJu/d4hKJUkSApKb4Y0T QrEtgepQ4U4QdMnYEF3F+zOXhnKqblTc/jRbXGC48QJ185Nm7JwQKKnN5ngzSfSi xS5YFCw5QtcfnuIaVVQow0ipnwBlnDV7BSSiwNY3rxLiUSYbgprgLuQLDXt55cUQ qM2Bz96ZnVtRWfZF/fffsDlTyFfzastyz9Ghih7CbA11fLXaTEr7gK43y0NHJf75 OEjFUFXK9LA8D6zUbc+VgcE50uiTRyv0FQ1C+DaIg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedtkedrudegfedguddvkecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfhuthenuceurghilhhouhhtmecu fedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvufffkf fojghfsedttdertdertddtnecuhfhrohhmpedfgfhmihhlihhoucfirdcuvehothgrfdcu oegtohhtrgessghrrggrphdrohhrgheqnecuffhomhgrihhnpehgnhhurdhorhhgnecukf hppeduvdekrdehledrvddtrddvudeinecurfgrrhgrmhepmhgrihhlfhhrohhmpegtohht rgessghrrggrphdrohhrghenucevlhhushhtvghrufhiiigvpedt X-ME-Proxy: From: "Emilio G. Cota" To: qemu-devel@nongnu.org Date: Sun, 9 Dec 2018 14:37:26 -0500 Message-Id: <20181209193749.12277-16-cota@braap.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181209193749.12277-1-cota@braap.org> References: <20181209193749.12277-1-cota@braap.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 64.147.123.25 Subject: [Qemu-devel] [RFC v2 15/38] tcg: let plugins instrument memory accesses X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Richard Henderson , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Pavel Dovgalyuk Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" XXX: store hostaddr from non-i386 TCG backends XXX: what hostaddr to return for I/O accesses? XXX: what hostaddr to return for cross-page accesses? Here the trickiest feature is passing the host address to memory callbacks that request it. Perhaps it would be more appropriate to pass a "physical" address to plugins, but since in QEMU host addr ~=3D guest physical, I'm going with that for simplicity. To keep the implementation simple we piggy-back on the TLB fast path, and thus can only provide the host address _after_ memory accesses have occurred. For the slow path, it's a bit tedious because there are many places to update, but it's fairly simple. However, note that cross-page accesses are tricky, since the access might be to non-contiguous host addresses. So I'm punting on that and just passing NULL. Signed-off-by: Emilio G. Cota --- accel/tcg/atomic_template.h | 5 +++ accel/tcg/softmmu_template.h | 43 +++++++++++++++++----- include/exec/cpu-defs.h | 9 +++++ include/exec/cpu_ldst.h | 9 +++++ include/exec/cpu_ldst_template.h | 43 ++++++++++++++-------- include/exec/cpu_ldst_useronly_template.h | 42 +++++++++++++++------- tcg/tcg.h | 1 + accel/tcg/cpu-exec.c | 2 ++ accel/tcg/cputlb.c | 9 +++++ tcg/i386/tcg-target.inc.c | 7 ++++ tcg/tcg-op.c | 44 ++++++++++++++++++----- 11 files changed, 169 insertions(+), 45 deletions(-) diff --git a/accel/tcg/atomic_template.h b/accel/tcg/atomic_template.h index 2f7d5ee02a..5619c4b4b9 100644 --- a/accel/tcg/atomic_template.h +++ b/accel/tcg/atomic_template.h @@ -18,6 +18,7 @@ * License along with this library; if not, see . */ =20 +#include "qemu/plugin.h" #include "trace/mem.h" =20 #if DATA_SIZE =3D=3D 16 @@ -73,6 +74,8 @@ void atomic_trace_rmw_pre(CPUArchState *env, target_ulong= addr, uint8_t info) static inline void atomic_trace_rmw_post(CPUArchState *env, target_ulong a= ddr, void *haddr, uint8_t info) { + qemu_plugin_vcpu_mem_cb(ENV_GET_CPU(env), addr, haddr, info); + qemu_plugin_vcpu_mem_cb(ENV_GET_CPU(env), addr, haddr, info | TRACE_ME= M_ST); } =20 static inline @@ -84,6 +87,7 @@ void atomic_trace_ld_pre(CPUArchState *env, target_ulong = addr, uint8_t info) static inline void atomic_trace_ld_post(CPUArchState *env, target_ulong ad= dr, void *haddr, uint8_t info) { + qemu_plugin_vcpu_mem_cb(ENV_GET_CPU(env), addr, haddr, info); } =20 static inline @@ -95,6 +99,7 @@ void atomic_trace_st_pre(CPUArchState *env, target_ulong = addr, uint8_t info) static inline void atomic_trace_st_post(CPUArchState *env, target_ulong ad= dr, void *haddr, uint8_t info) { + qemu_plugin_vcpu_mem_cb(ENV_GET_CPU(env), addr, haddr, info); } #endif /* ATOMIC_TEMPLATE_COMMON */ =20 diff --git a/accel/tcg/softmmu_template.h b/accel/tcg/softmmu_template.h index b0adea045e..79109e25a1 100644 --- a/accel/tcg/softmmu_template.h +++ b/accel/tcg/softmmu_template.h @@ -45,7 +45,6 @@ #error unsupported data size #endif =20 - /* For the benefit of TCG generated code, we want to avoid the complication of ABI-specific return type promotion and always return a value extended to the register size of the host. This is tcg_target_long, except in t= he @@ -99,10 +98,15 @@ static inline DATA_TYPE glue(io_read, SUFFIX)(CPUArchSt= ate *env, size_t mmu_idx, size_t index, target_ulong addr, uintptr_t retaddr, + TCGMemOp mo, bool recheck, MMUAccessType access_type) { CPUIOTLBEntry *iotlbentry =3D &env->iotlb[mmu_idx][index]; + + /* XXX Any sensible choice other than NULL? */ + set_hostaddr(env, mo, NULL); + return io_readx(env, iotlbentry, mmu_idx, addr, retaddr, recheck, access_type, DATA_SIZE); } @@ -115,7 +119,8 @@ WORD_TYPE helper_le_ld_name(CPUArchState *env, target_u= long addr, uintptr_t index =3D tlb_index(env, mmu_idx, addr); CPUTLBEntry *entry =3D tlb_entry(env, mmu_idx, addr); target_ulong tlb_addr =3D entry->ADDR_READ; - unsigned a_bits =3D get_alignment_bits(get_memop(oi)); + TCGMemOp mo =3D get_memop(oi); + unsigned a_bits =3D get_alignment_bits(mo); uintptr_t haddr; DATA_TYPE res; =20 @@ -141,7 +146,7 @@ WORD_TYPE helper_le_ld_name(CPUArchState *env, target_u= long addr, =20 /* ??? Note that the io helpers always read data in the target byte ordering. We should push the LE/BE request down into io. = */ - res =3D glue(io_read, SUFFIX)(env, mmu_idx, index, addr, retaddr, + res =3D glue(io_read, SUFFIX)(env, mmu_idx, index, addr, retaddr, = mo, tlb_addr & TLB_RECHECK, READ_ACCESS_TYPE); res =3D TGT_LE(res); @@ -162,12 +167,19 @@ WORD_TYPE helper_le_ld_name(CPUArchState *env, target= _ulong addr, res2 =3D helper_le_ld_name(env, addr2, oi, retaddr); shift =3D (addr & (DATA_SIZE - 1)) * 8; =20 + /* + * XXX cross-page accesses would have to be split into separate ac= cesses + * for the host address to make sense. For now, just return NULL. + */ + set_hostaddr(env, mo, NULL); + /* Little-endian combine. */ res =3D (res1 >> shift) | (res2 << ((DATA_SIZE * 8) - shift)); return res; } =20 haddr =3D addr + entry->addend; + set_hostaddr(env, mo, (void *)haddr); #if DATA_SIZE =3D=3D 1 res =3D glue(glue(ld, LSUFFIX), _p)((uint8_t *)haddr); #else @@ -184,7 +196,8 @@ WORD_TYPE helper_be_ld_name(CPUArchState *env, target_u= long addr, uintptr_t index =3D tlb_index(env, mmu_idx, addr); CPUTLBEntry *entry =3D tlb_entry(env, mmu_idx, addr); target_ulong tlb_addr =3D entry->ADDR_READ; - unsigned a_bits =3D get_alignment_bits(get_memop(oi)); + TCGMemOp mo =3D get_memop(oi); + unsigned a_bits =3D get_alignment_bits(mo); uintptr_t haddr; DATA_TYPE res; =20 @@ -210,7 +223,7 @@ WORD_TYPE helper_be_ld_name(CPUArchState *env, target_u= long addr, =20 /* ??? Note that the io helpers always read data in the target byte ordering. We should push the LE/BE request down into io. = */ - res =3D glue(io_read, SUFFIX)(env, mmu_idx, index, addr, retaddr, + res =3D glue(io_read, SUFFIX)(env, mmu_idx, index, addr, retaddr, = mo, tlb_addr & TLB_RECHECK, READ_ACCESS_TYPE); res =3D TGT_BE(res); @@ -231,12 +244,15 @@ WORD_TYPE helper_be_ld_name(CPUArchState *env, target= _ulong addr, res2 =3D helper_be_ld_name(env, addr2, oi, retaddr); shift =3D (addr & (DATA_SIZE - 1)) * 8; =20 + set_hostaddr(env, mo, NULL); + /* Big-endian combine. */ res =3D (res1 << shift) | (res2 >> ((DATA_SIZE * 8) - shift)); return res; } =20 haddr =3D addr + entry->addend; + set_hostaddr(env, mo, (void *)haddr); res =3D glue(glue(ld, LSUFFIX), _be_p)((uint8_t *)haddr); return res; } @@ -267,9 +283,12 @@ static inline void glue(io_write, SUFFIX)(CPUArchState= *env, DATA_TYPE val, target_ulong addr, uintptr_t retaddr, + TCGMemOp mo, bool recheck) { CPUIOTLBEntry *iotlbentry =3D &env->iotlb[mmu_idx][index]; + + set_hostaddr(env, mo, NULL); return io_writex(env, iotlbentry, mmu_idx, val, addr, retaddr, recheck, DATA_SIZE); } @@ -281,7 +300,8 @@ void helper_le_st_name(CPUArchState *env, target_ulong = addr, DATA_TYPE val, uintptr_t index =3D tlb_index(env, mmu_idx, addr); CPUTLBEntry *entry =3D tlb_entry(env, mmu_idx, addr); target_ulong tlb_addr =3D tlb_addr_write(entry); - unsigned a_bits =3D get_alignment_bits(get_memop(oi)); + TCGMemOp mo =3D get_memop(oi); + unsigned a_bits =3D get_alignment_bits(mo); uintptr_t haddr; =20 if (addr & ((1 << a_bits) - 1)) { @@ -308,7 +328,7 @@ void helper_le_st_name(CPUArchState *env, target_ulong = addr, DATA_TYPE val, byte ordering. We should push the LE/BE request down into io. = */ val =3D TGT_LE(val); glue(io_write, SUFFIX)(env, mmu_idx, index, val, addr, - retaddr, tlb_addr & TLB_RECHECK); + retaddr, mo, tlb_addr & TLB_RECHECK); return; } =20 @@ -340,10 +360,12 @@ void helper_le_st_name(CPUArchState *env, target_ulon= g addr, DATA_TYPE val, glue(helper_ret_stb, MMUSUFFIX)(env, addr + i, val8, oi, retaddr); } + set_hostaddr(env, mo, NULL); return; } =20 haddr =3D addr + entry->addend; + set_hostaddr(env, mo, (void *)haddr); #if DATA_SIZE =3D=3D 1 glue(glue(st, SUFFIX), _p)((uint8_t *)haddr, val); #else @@ -359,7 +381,8 @@ void helper_be_st_name(CPUArchState *env, target_ulong = addr, DATA_TYPE val, uintptr_t index =3D tlb_index(env, mmu_idx, addr); CPUTLBEntry *entry =3D tlb_entry(env, mmu_idx, addr); target_ulong tlb_addr =3D tlb_addr_write(entry); - unsigned a_bits =3D get_alignment_bits(get_memop(oi)); + TCGMemOp mo =3D get_memop(oi); + unsigned a_bits =3D get_alignment_bits(mo); uintptr_t haddr; =20 if (addr & ((1 << a_bits) - 1)) { @@ -385,7 +408,7 @@ void helper_be_st_name(CPUArchState *env, target_ulong = addr, DATA_TYPE val, /* ??? Note that the io helpers always read data in the target byte ordering. We should push the LE/BE request down into io. = */ val =3D TGT_BE(val); - glue(io_write, SUFFIX)(env, mmu_idx, index, val, addr, retaddr, + glue(io_write, SUFFIX)(env, mmu_idx, index, val, addr, retaddr, mo, tlb_addr & TLB_RECHECK); return; } @@ -418,10 +441,12 @@ void helper_be_st_name(CPUArchState *env, target_ulon= g addr, DATA_TYPE val, glue(helper_ret_stb, MMUSUFFIX)(env, addr + i, val8, oi, retaddr); } + set_hostaddr(env, mo, NULL); return; } =20 haddr =3D addr + entry->addend; + set_hostaddr(env, mo, (void *)haddr); glue(glue(st, SUFFIX), _be_p)((uint8_t *)haddr, val); } #endif /* DATA_SIZE > 1 */ diff --git a/include/exec/cpu-defs.h b/include/exec/cpu-defs.h index 40cd5d4774..f46bc0917d 100644 --- a/include/exec/cpu-defs.h +++ b/include/exec/cpu-defs.h @@ -178,6 +178,14 @@ typedef struct CPUTLBDesc { CPUIOTLBEntry iotlb[NB_MMU_MODES][CPU_TLB_SIZE]; #endif /* TCG_TARGET_IMPLEMENTS_DYN_TLB */ =20 +#ifdef CONFIG_PLUGIN +# define CPU_PLUGIN_HOSTADDR \ + /* stores the host address of a guest access */ \ + void *hostaddr; +#else +# define CPU_PLUGIN_HOSTADDR +#endif + #define CPU_COMMON_TLB \ /* The meaning of the MMU modes is defined in the target code. */ \ /* tlb_lock serializes updates to tlb_table and tlb_v_table */ \ @@ -186,6 +194,7 @@ typedef struct CPUTLBDesc { CPUTLBEntry tlb_v_table[NB_MMU_MODES][CPU_VTLB_SIZE]; \ CPU_IOTLB \ CPUIOTLBEntry iotlb_v[NB_MMU_MODES][CPU_VTLB_SIZE]; \ + CPU_PLUGIN_HOSTADDR \ size_t tlb_flush_count; \ target_ulong tlb_flush_addr; \ target_ulong tlb_flush_mask; \ diff --git a/include/exec/cpu_ldst.h b/include/exec/cpu_ldst.h index 83b2907d86..32dd8dd603 100644 --- a/include/exec/cpu_ldst.h +++ b/include/exec/cpu_ldst.h @@ -85,6 +85,15 @@ typedef target_ulong abi_ptr; #define TARGET_ABI_FMT_ptr TARGET_ABI_FMT_lx #endif =20 +static inline void *read_hostaddr(CPUArchState *env) +{ +#if defined(CONFIG_SOFTMMU) && defined(CONFIG_PLUGIN) + return env->hostaddr; +#else + return NULL; +#endif +} + #if defined(CONFIG_USER_ONLY) =20 extern __thread uintptr_t helper_retaddr; diff --git a/include/exec/cpu_ldst_template.h b/include/exec/cpu_ldst_templ= ate.h index 0f061d47ef..3493cb13bf 100644 --- a/include/exec/cpu_ldst_template.h +++ b/include/exec/cpu_ldst_template.h @@ -28,6 +28,7 @@ #include "trace-root.h" #endif =20 +#include "qemu/plugin.h" #include "trace/mem.h" =20 #if DATA_SIZE =3D=3D 8 @@ -86,11 +87,11 @@ glue(glue(glue(cpu_ld, USUFFIX), MEMSUFFIX), _ra)(CPUAr= chState *env, target_ulong addr; int mmu_idx; TCGMemOpIdx oi; - + uintptr_t hostaddr; #if !defined(SOFTMMU_CODE_ACCESS) - trace_guest_mem_before_exec( - ENV_GET_CPU(env), ptr, - trace_mem_build_info(SHIFT, false, MO_TE, false)); + uint8_t meminfo =3D trace_mem_build_info(SHIFT, false, MO_TE, false); + + trace_guest_mem_before_exec(ENV_GET_CPU(env), ptr, meminfo); #endif =20 addr =3D ptr; @@ -101,10 +102,14 @@ glue(glue(glue(cpu_ld, USUFFIX), MEMSUFFIX), _ra)(CPU= ArchState *env, oi =3D make_memop_idx(SHIFT, mmu_idx); res =3D glue(glue(helper_ret_ld, URETSUFFIX), MMUSUFFIX)(env, addr, oi, retaddr); + hostaddr =3D (uintptr_t)read_hostaddr(env); } else { - uintptr_t hostaddr =3D addr + entry->addend; + hostaddr =3D addr + entry->addend; res =3D glue(glue(ld, USUFFIX), _p)((uint8_t *)hostaddr); } +#ifndef SOFTMMU_CODE_ACCESS + qemu_plugin_vcpu_mem_cb(ENV_GET_CPU(env), ptr, (void *)hostaddr, memin= fo); +#endif return res; } =20 @@ -125,11 +130,11 @@ glue(glue(glue(cpu_lds, SUFFIX), MEMSUFFIX), _ra)(CPU= ArchState *env, target_ulong addr; int mmu_idx; TCGMemOpIdx oi; - + uintptr_t hostaddr; #if !defined(SOFTMMU_CODE_ACCESS) - trace_guest_mem_before_exec( - ENV_GET_CPU(env), ptr, - trace_mem_build_info(SHIFT, true, MO_TE, false)); + uint8_t meminfo =3D trace_mem_build_info(SHIFT, false, MO_TE, false); + + trace_guest_mem_before_exec(ENV_GET_CPU(env), ptr, meminfo); #endif =20 addr =3D ptr; @@ -140,10 +145,14 @@ glue(glue(glue(cpu_lds, SUFFIX), MEMSUFFIX), _ra)(CPU= ArchState *env, oi =3D make_memop_idx(SHIFT, mmu_idx); res =3D (DATA_STYPE)glue(glue(helper_ret_ld, SRETSUFFIX), MMUSUFFIX)(env, addr, oi, retaddr); + hostaddr =3D (uintptr_t)read_hostaddr(env); } else { - uintptr_t hostaddr =3D addr + entry->addend; + hostaddr =3D addr + entry->addend; res =3D glue(glue(lds, SUFFIX), _p)((uint8_t *)hostaddr); } +#ifndef SOFTMMU_CODE_ACCESS + qemu_plugin_vcpu_mem_cb(ENV_GET_CPU(env), ptr, (void *)hostaddr, memin= fo); +#endif return res; } =20 @@ -167,11 +176,11 @@ glue(glue(glue(cpu_st, SUFFIX), MEMSUFFIX), _ra)(CPUA= rchState *env, target_ulong addr; int mmu_idx; TCGMemOpIdx oi; - + uintptr_t hostaddr; #if !defined(SOFTMMU_CODE_ACCESS) - trace_guest_mem_before_exec( - ENV_GET_CPU(env), ptr, - trace_mem_build_info(SHIFT, false, MO_TE, true)); + uint8_t meminfo =3D trace_mem_build_info(SHIFT, false, MO_TE, true); + + trace_guest_mem_before_exec(ENV_GET_CPU(env), ptr, meminfo); #endif =20 addr =3D ptr; @@ -182,10 +191,14 @@ glue(glue(glue(cpu_st, SUFFIX), MEMSUFFIX), _ra)(CPUA= rchState *env, oi =3D make_memop_idx(SHIFT, mmu_idx); glue(glue(helper_ret_st, SUFFIX), MMUSUFFIX)(env, addr, v, oi, retaddr); + hostaddr =3D (uintptr_t)read_hostaddr(env); } else { - uintptr_t hostaddr =3D addr + entry->addend; + hostaddr =3D addr + entry->addend; glue(glue(st, SUFFIX), _p)((uint8_t *)hostaddr, v); } +#ifndef SOFTMMU_CODE_ACCESS + qemu_plugin_vcpu_mem_cb(ENV_GET_CPU(env), ptr, (void *)hostaddr, memin= fo); +#endif } =20 static inline void diff --git a/include/exec/cpu_ldst_useronly_template.h b/include/exec/cpu_l= dst_useronly_template.h index 0fd6019af0..e752e9c00e 100644 --- a/include/exec/cpu_ldst_useronly_template.h +++ b/include/exec/cpu_ldst_useronly_template.h @@ -64,12 +64,19 @@ static inline RES_TYPE glue(glue(cpu_ld, USUFFIX), MEMSUFFIX)(CPUArchState *env, abi_ptr ptr) { + RES_TYPE ret; +#if !defined(CODE_ACCESS) + uint8_t meminfo =3D trace_mem_build_info(SHIFT, false, MO_TE, false); + + trace_guest_mem_before_exec(ENV_GET_CPU(env), ptr, meminfo); +#endif + + ret =3D glue(glue(ld, USUFFIX), _p)(g2h(ptr)); + #if !defined(CODE_ACCESS) - trace_guest_mem_before_exec( - ENV_GET_CPU(env), ptr, - trace_mem_build_info(SHIFT, false, MO_TE, false)); + qemu_plugin_vcpu_mem_cb(ENV_GET_CPU(env), ptr, NULL, meminfo); #endif - return glue(glue(ld, USUFFIX), _p)(g2h(ptr)); + return ret; } =20 static inline RES_TYPE @@ -88,12 +95,19 @@ glue(glue(glue(cpu_ld, USUFFIX), MEMSUFFIX), _ra)(CPUAr= chState *env, static inline int glue(glue(cpu_lds, SUFFIX), MEMSUFFIX)(CPUArchState *env, abi_ptr ptr) { + int ret; #if !defined(CODE_ACCESS) - trace_guest_mem_before_exec( - ENV_GET_CPU(env), ptr, - trace_mem_build_info(SHIFT, true, MO_TE, false)); + uint8_t meminfo =3D trace_mem_build_info(SHIFT, true, MO_TE, false); + + trace_guest_mem_before_exec(ENV_GET_CPU(env), ptr, meminfo); #endif - return glue(glue(lds, SUFFIX), _p)(g2h(ptr)); + + ret =3D glue(glue(lds, SUFFIX), _p)(g2h(ptr)); + +#if !defined(CODE_ACCESS) + qemu_plugin_vcpu_mem_cb(ENV_GET_CPU(env), ptr, NULL, meminfo); +#endif + return ret; } =20 static inline int @@ -109,17 +123,21 @@ glue(glue(glue(cpu_lds, SUFFIX), MEMSUFFIX), _ra)(CPU= ArchState *env, } #endif =20 -#ifndef CODE_ACCESS +#if !defined(CODE_ACCESS) static inline void glue(glue(cpu_st, SUFFIX), MEMSUFFIX)(CPUArchState *env, abi_ptr ptr, RES_TYPE v) { #if !defined(CODE_ACCESS) - trace_guest_mem_before_exec( - ENV_GET_CPU(env), ptr, - trace_mem_build_info(SHIFT, false, MO_TE, true)); + uint8_t meminfo =3D trace_mem_build_info(SHIFT, false, MO_TE, true); + trace_guest_mem_before_exec(ENV_GET_CPU(env), ptr, meminfo); #endif + glue(glue(st, SUFFIX), _p)(g2h(ptr), v); + +#if !defined(CODE_ACCESS) + qemu_plugin_vcpu_mem_cb(ENV_GET_CPU(env), ptr, NULL, meminfo); +#endif } =20 static inline void diff --git a/tcg/tcg.h b/tcg/tcg.h index a376f83ab6..8938dcf52e 100644 --- a/tcg/tcg.h +++ b/tcg/tcg.h @@ -29,6 +29,7 @@ #include "cpu.h" #include "exec/tb-context.h" #include "qemu/bitops.h" +#include "qemu/plugin.h" #include "qemu/queue.h" #include "tcg-mo.h" #include "tcg-target.h" diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c index d590f1f6c0..4c8265a908 100644 --- a/accel/tcg/cpu-exec.c +++ b/accel/tcg/cpu-exec.c @@ -267,6 +267,7 @@ void cpu_exec_step_atomic(CPUState *cpu) tcg_debug_assert(!have_mmap_lock()); #endif assert_no_pages_locked(); + qemu_plugin_disable_mem_helpers(cpu); } =20 if (in_exclusive_region) { @@ -716,6 +717,7 @@ int cpu_exec(CPUState *cpu) if (qemu_mutex_iothread_locked()) { qemu_mutex_unlock_iothread(); } + qemu_plugin_disable_mem_helpers(cpu); } =20 /* if an exception is pending, we execute it here */ diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c index 5c61908084..3bdf98d2c3 100644 --- a/accel/tcg/cputlb.c +++ b/accel/tcg/cputlb.c @@ -1208,6 +1208,15 @@ static void *atomic_mmu_lookup(CPUArchState *env, ta= rget_ulong addr, cpu_loop_exit_atomic(ENV_GET_CPU(env), retaddr); } =20 +static inline void set_hostaddr(CPUArchState *env, TCGMemOp mo, void *hadd= r) +{ +#ifdef CONFIG_PLUGIN + if (mo & MO_HADDR) { + env->hostaddr =3D haddr; + } +#endif +} + #ifdef TARGET_WORDS_BIGENDIAN # define TGT_BE(X) (X) # define TGT_LE(X) BSWAP(X) diff --git a/tcg/i386/tcg-target.inc.c b/tcg/i386/tcg-target.inc.c index 5cbb07deab..eb3725f2e3 100644 --- a/tcg/i386/tcg-target.inc.c +++ b/tcg/i386/tcg-target.inc.c @@ -1685,6 +1685,13 @@ static inline void tcg_out_tlb_load(TCGContext *s, T= CGReg addrlo, TCGReg addrhi, /* add addend(r0), r1 */ tcg_out_modrm_offset(s, OPC_ADD_GvEv + hrexw, r1, r0, offsetof(CPUTLBEntry, addend)); + +#ifdef CONFIG_PLUGIN + if (opc & MO_HADDR) { + tcg_out_st(s, TCG_TYPE_PTR, r1, TCG_AREG0, + offsetof(CPUArchState, hostaddr)); + } +#endif } =20 /* diff --git a/tcg/tcg-op.c b/tcg/tcg-op.c index 7a8015c5a9..b30f0d4440 100644 --- a/tcg/tcg-op.c +++ b/tcg/tcg-op.c @@ -31,6 +31,7 @@ #include "tcg-mo.h" #include "trace-tcg.h" #include "trace/mem.h" +#include "exec/plugin-gen.h" =20 /* Reduce the number of ifdefs below. This assumes that all uses of TCGV_HIGH and TCGV_LOW are properly protected by a conditional that @@ -2595,6 +2596,7 @@ void tcg_gen_exit_tb(TranslationBlock *tb, unsigned i= dx) tcg_debug_assert(idx =3D=3D TB_EXIT_REQUESTED); } =20 + plugin_gen_disable_mem_helpers(); tcg_gen_op1i(INDEX_op_exit_tb, val); } =20 @@ -2607,6 +2609,7 @@ void tcg_gen_goto_tb(unsigned idx) tcg_debug_assert((tcg_ctx->goto_tb_issue_mask & (1 << idx)) =3D=3D 0); tcg_ctx->goto_tb_issue_mask |=3D 1 << idx; #endif + plugin_gen_disable_mem_helpers(); /* When not chaining, we simply fall through to the "fallback" exit. = */ if (!qemu_loglevel_mask(CPU_LOG_TB_NOCHAIN)) { tcg_gen_op1i(INDEX_op_goto_tb, idx); @@ -2616,7 +2619,10 @@ void tcg_gen_goto_tb(unsigned idx) void tcg_gen_lookup_and_goto_ptr(void) { if (TCG_TARGET_HAS_goto_ptr && !qemu_loglevel_mask(CPU_LOG_TB_NOCHAIN)= ) { - TCGv_ptr ptr =3D tcg_temp_new_ptr(); + TCGv_ptr ptr; + + plugin_gen_disable_mem_helpers(); + ptr =3D tcg_temp_new_ptr(); gen_helper_lookup_tb_ptr(ptr, cpu_env); tcg_gen_op1i(INDEX_op_goto_ptr, tcgv_ptr_arg(ptr)); tcg_temp_free_ptr(ptr); @@ -2699,26 +2705,42 @@ static void tcg_gen_req_mo(TCGBar type) } } =20 +static inline void plugin_gen_mem_callbacks(TCGv vaddr, uint8_t info) +{ +#ifdef CONFIG_PLUGIN + if (tcg_ctx->plugin_insn =3D=3D NULL) { + return; + } + plugin_gen_empty_mem_callback(vaddr, info); +#endif +} + void tcg_gen_qemu_ld_i32(TCGv_i32 val, TCGv addr, TCGArg idx, TCGMemOp mem= op) { + uint8_t info =3D trace_mem_get_info(memop, 0); + tcg_gen_req_mo(TCG_MO_LD_LD | TCG_MO_ST_LD); memop =3D tcg_canonicalize_memop(memop, 0, 0); - trace_guest_mem_before_tcg(tcg_ctx->cpu, cpu_env, - addr, trace_mem_get_info(memop, 0)); + trace_guest_mem_before_tcg(tcg_ctx->cpu, cpu_env, addr, info); gen_ldst_i32(INDEX_op_qemu_ld_i32, val, addr, memop, idx); + plugin_gen_mem_callbacks(addr, info); } =20 void tcg_gen_qemu_st_i32(TCGv_i32 val, TCGv addr, TCGArg idx, TCGMemOp mem= op) { + uint8_t info =3D trace_mem_get_info(memop, 1); + tcg_gen_req_mo(TCG_MO_LD_ST | TCG_MO_ST_ST); memop =3D tcg_canonicalize_memop(memop, 0, 1); - trace_guest_mem_before_tcg(tcg_ctx->cpu, cpu_env, - addr, trace_mem_get_info(memop, 1)); + trace_guest_mem_before_tcg(tcg_ctx->cpu, cpu_env, addr, info); gen_ldst_i32(INDEX_op_qemu_st_i32, val, addr, memop, idx); + plugin_gen_mem_callbacks(addr, info); } =20 void tcg_gen_qemu_ld_i64(TCGv_i64 val, TCGv addr, TCGArg idx, TCGMemOp mem= op) { + uint8_t info; + tcg_gen_req_mo(TCG_MO_LD_LD | TCG_MO_ST_LD); if (TCG_TARGET_REG_BITS =3D=3D 32 && (memop & MO_SIZE) < MO_64) { tcg_gen_qemu_ld_i32(TCGV_LOW(val), addr, idx, memop); @@ -2731,13 +2753,16 @@ void tcg_gen_qemu_ld_i64(TCGv_i64 val, TCGv addr, T= CGArg idx, TCGMemOp memop) } =20 memop =3D tcg_canonicalize_memop(memop, 1, 0); - trace_guest_mem_before_tcg(tcg_ctx->cpu, cpu_env, - addr, trace_mem_get_info(memop, 0)); + info =3D trace_mem_get_info(memop, 0); + trace_guest_mem_before_tcg(tcg_ctx->cpu, cpu_env, addr, info); gen_ldst_i64(INDEX_op_qemu_ld_i64, val, addr, memop, idx); + plugin_gen_mem_callbacks(addr, info); } =20 void tcg_gen_qemu_st_i64(TCGv_i64 val, TCGv addr, TCGArg idx, TCGMemOp mem= op) { + uint8_t info; + tcg_gen_req_mo(TCG_MO_LD_ST | TCG_MO_ST_ST); if (TCG_TARGET_REG_BITS =3D=3D 32 && (memop & MO_SIZE) < MO_64) { tcg_gen_qemu_st_i32(TCGV_LOW(val), addr, idx, memop); @@ -2745,9 +2770,10 @@ void tcg_gen_qemu_st_i64(TCGv_i64 val, TCGv addr, TC= GArg idx, TCGMemOp memop) } =20 memop =3D tcg_canonicalize_memop(memop, 1, 1); - trace_guest_mem_before_tcg(tcg_ctx->cpu, cpu_env, - addr, trace_mem_get_info(memop, 1)); + info =3D trace_mem_get_info(memop, 1); + trace_guest_mem_before_tcg(tcg_ctx->cpu, cpu_env, addr, info); gen_ldst_i64(INDEX_op_qemu_st_i64, val, addr, memop, idx); + plugin_gen_mem_callbacks(addr, info); } =20 static void tcg_gen_ext_i32(TCGv_i32 ret, TCGv_i32 val, TCGMemOp opc) --=20 2.17.1 From nobody Sat Apr 27 22:25:51 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1544385199031228.76450284985037; Sun, 9 Dec 2018 11:53:19 -0800 (PST) Received: from localhost ([::1]:56467 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gW58f-0007oo-Oi for importer@patchew.org; Sun, 09 Dec 2018 14:53:17 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33407) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gW4uF-0001SS-9A for qemu-devel@nongnu.org; Sun, 09 Dec 2018 14:38:24 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gW4uD-0005t5-BC for qemu-devel@nongnu.org; Sun, 09 Dec 2018 14:38:23 -0500 Received: from wout2-smtp.messagingengine.com ([64.147.123.25]:33515) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gW4uC-0004zU-TZ for qemu-devel@nongnu.org; Sun, 09 Dec 2018 14:38:21 -0500 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id 6273CF5B; Sun, 9 Dec 2018 14:38:04 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Sun, 09 Dec 2018 14:38:04 -0500 Received: from localhost (flamenco.cs.columbia.edu [128.59.20.216]) by mail.messagingengine.com (Postfix) with ESMTPA id 930D8102F2; Sun, 9 Dec 2018 14:38:03 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=braap.org; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; s=mesmtp; bh=IxB+NparCJlR1fefrnKMz9sA2cT9U+kwIe97h3XyXJM=; b=BhzKKJDUJoIE 7vsF3cMV8nviDOpUDRbjMuoSmdRaPWgxAoessZAKLqnERKSLqkigMx1aHcWMCKIb ETXXysgqBEpZrozlDgMBYEcqJU54ljigPgu+PnaevPguHBAeu4HCNofaJbwUV3Ia lfBBqDY6S4QnjWySbvYIscPHw+PJn2c= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; bh=IxB+NparCJlR1fefrnKMz9sA2cT9U+kwIe97h3XyX JM=; b=UPDkUCIB/In2glM+4HBOJTQA8OZCqxg0LXRTXezOXlf8MZ1PW5CJ6A9Me TciAYWu/YJCFcVyrmAFOjguk2sp0dYzr/cuaOMExI5WZT+110QHvy/lpuzBgbRMC wVhSFxGeDu4CkgJ0EGYCX6Gw1JKDVlICFLT8kUWSicNuS80WhfnvUTraA/MuzqBx UnPCsVpfvGXjc9CuTd+twO5ZUghwDOmgaA0l9WbooRT/C9PVQxgp0peRDAin8Bm+ O0sZW4WheS31H6rfVR+ULU4dUWpSfn6QjtVgSLGV3m/rXICf6W1weUZpbizEmy/b O/ivy564VTxrfqxAAD7+Vx66QEljw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedtkedrudegfedguddvkecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfhuthenuceurghilhhouhhtmecu fedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvufffkf fojghfgggtgfesthekredtredtjeenucfhrhhomhepfdfgmhhilhhiohcuifdrucevohht rgdfuceotghothgrsegsrhgrrghprdhorhhgqeenucfkphepuddvkedrheelrddvtddrvd duieenucfrrghrrghmpehmrghilhhfrhhomheptghothgrsegsrhgrrghprdhorhhgnecu vehluhhsthgvrhfuihiivgeptd X-ME-Proxy: From: "Emilio G. Cota" To: qemu-devel@nongnu.org Date: Sun, 9 Dec 2018 14:37:27 -0500 Message-Id: <20181209193749.12277-17-cota@braap.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181209193749.12277-1-cota@braap.org> References: <20181209193749.12277-1-cota@braap.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 64.147.123.25 Subject: [Qemu-devel] [RFC v2 16/38] translate-all: notify plugin code of tb_flush X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Richard Henderson , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Pavel Dovgalyuk Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Plugins might allocate per-TB data that then they get passed each time a TB is executed (via the *userdata pointer). Notify plugin code every time a code cache flush occurs, so that plugins can then reclaim the memory of the per-TB data. Reviewed-by: Alex Benn=C3=A9e Signed-off-by: Emilio G. Cota --- accel/tcg/translate-all.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index 62d5e13185..aaa8193ceb 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -1232,6 +1232,8 @@ static gboolean tb_host_size_iter(gpointer key, gpoin= ter value, gpointer data) /* flush all the translation blocks */ static void do_tb_flush(CPUState *cpu, run_on_cpu_data tb_flush_count) { + bool did_flush =3D false; + mmap_lock(); /* If it is already been done on request of another CPU, * just retry. @@ -1239,6 +1241,7 @@ static void do_tb_flush(CPUState *cpu, run_on_cpu_dat= a tb_flush_count) if (tb_ctx.tb_flush_count !=3D tb_flush_count.host_int) { goto done; } + did_flush =3D true; =20 if (DEBUG_TB_FLUSH_GATE) { size_t nb_tbs =3D tcg_nb_tbs(); @@ -1263,6 +1266,9 @@ static void do_tb_flush(CPUState *cpu, run_on_cpu_dat= a tb_flush_count) =20 done: mmap_unlock(); + if (did_flush) { + qemu_plugin_flush_cb(); + } } =20 void tb_flush(CPUState *cpu) --=20 2.17.1 From nobody Sat Apr 27 22:25:51 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1544385753955875.3038994105638; Sun, 9 Dec 2018 12:02:33 -0800 (PST) Received: from localhost ([::1]:56517 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gW5HU-00029k-BP for importer@patchew.org; Sun, 09 Dec 2018 15:02:24 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33424) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gW4uF-0001So-Hk for qemu-devel@nongnu.org; Sun, 09 Dec 2018 14:38:26 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gW4uD-0005ti-NP for qemu-devel@nongnu.org; Sun, 09 Dec 2018 14:38:23 -0500 Received: from wout2-smtp.messagingengine.com ([64.147.123.25]:39599) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gW4uD-0004za-C9 for qemu-devel@nongnu.org; Sun, 09 Dec 2018 14:38:21 -0500 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id 73334F5C; Sun, 9 Dec 2018 14:38:04 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Sun, 09 Dec 2018 14:38:04 -0500 Received: from localhost (flamenco.cs.columbia.edu [128.59.20.216]) by mail.messagingengine.com (Postfix) with ESMTPA id C2D7B102DD; Sun, 9 Dec 2018 14:38:03 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=braap.org; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; s=mesmtp; bh=oPcsNXCEvdLn1mpTXgZ7wPpoR2J0NUucRzTAG0ogh+k=; b=j84QF/90cwIk wAxXFqoV4VT/tZTCHoxkwWmZGQVCln520tQqbRVy6H/sOD/VO7alxSzpl/xkAjBa mV7Mvao9cstTUWaikigr++w3Vy0UWBccILqUrMPMxkMoa3C9oZiyfl9mvnaDM+dp 9MjtSR5bMWWZkifO5oPldkPtNiZ4vT8= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; bh=oPcsNXCEvdLn1mpTXgZ7wPpoR2J0NUucRzTAG0ogh +k=; b=iJdP7/VBFuqvEituMHz0NVAu0ZeROWV04G+DqkDob8yrcz7gAeq7d69Pu d2KBClVh+Y058JGzLN5ZqJFg2BcSfjj5DviXThcQ4op+qemThcyRBIsQAtw6MrdP c8qYDQPPbsIHiD5NDRwgsND4JHXWHT6hfn6CC5T43jnmja+cwuCTsPMrUCpwcgu/ WQQkLafoxiM5/BrD3m59xQiuCGRajlUAhI0Y7JTdlIfwJM4I/AsphtlN6THt4TXw DdVEECJl6T/INXBXWCq9uD7dP1xiRnJCzS3o9CkXAbvO0PKwRAzLJ7aEQk969Wfc NZ0tcSdn21Sphhg6a2E39QDFlO4lA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedtkedrudegfedguddvkecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfhuthenuceurghilhhouhhtmecu fedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvufffkf fojghfgggtgfesthekredtredtjeenucfhrhhomhepfdfgmhhilhhiohcuifdrucevohht rgdfuceotghothgrsegsrhgrrghprdhorhhgqeenucfkphepuddvkedrheelrddvtddrvd duieenucfrrghrrghmpehmrghilhhfrhhomheptghothgrsegsrhgrrghprdhorhhgnecu vehluhhsthgvrhfuihiivgeptd X-ME-Proxy: From: "Emilio G. Cota" To: qemu-devel@nongnu.org Date: Sun, 9 Dec 2018 14:37:28 -0500 Message-Id: <20181209193749.12277-18-cota@braap.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181209193749.12277-1-cota@braap.org> References: <20181209193749.12277-1-cota@braap.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 64.147.123.25 Subject: [Qemu-devel] [RFC v2 17/38] *-user: notify plugin of exit X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Richard Henderson , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Pavel Dovgalyuk Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Reviewed-by: Alex Benn=C3=A9e Signed-off-by: Emilio G. Cota --- bsd-user/syscall.c | 3 +++ linux-user/exit.c | 1 + 2 files changed, 4 insertions(+) diff --git a/bsd-user/syscall.c b/bsd-user/syscall.c index 66492aaf5d..b7818af450 100644 --- a/bsd-user/syscall.c +++ b/bsd-user/syscall.c @@ -332,6 +332,7 @@ abi_long do_freebsd_syscall(void *cpu_env, int num, abi= _long arg1, _mcleanup(); #endif gdb_exit(cpu_env, arg1); + qemu_plugin_atexit_cb(); /* XXX: should free thread stack and CPU env */ _exit(arg1); ret =3D 0; /* avoid warning */ @@ -430,6 +431,7 @@ abi_long do_netbsd_syscall(void *cpu_env, int num, abi_= long arg1, _mcleanup(); #endif gdb_exit(cpu_env, arg1); + qemu_plugin_atexit_cb(); /* XXX: should free thread stack and CPU env */ _exit(arg1); ret =3D 0; /* avoid warning */ @@ -505,6 +507,7 @@ abi_long do_openbsd_syscall(void *cpu_env, int num, abi= _long arg1, _mcleanup(); #endif gdb_exit(cpu_env, arg1); + qemu_plugin_atexit_cb(); /* XXX: should free thread stack and CPU env */ _exit(arg1); ret =3D 0; /* avoid warning */ diff --git a/linux-user/exit.c b/linux-user/exit.c index 14e94e28fa..768856483a 100644 --- a/linux-user/exit.c +++ b/linux-user/exit.c @@ -32,4 +32,5 @@ void preexit_cleanup(CPUArchState *env, int code) __gcov_dump(); #endif gdb_exit(env, code); + qemu_plugin_atexit_cb(); } --=20 2.17.1 From nobody Sat Apr 27 22:25:51 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1544385411024964.2266730526045; Sun, 9 Dec 2018 11:56:51 -0800 (PST) Received: from localhost ([::1]:56485 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gW5Bw-00044q-Dg for importer@patchew.org; Sun, 09 Dec 2018 14:56:40 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33413) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gW4uF-0001SX-9y for qemu-devel@nongnu.org; Sun, 09 Dec 2018 14:38:26 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gW4uD-0005sr-7b for qemu-devel@nongnu.org; Sun, 09 Dec 2018 14:38:23 -0500 Received: from wout2-smtp.messagingengine.com ([64.147.123.25]:33733) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gW4uC-00051I-Rx for qemu-devel@nongnu.org; Sun, 09 Dec 2018 14:38:21 -0500 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id B446BF4B; Sun, 9 Dec 2018 14:38:04 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Sun, 09 Dec 2018 14:38:05 -0500 Received: from localhost (flamenco.cs.columbia.edu [128.59.20.216]) by mail.messagingengine.com (Postfix) with ESMTPA id F0558102E4; Sun, 9 Dec 2018 14:38:03 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=braap.org; h= from:to:cc:subject:date:message-id:in-reply-to:references; s= mesmtp; bh=atCyk0MnkvDEKYMlARME8ppTXkJyrM2XbmFAS/wZs2g=; b=zq+Kf CzwZq4aBcqeUohO4WMTdh4oG9onf1LEN/yABS54+P2HdCvJTWeQ+enQvxeOQaGOn D/mv98OHlErqz5aEvBQSG0iVa1OZZCLUKjU0VBpMie7/lOe0w9Tf5NSrsxdExM2K 66hrnPwZsE3Tb+R5pz7H0xJ2tW8rDeEzxrHjrQ= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:date:from:in-reply-to:message-id :references:subject:to:x-me-proxy:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; bh=atCyk0MnkvDEKYMlARME8ppTXkJyr M2XbmFAS/wZs2g=; b=Qt5EsCUSuFI1oNKT3lN7uc+Wruacc+mJD9bKHxqD74cex Po1h3J5+qo/A61B4kasqHtvPJGxVE7x+rA2754fI2CV7alrkbtweDqlRqZacsqiy p/kap1mAyTIh6NtFOIl+KeORAnhX2a/NqHQljTA5AraLlF7YhIGOBttWY+kFN6sA vFG2n5pfshhxfXJCzNIN95caeUWDRopD153Gz54x6Nn7JZGNHPmxeJs3PzH9Mwk8 hARMYRXKtBKlHyTukvBzeRRKGcaMrIFrHyB2zY4tt6NwuD4r8aOmWxqJuZMZTZeE RYh4mTXGf1ImgId+GhtUE++8YqHJLWbCtZ724XhAw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedtkedrudegfedguddvkecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfhuthenuceurghilhhouhhtmecu fedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvufffkf fojghfsedttdertdertddtnecuhfhrohhmpedfgfhmihhlihhoucfirdcuvehothgrfdcu oegtohhtrgessghrrggrphdrohhrgheqnecukfhppeduvdekrdehledrvddtrddvudeine curfgrrhgrmhepmhgrihhlfhhrohhmpegtohhtrgessghrrggrphdrohhrghenucevlhhu shhtvghrufhiiigvpeej X-ME-Proxy: From: "Emilio G. Cota" To: qemu-devel@nongnu.org Date: Sun, 9 Dec 2018 14:37:29 -0500 Message-Id: <20181209193749.12277-19-cota@braap.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181209193749.12277-1-cota@braap.org> References: <20181209193749.12277-1-cota@braap.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 64.147.123.25 Subject: [Qemu-devel] [RFC v2 18/38] *-user: plugin syscalls X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Richard Henderson , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Pavel Dovgalyuk Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Emilio G. Cota --- bsd-user/syscall.c | 9 +++++++++ linux-user/syscall.c | 3 +++ 2 files changed, 12 insertions(+) diff --git a/bsd-user/syscall.c b/bsd-user/syscall.c index b7818af450..4993f81b2b 100644 --- a/bsd-user/syscall.c +++ b/bsd-user/syscall.c @@ -323,6 +323,8 @@ abi_long do_freebsd_syscall(void *cpu_env, int num, abi= _long arg1, gemu_log("freebsd syscall %d\n", num); #endif trace_guest_user_syscall(cpu, num, arg1, arg2, arg3, arg4, arg5, arg6,= arg7, arg8); + qemu_plugin_vcpu_syscall(cpu, num, arg1, arg2, arg3, arg4, arg5, arg6,= arg7, + arg8); if(do_strace) print_freebsd_syscall(num, arg1, arg2, arg3, arg4, arg5, arg6); =20 @@ -404,6 +406,7 @@ abi_long do_freebsd_syscall(void *cpu_env, int num, abi= _long arg1, if (do_strace) print_freebsd_syscall_ret(num, ret); trace_guest_user_syscall_ret(cpu, num, ret); + qemu_plugin_vcpu_syscall_ret(cpu, num, ret); return ret; efault: ret =3D -TARGET_EFAULT; @@ -422,6 +425,8 @@ abi_long do_netbsd_syscall(void *cpu_env, int num, abi_= long arg1, gemu_log("netbsd syscall %d\n", num); #endif trace_guest_user_syscall(cpu, num, arg1, arg2, arg3, arg4, arg5, arg6,= 0, 0); + qemu_plugin_vcpu_syscall(cpu, num, arg1, arg2, arg3, arg4, arg5, arg6,= 0, + 0); if(do_strace) print_netbsd_syscall(num, arg1, arg2, arg3, arg4, arg5, arg6); =20 @@ -480,6 +485,7 @@ abi_long do_netbsd_syscall(void *cpu_env, int num, abi_= long arg1, if (do_strace) print_netbsd_syscall_ret(num, ret); trace_guest_user_syscall_ret(cpu, num, ret); + qemu_plugin_vcpu_syscall_ret(cpu, num, ret); return ret; efault: ret =3D -TARGET_EFAULT; @@ -498,6 +504,8 @@ abi_long do_openbsd_syscall(void *cpu_env, int num, abi= _long arg1, gemu_log("openbsd syscall %d\n", num); #endif trace_guest_user_syscall(cpu, num, arg1, arg2, arg3, arg4, arg5, arg6,= 0, 0); + qemu_plugin_vcpu_syscall(cpu, num, arg1, arg2, arg3, arg4, arg5, arg6,= 0, + 0); if(do_strace) print_openbsd_syscall(num, arg1, arg2, arg3, arg4, arg5, arg6); =20 @@ -556,6 +564,7 @@ abi_long do_openbsd_syscall(void *cpu_env, int num, abi= _long arg1, if (do_strace) print_openbsd_syscall_ret(num, ret); trace_guest_user_syscall_ret(cpu, num, ret); + qemu_plugin_vcpu_syscall_ret(cpu, num, ret); return ret; efault: ret =3D -TARGET_EFAULT; diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 15b03e17b9..9f6457768c 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -11422,6 +11422,8 @@ abi_long do_syscall(void *cpu_env, int num, abi_lon= g arg1, =20 trace_guest_user_syscall(cpu, num, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8); + qemu_plugin_vcpu_syscall(cpu, num, arg1, arg2, arg3, arg4, arg5, arg6,= arg7, + arg8); =20 if (unlikely(do_strace)) { print_syscall(num, arg1, arg2, arg3, arg4, arg5, arg6); @@ -11434,5 +11436,6 @@ abi_long do_syscall(void *cpu_env, int num, abi_lon= g arg1, } =20 trace_guest_user_syscall_ret(cpu, num, ret); + qemu_plugin_vcpu_syscall_ret(cpu, num, ret); return ret; } --=20 2.17.1 From nobody Sat Apr 27 22:25:51 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1544385222179113.2424981719181; Sun, 9 Dec 2018 11:53:42 -0800 (PST) Received: from localhost ([::1]:56468 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gW592-0008D3-Vd for importer@patchew.org; Sun, 09 Dec 2018 14:53:41 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33414) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gW4uF-0001SZ-A1 for qemu-devel@nongnu.org; Sun, 09 Dec 2018 14:38:26 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gW4uD-0005sd-71 for qemu-devel@nongnu.org; Sun, 09 Dec 2018 14:38:23 -0500 Received: from wout2-smtp.messagingengine.com ([64.147.123.25]:43325) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gW4uC-00052M-QL for qemu-devel@nongnu.org; Sun, 09 Dec 2018 14:38:21 -0500 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id D3660F5E; Sun, 9 Dec 2018 14:38:04 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Sun, 09 Dec 2018 14:38:05 -0500 Received: from localhost (flamenco.cs.columbia.edu [128.59.20.216]) by mail.messagingengine.com (Postfix) with ESMTPA id 29EAF102F0; Sun, 9 Dec 2018 14:38:04 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=braap.org; h= from:to:cc:subject:date:message-id:in-reply-to:references; s= mesmtp; bh=GzNpR8NnC1RL+w/80hLaAA1YFOb9J0msL/P/8eC8pio=; b=GGKJi uZG3PIggc/CKRoj8sFrdDA3mmFvtrUUlFkbviHxS9104J2G9/IYB4b7+nxO0/xis 7l7KWQo2U/xnEN55bKcdTnPm0l4be7U33FhiSLF22ckryoSqTUjav3+X9bUr4oK8 hqQGnqYGTehnYi5sX9S5FEMbz3oMax+RTmeBqk= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:date:from:in-reply-to:message-id :references:subject:to:x-me-proxy:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; bh=GzNpR8NnC1RL+w/80hLaAA1YFOb9J 0msL/P/8eC8pio=; b=OXS8CiG5UitdmnRl3Mqmof8rXJiNRx+odUx71/EFaYIVk D3Q7vPvF+6aM06WrOjEl6gkVnq0pst4x4eIPQS+lffVxMvGkLUHI0JK1RdUwUgXo 0v5ddYO9irxcDkwSxDc9hBg90nUT098GduCCIzetAKnl2En7iVuI2IGFlEIu1PmN 21Hketi4OekXi3NHL9gaS/4a9BVpLhN3ecpprIjFpHNkXKaGMfWprEKypuFHvHgw 8aDQN+v0WBBbrvWHPFb2SNNYAckZxpklglAtIwAWWN5hAdiN6WALaxn+3mhAI9mw b/weYPE2+pwsHMkn7M+hupaVzEnTNdtEjGbHUEIng== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedtkedrudegfedguddvkecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfhuthenuceurghilhhouhhtmecu fedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvufffkf fojghfsedttdertdertddtnecuhfhrohhmpedfgfhmihhlihhoucfirdcuvehothgrfdcu oegtohhtrgessghrrggrphdrohhrgheqnecukfhppeduvdekrdehledrvddtrddvudeine curfgrrhgrmhepmhgrihhlfhhrohhmpegtohhtrgessghrrggrphdrohhrghenucevlhhu shhtvghrufhiiigvpeej X-ME-Proxy: From: "Emilio G. Cota" To: qemu-devel@nongnu.org Date: Sun, 9 Dec 2018 14:37:30 -0500 Message-Id: <20181209193749.12277-20-cota@braap.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181209193749.12277-1-cota@braap.org> References: <20181209193749.12277-1-cota@braap.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 64.147.123.25 Subject: [Qemu-devel] [RFC v2 19/38] cpu: hook plugin vcpu events X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Richard Henderson , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Pavel Dovgalyuk Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Emilio G. Cota --- cpus.c | 10 ++++++++++ exec.c | 2 ++ qom/cpu.c | 2 ++ 3 files changed, 14 insertions(+) diff --git a/cpus.c b/cpus.c index c9acef73e4..e3844c69c8 100644 --- a/cpus.c +++ b/cpus.c @@ -43,6 +43,7 @@ #include "exec/exec-all.h" =20 #include "qemu/thread.h" +#include "qemu/plugin.h" #include "sysemu/cpus.h" #include "sysemu/qtest.h" #include "qemu/main-loop.h" @@ -1322,12 +1323,21 @@ static void qemu_tcg_rr_wait_io_event(CPUState *cpu) =20 static void qemu_wait_io_event(CPUState *cpu) { + bool slept =3D false; + g_assert(cpu_mutex_locked(cpu)); g_assert(!qemu_mutex_iothread_locked()); =20 while (cpu_thread_is_idle(cpu)) { + if (!slept) { + slept =3D true; + qemu_plugin_vcpu_idle_cb(cpu); + } qemu_cond_wait(&cpu->halt_cond, &cpu->lock); } + if (slept) { + qemu_plugin_vcpu_resume_cb(cpu); + } =20 #ifdef _WIN32 /* Eat dummy APC queued by qemu_cpu_kick_thread. */ diff --git a/exec.c b/exec.c index 04d505500b..bdafb0e71a 100644 --- a/exec.c +++ b/exec.c @@ -967,6 +967,8 @@ void cpu_exec_realizefn(CPUState *cpu, Error **errp) } tlb_init(cpu); =20 + qemu_plugin_vcpu_init_hook(cpu); + #ifndef CONFIG_USER_ONLY if (qdev_get_vmsd(DEVICE(cpu)) =3D=3D NULL) { vmstate_register(NULL, cpu->cpu_index, &vmstate_cpu_common, cpu); diff --git a/qom/cpu.c b/qom/cpu.c index b33d182c4c..6233a98a84 100644 --- a/qom/cpu.c +++ b/qom/cpu.c @@ -32,6 +32,7 @@ #include "hw/boards.h" #include "hw/qdev-properties.h" #include "trace-root.h" +#include "qemu/plugin.h" =20 CPUInterruptHandler cpu_interrupt_handler; =20 @@ -352,6 +353,7 @@ static void cpu_common_unrealizefn(DeviceState *dev, Er= ror **errp) CPUState *cpu =3D CPU(dev); /* NOTE: latest generic point before the cpu is fully unrealized */ trace_fini_vcpu(cpu); + qemu_plugin_vcpu_exit_hook(cpu); cpu_exec_unrealizefn(cpu); } =20 --=20 2.17.1 From nobody Sat Apr 27 22:25:51 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1544384813885767.1683035407663; Sun, 9 Dec 2018 11:46:53 -0800 (PST) Received: from localhost ([::1]:56435 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gW52S-00015x-L3 for importer@patchew.org; Sun, 09 Dec 2018 14:46:52 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33417) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gW4uF-0001Sa-AK for qemu-devel@nongnu.org; Sun, 09 Dec 2018 14:38:26 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gW4uD-0005ri-2E for qemu-devel@nongnu.org; Sun, 09 Dec 2018 14:38:23 -0500 Received: from wout2-smtp.messagingengine.com ([64.147.123.25]:38161) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gW4uC-00054E-Mb for qemu-devel@nongnu.org; Sun, 09 Dec 2018 14:38:20 -0500 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id 23C7BF37; Sun, 9 Dec 2018 14:38:05 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Sun, 09 Dec 2018 14:38:05 -0500 Received: from localhost (flamenco.cs.columbia.edu [128.59.20.216]) by mail.messagingengine.com (Postfix) with ESMTPA id 58AC1102EA; Sun, 9 Dec 2018 14:38:04 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=braap.org; h= from:to:cc:subject:date:message-id:in-reply-to:references; s= mesmtp; bh=/eJPzjb+nQOTTcQHSWaggRr6KvpPM8C6BKO7revN/cM=; b=mcLt9 ZTwHlcD7VkiJYCUqHLKCsXEHD/Q00ho+Knpvxh0HDUgqR5XQIXKUXhCYNRlbo8Xe bs2kzh2VulHuBKAFxU0kwJhwDekgvwrrgHaS3o8RwbTHKF96JahmeDxv7SXQAc+7 i2dfhRMPj55EMQ/WFRoDW51YRufqalQiA6Wlqw= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:date:from:in-reply-to:message-id :references:subject:to:x-me-proxy:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; bh=/eJPzjb+nQOTTcQHSWaggRr6KvpPM 8C6BKO7revN/cM=; b=dNZBSIhDzqYeeo6X9oDAoTJenEaJhn/UD5JTxmaYqDD4c CehP0x8osJxKY2TiVBdflVykI8N+0YLPJZfsKO5RtstsEf5ujzFNN3PqOE5ahUuJ A1z/QAzK4XVj8l/8KCcxEe0GpYmRYJNgGOepHEkGC1zwV3kUqMjKwa3ZezIr0eUU YgjV2FAzpiMolh5G/N4V3x0N6Ck+4XbwuzErTKTxGX824Rp8OYSBmf21JmLr0say 4rwN0jXn9bAtQnqCgL+51i4WV5UGJIxTROR87GdV9UrMIR8Z4Vt+kpgJLBXY/FHP Lc1rJc7Y+nCC8TieT3uOsQ8g6IX67Dlyzzv2Q1oZQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedtkedrudegfedguddvkecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfhuthenuceurghilhhouhhtmecu fedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvufffkf fojghfsedttdertdertddtnecuhfhrohhmpedfgfhmihhlihhoucfirdcuvehothgrfdcu oegtohhtrgessghrrggrphdrohhrgheqnecukfhppeduvdekrdehledrvddtrddvudeine curfgrrhgrmhepmhgrihhlfhhrohhmpegtohhtrgessghrrggrphdrohhrghenucevlhhu shhtvghrufhiiigvpeej X-ME-Proxy: From: "Emilio G. Cota" To: qemu-devel@nongnu.org Date: Sun, 9 Dec 2018 14:37:31 -0500 Message-Id: <20181209193749.12277-21-cota@braap.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181209193749.12277-1-cota@braap.org> References: <20181209193749.12277-1-cota@braap.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 64.147.123.25 Subject: [Qemu-devel] [RFC v2 20/38] plugin-gen: add plugin_insn_append X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Richard Henderson , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Pavel Dovgalyuk Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" By adding it to plugin-gen's header file, we can export is as an inline, since tcg.h is included in the header (we need tcg_ctx). Signed-off-by: Emilio G. Cota --- include/exec/plugin-gen.h | 27 ++++++++++++++++++--------- accel/tcg/plugin-gen.c | 10 +++++++++- 2 files changed, 27 insertions(+), 10 deletions(-) diff --git a/include/exec/plugin-gen.h b/include/exec/plugin-gen.h index 449ea16034..b09c16b720 100644 --- a/include/exec/plugin-gen.h +++ b/include/exec/plugin-gen.h @@ -15,15 +15,6 @@ #include "qemu/plugin.h" #include "tcg/tcg.h" =20 -/* used by plugin_callback_start and plugin_callback_end TCG ops */ -enum plugin_gen_from { - PLUGIN_GEN_FROM_TB, - PLUGIN_GEN_FROM_INSN, - PLUGIN_GEN_FROM_MEM, - PLUGIN_GEN_AFTER_INSN, - PLUGIN_GEN_N_FROMS, -}; - struct DisasContextBase; =20 #ifdef CONFIG_PLUGIN @@ -36,6 +27,21 @@ void plugin_gen_insn_end(void); void plugin_gen_disable_mem_helpers(void); void plugin_gen_empty_mem_callback(TCGv addr, uint8_t info); =20 +static inline void plugin_insn_append(const void *from, size_t size) +{ + struct qemu_plugin_insn *insn =3D tcg_ctx->plugin_insn; + + if (insn =3D=3D NULL) { + return; + } + if (unlikely(insn->size + size > insn->capacity)) { + insn->data =3D g_realloc(insn->data, insn->size + size); + insn->capacity =3D insn->size + size; + } + memcpy(insn->data + insn->size, from, size); + insn->size +=3D size; +} + #else /* !CONFIG_PLUGIN */ =20 static inline @@ -60,6 +66,9 @@ static inline void plugin_gen_disable_mem_helpers(void) static inline void plugin_gen_empty_mem_callback(TCGv addr, uint8_t info) { } =20 +static inline void plugin_insn_append(const void *from, size_t size) +{ } + #endif /* CONFIG_PLUGIN */ =20 #endif /* QEMU_PLUGIN_GEN_H */ diff --git a/accel/tcg/plugin-gen.c b/accel/tcg/plugin-gen.c index 06ec23e9f5..e6dd79e4d8 100644 --- a/accel/tcg/plugin-gen.c +++ b/accel/tcg/plugin-gen.c @@ -60,9 +60,17 @@ /* * plugin_cb_start TCG op args[]: * 0: enum plugin_gen_from - * 1: enum plugin_gen_cb (defined below) + * 1: enum plugin_gen_cb * 2: set to 1 if it's a mem callback and it's a write, 0 otherwise. */ +enum plugin_gen_from { + PLUGIN_GEN_FROM_TB, + PLUGIN_GEN_FROM_INSN, + PLUGIN_GEN_FROM_MEM, + PLUGIN_GEN_AFTER_INSN, + PLUGIN_GEN_N_FROMS, +}; + enum plugin_gen_cb { PLUGIN_GEN_CB_UDATA, PLUGIN_GEN_CB_INLINE, --=20 2.17.1 From nobody Sat Apr 27 22:25:51 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1544385021225912.1893688153278; Sun, 9 Dec 2018 11:50:21 -0800 (PST) Received: from localhost ([::1]:56447 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gW55o-0005Rj-1p for importer@patchew.org; Sun, 09 Dec 2018 14:50:20 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33428) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gW4uF-0001Sy-MQ for qemu-devel@nongnu.org; Sun, 09 Dec 2018 14:38:26 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gW4uD-0005tT-IQ for qemu-devel@nongnu.org; Sun, 09 Dec 2018 14:38:23 -0500 Received: from wout2-smtp.messagingengine.com ([64.147.123.25]:40653) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gW4uD-00054C-5v for qemu-devel@nongnu.org; Sun, 09 Dec 2018 14:38:21 -0500 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id 29ABDF5F; Sun, 9 Dec 2018 14:38:05 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Sun, 09 Dec 2018 14:38:05 -0500 Received: from localhost (flamenco.cs.columbia.edu [128.59.20.216]) by mail.messagingengine.com (Postfix) with ESMTPA id 895EC102ED; Sun, 9 Dec 2018 14:38:04 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=braap.org; h= from:to:cc:subject:date:message-id:in-reply-to:references; s= mesmtp; bh=6qEwhA3u8u3hxlmvfff20rkcpX+J17DIxydRCi73n6U=; b=w2+H2 PnxuBMoCd+iotmzKjOpTxxXuLORKm/zbQwjDvm34IEkDvIwVfc4LMZohZSocK0sc DeUyp7it2KJk2tX95E0MxPEUHik7JJSk0FLPhH+kw+sfcQfM+D2N5YY4NCCWz7be 57EgfywTy2eVdvzK1l4AoaYfK/nXDPEFKe/NHs= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:date:from:in-reply-to:message-id :references:subject:to:x-me-proxy:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; bh=6qEwhA3u8u3hxlmvfff20rkcpX+J1 7DIxydRCi73n6U=; b=BL7ubtNvwNf5aD0Y6YzZ47cxDZGPxWi4hnSfHV8LI4ie7 HdBEsDpo39XiJvbLW4y3qzp9SNehd/WLTxks7MqQQAd4S1vk+etbvciYo7X1K2SP 5CnWTrQ+yxpPSpvC3sxSyEp3jfRf9zKM/f0ACOlnaNDqJMG3diTJ6DH+Ax7OFC/E GzIiFpzCteOwl4JHN06ozLaU6YfBVvBn/nrUb57Mz1ZB3VtQezXJ50JZinh6/SO0 kmJdMYT+etQhvAP6wOmWXflWu2O0jAz0et7hC6R9CW9ys0StolZWIj9fPHR3U5Wm alSJWRk+gW5p9dP1oBERxCqQgwjI7CLD1U75+W8Yw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedtkedrudegfedguddvkecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfhuthenuceurghilhhouhhtmecu fedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvufffkf fojghfsedttdertdertddtnecuhfhrohhmpedfgfhmihhlihhoucfirdcuvehothgrfdcu oegtohhtrgessghrrggrphdrohhrgheqnecukfhppeduvdekrdehledrvddtrddvudeine curfgrrhgrmhepmhgrihhlfhhrohhmpegtohhtrgessghrrggrphdrohhrghenucevlhhu shhtvghrufhiiigvpeej X-ME-Proxy: From: "Emilio G. Cota" To: qemu-devel@nongnu.org Date: Sun, 9 Dec 2018 14:37:32 -0500 Message-Id: <20181209193749.12277-22-cota@braap.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181209193749.12277-1-cota@braap.org> References: <20181209193749.12277-1-cota@braap.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 64.147.123.25 Subject: [Qemu-devel] [RFC v2 21/38] translator: add translator_ld{ub, sw, uw, l, q} X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Richard Henderson , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Pavel Dovgalyuk Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Suggested-by: Richard Henderson Signed-off-by: Emilio G. Cota --- include/exec/translator.h | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/include/exec/translator.h b/include/exec/translator.h index 71e7b2c347..39f6f514a7 100644 --- a/include/exec/translator.h +++ b/include/exec/translator.h @@ -19,7 +19,10 @@ */ =20 =20 +#include "qemu/bswap.h" #include "exec/exec-all.h" +#include "exec/cpu_ldst.h" +#include "exec/plugin-gen.h" #include "tcg/tcg.h" =20 =20 @@ -141,4 +144,29 @@ void translator_loop(const TranslatorOps *ops, DisasCo= ntextBase *db, =20 void translator_loop_temp_check(DisasContextBase *db); =20 +#define GEN_TRANSLATOR_LD(fullname, name, type, swap_fn) \ + static inline type \ + fullname ## _swap(CPUArchState *env, abi_ptr pc, bool do_swap) \ + { \ + type ret =3D cpu_ ## name ## _code(env, pc); \ + \ + if (do_swap) { \ + ret =3D swap_fn(ret); \ + } \ + plugin_insn_append(&ret, sizeof(ret)); \ + return ret; \ + } \ + \ + static inline type fullname(CPUArchState *env, abi_ptr pc) \ + { \ + return fullname ## _swap(env, pc, false); \ + } + +GEN_TRANSLATOR_LD(translator_ldub, ldub, uint8_t, /* no swap needed */) +GEN_TRANSLATOR_LD(translator_ldsw, ldsw, int16_t, bswap16) +GEN_TRANSLATOR_LD(translator_lduw, lduw, uint16_t, bswap16) +GEN_TRANSLATOR_LD(translator_ldl, ldl, uint32_t, bswap32) +GEN_TRANSLATOR_LD(translator_ldq, ldq, uint64_t, bswap64) +#undef GEN_TRANSLATOR_LD + #endif /* EXEC__TRANSLATOR_H */ --=20 2.17.1 From nobody Sat Apr 27 22:25:51 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1544385556953527.2734893333195; Sun, 9 Dec 2018 11:59:16 -0800 (PST) Received: from localhost ([::1]:56496 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gW5ER-00087f-JS for importer@patchew.org; Sun, 09 Dec 2018 14:59:15 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33426) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gW4uF-0001Sw-L6 for qemu-devel@nongnu.org; Sun, 09 Dec 2018 14:38:26 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gW4uE-0005ty-0K for qemu-devel@nongnu.org; Sun, 09 Dec 2018 14:38:23 -0500 Received: from wout2-smtp.messagingengine.com ([64.147.123.25]:54877) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gW4uD-00054P-Mw for qemu-devel@nongnu.org; Sun, 09 Dec 2018 14:38:21 -0500 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id 813B9C62; Sun, 9 Dec 2018 14:38:05 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Sun, 09 Dec 2018 14:38:05 -0500 Received: from localhost (flamenco.cs.columbia.edu [128.59.20.216]) by mail.messagingengine.com (Postfix) with ESMTPA id B93C5102EE; Sun, 9 Dec 2018 14:38:04 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=braap.org; h= from:to:cc:subject:date:message-id:in-reply-to:references; s= mesmtp; bh=/K6vmngCCUryOJus1SuwefP4SZ8PC8cW+6kzmBO9dco=; b=vOSYU LImMhzCA+o3jiwW6Z5tkpB155+1Ccj0oKviFFd7v9iAmayKJIzwQP5UXgahcYsPE E9QqxeKKczAyAhrlLCCw+TfJur3X+elBu6Ve/LZPjU63XoaDlgAQZ2xQbTnGfQG/ HGW4v2HJgbWNuUmERmkFcx/ww/OeHnbj+hAwgs= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:date:from:in-reply-to:message-id :references:subject:to:x-me-proxy:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; bh=/K6vmngCCUryOJus1SuwefP4SZ8PC 8cW+6kzmBO9dco=; b=N3wkvKZEPf7VFg0R95IiJySyMEMXosgKdVrfXG5HIcHZo Wm6oqbbk1+M1XhIWYslOOnuWabl5TpFwH7C5VMdpONhLKqwI9GGbWci77ChUkcio vGa8hpX+8B/pdWZo0tgfS3h/Pa3eoLBrDFd+BFAz9xT0aOzav6KW3Dbf+yc3wV5s rnjzUNavN7CjjKZutqxRFMolmG8pYl1eIXmAwi1MYpv1vlrwqab1b8gmP8HYdO4w +aIdaX++wDDSi8TYV6P+wzObC2s1J4dpo3euR+sIs+YekscpeKreF3HUGmHmiUAV /tu/CmQNYE6Zqw4OcehLbXTYcZndFKhbtrwkNDHCw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedtkedrudegfedguddvkecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfhuthenuceurghilhhouhhtmecu fedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvufffkf fojghfsedttdertdertddtnecuhfhrohhmpedfgfhmihhlihhoucfirdcuvehothgrfdcu oegtohhtrgessghrrggrphdrohhrgheqnecukfhppeduvdekrdehledrvddtrddvudeine curfgrrhgrmhepmhgrihhlfhhrohhmpegtohhtrgessghrrggrphdrohhrghenucevlhhu shhtvghrufhiiigvpeej X-ME-Proxy: From: "Emilio G. Cota" To: qemu-devel@nongnu.org Date: Sun, 9 Dec 2018 14:37:33 -0500 Message-Id: <20181209193749.12277-23-cota@braap.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181209193749.12277-1-cota@braap.org> References: <20181209193749.12277-1-cota@braap.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 64.147.123.25 Subject: [Qemu-devel] [RFC v2 22/38] target/arm: call qemu_plugin_insn_append X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Richard Henderson , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Pavel Dovgalyuk Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" I considered using translator_ld* from arm_ldl_code et al. However, note that there's a helper that also calls arm_ldl_code, so we'd have to change that caller. In thumb's case I'm also calling plugin_insn_append directly, since we can't assume that all instructions are 16 bits long. Signed-off-by: Emilio G. Cota --- target/arm/translate-a64.c | 2 ++ target/arm/translate.c | 8 +++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c index 88195ab949..db95161c16 100644 --- a/target/arm/translate-a64.c +++ b/target/arm/translate-a64.c @@ -38,6 +38,7 @@ #include "trace-tcg.h" #include "translate-a64.h" #include "qemu/atomic128.h" +#include "qemu/plugin.h" =20 static TCGv_i64 cpu_X[32]; static TCGv_i64 cpu_pc; @@ -13321,6 +13322,7 @@ static void disas_a64_insn(CPUARMState *env, DisasC= ontext *s) uint32_t insn; =20 insn =3D arm_ldl_code(env, s->pc, s->sctlr_b); + plugin_insn_append(&insn, sizeof(insn)); s->insn =3D insn; s->pc +=3D 4; =20 diff --git a/target/arm/translate.c b/target/arm/translate.c index 7c4675ffd8..d5171f54f6 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -13234,6 +13234,7 @@ static void arm_tr_translate_insn(DisasContextBase = *dcbase, CPUState *cpu) } =20 insn =3D arm_ldl_code(env, dc->pc, dc->sctlr_b); + plugin_insn_append(&insn, sizeof(insn)); dc->insn =3D insn; dc->pc +=3D 4; disas_arm_insn(dc, insn); @@ -13304,11 +13305,16 @@ static void thumb_tr_translate_insn(DisasContextB= ase *dcbase, CPUState *cpu) insn =3D arm_lduw_code(env, dc->pc, dc->sctlr_b); is_16bit =3D thumb_insn_is_16bit(dc, insn); dc->pc +=3D 2; - if (!is_16bit) { + if (is_16bit) { + uint16_t insn16 =3D insn; + + plugin_insn_append(&insn16, sizeof(insn16)); + } else { uint32_t insn2 =3D arm_lduw_code(env, dc->pc, dc->sctlr_b); =20 insn =3D insn << 16 | insn2; dc->pc +=3D 2; + plugin_insn_append(&insn, sizeof(insn)); } dc->insn =3D insn; =20 --=20 2.17.1 From nobody Sat Apr 27 22:25:51 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1544384877766999.7502927302966; Sun, 9 Dec 2018 11:47:57 -0800 (PST) Received: from localhost ([::1]:56438 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gW53U-0001no-Gs for importer@patchew.org; Sun, 09 Dec 2018 14:47:56 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33412) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gW4uF-0001SY-9u for qemu-devel@nongnu.org; Sun, 09 Dec 2018 14:38:24 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gW4uD-0005tZ-LL for qemu-devel@nongnu.org; Sun, 09 Dec 2018 14:38:23 -0500 Received: from wout2-smtp.messagingengine.com ([64.147.123.25]:33191) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gW4uD-00054R-Bp for qemu-devel@nongnu.org; Sun, 09 Dec 2018 14:38:21 -0500 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id 9707FF63; Sun, 9 Dec 2018 14:38:05 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Sun, 09 Dec 2018 14:38:05 -0500 Received: from localhost (flamenco.cs.columbia.edu [128.59.20.216]) by mail.messagingengine.com (Postfix) with ESMTPA id E556A102F1; Sun, 9 Dec 2018 14:38:04 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=braap.org; h= from:to:cc:subject:date:message-id:in-reply-to:references; s= mesmtp; bh=yahtcfft+d9bzkEJ6GsWr5vJfvhT41hFJbSrLRULUrU=; b=FIwD9 /CZLX7/xbq67a0N0hTJg9VC3lvp1iPZsijT+z9eJdkSxSTfAqXhnPe2gSUHpqmtc kbUDtJ9uTEgc9gM41ov+f7QA7QSUkuLKbfZpX1h9ugfn7fcx5Zj2IPnsujOnIvmO e0KtG1p0401SiJgTSvL2g/RDWfQ62T5QeyBnAM= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:date:from:in-reply-to:message-id :references:subject:to:x-me-proxy:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; bh=yahtcfft+d9bzkEJ6GsWr5vJfvhT4 1hFJbSrLRULUrU=; b=obMv0dnN33Q6InpFCttJ+8EfMbl1PvzsQNaAeA57exBBS 7ONO4FdkdMBjGNG9j+R206vtrHARz/NpVvRLfID80aMTq9UhWEWc8tNMP6DO0rbK RRIgHLm3dw78Goz+kRinY0kJXjLkaawr5p8TAVo4LMkfgkEKOtnLVqoFZO6PE4DL Ey5NkAiLrnghgW8XZsmGZRapGIx7RhOhKkkE7IwoQr6SSEoVS35tbTHdPIk0JGjL Q1ZvcaLBRoG+i4IINq8hO2tI/N6e8VgFINYlA6CQ61TxuRrqkdzyKZDgX073wasL pd1lD3ibikfTLGqCIczdpJSaANHahRdctX135lcHg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedtkedrudegfedguddvkecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfhuthenuceurghilhhouhhtmecu fedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvufffkf fojghfsedttdertdertddtnecuhfhrohhmpedfgfhmihhlihhoucfirdcuvehothgrfdcu oegtohhtrgessghrrggrphdrohhrgheqnecukfhppeduvdekrdehledrvddtrddvudeine curfgrrhgrmhepmhgrihhlfhhrohhmpegtohhtrgessghrrggrphdrohhrghenucevlhhu shhtvghrufhiiigvpeej X-ME-Proxy: From: "Emilio G. Cota" To: qemu-devel@nongnu.org Date: Sun, 9 Dec 2018 14:37:34 -0500 Message-Id: <20181209193749.12277-24-cota@braap.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181209193749.12277-1-cota@braap.org> References: <20181209193749.12277-1-cota@braap.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 64.147.123.25 Subject: [Qemu-devel] [RFC v2 23/38] target/ppc: fetch code with translator_ld X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Richard Henderson , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Pavel Dovgalyuk Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Emilio G. Cota --- target/ppc/translate.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/target/ppc/translate.c b/target/ppc/translate.c index 2d31b5f7a1..7a7c8a9a88 100644 --- a/target/ppc/translate.c +++ b/target/ppc/translate.c @@ -7555,11 +7555,9 @@ static void ppc_tr_translate_insn(DisasContextBase *= dcbase, CPUState *cs) LOG_DISAS("nip=3D" TARGET_FMT_lx " super=3D%d ir=3D%d\n", ctx->base.pc_next, ctx->mem_idx, (int)msr_ir); =20 - if (unlikely(need_byteswap(ctx))) { - ctx->opcode =3D bswap32(cpu_ldl_code(env, ctx->base.pc_next)); - } else { - ctx->opcode =3D cpu_ldl_code(env, ctx->base.pc_next); - } + ctx->opcode =3D translator_ldl_swap(env, ctx->base.pc_next, + need_byteswap(ctx)); + LOG_DISAS("translate opcode %08x (%02x %02x %02x %02x) (%s)\n", ctx->opcode, opc1(ctx->opcode), opc2(ctx->opcode), opc3(ctx->opcode), opc4(ctx->opcode), --=20 2.17.1 From nobody Sat Apr 27 22:25:51 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1544385383283822.0876132211869; Sun, 9 Dec 2018 11:56:23 -0800 (PST) Received: from localhost ([::1]:56484 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gW5Be-0003pj-3l for importer@patchew.org; Sun, 09 Dec 2018 14:56:22 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33421) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gW4uF-0001Sc-Aj for qemu-devel@nongnu.org; Sun, 09 Dec 2018 14:38:26 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gW4uD-0005tP-Ji for qemu-devel@nongnu.org; Sun, 09 Dec 2018 14:38:23 -0500 Received: from wout2-smtp.messagingengine.com ([64.147.123.25]:41347) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gW4uD-00054a-7l for qemu-devel@nongnu.org; Sun, 09 Dec 2018 14:38:21 -0500 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id C2C67F68; Sun, 9 Dec 2018 14:38:05 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Sun, 09 Dec 2018 14:38:06 -0500 Received: from localhost (flamenco.cs.columbia.edu [128.59.20.216]) by mail.messagingengine.com (Postfix) with ESMTPA id 2006F102DD; Sun, 9 Dec 2018 14:38:05 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=braap.org; h= from:to:cc:subject:date:message-id:in-reply-to:references; s= mesmtp; bh=ONNcbhm/f3gphTGDNDc8aPqJ8EaNqbCobft8mTXlo1c=; b=T4DVm ZtTSuAgP9thuzNkiDcxjZBvoYEbSn8eS9y5eHNQ4loWzdzYyK0Y60KzqttD7rLd0 X3uVjErco9YOkgANQRIHTIYBoQPlAuutNX782B536FQxouBg8tPjUMfvHknb70jC gDqj4H7H2PAot/CEEnQTYazjg9nk96i+4HqeF4= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:date:from:in-reply-to:message-id :references:subject:to:x-me-proxy:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; bh=ONNcbhm/f3gphTGDNDc8aPqJ8EaNq bCobft8mTXlo1c=; b=LhpzKnq4aNaRWIONm27yxJqzJX0HFrKNu4Ocn0G/BQKv6 FIDgQxVkSuDIU2E6elMVcP7Lns6myauVBq/4zElFxkoPi6aYqQko5mfhTGFZC5Aj ZALmaqX7uK1om2YHrbQ8FJ1yL+gNSQYl80jKQ6UFymNUffM5JjNxwDRw+RcbdlBj StVocD7YuP/UFmEIOibo/sdZUY7+Q1sE3RxP1wiiePEPmojFI/DFkYR4xHKhGE8q Mr6CYQq34+HpCdxVfi/2xDMgmH7bz8RTN2Be0u1LU85ZbVmTGcDORuxPlwXCGw7U u5ft413Jn+vu62XCHaR4L7nL0yqvSqbxcpAnzpHwg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedtkedrudegfedguddvkecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfhuthenuceurghilhhouhhtmecu fedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvufffkf fojghfsedttdertdertddtnecuhfhrohhmpedfgfhmihhlihhoucfirdcuvehothgrfdcu oegtohhtrgessghrrggrphdrohhrgheqnecukfhppeduvdekrdehledrvddtrddvudeine curfgrrhgrmhepmhgrihhlfhhrohhmpegtohhtrgessghrrggrphdrohhrghenucevlhhu shhtvghrufhiiigvpeej X-ME-Proxy: From: "Emilio G. Cota" To: qemu-devel@nongnu.org Date: Sun, 9 Dec 2018 14:37:35 -0500 Message-Id: <20181209193749.12277-25-cota@braap.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181209193749.12277-1-cota@braap.org> References: <20181209193749.12277-1-cota@braap.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 64.147.123.25 Subject: [Qemu-devel] [RFC v2 24/38] target/sh4: fetch code with translator_ld (WIP) X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Richard Henderson , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Pavel Dovgalyuk Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" XXX: cleanly get the gUSA instructions Signed-off-by: Emilio G. Cota --- target/sh4/translate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/sh4/translate.c b/target/sh4/translate.c index ab254b0e8d..1704ce8dae 100644 --- a/target/sh4/translate.c +++ b/target/sh4/translate.c @@ -2331,7 +2331,7 @@ static void sh4_tr_translate_insn(DisasContextBase *d= cbase, CPUState *cs) } #endif =20 - ctx->opcode =3D cpu_lduw_code(env, ctx->base.pc_next); + ctx->opcode =3D translator_lduw(env, ctx->base.pc_next); decode_opc(ctx); ctx->base.pc_next +=3D 2; } --=20 2.17.1 From nobody Sat Apr 27 22:25:51 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 154438634443385.26766313117525; Sun, 9 Dec 2018 12:12:24 -0800 (PST) Received: from localhost ([::1]:56566 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gW5R3-00052T-Ps for importer@patchew.org; Sun, 09 Dec 2018 15:12:17 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33597) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gW4uS-0001by-3V for qemu-devel@nongnu.org; Sun, 09 Dec 2018 14:38:38 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gW4uN-0006cT-4l for qemu-devel@nongnu.org; Sun, 09 Dec 2018 14:38:35 -0500 Received: from wout2-smtp.messagingengine.com ([64.147.123.25]:37589) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gW4uM-0005kH-Ol for qemu-devel@nongnu.org; Sun, 09 Dec 2018 14:38:31 -0500 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id 12E53F6B; Sun, 9 Dec 2018 14:38:06 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Sun, 09 Dec 2018 14:38:06 -0500 Received: from localhost (flamenco.cs.columbia.edu [128.59.20.216]) by mail.messagingengine.com (Postfix) with ESMTPA id 50A12102E4; Sun, 9 Dec 2018 14:38:05 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=braap.org; h= from:to:cc:subject:date:message-id:in-reply-to:references; s= mesmtp; bh=adjYRqMP/d3u+lsk+zmaBHkH2WRZc+hiD956t+jDUNU=; b=awtKv k8DH2H+ieO3jflx55bvxRXebGM8cFddtBA6ox+GafXMq0qUiRfoopGHLdEUfNNYO sB6Tp11/iF50l3PqGbHJ2KOKeKYJU7313eFCEf0xYplugPKj1R6o1XEMEdUye03s +c/lgtFJo/3HkrELxEHhGa29h+oJ68FTzr+exs= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:date:from:in-reply-to:message-id :references:subject:to:x-me-proxy:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; bh=adjYRqMP/d3u+lsk+zmaBHkH2WRZc +hiD956t+jDUNU=; b=U4ZlU7ZFo0wi1RWhCBKDlmtGcCdDfsi/UEW0liQx6sFMQ +BdmHCPiGEuneOK//pndyukaeRMNXnvj8djUZApGC1hAdMoemY63JJpA65Zecdik I/ZrwXSz6MeNgXV9uTnBDjGzf2tP2hCJh/y9cSNgd7E7vmFsdYAwup6xFNnWm95l IX/14aHsyUvY0Xvzm0vwfTOPqAKUY7b2HnMPEUufS48xPrs6uva1ae3wbjq7A8h8 0I1mUj3qzulXi351s6ba5ne56Om8PbgqJurcpK/41lXisFPb0yzGSz8AR32sIjYQ RywUhuPpMJyqM9gQYNP5y4u7mi4pXN7Iv1t78oKZQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedtkedrudegfedguddvkecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfhuthenuceurghilhhouhhtmecu fedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvufffkf fojghfsedttdertdertddtnecuhfhrohhmpedfgfhmihhlihhoucfirdcuvehothgrfdcu oegtohhtrgessghrrggrphdrohhrgheqnecukfhppeduvdekrdehledrvddtrddvudeine curfgrrhgrmhepmhgrihhlfhhrohhmpegtohhtrgessghrrggrphdrohhrghenucevlhhu shhtvghrufhiiigvpeej X-ME-Proxy: From: "Emilio G. Cota" To: qemu-devel@nongnu.org Date: Sun, 9 Dec 2018 14:37:36 -0500 Message-Id: <20181209193749.12277-26-cota@braap.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181209193749.12277-1-cota@braap.org> References: <20181209193749.12277-1-cota@braap.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 64.147.123.25 Subject: [Qemu-devel] [RFC v2 25/38] target/i386: fetch code with translator_ld X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Richard Henderson , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Pavel Dovgalyuk Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Emilio G. Cota --- target/i386/translate.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/target/i386/translate.c b/target/i386/translate.c index 83c1ebe491..6ea784da54 100644 --- a/target/i386/translate.c +++ b/target/i386/translate.c @@ -1900,28 +1900,28 @@ static uint64_t advance_pc(CPUX86State *env, DisasC= ontext *s, int num_bytes) =20 static inline uint8_t x86_ldub_code(CPUX86State *env, DisasContext *s) { - return cpu_ldub_code(env, advance_pc(env, s, 1)); + return translator_ldub(env, advance_pc(env, s, 1)); } =20 static inline int16_t x86_ldsw_code(CPUX86State *env, DisasContext *s) { - return cpu_ldsw_code(env, advance_pc(env, s, 2)); + return translator_ldsw(env, advance_pc(env, s, 2)); } =20 static inline uint16_t x86_lduw_code(CPUX86State *env, DisasContext *s) { - return cpu_lduw_code(env, advance_pc(env, s, 2)); + return translator_lduw(env, advance_pc(env, s, 2)); } =20 static inline uint32_t x86_ldl_code(CPUX86State *env, DisasContext *s) { - return cpu_ldl_code(env, advance_pc(env, s, 4)); + return translator_ldl(env, advance_pc(env, s, 4)); } =20 #ifdef TARGET_X86_64 static inline uint64_t x86_ldq_code(CPUX86State *env, DisasContext *s) { - return cpu_ldq_code(env, advance_pc(env, s, 8)); + return translator_ldq(env, advance_pc(env, s, 8)); } #endif =20 --=20 2.17.1 From nobody Sat Apr 27 22:25:51 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1544385957759658.7678370794777; Sun, 9 Dec 2018 12:05:57 -0800 (PST) Received: from localhost ([::1]:56533 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gW5Ku-0006ka-Iy for importer@patchew.org; Sun, 09 Dec 2018 15:05:56 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33592) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gW4uS-0001bs-2W for qemu-devel@nongnu.org; Sun, 09 Dec 2018 14:38:38 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gW4uN-0006cG-1d for qemu-devel@nongnu.org; Sun, 09 Dec 2018 14:38:35 -0500 Received: from wout2-smtp.messagingengine.com ([64.147.123.25]:43843) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gW4uM-0005kG-PD for qemu-devel@nongnu.org; Sun, 09 Dec 2018 14:38:30 -0500 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id 32482F6C; Sun, 9 Dec 2018 14:38:06 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Sun, 09 Dec 2018 14:38:06 -0500 Received: from localhost (flamenco.cs.columbia.edu [128.59.20.216]) by mail.messagingengine.com (Postfix) with ESMTPA id 7F73B102F0; Sun, 9 Dec 2018 14:38:05 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=braap.org; h= from:to:cc:subject:date:message-id:in-reply-to:references; s= mesmtp; bh=atezICT5IcZyhD7Mqziz0kjKALKl8+vsvdlPDwnXMHA=; b=BGaPG X21+v8RI+eWnLO8YQRmtrYfaJ2DREzuxF2NYVVETYTvFhtf19n3Tkf5YkUb1mjAk i5q4ML+i3MPhfXuEJh+F+wSGIujyI6cTBmspzocSry1Fc1kdT7r6je+zVHV/+YrN L7uw8vGSV5vBdTO+m2ffDkHd8xdFu+Xf08EdtA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:date:from:in-reply-to:message-id :references:subject:to:x-me-proxy:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; bh=atezICT5IcZyhD7Mqziz0kjKALKl8 +vsvdlPDwnXMHA=; b=hX248BX8ilrrz7Eya6NEYLMo0VC7fzb8uxloD9N4ODsrU GgZ9ENKaVsyOY4/M1xmhnlIBVHIpzR3Ob0d1FYPTzfQR+SO5LSqyjIrVUGjAWWfm bcEXjapJIIwEqBE9nn+M8ogwmbA2KcS2QwZoKGLWcF7cM2ghNEai6QDMNtIFBecq zHq4bxQlnaWMBv0O24Dwz3Vlwhu+LfX49Hz5WyhNbgELiyySuwASjNWPWcHWwEQp /sTK2NuhB3rG2dehmUeNX8HQYI3NjKvsCyBdi31d/4V+jG0Z7Fm1ZESrOT+u4hOz jIAFQLQ7vNzTkVqyvr1Enh8j3ppcExkfOLjCyjcXg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedtkedrudegfedguddvkecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfhuthenuceurghilhhouhhtmecu fedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvufffkf fojghfsedttdertdertddtnecuhfhrohhmpedfgfhmihhlihhoucfirdcuvehothgrfdcu oegtohhtrgessghrrggrphdrohhrgheqnecukfhppeduvdekrdehledrvddtrddvudeine curfgrrhgrmhepmhgrihhlfhhrohhmpegtohhtrgessghrrggrphdrohhrghenucevlhhu shhtvghrufhiiigvpeej X-ME-Proxy: From: "Emilio G. Cota" To: qemu-devel@nongnu.org Date: Sun, 9 Dec 2018 14:37:37 -0500 Message-Id: <20181209193749.12277-27-cota@braap.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181209193749.12277-1-cota@braap.org> References: <20181209193749.12277-1-cota@braap.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 64.147.123.25 Subject: [Qemu-devel] [RFC v2 26/38] target/hppa: fetch code with translator_ld X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Richard Henderson , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Pavel Dovgalyuk Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Emilio G. Cota --- target/hppa/translate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/hppa/translate.c b/target/hppa/translate.c index df9179e70f..806dbda51f 100644 --- a/target/hppa/translate.c +++ b/target/hppa/translate.c @@ -4754,7 +4754,7 @@ static void hppa_tr_translate_insn(DisasContextBase *= dcbase, CPUState *cs) { /* Always fetch the insn, even if nullified, so that we check the page permissions for execute. */ - uint32_t insn =3D cpu_ldl_code(env, ctx->base.pc_next); + uint32_t insn =3D translator_ldl(env, ctx->base.pc_next); =20 /* Set up the IA queue for the next insn. This will be overwritten by a branch. */ --=20 2.17.1 From nobody Sat Apr 27 22:25:51 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1544386334132270.6352012006673; Sun, 9 Dec 2018 12:12:14 -0800 (PST) Received: from localhost ([::1]:56565 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gW5Qz-0004y7-0U for importer@patchew.org; Sun, 09 Dec 2018 15:12:13 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33594) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gW4uS-0001bx-3n for qemu-devel@nongnu.org; Sun, 09 Dec 2018 14:38:38 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gW4uN-0006eB-DS for qemu-devel@nongnu.org; Sun, 09 Dec 2018 14:38:35 -0500 Received: from wout2-smtp.messagingengine.com ([64.147.123.25]:59289) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gW4uN-0005pg-4C for qemu-devel@nongnu.org; Sun, 09 Dec 2018 14:38:31 -0500 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id 78E4FF74; Sun, 9 Dec 2018 14:38:06 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Sun, 09 Dec 2018 14:38:06 -0500 Received: from localhost (flamenco.cs.columbia.edu [128.59.20.216]) by mail.messagingengine.com (Postfix) with ESMTPA id B1431102EA; Sun, 9 Dec 2018 14:38:05 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=braap.org; h= from:to:cc:subject:date:message-id:in-reply-to:references; s= mesmtp; bh=8Ze2AbGAZ21oPsOLiAlZa47JL27uZoargJGm3DEzs2Y=; b=1yKws 1ITonRFnA9WlB+juCMMjUfmJ8DSAai1TMoOkTEtQS3iFa4C6RsYd2ILMjFMSpeGK R16o27Faltb7+IcZi76Timll6D8ac8W3jkhHBTg4TYuB0T9OSexZwTdGhFHq7WGb gnZYrROfvotTdF3pq8wF6GdznieI8KCFUsje3E= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:date:from:in-reply-to:message-id :references:subject:to:x-me-proxy:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; bh=8Ze2AbGAZ21oPsOLiAlZa47JL27uZ oargJGm3DEzs2Y=; b=Dwb6Ro0oRYo3Sz2qEuJ4mV4xZ84K61GZEx13ge+cdPx0t uVhaV59Uth83NYZIDlcE7QhH2zE1ZkZ0/eTQjToiC5qoSlJRJRo6zXYrOhe7u4Q9 F88pBOoByi8xqJUExxCDDKhqDiFzYsyPQH7zQce5hiRhoTwHQUCtzXKjvV9ujk93 /dLevKb7S7SlzK4XogfysJDuJiw7gUXH5sb5kja7Vec9UG22bh48yYzCXQ+11PEm 5mj4OnSdcOeznuQ043ATKbE4Q3uOsHO/e4bIBABfeBDxVJahM2fO2cZtmlUTsN1H y5Pc1dB+BUb6m+5WgnEU6lVwj8VAeMuwCtsGmD57A== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedtkedrudegfedguddvkecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfhuthenuceurghilhhouhhtmecu fedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvufffkf fojghfsedttdertdertddtnecuhfhrohhmpedfgfhmihhlihhoucfirdcuvehothgrfdcu oegtohhtrgessghrrggrphdrohhrgheqnecukfhppeduvdekrdehledrvddtrddvudeine curfgrrhgrmhepmhgrihhlfhhrohhmpegtohhtrgessghrrggrphdrohhrghenucevlhhu shhtvghrufhiiigvpeej X-ME-Proxy: From: "Emilio G. Cota" To: qemu-devel@nongnu.org Date: Sun, 9 Dec 2018 14:37:38 -0500 Message-Id: <20181209193749.12277-28-cota@braap.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181209193749.12277-1-cota@braap.org> References: <20181209193749.12277-1-cota@braap.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 64.147.123.25 Subject: [Qemu-devel] [RFC v2 27/38] target/m68k: fetch code with translator_ld X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Richard Henderson , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Pavel Dovgalyuk Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Emilio G. Cota --- target/m68k/translate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/m68k/translate.c b/target/m68k/translate.c index d55e707cf6..71263f8b37 100644 --- a/target/m68k/translate.c +++ b/target/m68k/translate.c @@ -373,7 +373,7 @@ static TCGv gen_ldst(DisasContext *s, int opsize, TCGv = addr, TCGv val, static inline uint16_t read_im16(CPUM68KState *env, DisasContext *s) { uint16_t im; - im =3D cpu_lduw_code(env, s->pc); + im =3D translator_lduw(env, s->pc); s->pc +=3D 2; return im; } --=20 2.17.1 From nobody Sat Apr 27 22:25:51 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1544385272359972.1527446304084; Sun, 9 Dec 2018 11:54:32 -0800 (PST) Received: from localhost ([::1]:56470 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gW59r-0002Ej-5D for importer@patchew.org; Sun, 09 Dec 2018 14:54:31 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33593) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gW4uS-0001bu-2f for qemu-devel@nongnu.org; Sun, 09 Dec 2018 14:38:38 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gW4uN-0006gf-O9 for qemu-devel@nongnu.org; Sun, 09 Dec 2018 14:38:35 -0500 Received: from wout2-smtp.messagingengine.com ([64.147.123.25]:41631) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gW4uN-0005pi-Fw for qemu-devel@nongnu.org; Sun, 09 Dec 2018 14:38:31 -0500 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id 9B654F75; Sun, 9 Dec 2018 14:38:06 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Sun, 09 Dec 2018 14:38:07 -0500 Received: from localhost (flamenco.cs.columbia.edu [128.59.20.216]) by mail.messagingengine.com (Postfix) with ESMTPA id E194E102ED; Sun, 9 Dec 2018 14:38:05 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=braap.org; h= from:to:cc:subject:date:message-id:in-reply-to:references; s= mesmtp; bh=rueq75CHjhxgxUZjKRSWOD+VI+ijBjI6wwwFrTbJCkY=; b=ZI8np p4QVVeL8G6bEK41blknaG1cbgdhqYjqC5VfWs2A4fDfBdoqOvCssWMPS13FIeCXf voObiTRuV87OSgZYEm0spqRyr8w/M+gafg4YArFdxRS1OTzK3yP9FYw3OFLjwc82 R0yprKpRORvtV2NpbuUaBzCiW1NySgtAcFWUCo= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:date:from:in-reply-to:message-id :references:subject:to:x-me-proxy:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; bh=rueq75CHjhxgxUZjKRSWOD+VI+ijB jI6wwwFrTbJCkY=; b=kMXKnf6LG6p9KcF3IVbqLvvyQIewtTA0uXI6ak5a0CPHU rRNgDcVidUNSU+5WGXnmtYg3SIDJIjXj2xA7CyGoqfw2MOsNE3Y/JKXEegu9A+G3 5qD0NTre7lF+jj2aPPky8hot2D2G3lBB4yseJokardi9yGIHN+fagnG73rjEQG5I zBi417Oc3WtntouwpP0XYah6GP7jsupuxi6yJRwLcx8Kz992GAe7mpCCZzA5E3GW tduF20Ew5luXxSZxWuXLrNFvdlFpy6Zghu/vVaIv+iHUuJVJqFkcQDVZp+2DVKre kJ3TRL8ETW+FygwoWmY7OjStyx/oiLsarWVTPWKuA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedtkedrudegfedguddvkecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfhuthenuceurghilhhouhhtmecu fedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvufffkf fojghfsedttdertdertddtnecuhfhrohhmpedfgfhmihhlihhoucfirdcuvehothgrfdcu oegtohhtrgessghrrggrphdrohhrgheqnecukfhppeduvdekrdehledrvddtrddvudeine curfgrrhgrmhepmhgrihhlfhhrohhmpegtohhtrgessghrrggrphdrohhrghenucevlhhu shhtvghrufhiiigvpeej X-ME-Proxy: From: "Emilio G. Cota" To: qemu-devel@nongnu.org Date: Sun, 9 Dec 2018 14:37:39 -0500 Message-Id: <20181209193749.12277-29-cota@braap.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181209193749.12277-1-cota@braap.org> References: <20181209193749.12277-1-cota@braap.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 64.147.123.25 Subject: [Qemu-devel] [RFC v2 28/38] target/alpha: fetch code with translator_ld X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Richard Henderson , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Pavel Dovgalyuk Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Emilio G. Cota --- target/alpha/translate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/alpha/translate.c b/target/alpha/translate.c index 25cd95931d..f8d194994a 100644 --- a/target/alpha/translate.c +++ b/target/alpha/translate.c @@ -2987,7 +2987,7 @@ static void alpha_tr_translate_insn(DisasContextBase = *dcbase, CPUState *cpu) { DisasContext *ctx =3D container_of(dcbase, DisasContext, base); CPUAlphaState *env =3D cpu->env_ptr; - uint32_t insn =3D cpu_ldl_code(env, ctx->base.pc_next); + uint32_t insn =3D translator_ldl(env, ctx->base.pc_next); =20 ctx->base.pc_next +=3D 4; ctx->base.is_jmp =3D translate_one(ctx, insn); --=20 2.17.1 From nobody Sat Apr 27 22:25:51 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1544385455004603.9766859650096; Sun, 9 Dec 2018 11:57:35 -0800 (PST) Received: from localhost ([::1]:56487 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gW5Cn-0004mZ-Rf for importer@patchew.org; Sun, 09 Dec 2018 14:57:33 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33610) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gW4uS-0001c6-4y for qemu-devel@nongnu.org; Sun, 09 Dec 2018 14:38:38 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gW4uN-0006ig-WD for qemu-devel@nongnu.org; Sun, 09 Dec 2018 14:38:35 -0500 Received: from wout2-smtp.messagingengine.com ([64.147.123.25]:42707) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gW4uN-0005q8-OW for qemu-devel@nongnu.org; Sun, 09 Dec 2018 14:38:31 -0500 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id CBA6A9CA; Sun, 9 Dec 2018 14:38:06 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Sun, 09 Dec 2018 14:38:07 -0500 Received: from localhost (flamenco.cs.columbia.edu [128.59.20.216]) by mail.messagingengine.com (Postfix) with ESMTPA id 1F026102EE; Sun, 9 Dec 2018 14:38:06 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=braap.org; h= from:to:cc:subject:date:message-id:in-reply-to:references; s= mesmtp; bh=vlkd6OWzRQoAIyV2bn2Fgw0YY3lXEvIf3iJR9lzYZBg=; b=YMZVT au4AY+yk41Lv8uKWbmlAKAc4s+I2YrJC4WuEwFpxZuqqHvqhP9ztbBwpKk6+gf7v ZYQR2NwWknjPDH3F864sTYTe0p/niDzcwL3yASFGhlyRwii7LnG248kLS3NaNIzy wi6w0qVVwCg4cj/R651TtbrFK5yraYzXzYTbrc= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:date:from:in-reply-to:message-id :references:subject:to:x-me-proxy:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; bh=vlkd6OWzRQoAIyV2bn2Fgw0YY3lXE vIf3iJR9lzYZBg=; b=StMJwBmcyK4AkcFp9MWkASyIPhPS5nNUyix5RFG2lAz4C K80Zmjqm4x7mVnnxkyulxNpqcbnHYSx6w6EabETNxdlTKyckO+F2ph2LZjDm6KU1 SASufJAdtDOnpdlugtmu3Bb02MrdJ/hnV697JVwBb7Aby2s14ILxddW4GNhhEf6M xDgujPjD3HpR11mB8/8KbsWX/diMjtnhQzkub9V4/GaLRB16W8ia5i+Rp3i090G5 dbEaHlKpSms/WrW+KmSj89mqqntjR2jSym+hoQ6UXwULjlvdavJF+5qNiwMzsnZT MVfhzqlYAeFlmitnYNG3MUfbsnSBIaZFJhDa0/UoQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedtkedrudegfedguddvkecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfhuthenuceurghilhhouhhtmecu fedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvufffkf fojghfsedttdertdertddtnecuhfhrohhmpedfgfhmihhlihhoucfirdcuvehothgrfdcu oegtohhtrgessghrrggrphdrohhrgheqnecukfhppeduvdekrdehledrvddtrddvudeine curfgrrhgrmhepmhgrihhlfhhrohhmpegtohhtrgessghrrggrphdrohhrghenucevlhhu shhtvghrufhiiigvpeej X-ME-Proxy: From: "Emilio G. Cota" To: qemu-devel@nongnu.org Date: Sun, 9 Dec 2018 14:37:40 -0500 Message-Id: <20181209193749.12277-30-cota@braap.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181209193749.12277-1-cota@braap.org> References: <20181209193749.12277-1-cota@braap.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 64.147.123.25 Subject: [Qemu-devel] [RFC v2 29/38] target/riscv: fetch code with translator_ld X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Richard Henderson , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Pavel Dovgalyuk Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Emilio G. Cota --- target/riscv/translate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/riscv/translate.c b/target/riscv/translate.c index 18d7b6d147..fa96f45a69 100644 --- a/target/riscv/translate.c +++ b/target/riscv/translate.c @@ -1848,7 +1848,7 @@ static void riscv_tr_translate_insn(DisasContextBase = *dcbase, CPUState *cpu) DisasContext *ctx =3D container_of(dcbase, DisasContext, base); CPURISCVState *env =3D cpu->env_ptr; =20 - ctx->opcode =3D cpu_ldl_code(env, ctx->base.pc_next); + ctx->opcode =3D translator_ldl(env, ctx->base.pc_next); decode_opc(env, ctx); ctx->base.pc_next =3D ctx->pc_succ_insn; =20 --=20 2.17.1 From nobody Sat Apr 27 22:25:51 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1544385766723198.5118327538877; Sun, 9 Dec 2018 12:02:46 -0800 (PST) Received: from localhost ([::1]:56519 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gW5Hp-0002S4-4f for importer@patchew.org; Sun, 09 Dec 2018 15:02:45 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33599) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gW4uS-0001c0-3a for qemu-devel@nongnu.org; Sun, 09 Dec 2018 14:38:38 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gW4uN-0006gM-N6 for qemu-devel@nongnu.org; Sun, 09 Dec 2018 14:38:35 -0500 Received: from wout2-smtp.messagingengine.com ([64.147.123.25]:58167) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gW4uN-0005qA-Fc for qemu-devel@nongnu.org; Sun, 09 Dec 2018 14:38:31 -0500 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id 07DBAF7E; Sun, 9 Dec 2018 14:38:06 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Sun, 09 Dec 2018 14:38:07 -0500 Received: from localhost (flamenco.cs.columbia.edu [128.59.20.216]) by mail.messagingengine.com (Postfix) with ESMTPA id 4C7D9102F1; Sun, 9 Dec 2018 14:38:06 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=braap.org; h= from:to:cc:subject:date:message-id:in-reply-to:references; s= mesmtp; bh=7G0b3T3zUCc0Jv1TcNTs//lJW/uUANRsyZNBad/d3kU=; b=n4nUV b/ZhyptcBlyVmqWzU25CD3WQe/09EU2/a6D1rpBUP6yVlwBZ9jsc/ZpWH8MJfNXf QkBvJpK0OXbQ9zOm6JUKOsENVenKitrrd0PNK286CmGoeRYh6mnzVhtCw1QZh4WU xVBmhxRewBp7lumKOmFwzxHjv8njRXCwKNPJBI= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:date:from:in-reply-to:message-id :references:subject:to:x-me-proxy:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; bh=7G0b3T3zUCc0Jv1TcNTs//lJW/uUA NRsyZNBad/d3kU=; b=RAai0wWOVTmTtc7FfFnHwtFbO1pmj53X8XSc48XpDtZl9 nfwF3TzAjNNfLvXbm+rrStAbAvXBGu83FcPIUcfehJ7XkL7Ve3x8qFA7pHwHHGF2 0yAmMJta3Sf4Ckpsv67PGmm8dwrHrz0Gu+qI4J3QCzblzBDbv2eWM+d7ikFS295j KcwbI85ixfsosRv0OGdraP47x8q6vyoECt5nu8TMRwf0p/VkGRx/uA/6erltX73X 9WtZIfmXvGnaNXbFgomWm3shQgLq2Hp4gBx8gdywO8hNjcTAQ5nWSioaDrClgiyj W4zmv6HJ1f5KOMt20s4+0M5TXJMv3Vlei3JrH9JZA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedtkedrudegfedguddvkecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfhuthenuceurghilhhouhhtmecu fedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvufffkf fojghfsedttdertdertddtnecuhfhrohhmpedfgfhmihhlihhoucfirdcuvehothgrfdcu oegtohhtrgessghrrggrphdrohhrgheqnecukfhppeduvdekrdehledrvddtrddvudeine curfgrrhgrmhepmhgrihhlfhhrohhmpegtohhtrgessghrrggrphdrohhrghenucevlhhu shhtvghrufhiiigvpeej X-ME-Proxy: From: "Emilio G. Cota" To: qemu-devel@nongnu.org Date: Sun, 9 Dec 2018 14:37:41 -0500 Message-Id: <20181209193749.12277-31-cota@braap.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181209193749.12277-1-cota@braap.org> References: <20181209193749.12277-1-cota@braap.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 64.147.123.25 Subject: [Qemu-devel] [RFC v2 30/38] target/sparc: fetch code with translator_ld X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Richard Henderson , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Pavel Dovgalyuk Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Emilio G. Cota --- target/sparc/translate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/sparc/translate.c b/target/sparc/translate.c index 74315cdf09..2c754b6163 100644 --- a/target/sparc/translate.c +++ b/target/sparc/translate.c @@ -5900,7 +5900,7 @@ static void sparc_tr_translate_insn(DisasContextBase = *dcbase, CPUState *cs) CPUSPARCState *env =3D cs->env_ptr; unsigned int insn; =20 - insn =3D cpu_ldl_code(env, dc->pc); + insn =3D translator_ldl(env, dc->pc); dc->base.pc_next +=3D 4; disas_sparc_insn(dc, insn); =20 --=20 2.17.1 From nobody Sat Apr 27 22:25:51 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 15443865243871022.6987080634512; Sun, 9 Dec 2018 12:15:24 -0800 (PST) Received: from localhost ([::1]:56580 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gW5Tx-0000tW-9F for importer@patchew.org; Sun, 09 Dec 2018 15:15:17 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33600) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gW4uS-0001c1-3k for qemu-devel@nongnu.org; Sun, 09 Dec 2018 14:38:38 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gW4uO-0006mL-9m for qemu-devel@nongnu.org; Sun, 09 Dec 2018 14:38:35 -0500 Received: from wout2-smtp.messagingengine.com ([64.147.123.25]:42655) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gW4uN-0005sW-Sa for qemu-devel@nongnu.org; Sun, 09 Dec 2018 14:38:32 -0500 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id 41A3AF85; Sun, 9 Dec 2018 14:38:07 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Sun, 09 Dec 2018 14:38:07 -0500 Received: from localhost (flamenco.cs.columbia.edu [128.59.20.216]) by mail.messagingengine.com (Postfix) with ESMTPA id 7CBB8102DD; Sun, 9 Dec 2018 14:38:06 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=braap.org; h= from:to:cc:subject:date:message-id:in-reply-to:references; s= mesmtp; bh=k51Y6rZAHxBINbG0MmDa+7emDHd06Wc0OwQgXp9oZ4w=; b=NvH7d 2+1YT3xKHNrcP7ExR2dsoSHkWj3oQH3MdVrp4PcWMUZpUkfzguHgn2BtMALAy/0u IiuBkkhMYyzgIKaOsazTh1hZgxtDUKGueOeampDBpO63AsozhKRGH/bj0fnjdr6z J/tGXhESxTzxheI9fP1qj7MFq7lZtQqN12wxuI= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:date:from:in-reply-to:message-id :references:subject:to:x-me-proxy:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; bh=k51Y6rZAHxBINbG0MmDa+7emDHd06 Wc0OwQgXp9oZ4w=; b=WxcofswgelMupdFwgukP1ImJUufTrD+PUBFNj49rOrDHP s8kfg8Kj6tsOFZyCLP0y51Eo+5jDi05J2zU70OZNCjB4tyeUBaLo7BwNHubpfm1P FMSV0gySr1Wd2hvplsWagAwLw5GecBCGur73OT7lrxNT/HTQGXIjaLDEkV1AjjYC CxdpuTPP0pI5TPaZUTbZ2J8tM0/CGwcmfH0aRIe0Z+NqCHdRuMKMXOd2AKhsdDaP 9QNCoykdWusJsYjG7Uuq7r4VwZK7OGMUDEgD3coIXMHu/8EKpGJjRxYsLVXfj1m3 9y9AZSy0l5GueF0Onp1h0ZTHhqKBUXRfnuQxlYO/g== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedtkedrudegfedguddvkecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfhuthenuceurghilhhouhhtmecu fedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvufffkf fojghfsedttdertdertddtnecuhfhrohhmpedfgfhmihhlihhoucfirdcuvehothgrfdcu oegtohhtrgessghrrggrphdrohhrgheqnecukfhppeduvdekrdehledrvddtrddvudeine curfgrrhgrmhepmhgrihhlfhhrohhmpegtohhtrgessghrrggrphdrohhrghenucevlhhu shhtvghrufhiiigvpeej X-ME-Proxy: From: "Emilio G. Cota" To: qemu-devel@nongnu.org Date: Sun, 9 Dec 2018 14:37:42 -0500 Message-Id: <20181209193749.12277-32-cota@braap.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181209193749.12277-1-cota@braap.org> References: <20181209193749.12277-1-cota@braap.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 64.147.123.25 Subject: [Qemu-devel] [RFC v2 31/38] target/xtensa: fetch code with translator_ld X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Richard Henderson , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Pavel Dovgalyuk Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Emilio G. Cota --- target/xtensa/translate.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/target/xtensa/translate.c b/target/xtensa/translate.c index 46e1338448..c140742562 100644 --- a/target/xtensa/translate.c +++ b/target/xtensa/translate.c @@ -882,7 +882,7 @@ static inline unsigned xtensa_op0_insn_len(DisasContext= *dc, uint8_t op0) static void disas_xtensa_insn(CPUXtensaState *env, DisasContext *dc) { xtensa_isa isa =3D dc->config->isa; - unsigned char b[MAX_INSN_LENGTH] =3D {cpu_ldub_code(env, dc->pc)}; + unsigned char b[MAX_INSN_LENGTH] =3D {translator_ldub(env, dc->pc)}; unsigned len =3D xtensa_op0_insn_len(dc, b[0]); xtensa_format fmt; int slot, slots; @@ -914,7 +914,7 @@ static void disas_xtensa_insn(CPUXtensaState *env, Disa= sContext *dc) dc->pc); } for (i =3D 1; i < len; ++i) { - b[i] =3D cpu_ldub_code(env, dc->pc + i); + b[i] =3D translator_ldub(env, dc->pc + i); } xtensa_insnbuf_from_chars(isa, dc->insnbuf, b, len); fmt =3D xtensa_format_decode(isa, dc->insnbuf); --=20 2.17.1 From nobody Sat Apr 27 22:25:51 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 15443861899861004.4528376954946; Sun, 9 Dec 2018 12:09:49 -0800 (PST) Received: from localhost ([::1]:56551 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gW5Oe-0003CQ-O9 for importer@patchew.org; Sun, 09 Dec 2018 15:09:48 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33602) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gW4uS-0001c4-3w for qemu-devel@nongnu.org; Sun, 09 Dec 2018 14:38:38 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gW4uO-0006lW-6G for qemu-devel@nongnu.org; Sun, 09 Dec 2018 14:38:35 -0500 Received: from wout2-smtp.messagingengine.com ([64.147.123.25]:33329) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gW4uN-0005sj-TF for qemu-devel@nongnu.org; Sun, 09 Dec 2018 14:38:32 -0500 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id 60CFFF88; Sun, 9 Dec 2018 14:38:07 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Sun, 09 Dec 2018 14:38:07 -0500 Received: from localhost (flamenco.cs.columbia.edu [128.59.20.216]) by mail.messagingengine.com (Postfix) with ESMTPA id AD312102E4; Sun, 9 Dec 2018 14:38:06 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=braap.org; h= from:to:cc:subject:date:message-id:in-reply-to:references; s= mesmtp; bh=TZM/SOGQxqfBxDkGUIrRse7FkyUg1ZbqYCE1ltOuo1Y=; b=DaFnh wFJP9Bzua3Cd4FdL1ryQzaPEYGvt7LqDvj4LcGWyT8gZoBLyqjVnGljEk4jY3owB 6MDDX8uBU6QsWzEEVQp3IbqIh0XCLV65OItL/T2c2HW93WkiokNiWLaeWznGKK+0 oG9RmdszgK0QDAsrbpfpW8XJ8y+B1g40J/5NBc= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:date:from:in-reply-to:message-id :references:subject:to:x-me-proxy:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; bh=TZM/SOGQxqfBxDkGUIrRse7FkyUg1 ZbqYCE1ltOuo1Y=; b=EOuMivVn+MZYImoabojouQEwn2pJDXxa34laynrWhkdMy U2spdw4gJ5xG5Zk9BDnwqzHy/KDpZtmuQslEaqJSQ33fL+wnmyc1tzk6buOZUf3X AhfWElqrznpGe+kzFWL78VFi6z+uEHIugC1yZJDyzBhUw2cRJiY7XBQ+zkBcODeR 96zlkCivzgS3YbrpHwnCPrx6h4wJwFb55rhELpPQuS5QN1T/bBonEejAM+NoCtHf LzuBJpYL5zbiChS01tqjTkVVfFuEWYGYRlYx10yg5x4yjXgONpMmQs23JsiVS81k 7SBPMOFqDKD6MiL7sM8dKL4ldlz7nn1SrMtm8zbVg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedtkedrudegfedguddvkecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfhuthenuceurghilhhouhhtmecu fedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvufffkf fojghfsedttdertdertddtnecuhfhrohhmpedfgfhmihhlihhoucfirdcuvehothgrfdcu oegtohhtrgessghrrggrphdrohhrgheqnecukfhppeduvdekrdehledrvddtrddvudeine curfgrrhgrmhepmhgrihhlfhhrohhmpegtohhtrgessghrrggrphdrohhrghenucevlhhu shhtvghrufhiiigvpeej X-ME-Proxy: From: "Emilio G. Cota" To: qemu-devel@nongnu.org Date: Sun, 9 Dec 2018 14:37:43 -0500 Message-Id: <20181209193749.12277-33-cota@braap.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181209193749.12277-1-cota@braap.org> References: <20181209193749.12277-1-cota@braap.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 64.147.123.25 Subject: [Qemu-devel] [RFC v2 32/38] target/openrisc: fetch code with translator_ld X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Richard Henderson , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Pavel Dovgalyuk Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Emilio G. Cota --- target/openrisc/translate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/openrisc/translate.c b/target/openrisc/translate.c index a271cd3903..6b5efc0155 100644 --- a/target/openrisc/translate.c +++ b/target/openrisc/translate.c @@ -1305,7 +1305,7 @@ static void openrisc_tr_translate_insn(DisasContextBa= se *dcbase, CPUState *cs) { DisasContext *dc =3D container_of(dcbase, DisasContext, base); OpenRISCCPU *cpu =3D OPENRISC_CPU(cs); - uint32_t insn =3D cpu_ldl_code(&cpu->env, dc->base.pc_next); + uint32_t insn =3D translator_ldl(&cpu->env, dc->base.pc_next); =20 if (!decode(dc, insn)) { gen_illegal_exception(dc); --=20 2.17.1 From nobody Sat Apr 27 22:25:51 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 154438615242968.27793289156386; Sun, 9 Dec 2018 12:09:12 -0800 (PST) Received: from localhost ([::1]:56549 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gW5Ny-0002fT-Db for importer@patchew.org; Sun, 09 Dec 2018 15:09:06 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33601) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gW4uS-0001c3-3w for qemu-devel@nongnu.org; Sun, 09 Dec 2018 14:38:38 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gW4uO-0006nU-Bk for qemu-devel@nongnu.org; Sun, 09 Dec 2018 14:38:35 -0500 Received: from wout2-smtp.messagingengine.com ([64.147.123.25]:57967) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gW4uN-0005sv-U5 for qemu-devel@nongnu.org; Sun, 09 Dec 2018 14:38:32 -0500 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id 8C669F6D; Sun, 9 Dec 2018 14:38:07 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Sun, 09 Dec 2018 14:38:07 -0500 Received: from localhost (flamenco.cs.columbia.edu [128.59.20.216]) by mail.messagingengine.com (Postfix) with ESMTPA id DECC1102F0; Sun, 9 Dec 2018 14:38:06 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=braap.org; h= from:to:cc:subject:date:message-id:in-reply-to:references; s= mesmtp; bh=ZZ67Tsj0Pig66VNpHDdM/cQIVuKKpL6Vu8W1uUb4mi8=; b=axbj2 muyGYVoJr60kyEEKKUuxa0OQgUAaNR80EtgXAMlLZYL1AlXyLCqcgCsdlJlfteaA KUY/Kud8Vuh/6NCbVyJtQ6zJTQ+1XJ6B3cqgGBf6dDdDDw0eBHB/jJi0nz4ICGIC GY2zCzrXgxujd7gnNg++avFYYIh/DixDHE9Izw= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:date:from:in-reply-to:message-id :references:subject:to:x-me-proxy:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; bh=ZZ67Tsj0Pig66VNpHDdM/cQIVuKKp L6Vu8W1uUb4mi8=; b=FhE/WrOUAyS/uw21T3WZIhWj9ncsl8G6jD5JscOxCQ9Uy PdJ68AJcgAPD5+BmFRTbulir+n1SMWQIZgHrKdT3O3N1tusVRBkm6HiPj4MAosvj 76i1wusvJrAq06FBzj++9Nk1TyYmHptSxdsBjNIRHyPQExwjFHreg24qnuk1l7aq idUmRA6A9rY/OkjbFGnT9+WIIJaKg4zDDo2KC1IK2rhWhbACeaHnoawzZ+ww0Zf0 Y7H+SBOeiHkLnFu+IooGghvLtuX7AFQULPLNzkpimNCNpVZGRMBSTMgW1XTEKxh5 8FpYNX575JbCF0KmO+/w9/+axJlr4uhUX2J2NQTsA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedtkedrudegfedguddvkecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfhuthenuceurghilhhouhhtmecu fedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvufffkf fojghfsedttdertdertddtnecuhfhrohhmpedfgfhmihhlihhoucfirdcuvehothgrfdcu oegtohhtrgessghrrggrphdrohhrgheqnecukfhppeduvdekrdehledrvddtrddvudeine curfgrrhgrmhepmhgrihhlfhhrohhmpegtohhtrgessghrrggrphdrohhrghenucevlhhu shhtvghrufhiiigvpeej X-ME-Proxy: From: "Emilio G. Cota" To: qemu-devel@nongnu.org Date: Sun, 9 Dec 2018 14:37:44 -0500 Message-Id: <20181209193749.12277-34-cota@braap.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181209193749.12277-1-cota@braap.org> References: <20181209193749.12277-1-cota@braap.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 64.147.123.25 Subject: [Qemu-devel] [RFC v2 33/38] translator: inject instrumentation from plugins X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Richard Henderson , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Pavel Dovgalyuk Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Emilio G. Cota --- accel/tcg/translator.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/accel/tcg/translator.c b/accel/tcg/translator.c index afd0a49ea6..68174a2986 100644 --- a/accel/tcg/translator.c +++ b/accel/tcg/translator.c @@ -17,6 +17,7 @@ #include "exec/gen-icount.h" #include "exec/log.h" #include "exec/translator.h" +#include "exec/plugin-gen.h" =20 /* Pairs with tcg_clear_temp_count. To be called by #TranslatorOps.{translate_insn,tb_stop} if @@ -35,6 +36,7 @@ void translator_loop(const TranslatorOps *ops, DisasConte= xtBase *db, CPUState *cpu, TranslationBlock *tb) { int bp_insn =3D 0; + bool plugin_enabled; =20 /* Initialize DisasContext */ db->tb =3D tb; @@ -67,11 +69,17 @@ void translator_loop(const TranslatorOps *ops, DisasCon= textBase *db, ops->tb_start(db, cpu); tcg_debug_assert(db->is_jmp =3D=3D DISAS_NEXT); /* no early exit */ =20 + plugin_enabled =3D plugin_gen_tb_start(cpu, tb); + while (true) { db->num_insns++; ops->insn_start(db, cpu); tcg_debug_assert(db->is_jmp =3D=3D DISAS_NEXT); /* no early exit = */ =20 + if (plugin_enabled) { + plugin_gen_insn_start(cpu, db); + } + /* Pass breakpoint hits to target for further processing */ if (!db->singlestep_enabled && unlikely(!QTAILQ_EMPTY(&cpu->breakpoints))) { @@ -107,6 +115,10 @@ void translator_loop(const TranslatorOps *ops, DisasCo= ntextBase *db, ops->translate_insn(db, cpu); } =20 + if (plugin_enabled) { + plugin_gen_insn_end(); + } + /* Stop translation if translate_insn so indicated. */ if (db->is_jmp !=3D DISAS_NEXT) { break; @@ -124,6 +136,10 @@ void translator_loop(const TranslatorOps *ops, DisasCo= ntextBase *db, ops->tb_stop(db, cpu); gen_tb_end(db->tb, db->num_insns - bp_insn); =20 + if (plugin_enabled) { + plugin_gen_tb_end(cpu); + } + /* The disas_log hook may use these values rather than recompute. */ db->tb->size =3D db->pc_next - db->pc_first; db->tb->icount =3D db->num_insns; --=20 2.17.1 From nobody Sat Apr 27 22:25:51 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1544385574736673.1097406537838; Sun, 9 Dec 2018 11:59:34 -0800 (PST) Received: from localhost ([::1]:56497 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gW5Ej-0008Pu-JD for importer@patchew.org; Sun, 09 Dec 2018 14:59:33 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33598) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gW4uS-0001bz-3W for qemu-devel@nongnu.org; Sun, 09 Dec 2018 14:38:38 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gW4uO-0006o0-Cy for qemu-devel@nongnu.org; Sun, 09 Dec 2018 14:38:35 -0500 Received: from wout2-smtp.messagingengine.com ([64.147.123.25]:55759) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gW4uN-0005sx-Vi for qemu-devel@nongnu.org; Sun, 09 Dec 2018 14:38:32 -0500 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id C1D5CC13; Sun, 9 Dec 2018 14:38:07 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Sun, 09 Dec 2018 14:38:08 -0500 Received: from localhost (flamenco.cs.columbia.edu [128.59.20.216]) by mail.messagingengine.com (Postfix) with ESMTPA id 10FC5102E0; Sun, 9 Dec 2018 14:38:07 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=braap.org; h= from:to:cc:subject:date:message-id:in-reply-to:references; s= mesmtp; bh=+JkY9YuR8V71Xv/BqzHsJIe9z+UVVgxpAE5SPckscuU=; b=N7Iy9 FB2LP1RrF2cyXwrANDTOuhsgxoDPUSWO2mXV4hMN93poBuzzYSEv1Y2kNb+Ol10E g0R+B18ZQ/iUlLn9wtpHD7TXnloQzVW5BXoylio7uwQgN3CiP5dlcYj9SnjhS9t8 nCC8VQjXY/DTfbCbfk0IXJNUf4xqOpqcWTIZwU= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:date:from:in-reply-to:message-id :references:subject:to:x-me-proxy:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; bh=+JkY9YuR8V71Xv/BqzHsJIe9z+UVV gxpAE5SPckscuU=; b=Ng5OehOghHawol/K7oR74aTct2VkskR9JDL3oAGmGg4BD uTzX42ewSijl6tU+bM0t/TW44Kf5Wx/uLuUitWVluBQWXJfiAryd9yigx1S7B+JV Ovq6XNQjje0swxWnQnBmQTFIyB1dM6couJIy+K+l7ja1sQ+Z12dFcaFIVv707tfL arsZ0Gf2hvfz8QPax1kSQcn7TzVLMZTnBjZFUSo6ofhJ6Ak+VY1PLjtCyN6LsIYm 1e37+QiTT3O1Bgw2/Ogvi8eH363eCZxLdrHHZdf+fMZPOmZrGvQfkqNMaBxqUB3C GtnXqOdJnTb12pohJotMP3yhK68T4JHs40XZkvQqQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedtkedrudegfedguddvkecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfhuthenuceurghilhhouhhtmecu fedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvufffkf fojghfsedttdertdertddtnecuhfhrohhmpedfgfhmihhlihhoucfirdcuvehothgrfdcu oegtohhtrgessghrrggrphdrohhrgheqnecukfhppeduvdekrdehledrvddtrddvudeine curfgrrhgrmhepmhgrihhlfhhrohhmpegtohhtrgessghrrggrphdrohhrghenucevlhhu shhtvghrufhiiigvpeej X-ME-Proxy: From: "Emilio G. Cota" To: qemu-devel@nongnu.org Date: Sun, 9 Dec 2018 14:37:45 -0500 Message-Id: <20181209193749.12277-35-cota@braap.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181209193749.12277-1-cota@braap.org> References: <20181209193749.12277-1-cota@braap.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 64.147.123.25 Subject: [Qemu-devel] [RFC v2 34/38] plugin: add API symbols to qemu-plugins.symbols X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Richard Henderson , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Pavel Dovgalyuk Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Emilio G. Cota --- qemu-plugins.symbols | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 qemu-plugins.symbols diff --git a/qemu-plugins.symbols b/qemu-plugins.symbols new file mode 100644 index 0000000000..2a5b18862a --- /dev/null +++ b/qemu-plugins.symbols @@ -0,0 +1,34 @@ +{ + qemu_plugin_uninstall; + qemu_plugin_register_vcpu_init_cb; + qemu_plugin_register_vcpu_exit_cb; + qemu_plugin_register_vcpu_idle_cb; + qemu_plugin_register_vcpu_resume_cb; + qemu_plugin_register_vcpu_insn_exec_cb; + qemu_plugin_register_vcpu_insn_exec_inline; + qemu_plugin_register_vcpu_mem_cb; + qemu_plugin_register_vcpu_mem_haddr_cb; + qemu_plugin_register_vcpu_mem_inline; + qemu_plugin_ram_addr_from_host; + qemu_plugin_register_vcpu_tb_trans_cb; + qemu_plugin_register_vcpu_tb_exec_cb; + qemu_plugin_register_vcpu_tb_exec_inline; + qemu_plugin_register_flush_cb; + qemu_plugin_register_vcpu_syscall_cb; + qemu_plugin_register_vcpu_syscall_ret_cb; + qemu_plugin_register_atexit_cb; + qemu_plugin_tb_n_insns; + qemu_plugin_tb_get_insn; + qemu_plugin_tb_vaddr; + qemu_plugin_insn_data; + qemu_plugin_insn_size; + qemu_plugin_insn_vaddr; + qemu_plugin_insn_haddr; + qemu_plugin_mem_size_shift; + qemu_plugin_mem_is_sign_extended; + qemu_plugin_mem_is_big_endian; + qemu_plugin_mem_is_store; + qemu_plugin_vcpu_for_each; + qemu_plugin_n_vcpus; + qemu_plugin_n_max_vcpus; +}; --=20 2.17.1 From nobody Sat Apr 27 22:25:51 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1544386146763256.57051341426666; Sun, 9 Dec 2018 12:09:06 -0800 (PST) Received: from localhost ([::1]:56548 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gW5Nt-0002au-UL for importer@patchew.org; Sun, 09 Dec 2018 15:09:02 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33667) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gW4uT-0001cf-Lt for qemu-devel@nongnu.org; Sun, 09 Dec 2018 14:38:38 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gW4uO-0006oC-EC for qemu-devel@nongnu.org; Sun, 09 Dec 2018 14:38:37 -0500 Received: from wout2-smtp.messagingengine.com ([64.147.123.25]:48967) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gW4uO-0005sz-1L for qemu-devel@nongnu.org; Sun, 09 Dec 2018 14:38:32 -0500 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id E88D8F8A; Sun, 9 Dec 2018 14:38:07 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Sun, 09 Dec 2018 14:38:08 -0500 Received: from localhost (flamenco.cs.columbia.edu [128.59.20.216]) by mail.messagingengine.com (Postfix) with ESMTPA id 3752F102ED; Sun, 9 Dec 2018 14:38:07 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=braap.org; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; s=mesmtp; bh=s6tY36AX5rau4107DeJnhmmCwkv2DQ3rCDGJzgycMAY=; b=k/BhhhdFYWMf KutSQhlHJd8i1NKKKrNQKAa92Hwvz0D7IGS/vGhTv6NVSjHWlQ4lGZ8sADkeEERP 67CnOCRyYyoFTOb8f+lxH8J9r21rHk8z7Xa3/GxPoZKvYe1yTEgSfEoSsdpIfRXY qRs4g+gE8SVy/ulApTZcH5GgGkyo1vg= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; bh=s6tY36AX5rau4107DeJnhmmCwkv2DQ3rCDGJzgycM AY=; b=ABZHw8rCvNdFRVHkQYSKl6GQzwTkAOVBGyyS4nhhboYdGRgBUNJUxNSbl mvA+rp5brhIuA57YFrLCZRmvsZfX47i8F0KATWyjT7NWvUmrvIFVHUtFyhED2Ofa 7PPaZT5sRslnPw39pFMWXyAPtXuF8Wm5ZgyJRo2Zo1kaN1/8ZjAzKisviAJ72eq8 m1sdE7MgWucgxT4tjBNeWk/zUa5z/P2h3eYX/ovQc3+0rx/VJBcTidrxfXyUPQYy rxQEao2ARfwfp5RrkkTQOtyndnJj/lcS2AarRozxjwMdrhUQh+FvYRvwvu8CuNz7 f8cNeJ/uW+ra/hTpZaRv3MHCBm05g== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedtkedrudegfedguddvkecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfhuthenuceurghilhhouhhtmecu fedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvufffkf fojghfgggtgfesthekredtredtjeenucfhrhhomhepfdfgmhhilhhiohcuifdrucevohht rgdfuceotghothgrsegsrhgrrghprdhorhhgqeenucfkphepuddvkedrheelrddvtddrvd duieenucfrrghrrghmpehmrghilhhfrhhomheptghothgrsegsrhgrrghprdhorhhgnecu vehluhhsthgvrhfuihiivgepie X-ME-Proxy: From: "Emilio G. Cota" To: qemu-devel@nongnu.org Date: Sun, 9 Dec 2018 14:37:46 -0500 Message-Id: <20181209193749.12277-36-cota@braap.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181209193749.12277-1-cota@braap.org> References: <20181209193749.12277-1-cota@braap.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 64.147.123.25 Subject: [Qemu-devel] [RFC v2 35/38] configure: add --enable-plugins X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Richard Henderson , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Pavel Dovgalyuk Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Add support for both ld (using --dynamic-list) and MacOSX's ld64 (-exported_symbols_list). Reviewed-by: Alex Benn=C3=A9e Signed-off-by: Emilio G. Cota --- configure | 82 +++++++++++++++++++++++++++++++++++++++++++++++++ Makefile | 1 + Makefile.target | 18 ++++++++++- .gitignore | 2 ++ 4 files changed, 102 insertions(+), 1 deletion(-) diff --git a/configure b/configure index 1c473ce95b..91f9c08ae2 100755 --- a/configure +++ b/configure @@ -30,6 +30,7 @@ TMPO=3D"${TMPDIR1}/${TMPB}.o" TMPCXX=3D"${TMPDIR1}/${TMPB}.cxx" TMPE=3D"${TMPDIR1}/${TMPB}.exe" TMPMO=3D"${TMPDIR1}/${TMPB}.mo" +TMPTXT=3D"${TMPDIR1}/${TMPB}.txt" =20 rm -f config.log =20 @@ -474,6 +475,7 @@ libxml2=3D"" docker=3D"no" debug_mutex=3D"no" libpmem=3D"" +plugins=3D"no" =20 # cross compilers defaults, can be overridden with --cross-cc-ARCH cross_cc_aarch64=3D"aarch64-linux-gnu-gcc" @@ -1444,6 +1446,10 @@ for opt do ;; --disable-libpmem) libpmem=3Dno ;; + --enable-plugins) plugins=3D"yes" + ;; + --disable-plugins) plugins=3D"no" + ;; *) echo "ERROR: unknown option $opt" echo "Try '$0 --help' for more information" @@ -1634,6 +1640,8 @@ Advanced options (experts only): xen pv domain builder --enable-debug-stack-usage track the maximum stack usage of stacks created= by qemu_alloc_stack + --enable-plugins + enable plugins via shared library loading =20 Optional features, enabled with --enable-FEATURE and disabled with --disable-FEATURE, default is enabled if available: @@ -5143,6 +5151,58 @@ if compile_prog "" "" ; then atomic64=3Dyes fi =20 +######################################### +# See if --dynamic-list is supported by the linker + +cat > $TMPTXT < $TMPC < +void foo(void); + +void foo(void) +{ + printf("foo\n"); +} + +int main(void) +{ + foo(); + return 0; +} +EOF + +ld_dynamic_list=3D"no" +if compile_prog "" "-Wl,--dynamic-list=3D$TMPTXT" ; then + ld_dynamic_list=3D"yes" +fi + +######################################### +# See if -exported_symbols_list is supported by the linker + +cat > $TMPTXT < Your SDL version is too old - please upgrade to have SDL support" @@ -6779,6 +6840,27 @@ if test "$libpmem" =3D "yes" ; then echo "CONFIG_LIBPMEM=3Dy" >> $config_host_mak fi =20 +if test "$plugins" =3D "yes" ; then + echo "CONFIG_PLUGIN=3Dy" >> $config_host_mak + LIBS=3D"-ldl $LIBS" + # Copy the export object list to the build dir + if test "$ld_dynamic_list" =3D "yes" ; then + echo "CONFIG_HAS_LD_DYNAMIC_LIST=3Dyes" >> $config_host_mak + ld_symbols=3Dqemu-plugins-ld.symbols + cp "$source_path/qemu-plugins.symbols" $ld_symbols + elif test "$ld_exported_symbols_list" =3D "yes" ; then + echo "CONFIG_HAS_LD_EXPORTED_SYMBOLS_LIST=3Dyes" >> $config_host_mak + ld64_symbols=3Dqemu-plugins-ld64.symbols + echo "# Automatically generated by configure - do not modify" > $ld64_sym= bols + grep 'qemu_' "$source_path/qemu-plugins.symbols" | sed 's/;//g' | \ + sed -E 's/^[[:space:]]*(.*)/_\1/' >> $ld64_symbols + else + error_exit \ + "If \$plugins=3Dyes, either \$ld_dynamic_list or " \ + "\$ld_exported_symbols_list should have been set to 'yes'." + fi +fi + if test "$tcg_interpreter" =3D "yes"; then QEMU_INCLUDES=3D"-iquote \$(SRC_PATH)/tcg/tci $QEMU_INCLUDES" elif test "$ARCH" =3D "sparc64" ; then diff --git a/Makefile b/Makefile index 9cb3076d84..6fd15b296f 100644 --- a/Makefile +++ b/Makefile @@ -778,6 +778,7 @@ distclean: clean rm -f qemu-doc.fn qemu-doc.fns qemu-doc.info qemu-doc.ky qemu-doc.kys rm -f qemu-doc.log qemu-doc.pdf qemu-doc.pg qemu-doc.toc qemu-doc.tp rm -f qemu-doc.vr qemu-doc.txt + rm -f qemu-plugins-ld.symbols qemu-plugins-ld64.symbols rm -f config.log rm -f linux-headers/asm rm -f docs/version.texi diff --git a/Makefile.target b/Makefile.target index 75637c285c..7dada1f368 100644 --- a/Makefile.target +++ b/Makefile.target @@ -107,7 +107,23 @@ obj-y +=3D target/$(TARGET_BASE_ARCH)/ obj-y +=3D disas.o obj-$(call notempty,$(TARGET_XML_FILES)) +=3D gdbstub-xml.o =20 -obj-$(CONFIG_PLUGINS) +=3D plugin.o +ifdef CONFIG_PLUGIN +obj-y +=3D plugin.o +# Abuse -libs suffix to only link with --dynamic-list/-exported_symbols_li= st +# when the final binary includes the plugin object. +# +# Note that simply setting LDFLAGS is not enough: we build binaries that +# never link plugin.o, and the linker might fail (at least ld64 does) +# if the symbols in the list are not in the output binary. + ifdef CONFIG_HAS_LD_DYNAMIC_LIST + plugin.o-libs :=3D -Wl,--dynamic-list=3D$(BUILD_DIR)/qemu-plugins-ld.symb= ols + else + ifdef CONFIG_HAS_LD_EXPORTED_SYMBOLS_LIST + plugin.o-libs :=3D \ + -Wl,-exported_symbols_list,$(BUILD_DIR)/qemu-plugins-ld64.symbols + endif + endif +endif =20 ######################################################### # Linux user emulator target diff --git a/.gitignore b/.gitignore index 64efdfd929..29f6446508 100644 --- a/.gitignore +++ b/.gitignore @@ -213,3 +213,5 @@ trace-dtrace-root.dtrace trace-ust-all.h trace-ust-all.c /target/arm/decode-sve.inc.c +qemu-plugins-ld.symbols +qemu-plugins-ld64.symbols --=20 2.17.1 From nobody Sat Apr 27 22:25:51 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1544385804404206.0724230756406; Sun, 9 Dec 2018 12:03:24 -0800 (PST) Received: from localhost ([::1]:56520 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gW5IR-0002tw-4O for importer@patchew.org; Sun, 09 Dec 2018 15:03:23 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33662) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gW4uT-0001ce-DQ for qemu-devel@nongnu.org; Sun, 09 Dec 2018 14:38:38 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gW4uO-0006od-GL for qemu-devel@nongnu.org; Sun, 09 Dec 2018 14:38:37 -0500 Received: from wout2-smtp.messagingengine.com ([64.147.123.25]:47421) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gW4uO-0005tA-4H for qemu-devel@nongnu.org; Sun, 09 Dec 2018 14:38:32 -0500 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id DF860F91; Sun, 9 Dec 2018 14:38:08 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Sun, 09 Dec 2018 14:38:09 -0500 Received: from localhost (flamenco.cs.columbia.edu [128.59.20.216]) by mail.messagingengine.com (Postfix) with ESMTPA id 69EDF102F2; Sun, 9 Dec 2018 14:38:07 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=braap.org; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; s=mesmtp; bh=wMnBEeT1ZRH7Zdejn36LqPgj01GFciXucQo03CFJecg=; b=YlOs1yeYCtRm Es/ya0jiMPSzGb/8IvOhlF4n3ZqfrMh2DNLnXX/ATXv1RPUwNcm2k/vXOpPlJvjh 89T54vXgPP9cujWzc7t7QSbCcKkCRoNFJM2dl4dJagjFdR84UI1Lf9/fsHjOiqmY QN5wooVk0k+MndaokfnRinFJsfIAT98= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; bh=wMnBEeT1ZRH7Zdejn36LqPgj01GFciXucQo03CFJe cg=; b=y3ghjITMFl+8x0nSMrOWxL75/O3pUTdXdWaKQ8Cv+SsVoRDndldVW4hJq fTna1J7b/LMYZkYNW5f9AoQNMz3bv4Gixqj1MWvsapyAyYmXsu69VR08HXzsXc7T EA2hnLzm5UcTVoNdtoDVPUXfZPeyPVgIQHp8ZRkr6N/zpdw7ctWYu8Y4cOKDlvoI zaIYQ18hPxkfBOberFySMsR52PxpjO0X9cFYDIN9pivE+IpcXFNbGrkmvHPgJIvI qQ+fjfoTN3NeVAjVIBg2oInuvFMKZyqXJRMr29bWn35sWEKXxmucQYiWdNzFmGlm yeHqKa594wPfOjfpiLlbRNgNKNuug== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedtkedrudegfedguddvkecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfhuthenuceurghilhhouhhtmecu fedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvufffkf fojghfgggtgfesthekredtredtjeenucfhrhhomhepfdfgmhhilhhiohcuifdrucevohht rgdfuceotghothgrsegsrhgrrghprdhorhhgqeenucfkphepuddvkedrheelrddvtddrvd duieenucfrrghrrghmpehmrghilhhfrhhomheptghothgrsegsrhgrrghprdhorhhgnecu vehluhhsthgvrhfuihiivgepie X-ME-Proxy: From: "Emilio G. Cota" To: qemu-devel@nongnu.org Date: Sun, 9 Dec 2018 14:37:47 -0500 Message-Id: <20181209193749.12277-37-cota@braap.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181209193749.12277-1-cota@braap.org> References: <20181209193749.12277-1-cota@braap.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 64.147.123.25 Subject: [Qemu-devel] [RFC v2 36/38] vl: support -plugin option X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Richard Henderson , =?UTF-8?q?Alex=20Benn=C3=A9e?= , =?UTF-8?q?Llu=C3=ADs=20Vilanova?= , Pavel Dovgalyuk Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" From: Llu=C3=ADs Vilanova Signed-off-by: Llu=C3=ADs Vilanova [ cota: s/instrument/plugin ] Signed-off-by: Emilio G. Cota --- vl.c | 11 +++++++++++ qemu-options.hx | 17 +++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/vl.c b/vl.c index 1fcacc5caa..a1d6b76315 100644 --- a/vl.c +++ b/vl.c @@ -111,6 +111,7 @@ int main(int argc, char **argv) =20 #include "trace-root.h" #include "trace/control.h" +#include "qemu/plugin.h" #include "qemu/queue.h" #include "sysemu/arch_init.h" =20 @@ -2998,6 +2999,7 @@ int main(int argc, char **argv, char **envp) } BlockdevOptions_queue; QSIMPLEQ_HEAD(, BlockdevOptions_queue) bdo_queue =3D QSIMPLEQ_HEAD_INITIALIZER(bdo_queue); + struct qemu_plugin_list plugin_list =3D QTAILQ_HEAD_INITIALIZER(plugin= _list); =20 module_call_init(MODULE_INIT_TRACE); =20 @@ -3026,6 +3028,7 @@ int main(int argc, char **argv, char **envp) qemu_add_opts(&qemu_global_opts); qemu_add_opts(&qemu_mon_opts); qemu_add_opts(&qemu_trace_opts); + qemu_plugin_add_opts(); qemu_add_opts(&qemu_option_rom_opts); qemu_add_opts(&qemu_machine_opts); qemu_add_opts(&qemu_accel_opts); @@ -3840,6 +3843,9 @@ int main(int argc, char **argv, char **envp) g_free(trace_file); trace_file =3D trace_opt_parse(optarg); break; + case QEMU_OPTION_plugin: + qemu_plugin_opt_parse(optarg, &plugin_list); + break; case QEMU_OPTION_readconfig: { int ret =3D qemu_read_config_file(optarg); @@ -4137,6 +4143,11 @@ int main(int argc, char **argv, char **envp) machine_class->default_machine_opts, 0); } =20 + /* process plugin before CPUs are created, but once -smp has been pars= ed */ + if (qemu_plugin_load_list(&plugin_list)) { + exit(1); + } + qemu_opts_foreach(qemu_find_opts("device"), default_driver_check, NULL, NULL); qemu_opts_foreach(qemu_find_opts("global"), diff --git a/qemu-options.hx b/qemu-options.hx index 08f8516a9a..f3549eb2ec 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -3847,6 +3847,23 @@ HXCOMM HX does not support conditional compilation o= f text. @findex -trace @include qemu-option-trace.texi ETEXI +DEF("plugin", HAS_ARG, QEMU_OPTION_plugin, + "-plugin [file=3D][,arg=3D]\n" + " load a plugin\n", + QEMU_ARCH_ALL) +STEXI +@item -plugin file=3D@var{file}[,arg=3D@var{string}] +@findex -plugin + +Load a plugin. + +@table @option +@item file=3D@var{file} +Load the given plugin from a shared library file. +@item arg=3D@var{string} +Argument string passed to the plugin. (Can be given multiple times.) +@end table +ETEXI =20 HXCOMM Internal use DEF("qtest", HAS_ARG, QEMU_OPTION_qtest, "", QEMU_ARCH_ALL) --=20 2.17.1 From nobody Sat Apr 27 22:25:51 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1544385997341449.5908614330334; Sun, 9 Dec 2018 12:06:37 -0800 (PST) Received: from localhost ([::1]:56537 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gW5LY-0007Jx-4u for importer@patchew.org; Sun, 09 Dec 2018 15:06:36 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33659) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gW4uT-0001cd-AV for qemu-devel@nongnu.org; Sun, 09 Dec 2018 14:38:38 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gW4uO-0006oN-F3 for qemu-devel@nongnu.org; Sun, 09 Dec 2018 14:38:37 -0500 Received: from wout2-smtp.messagingengine.com ([64.147.123.25]:59453) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gW4uO-0005tH-28 for qemu-devel@nongnu.org; Sun, 09 Dec 2018 14:38:32 -0500 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id EEF82F92; Sun, 9 Dec 2018 14:38:08 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Sun, 09 Dec 2018 14:38:09 -0500 Received: from localhost (flamenco.cs.columbia.edu [128.59.20.216]) by mail.messagingengine.com (Postfix) with ESMTPA id A0DB4102EE; Sun, 9 Dec 2018 14:38:07 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=braap.org; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; s=mesmtp; bh=qC8jK/FW+vk6CAprNC8+Ijzz5780AnG+xwo2jaXxkLc=; b=16tqWE0+8ACr IDdzwk6jE3/DcYHy/b/wRNyYB7TiQHjqMYg9xQqq5drlcMrVc5a3lCCOmcKkVucP R3Rrbz1aVc9nrJYBu5c4Dklio9wlhsHW1WAfcTsXg+WnduMhSQRc7JumfiYtWSqs A9pnVp1E6iznn1HCv9xkcz6p3PImRoA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; bh=qC8jK/FW+vk6CAprNC8+Ijzz5780AnG+xwo2jaXxk Lc=; b=uvypyiDkwdwGnJ4gjFkdbpWjwjSAtnzKH6KQCKHgLJuR0zhezT+Un6r5z 7BQreO7gjpRncmjFT7vSl5N35GMTD1ZBKsu5XgCfCYmopkbPN3rRoG3qaHMda6ME 4axhWrnJA5V0fFU+QmVE4YRKItlMdE2RTmmhND0gm4Wiy3+eKILnX1hKhtpG3+Ks v0ftbxw7o9An1lFV29i8G3WZLhujUg2mzUnxhwuyHx2Z+r9opkoORIsmXMFHcL2T bOQecotlgCsHjfF20yn3lXRxLHGt3z95fV7bHNk8JjvfHks2RSSe+QKpdCEX5w5b j3ms2bPJtHTG91WduykdLCtYd5+EA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedtkedrudegfedguddvkecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfhuthenuceurghilhhouhhtmecu fedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvufffkf fojghfgggtgfesthekredtredtjeenucfhrhhomhepfdfgmhhilhhiohcuifdrucevohht rgdfuceotghothgrsegsrhgrrghprdhorhhgqeenucfkphepuddvkedrheelrddvtddrvd duieenucfrrghrrghmpehmrghilhhfrhhomheptghothgrsegsrhgrrghprdhorhhgnecu vehluhhsthgvrhfuihiivgepie X-ME-Proxy: From: "Emilio G. Cota" To: qemu-devel@nongnu.org Date: Sun, 9 Dec 2018 14:37:48 -0500 Message-Id: <20181209193749.12277-38-cota@braap.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181209193749.12277-1-cota@braap.org> References: <20181209193749.12277-1-cota@braap.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 64.147.123.25 Subject: [Qemu-devel] [RFC v2 37/38] linux-user: support -plugin option X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Richard Henderson , =?UTF-8?q?Alex=20Benn=C3=A9e?= , =?UTF-8?q?Llu=C3=ADs=20Vilanova?= , Pavel Dovgalyuk Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" From: Llu=C3=ADs Vilanova Signed-off-by: Llu=C3=ADs Vilanova [ cota: s/instrument/plugin ] Signed-off-by: Emilio G. Cota --- linux-user/main.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/linux-user/main.c b/linux-user/main.c index 923cbb753a..482766f0f4 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -28,6 +28,7 @@ #include "qemu/config-file.h" #include "qemu/cutils.h" #include "qemu/help_option.h" +#include "qemu/plugin.h" #include "cpu.h" #include "exec/exec-all.h" #include "tcg.h" @@ -385,6 +386,15 @@ static void handle_arg_trace(const char *arg) trace_file =3D trace_opt_parse(arg); } =20 +static struct qemu_plugin_list plugins =3D QTAILQ_HEAD_INITIALIZER(plugins= ); + +#ifdef CONFIG_PLUGIN +static void handle_arg_plugin(const char *arg) +{ + qemu_plugin_opt_parse(arg, &plugins); +} +#endif + struct qemu_argument { const char *argv; const char *env; @@ -436,6 +446,10 @@ static const struct qemu_argument arg_table[] =3D { "", "Seed for pseudo-random number generator"}, {"trace", "QEMU_TRACE", true, handle_arg_trace, "", "[[enable=3D]][,events=3D][,file=3D]"}, +#ifdef CONFIG_PLUGIN + {"plugin", "QEMU_PLUGIN", true, handle_arg_plugin, + "", "[file=3D][,arg=3D]"}, +#endif {"version", "QEMU_VERSION", false, handle_arg_version, "", "display version information and exit"}, {NULL, NULL, false, NULL, NULL, NULL} @@ -627,6 +641,7 @@ int main(int argc, char **argv, char **envp) srand(time(NULL)); =20 qemu_add_opts(&qemu_trace_opts); + qemu_plugin_add_opts(); =20 optind =3D parse_args(argc, argv); =20 @@ -634,6 +649,9 @@ int main(int argc, char **argv, char **envp) exit(1); } trace_init_file(trace_file); + if (qemu_plugin_load_list(&plugins)) { + exit(1); + } =20 /* Zero out regs */ memset(regs, 0, sizeof(struct target_pt_regs)); --=20 2.17.1 From nobody Sat Apr 27 22:25:51 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1544386524453297.163681442644; Sun, 9 Dec 2018 12:15:24 -0800 (PST) Received: from localhost ([::1]:56579 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gW5Tv-0000rO-LQ for importer@patchew.org; Sun, 09 Dec 2018 15:15:15 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33685) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gW4uU-0001cg-6b for qemu-devel@nongnu.org; Sun, 09 Dec 2018 14:38:39 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gW4uO-0006p5-I6 for qemu-devel@nongnu.org; Sun, 09 Dec 2018 14:38:38 -0500 Received: from wout2-smtp.messagingengine.com ([64.147.123.25]:46179) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gW4uO-0005t2-6v for qemu-devel@nongnu.org; Sun, 09 Dec 2018 14:38:32 -0500 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id A036CF8F; Sun, 9 Dec 2018 14:38:08 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Sun, 09 Dec 2018 14:38:09 -0500 Received: from localhost (flamenco.cs.columbia.edu [128.59.20.216]) by mail.messagingengine.com (Postfix) with ESMTPA id CAF72102F1; Sun, 9 Dec 2018 14:38:07 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=braap.org; h= from:to:cc:subject:date:message-id:in-reply-to:references; s= mesmtp; bh=ggtUTcVUWJ0cPFXDe63wY/0eOb6vPSGGbEnS0ni5rD8=; b=YKzzZ rVVXMFtc5c0muSXQ7p+OFSRdz6HU+3+cAn3BRLY+4aOlFphabCrn0n7HxshXRTKY bJ+xORo/a9xckY3ka6/EmaTtjTF/uBGFKHFvW9aWP5m1RUNmX/pf6U//tRMwrNze 9MP5xG1BijMZEzmR9jUEuaC6JjUOgAY+aCVIIQ= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:date:from:in-reply-to:message-id :references:subject:to:x-me-proxy:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; bh=ggtUTcVUWJ0cPFXDe63wY/0eOb6vP SGGbEnS0ni5rD8=; b=BNmM+WQxeGnT1b0eO1PW0f53ju3mG9ngAtwXnrC++jp0h XXoD20FuSHdWsMadJZoWdsbL4PheWJJOBcovgtOEdxVrlGzpICAXdXYGvpUStgyD uwmTPPy+tX/+nTBP7g3+0pe4Ibx0GpqQCf3CNx8MV+8r5n4+uLC3FEi3TDUSOOUD 6mlIiH1a1PwAktj8bxYso/ocmEiLWf88NZ831024T/npezQ5vprlZ2sA/V4mWk+Y Guerc0Kvq5DZdGOn1owKNhcanaz0qLDCfFhgs4DUREGLJkpu3WXxOOzrSpcR3N9M UydTQrCM+mOb7pg2FQHuWFYXwax0Rv6hOrjAFnilw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedtkedrudegfedguddvkecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfhuthenuceurghilhhouhhtmecu fedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvufffkf fojghfsedttdertdertddtnecuhfhrohhmpedfgfhmihhlihhoucfirdcuvehothgrfdcu oegtohhtrgessghrrggrphdrohhrgheqnecukfhppeduvdekrdehledrvddtrddvudeine curfgrrhgrmhepmhgrihhlfhhrohhmpegtohhtrgessghrrggrphdrohhrghenucevlhhu shhtvghrufhiiigvpeej X-ME-Proxy: From: "Emilio G. Cota" To: qemu-devel@nongnu.org Date: Sun, 9 Dec 2018 14:37:49 -0500 Message-Id: <20181209193749.12277-39-cota@braap.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181209193749.12277-1-cota@braap.org> References: <20181209193749.12277-1-cota@braap.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 64.147.123.25 Subject: [Qemu-devel] [RFC v2 38/38] tests/plugin: add sample plugins X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Richard Henderson , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Pavel Dovgalyuk Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Pass arguments with -plugin=3Dlibfoo.so,arg=3Dbar,arg=3Dbaz Signed-off-by: Emilio G. Cota --- configure | 4 +- tests/plugin/bb.c | 66 ++++++++++++++++++++++++++++++ tests/plugin/empty.c | 30 ++++++++++++++ tests/plugin/insn.c | 63 +++++++++++++++++++++++++++++ tests/plugin/mem.c | 93 +++++++++++++++++++++++++++++++++++++++++++ tests/plugin/Makefile | 28 +++++++++++++ 6 files changed, 282 insertions(+), 2 deletions(-) create mode 100644 tests/plugin/bb.c create mode 100644 tests/plugin/empty.c create mode 100644 tests/plugin/insn.c create mode 100644 tests/plugin/mem.c create mode 100644 tests/plugin/Makefile diff --git a/configure b/configure index 91f9c08ae2..1440b5e688 100755 --- a/configure +++ b/configure @@ -7450,14 +7450,14 @@ fi =20 # build tree in object directory in case the source is not in the current = directory DIRS=3D"tests tests/tcg tests/tcg/cris tests/tcg/lm32 tests/libqos tests/q= api-schema tests/tcg/xtensa tests/qemu-iotests tests/vm" -DIRS=3D"$DIRS tests/fp" +DIRS=3D"$DIRS tests/fp tests/plugin" DIRS=3D"$DIRS docs docs/interop fsdev scsi" DIRS=3D"$DIRS pc-bios/optionrom pc-bios/spapr-rtas pc-bios/s390-ccw" DIRS=3D"$DIRS roms/seabios roms/vgabios" FILES=3D"Makefile tests/tcg/Makefile qdict-test-data.txt" FILES=3D"$FILES tests/tcg/cris/Makefile tests/tcg/cris/.gdbinit" FILES=3D"$FILES tests/tcg/lm32/Makefile tests/tcg/xtensa/Makefile po/Makef= ile" -FILES=3D"$FILES tests/fp/Makefile" +FILES=3D"$FILES tests/fp/Makefile tests/plugin/Makefile" FILES=3D"$FILES pc-bios/optionrom/Makefile pc-bios/keymaps" FILES=3D"$FILES pc-bios/spapr-rtas/Makefile" FILES=3D"$FILES pc-bios/s390-ccw/Makefile" diff --git a/tests/plugin/bb.c b/tests/plugin/bb.c new file mode 100644 index 0000000000..bb868599a9 --- /dev/null +++ b/tests/plugin/bb.c @@ -0,0 +1,66 @@ +/* + * Copyright (C) 2018, Emilio G. Cota + * + * License: GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ +#include +#include +#include +#include +#include +#include + +#include + +static uint64_t bb_count; +static uint64_t insn_count; +static int stdout_fd; +static bool do_inline; + +static void plugin_exit(qemu_plugin_id_t id, void *p) +{ + dprintf(stdout_fd, "bb's: %" PRIu64", insns: %" PRIu64 "\n", + bb_count, insn_count); +} + +static void vcpu_tb_exec(unsigned int cpu_index, void *udata) +{ + unsigned long n_insns =3D (unsigned long)udata; + + insn_count +=3D n_insns; + bb_count++; +} + +static void vcpu_tb_trans(qemu_plugin_id_t id, unsigned int cpu_index, + struct qemu_plugin_tb *tb) +{ + unsigned long n_insns =3D qemu_plugin_tb_n_insns(tb); + + if (do_inline) { + qemu_plugin_register_vcpu_tb_exec_inline(tb, QEMU_PLUGIN_INLINE_AD= D_U64, + &bb_count, 1); + qemu_plugin_register_vcpu_tb_exec_inline(tb, QEMU_PLUGIN_INLINE_AD= D_U64, + &insn_count, n_insns); + } else { + qemu_plugin_register_vcpu_tb_exec_cb(tb, vcpu_tb_exec, + QEMU_PLUGIN_CB_NO_REGS, + (void *)n_insns); + } +} + +QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_id_t id, int argc, + char **argv) +{ + if (argc && strcmp(argv[0], "inline") =3D=3D 0) { + do_inline =3D true; + } + + /* to be used when in the exit hook */ + stdout_fd =3D dup(STDOUT_FILENO); + assert(stdout_fd); + + 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/empty.c b/tests/plugin/empty.c new file mode 100644 index 0000000000..b2e30bddb2 --- /dev/null +++ b/tests/plugin/empty.c @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2018, Emilio G. Cota + * + * License: GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ +#include +#include +#include +#include +#include +#include + +#include + +/* + * Empty TB translation callback. + * This allows us to measure the overhead of injecting and then + * removing empty instrumentation. + */ +static void vcpu_tb_trans(qemu_plugin_id_t id, unsigned int cpu_index, + struct qemu_plugin_tb *tb) +{ } + +QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_id_t id, int argc, + char **argv) +{ + qemu_plugin_register_vcpu_tb_trans_cb(id, vcpu_tb_trans); + return 0; +} diff --git a/tests/plugin/insn.c b/tests/plugin/insn.c new file mode 100644 index 0000000000..11afe0e8f1 --- /dev/null +++ b/tests/plugin/insn.c @@ -0,0 +1,63 @@ +/* + * Copyright (C) 2018, Emilio G. Cota + * + * License: GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ +#include +#include +#include +#include +#include +#include + +#include + +static int stdout_fd; +static uint64_t insn_count; +static bool do_inline; + +static void vcpu_insn_exec_before(unsigned int cpu_index, void *udata) +{ + insn_count++; +} + +static void vcpu_tb_trans(qemu_plugin_id_t id, unsigned int cpu_index, + struct qemu_plugin_tb *tb) +{ + size_t n =3D qemu_plugin_tb_n_insns(tb); + size_t i; + + for (i =3D 0; i < n; i++) { + struct qemu_plugin_insn *insn =3D qemu_plugin_tb_get_insn(tb, i); + + if (do_inline) { + qemu_plugin_register_vcpu_insn_exec_inline( + insn, QEMU_PLUGIN_INLINE_ADD_U64, &insn_count, 1); + } else { + qemu_plugin_register_vcpu_insn_exec_cb( + insn, vcpu_insn_exec_before, QEMU_PLUGIN_CB_NO_REGS, NULL); + } + } +} + +static void plugin_exit(qemu_plugin_id_t id, void *p) +{ + dprintf(stdout_fd, "insns: %" PRIu64 "\n", insn_count); +} + +QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_id_t id, int argc, + char **argv) +{ + if (argc && !strcmp(argv[0], "inline")) { + do_inline =3D true; + } + + /* to be used when in the exit hook */ + stdout_fd =3D dup(STDOUT_FILENO); + assert(stdout_fd); + + 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/mem.c b/tests/plugin/mem.c new file mode 100644 index 0000000000..c13c672c91 --- /dev/null +++ b/tests/plugin/mem.c @@ -0,0 +1,93 @@ +/* + * Copyright (C) 2018, Emilio G. Cota + * + * License: GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ +#include +#include +#include +#include +#include +#include + +#include + +static uint64_t mem_count; +static int stdout_fd; +static bool do_inline; +static bool do_haddr; +static enum qemu_plugin_mem_rw rw =3D QEMU_PLUGIN_MEM_RW; + +static void plugin_exit(qemu_plugin_id_t id, void *p) +{ + dprintf(stdout_fd, "accesses: %" PRIu64 "\n", mem_count); +} + +static void vcpu_mem(unsigned int cpu_index, qemu_plugin_meminfo_t meminfo, + uint64_t vaddr, void *udata) +{ + mem_count++; +} + +static void vcpu_haddr(unsigned int cpu_index, qemu_plugin_meminfo_t memin= fo, + uint64_t vaddr, void *haddr, void *udata) +{ + mem_count++; +} + +static void vcpu_tb_trans(qemu_plugin_id_t id, unsigned int cpu_index, + struct qemu_plugin_tb *tb) +{ + size_t n =3D qemu_plugin_tb_n_insns(tb); + size_t i; + + for (i =3D 0; i < n; i++) { + struct qemu_plugin_insn *insn =3D qemu_plugin_tb_get_insn(tb, i); + + if (do_inline) { + qemu_plugin_register_vcpu_mem_inline(insn, rw, + QEMU_PLUGIN_INLINE_ADD_U6= 4, + &mem_count, 1); + } else if (do_haddr) { + qemu_plugin_register_vcpu_mem_haddr_cb(insn, vcpu_haddr, + QEMU_PLUGIN_CB_NO_REGS, + rw, NULL); + } else { + qemu_plugin_register_vcpu_mem_cb(insn, vcpu_mem, + QEMU_PLUGIN_CB_NO_REGS, + rw, NULL); + } + } +} + +QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_id_t id, int argc, + char **argv) +{ + if (argc) { + if (argc >=3D 3) { + if (!strcmp(argv[2], "haddr")) { + do_haddr =3D true; + } + } + if (argc >=3D 2) { + const char *str =3D argv[1]; + + if (!strcmp(str, "r")) { + rw =3D QEMU_PLUGIN_MEM_R; + } else if (!strcmp(str, "w")) { + rw =3D QEMU_PLUGIN_MEM_W; + } + } + if (!strcmp(argv[0], "inline")) { + do_inline =3D true; + } + } + /* plugin_exit might write to stdout after stdout has been closed */ + stdout_fd =3D dup(STDOUT_FILENO); + assert(stdout_fd); + + 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/Makefile b/tests/plugin/Makefile new file mode 100644 index 0000000000..f9a3546ea3 --- /dev/null +++ b/tests/plugin/Makefile @@ -0,0 +1,28 @@ +BUILD_DIR :=3D $(CURDIR)/../.. + +include $(BUILD_DIR)/config-host.mak +include $(SRC_PATH)/rules.mak + +$(call set-vpath, $(SRC_PATH)/tests/plugin) + +NAMES :=3D +NAMES +=3D bb +NAMES +=3D empty +NAMES +=3D insn +NAMES +=3D mem + +SONAMES :=3D $(addsuffix .so,$(addprefix lib,$(NAMES))) + +QEMU_CFLAGS +=3D -fPIC +QEMU_CFLAGS +=3D -I$(SRC_PATH)/include/qemu + +all: $(SONAMES) + +lib%.so: %.o + $(CC) -shared -Wl,-soname,$@ -o $@ $^ $(LDLIBS) + +clean: + rm -f *.o *.so *.d + rm -Rf .libs + +.PHONY: all clean --=20 2.17.1 From nobody Sat Apr 27 22:25:51 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1558120396; cv=none; d=zoho.com; s=zohoarc; b=n0aGsJFW8yWeL9xeXkK/2zLR/U3GfhMEjFYdJ5BGRRDnQbZyY+GmkhdCZbbVRYzAA7+KizeFbrjwl7l/X2XfL3tNsJHJVAWrh7C6K5BFrUNaAFFmfORiALBpjtM8+UES60brxJKZtsziN77N5fpXNd+0/A94+K56YDcg0iaWst0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1558120396; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=UR0Nl8W0wGoR68IUXHoYPpMH947NuEaUQ987FFuQHgQ=; b=evxsh1QD+rOU0OVgfw62FLFygBb/1rCbyG03dzPNfI8mulYFKIjHlLk2BJHFjMKy4hOFPwrEnPdXV7NTf5nnJf4BxDGxOg5LWci4lc99VRc5RrRh80DBa8IMUvH6QAJR0gmms+27Da5rLZx85hSb/ZBeHZNIOMw5Vv/q+Sy/WBQ= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1558120396697337.57798755416627; Fri, 17 May 2019 12:13:16 -0700 (PDT) Received: from localhost ([127.0.0.1]:52715 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hRiHw-00039p-6s for importer@patchew.org; Fri, 17 May 2019 15:13:04 -0400 Received: from eggs.gnu.org ([209.51.188.92]:37308) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hRiGt-0002hZ-ER for qemu-devel@nongnu.org; Fri, 17 May 2019 15:12:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hRiGr-0003TY-Rw for qemu-devel@nongnu.org; Fri, 17 May 2019 15:11:59 -0400 Received: from mail-wm1-x343.google.com ([2a00:1450:4864:20::343]:56170) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hRiGr-00037X-Kx for qemu-devel@nongnu.org; Fri, 17 May 2019 15:11:57 -0400 Received: by mail-wm1-x343.google.com with SMTP id x64so7885546wmb.5 for ; Fri, 17 May 2019 12:11:38 -0700 (PDT) Received: from zen.linaroharston ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id b12sm11358023wmg.27.2019.05.17.12.11.36 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 17 May 2019 12:11:36 -0700 (PDT) Received: from zen.linaroharston. (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id DF8EB1FF87; Fri, 17 May 2019 20:11:35 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=UR0Nl8W0wGoR68IUXHoYPpMH947NuEaUQ987FFuQHgQ=; b=eBG1BmBQ1eQJFu8uk2BZBQTbtpsioduBsI91troFOlN3LsspM11K2ZMnheI8wK3BQi 3PsUgPMKWtsr6F73c3TddXNTmLtd4sbviGwteI1FrcgQPujoFHAMQILddPPm00jxLMeR zM+UwgJmPCFDUl7QCo3OnE4yVDo+qvkI3BZC6ywbrgV+0SCXdy0uUzHxONMvhuVba12W fE2nnHY+ccrmXc3urEqU/bEPeWwSAZ6szJn+JBktaTGoAdxZSAhZrxkvR87RTXBM8LFs hH+m3tftM02+EvLvn93AETv4OvGNceJHgmXrVG9Lk3002wBYRbcGwPMBhDhadxYnm85c BozQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=UR0Nl8W0wGoR68IUXHoYPpMH947NuEaUQ987FFuQHgQ=; b=QQUw2jGJotjSuLPYX/yP+HYIb11pcu93lig/ki7oCKfDnPXLERqmfDYIqHqZ9GcLVr lKQFV6+RUGHa4CA0W+YwsgSjSHPv5hwX3vLrbzx4QKzsvlFuYpxw3u80oecrow0nu+Bt T3mXM7o+WdN3JNGLvz3wnYv8jOE45WL+RgutQr3b745QyZnFnP2WtZHADW3H4GZX6sRH Hvqb0iG7/lkq24pTaesmMEDL7ViYSgf9cAsKkzFXseXsb0k0us9bMJ/9ctlaXGXLj+Vk eUMTPc4yHtqpj8hb6GvJVc/r2DeKqV0LWdN2R+T7/4NMg4g5Q7tvYYHGRcx43uPnUOvX p7ng== X-Gm-Message-State: APjAAAWw7D1GVwNzPe86c3w17Mbj/NdUPwvj+QzOeD44oRQvpH86b7vO VzkihwEcyNhf8ZB0xZ3jSrWzwQ== X-Google-Smtp-Source: APXvYqzhl2gT1R4mkVFoK8VU5qobMZ2TSL3UsV8WqMTby7Im0IOYqwym7zBaREmwhzRhgMTnrVX55g== X-Received: by 2002:a1c:f606:: with SMTP id w6mr3491982wmc.130.1558120296938; Fri, 17 May 2019 12:11:36 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: cota@braap.org Date: Fri, 17 May 2019 20:11:20 +0100 Message-Id: <20190517191120.765-1-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20181209193749.12277-1-cota@braap.org> References: <20181209193749.12277-1-cota@braap.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::343 Subject: [Qemu-devel] [RFC PATCH] tests/tcg: enable plugin testing X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , qemu-devel@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , "open list:ARM" , bobby.prani@gmail.com, =?UTF-8?q?Alex=20Benn=C3=A9e?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) If CONFIG_PLUGINS is enabled then lets enable testing for all our TCG targets. This is a simple smoke test that ensure we don't crash or otherwise barf out by running each plugin against each test. There is a minor knock on effect for additional runners which need specialised QEMU_OPTS which will also need to declare a plugin version of the runner. If this gets onerous we might need to add another helper. Checking the results of the plugins is left for a later exercise. Signed-off-by: Alex Benn=C3=A9e --- tests/Makefile.include | 10 +++++++- tests/tcg/Makefile | 34 +++++++++++++++++++++++++++ tests/tcg/arm/Makefile.softmmu-target | 1 + 3 files changed, 44 insertions(+), 1 deletion(-) diff --git a/tests/Makefile.include b/tests/Makefile.include index 792f685ac11..91d254cdca5 100644 --- a/tests/Makefile.include +++ b/tests/Makefile.include @@ -1037,6 +1037,14 @@ check-softfloat: "SKIPPED for non-TCG builds") endif =20 +# Plugins +ifeq ($(CONFIG_PLUGIN),y) +plugins: + $(call quiet-command,\ + $(MAKE) $(SUBDIR_MAKEFLAGS) -C tests/plugin V=3D"$(V)", \ + "BUILD", "plugins") +endif + # Per guest TCG tests =20 BUILD_TCG_TARGET_RULES=3D$(patsubst %,build-tcg-tests-%, $(TARGET_DIRS)) @@ -1051,7 +1059,7 @@ $(foreach PROBE_TARGET,$(TARGET_DIRS), \ $(eval build-tcg-tests-$(PROBE_TARGET): $(DOCKER_PREREQ)))) endif =20 -build-tcg-tests-%: +build-tcg-tests-%: $(if $(CONFIG_PLUGIN),plugins) $(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) -C $* V=3D"$(V)" \ SKIP_DOCKER_BUILD=3D1 TARGET_DIR=3D"$*/" guest-tests, \ "BUILD", "TCG tests for $*") diff --git a/tests/tcg/Makefile b/tests/tcg/Makefile index 6fa63cc8d53..9474ab29003 100644 --- a/tests/tcg/Makefile +++ b/tests/tcg/Makefile @@ -116,11 +116,37 @@ all: $(TESTS) # =20 RUN_TESTS=3D$(patsubst %,run-%, $(TESTS)) + +# If plugins exist also include those in the tests +ifeq ($(CONFIG_PLUGIN),y) +PLUGIN_DIR=3D../../tests/plugin +VPATH+=3D$(PLUGIN_DIR) +PLUGINS=3D$(notdir $(wildcard $(PLUGIN_DIR)/*.so)) + +# We need to ensure expand the run-plugin-TEST-with-PLUGIN +# pre-requistes manually here as we can't use stems to handle it. We +# also add some special helpers the run-plugin- rules can use bellow. + +$(foreach p,$(PLUGINS), \ + $(foreach t,$(TESTS),\ + $(eval run-plugin-$(t)-with-$(p): $t $p) \ + $(eval RUN_TESTS+=3Drun-plugin-$(t)-with-$(p)))) +endif + +strip-plugin =3D $(wordlist 1, 1, $(subst -with-, ,$1)) +extract-plugin =3D $(wordlist 2, 2, $(subst -with-, ,$1)) + RUN_TESTS+=3D$(EXTRA_RUNS) =20 ifdef CONFIG_USER_ONLY run-%: % $(call run-test, $<, $(QEMU) $(QEMU_OPTS) $<, "$< on $(TARGET_NAME)") + +run-plugin-%: + $(call run-test, $@, $(QEMU) $(QEMU_OPTS) \ + -plugin $(PLUGIN_DIR)/$(call extract-plugin,$@) \ + $(call strip-plugin,$<), \ + "$< on $(TARGET_NAME)") else run-%: % $(call run-test, $<, \ @@ -128,6 +154,14 @@ run-%: % -chardev file$(COMMA)path=3D$<.out$(COMMA)id=3Doutput \ $(QEMU_OPTS) $<, \ "$< on $(TARGET_NAME)") + +run-plugin-%: + $(call run-test, $@, \ + $(QEMU) -monitor none -display none \ + -chardev file$(COMMA)path=3D$@.out$(COMMA)id=3Doutput \ + -plugin $(PLUGIN_DIR)/$(call extract-plugin,$@) \ + $(QEMU_OPTS) $(call strip-plugin,$<), \ + "$< on $(TARGET_NAME)") endif =20 gdb-%: % diff --git a/tests/tcg/arm/Makefile.softmmu-target b/tests/tcg/arm/Makefile= .softmmu-target index 49d48d8a1c3..cd628306b3e 100644 --- a/tests/tcg/arm/Makefile.softmmu-target +++ b/tests/tcg/arm/Makefile.softmmu-target @@ -25,5 +25,6 @@ LDFLAGS+=3D-nostdlib -N -static test-armv6m-undef: EXTRA_CFLAGS+=3D-mcpu=3Dcortex-m0 =20 run-test-armv6m-undef: QEMU_OPTS+=3D-semihosting -M microbit -kernel +run-plugin-test-armv6m-undef-%: QEMU_OPTS+=3D-semihosting -M microbit -ker= nel =20 endif --=20 2.20.1