From patchwork Sat Oct 13 07:32:09 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gleb Natapov X-Patchwork-Id: 191285 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 07FE32C008F for ; Sat, 13 Oct 2012 18:32:24 +1100 (EST) Received: from localhost ([::1]:54381 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TMwCr-00037Y-OP for incoming@patchwork.ozlabs.org; Sat, 13 Oct 2012 03:32:21 -0400 Received: from eggs.gnu.org ([208.118.235.92]:50071) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TMwCk-00037R-LY for qemu-devel@nongnu.org; Sat, 13 Oct 2012 03:32:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TMwCj-0000CW-K5 for qemu-devel@nongnu.org; Sat, 13 Oct 2012 03:32:14 -0400 Received: from mx1.redhat.com ([209.132.183.28]:6055) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TMwCj-0000CI-CP for qemu-devel@nongnu.org; Sat, 13 Oct 2012 03:32:13 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q9D7WADM028608 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sat, 13 Oct 2012 03:32:10 -0400 Received: from dhcp-1-237.tlv.redhat.com (dhcp-4-26.tlv.redhat.com [10.35.4.26]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q9D7W9cD011115; Sat, 13 Oct 2012 03:32:10 -0400 Received: by dhcp-1-237.tlv.redhat.com (Postfix, from userid 13519) id 32E2718D3A5; Sat, 13 Oct 2012 09:32:09 +0200 (IST) Date: Sat, 13 Oct 2012 09:32:09 +0200 From: Gleb Natapov To: Chegu Vinod Message-ID: <20121013073209.GA12689@redhat.com> References: <5078D432.1010606@hp.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <5078D432.1010606@hp.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Cc: qemu-devel@nongnu.org Subject: Re: [Qemu-devel] Unable to enable +x2apic for the guest cpus... X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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: --- Gleb. 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 &