From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:39927) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TN0jr-00088w-JD for qemu-devel@nongnu.org; Sat, 13 Oct 2012 08:22:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TN0jq-0002D7-No for qemu-devel@nongnu.org; Sat, 13 Oct 2012 08:22:43 -0400 Received: from g5t0007.atlanta.hp.com ([15.192.0.44]:39843) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TN0jq-0002Ct-JG for qemu-devel@nongnu.org; Sat, 13 Oct 2012 08:22:42 -0400 Message-ID: <50795D10.5050407@hp.com> Date: Sat, 13 Oct 2012 05:22:40 -0700 From: Chegu Vinod MIME-Version: 1.0 References: <5078D432.1010606@hp.com> <20121013073209.GA12689@redhat.com> In-Reply-To: <20121013073209.GA12689@redhat.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] Unable to enable +x2apic for the guest cpus... List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Gleb Natapov Cc: qemu-devel@nongnu.org On 10/13/2012 12:32 AM, Gleb Natapov wrote: > On Fri, Oct 12, 2012 at 07:38:42PM -0700, Chegu Vinod wrote: >> Hello, >> >> I am using a very recent upstream version of qemu.git along with >> kvm.git kernels (in the host and guest). >> [Guest kernel had been compiled with CONFIG_X86_X2APIC and >> CONFIG_IRQ_REMAP both set] >> >> When I attempt to start a guest with +x2apic flag (pl. see the qemu >> cmd line below) I end up with a hang of the qemu and >> a kernel BUG at /arch/x86/kvm/lapic.c:159 ! Pl. see the attached >> screen shot of the console for additional info. >> >> I am able to boot the same guest without the +x2apic flag in the >> qemu cmd line. >> >> Not sure if this an issue (or) if I have something incorrectly >> specified in the qemu cmd line ? If its the latter...pl. advise the >> correct usage >> for enabling x2apic for the guest cpus.. for the upstream bits. >> > This is the bug in how ldr in x2apic mode is calculated. > > Try the following patch: > > diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c > index c6e6b72..43e9fad 100644 > --- a/arch/x86/kvm/lapic.c > +++ b/arch/x86/kvm/lapic.c > @@ -1311,7 +1311,7 @@ void kvm_lapic_set_base(struct kvm_vcpu *vcpu, u64 value) > vcpu->arch.apic_base = value; > if (apic_x2apic_mode(apic)) { > u32 id = kvm_apic_id(apic); > - u32 ldr = ((id & ~0xf) << 16) | (1 << (id & 0xf)); > + u32 ldr = ((id >> 4) << 16) | (1 << (id & 0xf)); > kvm_apic_set_ldr(apic, ldr); > } > apic->base_address = apic->vcpu->arch.apic_base & > -- > Gleb. > . > Retried with the above patch and the guest is booting fine. (x2apic flag shows up in the guest's /proc/cpuinfo). Was this a recent regression? Thanks! Vinod