From patchwork Wed Mar 15 17:43:05 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: 663371 Delivered-To: patch@linaro.org Received: by 2002:a5d:5602:0:0:0:0:0 with SMTP id l2csp1714536wrv; Wed, 15 Mar 2023 10:46:25 -0700 (PDT) X-Google-Smtp-Source: AK7set98A56PboF9Odai43st9xvx3ZWVvERcmf70eoXUnw9FQxeExjUOy5G9K8u4bwfPpalywnff X-Received: by 2002:a05:622a:42:b0:3bc:ff12:e5e5 with SMTP id y2-20020a05622a004200b003bcff12e5e5mr1506640qtw.17.1678902385666; Wed, 15 Mar 2023 10:46:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1678902385; cv=none; d=google.com; s=arc-20160816; b=g4Eewnumrtp1/kfPaZ2QZc5JEf8G6NjkSRwFgbbpHyI8odvP66B/uvNCHb0r+ImjwU ZnLZXFe5OAwMsYVuO7tgch2b5dpmsIuXmWUKUS1cZXdNnLH6zZh+NgrT88+190E7EUg8 RdTOG2sQpCK1Y6rc8H7zwlFO0T2Yj8wWPdrlWbBdQTfU6pg84dqUrw7FaTDViuu/clOu 7fqdjjXLMcnvJjyjk4CZkHYK0p3DonHOv9Vu4swEQT9wSF0S7JhuU5zL4SB9KSb0rg74 m2ApwC3J4TFsgCB4wQI3fh7RxoLMRGLQTLDBvbf0sdHKeQg2fihMVnNtxaZs63aQwaas kd7w== 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=geUNjFMGwEid6WoGyvpCgpe7/D1awaM6WtJ/t89l8mYj5tZUnhtbgKz2bX3BLBN770 Fh/UiisETKNrrVuWblFPW3IL8Hl7jR+sc710O79s7dGy3sIQ0hyi5kv9Ch9IPzgUtuCb RwGPFD86f7nt2gM8O8tjPbv7wA1Gr7HZ+wB8pBfOUtiVuLx9cNfTg23cRE4/Ecuwv3+l gg8jAxo0zU5nFZqTxSIfv+MpJsqw587mtliJsFq1tFGP2psS7yJZdm1/Xup+BmChLDgD XbxhJWBaqz8yYLCJvgEZQcTimdUgKdWXhPABkTJ9eb7g7M837rcJct4fFCQwN5DoKE+o op5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=cYPfFCln; 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 o8-20020a05622a138800b003bd0adc66e9si5250582qtk.244.2023.03.15.10.46.25 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 15 Mar 2023 10:46:25 -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=cYPfFCln; 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 1pcVAG-0002C5-6S; Wed, 15 Mar 2023 13:43:52 -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 1pcVAE-00028v-AY for qemu-devel@nongnu.org; Wed, 15 Mar 2023 13:43:50 -0400 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pcVA2-0000e2-Df for qemu-devel@nongnu.org; Wed, 15 Mar 2023 13:43:49 -0400 Received: by mail-wm1-x335.google.com with SMTP id ay8so7857421wmb.1 for ; Wed, 15 Mar 2023 10:43:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1678902216; 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=cYPfFClnzeGxmVf2UT21TxMcZfXew1UtQ5Edief9qGCRA9JNtB+9QK2k3Xl5/eBKxI ThWW+wzyYQYFhzb1zvoGoW40K7v9Oh9fUFg6eb+ggaj5gnZzAjYq1hxLktXyfkLcRr+1 Olsp3LHclUSQ5BrukvA2cL/7uahUoLbUD9gNX6+R/JhPbGe7pR6lTVUFHn5jaUrNzm3d TvgtySdTuAMzkZOVkng2cducQ/KpL+VbuAkmwLZqRemLeECL22o4jgN9qukPzR771bcJ ZLPss0TtYhugedtvJkUiWiVLBJnKcvn+dI1AGtqfaIIphIvbNotOIv+74Dg+vNVUNs5w iPcQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678902216; 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=KpbsVZITvFoeRFF/rw5FjgT/6Z5iTtzhQtYNMMP4btkeI/LVy4RRNImeiXUkabZzZQ RF8ry0NKEHRS33W3x4ktozaT5rkqgPXPZSEfV1IHMRiGFyosWyiDMZhluL0xJV1jt94V NQELPTqa0ayPesiKY7ABJh4pWWHMHaIqTmSc4zymtcxAMMwN1S9Mutb+oRKyYQTZGdVw RkVYQPC914ez4pAbg4N+oWeDQOzeaXXEZuIgQOIm6tFp9MEu1VEGweB0HuJfOcf/ceEn 4GVU5I0v0zqRSGM8/KCuRtEvtg1KERM8m8kgsmyhGVTIlYOMkVRYxpw8CVDr1+qb+s7P ZjDA== X-Gm-Message-State: AO0yUKWjVo0TYrES2z6ygA4/iUUOss4gs5Eaf59F0toWRHe9Bcg6/ffw VLdxMFDs0uBPyoPgkHOoHSvikA== X-Received: by 2002:a05:600c:198e:b0:3dc:405b:99bf with SMTP id t14-20020a05600c198e00b003dc405b99bfmr19401156wmq.15.1678902216357; Wed, 15 Mar 2023 10:43:36 -0700 (PDT) Received: from zen.linaroharston ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id r6-20020a05600c458600b003ebff290a52sm2854532wmo.28.2023.03.15.10.43.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Mar 2023 10:43:34 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id E55CE1FFBE; Wed, 15 Mar 2023 17:43:31 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Akihiko Odaki , =?utf-8?q?Marc-Andr=C3=A9_Lurea?= =?utf-8?q?u?= , qemu-riscv@nongnu.org, Riku Voipio , Igor Mammedov , Xiao Guangrong , Thomas Huth , Wainer dos Santos Moschetta , "Dr. David Alan Gilbert" , Alex Williamson , Hao Wu , Cleber Rosa , Daniel Henrique Barboza , Jan Kiszka , Aurelien Jarno , qemu-arm@nongnu.org, Marcelo Tosatti , Eduardo Habkost , Alexandre Iooss , Gerd Hoffmann , Palmer Dabbelt , Ilya Leoshkevich , qemu-ppc@nongnu.org, Juan Quintela , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Darren Kenny , kvm@vger.kernel.org, Marcel Apfelbaum , Peter Maydell , Richard Henderson , Stafford Horne , Weiwei Li , Sunil V L , Stefan Hajnoczi , Thomas Huth , Vijai Kumar K , Liu Zhiwei , David Gibson , Song Gao , Paolo Bonzini , "Michael S. Tsirkin" , Niek Linnenbank , Greg Kurz , Laurent Vivier , Qiuhao Li , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Xiaojuan Yang , Mahmoud Mandour , Alexander Bulekov , Jiaxun Yang , qemu-block@nongnu.org, Yanan Wang , David Woodhouse , qemu-s390x@nongnu.org, Strahinja Jankovic , Bandan Das , Alistair Francis , Aleksandar Rikalo , Tyrone Ting , Kevin Wolf , David Hildenbrand , Beraldo Leal , Beniamino Galvani , Paul Durrant , Bin Meng , Sunil Muthuswamy , Hanna Reitz , Peter Xu , =?utf-8?q?Al?= =?utf-8?q?ex_Benn=C3=A9e?= Subject: [PATCH v2 06/32] include/qemu: add documentation for memory callbacks Date: Wed, 15 Mar 2023 17:43:05 +0000 Message-Id: <20230315174331.2959-7-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230315174331.2959-1-alex.bennee@linaro.org> References: <20230315174331.2959-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::335; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x335.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 Reviewed-by: Richard Henderson Reviewed-by: Thomas Huth --- 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,