mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Dan Aloni <alonid@stratoscale.com>
To: linux-kernel@vger.kernel.org
Cc: kvm@vger.kernel.org, kgdb-bugreport@lists.sourceforge.net,
	x86@kernel.org, gleb@redhat.com, pbonzini@redhat.com,
	tglx@linutronix.de, mingo@redhat.com, hpa@zytor.com,
	Muli Ben-Yehuda <muli@stratoscale.com>
Subject: [PATCH linux-next 2/2] kvm-x86: emulator: disable kgdb-x86 on fastop and fpe flush
Date: Tue, 19 Nov 2013 16:53:30 +0200	[thread overview]
Message-ID: <1384872810-29492-3-git-send-email-alonid@stratoscale.com> (raw)
In-Reply-To: <1384872810-29492-1-git-send-email-alonid@stratoscale.com>

We have seen that when kvm-unit-tests runs with kgdb enabled, the
kernel halts on the debugger during the KVM x86 instruction emulation
that performs a test of a division by zero, and also during fwait.

This patch adds calls that temporarily disable the debugger trap.

Signed-off-by: Dan Aloni <alonid@stratoscale.com>
Signed-off-by: Muli Ben-Yehuda <muli@stratoscale.com>
---
 arch/x86/kvm/emulate.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
index 07ffca0..05e8509 100644
--- a/arch/x86/kvm/emulate.c
+++ b/arch/x86/kvm/emulate.c
@@ -24,6 +24,7 @@
 #include "kvm_cache_regs.h"
 #include <linux/module.h>
 #include <asm/kvm_emulate.h>
+#include <asm/kgdb.h>
 #include <linux/stringify.h>
 
 #include "x86.h"
@@ -4438,6 +4439,7 @@ static int flush_pending_x87_faults(struct x86_emulate_ctxt *ctxt)
 {
 	bool fault = false;
 
+	kgdb_ll_local_disable();
 	ctxt->ops->get_fpu(ctxt);
 	asm volatile("1: fwait \n\t"
 		     "2: \n\t"
@@ -4449,6 +4451,7 @@ static int flush_pending_x87_faults(struct x86_emulate_ctxt *ctxt)
 		     _ASM_EXTABLE(1b, 3b)
 		     : [fault]"+qm"(fault));
 	ctxt->ops->put_fpu(ctxt);
+	kgdb_ll_local_enable();
 
 	if (unlikely(fault))
 		return emulate_exception(ctxt, MF_VECTOR, 0, false);
@@ -4468,10 +4471,14 @@ static int fastop(struct x86_emulate_ctxt *ctxt, void (*fop)(struct fastop *))
 	ulong flags = (ctxt->eflags & EFLAGS_MASK) | X86_EFLAGS_IF;
 	if (!(ctxt->d & ByteOp))
 		fop += __ffs(ctxt->dst.bytes) * FASTOP_SIZE;
+
+	kgdb_ll_local_disable();
 	asm("push %[flags]; popf; call *%[fastop]; pushf; pop %[flags]\n"
 	    : "+a"(ctxt->dst.val), "+d"(ctxt->src.val), [flags]"+D"(flags),
 	      [fastop]"+S"(fop)
 	    : "c"(ctxt->src2.val));
+	kgdb_ll_local_enable();
+
 	ctxt->eflags = (ctxt->eflags & ~EFLAGS_MASK) | (flags & EFLAGS_MASK);
 	if (!fop) /* exception is returned in fop variable */
 		return emulate_de(ctxt);
-- 
1.8.3.1


  parent reply	other threads:[~2013-11-19 14:54 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-19 14:53 Dan Aloni
2013-11-19 14:53 ` [PATCH linux-next 1/2] kgdb-x86: allow to temporarily disable trap activation Dan Aloni
2013-11-19 14:53 ` Dan Aloni [this message]
2013-11-19 15:02   ` [PATCH linux-next 2/2] kvm-x86: emulator: disable kgdb-x86 on fastop and fpe flush Paolo Bonzini
2013-11-27 10:08 ` KVM/KGDB integration Gleb Natapov

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=1384872810-29492-3-git-send-email-alonid@stratoscale.com \
    --to=alonid@stratoscale.com \
    --cc=gleb@redhat.com \
    --cc=hpa@zytor.com \
    --cc=kgdb-bugreport@lists.sourceforge.net \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=muli@stratoscale.com \
    --cc=pbonzini@redhat.com \
    --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

all inboxes | Powered by JetHome®