public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Dave Hansen <dave.hansen@intel.com>
To: Thomas Gleixner <tglx@linutronix.de>
Cc: x86@kernel.org, Peter Zijlstra <peterz@infradead.org>,
	LKML <linux-kernel@vger.kernel.org>,
	Gleb Natapov <gleb@redhat.com>,
	Steven Rostedt <rostedt@goodmis.org>
Subject: Re: KVM_GUEST support breaks page fault tracing
Date: Thu, 08 May 2014 16:05:12 -0700	[thread overview]
Message-ID: <536C0DA8.4090608@intel.com> (raw)
In-Reply-To: <alpine.DEB.2.02.1405090024050.6261@ionos.tec.linutronix.de>

[-- Attachment #1: Type: text/plain, Size: 1068 bytes --]

On 05/08/2014 03:24 PM, Thomas Gleixner wrote:
>> > I noticed on some of my systems that page fault tracing doesn't work:
>> > 
>> > 	cd /sys/kernel/debug/tracing
>> > 	echo 1 > events/exceptions/enable
>> > 	cat trace;
>> > 	# nothing shows up
>> > 
>> > I eventually traced it down to CONFIG_KVM_GUEST.  At least in a KVM VM,
>> > enabling that option breaks page fault tracing, and disabling fixes it.
>> >  I tried on some old kernels and this does not appear to be a
>> > regression: it never worked.
>> > 
>> > Anybody have any theories about what is going on?

Looks like the KVM code calls do_page_fault() directly:

> dotraplinkage void __kprobes
> do_async_page_fault(struct pt_regs *regs, unsigned long error_code)
> {
>         enum ctx_state prev_state;
> 
>         switch (kvm_read_and_reset_pf_reason()) {
>         default:
>                 do_page_fault(regs, error_code);
>                 break;
>         case KVM_PV_REASON_PAGE_NOT_PRESENT:

That seems to explain my problems in a VM.  Any objections to doing
something like the attached patch?

[-- Attachment #2: muck-with-kvm-guest-code.patch --]
[-- Type: text/x-patch, Size: 1421 bytes --]



---

 b/arch/x86/include/asm/traps.h |    5 +++++
 b/arch/x86/kernel/kvm.c        |    2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff -puN arch/x86/kernel/kvm.c~muck-with-kvm-guest-code arch/x86/kernel/kvm.c
--- a/arch/x86/kernel/kvm.c~muck-with-kvm-guest-code	2014-05-08 15:03:24.358110394 -0700
+++ b/arch/x86/kernel/kvm.c	2014-05-08 16:03:56.765302785 -0700
@@ -259,7 +259,7 @@ do_async_page_fault(struct pt_regs *regs
 
 	switch (kvm_read_and_reset_pf_reason()) {
 	default:
-		do_page_fault(regs, error_code);
+		trace_do_page_fault(regs, error_code);
 		break;
 	case KVM_PV_REASON_PAGE_NOT_PRESENT:
 		/* page is swapped out by the host. */
diff -puN arch/x86/include/asm/traps.h~muck-with-kvm-guest-code arch/x86/include/asm/traps.h
--- a/arch/x86/include/asm/traps.h~muck-with-kvm-guest-code	2014-05-08 16:02:14.873675048 -0700
+++ b/arch/x86/include/asm/traps.h	2014-05-08 16:03:06.519020810 -0700
@@ -74,6 +74,11 @@ dotraplinkage void do_general_protection
 dotraplinkage void do_page_fault(struct pt_regs *, unsigned long);
 #ifdef CONFIG_TRACING
 dotraplinkage void trace_do_page_fault(struct pt_regs *, unsigned long);
+#else
+static inline void trace_do_page_fault(struct pt_regs *regs, unsigned long error)
+{
+	do_page_fault(regs, error);
+}
 #endif
 dotraplinkage void do_spurious_interrupt_bug(struct pt_regs *, long);
 dotraplinkage void do_coprocessor_error(struct pt_regs *, long);
_

  reply	other threads:[~2014-05-08 23:05 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-08 22:22 KVM_GUEST support breaks page fault tracing Dave Hansen
2014-05-08 22:24 ` Thomas Gleixner
2014-05-08 23:05   ` Dave Hansen [this message]
2014-05-08 23:45     ` Steven Rostedt
2014-05-09 16:42       ` Dave Hansen

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=536C0DA8.4090608@intel.com \
    --to=dave.hansen@intel.com \
    --cc=gleb@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox