From patchwork Fri Jun 30 15:54:16 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 106731 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp2507514qge; Fri, 30 Jun 2017 08:57:09 -0700 (PDT) X-Received: by 10.36.3.11 with SMTP id e11mr8237710ite.79.1498838229194; Fri, 30 Jun 2017 08:57:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1498838229; cv=none; d=google.com; s=arc-20160816; b=MpCCDoQtca0vZY1fZpss8Tq93I1nei+tcLHAbAlD1IufbqMf9T6fWPr/6EtH2sRS1x ZQqQUqkXxVmc0caWQIfoz/2jqOwu+rDHgN6NYeSoIPXaFxpPapeEPo9WZUjZHZJd7bNR nMdeAPfctRz3zQdTUCa2sGWdES2aSaOEUm/wd7yewLnc6xSWfUKgFJNrlBwa2hvpW78l 1MkDb1USPOgAaJAAp//FMHOIyobbbkf4P67k1fVk3kiNA6xxtPmQx5CgXAs+APc9hbBa CCp/PKg1Fs22edKADd6wYCdcDeuuDxhznIjR9UiWopvKYSlaqceemJdQ1jaCRW9hS4K2 C/Dw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-unsubscribe:list-id :precedence:subject:cc:references:in-reply-to:message-id:date:to :from:arc-authentication-results; bh=3vy9EXvMyDgcpYcax5dXYrNzwA5ICaqRIWHU+oud/s0=; b=wHiVc3LTMnNTeuvQfA+na/F0CShmUtEGZnqdnDrI6jZiJqVIYjabMU7vFIClXHpYLD /ov7UpdeP5A7+MfimomK0NcrBtURm1LlK5yXxkquSusveWt3eY9bFiaPjBYeZZ1yQvVf 6hDDP1otyr83IqjhkQ4ZEtTvJA5+1WIEeRQJnmBiZuQQMjcwZ0M/ixSg7A48jHg8FRyA LNZNLu+qIW+d3T8AWoCDk3s02N3bPiaqHohs0lvdpzlgR8H2BLqFh/HxlcEgHBtDcNza VAcadRZeJm2FgHC80ZnMv/2dZXXpswq30Ds1ZsfXxlGvbtJsrCHPNuTXDzfAzFwdI3/y OFhg== ARC-Authentication-Results: i=1; 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 Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id h67si7943272ioe.193.2017.06.30.08.57.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 30 Jun 2017 08:57:09 -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 1dQyFk-0000NB-Q9; Fri, 30 Jun 2017 15:54:40 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dQyFj-0000Mx-M3 for xen-devel@lists.xen.org; Fri, 30 Jun 2017 15:54:39 +0000 Received: from [193.109.254.147] by server-10.bemta-6.messagelabs.com id 4A/3F-03582-F3476595; Fri, 30 Jun 2017 15:54:39 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrDLMWRWlGSWpSXmKPExsVysyfVTdeuJCz S4NgrLYslHxezODB6HN39mymAMYo1My8pvyKBNePeg53sBa3sFY+2bGdsYJzJ2sXIxSEksJlR 4u/fm4xdjJxAzmlGiT1LzEBsNgFNiTufPzGB2CIC0hLXPl8Gq2EWcJB48/EeC4gtLBAj8XfDB TYQm0VAVeLO1eVANRwcvAKWEpcWeoGEJQTkJXa1XWQFsTkFrCSO/3vABLHKUuL1rKssExi5Fz AyrGJUL04tKkst0jXWSyrKTM8oyU3MzNE1NDDTy00tLk5MT81JTCrWS87P3cQI9C0DEOxg7Pj ndIhRkoNJSZR35bXQSCG+pPyUyozE4oz4otKc1OJDjDIcHEoSvGuKwiKFBItS01Mr0jJzgEEG k5bg4FES4ZUNAkrzFhck5hZnpkOkTjFacmxYvf4LE0fThy1A8tWE/9+YhFjy8vNSpcR500HmC YA0ZJTmwY2DRcIlRlkpYV5GoAOFeApSi3IzS1DlXzGKczAqCfNOAJnCk5lXArf1FdBBTEAHCc 8IATmoJBEhJdXAuCj6hsZyo+yJXjXa9Syz+ULehoceDjm8ZP6pnD2PQisCL3kqhM0+1CNaHrg zJ8nyqca3RwKsC5bregbH3HA6eGvy9rbL/UvXbr8+a5KlGoPG+7QUh6IX956nVCvLuR879uDz sU36uj0fbzuwX3O+U7b4DdO29Sw1WcEnD3+7JVT3fULvlhfvypRYijMSDbWYi4oTARPYX0t/A gAA X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-14.tower-27.messagelabs.com!1498838078!92584155!1 X-Originating-IP: [217.140.101.70] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.25; banners=-,-,- X-VirusChecked: Checked Received: (qmail 7590 invoked from network); 30 Jun 2017 15:54:38 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-14.tower-27.messagelabs.com with SMTP; 30 Jun 2017 15:54:38 -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 F362C15AD; Fri, 30 Jun 2017 08:54:37 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.206.53]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 61B373F41F; Fri, 30 Jun 2017 08:54:37 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Fri, 30 Jun 2017 16:54:16 +0100 Message-Id: <20170630155431.23824-2-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170630155431.23824-1-julien.grall@arm.com> References: <20170630155431.23824-1-julien.grall@arm.com> Cc: Julien Grall , sstabellini@kernel.org Subject: [Xen-devel] [PATCH v3 01/16] xen/arm: setup: Remove bogus xenheap_mfn_end in setup_mm for arm64 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" xenheap_mfn_end is storing an MFN and not a physical address. The value will be reset after the loop. So drop this bogus xenheap_mfn_end. Signed-off-by: Julien Grall --- Changes in v2: - Update commit message Changes in v3: - Don't mention the fact that Xen is not currently using xenheap_mfn_end. - Add Stefano's reviewed-by --- xen/arch/arm/setup.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c index f00f29a45b..ab4d8e4218 100644 --- a/xen/arch/arm/setup.c +++ b/xen/arch/arm/setup.c @@ -654,8 +654,6 @@ static void __init setup_mm(unsigned long dtb_paddr, size_t dtb_size) if ( e > bank_end ) e = bank_end; - xenheap_mfn_end = e; - dt_unreserved_regions(s, e, init_boot_pages, 0); s = n; } From patchwork Fri Jun 30 15:54:17 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 106732 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp2507537qge; Fri, 30 Jun 2017 08:57:10 -0700 (PDT) X-Received: by 10.36.101.135 with SMTP id u129mr7361924itb.21.1498838230542; Fri, 30 Jun 2017 08:57:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1498838230; cv=none; d=google.com; s=arc-20160816; b=AeeQZofleF/9Na9WZQwwwf8WDLzbCdU7bYcPanTsi+I0/+nXg0Rnu/wvCER7WTd3s7 bZCofRwRY+7de8MHHcvVflj+B0rLFmIs6Jg2DMKdIuIa3yrlYHvd82WolbjT4FV18sBf Xsvr96WG7SxW3yesGERsB4cDneEwav20KzS08FRFQY3a6mCjgsdGn1NdrCfTdRt+JGED gqXwZ+/wfqDzAyUky6R2ApFgqAe/yv5IUYelN0UnZmsqvFOznioQI1yX945tGSviaryk agISnhnt2doS3/OeXBA4NmWksTraUEE+8y95YhE+mbWVnppWFUhaZgZ9KwvDJjlocvtC JFiQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-unsubscribe:list-id :precedence:subject:cc:references:in-reply-to:message-id:date:to :from:arc-authentication-results; bh=O3sw+G2aqrpPZycGzZSbMUM7hu4LZpyBpvvYTpQr01Y=; b=SW20VABCHHQceCDVgyFe/9I/p4CvQzpnOrXsPniwL+kzBgCK3TGCxka4ygz6OpB8mK FxCdBS/gIPTMCCSUJpIe5EI7dudUb9Ipfwuo46E9CfRgs+F4S3Wn/XiGP5ITGqgiIqti mAWxWZk9wHovta4VAJwcbUzSOeUlxnM8yD4dtBDmwAFA1Ia3a+cnqBz6aCoB9DA6QBNk d/RiUzpZ6bSUZj8dcurVTarbsr+pagZ+F1ouZN8hJOQbOiwcZK1EbdT/+mJD4PwWbb9W LcK+L8TYuNTWyR+ECcwbwH3B9Jl5YhH+Nd4nNf33j2CUGk3U9LDPi5VOCqCHBV05/1sk 15+Q== ARC-Authentication-Results: i=1; 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 Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id h184si7927689iof.166.2017.06.30.08.57.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 30 Jun 2017 08:57:10 -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 1dQyFm-0000Nc-1E; Fri, 30 Jun 2017 15:54:42 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dQyFl-0000N9-0B for xen-devel@lists.xen.org; Fri, 30 Jun 2017 15:54:41 +0000 Received: from [85.158.143.35] by server-7.bemta-6.messagelabs.com id 64/27-03557-04476595; Fri, 30 Jun 2017 15:54:40 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrBLMWRWlGSWpSXmKPExsVysyfVTde+JCz S4PtzLYslHxezODB6HN39mymAMYo1My8pvyKBNWPCXbaCVyYVk/qOMzYwTtPsYuTiEBLYzCjx 9PFkVgjnNKPE4om72bsYOTnYBDQl7nz+xARiiwhIS1z7fJkRxGYWcJB48/EeC4gtLOAp8XL9Z bB6FgFViS+v34PV8wpYSizdfxvMlhCQl9jVdpEVxOYUsJI4/u8BWFwIqOb1rKssExi5FzAyrG LUKE4tKkst0jU000sqykzPKMlNzMzRNTQw08tNLS5OTE/NSUwq1kvOz93ECPQvAxDsYLy/MeA QoyQHk5Io78proZFCfEn5KZUZicUZ8UWlOanFhxhlODiUJHgVi8MihQSLUtNTK9Iyc4CBBpOW 4OBREuGVDQJK8xYXJOYWZ6ZDpE4xGnNsWL3+CxPHqwn/vzEJseTl56VKifOGgEwSACnNKM2DG wSLgEuMslLCvIxApwnxFKQW5WaWoMq/YhTnYFQS5mUDmcKTmVcCt+8V0ClMQKcIzwgBOaUkES El1cB4J8xvc/je5W0GH76IzW2u6ovrtWdvkTr27DQvl6qwTvJUQ+kT7/7FND3hfb69pyOETzl 9Qve7z/sUv68oWeD1zvTa8cjiVbmqhbJ3di46JOzEl7w4ax/7TTnbmunr1h+/vvHX5akbrt/M mveyxJ/xyWyrmlPPZFN8NHmtz36/5Zx/7tTNHcaGSizFGYmGWsxFxYkA22vgHXsCAAA= X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-6.tower-21.messagelabs.com!1498838079!48087897!1 X-Originating-IP: [217.140.101.70] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.25; banners=-,-,- X-VirusChecked: Checked Received: (qmail 57471 invoked from network); 30 Jun 2017 15:54:39 -0000 Received: from usa-sjc-mx-foss1.foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-6.tower-21.messagelabs.com with SMTP; 30 Jun 2017 15:54:39 -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 D7E7A15B2; Fri, 30 Jun 2017 08:54:38 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.206.53]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 3AAF03F41F; Fri, 30 Jun 2017 08:54:38 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Fri, 30 Jun 2017 16:54:17 +0100 Message-Id: <20170630155431.23824-3-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170630155431.23824-1-julien.grall@arm.com> References: <20170630155431.23824-1-julien.grall@arm.com> Cc: Julien Grall , sstabellini@kernel.org Subject: [Xen-devel] [PATCH v3 02/16] xen/arm: mm: Use typesafe mfn for xenheap_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" Add more safety when using xenheap_mfn_*. Signed-off-by: Julien Grall --- I haven't introduced mfn_less_than() and mfn_greather_than() as there would be only a couple of usage. We would be able to introduce them and replace the open-coding easily in the future grepping mfn_x(). Changes in v3: - Use INVALID_MFN_INITIALIZER rather than INVALID_MFN --- xen/arch/arm/mm.c | 16 ++++++++-------- xen/arch/arm/setup.c | 18 +++++++++--------- xen/include/asm-arm/mm.h | 11 ++++++----- 3 files changed, 23 insertions(+), 22 deletions(-) diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c index 018f44a6d1..d3674e732e 100644 --- a/xen/arch/arm/mm.c +++ b/xen/arch/arm/mm.c @@ -138,8 +138,8 @@ uint64_t init_ttbr; static paddr_t phys_offset; /* Limits of the Xen heap */ -unsigned long xenheap_mfn_start __read_mostly = ~0UL; -unsigned long xenheap_mfn_end __read_mostly; +mfn_t xenheap_mfn_start __read_mostly = INVALID_MFN_INITIALIZER; +mfn_t xenheap_mfn_end __read_mostly; vaddr_t xenheap_virt_end __read_mostly; #ifdef CONFIG_ARM_64 vaddr_t xenheap_virt_start __read_mostly; @@ -801,8 +801,8 @@ void __init setup_xenheap_mappings(unsigned long base_mfn, /* Record where the xenheap is, for translation routines. */ xenheap_virt_end = XENHEAP_VIRT_START + nr_mfns * PAGE_SIZE; - xenheap_mfn_start = base_mfn; - xenheap_mfn_end = base_mfn + nr_mfns; + xenheap_mfn_start = _mfn(base_mfn); + xenheap_mfn_end = _mfn(base_mfn + nr_mfns); } #else /* CONFIG_ARM_64 */ void __init setup_xenheap_mappings(unsigned long base_mfn, @@ -816,16 +816,16 @@ void __init setup_xenheap_mappings(unsigned long base_mfn, mfn = base_mfn & ~((FIRST_SIZE>>PAGE_SHIFT)-1); /* First call sets the xenheap physical and virtual offset. */ - if ( xenheap_mfn_start == ~0UL ) + if ( mfn_eq(xenheap_mfn_start, INVALID_MFN) ) { - xenheap_mfn_start = base_mfn; + xenheap_mfn_start = _mfn(base_mfn); xenheap_virt_start = DIRECTMAP_VIRT_START + (base_mfn - mfn) * PAGE_SIZE; } - if ( base_mfn < xenheap_mfn_start ) + if ( base_mfn < mfn_x(xenheap_mfn_start) ) panic("cannot add xenheap mapping at %lx below heap start %lx", - base_mfn, xenheap_mfn_start); + base_mfn, mfn_x(xenheap_mfn_start)); end_mfn = base_mfn + nr_mfns; diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c index ab4d8e4218..3b34855668 100644 --- a/xen/arch/arm/setup.c +++ b/xen/arch/arm/setup.c @@ -555,8 +555,8 @@ static void __init setup_mm(unsigned long dtb_paddr, size_t dtb_size) * and enough mapped pages for copying the DTB. */ dtb_pages = (dtb_size + PAGE_SIZE-1) >> PAGE_SHIFT; - boot_mfn_start = xenheap_mfn_end - dtb_pages - 1; - boot_mfn_end = xenheap_mfn_end; + boot_mfn_start = mfn_x(xenheap_mfn_end) - dtb_pages - 1; + boot_mfn_end = mfn_x(xenheap_mfn_end); init_boot_pages(pfn_to_paddr(boot_mfn_start), pfn_to_paddr(boot_mfn_end)); @@ -591,11 +591,11 @@ static void __init setup_mm(unsigned long dtb_paddr, size_t dtb_size) e = bank_end; /* Avoid the xenheap */ - if ( s < pfn_to_paddr(xenheap_mfn_start+xenheap_pages) - && pfn_to_paddr(xenheap_mfn_start) < e ) + if ( s < mfn_to_maddr(mfn_add(xenheap_mfn_start, xenheap_pages)) + && mfn_to_maddr(xenheap_mfn_start) < e ) { - e = pfn_to_paddr(xenheap_mfn_start); - n = pfn_to_paddr(xenheap_mfn_start+xenheap_pages); + e = mfn_to_maddr(xenheap_mfn_start); + n = mfn_to_maddr(mfn_add(xenheap_mfn_start, xenheap_pages)); } dt_unreserved_regions(s, e, init_boot_pages, 0); @@ -610,7 +610,7 @@ static void __init setup_mm(unsigned long dtb_paddr, size_t dtb_size) /* Add xenheap memory that was not already added to the boot allocator. */ - init_xenheap_pages(pfn_to_paddr(xenheap_mfn_start), + init_xenheap_pages(mfn_to_maddr(xenheap_mfn_start), pfn_to_paddr(boot_mfn_start)); } #else /* CONFIG_ARM_64 */ @@ -662,8 +662,8 @@ static void __init setup_mm(unsigned long dtb_paddr, size_t dtb_size) total_pages += ram_size >> PAGE_SHIFT; xenheap_virt_end = XENHEAP_VIRT_START + ram_end - ram_start; - xenheap_mfn_start = ram_start >> PAGE_SHIFT; - xenheap_mfn_end = ram_end >> PAGE_SHIFT; + xenheap_mfn_start = maddr_to_mfn(ram_start); + xenheap_mfn_end = maddr_to_mfn(ram_end); /* * Need enough mapped pages for copying the DTB. diff --git a/xen/include/asm-arm/mm.h b/xen/include/asm-arm/mm.h index ddb3f35ed1..7a35063546 100644 --- a/xen/include/asm-arm/mm.h +++ b/xen/include/asm-arm/mm.h @@ -107,7 +107,7 @@ struct page_info #define PGC_count_width PG_shift(9) #define PGC_count_mask ((1UL<= xenheap_mfn_start && _mfn < xenheap_mfn_end); \ + (_mfn >= mfn_x(xenheap_mfn_start) && \ + _mfn < mfn_x(xenheap_mfn_end)); \ }) #else #define is_xen_heap_page(page) ((page)->count_info & PGC_xen_heap) @@ -227,7 +228,7 @@ static inline paddr_t __virt_to_maddr(vaddr_t va) static inline void *maddr_to_virt(paddr_t ma) { ASSERT(is_xen_heap_mfn(ma >> PAGE_SHIFT)); - ma -= pfn_to_paddr(xenheap_mfn_start); + ma -= mfn_to_maddr(xenheap_mfn_start); return (void *)(unsigned long) ma + XENHEAP_VIRT_START; } #else @@ -235,7 +236,7 @@ static inline void *maddr_to_virt(paddr_t ma) { ASSERT(pfn_to_pdx(ma >> PAGE_SHIFT) < (DIRECTMAP_SIZE >> PAGE_SHIFT)); return (void *)(XENHEAP_VIRT_START - - pfn_to_paddr(xenheap_mfn_start) + + mfn_to_maddr(xenheap_mfn_start) + ((ma & ma_va_bottom_mask) | ((ma & ma_top_mask) >> pfn_pdx_hole_shift))); } @@ -276,7 +277,7 @@ static inline struct page_info *virt_to_page(const void *v) ASSERT(va < xenheap_virt_end); pdx = (va - XENHEAP_VIRT_START) >> PAGE_SHIFT; - pdx += pfn_to_pdx(xenheap_mfn_start); + pdx += pfn_to_pdx(mfn_x(xenheap_mfn_start)); return frame_table + pdx - frametable_base_pdx; } From patchwork Fri Jun 30 15:54:18 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 106728 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp2507458qge; Fri, 30 Jun 2017 08:57:05 -0700 (PDT) X-Received: by 10.107.136.90 with SMTP id k87mr25493973iod.154.1498838225044; Fri, 30 Jun 2017 08:57:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1498838225; cv=none; d=google.com; s=arc-20160816; b=WMVaFPnPw2Aym/dGxyeah2jMJn5HNNrV/0EWQYf47aJbxPMn+Nz+IeThE0g2fgubYZ nj+3MEND/gpBRoOiwVw46PngEDLBcV7A79Q+Z8l57d5ZPrAO9ku4A8A9AoieqjLWcbv6 WirI2B03JeLHFmugp3QNew0Cot7m7CBeX0osEfjraW7FQsuSg3S1mfG+B5jCcRS2qjfw QDMFGxV3gkVokhyxafT4ZpgIZ5Q9WAZI1ThN/GdYpdhfpBPGug+Ww6/C4+SpkAeA3nRf d3v3oUTdecIVsa7AjO+Kg2dm8UNbFYODHCUrZ1iYLx/Vu4zgdQddgpZwPtBV7nDHl/sU NtPw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-unsubscribe:list-id :precedence:subject:cc:references:in-reply-to:message-id:date:to :from:arc-authentication-results; bh=4ZFZYQpxHl7UsfoWwaNKBtJotVS9e2g7FK/IR1+11GY=; b=vNfJ+KOg3bYp2ukMuKN7am7I9dOAGDSfMeuYRHfbsuf6o1isjcAM2TDm1RFHEfjeqE F42pwNHYR1QhGr4YKR3qQT0i+cGeX+ru8wxFz7piIXoKGj2PMc57pgumNQSAnM7T3fOc kl1MGP6y3OWuWjxSUHGEjKslxvkbfWB4QBetvkemy+OcF5SADdZS6lvBtu6H/xYI2IUf bR7ERaM7X9c3cZfhMGF+cEM0MGb97AxaXcqkNKYdN/tzZ4hSHxmjxccDdILV5mkd44Pu w5F6vS98nviS/kwFWH/td0JiRqc3n1bAONPTcYmbVTGXc9yg6SxOjqZUm4vr3ipBQ57I EJZQ== ARC-Authentication-Results: i=1; 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 Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id f74si7518676iod.92.2017.06.30.08.57.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 30 Jun 2017 08:57:05 -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 1dQyFn-0000P3-8I; Fri, 30 Jun 2017 15:54:43 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dQyFl-0000NS-QU for xen-devel@lists.xen.org; Fri, 30 Jun 2017 15:54:41 +0000 Received: from [85.158.139.211] by server-15.bemta-5.messagelabs.com id 0E/82-01736-14476595; Fri, 30 Jun 2017 15:54:41 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrMLMWRWlGSWpSXmKPExsVysyfVTdehJCz SYOVHBYslHxezODB6HN39mymAMYo1My8pvyKBNeNhzxH2ggbpiq3dq9kaGPeIdjFycQgJbGKU uLBjGROEc5pRYk/bTNYuRk4ONgFNiTufPzGB2CIC0hLXPl9mBLGZBRwk3ny8xwJiCwvESJw8t IgZxGYRUJV413UVrIZXwFKi+/QCsBoJAXmJXW0XwWZyClhJHP/3AGymEFDN61lXWSYwci9gZF jFqFGcWlSWWqRrbKCXVJSZnlGSm5iZo2toYKqXm1pcnJiempOYVKyXnJ+7iRHo4XoGBsYdjBN W+R1ilORgUhLlXXktNFKILyk/pTIjsTgjvqg0J7X4EKMMB4eSBO+84rBIIcGi1PTUirTMHGCo waQlOHiURHhlg4DSvMUFibnFmekQqVOMuhyvJvz/xiTEkpeflyolzhsCMkMApCijNA9uBCzsL zHKSgnzMjIwMAjxFKQW5WaWoMq/YhTnYFQS5nUGmcKTmVcCt+kV0BFMQEcIzwgBOaIkESEl1c Co4yez+ULvaUXLuuDup8mLHiqfn8PCaBO654HZlYXWmoXyd6bXaz2qXaV0eJZR6Upfbr0FgtY ucWdWTeO9V/yF+6rHuwfxYXw+jRObFwvXVU7m2Mb2Z16hVGJwgMC5Qrtqvaxqb0HpYJ9barU8 kdu6Iw8Eml83mnpvBVfUn+9caYfO6HL2FCmxFGckGmoxFxUnAgDgtwHvdgIAAA== X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-12.tower-206.messagelabs.com!1498838080!64583846!1 X-Originating-IP: [217.140.101.70] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.25; banners=-,-,- X-VirusChecked: Checked Received: (qmail 44687 invoked from network); 30 Jun 2017 15:54:40 -0000 Received: from usa-sjc-mx-foss1.foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-12.tower-206.messagelabs.com with SMTP; 30 Jun 2017 15:54:40 -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 ABE0980D; Fri, 30 Jun 2017 08:54:39 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.206.53]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 15B733F41F; Fri, 30 Jun 2017 08:54:38 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Fri, 30 Jun 2017 16:54:18 +0100 Message-Id: <20170630155431.23824-4-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170630155431.23824-1-julien.grall@arm.com> References: <20170630155431.23824-1-julien.grall@arm.com> Cc: Julien Grall , sstabellini@kernel.org Subject: [Xen-devel] [PATCH v3 03/16] xen/arm: p2m: Redefine mfn_to_page and page_to_mfn to use typesafe 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 file xen/arch/arm/p2m.c is using typesafe MFN in most of the place. This requires caller to mfn_to_page and page_to_mfn to use _mfn/mfn_x. To avoid extra _mfn/mfn_x, re-define mfn_to_page and page_to_mfn within xen/arch/arm/p2m.c to handle typesafe MFN. Signed-off-by: Julien Grall Reviewed-by: Stefano Stabellini --- The idea behind redefining locally mfn_to_page and page_to_mfn is splitting the introduction of typesafe MFN in smaller series and between multiple people. We know the file is typesafe ready and if we decide to make the main helper typesafe, we would just need to drop the definition at the top of the file. Changes in v3: - Use __page_to_mfn(...) rather than mfn_x(page_to_mfn(...)) --- xen/arch/arm/p2m.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c index 05eb584e89..3e20a1ec82 100644 --- a/xen/arch/arm/p2m.c +++ b/xen/arch/arm/p2m.c @@ -38,6 +38,12 @@ static unsigned int __read_mostly max_vmid = MAX_VMID_8_BIT; #define P2M_ROOT_PAGES (1<domain_id, addr); printk("P2M @ %p mfn:0x%lx\n", - p2m->root, page_to_mfn(p2m->root)); + p2m->root, __page_to_mfn(p2m->root)); dump_pt_walk(page_to_maddr(p2m->root), addr, P2M_ROOT_LEVEL, P2M_ROOT_PAGES); @@ -591,7 +597,7 @@ static int p2m_create_table(struct p2m_domain *p2m, lpae_t *entry) * The access value does not matter because the hardware will ignore * the permission fields for table entry. */ - pte = mfn_to_p2m_entry(_mfn(page_to_mfn(page)), p2m_invalid, + pte = mfn_to_p2m_entry(page_to_mfn(page), p2m_invalid, p2m->default_access); p2m_write_pte(entry, pte, p2m->clean_pte); @@ -650,9 +656,9 @@ static void p2m_put_l3_page(const lpae_t pte) */ if ( p2m_is_foreign(pte.p2m.type) ) { - unsigned long mfn = pte.p2m.base; + mfn_t mfn = _mfn(pte.p2m.base); - ASSERT(mfn_valid(_mfn(mfn))); + ASSERT(mfn_valid(mfn)); put_page(mfn_to_page(mfn)); } } @@ -702,7 +708,7 @@ static void p2m_free_entry(struct p2m_domain *p2m, mfn = _mfn(entry.p2m.base); ASSERT(mfn_valid(mfn)); - pg = mfn_to_page(mfn_x(mfn)); + pg = mfn_to_page(mfn); page_list_del(pg, &p2m->pages); free_domheap_page(pg); @@ -780,7 +786,7 @@ static bool p2m_split_superpage(struct p2m_domain *p2m, lpae_t *entry, unmap_domain_page(table); - pte = mfn_to_p2m_entry(_mfn(page_to_mfn(page)), p2m_invalid, + pte = mfn_to_p2m_entry(page_to_mfn(page), p2m_invalid, p2m->default_access); /* @@ -1442,7 +1448,7 @@ struct page_info *get_page_from_gva(struct vcpu *v, vaddr_t va, if ( !mfn_valid(maddr_to_mfn(maddr)) ) goto err; - page = mfn_to_page(mfn_x(maddr_to_mfn(maddr))); + page = mfn_to_page(maddr_to_mfn(maddr)); ASSERT(page); if ( unlikely(!get_page(page, d)) ) From patchwork Fri Jun 30 15:54:19 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 106725 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp2507426qge; Fri, 30 Jun 2017 08:57:01 -0700 (PDT) X-Received: by 10.36.6.200 with SMTP id 191mr7987280itv.44.1498838221564; Fri, 30 Jun 2017 08:57:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1498838221; cv=none; d=google.com; s=arc-20160816; b=00dzC/0M03K2iEYzjXMrsZJgOvl7brhMO/jzJkd+D24FJouo3ff4jU98RmVM4duBBn 2bFNkfygisUL7GpjJ+Co72CZ1xCvJggQo1Q2e9Gw5Y+ICqFIWcESZdhwzKJHRSjoMtir 00UehFfmLLD2a7Gro5F7Bye7ajK2j0hUi+xg0cjwBHNiguXL8uHkgn5mFoLJOxfd3ilt Ct7UXTVOx3ngfkfGij3jD2sb4Tef6O5rMwDEJTr8+WImZIVGzw9vwY6ISLtTyYPL6N7L OOCpgtx4FyJc0ZunM9dtbYBVtJm7qaV6Py3W3eHRjNHUbWOqskaGTVTTn2GZaLQAwfUH TMlw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-unsubscribe:list-id :precedence:subject:cc:references:in-reply-to:message-id:date:to :from:arc-authentication-results; bh=LPTV946BD/9EzrXAldb41f0EAAgxhNGSbXTfQqNg9iQ=; b=jr3MsXCULqifhdnUIQdD085DXtcDM+ALi6uOy1WbAvVBGrDNAcKTMaIRHVSNBnXhv/ +jiyfmCz+BTo/gyfDX2T7u06O77wyevzteW7sBmI/4jl1NrtLQvaNQj0Flruhai7H3Ev W0PP0mHQ57ToK+uhRb/Bro0KQuoCAdPsguD0mZ45QUHRnqYHh8OTsoNcozZuw7J6IjP6 2Cs96vglZ13Ir7p4bCCKnKc+rDVSPzlIxeyL7Z+6DZ1ziJNTXb9bSAtfQgqWcUCtRdJq gTqU6I7mxicl63JyP+jNonC6k0NOTZYKqF5Bkv2tZ2G/jtz7QOOtqDQ2uFnTq+aWt6YT EN4w== ARC-Authentication-Results: i=1; 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 Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id j21si11240920iti.82.2017.06.30.08.57.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 30 Jun 2017 08:57:01 -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 1dQyFn-0000PQ-G9; Fri, 30 Jun 2017 15:54:43 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dQyFm-0000NT-6s for xen-devel@lists.xen.org; Fri, 30 Jun 2017 15:54:42 +0000 Received: from [85.158.143.35] by server-3.bemta-6.messagelabs.com id 62/8A-03044-14476595; Fri, 30 Jun 2017 15:54:41 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrELMWRWlGSWpSXmKPExsVysyfVTdexJCz S4OgyFoslHxezODB6HN39mymAMYo1My8pvyKBNWNC9wbWgn6Fin3PzrI1MB6R7GLk5BAS2Mwo sXuDRhcjF5B9mlFi3fspjCAJNgFNiTufPzGB2CIC0hLXPl8GizMLOEi8+XiPBcQWFvCX2HJ2J juIzSKgKrF37QSwel4BS4k572+D2RIC8hK72i6ygticAlYSx/89YIJYbCnxetZVlgmM3AsYGV YxahSnFpWlFukamuklFWWmZ5TkJmbm6BoamOnlphYXJ6an5iQmFesl5+duYgT6lwEIdjDe3xh wiFGSg0lJlHfltdBIIb6k/JTKjMTijPii0pzU4kOMMhwcShK8isVhkUKCRanpqRVpmTnAQINJ S3DwKInwygYBpXmLCxJzizPTIVKnGHU5Xk34/41JiCUvPy9VSpw3BGSGAEhRRmke3AhY0F9il JUS5mUEOkqIpyC1KDezBFX+FaM4B6OSMC8byBSezLwSuE2vgI5gAjpCeEYIyBEliQgpqQbG5p m5K5SNk+bfMvsSFB1RsnHmq49nzbMD7pqF6G+LvhYgPen/HP91ur+1Z12yshB4qnR7rQ7T92V L3+YZ7TFIYp507LPMDnu7s6xmvV89Fu3QTt/wpXKCTUFN1KlXq3lNT1WHBhnEx75sOOn6OK8j VUNb5vq/ihk8kzSWOkyNbV7Y6NFRclJBiaU4I9FQi7moOBEAkks3+XUCAAA= X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-6.tower-21.messagelabs.com!1498838079!48087897!2 X-Originating-IP: [217.140.101.70] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.25; banners=-,-,- X-VirusChecked: Checked Received: (qmail 57711 invoked from network); 30 Jun 2017 15:54:40 -0000 Received: from usa-sjc-mx-foss1.foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-6.tower-21.messagelabs.com with SMTP; 30 Jun 2017 15:54:40 -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 87C5515AD; Fri, 30 Jun 2017 08:54:40 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.206.53]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id E66993F41F; Fri, 30 Jun 2017 08:54:39 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Fri, 30 Jun 2017 16:54:19 +0100 Message-Id: <20170630155431.23824-5-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170630155431.23824-1-julien.grall@arm.com> References: <20170630155431.23824-1-julien.grall@arm.com> Cc: Julien Grall , sstabellini@kernel.org Subject: [Xen-devel] [PATCH v3 04/16] xen/arm: mm: Redefine virt_to_mfn to support typesafe 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 file xen/arch/arm/mm.c is using the typesafe MFN in most of the place. This requires all caller of virt_to_mfn to prefixed by _mfn(...). To avoid the extra _mfn(...), re-defined virt_to_mfn within arch/arm/mm.c to handle typesafe MFN. This patch also introduce __virt_to_mfn, so virt_to_mfn can be re-defined easily. Signed-off-by: Julien Grall Reviewed-by: Stefano Stabellini --- Changes in v2: - Use __virt_to_mfn rather than mfn_x(virt_to_mfn()). Changes in v3: - Add Stefano's reviewed-by --- xen/arch/arm/mm.c | 16 ++++++++++------ xen/include/asm-arm/mm.h | 3 ++- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c index d3674e732e..1e9e342fd3 100644 --- a/xen/arch/arm/mm.c +++ b/xen/arch/arm/mm.c @@ -44,6 +44,10 @@ struct domain *dom_xen, *dom_io, *dom_cow; +/* Override macros from asm/page.h to make them work with mfn_t */ +#undef virt_to_mfn +#define virt_to_mfn(va) _mfn(__virt_to_mfn(va)) + /* Static start-of-day pagetables that we use before the allocators * are up. These are used by all CPUs during bringup before switching * to the CPUs own pagetables. @@ -479,7 +483,7 @@ unsigned long domain_page_map_to_mfn(const void *ptr) unsigned long offset = (va>>THIRD_SHIFT) & LPAE_ENTRY_MASK; if ( va >= VMAP_VIRT_START && va < VMAP_VIRT_END ) - return virt_to_mfn(va); + return __virt_to_mfn(va); ASSERT(slot >= 0 && slot < DOMHEAP_ENTRIES); ASSERT(map[slot].pt.avail != 0); @@ -764,7 +768,7 @@ int init_secondary_pagetables(int cpu) * domheap mapping pages. */ for ( i = 0; i < DOMHEAP_SECOND_PAGES; i++ ) { - pte = mfn_to_xen_entry(_mfn(virt_to_mfn(domheap+i*LPAE_ENTRIES)), + pte = mfn_to_xen_entry(virt_to_mfn(domheap+i*LPAE_ENTRIES), WRITEALLOC); pte.pt.table = 1; write_pte(&first[first_table_offset(DOMHEAP_VIRT_START+i*FIRST_SIZE)], pte); @@ -961,7 +965,7 @@ static int create_xen_table(lpae_t *entry) if ( p == NULL ) return -ENOMEM; clear_page(p); - pte = mfn_to_xen_entry(_mfn(virt_to_mfn(p)), WRITEALLOC); + pte = mfn_to_xen_entry(virt_to_mfn(p), WRITEALLOC); pte.pt.table = 1; write_pte(entry, pte); return 0; @@ -1215,7 +1219,7 @@ int xenmem_add_to_physmap_one( unsigned long idx, gfn_t gfn) { - unsigned long mfn = 0; + mfn_t mfn = INVALID_MFN; int rc; p2m_type_t t; struct page_info *page = NULL; @@ -1301,7 +1305,7 @@ int xenmem_add_to_physmap_one( return -EINVAL; } - mfn = page_to_mfn(page); + mfn = _mfn(page_to_mfn(page)); t = p2m_map_foreign; rcu_unlock_domain(od); @@ -1320,7 +1324,7 @@ int xenmem_add_to_physmap_one( } /* Map at new location. */ - rc = guest_physmap_add_entry(d, gfn, _mfn(mfn), 0, t); + rc = guest_physmap_add_entry(d, gfn, mfn, 0, t); /* If we fail to add the mapping, we need to drop the reference we * took earlier on foreign pages */ diff --git a/xen/include/asm-arm/mm.h b/xen/include/asm-arm/mm.h index 7a35063546..ef84b72474 100644 --- a/xen/include/asm-arm/mm.h +++ b/xen/include/asm-arm/mm.h @@ -256,7 +256,7 @@ static inline int gvirt_to_maddr(vaddr_t va, paddr_t *pa, unsigned int flags) #define __va(x) (maddr_to_virt(x)) /* Convert between Xen-heap virtual addresses and machine frame numbers. */ -#define virt_to_mfn(va) (virt_to_maddr(va) >> PAGE_SHIFT) +#define __virt_to_mfn(va) (virt_to_maddr(va) >> PAGE_SHIFT) #define mfn_to_virt(mfn) (maddr_to_virt((paddr_t)(mfn) << PAGE_SHIFT)) /* @@ -266,6 +266,7 @@ static inline int gvirt_to_maddr(vaddr_t va, paddr_t *pa, unsigned int flags) */ #define mfn_to_page(mfn) __mfn_to_page(mfn) #define page_to_mfn(pg) __page_to_mfn(pg) +#define virt_to_mfn(va) __virt_to_mfn(va) /* Convert between Xen-heap virtual addresses and page-info structures. */ static inline struct page_info *virt_to_page(const void *v) From patchwork Fri Jun 30 15:54:20 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 106735 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp2507555qge; Fri, 30 Jun 2017 08:57:12 -0700 (PDT) X-Received: by 10.36.9.144 with SMTP id 138mr8253273itm.98.1498838232237; Fri, 30 Jun 2017 08:57:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1498838232; cv=none; d=google.com; s=arc-20160816; b=orcGqmkRC7n2pBVDV9UdI607gNQB63FL8jWvK6Xatsc5HKLzk8AZ2MZiC5YBCDu2T7 G0sYuD1P2efOJyI0HEl2zfCA8ciVnRXvjTZM5K/Aa23tQdufSQGNgFqCu4sTMwslqANK ioSmj7rQkUT9FYBey1TCVaHu96J1s/z9nyJfLnoHK4Mb91n5Tj4Yw+AD5P+y02urgSB4 SbL6eMbwQ03xDftuLUp6CWhFB28hHHHBfExrT6jNlkBVyxoL4TyoETohBW06PmkL6QVt 0YvZ2l2pwSfbuhgheovrUG6uAnsYDedNqLeeXbne4qhpS+wJsO5vatp9C30GdpjPRp6b jr+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-unsubscribe:list-id :precedence:subject:cc:references:in-reply-to:message-id:date:to :from:arc-authentication-results; bh=jteeSNjz2K9slOl7MOJIoqJsRi4GMLJOLJ3tRLfnMI4=; b=jGnXdx0gMvYT3HxustTCRcrVckhD65TBSPBb1/wMrfjSII82QiaqrtOMuJpIrU8lAl i4zdYG8cYRrfoPVrSZrWfXxTyAltcA67j3yNjiLzdYk38U3odwtmvYTQ1gy7wuf99+5p 3MLklKOE6q0YDsUV/OXuF6pulXj415IMIgptgoXVs/h1L5OFnF83AZBx4qvuedMByc0s xJadKdaAS1Q8IZHJvJvVkBxUTMgky1vh0lADFB1j5Uf+RzRTIcP0Z6cByfKNu4lTJDpC jfCR+WluEs8wcxE8UUfrtq+3RnXqBfwQRh9oo9aSqXdvprkhGwIIphBQzQfRSLtShGgZ UdDQ== ARC-Authentication-Results: i=1; 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 Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id j21si11241273iti.82.2017.06.30.08.57.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 30 Jun 2017 08:57:12 -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 1dQyFo-0000Qb-4F; Fri, 30 Jun 2017 15:54:44 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dQyFm-0000NS-Ps for xen-devel@lists.xen.org; Fri, 30 Jun 2017 15:54:42 +0000 Received: from [85.158.139.211] by server-15.bemta-5.messagelabs.com id 89/92-01736-24476595; Fri, 30 Jun 2017 15:54:42 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrMLMWRWlGSWpSXmKPExsVysyfVTdepJCz S4PkmLoslHxezODB6HN39mymAMYo1My8pvyKBNaO97TBzwQnuihVzfjI2MHZxdjFycQgJbGaU eH5iKROEc5pR4kbLfyCHk4NNQFPizudPYLaIgLTEtc+XGUFsZgEHiTcf77GA2MICkRKz90PYL AKqEjv23AKzeQUsJT733mAGsSUE5CV2tV1kBbE5Bawkjv97ADZTCKjm9ayrLBMYuRcwMqxi1C hOLSpLLdI1MtBLKspMzyjJTczM0TU0MNXLTS0uTkxPzUlMKtZLzs/dxAj0cD0DA+MOxsbZfoc YJTmYlER5V14LjRTiS8pPqcxILM6ILyrNSS0+xCjDwaEkwatYHBYpJFiUmp5akZaZAww1mLQE B4+SCK9sEFCat7ggMbc4Mx0idYpRl+PVhP/fmIRY8vLzUqXEeUNAZgiAFGWU5sGNgIX9JUZZK WFeRgYGBiGegtSi3MwSVPlXjOIcjErCvM4gU3gy80rgNr0COoIJ6AjhGSEgR5QkIqSkGhiTpp lOc7+lk5qY+NZhsuhC18/lV7TXFUh+EuZ+5MZoFF6onbSFdV+M9MtfU4X8UyOPFLX7CYqrekx 9cF/0rvCOvH3Lir0mJhkubExVKbm1ufZO4atdr2xuV3PfWmGosizPaeJbZ1unI3pnJs1dIB6c YO76yN2qMqD8P5u/1O+Xdh6h97/Mvq/EUpyRaKjFXFScCAB/ilmYdgIAAA== X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-11.tower-206.messagelabs.com!1498838081!81075311!1 X-Originating-IP: [217.140.101.70] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.25; banners=-,-,- X-VirusChecked: Checked Received: (qmail 52103 invoked from network); 30 Jun 2017 15:54:42 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-11.tower-206.messagelabs.com with SMTP; 30 Jun 2017 15:54:42 -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 621A515B2; Fri, 30 Jun 2017 08:54:41 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.206.53]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id C293D3F41F; Fri, 30 Jun 2017 08:54:40 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Fri, 30 Jun 2017 16:54:20 +0100 Message-Id: <20170630155431.23824-6-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170630155431.23824-1-julien.grall@arm.com> References: <20170630155431.23824-1-julien.grall@arm.com> Cc: Julien Grall , sstabellini@kernel.org Subject: [Xen-devel] [PATCH v3 05/16] xen/arm: domain_build: Redefine virt_to_mfn to support typesafe 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 file xen/arch/arm/domain_build.c is using typesafe MFN in most of the place. The only caller to virt_to_mfn is using prefixed with _mfn(...). To avoid extra _mfn(...), re-define virt_to_mfn within arch/arm/domain_build.c to handle typesafe MFN. Signed-off-by: Julien Grall Reviewed-by: Stefano Stabellini --- Changes in v2: - Add Stefano's reviewed-by --- xen/arch/arm/domain_build.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index c6776d76fc..1bec4fa23d 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -45,6 +45,10 @@ struct map_range_data p2m_type_t p2mt; }; +/* Override macros from asm/page.h to make them work with mfn_t */ +#undef virt_to_mfn +#define virt_to_mfn(va) _mfn(__virt_to_mfn(va)) + //#define DEBUG_11_ALLOCATION #ifdef DEBUG_11_ALLOCATION # define D11PRINT(fmt, args...) printk(XENLOG_DEBUG fmt, ##args) @@ -1903,7 +1907,7 @@ static int prepare_acpi(struct domain *d, struct kernel_info *kinfo) rc = map_regions_p2mt(d, gaddr_to_gfn(d->arch.efi_acpi_gpa), PFN_UP(d->arch.efi_acpi_len), - _mfn(virt_to_mfn(d->arch.efi_acpi_table)), + virt_to_mfn(d->arch.efi_acpi_table), p2m_mmio_direct_c); if ( rc != 0 ) { From patchwork Fri Jun 30 15:54:21 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 106727 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp2507459qge; Fri, 30 Jun 2017 08:57:05 -0700 (PDT) X-Received: by 10.36.225.198 with SMTP id n189mr7932690ith.93.1498838225084; Fri, 30 Jun 2017 08:57:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1498838225; cv=none; d=google.com; s=arc-20160816; b=NGxffH4EJzj1C7HBIes4q21pyEcO84Aj4ymPrK5kRXZcurrMAL5SQJOHYQcEY/lVo7 XaCXn8IxjpAQYTBhqF8r43nuN6nmd6cLw91k5eYf2Frj/7Vn80s19LhPdepDOHkD0S0P 7fzWnLt43PVi+vVZWBCN/jmIQM2U8u+zM8IbJQsMJaEndHIOEDsstlSCtT+R1GDfePPh /i8sN+dIJkIDNOaDtACKxKOvyI3N5mCV/RnajW4DpMaNulkf/6iaw4VnvlxRkPVGeWxO z+CZ3qGl1uAlEDzhneRoTnQhdFnqwZV42cZc1LVS4PfP5gZcJc5ri6uFV/YwASnHIjAf 9Qgw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-unsubscribe:list-id :precedence:subject:cc:references:in-reply-to:message-id:date:to :from:arc-authentication-results; bh=HMdBXsMFkpQ/pgoViJnEj1gO7GOGRlo1GqUHSMgs2As=; b=AZXA3TjHqZdtY5rhTeO1rIJIy2WeWbWS5q2dGx0DmqnbcYHxx63PKbLCHt6vPAax8V jHPs5vAlTgQblWMBWYd99S4eOinsTiYcrkbO/x+4jpe87CYsBru9sfj2vjSUSfJkPftJ qIRIO8IUM/tTZQHslZfEU+kQDSGsVVXhvoP3KvgH7ZK/jrBtqOEFMO7stSaPXwnCIgbE mty2HHoRhvSW0KQqVksoxG/KLezWE68bFsb40jAKc1wsOFH9vAX6pR5+0ZrUUlqxTfwj bnTYTmNAa9c3WlljD2q7DiQ+khdTNYc8WBFbFWfgA8emuBGGN7BrRG3UEN2vXwEHdadl nUEg== ARC-Authentication-Results: i=1; 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 Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id c24si4266001itd.141.2017.06.30.08.57.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 30 Jun 2017 08:57:05 -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 1dQyFp-0000Rh-Bq; Fri, 30 Jun 2017 15:54:45 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dQyFo-0000Pk-2o for xen-devel@lists.xen.org; Fri, 30 Jun 2017 15:54:44 +0000 Received: from [85.158.143.35] by server-11.bemta-6.messagelabs.com id DD/38-03612-34476595; Fri, 30 Jun 2017 15:54:43 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrJLMWRWlGSWpSXmKPExsVysyfVTdepJCz SYOM5S4slHxezODB6HN39mymAMYo1My8pvyKBNWPf39mMBZe4Kl5vvMbSwPiUo4uRi0NIYBOj xIIfx5ghnNOMEi2npzB1MXJysAloStz5/AnMFhGQlrj2+TIjiM0s4CDx5uM9FhBbWCBC4vOxv 2A2i4CqxKR/f8BqeAUsJY623gGzJQTkJXa1XWQFsTkFrCSO/3sANlMIqOb1rKssExi5FzAyrG LUKE4tKkst0jUy10sqykzPKMlNzMzRNTQw08tNLS5OTE/NSUwq1kvOz93ECPQwAxDsYFy8NvA QoyQHk5Io78proZFCfEn5KZUZicUZ8UWlOanFhxhlODiUJHgVi8MihQSLUtNTK9Iyc4ChBpOW 4OBREuGVDQJK8xYXJOYWZ6ZDpE4xGnNsWL3+CxPHqwn/vzEJseTl56VKifO+KgIqFQApzSjNg xsEi4FLjLJSwryMQKcJ8RSkFuVmlqDKv2IU52BUEuZlA7mHJzOvBG7fK6BTmIBOEZ4RAnJKSS JCSqqB0XnrDOEnYfryi4/EX2pP5Nz5Q9pDRllcv6577tESm3Re5QrPy3tSXXf/WHRq+r9bYet D7gh2p52NfnywwEyvsaRDcLPDfjmp0+HLQ4/KWt8629Wy33vfxdX/HluKrZRkvFS7WkdSYGfb X/MY1iDh6lDJ3LsT0y/f+H/bp8DvZvRk6yybneoTlViKMxINtZiLihMBvEnROnwCAAA= X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-3.tower-21.messagelabs.com!1498838082!67649181!1 X-Originating-IP: [217.140.101.70] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.25; banners=-,-,- X-VirusChecked: Checked Received: (qmail 48691 invoked from network); 30 Jun 2017 15:54:42 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-3.tower-21.messagelabs.com with SMTP; 30 Jun 2017 15:54:42 -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 3CF5C80D; Fri, 30 Jun 2017 08:54:42 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.206.53]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 9C90F3F41F; Fri, 30 Jun 2017 08:54:41 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Fri, 30 Jun 2017 16:54:21 +0100 Message-Id: <20170630155431.23824-7-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170630155431.23824-1-julien.grall@arm.com> References: <20170630155431.23824-1-julien.grall@arm.com> Cc: Julien Grall , sstabellini@kernel.org Subject: [Xen-devel] [PATCH v3 06/16] xen/arm: alternative: Redefine virt_to_mfn to support typesafe 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 file xen/arch/arm/alternative.c is using typesafe MFN in most of the place. The only caller to virt_to_mfn is using with _mfn(...). To avoid extra _mfn(...), re-define virt_to_mfn within xen/arch/arm/alternative.c to handle typesafe MFN. Signed-off-by: Julien Grall Reviewed-by: Stefano Stabelllini --- Changes in v2: - Add Stefano's reviewed-by --- xen/arch/arm/alternative.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/xen/arch/arm/alternative.c b/xen/arch/arm/alternative.c index 4d7e5b6155..a3bcda3117 100644 --- a/xen/arch/arm/alternative.c +++ b/xen/arch/arm/alternative.c @@ -32,6 +32,10 @@ #include #include +/* Override macros from asm/page.h to make them work with mfn_t */ +#undef virt_to_mfn +#define virt_to_mfn(va) _mfn(__virt_to_mfn(va)) + extern const struct alt_instr __alt_instructions[], __alt_instructions_end[]; struct alt_region { @@ -154,7 +158,7 @@ static int __apply_alternatives_multi_stop(void *unused) { int ret; struct alt_region region; - mfn_t xen_mfn = _mfn(virt_to_mfn(_start)); + mfn_t xen_mfn = virt_to_mfn(_start); paddr_t xen_size = _end - _start; unsigned int xen_order = get_order_from_bytes(xen_size); void *xenmap; From patchwork Fri Jun 30 15:54:22 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 106738 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp2507601qge; Fri, 30 Jun 2017 08:57:15 -0700 (PDT) X-Received: by 10.107.19.168 with SMTP id 40mr21891087iot.51.1498838235451; Fri, 30 Jun 2017 08:57:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1498838235; cv=none; d=google.com; s=arc-20160816; b=shtP+NhsGXOpN5Poc0aaPmGfQWNiY5trxIwV8t816RAXkfQ/EtyEIBD25rrSqLX32o 3NRIRY4GOTpdFp7YJfA9akwKGLijVGtjnZy6N35Jwrapi8BdPhSoOIcnVEwjs6OSXsdM DoT7G127w9vyVJFlzCkVvYqseGfeSnwielobNfSg4aGSgcntPn49cN2aeGNJxVbOG1yC QrOCXFxAuKsXqUBXf1j4wcwz0RQdkYdTn59lLGIof2ZowOnpnWM+O0MEqMrNIzFWFwMj BQLkUusMiXhbE5+Uh25AWGNuZx5ArTC6NJQNKTbIBmpkz/Pk9giWZdlXgYoj24Ptvawg T6zw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-unsubscribe:list-id :precedence:subject:cc:references:in-reply-to:message-id:date:to :from:arc-authentication-results; bh=iCMzM7TaZYeEkVEO5tWgyw0pHo2gSHptP14sZv9oTko=; b=rYNFwbzL/swLKnnFXz5iYk+8y2+0v/nbwGYQ0wf8hS1+fUyfLZSxQjEKgMC8ayfaJc eI/upARQS8EQZG9SSnhvOPGekoFDWPf8LgoR7u0tcIBllXdOoMS4YJLCVvjlHDrZqVNM q9RR7uUexeJJa0AGerDY6v7dsZXLB5Bbc8mTY2PHaz5Y62HZYmO4znYqqHCW07jnIZfx VWAJaHUMlAVsNNzX2OMYJKf3Igp511mcQLkkjZxLMFZiZ9JxYiHXkX7kFT9fq19lqnUM RnXQnKS9mcW5m1vrbX0X4Rua/1Nob6JXwU8vvtSQNpIijl158aB6+5GO1KT/TmD8X0fn KFlg== ARC-Authentication-Results: i=1; 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 Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id p73si4292901itg.4.2017.06.30.08.57.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 30 Jun 2017 08:57:15 -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 1dQyFq-0000TR-JB; Fri, 30 Jun 2017 15:54:46 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dQyFp-0000RH-9Y for xen-devel@lists.xen.org; Fri, 30 Jun 2017 15:54:45 +0000 Received: from [85.158.139.211] by server-9.bemta-5.messagelabs.com id B7/F8-01994-44476595; Fri, 30 Jun 2017 15:54:44 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrELMWRWlGSWpSXmKPExsVysyfVTdelJCz S4F6QxZKPi1kcGD2O7v7NFMAYxZqZl5RfkcCa8evMIsaCRu6Ky3MnMTYwTuLsYuTiEBLYzChx /PhFRgjnNKPEg0krgRxODjYBTYk7nz8xgdgiAtIS1z5fBoszC+RKzN29gx3EFhYIk1jweSULi M0ioCpx8ccFNhCbV8BS4tyOhWC2hIC8xK62i6wgNqeAlcTxfw/AZgoB1byedZVlAiP3AkaGVY waxalFZalFuobGeklFmekZJbmJmTm6hgamermpxcWJ6ak5iUnFesn5uZsYgf5lAIIdjP+2eR5 ilORgUhLlXXktNFKILyk/pTIjsTgjvqg0J7X4EKMMB4eSBK9icVikkGBRanpqRVpmDjDQYNIS HDxKIryyQUBp3uKCxNzizHSI1ClGXY5XE/5/YxJiycvPS5US5w0BmSEAUpRRmgc3Ahb0lxhlp YR5GYGOEuIpSC3KzSxBlX/FKM7BqCTM6wwyhSczrwRu0yugI5iAjhCeEQJyREkiQkqqgdFAZA KTvQjvz7oDDvLtVvErNMLjk7OnGHwpWHI7O3NGhiHvi6tvbrKdWs0T+DLvG0uCdLDx/DsOUjd CSgSU3fcpveybf/HTshDd84vXSD9elVyY1bxh+b31ui8DZ3z/uNF5lqmidBGr72ZbrdnSV7TP b9+nKFZheGe3nx1/qnTHj+Y0neC9yUosxRmJhlrMRcWJABrtW7F1AgAA X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-2.tower-206.messagelabs.com!1498838083!80256930!1 X-Originating-IP: [217.140.101.70] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.25; banners=-,-,- X-VirusChecked: Checked Received: (qmail 21753 invoked from network); 30 Jun 2017 15:54:43 -0000 Received: from usa-sjc-mx-foss1.foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-2.tower-206.messagelabs.com with SMTP; 30 Jun 2017 15:54:43 -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 3A5DE15AD; Fri, 30 Jun 2017 08:54:43 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.206.53]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 7825D3F41F; Fri, 30 Jun 2017 08:54:42 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Fri, 30 Jun 2017 16:54:22 +0100 Message-Id: <20170630155431.23824-8-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170630155431.23824-1-julien.grall@arm.com> References: <20170630155431.23824-1-julien.grall@arm.com> Cc: Ross Lagerwall , Julien Grall , sstabellini@kernel.org Subject: [Xen-devel] [PATCH v3 07/16] xen/arm: livepatch: Redefine virt_to_mfn to support typesafe 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 file xen/arch/arm/livepatch.c is using typesafe MFN in most of the place. The only caller to virt_to_mfn is using with _mfn(...). To avoid extra _mfn(...), re-define virt_to_mfn within xen/arch/arm/livepatch.c to handle typesafe MFN. Signed-off-by: Julien Grall Reviewed-by: Stefano Stabellini Acked-by: Konrad Rzeszutek Wilk Acked-by: Ross Lagerwall --- Cc: Ross Lagerwall Changes in v2: - Add Stefano's reviewed-by - Still missing an ack from Konrad and/or Ross. Changes in v3: - Add Konrad's acked-by --- xen/arch/arm/livepatch.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/xen/arch/arm/livepatch.c b/xen/arch/arm/livepatch.c index de95e54744..3e53524365 100644 --- a/xen/arch/arm/livepatch.c +++ b/xen/arch/arm/livepatch.c @@ -12,6 +12,10 @@ #include #include +/* Override macros from asm/page.h to make them work with mfn_t */ +#undef virt_to_mfn +#define virt_to_mfn(va) _mfn(__virt_to_mfn(va)) + void *vmap_of_xen_text; int arch_livepatch_quiesce(void) @@ -22,7 +26,7 @@ int arch_livepatch_quiesce(void) if ( vmap_of_xen_text ) return -EINVAL; - text_mfn = _mfn(virt_to_mfn(_start)); + text_mfn = virt_to_mfn(_start); text_order = get_order_from_bytes(_end - _start); /* From patchwork Fri Jun 30 15:54:23 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 106726 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp2507441qge; Fri, 30 Jun 2017 08:57:03 -0700 (PDT) X-Received: by 10.36.48.146 with SMTP id q140mr8074953itq.59.1498838223198; Fri, 30 Jun 2017 08:57:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1498838223; cv=none; d=google.com; s=arc-20160816; b=VvvDAjy6cWcvRa3L0FALGjWvkSKH4cjRh8vQ3pJ4UQCeYBkE3mAkJUy85jxna/qV/0 ucvWbwZFNWEIjRKsH09BoKY97DXHFLhLoZnmVseYhbwRHKkovAWou3bkuQSbtiJNrE39 QV/twC8uu9weLnyNn9/iAEgNIXSfVuVBu7c6If0OzMlF2QxaIB2bMTTTUJ9SvjsIEiTG fiR9gPItMySHaLJNuVW1nGwQZTWu/6RaCfI1HMGudaUP92A4q78hySjTWtshhFCZ/dtq iac/fAWcQjY6NnCrrKN9a2CcRCicELG79t/9eMKspO3Gz0sl0IlCHqzYCxxjwnDu43Kv KgPg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-unsubscribe:list-id :precedence:subject:cc:references:in-reply-to:message-id:date:to :from:arc-authentication-results; bh=a330b9sTmVWtqdXfbFXpIRARroQlAzQC802gHfQKx2U=; b=RPMcpbsl7qWTK3KM+SQjZluFjNd+RR6K96vRlj/TrAKCVPEnpBal7C+CaQo7Ksf478 BYFQfXSSelTrtMxF6eGRDygk8TK08IUeo4ldIuzCpYtQcVBaWrlQBUlxCVfl2LWeadID 7/nRFKPfuFYUGPZgYw4eRn4dxwyXO89Bv+z/eBfpB2v02zrpZcdFHk0LbMekv8cxk5I5 EGv9Hnk+UoVYFSwKfpnSce9moYCW/20TAPEPKzImBGUtRG/AZeTAW2CocsdxQO452MsP qjdwYWLElR+GzlIlTtUdQV5fTl9z5C9nB6HRLf1BsY6VNSw1PxuVtHojdeZGXAPz2mqg LjIg== ARC-Authentication-Results: i=1; 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 Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id v133si4389464itf.8.2017.06.30.08.57.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 30 Jun 2017 08:57: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 1dQyFr-0000Un-RD; Fri, 30 Jun 2017 15:54:47 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dQyFp-0000Ru-Tm for xen-devel@lists.xen.org; Fri, 30 Jun 2017 15:54:46 +0000 Received: from [85.158.139.211] by server-6.bemta-5.messagelabs.com id 45/33-02175-54476595; Fri, 30 Jun 2017 15:54:45 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrMLMWRWlGSWpSXmKPExsVysyfVTdelJCz S4O1uY4slHxezODB6HN39mymAMYo1My8pvyKBNePrzaWMBYukKlYvmcHWwLhRqIuRi0NIYBOj xJbFH1ggnNNAzo9ZbF2MnBxsApoSdz5/YgKxRQSkJa59vswIYjMLOEi8+XiPBcQWFnCXuLOvC yzOIqAq0Tj3P1g9r4ClxK22LrAaCQF5iV1tF1lBbE4BK4nj/x6A1QgB1byedZVlAiP3AkaGVY waxalFZalFuoZmeklFmekZJbmJmTm6hgamermpxcWJ6ak5iUnFesn5uZsYgR5mAIIdjOdPex5 ilORgUhLlXXktNFKILyk/pTIjsTgjvqg0J7X4EKMMB4eSBO+aorBIIcGi1PTUirTMHGCowaQl OHiURHhlg4DSvMUFibnFmekQqVOMuhyvJvz/xiTEkpeflyolzpsOMkMApCijNA9uBCzsLzHKS gnzMgIdJcRTkFqUm1mCKv+KUZyDUUmY9yTIFJ7MvBK4Ta+AjmACOkJ4RgjIESWJCCmpBkbGQj n/BVJN958H/mspY5HVEsn4tfSopdW+zaWWXK/UbDwjLWVaWH6IvLlb/EMv++Qk/bhM7rtiinz q3E0zr3yRUVwzSeqjr2+6DFOd2bckh7Ubrijxr+jrOPQx251TS1Frheq3G9FV6q2qzi5TZPXl mM7v7Mzf42FeLMVy6QXv/fg0f92NSizFGYmGWsxFxYkA9GdZZ3YCAAA= X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-6.tower-206.messagelabs.com!1498838084!100669901!1 X-Originating-IP: [217.140.101.70] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.25; banners=-,-,- X-VirusChecked: Checked Received: (qmail 23156 invoked from network); 30 Jun 2017 15:54:44 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-6.tower-206.messagelabs.com with SMTP; 30 Jun 2017 15:54:44 -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 14BC080D; Fri, 30 Jun 2017 08:54:44 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.206.53]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 765943F41F; Fri, 30 Jun 2017 08:54:43 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Fri, 30 Jun 2017 16:54:23 +0100 Message-Id: <20170630155431.23824-9-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170630155431.23824-1-julien.grall@arm.com> References: <20170630155431.23824-1-julien.grall@arm.com> Cc: Julien Grall , sstabellini@kernel.org Subject: [Xen-devel] [PATCH v3 08/16] xen/arm: create_xen_entries: Use typesafe 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" Add a bit more safety when using create_xen_entries. Also when destroying/modifying mapping, the MFN is currently not used. Rather than passing _mfn(0) use INVALID_MFN to stay consistent with the other usage. Signed-off-by: Julien Grall Reviewed-by: Stefano Stabellini --- Changes in v2: - Add Stefano's reviewed-by --- xen/arch/arm/mm.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c index 1e9e342fd3..c732771444 100644 --- a/xen/arch/arm/mm.c +++ b/xen/arch/arm/mm.c @@ -980,7 +980,7 @@ enum xenmap_operation { static int create_xen_entries(enum xenmap_operation op, unsigned long virt, - unsigned long mfn, + mfn_t mfn, unsigned long nr_mfns, unsigned int ai) { @@ -989,7 +989,7 @@ static int create_xen_entries(enum xenmap_operation op, lpae_t pte; lpae_t *third = NULL; - for(; addr < addr_end; addr += PAGE_SIZE, mfn++) + for(; addr < addr_end; addr += PAGE_SIZE, mfn = mfn_add(mfn, 1)) { if ( !xen_second[second_linear_offset(addr)].pt.valid || !xen_second[second_linear_offset(addr)].pt.table ) @@ -1010,13 +1010,13 @@ static int create_xen_entries(enum xenmap_operation op, case RESERVE: if ( third[third_table_offset(addr)].pt.valid ) { - printk("create_xen_entries: trying to replace an existing mapping addr=%lx mfn=%lx\n", - addr, mfn); + printk("create_xen_entries: trying to replace an existing mapping addr=%lx mfn=%"PRI_mfn"\n", + addr, mfn_x(mfn)); return -EINVAL; } if ( op == RESERVE ) break; - pte = mfn_to_xen_entry(_mfn(mfn), ai); + pte = mfn_to_xen_entry(mfn, ai); pte.pt.table = 1; write_pte(&third[third_table_offset(addr)], pte); break; @@ -1061,24 +1061,25 @@ int map_pages_to_xen(unsigned long virt, unsigned long nr_mfns, unsigned int flags) { - return create_xen_entries(INSERT, virt, mfn, nr_mfns, flags); + return create_xen_entries(INSERT, virt, _mfn(mfn), nr_mfns, flags); } int populate_pt_range(unsigned long virt, unsigned long mfn, unsigned long nr_mfns) { - return create_xen_entries(RESERVE, virt, mfn, nr_mfns, 0); + return create_xen_entries(RESERVE, virt, _mfn(mfn), nr_mfns, 0); } int destroy_xen_mappings(unsigned long v, unsigned long e) { - return create_xen_entries(REMOVE, v, 0, (e - v) >> PAGE_SHIFT, 0); + return create_xen_entries(REMOVE, v, INVALID_MFN, (e - v) >> PAGE_SHIFT, 0); } int modify_xen_mappings(unsigned long s, unsigned long e, unsigned int flags) { ASSERT((flags & (PTE_NX | PTE_RO)) == flags); - return create_xen_entries(MODIFY, s, 0, (e - s) >> PAGE_SHIFT, flags); + return create_xen_entries(MODIFY, s, INVALID_MFN, (e - s) >> PAGE_SHIFT, + flags); } enum mg { mg_clear, mg_ro, mg_rw, mg_rx }; From patchwork Fri Jun 30 15:54:24 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 106724 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp2507208qge; Fri, 30 Jun 2017 08:56:47 -0700 (PDT) X-Received: by 10.36.73.131 with SMTP id e3mr19732228itd.0.1498838207085; Fri, 30 Jun 2017 08:56:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1498838207; cv=none; d=google.com; s=arc-20160816; b=EUNZdRjV0p+TZVji3h5IO8oF7bZtKMNO6BqYprraUSdnvWVPZYwGBFiZR0b7dodXuF TmE4G3uiRsF/Zi2rsF3m5E1/d6DfdTRGmE1XosKVnfx5oWHrUjOLw9BxYOxcEHAUWDhM a6dnaniLYzGRLBJ6BmntsT61AGf4d+8wY2zimnOig43fibXNCbDsG+zYq98ucZCELfOz vfZEg8327IzbTqGN695QWEaosAxzJoEpC6XPl7Y0k9sC7CRj+YTdNXSXEVtCUVJ5vJ/T YUJmw0HYEI1TsFGOZXV7SBLdVYa7Y1m6aKFdYtudvHxhJhzJbu0q2aKnD2e6/YscaYOl o1mA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-unsubscribe:list-id :precedence:subject:cc:references:in-reply-to:message-id:date:to :from:arc-authentication-results; bh=L99LsRnIf40MyFI6fB/y/j+eX0s0sGQjanNXbI61sb0=; b=oCd4ZJQuZSTuzd1pkKzkW/8J8lnbOgIbDboivKWSNOb3nbB2B6Tny4lK8i8x9zdFhu i5kN8rBy6wdK7I5WOM/uduaQ1lJCKnIsUs7q9Axak8oOXEJKcr6fg8JhFsDtx5d1lGbY csK1Mvzkdz4/PJImJFnvnh3CDhd4EPUd4WLLVFwZ+uddaN/Ah0kJnmuM8+qGLnb5WmOo GGhPqPQemCOkiktnpLk9meD/bPOhQ0UKAYAXbIvwntLcpvmatWya51jd9ToAmEP0WQWy FJHdWb7W3zq+4k+e5vKXcAIG37Zc1iS7vYxaULSiP727Kao0E/WFEtuM40XlS7g0Qr6+ K7RA== ARC-Authentication-Results: i=1; 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 Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id o126si3527555ioo.136.2017.06.30.08.56.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 30 Jun 2017 08:56:47 -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 1dQyFu-0000ZV-OQ; Fri, 30 Jun 2017 15:54:50 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dQyFt-0000Ru-Gj for xen-devel@lists.xen.org; Fri, 30 Jun 2017 15:54:49 +0000 Received: from [85.158.139.211] by server-6.bemta-5.messagelabs.com id 23/53-02175-94476595; Fri, 30 Jun 2017 15:54:49 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrALMWRWlGSWpSXmKPExsVysyfVTdetJCz S4NlMLoslHxezODB6HN39mymAMYo1My8pvyKBNePxxpksBb+KKp6uncnSwLg/qouRi0NIYDOj xLQ9V1i7GDmBnNOMEk1va0FsNgFNiTufPzGB2CIC0hLXPl9m7GLk4GAWiJL4P40TJCws4CPR9 nIrWAmLgKrErld7GUFsXgErifX/dzKD2BIC8hK72i6CjecEih//94AJYpWlxOtZV1kmMHIvYG RYxahenFpUllqka6GXVJSZnlGSm5iZo2toYKqXm1pcnJiempOYVKyXnJ+7iRHoWwYg2MF4sNn 5EKMkB5OSKO/Ka6GRQnxJ+SmVGYnFGfFFpTmpxYcYZTg4lCR4FYvDIoUEi1LTUyvSMnOAQQaT luDgURLhlQ0CSvMWFyTmFmemQ6ROMepyvJrw/xuTEEtefl6qlDjvqyKgIgGQoozSPLgRsIC/x CgrJczLCHSUEE9BalFuZgmq/CtGcQ5GJWFeNpBLeDLzSuA2vQI6ggnoCOEZISBHlCQipKQaGI uYp4m/nmkfsE7v+72TJz/nS/9onPCwR61MIzfmiP1+xQ7x1rW9j13b7xTFf9v3guNA1tnKeTN ehl2PuGq1meWudmZM/EW96F3CEpEiC1S5r5y5ZerkGvP0gzpPy5X96e/kP/lIPHi4/3qfNsOz vu9y8/bO2d8bVP9zsWxp4dtVCZpqO64nCCixFGckGmoxFxUnAgAOyxBBcwIAAA== X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-7.tower-206.messagelabs.com!1498838085!97976173!1 X-Originating-IP: [217.140.101.70] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.25; banners=-,-,- X-VirusChecked: Checked Received: (qmail 54643 invoked from network); 30 Jun 2017 15:54:45 -0000 Received: from usa-sjc-mx-foss1.foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-7.tower-206.messagelabs.com with SMTP; 30 Jun 2017 15:54:45 -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 154EB15AD; Fri, 30 Jun 2017 08:54:45 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.206.53]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 508E33F41F; Fri, 30 Jun 2017 08:54:44 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Fri, 30 Jun 2017 16:54:24 +0100 Message-Id: <20170630155431.23824-10-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170630155431.23824-1-julien.grall@arm.com> References: <20170630155431.23824-1-julien.grall@arm.com> Cc: proskurin@sec.in.tum.de, Julien Grall , sstabellini@kernel.org Subject: [Xen-devel] [PATCH v3 09/16] xen/arm: Move LPAE definition in a separate header 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" page.h is getting bigger. Move out every LPAE definitions in a separate header. There is no functional changes. Signed-off-by: Julien Grall Reviewed-by: Stefano Stabellini Reviewed-by: Sergej Proskurin --- Cc: proskurin@sec.in.tum.de Changes in v2: - Move comment after the #endif rather than before - Add Stefano's reviewed-by --- xen/include/asm-arm/lpae.h | 169 +++++++++++++++++++++++++++++++++++++++++++++ xen/include/asm-arm/page.h | 152 +--------------------------------------- 2 files changed, 170 insertions(+), 151 deletions(-) create mode 100644 xen/include/asm-arm/lpae.h diff --git a/xen/include/asm-arm/lpae.h b/xen/include/asm-arm/lpae.h new file mode 100644 index 0000000000..ad8c571ea5 --- /dev/null +++ b/xen/include/asm-arm/lpae.h @@ -0,0 +1,169 @@ +#ifndef __ARM_LPAE_H__ +#define __ARM_LPAE_H__ + +#ifndef __ASSEMBLY__ + +/* WARNING! Unlike the Intel pagetable code, where l1 is the lowest + * level and l4 is the root of the trie, the ARM pagetables follow ARM's + * documentation: the levels are called first, second &c in the order + * that the MMU walks them (i.e. "first" is the root of the trie). */ + +/****************************************************************************** + * ARMv7-A LPAE pagetables: 3-level trie, mapping 40-bit input to + * 40-bit output addresses. Tables at all levels have 512 64-bit entries + * (i.e. are 4Kb long). + * + * The bit-shuffling that has the permission bits in branch nodes in a + * different place from those in leaf nodes seems to be to allow linear + * pagetable tricks. If we're not doing that then the set of permission + * bits that's not in use in a given node type can be used as + * extra software-defined bits. */ + +typedef struct __packed { + /* These are used in all kinds of entry. */ + unsigned long valid:1; /* Valid mapping */ + unsigned long table:1; /* == 1 in 4k map entries too */ + + /* These ten bits are only used in Block entries and are ignored + * in Table entries. */ + unsigned long ai:3; /* Attribute Index */ + unsigned long ns:1; /* Not-Secure */ + unsigned long user:1; /* User-visible */ + unsigned long ro:1; /* Read-Only */ + unsigned long sh:2; /* Shareability */ + unsigned long af:1; /* Access Flag */ + unsigned long ng:1; /* Not-Global */ + + /* The base address must be appropriately aligned for Block entries */ + unsigned long long base:36; /* Base address of block or next table */ + unsigned long sbz:4; /* Must be zero */ + + /* These seven bits are only used in Block entries and are ignored + * in Table entries. */ + unsigned long contig:1; /* In a block of 16 contiguous entries */ + unsigned long pxn:1; /* Privileged-XN */ + unsigned long xn:1; /* eXecute-Never */ + unsigned long avail:4; /* Ignored by hardware */ + + /* These 5 bits are only used in Table entries and are ignored in + * Block entries */ + unsigned long pxnt:1; /* Privileged-XN */ + unsigned long xnt:1; /* eXecute-Never */ + unsigned long apt:2; /* Access Permissions */ + unsigned long nst:1; /* Not-Secure */ +} lpae_pt_t; + +/* The p2m tables have almost the same layout, but some of the permission + * and cache-control bits are laid out differently (or missing) */ +typedef struct __packed { + /* These are used in all kinds of entry. */ + unsigned long valid:1; /* Valid mapping */ + unsigned long table:1; /* == 1 in 4k map entries too */ + + /* These ten bits are only used in Block entries and are ignored + * in Table entries. */ + unsigned long mattr:4; /* Memory Attributes */ + unsigned long read:1; /* Read access */ + unsigned long write:1; /* Write access */ + unsigned long sh:2; /* Shareability */ + unsigned long af:1; /* Access Flag */ + unsigned long sbz4:1; + + /* The base address must be appropriately aligned for Block entries */ + unsigned long long base:36; /* Base address of block or next table */ + unsigned long sbz3:4; + + /* These seven bits are only used in Block entries and are ignored + * in Table entries. */ + unsigned long contig:1; /* In a block of 16 contiguous entries */ + unsigned long sbz2:1; + unsigned long xn:1; /* eXecute-Never */ + unsigned long type:4; /* Ignore by hardware. Used to store p2m types */ + + unsigned long sbz1:5; +} lpae_p2m_t; + +/* Permission mask: xn, write, read */ +#define P2M_PERM_MASK (0x00400000000000C0ULL) +#define P2M_CLEAR_PERM(pte) ((pte).bits & ~P2M_PERM_MASK) + +/* + * Walk is the common bits of p2m and pt entries which are needed to + * simply walk the table (e.g. for debug). + */ +typedef struct __packed { + /* These are used in all kinds of entry. */ + unsigned long valid:1; /* Valid mapping */ + unsigned long table:1; /* == 1 in 4k map entries too */ + + unsigned long pad2:10; + + /* The base address must be appropriately aligned for Block entries */ + unsigned long long base:36; /* Base address of block or next table */ + + unsigned long pad1:16; +} lpae_walk_t; + +typedef union { + uint64_t bits; + lpae_pt_t pt; + lpae_p2m_t p2m; + lpae_walk_t walk; +} lpae_t; + +#endif /* __ASSEMBLY__ */ + +/* + * These numbers add up to a 48-bit input address space. + * + * On 32-bit the zeroeth level does not exist, therefore the total is + * 39-bits. The ARMv7-A architecture actually specifies a 40-bit input + * address space for the p2m, with an 8K (1024-entry) top-level table. + * However Xen only supports 16GB of RAM on 32-bit ARM systems and + * therefore 39-bits are sufficient. + */ + +#define LPAE_SHIFT 9 +#define LPAE_ENTRIES (_AC(1,U) << LPAE_SHIFT) +#define LPAE_ENTRY_MASK (LPAE_ENTRIES - 1) + +#define THIRD_SHIFT (PAGE_SHIFT) +#define THIRD_ORDER (THIRD_SHIFT - PAGE_SHIFT) +#define THIRD_SIZE ((paddr_t)1 << THIRD_SHIFT) +#define THIRD_MASK (~(THIRD_SIZE - 1)) +#define SECOND_SHIFT (THIRD_SHIFT + LPAE_SHIFT) +#define SECOND_ORDER (SECOND_SHIFT - PAGE_SHIFT) +#define SECOND_SIZE ((paddr_t)1 << SECOND_SHIFT) +#define SECOND_MASK (~(SECOND_SIZE - 1)) +#define FIRST_SHIFT (SECOND_SHIFT + LPAE_SHIFT) +#define FIRST_ORDER (FIRST_SHIFT - PAGE_SHIFT) +#define FIRST_SIZE ((paddr_t)1 << FIRST_SHIFT) +#define FIRST_MASK (~(FIRST_SIZE - 1)) +#define ZEROETH_SHIFT (FIRST_SHIFT + LPAE_SHIFT) +#define ZEROETH_ORDER (ZEROETH_SHIFT - PAGE_SHIFT) +#define ZEROETH_SIZE ((paddr_t)1 << ZEROETH_SHIFT) +#define ZEROETH_MASK (~(ZEROETH_SIZE - 1)) + +/* Calculate the offsets into the pagetables for a given VA */ +#define zeroeth_linear_offset(va) ((va) >> ZEROETH_SHIFT) +#define first_linear_offset(va) ((va) >> FIRST_SHIFT) +#define second_linear_offset(va) ((va) >> SECOND_SHIFT) +#define third_linear_offset(va) ((va) >> THIRD_SHIFT) + +#define TABLE_OFFSET(offs) ((unsigned int)(offs) & LPAE_ENTRY_MASK) +#define first_table_offset(va) TABLE_OFFSET(first_linear_offset(va)) +#define second_table_offset(va) TABLE_OFFSET(second_linear_offset(va)) +#define third_table_offset(va) TABLE_OFFSET(third_linear_offset(va)) +#define zeroeth_table_offset(va) TABLE_OFFSET(zeroeth_linear_offset(va)) + +#endif /* __ARM_LPAE_H__ */ + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * tab-width: 4 + * indent-tabs-mode: nil + * End: + */ diff --git a/xen/include/asm-arm/page.h b/xen/include/asm-arm/page.h index 3670ab665d..cef2f28914 100644 --- a/xen/include/asm-arm/page.h +++ b/xen/include/asm-arm/page.h @@ -3,6 +3,7 @@ #include #include +#include #ifdef CONFIG_ARM_64 #define PADDR_BITS 48 @@ -97,114 +98,6 @@ #include #include -/* WARNING! Unlike the Intel pagetable code, where l1 is the lowest - * level and l4 is the root of the trie, the ARM pagetables follow ARM's - * documentation: the levels are called first, second &c in the order - * that the MMU walks them (i.e. "first" is the root of the trie). */ - -/****************************************************************************** - * ARMv7-A LPAE pagetables: 3-level trie, mapping 40-bit input to - * 40-bit output addresses. Tables at all levels have 512 64-bit entries - * (i.e. are 4Kb long). - * - * The bit-shuffling that has the permission bits in branch nodes in a - * different place from those in leaf nodes seems to be to allow linear - * pagetable tricks. If we're not doing that then the set of permission - * bits that's not in use in a given node type can be used as - * extra software-defined bits. */ - -typedef struct __packed { - /* These are used in all kinds of entry. */ - unsigned long valid:1; /* Valid mapping */ - unsigned long table:1; /* == 1 in 4k map entries too */ - - /* These ten bits are only used in Block entries and are ignored - * in Table entries. */ - unsigned long ai:3; /* Attribute Index */ - unsigned long ns:1; /* Not-Secure */ - unsigned long user:1; /* User-visible */ - unsigned long ro:1; /* Read-Only */ - unsigned long sh:2; /* Shareability */ - unsigned long af:1; /* Access Flag */ - unsigned long ng:1; /* Not-Global */ - - /* The base address must be appropriately aligned for Block entries */ - unsigned long long base:36; /* Base address of block or next table */ - unsigned long sbz:4; /* Must be zero */ - - /* These seven bits are only used in Block entries and are ignored - * in Table entries. */ - unsigned long contig:1; /* In a block of 16 contiguous entries */ - unsigned long pxn:1; /* Privileged-XN */ - unsigned long xn:1; /* eXecute-Never */ - unsigned long avail:4; /* Ignored by hardware */ - - /* These 5 bits are only used in Table entries and are ignored in - * Block entries */ - unsigned long pxnt:1; /* Privileged-XN */ - unsigned long xnt:1; /* eXecute-Never */ - unsigned long apt:2; /* Access Permissions */ - unsigned long nst:1; /* Not-Secure */ -} lpae_pt_t; - -/* The p2m tables have almost the same layout, but some of the permission - * and cache-control bits are laid out differently (or missing) */ -typedef struct __packed { - /* These are used in all kinds of entry. */ - unsigned long valid:1; /* Valid mapping */ - unsigned long table:1; /* == 1 in 4k map entries too */ - - /* These ten bits are only used in Block entries and are ignored - * in Table entries. */ - unsigned long mattr:4; /* Memory Attributes */ - unsigned long read:1; /* Read access */ - unsigned long write:1; /* Write access */ - unsigned long sh:2; /* Shareability */ - unsigned long af:1; /* Access Flag */ - unsigned long sbz4:1; - - /* The base address must be appropriately aligned for Block entries */ - unsigned long long base:36; /* Base address of block or next table */ - unsigned long sbz3:4; - - /* These seven bits are only used in Block entries and are ignored - * in Table entries. */ - unsigned long contig:1; /* In a block of 16 contiguous entries */ - unsigned long sbz2:1; - unsigned long xn:1; /* eXecute-Never */ - unsigned long type:4; /* Ignore by hardware. Used to store p2m types */ - - unsigned long sbz1:5; -} lpae_p2m_t; - -/* Permission mask: xn, write, read */ -#define P2M_PERM_MASK (0x00400000000000C0ULL) -#define P2M_CLEAR_PERM(pte) ((pte).bits & ~P2M_PERM_MASK) - -/* - * Walk is the common bits of p2m and pt entries which are needed to - * simply walk the table (e.g. for debug). - */ -typedef struct __packed { - /* These are used in all kinds of entry. */ - unsigned long valid:1; /* Valid mapping */ - unsigned long table:1; /* == 1 in 4k map entries too */ - - unsigned long pad2:10; - - /* The base address must be appropriately aligned for Block entries */ - unsigned long long base:36; /* Base address of block or next table */ - - unsigned long pad1:16; -} lpae_walk_t; - -typedef union { - uint64_t bits; - lpae_pt_t pt; - lpae_p2m_t p2m; - lpae_walk_t walk; -} lpae_t; - #if defined(CONFIG_ARM_32) # include #elif defined(CONFIG_ARM_64) @@ -390,49 +283,6 @@ static inline int gva_to_ipa(vaddr_t va, paddr_t *paddr, unsigned int flags) #endif /* __ASSEMBLY__ */ -/* - * These numbers add up to a 48-bit input address space. - * - * On 32-bit the zeroeth level does not exist, therefore the total is - * 39-bits. The ARMv7-A architecture actually specifies a 40-bit input - * address space for the p2m, with an 8K (1024-entry) top-level table. - * However Xen only supports 16GB of RAM on 32-bit ARM systems and - * therefore 39-bits are sufficient. - */ - -#define LPAE_SHIFT 9 -#define LPAE_ENTRIES (_AC(1,U) << LPAE_SHIFT) -#define LPAE_ENTRY_MASK (LPAE_ENTRIES - 1) - -#define THIRD_SHIFT (PAGE_SHIFT) -#define THIRD_ORDER (THIRD_SHIFT - PAGE_SHIFT) -#define THIRD_SIZE ((paddr_t)1 << THIRD_SHIFT) -#define THIRD_MASK (~(THIRD_SIZE - 1)) -#define SECOND_SHIFT (THIRD_SHIFT + LPAE_SHIFT) -#define SECOND_ORDER (SECOND_SHIFT - PAGE_SHIFT) -#define SECOND_SIZE ((paddr_t)1 << SECOND_SHIFT) -#define SECOND_MASK (~(SECOND_SIZE - 1)) -#define FIRST_SHIFT (SECOND_SHIFT + LPAE_SHIFT) -#define FIRST_ORDER (FIRST_SHIFT - PAGE_SHIFT) -#define FIRST_SIZE ((paddr_t)1 << FIRST_SHIFT) -#define FIRST_MASK (~(FIRST_SIZE - 1)) -#define ZEROETH_SHIFT (FIRST_SHIFT + LPAE_SHIFT) -#define ZEROETH_ORDER (ZEROETH_SHIFT - PAGE_SHIFT) -#define ZEROETH_SIZE ((paddr_t)1 << ZEROETH_SHIFT) -#define ZEROETH_MASK (~(ZEROETH_SIZE - 1)) - -/* Calculate the offsets into the pagetables for a given VA */ -#define zeroeth_linear_offset(va) ((va) >> ZEROETH_SHIFT) -#define first_linear_offset(va) ((va) >> FIRST_SHIFT) -#define second_linear_offset(va) ((va) >> SECOND_SHIFT) -#define third_linear_offset(va) ((va) >> THIRD_SHIFT) - -#define TABLE_OFFSET(offs) ((unsigned int)(offs) & LPAE_ENTRY_MASK) -#define first_table_offset(va) TABLE_OFFSET(first_linear_offset(va)) -#define second_table_offset(va) TABLE_OFFSET(second_linear_offset(va)) -#define third_table_offset(va) TABLE_OFFSET(third_linear_offset(va)) -#define zeroeth_table_offset(va) TABLE_OFFSET(zeroeth_linear_offset(va)) - #define PAGE_ALIGN(x) (((x) + PAGE_SIZE - 1) & PAGE_MASK) #endif /* __ARM_PAGE_H__ */ From patchwork Fri Jun 30 15:54:25 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 106737 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp2507582qge; Fri, 30 Jun 2017 08:57:14 -0700 (PDT) X-Received: by 10.36.89.139 with SMTP id p133mr20294199itb.5.1498838233979; Fri, 30 Jun 2017 08:57:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1498838233; cv=none; d=google.com; s=arc-20160816; b=RvodywgK+2AfEUqv7OyXgOo+AQbTRxRKqPGjZkSN2jQYtjh4u+30eaCuOPjVKTomeg v5iCrv0urBCbNfyN5qbnjoCBXArKoW4BHnTOQR5aLOZG5iX0L/uNki1NETt1NDMq6jxd XvxUBw9K+vjHKIH72xId9Io+p1OMlZtj8znYkkWFUG9MDgQXJxusTy47pX5Ts4l4Q591 B6LaVUWI/HIxiygSpmETUBF/JYs5DdrAYlBEKfo+MmbPBG4rPNUmHIHNrW/8c6hSj5m9 L/RCTWMMOVYNiRge/lzycSSUhV3/lJQbtoIjfsCSPF3QieME/mKP/unFtJTpCAT9Fq5V v83w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-unsubscribe:list-id :precedence:subject:cc:references:in-reply-to:message-id:date:to :from:arc-authentication-results; bh=sLugTw8BtoeI/HsIamyWERIzKUqVWODS3dVKLrfyehI=; b=nBEJKReshAYHplQuxR22gqtdxPc+NYhvPryfGh6tpdPxklWsFUWMCgqvJQlI622Asj L6hk9WCyLaQvNq6qfNOrMf1GNFsEoqvmtKlD2QxlM60Sjq6RUEbIuIuNCommLwjsuitL bZ546lSk7+66f5+YxdduJFJNW14X2LCn17lD+x7+9Xa17KXIE/5OhaJjaVYFwX89iRhY MfpY+75rIMXjyWeSeTKxXJgxPHf06aZEJjQq8gFFU+W3T+91Qt6qAt+aqh+QO5goB21Q 5OjSHjKhH2aKWqGeUiTIYCx+SWbBBdTwr34kyooDbyOaQW2oMA5Odi2/gArY/LJoiXc7 Te8A== ARC-Authentication-Results: i=1; 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 Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id 191si7815345iof.51.2017.06.30.08.57.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 30 Jun 2017 08:57:13 -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 1dQyFu-0000XV-3X; Fri, 30 Jun 2017 15:54:50 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dQyFs-0000Ut-BL for xen-devel@lists.xen.org; Fri, 30 Jun 2017 15:54:48 +0000 Received: from [193.109.254.147] by server-2.bemta-6.messagelabs.com id DF/53-03032-74476595; Fri, 30 Jun 2017 15:54:47 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrPLMWRWlGSWpSXmKPExsVysyfVTdetJCz SYF+DucWSj4tZHBg9ju7+zRTAGMWamZeUX5HAmrFvxVv2gkuqFUueCDcwdst0MXJxCAlsYpR4 /HMfC4RzmlHi08TjbF2MnBxsApoSdz5/YgKxRQSkJa59vszYxcjBwSwQJfF/GieIKSzgJPF8r xRIBYuAqsTG71uZQWxeASuJ/8dnsYLYEgLyErvaLoLZnEDx4/8egE0UErCUeD3rKssERu4FjA yrGNWLU4vKUot0zfSSijLTM0pyEzNzdA0NzPRyU4uLE9NTcxKTivWS83M3MQI9ywAEOxjnnfA /xCjJwaQkyrvyWmikEF9SfkplRmJxRnxRaU5q8SFGGQ4OJQlexeKwSCHBotT01Iq0zBxgiMGk JTh4lER4ZYOA0rzFBYm5xZnpEKlTjLocryb8/8YkxJKXn5cqJc77qgioSACkKKM0D24ELNwvM cpKCfMyAh0lxFOQWpSbWYIq/4pRnINRSZj3JMgUnsy8ErhNr4COYAI6QnhGCMgRJYkIKakGxv 5Hm79vjf4w6aizx/nJbZ+Me1oW7zc4rphp8Lz2a1bv9n17z2wrXLFEan3eefGf2/+UVF7XybX /sSc7yUWr81OGZvG1dINtwrM6Z56517bWf2/yl2uGa+/+126f4/jn73p3lqm3/Of1b96+SbSq +Izw2v5TxuFlVb17J0apbRXZyumx89i9mJ1KLMUZiYZazEXFiQAl3k4fcgIAAA== X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-14.tower-27.messagelabs.com!1498838086!92584177!1 X-Originating-IP: [217.140.101.70] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.25; banners=-,-,- X-VirusChecked: Checked Received: (qmail 8614 invoked from network); 30 Jun 2017 15:54:46 -0000 Received: from usa-sjc-mx-foss1.foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-14.tower-27.messagelabs.com with SMTP; 30 Jun 2017 15:54:46 -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 1195980D; Fri, 30 Jun 2017 08:54:46 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.206.53]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 50FB43F41F; Fri, 30 Jun 2017 08:54:45 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Fri, 30 Jun 2017 16:54:25 +0100 Message-Id: <20170630155431.23824-11-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170630155431.23824-1-julien.grall@arm.com> References: <20170630155431.23824-1-julien.grall@arm.com> Cc: proskurin@sec.in.tum.de, Julien Grall , sstabellini@kernel.org Subject: [Xen-devel] [PATCH v3 10/16] xen/arm: lpae: Fix comments coding style 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" Also adding one missing full stop + fix description Signed-off-by: Julien Grall Reviewed-by: Stefano Stabellini Reviewed-by: Sergej Proskurin --- Cc: proskurin@sec.in.tum.de I haven't retained Stefano's reviewed-by because of the description update. Changes in v2: - Fix description regarding x86 page-table Changes in v3: - Add Stefano's reviewed-by --- xen/include/asm-arm/lpae.h | 49 ++++++++++++++++++++++++++++++---------------- 1 file changed, 32 insertions(+), 17 deletions(-) diff --git a/xen/include/asm-arm/lpae.h b/xen/include/asm-arm/lpae.h index ad8c571ea5..aa85cb8112 100644 --- a/xen/include/asm-arm/lpae.h +++ b/xen/include/asm-arm/lpae.h @@ -3,10 +3,12 @@ #ifndef __ASSEMBLY__ -/* WARNING! Unlike the Intel pagetable code, where l1 is the lowest - * level and l4 is the root of the trie, the ARM pagetables follow ARM's - * documentation: the levels are called first, second &c in the order - * that the MMU walks them (i.e. "first" is the root of the trie). */ +/* + * WARNING! Unlike the x86 pagetable code, where l1 is the lowest level and + * l4 is the root of the trie, the ARM pagetables follow ARM's documentation: + * the levels are called first, second &c in the order that the MMU walks them + * (i.e. "first" is the root of the trie). + */ /****************************************************************************** * ARMv7-A LPAE pagetables: 3-level trie, mapping 40-bit input to @@ -17,15 +19,18 @@ * different place from those in leaf nodes seems to be to allow linear * pagetable tricks. If we're not doing that then the set of permission * bits that's not in use in a given node type can be used as - * extra software-defined bits. */ + * extra software-defined bits. + */ typedef struct __packed { /* These are used in all kinds of entry. */ unsigned long valid:1; /* Valid mapping */ unsigned long table:1; /* == 1 in 4k map entries too */ - /* These ten bits are only used in Block entries and are ignored - * in Table entries. */ + /* + * These ten bits are only used in Block entries and are ignored + * in Table entries. + */ unsigned long ai:3; /* Attribute Index */ unsigned long ns:1; /* Not-Secure */ unsigned long user:1; /* User-visible */ @@ -38,30 +43,38 @@ typedef struct __packed { unsigned long long base:36; /* Base address of block or next table */ unsigned long sbz:4; /* Must be zero */ - /* These seven bits are only used in Block entries and are ignored - * in Table entries. */ + /* + * These seven bits are only used in Block entries and are ignored + * in Table entries. + */ unsigned long contig:1; /* In a block of 16 contiguous entries */ unsigned long pxn:1; /* Privileged-XN */ unsigned long xn:1; /* eXecute-Never */ unsigned long avail:4; /* Ignored by hardware */ - /* These 5 bits are only used in Table entries and are ignored in - * Block entries */ + /* + * These 5 bits are only used in Table entries and are ignored in + * Block entries. + */ unsigned long pxnt:1; /* Privileged-XN */ unsigned long xnt:1; /* eXecute-Never */ unsigned long apt:2; /* Access Permissions */ unsigned long nst:1; /* Not-Secure */ } lpae_pt_t; -/* The p2m tables have almost the same layout, but some of the permission - * and cache-control bits are laid out differently (or missing) */ +/* + * The p2m tables have almost the same layout, but some of the permission + * and cache-control bits are laid out differently (or missing). + */ typedef struct __packed { /* These are used in all kinds of entry. */ unsigned long valid:1; /* Valid mapping */ unsigned long table:1; /* == 1 in 4k map entries too */ - /* These ten bits are only used in Block entries and are ignored - * in Table entries. */ + /* + * These ten bits are only used in Block entries and are ignored + * in Table entries. + */ unsigned long mattr:4; /* Memory Attributes */ unsigned long read:1; /* Read access */ unsigned long write:1; /* Write access */ @@ -73,8 +86,10 @@ typedef struct __packed { unsigned long long base:36; /* Base address of block or next table */ unsigned long sbz3:4; - /* These seven bits are only used in Block entries and are ignored - * in Table entries. */ + /* + * These seven bits are only used in Block entries and are ignored + * in Table entries. + */ unsigned long contig:1; /* In a block of 16 contiguous entries */ unsigned long sbz2:1; unsigned long xn:1; /* eXecute-Never */ From patchwork Fri Jun 30 15:54:26 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 106739 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp2507642qge; Fri, 30 Jun 2017 08:57:17 -0700 (PDT) X-Received: by 10.107.24.5 with SMTP id 5mr25105404ioy.217.1498838237790; Fri, 30 Jun 2017 08:57:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1498838237; cv=none; d=google.com; s=arc-20160816; b=myrpGRv1xMPzkqzg2FnBeJUVurNCXttC1nMOpH1ZLGrZJ4kI4CUh7i4OxEJ1SS13/A e/lF9o/M7LO+3r6P+pauGYd4ekqfHrYC2Spo/I6VLO+s7qxFjbmQU2HLY0CdFzL5MeSH FZrmDD7WkosIRdyTPHelhaSo+I0VZbX5oy1lqJ9PWq9WHYsSaoXc5H0EhHvuLWWk4oMJ B3+cDKRC5Jk5JKwIK2gQaA+WlolgLGO7BRAJtUIJYKay5i0mnIMbfFvczQvD6qeOrxJJ E0Vfejh4Qi0nFpCF7QAfx9z5JHZbOPE5fNGE0uQzcRI2nE02N5NGTBm/Vr7dKjx5DINH q4wQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-unsubscribe:list-id :precedence:subject:cc:references:in-reply-to:message-id:date:to :from:arc-authentication-results; bh=elwbJdEDphUQt8gB6BSOZQK+qSEKBQpdjtEwpDy8szQ=; b=mDoS+nX5fLujZWOu9coyAx9KxsHrH2XLSFhEAGqo5a3/rztO45vm4O8rZqh93VPz6W vVFo5/7SZbQqN3LU+7l20klGLQoZL/6C+Pa0HLi7PnBytVjBOFRTrLxHvCeoTHXSz6j1 2W6wo/ewLjiHD4OFbWsQk0Op1p/HomuvDcdWz6MRZCSsPmTpc4xLfcorNMjHX113A9ul 0/brHlq00oGb43uVa1k65yMUAiBmr8WaftbCIlgIkN8cCAQUFnzh/INPP00Lg1oxca+J gh7iEYTRtxFhUgbeddPAgVybct/UnmwH01p4XzBqAGbFCiod9V06nUPUKY4GiARzfKlF NiNA== ARC-Authentication-Results: i=1; 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 Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id g10si7750954iog.207.2017.06.30.08.57.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 30 Jun 2017 08:57:17 -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 1dQyFu-0000YX-GO; Fri, 30 Jun 2017 15:54:50 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dQyFt-0000Vz-3p for xen-devel@lists.xen.org; Fri, 30 Jun 2017 15:54:49 +0000 Received: from [85.158.143.35] by server-1.bemta-6.messagelabs.com id 12/98-03577-84476595; Fri, 30 Jun 2017 15:54:48 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrILMWRWlGSWpSXmKPExsVysyfVTde9JCz SYO5+U4slHxezODB6HN39mymAMYo1My8pvyKBNaNtwx7mgjd6Ffef7mBqYOxV6WLk4hAS2Mwo 8XXDdTYI5zSjxLqO4yxdjJwcbAKaEnc+f2ICsUUEpCWufb7M2MXIwcEsECXxfxoniCkskCoxd W88SAWLgKrE9aNPwKp5BawkLn57xgpiSwjIS+xquwhmcwLFj/97AFYjJGAp8XrWVZYJjNwLGB lWMWoUpxaVpRbpGhnoJRVlpmeU5CZm5ugaGpjp5aYWFyemp+YkJhXrJefnbmIEepcBCHYw/lo WcIhRkoNJSZR35bXQSCG+pPyUyozE4oz4otKc1OJDjDIcHEoSvIrFYZFCgkWp6akVaZk5wDCD SUtw8CiJ8MoGAaV5iwsSc4sz0yFSpxh1OV5N+P+NSYglLz8vVUqcNwRkhgBIUUZpHtwIWMhfY pSVEuZlBDpKiKcgtSg3swRV/hWjOAejkjCvM8gUnsy8ErhNr4COYAI6QnhGCMgRJYkIKakGxt DuZStOiylvvPjxwbNHMUfXFT98/Ta88ICgVZHoXx32xc47/K+skpBavct7d9FaTmXd9B/Fh2t EVIqjVpdINInNORo9d/++Zbv73e+vlLZsKy9es3xz2cyMIisHj805i/5L8xW4dquKvhOV63QN ve8w58uivWcZzHiVXc/Pa1hs2cA0RSeqQYmlOCPRUIu5qDgRACWeBj50AgAA X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-10.tower-21.messagelabs.com!1498838087!64493537!1 X-Originating-IP: [217.140.101.70] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.25; banners=-,-,- X-VirusChecked: Checked Received: (qmail 9890 invoked from network); 30 Jun 2017 15:54:47 -0000 Received: from usa-sjc-mx-foss1.foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-10.tower-21.messagelabs.com with SMTP; 30 Jun 2017 15:54:47 -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 0E8CB15B2; Fri, 30 Jun 2017 08:54:47 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.206.53]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 4D1863F41F; Fri, 30 Jun 2017 08:54:46 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Fri, 30 Jun 2017 16:54:26 +0100 Message-Id: <20170630155431.23824-12-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170630155431.23824-1-julien.grall@arm.com> References: <20170630155431.23824-1-julien.grall@arm.com> Cc: proskurin@sec.in.tum.de, Julien Grall , sstabellini@kernel.org Subject: [Xen-devel] [PATCH v3 11/16] xen/arm: p2m: Rename p2m_valid, p2m_table, p2m_mapping and p2m_is_superpage 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 helpers p2m_valid, p2m_table, p2m_mapping and p2m_is_superpage are not specific to the stage-2 translation tables. They can also work on any LPAE translation tables. So rename then to lpae_* and use pte.walk to look for the value of the field. Signed-off-by: Julien Grall Reviewed-by: Stefano Stabellini Reviewed-by: Sergej Proskurin --- Cc: proskurin@sec.in.tum.de s/bool_t/bool/ will be done in a separate patch Changes in v2: - Patch added Changes in v3: - Add Stefano's reviewed-by --- xen/arch/arm/p2m.c | 45 +++++++++++++++++++++++---------------------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c index 3e20a1ec82..381df1f237 100644 --- a/xen/arch/arm/p2m.c +++ b/xen/arch/arm/p2m.c @@ -52,27 +52,27 @@ static const paddr_t level_masks[] = static const uint8_t level_orders[] = { ZEROETH_ORDER, FIRST_ORDER, SECOND_ORDER, THIRD_ORDER }; -static inline bool_t p2m_valid(lpae_t pte) +static inline bool_t lpae_valid(lpae_t pte) { - return pte.p2m.valid; + return pte.walk.valid; } /* * These two can only be used on L0..L2 ptes because L3 mappings set * the table bit and therefore these would return the opposite to what * you would expect. */ -static inline bool_t p2m_table(lpae_t pte) +static inline bool_t lpae_table(lpae_t pte) { - return p2m_valid(pte) && pte.p2m.table; + return lpae_valid(pte) && pte.walk.table; } -static inline bool_t p2m_mapping(lpae_t pte) +static inline bool_t lpae_mapping(lpae_t pte) { - return p2m_valid(pte) && !pte.p2m.table; + return lpae_valid(pte) && !pte.walk.table; } -static inline bool p2m_is_superpage(lpae_t pte, unsigned int level) +static inline bool lpae_is_superpage(lpae_t pte, unsigned int level) { - return (level < 3) && p2m_mapping(pte); + return (level < 3) && lpae_mapping(pte); } static void p2m_flush_tlb(struct p2m_domain *p2m); @@ -281,7 +281,7 @@ static int p2m_next_level(struct p2m_domain *p2m, bool read_only, entry = *table + offset; - if ( !p2m_valid(*entry) ) + if ( !lpae_valid(*entry) ) { if ( read_only ) return GUEST_TABLE_MAP_FAILED; @@ -292,7 +292,7 @@ static int p2m_next_level(struct p2m_domain *p2m, bool read_only, } /* The function p2m_next_level is never called at the 3rd level */ - if ( p2m_mapping(*entry) ) + if ( lpae_mapping(*entry) ) return GUEST_TABLE_SUPER_PAGE; mfn = _mfn(entry->p2m.base); @@ -372,7 +372,7 @@ mfn_t p2m_get_entry(struct p2m_domain *p2m, gfn_t gfn, entry = table[offsets[level]]; - if ( p2m_valid(entry) ) + if ( lpae_valid(entry) ) { *t = entry.p2m.type; @@ -577,7 +577,7 @@ static int p2m_create_table(struct p2m_domain *p2m, lpae_t *entry) lpae_t *p; lpae_t pte; - ASSERT(!p2m_valid(*entry)); + ASSERT(!lpae_valid(*entry)); page = alloc_domheap_page(NULL, 0); if ( page == NULL ) @@ -645,7 +645,7 @@ enum p2m_operation { */ static void p2m_put_l3_page(const lpae_t pte) { - ASSERT(p2m_valid(pte)); + ASSERT(lpae_valid(pte)); /* * TODO: Handle other p2m types @@ -673,11 +673,11 @@ static void p2m_free_entry(struct p2m_domain *p2m, struct page_info *pg; /* Nothing to do if the entry is invalid. */ - if ( !p2m_valid(entry) ) + if ( !lpae_valid(entry) ) return; /* Nothing to do but updating the stats if the entry is a super-page. */ - if ( p2m_is_superpage(entry, level) ) + if ( lpae_is_superpage(entry, level) ) { p2m->stats.mappings[level]--; return; @@ -733,7 +733,7 @@ static bool p2m_split_superpage(struct p2m_domain *p2m, lpae_t *entry, * a superpage. */ ASSERT(level < target); - ASSERT(p2m_is_superpage(*entry, level)); + ASSERT(lpae_is_superpage(*entry, level)); page = alloc_domheap_page(NULL, 0); if ( !page ) @@ -870,7 +870,7 @@ static int __p2m_set_entry(struct p2m_domain *p2m, /* We need to split the original page. */ lpae_t split_pte = *entry; - ASSERT(p2m_is_superpage(*entry, level)); + ASSERT(lpae_is_superpage(*entry, level)); if ( !p2m_split_superpage(p2m, &split_pte, level, target, offsets) ) { @@ -944,12 +944,12 @@ static int __p2m_set_entry(struct p2m_domain *p2m, * sequence when updating the translation table (D4.7.1 in ARM DDI * 0487A.j). */ - if ( p2m_valid(orig_pte) ) + if ( lpae_valid(orig_pte) ) p2m_remove_pte(entry, p2m->clean_pte); if ( mfn_eq(smfn, INVALID_MFN) ) /* Flush can be deferred if the entry is removed */ - p2m->need_flush |= !!p2m_valid(orig_pte); + p2m->need_flush |= !!lpae_valid(orig_pte); else { lpae_t pte = mfn_to_p2m_entry(smfn, t, a); @@ -964,7 +964,7 @@ static int __p2m_set_entry(struct p2m_domain *p2m, * Although, it could be defered when only the permissions are * changed (e.g in case of memaccess). */ - if ( p2m_valid(orig_pte) ) + if ( lpae_valid(orig_pte) ) { if ( likely(!p2m->mem_access_enabled) || P2M_CLEAR_PERM(pte) != P2M_CLEAR_PERM(orig_pte) ) @@ -986,10 +986,11 @@ static int __p2m_set_entry(struct p2m_domain *p2m, * Free the entry only if the original pte was valid and the base * is different (to avoid freeing when permission is changed). */ - if ( p2m_valid(orig_pte) && entry->p2m.base != orig_pte.p2m.base ) + if ( lpae_valid(orig_pte) && entry->p2m.base != orig_pte.p2m.base ) p2m_free_entry(p2m, orig_pte, level); - if ( need_iommu(p2m->domain) && (p2m_valid(orig_pte) || p2m_valid(*entry)) ) + if ( need_iommu(p2m->domain) && + (lpae_valid(orig_pte) || lpae_valid(*entry)) ) rc = iommu_iotlb_flush(p2m->domain, gfn_x(sgfn), 1UL << page_order); else rc = 0; From patchwork Fri Jun 30 15:54:27 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 106734 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp2507546qge; Fri, 30 Jun 2017 08:57:11 -0700 (PDT) X-Received: by 10.107.15.93 with SMTP id x90mr17498388ioi.41.1498838231500; Fri, 30 Jun 2017 08:57:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1498838231; cv=none; d=google.com; s=arc-20160816; b=d9wDcd389atXTdruLm5FwEJphzNujyDi61f8tqBO1+aeyD6kjZYnRAMR5DC2SSYDmr OXuC9YtFsTeKLfYDJDME+3u8lKT4gVzKYxBRk/6pLyDT0hJezzZo9l47QjcIJ+9ZnjWg M6im7OrliLsig6sSG+csn+KSsCBB/bOiLItgdRIw0HLBV3Vryw336OkBQlhq4hmw51m0 v9LnezdcV3W4cCZMXJNtRIxRAcvy4+0Z6Xd480jSqqqIDACfsX1vlWglyW3pT7hDVVIK 8zhGxZXSgW62sCKRqFizHOcBSZsc4R273t6MkBVVQZgNUF0gd/WFIF25Qu86TR68LlCT r1ng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-unsubscribe:list-id :precedence:subject:cc:references:in-reply-to:message-id:date:to :from:arc-authentication-results; bh=CKjfP5QPcHmSBb6vHDYpL5yYn/lyeWakHRBU/SzAcC4=; b=a4ibTTTsaY4paAzX0pUDp5M9oWyAClTYvI1H7aB/HJPw9EZhTY5pnEnJzJ1BLEMN57 UYR8tsWYATxoS/2MUH82uHlbJgEeNodhS4ll3VdoltWGU70ehFGPIZeQmrDMxv0pBSO6 qmLUuguMDbqNLI9CzzZ0DN0BMZibv1sdXflRnBu06JtJqWpMLB3ltipZ4Gtl4OnbwbKr Q7iVhVElUa6cdlCFwJdQghUjL5q3tbx2Z7SxpUkb3k3tRM9bhp4HSDZKySWtCfeIkbJp dVKOcm9FIn/b7+j6RRTuvf5+wGnbb245mW8OvCZKHHimiuUy4YF87ZcTPDSFyVeWNcUp zaSw== ARC-Authentication-Results: i=1; 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 Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id z22si8830773iof.16.2017.06.30.08.57.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 30 Jun 2017 08:57:11 -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 1dQyFv-0000aC-14; Fri, 30 Jun 2017 15:54:51 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dQyFt-0000Wp-Vz for xen-devel@lists.xen.org; Fri, 30 Jun 2017 15:54:50 +0000 Received: from [85.158.137.68] by server-12.bemta-3.messagelabs.com id 3F/C7-01862-94476595; Fri, 30 Jun 2017 15:54:49 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrILMWRWlGSWpSXmKPExsVysyfVTdejJCz S4PgyI4slHxezODB6HN39mymAMYo1My8pvyKBNePe15csBdeEKg5vWsvWwLiLv4uRi0NIYDOj xObGiewQzmlGiY3Xu1m6GDk52AQ0Je58/sQEYosISEtc+3yZsYuRg4NZIEri/zROkLCwgKtEz +ONrCA2i4CqxNaJy9lBSngFrCT6poGFJQTkJXa1XQSzOYHCx/89AJsoJGAp8XrWVZYJjNwLGB lWMWoUpxaVpRbpGlnqJRVlpmeU5CZm5ugaGhjr5aYWFyemp+YkJhXrJefnbmIEereegYFxB2P TXr9DjJIcTEqivCuvhUYK8SXlp1RmJBZnxBeV5qQWH2KU4eBQkuCdVxwWKSRYlJqeWpGWmQMM M5i0BAePkgivbBBQmre4IDG3ODMdInWKUZfj1YT/35iEWPLy81KlxHlDQGYIgBRllObBjYCF/ CVGWSlhXkYGBgYhnoLUotzMElT5V4ziHIxKwrzOIFN4MvNK4Da9AjqCCegI4RkhIEeUJCKkpB oYOc59T8tS/dx1YJGUQIrsYoma+IrHS8Q/fUoqWHhLp5D9a0LZzg5JnZOi058KTbgttOzPzht JW4vDvXVf7lvAelzt/NTk26t+3r79dpoff/z3zmKtA7Hn6yWfbju+7/Lz0BmrHKeePiR/tyuh 41i0x4Plr46K6nVZPBDRPSh2rlPVP7t6I+OJECWW4oxEQy3mouJEAKLqQFp0AgAA X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-13.tower-31.messagelabs.com!1498838088!102756310!1 X-Originating-IP: [217.140.101.70] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.19; banners=-,-,- X-VirusChecked: Checked Received: (qmail 50232 invoked from network); 30 Jun 2017 15:54:48 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-13.tower-31.messagelabs.com with SMTP; 30 Jun 2017 15:54:48 -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 0C61F15BE; Fri, 30 Jun 2017 08:54:48 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.206.53]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 496733F41F; Fri, 30 Jun 2017 08:54:47 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Fri, 30 Jun 2017 16:54:27 +0100 Message-Id: <20170630155431.23824-13-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170630155431.23824-1-julien.grall@arm.com> References: <20170630155431.23824-1-julien.grall@arm.com> Cc: proskurin@sec.in.tum.de, Julien Grall , sstabellini@kernel.org Subject: [Xen-devel] [PATCH v3 12/16] xen/arm: p2m: Move lpae_* helpers in lpae.h 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" lpae_* helpers can work on any LPAE translation tables. Move them in lpae.h to allow other part of Xen to use them. Signed-off-by: Julien Grall Reviewed-by: Stefano Stabellini Reviewed-by: Sergej Proskurin --- Cc: proskurin@sec.in.tum.de Changes in v2: - Patch added Changes in v3: - Add Stefano's reviewed-by --- xen/arch/arm/p2m.c | 23 ----------------------- xen/include/asm-arm/lpae.h | 25 +++++++++++++++++++++++++ 2 files changed, 25 insertions(+), 23 deletions(-) diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c index 381df1f237..9b7a580a87 100644 --- a/xen/arch/arm/p2m.c +++ b/xen/arch/arm/p2m.c @@ -52,29 +52,6 @@ static const paddr_t level_masks[] = static const uint8_t level_orders[] = { ZEROETH_ORDER, FIRST_ORDER, SECOND_ORDER, THIRD_ORDER }; -static inline bool_t lpae_valid(lpae_t pte) -{ - return pte.walk.valid; -} -/* - * These two can only be used on L0..L2 ptes because L3 mappings set - * the table bit and therefore these would return the opposite to what - * you would expect. - */ -static inline bool_t lpae_table(lpae_t pte) -{ - return lpae_valid(pte) && pte.walk.table; -} -static inline bool_t lpae_mapping(lpae_t pte) -{ - return lpae_valid(pte) && !pte.walk.table; -} - -static inline bool lpae_is_superpage(lpae_t pte, unsigned int level) -{ - return (level < 3) && lpae_mapping(pte); -} - static void p2m_flush_tlb(struct p2m_domain *p2m); /* Unlock the flush and do a P2M TLB flush if necessary */ diff --git a/xen/include/asm-arm/lpae.h b/xen/include/asm-arm/lpae.h index aa85cb8112..6fbf7c606c 100644 --- a/xen/include/asm-arm/lpae.h +++ b/xen/include/asm-arm/lpae.h @@ -126,6 +126,31 @@ typedef union { lpae_walk_t walk; } lpae_t; +static inline bool_t lpae_valid(lpae_t pte) +{ + return pte.walk.valid; +} + +/* + * These two can only be used on L0..L2 ptes because L3 mappings set + * the table bit and therefore these would return the opposite to what + * you would expect. + */ +static inline bool_t lpae_table(lpae_t pte) +{ + return lpae_valid(pte) && pte.walk.table; +} + +static inline bool_t lpae_mapping(lpae_t pte) +{ + return lpae_valid(pte) && !pte.walk.table; +} + +static inline bool lpae_is_superpage(lpae_t pte, unsigned int level) +{ + return (level < 3) && lpae_mapping(pte); +} + #endif /* __ASSEMBLY__ */ /* From patchwork Fri Jun 30 15:54:28 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 106730 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp2507513qge; Fri, 30 Jun 2017 08:57:09 -0700 (PDT) X-Received: by 10.107.199.198 with SMTP id x189mr22111859iof.14.1498838229092; Fri, 30 Jun 2017 08:57:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1498838229; cv=none; d=google.com; s=arc-20160816; b=uyb9AxJx81yi/5Jd1oKfnpdnjwfsVjFLPgRie7yFnpeLklTAkz6vox7/8Tbhr7a5Nb RFfjli8cWMT5kwqgEec8C3+0U19oANMwSU6WsGM9b4kxQampDE3fUt/40jgO0yl+tmPA oZtdG0pupC7bmp8BZaEeUImzx7JymVYah1BgCtOlukzrboacD8wvlcB7iWtF0QDR2evG qrSmuOOH9HoB3wRiiTLAZtjmfPkr/5i7LeImMNMhfqCZbPHpo2VKv71dCU0MlQsy+fiR G0V8nIxV8hV2a4pvseXx/oyHTswLtmpSrtvgdlYCmGYP0q+vbPwF5cXJhDfJNjwt8muv mQDA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-unsubscribe:list-id :precedence:subject:cc:references:in-reply-to:message-id:date:to :from:arc-authentication-results; bh=9CoTVoylmVKcUFj+vPIkXacT+ACgOM0uNtq035VPmM0=; b=FEnBBhKzND49rRWu5w1gq1A1OibzuAHU4ErTjo/bZH6ln0lgRR3wfxY1Oln1142yzt 3bmtyMu54KvwyuWKeh2D+nVJRhAgx5HmIoygmFQdm2jDTmbepi2JHR2NWHLGmcDqetic a9ydMBfESEl6s5LPjdKNcoxKo9LRwZfPkZ4FtIFafIDocO6p47jkydy6fbEmREHVhFWs 2LPywA4n4iQMo9rGDLVik7hEc4sqa/GTt5t0DjCJmd+egeKYBLnHviB44RaDqWnlep8H QqnDIOGn3dNFE28YT5US8y8pgpgdSp6iGi6cKABgYPa+plIo1M3LcMAGS+2TRAjoqHCu IDdw== ARC-Authentication-Results: i=1; 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 Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id h187si4487458ita.115.2017.06.30.08.57.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 30 Jun 2017 08:57:09 -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 1dQyFx-0000ex-Ki; Fri, 30 Jun 2017 15:54:53 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dQyFw-0000Ut-83 for xen-devel@lists.xen.org; Fri, 30 Jun 2017 15:54:52 +0000 Received: from [85.158.143.35] by server-2.bemta-6.messagelabs.com id 2B/83-03032-C4476595; Fri, 30 Jun 2017 15:54:52 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrOLMWRWlGSWpSXmKPExsVysyfVTdezJCz SYM4EAYslHxezODB6HN39mymAMYo1My8pvyKBNePTiZnMBUsFK5p/zWJpYNzG08XIySEksJlR 4uUchS5GLiD7NKPEvstz2UESbAKaEnc+f2ICsUUEpCWufb7MCGIzCzhIvPl4jwXEFhaIkni7s BksziKgKrF18U2gOAcHr4CVxIP3liBhCQF5iV1tF1lBbE6g8PF/D5gg9lpKvJ51lWUCI/cCRo ZVjBrFqUVlqUW6RgZ6SUWZ6RkluYmZObqGBmZ6uanFxYnpqTmJScV6yfm5mxiB3mUAgh2Mv5Y FHGKU5GBSEuVdeS00UogvKT+lMiOxOCO+qDQntfgQowwHh5IEr2JxWKSQYFFqempFWmYOMMxg 0hIcPEoivLJBQGne4oLE3OLMdIjUKUZjjhVvd31h4ng14f83JiGWvPy8VClx3hCQSQIgpRmle XCDYOF/iVFWSpiXEeg0IZ6C1KLczBJU+VeM4hyMSsK8ziBTeDLzSuD2vQI6hQnoFOEZISCnlC QipKQaGFvOFYdsTPrpOcPF+ME35vMLnry/khQp9Ou0J+fS54sZvrne73swfaKyrHBijIZJxfY f/a9s1DpD+mJndu52FnENmL70rUYWS+pR8/57nwVYNz+/ybHox59t757daZTTTXmz8fu1mMWJ rrpxTNMMjzzKMnwYmDAh+qbEWefPj2av32BU7Ma2zVmJpTgj0VCLuag4EQDNi3W+egIAAA== X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-10.tower-21.messagelabs.com!1498838087!64493537!2 X-Originating-IP: [217.140.101.70] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.25; banners=-,-,- X-VirusChecked: Checked Received: (qmail 10015 invoked from network); 30 Jun 2017 15:54:49 -0000 Received: from usa-sjc-mx-foss1.foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-10.tower-21.messagelabs.com with SMTP; 30 Jun 2017 15:54:49 -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 DA34E1610; Fri, 30 Jun 2017 08:54:48 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.206.53]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 476BC3F41F; Fri, 30 Jun 2017 08:54:48 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Fri, 30 Jun 2017 16:54:28 +0100 Message-Id: <20170630155431.23824-14-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170630155431.23824-1-julien.grall@arm.com> References: <20170630155431.23824-1-julien.grall@arm.com> Cc: Julien Grall , sstabellini@kernel.org Subject: [Xen-devel] [PATCH v3 13/16] xen/arm: mm: Use lpae_valid and lpae_table in create_xen_entries 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" This newly introduced lpae_valid and lpae_table helpers will recude the code and make more readable. Signed-off-by: Julien Grall Reviewed-by: Stefano Stabellini --- Changes in v2: - Patch added Changes in v3: - Add Stefano's reviewed-by --- xen/arch/arm/mm.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c index c732771444..21b3df395f 100644 --- a/xen/arch/arm/mm.c +++ b/xen/arch/arm/mm.c @@ -991,8 +991,7 @@ static int create_xen_entries(enum xenmap_operation op, for(; addr < addr_end; addr += PAGE_SIZE, mfn = mfn_add(mfn, 1)) { - if ( !xen_second[second_linear_offset(addr)].pt.valid || - !xen_second[second_linear_offset(addr)].pt.table ) + if ( !lpae_table(xen_second[second_linear_offset(addr)]) ) { rc = create_xen_table(&xen_second[second_linear_offset(addr)]); if ( rc < 0 ) { @@ -1001,14 +1000,14 @@ static int create_xen_entries(enum xenmap_operation op, } } - BUG_ON(!xen_second[second_linear_offset(addr)].pt.valid); + BUG_ON(!lpae_valid(xen_second[second_linear_offset(addr)])); third = mfn_to_virt(xen_second[second_linear_offset(addr)].pt.base); switch ( op ) { case INSERT: case RESERVE: - if ( third[third_table_offset(addr)].pt.valid ) + if ( lpae_valid(third[third_table_offset(addr)]) ) { printk("create_xen_entries: trying to replace an existing mapping addr=%lx mfn=%"PRI_mfn"\n", addr, mfn_x(mfn)); @@ -1022,7 +1021,7 @@ static int create_xen_entries(enum xenmap_operation op, break; case MODIFY: case REMOVE: - if ( !third[third_table_offset(addr)].pt.valid ) + if ( !lpae_valid(third[third_table_offset(addr)]) ) { printk("create_xen_entries: trying to %s a non-existing mapping addr=%lx\n", op == REMOVE ? "remove" : "modify", addr); From patchwork Fri Jun 30 15:54:29 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 106736 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp2507568qge; Fri, 30 Jun 2017 08:57:13 -0700 (PDT) X-Received: by 10.107.58.86 with SMTP id h83mr20785834ioa.28.1498838233129; Fri, 30 Jun 2017 08:57:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1498838233; cv=none; d=google.com; s=arc-20160816; b=P0lplXdtmlkqfXVvnElg+9InyUGS4GU5IKTH59AOrs2c2E5/AfhomRclKPdpJxFrCf w2zJlRTaLKHuJfGIHi7iiH8s20YB/KZwCEqao9QIE2rphFzJGyd5WKIOgHm8uZTv1aWz yxEITNsN8BiihnIodB0m1Djv7rm06fDKQcxoBDfCY7iQwV2t8uYRp7cAlI+8BTkIv5ZS 6mYp3PiJrMphJnE9BuRB1SoWGKPwysKe4BzSUhowmaeCV8ZL9CRb3Rh2+owNjBVYpZdS OSYTDlUp2GPF+rAuBPz//j0fNqyF0zXSRovlmcUEDpsQMx8Lm2d/VmLjoulCYVa1xopg gHAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-unsubscribe:list-id :precedence:subject:cc:references:in-reply-to:message-id:date:to :from:arc-authentication-results; bh=hKioti75bBe1VwsN4yR5FQ+hgYVNJ/FlmuQNyCH2d8A=; b=brfLYU3FWachqjhKAvxSrYlyAY7idOOuJeyJCDXfUguHzON2L0Y+u3LBb1R9z/oAop rLYV01pz+72jYUb66QCyXdClzrBWWxMpSqhArgq7r76XqiLhpvpsdgdMAAuN7XJNGoxp NfRLCn1TFSg3TsI8E8Dqe03LVClGstF/r+EcWY0g1YmXm8NLyA4eJmeRJPOKXkp6FYNn UXrS0dcifDyWHk3FTLuODGzFdQKeyr/mjqnle3dYhJeO6uORFKZzc97QGevzHlJyXE00 X75BAz7+OTitZZPsjOhNwFLLui55PVUcl1RKjqzeXuZCvqsT3OwvG8uwRJlfHsKGz8g2 KpkQ== ARC-Authentication-Results: i=1; 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 Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id n19si7945829ion.8.2017.06.30.08.57.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 30 Jun 2017 08:57:13 -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 1dQyFx-0000eF-C9; Fri, 30 Jun 2017 15:54:53 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dQyFv-0000ab-IL for xen-devel@lists.xen.org; Fri, 30 Jun 2017 15:54:51 +0000 Received: from [193.109.254.147] by server-11.bemta-6.messagelabs.com id 7C/88-03612-A4476595; Fri, 30 Jun 2017 15:54:50 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrBLMWRWlGSWpSXmKPExsVysyfVTderJCz S4FGnlMWSj4tZHBg9ju7+zRTAGMWamZeUX5HAmjH/xUumgrNSFeuuvGNsYFwp2MXIxSEksJlR 4u2Jj+wQzmlGiakH2hi7GDk52AQ0Je58/sQEYosISEtc+3wZLM4s4CDx5uM9FhBbWCBSomHff 6AaDg4WAVWJrQt8QcK8AlYSR3/sAiuREJCX2NV2kRXE5gSKH//3AGykkIClxOtZV1kmMHIvYG RYxahRnFpUllqka2Sql1SUmZ5RkpuYmaNraGCml5taXJyYnpqTmFSsl5yfu4kR6F8GINjBuGp B4CFGSQ4mJVHelddCI4X4kvJTKjMSizPii0pzUosPMcpwcChJ8K4pCosUEixKTU+tSMvMAQYa TFqCg0dJhFc2CCjNW1yQmFucmQ6ROsVozLHi7a4vTByvJvz/xiTEkpeflyolzvsKZJIASGlGa R7cIFgEXGKUlRLmZQQ6TYinILUoN7MEVf4VozgHo5IwbwjIFJ7MvBK4fa+ATmECOkV4RgjIKS WJCCmpBsaqfsuglJmCW4rCt0q0Kh28F2swN3p/XJbAnMVf/BcXfJp3+HRO646KttoU6+laG3b uWPeTcUpgfXX+s8Oxn/bXvVrmkGF+/XLooRdxDebrAqdzbuYtEeWYGPxT+zWjSkBI1TVZbr51 Lm/Tc7Xy7erlek6ILgyYtPBwfJnIz+ZMD55zr7oW1SqxFGckGmoxFxUnAgB7NXRcewIAAA== X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-2.tower-27.messagelabs.com!1498838089!45457977!1 X-Originating-IP: [217.140.101.70] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.25; banners=-,-,- X-VirusChecked: Checked Received: (qmail 3062 invoked from network); 30 Jun 2017 15:54:50 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-2.tower-27.messagelabs.com with SMTP; 30 Jun 2017 15:54:50 -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 B4606164F; Fri, 30 Jun 2017 08:54:49 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.206.53]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 212543F41F; Fri, 30 Jun 2017 08:54:48 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Fri, 30 Jun 2017 16:54:29 +0100 Message-Id: <20170630155431.23824-15-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170630155431.23824-1-julien.grall@arm.com> References: <20170630155431.23824-1-julien.grall@arm.com> Cc: Julien Grall , sstabellini@kernel.org Subject: [Xen-devel] [PATCH v3 14/16] xen/arm: mm: Introduce temporary variable in create_xen_entries 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" This is improving the code readability and avoid to dereference the table every single time we need to access the entry. Signed-off-by: Julien Grall Reviewed-by: Stefano Stabellini --- Changes in v2: - Patch added Changes in v3: - Add Stefano's reviewed-by --- xen/arch/arm/mm.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c index 21b3df395f..ea4a35ed7a 100644 --- a/xen/arch/arm/mm.c +++ b/xen/arch/arm/mm.c @@ -986,28 +986,30 @@ static int create_xen_entries(enum xenmap_operation op, { int rc; unsigned long addr = virt, addr_end = addr + nr_mfns * PAGE_SIZE; - lpae_t pte; + lpae_t pte, *entry; lpae_t *third = NULL; for(; addr < addr_end; addr += PAGE_SIZE, mfn = mfn_add(mfn, 1)) { - if ( !lpae_table(xen_second[second_linear_offset(addr)]) ) + entry = &xen_second[second_linear_offset(addr)]; + if ( !lpae_table(*entry) ) { - rc = create_xen_table(&xen_second[second_linear_offset(addr)]); + rc = create_xen_table(entry); if ( rc < 0 ) { printk("create_xen_entries: L2 failed\n"); goto out; } } - BUG_ON(!lpae_valid(xen_second[second_linear_offset(addr)])); + BUG_ON(!lpae_valid(*entry)); - third = mfn_to_virt(xen_second[second_linear_offset(addr)].pt.base); + third = mfn_to_virt(entry->pt.base); + entry = &third[third_table_offset(addr)]; switch ( op ) { case INSERT: case RESERVE: - if ( lpae_valid(third[third_table_offset(addr)]) ) + if ( lpae_valid(*entry) ) { printk("create_xen_entries: trying to replace an existing mapping addr=%lx mfn=%"PRI_mfn"\n", addr, mfn_x(mfn)); @@ -1017,11 +1019,11 @@ static int create_xen_entries(enum xenmap_operation op, break; pte = mfn_to_xen_entry(mfn, ai); pte.pt.table = 1; - write_pte(&third[third_table_offset(addr)], pte); + write_pte(entry, pte); break; case MODIFY: case REMOVE: - if ( !lpae_valid(third[third_table_offset(addr)]) ) + if ( !lpae_valid(*entry) ) { printk("create_xen_entries: trying to %s a non-existing mapping addr=%lx\n", op == REMOVE ? "remove" : "modify", addr); @@ -1031,7 +1033,7 @@ static int create_xen_entries(enum xenmap_operation op, pte.bits = 0; else { - pte = third[third_table_offset(addr)]; + pte = *entry; pte.pt.ro = PTE_RO_MASK(ai); pte.pt.xn = PTE_NX_MASK(ai); if ( !pte.pt.ro && !pte.pt.xn ) @@ -1041,7 +1043,7 @@ static int create_xen_entries(enum xenmap_operation op, return -EINVAL; } } - write_pte(&third[third_table_offset(addr)], pte); + write_pte(entry, pte); break; default: BUG(); From patchwork Fri Jun 30 15:54:30 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 106733 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp2507541qge; Fri, 30 Jun 2017 08:57:11 -0700 (PDT) X-Received: by 10.36.73.131 with SMTP id e3mr19733861itd.0.1498838230992; Fri, 30 Jun 2017 08:57:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1498838230; cv=none; d=google.com; s=arc-20160816; b=XbGrx8GpskESX0nFDHGx+PkyaJ6XmTR4GmHW79pvbJWr/ba/MLx+pABUzapUXchWmb UFdijfhxjQCUeom/JQxe8fnissrIacBgG3IVlR8kMX2ruoRNRej0smCNQbQt301kRKfI NAmQHndv7iJm74u2o8p5G3DJ13GO5g+UKCY6xms7D0tBqsTUOqHjnJQooCZA+qwqo/Sq yrpyNf2uzi1Ci5262sdMxZb1gvrB6z6qev1HDBNRjHl/ZBvxML6XwadHGAmLIj1VvMRr 5O+Hl33OM56+32pN7bWKpL0N2GpQg5s5rL7XvFujIL/xuy1pCAHcMPXjEAMt4Y7844Vt Z56A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-unsubscribe:list-id :precedence:subject:cc:references:in-reply-to:message-id:date:to :from:arc-authentication-results; bh=nCGaMcHfW9/TY8qx5DqHTN8WJj4a6sL8yb5ASGjqNXg=; b=p3pyHoR3HayxdZ8O5UYkWX/MPi+kC7sVQiP5aRQZc67qkuVkzJnNa9aFUcYB5bdWxW johqQZJQr0mc5ZUh4wRe6WL2pkDqRWjGHsAlpZ6L/mEwcXmL/6ZJqpgfD5OKbYhn684/ MqN2RJfOArb8lJUZxAcavXQmw3WrUR0z+la7RZBNDLqae9ldDbsCFfCcVKsHao0iw9lz 6mHsEiW9tAijtOqh8+Eu7YbDdvE1Uh+5nY+r3l0ORghd44IP153sBeJzNbA9aNH6YEWt Eg9Rn07GKNdLi1XQrFtmziWty09Ay9Zl40ShpFIzOpKTK+jSQAHvIzqnacIGTHY0uguU F0Bw== ARC-Authentication-Results: i=1; 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 Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id n125si4222704itg.5.2017.06.30.08.57.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 30 Jun 2017 08:57:10 -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 1dQyFx-0000ft-T8; Fri, 30 Jun 2017 15:54:53 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dQyFw-0000ce-Jj for xen-devel@lists.xen.org; Fri, 30 Jun 2017 15:54:52 +0000 Received: from [85.158.139.211] by server-7.bemta-5.messagelabs.com id C8/9A-02176-B4476595; Fri, 30 Jun 2017 15:54:51 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrJLMWRWlGSWpSXmKPExsVysyfVTde7JCz S4MRLEYslHxezODB6HN39mymAMYo1My8pvyKBNWNT11emgt3CFQ+29LA2MD7i7mLk4hAS2Mwo Mfv2VxYI5zSjRNuaD2xdjJwcbAKaEnc+f2ICsUUEpCWufb7MCGIzCzhIvPl4jwXEFhaIlvh46 SYziM0ioCqx7ec/MJtXwErixpMHYL0SAvISu9ousoLYnEDx4/8g4kIClhKvZ11lmcDIvYCRYR WjRnFqUVlqka6hhV5SUWZ6RkluYmaOrqGBqV5uanFxYnpqTmJSsV5yfu4mRqCHGYBgB2PTds9 DjJIcTEqivCuvhUYK8SXlp1RmJBZnxBeV5qQWH2KU4eBQkuBdUxQWKSRYlJqeWpGWmQMMNZi0 BAePkgivbBBQmre4IDG3ODMdInWK0ZhjxdtdX5g4Xk34/41JiCUvPy9VSpw3HWSSAEhpRmke3 CBYDFxilJUS5mUEOk2IpyC1KDezBFX+FaM4B6OSMO9JkCk8mXklcPteAZ3CBHSK8IwQkFNKEh FSUg2MxqrnCteu2KMa8XZuv2TDzcyarWdKyo7UPtr31Ue5O9x5bfz0f/MnPCl8O/3F6Q/L9e6 Y7Zx/I/mPxTqVAy/5xK+wO8f8/21fMCnjAqNhfDDX0pwLDisWpSkw/rnl3atQFKJXbXAm/sh8 X7VXCd0iZ9x+hnEEf2q8o+rbK/VB2TpTlHOhpnOlEktxRqKhFnNRcSIAc/EBSXwCAAA= X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-3.tower-206.messagelabs.com!1498838090!97274324!1 X-Originating-IP: [217.140.101.70] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.25; banners=-,-,- X-VirusChecked: Checked Received: (qmail 42246 invoked from network); 30 Jun 2017 15:54:51 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-3.tower-206.messagelabs.com with SMTP; 30 Jun 2017 15:54:51 -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 8E7B61610; Fri, 30 Jun 2017 08:54:50 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.206.53]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id EF6313F41F; Fri, 30 Jun 2017 08:54:49 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Fri, 30 Jun 2017 16:54:30 +0100 Message-Id: <20170630155431.23824-16-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170630155431.23824-1-julien.grall@arm.com> References: <20170630155431.23824-1-julien.grall@arm.com> Cc: Julien Grall , sstabellini@kernel.org Subject: [Xen-devel] [PATCH v3 15/16] xen/arm: mm: Use __func__ rather than plain name in format string 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" Signed-off-by: Julien Grall Reviewed-by: Stefano Stabelllini --- Changes in v2: - Patch added Changes in v3: - Add Stefano's reviewed-by --- xen/arch/arm/mm.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c index ea4a35ed7a..98260f604c 100644 --- a/xen/arch/arm/mm.c +++ b/xen/arch/arm/mm.c @@ -996,7 +996,7 @@ static int create_xen_entries(enum xenmap_operation op, { rc = create_xen_table(entry); if ( rc < 0 ) { - printk("create_xen_entries: L2 failed\n"); + printk("%s: L2 failed\n", __func__); goto out; } } @@ -1011,8 +1011,8 @@ static int create_xen_entries(enum xenmap_operation op, case RESERVE: if ( lpae_valid(*entry) ) { - printk("create_xen_entries: trying to replace an existing mapping addr=%lx mfn=%"PRI_mfn"\n", - addr, mfn_x(mfn)); + printk("%s: trying to replace an existing mapping addr=%lx mfn=%"PRI_mfn"\n", + __func__, addr, mfn_x(mfn)); return -EINVAL; } if ( op == RESERVE ) @@ -1025,8 +1025,8 @@ static int create_xen_entries(enum xenmap_operation op, case REMOVE: if ( !lpae_valid(*entry) ) { - printk("create_xen_entries: trying to %s a non-existing mapping addr=%lx\n", - op == REMOVE ? "remove" : "modify", addr); + printk("%s: trying to %s a non-existing mapping addr=%lx\n", + __func__, op == REMOVE ? "remove" : "modify", addr); return -EINVAL; } if ( op == REMOVE ) @@ -1038,8 +1038,8 @@ static int create_xen_entries(enum xenmap_operation op, pte.pt.xn = PTE_NX_MASK(ai); if ( !pte.pt.ro && !pte.pt.xn ) { - printk("create_xen_entries: Incorrect combination for addr=%lx\n", - addr); + printk("%s: Incorrect combination for addr=%lx\n", + __func__, addr); return -EINVAL; } } From patchwork Fri Jun 30 15:54:31 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 106723 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp2507184qge; Fri, 30 Jun 2017 08:56:45 -0700 (PDT) X-Received: by 10.107.34.205 with SMTP id i196mr25097823ioi.157.1498838205855; Fri, 30 Jun 2017 08:56:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1498838205; cv=none; d=google.com; s=arc-20160816; b=SiH1/sd7ymaqWxEm5KEh0cjfkB/FEFesNivN9UxGCy90FDO0fcKdWelC0uibToE+NY MFWin3hGdjhY1xzm1n2liZ7UTBUl96VJY6CVlXIOy/31e4xzCaFHxWwOzeEps6eb+B5+ 68THnVYKvQmx8ByvUJkeSIhgLuCGhVaOPsNdURC+1bwCK9vUaf1Mrn5vbuDu+mDPPyOj l44BHde6uZ5V/25GRGD1lNPSxzU166WKGM8ptW50iMgOPBOBPAhnBcWj+oEj/phPfj8j hLxi4rMWBayNYCvxcKhDTjT2baTLl1PD8MU6RsmJSSerYkcgKNpVY+OOeP5rV2RgAvB5 EYNQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-unsubscribe:list-id :precedence:subject:cc:references:in-reply-to:message-id:date:to :from:arc-authentication-results; bh=3AyDVnywIT6c6alV9I+K7xizb9PwHkGI9WOzbylTqZg=; b=LlQ2tGj5uQvmZ1djEUAcDRjfzbj8/DepP5unlv5/FzcmKzu6qBDJ/nJDwJttBCsbjb gugWKwtqKwlSXBuT3Y3ppRWx5qkSGRUbIPCj6Np+N3uV+foxPHv+pVX1ITIdlyDc+910 3uV4VpRmD9stTL135VYJODBVaarmsG/m3DUyHc7FilcQnHPNjsVGKo+XIqoGQH2ic9W5 3L4y4xqtMhnJvx/BIlISHfmEIbLu9Dq/auY9aZ6tJ6h7Y1nzqvU6zRL7UMQmrxtUkFuU 79c7fhmZd+ZDVhpxlxHx3ZiD6Hh1jKRM+SkBtCjax0F/Sqs3hgSq44nLYffiukA+n8a7 2VcA== ARC-Authentication-Results: i=1; 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 Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id e126si7780882iof.252.2017.06.30.08.56.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 30 Jun 2017 08:56:45 -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 1dQyFy-0000gf-4L; Fri, 30 Jun 2017 15:54:54 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dQyFx-0000de-8t for xen-devel@lists.xen.org; Fri, 30 Jun 2017 15:54:53 +0000 Received: from [85.158.143.35] by server-5.bemta-6.messagelabs.com id 66/CD-03368-C4476595; Fri, 30 Jun 2017 15:54:52 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrMLMWRWlGSWpSXmKPExsVysyfVTdenJCz S4NBFdoslHxezODB6HN39mymAMYo1My8pvyKBNWPitm+sBe0cFctaLrI1MF5g62Lk4hAS2Mwo cef7KUYI5zSjxPvzR1i7GDk52AQ0Je58/sQEYosISEtc+3yZEcRmFnCQePPxHguILSzgLPHg5 TSwOIuAqsS7mz/BenkFrCSu7lrEDGJLCMhL7Gq7CBbnBIof//cAbKaQgKXE61lXWSYwci9gZF jFqFGcWlSWWqRrZKiXVJSZnlGSm5iZo2toYKaXm1pcnJiempOYVKyXnJ+7iRHoYQYg2MH4Z1n AIUZJDiYlUd6V10IjhfiS8lMqMxKLM+KLSnNSiw8xynBwKEnwKhaHRQoJFqWmp1akZeYAQw0m LcHBoyTCKxsElOYtLkjMLc5Mh0idYtTleDXh/zcmIZa8/LxUKXHeEJAZAiBFGaV5cCNgYX+JU VZKmJcR6CghnoLUotzMElT5V4ziHIxKwrzOIFN4MvNK4Da9AjqCCegI4RkhIEeUJCKkpBoY91 SE5e4O0ROYXbzj486OfYefGlQG1SQEMUTfXN8yTcQsKIPh2KGKaesDjfy33lXO6mzu1rwzRS3 r1e9F9/fuOhrKGRJ2MUtxWsAPy6hi3Xu2SQuPK5w0YV/jffjfXt2fj/ctWch00kJKPO/S1GbO WRrSc7+fFzn5VWSru7vPJ6XfDzp3K8duU2Ipzkg01GIuKk4EAN1CBBx2AgAA X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-15.tower-21.messagelabs.com!1498838091!70998065!1 X-Originating-IP: [217.140.101.70] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.25; banners=-,-,- X-VirusChecked: Checked Received: (qmail 16438 invoked from network); 30 Jun 2017 15:54:51 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-15.tower-21.messagelabs.com with SMTP; 30 Jun 2017 15:54:51 -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 68ED4164F; Fri, 30 Jun 2017 08:54:51 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.206.53]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id C946D3F41F; Fri, 30 Jun 2017 08:54:50 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Fri, 30 Jun 2017 16:54:31 +0100 Message-Id: <20170630155431.23824-17-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170630155431.23824-1-julien.grall@arm.com> References: <20170630155431.23824-1-julien.grall@arm.com> Cc: Julien Grall , sstabellini@kernel.org Subject: [Xen-devel] [PATCH v3 16/16] xen/arm: lpae: Switch from bool_t to bool 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" We are phasing out the use of bool_t in the hypervisor code. Reviewed-by: Stefano Stabellini Signed-off-by: Julien Grall --- Changes in v3: - Patch added --- xen/include/asm-arm/lpae.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/xen/include/asm-arm/lpae.h b/xen/include/asm-arm/lpae.h index 6fbf7c606c..a62b118630 100644 --- a/xen/include/asm-arm/lpae.h +++ b/xen/include/asm-arm/lpae.h @@ -126,7 +126,7 @@ typedef union { lpae_walk_t walk; } lpae_t; -static inline bool_t lpae_valid(lpae_t pte) +static inline bool lpae_valid(lpae_t pte) { return pte.walk.valid; } @@ -136,12 +136,12 @@ static inline bool_t lpae_valid(lpae_t pte) * the table bit and therefore these would return the opposite to what * you would expect. */ -static inline bool_t lpae_table(lpae_t pte) +static inline bool lpae_table(lpae_t pte) { return lpae_valid(pte) && pte.walk.table; } -static inline bool_t lpae_mapping(lpae_t pte) +static inline bool lpae_mapping(lpae_t pte) { return lpae_valid(pte) && !pte.walk.table; }