From: Tianyu Lan <Tianyu.Lan@microsoft.com>
To: Paolo Bonzini <pbonzini@redhat.com>,
Tianyu Lan <Tianyu.Lan@microsoft.com>
Cc: KY Srinivasan <kys@microsoft.com>,
Haiyang Zhang <haiyangz@microsoft.com>,
Stephen Hemminger <sthemmin@microsoft.com>,
"tglx@linutronix.de" <tglx@linutronix.de>,
"mingo@redhat.com" <mingo@redhat.com>,
"hpa@zytor.com" <hpa@zytor.com>,
"x86@kernel.org" <x86@kernel.org>,
"rkrcmar@redhat.com" <rkrcmar@redhat.com>,
"devel@linuxdriverproject.org" <devel@linuxdriverproject.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"kvm@vger.kernel.org" <kvm@vger.kernel.org>,
"Michael Kelley (EOSG)" <Michael.H.Kelley@microsoft.com>,
"vkuznets@redhat.com" <vkuznets@redhat.com>
Subject: Re: [PATCH V2 2/5] KVM: Add tlb remote flush callback in kvm_x86_ops.
Date: Wed, 18 Jul 2018 13:25:44 +0000 [thread overview]
Message-ID: <fcce0753-a51a-aa47-d0df-053f0a355410@microsoft.com> (raw)
In-Reply-To: <3b2a6c3c-ba73-1c34-248f-f5d40c691b58@redhat.com>
Hi Paolo:
Thanks for review.
On 7/18/2018 8:01 PM, Paolo Bonzini wrote:
> On 09/07/2018 11:02, Tianyu Lan wrote:
>> + /*
>> + * Call kvm_arch_hv_tlb_remote first and go back old way when
>> + * return failure.
>> + */
>> + if (!kvm_arch_hv_flush_remote_tlb(kvm))
>> + return;
>> +
>> /*
>> * Read tlbs_dirty before setting KVM_REQ_TLB_FLUSH in
>> * kvm_make_all_cpus_request.
>> */
>> - long dirty_count = smp_load_acquire(&kvm->tlbs_dirty);
>> + dirty_count = smp_load_acquire(&kvm->tlbs_dirty);
>
> Also, the call to kvm_arch_flush_remote_tlbs should not replace the
> whole function. It should be something like:
>
> long dirty_count = smp_load_acquire(&kvm->tlbs_dirty);
>
> /*
> * We want to publish modifications to the page tables before reading
> * mode. Pairs with a memory barrier in arch-specific code.
> * - x86: smp_mb__after_srcu_read_unlock in vcpu_enter_guest
> * and smp_mb in walk_shadow_page_lockless_begin/end.
> * - powerpc: smp_mb in kvmppc_prepare_to_enter.
> *
> * There is already an smp_mb__after_atomic() before
> * kvm_make_all_cpus_request() reads vcpu->mode. We reuse that
> * barrier here.
> */
> if (!kvm_arch_hv_flush_remote_tlb(kvm) ||
> kvm_make_all_cpus_request(kvm, KVM_REQ_TLB_FLUSH))
> ++kvm->stat.remote_tlb_flush;
> cmpxchg(&kvm->tlbs_dirty, dirty_count, 0);
>
> Otherwise, kvm_mmu_notifier_invalidate_range_start will incorrectly skip
> a TLB flush.
Nice catch. Will update in the next version.
>
> Thanks,
>
> Paolo
>
next prev parent reply other threads:[~2018-07-18 13:26 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-09 9:02 [PATCH V2 0/5] KVM/x86/hyper-V: Introduce PV guest address space mapping flush support Tianyu Lan
2018-07-09 9:02 ` [PATCH V2 1/5] X86/Hyper-V: Add flush HvFlushGuestPhysicalAddressSpace hypercall support Tianyu Lan
2018-07-10 21:29 ` Michael Kelley (EOSG)
2018-07-11 6:01 ` Tianyu Lan
2018-07-09 9:02 ` [PATCH V2 2/5] KVM: Add tlb remote flush callback in kvm_x86_ops Tianyu Lan
2018-07-18 11:57 ` Paolo Bonzini
2018-07-18 12:01 ` Paolo Bonzini
2018-07-18 13:25 ` Tianyu Lan [this message]
2018-07-09 9:02 ` [PATCH V2 3/5] KVM/VMX: Add identical ept table pointer check Tianyu Lan
2018-07-18 11:59 ` Paolo Bonzini
2018-07-18 13:38 ` Tianyu Lan
2018-07-09 9:02 ` [PATCH V2 4/5] KVM/x86: Add tlb_remote_flush callback support for vmx Tianyu Lan
2018-07-09 9:02 ` [PATCH V2 5/5] X86/Hyper-V: Add hyperv_nested_flush_guest_mapping ftrace support Tianyu Lan
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=fcce0753-a51a-aa47-d0df-053f0a355410@microsoft.com \
--to=tianyu.lan@microsoft.com \
--cc=Michael.H.Kelley@microsoft.com \
--cc=devel@linuxdriverproject.org \
--cc=haiyangz@microsoft.com \
--cc=hpa@zytor.com \
--cc=kvm@vger.kernel.org \
--cc=kys@microsoft.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=pbonzini@redhat.com \
--cc=rkrcmar@redhat.com \
--cc=sthemmin@microsoft.com \
--cc=tglx@linutronix.de \
--cc=vkuznets@redhat.com \
--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;
as well as URLs for NNTP newsgroup(s).