From: Adrian Moreno <amorenoz@redhat.com>
To: "Liu, Yong" <yong.liu@intel.com>
Cc: "dev@dpdk.org" <dev@dpdk.org>,
"maxime.coquelin@redhat.com" <maxime.coquelin@redhat.com>,
"Bie, Tiwei" <tiwei.bie@intel.com>,
"Wang, Zhihong" <zhihong.wang@intel.com>
Subject: Re: [dpdk-dev] [PATCH] vhost: fix vhost user virtqueue not accessable
Date: Tue, 29 Oct 2019 11:02:20 +0100 [thread overview]
Message-ID: <b130a76a-8ede-5831-9b04-25c7d986157e@redhat.com> (raw)
In-Reply-To: <86228AFD5BCD8E4EBFD2B90117B5E81E633E5471@SHSMSX103.ccr.corp.intel.com>
On 10/28/19 3:13 AM, Liu, Yong wrote:
>
>
>> -----Original Message-----
>> From: Adrian Moreno [mailto:amorenoz@redhat.com]
>> Sent: Friday, October 25, 2019 8:21 PM
>> To: Liu, Yong <yong.liu@intel.com>; maxime.coquelin@redhat.com; Bie, Tiwei
>> <tiwei.bie@intel.com>; Wang, Zhihong <zhihong.wang@intel.com>
>> Cc: dev@dpdk.org
>> Subject: Re: [PATCH] vhost: fix vhost user virtqueue not accessable
>>
>> Hi Marvin,
>>
>> On 10/25/19 6:20 PM, Marvin Liu wrote:
>>> Log feature is disabled in vhost user, so that log address was invalid
>>> when checking. Add feature bit check can skip useless address check.
>>>
>> Just so I understand, what conditions is the log address invalid?
>>
>>> Fixes: 04cfc7fdbfca ("vhost: translate incoming log address to gpa")
>>>
>>> Signed-off-by: Marvin Liu <yong.liu@intel.com>
>>> ---
>>> lib/librte_vhost/vhost_user.c | 16 +++++++++-------
>>> 1 file changed, 9 insertions(+), 7 deletions(-)
>>>
>>> diff --git a/lib/librte_vhost/vhost_user.c
>> b/lib/librte_vhost/vhost_user.c
>>> index 61ef699ac..0407fdc29 100644
>>> --- a/lib/librte_vhost/vhost_user.c
>>> +++ b/lib/librte_vhost/vhost_user.c
>>> @@ -741,13 +741,15 @@ translate_ring_addresses(struct virtio_net *dev,
>> int vq_index)
>>> vq->last_avail_idx = vq->used->idx;
>>> }
>>>
>>> - vq->log_guest_addr =
>>> - translate_log_addr(dev, vq, addr->log_guest_addr);
>>> - if (vq->log_guest_addr == 0) {
>>> - RTE_LOG(DEBUG, VHOST_CONFIG,
>>> - "(%d) failed to map log_guest_addr .\n",
>>> - dev->vid);
>>> - return dev;
>>> + if (dev->features & (1ULL << VHOST_F_LOG_ALL)) {
>>> + vq->log_guest_addr =
>>> + translate_log_addr(dev, vq, addr->log_guest_addr);
>>
>> VHOST_F_LOG_ALL is only negotiated once the migration has started (at least
>> from
>> qemu's perspective).
>> That means that we will postponing the translation of the log address to
>> the
>> vhost_user_set_vring_addr() call that follows the VHOST_F_LOG_ALL enabling.
>> In
>> that call there are (at least) two things that could go wrong and lead to a
>> migration failure:
>> - If VHOST_USER_F_PROTOCOL_FEATURES is not enabled, the address won't be
>> translated:
>>
>> vhost_user:795
>> if ((vq->enabled && (dev->features &
>> (1ULL << VHOST_USER_F_PROTOCOL_FEATURES))) ||
>> access_ok) {
>> dev = translate_ring_addresses(dev, msg->payload.addr.index);
>> if (!dev)
>> return RTE_VHOST_MSG_RESULT_ERR;
>>
>> *pdev = dev;
>> }
>>
>> - If the IOMMU is enabled and there's a miss, we would have to wait for the
>> IOTLB_UPDATE and during that time, there would be failed accesses to the
>> (still
>> untranslated) log address.
>>
>>
>
> Thanks, Adrian.
> Log address can be zero when logging is not enabled.
> How about add other criteria after translation? Log address will be translated anyway and not affect vq status.
>
> vq->log_guest_addr =
> translate_log_addr(dev, vq, addr->log_guest_addr);
> - if (vq->log_guest_addr == 0) {
> + if (vq->log_guest_addr == 0 && addr->flags) {
> RTE_LOG(DEBUG, VHOST_CONFIG,
> "(%d) failed to map log_guest_addr .\n",
> dev->vid);
> return dev;
> }
>
That makes perfect sense IMHO. Thank you.
> Meanwhile, log address of packed ring is fixed to zero. Is any special reason to do that?
>
No idea to be honest.
Thanks.
Adrian
> Regards,
> Marvin
>
>>
>>> + if (vq->log_guest_addr == 0) {
>>> + RTE_LOG(DEBUG, VHOST_CONFIG,
>>> + "(%d) failed to map log_guest_addr .\n",
>>> + dev->vid);
>>> + return dev;
>>> + }
>>> }
>>> vq->access_ok = 1;
>>>
>>>
>> Thanks,
>> Adrian
next prev parent reply other threads:[~2019-10-29 10:02 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-25 16:20 Marvin Liu
2019-10-25 12:20 ` Adrian Moreno
2019-10-28 2:13 ` Liu, Yong
2019-10-29 10:02 ` Adrian Moreno [this message]
2019-10-30 11:07 ` [dpdk-dev] [PATCH v2] vhost: fix vhost user virtqueue not accessible Marvin Liu
2019-10-30 6:58 ` Tiwei Bie
2019-10-30 14:56 ` [dpdk-dev] [PATCH v3] " Marvin Liu
2019-10-31 10:42 ` Tiwei Bie
2019-10-31 14:54 ` Liu, Yong
2019-10-31 17:47 ` Adrian Moreno
2019-11-01 7:16 ` Liu, Yong
2019-11-04 8:44 ` Adrian Moreno
2019-11-04 10:13 ` [dpdk-dev] [PATCH v4] " Marvin Liu
2019-11-04 8:47 ` Adrian Moreno
2019-11-06 20:16 ` Maxime Coquelin
2019-11-06 20:59 ` Maxime Coquelin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=b130a76a-8ede-5831-9b04-25c7d986157e@redhat.com \
--to=amorenoz@redhat.com \
--cc=dev@dpdk.org \
--cc=maxime.coquelin@redhat.com \
--cc=tiwei.bie@intel.com \
--cc=yong.liu@intel.com \
--cc=zhihong.wang@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).