All of lore.kernel.org
 help / color / mirror / Atom feed
From: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
To: kvm@vger.kernel.org
Subject: Re: nmi is broken?
Date: Sun, 24 Apr 2011 07:50:23 +0900	[thread overview]
Message-ID: <877hak1t1s.fsf@devron.myhome.or.jp> (raw)
In-Reply-To: <87sjtbe7fz.fsf@devron.myhome.or.jp> (OGAWA Hirofumi's message of "Fri, 22 Apr 2011 04:21:52 +0900")

OGAWA Hirofumi <hirofumi@mail.parknet.co.jp> writes:

> I noticed recently NMI on guest kernel is not working well.  host/guest
> kernel is 2.6.39-rc4, and using vmx.
>
> And test code is something like the following:
>
> 	local_irq_disable();
> 	for (i = 0; i < 10; i++) {
> 		int cpu = get_cpu();
> 		printk("%s: nmi %u, lapic %u\n", __FUNCTION__,
> 			nmi_count(cpu), irq_stat[cpu].apic_timer_irqs);
> 		mdelay(1000);
> 		put_cpu();
> 	}
>
> the result is both of nmi and lapic are not increased. If I used
> -no-kvm-irqchip, it works fine (increase nmi only). So, it seems to be
> the bug of kvm driver side.

With some debug, the cause seems to be in pit_do_work(). With the
following patch, NMI watchdog seems to be working correctly (if irq
disabled for long time, NMI watchdog can detect it).

Is the following patch right?
-- 
OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>


[PATCH] kvm: Fix NMI on irq disabled state

On irq disabled state, there is no ->irq_ask from quest kernel. But
NMI shouldn't be affected by it.

This fixes inject NMI unconditionally.

Signed-off-by: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
---

 arch/x86/kvm/i8254.c |   26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)

diff -puN arch/x86/kvm/i8254.c~kvm-nmi-fix arch/x86/kvm/i8254.c
--- linux-2.6/arch/x86/kvm/i8254.c~kvm-nmi-fix	2011-04-24 07:42:23.000000000 +0900
+++ linux-2.6-hirofumi/arch/x86/kvm/i8254.c	2011-04-24 07:42:23.000000000 +0900
@@ -305,20 +305,20 @@ static void pit_do_work(struct work_stru
 	if (inject) {
 		kvm_set_irq(kvm, kvm->arch.vpit->irq_source_id, 0, 1);
 		kvm_set_irq(kvm, kvm->arch.vpit->irq_source_id, 0, 0);
-
-		/*
-		 * Provides NMI watchdog support via Virtual Wire mode.
-		 * The route is: PIT -> PIC -> LVT0 in NMI mode.
-		 *
-		 * Note: Our Virtual Wire implementation is simplified, only
-		 * propagating PIT interrupts to all VCPUs when they have set
-		 * LVT0 to NMI delivery. Other PIC interrupts are just sent to
-		 * VCPU0, and only if its LVT0 is in EXTINT mode.
-		 */
-		if (kvm->arch.vapics_in_nmi_mode > 0)
-			kvm_for_each_vcpu(i, vcpu, kvm)
-				kvm_apic_nmi_wd_deliver(vcpu);
 	}
+
+	/*
+	 * Provides NMI watchdog support via Virtual Wire mode.
+	 * The route is: PIT -> PIC -> LVT0 in NMI mode.
+	 *
+	 * Note: Our Virtual Wire implementation is simplified, only
+	 * propagating PIT interrupts to all VCPUs when they have set
+	 * LVT0 to NMI delivery. Other PIC interrupts are just sent to
+	 * VCPU0, and only if its LVT0 is in EXTINT mode.
+	 */
+	if (kvm->arch.vapics_in_nmi_mode > 0)
+		kvm_for_each_vcpu(i, vcpu, kvm)
+			kvm_apic_nmi_wd_deliver(vcpu);
 }
 
 static enum hrtimer_restart pit_timer_fn(struct hrtimer *data)
_

  reply	other threads:[~2011-04-23 22:50 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-21 19:21 nmi is broken? OGAWA Hirofumi
2011-04-23 22:50 ` OGAWA Hirofumi [this message]
2011-04-24  6:44   ` Avi Kivity
2011-04-24  9:17     ` OGAWA Hirofumi
2011-04-24  9:46       ` Jan Kiszka
2011-04-24 11:13         ` OGAWA Hirofumi
2011-04-24 11:15           ` OGAWA Hirofumi
2011-04-24 12:24     ` Jan Kiszka
2011-04-27  8:55       ` Avi Kivity
2011-04-27 12:09         ` Jan Kiszka
2011-04-28  1:28         ` OGAWA Hirofumi
2011-04-28  9:59           ` Avi Kivity
2011-04-28 13:44             ` OGAWA Hirofumi
2011-04-28 14:23               ` OGAWA Hirofumi
2011-05-01  1:45                 ` OGAWA Hirofumi
2011-05-02  8:46                   ` Avi Kivity
2011-05-02 14:30                     ` OGAWA Hirofumi
2011-05-03  9:36                       ` Avi Kivity
2011-05-03 10:07                         ` Avi Kivity
2011-05-03 13:25                           ` OGAWA Hirofumi
2011-05-03 13:35                             ` Avi Kivity
2011-05-03 16:57                               ` OGAWA Hirofumi
2011-05-03 17:09                                 ` Avi Kivity
2011-05-03 17:45                                   ` OGAWA Hirofumi
2011-05-04  8:27                                     ` Avi Kivity
2011-05-04 15:40                                       ` OGAWA Hirofumi
2011-05-04 16:15                                         ` Avi Kivity
2011-04-24 14:08     ` Jan Kiszka
2011-05-03  9:43       ` Avi Kivity
2011-05-03 10:37         ` Jan Kiszka
2011-05-03 13:31           ` Avi Kivity
2011-05-03 14:29             ` Jan Kiszka
2011-05-03 14:37               ` Avi Kivity
2011-05-03 15:01                 ` Jan Kiszka
  -- strict thread matches above, loose matches on Subject: below --
2001-11-30  9:10 NMI is broken! george anzinger
2001-12-01  7:11 ` george anzinger

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=877hak1t1s.fsf@devron.myhome.or.jp \
    --to=hirofumi@mail.parknet.co.jp \
    --cc=kvm@vger.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 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.