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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 68C66C761AF for ; Fri, 24 Mar 2023 15:23:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DA2186B0072; Fri, 24 Mar 2023 11:23:51 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D2B146B0074; Fri, 24 Mar 2023 11:23:51 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BCC2C6B007B; Fri, 24 Mar 2023 11:23:51 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id AD61B6B0072 for ; Fri, 24 Mar 2023 11:23:51 -0400 (EDT) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 81D901C6173 for ; Fri, 24 Mar 2023 15:23:51 +0000 (UTC) X-FDA: 80604161862.28.6BC5A14 Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [217.70.183.199]) by imf09.hostedemail.com (Postfix) with ESMTP id 41478140021 for ; Fri, 24 Mar 2023 15:23:48 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=none; spf=none (imf09.hostedemail.com: domain of alex@ghiti.fr has no SPF policy when checking 217.70.183.199) smtp.mailfrom=alex@ghiti.fr; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1679671429; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=UagDg680n7nc1vx7pvNNkFlK8h6/0MoetxhHv4ixiy8=; b=3E0msQJ4jIi/dE6QvCAa163XOdAePRM0p1SVEnJ5Hfqro5qt6ELY/OiApo5hz6sKEx9j/W AfQmTR48KBH/usx5TR2HP/Apgp3mbECBbKVXrl6jvIJcjf31ZTwSfeU7mBBLte3FBLYoqJ mf7N28pGUjoxEzwNaTF/ZYCF8fuPodU= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=none; spf=none (imf09.hostedemail.com: domain of alex@ghiti.fr has no SPF policy when checking 217.70.183.199) smtp.mailfrom=alex@ghiti.fr; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1679671429; a=rsa-sha256; cv=none; b=kxBf8PqYKH9pqLOoeU4eln1/h6Fv9z9vbbnBV359RNZTEVMh6KN1J2IOcEYDZ/J95TGkb6 JT5nFIO7HXNL9t5VpMGHjZKmAfbHnoj5PQtdm9heAl3IUjr+2CpPMU9Fz8wX5PFXZuga+X tGhd1F2zKzHJFf4PYU8sxZxNvkA4CYY= Received: (Authenticated sender: alex@ghiti.fr) by mail.gandi.net (Postfix) with ESMTPSA id A71C1FF814; Fri, 24 Mar 2023 15:23:42 +0000 (UTC) Message-ID: Date: Fri, 24 Mar 2023 16:23:42 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.8.0 Subject: Re: [PATCH v8 3/4] arm64: Make use of memblock_isolate_memory for the linear mapping Content-Language: en-US To: Will Deacon , Alexandre Ghiti Cc: Catalin Marinas , Paul Walmsley , Palmer Dabbelt , Albert Ou , Rob Herring , Frank Rowand , Mike Rapoport , Andrew Morton , Anup Patel , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, devicetree@vger.kernel.org, linux-mm@kvack.org References: <20230316131711.1284451-1-alexghiti@rivosinc.com> <20230316131711.1284451-4-alexghiti@rivosinc.com> <20230324152112.GD27199@willie-the-truck> From: Alexandre Ghiti In-Reply-To: <20230324152112.GD27199@willie-the-truck> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Rspam-User: X-Rspamd-Server: rspam03 X-Stat-Signature: i4b6fqw79uumknb61jboigwgj59wug37 X-Rspamd-Queue-Id: 41478140021 X-HE-Tag: 1679671428-34101 X-HE-Meta: U2FsdGVkX19flbcudIumL5/upMEuhtSC8tBMiWnSDplV8Ob7o9AkCW8gHXhJg1MAhv+wQaY5besTCt/+8sDfUT9vRFxTLfZnful+DFPLZX1WZX+UaA19XH0NbMUsL2vuwJNc+YyokiDsQOvVv2gjgKdeDOb1ytSpu+AfHHXn1L3/G+DFvJmT3ArDsNszB1cN0rXocjcMppLopV5mysLt7SCqwz6ycQjhVPqBaZ3fftteO0WmyMP6Lt1qeClBoNlJPOsqUQmQ9BfTD8Rr8YUzo7vxyV5sWOoiouSwUhgzFxXvylzrlPNbfG8JXF2/eVUpu+q+ACKnHhhPLcZgISSmyz0C7QULViQVzN1hinCyQwliA46FocHcxd7Yy1QeWWYEDgKkM8IckaJHa7sa3V+QjvfxIGfhcF19S1OoPbjgKWpvOmRAvBtIUNaLF/kWxcb/Q9puYSB68qEYgQmtfGBE/eEQHen+PuKtTiPfdbou00kHu9haJYFqw2WATzBBWHN2jfKjfolwOQp9z3HfU9wt86cgdoBOUpVoL6SEzfbcjpoURAaRfm6Z8YWTXREAj+zUwngrNYzmvP4E20waGHljFU8knTH2iaxViE/Pb+m1OpZmyO7aRdsAMI5IUydIK5gF9LyHwGLRKmIvB8dFY2hai9sfRsxRSig3NRvz74PjuUEONeh3xP5ZRKlbl7egMfE6c4n4kYCV5Ym1r80W1XkCvKbv2lVpaptd5ndMPBJMs6s6ORoiqlofF7AfwLfZo/RdzLFCifzxRWmUDHB26F/X1hUZ2ttQw06hqfj3DAUIPtqdyW+WzGHLicda5togcWGxkL0OchahOZq5rodzdBWwP4EnPh7AGVfc0B1IdGfiZ4n/ylJ9fK06shErR/YcLO6WO+Mis6RU/kKCgwzrf0rKKqsU/V9uX9Al/So+ybeOpNYHrSMHJ7MEqfNH27SLzzAaVUTb8Q+2MppleUht09l rOnL/JI/ YvDeezuFXgiy9zLECFsyzNyyJ6LyasYD7g+15YwvSE4uYQQLn55boDMJCPgl+vzRd6buXhj4FKR8+X4MC8kcuU7wPse1k5oL/gfdk5LiFAjhvL2HyeEcSzAJBmjlQReW1A0TXcgEuXamACjhRgbE19NP134pIu+/YfCXEf0aoH2T0XHT1KIrESh9ynTP/LY9Us9GiNwBG6rZlL7AqmRR7FEVZclDqEROFh2bGSNO2Odwr8RBLtpmfptxzpZEMEz4P/jazcu/LcjHjoWT6ajl3z6jabZu9BzNaNjsjobgAFiRq3MZc0KvzqMQfaw== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Hi Will, On 3/24/23 16:21, Will Deacon wrote: > On Thu, Mar 16, 2023 at 02:17:10PM +0100, Alexandre Ghiti wrote: >> In order to isolate the kernel text mapping and the crash kernel >> region, we used some sort of hack to isolate thoses ranges which consisted >> in marking them as not mappable with memblock_mark_nomap. >> >> Simply use the newly introduced memblock_isolate_memory function which does >> exactly the same but does not uselessly mark the region as not mappable. > But that's not what this patch does -- it's also adding special-case code > for kexec and, honestly, I'm struggling to see why this is improving > anything. > > Can we leave the code like it is, or is there something else going on? Yes, the next version won't touch arm64 at all since actually, I'll remove this new api. Thanks for your time, Alex > > Will > >> Signed-off-by: Alexandre Ghiti >> --- >> arch/arm64/mm/mmu.c | 25 ++++++++++++++++--------- >> 1 file changed, 16 insertions(+), 9 deletions(-) >> >> diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c >> index 6f9d8898a025..387c2a065a09 100644 >> --- a/arch/arm64/mm/mmu.c >> +++ b/arch/arm64/mm/mmu.c >> @@ -548,19 +548,18 @@ static void __init map_mem(pgd_t *pgdp) >> >> /* >> * 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 >> + * read-only text and rodata sections of the kernel image so isolate >> + * those regions and map them after the for loop. >> */ >> - memblock_mark_nomap(kernel_start, kernel_end - kernel_start); >> + memblock_isolate_memory(kernel_start, kernel_end - kernel_start); >> >> #ifdef CONFIG_KEXEC_CORE >> if (crash_mem_map) { >> if (defer_reserve_crashkernel()) >> flags |= NO_BLOCK_MAPPINGS | NO_CONT_MAPPINGS; >> else if (crashk_res.end) >> - memblock_mark_nomap(crashk_res.start, >> - resource_size(&crashk_res)); >> + memblock_isolate_memory(crashk_res.start, >> + resource_size(&crashk_res)); >> } >> #endif >> >> @@ -568,6 +567,17 @@ static void __init map_mem(pgd_t *pgdp) >> for_each_mem_range(i, &start, &end) { >> if (start >= end) >> break; >> + >> + if (start == kernel_start) >> + continue; >> + >> +#ifdef CONFIG_KEXEC_CORE >> + if (start == crashk_res.start && >> + crash_mem_map && !defer_reserve_crashkernel() && >> + crashk_res.end) >> + continue; >> +#endif >> + >> /* >> * The linear map must allow allocation tags reading/writing >> * if MTE is present. Otherwise, it has the same attributes as >> @@ -589,7 +599,6 @@ static void __init map_mem(pgd_t *pgdp) >> */ >> __map_memblock(pgdp, kernel_start, kernel_end, >> PAGE_KERNEL, NO_CONT_MAPPINGS); >> - memblock_clear_nomap(kernel_start, kernel_end - kernel_start); >> >> /* >> * Use page-level mappings here so that we can shrink the region >> @@ -603,8 +612,6 @@ static void __init map_mem(pgd_t *pgdp) >> crashk_res.end + 1, >> PAGE_KERNEL, >> NO_BLOCK_MAPPINGS | NO_CONT_MAPPINGS); >> - memblock_clear_nomap(crashk_res.start, >> - resource_size(&crashk_res)); >> } >> } >> #endif >> -- >> 2.37.2 >> > _______________________________________________ > linux-riscv mailing list > linux-riscv@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-riscv