From patchwork Wed Apr 24 23:02:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 791569 Delivered-To: patch@linaro.org Received: by 2002:a5d:4884:0:b0:346:15ad:a2a with SMTP id g4csp1096631wrq; Wed, 24 Apr 2024 16:05:00 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWi/EfNmjHpJYQwuSgX5/mRML0i0T9xrlDRd9pFrAoFtUAXaoWNVp4XeVR0wSdk1gq7RJPaIhx3OyiLsOVJ8PKd X-Google-Smtp-Source: AGHT+IH52snnt+IXbE1d969+KIcKuGjZd/Xgk3bXnhIpKfoYtpLn2suFOjxs2Zm1N0Y4RzdiFMet X-Received: by 2002:a05:6358:ed10:b0:17f:87fb:5326 with SMTP id hy16-20020a056358ed1000b0017f87fb5326mr3903441rwb.24.1713999900325; Wed, 24 Apr 2024 16:05:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1713999900; cv=none; d=google.com; s=arc-20160816; b=DRzMUgf1rU6+e3uJJs/JLF0JEOzHbn/eqWnBk60Gr0hrX0myWvnBFP2UDwXjf8AReU LjNRsYkWdkdk7RHTPhGS5XaBC8fVsY2hrtTAUsAGt9m+MgXgLptQuz3rSVm1/IHwgKds yE1JMxbMCZ4eBSa3EJKKxqiy8mhy4CO26ln3PCvjFiyg6m96ptGwgGIhz9yLCRSWUo49 jWcm/RYIMb1oaZqgAj9ILx429iQmV1E7BJvWE8kNrT/cuEHLZ6pRVtcuFGROXREF6r/j j9MRj64Cv58C2P/b9xw3fgt7xZ8ys3Q4NqizIe1enaUCVCiZj4FKRJGI1ytrcHZ1CvwP mn+g== 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=RVeB0bHQFGY/SSVn1Qgz+xRvb9sEVZjQRdzNWiNjXl1OUFRTlKt/OYO5VUSfFDTFb5 azYKGua4p0Is77cVj5cVwY8so2ok0OC2Gm8KWxs9IoiKi9YU3SS7S5P+X8WL79Cnm7Qa SvpdIFmW+U3iQJcpyMpBN5ZcXHclt2YtS1Wk0LinfrIpoD88l4MEFybzncWx0unox8h0 xIGq1+jct71fDIGt1BIkpqV/zMEvGX7ng2oxr/CT46P6Uk9OCZv5xmkUi/EOuL2vRbdi JFGphaQG95SdzP0khfybK4KKqXEyATkZmcD64rgjsj10gydSbu5ri2/NNPBJ2xJOAofU Glwg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KpXBbAEb; 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 l7-20020a05622a050700b00439a197af90si9074645qtx.679.2024.04.24.16.05.00 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 24 Apr 2024 16:05:00 -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=KpXBbAEb; 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 1rzldH-0003fZ-24; Wed, 24 Apr 2024 19:02:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rzldG-0003fP-1I for qemu-devel@nongnu.org; Wed, 24 Apr 2024 19:02:30 -0400 Received: from mail-pf1-x42e.google.com ([2607:f8b0:4864:20::42e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rzldE-0002cC-H3 for qemu-devel@nongnu.org; Wed, 24 Apr 2024 19:02:29 -0400 Received: by mail-pf1-x42e.google.com with SMTP id d2e1a72fcca58-6f07de6ab93so415771b3a.2 for ; Wed, 24 Apr 2024 16:02:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1713999747; x=1714604547; 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=KpXBbAEbeGBO/K7/bvHe/unYFTFwkKBNs1cx+FBnYyxyJbUKZdrWBxnErqIVGrgs6m AHTQEz+6HjM9Kqe2ElmVZJtOzEqYwV2ug+kz2jQ2JtqJVx26NGVjxbVaKbLiyAyF4bAs o6wfwfPYf0YyXi5a52ZqYdM4qxxxc+7J6qa9quzSJdDFIodqRCanGi4dlmxTD2rwgkoB zBxF4Hc+HP9Y1BCLANOOu0/2uThGfBXhsNzyeK3BtmI44GRIaWhXfaObD9LBc4wIo4zf JfSZuCAQtecdHRXA2GlMANOchRH2Isul1JpuvHIHLJbrqaHRHgRuqP6rosEKowLn4Odh bB0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713999747; x=1714604547; 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=Sf37pVZyhoH8UvVL8/Ml5V1BtPXCJl0Rhisem/KPO4r5KnGj8div++M+Ibkh+5BCkP svubuf0gEOBgQNwB9ZyvRQTvhrMwttY1/qA1QW34L8wtU1Ac9N168zOW9nq1q6z7aMRz WBE+ayjZleaihTs92621+P2EtAW0+B5B9yQt0EEkCU5/6uiMembfD4Jbak7CjCEAv5DO JhPOt3rwng3/GC+tBrRu8hEV54SxmRS3ltiXorgPrDgQDiEvtF2LdF6btnlETeyaPEH9 XUoGz9cdEorWjFW7B3w7PJnsQUl66Jwkf8WCF1TO5MrMEr29dBOlwqEKLpYvstzCkSyn szXg== X-Gm-Message-State: AOJu0YxPHKZUxmC5c4V6t3RraOIM5gWCqzEwwdQ6id/4v8ZCrRgLGmaT k2g4YgsFEmGw51feztCWmHB6Z99yMiNVHSWNdSq6sYQtgLo/2U/caZbzsAw4enBKB5sCzFUP6dn e X-Received: by 2002:a05:6a00:2388:b0:6ea:7468:1f31 with SMTP id f8-20020a056a00238800b006ea74681f31mr4623725pfc.30.1713999747188; Wed, 24 Apr 2024 16:02:27 -0700 (PDT) Received: from stoup.. ([156.19.246.23]) by smtp.gmail.com with ESMTPSA id h5-20020a056a00000500b006ed4aa9d5c0sm11981405pfk.188.2024.04.24.16.02.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Apr 2024 16:02:26 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Alex_Benn=C3=A9e?= Subject: [PATCH v3 01/20] tcg: Make tcg/helper-info.h self-contained Date: Wed, 24 Apr 2024 16:02:05 -0700 Message-Id: <20240424230224.941028-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240424230224.941028-1-richard.henderson@linaro.org> References: <20240424230224.941028-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::42e; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42e.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, 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 Reviewed-by: Philippe Mathieu-Daudé --- 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 Wed Apr 24 23:02:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 791555 Delivered-To: patch@linaro.org Received: by 2002:a5d:4884:0:b0:346:15ad:a2a with SMTP id g4csp1095772wrq; Wed, 24 Apr 2024 16:03:18 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUoSpo5z7xdIb4c1+ksp913HXwc0yRSk1UVenzmEIebyg8putNvm6bizLElhI8neiCOJygPKqsA1MVZJ07eL13p X-Google-Smtp-Source: AGHT+IHE8zAAkcmG9s+qjFa7hyxamtaXQ0QrM6OLGnvUZ4Yfsf94DUkpkg84hKFcAVLoNYG92zKD X-Received: by 2002:a05:620a:210c:b0:78e:e0d8:4203 with SMTP id l12-20020a05620a210c00b0078ee0d84203mr3880122qkl.73.1713999798721; Wed, 24 Apr 2024 16:03:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1713999798; cv=none; d=google.com; s=arc-20160816; b=tl+6aW1cNWMGvSJis8Ret4DF6hxRjej7uq0SBcayUjeYBEjH5X6nUCot47FuuF1Ve6 2xv+Tz8F5nddgQa5cErDNGFoPSkYGkxHgIGIL+l5vAA8cW88Uo273cacD2HBSOy+MXJF cBTlMd4Ai5s6LPwGAh/nZ7GmAHhDxRwDTng68lzUh8syEw8GXUzKMz5wzNddCm1RxfoM g8HzZ2fhDaFKLYQpZMAcQTBE1k2GTn7Bd0MvHXuHnMx6gL+NT03+s/HjxujryFcO++jr OBp0K3KmgiATqOPuNmhiKGEibS209eOzDqyaBergJQBxGsg2zkemarDwVOH76fW7mMDu Q8Aw== 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=RdidZ4c3GBgvuw8iaTy9X2ov/z5uWMCkjh6syl8dU0UKfOajwN/qRM+hu968NUYJXk +a0kLhNhZ7L/aKmb9YXaGbTDsbv5G5EZLip+nnysu0OFktdwjpMYMxVxk3GQk3vao4cm MlP+bV5RnPhLFwvtz0Oz8Agcy+Lf8rZITIOomPUOTiD/tisz1Dv64l8RgImcoat/sIZ8 e0OWzOmwRClcB++FOoAoM2gjlpR/f0m62kD0lYhmj9xUiXdAB1IhxLRerHTHk4eTmDRq T/3R0Q/LsQNiywvp88sWvUfYacjCDOgeecLdcnA+A1hGor1u4xrf2yN/pKm6pGri+SIA ZNLA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=U9z10mBU; 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 k9-20020a05620a0b8900b007905cfb4bd5si12510674qkh.361.2024.04.24.16.03.18 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 24 Apr 2024 16:03:18 -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=U9z10mBU; 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 1rzldL-0003hD-Mg; Wed, 24 Apr 2024 19:02:35 -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 1rzldI-0003fh-2h for qemu-devel@nongnu.org; Wed, 24 Apr 2024 19:02:33 -0400 Received: from mail-pf1-x434.google.com ([2607:f8b0:4864:20::434]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rzldG-0002cK-1e for qemu-devel@nongnu.org; Wed, 24 Apr 2024 19:02:31 -0400 Received: by mail-pf1-x434.google.com with SMTP id d2e1a72fcca58-6f00f24f761so362536b3a.3 for ; Wed, 24 Apr 2024 16:02:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1713999749; x=1714604549; 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=U9z10mBUdfWLRsreHh6jP0kzlS17rVqCo/9h+qPvUVY/QPm5pT64iKhfJp13l2OLOB v2VEJ3NEQ8R6CASPyhgytFBKbu8GWmovhnDn9MTTMYI3RCrabFaigZsMgkTYZ6gLhsC7 XqRPPNj4He/zUCk0ju4h923uGsiAk77FU4IOmrL024qnGucaIPaqAlWPaP5xwo0PryJC Yv68UgsrKHzp98FOKD93U39kvMPFaym4f1N5GabWIUfAMX8tCC8pMns95538dYIKPocu pWAw3AyOrltS4W3THSQjLkiA5O0SSwAOsHyvNQ6J4/0L2OcJ5styIdx9OPVSXcH2XBIq MPig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713999749; x=1714604549; 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=m2hSic3dDrqtuMaOvMv+iDsk5JBaWvbq+rbrZk0A3sgfXlnz2VUTA3Ds8NCi1kN73y Z6IP9g4vejwkL5NquVzMSKi1zYgZBGRXRh6JN1OhWSbNnvsp8jexKNqHmIObP2uPUQrP hftIM7ijoRE/NuQDkhVhT0A6BunwjT39MMFn6WwVJwg1lFzczmM/Zo8DKSlq17MDBcWP Lu0s9tx+8bAJ/OTqYL3ZKuaD1pysL9de8xUCO6DZXWqMxRuD1qrVGX3RePEKiWQWiwpp VzmhKGOifH1dPpDn3GNEDTc4GM+ydw1jOuBebs5S1vUrpOo+NUS7YUOHOTrjsWrwbgS+ 7WYA== X-Gm-Message-State: AOJu0YxYP2bSd7SizjCrsjJImkvg6ibe/9advhKFqCUy6YwFqG8Bj5J7 uj6zUdpUEXb3fsIX/bWwtdylPv8gukmS/T/xbfcNDib4sdOBhlW+UsFxDlmo/Ql39IvBNr2f6YH l X-Received: by 2002:a05:6a00:1911:b0:6ec:fdfe:9bde with SMTP id y17-20020a056a00191100b006ecfdfe9bdemr4771761pfi.25.1713999748582; Wed, 24 Apr 2024 16:02:28 -0700 (PDT) Received: from stoup.. ([156.19.246.23]) by smtp.gmail.com with ESMTPSA id h5-20020a056a00000500b006ed4aa9d5c0sm11981405pfk.188.2024.04.24.16.02.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Apr 2024 16:02:28 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Alex_Benn=C3=A9e?= Subject: [PATCH v3 02/20] tcg: Pass function pointer to tcg_gen_call* Date: Wed, 24 Apr 2024 16:02:06 -0700 Message-Id: <20240424230224.941028-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240424230224.941028-1-richard.henderson@linaro.org> References: <20240424230224.941028-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::434; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x434.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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 Reviewed-by: Philippe Mathieu-Daudé --- 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 Wed Apr 24 23:02:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 791558 Delivered-To: patch@linaro.org Received: by 2002:a5d:4884:0:b0:346:15ad:a2a with SMTP id g4csp1095890wrq; Wed, 24 Apr 2024 16:03:33 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWIXihX/fbhOPUaGlOLAWZi3j6ztH+q3j2BjWcZbq/ffgimxRy7y93WN7NwyT6Ut7DedcI1gdijKup9snu34Q7c X-Google-Smtp-Source: AGHT+IFLpX4xKKx2NstgzmZFmVYq5Dof36emDBCQEwfPgRYTT+xbreuPzTkx605wL/a+lGoHibQI X-Received: by 2002:a25:2f4e:0:b0:de5:5ba5:4e5f with SMTP id v75-20020a252f4e000000b00de55ba54e5fmr4522590ybv.51.1713999813147; Wed, 24 Apr 2024 16:03:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1713999813; cv=none; d=google.com; s=arc-20160816; b=Dl8nhDgZsbCRmLynVY7P/mMDGgDgls/CTjOfLfqyH+3MtZcGs/mdZf0B40H2Y8Rael G03hSX+EWAIpI++XZNuChGRk25YDTszKuDgpnKXzdLX0NVVerrC7XABz/eSNq1GWfiJ3 n2sCsqKSvFvkKRpQ4U/qZSnY7z17lPTATjZHjBm6r9NBIPGrLIyOeNFdk+C7uzebIxYQ M26VxbmOtgc0R3qSgtZlb8oEfRYxienf8rtJ/bB4gnzsO4BGTYNwt/ytGCuf9fW6zYux Ur06ceAvbShJOT2Dvx//dn/19wnfAjEjtipqq6G8RMrq/PfPi0cHkkiF7jqi0n6td0KE wPsA== 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=hsMN0b3xOFAlivGzTfOzXVfjEjg9NOqAzY3uZ6ogmNnbFt/9wSxtjS7wfbjnx4HhAB /e32OBXOg69191NFg+0r4yfe5MPp+8Lx7Bk+6PtxykszsXFi4BYOiQc9JioRt9B3GiaT RkXcwisXqEttAG7V51MrehvpyTvEGdVqWWmKAzV69kAZqJuH1l7NYBacIEJb09iimAJx LiUAPesCSmOCN5Tiseleu2V+vtDRUVZI3OnCnal4En7NimO2Eg+lFBabRZg5hqbfhk3f aDjSLU5ZqYddemjJnDP4P/dFd2XuMrRGAQBeZ+QL1PYbMGvKkMUW3nKOdc9Yqqy8d+XX 17UQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="kCWe/70P"; 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 ez23-20020a0561224a1700b004d408663eccsi2887475vkb.50.2024.04.24.16.03.32 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 24 Apr 2024 16:03: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="kCWe/70P"; 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 1rzldL-0003h8-IM; Wed, 24 Apr 2024 19:02:35 -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 1rzldJ-0003fz-JD for qemu-devel@nongnu.org; Wed, 24 Apr 2024 19:02:33 -0400 Received: from mail-pf1-x42d.google.com ([2607:f8b0:4864:20::42d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rzldH-0002cZ-Q1 for qemu-devel@nongnu.org; Wed, 24 Apr 2024 19:02:32 -0400 Received: by mail-pf1-x42d.google.com with SMTP id d2e1a72fcca58-6ed2dc03df6so424223b3a.1 for ; Wed, 24 Apr 2024 16:02:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1713999750; x=1714604550; 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=kCWe/70P0yUgs4cU1sCjBT8ddpGJ4cuFGGRoTzqhObE/HXBOaRGH1YXvtU9l1CcVZR uxVULAE8JsBCgGPQW5ZfO2oSbd0vgRvDS8P9ZncG88U3jHNVMjngQcOQ/dheFuQMwo05 ySBRw6p81XH7zPLgqXT/40bcdXyrxk0QVSJl8jPk8c9m8NjedHzwvi1eIIlMJk7CwAXn Ssj3EvS+oZ3xgl8dzpLqsNKlItLgd6k29UM2ovSVTulu1E6psJ3JNssnO3GWcOfTx9B2 /C8oeqtgkMw1C/NBkCAWtwENXlmyZKSwvlRkgaS2Qv3EonFSDkybB2iXlQOy5YFhm/7f QPPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713999750; x=1714604550; 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=sHIP2RjAxJf2BGpy6qTMNFntBKxWn/eSNOnHb9k5nGdao6DAarUGW3MRIhAhF51Ohr CmkBT0fBxND23DuZR0p7u4D73n5izDVRXAlpvOhL5yntdhELIo6w51ztqKdub53TkSCr d0qDxqi/PsTnSM2cEWhwRlfwExXxwny5J4dVgOHcoXKHuebPIaumPWbyzvwbJivBVnJ5 w36kNHw+WRgnu+yXGt5YTTSQAYJqriocH1aG0JYQRR5797VwlV6YExc8s/hzfFfQG3KF 2vubqqOqDTyHLtUCWhDgiOMlqOUSfFBAq3xPaOewbP3gE4RnLz1agQZEYruLvZYlDo2k RWxQ== X-Gm-Message-State: AOJu0YwNEeicrtqwMU8MitYOFcpwlnTJWbfu+Eqvj809PgHXD+xR/uxS Xl5iTSQ+PauiiEtATY/v/xn0wwSbw0fMqSP1hHBwmulba4uJZWGv/Mme/sM6o2MZHMNq/kBp6yE r X-Received: by 2002:a05:6a00:cd5:b0:6ea:e2d2:5e68 with SMTP id b21-20020a056a000cd500b006eae2d25e68mr5349618pfv.27.1713999749995; Wed, 24 Apr 2024 16:02:29 -0700 (PDT) Received: from stoup.. ([156.19.246.23]) by smtp.gmail.com with ESMTPSA id h5-20020a056a00000500b006ed4aa9d5c0sm11981405pfk.188.2024.04.24.16.02.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Apr 2024 16:02:29 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Alex_Benn=C3=A9e?= Subject: [PATCH v3 03/20] plugins: Zero new qemu_plugin_dyn_cb entries Date: Wed, 24 Apr 2024 16:02:07 -0700 Message-Id: <20240424230224.941028-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240424230224.941028-1-richard.henderson@linaro.org> References: <20240424230224.941028-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::42d; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42d.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=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 Wed Apr 24 23:02:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 791560 Delivered-To: patch@linaro.org Received: by 2002:a5d:4884:0:b0:346:15ad:a2a with SMTP id g4csp1095987wrq; Wed, 24 Apr 2024 16:03:45 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCX1Qa6Q1GHPLp3DE1o439hUunyUMhflljpztGfoWbiPjwytwj/jGLVhG/TsUseXm9yoPAfdgpxsOlVa98RCaOVg X-Google-Smtp-Source: AGHT+IEaCvLbOON/ePUyAMDqT1lfcOZeskQ9VJw8EtWhNqBTixc3k1s2NDY4z23DnqjVts+0jgWO X-Received: by 2002:a67:ea86:0:b0:47c:f59:f03b with SMTP id f6-20020a67ea86000000b0047c0f59f03bmr3306584vso.11.1713999825548; Wed, 24 Apr 2024 16:03:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1713999825; cv=none; d=google.com; s=arc-20160816; b=N/nZTJtZNCsXxnFvMAX+hW7jMsGeNEwLzzSFhnQQ2R9Mt/cADjgmXpm9GqWS+beCyp 6OmM9wFf97UKlDe4BfGe3Wg6Ka7ap6F2qsZ/pJaAWogTvDnu0MP758HMNEcEyCdxCw/E jBvvXOsJh4walgzW8gtH97E5SNkzwSgmYsttd/HUUyOQTzAoS3N3omKbxeprUkoZazsZ Vcp6itjwx6LCxUjzZxaoIZAsSzprO9rbTZlbUEjqMC2GNEcGp0yllWD4h+g5VQMjNNZW B25nJ742Yh/psXyDK0PEjYHRcR4OJ3EJqVZ8NCL05KG6vS/cBCSA3S6JKQgXFPQEtybe ExpA== 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=HxygNe1PjbVDZtM19Ea5trX9Zo6XpeVeqLqiVDhFkLIgqtduGVYa4pO29AvNjjJfAL kXyuE9IlhagPvy68zOs1fXBcgOOGkeXjqJ0bMSCdlTIa68R3yrR7vaZYwaDYddcfnSgA zAjHXZyxQqezBxULFD+nih0X8mMspLOPqmJmpjvuDbYVFcA4Y7ym0jYEVTa240r0GV8r umogFDKZnACePEzzITkCtmEJ1AUaZp3WmVLjSyufgGtzWCMdnOuDjDCvBnwY1uHSzPm4 K/XteFKCPKjFqATvUcFj9yE6tmfrWJZoOPm95XkZb4UYIiFLj2oQBij+qBaTMDWuDokn c0Tg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Oe1FTZeI; 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 d25-20020a056102149900b0047bf1af7987si1674546vsv.582.2024.04.24.16.03.45 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 24 Apr 2024 16:03:45 -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=Oe1FTZeI; 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 1rzldL-0003hM-Tm; Wed, 24 Apr 2024 19:02:35 -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 1rzldK-0003gg-Bl for qemu-devel@nongnu.org; Wed, 24 Apr 2024 19:02:34 -0400 Received: from mail-pf1-x42e.google.com ([2607:f8b0:4864:20::42e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rzldI-0002ce-Lw for qemu-devel@nongnu.org; Wed, 24 Apr 2024 19:02:34 -0400 Received: by mail-pf1-x42e.google.com with SMTP id d2e1a72fcca58-6ee13f19e7eso425352b3a.1 for ; Wed, 24 Apr 2024 16:02:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1713999751; x=1714604551; 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=Oe1FTZeIGB2MNV9MpJ3CftUfJV+nVNz71bZD68BGH1TVCLhfQEFnTN8FongbC1A7aG lgjNxjJJEEIP5UyUOBbTwp4mrD4NfN5tBJKrCTIr87aHED2sLZNCdvRf16oJzXBDYDm+ D5BtNTIP33Cu8yY2heCLTkblD1+K86s0EdD9SCwuTtSvDgngVnu080bUC7N1VEMRZhv+ 4EQDcQSJp+YmaPu+yGY1e3Qo2/iGZbnellOiSKEg/n5TdHPmQC4dgHVYvnTyh8w0BfyO f05j1Mn/f6gBt0ougJs9nMEv0JQH0VhLSPkhU8aatfXZUXdX7o0w3V3yPzEU6vBq4cGL gM4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713999751; x=1714604551; 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=t+hWH6c7wNDjzn11ctEK2atbMxp3f0XTSOzdgcwJ59EZpMrhlFbN01ufqnmU2hCXai G/e2GkwrVcBmoBosUJq443q790aKj8QyWwjA67kGuffZZVwjFRFKTj09JRaYCPUUN2Ls tv/7oSzdv9zJPai+YUkn4wLeDfEIcs6MIYabaQGlQjRqBABRjE12hd6zhbf8r3iK1W32 D165dnppYm38i42pd2Wjb1rDFS5TdG9BfdAdKIcqMK/Izr4H6LXQz0qQ+F4rwBTCcY4M QEq46GKxBcwIWXd2o2KTv5Tp3pbqOtwk+Eg3+AEwtqdE63QUWkO/CxMjmbcrrSTGSFPY 4iXA== X-Gm-Message-State: AOJu0YxFAy+IG+BcuVl2H3L1Hi4mMbm6NEn28FjxjXyI2monAOHEgmhH mCU0tE/SdwK8iFb4ta9rDNL5irhtJFPPCzG9Ib1PFRrQZlf0sBs4amtcC3nfZNtV5+edw4myE+a m X-Received: by 2002:a05:6a21:2d09:b0:1a9:694b:cfbd with SMTP id tw9-20020a056a212d0900b001a9694bcfbdmr4639880pzb.5.1713999751196; Wed, 24 Apr 2024 16:02:31 -0700 (PDT) Received: from stoup.. ([156.19.246.23]) by smtp.gmail.com with ESMTPSA id h5-20020a056a00000500b006ed4aa9d5c0sm11981405pfk.188.2024.04.24.16.02.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Apr 2024 16:02:30 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Alex_Benn=C3=A9e?= Subject: [PATCH v3 04/20] plugins: Move function pointer in qemu_plugin_dyn_cb Date: Wed, 24 Apr 2024 16:02:08 -0700 Message-Id: <20240424230224.941028-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240424230224.941028-1-richard.henderson@linaro.org> References: <20240424230224.941028-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::42e; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42e.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, 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 Reviewed-by: Philippe Mathieu-Daudé --- 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 Wed Apr 24 23:02: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: 791562 Delivered-To: patch@linaro.org Received: by 2002:a5d:4884:0:b0:346:15ad:a2a with SMTP id g4csp1096088wrq; Wed, 24 Apr 2024 16:03:55 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXwRvEYEAW5t1M2oPlcSvf0A0cwLX/wyKvYZRTEuZTRt4Zrv6Fxcn9fMak0gKrOkC9Jr3E75s1Z0IpKGfaek3th X-Google-Smtp-Source: AGHT+IFD6stuKpfvUP2rw4djAFauuyfAFbGRNRK8ViFKiJQ1X64nGToisdQcPMw8y+xnydPCqGFB X-Received: by 2002:a05:622a:48e:b0:436:ba90:17ad with SMTP id p14-20020a05622a048e00b00436ba9017admr4360058qtx.40.1713999835713; Wed, 24 Apr 2024 16:03:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1713999835; cv=none; d=google.com; s=arc-20160816; b=HW/UhhjUWahD2p68w71/0fH1gAy3OmG5QppV7AKwu3J3aJtPV0OgXuhCEYkHFzDx47 JKlANGhk2hNlqb7b3GkzFpxIQCmN14dXdoYR3mDH7Ih4XSTKSCkNwVbNDYf62zlCcSke XVyGxj8CZ6v4NHOkp3cf9bdqahAcE8iYuWTxHncnYN4G3quGA9KQTjc/XhSP82FFtDnr 2sEGJpfgBrAS56ol+mcplEBZAVQy4xUyavnC+8vfPbJI3WKK5pcyGsiiAHuaQhiuIJ/n 41vONZ7tF9wsip3QjnbUBFmA8FEDR110Wh6++1fiqOaXt8GVXaQnMwJImSCvVr+sHlU0 kEUQ== 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=gX3xxrPkPmbC70LT+AIVOS22kvOSQfEcCPcpuX1jkTefadP1jI/PEHRJ7LSXOOWAk4 PjiPQZD9S+TnA3k+ojgiC1mqqi/ifsWjsIBB0ryBfoZ/FMpt+QiW536wRRI46hnca5QT AxsDDTUvtqoEGg4lzXPTvuYrtofbBZd1i1PyGLqAFeVTsu3f/gDt7BtyTfzU0HFD0pwi wKnCrEkK9T6OqZsrxORx938JhPF0f2DGg1q3VdCj2YVaWGJucK+bJdKQj1EQb+rprtXr P4r/L3IOfh6qKJ4HsNjxEMK6ux/lKmkoCQJnrcoWTlX2po026YyvuJIk24B7C2CwtlVF hdhA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YIn7HrMb; 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 i17-20020ac85e51000000b004345e4cb66asi17260278qtx.63.2024.04.24.16.03.55 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 24 Apr 2024 16:03: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=YIn7HrMb; 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 1rzldN-0003i8-Dp; Wed, 24 Apr 2024 19:02:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rzldL-0003h0-6L for qemu-devel@nongnu.org; Wed, 24 Apr 2024 19:02:35 -0400 Received: from mail-pg1-x52c.google.com ([2607:f8b0:4864:20::52c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rzldJ-0002co-Bd for qemu-devel@nongnu.org; Wed, 24 Apr 2024 19:02:34 -0400 Received: by mail-pg1-x52c.google.com with SMTP id 41be03b00d2f7-5f7fc45fe1bso337911a12.0 for ; Wed, 24 Apr 2024 16:02:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1713999752; x=1714604552; 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=YIn7HrMbvpJw04PuEvtFlxoVmjGrGPUJlSmRqIfhUUCzczd6d9F+O7F2QsekiuIqVy 2d6V3TRg4yiPnMRCE+3f82yJhuHObgHA5AN5J40d+c55fKlRrDP3rXuZU9dGyDelmfg5 apCpNXx6HD/5xVZ1GzHAlRDi88kVQK3loFIdcfv4VNpsrmie+E/W7NiY5SwR84n8LdCO 0XCo8LbZk+08DX5RpI+TDC0vj9HBG82WjevtRLQVBLJSyuDbM0qlYBo8OOctL9i3xjKl 3A6cYoSzhYxng8wCuQPrvrFy2ojJFX+/ZmE21Xy6dLJxVg3dQYDQgBXVG8xS3nvRZIfE KS0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713999752; x=1714604552; 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=qWlKWv68u6Afva3Rn3/GTyRqJWxqAN2Xb9jAvp7j/0imcjv5n1mEjaT/wh+80MOS5B UIV2hkOm4UhAAsRs0uGh+r7/zBJIwIfwvdpN5TYEItE2DgbyFiQ530sygLQIiV60S2Ug VXStGhoDfbrEA861uE1B2UDNRBL+qVfRnkCYzPcRO1MHYKV1o3HGpYTAE8walMBd5Fz2 IYiGlghaSkZbDaVEXblmziIkCSOczNKIkQqmPDZmaU2TzrUdUPiXnW7/4s380fHinvFj FSpeYjXMwwRt0LZwuRLnaMesLi0jGvR1Ytjz62tHU2UUi79TyqbU1b57iTXE+nPUgLLi sE2Q== X-Gm-Message-State: AOJu0YyvenbAN4mz7r5K55ZX+olsGzdWNDos9DtX0q0tHnM6b699MuUw 2Wm1yFmSgCs+rAOEtjxGoUBfcU4qKcxjJ1PJev3jV1ACp/pcsJsrr4FoqGKglB7uu9Wb9lRQtvR J X-Received: by 2002:a05:6a20:bca8:b0:1a9:55bd:95f6 with SMTP id fx40-20020a056a20bca800b001a955bd95f6mr3505658pzb.31.1713999752041; Wed, 24 Apr 2024 16:02:32 -0700 (PDT) Received: from stoup.. ([156.19.246.23]) by smtp.gmail.com with ESMTPSA id h5-20020a056a00000500b006ed4aa9d5c0sm11981405pfk.188.2024.04.24.16.02.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Apr 2024 16:02:31 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Pierrick Bouvier Subject: [PATCH v3 05/20] plugins: Create TCGHelperInfo for all out-of-line callbacks Date: Wed, 24 Apr 2024 16:02:09 -0700 Message-Id: <20240424230224.941028-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240424230224.941028-1-richard.henderson@linaro.org> References: <20240424230224.941028-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::52c; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x52c.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 Wed Apr 24 23:02:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 791568 Delivered-To: patch@linaro.org Received: by 2002:a5d:4884:0:b0:346:15ad:a2a with SMTP id g4csp1096529wrq; Wed, 24 Apr 2024 16:04:44 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUjFNg5+9F9PXOz+Yeo+jTwhl45ggNT/8quGU0ySGEVuiP7ABOk+f9IC5ylSj9gcH8cu45uYtE2jSM6iSHmPUob X-Google-Smtp-Source: AGHT+IGvnkWCtsVB2LdJud+WFwJ+UPAfziFVO2jHnf1SQPAc0+0N+W9eoQv+3/PLb+eSwgC4kxEo X-Received: by 2002:a05:6122:1d9f:b0:4c9:f704:38c with SMTP id gg31-20020a0561221d9f00b004c9f704038cmr4432490vkb.11.1713999883811; Wed, 24 Apr 2024 16:04:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1713999883; cv=none; d=google.com; s=arc-20160816; b=ftLJhEUFlPzyCn3e5G2X7zzK9HlJvoWao1DO0L4e0OIQ4jGTHX6U5lplxvD257EAsA urWIDm5MCdE3XXzQYdVMhWCeRvgTGh+6FKQK4NIjEnUBFHuIo3nj1gJ/SG/pAa5nzUrf 2g4m7FpXnJvhqPDFI04RdYTBLxl9GZPHeBSEwJzeer3x0OPclPS8hRxXzFrDDP68luCZ pRu6klRwyS1HTUXlU9FqhXTNq+44uc040Rnu8LTAsmBd2M4f9OtVdnslha1cV89bcjzn gclAXy7Qs9dhV3uFYXQW5A+D5q7FtotL21Dzhl8C/c+qt8XEolI3Iw/QwwE+60dzdnNO zijg== 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=p5J1vUMlyM4ma/ourdn/yN75D4dwP7HLEKwZ7TCZJr7m2zFL9py+/qd1kQTZA6aobn s5m8C+RSZLyLZGixMDw7kch5aNX6+mdGkVS0I4HvEZKY/GfrAi1zYCrWAScu/JQ2M5IA HLc1eVEIHOypme3xTBgfzDfNuaofRRCR0gNxjACIXMzPZ34JWyaMVr86SFWhB/6ZOMpY 5EzFmxTxD0GdgutE61L4UhqZY0yaY7a+H1BN+ORg34zuWmNYsJ4qor8NCbzUJjceIpdq n3WhkkOn2rbmJLYH616mXoLtofEdRlZiCkY796Em6Lbm2uZ8wRPExG0f1faq3YUpo3/4 wTuQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=MS+I9jIk; 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 bi32-20020a05612218a000b004deb85efc31si638176vkb.257.2024.04.24.16.04.43 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 24 Apr 2024 16:04:43 -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=MS+I9jIk; 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 1rzldO-0003jv-Gw; Wed, 24 Apr 2024 19:02:38 -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 1rzldM-0003hw-Mg for qemu-devel@nongnu.org; Wed, 24 Apr 2024 19:02:36 -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 1rzldK-0002d1-VR for qemu-devel@nongnu.org; Wed, 24 Apr 2024 19:02:36 -0400 Received: by mail-pg1-x535.google.com with SMTP id 41be03b00d2f7-5dbcfa0eb5dso322302a12.3 for ; Wed, 24 Apr 2024 16:02:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1713999754; x=1714604554; 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=MS+I9jIk0xXiKX8hk8xvKBNSzgSuRwkC9ZaIjTtxlLob8eS3Am97ZlimqbmjsmI7aT YWonRnwtLTpJ/+tD1erKzIZ1TQPegrDsrbrhAqVw3JkXZ45YEyenGSlYeHL0TXT/BKtk SKJ8nqoswHIGH5ZmEEtSMZRclOFwMwkaHOc7+EuknE8MMG77604b07YQgyyxrj98gzQn tFm2wDySM4h2B6CYda05uCHJ1oNpA4FMizCCBeV5KN7GsG7wE0S/7cK/NThkDn6GgXkc o/DKxjyuK0AsGQp+QM2yurVwRHFBxnvsa/xNA/8P/9O4bg3szMK5JvJfPxbaU0788gNB pAhg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713999754; x=1714604554; 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=CwCvrGxBOj9b3HKjnAPBqoypRAc9QWUs9skbKpE9CnfwVxb8/V6pfKqxckk64KoXbq x8bKPFBEsu8DEPsotbALWwvyb4Edz/SYI0w1OCODFpI+luOrGtV6HVYYYZRCSfXx6ZN8 8fQB0ha0042urk6DKnvi1yrkqMFQliKl3f8SjRyr95FUj3mSGHDuG9Z/ta1enUutUXj7 ENueJaSFxKOuQXjDOnsDrBalmmS56//dL5eCSm9OFA8qSL/VJ4tIwTEgwLhNJPv+AaBN e7aijKs8f4kjBJr/EcDWEsWzXoktdekIffWbDrEy2Ez8tfh9P9XXwhAqBQ+pSh7gI7S1 cQsQ== X-Gm-Message-State: AOJu0YxO/9/fuNqSCj+wnMGplOQ8NLHWtyGvu1Xc9j3CiIMXmR/hVU1i TGukkZwBljU8Nr1jOse6cyYastmKgojJSqj/MBSmM/Xa1xFELXtM7fZjwtdHRzjo1qbmM0RDOGg 0 X-Received: by 2002:a05:6a20:3252:b0:1a9:5e1f:8485 with SMTP id hm18-20020a056a20325200b001a95e1f8485mr3885592pzc.31.1713999753608; Wed, 24 Apr 2024 16:02:33 -0700 (PDT) Received: from stoup.. ([156.19.246.23]) by smtp.gmail.com with ESMTPSA id h5-20020a056a00000500b006ed4aa9d5c0sm11981405pfk.188.2024.04.24.16.02.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Apr 2024 16:02:33 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 06/20] plugins: Use emit_before_op for PLUGIN_GEN_AFTER_INSN Date: Wed, 24 Apr 2024 16:02:10 -0700 Message-Id: <20240424230224.941028-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240424230224.941028-1-richard.henderson@linaro.org> References: <20240424230224.941028-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 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 Reviewed-by: Pierrick Bouvier --- 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 Wed Apr 24 23:02: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: 791570 Delivered-To: patch@linaro.org Received: by 2002:a5d:4884:0:b0:346:15ad:a2a with SMTP id g4csp1096635wrq; Wed, 24 Apr 2024 16:05:01 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXNbS8tE0fsRgLD53Z2DS5Kq4gdUjanzojZkvciVQZ+/OxBiMN75bDLj2jXeZJH02K+ZHfDhCLhWt256UZqBeOZ X-Google-Smtp-Source: AGHT+IG7XxlraJzU/Pu+3jlT3ETLOUvjjGkqBGO4eDJIlRdzYnWQQUJrpPsKfpXvlKW9cYiyeaba X-Received: by 2002:a05:620a:31a4:b0:78f:1056:a9f2 with SMTP id bi36-20020a05620a31a400b0078f1056a9f2mr5650744qkb.37.1713999901000; Wed, 24 Apr 2024 16:05:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1713999900; cv=none; d=google.com; s=arc-20160816; b=Jv8ND8IZgec/0peCKjwBeADXWS6xZzuzkTtmWRKqD6FhxYVdHQ+fGhcF8L04/XOnoN s3Pr/Q/lyPR8OHS7W2in8PpSuVPEI/kFNgUIMRw2A4fe0sOTaMxrROQQU6RuVHewVaio 5k/X2csG5te6uX5YPdL3gYkofRL4hwtBUvlBhluIUjGcbY7Kphl21jxRN7PrRXYUrmMu 4I8wROVs0t3bEkdN2dK5VhuYgZggssFGM9jgJHm7OnaEwBqFHzjrcd5XxtFBNUWpTLy6 ilk2WvPMGtKkdiMtTG98IHPOd61/0yoPrmafF/vQkeEINz9G7LyNq3LRCvzt1o8OdORz X3jA== 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=WChblAsobPbtzi1U2DW3+cZUPasKDyjJTGS2jonu0kAB4DDlkYG5Elk6d0duuKNEyg 9BI9ZthZ0l1tg45KsG16kP36B479Cnh7aPpFY+FOqd+NT3OB0ncPUCPk3VINP1rOtst0 ulDqUKpMnlNMUhJDSweWciTTVgCe6ennKzvH76ygD9qHfyVekUHn0ZA+/+rsRQ4Y9CFY 39ZamhMQ5xmJhvBmxuqsaHe9w2VlfsqDkkvPsIhiREt8n+4kIuQvBxnwPn2e/6PfzIkR 5XD4jXmktmIxNnz8gkDh6awVDyTrbMfUV+vmvhdTlx3WIXKOFY/djW9j0xSW0hxjhWBK md7g==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Jotw2+MU; 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 h24-20020a37de18000000b00790636a4436si11159362qkj.374.2024.04.24.16.05.00 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 24 Apr 2024 16:05:00 -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=Jotw2+MU; 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 1rzldQ-0003kg-7y; Wed, 24 Apr 2024 19:02: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 1rzldN-0003jo-Ur for qemu-devel@nongnu.org; Wed, 24 Apr 2024 19:02:38 -0400 Received: from mail-pf1-x433.google.com ([2607:f8b0:4864:20::433]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rzldM-0002dF-28 for qemu-devel@nongnu.org; Wed, 24 Apr 2024 19:02:37 -0400 Received: by mail-pf1-x433.google.com with SMTP id d2e1a72fcca58-6ee13f19e7eso425403b3a.1 for ; Wed, 24 Apr 2024 16:02:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1713999754; x=1714604554; 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=Jotw2+MUkPvnX4ZlGyas0IkCmgI3Oa7OWVZilLIaSXG3Phis303kcZnvDpuRXl9XVF 38aj2kPGkrUlTT2NjE3cI2BSsWCdo3vSg9ox94F/TpZq8HirIBhdsQqgjvKqBRDYUNco 3x4e5V8YNVzAPc/hI8eSTIcc+JuLXq8B4NQ6T6igBxFxhfTsKXxz+guZqEQPFVYz6bm6 +dRQozO3Sb/WpI5moDgGmvp/HSqOPLBDus7GCfSIzvtJ49yO8ucPCUx8mTadwfmM1tn1 N2LUw5aLzg5BMVC2qDsQnJh4wwAJQBZXRyojKUapYQkoJUHJU4vsiQ41xoDNsXvFvwBB 69Uw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713999754; x=1714604554; 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=tLrL5Fnaab7WN5gTnG4hVwLHYFoL9Is564K9HGwCrpBOP0Gu0sXGzXdfr29nJ64iTc OdfCvzt4ug6GmOB2iBuDl6CIDgRuQcSIxXtZWfyvjF/5Mkj72RHyfY7iA4HMXYv6OsGF TYxoNXI8RUYT5/+C73tHiD7lbO7oSIeGrUsNv/RF+GwUV2wmI0jsF1DrifniyqX3hE21 yieU3fylDgvNHoA4JEAU6dHKGGBHnI7zvfZulBRv6u/ecrp9ngn9tJ94e9aFBzp9QkOE aKEdB5+vX5QtRh2tr/iZ4RHaqfG3/Pd526TZD/kxTf3zyLd5TCVqbzsT+MCoeaCidXOe TqNw== X-Gm-Message-State: AOJu0YzoBfNhrz9sY6fjHOLxhs+crxUBtpgkyqh40ZfBy9GwlgZpcsmG L1s1U/CIJePDOZbog4rwGhrxz1rtX1WiVb3fdV6eVUyrsUqMCYYG96AISoY/mvTeg7ts2yNLZ9n T X-Received: by 2002:a05:6a21:3183:b0:1ad:9202:2391 with SMTP id za3-20020a056a21318300b001ad92022391mr732909pzb.2.1713999754526; Wed, 24 Apr 2024 16:02:34 -0700 (PDT) Received: from stoup.. ([156.19.246.23]) by smtp.gmail.com with ESMTPSA id h5-20020a056a00000500b006ed4aa9d5c0sm11981405pfk.188.2024.04.24.16.02.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Apr 2024 16:02:34 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 07/20] plugins: Use emit_before_op for PLUGIN_GEN_FROM_TB Date: Wed, 24 Apr 2024 16:02:11 -0700 Message-Id: <20240424230224.941028-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240424230224.941028-1-richard.henderson@linaro.org> References: <20240424230224.941028-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::433; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x433.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=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 Reviewed-by: Pierrick Bouvier --- 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 Wed Apr 24 23:02:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 791554 Delivered-To: patch@linaro.org Received: by 2002:a5d:4884:0:b0:346:15ad:a2a with SMTP id g4csp1095685wrq; Wed, 24 Apr 2024 16:03:06 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUoADmf0UPhKL3hTAr51qAoYk/FXFHr8COJLgaKpcScfAAcAHpmb4j1+SQHuVzEDlk7YRzwz56W5HJQCkn6qWFY X-Google-Smtp-Source: AGHT+IEqPDbJty0joSfY8KAVdytaJskIm2GuRUQdlCdZc25f44TntvOmtavJPD656TZ0yqvjnTCc X-Received: by 2002:a05:622a:40cb:b0:437:ad0a:a831 with SMTP id ch11-20020a05622a40cb00b00437ad0aa831mr5747555qtb.60.1713999786574; Wed, 24 Apr 2024 16:03:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1713999786; cv=none; d=google.com; s=arc-20160816; b=RneACk09kFkeuchT3DW1vwMF1BVTPqzhsEKR6JXxqeGyWysb3+nPpc1EjsL/WCZ4As 1hpNn4jpathERkBqzHsYihjZ7IECahenxImaFiEZaxSl9+cwX0+vWsPQwM9coFiQPxQ/ xonQOemuqqSB8dAi5eBB3PE83f4Przpey/oPeWuxsJFlpd1FtIEpJYtVFxWMHEJtwr2/ FZbazqg/ePj8Dj3IEIb1Cxuy3MsU2o6NAYHs8twNLlGPUesaQNX6DWvYo4tAdDs98A+J ekyjaobUnPGGJNtJzRMnftH8rasfkG3p3nXHnsYWL22rafGIXZHOMyP5OFf1vXhw5WjU OfQw== 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=0UiZjyCR2r5scimNCQ/ckI5Hhjnn62PqHF3WAmqYExOAb/EeQHVICS3n26YDsM7Tdv blgQUR0Qh8WXnlOVHkPPMCcq3D8x8TvmyiHOnZXAHyd510bvOX8IXz34tPyVMVd/hw10 pZQZwGazn6KwlM18/nlEAF0oiBJMQpSJWHVGlS5y62zKYFeGpx8KrWDRzK+uOlC1/HG9 lG8JWisY+i2WpKhGhQiFuQUFSFlq6E7XjdE5HOvss132I1qUkB4a8xGkrpluAsKRjBeH RoJplkdDDfOio8prFK7H3Ljrg9CddN6oZqtHQEJKCzRZYPj7uwO2Ef/Ko8RpoGiASI5J RMzw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kHWi8C+B; 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 w22-20020a05622a135600b0043a46e3a099si191738qtk.239.2024.04.24.16.03.06 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 24 Apr 2024 16:03:06 -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=kHWi8C+B; 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 1rzldR-0003l6-UB; Wed, 24 Apr 2024 19:02:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rzldO-0003kG-Im for qemu-devel@nongnu.org; Wed, 24 Apr 2024 19:02: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 1rzldM-0002db-Rh for qemu-devel@nongnu.org; Wed, 24 Apr 2024 19:02:38 -0400 Received: by mail-pg1-x532.google.com with SMTP id 41be03b00d2f7-5dbf7b74402so305092a12.0 for ; Wed, 24 Apr 2024 16:02:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1713999755; x=1714604555; 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=kHWi8C+BRybJihUi0HcN0UuWRa+4RHWuuRPEjbOpVwDOzy1XnFThREV/H66pgr1ns2 ZDZtrgqiTA4QNYp0S0KWvJNieqzfig3yqNmYUlBXKSvFZwA/xjGZYUX6FdE2sl8C4swA rag1Jye4c+Fho8cf76HLfUXzsJtLdnVpYhyZ+/5+MRamabnDjLdy81krKDUVLtrhBm3e s18BwMmkR1Up8hVTYS3jGcJhU875xbATNEODD/2M3mdOTNvtngG8Sgus8beIcj2riG4z 0Jm0X6pLSkLadIrPagD+MgrRxHXhtlDWK5etOtiUTRAWU3hFshre9XH+pMPRlDjM+b2k PoBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713999755; x=1714604555; 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=lu0UCSdoKpoLpksZrMf/jbu7iK8/trqiqSC+1vN3LfR4g08uGIu2Ua4m1nKNqFNpsg BE8B7g8JjG5f0QbQfrgq8boD5VP4PByeIiXkwU3uih2f05QAE1/o90sljaVsqh7N5pP3 F4aJpVqVu+dgc/sXuz49Qy3+QoHWSYHBakA+JG1tGog9Xsl1Qsxwen+mNQ/atnf+CgFY DjaFYy58fN8zXATTnsAvJy48A7fTR94efKO9otw429B+AZ75Xm2HYLl/DygikHXqgYus x0ej+xxXb4Te8UucdAoy2oTFn+1H2ue2uqW6rSbCvcZ98v5jQw+OsPlAEY8tyK8piNjj r/4w== X-Gm-Message-State: AOJu0YwJUxVHatlYHGYgJrHLmxuWlwtyn9SnXyYhm6uPVQmlvuO9sUwq b8eISqkU4jdfqZeNE/SDcycqUA1nEWAwK7QZ+iYQoGTROYMGtQR58R33Bbolm/M6b2JxixpKm6K L X-Received: by 2002:a05:6a20:244e:b0:1aa:5aab:567a with SMTP id t14-20020a056a20244e00b001aa5aab567amr4595232pzc.41.1713999755443; Wed, 24 Apr 2024 16:02:35 -0700 (PDT) Received: from stoup.. ([156.19.246.23]) by smtp.gmail.com with ESMTPSA id h5-20020a056a00000500b006ed4aa9d5c0sm11981405pfk.188.2024.04.24.16.02.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Apr 2024 16:02:35 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Pierrick Bouvier Subject: [PATCH v3 08/20] plugins: Add PLUGIN_GEN_AFTER_TB Date: Wed, 24 Apr 2024 16:02:12 -0700 Message-Id: <20240424230224.941028-9-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240424230224.941028-1-richard.henderson@linaro.org> References: <20240424230224.941028-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 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 Wed Apr 24 23:02:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 791553 Delivered-To: patch@linaro.org Received: by 2002:a5d:4884:0:b0:346:15ad:a2a with SMTP id g4csp1095546wrq; Wed, 24 Apr 2024 16:02:46 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXGlqG/pY8dSEiNmvF9fTERsFOxyho1BwwK1BrvaKUjZVzIGMhF1QR/40uhGXFt/pSAc9R80VKTMUkOfvkaRimk X-Google-Smtp-Source: AGHT+IHukVm3f/XMFG6kIuiKdH1ZVj1oouACAAPIkblqilpJufPg27SrjIqzACRYiMtmcv66M90r X-Received: by 2002:a05:6830:1357:b0:6eb:7d9b:386d with SMTP id r23-20020a056830135700b006eb7d9b386dmr5225282otq.32.1713999765931; Wed, 24 Apr 2024 16:02:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1713999765; cv=none; d=google.com; s=arc-20160816; b=Bshw3y2OYhQOkqrMefdrtPJRfjuoi5a1lNR8a5eIkjSfpI9Ekuq0E/rmOIcS2v/JaU M+6xhkgaRamBwr72dbWWDXnkb8U7/jyWy44P547Alnd8848l9CpJU1rmjKECi8jZKnqE 5r9Xi3HOjwuZagBdISkppL+cVJWnmf9ChaohoUOAPN1S7CSdSkgRw6g9qCjSroOXEk4E OezRh1H+3kH9bssE2cPhmP/q9SVHX8VBAbxY2tTJ88c9DTzfZtV6/fuX9E7qSJbGHeeH mElO8Kv2oqj/kWnibCt0NF4PoDnKU6Caz5s30pZWPuvT+29BKeobQYsHH/Ad3YmOrLho BsGw== 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=Z5n45Gt4f6CnwEOfkGuPLpjQJCifcAcZeu0ICWcPgbooB1amhLjecMgMcs5/Hi4kn2 6URBexlP+6JJ7AHV4F+tnM2vdgI7VZfJfgUg5TDmJ+NJKYXclOo5GIfT0vCjtW2LSXmM mPEUBKGFBmD2c9FOQFBbK+6ewwxeDA5x+I6/gePisp2B1OH/AuZXayzURky9h4F4R28O 2wz/ByiKAEh3LaTOf6oiS8VPQeDbwQfMnnhQE7rm1WyiGC00TROdWurIUMh91S9HDxfR CM5Dy2RVx/yR053j4u3ZTAiF4Bc1AmxcGasa7RePHPZpCV85IWQZ0q5IehluJ01bJsOr t0aA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Deqpeshs; 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 bu10-20020a056102524a00b0047bd18c4c24si2193408vsb.356.2024.04.24.16.02.45 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 24 Apr 2024 16:02:45 -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=Deqpeshs; 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 1rzldS-0003l9-2g; Wed, 24 Apr 2024 19:02:42 -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 1rzldQ-0003kl-FV for qemu-devel@nongnu.org; Wed, 24 Apr 2024 19:02:40 -0400 Received: from mail-pf1-x435.google.com ([2607:f8b0:4864:20::435]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rzldO-0002dl-48 for qemu-devel@nongnu.org; Wed, 24 Apr 2024 19:02:40 -0400 Received: by mail-pf1-x435.google.com with SMTP id d2e1a72fcca58-6ecee1f325bso441762b3a.2 for ; Wed, 24 Apr 2024 16:02:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1713999756; x=1714604556; 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=DeqpeshsD3aQOGToLsSq6He10jM8s4/BBxFxX3Hn+AI0o4jF3QS0l2LJTpvDHC9UqU QLbpyQBoaZhBf2qhMw9UuVZfg9ntXgswybb3QNGmIbvrLzVZCt8g9saloef90pdFbShA 4R3wT1JykFC7HWG6chjG+DelG12MQGYdcs7Ua3CPgWns5eENo2dqLujUbMFRi7vdk6Un xLaConXMk8XxB816IWX7Y7b6vBhOYYz/tjpRSwHhF9adC9cW7qau44It6s0znLCffkUw PHsIZI38VBZfs9sFQuIB2/d30OoB5C/taYOCOgJM7EZAYZdb0sEb7G0TMY3as1CZapNx leag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713999756; x=1714604556; 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=HiXUGKpzu+gdMa0+03bQpUG8uTdvRb3AIQCydOXZkSWTzYZ/1mdxiAkKjMTVCKBo8t wLJ6XMDO0vPevgjBeuEeTlpb3kD3qeRsHrNqNdp9r2TBH8G733xB+jsA3+/PRu3vAXv/ AAgT43S3n3XbdRYjZrt4qmd6r4a9KcwyB/3mBlkzhwF3VvY6EbACEo0+YPPR5GX9V26p KFunINsmkc4s55iat+99RTZvOaxOmvMVBQoJoza48Bg3AQ68y7I3fP3kToqIBvsCOYPU MbK71Oep3hHsvO7OuNVnFdESzvv6IRb+jEYowP7jZvvEN5j6t5CllrAItTNcYuo98NVQ mLzA== X-Gm-Message-State: AOJu0YzJK0Sfj+xU/eU6sVsFupzuNpXo1UfRpvqQcM8fFDzr0r7T9p9z iVx46wJX15XV142I0ZsDdEj+opbPgXO9Kudr8j5Jsrk2fli9cB5J6uKR5MJ4tZOmGDI9Q/qellA A X-Received: by 2002:a05:6a00:cd5:b0:6ea:e2d2:5e68 with SMTP id b21-20020a056a000cd500b006eae2d25e68mr5350052pfv.27.1713999756432; Wed, 24 Apr 2024 16:02:36 -0700 (PDT) Received: from stoup.. ([156.19.246.23]) by smtp.gmail.com with ESMTPSA id h5-20020a056a00000500b006ed4aa9d5c0sm11981405pfk.188.2024.04.24.16.02.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Apr 2024 16:02:36 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Pierrick Bouvier Subject: [PATCH v3 09/20] plugins: Use emit_before_op for PLUGIN_GEN_FROM_INSN Date: Wed, 24 Apr 2024 16:02:13 -0700 Message-Id: <20240424230224.941028-10-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240424230224.941028-1-richard.henderson@linaro.org> References: <20240424230224.941028-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::435; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x435.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=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 Wed Apr 24 23:02:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 791556 Delivered-To: patch@linaro.org Received: by 2002:a5d:4884:0:b0:346:15ad:a2a with SMTP id g4csp1095795wrq; Wed, 24 Apr 2024 16:03:21 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWCU6WzIi+xJqJ+z2s/9O6k+yy//rkTALXlUb6zyIZdkaDdBBhCHI0z5vSZIvJZcytZo5SfAqV7ZSXmTR4+FaZ9 X-Google-Smtp-Source: AGHT+IHXWbhOPklvMtg8jTwx5CetDo/rKX6TZxjy+5fHjLVL2j519qoex7I88d2ZHoxAKyDpKkL2 X-Received: by 2002:a05:6102:394c:b0:47b:9417:1528 with SMTP id f12-20020a056102394c00b0047b94171528mr1706241vsu.0.1713999801457; Wed, 24 Apr 2024 16:03:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1713999801; cv=none; d=google.com; s=arc-20160816; b=qalVuFA0HBCPXUBSbGSEqtHeKZClO5l0Seqf6nin9KAiAxszRuWf0jjf4xFE0aofyV /urYk9X0TpEYpdG99TJirDs3W+jZG9iJxQEG60EC9K6eJIe/jW6TxFW4NVOHjhm1dtSC EOUxyEu2LjAH8FTYfUj/7od++qL23M+BAw14PnmIDrfyVjvL7T9B1RmaAlb5VTPLPwNS rue6I+KiD7tznmuRk9KB4qhSD4M1YNCuSC1r8rcA0MDz6FUyAQ4c2vepRRqBjBejDXD4 RE+OiIOiB9Nd19GW64RjETIv7WhfA82SUJcLiEvG2snUcj7lfUyZyG6mivW/SjwSEgFU PqRQ== 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=XJHGgKvaEy8KYO+5SNnEMrDB+Rhokf6AEC44WaAdSQtiRZmLuf3LqwIFR9cq9Gpi5u yAP0+tUFhE8h5EW1/fta/csp2kVYGOBK4H9+0ruQz1+1HPTW6uLzzdxuZIyDnHg7Jn8X uZqOOIVqv4O7ArFbsQRNDj4dG+vZaPJbn3SzqxRyionD3SCco7MaCBezfMD82Z8HsrWB pvQw/nQjFC4MExCRdH3XivUKA4nTiTNmcYD39i+P3Hyr4/ApIFjrkCg09UgFurOWbse4 RriXSHbxKseHWmjdS86RRWjDQVa1N4th7WfOfW+iAGjHMz4zXy/nAtpi1R54rYBJrIRe UHcg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Bg3AuDay; 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 h10-20020a056102104a00b0047bc4522d92si2538186vsq.754.2024.04.24.16.03.21 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 24 Apr 2024 16:03:21 -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=Bg3AuDay; 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 1rzldT-0003m9-Df; Wed, 24 Apr 2024 19:02:43 -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 1rzldS-0003lC-16 for qemu-devel@nongnu.org; Wed, 24 Apr 2024 19:02:42 -0400 Received: from mail-pf1-x42c.google.com ([2607:f8b0:4864:20::42c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rzldP-0002dz-Dw for qemu-devel@nongnu.org; Wed, 24 Apr 2024 19:02:41 -0400 Received: by mail-pf1-x42c.google.com with SMTP id d2e1a72fcca58-6ed2170d89fso1069516b3a.1 for ; Wed, 24 Apr 2024 16:02:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1713999757; x=1714604557; 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=Bg3AuDaybqEU4Qp1yECDOzvIhtvwwYRDKBu4KCMz7w400Oy6p+3j1uEA6Su6gpuhUq h01sE2tpu7L6R6TagYuFtYkqQ+L+lzgaK6c05BQWB4Jj+wBLEjmNLZLrnLZ71EiQfgbg nw0a1CTk/uuN+8sLe25oAUgX/f5dPMXsOFlTult7NZfvsYrM5cxC3nl7Gu4GNZUpL4qW 1s9cNvXVDjThkiiA0VuQHoRn4gEBAorXQcrtqqmeuM3/cGmcpXNWfIDUdWqbJXnzFKJb if+ZGAZc8RSe1xPOoO6S0LSJdWGLa5uBQ5ZCH+uF9kaZL8zbmUVfzRt9oCFl1IzoyXwj O4eQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713999757; x=1714604557; 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=cC3QKjUdIINZ9I3nLYMFpuJs84AyHdCyb37cuMs+LGAZO3qPiNEqCz3duBBQdZLXmC lEvx8tGsY7wO7xfJK4xovuUIdgpmXS4fyt7iD2xqlkeyaA8QAF4K8f74yo089dU/WvSv xifNIhje8hudLelfLeImpBLGcCFcG8t5apBa6QAcTZTEzdeBES0pm8DcB/iQJx1t3qkI V5yWrVezu7/925+ZVhx15KcCwR1oZzs+62PAab76/ULaACygLDsbZbKVRzP2hqAzAXD0 ObIoTbdlx/RiaecUIcf2FWs+mN0PRiOLjiyzNM0QhKH6P3dziWv+oQuVROESGeGqPf1N qAbg== X-Gm-Message-State: AOJu0Ywt4uW/moOD93uweN1Y7/mmBWzH5TPKw+r87j0BaBt4gbvZ+sHG B8+O11crx32QxbOZYoci5ZqS5nyUok55Xr04lvSyoZ2BGpHEZ3CsMQnRqRYG51TbZhjjjV99Jlx G X-Received: by 2002:a05:6a21:164a:b0:1a5:6be8:2d70 with SMTP id no10-20020a056a21164a00b001a56be82d70mr1591373pzb.21.1713999757300; Wed, 24 Apr 2024 16:02:37 -0700 (PDT) Received: from stoup.. ([156.19.246.23]) by smtp.gmail.com with ESMTPSA id h5-20020a056a00000500b006ed4aa9d5c0sm11981405pfk.188.2024.04.24.16.02.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Apr 2024 16:02:36 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Pierrick Bouvier Subject: [PATCH v3 10/20] plugins: Use emit_before_op for PLUGIN_GEN_FROM_MEM Date: Wed, 24 Apr 2024 16:02:14 -0700 Message-Id: <20240424230224.941028-11-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240424230224.941028-1-richard.henderson@linaro.org> References: <20240424230224.941028-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::42c; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42c.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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 Wed Apr 24 23:02:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 791559 Delivered-To: patch@linaro.org Received: by 2002:a5d:4884:0:b0:346:15ad:a2a with SMTP id g4csp1095893wrq; Wed, 24 Apr 2024 16:03:33 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUDc3f3Rv9BIzv1ofqxGTI37AS9kQcZfSaNAIxYOtQPuOTnP+qI8/BvdDZu+NNeYk1bJ3DrLMj3TU0Saq8sjgPQ X-Google-Smtp-Source: AGHT+IEiNp2v959I63R5gFxO77LAveIPPHluQz4+p1QNCac9x/pYzb9T2fay3epTDI5kXJ/1L2Em X-Received: by 2002:a05:6808:1309:b0:3c6:1510:f35a with SMTP id y9-20020a056808130900b003c61510f35amr5762857oiv.9.1713999813394; Wed, 24 Apr 2024 16:03:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1713999813; cv=none; d=google.com; s=arc-20160816; b=tXZkrjpfAmg3WvzTdTg0QrB8EUmAA2R2yjr91hCXKzgiYztP++eNe3bUrs2P17LPkj z8If4zKqyDGBtRetxq/t0B4lGYZt9WS7Jj6X+rssMqgfkvKe1faFr/hKsYW8w+0pA/GF h7mx5OraSlda8vDxJA07G26IT86ta1gxJTh0jfKAdBWOgZB5XR5F0PFVAeiI9z7TV7DD 74ywussvobysB6rDuoh/nWadgR6j9zcxft5nWgwGWJB31eEg5mxonV/VadAxy4CXCjzH zBJogovo34VZXoUD9BHND9GNF9Vjx77KqY30Ld6YDGJ2QNmISw7ZFw6mXgywFmbOzBz9 5+OQ== 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=Wz+oQ2uxWFSLk0/nXq3ydGEsFZquHMlDUF8OYspeJTlvJCp/aEn52bXNLEoUF/H5U5 sdm6z3z7VTs2KGTqOw/c1zcMh4tn0zFu2LmITanez3KPOmvKNO8p9scw8cbdPKTF6ORf klaeAXxh4mE1ulQzws4IKGQu9Iur+g2YuFzN1ItXHmK+JT12ase8siY0Tutvp0gCN7w9 FT9pPpDQgfMXtMSNQNZX5X5QS0atNKtccvs/nyKRxYlfLFNmcuD5YNwIiL4EX827Awxl 8UNpB8YDb7hiiC870OnQi50D8NdE/w2ft7VPSvYWdG/pra4tVtpXkRpMwx1pGz97y3Q6 ZR+w==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=oUBw6Hnu; 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 4-20020a056214202400b006a065ac27f5si13169327qvf.596.2024.04.24.16.03.33 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 24 Apr 2024 16:03: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=oUBw6Hnu; 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 1rzldT-0003mA-DU; Wed, 24 Apr 2024 19:02:43 -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 1rzldR-0003l7-UO for qemu-devel@nongnu.org; Wed, 24 Apr 2024 19:02:41 -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 1rzldP-0002eA-JL for qemu-devel@nongnu.org; Wed, 24 Apr 2024 19:02:41 -0400 Received: by mail-pf1-x436.google.com with SMTP id d2e1a72fcca58-6ecee1f325bso441777b3a.2 for ; Wed, 24 Apr 2024 16:02:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1713999758; x=1714604558; 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=oUBw6HnugmgtnHSy90lqeLge7UPZplMGuYSYmnqX01psRsWjDjqDQ9rdjJghTnhTEQ /QpDlmuXC35Z3lv7YM/rdZHA+h01aJEPjhKMuEHhOp29iHkfDeYG2p9P3583belVkIsZ 5Vl/e2s9lpKur67j45NnbEd2aPazmZEV+a9RZG8sF5hRqwmhEIFVMX4S0F0FkpWQYcG5 0KB/Q9mJAcHjKMvMJhca6edv9qF811iVrSqNK5BOivBGS/5NiLZIcgdw/f0pmofKhHH5 maCrBi0SesQs+457UUjXlzTqGKZYXF4YBELmsq91znB0d9yNPGb9/KkGIw65lLwh/ALJ w+Vg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713999758; x=1714604558; 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=AR8dYhHuSlJnYABP8KklkDXL5CgRse1x5MdQEO0nszf8zoZjVCnahnMW+f75JqztM7 /yecg/H9h4lVDMBWS45dftxyuFzVa4UEQSDmkKyTx/4YOwFNLVLIyBYaFwUv6FSszESv pt1zveMQUP5T7CcOEM8RlI6E4q3hYKTYi7o90Hhqh6nMxatvRZGN0O5BGcKWR1B6/KTA LVe9kregTpNMa6+qJiA3nQUDDAggOFstxdA/YXIhxtrafIRaeWKjq/ln8Qvh1FtZh8sM PEB/r9qUud49KrCQpXeHf5PtpdVdZ3KVNUZHOPhzJXrrpP9jkG+wCfo89I1LsGIe22br rXHQ== X-Gm-Message-State: AOJu0Yy0Vn0GloSwjlEKLoIwAZVz/QgLxccRtsYNNWwBPrCD3W65Hz6W Nva30rMSpaAjSQjN81pQfi+YyHgZJQ4TcxTIJBiMFmISLp29FBM2izNAE66q/iQCSKwa03aUsbM v X-Received: by 2002:a05:6a00:4fc1:b0:6ea:d61b:edf4 with SMTP id le1-20020a056a004fc100b006ead61bedf4mr6794180pfb.7.1713999758287; Wed, 24 Apr 2024 16:02:38 -0700 (PDT) Received: from stoup.. ([156.19.246.23]) by smtp.gmail.com with ESMTPSA id h5-20020a056a00000500b006ed4aa9d5c0sm11981405pfk.188.2024.04.24.16.02.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Apr 2024 16:02:37 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Alex_Benn=C3=A9e?= Subject: [PATCH v3 11/20] plugins: Remove plugin helpers Date: Wed, 24 Apr 2024 16:02:15 -0700 Message-Id: <20240424230224.941028-12-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240424230224.941028-1-richard.henderson@linaro.org> References: <20240424230224.941028-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 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 Wed Apr 24 23:02:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 791563 Delivered-To: patch@linaro.org Received: by 2002:a5d:4884:0:b0:346:15ad:a2a with SMTP id g4csp1096114wrq; Wed, 24 Apr 2024 16:03:57 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUKlxBvCx+88wkuc0UdjrCHBDai/U9p+fTxASFWX1OkYqpKE4ONApQJYIVM5N1OH6j7e/WEelHvL6WKIHF7pDfu X-Google-Smtp-Source: AGHT+IG5xMr2RCpArOuXiUUJMGEDRsmgSGIBN9a/px2bmavSe2CwOsSQ5GhF9lX6tby21TIWGchw X-Received: by 2002:a05:6122:3c44:b0:4d3:43f8:8541 with SMTP id fv4-20020a0561223c4400b004d343f88541mr4675611vkb.1.1713999837253; Wed, 24 Apr 2024 16:03:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1713999837; cv=none; d=google.com; s=arc-20160816; b=mFgcZR9D1Cl8DFso5AGutfXnxCTCHyTS6BE8E74bd7w0WDwN/AtNsXDyCwnwwDtYGM 1JZrPLQgB2Jd1Qsi5h6FRsNiUHMKFVfm+QFYE1U/OXeQ1z87nfr6T+qXtM5Wrzg56+Di S0WKQ3eLhhMK8KoM2CQRf8MY6h6iBnw2bV88r3aB8VUwQxoybXkeMbRKNLPLOpITvFLA Jy9j3sYuxBJIC/3tFux/WwnLJow6JNQ/n4JMrCd+hXW/3b0wiKe7oEg5lFpcTUmaz9vL c2XOZKag2epCzQM+wR7LAku2rZrJ274mFtxajTu+zBHb7+G1Wz67rArev9asgYsMolsN 81KQ== 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=RbyXG6MTk8CRGFYLewAGhH7qh4GefLzy20I+eJmhXZ+Wa0DTW6U3FIahAMWP3ahQMd W+IvCtMFvrXuj/lrtl+d5x5fpL/3rFZYNzhTOaP+XbgnoKtCorJdeeGHFWmb8ZBxdFgp 2IVyC4gKpcTcotUstInTIVIIEeKrFWZ1s3+S25yGk0YjydmoaHLW5FKIrLBCVtHXVRXQ SS+dgKNXRm3g0pIEAm+st56xNKOFgZtUAvqxwWO9Y1t6jYwJNjDRdw49yRprBz+uNugl KkJHouu3GE0Jikl5NjNScokfZy/Nk/kLfeIU46WqnK5mnrlHvh7/DElppsoibqEJLHiP v92g==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fB62ETob; 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 2-20020a0561220a0200b004d8859fabe8si2988896vkn.203.2024.04.24.16.03.57 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 24 Apr 2024 16:03:57 -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=fB62ETob; 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 1rzldU-0003n4-DK; Wed, 24 Apr 2024 19:02:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rzldS-0003le-9H for qemu-devel@nongnu.org; Wed, 24 Apr 2024 19:02:42 -0400 Received: from mail-pf1-x42c.google.com ([2607:f8b0:4864:20::42c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rzldQ-0002eG-K0 for qemu-devel@nongnu.org; Wed, 24 Apr 2024 19:02:42 -0400 Received: by mail-pf1-x42c.google.com with SMTP id d2e1a72fcca58-6ed04c91c46so446802b3a.0 for ; Wed, 24 Apr 2024 16:02:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1713999759; x=1714604559; 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=fB62EToblP/73xujJ8oVS/pD/uf8LigxMIO9Tg5vlVJHBW34IXV8NTrB1WUtmswUXA NHEojeIP89HT/d17Ycjd3/04/pMzPEVuoRab94TMw+VktNsUyT+FFOQBLc/t2Vs74++w pstNt9lBr7TfDhiKVdhFTsXUprIjSce5d2aGjgq1WI7FcGmFWKXy2PQ3Xd725XHhr7wq TutEiH32b+E+RYK9unh9eiOcQo74yV4+FQh4sIyvGCXOjyoOwuaJsRcWU9g/oxCb5175 e+5qkYXLJlDY/IxDJb7qn0RDJIJDCEUsJVgbaz019rSsberdeOYAoHxPrFpFcgZOIYjK P40Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713999759; x=1714604559; 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=DC7IZ1lyL7vAGrXEzhy/QdUhxeeYad8OtZRBm7hGZVOkDnnNfa6ew8xKweWR3efoQ+ uhIFMwAHnjrSUphEDyBJCmwlKPF2MfXQvy+gWVa4znZk4Dogp6AfsJ6EspI9x2KjNCZx GV76tP+ladxHxmF/84jbbujeuFyttwEcsxcUFtMdFOO7n96sw7k/FB3RDWl9Yr/tORuK SxIbIxAWqY+AvpjXrh1bhrhQy2cn464lTJxJvWV4U4J6vpOOjvwMkEN8T+JFDz9kwALz YTpPuf0JJ9DEiFXsaiSJ6OGV5QKWuZpI0HFbfAgyOPq0TzZshZFLogxPSCiQ/Yuop63U 4GFw== X-Gm-Message-State: AOJu0Yw2FOWexQjo6AXmAmKblPgv+OpD4bkIQgs12NMZBT174CEAnptD Ol/YR+bZRWm+xfIzqij75BxldSsbmHYADsdxfS9eNepDTxvLthKMMzNF6C1VLtacJWNWDkGdl65 T X-Received: by 2002:a05:6a20:5b22:b0:1aa:bde:8c78 with SMTP id kl34-20020a056a205b2200b001aa0bde8c78mr3450969pzb.54.1713999759249; Wed, 24 Apr 2024 16:02:39 -0700 (PDT) Received: from stoup.. ([156.19.246.23]) by smtp.gmail.com with ESMTPSA id h5-20020a056a00000500b006ed4aa9d5c0sm11981405pfk.188.2024.04.24.16.02.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Apr 2024 16:02:38 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Pierrick Bouvier Subject: [PATCH v3 12/20] tcg: Remove TCG_CALL_PLUGIN Date: Wed, 24 Apr 2024 16:02:16 -0700 Message-Id: <20240424230224.941028-13-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240424230224.941028-1-richard.henderson@linaro.org> References: <20240424230224.941028-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::42c; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42c.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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 Wed Apr 24 23:02:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 791557 Delivered-To: patch@linaro.org Received: by 2002:a5d:4884:0:b0:346:15ad:a2a with SMTP id g4csp1095882wrq; Wed, 24 Apr 2024 16:03:32 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWCT7gPStS7b/VUlQdPja/iq6ftchdrKOPQmCAEZ0Qyo2lydfONAE36rtBMXo9dhK7Ku2vjqkNrSXsyeESTKmmJ X-Google-Smtp-Source: AGHT+IELyRQL9TybpQ9X5459/Bq05QigQbLA8akFFJLHwwl2lvAswkTF28v+wuRX42iXcgO6F82x X-Received: by 2002:a05:620a:12e6:b0:78d:54ab:8ff8 with SMTP id f6-20020a05620a12e600b0078d54ab8ff8mr3840204qkl.43.1713999812322; Wed, 24 Apr 2024 16:03:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1713999812; cv=none; d=google.com; s=arc-20160816; b=wjxc95MtFdr9P1eFfifXyaUFXrLFwroYXFe/3AtvBIUOgNAY1RftcUsnXqkx1bK8KE 82TO0LwsU+wUHMgKNStEIY+pfOrHWSXasVlu8YCcElicT6/tEkK+uFBdGDsRrtB2fish pSQmSVFjPMkAseNoLrxwqAe22VQnVEs+x7hPSPiabEqy/vawjuzP3rqIcjQh50QeNx60 4Du8WF0EkyI14OtUe6gGHUf65HeathNCFsknn64hsVrxXrF28y4nE5weR/lwyjdwgT1g UpJF8s4HhKd1b5BiKYFs8FzMhqgQoBTFdLMmncrZ+Z9Eizf1Rw0vDboJbwLrTCEmN9cH fA5A== 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=vd8LfUHHt8wXT95pjldog1mqltb+VeYTB/n+maop/mwcsR2FmnGxJsAP1NTOYV4cQk Xzp+zXQVN4YihO5dMr9ID42JoCKgUdZjEc1Xa3NG3z4vbbaAKh0IQhckYXTdWwYkmbEj NY/DEeDHNcTuHr0YJXbgMdhva0PBGK3I/JUSRWGlMHE34I8eqFirkIrjq0s0SUaF5mBF RnUDDvd0agsVMAxlzSGGk873g1Q3FK5HJOzx3zM5JeQe992cSXE8hUdH43c+CxOmQbj6 l3QjbdY4ndp6+mai0Ftb5S7/W4XOG8tjpMZoJosyx9brn7yhLtgJ2i+/f8jfOwHZmEAO 54rQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="Lkf1T/s3"; 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 b8-20020a05620a088800b0078ef8aa551bsi13656606qka.126.2024.04.24.16.03.32 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 24 Apr 2024 16:03:32 -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="Lkf1T/s3"; 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 1rzldU-0003n7-TW; Wed, 24 Apr 2024 19:02:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rzldT-0003mE-Fn for qemu-devel@nongnu.org; Wed, 24 Apr 2024 19:02:43 -0400 Received: from mail-pf1-x435.google.com ([2607:f8b0:4864:20::435]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rzldR-0002eS-Gl for qemu-devel@nongnu.org; Wed, 24 Apr 2024 19:02:43 -0400 Received: by mail-pf1-x435.google.com with SMTP id d2e1a72fcca58-6f30f69a958so381062b3a.1 for ; Wed, 24 Apr 2024 16:02:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1713999760; x=1714604560; 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=Lkf1T/s3EDd/ml7QWuJ8ii9k6ZZE9j++4tYtebUQfWry73t6mrz6Ivbi+VUpL0Fslp 0PBINn9JqHdU8j52Bbw73sKj4NPgmUny6Qfuz1SGBDUSC7yyJnMchwxseJDuSZ2XPCvF rILqiRJPQS3BLImp+XqrM2b5cJcSgbVexoFbeafLb3sdizeFq31wp/xx4tnFYelDADux TsB3zMeGR+g4I+1FEE3Y7Mtv9nFA47Q6VW+CYiRW+EENJZl8NT4IIyLfgKMu+rB7OvTr MnmjGlU7ydGuYsqwlgn+wyORkim1554VLPJzhMsoSjfHs05dau8Z9EvxxBIxgIEThhyD 13ow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713999760; x=1714604560; 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=KGJsc5ScfXeIp43y/wxLnnWTLBWMeDhD7escqm0QhabZUQsv2hsurkNtO6kSUuMHrX pjeqWM4C7UJklkW9Iw3eYzI2XCtMJGxLQ7Rh9oRQNGWUvsDYNVSKFZ1y5SdIhZ04yr+D LwefLJzu2D8r2F2NE+RBWbD+0FacoF9HPsnTJ+aP3xzSgBGMCN9qqzkgbzV1Wjy7vJpk UrYvH2bbW/zVdKgPaaOjHu95ATFEaA3taTpTAqcJtVInbdVu1VImBDU3nGHyLOFMdgl1 Wxiwj2dmqDEnYYlLxRDWjHb2vFdgP6kchOTI3KHE1J1y5+v8nvIUM31qlsYoKa106ScT pQ+Q== X-Gm-Message-State: AOJu0YyBvJ57rqhFQdFRo/5x1REoGeBdlUhlML+V5+b/ivr9M4C5c3le IHtiXVfz2sV9wj9VhQFpBVSLLlD75WG3uzDMOgvXp5Nr8GUkns7Z2ip9/rXs4JgD9mL8NS9F92j x X-Received: by 2002:a05:6a20:5525:b0:1a7:2ce0:633d with SMTP id ko37-20020a056a20552500b001a72ce0633dmr3716580pzb.5.1713999760251; Wed, 24 Apr 2024 16:02:40 -0700 (PDT) Received: from stoup.. ([156.19.246.23]) by smtp.gmail.com with ESMTPSA id h5-20020a056a00000500b006ed4aa9d5c0sm11981405pfk.188.2024.04.24.16.02.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Apr 2024 16:02:39 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Pierrick Bouvier Subject: [PATCH v3 13/20] tcg: Remove INDEX_op_plugin_cb_{start,end} Date: Wed, 24 Apr 2024 16:02:17 -0700 Message-Id: <20240424230224.941028-14-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240424230224.941028-1-richard.henderson@linaro.org> References: <20240424230224.941028-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::435; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x435.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=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 Wed Apr 24 23:02:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 791564 Delivered-To: patch@linaro.org Received: by 2002:a5d:4884:0:b0:346:15ad:a2a with SMTP id g4csp1096216wrq; Wed, 24 Apr 2024 16:04:07 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVJRR0tC5z/KiPbU2ni1KaX5gDswXbw757cVlwB8txGEsj7vf17eWajgsMTzp5cGzVJkEsdLC+Zjmw6S7+qW2Ug X-Google-Smtp-Source: AGHT+IGcZLYMJCSm2FsQ/koKF7cbedBf1Ozydi7QwRYlkOXYNA3Ud+nku8kHmEYfK8buDKoanFIW X-Received: by 2002:a05:620a:c8c:b0:790:88d6:7982 with SMTP id q12-20020a05620a0c8c00b0079088d67982mr3772471qki.29.1713999846999; Wed, 24 Apr 2024 16:04:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1713999846; cv=none; d=google.com; s=arc-20160816; b=JZppTaaVM7amiz0IRyZJjHIgPOaHp2WpmDz5xrTWwqMvBQpitzVnsllKZu16KRC1e2 Hl7AqcXJjLJlGK/9beYTPBr2RNHx7ls9sK2CP67nwAoN0OQYYRR5j7el1lqjoxdAP1A2 rO34z6ZituUe4GOa8WLsw6P/Sz8/VTvLtwopZwghKULfDDtqp//kVS7gm3ojNFApcFkD cNuz2QtTNgT3aHYNjuUtOyoDCbKSXHzvOb+ZzOm83uzm+fGHX3iTxdqCB37DlgEd/8eu M/vxUPdtopnCYQJMaZsfFENV0rfKxaj8w9jz940ARqfPHwGXKIP0KkUiEionCcFySmTD Q79g== 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=Z9zaVxTmYVDNdNd+CyZnNo+axHrIjFu7fbh6afFU32a9Nk8NWXaReMT697pkugWt61 vYSZMLm03Npcyg+WPvIRhBPvoFOJY5DCiyGMM9U57Tn37U0HRWyFfDqRVNAwly7FoxUt lF/MM1B57Zp4F7WDv9tu4ZUyKTCf8sSLZqS9DDFOrwGTnknn5LZfQ982ZogFkSWtRaO5 jkVNihTC9fCeUVxtiq6df+HypXz+e/CVVfuZ3A3Dp/2+JbA0DPXlcjiB1+lb6gY0F1yY xkQW2RLVCd+liMAaBzNlBrB8ABETeDlHjyQl7RgFTacXPO8mGwQZ4/MiLiXroZiYe8Ya rBsA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="V9/8G1Kz"; 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 m9-20020a05620a24c900b0078ee4546280si18350091qkn.467.2024.04.24.16.04.06 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 24 Apr 2024 16:04:06 -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="V9/8G1Kz"; 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 1rzldX-0003pV-LP; Wed, 24 Apr 2024 19:02:47 -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 1rzldV-0003nB-1b for qemu-devel@nongnu.org; Wed, 24 Apr 2024 19:02:45 -0400 Received: from mail-pf1-x432.google.com ([2607:f8b0:4864:20::432]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rzldS-0002ek-R6 for qemu-devel@nongnu.org; Wed, 24 Apr 2024 19:02:44 -0400 Received: by mail-pf1-x432.google.com with SMTP id d2e1a72fcca58-6ecff9df447so459444b3a.1 for ; Wed, 24 Apr 2024 16:02:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1713999761; x=1714604561; 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=V9/8G1KzyqnuS/qgN34j/Zwd+tFFRuo2ieVw96y/mRFEfD1P6nPubQaHfWm5jRUYVp qu4yLwJtf+SzhPN1qNqgDHfdJVCHrabIaW7WqhmzwTxOARFhJbp6BDc2Nmu6z+PDiOkB WCLBM9inlXsONg3dGpU3t+8EcsV4oFGjqSsrfZiX2wFHcJojFLfthY+9tYm9QSQ0ub8j rQGssiZ/eLTE8Klh7RDEmJAtZzm5k32ordCPPLHs3xCF5F4VnoJ0/FjOn66UN5t7y4pX Mpw2S4DcjvLVhFXFQUALt7PuHaUlJuaPV2dRVz7H7cF3IogQh1FInU445mF2ZABMdStd Rx7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713999761; x=1714604561; 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=CZi1GVUhu1L1Yaut1GazFpxppqkWw5dHAIzJmSRnUZAQ/gYwCFlg3Tz4inBDi2/5VL L7uA/i2b6o2aPHoKAGC9EP2sRD8o30cHZ2GJd0TFtKqFkwqO4kgU0V1+jYexHF0JNoLg jsvt5xr2KmfdqqjY4Xn/9mMaAShCFjzxyNjIx1/j7fMFEgk+rTlBPdKyX6L82oA6GAlh YOgIewtrEWbDkBIIqc2qZ8kmKJbLhmQTyFVIEhVlgjHm/1b4ZgcYVJOtvK+hYObdA7J7 wTgTq2Hczm/98EXk53RHK73/i+BhGsGbMHgyXqC7nqEl23xqqjdAr3b5Kg0/dXVkIALc fgSQ== X-Gm-Message-State: AOJu0Yzt2QnFwTXB203IR2r28PxJ/05nEdIQ4RtDLnFzlszF/7R4EWnJ uiKKOwVyw3QWWB/RcS1uUV2oco+ZUjz4/WsZyqqu9bxqcIq72S7fBuwG6WjG/mI0Hgy1z+GEtvM H X-Received: by 2002:a05:6a00:460e:b0:6ec:ed1a:16b6 with SMTP id ko14-20020a056a00460e00b006eced1a16b6mr5065988pfb.6.1713999761317; Wed, 24 Apr 2024 16:02:41 -0700 (PDT) Received: from stoup.. ([156.19.246.23]) by smtp.gmail.com with ESMTPSA id h5-20020a056a00000500b006ed4aa9d5c0sm11981405pfk.188.2024.04.24.16.02.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Apr 2024 16:02:40 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Pierrick Bouvier Subject: [PATCH v3 14/20] plugins: Simplify callback queues Date: Wed, 24 Apr 2024 16:02:18 -0700 Message-Id: <20240424230224.941028-15-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240424230224.941028-1-richard.henderson@linaro.org> References: <20240424230224.941028-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::432; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x432.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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 Wed Apr 24 23:02:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 791561 Delivered-To: patch@linaro.org Received: by 2002:a5d:4884:0:b0:346:15ad:a2a with SMTP id g4csp1096086wrq; Wed, 24 Apr 2024 16:03:55 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCW2ZhvO1ucXCxhmGMKrdshEiFjvw0O+djwPaxl2xVxsiIilAeyX9KethXuwhj8Ny36bjlLVKWkhj6//sn9htpa0 X-Google-Smtp-Source: AGHT+IExuwHnNcClo+g6V0zOlLtvo0YXVaWkkalGtSxz+HISbmYDxBEFV+mCxMV/WyUUfqdGKEqi X-Received: by 2002:a0c:e149:0:b0:6a0:8c9a:c74b with SMTP id c9-20020a0ce149000000b006a08c9ac74bmr4355940qvl.28.1713999835563; Wed, 24 Apr 2024 16:03:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1713999835; cv=none; d=google.com; s=arc-20160816; b=XCv4OQ7DZWpbBRg9ZLYeo8HWRP47re4MuwLxKg3fwclxkZvVt6750TQg3laylZ/Z3K Qngxnw4cf3wzhyqPeG0BP3JmfO5g4JU9eOnOXhmonBWinIblKH6d5oKTyhTh7GZEgRD+ 7eiNGV5z64F2fK2Bf1c489RtyGeqyk+4uWOhu9sZNK3Ng+f9Az521rzuvq5Rr7Z++Cb9 gIIkacrK9p6Vw9wvfNTeT5Tkac4DOq6p1KpBnoW5KCTiM2LDr3WNXzJzFNS9P1hFCDkG 4ZFaVGNa8aTxut92s2Om2p5QMH2Ww7NuqmmFktKGFfDmb/T7IwS5rtqy6VXeizhhexm1 53WA== 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=HvdKcevyt1WpF2JqoiDBcXpd51c7mc/c5W3QmKSYFhmTUIHjdd0y2mLW7b96VBP/46 UhvesgM5lj4esbWgWuxXHvJATCFsuZj618oCa5+q7qoTQS6Aucn11MIJpSSHGQlZyqke p78rNOD2rmgs3N24TxkBtTH4zwW3Di9EM4F7sUsTFr7YUlpuURJxN8Vd/3hgxFocWD3a 6fxrS3MeRPM3aKvaitZZRQoBLAhUy4+LMObcJss77/XxQf9SEPrmLWifpDu1OF9hwfbQ sYDpHau6iM6rbrcCPrj6fJd0FKNjSTLKxtktZFnpUmDcHgJk6pE+C9fcqLZ7lS7pWr2F bwwA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=wnHVHkwp; 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-20020a056214224a00b006992c794242si15980465qvc.451.2024.04.24.16.03.55 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 24 Apr 2024 16:03: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=wnHVHkwp; 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 1rzldZ-0003qq-Sl; Wed, 24 Apr 2024 19:02:49 -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 1rzldV-0003nU-DJ for qemu-devel@nongnu.org; Wed, 24 Apr 2024 19:02:45 -0400 Received: from mail-pf1-x429.google.com ([2607:f8b0:4864:20::429]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rzldT-0002ex-NZ for qemu-devel@nongnu.org; Wed, 24 Apr 2024 19:02:45 -0400 Received: by mail-pf1-x429.google.com with SMTP id d2e1a72fcca58-6ee13f19e7eso425497b3a.1 for ; Wed, 24 Apr 2024 16:02:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1713999762; x=1714604562; 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=wnHVHkwpWJpnlQH+TRY5chaKvo5Vw3a8t/v2PIPTNbiosmKwfqgzPQ3H9mWOVI7bfS u99hkfFhki7OnNhbJ6gRetIEpC9GwPOhpGUSgiJmNg2f4bpmgF+QIfyqUk4Vc3EBTa5c 7u41KiN7rTkO/vW3hMDRiMnQxd80YxJ1nEJj8fZoxGY5IEDiqjkbQr2nJKa3EplC5xbI NKVi2b6j4Rxsx4joD1rAlhI9n6G9rA4hYOfPd8WxcbmYxo4QVh7cK3P7z2XjDA2abYrb ApDTR7HwkAtw18fk11WPJTyiE83P6ch4OprFYM6/X9nLPBRDK4jGLpFMxUGavtVvuQyn 7zwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713999762; x=1714604562; 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=JxelFJSbvJSEEC3pjlfJkgUkA41TPh0CyX3S0vH7zdocKR1YN4L8AyWI64lWy3xyVI aEnyiAnI9lkoT8K7R1BYDxtn9gNyFPgwRtn49IiU4nT0zTMkpyy7jZ/7EMbONMLkhNPx DyNbMt6SRdDzJB4AHqb4UnMja/hW6JbMULwOpYOH2mst9Ixv551nUaRJO2JrUcexOlCf j87wqirTnmI7nkLrbMmlv2HO0T4APWJKwGDXPP60QpYbtIi2JGUxYn3wHQHAAHRXSZY2 1nSetBKRJQrpQWURK2/sDxC9qJdif/gf5Nt+Sz2tn8k4hhpulGUu94N5aGjgMpJC9Zhy HVIw== X-Gm-Message-State: AOJu0YzjZnLGm9SADYIrLyaBiizMGbgJVgyWAXh1Xcgputm0oFDoiz1b ggO89miu+w7May7wmsoZ30A+vh8Z0Mi0lX2XnNJ9Euv6ppB+oavEnfViVNEHNKlKgydoMTa6w2r h X-Received: by 2002:a05:6a20:4322:b0:1a7:89df:2707 with SMTP id h34-20020a056a20432200b001a789df2707mr4355966pzk.10.1713999762381; Wed, 24 Apr 2024 16:02:42 -0700 (PDT) Received: from stoup.. ([156.19.246.23]) by smtp.gmail.com with ESMTPSA id h5-20020a056a00000500b006ed4aa9d5c0sm11981405pfk.188.2024.04.24.16.02.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Apr 2024 16:02:41 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Pierrick Bouvier Subject: [PATCH v3 15/20] plugins: Introduce PLUGIN_CB_MEM_REGULAR Date: Wed, 24 Apr 2024 16:02:19 -0700 Message-Id: <20240424230224.941028-16-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240424230224.941028-1-richard.henderson@linaro.org> References: <20240424230224.941028-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::429; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x429.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 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 Wed Apr 24 23:02:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 791571 Delivered-To: patch@linaro.org Received: by 2002:a5d:4884:0:b0:346:15ad:a2a with SMTP id g4csp1096639wrq; Wed, 24 Apr 2024 16:05:01 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVVf8Sulx601hf0x+yMFMniZ6TkBPhz1/QeRF4nnuoyvfAmq//XG0IVJo9MkXQhVYlB1W59jDY+XwL32n3hWPLx X-Google-Smtp-Source: AGHT+IGWk+dE6BFRT9JB69GLKz4ZFbJFAC3p3iFdouyps4yeTGDvQJf4fX/2X8IiuACVqBhvKDyc X-Received: by 2002:ac8:5a0c:0:b0:43a:91a:4917 with SMTP id n12-20020ac85a0c000000b0043a091a4917mr5170187qta.16.1713999901570; Wed, 24 Apr 2024 16:05:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1713999901; cv=none; d=google.com; s=arc-20160816; b=kEpeEzvjVvIgXL1zd/TPpg2dpnZwLuSaMe0KFZO56a4rr0fvCvgBoJH5DEDzjMmZps bg+YyVuwI3upRaRvKBx76OrTou10FwYfH/knnhSco/qt33CulkFkuJkdhfnAtOccArvA KE1B3x5Dxi4TAgfXfXSgdPfu/h3ujhidKgO/mEoB1qaw2MgqvhEy6Kv5XGleAmHIqT8y FGUgwfB5LOVxvmveZytRAcjrb0w6miRQEy+NvUraWi44uR7y29Fsl7WcW+XqJElt1cGb pgKb0L5B53aQqHBNv8C+VJ9UXl3x5ooiCeQYDd7AofIaVxkf+MCMOgRf81HSdW9DYvtN X32w== 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=ZM1VOzXD+Upuql3yDNyd9G9qZJUJEy/UYeRHl8C9S1EX2N7ZQNdOIFgCR6ijdurrAr cp9DE9EG51ryIzzGiyYZl96LDgNMhDTLLxAqWzZ0i0/BEyQH3Yh07gxwJe2G+24lqYlj CEc8aTSLC8Kbr3CX+5g2EHUWE118M3EmxQ4xODPUn/qUhF6+D0vPbynzYSl/t8I5oVtI Ey5zxwrD8WWd3gq54pFvbnqaMWhD+o9ZXfljNQmQ+Is9a2MP2ABNazTeDwiLVAccDoc1 icNb1Ds7l0upr32Gq9L8WkhTpajLRdz5KEzWflrEYHUUiQQRSJubnclLGonE7VBzGpZW jz9w==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=s0CtbHUI; 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 fe14-20020a05622a4d4e00b0043975b71375si11996743qtb.283.2024.04.24.16.05.01 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 24 Apr 2024 16:05:01 -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=s0CtbHUI; 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 1rzldb-0003t3-L5; Wed, 24 Apr 2024 19:02: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 1rzldW-0003pW-Mm for qemu-devel@nongnu.org; Wed, 24 Apr 2024 19:02:47 -0400 Received: from mail-pf1-x42a.google.com ([2607:f8b0:4864:20::42a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rzldU-0002f7-ST for qemu-devel@nongnu.org; Wed, 24 Apr 2024 19:02:46 -0400 Received: by mail-pf1-x42a.google.com with SMTP id d2e1a72fcca58-6f043f9e6d7so455036b3a.3 for ; Wed, 24 Apr 2024 16:02:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1713999763; x=1714604563; 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=s0CtbHUIa0PJNpQt8o1pNlP5ZEgMQ3tOlDXJe0yeuyJ8rbZJ2I4HfHi9kV36dit41S 3O2mJe68twYfKGA+duQ9TdhjQ11InHosqJr5qGba05raY1IOjoItV0q/s7PogeuoWR5C ST4aNJlUOUatrsCWbg/YZ5lVLWShe+u3eaxM1RGgWzNjPEmmOxHw18oqnSQ4qrFrHXVg ZOGyC+EUy8aVjRhpIRT2sLuBMOmGtbta2yGQLlQKxATNLOa/ko01ls4iHF3KTTyp9+G9 GEq7jvGifEJp8R8hj876e1tL8gFDD2D0aiMP8Vk/DmTa0JzCHY0772R6cmHY5p82JuEX P6uA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713999763; x=1714604563; 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=QQWWC5inRbRj/CMRYFbTdGRCIWrXB+2qmpIa7ToYXsWQqgGpXLsnv3j4tbz/R/T1FX u1EMwRXCi/OGOXUcwaemEX8aocCvE7UggldE35kyIB2EkJOPMhV9k0W6nQz9yKWPAJyP UmLMirILwSFMdbm9gWSItY0+t+2Ac/r9iHEWPxZa959kIe1kS9eIFY0rPDnugs4PGQez Tee4qDpMruYeDXQLPqV0qsATgdbysn27jAJMnGqlkrK8/T+7Xa8u+/UYeMP3ET6uwEXm 34xekSSVdtnpYACp/MTTqdpbDJzSJv58Ckozad6ZugwxUFqa5hQpsCSHZ1BAhE+yzmny ++Lg== X-Gm-Message-State: AOJu0YzvOgRs6LtQ3QEAJK17bujDiygDRveehYRPW9pq+ZqfrrshjMJH vlGZpVWoMYguX0j3BlMYFd6C42IFgdzAvPZ3wSRtcP+0xgrkkyEt8BlzS0I/76gWkpqhwOwswbJ 3 X-Received: by 2002:a05:6a20:394b:b0:1a9:9547:1145 with SMTP id r11-20020a056a20394b00b001a995471145mr4919301pzg.47.1713999763484; Wed, 24 Apr 2024 16:02:43 -0700 (PDT) Received: from stoup.. ([156.19.246.23]) by smtp.gmail.com with ESMTPSA id h5-20020a056a00000500b006ed4aa9d5c0sm11981405pfk.188.2024.04.24.16.02.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Apr 2024 16:02:43 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Pierrick Bouvier Subject: [PATCH v3 16/20] plugins: Replace pr_ops with a proper debug dump flag Date: Wed, 24 Apr 2024 16:02:20 -0700 Message-Id: <20240424230224.941028-17-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240424230224.941028-1-richard.henderson@linaro.org> References: <20240424230224.941028-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::42a; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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 Wed Apr 24 23:02:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 791572 Delivered-To: patch@linaro.org Received: by 2002:a5d:4884:0:b0:346:15ad:a2a with SMTP id g4csp1096654wrq; Wed, 24 Apr 2024 16:05:03 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWY+dQHJUYK2Z0LZi87Xilq2Fl8+63AgPgPChAqlh8LQwyHiZZDSutWbuL9wWzT3XJGlKQKvdyOGvrJtfXVjDA/ X-Google-Smtp-Source: AGHT+IHH0LhQXUMpzZ/4CmWy6yrb06o0bP/BXatx8oSPcKTWMzWjTZebE5eR6y2l1IM8XhKP2No9 X-Received: by 2002:a05:6358:4b02:b0:17f:5ef7:15cc with SMTP id kr2-20020a0563584b0200b0017f5ef715ccmr4851428rwc.3.1713999902903; Wed, 24 Apr 2024 16:05:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1713999902; cv=none; d=google.com; s=arc-20160816; b=KLLFXYYaBKsldo0GeovfKjPZm0gKuRiYQUdBFzKhrpANRCnX7fAOp26PUATHqySEHG t7uN2veTojoOb2HcCDM7gnXnDUEfopn6OsUx4Ke00OqNczVwYTJDgNVMLErJy+A8svSg adHSLPxpprf7ouRo7DJ2Nc049GExNBUBkSd+yjrPGNrcnJd1LHXDl/89OCw6jt42YNHu qCS/vSWsrhRq5ZV1/RGlZRY986owcZjlEWtg8E/zzbUL+MztSYGDjtBsfqidjBFA7IrH wlqlpmWHK2cUQvBBT9sMlk70BKw+TadM3mYNstGpUlRuUJ4fNcsekJQ9ZvYn1/PZYfLl KiQw== 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=tW4cQf3qzQI4oIplMg5AIgAILatWTU4B2TSwmRpNBVWXY1MbdSH70oFXHYmGDbGdJd VUtZxaDk45/pQjpO9s6AlLjamNXBAwCECr6KHrwX1yPDn400khkB23ogvkAKyfRitj7C LmuIOfnsPeldNhWq/SQwFIbnNpddUuVocjVNeXgcCnBDp9OFhDsWSoo4PZJKGyZ8WePP tbA1aEWNjZ1s3BQZ2b0PdCejhPrvhVA1R+5DDQUcDpoR2XRy/gV75jjfcqsPTLT2CSVg Bnoli09UBdJuD+XDFQzOYHv0X1znN9LvYMHcRnogZiKru3LcjSKy6LHclWS/+w/VxdeT E/Ww==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=r3x1wSOq; 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 gd24-20020a05622a5c1800b0043a353ed3b9si1560792qtb.111.2024.04.24.16.05.02 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 24 Apr 2024 16:05:02 -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=r3x1wSOq; 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 1rzlda-0003r9-DC; Wed, 24 Apr 2024 19:02: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 1rzldX-0003pf-GW for qemu-devel@nongnu.org; Wed, 24 Apr 2024 19:02:47 -0400 Received: from mail-pf1-x432.google.com ([2607:f8b0:4864:20::432]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rzldV-0002fL-Qf for qemu-devel@nongnu.org; Wed, 24 Apr 2024 19:02:47 -0400 Received: by mail-pf1-x432.google.com with SMTP id d2e1a72fcca58-6eff2be3b33so456495b3a.2 for ; Wed, 24 Apr 2024 16:02:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1713999764; x=1714604564; 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=r3x1wSOqM3FfWc+ZQx1agyLUWDf+RhkTicKLrKuWhFer0XeAzXuq9YUdgZOTXj3Oii 5Ua6z9sEoj7hYof0IP+EDjquNWg3qb3tD5UvjtSAHve9yPo4KmhGHFCECTaIf1wTOX5W CoC2zWH8nn/BtLDQN1KBzdX2ZRa2GI738mwb3iLw0dE2mtJUvL3x4AdUEuwI/0dqOAwO LQS3Y9acDC0uu1M9qorfv4b0Aorwbh1Cu8Zku4pdb7ed0r8eP2HDB4rHvcE8hDalcJIo dCN0ETegV1AD5wcRFPDjmbflVh8qSab92hyglGwJ3OJP0NleMTUwhuIY2q+SFgIoocSo AEiA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713999764; x=1714604564; 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=mHaclyVtyhMM4WuQGCwCJzciP62st6KLZsOiCI7UfsV6cVbjMDMIaC0oFI4b5oIaw6 gNjRD54Am/8//czYV6f8w8vnTAS9I9Kv3ru7NEtDMx8PxrZUeB/hqyzB7iWVfLc0Oa5x 8P9fy0ucrjEYuXE7MzKkZw9y5d8JuL/rAJ2syONDcH/dSshrH1ua66Ug8w3orgolToO0 sSg3JCoyEJVNq6rXcmRpWxAnq8SEO/74K8VRrc1okez5W/iPkV9oz+Oe7GG798ypEams fxORYjliVllSKz41DegurSrdoldKLGT5QSLsu/C5ExTT4LTy6kI3jX6MkwRcHfIhmyiW wWyw== X-Gm-Message-State: AOJu0YzvYVHE8JzUs6QWDXdEElY4YiWBcjqpCqZ5ULj2/taB2JWoeQjn jWRm+8ckw6+j0kM3Iz3f3tvRgfz+HmUva8i6o1mn2NLW5EidqSok54DUDvNCs+Oqz9Kw8Km6HDV x X-Received: by 2002:a05:6a21:1a5:b0:1ad:12fe:103a with SMTP id le37-20020a056a2101a500b001ad12fe103amr4795553pzb.23.1713999764359; Wed, 24 Apr 2024 16:02:44 -0700 (PDT) Received: from stoup.. ([156.19.246.23]) by smtp.gmail.com with ESMTPSA id h5-20020a056a00000500b006ed4aa9d5c0sm11981405pfk.188.2024.04.24.16.02.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Apr 2024 16:02:44 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Pierrick Bouvier Subject: [PATCH v3 17/20] plugins: Split out common cb expanders Date: Wed, 24 Apr 2024 16:02:21 -0700 Message-Id: <20240424230224.941028-18-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240424230224.941028-1-richard.henderson@linaro.org> References: <20240424230224.941028-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::432; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x432.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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 Wed Apr 24 23:02:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 791567 Delivered-To: patch@linaro.org Received: by 2002:a5d:4884:0:b0:346:15ad:a2a with SMTP id g4csp1096527wrq; Wed, 24 Apr 2024 16:04:44 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXT369i5XA1V+F7tqkeYJbieNbSAgVnl/RJhL3oAlzNqul5RGlnVchiggzB4W1h6AZaM0rXjqgBUjpJ8PNvc1ne X-Google-Smtp-Source: AGHT+IHdpcWMKRT0AGEW/9AhRi8TkjpNyXfggmKZRUMcI4nSbOYoASuOd7o+FNwAQwSxCcBHVNUC X-Received: by 2002:a05:6102:22f2:b0:47a:1b4f:7bdd with SMTP id b18-20020a05610222f200b0047a1b4f7bddmr4066711vsh.34.1713999883806; Wed, 24 Apr 2024 16:04:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1713999883; cv=none; d=google.com; s=arc-20160816; b=TAcyLuRlpFP4R44TAvfH7pijNXqpRRJkO8ENxIKijACX/qx8AqorzFndIIgJMjivyj V3ASxM37CiVtKbU8Ufwv6WD5aciEgU7USKxcy2NnZRYQwzXM4js/BeD+hXX9KOoU4mhv PDFxWpxX5kzZG11JVE/HVJbuWL2c5dKsbq/7Zp9g2EzQbpxdDbI1BAUCmaaYUXphXaRS 8uZWxhH1SGzB1vIm4SnXFutf5hEj0UmF9HnRe0xyQoS24Omc4ruAFaL/3LywVob6kT7u EYVfiOYfJ7Diilln8Vh4HO9KhTUurNpodg/9E6Na3chmsdcoEHMTDxXpixlnv9QWulre /N6Q== 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=ETCJVDSXGdnbhaS34TTA4eigz471Z7tKCCXHV2Ax/WmVaHMpekB/MIAEH4W/NZ1SSC IXM95Qki7DzgK+HSMoh/LTEc+eEv3Xh3m2Po1ACJbmhtnqsVwTnWMrSNAFRJ5nldTI/W U1sd/0rSFq062CBGjirE4I4tMiid5MXkTH2xw0FF5C4srmESg/gbq4+NSNUopvHhbrQZ gpTLYJ3usVAGZRLPRUY6eRCFSlckK1ETspraGsS1gcoPmQaefLoiMO4GPNeX869vSMIm k4+KZsEClN7oMcbnY9yko6lilF9sA72UCJd/KjthjgjLLySHdrByltoiDHlXhWMXR4fr cmFA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=wuV6QoWw; 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 u15-20020a056102374f00b0047c1812951csi33931vst.269.2024.04.24.16.04.43 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 24 Apr 2024 16:04:43 -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=wuV6QoWw; 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 1rzldb-0003sI-AK; Wed, 24 Apr 2024 19:02: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 1rzldY-0003qD-Bn for qemu-devel@nongnu.org; Wed, 24 Apr 2024 19:02:49 -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 1rzldW-0002fW-J3 for qemu-devel@nongnu.org; Wed, 24 Apr 2024 19:02:48 -0400 Received: by mail-pf1-x42f.google.com with SMTP id d2e1a72fcca58-6ed627829e6so502380b3a.1 for ; Wed, 24 Apr 2024 16:02:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1713999765; x=1714604565; 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=wuV6QoWw42iktFgmXcXz9JGWu4MYTzgIYm6nyDXbyVI/6QWvMvQ5wmqF0r8VIWZRLA ZtPaEs/kUkAEUWFU7riKTuVgtf7a9WlRJpCVpfd/uUaBGfqKlnS2JNvFab4KRCzO/peF brcMQGtMbYmTenCqIVsRY53buCn382v05O8tN1zSkR1on7zg70+cdgVqgJD7X8lCs/q2 ydG7OC7gO70lvNthBah6wVZd5+C9JCToSDlq5AxMsNVrgqxaeZ+plXmF43hcV6qB5KlA kVq+KdOG3wlMNZgUATf3TXJWcccpfwhjdTEIip0nQqsLqjbfu55fkxTb1yBenz5m8G1p edSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713999765; x=1714604565; 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=Bg2h2ZO+ZV+ium8qE4S23xgTRsPQo7dK3rRxdO4jIOn8+QpT7vRC1riaHNwQlbl4zr EUNiekP9cExg5YkW6BZheJOWc9tFxg8ZRwaRJcLt24g/g1YZVY02CJHby3pI/HAmYBqM oQ/Lhe8ZjLagre+WeXo49skZmFBawIhozWCCtv1a/ilLsl3BbxvFaJ/FFKRc186Ycfw9 SwG4RxgNXUQQrIGnxaUZCqhoBS2akSb4L3Gk11kzrHNbnUJqrN9K94t7XsC+OuE1vCpp eDTUxzEsBBsA097zt+TyY7N2d+/96JnrA5E8/K21ilzAzd0gB6GE660k4hxRChlVYMby BO4A== X-Gm-Message-State: AOJu0Yz0uBh1pVDe7NxbL/rwBFIAn+oEmHAmfL2zVnIdc/RKMHfQh7CP MM0c2nRcThzxH3JkLIL+hEnlWuxJEsZljLplw+BV3i2MIDRyUyorYPOUzdSu40RmPspPyd2kLqV 9 X-Received: by 2002:a05:6a21:3991:b0:1a7:c67:82ff with SMTP id ad17-20020a056a21399100b001a70c6782ffmr5103506pzc.13.1713999765221; Wed, 24 Apr 2024 16:02:45 -0700 (PDT) Received: from stoup.. ([156.19.246.23]) by smtp.gmail.com with ESMTPSA id h5-20020a056a00000500b006ed4aa9d5c0sm11981405pfk.188.2024.04.24.16.02.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Apr 2024 16:02:44 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Pierrick Bouvier Subject: [PATCH v3 18/20] plugins: Merge qemu_plugin_tb_insn_get to plugin-gen.c Date: Wed, 24 Apr 2024 16:02:22 -0700 Message-Id: <20240424230224.941028-19-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240424230224.941028-1-richard.henderson@linaro.org> References: <20240424230224.941028-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 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 Wed Apr 24 23:02:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 791565 Delivered-To: patch@linaro.org Received: by 2002:a5d:4884:0:b0:346:15ad:a2a with SMTP id g4csp1096283wrq; Wed, 24 Apr 2024 16:04:13 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVQiowjbJYX6FAtjaF+v2i73vYw5YN+uLZt+XPNfNo1bitJ7XWG7O7bMacArrnstvqq2Xx1Wx6aLX5xNwSns/kd X-Google-Smtp-Source: AGHT+IFZlRLUohNjlTvaXUujheThMvGUqrY4xcUPEmWPJTBaRYME8Wybofeka4R6jDSRc/EZukNa X-Received: by 2002:a05:6214:e82:b0:69b:7363:92a with SMTP id hf2-20020a0562140e8200b0069b7363092amr1961874qvb.8.1713999853450; Wed, 24 Apr 2024 16:04:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1713999853; cv=none; d=google.com; s=arc-20160816; b=gqQkD0BwmLeQa5nziOLsdJX7a9aBlqVZFAWafX73Az+tuOcfuNytwkYZzwtmSsNc9g nK1573oF+ZcKVG+Z0C/rP3W6axtXh3ESAoi/FY+ltZMVCirAaBjq3vEVE93fzB0DV9f0 JIWluLUoAzO3/bvWkP9shTR0Mf+B4wVW0WoTfmwABJeDKtIE/rb0auCwhEUvf5sI/n5I GjZYLb58v/xiAYlmyX/NNE0uYjZza2laGWP+/2EMHcLGub+h3hIpRGoS/hz3QeMtgVQL tlGXpHaTDHF8LCjlE68WmLFDrQsSIdon8oWGj8KY97I+0TAQ98N7E/kjfp21pkIlNi2i vtxQ== 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=Pfi7Zex/LeqnOJjPqTZSMVRJP/Uq37OjQrpOek/PGaLs1jHwBjrk/TCYpm1Lf2erJx bSkh6KFiqRM+gY1IDDuKoIbrtvp67dGTEDLWi1nwSH5ljVwtqjbNrXqJYLDlDmQ/hdI3 lmeWi/rk58xGXNSm7IceGHHfzqjpqXWs2puFVLq5vBVXc7WVFShKzILOM1rsmqSKzdO2 XU+/PvPzRpS7dp/8TT28ALEzVIKRt8kidf91RhchrfaavMo8eXpp6fX33NskVFsbvpcz jS7jjbdUkjLzG6XfveFWH1N7hD7ykqPPMGOIb7M03PGlUTd64LxBZzUL5B1f0uymqLAw 80Kw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="rWdA/Zoc"; 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 kc21-20020a056214411500b006a04756facdsi16747414qvb.182.2024.04.24.16.04.13 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 24 Apr 2024 16:04:13 -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="rWdA/Zoc"; 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 1rzldc-0003tH-4l; Wed, 24 Apr 2024 19:02: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 1rzldZ-0003qM-A4 for qemu-devel@nongnu.org; Wed, 24 Apr 2024 19:02:49 -0400 Received: from mail-pf1-x430.google.com ([2607:f8b0:4864:20::430]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rzldX-0002ff-L8 for qemu-devel@nongnu.org; Wed, 24 Apr 2024 19:02:49 -0400 Received: by mail-pf1-x430.google.com with SMTP id d2e1a72fcca58-6ed2170d89fso1069564b3a.1 for ; Wed, 24 Apr 2024 16:02:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1713999766; x=1714604566; 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=rWdA/ZocjsbTHgQyVSCBkurn0kpCIzt7nHMhhe+LkutEV3yxrW6IEtB1DH5o7tYvk8 Kp/KSg76YryBVmYAMwNrcUYCWh/Z+wZOLX5XOVNveOULK3EElgHhJp8B6QheslEHD1Sl Wkk2liwlVTtvk9w7RlpghIMBmTTwk1IpLgShcvOSRjJwwywSUfhZrjVxHICtcAz5zWge eVko/0TAxc/lK3VhFi6quog/ys5+EeXResQ72M/VzVh5z7o3NnBji4r7T+WbD86Vaody UqkmUO89XZnRNepvP8Rm3pfInDl1aZ3vMrVCab342F9j8F0QBrFIjBnDAuY87v9FePum cTDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713999766; x=1714604566; 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=Rl1ymeJki0CMsuQn2o1g5uxfXR/tgqgyngJbCfY9y/FxUHSz7zvq4YXThKfqwfUB0c cSF/X+vSyFdDTuX7KGfxryH5htL+6OuKp8PLXyI7EWoVKwA8PbxqrQc6fWsx4hA1Pbc0 yupgP+QJlwtphEUUqxYMLWGCV/VpxmRkUv5xsDj2EZJZz01oaKxVf2BUOnw0vYrd8tKF OR95n3KeUz3NEEcFAk7TzUQQ9aUdiIfo7+luOymsnRxaQ/KbW5rUKaduM31qJkGwkiFs 88T825HZagoOoCihq6i0Onj7ZIm6nzhxfc3rL6BOeohMme7dUZ1UVR63wZcGMaC/iPc2 HGng== X-Gm-Message-State: AOJu0Yz3Lx7KH/mmmbf3ryRq36pNsokiUT02oVy/llvSVSM/CQQJaEbr EsKk+9xqBq0EcQFyoNDLtSewy8mxce/VHScL+mxhivHBN2kyITapEeCAIyy6iVAh7Mc6MbjgWpE n X-Received: by 2002:a05:6a20:564b:b0:1a9:509c:eba6 with SMTP id is11-20020a056a20564b00b001a9509ceba6mr1531026pzc.25.1713999766125; Wed, 24 Apr 2024 16:02:46 -0700 (PDT) Received: from stoup.. ([156.19.246.23]) by smtp.gmail.com with ESMTPSA id h5-20020a056a00000500b006ed4aa9d5c0sm11981405pfk.188.2024.04.24.16.02.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Apr 2024 16:02:45 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Alex_Benn=C3=A9e?= Subject: [PATCH v3 19/20] plugins: Inline plugin_gen_empty_callback Date: Wed, 24 Apr 2024 16:02:23 -0700 Message-Id: <20240424230224.941028-20-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240424230224.941028-1-richard.henderson@linaro.org> References: <20240424230224.941028-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::430; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x430.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 Wed Apr 24 23:02:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 791566 Delivered-To: patch@linaro.org Received: by 2002:a5d:4884:0:b0:346:15ad:a2a with SMTP id g4csp1096344wrq; Wed, 24 Apr 2024 16:04:20 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUnwIotbb8cQSZPvdRMWLql/H8IppkKHbaOzABmGUHDNBdfIbg/oc20TK4RyZa2dM481I3yuE16jddLmG22rnCr X-Google-Smtp-Source: AGHT+IHNH8S5rSbl+smlPRmaiT/iS81dJk9rXB5nfSOnNIlL8rHLCL1+68xqzRofUe8SFo/hIQcY X-Received: by 2002:a05:622a:14c7:b0:437:c49e:ece9 with SMTP id u7-20020a05622a14c700b00437c49eece9mr4516282qtx.42.1713999860320; Wed, 24 Apr 2024 16:04:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1713999860; cv=none; d=google.com; s=arc-20160816; b=q01SFWCZm8NPs2Wla3toQXGjYiwkMQFGDWOmvR7hNfACI0ikmc4F1ddN0zOifoVPAI WveX1+qxTkDGJACFykaCROQhzbpEtw6hbRi/W903IA5/LzghnLUcDp6hBoYY2NrCp6sA wdu+UScEQXBiVmlZ688bKwv65Z8Oyi5BHeqVxN/d6+NEotEG+fT1Md7GkstbnVN4s3si RYzFyjE3plC6pkozwp4g7nm92fOc3al6OJXgjo8Zx7sbE4lCNOsjigXvSdFIJkFTTHbP 3ZdjDx3WC+2TtP4ZOyxvnxpe+tAF9TL4MfVQTFLtf162FY774sT6KFrC3JcPEQ4ysY7w w5bw== 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=coQwxowwAQdt7qYYXU7PPvsmghlOBu/8bwAtHMvuCLHywI+0YxUZhAE+KilKwAJAeW HU6uiZ60lJKLgtq2rtfzPPgSusICQTsRBKcZRFub6jnOaUlUFnih2wBe7/sOa4iV4X+S Tk46HtuKSc7vDd+ew6UG0eMWkmT62VU5HyM3YqJNCL4fm5JtGTxEknZs4exgqioqft1h kg6i3NOcRkKWL4wu27JqnD3zPrqhUVOsQwK3wlA3ArTssXlOfMzsYxsCSGC66uSjYzvN e2a8kS9iFviv1Tw1bu+7ApT+TdIMHvJVEwI8/NJ8g64+l2HKFoz+f40N623/jZa4jh7/ W8bA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=lMxfB9E5; 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 o10-20020ac85a4a000000b00436adb9ec89si16645183qta.301.2024.04.24.16.04.20 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 24 Apr 2024 16:04: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=lMxfB9E5; 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 1rzldc-0003tQ-MQ; Wed, 24 Apr 2024 19:02: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 1rzlda-0003rT-Ce for qemu-devel@nongnu.org; Wed, 24 Apr 2024 19:02:50 -0400 Received: from mail-pf1-x42b.google.com ([2607:f8b0:4864:20::42b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rzldY-0002fv-HY for qemu-devel@nongnu.org; Wed, 24 Apr 2024 19:02:49 -0400 Received: by mail-pf1-x42b.google.com with SMTP id d2e1a72fcca58-6ee13f19e7eso425563b3a.1 for ; Wed, 24 Apr 2024 16:02:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1713999767; x=1714604567; 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=lMxfB9E51nVwCVawkxn8buzfoGOSX2vUXTqRFQtYjFyKzvoMj9DSmYwT1IJd9dMBul YMkKAI9mOCTZfGjP2BcDPTZNj2EwhLvk23vN5vKeW9JbYzjg1POQv9U5s+De9x27PvjY vjPc3znq608oqsHejximUSpt23JaBudkSmqUhV4duEdBf1xz7uxugi1f5ixWlXnsT8jy VzdeMwyIyio4GlcBPjrlUk31bhFRZgB/Hvrf6UdJss0L2Oq6m+wlmeVuLFZT5BKxAls4 YcsKLTfZNIhBT5wTznqMuGjRoL73apTsJ60QpC5bLsVPJX3AzAkQDMkfOAF5LuhQrs3I Jr3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713999767; x=1714604567; 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=Vfx2JR0AAVWZhnyq422tzq0+1+Guu9j5cgA/5H1yONeN9jhfn8P5KUgcSw8TdYRtRZ tHca13WCr+UJ8skFX/xtfff6RmpGHDDq5eZjJrRM4kT8FPzefNabmQ8bPKaExKYl6+XN tadNcCrh2RyE2bfcN2vfVTGZeAG7doP+eQ3CpSC+gr5BRz0H5BMmMBIb3xcCtD/J2fTf WowGwxm3NQ1dn5Dou5+U/EvvUf4xFO5aNnWe7HZFYV7SK31p6OROef/49dSRHMWiFtLQ VJ9eSPQ3suZi1jcjxQNy14l5DTO0AdZsETgcs4Wi5HAyjXiIh3EuH3YUvyFwvz/jZsHE YkDQ== X-Gm-Message-State: AOJu0YyHuht6zOvwvZuZh8198/+XhOMDGkxbth6nrOL7+cEDLgwDDZhu P0NOVJPXTqB3dyesgA8qZYzByWcSIyYRnNcwPvcJDnbXwDVu8IQUVfmvdBTRdGD5Eb716Z0cP/u X X-Received: by 2002:a05:6a21:6802:b0:1aa:5fb4:87ff with SMTP id wr2-20020a056a21680200b001aa5fb487ffmr4008038pzb.14.1713999767178; Wed, 24 Apr 2024 16:02:47 -0700 (PDT) Received: from stoup.. ([156.19.246.23]) by smtp.gmail.com with ESMTPSA id h5-20020a056a00000500b006ed4aa9d5c0sm11981405pfk.188.2024.04.24.16.02.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Apr 2024 16:02:46 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Pierrick Bouvier Subject: [PATCH v3 20/20] plugins: Update the documentation block for plugin-gen.c Date: Wed, 24 Apr 2024 16:02:24 -0700 Message-Id: <20240424230224.941028-21-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240424230224.941028-1-richard.henderson@linaro.org> References: <20240424230224.941028-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::42b; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42b.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=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"