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 C1BD341E9F; Wed, 15 Mar 2023 12:37:26 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9870D40EE4; Wed, 15 Mar 2023 12:37:26 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mails.dpdk.org (Postfix) with ESMTP id 8D34240141 for ; Wed, 15 Mar 2023 12:37:25 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1678880244; 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=sf+w1H+1WhVgWCodldt7IQ2un26DVTKUTo8to8FGpSs=; b=Hu1rcdpOQlcGcUwwSCItfKcurqy7/F2vou1xp3KHxalgwAKJlz6lsRpslUeObhGIqSE3+0 /WocHRfUmzosT/oVG18ri4yjfVCMUZsOFQb+W8PgoMQstsMLfPV2vULYwSsk9ztUKsj4UH 1658OwLhaDz0PN/81iiOmfvBQ4wxSyM= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-629-Ii6FgovnPbWBv0wdDIKPHA-1; Wed, 15 Mar 2023 07:37:20 -0400 X-MC-Unique: Ii6FgovnPbWBv0wdDIKPHA-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 36F69884EC9; Wed, 15 Mar 2023 11:37:17 +0000 (UTC) Received: from [10.39.208.23] (unknown [10.39.208.23]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3FD001121314; Wed, 15 Mar 2023 11:37:16 +0000 (UTC) Message-ID: <7d212820-9b08-b111-5d2d-c2c9624d5634@redhat.com> Date: Wed, 15 Mar 2023 12:37:14 +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] vhost: fix madvise IOTLB entries pages overlap check To: dev@dpdk.org, mkp@redhat.com, chenbo.xia@intel.com, david.marchand@redhat.com References: <20230315113158.442632-1-maxime.coquelin@redhat.com> From: Maxime Coquelin In-Reply-To: <20230315113158.442632-1-maxime.coquelin@redhat.com> X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 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:31, 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..bfa04a0439 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) & mask) != Oups, forgot to amend a change before generating the patch. It should be (node->uaddr + node->size - 1) as we want the end address of the entry. > + (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) & mask) != Same here. > + (next_node->uaddr & mask)) > mem_set_dump((void *)(uintptr_t)node->uaddr, node->size, > false, alignment); > } Sending v2.