From patchwork Thu Jan 7 09:11:16 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Zhao X-Patchwork-Id: 7974961 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id AF6D0BEEE5 for ; Thu, 7 Jan 2016 09:14:22 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id DB83120172 for ; Thu, 7 Jan 2016 09:14:21 +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 E9C2C20149 for ; Thu, 7 Jan 2016 09:14:20 +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 1aH6cW-0005SF-5q; Thu, 07 Jan 2016 09:12:36 +0000 Received: from szxga02-in.huawei.com ([119.145.14.65]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aH6cR-00054b-Ph for linux-arm-kernel@lists.infradead.org; Thu, 07 Jan 2016 09:12:33 +0000 Received: from 172.24.1.50 (EHLO szxeml431-hub.china.huawei.com) ([172.24.1.50]) by szxrg02-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id CZL52624; Thu, 07 Jan 2016 17:11:30 +0800 (CST) Received: from [127.0.0.1] (10.177.16.142) by szxeml431-hub.china.huawei.com (10.82.67.208) with Microsoft SMTP Server id 14.3.235.1; Thu, 7 Jan 2016 17:11:19 +0800 Message-ID: <568E2BB4.8080802@huawei.com> Date: Thu, 7 Jan 2016 17:11:16 +0800 From: Shannon Zhao User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:24.0) Gecko/20100101 Thunderbird/24.4.0 MIME-Version: 1.0 To: Jan Beulich , Subject: Re: [PATCH v3 59/62] xen/arm: Add a hypercall for device mmio mapping References: <1447753261-7552-1-git-send-email-shannon.zhao@linaro.org> <1447753261-7552-60-git-send-email-shannon.zhao@linaro.org> <564B17EA02000078000B5D34@prv-mh.provo.novell.com> <568E0CA9.4090307@huawei.com> <568E25A702000078000C43EA@prv-mh.provo.novell.com> In-Reply-To: <568E25A702000078000C43EA@prv-mh.provo.novell.com> X-Originating-IP: [10.177.16.142] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A090205.568E2BC5.002F, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0, ip=0.0.0.0, so=2013-06-18 04:22:30, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 1102b23f44c1b906eadb2fd898bbc26e X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160107_011232_218417_093D8DDA X-CRM114-Status: GOOD ( 14.61 ) X-Spam-Score: -4.2 (----) 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: ian.campbell@citrix.com, peter.huangpeng@huawei.com, xen-devel@lists.xen.org, julien.grall@citrix.com, stefano.stabellini@citrix.com, linux-arm-kernel@lists.infradead.org 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.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, 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 Hi Jan, On 2016/1/7 15:45, Jan Beulich wrote: >>>> On 07.01.16 at 07:58, wrote: >> > On 2015/11/17 19:04, Jan Beulich wrote: >>>>>> >>>>> On 17.11.15 at 10:40, wrote: >>>>> >>> > --- 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; >>> >> Blindly for any kind of domain? The XSM check in the >>> >> XENMEM_add_to_physmap_batch handler (in common code) doesn't >>> >> even know which map space is to be used... >> > >> > Sorry, I know little about XSM. Could you suggest me how to add the >> > check for this new type here? > I'm sorry to push back here, but did you at least try to derive > what is wanted from the multitude of other XSM checks present > throughout the tree? IIUC, you mean that it doean't need to change the XSM check itself, but we should check if the current->domain is hardware domain and it maps the space to itself before the XSM check, right? If so, how about below patch on top of this patch? rc = xsm_add_to_physmap(XSM_TARGET, current->domain, d); if ( rc ) { @@ -1024,6 +1031,13 @@ long do_memory_op(unsigned long cmd, XEN_GUEST_HANDLE_PARAM(void) arg) if ( d == NULL ) return -ESRCH; + /* Device MMIO mapping is only supported for Domain0 to map these ranges + * to itself + */ + if ( (xatpb.space == XENMAPSPACE_dev_mmio) && + (!is_hardware_domain(current->domain) || (d != current->domain)) ) + return -EOPNOTSUPP; + rc = xsm_add_to_physmap(XSM_TARGET, current->domain, d); if ( rc ) { Thanks, diff --git a/xen/common/memory.c b/xen/common/memory.c index 9ff1145..33feb2d 100644 --- a/xen/common/memory.c +++ b/xen/common/memory.c @@ -980,6 +980,13 @@ long do_memory_op(unsigned long cmd, XEN_GUEST_HANDLE_PARAM(void) arg) if ( d == NULL ) return -ESRCH; + /* Device MMIO mapping is only supported for Domain0 to map these ranges + * to itself + */ + if ( (xatp.space == XENMAPSPACE_dev_mmio) && + (!is_hardware_domain(current->domain) || (d != current->domain)) ) + return -EOPNOTSUPP; +