From mboxrd@z Thu Jan 1 00:00:00 1970 From: Parth Dixit Subject: [PATCH v2 32/41] arm : acpi dynamically map mmio regions Date: Mon, 18 May 2015 01:33:59 +0530 Message-ID: <1431893048-5214-33-git-send-email-parth.dixit@linaro.org> References: <1431893048-5214-1-git-send-email-parth.dixit@linaro.org> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1431893048-5214-1-git-send-email-parth.dixit@linaro.org> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel@lists.xen.org Cc: keir@xen.org, ian.campbell@citrix.com, andrew.cooper3@citrix.com, tim@xen.org, julien.grall@citrix.com, stefano.stabellini@citrix.com, jbeulich@suse.com, parth.dixit@linaro.org, christoffer.dall@linaro.org List-Id: xen-devel@lists.xenproject.org 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 --- 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 #include #include +#include #include #include #include @@ -46,6 +47,7 @@ #include "vtimer.h" #include #include +#include /* 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