From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:58420) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SCeSK-0005nc-CK for qemu-devel@nongnu.org; Tue, 27 Mar 2012 18:01:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SCeSI-0002G8-D8 for qemu-devel@nongnu.org; Tue, 27 Mar 2012 18:01:31 -0400 Received: from fmmailgate05.web.de ([217.72.192.243]:49717) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SCeSI-0002Fy-3K for qemu-devel@nongnu.org; Tue, 27 Mar 2012 18:01:30 -0400 Received: from moweb002.kundenserver.de (moweb002.kundenserver.de [172.19.20.108]) by fmmailgate05.web.de (Postfix) with ESMTP id 81A146BB855A for ; Wed, 28 Mar 2012 00:01:28 +0200 (CEST) Message-ID: <4F7238B5.600@web.de> Date: Wed, 28 Mar 2012 00:01:25 +0200 From: Jan Kiszka MIME-Version: 1.0 References: <025b834272f9972f97873779be6523527dad42a8.1332881354.git.jbaron@redhat.com> <1332883861.3799.13.camel@bling.home> In-Reply-To: <1332883861.3799.13.camel@bling.home> Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enig11EE451565F07AD90E23033F" Subject: Re: [Qemu-devel] [PATCH 1/2] qemu kvm: Set up gsi bitmap correctly List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Alex Williamson Cc: aliguori@us.ibm.com, kvm@vger.kernel.org, mst@redhat.com, Jason Baron , qemu-devel@nongnu.org, avi@redhat.com This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig11EE451565F07AD90E23033F Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 2012-03-27 23:31, Alex Williamson wrote: > On Tue, 2012-03-27 at 17:00 -0400, Jason Baron wrote: >> The current 'kvm_init_irq_routing()' doesn't set up the gsi bitmap >> correctly, and as a consequence pins max_gsi to 32 when it really >> should be 1024. I ran into this limitation while testing pci >> passthrough, where I consistently would get -ENOSPACE return from >> kvm_get_irq_route_gsi() in assigned_dev_update_msix_mmio(). >> >> Signed-off-by: Jason Baron >> --- >> kvm-all.c | 4 ++-- >> qemu-kvm.c | 2 +- >> 2 files changed, 3 insertions(+), 3 deletions(-) >> >> diff --git a/kvm-all.c b/kvm-all.c >> index ab88c7c..7d602af 100644 >> --- a/kvm-all.c >> +++ b/kvm-all.c >> @@ -873,9 +873,9 @@ static void kvm_init_irq_routing(KVMState *s) >> unsigned int gsi_bits, i; >> =20 >> /* Round up so we can search ints using ffs */ >> - gsi_bits =3D (gsi_count + 31) / 32; >> + gsi_bits =3D ALIGN(gsi_count, 32); >> s->used_gsi_bitmap =3D g_malloc0(gsi_bits / 8); >=20 > I think the above is all that's needed (it actually used to be this, > then got broken in 84b058d). But if we do this: >=20 >> - s->max_gsi =3D gsi_bits; >> + s->max_gsi =3D gsi_count; >=20 > Then we'll hit this assert from the code immediately below where we're > marking over-allocated bits as already used if we actually did a > round-up: >=20 > static void set_gsi(KVMState *s, unsigned int gsi) > { > assert(gsi < s->max_gsi); >=20 > Sorry, I had forgotten about this pre-allocation trick to avoid > returning > gsi_count when we talked about this. Oh, indeed. That's slightly ugly, gsi_max remains misnamed. Let's just drop the overeager asserts and keep the number of bitmap words in KVMState. That's what we really need for doing the work. Jan --------------enig11EE451565F07AD90E23033F Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.16 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk9yOLUACgkQitSsb3rl5xTfxwCgkhqJNdjV/2EdTns0JXb911ay ypQAnissd7LfaO27VnRCe3OU7ql2ogIf =C/5H -----END PGP SIGNATURE----- --------------enig11EE451565F07AD90E23033F--