]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit - include/uapi/linux/kvm.h
KVM: arm/arm64: vgic: Allow more than 256 vcpus for KVM_IRQ_LINE
authorMarc Zyngier <maz@kernel.org>
Sun, 18 Aug 2019 13:09:47 +0000 (14:09 +0100)
committerMarc Zyngier <maz@kernel.org>
Mon, 9 Sep 2019 11:29:09 +0000 (12:29 +0100)
commit92f35b751c71d14250a401246f2c792e3aa5b386
treea1a662935b14d6f2922517e1a45a708c182eb6c8
parente8688ba3874915b7d1661a57adf15a9c9e877df7
KVM: arm/arm64: vgic: Allow more than 256 vcpus for KVM_IRQ_LINE

While parts of the VGIC support a large number of vcpus (we
bravely allow up to 512), other parts are more limited.

One of these limits is visible in the KVM_IRQ_LINE ioctl, which
only allows 256 vcpus to be signalled when using the CPU or PPI
types. Unfortunately, we've cornered ourselves badly by allocating
all the bits in the irq field.

Since the irq_type subfield (8 bit wide) is currently only taking
the values 0, 1 and 2 (and we have been careful not to allow anything
else), let's reduce this field to only 4 bits, and allocate the
remaining 4 bits to a vcpu2_index, which acts as a multiplier:

  vcpu_id = 256 * vcpu2_index + vcpu_index

With that, and a new capability (KVM_CAP_ARM_IRQ_LINE_LAYOUT_2)
allowing this to be discovered, it becomes possible to inject
PPIs to up to 4096 vcpus. But please just don't.

Whilst we're there, add a clarification about the use of KVM_IRQ_LINE
on arm, which is not completely conditionned by KVM_CAP_IRQCHIP.

Reported-by: Zenghui Yu <yuzenghui@huawei.com>
Reviewed-by: Eric Auger <eric.auger@redhat.com>
Reviewed-by: Zenghui Yu <yuzenghui@huawei.com>
Signed-off-by: Marc Zyngier <maz@kernel.org>
Documentation/virt/kvm/api.txt
arch/arm/include/uapi/asm/kvm.h
arch/arm64/include/uapi/asm/kvm.h
include/uapi/linux/kvm.h
virt/kvm/arm/arm.c