From patchwork Wed Jul 20 16:10:58 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 72439 Delivered-To: patch@linaro.org Received: by 10.140.29.52 with SMTP id a49csp66364qga; Wed, 20 Jul 2016 09:14:01 -0700 (PDT) X-Received: by 10.107.56.70 with SMTP id f67mr15205940ioa.162.1469031240181; Wed, 20 Jul 2016 09:14:00 -0700 (PDT) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id 77si17928495itf.109.2016.07.20.09.14.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 20 Jul 2016 09:14:00 -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 1bPu67-0007oH-HG; Wed, 20 Jul 2016 16:11:47 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bPu66-0007lv-9a for xen-devel@lists.xen.org; Wed, 20 Jul 2016 16:11:46 +0000 Received: from [85.158.137.68] by server-17.bemta-3.messagelabs.com id 7F/A0-27186-1C2AF875; Wed, 20 Jul 2016 16:11:45 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrOLMWRWlGSWpSXmKPExsVysyfVTffAov5 wg1+r9S2WfFzM4sDocXT3b6YAxijWzLyk/IoE1oynD1YwF1wWqbh+8DBLA+M9gS5GLg4hgU2M Egf/trFBOKcZJZ7u3M7excjJwSagKXHn8ycmEFtEQFri2ufLjCBFzALtjBLLN/5jAUkIC0RIf F+4CKyIRUBVYt2EFlYQm1fAVaLnzxSwGgkBOYmTxyaDxTmB4udP/mQEsYUEXCQ2vf3GPIGRew EjwypG9eLUorLUIl1LvaSizPSMktzEzBxdQwNjvdzU4uLE9NScxKRiveT83E2MQA/XMzAw7mB 8/dPpEKMkB5OSKK+qaG+4EF9SfkplRmJxRnxRaU5q8SFGGQ4OJQnexQv7w4UEi1LTUyvSMnOA oQaTluDgURLh/QWS5i0uSMwtzkyHSJ1iVJQS590GkhAASWSU5sG1wcL7EqOslDAvIwMDgxBPQ WpRbmYJqvwrRnEORiVh3kCQKTyZeSVw018BLWYCWjxHAGxxSSJCSqqBUfiW9+rKl5XLZDNqNz y5kNU6wU3yi/HsTYHJrbPdEpefXcRS8FnvUEIn29Qo29neuzRvCCxQ2Fmi/SBTaOWK5JDzahV tT1iuJ8/oPFetICd613LL862xZrOV2xXXPRLydu/OPjJvrXmF6vTpPPFTbaWeaYmVLQt4513z 8cg6k99zbtzafE3kihJLcUaioRZzUXEiAIGdI95qAgAA X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-4.tower-31.messagelabs.com!1469031104!1374923!1 X-Originating-IP: [217.140.101.70] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 8.77; banners=-,-,- X-VirusChecked: Checked Received: (qmail 37714 invoked from network); 20 Jul 2016 16:11:44 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-4.tower-31.messagelabs.com with SMTP; 20 Jul 2016 16:11:44 -0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 92590BFC; Wed, 20 Jul 2016 09:12:54 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.218.32]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id E620D3F387; Wed, 20 Jul 2016 09:11:42 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Wed, 20 Jul 2016 17:10:58 +0100 Message-Id: <1469031064-23344-17-git-send-email-julien.grall@arm.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1469031064-23344-1-git-send-email-julien.grall@arm.com> References: <1469031064-23344-1-git-send-email-julien.grall@arm.com> Cc: proskurin@sec.in.tum.de, Julien Grall , sstabellini@kernel.org, wei.chen@linaro.org, steve.capper@arm.com Subject: [Xen-devel] [PATCH 16/22] xen/arm: p2m: Move the vttbr field from arch_domain to p2m_domain 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 field vttbr holds the base address of the translation table for guest. Its value will depends on how the p2m has been initialized and will only be used by the code code. So move the field from arch_domain to p2m_domain. This will also ease the implementation of altp2m. --- xen/arch/arm/p2m.c | 11 +++++++---- xen/arch/arm/traps.c | 2 +- xen/include/asm-arm/domain.h | 1 - xen/include/asm-arm/p2m.h | 3 +++ 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c index c407e6a..c52081a 100644 --- a/xen/arch/arm/p2m.c +++ b/xen/arch/arm/p2m.c @@ -107,10 +107,14 @@ void dump_p2m_lookup(struct domain *d, paddr_t addr) static void p2m_load_VTTBR(struct domain *d) { + struct p2m_domain *p2m = &d->arch.p2m; + if ( is_idle_domain(d) ) return; - BUG_ON(!d->arch.vttbr); - WRITE_SYSREG64(d->arch.vttbr, VTTBR_EL2); + + ASSERT(p2m->vttbr); + + WRITE_SYSREG64(p2m->vttbr, VTTBR_EL2); isb(); /* Ensure update is visible */ } @@ -1298,8 +1302,7 @@ static int p2m_alloc_table(struct domain *d) p2m->root = page; - d->arch.vttbr = page_to_maddr(p2m->root) - | ((uint64_t)p2m->vmid&0xff)<<48; + p2m->vttbr = page_to_maddr(p2m->root) | ((uint64_t)p2m->vmid & 0xff) << 48; /* * Make sure that all TLBs corresponding to the new VMID are flushed diff --git a/xen/arch/arm/traps.c b/xen/arch/arm/traps.c index 06a8ee5..65c6fb4 100644 --- a/xen/arch/arm/traps.c +++ b/xen/arch/arm/traps.c @@ -880,7 +880,7 @@ void vcpu_show_registers(const struct vcpu *v) ctxt.ifsr32_el2 = v->arch.ifsr; #endif - ctxt.vttbr_el2 = v->domain->arch.vttbr; + ctxt.vttbr_el2 = v->domain->arch.p2m.vttbr; _show_registers(&v->arch.cpu_info->guest_cpu_user_regs, &ctxt, 1, v); } diff --git a/xen/include/asm-arm/domain.h b/xen/include/asm-arm/domain.h index 4e9d8bf..9452fcd 100644 --- a/xen/include/asm-arm/domain.h +++ b/xen/include/asm-arm/domain.h @@ -48,7 +48,6 @@ struct arch_domain /* Virtual MMU */ struct p2m_domain p2m; - uint64_t vttbr; struct hvm_domain hvm_domain; gfn_t *grant_table_gfn; diff --git a/xen/include/asm-arm/p2m.h b/xen/include/asm-arm/p2m.h index ce28e8a..53c4d78 100644 --- a/xen/include/asm-arm/p2m.h +++ b/xen/include/asm-arm/p2m.h @@ -32,6 +32,9 @@ struct p2m_domain { /* Current VMID in use */ uint8_t vmid; + /* Current Translation Table Base Register for the p2m */ + uint64_t vttbr; + /* * Highest guest frame that's ever been mapped in the p2m * Only takes into account ram and foreign mapping