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: 161476 Delivered-To: patch@linaro.org Received: by 2002:ac9:18c7:0:0:0:0:0 with SMTP id i7csp2252510oce; Fri, 29 Mar 2019 11:24:40 -0700 (PDT) X-Google-Smtp-Source: APXvYqyOSznP8gPDQrEquBhYYdmmChuX0PdNTCnPmrEzXvOjoor/UBTqOoiA70T/FH6U8AqL51p1 X-Received: by 2002:a65:430a:: with SMTP id j10mr30374885pgq.143.1553883880520; Fri, 29 Mar 2019 11:24:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553883880; cv=none; d=google.com; s=arc-20160816; b=aZ5NOd0ZRyKqMdgi+gEPLNK0AB4JHRCRxhT8KimfSconNAGBUcfgjDPsyL838dDNaL rFNc3ExAq1VuIm1SLTTMKQf3w6oIsdzoulk8EIuuv/ePu/LhIHsdeIG18I6I2Vem+N9C Dr7DfPUy1FwV4d9+dtHRCW9FOJUwIA+akR2DGUvVGGkvnplrs/xrf1UzRsMRou7oETx/ PRlobDvDtnLLF7s4faXYrkofbcZ+hTyCgOLWm7v7AAthFEigQfOpw/U+Q45oVVQiP0kB Wd+Us0EiwzSqQ0N77/Yti/UraXQw6+BwKix06cNLh9PlmzDtH4tnqG8ibYtYum5Xzh0J BLBA== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=B7wKfX9UE6y/2Y25AWVXGi17K9UuegsvGqjc2LG7tOc=; b=yuMLdC5qeWDgUkjjS8HhXMUAkOto7phjW4sLkQzhzibds/jB9cjRTNBLZH335lPNOh jOYB2HsmZpr3kEZkOC8mu0B1nqjj3RQC4MM2Ta7Gnz6/UhZ81svBmSPcj3lbsyl6qj3q iNdFapvpuqoH+8seWiyF7b8kPdwxUr3dAQ3MOKD9QcNrxTAYG4GIbnECRQa9CEwUzOds qE5wI34ZDwzyI7iDmr7WcfniM9Lv46xA3qGCgZZI0B6XF21SXQOWrfbFCDQWj0dnagZx oocsJDCQQd2tjVPzHw/aCkdLWc1RGeckAmpKI7WJcxvicAqYWimSFuQgBWGYYSQlmmuo 30fg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fyTjh5EQ; spf=pass (google.com: best guess record for domain of linux-efi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-efi-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t186si2360962pgd.221.2019.03.29.11.24.40; Fri, 29 Mar 2019 11:24:40 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-efi-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=@linaro.org header.s=google header.b=fyTjh5EQ; spf=pass (google.com: best guess record for domain of linux-efi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-efi-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729995AbfC2SYj (ORCPT + 3 others); Fri, 29 Mar 2019 14:24:39 -0400 Received: from mail-wm1-f68.google.com ([209.85.128.68]:38484 "EHLO mail-wm1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729956AbfC2SYj (ORCPT ); Fri, 29 Mar 2019 14:24:39 -0400 Received: by mail-wm1-f68.google.com with SMTP id w15so3897200wmc.3 for ; Fri, 29 Mar 2019 11:24:38 -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=pAdV+M4Xk9NFfxpjKDO9oRJ7luLM270CxbMxgoXKkPFSN0H6xZOKlIhfe2sOm62hHT Y+FSnnNa4e4WXcMM78VVKla97mGFaepXj0MnfOuViUbOfjDgLQtcgBOWX4y3SaAm+EAr HD1kVz+yHe1wDmKu398th6KmtFKUd5Sn1I7BlAPcLKoDvEPeJ19bPiPql4obVYOG06bz CYl8K+vOyibTdgFprrWT9ym9lxchOPXchoAcxVRvtWZaJdzfU9IEJ+sODlCv+s1dJ/tB J2Jhe4yCYSD++afPyUcI/0m7MwQYeQaGIiueNZhJWdqyKvABO3pdDmSwC8Xsa4X0jlE3 gLig== X-Gm-Message-State: APjAAAUqEt6iriNUXkNe87gS4y9xwRr1He4JU5d4/6pbYHfyJhChPQ0C crb2z+sHOQ1BRFyXO0ySMiF6Rw== 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 Cc: linux-efi@vger.kernel.org, linux@armlinux.org.uk, leif.lindholm@linaro.org, steve.mcintyre@linaro.org, Ard Biesheuvel , Marc Zyngier 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 Sender: linux-efi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-efi@vger.kernel.org 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 --- arch/arm/boot/compressed/head.S | 10 ++++++++++ 1 file changed, 10 insertions(+) -- 2.20.1 Acked-by: Marc Zyngier 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