From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753104AbdCTHHP (ORCPT ); Mon, 20 Mar 2017 03:07:15 -0400 Received: from mga05.intel.com ([192.55.52.43]:63980 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751153AbdCTHHN (ORCPT ); Mon, 20 Mar 2017 03:07:13 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.36,193,1486454400"; d="asc'?scan'208";a="1110235671" Date: Mon, 20 Mar 2017 15:05:47 +0800 From: Zhenyu Wang To: Jike Song Cc: Alex Williamson , intel-gvt-dev@lists.freedesktop.org, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org#v4.10, Paolo Bonzini , Zhi Wang Subject: Re: [PATCH] kvmgt: Hold struct kvm reference Message-ID: <20170320070547.whyfdsr76ji7lexe@zhen-hp.sh.intel.com> Reply-To: Zhenyu Wang References: <20170320023814.18566.36538.stgit@gimli.home> <58CF7D7E.6010006@intel.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="qh4hiwl33k4otdnt" Content-Disposition: inline In-Reply-To: <58CF7D7E.6010006@intel.com> User-Agent: NeoMutt/20161126 (1.7.1) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --qh4hiwl33k4otdnt Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On 2017.03.20 14:58:06 +0800, Jike Song wrote: > On 03/20/2017 10:38 AM, Alex Williamson wrote: > > The kvmgt code keeps a pointer to the struct kvm associated with the > > device, but doesn't actually hold a reference to it. If we do unclean > > shutdown testing (ie. killing the user process), then we can see the > > kvm association to the device unset, which causes kvmgt to trigger a > > device release via a work queue. Naturally we cannot guarantee that > > the cached struct kvm pointer is still valid at this point without > > holding a reference. The observed failure in this case is a stuck > > cpu trying to acquire the spinlock from the invalid reference, but > > other failure modes are clearly possible. Hold a reference to avoid > > this. > >=20 > > Signed-off-by: Alex Williamson > > Cc: stable@vger.kernel.org #v4.10 > > Cc: Jike Song > > Cc: Paolo Bonzini > > Cc: Zhenyu Wang > > Cc: Zhi Wang > > --- >=20 > Reviewed-by: Jike Song >=20 > Thanks for the fix! >=20 queued in fixes tree, thanks! >=20 > > drivers/gpu/drm/i915/gvt/kvmgt.c | 2 ++ > > 1 file changed, 2 insertions(+) > >=20 > > diff --git a/drivers/gpu/drm/i915/gvt/kvmgt.c b/drivers/gpu/drm/i915/gv= t/kvmgt.c > > index 84d801638ede..142b8bd4ba6b 100644 > > --- a/drivers/gpu/drm/i915/gvt/kvmgt.c > > +++ b/drivers/gpu/drm/i915/gvt/kvmgt.c > > @@ -1324,6 +1324,7 @@ static int kvmgt_guest_init(struct mdev_device *m= dev) > > vgpu->handle =3D (unsigned long)info; > > info->vgpu =3D vgpu; > > info->kvm =3D kvm; > > + kvm_get_kvm(info->kvm); > > =20 > > kvmgt_protect_table_init(info); > > gvt_cache_init(vgpu); > > @@ -1343,6 +1344,7 @@ static bool kvmgt_guest_exit(struct kvmgt_guest_i= nfo *info) > > } > > =20 > > kvm_page_track_unregister_notifier(info->kvm, &info->track_node); > > + kvm_put_kvm(info->kvm); > > kvmgt_protect_table_destroy(info); > > gvt_cache_destroy(info->vgpu); > > vfree(info); > >=20 --=20 Open Source Technology Center, Intel ltd. $gpg --keyserver wwwkeys.pgp.net --recv-keys 4D781827 --qh4hiwl33k4otdnt Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iEYEARECAAYFAljPf0sACgkQsQQaM014GCdfWwCfZO4IdSnfHEInmTzd4Pq3oXJd xtoAn3wMtE9eFJ0osX0oWCsiwvvUhRgi =Qu4W -----END PGP SIGNATURE----- --qh4hiwl33k4otdnt--