Re: [RFC][PATCH] x86/mm: Sync all vmalloc mappings before text_poke()

From: Steven Rostedt
Date: Wed Apr 29 2020 - 10:07:35 EST


On Wed, 29 Apr 2020 08:28:54 -0400
Steven Rostedt <rostedt@xxxxxxxxxxx> wrote:

> On Wed, 29 Apr 2020 12:59:41 +0200
> Joerg Roedel <jroedel@xxxxxxx> wrote:
>
> > > use_temporary_mm() {
> > > switch_mm_irqs_off() {
> > > load_new_mm_cr3() {
> > > write_cr3() <<--- Lock up!
> >
> > I don't see how it could lock up in write_cr3(), at least on bare-metal.
> > What is the environment this happens, 32 or 64 bit, in a VM or
> > bare-metal?
>
> 64 bit bare-metal. In fact, it wasn't reproducible on a VM (according
> to Tzvetomir, who was just using a Fedora kernel). I only tried it on
> bare-metal.
>
> >
> > I think it is more likely that your lockup is actually a page-fault
> > loop, where the #PF handler does not map the faulting address correctly.
>
> Sounds reasonable.
>
> >
> > But I have to look closer into how text_poke() works before I can say
> > more.
> >
> > Btw, in case it happens on x86-64, does it also happen without
> > vmalloc-stacks?
>
> Just tried it out with !CONFIG_VMAP_STACKS and it still locks up :-/

Talking with Mathieu about this on IRC, he pointed out that my code does
have a vzalloc() that is called:

in trace_pid_write()

pid_list->pids = vzalloc((pid_list->pid_max + 7) >> 3);

This is done when -P1,2 is on the trace-cmd command line.

-- Steve