Re: [RFC][PATCH] tracing/x86: Save CR2 before tracing irqsoff on error_entry

From: Peter Zijlstra
Date: Thu Mar 21 2019 - 05:02:52 EST


On Thu, Mar 21, 2019 at 09:33:17AM +0100, Peter Zijlstra wrote:

I'm thinking this problem wasn't new.

> idtentry page_fault do_page_fault has_error_code=1
> call error_entry
> TRACE_IRQS_OFF
> call trace_hardirqs_off*
> <tracer stuff>
> <fault> # modifies CR2

CALL_enter_from_user_mode
__context_tracking_exit()
trace_user_exit(0)
#PF

> call do_page_fault
> address = read_cr2(); /* whoopsie */

And that also isn't fixed by your patch.

I'm trying to make idtentry put cr2 in rdx, such that do_page_fault()
takes address as a 3rd argument, but I'm still fighting that context
tracking nonsense.