From nobody Fri Nov 14 12:16:54 2025 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=foxmail.com ARC-Seal: i=1; a=rsa-sha256; t=1587911701; cv=none; d=zohomail.com; s=zohoarc; b=k6BFKl8FCfpGQwsX5LwZyrXZpqvMu4Bdq1gxV9HjeryGpybHHRocQthgp9GdkL6g5djkjAhfL5mBDTGV9pcHKjwzV0sMNykELpFqV9oHj6wHmavaUVvEmPrylPYzLzAE/v4zJ0gewVYBhtoVoufdzjhj/61hwoPrZn6GRJGqCxY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1587911701; h=Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=jvIG8j//AbEeqMWpFi5xJu/UZ8C/QeSTeZTr2Onp2nA=; b=mUkNqqlwtDoB5lynrBeqBifF+CgAU1f7WAc9RpkKXi2t3BH1NiSclXbPVauEy/nhDa7KbCDTjXugzQ9DbsJHJXYmCrGTdcFXbYLkj+pHgClNeQonbdMjZj5dQVp0VpKCF8kzJ+v6ymCiSx+SeB9Z44+gDFIRm/UltZRwavOZMQA= 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 1587911701813393.1473734719681; Sun, 26 Apr 2020 07:35:01 -0700 (PDT) Received: from localhost ([::1]:60554 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jSiN2-0007RF-42 for importer@patchew.org; Sun, 26 Apr 2020 10:35:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58692) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jSiM5-0006aR-1i for qemu-devel@nongnu.org; Sun, 26 Apr 2020 10:34:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.90_1) (envelope-from ) id 1jSiM2-00053X-HJ for qemu-devel@nongnu.org; Sun, 26 Apr 2020 10:34:00 -0400 Received: from out203-205-221-205.mail.qq.com ([203.205.221.205]:52526 helo=qq.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jSiLz-0004Wf-O0 for qemu-devel@nongnu.org; Sun, 26 Apr 2020 10:33:58 -0400 Received: from localhost.localdomain ([123.185.180.85]) by newxmesmtplogicsvrszc7.qq.com (NewEsmtp) with SMTP id 820A4664; Sun, 26 Apr 2020 22:32:32 +0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qq.com; s=s201512; t=1587911627; bh=jvIG8j//AbEeqMWpFi5xJu/UZ8C/QeSTeZTr2Onp2nA=; h=From:To:Cc:Subject:Date; b=LQ7c7xfMH5jl8IkcL0k62TPs1Q7wqtRVHYcJDIIFZeMe4mORV4+OVH/mti79jlhM7 lOrvPYze4HjvwkK7C7lCSFI5jCGCGDKZAzbK6NDxVFJhxPJszI5ZwVJiNJH6ln9MQt iSuh0yLyfh4PvNl8keoB44kI7gPU/txLRYzMbqlg= X-QQ-mid: xmsmtpt1587911552tqus51fs6 X-QQ-XMAILINFO: MRtgQJ5r0UjaRway8WzWfKMoY4HLJYIto90evLlR7jg5NV+aiWj/hx/UndnMox pd9dZVfneArug+EDF5iRggh1XMSlSIaoRJ7nwFpmTE2vDQlJtO3MSJgK26zfFhbT248DbXRgVgQS lyEBqETdyfparn6nK6knRsdN40qeEVi/JT2V7PaQjvpPvktZVqffEDmymmbX/GyqnsxMl4+K2JZJ z2toF3vh1gUqLxCtS+Y4iE+mpVT6cb8honm28U/+Oakvbas8sdjcQvtjT5rLuG/Ctxvs8QLmLxmK d1chPN6TW+p32GEQwglRjgBotsTr4SLWYBE+oFb0HxO+UWzrDdmIB7Fn+ievnAMn0EEoVv2zg4CU HYq0G4+pLSyNIcXtdnQJO07DhY9VMGNs2JCZ9Wz2pp4NGAJrqt+8+MB+RtZ+/wTuHaxmo2eC47oi gbc6vkRvG2u91eZAhLOfIiFNGdR5HwMMtpvBSOoUHhBthpoUHLYA5db31gya6hnI4A2Wc1c2C5dc Lhxl3RTsIvV46FsP5Bggi1nSddjBk9XpnZbTDWZx3T0YgZtTt41LH+4Omy/hev9rFiydnDz1R+0J trPIoOybgmJMzkwUxXRCMpDtqHh5tPo1zGlabFajPEYLasRoGNEwGZGIAfxwREoGtWXDPF1cuP5j +/vw== From: teachk To: qemu-devel@nongnu.org Subject: [PATCH] Convert DPRINTF() to trace event Date: Sun, 26 Apr 2020 22:32:17 +0800 Message-Id: <20200426143217.1962-1-teachk@foxmail.com> X-Mailer: git-send-email 2.22.0.windows.1 MIME-Version: 1.0 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=203.205.221.205; envelope-from=teachk@foxmail.com; helo=qq.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/04/26 10:33:48 X-ACL-Warn: Detected OS = Linux 3.1-3.10 X-Received-From: 203.205.221.205 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: arei.gonglei@huawei.com, Halloween , mst@redhat.com 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" From: Halloween Signed-off-by: Halloween --- hw/virtio/trace-events | 12 ++++++++++++ hw/virtio/virtio-crypto.c | 29 ++++++++++++++++------------- include/hw/virtio/virtio-crypto.h | 11 ----------- 3 files changed, 28 insertions(+), 24 deletions(-) diff --git a/hw/virtio/trace-events b/hw/virtio/trace-events index e83500bee9..f7c20f211a 100644 --- a/hw/virtio/trace-events +++ b/hw/virtio/trace-events @@ -73,3 +73,15 @@ virtio_iommu_get_domain(uint32_t domain_id) "Alloc domai= n=3D%d" virtio_iommu_put_domain(uint32_t domain_id) "Free domain=3D%d" virtio_iommu_translate_out(uint64_t virt_addr, uint64_t phys_addr, uint32_= t sid) "0x%"PRIx64" -> 0x%"PRIx64 " for sid=3D%d" virtio_iommu_report_fault(uint8_t reason, uint32_t flags, uint32_t endpoin= t, uint64_t addr) "FAULT reason=3D%d flags=3D%d endpoint=3D%d address =3D0x= %"PRIx64 + +# virtio-crypto.c +virtio_crypto_cipher_session_helper_cipher_alg_and_direction(uint32_t ciph= er_alg, uint8_t direction) "cipher_alg=3D%" PRIu32 ", info->direction=3D%" = PRIu32 +virtio_crypto_cipher_session_helper_keylen(uint32_t keylen) "keylen=3D%" P= RIu32 +virtio_crypto_create_sym_session_auth_keylen(uint32_t auth_keylen) "auth_k= eylen=3D%" PRIu32 +virtio_crypto_create_sym_session_session_id(int64_t session_id) "create se= ssion_id=3D%" PRIu64 " successfully" +virtio_crypto_sym_op_helper_src_len(uint32_t src_len) "src_len=3D%" PRIu32 +virtio_crypto_sym_op_helper_dst_len(uint32_t dst_len) "dst_len=3D%" PRIu32 +virtio_crypto_sym_op_helper_hash_result_len(uint32_t hash_result_len) "has= h_result_len=3D%" PRIu32 +virtio_crypto_handle_close_session(uint64_t session_id) "close session id = %" PRIu64 +virtio_crypto_sym_op_helper_iv_len(uint32_t iv_len) "iv_len %" PRIu32 +virtio_crypto_sym_op_helper_aad_len(uint32_t aad_len) "aad_len %" PRIu32 diff --git a/hw/virtio/virtio-crypto.c b/hw/virtio/virtio-crypto.c index 4c65114de5..f816db2fca 100644 --- a/hw/virtio/virtio-crypto.c +++ b/hw/virtio/virtio-crypto.c @@ -25,6 +25,8 @@ #include "standard-headers/linux/virtio_ids.h" #include "sysemu/cryptodev-vhost.h" =20 +#include "trace.h" + #define VIRTIO_CRYPTO_VM_VERSION 1 =20 /* @@ -49,8 +51,8 @@ virtio_crypto_cipher_session_helper(VirtIODevice *vdev, info->cipher_alg =3D ldl_le_p(&cipher_para->algo); info->key_len =3D ldl_le_p(&cipher_para->keylen); info->direction =3D ldl_le_p(&cipher_para->op); - DPRINTF("cipher_alg=3D%" PRIu32 ", info->direction=3D%" PRIu32 "\n", - info->cipher_alg, info->direction); + trace_virtio_crypto_cipher_session_helper_cipher_alg_and_direction(\ + info->cipher_alg, info->direction); =20 if (info->key_len > vcrypto->conf.max_cipher_key_len) { error_report("virtio-crypto length of cipher key is too big: %u", @@ -60,7 +62,7 @@ virtio_crypto_cipher_session_helper(VirtIODevice *vdev, /* Get cipher key */ if (info->key_len > 0) { size_t s; - DPRINTF("keylen=3D%" PRIu32 "\n", info->key_len); + trace_virtio_crypto_cipher_session_helper_keylen(info->key_len); =20 info->cipher_key =3D g_malloc(info->key_len); s =3D iov_to_buf(*iov, num, 0, info->cipher_key, info->key_len); @@ -130,7 +132,9 @@ virtio_crypto_create_sym_session(VirtIOCrypto *vcrypto, } /* get auth key */ if (info.auth_key_len > 0) { - DPRINTF("auth_keylen=3D%" PRIu32 "\n", info.auth_key_len); + trace_virtio_crypto_create_sym_session_auth_keylen(\ + info.auth_key_len); + info.auth_key =3D g_malloc(info.auth_key_len); s =3D iov_to_buf(iov, out_num, 0, info.auth_key, info.auth_key_len); @@ -165,9 +169,7 @@ virtio_crypto_create_sym_session(VirtIOCrypto *vcrypto, vcrypto->cryptodev, &info, queue_index, &local_err); if (session_id >=3D 0) { - DPRINTF("create session_id=3D%" PRIu64 " successfully\n", - session_id); - + trace_virtio_crypto_create_sym_session_session_id(session_id); ret =3D session_id; } else { if (local_err) { @@ -193,7 +195,7 @@ virtio_crypto_handle_close_session(VirtIOCrypto *vcrypt= o, Error *local_err =3D NULL; =20 session_id =3D ldq_le_p(&close_sess_req->session_id); - DPRINTF("close session, id=3D%" PRIu64 "\n", session_id); + trace_virtio_crypto_handle_close_session(session_id); =20 ret =3D cryptodev_backend_sym_close_session( vcrypto->cryptodev, session_id, queue_id, &local_err); @@ -474,7 +476,8 @@ virtio_crypto_sym_op_helper(VirtIODevice *vdev, op_info->len_to_cipher =3D len_to_cipher; /* Handle the initilization vector */ if (op_info->iv_len > 0) { - DPRINTF("iv_len=3D%" PRIu32 "\n", op_info->iv_len); + trace_virtio_crypto_sym_op_helper_iv_len(op_info->iv_len); + op_info->iv =3D op_info->data + curr_size; =20 s =3D iov_to_buf(iov, out_num, 0, op_info->iv, op_info->iv_len); @@ -488,7 +491,7 @@ virtio_crypto_sym_op_helper(VirtIODevice *vdev, =20 /* Handle additional authentication data if exists */ if (op_info->aad_len > 0) { - DPRINTF("aad_len=3D%" PRIu32 "\n", op_info->aad_len); + trace_virtio_crypto_sym_op_helper_aad_len(op_info->aad_len); op_info->aad_data =3D op_info->data + curr_size; =20 s =3D iov_to_buf(iov, out_num, 0, op_info->aad_data, op_info->aad_= len); @@ -503,7 +506,7 @@ virtio_crypto_sym_op_helper(VirtIODevice *vdev, =20 /* Handle the source data */ if (op_info->src_len > 0) { - DPRINTF("src_len=3D%" PRIu32 "\n", op_info->src_len); + trace_virtio_crypto_sym_op_helper_src_len(op_info->src_len); op_info->src =3D op_info->data + curr_size; =20 s =3D iov_to_buf(iov, out_num, 0, op_info->src, op_info->src_len); @@ -520,11 +523,11 @@ virtio_crypto_sym_op_helper(VirtIODevice *vdev, op_info->dst =3D op_info->data + curr_size; curr_size +=3D op_info->dst_len; =20 - DPRINTF("dst_len=3D%" PRIu32 "\n", op_info->dst_len); + trace_virtio_crypto_sym_op_helper_dst_len(op_info->dst_len); =20 /* Handle the hash digest result */ if (hash_result_len > 0) { - DPRINTF("hash_result_len=3D%" PRIu32 "\n", hash_result_len); + trace_virtio_crypto_sym_op_helper_hash_result_len(hash_result_len); op_info->digest_result =3D op_info->data + curr_size; } =20 diff --git a/include/hw/virtio/virtio-crypto.h b/include/hw/virtio/virtio-c= rypto.h index ffe2391ece..f59f91f11e 100644 --- a/include/hw/virtio/virtio-crypto.h +++ b/include/hw/virtio/virtio-crypto.h @@ -19,17 +19,6 @@ #include "sysemu/iothread.h" #include "sysemu/cryptodev.h" =20 - -#define DEBUG_VIRTIO_CRYPTO 0 - -#define DPRINTF(fmt, ...) \ -do { \ - if (DEBUG_VIRTIO_CRYPTO) { \ - fprintf(stderr, "virtio_crypto: " fmt, ##__VA_ARGS__); \ - } \ -} while (0) - - #define TYPE_VIRTIO_CRYPTO "virtio-crypto-device" #define VIRTIO_CRYPTO(obj) \ OBJECT_CHECK(VirtIOCrypto, (obj), TYPE_VIRTIO_CRYPTO) -- 2.17.1