From patchwork Wed Jan 11 10:22:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 13096379 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 99300C46467 for ; Wed, 11 Jan 2023 10:24:43 +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=Pn8cjNOyNo7pX6S7ulH+1/uvOY4rFp9sN1yQUXey8IA=; b=EK3Nba6G6Sh0dc xyYDSbbec8u6e6RUElDj7/nK1OPd/DlSqPQb1u3v9iQ1zGLQEHV/UJY4CT0HsJDkLTK62Ie/mxkks F6qSxvNxcxv2nqnKtasZ8RRs/0GXweVw7Ms4IkCJ5zC2AxDemYwfVPg4vB1SvXU6rXOLkdYPIqAhL vHl40CyCj3f+j2n8QZZEFW2IPb0ETbE6SLKlbmlJUQkUFqETPuE3lp7J6imGp+UaDqQhZ3YqaUUGn Bhcg7h5F+mmzVasl+D6ywlp0N+6/kPD5a04sSqPWkwOdnchlC0yapp8MKSJBFuYXevMM8xy2fA7X9 hpIXBiBf98GYJHrmW4lw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pFYGk-00Al5V-C7; Wed, 11 Jan 2023 10:23:42 +0000 Received: from sin.source.kernel.org ([145.40.73.55]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pFYGG-00Akwd-Ko for linux-arm-kernel@lists.infradead.org; Wed, 11 Jan 2023 10:23:14 +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 sin.source.kernel.org (Postfix) with ESMTPS id 97DD9CE1AA4; Wed, 11 Jan 2023 10:23:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 69DAFC433F0; Wed, 11 Jan 2023 10:23:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1673432588; bh=gHObniuOxNHTAroo4Q9eW2BQ31mqU1jn6IHWAhEPJO4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=X2T3GP0kdrUOejzZ6Rw9dKSmjs6oCA4K31twbR5eHEU6fTcIbYY1e73wnUs47IfH/ fOTAfVLhjDlRV3XO/3Nx6ffUCgrMO+kiByfTk0aYqh3Ndo20bnZfn08jBstrmLIKQj KFNQ19k1eUfjVMWJ+dQe1qI24fmxNVmFhmWZdnWn/VVatzneH1JlHbsN06iIPnrRWK LSYC8BceKkWxLj0paWpBTomNArJ64K1AWoVFVtKpGpxsAo55FwK7d0zPNy3Pt+VU1s 6YX1d5r8eAB8aei6DwrH/pxJcOSifsTt2hlfVTgl1WlXYdDjSrET3XO5ZvIXfCw+Wa kdIAmLzgkGOjg== From: Ard Biesheuvel To: linux-efi@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, Ard Biesheuvel , Will Deacon , Catalin Marinas , Marc Zyngier , Mark Rutland Subject: [PATCH v7 4/6] arm64: head: avoid cache invalidation when entering with the MMU on Date: Wed, 11 Jan 2023 11:22:34 +0100 Message-Id: <20230111102236.1430401-5-ardb@kernel.org> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230111102236.1430401-1-ardb@kernel.org> References: <20230111102236.1430401-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=gHObniuOxNHTAroo4Q9eW2BQ31mqU1jn6IHWAhEPJO4=; b=owEB7QES/pANAwAKAcNPIjmS2Y8kAcsmYgBjvo3oq/GwOjCdOMkP3gzv7fJ4nXBKTAGCeax1eg/T OafiT/OJAbMEAAEKAB0WIQT72WJ8QGnJQhU3VynDTyI5ktmPJAUCY76N6AAKCRDDTyI5ktmPJJT4DA DIhUCCSPUhAfdUmZLkKmUK4uxiTEC7gAAz+p49jCcl2rNkS6tBQLbwPOCAyt1oCPW+ccXyZZ/IrlWA DsjndoORpkrpPn7+16ZOU034eBEocejFANuzCuPiIZ3j7ZYiW9KrjylFaHXGYq+W+veYvLD0EaYeK2 5WOaZ18gqr5tq1Qd8sE0YXZiHuKhzXFM/QeWhPp8hyAj0MYwfYMy5pBQb5xJEgXsCG1mtqUYE40iVJ 1gKTPxen16zyidI/YEkrekj+hmgllEIHSzDDnM6laIliJaKrWqtDx9AXtxvtOf1Hg5QmQKu0GCdF/c qes/wjZggseoIu11f7PRucv04md0tiuAJirNsTsAgqYs+QlndFsW8rr9eYZ542mOF1TcT3V9n3Bqpn a4XRJembfXsB1xR83cS+qSte0LpovrO+XA3jM0jKpNlOAxuBnJfdgcLCJJVXpczOAc2GoP063gx5p0 dp+M4uLMzmDlmB0hoExAltsL+7mu6PN97kwJlfEZdMQmo= 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-20230111_022312_889288_D09AE9A4 X-CRM114-Status: GOOD ( 13.34 ) 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 c3b898efd3b5288d..d75f419206451d07 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 @@ -377,12 +377,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)