Re: [PATCH v10 00/10] x86: Quiesce text_poke() IPIs

From: Valentin Schneider

Date: Wed Dec 02 2026 - 05:41:53 EST


On 01/12/26 13:41, Andy Lutomirski wrote:
> On Tue, Dec 1, 2026, at 1:28 PM, Andy Lutomirski wrote:
>> On Tue, Dec 1, 2026, at 4:55 AM, Peter Zijlstra wrote:
>>> On Tue, Dec 01, 2026 at 12:10:26PM +0100, Valentin Schneider wrote:
>>>
>>>> The real problem is those (kernel) TLB flushes. I found no way to
>>>> check/validate when/where exactly vmalloc accesses can happen in the kernel
>>>> entry, so the only sane approach was to have the catch-up sequence (TLB
>>>> flush) happen exactly when any vmalloc becomes possible: at the kPTI CR3
>>>> switch.
>>>
>>> Right, so the task stacks are vmalloc. So since you didn't qualify what
>>> vmalloc accesses are problematic, it is pretty much the very first thing
>>> you touch.
>>
>> I spent like thirty seconds contemplating exactly how nasty it would be
>> to try to implement all this cleanly without touching the vmapped stack.
>>
>> And then I decided this was a nonissue. Consider how we actually reach
>> the enter-the-kernel code: we start in the kernel *on the task stack*,
>> then we run the exit-the-kernel code, then we maybe go to userspace and
>> come back, then we run the enter-the-kernel code.
>>
>> There had better not be anything in the kernel that changes the task
>> stack mapping and relies on an IPI that runs in the interim! If there
>> was, it would surely crash us just as crashily if we were just
>> executing normal kernel code, expecially with IRQs off :)
>
> Let me say this more clearly: no one unmaps the task stack while the task is still running.
>

Right, the task has to reach do_exit() in kernelspace proper before that
happens; I think I had established quite early on that this one of the
few safe cases.

The annoying thing is that I can't quiesce kernel TLB range flushes /just/
for the task stacks, there's too much indirection and from what I've seen
these flushes are mainly driven by __purge_vmap_area_lazy() which is
completely out of line.

Ideally I would like to have some static/build time analysis (like objtool
for the text_poke() stuff) that can catch vmap'd accesses in .entry text to
1) validate this stuff
2) prevent future breakage
but again I fear there's too much indirection.

I had given up trying to set up some poisoning scheme to at least get some
debug info under QEMU, maybe I can try again by shoving that to an AI.