All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/1] X86: Fix the circular dependency in IPI enlightenment.
@ 2018-07-03 22:36 kys
  2018-07-03 22:44 ` KY Srinivasan
  0 siblings, 1 reply; 2+ messages in thread
From: kys @ 2018-07-03 22:36 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       | 3 +++
 arch/x86/include/asm/mshyperv.h | 2 ++
 3 files changed, 10 insertions(+)

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 595e44e8abaa..762ce164d733 100644
--- a/arch/x86/hyperv/hv_init.c
+++ b/arch/x86/hyperv/hv_init.c
@@ -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 81e768b8d9eb..299de3dcc319 100644
--- a/arch/x86/include/asm/mshyperv.h
+++ b/arch/x86/include/asm/mshyperv.h
@@ -285,6 +285,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] 2+ messages in thread

* RE: [PATCH 1/1] X86: Fix the circular dependency in IPI enlightenment.
  2018-07-03 22:36 [PATCH 1/1] X86: Fix the circular dependency in IPI enlightenment kys
@ 2018-07-03 22:44 ` KY Srinivasan
  0 siblings, 0 replies; 2+ messages in thread
From: KY Srinivasan @ 2018-07-03 22:44 UTC (permalink / raw)
  To: KY Srinivasan, 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,
	Michael Kelley (EOSG), vkuznets@redhat.com



> -----Original Message-----
> From: kys@linuxonhyperv.com <kys@linuxonhyperv.com>
> Sent: Tuesday, July 3, 2018 3:37 PM
> To: 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
> Cc: KY Srinivasan <kys@microsoft.com>
> Subject: [PATCH 1/1] X86: Fix the circular dependency in IPI enlightenment.
> 
> 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")

Please drop this patch; I have sent the wrong patch.

Regards,

K. Y
> 
> 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       | 3 +++
>  arch/x86/include/asm/mshyperv.h | 2 ++
>  3 files changed, 10 insertions(+)
> 
> 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 595e44e8abaa..762ce164d733 100644
> --- a/arch/x86/hyperv/hv_init.c
> +++ b/arch/x86/hyperv/hv_init.c
> @@ -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 81e768b8d9eb..299de3dcc319 100644
> --- a/arch/x86/include/asm/mshyperv.h
> +++ b/arch/x86/include/asm/mshyperv.h
> @@ -285,6 +285,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	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-07-03 22:44 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-07-03 22:36 [PATCH 1/1] X86: Fix the circular dependency in IPI enlightenment kys
2018-07-03 22:44 ` KY Srinivasan

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.