Commit a9605e03 authored by Jan Kiszka's avatar Jan Kiszka Committed by Marcelo Tosatti
Browse files

kvmvapic: Disable if there is insufficient memory



We need at least 1M of RAM to map the option ROM. Otherwise, we will
corrupt host memory or even crash:

    $ qemu-system-x86_64 -nodefaults --enable-kvm -vnc :0 -m 640k
    Segmentation fault (core dumped)

Reported-and-tested-by: default avatarMarkus Armbruster <armbru@redhat.com>
Signed-off-by: default avatarJan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: default avatarMarcelo Tosatti <mtosatti@redhat.com>
parent 050a4606
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -299,7 +299,9 @@ static int apic_init_common(SysBusDevice *dev)

    sysbus_init_mmio(dev, &s->io_memory);

    if (!vapic && s->vapic_control & VAPIC_ENABLE_MASK) {
    /* Note: We need at least 1M to map the VAPIC option ROM */
    if (!vapic && s->vapic_control & VAPIC_ENABLE_MASK &&
        ram_size >= 1024 * 1024) {
        vapic = sysbus_create_simple("kvmvapic", -1, NULL);
    }
    s->vapic = vapic;