From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 2BAF7A2F6B for ; Tue, 8 Oct 2019 10:25:24 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 02BA81C0D1; Tue, 8 Oct 2019 10:25:24 +0200 (CEST) Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by dpdk.org (Postfix) with ESMTP id E41501BFD5 for ; Tue, 8 Oct 2019 10:25:21 +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 23C037FDE5 for ; Tue, 8 Oct 2019 08:25:21 +0000 (UTC) Received: by mail-wr1-f71.google.com with SMTP id k4so8638678wru.1 for ; Tue, 08 Oct 2019 01:25: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=3ESFmSCnPqBqOxkSyOWA/KjAkYBHgukzgQHSWwqkG0o=; b=KRK4iUhPQ5VKvaw/+BIfIOyZqu+9jrl0HsbHlYr1XGoOU+ylVNaDJWER+82PlHYXVG LsKqghCTIVpL+bVckS8KvwBZJX9Zv507a0p4x4oGNfZ4yf1NrLkrA/SpaleVJ6K1QyiN Vycp3q/uY5Aj0ysSSv08iVDGJiq90TJUrDoEWDBXMEf92hwRFVhubTPjC7/0h4AhXCip sgy80nPJJBqCcrNFQJV5H/F5Z3+5Vq6xi6aL1hVq4cDNIkF3Ht99TiiExU78OWBvOiZt n9RJgwjv4JDSqcCtbKuhYB6GR5mGI3VWl1tHmBOml7VklX6cQ6ejmYahAOt+bFAXlVs5 1uyw== X-Gm-Message-State: APjAAAVApF9HkAn7r/B9v7+EzLrCe7FJFs8/Zn3CS28xiU9R2Rll68iG t13uNmySiPDZ6FTV7l86Ixeuxq1b5l/mogPGFQ0lEGDwdnZhP+I95ReNhgrcIdDUluaZM0AZEYk WQf3PYOs= X-Received: by 2002:a05:6000:110f:: with SMTP id z15mr24840813wrw.328.1570523119293; Tue, 08 Oct 2019 01:25:19 -0700 (PDT) X-Google-Smtp-Source: APXvYqwFFXAOKuGyYr3x/IPyTnDqcZvxkiMyZ6N5vsvTwt9d/8m/gN9aYt72wFAqhGjvGw0pKCyp4Q== X-Received: by 2002:a05:6000:110f:: with SMTP id z15mr24840779wrw.328.1570523118958; Tue, 08 Oct 2019 01:25:18 -0700 (PDT) Received: from amorenoz.users.ipa.redhat.com (static.169.4.0.81.ibercom.com. [81.0.4.169]) by smtp.gmail.com with ESMTPSA id h63sm3671782wmf.15.2019.10.08.01.25.18 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 08 Oct 2019 01:25:18 -0700 (PDT) To: Tiwei Bie , Maxime Coquelin Cc: dev@dpdk.org, zhihong.wang@intel.com, stable@dpdk.org References: <20190927183759.18816-1-amorenoz@redhat.com> <20190927183759.18816-3-amorenoz@redhat.com> <20191008063049.GB25865@___> <20191008080158.GA9919@___> From: Adrian Moreno Autocrypt: addr=amorenoz@redhat.com; prefer-encrypt=mutual; keydata= mQENBF1syNUBCADQ9dk3fDMxOZ/+OQpmbanpodYxEv8IRtDz8PXw8YX7UyGfozOpLjQ8Fftj ZxuubYNbt2QVbSgviFilFdNWu2eTnN/JaGtfhmTOLPVoakkPHZF8lbgImMoch7L0fH8wN2IM KPxQyPNlX+K9FD5brHsV1lfe1TwAxmhcvLW8yNrVq+9eDIDykxc7tH4exIqXgZroahGxMHKy c8Ti2kJka/t6pDfRaY0J+6J7I1nrn6GXXSMNA45EH8+0N/QlcXhP3rfftnoPeVmpjswzvJqY FNjf/Q5VPL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J9G+L1/5uTRbDQ/4LdoKqize8LjehA+iF6ba4t9Npikh8fLKWgaJfQ/hPhH4C3O5gWPOLTW6 ylGxiuER4CdFwQIoAMMslhFA7G+teeOKBq36E+1+zrybI6Xy1UBSlpDK9j4CtTnMQejjuSQb Qhle+l8VroaUHq869wjAhRHHhqmtJKggI+OvzgQpDIwfHIDypb1BuKydi2W6cVYEALUYyCLS dTBDhzj8zR5tPCsga8J7+TclQzkWOiI2C6ZtiWrMsL/Uym3uXk5nsoc7lSj7yLd/MrBRhYfP JQ== Message-ID: Date: Tue, 8 Oct 2019 10:25:17 +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: <20191008080158.GA9919@___> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Subject: Re: [dpdk-stable] [PATCH v3 2/3] vhost: convert buffer addresses to GPA for logging X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" On 10/8/19 10:01 AM, Tiwei Bie wrote: > On Tue, Oct 08, 2019 at 09:43:48AM +0200, Maxime Coquelin wrote: >> On 10/8/19 9:38 AM, Adrian Moreno wrote: >>> 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 >>>>> --- >>>>> 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", >> >> I personally prefer not to split error messages even it is is slightly >> above 80 chars. It makes grepping for error messages easier. > > +1 > Makes perfect sense. Addressed in the new version. Thanks! > >> >>>>> + iova); >>>>> + return; >>>>> + } >>>>> + >>>>> + gpa = hva_to_gpa(dev, hva, len); >>>>> + if (gpa) >>>>> + __vhost_log_cache_write(dev, vq, gpa, len); >>>>> +} >>>>> + >>> -Adrián