Re: [RFC PATCH] KVM: x86: Dynamically allocate bitmap to fix -Wframe-larger-than error

From: Paolo Bonzini
Date: Fri Jun 13 2025 - 07:26:07 EST


On Fri, Jun 13, 2025 at 1:11 PM avinashlalotra <abinashlalotra@xxxxxxxxx> wrote:
> diff --git a/arch/x86/kvm/hyperv.c b/arch/x86/kvm/hyperv.c
> index 24f0318c50d7..78bb8d58fe94 100644
> --- a/arch/x86/kvm/hyperv.c
> +++ b/arch/x86/kvm/hyperv.c
> @@ -2005,7 +2005,7 @@ static u64 kvm_hv_flush_tlb(struct kvm_vcpu *vcpu, struct kvm_hv_hcall *hc)
> struct kvm *kvm = vcpu->kvm;
> struct hv_tlb_flush_ex flush_ex;
> struct hv_tlb_flush flush;
> - DECLARE_BITMAP(vcpu_mask, KVM_MAX_VCPUS);
> + unsigned long *vcpu_mask;

The default KVM_MAX_VCPUS is 1024, which is not too bad; you're
probably compiling with CONFIG_MAXSMP and accepting the default limit
of 4096. Adding an allocation for every hypercall is not great, I'd
rather add it to struct kvm_vcpu_arch* instead.

If instead we go for having the allocation, you can use this:

unsigned long *vcpu_mask __free(bitmap) = NULL;

and avoid changing the returns to gotos everywhere else.

Paolo