Bug 3908 - Kernel panic on qemux86-64 when using runqemu kvm and cpu host
Summary: Kernel panic on qemux86-64 when using runqemu kvm and cpu host
Status: VERIFIED FIXED
Alias: None
Product: Kernel
Classification: Yocto Project Subprojects
Component: linux-yocto (show other bugs)
Version: 1.4
Hardware: x86 Multiple
: Medium+ normal
Target Milestone: 1.5 M2
Assignee: Richard Purdie
QA Contact:
URL:
Whiteboard: release note for 1.4
: 4569 (view as bug list)
Depends on:
Blocks:
 
Reported: 2013-02-19 13:48 UTC by Stefan Stanacar
Modified: 2013-10-07 13:34 UTC (History)
9 users (show)

See Also:
OS type for building Yocto: ---
Type of Regression: ---
Verified:
Documentation change: No (bug/feature does not impact docs)


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Stefan Stanacar 2013-02-19 13:48:32 UTC
Build Configuration:
BB_VERSION        = "1.17.1"
BUILD_SYS         = "x86_64-linux"
NATIVELSBSTRING   = "Fedora-18"
TARGET_SYS        = "x86_64-poky-linux"
MACHINE           = "qemux86-64"
DISTRO            = "poky"
DISTRO_VERSION    = "1.3+snapshot-20130219"
TUNE_FEATURES     = "m64"
TARGET_FPU        = ""
meta              
meta-yocto        
meta-yocto-bsp    = "(nobranch):3ec4df57540421df2cda6b83c615bfb7cebccefd"


bitbake core-image-minimal

runqemu qemux86-64 core-image-minimal kvm nographic

CPU0: Intel(R) Core(TM) i7-2600 CPU @ 3.40GHz stepping 07
Performance Events: 
general protection fault: 0000 [#1] PREEMPT SMP 
CPU 0 
Modules linked in:

Pid: 1, comm: swapper/0 Not tainted 3.4.28-yocto-standard #1 Bochs Bochs
RIP: 0010:[<ffffffff81cc2604>]  [<ffffffff81cc2604>] intel_pmu_init+0x2a8/0x59d
RSP: 0018:ffff88000791be00  EFLAGS: 00000202
RAX: 0000000000000003 RBX: 0000000000000000 RCX: 0000000000000345
RDX: 0000000000000003 RSI: 0000000000000007 RDI: ffffffff81c9d660
RBP: ffff88000791be20 R08: 0000000000000000 R09: ffffffff81c9d500
R10: 0000000000000000 R11: 0000000000000000 R12: ffffffff81cc1969
R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000
FS:  0000000000000000(0000) GS:ffff880007c00000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 000000008005003b
CR2: 0000000000000000 CR3: 0000000001c0b000 CR4: 00000000000406b0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400
Process swapper/0 (pid: 1, threadinfo ffff88000791a000, task ffff880007920000)
Stack:
 0000060300000100 0000000007300402 0000000000000000 ffffffff81d47958
 ffff88000791be40 ffffffff81cc1997 ffffffff81d47958 ffffffff81cc1969
 ffff88000791be70 ffffffff810002b2 ffffffff81d47958 ffff8800079205d8
Call Trace:
 [<ffffffff81cc1997>] init_hw_perf_events+0x2e/0x43a
 [<ffffffff81cc1969>] ? check_bugs+0x2d/0x2d
 [<ffffffff810002b2>] do_one_initcall+0x122/0x170
 [<ffffffff81cb9c03>] kernel_init+0x9e/0x1f8
 [<ffffffff810616a1>] ? get_parent_ip+0x11/0x50
 [<ffffffff81648acd>] ? sub_preempt_count+0x6d/0xd0
 [<ffffffff816451e7>] ? _raw_spin_unlock_irq+0x17/0x40
 [<ffffffff8105df8b>] ? finish_task_switch+0x5b/0xc0
 [<ffffffff8164d794>] kernel_thread_helper+0x4/0x10
 [<ffffffff81cb9b65>] ? start_kernel+0x362/0x362
 [<ffffffff8164d790>] ? gs_change+0xb/0xb
Code: af fd ff 8b 45 ec 48 89 05 8a af fd ff 7e 2e 8a 55 e4 b8 03 00 00 00 b9 45 03 00 00 83 e2 1f 83 fa 02 0f 4f c2 89 05 5c af fd ff <0f> 32 48 c1 e2 20 89 c0 48 09 c2 48 89 15 d2 af fd ff e8 f5 38 
RIP  [<ffffffff81cc2604>] intel_pmu_init+0x2a8/0x59d
 RSP <ffff88000791be00>
---[ end trace c37d9dee481c2517 ]---
Kernel panic - not syncing: Attempted to kill init! exitcode=0x0000000b

runqemu actually runs this command:

/home/stefans/yocto/builds/y1/tmp/sysroots/x86_64-linux/usr/bin/qemu-system-x86_64 -kernel tmp/deploy/images/bzImage-qemux86-64.bin -net nic,model=virtio -net tap,vlan=0,ifname=tap0,script=no,downscript=no,vhost=on -drive file=tmp/deploy/images/core-image-minimal-qemux86-64.ext3,if=virtio -show-cursor -usb -usbdevice wacom-tablet -vga vmware -no-reboot -enable-kvm -cpu host -m 128 --append "vga=0 root=/dev/vda rw mem=128M ip=192.168.7.2::192.168.7.1:255.255.255.0 oprofile.timer=1 "

 
http://git.yoctoproject.org/cgit.cgi/poky/commit/meta/recipes-kernel/linux/linux-yocto_3.4.bb?id=e6149ec6c4c14d3a939022cdc29ac94dced836dd

The above commit removed guest kvm support on qemux86-64. Now, I believe it should be possible to pass --enable-kvm to qemu and run an unmodified guest  without it crashing. 
And indeed, if I don't use runqemu and I remove "-cpu host" from the above command, it doesn't crash anymore.
Comment 1 Darren Hart 2013-02-28 04:58:38 UTC
Scott, can you please have a look an runqemu and whether "-cpu host" is the right option to be using here?
Comment 2 Cristian Iorga 2013-03-26 17:11:31 UTC
Hi Stefan.

Can you please explain to me the rationale behind your observations?

Paravirtualization is not directly related to -cpu host option, as far as I know.

That is one thing.

The other thing is this used to work, so clearly it is a regression.

Regards,
Cristian
Comment 3 Cristian Iorga 2013-04-02 06:46:41 UTC
Hi, is there an estimate when this bug will be fixed?

The fact that qemux86-64 machines cannot be run with KVM impacts the performance (boot time is 2x longer), therefore impacting during the development testing.
Comment 4 Alexandru Damian 2013-04-09 14:01:03 UTC
Darren is right, I got a root cause. Patch coming up shortly.
Comment 5 Alexandru Damian 2013-04-09 14:48:14 UTC
This is caused by a restricted instruction issued on CPU type. Patch submitted that sets CPU type to qemu on all targets, and thus avoids using model-specific registers under emulation.
Comment 6 Cristian Iorga 2013-04-15 06:57:14 UTC
Hi Alex,
I might be wrong, and I need more time to investigate, but I don't agree with the fix you proposed for this issue.

What you propose is just a step back from how qemu should optimally work, meaning exporting "-cpu host".

That's one thing.

Another thing is the described issue seems to be specific to some kernels on the host.
For example, I checked with LaurP and AlexG and thes issue is:
- reproducible on Ubuntu 12.10 with kernel 3.5.0.27 and Fedora Core 18 with kernel 3.8.5.
- not reproducible with Ubuntu 12.04 with kernel 3.2.x (need to check the exact details with LaurP).

This issue needs more investigation.

Regards,
Cristian
Comment 7 Darren Hart 2013-05-28 20:46:18 UTC
Where are we with this? Is it still reproducing?
Comment 8 Stefan Stanacar 2013-05-29 08:50:44 UTC
As of 676fd3f394a0c0576b63c77ed2184bf5f42c29b6 I still get the same general protection fault for: runqemu qemux86-64 core-image-sato kvm
Comment 9 Cristian Iorga 2013-05-29 08:57:17 UTC
Hi Stefan,

Can you please state the host OS for running qemu?

I have noticed that:
On Ubuntu 12.04 x86-64 the issue is not reproducible.
On Ubuntu 12.10 x86-64 the issue is reproducible.

Regards,
Cristian
Comment 10 Stefan Stanacar 2013-05-29 09:34:11 UTC
It's the same OS as in my first comment: Fedora 18 x86-64. In the meantime kernel went from  3.8.5. to 3.9.4-200.fc18.x86_64
Comment 11 Stefan Stanacar 2013-06-28 12:27:23 UTC
Ping? 

I still see this on poky master:67f76e6fc2d8476bdaaf500432198670b883138a, Fedora 18 3.9.6-200.fc18.x86_64
Comment 12 Ning Zhang 2013-07-09 06:16:47 UTC
Hi, 

I found this bug can be reproduced on Ubuntu 13.04.
But it can not be reproduced on Ubuntu 12.04.

Poky is master eaa5df34af42b6a37f6506847d0f3ef6ba0d298a
Comment 13 Darren Hart 2013-09-17 17:03:09 UTC
This should be resolved via the updated runqemu options. If this bug can be reproduced with the runqemu script, please reopen.
Comment 14 Yi Zhao 2013-09-18 09:18:31 UTC
This issue still happens on 1.5 M5 rc1.
Comment 15 Stefan Stanacar 2013-09-18 15:19:59 UTC
This isn't fixed as of latest master 63cd03b80c3eb5b4b88774e44a4ed2cf0905f094,
and I haven't seen anything going in related to this.
(see earlier comments about distro/kernel versions where the panic shows up)

I know this bug has been in set  in REVIEW for a looong time (probably because of comment #5) but that patch has never been merged and IIRC there were some comments on the list at that time, so nothing changed here.

Darren are we missing something?   You said something about "updated runqemu options"... )
Comment 16 Darren Hart 2013-09-18 18:08:07 UTC
Stefan, how are you running the test? Is the runqemu command used?
Comment 17 Stefan Stanacar 2013-09-19 06:05:16 UTC
Yup:
 runqemu qemux86-64 core-image-minimal kvm
Comment 18 Richard Purdie 2013-09-25 16:20:30 UTC
Bruce, I'm hoping with your work in the virtualisation space you have a better idea than we do of what we should be passing to qemu here.

Currently -cpu host is used which gets a backtrace from perf for me too. Other options appear to be qemu64, kvm64, kvm32 and qemu32. 

$ /qemu-system-x86_64 -cpu help
x86           qemu64  QEMU Virtual CPU version 1.5.0                  
x86            kvm64  Common KVM processor                            
x86           qemu32  QEMU Virtual CPU version 1.5.0                  
x86            kvm32  Common 32-bit KVM processor                     
x86             host  KVM processor with all supported host features (only available in KVM mode)

which one do we want and why?
Comment 19 Bruce Ashfield 2013-09-25 16:36:17 UTC
qemu64 and kvm64 are roughly the same, in particular if you are launching with
the -enable-kvm. The latter is supposed to offer a consistent base and capability
set to the VMs, the former is often the default and will present a similar ... but not
as tailored set of options.

My recommendation is to use the kvm cpu types if you really are launched accelerated
guests all the time. If you want to mix and match, use qemu64 (and use the --enable-kvm
flag to get the optional acceleration).

Also note that we can beef up the capabilities as required, like so:

    -cpu qemu64,+x2apic

Which means you can add any instruction or capability that -cpu host used to offer, but
do it in a safer way.
Comment 20 Richard Purdie 2013-09-25 20:59:54 UTC
Thanks Bruce, much appreciated. I've sent out a patch for review which fixes the problem for me locally.
Comment 22 Stefan Stanacar 2013-10-03 11:08:53 UTC
*** Bug 4569 has been marked as a duplicate of this bug. ***
Comment 23 Stefan Stanacar 2013-10-07 13:34:00 UTC
Thanks, works now. Marked as Verified.