From patchwork Tue Apr 30 11:38:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 163102 Delivered-To: patch@linaro.org Received: by 2002:a92:7e86:0:0:0:0:0 with SMTP id q6csp3116319ill; Tue, 30 Apr 2019 04:47:25 -0700 (PDT) X-Google-Smtp-Source: APXvYqwbBOijZY1fi/w1htx2e0FCQFhNfGVQiHA8EqHD8+i/GprFPEtvB8DRKOV0bodLgu5ZIE0g X-Received: by 2002:a62:4607:: with SMTP id t7mr328674pfa.138.1556624845450; Tue, 30 Apr 2019 04:47:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556624845; cv=none; d=google.com; s=arc-20160816; b=z0RuXNnlb4hJI6FICTrOVvHmu5WiJpz+30KxugcV/fitW1NjdVUb6ZkdgyPNSA+79u bjowsjUl3pZ480TQ7srQ9uvk6cfcmZv+qw5nP32kCbM9tH5F1/PuIP6Ea3jR1l0ulqcu Dn5Z+pIrD9ytg1FMdHzMbO0edPjKIC/vynS1Dtb3GIlvrbPBKTNjd1uE0zkTTXaoaXrZ tIdp/nWsByAichiXfg9wZ2+I4E691CZ4+5hyYvLPSx1qS3RvMJ6gCLRf2Y1wrMmRu8B+ PyTsu/w1nHlhat/T8fv1tMbrKS3gPPkTOfCKVev3zHEKRA7V3bFkWYPkiWVorFypGYSk 7psQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=fGHs00EkhNagkZbqqPaGLk+y058B+xNmWIMNAazau80=; b=wNkD+UJ54UeXYnAlK2IEvpuxIZOVNVJFJOADVKyI+eiAX8w6kVf/UohvNvJxOrOcA4 An6zA/Mh+9auL5GR4q0oxvBHGx1efJxSb+rVdXh0vqLbq3Btr0Q9Ggs2xXv4mupvkmKm ykJPbahMDEbJrQ4tvSZhIjkta80qwNsS6oFW38a2FAefMXr1By5kSxwfXjsr4YDf94jA NNMTy0mYj8aOQNkJydX7VyXOilC8Z9Mb3zeOXsKHC3AoLHRdocoRbE39jqT9UDaK9iPJ sgjAZ/IBCBvdfV+oPiJZj7bKP1+EcLtshNQYYBDCAx0iQUzIZ8KWtHAtUU+YdhEgZeWO ehmg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="UXA/CBYX"; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j187si38345770pfc.181.2019.04.30.04.47.25; Tue, 30 Apr 2019 04:47:25 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="UXA/CBYX"; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729088AbfD3LrX (ORCPT + 14 others); Tue, 30 Apr 2019 07:47:23 -0400 Received: from mail.kernel.org ([198.145.29.99]:60930 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728862AbfD3LrW (ORCPT ); Tue, 30 Apr 2019 07:47:22 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id EAA562054F; Tue, 30 Apr 2019 11:47:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1556624841; bh=oKlPAoQ9ZBkCJzVeAwx87mKWHmnicgEOjcEmv6Oj014=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UXA/CBYXWu+Hkp6OmedE0dStkoUQlSTcRO38JPyUi14NwhXeM0jSHpovIfpdBvaSS xq2caHEbTiGibhfm0mnLcsZMeuo3M8BOoGB4pFzHpfxFX2dxctI9vQnfIm2haoCOIK AhkS02qN0bZh8MNqyypZE8siw1kL5QgSV6JkYf9E= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Marc Zyngier , Ard Biesheuvel , Russell King Subject: [PATCH 4.19 045/100] ARM: 8857/1: efi: enable CP15 DMB instructions before cleaning the cache Date: Tue, 30 Apr 2019 13:38:14 +0200 Message-Id: <20190430113611.214119965@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190430113608.616903219@linuxfoundation.org> References: <20190430113608.616903219@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Ard Biesheuvel commit e17b1af96b2afc38e684aa2f1033387e2ed10029 upstream. The EFI stub is entered with the caches and MMU enabled by the firmware, and once the stub is ready to hand over to the decompressor, we clean and disable the caches. The cache clean routines use CP15 barrier instructions, which can be disabled via SCTLR. Normally, when using the provided cache handling routines to enable the caches and MMU, this bit is enabled as well. However, but since we entered the stub with the caches already enabled, this routine is not executed before we call the cache clean routines, resulting in undefined instruction exceptions if the firmware never enabled this bit. So set the bit explicitly in the EFI entry code, but do so in a way that guarantees that the resulting code can still run on v6 cores as well (which are guaranteed to have CP15 barriers enabled) Cc: # v4.9+ Acked-by: Marc Zyngier Signed-off-by: Ard Biesheuvel Signed-off-by: Russell King Signed-off-by: Greg Kroah-Hartman --- arch/arm/boot/compressed/head.S | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) --- a/arch/arm/boot/compressed/head.S +++ b/arch/arm/boot/compressed/head.S @@ -1395,7 +1395,21 @@ ENTRY(efi_stub_entry) @ Preserve return value of efi_entry() in r4 mov r4, r0 - bl cache_clean_flush + + @ our cache maintenance code relies on CP15 barrier instructions + @ but since we arrived here with the MMU and caches configured + @ by UEFI, we must check that the CP15BEN bit is set in SCTLR. + @ Note that this bit is RAO/WI on v6 and earlier, so the ISB in + @ the enable path will be executed on v7+ only. + mrc p15, 0, r1, c1, c0, 0 @ read SCTLR + tst r1, #(1 << 5) @ CP15BEN bit set? + bne 0f + orr r1, r1, #(1 << 5) @ CP15 barrier instructions + mcr p15, 0, r1, c1, c0, 0 @ write SCTLR + ARM( .inst 0xf57ff06f @ v7+ isb ) + THUMB( isb ) + +0: bl cache_clean_flush bl cache_off @ Set parameters for booting zImage according to boot protocol