From nobody Tue Dec 16 16:37:15 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E9E6CE80AAC for ; Wed, 27 Sep 2023 14:06:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232053AbjI0OGn (ORCPT ); Wed, 27 Sep 2023 10:06:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38774 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231758AbjI0OGl (ORCPT ); Wed, 27 Sep 2023 10:06:41 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EA078FC for ; Wed, 27 Sep 2023 07:05:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695823554; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=2yrzCvJKKpyb6A3C4WRH7XAPotWnSI2iCGZEtxqtwTM=; b=UI1MUJ4oycgPfwopH9uBwP391wo7CWGlALuRePWow94vZw2AuTV757K3gKiPCajT5Hr0ph s8wkoQa9KFHq2UbnvysR4Y+Gs6axJsuYcuKPB2PPi6GMYaxp1W0exVELeKLnFJcutCYmlX 1pp5Rw6ak33QXOCEPVwcJXTBgc3O8gI= Received: from mimecast-mx02.redhat.com (mx-ext.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-275-jzxT90fYPaiCVfzsHq1OBg-1; Wed, 27 Sep 2023 10:05:49 -0400 X-MC-Unique: jzxT90fYPaiCVfzsHq1OBg-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id BFDAF280D206; Wed, 27 Sep 2023 14:05:48 +0000 (UTC) Received: from laptop.redhat.com (unknown [10.39.192.172]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9990A492B16; Wed, 27 Sep 2023 14:05:46 +0000 (UTC) From: Eric Auger To: eric.auger.pro@gmail.com, eric.auger@redhat.com, elic@nvidia.com, mail@anirudhrb.com, jasowang@redhat.com, mst@redhat.com, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, netdev@vger.kernel.org, virtualization@lists.linux-foundation.org, kvmarm@lists.linux.dev Cc: stable@vger.kernel.org Subject: [RESEND PATCH v2] vhost: Allow null msg.size on VHOST_IOTLB_INVALIDATE Date: Wed, 27 Sep 2023 16:05:44 +0200 Message-ID: <20230927140544.205088-1-eric.auger@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Commit e2ae38cf3d91 ("vhost: fix hung thread due to erroneous iotlb entries") Forbade vhost iotlb msg with null size to prevent entries with size =3D start =3D 0 and last =3D ULONG_MAX to end up in the iotlb. Then commit 95932ab2ea07 ("vhost: allow batching hint without size") only applied the check for VHOST_IOTLB_UPDATE and VHOST_IOTLB_INVALIDATE message types to fix a regression observed with batching hit. Still, the introduction of that check introduced a regression for some users attempting to invalidate the whole ULONG_MAX range by setting the size to 0. This is the case with qemu/smmuv3/vhost integration which does not work anymore. It Looks safe to partially revert the original commit and allow VHOST_IOTLB_INVALIDATE messages with null size. vhost_iotlb_del_range() will compute a correct end iova. Same for vhost_vdpa_iotlb_unmap(). Signed-off-by: Eric Auger Fixes: e2ae38cf3d91 ("vhost: fix hung thread due to erroneous iotlb entries= ") Cc: stable@vger.kernel.org # v5.17+ Acked-by: Jason Wang --- drivers/vhost/vhost.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c index c71d573f1c94..e0c181ad17e3 100644 --- a/drivers/vhost/vhost.c +++ b/drivers/vhost/vhost.c @@ -1458,9 +1458,7 @@ ssize_t vhost_chr_write_iter(struct vhost_dev *dev, goto done; } =20 - if ((msg.type =3D=3D VHOST_IOTLB_UPDATE || - msg.type =3D=3D VHOST_IOTLB_INVALIDATE) && - msg.size =3D=3D 0) { + if (msg.type =3D=3D VHOST_IOTLB_UPDATE && msg.size =3D=3D 0) { ret =3D -EINVAL; goto done; } --=20 2.41.0