Message ID | 20230415021959.197891-1-lulu@redhat.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp798214vqo; Fri, 14 Apr 2023 20:05:48 -0700 (PDT) X-Google-Smtp-Source: AKy350afsT2YsT++S/nihDdExiJ9uVNkFrLT39HCrzJWDmguK72rXkGfNrIXLESNDhP8pXCCBaw7 X-Received: by 2002:a05:6a00:1a16:b0:63b:646d:9165 with SMTP id g22-20020a056a001a1600b0063b646d9165mr5818943pfv.26.1681527948555; Fri, 14 Apr 2023 20:05:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681527948; cv=none; d=google.com; s=arc-20160816; b=fz5o4a9ow0vikVAb1XwRalnS978miQYI4VKaAzSRqTdGQnU1afiC9IAzPC5bF8v5m/ SW/78IofJLUzaB9P1LRNwPLCzjTyPjUBUdtD9DX422bdlUAYjew47CWTP9ObGu8nGogy LNGvJNvG2UeRx14w526cKmH42bIRDcnw0TqnwlQEY581iBY3WsU0tFTj/lH26CXfAe6+ BfKrUXEWawpzg7/7tkFQeC1KoiJCc1H9qevUWiugCawQ4QtOcWsv6FMYb66VII1L6q2t ah0u1wW8+Yw4oIV42XxOnjLKX9+DnYdtofQqbKZEafZE02y6OLIZmgWd0wv88k6hiqAY PwJw== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v1-20020a626101000000b00624a13d1b45si5617218pfb.72.2023.04.14.20.05.36; Fri, 14 Apr 2023 20:05:48 -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 S230167AbjDOCVA (ORCPT <rfc822;yuanzuo1009@gmail.com> + 99 others); Fri, 14 Apr 2023 22:21:00 -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 <rfc822;linux-kernel@vger.kernel.org>); 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 <linux-kernel@vger.kernel.org>; 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 <lulu@redhat.com> 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1763209850365471532?= X-GMAIL-MSGID: =?utf-8?q?1763209850365471532?= |
Series |
[v2] vhost_vdpa: fix unmap process in no-batch mode
|
|
Commit Message
Cindy Lu
April 15, 2023, 2:19 a.m. UTC
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 <lulu@redhat.com>
---
drivers/vhost/vdpa.c | 8 +-------
1 file changed, 1 insertion(+), 7 deletions(-)
Comments
On Sat, Apr 15, 2023 at 10:20 AM Cindy Lu <lulu@redhat.com> wrote: > > 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. This patch looks good but I don't understand the above. I think it's better to explain why such large unmap will lead to this error: Is it a batched unmap or a [0, ULONG_MAX] map? How could we end up the NULL? > 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 <lulu@redhat.com> Do we need a fix tag and does it need to go for -stable? Thanks > --- > 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 >
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;