Received: by 2002:a05:6358:53a8:b0:117:f937:c515 with SMTP id z40csp1330607rwe; Fri, 14 Apr 2023 19:37:46 -0700 (PDT) X-Google-Smtp-Source: AKy350YYgINpm8LevPnenIjXAg9b/tqcneto+5tWsGzzoLh86eyji0azh9uQse+m/cRTnIZ78Nh9 X-Received: by 2002:a05:6a20:a11a:b0:ec:8739:d993 with SMTP id q26-20020a056a20a11a00b000ec8739d993mr8584562pzk.14.1681526265613; Fri, 14 Apr 2023 19:37:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681526265; cv=none; d=google.com; s=arc-20160816; b=MqB16lSQ6JBGIFSdZN/CPptkrVnau0CA1Md60BVtRwtGEizoiVYKY6tUYzeGr5SIB3 V1X2+iEWnldKVjPXeo/KB0AGpFOPXVs1CkZyWoCH2X7X0XljBY70XsqKogDnwp5P8vx9 AoH8ndBs9hX4IBJZa2EQkQM2FhDlpYt8C3TVgr/wGbEPWh4S1/E4SLWwfZcy33QjYhh5 Qbs4emg5gcjsa4d0/Xvgo4FDtmn4doZLh4VugaeD75W6kzbsGAMq75ohRW2GQcJ0SF4a rE/SksBhNUOOSINI4oYId4QvC9hjMGTl5DIHHI7iJUt+sJCCSsHI61u05XRIUVucy1lz DuSg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:to:from:dkim-signature; bh=EbchukXhmamBCY4yfdTiw3lkj6XszMDdhtygCuSoX2M=; b=ELZPhildSHxvDNRlvxCbQHFjppCaKkIPJkVL5/Q4STcuBR6XcfnnlHV4CZwZnRsVg+ UDaiVyz2e40MJ50GIx3jzJQYae77naMTnqJeyhzRNTKCUQN+FrSKSPfkQcokWTJ/F6Jl 9NKYGabx6EJvEZZTMSs65hjvRG6Cm6qfH03L1ip6Jj5SEbVUMVCUNjAIT0qFU2qhMb/+ TEeu3nn9jccV1ecZC14noVJCv/k53G9Z14SJkMk+gOjMKWh7UyTxT3PEQbos0vdYAOUO yfnLP4m+ZapiD55fNkhdaIz2pvgIed/xBfEqINCCYArAwfCE0Jm/9wLuGiTMFZAyoo0s zHhg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=dry5TG1B; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c28-20020a634e1c000000b00507249cdbb4si5593881pgb.296.2023.04.14.19.37.34; Fri, 14 Apr 2023 19:37:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=dry5TG1B; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230163AbjDOCU7 (ORCPT + 99 others); Fri, 14 Apr 2023 22:20:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52296 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229890AbjDOCU6 (ORCPT ); Fri, 14 Apr 2023 22:20:58 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 52B552130 for ; Fri, 14 Apr 2023 19:20:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1681525209; 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; bh=EbchukXhmamBCY4yfdTiw3lkj6XszMDdhtygCuSoX2M=; b=dry5TG1B3rW3fk87kzmw4L3zIbHVT9JgXP0mfrMX+Q5/uXmBfJsS5C82SFcxEX0HbEd3Xp 6LT0f8TZ8JCkSEWAdExGAYbF2ElAxLLZZBsFoN7Me8nMjj67lVRyYQ+G+K50Mw5xj1FuQq c2swSE0DV52Fhh0D2zqEeUfqSq12FbU= 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-664-B07pot0kPLylViyUjY6cqw-1; Fri, 14 Apr 2023 22:20:05 -0400 X-MC-Unique: B07pot0kPLylViyUjY6cqw-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 74A1080C8C7; Sat, 15 Apr 2023 02:20:05 +0000 (UTC) Received: from server.redhat.com (ovpn-12-28.pek2.redhat.com [10.72.12.28]) by smtp.corp.redhat.com (Postfix) with ESMTP id C12B1140EBF4; Sat, 15 Apr 2023 02:20:02 +0000 (UTC) From: Cindy Lu To: lulu@redhat.com, mst@redhat.com, jasowang@redhat.com, virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org Subject: [PATCH v2] vhost_vdpa: fix unmap process in no-batch mode Date: Sat, 15 Apr 2023 10:19:59 +0800 Message-Id: <20230415021959.197891-1-lulu@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org While using the no-batch mode with vIOMMU enabled Qemu will call a large memory to unmap. Much larger than the memory mapped to the kernel. The iotlb is NULL in the kernel and will returnĀ fail. Which causes failure. To fix this, we will not remove the AS while the iotlb->nmaps is 0. This will free in the vhost_vdpa_clean Signed-off-by: Cindy Lu --- drivers/vhost/vdpa.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/drivers/vhost/vdpa.c b/drivers/vhost/vdpa.c index 7be9d9d8f01c..74c7d1f978b7 100644 --- a/drivers/vhost/vdpa.c +++ b/drivers/vhost/vdpa.c @@ -851,11 +851,7 @@ static void vhost_vdpa_unmap(struct vhost_vdpa *v, if (!v->in_batch) ops->set_map(vdpa, asid, iotlb); } - /* If we are in the middle of batch processing, delay the free - * of AS until BATCH_END. - */ - if (!v->in_batch && !iotlb->nmaps) - vhost_vdpa_remove_as(v, asid); + } static int vhost_vdpa_va_map(struct vhost_vdpa *v, @@ -1112,8 +1108,6 @@ static int vhost_vdpa_process_iotlb_msg(struct vhost_dev *dev, u32 asid, if (v->in_batch && ops->set_map) ops->set_map(vdpa, asid, iotlb); v->in_batch = false; - if (!iotlb->nmaps) - vhost_vdpa_remove_as(v, asid); break; default: r = -EINVAL; -- 2.34.3