From patchwork Wed Dec 19 08:47:01 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Hao, Xudong" X-Patchwork-Id: 1894961 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 3D456DFE82 for ; Wed, 19 Dec 2012 08:41:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753363Ab2LSIlB (ORCPT ); Wed, 19 Dec 2012 03:41:01 -0500 Received: from mga14.intel.com ([143.182.124.37]:22437 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752273Ab2LSIlA (ORCPT ); Wed, 19 Dec 2012 03:41:00 -0500 Received: from azsmga001.ch.intel.com ([10.2.17.19]) by azsmga102.ch.intel.com with ESMTP; 19 Dec 2012 00:40:59 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.84,313,1355126400"; d="scan'208";a="233752481" Received: from xhao-dev.sh.intel.com (HELO localhost.localdomain) ([10.239.48.48]) by azsmga001.ch.intel.com with ESMTP; 19 Dec 2012 00:40:57 -0800 From: Xudong Hao To: qemu-devel@nongnu.org Cc: mtosatti@redhat.com, gleb@redhat.com, kvm@vger.kernel.org, Xudong Hao Subject: [PATCH v2] qemu-kvm/pci-assign: 64 bits bar emulation Date: Wed, 19 Dec 2012 16:47:01 +0800 Message-Id: <1355906821-22928-1-git-send-email-xudong.hao@intel.com> X-Mailer: git-send-email 1.5.5 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Enable 64 bits bar emulation. v2 changes from v1: - Change 0lx% to 0x%016 when print a 64 bit variable. Test pass with the current seabios which already support 64bit pci bars. Signed-off-by: Xudong Hao --- hw/kvm/pci-assign.c | 22 ++++++++++++++-------- 1 files changed, 14 insertions(+), 8 deletions(-) diff --git a/hw/kvm/pci-assign.c b/hw/kvm/pci-assign.c index 7a0998c..fb58ca9 100644 --- a/hw/kvm/pci-assign.c +++ b/hw/kvm/pci-assign.c @@ -46,6 +46,7 @@ #define IORESOURCE_IRQ 0x00000400 #define IORESOURCE_DMA 0x00000800 #define IORESOURCE_PREFETCH 0x00002000 /* No side effects */ +#define IORESOURCE_MEM_64 0x00100000 //#define DEVICE_ASSIGNMENT_DEBUG @@ -442,9 +443,13 @@ static int assigned_dev_register_regions(PCIRegion *io_regions, /* handle memory io regions */ if (cur_region->type & IORESOURCE_MEM) { - int t = cur_region->type & IORESOURCE_PREFETCH - ? PCI_BASE_ADDRESS_MEM_PREFETCH - : PCI_BASE_ADDRESS_SPACE_MEMORY; + int t = PCI_BASE_ADDRESS_SPACE_MEMORY; + if (cur_region->type & IORESOURCE_PREFETCH) { + t |= PCI_BASE_ADDRESS_MEM_PREFETCH; + } + if (cur_region->type & IORESOURCE_MEM_64) { + t |= PCI_BASE_ADDRESS_MEM_TYPE_64; + } /* map physical memory */ pci_dev->v_addrs[i].u.r_virtbase = mmap(NULL, cur_region->size, @@ -468,10 +473,10 @@ static int assigned_dev_register_regions(PCIRegion *io_regions, (cur_region->base_addr & 0xFFF); if (cur_region->size & 0xFFF) { - error_report("PCI region %d at address 0x%" PRIx64 " has " - "size 0x%" PRIx64 ", which is not a multiple of " - "4K. You might experience some performance hit " - "due to that.", + error_report("PCI region %d at address 0x%016" PRIx64 " has " + "size 0x%016" PRIx64 ", which is not a multiple " + "of 4K. You might experience some performance " + "hit due to that.", i, cur_region->base_addr, cur_region->size); memory_region_init_io(&pci_dev->v_addrs[i].real_iomem, &slow_bar_ops, &pci_dev->v_addrs[i], @@ -632,7 +637,8 @@ again: rp->valid = 0; rp->resource_fd = -1; size = end - start + 1; - flags &= IORESOURCE_IO | IORESOURCE_MEM | IORESOURCE_PREFETCH; + flags &= IORESOURCE_IO | IORESOURCE_MEM | IORESOURCE_PREFETCH + | IORESOURCE_MEM_64; if (size == 0 || (flags & ~IORESOURCE_PREFETCH) == 0) { continue; }