From: Ian Campbell Subject: [PATCH] xen: arm: setup sane EL1 state while building domain 0. Date: Mon, 17 Mar 2014 15:31:09 +0000 Message-ID: <1395070269-32356-1-git-send-email-ian.campbell@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel@lists.xen.org Cc: julien.grall@linaro.org, tim@xen.org, Ian Campbell , Fu Wei , stefano.stabellini@eu.citrix.com List-Id: xen-devel@lists.xenproject.org The address translation functions used while building dom0 rely on certain EL1 state being configured. In particular they are subject to the behaviour of SCTLR_EL1.M (stage 1 MMU enabled). The Xen (and Linux) boot protocol require that the kernel be entered with the MMU disabled but they don't say anything explicitly about exception levels other than the one which is active when entering the kernels. Arguably the protocol could be said to apply to all exception levels but in any case we should cope with this and setup the EL1 state as necessary. Fu Wei discovered this when booting Xen from grub.efi over UEFI, it's not clear whether grub or UEFI is responsible for leaving stage 1 MMU enabled. Reported-by: Fu Wei Signed-off-by: Ian Campbell Cc: Fu Wei --- Fu Wei, can I add your Tested-by here? --- xen/arch/arm/domain_build.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index 5ca2f15..ea47af5 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -1022,6 +1022,13 @@ int construct_dom0(struct domain *d) /* The following loads use the domain's p2m */ p2m_load_VTTBR(d); + /* Various EL2 operations, such as guest address translations used + * part of the domain build, rely on EL1 state (i.e. whether the + * guest has paging enabled). Since the bootloader may have left + * this state in an arbitrary configuration set it to something + * safe here. + */ + WRITE_SYSREG32(SCTLR_GUEST_INIT, SCTLR_EL1); #ifdef CONFIG_ARM_64 d->arch.type = kinfo.type; if ( is_pv32_domain(d) ) -- 1.7.10.4