From patchwork Fri Mar 10 10:31:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 661612 Delivered-To: patch@linaro.org Received: by 2002:adf:a3c6:0:0:0:0:0 with SMTP id m6csp770893wrb; Fri, 10 Mar 2023 02:31:58 -0800 (PST) X-Google-Smtp-Source: AK7set+j2wlKA4cuDG+l+UjgAYCT06TJeuTavbPkd1arYWh4v2rwXqca7NlzSKWNlnwsNnu1DzuX X-Received: by 2002:a05:622a:18c:b0:3bf:a760:cb5 with SMTP id s12-20020a05622a018c00b003bfa7600cb5mr9687657qtw.4.1678444318373; Fri, 10 Mar 2023 02:31:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678444318; cv=none; d=google.com; s=arc-20160816; b=AbGqPsUaWpGEWJan00xolVXjcKRDEfjxrpde9Sf3NhoKy6A+JEFc+Jo0m0trFXNmfq UrUPo5CrCQzOncDPlLI7X5scBWZZtw4iwBg0iKEdu5+dEXLi5hIT56AmwnAudcAvphev xAsFWFnSdNctxgzQ1lz46ysJ3tow/ed+Dsntfc1RZunZ6NgrNFMhwpCl5zqiBwsfabQM xVLf0aI7XaLFHis2hO4aTbdIsrehDbz00pOOrU1BSE70+cAWMqefWwJFtRkiPzoiA+OR 4rs7UfNHNHpyFtIYeu12VKHSHa22PLBoI6Hk+JL/kw+X0jmzOOe3efGp+97RgxS+IjS3 6vag== 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=MDK+aMGOP0xpM2yh43emDI7/ZdusXKwC3yy2K8RboBM=; b=CXwpfWWN4zjNm3GZirzWcq/gzZ6rDHW4q+mJqamL8pyraWYW37xeYG53DW9a0Ej7MP sffKb5OkkqgJN88saR9fWw+cPOVjNtPgwm5HKYKqjgf6f+9Cvc+2KWrxbdvERJFygj4x r6IULSjGA78Jbjn+9g5mdt/8DO/FuuaZxo0q68NbPXnc25IyZ5it1+iWnC/+bgspyDZ1 SU6qT6L/kvPx1LFkAkkcX8ExWy50ArYFcEmtWmCCUUIGrSFiDzxUh7U2e7bfOLY76XvO yxWfSYmAZofF57b4c/C3p7iDKlOkUtZ/R5nvuOp7bcec7I45j+8v+h59FuXzrQHrxfuG gSIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=pbx30FAU; 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 q131-20020a374389000000b007066f405b31si1155673qka.295.2023.03.10.02.31.58 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 10 Mar 2023 02:31:58 -0800 (PST) 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=pbx30FAU; 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 1paa2F-0007gM-GO; Fri, 10 Mar 2023 05:31:39 -0500 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 1paa27-0007Wf-UV for qemu-devel@nongnu.org; Fri, 10 Mar 2023 05:31:32 -0500 Received: from mail-wm1-x32d.google.com ([2a00:1450:4864:20::32d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1paa24-0004GK-3D for qemu-devel@nongnu.org; Fri, 10 Mar 2023 05:31:31 -0500 Received: by mail-wm1-x32d.google.com with SMTP id bg16-20020a05600c3c9000b003eb34e21bdfso5678292wmb.0 for ; Fri, 10 Mar 2023 02:31:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1678444286; 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=MDK+aMGOP0xpM2yh43emDI7/ZdusXKwC3yy2K8RboBM=; b=pbx30FAU1PHXBeDRBdzLPqFzMPxlMt5gj3ogc1Z/VGq27I2UQct9NCH/L22rIsnIOF x1gjJ9iHkhG7YLRHy0O8hu19Rcq16rMFt8qq9ZzvSoLJQz9qrSoTizKgPl1RGegdFLb9 HNJN9zj5z0LZubaPHXGI2OPYOGUMvjmcVCYAC2YnmZVpJmszACo4axdTsdCNOhMY5+Iy rMrYC3/On+EQGjjdsgt5yJT0dk/uD1Idf0uX4S+K5iChosFpzhxiXf7OgFY7HInxNK1Q xmMykO4i1MwOYziQcimdLBtKLj6uxH9nf/jGYJIY62OHZrJHk6vm+wVLpyliZ4OrIuKR x77A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678444286; 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=MDK+aMGOP0xpM2yh43emDI7/ZdusXKwC3yy2K8RboBM=; b=O+9sVNA9XXCtJMrWqUtgX6nlNab3T2TM+XQC3jewy1Is/62c+DA2fm71BzRgERYMXR Gf6FOdFybS/9VRjRWfA3nDFrZj8WV0APxWEPlS2q2QkRxQ7i/9Iq2IobSgVCxFZs1E3b toqGMAL+l+vljdxmi5idzV74bR+cdOIj4xW4yIpU/xdaXSVML//e8s69GDdDkmUJJhL9 Ik+YZEs0+L8ybvSFx23Nyvab2ycfLtKZKkb9pEXd0bgywkCAbRTe2fjNiOvsj82/FEDj v+g0EX6kqjKrYG7TL5YtZ5VdMuhFHRh5Lw9vpsb0MBtQE4EWlg9GDuYWZzuQnm2+InJK sBZA== X-Gm-Message-State: AO0yUKUu8CcmY4Q+1owK+J+aW+J+rj7h5I1XVSxvXfnIGzVBGj/EsAKj y7mzEnGJNKXFGWHP1KuWGDrnVA== X-Received: by 2002:a05:600c:3b99:b0:3df:3bd6:63e5 with SMTP id n25-20020a05600c3b9900b003df3bd663e5mr2235604wms.12.1678444286355; Fri, 10 Mar 2023 02:31:26 -0800 (PST) Received: from zen.linaroharston ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id f21-20020a7bcc15000000b003e20a6fd604sm1675768wmh.4.2023.03.10.02.31.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Mar 2023 02:31:25 -0800 (PST) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 23A101FFBE; Fri, 10 Mar 2023 10:31:24 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: David Hildenbrand , Wainer dos Santos Moschetta , Richard Henderson , qemu-arm@nongnu.org, Peter Xu , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Peter Maydell , Cleber Rosa , Thomas Huth , Paolo Bonzini , =?utf-8?q?Alex_Benn=C3=A9e?= , Beraldo Leal Subject: [PATCH 06/11] include/qemu: add documentation for memory callbacks Date: Fri, 10 Mar 2023 10:31:18 +0000 Message-Id: <20230310103123.2118519-7-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230310103123.2118519-1-alex.bennee@linaro.org> References: <20230310103123.2118519-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32d; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x32d.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=unavailable 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 Some API documentation was missed, rectify that. Fixes: https://gitlab.com/qemu-project/qemu/-/issues/1497 Signed-off-by: Alex Bennée --- include/qemu/qemu-plugin.h | 47 ++++++++++++++++++++++++++++++++++---- 1 file changed, 43 insertions(+), 4 deletions(-) diff --git a/include/qemu/qemu-plugin.h b/include/qemu/qemu-plugin.h index d0e9d03adf..50a9957279 100644 --- a/include/qemu/qemu-plugin.h +++ b/include/qemu/qemu-plugin.h @@ -481,17 +481,56 @@ uint64_t qemu_plugin_hwaddr_phys_addr(const struct qemu_plugin_hwaddr *haddr); */ const char *qemu_plugin_hwaddr_device_name(const struct qemu_plugin_hwaddr *h); -typedef void -(*qemu_plugin_vcpu_mem_cb_t)(unsigned int vcpu_index, - qemu_plugin_meminfo_t info, uint64_t vaddr, - void *userdata); +/** + * typedef qemu_plugin_vcpu_mem_cb_t - memory callback function type + * @vcpu_index: the executing vCPU + * @info: an opaque handle for further queries about the memory + * @vaddr: the virtual address of the transaction + * @userdata: any user data attached to the callback + */ +typedef void (*qemu_plugin_vcpu_mem_cb_t) (unsigned int vcpu_index, + qemu_plugin_meminfo_t info, + uint64_t vaddr, + void *userdata); +/** + * qemu_plugin_register_vcpu_mem_cb() - register memory access callback + * @insn: handle for instruction to instrument + * @cb: callback of type qemu_plugin_vcpu_mem_cb_t + * @flags: (currently unused) callback flags + * @rw: monitor reads, writes or both + * @userdata: opaque pointer for userdata + * + * This registers a full callback for every memory access generated by + * an instruction. If the instruction doesn't access memory no + * callback will be made. + * + * The callback reports the vCPU the access took place on, the virtual + * address of the access and a handle for further queries. The user + * can attach some userdata to the callback for additional purposes. + * + * Other execution threads will continue to execute during the + * callback so the plugin is responsible for ensuring it doesn't get + * confused by making appropriate use of locking if required. + */ void qemu_plugin_register_vcpu_mem_cb(struct qemu_plugin_insn *insn, qemu_plugin_vcpu_mem_cb_t cb, enum qemu_plugin_cb_flags flags, enum qemu_plugin_mem_rw rw, void *userdata); +/** + * qemu_plugin_register_vcpu_mem_inline() - register an inline op to any memory access + * @insn: handle for instruction to instrument + * @rw: apply to reads, writes or both + * @op: the op, of type qemu_plugin_op + * @ptr: pointer memory for the op + * @imm: immediate data for @op + * + * This registers a inline op every memory access generated by the + * instruction. This provides for a lightweight but not thread-safe + * way of counting the number of operations done. + */ void qemu_plugin_register_vcpu_mem_inline(struct qemu_plugin_insn *insn, enum qemu_plugin_mem_rw rw, enum qemu_plugin_op op, void *ptr,