Re: [PATCH V4 7/15] KVM/MMU: Flush tlb directly in the kvm_zap_gfn_range()

2018-10-15 Thread Tianyu Lan
} > > } > > > > + if (flush && kvm_available_flush_tlb_with_range()) > > + kvm_flush_remote_tlbs_with_address(kvm, gfn_start, > > + gfn_end - gfn_start + 1); > > + > > ... and this can be just if (flush), because if flush_tlb is true then > slot_handle_level_range always returns false. OK. Will update. -- Best regards Tianyu Lan

Re: [PATCH V4 7/15] KVM/MMU: Flush tlb directly in the kvm_zap_gfn_range()

2018-10-15 Thread Tianyu Lan
} > > } > > > > + if (flush && kvm_available_flush_tlb_with_range()) > > + kvm_flush_remote_tlbs_with_address(kvm, gfn_start, > > + gfn_end - gfn_start + 1); > > + > > ... and this can be just if (flush), because if flush_tlb is true then > slot_handle_level_range always returns false. OK. Will update. -- Best regards Tianyu Lan

Re: [PATCH] KVM: vmx: hyper-v: don't pass EPT configuration info to vmx_hv_remote_flush_tlb()

2018-10-11 Thread Tianyu Lan
On Thu, Oct 11, 2018 at 9:00 PM Vitaly Kuznetsov wrote: > > Tianyu Lan writes: > > > On Thu, Oct 11, 2018 at 8:18 PM Vitaly Kuznetsov > > wrote: > >> > >> Tianyu Lan writes: > >> > >> > On Thu, Oct 11, 2018 at 6:32 PM Vitaly Ku

Re: [PATCH] KVM: vmx: hyper-v: don't pass EPT configuration info to vmx_hv_remote_flush_tlb()

2018-10-11 Thread Tianyu Lan
On Thu, Oct 11, 2018 at 9:00 PM Vitaly Kuznetsov wrote: > > Tianyu Lan writes: > > > On Thu, Oct 11, 2018 at 8:18 PM Vitaly Kuznetsov > > wrote: > >> > >> Tianyu Lan writes: > >> > >> > On Thu, Oct 11, 2018 at 6:32 PM Vitaly Ku

Re: [PATCH] KVM: vmx: hyper-v: don't pass EPT configuration info to vmx_hv_remote_flush_tlb()

2018-10-11 Thread Tianyu Lan
On Thu, Oct 11, 2018 at 8:18 PM Vitaly Kuznetsov wrote: > > Tianyu Lan writes: > > > On Thu, Oct 11, 2018 at 6:32 PM Vitaly Kuznetsov > > wrote: > >> > >> I'm observing random crashes in multi-vCPU L2 guests running on KVM on > >> Hyper-V. I bis

Re: [PATCH] KVM: vmx: hyper-v: don't pass EPT configuration info to vmx_hv_remote_flush_tlb()

2018-10-11 Thread Tianyu Lan
On Thu, Oct 11, 2018 at 8:18 PM Vitaly Kuznetsov wrote: > > Tianyu Lan writes: > > > On Thu, Oct 11, 2018 at 6:32 PM Vitaly Kuznetsov > > wrote: > >> > >> I'm observing random crashes in multi-vCPU L2 guests running on KVM on > >> Hyper-V. I bis

Re: [PATCH] KVM: vmx: hyper-v: don't pass EPT configuration info to vmx_hv_remote_flush_tlb()

2018-10-11 Thread Tianyu Lan
s the address of > the > +* base of EPT PML4 table, strip off EPT configuration information. > +*/ > ret = hyperv_flush_guest_mapping( > - to_vmx(kvm_get_vcpu(kvm, 0))->ept_pointer); > + to_vmx(kvm_get_vcpu(kvm, 0))->ept_pointer & > PAGE_MASK); > > out: > spin_unlock(_kvm_vmx(kvm)->ept_pointer_lock); > -- > 2.17.1 > -- Best regards Tianyu Lan

Re: [PATCH] KVM: vmx: hyper-v: don't pass EPT configuration info to vmx_hv_remote_flush_tlb()

2018-10-11 Thread Tianyu Lan
s the address of > the > +* base of EPT PML4 table, strip off EPT configuration information. > +*/ > ret = hyperv_flush_guest_mapping( > - to_vmx(kvm_get_vcpu(kvm, 0))->ept_pointer); > + to_vmx(kvm_get_vcpu(kvm, 0))->ept_pointer & > PAGE_MASK); > > out: > spin_unlock(_kvm_vmx(kvm)->ept_pointer_lock); > -- > 2.17.1 > -- Best regards Tianyu Lan

Re: [PATCH V3 2/13] KVM/MMU: Add tlb flush with range helper function

2018-10-08 Thread Tianyu Lan
Hi Paolo: Thanks for your review. Sorry for later response due to holiday. On Mon, Oct 1, 2018 at 11:26 PM Paolo Bonzini wrote: > > On 27/09/2018 05:48, Tianyu Lan wrote: > > + > > + if (range && kvm_x86_ops-&g

Re: [PATCH V3 2/13] KVM/MMU: Add tlb flush with range helper function

2018-10-08 Thread Tianyu Lan
Hi Paolo: Thanks for your review. Sorry for later response due to holiday. On Mon, Oct 1, 2018 at 11:26 PM Paolo Bonzini wrote: > > On 27/09/2018 05:48, Tianyu Lan wrote: > > + > > + if (range && kvm_x86_ops-&g

[PATCH] KVM/VMX: Remve unused function is_external_interrupt().

2018-09-28 Thread Tianyu Lan
is_external_interrupt() is not used now and so remove it. Signed-off-by: Lan Tianyu --- arch/x86/kvm/vmx.c | 6 -- 1 file changed, 6 deletions(-) diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index 70e1f916bfc9..619307b3e6bb 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c

[PATCH] KVM/VMX: Remve unused function is_external_interrupt().

2018-09-28 Thread Tianyu Lan
is_external_interrupt() is not used now and so remove it. Signed-off-by: Lan Tianyu --- arch/x86/kvm/vmx.c | 6 -- 1 file changed, 6 deletions(-) diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index 70e1f916bfc9..619307b3e6bb 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c

Re: [PATCH V3 10/13] x86/hyper-v: Add HvFlushGuestAddressList hypercall support

2018-09-26 Thread Tianyu Lan
On 9/27/2018 12:16 PM, Michael Kelley (EOSG) wrote: > From: Tianyu Lan Sent: Wednesday, September 26, 2018 8:50 PM >> >> Hyper-V provides HvFlushGuestAddressList() hypercall to flush EPT tlb >> with specified ranges. This patch is to add the hypercall support. >> &

Re: [PATCH V3 10/13] x86/hyper-v: Add HvFlushGuestAddressList hypercall support

2018-09-26 Thread Tianyu Lan
On 9/27/2018 12:16 PM, Michael Kelley (EOSG) wrote: > From: Tianyu Lan Sent: Wednesday, September 26, 2018 8:50 PM >> >> Hyper-V provides HvFlushGuestAddressList() hypercall to flush EPT tlb >> with specified ranges. This patch is to add the hypercall support. >> &

[PATCH V3 2/13] KVM/MMU: Add tlb flush with range helper function

2018-09-26 Thread Tianyu Lan
This patch is to add wrapper functions for tlb_remote_flush_with_range callback. Signed-off-by: Lan Tianyu --- Change since V2: Fix comment in the kvm_flush_remote_tlbs_with_range() --- arch/x86/kvm/mmu.c | 48 1 file changed, 48

[PATCH V3 2/13] KVM/MMU: Add tlb flush with range helper function

2018-09-26 Thread Tianyu Lan
This patch is to add wrapper functions for tlb_remote_flush_with_range callback. Signed-off-by: Lan Tianyu --- Change since V2: Fix comment in the kvm_flush_remote_tlbs_with_range() --- arch/x86/kvm/mmu.c | 48 1 file changed, 48

[PATCH V3 4/13] KVM/MMU: Flush tlb directly in the kvm_handle_hva_range()

2018-09-26 Thread Tianyu Lan
This patch is to flush tlb directly in the kvm_handle_hva_range() when range flush is available. Signed-off-by: Lan Tianyu --- arch/x86/kvm/mmu.c | 7 +++ 1 file changed, 7 insertions(+) diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c index d10d8423e8d6..877edae0401f 100644 ---

[PATCH V3 4/13] KVM/MMU: Flush tlb directly in the kvm_handle_hva_range()

2018-09-26 Thread Tianyu Lan
This patch is to flush tlb directly in the kvm_handle_hva_range() when range flush is available. Signed-off-by: Lan Tianyu --- arch/x86/kvm/mmu.c | 7 +++ 1 file changed, 7 insertions(+) diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c index d10d8423e8d6..877edae0401f 100644 ---

[PATCH V3 7/13] KVM: Add flush_link and parent_pte in the struct kvm_mmu_page

2018-09-26 Thread Tianyu Lan
PV EPT tlb flush function will accept a list of flush ranges and use struct kvm_mmu_page as the list entry. Signed-off-by: Lan Tianyu --- arch/x86/include/asm/kvm_host.h | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h index

[PATCH V3 7/13] KVM: Add flush_link and parent_pte in the struct kvm_mmu_page

2018-09-26 Thread Tianyu Lan
PV EPT tlb flush function will accept a list of flush ranges and use struct kvm_mmu_page as the list entry. Signed-off-by: Lan Tianyu --- arch/x86/include/asm/kvm_host.h | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h index

[PATCH V3 13/13] KVM/VMX: Add hv tlb range flush support

2018-09-26 Thread Tianyu Lan
This patch is to register tlb_remote_flush_with_range callback with hv tlb range flush interface. Signed-off-by: Lan Tianyu --- Change since v1: Pass flush range with new hyper-v tlb flush struct rather than KVM tlb flush struct. --- arch/x86/kvm/vmx.c | 58

[PATCH V3 8/13] KVM: Add spte's point in the struct kvm_mmu_page

2018-09-26 Thread Tianyu Lan
It's necessary to check whether mmu page is last or large page when add mmu page into flush list. "spte" is needed for such check and so add spte point in the struct kvm_mmu_page. Signed-off-by: Lan Tianyu --- arch/x86/include/asm/kvm_host.h | 1 + arch/x86/kvm/mmu.c | 5 +

[PATCH V3 13/13] KVM/VMX: Add hv tlb range flush support

2018-09-26 Thread Tianyu Lan
This patch is to register tlb_remote_flush_with_range callback with hv tlb range flush interface. Signed-off-by: Lan Tianyu --- Change since v1: Pass flush range with new hyper-v tlb flush struct rather than KVM tlb flush struct. --- arch/x86/kvm/vmx.c | 58

[PATCH V3 8/13] KVM: Add spte's point in the struct kvm_mmu_page

2018-09-26 Thread Tianyu Lan
It's necessary to check whether mmu page is last or large page when add mmu page into flush list. "spte" is needed for such check and so add spte point in the struct kvm_mmu_page. Signed-off-by: Lan Tianyu --- arch/x86/include/asm/kvm_host.h | 1 + arch/x86/kvm/mmu.c | 5 +

[PATCH V3 9/13] KVM/MMU: Replace tlb flush function with range list flush function

2018-09-26 Thread Tianyu Lan
This patch is to use range list flush function in the mmu_sync_children(), kvm_mmu_commit_zap_page() and FNAME(sync_page)(). Signed-off-by: Lan Tianyu --- arch/x86/kvm/mmu.c | 26 +++--- arch/x86/kvm/paging_tmpl.h | 5 - 2 files changed, 27 insertions(+), 4

[PATCH V3 11/13] x86/Hyper-v: Add trace in the hyperv_nested_flush_guest_mapping_range()

2018-09-26 Thread Tianyu Lan
This patch is to trace log in the hyperv_nested_flush_ guest_mapping_range(). Signed-off-by: Lan Tianyu --- arch/x86/hyperv/nested.c| 1 + arch/x86/include/asm/trace/hyperv.h | 14 ++ 2 files changed, 15 insertions(+) diff --git a/arch/x86/hyperv/nested.c

[PATCH V3 11/13] x86/Hyper-v: Add trace in the hyperv_nested_flush_guest_mapping_range()

2018-09-26 Thread Tianyu Lan
This patch is to trace log in the hyperv_nested_flush_ guest_mapping_range(). Signed-off-by: Lan Tianyu --- arch/x86/hyperv/nested.c| 1 + arch/x86/include/asm/trace/hyperv.h | 14 ++ 2 files changed, 15 insertions(+) diff --git a/arch/x86/hyperv/nested.c

[PATCH V3 9/13] KVM/MMU: Replace tlb flush function with range list flush function

2018-09-26 Thread Tianyu Lan
This patch is to use range list flush function in the mmu_sync_children(), kvm_mmu_commit_zap_page() and FNAME(sync_page)(). Signed-off-by: Lan Tianyu --- arch/x86/kvm/mmu.c | 26 +++--- arch/x86/kvm/paging_tmpl.h | 5 - 2 files changed, 27 insertions(+), 4

[PATCH V3 12/13] KVM/VMX: Change hv flush logic when ept tables are mismatched.

2018-09-26 Thread Tianyu Lan
If ept table pointers are mismatched, flushing tlb for each vcpus via hv flush interface still helps to reduce vmexits which are triggered by IPI and INEPT emulation. Signed-off-by: Lan Tianyu --- arch/x86/kvm/vmx.c | 15 --- 1 file changed, 8 insertions(+), 7 deletions(-) diff

[PATCH V3 12/13] KVM/VMX: Change hv flush logic when ept tables are mismatched.

2018-09-26 Thread Tianyu Lan
If ept table pointers are mismatched, flushing tlb for each vcpus via hv flush interface still helps to reduce vmexits which are triggered by IPI and INEPT emulation. Signed-off-by: Lan Tianyu --- arch/x86/kvm/vmx.c | 15 --- 1 file changed, 8 insertions(+), 7 deletions(-) diff

[PATCH V3 10/13] x86/hyper-v: Add HvFlushGuestAddressList hypercall support

2018-09-26 Thread Tianyu Lan
Hyper-V provides HvFlushGuestAddressList() hypercall to flush EPT tlb with specified ranges. This patch is to add the hypercall support. Signed-off-by: Lan Tianyu --- Change since v2: Fix some coding style issues - Move HV_MAX_FLUSH_PAGES and HV_MAX_FLUSH_REP_COUNT to

[PATCH V3 3/13] KVM: Replace old tlb flush function with new one to flush a specified range.

2018-09-26 Thread Tianyu Lan
This patch is to replace kvm_flush_remote_tlbs() with kvm_flush_ remote_tlbs_with_address() in some functions without logic change. Signed-off-by: Lan Tianyu --- arch/x86/kvm/mmu.c | 33 ++--- arch/x86/kvm/paging_tmpl.h | 3 ++- 2 files changed, 24

[PATCH V3 10/13] x86/hyper-v: Add HvFlushGuestAddressList hypercall support

2018-09-26 Thread Tianyu Lan
Hyper-V provides HvFlushGuestAddressList() hypercall to flush EPT tlb with specified ranges. This patch is to add the hypercall support. Signed-off-by: Lan Tianyu --- Change since v2: Fix some coding style issues - Move HV_MAX_FLUSH_PAGES and HV_MAX_FLUSH_REP_COUNT to

[PATCH V3 3/13] KVM: Replace old tlb flush function with new one to flush a specified range.

2018-09-26 Thread Tianyu Lan
This patch is to replace kvm_flush_remote_tlbs() with kvm_flush_ remote_tlbs_with_address() in some functions without logic change. Signed-off-by: Lan Tianyu --- arch/x86/kvm/mmu.c | 33 ++--- arch/x86/kvm/paging_tmpl.h | 3 ++- 2 files changed, 24

[PATCH V3 1/13] KVM: Add tlb_remote_flush_with_range callback in kvm_x86_ops

2018-09-26 Thread Tianyu Lan
Add flush range call back in the kvm_x86_ops and platform can use it to register its associated function. The parameter "kvm_tlb_range" accepts a single range and flush list which contains a list of ranges. Signed-off-by: Lan Tianyu --- Change since v1: Change "end_gfn" to "pages" to

[PATCH V3 1/13] KVM: Add tlb_remote_flush_with_range callback in kvm_x86_ops

2018-09-26 Thread Tianyu Lan
Add flush range call back in the kvm_x86_ops and platform can use it to register its associated function. The parameter "kvm_tlb_range" accepts a single range and flush list which contains a list of ranges. Signed-off-by: Lan Tianyu --- Change since v1: Change "end_gfn" to "pages" to

[PATCH V3 5/13] KVM/MMU: Flush tlb directly in the kvm_zap_gfn_range()

2018-09-26 Thread Tianyu Lan
Originally, flush tlb is done by slot_handle_level_range(). This patch is to flush tlb directly in the kvm_zap_gfn_range() when range flush is available. Signed-off-by: Lan Tianyu --- arch/x86/kvm/mmu.c | 16 +--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git

[PATCH V3 00/13] x86/KVM/Hyper-v: Add HV ept tlb range flush hypercall support in KVM

2018-09-26 Thread Tianyu Lan
For nested memory virtualization, Hyper-v doesn't set write-protect L1 hypervisor EPT page directory and page table node to track changes while it relies on guest to tell it changes via HvFlushGuestAddressLlist hypercall. HvFlushGuestAddressLlist hypercall provides a way to flush EPT page table

[PATCH V3 6/13] KVM/MMU: Flush tlb directly in kvm_mmu_zap_collapsible_spte()

2018-09-26 Thread Tianyu Lan
kvm_mmu_zap_collapsible_spte() returns flush request to the slot_handle_leaf() and the latter does flush on demand. When range flush is available, make kvm_mmu_zap_collapsible_spte() to flush tlb with range directly to avoid returning range back to slot_handle_leaf(). Signed-off-by: Lan Tianyu

[PATCH V3 5/13] KVM/MMU: Flush tlb directly in the kvm_zap_gfn_range()

2018-09-26 Thread Tianyu Lan
Originally, flush tlb is done by slot_handle_level_range(). This patch is to flush tlb directly in the kvm_zap_gfn_range() when range flush is available. Signed-off-by: Lan Tianyu --- arch/x86/kvm/mmu.c | 16 +--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git

[PATCH V3 00/13] x86/KVM/Hyper-v: Add HV ept tlb range flush hypercall support in KVM

2018-09-26 Thread Tianyu Lan
For nested memory virtualization, Hyper-v doesn't set write-protect L1 hypervisor EPT page directory and page table node to track changes while it relies on guest to tell it changes via HvFlushGuestAddressLlist hypercall. HvFlushGuestAddressLlist hypercall provides a way to flush EPT page table

[PATCH V3 6/13] KVM/MMU: Flush tlb directly in kvm_mmu_zap_collapsible_spte()

2018-09-26 Thread Tianyu Lan
kvm_mmu_zap_collapsible_spte() returns flush request to the slot_handle_leaf() and the latter does flush on demand. When range flush is available, make kvm_mmu_zap_collapsible_spte() to flush tlb with range directly to avoid returning range back to slot_handle_leaf(). Signed-off-by: Lan Tianyu

Re: [PATCH V2 4/13] KVM/MMU: Flush tlb directly in the kvm_handle_hva_range()

2018-09-20 Thread Tianyu Lan
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

Re: [PATCH V2 4/13] KVM/MMU: Flush tlb directly in the kvm_handle_hva_range()

2018-09-20 Thread Tianyu Lan
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

[PATCH V2 7/13] KVM: Add flush_link and parent_pte in the struct kvm_mmu_page

2018-09-17 Thread Tianyu Lan
PV EPT tlb flush function will accept a list of flush ranges and use struct kvm_mmu_page as the list entry. Signed-off-by: Lan Tianyu --- arch/x86/include/asm/kvm_host.h | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h index

[PATCH V2 9/13] KVM/MMU: Replace tlb flush function with range list flush function

2018-09-17 Thread Tianyu Lan
This patch is to use range list flush function in the mmu_sync_children(), kvm_mmu_commit_zap_page() and FNAME(sync_page)(). Signed-off-by: Lan Tianyu --- arch/x86/kvm/mmu.c | 26 +++--- arch/x86/kvm/paging_tmpl.h | 5 - 2 files changed, 27 insertions(+), 4

[PATCH V2 9/13] KVM/MMU: Replace tlb flush function with range list flush function

2018-09-17 Thread Tianyu Lan
This patch is to use range list flush function in the mmu_sync_children(), kvm_mmu_commit_zap_page() and FNAME(sync_page)(). Signed-off-by: Lan Tianyu --- arch/x86/kvm/mmu.c | 26 +++--- arch/x86/kvm/paging_tmpl.h | 5 - 2 files changed, 27 insertions(+), 4

[PATCH V2 7/13] KVM: Add flush_link and parent_pte in the struct kvm_mmu_page

2018-09-17 Thread Tianyu Lan
PV EPT tlb flush function will accept a list of flush ranges and use struct kvm_mmu_page as the list entry. Signed-off-by: Lan Tianyu --- arch/x86/include/asm/kvm_host.h | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h index

[PATCH V2 12/13] KVM/VMX: Change hv flush logic when ept tables are mismatched.

2018-09-17 Thread Tianyu Lan
If ept table pointers are mismatched, flushing tlb for each vcpus via hv flush interface still helps to reduce vmexits which are triggered by IPI and INEPT emulation. Signed-off-by: Lan Tianyu --- arch/x86/kvm/vmx.c | 15 --- 1 file changed, 8 insertions(+), 7 deletions(-) diff

[PATCH V2 8/13] KVM: Add spte's point in the struct kvm_mmu_page

2018-09-17 Thread Tianyu Lan
It's necessary to check whether mmu page is last or large page when add mmu page into flush list. "spte" is needed for such check and so add spte point in the struct kvm_mmu_page. Signed-off-by: Lan Tianyu --- arch/x86/include/asm/kvm_host.h | 1 + arch/x86/kvm/mmu.c | 5 +

[PATCH V2 13/13] KVM/VMX: Add hv tlb range flush support

2018-09-17 Thread Tianyu Lan
This patch is to register tlb_remote_flush_with_range callback with hv tlb range flush interface. Signed-off-by: Lan Tianyu --- Change since v1: Pass flush range with new hyper-v tlb flush struct rather than KVM tlb flush struct. --- arch/x86/kvm/vmx.c | 58

[PATCH V2 12/13] KVM/VMX: Change hv flush logic when ept tables are mismatched.

2018-09-17 Thread Tianyu Lan
If ept table pointers are mismatched, flushing tlb for each vcpus via hv flush interface still helps to reduce vmexits which are triggered by IPI and INEPT emulation. Signed-off-by: Lan Tianyu --- arch/x86/kvm/vmx.c | 15 --- 1 file changed, 8 insertions(+), 7 deletions(-) diff

[PATCH V2 8/13] KVM: Add spte's point in the struct kvm_mmu_page

2018-09-17 Thread Tianyu Lan
It's necessary to check whether mmu page is last or large page when add mmu page into flush list. "spte" is needed for such check and so add spte point in the struct kvm_mmu_page. Signed-off-by: Lan Tianyu --- arch/x86/include/asm/kvm_host.h | 1 + arch/x86/kvm/mmu.c | 5 +

[PATCH V2 13/13] KVM/VMX: Add hv tlb range flush support

2018-09-17 Thread Tianyu Lan
This patch is to register tlb_remote_flush_with_range callback with hv tlb range flush interface. Signed-off-by: Lan Tianyu --- Change since v1: Pass flush range with new hyper-v tlb flush struct rather than KVM tlb flush struct. --- arch/x86/kvm/vmx.c | 58

[PATCH V2 11/13] x86/Hyper-v: Add trace in the hyperv_nested_flush_guest_mapping_range()

2018-09-17 Thread Tianyu Lan
This patch is to trace log in the hyperv_nested_flush_ guest_mapping_range(). Signed-off-by: Lan Tianyu --- arch/x86/hyperv/nested.c| 1 + arch/x86/include/asm/trace/hyperv.h | 14 ++ 2 files changed, 15 insertions(+) diff --git a/arch/x86/hyperv/nested.c

[PATCH V2 11/13] x86/Hyper-v: Add trace in the hyperv_nested_flush_guest_mapping_range()

2018-09-17 Thread Tianyu Lan
This patch is to trace log in the hyperv_nested_flush_ guest_mapping_range(). Signed-off-by: Lan Tianyu --- arch/x86/hyperv/nested.c| 1 + arch/x86/include/asm/trace/hyperv.h | 14 ++ 2 files changed, 15 insertions(+) diff --git a/arch/x86/hyperv/nested.c

[PATCH V2 4/13] KVM/MMU: Flush tlb directly in the kvm_handle_hva_range()

2018-09-17 Thread Tianyu Lan
This patch is to flush tlb directly in the kvm_handle_hva_range() when range flush is available. Signed-off-by: Lan Tianyu --- arch/x86/kvm/mmu.c | 7 +++ 1 file changed, 7 insertions(+) diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c index 822e170881a4..dfd2a0710417 100644 ---

[PATCH V2 10/13] x86/hyper-v: Add HvFlushGuestAddressList hypercall support

2018-09-17 Thread Tianyu Lan
Hyper-V provides HvFlushGuestAddressList() hypercall to flush EPT tlb with specified ranges. This patch is to add the hypercall support. Signed-off-by: Lan Tianyu --- Change since v1: Add hyperv tlb flush struct to avoid use kvm tlb flush struct in the hyperv file. ---

[PATCH V2 4/13] KVM/MMU: Flush tlb directly in the kvm_handle_hva_range()

2018-09-17 Thread Tianyu Lan
This patch is to flush tlb directly in the kvm_handle_hva_range() when range flush is available. Signed-off-by: Lan Tianyu --- arch/x86/kvm/mmu.c | 7 +++ 1 file changed, 7 insertions(+) diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c index 822e170881a4..dfd2a0710417 100644 ---

[PATCH V2 10/13] x86/hyper-v: Add HvFlushGuestAddressList hypercall support

2018-09-17 Thread Tianyu Lan
Hyper-V provides HvFlushGuestAddressList() hypercall to flush EPT tlb with specified ranges. This patch is to add the hypercall support. Signed-off-by: Lan Tianyu --- Change since v1: Add hyperv tlb flush struct to avoid use kvm tlb flush struct in the hyperv file. ---

[PATCH V2 6/13] KVM/MMU: Flush tlb directly in kvm_mmu_zap_collapsible_spte()

2018-09-17 Thread Tianyu Lan
kvm_mmu_zap_collapsible_spte() returns flush request to the slot_handle_leaf() and the latter does flush on demand. When range flush is available, make kvm_mmu_zap_collapsible_spte() to flush tlb with range directly to avoid returning range back to slot_handle_leaf(). Signed-off-by: Lan Tianyu

[PATCH V2 6/13] KVM/MMU: Flush tlb directly in kvm_mmu_zap_collapsible_spte()

2018-09-17 Thread Tianyu Lan
kvm_mmu_zap_collapsible_spte() returns flush request to the slot_handle_leaf() and the latter does flush on demand. When range flush is available, make kvm_mmu_zap_collapsible_spte() to flush tlb with range directly to avoid returning range back to slot_handle_leaf(). Signed-off-by: Lan Tianyu

[PATCH V2 1/13] KVM: Add tlb_remote_flush_with_range callback in kvm_x86_ops

2018-09-17 Thread Tianyu Lan
Add flush range call back in the kvm_x86_ops and platform can use it to register its associated function. The parameter "kvm_tlb_range" accepts a single range and flush list which contains a list of ranges. Signed-off-by: Lan Tianyu --- Change since v1: Change "end_gfn" to "pages" to

[PATCH V2 2/13] KVM/MMU: Add tlb flush with range helper function

2018-09-17 Thread Tianyu Lan
This patch is to add wrapper functions for tlb_remote_flush_with_range callback. Signed-off-by: Lan Tianyu --- arch/x86/kvm/mmu.c | 48 1 file changed, 48 insertions(+) diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c index

[PATCH V2 5/13] KVM/MMU: Flush tlb directly in the kvm_zap_gfn_range()

2018-09-17 Thread Tianyu Lan
Originally, flush tlb is done by slot_handle_level_range(). This patch is to flush tlb directly in the kvm_zap_gfn_range() when range flush is available. Signed-off-by: Lan Tianyu --- arch/x86/kvm/mmu.c | 16 +--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git

[PATCH V2 00/13] x86/KVM/Hyper-v: Add HV ept tlb range flush hypercall support in KVM

2018-09-17 Thread Tianyu Lan
For nested memory virtualization, Hyper-v doesn't set write-protect L1 hypervisor EPT page directory and page table node to track changes while it relies on guest to tell it changes via HvFlushGuestAddressLlist hypercall. HvFlushGuestAddressLlist hypercall provides a way to flush EPT page table

[PATCH V2 3/13] KVM: Replace old tlb flush function with new one to flush a specified range.

2018-09-17 Thread Tianyu Lan
This patch is to replace kvm_flush_remote_tlbs() with kvm_flush_ remote_tlbs_with_address() in some functions without logic change. Signed-off-by: Lan Tianyu --- arch/x86/kvm/mmu.c | 33 ++--- arch/x86/kvm/paging_tmpl.h | 3 ++- 2 files changed, 24

[PATCH V2 1/13] KVM: Add tlb_remote_flush_with_range callback in kvm_x86_ops

2018-09-17 Thread Tianyu Lan
Add flush range call back in the kvm_x86_ops and platform can use it to register its associated function. The parameter "kvm_tlb_range" accepts a single range and flush list which contains a list of ranges. Signed-off-by: Lan Tianyu --- Change since v1: Change "end_gfn" to "pages" to

[PATCH V2 2/13] KVM/MMU: Add tlb flush with range helper function

2018-09-17 Thread Tianyu Lan
This patch is to add wrapper functions for tlb_remote_flush_with_range callback. Signed-off-by: Lan Tianyu --- arch/x86/kvm/mmu.c | 48 1 file changed, 48 insertions(+) diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c index

[PATCH V2 5/13] KVM/MMU: Flush tlb directly in the kvm_zap_gfn_range()

2018-09-17 Thread Tianyu Lan
Originally, flush tlb is done by slot_handle_level_range(). This patch is to flush tlb directly in the kvm_zap_gfn_range() when range flush is available. Signed-off-by: Lan Tianyu --- arch/x86/kvm/mmu.c | 16 +--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git

[PATCH V2 00/13] x86/KVM/Hyper-v: Add HV ept tlb range flush hypercall support in KVM

2018-09-17 Thread Tianyu Lan
For nested memory virtualization, Hyper-v doesn't set write-protect L1 hypervisor EPT page directory and page table node to track changes while it relies on guest to tell it changes via HvFlushGuestAddressLlist hypercall. HvFlushGuestAddressLlist hypercall provides a way to flush EPT page table

[PATCH V2 3/13] KVM: Replace old tlb flush function with new one to flush a specified range.

2018-09-17 Thread Tianyu Lan
This patch is to replace kvm_flush_remote_tlbs() with kvm_flush_ remote_tlbs_with_address() in some functions without logic change. Signed-off-by: Lan Tianyu --- arch/x86/kvm/mmu.c | 33 ++--- arch/x86/kvm/paging_tmpl.h | 3 ++- 2 files changed, 24

Re: [PATCH 1/13] KVM: Add tlb_remote_flush_with_range callback in kvm_x86_ops

2018-09-12 Thread Tianyu Lan
Hi Sean: Thanks for your review. On 9/10/2018 10:21 PM, Sean Christopherson wrote: > On Mon, 2018-09-10 at 08:38 +0000, Tianyu Lan wrote: >> Add flush range call back in the kvm_x86_ops and platform can use it >> to register its associated function. The parameter

Re: [PATCH 1/13] KVM: Add tlb_remote_flush_with_range callback in kvm_x86_ops

2018-09-12 Thread Tianyu Lan
Hi Sean: Thanks for your review. On 9/10/2018 10:21 PM, Sean Christopherson wrote: > On Mon, 2018-09-10 at 08:38 +0000, Tianyu Lan wrote: >> Add flush range call back in the kvm_x86_ops and platform can use it >> to register its associated function. The parameter

Re: [PATCH 10/13] x86/hyper-v: Add HvFlushGuestAddressList hypercall support

2018-09-12 Thread Tianyu Lan
Hi Michael: Thanks for your review. On 9/12/2018 8:22 AM, Michael Kelley (EOSG) wrote: > From: Tianyu Lan Sent: Monday, September 10, 2018 1:39 AM >> + >> +int hyperv_flush_guest_mapping_range(u64 as, struct kvm_tlb_range *range) > > I'm really concerned about

Re: [PATCH 10/13] x86/hyper-v: Add HvFlushGuestAddressList hypercall support

2018-09-12 Thread Tianyu Lan
Hi Michael: Thanks for your review. On 9/12/2018 8:22 AM, Michael Kelley (EOSG) wrote: > From: Tianyu Lan Sent: Monday, September 10, 2018 1:39 AM >> + >> +int hyperv_flush_guest_mapping_range(u64 as, struct kvm_tlb_range *range) > > I'm really concerned about

[PATCH 11/13] x86/Hyper-v: Add trace in the hyperv_nested_flush_guest_mapping_range()

2018-09-10 Thread Tianyu Lan
This patch is to trace log in the hyperv_nested_flush_ guest_mapping_range(). Signed-off-by: Lan Tianyu --- arch/x86/hyperv/nested.c| 1 + arch/x86/include/asm/trace/hyperv.h | 14 ++ 2 files changed, 15 insertions(+) diff --git a/arch/x86/hyperv/nested.c

[PATCH 11/13] x86/Hyper-v: Add trace in the hyperv_nested_flush_guest_mapping_range()

2018-09-10 Thread Tianyu Lan
This patch is to trace log in the hyperv_nested_flush_ guest_mapping_range(). Signed-off-by: Lan Tianyu --- arch/x86/hyperv/nested.c| 1 + arch/x86/include/asm/trace/hyperv.h | 14 ++ 2 files changed, 15 insertions(+) diff --git a/arch/x86/hyperv/nested.c

[PATCH 12/13] KVM/VMX: Change hv flush logic when ept tables are mismatched.

2018-09-10 Thread Tianyu Lan
If ept table pointers are mismatched, flushing tlb for each vcpus via hv flush interface still helps to reduce vmexits which are triggered by IPI and INEPT emulation. Signed-off-by: Lan Tianyu --- arch/x86/kvm/vmx.c | 15 --- 1 file changed, 8 insertions(+), 7 deletions(-) diff

[PATCH 13/13] KVM/VMX: Add hv tlb range flush support

2018-09-10 Thread Tianyu Lan
This patch is to register tlb_remote_flush_with_range callback with hv tlb range flush interface. Signed-off-by: Lan Tianyu --- arch/x86/kvm/vmx.c | 34 +++--- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c

[PATCH 10/13] x86/hyper-v: Add HvFlushGuestAddressList hypercall support

2018-09-10 Thread Tianyu Lan
Hyper-V provides HvFlushGuestAddressList() hypercall to flush EPT tlb with specified ranges. This patch is to add the hypercall support. Signed-off-by: Lan Tianyu --- arch/x86/hyperv/nested.c | 110 + arch/x86/include/asm/hyperv-tlfs.h | 17 ++

[PATCH 8/13] KVM: Add spte's point in the struct kvm_mmu_page

2018-09-10 Thread Tianyu Lan
It's necessary to check whether mmu page is last or large page when add mmu page into flush list. "spte" is needed for such check and so add spte point in the struct kvm_mmu_page. Signed-off-by: Lan Tianyu --- arch/x86/include/asm/kvm_host.h | 1 + arch/x86/kvm/mmu.c | 5 +

[PATCH 13/13] KVM/VMX: Add hv tlb range flush support

2018-09-10 Thread Tianyu Lan
This patch is to register tlb_remote_flush_with_range callback with hv tlb range flush interface. Signed-off-by: Lan Tianyu --- arch/x86/kvm/vmx.c | 34 +++--- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c

[PATCH 10/13] x86/hyper-v: Add HvFlushGuestAddressList hypercall support

2018-09-10 Thread Tianyu Lan
Hyper-V provides HvFlushGuestAddressList() hypercall to flush EPT tlb with specified ranges. This patch is to add the hypercall support. Signed-off-by: Lan Tianyu --- arch/x86/hyperv/nested.c | 110 + arch/x86/include/asm/hyperv-tlfs.h | 17 ++

[PATCH 12/13] KVM/VMX: Change hv flush logic when ept tables are mismatched.

2018-09-10 Thread Tianyu Lan
If ept table pointers are mismatched, flushing tlb for each vcpus via hv flush interface still helps to reduce vmexits which are triggered by IPI and INEPT emulation. Signed-off-by: Lan Tianyu --- arch/x86/kvm/vmx.c | 15 --- 1 file changed, 8 insertions(+), 7 deletions(-) diff

[PATCH 8/13] KVM: Add spte's point in the struct kvm_mmu_page

2018-09-10 Thread Tianyu Lan
It's necessary to check whether mmu page is last or large page when add mmu page into flush list. "spte" is needed for such check and so add spte point in the struct kvm_mmu_page. Signed-off-by: Lan Tianyu --- arch/x86/include/asm/kvm_host.h | 1 + arch/x86/kvm/mmu.c | 5 +

[PATCH 9/13] KVM/MMU: Replace tlb flush function with range list flush function

2018-09-10 Thread Tianyu Lan
This patch is to use range list flush function in the mmu_sync_children(), kvm_mmu_commit_zap_page() and FNAME(sync_page)(). Signed-off-by: Lan Tianyu --- arch/x86/kvm/mmu.c | 26 +++--- arch/x86/kvm/paging_tmpl.h | 5 - 2 files changed, 27 insertions(+), 4

[PATCH 7/13] KVM: Add flush_link and parent_pte in the struct kvm_mmu_page

2018-09-10 Thread Tianyu Lan
PV EPT tlb flush function will accept a list of flush ranges and use struct kvm_mmu_page as the list entry. Signed-off-by: Lan Tianyu --- arch/x86/include/asm/kvm_host.h | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h index

[PATCH 6/13] KVM/MMU: Flush tlb directly in kvm_mmu_zap_collapsible_spte()

2018-09-10 Thread Tianyu Lan
kvm_mmu_zap_collapsible_spte() returns flush request to the slot_handle_leaf() and the latter does flush on demand. When range flush is available, make kvm_mmu_zap_collapsible_spte() to flush tlb with range directly to avoid returning range back to slot_handle_leaf(). Signed-off-by: Lan Tianyu

[PATCH 9/13] KVM/MMU: Replace tlb flush function with range list flush function

2018-09-10 Thread Tianyu Lan
This patch is to use range list flush function in the mmu_sync_children(), kvm_mmu_commit_zap_page() and FNAME(sync_page)(). Signed-off-by: Lan Tianyu --- arch/x86/kvm/mmu.c | 26 +++--- arch/x86/kvm/paging_tmpl.h | 5 - 2 files changed, 27 insertions(+), 4

[PATCH 7/13] KVM: Add flush_link and parent_pte in the struct kvm_mmu_page

2018-09-10 Thread Tianyu Lan
PV EPT tlb flush function will accept a list of flush ranges and use struct kvm_mmu_page as the list entry. Signed-off-by: Lan Tianyu --- arch/x86/include/asm/kvm_host.h | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h index

[PATCH 6/13] KVM/MMU: Flush tlb directly in kvm_mmu_zap_collapsible_spte()

2018-09-10 Thread Tianyu Lan
kvm_mmu_zap_collapsible_spte() returns flush request to the slot_handle_leaf() and the latter does flush on demand. When range flush is available, make kvm_mmu_zap_collapsible_spte() to flush tlb with range directly to avoid returning range back to slot_handle_leaf(). Signed-off-by: Lan Tianyu

[PATCH 5/13] KVM/MMU: Flush tlb directly in the kvm_zap_gfn_range()

2018-09-10 Thread Tianyu Lan
Originally, flush tlb is done by slot_handle_level_range(). This patch is to flush tlb directly in the kvm_zap_gfn_range() when range flush is available. Signed-off-by: Lan Tianyu --- arch/x86/kvm/mmu.c | 15 --- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git

[PATCH 5/13] KVM/MMU: Flush tlb directly in the kvm_zap_gfn_range()

2018-09-10 Thread Tianyu Lan
Originally, flush tlb is done by slot_handle_level_range(). This patch is to flush tlb directly in the kvm_zap_gfn_range() when range flush is available. Signed-off-by: Lan Tianyu --- arch/x86/kvm/mmu.c | 15 --- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git

[PATCH 4/13] KVM/MMU: Flush tlb directly in the kvm_handle_hva_range()

2018-09-10 Thread Tianyu Lan
This patch is to flush tlb directly in the kvm_handle_hva_range() when range flush is available. Signed-off-by: Lan Tianyu --- arch/x86/kvm/mmu.c | 6 ++ 1 file changed, 6 insertions(+) diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c index 0ee310bad2c6..cadb6a0b5247 100644 ---

[PATCH 4/13] KVM/MMU: Flush tlb directly in the kvm_handle_hva_range()

2018-09-10 Thread Tianyu Lan
This patch is to flush tlb directly in the kvm_handle_hva_range() when range flush is available. Signed-off-by: Lan Tianyu --- arch/x86/kvm/mmu.c | 6 ++ 1 file changed, 6 insertions(+) diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c index 0ee310bad2c6..cadb6a0b5247 100644 ---

[PATCH 3/13] KVM: Replace old tlb flush function with new one to flush a specified range.

2018-09-10 Thread Tianyu Lan
This patch is to replace kvm_flush_remote_tlbs() with kvm_flush_ remote_tlbs_with_address() in some functions without logic change. Signed-off-by: Lan Tianyu --- arch/x86/kvm/mmu.c | 34 +++--- arch/x86/kvm/paging_tmpl.h | 9 +++-- 2 files changed, 30

[PATCH 3/13] KVM: Replace old tlb flush function with new one to flush a specified range.

2018-09-10 Thread Tianyu Lan
This patch is to replace kvm_flush_remote_tlbs() with kvm_flush_ remote_tlbs_with_address() in some functions without logic change. Signed-off-by: Lan Tianyu --- arch/x86/kvm/mmu.c | 34 +++--- arch/x86/kvm/paging_tmpl.h | 9 +++-- 2 files changed, 30

[PATCH 2/13] KVM/MMU: Add tlb flush with range helper function

2018-09-10 Thread Tianyu Lan
This patch is to add wrapper functions for tlb_remote_flush_with_range callback. Signed-off-by: Lan Tianyu --- arch/x86/kvm/mmu.c | 48 1 file changed, 48 insertions(+) diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c index

[PATCH 00/13] x86/KVM/Hyper-v: Add HV ept tlb range flush hypercall support in KVM

2018-09-10 Thread Tianyu Lan
For nested memory virtualization, Hyper-v doesn't set write-protect L1 hypervisor EPT page directory and page table node to track changes while it relies on guest to tell it changes via HvFlushGuestAddressLlist hypercall. HvFlushGuestAddressLlist hypercall provides a way to flush EPT page table

<    1   2   3   4   >