From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from dpdk.org (dpdk.org [92.243.14.124])
	by inbox.dpdk.org (Postfix) with ESMTP id 42467A2F6B
	for <public@inbox.dpdk.org>; Tue,  8 Oct 2019 09:38:26 +0200 (CEST)
Received: from [92.243.14.124] (localhost [127.0.0.1])
	by dpdk.org (Postfix) with ESMTP id C4DB21BFF8;
	Tue,  8 Oct 2019 09:38:24 +0200 (CEST)
Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28])
 by dpdk.org (Postfix) with ESMTP id 439C51BFDF
 for <dev@dpdk.org>; Tue,  8 Oct 2019 09:38:22 +0200 (CEST)
Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com
 [209.85.221.71])
 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
 (No client certificate requested)
 by mx1.redhat.com (Postfix) with ESMTPS id 359F54FCDA
 for <dev@dpdk.org>; Tue,  8 Oct 2019 07:38:21 +0000 (UTC)
Received: by mail-wr1-f71.google.com with SMTP id i2so4998275wrv.0
 for <dev@dpdk.org>; Tue, 08 Oct 2019 00:38:21 -0700 (PDT)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:subject:to:cc:references:from:autocrypt
 :message-id:date:user-agent:mime-version:in-reply-to
 :content-language:content-transfer-encoding;
 bh=cBmcwIeFIfRe/dQ22qKOn3VLEZ6If9NlUhYd3zbMJZg=;
 b=lfwFmnXbhRgps3GN+SKEypA52ysleEKV/CggQQuF8Kp9eVFUyPpxQ96zo5JCXCUiaH
 fUjkU5CKXBiqfsqDSCzS/m4OQBiSi/xSwncMAcbIB5zNDXRDnwfOkAiqgi9aaYnvBV/J
 Z9vCwzq5917PSApbL/mPxflev5BAGI/ka0kXnmXEDhfj6Rv2etfClSz0ieokGsxvsoQf
 geI9N8+IlU555QMjEciC2s85u9kxheZ8WGivGEza7jXGhLKGIzfgG3BnEy7mRWlJ0Hm0
 Z8ZcUmhrAq+DBRjkgXdgh7ko4YsSmWymrWzpBSxFOd+ab3qKBBkZMAdylhFHf2HxJC33
 VNeg==
X-Gm-Message-State: APjAAAW5Z57PwQSWTdXRPddjhJzKkbOhl0PcXjK0MSy52PXEB1TCWbvH
 c9stTWgTAAs6hikgpvSq3fySQCs2Me19BIZIFr2RPB3SA06h6+dTpi/plBEmiWwnYv1BR7xMKyr
 BHS0=
X-Received: by 2002:a5d:4bc7:: with SMTP id l7mr19448457wrt.188.1570520299896; 
 Tue, 08 Oct 2019 00:38:19 -0700 (PDT)
X-Google-Smtp-Source: APXvYqwtv1TyvZF6eFSOQhs58UVpL9swCCbw01OzpXm2O7df32AAgqrSVaF6TcDssSXqbcRT9WGifw==
X-Received: by 2002:a5d:4bc7:: with SMTP id l7mr19448434wrt.188.1570520299621; 
 Tue, 08 Oct 2019 00:38:19 -0700 (PDT)
Received: from amorenoz.users.ipa.redhat.com ([81.0.4.169])
 by smtp.gmail.com with ESMTPSA id y18sm44378968wro.36.2019.10.08.00.38.18
 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);
 Tue, 08 Oct 2019 00:38:18 -0700 (PDT)
To: Tiwei Bie <tiwei.bie@intel.com>
Cc: dev@dpdk.org, zhihong.wang@intel.com, maxime.coquelin@redhat.com,
 stable@dpdk.org
References: <20190927183759.18816-1-amorenoz@redhat.com>
 <20190927183759.18816-3-amorenoz@redhat.com> <20191008063049.GB25865@___>
From: Adrian Moreno <amorenoz@redhat.com>
Autocrypt: addr=amorenoz@redhat.com; prefer-encrypt=mutual; keydata=
 mQENBF1syNUBCADQ9dk3fDMxOZ/+OQpmbanpodYxEv8IRtDz8PXw8YX7UyGfozOpLjQ8Fftj
 ZxuubYNbt2QVbSgviFilFdNWu2eTnN/JaGtfhmTOLPVoakkPHZF8lbgImMoch7L0fH8wN2IM
 KPxQyPNlX+K9FD5brHsV1lfe1TwAxmhcvLW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c
 SwARAQABiQE8BBgBCAAmFiEEogUDgihhmbOPHy26d5C5fbYeFsUFAl1syNUCGwwFCQHhM4AA
 CgkQd5C5fbYeFsUlSwf8CH+u/IXaE7WeWxwFkMaORfW8cM4q0xrL3M6yRGuQNW+kMjnrvK9U
 J9G+L1/5uTRbDQ/4LdoKqize8LjehA+iF6ba4t9Npikh8fLKWgaJfQ/hPhH4C3O5gWPOLTW6
 ylGxiuER4CdFwQIoAMMslhFA7G+teeOKBq36E+1+zrybI6Xy1UBSlpDK9j4CtTnMQejjuSQb
 Qhle+l8VroaUHq869wjAhRHHhqmtJKggI+OvzgQpDIwfHIDypb1BuKydi2W6cVYEALUYyCLS
 dTBDhzj8zR5tPCsga8J7+TclQzkWOiI2C6ZtiWrMsL/Uym3uXk5nsoc7lSj7yLd/MrBRhYfP JQ==
Message-ID: <afaf39d3-9ca8-e1ab-a273-3ce23c51d9fd@redhat.com>
Date: Tue, 8 Oct 2019 09:38:18 +0200
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101
 Thunderbird/68.1.0
MIME-Version: 1.0
In-Reply-To: <20191008063049.GB25865@___>
Content-Type: text/plain; charset=utf-8
Content-Language: en-US
Content-Transfer-Encoding: 7bit
Subject: Re: [dpdk-dev] [PATCH v3 2/3] vhost: convert buffer addresses to
	GPA for logging
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
Errors-To: dev-bounces@dpdk.org
Sender: "dev" <dev-bounces@dpdk.org>

On 10/8/19 8:30 AM, Tiwei Bie wrote:
> On Fri, Sep 27, 2019 at 08:37:58PM +0200, Adrian Moreno wrote:
>> Note that the API facing rte_vhost_log_write is not modified.
>> So, make explicit that it expects the address in GPA space.
>>
>> Fixes: 69c90e98f483 ("vhost: enable IOMMU support")
>> Cc: maxime.coquelin@redhat.com
>> Cc: stable@dpdk.org
>>
>> Signed-off-by: Adrian Moreno <amorenoz@redhat.com>
>> ---
>>  lib/librte_vhost/rte_vhost.h  |  2 +-
>>  lib/librte_vhost/vdpa.c       |  4 +++-
>>  lib/librte_vhost/vhost.c      | 21 +++++++++++++++++++++
>>  lib/librte_vhost/vhost.h      | 16 ++++++++++++++++
>>  lib/librte_vhost/virtio_net.c | 12 +++++++-----
>>  5 files changed, 48 insertions(+), 7 deletions(-)
>>
>> diff --git a/lib/librte_vhost/rte_vhost.h b/lib/librte_vhost/rte_vhost.h
>> index 7fb172912..16c7e4243 100644
>> --- a/lib/librte_vhost/rte_vhost.h
>> +++ b/lib/librte_vhost/rte_vhost.h
>> @@ -265,7 +265,7 @@ rte_vhost_va_from_guest_pa(struct rte_vhost_memory *mem,
>>   * @param vid
>>   *  vhost device ID
>>   * @param addr
>> - *  the starting address for write
>> + *  the starting address for write (in guest physical address space)
>>   * @param len
>>   *  the length to write
>>   */
>> diff --git a/lib/librte_vhost/vdpa.c b/lib/librte_vhost/vdpa.c
>> index 8e45ce9f8..11fd5aede 100644
>> --- a/lib/librte_vhost/vdpa.c
>> +++ b/lib/librte_vhost/vdpa.c
>> @@ -201,7 +201,9 @@ rte_vdpa_relay_vring_used(int vid, uint16_t qid, void *vring_m)
>>  				goto fail;
>>  			desc = desc_ring[desc_id];
>>  			if (desc.flags & VRING_DESC_F_WRITE)
>> -				vhost_log_write(dev, desc.addr, desc.len);
>> +				vhost_log_cache_write_iova(dev, vq,
>> +							   desc.addr,
>> +							   desc.len);
> 
> This will only log the dirty pages in cache.
You're right. Thanks for spotting it. I will change it in the next version.
> 
> 
>>  			desc_id = desc.next;
>>  		} while (desc.flags & VRING_DESC_F_NEXT);
>>  
>> diff --git a/lib/librte_vhost/vhost.c b/lib/librte_vhost/vhost.c
>> index e57dda22f..78457a77c 100644
>> --- a/lib/librte_vhost/vhost.c
>> +++ b/lib/librte_vhost/vhost.c
>> @@ -200,6 +200,27 @@ __vhost_log_cache_write(struct virtio_net *dev, struct vhost_virtqueue *vq,
>>  	}
>>  }
>>  
>> +void
>> +__vhost_log_cache_write_iova(struct virtio_net *dev, struct vhost_virtqueue *vq,
>> +			     uint64_t iova, uint64_t len)
>> +{
>> +	uint64_t hva, gpa, map_len;
>> +	map_len = len;
>> +
>> +	hva = __vhost_iova_to_vva(dev, vq, iova, &map_len, VHOST_ACCESS_RW);
>> +	if (map_len != len) {
>> +		RTE_LOG(ERR, VHOST_CONFIG,
>> +			"Failed to write log for IOVA 0x%0lx."
> 
> PRIx64 should be used here, otherwise the build will be
> broken on i686.
> 
> It's better to add a space after '.'
Thank you. Will do.
> 
> 
>> +			"No IOTLB entry found\n",
>> +			iova);
>> +		return;
>> +	}
>> +
>> +	gpa = hva_to_gpa(dev, hva, len);
>> +	if (gpa)
>> +		__vhost_log_cache_write(dev, vq, gpa, len);
>> +}
>> +