From patchwork Sat Mar 16 01:57:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 780754 Delivered-To: patch@linaro.org Received: by 2002:a5d:46c1:0:b0:33e:7753:30bd with SMTP id g1csp489587wrs; Fri, 15 Mar 2024 18:59:51 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXY79V2BA0bGcaTzPl0BddtKSu9pOHo6h34nlCDAkrzdbN8iZsKsd6XZ43Ks8mn+f7j5pwr9VOVWM6scpjyliyo X-Google-Smtp-Source: AGHT+IFepKOQCMcr2zs2xcHxlB9epcnD+JmyKJmdec/K+Yx81vipVMJGsa/LsrxaIXakkLfRordR X-Received: by 2002:a0c:cd83:0:b0:692:494f:f0aa with SMTP id v3-20020a0ccd83000000b00692494ff0aamr16201qvm.9.1710554391320; Fri, 15 Mar 2024 18:59:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1710554391; cv=none; d=google.com; s=arc-20160816; b=a71Z8Js7LNq2erKLxM24TL8wqZAUAb4rxL63Cfy76oxv0fP84jsHYXx0Qdn9pA/5Ub K7o7/jnSHYjoSA3yV2vMFMX2YMH2h2mLtOGrWrXj/t+FW/AMzt98dNVz6zd/mNfh2uj2 SG/WR1Q521SHJlI/cxIH9Mr//CaX8EG1yYGzw+knFFDyaVfZQrL29w+ahKFUEkXZ10bE /QomBRPvaaZ8nq3PkBzN39yf+4UJ0SQeDWlwCGKi4ZW1fMIFDwjeNAf6dxmB2M02NDsk qkph4//NAsEjOblI5aPJ2OGf0BFpajYnSn4M3TIo+tqnGk9jAAXvTuuhrLeNoPLeAFv4 kofg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=P54sXZhacQ5iITFNcA4P+H/BERfNZULzKjLOWe/9z8w=; fh=DfUxOGz7MnM49MBgqH5VPROGi+97fYtPWhcEZCG1Y5Q=; b=rs24ekyj5dTZZxxM/Ng5z5h3Q6oQHgqHc0Xxs2avErz7l4sRt1igPgS637sZ6Ysufs PVMvY7GQaU+oBpfBGtZMAH7pTNQRW9Dm4CfbbQtNmFXmvbMDt9nxI7sCvaOFMbNI13P+ Lx/QBg2oUOZgJhkecCUWHnWaobw8edYGKT6cdEkmlUXrXYL6WrnW3CfxUa1ajs1g07B2 +YdbmR52btk6QOLOZLUYli/0ZDr5IIPoGZx+oCQp+szpLSZW/Xq6uxiThXmqWp1bxbiA prWL/3wHaGTniqZesz+Cnv2kEXzFGi+Ae5p7WjqHLk/qzx+v32J9enZAxJcy0CY5W7SC GkqA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=RCce+Mbg; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id t13-20020ad45bcd000000b00691664f4112si3497477qvt.428.2024.03.15.18.59.51 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 15 Mar 2024 18:59:51 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=RCce+Mbg; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rlJJR-00032q-PI; Fri, 15 Mar 2024 21:58:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rlJJL-00030B-UZ for qemu-devel@nongnu.org; Fri, 15 Mar 2024 21:58:12 -0400 Received: from mail-pl1-x633.google.com ([2607:f8b0:4864:20::633]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rlJJJ-0000pN-WD for qemu-devel@nongnu.org; Fri, 15 Mar 2024 21:58:11 -0400 Received: by mail-pl1-x633.google.com with SMTP id d9443c01a7336-1def89f0cfdso6711005ad.0 for ; Fri, 15 Mar 2024 18:58:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1710554289; x=1711159089; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=P54sXZhacQ5iITFNcA4P+H/BERfNZULzKjLOWe/9z8w=; b=RCce+MbghlQfnsVYXuGL3nKKrJKYMvSa728dbFR4Maq/W4NYQ2qpuXt4HqN2+9bzSt 64id1jF3wBOvVFjvvCqq5KE28vsNE7YiRV5rMLQDLE+sFnakirO4RHg7GDrrhIcDz4uf o4+2wc5dI/Ob89EajtoivkGB6dBKpz3rMKglThbbhe8rbnxJ58nT/aNJRgdvyCy/73fS PrwAO7llhrBs/CwNugW/5OY9b+9EsrW0xerXYUJNmgghSD4x3sXPsXCPEC+D+xcLIuZw /LCdtjdJuxNoTsYdEDm3R74Z5X0kLJK0XJs0seAn8bPB9aMRJpqh4BWkGP3cMG94T16A RmEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710554289; x=1711159089; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=P54sXZhacQ5iITFNcA4P+H/BERfNZULzKjLOWe/9z8w=; b=VBp76OrTpVOlN9WBxT/DyBE+iEfKpa8+LaMMLxV3zgEe69XhypE0ZYYvD+DL1Afffe +yGobCpwDmDF8fTyJtzQ9gXyKmzzo2uiP7A3okTPIQBeU/xLua7aDNDCbgpglGHucYWJ Y/7fSRI/9HYNTvgajYwSEoOxaAIFL5DYTO7pp7dO5MTI+1KzwnrksYktdriwBQTkOjbe VXaiLWw79o+DHRMr5i0v1DfYJXvIrDt+jjhIiUix/DyzulZT0F8d9SrkhJiONij8d53b gEFi+Qz5kIZbXYHx6Z4Hw2RoYpgwIPqjGPO2RyuQWeKRrN1N3Q6igcaH8yJ/seQNS16s Aeww== X-Gm-Message-State: AOJu0YzaaBsXse/82EVklP/zG8ppeEm5E4DPt1mXep/eEZhwuswcOABu FM7FFRUAuc/pzVwZurknqZSeHrBykMpV+66XWuuV0jEA7enDPzALdEi49ETUrTd10Kg2yjWIo8M y X-Received: by 2002:a17:902:f68b:b0:1db:cf64:7331 with SMTP id l11-20020a170902f68b00b001dbcf647331mr14824464plg.13.1710554288764; Fri, 15 Mar 2024 18:58:08 -0700 (PDT) Received: from stoup.. (173-197-098-125.biz.spectrum.com. [173.197.98.125]) by smtp.gmail.com with ESMTPSA id b3-20020a170903228300b001dd42bbb08asm4592985plh.253.2024.03.15.18.58.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Mar 2024 18:58:07 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: pierrick.bouvier@linaro.org, alex.bennee@linaro.org Subject: [PATCH 22/22] plugins: Update the documentation block for plugin-gen.c Date: Fri, 15 Mar 2024 15:57:20 -1000 Message-Id: <20240316015720.3661236-23-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240316015720.3661236-1-richard.henderson@linaro.org> References: <20240316015720.3661236-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::633; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x633.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier --- accel/tcg/plugin-gen.c | 31 ++++--------------------------- 1 file changed, 4 insertions(+), 27 deletions(-) diff --git a/accel/tcg/plugin-gen.c b/accel/tcg/plugin-gen.c index fd52ea3987..c354825779 100644 --- a/accel/tcg/plugin-gen.c +++ b/accel/tcg/plugin-gen.c @@ -14,33 +14,10 @@ * 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 twice. - * Instead, during TB translation we add "empty" instrumentation calls for all - * possible instrumentation events, and then once we collect the instrumentation - * 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 copies - * of the TCG ops generated for the empty callback, substituting the function - * pointer that points to the empty helper function with the plugins' desired - * callback functions. After that we remove the empty callback's ops. - * - * Note that the location in TCGOp.args[] of the pointer to a helper function - * varies across different guest and host architectures. Instead of duplicating - * 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 program. - * 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 callback'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, for the - * second and all subsequent callbacks of an event, we do not need to reload the - * CPU's index into a TCG temp, since the first callback did it already. + * Instead, during TB translation we add "plugin_cb" marker opcodes + * for all possible instrumentation events, and then once we collect the + * instrumentation requests from plugins, we generate code for those markers + * or remove them if they have no requests. */ #include "qemu/osdep.h" #include "qemu/plugin.h"