* [Qemu-devel] Unable to enable +x2apic for the guest cpus...
@ 2012-10-13 2:38 Chegu Vinod
2012-10-13 7:32 ` Gleb Natapov
0 siblings, 1 reply; 4+ messages in thread
From: Chegu Vinod @ 2012-10-13 2:38 UTC (permalink / raw)
To: Gleb Natapov; +Cc: qemu-devel
[-- Attachment #1.1: Type: text/plain, Size: 1450 bytes --]
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.
Thanks
Vinod
----
/usr/local/bin/qemu-system-x86_64 \
-enable-kvm \
-machine kernel_irqchip=on \
-cpu
Westmere,+rdtscp,+pdpe1gb,+dca,+pdcm,+xtpr,+tm2,+est,+smx,+vmx,+ds_cpl,+monitor,+dtes64,+pclmuldq,+pbe,+tm,+ht,+ss,+acpi,+ds,+vme,+x2apic
\
-m 786432 -smp 80,sockets=80,cores=1,threads=1 \
-name vm1 \
-chardev
socket,id=charmonitor,path=/var/lib/libvirt/qemu/vm1.monitor,server,nowait \
-drive
file=/dev/libvirt_lvm/vm1,if=none,id=drive-virtio-disk0,format=raw,cache=none,aio=native
\
-device
virtio-blk-pci,scsi=off,bus=pci.0,addr=0x5,drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1
\
-monitor stdio \
-net nic,macaddr=52:54:00:71:01:01 \
-net tap,ifname=tap0,script=no,downscript=no \
-vnc :4
[-- Attachment #1.2: Type: text/html, Size: 1971 bytes --]
[-- Attachment #2: kvm.JPG --]
[-- Type: image/jpeg, Size: 237310 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] Unable to enable +x2apic for the guest cpus...
2012-10-13 2:38 [Qemu-devel] Unable to enable +x2apic for the guest cpus Chegu Vinod
@ 2012-10-13 7:32 ` Gleb Natapov
2012-10-13 12:22 ` Chegu Vinod
0 siblings, 1 reply; 4+ messages in thread
From: Gleb Natapov @ 2012-10-13 7:32 UTC (permalink / raw)
To: Chegu Vinod; +Cc: qemu-devel
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.
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] Unable to enable +x2apic for the guest cpus...
2012-10-13 7:32 ` Gleb Natapov
@ 2012-10-13 12:22 ` Chegu Vinod
2012-10-13 12:26 ` Gleb Natapov
0 siblings, 1 reply; 4+ messages in thread
From: Chegu Vinod @ 2012-10-13 12:22 UTC (permalink / raw)
To: Gleb Natapov; +Cc: qemu-devel
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
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] Unable to enable +x2apic for the guest cpus...
2012-10-13 12:22 ` Chegu Vinod
@ 2012-10-13 12:26 ` Gleb Natapov
0 siblings, 0 replies; 4+ messages in thread
From: Gleb Natapov @ 2012-10-13 12:26 UTC (permalink / raw)
To: Chegu Vinod; +Cc: qemu-devel
On Sat, Oct 13, 2012 at 05:22:40AM -0700, Chegu Vinod wrote:
> 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?
>
The bug was there for as long as x2apic support, but it was benign till
the resent apic optimization. We should treat it as a regression.
--
Gleb.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2012-10-13 12:26 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-10-13 2:38 [Qemu-devel] Unable to enable +x2apic for the guest cpus Chegu Vinod
2012-10-13 7:32 ` Gleb Natapov
2012-10-13 12:22 ` Chegu Vinod
2012-10-13 12:26 ` Gleb Natapov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).