From patchwork Tue Nov 8 18:22:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 13036687 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 BAEA0C4332F for ; Tue, 8 Nov 2022 18:24:28 +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=3f9VzSLkCHDJPAB1JqB9aDIcdpb4qVLDRWkVwlyEEBk=; b=yc1erFyxROS4mx dDJfrefUuqW3BLP/AOGDOn0fhab6KMhaeHe/8cCzcWXeUufb9lwcXsKjJEX5B7+tvk8RfLBPHyqqx zS7NdFyoqKSIX4kupB5gKEbrevw3a9jienyOCd6hF2f1MZzsnJGBjXy/AxdE8fBkiWBmfb50lhyAk VueWagKHlcNVOFwsI2c8Oc9UvNqLeaW6JW3cEZH8uBCxzGpWl9r4lZpHctM+RTVoA4ZmHdJP9AEQ5 F4P+xE9vL791Sy4xvBluooVjl9wTfstxM4Vw4gJR4E/3SQUDvW+mFcuNjmJrLkWlE+pgDmJMgljuB gDArP8V4C44NYWhgc3vQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1osTFd-007Rkp-31; Tue, 08 Nov 2022 18:23:09 +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 1osTF3-007RaX-6u for linux-arm-kernel@lists.infradead.org; Tue, 08 Nov 2022 18:22:34 +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 BA8946171B; Tue, 8 Nov 2022 18:22:32 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 71D6FC43470; Tue, 8 Nov 2022 18:22:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1667931752; bh=L5q3Hzdh1HbKLn9PVJqkB2WytTwlIIHjujoTsQXL1Uw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WMa//HNmViFf3Zk/Dn72obg8yCz47D75F8c5Y+x9+dJxAjGJx5V23Lwy0D/BnMbu6 +R4y8PFqrEkv38RWevx9nLo4oMdSVwRG246tsweDDWX6ONOtTbmUeQrHqQ+CZwSnW3 HhKkMSS7dd7RwXpwOygUTz9dS18xZCZGfhiEHpCQQXnflhiIcTaYXnBq4VWjgi4hqd 6aYGM5JN4r2KHVjasAXnFQOMo3VhuDquBH7g9vcv9soZn6rxrsTGU6CnqC16fbJNHQ e7FadPuT7Si97/cM9qxkfCFx9kFxikb9iFbtzGJu5Y3jefS572BzgAFT9RViY0ClWV UPKB3LlF/pSSg== From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org Cc: linux-efi@vger.kernel.org, keescook@chromium.org, Ard Biesheuvel , Will Deacon , Catalin Marinas , Marc Zyngier , Mark Rutland Subject: [PATCH v5 4/7] arm64: head: avoid cache invalidation when entering with the MMU on Date: Tue, 8 Nov 2022 19:22:01 +0100 Message-Id: <20221108182204.2447664-5-ardb@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221108182204.2447664-1-ardb@kernel.org> References: <20221108182204.2447664-1-ardb@kernel.org> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1358; i=ardb@kernel.org; h=from:subject; bh=L5q3Hzdh1HbKLn9PVJqkB2WytTwlIIHjujoTsQXL1Uw=; b=owEB7QES/pANAwAKAcNPIjmS2Y8kAcsmYgBjap5Gwd1LA9GuF/9QsQ0L389fKmqeZ3BEvPyQcdV2 9eokvUGJAbMEAAEKAB0WIQT72WJ8QGnJQhU3VynDTyI5ktmPJAUCY2qeRgAKCRDDTyI5ktmPJGxbDA DEIc4rgcoZghfL2wuCC40W+38B0i4SCAPXX3J+fCB9/w1Q8uBZDRoZAxhAaO5NmLYVLIgZZpU06Zv+ rRi6wqY+DlCGsLIvWXT9QNwYvgp67gpjj4QJa8mTrqEVdkWFlPv5cZI85FEqU0GDXHqslZ9Pxke2VP AivCF9OngqI4+tCdi0pxngDw+XBPgqCt2yMD8AMEbpPPRGXpJiHUho1CzdYOvKESOjqSQDsD/zJp0F C+NUN4TRZ1fBuLcuyHZVzCD9Gy4GGm6ltFhuZT79sygqF+wWCDcfQNYiuZvMgXE48kE74vl8+lO5tk 7BOI/80cIhSHe0yH+lhdCPXnBziODR0HBuZQsAJ18FQyWmwprdByBGjCcWtatzjfKue0YUMOj+rK4P lfDcyousyRTnUTbB6+gH1pf1CiIThTAxcZuMdBD0O4WAwQaZyvWD5xww86USyrupzFP95MQCCqLyjM Qoy2lUp/JNG1S9C2m6jukPmflj8i8AnHSpVVKamdmcwVo= 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-20221108_102233_323684_3928F99D X-CRM114-Status: GOOD ( 13.77 ) 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 we enter with the MMU on, there is no need for explicit cache invalidation for stores to memory, as they will be coherent with the caches. Let's take advantage of this, and create the ID map with the MMU still enabled if that is how we entered, and avoid any cache invalidation calls in that case. Signed-off-by: Ard Biesheuvel --- arch/arm64/kernel/head.S | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/arch/arm64/kernel/head.S b/arch/arm64/kernel/head.S index 3e654e43fa115947..a7c84cde67c5c652 100644 --- a/arch/arm64/kernel/head.S +++ b/arch/arm64/kernel/head.S @@ -89,9 +89,9 @@ SYM_CODE_START(primary_entry) bl record_mmu_state bl preserve_boot_args + bl create_idmap bl init_kernel_el // w0=cpu_boot_mode mov x20, x0 - bl create_idmap /* * The following calls CPU setup code, see arch/arm64/mm/proc.S for @@ -378,12 +378,13 @@ SYM_FUNC_START_LOCAL(create_idmap) * accesses (MMU disabled), invalidate those tables again to * remove any speculatively loaded cache lines. */ + cbnz x19, 0f // skip cache invalidation if MMU is on dmb sy adrp x0, init_idmap_pg_dir adrp x1, init_idmap_pg_end bl dcache_inval_poc - ret x28 +0: ret x28 SYM_FUNC_END(create_idmap) SYM_FUNC_START_LOCAL(create_kernel_mapping)