From patchwork Mon Mar 17 15:31:09 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Campbell X-Patchwork-Id: 26387 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vc0-f198.google.com (mail-vc0-f198.google.com [209.85.220.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id C075A20143 for ; Mon, 17 Mar 2014 15:33:01 +0000 (UTC) Received: by mail-vc0-f198.google.com with SMTP id il7sf13746048vcb.1 for ; Mon, 17 Mar 2014 08:33:01 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id :mime-version:cc:subject:precedence:list-id:list-unsubscribe :list-post:list-help:list-subscribe:sender:errors-to :x-original-sender:x-original-authentication-results:mailing-list :list-archive:content-type:content-transfer-encoding; bh=EFNMFcUkPcVFbZDm9RKRUmnW7rnQ21R4R92e9U1WxQI=; b=FPBB4NLRY3tqfsyQMh3NwAIyVweLZ0zRCgK/+10MSz8sjbJl6ifawGDncz5OoMx7MI 4uET4Gzp/S4qlNbL3lv0tEIpioCYOJ1nEPUCvPV8SeqQMTVNKFdSbn1lDUOlrl6gOeNF xEaezn8ygqS0tGOev4+pLKGu1B/EfaTtrRHpoh+lGXJjxDcL02yAOeU7C8YWsNrVTppw 5qulW9Q5vIQVgGmJts4d8yHaxQpKeTSGnlpp/WGAfsx4hOmUClpZWl2+rsO/1VU/CuUb pZzSuOn3/UT4sWjZzLFSqcLVCLuL51o2/wsLcNg63F9TaIFwJpz9FxELsMTZukPgRV96 /Gvw== X-Gm-Message-State: ALoCoQlvjZWDur+G9/W72jmdVZ0GkMnh2axMNI8PsHT8kKi5aEXLDXZi7HO2E/D0VyQ7UvStsMvg X-Received: by 10.236.45.41 with SMTP id o29mr2746885yhb.13.1395070381437; Mon, 17 Mar 2014 08:33:01 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.49.166 with SMTP id q35ls1720883qga.89.gmail; Mon, 17 Mar 2014 08:33:01 -0700 (PDT) X-Received: by 10.220.103.141 with SMTP id k13mr2310339vco.25.1395070381313; Mon, 17 Mar 2014 08:33:01 -0700 (PDT) Received: from mail-vc0-f177.google.com (mail-vc0-f177.google.com [209.85.220.177]) by mx.google.com with ESMTPS id sn5si1832705vdc.155.2014.03.17.08.33.01 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 17 Mar 2014 08:33:01 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.177 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.177; Received: by mail-vc0-f177.google.com with SMTP id if17so5813194vcb.8 for ; Mon, 17 Mar 2014 08:33:01 -0700 (PDT) X-Received: by 10.52.247.231 with SMTP id yh7mr972470vdc.34.1395070381185; Mon, 17 Mar 2014 08:33:01 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.220.78.9 with SMTP id i9csp135691vck; Mon, 17 Mar 2014 08:33:00 -0700 (PDT) X-Received: by 10.52.164.175 with SMTP id yr15mr66181vdb.59.1395070380749; Mon, 17 Mar 2014 08:33:00 -0700 (PDT) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id b4si5376932vck.7.2014.03.17.08.33.00 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 17 Mar 2014 08:33:00 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of xen-devel-bounces@lists.xen.org designates 50.57.142.19 as permitted sender) client-ip=50.57.142.19; Received: from localhost ([127.0.0.1] helo=lists.xen.org) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1WPZVT-00079i-G8; Mon, 17 Mar 2014 15:31:15 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1WPZVR-00079Y-U8 for xen-devel@lists.xen.org; Mon, 17 Mar 2014 15:31:14 +0000 Received: from [85.158.139.211:24822] by server-9.bemta-5.messagelabs.com id AA/69-04350-14517235; Mon, 17 Mar 2014 15:31:13 +0000 X-Env-Sender: Ian.Campbell@citrix.com X-Msg-Ref: server-5.tower-206.messagelabs.com!1395070270!1550057!1 X-Originating-IP: [66.165.176.63] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni42MyA9PiAzMDYwNDg=\n X-StarScan-Received: X-StarScan-Version: 6.11.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 10802 invoked from network); 17 Mar 2014 15:31:12 -0000 Received: from smtp02.citrix.com (HELO SMTP02.CITRIX.COM) (66.165.176.63) by server-5.tower-206.messagelabs.com with RC4-SHA encrypted SMTP; 17 Mar 2014 15:31:12 -0000 X-IronPort-AV: E=Sophos;i="4.97,670,1389744000"; d="scan'208";a="110747832" Received: from accessns.citrite.net (HELO FTLPEX01CL03.citrite.net) ([10.9.154.239]) by FTLPIPO02.CITRIX.COM with ESMTP; 17 Mar 2014 15:31:10 +0000 Received: from norwich.cam.xci-test.com (10.80.248.129) by smtprelay.citrix.com (10.13.107.80) with Microsoft SMTP Server id 14.2.342.4; Mon, 17 Mar 2014 11:31:09 -0400 Received: from drall.uk.xensource.com ([10.80.16.71] helo=drall.uk.xensource.com.) by norwich.cam.xci-test.com with esmtp (Exim 4.72) (envelope-from ) id 1WPZVN-0001EQ-DE; Mon, 17 Mar 2014 15:31:09 +0000 From: Ian Campbell To: Date: Mon, 17 Mar 2014 15:31:09 +0000 Message-ID: <1395070269-32356-1-git-send-email-ian.campbell@citrix.com> X-Mailer: git-send-email 1.7.10.4 MIME-Version: 1.0 X-DLP: MIA1 Cc: julien.grall@linaro.org, tim@xen.org, Ian Campbell , Fu Wei , stefano.stabellini@eu.citrix.com Subject: [Xen-devel] [PATCH] xen: arm: setup sane EL1 state while building domain 0. X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Post: , List-Help: , List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: ian.campbell@citrix.com X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.177 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Archive: 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) )