[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH v2 32/41] arm : acpi dynamically map mmio regions



In ACPI mmio regions are described in DSDT which requires
AML interpreter. Defer the mapping of mmio until DSDT is parsed in
DOM0 and map mmio's dynamically at the time of request.

Signed-off-by: Parth Dixit <parth.dixit@xxxxxxxxxx>
---
 xen/arch/arm/traps.c | 51 ++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 50 insertions(+), 1 deletion(-)

diff --git a/xen/arch/arm/traps.c b/xen/arch/arm/traps.c
index 47d6cef..6b8d247 100644
--- a/xen/arch/arm/traps.c
+++ b/xen/arch/arm/traps.c
@@ -31,6 +31,7 @@
 #include <xen/softirq.h>
 #include <xen/domain_page.h>
 #include <xen/perfc.h>
+#include <xen/acpi.h>
 #include <public/sched.h>
 #include <public/xen.h>
 #include <asm/debugger.h>
@@ -46,6 +47,7 @@
 #include "vtimer.h"
 #include <asm/gic.h>
 #include <asm/vgic.h>
+#include <xen/iocap.h>
 
 /* The base of the stack must always be double-word aligned, which means
  * that both the kernel half of struct cpu_user_regs (which is pushed in
@@ -2336,6 +2338,47 @@ bad_insn_abort:
     inject_iabt_exception(regs, gva, hsr.len);
 }
 
+#ifdef CONFIG_ACPI
+static int map_mmio_dsdt(struct cpu_user_regs *regs,
+                         mmio_info_t *info)
+{
+    int res;
+    u64 addr,size;
+    struct domain* d = current->domain;
+
+    if ( !is_hardware_domain(d) )
+        return 0;
+
+    addr = info->gpa;
+    size = PAGE_SIZE;
+
+    res = iomem_permit_access(d, paddr_to_pfn(addr & PAGE_MASK),
+                              paddr_to_pfn(PAGE_ALIGN(addr + size - 1)));
+    if ( res )
+    {
+        printk(XENLOG_ERR "Unable to permit to dom%d access to"
+               " 0x%"PRIx64" - 0x%"PRIx64"\n",
+               d->domain_id,
+               addr & PAGE_MASK, PAGE_ALIGN(addr + size) - 1);
+        return 0;
+    }
+    res = map_mmio_regions(d,
+                           paddr_to_pfn(addr & PAGE_MASK),
+                           DIV_ROUND_UP(size, PAGE_SIZE),
+                           paddr_to_pfn(addr & PAGE_MASK));
+    if ( res )
+    {
+        printk(XENLOG_ERR "Unable to map 0x%"PRIx64
+               " - 0x%"PRIx64" in domain %d\n",
+               addr & PAGE_MASK, PAGE_ALIGN(addr + size) - 1,
+               d->domain_id);
+        return 0;
+    }
+
+    return 1;
+}
+#endif
+
 static void do_trap_data_abort_guest(struct cpu_user_regs *regs,
                                      const union hsr hsr)
 {
@@ -2411,7 +2454,13 @@ static void do_trap_data_abort_guest(struct 
cpu_user_regs *regs,
         advance_pc(regs, hsr);
         return;
     }
-
+#ifdef CONFIG_ACPI
+    if( !acpi_disabled )
+    {
+        if( map_mmio_dsdt(regs, &info) )
+            return;
+    }
+#endif
 bad_data_abort:
     inject_dabt_exception(regs, info.gva, hsr.len);
 }
-- 
1.9.1


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.