From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jean Guyader Subject: [PATCH 5/6] hvmloader: Change memory relocation loop when overlap with PCI hole. Date: Fri, 4 Nov 2011 10:38:28 +0000 Message-ID: <1320403109-8739-6-git-send-email-jean.guyader@eu.citrix.com> References: <1320403109-8739-1-git-send-email-jean.guyader@eu.citrix.com> <1320403109-8739-2-git-send-email-jean.guyader@eu.citrix.com> <1320403109-8739-3-git-send-email-jean.guyader@eu.citrix.com> <1320403109-8739-4-git-send-email-jean.guyader@eu.citrix.com> <1320403109-8739-5-git-send-email-jean.guyader@eu.citrix.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------true" Return-path: In-Reply-To: <1320403109-8739-5-git-send-email-jean.guyader@eu.citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel@lists.xensource.com Cc: allen.m.kay@intel.com, tim@xen.org, Jean Guyader List-Id: xen-devel@lists.xenproject.org --------------true Content-Type: text/plain; charset="UTF-8"; format=fixed Content-Transfer-Encoding: 8bit Change the way we relocate the memory page if they overlap with pci hole. Use new map space (XENMAPSPACE_gmfn_range) to move the loop into xen. This code usually get triggered when a device is pass through to a guest and the PCI hole has to be extended to have enough room to map the device BARs. The PCI hole will starts lower and it might overlap with some RAM that has been alocated for the guest. That usually happen if the guest has more than 4G of RAM. We have to relocate those pages in high mem otherwise they won't be accessible. Signed-off-by: Jean Guyader --- tools/firmware/hvmloader/pci.c | 20 ++++++++++++++------ 1 files changed, 14 insertions(+), 6 deletions(-) --------------true Content-Type: text/x-patch; name="0005-hvmloader-Change-memory-relocation-loop-when-overlap.patch" Content-Transfer-Encoding: 8bit Content-Disposition: attachment; filename="0005-hvmloader-Change-memory-relocation-loop-when-overlap.patch" diff --git a/tools/firmware/hvmloader/pci.c b/tools/firmware/hvmloader/pci.c index 29ec011..fb451ef 100644 --- a/tools/firmware/hvmloader/pci.c +++ b/tools/firmware/hvmloader/pci.c @@ -185,17 +185,25 @@ void pci_setup(void) ((pci_mem_start << 1) != 0) ) pci_mem_start <<= 1; - while ( (pci_mem_start >> PAGE_SHIFT) < hvm_info->low_mem_pgend ) + if ((pci_mem_start >> PAGE_SHIFT) < hvm_info->low_mem_pgend) { struct xen_add_to_physmap xatp; - if ( hvm_info->high_mem_pgend == 0 ) - hvm_info->high_mem_pgend = 1ull << (32 - PAGE_SHIFT); + unsigned int size = hvm_info->low_mem_pgend - (pci_mem_start >> PAGE_SHIFT); xatp.domid = DOMID_SELF; - xatp.space = XENMAPSPACE_gmfn; - xatp.idx = --hvm_info->low_mem_pgend; - xatp.gpfn = hvm_info->high_mem_pgend++; + xatp.space = XENMAPSPACE_gmfn_range; + xatp.size = size; + xatp.idx = (pci_mem_start >> PAGE_SHIFT); + xatp.gpfn = hvm_info->high_mem_pgend; + + printf("Relocate page for pci hole:\n"); if ( hypercall_memory_op(XENMEM_add_to_physmap, &xatp) != 0 ) BUG(); + printf(" - low_mem_pgend: %x -> %lx\n" + " - high_mem_pgend: %x -> %x\n", + hvm_info->low_mem_pgend, (pci_mem_start >> PAGE_SHIFT), + hvm_info->high_mem_pgend, hvm_info->high_mem_pgend + size); + hvm_info->low_mem_pgend = pci_mem_start >> PAGE_SHIFT; + hvm_info->high_mem_pgend += size; } mem_resource.base = pci_mem_start; --------------true Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --------------true--