From patchwork Fri Mar 29 18:24:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 10877667 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7C6891708 for ; Fri, 29 Mar 2019 18:24:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6950F2874C for ; Fri, 29 Mar 2019 18:24:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 598E028ABE; Fri, 29 Mar 2019 18:24:53 +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=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.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 4E7F62874C for ; Fri, 29 Mar 2019 18:24:51 +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:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version: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:In-Reply-To:References: List-Owner; bh=xqdKtVC8DrHL5Ixw/qDIUZ4mFhNaoWF6uCq+as2zp4I=; b=ZzyZVZKDRJvmBo unqxOLeaNAJegRBh2h2RXGQ721P0Ujsak9OIfSusXGqpv7R8vp+Nt2MwNSHddCCS5cKZtXI79Dwqy s9K50pppfvZH3rVTbefJkGCY4jSt2/leAjXa0POB6ugoyP4NNcW54Mzz6OG/XDAfKBiF3P62e6Rg0 jFs0JIJbalQfH3aMKwNfC7Q0G1+7/QHsKibLb1+r/zvJ6xWFuPPDh20zDZVV4hIjxl7XQaB76eKIC mvuw/0ulNMgPI0hR8UrRir9MRdP8927i8fF+g/qar9PzCsKdFT/eaLQchhkXZ33SKzD0+ocUP8+pI cCvK7K9RIt3+Mq6/xxiQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1h9wBI-0005jM-5b; Fri, 29 Mar 2019 18:24:44 +0000 Received: from mail-wm1-x342.google.com ([2a00:1450:4864:20::342]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1h9wBF-0005j0-CR for linux-arm-kernel@lists.infradead.org; Fri, 29 Mar 2019 18:24:42 +0000 Received: by mail-wm1-x342.google.com with SMTP id n25so3898412wmk.4 for ; Fri, 29 Mar 2019 11:24:39 -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:mime-version :content-transfer-encoding; bh=B7wKfX9UE6y/2Y25AWVXGi17K9UuegsvGqjc2LG7tOc=; b=fyTjh5EQlCwEskJAEljwkSzaN9Sk0o4knps2HmjRh66W+AgO6mVtKgdwmR2uXf4aTk usWyZeF2tvgWtAP6xcgb+73bqN5PGrbEjfyPGH5cuGHPZMoghPibtTUFEZUsSVEK+uFK J8+LDgdVdAB40GGab+2oYnnnj2IxFraMKwEAATYg7WJ7nlBy7hBWNzAK2oJar54heQu6 N6BKLTB6yC0a3tVlDf11ZhqAx9m2OOGqHM3w8axPMHx89LuXi5CbnmAbqD9nKts6Ivp+ pNRU6JRQQxEXXurbHLHofObl/a6exM5acRq7dN9T34qshPRwXEkUupHOUgdbM8d7Ni0v 2xtg== 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:mime-version :content-transfer-encoding; bh=B7wKfX9UE6y/2Y25AWVXGi17K9UuegsvGqjc2LG7tOc=; b=ZWitfKjCn7OAVvEAiKB093TDEtBq1hK53PLgebEshYGtja8r3nvDvMEBjVirVbJZii EBJxRIA/OwBL7i+TVjro/OXwB6xJIMlXLoIk+EvLlihAqBkCX3lFrVMhJa/S07C2+Acd b3TSC4fX9Ppzp2mvZ6cr8NVboGGzfLK0OqiWp09R+rzXHWgSYSHzzR3/2ulkSz6jA2L1 6qCv0ST/TIbg2tYmpbC8r5+I46N4grz5LB8UTkSrNskGbj5axtpq80BElZmFp/MlrBjP FCadtugHp3TwlwwIXxMMMMRPzaBjM8xevEaoRJ5d7ecvfjg5yLLxTz/FivpSvUYlWKCn OnYA== X-Gm-Message-State: APjAAAW0i3ABzwku+EzL5NJrqLa90506mL7xMMZ2NTT1P4KO7zAGiRnN FnPhpOLVW9ZcI+/qyMuE5BgjJVgaDNzbKg== X-Google-Smtp-Source: APXvYqzQoNDuSBVnaArzQiR9DPc2Nd5MkR+FFwD6B994jHhWL+EYAkgEgklqrRpvnqvBvQQzEV3MCA== X-Received: by 2002:a1c:1fcf:: with SMTP id f198mr4756391wmf.145.1553883877902; Fri, 29 Mar 2019 11:24:37 -0700 (PDT) Received: from localhost.localdomain (laubervilliers-657-1-83-120.w92-154.abo.wanadoo.fr. [92.154.90.120]) by smtp.gmail.com with ESMTPSA id x5sm4313848wmi.37.2019.03.29.11.24.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 29 Mar 2019 11:24:36 -0700 (PDT) From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org Subject: [PATCH] efi/arm: enable CP15 DMB instructions before cleaning the cache Date: Fri, 29 Mar 2019 19:24:18 +0100 Message-Id: <20190329182418.29592-1-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190329_112441_459353_7556AE78 X-CRM114-Status: GOOD ( 10.99 ) 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: linux-efi@vger.kernel.org, Ard Biesheuvel , Marc Zyngier , linux@armlinux.org.uk, leif.lindholm@linaro.org, steve.mcintyre@linaro.org 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 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. Cc: Marc Zyngier Signed-off-by: Ard Biesheuvel Acked-by: Marc Zyngier --- arch/arm/boot/compressed/head.S | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/arch/arm/boot/compressed/head.S b/arch/arm/boot/compressed/head.S index 6c7ccb428c07..62a49356fca3 100644 --- a/arch/arm/boot/compressed/head.S +++ b/arch/arm/boot/compressed/head.S @@ -1438,6 +1438,16 @@ ENTRY(efi_stub_entry) @ Preserve return value of efi_entry() in r4 mov r4, r0 + + @ our cache maintenance code relies on CP15 barrier instructions + @ but since we arrived here with the MMU and caches configured + @ by UEFI, we must ensure that the use of those instructions is + @ enabled in the SCTLR register, since we never executed our own + @ cache enable routine, which is normally in charge of this. + mrc p15, 0, r1, c1, c0, 0 @ read SCTLR + orr r1, r1, #(1 << 5) @ CP15 barrier instructions + mcr p15, 0, r1, c1, c0, 0 @ write SCTLR + bl cache_clean_flush bl cache_off