Message ID | 20180918031754.113013-5-Tianyu.Lan@microsoft.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | x86/KVM/Hyper-v: Add HV ept tlb range flush hypercall support in KVM | expand |
From: Tianyu Lan Sent: Monday, September 17, 2018 8:19 PM > + > + if (ret && kvm_available_flush_tlb_with_range()) { > + kvm_flush_remote_tlbs_with_address(kvm, > + gfn_start, > + gfn_end - gfn_start); Does the above need to be gfn_end - gfn_start + 1? > + ret = 0; > + } Michael
On 9/20/2018 12:08 AM, Michael Kelley (EOSG) wrote: > From: Tianyu Lan Sent: Monday, September 17, 2018 8:19 PM >> + >> + if (ret && kvm_available_flush_tlb_with_range()) { >> + kvm_flush_remote_tlbs_with_address(kvm, >> + gfn_start, >> + gfn_end - gfn_start); > > Does the above need to be gfn_end - gfn_start + 1? The flush range depends on the input parameter frame start and frame end of for_each_slot_rmap_range(). for_each_slot_rmap_range(memslot, PT_PAGE_TABLE_LEVEL, PT_MAX_HUGEPAGE_LEVEL, gfn_start, gfn_end - 1, &iterator) ret |= handler(kvm, iterator.rmap, memslot, iterator.gfn, iterator.level, data); The start is "gfn_start" and the end is "gfn_end - 1". The flush size is (gfn_end - 1) - gfn_start + 1 = gfn_end - gfn_start. > >> + ret = 0; >> + } > > Michael >
From: Tianyu Lan Sent: Thursday, September 20, 2018 7:30 AM > On 9/20/2018 12:08 AM, Michael Kelley (EOSG) wrote: > > From: Tianyu Lan Sent: Monday, September 17, 2018 8:19 PM > >> + > >> + if (ret && kvm_available_flush_tlb_with_range()) { > >> + kvm_flush_remote_tlbs_with_address(kvm, > >> + gfn_start, > >> + gfn_end - gfn_start); > > > > Does the above need to be gfn_end - gfn_start + 1? > > The flush range depends on the input parameter frame start and frame end > of for_each_slot_rmap_range(). > > for_each_slot_rmap_range(memslot, PT_PAGE_TABLE_LEVEL, > PT_MAX_HUGEPAGE_LEVEL, > gfn_start, gfn_end - 1, > &iterator) > ret |= handler(kvm, iterator.rmap, memslot, > iterator.gfn, iterator.level, data); > > > The start is "gfn_start" and the end is "gfn_end - 1". The flush size is > (gfn_end - 1) - gfn_start + 1 = gfn_end - gfn_start. > Got it. I agree. Michael
diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c index 822e170881a4..dfd2a0710417 100644 --- a/arch/x86/kvm/mmu.c +++ b/arch/x86/kvm/mmu.c @@ -1888,6 +1888,13 @@ static int kvm_handle_hva_range(struct kvm *kvm, &iterator) ret |= handler(kvm, iterator.rmap, memslot, iterator.gfn, iterator.level, data); + + if (ret && kvm_available_flush_tlb_with_range()) { + kvm_flush_remote_tlbs_with_address(kvm, + gfn_start, + gfn_end - gfn_start); + ret = 0; + } } }
This patch is to flush tlb directly in the kvm_handle_hva_range() when range flush is available. Signed-off-by: Lan Tianyu <Tianyu.Lan@microsoft.com> --- arch/x86/kvm/mmu.c | 7 +++++++ 1 file changed, 7 insertions(+)