From patchwork Tue Nov 17 09:40:58 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Zhao X-Patchwork-Id: 56757 Delivered-To: patch@linaro.org Received: by 10.112.155.196 with SMTP id vy4csp1828295lbb; Tue, 17 Nov 2015 01:50:56 -0800 (PST) X-Received: by 10.31.152.83 with SMTP id a80mr2523433vke.137.1447753855801; Tue, 17 Nov 2015 01:50:55 -0800 (PST) Return-Path: Received: from lists.xen.org (lists.xenproject.org. [50.57.142.19]) by mx.google.com with ESMTPS id 78si2034984vkq.135.2015.11.17.01.50.55 (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 17 Nov 2015 01:50:55 -0800 (PST) Received-SPF: neutral (google.com: 50.57.142.19 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) client-ip=50.57.142.19; Authentication-Results: mx.google.com; spf=neutral (google.com: 50.57.142.19 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) smtp.mailfrom=xen-devel-bounces@lists.xen.org; dkim=neutral (body hash did not verify) header.i=@linaro-org.20150623.gappssmtp.com Received: from localhost ([127.0.0.1] helo=lists.xen.org) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1ZyctN-0000QP-WA; Tue, 17 Nov 2015 09:49:38 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1ZyctL-0000NO-MM for xen-devel@lists.xen.org; Tue, 17 Nov 2015 09:49:35 +0000 Received: from [85.158.137.68] by server-3.bemta-3.messagelabs.com id AE/4F-01753-E28FA465; Tue, 17 Nov 2015 09:49:34 +0000 X-Env-Sender: shannon.zhao@linaro.org X-Msg-Ref: server-14.tower-31.messagelabs.com!1447753774!4264615!1 X-Originating-IP: [74.125.82.44] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 7.19.2; banners=-,-,- X-VirusChecked: Checked Received: (qmail 58487 invoked from network); 17 Nov 2015 09:49:34 -0000 Received: from mail-wm0-f44.google.com (HELO mail-wm0-f44.google.com) (74.125.82.44) by server-14.tower-31.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 17 Nov 2015 09:49:34 -0000 Received: by wmvv187 with SMTP id v187so218021796wmv.1 for ; Tue, 17 Nov 2015 01:49:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=4Xkd8tJaovNCLMkpY7jEl62XrkP4MfoQ4fyQTTAEFi4=; b=QaoOVtebYiUAFXrXEqRWJgWsv3ziPzzzqkHA7n0R3c5ZuXdbyFoxX93eadBMHnAOUr FwW4p257NyEvOCk6hnaKeSx/BCBH+tM75H6r/oLF3mKhORmO/uzGWW/B69XRb+IgbRP5 lEybiokJCh6iIAUudjhjiWnUDU/nUzK6Aw+2/5JE6v4fliSPj5Z2hZVZo6ONoSkVv6DK mjr3qXhghnCav+ctw45IHB0pk5vNVltGEoNRsCArCgpr5bheI34UUtynYfr0oluQFIA4 RbQQyOj6n5+c3AUiVZQ6HqtFhogH1h6HuEN8mKYgJ/imy1RR+YNDA6ivnoo4kR5+Vp3u qoBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=4Xkd8tJaovNCLMkpY7jEl62XrkP4MfoQ4fyQTTAEFi4=; b=LXoqppx9n6KXW3QMyVXNYxNqySjExv/oXF1QNCAnfJ0ZFePLXESG25R0D8DADEINxR VSiYutDCOKqCYubFpzCKZwW0rsVgxM/YMJiCy+LJs841zKnIlrIiCZp15Hf48Uj//Z5J XeLj6jwW93iXImlxjsBmG6u15EtgSTct+Xlnniu47Z64VbSc3P8plMDlcLiFcy6hgpRs 2f/ruQkhW77SfEL/5WMNqfqHYYgFW/26LYRWwCTv7Vw9qjjwJvZJNuPxtegEiaiUebJ5 67mxTUsIBDiP5mDvkDSbobJE7pytCGHT2gaPsBxO6dZ8P+N54DtX6z6HGp6YQdBHxuEA RODw== X-Gm-Message-State: ALoCoQkNWeD5a9R6NduFyVx0XZfkYX/rBKZpnokMUZzwK6NmB/J34lN2KxRYcXEVs5FexB+p55Y7 X-Received: by 10.28.47.8 with SMTP id v8mr1546231wmv.30.1447753774321; Tue, 17 Nov 2015 01:49:34 -0800 (PST) Received: from localhost ([78.129.251.54]) by smtp.gmail.com with ESMTPSA id l1sm39029011wjx.13.2015.11.17.01.49.31 (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 17 Nov 2015 01:49:33 -0800 (PST) From: shannon.zhao@linaro.org To: ian.campbell@citrix.com, stefano.stabellini@citrix.com, keir@xen.org, jbeulich@suse.com, andrew.cooper3@citrix.com, julien.grall@citrix.com, xen-devel@lists.xen.org Date: Tue, 17 Nov 2015 17:40:58 +0800 Message-Id: <1447753261-7552-60-git-send-email-shannon.zhao@linaro.org> X-Mailer: git-send-email 1.9.5.msysgit.1 In-Reply-To: <1447753261-7552-1-git-send-email-shannon.zhao@linaro.org> References: <1447753261-7552-1-git-send-email-shannon.zhao@linaro.org> Cc: mark.rutland@arm.com, hangaohuai@huawei.com, ard.biesheuvel@linaro.org, shannon.zhao@linaro.org, christoffer.dall@linaro.org, peter.huangpeng@huawei.com, david.vrabel@citrix.com, zhaoshenglong@huawei.com, linux-arm-kernel@lists.infradead.org, roger.pau@citrix.com Subject: [Xen-devel] [PATCH v3 59/62] xen/arm: Add a hypercall for device mmio mapping X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org From: Shannon Zhao It needs to map platform or amba device mmio to Dom0 on ARM. But when booting with ACPI, it can't get the mmio region in Xen due to lack of AML interpreter to parse DSDT table. Therefore, let Dom0 call a hypercall to map mmio region when it adds the devices. Signed-off-by: Shannon Zhao --- xen/arch/arm/mm.c | 4 ++++ xen/arch/arm/p2m.c | 34 ++++++++++++++++++++++++++++++++++ xen/include/asm-arm/p2m.h | 5 +++++ xen/include/public/memory.h | 1 + 4 files changed, 44 insertions(+) -- 2.1.0 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c index 8b6d915..fbe0406 100644 --- a/xen/arch/arm/mm.c +++ b/xen/arch/arm/mm.c @@ -1138,6 +1138,10 @@ int xenmem_add_to_physmap_one( rcu_unlock_domain(od); break; } + case XENMAPSPACE_dev_mmio: + rc = map_dev_mmio_region(d, gpfn, 1, idx); + return rc; + break; default: return -ENOSYS; diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c index 7a108d8..b44ad76 100644 --- a/xen/arch/arm/p2m.c +++ b/xen/arch/arm/p2m.c @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include @@ -1192,6 +1193,39 @@ int unmap_mmio_regions(struct domain *d, d->arch.p2m.default_access); } +int map_dev_mmio_region(struct domain *d, + unsigned long start_gfn, + unsigned long nr, + unsigned long mfn) +{ + int res; + + if(!iomem_access_permitted(d, start_gfn, start_gfn + nr)) + return 0; + + res = iomem_permit_access(d, start_gfn, (start_gfn + nr)); + if ( res ) + { + printk(XENLOG_ERR "Unable to permit to dom%d access to" + " 0x%"PRIx64" - 0x%"PRIx64"\n", + d->domain_id, + start_gfn << PAGE_SHIFT, (start_gfn + nr) << PAGE_SHIFT); + return res; + } + + res = map_mmio_regions(d, start_gfn, nr, mfn); + if ( res < 0 ) + { + printk(XENLOG_ERR "Unable to map 0x%"PRIx64 + " - 0x%"PRIx64" in domain %d\n", + start_gfn << PAGE_SHIFT, (start_gfn + nr) << PAGE_SHIFT, + d->domain_id); + return res; + } + + return 0; +} + int guest_physmap_add_entry(struct domain *d, unsigned long gpfn, unsigned long mfn, diff --git a/xen/include/asm-arm/p2m.h b/xen/include/asm-arm/p2m.h index b6215f9..5e9d0a1 100644 --- a/xen/include/asm-arm/p2m.h +++ b/xen/include/asm-arm/p2m.h @@ -168,6 +168,11 @@ int unmap_regions(struct domain *d, unsigned long nr_mfns, unsigned long mfn); +int map_dev_mmio_region(struct domain *d, + unsigned long start_gfn, + unsigned long nr, + unsigned long mfn); + int guest_physmap_add_entry(struct domain *d, unsigned long gfn, unsigned long mfn, diff --git a/xen/include/public/memory.h b/xen/include/public/memory.h index 4df38d6..c19da1a 100644 --- a/xen/include/public/memory.h +++ b/xen/include/public/memory.h @@ -220,6 +220,7 @@ DEFINE_XEN_GUEST_HANDLE(xen_machphys_mapping_t); #define XENMAPSPACE_gmfn_range 3 /* GMFN range, XENMEM_add_to_physmap only. */ #define XENMAPSPACE_gmfn_foreign 4 /* GMFN from another dom, * XENMEM_add_to_physmap_batch only. */ +#define XENMAPSPACE_dev_mmio 5 /* device mmio region */ /* ` } */ /*