Skip to content

Commit 0b6f4a5

Browse files
committed
KVM: x86/hyper-v: Use preallocated per-vCPU buffer for de-sparsified vCPU masks
Use a preallocated per-vCPU bitmap for tracking the unpacked set of vCPUs being targeted for Hyper-V's paravirt TLB flushing. If KVM_MAX_NR_VCPUS is set to 4096 (which is allowed even for MAXSMP=n builds), putting the vCPU mask on-stack pushes kvm_hv_flush_tlb() past the default FRAME_WARN limit. arch/x86/kvm/hyperv.c:2001:12: error: stack frame size (1288) exceeds limit (1024) in 'kvm_hv_flush_tlb' [-Werror,-Wframe-larger-than] 2001 | static u64 kvm_hv_flush_tlb(struct kvm_vcpu *vcpu, struct kvm_hv_hcall *hc) | ^ 1 error generated. Note, sparse_banks was given the same treatment by commit 7d5e88d ("KVM: x86: hyper-v: Use preallocated buffer in 'struct kvm_vcpu_hv' instead of on-stack 'sparse_banks'"), for the exact same reason. Reported-by: Abinash Lalotra <[email protected]> Closes: https://lore.kernel.org/all/[email protected] Link: https://lore.kernel.org/all/[email protected] Signed-off-by: Sean Christopherson <[email protected]>
1 parent 48f15f6 commit 0b6f4a5

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

arch/x86/include/asm/kvm_host.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -700,8 +700,13 @@ struct kvm_vcpu_hv {
700700

701701
struct kvm_vcpu_hv_tlb_flush_fifo tlb_flush_fifo[HV_NR_TLB_FLUSH_FIFOS];
702702

703-
/* Preallocated buffer for handling hypercalls passing sparse vCPU set */
703+
/*
704+
* Preallocated buffers for handling hypercalls that pass sparse vCPU
705+
* sets (for high vCPU counts, they're too large to comfortably fit on
706+
* the stack).
707+
*/
704708
u64 sparse_banks[HV_MAX_SPARSE_VCPU_BANKS];
709+
DECLARE_BITMAP(vcpu_mask, KVM_MAX_VCPUS);
705710

706711
struct hv_vp_assist_page vp_assist_page;
707712

arch/x86/kvm/hyperv.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2001,11 +2001,11 @@ int kvm_hv_vcpu_flush_tlb(struct kvm_vcpu *vcpu)
20012001
static u64 kvm_hv_flush_tlb(struct kvm_vcpu *vcpu, struct kvm_hv_hcall *hc)
20022002
{
20032003
struct kvm_vcpu_hv *hv_vcpu = to_hv_vcpu(vcpu);
2004+
unsigned long *vcpu_mask = hv_vcpu->vcpu_mask;
20042005
u64 *sparse_banks = hv_vcpu->sparse_banks;
20052006
struct kvm *kvm = vcpu->kvm;
20062007
struct hv_tlb_flush_ex flush_ex;
20072008
struct hv_tlb_flush flush;
2008-
DECLARE_BITMAP(vcpu_mask, KVM_MAX_VCPUS);
20092009
struct kvm_vcpu_hv_tlb_flush_fifo *tlb_flush_fifo;
20102010
/*
20112011
* Normally, there can be no more than 'KVM_HV_TLB_FLUSH_FIFO_SIZE'

0 commit comments

Comments
 (0)