* [PATCH 11/22] KVM: x86: hyper-v: replace bitmap_weight() with hweight64()
[not found] <20220510154750.212913-1-yury.norov@gmail.com>
@ 2022-05-10 15:47 ` Yury Norov
2022-05-16 13:08 ` Vitaly Kuznetsov
2022-05-22 14:53 ` Guenter Roeck
0 siblings, 2 replies; 4+ messages in thread
From: Yury Norov @ 2022-05-10 15:47 UTC (permalink / raw)
To: Andy Shevchenko, David Laight, Greg Kroah-Hartman, Joe Perches,
Julia Lawall, Michał Mirosław, Nicholas Piggin,
Nicolas Palix, Peter Zijlstra, Rasmus Villemoes, Matti Vaittinen,
linux-kernel
Cc: Yury Norov, Borislav Petkov, Dave Hansen, H . Peter Anvin,
Ingo Molnar, Jim Mattson, Joerg Roedel, Paolo Bonzini,
Sean Christopherson, Thomas Gleixner, Vitaly Kuznetsov,
Wanpeng Li, kvm, x86
kvm_hv_flush_tlb() applies bitmap API to a u64 variable valid_bank_mask.
Since valid_bank_mask has a fixed size, we can use hweight64() and avoid
excessive bloating.
CC: Borislav Petkov <bp@alien8.de>
CC: Dave Hansen <dave.hansen@linux.intel.com>
CC: H. Peter Anvin <hpa@zytor.com>
CC: Ingo Molnar <mingo@redhat.com>
CC: Jim Mattson <jmattson@google.com>
CC: Joerg Roedel <joro@8bytes.org>
CC: Paolo Bonzini <pbonzini@redhat.com>
CC: Sean Christopherson <seanjc@google.com>
CC: Thomas Gleixner <tglx@linutronix.de>
CC: Vitaly Kuznetsov <vkuznets@redhat.com>
CC: Wanpeng Li <wanpengli@tencent.com>
CC: kvm@vger.kernel.org
CC: linux-kernel@vger.kernel.org
CC: x86@kernel.org
Signed-off-by: Yury Norov <yury.norov@gmail.com>
---
arch/x86/kvm/hyperv.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/x86/kvm/hyperv.c b/arch/x86/kvm/hyperv.c
index 41585f0edf1e..b652b856df2b 100644
--- a/arch/x86/kvm/hyperv.c
+++ b/arch/x86/kvm/hyperv.c
@@ -1855,7 +1855,7 @@ static u64 kvm_hv_flush_tlb(struct kvm_vcpu *vcpu, struct kvm_hv_hcall *hc)
all_cpus = flush_ex.hv_vp_set.format !=
HV_GENERIC_SET_SPARSE_4K;
- if (hc->var_cnt != bitmap_weight((unsigned long *)&valid_bank_mask, 64))
+ if (hc->var_cnt != hweight64(valid_bank_mask))
return HV_STATUS_INVALID_HYPERCALL_INPUT;
if (all_cpus)
@@ -1956,7 +1956,7 @@ static u64 kvm_hv_send_ipi(struct kvm_vcpu *vcpu, struct kvm_hv_hcall *hc)
valid_bank_mask = send_ipi_ex.vp_set.valid_bank_mask;
all_cpus = send_ipi_ex.vp_set.format == HV_GENERIC_SET_ALL;
- if (hc->var_cnt != bitmap_weight(&valid_bank_mask, 64))
+ if (hc->var_cnt != hweight64(valid_bank_mask))
return HV_STATUS_INVALID_HYPERCALL_INPUT;
if (all_cpus)
--
2.32.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 11/22] KVM: x86: hyper-v: replace bitmap_weight() with hweight64()
2022-05-10 15:47 ` [PATCH 11/22] KVM: x86: hyper-v: replace bitmap_weight() with hweight64() Yury Norov
@ 2022-05-16 13:08 ` Vitaly Kuznetsov
2022-05-22 14:53 ` Guenter Roeck
1 sibling, 0 replies; 4+ messages in thread
From: Vitaly Kuznetsov @ 2022-05-16 13:08 UTC (permalink / raw)
To: Yury Norov
Cc: Borislav Petkov, Dave Hansen, H . Peter Anvin, Ingo Molnar,
Jim Mattson, Joerg Roedel, Paolo Bonzini, Sean Christopherson,
Thomas Gleixner, Wanpeng Li, kvm, x86, Andy Shevchenko,
David Laight, Greg Kroah-Hartman, Joe Perches, Julia Lawall,
Michał Mirosław, Nicholas Piggin, Nicolas Palix,
Peter Zijlstra, Rasmus Villemoes, Matti Vaittinen, linux-kernel
Yury Norov <yury.norov@gmail.com> writes:
> kvm_hv_flush_tlb() applies bitmap API to a u64 variable valid_bank_mask.
> Since valid_bank_mask has a fixed size, we can use hweight64() and avoid
> excessive bloating.
>
> CC: Borislav Petkov <bp@alien8.de>
> CC: Dave Hansen <dave.hansen@linux.intel.com>
> CC: H. Peter Anvin <hpa@zytor.com>
> CC: Ingo Molnar <mingo@redhat.com>
> CC: Jim Mattson <jmattson@google.com>
> CC: Joerg Roedel <joro@8bytes.org>
> CC: Paolo Bonzini <pbonzini@redhat.com>
> CC: Sean Christopherson <seanjc@google.com>
> CC: Thomas Gleixner <tglx@linutronix.de>
> CC: Vitaly Kuznetsov <vkuznets@redhat.com>
> CC: Wanpeng Li <wanpengli@tencent.com>
> CC: kvm@vger.kernel.org
> CC: linux-kernel@vger.kernel.org
> CC: x86@kernel.org
> Signed-off-by: Yury Norov <yury.norov@gmail.com>
> ---
> arch/x86/kvm/hyperv.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/arch/x86/kvm/hyperv.c b/arch/x86/kvm/hyperv.c
> index 41585f0edf1e..b652b856df2b 100644
> --- a/arch/x86/kvm/hyperv.c
> +++ b/arch/x86/kvm/hyperv.c
> @@ -1855,7 +1855,7 @@ static u64 kvm_hv_flush_tlb(struct kvm_vcpu *vcpu, struct kvm_hv_hcall *hc)
> all_cpus = flush_ex.hv_vp_set.format !=
> HV_GENERIC_SET_SPARSE_4K;
>
> - if (hc->var_cnt != bitmap_weight((unsigned long *)&valid_bank_mask, 64))
> + if (hc->var_cnt != hweight64(valid_bank_mask))
> return HV_STATUS_INVALID_HYPERCALL_INPUT;
>
> if (all_cpus)
> @@ -1956,7 +1956,7 @@ static u64 kvm_hv_send_ipi(struct kvm_vcpu *vcpu, struct kvm_hv_hcall *hc)
> valid_bank_mask = send_ipi_ex.vp_set.valid_bank_mask;
> all_cpus = send_ipi_ex.vp_set.format == HV_GENERIC_SET_ALL;
>
> - if (hc->var_cnt != bitmap_weight(&valid_bank_mask, 64))
> + if (hc->var_cnt != hweight64(valid_bank_mask))
> return HV_STATUS_INVALID_HYPERCALL_INPUT;
>
> if (all_cpus)
(please Cc: me on the whole series next time)
Acked-by: Vitaly Kuznetsov <vkuznets@redhat.com>
--
Vitaly
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 11/22] KVM: x86: hyper-v: replace bitmap_weight() with hweight64()
2022-05-10 15:47 ` [PATCH 11/22] KVM: x86: hyper-v: replace bitmap_weight() with hweight64() Yury Norov
2022-05-16 13:08 ` Vitaly Kuznetsov
@ 2022-05-22 14:53 ` Guenter Roeck
2022-05-22 17:39 ` Yury Norov
1 sibling, 1 reply; 4+ messages in thread
From: Guenter Roeck @ 2022-05-22 14:53 UTC (permalink / raw)
To: Yury Norov
Cc: Andy Shevchenko, David Laight, Greg Kroah-Hartman, Joe Perches,
Julia Lawall, Michał Mirosław, Nicholas Piggin,
Nicolas Palix, Peter Zijlstra, Rasmus Villemoes, Matti Vaittinen,
linux-kernel, Borislav Petkov, Dave Hansen, H . Peter Anvin,
Ingo Molnar, Jim Mattson, Joerg Roedel, Paolo Bonzini,
Sean Christopherson, Thomas Gleixner, Vitaly Kuznetsov,
Wanpeng Li, kvm, x86
On Tue, May 10, 2022 at 08:47:39AM -0700, Yury Norov wrote:
> kvm_hv_flush_tlb() applies bitmap API to a u64 variable valid_bank_mask.
> Since valid_bank_mask has a fixed size, we can use hweight64() and avoid
> excessive bloating.
In kvm_hv_send_ipi(), valid_bank_mask is unsigned long, not u64.
This results in:
arch/x86/kvm/hyperv.c: In function 'kvm_hv_send_ipi':
include/asm-generic/bitops/const_hweight.h:21:76: error: right shift count >= width of type
on all 32-bit builds.
Guenter
>
> CC: Borislav Petkov <bp@alien8.de>
> CC: Dave Hansen <dave.hansen@linux.intel.com>
> CC: H. Peter Anvin <hpa@zytor.com>
> CC: Ingo Molnar <mingo@redhat.com>
> CC: Jim Mattson <jmattson@google.com>
> CC: Joerg Roedel <joro@8bytes.org>
> CC: Paolo Bonzini <pbonzini@redhat.com>
> CC: Sean Christopherson <seanjc@google.com>
> CC: Thomas Gleixner <tglx@linutronix.de>
> CC: Vitaly Kuznetsov <vkuznets@redhat.com>
> CC: Wanpeng Li <wanpengli@tencent.com>
> CC: kvm@vger.kernel.org
> CC: linux-kernel@vger.kernel.org
> CC: x86@kernel.org
> Signed-off-by: Yury Norov <yury.norov@gmail.com>
> ---
> arch/x86/kvm/hyperv.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/arch/x86/kvm/hyperv.c b/arch/x86/kvm/hyperv.c
> index 41585f0edf1e..b652b856df2b 100644
> --- a/arch/x86/kvm/hyperv.c
> +++ b/arch/x86/kvm/hyperv.c
> @@ -1855,7 +1855,7 @@ static u64 kvm_hv_flush_tlb(struct kvm_vcpu *vcpu, struct kvm_hv_hcall *hc)
> all_cpus = flush_ex.hv_vp_set.format !=
> HV_GENERIC_SET_SPARSE_4K;
>
> - if (hc->var_cnt != bitmap_weight((unsigned long *)&valid_bank_mask, 64))
> + if (hc->var_cnt != hweight64(valid_bank_mask))
> return HV_STATUS_INVALID_HYPERCALL_INPUT;
>
> if (all_cpus)
> @@ -1956,7 +1956,7 @@ static u64 kvm_hv_send_ipi(struct kvm_vcpu *vcpu, struct kvm_hv_hcall *hc)
> valid_bank_mask = send_ipi_ex.vp_set.valid_bank_mask;
> all_cpus = send_ipi_ex.vp_set.format == HV_GENERIC_SET_ALL;
>
> - if (hc->var_cnt != bitmap_weight(&valid_bank_mask, 64))
> + if (hc->var_cnt != hweight64(valid_bank_mask))
> return HV_STATUS_INVALID_HYPERCALL_INPUT;
>
> if (all_cpus)
> --
> 2.32.0
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 11/22] KVM: x86: hyper-v: replace bitmap_weight() with hweight64()
2022-05-22 14:53 ` Guenter Roeck
@ 2022-05-22 17:39 ` Yury Norov
0 siblings, 0 replies; 4+ messages in thread
From: Yury Norov @ 2022-05-22 17:39 UTC (permalink / raw)
To: Guenter Roeck
Cc: Andy Shevchenko, David Laight, Greg Kroah-Hartman, Joe Perches,
Julia Lawall, Michał Mirosław, Nicholas Piggin,
Nicolas Palix, Peter Zijlstra, Rasmus Villemoes, Matti Vaittinen,
linux-kernel, Borislav Petkov, Dave Hansen, H . Peter Anvin,
Ingo Molnar, Jim Mattson, Joerg Roedel, Paolo Bonzini,
Sean Christopherson, Thomas Gleixner, Vitaly Kuznetsov,
Wanpeng Li, kvm, x86
On Sun, May 22, 2022 at 07:53:57AM -0700, Guenter Roeck wrote:
> On Tue, May 10, 2022 at 08:47:39AM -0700, Yury Norov wrote:
> > kvm_hv_flush_tlb() applies bitmap API to a u64 variable valid_bank_mask.
> > Since valid_bank_mask has a fixed size, we can use hweight64() and avoid
> > excessive bloating.
>
> In kvm_hv_send_ipi(), valid_bank_mask is unsigned long, not u64.
>
> This results in:
>
> arch/x86/kvm/hyperv.c: In function 'kvm_hv_send_ipi':
> include/asm-generic/bitops/const_hweight.h:21:76: error: right shift count >= width of type
>
> on all 32-bit builds.
>
> Guenter
Hi Guenter,
The fix is in Paolo's tree:
https://lore.kernel.org/lkml/20220519171504.1238724-1-yury.norov@gmail.com/T/
Thanks,
Yury
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-05-22 17:39 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20220510154750.212913-1-yury.norov@gmail.com>
2022-05-10 15:47 ` [PATCH 11/22] KVM: x86: hyper-v: replace bitmap_weight() with hweight64() Yury Norov
2022-05-16 13:08 ` Vitaly Kuznetsov
2022-05-22 14:53 ` Guenter Roeck
2022-05-22 17:39 ` Yury Norov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox