From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.0 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8EE39C10F0E for ; Tue, 9 Apr 2019 16:42:28 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5FF892084C for ; Tue, 9 Apr 2019 16:42:28 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="p7db/xO7"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="oY1oyE6j" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5FF892084C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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: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=AdiUW0iuC5TWu3Hc20cam527DovapgfnSoYDtXQEUEc=; b=p7d b/xO77RqgWB8iiIyU+s8UeTBEX4/+Tphq0aPxOzzFyME6S0KUEyX82nOYHY7PjMCTm39wTjP5s8VZ 5OOBReOFTz6kWZJLuJPtCtbj+pZyxjf+SBXCmufhcYjdLJ9I1GPH/lFGTxyOMuVO9EkvLVCx9JDCO 1Cvn1CtOsldQ4vD1YuOfvHv174yKfMuGUzAe3LHtfCuforMel8Pe3LAQBFBLTJrD2Z1p3kxXFgC4h XnNpc2C7K0i+bL7AXvll3DfmlMGFl7QJcwAHPqwK7pApA1CW59bhHUF+nysuSoUmcoyPuLpH95L60 tMnn0XL+LJE4GZ+x3gpx6aJ9NRbtE2g==; 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 1hDtpL-0002Vb-LB; Tue, 09 Apr 2019 16:42:27 +0000 Received: from mail-pl1-x642.google.com ([2607:f8b0:4864:20::642]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hDtpJ-0002VH-DB for linux-arm-kernel@lists.infradead.org; Tue, 09 Apr 2019 16:42:26 +0000 Received: by mail-pl1-x642.google.com with SMTP id n8so5171733plp.10 for ; Tue, 09 Apr 2019 09:42:25 -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; bh=Lwv0DS81R3UDGsDpa6oEEiS09+Iy8UYSWPxuCX54ix4=; b=oY1oyE6jnRUWo5pShSwWr7HP2ZhWyMHmiyWwAujmXbYCDdLS+56Wmifj0wJ7X0isGD EvPajv/pIrjMS90xl3OiqJ7aB7aCzvgdS7M1aXDw62dS+CwaPaWuYv9W9VHmdUYl/Fam /SMONECHNcN65aj75YzaioGlgntom1ER8Ena7QjF12zwrn5gw8ZVVd0EstDH3zC6j9bm hTSXRzhlN12UGFPbRuaDvGkZbyBXiEjQaUEDaLad4B5etDAc0XDwqcT4hKBLNjy98Iq1 BySE6fOUNso9tKGTInHAtv76iEqTEIGwJnkEOi/imUIHurKkEQuzGzC/xZTPokM6KRL1 gFDg== 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; bh=Lwv0DS81R3UDGsDpa6oEEiS09+Iy8UYSWPxuCX54ix4=; b=Ux/iOBsCCpBPyIcAIx+bjK9j3QM2WN4G42C1sT6laU7TelotVt7rX0OwVUjqyKky1s lPzscHiiNcfnCMWSF8bTK2t7OUVBS20ZiD9HwTQv/T5O7eBWOLI0HmCIJm9vFZLTGW/J LATxSazV4WFfNbV5PCWw+NcEp2ycXPkPR24RJ5Q6yz7OPgtT8C+ETdJVkfR2JybQXSE2 oARZ9qhcXT0ok201GTKsPyVG4k7y44+CydnPpL5ddMZOFKtHuJnwMjC5xqXCuXLbu8At zLeIZk0ztHdCNHe6aQg3xiQ0R2vKqE2G0TYjTgQri6qDJ9O4FCWHKtLSr4Xyoou1K/bW f+Ug== X-Gm-Message-State: APjAAAW7bTxnEq1oRBtsfOXTAvlsobhnq2aJoQpBLpJN93mgcLI+rwbA iscqBT5EfUqt2CuJ7c6cc4ODy34T3hU1Frb1 X-Google-Smtp-Source: APXvYqzOAUmKIHRNH4pEZruDrENCmVtf/xZnd/2ih0N/6hHyAn7pMfG7JgI0AQiNDMUg1J3OrCduVg== X-Received: by 2002:a17:902:441:: with SMTP id 59mr8471761ple.242.1554828144068; Tue, 09 Apr 2019 09:42:24 -0700 (PDT) Received: from localhost.localdomain (50-205-23-12-static.hfc.comcastbusiness.net. [50.205.23.12]) by smtp.gmail.com with ESMTPSA id j16sm44455524pfi.58.2019.04.09.09.42.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 Apr 2019 09:42:22 -0700 (PDT) From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org Subject: [PATCH v2] efi/arm: enable CP15 DMB instructions before cleaning the cache Date: Tue, 9 Apr 2019 09:42:20 -0700 Message-Id: <20190409164220.5993-1-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.17.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190409_094225_446611_C258A7B5 X-CRM114-Status: GOOD ( 12.96 ) 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: marc.zyngier@arm.com, vladimir.murzin@arm.com, linux-efi@vger.kernel.org, linux@armlinux.org.uk, Ard Biesheuvel MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.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, 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) Acked-by: Marc Zyngier Signed-off-by: Ard Biesheuvel --- arch/arm/boot/compressed/head.S | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/arch/arm/boot/compressed/head.S b/arch/arm/boot/compressed/head.S index 6c7ccb428c07..c174098acdf1 100644 --- a/arch/arm/boot/compressed/head.S +++ b/arch/arm/boot/compressed/head.S @@ -1438,7 +1438,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 @ isb ) + THUMB( isb ) + +0: bl cache_clean_flush bl cache_off @ Set parameters for booting zImage according to boot protocol -- 2.17.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel