From patchwork Tue Jun 14 11:50:26 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 69987 Delivered-To: patch@linaro.org Received: by 10.140.106.246 with SMTP id e109csp2003807qgf; Tue, 14 Jun 2016 04:52:03 -0700 (PDT) X-Received: by 10.55.17.84 with SMTP id b81mr19351851qkh.104.1465905123171; Tue, 14 Jun 2016 04:52:03 -0700 (PDT) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id w92si5671950qgd.60.2016.06.14.04.52.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 14 Jun 2016 04:52:03 -0700 (PDT) Received-SPF: neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) client-ip=192.237.175.120; Authentication-Results: mx.google.com; spf=neutral (google.com: 192.237.175.120 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 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bCmrc-0003us-VV; Tue, 14 Jun 2016 11:50:36 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bCmrc-0003um-4A for xen-devel@lists.xen.org; Tue, 14 Jun 2016 11:50:36 +0000 Received: from [85.158.137.68] by server-4.bemta-3.messagelabs.com id 75/7E-18304-B8FEF575; Tue, 14 Jun 2016 11:50:35 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrHLMWRWlGSWpSXmKPExsVysyfVTbfrfXy 4wZ+5xhZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa8b3uVMZC6ZwVRzdeImtgfEJexcjF4eQwAZG iXvzmpghnNOMErsXXwdyODnYBDQl7nz+xARiiwhIS1z7fJkRxGYWqJf4u+YpWFxYIF5iz+kbY HEWAVWJFT9/gPXyCrhIHP9xFywuISAncfLYZNYJjJwLGBlWMaoXpxaVpRbpmuklFWWmZ5TkJm bm6BoaGOvlphYXJ6an5iQmFesl5+duYgT6q56BgXEH45U250OMkhxMSqK8tyfGhwvxJeWnVGY kFmfEF5XmpBYfYpTh4FCS4NV4B5QTLEpNT61Iy8wBBg5MWoKDR0mEVx8kzVtckJhbnJkOkTrF qCglzpsJkhAASWSU5sG1wYL1EqOslDAvIwMDgxBPQWpRbmYJqvwrRnEORiVhXhOQKTyZeSVw0 18BLWYCWmwzHWxxSSJCSqqBMeSjbVhxsfb98oqTldWMKvszHq3NnLvl4FPFv5tOJ2vKu310ld hy54H3gSiGetntAmv/T3L9/nKZV/6WVXm39xarHpvd8py/PEuSXe1Ye0COr/DFXtnFi2cyKq8 OLWJO/7vt15eJge8YTn03rQ1iPsRc5zN9xSqZGp4yWb0tvv8OzFnukJGWpcRSnJFoqMVcVJwI AMma3jNRAgAA X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-10.tower-31.messagelabs.com!1465905034!44632345!1 X-Originating-IP: [217.140.101.70] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 8.46; banners=-,-,- X-VirusChecked: Checked Received: (qmail 28901 invoked from network); 14 Jun 2016 11:50:34 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-10.tower-31.messagelabs.com with SMTP; 14 Jun 2016 11:50:34 -0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 94B8EF; Tue, 14 Jun 2016 04:51:12 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.215.28]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 824183F246; Tue, 14 Jun 2016 04:50:31 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Tue, 14 Jun 2016 12:50:26 +0100 Message-Id: <1465905026-12887-1-git-send-email-julien.grall@arm.com> X-Mailer: git-send-email 1.9.1 Cc: Julien Grall , sstabellini@kernel.org, wei.liu2@citrix.com, Shannon Zhao Subject: [Xen-devel] [PATCH] xen/arm: map_dev_mmio_region: The iomem permission check should be done on MFN X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" The helper iomem_access_permitted expects MFNs in parameters and not GNFs. Thankfully only the hardware domain can call this function and it will always be with GFNS == MFNs for now. Also, fix the printf to use the MFN range and not the GFN one. Signed-off-by: Julien Grall Cc: Shannon Zhao --- This patch is a good candidate to backport to Xen 4.7. Without it, the hardware domain can map any MMIO because the permission check is done on the GPFNs and not the MNFs. --- xen/arch/arm/p2m.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c index 6a19c57..4c6547d 100644 --- a/xen/arch/arm/p2m.c +++ b/xen/arch/arm/p2m.c @@ -1275,14 +1275,14 @@ int map_dev_mmio_region(struct domain *d, { int res; - if ( !(nr && iomem_access_permitted(d, start_gfn, start_gfn + nr - 1)) ) + if ( !(nr && iomem_access_permitted(d, mfn, mfn + nr - 1)) ) return 0; res = map_mmio_regions(d, start_gfn, nr, mfn); if ( res < 0 ) { printk(XENLOG_G_ERR "Unable to map [%#lx - %#lx] in Dom%d\n", - start_gfn, start_gfn + nr - 1, d->domain_id); + mfn, mfn + nr - 1, d->domain_id); return res; }