[PATCH] arm64: fixmap: fix missing break-before-make in __set_fixmap()

yadong.qi at linux.alibaba.com yadong.qi at linux.alibaba.com
Tue Nov 24 18:43:30 PST 2026


> -----Original Message-----
> From: Catalin Marinas <catalin.marinas at arm.com>
> Sent: 2026年11月25日 0:11
> To: Yadong Qi <yadong.qi at linux.alibaba.com>
> Cc: will at kernel.org; mark.rutland at arm.com; ying.huang at linux.alibaba.com;
> linux-arm-kernel at lists.infradead.org; linux-kernel at vger.kernel.org;
> ryan.roberts at arm.com; robh at kernel.org; gregkh at linuxfoundation.org;
> ptg-linux-kernel at linux.alibaba.com; stable at vger.kernel.org
> Subject: Re: [PATCH] arm64: fixmap: fix missing break-before-make in
> __set_fixmap()
> 
> On Mon, Nov 23, 2026 at 05:35:05PM +0800, Yadong Qi wrote:
> > diff --git a/arch/arm64/mm/fixmap.c b/arch/arm64/mm/fixmap.c
> > index f66a0016dd02..5593d7e0d523 100644
> > --- a/arch/arm64/mm/fixmap.c
> > +++ b/arch/arm64/mm/fixmap.c
> > @@ -126,12 +126,19 @@ void __set_fixmap(enum fixed_addresses idx,
> >
> >  	ptep = fixmap_pte(addr);
> >
> > -	if (pgprot_val(flags)) {
> > -		__set_pte(ptep, pfn_pte(phys >> PAGE_SHIFT, flags));
> > -	} else {
> > +	/*
> > +	 * Break-before-make: when the slot still holds a valid mapping
> > +	 * (e.g. earlycon re-mapping FIX_EARLYCON_MEM_BASE), invalidate the
> > +	 * old entry and flush the TLB entries caching it before a new
> > +	 * mapping is installed, so old and new translations never coexist.
> > +	 */
> > +	if (pte_valid(__ptep_get(ptep))) {
> >  		__pte_clear(&init_mm, addr, ptep);
> > -		flush_tlb_kernel_range(addr, addr+PAGE_SIZE);
> > +		flush_tlb_kernel_range(addr, addr + PAGE_SIZE);
> >  	}
> > +
> > +	if (pgprot_val(flags))
> > +		__set_pte(ptep, pfn_pte(phys >> PAGE_SHIFT, flags));
> >  }
> 
> I guess that's easier than getting the driver or earlycon code to do
> clear_fixmap(). Note that I queued Fuad's patches for missing barriers
> onto arm64 for-next/fixes, so please rebase on top.
Sure, will rebase on that.

> 
> Sashiko also has a valid point about keeping the TLB flush unconditional
> for the clear_fixmap() case:
> 
> https://sashiko.dev/#/patchset/20261123093505.974-1-yadong.qi@linux.alibaba.c
> om
Got it.

> 
> --
> Catalin


Best Regards
Yadong




More information about the linux-arm-kernel mailing list