From: Isaku Yamahata Subject: Re: [SeaBIOS] Graphics card pass-through working with two pass pci-initialization Date: Tue, 31 May 2011 11:29:22 +0900 Message-ID: <20110531022922.GB10673@valinux.co.jp> References: <20110525023406.GG8517@valinux.co.jp> <20110525043353.GH8517@valinux.co.jp> <4DDCC7A5.60706@redhat.com> <4DDCF9ED.5050208@redhat.com> <4DDDDA8D.6080807@web.de> <4DDDF62C.2010603@redhat.com> <4DDF3768.5010002@web.de> <4DDF867A.9040700@siemens.com> <4DDFFE1E.1060900@web.de> <4DE3486F.10502@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: =?utf-8?B?QW5kcsOp?= Weidemann , Jan Kiszka , Alex Williamson , seabios@seabios.org, kvm@vger.kernel.org To: Gerd Hoffmann Return-path: Received: from mail.valinux.co.jp ([210.128.90.3]:53518 "EHLO mail.valinux.co.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756637Ab1EaC3X (ORCPT ); Mon, 30 May 2011 22:29:23 -0400 Content-Disposition: inline In-Reply-To: <4DE3486F.10502@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: On Mon, May 30, 2011 at 09:34:07AM +0200, Gerd Hoffmann wrote: > Hi, > >> If I am not mistaken then the graphics card needs 2 bars, one with 256MB >> and one with 128K. The sound card then needs 1 bar with 16K of PCI memory. >> How big is the PCI memory with seabios? > > Some comments on that (apply to the kraxel.q35 branch): > > You can add this to the qemu command line to get the seabios debug > output printed: > > qemu $usualoptions -chardev stdio,id=seabios \ > -device isa-debugcon,iobase=0x402,chardev=seabios > > Then you can watch seabios assigning memory. > > The ordering of the cards should not matter at all, the hacked bios does > a two-pass scan to order the memory bars by size and pack them nicely. > > Finding holes in address space for pci bars is not perfect yet. Right > now it has sort-of hardcoded the 0xf0000000 -> 0xfec00000 range and > tries to fit in stuff there. If it fails to fit in everything it tries > again but leaves out devices which are not essential for boot. If it > still fails the error isn't handled yet. For q35 this is a non-starter > as it uses the e0000000 -> efffffff range for pci mmconfig. For the > piix it doesn't hurt for now as the area above 0xe0000000 is unused. And > the address space up to 0xe0000000 is used for guest ram only, thus it > depends on the amount of memory you assign to the guest whenever this > area is free or not. If you assign -- say -- 2G to your guest > everything above 0x80000000 is free. > > With your setup (256m + 128m + small stuff) I'd expect seabios place the > 256m bar @ 0xe0000000, the 128m bar @ 0xf0000000 and all the small ones > above 0xf8000000. It will maps only the devices which it thinks are > essential for boot (i.e. skip the sound card). > > At the end of the day I want the pci address space allocation code have > no hard-coded addresses in there but use the e820 table instead to > figure how big the address space hole is. Maybe even use multiple holes > (i.e. also use the memory below mmconfig @ 0xe0000000 with q35). 0xE0000000 is hard-coded in the DSDT for both piix and q35 as below. If the range is determined dynamically, the area also needs to be updated somehow dynamically. ... Name (_CRS, ResourceTemplate () ... DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed, NonCacheable, ReadWrite, 0x00000000, // Address Space Granularity 0xE0000000, // Address Range Minimum 0xFEBFFFFF, // Address Range Maximum 0x00000000, // Address Translation Offset 0x1EC00000, // Address Length ,, , AddressRangeMemory, TypeStatic) thanks, -- yamahata