From: Peter Zijlstra <peterz@infradead.org>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
"H. Peter Anvin" <hpa@zytor.com>,
Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@kernel.org>, Borislav Petkov <bp@alien8.de>,
Andy Lutomirski <luto@amacapital.net>,
Joel Fernandes <joel@joelfernandes.org>,
He Zhe <zhe.he@windriver.com>,
Linus Torvalds <torvalds@linux-foundation.org>
Subject: Re: [RFC][PATCH] tracing/x86: Save CR2 before tracing irqsoff on error_entry
Date: Thu, 21 Mar 2019 09:33:17 +0100 [thread overview]
Message-ID: <20190321083317.GL6058@hirez.programming.kicks-ass.net> (raw)
In-Reply-To: <20190320221534.165ab87b@oasis.local.home>
On Wed, Mar 20, 2019 at 10:15:34PM -0400, Steven Rostedt wrote:
> And it would crash similarly each time I tried it, but always at a
> different place. After spending the day on this, I finally figured it
> out. The bug is happening in entry_64.S right after error_entry.
> There's two TRACE_IRQS_OFF in that code path, which if I comment out,
> the bug goes away. Then it dawned on me that the crash always happens
> when systemd does a normal page fault. We had this bug before, and it
> was with the exception trace points.
0ac09f9f8cd1 ("x86, trace: Fix CR2 corruption when tracing page faults")
d4078e232267 ("x86, trace: Further robustify CR2 handling vs tracing")
Or were you talking about:
70fb74a5420f ("x86: Save cr2 in NMI in case NMIs take a page fault (for i386)")
> The issue is that a tracepoint can fault (reading vmalloc or whatever).
> And doing a userspace stack trace most definitely will fault. But if we
> are coming from a legitimate page fault, the address of that fault (in
> the CR2 register) will be lost if we fault before we get to the page
> fault handler. That's exactly what is happening.
Shees, that could've been written much clearer. So you're saying:
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 do_page_fault
address = read_cr2(); /* whoopsie */
Right?
> To solve this, a TRACE_IRQS_OFF_CR2 (and ON for consistency) was added
> that saves the CR2 register. A new trace_hardirqs_off_thunk_cr2 is
> created that stores the cr2 register, calls the
> trace_hardirqs_off_caller, then on return restores the cr2 register if
> it changed, before returning.
Yuck.. also, not consistent with the actual patch. The thunk doesn't
save/restore CR2.
I really hate making this special TRACE_IRQS_OFF_CR2 thing, it feels far
too fragile. I'd _much_ rather push the #PF CR2 read much earlier.
Also, argh I fscking hate context tracking. That makes all this so much
more complicated. It if weren't for CALL_enter_from_user_mode, we could
pull that TRACE_IRQS_OFF out of error_entry.
Damn... Andy, any bright ideas?
next prev parent reply other threads:[~2019-03-21 8:33 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-21 2:15 [RFC][PATCH] tracing/x86: Save CR2 before tracing irqsoff on error_entry Steven Rostedt
2019-03-21 8:33 ` Peter Zijlstra [this message]
2019-03-21 9:02 ` Peter Zijlstra
2019-03-21 10:45 ` Peter Zijlstra
2019-03-21 13:32 ` Steven Rostedt
2019-03-21 13:55 ` Steven Rostedt
2019-03-21 17:23 ` Linus Torvalds
2019-03-21 17:22 ` Peter Zijlstra
2019-03-21 18:05 ` Andy Lutomirski
2019-03-21 18:10 ` Steven Rostedt
2019-03-21 18:27 ` Andy Lutomirski
2019-03-21 20:50 ` Peter Zijlstra
2019-03-22 2:52 ` Andy Lutomirski
2019-03-21 18:28 ` Peter Zijlstra
2019-03-21 18:55 ` Steven Rostedt
2019-03-21 19:31 ` Peter Zijlstra
2019-03-21 19:50 ` Steven Rostedt
2019-03-21 20:03 ` Peter Zijlstra
2019-03-21 20:11 ` Steven Rostedt
2019-03-21 18:18 ` Linus Torvalds
2019-03-21 18:20 ` Andy Lutomirski
2019-03-21 18:25 ` Linus Torvalds
2019-03-21 18:37 ` Peter Zijlstra
2019-03-21 18:39 ` Andy Lutomirski
2019-03-21 20:00 ` Andrew Cooper
2019-03-21 20:35 ` Steven Rostedt
2019-03-21 18:38 ` Andy Lutomirski
2019-03-21 18:42 ` Peter Zijlstra
2019-03-21 18:22 ` hpa
2019-03-22 5:54 ` Juergen Gross
2019-03-21 18:27 ` Peter Zijlstra
2019-03-21 18:28 ` Andy Lutomirski
2019-03-21 18:33 ` Peter Zijlstra
2019-03-21 13:04 ` Steven Rostedt
2019-04-17 1:52 ` He Zhe
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=20190321083317.GL6058@hirez.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=bp@alien8.de \
--cc=hpa@zytor.com \
--cc=joel@joelfernandes.org \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@amacapital.net \
--cc=mingo@kernel.org \
--cc=rostedt@goodmis.org \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.org \
--cc=zhe.he@windriver.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.