On Fri, Nov 14, 2025, at 7:14 AM, Valentin Schneider wrote: > Deferring kernel range TLB flushes requires the guarantee that upon > entering the kernel, no stale entry may be accessed. The simplest way to > provide such a guarantee is to issue an unconditional flush upon switching > to the kernel CR3, as this is the pivoting point where such stale entries > may be accessed. > Doing this together with the PTI CR3 switch has no actual benefit: MOV CR3 doesn’t flush global pages. And doing this in asm is pretty gross. We don’t even get a free sync_core() out of it because INVPCID is not documented as being serializing. Why can’t we do it in C? What’s the actual risk? In order to trip over a stale TLB entry, we would need to deference a pointer to newly allocated kernel virtual memory that was not valid prior to our entry into user mode. I can imagine BPF doing this, but plain noinstr C in the entry path? Especially noinstr C *that has RCU disabled*? We already can’t follow an RCU pointer, and ISTM the only style of kernel code that might do this would use RCU to protect the pointer, and we are already doomed if we follow an RCU pointer to any sort of memory. We do need to watch out for NMI/MCE hitting before we flush.
- [PATCH v7 15/31] sched/clock: Mark sched_clock_running ... Valentin Schneider
- [PATCH v7 13/31] arm/paravirt: Mark pv_steal_clock stat... Valentin Schneider
- [PATCH v7 16/31] KVM: VMX: Mark __kvm_is_using_evmcs st... Valentin Schneider
- [PATCH v7 02/31] objtool: Flesh out warning related to ... Valentin Schneider
- [PATCH v7 19/31] sched/clock, x86: Mark __sched_clock_s... Valentin Schneider
- [PATCH v7 21/31] stackleack: Mark stack_erasing_bypass ... Valentin Schneider
- [PATCH v7 20/31] KVM: VMX: Mark vmx_l1d_should flush an... Valentin Schneider
- [PATCH v7 27/31] x86/mm: Make INVPCID type macros avail... Valentin Schneider
- [PATCH v7 07/31] x86/paravirt: Mark pv_sched_clock stat... Valentin Schneider
- [RFC PATCH v7 29/31] x86/mm/pti: Implement a TLB flush ... Valentin Schneider
- Re: [RFC PATCH v7 29/31] x86/mm/pti: Implement a T... Andy Lutomirski
- Re: [RFC PATCH v7 29/31] x86/mm/pti: Implement... Valentin Schneider
- Re: [RFC PATCH v7 29/31] x86/mm/pti: Imple... Andy Lutomirski
- Re: [RFC PATCH v7 29/31] x86/mm/pti: I... Valentin Schneider
- [RFC PATCH v7 28/31] x86/mm/pti: Introduce a kernel/use... Valentin Schneider
- [PATCH v7 22/31] objtool: Add noinstr validation for st... Valentin Schneider
- [PATCH v7 17/31] x86/bugs: Mark cpu_buf_vm_clear key as... Valentin Schneider
- [PATCH v7 23/31] module: Add MOD_NOINSTR_TEXT mem_type Valentin Schneider
- [PATCH v7 11/31] loongarch/paravirt: Mark pv_steal_cloc... Valentin Schneider
- [RFC PATCH v7 30/31] x86/mm, mm/vmalloc: Defer kernel T... Valentin Schneider
