Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp4875670imm; Fri, 18 May 2018 12:11:02 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpgtNVseUMIE8aOkmni5eFaUIsqe/18jJ8wEzYPAqMnprCRUG4XijofLiNqWMAGWhh+fgmS X-Received: by 2002:a63:6d02:: with SMTP id i2-v6mr1427804pgc.228.1526670662771; Fri, 18 May 2018 12:11:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526670662; cv=none; d=google.com; s=arc-20160816; b=K7H63I0VCN63T1CB6l/j9LneuaUqU0FeR0IClzzoUiTdlJfsNxsIZoaWtB8a30HFSS gLYnydJljDDBg6kFhQOjXn2nF9v9eSarxk7+ZkroXhOBZZgBMrzZNGel6rKLtbyLXng8 aarqN16W0XoHfZh+cwiQYiKRKHOcJbHXsFIIEEaPY+a6JMTtGLiqg8d9RH3kGyyKegHy oomiCHXiniOnD9oVKIwH+FPu5HCvJJKWYItAiQbm6hg68+lJuHlHtN6P/0hqDJVCmK5m +13Zff2AVz1sZJgJpt5KlV3RIoyBKiXCUjInLSOxvTbJSblMIdjWP8U9xmX+rbBY6K6A aAWg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:message-id:date:cc:to:from:subject :arc-authentication-results; bh=MKqfyJaHB9mnr2S40ZFJiWnAI72WKnoYjls/7aLFOZU=; b=VqWsckmpfixcgRLWMiF6wIipsZNo5pJu+I5m5qwKpTCg4yR6Zmm8zTLdGGuk7gEbcw lTrDCsMOQv8Uoi6H8lCVgtORZ7WMuK7TFxe/weT6qvRiKRZWRjBnOuvsaHJTfWngREy1 K3XL48GX+yrrACLBIVCLRx1pVoW4QZVvnSkIT+oKfFKqMYFONS7zt/MVZHPQYvVR8gbq xeY6cJnbOx08r7xAJERSFw9I5Re1qyzqzVxom8p4W8V3Vs/vONiRl74gIHP09VRURQ+2 FIP2igGBuz3VXHcOSAyy/evO0BAwI6EoGCd0u2wl3xepCzC5Tee7uICxZKtJ3vZbKquW bBUg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e9-v6si7787788pln.72.2018.05.18.12.10.48; Fri, 18 May 2018 12:11:02 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751952AbeERTKX (ORCPT + 99 others); Fri, 18 May 2018 15:10:23 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40270 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751606AbeERTKU (ORCPT ); Fri, 18 May 2018 15:10:20 -0400 Received: from smtp.corp.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3141730D4DAA; Fri, 18 May 2018 19:10:20 +0000 (UTC) Received: from gimli.home (ovpn-116-135.phx2.redhat.com [10.3.116.135]) by smtp.corp.redhat.com (Postfix) with ESMTP id 20DC29ABA0; Fri, 18 May 2018 19:10:17 +0000 (UTC) Subject: [PATCH v4 0/2] vfio/mdev: Device namespace protection From: Alex Williamson To: kwankhede@nvidia.com Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, alex.williamson@redhat.com, cohuck@redhat.com, pasic@linux.ibm.com Date: Fri, 18 May 2018 13:10:16 -0600 Message-ID: <20180518190145.3187.7620.stgit@gimli.home> User-Agent: StGit/0.18-102-gdf9f MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.84 on 10.5.11.27 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Fri, 18 May 2018 19:10:20 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org v4: Fix the 'create' racing 'remove' gap noted by Kirti by moving removal from mdev_list to mdev_device_release(). Fix missing mdev_put_parent() cases in mdev_device_create(), also noted by Kirti. Added documention update regarding serialization as noted by Cornelia. Added additional commit log comment about -EAGAIN vs -ENODEV for 'remove' racing 'create'. Added second patch to re-order sysfs attributes, with this my targeted scripts can no longer hit the gap where -EAGAIN is regurned. BTW, the gap where the current code returns -ENODEV in this race condition is about 50% easier to hit than it exists in this series with patch 1 alone. Thanks, Alex --- Alex Williamson (2): vfio/mdev: Check globally for duplicate devices vfio/mdev: Re-order sysfs attribute creation Documentation/vfio-mediated-device.txt | 5 ++ drivers/vfio/mdev/mdev_core.c | 102 +++++++++++--------------------- drivers/vfio/mdev/mdev_private.h | 2 - drivers/vfio/mdev/mdev_sysfs.c | 14 ++-- 4 files changed, 49 insertions(+), 74 deletions(-)