All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH V3 0/4] KVM/x86/hyper-V: Introduce PV guest address space mapping flush support
@ 2018-07-19  8:39 Tianyu Lan
  2018-07-19  8:40 ` [PATCH V3 1/4] X86/Hyper-V: Add flush HvFlushGuestPhysicalAddressSpace hypercall support Tianyu Lan
                   ` (6 more replies)
  0 siblings, 7 replies; 17+ messages in thread
From: Tianyu Lan @ 2018-07-19  8:39 UTC (permalink / raw)
  Cc: Tianyu Lan, devel, Haiyang Zhang, hpa, kvm, KY Srinivasan,
	linux-kernel, mingo, pbonzini, rkrcmar, Stephen Hemminger, tglx,
	x86, Michael Kelley (EOSG),
	vkuznets

Hyper-V provides a para-virtualization hypercall HvFlushGuestPhysicalAddressSpace
to flush nested VM address space mapping in l1 hypervisor and it's to reduce overhead
of flushing ept tlb among vcpus. The tradition way is to send IPIs to all affected
vcpus and executes INVEPT on each vcpus. It will trigger several vmexits for IPI and
INVEPT emulation. The pv hypercall can help to flush specified ept table on all vcpus
via one single hypercall.

Change since v2:
       - Make ept_pointers_match as tristate "check", "match" and "mismatch".
       Set "check" in vmx_set_cr3(), check all ept table pointers in hv_remote_flush_tlb()
       and call hypercall when all ept pointers are same.
       - Rename kvm_arch_hv_flush_remote_tlb with kvm_arch_flush_remote_tlb and
       Rename kvm_x86_ops->hv_tlb_remote_flush with kvm_x86_ops->tlb_remote_flush
       - Fix issue that ignore updating tlbs_dirty during calling kvm_arch_flush_remote_tlbs()
       - Merge patch "KVM/VMX: Add identical ept table pointer check" and
       patch "KVM/x86: Add tlb_remote_flush callback support for vmx"

Change since v1:
       - Fix compilation error for non-x86 platform.
       - Use ept_pointers_match to check condition of identical ept
            table pointer and get ept pointer from struct vcpu_vmx->ept_pointer.
       - Add hyperv_nested_flush_guest_mapping ftrace support
		     


Lan Tianyu (4):
  X86/Hyper-V: Add flush HvFlushGuestPhysicalAddressSpace hypercall
    support
  X86/Hyper-V: Add hyperv_nested_flush_guest_mapping ftrace support
  KVM: Add tlb remote flush callback in kvm_x86_ops.
  KVM/x86: Add tlb_remote_flush callback support for vmx

 arch/x86/hyperv/Makefile            |  2 +-
 arch/x86/hyperv/nested.c            | 67 ++++++++++++++++++++++++++++++++++
 arch/x86/include/asm/hyperv-tlfs.h  |  8 +++++
 arch/x86/include/asm/kvm_host.h     | 11 ++++++
 arch/x86/include/asm/mshyperv.h     |  2 ++
 arch/x86/include/asm/trace/hyperv.h | 14 ++++++++
 arch/x86/kvm/vmx.c                  | 72 ++++++++++++++++++++++++++++++++++++-
 include/linux/kvm_host.h            |  7 ++++
 virt/kvm/kvm_main.c                 |  3 +-
 9 files changed, 183 insertions(+), 3 deletions(-)
 create mode 100644 arch/x86/hyperv/nested.c

-- 
2.14.3

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH V3 1/4] X86/Hyper-V: Add flush HvFlushGuestPhysicalAddressSpace hypercall support
  2018-07-19  8:39 [PATCH V3 0/4] KVM/x86/hyper-V: Introduce PV guest address space mapping flush support Tianyu Lan
@ 2018-07-19  8:40 ` Tianyu Lan
  2018-07-19 12:05   ` Thomas Gleixner
  2018-07-19  8:40 ` [PATCH V3 2/4] X86/Hyper-V: Add hyperv_nested_flush_guest_mapping ftrace support Tianyu Lan
                   ` (5 subsequent siblings)
  6 siblings, 1 reply; 17+ messages in thread
From: Tianyu Lan @ 2018-07-19  8:40 UTC (permalink / raw)
  Cc: Tianyu Lan, KY Srinivasan, Haiyang Zhang, Stephen Hemminger,
	tglx, mingo, hpa, x86, pbonzini, rkrcmar, devel, linux-kernel,
	kvm, Michael Kelley (EOSG),
	vkuznets

Hyper-V supports a pv hypercall HvFlushGuestPhysicalAddressSpace to
flush nested VM address space mapping in l1 hypervisor and it's to
reduce overhead of flushing ept tlb among vcpus. This patch is to
implement it.

Signed-off-by: Lan Tianyu <Tianyu.Lan@microsoft.com>
---
 arch/x86/hyperv/Makefile           |  2 +-
 arch/x86/hyperv/nested.c           | 64 ++++++++++++++++++++++++++++++++++++++
 arch/x86/include/asm/hyperv-tlfs.h |  8 +++++
 arch/x86/include/asm/mshyperv.h    |  2 ++
 4 files changed, 75 insertions(+), 1 deletion(-)
 create mode 100644 arch/x86/hyperv/nested.c

diff --git a/arch/x86/hyperv/Makefile b/arch/x86/hyperv/Makefile
index b173d404e3df..b21ee65c4101 100644
--- a/arch/x86/hyperv/Makefile
+++ b/arch/x86/hyperv/Makefile
@@ -1,2 +1,2 @@
-obj-y			:= hv_init.o mmu.o
+obj-y			:= hv_init.o mmu.o nested.o
 obj-$(CONFIG_X86_64)	+= hv_apic.o
diff --git a/arch/x86/hyperv/nested.c b/arch/x86/hyperv/nested.c
new file mode 100644
index 000000000000..74dd38b5221d
--- /dev/null
+++ b/arch/x86/hyperv/nested.c
@@ -0,0 +1,64 @@
+// SPDX-License-Identifier: GPL-2.0
+
+/*
+ * Hyper-V nested virtualization code.
+ *
+ * Copyright (C) 2018, Microsoft, Inc.
+ *
+ * Author : Lan Tianyu <Tianyu.Lan@microsoft.com>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published
+ * by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
+ * NON INFRINGEMENT.  See the GNU General Public License for more
+ * details.
+ *
+ */
+
+
+#include <linux/types.h>
+#include <asm/hyperv-tlfs.h>
+#include <asm/mshyperv.h>
+#include <asm/tlbflush.h>
+
+int hyperv_flush_guest_mapping(u64 as)
+{
+	struct hv_guest_mapping_flush **flush_pcpu;
+	struct hv_guest_mapping_flush *flush;
+	u64 status;
+	unsigned long flags;
+	int ret = -EFAULT;
+
+	if (!hv_hypercall_pg)
+		goto fault;
+
+	local_irq_save(flags);
+
+	flush_pcpu = (struct hv_guest_mapping_flush **)
+		this_cpu_ptr(hyperv_pcpu_input_arg);
+
+	flush = *flush_pcpu;
+
+	if (unlikely(!flush)) {
+		local_irq_restore(flags);
+		goto fault;
+	}
+
+	flush->address_space = as;
+	flush->flags = 0;
+
+	status = hv_do_hypercall(HVCALL_FLUSH_GUEST_PHYSICAL_ADDRESS_SPACE,
+				 flush, NULL);
+	local_irq_restore(flags);
+
+	if (!(status & HV_HYPERCALL_RESULT_MASK))
+		ret = 0;
+
+fault:
+	return ret;
+}
+EXPORT_SYMBOL_GPL(hyperv_flush_guest_mapping);
diff --git a/arch/x86/include/asm/hyperv-tlfs.h b/arch/x86/include/asm/hyperv-tlfs.h
index b8c89265baf0..08e24f552030 100644
--- a/arch/x86/include/asm/hyperv-tlfs.h
+++ b/arch/x86/include/asm/hyperv-tlfs.h
@@ -309,6 +309,7 @@ struct ms_hyperv_tsc_page {
 #define HV_X64_MSR_REENLIGHTENMENT_CONTROL	0x40000106
 
 /* Nested features (CPUID 0x4000000A) EAX */
+#define HV_X64_NESTED_GUEST_MAPPING_FLUSH	BIT(18)
 #define HV_X64_NESTED_MSR_BITMAP		BIT(19)
 
 struct hv_reenlightenment_control {
@@ -350,6 +351,7 @@ struct hv_tsc_emulation_status {
 #define HVCALL_SEND_IPI_EX			0x0015
 #define HVCALL_POST_MESSAGE			0x005c
 #define HVCALL_SIGNAL_EVENT			0x005d
+#define HVCALL_FLUSH_GUEST_PHYSICAL_ADDRESS_SPACE 0x00af
 
 #define HV_X64_MSR_VP_ASSIST_PAGE_ENABLE	0x00000001
 #define HV_X64_MSR_VP_ASSIST_PAGE_ADDRESS_SHIFT	12
@@ -741,6 +743,12 @@ struct ipi_arg_ex {
 	struct hv_vpset vp_set;
 };
 
+/* HvFlushGuestPhysicalAddressSpace hypercalls */
+struct hv_guest_mapping_flush {
+	u64 address_space;
+	u64 flags;
+};
+
 /* HvFlushVirtualAddressSpace, HvFlushVirtualAddressList hypercalls */
 struct hv_tlb_flush {
 	u64 address_space;
diff --git a/arch/x86/include/asm/mshyperv.h b/arch/x86/include/asm/mshyperv.h
index 3cd14311edfa..a6a615b49876 100644
--- a/arch/x86/include/asm/mshyperv.h
+++ b/arch/x86/include/asm/mshyperv.h
@@ -302,6 +302,7 @@ void hyperv_reenlightenment_intr(struct pt_regs *regs);
 void set_hv_tscchange_cb(void (*cb)(void));
 void clear_hv_tscchange_cb(void);
 void hyperv_stop_tsc_emulation(void);
+int hyperv_flush_guest_mapping(u64 as);
 
 #ifdef CONFIG_X86_64
 void hv_apic_init(void);
@@ -321,6 +322,7 @@ static inline struct hv_vp_assist_page *hv_get_vp_assist_page(unsigned int cpu)
 {
 	return NULL;
 }
+static inline int hyperv_flush_guest_mapping(u64 as) { return -1; }
 #endif /* CONFIG_HYPERV */
 
 #ifdef CONFIG_HYPERV_TSCPAGE
-- 
2.14.3

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH V3 2/4] X86/Hyper-V: Add hyperv_nested_flush_guest_mapping ftrace support
  2018-07-19  8:39 [PATCH V3 0/4] KVM/x86/hyper-V: Introduce PV guest address space mapping flush support Tianyu Lan
  2018-07-19  8:40 ` [PATCH V3 1/4] X86/Hyper-V: Add flush HvFlushGuestPhysicalAddressSpace hypercall support Tianyu Lan
@ 2018-07-19  8:40 ` Tianyu Lan
  2018-07-19  8:40 ` [PATCH V3 3/4] KVM: Add tlb remote flush callback in kvm_x86_ops Tianyu Lan
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 17+ messages in thread
From: Tianyu Lan @ 2018-07-19  8:40 UTC (permalink / raw)
  Cc: Tianyu Lan, KY Srinivasan, Haiyang Zhang, Stephen Hemminger,
	tglx, mingo, hpa, x86, pbonzini, rkrcmar, devel, linux-kernel,
	kvm, Michael Kelley (EOSG),
	vkuznets

This patch is to add hyperv_nested_flush_guest_mapping support to trace
hvFlushGuestPhysicalAddressSpace hypercall.

Signed-off-by: Lan Tianyu <Tianyu.Lan@microsoft.com>
---
 arch/x86/hyperv/nested.c            |  3 +++
 arch/x86/include/asm/trace/hyperv.h | 14 ++++++++++++++
 2 files changed, 17 insertions(+)

diff --git a/arch/x86/hyperv/nested.c b/arch/x86/hyperv/nested.c
index 74dd38b5221d..42a3232f2835 100644
--- a/arch/x86/hyperv/nested.c
+++ b/arch/x86/hyperv/nested.c
@@ -25,6 +25,8 @@
 #include <asm/mshyperv.h>
 #include <asm/tlbflush.h>
 
+#include <asm/trace/hyperv.h>
+
 int hyperv_flush_guest_mapping(u64 as)
 {
 	struct hv_guest_mapping_flush **flush_pcpu;
@@ -59,6 +61,7 @@ int hyperv_flush_guest_mapping(u64 as)
 		ret = 0;
 
 fault:
+	trace_hyperv_nested_flush_guest_mapping(as, ret);
 	return ret;
 }
 EXPORT_SYMBOL_GPL(hyperv_flush_guest_mapping);
diff --git a/arch/x86/include/asm/trace/hyperv.h b/arch/x86/include/asm/trace/hyperv.h
index 4253bca99989..e1ffe61de8d6 100644
--- a/arch/x86/include/asm/trace/hyperv.h
+++ b/arch/x86/include/asm/trace/hyperv.h
@@ -28,6 +28,20 @@ TRACE_EVENT(hyperv_mmu_flush_tlb_others,
 		      __entry->addr, __entry->end)
 	);
 
+TRACE_EVENT(hyperv_nested_flush_guest_mapping,
+	    TP_PROTO(u64 as, int ret),
+	    TP_ARGS(as, ret),
+
+	    TP_STRUCT__entry(
+		    __field(u64, as)
+		    __field(int, ret)
+		    ),
+	    TP_fast_assign(__entry->as = as;
+			   __entry->ret = ret;
+		    ),
+	    TP_printk("address space %llx ret %d", __entry->as, __entry->ret)
+	);
+
 #endif /* CONFIG_HYPERV */
 
 #undef TRACE_INCLUDE_PATH
-- 
2.14.3

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH V3 3/4] KVM: Add tlb remote flush callback in kvm_x86_ops.
  2018-07-19  8:39 [PATCH V3 0/4] KVM/x86/hyper-V: Introduce PV guest address space mapping flush support Tianyu Lan
  2018-07-19  8:40 ` [PATCH V3 1/4] X86/Hyper-V: Add flush HvFlushGuestPhysicalAddressSpace hypercall support Tianyu Lan
  2018-07-19  8:40 ` [PATCH V3 2/4] X86/Hyper-V: Add hyperv_nested_flush_guest_mapping ftrace support Tianyu Lan
@ 2018-07-19  8:40 ` Tianyu Lan
  2018-07-19  8:40 ` [PATCH V3 4/4] KVM/x86: Add tlb_remote_flush callback support for vmx Tianyu Lan
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 17+ messages in thread
From: Tianyu Lan @ 2018-07-19  8:40 UTC (permalink / raw)
  Cc: Tianyu Lan, pbonzini, rkrcmar, tglx, mingo, hpa, x86, kvm,
	linux-kernel, Michael Kelley (EOSG),
	KY Srinivasan, vkuznets

This patch is to provide a way for platforms to register hv tlb remote
flush callback and this helps to optimize operation of tlb flush
among vcpus for nested virtualization case.

Signed-off-by: Lan Tianyu <Tianyu.Lan@microsoft.com>
---
Change since v2:
       Rename kvm_arch_hv_flush_remote_tlb with kvm_arch_flush_remote_tlb
       Rename kvm_x86_ops->hv_tlb_remote_flush with kvm_x86_ops->tlb_remote_flush
       Fix issue that ignore updating tlbs_dirty during calling kvm_arch_flush_remote_tlbs()
Change since v1:
       Add kvm_arch_hv_flush_remote_tlb() to avoid compilation issue
for non-x86 platform.
---
 arch/x86/include/asm/kvm_host.h | 11 +++++++++++
 include/linux/kvm_host.h        |  7 +++++++
 virt/kvm/kvm_main.c             |  3 ++-
 3 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
index c13cd28d9d1b..76e806bc4ef8 100644
--- a/arch/x86/include/asm/kvm_host.h
+++ b/arch/x86/include/asm/kvm_host.h
@@ -973,6 +973,7 @@ struct kvm_x86_ops {
 	void (*set_rflags)(struct kvm_vcpu *vcpu, unsigned long rflags);
 
 	void (*tlb_flush)(struct kvm_vcpu *vcpu, bool invalidate_gpa);
+	int  (*tlb_remote_flush)(struct kvm *kvm);
 
 	void (*run)(struct kvm_vcpu *vcpu);
 	int (*handle_exit)(struct kvm_vcpu *vcpu);
@@ -1117,6 +1118,16 @@ static inline void kvm_arch_free_vm(struct kvm *kvm)
 	return kvm_x86_ops->vm_free(kvm);
 }
 
+#define __KVM_HAVE_ARCH_FLUSH_REMOTE_TLB
+static inline int kvm_arch_flush_remote_tlb(struct kvm *kvm)
+{
+	if (kvm_x86_ops->tlb_remote_flush &&
+	    !kvm_x86_ops->tlb_remote_flush(kvm))
+		return 0;
+	else
+		return -EFAULT;
+}
+
 int kvm_mmu_module_init(void);
 void kvm_mmu_module_exit(void);
 
diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
index 4ee7bc548a83..0781d94200df 100644
--- a/include/linux/kvm_host.h
+++ b/include/linux/kvm_host.h
@@ -827,6 +827,13 @@ static inline void kvm_arch_free_vm(struct kvm *kvm)
 }
 #endif
 
+#ifndef __KVM_HAVE_ARCH_FLUSH_REMOTE_TLB
+static inline int kvm_arch_flush_remote_tlb(struct kvm *kvm)
+{
+	return -EFAULT;
+}
+#endif
+
 #ifdef __KVM_HAVE_ARCH_NONCOHERENT_DMA
 void kvm_arch_register_noncoherent_dma(struct kvm *kvm);
 void kvm_arch_unregister_noncoherent_dma(struct kvm *kvm);
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 8b47507faab5..1a13cdb2822b 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -273,7 +273,8 @@ void kvm_flush_remote_tlbs(struct kvm *kvm)
 	 * kvm_make_all_cpus_request() reads vcpu->mode. We reuse that
 	 * barrier here.
 	 */
-	if (kvm_make_all_cpus_request(kvm, KVM_REQ_TLB_FLUSH))
+	if (!kvm_arch_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);
 }
-- 
2.14.3

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH V3 4/4] KVM/x86: Add tlb_remote_flush callback support for vmx
  2018-07-19  8:39 [PATCH V3 0/4] KVM/x86/hyper-V: Introduce PV guest address space mapping flush support Tianyu Lan
                   ` (2 preceding siblings ...)
  2018-07-19  8:40 ` [PATCH V3 3/4] KVM: Add tlb remote flush callback in kvm_x86_ops Tianyu Lan
@ 2018-07-19  8:40 ` Tianyu Lan
  2018-07-19  8:57 ` [PATCH V3 0/4] KVM/x86/hyper-V: Introduce PV guest address space mapping flush support Paolo Bonzini
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 17+ messages in thread
From: Tianyu Lan @ 2018-07-19  8:40 UTC (permalink / raw)
  Cc: Tianyu Lan, pbonzini, rkrcmar, tglx, mingo, hpa, x86, kvm,
	linux-kernel, Michael Kelley (EOSG),
	KY Srinivasan, vkuznets

Register tlb_remote_flush callback for vmx when hyperv capability of
nested guest mapping flush is detected. The interface can help to
reduce overhead when flush ept table among vcpus for nested VM. The
tradition way is to send IPIs to all affected vcpus and executes
INVEPT on each vcpus. It will trigger several vmexits for IPI
and INVEPT emulation. Hyper-V provides such hypercall to do
flush for all vcpus and call the hypercall when all ept table
pointers of single VM are same.

Signed-off-by: Lan Tianyu <Tianyu.Lan@microsoft.com>
---
Change since v2:
       Make ept_pointers_match as tristate "check", "match" and
"mismatch". Set "check" in vmx_set_cr3(), check all ept table
pointers in hv_remote_flush_tlb() and call hypercall when all
ept pointers are same.

Change since v1:
       Replace identical_ept_pointer with ept_pointers_match and
check kvm_x86_ops->tlb_remote_flush in check_ept_pointer().
---
 arch/x86/kvm/vmx.c | 72 +++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 71 insertions(+), 1 deletion(-)

diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index 1689f433f3a0..601ee37937a9 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -188,12 +188,21 @@ module_param(ple_window_max, uint, 0444);
 
 extern const ulong vmx_return;
 
+enum ept_pointers_status {
+	EPT_POINTERS_CHECK = 0,
+	EPT_POINTERS_MATCH = 1,
+	EPT_POINTERS_MISMATCH = 2
+};
+
 struct kvm_vmx {
 	struct kvm kvm;
 
 	unsigned int tss_addr;
 	bool ept_identity_pagetable_done;
 	gpa_t ept_identity_map_addr;
+
+	enum ept_pointers_status ept_pointers_match;
+	spinlock_t ept_pointer_lock;
 };
 
 #define NR_AUTOLOAD_MSRS 8
@@ -853,6 +862,7 @@ struct vcpu_vmx {
 	 */
 	u64 msr_ia32_feature_control;
 	u64 msr_ia32_feature_control_valid_bits;
+	u64 ept_pointer;
 };
 
 enum segment_cache_field {
@@ -4774,6 +4784,48 @@ static inline void __vmx_flush_tlb(struct kvm_vcpu *vcpu, int vpid,
 	}
 }
 
+/* check_ept_pointer() should be under protection of ept_pointer_lock. */
+static void check_ept_pointer(struct kvm *kvm)
+{
+	struct kvm_vcpu *vcpu;
+	u64 tmp_eptp = INVALID_PAGE;
+	int i;
+
+	kvm_for_each_vcpu(i, vcpu, kvm) {
+		if (!VALID_PAGE(tmp_eptp)) {
+			tmp_eptp = to_vmx(vcpu)->ept_pointer;
+		} else if (tmp_eptp != to_vmx(vcpu)->ept_pointer) {
+			to_kvm_vmx(kvm)->ept_pointers_match
+				= EPT_POINTERS_MISMATCH;
+			return;
+		}
+	}
+
+	to_kvm_vmx(kvm)->ept_pointers_match = EPT_POINTERS_MATCH;
+}
+
+static int hv_remote_flush_tlb(struct kvm *kvm)
+{
+	int ret;
+
+	spin_lock(&to_kvm_vmx(kvm)->ept_pointer_lock);
+
+	if (to_kvm_vmx(kvm)->ept_pointers_match == EPT_POINTERS_CHECK)
+		check_ept_pointer(kvm);
+
+	if (to_kvm_vmx(kvm)->ept_pointers_match != EPT_POINTERS_MATCH) {
+		ret = -EFAULT;
+		goto out;
+	}
+
+	ret = hyperv_flush_guest_mapping(
+			to_vmx(kvm_get_vcpu(kvm, 0))->ept_pointer);
+
+out:
+	spin_unlock(&to_kvm_vmx(kvm)->ept_pointer_lock);
+	return ret;
+}
+
 static void vmx_flush_tlb(struct kvm_vcpu *vcpu, bool invalidate_gpa)
 {
 	__vmx_flush_tlb(vcpu, to_vmx(vcpu)->vpid, invalidate_gpa);
@@ -4960,6 +5012,7 @@ static u64 construct_eptp(struct kvm_vcpu *vcpu, unsigned long root_hpa)
 
 static void vmx_set_cr3(struct kvm_vcpu *vcpu, unsigned long cr3)
 {
+	struct kvm *kvm = vcpu->kvm;
 	unsigned long guest_cr3;
 	u64 eptp;
 
@@ -4967,11 +5020,20 @@ static void vmx_set_cr3(struct kvm_vcpu *vcpu, unsigned long cr3)
 	if (enable_ept) {
 		eptp = construct_eptp(vcpu, cr3);
 		vmcs_write64(EPT_POINTER, eptp);
+
+		if (kvm_x86_ops->tlb_remote_flush) {
+			spin_lock(&to_kvm_vmx(kvm)->ept_pointer_lock);
+			to_vmx(vcpu)->ept_pointer = eptp;
+			to_kvm_vmx(kvm)->ept_pointers_match
+				= EPT_POINTERS_CHECK;
+			spin_unlock(&to_kvm_vmx(kvm)->ept_pointer_lock);
+		}
+
 		if (enable_unrestricted_guest || is_paging(vcpu) ||
 		    is_guest_mode(vcpu))
 			guest_cr3 = kvm_read_cr3(vcpu);
 		else
-			guest_cr3 = to_kvm_vmx(vcpu->kvm)->ept_identity_map_addr;
+			guest_cr3 = to_kvm_vmx(kvm)->ept_identity_map_addr;
 		ept_load_pdptrs(vcpu);
 	}
 
@@ -7538,6 +7600,12 @@ static __init int hardware_setup(void)
 	if (enable_ept && !cpu_has_vmx_ept_2m_page())
 		kvm_disable_largepages();
 
+#if IS_ENABLED(CONFIG_HYPERV)
+	if (ms_hyperv.nested_features & HV_X64_NESTED_GUEST_MAPPING_FLUSH
+	    && enable_ept)
+		kvm_x86_ops->tlb_remote_flush = hv_remote_flush_tlb;
+#endif
+
 	if (!cpu_has_vmx_ple()) {
 		ple_gap = 0;
 		ple_window = 0;
@@ -10383,6 +10451,8 @@ static struct kvm_vcpu *vmx_create_vcpu(struct kvm *kvm, unsigned int id)
 
 static int vmx_vm_init(struct kvm *kvm)
 {
+	spin_lock_init(&to_kvm_vmx(kvm)->ept_pointer_lock);
+
 	if (!ple_gap)
 		kvm->arch.pause_in_guest = true;
 	return 0;
-- 
2.14.3

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* Re: [PATCH V3 0/4] KVM/x86/hyper-V: Introduce PV guest address space mapping flush support
  2018-07-19  8:39 [PATCH V3 0/4] KVM/x86/hyper-V: Introduce PV guest address space mapping flush support Tianyu Lan
                   ` (3 preceding siblings ...)
  2018-07-19  8:40 ` [PATCH V3 4/4] KVM/x86: Add tlb_remote_flush callback support for vmx Tianyu Lan
@ 2018-07-19  8:57 ` Paolo Bonzini
  2018-07-19  9:31     ` Tianyu Lan
  2018-07-19 13:56 ` [Update PATCH V3 1/4] X86/Hyper-V: Add flush HvFlushGuestPhysicalAddressSpace hypercall support Tianyu Lan
  2018-07-20  3:58 ` [PATCH V3 0/4] KVM/x86/hyper-V: Introduce PV guest address space mapping flush support KY Srinivasan
  6 siblings, 1 reply; 17+ messages in thread
From: Paolo Bonzini @ 2018-07-19  8:57 UTC (permalink / raw)
  To: Tianyu Lan
  Cc: devel, Haiyang Zhang, hpa, kvm, KY Srinivasan, linux-kernel,
	mingo, rkrcmar, Stephen Hemminger, tglx, x86,
	Michael Kelley (EOSG),
	vkuznets

On 19/07/2018 10:39, Tianyu Lan wrote:
> Hyper-V provides a para-virtualization hypercall HvFlushGuestPhysicalAddressSpace
> to flush nested VM address space mapping in l1 hypervisor and it's to reduce overhead
> of flushing ept tlb among vcpus. The tradition way is to send IPIs to all affected
> vcpus and executes INVEPT on each vcpus. It will trigger several vmexits for IPI and
> INVEPT emulation. The pv hypercall can help to flush specified ept table on all vcpus
> via one single hypercall.

Thanks, this looks good apart from a global replace of EFAULT with
ENOTSUP (which can be done when applying).  Can I have an explicit ack
for patches 1 and 2 from the Hyper-V people?

Thanks,

Paolo

> Change since v2:
>        - Make ept_pointers_match as tristate "check", "match" and "mismatch".
>        Set "check" in vmx_set_cr3(), check all ept table pointers in hv_remote_flush_tlb()
>        and call hypercall when all ept pointers are same.
>        - Rename kvm_arch_hv_flush_remote_tlb with kvm_arch_flush_remote_tlb and
>        Rename kvm_x86_ops->hv_tlb_remote_flush with kvm_x86_ops->tlb_remote_flush
>        - Fix issue that ignore updating tlbs_dirty during calling kvm_arch_flush_remote_tlbs()
>        - Merge patch "KVM/VMX: Add identical ept table pointer check" and
>        patch "KVM/x86: Add tlb_remote_flush callback support for vmx"
> 
> Change since v1:
>        - Fix compilation error for non-x86 platform.
>        - Use ept_pointers_match to check condition of identical ept
>             table pointer and get ept pointer from struct vcpu_vmx->ept_pointer.
>        - Add hyperv_nested_flush_guest_mapping ftrace support
> 		     
> 
> 
> Lan Tianyu (4):
>   X86/Hyper-V: Add flush HvFlushGuestPhysicalAddressSpace hypercall
>     support
>   X86/Hyper-V: Add hyperv_nested_flush_guest_mapping ftrace support
>   KVM: Add tlb remote flush callback in kvm_x86_ops.
>   KVM/x86: Add tlb_remote_flush callback support for vmx
> 
>  arch/x86/hyperv/Makefile            |  2 +-
>  arch/x86/hyperv/nested.c            | 67 ++++++++++++++++++++++++++++++++++
>  arch/x86/include/asm/hyperv-tlfs.h  |  8 +++++
>  arch/x86/include/asm/kvm_host.h     | 11 ++++++
>  arch/x86/include/asm/mshyperv.h     |  2 ++
>  arch/x86/include/asm/trace/hyperv.h | 14 ++++++++
>  arch/x86/kvm/vmx.c                  | 72 ++++++++++++++++++++++++++++++++++++-
>  include/linux/kvm_host.h            |  7 ++++
>  virt/kvm/kvm_main.c                 |  3 +-
>  9 files changed, 183 insertions(+), 3 deletions(-)
>  create mode 100644 arch/x86/hyperv/nested.c
> 


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH V3 0/4] KVM/x86/hyper-V: Introduce PV guest address space mapping flush support
  2018-07-19  8:57 ` [PATCH V3 0/4] KVM/x86/hyper-V: Introduce PV guest address space mapping flush support Paolo Bonzini
@ 2018-07-19  9:31     ` Tianyu Lan
  0 siblings, 0 replies; 17+ messages in thread
From: Tianyu Lan @ 2018-07-19  9:31 UTC (permalink / raw)
  To: Paolo Bonzini, Tianyu Lan
  Cc: devel, Haiyang Zhang, hpa, kvm, KY Srinivasan, linux-kernel,
	mingo, rkrcmar, Stephen Hemminger, tglx, x86,
	Michael Kelley (EOSG),
	vkuznets

On 7/19/2018 4:57 PM, Paolo Bonzini wrote:
> On 19/07/2018 10:39, Tianyu Lan wrote:
>> Hyper-V provides a para-virtualization hypercall HvFlushGuestPhysicalAddressSpace
>> to flush nested VM address space mapping in l1 hypervisor and it's to reduce overhead
>> of flushing ept tlb among vcpus. The tradition way is to send IPIs to all affected
>> vcpus and executes INVEPT on each vcpus. It will trigger several vmexits for IPI and
>> INVEPT emulation. The pv hypercall can help to flush specified ept table on all vcpus
>> via one single hypercall.
> 
> Thanks, this looks good apart from a global replace of EFAULT with
> ENOTSUP (which can be done when applying).  Can I have an explicit ack
> for patches 1 and 2 from the Hyper-V people?

Thanks, Paolo. I will try to hyper-V people's ack.

> 
> Thanks,
> 
> Paolo
> 
>> Change since v2:
>>         - Make ept_pointers_match as tristate "check", "match" and "mismatch".
>>         Set "check" in vmx_set_cr3(), check all ept table pointers in hv_remote_flush_tlb()
>>         and call hypercall when all ept pointers are same.
>>         - Rename kvm_arch_hv_flush_remote_tlb with kvm_arch_flush_remote_tlb and
>>         Rename kvm_x86_ops->hv_tlb_remote_flush with kvm_x86_ops->tlb_remote_flush
>>         - Fix issue that ignore updating tlbs_dirty during calling kvm_arch_flush_remote_tlbs()
>>         - Merge patch "KVM/VMX: Add identical ept table pointer check" and
>>         patch "KVM/x86: Add tlb_remote_flush callback support for vmx"
>>
>> Change since v1:
>>         - Fix compilation error for non-x86 platform.
>>         - Use ept_pointers_match to check condition of identical ept
>>              table pointer and get ept pointer from struct vcpu_vmx->ept_pointer.
>>         - Add hyperv_nested_flush_guest_mapping ftrace support
>> 		
>>
>>
>> Lan Tianyu (4):
>>    X86/Hyper-V: Add flush HvFlushGuestPhysicalAddressSpace hypercall
>>      support
>>    X86/Hyper-V: Add hyperv_nested_flush_guest_mapping ftrace support
>>    KVM: Add tlb remote flush callback in kvm_x86_ops.
>>    KVM/x86: Add tlb_remote_flush callback support for vmx
>>
>>   arch/x86/hyperv/Makefile            |  2 +-
>>   arch/x86/hyperv/nested.c            | 67 ++++++++++++++++++++++++++++++++++
>>   arch/x86/include/asm/hyperv-tlfs.h  |  8 +++++
>>   arch/x86/include/asm/kvm_host.h     | 11 ++++++
>>   arch/x86/include/asm/mshyperv.h     |  2 ++
>>   arch/x86/include/asm/trace/hyperv.h | 14 ++++++++
>>   arch/x86/kvm/vmx.c                  | 72 ++++++++++++++++++++++++++++++++++++-
>>   include/linux/kvm_host.h            |  7 ++++
>>   virt/kvm/kvm_main.c                 |  3 +-
>>   9 files changed, 183 insertions(+), 3 deletions(-)
>>   create mode 100644 arch/x86/hyperv/nested.c
>>
> 

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH V3 0/4] KVM/x86/hyper-V: Introduce PV guest address space mapping flush support
@ 2018-07-19  9:31     ` Tianyu Lan
  0 siblings, 0 replies; 17+ messages in thread
From: Tianyu Lan @ 2018-07-19  9:31 UTC (permalink / raw)
  To: Paolo Bonzini, Tianyu Lan
  Cc: Stephen Hemminger, kvm, rkrcmar, Haiyang Zhang, x86,
	linux-kernel, Michael Kelley (EOSG),
	mingo, hpa, devel, tglx, vkuznets

On 7/19/2018 4:57 PM, Paolo Bonzini wrote:
> On 19/07/2018 10:39, Tianyu Lan wrote:
>> Hyper-V provides a para-virtualization hypercall HvFlushGuestPhysicalAddressSpace
>> to flush nested VM address space mapping in l1 hypervisor and it's to reduce overhead
>> of flushing ept tlb among vcpus. The tradition way is to send IPIs to all affected
>> vcpus and executes INVEPT on each vcpus. It will trigger several vmexits for IPI and
>> INVEPT emulation. The pv hypercall can help to flush specified ept table on all vcpus
>> via one single hypercall.
> 
> Thanks, this looks good apart from a global replace of EFAULT with
> ENOTSUP (which can be done when applying).  Can I have an explicit ack
> for patches 1 and 2 from the Hyper-V people?

Thanks, Paolo. I will try to hyper-V people's ack.

> 
> Thanks,
> 
> Paolo
> 
>> Change since v2:
>>         - Make ept_pointers_match as tristate "check", "match" and "mismatch".
>>         Set "check" in vmx_set_cr3(), check all ept table pointers in hv_remote_flush_tlb()
>>         and call hypercall when all ept pointers are same.
>>         - Rename kvm_arch_hv_flush_remote_tlb with kvm_arch_flush_remote_tlb and
>>         Rename kvm_x86_ops->hv_tlb_remote_flush with kvm_x86_ops->tlb_remote_flush
>>         - Fix issue that ignore updating tlbs_dirty during calling kvm_arch_flush_remote_tlbs()
>>         - Merge patch "KVM/VMX: Add identical ept table pointer check" and
>>         patch "KVM/x86: Add tlb_remote_flush callback support for vmx"
>>
>> Change since v1:
>>         - Fix compilation error for non-x86 platform.
>>         - Use ept_pointers_match to check condition of identical ept
>>              table pointer and get ept pointer from struct vcpu_vmx->ept_pointer.
>>         - Add hyperv_nested_flush_guest_mapping ftrace support
>> 		
>>
>>
>> Lan Tianyu (4):
>>    X86/Hyper-V: Add flush HvFlushGuestPhysicalAddressSpace hypercall
>>      support
>>    X86/Hyper-V: Add hyperv_nested_flush_guest_mapping ftrace support
>>    KVM: Add tlb remote flush callback in kvm_x86_ops.
>>    KVM/x86: Add tlb_remote_flush callback support for vmx
>>
>>   arch/x86/hyperv/Makefile            |  2 +-
>>   arch/x86/hyperv/nested.c            | 67 ++++++++++++++++++++++++++++++++++
>>   arch/x86/include/asm/hyperv-tlfs.h  |  8 +++++
>>   arch/x86/include/asm/kvm_host.h     | 11 ++++++
>>   arch/x86/include/asm/mshyperv.h     |  2 ++
>>   arch/x86/include/asm/trace/hyperv.h | 14 ++++++++
>>   arch/x86/kvm/vmx.c                  | 72 ++++++++++++++++++++++++++++++++++++-
>>   include/linux/kvm_host.h            |  7 ++++
>>   virt/kvm/kvm_main.c                 |  3 +-
>>   9 files changed, 183 insertions(+), 3 deletions(-)
>>   create mode 100644 arch/x86/hyperv/nested.c
>>
> 

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH V3 1/4] X86/Hyper-V: Add flush HvFlushGuestPhysicalAddressSpace hypercall support
  2018-07-19  8:40 ` [PATCH V3 1/4] X86/Hyper-V: Add flush HvFlushGuestPhysicalAddressSpace hypercall support Tianyu Lan
@ 2018-07-19 12:05   ` Thomas Gleixner
  2018-07-19 12:41     ` Tianyu Lan
  0 siblings, 1 reply; 17+ messages in thread
From: Thomas Gleixner @ 2018-07-19 12:05 UTC (permalink / raw)
  To: Tianyu Lan
  Cc: KY Srinivasan, Haiyang Zhang, Stephen Hemminger, mingo, hpa, x86,
	pbonzini, rkrcmar, devel, linux-kernel, kvm,
	Michael Kelley (EOSG),
	vkuznets

On Thu, 19 Jul 2018, Tianyu Lan wrote:
> @@ -0,0 +1,64 @@
> +// SPDX-License-Identifier: GPL-2.0
> +
> +/*
> + * Hyper-V nested virtualization code.
> + *
> + * Copyright (C) 2018, Microsoft, Inc.
> + *
> + * Author : Lan Tianyu <Tianyu.Lan@microsoft.com>
> + *
> + * This program is free software; you can redistribute it and/or modify it
> + * under the terms of the GNU General Public License version 2 as published
> + * by the Free Software Foundation.
> + *
> + * This program is distributed in the hope that it will be useful, but
> + * WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
> + * NON INFRINGEMENT.  See the GNU General Public License for more
> + * details.

You already have the SPDX identifier. So the GPL boilerplate is not really
required, unless your legal departement insist on it.

Thanks,

	tglx

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH V3 1/4] X86/Hyper-V: Add flush HvFlushGuestPhysicalAddressSpace hypercall support
  2018-07-19 12:05   ` Thomas Gleixner
@ 2018-07-19 12:41     ` Tianyu Lan
  2018-07-19 12:54       ` Thomas Gleixner
  0 siblings, 1 reply; 17+ messages in thread
From: Tianyu Lan @ 2018-07-19 12:41 UTC (permalink / raw)
  To: Thomas Gleixner, Tianyu Lan
  Cc: KY Srinivasan, Haiyang Zhang, Stephen Hemminger, mingo, hpa, x86,
	pbonzini, rkrcmar, devel, linux-kernel, kvm,
	Michael Kelley (EOSG),
	vkuznets

On 7/19/2018 8:05 PM, Thomas Gleixner wrote:
> On Thu, 19 Jul 2018, Tianyu Lan wrote:
>> @@ -0,0 +1,64 @@
>> +// SPDX-License-Identifier: GPL-2.0
>> +
>> +/*
>> + * Hyper-V nested virtualization code.
>> + *
>> + * Copyright (C) 2018, Microsoft, Inc.
>> + *
>> + * Author : Lan Tianyu <Tianyu.Lan@microsoft.com>
>> + *
>> + * This program is free software; you can redistribute it and/or modify it
>> + * under the terms of the GNU General Public License version 2 as published
>> + * by the Free Software Foundation.
>> + *
>> + * This program is distributed in the hope that it will be useful, but
>> + * WITHOUT ANY WARRANTY; without even the implied warranty of
>> + * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
>> + * NON INFRINGEMENT.  See the GNU General Public License for more
>> + * details.
> 
> You already have the SPDX identifier. So the GPL boilerplate is not really
> required, unless your legal departement insist on it.
> 

Hi Thomas:
	Thanks for your reminder. How about the following?


+// SPDX-License-Identifier: GPL-2.0
+
+/*
+ * Hyper-V nested virtualization code.
+ *
+ * Copyright (C) 2018, Microsoft, Inc.
+ *
+ * Author : Lan Tianyu <Tianyu.Lan@microsoft.com>
+ */

> Thanks,
> 
> 	tglx
> 

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH V3 1/4] X86/Hyper-V: Add flush HvFlushGuestPhysicalAddressSpace hypercall support
  2018-07-19 12:41     ` Tianyu Lan
@ 2018-07-19 12:54       ` Thomas Gleixner
  0 siblings, 0 replies; 17+ messages in thread
From: Thomas Gleixner @ 2018-07-19 12:54 UTC (permalink / raw)
  To: Tianyu Lan
  Cc: KY Srinivasan, Haiyang Zhang, Stephen Hemminger, mingo, hpa, x86,
	pbonzini, rkrcmar, devel, linux-kernel, kvm,
	Michael Kelley (EOSG),
	vkuznets

On Thu, 19 Jul 2018, Tianyu Lan wrote:
> On 7/19/2018 8:05 PM, Thomas Gleixner wrote:
> > You already have the SPDX identifier. So the GPL boilerplate is not really
> > required, unless your legal departement insist on it.
> > 
> 
> Hi Thomas:
> 	Thanks for your reminder. How about the following?
> 
> 
> +// SPDX-License-Identifier: GPL-2.0
> +
> +/*
> + * Hyper-V nested virtualization code.
> + *
> + * Copyright (C) 2018, Microsoft, Inc.
> + *
> + * Author : Lan Tianyu <Tianyu.Lan@microsoft.com>
> + */

Perfect :)

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [Update PATCH V3 1/4] X86/Hyper-V: Add flush HvFlushGuestPhysicalAddressSpace hypercall support
  2018-07-19  8:39 [PATCH V3 0/4] KVM/x86/hyper-V: Introduce PV guest address space mapping flush support Tianyu Lan
                   ` (4 preceding siblings ...)
  2018-07-19  8:57 ` [PATCH V3 0/4] KVM/x86/hyper-V: Introduce PV guest address space mapping flush support Paolo Bonzini
@ 2018-07-19 13:56 ` Tianyu Lan
  2018-07-20  3:58 ` [PATCH V3 0/4] KVM/x86/hyper-V: Introduce PV guest address space mapping flush support KY Srinivasan
  6 siblings, 0 replies; 17+ messages in thread
From: Tianyu Lan @ 2018-07-19 13:56 UTC (permalink / raw)
  Cc: Tianyu Lan, KY Srinivasan, Haiyang Zhang, Stephen Hemminger,
	tglx, mingo, hpa, x86, pbonzini, rkrcmar, devel, linux-kernel,
	kvm, Michael Kelley (EOSG),
	vkuznets

Hyper-V supports a pv hypercall HvFlushGuestPhysicalAddressSpace to
flush nested VM address space mapping in l1 hypervisor and it's to
reduce overhead of flushing ept tlb among vcpus. This patch is to
implement it.

Signed-off-by: Lan Tianyu <Tianyu.Lan@microsoft.com>
---
Change since v3
	Remove GPL boilerplate.

 arch/x86/hyperv/Makefile           |  2 +-
 arch/x86/hyperv/nested.c           | 53 ++++++++++++++++++++++++++++++++++++++
 arch/x86/include/asm/hyperv-tlfs.h |  8 ++++++
 arch/x86/include/asm/mshyperv.h    |  2 ++
 4 files changed, 64 insertions(+), 1 deletion(-)
 create mode 100644 arch/x86/hyperv/nested.c

diff --git a/arch/x86/hyperv/Makefile b/arch/x86/hyperv/Makefile
index b173d404e3df..b21ee65c4101 100644
--- a/arch/x86/hyperv/Makefile
+++ b/arch/x86/hyperv/Makefile
@@ -1,2 +1,2 @@
-obj-y			:= hv_init.o mmu.o
+obj-y			:= hv_init.o mmu.o nested.o
 obj-$(CONFIG_X86_64)	+= hv_apic.o
diff --git a/arch/x86/hyperv/nested.c b/arch/x86/hyperv/nested.c
new file mode 100644
index 000000000000..3ad9d0fdea63
--- /dev/null
+++ b/arch/x86/hyperv/nested.c
@@ -0,0 +1,53 @@
+// SPDX-License-Identifier: GPL-2.0
+
+/*
+ * Hyper-V nested virtualization code.
+ *
+ * Copyright (C) 2018, Microsoft, Inc.
+ *
+ * Author : Lan Tianyu <Tianyu.Lan@microsoft.com>
+ */
+
+
+#include <linux/types.h>
+#include <asm/hyperv-tlfs.h>
+#include <asm/mshyperv.h>
+#include <asm/tlbflush.h>
+
+int hyperv_flush_guest_mapping(u64 as)
+{
+	struct hv_guest_mapping_flush **flush_pcpu;
+	struct hv_guest_mapping_flush *flush;
+	u64 status;
+	unsigned long flags;
+	int ret = -EFAULT;
+
+	if (!hv_hypercall_pg)
+		goto fault;
+
+	local_irq_save(flags);
+
+	flush_pcpu = (struct hv_guest_mapping_flush **)
+		this_cpu_ptr(hyperv_pcpu_input_arg);
+
+	flush = *flush_pcpu;
+
+	if (unlikely(!flush)) {
+		local_irq_restore(flags);
+		goto fault;
+	}
+
+	flush->address_space = as;
+	flush->flags = 0;
+
+	status = hv_do_hypercall(HVCALL_FLUSH_GUEST_PHYSICAL_ADDRESS_SPACE,
+				 flush, NULL);
+	local_irq_restore(flags);
+
+	if (!(status & HV_HYPERCALL_RESULT_MASK))
+		ret = 0;
+
+fault:
+	return ret;
+}
+EXPORT_SYMBOL_GPL(hyperv_flush_guest_mapping);
diff --git a/arch/x86/include/asm/hyperv-tlfs.h b/arch/x86/include/asm/hyperv-tlfs.h
index b8c89265baf0..08e24f552030 100644
--- a/arch/x86/include/asm/hyperv-tlfs.h
+++ b/arch/x86/include/asm/hyperv-tlfs.h
@@ -309,6 +309,7 @@ struct ms_hyperv_tsc_page {
 #define HV_X64_MSR_REENLIGHTENMENT_CONTROL	0x40000106
 
 /* Nested features (CPUID 0x4000000A) EAX */
+#define HV_X64_NESTED_GUEST_MAPPING_FLUSH	BIT(18)
 #define HV_X64_NESTED_MSR_BITMAP		BIT(19)
 
 struct hv_reenlightenment_control {
@@ -350,6 +351,7 @@ struct hv_tsc_emulation_status {
 #define HVCALL_SEND_IPI_EX			0x0015
 #define HVCALL_POST_MESSAGE			0x005c
 #define HVCALL_SIGNAL_EVENT			0x005d
+#define HVCALL_FLUSH_GUEST_PHYSICAL_ADDRESS_SPACE 0x00af
 
 #define HV_X64_MSR_VP_ASSIST_PAGE_ENABLE	0x00000001
 #define HV_X64_MSR_VP_ASSIST_PAGE_ADDRESS_SHIFT	12
@@ -741,6 +743,12 @@ struct ipi_arg_ex {
 	struct hv_vpset vp_set;
 };
 
+/* HvFlushGuestPhysicalAddressSpace hypercalls */
+struct hv_guest_mapping_flush {
+	u64 address_space;
+	u64 flags;
+};
+
 /* HvFlushVirtualAddressSpace, HvFlushVirtualAddressList hypercalls */
 struct hv_tlb_flush {
 	u64 address_space;
diff --git a/arch/x86/include/asm/mshyperv.h b/arch/x86/include/asm/mshyperv.h
index 3cd14311edfa..a6a615b49876 100644
--- a/arch/x86/include/asm/mshyperv.h
+++ b/arch/x86/include/asm/mshyperv.h
@@ -302,6 +302,7 @@ void hyperv_reenlightenment_intr(struct pt_regs *regs);
 void set_hv_tscchange_cb(void (*cb)(void));
 void clear_hv_tscchange_cb(void);
 void hyperv_stop_tsc_emulation(void);
+int hyperv_flush_guest_mapping(u64 as);
 
 #ifdef CONFIG_X86_64
 void hv_apic_init(void);
@@ -321,6 +322,7 @@ static inline struct hv_vp_assist_page *hv_get_vp_assist_page(unsigned int cpu)
 {
 	return NULL;
 }
+static inline int hyperv_flush_guest_mapping(u64 as) { return -1; }
 #endif /* CONFIG_HYPERV */
 
 #ifdef CONFIG_HYPERV_TSCPAGE
-- 
2.14.3

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* RE: [PATCH V3 0/4] KVM/x86/hyper-V: Introduce PV guest address space mapping flush support
  2018-07-19  8:39 [PATCH V3 0/4] KVM/x86/hyper-V: Introduce PV guest address space mapping flush support Tianyu Lan
                   ` (5 preceding siblings ...)
  2018-07-19 13:56 ` [Update PATCH V3 1/4] X86/Hyper-V: Add flush HvFlushGuestPhysicalAddressSpace hypercall support Tianyu Lan
@ 2018-07-20  3:58 ` KY Srinivasan
  2018-07-20  8:31   ` Paolo Bonzini
  6 siblings, 1 reply; 17+ messages in thread
From: KY Srinivasan @ 2018-07-20  3:58 UTC (permalink / raw)
  To: Tianyu Lan
  Cc: devel, Haiyang Zhang, hpa, kvm, linux-kernel, mingo, pbonzini,
	rkrcmar, Stephen Hemminger, tglx, x86, Michael Kelley (EOSG),
	vkuznets



> -----Original Message-----
> From: Tianyu Lan
> Sent: Thursday, July 19, 2018 1:40 AM
> Cc: Tianyu Lan <Tianyu.Lan@microsoft.com>; devel@linuxdriverproject.org;
> Haiyang Zhang <haiyangz@microsoft.com>; hpa@zytor.com;
> kvm@vger.kernel.org; KY Srinivasan <kys@microsoft.com>; linux-
> kernel@vger.kernel.org; mingo@redhat.com; pbonzini@redhat.com;
> rkrcmar@redhat.com; Stephen Hemminger <sthemmin@microsoft.com>;
> tglx@linutronix.de; x86@kernel.org; Michael Kelley (EOSG)
> <Michael.H.Kelley@microsoft.com>; vkuznets@redhat.com
> Subject: [PATCH V3 0/4] KVM/x86/hyper-V: Introduce PV guest address
> space mapping flush support
> 
> Hyper-V provides a para-virtualization hypercall
> HvFlushGuestPhysicalAddressSpace
> to flush nested VM address space mapping in l1 hypervisor and it's to reduce
> overhead
> of flushing ept tlb among vcpus. The tradition way is to send IPIs to all
> affected
> vcpus and executes INVEPT on each vcpus. It will trigger several vmexits for
> IPI and
> INVEPT emulation. The pv hypercall can help to flush specified ept table on all
> vcpus
> via one single hypercall.
> 
> Change since v2:
>        - Make ept_pointers_match as tristate "check", "match" and "mismatch".
>        Set "check" in vmx_set_cr3(), check all ept table pointers in
> hv_remote_flush_tlb()
>        and call hypercall when all ept pointers are same.
>        - Rename kvm_arch_hv_flush_remote_tlb with
> kvm_arch_flush_remote_tlb and
>        Rename kvm_x86_ops->hv_tlb_remote_flush with kvm_x86_ops-
> >tlb_remote_flush
>        - Fix issue that ignore updating tlbs_dirty during calling
> kvm_arch_flush_remote_tlbs()
>        - Merge patch "KVM/VMX: Add identical ept table pointer check" and
>        patch "KVM/x86: Add tlb_remote_flush callback support for vmx"
> 
> Change since v1:
>        - Fix compilation error for non-x86 platform.
>        - Use ept_pointers_match to check condition of identical ept
>             table pointer and get ept pointer from struct vcpu_vmx->ept_pointer.
>        - Add hyperv_nested_flush_guest_mapping ftrace support
> 
> 
> 
> Lan Tianyu (4):
>   X86/Hyper-V: Add flush HvFlushGuestPhysicalAddressSpace hypercall
>     support
>   X86/Hyper-V: Add hyperv_nested_flush_guest_mapping ftrace support
>   KVM: Add tlb remote flush callback in kvm_x86_ops.
>   KVM/x86: Add tlb_remote_flush callback support for vmx
> 
>  arch/x86/hyperv/Makefile            |  2 +-
>  arch/x86/hyperv/nested.c            | 67
> ++++++++++++++++++++++++++++++++++
>  arch/x86/include/asm/hyperv-tlfs.h  |  8 +++++
>  arch/x86/include/asm/kvm_host.h     | 11 ++++++
>  arch/x86/include/asm/mshyperv.h     |  2 ++
>  arch/x86/include/asm/trace/hyperv.h | 14 ++++++++
>  arch/x86/kvm/vmx.c                  | 72
> ++++++++++++++++++++++++++++++++++++-
>  include/linux/kvm_host.h            |  7 ++++
>  virt/kvm/kvm_main.c                 |  3 +-
>  9 files changed, 183 insertions(+), 3 deletions(-)
>  create mode 100644 arch/x86/hyperv/nested.c

Acked-by: K. Y. Srinivasan <kys@microsoft.com>

> 
> --
> 2.14.3

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH V3 0/4] KVM/x86/hyper-V: Introduce PV guest address space mapping flush support
  2018-07-20  3:58 ` [PATCH V3 0/4] KVM/x86/hyper-V: Introduce PV guest address space mapping flush support KY Srinivasan
@ 2018-07-20  8:31   ` Paolo Bonzini
  2018-07-23  7:39       ` Wanpeng Li
  0 siblings, 1 reply; 17+ messages in thread
From: Paolo Bonzini @ 2018-07-20  8:31 UTC (permalink / raw)
  To: KY Srinivasan, Tianyu Lan
  Cc: devel, Haiyang Zhang, hpa, kvm, linux-kernel, mingo, rkrcmar,
	Stephen Hemminger, tglx, x86, Michael Kelley (EOSG),
	vkuznets

On 20/07/2018 05:58, KY Srinivasan wrote:
> 
> 
>> -----Original Message-----
>> From: Tianyu Lan
>> Sent: Thursday, July 19, 2018 1:40 AM
>> Cc: Tianyu Lan <Tianyu.Lan@microsoft.com>; devel@linuxdriverproject.org;
>> Haiyang Zhang <haiyangz@microsoft.com>; hpa@zytor.com;
>> kvm@vger.kernel.org; KY Srinivasan <kys@microsoft.com>; linux-
>> kernel@vger.kernel.org; mingo@redhat.com; pbonzini@redhat.com;
>> rkrcmar@redhat.com; Stephen Hemminger <sthemmin@microsoft.com>;
>> tglx@linutronix.de; x86@kernel.org; Michael Kelley (EOSG)
>> <Michael.H.Kelley@microsoft.com>; vkuznets@redhat.com
>> Subject: [PATCH V3 0/4] KVM/x86/hyper-V: Introduce PV guest address
>> space mapping flush support
>>
>> Hyper-V provides a para-virtualization hypercall
>> HvFlushGuestPhysicalAddressSpace
>> to flush nested VM address space mapping in l1 hypervisor and it's to reduce
>> overhead
>> of flushing ept tlb among vcpus. The tradition way is to send IPIs to all
>> affected
>> vcpus and executes INVEPT on each vcpus. It will trigger several vmexits for
>> IPI and
>> INVEPT emulation. The pv hypercall can help to flush specified ept table on all
>> vcpus
>> via one single hypercall.
>>
>> Change since v2:
>>        - Make ept_pointers_match as tristate "check", "match" and "mismatch".
>>        Set "check" in vmx_set_cr3(), check all ept table pointers in
>> hv_remote_flush_tlb()
>>        and call hypercall when all ept pointers are same.
>>        - Rename kvm_arch_hv_flush_remote_tlb with
>> kvm_arch_flush_remote_tlb and
>>        Rename kvm_x86_ops->hv_tlb_remote_flush with kvm_x86_ops-
>>> tlb_remote_flush
>>        - Fix issue that ignore updating tlbs_dirty during calling
>> kvm_arch_flush_remote_tlbs()
>>        - Merge patch "KVM/VMX: Add identical ept table pointer check" and
>>        patch "KVM/x86: Add tlb_remote_flush callback support for vmx"
>>
>> Change since v1:
>>        - Fix compilation error for non-x86 platform.
>>        - Use ept_pointers_match to check condition of identical ept
>>             table pointer and get ept pointer from struct vcpu_vmx->ept_pointer.
>>        - Add hyperv_nested_flush_guest_mapping ftrace support
>>
>>
>>
>> Lan Tianyu (4):
>>   X86/Hyper-V: Add flush HvFlushGuestPhysicalAddressSpace hypercall
>>     support
>>   X86/Hyper-V: Add hyperv_nested_flush_guest_mapping ftrace support
>>   KVM: Add tlb remote flush callback in kvm_x86_ops.
>>   KVM/x86: Add tlb_remote_flush callback support for vmx
>>
>>  arch/x86/hyperv/Makefile            |  2 +-
>>  arch/x86/hyperv/nested.c            | 67
>> ++++++++++++++++++++++++++++++++++
>>  arch/x86/include/asm/hyperv-tlfs.h  |  8 +++++
>>  arch/x86/include/asm/kvm_host.h     | 11 ++++++
>>  arch/x86/include/asm/mshyperv.h     |  2 ++
>>  arch/x86/include/asm/trace/hyperv.h | 14 ++++++++
>>  arch/x86/kvm/vmx.c                  | 72
>> ++++++++++++++++++++++++++++++++++++-
>>  include/linux/kvm_host.h            |  7 ++++
>>  virt/kvm/kvm_main.c                 |  3 +-
>>  9 files changed, 183 insertions(+), 3 deletions(-)
>>  create mode 100644 arch/x86/hyperv/nested.c
> 
> Acked-by: K. Y. Srinivasan <kys@microsoft.com>

Queued, thanks!

Paolo


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH V3 0/4] KVM/x86/hyper-V: Introduce PV guest address space mapping flush support
  2018-07-20  8:31   ` Paolo Bonzini
@ 2018-07-23  7:39       ` Wanpeng Li
  0 siblings, 0 replies; 17+ messages in thread
From: Wanpeng Li @ 2018-07-23  7:39 UTC (permalink / raw)
  To: Paolo Bonzini
  Cc: K. Y. Srinivasan, Tianyu.Lan, devel, Haiyang Zhang,
	H. Peter Anvin, kvm, LKML, Ingo Molnar, Radim Krcmar,
	Stephen Hemminger, Thomas Gleixner, the arch/x86 maintainers,
	Michael Kelley (EOSG),
	Vitaly Kuznetsov

On Fri, 20 Jul 2018 at 16:32, Paolo Bonzini <pbonzini@redhat.com> wrote:
>
> On 20/07/2018 05:58, KY Srinivasan wrote:
> >
> >
> >> -----Original Message-----
> >> From: Tianyu Lan
> >> Sent: Thursday, July 19, 2018 1:40 AM
> >> Cc: Tianyu Lan <Tianyu.Lan@microsoft.com>; devel@linuxdriverproject.org;
> >> Haiyang Zhang <haiyangz@microsoft.com>; hpa@zytor.com;
> >> kvm@vger.kernel.org; KY Srinivasan <kys@microsoft.com>; linux-
> >> kernel@vger.kernel.org; mingo@redhat.com; pbonzini@redhat.com;
> >> rkrcmar@redhat.com; Stephen Hemminger <sthemmin@microsoft.com>;
> >> tglx@linutronix.de; x86@kernel.org; Michael Kelley (EOSG)
> >> <Michael.H.Kelley@microsoft.com>; vkuznets@redhat.com
> >> Subject: [PATCH V3 0/4] KVM/x86/hyper-V: Introduce PV guest address
> >> space mapping flush support
> >>
> >> Hyper-V provides a para-virtualization hypercall
> >> HvFlushGuestPhysicalAddressSpace
> >> to flush nested VM address space mapping in l1 hypervisor and it's to reduce
> >> overhead
> >> of flushing ept tlb among vcpus. The tradition way is to send IPIs to all
> >> affected
> >> vcpus and executes INVEPT on each vcpus. It will trigger several vmexits for
> >> IPI and
> >> INVEPT emulation. The pv hypercall can help to flush specified ept table on all
> >> vcpus
> >> via one single hypercall.
> >>
> >> Change since v2:
> >>        - Make ept_pointers_match as tristate "check", "match" and "mismatch".
> >>        Set "check" in vmx_set_cr3(), check all ept table pointers in
> >> hv_remote_flush_tlb()
> >>        and call hypercall when all ept pointers are same.
> >>        - Rename kvm_arch_hv_flush_remote_tlb with
> >> kvm_arch_flush_remote_tlb and
> >>        Rename kvm_x86_ops->hv_tlb_remote_flush with kvm_x86_ops-
> >>> tlb_remote_flush
> >>        - Fix issue that ignore updating tlbs_dirty during calling
> >> kvm_arch_flush_remote_tlbs()
> >>        - Merge patch "KVM/VMX: Add identical ept table pointer check" and
> >>        patch "KVM/x86: Add tlb_remote_flush callback support for vmx"
> >>
> >> Change since v1:
> >>        - Fix compilation error for non-x86 platform.
> >>        - Use ept_pointers_match to check condition of identical ept
> >>             table pointer and get ept pointer from struct vcpu_vmx->ept_pointer.
> >>        - Add hyperv_nested_flush_guest_mapping ftrace support
> >>
> >>
> >>
> >> Lan Tianyu (4):
> >>   X86/Hyper-V: Add flush HvFlushGuestPhysicalAddressSpace hypercall
> >>     support
> >>   X86/Hyper-V: Add hyperv_nested_flush_guest_mapping ftrace support
> >>   KVM: Add tlb remote flush callback in kvm_x86_ops.
> >>   KVM/x86: Add tlb_remote_flush callback support for vmx
> >>
> >>  arch/x86/hyperv/Makefile            |  2 +-
> >>  arch/x86/hyperv/nested.c            | 67
> >> ++++++++++++++++++++++++++++++++++
> >>  arch/x86/include/asm/hyperv-tlfs.h  |  8 +++++
> >>  arch/x86/include/asm/kvm_host.h     | 11 ++++++
> >>  arch/x86/include/asm/mshyperv.h     |  2 ++
> >>  arch/x86/include/asm/trace/hyperv.h | 14 ++++++++
> >>  arch/x86/kvm/vmx.c                  | 72
> >> ++++++++++++++++++++++++++++++++++++-
> >>  include/linux/kvm_host.h            |  7 ++++
> >>  virt/kvm/kvm_main.c                 |  3 +-
> >>  9 files changed, 183 insertions(+), 3 deletions(-)
> >>  create mode 100644 arch/x86/hyperv/nested.c
> >
> > Acked-by: K. Y. Srinivasan <kys@microsoft.com>
>
> Queued, thanks!

My CONFIG_HYPERV is disabled, there is a warning when compiling kvm/queue.
warning: ‘hv_remote_flush_tlb’ defined but not used [-Wunused-function]
 static int hv_remote_flush_tlb(struct kvm *kvm)

Regards,
Wanpeng Li

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH V3 0/4] KVM/x86/hyper-V: Introduce PV guest address space mapping flush support
@ 2018-07-23  7:39       ` Wanpeng Li
  0 siblings, 0 replies; 17+ messages in thread
From: Wanpeng Li @ 2018-07-23  7:39 UTC (permalink / raw)
  To: Paolo Bonzini
  Cc: Stephen Hemminger, Tianyu.Lan, kvm, Radim Krcmar, Haiyang Zhang,
	the arch/x86 maintainers, LKML, Michael Kelley (EOSG),
	Ingo Molnar, H. Peter Anvin, devel, Thomas Gleixner,
	Vitaly Kuznetsov

On Fri, 20 Jul 2018 at 16:32, Paolo Bonzini <pbonzini@redhat.com> wrote:
>
> On 20/07/2018 05:58, KY Srinivasan wrote:
> >
> >
> >> -----Original Message-----
> >> From: Tianyu Lan
> >> Sent: Thursday, July 19, 2018 1:40 AM
> >> Cc: Tianyu Lan <Tianyu.Lan@microsoft.com>; devel@linuxdriverproject.org;
> >> Haiyang Zhang <haiyangz@microsoft.com>; hpa@zytor.com;
> >> kvm@vger.kernel.org; KY Srinivasan <kys@microsoft.com>; linux-
> >> kernel@vger.kernel.org; mingo@redhat.com; pbonzini@redhat.com;
> >> rkrcmar@redhat.com; Stephen Hemminger <sthemmin@microsoft.com>;
> >> tglx@linutronix.de; x86@kernel.org; Michael Kelley (EOSG)
> >> <Michael.H.Kelley@microsoft.com>; vkuznets@redhat.com
> >> Subject: [PATCH V3 0/4] KVM/x86/hyper-V: Introduce PV guest address
> >> space mapping flush support
> >>
> >> Hyper-V provides a para-virtualization hypercall
> >> HvFlushGuestPhysicalAddressSpace
> >> to flush nested VM address space mapping in l1 hypervisor and it's to reduce
> >> overhead
> >> of flushing ept tlb among vcpus. The tradition way is to send IPIs to all
> >> affected
> >> vcpus and executes INVEPT on each vcpus. It will trigger several vmexits for
> >> IPI and
> >> INVEPT emulation. The pv hypercall can help to flush specified ept table on all
> >> vcpus
> >> via one single hypercall.
> >>
> >> Change since v2:
> >>        - Make ept_pointers_match as tristate "check", "match" and "mismatch".
> >>        Set "check" in vmx_set_cr3(), check all ept table pointers in
> >> hv_remote_flush_tlb()
> >>        and call hypercall when all ept pointers are same.
> >>        - Rename kvm_arch_hv_flush_remote_tlb with
> >> kvm_arch_flush_remote_tlb and
> >>        Rename kvm_x86_ops->hv_tlb_remote_flush with kvm_x86_ops-
> >>> tlb_remote_flush
> >>        - Fix issue that ignore updating tlbs_dirty during calling
> >> kvm_arch_flush_remote_tlbs()
> >>        - Merge patch "KVM/VMX: Add identical ept table pointer check" and
> >>        patch "KVM/x86: Add tlb_remote_flush callback support for vmx"
> >>
> >> Change since v1:
> >>        - Fix compilation error for non-x86 platform.
> >>        - Use ept_pointers_match to check condition of identical ept
> >>             table pointer and get ept pointer from struct vcpu_vmx->ept_pointer.
> >>        - Add hyperv_nested_flush_guest_mapping ftrace support
> >>
> >>
> >>
> >> Lan Tianyu (4):
> >>   X86/Hyper-V: Add flush HvFlushGuestPhysicalAddressSpace hypercall
> >>     support
> >>   X86/Hyper-V: Add hyperv_nested_flush_guest_mapping ftrace support
> >>   KVM: Add tlb remote flush callback in kvm_x86_ops.
> >>   KVM/x86: Add tlb_remote_flush callback support for vmx
> >>
> >>  arch/x86/hyperv/Makefile            |  2 +-
> >>  arch/x86/hyperv/nested.c            | 67
> >> ++++++++++++++++++++++++++++++++++
> >>  arch/x86/include/asm/hyperv-tlfs.h  |  8 +++++
> >>  arch/x86/include/asm/kvm_host.h     | 11 ++++++
> >>  arch/x86/include/asm/mshyperv.h     |  2 ++
> >>  arch/x86/include/asm/trace/hyperv.h | 14 ++++++++
> >>  arch/x86/kvm/vmx.c                  | 72
> >> ++++++++++++++++++++++++++++++++++++-
> >>  include/linux/kvm_host.h            |  7 ++++
> >>  virt/kvm/kvm_main.c                 |  3 +-
> >>  9 files changed, 183 insertions(+), 3 deletions(-)
> >>  create mode 100644 arch/x86/hyperv/nested.c
> >
> > Acked-by: K. Y. Srinivasan <kys@microsoft.com>
>
> Queued, thanks!

My CONFIG_HYPERV is disabled, there is a warning when compiling kvm/queue.
warning: ‘hv_remote_flush_tlb’ defined but not used [-Wunused-function]
 static int hv_remote_flush_tlb(struct kvm *kvm)

Regards,
Wanpeng Li
_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH V3 0/4] KVM/x86/hyper-V: Introduce PV guest address space mapping flush support
  2018-07-23  7:39       ` Wanpeng Li
  (?)
@ 2018-07-23  7:52       ` Tianyu Lan
  -1 siblings, 0 replies; 17+ messages in thread
From: Tianyu Lan @ 2018-07-23  7:52 UTC (permalink / raw)
  To: Wanpeng Li, Paolo Bonzini
  Cc: KY Srinivasan, Tianyu Lan, devel, Haiyang Zhang, H. Peter Anvin,
	kvm, LKML, Ingo Molnar, Radim Krcmar, Stephen Hemminger,
	Thomas Gleixner, the arch/x86 maintainers, Michael Kelley (EOSG),
	Vitaly Kuznetsov

On 7/23/2018 3:39 PM, Wanpeng Li wrote:
> On Fri, 20 Jul 2018 at 16:32, Paolo Bonzini <pbonzini@redhat.com> wrote:
>>
>> On 20/07/2018 05:58, KY Srinivasan wrote:
>>>
>>>
>>>> -----Original Message-----
>>>> From: Tianyu Lan
>>>> Sent: Thursday, July 19, 2018 1:40 AM
>>>> Cc: Tianyu Lan <Tianyu.Lan@microsoft.com>; devel@linuxdriverproject.org;
>>>> Haiyang Zhang <haiyangz@microsoft.com>; hpa@zytor.com;
>>>> kvm@vger.kernel.org; KY Srinivasan <kys@microsoft.com>; linux-
>>>> kernel@vger.kernel.org; mingo@redhat.com; pbonzini@redhat.com;
>>>> rkrcmar@redhat.com; Stephen Hemminger <sthemmin@microsoft.com>;
>>>> tglx@linutronix.de; x86@kernel.org; Michael Kelley (EOSG)
>>>> <Michael.H.Kelley@microsoft.com>; vkuznets@redhat.com
>>>> Subject: [PATCH V3 0/4] KVM/x86/hyper-V: Introduce PV guest address
>>>> space mapping flush support
>>>>
>>>> Hyper-V provides a para-virtualization hypercall
>>>> HvFlushGuestPhysicalAddressSpace
>>>> to flush nested VM address space mapping in l1 hypervisor and it's to reduce
>>>> overhead
>>>> of flushing ept tlb among vcpus. The tradition way is to send IPIs to all
>>>> affected
>>>> vcpus and executes INVEPT on each vcpus. It will trigger several vmexits for
>>>> IPI and
>>>> INVEPT emulation. The pv hypercall can help to flush specified ept table on all
>>>> vcpus
>>>> via one single hypercall.
>>>>
>>>> Change since v2:
>>>>         - Make ept_pointers_match as tristate "check", "match" and "mismatch".
>>>>         Set "check" in vmx_set_cr3(), check all ept table pointers in
>>>> hv_remote_flush_tlb()
>>>>         and call hypercall when all ept pointers are same.
>>>>         - Rename kvm_arch_hv_flush_remote_tlb with
>>>> kvm_arch_flush_remote_tlb and
>>>>         Rename kvm_x86_ops->hv_tlb_remote_flush with kvm_x86_ops-
>>>>> tlb_remote_flush
>>>>         - Fix issue that ignore updating tlbs_dirty during calling
>>>> kvm_arch_flush_remote_tlbs()
>>>>         - Merge patch "KVM/VMX: Add identical ept table pointer check" and
>>>>         patch "KVM/x86: Add tlb_remote_flush callback support for vmx"
>>>>
>>>> Change since v1:
>>>>         - Fix compilation error for non-x86 platform.
>>>>         - Use ept_pointers_match to check condition of identical ept
>>>>              table pointer and get ept pointer from struct vcpu_vmx->ept_pointer.
>>>>         - Add hyperv_nested_flush_guest_mapping ftrace support
>>>>
>>>>
>>>>
>>>> Lan Tianyu (4):
>>>>    X86/Hyper-V: Add flush HvFlushGuestPhysicalAddressSpace hypercall
>>>>      support
>>>>    X86/Hyper-V: Add hyperv_nested_flush_guest_mapping ftrace support
>>>>    KVM: Add tlb remote flush callback in kvm_x86_ops.
>>>>    KVM/x86: Add tlb_remote_flush callback support for vmx
>>>>
>>>>   arch/x86/hyperv/Makefile            |  2 +-
>>>>   arch/x86/hyperv/nested.c            | 67
>>>> ++++++++++++++++++++++++++++++++++
>>>>   arch/x86/include/asm/hyperv-tlfs.h  |  8 +++++
>>>>   arch/x86/include/asm/kvm_host.h     | 11 ++++++
>>>>   arch/x86/include/asm/mshyperv.h     |  2 ++
>>>>   arch/x86/include/asm/trace/hyperv.h | 14 ++++++++
>>>>   arch/x86/kvm/vmx.c                  | 72
>>>> ++++++++++++++++++++++++++++++++++++-
>>>>   include/linux/kvm_host.h            |  7 ++++
>>>>   virt/kvm/kvm_main.c                 |  3 +-
>>>>   9 files changed, 183 insertions(+), 3 deletions(-)
>>>>   create mode 100644 arch/x86/hyperv/nested.c
>>>
>>> Acked-by: K. Y. Srinivasan <kys@microsoft.com>
>>
>> Queued, thanks!
> 
> My CONFIG_HYPERV is disabled, there is a warning when compiling kvm/queue.
> warning: ‘hv_remote_flush_tlb’ defined but not used [-Wunused-function]
>   static int hv_remote_flush_tlb(struct kvm *kvm)

Thanks. Wanpeng! Just send a fix patch.

> 
> Regards,
> Wanpeng Li
> 

^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2018-07-23  7:52 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-19  8:39 [PATCH V3 0/4] KVM/x86/hyper-V: Introduce PV guest address space mapping flush support Tianyu Lan
2018-07-19  8:40 ` [PATCH V3 1/4] X86/Hyper-V: Add flush HvFlushGuestPhysicalAddressSpace hypercall support Tianyu Lan
2018-07-19 12:05   ` Thomas Gleixner
2018-07-19 12:41     ` Tianyu Lan
2018-07-19 12:54       ` Thomas Gleixner
2018-07-19  8:40 ` [PATCH V3 2/4] X86/Hyper-V: Add hyperv_nested_flush_guest_mapping ftrace support Tianyu Lan
2018-07-19  8:40 ` [PATCH V3 3/4] KVM: Add tlb remote flush callback in kvm_x86_ops Tianyu Lan
2018-07-19  8:40 ` [PATCH V3 4/4] KVM/x86: Add tlb_remote_flush callback support for vmx Tianyu Lan
2018-07-19  8:57 ` [PATCH V3 0/4] KVM/x86/hyper-V: Introduce PV guest address space mapping flush support Paolo Bonzini
2018-07-19  9:31   ` Tianyu Lan
2018-07-19  9:31     ` Tianyu Lan
2018-07-19 13:56 ` [Update PATCH V3 1/4] X86/Hyper-V: Add flush HvFlushGuestPhysicalAddressSpace hypercall support Tianyu Lan
2018-07-20  3:58 ` [PATCH V3 0/4] KVM/x86/hyper-V: Introduce PV guest address space mapping flush support KY Srinivasan
2018-07-20  8:31   ` Paolo Bonzini
2018-07-23  7:39     ` Wanpeng Li
2018-07-23  7:39       ` Wanpeng Li
2018-07-23  7:52       ` Tianyu Lan

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.