WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-ia64-devel

[Xen-ia64-devel] [patch] Handle MMIO EFI mappings outside the page table

To: xen-ia64-devel@xxxxxxxxxxxxxxxxxxx, Alex Williamson <alex.williamson@xxxxxx>
Subject: [Xen-ia64-devel] [patch] Handle MMIO EFI mappings outside the page table range
From: Jes Sorensen <jes@xxxxxxx>
Date: Thu, 01 Mar 2007 15:24:33 +0100
Delivery-date: Thu, 01 Mar 2007 06:23:44 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-ia64-devel-request@lists.xensource.com?subject=help>
List-id: Discussion of the ia64 port of Xen <xen-ia64-devel.lists.xensource.com>
List-post: <mailto:xen-ia64-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-ia64-devel>, <mailto:xen-ia64-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-ia64-devel>, <mailto:xen-ia64-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-ia64-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Thunderbird 1.5.0.4 (X11/20060527)
Hi,

On Altix IO ports are located at a physical address range which we
cannot map with the dom page tables and these needs to be remapped
down to a safe zone. This patch changes assign_domain_mmio_page() to be
able to handle it and catches the high ports - which I suspect are only
going to be seen on Altix.  I don't think this patch will have any
affect on non-SN2.

Cheers,
Jes
# HG changeset patch
# User jes@xxxxxxxxxxxxxxxx
# Date 1172758845 -3600
# Node ID d7568a1a2481b17542c7b0d0372a6e35bd4fba66
# Parent  7941568b1f894fb0e52f584550dd025a28fbcf1c
We cannot rely on MMIO pages presented in the EFI mem-map can be
mapped directly to the same meta-physical address, because of
restrictions on the address range imposed by the page tables.

As an example, IO ports are located at 0x1ffffffffc000000 on many SN2
systems.

Change assign_domain_mmio_page() to take a flags and a source and
destination address to handle this and catch IO ports above
0x1ffffffff0000000 and map them down to a safe area.

Signed-off-by: Jes Sorensen <jes@xxxxxxx>

diff -r 7941568b1f89 -r d7568a1a2481 xen/arch/ia64/xen/dom0_ops.c
--- a/xen/arch/ia64/xen/dom0_ops.c      Thu Mar 01 14:37:15 2007 +0100
+++ b/xen/arch/ia64/xen/dom0_ops.c      Thu Mar 01 15:20:45 2007 +0100
@@ -299,13 +299,17 @@ dom0vp_ioremap(struct domain *d, unsigne
     if (size == 0)
         size = PAGE_SIZE;
 
+    if (size == 0)
+        printk("ioremap(): Trying to map %lx, size 0\n", mpaddr);
+
     end = PAGE_ALIGN(mpaddr + size);
 
     if (!iomem_access_permitted(d, mpaddr >> PAGE_SHIFT,
                                 (end >> PAGE_SHIFT) - 1))
         return -EPERM;
 
-    return assign_domain_mmio_page(d, mpaddr, size);
+    return assign_domain_mmio_page(d, mpaddr, mpaddr, size,
+                                   ASSIGN_writable | ASSIGN_nocache);
 }
 
 unsigned long
diff -r 7941568b1f89 -r d7568a1a2481 xen/arch/ia64/xen/dom_fw.c
--- a/xen/arch/ia64/xen/dom_fw.c        Thu Mar 01 14:37:15 2007 +0100
+++ b/xen/arch/ia64/xen/dom_fw.c        Thu Mar 01 15:20:45 2007 +0100
@@ -534,6 +534,7 @@ complete_dom0_memmap(struct domain *d,
                u64 start = md->phys_addr;
                u64 size = md->num_pages << EFI_PAGE_SHIFT;
                u64 end = start + size;
+               u64 mpaddr;
                unsigned long flags;
 
                switch (md->type) {
@@ -566,10 +567,22 @@ complete_dom0_memmap(struct domain *d,
                        break;
 
                case EFI_MEMORY_MAPPED_IO_PORT_SPACE:
+                       flags = ASSIGN_writable;        /* dummy - zero */
+                       if (md->attribute & EFI_MEMORY_UC)
+                               flags |= ASSIGN_nocache;
+
+                       if (start > 0x1ffffffff0000000UL) {
+                               mpaddr = 0x4000000000000UL - size;
+                               printk("Remapping IO ports from %lx to lower "
+                                      "address %lx\n", start, mpaddr);
+                       } else
+                               mpaddr = start;
+
                        /* Map into dom0.  */
-                       assign_domain_mmio_page(d, start, size);
+                       assign_domain_mmio_page(d, mpaddr, start, size, flags);
                        /* Copy descriptor.  */
                        *dom_md = *md;
+                       dom_md->phys_addr = mpaddr;
                        dom_md->virt_addr = 0;
                        num_mds++;
                        break;
@@ -652,8 +665,12 @@ complete_dom0_memmap(struct domain *d,
                if (domain_page_mapped(d, addr))
                        continue;
                
-               if (efi_mmio(addr, PAGE_SIZE))
-                       assign_domain_mmio_page(d, addr, PAGE_SIZE);
+               if (efi_mmio(addr, PAGE_SIZE)) {
+                       unsigned long flags;
+                       flags = ASSIGN_writable | ASSIGN_nocache;
+                       assign_domain_mmio_page(d, addr, addr,
+                                               PAGE_SIZE, flags);
+               }
        }
        return num_mds;
 }
diff -r 7941568b1f89 -r d7568a1a2481 xen/arch/ia64/xen/mm.c
--- a/xen/arch/ia64/xen/mm.c    Thu Mar 01 14:37:15 2007 +0100
+++ b/xen/arch/ia64/xen/mm.c    Thu Mar 01 15:20:45 2007 +0100
@@ -1044,9 +1044,11 @@ efi_mmio(unsigned long physaddr, unsigne
 }
 
 unsigned long
-assign_domain_mmio_page(struct domain *d,
-                        unsigned long mpaddr, unsigned long size)
-{
+assign_domain_mmio_page(struct domain *d, unsigned long mpaddr,
+                        unsigned long phys_addr, unsigned long size,
+                        unsigned long flags)
+{
+    unsigned long end = PAGE_ALIGN(mpaddr + size);
     if (size == 0) {
         gdprintk(XENLOG_INFO, "%s: domain %p mpaddr 0x%lx size = 0x%lx\n",
                 __func__, d, mpaddr, size);
@@ -1058,7 +1060,12 @@ assign_domain_mmio_page(struct domain *d
 #endif
         return -EINVAL;
     }
-    assign_domain_same_page(d, mpaddr, size, ASSIGN_writable | ASSIGN_nocache);
+
+    for (mpaddr &= PAGE_MASK; mpaddr < end;
+         mpaddr += PAGE_SIZE, phys_addr += PAGE_SIZE) {
+        __assign_domain_page(d, mpaddr, phys_addr, flags);
+    }
+
     return mpaddr;
 }
 
diff -r 7941568b1f89 -r d7568a1a2481 xen/include/asm-ia64/mm.h
--- a/xen/include/asm-ia64/mm.h Thu Mar 01 14:37:15 2007 +0100
+++ b/xen/include/asm-ia64/mm.h Thu Mar 01 15:20:45 2007 +0100
@@ -433,7 +433,7 @@ extern unsigned long lookup_domain_mpa(s
 extern unsigned long lookup_domain_mpa(struct domain *d, unsigned long mpaddr, 
struct p2m_entry* entry);
 extern void *domain_mpa_to_imva(struct domain *d, unsigned long mpaddr);
 extern volatile pte_t *lookup_noalloc_domain_pte(struct domain* d, unsigned 
long mpaddr);
-extern unsigned long assign_domain_mmio_page(struct domain *d, unsigned long 
mpaddr, unsigned long size);
+extern unsigned long assign_domain_mmio_page(struct domain *d, unsigned long 
mpaddr, unsigned long phys_addr, unsigned long size, unsigned long flags);
 extern unsigned long assign_domain_mach_page(struct domain *d, unsigned long 
mpaddr, unsigned long size, unsigned long flags);
 int domain_page_mapped(struct domain *d, unsigned long mpaddr);
 int efi_mmio(unsigned long physaddr, unsigned long size);
_______________________________________________
Xen-ia64-devel mailing list
Xen-ia64-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-ia64-devel
<Prev in Thread] Current Thread [Next in Thread>