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 EFAD341EAA; Thu, 16 Mar 2023 02:57:24 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8550B40FDF; Thu, 16 Mar 2023 02:57:24 +0100 (CET) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by mails.dpdk.org (Postfix) with ESMTP id AAE5F40EF1 for ; Thu, 16 Mar 2023 02:57:22 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1678931842; x=1710467842; h=from:to:subject:date:message-id:references:in-reply-to: content-transfer-encoding:mime-version; bh=p17MYODQr8zK37pFO9cTDhMyuQb9uYGd6GGuS7xZVkU=; b=SfIIOGs9VbsJLVwdKCH7l+EHckDyyqc++t3df8DKgpms56m3XbQAhAQR vSGO8Yy30EWWUnUJw37kQoRAY5qAUGitHK7MTJusfEyQkYIFknQToIQZx 8QIGJMIHS2gpV/AxusjmDDAU4heS3r4JZjue/okfmT6yqyF98GYrEMa0C ycqZEwNN4weE+q3Y36ykh42mI/T34fnSHd7qzEQGWisD4xkMc0d2Ga9aB BkfPpvC6mxIqPchALQCRrYAY3w4NjRTLp9jd/RYwMKQQGyGBWNv4ASqYZ 69iIgpAqYi7SpaK1x52vPaWKkQUJaqAYlphhi96xmKzLXOiNtIYVSdYSi g==; X-IronPort-AV: E=McAfee;i="6500,9779,10650"; a="337881665" X-IronPort-AV: E=Sophos;i="5.98,264,1673942400"; d="scan'208";a="337881665" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Mar 2023 18:57:21 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10650"; a="656994009" X-IronPort-AV: E=Sophos;i="5.98,264,1673942400"; d="scan'208";a="656994009" Received: from fmsmsx601.amr.corp.intel.com ([10.18.126.81]) by orsmga006.jf.intel.com with ESMTP; 15 Mar 2023 18:57:20 -0700 Received: from fmsmsx611.amr.corp.intel.com (10.18.126.91) by fmsmsx601.amr.corp.intel.com (10.18.126.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.21; Wed, 15 Mar 2023 18:57:20 -0700 Received: from fmsmsx610.amr.corp.intel.com (10.18.126.90) by fmsmsx611.amr.corp.intel.com (10.18.126.91) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.21; Wed, 15 Mar 2023 18:57:19 -0700 Received: from fmsedg601.ED.cps.intel.com (10.1.192.135) by fmsmsx610.amr.corp.intel.com (10.18.126.90) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.21 via Frontend Transport; Wed, 15 Mar 2023 18:57:19 -0700 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (104.47.58.107) by edgegateway.intel.com (192.55.55.70) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.21; Wed, 15 Mar 2023 18:57:19 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jYHDYoC37dJOh0KvqMtZLKs88R0MTAn36bt+tXzhsLsBEsgpiLulns6Eqm7tKsUMS7yuJRUEMsSBoWYn8CRnjkiAob2D5mG7Tak7wyKTtojXre5UZEcVyyomqbhoimYPMMxetoZm9dggiDPoDurdDe9qUHUlLiuOVy+xxbCTvOBYIKVeie/DXN+Kx8KVv6oKkZoBtRnXRq/nlM7bNoEoEShm7L1CFezherhIOioqkr0gCF6r1HPmNV7vm5s9WuKAyHgxBWI4rPkgRUi4grp3wRDe0NLMgx88HCQ6Jbd2bJB2L3QIQNrzoxknpFVdleA5yPJIMrpL0Ti2BvmnjAOJxg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=M5Pm+NoX7XEVidn5XxKh8jKO9Vo/1/UMA5PrdYzUaxQ=; b=TxPm+46IP411nOKpd06KH97O/cPOEH8iXU5LE28I450OIeKUUuKwRnsqWEkn+9kAKLE3uUn1xQuzbrStQLxs980bqRKxMrvEXMM5V/Z1Z+bwj6V1qRIVRrkukT6bk+iHJBHXiLtone0hV0KXzmJmdZsxV9g6Jfpw7UjewEBWwP28JX8RjVD2n1IJbIoCKTvSdAIr+mkn2jQheTWsEitUxLX3YIKOmz+r8SPhzo0VmaImSZbuf/V5uSf8Dn/pBADgrwiIowDdqJRrl5VmYKa8kcnFHoJ1i1WyBgDqMZqyFAvVB2jMopsSkChn4zWkp4/wPgbuRNWfj90DUa+wKuBCPw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Received: from SN6PR11MB3504.namprd11.prod.outlook.com (2603:10b6:805:d0::17) by PH7PR11MB6547.namprd11.prod.outlook.com (2603:10b6:510:211::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.29; Thu, 16 Mar 2023 01:57:17 +0000 Received: from SN6PR11MB3504.namprd11.prod.outlook.com ([fe80::930b:6671:e4f0:4ebc]) by SN6PR11MB3504.namprd11.prod.outlook.com ([fe80::930b:6671:e4f0:4ebc%3]) with mapi id 15.20.6178.029; Thu, 16 Mar 2023 01:57:17 +0000 From: "Xia, Chenbo" To: Maxime Coquelin , "dev@dpdk.org" , "mkp@redhat.com" , "david.marchand@redhat.com" Subject: RE: [PATCH v2] vhost: fix madvise IOTLB entries pages overlap check Thread-Topic: [PATCH v2] vhost: fix madvise IOTLB entries pages overlap check Thread-Index: AQHZVzL+7H6aJRbezkeytS1O3/jLA678ptPA Date: Thu, 16 Mar 2023 01:57:17 +0000 Message-ID: References: <20230315114010.444005-1-maxime.coquelin@redhat.com> In-Reply-To: <20230315114010.444005-1-maxime.coquelin@redhat.com> Accept-Language: en-US, zh-CN Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: SN6PR11MB3504:EE_|PH7PR11MB6547:EE_ x-ms-office365-filtering-correlation-id: 6fae0906-bca7-4b65-e98c-08db25c1c582 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: XRbstztGouaWE+AOCyTM0H3/qtBhkep5vh7n3jcg5WW+RBwV6i9Cbh0f86vnb6/McuD+dBlao28nooNTziD5Pk3u1fQ71yT4MHThjKzggmkLAbsrku2CFJDkOef76uxG85Dr3O9bYNFal3hAfvsbGEf9Wd0aPMpdYL7Skp/elAn11d6Y/OE4MRhIROaP03bA8Hi+co1SRvIkqXgTOHVSizk1JLJsFDlgeBkRx4mN5yAlhWQZvCFaDArpeNpxfTtnWQrFeT9M7b4eEIF+VzDHNswrP6Tw2/uOKtO9xp8ouN6abz6rF48pouenEkkDS7W8+YEAFy5tVWNqUv5gdIyEpdR2aEOst/+4Ck6qTBeuyxYUPjjzWyGDoCJsxJIjwAvH1GLwA3Hs6XsQfPqN9AOiCuV67WeHA7b6VTg2te7hdG2x3gNZz8o1CNSUDoCp4icpCbv/krHfDK8WvUS34cXf6ax0M9TPv6tJNR1AtOZ/92QAcEdqBvjQLxI69rWrBbAhSCgfMPKGUeQX2N75bFoIDZagi+cPKaQd40AFVs+xH7buTVj+ouxuWsB4cbCA6oZtpPkk8Be1bCazKqnjmRnrtwhvlSczBOaloUp+hRsBYa9hSnxbXD/deEVAQVMObPQ8xP0Cq1TaKfR3tMpPoQOGIBMTyBbP03XjgQKZE35xa0zUSQSkU01zK//TAFcu+ypZjB4I71fM/BFsOaBV2jA+IQ== x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SN6PR11MB3504.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230025)(366004)(136003)(346002)(396003)(39860400002)(376002)(451199018)(33656002)(38070700005)(86362001)(38100700002)(122000001)(82960400001)(8936002)(2906002)(5660300002)(52536014)(41300700001)(55016003)(6506007)(66446008)(26005)(186003)(9686003)(83380400001)(53546011)(316002)(110136005)(478600001)(8676002)(66476007)(66556008)(7696005)(71200400001)(66946007)(76116006)(64756008); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?boe6uecib1tIWo8aJgFvee6b1Oia9mQ0K+cGsF0BEgi3JB9X5fZukllXuSg9?= =?us-ascii?Q?gtscjHnCOgUducxj9OK7bYWt7pAHly90DVEDIpHtkCba752dgs1SCoYPlUUQ?= =?us-ascii?Q?YGOLQ1/PS3qcS2VKYrDEPCXm2//A6HU2aQJtATtYZocgQOYRgCRgdNWzJgWC?= =?us-ascii?Q?KGa7+b4XfLMbOqFRw757JBWT0qniiXWL6tFPbfxUzVsem6nfgzXeeXvTQ3Xc?= =?us-ascii?Q?ItEVgkkYTOFBd5SFMcU1+U4dTBJHbKKHJaLFMoaOdHmqnc9O56WepSiOivwq?= =?us-ascii?Q?NGaCkIl/2b0hsIeUDGKADZPRwolfF4D9eD4NsDBNpLsdAIue0nlsLhejssrV?= =?us-ascii?Q?knX/gJEx1+DolO00zw2+1F+RqcgL7nE8cS/y85YkkvXLHJG8Fy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sMHtxz4VP/HdakBADwx3Iv6rgMXA0FKn8?= =?us-ascii?Q?+v6P8HI55qVJmnr6cPF5WJpbjxeguhGk5mBJp5MUsYtx+jbq7A1w+eqVIy+B?= =?us-ascii?Q?kCWG8Q4c1c8zZX7RPoCrOgsfozrPKWM1DNq/ivpKAPxEqNcQXZ+11Tnvv+h8?= =?us-ascii?Q?fPB5sk+740oFrcLFIsc88anYfkmSuVllIjCQJMUwY2GHkUzel3n8fSDiUpyP?= =?us-ascii?Q?yq6bPC/6NThiVlNIrSg9y+StM/q/iVaXT53qqqAW6VhWrKv2wRoCvfjDNHqP?= =?us-ascii?Q?7UL5BbTc4ZzGaUmsifxu73RRgADqlRFw9U/8wLZ9?= Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: SN6PR11MB3504.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6fae0906-bca7-4b65-e98c-08db25c1c582 X-MS-Exchange-CrossTenant-originalarrivaltime: 16 Mar 2023 01:57:17.5507 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: gbT7kLcx8Ww8+AGzxf+mMFzoO2sSHch4MhP/JyVgZeiDpaB1OEldKJjYqzvfOPdEZrAY/dYk5gKlkLLoVnrQHQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR11MB6547 X-OriginatorOrg: intel.com 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 > -----Original Message----- > From: Maxime Coquelin > Sent: Wednesday, March 15, 2023 7:40 PM > To: dev@dpdk.org; mkp@redhat.com; Xia, Chenbo ; > david.marchand@redhat.com > Cc: Maxime Coquelin > Subject: [PATCH v2] vhost: fix madvise IOTLB entries pages overlap check >=20 > 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. >=20 > 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. >=20 > Fixes: dea092d0addb ("vhost: fix madvise arguments alignment") >=20 > Signed-off-by: Maxime Coquelin > --- > lib/vhost/iotlb.c | 8 ++++---- > 1 file changed, 4 insertions(+), 4 deletions(-) >=20 > 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) !=3D (prev_node->uaddr & > mask)) { > next_node =3D RTE_TAILQ_NEXT(node, next); > /* Don't disable coredump if the next node is in > the same page */ > - if (next_node =3D=3D NULL || > - (node->uaddr & mask) !=3D (next_node- > >uaddr & mask)) > + if (next_node =3D=3D NULL || ((node->uaddr + node- > >size - 1) & mask) !=3D > + (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) !=3D (prev_node->uaddr & > mask)) { > next_node =3D RTE_TAILQ_NEXT(node, next); > /* Don't disable coredump if the next node is in > the same page */ > - if (next_node =3D=3D NULL || > - (node->uaddr & mask) !=3D (next_node- > >uaddr & mask)) > + if (next_node =3D=3D NULL || ((node->uaddr + node- > >size - 1) & mask) !=3D > + (next_node->uaddr & mask)) > mem_set_dump((void *)(uintptr_t)node->uaddr, > node->size, > false, alignment); > } > -- > 2.39.2 Reviewed-by: Chenbo Xia =20