From patchwork Sun May 15 19:23:32 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcel Apfelbaum X-Patchwork-Id: 9096781 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 845A59F1C1 for ; Sun, 15 May 2016 19:23:56 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id F1809201F5 for ; Sun, 15 May 2016 19:23:55 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4884A20172 for ; Sun, 15 May 2016 19:23:55 +0000 (UTC) Received: from localhost ([::1]:41183 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b21dq-00054s-GL for patchwork-qemu-devel@patchwork.kernel.org; Sun, 15 May 2016 15:23:54 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33947) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b21df-00050R-Ue for qemu-devel@nongnu.org; Sun, 15 May 2016 15:23:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b21de-0003dF-W9 for qemu-devel@nongnu.org; Sun, 15 May 2016 15:23:43 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53153) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b21de-0003dB-Qo for qemu-devel@nongnu.org; Sun, 15 May 2016 15:23:42 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (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 4254510B83B for ; Sun, 15 May 2016 19:23:42 +0000 (UTC) Received: from work.redhat.com (vpn-203-81.tlv.redhat.com [10.35.203.81]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u4FJNYMT019754; Sun, 15 May 2016 15:23:39 -0400 From: Marcel Apfelbaum To: qemu-devel@nongnu.org Date: Sun, 15 May 2016 22:23:32 +0300 Message-Id: <1463340214-8721-3-git-send-email-marcel@redhat.com> In-Reply-To: <1463340214-8721-1-git-send-email-marcel@redhat.com> References: <1463340214-8721-1-git-send-email-marcel@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Sun, 15 May 2016 19:23:42 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH V2 2/4] pci: reserve 64 bit MMIO range for PCI hotplug X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: marcel@redhat.com, imammedo@redhat.com, lersek@redhat.com, ehabkost@redhat.com, mst@redhat.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Using the firmware assigned MMIO ranges for 64-bit PCI window leads to zero space for hot-plugging PCI devices over 4G. PC machines can use the whole CPU addressable range after the space reserved for memory-hotplug. Signed-off-by: Marcel Apfelbaum --- hw/pci/pci.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/hw/pci/pci.c b/hw/pci/pci.c index bb605ef..44dd949 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -41,6 +41,7 @@ #include "hw/hotplug.h" #include "hw/boards.h" #include "qemu/cutils.h" +#include "hw/i386/pc.h" //#define DEBUG_PCI #ifdef DEBUG_PCI @@ -2467,8 +2468,19 @@ static void pci_dev_get_w64(PCIBus *b, PCIDevice *dev, void *opaque) void pci_bus_get_w64_range(PCIBus *bus, Range *range) { - range->begin = range->end = 0; - pci_for_each_device_under_bus(bus, pci_dev_get_w64, range); + Object *machine = qdev_get_machine(); + if (object_dynamic_cast(machine, TYPE_PC_MACHINE)) { + PCMachineState *pcms = PC_MACHINE(machine); + range->begin = pc_machine_get_reserved_memory_end(pcms); + if (!range->begin) { + range->begin = ROUND_UP(0x100000000ULL + pcms->above_4g_mem_size, + 1ULL << 30); + } + range->end = 1ULL << 40; /* 40 bits physical */ + } else { + range->begin = range->end = 0; + pci_for_each_device_under_bus(bus, pci_dev_get_w64, range); + } } static bool pcie_has_upstream_port(PCIDevice *dev)