mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Huang, Ying" <ying.huang@linux.alibaba.com>
To: Catalin Marinas <catalin.marinas@arm.com>
Cc: Yadong Qi <yadong.qi@linux.alibaba.com>,
	 will@kernel.org, mark.rutland@arm.com,
	 linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org,  ryan.roberts@arm.com,
	 robh@kernel.org, gregkh@linuxfoundation.org,
	 ptg-linux-kernel@linux.alibaba.com, stable@vger.kernel.org
Subject: Re: [PATCH] arm64: fixmap: fix missing break-before-make in __set_fixmap()
Date: Thu, 26 Nov 2026 10:42:11 +0800	[thread overview]
Message-ID: <87wlq0s48s.fsf@DESKTOP-5N7EMDA> (raw)
In-Reply-To: <awbvHVSX7sB8jzYA@arm.com> (Catalin Marinas's message of "Wed, 25 Nov 2026 14:22:21 +0000")

Catalin Marinas <catalin.marinas@arm.com> writes:

> On Wed, Nov 25, 2026 at 02:36:36PM +0800, Huang, Ying wrote:
>> Catalin Marinas <catalin.marinas@arm.com> writes:
>> 
>> > 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().
>> 
>> Yes.  And because set_fixmap() flushes the tlb on x86, IMHO, it's a
>> little hard to justify the driver modification.
>> 
>> However, set_fixmap() only flushes the tlb on the local CPU instead of
>> broadcasting the flush, because fixmap is either per-CPU or used during
>> early boot.  In theory, we could follow that approach and perform a
>> local flush instead though the benefit may be marginal.
>
> Local TLBI won't work on arm64 since the page tables are shared (any CPU
> can speculatively load the TLB) and only FIX_VNCR has per-CPU entries.

Got it.  IIUC, because we have the shared page table and the BBM
restriction, even if we change the PTE for a per-CPU entry, we still
need to use a global TLBI.

---
Best Regards,
Huang, Ying

      reply	other threads:[~2026-11-26  2:42 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-23  9:35 Yadong Qi
2026-11-24 16:10 ` Catalin Marinas
2026-11-25  2:43   ` yadong.qi
2026-11-25  6:36   ` Huang, Ying
2026-11-25 14:22     ` Catalin Marinas
2026-11-26  2:42       ` Huang, Ying [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87wlq0s48s.fsf@DESKTOP-5N7EMDA \
    --to=ying.huang@linux.alibaba.com \
    --cc=catalin.marinas@arm.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=ptg-linux-kernel@linux.alibaba.com \
    --cc=robh@kernel.org \
    --cc=ryan.roberts@arm.com \
    --cc=stable@vger.kernel.org \
    --cc=will@kernel.org \
    --cc=yadong.qi@linux.alibaba.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®