From patchwork Tue Jun 13 16:13:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 105405 Delivered-To: patch@linaro.org Received: by 10.140.91.77 with SMTP id y71csp486566qgd; Tue, 13 Jun 2017 09:15:41 -0700 (PDT) X-Received: by 10.107.9.93 with SMTP id j90mr831487ioi.172.1497370541404; Tue, 13 Jun 2017 09:15:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1497370541; cv=none; d=google.com; s=arc-20160816; b=jYYPHX6LkTiKGlS6o0Q8eyAZDOm8cj1pd/sU6h0On0DQO65vUyBNWhm9hBBeWZ4ufj r7WD9LSyG9HxNF2nQVVFlSH9ZFrWhIo1OYmoWdleFsPBVNjIYdBfqHp8mRHZoRIXhpgd aq0qoWjK7hH/aPfWOpM+kK43Z7yc6SeeHp8mD2nvicQrnqlb9pMvSVZalpTFgTGb+Ag0 DV5Y61nQ7Exr4iFHsM1LcRBUbwecpeDilKC4EnTmtTxkEaLg5xmf+ciJnwc/m3e6/jXP YTZweFDhfZSs10RU6XzpCKM+1Cu8gfYiQ3MvMQ444JrG6yzKcTjLJ8Je73bFObKMsq2J XNXQ== 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=KJkwyF6bj+83oWW2cA1PEmPiyyqOSBYaG+At9r4U2sA=; b=lFjHiQcVoNuoraXoU+ZA2VB1wQBIuy7lzGQ8NEIlQPRAY8IHtIXdqJ6TffVYga3+1O WKbGUOAm9YjJVkgfaiOOsSpNZgNgSVtgFAJOR0QOE/+w3xP1K7ee8J7gKqK3gFsAwEus hkKQ0MO2ullJh7QqLnMC88FDLwm5I1mykoNFDWXyMCUXVJdxLYvPiVyj25ucQ37Kj3+8 6i2GVj0yUSXg5/WcCM7SbVC1fBqVEcZmEN0ATCdl/bZc1ZNsEKKTzcJwGFNyaYZVyu3r TzisGNLGxeDe9naP9+aTgvhV5OZ2R0iAy8zFSZl2v8xCpH7lReTyFWXMJ44b24o+B7RS JEPw== 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 m9si419921iti.21.2017.06.13.09.15.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 13 Jun 2017 09:15:41 -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 1dKoRo-00084z-9f; Tue, 13 Jun 2017 16:13:40 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dKoRn-00083h-FA for xen-devel@lists.xen.org; Tue, 13 Jun 2017 16:13:39 +0000 Received: from [85.158.139.211] by server-7.bemta-5.messagelabs.com id 84/EC-02181-23F00495; Tue, 13 Jun 2017 16:13:38 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrOLMWRWlGSWpSXmKPExsVysyfVTdeQ3yH SYPZjK4slHxezODB6HN39mymAMYo1My8pvyKBNePN3w+MBXMMK/omHGRsYHyv2MXIxSEksJlR 4u3p98wQzmlGieZ7W1m6GDk52AQ0Je58/sQEYosISEtc+3yZEcRmFoiQaFqwFywuLOArsXLqR rB6FgFViYdrP4LFeQUsJf6e/MkMYksIyEvsarvICmJzClhJXHreBDZHCKimefd6pgmM3AsYGV YxahSnFpWlFukameglFWWmZ5TkJmbm6BoamOrlphYXJ6an5iQmFesl5+duYgR6uJ6BgXEH483 JfocYJTmYlER5t1yxiRTiS8pPqcxILM6ILyrNSS0+xCjDwaEkwWvP5xApJFiUmp5akZaZAww1 mLQEB4+SCO99FqA0b3FBYm5xZjpE6hSjopQ47x9eoIQASCKjNA+uDRbelxhlpYR5GRkYGIR4C lKLcjNLUOVfMYpzMCoJ87bwAE3hycwrgZv+CmgxE9Di6yA38xaXJCKkpBoYZV8/XHdoupPJjZ yXp78fv609yc18ocLeL5xBvgYTrl0/evxQ9ExLYfWUpMvP6hfGOHGzHNxz0Vjo9R9NXfGszSW BS//1rDh2so6/Qt6faZOfrfgx63sp5q+mG9p5vnG3sHpvW247484DmeTQo471BUUf9qmU3dn4 Wb7V21f0wv/nec1MfCxflFiKMxINtZiLihMBa8HfF2oCAAA= X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-12.tower-206.messagelabs.com!1497370417!66951659!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 20895 invoked from network); 13 Jun 2017 16:13:37 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-12.tower-206.messagelabs.com with SMTP; 13 Jun 2017 16:13:37 -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 02D9915A2; Tue, 13 Jun 2017 09:13:37 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.206.53]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 3DCF63F557; Tue, 13 Jun 2017 09:13:36 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Tue, 13 Jun 2017 17:13:04 +0100 Message-Id: <20170613161323.25196-6-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170613161323.25196-1-julien.grall@arm.com> References: <20170613161323.25196-1-julien.grall@arm.com> Cc: Julien Grall , sstabellini@kernel.org, punit.agrawal@arm.com Subject: [Xen-devel] [PATCH 05/24] xen/arm: mm: Move mfn_to_xen_entry from page.h to mm.c 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 mm.c is the only user of mfn_to_xen_entry. This will also help to use the typesafe MFN. Signed-off-by: Julien Grall Reviewed-by: Stefano Stabellini --- xen/arch/arm/mm.c | 65 ++++++++++++++++++++++++++++++++++++++++++++++ xen/include/asm-arm/page.h | 65 ---------------------------------------------- 2 files changed, 65 insertions(+), 65 deletions(-) diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c index b4ff777b55..587a6b3975 100644 --- a/xen/arch/arm/mm.c +++ b/xen/arch/arm/mm.c @@ -254,6 +254,71 @@ void dump_hyp_walk(vaddr_t addr) dump_pt_walk(ttbr, addr, HYP_PT_ROOT_LEVEL, 1); } +/* Standard entry type that we'll use to build Xen's own pagetables. + * We put the same permissions at every level, because they're ignored + * by the walker in non-leaf entries. */ +static inline lpae_t mfn_to_xen_entry(unsigned long mfn, unsigned attr) +{ + paddr_t pa = ((paddr_t) mfn) << PAGE_SHIFT; + lpae_t e = (lpae_t) { + .pt = { + .valid = 1, /* Mappings are present */ + .table = 0, /* Set to 1 for links and 4k maps */ + .ai = attr, + .ns = 1, /* Hyp mode is in the non-secure world */ + .user = 1, /* See below */ + .ro = 0, /* Assume read-write */ + .af = 1, /* No need for access tracking */ + .ng = 1, /* Makes TLB flushes easier */ + .contig = 0, /* Assume non-contiguous */ + .xn = 1, /* No need to execute outside .text */ + .avail = 0, /* Reference count for domheap mapping */ + }};; + /* Setting the User bit is strange, but the ATS1H[RW] instructions + * don't seem to work otherwise, and since we never run on Xen + * pagetables in User mode it's OK. If this changes, remember + * to update the hard-coded values in head.S too */ + + switch ( attr ) + { + case BUFFERABLE: + /* + * ARM ARM: Overlaying the shareability attribute (DDI + * 0406C.b B3-1376 to 1377) + * + * A memory region with a resultant memory type attribute of Normal, + * and a resultant cacheability attribute of Inner Non-cacheable, + * Outer Non-cacheable, must have a resultant shareability attribute + * of Outer Shareable, otherwise shareability is UNPREDICTABLE. + * + * On ARMv8 sharability is ignored and explicitly treated as Outer + * Shareable for Normal Inner Non_cacheable, Outer Non-cacheable. + */ + e.pt.sh = LPAE_SH_OUTER; + break; + case UNCACHED: + case DEV_SHARED: + /* Shareability is ignored for non-Normal memory, Outer is as + * good as anything. + * + * On ARMv8 sharability is ignored and explicitly treated as Outer + * Shareable for any device memory type. + */ + e.pt.sh = LPAE_SH_OUTER; + break; + default: + e.pt.sh = LPAE_SH_INNER; /* Xen mappings are SMP coherent */ + break; + } + + ASSERT(!(pa & ~PAGE_MASK)); + ASSERT(!(pa & ~PADDR_MASK)); + + // XXX shifts + e.bits |= pa; + return e; +} + /* Map a 4k page in a fixmap entry */ void set_fixmap(unsigned map, unsigned long mfn, unsigned attributes) { diff --git a/xen/include/asm-arm/page.h b/xen/include/asm-arm/page.h index 497b4c86ad..3670ab665d 100644 --- a/xen/include/asm-arm/page.h +++ b/xen/include/asm-arm/page.h @@ -205,71 +205,6 @@ typedef union { lpae_walk_t walk; } lpae_t; -/* Standard entry type that we'll use to build Xen's own pagetables. - * We put the same permissions at every level, because they're ignored - * by the walker in non-leaf entries. */ -static inline lpae_t mfn_to_xen_entry(unsigned long mfn, unsigned attr) -{ - paddr_t pa = ((paddr_t) mfn) << PAGE_SHIFT; - lpae_t e = (lpae_t) { - .pt = { - .valid = 1, /* Mappings are present */ - .table = 0, /* Set to 1 for links and 4k maps */ - .ai = attr, - .ns = 1, /* Hyp mode is in the non-secure world */ - .user = 1, /* See below */ - .ro = 0, /* Assume read-write */ - .af = 1, /* No need for access tracking */ - .ng = 1, /* Makes TLB flushes easier */ - .contig = 0, /* Assume non-contiguous */ - .xn = 1, /* No need to execute outside .text */ - .avail = 0, /* Reference count for domheap mapping */ - }};; - /* Setting the User bit is strange, but the ATS1H[RW] instructions - * don't seem to work otherwise, and since we never run on Xen - * pagetables in User mode it's OK. If this changes, remember - * to update the hard-coded values in head.S too */ - - switch ( attr ) - { - case BUFFERABLE: - /* - * ARM ARM: Overlaying the shareability attribute (DDI - * 0406C.b B3-1376 to 1377) - * - * A memory region with a resultant memory type attribute of Normal, - * and a resultant cacheability attribute of Inner Non-cacheable, - * Outer Non-cacheable, must have a resultant shareability attribute - * of Outer Shareable, otherwise shareability is UNPREDICTABLE. - * - * On ARMv8 sharability is ignored and explicitly treated as Outer - * Shareable for Normal Inner Non_cacheable, Outer Non-cacheable. - */ - e.pt.sh = LPAE_SH_OUTER; - break; - case UNCACHED: - case DEV_SHARED: - /* Shareability is ignored for non-Normal memory, Outer is as - * good as anything. - * - * On ARMv8 sharability is ignored and explicitly treated as Outer - * Shareable for any device memory type. - */ - e.pt.sh = LPAE_SH_OUTER; - break; - default: - e.pt.sh = LPAE_SH_INNER; /* Xen mappings are SMP coherent */ - break; - } - - ASSERT(!(pa & ~PAGE_MASK)); - ASSERT(!(pa & ~PADDR_MASK)); - - // XXX shifts - e.bits |= pa; - return e; -} - #if defined(CONFIG_ARM_32) # include #elif defined(CONFIG_ARM_64)