Received: from [140.186.70.92] (port=53823 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OdZEq-00064U-DV for qemu-devel@nongnu.org; Mon, 26 Jul 2010 21:45:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OdZEp-0001A2-AX for qemu-devel@nongnu.org; Mon, 26 Jul 2010 21:45:48 -0400 Received: from mail-vw0-f45.google.com ([209.85.212.45]:39029) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OdZEp-00019x-7M for qemu-devel@nongnu.org; Mon, 26 Jul 2010 21:45:47 -0400 Received: by vws19 with SMTP id 19so3090010vws.4 for ; Mon, 26 Jul 2010 18:45:46 -0700 (PDT) Date: Mon, 26 Jul 2010 21:45:42 -0400 From: Kevin O'Connor Message-ID: <20100727014542.GB30752@morn.localdomain> References: <467b97ca8eab5336ed7fa6fae93db3695a04e8dd.1280120278.git.yamahata@valinux.co.jp> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <467b97ca8eab5336ed7fa6fae93db3695a04e8dd.1280120278.git.yamahata@valinux.co.jp> Subject: [Qemu-devel] Re: [SeaBIOS] [PATCH 2/2] seabios: pciinit: fix overflow when bar allocation. List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Isaku Yamahata Cc: seabios@seabios.org, mst@redhat.com, cam@cs.ualberta.ca, qemu-devel@nongnu.org On Mon, Jul 26, 2010 at 02:02:46PM +0900, Isaku Yamahata wrote: > When allocating bar, overflow can occur. > So add overflow check and don't allocate bar if overflowed. > Overflow check is ugly, but necessary. > Another suggested way is to change related variables u64 from u32 > thus overflow can't occur because the related value are all u32 addressable. > Anyway even with u64, it is necessary to the resulted value > max_u32. I wonder if we could create malloc zones for this and then use pmm_alloc. The pmm_alloc function already handles overflow and alignments. One difficulty, though, is that pmm_alloc doesn't guarentee linear allocations, and it looks like pci_bios_init_device_bridge assumes this. -Kevin