kvm -kernel with grub multiboot kernel dumps core or exits

Bug #957622 reported by Scott Moser on 2012-03-17
This bug affects 1 person
Affects Status Importance Assigned to Milestone
qemu-kvm (Ubuntu)

Bug Description

I attempted to use kvm -kernel with a grub multiboot image, specifically grub-maverick-20100729.img at [1]. That file was built using [2]

$ url="http://bazaar.launchpad.net/~ubuntu-on-ec2/vmbuilder/automated-ec2-builds/download/head:/grubmaverick20100729-20100729071944-bevge631maio9jpl-2/grub-maverick-20100729.img"
$ wget $url -O grub-maverick-20100729.img
$ qemu-img create -f qcow2 disk.img 1G
$ kvm -curses -kernel grub-maverick-20100729.img -drive file=disk.img,if=virtio

This process works fine on oneiric and you will see a curses interface, and some output of grub looking for a image to boot.

On my laptop (with kvm support), I saw:

$ kvm -curses -kernel grub-maverick-20100729.img -drive file=disk.img,if=virtio;
fread() failed
$ echo $?

On a kvm guest (via openstack instance), it crashed differently:
$ kvm -curses -kernel grub-maverick-20100729.img -drive file=disk.img,if=virtio
Could not access KVM kernel module: No such file or directory
failed to initialize KVM: No such file or directory
Back to tcg accelerator.

GLib-ERROR **: /build/buildd/glib2.0-2.31.20/./glib/gmem.c:165: failed to allocate 4293918720 bytes
Trace/breakpoint trap (core dumped)

Just for a test, I tried loading kvm-amd, got nested kvm virtualization, but the instance fails the same way.

[1] http://bazaar.launchpad.net/~ubuntu-on-ec2/vmbuilder/automated-ec2-builds/files/head:/loaders/
[2] http://bazaar.launchpad.net/~ubuntu-on-ec2/vmbuilder/automated-ec2-builds/view/head:/mk-image-mb-loader

ProblemType: Bug
DistroRelease: Ubuntu 12.04
Package: kvm (not installed)
ProcVersionSignature: User Name 3.2.0-18.29-virtual 3.2.9
Uname: Linux 3.2.0-18-virtual x86_64
ApportVersion: 1.94.1-0ubuntu2
Architecture: amd64
 [27230.320857] init: qemu-kvm pre-start process (8659) terminated with status 1
 [27230.361904] init: qemu-kvm post-stop process (8664) terminated with status 1
 [27249.426836] kvm[9021] trap int3 ip:7f44c2bbc13b sp:7fff447e1120 error:0
 [27263.380598] kvm[9283] trap int3 ip:7f3fba9f713b sp:7fff8b55d1a0 error:0
Date: Sat Mar 17 01:48:13 2012
Ec2AMI: ami-00000000
Ec2AMIManifest: FIXME
Ec2AvailabilityZone: nova
Ec2InstanceType: m1.small
Ec2Kernel: unavailable
Ec2Ramdisk: unavailable
KvmCmdLine: Error: command ['ps', '-C', 'kvm', '-F'] failed with exit code 1: UID PID PPID C SZ RSS PSR STIME TTY TIME CMD
 Bus 001 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
 Bus 001 Device 002: ID 0627:0001 Adomax Technology Co., Ltd
MachineType: Bochs Bochs
 PATH=(custom, user)
ProcKernelCmdLine: BOOT_IMAGE=/boot/vmlinuz-3.2.0-18-virtual root=LABEL=cloudimg-rootfs ro console=ttyS0
 acpiphp 24231 0 - Live 0x0000000000000000
 floppy 70365 0 - Live 0x0000000000000000
 psmouse 87603 0 - Live 0x0000000000000000
 serio_raw 13211 0 - Live 0x0000000000000000
 virtio_balloon 13108 0 - Live 0x0000000000000000
SourcePackage: qemu-kvm
UpgradeStatus: No upgrade log present (probably fresh install)
dmi.bios.date: 01/01/2007
dmi.bios.vendor: Bochs
dmi.bios.version: Bochs
dmi.chassis.type: 1
dmi.chassis.vendor: Bochs
dmi.modalias: dmi:bvnBochs:bvrBochs:bd01/01/2007:svnBochs:pnBochs:pvr:cvnBochs:ct1:cvr:
dmi.product.name: Bochs
dmi.sys.vendor: Bochs

Scott Moser (smoser) wrote :
tags: added: regression-release
Scott Moser (smoser) wrote :

some more info, with debug enabled in hw/multiboot.kvm on kvm git trunk:

$ ./x86_64-softmmu/qemu-system-x86_64 --machine accel=tcg -kernel ~/grub-maverick-20100729.img
qemu: I believe we found a multiboot image!
multiboot: mh_header_addr = 0x10025c
multiboot: mh_load_addr = 0x100000
multiboot: mh_load_end_addr = 0
multiboot: mh_bss_end_addr = 0
qemu: loading multiboot kernel (0xfff00000 bytes) at 0x100000

GLib-ERROR **: /build/buildd/glib2.0-2.31.20/./glib/gmem.c:165: failed to allocate 4293918720 bytes
Trace/breakpoint trap (core dumped)

Scott Moser (smoser) wrote :

a quick look at source from the above, and this appears to have been broken/influenced by commit for "multiboot: Fix bss segment support".

Some evidence to the validity of the multiboot image is here:
$ bzr branch http://bzr.savannah.gnu.org/r/grub/trunk/multiboot
$ cd multiboot
$ ./autogen.sh
$ ./configure
$ make
$ ./util/mbchk grub-maverick-20100729.img
grub-maverick-20100729.img: The Multiboot header is found at the offset 604.
grub-maverick-20100729.img: Page alignment is turned off.
grub-maverick-20100729.img: Memory information is turned off.
grub-maverick-20100729.img: Address fields is turned on.
grub-maverick-20100729.img: All checks passed.

[1] http://git.kernel.org/?p=virt/kvm/qemu-kvm.git;a=commit;h=6b8273a1b97876950d91c228a420a851e10e12bb

Scott Moser (smoser) wrote :

I'm pretty sure this is a bug in the linked commit above, in that it does not account for this statement in the multiboot spec:

     Contains the physical address of the end of the data segment.
     (load_end_addr - load_addr) specifies how much data to load. This
     implies that the text and data segments must be consecutive in the
     OS image; this is true for existing a.out executable formats. If
     this field is zero, the boot loader assumes that the text and data
     segments occupy the whole OS image file.

Specifically, "If this field is zero..."

Scott Moser (smoser) wrote :
Changed in qemu-kvm (Ubuntu):
status: New → In Progress
Changed in qemu:
status: New → Confirmed
Changed in qemu-kvm (Ubuntu):
importance: Undecided → Medium
Scott Moser (smoser) wrote :

Forwarded to qemu-devel mailing list at http://<email address hidden>/msg103059.html .

Scott Moser (smoser) wrote :
tags: added: patch
Serge Hallyn (serge-hallyn) wrote :

Thanks, Scott. I"ll wait a day or two to see if there are any upstream comments, then apply.

description: updated
Serge Hallyn (serge-hallyn) wrote :

Thanks, Scott, the patch worked for me so I'll push it.

Launchpad Janitor (janitor) wrote :

This bug was fixed in the package qemu-kvm - 1.0+noroms-0ubuntu9

qemu-kvm (1.0+noroms-0ubuntu9) precise; urgency=low

  * debian/patches/multiboot-load-fix.diff: fix bug when loading
    multiboot images such as grub via -kernel parameter (LP: #957622)
 -- Scott Moser <email address hidden> Sun, 18 Mar 2012 19:34:28 -0400

Changed in qemu-kvm (Ubuntu):
status: In Progress → Fix Released
Scott Moser (smoser) wrote :
Changed in qemu:
status: Confirmed → Fix Committed
Aurelien Jarno (aurel32) on 2012-09-07
Changed in qemu:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers