From patchwork Thu Jul 28 14:20:14 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 72960 Delivered-To: patch@linaro.org Received: by 10.140.29.52 with SMTP id a49csp880513qga; Thu, 28 Jul 2016 07:24:34 -0700 (PDT) X-Received: by 10.107.189.6 with SMTP id n6mr37277249iof.72.1469715873614; Thu, 28 Jul 2016 07:24:33 -0700 (PDT) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id v131si13331794itc.53.2016.07.28.07.24.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Jul 2016 07:24:33 -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 1bSmAz-0007Go-3u; Thu, 28 Jul 2016 14:20:41 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bSmAx-0007Eh-RE for xen-devel@lists.xen.org; Thu, 28 Jul 2016 14:20:39 +0000 Received: from [85.158.137.68] by server-5.bemta-3.messagelabs.com id 34/B6-03281-7B41A975; Thu, 28 Jul 2016 14:20:39 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrBLMWRWlGSWpSXmKPExsVysyfVTXebyKx wgwnPdC2WfFzM4sDocXT3b6YAxijWzLyk/IoE1ozvT06xF3wQrbg5fQVrA+MFwS5GLg4hgU2M EvtuzGKHcE4zSsxfdJCxi5GTg01AU+LO509MILaIgLTEtc+XGUGKmAXaGSXW9vcygySEBaIlH v+YBVbEIqAq0TK3B8zmFXCR2NY0A2yQhICcxMljk1lBbE6g+L2272C2kICzxOm729knMHIvYG RYxahRnFpUllqka2iql1SUmZ5RkpuYmaNraGCsl5taXJyYnpqTmFSsl5yfu4kR6GMGINjBuGa 75yFGSQ4mJVHesNCZ4UJ8SfkplRmJxRnxRaU5qcWHGGU4OJQkeN2EZ4ULCRalpqdWpGXmAIMN Ji3BwaMkwhsJkuYtLkjMLc5Mh0idYlSUEufNBUkIgCQySvPg2mABfolRVkqYlxHoECGegtSi3 MwSVPlXjOIcjErCvBtBpvBk5pXATX8FtJgJaHFx7AyQxSWJCCmpBsauDd/7zpTVXvoTPeuqut n/M7e2mE6t3PflSM1Ooy5mnpPhN2O1dn/gaVafv73F+SOzzawFqR67N10UvXY3R/DCt8SfR6b 6tW2ZN8ll6rmUl02eu/gKy4WEOgw3z15w5UB42sv6q3dvvLpwPjz+wJZ6TrWnJXwHy2771Rc3 m88WfOc9VVb6Yla7EktxRqKhFnNRcSIAbQZHWGsCAAA= X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-11.tower-31.messagelabs.com!1469715635!26646407!3 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 44641 invoked from network); 28 Jul 2016 14:20:38 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-11.tower-31.messagelabs.com with SMTP; 28 Jul 2016 14:20:38 -0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 6E968BB3; Thu, 28 Jul 2016 07:21:55 -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 3A8A33F21A; Thu, 28 Jul 2016 07:20:37 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Thu, 28 Jul 2016 15:20:14 +0100 Message-Id: <1469715620-4670-10-git-send-email-julien.grall@arm.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1469715620-4670-1-git-send-email-julien.grall@arm.com> References: <1469715620-4670-1-git-send-email-julien.grall@arm.com> Cc: proskurin@sec.in.tum.de, Julien Grall , sstabellini@kernel.org, steve.capper@arm.com, wei.chen@linaro.org Subject: [Xen-devel] [PATCH v2 09/15] 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 P2M code. So move the field from arch_domain to p2m_domain. This will also ease the implementation of altp2m. Signed-off-by: Julien Grall --- Changes in v2: - Forgot to add my signed-off-by - Fix typo in the commit message --- 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 512fd7d..7e524fe 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 */ } @@ -1297,8 +1301,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 2482a20..f509a00 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