From patchwork Thu Apr 4 23:05:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 785849 Delivered-To: patch@linaro.org Received: by 2002:adf:f001:0:b0:33e:7753:30bd with SMTP id j1csp1074215wro; Thu, 4 Apr 2024 16:08:10 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWYr26T0OJ0Lsnjvr1UpouFsQJjHMqtX1Oso2PRIklxJqlER18X9O+60nOewH86H2Xe8lUawEFWNFUR/G/ZxnNT X-Google-Smtp-Source: AGHT+IHXbueJvt9B9/I3Iu02miJsXWdV4wYhFPrucLNhMkVVhVsRk5lXdjKJaLVSf9U1tMeb+Ajb X-Received: by 2002:ac8:7d48:0:b0:432:cf1c:9d65 with SMTP id h8-20020ac87d48000000b00432cf1c9d65mr3994567qtb.53.1712272090143; Thu, 04 Apr 2024 16:08:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712272090; cv=none; d=google.com; s=arc-20160816; b=zIMSV3QQQ4l0L9NktUqRQuUN2bNmTzH+I/540el9o/Fx4/WQjROV8wC0vZa+uFxM/5 OxVNyl2rngBTucSpeWN8ounaKJvYSPL4WMykb3B7sZA4K7yvr7Kb1Y8Takmc9HFeqBj5 xiK10zE1WwEOjwDqKMJlnhRiZpVsYWBvLqreWJq2d8u9o/HsDrSrwZghW/ddvHf/3R1C HqcnxSQHvIksWCXRRjtBQkenFs+M+ru5+S6EBDqSd7Q6Uo2ocO/EIhyw/xH92s9jr/SI kWeW89BEJTlNs/oj0ktgnYNr1tGdZC1dcQMQ/6lhBW5mb5TfGjCb6YjH+A5Cvq5W5hfJ 2q9w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Vf2pglGQtHQjyWIwNLhivR5j/rpAVWzFiLJardZxKs4=; fh=vm85eyWrvOAHduw3sqEA+cYBqvHB7M0MHFcRJg7VWOo=; b=A+/1g07PU+ZWW8D9UcQY4Kb5ybW8lxyokl0ZaG6uzyMbR6hGjtDhovCgJdseDhHGlm O4CI86N1d8ndBobSVL3duIfoD3qqClZJ2W0RvId38fV+jLvlAKuAjlivojLNhfzE26RH LoUtgMu7r2E0Qlk2aoH2M3bTCDVWJfNiMY2jFVsJ17EBQalNp2Vr6V/AGIwDOFrsXJ5E xqw/JEu9MGfppeiUyYhnlE1earjaj6bAUrsIyPCwD9umcAAEYel9us8W6oWLf9aJogZP JqwBFuWPtR4UNHd+xpManxL+x4zM0s+V6+YRbns43uV35w3dKWhXh1SxXIIe16xrbUjj t2iA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jKxa3b+M; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id c10-20020ac85a8a000000b00431627efa14si420551qtc.411.2024.04.04.16.08.09 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 04 Apr 2024 16:08:10 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jKxa3b+M; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rsWAA-00022R-Eg; Thu, 04 Apr 2024 19:06:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rsWA6-00020U-5q for qemu-devel@nongnu.org; Thu, 04 Apr 2024 19:06:26 -0400 Received: from mail-pg1-x52a.google.com ([2607:f8b0:4864:20::52a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rsWA4-0007ir-BO for qemu-devel@nongnu.org; Thu, 04 Apr 2024 19:06:25 -0400 Received: by mail-pg1-x52a.google.com with SMTP id 41be03b00d2f7-53fbf2c42bfso1228254a12.3 for ; Thu, 04 Apr 2024 16:06:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712271982; x=1712876782; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Vf2pglGQtHQjyWIwNLhivR5j/rpAVWzFiLJardZxKs4=; b=jKxa3b+MAScs4AlRUaJKLI6tFY7+4GTDbRT8Ui5LPfKdjUmzdu8rlhA2ZSnusyH5Zq OFQDkDM2+0lP69zDUgYRvjjuP+ThQIRG5dx4h3O/7vUktIGtvms3MI+tJOg8oYg+85KJ UeyIW0gurAt/2AeB7zodtx1o33LBbg27ihsTN+NQEw6sdAzPx1Kxm+h7HrHFFy17ZbBu IWMD0eD6mnv2Tep9M+2zRhgd/2cxdg5fEpJxW7Str/wJM2sEFzaG+1oxJdZ+rFHKu0Mf W7XUfgM7MmZJZHtUn1LfgQXAL68k5iCOvBO5cf6h+9UInNs6kO55k8i09TWv6hEfteRp xcaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712271982; x=1712876782; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Vf2pglGQtHQjyWIwNLhivR5j/rpAVWzFiLJardZxKs4=; b=ZJiGS84TgNVKpfsDmBKQTqhypBPUKBvTlgWjpRUqYlEQ2GtqTb4FeSSxo6KsWh0Bb0 CzdK7LOy7/+HtTjOoxZsyzA3ehc6uKeXnJRFnLda/OMMJLpj+bAMsI6oIOUvz6tX9LoP mWqWqxCllfwy0DkDpgSFES1VzBsJHI6oxiKc6RCz0gTKlElX950AmAGmVtLJ+Hxp0JOA 5eKgUFVHsY36vliinyzJyUP04e16Pu3n5pPAEhEgS7Fn8b/Z6+ski4TD9dbHq36aRjVm NINnvgDeBDi2JEk3xXv749cs+F6h5knteBzfFwOLsRV6srQ13N16zS7xWxN1OSrqQVPm Nc1w== X-Gm-Message-State: AOJu0YxoAphRWqehLHN3glE8TAXJ/408GCEGYRZyn06yg/CN4OSNINvS oUmXW1Et1fQ3S0l3qZ+c7uYl+SVjM50LzQ8Q7XomBjEeoEJ0c9X3uWgJZ8cR7NLffTdwzvDfPUA O X-Received: by 2002:a17:90a:bb05:b0:2a2:f3:f52f with SMTP id u5-20020a17090abb0500b002a200f3f52fmr3716896pjr.43.1712271981845; Thu, 04 Apr 2024 16:06:21 -0700 (PDT) Received: from stoup.. (098-147-007-212.res.spectrum.com. [98.147.7.212]) by smtp.gmail.com with ESMTPSA id q36-20020a17090a17a700b002a2f3cfc92asm1052592pja.16.2024.04.04.16.06.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Apr 2024 16:06:21 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Pierrick Bouvier Subject: [PATCH v2 06/21] plugins: Create TCGHelperInfo for all out-of-line callbacks Date: Thu, 4 Apr 2024 13:05:56 -1000 Message-Id: <20240404230611.21231-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240404230611.21231-1-richard.henderson@linaro.org> References: <20240404230611.21231-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::52a; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x52a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org TCGHelperInfo includes the ABI for every function call. Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- include/qemu/plugin.h | 1 + plugins/core.c | 51 ++++++++++++++++++++++++++++++++++++++----- 2 files changed, 46 insertions(+), 6 deletions(-) diff --git a/include/qemu/plugin.h b/include/qemu/plugin.h index 143262dca8..793c44f1f2 100644 --- a/include/qemu/plugin.h +++ b/include/qemu/plugin.h @@ -92,6 +92,7 @@ struct qemu_plugin_dyn_cb { union { struct { union qemu_plugin_cb_sig f; + TCGHelperInfo *info; } regular; struct { qemu_plugin_u64 entry; diff --git a/plugins/core.c b/plugins/core.c index 837c373690..b0a2e80874 100644 --- a/plugins/core.c +++ b/plugins/core.c @@ -338,12 +338,26 @@ void plugin_register_dyn_cb__udata(GArray **arr, enum qemu_plugin_cb_flags flags, void *udata) { - struct qemu_plugin_dyn_cb *dyn_cb = plugin_get_dyn_cb(arr); + static TCGHelperInfo info[3] = { + [QEMU_PLUGIN_CB_NO_REGS].flags = TCG_CALL_NO_RWG | TCG_CALL_PLUGIN, + [QEMU_PLUGIN_CB_R_REGS].flags = TCG_CALL_NO_WG | TCG_CALL_PLUGIN, + [QEMU_PLUGIN_CB_RW_REGS].flags = TCG_CALL_PLUGIN, + /* + * Match qemu_plugin_vcpu_udata_cb_t: + * void (*)(uint32_t, void *) + */ + [0 ... 2].typemask = (dh_typemask(void, 0) | + dh_typemask(i32, 1) | + dh_typemask(ptr, 2)) + }; + struct qemu_plugin_dyn_cb *dyn_cb = plugin_get_dyn_cb(arr); dyn_cb->userp = udata; - /* Note flags are discarded as unused. */ - dyn_cb->regular.f.vcpu_udata = cb; dyn_cb->type = PLUGIN_CB_REGULAR; + dyn_cb->regular.f.vcpu_udata = cb; + + assert((unsigned)flags < ARRAY_SIZE(info)); + dyn_cb->regular.info = &info[flags]; } void plugin_register_vcpu_mem_cb(GArray **arr, @@ -352,14 +366,39 @@ void plugin_register_vcpu_mem_cb(GArray **arr, enum qemu_plugin_mem_rw rw, void *udata) { - struct qemu_plugin_dyn_cb *dyn_cb; + /* + * Expect that the underlying type for enum qemu_plugin_meminfo_t + * is either int32_t or uint32_t, aka int or unsigned int. + */ + QEMU_BUILD_BUG_ON( + !__builtin_types_compatible_p(qemu_plugin_meminfo_t, uint32_t) && + !__builtin_types_compatible_p(qemu_plugin_meminfo_t, int32_t)); - dyn_cb = plugin_get_dyn_cb(arr); + static TCGHelperInfo info[3] = { + [QEMU_PLUGIN_CB_NO_REGS].flags = TCG_CALL_NO_RWG | TCG_CALL_PLUGIN, + [QEMU_PLUGIN_CB_R_REGS].flags = TCG_CALL_NO_WG | TCG_CALL_PLUGIN, + [QEMU_PLUGIN_CB_RW_REGS].flags = TCG_CALL_PLUGIN, + /* + * Match qemu_plugin_vcpu_mem_cb_t: + * void (*)(uint32_t, qemu_plugin_meminfo_t, uint64_t, void *) + */ + [0 ... 2].typemask = + (dh_typemask(void, 0) | + dh_typemask(i32, 1) | + (__builtin_types_compatible_p(qemu_plugin_meminfo_t, uint32_t) + ? dh_typemask(i32, 2) : dh_typemask(s32, 2)) | + dh_typemask(i64, 3) | + dh_typemask(ptr, 4)) + }; + + struct qemu_plugin_dyn_cb *dyn_cb = plugin_get_dyn_cb(arr); dyn_cb->userp = udata; - /* Note flags are discarded as unused. */ dyn_cb->type = PLUGIN_CB_REGULAR; dyn_cb->rw = rw; dyn_cb->regular.f.vcpu_mem = cb; + + assert((unsigned)flags < ARRAY_SIZE(info)); + dyn_cb->regular.info = &info[flags]; } /*