From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50804) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1afd0W-0004cI-V3 for qemu-devel@nongnu.org; Mon, 14 Mar 2016 20:38:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1afd0T-00073V-Ny for qemu-devel@nongnu.org; Mon, 14 Mar 2016 20:38:44 -0400 Date: Tue, 15 Mar 2016 11:30:39 +1100 From: David Gibson Message-ID: <20160315003039.GD15272@voom.fritz.box> References: <20160311184514.2768.97728.stgit@bahia.huguette.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="Clx92ZfkiYIKRjnr" Content-Disposition: inline In-Reply-To: <20160311184514.2768.97728.stgit@bahia.huguette.org> Subject: Re: [Qemu-devel] [PATCH] spapr_rng: fix race with main loop List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Greg Kurz Cc: Thomas Huth , Cedric Le Goater , qemu-ppc@nongnu.org, qemu-devel@nongnu.org --Clx92ZfkiYIKRjnr Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Mar 11, 2016 at 07:48:47PM +0100, Greg Kurz wrote: > Since commit "60253ed1e6ec rng: add request queue support to rng-random", > the use of a spapr_rng device may hang vCPU threads. >=20 > The following path is taken without holding the lock to the main loop mut= ex: >=20 > h_random() > rng_backend_request_entropy() > rng_random_request_entropy() > qemu_set_fd_handler() >=20 > The consequence is that entropy_available() may be called before the vCPU > thread could even queue the request: depending on the scheduling, it may > happen that entropy_available() does not call random_recv()->qemu_sem_pos= t(). > The vCPU thread will then sleep forever in h_random()->qemu_sem_wait(). >=20 > This could not happen before 60253ed1e6ec because entropy_available() used > to call random_recv() unconditionally. >=20 > This patch ensures the lock is held to avoid the race. >=20 > Signed-off-by: Greg Kurz Applied to ppc-for-2.6 > --- >=20 > Thomas, >=20 > This is the problem mentioned by Cedric in: >=20 > https://lists.nongnu.org/archive/html/qemu-devel/2016-03/msg02526.html >=20 > Cheers. >=20 --=20 David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson --Clx92ZfkiYIKRjnr Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBAgAGBQJW51evAAoJEGw4ysog2bOSTFoP/03UvkuSYI+C15cqbctixIV1 DPYMVXntWDm+8A9FcblrFDhKVPNZGmnJKIJbFzPQMuc9J36BW+PJ+Kxp9tS5LzJp MPxSXLUDiey8eHIrFxn7BGXwDA7Gq4m/1ndGh0/AmzoNFbsVVxwgNi17d0VN3esx Ucy/6+XjtbpEV+vAk80uOECb8WoHffgybvdrCuJwF1XwQs57cFf8CRYG9VIx8fwZ 67alkZfSnpZ/VgaloJIwNUG28UaOfgAc5GBF0FVCWhma5XUKL5Ob6zfw/Qi59n0R yzVES+adpmHtgQa4U9/fnPnX2X0XQDw1bYbm5sJfDEHMlFlTn8n1nkFk7JycQZYc CgGIQj7MgcPHHbClMls4bzXFlE0xa80j+r2h1dLc8wXMfMXCv8G+4LC4gQdv5lfA HLQyuepWBVHdHCuxr5HJLFvTuDIKFrJDMjszSoiHk6vzIcy77NPlvi57eeHLNvH4 tq1s/8fuui2JH6UZCaohNcofAAcTl2SUzHlhGBsgqDSilKcssnNso5cd4fVdEjJK D3dmtj0PjZO3YQuVlS8r+hnnW7fl/0ZbHQLCm54Z92foGRx4KMfNucj9cRQ/pZhh h7inaowIZZOm+S3NbK9Chxt0IG9MNltY+nAJKZZhQqXcPp35m3cKJRTEmA5KBs9M i6PuUl+xljNtXjkmeIF6 =/BHw -----END PGP SIGNATURE----- --Clx92ZfkiYIKRjnr--