From: Michael Ellerman Subject: Re: [PATCH] KVM: Ensure all vcpus are consistent with in-kernel irqchip settings Date: Tue, 06 Mar 2012 16:30:59 +1100 Message-ID: <1331011859.25651.6.camel@concordia> References: <1330950548-10918-1-git-send-email-avi@redhat.com> Reply-To: michael@ellerman.id.au Mime-Version: 1.0 Content-Type: multipart/signed; micalg="pgp-sha256"; protocol="application/pgp-signature"; boundary="=-QiSuPjZeJpuaWaGnv297" Cc: Marcelo Tosatti , kvm@vger.kernel.org To: Avi Kivity Return-path: Received: from ozlabs.org ([203.10.76.45]:46151 "EHLO ozlabs.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751139Ab2CFFbX (ORCPT ); Tue, 6 Mar 2012 00:31:23 -0500 In-Reply-To: <1330950548-10918-1-git-send-email-avi@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: --=-QiSuPjZeJpuaWaGnv297 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Mon, 2012-03-05 at 14:29 +0200, Avi Kivity wrote: > If some vcpus are created before KVM_CREATE_IRQCHIP, then > irqchip_in_kernel() and vcpu->arch.apic will be inconsistent, leading > to potential NULL pointer dereferences. >=20 > Fix by: > - ensuring that no vcpus are installed when KVM_CREATE_IRQCHIP is called > - ensuring that a vcpu has an apic if it is installed after KVM_CREATE_IR= QCHIP >=20 > This is somewhat long winded because vcpu->arch.apic is created without > kvm->lock held. Hi Avi, Thanks for following up on this. This looks OK to me. I wonder if we will end up needing to add other sanity tests at the same point, ie. when we install the vcpu, in which case we might need a generic "sanity hook". But better to keep it specific until we need something generalised. When we do irqchip-in-kernel on powerpc we'll need to rework the #ifdef in kvm_host.h, because we don't want CONFIG_KVM_APIC_ARCHITECTURE, but we will need our own kvm_vcpu_compatible(). But again we'll do that at the time. cheers --=-QiSuPjZeJpuaWaGnv297 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux) iQIcBAABCAAGBQJPVaETAAoJEFHr6jzI4aWABGsP/i3t9SqxYpoZsTufh6hklAAW QJDwgSQN4kjZr7W1oeCm1I0i13Z+lwAGWls8Rxe60WGEAzFmjfU6598Xs8faa5jx r/dkTpBkFqAq8aQiS9jsjHfivE44Rc5PlSYfRvEAKVEhqNN18EHBCVchIWEf57C6 gJj/f0zTWB+KnIeVgb5Qi9uZtsRISImbniKvk+Y57QIRP6dY799u0uWIGxfwIlvV YnbSW0NtK0YDL8FpnTzW/oOMlZoNl0YXI68tbzKobarrE9KcaWw+6SmRNVxSdeFO gqvbVYuWmzUkCxM05i4DM6u5ItaO/+9h46YAlT8EVldQwzUifKnUkAIlJuMLxv62 RV9OCOHrDfsTj8bXPZF7wF2ZVs70HRsrp/A0v+cB6O+4h+pbkgnce1YBFLS9cq3t s0cH3WfwE4XoOcw8Xdu4W+ZZ3JiLKktM6gRxVREJJlwQTZIJBozSevMiD9tisGfU PMYYhBigivSfwTJhGYBzoMgIgTNJUhzJy374iqBuJnzlMyJgxBugsX7OtU1imfsv 0ubciXhakZpt5w0ggmDxUapUdXRAiINdXFmbthNq+u8IlmIpf419UDV/eEoZQcR5 EuFdgTQ68s9qgSAkD2IC48um/bmSglrQ2dJLo6iv/blX6xg8g/UPx0WdkqCxgu4d EeAr4GGJg1INgk2RhCgc =drdN -----END PGP SIGNATURE----- --=-QiSuPjZeJpuaWaGnv297--