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 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 AE37BC433EF for ; Fri, 4 Mar 2022 18:00:55 +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=t+4K0GtcPOeIN77ClyqVku+zX3bnWz58bUcW9vbg9gY=; b=TYwRD+wLljM9pE 3R5HD/PMHvYleNoXCueqQ9Rkg8iz7gWvg9XlMrQhok9DwR6y7i9J8EW20/fIcF5lFZs61YVXvKkyW R7fe3Ky0upgayw2daziHvylV1qXQZn+/B1Eo7jswmKfMEXkl50Pbd2zL9SJ0MrnrFO6D6dTh1nI+s h0mHwGUlkQlvBXUNiHA0rti2YlYd/AxtOSsu9lZfntJZuzN+2eGWbjiYtouTYtnKU97C6bOypyHTy ugeEaTrHLnEulH6e31fYOK4/8+LwR9zV5BaiL6VWiVpr5la29ij/lIubgojs3+O8x+uEUhliVxLo7 izm97cXI36ry34uXamDw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nQCDF-00BTkn-5c; Fri, 04 Mar 2022 17:59:34 +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 1nQCBb-00BSuc-EU for linux-arm-kernel@lists.infradead.org; Fri, 04 Mar 2022 17:57:52 +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 C45F6CE2DB2; Fri, 4 Mar 2022 17:57:49 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 91FF1C36AE5; Fri, 4 Mar 2022 17:57:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1646416666; bh=K4/ubvR582x06JHFDx5s0SyNP3oA8NZVFPUk7uzjbkM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=N8GiZdo3j9iYbXWlv3GfWOf+p4v8JGS++j+i5kLf9hlCKe4kR1yOzWz0iL2ooHzME wnOu4FwJrG9xA+K2HKr/WMH8P47uXQBjbhVLf9QeBQUGJb5751HYRVyjCmKanvK1zc p55LQNEc0izyEtKj2nzNoE/ihzaZU2olmYAIG39EJKyOzPvmDaKNtMsHl6GP+ljFF7 5lXq7O5P71uFUiKvtD/fonKJKbymo3XzZDPq0cRwPWBXjAP6oqONvKbVtev+9J+hnB nHHml1njUmd1KSyLl1JbcX0jw9m1saoGtMHuhFBfcgIwUTHczDV9xcu0dtfRU04U94 BSFs7Nzo6U3wg== From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org Cc: mark.rutland@arm.com, android-kvm@google.com, Ard Biesheuvel , Marc Zyngier , Will Deacon Subject: [RFC PATCH 6/8] arm64: head: clean the ID map page to the PoC Date: Fri, 4 Mar 2022 18:56:55 +0100 Message-Id: <20220304175657.2744400-7-ardb@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220304175657.2744400-1-ardb@kernel.org> References: <20220304175657.2744400-1-ardb@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220304_095751_703291_3DC8215B X-CRM114-Status: GOOD ( 14.38 ) 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: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 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 and caches enabled, the caller may not have performed any cache maintenance. So clean the ID mapped page to the PoC, and invalidate the I-cache so we can safely execute from it after disabling the MMU and caches. Note that this means primary_entry() itself needs to be moved into the ID map as well, as we will return from init_kernel_el() with the MMU and caches off. Signed-off-by: Ard Biesheuvel --- arch/arm64/kernel/head.S | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/arch/arm64/kernel/head.S b/arch/arm64/kernel/head.S index 6041078df62a..ebc04d25f775 100644 --- a/arch/arm64/kernel/head.S +++ b/arch/arm64/kernel/head.S @@ -75,7 +75,7 @@ __EFI_PE_HEADER - __INIT + .section ".idmap.text","awx" /* * The following callee saved general purpose registers are used on the @@ -94,6 +94,19 @@ SYM_CODE_START(primary_entry) bl record_kaslr_offset bl preserve_boot_args bl __create_page_tables + + /* + * If we entered with the MMU and caches on, clean the ID mapped part + * of the primary boot code to the PoC and invalidate it from the + * I-cache so we can safely disable them. + */ + cbz x25, 0f + adrp x0, __idmap_text_start + adr_l x1, __idmap_text_end + sub x1, x1, x0 + bl dcache_clean_poc + ic ialluis +0: bl init_kernel_el // w0=cpu_boot_mode bl set_cpu_boot_mode_flag /* @@ -106,6 +119,7 @@ SYM_CODE_START(primary_entry) b __primary_switch SYM_CODE_END(primary_entry) + __INIT SYM_CODE_START_LOCAL(record_mmu_state) mrs x25, CurrentEL cmp x25, #CurrentEL_EL2 -- 2.30.2 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel