Received: from eggs.gnu.org ([2001:4830:134:3::10]:33011) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bDwVP-0006wP-BN for qemu-devel@nongnu.org; Fri, 17 Jun 2016 12:20:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bDwVL-00089g-80 for qemu-devel@nongnu.org; Fri, 17 Jun 2016 12:20:27 -0400 Received: from mx1.redhat.com ([209.132.183.28]:46955) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bDwVK-00089A-Vm for qemu-devel@nongnu.org; Fri, 17 Jun 2016 12:20:23 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9D345811A2 for ; Fri, 17 Jun 2016 16:20:22 +0000 (UTC) References: <1466097133-5489-1-git-send-email-dgilbert@redhat.com> <1466097133-5489-5-git-send-email-dgilbert@redhat.com> <20160616202449.GY18662@thinpad.lan.raisama.net> <20160617081505.GA2273@work-vm> <08f8e4e0-781a-d7f2-9008-3274f8a085eb@redhat.com> <1466155074.18921.16.camel@redhat.com> <20160617115239.035fb544@nial.brq.redhat.com> <1466162438.18921.22.camel@redhat.com> From: Laszlo Ersek Message-ID: <92151ec0-93ab-bb15-fb0e-a889645fd07f@redhat.com> Date: Fri, 17 Jun 2016 18:20:19 +0200 MIME-Version: 1.0 In-Reply-To: <1466162438.18921.22.camel@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 4/5] x86: Allow physical address bits to be set List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Gerd Hoffmann , Igor Mammedov Cc: Paolo Bonzini , aarcange@redhat.com, qemu-devel@nongnu.org, "Dr. David Alan Gilbert" , Eduardo Habkost , Marcel Apfelbaum On 06/17/16 13:20, Gerd Hoffmann wrote: > Hi, > >>> Not sure whenever qemu adds some extra space for hotplug to the 64bit >>> hole and if so how it calculates the size then. But the guest os should >>> stick to those ranges when configuring hotplugged devices. > >> currently firmware would assign 64-bit BARs after reserved-memory-end >> (not sure about ovmf though) > > Ah, right, reserved-memory-end is checked too if present. Both seabios > and ovmf should do that. OVMF does that, yes. > >> but QEMU on ACPI side will add 64-bit _CRS only >> for firmware mapped devices (i.e. no space reserved for hotplug). > > Yes. Tested meanwhile, looks like this (seabios): > > 100000000-17fffffff : System RAM > 180000000-1c1ffffff : PCI Bus 0000:00 > 180000000-1bfffffff : 0000:00:0f.0 > 1c0000000-1c07fffff : PCI Bus 0000:04 > 1c0000000-1c07fffff : 0000:04:00.0 > 1c0000000-1c07fffff : virtio-pci > 1c0800000-1c0ffffff : PCI Bus 0000:03 > 1c0800000-1c0ffffff : 0000:03:00.0 > 1c0800000-1c0ffffff : virtio-pci > 1c1000000-1c17fffff : PCI Bus 0000:02 > 1c1000000-1c17fffff : 0000:02:00.0 > 1c1000000-1c17fffff : virtio-pci > 1c1800000-1c19fffff : PCI Bus 0000:08 > 1c1a00000-1c1bfffff : PCI Bus 0000:07 > 1c1c00000-1c1dfffff : PCI Bus 0000:06 > 1c1e00000-1c1ffffff : PCI Bus 0000:05 (This is from /proc/iomem in the guest, right? A note about this later.) > seabios assigns a 2M memory window to pci bridges (which support > hotplug) even in case no device is connected, so there is some space for > hotplug because of that. > > /me should try the same with ovmf ... The generic PCI bus driver in edk2 (PciBusDxe), which is built into OVMF, does not allocate IO and/or MMIO for a bridge if there are zero devices behind the bridge that consume that kind of resource. I actually consider this a feature, not a bug, because it helps avoid the exhaustion of the limited IO port space. In any case, /proc/iomem is not a good tool for investigating resources assigned by the firmware. Linux is stubborn and will *itself* allocate IO port ranges for bridges, for example, when OVMF -- justifiedly, see above -- did no such thing. Marcel suggested to prevent this with various bridge registers, and Paolo suggested to modify Linux's behavior. Either way, what you see in /proc/iomem is not the unadulterated effect of the firmware. In OVMF's case, the resource map for every bridge / device can be seen in the OVMF debug log, searching for the string "resource map" (case-insensitively). Regarding PCIe hotplug, it seemed to work under OVMF, after we fixed with Marcel's crucial help. OVMF inherits the PcdPciBusHotplugDeviceSupport=TRUE build-time feature flag from "MdeModulePkg/MdeModulePkg.dec": ## Indicates if PciBus driver supports the hot plug device.

# TRUE - PciBus driver supports the hot plug device.
# FALSE - PciBus driver doesn't support the hot plug device.
# @Prompt Enable PciBus hot plug device support. gEfiMdeModulePkgTokenSpaceGuid.PcdPciBusHotplugDeviceSupport|TRUE|BOOLEAN|0x0001003d I've never checked how exactly that knob affects PciBusDxe, but it's TRUE in OVMF. Thanks Laszlo