Skip to contentSkip to conversation

KVM: x86: hyperv: PV IPI support for Windows guests

PATCH Superseded Vitaly Kuznetsov 2 participants 11 messages Jun 29, 2018

Subsystems (6)
Documentation x86 KVM KVM x86 +2 more subsystems

v3 of 6 Superseded Latest is v6 →

lore
Share & tools
lore

Vitaly Kuznetsov

author maintainer
#0 lore raw

v3 cover KVM: x86: hyperv: PV IPI support for Windows guests

Changes since v1 [Roman Kagan]:
- Drop vp_index_to_vcpu_idx mapping. get_vcpu_by_vpidx() should be fast (1:1 mapping) in all valid use-cases. We'll optimize it later if needed (or at least discuss this in a separate patchset).
- "enforce vp_index < KVM_MAX_VCPUS" patch added.
- Issues reported by kbuild are now gone with the PATCH2 from v2.

Using hypercall for sending IPIs is faster because this allows to specify any number of vCPUs (even > 64 with sparse CPU set), the whole procedure will take only one VMEXIT.

Same as PV TLB flush, this allows Windows guests having > 64 vCPUs to boot on KVM when Hyper-V extensions are enabled.

Vitaly Kuznetsov (5):
KVM: x86: hyperv: enforce vp_index < KVM_MAX_VCPUS
KVM: x86: hyperv: optimize 'all cpus' case in kvm_hv_flush_tlb()
KVM: x86: hyperv: use get_vcpu_by_vpidx() in kvm_hv_flush_tlb() x86/hyper-v: rename ipi_arg_{ex,non_ex} structures
KVM: x86: hyperv: implement PV IPI send hypercalls

 Documentation/virtual/kvm/api.txt  |   8 ++
 arch/x86/hyperv/hv_apic.c          |  12 +--
 arch/x86/include/asm/hyperv-tlfs.h |  16 +--
 arch/x86/kvm/hyperv.c              | 194 +++++++++++++++++++++++++++----------
 arch/x86/kvm/trace.h               |  42 ++++++++
 arch/x86/kvm/x86.c                 |   1 +
 include/uapi/linux/kvm.h           |   1 +
 virt/kvm/kvm_main.c                |   6 +-
 8 files changed, 210 insertions(+), 70 deletions(-)
Signature · 1 line
2.14.4
author maintainer
#1 lore raw

PATCH v3 1/5 KVM: x86: hyperv: enforce vp_index < KVM_MAX_VCPUS

Hyper-V TLFS (5.0b) states:

Quoted 5 lines

Virtual processors are identified by using an index (VP index). The maximum number of virtual processors per partition supported by the current implementation of the hypervisor can be obtained through CPUID leaf 0x40000005. A virtual processor index must be less than the maximum number of virtual processors per partition.

Forbid userspace to set VP_INDEX above KVM_MAX_VCPUS. get_vcpu_by_vpidx() can now be optimized to bail early when supplied vpidx is >= KVM_MAX_VCPUS.

---
 arch/x86/kvm/hyperv.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
arch/x86/kvm/hyperv.c +5 -3
index af8caf965baa..ceaa7fb10c49 100644
@@ -132,8 +132,10 @@ static struct kvm_vcpu *get_vcpu_by_vpidx(struct kvm *kvm, u32 vpidx)
 	struct kvm_vcpu *vcpu = NULL;
 	int i;
 
-	if (vpidx < KVM_MAX_VCPUS)
-		vcpu = kvm_get_vcpu(kvm, vpidx);
+	if (vpidx >= KVM_MAX_VCPUS)
+		return NULL;
+
+	vcpu = kvm_get_vcpu(kvm, vpidx);
 	if (vcpu && vcpu_to_hv_vcpu(vcpu)->vp_index == vpidx)
 		return vcpu;
 	kvm_for_each_vcpu(i, vcpu, kvm)
@@ -1038,7 +1040,7 @@ static int kvm_hv_set_msr(struct kvm_vcpu *vcpu, u32 msr, u64 data, bool host)
 
 	switch (msr) {
 	case HV_X64_MSR_VP_INDEX:
-		if (!host)
+		if (!host || (u32)data >= KVM_MAX_VCPUS)
 			return 1;
 		hv->vp_index = (u32)data;
 		break;
Signature · 1 line
2.14.4
author maintainer
#2 lore raw

PATCH v3 2/5 KVM: x86: hyperv: optimize 'all cpus' case in kvm_hv_flush_tlb()

In reply to Vitaly Kuznetsov

We can use 'NULL' to represent 'all cpus' case in kvm_make_vcpus_request_mask() and avoid building vCPU mask with all vCPUs.

---
 arch/x86/kvm/hyperv.c | 42 +++++++++++++++++++++++-------------------
 virt/kvm/kvm_main.c   |  6 ++----
 2 files changed, 25 insertions(+), 23 deletions(-)
arch/x86/kvm/hyperv.c +23 -19
index ceaa7fb10c49..c5b921c0a467 100644
@@ -1312,35 +1312,39 @@ static u64 kvm_hv_flush_tlb(struct kvm_vcpu *current_vcpu, u64 ingpa,
 
 	cpumask_clear(&hv_current->tlb_lush);
 
+	if (all_cpus) {
+		kvm_make_vcpus_request_mask(kvm,
+				    KVM_REQ_TLB_FLUSH | KVM_REQUEST_NO_WAKEUP,
+				    NULL, &hv_current->tlb_lush);
+		goto ret_success;
+	}
+
 	kvm_for_each_vcpu(i, vcpu, kvm) {
 		struct kvm_vcpu_hv *hv = &vcpu->arch.hyperv;
 		int bank = hv->vp_index / 64, sbank = 0;
 
-		if (!all_cpus) {
-			/* Banks >64 can't be represented */
-			if (bank >= 64)
-				continue;
-
-			/* Non-ex hypercalls can only address first 64 vCPUs */
-			if (!ex && bank)
-				continue;
+		/* Banks >64 can't be represented */
+		if (bank >= 64)
+			continue;
 
-			if (ex) {
-				/*
-				 * Check is the bank of this vCPU is in sparse
-				 * set and get the sparse bank number.
-				 */
-				sbank = get_sparse_bank_no(valid_bank_mask,
-							   bank);
+		/* Non-ex hypercalls can only address first 64 vCPUs */
+		if (!ex && bank)
+			continue;
 
-				if (sbank < 0)
-					continue;
-			}
+		if (ex) {
+			/*
+			 * Check is the bank of this vCPU is in sparse
+			 * set and get the sparse bank number.
+			 */
+			sbank = get_sparse_bank_no(valid_bank_mask, bank);
 
-			if (!(sparse_banks[sbank] & BIT_ULL(hv->vp_index % 64)))
+			if (sbank < 0)
 				continue;
 		}
 
+		if (!(sparse_banks[sbank] & BIT_ULL(hv->vp_index % 64)))
+			continue;
+
 		/*
 		 * vcpu->arch.cr3 may not be up-to-date for running vCPUs so we
 		 * can't analyze it here, flush TLB regardless of the specified
virt/kvm/kvm_main.c +2 -4
index ada21f47f22b..153f14e91fb1 100644
@@ -213,7 +213,7 @@ bool kvm_make_vcpus_request_mask(struct kvm *kvm, unsigned int req,
 	me = get_cpu();
 
 	kvm_for_each_vcpu(i, vcpu, kvm) {
-		if (!test_bit(i, vcpu_bitmap))
+		if (vcpu_bitmap && !test_bit(i, vcpu_bitmap))
 			continue;
 
 		kvm_make_request(req, vcpu);
@@ -237,12 +237,10 @@ bool kvm_make_all_cpus_request(struct kvm *kvm, unsigned int req)
 {
 	cpumask_var_t cpus;
 	bool called;
-	static unsigned long vcpu_bitmap[BITS_TO_LONGS(KVM_MAX_VCPUS)]
-		= {[0 ... BITS_TO_LONGS(KVM_MAX_VCPUS)-1] = ULONG_MAX};
 
 	zalloc_cpumask_var(&cpus, GFP_ATOMIC);
 
-	called = kvm_make_vcpus_request_mask(kvm, req, vcpu_bitmap, cpus);
+	called = kvm_make_vcpus_request_mask(kvm, req, NULL, cpus);
 
 	free_cpumask_var(cpus);
 	return called;
Signature · 1 line
2.14.4
author maintainer
#3 lore raw

PATCH v3 3/5 KVM: x86: hyperv: use get_vcpu_by_vpidx() in kvm_hv_flush_tlb()

In reply to Vitaly Kuznetsov

VP_INDEX almost always matches VCPU id and get_vcpu_by_vpidx() is fast, use it instead of traversing full vCPU list every time.

To support the change switch kvm_make_vcpus_request_mask() to checking vcpu_id instead of vcpu index, kvm_hv_flush_tlb() is currently the only user with non-NULL vcpu_bitmap.

---
 arch/x86/kvm/hyperv.c | 60 +++++++++++++++------------------------------------
 virt/kvm/kvm_main.c   |  2 +-
 2 files changed, 18 insertions(+), 44 deletions(-)
arch/x86/kvm/hyperv.c +17 -43
index c5b921c0a467..3401da849265 100644
@@ -1244,20 +1244,6 @@ int kvm_hv_get_msr_common(struct kvm_vcpu *vcpu, u32 msr, u64 *pdata)
 		return kvm_hv_get_msr(vcpu, msr, pdata);
 }
 
-static __always_inline int get_sparse_bank_no(u64 valid_bank_mask, int bank_no)
-{
-	int i = 0, j;
-
-	if (!(valid_bank_mask & BIT_ULL(bank_no)))
-		return -1;
-
-	for (j = 0; j < bank_no; j++)
-		if (valid_bank_mask & BIT_ULL(j))
-			i++;
-
-	return i;
-}
-
 static u64 kvm_hv_flush_tlb(struct kvm_vcpu *current_vcpu, u64 ingpa,
 			    u16 rep_cnt, bool ex)
 {
@@ -1265,11 +1251,10 @@ static u64 kvm_hv_flush_tlb(struct kvm_vcpu *current_vcpu, u64 ingpa,
 	struct kvm_vcpu_hv *hv_current = &current_vcpu->arch.hyperv;
 	struct hv_tlb_flush_ex flush_ex;
 	struct hv_tlb_flush flush;
-	struct kvm_vcpu *vcpu;
 	unsigned long vcpu_bitmap[BITS_TO_LONGS(KVM_MAX_VCPUS)] = {0};
-	unsigned long valid_bank_mask = 0;
+	unsigned long valid_bank_mask;
 	u64 sparse_banks[64];
-	int sparse_banks_len, i;
+	int sparse_banks_len, bank, i;
 	bool all_cpus;
 
 	if (!ex) {
@@ -1279,6 +1264,7 @@ static u64 kvm_hv_flush_tlb(struct kvm_vcpu *current_vcpu, u64 ingpa,
 		trace_kvm_hv_flush_tlb(flush.processor_mask,
 				       flush.address_space, flush.flags);
 
+		valid_bank_mask = BIT_ULL(0);
 		sparse_banks[0] = flush.processor_mask;
 		all_cpus = flush.flags & HV_FLUSH_ALL_PROCESSORS;
 	} else {
@@ -1319,38 +1305,26 @@ static u64 kvm_hv_flush_tlb(struct kvm_vcpu *current_vcpu, u64 ingpa,
 		goto ret_success;
 	}
 
-	kvm_for_each_vcpu(i, vcpu, kvm) {
-		struct kvm_vcpu_hv *hv = &vcpu->arch.hyperv;
-		int bank = hv->vp_index / 64, sbank = 0;
+	for_each_set_bit(bank, (unsigned long *)&valid_bank_mask,
+			 BITS_PER_LONG) {
 
-		/* Banks >64 can't be represented */
-		if (bank >= 64)
-			continue;
+		for_each_set_bit(i, (unsigned long *)&sparse_banks[bank],
+				 BITS_PER_LONG) {
+			u32 vp_index = bank * 64 + i;
+			struct kvm_vcpu *vcpu =
+				get_vcpu_by_vpidx(kvm, vp_index);
 
-		/* Non-ex hypercalls can only address first 64 vCPUs */
-		if (!ex && bank)
-			continue;
+			/* A non-existent vCPU was specified */
+			if (!vcpu)
+				return HV_STATUS_INVALID_HYPERCALL_INPUT;
 
-		if (ex) {
 			/*
-			 * Check is the bank of this vCPU is in sparse
-			 * set and get the sparse bank number.
+			 * vcpu->arch.cr3 may not be up-to-date for running
+			 * vCPUs so we can't analyze it here, flush TLB
+			 * regardless of the specified address space.
 			 */
-			sbank = get_sparse_bank_no(valid_bank_mask, bank);
-
-			if (sbank < 0)
-				continue;
+			__set_bit(vcpu->vcpu_id, vcpu_bitmap);
 		}
-
-		if (!(sparse_banks[sbank] & BIT_ULL(hv->vp_index % 64)))
-			continue;
-
-		/*
-		 * vcpu->arch.cr3 may not be up-to-date for running vCPUs so we
-		 * can't analyze it here, flush TLB regardless of the specified
-		 * address space.
-		 */
-		__set_bit(i, vcpu_bitmap);
 	}
 
 	kvm_make_vcpus_request_mask(kvm,
virt/kvm/kvm_main.c +1 -1
index 153f14e91fb1..b1971d2c8b44 100644
@@ -213,7 +213,7 @@ bool kvm_make_vcpus_request_mask(struct kvm *kvm, unsigned int req,
 	me = get_cpu();
 
 	kvm_for_each_vcpu(i, vcpu, kvm) {
-		if (vcpu_bitmap && !test_bit(i, vcpu_bitmap))
+		if (vcpu_bitmap && !test_bit(vcpu->vcpu_id, vcpu_bitmap))
 			continue;
 
 		kvm_make_request(req, vcpu);
Signature · 1 line
2.14.4
#4 lore raw

Re: [PATCH v3 3/5] KVM: x86: hyperv: use get_vcpu_by_vpidx() in kvm_hv_flush_tlb()

Quoted 5 lines · Vitaly Kuznetsov

VP_INDEX almost always matches VCPU id and get_vcpu_by_vpidx() is fast, use it instead of traversing full vCPU list every time.

To support the change switch kvm_make_vcpus_request_mask() to checking vcpu_id instead of vcpu index,

I'm afraid you can't do this: vcpu_id (== apic id) can be sparse, i.e. it's not very well suited for bitmaps and can exceed the max number of vcpus.

Roman.

author maintainer
#5 lore raw

Re: [PATCH v3 3/5] KVM: x86: hyperv: use get_vcpu_by_vpidx() in kvm_hv_flush_tlb()

Quoted 10 lines · Roman Kagan
Quoted 5 lines · Vitaly Kuznetsov

VP_INDEX almost always matches VCPU id and get_vcpu_by_vpidx() is fast, use it instead of traversing full vCPU list every time.

To support the change switch kvm_make_vcpus_request_mask() to checking vcpu_id instead of vcpu index,

I'm afraid you can't do this: vcpu_id (== apic id) can be sparse, i.e. it's not very well suited for bitmaps and can exceed the max number of vcpus.

True. The bitmap should be of KVM_MAX_VCPU_ID size, not KVM_MAX_VCPUS.

Unfortunately there's no convenient way to get VCPU idx from VCPU id, kvm_vcpu_get_idx() just walks the whole list :-( I see two possible options:
1) Add vcpu_idx fields to struct kvm_vcpu
2) Keep the change expecting masks of KVM_MAX_VCPU_ID in kvm_make_vcpus_request_mask(). KVM_MAX_VCPU_ID is currently 1023 so our bitmaps will be 16 longs long. Not sure if it's too much.

Signature · 1 line
  Vitaly
#6 lore raw

Re: [PATCH v3 3/5] KVM: x86: hyperv: use get_vcpu_by_vpidx() in kvm_hv_flush_tlb()

Quoted 16 lines · Vitaly Kuznetsov
Quoted 10 lines · Roman Kagan
Quoted 5 lines · Vitaly Kuznetsov

VP_INDEX almost always matches VCPU id and get_vcpu_by_vpidx() is fast, use it instead of traversing full vCPU list every time.

To support the change switch kvm_make_vcpus_request_mask() to checking vcpu_id instead of vcpu index,

I'm afraid you can't do this: vcpu_id (== apic id) can be sparse, i.e. it's not very well suited for bitmaps and can exceed the max number of vcpus.

True. The bitmap should be of KVM_MAX_VCPU_ID size, not KVM_MAX_VCPUS.

Quoted 7 lines

Unfortunately there's no convenient way to get VCPU idx from VCPU id, kvm_vcpu_get_idx() just walks the whole list :-( I see two possible options:
1) Add vcpu_idx fields to struct kvm_vcpu
2) Keep the change expecting masks of KVM_MAX_VCPU_ID in kvm_make_vcpus_request_mask(). KVM_MAX_VCPU_ID is currently 1023 so our bitmaps will be 16 longs long. Not sure if it's too much.

3) rework get_vcpu_by_vpidx into get_vcpu_idx_by_vpidx followed by get_cpu, and use the former for your purposes
4) duplicate get_vcpu_by_vpidx logic in get_vcpu_idx_by_vpidx

Roman.

P.S. I'm starting to wonder how safe this get_vcpu_* thing is WRT vcpu removal, but that's a different story anyway.

author maintainer
#7 lore raw

Re: [PATCH v3 3/5] KVM: x86: hyperv: use get_vcpu_by_vpidx() in kvm_hv_flush_tlb()

Quoted 25 lines · Roman Kagan
Quoted 16 lines · Vitaly Kuznetsov
Quoted 10 lines · Roman Kagan
Quoted 5 lines · Vitaly Kuznetsov

VP_INDEX almost always matches VCPU id and get_vcpu_by_vpidx() is fast, use it instead of traversing full vCPU list every time.

To support the change switch kvm_make_vcpus_request_mask() to checking vcpu_id instead of vcpu index,

I'm afraid you can't do this: vcpu_id (== apic id) can be sparse, i.e. it's not very well suited for bitmaps and can exceed the max number of vcpus.

True. The bitmap should be of KVM_MAX_VCPU_ID size, not KVM_MAX_VCPUS.

Quoted 7 lines

Unfortunately there's no convenient way to get VCPU idx from VCPU id, kvm_vcpu_get_idx() just walks the whole list :-( I see two possible options:
1) Add vcpu_idx fields to struct kvm_vcpu
2) Keep the change expecting masks of KVM_MAX_VCPU_ID in kvm_make_vcpus_request_mask(). KVM_MAX_VCPU_ID is currently 1023 so our bitmaps will be 16 longs long. Not sure if it's too much.

Quoted 3 lines

3) rework get_vcpu_by_vpidx into get_vcpu_idx_by_vpidx followed by get_cpu, and use the former for your purposes
4) duplicate get_vcpu_by_vpidx logic in get_vcpu_idx_by_vpidx

Oh, true, thanks!

Quoted 5 lines

Roman.

P.S. I'm starting to wonder how safe this get_vcpu_* thing is WRT vcpu removal, but that's a different story anyway.

As there's no CPU removal in real Hyper-V I'd expect us to find a number of issues with Windows guests if we go down this road :-)

Signature · 1 line
  Vitaly
#8 lore raw

Re: [PATCH v3 3/5] KVM: x86: hyperv: use get_vcpu_by_vpidx() in kvm_hv_flush_tlb()

In reply to Roman Kagan
Quoted 25 lines · Roman Kagan
Quoted 16 lines · Vitaly Kuznetsov
Quoted 10 lines · Roman Kagan
Quoted 5 lines · Vitaly Kuznetsov

VP_INDEX almost always matches VCPU id and get_vcpu_by_vpidx() is fast, use it instead of traversing full vCPU list every time.

To support the change switch kvm_make_vcpus_request_mask() to checking vcpu_id instead of vcpu index,

I'm afraid you can't do this: vcpu_id (== apic id) can be sparse, i.e. it's not very well suited for bitmaps and can exceed the max number of vcpus.

True. The bitmap should be of KVM_MAX_VCPU_ID size, not KVM_MAX_VCPUS.

Quoted 7 lines

Unfortunately there's no convenient way to get VCPU idx from VCPU id, kvm_vcpu_get_idx() just walks the whole list :-( I see two possible options:
1) Add vcpu_idx fields to struct kvm_vcpu
2) Keep the change expecting masks of KVM_MAX_VCPU_ID in kvm_make_vcpus_request_mask(). KVM_MAX_VCPU_ID is currently 1023 so our bitmaps will be 16 longs long. Not sure if it's too much.

Quoted 2 lines

3) rework get_vcpu_by_vpidx into get_vcpu_idx_by_vpidx followed by get_cpu, and use the former for your purposes

s/get_cpu/kvm_get_vcpu/ of course

Quoted 6 lines

4) duplicate get_vcpu_by_vpidx logic in get_vcpu_idx_by_vpidx

Roman.

P.S. I'm starting to wonder how safe this get_vcpu_* thing is WRT vcpu removal, but that's a different story anyway.

author maintainer
#9 lore raw

PATCH v3 4/5 x86/hyper-v: rename ipi_arg_{ex,non_ex} structures

In reply to Vitaly Kuznetsov

These structures are going to be used from KVM code so let's make their names reflect their Hyper-V origin.

---
 arch/x86/hyperv/hv_apic.c          | 12 ++++++------
 arch/x86/include/asm/hyperv-tlfs.h | 16 +++++++++-------
 2 files changed, 15 insertions(+), 13 deletions(-)
arch/x86/hyperv/hv_apic.c +6 -6
index f68855499391..cb17168e6263 100644
@@ -93,14 +93,14 @@ static void hv_apic_eoi_write(u32 reg, u32 val)
  */
 static bool __send_ipi_mask_ex(const struct cpumask *mask, int vector)
 {
-	struct ipi_arg_ex **arg;
-	struct ipi_arg_ex *ipi_arg;
+	struct hv_send_ipi_ex **arg;
+	struct hv_send_ipi_ex *ipi_arg;
 	unsigned long flags;
 	int nr_bank = 0;
 	int ret = 1;
 
 	local_irq_save(flags);
-	arg = (struct ipi_arg_ex **)this_cpu_ptr(hyperv_pcpu_input_arg);
+	arg = (struct hv_send_ipi_ex **)this_cpu_ptr(hyperv_pcpu_input_arg);
 
 	ipi_arg = *arg;
 	if (unlikely(!ipi_arg))
@@ -128,8 +128,8 @@ static bool __send_ipi_mask_ex(const struct cpumask *mask, int vector)
 static bool __send_ipi_mask(const struct cpumask *mask, int vector)
 {
 	int cur_cpu, vcpu;
-	struct ipi_arg_non_ex **arg;
-	struct ipi_arg_non_ex *ipi_arg;
+	struct hv_send_ipi **arg;
+	struct hv_send_ipi *ipi_arg;
 	int ret = 1;
 	unsigned long flags;
 
@@ -146,7 +146,7 @@ static bool __send_ipi_mask(const struct cpumask *mask, int vector)
 		return __send_ipi_mask_ex(mask, vector);
 
 	local_irq_save(flags);
-	arg = (struct ipi_arg_non_ex **)this_cpu_ptr(hyperv_pcpu_input_arg);
+	arg = (struct hv_send_ipi **)this_cpu_ptr(hyperv_pcpu_input_arg);
 
 	ipi_arg = *arg;
 	if (unlikely(!ipi_arg))
arch/x86/include/asm/hyperv-tlfs.h +9 -7
index b8c89265baf0..b52c9604b20d 100644
@@ -723,19 +723,21 @@ struct hv_enlightened_vmcs {
 #define HV_STIMER_AUTOENABLE		(1ULL << 3)
 #define HV_STIMER_SINT(config)		(__u8)(((config) >> 16) & 0x0F)
 
-struct ipi_arg_non_ex {
-	u32 vector;
-	u32 reserved;
-	u64 cpu_mask;
-};
-
 struct hv_vpset {
 	u64 format;
 	u64 valid_bank_mask;
 	u64 bank_contents[];
 };
 
-struct ipi_arg_ex {
+/* HvCallSendSyntheticClusterIpi hypercall */
+struct hv_send_ipi {
+	u32 vector;
+	u32 reserved;
+	u64 cpu_mask;
+};
+
+/* HvCallSendSyntheticClusterIpiEx hypercall */
+struct hv_send_ipi_ex {
 	u32 vector;
 	u32 reserved;
 	struct hv_vpset vp_set;
Signature · 1 line
2.14.4
author maintainer
#10 lore raw

PATCH v3 5/5 KVM: x86: hyperv: implement PV IPI send hypercalls

In reply to Vitaly Kuznetsov

Using hypercall for sending IPIs is faster because this allows to specify any number of vCPUs (even > 64 with sparse CPU set), the whole procedure will take only one VMEXIT.

Current Hyper-V TLFS (v5.0b) claims that HvCallSendSyntheticClusterIpi hypercall can't be 'fast' (passing parameters through registers) but apparently this is not true, Windows always uses it as 'fast' so we need to support that.

---
 Documentation/virtual/kvm/api.txt |   8 +++
 arch/x86/kvm/hyperv.c             | 108 ++++++++++++++++++++++++++++++++++++++
 arch/x86/kvm/trace.h              |  42 +++++++++++++++
 arch/x86/kvm/x86.c                |   1 +
 include/uapi/linux/kvm.h          |   1 +
 5 files changed, 160 insertions(+)
Documentation/virtual/kvm/api.txt +8 -0
index 495b7742ab58..1f3a9ea6a59c 100644
@@ -4618,3 +4618,11 @@ This capability indicates that KVM supports paravirtualized Hyper-V TLB Flush
 hypercalls:
 HvFlushVirtualAddressSpace, HvFlushVirtualAddressSpaceEx,
 HvFlushVirtualAddressList, HvFlushVirtualAddressListEx.
+
+8.19 KVM_CAP_HYPERV_SEND_IPI
+
+Architectures: x86
+
+This capability indicates that KVM supports paravirtualized Hyper-V IPI send
+hypercalls:
+HvCallSendSyntheticClusterIpi, HvCallSendSyntheticClusterIpiEx.
arch/x86/kvm/hyperv.c +108 -0

120 lines not on this page · raw message

arch/x86/kvm/trace.h +42 -0

48 lines not on this page · raw message

arch/x86/kvm/x86.c +1 -0
index 0046aa70205a..1884b66de9c2 100644
@@ -2874,6 +2874,7 @@ int kvm_vm_ioctl_check_extension(struct kvm *kvm, long ext)
 	case KVM_CAP_HYPERV_VP_INDEX:
 	case KVM_CAP_HYPERV_EVENTFD:
 	case KVM_CAP_HYPERV_TLBFLUSH:
+	case KVM_CAP_HYPERV_SEND_IPI:
 	case KVM_CAP_PCI_SEGMENT:
 	case KVM_CAP_DEBUGREGS:
 	case KVM_CAP_X86_ROBUST_SINGLESTEP:
include/uapi/linux/kvm.h +1 -0
index b6270a3b38e9..adce915f80a5 100644
@@ -949,6 +949,7 @@ struct kvm_ppc_resize_hpt {
 #define KVM_CAP_GET_MSR_FEATURES 153
 #define KVM_CAP_HYPERV_EVENTFD 154
 #define KVM_CAP_HYPERV_TLBFLUSH 155
+#define KVM_CAP_HYPERV_SEND_IPI 156
 
 #ifdef KVM_CAP_IRQ_ROUTING
 
Signature · 1 line
2.14.4