From patchwork Sat Mar 18 11:46:19 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: 664743 Delivered-To: patch@linaro.org Received: by 2002:a5d:5602:0:0:0:0:0 with SMTP id l2csp246026wrv; Sat, 18 Mar 2023 04:49:24 -0700 (PDT) X-Google-Smtp-Source: AK7set83om7yi12UUwQKAcsneGXE6sS3o/vxRAP1pOu0h2+22Q7C2iUwMW2FXJgujo5P1KkuNGMY X-Received: by 2002:a05:6214:1c06:b0:5b8:c53:3a9 with SMTP id u6-20020a0562141c0600b005b80c5303a9mr13335160qvc.36.1679140164082; Sat, 18 Mar 2023 04:49:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679140164; cv=none; d=google.com; s=arc-20160816; b=t7A6IOPLBgn1K0NyJcHdaOkl2GxBJyRllgsilmTTldat58b147+mj3R4vlWI2gxpzo rAgq5CihQgNZYe1/YJYTXH+g2ZAozdO23sXl50MiDVA7tWLahfKnYIu4BEB0Qgb/RZBs FkzUQBlXYlKtVH6a7PSUO2411bd7ALzLL4arV2d4/914rq9VaSp+tdNIZxO+4PXQMLyS Uqyu7LO1XhmoPwPgrhJ5bQiDiGoI3D8QWJv5+aZQTEp8fgYMVteUAv6Z4UPaTXoZXtv3 Xwf5fq2tvWS3iB5LexB6MpGXKWtLU/W70CXsuikDcEoYPuAvyYm4HABrcJz2vwbrPyiM tHow== 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=fBYk5bGVNcz+Cm3QC0lbKHCg7DWMcmjX+dS/dafzz5k=; b=ppTbrzc8WBKdB9u8g1xmjt5KwgqgIMq4JyzX2gFnHvaeiMD+ehtwneiHh660d/pl0f Ae2fdAWOcNd6S74Dsuain9xbStrpwUM1cEXC1ECkbC63kyd/sJeVeF9ohGfOo1NBNq5D VgUsuEdf2jdo6d7Lm8S/4yuvB1u0rcYX74MIeO6rLENNLz908hcDBb1FOh9Y9gyMt+4Z oNnCgU+BtO30iRREoKblZkX8cDSLbjj6zElVX3V/+vjeid0SyYptfYtZ3A5ExnjQUk15 3dJ07ZarkB1xdh5znMVf2gyHZYWPx2EJ4kmFHvgcsKNMMlz55rHI+ob3GLuxzl8mM70W 0QRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=VsSFWHlY; 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 104-20020a0c8171000000b005ad18b4d5cdsi2927204qvc.476.2023.03.18.04.49.23 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 18 Mar 2023 04:49:24 -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=VsSFWHlY; 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 1pdV1W-0004oc-Ch; Sat, 18 Mar 2023 07:46:58 -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 1pdV1Q-0004mm-QA for qemu-devel@nongnu.org; Sat, 18 Mar 2023 07:46:52 -0400 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pdV1P-0007Db-0k for qemu-devel@nongnu.org; Sat, 18 Mar 2023 07:46:52 -0400 Received: by mail-wm1-x333.google.com with SMTP id m35so4748673wms.4 for ; Sat, 18 Mar 2023 04:46:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1679140009; 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=fBYk5bGVNcz+Cm3QC0lbKHCg7DWMcmjX+dS/dafzz5k=; b=VsSFWHlYpziQ/+tP46C3S5dBq0DjOGjgiKxjp1Lxou1C/Px8y2nGtyi/bENTPhNLrD eDowkwLvFpeqnAa/G20pOrKvMF5R7nhwVjvleVuQbb+s7bvn6Idrvtw+6j9ZPRtw975u fLYhzlnJcxC5BgHTQp6ZI5e+j5P2b94h2fbENW05EMdeh9y3kcwtJc1pRiHmp14rmV5y 0FZBBn4SdK8Z8FENOuNhFxtgnSBJEyoWa9uEeP0he0485eBd8jSe3LdJotMMM3GY6eJ9 jcRlex8xUzeqKKL7fWq1F67XsXaOndfrJj7uUtp+KgKMwr4gTulnpUBLTMgbfwL+jL06 szxQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679140009; 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=fBYk5bGVNcz+Cm3QC0lbKHCg7DWMcmjX+dS/dafzz5k=; b=J0BUwKIf/6vwPI9wi4xJO5yXg1cJJkUyX44l+Bm7wGjE06C7j9d6dLoO8tl/bbnz8L LD1nhf9tYumsGpjQlMZPQe1gQ5ImDTpJOCxuv3ocHWatmB9jNx2FfnXV8BhmV/wRhP29 4XuhUDG4vgrZSpr9YFeHQCG+LwJ9n+4seBrmZHdk2cDF35NggmlkJmcn0yQ+PSO2MLa3 KLoSB9LDfpJutDvmpPMZznXo70VRW2iMVaiHcHioy3L7qiPiZ7khi/y0QBNZTIxtgC1S jQaoqYokDqD22zJsdlyeHjzwSSuoyCKz1bsfgyp8zr5zGhG126SM/ER69mCjcLowF+JC 9qSg== X-Gm-Message-State: AO0yUKVIqb37Us5g3xR6nL9ZnMdu9+9TVJgnFvc9cGB4cEdDxmdwslkt eG6HpHP7KQ3M4Xe3WcW1i4DvYw== X-Received: by 2002:a05:600c:19cf:b0:3eb:2da4:f304 with SMTP id u15-20020a05600c19cf00b003eb2da4f304mr25867313wmq.17.1679140009719; Sat, 18 Mar 2023 04:46:49 -0700 (PDT) Received: from zen.linaroharston ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id 4-20020a05600c028400b003eb192787bfsm4582187wmk.25.2023.03.18.04.46.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 Mar 2023 04:46:46 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 275151FFBE; Sat, 18 Mar 2023 11:46:45 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, =?utf-8?q?Alex_Benn=C3=A9e?= , Richard Henderson , Thomas Huth Subject: [PULL 06/31] include/qemu: add documentation for memory callbacks Date: Sat, 18 Mar 2023 11:46:19 +0000 Message-Id: <20230318114644.1340899-7-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230318114644.1340899-1-alex.bennee@linaro.org> References: <20230318114644.1340899-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::333; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x333.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 Some API documentation was missed, rectify that. Fixes: https://gitlab.com/qemu-project/qemu/-/issues/1497 Signed-off-by: Alex Bennée Reviewed-by: Richard Henderson Reviewed-by: Thomas Huth Message-Id: <20230315174331.2959-7-alex.bennee@linaro.org> 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,