From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35669) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wiilm-0006l6-53 for qemu-devel@nongnu.org; Fri, 09 May 2014 07:15:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Wiilh-0004gm-AZ for qemu-devel@nongnu.org; Fri, 09 May 2014 07:15:14 -0400 Received: from isrv.corpit.ru ([86.62.121.231]:38325) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wiilh-0004fs-41 for qemu-devel@nongnu.org; Fri, 09 May 2014 07:15:09 -0400 Message-ID: <536CB8BA.6060405@msgid.tls.msk.ru> Date: Fri, 09 May 2014 15:15:06 +0400 From: Michael Tokarev 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-1 Content-Transfer-Encoding: 7bit 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: weidong.huang@huawei.com, mst@redhat.com, blauwirbel@gmail.com, kraxel@redhat.com, pbonzini@redhat.com, afaerber@suse.de 09.05.2014 15:04, arei.gonglei@huawei.com wrote: > From: Gonglei > > 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 > --- > v2: fix checkpatch fails. > "WARNING: suspect code indent for conditional statements (5, 9)" > maybe not a real warning. > > hw/display/cirrus_vga.c | 8 ++++++++ > 1 file changed, 8 insertions(+) > > 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 = 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) { This condition will always be true, because a number can't be equal to 3 _different_ numbers at the same time. Thanks, /mjt