From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40167) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wij9t-0005ub-P0 for qemu-devel@nongnu.org; Fri, 09 May 2014 07:40:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Wij9m-00057l-FV for qemu-devel@nongnu.org; Fri, 09 May 2014 07:40:09 -0400 Received: from cantor2.suse.de ([195.135.220.15]:39153 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wij9m-000535-8R for qemu-devel@nongnu.org; Fri, 09 May 2014 07:40:02 -0400 Message-ID: <536CBE8D.4050201@suse.de> Date: Fri, 09 May 2014 13:39:57 +0200 From: =?ISO-8859-15?Q?Andreas_F=E4rber?= MIME-Version: 1.0 References: <1399633496-2192-1-git-send-email-arei.gonglei@huawei.com> In-Reply-To: <1399633496-2192-1-git-send-email-arei.gonglei@huawei.com> Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH v2] cirrus_vga: adding sanity check for vram size List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: arei.gonglei@huawei.com, qemu-devel@nongnu.org Cc: blauwirbel@gmail.com, pbonzini@redhat.com, weidong.huang@huawei.com, kraxel@redhat.com, mst@redhat.com Am 09.05.2014 13:04, schrieb arei.gonglei@huawei.com: > From: Gonglei >=20 > 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. >=20 > Signed-off-by: Gonglei > --- > v2: fix checkpatch fails. > "WARNING: suspect code indent for conditional statements (5, 9)" > maybe not a real warning. >=20 > hw/display/cirrus_vga.c | 8 ++++++++ > 1 file changed, 8 insertions(+) >=20 > diff --git a/hw/display/cirrus_vga.c b/hw/display/cirrus_vga.c > index d1afc76..399a2ef 100644 > --- a/hw/display/cirrus_vga.c > +++ b/hw/display/cirrus_vga.c > @@ -2959,6 +2959,14 @@ static int pci_cirrus_vga_initfn(PCIDevice *dev) > PCIDeviceClass *pc =3D PCI_DEVICE_GET_CLASS(dev); > int16_t device_id =3D pc->device_id; > =20 > + /* follow real hardware, cirrus card emulated has 4 MB video memo= ry. > + Also accept 8 MB/16 MB for backward compatibility. */ > + if (s->vga.vram_size_mb !=3D 4 || s->vga.vram_size_mb !=3D 8 || > + s->vga.vram_size_mb !=3D 16) { Apart from the logic bug mjt already pointed out, I note that this check is in the PCI initfn. Should the same restriction also apply for the ISA version of the device? > + error_report("Invalid cirrus_vga ram size '%u'\n", > + s->vga.vram_size_mb); Thanks for using our new error_report(). It does not require a trailing \n though. Regards, Andreas > + return -1; > + } > /* setup VGA */ > vga_common_init(&s->vga, OBJECT(dev), true); > cirrus_init_common(s, OBJECT(dev), device_id, 1, pci_address_spac= e(dev), --=20 SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 N=FCrnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imend=F6rffer; HRB 16746 AG N=FCrnbe= rg