From patchwork Sun Mar 20 07:44:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anirudh Rayabharam X-Patchwork-Id: 12786455 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 661D8C433EF for ; Sun, 20 Mar 2022 07:45:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244795AbiCTHqb (ORCPT ); Sun, 20 Mar 2022 03:46:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55710 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236841AbiCTHq3 (ORCPT ); Sun, 20 Mar 2022 03:46:29 -0400 Received: from sender4-of-o53.zoho.com (sender4-of-o53.zoho.com [136.143.188.53]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CDA68BB6; Sun, 20 Mar 2022 00:45:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647762300; cv=none; d=zohomail.com; s=zohoarc; b=EDNwVrXEK6Oway1Y2ekLuadKuWPFi4I44XhEaZyHQXnMt2h3ridc6vNPri2vgOzOy2Nt50ux/qDYMCtHeDF1KvuSVulYALVnDxUbM+wkC5hw8UtWTCcZ4OWIK+VWp8CLMU48I+hd1gQoxBwcpV6vrvkNEEGaCFFy0EsKhIvzQC0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1647762300; h=Content-Transfer-Encoding:Cc:Date:From:MIME-Version:Message-ID:Subject:To; bh=w5LyUHJofJCyeKMRiw9YiX9jA/Wm8ilUQt322JAg2Fw=; b=SjKBYcx+1k6Nu3WNqwDNuVa8u6nac4CrkGv9HXeOx8H+wPAgvjWM8ikrE8KdIyfFYZzaSZCgn9Ph16Guzv2g+zPjHZuQ87KPrx/CJPa7zGWppowfaoTeoCkbdrstOXFR6rz1tWBk6jfvulaQm5fOBYW4JeCs1f4u7SPnZczRgE4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=anirudhrb.com; spf=pass smtp.mailfrom=mail@anirudhrb.com; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1647762300; s=zoho; d=anirudhrb.com; i=mail@anirudhrb.com; h=From:From:To:To:Cc:Cc:Subject:Subject:Date:Message-Id:Message-Id:MIME-Version:Content-Transfer-Encoding:Reply-To; bh=w5LyUHJofJCyeKMRiw9YiX9jA/Wm8ilUQt322JAg2Fw=; b=pZaPNAdbrS0juZd3ejmm6jiH3ppZvGIDxtGR9vjxotKMgPYbaQzc6otg5n17GIVn jnpyllYpV2Pm/+07mkHsq0G9qH1NutaJWnCKKUj4l3nfuJS9SFHG1L9CJP1RMHPWtN2 5wNaWm/1DyDXXHQp5p1whUOhe34j7hCaxpIhshCs= Received: from localhost.localdomain (49.207.204.88 [49.207.204.88]) by mx.zohomail.com with SMTPS id 1647762299802751.4615773189689; Sun, 20 Mar 2022 00:44:59 -0700 (PDT) From: Anirudh Rayabharam To: "Michael S. Tsirkin" , Jason Wang , Anirudh Rayabharam Cc: Stefano Garzarella , kvm@vger.kernel.org, virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2] vhost: handle error while adding split ranges to iotlb Date: Sun, 20 Mar 2022 13:14:49 +0530 Message-Id: <20220320074449.4909-1-mail@anirudhrb.com> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 X-ZohoMailClient: External Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org vhost_iotlb_add_range_ctx() handles the range [0, ULONG_MAX] by splitting it into two ranges and adding them separately. The return value of adding the first range to the iotlb is currently ignored. Check the return value and bail out in case of an error. Fixes: e2ae38cf3d91 ("vhost: fix hung thread due to erroneous iotlb entries") Reviewed-by: Stefano Garzarella Signed-off-by: Anirudh Rayabharam Acked-by: Jason Wang --- v2: - Add "Fixes:" tag and "Reviewed-by:". v1: https://lore.kernel.org/kvm/20220312141121.4981-1-mail@anirudhrb.com/ --- drivers/vhost/iotlb.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/vhost/iotlb.c b/drivers/vhost/iotlb.c index 40b098320b2a..5829cf2d0552 100644 --- a/drivers/vhost/iotlb.c +++ b/drivers/vhost/iotlb.c @@ -62,8 +62,12 @@ int vhost_iotlb_add_range_ctx(struct vhost_iotlb *iotlb, */ if (start == 0 && last == ULONG_MAX) { u64 mid = last / 2; + int err = vhost_iotlb_add_range_ctx(iotlb, start, mid, addr, + perm, opaque); + + if (err) + return err; - vhost_iotlb_add_range_ctx(iotlb, start, mid, addr, perm, opaque); addr += mid + 1; start = mid + 1; }