From patchwork Wed Jun 7 17:11:50 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 9772057 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 178E26034B for ; Wed, 7 Jun 2017 17:13:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BCC1426785 for ; Wed, 7 Jun 2017 17:13:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B11B2283B9; Wed, 7 Jun 2017 17:13:44 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 3AAAE26785 for ; Wed, 7 Jun 2017 17:13:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=+TdZDx/jy+ZhQBjv28Rotqxsy2V44AYUGDOQMg54w6w=; b=AIjfOQyowuz7msFT+BWOhuahw7 9uVCKzvQ3Lgd11YIcMXwf5cb6u9PL6q9NKd8Y9aY5o34znMCKWSxWcU1xglRKIbmxmM3LidFIdZl5 aSaOnK58KK+e76DlP/58YOwgZ9w1FOPmTyYYIEjftXwSiDDgMh9ZzCELS5PSBNpBCB8gEkVQDwP37 sHtF7kIbjzmp3OaVvb+9tJphrb4mIPe8OZLNFFqL+IXaMIPvOgV4iSBz0Cb3k/UIphYtFIBytpVc6 GNkI446W7kz2G6vhdE6GSkjIE+lvwUcc0c142qLxJMkGdQVXwA5pskt2fmqA+fFzHGFoTt7KZr1qv ADfexx7w==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dIeWd-00060x-4a; Wed, 07 Jun 2017 17:13:43 +0000 Received: from mail-wm0-x229.google.com ([2a00:1450:400c:c09::229]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dIeVU-0004pP-BF for linux-arm-kernel@lists.infradead.org; Wed, 07 Jun 2017 17:12:34 +0000 Received: by mail-wm0-x229.google.com with SMTP id x70so62270665wme.0 for ; Wed, 07 Jun 2017 10:12:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=kSJcxCq52VEJcAP+FSoEreKvX3VzBwSlYqjYM02+oAg=; b=HkjynrHZOljt+sR9rV9wiihu3pHiPeC3MNSoRicCuadL1Tnj6CgbqUAv86kY/wo7QN owcFUbZOSYQBoZg7f4Etgwirxf0DzNlMmUmDX2wmliytHXPdYHF8S0F16pUZr4gEQAzV +pln5YVx8VEiec49obsm93a9ybnvp9Xb6tO+g= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=kSJcxCq52VEJcAP+FSoEreKvX3VzBwSlYqjYM02+oAg=; b=U+M5xn/2XII2NzBMjxlVqjerzT529Im7V9JCIGQzptkxd1obQjLpjgmUe9TDC7RZH7 p/+ktdlf40J2YOk66WmiUvz1BhEPDXxCdVYbS4P6kWlXxcX3EVdsO3GSoXPVky29yeFf narMPzb1l+CaVUzmIJ9n19/THmMffWLWt3LeOh8zI1/DlaubUU8Vr3C+aU1Ep4c6bS+G PM5UXD6A87T+k7nvHjd44vA3ZV54Td2V9bD/CwBdBtxcL7ZsPT6txfv7sD28W1NELGuE logPdTId4skImlXEsZyTK5uFRLnRYm97rWGvqiWHBpRg3taRqGen7VRp+yZJWSatih8C MkZg== X-Gm-Message-State: AODbwcBz2rmHdMyLWyYEZB0nSGdaApzNAC59v2cRRAYqgTSbcnZgX6eT lPQf/6sLzac1wwcD X-Received: by 10.80.131.67 with SMTP id 61mr26039903edh.21.1496855530304; Wed, 07 Jun 2017 10:12:10 -0700 (PDT) Received: from localhost.localdomain (xd93ddc2d.cust.hiper.dk. [217.61.220.45]) by smtp.gmail.com with ESMTPSA id c2sm966244edc.34.2017.06.07.10.12.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 07 Jun 2017 10:12:09 -0700 (PDT) From: Christoffer Dall To: Paolo Bonzini , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= Subject: [PULL v2 4/6] arm64: KVM: Preserve RES1 bits in SCTLR_EL2 Date: Wed, 7 Jun 2017 19:11:50 +0200 Message-Id: <20170607171152.21874-5-cdall@linaro.org> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20170607171152.21874-1-cdall@linaro.org> References: <20170607171152.21874-1-cdall@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170607_101232_540669_1081552B X-CRM114-Status: GOOD ( 10.72 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Christoffer Dall , kvm@vger.kernel.org, Marc Zyngier , stable@vger.kernel.org, kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Marc Zyngier __do_hyp_init has the rather bad habit of ignoring RES1 bits and writing them back as zero. On a v8.0-8.2 CPU, this doesn't do anything bad, but may end-up being pretty nasty on future revisions of the architecture. Let's preserve those bits so that we don't have to fix this later on. Cc: stable@vger.kernel.org Signed-off-by: Marc Zyngier Signed-off-by: Christoffer Dall --- arch/arm64/include/asm/sysreg.h | 4 ++++ arch/arm64/kvm/hyp-init.S | 10 ++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/arch/arm64/include/asm/sysreg.h b/arch/arm64/include/asm/sysreg.h index 15c142c..b4d13d9 100644 --- a/arch/arm64/include/asm/sysreg.h +++ b/arch/arm64/include/asm/sysreg.h @@ -286,6 +286,10 @@ #define SCTLR_ELx_A (1 << 1) #define SCTLR_ELx_M 1 +#define SCTLR_EL2_RES1 ((1 << 4) | (1 << 5) | (1 << 11) | (1 << 16) | \ + (1 << 16) | (1 << 18) | (1 << 22) | (1 << 23) | \ + (1 << 28) | (1 << 29)) + #define SCTLR_ELx_FLAGS (SCTLR_ELx_M | SCTLR_ELx_A | SCTLR_ELx_C | \ SCTLR_ELx_SA | SCTLR_ELx_I) diff --git a/arch/arm64/kvm/hyp-init.S b/arch/arm64/kvm/hyp-init.S index 839425c..4072d40 100644 --- a/arch/arm64/kvm/hyp-init.S +++ b/arch/arm64/kvm/hyp-init.S @@ -106,10 +106,12 @@ __do_hyp_init: tlbi alle2 dsb sy - mrs x4, sctlr_el2 - and x4, x4, #SCTLR_ELx_EE // preserve endianness of EL2 - ldr x5, =SCTLR_ELx_FLAGS - orr x4, x4, x5 + /* + * Preserve all the RES1 bits while setting the default flags, + * as well as the EE bit on BE. + */ + ldr x4, =(SCTLR_EL2_RES1 | SCTLR_ELx_FLAGS) +CPU_BE( orr x4, x4, #SCTLR_ELx_EE) msr sctlr_el2, x4 isb