qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH] cirrus_vga: adding sanity check for vram size


From: arei.gonglei
Subject: [Qemu-devel] [PATCH] cirrus_vga: adding sanity check for vram size
Date: Fri, 9 May 2014 18:21:09 +0800

From: Gonglei <address@hidden>

when configure a invalid vram size for cirrus card, such as less
2 MB, which will crash qemu. Follow the real hardware, the cirrus
card has 4 MB video memory. Also for backward compatibility, accept
8 MB and 16 MB vram size.

Signed-off-by: Gonglei <address@hidden>
---
For isa cirrus vga device, its' init function has been droped at
commit db895a1e6a97e919f9b86d60c969377357b05066. I have no idea how adding
check on isa_cirrus_vga device. Any ideas? Thanks.
 
 hw/display/cirrus_vga.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/hw/display/cirrus_vga.c b/hw/display/cirrus_vga.c
index d1afc76..5fec068 100644
--- a/hw/display/cirrus_vga.c
+++ b/hw/display/cirrus_vga.c
@@ -2959,6 +2959,13 @@ static int pci_cirrus_vga_initfn(PCIDevice *dev)
      PCIDeviceClass *pc = PCI_DEVICE_GET_CLASS(dev);
      int16_t device_id = pc->device_id;
 
+     /* follow real hardware, cirrus card emulated has 4 MB video memory.
+       Also accept 8 MB/16 MB for backward compatibility. */
+     if (s->vga.vram_size_mb != 4 || s->vga.vram_size_mb != 8 ||
+         s->vga.vram_size_mb != 16) {
+         error_report("Invalid cirrus_vga ram size '%u'\n", 
s->vga.vram_size_mb);
+         return -1;
+     }
      /* setup VGA */
      vga_common_init(&s->vga, OBJECT(dev), true);
      cirrus_init_common(s, OBJECT(dev), device_id, 1, pci_address_space(dev),
-- 
1.7.12.4





reply via email to

[Prev in Thread] Current Thread [Next in Thread]