Message ID | 20221111002225.2418386-3-seanjc@google.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp455283wru; Thu, 10 Nov 2022 16:31:55 -0800 (PST) X-Google-Smtp-Source: AA0mqf5rtayfHEK+IsyC7Ir4TllK7b+1NglojdqXVBY28RTimsai9Ib8EVYZcRTQ24qcmCMUqmeg X-Received: by 2002:aa7:9011:0:b0:561:c295:7568 with SMTP id m17-20020aa79011000000b00561c2957568mr87165pfo.35.1668126715420; Thu, 10 Nov 2022 16:31:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668126715; cv=none; d=google.com; s=arc-20160816; b=tLGyKU2oQ9QAG80QU+xSJembPIQiSclXd7DsCrAFYQDwBt1lTJHCJM+AHtNyy/t7iK Zm547E0rJJHihqB9VBj4Pfjcwf0zjwjja0ANSN8VfvQjFZa1Lxj5kiij0t0+rOOrx6VI 06psTKko9Ak3Wm/0+a1waLarnd/DjVtcRFrXJb5hl7CvRBrvnp2zoEybhNIV9OdKGB5a IFxdoWsKZDcKb8SbEneKpFe/X+6jr4kHKzJMJC+mTnOzl38UGDyRzcfWURZj/yr/Sw0L 7y8GLK4Xe6FG5dmKoK4IUv4kMLZO5DXJfn+ZP//n/1OZ0knRVrPkI6BjKuxWpnApDrfb wMXQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:reply-to:dkim-signature; bh=n36J7s+0ilM0Tsn5slAdsXyaRWJfxWCAeT/6FWqeTp8=; b=DMaB05OOB7wlai/yUKS/RV0Fv6LDzidB6b4e/SGSZC5OGiZ/OzhAdnjAxX9vjb3k1P h5TfJtUc3+4R/PFW7uwkgXUpQlSbmLQHNfcOdj006y6FYJhyCI/TZ8Iqch81iwG9msu6 BcJ9DmW+ykC+S+TDFgl4KNVslwB/+QtyHnhJz0HTv9aL15jtq/IK5/ApBfXVHhy8Pmg5 2Pig3yYaPT78h3NHirkRSGZ3LfR40uO9Bp9ghd2YTRwWpYQl7wN74cYC7h3ss6JbTUG5 HB5K1BiE9xE0b5KlieQb+UKUAdza+vrAzYGMRaiGK+XrHf0tIguj9frAeeofxAy76P++ JgmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=TZiKdFTb; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 17-20020a170902ee5100b00178b88d40ebsi805203plo.51.2022.11.10.16.31.34; Thu, 10 Nov 2022 16:31:55 -0800 (PST) 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=@google.com header.s=20210112 header.b=TZiKdFTb; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231688AbiKKAWj (ORCPT <rfc822;winker.wchi@gmail.com> + 99 others); Thu, 10 Nov 2022 19:22:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51334 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231207AbiKKAWc (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 10 Nov 2022 19:22:32 -0500 Received: from mail-pl1-x64a.google.com (mail-pl1-x64a.google.com [IPv6:2607:f8b0:4864:20::64a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 01B6543872 for <linux-kernel@vger.kernel.org>; Thu, 10 Nov 2022 16:22:31 -0800 (PST) Received: by mail-pl1-x64a.google.com with SMTP id o7-20020a170902d4c700b001868cdac9adso2403983plg.13 for <linux-kernel@vger.kernel.org>; Thu, 10 Nov 2022 16:22:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:from:to:cc:subject:date:message-id:reply-to; bh=n36J7s+0ilM0Tsn5slAdsXyaRWJfxWCAeT/6FWqeTp8=; b=TZiKdFTbv7ULH977/XXkoaKwCBWIUXcZgjj3kk67qk6G/7NTnWl7f9ErIfa3sgs6Iu PIE2j9lVQnRevVhSmgy5ghpMaowZSmo/JvV26NB/u5XUxIGVX2T3kGhGEB+GX40/BH+e dMm5i34zN0Ep9bgjqiptCmyqKJTPz98+Gc5Erv/2Hk0eC6sx/JrEjrvIb4L//JadZb+D yyrZCQmeoRcq14GM/aKC8IJAyy66Zz5B57Ex00OXo4YACUPRLXDVs9TboavE9uxTi60O H5HIhz1q4T4MEoC0qbI3gIAqHaqRVBYY+wU9Sv6jmDDDGplg8ezaO+Oydl1V1nV+l4ZE GG4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=n36J7s+0ilM0Tsn5slAdsXyaRWJfxWCAeT/6FWqeTp8=; b=voRodq6sa9ttDSJRgPNpQSFapiUVq5vKr4WaGL1Tz95QA2RSGxIIf9eHjmZY7PlzbM 5hpKJ82Kv2d2v/LUixDSZn1oG2C2dxGufMyc67m8hHWuVZlUUfa6dGQLkaOMEmlZ8XxE 8lahKnCF1XIZZZ3b81O/t/XyS3Rqm6co9OxWm5jXnx8pHszY/Iz8JvaDcXtwJcVjcbI8 o3TOJEGHFOP258wbAZ1qQQQ9wyw44tav0aUt0mEYVYBixuj5E9NexuFLgX+sdMYf06lp 3aPx+CfqCfg3gFhzKG5hhsaAMuEehd9yh0HvGvKjkNHkSdDRUw++LCH0ALrBltaXPcnj b70Q== X-Gm-Message-State: ANoB5pmWYz6OvyRyUnS94hPBbkej7FhOaZdfsNcs48ZENNea9+yLeiHa KEznS43UH6qNjZBlZXWG0iFlZwpgT1U= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a17:902:dac4:b0:186:5f54:18cf with SMTP id q4-20020a170902dac400b001865f5418cfmr4884plx.141.1668126151578; Thu, 10 Nov 2022 16:22:31 -0800 (PST) Reply-To: Sean Christopherson <seanjc@google.com> Date: Fri, 11 Nov 2022 00:22:25 +0000 In-Reply-To: <20221111002225.2418386-1-seanjc@google.com> Mime-Version: 1.0 References: <20221111002225.2418386-1-seanjc@google.com> X-Mailer: git-send-email 2.38.1.431.g37b22c650d-goog Message-ID: <20221111002225.2418386-3-seanjc@google.com> Subject: [PATCH 2/2] drm/i915/gvt: Unconditionally put reference to KVM when detaching vGPU From: Sean Christopherson <seanjc@google.com> To: Zhenyu Wang <zhenyuw@linux.intel.com>, Zhi Wang <zhi.a.wang@intel.com> Cc: intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org, Sean Christopherson <seanjc@google.com> Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL 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?1749157639201959375?= X-GMAIL-MSGID: =?utf-8?q?1749157639201959375?= |
Series |
drm/i915/gvt: Fix for KVM refcounting bug
|
|
Commit Message
Sean Christopherson
Nov. 11, 2022, 12:22 a.m. UTC
Always put the KVM reference when closing a vCPU device, as
intel_vgpu_open_device() succeeds if and only if the KVM pointer is
valid and a reference to KVM is acquired. And if that doesn't hold true,
the call to kvm_page_track_unregister_notifier() a few lines earlier is
doomed.
Signed-off-by: Sean Christopherson <seanjc@google.com>
---
drivers/gpu/drm/i915/gvt/kvmgt.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
Comments
> From: Sean Christopherson <seanjc@google.com> > Sent: Friday, November 11, 2022 8:22 AM > > Always put the KVM reference when closing a vCPU device, as > intel_vgpu_open_device() succeeds if and only if the KVM pointer is > valid and a reference to KVM is acquired. And if that doesn't hold true, > the call to kvm_page_track_unregister_notifier() a few lines earlier is > doomed. > > Signed-off-by: Sean Christopherson <seanjc@google.com> Reviewed-by: Kevin Tian <kevin.tian@intel.com>
diff --git a/drivers/gpu/drm/i915/gvt/kvmgt.c b/drivers/gpu/drm/i915/gvt/kvmgt.c index e67d5267fde0..714221f9a131 100644 --- a/drivers/gpu/drm/i915/gvt/kvmgt.c +++ b/drivers/gpu/drm/i915/gvt/kvmgt.c @@ -714,15 +714,14 @@ static void intel_vgpu_close_device(struct vfio_device *vfio_dev) kvm_page_track_unregister_notifier(vgpu->vfio_device.kvm, &vgpu->track_node); + kvm_put_kvm(vgpu->vfio_device.kvm); + kvmgt_protect_table_destroy(vgpu); gvt_cache_destroy(vgpu); intel_vgpu_release_msi_eventfd_ctx(vgpu); vgpu->attached = false; - - if (vgpu->vfio_device.kvm) - kvm_put_kvm(vgpu->vfio_device.kvm); } static u64 intel_vgpu_get_bar_addr(struct intel_vgpu *vgpu, int bar)