From nobody Tue May 14 01:31:32 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1601025153; cv=none; d=zohomail.com; s=zohoarc; b=gqBSvM6GRPTOIRg0LbYM4gXV+8uyTNxIAQUmOxka7LjMq93W62pVzq+NBsv7Is7GAqaJwHtV+Velsk+Ixcabzf9Z/ZJSgekdnTHbDQh450eGWrWqDslwulKN/02vjWUcNFfdO13HD8WcK3iCqynULrmL6/ssU1OGVXWho+PZrNk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601025153; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=le/AFLjMKIUwwPTP9MPoIbrqeSSlGtYNtRO3yJzdnUk=; b=AAcZYCzSIQoy5D07t2T7slaU4Fxf05LcSb3GtMGL4WsPzkMnjgD0pI6UHeE0D7YLCMNVx4ywhP7plzionbUpnHr9skROAo4pkSzvQLIs6cq3UNC7yASNP79/ZywKRDgaqguThV1kSH0o7hXHCXaPZ09Zb6O0aXNyg0I3jDokFW8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1601025153340748.3235221307208; Fri, 25 Sep 2020 02:12:33 -0700 (PDT) Received: from localhost ([::1]:38268 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kLjmJ-0005CT-Ua for importer@patchew.org; Fri, 25 Sep 2020 05:12:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56792) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kLjl3-000404-F1 for qemu-devel@nongnu.org; Fri, 25 Sep 2020 05:11:13 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:45555) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kLjl1-0007ss-RE for qemu-devel@nongnu.org; Fri, 25 Sep 2020 05:11:13 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-346-mmIcUKKIMjuh8VWTM8yC4w-1; Fri, 25 Sep 2020 05:11:08 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E61A1800597 for ; Fri, 25 Sep 2020 09:11:07 +0000 (UTC) Received: from thinkpad.redhat.com (ovpn-112-16.ams2.redhat.com [10.36.112.16]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3482E1002C0F; Fri, 25 Sep 2020 09:11:05 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1601025070; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=le/AFLjMKIUwwPTP9MPoIbrqeSSlGtYNtRO3yJzdnUk=; b=Z2aFztUGX/vELKVrV9dR+A7WBBqFSOx+IE6Vr3VBqywCYH8kkah+6iI4lrtPKDLwof6JqS lBhRPeXPHM+1Vp0CbSgyM9LkCjRwYfh2iC1aFoyMuozBwtdMQQMkMfZXui8JLa/L2JSSFU nF+KfWJnRnjmY7wpcjQOFIMqmFApTS8= X-MC-Unique: mmIcUKKIMjuh8VWTM8yC4w-1 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PATCH v3 1/2] util/hexdump: introduce qemu_hexdump_line() Date: Fri, 25 Sep 2020 11:10:54 +0200 Message-Id: <20200925091055.186023-2-lvivier@redhat.com> In-Reply-To: <20200925091055.186023-1-lvivier@redhat.com> References: <20200925091055.186023-1-lvivier@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=lvivier@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=63.128.21.124; envelope-from=lvivier@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/25 01:07:33 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -32 X-Spam_score: -3.3 X-Spam_bar: --- X-Spam_report: (-3.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.199, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Cindy Lu , "Michael S . Tsirkin" , Jason Wang , Stefan Hajnoczi , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Dumping one line of hexadecimal/ASCII from a buffer is often needed. Move this part from qemu_hexdump() and use it Acked-by: Stefan Hajnoczi Signed-off-by: Laurent Vivier --- include/qemu-common.h | 8 +++++++ util/hexdump.c | 54 +++++++++++++++++++++++++++---------------- 2 files changed, 42 insertions(+), 20 deletions(-) diff --git a/include/qemu-common.h b/include/qemu-common.h index 9cfd62669bf8..cc902b690db3 100644 --- a/include/qemu-common.h +++ b/include/qemu-common.h @@ -134,6 +134,14 @@ void os_setup_early_signal_handling(void); char *os_find_datadir(void); int os_parse_cmd_args(int index, const char *optarg); =20 +/* + * Hexdump a line of a byte buffer into a hexadecimal/ASCII buffer + */ +#define QEMU_HEXDUMP_LINE_BYTES 16 /* Number of bytes to dump */ +#define QEMU_HEXDUMP_LINE_LEN 75 /* Number of characters in line */ +void qemu_hexdump_line(char *line, unsigned int b, const void *bufptr, + unsigned int len, bool ascii); + /* * Hexdump a buffer to a file. An optional string prefix is added to every= line */ diff --git a/util/hexdump.c b/util/hexdump.c index 0b4662e701d8..2c105a884620 100644 --- a/util/hexdump.c +++ b/util/hexdump.c @@ -16,36 +16,50 @@ #include "qemu/osdep.h" #include "qemu-common.h" =20 -void qemu_hexdump(FILE *fp, const char *prefix, - const void *bufptr, size_t size) +void qemu_hexdump_line(char *line, unsigned int b, const void *bufptr, + unsigned int len, bool ascii) { const char *buf =3D bufptr; - unsigned int b, len, i, c; + int i, c; =20 - for (b =3D 0; b < size; b +=3D 16) { - len =3D size - b; - if (len > 16) { - len =3D 16; + if (len > QEMU_HEXDUMP_LINE_BYTES) { + len =3D QEMU_HEXDUMP_LINE_BYTES; + } + + line +=3D snprintf(line, 6, "%04x:", b); + for (i =3D 0; i < QEMU_HEXDUMP_LINE_BYTES; i++) { + if ((i % 4) =3D=3D 0) { + *line++ =3D ' '; } - fprintf(fp, "%s: %04x:", prefix, b); - for (i =3D 0; i < 16; i++) { - if ((i % 4) =3D=3D 0) { - fprintf(fp, " "); - } - if (i < len) { - fprintf(fp, " %02x", (unsigned char)buf[b + i]); - } else { - fprintf(fp, " "); - } + if (i < len) { + line +=3D sprintf(line, " %02x", (unsigned char)buf[b + i]); + } else { + line +=3D sprintf(line, " "); } - fprintf(fp, " "); + } + if (ascii) { + *line++ =3D ' '; for (i =3D 0; i < len; i++) { c =3D buf[b + i]; if (c < ' ' || c > '~') { c =3D '.'; } - fprintf(fp, "%c", c); + *line++ =3D c; } - fprintf(fp, "\n"); } + *line =3D '\0'; +} + +void qemu_hexdump(FILE *fp, const char *prefix, + const void *bufptr, size_t size) +{ + unsigned int b, len; + char line[QEMU_HEXDUMP_LINE_LEN]; + + for (b =3D 0; b < size; b +=3D QEMU_HEXDUMP_LINE_BYTES) { + len =3D size - b; + qemu_hexdump_line(line, b, bufptr, len, true); + fprintf(fp, "%s: %s\n", prefix, line); + } + } --=20 2.26.2 From nobody Tue May 14 01:31:32 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1601025160; cv=none; d=zohomail.com; s=zohoarc; b=EKfZ9X32nGE4bHWYdTxos0hyjFzYBgIEZrlV62inocvmPq+PdrbXNSUBnZabeWR+Wx8d+CsvX4A5qO5EEhD2wgBdUMxA+uN/7Hhj0itsVTWg56zwTVkCPyKGpwnKXWltwjwCjCnvFyaAmcoqihw8WgsSqITun0hJehwrxeiAMbU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601025160; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=4g6FaaIgv+RPCqB2VEzLKsaQ1g0HLCnSADW4XkUgMxE=; b=SFvegivz3SCxfKuZxlSnGpPe2ddCKwBEX55V4mjEECuPuS8KxDk5ZbxYDWFFzk0YFL/+55eFm0FeilE3XK9B92eUgOrhIUyiY9foFxEa67DJaDV0v8KWvqIvHyrCt0dEPQ9aPONZYeFqcF2TAGxfzMf/hzVLpEhXJEn0dR6UmKY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1601025160679432.26356146136663; Fri, 25 Sep 2020 02:12:40 -0700 (PDT) Received: from localhost ([::1]:38982 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kLjmR-0005Vq-84 for importer@patchew.org; Fri, 25 Sep 2020 05:12:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56812) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kLjl7-00046Z-I6 for qemu-devel@nongnu.org; Fri, 25 Sep 2020 05:11:17 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:54965) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kLjl5-0007tE-06 for qemu-devel@nongnu.org; Fri, 25 Sep 2020 05:11:17 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-423-PNkb6RejNjuYtexBIomLuA-1; Fri, 25 Sep 2020 05:11:12 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3AC5464097 for ; Fri, 25 Sep 2020 09:11:11 +0000 (UTC) Received: from thinkpad.redhat.com (ovpn-112-16.ams2.redhat.com [10.36.112.16]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4926C1002C0F; Fri, 25 Sep 2020 09:11:08 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1601025074; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=4g6FaaIgv+RPCqB2VEzLKsaQ1g0HLCnSADW4XkUgMxE=; b=TgdI23yR+Y6F3LXrNj6IhpJx5lVYDy+xAEVWQXVNtAyK28M9pd8KmTo4hBFhK/vSmr91X6 L4QNt8LcClXoOQcaYJiqmiX3X2U7QuheyndNZ0dL+Ayj54xVHeHwPUmNOffPuOjqp4+38h NZZUSjIQdjMVVlusOP79H8AVZ4TOu00= X-MC-Unique: PNkb6RejNjuYtexBIomLuA-1 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PATCH v3 2/2] vhost-vdpa: add trace-events Date: Fri, 25 Sep 2020 11:10:55 +0200 Message-Id: <20200925091055.186023-3-lvivier@redhat.com> In-Reply-To: <20200925091055.186023-1-lvivier@redhat.com> References: <20200925091055.186023-1-lvivier@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=lvivier@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=lvivier@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/25 02:48:20 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -32 X-Spam_score: -3.3 X-Spam_bar: --- X-Spam_report: (-3.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.199, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Cindy Lu , "Michael S . Tsirkin" , Jason Wang , Stefan Hajnoczi , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Add trace functions in vhost-vdpa.c. All traces from this file can be enabled with '-trace vhost_vdpa*'. Acked-by: Stefan Hajnoczi Signed-off-by: Laurent Vivier Acked-by: Jason Wang --- hw/virtio/trace-events | 31 ++++++++++++++ hw/virtio/vhost-vdpa.c | 92 +++++++++++++++++++++++++++++++++++++++--- 2 files changed, 118 insertions(+), 5 deletions(-) diff --git a/hw/virtio/trace-events b/hw/virtio/trace-events index 845200bf109d..cf1e59de302a 100644 --- a/hw/virtio/trace-events +++ b/hw/virtio/trace-events @@ -22,6 +22,37 @@ vhost_user_postcopy_waker(const char *rb, uint64_t rb_of= fset) "%s + 0x%"PRIx64 vhost_user_postcopy_waker_found(uint64_t client_addr) "0x%"PRIx64 vhost_user_postcopy_waker_nomatch(const char *rb, uint64_t rb_offset) "%s = + 0x%"PRIx64 =20 +# vhost-vdpa.c +vhost_vdpa_dma_map(void *vdpa, int fd, uint32_t msg_type, uint64_t iova, u= int64_t size, uint64_t uaddr, uint8_t perm, uint8_t type) "vdpa:%p fd: %d m= sg_type: %"PRIu32" iova: 0x%"PRIx64" size: 0x%"PRIx64" uaddr: 0x%"PRIx64" p= erm: 0x%"PRIx8" type: %"PRIu8 +vhost_vdpa_dma_unmap(void *vdpa, int fd, uint32_t msg_type, uint64_t iova,= uint64_t size, uint8_t type) "vdpa:%p fd: %d msg_type: %"PRIu32" iova: 0x%= "PRIx64" size: 0x%"PRIx64" type: %"PRIu8 +vhost_vdpa_listener_region_add(void *vdpa, uint64_t iova, uint64_t llend, = void *vaddr, bool readonly) "vdpa: %p iova 0x%"PRIx64" llend 0x%"PRIx64" va= ddr: %p read-only: %d" +vhost_vdpa_listener_region_del(void *vdpa, uint64_t iova, uint64_t llend) = "vdpa: %p iova 0x%"PRIx64" llend 0x%"PRIx64 +vhost_vdpa_add_status(void *dev, uint8_t status) "dev: %p status: 0x%"PRIx8 +vhost_vdpa_init(void *dev, void *vdpa) "dev: %p vdpa: %p" +vhost_vdpa_cleanup(void *dev, void *vdpa) "dev: %p vdpa: %p" +vhost_vdpa_memslots_limit(void *dev, int ret) "dev: %p =3D 0x%x" +vhost_vdpa_set_mem_table(void *dev, uint32_t nregions, uint32_t padding) "= dev: %p nregions: %"PRIu32" padding: 0x%"PRIx32 +vhost_vdpa_dump_regions(void *dev, int i, uint64_t guest_phys_addr, uint64= _t memory_size, uint64_t userspace_addr, uint64_t flags_padding) "dev: %p %= d: guest_phys_addr: 0x%"PRIx64" memory_size: 0x%"PRIx64" userspace_addr: 0x= %"PRIx64" flags_padding: 0x%"PRIx64 +vhost_vdpa_set_features(void *dev, uint64_t features) "dev: %p features: 0= x%"PRIx64 +vhost_vdpa_get_device_id(void *dev, uint32_t device_id) "dev: %p device_id= %"PRIu32 +vhost_vdpa_reset_device(void *dev, uint8_t status) "dev: %p status: 0x%"PR= Ix8 +vhost_vdpa_get_vq_index(void *dev, int idx, int vq_idx) "dev: %p idx: %d v= q idx: %d" +vhost_vdpa_set_vring_ready(void *dev) "dev: %p" +vhost_vdpa_dump_config(void *dev, const char *line) "dev: %p %s" +vhost_vdpa_set_config(void *dev, uint32_t offset, uint32_t size, uint32_t = flags) "dev: %p offset: %"PRIu32" size: %"PRIu32" flags: 0x%"PRIx32 +vhost_vdpa_get_config(void *dev, void *config, uint32_t config_len) "dev: = %p config: %p config_len: %"PRIu32 +vhost_vdpa_dev_start(void *dev, bool started) "dev: %p started: %d" +vhost_vdpa_set_log_base(void *dev, uint64_t base, unsigned long long size,= int refcnt, int fd, void *log) "dev: %p base: 0x%"PRIx64" size: %llu refcn= t: %d fd: %d log: %p" +vhost_vdpa_set_vring_addr(void *dev, unsigned int index, unsigned int flag= s, uint64_t desc_user_addr, uint64_t used_user_addr, uint64_t avail_user_ad= dr, uint64_t log_guest_addr) "dev: %p index: %u flags: 0x%x desc_user_addr:= 0x%"PRIx64" used_user_addr: 0x%"PRIx64" avail_user_addr: 0x%"PRIx64" log_g= uest_addr: 0x%"PRIx64 +vhost_vdpa_set_vring_num(void *dev, unsigned int index, unsigned int num) = "dev: %p index: %u num: %u" +vhost_vdpa_set_vring_base(void *dev, unsigned int index, unsigned int num)= "dev: %p index: %u num: %u" +vhost_vdpa_get_vring_base(void *dev, unsigned int index, unsigned int num)= "dev: %p index: %u num: %u" +vhost_vdpa_set_vring_kick(void *dev, unsigned int index, int fd) "dev: %p = index: %u fd: %d" +vhost_vdpa_set_vring_call(void *dev, unsigned int index, int fd) "dev: %p = index: %u fd: %d" +vhost_vdpa_get_features(void *dev, uint64_t features) "dev: %p features: 0= x%"PRIx64 +vhost_vdpa_set_owner(void *dev) "dev: %p" +vhost_vdpa_vq_get_addr(void *dev, void *vq, uint64_t desc_user_addr, uint6= 4_t avail_user_addr, uint64_t used_user_addr) "dev: %p vq: %p desc_user_add= r: 0x%"PRIx64" avail_user_addr: 0x%"PRIx64" used_user_addr: 0x%"PRIx64 + # virtio.c virtqueue_alloc_element(void *elem, size_t sz, unsigned in_num, unsigned o= ut_num) "elem %p size %zd in_num %u out_num %u" virtqueue_fill(void *vq, const void *elem, unsigned int len, unsigned int = idx) "vq %p elem %p len %u idx %u" diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c index 4580f3efd8a2..c43e12551546 100644 --- a/hw/virtio/vhost-vdpa.c +++ b/hw/virtio/vhost-vdpa.c @@ -20,6 +20,8 @@ #include "hw/virtio/vhost-vdpa.h" #include "qemu/main-loop.h" #include "cpu.h" +#include "trace.h" +#include "qemu-common.h" =20 static bool vhost_vdpa_listener_skipped_section(MemoryRegionSection *secti= on) { @@ -48,6 +50,9 @@ static int vhost_vdpa_dma_map(struct vhost_vdpa *v, hwadd= r iova, hwaddr size, msg.iotlb.perm =3D readonly ? VHOST_ACCESS_RO : VHOST_ACCESS_RW; msg.iotlb.type =3D VHOST_IOTLB_UPDATE; =20 + trace_vhost_vdpa_dma_map(v, fd, msg.type, msg.iotlb.iova, msg.iotlb.siz= e, + msg.iotlb.uaddr, msg.iotlb.perm, msg.iotlb.typ= e); + if (write(fd, &msg, sizeof(msg)) !=3D sizeof(msg)) { error_report("failed to write, fd=3D%d, errno=3D%d (%s)", fd, errno, strerror(errno)); @@ -69,6 +74,9 @@ static int vhost_vdpa_dma_unmap(struct vhost_vdpa *v, hwa= ddr iova, msg.iotlb.size =3D size; msg.iotlb.type =3D VHOST_IOTLB_INVALIDATE; =20 + trace_vhost_vdpa_dma_unmap(v, fd, msg.type, msg.iotlb.iova, + msg.iotlb.size, msg.iotlb.type); + if (write(fd, &msg, sizeof(msg)) !=3D sizeof(msg)) { error_report("failed to write, fd=3D%d, errno=3D%d (%s)", fd, errno, strerror(errno)); @@ -114,6 +122,9 @@ static void vhost_vdpa_listener_region_add(MemoryListen= er *listener, section->offset_within_region + (iova - section->offset_within_address_space); =20 + trace_vhost_vdpa_listener_region_add(v, iova, int128_get64(llend), + vaddr, section->readonly); + llsize =3D int128_sub(llend, int128_make64(iova)); =20 ret =3D vhost_vdpa_dma_map(v, iova, int128_get64(llsize), @@ -170,6 +181,8 @@ static void vhost_vdpa_listener_region_del(MemoryListen= er *listener, llend =3D int128_add(llend, section->size); llend =3D int128_and(llend, int128_exts64(TARGET_PAGE_MASK)); =20 + trace_vhost_vdpa_listener_region_del(v, iova, int128_get64(llend)); + if (int128_ge(int128_make64(iova), llend)) { return; } @@ -210,6 +223,7 @@ static void vhost_vdpa_add_status(struct vhost_dev *dev= , uint8_t status) { uint8_t s; =20 + trace_vhost_vdpa_add_status(dev, status); if (vhost_vdpa_call(dev, VHOST_VDPA_GET_STATUS, &s)) { return; } @@ -224,6 +238,7 @@ static int vhost_vdpa_init(struct vhost_dev *dev, void = *opaque) struct vhost_vdpa *v; uint64_t features; assert(dev->vhost_ops->backend_type =3D=3D VHOST_BACKEND_TYPE_VDPA); + trace_vhost_vdpa_init(dev, opaque); =20 v =3D opaque; dev->opaque =3D opaque ; @@ -243,6 +258,7 @@ static int vhost_vdpa_cleanup(struct vhost_dev *dev) struct vhost_vdpa *v; assert(dev->vhost_ops->backend_type =3D=3D VHOST_BACKEND_TYPE_VDPA); v =3D dev->opaque; + trace_vhost_vdpa_cleanup(dev, v); memory_listener_unregister(&v->listener); =20 dev->opaque =3D NULL; @@ -251,13 +267,25 @@ static int vhost_vdpa_cleanup(struct vhost_dev *dev) =20 static int vhost_vdpa_memslots_limit(struct vhost_dev *dev) { + trace_vhost_vdpa_memslots_limit(dev, INT_MAX); return INT_MAX; } =20 static int vhost_vdpa_set_mem_table(struct vhost_dev *dev, struct vhost_memory *mem) { - + trace_vhost_vdpa_set_mem_table(dev, mem->nregions, mem->padding); + if (trace_event_get_state_backends(TRACE_VHOST_VDPA_SET_MEM_TABLE) && + trace_event_get_state_backends(TRACE_VHOST_VDPA_DUMP_REGIONS)) { + int i; + for (i =3D 0; i < mem->nregions; i++) { + trace_vhost_vdpa_dump_regions(dev, i, + mem->regions[i].guest_phys_addr, + mem->regions[i].memory_size, + mem->regions[i].userspace_addr, + mem->regions[i].flags_padding); + } + } if (mem->padding) { return -1; } @@ -269,6 +297,7 @@ static int vhost_vdpa_set_features(struct vhost_dev *de= v, uint64_t features) { int ret; + trace_vhost_vdpa_set_features(dev, features); ret =3D vhost_vdpa_call(dev, VHOST_SET_FEATURES, &features); uint8_t status =3D 0; if (ret) { @@ -283,26 +312,34 @@ static int vhost_vdpa_set_features(struct vhost_dev *= dev, int vhost_vdpa_get_device_id(struct vhost_dev *dev, uint32_t *device_id) { - return vhost_vdpa_call(dev, VHOST_VDPA_GET_DEVICE_ID, device_id); + int ret; + ret =3D vhost_vdpa_call(dev, VHOST_VDPA_GET_DEVICE_ID, device_id); + trace_vhost_vdpa_get_device_id(dev, *device_id); + return ret; } =20 static int vhost_vdpa_reset_device(struct vhost_dev *dev) { + int ret; uint8_t status =3D 0; =20 - return vhost_vdpa_call(dev, VHOST_VDPA_SET_STATUS, &status); + ret =3D vhost_vdpa_call(dev, VHOST_VDPA_SET_STATUS, &status); + trace_vhost_vdpa_reset_device(dev, status); + return ret; } =20 static int vhost_vdpa_get_vq_index(struct vhost_dev *dev, int idx) { assert(idx >=3D dev->vq_index && idx < dev->vq_index + dev->nvqs); =20 + trace_vhost_vdpa_get_vq_index(dev, idx, idx - dev->vq_index); return idx - dev->vq_index; } =20 static int vhost_vdpa_set_vring_ready(struct vhost_dev *dev) { int i; + trace_vhost_vdpa_set_vring_ready(dev); for (i =3D 0; i < dev->nvqs; ++i) { struct vhost_vring_state state =3D { .index =3D dev->vq_index + i, @@ -313,6 +350,19 @@ static int vhost_vdpa_set_vring_ready(struct vhost_dev= *dev) return 0; } =20 +static void vhost_vdpa_dump_config(struct vhost_dev *dev, const uint8_t *c= onfig, + uint32_t config_len) +{ + int b, len; + char line[QEMU_HEXDUMP_LINE_LEN]; + + for (b =3D 0; b < config_len; b +=3D 16) { + len =3D config_len - b; + qemu_hexdump_line(line, b, config, len, false); + trace_vhost_vdpa_dump_config(dev, line); + } +} + static int vhost_vdpa_set_config(struct vhost_dev *dev, const uint8_t *dat= a, uint32_t offset, uint32_t size, uint32_t flags) @@ -320,6 +370,7 @@ static int vhost_vdpa_set_config(struct vhost_dev *dev,= const uint8_t *data, struct vhost_vdpa_config *config; int ret; unsigned long config_size =3D offsetof(struct vhost_vdpa_config, buf); + trace_vhost_vdpa_set_config(dev, offset, size, flags); config =3D g_malloc(size + config_size); if (config =3D=3D NULL) { return -1; @@ -327,6 +378,10 @@ static int vhost_vdpa_set_config(struct vhost_dev *dev= , const uint8_t *data, config->off =3D offset; config->len =3D size; memcpy(config->buf, data, size); + if (trace_event_get_state_backends(TRACE_VHOST_VDPA_SET_CONFIG) && + trace_event_get_state_backends(TRACE_VHOST_VDPA_DUMP_CONFIG)) { + vhost_vdpa_dump_config(dev, data, size); + } ret =3D vhost_vdpa_call(dev, VHOST_VDPA_SET_CONFIG, config); g_free(config); return ret; @@ -339,6 +394,7 @@ static int vhost_vdpa_get_config(struct vhost_dev *dev,= uint8_t *config, unsigned long config_size =3D offsetof(struct vhost_vdpa_config, buf); int ret; =20 + trace_vhost_vdpa_get_config(dev, config, config_len); v_config =3D g_malloc(config_len + config_size); if (v_config =3D=3D NULL) { return -1; @@ -348,12 +404,17 @@ static int vhost_vdpa_get_config(struct vhost_dev *de= v, uint8_t *config, ret =3D vhost_vdpa_call(dev, VHOST_VDPA_GET_CONFIG, v_config); memcpy(config, v_config->buf, config_len); g_free(v_config); + if (trace_event_get_state_backends(TRACE_VHOST_VDPA_GET_CONFIG) && + trace_event_get_state_backends(TRACE_VHOST_VDPA_DUMP_CONFIG)) { + vhost_vdpa_dump_config(dev, config, config_len); + } return ret; } =20 static int vhost_vdpa_dev_start(struct vhost_dev *dev, bool started) { struct vhost_vdpa *v =3D dev->opaque; + trace_vhost_vdpa_dev_start(dev, started); if (started) { uint8_t status =3D 0; memory_listener_register(&v->listener, &address_space_memory); @@ -375,53 +436,72 @@ static int vhost_vdpa_dev_start(struct vhost_dev *dev= , bool started) static int vhost_vdpa_set_log_base(struct vhost_dev *dev, uint64_t base, struct vhost_log *log) { + trace_vhost_vdpa_set_log_base(dev, base, log->size, log->refcnt, log->= fd, + log->log); return vhost_vdpa_call(dev, VHOST_SET_LOG_BASE, &base); } =20 static int vhost_vdpa_set_vring_addr(struct vhost_dev *dev, struct vhost_vring_addr *addr) { + trace_vhost_vdpa_set_vring_addr(dev, addr->index, addr->flags, + addr->desc_user_addr, addr->used_user_= addr, + addr->avail_user_addr, + addr->log_guest_addr); return vhost_vdpa_call(dev, VHOST_SET_VRING_ADDR, addr); } =20 static int vhost_vdpa_set_vring_num(struct vhost_dev *dev, struct vhost_vring_state *ring) { + trace_vhost_vdpa_set_vring_num(dev, ring->index, ring->num); return vhost_vdpa_call(dev, VHOST_SET_VRING_NUM, ring); } =20 static int vhost_vdpa_set_vring_base(struct vhost_dev *dev, struct vhost_vring_state *ring) { + trace_vhost_vdpa_set_vring_base(dev, ring->index, ring->num); return vhost_vdpa_call(dev, VHOST_SET_VRING_BASE, ring); } =20 static int vhost_vdpa_get_vring_base(struct vhost_dev *dev, struct vhost_vring_state *ring) { - return vhost_vdpa_call(dev, VHOST_GET_VRING_BASE, ring); + int ret; + + ret =3D vhost_vdpa_call(dev, VHOST_GET_VRING_BASE, ring); + trace_vhost_vdpa_get_vring_base(dev, ring->index, ring->num); + return ret; } =20 static int vhost_vdpa_set_vring_kick(struct vhost_dev *dev, struct vhost_vring_file *file) { + trace_vhost_vdpa_set_vring_kick(dev, file->index, file->fd); return vhost_vdpa_call(dev, VHOST_SET_VRING_KICK, file); } =20 static int vhost_vdpa_set_vring_call(struct vhost_dev *dev, struct vhost_vring_file *file) { + trace_vhost_vdpa_set_vring_call(dev, file->index, file->fd); return vhost_vdpa_call(dev, VHOST_SET_VRING_CALL, file); } =20 static int vhost_vdpa_get_features(struct vhost_dev *dev, uint64_t *features) { - return vhost_vdpa_call(dev, VHOST_GET_FEATURES, features); + int ret; + + ret =3D vhost_vdpa_call(dev, VHOST_GET_FEATURES, features); + trace_vhost_vdpa_get_features(dev, *features); + return ret; } =20 static int vhost_vdpa_set_owner(struct vhost_dev *dev) { + trace_vhost_vdpa_set_owner(dev); return vhost_vdpa_call(dev, VHOST_SET_OWNER, NULL); } =20 @@ -432,6 +512,8 @@ static int vhost_vdpa_vq_get_addr(struct vhost_dev *dev, addr->desc_user_addr =3D (uint64_t)(unsigned long)vq->desc_phys; addr->avail_user_addr =3D (uint64_t)(unsigned long)vq->avail_phys; addr->used_user_addr =3D (uint64_t)(unsigned long)vq->used_phys; + trace_vhost_vdpa_vq_get_addr(dev, vq, addr->desc_user_addr, + addr->avail_user_addr, addr->used_user_ad= dr); return 0; } =20 --=20 2.26.2