linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/1] X86/Hyper-V:: Fix the circular dependency in IPI enlightenment.
@ 2018-07-03 23:01 kys
  2018-07-04  8:54 ` [tip:x86/urgent] x86/hyper-v: " tip-bot for K. Y. Srinivasan
                   ` (3 more replies)
  0 siblings, 4 replies; 17+ messages in thread
From: kys @ 2018-07-03 23:01 UTC (permalink / raw)
  To: x86, gregkh, linux-kernel, devel, olaf, apw, jasowang, tglx, hpa,
	sthemmin, Michael.H.Kelley, vkuznets
  Cc: K. Y. Srinivasan

From: "K. Y. Srinivasan" <kys@microsoft.com>

The IPI hypercalls depend on being able to map the Linux notion of CPU ID
to the hypervisor's notion of the CPU ID. The array hv_vp_index[] provides
this mapping. Code for populating this array depends on the IPI functionality.
Break this circular dependency.

Fixes: 68bb7bfb7985 ("X86/Hyper-V: Enable IPI enlightenments")

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Tested-by: Michael Kelley <mikelley@microsoft.com>
---
 arch/x86/hyperv/hv_apic.c       | 5 +++++
 arch/x86/hyperv/hv_init.c       | 5 ++++-
 arch/x86/include/asm/mshyperv.h | 2 ++
 3 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/arch/x86/hyperv/hv_apic.c b/arch/x86/hyperv/hv_apic.c
index f68855499391..63d7c196739f 100644
--- a/arch/x86/hyperv/hv_apic.c
+++ b/arch/x86/hyperv/hv_apic.c
@@ -114,6 +114,8 @@ static bool __send_ipi_mask_ex(const struct cpumask *mask, int vector)
 		ipi_arg->vp_set.format = HV_GENERIC_SET_SPARSE_4K;
 		nr_bank = cpumask_to_vpset(&(ipi_arg->vp_set), mask);
 	}
+	if (nr_bank == -1)
+		goto ipi_mask_ex_done;
 	if (!nr_bank)
 		ipi_arg->vp_set.format = HV_GENERIC_SET_ALL;
 
@@ -158,6 +160,9 @@ static bool __send_ipi_mask(const struct cpumask *mask, int vector)
 
 	for_each_cpu(cur_cpu, mask) {
 		vcpu = hv_cpu_number_to_vp_number(cur_cpu);
+		if (vcpu == -1)
+			goto ipi_mask_done;
+
 		/*
 		 * This particular version of the IPI hypercall can
 		 * only target upto 64 CPUs.
diff --git a/arch/x86/hyperv/hv_init.c b/arch/x86/hyperv/hv_init.c
index 4c431e1c1eff..04159893702e 100644
--- a/arch/x86/hyperv/hv_init.c
+++ b/arch/x86/hyperv/hv_init.c
@@ -265,7 +265,7 @@ void __init hyperv_init(void)
 {
 	u64 guest_id, required_msrs;
 	union hv_x64_msr_hypercall_contents hypercall_msr;
-	int cpuhp;
+	int cpuhp, i;
 
 	if (x86_hyper_type != X86_HYPER_MS_HYPERV)
 		return;
@@ -293,6 +293,9 @@ void __init hyperv_init(void)
 	if (!hv_vp_index)
 		return;
 
+	for (i = 0; i < num_possible_cpus(); i++)
+		hv_vp_index[i] = -1;
+
 	hv_vp_assist_page = kcalloc(num_possible_cpus(),
 				    sizeof(*hv_vp_assist_page), GFP_KERNEL);
 	if (!hv_vp_assist_page) {
diff --git a/arch/x86/include/asm/mshyperv.h b/arch/x86/include/asm/mshyperv.h
index 3cd14311edfa..dee3f7347253 100644
--- a/arch/x86/include/asm/mshyperv.h
+++ b/arch/x86/include/asm/mshyperv.h
@@ -281,6 +281,8 @@ static inline int cpumask_to_vpset(struct hv_vpset *vpset,
 	 */
 	for_each_cpu(cpu, cpus) {
 		vcpu = hv_cpu_number_to_vp_number(cpu);
+		if (vcpu == -1)
+			return -1;
 		vcpu_bank = vcpu / 64;
 		vcpu_offset = vcpu % 64;
 		__set_bit(vcpu_offset, (unsigned long *)
-- 
2.17.1


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

* [tip:x86/urgent] x86/hyper-v: Fix the circular dependency in IPI enlightenment
  2018-07-03 23:01 [PATCH 1/1] X86/Hyper-V:: Fix the circular dependency in IPI enlightenment kys
@ 2018-07-04  8:54 ` tip-bot for K. Y. Srinivasan
  2018-07-04  9:13 ` [PATCH 1/1] X86/Hyper-V:: " Vitaly Kuznetsov
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 17+ messages in thread
From: tip-bot for K. Y. Srinivasan @ 2018-07-04  8:54 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: mikelley, peterz, hpa, linux-kernel, kys, tglx, torvalds, mingo

Commit-ID:  5e6f19db2deca9e7eaa378447c77616b35693399
Gitweb:     https://git.kernel.org/tip/5e6f19db2deca9e7eaa378447c77616b35693399
Author:     K. Y. Srinivasan <kys@microsoft.com>
AuthorDate: Tue, 3 Jul 2018 16:01:55 -0700
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Wed, 4 Jul 2018 10:50:03 +0200

x86/hyper-v: Fix the circular dependency in IPI enlightenment

The IPI hypercalls depend on being able to map the Linux notion of CPU ID
to the hypervisor's notion of the CPU ID. The array hv_vp_index[] provides
this mapping. Code for populating this array depends on the IPI functionality.
Break this circular dependency.

Tested-by: Michael Kelley <mikelley@microsoft.com>
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Acked-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Michael.H.Kelley@microsoft.com
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: apw@canonical.com
Cc: devel@linuxdriverproject.org
Cc: gregkh@linuxfoundation.org
Cc: jasowang@redhat.com
Cc: olaf@aepfle.de
Cc: sthemmin@microsoft.com
Cc: vkuznets@redhat.com
Fixes: 68bb7bfb7985 ("X86/Hyper-V: Enable IPI enlightenments")
Link: http://lkml.kernel.org/r/20180703230155.15160-1-kys@linuxonhyperv.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 arch/x86/hyperv/hv_apic.c       | 5 +++++
 arch/x86/hyperv/hv_init.c       | 5 ++++-
 arch/x86/include/asm/mshyperv.h | 2 ++
 3 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/arch/x86/hyperv/hv_apic.c b/arch/x86/hyperv/hv_apic.c
index f68855499391..63d7c196739f 100644
--- a/arch/x86/hyperv/hv_apic.c
+++ b/arch/x86/hyperv/hv_apic.c
@@ -114,6 +114,8 @@ static bool __send_ipi_mask_ex(const struct cpumask *mask, int vector)
 		ipi_arg->vp_set.format = HV_GENERIC_SET_SPARSE_4K;
 		nr_bank = cpumask_to_vpset(&(ipi_arg->vp_set), mask);
 	}
+	if (nr_bank == -1)
+		goto ipi_mask_ex_done;
 	if (!nr_bank)
 		ipi_arg->vp_set.format = HV_GENERIC_SET_ALL;
 
@@ -158,6 +160,9 @@ static bool __send_ipi_mask(const struct cpumask *mask, int vector)
 
 	for_each_cpu(cur_cpu, mask) {
 		vcpu = hv_cpu_number_to_vp_number(cur_cpu);
+		if (vcpu == -1)
+			goto ipi_mask_done;
+
 		/*
 		 * This particular version of the IPI hypercall can
 		 * only target upto 64 CPUs.
diff --git a/arch/x86/hyperv/hv_init.c b/arch/x86/hyperv/hv_init.c
index 4c431e1c1eff..04159893702e 100644
--- a/arch/x86/hyperv/hv_init.c
+++ b/arch/x86/hyperv/hv_init.c
@@ -265,7 +265,7 @@ void __init hyperv_init(void)
 {
 	u64 guest_id, required_msrs;
 	union hv_x64_msr_hypercall_contents hypercall_msr;
-	int cpuhp;
+	int cpuhp, i;
 
 	if (x86_hyper_type != X86_HYPER_MS_HYPERV)
 		return;
@@ -293,6 +293,9 @@ void __init hyperv_init(void)
 	if (!hv_vp_index)
 		return;
 
+	for (i = 0; i < num_possible_cpus(); i++)
+		hv_vp_index[i] = -1;
+
 	hv_vp_assist_page = kcalloc(num_possible_cpus(),
 				    sizeof(*hv_vp_assist_page), GFP_KERNEL);
 	if (!hv_vp_assist_page) {
diff --git a/arch/x86/include/asm/mshyperv.h b/arch/x86/include/asm/mshyperv.h
index 3cd14311edfa..dee3f7347253 100644
--- a/arch/x86/include/asm/mshyperv.h
+++ b/arch/x86/include/asm/mshyperv.h
@@ -281,6 +281,8 @@ static inline int cpumask_to_vpset(struct hv_vpset *vpset,
 	 */
 	for_each_cpu(cpu, cpus) {
 		vcpu = hv_cpu_number_to_vp_number(cpu);
+		if (vcpu == -1)
+			return -1;
 		vcpu_bank = vcpu / 64;
 		vcpu_offset = vcpu % 64;
 		__set_bit(vcpu_offset, (unsigned long *)

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

* Re: [PATCH 1/1] X86/Hyper-V:: Fix the circular dependency in IPI enlightenment.
  2018-07-03 23:01 [PATCH 1/1] X86/Hyper-V:: Fix the circular dependency in IPI enlightenment kys
  2018-07-04  8:54 ` [tip:x86/urgent] x86/hyper-v: " tip-bot for K. Y. Srinivasan
@ 2018-07-04  9:13 ` Vitaly Kuznetsov
  2018-07-04 16:10 ` Ingo Molnar
  2018-07-06 10:42 ` [tip:x86/hyperv] x86/hyper-v: " tip-bot for K. Y. Srinivasan
  3 siblings, 0 replies; 17+ messages in thread
From: Vitaly Kuznetsov @ 2018-07-04  9:13 UTC (permalink / raw)
  To: kys
  Cc: x86, gregkh, linux-kernel, devel, olaf, apw, jasowang, tglx, hpa,
	sthemmin, Michael.H.Kelley, kys

kys@linuxonhyperv.com writes:

> From: "K. Y. Srinivasan" <kys@microsoft.com>
>
> The IPI hypercalls depend on being able to map the Linux notion of CPU ID
> to the hypervisor's notion of the CPU ID. The array hv_vp_index[] provides
> this mapping. Code for populating this array depends on the IPI functionality.
> Break this circular dependency.
>
> Fixes: 68bb7bfb7985 ("X86/Hyper-V: Enable IPI enlightenments")
>
> Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
> Tested-by: Michael Kelley <mikelley@microsoft.com>
> ---
>  arch/x86/hyperv/hv_apic.c       | 5 +++++
>  arch/x86/hyperv/hv_init.c       | 5 ++++-
>  arch/x86/include/asm/mshyperv.h | 2 ++
>  3 files changed, 11 insertions(+), 1 deletion(-)
>
> diff --git a/arch/x86/hyperv/hv_apic.c b/arch/x86/hyperv/hv_apic.c
> index f68855499391..63d7c196739f 100644
> --- a/arch/x86/hyperv/hv_apic.c
> +++ b/arch/x86/hyperv/hv_apic.c
> @@ -114,6 +114,8 @@ static bool __send_ipi_mask_ex(const struct cpumask *mask, int vector)
>  		ipi_arg->vp_set.format = HV_GENERIC_SET_SPARSE_4K;
>  		nr_bank = cpumask_to_vpset(&(ipi_arg->vp_set), mask);
>  	}
> +	if (nr_bank == -1)
> +		goto ipi_mask_ex_done;
>  	if (!nr_bank)
>  		ipi_arg->vp_set.format = HV_GENERIC_SET_ALL;
>
> @@ -158,6 +160,9 @@ static bool __send_ipi_mask(const struct cpumask *mask, int vector)
>
>  	for_each_cpu(cur_cpu, mask) {
>  		vcpu = hv_cpu_number_to_vp_number(cur_cpu);
> +		if (vcpu == -1)
> +			goto ipi_mask_done;
> +

Nit: hv_vp_index is u32 *, it would make sense to use U32_MAX instead of
'-1' everywhere in this patch.

>  		/*
>  		 * This particular version of the IPI hypercall can
>  		 * only target upto 64 CPUs.
> diff --git a/arch/x86/hyperv/hv_init.c b/arch/x86/hyperv/hv_init.c
> index 4c431e1c1eff..04159893702e 100644
> --- a/arch/x86/hyperv/hv_init.c
> +++ b/arch/x86/hyperv/hv_init.c
> @@ -265,7 +265,7 @@ void __init hyperv_init(void)
>  {
>  	u64 guest_id, required_msrs;
>  	union hv_x64_msr_hypercall_contents hypercall_msr;
> -	int cpuhp;
> +	int cpuhp, i;
>
>  	if (x86_hyper_type != X86_HYPER_MS_HYPERV)
>  		return;
> @@ -293,6 +293,9 @@ void __init hyperv_init(void)
>  	if (!hv_vp_index)
>  		return;
>
> +	for (i = 0; i < num_possible_cpus(); i++)
> +		hv_vp_index[i] = -1;
> +
>  	hv_vp_assist_page = kcalloc(num_possible_cpus(),
>  				    sizeof(*hv_vp_assist_page), GFP_KERNEL);
>  	if (!hv_vp_assist_page) {
> diff --git a/arch/x86/include/asm/mshyperv.h b/arch/x86/include/asm/mshyperv.h
> index 3cd14311edfa..dee3f7347253 100644
> --- a/arch/x86/include/asm/mshyperv.h
> +++ b/arch/x86/include/asm/mshyperv.h
> @@ -281,6 +281,8 @@ static inline int cpumask_to_vpset(struct hv_vpset *vpset,
>  	 */
>  	for_each_cpu(cpu, cpus) {
>  		vcpu = hv_cpu_number_to_vp_number(cpu);
> +		if (vcpu == -1)
> +			return -1;
>  		vcpu_bank = vcpu / 64;
>  		vcpu_offset = vcpu % 64;
>  		__set_bit(vcpu_offset, (unsigned long *)

-- 
  Vitaly

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

* Re: [PATCH 1/1] X86/Hyper-V:: Fix the circular dependency in IPI enlightenment.
  2018-07-03 23:01 [PATCH 1/1] X86/Hyper-V:: Fix the circular dependency in IPI enlightenment kys
  2018-07-04  8:54 ` [tip:x86/urgent] x86/hyper-v: " tip-bot for K. Y. Srinivasan
  2018-07-04  9:13 ` [PATCH 1/1] X86/Hyper-V:: " Vitaly Kuznetsov
@ 2018-07-04 16:10 ` Ingo Molnar
  2018-07-05 15:01   ` KY Srinivasan
  2018-07-06 10:42 ` [tip:x86/hyperv] x86/hyper-v: " tip-bot for K. Y. Srinivasan
  3 siblings, 1 reply; 17+ messages in thread
From: Ingo Molnar @ 2018-07-04 16:10 UTC (permalink / raw)
  To: kys
  Cc: x86, gregkh, linux-kernel, devel, olaf, apw, jasowang, tglx, hpa,
	sthemmin, Michael.H.Kelley, vkuznets


* kys@linuxonhyperv.com <kys@linuxonhyperv.com> wrote:

> From: "K. Y. Srinivasan" <kys@microsoft.com>
> 
> The IPI hypercalls depend on being able to map the Linux notion of CPU ID
> to the hypervisor's notion of the CPU ID. The array hv_vp_index[] provides
> this mapping. Code for populating this array depends on the IPI functionality.
> Break this circular dependency.
> 
> Fixes: 68bb7bfb7985 ("X86/Hyper-V: Enable IPI enlightenments")
> 
> Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
> Tested-by: Michael Kelley <mikelley@microsoft.com>
> ---
>  arch/x86/hyperv/hv_apic.c       | 5 +++++
>  arch/x86/hyperv/hv_init.c       | 5 ++++-
>  arch/x86/include/asm/mshyperv.h | 2 ++
>  3 files changed, 11 insertions(+), 1 deletion(-)

Ugh, this patch wasn't even build tested, on 64-bit allyes/allmodconfig:

 arch/x86/hyperv/hv_apic.c: In function ‘__send_ipi_mask’:
 arch/x86/hyperv/hv_apic.c:171:4: error: label ‘ipi_mask_done’ used but not defined
 scripts/Makefile.build:317: recipe for target 'arch/x86/hyperv/hv_apic.o' failed
 make[2]: *** [arch/x86/hyperv/hv_apic.o] Error 1

Thanks,

	Ingo

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

* RE: [PATCH 1/1] X86/Hyper-V:: Fix the circular dependency in IPI enlightenment.
  2018-07-04 16:10 ` Ingo Molnar
@ 2018-07-05 15:01   ` KY Srinivasan
  2018-07-05 15:38     ` Ingo Molnar
  0 siblings, 1 reply; 17+ messages in thread
From: KY Srinivasan @ 2018-07-05 15:01 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: x86, gregkh, linux-kernel, devel, olaf, apw, jasowang, tglx, hpa,
	Stephen Hemminger, Michael Kelley (EOSG),
	vkuznets



> -----Original Message-----
> From: Ingo Molnar <mingo.kernel.org@gmail.com> On Behalf Of Ingo Molnar
> Sent: Wednesday, July 4, 2018 9:11 AM
> To: KY Srinivasan <kys@microsoft.com>
> Cc: x86@kernel.org; gregkh@linuxfoundation.org; linux-
> kernel@vger.kernel.org; devel@linuxdriverproject.org; olaf@aepfle.de;
> apw@canonical.com; jasowang@redhat.com; tglx@linutronix.de;
> hpa@zytor.com; Stephen Hemminger <sthemmin@microsoft.com>; Michael
> Kelley (EOSG) <Michael.H.Kelley@microsoft.com>; vkuznets@redhat.com
> Subject: Re: [PATCH 1/1] X86/Hyper-V:: Fix the circular dependency in IPI
> enlightenment.
> 
> 
> * kys@linuxonhyperv.com <kys@linuxonhyperv.com> wrote:
> 
> > From: "K. Y. Srinivasan" <kys@microsoft.com>
> >
> > The IPI hypercalls depend on being able to map the Linux notion of CPU ID
> > to the hypervisor's notion of the CPU ID. The array hv_vp_index[] provides
> > this mapping. Code for populating this array depends on the IPI
> functionality.
> > Break this circular dependency.
> >
> > Fixes: 68bb7bfb7985 ("X86/Hyper-V: Enable IPI enlightenments")
> >
> > Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
> > Tested-by: Michael Kelley <mikelley@microsoft.com>
> > ---
> >  arch/x86/hyperv/hv_apic.c       | 5 +++++
> >  arch/x86/hyperv/hv_init.c       | 5 ++++-
> >  arch/x86/include/asm/mshyperv.h | 2 ++
> >  3 files changed, 11 insertions(+), 1 deletion(-)
> 
> Ugh, this patch wasn't even build tested, on 64-bit allyes/allmodconfig:
> 
>  arch/x86/hyperv/hv_apic.c: In function ‘__send_ipi_mask’:
>  arch/x86/hyperv/hv_apic.c:171:4: error: label ‘ipi_mask_done’ used but not
> defined
>  scripts/Makefile.build:317: recipe for target 'arch/x86/hyperv/hv_apic.o'
> failed
>  make[2]: *** [arch/x86/hyperv/hv_apic.o] Error 1

Sorry Ingo. I had a clean build on the linux-next tree (tag: next-20180702) that
I used to base this patch. What was the tree you applied the patch to?

Regards,

K. Y

> 
> Thanks,
> 
> 	Ingo

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

* Re: [PATCH 1/1] X86/Hyper-V:: Fix the circular dependency in IPI enlightenment.
  2018-07-05 15:01   ` KY Srinivasan
@ 2018-07-05 15:38     ` Ingo Molnar
  2018-07-05 21:11       ` KY Srinivasan
  0 siblings, 1 reply; 17+ messages in thread
From: Ingo Molnar @ 2018-07-05 15:38 UTC (permalink / raw)
  To: KY Srinivasan
  Cc: x86, gregkh, linux-kernel, devel, olaf, apw, jasowang, tglx, hpa,
	Stephen Hemminger, Michael Kelley (EOSG),
	vkuznets


* KY Srinivasan <kys@microsoft.com> wrote:

> 
> 
> > -----Original Message-----
> > From: Ingo Molnar <mingo.kernel.org@gmail.com> On Behalf Of Ingo Molnar
> > Sent: Wednesday, July 4, 2018 9:11 AM
> > To: KY Srinivasan <kys@microsoft.com>
> > Cc: x86@kernel.org; gregkh@linuxfoundation.org; linux-
> > kernel@vger.kernel.org; devel@linuxdriverproject.org; olaf@aepfle.de;
> > apw@canonical.com; jasowang@redhat.com; tglx@linutronix.de;
> > hpa@zytor.com; Stephen Hemminger <sthemmin@microsoft.com>; Michael
> > Kelley (EOSG) <Michael.H.Kelley@microsoft.com>; vkuznets@redhat.com
> > Subject: Re: [PATCH 1/1] X86/Hyper-V:: Fix the circular dependency in IPI
> > enlightenment.
> > 
> > 
> > * kys@linuxonhyperv.com <kys@linuxonhyperv.com> wrote:
> > 
> > > From: "K. Y. Srinivasan" <kys@microsoft.com>
> > >
> > > The IPI hypercalls depend on being able to map the Linux notion of CPU ID
> > > to the hypervisor's notion of the CPU ID. The array hv_vp_index[] provides
> > > this mapping. Code for populating this array depends on the IPI
> > functionality.
> > > Break this circular dependency.
> > >
> > > Fixes: 68bb7bfb7985 ("X86/Hyper-V: Enable IPI enlightenments")
> > >
> > > Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
> > > Tested-by: Michael Kelley <mikelley@microsoft.com>
> > > ---
> > >  arch/x86/hyperv/hv_apic.c       | 5 +++++
> > >  arch/x86/hyperv/hv_init.c       | 5 ++++-
> > >  arch/x86/include/asm/mshyperv.h | 2 ++
> > >  3 files changed, 11 insertions(+), 1 deletion(-)
> > 
> > Ugh, this patch wasn't even build tested, on 64-bit allyes/allmodconfig:
> > 
> >  arch/x86/hyperv/hv_apic.c: In function ‘__send_ipi_mask’:
> >  arch/x86/hyperv/hv_apic.c:171:4: error: label ‘ipi_mask_done’ used but not
> > defined
> >  scripts/Makefile.build:317: recipe for target 'arch/x86/hyperv/hv_apic.o'
> > failed
> >  make[2]: *** [arch/x86/hyperv/hv_apic.o] Error 1
> 
> Sorry Ingo. I had a clean build on the linux-next tree (tag: next-20180702) that
> I used to base this patch. What was the tree you applied the patch to?

If you look at the error message, it won't build against *any* tree, because 
there's no 'ipi_mask_done' label either in the kernel source, or introduced
by the patch.

So whatever tree you used it on, if you build arch/x86/hyperv/hv_apic.o it should 
be broken.

Thanks,

	Ingo

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

* RE: [PATCH 1/1] X86/Hyper-V:: Fix the circular dependency in IPI enlightenment.
  2018-07-05 15:38     ` Ingo Molnar
@ 2018-07-05 21:11       ` KY Srinivasan
  2018-07-05 22:23         ` Ingo Molnar
  0 siblings, 1 reply; 17+ messages in thread
From: KY Srinivasan @ 2018-07-05 21:11 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: x86, gregkh, linux-kernel, devel, olaf, apw, jasowang, tglx, hpa,
	Stephen Hemminger, Michael Kelley (EOSG),
	vkuznets



> -----Original Message-----
> From: Ingo Molnar <mingo.kernel.org@gmail.com> On Behalf Of Ingo Molnar
> Sent: Thursday, July 5, 2018 8:38 AM
> To: KY Srinivasan <kys@microsoft.com>
> Cc: x86@kernel.org; gregkh@linuxfoundation.org; linux-
> kernel@vger.kernel.org; devel@linuxdriverproject.org; olaf@aepfle.de;
> apw@canonical.com; jasowang@redhat.com; tglx@linutronix.de;
> hpa@zytor.com; Stephen Hemminger <sthemmin@microsoft.com>; Michael
> Kelley (EOSG) <Michael.H.Kelley@microsoft.com>; vkuznets@redhat.com
> Subject: Re: [PATCH 1/1] X86/Hyper-V:: Fix the circular dependency in IPI
> enlightenment.
> 
> 
> * KY Srinivasan <kys@microsoft.com> wrote:
> 
> >
> >
> > > -----Original Message-----
> > > From: Ingo Molnar <mingo.kernel.org@gmail.com> On Behalf Of Ingo
> Molnar
> > > Sent: Wednesday, July 4, 2018 9:11 AM
> > > To: KY Srinivasan <kys@microsoft.com>
> > > Cc: x86@kernel.org; gregkh@linuxfoundation.org; linux-
> > > kernel@vger.kernel.org; devel@linuxdriverproject.org; olaf@aepfle.de;
> > > apw@canonical.com; jasowang@redhat.com; tglx@linutronix.de;
> > > hpa@zytor.com; Stephen Hemminger <sthemmin@microsoft.com>;
> Michael
> > > Kelley (EOSG) <Michael.H.Kelley@microsoft.com>;
> vkuznets@redhat.com
> > > Subject: Re: [PATCH 1/1] X86/Hyper-V:: Fix the circular dependency in IPI
> > > enlightenment.
> > >
> > >
> > > * kys@linuxonhyperv.com <kys@linuxonhyperv.com> wrote:
> > >
> > > > From: "K. Y. Srinivasan" <kys@microsoft.com>
> > > >
> > > > The IPI hypercalls depend on being able to map the Linux notion of CPU
> ID
> > > > to the hypervisor's notion of the CPU ID. The array hv_vp_index[]
> provides
> > > > this mapping. Code for populating this array depends on the IPI
> > > functionality.
> > > > Break this circular dependency.
> > > >
> > > > Fixes: 68bb7bfb7985 ("X86/Hyper-V: Enable IPI enlightenments")
> > > >
> > > > Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
> > > > Tested-by: Michael Kelley <mikelley@microsoft.com>
> > > > ---
> > > >  arch/x86/hyperv/hv_apic.c       | 5 +++++
> > > >  arch/x86/hyperv/hv_init.c       | 5 ++++-
> > > >  arch/x86/include/asm/mshyperv.h | 2 ++
> > > >  3 files changed, 11 insertions(+), 1 deletion(-)
> > >
> > > Ugh, this patch wasn't even build tested, on 64-bit allyes/allmodconfig:
> > >
> > >  arch/x86/hyperv/hv_apic.c: In function ‘__send_ipi_mask’:
> > >  arch/x86/hyperv/hv_apic.c:171:4: error: label ‘ipi_mask_done’ used but
> not
> > > defined
> > >  scripts/Makefile.build:317: recipe for target 'arch/x86/hyperv/hv_apic.o'
> > > failed
> > >  make[2]: *** [arch/x86/hyperv/hv_apic.o] Error 1
> >
> > Sorry Ingo. I had a clean build on the linux-next tree (tag: next-20180702)
> that
> > I used to base this patch. What was the tree you applied the patch to?
> 
> If you look at the error message, it won't build against *any* tree, because
> there's no 'ipi_mask_done' label either in the kernel source, or introduced
> by the patch.
> 
> So whatever tree you used it on, if you build arch/x86/hyperv/hv_apic.o it
> should
> be broken.

Ingo,

I am confused. The label ipi_mask_done was introduced in this patch
(the patch under question fixes a circular dependency in this patch):

commit 68bb7bfb7985df2bd15c2dc975cb68b7a901488a
Author: K. Y. Srinivasan <kys@microsoft.com>
Date:   Wed May 16 14:53:31 2018 -0700

    X86/Hyper-V: Enable IPI enlightenments

    Hyper-V supports hypercalls to implement IPI; use them.

    Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Reviewed-by: Michael Kelley <mikelley@microsoft.com>

This patch was committed by Thomas some weeks ago and is in linux-next.
This patch is also in 4.18-rc3.

Regards,

K. Y



> 
> Thanks,
> 
> 	Ingo

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

* Re: [PATCH 1/1] X86/Hyper-V:: Fix the circular dependency in IPI enlightenment.
  2018-07-05 21:11       ` KY Srinivasan
@ 2018-07-05 22:23         ` Ingo Molnar
  2018-07-05 22:46           ` Thomas Gleixner
  0 siblings, 1 reply; 17+ messages in thread
From: Ingo Molnar @ 2018-07-05 22:23 UTC (permalink / raw)
  To: KY Srinivasan
  Cc: x86, gregkh, linux-kernel, devel, olaf, apw, jasowang, tglx, hpa,
	Stephen Hemminger, Michael Kelley (EOSG),
	vkuznets


* KY Srinivasan <kys@microsoft.com> wrote:

> 
> 
> > -----Original Message-----
> > From: Ingo Molnar <mingo.kernel.org@gmail.com> On Behalf Of Ingo Molnar
> > Sent: Thursday, July 5, 2018 8:38 AM
> > To: KY Srinivasan <kys@microsoft.com>
> > Cc: x86@kernel.org; gregkh@linuxfoundation.org; linux-
> > kernel@vger.kernel.org; devel@linuxdriverproject.org; olaf@aepfle.de;
> > apw@canonical.com; jasowang@redhat.com; tglx@linutronix.de;
> > hpa@zytor.com; Stephen Hemminger <sthemmin@microsoft.com>; Michael
> > Kelley (EOSG) <Michael.H.Kelley@microsoft.com>; vkuznets@redhat.com
> > Subject: Re: [PATCH 1/1] X86/Hyper-V:: Fix the circular dependency in IPI
> > enlightenment.
> > 
> > 
> > * KY Srinivasan <kys@microsoft.com> wrote:
> > 
> > >
> > >
> > > > -----Original Message-----
> > > > From: Ingo Molnar <mingo.kernel.org@gmail.com> On Behalf Of Ingo
> > Molnar
> > > > Sent: Wednesday, July 4, 2018 9:11 AM
> > > > To: KY Srinivasan <kys@microsoft.com>
> > > > Cc: x86@kernel.org; gregkh@linuxfoundation.org; linux-
> > > > kernel@vger.kernel.org; devel@linuxdriverproject.org; olaf@aepfle.de;
> > > > apw@canonical.com; jasowang@redhat.com; tglx@linutronix.de;
> > > > hpa@zytor.com; Stephen Hemminger <sthemmin@microsoft.com>;
> > Michael
> > > > Kelley (EOSG) <Michael.H.Kelley@microsoft.com>;
> > vkuznets@redhat.com
> > > > Subject: Re: [PATCH 1/1] X86/Hyper-V:: Fix the circular dependency in IPI
> > > > enlightenment.
> > > >
> > > >
> > > > * kys@linuxonhyperv.com <kys@linuxonhyperv.com> wrote:
> > > >
> > > > > From: "K. Y. Srinivasan" <kys@microsoft.com>
> > > > >
> > > > > The IPI hypercalls depend on being able to map the Linux notion of CPU
> > ID
> > > > > to the hypervisor's notion of the CPU ID. The array hv_vp_index[]
> > provides
> > > > > this mapping. Code for populating this array depends on the IPI
> > > > functionality.
> > > > > Break this circular dependency.
> > > > >
> > > > > Fixes: 68bb7bfb7985 ("X86/Hyper-V: Enable IPI enlightenments")
> > > > >
> > > > > Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
> > > > > Tested-by: Michael Kelley <mikelley@microsoft.com>
> > > > > ---
> > > > >  arch/x86/hyperv/hv_apic.c       | 5 +++++
> > > > >  arch/x86/hyperv/hv_init.c       | 5 ++++-
> > > > >  arch/x86/include/asm/mshyperv.h | 2 ++
> > > > >  3 files changed, 11 insertions(+), 1 deletion(-)
> > > >
> > > > Ugh, this patch wasn't even build tested, on 64-bit allyes/allmodconfig:
> > > >
> > > >  arch/x86/hyperv/hv_apic.c: In function ‘__send_ipi_mask’:
> > > >  arch/x86/hyperv/hv_apic.c:171:4: error: label ‘ipi_mask_done’ used but
> > not
> > > > defined
> > > >  scripts/Makefile.build:317: recipe for target 'arch/x86/hyperv/hv_apic.o'
> > > > failed
> > > >  make[2]: *** [arch/x86/hyperv/hv_apic.o] Error 1
> > >
> > > Sorry Ingo. I had a clean build on the linux-next tree (tag: next-20180702)
> > that
> > > I used to base this patch. What was the tree you applied the patch to?
> > 
> > If you look at the error message, it won't build against *any* tree, because
> > there's no 'ipi_mask_done' label either in the kernel source, or introduced
> > by the patch.
> > 
> > So whatever tree you used it on, if you build arch/x86/hyperv/hv_apic.o it
> > should
> > be broken.
> 
> Ingo,
> 
> I am confused. The label ipi_mask_done was introduced in this patch
> (the patch under question fixes a circular dependency in this patch):
> 
> commit 68bb7bfb7985df2bd15c2dc975cb68b7a901488a
> Author: K. Y. Srinivasan <kys@microsoft.com>
> Date:   Wed May 16 14:53:31 2018 -0700
> 
>     X86/Hyper-V: Enable IPI enlightenments
> 
>     Hyper-V supports hypercalls to implement IPI; use them.
> 
>     Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
>     Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
>     Reviewed-by: Michael Kelley <mikelley@microsoft.com>
> 
> This patch was committed by Thomas some weeks ago and is in linux-next.
> This patch is also in 4.18-rc3.

And then that name was changed to a different label in:

  4bd06060762b: x86/hyper-v: Use cheaper HVCALL_SEND_IPI hypercall when possible

So maybe you were testing on an older kernel. Could you try the latest -tip?

Thanks,

	Ingo

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

* Re: [PATCH 1/1] X86/Hyper-V:: Fix the circular dependency in IPI enlightenment.
  2018-07-05 22:23         ` Ingo Molnar
@ 2018-07-05 22:46           ` Thomas Gleixner
  2018-07-06  3:59             ` KY Srinivasan
  2018-07-06 10:00             ` Ingo Molnar
  0 siblings, 2 replies; 17+ messages in thread
From: Thomas Gleixner @ 2018-07-05 22:46 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: KY Srinivasan, x86, gregkh, linux-kernel, devel, olaf, apw,
	jasowang, hpa, Stephen Hemminger, Michael Kelley (EOSG),
	vkuznets

On Fri, 6 Jul 2018, Ingo Molnar wrote:
> * KY Srinivasan <kys@microsoft.com> wrote:
> > I am confused. The label ipi_mask_done was introduced in this patch
> > (the patch under question fixes a circular dependency in this patch):
> > 
> > commit 68bb7bfb7985df2bd15c2dc975cb68b7a901488a
> > Author: K. Y. Srinivasan <kys@microsoft.com>
> > Date:   Wed May 16 14:53:31 2018 -0700
> > 
> >     X86/Hyper-V: Enable IPI enlightenments
> > 
> >     Hyper-V supports hypercalls to implement IPI; use them.
> > 
> >     Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
> >     Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
> >     Reviewed-by: Michael Kelley <mikelley@microsoft.com>
> > 
> > This patch was committed by Thomas some weeks ago and is in linux-next.
> > This patch is also in 4.18-rc3.
> 
> And then that name was changed to a different label in:
> 
>   4bd06060762b: x86/hyper-v: Use cheaper HVCALL_SEND_IPI hypercall when possible
> 
> So maybe you were testing on an older kernel. Could you try the latest -tip?

The problem is that the wreckage is in Linus tree and needs to be fixed
there, i.e. via x86/urgent.

Now we have the new bits queued in x86/hyperv already which collide. So we
need to merge x86/urgent into x86/hyperv after applying the fix and mop up
the merge wreckage in x86/hyperv.

I'll have a look tomorrow morning unless you beat me to it.

Thanks,

	tglx

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

* RE: [PATCH 1/1] X86/Hyper-V:: Fix the circular dependency in IPI enlightenment.
  2018-07-05 22:46           ` Thomas Gleixner
@ 2018-07-06  3:59             ` KY Srinivasan
  2018-07-06  8:53               ` Thomas Gleixner
  2018-07-06 10:00             ` Ingo Molnar
  1 sibling, 1 reply; 17+ messages in thread
From: KY Srinivasan @ 2018-07-06  3:59 UTC (permalink / raw)
  To: Thomas Gleixner, Ingo Molnar
  Cc: x86, gregkh, linux-kernel, devel, olaf, apw, jasowang, hpa,
	Stephen Hemminger, Michael Kelley (EOSG),
	vkuznets



> -----Original Message-----
> From: Thomas Gleixner <tglx@linutronix.de>
> Sent: Thursday, July 5, 2018 3:46 PM
> To: Ingo Molnar <mingo@kernel.org>
> Cc: KY Srinivasan <kys@microsoft.com>; x86@kernel.org;
> gregkh@linuxfoundation.org; linux-kernel@vger.kernel.org;
> devel@linuxdriverproject.org; olaf@aepfle.de; apw@canonical.com;
> jasowang@redhat.com; hpa@zytor.com; Stephen Hemminger
> <sthemmin@microsoft.com>; Michael Kelley (EOSG)
> <Michael.H.Kelley@microsoft.com>; vkuznets@redhat.com
> Subject: Re: [PATCH 1/1] X86/Hyper-V:: Fix the circular dependency in IPI
> enlightenment.
> 
> On Fri, 6 Jul 2018, Ingo Molnar wrote:
> > * KY Srinivasan <kys@microsoft.com> wrote:
> > > I am confused. The label ipi_mask_done was introduced in this patch
> > > (the patch under question fixes a circular dependency in this patch):
> > >
> > > commit 68bb7bfb7985df2bd15c2dc975cb68b7a901488a
> > > Author: K. Y. Srinivasan <kys@microsoft.com>
> > > Date:   Wed May 16 14:53:31 2018 -0700
> > >
> > >     X86/Hyper-V: Enable IPI enlightenments
> > >
> > >     Hyper-V supports hypercalls to implement IPI; use them.
> > >
> > >     Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
> > >     Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
> > >     Reviewed-by: Michael Kelley <mikelley@microsoft.com>
> > >
> > > This patch was committed by Thomas some weeks ago and is in linux-
> next.
> > > This patch is also in 4.18-rc3.
> >
> > And then that name was changed to a different label in:
> >
> >   4bd06060762b: x86/hyper-v: Use cheaper HVCALL_SEND_IPI hypercall
> when possible
> >
> > So maybe you were testing on an older kernel. Could you try the latest -
> tip?


> 
> The problem is that the wreckage is in Linus tree and needs to be fixed
> there, i.e. via x86/urgent.
> 
> Now we have the new bits queued in x86/hyperv already which collide. So
> we
> need to merge x86/urgent into x86/hyperv after applying the fix and mop up
> the merge wreckage in x86/hyperv.
> 
> I'll have a look tomorrow morning unless you beat me to it.

I can rebase this patch against the latest tip and resend (tomorrow).

K. Y 
> 
> Thanks,
> 
> 	tglx

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

* RE: [PATCH 1/1] X86/Hyper-V:: Fix the circular dependency in IPI enlightenment.
  2018-07-06  3:59             ` KY Srinivasan
@ 2018-07-06  8:53               ` Thomas Gleixner
  2018-07-06 10:42                 ` Thomas Gleixner
  0 siblings, 1 reply; 17+ messages in thread
From: Thomas Gleixner @ 2018-07-06  8:53 UTC (permalink / raw)
  To: KY Srinivasan
  Cc: Ingo Molnar, x86, gregkh, linux-kernel, devel, olaf, apw,
	jasowang, hpa, Stephen Hemminger, Michael Kelley (EOSG),
	vkuznets

On Fri, 6 Jul 2018, KY Srinivasan wrote:
> > 
> > The problem is that the wreckage is in Linus tree and needs to be fixed
> > there, i.e. via x86/urgent.
> > 
> > Now we have the new bits queued in x86/hyperv already which collide. So
> > we
> > need to merge x86/urgent into x86/hyperv after applying the fix and mop up
> > the merge wreckage in x86/hyperv.
> > 
> > I'll have a look tomorrow morning unless you beat me to it.
> 
> I can rebase this patch against the latest tip and resend (tomorrow).

That doesn't help as we need to push the original fix to Linus ...

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

* Re: [PATCH 1/1] X86/Hyper-V:: Fix the circular dependency in IPI enlightenment.
  2018-07-05 22:46           ` Thomas Gleixner
  2018-07-06  3:59             ` KY Srinivasan
@ 2018-07-06 10:00             ` Ingo Molnar
  1 sibling, 0 replies; 17+ messages in thread
From: Ingo Molnar @ 2018-07-06 10:00 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: KY Srinivasan, x86, gregkh, linux-kernel, devel, olaf, apw,
	jasowang, hpa, Stephen Hemminger, Michael Kelley (EOSG),
	vkuznets


* Thomas Gleixner <tglx@linutronix.de> wrote:

> On Fri, 6 Jul 2018, Ingo Molnar wrote:
> > * KY Srinivasan <kys@microsoft.com> wrote:
> > > I am confused. The label ipi_mask_done was introduced in this patch
> > > (the patch under question fixes a circular dependency in this patch):
> > > 
> > > commit 68bb7bfb7985df2bd15c2dc975cb68b7a901488a
> > > Author: K. Y. Srinivasan <kys@microsoft.com>
> > > Date:   Wed May 16 14:53:31 2018 -0700
> > > 
> > >     X86/Hyper-V: Enable IPI enlightenments
> > > 
> > >     Hyper-V supports hypercalls to implement IPI; use them.
> > > 
> > >     Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
> > >     Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
> > >     Reviewed-by: Michael Kelley <mikelley@microsoft.com>
> > > 
> > > This patch was committed by Thomas some weeks ago and is in linux-next.
> > > This patch is also in 4.18-rc3.
> > 
> > And then that name was changed to a different label in:
> > 
> >   4bd06060762b: x86/hyper-v: Use cheaper HVCALL_SEND_IPI hypercall when possible
> > 
> > So maybe you were testing on an older kernel. Could you try the latest -tip?
> 
> The problem is that the wreckage is in Linus tree and needs to be fixed
> there, i.e. via x86/urgent.

Indeed, I missed that!

> Now we have the new bits queued in x86/hyperv already which collide. So we
> need to merge x86/urgent into x86/hyperv after applying the fix and mop up
> the merge wreckage in x86/hyperv.
> 
> I'll have a look tomorrow morning unless you beat me to it.

Ok!

Thanks,

	Ingo

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

* RE: [PATCH 1/1] X86/Hyper-V:: Fix the circular dependency in IPI enlightenment.
  2018-07-06  8:53               ` Thomas Gleixner
@ 2018-07-06 10:42                 ` Thomas Gleixner
  2018-07-06 16:12                   ` Michael Kelley (EOSG)
  2018-07-06 18:05                   ` KY Srinivasan
  0 siblings, 2 replies; 17+ messages in thread
From: Thomas Gleixner @ 2018-07-06 10:42 UTC (permalink / raw)
  To: KY Srinivasan
  Cc: Ingo Molnar, x86, gregkh, linux-kernel, devel, olaf, apw,
	jasowang, hpa, Stephen Hemminger, Michael Kelley (EOSG),
	vkuznets

On Fri, 6 Jul 2018, Thomas Gleixner wrote:
> On Fri, 6 Jul 2018, KY Srinivasan wrote:
> > > 
> > > The problem is that the wreckage is in Linus tree and needs to be fixed
> > > there, i.e. via x86/urgent.
> > > 
> > > Now we have the new bits queued in x86/hyperv already which collide. So
> > > we
> > > need to merge x86/urgent into x86/hyperv after applying the fix and mop up
> > > the merge wreckage in x86/hyperv.
> > > 
> > > I'll have a look tomorrow morning unless you beat me to it.
> > 
> > I can rebase this patch against the latest tip and resend (tomorrow).
> 
> That doesn't help as we need to push the original fix to Linus ...

Applied it to x86/urgent and fixed up the '-1' sloppy hack as pointed out
by Vitaly and merged x86/urgent into x86/hyperv.

Please check both branches for correctness.

Thanks,

	tglx


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

* [tip:x86/hyperv] x86/hyper-v: Fix the circular dependency in IPI enlightenment
  2018-07-03 23:01 [PATCH 1/1] X86/Hyper-V:: Fix the circular dependency in IPI enlightenment kys
                   ` (2 preceding siblings ...)
  2018-07-04 16:10 ` Ingo Molnar
@ 2018-07-06 10:42 ` tip-bot for K. Y. Srinivasan
  3 siblings, 0 replies; 17+ messages in thread
From: tip-bot for K. Y. Srinivasan @ 2018-07-06 10:42 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: hpa, linux-kernel, tglx, mingo, kys, mikelley

Commit-ID:  1268ed0c474a5c8f165ef386f3310521b5e00e27
Gitweb:     https://git.kernel.org/tip/1268ed0c474a5c8f165ef386f3310521b5e00e27
Author:     K. Y. Srinivasan <kys@microsoft.com>
AuthorDate: Tue, 3 Jul 2018 16:01:55 -0700
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Fri, 6 Jul 2018 12:32:59 +0200

x86/hyper-v: Fix the circular dependency in IPI enlightenment

The IPI hypercalls depend on being able to map the Linux notion of CPU ID
to the hypervisor's notion of the CPU ID. The array hv_vp_index[] provides
this mapping. Code for populating this array depends on the IPI functionality.
Break this circular dependency.

[ tglx: Use a proper define instead of '-1' with a u32 variable as pointed
  	out by Vitaly ]

Fixes: 68bb7bfb7985 ("X86/Hyper-V: Enable IPI enlightenments")
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Tested-by: Michael Kelley <mikelley@microsoft.com>
Cc: gregkh@linuxfoundation.org
Cc: devel@linuxdriverproject.org
Cc: olaf@aepfle.de
Cc: apw@canonical.com
Cc: jasowang@redhat.com
Cc: hpa@zytor.com
Cc: sthemmin@microsoft.com
Cc: Michael.H.Kelley@microsoft.com
Cc: vkuznets@redhat.com
Link: https://lkml.kernel.org/r/20180703230155.15160-1-kys@linuxonhyperv.com


---
 arch/x86/hyperv/hv_apic.c       | 5 +++++
 arch/x86/hyperv/hv_init.c       | 5 ++++-
 arch/x86/include/asm/mshyperv.h | 5 ++++-
 3 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/arch/x86/hyperv/hv_apic.c b/arch/x86/hyperv/hv_apic.c
index f68855499391..402338365651 100644
--- a/arch/x86/hyperv/hv_apic.c
+++ b/arch/x86/hyperv/hv_apic.c
@@ -114,6 +114,8 @@ static bool __send_ipi_mask_ex(const struct cpumask *mask, int vector)
 		ipi_arg->vp_set.format = HV_GENERIC_SET_SPARSE_4K;
 		nr_bank = cpumask_to_vpset(&(ipi_arg->vp_set), mask);
 	}
+	if (nr_bank < 0)
+		goto ipi_mask_ex_done;
 	if (!nr_bank)
 		ipi_arg->vp_set.format = HV_GENERIC_SET_ALL;
 
@@ -158,6 +160,9 @@ static bool __send_ipi_mask(const struct cpumask *mask, int vector)
 
 	for_each_cpu(cur_cpu, mask) {
 		vcpu = hv_cpu_number_to_vp_number(cur_cpu);
+		if (vcpu == VP_INVAL)
+			goto ipi_mask_done;
+
 		/*
 		 * This particular version of the IPI hypercall can
 		 * only target upto 64 CPUs.
diff --git a/arch/x86/hyperv/hv_init.c b/arch/x86/hyperv/hv_init.c
index 4c431e1c1eff..1ff420217298 100644
--- a/arch/x86/hyperv/hv_init.c
+++ b/arch/x86/hyperv/hv_init.c
@@ -265,7 +265,7 @@ void __init hyperv_init(void)
 {
 	u64 guest_id, required_msrs;
 	union hv_x64_msr_hypercall_contents hypercall_msr;
-	int cpuhp;
+	int cpuhp, i;
 
 	if (x86_hyper_type != X86_HYPER_MS_HYPERV)
 		return;
@@ -293,6 +293,9 @@ void __init hyperv_init(void)
 	if (!hv_vp_index)
 		return;
 
+	for (i = 0; i < num_possible_cpus(); i++)
+		hv_vp_index[i] = VP_INVAL;
+
 	hv_vp_assist_page = kcalloc(num_possible_cpus(),
 				    sizeof(*hv_vp_assist_page), GFP_KERNEL);
 	if (!hv_vp_assist_page) {
diff --git a/arch/x86/include/asm/mshyperv.h b/arch/x86/include/asm/mshyperv.h
index 3cd14311edfa..5a7375ed5f7c 100644
--- a/arch/x86/include/asm/mshyperv.h
+++ b/arch/x86/include/asm/mshyperv.h
@@ -9,6 +9,8 @@
 #include <asm/hyperv-tlfs.h>
 #include <asm/nospec-branch.h>
 
+#define VP_INVAL	U32_MAX
+
 struct ms_hyperv_info {
 	u32 features;
 	u32 misc_features;
@@ -20,7 +22,6 @@ struct ms_hyperv_info {
 
 extern struct ms_hyperv_info ms_hyperv;
 
-
 /*
  * Generate the guest ID.
  */
@@ -281,6 +282,8 @@ static inline int cpumask_to_vpset(struct hv_vpset *vpset,
 	 */
 	for_each_cpu(cpu, cpus) {
 		vcpu = hv_cpu_number_to_vp_number(cpu);
+		if (vcpu == VP_INVAL)
+			return -1;
 		vcpu_bank = vcpu / 64;
 		vcpu_offset = vcpu % 64;
 		__set_bit(vcpu_offset, (unsigned long *)

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

* RE: [PATCH 1/1] X86/Hyper-V:: Fix the circular dependency in IPI enlightenment.
  2018-07-06 10:42                 ` Thomas Gleixner
@ 2018-07-06 16:12                   ` Michael Kelley (EOSG)
  2018-07-06 17:01                     ` Thomas Gleixner
  2018-07-06 18:05                   ` KY Srinivasan
  1 sibling, 1 reply; 17+ messages in thread
From: Michael Kelley (EOSG) @ 2018-07-06 16:12 UTC (permalink / raw)
  To: Thomas Gleixner, KY Srinivasan
  Cc: Ingo Molnar, x86, gregkh, linux-kernel, devel, olaf, apw,
	jasowang, hpa, Stephen Hemminger, vkuznets

> -----Original Message-----
> From: Thomas Gleixner <tglx@linutronix.de>
> Sent: Friday, July 6, 2018 3:42 AM
> To: KY Srinivasan <kys@microsoft.com>
> Cc: Ingo Molnar <mingo@kernel.org>; x86@kernel.org; gregkh@linuxfoundation.org; linux-
> kernel@vger.kernel.org; devel@linuxdriverproject.org; olaf@aepfle.de; apw@canonical.com;
> jasowang@redhat.com; hpa@zytor.com; Stephen Hemminger <sthemmin@microsoft.com>;
> Michael Kelley (EOSG) <Michael.H.Kelley@microsoft.com>; vkuznets@redhat.com
> Subject: RE: [PATCH 1/1] X86/Hyper-V:: Fix the circular dependency in IPI enlightenment.
> 
> On Fri, 6 Jul 2018, Thomas Gleixner wrote:
> > On Fri, 6 Jul 2018, KY Srinivasan wrote:
> > > >
> > > > The problem is that the wreckage is in Linus tree and needs to be fixed
> > > > there, i.e. via x86/urgent.
> > > >
> > > > Now we have the new bits queued in x86/hyperv already which collide. So
> > > > we
> > > > need to merge x86/urgent into x86/hyperv after applying the fix and mop up
> > > > the merge wreckage in x86/hyperv.
> > > >
> > > > I'll have a look tomorrow morning unless you beat me to it.
> > >
> > > I can rebase this patch against the latest tip and resend (tomorrow).
> >
> > That doesn't help as we need to push the original fix to Linus ...
> 
> Applied it to x86/urgent and fixed up the '-1' sloppy hack as pointed out
> by Vitaly and merged x86/urgent into x86/hyperv.
> 
> Please check both branches for correctness.

Changes look good to me.  Some pre-existing signed/unsigned type sloppiness is
still there in that hv_cpu_number_to_vp_number() should be 'u32' instead
of 'int', along with related local variables, but that's probably best to fix in
linux-next on top of Vitaly's other changes.  This code will work.

Michael

> 
> Thanks,
> 
> 	tglx


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

* RE: [PATCH 1/1] X86/Hyper-V:: Fix the circular dependency in IPI enlightenment.
  2018-07-06 16:12                   ` Michael Kelley (EOSG)
@ 2018-07-06 17:01                     ` Thomas Gleixner
  0 siblings, 0 replies; 17+ messages in thread
From: Thomas Gleixner @ 2018-07-06 17:01 UTC (permalink / raw)
  To: Michael Kelley (EOSG)
  Cc: KY Srinivasan, Ingo Molnar, x86, gregkh, linux-kernel, devel,
	olaf, apw, jasowang, hpa, Stephen Hemminger, vkuznets

On Fri, 6 Jul 2018, Michael Kelley (EOSG) wrote:
> > -----Original Message-----
> > From: Thomas Gleixner <tglx@linutronix.de>
> > Sent: Friday, July 6, 2018 3:42 AM
> > To: KY Srinivasan <kys@microsoft.com>
> > Cc: Ingo Molnar <mingo@kernel.org>; x86@kernel.org; gregkh@linuxfoundation.org; linux-
> > kernel@vger.kernel.org; devel@linuxdriverproject.org; olaf@aepfle.de; apw@canonical.com;
> > jasowang@redhat.com; hpa@zytor.com; Stephen Hemminger <sthemmin@microsoft.com>;
> > Michael Kelley (EOSG) <Michael.H.Kelley@microsoft.com>; vkuznets@redhat.com
> > Subject: RE: [PATCH 1/1] X86/Hyper-V:: Fix the circular dependency in IPI enlightenment.

Can you please strip that useless duplication of the mail header from your
replies. Manualy if you can't teach your MUA to avoid that :)

> > On Fri, 6 Jul 2018, Thomas Gleixner wrote:
> > Applied it to x86/urgent and fixed up the '-1' sloppy hack as pointed out
> > by Vitaly and merged x86/urgent into x86/hyperv.
> > 
> > Please check both branches for correctness.
> 
> Changes look good to me.  Some pre-existing signed/unsigned type sloppiness is
> still there in that hv_cpu_number_to_vp_number() should be 'u32' instead
> of 'int', along with related local variables, but that's probably best to fix in
> linux-next on top of Vitaly's other changes.  This code will work.

Yes, delta patch is fine on top of x86/hyperv.

Thanks,

	tglx

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

* RE: [PATCH 1/1] X86/Hyper-V:: Fix the circular dependency in IPI enlightenment.
  2018-07-06 10:42                 ` Thomas Gleixner
  2018-07-06 16:12                   ` Michael Kelley (EOSG)
@ 2018-07-06 18:05                   ` KY Srinivasan
  1 sibling, 0 replies; 17+ messages in thread
From: KY Srinivasan @ 2018-07-06 18:05 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: Ingo Molnar, x86, gregkh, linux-kernel, devel, olaf, apw,
	jasowang, hpa, Stephen Hemminger, Michael Kelley (EOSG),
	vkuznets



> -----Original Message-----
> On Fri, 6 Jul 2018, Thomas Gleixner wrote:
> > On Fri, 6 Jul 2018, KY Srinivasan wrote:
> > > >
> > > > The problem is that the wreckage is in Linus tree and needs to be fixed
> > > > there, i.e. via x86/urgent.
> > > >
> > > > Now we have the new bits queued in x86/hyperv already which collide.
> So
> > > > we
> > > > need to merge x86/urgent into x86/hyperv after applying the fix and
> mop up
> > > > the merge wreckage in x86/hyperv.
> > > >
> > > > I'll have a look tomorrow morning unless you beat me to it.
> > >
> > > I can rebase this patch against the latest tip and resend (tomorrow).
> >
> > That doesn't help as we need to push the original fix to Linus ...
> 
> Applied it to x86/urgent and fixed up the '-1' sloppy hack as pointed out
> by Vitaly and merged x86/urgent into x86/hyperv.
> 
> Please check both branches for correctness.

Thanks Thomas. The merge looks good.

Regards,

K. Y


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

end of thread, other threads:[~2018-07-06 18:06 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-03 23:01 [PATCH 1/1] X86/Hyper-V:: Fix the circular dependency in IPI enlightenment kys
2018-07-04  8:54 ` [tip:x86/urgent] x86/hyper-v: " tip-bot for K. Y. Srinivasan
2018-07-04  9:13 ` [PATCH 1/1] X86/Hyper-V:: " Vitaly Kuznetsov
2018-07-04 16:10 ` Ingo Molnar
2018-07-05 15:01   ` KY Srinivasan
2018-07-05 15:38     ` Ingo Molnar
2018-07-05 21:11       ` KY Srinivasan
2018-07-05 22:23         ` Ingo Molnar
2018-07-05 22:46           ` Thomas Gleixner
2018-07-06  3:59             ` KY Srinivasan
2018-07-06  8:53               ` Thomas Gleixner
2018-07-06 10:42                 ` Thomas Gleixner
2018-07-06 16:12                   ` Michael Kelley (EOSG)
2018-07-06 17:01                     ` Thomas Gleixner
2018-07-06 18:05                   ` KY Srinivasan
2018-07-06 10:00             ` Ingo Molnar
2018-07-06 10:42 ` [tip:x86/hyperv] x86/hyper-v: " tip-bot for K. Y. Srinivasan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).