From patchwork Sun Oct 13 12:13:44 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Mammedov X-Patchwork-Id: 283085 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 9A5622C033C for ; Sun, 13 Oct 2013 23:14:20 +1100 (EST) Received: from localhost ([::1]:32993 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VVKYq-0001JO-Fb for incoming@patchwork.ozlabs.org; Sun, 13 Oct 2013 08:14:16 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51536) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VVKYW-0001Iu-L3 for qemu-devel@nongnu.org; Sun, 13 Oct 2013 08:14:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VVKYQ-0000DP-Lf for qemu-devel@nongnu.org; Sun, 13 Oct 2013 08:13:56 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42073) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VVKYQ-0000DD-Dc for qemu-devel@nongnu.org; Sun, 13 Oct 2013 08:13:50 -0400 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r9DCDlhD005307 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sun, 13 Oct 2013 08:13:47 -0400 Received: from thinkpad.redhat.com (vpn-239-246.phx2.redhat.com [10.3.239.246]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r9DCDirL022600; Sun, 13 Oct 2013 08:13:45 -0400 From: Igor Mammedov To: seabios@seabios.org Date: Sun, 13 Oct 2013 14:13:44 +0200 Message-Id: <1381666424-25250-1-git-send-email-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.25 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: pbonzini@redhat.com, kevin@koconnor.net, mst@redhat.com, kraxel@redhat.com, qemu-devel@nongnu.org Subject: [Qemu-devel] [PATCH v2] map 64-bit PCI BARs at location provided by emulator X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Currently 64-bit PCI BARs are unconditionally mapped by BIOS right over 4G + RamSizeOver4G location, which doesn't allow to reserve extra space before 64-bit PCI window. For memory hotplug an extra RAM space might be reserved after present 64-bit RAM end and BIOS should map 64-bit PCI BARs after it. Introduce "etc/pcimem64-start" romfile to provide BIOS a hint where it should start mapping of 64-bit PCI BARs. If romfile is missing, BIOS reverts to legacy behavior and starts mapping right after high memory. Signed-off-by: Igor Mammedov --- v2: * place 64-bit window behind high RAM end if "etc/pcimem64-start" points below it. --- src/fw/pciinit.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/fw/pciinit.c b/src/fw/pciinit.c index b29db99..798309b 100644 --- a/src/fw/pciinit.c +++ b/src/fw/pciinit.c @@ -18,6 +18,8 @@ #include "paravirt.h" // RamSize #include "string.h" // memset #include "util.h" // pci_setup +#include "byteorder.h" // le64_to_cpu +#include "romfile.h" // romfile_loadint #define PCI_DEVICE_MEM_MIN 0x1000 #define PCI_BRIDGE_IO_MIN 0x1000 @@ -764,6 +766,15 @@ static void pci_bios_map_devices(struct pci_bus *busses) { if (pci_bios_init_root_regions(busses)) { struct pci_region r64_mem, r64_pref; + u64 ram64_end = 0x100000000ULL + RamSizeOver4G; + u64 base64 = le64_to_cpu(romfile_loadint("etc/pcimem64-start", + ram64_end)); + if (base64 < ram64_end) { + dprintf(1, "ignorig etc/pcimem64-start [0x%llx] below present RAM, " + "placing 64-bit PCI window behind RAM end: %llx", + base64, ram64_end); + base64 = ram64_end; + } r64_mem.list.first = NULL; r64_pref.list.first = NULL; pci_region_migrate_64bit_entries(&busses[0].r[PCI_REGION_TYPE_MEM], @@ -779,7 +790,7 @@ static void pci_bios_map_devices(struct pci_bus *busses) u64 align_mem = pci_region_align(&r64_mem); u64 align_pref = pci_region_align(&r64_pref); - r64_mem.base = ALIGN(0x100000000LL + RamSizeOver4G, align_mem); + r64_mem.base = ALIGN(base64, align_mem); r64_pref.base = ALIGN(r64_mem.base + sum_mem, align_pref); pcimem64_start = r64_mem.base; pcimem64_end = r64_pref.base + sum_pref;