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: 7975041 Return-Path: X-Original-To: patchwork-xen-devel@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 00D3C9F38D for ; Thu, 7 Jan 2016 09:15:16 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1EF27201F4 for ; Thu, 7 Jan 2016 09:15:15 +0000 (UTC) Received: from lists.xen.org (lists.xenproject.org [50.57.142.19]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3CB3B2021A for ; Thu, 7 Jan 2016 09:15:14 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xen.org) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aH6bq-0001ZG-Bl; Thu, 07 Jan 2016 09:11:54 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aH6bo-0001ZB-Nl for xen-devel@lists.xen.org; Thu, 07 Jan 2016 09:11:52 +0000 Received: from [85.158.139.211] by server-13.bemta-5.messagelabs.com id 57/F9-06091-7DB2E865; Thu, 07 Jan 2016 09:11:51 +0000 X-Env-Sender: zhaoshenglong@huawei.com X-Msg-Ref: server-15.tower-206.messagelabs.com!1452157898!14127034!1 X-Originating-IP: [119.145.14.65] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogMTE5LjE0NS4xNC42NSA9PiA3NzQ2Mw==\n X-StarScan-Received: X-StarScan-Version: 7.35.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 14587 invoked from network); 7 Jan 2016 09:11:45 -0000 Received: from szxga02-in.huawei.com (HELO szxga02-in.huawei.com) (119.145.14.65) by server-15.tower-206.messagelabs.com with RC4-SHA encrypted SMTP; 7 Jan 2016 09:11:45 -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 , 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 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 Subject: Re: [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: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, 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; +