qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH uq/master] kvmvapic: Disable if there is insufficient memory
@ 2012-08-14 11:12 Jan Kiszka
  2012-08-14 11:40 ` Markus Armbruster
  0 siblings, 1 reply; 4+ messages in thread
From: Jan Kiszka @ 2012-08-14 11:12 UTC (permalink / raw)
  To: Avi Kivity, Marcelo Tosatti; +Cc: qemu-devel, kvm, Markus Armbruster

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 <armbru@redhat.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
 hw/apic_common.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/hw/apic_common.c b/hw/apic_common.c
index 58e63b0..371f95d 100644
--- a/hw/apic_common.c
+++ b/hw/apic_common.c
@@ -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;
-- 
1.7.3.4

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [PATCH uq/master] kvmvapic: Disable if there is insufficient memory
  2012-08-14 11:12 [Qemu-devel] [PATCH uq/master] kvmvapic: Disable if there is insufficient memory Jan Kiszka
@ 2012-08-14 11:40 ` Markus Armbruster
  2012-08-14 11:43   ` [Qemu-devel] [PATCH v2 " Jan Kiszka
  0 siblings, 1 reply; 4+ messages in thread
From: Markus Armbruster @ 2012-08-14 11:40 UTC (permalink / raw)
  To: Jan Kiszka; +Cc: Marcelo Tosatti, Avi Kivity, kvm, qemu-devel

Jan Kiszka <jan.kiszka@siemens.com> writes:

> 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)

> Reported-by: Markus Armbruster <armbru@redhat.com>
> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>

Tested-by: Markus Armbruster <armbru@redhat.com>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Qemu-devel] [PATCH v2 uq/master] kvmvapic: Disable if there is insufficient memory
  2012-08-14 11:40 ` Markus Armbruster
@ 2012-08-14 11:43   ` Jan Kiszka
  2012-08-14 19:01     ` Marcelo Tosatti
  0 siblings, 1 reply; 4+ messages in thread
From: Jan Kiszka @ 2012-08-14 11:43 UTC (permalink / raw)
  To: Avi Kivity, Marcelo Tosatti; +Cc: Markus Armbruster, kvm, qemu-devel

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 <armbru@redhat.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
 hw/apic_common.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/hw/apic_common.c b/hw/apic_common.c
index 58e63b0..371f95d 100644
--- a/hw/apic_common.c
+++ b/hw/apic_common.c
@@ -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;
-- 
1.7.3.4

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [PATCH v2 uq/master] kvmvapic: Disable if there is insufficient memory
  2012-08-14 11:43   ` [Qemu-devel] [PATCH v2 " Jan Kiszka
@ 2012-08-14 19:01     ` Marcelo Tosatti
  0 siblings, 0 replies; 4+ messages in thread
From: Marcelo Tosatti @ 2012-08-14 19:01 UTC (permalink / raw)
  To: Jan Kiszka; +Cc: qemu-devel, Avi Kivity, kvm, Markus Armbruster

On Tue, Aug 14, 2012 at 01:43:12PM +0200, Jan Kiszka wrote:
> 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 <armbru@redhat.com>
> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
> ---
>  hw/apic_common.c |    4 +++-
>  1 files changed, 3 insertions(+), 1 deletions(-)
> 
> diff --git a/hw/apic_common.c b/hw/apic_common.c
> index 58e63b0..371f95d 100644
> --- a/hw/apic_common.c
> +++ b/hw/apic_common.c
> @@ -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;
> -- 
> 1.7.3.4

Applied, thanks.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-08-14 19:01 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-08-14 11:12 [Qemu-devel] [PATCH uq/master] kvmvapic: Disable if there is insufficient memory Jan Kiszka
2012-08-14 11:40 ` Markus Armbruster
2012-08-14 11:43   ` [Qemu-devel] [PATCH v2 " Jan Kiszka
2012-08-14 19:01     ` Marcelo Tosatti

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).