From patchwork Mon Jun 19 16:57:38 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 105899 Delivered-To: patch@linaro.org Received: by 10.182.29.35 with SMTP id g3csp942474obh; Mon, 19 Jun 2017 10:00:01 -0700 (PDT) X-Received: by 10.107.184.67 with SMTP id i64mr22439532iof.153.1497891601267; Mon, 19 Jun 2017 10:00:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1497891601; cv=none; d=google.com; s=arc-20160816; b=RY9NjrUQENIStcuHPEOyv0G25Ro8KRK26WUWOmIoilokt5DyNOX7FddNPvQnifSuek HmwVBF0KDOJekANBzgubG79CCIBiTmvUNqhuuRsLwnsCKcCloZG3SXxScPGukR4dx9hR yY6bnsT9MvucuzR3+4HTwKuHvj+auCCljyUtm86ErVHgsdk273v7a0OmgUIulVO2K9nk 6FR08dODfSDyJnf6MUuDRPmTeN8piVBl3me5N3eMU3UJu99eXFFYteESJCItI+/2oO1Z M7uebcvK5s31tYj2tlzlTvgJDzX7aT41FW1lS9LZcdZvMZh6+qmkBs/eUDLkIC3LLgRl Mcpg== 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=vSY0quxkk7e2Fgkcn/pjPP+f8I9ihqcp98xdvDLXntQ=; b=QpNCx7mG9t/PwYAOUmpdZwLf7T0l/xCruIYVyeeqD/F1EFVsw1iMczrFwTDtZiSqSj dUGDvsnZrBaqWWT7l7fNL7eLFmI6jzSXS3yzbFgQw0WMV3pZHBN2H5JpgY7sKUVATg1w WvQmjBx8XynsoFQESPR3ps6AAuDXQhfGuPNx0eo9hkkhY6hihaU3twUqX+KMKyaXxD36 YTukrPe9i/sG9dIpmya3ewx6TmZHjE1zLxTjNa1J/2/da79MakkpBzVnMxm+cfbuVqvl 9iROTge/aKFhEK+jL8aUj+qUipQYhwBTV2B+l1ay6lFq28xivVFROByRINWPcdHgjKw8 dtFQ== 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 m127si9222840ite.94.2017.06.19.10.00.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 19 Jun 2017 10:00: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 1dN005-0003hC-Qj; Mon, 19 Jun 2017 16:58:05 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dN004-0003gf-4J for xen-devel@lists.xen.org; Mon, 19 Jun 2017 16:58:04 +0000 Received: from [85.158.137.68] by server-12.bemta-3.messagelabs.com id 26/88-11537-B9208495; Mon, 19 Jun 2017 16:58:03 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrKLMWRWlGSWpSXmKPExsVysyfVTXcWk0e kwbVvehZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa0bjpI8sBRN4KzbMmcrewPiMq4uRi0NIYDOj xPXjH1kgnNOMEhu3T2frYuTkYBPQlLjz+RMTiC0iIC1x7fNlRpAiZoFLTBIz/v8G6uDgEBYIl DjW7gtisgioStzvMQEp5xWwlJg1s4EZxJYQkJfY1XaRFcTmFLCS+D7/GiOILQRUc/zJLbYJjN wLGBlWMaoXpxaVpRbpGuslFWWmZ5TkJmbm6BoaGOvlphYXJ6an5iQmFesl5+duYgR6lwEIdjA 2f3E6xCjJwaQkyjvrv3ukEF9SfkplRmJxRnxRaU5q8SFGGQ4OJQneTYwekUKCRanpqRVpmTnA MINJS3DwKInw1vwGauUtLkjMLc5Mh0idYlSUEuc9CdInAJLIKM2Da4OF9iVGWSlhXkagQ4R4C lKLcjNLUOVfMYpzMCoJ8z4FmcKTmVcCN/0V0GImoMXMZ1xAFpckIqSkGhhn/+Pdq//MX27l/Z xX515ukk/2e2R99+EtX5e0BwkKr2zLMu6IRXC3937kYWK2T7Sf2fPU4d+jN79fcJ/MChQ//Mx DUuHKiV3be+UOvTCdeOqAyYM5//oKHv5ZOKle5KTxndcuoZJfnxvaP8ncF5tjvsU6Oy+Vc5Hq xeYD/21/yHYuzL13+6m6EktxRqKhFnNRcSIA2qdxOmgCAAA= X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-7.tower-31.messagelabs.com!1497891482!98806675!1 X-Originating-IP: [217.140.101.70] X-SpamReason: No, hits=0.5 required=7.0 tests=BODY_RANDOM_LONG X-StarScan-Received: X-StarScan-Version: 9.4.19; banners=-,-,- X-VirusChecked: Checked Received: (qmail 54402 invoked from network); 19 Jun 2017 16:58:02 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-7.tower-31.messagelabs.com with SMTP; 19 Jun 2017 16:58:02 -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 EDB0E15AD; Mon, 19 Jun 2017 09:58:01 -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 351EB3F41F; Mon, 19 Jun 2017 09:58:00 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Mon, 19 Jun 2017 17:57:38 +0100 Message-Id: <20170619165753.25049-2-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170619165753.25049-1-julien.grall@arm.com> References: <20170619165753.25049-1-julien.grall@arm.com> Cc: sstabellini@kernel.org, Wei Liu , George Dunlap , Andrew Cooper , Tim Deegan , Julien Grall , Jan Beulich , Ian Jackson Subject: [Xen-devel] [PATCH v2 01/16] xen/mm: Don't use _{g, m}fn for defining INVALID_{G, M}FN 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" INVALID_{G,M}FN are defined using static inline helpers _{g,m}fn. This means, they cannot be used to initialize a build time static variable: In file included from mm.c:24:0: xen/xen/include/xen/mm.h:59:26: error: initializer element is not constant #define INVALID_MFN _mfn(~0UL) Signed-off-by: Julien Grall Acked-by: Tim Deegan --- Cc: Andrew Cooper Cc: George Dunlap Cc: Ian Jackson Cc: Jan Beulich Cc: Konrad Rzeszutek Wilk Cc: Stefano Stabellini Cc: Tim Deegan Cc: Wei Liu Changes in v2: - Add Tim's acked - The solution suggested in v1 is also working for non-debug build. So keep the code as it is. --- xen/include/xen/mm.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xen/include/xen/mm.h b/xen/include/xen/mm.h index c9198232e2..e61b6e991c 100644 --- a/xen/include/xen/mm.h +++ b/xen/include/xen/mm.h @@ -56,7 +56,7 @@ TYPE_SAFE(unsigned long, mfn); #define PRI_mfn "05lx" -#define INVALID_MFN _mfn(~0UL) +#define INVALID_MFN (mfn_t){ ~0UL } #ifndef mfn_t #define mfn_t /* Grep fodder: mfn_t, _mfn() and mfn_x() are defined above */ @@ -89,7 +89,7 @@ static inline bool_t mfn_eq(mfn_t x, mfn_t y) TYPE_SAFE(unsigned long, gfn); #define PRI_gfn "05lx" -#define INVALID_GFN _gfn(~0UL) +#define INVALID_GFN (gfn_t){ ~0UL } #ifndef gfn_t #define gfn_t /* Grep fodder: gfn_t, _gfn() and gfn_x() are defined above */ From patchwork Mon Jun 19 16:57:39 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 105894 Delivered-To: patch@linaro.org Received: by 10.182.29.35 with SMTP id g3csp942443obh; Mon, 19 Jun 2017 09:59:56 -0700 (PDT) X-Received: by 10.107.173.221 with SMTP id m90mr26185261ioo.152.1497891596813; Mon, 19 Jun 2017 09:59:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1497891596; cv=none; d=google.com; s=arc-20160816; b=dqbyGOgiJmFpBdkEpRoCYqb4uab3q1YZ2n6crMap99nPQEm/p4EXkdIp9ng6EVrLMU i0FwVhi45YRGFtsXBE0T5azeersQUJ117kbC/WgpeihRDr0kELtBZF+9YXybbRsMKMb0 bjcWFNB/RO44lkXO+3DwD4KqHREASsheAmabASg39agcmlQv0a8di3fvkcYwam1+Uk5u 1II/Yb0T9Muz/a7LhzUWGmkczDFaUMCowM+31I5LrJypMSXhaolceZ5p2eC+wgdBccqa KFuZDjyoGMF34heK11bBBf6Ob4az6jlh3LPUMgOxMh0bggTBTvj0aBYylmCcT75KaZpB x67Q== 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=FrMVtJMRRoXFJltoq024j1cSVB83Jj9jWANDF0XXt1k=; b=tOzdkaXU6pMRDE1szzkl2OnGfh5wR3PSKqcynfiC4owO2jh+Mgk9WA6mYaGSV9Vw9W OduiriLVyCrNIezkHI27hjKIuqKbrZwDNIrIHTs6QepLrFNbgDCCuuHD+Qj19ePLuWdE 0qDO1HRvdSbtCB+tiYlH61kwEljt2IiIugog5CrThwGmqW79HKlxABgHvDpjjQngxF62 r42xCd2/T56on10mYmVaobZUekXTh/PprE3EpTA03cgUTcjltULG7A35S+V4QQB6vZWu 6/6iEl9acUxSdhjqxFsCHR2XWbDaT6j+jtFEwAenFKTeou1OLfRZFX+rEoJoB+QCM/3A SCkg== 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 d82si11063026itg.18.2017.06.19.09.59.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 19 Jun 2017 09:59:56 -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 1dN006-0003hO-1g; Mon, 19 Jun 2017 16:58:06 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dN004-0003gl-Od for xen-devel@lists.xen.org; Mon, 19 Jun 2017 16:58:04 +0000 Received: from [85.158.139.211] by server-15.bemta-5.messagelabs.com id 2F/75-01730-C9208495; Mon, 19 Jun 2017 16:58:04 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrGLMWRWlGSWpSXmKPExsVysyfVTXc2k0e kwdFeTYslHxezODB6HN39mymAMYo1My8pvyKBNePGyzvMBYvYKpafXcPYwHifpYuRk0NIYBOj xNMD0V2MXED2aUaJ75des4Ek2AQ0Je58/sQEYosISEtc+3yZEcRmFnCQePPxHlizsECMxLq9O 9m7GDk4WARUJaauFQMJ8wpYSrw+dwasVUJAXmJX20VWEJtTwEri+/xrjBB7LSWOP7nFNoGRew EjwypG9eLUorLUIl0jvaSizPSMktzEzBxdQwNTvdzU4uLE9NScxKRiveT83E2MQN8yAMEOxu9 /nA4xSnIwKYnyzvrvHinEl5SfUpmRWJwRX1Sak1p8iFGGg0NJgncTo0ekkGBRanpqRVpmDjDI YNISHDxKIrw1v4FaeYsLEnOLM9MhUqcYjTk2rF7/hYmj6cOWL0xCLHn5ealS4rwnQSYJgJRml ObBDYIF/yVGWSlhXkag04R4ClKLcjNLUOVfMYpzMCoJ8z4FmcKTmVcCt+8V0ClMQKcwn3EBOa UkESEl1cBYlmNSv1GRMcLo+qbweZWm65tlCo4s7GK+a25q073xwMWVf71lOiqnWi7fu8w38LF 8Yfqq1N0VpueTr6ZY5c6e0+YxQzxdvObfS8kc1vq/TPwHmd5HFbSttrqf+YV3wfmPmxS6T+k1 t57+dtJultfvmWdnGkxREHjQc3/plfUJdjcKM94Z8rcqsRRnJBpqMRcVJwIAKkuOmnkCAAA= X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-6.tower-206.messagelabs.com!1497891483!103918904!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 32320 invoked from network); 19 Jun 2017 16:58:03 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-6.tower-206.messagelabs.com with SMTP; 19 Jun 2017 16:58:03 -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 DD4C5344; Mon, 19 Jun 2017 09:58:02 -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 3C58A3F41F; Mon, 19 Jun 2017 09:58:02 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Mon, 19 Jun 2017 17:57:39 +0100 Message-Id: <20170619165753.25049-3-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170619165753.25049-1-julien.grall@arm.com> References: <20170619165753.25049-1-julien.grall@arm.com> Cc: Julien Grall , sstabellini@kernel.org Subject: [Xen-devel] [PATCH v2 02/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. Xen is not currently using xenheap_mfn_end and the value will be reset after the loop. So drop this bogus xenheap_mfn_end. Signed-off-by: Julien Grall Reviewed-by: Stefano Stabellini --- Changes in v2: - Update commit message --- 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 Mon Jun 19 16:57:40 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 105902 Delivered-To: patch@linaro.org Received: by 10.182.29.35 with SMTP id g3csp942526obh; Mon, 19 Jun 2017 10:00:07 -0700 (PDT) X-Received: by 10.36.69.19 with SMTP id y19mr22935280ita.26.1497891607596; Mon, 19 Jun 2017 10:00:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1497891607; cv=none; d=google.com; s=arc-20160816; b=B8J9ov684dGDOjoYGxQl27qlRzUZYNF8GATArb0w16BPbLfQ3pplw8gt4F5utOc5bk irDBm11QIjHiB1BW4EZEKaj/h5NrwZ9dfean/tgVNmM/sTOC0BFm+BvlS+lU43XJXSyL gdtDcRoVz/SwV/ywTfzYoiKIt2P1cPFOcbQ7F1BbXO+LIEhZdLXzl+zZ+IlP09DBHMAW xy/MhMqKdJ1ENM6yxgzQNUx0d8C2XQWg9xzWDoL2/6OY2vaJJuFVD3ZM4/r1SqOQwcbx HxfgZ+jj0VnJNqwGi4ljN/p1SB3jG78nAIsKczf1Z8KsT63KcClvml04XMHQ0aaNxPkI 9qEg== 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=pcJ6mNyBU07YguqxKzVEfF+MBJ/LEg7LhC1KDI+ImSs=; b=OL8eT9/RjzTtsg9KLtPuFZIlMbe7FDSLjmPthJX63zKsj4jAuLlgDez1X8lBJH6ws3 vinmirDDW+4mQB5R5oYqSOOhIUTFPRRps6JjWEe9oQbr6MIoRJh5Ns8XmGsDndf5RB5/ 7AasfL7rml1TnkAwSsKhvQt/8EMYJC8Yw1DFM/i0ohqC5K6/o97zsUyWVCMdYLLj+c4L MkU7dECwEBMdwEvnvETjlTrt98zgbnE1P5cX/xML8O9QxPI3p+AjVy3iHHTdYdFKC+0t O6bVJXW2OiEqhpdNXt3mFRbGiQXWh06K/HL4ekqnlDXTeHFyjAcClww2oKvON0+bcjur eXIQ== 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 n4si6796421ite.24.2017.06.19.10.00.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 19 Jun 2017 10:00:07 -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 1dN006-0003ia-RZ; Mon, 19 Jun 2017 16:58:06 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dN005-0003hB-Tm for xen-devel@lists.xen.org; Mon, 19 Jun 2017 16:58:06 +0000 Received: from [85.158.139.211] by server-3.bemta-5.messagelabs.com id 7A/B0-02022-D9208495; Mon, 19 Jun 2017 16:58:05 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrELMWRWlGSWpSXmKPExsVysyfVTXcOk0e kQd82fYslHxezODB6HN39mymAMYo1My8pvyKBNePgwmtMBT0mFXdvtbE1MJ7T6GLk4hAS2Mwo MefBa9YuRk4g5zSjxN2LSiA2m4CmxJ3Pn5hAbBEBaYlrny8zgtjMAg4Sbz7eYwGxhQU8JZbM2 gFmswioSvz+dpYdxOYVsJT4+GsjmC0hIC+xq+0i2HxOASuJ7/OvMULsspQ4/uQW2wRG7gWMDK sYNYpTi8pSi3SNDPSSijLTM0pyEzNzdA0NTPVyU4uLE9NTcxKTivWS83M3MQL9W8/AwLiDsXG 23yFGSQ4mJVHeWf/dI4X4kvJTKjMSizPii0pzUosPMcpwcChJ8KoyekQKCRalpqdWpGXmAAMN Ji3BwaMkwlvzG6iVt7ggMbc4Mx0idYpRl2PD6vVfmIRY8vLzUqXEeU+CzBAAKcoozYMbAQv6S 4yyUsK8jAwMDEI8BalFuZklqPKvGMU5GJWEebtAruTJzCuB2/QK6AgmoCOYz7iAHFGSiJCSam A0F2Tgv2Yn/+KLAXst+x2P//vdP26fbn48RU+Y93fR4h1Jif8zmtnnT+1INJk1rX/RqrrqFZ1 uEdfWugetULdIDVt3ptjk6rwOxrUyETatuS/bGN7FLQlccTFBQ4Pt0UF9+YCz2/aZ5JatyFVZ vXHanYiuG/9WPD2jMPn6aZ2zARHxKisL++KUWIozEg21mIuKEwECEy66dQIAAA== X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-2.tower-206.messagelabs.com!1497891484!83507508!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 21716 invoked from network); 19 Jun 2017 16:58:04 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-2.tower-206.messagelabs.com with SMTP; 19 Jun 2017 16:58:04 -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 D093F15BE; Mon, 19 Jun 2017 09:58:03 -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 2C10C3F41F; Mon, 19 Jun 2017 09:58:03 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Mon, 19 Jun 2017 17:57:40 +0100 Message-Id: <20170619165753.25049-4-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170619165753.25049-1-julien.grall@arm.com> References: <20170619165753.25049-1-julien.grall@arm.com> Cc: Julien Grall , sstabellini@kernel.org Subject: [Xen-devel] [PATCH v2 03/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 Reviewed-by: Stefano Stabellini --- 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(). --- 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 7b313ca123..452c1e26c3 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; +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 274b1752b3..b2e7ea7761 100644 --- a/xen/include/asm-arm/mm.h +++ b/xen/include/asm-arm/mm.h @@ -115,7 +115,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) @@ -235,7 +236,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 @@ -243,7 +244,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))); } @@ -284,7 +285,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 Mon Jun 19 16:57:41 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 105898 Delivered-To: patch@linaro.org Received: by 10.182.29.35 with SMTP id g3csp942460obh; Mon, 19 Jun 2017 09:59:59 -0700 (PDT) X-Received: by 10.36.161.67 with SMTP id n3mr22978037iti.7.1497891599819; Mon, 19 Jun 2017 09:59:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1497891599; cv=none; d=google.com; s=arc-20160816; b=cxrZT7JncliEB5jWsE/S2ajw2wRVpGT3tntd6Ym2oLWc/Y4GrrH9wWTFLzrrqU2mPr D2C56VXSy25FgD+riPlTFUObwyPh6h9sP5MpvPbVDo/MYikXdoAkOgxX/MXIBK0DSK60 DFB4M2jUONpIWBPvUGC6HuY02Kccw0AcCirlhdO/O2HgW118i0KbUt+72CkN5M1+rRC+ iySy77dIMHIAzkasnTBcuYDWCoDmj4wAA3di2yWwt5CVT1OUza1doKT+5jl5udrsQnxx QlOoVYW33kkElFsux3CN11dOZzpglOkm329bHINbx6pYdw+7Q3o/Vb7lpXWGvVrTX/J0 /Glw== 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=3ZYF9b8DdUfYv/VJkXY2nvcCpyppYyRKPOrN+lhBp48=; b=yuEAs+u3104Wt2maBfODpCnj/WvgGCkEqdSdPBOzwOzHNiFp2oHgZVJ1+wVD+Fz3Qq wQ0pOL3j41fHRXRlKrL1Ol3q1Eg9v6PkIeFdGIQVagB+dmv3IQZyzy1fq+dnj3pRxyH6 IPuA3T3lciWT7XRkJqN9LZtvWSdMRFMwDiLCi8HqtdR8ADaSl81pCKfJz0nLxhsy9Wyc YHTZSzpJrYJLCfzdZ/H1NYjpy8+Q7iNotxjXwO5mc5yBwdGxd3BrexB6me1uVNFQs3iY hOLGZ2i3llzppzEBUSbceVIzxEfEnzYMMGAa64e7V58l+9jVrr4LaAdtRIcokeQX1Z2Y 9jVQ== 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 h92si10034986iod.181.2017.06.19.09.59.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 19 Jun 2017 09:59:59 -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 1dN00A-0003lr-Oq; Mon, 19 Jun 2017 16:58:10 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dN009-0003js-SD for xen-devel@lists.xen.org; Mon, 19 Jun 2017 16:58:09 +0000 Received: from [85.158.139.211] by server-16.bemta-5.messagelabs.com id FF/43-01752-1A208495; Mon, 19 Jun 2017 16:58:09 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrGLMWRWlGSWpSXmKPExsVysyfVTXcuk0e kwfPjKhZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa8apjavYCtZIVTx5/IO5gfGfSBcjF4eQwGZG iVstm5ggnNOMEg9aD7N0MXJysAloStz5/IkJxBYRkJa49vkyI4jNLOAg8ebjPbAaYYEYiQOfr oPVsAioSsx7MBvM5hWwlDh/8BlYvYSAvMSutousIDangJXE9/nXwOJCQDXHn9xim8DIvYCRYR WjenFqUVlqka6hXlJRZnpGSW5iZo6uoYGpXm5qcXFiempOYlKxXnJ+7iZGoH/rGRgYdzA29To fYpTkYFIS5Z313z1SiC8pP6UyI7E4I76oNCe1+BCjDAeHkgTvJkaPSCHBotT01Iq0zBxgoMGk JTh4lER4a34DtfIWFyTmFmemQ6ROMSpKifMqgPQJgCQySvPg2mDBfYlRVkqYl5GBgUGIpyC1K DezBFX+FaM4B6OSMG8XyGU8mXklcNNfAS1mAlrMfMYFZHFJIkJKqoGR3UJdPfKKVo913nS7H6 fufD4dvLdi+x+ts6Ldqx0rj+2yWLbyjeqiSLEKHf5O9T7P/V3fXGcv2XQn5XHavfxrp86yHO1 SfrWnu3iB8S61ZZe9omued2yqinsb/FrxtHi21v8VvH5fp2o3cZmdC1rN9HVTXojd1bx9/3+K Jj4S0HJzT2l5yeesxFKckWioxVxUnAgAWis3AWkCAAA= X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-8.tower-206.messagelabs.com!1497891485!103980153!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 17824 invoked from network); 19 Jun 2017 16:58:05 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-8.tower-206.messagelabs.com with SMTP; 19 Jun 2017 16:58:05 -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 C3B1F15AD; Mon, 19 Jun 2017 09:58:04 -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 1F94D3F41F; Mon, 19 Jun 2017 09:58:03 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Mon, 19 Jun 2017 17:57:41 +0100 Message-Id: <20170619165753.25049-5-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170619165753.25049-1-julien.grall@arm.com> References: <20170619165753.25049-1-julien.grall@arm.com> Cc: Julien Grall , sstabellini@kernel.org Subject: [Xen-devel] [PATCH v2 04/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 --- 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. --- 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 266d1c3bd6..6c1ac70044 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, mfn_x(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); /* @@ -1443,7 +1449,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 Mon Jun 19 16:57:42 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 105895 Delivered-To: patch@linaro.org Received: by 10.182.29.35 with SMTP id g3csp942451obh; Mon, 19 Jun 2017 09:59:58 -0700 (PDT) X-Received: by 10.36.163.137 with SMTP id p131mr18375287ite.85.1497891598827; Mon, 19 Jun 2017 09:59:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1497891598; cv=none; d=google.com; s=arc-20160816; b=qe9lBg+ZCrbguUdVdjclXefRRNGF02nxciQjxBsnqfCIXw2fkEeuqf0xI6GMLV4/7S y2LITEdZVe2oIFnWbSNBXordyjWjkt5aD1vtMBTiIrtznO5Jd9vWYOQ8miQ/QRhhytnu aof8gissAH/1ZSDi/auuOJmt27bkH8gOXPXOnlbBwSgZ5A7wXMLjIv3EQTux8ffdl7sX TiMCk03pTUKH5UV7wy2dwULIQcurMxe+DZhnVi/qxlhVkYEu+isnM4v1PGxHtamalcMb aEwoKLG5SATl11FnXMahVyiwY1/mlhIcE3FS1mhJVWZ3DxtJWack/BRuUgNqrG1Mtnhx 4nPA== 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=U2J1/a3CaJjUJni3yKvdQ1cch3Z6E8Y+5Uo0Ad1hJe0=; b=Ct7D9tzzKWKiHQiK+dTuJeyghXsMNej0eTOJc5r2UmJc81FVZS2TR8rx4BBd+HeF9c ZY8+jezv0FKATGf5gTRIJqUwO2I+eofunrJYIL5LlU6Ex1+xZ+Db6+WHTP7p07vu62OY HU81bi5vNH5T6Zo50mO6Abv21iEmbdq9pAi+aRgJp40SC0HdWoplcdETuHHx+8PK+DMe UifaRt4uSl4gF8sWIsOgNk5/et5gvh43DE71pBd/2OE/pUlLZKsuiYrw2NoolNg4wbNF F4PL2dOp0AawerEQHKHqH6jtb9Ji+g8Ou3SstcVb9fuktwRdAny3ET+MpU8VElsd2aLi +fDw== 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 j16si10878949ita.127.2017.06.19.09.59.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 19 Jun 2017 09:59:58 -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 1dN009-0003jV-21; Mon, 19 Jun 2017 16:58:09 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dN007-0003ir-Ol for xen-devel@lists.xen.org; Mon, 19 Jun 2017 16:58:07 +0000 Received: from [193.109.254.147] by server-2.bemta-6.messagelabs.com id C1/BB-03058-F9208495; Mon, 19 Jun 2017 16:58:07 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrOLMWRWlGSWpSXmKPExsVysyfVTXcek0e kwbd7qhZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa8a0dX9ZC+bJV6y+Poe9gfG1RBcjF4eQwGZG iTnXPjBCOKcZJZb9X8TaxcjJwSagKXHn8ycmEFtEQFri2ufLjCA2s4CDxJuP91hAbGEBf4n/3 9aB1bMIqEq8f3sSrIZXwFLi3auHzCC2hIC8xK62i2A1nAJWEt/nXwOrEQKqOf7kFtsERu4FjA yrGDWKU4vKUot0jYz0kooy0zNKchMzc3QNDcz0clOLixPTU3MSk4r1kvNzNzECPcwABDsY18w PPMQoycGkJMo76797pBBfUn5KZUZicUZ8UWlOavEhRhkODiUJXlVGj0ghwaLU9NSKtMwcYKjB pCU4eJREeGt+A7XyFhck5hZnpkOkTjEqSonzKoD0CYAkMkrz4Npg4X2JUVZKmJcR6BAhnoLUo tzMElT5V4ziHIxKwrxdIJfxZOaVwE1/BbSYCWgx8xkXkMUliQgpqQZGU4EtAXrf5cw2FsosXc jyg+NV65119aFMxbeScoz6prE9n/3vuuPri75KMnt6c1Zt2FzYxCCwf8Mt35lSxz/c81utz1K /yCNFkuPz1nCPdV37fU+93iCX1fTMfeazG5ZROvPefMldqdJsHrPh0elO1owrMznDKi+svLOH T8Hx4C7NNjajuqfpSizFGYmGWsxFxYkA54KxjmoCAAA= X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-9.tower-27.messagelabs.com!1497891486!108525070!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 52637 invoked from network); 19 Jun 2017 16:58:06 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-9.tower-27.messagelabs.com with SMTP; 19 Jun 2017 16:58:06 -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 B611115BE; Mon, 19 Jun 2017 09:58:05 -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 123333F41F; Mon, 19 Jun 2017 09:58:04 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Mon, 19 Jun 2017 17:57:42 +0100 Message-Id: <20170619165753.25049-6-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170619165753.25049-1-julien.grall@arm.com> References: <20170619165753.25049-1-julien.grall@arm.com> Cc: Julien Grall , sstabellini@kernel.org Subject: [Xen-devel] [PATCH v2 05/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()). --- 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 452c1e26c3..5612834dfc 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; @@ -1216,7 +1220,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; @@ -1302,7 +1306,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); @@ -1321,7 +1325,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 b2e7ea7761..6e2b3c7f2b 100644 --- a/xen/include/asm-arm/mm.h +++ b/xen/include/asm-arm/mm.h @@ -264,7 +264,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)) /* @@ -274,6 +274,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 Mon Jun 19 16:57:43 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 105891 Delivered-To: patch@linaro.org Received: by 10.182.29.35 with SMTP id g3csp942430obh; Mon, 19 Jun 2017 09:59:55 -0700 (PDT) X-Received: by 10.36.68.19 with SMTP id o19mr15294802ita.47.1497891595183; Mon, 19 Jun 2017 09:59:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1497891595; cv=none; d=google.com; s=arc-20160816; b=I+c4vqFkENC+gzcjzXYO9nt18SMy96AbNcwjdonhVXsj+K6xp0sK2wwyaPMkdDZFT5 qeovCt9an8LVmySLULEyiERprOFNAyuJeRpAktUXE63g27f56dOliqObU2Bg0wCC1NTZ PFPDDdjDsCjVq8ICXQFxXUij/5P9JwIHBgsfDXDegXic9Cgdz3h0NMkqTAd9X5t+qsxA hUEMrH2r+I89WFh1wBFbakDGNPM6wlK5JO/w6rP70nXzdxy9B8BttpQ1/NhIXgvWMPWx ZOZcXVOihzWqJczP4femPHhfA6VbpIFHcNRvW9LEeVSkI1HflIkiz+DS8YNnJ2dB8wL3 KhUA== 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=Fjgo+plWbV8/MfQZAMCvjCwiDk1ueZdCghv7tYZAg8kBnTDoBBN21cuc8RbO9JWKAX DeDzmdF+KEwGRK08t425vGLfcC12iSM5Fs0SQh222zh6FOB6vPva8ZZql6i7Hn6Gdtgv 90FrtPAyIOpC2atqz6vYrQZTST/iHwHcWw2ITdgw0JexS2Ff1bx6fUjXf8yWTOJcijb0 ZovWe5RtsUHFVtGrNJuvXQez4Y5gQKKaQ6MnOTKqCwjhbT0DeUtVvOTd1nDyJ4dlCQqw L9Az1p7vAxyGzt/KdlXG8YlJWes1cZ7lYhRYDmIk++qGfxtkexe5Nha0NwTI0d0+sGe3 okjg== 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 f192si10185964ioe.7.2017.06.19.09.59.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 19 Jun 2017 09:59:55 -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 1dN009-0003jj-9P; Mon, 19 Jun 2017 16:58:09 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dN008-0003ir-3l for xen-devel@lists.xen.org; Mon, 19 Jun 2017 16:58:08 +0000 Received: from [193.109.254.147] by server-2.bemta-6.messagelabs.com id D5/BB-03058-F9208495; Mon, 19 Jun 2017 16:58:07 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrGLMWRWlGSWpSXmKPExsVysyfVTXc+k0e kwYp1YhZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa0Z722HmghPcFSvm/GRsYOzi7GLk4hAS2MQo cWHjE3YI5zSjRNflvcxdjJwcbAKaEnc+f2ICsUUEpCWufb7MCGIzCzhIvPl4jwXEFhaIlJj8c gdYDYuAqsSiJ5fZQWxeAUuJjy+2s4LYEgLyErvaLoLZnAJWEt/nXwObIwRUc/zJLbYJjNwLGB lWMaoXpxaVpRbpmuglFWWmZ5TkJmbm6BoamOnlphYXJ6an5iQmFesl5+duYgT6lwEIdjB2X/Y /xCjJwaQkyjvrv3ukEF9SfkplRmJxRnxRaU5q8SFGGQ4OJQneTYwekUKCRanpqRVpmTnAQINJ S3DwKInw2gGDTYi3uCAxtzgzHSJ1ilFRSpz3JEifAEgiozQPrg0W3JcYZaWEeRmBDhHiKUgty s0sQZV/xSjOwagkzPsUZApPZl4J3PRXQIuZgBYzn3EBWVySiJCSAsYLe3XamZazSTVm7NstLu +vCDGKTzJOS1Q/0/D5jI63rrnK50zHlJzEk+qF+WYhjjPLbueH7gv8GRknZSZSf++tahbTi0W awhcLWo9/vN3x2Nx/X/6Sksufz+QsPx/KdaX0oNcRhw9n5cSkT3DkRF/IYWG5zO0yoVys96Cn Su7ZNKd8edmjSizFGYmGWsxFxYkAPleCxGkCAAA= X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-5.tower-27.messagelabs.com!1497891486!102926268!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 47722 invoked from network); 19 Jun 2017 16:58:07 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-5.tower-27.messagelabs.com with SMTP; 19 Jun 2017 16:58:07 -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 A630F344; Mon, 19 Jun 2017 09:58:06 -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 0490D3F41F; Mon, 19 Jun 2017 09:58:05 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Mon, 19 Jun 2017 17:57:43 +0100 Message-Id: <20170619165753.25049-7-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170619165753.25049-1-julien.grall@arm.com> References: <20170619165753.25049-1-julien.grall@arm.com> Cc: Julien Grall , sstabellini@kernel.org Subject: [Xen-devel] [PATCH v2 06/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 Mon Jun 19 16:57:44 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 105893 Delivered-To: patch@linaro.org Received: by 10.182.29.35 with SMTP id g3csp942442obh; Mon, 19 Jun 2017 09:59:56 -0700 (PDT) X-Received: by 10.36.167.76 with SMTP id s12mr23623917iti.97.1497891596621; Mon, 19 Jun 2017 09:59:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1497891596; cv=none; d=google.com; s=arc-20160816; b=BBWkGPn/BEP4mTjN0Xd7vAyb9Lj4GHAm8kdTzI13fWzNCG34E9LvkYuw6bKkWDeLcY fiwrKJ4d2N6NXVQBvApVrfF/Dn4pro3/XGHJhwhjOsT2Ed0cWzRBfMP8fppgy/zMD8HO XOM1pEBwR111E3H1hpvHHZ37SzIphBWJRjNIqitUAx4tG/h69BQt0EvDV80Pv3ScHVms SumO5Dq5yX7Kp3xPg3MeQeAw8CxzTJkoanyYxLgW14/P8JWmQgstsz3oxJ3k7iWsqoP4 MOUxK/Y6y3a3zZJJQ8s+rj4ZggXhgtU7OX5p0WlXUrMMtdKIj4EFc9IW7g3mNPIcrbBE 89sQ== 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=K+tPfyH+BYc3ozBsvA3pCmrB1z+1npaK8UiDQUEghLrfScjnwSD+IxlxG6LU9X+OWf R3lTsA9sqy/pea4KWtbi0ZsEht7DGjPwhBQq6dMGScFE+tOhHd8RAsFTCFIXCZq/aibJ ZnWURnw27rHw5ToEOZ1y964cYfsmtaGaiAgxBl5FmgucmXMamaKQ8BoNSlWeFNh7g4O5 Q/m9lOU+G1XkA2zn1GWG5cc0JXRlsH96DX855M3cw3blpW4inpEi1QHXhZVpPG7mEMb4 t1gM5pRXYVou5rbPWqQdjmix2F2n/CJszechc324BrzQEGuRyboRHKDAh46WVkKOg5wu PPTA== 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 y8si6508574iti.1.2017.06.19.09.59.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 19 Jun 2017 09:59:56 -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 1dN00A-0003lN-H8; Mon, 19 Jun 2017 16:58:10 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dN009-0003jg-Od for xen-devel@lists.xen.org; Mon, 19 Jun 2017 16:58:09 +0000 Received: from [85.158.137.68] by server-3.bemta-3.messagelabs.com id D4/AE-01985-0A208495; Mon, 19 Jun 2017 16:58:08 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrMLMWRWlGSWpSXmKPExsVysyfVTXcBk0e kQcNdMYslHxezODB6HN39mymAMYo1My8pvyKBNWPf39mMBZe4Kl5vvMbSwPiUo4uRi0NIYDOj xPTTf9kgnNOMEsv2LmXvYuTkYBPQlLjz+RMTiC0iIC1x7fNlRhCbWcBB4s3HeywgtrBAhMTU/ 9vB4iwCqhKzvl4Ci/MKWErM7f8PFpcQkJfY1XaRFcTmFLCS+D7/GlhcCKjm+JNbbBMYuRcwMq xi1ChOLSpLLdI1NNFLKspMzyjJTczM0TU0MNbLTS0uTkxPzUlMKtZLzs/dxAj0MAMQ7GBcsd3 zEKMkB5OSKO+s/+6RQnxJ+SmVGYnFGfFFpTmpxYcYZTg4lCR4rzB4RAoJFqWmp1akZeYAQw0m LcHBoyTCW/MbqJW3uCAxtzgzHSJ1ilGXY8Pq9V+YhFjy8vNSpcR5FRiBZgiAFGWU5sGNgIX9J UZZKWFeRqCjhHgKUotyM0tQ5V8xinMwKgnzPgWZwpOZVwK36RXQEUxARzCfcQE5oiQRISXVwO h1MeJfR7mqFYvfd0/j33JLTznU3/a+4ry+Xf3hBLH+UP6mlhktH7fEt7183HlMxfT5R9vvf39 PnDHdjp3h52YxDTkO5wnGeZOWFTfK2PQ+2Gh89nXcq+zV644t7zALO5tWJcWjp6ziMJWndd35 as7TPq+en/jXUHCSadOSDZaHE5o7Q/8uU1ZiKc5INNRiLipOBABe5pPVdgIAAA== X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-6.tower-31.messagelabs.com!1497891487!67805838!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 38890 invoked from network); 19 Jun 2017 16:58:08 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-6.tower-31.messagelabs.com with SMTP; 19 Jun 2017 16:58:08 -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 9833415AD; Mon, 19 Jun 2017 09:58:07 -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 E8F7E3F41F; Mon, 19 Jun 2017 09:58:06 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Mon, 19 Jun 2017 17:57:44 +0100 Message-Id: <20170619165753.25049-8-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170619165753.25049-1-julien.grall@arm.com> References: <20170619165753.25049-1-julien.grall@arm.com> Cc: Julien Grall , sstabellini@kernel.org Subject: [Xen-devel] [PATCH v2 07/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 Mon Jun 19 16:57:45 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 105890 Delivered-To: patch@linaro.org Received: by 10.182.29.35 with SMTP id g3csp942411obh; Mon, 19 Jun 2017 09:59:51 -0700 (PDT) X-Received: by 10.107.33.140 with SMTP id h134mr9294593ioh.57.1497891591141; Mon, 19 Jun 2017 09:59:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1497891591; cv=none; d=google.com; s=arc-20160816; b=FDoC1yZLsVUdmevy4BU8SJjIF3irbLiitZx/LG+RBcmGKdLrq/ScY2thjENm3TlriQ d+vfPRODijLrYHpyST/muuvkR0nUHO8DDThtEVhDig6W9KYoK85Ix+CrHqRE59z7n7CB wDM8Ai9IuD1modV0u/GkZOYfo+BuhWtMFVvakhk1EU7jshw7l5bcFamWka6V6+/gVZNr DnubZ62OZfxKqrMHuq0FF9lWBvceQSSztr+k8qIQZvajr0sMELx1JsL9yterMHRg6iNU VGPqb7+CHygRoTta2B3m/FzQdOjsmE9+g3H1JvZQT/3QQkjmZL/+UH77Er31r25LwtmF MDNA== 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=qOD4e0s3zlILYDM64kk1QRdOPPrZIJvoFAdy0DZtP6Q=; b=yB6lyI4c4q894i1xZXPYnmFQp513kq14IeR2sSTwNB16RY48L9ovw9O7N9psEMUFEf OFW6Cfi+nqBv59AvK6dFQIqVdN8/8tosBEUx1qmqwI0zjmx3EnjuM3DSXvlMAS0uf7Uq WUAEUbjT2sES0fgSgEE7tNKcWm8TONEIK55SLQTTPuibq29h0qpYSdpoSaR7isVA157X Uj620Qdu5QmHp30SJ3gVfWlTectDbqVo/2ZrrVKX7qsMu3E3NWS9t//s0BRqurJCquuy +BtMWUq93wWoCn3j3U5eWRRkziRnMAy3SWEWxeIi4vKvAaeubL9Leyb9P2kgbNtxmD2X vMtA== 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 y7si7197870itd.62.2017.06.19.09.59.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 19 Jun 2017 09:59:51 -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 1dN00F-0003sA-IW; Mon, 19 Jun 2017 16:58:15 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dN00D-0003pE-VE for xen-devel@lists.xen.org; Mon, 19 Jun 2017 16:58:14 +0000 Received: from [85.158.139.211] by server-5.bemta-5.messagelabs.com id E0/B5-02183-5A208495; Mon, 19 Jun 2017 16:58:13 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrKLMWRWlGSWpSXmKPExsVysyfVTXchk0e kweS56hZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa8bVLr2CY1wVB3f1sTUwvuboYuTiEBLYzChx c8tdVgjnNKPEoh0rWLoYOTnYBDQl7nz+xARiiwhIS1z7fJmxi5GDg1lgHqPElkiQsLBAmMSKr 5/YQGwWAVWJW9fPgNm8ApYSp69+ZQSxJQTkJXa1XWQFsTkFrCS+z78GFhcCqjn+5BbbBEbuBY wMqxg1ilOLylKLdI3M9JKKMtMzSnITM3N0DQ1M9XJTi4sT01NzEpOK9ZLzczcxAr1bz8DAuIP x9mS/Q4ySHExKoryz/rtHCvEl5adUZiQWZ8QXleakFh9ilOHgUJLgVWX0iBQSLEpNT61Iy8wB hhlMWoKDR0mEt+Y3UCtvcUFibnFmOkTqFKOilDivAkifAEgiozQPrg0W2pcYZaWEeRkZGBiEe ApSi3IzS1DlXzGKczAqCfN2gVzGk5lXAjf9FdBiJqDFzGdcQBaXJCKkpBoYmZet/NvLf2b7sz kbX6S8C9ytFOT46IWo2VKzzx/u7NkUcMfqofS3M9KMXnckAtoW+/3vvdYwf+HJFouWwKBb3zk 3e947/vJUn/AFrc6whRNF2WKO/za+sWTzPFV/6b4Nk/VLHifEHzsxS3TK85zen52Hj+pZi28/ Mz9f4OLjO/5cz26qs6Ro2imxFGckGmoxFxUnAgAgiEr6aAIAAA== X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-3.tower-206.messagelabs.com!1497891489!100528609!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 33380 invoked from network); 19 Jun 2017 16:58:09 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-3.tower-206.messagelabs.com with SMTP; 19 Jun 2017 16:58:09 -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 D43E115BE; Mon, 19 Jun 2017 09:58:08 -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 DA9B23F41F; Mon, 19 Jun 2017 09:58:07 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Mon, 19 Jun 2017 17:57:45 +0100 Message-Id: <20170619165753.25049-9-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170619165753.25049-1-julien.grall@arm.com> References: <20170619165753.25049-1-julien.grall@arm.com> Cc: Ross Lagerwall , Julien Grall , sstabellini@kernel.org Subject: [Xen-devel] [PATCH v2 08/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 --- Cc: Ross Lagerwall Cc: Konrad Rzeszutek Wilk Changes in v2: - Add Stefano's reviewed-by - Still missing an ack from Konrad and/or Ross. --- 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 Mon Jun 19 16:57:46 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 105896 Delivered-To: patch@linaro.org Received: by 10.182.29.35 with SMTP id g3csp942452obh; Mon, 19 Jun 2017 09:59:59 -0700 (PDT) X-Received: by 10.36.82.11 with SMTP id d11mr21729389itb.43.1497891598977; Mon, 19 Jun 2017 09:59:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1497891598; cv=none; d=google.com; s=arc-20160816; b=xav+iF8Snllsz87/M4Ma79fCpwQhZJfMG5t1l/qTqtXVoKMrVwDWKnO0YLNq2jIYvG WpjfeqHh3la+2uQ/DiX2neouIz6WoO7OwVc5ohCsMiP840vu+KOYOoqBhWxeWd6alk1z j1kWQJ7cGPSG1ObNoVOkkRHMj4A2H74tvHNtr78QLTBw2ORgN8HfHuer2HM7KI1ntO51 mV7E7rV0oMLnmtXDA+CgKXnzHp6/1KVvpo0ZteL1chwL/EaIX/EyVR6yXUp0aU5kA6ty HrI70OLs8jvIgprL6UvVblNy6pAn8iOSWIO3aw/BVosbYFR1K94DyF+B1YYspaHv3xBS a5yQ== 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=2Mut2yJFn88ePTckMlLaP/702IM6XISpfAgMg6dMc34=; b=qLbvJGfnO7JUvyDqR1nAqhf+0FTzIUk3ZkG1ObZqMXa5A1U9jhR8LdrIQ7HPf1oxrh H7ZFQFpmgOLMj/7E1ZnHEkAxR23h2Q3cdCMGShCbMjVBW0CY24GBqy7A0gM25on9I6sg ete+pJBsFLhHMMnrxEy8HG899bAmonau49QHwR3zsbyqXbJ7rRw9THIeusbV4HD/8Fq/ Ae5MVohwSiQy3fW81Z7fBN21Wjy1CVYIksJSelzpvqz7qxGKo7PCxWUieKo52HJx3Rmx eOHhIUdGWCR0uFE+RGxeRA1IZLNLbe9UsmuyEo5Vr/lJxFWf+fh4uqGCuXkV71IS7alv OLUQ== 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 v6si10755552itb.54.2017.06.19.09.59.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 19 Jun 2017 09:59:58 -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 1dN00C-0003nK-3b; Mon, 19 Jun 2017 16:58:12 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dN00B-0003ir-6L for xen-devel@lists.xen.org; Mon, 19 Jun 2017 16:58:11 +0000 Received: from [193.109.254.147] by server-2.bemta-6.messagelabs.com id 0B/CB-03058-2A208495; Mon, 19 Jun 2017 16:58:10 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrCLMWRWlGSWpSXmKPExsVysyfVTXcRk0e kwZblchZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa8aUz2UFi6Qqfq1cxNzAuFGoi5GTQ0hgE6PE oubCLkYuIPs0o8T5LTcYQRJsApoSdz5/YgKxRQSkJa59vgwWZxZwkHjz8R4LiC0s4C5x/Pszd hCbRUBVYtXhhawgNq+AlcS+dxvAeiUE5CV2tV0Ei3MCxb/Pv8YIsdhS4viTW2wTGLkXMDKsYl QvTi0qSy3SNdFLKspMzyjJTczM0TU0MNPLTS0uTkxPzUlMKtZLzs/dxAj0LQMQ7GDsvux/iFG Sg0lJlHfWf/dIIb6k/JTKjMTijPii0pzU4kOMMhwcShK8mxg9IoUEi1LTUyvSMnOAQQaTluDg URLhtQMGmhBvcUFibnFmOkTqFKOilDjvSZA+AZBERmkeXBsssC8xykoJ8zICHSLEU5BalJtZg ir/ilGcg1FJmPcpyBSezLwSuOmvgBYzAS1mPuMCsrgkESEl1cDYI/T/l+CnJ3ZTI95uSuA4nb FN6Xds9e1wPRXBdF3GTW6OoRzP74SsN9q8L+CMaTXnYqWnCUf2fdjBypVztP+Z+93X0y+r8ln az0pec8L4lDTvbivxSVtYFzR1vs1UdFLSdOo/5jAhY/vT+h3iCdHTrV/kCTnbTJluXitl2zG5 74HfxEC7WzxKLMUZiYZazEXFiQADXcyJZwIAAA== X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-8.tower-27.messagelabs.com!1497891490!98132485!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 56788 invoked from network); 19 Jun 2017 16:58:10 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-8.tower-27.messagelabs.com with SMTP; 19 Jun 2017 16:58:10 -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 C5DDD344; Mon, 19 Jun 2017 09:58:09 -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 2297D3F41F; Mon, 19 Jun 2017 09:58:08 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Mon, 19 Jun 2017 17:57:46 +0100 Message-Id: <20170619165753.25049-10-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170619165753.25049-1-julien.grall@arm.com> References: <20170619165753.25049-1-julien.grall@arm.com> Cc: Julien Grall , sstabellini@kernel.org Subject: [Xen-devel] [PATCH v2 09/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 5612834dfc..8d34ae7279 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 Mon Jun 19 16:57:47 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 105901 Delivered-To: patch@linaro.org Received: by 10.182.29.35 with SMTP id g3csp942519obh; Mon, 19 Jun 2017 10:00:06 -0700 (PDT) X-Received: by 10.36.39.13 with SMTP id g13mr21342009ita.87.1497891606617; Mon, 19 Jun 2017 10:00:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1497891606; cv=none; d=google.com; s=arc-20160816; b=dT1DzA5YU+GHjS1elsmclJyoxYr0c5HTR8Ka82u8f3uPTn8y1rNIU1lTtw1N2ZHJTk GOaYFhruGxssJmPipFRpO2a7/S3JRSvvXJEc/wzejIlNaVLoHb79o15DFVY2JXpc4p5q NOKGh8JwXNdXT3A0rfJH08GMqbvawauj8E/5sxahJ5VZ0CN8LpeELVXkoJmlgKmcuCzN KzLmyeRh0iAQxaeyS1qC4ZjqpsaNtPheA8+i00l1q2SFw41f2sMOm9E7AuNrzFC+VWAi L9n7g/+PDoFgtObD6pTOlgtBpVTSFt8lah3lpByOAj+Bcd85hocnKQhCbDafMLD1J11c +ZgQ== 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=cNa63AHy5zD4bufXIooGXLO80w3xRLW/K5bGamxiHaJOu/iAW/3T9yZVxW7x6DBrKZ OXN7KQvJrBumitHgqRZc1I3LscRe3yrSjJ9iMMCKifrTIaiKNqMX63IkuX8G2S622T9t m0q2yZzUdD26ax8LpjSs/I+mOmgDQRSvDLnHitD4FAe8zpMtj/neCajGRDcxnfoTXbrP etEvNLNasCqdi3OWLAckIiBuocuBH34RzUl+0pv/fJGOKeO3L2nPdovzKR6bi/TF5+hR 4+QStR+GlaGY78ucB6OGnjxLEFSEm9UTEW1aTQ9sa1hTjR8Ezyp3KfMAs52KH//cz++5 hsxw== 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 l101si8915309iod.266.2017.06.19.10.00.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 19 Jun 2017 10:00:06 -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 1dN00F-0003rW-At; Mon, 19 Jun 2017 16:58:15 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dN00D-0003on-Et for xen-devel@lists.xen.org; Mon, 19 Jun 2017 16:58:13 +0000 Received: from [85.158.137.68] by server-13.bemta-3.messagelabs.com id 08/E2-17076-4A208495; Mon, 19 Jun 2017 16:58:12 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrKLMWRWlGSWpSXmKPExsVysyfVTXcxk0e kwdcL1hZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa8bjjTNZCn4VVTxdO5OlgXF/VBcjF4eQwGZG iUd3utkgnNOMEh2TfjB2MXJysAloStz5/IkJxBYRkJa49vkyUJyDg1kgSuL/NE4QU1jAR+LhW VaQChYBVYnPO9eCVfMKWEk8WLKZBcSWEJCX2NV2EayGEyj+ff41sOlCApYSx5/cYpvAyL2AkW EVo0ZxalFZapGukZleUlFmekZJbmJmjq6hgbFebmpxcWJ6ak5iUrFecn7uJkagd+sZGBh3MDb s9TvEKMnBpCTKO+u/e6QQX1J+SmVGYnFGfFFpTmrxIUYZDg4lCd5NjB6RQoJFqempFWmZOcAw g0lLcPAoifDW/AZq5S0uSMwtzkyHSJ1iVJQS5z0J0icAksgozYNrg4X2JUZZKWFeRgYGBiGeg tSi3MwSVPlXjOIcjErCvF0gl/Fk5pXATX8FtJgJaDHzGReQxSWJCCmpBsZVjlvmZGdyvyzfdP +EkZfz+akC7zYaCmTvFdIz8VstFXZr2aLg70vT8g7tbG4pihE/udOocN1uZ/Gc9gNzZj1sPJv NzR1ReYexTfTaI4691uI512Sbe6rUP4jcXHkqwOhcW+3X6ddmSryNy5747MAXm+yZh+zvTCya Km7CuLGutsY+LiRiF5cSS3FGoqEWc1FxIgD44kJbaAIAAA== X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-6.tower-31.messagelabs.com!1497891491!67805842!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 39075 invoked from network); 19 Jun 2017 16:58:11 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-6.tower-31.messagelabs.com with SMTP; 19 Jun 2017 16:58:11 -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 DF3A715AD; Mon, 19 Jun 2017 09:58:10 -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 14C133F41F; Mon, 19 Jun 2017 09:58:09 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Mon, 19 Jun 2017 17:57:47 +0100 Message-Id: <20170619165753.25049-11-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170619165753.25049-1-julien.grall@arm.com> References: <20170619165753.25049-1-julien.grall@arm.com> Cc: proskurin@sec.in.tum.de, Julien Grall , sstabellini@kernel.org Subject: [Xen-devel] [PATCH v2 10/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 --- 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 Mon Jun 19 16:57:48 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 105897 Delivered-To: patch@linaro.org Received: by 10.182.29.35 with SMTP id g3csp942454obh; Mon, 19 Jun 2017 09:59:59 -0700 (PDT) X-Received: by 10.36.65.18 with SMTP id x18mr23751105ita.88.1497891599151; Mon, 19 Jun 2017 09:59:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1497891599; cv=none; d=google.com; s=arc-20160816; b=qELAQK7dpcZz+4KCbhy0NenntjaKBsX1tk6pptlCelGISd+wOphlnXtM8MhcLiiK/m LBFOT+JvviKEmj7dkH+chUulEonMxt+kbYb9FwoCWexETVF8AxVvl4/ghia/f2w1UJTG PkUWv16UMAEw2vktF9bHgRip7EOPSOVRlXOTu7By+JnEXMq2DXmsHWFqKrEQcBYwsPaO 8ynmHtcd20Q3NxlgMWSX4EIHvDZ1Pdj2Chy6oA3yJOKJAJOx9Zt43qfztoxrBP7FpOPX 6gatHXiP8x5Th255p18cZucMcat3GyZ0S4TUHwonihbWk7KcunOn7hgaQQR+76mNKvab vC4Q== 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=RgFDMBSHO3uB7QI7/RCurRbuBPclaZr9VC402eFTTDA=; b=krVTOUEF7zadtTkZ3mB9Eujqv534jkltsTFXTtQk8P1fp7oO0WRH5ZVXL8ce+Me7zK whiJo1XEDUPJ5dcQnow5zyCLYmNwRn1bHiY1Lhm6dudvyLfewP5Yg1sd0tNxR9wJT3yP iS57tZ971xAbxGyVwnYGQueKqmFFyiXA+V6eKVqwmbcAGFnLyu8MsYdqNHMTElVbnzWW groAY/l1Gjtjd5QJofMs1DsdrktjHW+k5o3E5Zq/enDba4n6ojcEIxEEhrYAc+CQlE6w yzVcffFEAzP2QhvNDw1syAHXZybHgYPQtIl58rI3gcFdZNtixX3ul7uSnplW9PUzii1b 1QeA== 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 67si10337519ioq.41.2017.06.19.09.59.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 19 Jun 2017 09:59:59 -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 1dN00F-0003su-Rw; Mon, 19 Jun 2017 16:58:15 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dN00E-0003pe-9T for xen-devel@lists.xen.org; Mon, 19 Jun 2017 16:58:14 +0000 Received: from [85.158.137.68] by server-8.bemta-3.messagelabs.com id 58/4E-23755-5A208495; Mon, 19 Jun 2017 16:58:13 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrCLMWRWlGSWpSXmKPExsVysyfVTXcJk0e kwcRnVhZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa8bCsz2sBQ9VKtqudDA3MG6S7mLk4hAS2MQo MWn9XDYI5zSjxOmb/1m6GDk52AQ0Je58/sQEYosISEtc+3yZsYuRg4NZIEri/zROEFNYwEnix 04tkAoWAVWJFbtegnXyClhJfGk9C9YpISAvsavtIiuIzQkU/z7/GiOILSRgKXH8yS22CYzcCx gZVjGqF6cWlaUW6ZrpJRVlpmeU5CZm5ugaGhjr5aYWFyemp+YkJhXrJefnbmIE+raegYFxB+O VNudDjJIcTEqivLP+u0cK8SXlp1RmJBZnxBeV5qQWH2KU4eBQkuDdxOgRKSRYlJqeWpGWmQMM Mpi0BAePkghvzW+gVt7igsTc4sx0iNQpRkUpcd6TIH0CIImM0jy4NlhgX2KUlRLmZWRgYBDiK Ugtys0sQZV/xSjOwagkzPsUZApPZl4J3PRXQIuZgBYzn3EBWVySiJCSamD0jd/zqL/71exU1q ZPFWcnH0yZ6L097Ud6UjpDy8LQa+HprUmdl6TKitg9b0ZOu/tKeErchIpHPXNEpl0s8n728cm iJTyS/13K16rL5u6enBaYv/ucR9ccg6KXmqLLLvAzWPg3rWWp93O4kiK+0Cpavmjv342f0w8I KOxhPFBte/ZQdvZxjbVKLMUZiYZazEXFiQAy28JoZwIAAA== X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-4.tower-31.messagelabs.com!1497891492!48279978!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 40852 invoked from network); 19 Jun 2017 16:58:12 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-4.tower-31.messagelabs.com with SMTP; 19 Jun 2017 16:58:12 -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 04E8B344; Mon, 19 Jun 2017 09:58:12 -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 2E63B3F41F; Mon, 19 Jun 2017 09:58:11 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Mon, 19 Jun 2017 17:57:48 +0100 Message-Id: <20170619165753.25049-12-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170619165753.25049-1-julien.grall@arm.com> References: <20170619165753.25049-1-julien.grall@arm.com> Cc: proskurin@sec.in.tum.de, Julien Grall , sstabellini@kernel.org Subject: [Xen-devel] [PATCH v2 11/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 --- 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 --- 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 Mon Jun 19 16:57:49 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 105888 Delivered-To: patch@linaro.org Received: by 10.182.29.35 with SMTP id g3csp942378obh; Mon, 19 Jun 2017 09:59:45 -0700 (PDT) X-Received: by 10.36.237.206 with SMTP id r197mr22891158ith.52.1497891585573; Mon, 19 Jun 2017 09:59:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1497891585; cv=none; d=google.com; s=arc-20160816; b=PBMMLtNmi0uFMeVl6+10NQuZaGKJWp8TYPH3oQIbH+JFDNWmMxCulWogOdLre3aT4i DIjo3q/A+P8jRA4A+RWwBp0x5fUJnEuOw0OYVol7bM6epKbp9UeqasQntiRhmIMC9YfB ah224DTk31P0+0p6i51DZjwIG0rk5Muz4/uhWAXs2d78/Dd0y9UUVztt3p80oNZHHdV1 QzB2TX/5o6KboxPU2meq0TemNoxKxK8W3sXMLcRGwWOHNCEsbuqr/I6qhkXc/kowsk+W YLiKLXi0U0ibKGqaFmZ7STMdmJwU1g99VAD1MwTkoTxI9/dt4ygu8Kr/D2taI7DxmEPQ p7Aw== 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=k4Q2ls4cfbOH9o1GcNaFnwWF6Rz1/4NPFAY+rO2ApHs=; b=l6bTGBZfQ3wbqZENsU3SZXGtJmOX2aJBKeEhMZrAJPpYgCKncVMGETlKxR81rcUo3c kjhPTR9HCKKVXELPRWUmSEbRLBT34GqRHozgOfMc3PrzgSOR2cB1IKFmmRDixJDCpvd/ TZdksS1jfEtpmdy9q9yxd1nU70nSYY4rwjSMORrTXuIHk+v+PaGyUqdKQAR2wS9OK4km oHAMI6NzbS+4zILhlxZcLA9s99XapetFkHFal+s47KunsPgECe6utZOn5/jOh+p1lvLo 3GEhsICFTKue7nn3zQQukC89532GsjZpSvjQdxO2UzipZeywdxsw5aMlyOZPzbudM1KL K/KA== 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 q73si11286894itb.97.2017.06.19.09.59.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 19 Jun 2017 09:59: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 1dN00G-0003uA-6f; Mon, 19 Jun 2017 16:58:16 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dN00F-0003qY-1a for xen-devel@lists.xen.org; Mon, 19 Jun 2017 16:58:15 +0000 Received: from [193.109.254.147] by server-11.bemta-6.messagelabs.com id 02/D7-03587-6A208495; Mon, 19 Jun 2017 16:58:14 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrKLMWRWlGSWpSXmKPExsVysyfVTXcpk0e kQdNDS4slHxezODB6HN39mymAMYo1My8pvyKBNWNO61LGgmO6Fc+eezUw9ih3MXJxCAlsZpR4 /nA7M4RzmlHi8dEZLF2MnBxsApoSdz5/YgKxRQSkJa59vszYxcjBwSwQJfF/GidIWFggVeJP2 zQ2EJtFQFXixZT1YDavgJXEk4ZvjCC2hIC8xK62i6wgNidQ/Pv8a2BxIQFLieNPbrFNYORewM iwilGjOLWoLLVI19hQL6koMz2jJDcxM0fX0MBMLze1uDgxPTUnMalYLzk/dxMj0LsMQLCDsWl R4CFGSQ4mJVHeWf/dI4X4kvJTKjMSizPii0pzUosPMcpwcChJ8KoyekQKCRalpqdWpGXmAMMM Ji3BwaMkwlvzG6iVt7ggMbc4Mx0idYpRUUqcVwGkTwAkkVGaB9cGC+1LjLJSwryMQIcI8RSkF uVmlqDKv2IU52BUEubtArmMJzOvBG76K6DFTECLmc+4gCwuSURISTUwSjDyety8ZlW1sUXr+3 2N9ptJy21fStjPO9jzaVJEZVhAxu7vJoVH6qr590/tXhFm81Xk0mnrWJ7oKbMjnwVn+7PfNo4 VnBqusrx133pTjvvvVc7abp10/qXnzzWlbi6uepeElHNXn29YzPHgiEL9B4MM1yAZxZlm8dz3 I8+/YfnI21nFvUhDiaU4I9FQi7moOBEAnhov3mgCAAA= X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-2.tower-27.messagelabs.com!1497891493!48857678!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 17501 invoked from network); 19 Jun 2017 16:58:13 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-2.tower-27.messagelabs.com with SMTP; 19 Jun 2017 16:58:13 -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 1E03C15BE; Mon, 19 Jun 2017 09:58:13 -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 47BA03F41F; Mon, 19 Jun 2017 09:58:12 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Mon, 19 Jun 2017 17:57:49 +0100 Message-Id: <20170619165753.25049-13-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170619165753.25049-1-julien.grall@arm.com> References: <20170619165753.25049-1-julien.grall@arm.com> Cc: proskurin@sec.in.tum.de, Julien Grall , sstabellini@kernel.org Subject: [Xen-devel] [PATCH v2 12/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 --- Cc: proskurin@sec.in.tum.de Changes in v2: - Patch added --- 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 6c1ac70044..1136d837fb 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 Mon Jun 19 16:57:50 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 105892 Delivered-To: patch@linaro.org Received: by 10.182.29.35 with SMTP id g3csp942434obh; Mon, 19 Jun 2017 09:59:55 -0700 (PDT) X-Received: by 10.36.124.143 with SMTP id a137mr22982105itd.30.1497891595812; Mon, 19 Jun 2017 09:59:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1497891595; cv=none; d=google.com; s=arc-20160816; b=HsT8Uj0N4F4J33iEMY40ozl3fz2R96VLHekEBPWCwwkE+HXh24OCNb7GVjaldUnMwD PxXk8Twju0jEkTuMQCSx3Pv4mXYSK9ba3NPVMASIWud6JN1lBEK1mXGFGZfWSBMtIaj0 ISYuQkqMlYouxCkOrDNIaJheGkhAlkb8LeuUM8f1FBZhwxGKeY39s4FV+WHkaMfOci7U fWqrB1W6poYTZTzOuQlvYveKgum+7yG5GrqYMkUoI6oMsz4X7BjxOBAmFK3x8C7N2Nge b7fQYDAR9zFuVXErtUd0RakfLD7P6MM4e64e7tQioi0BcEI7uK9NOG07ud5zT54H3y+v RuTQ== 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=fDR6HTDUMoUYNJtf3U1RtVHnxLWrUAC8VLGSG79f2bg=; b=SvnHtngsxR3QbVw8bTfOAqYdTATj11J1cQhyQIYNa2qYJ0HcowR6wMyiLxSqruS2V3 GHZh2I1NBHLYu8hohGfbd9baDPLGKPIdLO59AwYdSLJPMqQcY5dRaPAD3RfTUT6UbQgd P8Bxb4+pPRhpp5l7aanU1t52UKzel6AV9k5t81mCrS9zqT8jq0upD76TbniXZWKRwgXB 9zX2Tknp+U57cSWVdh/MBvW6FKI8FEv5heVHR9Z67qOsv5JaDmapZjRVjvskC1UQmD/f QNoX7PCIX9/Ao+qs3X83FtC5AYRfkcgZTNO3ZRmIcoipCaey1x/GZjvhdvc9i7NBNsu8 ZZYA== 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 y99si12020156ioe.224.2017.06.19.09.59.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 19 Jun 2017 09:59:55 -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 1dN00H-0003wX-Dy; Mon, 19 Jun 2017 16:58:17 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dN00G-0003sP-69 for xen-devel@lists.xen.org; Mon, 19 Jun 2017 16:58:16 +0000 Received: from [85.158.137.68] by server-3.bemta-3.messagelabs.com id ED/CE-01985-7A208495; Mon, 19 Jun 2017 16:58:15 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrCLMWRWlGSWpSXmKPExsVysyfVTXcZk0e kweGD1hZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa8b/BS2sBU8FK861PmFqYHzI18XIxSEksJlR ondpFzuEc5pRoqfzL3MXIycHm4CmxJ3Pn5hAbBEBaYlrny8zdjFycDALREn8n8YJEhYWcJV43 NvKBBJmEVCV2PdeHsTkFbCSOHIjBaRCQkBeYlfbRVYQmxMo/H3+NUYQW0jAUuL4k1tsExi5Fz AyrGLUKE4tKkst0jUy1ksqykzPKMlNzMzRNTQw1stNLS5OTE/NSUwq1kvOz93ECPRtPQMD4w7 Gvr1+hxglOZiURHln/XePFOJLyk+pzEgszogvKs1JLT7EKMPBoSTBu4nRI1JIsCg1PbUiLTMH GGQwaQkOHiURXjtgoAnxFhck5hZnpkOkTjEqSonzngTpEwBJZJTmwbXBAvsSo6yUMC8jAwODE E9BalFuZgmq/CtGcQ5GJWHepyBTeDLzSuCmvwJazAS0mPmMC8jikkSElFQDI7vUziMZLT+eOD UcDbm0cef8MveylebzLM142B/ve7m3wG0154ztfbWGm1c0JjXNl31cNneThO/qD8amP+o8Jrn ucc9p7Juxn/GVg7MG0+wza/ySFq9832EjtELxH2tmotzX/cJMh05Znfj4wcbJseAhr1qeh6nh 9Mb0jWallucXejN17BLhUGIpzkg01GIuKk4EADQ/N7RnAgAA X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-12.tower-31.messagelabs.com!1497891494!89562475!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 31063 invoked from network); 19 Jun 2017 16:58:14 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-12.tower-31.messagelabs.com with SMTP; 19 Jun 2017 16:58:14 -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 367231610; Mon, 19 Jun 2017 09:58:14 -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 6073F3F41F; Mon, 19 Jun 2017 09:58:13 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Mon, 19 Jun 2017 17:57:50 +0100 Message-Id: <20170619165753.25049-14-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170619165753.25049-1-julien.grall@arm.com> References: <20170619165753.25049-1-julien.grall@arm.com> Cc: proskurin@sec.in.tum.de, Julien Grall , sstabellini@kernel.org Subject: [Xen-devel] [PATCH v2 13/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 --- Cc: proskurin@sec.in.tum.de Changes in v2: - Patch added --- 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 1136d837fb..f9145f052f 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 Mon Jun 19 16:57:51 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 105903 Delivered-To: patch@linaro.org Received: by 10.182.29.35 with SMTP id g3csp942583obh; Mon, 19 Jun 2017 10:00:12 -0700 (PDT) X-Received: by 10.36.160.8 with SMTP id o8mr10670850ite.10.1497891612713; Mon, 19 Jun 2017 10:00:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1497891612; cv=none; d=google.com; s=arc-20160816; b=PebRCNNnnB3CCFw7qfDn6ky2EC3UE4MLJws3kr6sciwpo2fyy2cqZnSlCfCyuBvg3h Mumbpgk5XsUELdMvOBvdyZTvoVcaSpp5RSBgnvbHCUmK76Q9i1zu+KFk59j9RyBIvM25 2kAaIjAn5DD0m4XOgpWn9fZo3/xitF0C0/jBBEc+srGk0Ye2yW1jeUCUFqisrlx1q2i0 9hvvWkUPDiYM/2WRiWnFRlsCAB0svB+712wtAKrg3cKJ0BQS+qIpNAyVIgX8LGILPoYO g+ZH5AfBRtgKC2rg/1No9Sjw3AOkGZFROtR6E1CVKc0NA2DnlVaxuj3G+DL7yJEnvuO/ zQfA== 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=gaJAJfLzkz96uvNZII6SuevPnA3FtTu0xHeTMJ0ETjg=; b=UdQbrhjgwbqXeD3WVwo+oQqNeQDtKJBVPE/6QFiB+LnvFLPYkZhHZNCRaqhry6bOtt MGa3bRuuh7V9CyfnA54Ba4OdpBwcVzNF4jC6CTNxcBRf5haVTVERvuOVOgRpJAHLoVZK rJhab4unOJUKuOFdTzWkNvEOmQjzutFKYrUuM2zlTDKy5UUgXwduffEiOPFGmN2W2FNc 0d4V2isXuQ4akl6Rq052zqj3Ld0op16oOFMp7Hcrw2T74DXlqBmF3o6VZ+KhS14ph2ii LRmyxy3LtEI3D8Dwb9kp+j+qyuaC8WW3QfOuHOMuhUsUq2n9iTvLmXgV/xxcy+XCrIJN odyA== 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 z143si6946540itb.40.2017.06.19.10.00.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 19 Jun 2017 10:00: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 1dN00I-0003yk-L0; Mon, 19 Jun 2017 16:58:18 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dN00G-0003pe-LC for xen-devel@lists.xen.org; Mon, 19 Jun 2017 16:58:16 +0000 Received: from [85.158.137.68] by server-8.bemta-3.messagelabs.com id B9/5E-23755-8A208495; Mon, 19 Jun 2017 16:58:16 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrELMWRWlGSWpSXmKPExsVysyfVTXc5k0e kQXOnhcWSj4tZHBg9ju7+zRTAGMWamZeUX5HAmrFk8lOWgi0CFau3nGJpYLzL3cXIxSEksJlR YsO8ycwQzmlGid57h1m6GDk52AQ0Je58/sQEYosISEtc+3yZEcRmFnCQePPxHliNsECUxMyVk 8BsFgFViXu3FoLZvAJWEpt3vmYGsSUE5CV2tV1kBbE5geLf518DmyMkYClx/MkttgmM3AsYGV YxqhenFpWlFula6iUVZaZnlOQmZuboGhoY6+WmFhcnpqfmJCYV6yXn525iBPq3noGBcQfj659 OhxglOZiURHln/XePFOJLyk+pzEgszogvKs1JLT7EKMPBoSTBq8roESkkWJSanlqRlpkDDDSY tAQHj5IIb81voFbe4oLE3OLMdIjUKUZdjhVvd31hEmLJy89LlRLnPQkyQwCkKKM0D24ELOgvM cpKCfMyMjAwCPEUpBblZpagyr9iFOdgVBLm7QK5kiczrwRu0yugI5iAjmA+4wJyREkiQkqqgd Fh8YVWqS0XYzds3n2R1/vKpCcx7Ju+LetX2yh2y+Ss0efLXyPzaorvh32drXGfLXexivfUeM7 cTWa51+e8khbYerdtF2fH/B0/+0xbK3VFBffsrFJKnvOVYVnD04+fFtzK/xzqODWxtbvAiu+u 4NbMP0obZz30LT7DGPEnXiarOWT9wR6jYF4lluKMREMt5qLiRAAyIRdrdQIAAA== X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-13.tower-31.messagelabs.com!1497891495!105722322!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 20311 invoked from network); 19 Jun 2017 16:58:15 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-13.tower-31.messagelabs.com with SMTP; 19 Jun 2017 16:58:15 -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 2873D165C; Mon, 19 Jun 2017 09:58:15 -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 7A31C3F41F; Mon, 19 Jun 2017 09:58:14 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Mon, 19 Jun 2017 17:57:51 +0100 Message-Id: <20170619165753.25049-15-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170619165753.25049-1-julien.grall@arm.com> References: <20170619165753.25049-1-julien.grall@arm.com> Cc: Julien Grall , sstabellini@kernel.org Subject: [Xen-devel] [PATCH v2 14/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 --- 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 8d34ae7279..6241c53821 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 Mon Jun 19 16:57:52 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 105904 Delivered-To: patch@linaro.org Received: by 10.182.29.35 with SMTP id g3csp942588obh; Mon, 19 Jun 2017 10:00:13 -0700 (PDT) X-Received: by 10.36.120.134 with SMTP id p128mr13553037itc.19.1497891612982; Mon, 19 Jun 2017 10:00:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1497891612; cv=none; d=google.com; s=arc-20160816; b=cwIVHXNxOwbNrUZpq2MMrWuftSWXVNCd7FyZPa8r0wT0VpEjVWueqIsflwuJO7K9hb HChk6k7oGxjbySWJKe1p+JTTIP4TQ8vrUSKogJf3Epp0GxIxdOtjTx22eUDZZAqbeYCZ 8dm2kcQXLeutq6NNPqWfE839bhpKg8iWGihFhK7EcIxasbio3RrJ1cITeJM/b2XvYhtz B21J1MXvSk7SnV8qUPhVGv6/PofWARTar8ebUI0S5AEbdHEsobYpc20Pf0Y+8gXv6GSD m52EFics4/5oRmxq0/o0gMwcSyUYaAdJT2WC3igQ3AE2v/t4mYXmX0wswGt5cifM3ien VBAQ== 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=gdOd23kxgMOMRqLG0ZIC99T/12hy0dM587euPbYyMhc=; b=tC8Q6Ec4dfyxIRT4c1TOqZHeJI3139ESjjmrSzk0cDVPey4vyV15274miveRyjJN/K 2dBg5aiF3zoGw5eegInPxpfALPzfYko+CQ9kSoBeHqQqBqvv1T6Ak3mL3chwwXJcXRYz GQyOHiiSi2mH+ov5g5ABERJmr+FxizPUjCtyHLs8ph+RANuxtLQB6N96hvaKLmGe/ZWA YYhpkf+izOKb+qItpAi6df5nyLl/qr7VDxWKXondTmP7gXPOh9/O6/H/qmjhep1F5+mp ivZdEHdtBqSo1T/09MhnmsdmKBix+R++YDlND/rolod40jHMRzevi0HNE4Jab++01QoD ioOg== 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 n138si10977585itn.73.2017.06.19.10.00.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 19 Jun 2017 10:00: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 1dN00I-0003zI-S1; Mon, 19 Jun 2017 16:58:18 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dN00I-0003wv-0U for xen-devel@lists.xen.org; Mon, 19 Jun 2017 16:58:18 +0000 Received: from [193.109.254.147] by server-4.bemta-6.messagelabs.com id 90/3E-02956-9A208495; Mon, 19 Jun 2017 16:58:17 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrELMWRWlGSWpSXmKPExsVysyfVTXcFk0e kwar5+hZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa8amY2tZC+5KVjT/3MbawHhBoIuRk0NIYDOj xIG5Xl2MXED2aUaJ39+bWUASbAKaEnc+f2ICsUUEpCWufb7MCGIzCzhIvPl4D6xGWCBSYtr24 +wgNouAqsT9LR/AangFrCSW/X7MDGJLCMhL7Gq7yApicwLFv8+/xgix2FLi+JNbbBMYuRcwMq xi1ChOLSpLLdI1NNdLKspMzyjJTczM0TU0MNPLTS0uTkxPzUlMKtZLzs/dxAj0LwMQ7GC8vTH gEKMkB5OSKO+s/+6RQnxJ+SmVGYnFGfFFpTmpxYcYZTg4lCR4NzF6RAoJFqWmp1akZeYAAw0m LcHBoyTCW/MbqJW3uCAxtzgzHSJ1ilGXY8XbXV+YhFjy8vNSpcR5T4LMEAApyijNgxsBC/pLj LJSwryMQEcJ8RSkFuVmlqDKv2IU52BUEuZ9CjKFJzOvBG7TK6AjmICOYD7jAnJESSJCSqqB0X DOOQ5h0XW3ZesXOzQnulYtjphzp2nOlXVCbg8KLLXSpCQjVDZYHci4nP3Rp/FX0o31iZVyKS3 mPQ85V7qcUc559yBm9c6zGy7pMIRVMS/cuV4xR9Uy5ss62775nyfKm0WuF+cwnjlBWX33ye9h VrGsAWe7lz16PtPx8Fb3SbPrObKyVC54KLEUZyQaajEXFScCAOpHi2B1AgAA X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-7.tower-27.messagelabs.com!1497891496!103807769!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 21722 invoked from network); 19 Jun 2017 16:58:16 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-7.tower-27.messagelabs.com with SMTP; 19 Jun 2017 16:58:16 -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 178E01684; Mon, 19 Jun 2017 09:58:16 -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 6A71E3F41F; Mon, 19 Jun 2017 09:58:15 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Mon, 19 Jun 2017 17:57:52 +0100 Message-Id: <20170619165753.25049-16-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170619165753.25049-1-julien.grall@arm.com> References: <20170619165753.25049-1-julien.grall@arm.com> Cc: Julien Grall , sstabellini@kernel.org Subject: [Xen-devel] [PATCH v2 15/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 --- 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 6241c53821..657fee0b17 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 Mon Jun 19 16:57:53 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 105889 Delivered-To: patch@linaro.org Received: by 10.182.29.35 with SMTP id g3csp942380obh; Mon, 19 Jun 2017 09:59:46 -0700 (PDT) X-Received: by 10.36.33.210 with SMTP id e201mr23008088ita.112.1497891586381; Mon, 19 Jun 2017 09:59:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1497891586; cv=none; d=google.com; s=arc-20160816; b=BvUAgPq+2n2xZqZsqMVvAMNKrANNqm9Qku4H9/T8vtzAdQN484SGD4cysWfNqmbX8x Y8tBffmmwuAlnRA/9S/8fLWn33Pz8DgYHLn94yUgIf5H3+GfJtdzEEzW5K0utUnxEgCP N7Cm/IuvJbDPgvTjxOqAL/4gO9jeesWiRuLQPhJBPxxaqo4t0RvwuU56ap+PIeoIDCic KoGR3c27M04DOXjIM8nWczSbxYs+h3KEZWe5+XT7fwaVtU0c/YD6prKikTmfPE64R1gD ycKg5y2KgvtPYl4753WGhPUfIbGC2DRRQcQ5MxaMANOqu+LTZgriVprBrWNRxxIQ+Q3+ L7uw== 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=lv0LM1bGM8CHW85cpatmgNI19Qgf9nAdlZIvmLk2NWI=; b=nJgLcWT1G7rPpHZB8V8RbAAqXSucMQzhjhg6WQoQ/E4YL+uhVle0EXcf9Id7n3RWym XrV75Dx5UsTeWcgQlOqNAQyEVYvSRv45bFBcKiM4zyguStWDF1rmPa/wlqXkE05iS+pH 4hODgknKby4V9GcIPfXCyb6nz5sk1VZ+huAa0MGpQ9REg7ZgT7Q3guqY1VdzjcFSh7Ca si2ksa3bZyGndXdUMLRuZC4VnfSiBb7i65QWp13K2tlRjOnlL3LQ4KGF3h8FZ98og7Di cOYXl+bSgjj/Ovp7HG5S+RLVjXTVzRj+/urmNkLXB0I/LD+ulq2adqlS2uw0cqlfLjT/ L9bg== 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 d9si10265561iod.20.2017.06.19.09.59.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 19 Jun 2017 09:59:46 -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 1dN00K-00042G-4a; Mon, 19 Jun 2017 16:58:20 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dN00J-0003yf-3s for xen-devel@lists.xen.org; Mon, 19 Jun 2017 16:58:19 +0000 Received: from [85.158.137.68] by server-9.bemta-3.messagelabs.com id 5F/66-26749-AA208495; Mon, 19 Jun 2017 16:58:18 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrILMWRWlGSWpSXmKPExsVysyfVTXclk0e kweRGA4slHxezODB6HN39mymAMYo1My8pvyKBNePYinfsBSeFKjYeC21g7ODuYuTkEBLYzCjx 5qVRFyMXkH2aUWLShR/MIAk2AU2JO58/MYHYIgLSEtc+X2YEsZkFHCTefLzHAmILC0RLvFj/F qyeRUBVYuqK1WBxXgEricv7PrCD2BIC8hK72i6ygticQPHv868xQiy2lDj+5BbbBEbuBYwMqx g1ilOLylKLdA1N9ZKKMtMzSnITM3N0DQ2M9XJTi4sT01NzEpOK9ZLzczcxAr3LAAQ7GNds9zz EKMnBpCTKO+u/e6QQX1J+SmVGYnFGfFFpTmrxIUYZDg4lCd5NjB6RQoJFqempFWmZOcAwg0lL cPAoifDaAUNNiLe4IDG3ODMdInWKUZdjxdtdX5iEWPLy81KlxHlPgswQACnKKM2DGwEL+UuMs lLCvIxARwnxFKQW5WaWoMq/YhTnYFQS5n0KMoUnM68EbtMroCOYgI5gPuMCckRJIkJKqoFRnE mHbfWv2a4mJjYrPt7f+/zUza13FyS973S/kffC1Juz+tqdE9e0tz9/rTN9tlZf2MJE90VbO84 xRr24eUvr0QXt8zw93Zf/PLF6y7+hhc/Fea72/u/L9Ap4jNe/+Hylt1LfYtWqY8b8zqH6r6Td 3U86S8//8vjoQ7MbyQEe21Yf3TzRqvK6nBJLcUaioRZzUXEiAFH+0AR0AgAA X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-14.tower-31.messagelabs.com!1497891497!106202486!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 28363 invoked from network); 19 Jun 2017 16:58:17 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-14.tower-31.messagelabs.com with SMTP; 19 Jun 2017 16:58:17 -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 084F31688; Mon, 19 Jun 2017 09:58:17 -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 59C6D3F41F; Mon, 19 Jun 2017 09:58:16 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Mon, 19 Jun 2017 17:57:53 +0100 Message-Id: <20170619165753.25049-17-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170619165753.25049-1-julien.grall@arm.com> References: <20170619165753.25049-1-julien.grall@arm.com> Cc: Julien Grall , sstabellini@kernel.org Subject: [Xen-devel] [PATCH v2 16/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 Stabellini --- Changes in v2: - Patch added --- 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 657fee0b17..91af4c8743 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; } }