kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Wanpeng Li <kernellwp@gmail.com>
To: David Matlack <dmatlack@google.com>
Cc: LKML <linux-kernel@vger.kernel.org>,
	kvm list <kvm@vger.kernel.org>,
	Paolo Bonzini <pbonzini@redhat.com>,
	Sean Christopherson <seanjc@google.com>,
	Vitaly Kuznetsov <vkuznets@redhat.com>,
	Wanpeng Li <wanpengli@tencent.com>,
	Jim Mattson <jmattson@google.com>, Joerg Roedel <joro@8bytes.org>
Subject: Re: [PATCH 1/2] KVM: LAPIC: write 0 to TMICT should also cancel vmx-preemption timer
Date: Fri, 4 Jun 2021 08:32:57 +0800	[thread overview]
Message-ID: <CANRm+CzNeGzJyisK659h1kdgcQQ+Y7OwW+tiXPnZ9gmiGB1qUA@mail.gmail.com> (raw)
In-Reply-To: <CALzav=e9pbkk0=Yz9s1b+53MEy7yuo_otoFM75fNeoJGCQjqCg@mail.gmail.com>

On Fri, 4 Jun 2021 at 07:02, David Matlack <dmatlack@google.com> wrote:
>
> On Thu, Jun 3, 2021 at 2:04 AM Wanpeng Li <kernellwp@gmail.com> wrote:
> >
> > From: Wanpeng Li <wanpengli@tencent.com>
> >
> > According to the SDM 10.5.4.1:
> >
> >   A write of 0 to the initial-count register effectively stops the local
> >   APIC timer, in both one-shot and periodic mode.
>
> If KVM is not correctly emulating this behavior then could you also
> add a kvm-unit-test to test for the correct behavior?

A simple test here, the test will hang after the patch since it will
not receive the spurious interrupt any more.

diff --git a/x86/apic.c b/x86/apic.c
index a7681fe..947d018 100644
--- a/x86/apic.c
+++ b/x86/apic.c
@@ -488,6 +488,14 @@ static void test_apic_timer_one_shot(void)
      */
     report((lvtt_counter == 1) && (tsc2 - tsc1 >= interval),
            "APIC LVT timer one shot");
+
+    lvtt_counter = 0;
+    apic_write(APIC_TMICT, interval);
+    apic_write(APIC_TMICT, 0);
+    while (!lvtt_counter);
+
+    report((lvtt_counter == 1),
+          "APIC LVT timer one shot spurious interrupt");
 }

  reply	other threads:[~2021-06-04  0:34 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-03  9:00 [PATCH 1/2] KVM: LAPIC: write 0 to TMICT should also cancel vmx-preemption timer Wanpeng Li
2021-06-03  9:00 ` [PATCH 2/2] KVM: LAPIC: reset TMCCT during vCPU reset Wanpeng Li
2021-06-03 12:27   ` Jim Mattson
2021-06-03 15:34     ` Sean Christopherson
2021-06-08  0:31       ` Wanpeng Li
2021-06-03 15:20 ` [PATCH 1/2] KVM: LAPIC: write 0 to TMICT should also cancel vmx-preemption timer Sean Christopherson
2021-06-04  0:36   ` Wanpeng Li
2021-06-04 15:37     ` Sean Christopherson
2021-06-08  0:30       ` Wanpeng Li
2021-06-03 23:02 ` David Matlack
2021-06-04  0:32   ` Wanpeng Li [this message]
2021-06-04 15:59     ` David Matlack

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=CANRm+CzNeGzJyisK659h1kdgcQQ+Y7OwW+tiXPnZ9gmiGB1qUA@mail.gmail.com \
    --to=kernellwp@gmail.com \
    --cc=dmatlack@google.com \
    --cc=jmattson@google.com \
    --cc=joro@8bytes.org \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=seanjc@google.com \
    --cc=vkuznets@redhat.com \
    --cc=wanpengli@tencent.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).