From: Leonardo Bras Date: Thu, 28 Nov 2019 16:29:00 +0000 Subject: Re: [PATCH] KVM: Add separate helper for putting borrowed reference to kvm Message-Id: <45e643bce58e0f7c9646bb6c548c4e9f026f1fa8.camel@linux.ibm.com> MIME-Version: 1 Content-Type: multipart/mixed; boundary="=-lkoTnqA1IktRvD8hYwr4" List-Id: References: <20191126171416.GA22233@linux.intel.com> <0009c6c1bb635098fa68cb6db6414634555039fe.camel@linux.ibm.com> <6beeff56-7676-5dfd-a578-1732730f8963@redhat.com> <20191127194757.GI22227@linux.intel.com> <103b290917221baa10194c27c8e35b9803f3cafa.camel@linux.ibm.com> <41fe3962ce1f1d5f61db5f5c28584f68ad66b2b1.camel@linux.ibm.com> <20191128010001.GJ22227@linux.intel.com> In-Reply-To: <20191128010001.GJ22227@linux.intel.com> To: Sean Christopherson Cc: Paolo Bonzini , Paul Mackerras , Radim =?UTF-8?Q?Kr=C4=8Dm=C3=A1=C5=99?= , kvm-ppc@vger.kernel.org, kvm@vger.kernel.org, linux-kernel@vger.kernel.org --=-lkoTnqA1IktRvD8hYwr4 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, 2019-11-27 at 17:00 -0800, Sean Christopherson wrote: > > Sorry, I missed some information on above example.=20 > > Suppose on that example that the reorder changes take place so that > > kvm_put_kvm{,_no_destroy}() always happens after the last usage of kvm > > (in the same syscall, let's say). >=20 > That can't happen, because the ioctl() holds a reference to KVM via its > file descriptor for /dev/kvm, and ioctl() in turn prevents the fd from > being closed. >=20 > > Before T1 and T2, refcount =3D 1; >=20 > This is what's impossible. T1 must have an existing reference to get > into the ioctl(), and that reference cannot be dropped until the ioctl() > completes (and by completes I mean returns to userspace). Assuming no > other bugs, i.e. T2 has its own reference, then refcount >=3D 2. >=20 Thanks for explaining, I think I get it now. Best regards, Leonardo Bras --=-lkoTnqA1IktRvD8hYwr4 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEEMdeUgIzgjf6YmUyOlQYWtz9SttQFAl3f9cwACgkQlQYWtz9S ttQiShAAmAyXr/SVVcZnPHuqz3y4cJ53nMVktdEAtF8U0z3IdztHygSaR/fDLJh7 l9gbD8FHe5Q5mm/cJ22GvZBpi1UJZfq0PZkc9X6h8laGCoBB3hZROkKTyPdeIxD2 1OaisVXrjDi6F/Y9NgRfwhtYdja7MrDEXhzxfcvHf2wylukYIQ58AaZd2f/zgD/X 1Br2XHdKZrKb59MUr4zjWr4v5mNn3Irt16MmdCeZeW5WKiPWvfNPgDSeJhsWWhvH TudyzCickYAn+uOu91BCwzX6oiKRhhWmacI7OB6fByypGaP36yLCxmfyzgIDAvsL BSS7eqCbVFN5x/fSqwHTfXobnTGiLLGJJAzRxsZ6pECitcEgDlyHVg4I3n1nmktV Dsvg2efxVwdhADXesl1d6G3UO51g0vkz4doRq2T+EvONdCp9zpjR6FmpjNQo3VVu jtCfKGayQA3stSSB8iPXllAQ1AhwfqApCmSlRciH5+st2C9GTqocEGWnrxbwAsx4 +6ukeybJxv/bFE568gMvulVUIsLGxQi0Hm2TliyqxTKvhv6Fi8StnP+zo0koquuC IKk4KfpkMHpcwG39X3IYH0tTJW7NFZKR/FBrTN9D6CazZJLvB2RmUmX01C+1d+hq sEbfMtyt7TBruoiT4wrPTEV36FQN+nhKBLFzDH22GYT5xy3aPdQ= =/1KK -----END PGP SIGNATURE----- --=-lkoTnqA1IktRvD8hYwr4--