From patchwork Thu Apr 4 23:05:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 785848 Delivered-To: patch@linaro.org Received: by 2002:adf:f001:0:b0:33e:7753:30bd with SMTP id j1csp1074119wro; Thu, 4 Apr 2024 16:07:55 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVnuGOmxhI48fiwWE9umk2WH0qhuSlZtpmKqfClS2TXiRBgpqjNaCCYSTPpxQRxpD9szqlndd9erCqzTX0ZuFET X-Google-Smtp-Source: AGHT+IHzsYR9G4nGlNzbgk9U0uKS7Li8NlSG8pDHHUMdxnTKLcH1Ud798tWKbZF2BFbRpCPcAEuw X-Received: by 2002:a05:6214:401:b0:699:2c8e:afd9 with SMTP id z1-20020a056214040100b006992c8eafd9mr4612377qvx.4.1712272074643; Thu, 04 Apr 2024 16:07:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712272074; cv=none; d=google.com; s=arc-20160816; b=O2rI7vhwi9Uee/liHEnmg+3U79boKy/pTpemhkel4e3R2Blty+7GthE/Xl860ssPUW OFpLwwMdbmKK1PhS7CVDNQCEu5qYhPQr1AfmEongZqax3chIL/+RFFwonMr1xBKiIXq0 r7K1q52NC7cs6TnKTh0CrhSTocyB9JVXenflSTiy5YfPgZxAfFOX0D6AYHJb0xJ2ltBY Usan3ODS19TKDbcEdtuOZdzeuI+oDcF0Qa/UYesrqvbDXjT9LaLG22alq+0FN0pQG7vF 3B9s117y79VzF5rOyT8zZx3IvV0OulkfxMo6ys/6aGJWi68feoNl2RBcOf26f9BQi4IT A7RA== 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=uK1v+EiguMoYRGbIEG8BvH+kU+PSbAC8gTglH1oJQN4=; fh=vm85eyWrvOAHduw3sqEA+cYBqvHB7M0MHFcRJg7VWOo=; b=WiSxaB3zNKLkAk3Q9F8VVln/Y3mnCPduMhAK1ZT+AXeyM9jQwvVHTcCPqoKQYBocox MJRzfGqFb0Ex9dBR5mOpu96YQ2h/xF9Gs8Ny95upah/tdIEMqOGF95hbFIXLbxcwX7/b giURgGxeh8gNmy8oojtFEzzhHHYggjklqF60a+b2A8c1HxsfV5okDVFA56061enivox/ bl1FuJLmfFHdZ1ro5mnf2tNr++rzJheAgZIu0Hf2C5SitY1w+prWu5z8oip2nHEgp7Lp YEdfzC7L+umqUj14N8+crKJXEOd0+W+GE0AXm9Nq/JS2Nw+ayRoXU/CvqpWHwmB6bt7i 91FA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YUHvzM7F; 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 t4-20020a0cea24000000b00699386e4aa8si414507qvp.308.2024.04.04.16.07.54 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 04 Apr 2024 16:07:54 -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=YUHvzM7F; 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 1rsWAA-00022Q-18; Thu, 04 Apr 2024 19:06:30 -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 1rsW9z-0001zA-Cw for qemu-devel@nongnu.org; Thu, 04 Apr 2024 19:06:20 -0400 Received: from mail-pg1-x535.google.com ([2607:f8b0:4864:20::535]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rsW9w-0007hK-SC for qemu-devel@nongnu.org; Thu, 04 Apr 2024 19:06:19 -0400 Received: by mail-pg1-x535.google.com with SMTP id 41be03b00d2f7-5ce9555d42eso1141310a12.2 for ; Thu, 04 Apr 2024 16:06:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712271975; x=1712876775; 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=uK1v+EiguMoYRGbIEG8BvH+kU+PSbAC8gTglH1oJQN4=; b=YUHvzM7Fp4AY4HEEPmkT80jDSpOTwkZHWs5BK7Ifh5Y/Qx7dcxEhtEmm3zIOzFomqE 2RZBO9cTP1ykK3CCQveyjXxAWij0BiP6lSRkg18jel3RaoPylNuhvKUGPb+54qhPnIZI Nd8E+4WygAPqCkcumBwre/iXBKH0wCo/i3B/gZqz3tqpFw19rHPDXBgY7PuZJVHgZ/qi ISMt3n/KxazpgYgyZeCyHKM9lmHSIG29fzGbWgLzb9ydLyYIupytMra/QRjWzjEOH7lf 1tK5zbw1fUaw/wVjpnMkS/LKCOKZ7PL45q7ab5hJzeGvSM+zUC1LpZ+ge0jXsjo4wP9/ wj/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712271975; x=1712876775; 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=uK1v+EiguMoYRGbIEG8BvH+kU+PSbAC8gTglH1oJQN4=; b=JTV4+vOpYIXtcZah1iYHZOmfowWaxvgpO/97CM2fAp+4yACMyp3Zh/cAcQY5LhxFpG 6cf6GQSmMMcsjU/vIWYRc5+Eg2Pb0occvMdabsU0w0SBGi2/rFKCq/6u5RjuIiNtyep9 jYT9jkCA4hqAamXywXz2Ha/HrIT20GUm96t9YeC0lIGfdNQFc9+2Yz/6owfrSsQKm9Xi aLJQXlBYgyBf8w5X+tGzyFMTI/bMTFUxHT/AGuElW4Xk/KlRHGl5YIWd+B9uIQs+Hlgr iXxIa8vKSl2ACN9ndTq4Op3u5ZUBNIaQohUMy1W/emVbYvq3WHjzfomFXpVABggxpEac NmQA== X-Gm-Message-State: AOJu0YxuJaaWWeaHQLpWY0DuM2c8WIkHMENaVDqhY86qs6PZT5TLt/El MyTDJgHgXgP6tWlCQeyYdMS6Atdh6HLVIjhol2S5mYMj3UYq5GTz44NZ7ReYgNo9w3YpJWAl2UL x X-Received: by 2002:a17:90b:90f:b0:2a1:fe2c:75e9 with SMTP id bo15-20020a17090b090f00b002a1fe2c75e9mr3840524pjb.42.1712271975071; Thu, 04 Apr 2024 16:06:15 -0700 (PDT) Received: from stoup.. (098-147-007-212.res.spectrum.com. [98.147.7.212]) by smtp.gmail.com with ESMTPSA id q36-20020a17090a17a700b002a2f3cfc92asm1052592pja.16.2024.04.04.16.06.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Apr 2024 16:06:14 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Pierrick Bouvier Subject: [PATCH v2 01/21] tcg: Add TCGContext.emit_before_op Date: Thu, 4 Apr 2024 13:05:51 -1000 Message-Id: <20240404230611.21231-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240404230611.21231-1-richard.henderson@linaro.org> References: <20240404230611.21231-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::535; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x535.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Allow operations to be emitted via normal expanders into the middle of the opcode stream. Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- include/tcg/tcg.h | 6 ++++++ tcg/tcg.c | 14 ++++++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/include/tcg/tcg.h b/include/tcg/tcg.h index 451f3fec41..05a1912f8a 100644 --- a/include/tcg/tcg.h +++ b/include/tcg/tcg.h @@ -553,6 +553,12 @@ struct TCGContext { QTAILQ_HEAD(, TCGOp) ops, free_ops; QSIMPLEQ_HEAD(, TCGLabel) labels; + /* + * When clear, new ops are added to the tail of @ops. + * When set, new ops are added in front of @emit_before_op. + */ + TCGOp *emit_before_op; + /* Tells which temporary holds a given register. It does not take into account fixed registers */ TCGTemp *reg_to_temp[TCG_TARGET_NB_REGS]; diff --git a/tcg/tcg.c b/tcg/tcg.c index d6670237fb..0c0bb9d169 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -1521,6 +1521,7 @@ void tcg_func_start(TCGContext *s) QTAILQ_INIT(&s->ops); QTAILQ_INIT(&s->free_ops); + s->emit_before_op = NULL; QSIMPLEQ_INIT(&s->labels); tcg_debug_assert(s->addr_type == TCG_TYPE_I32 || @@ -2332,7 +2333,11 @@ static void tcg_gen_callN(TCGHelperInfo *info, TCGTemp *ret, TCGTemp **args) op->args[pi++] = (uintptr_t)info; tcg_debug_assert(pi == total_args); - QTAILQ_INSERT_TAIL(&tcg_ctx->ops, op, link); + if (tcg_ctx->emit_before_op) { + QTAILQ_INSERT_BEFORE(tcg_ctx->emit_before_op, op, link); + } else { + QTAILQ_INSERT_TAIL(&tcg_ctx->ops, op, link); + } tcg_debug_assert(n_extend < ARRAY_SIZE(extend_free)); for (i = 0; i < n_extend; ++i) { @@ -3215,7 +3220,12 @@ static TCGOp *tcg_op_alloc(TCGOpcode opc, unsigned nargs) TCGOp *tcg_emit_op(TCGOpcode opc, unsigned nargs) { TCGOp *op = tcg_op_alloc(opc, nargs); - QTAILQ_INSERT_TAIL(&tcg_ctx->ops, op, link); + + if (tcg_ctx->emit_before_op) { + QTAILQ_INSERT_BEFORE(tcg_ctx->emit_before_op, op, link); + } else { + QTAILQ_INSERT_TAIL(&tcg_ctx->ops, op, link); + } return op; } From patchwork Thu Apr 4 23:05:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 785843 Delivered-To: patch@linaro.org Received: by 2002:adf:f001:0:b0:33e:7753:30bd with SMTP id j1csp1074024wro; Thu, 4 Apr 2024 16:07:38 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCV8Tz+xa/W9dYgFscL1AbiOY6BTulRkip62n1sk1OPRAfLv8yGvzmB9yjJ2qIqOvkjlaxsMxkhXQbEAnIjoJVyP X-Google-Smtp-Source: AGHT+IFFcSazlzo09n997DlkqylaHEAj2bTPHPEqUh1f9tBDX49Abqp9h8g1ouO7pG+5lFrkDXlx X-Received: by 2002:a05:620a:5d84:b0:78b:e84f:3dd1 with SMTP id xx4-20020a05620a5d8400b0078be84f3dd1mr3792789qkn.32.1712272057931; Thu, 04 Apr 2024 16:07:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712272057; cv=none; d=google.com; s=arc-20160816; b=KZ4rWybj4oksTuvZerHiXEC1epbQ4Fz/6gb2S+iPNh3bVN5pR7pX4/lH/gkOKOG8kj bOOOxtoptJoKN0qsZbMPHM8c0nL9+ITPWUXRcxvta9Bj1ZzAZiTdSWW5H4HYPavzUxE/ XKC9ZGap5x76nHexPU3ut01zVWMyqffBDi1TXWGoCagB/pVtyygJsKDHNvmwdHY20MSg Dm2PkeD55hEq4KhL/nNurTn9R9hEv5TjNM6wHuwmSnuMbchC9REBbRgNq2lP7KxYU1sV gkCf+IYX7rZ8BzAECau/soQiyDPn4Ti+IF73yFyg62xFecdoKgjTB5ndZfvppCyNeYJf bXog== 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=AXNxunD293g232TU+51MeWlmAuFekT13Nuf8XRAYogk=; fh=eu2DY09p+eeddYDiV+DalJS3Vr0kxK5BujclYkgWvDw=; b=BRgjcr0Mx2PGsHLqhE73UFOBC/N33e/ZGJkP0hr7UsZPgS93pOtqrkYMCNNLgrmGtF hudIuytM4YQLm58USdMqj2oNHtzRUaNztJlYr1xRvkBlQhjaY+fM+mXoLm2Fn0R80RZ5 mxm3J4qh4IhiFc4c77wUvL4UIPFEMUtbHtVgTZCrQ7PZHPl6DE8kO4bJFWEuxqevlG6M 9vhwy+IcJTGphJk8SQqm9umjwDkjZW/DCuUuv+T1zodQaVG6KU9DcZTUBr5CTpPhQJf/ Jt8rc6ZABZi779mMXVP+BA6b1BeX5vamTImXTn0dADodB2+6UJAgplO/Z1RiRAhhYXBi DE/Q==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HpWJWpyn; 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 y2-20020a05620a44c200b00789eb26bda5si485462qkp.729.2024.04.04.16.07.37 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 04 Apr 2024 16:07:37 -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=HpWJWpyn; 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 1rsWA6-00020e-NP; Thu, 04 Apr 2024 19:06:26 -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 1rsWA0-0001zB-6l for qemu-devel@nongnu.org; Thu, 04 Apr 2024 19:06:20 -0400 Received: from mail-pg1-x52a.google.com ([2607:f8b0:4864:20::52a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rsW9y-0007hY-Kv for qemu-devel@nongnu.org; Thu, 04 Apr 2024 19:06:19 -0400 Received: by mail-pg1-x52a.google.com with SMTP id 41be03b00d2f7-5e8470c1cb7so1215898a12.2 for ; Thu, 04 Apr 2024 16:06:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712271976; x=1712876776; 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=AXNxunD293g232TU+51MeWlmAuFekT13Nuf8XRAYogk=; b=HpWJWpyn4CEi2u0dNTxi9/1T2eWS6noOOcqiuzyazY7s+Ed5VkRll7a1ZNfuW04S/A 1OvQm7fWsa8zJBy7mZvFeAd0KmJcDicmq0CIKA2P7ydSEb+OGCJlDYBnb3u2SyYcQCaI 53qNUcfjTgREoM0YBFbf81ICS646sdU8pVCwpLvWPdmjQREqnYBaPRNVqT1WWGjMDWns i+AIKP6/6x+mFnFX8lFTcwcZQFgIuz4JJsEjcycVx5gRzGSD2whic9HNV6IzsLuqOSSl rf0l5KFYI7X2hLX6YQpV7OC0oMkLFdDChIOLK53xRuEpDROtCkie1l0cjhO/JwOTnwp3 Y0ig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712271976; x=1712876776; 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=AXNxunD293g232TU+51MeWlmAuFekT13Nuf8XRAYogk=; b=kvRQC4cbjw/FuESg4+NTKiSchB3mBXg1V/hOB/c+etljCnJp9wtcLrEqW+UPVUla1Q 2gEfAdJTmyOttYh95CeeoI2FxcJfLHSAgCW7H75T3X/eYRyXMy9m4ePpgMW6HLXWzXlJ rW/6wW7gyqJg9gW09vK1MBng6QnE7A5vctbrLnwgS2nYwe7yz94zTh2bHbD3Z8OysD4Q a3EluezyQBzLZM2n4g9neEFbAlTlYqn3tnnbZRAjUmsFZyJ0+yPt9TgoHLi1MTW7Z8+A WV0Sj72rRLhDEG+V4kze0/CGRV4Y5qzxKSyCxa6MfvnidQdyHKuKbYuYpr0RuK9BhH5X HvdQ== X-Gm-Message-State: AOJu0YypN0kAFgC9aGEcgGavNMJEbJrsIWFLLeRMYC1FPOgxrnE15bT7 z2FgZRJIAKngijJVQIfnpfcSNQy4VZXKKox9Xjlhq1d0h8oArP9jnm00/rzT0O0BLEhX8sMLREG j X-Received: by 2002:a17:90b:f18:b0:2a2:bc68:2897 with SMTP id br24-20020a17090b0f1800b002a2bc682897mr3640872pjb.44.1712271976328; Thu, 04 Apr 2024 16:06:16 -0700 (PDT) Received: from stoup.. (098-147-007-212.res.spectrum.com. [98.147.7.212]) by smtp.gmail.com with ESMTPSA id q36-20020a17090a17a700b002a2f3cfc92asm1052592pja.16.2024.04.04.16.06.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Apr 2024 16:06:15 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Alex_Benn=C3=A9e?= Subject: [PATCH v2 02/21] tcg: Make tcg/helper-info.h self-contained Date: Thu, 4 Apr 2024 13:05:52 -1000 Message-Id: <20240404230611.21231-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240404230611.21231-1-richard.henderson@linaro.org> References: <20240404230611.21231-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::52a; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x52a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Move MAX_CALL_IARGS from tcg.h and include for the define of TCG_TARGET_REG_BITS. Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson --- include/tcg/helper-info.h | 3 +++ include/tcg/tcg.h | 2 -- tcg/tci.c | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/include/tcg/helper-info.h b/include/tcg/helper-info.h index 7c27d6164a..909fe73afa 100644 --- a/include/tcg/helper-info.h +++ b/include/tcg/helper-info.h @@ -12,6 +12,9 @@ #ifdef CONFIG_TCG_INTERPRETER #include #endif +#include "tcg-target-reg-bits.h" + +#define MAX_CALL_IARGS 7 /* * Describe the calling convention of a given argument type. diff --git a/include/tcg/tcg.h b/include/tcg/tcg.h index 05a1912f8a..e4c598428d 100644 --- a/include/tcg/tcg.h +++ b/include/tcg/tcg.h @@ -39,8 +39,6 @@ /* XXX: make safe guess about sizes */ #define MAX_OP_PER_INSTR 266 -#define MAX_CALL_IARGS 7 - #define CPU_TEMP_BUF_NLONGS 128 #define TCG_STATIC_FRAME_SIZE (CPU_TEMP_BUF_NLONGS * sizeof(long)) diff --git a/tcg/tci.c b/tcg/tci.c index 39adcb7d82..3afb223528 100644 --- a/tcg/tci.c +++ b/tcg/tci.c @@ -19,6 +19,7 @@ #include "qemu/osdep.h" #include "tcg/tcg.h" +#include "tcg/helper-info.h" #include "tcg/tcg-ldst.h" #include From patchwork Thu Apr 4 23:05:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 785858 Delivered-To: patch@linaro.org Received: by 2002:adf:f001:0:b0:33e:7753:30bd with SMTP id j1csp1074475wro; Thu, 4 Apr 2024 16:08:56 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWkXUK6VVe1asQtqVnvCN9jlgdNhNw/x0K5TMDKwY5/0JPe1KXdq3LZBPTIBpcqg36MQkqEYgOR7aIdbkExPkZ/ X-Google-Smtp-Source: AGHT+IHSBLwhpnmYOUW/1l2+9e93zfqRtw6wLt0XKDKhJrhD03QiC4tNsJv2FkTgrjrhoOHejz9l X-Received: by 2002:a05:6808:1384:b0:3c5:b002:1b6a with SMTP id c4-20020a056808138400b003c5b0021b6amr884054oiw.52.1712272135604; Thu, 04 Apr 2024 16:08:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712272135; cv=none; d=google.com; s=arc-20160816; b=rbb7HCfklBYOXy1/Cr+xUlOj7uotiDbBm0AQ6j+mHX+Y1O8ODkWsauFoFpLJSL2z+O qxV+nt7HKAlMkygCLyucxWY7rHKKIpQBPbD44x5DP9iSY92b1kGrZ6STVtPcHnF1ooXQ 6FFLNBCY5uAvFcHtYNWNA397oK0/t2yTh8+ZsW7cZrS8QDHG2zyO0J9pK4Z3RgEvBL3I KAfb9Z0+WdlZhsX908+geAZo+MznKhgwYBcDGwHAKBod9R4pO28sKHGmFrnTgBSiBB/T kMEC6wXG59RXM+I2nIK1jjUsD4s2pqZUZ3aH+9TufphhKtelVHJVL4I6q85uW1Y7NvAF fU4g== 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=JpTCH1YULD/T8eR03//FfcdW59oyfLg0vMaMY0B4ivI=; fh=eu2DY09p+eeddYDiV+DalJS3Vr0kxK5BujclYkgWvDw=; b=p7drSl3nbF40VRbd+OWKwCavRqdifmOJqLY982EO8zEyIIwTErPYG+nPHbsh+xqhWa 0UHrgDlrpY3Udrd+3KjOxwYkLXbnRyRf0+WmD8iH/r4sLjeMyMiVtHlCF6EBiQpX9CyP WCkbxFxLik8wROt4eYsF7dp9aaSZ0gzFMp4QT4yIbr7ac39k+zHAkbZN+lB/2uBhfzAi B4nMwvZHFWEAqEyU8PL/0/z7uMVeUL9cAI+PuyjmP3eDLZyU4gjG+Rcw2qMqsJJKsCkx FDUZzJFYX4BfgNEIoVV4jeOaGUyYMN4KaIqHCFU/qSvcRWsq/r0kuYGQPHsnYEzx+DYm yXKA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="jG/w/VTk"; 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 g5-20020ac87f45000000b00432c273f671si418707qtk.656.2024.04.04.16.08.55 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 04 Apr 2024 16:08:55 -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="jG/w/VTk"; 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 1rsWA7-00021X-LX; Thu, 04 Apr 2024 19:06:27 -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 1rsWA1-0001zU-CR for qemu-devel@nongnu.org; Thu, 04 Apr 2024 19:06:24 -0400 Received: from mail-pf1-x436.google.com ([2607:f8b0:4864:20::436]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rsW9z-0007hn-9O for qemu-devel@nongnu.org; Thu, 04 Apr 2024 19:06:21 -0400 Received: by mail-pf1-x436.google.com with SMTP id d2e1a72fcca58-6e709e0c123so1380819b3a.1 for ; Thu, 04 Apr 2024 16:06:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712271977; x=1712876777; 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=JpTCH1YULD/T8eR03//FfcdW59oyfLg0vMaMY0B4ivI=; b=jG/w/VTkFfFzyC1RhnOe2KsGENPOkbK6kDzHlUVs6lj/dMvbAXCupasJy9r+rXItXU mBpsW8bcA2C1WmfH1ejIi4TwozUcC9DUPN3BSTAjn6ypMujBGvwgt2WVzeVx3ifkQeIW 5xmix9QBYJQFDkp2oMuehs2Fp9fvdlDLqaDvFY7hs+coHpAqzMb76otT1s7vfQosforu 6HNysAgHPUIlahXpgxZ5Dzyf9LjswVF4pdsDTyMuZtspiFlXNcd2MNViXZ78ZdKNxltj SS/wjf3uUCRPaoHVhWY7kbmXdNXZjQqGgi8SHgIwzzRUmW59nreFb9al9n8b5anJENFj gtSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712271977; x=1712876777; 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=JpTCH1YULD/T8eR03//FfcdW59oyfLg0vMaMY0B4ivI=; b=mwl6DlQc2/iNYQrHndEpTYcPYxf1rSRiDpj4WFEexh3Vnd4c7neiSncw1fF7HEtqVT /7WMFqNmaPrjWNgFLBscYGZwC4QObfKKD98uYhCwVCdyqMv9rTVswsoIiX/VDCZevtwe hiAr5OBlB9GcJpkI9mFTn9DAGAlBcl4iWc3pZAdQULoho+ydSn+hYl5yX7Uj6GfVhJUC /gSQl2obftm3CB6fq3MWU+HQVYBtLY/58/qmPy5DuFfVGldlRfFOA9uAG6p8PsU1WIp6 WBqXjENf+n79HULMzLthpMWdawCKDqhy5DbZj0/U1M1m6xJhBmsSB3eUznolcN9p/+ym gGqg== X-Gm-Message-State: AOJu0YwAwzEjUKRECJ0SDuYO69ETidafJ7lS2XQknERs1lTT2LkhjCUO qxau/ARxfnnSGYdhWPK+2wFt6ew+d8LvMP0B8ZqgAGLs9dedfpV6qDgt+D3hFwPz/h/+4davY/r b X-Received: by 2002:a05:6a21:150b:b0:1a3:d618:cfdf with SMTP id nq11-20020a056a21150b00b001a3d618cfdfmr1256797pzb.26.1712271977616; Thu, 04 Apr 2024 16:06:17 -0700 (PDT) Received: from stoup.. (098-147-007-212.res.spectrum.com. [98.147.7.212]) by smtp.gmail.com with ESMTPSA id q36-20020a17090a17a700b002a2f3cfc92asm1052592pja.16.2024.04.04.16.06.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Apr 2024 16:06:17 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Alex_Benn=C3=A9e?= Subject: [PATCH v2 03/21] tcg: Pass function pointer to tcg_gen_call* Date: Thu, 4 Apr 2024 13:05:53 -1000 Message-Id: <20240404230611.21231-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240404230611.21231-1-richard.henderson@linaro.org> References: <20240404230611.21231-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::436; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x436.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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 For normal helpers, read the function pointer from the structure earlier. For plugins, this will allow the function pointer to come from elsewhere. Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson --- include/tcg/tcg.h | 21 +++++++++------- include/exec/helper-gen.h.inc | 24 ++++++++++++------- tcg/tcg.c | 45 +++++++++++++++++++---------------- 3 files changed, 52 insertions(+), 38 deletions(-) diff --git a/include/tcg/tcg.h b/include/tcg/tcg.h index e4c598428d..8d9f6585ff 100644 --- a/include/tcg/tcg.h +++ b/include/tcg/tcg.h @@ -852,19 +852,22 @@ typedef struct TCGTargetOpDef { bool tcg_op_supported(TCGOpcode op); -void tcg_gen_call0(TCGHelperInfo *, TCGTemp *ret); -void tcg_gen_call1(TCGHelperInfo *, TCGTemp *ret, TCGTemp *); -void tcg_gen_call2(TCGHelperInfo *, TCGTemp *ret, TCGTemp *, TCGTemp *); -void tcg_gen_call3(TCGHelperInfo *, TCGTemp *ret, TCGTemp *, +void tcg_gen_call0(void *func, TCGHelperInfo *, TCGTemp *ret); +void tcg_gen_call1(void *func, TCGHelperInfo *, TCGTemp *ret, TCGTemp *); +void tcg_gen_call2(void *func, TCGHelperInfo *, TCGTemp *ret, TCGTemp *, TCGTemp *); -void tcg_gen_call4(TCGHelperInfo *, TCGTemp *ret, TCGTemp *, TCGTemp *, - TCGTemp *, TCGTemp *); -void tcg_gen_call5(TCGHelperInfo *, TCGTemp *ret, TCGTemp *, TCGTemp *, +void tcg_gen_call3(void *func, TCGHelperInfo *, TCGTemp *ret, TCGTemp *, TCGTemp *, TCGTemp *); -void tcg_gen_call6(TCGHelperInfo *, TCGTemp *ret, TCGTemp *, TCGTemp *, +void tcg_gen_call4(void *func, TCGHelperInfo *, TCGTemp *ret, TCGTemp *, TCGTemp *, TCGTemp *, TCGTemp *); -void tcg_gen_call7(TCGHelperInfo *, TCGTemp *ret, TCGTemp *, TCGTemp *, +void tcg_gen_call5(void *func, TCGHelperInfo *, TCGTemp *ret, TCGTemp *, TCGTemp *, TCGTemp *, TCGTemp *, TCGTemp *); +void tcg_gen_call6(void *func, TCGHelperInfo *, TCGTemp *ret, + TCGTemp *, TCGTemp *, TCGTemp *, TCGTemp *, + TCGTemp *, TCGTemp *); +void tcg_gen_call7(void *func, TCGHelperInfo *, TCGTemp *ret, + TCGTemp *, TCGTemp *, TCGTemp *, TCGTemp *, + TCGTemp *, TCGTemp *, TCGTemp *); TCGOp *tcg_emit_op(TCGOpcode opc, unsigned nargs); void tcg_op_remove(TCGContext *s, TCGOp *op); diff --git a/include/exec/helper-gen.h.inc b/include/exec/helper-gen.h.inc index c009641517..f7eb59b6c1 100644 --- a/include/exec/helper-gen.h.inc +++ b/include/exec/helper-gen.h.inc @@ -14,7 +14,8 @@ extern TCGHelperInfo glue(helper_info_, name); \ static inline void glue(gen_helper_, name)(dh_retvar_decl0(ret)) \ { \ - tcg_gen_call0(&glue(helper_info_, name), dh_retvar(ret)); \ + tcg_gen_call0(glue(helper_info_,name).func, \ + &glue(helper_info_,name), dh_retvar(ret)); \ } #define DEF_HELPER_FLAGS_1(name, flags, ret, t1) \ @@ -22,7 +23,8 @@ extern TCGHelperInfo glue(helper_info_, name); \ static inline void glue(gen_helper_, name)(dh_retvar_decl(ret) \ dh_arg_decl(t1, 1)) \ { \ - tcg_gen_call1(&glue(helper_info_, name), dh_retvar(ret), \ + tcg_gen_call1(glue(helper_info_,name).func, \ + &glue(helper_info_,name), dh_retvar(ret), \ dh_arg(t1, 1)); \ } @@ -31,7 +33,8 @@ extern TCGHelperInfo glue(helper_info_, name); \ static inline void glue(gen_helper_, name)(dh_retvar_decl(ret) \ dh_arg_decl(t1, 1), dh_arg_decl(t2, 2)) \ { \ - tcg_gen_call2(&glue(helper_info_, name), dh_retvar(ret), \ + tcg_gen_call2(glue(helper_info_,name).func, \ + &glue(helper_info_,name), dh_retvar(ret), \ dh_arg(t1, 1), dh_arg(t2, 2)); \ } @@ -40,7 +43,8 @@ extern TCGHelperInfo glue(helper_info_, name); \ static inline void glue(gen_helper_, name)(dh_retvar_decl(ret) \ dh_arg_decl(t1, 1), dh_arg_decl(t2, 2), dh_arg_decl(t3, 3)) \ { \ - tcg_gen_call3(&glue(helper_info_, name), dh_retvar(ret), \ + tcg_gen_call3(glue(helper_info_,name).func, \ + &glue(helper_info_,name), dh_retvar(ret), \ dh_arg(t1, 1), dh_arg(t2, 2), dh_arg(t3, 3)); \ } @@ -50,7 +54,8 @@ static inline void glue(gen_helper_, name)(dh_retvar_decl(ret) \ dh_arg_decl(t1, 1), dh_arg_decl(t2, 2), \ dh_arg_decl(t3, 3), dh_arg_decl(t4, 4)) \ { \ - tcg_gen_call4(&glue(helper_info_, name), dh_retvar(ret), \ + tcg_gen_call4(glue(helper_info_,name).func, \ + &glue(helper_info_,name), dh_retvar(ret), \ dh_arg(t1, 1), dh_arg(t2, 2), \ dh_arg(t3, 3), dh_arg(t4, 4)); \ } @@ -61,7 +66,8 @@ static inline void glue(gen_helper_, name)(dh_retvar_decl(ret) \ dh_arg_decl(t1, 1), dh_arg_decl(t2, 2), dh_arg_decl(t3, 3), \ dh_arg_decl(t4, 4), dh_arg_decl(t5, 5)) \ { \ - tcg_gen_call5(&glue(helper_info_, name), dh_retvar(ret), \ + tcg_gen_call5(glue(helper_info_,name).func, \ + &glue(helper_info_,name), dh_retvar(ret), \ dh_arg(t1, 1), dh_arg(t2, 2), dh_arg(t3, 3), \ dh_arg(t4, 4), dh_arg(t5, 5)); \ } @@ -72,7 +78,8 @@ static inline void glue(gen_helper_, name)(dh_retvar_decl(ret) \ dh_arg_decl(t1, 1), dh_arg_decl(t2, 2), dh_arg_decl(t3, 3), \ dh_arg_decl(t4, 4), dh_arg_decl(t5, 5), dh_arg_decl(t6, 6)) \ { \ - tcg_gen_call6(&glue(helper_info_, name), dh_retvar(ret), \ + tcg_gen_call6(glue(helper_info_,name).func, \ + &glue(helper_info_,name), dh_retvar(ret), \ dh_arg(t1, 1), dh_arg(t2, 2), dh_arg(t3, 3), \ dh_arg(t4, 4), dh_arg(t5, 5), dh_arg(t6, 6)); \ } @@ -84,7 +91,8 @@ static inline void glue(gen_helper_, name)(dh_retvar_decl(ret) \ dh_arg_decl(t4, 4), dh_arg_decl(t5, 5), dh_arg_decl(t6, 6), \ dh_arg_decl(t7, 7)) \ { \ - tcg_gen_call7(&glue(helper_info_, name), dh_retvar(ret), \ + tcg_gen_call7(glue(helper_info_,name).func, \ + &glue(helper_info_,name), dh_retvar(ret), \ dh_arg(t1, 1), dh_arg(t2, 2), dh_arg(t3, 3), \ dh_arg(t4, 4), dh_arg(t5, 5), dh_arg(t6, 6), \ dh_arg(t7, 7)); \ diff --git a/tcg/tcg.c b/tcg/tcg.c index 0c0bb9d169..0bf218314b 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -2251,7 +2251,8 @@ bool tcg_op_supported(TCGOpcode op) static TCGOp *tcg_op_alloc(TCGOpcode opc, unsigned nargs); -static void tcg_gen_callN(TCGHelperInfo *info, TCGTemp *ret, TCGTemp **args) +static void tcg_gen_callN(void *func, TCGHelperInfo *info, + TCGTemp *ret, TCGTemp **args) { TCGv_i64 extend_free[MAX_CALL_IARGS]; int n_extend = 0; @@ -2329,7 +2330,7 @@ static void tcg_gen_callN(TCGHelperInfo *info, TCGTemp *ret, TCGTemp **args) g_assert_not_reached(); } } - op->args[pi++] = (uintptr_t)info->func; + op->args[pi++] = (uintptr_t)func; op->args[pi++] = (uintptr_t)info; tcg_debug_assert(pi == total_args); @@ -2345,56 +2346,58 @@ static void tcg_gen_callN(TCGHelperInfo *info, TCGTemp *ret, TCGTemp **args) } } -void tcg_gen_call0(TCGHelperInfo *info, TCGTemp *ret) +void tcg_gen_call0(void *func, TCGHelperInfo *info, TCGTemp *ret) { - tcg_gen_callN(info, ret, NULL); + tcg_gen_callN(func, info, ret, NULL); } -void tcg_gen_call1(TCGHelperInfo *info, TCGTemp *ret, TCGTemp *t1) +void tcg_gen_call1(void *func, TCGHelperInfo *info, TCGTemp *ret, TCGTemp *t1) { - tcg_gen_callN(info, ret, &t1); + tcg_gen_callN(func, info, ret, &t1); } -void tcg_gen_call2(TCGHelperInfo *info, TCGTemp *ret, TCGTemp *t1, TCGTemp *t2) +void tcg_gen_call2(void *func, TCGHelperInfo *info, TCGTemp *ret, + TCGTemp *t1, TCGTemp *t2) { TCGTemp *args[2] = { t1, t2 }; - tcg_gen_callN(info, ret, args); + tcg_gen_callN(func, info, ret, args); } -void tcg_gen_call3(TCGHelperInfo *info, TCGTemp *ret, TCGTemp *t1, - TCGTemp *t2, TCGTemp *t3) +void tcg_gen_call3(void *func, TCGHelperInfo *info, TCGTemp *ret, + TCGTemp *t1, TCGTemp *t2, TCGTemp *t3) { TCGTemp *args[3] = { t1, t2, t3 }; - tcg_gen_callN(info, ret, args); + tcg_gen_callN(func, info, ret, args); } -void tcg_gen_call4(TCGHelperInfo *info, TCGTemp *ret, TCGTemp *t1, - TCGTemp *t2, TCGTemp *t3, TCGTemp *t4) +void tcg_gen_call4(void *func, TCGHelperInfo *info, TCGTemp *ret, + TCGTemp *t1, TCGTemp *t2, TCGTemp *t3, TCGTemp *t4) { TCGTemp *args[4] = { t1, t2, t3, t4 }; - tcg_gen_callN(info, ret, args); + tcg_gen_callN(func, info, ret, args); } -void tcg_gen_call5(TCGHelperInfo *info, TCGTemp *ret, TCGTemp *t1, +void tcg_gen_call5(void *func, TCGHelperInfo *info, TCGTemp *ret, TCGTemp *t1, TCGTemp *t2, TCGTemp *t3, TCGTemp *t4, TCGTemp *t5) { TCGTemp *args[5] = { t1, t2, t3, t4, t5 }; - tcg_gen_callN(info, ret, args); + tcg_gen_callN(func, info, ret, args); } -void tcg_gen_call6(TCGHelperInfo *info, TCGTemp *ret, TCGTemp *t1, TCGTemp *t2, - TCGTemp *t3, TCGTemp *t4, TCGTemp *t5, TCGTemp *t6) +void tcg_gen_call6(void *func, TCGHelperInfo *info, TCGTemp *ret, + TCGTemp *t1, TCGTemp *t2, TCGTemp *t3, + TCGTemp *t4, TCGTemp *t5, TCGTemp *t6) { TCGTemp *args[6] = { t1, t2, t3, t4, t5, t6 }; - tcg_gen_callN(info, ret, args); + tcg_gen_callN(func, info, ret, args); } -void tcg_gen_call7(TCGHelperInfo *info, TCGTemp *ret, TCGTemp *t1, +void tcg_gen_call7(void *func, TCGHelperInfo *info, TCGTemp *ret, TCGTemp *t1, TCGTemp *t2, TCGTemp *t3, TCGTemp *t4, TCGTemp *t5, TCGTemp *t6, TCGTemp *t7) { TCGTemp *args[7] = { t1, t2, t3, t4, t5, t6, t7 }; - tcg_gen_callN(info, ret, args); + tcg_gen_callN(func, info, ret, args); } static void tcg_reg_alloc_start(TCGContext *s) From patchwork Thu Apr 4 23:05:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 785856 Delivered-To: patch@linaro.org Received: by 2002:adf:f001:0:b0:33e:7753:30bd with SMTP id j1csp1074463wro; Thu, 4 Apr 2024 16:08:55 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUW8zHpkdfO4LQJYMeetVyFkhxhRTeBpqYlXz/T5wVcWHWA3SifQ+2dwx9xEQ6pafRrViEj5t8HIwU9z6qEm5iy X-Google-Smtp-Source: AGHT+IG9oX8R1r7crYZIng1fk2LW5BnqzsfIZd1aqz3QCE1wVbIrc9T5IizQJ68HszgTsw/pnGL7 X-Received: by 2002:a9d:5909:0:b0:6e5:3134:1108 with SMTP id t9-20020a9d5909000000b006e531341108mr3554320oth.38.1712272134903; Thu, 04 Apr 2024 16:08:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712272134; cv=none; d=google.com; s=arc-20160816; b=fm52H+PtDARDU5PToGcoWSaBolDY19reoNQ2Deeav25wetVfVLNPVfmGZ3tVfQAmdy 6Uizp7ewiOuYPZPVMg8W1V8YKhBwK5p5T/0k+YiVHGbSlfEnzLdE4BoGImm+JhUXvDJf wqF1JMzueQYQy9w1JuSM+6oT7Ymrnmn2ov8GSdD3s2MFgdl7VRGqUppv59ByP1UVMUkA LsxzRmvCa7GvoXSAzn3AtENGMCz/RicB8Bw11fJrt3zcOpoAJqBhTBevSNqp4Tl9VDpU j6Y5N8d/6voaJ2Axodtija0Ys+8I56fDIxFmU55aIp4582KcQequnDIsDDXsW3++IL+0 0vCA== 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=luXE4K25FW6HOCJ1kHOE0xkHZzSsFeoNOQtESvbBF/8=; fh=eu2DY09p+eeddYDiV+DalJS3Vr0kxK5BujclYkgWvDw=; b=q9IpPkb5q33mpd2/w1MxOBl44sRWb7ssihbgXBcH8GQutKTdniby1OLV8xRo3UmdbK Kwt9jXPk9oWJJeSb3sFgxg/RL/cWupaWUBBQbWI0VcgdvZXuZ/KQLbWpNcrlC5EY9Cc0 GKJYwGV50x0QtsWCHSo0MCSGaTwZJO1Ku+7Z2rfNg+YUO3tj1cm7/GMfSGHJ+PujY1Qj 7p46JTcLygB0qIs0gd+jp54wV4aLUNkPtNd3tk1iAPQ/b+mvFa7m5vGixJ7tMi2jftBx d76IKAoGhxwBAZwlNt28UZ52e2BWQwQ1fiu+6vMnw1kdmfFvqrZotkxQQ0ObCcdmEiQ7 AvTQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Opls4Y9C; 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 o13-20020ac87c4d000000b004313b32d8c6si427312qtv.669.2024.04.04.16.08.54 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 04 Apr 2024 16:08:54 -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=Opls4Y9C; 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 1rsWA7-00020y-8j; Thu, 04 Apr 2024 19:06:27 -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 1rsWA1-0001zX-VB for qemu-devel@nongnu.org; Thu, 04 Apr 2024 19:06:24 -0400 Received: from mail-pg1-x52f.google.com ([2607:f8b0:4864:20::52f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rsWA0-0007i8-GD for qemu-devel@nongnu.org; Thu, 04 Apr 2024 19:06:21 -0400 Received: by mail-pg1-x52f.google.com with SMTP id 41be03b00d2f7-5ce6b5e3c4eso1040187a12.2 for ; Thu, 04 Apr 2024 16:06:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712271979; x=1712876779; 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=luXE4K25FW6HOCJ1kHOE0xkHZzSsFeoNOQtESvbBF/8=; b=Opls4Y9Ccq0Lt//5b2zKi1giZvoVPfiOY+nRza6mvvHei62PfIuulITHPwLruXytvb IW6QifxFnHxQR6opToK6IWw4mdLuto8cYcsj9RWoYE7cMUSJ6GFGq5UIim7mCt52saCQ VdNbQoK4ZBacnv76gO+NWBJWs19cIyJb+m95KaHbWtp8TUZ+dK+P9suS5gNetFJ/2ft2 t1ZbHNC3kqkbQC2XdOmwsqMzFAn+Oj1pKK73JpAaHqJLZuBoWdbglphFszIYJh3OcyQ5 CLbiwxVSyJf8jSDCPYoFgdvew9uAl5NzidI7sk5pNkJiu4p+owlOa1RVDvB9R8JpbjOE 04pQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712271979; x=1712876779; 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=luXE4K25FW6HOCJ1kHOE0xkHZzSsFeoNOQtESvbBF/8=; b=P+yBHgy1dlyAPL5mvvMRWLEjH6STMQSDGYFPKPVvN+3cqzan/UcwngX5qdzaqpTz3k DU5ZsmuMroBWe1smbU04Z/6AJtsabV9B11YdNwsxxEBWmRDDQs2PFSi02PW34v3kx0+W OVHBl53NjhnaKL3imZoYR3BjJ1RhYuepI1nlp7D8Hymp5QVQAbv1+nB1SWJ98GSfbNwu JwpKGjK2uzt/8JQZO7TjywZE/68lEVN/Q9khZmDQSAhd0dsNn+z4UB5IZ8ikxUQJok29 eIay+t+Ieu/xVorr7zNuJ9SUnKUVMyJgxwclU+Ewglg45sTSCCq5gPvOmu3HpJJLxm87 kHZA== X-Gm-Message-State: AOJu0YyuzbQ3sbXyDlXmQKce+bsjqI27b7KZ99BKnC4iQQ/Veb22g71H Z8AsjIsY2Oq/Y85DS6PtAUirI94pW8CDKqEQ8bReJLkukOytEPzuzTOCMWIK8GEmyV4OcwvHJnO v X-Received: by 2002:a17:90a:8a81:b0:2a2:5ec9:3754 with SMTP id x1-20020a17090a8a8100b002a25ec93754mr3598172pjn.33.1712271979199; Thu, 04 Apr 2024 16:06:19 -0700 (PDT) Received: from stoup.. (098-147-007-212.res.spectrum.com. [98.147.7.212]) by smtp.gmail.com with ESMTPSA id q36-20020a17090a17a700b002a2f3cfc92asm1052592pja.16.2024.04.04.16.06.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Apr 2024 16:06:18 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Alex_Benn=C3=A9e?= Subject: [PATCH v2 04/21] plugins: Zero new qemu_plugin_dyn_cb entries Date: Thu, 4 Apr 2024 13:05:54 -1000 Message-Id: <20240404230611.21231-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240404230611.21231-1-richard.henderson@linaro.org> References: <20240404230611.21231-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::52f; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x52f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson --- plugins/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/core.c b/plugins/core.c index 11ca20e626..4487cb7c48 100644 --- a/plugins/core.c +++ b/plugins/core.c @@ -307,7 +307,7 @@ static struct qemu_plugin_dyn_cb *plugin_get_dyn_cb(GArray **arr) GArray *cbs = *arr; if (!cbs) { - cbs = g_array_sized_new(false, false, + cbs = g_array_sized_new(false, true, sizeof(struct qemu_plugin_dyn_cb), 1); *arr = cbs; } From patchwork Thu Apr 4 23:05:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 785840 Delivered-To: patch@linaro.org Received: by 2002:adf:f001:0:b0:33e:7753:30bd with SMTP id j1csp1073768wro; Thu, 4 Apr 2024 16:06:59 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUo6UBiPHIlxovLCFMExhnUSIR/D89K8j8B+MjH6IKjN1ara0SvNK/jM9lPLPG6hkLhbT2/JkRtIi5gmnDw3Ur8 X-Google-Smtp-Source: AGHT+IHrYH7vonkX+Ypq+6A0rpXp+8qCUhGLTPE+J+yqHHUyuRgLOeYjrmlc9bJ+kdSWu5YXC9xA X-Received: by 2002:a05:622a:16:b0:432:b560:41fa with SMTP id x22-20020a05622a001600b00432b56041famr1587132qtw.34.1712272018787; Thu, 04 Apr 2024 16:06:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712272018; cv=none; d=google.com; s=arc-20160816; b=WnXN2T0e35URlSNiqT0+K0zbdbGP4YgDm8wx5+MKGbXwQXx1NIpEl5DJ+I+1QnY5F0 lwK5TmqkpMHO0MAG2wbbAy9idK1l58WXRrM9fAhHd8TPJBMgjPFcePrXYJ1Mjnfmcqc9 UjCzbPQ3Qt6+GmzG/HZvzyQORyk9seq+ssxRAgLPwBwCWYWS9rvnK+ZS3+GHlGTimxZZ +IvWJvj8p8AZXe4ImeA07jmanlhYDyYCqsTN93ZPNJPe2kKZNqGCqrZjjGiW4HKRbfNJ XuID8foCalOrMBDpr4JSaGG+cTgKvxP3thocW1sHKwZn1LGgjQlWmm0b4DAAuDJ6MVOf G1YA== 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=58RO24HbGZXsQzLPlVmO4lYrlwiy6xL20O90riCGy0c=; fh=eu2DY09p+eeddYDiV+DalJS3Vr0kxK5BujclYkgWvDw=; b=D2lzkMKyfHgmjYQEZHEmd6ma+rf/bXx02bkylYz0kpK+MtNBH2WBUo+x4bsnXrCGpe 8lVWt3Vkmcb/Dw+KJmVaP9wx7OIciQ/dEffR4i/pLziN+pGsp5cdzvtvbIBxKzIiFIrm evj8/HLtuSa0XpAHlEI7Ru+CVC9Y4ZSt7q35LKiziRxD01W7vL0qpAbcb5EG6iHGujo7 ENxysEkGYkSf0rCiOJiH5JZ8hfRl/Y2KIRmSYe9hhH2/6AZBwjubXwE8Lcj1ZhJhG6ch iosPv0G6jjk+FSjED9SuUGfhHGmYmUH1j0DXefHezbQHsVVFrqK5n4KL9OOlxspdQ8A2 3cbQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="F/YGyKYM"; 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 c16-20020ac87dd0000000b004343a1955a3si393186qte.801.2024.04.04.16.06.58 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 04 Apr 2024 16:06:58 -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="F/YGyKYM"; 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 1rsWA8-00021m-Mp; Thu, 04 Apr 2024 19:06:28 -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 1rsWA4-0001zi-IG for qemu-devel@nongnu.org; Thu, 04 Apr 2024 19:06:24 -0400 Received: from mail-pg1-x531.google.com ([2607:f8b0:4864:20::531]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rsWA1-0007iP-PQ for qemu-devel@nongnu.org; Thu, 04 Apr 2024 19:06:23 -0400 Received: by mail-pg1-x531.google.com with SMTP id 41be03b00d2f7-5c66b093b86so2065555a12.0 for ; Thu, 04 Apr 2024 16:06:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712271980; x=1712876780; 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=58RO24HbGZXsQzLPlVmO4lYrlwiy6xL20O90riCGy0c=; b=F/YGyKYMdw9yo7OEs9Dl37IM3w7+Uy2y5Mwmg0ili8ueYCz/CvHvtAo1zDBCnj7KRS cQTyOIUDYaPt+NeRTjxypz1ugvwOlBxbC3Si/n3oCQeYjBgh/azXTTMjW4pRFqvNpGEl JRTGarEhVptlve1iv3Vzx4uwgnS5SYmaS5Vl4hlMn+0i/h8Y3/QMfV38JMHRbVJh/kyS eXvyJHLZRq9oO9XHQb4VDOHNdGzD3lhI2UOa/stRdiDYj0weJalum+ZtHC62cC64tOeA ow+AfWWMMMhwlUSK6ihZ/Rr3EaW6/BZqWEEI4rxdilXp0aSFElpZRJn0VLNU9Z70vKTA 1lkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712271980; x=1712876780; 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=58RO24HbGZXsQzLPlVmO4lYrlwiy6xL20O90riCGy0c=; b=H+GHHUJEKkRw9itBfc9BFFrR2i8zQvspTh8uIG6VM8qmS4P7EVIDQwb1aLC2ZhltKV rScXquF/l8Ddotuoh/hdu1ZYTzvPxGJRI7FuCujtg3b7TuIVQAuIVTYClr4GKsZQkPr4 TMktZiv68hGM+zC+lAQdsvf4e0PE1xXpQudXe/z4muAahZYAr8ybZcygrpCwp9PO7Qb8 XYxlgStQeSSMM6f45M5FqM1lQsllu4gV4sR4jqjU2r+R08q1eSWcjm8KvxWC+6+vhhP6 CuWkgcZSA9XmlQJRbrC+jw3HdizYDaUHp63fUcaC973r43srWg0liQFbubuHDlQFAACO jeTg== X-Gm-Message-State: AOJu0Yys49Unq1BIZNx7fErGaUNdQj9TJNRb93+KwZQLpOefh5RyT2l/ zBVOmNcfDxbYbjh9juPbtJ+aqXDMf8PgB2Coqb19nz+jX5FEourBCauICRVBaP0yCaCCG6Dbm7T F X-Received: by 2002:a17:90b:305:b0:2a2:b732:42f1 with SMTP id ay5-20020a17090b030500b002a2b73242f1mr1141568pjb.8.1712271980423; Thu, 04 Apr 2024 16:06:20 -0700 (PDT) Received: from stoup.. (098-147-007-212.res.spectrum.com. [98.147.7.212]) by smtp.gmail.com with ESMTPSA id q36-20020a17090a17a700b002a2f3cfc92asm1052592pja.16.2024.04.04.16.06.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Apr 2024 16:06:20 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Alex_Benn=C3=A9e?= Subject: [PATCH v2 05/21] plugins: Move function pointer in qemu_plugin_dyn_cb Date: Thu, 4 Apr 2024 13:05:55 -1000 Message-Id: <20240404230611.21231-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240404230611.21231-1-richard.henderson@linaro.org> References: <20240404230611.21231-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::531; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x531.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org The out-of-line function pointer is mutually exclusive with inline expansion, so move it into the union. Wrap the pointer in a structure named 'regular' to match PLUGIN_CB_REGULAR. Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson --- include/qemu/plugin.h | 4 +++- accel/tcg/plugin-gen.c | 4 ++-- plugins/core.c | 8 ++++---- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/include/qemu/plugin.h b/include/qemu/plugin.h index 12a96cea2a..143262dca8 100644 --- a/include/qemu/plugin.h +++ b/include/qemu/plugin.h @@ -84,13 +84,15 @@ enum plugin_dyn_cb_subtype { * 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; enum plugin_dyn_cb_subtype 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 { + union qemu_plugin_cb_sig f; + } regular; struct { qemu_plugin_u64 entry; enum qemu_plugin_op op; diff --git a/accel/tcg/plugin-gen.c b/accel/tcg/plugin-gen.c index cd78ef94a1..4b488943ff 100644 --- a/accel/tcg/plugin-gen.c +++ b/accel/tcg/plugin-gen.c @@ -425,7 +425,7 @@ static TCGOp *append_udata_cb(const struct qemu_plugin_dyn_cb *cb, } /* call */ - op = copy_call(&begin_op, op, cb->f.vcpu_udata, cb_idx); + op = copy_call(&begin_op, op, cb->regular.f.vcpu_udata, cb_idx); return op; } @@ -473,7 +473,7 @@ static TCGOp *append_mem_cb(const struct qemu_plugin_dyn_cb *cb, if (type == PLUGIN_GEN_CB_MEM) { /* call */ - op = copy_call(&begin_op, op, cb->f.vcpu_udata, cb_idx); + op = copy_call(&begin_op, op, cb->regular.f.vcpu_udata, cb_idx); } return op; diff --git a/plugins/core.c b/plugins/core.c index 4487cb7c48..837c373690 100644 --- a/plugins/core.c +++ b/plugins/core.c @@ -342,7 +342,7 @@ void plugin_register_dyn_cb__udata(GArray **arr, dyn_cb->userp = udata; /* Note flags are discarded as unused. */ - dyn_cb->f.vcpu_udata = cb; + dyn_cb->regular.f.vcpu_udata = cb; dyn_cb->type = PLUGIN_CB_REGULAR; } @@ -359,7 +359,7 @@ void plugin_register_vcpu_mem_cb(GArray **arr, /* Note flags are discarded as unused. */ dyn_cb->type = PLUGIN_CB_REGULAR; dyn_cb->rw = rw; - dyn_cb->f.generic = cb; + dyn_cb->regular.f.vcpu_mem = cb; } /* @@ -511,8 +511,8 @@ void qemu_plugin_vcpu_mem_cb(CPUState *cpu, uint64_t vaddr, } switch (cb->type) { case PLUGIN_CB_REGULAR: - cb->f.vcpu_mem(cpu->cpu_index, make_plugin_meminfo(oi, rw), - vaddr, cb->userp); + cb->regular.f.vcpu_mem(cpu->cpu_index, make_plugin_meminfo(oi, rw), + vaddr, cb->userp); break; case PLUGIN_CB_INLINE: exec_inline_op(cb, cpu->cpu_index); From patchwork Thu Apr 4 23:05:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 785849 Delivered-To: patch@linaro.org Received: by 2002:adf:f001:0:b0:33e:7753:30bd with SMTP id j1csp1074215wro; Thu, 4 Apr 2024 16:08:10 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWYr26T0OJ0Lsnjvr1UpouFsQJjHMqtX1Oso2PRIklxJqlER18X9O+60nOewH86H2Xe8lUawEFWNFUR/G/ZxnNT X-Google-Smtp-Source: AGHT+IHXbueJvt9B9/I3Iu02miJsXWdV4wYhFPrucLNhMkVVhVsRk5lXdjKJaLVSf9U1tMeb+Ajb X-Received: by 2002:ac8:7d48:0:b0:432:cf1c:9d65 with SMTP id h8-20020ac87d48000000b00432cf1c9d65mr3994567qtb.53.1712272090143; Thu, 04 Apr 2024 16:08:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712272090; cv=none; d=google.com; s=arc-20160816; b=zIMSV3QQQ4l0L9NktUqRQuUN2bNmTzH+I/540el9o/Fx4/WQjROV8wC0vZa+uFxM/5 OxVNyl2rngBTucSpeWN8ounaKJvYSPL4WMykb3B7sZA4K7yvr7Kb1Y8Takmc9HFeqBj5 xiK10zE1WwEOjwDqKMJlnhRiZpVsYWBvLqreWJq2d8u9o/HsDrSrwZghW/ddvHf/3R1C HqcnxSQHvIksWCXRRjtBQkenFs+M+ru5+S6EBDqSd7Q6Uo2ocO/EIhyw/xH92s9jr/SI kWeW89BEJTlNs/oj0ktgnYNr1tGdZC1dcQMQ/6lhBW5mb5TfGjCb6YjH+A5Cvq5W5hfJ 2q9w== 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=Vf2pglGQtHQjyWIwNLhivR5j/rpAVWzFiLJardZxKs4=; fh=vm85eyWrvOAHduw3sqEA+cYBqvHB7M0MHFcRJg7VWOo=; b=A+/1g07PU+ZWW8D9UcQY4Kb5ybW8lxyokl0ZaG6uzyMbR6hGjtDhovCgJdseDhHGlm O4CI86N1d8ndBobSVL3duIfoD3qqClZJ2W0RvId38fV+jLvlAKuAjlivojLNhfzE26RH LoUtgMu7r2E0Qlk2aoH2M3bTCDVWJfNiMY2jFVsJ17EBQalNp2Vr6V/AGIwDOFrsXJ5E xqw/JEu9MGfppeiUyYhnlE1earjaj6bAUrsIyPCwD9umcAAEYel9us8W6oWLf9aJogZP JqwBFuWPtR4UNHd+xpManxL+x4zM0s+V6+YRbns43uV35w3dKWhXh1SxXIIe16xrbUjj t2iA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jKxa3b+M; 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 c10-20020ac85a8a000000b00431627efa14si420551qtc.411.2024.04.04.16.08.09 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 04 Apr 2024 16:08:10 -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=jKxa3b+M; 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 1rsWAA-00022R-Eg; Thu, 04 Apr 2024 19:06:30 -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 1rsWA6-00020U-5q for qemu-devel@nongnu.org; Thu, 04 Apr 2024 19:06:26 -0400 Received: from mail-pg1-x52a.google.com ([2607:f8b0:4864:20::52a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rsWA4-0007ir-BO for qemu-devel@nongnu.org; Thu, 04 Apr 2024 19:06:25 -0400 Received: by mail-pg1-x52a.google.com with SMTP id 41be03b00d2f7-53fbf2c42bfso1228254a12.3 for ; Thu, 04 Apr 2024 16:06:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712271982; x=1712876782; 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=Vf2pglGQtHQjyWIwNLhivR5j/rpAVWzFiLJardZxKs4=; b=jKxa3b+MAScs4AlRUaJKLI6tFY7+4GTDbRT8Ui5LPfKdjUmzdu8rlhA2ZSnusyH5Zq OFQDkDM2+0lP69zDUgYRvjjuP+ThQIRG5dx4h3O/7vUktIGtvms3MI+tJOg8oYg+85KJ UeyIW0gurAt/2AeB7zodtx1o33LBbg27ihsTN+NQEw6sdAzPx1Kxm+h7HrHFFy17ZbBu IWMD0eD6mnv2Tep9M+2zRhgd/2cxdg5fEpJxW7Str/wJM2sEFzaG+1oxJdZ+rFHKu0Mf W7XUfgM7MmZJZHtUn1LfgQXAL68k5iCOvBO5cf6h+9UInNs6kO55k8i09TWv6hEfteRp xcaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712271982; x=1712876782; 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=Vf2pglGQtHQjyWIwNLhivR5j/rpAVWzFiLJardZxKs4=; b=ZJiGS84TgNVKpfsDmBKQTqhypBPUKBvTlgWjpRUqYlEQ2GtqTb4FeSSxo6KsWh0Bb0 CzdK7LOy7/+HtTjOoxZsyzA3ehc6uKeXnJRFnLda/OMMJLpj+bAMsI6oIOUvz6tX9LoP mWqWqxCllfwy0DkDpgSFES1VzBsJHI6oxiKc6RCz0gTKlElX950AmAGmVtLJ+Hxp0JOA 5eKgUFVHsY36vliinyzJyUP04e16Pu3n5pPAEhEgS7Fn8b/Z6+ski4TD9dbHq36aRjVm NINnvgDeBDi2JEk3xXv749cs+F6h5knteBzfFwOLsRV6srQ13N16zS7xWxN1OSrqQVPm Nc1w== X-Gm-Message-State: AOJu0YxoAphRWqehLHN3glE8TAXJ/408GCEGYRZyn06yg/CN4OSNINvS oUmXW1Et1fQ3S0l3qZ+c7uYl+SVjM50LzQ8Q7XomBjEeoEJ0c9X3uWgJZ8cR7NLffTdwzvDfPUA O X-Received: by 2002:a17:90a:bb05:b0:2a2:f3:f52f with SMTP id u5-20020a17090abb0500b002a200f3f52fmr3716896pjr.43.1712271981845; Thu, 04 Apr 2024 16:06:21 -0700 (PDT) Received: from stoup.. (098-147-007-212.res.spectrum.com. [98.147.7.212]) by smtp.gmail.com with ESMTPSA id q36-20020a17090a17a700b002a2f3cfc92asm1052592pja.16.2024.04.04.16.06.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Apr 2024 16:06:21 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Pierrick Bouvier Subject: [PATCH v2 06/21] plugins: Create TCGHelperInfo for all out-of-line callbacks Date: Thu, 4 Apr 2024 13:05:56 -1000 Message-Id: <20240404230611.21231-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240404230611.21231-1-richard.henderson@linaro.org> References: <20240404230611.21231-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::52a; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x52a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org TCGHelperInfo includes the ABI for every function call. Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- include/qemu/plugin.h | 1 + plugins/core.c | 51 ++++++++++++++++++++++++++++++++++++++----- 2 files changed, 46 insertions(+), 6 deletions(-) diff --git a/include/qemu/plugin.h b/include/qemu/plugin.h index 143262dca8..793c44f1f2 100644 --- a/include/qemu/plugin.h +++ b/include/qemu/plugin.h @@ -92,6 +92,7 @@ struct qemu_plugin_dyn_cb { union { struct { union qemu_plugin_cb_sig f; + TCGHelperInfo *info; } regular; struct { qemu_plugin_u64 entry; diff --git a/plugins/core.c b/plugins/core.c index 837c373690..b0a2e80874 100644 --- a/plugins/core.c +++ b/plugins/core.c @@ -338,12 +338,26 @@ void plugin_register_dyn_cb__udata(GArray **arr, enum qemu_plugin_cb_flags flags, void *udata) { - struct qemu_plugin_dyn_cb *dyn_cb = plugin_get_dyn_cb(arr); + static TCGHelperInfo info[3] = { + [QEMU_PLUGIN_CB_NO_REGS].flags = TCG_CALL_NO_RWG | TCG_CALL_PLUGIN, + [QEMU_PLUGIN_CB_R_REGS].flags = TCG_CALL_NO_WG | TCG_CALL_PLUGIN, + [QEMU_PLUGIN_CB_RW_REGS].flags = TCG_CALL_PLUGIN, + /* + * Match qemu_plugin_vcpu_udata_cb_t: + * void (*)(uint32_t, void *) + */ + [0 ... 2].typemask = (dh_typemask(void, 0) | + dh_typemask(i32, 1) | + dh_typemask(ptr, 2)) + }; + struct qemu_plugin_dyn_cb *dyn_cb = plugin_get_dyn_cb(arr); dyn_cb->userp = udata; - /* Note flags are discarded as unused. */ - dyn_cb->regular.f.vcpu_udata = cb; dyn_cb->type = PLUGIN_CB_REGULAR; + dyn_cb->regular.f.vcpu_udata = cb; + + assert((unsigned)flags < ARRAY_SIZE(info)); + dyn_cb->regular.info = &info[flags]; } void plugin_register_vcpu_mem_cb(GArray **arr, @@ -352,14 +366,39 @@ void plugin_register_vcpu_mem_cb(GArray **arr, enum qemu_plugin_mem_rw rw, void *udata) { - struct qemu_plugin_dyn_cb *dyn_cb; + /* + * Expect that the underlying type for enum qemu_plugin_meminfo_t + * is either int32_t or uint32_t, aka int or unsigned int. + */ + QEMU_BUILD_BUG_ON( + !__builtin_types_compatible_p(qemu_plugin_meminfo_t, uint32_t) && + !__builtin_types_compatible_p(qemu_plugin_meminfo_t, int32_t)); - dyn_cb = plugin_get_dyn_cb(arr); + static TCGHelperInfo info[3] = { + [QEMU_PLUGIN_CB_NO_REGS].flags = TCG_CALL_NO_RWG | TCG_CALL_PLUGIN, + [QEMU_PLUGIN_CB_R_REGS].flags = TCG_CALL_NO_WG | TCG_CALL_PLUGIN, + [QEMU_PLUGIN_CB_RW_REGS].flags = TCG_CALL_PLUGIN, + /* + * Match qemu_plugin_vcpu_mem_cb_t: + * void (*)(uint32_t, qemu_plugin_meminfo_t, uint64_t, void *) + */ + [0 ... 2].typemask = + (dh_typemask(void, 0) | + dh_typemask(i32, 1) | + (__builtin_types_compatible_p(qemu_plugin_meminfo_t, uint32_t) + ? dh_typemask(i32, 2) : dh_typemask(s32, 2)) | + dh_typemask(i64, 3) | + dh_typemask(ptr, 4)) + }; + + struct qemu_plugin_dyn_cb *dyn_cb = plugin_get_dyn_cb(arr); dyn_cb->userp = udata; - /* Note flags are discarded as unused. */ dyn_cb->type = PLUGIN_CB_REGULAR; dyn_cb->rw = rw; dyn_cb->regular.f.vcpu_mem = cb; + + assert((unsigned)flags < ARRAY_SIZE(info)); + dyn_cb->regular.info = &info[flags]; } /* From patchwork Thu Apr 4 23:05:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 785844 Delivered-To: patch@linaro.org Received: by 2002:adf:f001:0:b0:33e:7753:30bd with SMTP id j1csp1074040wro; Thu, 4 Apr 2024 16:07:40 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUvocPngeIQ0gGmLRFaStdNfzCqu3WGeHwmU5DkSue1/kgaG1s69a1vyoH7dBBswdDTDlPNBzNV7rKMy90M4xW8 X-Google-Smtp-Source: AGHT+IHa8jBpTPFH04ziNeuQgOQoA18UMq0UKJCGJyzChora8lyr2ne3thX+JyifKdSg1xDc5wFx X-Received: by 2002:ac8:5981:0:b0:431:3163:c32d with SMTP id e1-20020ac85981000000b004313163c32dmr1381484qte.48.1712272059794; Thu, 04 Apr 2024 16:07:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712272059; cv=none; d=google.com; s=arc-20160816; b=dHNhfuGd0jFS+QjaD0HCqTW2P1ElRKO6a0AQsVr6UaMHs8bFlyn6pyypxXkHmYm/94 GVkbuNGWxm4vvmLQZmZ0uyX58W2OMORZsROqiyAMEK/gsvk8DXQ6iQOfcD+5E1OBRYVN Qm6pc3mOViqtFy7n0GgHy2Lqf6bCTAFAcZGzWljBL1Gs+m16z7YKGKPF+kAc92ZByxVq g/qrT91ccCYK2czw1duka2PRRtObxaB/otlWRfvf29goBSB5kFDlu7Og4YzOxOCZpiXO v05D3LCjScdG+GPAUQ+1q1vjFaUMWprVcapeCmSuvNTdRXukWrP69LQfNB8uijCb4Qla Oaqw== 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:to:from :dkim-signature; bh=2G4bfhkGtHkTpReC7gmCGCR5um+WwFsm5xLqETkyRYk=; fh=PnYt+qEB9tAfMKoqBm2xjKOFpYyFFGPudh5cVIoieJM=; b=brnD8D7f+sjR001hul5tjbd136Y5aXS80od8fQPMxsbHvjG9hbsZXfJ1yBmTmQjQHn TUe8oBFmtUr/k7E/TfaxUX8SaNjjANWqvgOVDkZSQ80KRvwp+63cDVtUk7Owk9Wz9JW4 gm4Op6JgpG0c/J4QsT5uLWQGOn8GSpzNT+dKsQ/jldpSNawFNGoY5N2KZygIscV9SslI X6JCZHOSiggmR+IRncbNG+qXE206G4kE4Wc3v00hsc6FZ3RrMwSTq4lVA796bGeW727c XexpnzI+T4HAXMcpYmomVAeD1rttObxF32dks82ZnyJy+Sv5WicXn3BvjK/t/UswZK0f brPA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=q1LWy8u1; 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 x12-20020ac85f0c000000b0043133444198si448017qta.185.2024.04.04.16.07.39 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 04 Apr 2024 16:07:39 -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=q1LWy8u1; 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 1rsWA9-00022E-3W; Thu, 04 Apr 2024 19:06:29 -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 1rsWA7-00021J-Ek for qemu-devel@nongnu.org; Thu, 04 Apr 2024 19:06:27 -0400 Received: from mail-pg1-x52e.google.com ([2607:f8b0:4864:20::52e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rsWA4-0007iz-G6 for qemu-devel@nongnu.org; Thu, 04 Apr 2024 19:06:27 -0400 Received: by mail-pg1-x52e.google.com with SMTP id 41be03b00d2f7-5d3907ff128so1317675a12.3 for ; Thu, 04 Apr 2024 16:06:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712271983; x=1712876783; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=2G4bfhkGtHkTpReC7gmCGCR5um+WwFsm5xLqETkyRYk=; b=q1LWy8u16lzydDhH5R+BAJvaccwh5ivUodJTFKVnTqbG1iJcqx94rXEflKxp5yO7xS 6ssl10zydLMTx5Ss9YZeQ4VtUzvzsz4L4xBRsbXzxKUS9nDJ5AN+E/mbcrmBHOUDTO3n 67oqrEWOKGASM0dDnBTvid3iYCFffDY1k1CO71qJ0RvlSKi7Ze+9uyEd+x5opq27twcR VKkdgo6JoBHrtxhRbTzZT3hgvjn3LwUdvqH9Fw/zfk4r9xiBpavb2vIR+GLw96pRvpyA Y3Wt+obX7YzhBpNDKfoPuJVZd7/Fvqigf/Kb9uh77Q9KL7YWLok3t14+r83usbsN31aO NzGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712271983; x=1712876783; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2G4bfhkGtHkTpReC7gmCGCR5um+WwFsm5xLqETkyRYk=; b=LEokrby/qjMeBwq/FncsL79MqJZmNUz2Q1U58d6rhi4Z9C+5ZkFJJWeYiMsm9PCYs7 YxTFa9vgywcjqMzYZcOGrIKalzFGSmdFH853wG27VjYUYHHLHAr9Xg7hMjFXMdY2It39 0yHdbm3Ps8byWM/8g9qgp3QJcUbP0+OcubIG5IEpwi4//7gqWyWuU6pPaErX3i/5PKLN GY4ARyqb3KGjbVPJL77h/AM3RbwiFc+sBuo4RTIMM478CsidtnC8/CtWN4wNryNnb65y vkDyiUaZR/enJemC77FnNYr9Tz1arWSa7Wjewqr36ofeuN90L8RPVDhYUkn17Y96vcLu JoXg== X-Gm-Message-State: AOJu0Yyqtpc0iR4xwBBea2aL8/QPm9pgcYWVchfdhYPtc0uI0T4dawr0 dJ1Z3mTeXSEFd5MWR9X66EpRFO5tzR7CaEmFHa58c0p/cMc3tZ7iChlo0/uy2UBKdX/e9kYckpT k X-Received: by 2002:a17:90a:68ca:b0:2a2:b097:dabc with SMTP id q10-20020a17090a68ca00b002a2b097dabcmr1218430pjj.31.1712271982981; Thu, 04 Apr 2024 16:06:22 -0700 (PDT) Received: from stoup.. (098-147-007-212.res.spectrum.com. [98.147.7.212]) by smtp.gmail.com with ESMTPSA id q36-20020a17090a17a700b002a2f3cfc92asm1052592pja.16.2024.04.04.16.06.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Apr 2024 16:06:22 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 07/21] plugins: Use emit_before_op for PLUGIN_GEN_AFTER_INSN Date: Thu, 4 Apr 2024 13:05:57 -1000 Message-Id: <20240404230611.21231-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240404230611.21231-1-richard.henderson@linaro.org> References: <20240404230611.21231-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::52e; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x52e.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Introduce a new plugin_cb op and migrate one operation. By using emit_before_op, we do not need to emit opcodes early and modify them later -- we can simply emit the final set of opcodes once. Signed-off-by: Richard Henderson --- include/tcg/tcg-op-common.h | 1 + include/tcg/tcg-opc.h | 1 + accel/tcg/plugin-gen.c | 74 +++++++++++++++++++++---------------- tcg/tcg-op.c | 5 +++ 4 files changed, 50 insertions(+), 31 deletions(-) diff --git a/include/tcg/tcg-op-common.h b/include/tcg/tcg-op-common.h index 2d932a515e..9de5a7f280 100644 --- a/include/tcg/tcg-op-common.h +++ b/include/tcg/tcg-op-common.h @@ -74,6 +74,7 @@ void tcg_gen_goto_tb(unsigned idx); */ void tcg_gen_lookup_and_goto_ptr(void); +void tcg_gen_plugin_cb(unsigned from); void tcg_gen_plugin_cb_start(unsigned from, unsigned type, unsigned wr); void tcg_gen_plugin_cb_end(void); diff --git a/include/tcg/tcg-opc.h b/include/tcg/tcg-opc.h index b80227fa1c..3b7cb2bce1 100644 --- a/include/tcg/tcg-opc.h +++ b/include/tcg/tcg-opc.h @@ -197,6 +197,7 @@ DEF(exit_tb, 0, 0, 1, TCG_OPF_BB_EXIT | TCG_OPF_BB_END) DEF(goto_tb, 0, 0, 1, TCG_OPF_BB_EXIT | TCG_OPF_BB_END) DEF(goto_ptr, 0, 1, 0, TCG_OPF_BB_EXIT | TCG_OPF_BB_END) +DEF(plugin_cb, 0, 0, 1, TCG_OPF_NOT_PRESENT) DEF(plugin_cb_start, 0, 0, 3, TCG_OPF_NOT_PRESENT) DEF(plugin_cb_end, 0, 0, 0, TCG_OPF_NOT_PRESENT) diff --git a/accel/tcg/plugin-gen.c b/accel/tcg/plugin-gen.c index 4b488943ff..4b02c0bfbf 100644 --- a/accel/tcg/plugin-gen.c +++ b/accel/tcg/plugin-gen.c @@ -201,8 +201,7 @@ static 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); + tcg_gen_plugin_cb(from); break; case PLUGIN_GEN_FROM_INSN: /* @@ -608,16 +607,6 @@ static void inject_mem_enable_helper(struct qemu_plugin_tb *ptb, 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) { @@ -703,11 +692,14 @@ static void plugin_gen_enable_mem_helper(struct qemu_plugin_tb *ptb, inject_mem_enable_helper(ptb, insn, begin_op); } -static void plugin_gen_disable_mem_helper(struct qemu_plugin_tb *ptb, - TCGOp *begin_op, int insn_idx) +static void gen_disable_mem_helper(struct qemu_plugin_tb *ptb, + struct qemu_plugin_insn *insn) { - struct qemu_plugin_insn *insn = g_ptr_array_index(ptb->insns, insn_idx); - inject_mem_disable_helper(insn, begin_op); + if (insn->mem_helper) { + tcg_gen_st_ptr(tcg_constant_ptr(0), tcg_env, + offsetof(CPUState, plugin_mem_cbs) - + offsetof(ArchCPU, env)); + } } /* #define DEBUG_PLUGIN_GEN_OPS */ @@ -766,16 +758,49 @@ static void pr_ops(void) static void plugin_gen_inject(struct qemu_plugin_tb *plugin_tb) { - TCGOp *op; + TCGOp *op, *next; int insn_idx = -1; pr_ops(); - QTAILQ_FOREACH(op, &tcg_ctx->ops, link) { + /* + * While injecting code, we cannot afford to reuse any ebb temps + * that might be live within the existing opcode stream. + * The simplest solution is to release them all and create new. + */ + memset(tcg_ctx->free_temps, 0, sizeof(tcg_ctx->free_temps)); + + QTAILQ_FOREACH_SAFE(op, &tcg_ctx->ops, link, next) { switch (op->opc) { case INDEX_op_insn_start: insn_idx++; break; + + case INDEX_op_plugin_cb: + { + enum plugin_gen_from from = op->args[0]; + struct qemu_plugin_insn *insn = NULL; + + if (insn_idx >= 0) { + insn = g_ptr_array_index(plugin_tb->insns, insn_idx); + } + + tcg_ctx->emit_before_op = op; + + switch (from) { + case PLUGIN_GEN_AFTER_INSN: + assert(insn != NULL); + gen_disable_mem_helper(plugin_tb, insn); + break; + default: + g_assert_not_reached(); + } + + tcg_ctx->emit_before_op = NULL; + tcg_op_remove(tcg_ctx, op); + break; + } + case INDEX_op_plugin_cb_start: { enum plugin_gen_from from = op->args[0]; @@ -840,19 +865,6 @@ static void plugin_gen_inject(struct qemu_plugin_tb *plugin_tb) break; } - case PLUGIN_GEN_AFTER_INSN: - { - g_assert(insn_idx >= 0); - - switch (type) { - case PLUGIN_GEN_DISABLE_MEM_HELPER: - plugin_gen_disable_mem_helper(plugin_tb, op, insn_idx); - break; - default: - g_assert_not_reached(); - } - break; - } default: g_assert_not_reached(); } diff --git a/tcg/tcg-op.c b/tcg/tcg-op.c index aa6bc6f57d..0f2026c91c 100644 --- a/tcg/tcg-op.c +++ b/tcg/tcg-op.c @@ -312,6 +312,11 @@ void tcg_gen_mb(TCGBar mb_type) } } +void tcg_gen_plugin_cb(unsigned from) +{ + tcg_gen_op1(INDEX_op_plugin_cb, from); +} + void tcg_gen_plugin_cb_start(unsigned from, unsigned type, unsigned wr) { tcg_gen_op3(INDEX_op_plugin_cb_start, from, type, wr); From patchwork Thu Apr 4 23:05:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 785846 Delivered-To: patch@linaro.org Received: by 2002:adf:f001:0:b0:33e:7753:30bd with SMTP id j1csp1074098wro; Thu, 4 Apr 2024 16:07:50 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCU6rHjqtbfzMG9jVaLvN6/T7ikvG7rLEfAB9vugXC89M6h41ww8CHLQVx6FMK3JlBfFAJ/Ct5m7rIshr5B3vYdi X-Google-Smtp-Source: AGHT+IHcqwo06C0tKjq8hrv9uOUpqjAVxEWAA4u5MDhyjtwmu3IBNKD1NKLpLIRzodO9g2xPCj3n X-Received: by 2002:a05:6214:23cf:b0:699:a2d:d794 with SMTP id hr15-20020a05621423cf00b006990a2dd794mr4047001qvb.50.1712272070186; Thu, 04 Apr 2024 16:07:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712272070; cv=none; d=google.com; s=arc-20160816; b=lsqqSWzmXj3q0WQOn2SzQRdHUs1AlsKdhXGqgme3cfUClEcfNuQhiXumFO9LC2WwA4 BGcSXVhSjqev6xmdIo4oMHHN83l3uJzT4o47QMwPi6hIjPnhNPA2dH9gBEensN/cPik5 /bPEUf9E1tN5+IimMPRk3ya5/lwcsiE2lx4EQqAlRNL/LZdEf5mPWEVX93FYaQlEg+2X PeFxsVVx3xCRlOl1vIAW/HLrnuIYxDSMApAYPDkJUL5wuOvNrYYvhEp6//ZJYlLqRiEF i+Jdoz3NBv/74oktmvQEpH/n+uS18QK2zh6BjOgkf/OdUQ++LNYwzpMYJ5cMWME9t07i klUQ== 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:to:from :dkim-signature; bh=XIrzr8Gj4slMnxdZrOrVhobtdoNtfeTg1wHY9Xb2+Ms=; fh=PnYt+qEB9tAfMKoqBm2xjKOFpYyFFGPudh5cVIoieJM=; b=fucNOTTQvt2Phy1aeObPMuTkEWXz+0aRN0IMWiWpTrsAFKVVlKPB2KfitzhoYI7srL kv7Sb6Z+j8RigTsBUo5aOOw/dzxrqAWZffO5rXvkdCLnmcTWjFogqFIvahLg7buyLwM3 M/aSWdTEQnIe8j7WlnCThYIF3p230Yjdu+V7m8wOV7rzpaahZ118tnfvcZ5BwOmBc14S 9sf2XM03hQUQJuPB8BNj55rAxpgjFCH42G0fD8R2M/nd3S8weOSqI5Q/5w/Q7o+Z/VqG MsAuLKQfQofJC6K9+5uyRY2G3OhI0VsggW2uKe0S7UGyixwUjy4ABP0GMvQLN0NaSdSH F2yw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LcclhzqW; 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 i11-20020a0cfccb000000b0068fc588ca99si407419qvq.476.2024.04.04.16.07.49 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 04 Apr 2024 16:07:50 -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=LcclhzqW; 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 1rsWAI-00023D-HR; Thu, 04 Apr 2024 19:06:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rsWA7-00021U-I1 for qemu-devel@nongnu.org; Thu, 04 Apr 2024 19:06:27 -0400 Received: from mail-pg1-x530.google.com ([2607:f8b0:4864:20::530]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rsWA5-0007jH-KF for qemu-devel@nongnu.org; Thu, 04 Apr 2024 19:06:27 -0400 Received: by mail-pg1-x530.google.com with SMTP id 41be03b00d2f7-5dbf7b74402so1096815a12.0 for ; Thu, 04 Apr 2024 16:06:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712271984; x=1712876784; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=XIrzr8Gj4slMnxdZrOrVhobtdoNtfeTg1wHY9Xb2+Ms=; b=LcclhzqWxXTzEm9jSzU84FpKQ6Sk+BsNcWbrbijea8HBmAYI4SQiVAnAC4z33ADUFO 0ulJU/BJHF5Xhf4S+0yK4hoOYOc0TpytYo86c2pLlWCp/akwRFImOSQbX2wywJJ/fF6D dbJTfNo5pZCAz3SgiW0mZtHtIMfRQbyp11KrDWpyKXe3C1gU210OXzGVxJ5WsSRe+6wn n2ljbcF5O4iVjdgzobILFQb3xpA3vfScQPcdIWoLhE0129KxzaXVeSad1aQWpTkn+S4T vj/knjsAyA/rwA58iHMDrXDEnlS3a2Az3HX/EhmUTZSeq2yqThFSKIpX5SgLaJOpPcOG 7rFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712271984; x=1712876784; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=XIrzr8Gj4slMnxdZrOrVhobtdoNtfeTg1wHY9Xb2+Ms=; b=ZmEBeh32Dwjajj9Gp2aj9siQV61kIIeNIRVPiDyhoSic+6NSYvoTKmjg5dO4XClRle xLxMMGDDq597D19Wp4FWQ7zSCeY6X7xFgG7l9FGE0yvRsdeVXVLneR1tDfgIJsP92615 Mv0vu6ARqJN1F7ny18MIM7Fk/5FK3Rzv6sw7mtAYA1lu020A13C/47XYomKAzqB2PNBI rjkHAqNaitSlIZNR88/1BwW1sEtTFqUP3ii/ObQ97E3TSdEgR+dCtSPAto6DPs64WUTH YNyagkEsYGBsGSiF2HsulfU2j8WG+N4FxvqSXNy4k1Tgkl59eYdcaJFk/NZkQQPx1w9S jFLw== X-Gm-Message-State: AOJu0YyzjUiqDOIPiSfqET/iT9lgmi0hplTGqAUOKrH8x0rGLC3WTZEi lkbBtkQUXRjiHCobkW12EAlRxxxkBb+P+SqiPnWSy3w3ser8p6pYva6sqH4TM1hwqzRLnmw4E8r N X-Received: by 2002:a17:90a:9a4:b0:2a2:dcbd:9f01 with SMTP id 33-20020a17090a09a400b002a2dcbd9f01mr2774227pjo.38.1712271984242; Thu, 04 Apr 2024 16:06:24 -0700 (PDT) Received: from stoup.. (098-147-007-212.res.spectrum.com. [98.147.7.212]) by smtp.gmail.com with ESMTPSA id q36-20020a17090a17a700b002a2f3cfc92asm1052592pja.16.2024.04.04.16.06.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Apr 2024 16:06:23 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 08/21] plugins: Use emit_before_op for PLUGIN_GEN_FROM_TB Date: Thu, 4 Apr 2024 13:05:58 -1000 Message-Id: <20240404230611.21231-9-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240404230611.21231-1-richard.henderson@linaro.org> References: <20240404230611.21231-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::530; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x530.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org By having the qemu_plugin_cb_flags be recorded in the TCGHelperInfo, we no longer need to distinguish PLUGIN_CB_REGULAR from PLUGIN_CB_REGULAR_R, so place all TB callbacks in the same queue. Signed-off-by: Richard Henderson --- accel/tcg/plugin-gen.c | 96 +++++++++++++++++++++++++----------------- plugins/api.c | 6 +-- 2 files changed, 58 insertions(+), 44 deletions(-) diff --git a/accel/tcg/plugin-gen.c b/accel/tcg/plugin-gen.c index 4b02c0bfbf..c803fe8e96 100644 --- a/accel/tcg/plugin-gen.c +++ b/accel/tcg/plugin-gen.c @@ -201,6 +201,7 @@ static void plugin_gen_empty_callback(enum plugin_gen_from from) { switch (from) { case PLUGIN_GEN_AFTER_INSN: + case PLUGIN_GEN_FROM_TB: tcg_gen_plugin_cb(from); break; case PLUGIN_GEN_FROM_INSN: @@ -210,8 +211,6 @@ static void plugin_gen_empty_callback(enum plugin_gen_from from) */ 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_no_rwg); gen_wrapped(from, PLUGIN_GEN_CB_UDATA_R, gen_empty_udata_cb_no_wg); gen_wrapped(from, PLUGIN_GEN_CB_INLINE, gen_empty_inline_cb); @@ -626,24 +625,6 @@ void plugin_gen_disable_mem_helpers(void) offsetof(CPUState, plugin_mem_cbs) - offsetof(ArchCPU, env)); } -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_udata_r(const struct qemu_plugin_tb *ptb, - TCGOp *begin_op) -{ - inject_udata_cb(ptb->cbs[PLUGIN_CB_REGULAR_R], 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) { @@ -702,6 +683,41 @@ static void gen_disable_mem_helper(struct qemu_plugin_tb *ptb, } } +static void gen_udata_cb(struct qemu_plugin_dyn_cb *cb) +{ + TCGv_i32 cpu_index = tcg_temp_ebb_new_i32(); + + tcg_gen_ld_i32(cpu_index, tcg_env, + -offsetof(ArchCPU, env) + offsetof(CPUState, cpu_index)); + tcg_gen_call2(cb->regular.f.vcpu_udata, cb->regular.info, NULL, + tcgv_i32_temp(cpu_index), + tcgv_ptr_temp(tcg_constant_ptr(cb->userp))); + tcg_temp_free_i32(cpu_index); +} + +static void gen_inline_cb(struct qemu_plugin_dyn_cb *cb) +{ + GArray *arr = cb->inline_insn.entry.score->data; + size_t offset = cb->inline_insn.entry.offset; + TCGv_i32 cpu_index = tcg_temp_ebb_new_i32(); + TCGv_i64 val = tcg_temp_ebb_new_i64(); + TCGv_ptr ptr = tcg_temp_ebb_new_ptr(); + + tcg_gen_ld_i32(cpu_index, tcg_env, + -offsetof(ArchCPU, env) + offsetof(CPUState, cpu_index)); + tcg_gen_muli_i32(cpu_index, cpu_index, g_array_get_element_size(arr)); + tcg_gen_ext_i32_ptr(ptr, cpu_index); + tcg_temp_free_i32(cpu_index); + + tcg_gen_addi_ptr(ptr, ptr, (intptr_t)arr->data); + tcg_gen_ld_i64(val, ptr, offset); + tcg_gen_addi_i64(val, val, cb->inline_insn.imm); + tcg_gen_st_i64(val, ptr, offset); + + tcg_temp_free_i64(val); + tcg_temp_free_ptr(ptr); +} + /* #define DEBUG_PLUGIN_GEN_OPS */ static void pr_ops(void) { @@ -780,6 +796,8 @@ static void plugin_gen_inject(struct qemu_plugin_tb *plugin_tb) { enum plugin_gen_from from = op->args[0]; struct qemu_plugin_insn *insn = NULL; + const GArray *cbs; + int i, n; if (insn_idx >= 0) { insn = g_ptr_array_index(plugin_tb->insns, insn_idx); @@ -792,6 +810,25 @@ static void plugin_gen_inject(struct qemu_plugin_tb *plugin_tb) assert(insn != NULL); gen_disable_mem_helper(plugin_tb, insn); break; + + case PLUGIN_GEN_FROM_TB: + assert(insn == NULL); + + cbs = plugin_tb->cbs[PLUGIN_CB_REGULAR]; + for (i = 0, n = (cbs ? cbs->len : 0); i < n; i++) { + struct qemu_plugin_dyn_cb *cb = + &g_array_index(cbs, struct qemu_plugin_dyn_cb, i); + gen_udata_cb(cb); + } + + cbs = plugin_tb->cbs[PLUGIN_CB_INLINE]; + for (i = 0, n = (cbs ? cbs->len : 0); i < n; i++) { + struct qemu_plugin_dyn_cb *cb = + &g_array_index(cbs, struct qemu_plugin_dyn_cb, i); + gen_inline_cb(cb); + } + break; + default: g_assert_not_reached(); } @@ -807,25 +844,6 @@ static void plugin_gen_inject(struct qemu_plugin_tb *plugin_tb) enum plugin_gen_cb type = op->args[1]; switch (from) { - case PLUGIN_GEN_FROM_TB: - { - g_assert(insn_idx == -1); - - switch (type) { - case PLUGIN_GEN_CB_UDATA: - plugin_gen_tb_udata(plugin_tb, op); - break; - case PLUGIN_GEN_CB_UDATA_R: - plugin_gen_tb_udata_r(plugin_tb, op); - break; - case PLUGIN_GEN_CB_INLINE: - plugin_gen_tb_inline(plugin_tb, op); - break; - default: - g_assert_not_reached(); - } - break; - } case PLUGIN_GEN_FROM_INSN: { g_assert(insn_idx >= 0); diff --git a/plugins/api.c b/plugins/api.c index 8fa5a600ac..5d119e8049 100644 --- a/plugins/api.c +++ b/plugins/api.c @@ -92,11 +92,7 @@ void qemu_plugin_register_vcpu_tb_exec_cb(struct qemu_plugin_tb *tb, void *udata) { if (!tb->mem_only) { - int index = flags == QEMU_PLUGIN_CB_R_REGS || - flags == QEMU_PLUGIN_CB_RW_REGS ? - PLUGIN_CB_REGULAR_R : PLUGIN_CB_REGULAR; - - plugin_register_dyn_cb__udata(&tb->cbs[index], + plugin_register_dyn_cb__udata(&tb->cbs[PLUGIN_CB_REGULAR], cb, flags, udata); } } From patchwork Thu Apr 4 23:05:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 785842 Delivered-To: patch@linaro.org Received: by 2002:adf:f001:0:b0:33e:7753:30bd with SMTP id j1csp1074017wro; Thu, 4 Apr 2024 16:07:37 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCW78ceGCslP3njRtvNPCdD3cPROYJPTGtr4+9Z+MPc0caVfoYvCEYHMdeDWlCFaWOdcT25LusY3TtfDWrEsbRf5 X-Google-Smtp-Source: AGHT+IHfkeDpaSsc7Ps+GmZnkN6/xjz9gpbAThZ7BWoCNslILGXPU8/c4GcDGMOYI9f4LQaLhbqj X-Received: by 2002:ac8:5742:0:b0:432:e325:2c27 with SMTP id 2-20020ac85742000000b00432e3252c27mr1317602qtx.52.1712272057009; Thu, 04 Apr 2024 16:07:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712272056; cv=none; d=google.com; s=arc-20160816; b=l359VRuVhmCU0PN9EO9Ji77JIWdGCeNq1SEmO9978U1KuaQOmKOO7siBjZc/iDAa/K jlbVrVc7fqgtGIKafE4fEhv2xFJ+VASx06Gqbl3pvQGY+ufhtw+UXZ+G1PNc28pyZLu/ GdbzFC1Zi1O/P6qHsWjfrWVDct1eQwj+SECD3RGBekXsCJfjgo1ATFEx6F66qzbJaGNt MBtLMfMe3AowFfT96Z9IcUhITXzi3yvLfmHZ4KlvF5pBI//zUf5fjm+bCaB6FQgn/aDM yHNdmDfanX9IncyttJoGy9yIaUN6sxcui/fdGEQahtMUQzoDyCBarmVJ0dujFdAdbwk/ tWjA== 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=6NiZ3HGz3Hc6pId3zVyG1cXL7lbYUMaIMlfQHI2GKrk=; fh=vm85eyWrvOAHduw3sqEA+cYBqvHB7M0MHFcRJg7VWOo=; b=vc9Bu6OPNZlS2zArVyeNLOD8RlyGYn85micaK+XfYeZO4F4U36A/Sjs+E6+XKAzLpy Q/gUqaP3QJNhYlHBkt4jbcnslkzhyxO9feDA1NBcrT5m2QHOk0m92D7YLXhaMDzhCTGk io/qOMShrvzxcVVG8WgmXTLm6zjGqGc37RoCTvCf42/wAxzlMqkkNQeJcqTm8oSZ4zbh 6WlVqnMotDLx9NOXCD5h+vFrDCmzkt5EM9RH686l8d18Ak5HCgclEFrooecgOmCQFy8G EPcoJCUXRihR9Qt/s1lPrjE6RiVFqi6S9WRVxBmCNGG5fywvt+qsdrVubaKLCid6sJwq Ue4A==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=rCCTP2zw; 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 g17-20020ac85d51000000b00432f4f733b8si434645qtx.52.2024.04.04.16.07.36 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 04 Apr 2024 16:07:36 -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=rCCTP2zw; 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 1rsWAD-00022o-14; Thu, 04 Apr 2024 19:06:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rsWA8-00022D-NF for qemu-devel@nongnu.org; Thu, 04 Apr 2024 19:06:28 -0400 Received: from mail-pj1-x102d.google.com ([2607:f8b0:4864:20::102d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rsWA6-0007jp-UV for qemu-devel@nongnu.org; Thu, 04 Apr 2024 19:06:28 -0400 Received: by mail-pj1-x102d.google.com with SMTP id 98e67ed59e1d1-2a07b092c4fso1232885a91.0 for ; Thu, 04 Apr 2024 16:06:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712271985; x=1712876785; 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=6NiZ3HGz3Hc6pId3zVyG1cXL7lbYUMaIMlfQHI2GKrk=; b=rCCTP2zwJvm18oRXgEFscdvyGX57x5QUf+fhHUK7aHK87NFXdLCtYa215hquSP6Zwc I/W1mHDsmyXk9+Lsx8NzzDhK2kH3TLdOPyn1NLRjTHHCIwY3Af4wK5dI7jX4/2yYVzHF rccri7misYY0GOdPwhOgzpZ1EqvJZ3yf3rSSgtyvuZP8a+RFMijAq8bKu+tZdO1I5Ax9 /yIVtF2WP5QHzc8C3iyesn+gtAPXVd7eIf2rfwKrqhzduvE6iahThiqSmHNJeGDzjdAh k6kLZCVFszdle5Wu70Vf1u6Nc2Y9ExcJsP6y2wWfgi2fOcFtFbRKMZ2LUi042N1OjnLK sePw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712271985; x=1712876785; 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=6NiZ3HGz3Hc6pId3zVyG1cXL7lbYUMaIMlfQHI2GKrk=; b=KEM9daKXV5mq9qmNp56udsylDuPbUzVxMvoy2GCKvu9HYNuVV+vfIfWhY5kFavGJB5 0euoEea6gl/BpPejnbUN2JJIJQU2NdlO3Knt9aSUakyJ6FH/e4U1AeYRwfAekJU6Z51t 7e0QZEIitgcQWBx3Fn1D5y2ks60O90HmAVRGrCn4MyXMVbIJfWi/47vAY2RjXEfd3dvZ i4XiUW9MbbMOKeu6Yuc3NrR+Ve8lHRG8xMxMhSrlxRZz88J7ogvXqTdNIYykh+Q3+oQ9 Uo1F6M337tHRoLsAC9lwMWo8IvksJBjqX4rlXCn1I83l6tYvMu0d2R2CGZyLetS0ed5w NHdw== X-Gm-Message-State: AOJu0YzkXfIhkUjKOYgrHW73EAhzyPcMVasvCyRlXKQIk4paK7bKygBn CPQbOEZ19mVdlxmUsK1+eReP9l/zU2rFI59q7WdR9zt9HSO0qbXPQAprpqfrMEQ98sC70Mclb5+ k X-Received: by 2002:a17:90a:15c9:b0:29f:67ad:7db0 with SMTP id w9-20020a17090a15c900b0029f67ad7db0mr1124772pjd.11.1712271985670; Thu, 04 Apr 2024 16:06:25 -0700 (PDT) Received: from stoup.. (098-147-007-212.res.spectrum.com. [98.147.7.212]) by smtp.gmail.com with ESMTPSA id q36-20020a17090a17a700b002a2f3cfc92asm1052592pja.16.2024.04.04.16.06.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Apr 2024 16:06:25 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Pierrick Bouvier Subject: [PATCH v2 09/21] plugins: Add PLUGIN_GEN_AFTER_TB Date: Thu, 4 Apr 2024 13:05:59 -1000 Message-Id: <20240404230611.21231-10-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240404230611.21231-1-richard.henderson@linaro.org> References: <20240404230611.21231-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::102d; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102d.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Delay test of plugin_tb->mem_helper until the inject pass. Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- accel/tcg/plugin-gen.c | 37 ++++++++++++++++--------------------- 1 file changed, 16 insertions(+), 21 deletions(-) diff --git a/accel/tcg/plugin-gen.c b/accel/tcg/plugin-gen.c index c803fe8e96..1faa49cb8f 100644 --- a/accel/tcg/plugin-gen.c +++ b/accel/tcg/plugin-gen.c @@ -69,6 +69,7 @@ enum plugin_gen_from { PLUGIN_GEN_FROM_INSN, PLUGIN_GEN_FROM_MEM, PLUGIN_GEN_AFTER_INSN, + PLUGIN_GEN_AFTER_TB, PLUGIN_GEN_N_FROMS, }; @@ -609,20 +610,9 @@ static void inject_mem_enable_helper(struct qemu_plugin_tb *ptb, /* called before finishing a TB with exit_tb, goto_tb or goto_ptr */ void plugin_gen_disable_mem_helpers(void) { - /* - * We could emit the clearing unconditionally and be done. However, this can - * be wasteful if for instance plugins don't track memory accesses, or if - * most TBs don't use helpers. Instead, emit the clearing iff the TB calls - * helpers that might access guest memory. - * - * Note: we do not reset plugin_tb->mem_helper here; a TB might have several - * exit points, and we want to emit the clearing from all of them. - */ - if (!tcg_ctx->plugin_tb->mem_helper) { - return; + if (tcg_ctx->plugin_insn) { + tcg_gen_plugin_cb(PLUGIN_GEN_AFTER_TB); } - tcg_gen_st_ptr(tcg_constant_ptr(NULL), tcg_env, - offsetof(CPUState, plugin_mem_cbs) - offsetof(ArchCPU, env)); } static void plugin_gen_insn_udata(const struct qemu_plugin_tb *ptb, @@ -673,14 +663,11 @@ static void plugin_gen_enable_mem_helper(struct qemu_plugin_tb *ptb, inject_mem_enable_helper(ptb, insn, begin_op); } -static void gen_disable_mem_helper(struct qemu_plugin_tb *ptb, - struct qemu_plugin_insn *insn) +static void gen_disable_mem_helper(void) { - if (insn->mem_helper) { - tcg_gen_st_ptr(tcg_constant_ptr(0), tcg_env, - offsetof(CPUState, plugin_mem_cbs) - - offsetof(ArchCPU, env)); - } + tcg_gen_st_ptr(tcg_constant_ptr(0), tcg_env, + offsetof(CPUState, plugin_mem_cbs) - + offsetof(ArchCPU, env)); } static void gen_udata_cb(struct qemu_plugin_dyn_cb *cb) @@ -806,9 +793,17 @@ static void plugin_gen_inject(struct qemu_plugin_tb *plugin_tb) tcg_ctx->emit_before_op = op; switch (from) { + case PLUGIN_GEN_AFTER_TB: + if (plugin_tb->mem_helper) { + gen_disable_mem_helper(); + } + break; + case PLUGIN_GEN_AFTER_INSN: assert(insn != NULL); - gen_disable_mem_helper(plugin_tb, insn); + if (insn->mem_helper) { + gen_disable_mem_helper(); + } break; case PLUGIN_GEN_FROM_TB: From patchwork Thu Apr 4 23:06:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 785847 Delivered-To: patch@linaro.org Received: by 2002:adf:f001:0:b0:33e:7753:30bd with SMTP id j1csp1074104wro; Thu, 4 Apr 2024 16:07:52 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUCO8nDzkxj+ZLrK0/J7v1woO9b+GEh26xwkwSDM9BaFKN2y87DJfWUb4NRz/DncBJkZziZurZCB8p41aAjQ+6Y X-Google-Smtp-Source: AGHT+IFG41vUCWTuF/L+2RykkicWgeYNIsDkseivUaHtj+PMdT7twhm73e2iHQKP3lpx//Y3of99 X-Received: by 2002:a05:620a:1662:b0:78d:2f63:21fc with SMTP id d2-20020a05620a166200b0078d2f6321fcmr1069890qko.41.1712272072036; Thu, 04 Apr 2024 16:07:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712272072; cv=none; d=google.com; s=arc-20160816; b=d+tYNTBOBroa1MBGf0smW7RUMvkoMKZpykpYHl8kpS6rs/ZH9/Qy93HvU0w+aD4tb2 Ai947f6gUJVoBciayZBhPrGMfyKSj7wHCZy0/CMVA9BFzZk4Eg5Kda2K9b1j28c/uHp3 e84WukUi1xmL9mUpQ5gqzPq7kAcn1FPBV5Jt2xbMW3FK42dQHk5iTLWmJDf8UFpuf5fE 21xHzQCbYCePP6iXkdG3vJ/7tosRfwy6fc+guUOPzcTvQ1h6F/RlCi5mqsFwBLMUdhIo xljkbcUorqQqw0VwyV3Zf0jQY39qpq9tXIBAxKN/p6JKEAsBV++b9Ra6LmTagdAoNZdz n0jQ== 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=P/qL7hPT5BRbOA8liuFR3tQMzphxIlFBB93p3SZvf90=; fh=vm85eyWrvOAHduw3sqEA+cYBqvHB7M0MHFcRJg7VWOo=; b=bXKsd7CeWMW+bdyMMTqFxvAfTUtA6QRDgxRG9QBL4bYXXRXaFgQ5/Oa2oZ7Secopq6 4eAz9oLeVLdHrtVQlGDGS0PGU0V1orD6U0lO75K/291u+kytintdWBBnEEsUKFrrx+qB Hdwui26Hau2+pg+6HkfxqDYXAaHwghnKaDaI6y6fq+Nirw7jtdbxowAU18Ge2AdM/HhH u5l70xulG4xl4Nuse7uAETjlqPouh1oOR1jDLH6Ts1IOt/VOJfJvlbGy9o32IBRBVvOt hmGMn9gTMGAf3tnPEpgr+wmBCmSi1o0zzch1lWUUg25AqP65bJbqVqswzCtFHfTH8dbD 5Pkg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Z9doKMbk; 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 br20-20020a05620a461400b0078d46ddbc59si512403qkb.332.2024.04.04.16.07.51 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 04 Apr 2024 16:07:52 -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=Z9doKMbk; 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 1rsWAU-000288-Nz; Thu, 04 Apr 2024 19:06:50 -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 1rsWAC-00022d-EH for qemu-devel@nongnu.org; Thu, 04 Apr 2024 19:06:32 -0400 Received: from mail-pg1-x52b.google.com ([2607:f8b0:4864:20::52b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rsWA8-0007kK-Ae for qemu-devel@nongnu.org; Thu, 04 Apr 2024 19:06:30 -0400 Received: by mail-pg1-x52b.google.com with SMTP id 41be03b00d2f7-5d42e7ab8a9so1064612a12.3 for ; Thu, 04 Apr 2024 16:06:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712271987; x=1712876787; 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=P/qL7hPT5BRbOA8liuFR3tQMzphxIlFBB93p3SZvf90=; b=Z9doKMbkZnHlYmfawtCENOdqVqzWKgEQk+dcGcZJTUvfXd2G5U9OfZmcl83AMTI1s/ 2HsCHOmShzSk7zNvCMrTwqT4e/ek+wcG7K5RXJx5NOtfjNAL5R46GaVMi7agj130D9Tb XDWZN2xuDGSXRReo2TlnQVIMKr2ymyOXEn+Ow2K3FHo4h1VrCnzb0r8zY4tdtVpYnvYT SxKVFd+dRbjsKXFXIq3t8xG1U9yDcqzfDNviCkiF/NPJxJuxTYaTOljI+D0ZuAXvrtX2 aofJue0Tw8wPd2GsvaAnYIXkhdVvHcBr9YUClousHIkPgyeWeqyig53aYWSeJkGFz/NW AnBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712271987; x=1712876787; 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=P/qL7hPT5BRbOA8liuFR3tQMzphxIlFBB93p3SZvf90=; b=DIY4V8N5/Cw9csnc8f+7SvFRGlwRpA34kWaO+b1z4/5Jg1XcPYaud4hkHjK6uoTgKc rALbq3sZt4padSunaLKvDGQv6cA7nMj0dtftdm2hN6CegLJZ5odHUZjS4n6Iep83FHx5 toTI8dGEpBZ8kGAbtPZMui1++/EWIP7nm0c7G1Co7HzWu9D6+HX40B0/mGQjLXjt0Gsm iet18iu5dXTq2uHiwfWp2WrZX2YaHzVJj9e4xwQaitrnACVyg4ZLFBEyMRV3FsDVLaJO /L2RRzDroyQxt98JPGkbDd2fFqCxOlXLhoh9959wQRAHsxoq3d5xRrorZDajyrkRL0kl +S9w== X-Gm-Message-State: AOJu0YzrVXovoutsEsLzFl8vatTswoU880RFBjfGhvOjvYTsPdKA/nxr sOJXdtOraeP3c6f0w6WScO0nASQSLleUU5GJtYKFnWKbr7kHGvmGMNElg+89OHqY8LYomCPQSFB 8 X-Received: by 2002:a17:90b:118d:b0:2a2:648a:74fa with SMTP id gk13-20020a17090b118d00b002a2648a74famr1040200pjb.42.1712271987021; Thu, 04 Apr 2024 16:06:27 -0700 (PDT) Received: from stoup.. (098-147-007-212.res.spectrum.com. [98.147.7.212]) by smtp.gmail.com with ESMTPSA id q36-20020a17090a17a700b002a2f3cfc92asm1052592pja.16.2024.04.04.16.06.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Apr 2024 16:06:26 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Pierrick Bouvier Subject: [PATCH v2 10/21] plugins: Use emit_before_op for PLUGIN_GEN_FROM_INSN Date: Thu, 4 Apr 2024 13:06:00 -1000 Message-Id: <20240404230611.21231-11-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240404230611.21231-1-richard.henderson@linaro.org> References: <20240404230611.21231-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::52b; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x52b.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- include/qemu/plugin.h | 1 - accel/tcg/plugin-gen.c | 286 ++++++++++------------------------------- plugins/api.c | 8 +- 3 files changed, 67 insertions(+), 228 deletions(-) diff --git a/include/qemu/plugin.h b/include/qemu/plugin.h index 793c44f1f2..ee1c1b174a 100644 --- a/include/qemu/plugin.h +++ b/include/qemu/plugin.h @@ -73,7 +73,6 @@ enum plugin_dyn_cb_type { enum plugin_dyn_cb_subtype { PLUGIN_CB_REGULAR, - PLUGIN_CB_REGULAR_R, PLUGIN_CB_INLINE, PLUGIN_N_CB_SUBTYPES, }; diff --git a/accel/tcg/plugin-gen.c b/accel/tcg/plugin-gen.c index 1faa49cb8f..a3dd82df4b 100644 --- a/accel/tcg/plugin-gen.c +++ b/accel/tcg/plugin-gen.c @@ -98,30 +98,6 @@ void HELPER(plugin_vcpu_mem_cb)(unsigned int vcpu_index, void *userdata) { } -static void gen_empty_udata_cb(void (*gen_helper)(TCGv_i32, TCGv_ptr)) -{ - TCGv_i32 cpu_index = tcg_temp_ebb_new_i32(); - TCGv_ptr udata = tcg_temp_ebb_new_ptr(); - - tcg_gen_movi_ptr(udata, 0); - tcg_gen_ld_i32(cpu_index, tcg_env, - -offsetof(ArchCPU, env) + offsetof(CPUState, cpu_index)); - gen_helper(cpu_index, udata); - - tcg_temp_free_ptr(udata); - tcg_temp_free_i32(cpu_index); -} - -static void gen_empty_udata_cb_no_wg(void) -{ - gen_empty_udata_cb(gen_helper_plugin_vcpu_udata_cb_no_wg); -} - -static void gen_empty_udata_cb_no_rwg(void) -{ - gen_empty_udata_cb(gen_helper_plugin_vcpu_udata_cb_no_rwg); -} - /* * For now we only support addi_i64. * When we support more ops, we can generate one empty inline cb for each. @@ -170,51 +146,19 @@ static void gen_empty_mem_cb(TCGv_i64 addr, uint32_t info) tcg_temp_free_i32(cpu_index); } -/* - * 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 = tcg_temp_ebb_new_ptr(); - - tcg_gen_movi_ptr(ptr, 0); - tcg_gen_st_ptr(ptr, tcg_env, offsetof(CPUState, plugin_mem_cbs) - - offsetof(ArchCPU, env)); - tcg_temp_free_ptr(ptr); -} - static void gen_plugin_cb_start(enum plugin_gen_from from, enum plugin_gen_cb type, unsigned wr) { tcg_gen_plugin_cb_start(from, type, wr); } -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 void plugin_gen_empty_callback(enum plugin_gen_from from) { switch (from) { case PLUGIN_GEN_AFTER_INSN: case PLUGIN_GEN_FROM_TB: - tcg_gen_plugin_cb(from); - 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); - gen_wrapped(from, PLUGIN_GEN_CB_UDATA, gen_empty_udata_cb_no_rwg); - gen_wrapped(from, PLUGIN_GEN_CB_UDATA_R, gen_empty_udata_cb_no_wg); - gen_wrapped(from, PLUGIN_GEN_CB_INLINE, gen_empty_inline_cb); + tcg_gen_plugin_cb(from); break; default: g_assert_not_reached(); @@ -368,18 +312,6 @@ static TCGOp *copy_mul_i32(TCGOp **begin_op, TCGOp *op, uint32_t v) return op; } -static TCGOp *copy_st_ptr(TCGOp **begin_op, TCGOp *op) -{ - if (UINTPTR_MAX == UINT32_MAX) { - /* st_i32 */ - op = copy_op(begin_op, op, INDEX_op_st_i32); - } else { - /* st_i64 */ - op = copy_st_i64(begin_op, op); - } - return op; -} - static TCGOp *copy_call(TCGOp **begin_op, TCGOp *op, void *func, int *cb_idx) { TCGOp *old_op; @@ -403,32 +335,6 @@ static TCGOp *copy_call(TCGOp **begin_op, TCGOp *op, void *func, int *cb_idx) return op; } -/* - * When we append/replace ops here we are sensitive to changing patterns of - * TCGOps generated by the tcg_gen_FOO calls when we generated the - * empty callbacks. This will assert very quickly in a debug build as - * we assert the ops we are replacing are the correct ones. - */ -static TCGOp *append_udata_cb(const struct qemu_plugin_dyn_cb *cb, - TCGOp *begin_op, TCGOp *op, int *cb_idx) -{ - /* const_ptr */ - op = copy_const_ptr(&begin_op, op, cb->userp); - - /* copy the ld_i32, but note that we only have to copy it once */ - if (*cb_idx == -1) { - op = copy_op(&begin_op, op, INDEX_op_ld_i32); - } else { - begin_op = QTAILQ_NEXT(begin_op, link); - tcg_debug_assert(begin_op && begin_op->opc == INDEX_op_ld_i32); - } - - /* call */ - op = copy_call(&begin_op, op, cb->regular.f.vcpu_udata, cb_idx); - - return op; -} - static TCGOp *append_inline_cb(const struct qemu_plugin_dyn_cb *cb, TCGOp *begin_op, TCGOp *op, int *unused) @@ -482,11 +388,6 @@ 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; @@ -524,12 +425,6 @@ static void inject_cb_type(const GArray *cbs, TCGOp *begin_op, rm_ops_range(begin_op, end_op); } -static void -inject_udata_cb(const GArray *cbs, TCGOp *begin_op) -{ - inject_cb_type(cbs, begin_op, append_udata_cb, op_ok); -} - static void inject_inline_cb(const GArray *cbs, TCGOp *begin_op, op_ok_fn ok) { @@ -542,71 +437,6 @@ inject_mem_cb(const GArray *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, GArray *arr) -{ - TCGOp *orig_op = begin_op; - TCGOp *end_op; - TCGOp *op; - - end_op = find_op(begin_op, INDEX_op_plugin_cb_end); - tcg_debug_assert(end_op); - - /* const ptr */ - op = copy_const_ptr(&begin_op, end_op, arr); - - /* st_ptr */ - op = 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 descriptors, 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_tb *ptb, - struct qemu_plugin_insn *plugin_insn, - TCGOp *begin_op) -{ - GArray *cbs[2]; - GArray *arr; - size_t n_cbs, i; - - cbs[0] = plugin_insn->cbs[PLUGIN_CB_MEM][PLUGIN_CB_REGULAR]; - cbs[1] = plugin_insn->cbs[PLUGIN_CB_MEM][PLUGIN_CB_INLINE]; - - n_cbs = 0; - for (i = 0; i < ARRAY_SIZE(cbs); i++) { - n_cbs += cbs[i]->len; - } - - plugin_insn->mem_helper = plugin_insn->calls_helpers && n_cbs; - if (likely(!plugin_insn->mem_helper)) { - rm_ops(begin_op); - return; - } - ptb->mem_helper = true; - - arr = g_array_sized_new(false, false, - sizeof(struct qemu_plugin_dyn_cb), n_cbs); - - for (i = 0; i < ARRAY_SIZE(cbs); i++) { - g_array_append_vals(arr, cbs[i]->data, cbs[i]->len); - } - - qemu_plugin_add_dyn_cb_arr(arr); - inject_mem_helper(begin_op, arr); -} - /* called before finishing a TB with exit_tb, goto_tb or goto_ptr */ void plugin_gen_disable_mem_helpers(void) { @@ -615,30 +445,6 @@ void plugin_gen_disable_mem_helpers(void) } } -static void plugin_gen_insn_udata(const struct qemu_plugin_tb *ptb, - TCGOp *begin_op, int insn_idx) -{ - struct qemu_plugin_insn *insn = g_ptr_array_index(ptb->insns, insn_idx); - - inject_udata_cb(insn->cbs[PLUGIN_CB_INSN][PLUGIN_CB_REGULAR], begin_op); -} - -static void plugin_gen_insn_udata_r(const struct qemu_plugin_tb *ptb, - TCGOp *begin_op, int insn_idx) -{ - struct qemu_plugin_insn *insn = g_ptr_array_index(ptb->insns, insn_idx); - - inject_udata_cb(insn->cbs[PLUGIN_CB_INSN][PLUGIN_CB_REGULAR_R], begin_op); -} - -static void plugin_gen_insn_inline(const struct qemu_plugin_tb *ptb, - TCGOp *begin_op, int insn_idx) -{ - struct qemu_plugin_insn *insn = g_ptr_array_index(ptb->insns, insn_idx); - inject_inline_cb(insn->cbs[PLUGIN_CB_INSN][PLUGIN_CB_INLINE], - begin_op, op_ok); -} - static void plugin_gen_mem_regular(const struct qemu_plugin_tb *ptb, TCGOp *begin_op, int insn_idx) { @@ -656,11 +462,51 @@ static void plugin_gen_mem_inline(const struct qemu_plugin_tb *ptb, inject_inline_cb(cbs, begin_op, op_rw); } -static void plugin_gen_enable_mem_helper(struct qemu_plugin_tb *ptb, - TCGOp *begin_op, int insn_idx) +static void gen_enable_mem_helper(struct qemu_plugin_tb *ptb, + struct qemu_plugin_insn *insn) { - struct qemu_plugin_insn *insn = g_ptr_array_index(ptb->insns, insn_idx); - inject_mem_enable_helper(ptb, insn, begin_op); + GArray *cbs[2]; + GArray *arr; + size_t n_cbs; + + /* + * 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 + * descriptors, 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. + */ + if (!insn->calls_helpers) { + return; + } + + cbs[0] = insn->cbs[PLUGIN_CB_MEM][PLUGIN_CB_REGULAR]; + cbs[1] = insn->cbs[PLUGIN_CB_MEM][PLUGIN_CB_INLINE]; + n_cbs = cbs[0]->len + cbs[1]->len; + + if (n_cbs == 0) { + insn->mem_helper = false; + return; + } + insn->mem_helper = true; + ptb->mem_helper = true; + + arr = g_array_sized_new(false, false, + sizeof(struct qemu_plugin_dyn_cb), n_cbs); + g_array_append_vals(arr, cbs[0]->data, cbs[0]->len); + g_array_append_vals(arr, cbs[1]->data, cbs[1]->len); + + qemu_plugin_add_dyn_cb_arr(arr); + + tcg_gen_st_ptr(tcg_constant_ptr((intptr_t)arr), tcg_env, + offsetof(CPUState, plugin_mem_cbs) - + offsetof(ArchCPU, env)); } static void gen_disable_mem_helper(void) @@ -824,6 +670,26 @@ static void plugin_gen_inject(struct qemu_plugin_tb *plugin_tb) } break; + case PLUGIN_GEN_FROM_INSN: + assert(insn != NULL); + + gen_enable_mem_helper(plugin_tb, insn); + + cbs = insn->cbs[PLUGIN_CB_INSN][PLUGIN_CB_REGULAR]; + for (i = 0, n = (cbs ? cbs->len : 0); i < n; i++) { + struct qemu_plugin_dyn_cb *cb = + &g_array_index(cbs, struct qemu_plugin_dyn_cb, i); + gen_udata_cb(cb); + } + + cbs = insn->cbs[PLUGIN_CB_INSN][PLUGIN_CB_INLINE]; + for (i = 0, n = (cbs ? cbs->len : 0); i < n; i++) { + struct qemu_plugin_dyn_cb *cb = + &g_array_index(cbs, struct qemu_plugin_dyn_cb, i); + gen_inline_cb(cb); + } + break; + default: g_assert_not_reached(); } @@ -839,28 +705,6 @@ static void plugin_gen_inject(struct qemu_plugin_tb *plugin_tb) enum plugin_gen_cb type = op->args[1]; switch (from) { - case PLUGIN_GEN_FROM_INSN: - { - g_assert(insn_idx >= 0); - - switch (type) { - case PLUGIN_GEN_CB_UDATA: - plugin_gen_insn_udata(plugin_tb, op, insn_idx); - break; - case PLUGIN_GEN_CB_UDATA_R: - plugin_gen_insn_udata_r(plugin_tb, op, insn_idx); - break; - case PLUGIN_GEN_CB_INLINE: - plugin_gen_insn_inline(plugin_tb, op, insn_idx); - break; - case PLUGIN_GEN_ENABLE_MEM_HELPER: - plugin_gen_enable_mem_helper(plugin_tb, op, insn_idx); - break; - default: - g_assert_not_reached(); - } - break; - } case PLUGIN_GEN_FROM_MEM: { g_assert(insn_idx >= 0); diff --git a/plugins/api.c b/plugins/api.c index 5d119e8049..29cce2d97c 100644 --- a/plugins/api.c +++ b/plugins/api.c @@ -115,12 +115,8 @@ void qemu_plugin_register_vcpu_insn_exec_cb(struct qemu_plugin_insn *insn, void *udata) { if (!insn->mem_only) { - int index = flags == QEMU_PLUGIN_CB_R_REGS || - flags == QEMU_PLUGIN_CB_RW_REGS ? - PLUGIN_CB_REGULAR_R : PLUGIN_CB_REGULAR; - - plugin_register_dyn_cb__udata(&insn->cbs[PLUGIN_CB_INSN][index], - cb, flags, udata); + plugin_register_dyn_cb__udata( + &insn->cbs[PLUGIN_CB_INSN][PLUGIN_CB_REGULAR], cb, flags, udata); } } From patchwork Thu Apr 4 23:06:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 785853 Delivered-To: patch@linaro.org Received: by 2002:adf:f001:0:b0:33e:7753:30bd with SMTP id j1csp1074340wro; Thu, 4 Apr 2024 16:08:35 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCViLLluTwIWMN4kJcXLp5hm9SEwlXmInrWWDRKEjd4k2qG4HBUHxe5jz3Kcy5QjefNUKLCw2AIt95dubV5Mjw7z X-Google-Smtp-Source: AGHT+IHg7RCJesuRvvQ6ksJqe0YZVcq6mOqfqqJ7fMXG8sXQ22BCDdJPsaYaK+Z8J6C3qkdOlPlC X-Received: by 2002:a05:6214:2aa8:b0:699:2fd8:968 with SMTP id js8-20020a0562142aa800b006992fd80968mr1133629qvb.1.1712272115338; Thu, 04 Apr 2024 16:08:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712272115; cv=none; d=google.com; s=arc-20160816; b=X9l1aDCY8oM0gyvKSY6rbBgEHCr6mNjk2SvazDFSU8SLRe3dxQBAZXd4hB4ADVkesb 01PIpywAfrZj7c4GxjxAkj1W9KD1IJhyBqKSy1lGbw5b0KWe6jmgWpjWn1TXr/TZRafD dSuL0Gvp3bYKANGRhBkc0tUYq6EDjdLWlkySUU34T/X6qe1ge85fcx3HDpRdZqthbkUp njIhn9/+95ySPXmwRGzdzZg+McH92IgMa6PYdeOxnpaMO/rBULaDERay3r80wHN3VCwP ptT5j2FUF0F+UbDUuI0BelB1h7x2Wo9cgQQAKy/SXiqNLj63D6rAdNEpBHkcdYZOwkM4 Kyxw== 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=jJHHILIZeAXQQp3muG0Zx3EhXXpXgC+WOu9E4BLXxf0=; fh=vm85eyWrvOAHduw3sqEA+cYBqvHB7M0MHFcRJg7VWOo=; b=WiCuABznsCIKI6Nzy/aVefy4tLSiDPuX43DWr6DkQsxwVgzpBYqE16hfwek4zA1BAd seikHFZGkJz+I4pG5qOYsW9n5rcyTQqwF3iK1CsGjO/bd5AKrXb8877ZdU2NBk33zNW7 655j5veUO9X2HjwtvjXSKVL/jZAzYDBSgDxa0YV6s1Ix6hUnG4cf/kNKd3kWcw1pETJD ZR7Nlo/42zRnAsE6tn03NK7B2E8nP2Ial3GmvINQFlG+ljaRlPDq59T1EeDyEEh4kci2 NUNpKZk7S9CeFn61FMFjXb8Ssbcit41oACfdm9Y8ueRA/N94KuNtvZEl9G8hWAy/cFU/ rXsg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=XJ6H3smp; 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 n6-20020a0cdc86000000b006991179d6f6si450943qvk.46.2024.04.04.16.08.35 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 04 Apr 2024 16:08:35 -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=XJ6H3smp; 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 1rsWAW-00028g-Cv; Thu, 04 Apr 2024 19:06:52 -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 1rsWAE-000237-8l for qemu-devel@nongnu.org; Thu, 04 Apr 2024 19:06:34 -0400 Received: from mail-pj1-x1035.google.com ([2607:f8b0:4864:20::1035]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rsWA9-0007ko-Uo for qemu-devel@nongnu.org; Thu, 04 Apr 2024 19:06:32 -0400 Received: by mail-pj1-x1035.google.com with SMTP id 98e67ed59e1d1-2a2f82ded89so485885a91.1 for ; Thu, 04 Apr 2024 16:06:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712271988; x=1712876788; 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=jJHHILIZeAXQQp3muG0Zx3EhXXpXgC+WOu9E4BLXxf0=; b=XJ6H3smptko/LaYTm+ITUpq7U5mmNiNFX+Xvy5G/RhObLkFQEmdEZMHaSPb9TQMvsd 2lQ2k1zvYU9yzHTgkp8uGufGt3fsBFXEKuWTVFAj1+SeH9VzzF+dsXzjpJYLsPdzO32R nVsnjLa0jsRH/D3Haq9sJE+P1/0cJ2dVbLOnHoa3zVawWVL65Uo0lTR/hiIRMnsbUkpy nl+mBxqsEKASULJQNcVb9kFHW0oU5yp1i4zTKbQU7ZNPXUFQA78mMf/7HZkJoWSAmHJp DyvX3fc0SNegEieYpmG5aZZfNW+JOVIq0lXEkLHHnoRwziqtfZx4C++uOhbXea5a7PoG E5OA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712271988; x=1712876788; 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=jJHHILIZeAXQQp3muG0Zx3EhXXpXgC+WOu9E4BLXxf0=; b=TmhRn9PE3kWOPcSuxiUJ/vr4qZWEltHRyDvuHQC3z/TaIHyH0QubHW98ha0AZeGtqm 0p0ybMi0XcFF1DbUvG8LCH0DUVzTKnZkivvdDGYJeqTMMvLJ5c987+URzOHk+qkw11hg 03fk1NoVLy+3oilFh5Lg51Fg2gjoF3r6kwyW234xIXpXCExplQyCTPKjyTLbCvdqLHIz F+8QVCL1MpMbYku6PU5u0/bjPlAyL8+L/gHc5S5q0lmoClDnY5w8jpHieRrjratoiFxt a45ibLFICe68i1zwM5iTbr04IY0OGwxvJmpgRpaCUSr9FFh4EpFWwbCyGa4hZAYP2kjE v+HA== X-Gm-Message-State: AOJu0YxGue/TGaRh3PpEmqpFcs58rwYcHa489uwp09C6r2MdyiZF5Obk KkrltldxK8BC9SnXY+kJpSHU+jQ+2I36iQz+uTzhba2CN20sHdadDxKmaCszW+VnvTx1b9XcxvM X X-Received: by 2002:a17:90b:3595:b0:2a2:c127:5aed with SMTP id mm21-20020a17090b359500b002a2c1275aedmr1417466pjb.0.1712271988294; Thu, 04 Apr 2024 16:06:28 -0700 (PDT) Received: from stoup.. (098-147-007-212.res.spectrum.com. [98.147.7.212]) by smtp.gmail.com with ESMTPSA id q36-20020a17090a17a700b002a2f3cfc92asm1052592pja.16.2024.04.04.16.06.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Apr 2024 16:06:27 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Pierrick Bouvier Subject: [PATCH v2 11/21] plugins: Use emit_before_op for PLUGIN_GEN_FROM_MEM Date: Thu, 4 Apr 2024 13:06:01 -1000 Message-Id: <20240404230611.21231-12-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240404230611.21231-1-richard.henderson@linaro.org> References: <20240404230611.21231-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1035; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1035.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Introduce a new plugin_mem_cb op to hold the address temp and meminfo computed by tcg-op-ldst.c. Because this now has its own opcode, we no longer need PLUGIN_GEN_FROM_MEM. Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- include/exec/plugin-gen.h | 4 - include/tcg/tcg-op-common.h | 1 + include/tcg/tcg-opc.h | 1 + accel/tcg/plugin-gen.c | 408 ++++-------------------------------- tcg/tcg-op-ldst.c | 6 +- tcg/tcg-op.c | 5 + 6 files changed, 54 insertions(+), 371 deletions(-) diff --git a/include/exec/plugin-gen.h b/include/exec/plugin-gen.h index c4552b5061..f333f33198 100644 --- a/include/exec/plugin-gen.h +++ b/include/exec/plugin-gen.h @@ -25,7 +25,6 @@ void plugin_gen_insn_start(CPUState *cpu, const struct DisasContextBase *db); void plugin_gen_insn_end(void); void plugin_gen_disable_mem_helpers(void); -void plugin_gen_empty_mem_callback(TCGv_i64 addr, uint32_t info); #else /* !CONFIG_PLUGIN */ @@ -48,9 +47,6 @@ static inline void plugin_gen_tb_end(CPUState *cpu, size_t num_insns) static inline void plugin_gen_disable_mem_helpers(void) { } -static inline void plugin_gen_empty_mem_callback(TCGv_i64 addr, uint32_t info) -{ } - #endif /* CONFIG_PLUGIN */ #endif /* QEMU_PLUGIN_GEN_H */ diff --git a/include/tcg/tcg-op-common.h b/include/tcg/tcg-op-common.h index 9de5a7f280..72b80b20d0 100644 --- a/include/tcg/tcg-op-common.h +++ b/include/tcg/tcg-op-common.h @@ -75,6 +75,7 @@ void tcg_gen_goto_tb(unsigned idx); void tcg_gen_lookup_and_goto_ptr(void); void tcg_gen_plugin_cb(unsigned from); +void tcg_gen_plugin_mem_cb(TCGv_i64 addr, unsigned meminfo); void tcg_gen_plugin_cb_start(unsigned from, unsigned type, unsigned wr); void tcg_gen_plugin_cb_end(void); diff --git a/include/tcg/tcg-opc.h b/include/tcg/tcg-opc.h index 3b7cb2bce1..be9e36e386 100644 --- a/include/tcg/tcg-opc.h +++ b/include/tcg/tcg-opc.h @@ -198,6 +198,7 @@ DEF(goto_tb, 0, 0, 1, TCG_OPF_BB_EXIT | TCG_OPF_BB_END) DEF(goto_ptr, 0, 1, 0, TCG_OPF_BB_EXIT | TCG_OPF_BB_END) DEF(plugin_cb, 0, 0, 1, TCG_OPF_NOT_PRESENT) +DEF(plugin_mem_cb, 0, 1, 1, TCG_OPF_NOT_PRESENT) DEF(plugin_cb_start, 0, 0, 3, TCG_OPF_NOT_PRESENT) DEF(plugin_cb_end, 0, 0, 0, TCG_OPF_NOT_PRESENT) diff --git a/accel/tcg/plugin-gen.c b/accel/tcg/plugin-gen.c index a3dd82df4b..8f8ae156b6 100644 --- a/accel/tcg/plugin-gen.c +++ b/accel/tcg/plugin-gen.c @@ -67,7 +67,6 @@ enum plugin_gen_from { PLUGIN_GEN_FROM_TB, PLUGIN_GEN_FROM_INSN, - PLUGIN_GEN_FROM_MEM, PLUGIN_GEN_AFTER_INSN, PLUGIN_GEN_AFTER_TB, PLUGIN_GEN_N_FROMS, @@ -98,60 +97,6 @@ void HELPER(plugin_vcpu_mem_cb)(unsigned int vcpu_index, void *userdata) { } -/* - * 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_i32 cpu_index = tcg_temp_ebb_new_i32(); - TCGv_ptr cpu_index_as_ptr = tcg_temp_ebb_new_ptr(); - TCGv_i64 val = tcg_temp_ebb_new_i64(); - TCGv_ptr ptr = tcg_temp_ebb_new_ptr(); - - tcg_gen_ld_i32(cpu_index, tcg_env, - -offsetof(ArchCPU, env) + offsetof(CPUState, cpu_index)); - /* second operand will be replaced by immediate value */ - tcg_gen_mul_i32(cpu_index, cpu_index, cpu_index); - tcg_gen_ext_i32_ptr(cpu_index_as_ptr, cpu_index); - - tcg_gen_movi_ptr(ptr, 0); - tcg_gen_add_ptr(ptr, ptr, cpu_index_as_ptr); - tcg_gen_ld_i64(val, ptr, 0); - /* second operand will be replaced by immediate value */ - tcg_gen_add_i64(val, val, val); - - tcg_gen_st_i64(val, ptr, 0); - tcg_temp_free_ptr(ptr); - tcg_temp_free_i64(val); - tcg_temp_free_ptr(cpu_index_as_ptr); - tcg_temp_free_i32(cpu_index); -} - -static void gen_empty_mem_cb(TCGv_i64 addr, uint32_t info) -{ - TCGv_i32 cpu_index = tcg_temp_ebb_new_i32(); - TCGv_i32 meminfo = tcg_temp_ebb_new_i32(); - TCGv_ptr udata = tcg_temp_ebb_new_ptr(); - - tcg_gen_movi_i32(meminfo, info); - tcg_gen_movi_ptr(udata, 0); - tcg_gen_ld_i32(cpu_index, tcg_env, - -offsetof(ArchCPU, env) + offsetof(CPUState, cpu_index)); - - gen_helper_plugin_vcpu_mem_cb(cpu_index, meminfo, addr, udata); - - tcg_temp_free_ptr(udata); - tcg_temp_free_i32(meminfo); - tcg_temp_free_i32(cpu_index); -} - -static void gen_plugin_cb_start(enum plugin_gen_from from, - enum plugin_gen_cb type, unsigned wr) -{ - tcg_gen_plugin_cb_start(from, type, wr); -} - static void plugin_gen_empty_callback(enum plugin_gen_from from) { switch (from) { @@ -165,278 +110,6 @@ static void plugin_gen_empty_callback(enum plugin_gen_from from) } } -void plugin_gen_empty_mem_callback(TCGv_i64 addr, uint32_t info) -{ - enum qemu_plugin_mem_rw rw = get_plugin_meminfo_rw(info); - - gen_plugin_cb_start(PLUGIN_GEN_FROM_MEM, PLUGIN_GEN_CB_MEM, rw); - gen_empty_mem_cb(addr, info); - tcg_gen_plugin_cb_end(); - - gen_plugin_cb_start(PLUGIN_GEN_FROM_MEM, PLUGIN_GEN_CB_INLINE, rw); - gen_empty_inline_cb(); - tcg_gen_plugin_cb_end(); -} - -static TCGOp *find_op(TCGOp *op, TCGOpcode opc) -{ - while (op) { - if (op->opc == opc) { - return op; - } - op = QTAILQ_NEXT(op, link); - } - return NULL; -} - -static TCGOp *rm_ops_range(TCGOp *begin, TCGOp *end) -{ - TCGOp *ret = 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 = 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) -{ - TCGOp *old_op = QTAILQ_NEXT(*begin_op, link); - unsigned nargs = old_op->nargs; - - *begin_op = old_op; - op = tcg_op_insert_after(tcg_ctx, op, old_op->opc, nargs); - memcpy(op->args, old_op->args, sizeof(op->args[0]) * nargs); - - return op; -} - -static TCGOp *copy_op(TCGOp **begin_op, TCGOp *op, TCGOpcode opc) -{ - op = copy_op_nocheck(begin_op, op); - tcg_debug_assert((*begin_op)->opc == opc); - return op; -} - -static TCGOp *copy_const_ptr(TCGOp **begin_op, TCGOp *op, void *ptr) -{ - if (UINTPTR_MAX == UINT32_MAX) { - /* mov_i32 */ - op = copy_op(begin_op, op, INDEX_op_mov_i32); - op->args[1] = tcgv_i32_arg(tcg_constant_i32((uintptr_t)ptr)); - } else { - /* mov_i64 */ - op = copy_op(begin_op, op, INDEX_op_mov_i64); - op->args[1] = tcgv_i64_arg(tcg_constant_i64((uintptr_t)ptr)); - } - return op; -} - -static TCGOp *copy_ld_i32(TCGOp **begin_op, TCGOp *op) -{ - return copy_op(begin_op, op, INDEX_op_ld_i32); -} - -static TCGOp *copy_ext_i32_ptr(TCGOp **begin_op, TCGOp *op) -{ - if (UINTPTR_MAX == UINT32_MAX) { - op = copy_op(begin_op, op, INDEX_op_mov_i32); - } else { - op = copy_op(begin_op, op, INDEX_op_ext_i32_i64); - } - return op; -} - -static TCGOp *copy_add_ptr(TCGOp **begin_op, TCGOp *op) -{ - if (UINTPTR_MAX == UINT32_MAX) { - op = copy_op(begin_op, op, INDEX_op_add_i32); - } else { - op = copy_op(begin_op, op, INDEX_op_add_i64); - } - return op; -} - -static TCGOp *copy_ld_i64(TCGOp **begin_op, TCGOp *op) -{ - if (TCG_TARGET_REG_BITS == 32) { - /* 2x ld_i32 */ - op = copy_ld_i32(begin_op, op); - op = copy_ld_i32(begin_op, op); - } else { - /* ld_i64 */ - op = copy_op(begin_op, op, INDEX_op_ld_i64); - } - return op; -} - -static TCGOp *copy_st_i64(TCGOp **begin_op, TCGOp *op) -{ - if (TCG_TARGET_REG_BITS == 32) { - /* 2x st_i32 */ - op = copy_op(begin_op, op, INDEX_op_st_i32); - op = copy_op(begin_op, op, INDEX_op_st_i32); - } else { - /* st_i64 */ - op = copy_op(begin_op, op, INDEX_op_st_i64); - } - return op; -} - -static TCGOp *copy_add_i64(TCGOp **begin_op, TCGOp *op, uint64_t v) -{ - if (TCG_TARGET_REG_BITS == 32) { - /* all 32-bit backends must implement add2_i32 */ - g_assert(TCG_TARGET_HAS_add2_i32); - op = copy_op(begin_op, op, INDEX_op_add2_i32); - op->args[4] = tcgv_i32_arg(tcg_constant_i32(v)); - op->args[5] = tcgv_i32_arg(tcg_constant_i32(v >> 32)); - } else { - op = copy_op(begin_op, op, INDEX_op_add_i64); - op->args[2] = tcgv_i64_arg(tcg_constant_i64(v)); - } - return op; -} - -static TCGOp *copy_mul_i32(TCGOp **begin_op, TCGOp *op, uint32_t v) -{ - op = copy_op(begin_op, op, INDEX_op_mul_i32); - op->args[2] = tcgv_i32_arg(tcg_constant_i32(v)); - return op; -} - -static TCGOp *copy_call(TCGOp **begin_op, TCGOp *op, void *func, int *cb_idx) -{ - TCGOp *old_op; - int func_idx; - - /* copy all ops until the call */ - do { - op = copy_op_nocheck(begin_op, op); - } while (op->opc != INDEX_op_call); - - /* fill in the op call */ - old_op = *begin_op; - TCGOP_CALLI(op) = TCGOP_CALLI(old_op); - TCGOP_CALLO(op) = TCGOP_CALLO(old_op); - tcg_debug_assert(op->life == 0); - - func_idx = TCGOP_CALLO(op) + TCGOP_CALLI(op); - *cb_idx = func_idx; - op->args[func_idx] = (uintptr_t)func; - - return op; -} - -static TCGOp *append_inline_cb(const struct qemu_plugin_dyn_cb *cb, - TCGOp *begin_op, TCGOp *op, - int *unused) -{ - char *ptr = cb->inline_insn.entry.score->data->data; - size_t elem_size = g_array_get_element_size( - cb->inline_insn.entry.score->data); - size_t offset = cb->inline_insn.entry.offset; - - op = copy_ld_i32(&begin_op, op); - op = copy_mul_i32(&begin_op, op, elem_size); - op = copy_ext_i32_ptr(&begin_op, op); - op = copy_const_ptr(&begin_op, op, ptr + offset); - op = copy_add_ptr(&begin_op, op); - op = copy_ld_i64(&begin_op, op); - op = copy_add_i64(&begin_op, op, cb->inline_insn.imm); - op = copy_st_i64(&begin_op, op); - return op; -} - -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 = begin_op->args[1]; - - tcg_debug_assert(type == PLUGIN_GEN_CB_MEM); - - /* const_i32 == mov_i32 ("info", so it remains as is) */ - op = copy_op(&begin_op, op, INDEX_op_mov_i32); - - /* const_ptr */ - op = copy_const_ptr(&begin_op, op, cb->userp); - - /* copy the ld_i32, but note that we only have to copy it once */ - if (*cb_idx == -1) { - op = copy_op(&begin_op, op, INDEX_op_ld_i32); - } else { - begin_op = QTAILQ_NEXT(begin_op, link); - tcg_debug_assert(begin_op && begin_op->opc == INDEX_op_ld_i32); - } - - if (type == PLUGIN_GEN_CB_MEM) { - /* call */ - op = copy_call(&begin_op, op, cb->regular.f.vcpu_udata, 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_rw(const TCGOp *op, const struct qemu_plugin_dyn_cb *cb) -{ - int w; - - w = op->args[2]; - return !!(cb->rw & (w + 1)); -} - -static void inject_cb_type(const GArray *cbs, TCGOp *begin_op, - inject_fn inject, op_ok_fn ok) -{ - TCGOp *end_op; - TCGOp *op; - int cb_idx = -1; - int i; - - if (!cbs || cbs->len == 0) { - rm_ops(begin_op); - return; - } - - end_op = find_op(begin_op, INDEX_op_plugin_cb_end); - tcg_debug_assert(end_op); - - op = end_op; - for (i = 0; i < cbs->len; i++) { - struct qemu_plugin_dyn_cb *cb = - &g_array_index(cbs, struct qemu_plugin_dyn_cb, i); - - if (!ok(begin_op, cb)) { - continue; - } - op = inject(cb, begin_op, op, &cb_idx); - } - rm_ops_range(begin_op, end_op); -} - -static void -inject_inline_cb(const GArray *cbs, TCGOp *begin_op, op_ok_fn ok) -{ - inject_cb_type(cbs, begin_op, append_inline_cb, ok); -} - -static void -inject_mem_cb(const GArray *cbs, TCGOp *begin_op) -{ - inject_cb_type(cbs, begin_op, append_mem_cb, op_rw); -} - /* called before finishing a TB with exit_tb, goto_tb or goto_ptr */ void plugin_gen_disable_mem_helpers(void) { @@ -445,23 +118,6 @@ void plugin_gen_disable_mem_helpers(void) } } -static void plugin_gen_mem_regular(const struct qemu_plugin_tb *ptb, - TCGOp *begin_op, int insn_idx) -{ - struct qemu_plugin_insn *insn = g_ptr_array_index(ptb->insns, insn_idx); - inject_mem_cb(insn->cbs[PLUGIN_CB_MEM][PLUGIN_CB_REGULAR], begin_op); -} - -static void plugin_gen_mem_inline(const struct qemu_plugin_tb *ptb, - TCGOp *begin_op, int insn_idx) -{ - const GArray *cbs; - struct qemu_plugin_insn *insn = g_ptr_array_index(ptb->insns, insn_idx); - - cbs = insn->cbs[PLUGIN_CB_MEM][PLUGIN_CB_INLINE]; - inject_inline_cb(cbs, begin_op, op_rw); -} - static void gen_enable_mem_helper(struct qemu_plugin_tb *ptb, struct qemu_plugin_insn *insn) { @@ -551,6 +207,21 @@ static void gen_inline_cb(struct qemu_plugin_dyn_cb *cb) tcg_temp_free_ptr(ptr); } +static void gen_mem_cb(struct qemu_plugin_dyn_cb *cb, + qemu_plugin_meminfo_t meminfo, TCGv_i64 addr) +{ + TCGv_i32 cpu_index = tcg_temp_ebb_new_i32(); + + tcg_gen_ld_i32(cpu_index, tcg_env, + -offsetof(ArchCPU, env) + offsetof(CPUState, cpu_index)); + tcg_gen_call4(cb->regular.f.vcpu_mem, cb->regular.info, NULL, + tcgv_i32_temp(cpu_index), + tcgv_i32_temp(tcg_constant_i32(meminfo)), + tcgv_i64_temp(addr), + tcgv_ptr_temp(tcg_constant_ptr(cb->userp))); + tcg_temp_free_i32(cpu_index); +} + /* #define DEBUG_PLUGIN_GEN_OPS */ static void pr_ops(void) { @@ -699,34 +370,43 @@ static void plugin_gen_inject(struct qemu_plugin_tb *plugin_tb) break; } - case INDEX_op_plugin_cb_start: + case INDEX_op_plugin_mem_cb: { - enum plugin_gen_from from = op->args[0]; - enum plugin_gen_cb type = op->args[1]; + TCGv_i64 addr = temp_tcgv_i64(arg_temp(op->args[0])); + qemu_plugin_meminfo_t meminfo = op->args[1]; + struct qemu_plugin_insn *insn; + const GArray *cbs; + int i, n, rw; - switch (from) { - case PLUGIN_GEN_FROM_MEM: - { - g_assert(insn_idx >= 0); + assert(insn_idx >= 0); + insn = g_ptr_array_index(plugin_tb->insns, insn_idx); + rw = qemu_plugin_mem_is_store(meminfo) ? 2 : 1; - switch (type) { - case PLUGIN_GEN_CB_MEM: - plugin_gen_mem_regular(plugin_tb, op, insn_idx); - break; - case PLUGIN_GEN_CB_INLINE: - plugin_gen_mem_inline(plugin_tb, op, insn_idx); - break; - default: - g_assert_not_reached(); + tcg_ctx->emit_before_op = op; + + cbs = insn->cbs[PLUGIN_CB_MEM][PLUGIN_CB_REGULAR]; + for (i = 0, n = (cbs ? cbs->len : 0); i < n; i++) { + struct qemu_plugin_dyn_cb *cb = + &g_array_index(cbs, struct qemu_plugin_dyn_cb, i); + if (cb->rw & rw) { + gen_mem_cb(cb, meminfo, addr); } + } - break; - } - default: - g_assert_not_reached(); + cbs = insn->cbs[PLUGIN_CB_MEM][PLUGIN_CB_INLINE]; + for (i = 0, n = (cbs ? cbs->len : 0); i < n; i++) { + struct qemu_plugin_dyn_cb *cb = + &g_array_index(cbs, struct qemu_plugin_dyn_cb, i); + if (cb->rw & rw) { + gen_inline_cb(cb); + } } + + tcg_ctx->emit_before_op = NULL; + tcg_op_remove(tcg_ctx, op); break; } + default: /* plugins don't care about any other ops */ break; diff --git a/tcg/tcg-op-ldst.c b/tcg/tcg-op-ldst.c index f11043b449..8510160258 100644 --- a/tcg/tcg-op-ldst.c +++ b/tcg/tcg-op-ldst.c @@ -161,14 +161,14 @@ plugin_gen_mem_callbacks(TCGv_i64 copy_addr, TCGTemp *orig_addr, MemOpIdx oi, copy_addr = tcg_temp_ebb_new_i64(); tcg_gen_extu_i32_i64(copy_addr, temp_tcgv_i32(orig_addr)); } - plugin_gen_empty_mem_callback(copy_addr, info); + tcg_gen_plugin_mem_cb(copy_addr, info); tcg_temp_free_i64(copy_addr); } else { if (copy_addr) { - plugin_gen_empty_mem_callback(copy_addr, info); + tcg_gen_plugin_mem_cb(copy_addr, info); tcg_temp_free_i64(copy_addr); } else { - plugin_gen_empty_mem_callback(temp_tcgv_i64(orig_addr), info); + tcg_gen_plugin_mem_cb(temp_tcgv_i64(orig_addr), info); } } } diff --git a/tcg/tcg-op.c b/tcg/tcg-op.c index 0f2026c91c..0ae12fa49d 100644 --- a/tcg/tcg-op.c +++ b/tcg/tcg-op.c @@ -317,6 +317,11 @@ void tcg_gen_plugin_cb(unsigned from) tcg_gen_op1(INDEX_op_plugin_cb, from); } +void tcg_gen_plugin_mem_cb(TCGv_i64 addr, unsigned meminfo) +{ + tcg_gen_op2(INDEX_op_plugin_mem_cb, tcgv_i64_arg(addr), meminfo); +} + void tcg_gen_plugin_cb_start(unsigned from, unsigned type, unsigned wr) { tcg_gen_op3(INDEX_op_plugin_cb_start, from, type, wr); From patchwork Thu Apr 4 23:06:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 785857 Delivered-To: patch@linaro.org Received: by 2002:adf:f001:0:b0:33e:7753:30bd with SMTP id j1csp1074469wro; Thu, 4 Apr 2024 16:08:55 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCW3ahgZjXo5Jgsox0HdzTZ96IJYXLVGyRG5x6U7tbT/Ntkh1X7MQZnqgKBxMXZy323VI2RRpQTRLWtRHml694Cw X-Google-Smtp-Source: AGHT+IGp4PeVfwPhdCOU4fXJUVcyrOvLquQhoXhKNbZBWENHZwi7+LFBi4LtRmoJzRNV+qtrRJuq X-Received: by 2002:a05:6358:27a8:b0:183:40f2:4bd6 with SMTP id l40-20020a05635827a800b0018340f24bd6mr4041706rwb.0.1712272135163; Thu, 04 Apr 2024 16:08:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712272135; cv=none; d=google.com; s=arc-20160816; b=x5Zjc1wT25EwBfyO5J3xte7wzh6LYyuhB1K8sQNdeRyplCH0juna9mCHFioiUk/6af IaZ/h+xQ3X8vXFHyJJHlCKruu3pZskCOk/lpTczfvRoaIDFwseRFLaf+0pLBJokWOrWs ggz6RwebgB/E0ZJKTZP8ggn/5U2aKD6yyf6xRxokx4t+d+y+KO05bVR0wblWreEO7Asb VnYT/5iWmnDBjxjvc8ocn5XXR5N/gK52tD467oW5ZbIYBUgf/+DckIT/42YZaD/cuaz6 57tst7Y5gghjSCRRK+1ByJJskHyhyF8mm/WRkKsdr/Ha8E7TFLhcEyfVQuzXDUt1A9cP A39g== 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=Yq7gfhqzCEYtWciBbW30RRAKn3Q931Bk5u6D2pAF6UU=; fh=eu2DY09p+eeddYDiV+DalJS3Vr0kxK5BujclYkgWvDw=; b=SxLbjCmUyTXKJbpP+14MXI0vD18/ebrLi1HLZV0yLuy9Y2nmfYxoMdvkeYXZqutdaf ShW5lv8Kvg+1OnQE67XhGjXtQrbsTYbDb93oBb6AQyiL79m6Lfg0YbPTAfRk/IbG06mo AXXt9V3W1vDSyQ//q9dvuTC15WW1hDpAsHd90Wua9ESX5QdhL9+L8TjpN3o/jSvYaNR6 or71jC1DhoPEHWo7WbUONuGZ6Oz6XpFGwrxT1RipLKL85JXzxrPJ6R/HUgP1jh3RCenM FiL8vkXhGhkX5+/rp2sP5qUqGCV4q7jtJh3xUoisAE8YTxxZSo3QEIhWlm8wELbVXOBU KeRw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=VfeHwPPJ; 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 u16-20020a05620a0c5000b0078a0759f66esi542669qki.69.2024.04.04.16.08.55 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 04 Apr 2024 16:08:55 -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=VfeHwPPJ; 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 1rsWAV-00028C-Ax; Thu, 04 Apr 2024 19:06:51 -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 1rsWAF-00023Y-LC for qemu-devel@nongnu.org; Thu, 04 Apr 2024 19:06:37 -0400 Received: from mail-pf1-x42f.google.com ([2607:f8b0:4864:20::42f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rsWAC-0007lG-6s for qemu-devel@nongnu.org; Thu, 04 Apr 2024 19:06:35 -0400 Received: by mail-pf1-x42f.google.com with SMTP id d2e1a72fcca58-6ea9a60f7f5so1371809b3a.3 for ; Thu, 04 Apr 2024 16:06:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712271990; x=1712876790; 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=Yq7gfhqzCEYtWciBbW30RRAKn3Q931Bk5u6D2pAF6UU=; b=VfeHwPPJiwnzKiBjfbW+AytV1ytBTL4sxpnd7g18S7o357PUa/QCmcowyKxmN2eZdW 1bBwZYC4hxLbeG4vObg9IDL/84TVhEmBnBvRIzWxa3n+cUkJzllW1kPVSt5fIyMmlLEL 5+kKE+IzyvFKjc3i3y2M+w5Ha3sKLL1KOVj0x6wrqgNzI4gRgDy1fzbrUsN5fUvp82Xc PEPV5sIKd8ut5rcDFvverTLrwflUpGATszsp3qeoc+I0lHsZHQ2ePHdxUY8Cgo2P20DM 3Ba9ZljT4qiOdLQpHX048FqPNzPyX/vCedN5IH69v/Nt3fgKtWd5Aiq/i9NYO8x4B/VT x8gQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712271990; x=1712876790; 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=Yq7gfhqzCEYtWciBbW30RRAKn3Q931Bk5u6D2pAF6UU=; b=l0+MBcWbUscW/5sm2ghgSJbfZXtmjOS0xe+mLYb+oRewMND7gZEYSNHNONTIjZ99+4 vCiqLdAUd4LZYJvRNhxssbQOfLDu5NNQaqzrU+LFcm6ecP3XUEwZJ8LMd9e1xiDVat4z HibNuE/BrNp2ZVSL7aQDX9/1qvg3UYU4AhQZgwclir32V7FB9XwfbQPNM8AVI+08hk6d Ege7PHQcVJJuf4JgA52gc9f0HywVML+zu1OKIoZ1ksrnb9ARPFCw3CZOylbfr7S7+vwE oqA3hAIbZ/Ce/qm903u5hqQ0zQbMPCxAcY1kWt5KRMddyvOlIiS5/AWpgwKOfmnFl0vG PaFA== X-Gm-Message-State: AOJu0YyhZPy1kd183nmI46cpmhjp5U4Kj7snCpmH8pQ0ViuYvbGPxEbY 1dV0ilJHYerdTNUdAazWHvxry0IT0TglCbpMQikRlGhNFr+6+LQOGAtaIzW5/nKpmBOnat9+0kl 2 X-Received: by 2002:a17:90a:c58a:b0:2a2:c353:7c38 with SMTP id l10-20020a17090ac58a00b002a2c3537c38mr3388116pjt.24.1712271989924; Thu, 04 Apr 2024 16:06:29 -0700 (PDT) Received: from stoup.. (098-147-007-212.res.spectrum.com. [98.147.7.212]) by smtp.gmail.com with ESMTPSA id q36-20020a17090a17a700b002a2f3cfc92asm1052592pja.16.2024.04.04.16.06.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Apr 2024 16:06:29 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Alex_Benn=C3=A9e?= Subject: [PATCH v2 12/21] plugins: Remove plugin helpers Date: Thu, 4 Apr 2024 13:06:02 -1000 Message-Id: <20240404230611.21231-13-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240404230611.21231-1-richard.henderson@linaro.org> References: <20240404230611.21231-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::42f; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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 These placeholder helpers are no longer required. Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson --- accel/tcg/plugin-helpers.h | 5 ----- include/exec/helper-gen-common.h | 4 ---- include/exec/helper-proto-common.h | 4 ---- accel/tcg/plugin-gen.c | 20 -------------------- 4 files changed, 33 deletions(-) delete mode 100644 accel/tcg/plugin-helpers.h diff --git a/accel/tcg/plugin-helpers.h b/accel/tcg/plugin-helpers.h deleted file mode 100644 index 11796436f3..0000000000 --- a/accel/tcg/plugin-helpers.h +++ /dev/null @@ -1,5 +0,0 @@ -#ifdef CONFIG_PLUGIN -DEF_HELPER_FLAGS_2(plugin_vcpu_udata_cb_no_wg, TCG_CALL_NO_WG | TCG_CALL_PLUGIN, void, i32, ptr) -DEF_HELPER_FLAGS_2(plugin_vcpu_udata_cb_no_rwg, TCG_CALL_NO_RWG | TCG_CALL_PLUGIN, void, i32, ptr) -DEF_HELPER_FLAGS_4(plugin_vcpu_mem_cb, TCG_CALL_NO_RWG | TCG_CALL_PLUGIN, void, i32, i32, i64, ptr) -#endif diff --git a/include/exec/helper-gen-common.h b/include/exec/helper-gen-common.h index 5d6d78a625..834590dc4e 100644 --- a/include/exec/helper-gen-common.h +++ b/include/exec/helper-gen-common.h @@ -11,8 +11,4 @@ #include "exec/helper-gen.h.inc" #undef HELPER_H -#define HELPER_H "accel/tcg/plugin-helpers.h" -#include "exec/helper-gen.h.inc" -#undef HELPER_H - #endif /* HELPER_GEN_COMMON_H */ diff --git a/include/exec/helper-proto-common.h b/include/exec/helper-proto-common.h index 8b67170a22..16782ef46c 100644 --- a/include/exec/helper-proto-common.h +++ b/include/exec/helper-proto-common.h @@ -13,8 +13,4 @@ #include "exec/helper-proto.h.inc" #undef HELPER_H -#define HELPER_H "accel/tcg/plugin-helpers.h" -#include "exec/helper-proto.h.inc" -#undef HELPER_H - #endif /* HELPER_PROTO_COMMON_H */ diff --git a/accel/tcg/plugin-gen.c b/accel/tcg/plugin-gen.c index 8f8ae156b6..fb77585ac0 100644 --- a/accel/tcg/plugin-gen.c +++ b/accel/tcg/plugin-gen.c @@ -51,11 +51,6 @@ #include "exec/exec-all.h" #include "exec/plugin-gen.h" #include "exec/translator.h" -#include "exec/helper-proto-common.h" - -#define HELPER_H "accel/tcg/plugin-helpers.h" -#include "exec/helper-info.c.inc" -#undef HELPER_H /* * plugin_cb_start TCG op args[]: @@ -82,21 +77,6 @@ enum plugin_gen_cb { PLUGIN_GEN_N_CBS, }; -/* - * These helpers are stubs that get dynamically switched out for calls - * direct to the plugin if they are subscribed to. - */ -void HELPER(plugin_vcpu_udata_cb_no_wg)(uint32_t cpu_index, void *udata) -{ } - -void HELPER(plugin_vcpu_udata_cb_no_rwg)(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) -{ } - static void plugin_gen_empty_callback(enum plugin_gen_from from) { switch (from) { From patchwork Thu Apr 4 23:06:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 785852 Delivered-To: patch@linaro.org Received: by 2002:adf:f001:0:b0:33e:7753:30bd with SMTP id j1csp1074338wro; Thu, 4 Apr 2024 16:08:35 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUSMwJ/HCTfJN4ZTVq7h9souUTTms5v/IbUWSXDOqVTM4P2lbrAV9iRMwUkeK3Wf5J3xT/mrBi48IUu6f8tXLJm X-Google-Smtp-Source: AGHT+IFTyrkrAYsCEqJS2u400O/hrKkV4sj5dLi+Ag3RsDFZ/BNYO2s9a8IGpZ8CtYEgppEKYZ6P X-Received: by 2002:ac8:5882:0:b0:432:cf93:d369 with SMTP id t2-20020ac85882000000b00432cf93d369mr3747964qta.2.1712272115069; Thu, 04 Apr 2024 16:08:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712272115; cv=none; d=google.com; s=arc-20160816; b=h+QEsZUi6AJW9oyaLmE1nM5vg2OOMWypjkiEhjk6ehmvXrWn/QTai/jdBzwJg4B/7S YybheKMyAst5OydC10oNnwxGoia1JQWdZwEWTGAeKxTC0DXyaHeJTQykdTIfKpkYtHcs t4z3MCDwdGPnxKxVWCv2S1k0mqk8EjgzziwA4FTJzEUJF+fapDLvGTAyj+uCwIorTJqS QFIjnq2Np7Fq5XHPub1Lf/lRxzlnx8lg9us0lFjol/l0su9mNy5F4z3QYIHVKJC/Y0/G JmZSFRdrfVTgy5aeI0DRXdNzcjORjtAwYedB0xqiVRb53u5LvQw6TeP82x3owMQVvZaC /U4Q== 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=/FK2WWMw+RB5io7Nzuf8LNknc8niTsj2ljKDgkXD3m0=; fh=vm85eyWrvOAHduw3sqEA+cYBqvHB7M0MHFcRJg7VWOo=; b=HNmOpp0+52izHJMEOygo97lFwPctRWvE+l+lxIXxdRUcl8V331BuemgXDvMCQzn8uG oneTOm+97tuO6JmkDctkg0bi3kniRffAOIcnATKWKkZcu7lcJdOlbzoFfib26EYv92Zy Luw1x5Uxl6rhm6HZlnexa8o5KO5NvRcuXaPoRFFXSOZ3rAj0aYOguRzSb2zwd1DvTQcH e5dWz6RUVUDYssVp2rV3+4zOxoC3n60dU27nTE1x9AUms8pzl/aGn18OdZHu981t21SS PSHmcbKndTP0GrR6l6vECTZUcpe3hlFE1e5tHgZVgbeRDZOoQcm1yOqyBRi1jVrKYXfP mR6w==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=F9CJpeEf; 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 r10-20020ac85c8a000000b004313d29c234si427259qta.188.2024.04.04.16.08.34 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 04 Apr 2024 16:08:35 -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=F9CJpeEf; 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 1rsWAW-00028f-DF; Thu, 04 Apr 2024 19:06:52 -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 1rsWAG-00023g-N4 for qemu-devel@nongnu.org; Thu, 04 Apr 2024 19:06:38 -0400 Received: from mail-pj1-x102e.google.com ([2607:f8b0:4864:20::102e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rsWAE-0007mr-1J for qemu-devel@nongnu.org; Thu, 04 Apr 2024 19:06:36 -0400 Received: by mail-pj1-x102e.google.com with SMTP id 98e67ed59e1d1-29e0a1fd9a7so1051770a91.2 for ; Thu, 04 Apr 2024 16:06:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712271991; x=1712876791; 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=/FK2WWMw+RB5io7Nzuf8LNknc8niTsj2ljKDgkXD3m0=; b=F9CJpeEfEUFzmK1dXcHzQO4J1bwknYXvsXlH5xtTkPB0AEMRrqb68RErjx1WJi5zca ZZJt1zvB4z/RRUsy82HdVkA4va0Am4uWj0FdqqrI0k7eZtntRGrpht+PRPVERUYzxlkQ yGZhHtNgwZinDnf5XIS+DzimhtZiluJfWopO3pxraXK06BUgB2pCDpB/cuXscVhDdiUe M+hEsMWsC2JVe89gTQhsyl6ikx8Vx69+lT1yHSxKVxXcMrCGtkzppGAMYznA3QCD/hqJ hdDXterdblGTQgnx6AqBUPELt5HDJTI1lAB61/TyvHvvqJXOHZjW9W0qz5m1cbjUzH1T DFaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712271991; x=1712876791; 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=/FK2WWMw+RB5io7Nzuf8LNknc8niTsj2ljKDgkXD3m0=; b=PnkEY3Tsabgh8ldPtNkGVxx7BAk3eGkoO9d7QM0NahNdP2huRYFUa5J5z2sbmKeDoW kgOVk8b2pHVAI4F8ELCzLsTN5e+hhGqs4fbAWvFqSX98vIcrRXD36SW3Z+0Si2u9Wcu0 04lqSu50FkDPFTZh/zH8OnRpsNN9Z8zgcvpGysOST7IvbnO+3utKyUopmVp8lpa/O8mV IXQd1h1f1pV/YF2MUGSxpXYCf2HJqcIeYDE9BmF2rUHXaA77QKknKzKPXdjSTa/7Wn0R J604afjcymReG4UO/3JuwGlSKtGUIYgIVOKLoC+9NKWIr4Rll7E0/TBDojUrSoOxnuNT eSyw== X-Gm-Message-State: AOJu0YzQ5yWVUWBBbAcbJx4d2rENgzWI93MG5SmVhYQOr7U2WPAz7oyz LtMKBPJBamOEjWqySceooQXJ0JYQB+MKi1byCkmDLtZubjtqp91M9/2A0hk6iBu3zAJq0XP0ZA1 k X-Received: by 2002:a17:90a:898a:b0:2a2:d009:75f2 with SMTP id v10-20020a17090a898a00b002a2d00975f2mr3065446pjn.28.1712271991587; Thu, 04 Apr 2024 16:06:31 -0700 (PDT) Received: from stoup.. (098-147-007-212.res.spectrum.com. [98.147.7.212]) by smtp.gmail.com with ESMTPSA id q36-20020a17090a17a700b002a2f3cfc92asm1052592pja.16.2024.04.04.16.06.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Apr 2024 16:06:31 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Pierrick Bouvier Subject: [PATCH v2 13/21] tcg: Remove TCG_CALL_PLUGIN Date: Thu, 4 Apr 2024 13:06:03 -1000 Message-Id: <20240404230611.21231-14-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240404230611.21231-1-richard.henderson@linaro.org> References: <20240404230611.21231-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::102e; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102e.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Since we no longer emit plugin helpers during the initial code translation phase, we don't need to specially mark plugin helpers. Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- include/tcg/tcg.h | 2 -- plugins/core.c | 10 ++++------ tcg/tcg.c | 4 +--- 3 files changed, 5 insertions(+), 11 deletions(-) diff --git a/include/tcg/tcg.h b/include/tcg/tcg.h index 8d9f6585ff..196e3b7ba1 100644 --- a/include/tcg/tcg.h +++ b/include/tcg/tcg.h @@ -353,8 +353,6 @@ typedef TCGv_ptr TCGv_env; #define TCG_CALL_NO_SIDE_EFFECTS 0x0004 /* Helper is G_NORETURN. */ #define TCG_CALL_NO_RETURN 0x0008 -/* Helper is part of Plugins. */ -#define TCG_CALL_PLUGIN 0x0010 /* convenience version of most used call flags */ #define TCG_CALL_NO_RWG TCG_CALL_NO_READ_GLOBALS diff --git a/plugins/core.c b/plugins/core.c index b0a2e80874..b0615f1e7f 100644 --- a/plugins/core.c +++ b/plugins/core.c @@ -339,9 +339,8 @@ void plugin_register_dyn_cb__udata(GArray **arr, void *udata) { static TCGHelperInfo info[3] = { - [QEMU_PLUGIN_CB_NO_REGS].flags = TCG_CALL_NO_RWG | TCG_CALL_PLUGIN, - [QEMU_PLUGIN_CB_R_REGS].flags = TCG_CALL_NO_WG | TCG_CALL_PLUGIN, - [QEMU_PLUGIN_CB_RW_REGS].flags = TCG_CALL_PLUGIN, + [QEMU_PLUGIN_CB_NO_REGS].flags = TCG_CALL_NO_RWG, + [QEMU_PLUGIN_CB_R_REGS].flags = TCG_CALL_NO_WG, /* * Match qemu_plugin_vcpu_udata_cb_t: * void (*)(uint32_t, void *) @@ -375,9 +374,8 @@ void plugin_register_vcpu_mem_cb(GArray **arr, !__builtin_types_compatible_p(qemu_plugin_meminfo_t, int32_t)); static TCGHelperInfo info[3] = { - [QEMU_PLUGIN_CB_NO_REGS].flags = TCG_CALL_NO_RWG | TCG_CALL_PLUGIN, - [QEMU_PLUGIN_CB_R_REGS].flags = TCG_CALL_NO_WG | TCG_CALL_PLUGIN, - [QEMU_PLUGIN_CB_RW_REGS].flags = TCG_CALL_PLUGIN, + [QEMU_PLUGIN_CB_NO_REGS].flags = TCG_CALL_NO_RWG, + [QEMU_PLUGIN_CB_R_REGS].flags = TCG_CALL_NO_WG, /* * Match qemu_plugin_vcpu_mem_cb_t: * void (*)(uint32_t, qemu_plugin_meminfo_t, uint64_t, void *) diff --git a/tcg/tcg.c b/tcg/tcg.c index 0bf218314b..363a065e28 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -2269,9 +2269,7 @@ static void tcg_gen_callN(void *func, TCGHelperInfo *info, #ifdef CONFIG_PLUGIN /* Flag helpers that may affect guest state */ - if (tcg_ctx->plugin_insn && - !(info->flags & TCG_CALL_PLUGIN) && - !(info->flags & TCG_CALL_NO_SIDE_EFFECTS)) { + if (tcg_ctx->plugin_insn && !(info->flags & TCG_CALL_NO_SIDE_EFFECTS)) { tcg_ctx->plugin_insn->calls_helpers = true; } #endif From patchwork Thu Apr 4 23:06:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 785861 Delivered-To: patch@linaro.org Received: by 2002:adf:f001:0:b0:33e:7753:30bd with SMTP id j1csp1074675wro; Thu, 4 Apr 2024 16:09:35 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUIWh9EiHonXVrLoE5cCsxFxf9iY/650P/Ww4RCQlyiBwaCFg6vGmn49U0oFdRC656SuG3CHqtayM8858LGDtNl X-Google-Smtp-Source: AGHT+IE2Hv0QscIsdeeSiyrw0LT6pmJ1cHw5CZM21zMoJgj4dNv+Pa9yzGqHlUvsvvmg/QQm77a7 X-Received: by 2002:a05:6102:48e:b0:478:7977:338d with SMTP id n14-20020a056102048e00b004787977338dmr3799330vsa.20.1712272175382; Thu, 04 Apr 2024 16:09:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712272175; cv=none; d=google.com; s=arc-20160816; b=tbncb5u/3tSh4oLJmwgci+xVCwQjCE2I+BOaVoM69AD/20wbC7aImUACuXuAh63MLV zBSL8/+k0n1yR+XoshafVLiME3rwHBODFB6xpQuPPQSlHyVyXHXFBia+C8RYD0nUm5A7 lhJ7lr+6xrzhwOvaWhwFWVPSYhyviiHHqYTkrn9xbSCCTqG3v63cYs3XxHi0urv0O3d1 f8O35tMTR4OTW8YRgvO9HYgNt13X5lG7JAU5s/UwAhAUOmTU9ufNuwt9u6WOqEer59iV nHX8jKIHrNd6RudA1/jjWTwsRkYAltlkMiza53tsv9417ibuPKBVv2NkHG6z1u8S0J+O 7qSg== 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=QUzW5EpE6psTv3wNqcRJ2QohJfV0nsRef4r1zjcLMwE=; fh=vm85eyWrvOAHduw3sqEA+cYBqvHB7M0MHFcRJg7VWOo=; b=dj0MB/EeaUHSuD+FHZO9fIPwIy5o5NwXTu2Ryp6ztHQU6fszx6fwBUAcYbaGEXR7b9 ICqV7s1L0BLKGtolTbIwACRqN3nsV35+QkYKMTxDtBbTGqEmMGGMH2zZnC9zxxbV2HuY +d0WB4j+UAlTa5ueKggZSdxF9jc9GkHChVs2GthRa+hHCA8xmwgmEN8SQUgda2KkzQe6 bE5SoZGqLIGTC+z/WEjGVSMJdnrlJ24J2wEEOzC6409v9Lk0MWasTV8iZA4f82qF3NrJ D4c5UjTRN1ArMGoclccujTHPySvmohyjAYisF5TFnQ2ttKCWa4yyIafJe5p589JPbWqP 1SKA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=e8B9cHem; 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 y2-20020a05620a44c200b00789eb26bda5si489570qkp.729.2024.04.04.16.09.35 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 04 Apr 2024 16:09:35 -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=e8B9cHem; 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 1rsWAV-00028E-Fk; Thu, 04 Apr 2024 19:06:51 -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 1rsWAG-00023i-OH for qemu-devel@nongnu.org; Thu, 04 Apr 2024 19:06:38 -0400 Received: from mail-pg1-x532.google.com ([2607:f8b0:4864:20::532]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rsWAE-0007nB-6O for qemu-devel@nongnu.org; Thu, 04 Apr 2024 19:06:36 -0400 Received: by mail-pg1-x532.google.com with SMTP id 41be03b00d2f7-5bdbe2de25fso1232192a12.3 for ; Thu, 04 Apr 2024 16:06:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712271993; x=1712876793; 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=QUzW5EpE6psTv3wNqcRJ2QohJfV0nsRef4r1zjcLMwE=; b=e8B9cHem6j0ZzFeE78hJvb147gfpw9lisYxfUmI/HS9IrbNqi0juzFHBaXRos7/Wr9 0yGYYTGgnW8jS/rQvyFcjjJ4sFhRsSZkM3UgEJQlIqg8m3OprLFoT9qIRhnh6jRf949S BtkOfEFTv/6CMmDvwyJdn9QKlWT+cCL6WVajnFArsay+RQaCdGpURSDUN8baus0Y4/oJ GU92plT8w3fqG+kM+iNcqAVLu4csybAJUyMCnvlZbkbrvBVr0FngPS4fcrkYWjk0WASw nDqZH7ULoM1JUNMM2hJCdxG1CGiJVRETtMSUjJfVLJohOyXf68W/fgFPfpVFzZFBLdmt LXIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712271993; x=1712876793; 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=QUzW5EpE6psTv3wNqcRJ2QohJfV0nsRef4r1zjcLMwE=; b=T44Xi2GHSuAfcDRG87+V8t5RCZtE7fWDmiLpMSAUcJY+TIH+DWGCtXyXRzFSzIQY8d +/7EQFd+yO58xvyOBD22HZP1absIb1vpDN7bJWmggkG02CATeNTb2HGcN2yt3+TyxV3a j0e7oh2as24PWZVFyWQDhJovmHDXKJGP7nTZ7ED0lCH3gypZq84bR4r9OK2b2pSHUkum y7oBH47aP4/Y7ed6agWOMlt1le5u4/1ixRKRm4wWYPCOkHHmIvznDABHuMOy55Txp0EU ovKdqPk/fBWJBASPe7GPS7aRXm3tcfsA14d8YrDk768x0ElNk9RW8Oo2YglgRDKIPaMk ah+Q== X-Gm-Message-State: AOJu0YyR4fYl3OoiXxe61LfD3/YbLEwgX747HDwXWISWDqgZgQl2/8Pz ZgN7iFVhDcIcP8bDv5oGVO4igSWOoYvMz/FCDWrzSYa1O4R6Dyvd1OicCaBusuEiG1CU2iMK+FY 4 X-Received: by 2002:a17:90b:78b:b0:2a2:8a0e:1b81 with SMTP id l11-20020a17090b078b00b002a28a0e1b81mr3803893pjz.30.1712271992859; Thu, 04 Apr 2024 16:06:32 -0700 (PDT) Received: from stoup.. (098-147-007-212.res.spectrum.com. [98.147.7.212]) by smtp.gmail.com with ESMTPSA id q36-20020a17090a17a700b002a2f3cfc92asm1052592pja.16.2024.04.04.16.06.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Apr 2024 16:06:32 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Pierrick Bouvier Subject: [PATCH v2 14/21] tcg: Remove INDEX_op_plugin_cb_{start,end} Date: Thu, 4 Apr 2024 13:06:04 -1000 Message-Id: <20240404230611.21231-15-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240404230611.21231-1-richard.henderson@linaro.org> References: <20240404230611.21231-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::532; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x532.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org These opcodes are no longer used. Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- include/tcg/tcg-op-common.h | 2 -- include/tcg/tcg-opc.h | 2 -- accel/tcg/plugin-gen.c | 18 ------------------ tcg/tcg-op.c | 10 ---------- 4 files changed, 32 deletions(-) diff --git a/include/tcg/tcg-op-common.h b/include/tcg/tcg-op-common.h index 72b80b20d0..009e2778c5 100644 --- a/include/tcg/tcg-op-common.h +++ b/include/tcg/tcg-op-common.h @@ -76,8 +76,6 @@ void tcg_gen_lookup_and_goto_ptr(void); void tcg_gen_plugin_cb(unsigned from); void tcg_gen_plugin_mem_cb(TCGv_i64 addr, unsigned meminfo); -void tcg_gen_plugin_cb_start(unsigned from, unsigned type, unsigned wr); -void tcg_gen_plugin_cb_end(void); /* 32 bit ops */ diff --git a/include/tcg/tcg-opc.h b/include/tcg/tcg-opc.h index be9e36e386..546eb49c11 100644 --- a/include/tcg/tcg-opc.h +++ b/include/tcg/tcg-opc.h @@ -199,8 +199,6 @@ DEF(goto_ptr, 0, 1, 0, TCG_OPF_BB_EXIT | TCG_OPF_BB_END) DEF(plugin_cb, 0, 0, 1, TCG_OPF_NOT_PRESENT) DEF(plugin_mem_cb, 0, 1, 1, TCG_OPF_NOT_PRESENT) -DEF(plugin_cb_start, 0, 0, 3, TCG_OPF_NOT_PRESENT) -DEF(plugin_cb_end, 0, 0, 0, TCG_OPF_NOT_PRESENT) /* Replicate ld/st ops for 32 and 64-bit guest addresses. */ DEF(qemu_ld_a32_i32, 1, 1, 1, diff --git a/accel/tcg/plugin-gen.c b/accel/tcg/plugin-gen.c index fb77585ac0..d9ee9bb2ec 100644 --- a/accel/tcg/plugin-gen.c +++ b/accel/tcg/plugin-gen.c @@ -52,29 +52,11 @@ #include "exec/plugin-gen.h" #include "exec/translator.h" -/* - * plugin_cb_start TCG op args[]: - * 0: enum plugin_gen_from - * 1: enum plugin_gen_cb - * 2: set to 1 for mem callback that is a write, 0 otherwise. - */ - enum plugin_gen_from { PLUGIN_GEN_FROM_TB, PLUGIN_GEN_FROM_INSN, PLUGIN_GEN_AFTER_INSN, PLUGIN_GEN_AFTER_TB, - PLUGIN_GEN_N_FROMS, -}; - -enum plugin_gen_cb { - PLUGIN_GEN_CB_UDATA, - PLUGIN_GEN_CB_UDATA_R, - PLUGIN_GEN_CB_INLINE, - PLUGIN_GEN_CB_MEM, - PLUGIN_GEN_ENABLE_MEM_HELPER, - PLUGIN_GEN_DISABLE_MEM_HELPER, - PLUGIN_GEN_N_CBS, }; static void plugin_gen_empty_callback(enum plugin_gen_from from) diff --git a/tcg/tcg-op.c b/tcg/tcg-op.c index 0ae12fa49d..eff3728622 100644 --- a/tcg/tcg-op.c +++ b/tcg/tcg-op.c @@ -322,16 +322,6 @@ void tcg_gen_plugin_mem_cb(TCGv_i64 addr, unsigned meminfo) tcg_gen_op2(INDEX_op_plugin_mem_cb, tcgv_i64_arg(addr), meminfo); } -void tcg_gen_plugin_cb_start(unsigned from, unsigned type, unsigned wr) -{ - tcg_gen_op3(INDEX_op_plugin_cb_start, from, type, wr); -} - -void tcg_gen_plugin_cb_end(void) -{ - tcg_emit_op(INDEX_op_plugin_cb_end, 0); -} - /* 32 bit ops */ void tcg_gen_discard_i32(TCGv_i32 arg) From patchwork Thu Apr 4 23:06:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 785850 Delivered-To: patch@linaro.org Received: by 2002:adf:f001:0:b0:33e:7753:30bd with SMTP id j1csp1074285wro; Thu, 4 Apr 2024 16:08:24 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWrXoZHru71tO/kuhF3d8IfjtSURL7tuwTNBq/kiIdVNYGIsq/97qLE6RFmSRWxWq/KlpYupRJvin+OUP6ZxGKd X-Google-Smtp-Source: AGHT+IEJ+WQ5/qAvVnj5LJ4g3fZB4/zk3QYHY43UxLV3VIuIZwh8qX8Rax0deCo4sbmXyMa49XfE X-Received: by 2002:a05:622a:83:b0:434:587e:fc1e with SMTP id o3-20020a05622a008300b00434587efc1emr1899738qtw.26.1712272103779; Thu, 04 Apr 2024 16:08:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712272103; cv=none; d=google.com; s=arc-20160816; b=W6iIlYC03VWUQcyo7ekqdBsihWCjdj45054ep+AK35c1BeAdvW5HE47lmY+ME0NAUx LGcTUCczciHLRrXz7y1i0O9B0DDgeFpa4jxZBOGlleSZMQiFtdYFEURvP7PX2ag2rxiv pNpluesQwk+CA7mxO1LfpnuoLsKSzMXC+JYksLINL3N3ufDhDEbzPGueoAPJWmCdJ734 m1YbxqQnCOFLqV0wJhAFETgzM/Xpn5vBso6gwSlUnDs4pH/Hs+Wyoc+/UksacpwoByWM uLVtftxbwW34EnfBDDR704iRb62iURBzSIaJn9uweZoXvlddnw6RxZNDZHA0WiHkurCv JveQ== 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=vTIUW5pAbj5S0ydnqmF/maLVrqi0GbMLZ1OPEJ7z3T8=; fh=vm85eyWrvOAHduw3sqEA+cYBqvHB7M0MHFcRJg7VWOo=; b=TGf+Pz0MEnVDqOEMUgBFxTVlWOuvdobYtOIqt/bvUEgHILMADez3ywmkMmOMDAUccx y2dnFoaEdxLV+/+IfIUmJQdDeEEj/AgJNdSeRaGYUi/mwzcCFDF7foIpLKOEi3TGYIyy KlKdadlSBjQrdrtmixG3NDiRon2ixACoHHmt73Whax5XQS3abOaN1+s+cTeBQFRri99u fip9Njf8QlUr1v+rXdbpDwThM94Uz2+eYqp/8/7hVW/2m3N/Kg8C8yf5bqbHchtBgJ+a /X5fPtAChOxM1pAc6attg5oFVUOHcHe2ly+GJC6o2FY6aZdKKvqKLSbQGypCslonyZuo 0LFQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=H6TRuqVt; 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 r4-20020ac85c84000000b0043160b9b8desi433085qta.219.2024.04.04.16.08.23 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 04 Apr 2024 16:08:23 -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=H6TRuqVt; 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 1rsWAU-000287-Nu; Thu, 04 Apr 2024 19:06:50 -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 1rsWAH-00023u-Uj for qemu-devel@nongnu.org; Thu, 04 Apr 2024 19:06:38 -0400 Received: from mail-pl1-x630.google.com ([2607:f8b0:4864:20::630]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rsWAF-0007na-OP for qemu-devel@nongnu.org; Thu, 04 Apr 2024 19:06:37 -0400 Received: by mail-pl1-x630.google.com with SMTP id d9443c01a7336-1e28856ed7aso11676505ad.0 for ; Thu, 04 Apr 2024 16:06:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712271994; x=1712876794; 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=vTIUW5pAbj5S0ydnqmF/maLVrqi0GbMLZ1OPEJ7z3T8=; b=H6TRuqVtOY1HWYaovxVNIoFDhHxhpLNlLFMVTubUHlzHzS7ds1Q1UhaYFmZDY/1cox /yTpouoQ9wkAPgXl+sl4RpfJezi1NG0LugoRmV7LeQOmX3aNTOW+b4x7QGyuBwW19EwJ W+K47gtaN/JF7yoPT6H7JSDtFILo6llSnsgYNm2DPbJppaNUjcIRH7nr3uDC2Ujf2t3O kw82XEaoNu9qLNZt2GZj2oy30SPNWG+Pa4OGuKcISPWnLgQXGfdDrhuZ+JrWJ44oFR81 uH7UJXAgUvHzTsepYTKUWdKFCrwT72608CAriThaNm/Ncov16kpwLx71iixw4WoYY/2g /Pgg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712271994; x=1712876794; 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=vTIUW5pAbj5S0ydnqmF/maLVrqi0GbMLZ1OPEJ7z3T8=; b=P8v6ny33D3i4pzcfIF7+9bihlczCWTyUDFPoOmsyVJOd56rajbIwGE6amstROk602p 8lhUvNijjdhmwL876ngWpZpfKj1JF5xbftqwNsHtw3stffw/m6nz0M43AiiSUf2u2XIO 7ZPWQhciWOTuSgX5op6UlpbjE6zoMZCSCCbWMkWuSy+Y6zMk/uv7KcIP1wIiehQMi7yh ooIp3KEbxeV2k5jL/a0V9Qrhp+rTySKnlsLimWa+eaeXFjxQX28RHvOm6gRg1lGXaoO+ ClgGLNVzU02IVuAOK+hUKTcTCOKxHyO6gJsQRC35Ku0qgrQ9V+y2uqZK1xDByFTXdo+A IvgQ== X-Gm-Message-State: AOJu0YwRqNPwjmw5nIiZerug97ZNUG8MZY9UrgoRZn5JiFUix2CPuRk3 EsOhwHzyoQ9uSkHvqdHUy3TLbFRQrKV4yeHWMyUAtUca6D2t9yRaE7fbnv6+XqG9Q2wcLO4AQDj 0 X-Received: by 2002:a17:902:ca8d:b0:1e2:9d65:253f with SMTP id v13-20020a170902ca8d00b001e29d65253fmr3304367pld.29.1712271994400; Thu, 04 Apr 2024 16:06:34 -0700 (PDT) Received: from stoup.. (098-147-007-212.res.spectrum.com. [98.147.7.212]) by smtp.gmail.com with ESMTPSA id q36-20020a17090a17a700b002a2f3cfc92asm1052592pja.16.2024.04.04.16.06.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Apr 2024 16:06:34 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Pierrick Bouvier Subject: [PATCH v2 15/21] plugins: Simplify callback queues Date: Thu, 4 Apr 2024 13:06:05 -1000 Message-Id: <20240404230611.21231-16-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240404230611.21231-1-richard.henderson@linaro.org> References: <20240404230611.21231-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::630; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x630.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org We have qemu_plugin_dyn_cb.type to differentiate the various callback types, so we do not need to keep them in separate queues. Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- include/qemu/plugin.h | 35 ++++++---------- accel/tcg/plugin-gen.c | 90 ++++++++++++++++++++++-------------------- plugins/api.c | 18 +++------ 3 files changed, 65 insertions(+), 78 deletions(-) diff --git a/include/qemu/plugin.h b/include/qemu/plugin.h index ee1c1b174a..cf9758be55 100644 --- a/include/qemu/plugin.h +++ b/include/qemu/plugin.h @@ -66,15 +66,8 @@ union qemu_plugin_cb_sig { }; enum plugin_dyn_cb_type { - PLUGIN_CB_INSN, - PLUGIN_CB_MEM, - PLUGIN_N_CB_TYPES, -}; - -enum plugin_dyn_cb_subtype { PLUGIN_CB_REGULAR, PLUGIN_CB_INLINE, - PLUGIN_N_CB_SUBTYPES, }; /* @@ -84,7 +77,7 @@ enum plugin_dyn_cb_subtype { */ struct qemu_plugin_dyn_cb { void *userp; - enum plugin_dyn_cb_subtype type; + 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 */ @@ -106,7 +99,8 @@ struct qemu_plugin_insn { GByteArray *data; uint64_t vaddr; void *haddr; - GArray *cbs[PLUGIN_N_CB_TYPES][PLUGIN_N_CB_SUBTYPES]; + GArray *insn_cbs; + GArray *mem_cbs; bool calls_helpers; /* if set, the instruction calls helpers that might access guest memory */ @@ -135,16 +129,9 @@ static inline void qemu_plugin_insn_cleanup_fn(gpointer data) static inline struct qemu_plugin_insn *qemu_plugin_insn_alloc(void) { - int i, j; struct qemu_plugin_insn *insn = g_new0(struct qemu_plugin_insn, 1); - insn->data = g_byte_array_sized_new(4); - for (i = 0; i < PLUGIN_N_CB_TYPES; i++) { - for (j = 0; j < PLUGIN_N_CB_SUBTYPES; j++) { - insn->cbs[i][j] = g_array_new(false, false, - sizeof(struct qemu_plugin_dyn_cb)); - } - } + insn->data = g_byte_array_sized_new(4); return insn; } @@ -161,7 +148,7 @@ struct qemu_plugin_tb { /* if set, the TB calls helpers that might access guest memory */ bool mem_helper; - GArray *cbs[PLUGIN_N_CB_SUBTYPES]; + GArray *cbs; }; /** @@ -174,22 +161,22 @@ struct qemu_plugin_insn *qemu_plugin_tb_insn_get(struct qemu_plugin_tb *tb, uint64_t pc) { struct qemu_plugin_insn *insn; - int i, j; if (unlikely(tb->n == tb->insns->len)) { struct qemu_plugin_insn *new_insn = qemu_plugin_insn_alloc(); g_ptr_array_add(tb->insns, new_insn); } + insn = g_ptr_array_index(tb->insns, tb->n++); g_byte_array_set_size(insn->data, 0); insn->calls_helpers = false; insn->mem_helper = false; insn->vaddr = pc; - - for (i = 0; i < PLUGIN_N_CB_TYPES; i++) { - for (j = 0; j < PLUGIN_N_CB_SUBTYPES; j++) { - g_array_set_size(insn->cbs[i][j], 0); - } + if (insn->insn_cbs) { + g_array_set_size(insn->insn_cbs, 0); + } + if (insn->mem_cbs) { + g_array_set_size(insn->mem_cbs, 0); } return insn; diff --git a/accel/tcg/plugin-gen.c b/accel/tcg/plugin-gen.c index d9ee9bb2ec..e77ff2a565 100644 --- a/accel/tcg/plugin-gen.c +++ b/accel/tcg/plugin-gen.c @@ -83,9 +83,8 @@ void plugin_gen_disable_mem_helpers(void) static void gen_enable_mem_helper(struct qemu_plugin_tb *ptb, struct qemu_plugin_insn *insn) { - GArray *cbs[2]; GArray *arr; - size_t n_cbs; + size_t len; /* * Tracking memory accesses performed from helpers requires extra work. @@ -104,22 +103,25 @@ static void gen_enable_mem_helper(struct qemu_plugin_tb *ptb, return; } - cbs[0] = insn->cbs[PLUGIN_CB_MEM][PLUGIN_CB_REGULAR]; - cbs[1] = insn->cbs[PLUGIN_CB_MEM][PLUGIN_CB_INLINE]; - n_cbs = cbs[0]->len + cbs[1]->len; - - if (n_cbs == 0) { + if (!insn->mem_cbs || !insn->mem_cbs->len) { insn->mem_helper = false; return; } insn->mem_helper = true; ptb->mem_helper = true; + /* + * TODO: It seems like we should be able to use ref/unref + * to avoid needing to actually copy this array. + * Alternately, perhaps we could allocate new memory adjacent + * to the TranslationBlock itself, so that we do not have to + * actively manage the lifetime after this. + */ + len = insn->mem_cbs->len; arr = g_array_sized_new(false, false, - sizeof(struct qemu_plugin_dyn_cb), n_cbs); - g_array_append_vals(arr, cbs[0]->data, cbs[0]->len); - g_array_append_vals(arr, cbs[1]->data, cbs[1]->len); - + sizeof(struct qemu_plugin_dyn_cb), len); + memcpy(arr->data, insn->mem_cbs->data, + len * sizeof(struct qemu_plugin_dyn_cb)); qemu_plugin_add_dyn_cb_arr(arr); tcg_gen_st_ptr(tcg_constant_ptr((intptr_t)arr), tcg_env, @@ -288,18 +290,21 @@ static void plugin_gen_inject(struct qemu_plugin_tb *plugin_tb) case PLUGIN_GEN_FROM_TB: assert(insn == NULL); - cbs = plugin_tb->cbs[PLUGIN_CB_REGULAR]; + cbs = plugin_tb->cbs; for (i = 0, n = (cbs ? cbs->len : 0); i < n; i++) { struct qemu_plugin_dyn_cb *cb = &g_array_index(cbs, struct qemu_plugin_dyn_cb, i); - gen_udata_cb(cb); - } - cbs = plugin_tb->cbs[PLUGIN_CB_INLINE]; - for (i = 0, n = (cbs ? cbs->len : 0); i < n; i++) { - struct qemu_plugin_dyn_cb *cb = - &g_array_index(cbs, struct qemu_plugin_dyn_cb, i); - gen_inline_cb(cb); + switch (cb->type) { + case PLUGIN_CB_REGULAR: + gen_udata_cb(cb); + break; + case PLUGIN_CB_INLINE: + gen_inline_cb(cb); + break; + default: + g_assert_not_reached(); + } } break; @@ -308,18 +313,21 @@ static void plugin_gen_inject(struct qemu_plugin_tb *plugin_tb) gen_enable_mem_helper(plugin_tb, insn); - cbs = insn->cbs[PLUGIN_CB_INSN][PLUGIN_CB_REGULAR]; + cbs = insn->insn_cbs; for (i = 0, n = (cbs ? cbs->len : 0); i < n; i++) { struct qemu_plugin_dyn_cb *cb = &g_array_index(cbs, struct qemu_plugin_dyn_cb, i); - gen_udata_cb(cb); - } - cbs = insn->cbs[PLUGIN_CB_INSN][PLUGIN_CB_INLINE]; - for (i = 0, n = (cbs ? cbs->len : 0); i < n; i++) { - struct qemu_plugin_dyn_cb *cb = - &g_array_index(cbs, struct qemu_plugin_dyn_cb, i); - gen_inline_cb(cb); + switch (cb->type) { + case PLUGIN_CB_REGULAR: + gen_udata_cb(cb); + break; + case PLUGIN_CB_INLINE: + gen_inline_cb(cb); + break; + default: + g_assert_not_reached(); + } } break; @@ -346,21 +354,22 @@ static void plugin_gen_inject(struct qemu_plugin_tb *plugin_tb) tcg_ctx->emit_before_op = op; - cbs = insn->cbs[PLUGIN_CB_MEM][PLUGIN_CB_REGULAR]; + cbs = insn->mem_cbs; for (i = 0, n = (cbs ? cbs->len : 0); i < n; i++) { struct qemu_plugin_dyn_cb *cb = &g_array_index(cbs, struct qemu_plugin_dyn_cb, i); - if (cb->rw & rw) { - gen_mem_cb(cb, meminfo, addr); - } - } - cbs = insn->cbs[PLUGIN_CB_MEM][PLUGIN_CB_INLINE]; - for (i = 0, n = (cbs ? cbs->len : 0); i < n; i++) { - struct qemu_plugin_dyn_cb *cb = - &g_array_index(cbs, struct qemu_plugin_dyn_cb, i); if (cb->rw & rw) { - gen_inline_cb(cb); + switch (cb->type) { + case PLUGIN_CB_REGULAR: + gen_mem_cb(cb, meminfo, addr); + break; + case PLUGIN_CB_INLINE: + gen_inline_cb(cb); + break; + default: + g_assert_not_reached(); + } } } @@ -384,13 +393,10 @@ bool plugin_gen_tb_start(CPUState *cpu, const DisasContextBase *db, if (test_bit(QEMU_PLUGIN_EV_VCPU_TB_TRANS, cpu->plugin_state->event_mask)) { struct qemu_plugin_tb *ptb = tcg_ctx->plugin_tb; - int i; /* reset callbacks */ - for (i = 0; i < PLUGIN_N_CB_SUBTYPES; i++) { - if (ptb->cbs[i]) { - g_array_set_size(ptb->cbs[i], 0); - } + if (ptb->cbs) { + g_array_set_size(ptb->cbs, 0); } ptb->n = 0; diff --git a/plugins/api.c b/plugins/api.c index 29cce2d97c..3912c9cc8f 100644 --- a/plugins/api.c +++ b/plugins/api.c @@ -92,8 +92,7 @@ void qemu_plugin_register_vcpu_tb_exec_cb(struct qemu_plugin_tb *tb, void *udata) { if (!tb->mem_only) { - plugin_register_dyn_cb__udata(&tb->cbs[PLUGIN_CB_REGULAR], - cb, flags, udata); + plugin_register_dyn_cb__udata(&tb->cbs, cb, flags, udata); } } @@ -104,8 +103,7 @@ void qemu_plugin_register_vcpu_tb_exec_inline_per_vcpu( uint64_t imm) { if (!tb->mem_only) { - plugin_register_inline_op_on_entry( - &tb->cbs[PLUGIN_CB_INLINE], 0, op, entry, imm); + plugin_register_inline_op_on_entry(&tb->cbs, 0, op, entry, imm); } } @@ -115,8 +113,7 @@ void qemu_plugin_register_vcpu_insn_exec_cb(struct qemu_plugin_insn *insn, void *udata) { if (!insn->mem_only) { - plugin_register_dyn_cb__udata( - &insn->cbs[PLUGIN_CB_INSN][PLUGIN_CB_REGULAR], cb, flags, udata); + plugin_register_dyn_cb__udata(&insn->insn_cbs, cb, flags, udata); } } @@ -127,8 +124,7 @@ void qemu_plugin_register_vcpu_insn_exec_inline_per_vcpu( uint64_t imm) { if (!insn->mem_only) { - plugin_register_inline_op_on_entry( - &insn->cbs[PLUGIN_CB_INSN][PLUGIN_CB_INLINE], 0, op, entry, imm); + plugin_register_inline_op_on_entry(&insn->insn_cbs, 0, op, entry, imm); } } @@ -143,8 +139,7 @@ void qemu_plugin_register_vcpu_mem_cb(struct qemu_plugin_insn *insn, enum qemu_plugin_mem_rw rw, void *udata) { - plugin_register_vcpu_mem_cb(&insn->cbs[PLUGIN_CB_MEM][PLUGIN_CB_REGULAR], - cb, flags, rw, udata); + plugin_register_vcpu_mem_cb(&insn->mem_cbs, cb, flags, rw, udata); } void qemu_plugin_register_vcpu_mem_inline_per_vcpu( @@ -154,8 +149,7 @@ void qemu_plugin_register_vcpu_mem_inline_per_vcpu( qemu_plugin_u64 entry, uint64_t imm) { - plugin_register_inline_op_on_entry( - &insn->cbs[PLUGIN_CB_MEM][PLUGIN_CB_INLINE], rw, op, entry, imm); + plugin_register_inline_op_on_entry(&insn->mem_cbs, rw, op, entry, imm); } void qemu_plugin_register_vcpu_tb_trans_cb(qemu_plugin_id_t id, From patchwork Thu Apr 4 23:06:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 785854 Delivered-To: patch@linaro.org Received: by 2002:adf:f001:0:b0:33e:7753:30bd with SMTP id j1csp1074367wro; Thu, 4 Apr 2024 16:08:38 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVTZ0oPkGTJjfrJk+RVfdjykMg1uHYerS1y6OXqVwM1sMDWgx/K9yEZrOZlLWoO0kmsxUPZBDc2JelmxVrrLSA1 X-Google-Smtp-Source: AGHT+IGC/DDBqejVSNsiUKQB4g85vujDITgfNXfoXmE8WAhbgZyQMpQjY/OOogM5riAmTjUpM4KA X-Received: by 2002:a05:6808:2184:b0:3c3:e2e2:ec7c with SMTP id be4-20020a056808218400b003c3e2e2ec7cmr4863408oib.31.1712272118218; Thu, 04 Apr 2024 16:08:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712272118; cv=none; d=google.com; s=arc-20160816; b=Z9lV25U9Sy/hA0Yt3Qx/DLUps+LRtN8e/Q2USB1IUrUOxFgvUAzoMv1pWeIDEJrLHP eAG4PsWLepFBxC+tiDlLLKVbL8BGf/6LX2Bu1edurUyOf2DfvMXfwIHjPNN+naNv//Zo H4i7b3W+WjVlarKwXJTzy+7frRlyqWFzyQv/7z6okz7DfruTh2wNyOWfMdcx8fLF6mK+ 9+Ruj95nxein4oBy+KqbGnfVCGT9OuglNzNTGZ8OYDrmGomBqgmBbZIQCodVKvPcIGA9 hTT1NmcZaPrIq6hmoGjzVViRhSKgi67y/263sDyYNGGV6NYZwSBf8pMyuAhDKIpHb7qN JTIg== 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=RzYzU7RypP3Y+HHaxfaYXazYrOjoOSxUmTQNH2aYDBw=; fh=vm85eyWrvOAHduw3sqEA+cYBqvHB7M0MHFcRJg7VWOo=; b=Xc3LJTzP/9mg0LjWBSKHCyriCdjiEp4UWpZq+D1ONFLvvvwwZmhwVbeTjjHAcOejOn whKol6WrJtyCw9exszvrJ4n9iJGSgGUwJee9RTiI/nNa4Hq5HWyAems3UZNrpotZJH3K eGmYKPmzqUISqWXDtFMIxZMg73u04VGDiFwOzBk2Qt6UMfZZcu2GwieEO7XcupnCUGz1 FkvaivfpYh/FfsacgPS4mwQi2iO61lfOCVz4TumUtSk/H2Ga2/1XMfQ/bSAoXdOXLDW2 HvGa5CzGkRp7DNf0wtasNW98Uh/iy1kQFXlw+0KjXW8tdwLZ5mNNpQDAAeMObkigc815 ysoA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YoXeEzup; 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 t9-20020a05622a01c900b00431310f8ba4si430163qtw.340.2024.04.04.16.08.38 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 04 Apr 2024 16:08:38 -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=YoXeEzup; 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 1rsWAX-00029F-Pe; Thu, 04 Apr 2024 19:06:53 -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 1rsWAS-00027n-Dn for qemu-devel@nongnu.org; Thu, 04 Apr 2024 19:06:48 -0400 Received: from mail-pj1-x1032.google.com ([2607:f8b0:4864:20::1032]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rsWAH-0007ns-2o for qemu-devel@nongnu.org; Thu, 04 Apr 2024 19:06:45 -0400 Received: by mail-pj1-x1032.google.com with SMTP id 98e67ed59e1d1-29ddfada0d0so1123350a91.3 for ; Thu, 04 Apr 2024 16:06:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712271995; x=1712876795; 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=RzYzU7RypP3Y+HHaxfaYXazYrOjoOSxUmTQNH2aYDBw=; b=YoXeEzupH6xqdljw1B/7iOAqN+hBKYCVDOuhA+nJPpF9eaCVsShQDFD3jUENwSejWo Ub/MXkWbUKx2qJlO1sV+skZbqA9+zefqgU2XD7VmX+a9iffzfAcwxTofB4R64wOjDtYG /a/N05+cOfBuwr+rbGw8hOYPMsiuNZCACGndevnkGjCeL9sdIdLDGoCYRoZ0B9mBUyCH Hfulo/mhke0/xY6Zd+Ovtntg9y0OzkwFkYI25+8cxmfuQtdTaPZe1Fu4CKvVXt7WsN+d D7PCnOb3F6/1a1LbkDIcp7AkY/wyuQr5PhTyKuAT+/64a1c3H2Dda0E/DkAMc/uAWrBT QwHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712271995; x=1712876795; 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=RzYzU7RypP3Y+HHaxfaYXazYrOjoOSxUmTQNH2aYDBw=; b=S+NazxclUMbOc+tsKICklz8cmVnRqrVy4JUj0Tw2L+lbbXY1SKyQ2OBwwDjx4pNAAK Y8mwPbZyPnZMPVCPJJOvnaWrzc7lG0NT2uMwGzDFtTvrE6hzGdIH4H5HBK+1nitgWR/F KYZIum5uhgb5R6NI+vV9tFwOPafA08t5wcolbCNjcZIFV9xWANmhZEBi5CzIF8iIT+4s cNkK0PH+cE8xjZozRhPb4Nytf9FnVMO0YCm25RewAqP2kg7hmUBwBaLK4AKkfDyVh5La AGjgJcCZxfJkOdYgXDWk+tC6L3cr3bXGRlLzst4YL/ttI+VZVorfAnA8RSWsmTixQorM N3yw== X-Gm-Message-State: AOJu0Yztc4qK4uZNmZYuq/rvGylvibqNhlYAEHWzrQwQkNpyC1k8aj0k zdD3/CIF4fijh6VyugWbrH/24SSF4dglMOhVroQEi2ngdo7afNUOXg4qKZNzim/K1uOdpKE664+ q X-Received: by 2002:a17:90b:358f:b0:2a2:9f46:439 with SMTP id mm15-20020a17090b358f00b002a29f460439mr4249752pjb.9.1712271995698; Thu, 04 Apr 2024 16:06:35 -0700 (PDT) Received: from stoup.. (098-147-007-212.res.spectrum.com. [98.147.7.212]) by smtp.gmail.com with ESMTPSA id q36-20020a17090a17a700b002a2f3cfc92asm1052592pja.16.2024.04.04.16.06.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Apr 2024 16:06:35 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Pierrick Bouvier Subject: [PATCH v2 16/21] plugins: Introduce PLUGIN_CB_MEM_REGULAR Date: Thu, 4 Apr 2024 13:06:06 -1000 Message-Id: <20240404230611.21231-17-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240404230611.21231-1-richard.henderson@linaro.org> References: <20240404230611.21231-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1032; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1032.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, T_SPF_TEMPERROR=0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Use different enumerators for vcpu_udata and vcpu_mem callbacks. Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- include/qemu/plugin.h | 1 + accel/tcg/plugin-gen.c | 2 +- plugins/core.c | 4 ++-- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/include/qemu/plugin.h b/include/qemu/plugin.h index cf9758be55..34498da717 100644 --- a/include/qemu/plugin.h +++ b/include/qemu/plugin.h @@ -67,6 +67,7 @@ union qemu_plugin_cb_sig { enum plugin_dyn_cb_type { PLUGIN_CB_REGULAR, + PLUGIN_CB_MEM_REGULAR, PLUGIN_CB_INLINE, }; diff --git a/accel/tcg/plugin-gen.c b/accel/tcg/plugin-gen.c index e77ff2a565..c545303956 100644 --- a/accel/tcg/plugin-gen.c +++ b/accel/tcg/plugin-gen.c @@ -361,7 +361,7 @@ static void plugin_gen_inject(struct qemu_plugin_tb *plugin_tb) if (cb->rw & rw) { switch (cb->type) { - case PLUGIN_CB_REGULAR: + case PLUGIN_CB_MEM_REGULAR: gen_mem_cb(cb, meminfo, addr); break; case PLUGIN_CB_INLINE: diff --git a/plugins/core.c b/plugins/core.c index b0615f1e7f..0213513ec6 100644 --- a/plugins/core.c +++ b/plugins/core.c @@ -391,7 +391,7 @@ void plugin_register_vcpu_mem_cb(GArray **arr, struct qemu_plugin_dyn_cb *dyn_cb = plugin_get_dyn_cb(arr); dyn_cb->userp = udata; - dyn_cb->type = PLUGIN_CB_REGULAR; + dyn_cb->type = PLUGIN_CB_MEM_REGULAR; dyn_cb->rw = rw; dyn_cb->regular.f.vcpu_mem = cb; @@ -547,7 +547,7 @@ void qemu_plugin_vcpu_mem_cb(CPUState *cpu, uint64_t vaddr, break; } switch (cb->type) { - case PLUGIN_CB_REGULAR: + case PLUGIN_CB_MEM_REGULAR: cb->regular.f.vcpu_mem(cpu->cpu_index, make_plugin_meminfo(oi, rw), vaddr, cb->userp); break; From patchwork Thu Apr 4 23:06:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 785845 Delivered-To: patch@linaro.org Received: by 2002:adf:f001:0:b0:33e:7753:30bd with SMTP id j1csp1074057wro; Thu, 4 Apr 2024 16:07:42 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWZj/iOrkj11Lnkk4GrkThJEkoYL29Le/xjZQqP57kj20rnGmenQ7kSZbHcJHLllmPRVTs+lwkHCxxVJBdsBCWM X-Google-Smtp-Source: AGHT+IG8oe9dx3Jre2PVOil6Jqqegc2opQVPipGzmPIxdcjDkszyVcBtZeBvdFT3FJzlcqZiB74/ X-Received: by 2002:a05:620a:40c3:b0:78d:47fd:5c8c with SMTP id g3-20020a05620a40c300b0078d47fd5c8cmr930631qko.1.1712272062550; Thu, 04 Apr 2024 16:07:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712272062; cv=none; d=google.com; s=arc-20160816; b=cxwaR9NvbPRg/cmav4Dc5eup5uZtqAvrdKk79+t4hiZfWE2x6fybEyr2gfusqxY5I1 7q8BZ+jxexui5HyFpTJUFuoN79RJPo6w71QADgdZTH7ZK5Rkx+ojtzUALeRNdIsIhd5T Hil4F+BWtQeEPQo8mlgVFqICNpaGkNLAR8lL8DMZ+xsZ56bla9v43kdePYannPLgAAyl oUvMa9bPpG/tuWGoKqh35S1Dym69QuzGQE7E214MpD3i2/ObwDm2LIlRhJw8gWIq5d5h UmNHCOSF9xS4PqCL0dowCNNZe2+hwQNyLVaV3FIxzUj6FOYa2i5Syp+yGrmXBTwpDEV5 97IA== 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=4O/S7CzC0zSv8/mdbOPeo5wN+nYsN/0iJkrPrfvvWjE=; fh=vm85eyWrvOAHduw3sqEA+cYBqvHB7M0MHFcRJg7VWOo=; b=ZAqXqIVhAlUFthTaC8dzoLgXq+C4e0GnaTr27s5deRF0KhuNuhUTUHIckyB/eVfwor sxBdPZ+qDUReXCb7I2h+uV2/QLzwzDj4Lh75MbNFW/zxratRZttlRr6RziKu0ca446ud 3C3ni6L7snNBeIMfL9vw5l97jmX62fvEF5Kpb1/iAf6KH0SeX7wR4OhOp78via3/2WzC 3OEc/18nx09HsL71r7FV+/3Ttz7UOMddpEoZxgehkvMAzMSog2+YAlSe7ThW/ISStTGI FENBZsrsWlDJecddQYK40aslvVLcjmbyjpr/ulpRRAJVjlQrOj2mh1wyUvHHgGZGRpde R0EQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Wxf9tWvX; 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 xy3-20020a05620a5dc300b0078d48ec6c8csi367393qkn.630.2024.04.04.16.07.42 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 04 Apr 2024 16:07:42 -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=Wxf9tWvX; 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 1rsWAX-00029E-98; Thu, 04 Apr 2024 19:06:53 -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 1rsWAK-00024U-P9 for qemu-devel@nongnu.org; Thu, 04 Apr 2024 19:06:42 -0400 Received: from mail-pg1-x532.google.com ([2607:f8b0:4864:20::532]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rsWAI-0007oE-6V for qemu-devel@nongnu.org; Thu, 04 Apr 2024 19:06:39 -0400 Received: by mail-pg1-x532.google.com with SMTP id 41be03b00d2f7-5d4d15ec7c5so1303685a12.1 for ; Thu, 04 Apr 2024 16:06:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712271997; x=1712876797; 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=4O/S7CzC0zSv8/mdbOPeo5wN+nYsN/0iJkrPrfvvWjE=; b=Wxf9tWvX84MS44byu01z9u6b3uAa1gWiMqivddwssIWdcGrGFoTdERiNPeEajahtiK HKlLcAXgUCTkt3GhVI8A8MuiTY99y0mpJSmB/9stHoShk6Y79Ym5uBoUtoCt86PMCiek RGK1zkc1DKgLo+cLLIi0z74uyNeRRu+aWWPUnS8IJIBjir/VOqIlWoGwdmBgUcUkfJd4 j1nylsFicHgO03+pURB0Euwf4iAqfl5Pno8V/6qjuoS78gJWBMIU63kUqS9S9gHSrQEJ 0zP9kO3xDej9nhOOcp3fZ8GFIO+FUdTU6MSM1t7Ew1omebOnUHQcAvQgKVn0NC1qG3Qb kepg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712271997; x=1712876797; 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=4O/S7CzC0zSv8/mdbOPeo5wN+nYsN/0iJkrPrfvvWjE=; b=HEdL771Qs9GMMGCtjOz/cT1tjBpqH2NSpxMnfGkqjwr9KwOlYxIt/mN+AdL+ZuDbad rUm3INuUdS5OXFUQIdKxctNQQOQ7pm8zAGlx7htW7kllCSi8UidiUBg/50bi3eO3XY6P GsGTt7cdUzfX34cGIFcKxN6zTenq1ZrxAUbiQfU87hykHdclqRkLj451B+ym33QaUZhO /NmhwwyRtS9KO27QTPWGHJBqX1oGIXbgbQrq9eJ8VccVvjsxiFFxABkMyoRSA0zmjKIR yiRvn7H0qKatnp9wmV2W7XOU5Qy+NViuJtgQTn8E8/w3c0zPNquNpXoEq0SiM43p+xpP Wc5w== X-Gm-Message-State: AOJu0YyWvWIswky6mVDstuem1rwwJ7UnFd5J20iHei1UJjGzJ2RpM2jk GC7dj1g4pGgd/hrfP5fHbfkIoJLyKSMmbJlc5zt++droOBoQRCKHsbnDmoYnuHHNKjDyXiGiWMq O X-Received: by 2002:a17:90a:d34b:b0:2a2:4390:a1b1 with SMTP id i11-20020a17090ad34b00b002a24390a1b1mr1183251pjx.5.1712271996945; Thu, 04 Apr 2024 16:06:36 -0700 (PDT) Received: from stoup.. (098-147-007-212.res.spectrum.com. [98.147.7.212]) by smtp.gmail.com with ESMTPSA id q36-20020a17090a17a700b002a2f3cfc92asm1052592pja.16.2024.04.04.16.06.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Apr 2024 16:06:36 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Pierrick Bouvier Subject: [PATCH v2 17/21] plugins: Replace pr_ops with a proper debug dump flag Date: Thu, 4 Apr 2024 13:06:07 -1000 Message-Id: <20240404230611.21231-18-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240404230611.21231-1-richard.henderson@linaro.org> References: <20240404230611.21231-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::532; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x532.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org The DEBUG_PLUGIN_GEN_OPS ifdef is replaced with "-d op_plugin". The second pr_ops call can be obtained with "-d op". Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- include/qemu/log.h | 1 + include/tcg/tcg.h | 1 + accel/tcg/plugin-gen.c | 67 +++++++----------------------------------- tcg/tcg.c | 29 +++++++++++++++++- util/log.c | 4 +++ 5 files changed, 45 insertions(+), 57 deletions(-) diff --git a/include/qemu/log.h b/include/qemu/log.h index df59bfabcd..e10e24cd4f 100644 --- a/include/qemu/log.h +++ b/include/qemu/log.h @@ -36,6 +36,7 @@ bool qemu_log_separate(void); #define LOG_STRACE (1 << 19) #define LOG_PER_THREAD (1 << 20) #define CPU_LOG_TB_VPU (1 << 21) +#define LOG_TB_OP_PLUGIN (1 << 22) /* Lock/unlock output. */ diff --git a/include/tcg/tcg.h b/include/tcg/tcg.h index 196e3b7ba1..135e36d729 100644 --- a/include/tcg/tcg.h +++ b/include/tcg/tcg.h @@ -1070,5 +1070,6 @@ static inline const TCGOpcode *tcg_swap_vecop_list(const TCGOpcode *n) } bool tcg_can_emit_vecop_list(const TCGOpcode *, TCGType, unsigned); +void tcg_dump_ops(TCGContext *s, FILE *f, bool have_prefs); #endif /* TCG_H */ diff --git a/accel/tcg/plugin-gen.c b/accel/tcg/plugin-gen.c index c545303956..49d9b07438 100644 --- a/accel/tcg/plugin-gen.c +++ b/accel/tcg/plugin-gen.c @@ -44,6 +44,7 @@ */ #include "qemu/osdep.h" #include "qemu/plugin.h" +#include "qemu/log.h" #include "cpu.h" #include "tcg/tcg.h" #include "tcg/tcg-temp-internal.h" @@ -186,66 +187,21 @@ static void gen_mem_cb(struct qemu_plugin_dyn_cb *cb, tcg_temp_free_i32(cpu_index); } -/* #define DEBUG_PLUGIN_GEN_OPS */ -static void pr_ops(void) -{ -#ifdef DEBUG_PLUGIN_GEN_OPS - TCGOp *op; - int i = 0; - - QTAILQ_FOREACH(op, &tcg_ctx->ops, link) { - const char *name = ""; - const char *type = ""; - - if (op->opc == INDEX_op_plugin_cb_start) { - switch (op->args[0]) { - case PLUGIN_GEN_FROM_TB: - name = "tb"; - break; - case PLUGIN_GEN_FROM_INSN: - name = "insn"; - break; - case PLUGIN_GEN_FROM_MEM: - name = "mem"; - break; - case PLUGIN_GEN_AFTER_INSN: - name = "after insn"; - break; - default: - break; - } - switch (op->args[1]) { - case PLUGIN_GEN_CB_UDATA: - type = "udata"; - break; - case PLUGIN_GEN_CB_INLINE: - type = "inline"; - break; - case PLUGIN_GEN_CB_MEM: - type = "mem"; - break; - case PLUGIN_GEN_ENABLE_MEM_HELPER: - type = "enable mem helper"; - break; - case PLUGIN_GEN_DISABLE_MEM_HELPER: - type = "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(struct qemu_plugin_tb *plugin_tb) { TCGOp *op, *next; int insn_idx = -1; - pr_ops(); + if (unlikely(qemu_loglevel_mask(LOG_TB_OP_PLUGIN) + && qemu_log_in_addr_range(plugin_tb->vaddr))) { + FILE *logfile = qemu_log_trylock(); + if (logfile) { + fprintf(logfile, "OP before plugin injection:\n"); + tcg_dump_ops(tcg_ctx, logfile, false); + fprintf(logfile, "\n"); + qemu_log_unlock(logfile); + } + } /* * While injecting code, we cannot afford to reuse any ebb temps @@ -383,7 +339,6 @@ static void plugin_gen_inject(struct qemu_plugin_tb *plugin_tb) break; } } - pr_ops(); } bool plugin_gen_tb_start(CPUState *cpu, const DisasContextBase *db, diff --git a/tcg/tcg.c b/tcg/tcg.c index 363a065e28..d248c52e96 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -2540,6 +2540,15 @@ static const char bswap_flag_name[][6] = { [TCG_BSWAP_IZ | TCG_BSWAP_OS] = "iz,os", }; +#ifdef CONFIG_PLUGIN +static const char * const plugin_from_name[] = { + "from-tb", + "from-insn", + "after-insn", + "after-tb", +}; +#endif + static inline bool tcg_regset_single(TCGRegSet d) { return (d & (d - 1)) == 0; @@ -2558,7 +2567,7 @@ static inline TCGReg tcg_regset_first(TCGRegSet d) #define ne_fprintf(...) \ ({ int ret_ = fprintf(__VA_ARGS__); ret_ >= 0 ? ret_ : 0; }) -static void tcg_dump_ops(TCGContext *s, FILE *f, bool have_prefs) +void tcg_dump_ops(TCGContext *s, FILE *f, bool have_prefs) { char buf[128]; TCGOp *op; @@ -2714,6 +2723,24 @@ static void tcg_dump_ops(TCGContext *s, FILE *f, bool have_prefs) i = k = 1; } break; +#ifdef CONFIG_PLUGIN + case INDEX_op_plugin_cb: + { + TCGArg from = op->args[k++]; + const char *name = NULL; + + if (from < ARRAY_SIZE(plugin_from_name)) { + name = plugin_from_name[from]; + } + if (name) { + col += ne_fprintf(f, "%s", name); + } else { + col += ne_fprintf(f, "$0x%" TCG_PRIlx, from); + } + i = 1; + } + break; +#endif default: i = 0; break; diff --git a/util/log.c b/util/log.c index d36c98da0b..6219819855 100644 --- a/util/log.c +++ b/util/log.c @@ -466,6 +466,10 @@ const QEMULogItem qemu_log_items[] = { "show micro ops after optimization" }, { CPU_LOG_TB_OP_IND, "op_ind", "show micro ops before indirect lowering" }, +#ifdef CONFIG_PLUGIN + { LOG_TB_OP_PLUGIN, "op_plugin", + "show micro ops before plugin injection" }, +#endif { CPU_LOG_INT, "int", "show interrupts/exceptions in short format" }, { CPU_LOG_EXEC, "exec", From patchwork Thu Apr 4 23:06:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 785860 Delivered-To: patch@linaro.org Received: by 2002:adf:f001:0:b0:33e:7753:30bd with SMTP id j1csp1074604wro; Thu, 4 Apr 2024 16:09:20 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWO/wryL7NAad5rljNnTlxaZ+sAPKzkdHpDZYm/1SMUYhWsu0+ga+SDqgScXd9Eeka/5T2ykZeQ0tZXpgOWpKXs X-Google-Smtp-Source: AGHT+IFxOMvpGLIKleI3vR/Ze3kJ/SSRFRWureOhvYN+casrfEtnX1fyfMLytp8hCFLQj6g0kyJT X-Received: by 2002:a05:620a:880a:b0:78b:e555:a680 with SMTP id qj10-20020a05620a880a00b0078be555a680mr1158778qkn.52.1712272160113; Thu, 04 Apr 2024 16:09:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712272160; cv=none; d=google.com; s=arc-20160816; b=EtxdPszEnt1qhyzP+cEMPdcmdzkpg6wez2dyldSLIj8RZNV+5/29CVKXNDh32o3/0U p1FZRL0XBwyVx2JtkYoY/AlQWRU5GdsvjdrZDRHoy6/uIVIpGnqguegM9TpGW9WOCUqf By9ZReihE0l3Q+VryddUyAQidhmUZ9VP/BvwJ0hQsGeXYFYGhYs+hftUZV4s0eCKDcN3 lb8hproo17AXGSruLJkr0SXGylYblM0xjbjJskquxWoMJp1igomG/e/gIiJVXhqxNNF2 PmIUu+cwawzYZApUoEDUXEoPEAOHaE2bbF4bL2uCHJJ/LaPC1WSvy76doS0tP/NJktKF OsBw== 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=LosuIyCzAc9oB5OxDPZNgW94mh4MJImjLMLCS31GDcs=; fh=vm85eyWrvOAHduw3sqEA+cYBqvHB7M0MHFcRJg7VWOo=; b=Tn9faO1OmZEWrNSAQvYpEaeGCO+cy5DfbF1UGcqpKXIZ8SnOTuOQeSVDbQueDG+Ta6 GfqnujD+hUMkL6/ruY9A/i8wGJOn1BfnnfTyaDGUIJVyFZu7Cz6Z53a11mGJ5J7WHkZt esDMxtTK3OdCyThiX0rc8uWVqeqVcWjG5dM0ltrog1Lt6dE0RielAmXE5aDf1+2NLkxj 6VF1gwuXMnoUDBR+4EGiog7+DSoeDv8eRD/MKlieLal30zL8m8/TIB6SmrhFKRnVf9Gy oiShr0ozEam2ukfdXQs9JLUMbgNRAEuMI+IRkY/1FTd0gbYygCge3pBEha3WGt8gWLSY ABfg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=OboIGTMZ; 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 pa16-20020a05620a831000b0078a0a41e771si425600qkn.725.2024.04.04.16.09.19 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 04 Apr 2024 16:09:20 -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=OboIGTMZ; 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 1rsWAX-00029D-90; Thu, 04 Apr 2024 19:06:53 -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 1rsWAL-00024X-Af for qemu-devel@nongnu.org; Thu, 04 Apr 2024 19:06:42 -0400 Received: from mail-pj1-x102e.google.com ([2607:f8b0:4864:20::102e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rsWAJ-0007oQ-B9 for qemu-devel@nongnu.org; Thu, 04 Apr 2024 19:06:41 -0400 Received: by mail-pj1-x102e.google.com with SMTP id 98e67ed59e1d1-2a2c9903ef0so1149349a91.3 for ; Thu, 04 Apr 2024 16:06:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712271998; x=1712876798; 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=LosuIyCzAc9oB5OxDPZNgW94mh4MJImjLMLCS31GDcs=; b=OboIGTMZwcuNF2FF1HLxC0z92zAMXT9T1BPVbYOgbx7zCjFwMB5Ro8znA4SX4daNxZ HJFRlpWt434bNppObDsjeasDDcVr8i5z8F5rp+bLC/esQFBV6uRE3Pqmlouoo6jDQgH2 qqG0/vlJT+wn2Z+LMSkStzClFvHlxI3F1jfjlveiu8LD2FU9J2EEQpxpYRuIlTy5JkBL YgCn5Tyw2Tn+zsyPy5v9tB3D4Aktovg9VvMphws19w9dbY91ZUceA0ry1EL5G6GaO8YZ vbP6pFZrfgIVS/7KLT/Km5ifgAaRHsdceO2ON+if57fpVns7iSecr9tgo9JBT4yV4aTk EEbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712271998; x=1712876798; 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=LosuIyCzAc9oB5OxDPZNgW94mh4MJImjLMLCS31GDcs=; b=dcHFGl+m5Vj81SPoyL6nmkZQpswTSZW8KfzrVCQuFMJRMA5y22mUGsLUSx7sqHqj61 UejsNzTtg7v2B0fNHFHZ/xlxe/+pXFV4xEVyDP/sijkqKfB2wN0LoUHGli8LSCXo7Z99 kBhj35867VPHEABta4xksESROQ/wz8aP1OuMcn101gDGp0eAC2xVn4DWNXHznRo99HpU CEP5ohRC9MGcltZY2mwvMv/QmnYPYHXa8TK/3p/C6CScooK7InrnSQIC5bqVq8TKhYLf juUtsPhcXzWXFZw2uwVvBFhf0jy2lzzcSNjK3fr6kAW5iBk39PydxoXmNR4RJyLU7bkB hKIg== X-Gm-Message-State: AOJu0Yw3xbbLkc6NLvj0UEoRtMoMlGXF749M92h3fBCFPk7czHlbs7wJ PLWg5QXqvT31LplOL0z1TOw6uZzAyPLnGrBrNiuvrTdbP0OHjb/xD8uph20XA01UscrlzehAe6b h X-Received: by 2002:a17:90a:cb8d:b0:2a2:7064:447a with SMTP id a13-20020a17090acb8d00b002a27064447amr1166183pju.18.1712271998141; Thu, 04 Apr 2024 16:06:38 -0700 (PDT) Received: from stoup.. (098-147-007-212.res.spectrum.com. [98.147.7.212]) by smtp.gmail.com with ESMTPSA id q36-20020a17090a17a700b002a2f3cfc92asm1052592pja.16.2024.04.04.16.06.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Apr 2024 16:06:37 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Pierrick Bouvier Subject: [PATCH v2 18/21] plugins: Split out common cb expanders Date: Thu, 4 Apr 2024 13:06:08 -1000 Message-Id: <20240404230611.21231-19-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240404230611.21231-1-richard.henderson@linaro.org> References: <20240404230611.21231-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::102e; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102e.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- accel/tcg/plugin-gen.c | 84 +++++++++++++++++++++--------------------- 1 file changed, 41 insertions(+), 43 deletions(-) diff --git a/accel/tcg/plugin-gen.c b/accel/tcg/plugin-gen.c index 49d9b07438..5b63b93114 100644 --- a/accel/tcg/plugin-gen.c +++ b/accel/tcg/plugin-gen.c @@ -187,6 +187,37 @@ static void gen_mem_cb(struct qemu_plugin_dyn_cb *cb, tcg_temp_free_i32(cpu_index); } +static void inject_cb(struct qemu_plugin_dyn_cb *cb) + +{ + switch (cb->type) { + case PLUGIN_CB_REGULAR: + gen_udata_cb(cb); + break; + case PLUGIN_CB_INLINE: + gen_inline_cb(cb); + break; + default: + g_assert_not_reached(); + } +} + +static void inject_mem_cb(struct qemu_plugin_dyn_cb *cb, + enum qemu_plugin_mem_rw rw, + qemu_plugin_meminfo_t meminfo, TCGv_i64 addr) +{ + if (cb->rw & rw) { + switch (cb->type) { + case PLUGIN_CB_MEM_REGULAR: + gen_mem_cb(cb, meminfo, addr); + break; + default: + inject_cb(cb); + break; + } + } +} + static void plugin_gen_inject(struct qemu_plugin_tb *plugin_tb) { TCGOp *op, *next; @@ -248,19 +279,8 @@ static void plugin_gen_inject(struct qemu_plugin_tb *plugin_tb) cbs = plugin_tb->cbs; for (i = 0, n = (cbs ? cbs->len : 0); i < n; i++) { - struct qemu_plugin_dyn_cb *cb = - &g_array_index(cbs, struct qemu_plugin_dyn_cb, i); - - switch (cb->type) { - case PLUGIN_CB_REGULAR: - gen_udata_cb(cb); - break; - case PLUGIN_CB_INLINE: - gen_inline_cb(cb); - break; - default: - g_assert_not_reached(); - } + inject_cb( + &g_array_index(cbs, struct qemu_plugin_dyn_cb, i)); } break; @@ -271,19 +291,8 @@ static void plugin_gen_inject(struct qemu_plugin_tb *plugin_tb) cbs = insn->insn_cbs; for (i = 0, n = (cbs ? cbs->len : 0); i < n; i++) { - struct qemu_plugin_dyn_cb *cb = - &g_array_index(cbs, struct qemu_plugin_dyn_cb, i); - - switch (cb->type) { - case PLUGIN_CB_REGULAR: - gen_udata_cb(cb); - break; - case PLUGIN_CB_INLINE: - gen_inline_cb(cb); - break; - default: - g_assert_not_reached(); - } + inject_cb( + &g_array_index(cbs, struct qemu_plugin_dyn_cb, i)); } break; @@ -300,33 +309,22 @@ static void plugin_gen_inject(struct qemu_plugin_tb *plugin_tb) { TCGv_i64 addr = temp_tcgv_i64(arg_temp(op->args[0])); qemu_plugin_meminfo_t meminfo = op->args[1]; + enum qemu_plugin_mem_rw rw = + (qemu_plugin_mem_is_store(meminfo) + ? QEMU_PLUGIN_MEM_W : QEMU_PLUGIN_MEM_R); struct qemu_plugin_insn *insn; const GArray *cbs; - int i, n, rw; + int i, n; assert(insn_idx >= 0); insn = g_ptr_array_index(plugin_tb->insns, insn_idx); - rw = qemu_plugin_mem_is_store(meminfo) ? 2 : 1; tcg_ctx->emit_before_op = op; cbs = insn->mem_cbs; for (i = 0, n = (cbs ? cbs->len : 0); i < n; i++) { - struct qemu_plugin_dyn_cb *cb = - &g_array_index(cbs, struct qemu_plugin_dyn_cb, i); - - if (cb->rw & rw) { - switch (cb->type) { - case PLUGIN_CB_MEM_REGULAR: - gen_mem_cb(cb, meminfo, addr); - break; - case PLUGIN_CB_INLINE: - gen_inline_cb(cb); - break; - default: - g_assert_not_reached(); - } - } + inject_mem_cb(&g_array_index(cbs, struct qemu_plugin_dyn_cb, i), + rw, meminfo, addr); } tcg_ctx->emit_before_op = NULL; From patchwork Thu Apr 4 23:06:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 785851 Delivered-To: patch@linaro.org Received: by 2002:adf:f001:0:b0:33e:7753:30bd with SMTP id j1csp1074333wro; Thu, 4 Apr 2024 16:08:34 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUZuew+1ogAJG1QdGHRqXwDkLaL05VYCpkiEDvQoVwe67vSBflHMgsDV5ozhOWCki0Pt/4B9YpST/Byyr90qAL2 X-Google-Smtp-Source: AGHT+IFEdu1yA07ubWrKNX6PxOFQwKz77Z7khL/3anYEbuejR7mgwMI0cRN5aPLkkKAdEZseoJ4T X-Received: by 2002:a05:6214:3018:b0:699:3883:5474 with SMTP id ke24-20020a056214301800b0069938835474mr1305152qvb.33.1712272113836; Thu, 04 Apr 2024 16:08:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712272113; cv=none; d=google.com; s=arc-20160816; b=uI6YY96sKBBZvGHI1wiCz2KBuRxiFANgj4+M7BYVmJHX7TVCcHqPuWbtesWqjuydPy nT67f1PiihTtVvYFsM5fbe/FH0tt3ORyDNyVysL6/9hKleDhFhRtPiNThCk0aRGs1B2Y /XEHTop7syllLxPdwyoDMal+ZXjpXxQn9OAShqHBdrMzm9qa+evNAnGRBje0HucSHVkf bVL8VOp+5E6bWd2xuvRZFUF/sA5YW2OtmUp8KqUWAepLE3RP3F93RrBGgLnS4nnFeBJd pX7bWSOWXk8EQRet4cDJPhY2Lx/ODJt8sCSk4Z4tn+6YM8rCHnvG09LZROBT/Q2AnUTo scDQ== 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=G3LtGKJ/E6t3oKQLojhaCAB+/niRzlzRz3BS8xhiLDs=; fh=vm85eyWrvOAHduw3sqEA+cYBqvHB7M0MHFcRJg7VWOo=; b=NDRIvKBMn/joDKTxxbhhaC5DWki5PH2/hdcTW9BKsN+gQFASKPHFB5vq4JPEJj1x/x asv1D8t9b5JudXO6P2BjTcwdFfET67owp1daEKFzwv14pkhcnhiN380EPpI+Zz8H+6h9 xloMBWRhx53BVMJkHygDVLlYAaKaU3r6InfJ7sjPPduf9Ccqq5tndi391JAKZtoNML/w povxoE2F33hVx+Km2zv2V9MCKN+0reJaAQ6j82qAIUdWn9apEx5VUeB1dVfvdbk2FeVj QMTmh/7GKEKw+AcBA34Yw7QXbyhJnPW/A6yTRPUlFwLeg77E0hcV0AJM/7fWPLXl8HMg e18g==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=RF8CibcC; 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 j10-20020a0cc34a000000b006993b951aa3si427670qvi.396.2024.04.04.16.08.33 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 04 Apr 2024 16:08:33 -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=RF8CibcC; 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 1rsWAU-000289-N9; Thu, 04 Apr 2024 19:06:50 -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 1rsWAN-00025G-E2 for qemu-devel@nongnu.org; Thu, 04 Apr 2024 19:06:45 -0400 Received: from mail-pj1-x1033.google.com ([2607:f8b0:4864:20::1033]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rsWAL-0007og-1t for qemu-devel@nongnu.org; Thu, 04 Apr 2024 19:06:42 -0400 Received: by mail-pj1-x1033.google.com with SMTP id 98e67ed59e1d1-29c14800a7fso1138935a91.2 for ; Thu, 04 Apr 2024 16:06:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712272000; x=1712876800; 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=G3LtGKJ/E6t3oKQLojhaCAB+/niRzlzRz3BS8xhiLDs=; b=RF8CibcCm7oCgYVFwjVrmPEFTwrMIGkjLAlxDXV0Www5JwbryWqJ9i5oCBOhmuVEuH R9RqWoKUQtZ06omCKRhFzHs9rQQghb6u3zk9BuqlBSObx5FFdz4nttSMDiVhV+UsH4Gv nmp+BADiTR5Kv7eRvXY8vlA9guBXZXlMuSkWZRFThQmW5WgW67wlHppDFKq6ZjudqRD/ e1GYF2xFBKqwJlsxs90AixR7I0+1iVZvEyABDuFdznFxhsrUU08NEvpFSR4CJaEjdkmb 6Szqek0dm36HZQKdvYG7MPqyQk+LbCUYbsBHMPRWmeGC7qmzFD6s3UE+FAWYk1BHeARF q7fA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712272000; x=1712876800; 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=G3LtGKJ/E6t3oKQLojhaCAB+/niRzlzRz3BS8xhiLDs=; b=RpyNVueutDBapm9ZMWwvdzvy+2iYrruPDbEfwmoxLTy3Az1dja3U4nYFnPxap79T0o 9bH/J5WX27oaUTAVhiRm2EYFULCW617cbPPXbsBsX5o2CyGh0Yf+nRpLtM5IpgTI4RH4 Kh/ePI+zX7Xz0JElBSSCjco9Ho59I+df0NxOGPOxddpCXwQbw40MNWy+heFoWCFmadCa YbHa9ypAJOosY4z1TVb4rGYRrYXgKUch6hhwNHQkKUOVBC1KcdOc01WNB6kMdG09bZXn xZorYDviyhQjSCF4XIDT6uMQnbr1P8k1Kz6i96jmufy3MKty8p92NbtBOh8PnVA3pw1z EMdA== X-Gm-Message-State: AOJu0YyRYmyu/QFtGPmuWsEt4BMR295ztq+BGXNt5stqhazEUh/QSTL9 HhLJYjdiriMTEsy8q3n9GOlWMJoFJcLVQRvXEquLefQXCptGHnUSBD1qyyk0UZDGRhndOLAd3iN 2 X-Received: by 2002:a17:90a:c385:b0:2a2:3223:1930 with SMTP id h5-20020a17090ac38500b002a232231930mr1132777pjt.8.1712271999364; Thu, 04 Apr 2024 16:06:39 -0700 (PDT) Received: from stoup.. (098-147-007-212.res.spectrum.com. [98.147.7.212]) by smtp.gmail.com with ESMTPSA id q36-20020a17090a17a700b002a2f3cfc92asm1052592pja.16.2024.04.04.16.06.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Apr 2024 16:06:39 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Pierrick Bouvier Subject: [PATCH v2 19/21] plugins: Merge qemu_plugin_tb_insn_get to plugin-gen.c Date: Thu, 4 Apr 2024 13:06:09 -1000 Message-Id: <20240404230611.21231-20-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240404230611.21231-1-richard.henderson@linaro.org> References: <20240404230611.21231-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1033; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1033.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Merge qemu_plugin_insn_alloc and qemu_plugin_tb_insn_get into plugin_gen_insn_start, since it is used nowhere else. Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- include/qemu/plugin.h | 39 --------------------------------------- accel/tcg/plugin-gen.c | 39 ++++++++++++++++++++++++++++++++------- 2 files changed, 32 insertions(+), 46 deletions(-) diff --git a/include/qemu/plugin.h b/include/qemu/plugin.h index 34498da717..07b1755990 100644 --- a/include/qemu/plugin.h +++ b/include/qemu/plugin.h @@ -128,14 +128,6 @@ static inline void qemu_plugin_insn_cleanup_fn(gpointer data) g_byte_array_free(insn->data, true); } -static inline struct qemu_plugin_insn *qemu_plugin_insn_alloc(void) -{ - struct qemu_plugin_insn *insn = g_new0(struct qemu_plugin_insn, 1); - - insn->data = g_byte_array_sized_new(4); - return insn; -} - /* Internal context for this TranslationBlock */ struct qemu_plugin_tb { GPtrArray *insns; @@ -152,37 +144,6 @@ struct qemu_plugin_tb { GArray *cbs; }; -/** - * qemu_plugin_tb_insn_get(): get next plugin record for translation. - * @tb: the internal tb context - * @pc: address of instruction - */ -static inline -struct qemu_plugin_insn *qemu_plugin_tb_insn_get(struct qemu_plugin_tb *tb, - uint64_t pc) -{ - struct qemu_plugin_insn *insn; - - if (unlikely(tb->n == tb->insns->len)) { - struct qemu_plugin_insn *new_insn = qemu_plugin_insn_alloc(); - g_ptr_array_add(tb->insns, new_insn); - } - - insn = g_ptr_array_index(tb->insns, tb->n++); - g_byte_array_set_size(insn->data, 0); - insn->calls_helpers = false; - insn->mem_helper = false; - insn->vaddr = pc; - if (insn->insn_cbs) { - g_array_set_size(insn->insn_cbs, 0); - } - if (insn->mem_cbs) { - g_array_set_size(insn->mem_cbs, 0); - } - - return insn; -} - /** * struct CPUPluginState - per-CPU state for plugins * @event_mask: plugin event bitmap. Modified only via async work. diff --git a/accel/tcg/plugin-gen.c b/accel/tcg/plugin-gen.c index 5b63b93114..c0cbc26984 100644 --- a/accel/tcg/plugin-gen.c +++ b/accel/tcg/plugin-gen.c @@ -373,11 +373,34 @@ bool plugin_gen_tb_start(CPUState *cpu, const DisasContextBase *db, void plugin_gen_insn_start(CPUState *cpu, const DisasContextBase *db) { struct qemu_plugin_tb *ptb = tcg_ctx->plugin_tb; - struct qemu_plugin_insn *pinsn; + struct qemu_plugin_insn *insn; + size_t n = db->num_insns; + vaddr pc; - pinsn = qemu_plugin_tb_insn_get(ptb, db->pc_next); - tcg_ctx->plugin_insn = pinsn; - plugin_gen_empty_callback(PLUGIN_GEN_FROM_INSN); + assert(n >= 1); + ptb->n = n; + if (n <= ptb->insns->len) { + insn = g_ptr_array_index(ptb->insns, n - 1); + g_byte_array_set_size(insn->data, 0); + } else { + assert(n - 1 == ptb->insns->len); + insn = g_new0(struct qemu_plugin_insn, 1); + insn->data = g_byte_array_sized_new(4); + g_ptr_array_add(ptb->insns, insn); + } + + tcg_ctx->plugin_insn = insn; + insn->calls_helpers = false; + insn->mem_helper = false; + if (insn->insn_cbs) { + g_array_set_size(insn->insn_cbs, 0); + } + if (insn->mem_cbs) { + g_array_set_size(insn->mem_cbs, 0); + } + + pc = db->pc_next; + insn->vaddr = pc; /* * Detect page crossing to get the new host address. @@ -385,16 +408,18 @@ void plugin_gen_insn_start(CPUState *cpu, const DisasContextBase *db) * fetching instructions from a region not backed by RAM. */ if (ptb->haddr1 == NULL) { - pinsn->haddr = NULL; + insn->haddr = NULL; } else if (is_same_page(db, db->pc_next)) { - pinsn->haddr = ptb->haddr1 + pinsn->vaddr - ptb->vaddr; + insn->haddr = ptb->haddr1 + pc - ptb->vaddr; } else { if (ptb->vaddr2 == -1) { ptb->vaddr2 = TARGET_PAGE_ALIGN(db->pc_first); get_page_addr_code_hostp(cpu_env(cpu), ptb->vaddr2, &ptb->haddr2); } - pinsn->haddr = ptb->haddr2 + pinsn->vaddr - ptb->vaddr2; + insn->haddr = ptb->haddr2 + pc - ptb->vaddr2; } + + plugin_gen_empty_callback(PLUGIN_GEN_FROM_INSN); } void plugin_gen_insn_end(void) From patchwork Thu Apr 4 23:06:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 785859 Delivered-To: patch@linaro.org Received: by 2002:adf:f001:0:b0:33e:7753:30bd with SMTP id j1csp1074603wro; Thu, 4 Apr 2024 16:09:20 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWuBBB+vNZDCHCfXf95YgQfdesrknOrmaJ5oQfn8EmoHDzAEASr8XUqO02gL+7DTroxcd+KDOjQgyMuq6evS29q X-Google-Smtp-Source: AGHT+IEd6XTT9Jv0t1NZmW3MIdkEZrDYTHhtHlw/DGKeLS02KWFgw5LaYqtUxpJv0PYoyRp3/N6q X-Received: by 2002:a1f:fccb:0:b0:4d8:7a5e:392f with SMTP id a194-20020a1ffccb000000b004d87a5e392fmr3644171vki.12.1712272159785; Thu, 04 Apr 2024 16:09:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712272159; cv=none; d=google.com; s=arc-20160816; b=MVxgDpnyFnMvT/8Sn8QBkQby/Qx6IzShyM0YEJfzPMjayHYEEEkdeHG4EDcaOwm5yt KTIGZr7uOMRG7VNWgV7bAY6IhUI4lDtFnE/iVFDatrZNcNw6DoSCkQFg0N9DfWO/1dRk t2hXIo5uj6Y/E4Q+grY7+2Zn8grB1Z2CqIFIsBlM6f2S4yIZlQIJrx+soCS0grF4q+DH Z6s1A29tPmtcRyW/1rX5VrFmZ9fi6vvVIvSAbisz5a6Oocobr+bXEUocWySXansHKqeM qo37H7jpH+JFQsprhkR9YdxR9YLVBOcnVy7/Kryht6rTJ9aF/4H/ezV6Kf+LX/irByuj o4sQ== 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=nSa2977I3Rq8Xc+67Y2/yCKgEWXvHU4DRnUfHiUzUVE=; fh=eu2DY09p+eeddYDiV+DalJS3Vr0kxK5BujclYkgWvDw=; b=p5lxwzuplYrPeFpEHubVcybLxhFvtJP3OYtfPVGJW+tkjb6P4zlf4TGpE3TK5ihrwK dTdl9wfPTpvv8YlYJY7WV5PqBjiFGd2SN5PcbLAPj5hhYQAE0hMZB4cN0WeXNDLyqd1E YVx4Cl7U2jGPbAMb4a1tdUX91wHx2PMRg1OOOlYDanXs8tLTdRxg2xwP0F8Y4zDGwO+f uG8ihYsvkmOxm0JHx4tcyehxFg7sqt9duDYAzsqLOG8vJiVm76W7m92hSYiQUT3ZVnoX mrpFOQTBJ9FmPQPA9t5YJlOVONwSKayZ3pO+kWOv4MwjwZtL0JUeGC08ig26AcqOZa1p S0QA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=xO+zmGXV; 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 dr9-20020a05621408e900b006971f65b493si429807qvb.35.2024.04.04.16.09.19 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 04 Apr 2024 16:09:19 -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=xO+zmGXV; 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 1rsWAV-00028F-HA; Thu, 04 Apr 2024 19:06:51 -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 1rsWAR-000272-Au for qemu-devel@nongnu.org; Thu, 04 Apr 2024 19:06:47 -0400 Received: from mail-pg1-x52f.google.com ([2607:f8b0:4864:20::52f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rsWAL-0007ox-Qp for qemu-devel@nongnu.org; Thu, 04 Apr 2024 19:06:44 -0400 Received: by mail-pg1-x52f.google.com with SMTP id 41be03b00d2f7-5e152c757a5so1126937a12.2 for ; Thu, 04 Apr 2024 16:06:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712272000; x=1712876800; 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=nSa2977I3Rq8Xc+67Y2/yCKgEWXvHU4DRnUfHiUzUVE=; b=xO+zmGXVMPg0Us5fPhv6Fjv83GcbyrgECUj6JbXfisfn6lSNzsINhsxVORngNwg2li OWNS+grktLrMraxpmpKBRkGRQPXH+6z2SYUnxXfSsNg6onQry1/5asWYgboDiiYsgaAo wihH8Exv/zrojpfgwNZyVAlYEQKF4YIkah09bkoYWZbrYRCUZ9Fn9DENOBPg+UAV1qdb a8RVvFaARbh07hB58awocumjSZGHhM8zVPKwAsw7ZvCo1zsSt0U31iVFDksFgnfxOrps VfwQ5ia/MUpbnf+qwjDVjjnu9LZmEiHn6lw/+0XDa2tlRbhrz0FBdltOFKlWTL1KVAxw Njug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712272000; x=1712876800; 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=nSa2977I3Rq8Xc+67Y2/yCKgEWXvHU4DRnUfHiUzUVE=; b=Mwr/m/VPYXrFljkw+9od6hOE272xo1qj8wXVZBH4vz3RFDQfrn0aJJgJl1GKEHKBDc vvqadngD1JZGhW0PAwx8fgx92RQeme8DQa+xjxGs343L8iPSjPOPUvRT/qxBXIjnb6Lh 2dFT3g+TtBcN0NOTZQyzaWoy7MetXfDKnWQVe3Er9JXbwwl9yhcWeNi775or7kZcG6zC V8nF8jVHNAX8XYKYuv4OMJWBF0jwpid8HPLUQuN5eP8VPFagBWyohYNzeAls1FkefP2M JOnv95dECJrZ3mYskxFyBpi5lB25VRFJyHN+lIM2jAcKGrnZy1jp1Uym/1VWl4dKTVeA wx6Q== X-Gm-Message-State: AOJu0Yyph2FBuXVCo55MIdNfoVFny4uHPr2IKN4V6GnM0lVBCx3awuKF 1yRZuOybvN5Gx7iT6KMH53vP7TbrPJXekLf4KvxQh+pAKPoDxgZDw2b4cqyjpx5sQmZfnec2Kmr f X-Received: by 2002:a17:90b:3e82:b0:2a1:fcc2:bf36 with SMTP id rj2-20020a17090b3e8200b002a1fcc2bf36mr3594875pjb.22.1712272000656; Thu, 04 Apr 2024 16:06:40 -0700 (PDT) Received: from stoup.. (098-147-007-212.res.spectrum.com. [98.147.7.212]) by smtp.gmail.com with ESMTPSA id q36-20020a17090a17a700b002a2f3cfc92asm1052592pja.16.2024.04.04.16.06.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Apr 2024 16:06:40 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Alex_Benn=C3=A9e?= Subject: [PATCH v2 20/21] plugins: Inline plugin_gen_empty_callback Date: Thu, 4 Apr 2024 13:06:10 -1000 Message-Id: <20240404230611.21231-21-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240404230611.21231-1-richard.henderson@linaro.org> References: <20240404230611.21231-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::52f; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x52f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Each caller can use tcg_gen_plugin_cb directly. Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson --- accel/tcg/plugin-gen.c | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/accel/tcg/plugin-gen.c b/accel/tcg/plugin-gen.c index c0cbc26984..d914d64de0 100644 --- a/accel/tcg/plugin-gen.c +++ b/accel/tcg/plugin-gen.c @@ -60,19 +60,6 @@ enum plugin_gen_from { PLUGIN_GEN_AFTER_TB, }; -static void plugin_gen_empty_callback(enum plugin_gen_from from) -{ - switch (from) { - case PLUGIN_GEN_AFTER_INSN: - case PLUGIN_GEN_FROM_TB: - case PLUGIN_GEN_FROM_INSN: - tcg_gen_plugin_cb(from); - break; - default: - g_assert_not_reached(); - } -} - /* called before finishing a TB with exit_tb, goto_tb or goto_ptr */ void plugin_gen_disable_mem_helpers(void) { @@ -362,7 +349,7 @@ bool plugin_gen_tb_start(CPUState *cpu, const DisasContextBase *db, ptb->mem_only = mem_only; ptb->mem_helper = false; - plugin_gen_empty_callback(PLUGIN_GEN_FROM_TB); + tcg_gen_plugin_cb(PLUGIN_GEN_FROM_TB); } tcg_ctx->plugin_insn = NULL; @@ -419,12 +406,12 @@ void plugin_gen_insn_start(CPUState *cpu, const DisasContextBase *db) insn->haddr = ptb->haddr2 + pc - ptb->vaddr2; } - plugin_gen_empty_callback(PLUGIN_GEN_FROM_INSN); + tcg_gen_plugin_cb(PLUGIN_GEN_FROM_INSN); } void plugin_gen_insn_end(void) { - plugin_gen_empty_callback(PLUGIN_GEN_AFTER_INSN); + tcg_gen_plugin_cb(PLUGIN_GEN_AFTER_INSN); } /* From patchwork Thu Apr 4 23:06:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 785855 Delivered-To: patch@linaro.org Received: by 2002:adf:f001:0:b0:33e:7753:30bd with SMTP id j1csp1074378wro; Thu, 4 Apr 2024 16:08:39 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCV6MiEBVtPtbKvWkubO93auVPliY4+ZLcpXdCsb10r3xy0Ggmve+V+nlvZOx3JUQ/v8QeTsfd5FyIDhkc9vred9 X-Google-Smtp-Source: AGHT+IHVXOMA8avGo3oyuHwj5CVVYErlrkcZjjvjSu6c6Nt5vm7Hs2VKrGwnK5uDePA+hLHn1Fcg X-Received: by 2002:a05:620a:564b:b0:78a:6c09:2a15 with SMTP id vw11-20020a05620a564b00b0078a6c092a15mr1028287qkn.20.1712272119541; Thu, 04 Apr 2024 16:08:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712272119; cv=none; d=google.com; s=arc-20160816; b=gKFEf7t2ktDmlP9zalqps5k7N0O/x4SlDY3B5osAW+uodhdJOTB1sI4/9vIRSphcfa onBMDlmeDSFzy4ybRndzUy5kuLju2TzZpoHnJhMzQC72yPn9aURFwlOmkcKdzmRSUNHI zg8KyqvH+FmVnr/xf63aE23hV7nSut3zJ1OXOebvemN6KYrZQjFgGSvBQnmfcQbpwbAV EtBmTtef0iaYbChpl9MSXTwaxafjCdKNc6EZdRX27m8qDhiB8pbTjyxnGvWSllKMY26w SSNFQte5PZoinlEGeIXugSP/6VpczgsROnL06pxwzKqqf/GExdOQRPNnEfDY5d00nosG KblQ== 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=cdYcjDwLN/xr8PQzvEnfgv6lYJ6ezf5kr9JF5Mk0QDo=; fh=vm85eyWrvOAHduw3sqEA+cYBqvHB7M0MHFcRJg7VWOo=; b=ABGKDMkADp4JIKzPNYElZV9IGeGDStyg2kPzhn7mEDAqBnu6icG4PpSBIXyp25RKVX zx3+TSvgm3jIIWz6I1OXSs5NDOKPdGfLSa6tKLWu8k82HnJ/CHWAqJ5eXlH5S/pgfU8S SSELKFHWUfIIzi6/VyiUSrG/p7g4XRIGPi+mEtm7TF5DlSvuV7cDTIMlDke2pomhLbjV k0wBvhuAt23IukE/moOqaBlV0VX21a05rq/MXnS2dGfMYKHhC4NkvYZ5JUldheq4Hcyn rzg7eQDOIKlw1p5u2QNSSpib2KMZR6K6drr490q+SljJ1rPjzes3r6IRtqURnp29sLPi qjTQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fiaYcA4w; 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 z10-20020ae9f44a000000b0078a00267a7esi435283qkl.482.2024.04.04.16.08.39 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 04 Apr 2024 16:08:39 -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=fiaYcA4w; 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 1rsWAW-00028a-7e; Thu, 04 Apr 2024 19:06:52 -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 1rsWAS-00027b-2z for qemu-devel@nongnu.org; Thu, 04 Apr 2024 19:06:48 -0400 Received: from mail-pj1-x1032.google.com ([2607:f8b0:4864:20::1032]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rsWAN-0007pC-6h for qemu-devel@nongnu.org; Thu, 04 Apr 2024 19:06:44 -0400 Received: by mail-pj1-x1032.google.com with SMTP id 98e67ed59e1d1-2a2c9903ef0so1149382a91.3 for ; Thu, 04 Apr 2024 16:06:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712272002; x=1712876802; 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=cdYcjDwLN/xr8PQzvEnfgv6lYJ6ezf5kr9JF5Mk0QDo=; b=fiaYcA4whMgC7FL8KEWtoPUAF4N34MaHkmu4FYmMjaSKwnJL6s6MgwbLZbTL4AYHb5 MwLzbSwVSOxPGJmbIXDXo3uIqJD5CAA8fYF6z38O87MmTYey3J6fOeLw3rJRNKVsprlV 16tUCJHjpRzEGGL9b3XyhxVNv8JCrsBIlg6MmdkTuPfyElGAH1kTnKSEyCBuv3zOCGh/ E/Za0fCe6ZP8yu4MuYxRlpyVzeuaTwQ4hh6hqFiPrDcIbuylWNV7RrDdXXW0n6wLV1UV 2/t8fNWXjv3z3RHSB0RMdL5VWK2fsXYrY1tetTqfvmcamUUpTsM0rCvExd5KOWuY+Ma1 sdkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712272002; x=1712876802; 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=cdYcjDwLN/xr8PQzvEnfgv6lYJ6ezf5kr9JF5Mk0QDo=; b=s/DvDjbLJvav5CL8ozqoI4jOC093cGSP24kJIDWPp5vF61drNJFymuisiLNjoXOdi2 MjVCw7hVT8pF3GK1Utsitly36xWSCN0KuZ1agS/k/bYd1eDbez/yFFqL+yWeIjx9XoK8 XuzOd/Sam0otDhb/J2C3nQYIH8ZVJF426ogbF8xq2iEQetoqSm1YaAZHfm2y/4JX9zER 6b8/ccspU4LluTWjV62Z3Jt1Lo/UjqXoLC5KWEs+5NPieDlYMIUFj5uQMf8uWi7JT6sq 1M7Qe0wpeDV9IQ5mA3j+EQUHpKXph6Pqf77Ed98kyyQ2Z0/HKznF84yunl0FLSuphG6E WezQ== X-Gm-Message-State: AOJu0YymVrk7phiiGSpC9VJjWJf3ntFQsy2HUOAXXFDnWoA5rR15+KHA XCY5V1gStD22WVRPFacaKi0J3eb8gzXB7cCsHV+14q3UfYpFZhK2p5C9bcDcK6PxsoA6Av0Hzas t X-Received: by 2002:a17:90b:4ac1:b0:29b:22d2:9dd5 with SMTP id mh1-20020a17090b4ac100b0029b22d29dd5mr1145312pjb.38.1712272001890; Thu, 04 Apr 2024 16:06:41 -0700 (PDT) Received: from stoup.. (098-147-007-212.res.spectrum.com. [98.147.7.212]) by smtp.gmail.com with ESMTPSA id q36-20020a17090a17a700b002a2f3cfc92asm1052592pja.16.2024.04.04.16.06.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Apr 2024 16:06:41 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Pierrick Bouvier Subject: [PATCH v2 21/21] plugins: Update the documentation block for plugin-gen.c Date: Thu, 4 Apr 2024 13:06:11 -1000 Message-Id: <20240404230611.21231-22-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240404230611.21231-1-richard.henderson@linaro.org> References: <20240404230611.21231-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1032; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1032.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- 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 d914d64de0..3db74ae9bf 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"