kvmvapic: Disable if there is insufficient memory
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.
Reported-by Markus Armbruster <[email protected]>
Signed-off-by Jan Kiszka <[email protected]>
--- hw/apic_common.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-)
hw/apic_common.c +3 -1
@@ -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
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
Reported-by Markus Armbruster <[email protected]>Signed-off-by Jan Kiszka <[email protected]>
Tested-by Markus Armbruster <[email protected]>
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)Reported-and-tested-by Markus Armbruster <[email protected]>
Signed-off-by Jan Kiszka <[email protected]>
--- hw/apic_common.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-)
hw/apic_common.c +3 -1
@@ -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
Marcelo Tosatti
AppliedQuoted 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)Reported-and-tested-by Markus Armbruster <[email protected]>Signed-off-by Jan Kiszka <[email protected]>--- hw/apic_common.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-)hw/apic_common.c +3
-1@@ -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.