From patchwork Mon Apr 11 09:48:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 12808930 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 96BBAC433EF for ; Mon, 11 Apr 2022 10:18:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Z6siZcUGxKUo2xhrdqsedp6zm0DYyNRIfTYs1scDYU4=; b=NyQa+r+/B3Gfv0 AhyUifpjqDL5TP2mh5c/BrKDhnGQuEed759APflb2DczfhaFDIO0GFPlwM6BRukk74b08cIQu71dc mhbHbhxwhmV9LHI1lOd31bnClzwBPLW57QyT+L7ZUXt2nLsSqcVtfZDV7GuQWZFWNRa+yUf5jlqvC jK2MTC6j1Tq075oIxNQCqbV3RCYvXjnAf84+eulmLr5tZDiTq745GAE13fWrDSZtUoXno13xCgmpV RUl8DWCAWL/EilB2aXj08qYLGyAxnbigQnZzpqFMHLA8EUzuX7crfau1hKX/Xm30deid6kl2c+Xl1 ZFGGR2lbI1MOK0Y3IIGg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ndr6t-008FLt-Ga; Mon, 11 Apr 2022 10:17:27 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ndqgF-0082jc-Ne for linux-arm-kernel@lists.infradead.org; Mon, 11 Apr 2022 09:49:57 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 3F38461164; Mon, 11 Apr 2022 09:49:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B614CC385A3; Mon, 11 Apr 2022 09:49:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1649670594; bh=1qxefU9ioI70as0lbJZH1S8z3I47C60UFcTZFTnl2os=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=n+rblAVRH4wDlEtdFm7egzo+8XH9XkP+N9ksYrhYr0XqMyHVhUPUVjemwfV6fqmy5 PRjAqC8+Kf5qwGUoAzG0JEX+IKVS81z2av8dnUyThc+yEAO+VsLKwNi0ngvJEOXgod 5KiLFlaE1/+Bg+10ZFQzcH0F02hbn1b1PEAl2GKPeD6P1TLPC9+iLNxGOOggy57RXj 3e3enBZ2z2N5mqNc6VE82oNGG8OClP+llsmNzKP/ZZQC0tTV4OrTj6yPRSrT6pUiy6 j4VgCWxiq9d7QOHJH3xrtDPpfSMxeweobEWAHwzO+CiYUJNANm99/b0Hh8zivnjk/q w7MFxb/dXiLfg== From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org Cc: linux-efi@vger.kernel.org, Ard Biesheuvel , Marc Zyngier , Will Deacon , Mark Rutland , Kees Cook , Catalin Marinas , Mark Brown Subject: [PATCH v3 30/30] arm64: efi/libstub: enter with the MMU on if executing in place Date: Mon, 11 Apr 2022 11:48:24 +0200 Message-Id: <20220411094824.4176877-31-ardb@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220411094824.4176877-1-ardb@kernel.org> References: <20220411094824.4176877-1-ardb@kernel.org> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=986; h=from:subject; bh=1qxefU9ioI70as0lbJZH1S8z3I47C60UFcTZFTnl2os=; b=owEB7QES/pANAwAKAcNPIjmS2Y8kAcsmYgBiU/lnFUYaEzHCp/GnbA810DD+iTSzsBU687E/JIft 4fc53xCJAbMEAAEKAB0WIQT72WJ8QGnJQhU3VynDTyI5ktmPJAUCYlP5ZwAKCRDDTyI5ktmPJHQcC/ 92qP+noLshpJmyk5f21siOVQ14gjQqcxRXRd3mQAmsSR5m586LNL+dJdre3/Y/k6UQ/6VK1kvODh6Y VyLa73v4SF6I/dInO+KGJt5sOexXtTBr2XeKK4TydG2faSK0ZjEzdbZcJK0gJ5fDHMn1+bp2ymhl1t xG94oC8bEQmGp+MeX7Op9gOOqSTeo6TyXwsKkp4z0jApClWEqXGgb7ntv0uKaoXwEbE23j9V9TKDAf bTWCij7AVbE/l9wPG59Jlo12EAWvYDTtGSwFweMhxuDbcGge/P3XlCkzwjrMSDrMALOZmjA2jYReBM 23WUxyDmwW7tkMgVm9HmkVQwl4cXWu0fM8RMFr0FKvD+22+MQ9/Sz5la1UiMSQmAPifylVVwbEII52 NEEFf8RPBMh5B2Sa4+ZPLAZYMlmOeaQHBYYwwXLEK7xDFLXovNU1Mwa7/Rw0ZQiJ3O70U1faR5JDl3 SID408Az8bMDf9dvjBJXLa8Y63E8G51uv65SahI9z324k= X-Developer-Key: i=ardb@kernel.org; a=openpgp; fpr=F43D03328115A198C90016883D200E9CA6329909 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220411_024955_882347_17C8B62E X-CRM114-Status: GOOD ( 13.45 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org If the kernel image has not been moved from the place where it was loaded by the firmware, just call the kernel entrypoint directly, and keep the MMU and caches enabled. This removes the need for any cache invalidation in the entry path. Signed-off-by: Ard Biesheuvel --- arch/arm64/kernel/efi-entry.S | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/arch/arm64/kernel/efi-entry.S b/arch/arm64/kernel/efi-entry.S index 61a87fa1c305..0da0b373cf32 100644 --- a/arch/arm64/kernel/efi-entry.S +++ b/arch/arm64/kernel/efi-entry.S @@ -23,6 +23,10 @@ SYM_CODE_START(efi_enter_kernel) add x19, x0, x2 // relocated Image entrypoint mov x20, x1 // DTB address + adrp x3, _text // just call the entrypoint + cmp x0, x3 // directly if the image was + b.eq 2f // not moved around in memory + /* * Clean the copied Image to the PoC, and ensure it is not shadowed by * stale icache entries from before relocation.