Skip to contentSkip to conversation

kvmvapic: Disable if there is insufficient memory

PATCH Superseded Jan Kiszka 3 participants 4 messages Aug 14, 2012 KVM

lore
Share & tools
lore

Jan Kiszka

author
#0 lore raw

PATCH 1/1 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.

---
 hw/apic_common.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
hw/apic_common.c +3 -1
index 58e63b0..371f95d 100644
@@ -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;
Signature · 1 line
1.7.3.4
Tested-by on v1 1/1
#1 lore raw
Quoted 2 lines · Jan Kiszka

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

Let's put a reproducer in the commit message, if it's not too much trouble. Here's mine:

    $ qemu-system-x86_64 -nodefaults --enable-kvm -vnc :0 -m 640k
    Segmentation fault (core dumped)
Quoted 2 lines
author
#2 lore raw

PATCH v2 1/1 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)
---
 hw/apic_common.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
hw/apic_common.c +3 -1
index 58e63b0..371f95d 100644
@@ -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;
Signature · 1 line
1.7.3.4
#3 lore raw
Quoted 29 lines · Jan Kiszka

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)
---
 hw/apic_common.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
hw/apic_common.c +3 -1
index 58e63b0..371f95d 100644
@@ -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;
Signature · 1 line
1.7.3.4

Applied, thanks.