From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 94419335BC4 for ; Wed, 10 Sep 2025 16:25:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757521556; cv=none; b=VcJ05ST5k0pj93UdwMKQFWMvlOpvX+xsr5a7bpwLgt+COana5h2CVjNZQigBV4FwaGpIXlhRZ6JWAJ6IsaSz2lF88jwrKsOdjBb2gbzWa/mdj/BC65EqelI1IRF3YC35Q7MBEwAeknK89pVKWRAHB05OGK0OwKJuw+xcMJzp/C4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757521556; c=relaxed/simple; bh=NItkhV+J7EkGZ9L4Me7fKyuKJDLlzvDoljoZzn5hHAU=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=VWK/NtTgg636ocGIZQw0dvMRQF0/EFZqqhOetxsBXLaG238z+5tGyaS6NZrk9jssQqtdwhkfRWY/ibKgtTdAHtA2MeDELirGq7MJCm7K1tpoDSGh3pOrmi9qbqiC9YQA/D+hoMVx6GiHsfxeepEDil4Ry0IuTWwsl3WZvJMRMPQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com 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 A713C16F2; Wed, 10 Sep 2025 09:25:44 -0700 (PDT) Received: from [10.57.67.148] (unknown [10.57.67.148]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id A8EE83F63F; Wed, 10 Sep 2025 09:25:50 -0700 (PDT) Message-ID: Date: Wed, 10 Sep 2025 18:25:48 +0200 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] arm64: mm: Move KPTI helpers to mmu.c To: Ryan Roberts , linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org, Anshuman Khandual , Ard Biesheuvel , Catalin Marinas , Kees Cook , Mark Rutland , Suzuki K Poulose , Will Deacon , Yeoreum Yun References: <20250910104454.317067-1-kevin.brodsky@arm.com> <6fd9df06-7120-4eef-9f02-70ba49266c75@arm.com> Content-Language: en-GB From: Kevin Brodsky In-Reply-To: <6fd9df06-7120-4eef-9f02-70ba49266c75@arm.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 10/09/2025 16:33, Ryan Roberts wrote: > On 10/09/2025 11:44, Kevin Brodsky wrote: >> create_kpti_ng_temp_pgd() is currently defined (as an alias) in >> mmu.c without matching declaration in a header; instead cpufeature.c >> makes its own declaration. This is clearly not pretty, and as commit >> ceca927c86e6 ("arm64: mm: Fix CFI failure due to kpti_ng_pgd_alloc >> function signature") showed, it also makes it very easy for the >> prototypes to go out of sync. >> >> All this would be much simpler if kpti_install_ng_mappings() and >> associated functions lived in mmu.c, where they logically belong. >> This is what this patch does: >> - Move kpti_install_ng_mappings() and associated functions from >> cpufeature.c to mmu.c, add a declaration to >> - Make create_kpti_ng_temp_pgd() a static function that simply calls >> __create_pgd_mapping_locked() instead of aliasing it >> - Mark all these functions __init >> - Move __initdata after kpti_ng_temp_alloc (as suggested by >> checkpatch) > This is a great clean up IMHO; that alias has caught me out a few times in the > past when hacking in this area. And this code clearly belongs in mmu.c. Good to hear! >> Signed-off-by: Kevin Brodsky >> --- >> Note: as things stand, create_kpti_ng_temp_pgd() could be removed, >> but a separate patch [1] will make use of it to add an >> assertion. > I'd vote for removing it and just calling __create_pgd_mapping_locked() direct. > The next version of the other patch can just rebase on top of yours and add the > assert in __kpti_install_ng_mappings(). Oh yes good point, not sure why I didn't consider that! It clearly makes more sense, I'll send a v2. > Either way: > > Reviewed-by: Ryan Roberts > >> [1] https://lore.kernel.org/all/20250813145607.1612234-3-chaitanyas.prakash@arm.com/ >> >> [...] >> >> +static pgprot_t __init kernel_exec_prot(void) > nit: this change (to add __init) is unrelated; does it deserve it's own patch? I thought I might as well sneak it in since it's still related to KPTI and in the same block... But happy to split it off if that feels more appropriate. - Kevin