Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp1595984iob; Thu, 19 May 2022 09:50:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz+bOOn5TeQL7dXQgEEgb8QlzWYfS+3+UZsUdtXs3X1h3uTCtIV1/O7josxRgtt8+6UO2Hx X-Received: by 2002:a17:907:608e:b0:6fe:12f8:7967 with SMTP id ht14-20020a170907608e00b006fe12f87967mr4924481ejc.441.1652979018022; Thu, 19 May 2022 09:50:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652979018; cv=none; d=google.com; s=arc-20160816; b=mepYaCTmvyJK+MoTKs2lGd4ZwJNGKHTt6lsCC4oaPqm2WmiwhCpfN+ZDmiPBcumAAp tk6bHc4zAOu5o+bHhshGdapSPPswqUR3AgP9QhnyOIWnuZbFRyqMM6xJ5mgu2mcyDMOb apfUeI8R9a6OkPFw19chuGYEBPRHEbkKblJA/Hgvg7lx8eQK1V6jdywjTlFaJlhsS05W f17i5TLo5b5JuX+v+kLYwDZiF4HkMv6+69M3n/A4VFh4hniMwQ/lN5EnrnOw31iSl8ow A2caYV7zZ60PO4zW3hziNqrsG0JwDvswfvxP4DwLwp76cysLfb5gO3VJogcW/ejl+L1e fRjw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=xVNgLNspLSR5Zdl3y2dXwcEBrzDQ/5UKA9hIbWaD6p8=; b=J00T44uiFJ5zLUHPglPf6HAqTtZtvMiL35kJ2i1aP325N23GCpDkY9ZI4eru4yFMEo DdlRe9RYMDpIcmKf7E3UOTOrJ/v8ZwMDz/+M8l2hI3uRM0XGRkx8w41yMPtluAViBXHA BwqyQ9GFhJymbnyBLG7sthKpEXowMQxxhzuX8AXU+CS65A19bZ87PKSnFHQ5l6hEIXAb 8Aabi4Nr2ck/FWTd/mNVhkwbQAgmDpBj8FMcYFuogm4qJgCvXxtYqzPHy9MwJYEUeXZ4 vtz5QDiKn5SrHfYjPNqy7u07mtn3ZT0xleFUHWUdNHfs73cyogo0XMQWd6BinhSBGIAM myBQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=OK5oxehF; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ee29-20020a056402291d00b0042aa54f0349si5165618edb.106.2022.05.19.09.49.50; Thu, 19 May 2022 09:50:18 -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=@infradead.org header.s=bombadil.20210309 header.b=OK5oxehF; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234184AbiESGsZ (ORCPT + 99 others); Thu, 19 May 2022 02:48:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33964 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229544AbiESGsU (ORCPT ); Thu, 19 May 2022 02:48:20 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6B73150049; Wed, 18 May 2022 23:48:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=xVNgLNspLSR5Zdl3y2dXwcEBrzDQ/5UKA9hIbWaD6p8=; b=OK5oxehFsQh/LcIiP98mvU1qO2 ozZuJXF3hyQwN72+zLrsBNTfp9RlauKjgJrWRA4E0THsZuC3t9qpVIMF54cqrdRvcFWf2OplSA2Q1 DcuXnyVmqcZuuRcYtJF7PCKqwilMsyg40AZqGeTEPvyiSjLKFZPhJqjwmWivF3bbBxagNf1tyYaTN 9rQ57e/MmHy+vJJpJc5LRTC80LM7PVYQSUm2AX+Fhoq6IPWdJ7X+m9UovLRVLSLQBT9A5wrRdqV6f c5QVWX8k+pM00LSq8eJz0pN3wyOz/PueU5OUErC3uZC0TTrHIJfhrCktGbZ+pKseBSoTNBUqQPmyb pHLEj4/w==; Received: from hch by bombadil.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1nrZxH-005MH9-5n; Thu, 19 May 2022 06:48:15 +0000 Date: Wed, 18 May 2022 23:48:15 -0700 From: "hch@infradead.org" To: "Tian, Kevin" Cc: Matthew Rosato , "jgg@nvidia.com" , "alex.williamson@redhat.com" , "jjherne@linux.ibm.com" , "akrowiak@linux.ibm.com" , "kvm@vger.kernel.org" , "hch@infradead.org" , "linux-s390@vger.kernel.org" , "intel-gfx@lists.freedesktop.org" , "cohuck@redhat.com" , "linux-kernel@vger.kernel.org" , "zhenyuw@linux.intel.com" , "pasic@linux.ibm.com" , "borntraeger@linux.ibm.com" , "intel-gvt-dev@lists.freedesktop.org" , "Wang, Zhi A" Subject: Re: [PATCH v2 1/1] vfio: remove VFIO_GROUP_NOTIFY_SET_KVM Message-ID: References: <20220518212607.467538-1-mjrosato@linux.ibm.com> <20220518212607.467538-2-mjrosato@linux.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,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 On Thu, May 19, 2022 at 06:43:06AM +0000, Tian, Kevin wrote: > > This fixes a user-triggerable oops in GVT. > > No changelog. ?? the cover latter clearly states what has changed since v1, and this patch has a good commit log. This is exactly how it is supposed to be done. > > > > > Signed-off-by: Jason Gunthorpe > > Signed-off-by: Matthew Rosato > > Not sure whether Christoph wants a s-o-b here when he wrote > the snippet to remove the release work of gvt... That's just tivial code removal, so no. > > > @@ -1083,11 +1083,22 @@ static struct file *vfio_device_open(struct > > vfio_device *device) > > > > mutex_lock(&device->dev_set->lock); > > device->open_count++; > > + down_read(&device->group->group_rwsem); > > + if (device->open_count == 1 && device->group->kvm) { > > + /* > > + * Here we pass the KVM pointer with the group under the > > read > > + * lock. If the device driver will use it, it must obtain a > > + * reference and release it during close_device. > > + */ > > + device->kvm = device->group->kvm; > > + } > > + > > if (device->open_count == 1 && device->ops->open_device) { > > Merge the two branches so both are under if (device->open_count == 1) {} > (and group_rwsem can be also moved inside) Yeah. And we don't really need the device->group->kvm check, as it would otherwise assign NULL which is perfectly fine. But otherwise this also looks good to me: Reviewed-by: Christoph Hellwig