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: 7635071 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id B6E619F2EC for ; Tue, 17 Nov 2015 10:12:48 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C7F4E204D6 for ; Tue, 17 Nov 2015 10:12:47 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E4A9520411 for ; Tue, 17 Nov 2015 10:12:46 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZydDc-0004xh-Sd; Tue, 17 Nov 2015 10:10:32 +0000 Received: from mail-wm0-x22d.google.com ([2a00:1450:400c:c09::22d]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Zycta-0004Wj-VR for linux-arm-kernel@lists.infradead.org; Tue, 17 Nov 2015 09:50:07 +0000 Received: by wmec201 with SMTP id c201so218176405wme.0 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=Wf/KRB0PH1kTHYs7eWdWIy4snMZODDk+XpNloZJW0hTu8ahj8qNZaLXoXBufUVqBg9 UgZLjuKH7owFA3iwdCr8NtNJ0GZi99coDvSUWfivxzQZkYCu49K6kmLTsN7PYjqUpo3N 97FbsSDQ7y9iY1NCpORoR40LsIQ8eGNkH44K6iXM+m8T46mq7T86OQGiEbgR48AIE0U+ 9/VHxcIZ56dG/hIqK+aqIo2BCbpGOSo47k/Plbe56hARKklQx8JZAFczvexV0t+I6/yh KCp04yr0T8kN3QLuYYLeJGGSvlGgjSk26yveJlnF5DC8p2xWgqyh4HqCiUt/D62iRFc7 5j5A== X-Gm-Message-State: ALoCoQn+MBgfMlRcjUhEB2J5K40uXnfn5Osx/v6eAvZuTXgqFbSxUAeZE8BBSiLlFM4YmyqDCyz3 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 Subject: [PATCH v3 59/62] xen/arm: Add a hypercall for device mmio mapping 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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20151117_014951_660142_82558D5B X-CRM114-Status: GOOD ( 13.42 ) X-Spam-Score: -2.6 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , 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 MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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(+) 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 */ /* ` } */ /*