From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 2EADA41EB1; Thu, 16 Mar 2023 15:45:52 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 1F03F42D4E; Thu, 16 Mar 2023 15:45:52 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mails.dpdk.org (Postfix) with ESMTP id 1E30840DDC for ; Thu, 16 Mar 2023 15:45:50 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1678977949; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=j+08DTTj8qOHZ6/2PZGABlFCD06onC2nQBYFYbri6Tg=; b=hxRqwNYp+CVkBNWkTx3G1cmdabjRouXpCU5K8KQVDQORKi49sAdHWitMEX3/e2aXgPwiRF KBf1yKGKM7e0mJeiMusutvH5vbDEuNM+YCG+6p1I0IvPNlaWPAs0I5VetZDAILXNHGtdj8 9VsXwEBmA+rC1M5dRFjM9CgzRspy89A= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-204-zAmudLSEPMSZwQhPESrRyw-1; Thu, 16 Mar 2023 10:45:46 -0400 X-MC-Unique: zAmudLSEPMSZwQhPESrRyw-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5EFE03C16E8A; Thu, 16 Mar 2023 14:45:46 +0000 (UTC) Received: from [10.39.208.23] (unknown [10.39.208.23]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7335440C6E67; Thu, 16 Mar 2023 14:45:45 +0000 (UTC) Message-ID: <321f6730-2c39-75bd-884b-06780b4a6c4c@redhat.com> Date: Thu, 16 Mar 2023 15:45:44 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.8.0 Subject: Re: [PATCH v2] vhost: fix madvise IOTLB entries pages overlap check To: dev@dpdk.org, mkp@redhat.com, chenbo.xia@intel.com, david.marchand@redhat.com References: <20230315114010.444005-1-maxime.coquelin@redhat.com> From: Maxime Coquelin In-Reply-To: <20230315114010.444005-1-maxime.coquelin@redhat.com> X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org On 3/15/23 12:40, Maxime Coquelin wrote: > At removal time, when testing whether the IOTLB entry has > shared pages with the previous and next entries in the > cache, it checks whether the start address of the entry to > be removed is on the same page as the start address of the > next entry in the cache. > > This is not correct, as an entry could cover several page > so the end address of the entry to be remove should be > used. This patch address this issue. > > Fixes: dea092d0addb ("vhost: fix madvise arguments alignment") > > Signed-off-by: Maxime Coquelin > --- > lib/vhost/iotlb.c | 8 ++++---- > 1 file changed, 4 insertions(+), 4 deletions(-) > > diff --git a/lib/vhost/iotlb.c b/lib/vhost/iotlb.c > index 11785392ac..3f45bc6061 100644 > --- a/lib/vhost/iotlb.c > +++ b/lib/vhost/iotlb.c > @@ -182,8 +182,8 @@ vhost_user_iotlb_cache_random_evict(struct virtio_net *dev, struct vhost_virtque > (node->uaddr & mask) != (prev_node->uaddr & mask)) { > next_node = RTE_TAILQ_NEXT(node, next); > /* Don't disable coredump if the next node is in the same page */ > - if (next_node == NULL || > - (node->uaddr & mask) != (next_node->uaddr & mask)) > + if (next_node == NULL || ((node->uaddr + node->size - 1) & mask) != > + (next_node->uaddr & mask)) > mem_set_dump((void *)(uintptr_t)node->uaddr, node->size, > false, alignment); > } > @@ -287,8 +287,8 @@ vhost_user_iotlb_cache_remove(struct virtio_net *dev, struct vhost_virtqueue *vq > (node->uaddr & mask) != (prev_node->uaddr & mask)) { > next_node = RTE_TAILQ_NEXT(node, next); > /* Don't disable coredump if the next node is in the same page */ > - if (next_node == NULL || > - (node->uaddr & mask) != (next_node->uaddr & mask)) > + if (next_node == NULL || ((node->uaddr + node->size - 1) & mask) != > + (next_node->uaddr & mask)) > mem_set_dump((void *)(uintptr_t)node->uaddr, node->size, > false, alignment); > } Applied to dpdk-next-virtio/main. Thanks, Maxime