From: Paolo Bonzini <pbonzini@redhat.com>
To: Wanpeng Li <kernellwp@gmail.com>,
linux-kernel@vger.kernel.org, kvm@vger.kernel.org
Cc: "Radim Krčmář" <rkrcmar@redhat.com>,
"Wanpeng Li" <wanpeng.li@hotmail.com>
Subject: Re: [PATCH] KVM: X86: Fix preempt the preemption timer cancel
Date: Fri, 26 May 2017 17:45:30 +0200 [thread overview]
Message-ID: <9c21e92e-0754-7eda-76bc-2418abe8cd5b@redhat.com> (raw)
In-Reply-To: <1495337552-78885-1-git-send-email-wanpeng.li@hotmail.com>
On 21/05/2017 05:32, Wanpeng Li wrote:
> vmx_cancel_hv_timer
> vCPU0's vmx->hv_deadline_tsc = -1
>
> preempt occur
>
> clear preemption timer field in CPU1's active vmcs
> vCPU0's apic_timer.hv_timer_in_use = false
> vmx_vcpu_run(vCPU0)
> vmx_arm_hv_timer
> if (vmx->hv_deadline_tsc == -1)
> nothing change
>
> handle_preemption_timer(vCPU0)
> kvm_lapic_expired_hv_timer
> WARN_ON(!apic->lapic_timer.hv_timer_in_use);
>
> Preemption can occur during cancel preemption timer, and there will be inconsistent
> status in lapic, vmx and vmcs field. This patch fixes it by disable preemption for
> cancelling preemption timer.
I see, so the purpose is to serialize against kvm_arch_vcpu_load. Nice
catch, I've queued the patch for kvm/master.
Paolo
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Cc: Radim Krčmář <rkrcmar@redhat.com>
> Signed-off-by: Wanpeng Li <wanpeng.li@hotmail.com>
> ---
> arch/x86/kvm/lapic.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
> index c329d28..6e6f345 100644
> --- a/arch/x86/kvm/lapic.c
> +++ b/arch/x86/kvm/lapic.c
> @@ -1495,8 +1495,10 @@ EXPORT_SYMBOL_GPL(kvm_lapic_hv_timer_in_use);
>
> static void cancel_hv_timer(struct kvm_lapic *apic)
> {
> + preempt_disable();
> kvm_x86_ops->cancel_hv_timer(apic->vcpu);
> apic->lapic_timer.hv_timer_in_use = false;
> + preempt_enable();
> }
>
> static bool start_hv_timer(struct kvm_lapic *apic)
> --
next prev parent reply other threads:[~2017-05-26 15:45 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-21 3:32 Wanpeng Li
2017-05-26 15:45 ` Paolo Bonzini [this message]
2017-05-26 15:57 ` Paolo Bonzini
2017-05-26 22:07 ` Wanpeng Li
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=9c21e92e-0754-7eda-76bc-2418abe8cd5b@redhat.com \
--to=pbonzini@redhat.com \
--cc=kernellwp@gmail.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rkrcmar@redhat.com \
--cc=wanpeng.li@hotmail.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
all inboxes | Powered by JetHome®