From patchwork Fri Jun 24 15:06:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 12894747 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 87A03C43334 for ; Fri, 24 Jun 2022 15:10:08 +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=9Mgb1GW2Pdp7VhpagXfffuXw55kj7ZcqEIY1yOU8uSY=; b=DEakeHdD7zqny1 rYitJ56oazMIAyBosf2+IcZdic0SffKDZVdaylGmYQb8hwx0w3gedf466jCQTIs3tVYdjlz3EwdBQ Fox4P1hjvPS8WivtIWEv3R29n1REKDBwoVbDiUvjlW1bhOTP5kM/irW3v+fxKjYrLsZUNDAh0TCQ9 XQQSrKPiMk9vkTNEH5U2gAn6syV0a7OnhcZbH5MwLyMcR+XCi7Dh/6Uzh9vBVwHYKqvVvtlakHtJh 07/Xui3REP6bro6GA768jrmXnfdg9GTrmzTkUdQP9X872fRDI8Z2GWRPc9+i3QXdpl/8hOFondu9U wqw6FjW9nDAJL/yfmbcw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1o4kve-002j9O-Md; Fri, 24 Jun 2022 15:09:03 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1o4kuA-002iPb-2U for linux-arm-kernel@lists.infradead.org; Fri, 24 Jun 2022 15:07:31 +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 939C6621CE; Fri, 24 Jun 2022 15:07:28 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 19F9AC341C0; Fri, 24 Jun 2022 15:07:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1656083248; bh=yCVJYYYykSt6KnWCMioWX1iDCDAGGrNVSzypc+CilpI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZhqYQq7z38DlJxBJEpIlaGbgRiXUk4XdPTYvr26vhRnkK3h56ayRHCQJrSe2+T9rG wz4CszyuVxJOBEGegDCkjzkwhu1a4khYzxJ1s95xq0ccQ2ZU4OALhgJ0UM7Eon15lB iwhNgSNcEEnUjkaE+MTntdekBgRLVOXVmjfvB1z0qd325rnlPVxdDW8GeCzvtZAoaA QCVEzRg1gd+jdKcVLpnb4uFd4RQJZrKYAi2vQ017fVE04M+UmqnLFS09J5ohIweAhf QtrsG4LafrD3OhhzINjPXfqfDR3RpB7V8ZduhNfEJeeF7NwyuMA609dFwWZic0+ewC YwUnEEST/ujFQ== From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org Cc: Ard Biesheuvel , Marc Zyngier , Will Deacon , Mark Rutland , Kees Cook , Catalin Marinas , Mark Brown , Anshuman Khandual Subject: [PATCH v5 08/21] arm64: kernel: drop unnecessary PoC cache clean+invalidate Date: Fri, 24 Jun 2022 17:06:38 +0200 Message-Id: <20220624150651.1358849-9-ardb@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220624150651.1358849-1-ardb@kernel.org> References: <20220624150651.1358849-1-ardb@kernel.org> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2148; h=from:subject; bh=yCVJYYYykSt6KnWCMioWX1iDCDAGGrNVSzypc+CilpI=; b=owEB7QES/pANAwAKAcNPIjmS2Y8kAcsmYgBitdL0HnTJXAduRed8vz+HQLHWvtUhbR0eJGPZ8t/F GSbvlKyJAbMEAAEKAB0WIQT72WJ8QGnJQhU3VynDTyI5ktmPJAUCYrXS9AAKCRDDTyI5ktmPJIHSC/ 92bEDJS4/W40OF5cPmA3LMkXC4Ru/+XVz1Q3PYtKA3MuVAHwIkhF7BqEcc41iF6bhywm055cNl43yQ H321Vq4/VyYAI55a1QSkJMMIEnpIb7+23h0hNha/GIt7DMs8fRat5yYRhGciBaEkep1+OVc4LJI+Sx xqhyOVHJXAe5Sp/DHQlDqzQgx3emho5zi28vMo/mbKH7ez4s/4QhxIEG2QziWoVzpKm8hVLVeCQuv9 pRPYC4rHSnLbIxRMjvfHF7z/yvVzTc5aAYEFd9ouSt826Ws7cSXmchy5Lc3NMOIYSZko29n18kLJPf yJRYMkeSWgWPpehqKxZfCIJsz8Uck39Apnasww8Jo1GMNwuvfb2nzl1w6CU4QyVtNvKuf+enzdhXc3 0eaElXPfJFEstKbCQyCeOARy8buslOZAXjLCJAztdrHi/hvitTq3z7x/4k5dMrRhhFu6vJe0UAiGK3 88J6coUTkYJOrVoZu8pXRAsCmLT3IGqS/mIPfR9EZIBco= 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-20220624_080730_227301_D9FC0218 X-CRM114-Status: GOOD ( 16.44 ) 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 Some early boot code runs before the virtual placement of the kernel is finalized, and we used to go back to the very start and recreate the ID map along with the page tables describing the virtual kernel mapping, and this involved setting some global variables with the caches off. In order to ensure that global state created by the KASLR code is not corrupted by the cache invalidation that occurs in that case, we needed to clean those global variables to the PoC explicitly. This is no longer needed now that the ID map is created only once (and the associated global variable updates are no longer repeated). So drop the cache maintenance that is no longer necessary. Signed-off-by: Ard Biesheuvel Reviewed-by: Anshuman Khandual --- arch/arm64/kernel/kaslr.c | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/arch/arm64/kernel/kaslr.c b/arch/arm64/kernel/kaslr.c index 418b2bba1521..d5542666182f 100644 --- a/arch/arm64/kernel/kaslr.c +++ b/arch/arm64/kernel/kaslr.c @@ -13,7 +13,6 @@ #include #include -#include #include #include #include @@ -72,9 +71,6 @@ u64 __init kaslr_early_init(void) * we end up running with module randomization disabled. */ module_alloc_base = (u64)_etext - MODULES_VSIZE; - dcache_clean_inval_poc((unsigned long)&module_alloc_base, - (unsigned long)&module_alloc_base + - sizeof(module_alloc_base)); /* * Try to map the FDT early. If this fails, we simply bail, @@ -174,13 +170,6 @@ u64 __init kaslr_early_init(void) module_alloc_base += (module_range * (seed & ((1 << 21) - 1))) >> 21; module_alloc_base &= PAGE_MASK; - dcache_clean_inval_poc((unsigned long)&module_alloc_base, - (unsigned long)&module_alloc_base + - sizeof(module_alloc_base)); - dcache_clean_inval_poc((unsigned long)&memstart_offset_seed, - (unsigned long)&memstart_offset_seed + - sizeof(memstart_offset_seed)); - return offset; }