Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp3476613pxv; Sun, 4 Jul 2021 20:50:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz5to7IgKPBHZeZK6aOyinBYbSxCyq9DTzte8k27EOW82qvZHHTAvHnR+Mu0J9kYRDMFVfi X-Received: by 2002:a17:906:7f19:: with SMTP id d25mr8895292ejr.112.1625457010277; Sun, 04 Jul 2021 20:50:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625457010; cv=none; d=google.com; s=arc-20160816; b=Aa5Ans/GrmFWgZuqhqIkPdaUukFvpcGdFYzee++zufGORojT4TRGJ+PQ0hMpCGu48X rnnIxzRUI1LBL/Qk3azbJ+eXzW1ZX1PsnPs3iHv1qNNzf/W70nUxjxo2v0OCZ7xOxPsZ VXvVakSM04hYM9Dj0c8ptcNXxT+mE+jPJqan3QMfqRwSi+KgcCSO3yR2XFnnNW9KsHPz gBzmcrN9JQ6EYgVgEZv5pNoFtGv1YBDgOlyQ5x4NIcfKYkgF7qK26WdfJFq1OJ4wvirw NZgCpBTZz/7eFM5nyp0l97ku+ajdGJQttCnNHi0aZbgPZqridnF3L0uAyNTJ3cu7S8+1 956Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-language:content-transfer-encoding :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=25P6+qOObwDiaurdWnfUZ/5fIR3I7PXs4U3cGO2pDNQ=; b=F86pmItnlGWOqe3fMakotlfouzVnMD9LBZEKuzU/6M9rV5wEpFdpdcpWiFJ881/BVI S4zBrKFIq2584LlvoGbt49nzLRzmoFWPfG9wpdqn0glkJ1zDG12OZ6M4e/Lp+y6GLrNr hFpjLeDGb6gafxu6IyEqkuipH8LvOi22uR39HKzNO5AEIDwystnZR8hlLwxmsCf5WSKT w29udN4FBJ5rBCuuHfJ+86H5EqyCbsgmuzVYPlUJ8GyRSxQTAn8YJMWcgELTQzMRcMjn TcjUbs606OS505LRi3fUvP6VPezU7mB/lEZL4QEPzU3If/4GgSwZ07gS+so0hnFczKmP yATw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ZxfKnzuU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id eo21si10408195ejc.233.2021.07.04.20.49.47; Sun, 04 Jul 2021 20:50:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ZxfKnzuU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S229793AbhGEDvZ (ORCPT + 99 others); Sun, 4 Jul 2021 23:51:25 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:28798 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229722AbhGEDvZ (ORCPT ); Sun, 4 Jul 2021 23:51:25 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1625456928; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=25P6+qOObwDiaurdWnfUZ/5fIR3I7PXs4U3cGO2pDNQ=; b=ZxfKnzuUsmBJ24UVTsrzkAeYBQNnDiNzUV/bqxYppgDq1SU3RyEdzt0Se4hoHuUpnk4G1x Gltq3yKVXEelmzk5iBAO35A5/LKb2D4RbY1O6zdlmoHUos8D9oOYnEXkUw36XZInZOIaid +p05T5anyVxz+wzT9RmF1sq4ZNfyDLQ= Received: from mail-pg1-f199.google.com (mail-pg1-f199.google.com [209.85.215.199]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-519-_HevpuGROUCrMfsWHfcTwg-1; Sun, 04 Jul 2021 23:48:47 -0400 X-MC-Unique: _HevpuGROUCrMfsWHfcTwg-1 Received: by mail-pg1-f199.google.com with SMTP id d28-20020a634f1c0000b02902238495b6a7so12713370pgb.16 for ; Sun, 04 Jul 2021 20:48:47 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=25P6+qOObwDiaurdWnfUZ/5fIR3I7PXs4U3cGO2pDNQ=; b=XDV0t7LLSEVWpxlqpdGd8AQBktLjxYj3FADhqIc9ZB74hJaMA7Bk477mHx3OZ2BNcq bzgWVDcswJk+yS4eaZbpTcW11zAZVeOBVK/wfOUeBs/gbzSlgNl7DdjXdpr/1CNG9d1N dcXHbwW5t1rfmp9ghULNz9/CmquAVJWDATJFdIOxdi2/P6WH2dm6ySpNpOI1K+9ENsfQ WENJqL3mS9dMWHcUekbbSM0gOF3OMmtOK5m6KIuKU1D6ZplMPJjKtVuSQwj5E5ZmITPB MxHhIquC/2+tAhNVQjtbEFhll/cD8pviXyx7YDkKDWkXlJvlw01P12KQNuL4h7ySy00i 7U1w== X-Gm-Message-State: AOAM531OCuY+Wo8a1yxQ5qU5Stcss/ukxsl+Mlo7AuTEn4XAvIf6nIl4 v1yMHVziAaMUSkaQbo/T3rAkmJ4FYmhqwitoiec7kUjJHhS2YYOYVpqZaYsJAQt79Iygdo68TIr 9F7TCV2OLsTEHG0YZcQTBaOyNFVGObqORaTxwGJG0TIFPs9WLSt7uGD5KOEQIkEZCtiIjBGAWlt 4u X-Received: by 2002:a63:f955:: with SMTP id q21mr13651952pgk.448.1625456926315; Sun, 04 Jul 2021 20:48:46 -0700 (PDT) X-Received: by 2002:a63:f955:: with SMTP id q21mr13651917pgk.448.1625456925713; Sun, 04 Jul 2021 20:48:45 -0700 (PDT) Received: from wangxiaodeMacBook-Air.local ([209.132.188.80]) by smtp.gmail.com with ESMTPSA id f193sm2380694pfa.185.2021.07.04.20.48.42 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 04 Jul 2021 20:48:45 -0700 (PDT) Subject: Re: [RFC PATCH] vhost-vdpa: mark vhost device invalid to reflect vdpa device unregistration To: gautam.dawar@xilinx.com Cc: martinh@xilinx.com, hanand@xilinx.com, gdawar@xilinx.com, "Michael S. Tsirkin" , kvm@vger.kernel.org, virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org References: <20210704205205.6132-1-gdawar@xilinx.com> From: Jason Wang Message-ID: <3d02b8f5-0a6b-e8d1-533d-8503da3fcc4e@redhat.com> Date: Mon, 5 Jul 2021 11:48:36 +0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: <20210704205205.6132-1-gdawar@xilinx.com> Content-Type: text/plain; charset=gbk; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org ?? 2021/7/5 ????4:52, gautam.dawar@xilinx.com ะด??: > vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot); > @@ -1091,11 +1122,13 @@ static void vhost_vdpa_remove(struct vdpa_device *vdpa) > opened = atomic_cmpxchg(&v->opened, 0, 1); > if (!opened) > break; > - wait_for_completion_timeout(&v->completion, > - msecs_to_jiffies(1000)); > - dev_warn_once(&v->dev, > - "%s waiting for/dev/%s to be closed\n", > - __func__, dev_name(&v->dev)); > + if (!wait_for_completion_timeout(&v->completion, > + msecs_to_jiffies(1000))) { > + dev_warn(&v->dev, > + "%s/dev/%s in use, continue..\n", > + __func__, dev_name(&v->dev)); > + break; > + } > } while (1); > > put_device(&v->dev); > + v->dev_invalid = true; Besides the mapping handling mentioned by Michael. I think this can lead use-after-free. put_device may release the memory. Another fundamental issue, vDPA is the parent of vhost-vDPA device. I'm not sure the device core can allow the parent to go away first. Thanks