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 36D15A2F6B for ; Tue, 8 Oct 2019 10:25:22 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 1205C1BFEF; Tue, 8 Oct 2019 10:25:22 +0200 (CEST) Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by dpdk.org (Postfix) with ESMTP id 347AD1BFD5 for ; Tue, 8 Oct 2019 10:25:21 +0200 (CEST) Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) (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 6838A19D369 for ; Tue, 8 Oct 2019 08:25:20 +0000 (UTC) Received: by mail-wm1-f70.google.com with SMTP id r21so669166wme.5 for ; Tue, 08 Oct 2019 01:25:20 -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=d2rqInfQAiXtrvQcy3qhguZzPDcPSxgeo8zjD7H5Jjg/wZdx0zNAdlZIRoaJ2UXqTm hudPSP3xxxF/VWMviCq740A1BUAAwxxFihX6FZ5OLZ69iA2SlmpauFJu8cR54iW4kN6j N/o0XioE3dJHlHKOCToowtU7JyP7aPiD+CM8BbtizKF4RKD1N8ODyiewi3AHZPnu83dO srTvJviTUl/FAagdef2hTvpya86ukEQXrpI0EBtfMKRjMx6e1ojRyZjKK0hb4d5AuRvI lAolTRz+GDdGiQ1gK1lM7Ae0qA2yTyfHNC7F02MKflrubRdYD25EFFIB3J5eC6wdg78d YxfQ== X-Gm-Message-State: APjAAAUa681hH9cr1uyuV4azMjWc+H7C+OjUVNE7JlGPj6CvNrTU/+eg 4OVOtS6RH3XC+VIRCRPEdpWpLS6rrmSlLE4s5+HY3ZPD/O8woy6DxMHJhOFljey1JtJ/jjTtcPS auJU= X-Received: by 2002:a05:6000:110f:: with SMTP id z15mr24840796wrw.328.1570523119172; 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/Q5VPLx7RX0Qx+y8mMB2Jc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LdoKqize8LjehA+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-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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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