From patchwork Wed May 1 14:37:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 793716 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:54f:b0:34d:5089:5a9e with SMTP id b15csp790556wrf; Wed, 1 May 2024 07:39:00 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWxjL0xhd2PxLAmcYLDUA5WCQSGXpATEAid4EfDq0xMc7YZTCh28d54jhjTjuECz2b3kx2usZcjpIgM85cFv4Dm X-Google-Smtp-Source: AGHT+IHnCwQsiYUiv46yVPx+ajhF4mdZAEeSthfY/6S7yj7Jyfft5TkLyyDgt6Cza77h+ZkZHILj X-Received: by 2002:ac8:58c3:0:b0:43a:e5b2:8627 with SMTP id u3-20020ac858c3000000b0043ae5b28627mr2397421qta.62.1714574339790; Wed, 01 May 2024 07:38:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1714574339; cv=none; d=google.com; s=arc-20160816; b=xEL5YB0ZRWHrjwatx+4rq+B9o41e6dguEo4fHOAJ6aO7UOseLTRJBzut/W4wOuphcm F4w+Sa8YUSyc3F9Rrfwt2ADEFAnW255S0ze681Hwf2ltbZQ3x9yszKm08j75PGxz+vhm 2cTXVkFDxt9+DENlBiV9doF7bYR1jAYkXVVheHGHzg1HlT0+IQFi4FuUHTu2FuZpsm5J +jYVe9pi9/IdQzuBNYDX4DjwxE17HVXSh4RiIz2CALGdhwyLwbazWQkVIcYxyfvOEoLd 2mn2I6SpjF1Tb0KjoyldMxwKKw6fFNeQQwvTV60gEIPSRjc7bFjJShoqDzETLrHJ0YzB QrhA== 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=w0VoQ2qkKN/RYQvDr68owMd+LBRx3HOf412+iIHwvUA=; fh=D6FqPLU6GE0ldmgADbJ5dLNMSeh7MbgWcAv41ubRnOE=; b=I7ywCoaj6AvRPM9CYoMS22gUdqnL0+PD49ye8uTCD6NaIESgShMgZMVhfDXEZBWiJi DA6N1mb0N2gE2T5aOYApgk83Y0VC/42X4hhOEkAnK7HuZgJdSQJym2gaDpZcr0CYWDwm gnerfDuaHJYw/1LarLEkRXxQWxOa0v8yLmJj5aUmqivh8dO2SXRArk46LrP+dUvdLII3 btTtEBtHXGYXGqyy8+WJfE/xJoRZ3kXpbe2O1NEjWfgBftYk72y97O78k5SD7TgbyZ60 GFxPd07UMMMxVX/JZxAEN/dCu6qnsl5lBsSmwCBnVaZQRVF2Xr9cPu56ApMdzXxCsTBk zrhA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=tLNv+QX3; 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 p14-20020a05622a13ce00b0043aed1d9b19si7044177qtk.209.2024.05.01.07.38.59 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 01 May 2024 07:38:59 -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=tLNv+QX3; 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 1s2B5g-0002en-Gr; Wed, 01 May 2024 10:37:48 -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 1s2B5d-0002dx-70 for qemu-devel@nongnu.org; Wed, 01 May 2024 10:37:45 -0400 Received: from mail-pl1-x62f.google.com ([2607:f8b0:4864:20::62f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s2B5b-00026F-Mn for qemu-devel@nongnu.org; Wed, 01 May 2024 10:37:44 -0400 Received: by mail-pl1-x62f.google.com with SMTP id d9443c01a7336-1ec4dd8525cso14157525ad.3 for ; Wed, 01 May 2024 07:37:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1714574262; x=1715179062; 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=w0VoQ2qkKN/RYQvDr68owMd+LBRx3HOf412+iIHwvUA=; b=tLNv+QX3Z0KgyxF+r0rhdhom+mqpVD0E7nGJ3CwqeF2HhRn0KigF0pB2sGxDGGekh9 FHCwzCL5KB5TBqyW3eJIKpBnOuyfSxvy6+j2yOP+WLKM9lP5/ks6QRUGoCuOKJuD+qfb 4eN1yieIEFCSTrYrnj91UShqbfrZjYv9rriQ7mmtl3nZmv0u3MabCQ0FYKB87O0zg0Fa FieU3SyJhoXi5KYpA+cOUNoZUatXIYB5dXNxqc9noj3e/+M2wPFy15zt1bNMeVRpp/Bg NR06SDN9+5KmUhP/4fUSGD+gFRrMowVNOp/aQrUKIl3i9rsEr7j11XZnClvgiy/OZ0Bd f7NA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714574262; x=1715179062; 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=w0VoQ2qkKN/RYQvDr68owMd+LBRx3HOf412+iIHwvUA=; b=JpBS2eowvbIbXPIKqgknwWVBtoCNxA/vVTFDX7ZqhGZELW00zhg5j+x8NdIQ45U/Wq rG6Y+lAjVBi0fX+Kx10athkL22bEDZOzHXPGUzgaweZz2xnVqNmOaQza55UoTn8Pgkns OJ6a5pGBdEPGg2oeu67bWTD70h20zqJid+TIID6GXskhqgV+N41gl+tw0JJ1Ba9RHq7y iWYYOkx++FtDfVSRhGNKGn16ewodsk6kBMciCDxKZKmvvaKamWCEGBaIH2B8q1XTZjpY zxmxsnXfE4eo7/lDDsH2tTT3tarLFA8bE4V6MC4eW3RQ9VqDv9trVZnzXBPi9zbx+wr5 k7/Q== X-Gm-Message-State: AOJu0YybLlFX/e+qS0Ed3srDKJdYAH/kak1LqmLFG+22sBZfl980Lwac SM8vmZr7U8F9cPrdelVtB9TUi3eVt36uznuFTy0LBU0ny20sJNif8/RciIiRDUCcI91ewz4bUuc S X-Received: by 2002:a17:902:c411:b0:1e2:9aa7:fd21 with SMTP id k17-20020a170902c41100b001e29aa7fd21mr2820860plk.54.1714574262287; Wed, 01 May 2024 07:37:42 -0700 (PDT) Received: from stoup.. (174-21-72-5.tukw.qwest.net. [174.21.72.5]) by smtp.gmail.com with ESMTPSA id h12-20020a170902f54c00b001ebd73f61fcsm5751573plf.121.2024.05.01.07.37.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 May 2024 07:37:41 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , =?utf-8?q?Philipp?= =?utf-8?q?e_Mathieu-Daud=C3=A9?= Subject: [PULL 01/20] tcg: Make tcg/helper-info.h self-contained Date: Wed, 1 May 2024 07:37:20 -0700 Message-Id: <20240501143739.10541-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240501143739.10541-1-richard.henderson@linaro.org> References: <20240501143739.10541-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62f; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62f.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 Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- include/tcg/helper-info.h | 3 +++ include/tcg/tcg.h | 2 -- tcg/tci.c | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/include/tcg/helper-info.h b/include/tcg/helper-info.h index 7c27d6164a..909fe73afa 100644 --- a/include/tcg/helper-info.h +++ b/include/tcg/helper-info.h @@ -12,6 +12,9 @@ #ifdef CONFIG_TCG_INTERPRETER #include #endif +#include "tcg-target-reg-bits.h" + +#define MAX_CALL_IARGS 7 /* * Describe the calling convention of a given argument type. diff --git a/include/tcg/tcg.h b/include/tcg/tcg.h index 05a1912f8a..e4c598428d 100644 --- a/include/tcg/tcg.h +++ b/include/tcg/tcg.h @@ -39,8 +39,6 @@ /* XXX: make safe guess about sizes */ #define MAX_OP_PER_INSTR 266 -#define MAX_CALL_IARGS 7 - #define CPU_TEMP_BUF_NLONGS 128 #define TCG_STATIC_FRAME_SIZE (CPU_TEMP_BUF_NLONGS * sizeof(long)) diff --git a/tcg/tci.c b/tcg/tci.c index 39adcb7d82..3afb223528 100644 --- a/tcg/tci.c +++ b/tcg/tci.c @@ -19,6 +19,7 @@ #include "qemu/osdep.h" #include "tcg/tcg.h" +#include "tcg/helper-info.h" #include "tcg/tcg-ldst.h" #include From patchwork Wed May 1 14:37:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 793713 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:54f:b0:34d:5089:5a9e with SMTP id b15csp790419wrf; Wed, 1 May 2024 07:38:42 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXy7NZi7RLgfX+Bahw7v8JTmn/xBNkVxEB8URJ3QnmVMuNiNTjTkEYw4N1Yu/xcIHplgrG7zoT6Sfwu/fVVCx8H X-Google-Smtp-Source: AGHT+IHMy/XHdOHXGkW72fFVhJZOD5xFt6BAY+NE/m1qWA+xXHyFzrbPRUb/zfztD0itIFgh4gPV X-Received: by 2002:a05:6358:9889:b0:183:6427:10b5 with SMTP id q9-20020a056358988900b00183642710b5mr3900762rwa.21.1714574322280; Wed, 01 May 2024 07:38:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1714574322; cv=none; d=google.com; s=arc-20160816; b=tm/+mpMrkYiCE0h6CFPX1z4PsPhgdIfTKq/rFOExO2bvJEry5QSwAAqkUcefhBQiCY XSEBlmoE48YOfri7l8FmIyRHtLdgdKRqGv+Yc0J57IfGKDTg25TtnAMAGrgUE1hPnexa Ffb/o2Xx7r83u6R70I6ZCxXTEcgRR5BHReEoHa71Vw1oC5sVTh2JezVIsljNbAbZ1wdI JRJG8udLJuZDbPL0K+17V5Oujvjz1nIasqVqRv40GnVEgne1iExPaDkE9xuaWRqQSnxR lMuRiLpXwKSasbnyB5QHMXSGJzt1n43NApx3wIbddzQS2pIfIFZmnJTHKq32RYAqJpDS 0YTg== 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=jid2brVEKFhU0CMUENvSPUf/xlRDtdQ3X2d2opplfCQ=; fh=D6FqPLU6GE0ldmgADbJ5dLNMSeh7MbgWcAv41ubRnOE=; b=iacaXXDh9O0ss2TlZ2GTEj73Ov4Ml89CQEJUQF1dGQCMOB2kpkx1uv9o2kwM5eCc3k /PB1QBL1kVcJJd9aZUxbHcmQMLZ2U91KjyETVjqpfpbzFqh3mcbkQTn2Umt/yeLh959F /FDdWno41BuMkYGRNeAtaEp2LJjuJAgaU8LSDK7AnJs4z9ZFdhObb/LVa6Vsycfoa8Pz hPJ6Lun9CSHZq8b+G1WX8TZN4l/CuydHRazYJx3ypqgKMpNDnn4Ll9CwUYBZsuxLhOFm 0u9iw011OYCKYxEFJWM6RLV69ugCXWJ9WZt6Xqipy6RsDWNMnVunfrnLUtbT/OYQLbZE HAZw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Hbl7SjWi; 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 gi9-20020a056214248900b0069c185ec102si32815708qvb.364.2024.05.01.07.38.42 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 01 May 2024 07:38:42 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Hbl7SjWi; 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 1s2B5h-0002f6-6Y; Wed, 01 May 2024 10:37: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 1s2B5f-0002ee-S0 for qemu-devel@nongnu.org; Wed, 01 May 2024 10:37:47 -0400 Received: from mail-pl1-x631.google.com ([2607:f8b0:4864:20::631]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s2B5c-00026U-Oa for qemu-devel@nongnu.org; Wed, 01 May 2024 10:37:47 -0400 Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-1e65a1370b7so64098105ad.3 for ; Wed, 01 May 2024 07:37:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1714574263; x=1715179063; 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=jid2brVEKFhU0CMUENvSPUf/xlRDtdQ3X2d2opplfCQ=; b=Hbl7SjWiMrAXUMUnTm9vGRQx8D9wPPGkRhcRqUsRZWI+5AIl/NtmaaZvYUPiCfv2Dd 5wdi/JYYKgjJX8tCY9CVHycbHYeKTrwfXOqD+9QKEhMWWJOabco3mXmlpyZ4mQIqgAnz SMJZnrTcLIMPk/IhzEAB0d5M7W1ZDQxq/QLJOf6Bl7aJstYlH4AGmzyJWpy+6RpBUfGu oPAWjit7/uSgqXUpYpsdVdDfBptUo7S/cTY2ukp0WSKjShzNZ3QYGt8xwTemG1r16B+R 837T9I/l0Gsx5qs6ouHhvheXhfBqf8mZgyAB6uRlhvm/oXBqVaafD5PEOVraWYBtCF7T 4+6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714574263; x=1715179063; 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=jid2brVEKFhU0CMUENvSPUf/xlRDtdQ3X2d2opplfCQ=; b=X2yGHg5qeAQEM0DzV0Xd8s9bAeF8zs0xWTdaMmvH4FGvzvDo6DCVCp9CwsIf2jlg6M ma0ihAkFfE0GAJrwn0T7Ok9OiDXy2p7lSLX00iqQiBdmHMMGU1+mYFbo81amI+ftbY8K cUYeJpVlfP7J1+y+KLpVMSi82ewLjG49a03cJZPlwcRKAhR76d5TkoVv7B35L4ltdIpO 8wFpvZZyYHEp7l5UzivCrw0Niq5GZet91Cc8Y1nUZrj+/HYDPIsk40YlPGn5C6D+4fkf MA9F4IY07GKDooEDqNsa8qe2+UwBBfTvvC8so13NXhGlAGJSyMm2ZDfW4qK8RrR8htrU Exmg== X-Gm-Message-State: AOJu0Yz8zePB/1aIPQS0gNo5M2VxbVIzJJ7Vptvcb2o8UUkJj0k+8ZVc DF4nLpHLhcjeihed2UemH3kBmjFXn4rTIPii535bNnYVTqLu0DT+jaGcBBB+NcdZcu/5GuYQitL H X-Received: by 2002:a17:903:1d2:b0:1e2:ca65:68c2 with SMTP id e18-20020a17090301d200b001e2ca6568c2mr3358451plh.51.1714574263267; Wed, 01 May 2024 07:37:43 -0700 (PDT) Received: from stoup.. (174-21-72-5.tukw.qwest.net. [174.21.72.5]) by smtp.gmail.com with ESMTPSA id h12-20020a170902f54c00b001ebd73f61fcsm5751573plf.121.2024.05.01.07.37.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 May 2024 07:37:42 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , =?utf-8?q?Philipp?= =?utf-8?q?e_Mathieu-Daud=C3=A9?= Subject: [PULL 02/20] tcg: Pass function pointer to tcg_gen_call* Date: Wed, 1 May 2024 07:37:21 -0700 Message-Id: <20240501143739.10541-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240501143739.10541-1-richard.henderson@linaro.org> References: <20240501143739.10541-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::631; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x631.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 Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- include/tcg/tcg.h | 21 +++++++++------- include/exec/helper-gen.h.inc | 24 ++++++++++++------- tcg/tcg.c | 45 +++++++++++++++++++---------------- 3 files changed, 52 insertions(+), 38 deletions(-) diff --git a/include/tcg/tcg.h b/include/tcg/tcg.h index e4c598428d..8d9f6585ff 100644 --- a/include/tcg/tcg.h +++ b/include/tcg/tcg.h @@ -852,19 +852,22 @@ typedef struct TCGTargetOpDef { bool tcg_op_supported(TCGOpcode op); -void tcg_gen_call0(TCGHelperInfo *, TCGTemp *ret); -void tcg_gen_call1(TCGHelperInfo *, TCGTemp *ret, TCGTemp *); -void tcg_gen_call2(TCGHelperInfo *, TCGTemp *ret, TCGTemp *, TCGTemp *); -void tcg_gen_call3(TCGHelperInfo *, TCGTemp *ret, TCGTemp *, +void tcg_gen_call0(void *func, TCGHelperInfo *, TCGTemp *ret); +void tcg_gen_call1(void *func, TCGHelperInfo *, TCGTemp *ret, TCGTemp *); +void tcg_gen_call2(void *func, TCGHelperInfo *, TCGTemp *ret, TCGTemp *, TCGTemp *); -void tcg_gen_call4(TCGHelperInfo *, TCGTemp *ret, TCGTemp *, TCGTemp *, - TCGTemp *, TCGTemp *); -void tcg_gen_call5(TCGHelperInfo *, TCGTemp *ret, TCGTemp *, TCGTemp *, +void tcg_gen_call3(void *func, TCGHelperInfo *, TCGTemp *ret, TCGTemp *, TCGTemp *, TCGTemp *); -void tcg_gen_call6(TCGHelperInfo *, TCGTemp *ret, TCGTemp *, TCGTemp *, +void tcg_gen_call4(void *func, TCGHelperInfo *, TCGTemp *ret, TCGTemp *, TCGTemp *, TCGTemp *, TCGTemp *); -void tcg_gen_call7(TCGHelperInfo *, TCGTemp *ret, TCGTemp *, TCGTemp *, +void tcg_gen_call5(void *func, TCGHelperInfo *, TCGTemp *ret, TCGTemp *, TCGTemp *, TCGTemp *, TCGTemp *, TCGTemp *); +void tcg_gen_call6(void *func, TCGHelperInfo *, TCGTemp *ret, + TCGTemp *, TCGTemp *, TCGTemp *, TCGTemp *, + TCGTemp *, TCGTemp *); +void tcg_gen_call7(void *func, TCGHelperInfo *, TCGTemp *ret, + TCGTemp *, TCGTemp *, TCGTemp *, TCGTemp *, + TCGTemp *, TCGTemp *, TCGTemp *); TCGOp *tcg_emit_op(TCGOpcode opc, unsigned nargs); void tcg_op_remove(TCGContext *s, TCGOp *op); diff --git a/include/exec/helper-gen.h.inc b/include/exec/helper-gen.h.inc index d9fd3ed72a..dabe138e20 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 6a32656cd4..7484a07722 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 May 1 14:37:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 793718 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:54f:b0:34d:5089:5a9e with SMTP id b15csp790602wrf; Wed, 1 May 2024 07:39:07 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVAZJvoeHOqYGNTvAHkzcbtwVaEV4r3i5V6dTs6V2q5lQcm/5Dw7HTRv2l11ku5UJjS1kDaEGqNzXtGEXa04czr X-Google-Smtp-Source: AGHT+IEFcyYn9GsVXRynWPzC1TXS0mVKlE+cPCumTk8rWi64Nt4KhfNrbkHxM7ay1l5IpXOCnMaO X-Received: by 2002:a05:6870:b4a0:b0:23c:6619:ee41 with SMTP id y32-20020a056870b4a000b0023c6619ee41mr3332312oap.54.1714574347150; Wed, 01 May 2024 07:39:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1714574347; cv=none; d=google.com; s=arc-20160816; b=SnF+MZlfatOu3wULCdmNagPlpWrepEJRgoYI9LK+yXojCV8ECVw6TVVY3bEUK35I3T haahumGEjHil/MAaqfvNf8hPlabZz9zcHxLPjugQC2yqt0dbZYg4sbuxkrpEUZFq8N/k EfDwLO07WsTy5aqI+WQbQeXD7DvCGiviWInhLp3OEX49c0JRV+1D+MrXkZApI/i4rLZl Gp+qTed1uOrYZgajwSPMnL+hbIPxTYd88cJMzt21MwnL8UoqqjJd6Lk3vuY06zXZsFkJ CkqhCJIZ1a2n5NmzeaRf73v5xCiWkmKrBb5JBqMCYV6atP54zAwQ/f1hD6qkc/7cWHAb xSbQ== 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=dFut8/1DV+9puLMOSSFmNtLOM9WJtXX+TX8Pbm2ApK9kflgtwqOrnJZSSwdCwrsV+I g3g/TzGNdmYVClO5dLdMRyoLDI8j+OHwicoTjzo2e4iiF3cERrDO6ILNGBxsRnQoZS2F wFGBP18MIvhpvP73wjc0bv3ttPTYZzgPmJoC+isuosFJwud+RJXCbV2SSpmT9HuzljCO ULwpqEYTQLc5HLNE8+B9nHovWZHvEGnYPETOPinoYJ9SJdOU2KWzVo0HHnn/2MzAOJro wrKWT0r5Mx0Cl0r0ZVYBkcuVhwbknObKgnRldxTxQ/8aL7w9hMZiPqGXmlG1LSLgjnHB 3OIA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=cK9RlXqZ; 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 pj19-20020a05620a1d9300b0078edfedb6b2si29607811qkn.471.2024.05.01.07.39.06 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 01 May 2024 07:39:07 -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=cK9RlXqZ; 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 1s2B6F-0002qh-K5; Wed, 01 May 2024 10:38:23 -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 1s2B5g-0002el-7J for qemu-devel@nongnu.org; Wed, 01 May 2024 10:37:48 -0400 Received: from mail-pl1-x62d.google.com ([2607:f8b0:4864:20::62d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s2B5d-00026o-Oq for qemu-devel@nongnu.org; Wed, 01 May 2024 10:37:47 -0400 Received: by mail-pl1-x62d.google.com with SMTP id d9443c01a7336-1e51398cc4eso60800885ad.2 for ; Wed, 01 May 2024 07:37:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1714574264; x=1715179064; 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=cK9RlXqZlJ/cxNAF1uxSjKcLYeTlh8rVuLVg6xRE2MAg1l0pV0efStmVlC6kTjKxsF 4dbxbi38ipibRY8/dYzndLiGWoFlZj/w74loJVROhdk/T2zyAJbWu2I1zFlZQfDlNlCn HK2kj9lPmIamH/nvPgJ5jWJ3mKNROliFPvdbfCRaWw/txBirUDzVji8Qt3AtRZamu0rT p5K7rwgl9PnPnMCiPFNfozXDqpQRbsshcqTkefmnge110Zy1KnFYZcYEWJFLZudSezki 7y6OY2H4Q4IfaLp87/oUlQNyHsC8YBw24QaUIXpZa01C5Vzcw1qowwQDftOc4hE1LEUV OHZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714574264; x=1715179064; 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=oCGfN1UrFQR29aaeJlhCn1tl+ncRVqPxScOWG+DSQozU46KQurZYp7XQ7BNE/z5WpE DEOJsp0/ktumD89BHirqSX5EJtoB82p9Z4mEhd3EMlw5CwXDHvZYyOm3oOsqTpNPzrM6 HkMw1kgnZNuh1rvIuohSys0LpqaqtZHg9BWit5nd5CAudZQn+di2akQ0PiJJJmprY9CZ /rOE5d5wm3mr92ELVndXIYtwiZZosTKP/BPfgDIzDOEtBLzmZ5DOfONTSTJ0Wv4DDLNP VwICOJhEB80yU4v//HxBow/bhvpKMYumHDjW/enuRoHA58aMHJbuFLgC1/43g4YON26H giyw== X-Gm-Message-State: AOJu0Yz+izIS3bIAct97bNE44xd7VSJp22nmKaX1621zF+yjlTmjqQmQ nQCx7V6UEqk9TYCUYY5ilfcKNPBot+0JwanZIV3nYKIqMmicNcO3R3a+GbXpvvbkMoB7eQn5myz C X-Received: by 2002:a17:903:40c9:b0:1e7:d482:9d96 with SMTP id t9-20020a17090340c900b001e7d4829d96mr3120107pld.10.1714574264387; Wed, 01 May 2024 07:37:44 -0700 (PDT) Received: from stoup.. (174-21-72-5.tukw.qwest.net. [174.21.72.5]) by smtp.gmail.com with ESMTPSA id h12-20020a170902f54c00b001ebd73f61fcsm5751573plf.121.2024.05.01.07.37.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 May 2024 07:37:44 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Alex_Benn=C3=A9e?= Subject: [PULL 03/20] plugins: Zero new qemu_plugin_dyn_cb entries Date: Wed, 1 May 2024 07:37:22 -0700 Message-Id: <20240501143739.10541-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240501143739.10541-1-richard.henderson@linaro.org> References: <20240501143739.10541-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62d; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62d.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 May 1 14:37: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: 793725 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:54f:b0:34d:5089:5a9e with SMTP id b15csp790888wrf; Wed, 1 May 2024 07:39:49 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWu2Fgfw7CUeR8ABzhH3t0FVYL/LTFJku1gRwUWouvI1uZf04xGXJF43crkc4eXNrEu/qa7delCEpejAnZz3hpn X-Google-Smtp-Source: AGHT+IFiv3UJveoUIly8bHjI4Y8F86+crzlH9UJFllUO5SdfUzVwQxxjHhHRWslBykZHV4vRhNDx X-Received: by 2002:a05:622a:491:b0:43a:5f5e:c10b with SMTP id p17-20020a05622a049100b0043a5f5ec10bmr5011261qtx.20.1714574389508; Wed, 01 May 2024 07:39:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1714574389; cv=none; d=google.com; s=arc-20160816; b=Jdoqf3xS2hYN0hyWRoGkxg2s7tQPPGV9tk/0LtTpDb2Agl16wtPfo8yCzGEHzJsdjA 7jzKaq1x9QmDTivg6GZ56RH/ZXjEJqRl3ihHOXulPEt9hAeu53uPmJdSohz1K5Rkyw1S 4fIYeXrt1X/jboK1voyuhduqO0nvUPl42hQujf7CXUhfP4k2RcKeBFLcQGpQ8cVlssIx 1qYxS+dxJjwfg4Go/v1WGnspnyL9ftOVqu6301z5RhZ6t8pbkDitBKLusAvg0WGtwnef g0QeigDtUCRJ+7aXPeVCEgexS8wD/bLHBD7M5NgSZPac1sJpu6iFv/NX1mkqd/lPUtWD KsDg== 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=/mvFgQ07uq/6Zxz3YFl1o78VrbR/mo0c+cULSy+Rk10=; fh=D6FqPLU6GE0ldmgADbJ5dLNMSeh7MbgWcAv41ubRnOE=; b=NNIbcvKzAO7RlMBmsF0jaxBSyhaZRnEu66ky2P21C+U0vtXQWLLHGnYl0DsbIDkClL BEud+fVaL1/ktBy0Ts9BKKnfYsF+bIRw10Vz2eWtnbzyDRHirA66crqTdMXrZ2Ll6s4f cAi6SSaZA8bDA/Oom0FeHICi9SnH/CtXHAwQbB2klfvg1FItVDElcpWzrQ2OxYMvtAiK vZPKjz752TFyfZYHXbkLpAPHYcoiPjgsdlY2P2DtqwvDY+I8tJhahOZC9oShrC1X5T+u 4w2w/aANIiUwrhqW34ERTTZqvFJnWsWwnvsWfwdnCN5X36v+VExLDqfvub8ZVNFMBUW8 HbYQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=EwjoVwFS; 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 v14-20020ac8578e000000b0043c6e1b2a84si2752481qta.292.2024.05.01.07.39.49 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 01 May 2024 07:39:49 -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=EwjoVwFS; 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 1s2B5v-0002io-HW; Wed, 01 May 2024 10:38:03 -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 1s2B5h-0002fC-Lv for qemu-devel@nongnu.org; Wed, 01 May 2024 10:37:50 -0400 Received: from mail-pl1-x635.google.com ([2607:f8b0:4864:20::635]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s2B5f-00027D-Oz for qemu-devel@nongnu.org; Wed, 01 May 2024 10:37:49 -0400 Received: by mail-pl1-x635.google.com with SMTP id d9443c01a7336-1e3ff14f249so6734715ad.1 for ; Wed, 01 May 2024 07:37:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1714574265; x=1715179065; 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=/mvFgQ07uq/6Zxz3YFl1o78VrbR/mo0c+cULSy+Rk10=; b=EwjoVwFSu9jfsHy+CqztVHWyH1ZeYYwbupbWBiWem9Mm+8WNhzhbRElgoeRCt12d2s 6Bor6Ed0j6Fgr4kGEF6ladCk437DCBO1VzRYAHXqKWhtSSJJoFOy4D224RcFKx9mTzKr zArymvBcSz2p8Bu0nmCLN0n67JbMsoFhT4xs3iZel9AR55fICfSAVp3IYZjn92k+Mefp Bh0I/cyVDNSWSeD/KZuAI5c6gXbW3YICOL4c9i7Fy2iNMnZnPuj0gkJtoaKK9qYINnyC JLzgxXLLELqEfrdbhNVv2h0Am+SF791y/gndnX2R7zQr6oGk9/NEC1d+NJlun4R+kScz AWlA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714574265; x=1715179065; 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=/mvFgQ07uq/6Zxz3YFl1o78VrbR/mo0c+cULSy+Rk10=; b=aKcBxJ9ZR+4Dr+KFLmAKN4RKYrIkWhX+gIkFNpwtHDiIt0KbXQiKJ7b66nrewe5FZO H63I+ErPO+NhwgEpig1W29RRzmqpQ1mXHwbrwCz2pLtK8JgD/AFWPfAiN/kpk92NVqje 7+Un2OzLjwZhWCfY4KX2w+D6scaP6+qlymsWGRiHZMDY6tI89t5FjuS5CkgSWhTktZlN 49Kue75zCF77WpQywneQ3fsLy74EW/rKUOYTp/eK1nYWrOV8NMfVPiqAAfNkeeTWyIa9 rmfWWLbf/eSSDLg4/szvdn/NuLxn/iPtW+as5FL/0C2LwlyFEboTte3EQXeaIa/0vCTv eg7Q== X-Gm-Message-State: AOJu0YwJPcTLMazZjiqFR9ZMNmOHHDmwpFvA+xfgilgdwmt5AmY+llbo 05D7uax0hMgyfGZUrchUzeJ3K5lsx2tQqVA+GZzAXeDkYmGnm0i7QGbu18LfBw9Qrj67iynSYXj p X-Received: by 2002:a17:903:1105:b0:1e2:58f:7ed4 with SMTP id n5-20020a170903110500b001e2058f7ed4mr4736772plh.5.1714574265288; Wed, 01 May 2024 07:37:45 -0700 (PDT) Received: from stoup.. (174-21-72-5.tukw.qwest.net. [174.21.72.5]) by smtp.gmail.com with ESMTPSA id h12-20020a170902f54c00b001ebd73f61fcsm5751573plf.121.2024.05.01.07.37.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 May 2024 07:37:44 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , =?utf-8?q?Philipp?= =?utf-8?q?e_Mathieu-Daud=C3=A9?= Subject: [PULL 04/20] plugins: Move function pointer in qemu_plugin_dyn_cb Date: Wed, 1 May 2024 07:37:23 -0700 Message-Id: <20240501143739.10541-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240501143739.10541-1-richard.henderson@linaro.org> References: <20240501143739.10541-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::635; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x635.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 Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- include/qemu/plugin.h | 4 +++- accel/tcg/plugin-gen.c | 4 ++-- plugins/core.c | 8 ++++---- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/include/qemu/plugin.h b/include/qemu/plugin.h index 41db748eda..5676ab5ef2 100644 --- a/include/qemu/plugin.h +++ b/include/qemu/plugin.h @@ -85,13 +85,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 May 1 14:37: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: 793730 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:54f:b0:34d:5089:5a9e with SMTP id b15csp791435wrf; Wed, 1 May 2024 07:41:05 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUCGJ7ISscM8VPQ18h1neeKVDvxxuzcwM8VoZrs1ugtBkYWErQYt8fjk1+niiVtoyYS5mwXdsHb28Vu2EKoNP3l X-Google-Smtp-Source: AGHT+IFBDydoO64Bqm67ZRSHjT+Zw7/LLtMQe55XUR76qu0s1JOQgGdd2AWsbJYe505rSY5vV5Z6 X-Received: by 2002:a5b:d09:0:b0:de6:fe6:68b4 with SMTP id y9-20020a5b0d09000000b00de60fe668b4mr2654467ybp.33.1714574465045; Wed, 01 May 2024 07:41:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1714574465; cv=none; d=google.com; s=arc-20160816; b=JUKhEmoetGEE/MKT/Bri/0GInO+DIdRD/1rmABDDxYhKPVD6ade5txMUrJjkhXs5tR oMv8LilXq2e7Rv8+mk2Fj4K+U8bwJPYtTQ1wDZC7S9ffV9lKeBuleiprW/50h/Opys9u j+09ofnB3a+hpGjyld8NTdk5H7PTO2N57THSLV29JcRufm2omED7yUawN2hIeyAuOOzM o0XRKI0NM+8Su6tkyixR62TWoKFQvO6K6HUsJ23eBCqjhT1rAUkHui8TbseN3w/2aUz4 ne4cS3Bl0WxEUZa5Rx5nNMMhuwO2HS1uFdAMSpKRz9C/KQt1eUVU+sHWEAV1l4k1NcuB Ju0w== 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=06SN57pqqKBY1c5MKLR3ZmhRP+7u+LpsRiqijEh2kh8=; fh=vm85eyWrvOAHduw3sqEA+cYBqvHB7M0MHFcRJg7VWOo=; b=YqeaafV59ti+merctT9eoNGRM26c78LsK82vJ6TY1Nqb7wbr4uLL1MG6DNi2qfWCUz YTMc8PKAuncmeJMDfPS+aimUn+b07YkZ7l1BY8UtliSGX7UZ/RchlFOchAcvkrhJZbv+ 1yuvPPJV/sWf8J59eJ4wa5JVWcTJrSL/yYFMT86VNueUiOpECIbuOmdupyKZoIFgR+Y2 hdSoBpoyKQR0MH3RW0S32dB/Bw6aYs8g8BcvEnCNFnpE5uNUlcfrSlXyZAwsRjxKBNdu 44WD6BlUQVc5hPYPPS9X5Tjzzq5aMXPn9///QmwgP4oGqGpH5yY03KePEuBdAJ8a+Hd9 8Cew==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=M49hcT2z; 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 ey12-20020a05622a4c0c00b0043a69c12b30si13940938qtb.344.2024.05.01.07.41.04 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 01 May 2024 07:41:05 -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=M49hcT2z; 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 1s2B5r-0002gx-03; Wed, 01 May 2024 10:37:59 -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 1s2B5h-0002fD-M2 for qemu-devel@nongnu.org; Wed, 01 May 2024 10:37:50 -0400 Received: from mail-pg1-x52e.google.com ([2607:f8b0:4864:20::52e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s2B5f-00027M-Og for qemu-devel@nongnu.org; Wed, 01 May 2024 10:37:49 -0400 Received: by mail-pg1-x52e.google.com with SMTP id 41be03b00d2f7-6001399f22bso4727218a12.0 for ; Wed, 01 May 2024 07:37:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1714574266; x=1715179066; 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=06SN57pqqKBY1c5MKLR3ZmhRP+7u+LpsRiqijEh2kh8=; b=M49hcT2zJ5et89r3aMjWgwr0yFGP8t6L+bCKHveNYR3nAUqbVCR9nSW2DtKR5XKKhQ kw+3uhKtFHDwXKLAESyKDtTwgh0VAaeWG77BGwCh/ALEhx8xJVrKJd0UD3FOykUOhvTW isV1o5alTQCxPvDViOcX64mRvosZdshkFTUqNvphE4Gs3RddWf2mn31Jfmi8YsRBBP8Z HRIFRJ/aJh8HM7FCU473FujwydmJvuzWZHy3DidWAPV53Kgbn6fudrJJJ3JQk+6pCQKq M3IfvYrTngkWnKU0jFcVNUR6sKjmC9q4kmNxbIdqLOU2EojRoUmYyDmiW24qVWW8jpUS eN+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714574266; x=1715179066; 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=06SN57pqqKBY1c5MKLR3ZmhRP+7u+LpsRiqijEh2kh8=; b=fOs/jIPPoln+Luz9TN+2yNWnFAu3vyr9TJeicXPnHyO4xajn9Us6/zL3NOj9f4evyQ ebuvhDC0SWPcGYCG6XPwcg9sdI0JFNaqR10fiw2Ie9ghxCGauBH5PcOgOwilVMZ3SjW+ URLKMmsDiJ5TZqZNHCJOJW9D9Y1Dn3hSguzVj66Jcue/HTp0LwDtE7ra0CYEPSWk3jua 8E7aktTAz2nsD2ok/rAOWxtymHnQge87TS084N6V7cNnfjcVyY/PL7ihX9B289Fvhl8l XYXkKo8pBNVYR88Xbm/RE39vscYHpZ5Glo0q+KvXGGF6wqCQhExGEQbFT7gun/z62YHh tw1Q== X-Gm-Message-State: AOJu0Ywow2HO28DnBXXD1Kkpsma7a1UqkE1g2X8C7BarK/Lou8q1YvC3 q+fidx/7uxbZH5l3Vi1PJZfk7wGp16aJTw5S16UiwcnhI7BuQ551WgDh2QkOAMQ073QOMjt1rAM 6 X-Received: by 2002:a17:903:244d:b0:1eb:4950:554f with SMTP id l13-20020a170903244d00b001eb4950554fmr3360916pls.22.1714574266222; Wed, 01 May 2024 07:37:46 -0700 (PDT) Received: from stoup.. (174-21-72-5.tukw.qwest.net. [174.21.72.5]) by smtp.gmail.com with ESMTPSA id h12-20020a170902f54c00b001ebd73f61fcsm5751573plf.121.2024.05.01.07.37.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 May 2024 07:37:45 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Pierrick Bouvier Subject: [PULL 05/20] plugins: Create TCGHelperInfo for all out-of-line callbacks Date: Wed, 1 May 2024 07:37:24 -0700 Message-Id: <20240501143739.10541-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240501143739.10541-1-richard.henderson@linaro.org> References: <20240501143739.10541-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::52e; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x52e.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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 5676ab5ef2..d0d830bfc0 100644 --- a/include/qemu/plugin.h +++ b/include/qemu/plugin.h @@ -93,6 +93,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 May 1 14:37:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 793729 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:54f:b0:34d:5089:5a9e with SMTP id b15csp791287wrf; Wed, 1 May 2024 07:40:40 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWiLM3J2dGHfsrCQ2hLZP9DdXd+T79XVmsD/MkFfKG43kvBPZ+kKrd95kHgSvZ4XupFOTV71rPDjkcA0M9kQt3i X-Google-Smtp-Source: AGHT+IEBt5H/sheIZpCzYvYI/JsbHxg/C5/2ol3oy14exuTWl4CfQz5CsZAUncqDPfE+nDpS7BCg X-Received: by 2002:a05:622a:2299:b0:437:bedb:3ff with SMTP id ay25-20020a05622a229900b00437bedb03ffmr9884544qtb.27.1714574440396; Wed, 01 May 2024 07:40:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1714574440; cv=none; d=google.com; s=arc-20160816; b=Yu9e1D6N4XVAYs1IxE8EE/2RFx7gjqx9n+r58hxkZ/T7i7i4VRljU0I+YA5R0kyCU1 LXS3sPvhWpM/3PS5pVLb19U+jgIz3CG0TqqBWa36LjgULUnNtAl1BEggH+r/jzOomARJ DAqXJBu7se1YrLr41cuz4t3GFPi1JOEYOgYyVeuwoNZVzuygApF9j1YgtjGzEHyjrFRT kuZxEgyanIVrrgp3t+O0DYLoXb7f3vb/mUFjEAQ1pO6jZ6ZTuA6EclbpaZvuPEt3vhR3 0BddQfcggPZ9agCFEfBf4UxBRa8/O5bW+5IWCPu0o3GpfTUpzxUGdqCGSYZr2BApo9Ws w+Mg== 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=I+chihv+aCHSo8sD0JFlhAbGFbkZ1HxgertwSMQKsZo=; fh=vm85eyWrvOAHduw3sqEA+cYBqvHB7M0MHFcRJg7VWOo=; b=gJQrnk3KAdCKhxWGlvhOJL8BVHzH/U9dDdVCWCHQJeKs5+y1JZ0dHefrlSaZezQZPa TUj7bfqywePlRkVG9yjkI20frOvDyf7ckD6r+PSTFaO8+qcGTJLtOoexFj7SRIQDt6dY 99LgwJdxTsnyLoZo70q6WQt1XiSDxnRtdqL0OlzK0qxCLQiPebbsLUAZSl82uxdVoa4a 6l1kl1EPx1Wik36ZMgRqQ+/Xy2pCOA11Yw98rYst59mrSAJQLC3Piyy40N2a+hlWB8u+ Wm/9zIQpPEuwiVfAvtpB6zIeSQ5jE0jOH6ugvwy0DM/rIbXoHQa2XX9DhQ4ER1Ok/FR2 tt/A==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dUw5Gb0R; 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 er13-20020a05622a5e8d00b004313889961dsi27557240qtb.557.2024.05.01.07.40.40 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 01 May 2024 07:40:40 -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=dUw5Gb0R; 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 1s2B6G-0002rQ-42; Wed, 01 May 2024 10:38:24 -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 1s2B5i-0002fl-Fs for qemu-devel@nongnu.org; Wed, 01 May 2024 10:37:53 -0400 Received: from mail-pl1-x62f.google.com ([2607:f8b0:4864:20::62f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s2B5g-00027c-G6 for qemu-devel@nongnu.org; Wed, 01 May 2024 10:37:50 -0400 Received: by mail-pl1-x62f.google.com with SMTP id d9443c01a7336-1ec85c2f469so6239705ad.1 for ; Wed, 01 May 2024 07:37:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1714574267; x=1715179067; 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=I+chihv+aCHSo8sD0JFlhAbGFbkZ1HxgertwSMQKsZo=; b=dUw5Gb0RKNUbheHth2F8cKp984zPnnAWTEsgMGpW70DXZVp0Xs9gKaNVIbF0G5iIjg pvuKKxOm+17ZNFI0TXFsNPo3Bi6yV5D+oeHM6qW5CZ5PBxtTHjO7GcvnmRMQlYlno5/A 4m6VYnZjHqqs8ma6nni8ufSpCmk/RWruGkH7++xO9cbBxXtry/RIQ9A8pPxH3crj+F9W Zhq0gcx7b1BwxYN6RL60cmHz1Ey5X79liHxZhUL4i9FBa6/FByh3t9JiIuYAY7uMUNsW VrS4Cjuni8WKj96d8mnXWdO/F2YfXUJot9OwY/nnj1JIyFZ2wxZyRUVGCXcxtSpgrVXE +Gaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714574267; x=1715179067; 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=I+chihv+aCHSo8sD0JFlhAbGFbkZ1HxgertwSMQKsZo=; b=QYITX83F43mb5TdSidjrtDZ7OoIDz3VmEajWXCNedBET2YOovnihm2MfH+yLgVvlXA RrTnXB5VomkCb4B2x6iKZfJRSze83ePRw9xZx80GVft7ia3Q3sSiivWijX0M8foyRhJg bYpqFH235bZO1GvzCSRCHqH7MkMV5Az/YhWwcFPM58ZqLNSPx7z6vz+7kxxHH1kFd/+B bwIgneuwuW3Z9WBj69UcCvPlLrZtQyKJYkTa0/a7lM2X4bVF0q6lGK23OUTjTSZDo1H4 g+CfOY/qL6WmZDH44VJIYZ0kyGRvqNBcsJMV3N2f4fTbj5qeByI1dsgi9n9nj516DrMQ r44g== X-Gm-Message-State: AOJu0YxB4LFNWDrOgHBZdv9FgEKOvdxCW+HeGM7oYAfiSo6OC+j2UyQm bT4lB1eNDvfldBDwDthtczGSEd0eB34H/Vp6QzIMtPKm9PBtJCQ00suSXKiT3ykP3Oz8NfVAz3v W X-Received: by 2002:a17:902:8b89:b0:1e4:733c:eac8 with SMTP id ay9-20020a1709028b8900b001e4733ceac8mr3709168plb.8.1714574267276; Wed, 01 May 2024 07:37:47 -0700 (PDT) Received: from stoup.. (174-21-72-5.tukw.qwest.net. [174.21.72.5]) by smtp.gmail.com with ESMTPSA id h12-20020a170902f54c00b001ebd73f61fcsm5751573plf.121.2024.05.01.07.37.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 May 2024 07:37:46 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Pierrick Bouvier Subject: [PULL 06/20] plugins: Use emit_before_op for PLUGIN_GEN_AFTER_INSN Date: Wed, 1 May 2024 07:37:25 -0700 Message-Id: <20240501143739.10541-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240501143739.10541-1-richard.henderson@linaro.org> References: <20240501143739.10541-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62f; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62f.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. Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- include/tcg/tcg-op-common.h | 1 + include/tcg/tcg-opc.h | 1 + accel/tcg/plugin-gen.c | 74 +++++++++++++++++++++---------------- tcg/tcg-op.c | 5 +++ 4 files changed, 50 insertions(+), 31 deletions(-) diff --git a/include/tcg/tcg-op-common.h b/include/tcg/tcg-op-common.h index 2d932a515e..9de5a7f280 100644 --- a/include/tcg/tcg-op-common.h +++ b/include/tcg/tcg-op-common.h @@ -74,6 +74,7 @@ void tcg_gen_goto_tb(unsigned idx); */ void tcg_gen_lookup_and_goto_ptr(void); +void tcg_gen_plugin_cb(unsigned from); void tcg_gen_plugin_cb_start(unsigned from, unsigned type, unsigned wr); void tcg_gen_plugin_cb_end(void); diff --git a/include/tcg/tcg-opc.h b/include/tcg/tcg-opc.h index b80227fa1c..3b7cb2bce1 100644 --- a/include/tcg/tcg-opc.h +++ b/include/tcg/tcg-opc.h @@ -197,6 +197,7 @@ DEF(exit_tb, 0, 0, 1, TCG_OPF_BB_EXIT | TCG_OPF_BB_END) DEF(goto_tb, 0, 0, 1, TCG_OPF_BB_EXIT | TCG_OPF_BB_END) DEF(goto_ptr, 0, 1, 0, TCG_OPF_BB_EXIT | TCG_OPF_BB_END) +DEF(plugin_cb, 0, 0, 1, TCG_OPF_NOT_PRESENT) DEF(plugin_cb_start, 0, 0, 3, TCG_OPF_NOT_PRESENT) DEF(plugin_cb_end, 0, 0, 0, TCG_OPF_NOT_PRESENT) diff --git a/accel/tcg/plugin-gen.c b/accel/tcg/plugin-gen.c index 4b488943ff..4b02c0bfbf 100644 --- a/accel/tcg/plugin-gen.c +++ b/accel/tcg/plugin-gen.c @@ -201,8 +201,7 @@ static void plugin_gen_empty_callback(enum plugin_gen_from from) { switch (from) { case PLUGIN_GEN_AFTER_INSN: - gen_wrapped(from, PLUGIN_GEN_DISABLE_MEM_HELPER, - gen_empty_mem_helper); + tcg_gen_plugin_cb(from); break; case PLUGIN_GEN_FROM_INSN: /* @@ -608,16 +607,6 @@ static void inject_mem_enable_helper(struct qemu_plugin_tb *ptb, inject_mem_helper(begin_op, arr); } -static void inject_mem_disable_helper(struct qemu_plugin_insn *plugin_insn, - TCGOp *begin_op) -{ - if (likely(!plugin_insn->mem_helper)) { - rm_ops(begin_op); - return; - } - inject_mem_helper(begin_op, NULL); -} - /* called before finishing a TB with exit_tb, goto_tb or goto_ptr */ void plugin_gen_disable_mem_helpers(void) { @@ -703,11 +692,14 @@ static void plugin_gen_enable_mem_helper(struct qemu_plugin_tb *ptb, inject_mem_enable_helper(ptb, insn, begin_op); } -static void plugin_gen_disable_mem_helper(struct qemu_plugin_tb *ptb, - TCGOp *begin_op, int insn_idx) +static void gen_disable_mem_helper(struct qemu_plugin_tb *ptb, + struct qemu_plugin_insn *insn) { - struct qemu_plugin_insn *insn = g_ptr_array_index(ptb->insns, insn_idx); - inject_mem_disable_helper(insn, begin_op); + if (insn->mem_helper) { + tcg_gen_st_ptr(tcg_constant_ptr(0), tcg_env, + offsetof(CPUState, plugin_mem_cbs) - + offsetof(ArchCPU, env)); + } } /* #define DEBUG_PLUGIN_GEN_OPS */ @@ -766,16 +758,49 @@ static void pr_ops(void) static void plugin_gen_inject(struct qemu_plugin_tb *plugin_tb) { - TCGOp *op; + TCGOp *op, *next; int insn_idx = -1; pr_ops(); - QTAILQ_FOREACH(op, &tcg_ctx->ops, link) { + /* + * While injecting code, we cannot afford to reuse any ebb temps + * that might be live within the existing opcode stream. + * The simplest solution is to release them all and create new. + */ + memset(tcg_ctx->free_temps, 0, sizeof(tcg_ctx->free_temps)); + + QTAILQ_FOREACH_SAFE(op, &tcg_ctx->ops, link, next) { switch (op->opc) { case INDEX_op_insn_start: insn_idx++; break; + + case INDEX_op_plugin_cb: + { + enum plugin_gen_from from = op->args[0]; + struct qemu_plugin_insn *insn = NULL; + + if (insn_idx >= 0) { + insn = g_ptr_array_index(plugin_tb->insns, insn_idx); + } + + tcg_ctx->emit_before_op = op; + + switch (from) { + case PLUGIN_GEN_AFTER_INSN: + assert(insn != NULL); + gen_disable_mem_helper(plugin_tb, insn); + break; + default: + g_assert_not_reached(); + } + + tcg_ctx->emit_before_op = NULL; + tcg_op_remove(tcg_ctx, op); + break; + } + case INDEX_op_plugin_cb_start: { enum plugin_gen_from from = op->args[0]; @@ -840,19 +865,6 @@ static void plugin_gen_inject(struct qemu_plugin_tb *plugin_tb) break; } - case PLUGIN_GEN_AFTER_INSN: - { - g_assert(insn_idx >= 0); - - switch (type) { - case PLUGIN_GEN_DISABLE_MEM_HELPER: - plugin_gen_disable_mem_helper(plugin_tb, op, insn_idx); - break; - default: - g_assert_not_reached(); - } - break; - } default: g_assert_not_reached(); } diff --git a/tcg/tcg-op.c b/tcg/tcg-op.c index aa6bc6f57d..0f2026c91c 100644 --- a/tcg/tcg-op.c +++ b/tcg/tcg-op.c @@ -312,6 +312,11 @@ void tcg_gen_mb(TCGBar mb_type) } } +void tcg_gen_plugin_cb(unsigned from) +{ + tcg_gen_op1(INDEX_op_plugin_cb, from); +} + void tcg_gen_plugin_cb_start(unsigned from, unsigned type, unsigned wr) { tcg_gen_op3(INDEX_op_plugin_cb_start, from, type, wr); From patchwork Wed May 1 14:37:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 793714 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:54f:b0:34d:5089:5a9e with SMTP id b15csp790417wrf; Wed, 1 May 2024 07:38:42 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUhCJ+AbMZ71ZsHfuwJADaAPjKKkILAOLUSz+o8dpvjuDHT/os3NVlG23dqTjtTOLpuEXkGcA74X5VneQRpDRF2 X-Google-Smtp-Source: AGHT+IHxf7t4LqPWkfxqbDxN69BOBFeuT/3lMqLaBFN2YGJh63E+q9dehMcvJjR6aCjoIRdrIUSQ X-Received: by 2002:ac8:5fd3:0:b0:43a:e61a:ddc7 with SMTP id k19-20020ac85fd3000000b0043ae61addc7mr2836012qta.44.1714574322090; Wed, 01 May 2024 07:38:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1714574322; cv=none; d=google.com; s=arc-20160816; b=NsndR5gZaWC01kk6v4jQv8SWeqQJQb3AoLJ1HicsEewt6UnyOOO1aAqX2Fjvl6CLbr fjKsW0LkVi4bSvHGjgFYDUX5J7a2H2Ae3fpfGmoBuyIYiUemsXYceR9YemLSRYoo2VNb FW8xm9NK9h3lbcRHRWzBMXSvL0btwCD+XXdVWdWO3x9w90lnhlfvlbp5Un4Ir30/+5AW FMf6IniIgUZce5JEfNkebQkls3SXXVs3LbLc2iHyvjB9zTFQLq5RKbA/6mz/igl+iYAp xTaaKRf0DXmsVdzXFxrtDMq/HluqEdN2dapELrKEX5BFDIQnpn7URXl4E9M/aiwKTzjq /DuA== 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=RmGbooE7MMw6U3zKUesAFTGouJdUS0zDOY8tro2IA3U=; fh=vm85eyWrvOAHduw3sqEA+cYBqvHB7M0MHFcRJg7VWOo=; b=HI2ixEbFpYYSgYUl55USJazLh8qwGb9xkNhYzLFP8qudpdl9V+RtwMol9dk8gQnkDC /cjYYpSC1997U2Q8+Ph0h4IgQ0MaCntMiUX0k8JlGUXh/N5vjT18ZrS36RWPkX3waTem uv18q6Z8atx29O2dfaSl4c9UKRgfIVSFq3MtaHENpgYBA0++r/Qrd8KxXqR22N5T323q hrj3MSBjm2nLyH1wWL+4NJKr/21FZgKIcVW+4eKYbHJpK1dC/6LtoxQlr7WL1PNCBxsL e4xqSfVlI3AXJWwIs5josaSh/9d3kCL7KkfaWISAuYwVRyW8a7O8eUrBXHFiXWeH12mB zCvw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HuFebopb; 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 o18-20020ac87c52000000b0043b024830f5si6140166qtv.341.2024.05.01.07.38.41 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 01 May 2024 07:38:42 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HuFebopb; 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 1s2B5q-0002gv-W4; Wed, 01 May 2024 10:37:59 -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 1s2B5k-0002fu-8l for qemu-devel@nongnu.org; Wed, 01 May 2024 10:37:53 -0400 Received: from mail-pl1-x632.google.com ([2607:f8b0:4864:20::632]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s2B5h-000281-Jc for qemu-devel@nongnu.org; Wed, 01 May 2024 10:37:51 -0400 Received: by mail-pl1-x632.google.com with SMTP id d9443c01a7336-1ec4b2400b6so15850345ad.3 for ; Wed, 01 May 2024 07:37:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1714574268; x=1715179068; 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=RmGbooE7MMw6U3zKUesAFTGouJdUS0zDOY8tro2IA3U=; b=HuFebopbOYN2vvIkfMQ/vFyBsvayuSNRXbP/Df0Dy8GxXMfFdcCJw+6WX17iRLPNEH JVBp09WfpiJ1tKuPiasT1d0zvO+JvBGM+WX7sS6I/zyn3T2cB8GoRcr4tptBk1Sce9IO whDwJIPi4mwoPTf03NZY/Vzmy9iHbma9m/l+x4rXCat1e4uWJdFKYa2vWVhyqgmk6Wn+ 865zWKsqkOeOg8Kd9wAAQmu8Z28j3eouuhkZ+k227H6NSDdIN6aWy2LZDgDbDp0KhoyX 0p5zTbMiy4h5w0WSgHEkfhk5eu3qQZoSN8lcYHUKzlqT0fqC+vRUVv31dWkeIrOMHwL2 GUQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714574268; x=1715179068; 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=RmGbooE7MMw6U3zKUesAFTGouJdUS0zDOY8tro2IA3U=; b=VDQTBz14PBQJ9fgkrDsYp/srVhN0iqJ/oOL31kpVECQgP1jUQNi2mE79s5Es2O1wM9 iCBduH8qdFge+q5lJiXtTtmQN0KcN1qc4mDmc+hUHcJ8Ej3KRQFZVFEiKw0g5iUD21fo UgWrsQqGo6uoW0wLrJDL0CCJqHye/Y+k/wDxl6qlR6CDaHw3Qxe50d9q8sQRuRN+qF5B l0lGgHSQARFBOy/I7wX6eeYkZn7kEDWZUnn0R/fW16Mz2lZOMzvcMwir8ORA+9uMWSMk 3/64qxMVPqXagFPI+KL3oHDP3PC626RS6wyzX00BWl5MB0l+k0IvxvtHh50HTzle2l9r Mq7A== X-Gm-Message-State: AOJu0YwRDC6KT8NT8AtZaaBhj/Y2mEM8aeF+rP+MK8zlnPnDm66+2/xI 6p0lGeKS4vH+Ho89XX6fOGEk/7P/5CDnYRcfAbNwcxvX9ftECrbajAtASECDDWMaFvBl5ldPAo+ D X-Received: by 2002:a17:902:dac7:b0:1eb:527e:a8ad with SMTP id q7-20020a170902dac700b001eb527ea8admr3075691plx.51.1714574268186; Wed, 01 May 2024 07:37:48 -0700 (PDT) Received: from stoup.. (174-21-72-5.tukw.qwest.net. [174.21.72.5]) by smtp.gmail.com with ESMTPSA id h12-20020a170902f54c00b001ebd73f61fcsm5751573plf.121.2024.05.01.07.37.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 May 2024 07:37:47 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Pierrick Bouvier Subject: [PULL 07/20] plugins: Use emit_before_op for PLUGIN_GEN_FROM_TB Date: Wed, 1 May 2024 07:37:26 -0700 Message-Id: <20240501143739.10541-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240501143739.10541-1-richard.henderson@linaro.org> References: <20240501143739.10541-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::632; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x632.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. Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- accel/tcg/plugin-gen.c | 96 +++++++++++++++++++++++++----------------- plugins/api.c | 6 +-- 2 files changed, 58 insertions(+), 44 deletions(-) diff --git a/accel/tcg/plugin-gen.c b/accel/tcg/plugin-gen.c index 4b02c0bfbf..c803fe8e96 100644 --- a/accel/tcg/plugin-gen.c +++ b/accel/tcg/plugin-gen.c @@ -201,6 +201,7 @@ static void plugin_gen_empty_callback(enum plugin_gen_from from) { switch (from) { case PLUGIN_GEN_AFTER_INSN: + case PLUGIN_GEN_FROM_TB: tcg_gen_plugin_cb(from); break; case PLUGIN_GEN_FROM_INSN: @@ -210,8 +211,6 @@ static void plugin_gen_empty_callback(enum plugin_gen_from from) */ gen_wrapped(from, PLUGIN_GEN_ENABLE_MEM_HELPER, gen_empty_mem_helper); - /* fall through */ - case PLUGIN_GEN_FROM_TB: gen_wrapped(from, PLUGIN_GEN_CB_UDATA, gen_empty_udata_cb_no_rwg); gen_wrapped(from, PLUGIN_GEN_CB_UDATA_R, gen_empty_udata_cb_no_wg); gen_wrapped(from, PLUGIN_GEN_CB_INLINE, gen_empty_inline_cb); @@ -626,24 +625,6 @@ void plugin_gen_disable_mem_helpers(void) offsetof(CPUState, plugin_mem_cbs) - offsetof(ArchCPU, env)); } -static void plugin_gen_tb_udata(const struct qemu_plugin_tb *ptb, - TCGOp *begin_op) -{ - inject_udata_cb(ptb->cbs[PLUGIN_CB_REGULAR], begin_op); -} - -static void plugin_gen_tb_udata_r(const struct qemu_plugin_tb *ptb, - TCGOp *begin_op) -{ - inject_udata_cb(ptb->cbs[PLUGIN_CB_REGULAR_R], begin_op); -} - -static void plugin_gen_tb_inline(const struct qemu_plugin_tb *ptb, - TCGOp *begin_op) -{ - inject_inline_cb(ptb->cbs[PLUGIN_CB_INLINE], begin_op, op_ok); -} - static void plugin_gen_insn_udata(const struct qemu_plugin_tb *ptb, TCGOp *begin_op, int insn_idx) { @@ -702,6 +683,41 @@ static void gen_disable_mem_helper(struct qemu_plugin_tb *ptb, } } +static void gen_udata_cb(struct qemu_plugin_dyn_cb *cb) +{ + TCGv_i32 cpu_index = tcg_temp_ebb_new_i32(); + + tcg_gen_ld_i32(cpu_index, tcg_env, + -offsetof(ArchCPU, env) + offsetof(CPUState, cpu_index)); + tcg_gen_call2(cb->regular.f.vcpu_udata, cb->regular.info, NULL, + tcgv_i32_temp(cpu_index), + tcgv_ptr_temp(tcg_constant_ptr(cb->userp))); + tcg_temp_free_i32(cpu_index); +} + +static void gen_inline_cb(struct qemu_plugin_dyn_cb *cb) +{ + GArray *arr = cb->inline_insn.entry.score->data; + size_t offset = cb->inline_insn.entry.offset; + TCGv_i32 cpu_index = tcg_temp_ebb_new_i32(); + TCGv_i64 val = tcg_temp_ebb_new_i64(); + TCGv_ptr ptr = tcg_temp_ebb_new_ptr(); + + tcg_gen_ld_i32(cpu_index, tcg_env, + -offsetof(ArchCPU, env) + offsetof(CPUState, cpu_index)); + tcg_gen_muli_i32(cpu_index, cpu_index, g_array_get_element_size(arr)); + tcg_gen_ext_i32_ptr(ptr, cpu_index); + tcg_temp_free_i32(cpu_index); + + tcg_gen_addi_ptr(ptr, ptr, (intptr_t)arr->data); + tcg_gen_ld_i64(val, ptr, offset); + tcg_gen_addi_i64(val, val, cb->inline_insn.imm); + tcg_gen_st_i64(val, ptr, offset); + + tcg_temp_free_i64(val); + tcg_temp_free_ptr(ptr); +} + /* #define DEBUG_PLUGIN_GEN_OPS */ static void pr_ops(void) { @@ -780,6 +796,8 @@ static void plugin_gen_inject(struct qemu_plugin_tb *plugin_tb) { enum plugin_gen_from from = op->args[0]; struct qemu_plugin_insn *insn = NULL; + const GArray *cbs; + int i, n; if (insn_idx >= 0) { insn = g_ptr_array_index(plugin_tb->insns, insn_idx); @@ -792,6 +810,25 @@ static void plugin_gen_inject(struct qemu_plugin_tb *plugin_tb) assert(insn != NULL); gen_disable_mem_helper(plugin_tb, insn); break; + + case PLUGIN_GEN_FROM_TB: + assert(insn == NULL); + + cbs = plugin_tb->cbs[PLUGIN_CB_REGULAR]; + for (i = 0, n = (cbs ? cbs->len : 0); i < n; i++) { + struct qemu_plugin_dyn_cb *cb = + &g_array_index(cbs, struct qemu_plugin_dyn_cb, i); + gen_udata_cb(cb); + } + + cbs = plugin_tb->cbs[PLUGIN_CB_INLINE]; + for (i = 0, n = (cbs ? cbs->len : 0); i < n; i++) { + struct qemu_plugin_dyn_cb *cb = + &g_array_index(cbs, struct qemu_plugin_dyn_cb, i); + gen_inline_cb(cb); + } + break; + default: g_assert_not_reached(); } @@ -807,25 +844,6 @@ static void plugin_gen_inject(struct qemu_plugin_tb *plugin_tb) enum plugin_gen_cb type = op->args[1]; switch (from) { - case PLUGIN_GEN_FROM_TB: - { - g_assert(insn_idx == -1); - - switch (type) { - case PLUGIN_GEN_CB_UDATA: - plugin_gen_tb_udata(plugin_tb, op); - break; - case PLUGIN_GEN_CB_UDATA_R: - plugin_gen_tb_udata_r(plugin_tb, op); - break; - case PLUGIN_GEN_CB_INLINE: - plugin_gen_tb_inline(plugin_tb, op); - break; - default: - g_assert_not_reached(); - } - break; - } case PLUGIN_GEN_FROM_INSN: { g_assert(insn_idx >= 0); diff --git a/plugins/api.c b/plugins/api.c index 8fa5a600ac..5d119e8049 100644 --- a/plugins/api.c +++ b/plugins/api.c @@ -92,11 +92,7 @@ void qemu_plugin_register_vcpu_tb_exec_cb(struct qemu_plugin_tb *tb, void *udata) { if (!tb->mem_only) { - int index = flags == QEMU_PLUGIN_CB_R_REGS || - flags == QEMU_PLUGIN_CB_RW_REGS ? - PLUGIN_CB_REGULAR_R : PLUGIN_CB_REGULAR; - - plugin_register_dyn_cb__udata(&tb->cbs[index], + plugin_register_dyn_cb__udata(&tb->cbs[PLUGIN_CB_REGULAR], cb, flags, udata); } } From patchwork Wed May 1 14:37:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 793717 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:54f:b0:34d:5089:5a9e with SMTP id b15csp790558wrf; Wed, 1 May 2024 07:39:00 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCX8wBBTVt0LZBRLpMxXAAIhbS0sowy74nUwPB2kU21TIvFXwxnr4J912H/4TsdS7YELc7Bs60n9oPTf77N/fgah X-Google-Smtp-Source: AGHT+IHgaj7gSOwqtQEYlh037SfZZkwdTj+6M/v2G6VQY/77D/1ZsF96kBOhd8gcBwEuizbru992 X-Received: by 2002:a05:6214:23ca:b0:6a0:7df4:90b8 with SMTP id hr10-20020a05621423ca00b006a07df490b8mr1927680qvb.35.1714574339918; Wed, 01 May 2024 07:38:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1714574339; cv=none; d=google.com; s=arc-20160816; b=ncVuufYjGXH9TBzN/qRo7AeN+n+6Tq/QCjRh6MKZpaxNjLJWgJskC9O3HswpugwpsM /R7bAi+enVXVUMBu1ZYucJIrkZhJcyhgpm9Qfapi1r1fV1qGYH3wkWHD9k/E1vdaP1yG 5vwxSp9Kg7sw55q5FVzsKk1W2zQ3KoUQpXSQn1AyWLO6juipittO8CMm2hq14OEzAMMb 1JrX273Pmvp6E5qayK27nK8j0Lbh4DGXpmpmKQFOlepyMpkf3663cOZr2JbAfXO4jaQB f4dHDtDCWNYIdQ8QUYO9e3mulIx3M3+fwtGtAkuxeh91bHo+CQ/TFWpz285Xh67xtjMw HoEA== 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=LFBHKbfIw86sLSqmp+tY4EU35vlSG5FIWnRvQETF3JHQd4o2eTrSzIIxaetHEvNzRY FfXc4lG0xaflsJQoJgdSvmMCB0bozr4+uw7ygfCnwss39Jfp/VfySpICiVlXvT4dERCK 1BTFCwBrWghf+RygZJhM01dG1cqI6moN00atnwrk4dLZKaBfzrxxvrrX9eb1zSKdKCgx aW2Ya193k4k3w9rma5KqVuH2p+UdPScB90em7Lu/YD5ZIpv8K8yqvAHdB226o4Myz1Ct Ri1kv7K9cx6Drm1cJrrnfoYCFsw46qBbznSV/ouiV6VR0soAdpH4/mwbnwgkFa2tDgon PIFw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="MMLs/dbe"; 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 if14-20020a0562141c4e00b006a0d1f42532si6550776qvb.558.2024.05.01.07.38.59 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 01 May 2024 07:38:59 -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="MMLs/dbe"; 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 1s2B6B-0002kY-1o; Wed, 01 May 2024 10:38:19 -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 1s2B5k-0002fv-Fb for qemu-devel@nongnu.org; Wed, 01 May 2024 10:37:53 -0400 Received: from mail-pl1-x636.google.com ([2607:f8b0:4864:20::636]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s2B5i-00028Q-RS for qemu-devel@nongnu.org; Wed, 01 May 2024 10:37:52 -0400 Received: by mail-pl1-x636.google.com with SMTP id d9443c01a7336-1e50a04c317so37747405ad.1 for ; Wed, 01 May 2024 07:37:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1714574269; x=1715179069; 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=MMLs/dbeVHFyXXwBBndTsbPj9oWUIhTen3YuB0jPMk++YeudGpibkJ5quyr7P+I006 hQ9b10QUI4xQGrqAf0W8oWkbs/LGAzg03t/v89+DyfHMRrR1raUBaols+C673F7ETZd1 ckiQsoIH50Ik8qHKM+ay3OhUV5162eOu71pmGu1XWYzEyzHJ1QihTid1tFi2dlAhx0F+ TjxR3xHXXed4Bs1S9ZCvRj3LntFAXXD6ywKatFcgaZ+palce5wna4OrTymqJJtPpYgfH 0H1D1fV7n553s5gArLBiSZ5PFGIFFjdxwnGLqBCudlaHb/Qqp7XKSgWJwejXJ8CI/MEI aQ5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714574269; x=1715179069; 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=Gx+eK83cjmCzTPkjkkLgZP7dzQ2RP6qcTXdDL01trfFOPQ+/72x8Ce4Vxx9Ejnl20y F2QYkD0o2OX20zWJbF1jWG1/SVVAGUQD/AX8pn58VlnlF2xzKPxthvTto/wcDg5fR/Q0 7Cb8Sgn8pwSYnV/lzrtDMFhyXzffDuwMHHtMRxuFFcbf/4p9EIolZLngfaWilnXjfIw6 txMAFmXA/f/ZrYdPuxUjFmzr7nsTPEnRe6L6+pYM3ctMfqQ3SraTYW91QNgC2zBFA5dH V9DTDhk8BQq44mLlVJY6csvAgfM4VJc0IlOvakWWJDhGfGEheETgbW245wKotgMlHX8w DSJA== X-Gm-Message-State: AOJu0YwTI+7BYtrtqLU8pcM4IEQzqT2bR6CZ/wCE6TQY3pyeST86bXV2 FiqPtjBUN7NkC87n8cC0C7VVp32/0NZlsQk9ApooKcwjmQ06mGJbxRgiIxO/3hHYTEoEPq/gVSA C X-Received: by 2002:a17:902:bb17:b0:1e4:9d6f:593 with SMTP id im23-20020a170902bb1700b001e49d6f0593mr2844010plb.36.1714574269116; Wed, 01 May 2024 07:37:49 -0700 (PDT) Received: from stoup.. (174-21-72-5.tukw.qwest.net. [174.21.72.5]) by smtp.gmail.com with ESMTPSA id h12-20020a170902f54c00b001ebd73f61fcsm5751573plf.121.2024.05.01.07.37.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 May 2024 07:37:48 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Pierrick Bouvier Subject: [PULL 08/20] plugins: Add PLUGIN_GEN_AFTER_TB Date: Wed, 1 May 2024 07:37:27 -0700 Message-Id: <20240501143739.10541-9-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240501143739.10541-1-richard.henderson@linaro.org> References: <20240501143739.10541-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::636; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x636.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 May 1 14:37:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 793715 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:54f:b0:34d:5089:5a9e with SMTP id b15csp790524wrf; Wed, 1 May 2024 07:38:57 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUDRD0+SnUD7KUXbfumYCw/a7/D/H5A1IC4ikKbw4TrDEeB6dwmyd2xGx9BrFdKk4pCNfi+plSCSSsz2TjUaVSE X-Google-Smtp-Source: AGHT+IEPHKvX+YB9qDijVB0Z5DF6J299B/g3MgwGx8Zqw9q5pWs+nHY8Cm8fUhuHDp7kSGhUHwg7 X-Received: by 2002:a37:db11:0:b0:790:c338:d20f with SMTP id e17-20020a37db11000000b00790c338d20fmr2743384qki.35.1714574337320; Wed, 01 May 2024 07:38:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1714574337; cv=none; d=google.com; s=arc-20160816; b=W4L35gqylDOSUO8kD99XZtHli7E7IQyTYnKZn4/afZxZ026FpUIaBaEPblw4rx7qiF oEmSSgxdSdqs2ZHwoGCVq1xWW4wRVUWTJ1hP15P6UgIG3hg0E63MxUQ5CY9u/FvtL1Le PHBLDffUYLW3cq4L6QqXK1zsZ/gMlu6+b2TQYv/gdkcdnYAJRxE3/EwcYYtQvuBRJfrB nW2RTdNEgwwXSMql6rWwj9L45zyZ2YHqGvF2VkYfye9RgcBLxJdDGr3ijefBJJE+8ial 9rnOhXINyZ4WHem+3XVtn5huAzIUy2GvzWZkyTPa8NDpuuHgxEJ+mVshihNQBY9Fondl WPMQ== 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=tzoE6tNUyoIQQfQ5RRfqTp+rcBHHbD8Je+8IXwvSf38=; fh=vm85eyWrvOAHduw3sqEA+cYBqvHB7M0MHFcRJg7VWOo=; b=LF3dkQ77k5QVMEKoTEmO5N9hj1x2lqNh6dcbQD4bvRFoZJJ1i1oWz6e6P5YfEjWwk6 rZaODoAMykpK8t+yU4jwMchuQ1JOGYkW17QQVRAH35nh2zaO+GyMGxi3wtbrMJSgV0A3 3Ic1V7D+tAsgbzbsVFVGvomo+55vQ+nznNiAk+WB/Q7hQNVKwb6uCtIWsFZCe9aUyGiM 6UBzQdfttN14SaeSJA04dreepEsx4hBzUSf7EKdGQp4YqYZulJHqThr9fbwonq/eGBhe 0Z9ftvDwasB3b9a32Pjprta7TUTNSb5DV0q6GGxrtp9bw5FBZhvgFNys+yY7Xz0S8zWp 9jcg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WMQLme0a; 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 t2-20020a05620a0b0200b0078a35250c01si30742540qkg.387.2024.05.01.07.38.57 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 01 May 2024 07:38: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=WMQLme0a; 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 1s2B5v-0002ih-9S; Wed, 01 May 2024 10:38:03 -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 1s2B5m-0002gY-22 for qemu-devel@nongnu.org; Wed, 01 May 2024 10:37:54 -0400 Received: from mail-pl1-x635.google.com ([2607:f8b0:4864:20::635]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s2B5j-00028Z-64 for qemu-devel@nongnu.org; Wed, 01 May 2024 10:37:53 -0400 Received: by mail-pl1-x635.google.com with SMTP id d9443c01a7336-1ec4dd8525cso14158395ad.3 for ; Wed, 01 May 2024 07:37:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1714574270; x=1715179070; 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=tzoE6tNUyoIQQfQ5RRfqTp+rcBHHbD8Je+8IXwvSf38=; b=WMQLme0aHpScjFDE0LMi5GyP4YsOjCQk/XNDdLMsjztbBT10wIjHTzqzTR30RCVUF1 t1+LLklZrl4Ns3Dp6ylIENdM+Do4icIu2gBX05MHwiprEH5RAuposigTXtedH8DKIgF/ GY23TfktwykubinE4X/0Zf+1cl4Jtxu9dptaOa+ehpXUvNRp+FJgqdbt7STRMGd/xBZ3 n7sbEqeC7LR7gNtEOfkX8M7yjpbscyKRdX9+EuKvMEO1vriLcfpftoEKtDIolrbbqxcN 9EMM8bV2G4QMQwmse0G5Y7zbXutB1MyoP9WrlbJ7VW6OnFgJJol0wN1LxxcTizMetsqX AyUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714574270; x=1715179070; 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=tzoE6tNUyoIQQfQ5RRfqTp+rcBHHbD8Je+8IXwvSf38=; b=bx9my5moRT+lAEjXAjMISdOt9hTXJZ9D5btP7e32wQ8ot+z0E84aAgoxuceZ95hQ8w M9oS4DJlcLQB7c1e0QMwnDiRyWHV16xurrEAxPYDTVKmDwE74+w10ZqwfWJ1Rarh5MiN duNomT7+HokNUE33u8+z3YV6C0CbsVOhc+W7riDE8c7NfPZrSUZWqX9vBCQ/izyaeRST kgUcUi3X/CrwpMGMjsXTJtksrrLNSgndwuruqkw7awOtwor4Nyn0GM4+m2YrMH9b/Ex6 jPauvz0/NHQTq+WPf4wRIqAWO4i3r7ebYQ3HilqmSr3biQZWkDGEJ6k+1PNxk/ClElIb WUKg== X-Gm-Message-State: AOJu0YzvNdY5myxpOi5GEUMmBHJbtNfSpGT8WZqM6gn0Zc/1RX9E5k3j rWGBNJbsqGLo3oVfkTURw/njqHVyw+719e85ubqmbq6kvwXgcP87eLNJVl+k9r3BPQLicAUTPrF 5 X-Received: by 2002:a17:902:e751:b0:1e3:cf2b:7151 with SMTP id p17-20020a170902e75100b001e3cf2b7151mr3172539plf.59.1714574269877; Wed, 01 May 2024 07:37:49 -0700 (PDT) Received: from stoup.. (174-21-72-5.tukw.qwest.net. [174.21.72.5]) by smtp.gmail.com with ESMTPSA id h12-20020a170902f54c00b001ebd73f61fcsm5751573plf.121.2024.05.01.07.37.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 May 2024 07:37:49 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Pierrick Bouvier Subject: [PULL 09/20] plugins: Use emit_before_op for PLUGIN_GEN_FROM_INSN Date: Wed, 1 May 2024 07:37:28 -0700 Message-Id: <20240501143739.10541-10-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240501143739.10541-1-richard.henderson@linaro.org> References: <20240501143739.10541-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::635; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x635.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 d0d830bfc0..0d0062448b 100644 --- a/include/qemu/plugin.h +++ b/include/qemu/plugin.h @@ -74,7 +74,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 May 1 14:37:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 793731 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:54f:b0:34d:5089:5a9e with SMTP id b15csp791493wrf; Wed, 1 May 2024 07:41:11 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCV8rSFUyloTNyOZAhAz0GnjegejxciXvddMSb68tTeXWHWnX0EBeUSs5yyP4tQT6XQh+KyV8qUayvfdDGr4ioVt X-Google-Smtp-Source: AGHT+IGRlWr5o6ki5K6EGQnG0nGvsdmtjB/NCs/+wXAWGi/O/urPGEuSsC2ew00jXQMfRr3Zmdfw X-Received: by 2002:a05:622a:1307:b0:43a:ed8b:5a52 with SMTP id v7-20020a05622a130700b0043aed8b5a52mr3049359qtk.44.1714574470863; Wed, 01 May 2024 07:41:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1714574470; cv=none; d=google.com; s=arc-20160816; b=s4k7dxy31fbN1D5OW53EcvZf9R+vAy31zv9KqVmdroLB1uHc/TSu7PWfGuxIKGHqlX Vf1WhccpnGtJn3ihXBwf837b8mdVc6rM4gJdo9qZQqUIj07s33pFAE+GP/yQmgv6k7pL r5GNiINqm2kL4Gy0baXhM9YhBi2WceBnYBLKultgUZtCPy943+/YbhD0DjhIx6yzvtm3 nGbVmeD/st3Jw6Qv6tYsOi3Jc6CPckTKQSU2xB9JSwYXNTPtKKk4U/xhaJcunrnMBeFU Sb/PxHn3kG1ihHG5o1g/hE7F1d0SFrRCtgdH7w9weXL46eg1u//sMbjwaOxcF25ETnow aH6w== 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=qoXWDcTLea7evAQ6WjI0jTiE4629RsXMCIkFXjudEjT0sxHRxu0a33Ol+yqHcqrQJy wDSqbOhxkToFEQX9ahkEq3UJhg22GmvJjugY5ONG/jG1BUtuijF6q8nutOvZyA/oX7wP Qtu4ISPhXvwxm4RoVTUJfDEgRyfOCVM+hJRE3YX/tozCbFYwZR6oTK1OI7rN/w7OY+wb cOJsmml4gJ7kATkU/EhHnXxklygNWQQsVGLiQh7YCdg9Fbw6s4C1O66xu5DAR26Q/UnX XzNv+HYpgb+NPBiprgX22kQVxec3IL1UEItIWTpPw2JaDHgPx4O3sP1byaTLVyqd5u4H K9rQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ZnEJq0R5; 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 f18-20020ac87f12000000b0043acfc5d329si8148597qtk.235.2024.05.01.07.41.10 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 01 May 2024 07:41:10 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ZnEJq0R5; 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 1s2B6D-0002lA-RH; Wed, 01 May 2024 10:38:21 -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 1s2B5n-0002h2-II for qemu-devel@nongnu.org; Wed, 01 May 2024 10:37:56 -0400 Received: from mail-pl1-x62d.google.com ([2607:f8b0:4864:20::62d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s2B5k-000290-Af for qemu-devel@nongnu.org; Wed, 01 May 2024 10:37:54 -0400 Received: by mail-pl1-x62d.google.com with SMTP id d9443c01a7336-1ec92e355bfso6587825ad.3 for ; Wed, 01 May 2024 07:37:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1714574271; x=1715179071; 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=ZnEJq0R5WfvuuGzFjUOaS0S4IbaZPs1MKbwm+343pD7qEdWleWdHpQkrBxsGYbzAh4 37uXKD5vISVgjm2+y2B7pYTi2PW66LhPiG2Pd534J918nDtvgpZWr6z+3seQvysqZgs6 Qa20OsVuaRK4ZvQQL0VuC8NborSO+jUkPaSrdADeiYHbSYmcFaQ729Je6bsjC1jX8aO5 Aa/+ZaZ5WsVFccm567by5w2234KAKCppww+W1cR1/mXphyptW/POodN+HpuyGqBwe0cx EZatcLGfB9YzbI1L6k0YZdve31slK4Ylkh6i9G308SdmVseutbexrGtyzOcd5pOgnY7R lgdw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714574271; x=1715179071; 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=nMl7+Zh9h30ldq+EP87vqcxXkMeAnqn7EhZB5vv22R7vqYHhSYx8Xfp/0kMVUx0aWS no4f8I3/mO0LNQurf2gzFucRU2t+2IvL6qXugl3RPSTtDB6Ll3EgqKD2O8FxXBqVKa/j ZkNhyPcfZ8eyc/5p+/xM3vYIYo80xzAC5YA4BY2ra1qq/XCNBIn8I6eLKq5t0zbm8UBU 3by4cN4TRNh/M9XGe5ZzPiUxSlPwPBzWev0p4n35nclpYr4g6hTuCNUJHVsUasb5xZpi TQkrRPeyVrd2PaUB9+fZ9wnm4N9F68OY0ZoGbPu9XWPaL8xNQ58AKtThWD1BYcbEn0x8 Y58w== X-Gm-Message-State: AOJu0Yx0cE5UyHACF6gW+9/nMQTJpUDAlvO6TBgoYpIh/ioDq4qH1Syf m368KyuMqFnZcftsj4AkIYQY3mnsRNF92+lcGKkpWea7s3TS/ULmA/rfw2Y9H1yH2J/tFHHNy7p G X-Received: by 2002:a17:902:e5d2:b0:1eb:5c40:54bf with SMTP id u18-20020a170902e5d200b001eb5c4054bfmr3578951plf.1.1714574270899; Wed, 01 May 2024 07:37:50 -0700 (PDT) Received: from stoup.. (174-21-72-5.tukw.qwest.net. [174.21.72.5]) by smtp.gmail.com with ESMTPSA id h12-20020a170902f54c00b001ebd73f61fcsm5751573plf.121.2024.05.01.07.37.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 May 2024 07:37:50 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Pierrick Bouvier Subject: [PULL 10/20] plugins: Use emit_before_op for PLUGIN_GEN_FROM_MEM Date: Wed, 1 May 2024 07:37:29 -0700 Message-Id: <20240501143739.10541-11-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240501143739.10541-1-richard.henderson@linaro.org> References: <20240501143739.10541-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62d; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62d.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 May 1 14:37:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 793722 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:54f:b0:34d:5089:5a9e with SMTP id b15csp790791wrf; Wed, 1 May 2024 07:39:36 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUBtvcpmGqB+YJfr8Vx8Ga9wvIjMUDfp4HTNzy03aTzKxjQAEptNzgN7sjg7SFSe0DUYW8jDPt7aOK3EJfaWDB8 X-Google-Smtp-Source: AGHT+IFy8uUaZlEzxfIkf1wndyAYoVmuM6tm/mM1nugYdVGkvhyDr7PIRJRaz0eNVW+mM3vv+6cP X-Received: by 2002:a05:6808:2814:b0:3c8:2b6f:de1d with SMTP id et20-20020a056808281400b003c82b6fde1dmr2598298oib.6.1714574375857; Wed, 01 May 2024 07:39:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1714574375; cv=none; d=google.com; s=arc-20160816; b=DvncePxfe03nvYJf7U2+GWVj9tGooxGl3EtdNgc/0tKVgimqY08pz/ZSKOU3PvbSG/ ID6JxvlECXRJBxv3zfNGM577vN1RW9G7I1q1MqD6VfC4Ac0Vr5FFWDtTGQ5ydzQsBSML RKnYRrBgUvaVYKkmeZASPq8NeI+R9t07YeAAbNljedgkq9f8uxoRS12yQXyZUO+HcyCQ yuun+Ik0qDan0hdUps4kNRDrmmVJiLkRsBS2VrM0R3UNkeFbx51Fm5RIVbsTsEqJUWoE uAf9oK1ndDPnb9re6SSP5vT3jv44MXdeUpyHOiKgkE/YjpJwT6h+77aiJ5d1pdApM4ST 7cig== 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=SDlFaK+SlhzdMJZ6vMncH7Km5ZKBbIcTUYF0H+1g/n3wEivXcep2/dFBojlmDTLMWG p1+JY6Q+ArnEZulFOpwoU3pgdIWvFzLxLVuljPoC1kFA0HHLK1DPZ68K62nk5Kxbdkcm SNvmqwIYABinDjHrGP1OXOKjDqxFRYK75h8Wp2wn9DE3zoqLdHgDkvMPneUMXfQ80okY PREEerMTQXbE9HSWaPmhYRGxvYOPGfOOJVma/gdqTPMI9DPPU6Tx/DqscO2ctUJ7PDg7 xiXrldDUa5j42luHMOMPSERIxDp6pMSa0sH2AvLSyc5B1tE/PQZ5xn+bvr1JR1930+J4 gllw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=qXotNAux; 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 o15-20020a05622a138f00b0043affa6212fsi5809515qtk.801.2024.05.01.07.39.35 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 01 May 2024 07:39:35 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=qXotNAux; 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 1s2B6H-0002va-QO; Wed, 01 May 2024 10:38:25 -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 1s2B5n-0002h3-IZ for qemu-devel@nongnu.org; Wed, 01 May 2024 10:37:56 -0400 Received: from mail-pl1-x62e.google.com ([2607:f8b0:4864:20::62e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s2B5l-00029C-7d for qemu-devel@nongnu.org; Wed, 01 May 2024 10:37:54 -0400 Received: by mail-pl1-x62e.google.com with SMTP id d9443c01a7336-1ec92e355bfso6587915ad.3 for ; Wed, 01 May 2024 07:37:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1714574272; x=1715179072; 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=qXotNAux2/Veppk9v5okXtsAUrjFB/1Xbyl6tDFWSH7EQKPXbJv1853CEg3XdoRcIA 0iXCp7h8JItymWUDAR3Y49GKFMIKtm8b3l0W5NaQgQ6h6pE7eHT1HrJH45VNWnpXok1x vRmQEzFVKJ2dVNDZ1UTMiyy49fwdsFnFDq9gDXZwzBlAt58FjIH83vZfwhCSGD7BpA89 tZtq/KbYPnVNfpWLggJp7nMVzJ8G4vJ5O3+4Htx0+J7sM7X5M2I3MyKXFvu7zku240Um 6F5/f7l0VoqWiDEVVIAsltSJNdJ8EB200nchMjy17vTSZKLwInZEY1fiDoaapJW4ca3C +QvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714574272; x=1715179072; 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=fA3tds+EqvoAE3OUWEELkM3TCBfEkMvWq0FLFBkwO6h2OgWRo1lhsUFCRJce41zaeW Ass7ZIJY/oVRi5/yD02S6CC+su5+57SZGNocRnl4obMbIt9LBzYC475/HSuILbE3eIEr NLUGorRlyMeiWQCSxtxkA0mToi3EfaRrAsIGuniUqWAIdRhMWYqWU+uH7r8s4K1gx8ry rP4Jyua6Nm48VEAMM2sEhvPfVptOSzuKmgilbXMYN0pzqWbXO55OWe1vJGaM5HXCtpaL 9porNrjl/KdFXWiyFIpQVXZ/5VMr4tauQ5kEjrkwZtCmhUvCtA/TFdtduoV4N/3L8rcv lR7g== X-Gm-Message-State: AOJu0Yy2xcdo0Hp3ggqcKNDtrExgH9xs1SRNYWEo93gOuSvrhKTiKMTf 1HlpsWhwqLetAiC7QBR6dn32x4vJ88C34u9gPoTw5s0/gtas7FSBEQMy0ZES5gHqu4K1BZwn+RR k X-Received: by 2002:a17:902:ee84:b0:1e5:10e5:b66e with SMTP id a4-20020a170902ee8400b001e510e5b66emr2286173pld.27.1714574271727; Wed, 01 May 2024 07:37:51 -0700 (PDT) Received: from stoup.. (174-21-72-5.tukw.qwest.net. [174.21.72.5]) by smtp.gmail.com with ESMTPSA id h12-20020a170902f54c00b001ebd73f61fcsm5751573plf.121.2024.05.01.07.37.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 May 2024 07:37:51 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Alex_Benn=C3=A9e?= Subject: [PULL 11/20] plugins: Remove plugin helpers Date: Wed, 1 May 2024 07:37:30 -0700 Message-Id: <20240501143739.10541-12-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240501143739.10541-1-richard.henderson@linaro.org> References: <20240501143739.10541-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62e; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62e.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 May 1 14:37:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 793727 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:54f:b0:34d:5089:5a9e with SMTP id b15csp791157wrf; Wed, 1 May 2024 07:40:22 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXGg+1rHHxoQkJ1Y+H+DHOlP2r9SCm5aUSZanADLtzKfhW847szv3rLcRN38C3uAPUR0yKP87sjJQaXb3khqKEH X-Google-Smtp-Source: AGHT+IGzsYIJHv0IqZKe/PBYG7ZovruQE+ENAEu+kLnDodquxKUis8j1pmuZFQgG+EKtxT9aM/UZ X-Received: by 2002:a05:6808:4182:b0:3c7:522c:3407 with SMTP id dj2-20020a056808418200b003c7522c3407mr2809165oib.12.1714574421811; Wed, 01 May 2024 07:40:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1714574421; cv=none; d=google.com; s=arc-20160816; b=eAv5aqPhppMTvLmcZTv5fL0s18/3+HxqUd3vqKkdSAec+30qD2Kzsojr1n/La1N3zq hesHAaGKRyyf4e/IZ+jJOvAah9rCq0iIy1dE8Od6nwmfeQah3uRFFqgx4iqG3LXFjwXY iKXDLPInKYldJYTuFofxZhNH9P+aSY30N/6hPg7/SEOhaNXy/5aUf/q1bFwFhhtPWUcx J2WN0hNtoDSANa/v0f5J1uV49+FfI9ALT4Ji7cTCXctN6fG1+1t7fe5myrckIIbjT6T+ niuovNYhxrAtx/BDP+JKjFLymvDDE+EDBiFh9WG1n4LOHWqWlM7B6cfk9icDFYrnKZts Qqqw== 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=P3yOz4ai1P+rruJtDN+ly5UPZeaVEUB8c8mUXDe5M74=; fh=vm85eyWrvOAHduw3sqEA+cYBqvHB7M0MHFcRJg7VWOo=; b=GoaIuqwsQ0WwVHY3YohhpI6HNlIQxaUgvAG6hn9+8QSVURb78TZGAbsw0bFtxGZzC3 t6VhXA83k6BCRdie5kAmoQ24mQCc24qudQoBRgy9Di6EVLHc7tLbx1P9EwKX+Ajeja66 9QZ4zzoSh0LRooVTG81txGYqBZnlNYkcKSnHFL99tYmDwwbgjt82aM4jOSrr2SISSivx /sRNfqLZqvOE9OSqJ0FT9qhwVzt3gXNucrFCcIL7CA3sg0SdCv5DuXH3iUJdsabY0QdP O0uRf4C23XWNniZTVeowH2KooZ0fBPrBFy0BLd8WWtvf/qi5bYxIS4QxKCYWR7Xoj23l 7VNg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ARnzWV57; 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 d17-20020a05622a15d100b0043ae5f1a53bsi7575645qty.61.2024.05.01.07.40.21 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 01 May 2024 07:40: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=ARnzWV57; 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 1s2B6G-0002t0-M0; Wed, 01 May 2024 10:38:24 -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 1s2B5n-0002h4-JA for qemu-devel@nongnu.org; Wed, 01 May 2024 10:37:58 -0400 Received: from mail-pl1-x636.google.com ([2607:f8b0:4864:20::636]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s2B5l-00029R-T0 for qemu-devel@nongnu.org; Wed, 01 May 2024 10:37:55 -0400 Received: by mail-pl1-x636.google.com with SMTP id d9443c01a7336-1e9ffd3f96eso55769025ad.3 for ; Wed, 01 May 2024 07:37:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1714574272; x=1715179072; 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=P3yOz4ai1P+rruJtDN+ly5UPZeaVEUB8c8mUXDe5M74=; b=ARnzWV576Oz9GXZnOhd1lYdVggI6tOwLMzVnh91FiP7xJD5w12cy51pVtvC0vHjjZq 5zJI0IVKYptBJJ/TasrvHTiS8YGeMX1LMhgpQ608+KYvcRP6fJb3PvrvRgncsF8so0fi eRhOBNbNqeer9njUIF/aAZRvsl+CW1uqvDrYPg7myvNQQEo0On4HRVVt/vqtRLEtFaZE EADbGQT+R+YARCCn9DH/yPP317MtY1Cu/58sEaFHlsS4w/FmlB0d37HgT7eSDiYGH2XF uyw2+O3X2G9G/kRYgUOkKQ/czDB4bsfWC4TqenCj7547s+1L8ZuZybMGEfi/+BIACfoa 0O/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714574272; x=1715179072; 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=P3yOz4ai1P+rruJtDN+ly5UPZeaVEUB8c8mUXDe5M74=; b=agSQEZzz3YLQm+zHil3QJN77FG9jvc3M6E5cCbLFMG8xHnZDts2uwWec+CxtSymX/C tvfEt1EVPMA1M8mJbOPNpWtdITMwPLag4mzqTjOMt65JqQAvcQv8xSviclwnSLN0pl1A PyKB34r6RRVenwTNoKfAU2alqtEoYqrluADjeTxIy8xVGmU12vlkKPzmouNk9hrSXuBW ElgKF10nKVrP+SJRY8sVptUHbglQWmRhnseT8crqrUFt5WRnmiFQ7e30cGJ+OU415IZh IFV6D8p7IK/zDTJ97yZBLr/eW8dbD2hZteaW2Sm8DaVuVKP2vjQ4EhfYC7s+08T03InI 1h7Q== X-Gm-Message-State: AOJu0YwfiHcHA7mdME5+W4PiN8WDezFnPXXv21OHZ9cz6pp+wp7rjmD2 SZ5Cfr85g0m9TEME2uHc3fm6Dn8S1H0Vv3ow3lvJCgkGM/aGf459WzTkujCHpF8FPrqhiIAu89P w X-Received: by 2002:a17:902:6506:b0:1eb:1fdc:25e7 with SMTP id b6-20020a170902650600b001eb1fdc25e7mr2775459plk.19.1714574272575; Wed, 01 May 2024 07:37:52 -0700 (PDT) Received: from stoup.. (174-21-72-5.tukw.qwest.net. [174.21.72.5]) by smtp.gmail.com with ESMTPSA id h12-20020a170902f54c00b001ebd73f61fcsm5751573plf.121.2024.05.01.07.37.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 May 2024 07:37:52 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Pierrick Bouvier Subject: [PULL 12/20] tcg: Remove TCG_CALL_PLUGIN Date: Wed, 1 May 2024 07:37:31 -0700 Message-Id: <20240501143739.10541-13-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240501143739.10541-1-richard.henderson@linaro.org> References: <20240501143739.10541-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::636; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x636.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 7484a07722..cfcf9122d6 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 May 1 14:37:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 793726 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:54f:b0:34d:5089:5a9e with SMTP id b15csp790975wrf; Wed, 1 May 2024 07:40:02 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXBETe5AyF7+MxB0ieohRRdjFqbkNjV58KEsAWzIom9ZWyff2rFqgsy8vlD3kbNnHyiKjc9/lvjFgYgn7g0B0I/ X-Google-Smtp-Source: AGHT+IE+OysYxg6mYpyNatqnsO4zgGqgCc93UaqVO9Ex9jvB8dAShB/xYVWhk0Vz0m707OJ+Mezu X-Received: by 2002:a05:6808:2cf:b0:3c7:4af5:728a with SMTP id a15-20020a05680802cf00b003c74af5728amr3373830oid.8.1714574402699; Wed, 01 May 2024 07:40:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1714574402; cv=none; d=google.com; s=arc-20160816; b=G7fAEGnVQVRRmMfnz9vuaF7mDbAkbX1W48MT7uNIsGflWHf007DIt2mIuBPuYlW1bJ hWvS+zRMqb4xb8Ht1l2WpbgyGwIXvFhosBz61JLoZmWC/kLvzi9w9+ZpantnI/Ofjkpu lDsnyNJWJUEBqCHZubze5z7HFiuEa+QQuB/sk+EK1PW/3Vk/naTkcYYqZIRWDEx2prf7 /TKZwYUAIFhfi4CBCFTAPO8b9YO8X59peBBwqSO8N1pGxA8ck7TF7rv9gQolGQxhb29I bXcNhapUI8BHmg0PzJjtMi28NP+CDqAMt02avyxnHCAn9si6Kd3b7Bu2+oImPMtirRIi /9Pw== 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=ZONlK+Rxtdnh/fKjGAYAfMmeMF6TosPCDE0m3bDqDWY/g/WgMOWYKyWy4WjWaLKPsL +F36FmNDBFEwwe4IsvbQxWfb0MKZ85+3wE9un8OXVYqOLDeaXrLnInzwBXzrXHun62mn CNrfpID/EnnP3VXK9Ls1ngIC59E1ulHSDZQW7jPTtRP1gOR3PCDft3uvYKX6hjlDMrbL umt52X1Huef++t8CIzeWaXglxAWrvFAbZZRgfTvSVhEnmLjsBX5Xnwz7trci+tNIlXdd 5/ulNXCiInNt1r2KP3BUFplpIwHRCQghPbwIf0+ZWdbutQCr2K+gaqWiH9wes2vO9G+X +RTw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=e7wVBdtF; 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 10-20020a0562140d6a00b006a09243a2d6si18034002qvs.478.2024.05.01.07.40.02 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 01 May 2024 07:40: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=e7wVBdtF; 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 1s2B6E-0002lB-09; Wed, 01 May 2024 10:38:22 -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 1s2B5p-0002hD-8U for qemu-devel@nongnu.org; Wed, 01 May 2024 10:37:58 -0400 Received: from mail-pl1-x62e.google.com ([2607:f8b0:4864:20::62e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s2B5n-00029n-An for qemu-devel@nongnu.org; Wed, 01 May 2024 10:37:56 -0400 Received: by mail-pl1-x62e.google.com with SMTP id d9443c01a7336-1eca195a7c8so4142935ad.2 for ; Wed, 01 May 2024 07:37:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1714574273; x=1715179073; 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=e7wVBdtFg43+oaXJphjrT4q2pWqM+9pGQmMKYGY4PLDaMZJkfHPcleEUuRmbU3EE3F bJZ9rbnTImOP2M6Eb+5mfOygjd22uDi6+lSUWm9icAjf5jiPQZ6Sts/eBLSycG2xAwyM iGiUvKiI4OTx343U215o4OJKcXzFy2tGc48IC/9kJ+ZwRCD3zzFmBUppGv6xrjSwWECW snmKSNRLz7M14OG2IHQr62o2cZWsyBp8+oA5gCoqoWEnH506Jte3oCqvEAUh0B8i1jj3 mp6sTRF4XmLtD/Y0MsS9e+A8aIvvsP+iq5WnWwwm7lxMSKSUFPcho7J1v+b6Vdzo4m0I v8pw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714574273; x=1715179073; 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=cGcFtZ3AsMtcdNrQkCMSf9WVQWQYJqpVApkOhxHRHbg8FX9t2sj0TBpaQEldOSapbb hJWt2O49gS7ltd+tO6Vj5SfUhPI7+uzBxeC6H4T1/vDd04eYmcbyHvGu4xdJxk5JL4dg vlUP4pl2hIlTkk6PZyfZzt2s/Z6GRP7Ugfqr27WCmRfPoBOnTKWGLS2qYXipJqZFXuFp WtRXLY2F3s142/QK8B/CNpmf/7ai7SNhgLBFW8qaC1zbNUE478ONX/AXbhCoGFaF8APz PKj3ivOUx+IToIbUsKYZdtD3mYoNFp2ZtFE6qufNr8MOv46c6a3YEiZ+cO7F9AkK9fhE Wrpw== X-Gm-Message-State: AOJu0YythhqtcOcHILrUv5u0My4g1lKbp3lCesqTTCt/4wvLH641JMDA 0xa/RA18x/u7QKEEkndgjQ6rcXsfj73vIQ9Vs+fJZevYgWMd6ono7ratlr2o3pIJUe4jkRS6bNm p X-Received: by 2002:a17:902:e892:b0:1eb:c3d4:349c with SMTP id w18-20020a170902e89200b001ebc3d4349cmr2785867plg.30.1714574273495; Wed, 01 May 2024 07:37:53 -0700 (PDT) Received: from stoup.. (174-21-72-5.tukw.qwest.net. [174.21.72.5]) by smtp.gmail.com with ESMTPSA id h12-20020a170902f54c00b001ebd73f61fcsm5751573plf.121.2024.05.01.07.37.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 May 2024 07:37:53 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Pierrick Bouvier Subject: [PULL 13/20] tcg: Remove INDEX_op_plugin_cb_{start,end} Date: Wed, 1 May 2024 07:37:32 -0700 Message-Id: <20240501143739.10541-14-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240501143739.10541-1-richard.henderson@linaro.org> References: <20240501143739.10541-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62e; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62e.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 May 1 14:37:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 793720 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:54f:b0:34d:5089:5a9e with SMTP id b15csp790711wrf; Wed, 1 May 2024 07:39:23 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWTLA0vd6E0Mnrl5OSOFn97KWcRwWg0enARcUSEPLsQw5wCrsk4i1bq7WbHWbGPyuyaCHByLfFE5k8VqsIDeIBy X-Google-Smtp-Source: AGHT+IETyKJpY0JV2TqUsYmk7PiVNvW8U7kWPfQQcezDI4xmq0JGH8KXsEY1eNEe5RmWFywn7kNx X-Received: by 2002:a05:6870:95a5:b0:22e:ce91:d6f8 with SMTP id k37-20020a05687095a500b0022ece91d6f8mr2845952oao.51.1714574363078; Wed, 01 May 2024 07:39:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1714574363; cv=none; d=google.com; s=arc-20160816; b=qcAqwsHRPeSFjjDZ7lZeNeYuSB0yop8iAqIIRUTqpiLMGoyCJaBuJ6TZC3t/uItV5a WL2ppg/p1zhTxWHglhlmHAAP3RPVdy7TlXIJTiOz2o0LX3NfDNUFySE8aVIWAwXkaal4 vfWwZcDgliIB3XlyAMLvPCejqNjygi+JGXj9NmGOWO8k4qNTkULjxhQYq9qSkjZ7/odG u5d8JQcYuYUMe1cQ45PfVOLSGZ7WWD2rGFWCnAz1y81SOBjRfF2i3RNbN4b9l++lPygW dUphbCIi5m59Z01AQa4K7pvLBNKGwIPjgjMHxPaonS9mp/GhJhHqPj8+kOEo7zmcrBWc jaEQ== 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=hIMvAm2jbpK2PQHQ4qVUc/TGJ1BeB5t3WwlK4/K5NYE=; fh=vm85eyWrvOAHduw3sqEA+cYBqvHB7M0MHFcRJg7VWOo=; b=0sYld2+n3e4txGOE1JB9Zxg9EeoR1dQ8+QZ1FGxSoY6YIMJX+nGr/d/Bs9YwD8lkfG nrBcNxiieKy5XzGgeCT2sqHX430hnfza92qA2N32Y+VcmKmX07joahMdY4PKQA2bcwPy KcktISFkhX18sr/jxJ6QBuL4Lg37oNRH8iZhg6ZJMNF8rIzKsf1gxUA9u2x18lJw5hPO rRZeVAmzTurhrycBJPZb+qgdsFBS6pnj3e0VwP5CXUFZo/sgEV68irGiA/71C1my8Z0R ngyq9/mKhHcAD1BhigSdLvzOgIryV8TymdjLnOjHobBRrq4VKaJJ10xpC/NRlHKxvXhW 4E9A==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=IHeisvYK; 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 ci14-20020a05622a260e00b00439ff3a7fb2si19780769qtb.121.2024.05.01.07.39.22 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 01 May 2024 07:39:23 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=IHeisvYK; 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 1s2B5w-0002jC-Pu; Wed, 01 May 2024 10:38:06 -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 1s2B5p-0002hH-Pi for qemu-devel@nongnu.org; Wed, 01 May 2024 10:37:58 -0400 Received: from mail-pl1-x62c.google.com ([2607:f8b0:4864:20::62c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s2B5n-0002A5-LR for qemu-devel@nongnu.org; Wed, 01 May 2024 10:37:57 -0400 Received: by mail-pl1-x62c.google.com with SMTP id d9443c01a7336-1ec4dd8525cso14159005ad.3 for ; Wed, 01 May 2024 07:37:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1714574274; x=1715179074; 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=hIMvAm2jbpK2PQHQ4qVUc/TGJ1BeB5t3WwlK4/K5NYE=; b=IHeisvYKwzqrGywBsJcw47HfjUVT1DzNIycb6w2Im8R+7ld6ttJeRf9iYNl44uKI6O YIEL7ryccK4wl17njz5BhvbLZ01Pzmm4SN9fNPx51AoOSH/T+YX9UlEm64wdZ/xYNkCH ga3DZnG0L+c5tVRSTcmsjP92tzdPRqguvqVfL3FtOW6E352YOk5I+27jD3jfKUTAPPr5 AlvUYVlgF8g2rZdrg8UPl3S4NDMySqUQZPZ/laVv35ReizWxp0NUrAWD9jtpYAsMXJpM YmrYqWb4SH888Mr1Q54AqikdfV2yx9Uk4GMc21FyODDkDO5VbDWn4ZBWRKRBIkaYABJJ OfYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714574274; x=1715179074; 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=hIMvAm2jbpK2PQHQ4qVUc/TGJ1BeB5t3WwlK4/K5NYE=; b=g9nywH4GdE2TtEG35M+cb3HsO4qPVn7JfF/ewFku9LUjMFD1Cj7BT05+NKy0hWvcj9 cuCPv19CsxzAvNt91rSnVW7vL4t7jkjlTVUgAqs3p9QKXEVrzLSEtVZ59wPkzIrVaeoA u5f36FspiDa3Fko7eKscUZPSoHm6nvIs7FIx45gQf3F1wCrzUOiq7aXva4dtE1iMpOOA YcBiHwNqQpHGhuI3zpe9tQb0ne8gmVU5fU7A5IELojvJ5fvIgL8ZT3iufvdbUOHpZPmH 6ooQJG+uBIv/5i4SZnFzlU7tVRMqSsDLfbfSVYRM1qs5yrO+dPSnXqRi/Vx152vwnP0U 1viQ== X-Gm-Message-State: AOJu0YwSrIUmyq2FDMjeNYaNi/bDFoOccmmriYRGDrRiWPLkrKAx5wBp Dn6SCcHf+ctaJNiB4ZrcWQw7lHLa/oYfp198ZVhoetQj60rhJGEjYHw2Fc+x891klNy/g01Sk9l w X-Received: by 2002:a17:902:db0d:b0:1eb:5291:d3cd with SMTP id m13-20020a170902db0d00b001eb5291d3cdmr3092382plx.49.1714574274409; Wed, 01 May 2024 07:37:54 -0700 (PDT) Received: from stoup.. (174-21-72-5.tukw.qwest.net. [174.21.72.5]) by smtp.gmail.com with ESMTPSA id h12-20020a170902f54c00b001ebd73f61fcsm5751573plf.121.2024.05.01.07.37.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 May 2024 07:37:53 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Pierrick Bouvier Subject: [PULL 14/20] plugins: Simplify callback queues Date: Wed, 1 May 2024 07:37:33 -0700 Message-Id: <20240501143739.10541-15-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240501143739.10541-1-richard.henderson@linaro.org> References: <20240501143739.10541-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62c; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62c.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 0d0062448b..b679a22bae 100644 --- a/include/qemu/plugin.h +++ b/include/qemu/plugin.h @@ -67,15 +67,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, }; /* @@ -85,7 +78,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 */ @@ -107,7 +100,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 */ @@ -136,16 +130,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; } @@ -162,7 +149,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; }; /** @@ -175,22 +162,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 May 1 14:37:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 793733 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:54f:b0:34d:5089:5a9e with SMTP id b15csp791565wrf; Wed, 1 May 2024 07:41:20 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVIDIezZz/Pd8dJkA1V2CmCPoVvSYTm/QiFjtEgyzQqxCZcMAGmRWxabNiOP5diGZi+JceKqogwmnQvlrIAJg8S X-Google-Smtp-Source: AGHT+IHFtxkZbvWMHClLvp90si4M+gsibq+SHxpWpiXwG6bkoggl0nivdkCKOuuRh6me5qoARrM4 X-Received: by 2002:a05:622a:130f:b0:43b:248:30e1 with SMTP id v15-20020a05622a130f00b0043b024830e1mr2435391qtk.12.1714574480306; Wed, 01 May 2024 07:41:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1714574480; cv=none; d=google.com; s=arc-20160816; b=hEV4uDzycyyWpGrQqxmiCTKT46BWhoaItnT6FbXUJ+Mq8TDCtXz2bDp1ziV2t+FsMl oNuP9R+4rlNMKOWsOA/9h8gMYH2T7SUMBrA6y+2ENnnYtEWmbyNYeM3XnDDFDoj229uH gczcLownixsAV5mc6wU+6S9Rj46ZCftc2EFieWiPZ3xDnWXHAxdrKLAfM0EJyC+95pz/ svrVMagHhl0adOsbNKZKWKlYqcSgvkBrWLyMFYDw36P1kUlG7cS1HhCrlqCl+rNiJXr5 90dnyr9l8wT1GwbzGuKNARLZBKWkMok1x+Smn08PbsK4Kqu1NQ/4xm5i8P3WECquqz9j dk/Q== 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=kmUmHZTNzNBMvvIGWmKaQ5oKXKcaA0ppcXgwQeTRE2E=; fh=vm85eyWrvOAHduw3sqEA+cYBqvHB7M0MHFcRJg7VWOo=; b=NU0z1HxumakBuDWkF1DApIMPHX759CEAAg+eusnk/UCnyMolJJyiEPpHxBfYXZAZ27 O+Sz6vsPYO1LiO73LeUIDweXAZT0bjEN44hKmEoRY/1kvjWAvAciNTxUVi5Gb+V4RQE/ /i7p70o0LUiFsG31dXLijTYaaxNRIwsKfFi4ATPvNxW/xtO9CMj4wXPsA5ZsqinK3rGG gLgdONQrexdsHRwHmC89mx30vftb0jkzP1Yp37dGF+35bGIbM+ijD8OuYzcLn67+25Zt zSArBqTOUo1M5/gMNI5Oc+nlRyD261lW5cGJeG6XVbh5nrd1T7XaVVypt0Tgigb2NJee Hp1w==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=IP7uYznm; 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 w16-20020a05622a191000b0043c9803c552si683929qtc.794.2024.05.01.07.41.20 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 01 May 2024 07:41: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=IP7uYznm; 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 1s2B6D-0002ku-93; Wed, 01 May 2024 10:38:21 -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 1s2B5q-0002hL-If for qemu-devel@nongnu.org; Wed, 01 May 2024 10:37:58 -0400 Received: from mail-pl1-x636.google.com ([2607:f8b0:4864:20::636]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s2B5o-0002AV-Dc for qemu-devel@nongnu.org; Wed, 01 May 2024 10:37:58 -0400 Received: by mail-pl1-x636.google.com with SMTP id d9443c01a7336-1ec69e3dbe5so12751645ad.0 for ; Wed, 01 May 2024 07:37:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1714574275; x=1715179075; 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=kmUmHZTNzNBMvvIGWmKaQ5oKXKcaA0ppcXgwQeTRE2E=; b=IP7uYznmdhLf/uUTUbA+D7r3jkMCKsUwfvjSW55jlB/c/3yjTgntNXHww0170KQZrn gAJr6v0AESLtORYf+/reFDiqWFCwFityfosJhSS1qomvAycGLzudZ7C1bV8wgHAHN2o8 TtQeSvtEDaW5RkNeJZ45RcM9ujwkPmoP3tmajzL7COnuWZybUk6CyNGvkMCJCiiDLxpz DoXa2aGZFelFFLspCWAq/0SSVaXE40e5Asy5+s1miCJwZ+SmmeWuTOYwLrdn8y3q+8+K K5uZ1A92fBhoWiK9CL/Wxb0Ukl92E2rCOpPxlKCHVDH3v4jakMMAAC/Nn/sw9uqaIkS5 IZLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714574275; x=1715179075; 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=kmUmHZTNzNBMvvIGWmKaQ5oKXKcaA0ppcXgwQeTRE2E=; b=ht3/IFW/4238z7DXDIf5YOVEPTTzFlDIUBUNBx+jN48vv6CGdE2lRkv3wpl9CqxMe6 8OyjzBRccxbf8XcxG3mQMXq0b8QqckWIiCj5nqZwKd5hogi2KHlcdyPcr32hM6YXrU0C PH5moBmOgrfzyNxQTmB+IB7hAdQEvaF3NrBE6vSBfdMa+kghoVHLXMyuMZ6APUWc4UCJ ukr0a0b67eLLfSPpueTVZMNZEhN28bglv8hQXSn6mo3Q9vpWETnV3wlRvgkUoXzT9XZa V565LESWvfn1aoIcUrmBcrC86eVZLyUUlEaamOIf+wUeQ7nPKYq1nvv5HQVW8qYZUPHv LQog== X-Gm-Message-State: AOJu0Yw7uffGRFqraSCcffZeo1YuU0dJWzRyMGDOX8M/tZFEsFjCO9hb 7sp91zeWfmXHFvxFvDvVvRuvGPWK6UP0KI46Qfa0l0ZUvMxGmeDBX6Lc9wsGwKkKZ90URgpaAms O X-Received: by 2002:a17:903:2c9:b0:1ec:a6e4:dc9c with SMTP id s9-20020a17090302c900b001eca6e4dc9cmr1648750plk.50.1714574275156; Wed, 01 May 2024 07:37:55 -0700 (PDT) Received: from stoup.. (174-21-72-5.tukw.qwest.net. [174.21.72.5]) by smtp.gmail.com with ESMTPSA id h12-20020a170902f54c00b001ebd73f61fcsm5751573plf.121.2024.05.01.07.37.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 May 2024 07:37:54 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Pierrick Bouvier Subject: [PULL 15/20] plugins: Introduce PLUGIN_CB_MEM_REGULAR Date: Wed, 1 May 2024 07:37:34 -0700 Message-Id: <20240501143739.10541-16-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240501143739.10541-1-richard.henderson@linaro.org> References: <20240501143739.10541-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::636; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x636.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 b679a22bae..f5a08b1220 100644 --- a/include/qemu/plugin.h +++ b/include/qemu/plugin.h @@ -68,6 +68,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 May 1 14:37:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 793721 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:54f:b0:34d:5089:5a9e with SMTP id b15csp790714wrf; Wed, 1 May 2024 07:39:23 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVj8mSXHLv0GyGdZNCkhZR7YwEjBmVj0ZcwQctyZ6OOf7z1td7ki7Ziq4lnw42x80FHBUbKqJjTrtzBByxK6rfv X-Google-Smtp-Source: AGHT+IHwkhhLDCgIhHafTNaik4+4AcSym57AYDkwh9za8UyvKiK/1xSnzSgOaredvg+v8v1KllGq X-Received: by 2002:a05:620a:8319:b0:78d:3b3f:50cd with SMTP id pa25-20020a05620a831900b0078d3b3f50cdmr2507989qkn.65.1714574363494; Wed, 01 May 2024 07:39:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1714574363; cv=none; d=google.com; s=arc-20160816; b=R+t5uHK/s4vyfX8qI4tAD+Y1ZWCu2GDKWvkAFrPu68B9hfYnBCcUetgM+UVJgp8ACa oCJEHGb57fajHx2r8A8V/7Mzssns/XJT3V1CpB9VSyDAqSCK7gCTW431vIJthAQoEgv0 XC8+R/1FEY9d7yfywjUapg0Jn+rHmta0yBe0ANLWJqzDkcT28zrE7xIfnPMVJ7BLP64R xDOm+rdejhYcgv/QPEaHo02KZ66vTdlfqiLnuO6YvZ5kPj7H3NpXyqqppGDaRIHwezuy RshHSVkc04+AH5fN2j2q3kWm9QgeYBZKnvSQzoKGj8VJlewoKDI86QwdfcjU6PzkjVak yPcg== 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=OMqu4I3VDo5VH0NHwXPVejBk+9hwoDGlyxitKQKItks=; fh=vm85eyWrvOAHduw3sqEA+cYBqvHB7M0MHFcRJg7VWOo=; b=nNXl3lw1DAdZbr2yefqvsRvF0e4++GUft9G1bX138RRbDU5Q5r3g8xD+BxFigGVgqK crlNZtNQMcNqdv9P6LbmJtYUW+fcKsa9QtcgrpH/PnPXPsFfhApwhTjZRRJVLbG9KPFi SpfKanHQ0ymSkIpKbtyPLN9hGesc5SXWkZI4WGqVPGZUhUDcXFIMwnPDonW1eQ/GNkWL g1F+HHtcQkPTVW0iQ7OoHVmuGFNgUi2+jX2taUi0Dyp4kwRCFy/ldCMIY7GGqsZjntRy Zli8A4xv0GJSXBhyHhYHjvDoZNqpW3Jn8nTJevKMz+o5zBSiLS1rv44cOFcfeXLsUeOk OdAQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=rGi1tQGS; 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 d18-20020a05620a137200b0078eeff06f62si30897481qkl.378.2024.05.01.07.39.23 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 01 May 2024 07:39:23 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=rGi1tQGS; 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 1s2B6F-0002os-1U; Wed, 01 May 2024 10:38:23 -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 1s2B5s-0002i4-5C for qemu-devel@nongnu.org; Wed, 01 May 2024 10:38:00 -0400 Received: from mail-pl1-x62b.google.com ([2607:f8b0:4864:20::62b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s2B5q-0002Ak-C9 for qemu-devel@nongnu.org; Wed, 01 May 2024 10:37:59 -0400 Received: by mail-pl1-x62b.google.com with SMTP id d9443c01a7336-1e4266673bbso62108145ad.2 for ; Wed, 01 May 2024 07:37:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1714574276; x=1715179076; 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=OMqu4I3VDo5VH0NHwXPVejBk+9hwoDGlyxitKQKItks=; b=rGi1tQGSiOrGgSMX85qtwsyqZDaBDUQtCp2bg9FD3aWv9/Xi8MFl6FvfFNhoPX7Ylh FbDc7PXHRl22poZZDVyYG7hirGHWTqWGVtdlWQKDmWGH/NLrj5RRnSdv/Xs79I8vC5hN xiHNWjso4EC3nq36FoFhsgWEaoofSKexlgXSfonR4KXlF413j4v5lPCQ1uDoEataA96Y FG9nemIlwJmEkO/3L8Dy5GbcsRIabjc5xKuXjnHoSlgmq1mw9fbbKVVETNawes4vjFN2 x/uraRYg5tq49/iJ5B/inH6WmeFRULurR4mYXwn8ilr2exfIa1paKO8vR1YLyBY6YjF/ 9P0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714574276; x=1715179076; 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=OMqu4I3VDo5VH0NHwXPVejBk+9hwoDGlyxitKQKItks=; b=OyiZVdbsOgn31hCw211OHorrBtRMzfMFH0rasKpCkdMPXWoPTvkoV6sqBgiHg57ZtB DbdSMIhAQsWHLUu1A6LW4TxnS2wADu32fSMHEtAX08I53rNGkvDtfOmD/2lSLM+m9kSE IGbLkLIZfRvTOiMQPjTLKyn5IdJ3Wy5aOjtrYontJhCDvQdWORGgfys9Eu2b4he/L2tQ LDK/aSCO2SL5cmNdw1D1lAtjmen5Qc5mQvlouD0/F2V5BeheqmFv+k1nGBBlUaDhQpp4 anTlsvswlsrfSTkqAt+V0W0FsHKlOTg/wsE/SVDiyBNMKVqxiAbh9SqGSnFbv4Wmqhn1 glsQ== X-Gm-Message-State: AOJu0YxQZYarU8dtc3J8PVn1hgx03UIpmrHT7YhAA5kvHBxyK+kb7aAT 4FWdh49w4M5465JWxI9IHCcHEpgjF/XZpXjCpUuUhmMmMFm7EhAwPTTG/6jS+bfWlQmjcTGrxQU I X-Received: by 2002:a17:902:ce85:b0:1e0:c0dd:c5eb with SMTP id f5-20020a170902ce8500b001e0c0ddc5ebmr3210516plg.9.1714574276025; Wed, 01 May 2024 07:37:56 -0700 (PDT) Received: from stoup.. (174-21-72-5.tukw.qwest.net. [174.21.72.5]) by smtp.gmail.com with ESMTPSA id h12-20020a170902f54c00b001ebd73f61fcsm5751573plf.121.2024.05.01.07.37.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 May 2024 07:37:55 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Pierrick Bouvier Subject: [PULL 16/20] plugins: Replace pr_ops with a proper debug dump flag Date: Wed, 1 May 2024 07:37:35 -0700 Message-Id: <20240501143739.10541-17-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240501143739.10541-1-richard.henderson@linaro.org> References: <20240501143739.10541-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62b; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62b.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 cfcf9122d6..d827c6d431 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 May 1 14:37:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 793724 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:54f:b0:34d:5089:5a9e with SMTP id b15csp790869wrf; Wed, 1 May 2024 07:39:48 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXPdHg8IbMp0RyjrmNZUEZ6PTXCPiuRUQumuiIBZQ6XLXDTpEirwPygSZ+TaKlsG0Oyb7QfQND5p3n0UoS+PhyB X-Google-Smtp-Source: AGHT+IHxmtBYNJdp7U8Vy0yrvIirhhoiDj62HJ9frXPQbk+1xCg5S3iQeQAXVhFjo3BKYqCLh8Cb X-Received: by 2002:a05:620a:9cb:b0:790:b6e0:e1ac with SMTP id y11-20020a05620a09cb00b00790b6e0e1acmr2807749qky.6.1714574387874; Wed, 01 May 2024 07:39:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1714574387; cv=none; d=google.com; s=arc-20160816; b=hqN+34r7U1FfaN70X5TflpHrTs02xmRo+J13B9V3cpi1tLBplj9Zfsa+6UmV8+OiSn K5ZYelbkHzF+2P+comCQB0LCqGAryzS68KHkE44/rBqjfztY8D6gbvaocsI9syG7dEkH qAcyIhkvdSMKxESvMmT4kmRwoJYy1SahBR/cjxYXqV+fAUbP6RRrO2fLX5cFGBE1gt+V 5E91c6XtQk8VO3RDeh/ZnSOw67WcOmJTbpaLLIfss1YaxEsXYJ2wG3yYE1EGFtRKzOUh OnOUu+zxqPhIwaPnKZrlzcRTwtJp4ueXogtAV93yR2B/tAluHxnnVD+BdJeGH+55Fe/2 cNEA== 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=QmGCfYxLN1qyg+gMBBo6/0OgE38RRYtIp301aF61ho82OUdKd3dLwOzxp71Pdj33FZ 5wBl7LMkndO+OjiqcS/zjdt4SQYrXMR7Xpfqi+yLliC1jE+jfCTk9QXxCNN44tKYckxe Sf9WckCzy8w6t9lrQHetdQ1ZRT00WK+w/UBYhwaE5DpSIE9SI/0gtgP6DfSlmg0temTo I0pGuiXnUugVt2yRpJHUtopgWtY+Xw1HbJN6TYPoAofyZWH8esG/DB+nmRr8az8LV/Yw OuK75vdBst9pTZI5K2KEmsHzkEPZ4qrZMVi5YvQdjptX/u0E3s552POnRSRyV/YUa2oy L+cQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=vTCB5tQv; 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 pj17-20020a05620a1d9100b0078efd8dca5csi29507402qkn.276.2024.05.01.07.39.47 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 01 May 2024 07:39:47 -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=vTCB5tQv; 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 1s2B6I-0002wR-GY; Wed, 01 May 2024 10:38:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s2B5s-0002i3-1r for qemu-devel@nongnu.org; Wed, 01 May 2024 10:38:00 -0400 Received: from mail-pl1-x62d.google.com ([2607:f8b0:4864:20::62d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s2B5q-0002BA-9u for qemu-devel@nongnu.org; Wed, 01 May 2024 10:37:59 -0400 Received: by mail-pl1-x62d.google.com with SMTP id d9443c01a7336-1e834159f40so54901245ad.2 for ; Wed, 01 May 2024 07:37:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1714574277; x=1715179077; 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=vTCB5tQvM50YpdBeVz8D6pebQI80Q+7T455w0ay2f0krxCo2D/Dn6uyWahXq3s0+EN 07BGdZzCraE2Eki8QbZXK7omRAKirB8k+DRfGdPgTr0NEELmoU9LQwhupvmn+0do72eb Zbpq/st4Y8Yvy2Gq5kFYMxzZ+irkdkf+7WlLCJO9+tHb9SNcsxjWYUeHB+TC2AAtWr+C js/hrmHOpigU4H/F2Mv+xxN7UCXvQlcrX0J20BDUgKeHzx1VmQj2Fnwx/fhYkjv1gCiE rV5EmG1CDnEuhpuDjGLGV9aTrVeJZKbK7OrYEUgPRrkLG6keXO/mbK+cg5Lo4/JTU1zE VDrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714574277; x=1715179077; 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=ZsoF6Mtw2UH8lTsY2vl19SAi/MpDmtt8L9Fm2Wv57nQr4OMEevev6CUZEKfHLrYMwp anKfkYtAxcBMB+COW1cwKZZRQPcAOc+hgZORtmkZML0mr0yQ+1c/YBVlH8VMAPv6nJ3K VrFL7v3jpET6hjbs1HqqWp1FworGFJv+VoORRfJoHcx04H6xljGZm5f81qpQ1GoHSEXe vx9HUf2B1nMKoU7uPLbfppOAT3AAjnh3ZlB7GQjKS8+UohKPYkKMkLABayLGCh+rb73N LzZNvP8ElsrNtcJ5JLb8ikZnnUTmdHh/PXPffNjy/Evm1Z7oXZY+EYRnLypDsefMO/HP 0ZUA== X-Gm-Message-State: AOJu0Yx+qQcwrETPXYHQmwD87cmgavoGlznlabpQbySiRw565O4URTpH xDwU6PsFJjR8ozONYH8U6JbM3E/xpSs8NImnGYsqI3IKhzcKM4q743YQeNMYEQc2jYZE6IgT/vv j X-Received: by 2002:a17:903:1d1:b0:1e4:d548:81a0 with SMTP id e17-20020a17090301d100b001e4d54881a0mr2275720plh.67.1714574276973; Wed, 01 May 2024 07:37:56 -0700 (PDT) Received: from stoup.. (174-21-72-5.tukw.qwest.net. [174.21.72.5]) by smtp.gmail.com with ESMTPSA id h12-20020a170902f54c00b001ebd73f61fcsm5751573plf.121.2024.05.01.07.37.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 May 2024 07:37:56 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Pierrick Bouvier Subject: [PULL 17/20] plugins: Split out common cb expanders Date: Wed, 1 May 2024 07:37:36 -0700 Message-Id: <20240501143739.10541-18-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240501143739.10541-1-richard.henderson@linaro.org> References: <20240501143739.10541-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62d; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62d.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 May 1 14:37:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 793728 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:54f:b0:34d:5089:5a9e with SMTP id b15csp791252wrf; Wed, 1 May 2024 07:40:35 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUTVzx0AQHfofrWuz4UyeXV792rHt2AxE3R5DD2irR9Qn0J6/kuVF4rlrr9Q2visbUXXyFbiItU176GPp9rFZor X-Google-Smtp-Source: AGHT+IHMo/tGtXKF+tRhp6pnWRD9jJxCmodNzz/KhsNQmO4gxi33g498L7XmIIazANIDlXqV0E73 X-Received: by 2002:a05:6870:390e:b0:22e:caed:b1f with SMTP id b14-20020a056870390e00b0022ecaed0b1fmr2969236oap.2.1714574434822; Wed, 01 May 2024 07:40:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1714574434; cv=none; d=google.com; s=arc-20160816; b=Oa2Kvy+/xnUwKPcejuAJ7rGF9ZEmi/oqbjGdhSH1VYOMVS5/4h57ic+PwO9QedgMm1 OiNnQk4q52Kh+kDWbRduJ+2mKnv2TNLqmqiOF+5R7xAb21ySm2REx61PajqMuoxYtPDe M8m17lXGqJbTzHGYjCilPPdCw4iDwaJi3CYHyNm39pNV6Liai/K1Ar3C2+PjNzI9co6s agM4bkncWo2PNdUkvjVOwLIK5vbYyLF3DLfj96vL9JxfOYcub7deTCAD+RWfvFOE9CNc H5DJtp6U9YPY9do4llgAlrnLq+rCfVM+/pNulA33XzRtd+GnSeNXLiNvPRQbszIEmFwW t/Cg== 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=i8VOItWkFsBquzhiz/l7Y2hIgNzVUVvjoEVZSZUA8wY=; fh=vm85eyWrvOAHduw3sqEA+cYBqvHB7M0MHFcRJg7VWOo=; b=OL0tzx17lU212N2vhUFPyFUszA7ysIEbDB0CH+9hfZsQ3ahVRfEptmNscErtQUlnl6 W+j2AzTpKYohaY5FrYDJpB2NFksuFy2xjducPo6RqiJ2FFleRL+BkILV/tY+vfcHn69f d2WeklHt/sQvWQexqFv9ASftz7y+uS3L6ev6QZ6ZZziwjdWUfk0tYl/aBZbJ6X2XbByP eCOdHt/YdZafwFyXDh3u38Wgu6h1+4VXKXMfra17hzFlShCwZox4l1YRaAayd+ZSPv85 LCcNHr6sc8kARp6R6CqCiUEfJAS7C0TvoSFeU0KISbov/JZlKIk5ML4Ly5UJ/z/3B7MV yW+A==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=H7+ZAyIL; 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 f5-20020a05620a12e500b00790fd2b6197si5615801qkl.199.2024.05.01.07.40.34 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 01 May 2024 07:40:34 -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=H7+ZAyIL; 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 1s2B6M-00032L-EG; Wed, 01 May 2024 10:38:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s2B5v-0002j1-Rk for qemu-devel@nongnu.org; Wed, 01 May 2024 10:38:04 -0400 Received: from mail-pl1-x62d.google.com ([2607:f8b0:4864:20::62d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s2B5u-0002Cb-2z for qemu-devel@nongnu.org; Wed, 01 May 2024 10:38:03 -0400 Received: by mail-pl1-x62d.google.com with SMTP id d9443c01a7336-1ec4b2400b6so15852765ad.3 for ; Wed, 01 May 2024 07:38:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1714574280; x=1715179080; 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=i8VOItWkFsBquzhiz/l7Y2hIgNzVUVvjoEVZSZUA8wY=; b=H7+ZAyILik/agYQQPephKxCc/UzAY6YTsy0NL//xa2bYVM3f8TI+sjGws++OEqaCm6 3lMDVtYzvda3+X421DRloF1q9pkz/RLY89/gNGQz5e1WCYXk4MoOgfJayoziILDgQjiE nlRVPKaqAGFBFum+Hig5s0QGlpfne20MAdPImu6J0EAETFrJcEVwHh14MNHVypfT+HQz dMJWobyMyEbha0Xm4SGEPFWHR0tnvuaxIhSqZht0HDb2eEzJ/tPT1GWSZXP0gup2PHV3 WhjqTn0jTxu+AHC5wM/SgiJCGs1w4+HMp6dcp7AJ3PMMO7E50oJlnG9Jbq7geN+IbLNq h6BA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714574280; x=1715179080; 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=i8VOItWkFsBquzhiz/l7Y2hIgNzVUVvjoEVZSZUA8wY=; b=rwhO+ePRbRPZ2dz0gd+sqsCcDHXcqI4aFc3OEpDI77BkMaNl2Od37rHJRFr10xYK7O 187tWH0dJRsp1TRQE2vUNDgIh50EOa2Iuc/E6gNelkcKJjNANbmTc1mkP4qew6sZ6Az3 bdqm+j9tpytixAYh1AcVxqGA2sVmc0hbsh6IqNh1+8KdPpxFKDTiKhqVuiRGErK7nDiW /J+ED+MKkS+0RLVy5goAZIf4dHhcdQwkSDcjpGDx/GYX4DahnUSoN1HSAoJtGb6Luqsc NBm9QadAgWC5Br5q1hE+UPEeIonCxxnzOXUVAU9BNDRvsJPuyRD/sfsJ/vBBZOg0oigv +fMA== X-Gm-Message-State: AOJu0Yycbmdx8RjQYCsKCToqvhPuxeYOnpbdPTedSKotxUAthTPTcCUO T+slZXxjdX7F7FJijEs1ItkypiFMlBngqJf4e+HLXb5oTcPI05Ykn6D47ktN9xVL/Q9moE9RoYA V X-Received: by 2002:a17:903:428a:b0:1ec:53de:a527 with SMTP id ju10-20020a170903428a00b001ec53dea527mr2271451plb.59.1714574278584; Wed, 01 May 2024 07:37:58 -0700 (PDT) Received: from stoup.. (174-21-72-5.tukw.qwest.net. [174.21.72.5]) by smtp.gmail.com with ESMTPSA id h12-20020a170902f54c00b001ebd73f61fcsm5751573plf.121.2024.05.01.07.37.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 May 2024 07:37:57 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Pierrick Bouvier Subject: [PULL 18/20] plugins: Merge qemu_plugin_tb_insn_get to plugin-gen.c Date: Wed, 1 May 2024 07:37:37 -0700 Message-Id: <20240501143739.10541-19-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240501143739.10541-1-richard.henderson@linaro.org> References: <20240501143739.10541-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62d; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62d.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 f5a08b1220..18062528c1 100644 --- a/include/qemu/plugin.h +++ b/include/qemu/plugin.h @@ -129,14 +129,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; @@ -153,37 +145,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 May 1 14:37:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 793732 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:54f:b0:34d:5089:5a9e with SMTP id b15csp791523wrf; Wed, 1 May 2024 07:41:13 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXxy678n4ktupkTNu6hAj3INz111Bqw2dSCtIwPqPPxeluTgcIJdiTWtp0IyjcO5OvBfJzSWZZCOwrZrMa2rDX3 X-Google-Smtp-Source: AGHT+IGWRMQsW6ZND2Aa1pMKl6e6wZ8x5C1w1LqwDgyrD8xEenkJAwhYrQ0dEA0GNyo5w7vf2IJG X-Received: by 2002:a9d:7549:0:b0:6eb:7ce8:3e72 with SMTP id b9-20020a9d7549000000b006eb7ce83e72mr2812515otl.7.1714574472895; Wed, 01 May 2024 07:41:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1714574472; cv=none; d=google.com; s=arc-20160816; b=CKglF+EbBLz7E4PJQ/YPW0Q6wWSz7t2MksALy/V/x7z+Pe3B4FbJT+IsKdUAJ6L+TH 1ycQqjVqgDh+8F/bnuh5HTgd769rlf9ABYQ4Mfxju8OMeOuA4wasnSYgba6nFu+dGqUT xn9G4l6JSd76S3K46JXd7FNce6q2rWr5tp3UksEplUGkmAUyjFpAuBGiIf7yvtWAFBFx LVDps3yDVEkVYPnmDfGxDerFR+cF3jURALKlM7fFkraOI6LEj0ibGn5nRuue0OUGQgFW QHMDTJUoveSOh+QqZ0rI85eOOl6GkEKxwdroHGtuMejWyonUph9LN+YPpuBwBbOIREEg phlg== 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=ZpRiUpm60TCK1vhGBz7ZTZgR3ufYBtBfhMorPl/+66ImBQlHHmm9lYj04rDvC/2iag oYVq+hF/GiOfHOa3ERFMWr+p1zmTlcVGZt7gg65bf0zJ6NdXWFstbbUAbqu+jl3X+8zV EwdLR6syK2tAYV4lnEq1qTGdHcPFsJsF1EUSNxTVZPomvOk5byRkC+KHqExr93qdanDb LsQabm9YvXZjf5jx57i7K0n/6bHN9Eii9AUiYasOnG+WIesNAynSh0aMvlWQMYsxzU2U Q3x1bs/MxBoxh9b74RiGUcmCjBCNHoJ7iG+g7aqhUMFZeBXM5zB2fzzQRPaAo2s9lMZQ 5Sng==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="rsygncj/"; 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 ow29-20020a05620a821d00b0078edc1fa0fbsi31097358qkn.62.2024.05.01.07.41.12 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 01 May 2024 07:41:12 -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="rsygncj/"; 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 1s2B6E-0002oC-QI; Wed, 01 May 2024 10:38:22 -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 1s2B5w-0002j2-Fu for qemu-devel@nongnu.org; Wed, 01 May 2024 10:38:04 -0400 Received: from mail-pl1-x631.google.com ([2607:f8b0:4864:20::631]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s2B5u-0002Cp-VT for qemu-devel@nongnu.org; Wed, 01 May 2024 10:38:04 -0400 Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-1ec4dd8525cso14160435ad.3 for ; Wed, 01 May 2024 07:38:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1714574282; x=1715179082; 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=rsygncj/EIs54VAIMitaOr+b5vCZO0u/NZRd5gZ8lT/EO5bHydgJR75xk05soDnZUL 2NPkbU5BcbWVS5MuZBL0uBzzFkzsxqvVqCY6YW3YUwN02u6uMEgTh9bw9QNZ4SYr1fvi SP/fPEY5dxgKAopcJZL9gIJwL5wH4aLZ/MrPn4gxXJBRciVoKSBGyR15FTGlLebOC3Kb sNtNMDtpcHdx2mGwDWjSwtjQDTn+K4GQR8MJWMfIp0VOtWaXsFS0IqOGxWXMWLCoiKcf W9Q4SUw7kI69swJAEPCA2WOmlncju1wnlLZlEBq1KzNWnrPhvn+bOMNGyHjWSo5H7NOH k2jw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714574282; x=1715179082; 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=mIsESqxKiGZR2cIlq4UGuM7t/4OROxu3Hvvf9jYaeAGOn/8G430B897BETXHkbug1C CFp94FDrttauD73UDeRirk5LKasYQb8qvmqMVFp0lii/MFWywtOyOqTrI72b9IeAnpu1 iVSqeE7iIQd9L0w2tFIOgO9ga+uOVGwRTI0/xRyEGrI5wT757PeyHIWoRY9c3blEmSzM 2aEbZ+cyfRo70fnyYs3espFcifQIWRogP4FKCEudkrS0LSNfj6HZ9VrQTOyyQULX4ap6 0j2+90e2lShU1d8+8/c8yGtELJxFHNXnfm4bUo+H4AqlxKfwJjYtbVdnJbctNohV/yRd YO3Q== X-Gm-Message-State: AOJu0Yxef6cxCbNs6cIg19OaiqoRn191XwZhBtemkbIagS4h2aSGaxkh 8zCa1JAQFKoQo2Vjlj/CsUr4avMamOD5MAdzAw9WTqB2cmoMC+HuUoPqGx/WcAV/867CaS8p+aI t X-Received: by 2002:a17:902:c185:b0:1e4:60d4:916b with SMTP id d5-20020a170902c18500b001e460d4916bmr2355319pld.64.1714574281733; Wed, 01 May 2024 07:38:01 -0700 (PDT) Received: from stoup.. (174-21-72-5.tukw.qwest.net. [174.21.72.5]) by smtp.gmail.com with ESMTPSA id h12-20020a170902f54c00b001ebd73f61fcsm5751573plf.121.2024.05.01.07.38.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 May 2024 07:38:01 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Alex_Benn=C3=A9e?= Subject: [PULL 19/20] plugins: Inline plugin_gen_empty_callback Date: Wed, 1 May 2024 07:37:38 -0700 Message-Id: <20240501143739.10541-20-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240501143739.10541-1-richard.henderson@linaro.org> References: <20240501143739.10541-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::631; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x631.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 May 1 14:37:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 793723 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:54f:b0:34d:5089:5a9e with SMTP id b15csp790859wrf; Wed, 1 May 2024 07:39:46 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWMThPVg58gMHiboIB1GXJtHnG1AXdAp3joc1mjA1mModLSb/arwfOhzSEL+i6ynjOIqyhYwQ9KxJ9N0PHCIgcB X-Google-Smtp-Source: AGHT+IGTrZRbS+XC+byAmaVmqzUFofk6YJW6HuKLgDZq5Wr0F1tclLac+rJX+srUnLoDB5MijS1B X-Received: by 2002:a05:622a:1a1c:b0:439:85b8:f71d with SMTP id f28-20020a05622a1a1c00b0043985b8f71dmr2425018qtb.58.1714574386417; Wed, 01 May 2024 07:39:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1714574386; cv=none; d=google.com; s=arc-20160816; b=N2TW+fwjCyQue92nanZsK2sDqx62hqpIYbR23Ai89uxyUMo2alftZOO1mH9W3sBlNg 5l46R2FDcjVQH64hygfxD0HNgcQ08Up1ehfI1aR2+Z4i8kkfa324Uc6dAiBKGbyrTpev RDfTL0+ZHsa7PDcIDiuwCLP15942kdt0AiCkan85j9ETeJB8VGAqXN2bCb33ivI8B9MK gzJu76pOVin9yr4Nq2or3KzpHgyCX/RwAu/kFlbLyn2kE/6nEdGtZKFEmomFfw/kezwT wq5f1p58IH1BmIF7nMKrx6HJNMaAMx5WU2nGoJl1b4voucT035ZJ81dZ3zDh3YKO6AV9 vY8Q== 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=q08LJEVt82GQCtiMQ26RPXaFpwqSPYtC+bTfx8EGKeyJEwSjtdFJ7fF7V8g08Nb0IB iWpBCSEcG/bBXX2HU1AKS6Nvh9Ma42gUp3kOCtu3t+eC4l6eert48tgpRM0rTj7/Zhyo OT5NX6mINptK/F89OmkfLuKelbnGanE5iJlMsRLg61Awde9rL+5TWmetg+l0V7iAdBTX X6FoF8O78sBReUBpgctr0JrVI8QB1yE1no1rvEKPCIa8VOrzAw4mNsXSmbNY3b52VZwp Y7BXxS8Hojfux25k8SONlBksay988pH00CByxh1wq2cK/24S2UzxBhETmHrD/AzjAmlW sZ6g==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BprKGdB7; 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 d1-20020ac85ac1000000b0043ae7cf8673si7278980qtd.672.2024.05.01.07.39.46 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 01 May 2024 07:39:46 -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=BprKGdB7; 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 1s2B6N-00038Y-KZ; Wed, 01 May 2024 10:38:31 -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 1s2B5x-0002ja-Kj for qemu-devel@nongnu.org; Wed, 01 May 2024 10:38:11 -0400 Received: from mail-pl1-x62c.google.com ([2607:f8b0:4864:20::62c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s2B5w-0002D8-2t for qemu-devel@nongnu.org; Wed, 01 May 2024 10:38:05 -0400 Received: by mail-pl1-x62c.google.com with SMTP id d9443c01a7336-1e50a04c317so37749165ad.1 for ; Wed, 01 May 2024 07:38:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1714574283; x=1715179083; 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=BprKGdB7b9NZil8ImgEMzUk1wSkPlY2rjadiv2XcVGC/WRHeiu3Z0rTvBKsdeEL034 UNMNohEzVLJEr/IPmb3RoeopMBZ+mkh8HLK0mH4QOh+skPMulncaqvlvq8g5KjmUG65/ XiUYCqf1MW2QLKGdWi3CXNOhdCDOaTunOY2XuXYR0kaLc/bHUVMRhSPe/KPlIJxp6duT c+7HtRIrSqyDcs63sNThEoWLAsZ+8saIZxe7bg1FZb2t1fpYMLjpAnV+NVCi2ITA7Pph 6CUsAXdGKWnbLcMxs20VKg2RYvTrpXWOEAPfXDK4MWVL/XSqP47YePFyuNFUxC0o/0lM a1DQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714574283; x=1715179083; 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=AhVVyWyHQ9XKxJ+y/VG1yu7diQ9D+1cVKIT20gI/9B1jLNnOExZAY3ksqkvbmGNv6k UYfoIwGhy7O67wQ8P8pcHXkN/Gcp5n/bLS2UgsBHCXRpN4XgykFbXn6AzdH5O+eDEx2l HhQUCrK6kf56jC1mv6j4YyL7EhA8yAEsy07VGiLVGROLPqkCjVaxVEont2GtblK+jaYv bYhs5H8GDXrZu82B4SkB77ggix6UVg3H/kiyrjRd9gHvNhY/m3qwER0HpTdORHMzwt3Q 7hqutOuLYD+6xrDw0mbN4xp4ZZ0GoidKIwGVbNHQMoKQPbzDVV7P9tTbRVTVunQWMXFy nFXA== X-Gm-Message-State: AOJu0YzFfuTkztYpZD3ogqz7wyl3QMvgeA6OW+/o4cFLuB7ZJt8hSajY 1bH3kLB2we3vcb2w5/rE9OW6lVbeUKavpPi5vhpW4QO6+6hoakKuZKyFyGK2l7WN8VB0wNuucoh + X-Received: by 2002:a17:902:e892:b0:1eb:c3d4:349c with SMTP id w18-20020a170902e89200b001ebc3d4349cmr2786402plg.30.1714574282800; Wed, 01 May 2024 07:38:02 -0700 (PDT) Received: from stoup.. (174-21-72-5.tukw.qwest.net. [174.21.72.5]) by smtp.gmail.com with ESMTPSA id h12-20020a170902f54c00b001ebd73f61fcsm5751573plf.121.2024.05.01.07.38.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 May 2024 07:38:02 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Pierrick Bouvier Subject: [PULL 20/20] plugins: Update the documentation block for plugin-gen.c Date: Wed, 1 May 2024 07:37:39 -0700 Message-Id: <20240501143739.10541-21-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240501143739.10541-1-richard.henderson@linaro.org> References: <20240501143739.10541-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62c; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62c.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"