From patchwork Wed Apr 24 23:02:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 791562 Delivered-To: patch@linaro.org Received: by 2002:a5d:4884:0:b0:346:15ad:a2a with SMTP id g4csp1096088wrq; Wed, 24 Apr 2024 16:03:55 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXwRvEYEAW5t1M2oPlcSvf0A0cwLX/wyKvYZRTEuZTRt4Zrv6Fxcn9fMak0gKrOkC9Jr3E75s1Z0IpKGfaek3th X-Google-Smtp-Source: AGHT+IFD6stuKpfvUP2rw4djAFauuyfAFbGRNRK8ViFKiJQ1X64nGToisdQcPMw8y+xnydPCqGFB X-Received: by 2002:a05:622a:48e:b0:436:ba90:17ad with SMTP id p14-20020a05622a048e00b00436ba9017admr4360058qtx.40.1713999835713; Wed, 24 Apr 2024 16:03:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1713999835; cv=none; d=google.com; s=arc-20160816; b=HW/UhhjUWahD2p68w71/0fH1gAy3OmG5QppV7AKwu3J3aJtPV0OgXuhCEYkHFzDx47 JKlANGhk2hNlqb7b3GkzFpxIQCmN14dXdoYR3mDH7Ih4XSTKSCkNwVbNDYf62zlCcSke XVyGxj8CZ6v4NHOkp3cf9bdqahAcE8iYuWTxHncnYN4G3quGA9KQTjc/XhSP82FFtDnr 2sEGJpfgBrAS56ol+mcplEBZAVQy4xUyavnC+8vfPbJI3WKK5pcyGsiiAHuaQhiuIJ/n 41vONZ7tF9wsip3QjnbUBFmA8FEDR110Wh6++1fiqOaXt8GVXaQnMwJImSCvVr+sHlU0 kEUQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Vf2pglGQtHQjyWIwNLhivR5j/rpAVWzFiLJardZxKs4=; fh=vm85eyWrvOAHduw3sqEA+cYBqvHB7M0MHFcRJg7VWOo=; b=gX3xxrPkPmbC70LT+AIVOS22kvOSQfEcCPcpuX1jkTefadP1jI/PEHRJ7LSXOOWAk4 PjiPQZD9S+TnA3k+ojgiC1mqqi/ifsWjsIBB0ryBfoZ/FMpt+QiW536wRRI46hnca5QT AxsDDTUvtqoEGg4lzXPTvuYrtofbBZd1i1PyGLqAFeVTsu3f/gDt7BtyTfzU0HFD0pwi wKnCrEkK9T6OqZsrxORx938JhPF0f2DGg1q3VdCj2YVaWGJucK+bJdKQj1EQb+rprtXr P4r/L3IOfh6qKJ4HsNjxEMK6ux/lKmkoCQJnrcoWTlX2po026YyvuJIk24B7C2CwtlVF hdhA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YIn7HrMb; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id i17-20020ac85e51000000b004345e4cb66asi17260278qtx.63.2024.04.24.16.03.55 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 24 Apr 2024 16:03:55 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YIn7HrMb; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rzldN-0003i8-Dp; Wed, 24 Apr 2024 19:02:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rzldL-0003h0-6L for qemu-devel@nongnu.org; Wed, 24 Apr 2024 19:02:35 -0400 Received: from mail-pg1-x52c.google.com ([2607:f8b0:4864:20::52c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rzldJ-0002co-Bd for qemu-devel@nongnu.org; Wed, 24 Apr 2024 19:02:34 -0400 Received: by mail-pg1-x52c.google.com with SMTP id 41be03b00d2f7-5f7fc45fe1bso337911a12.0 for ; Wed, 24 Apr 2024 16:02:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1713999752; x=1714604552; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Vf2pglGQtHQjyWIwNLhivR5j/rpAVWzFiLJardZxKs4=; b=YIn7HrMbvpJw04PuEvtFlxoVmjGrGPUJlSmRqIfhUUCzczd6d9F+O7F2QsekiuIqVy 2d6V3TRg4yiPnMRCE+3f82yJhuHObgHA5AN5J40d+c55fKlRrDP3rXuZU9dGyDelmfg5 apCpNXx6HD/5xVZ1GzHAlRDi88kVQK3loFIdcfv4VNpsrmie+E/W7NiY5SwR84n8LdCO 0XCo8LbZk+08DX5RpI+TDC0vj9HBG82WjevtRLQVBLJSyuDbM0qlYBo8OOctL9i3xjKl 3A6cYoSzhYxng8wCuQPrvrFy2ojJFX+/ZmE21Xy6dLJxVg3dQYDQgBXVG8xS3nvRZIfE KS0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713999752; x=1714604552; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Vf2pglGQtHQjyWIwNLhivR5j/rpAVWzFiLJardZxKs4=; b=qWlKWv68u6Afva3Rn3/GTyRqJWxqAN2Xb9jAvp7j/0imcjv5n1mEjaT/wh+80MOS5B UIV2hkOm4UhAAsRs0uGh+r7/zBJIwIfwvdpN5TYEItE2DgbyFiQ530sygLQIiV60S2Ug VXStGhoDfbrEA861uE1B2UDNRBL+qVfRnkCYzPcRO1MHYKV1o3HGpYTAE8walMBd5Fz2 IYiGlghaSkZbDaVEXblmziIkCSOczNKIkQqmPDZmaU2TzrUdUPiXnW7/4s380fHinvFj FSpeYjXMwwRt0LZwuRLnaMesLi0jGvR1Ytjz62tHU2UUi79TyqbU1b57iTXE+nPUgLLi sE2Q== X-Gm-Message-State: AOJu0YyvenbAN4mz7r5K55ZX+olsGzdWNDos9DtX0q0tHnM6b699MuUw 2Wm1yFmSgCs+rAOEtjxGoUBfcU4qKcxjJ1PJev3jV1ACp/pcsJsrr4FoqGKglB7uu9Wb9lRQtvR J X-Received: by 2002:a05:6a20:bca8:b0:1a9:55bd:95f6 with SMTP id fx40-20020a056a20bca800b001a955bd95f6mr3505658pzb.31.1713999752041; Wed, 24 Apr 2024 16:02:32 -0700 (PDT) Received: from stoup.. ([156.19.246.23]) by smtp.gmail.com with ESMTPSA id h5-20020a056a00000500b006ed4aa9d5c0sm11981405pfk.188.2024.04.24.16.02.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Apr 2024 16:02:31 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Pierrick Bouvier Subject: [PATCH v3 05/20] plugins: Create TCGHelperInfo for all out-of-line callbacks Date: Wed, 24 Apr 2024 16:02:09 -0700 Message-Id: <20240424230224.941028-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240424230224.941028-1-richard.henderson@linaro.org> References: <20240424230224.941028-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::52c; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x52c.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org TCGHelperInfo includes the ABI for every function call. Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- include/qemu/plugin.h | 1 + plugins/core.c | 51 ++++++++++++++++++++++++++++++++++++++----- 2 files changed, 46 insertions(+), 6 deletions(-) diff --git a/include/qemu/plugin.h b/include/qemu/plugin.h index 143262dca8..793c44f1f2 100644 --- a/include/qemu/plugin.h +++ b/include/qemu/plugin.h @@ -92,6 +92,7 @@ struct qemu_plugin_dyn_cb { union { struct { union qemu_plugin_cb_sig f; + TCGHelperInfo *info; } regular; struct { qemu_plugin_u64 entry; diff --git a/plugins/core.c b/plugins/core.c index 837c373690..b0a2e80874 100644 --- a/plugins/core.c +++ b/plugins/core.c @@ -338,12 +338,26 @@ void plugin_register_dyn_cb__udata(GArray **arr, enum qemu_plugin_cb_flags flags, void *udata) { - struct qemu_plugin_dyn_cb *dyn_cb = plugin_get_dyn_cb(arr); + static TCGHelperInfo info[3] = { + [QEMU_PLUGIN_CB_NO_REGS].flags = TCG_CALL_NO_RWG | TCG_CALL_PLUGIN, + [QEMU_PLUGIN_CB_R_REGS].flags = TCG_CALL_NO_WG | TCG_CALL_PLUGIN, + [QEMU_PLUGIN_CB_RW_REGS].flags = TCG_CALL_PLUGIN, + /* + * Match qemu_plugin_vcpu_udata_cb_t: + * void (*)(uint32_t, void *) + */ + [0 ... 2].typemask = (dh_typemask(void, 0) | + dh_typemask(i32, 1) | + dh_typemask(ptr, 2)) + }; + struct qemu_plugin_dyn_cb *dyn_cb = plugin_get_dyn_cb(arr); dyn_cb->userp = udata; - /* Note flags are discarded as unused. */ - dyn_cb->regular.f.vcpu_udata = cb; dyn_cb->type = PLUGIN_CB_REGULAR; + dyn_cb->regular.f.vcpu_udata = cb; + + assert((unsigned)flags < ARRAY_SIZE(info)); + dyn_cb->regular.info = &info[flags]; } void plugin_register_vcpu_mem_cb(GArray **arr, @@ -352,14 +366,39 @@ void plugin_register_vcpu_mem_cb(GArray **arr, enum qemu_plugin_mem_rw rw, void *udata) { - struct qemu_plugin_dyn_cb *dyn_cb; + /* + * Expect that the underlying type for enum qemu_plugin_meminfo_t + * is either int32_t or uint32_t, aka int or unsigned int. + */ + QEMU_BUILD_BUG_ON( + !__builtin_types_compatible_p(qemu_plugin_meminfo_t, uint32_t) && + !__builtin_types_compatible_p(qemu_plugin_meminfo_t, int32_t)); - dyn_cb = plugin_get_dyn_cb(arr); + static TCGHelperInfo info[3] = { + [QEMU_PLUGIN_CB_NO_REGS].flags = TCG_CALL_NO_RWG | TCG_CALL_PLUGIN, + [QEMU_PLUGIN_CB_R_REGS].flags = TCG_CALL_NO_WG | TCG_CALL_PLUGIN, + [QEMU_PLUGIN_CB_RW_REGS].flags = TCG_CALL_PLUGIN, + /* + * Match qemu_plugin_vcpu_mem_cb_t: + * void (*)(uint32_t, qemu_plugin_meminfo_t, uint64_t, void *) + */ + [0 ... 2].typemask = + (dh_typemask(void, 0) | + dh_typemask(i32, 1) | + (__builtin_types_compatible_p(qemu_plugin_meminfo_t, uint32_t) + ? dh_typemask(i32, 2) : dh_typemask(s32, 2)) | + dh_typemask(i64, 3) | + dh_typemask(ptr, 4)) + }; + + struct qemu_plugin_dyn_cb *dyn_cb = plugin_get_dyn_cb(arr); dyn_cb->userp = udata; - /* Note flags are discarded as unused. */ dyn_cb->type = PLUGIN_CB_REGULAR; dyn_cb->rw = rw; dyn_cb->regular.f.vcpu_mem = cb; + + assert((unsigned)flags < ARRAY_SIZE(info)); + dyn_cb->regular.info = &info[flags]; } /*