Skip to content

Commit 4e7728c

Browse files
Marc Zyngieroupton
authored andcommitted
KVM: arm64: vgic-v2: Use cpuid from userspace as vcpu_id
When parsing a GICv2 attribute that contains a cpuid, handle this as the vcpu_id, not a vcpu_idx, as userspace cannot really know the mapping between the two. For this, use kvm_get_vcpu_by_id() instead of kvm_get_vcpu(). Take this opportunity to get rid of the pointless check against online_vcpus, which doesn't make much sense either, and switch to FIELD_GET as a way to extract the vcpu_id. Reviewed-by: Zenghui Yu <[email protected]> Signed-off-by: Marc Zyngier <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Oliver Upton <[email protected]>
1 parent f3f60a5 commit 4e7728c

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

arch/arm64/kvm/vgic/vgic-kvm-device.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -339,13 +339,9 @@ int vgic_v2_parse_attr(struct kvm_device *dev, struct kvm_device_attr *attr,
339339
{
340340
int cpuid;
341341

342-
cpuid = (attr->attr & KVM_DEV_ARM_VGIC_CPUID_MASK) >>
343-
KVM_DEV_ARM_VGIC_CPUID_SHIFT;
342+
cpuid = FIELD_GET(KVM_DEV_ARM_VGIC_CPUID_MASK, attr->attr);
344343

345-
if (cpuid >= atomic_read(&dev->kvm->online_vcpus))
346-
return -EINVAL;
347-
348-
reg_attr->vcpu = kvm_get_vcpu(dev->kvm, cpuid);
344+
reg_attr->vcpu = kvm_get_vcpu_by_id(dev->kvm, cpuid);
349345
reg_attr->addr = attr->attr & KVM_DEV_ARM_VGIC_OFFSET_MASK;
350346

351347
return 0;

0 commit comments

Comments
 (0)