From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B9F552475D0 for ; Fri, 22 May 2026 06:51:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779432711; cv=none; b=BrtvQuwKItJGuH3NwvRtW2k7W3NQqD0LhO5cPPnePpyGALqderuC2F6281bJy7dptilgpP7ff9gFbnnL14dnEe+TkEfyOxrLGeM2gzVer7p/TLU4P/kOaY2t5JGqLh6Ma12WFj6qTTYJcE+kDQ5DRoghsv0nt983IOBLVfiIsQ8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779432711; c=relaxed/simple; bh=Qyi096iRzU8r9/jqIoPT7t39SJp7pSCukgtW3m3/Uhc=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=HSVfRZ3J464jkJ7I7yHT6Q323a5P5xm8nhRo0PTzPEYox0K1fQHkNyDQqXGbjioPfeC8tBNO5GJ0sODLts8k7CZCd5BRSTB43PgsMVrH0+gSqHs/97wKOctUvl+ncbkmH4NEj9ySiA2arHwy/sEOzmEKmAK5i+l/RkO2vl7mLHg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=YeAKmcy9; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="YeAKmcy9" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 04AE01F000E9; Fri, 22 May 2026 06:51:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1779432710; bh=IbXyWQ5T5tgl83yU5MLVm4r8uYyUNSyUC9g+Wz/2rFs=; h=Date:Subject:To:Cc:References:From:In-Reply-To; b=YeAKmcy9A6+AkfcUKSjQZC4fx/dRV+9epVeo32VcYbcU/aRIPMoorMPxL27IHN40D vrS6gAKTbxi9TK0g3IPBfneVhbvDnlrIzVtllROisLvqZE79VAzSlFyPLFHRbleale jZd450gTmPpaucAqiYPJZ5Du0smwP5mMcxiiW8a9x3aE0TRmmWZZzaKrmB5SJVTooO 3QiKZOaGu8AMN13QWzpxrBUOVzSgXBkBhUCcfPbh7yXX1m2vBCeNfaqd+qmm8A5p6X 2+qmAlkefwQS6SXmDARSZGZQR8vR+MM0pdO+GpYNiv3eB5USNTUsmb5aovFdYUr7wv aNXjwV2jIbmuQ== Message-ID: Date: Fri, 22 May 2026 16:51:46 +1000 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 resend] powerpc/code-patching: Avoid r/w mapping of the zero page To: Ard Biesheuvel , "Christophe Leroy (CS GROUP)" , linux-kernel@vger.kernel.org Cc: linuxppc-dev@lists.ozlabs.org, Madhavan Srinivasan , Nicholas Piggin References: <20260520085423.485402-1-ardb@kernel.org> <3e63e2eb-30b3-4377-9331-41445d9c8720@app.fastmail.com> <757318e3-91df-4e39-ba44-5130626d38b8@kernel.org> Content-Language: en-US From: Michael Ellerman In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 20/5/2026 20:16, Ard Biesheuvel wrote: > > On Wed, 20 May 2026, at 11:59, Christophe Leroy (CS GROUP) wrote: >> Le 20/05/2026 à 11:40, Ard Biesheuvel a écrit : >>> >>> On Wed, 20 May 2026, at 11:36, Christophe Leroy (CS GROUP) wrote: >>>> Le 20/05/2026 à 10:54, Ard Biesheuvel a écrit : ... >>>>> diff --git a/arch/powerpc/lib/code-patching.c b/arch/powerpc/lib/code-patching.c >>>>> index f84e0337cc02..13a8acf851f1 100644 >>>>> --- a/arch/powerpc/lib/code-patching.c >>>>> +++ b/arch/powerpc/lib/code-patching.c >>>>> @@ -60,7 +60,7 @@ struct patch_context { >>>>> >>>>> static DEFINE_PER_CPU(struct patch_context, cpu_patching_context); >>>>> >>>>> -static int map_patch_area(void *addr, unsigned long text_poke_addr); >>>>> +static int map_patch_area(unsigned long text_poke_addr); >>>>> static void unmap_patch_area(unsigned long addr); >>>>> >>>>> static bool mm_patch_enabled(void) >>>>> @@ -117,7 +117,7 @@ static int text_area_cpu_up(unsigned int cpu) >>>>> >>>>> // Map/unmap the area to ensure all page tables are pre-allocated >>>>> addr = (unsigned long)area->addr; >>>>> - err = map_patch_area(empty_zero_page, addr); >>>>> + err = map_patch_area(addr); >>>> >>>> I would get rid of map_patch_area() completely and just do: >>>> >>>> err = map_kernel_page(addr, __pa_symbol(empty_zero_page), PAGE_KERNEL_RO); >>>> >>> >>> I think retaining the symmetry of map_patch_area() and unmap_patch_area() >>> makes sense too. >> >> Could also drop unmap_patch_area() and use unmap_kernel_page() instead. >> > > Good point. That way, we'll end up with > > arch/powerpc/lib/code-patching.c | 52 ++-------------------------------------- > 1 file changed, 2 insertions(+), 50 deletions(- > > I'll spin a v2 with those changes once everyone on cc has had the opportunity > to chime in. That diffstat is definitely attractive. I do like that unmap_patch_area() is more defensive with the page table walk, but it's probably overly paranoid. If page table levels have vanished since we just mapped them then the system is probably toast anyway. So OK by me. cheers