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 7334CCD6E56 for ; Mon, 1 Jun 2026 10:43:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: Content-Type:In-Reply-To:From:References:Cc:To:Subject:MIME-Version:Date: Message-ID:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=gfHfXoVYENkxwmj3NCbefgONe/D1FVurRR4OnxrKFd8=; b=KLYrhWT+uWvtyvD0n8aQwnNs3v 8svlPHDjSAY83d9FXYxxJqtOI0w2cHE1F7G2FpYmi3VDZRuUK61hCg4Kadmp5nfiiczrFd3TSjNEz d/Sus1Sluv6csFS9uwOmOBk2gnkMJ2Tgrii38EvSUKgT+Pm4IEdAWIr3OoZIazrLF8wm6cBSSTwRk e4NAy3WhC63rFL0XGdSnfGXwS9HiAjY8bMu0m/dwZcusqnafKqxgp8D6TAIMgnZ0/3whhpnz0QDgP iTHZhrku+PiPTNfEiQT3+dkjT4GzhxCdRQUYvWRloaD4vRa8uO8pLwuXtwyz7SH+YNr6fDxukyhB+ 8rIHbv3Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.99.1 #2 (Red Hat Linux)) id 1wU07B-0000000Ae5m-1XaH; Mon, 01 Jun 2026 10:43:25 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.99.1 #2 (Red Hat Linux)) id 1wU07A-0000000Ae5F-0Qtc for linux-arm-kernel@bombadil.infradead.org; Mon, 01 Jun 2026 10:43:24 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:Content-Type :In-Reply-To:From:References:Cc:To:Subject:MIME-Version:Date:Message-ID: Sender:Reply-To:Content-ID:Content-Description; bh=gfHfXoVYENkxwmj3NCbefgONe/D1FVurRR4OnxrKFd8=; b=SJ0WMrBbKrIDJ5jdgMirETHZKq FChoT81W7cwPfwcX1bFCDSk/K7eGpfZOB8OrdYtsxn6rnZfdxI9GbE6cb8m78TeUh/X1DSV/gZMnd 1dru6gMIu0UUgtylXfREt3E2H6EHpU7ZQx6POMrrk2yTk1RAk/cm5TwncUw+OTUGY9TVprBGkBpba WRs02TIhBztOfMQPVnXPw/IA2U4wvsqQpNWGcjV/M86VUatL3SEHJfC+P4edvlzjeTz9oce4FA3I8 0kumzspzobVJHydBM9ZZCdaTI3XAdc8oVkUmHCu/5SePAft1+9IO241UA5EeENxELDesbhUMiugs8 8RlTN4CA==; Received: from foss.arm.com ([217.140.110.172]) by desiato.infradead.org with esmtp (Exim 4.99.1 #2 (Red Hat Linux)) id 1wU076-00000006RML-2EtL for linux-arm-kernel@lists.infradead.org; Mon, 01 Jun 2026 10:43:22 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 8FA3F2696; Mon, 1 Jun 2026 03:43:14 -0700 (PDT) Received: from [10.57.94.8] (unknown [10.57.94.8]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id A5FEA3F905; Mon, 1 Jun 2026 03:43:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arm.com; s=foss; t=1780310599; bh=M9JAdG5DV/7YdqUDPO7phO8QpaY+0Cm/rOxjWCg5rg4=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=F8Byp1c2fESYbQpuqvr4AlWD6wXTjIviMOELOHMH97zUW2cYZrKpsdEn1LfcD6kXz UJIy+EgpBQi+xkE4miNGCmjzdHMfaUipsb7TkmxOblXjY1f60mslkBJ2kiKuhbuSA2 1yYR+XdZ5mwIByNNWcqVdJfgqcvs2DD6HSpBSnVM= Message-ID: Date: Mon, 1 Jun 2026 12:43:12 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v7 10/15] arm64: mm: Don't abuse memblock NOMAP to check for overlaps To: Ard Biesheuvel , linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org, will@kernel.org, catalin.marinas@arm.com, mark.rutland@arm.com, Ard Biesheuvel , Ryan Roberts , Anshuman Khandual , Liz Prucka , Seth Jenkins , Kees Cook , Mike Rapoport , David Hildenbrand , Andrew Morton , Jann Horn , linux-mm@kvack.org, linux-hardening@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-sh@vger.kernel.org References: <20260529150150.1670604-17-ardb+git@google.com> <20260529150150.1670604-27-ardb+git@google.com> From: Kevin Brodsky Content-Language: en-GB In-Reply-To: <20260529150150.1670604-27-ardb+git@google.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20260601_114321_149358_1EC7E69B X-CRM114-Status: GOOD ( 21.78 ) 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 On 29/05/2026 17:02, Ard Biesheuvel wrote: > From: Ard Biesheuvel > > Now that the linear region mapping routines respect existing table > mappings and contiguous block and page mappings, it is no longer needed > to fiddle with the memblock tables to set and clear the NOMAP attribute > in order to omit text and rodata when creating the linear map. > > Instead, map the kernel text and rodata alias first with the desired > initial attributes and granularity, so that the loop iterating over the > memblocks will not remap it in a manner that prevents it from being > remapped with updated attributes later. > > Signed-off-by: Ard Biesheuvel Reviewed-by: Kevin Brodsky > --- > arch/arm64/mm/mmu.c | 26 ++++++++------------ > 1 file changed, 10 insertions(+), 16 deletions(-) > > diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c > index 971996e46fd1..dcfca5667e5c 100644 > --- a/arch/arm64/mm/mmu.c > +++ b/arch/arm64/mm/mmu.c > @@ -1164,12 +1164,17 @@ static void __init map_mem(void) > flags |= NO_BLOCK_MAPPINGS | NO_CONT_MAPPINGS; > > /* > - * Take care not to create a writable alias for the > - * read-only text and rodata sections of the kernel image. > - * So temporarily mark them as NOMAP to skip mappings in > - * the following for-loop > + * Map the linear alias of the [_text, __init_begin) interval first > + * so that its write permissions can be removed later without the need > + * to split any block mappings created by the loop below. > + * > + * Write permissions are needed for alternatives patching, and will be > + * removed later by mark_linear_text_alias_ro() above. This makes the > + * contents of the region accessible to subsystems such as hibernate, > + * but protects it from inadvertent modification or execution. > */ > - memblock_mark_nomap(kernel_start, kernel_end - kernel_start); > + __map_memblock(kernel_start, kernel_end, pgprot_tagged(PAGE_KERNEL), > + flags); > > /* map all the memory banks */ > for_each_mem_range(i, &start, &end) { > @@ -1181,17 +1186,6 @@ static void __init map_mem(void) > __map_memblock(start, end, pgprot_tagged(PAGE_KERNEL), > flags); > } > - > - /* > - * Map the linear alias of the [_text, __init_begin) interval > - * as non-executable now, and remove the write permission in > - * mark_linear_text_alias_ro() below (which will be called after > - * alternative patching has completed). This makes the contents > - * of the region accessible to subsystems such as hibernate, > - * but protects it from inadvertent modification or execution. > - */ > - __map_memblock(kernel_start, kernel_end, PAGE_KERNEL, 0); > - memblock_clear_nomap(kernel_start, kernel_end - kernel_start); > } > > void mark_rodata_ro(void)