Skip to content

Commit e0fc6b2

Browse files
ouptonMarc Zyngier
authored andcommitted
KVM: arm64: Add vm fd device attribute accessors
A subsequent change will allow userspace to convey a filter for hypercalls through a vm device attribute. Add the requisite boilerplate for vm attribute accessors. Reviewed-by: Suzuki K Poulose <suzuki.poulose@arm.com> Signed-off-by: Oliver Upton <oliver.upton@linux.dev> Signed-off-by: Marc Zyngier <maz@kernel.org> Link: https://lore.kernel.org/r/20230404154050.2270077-4-oliver.upton@linux.dev
1 parent de40bb8 commit e0fc6b2

1 file changed

Lines changed: 29 additions & 0 deletions

File tree

arch/arm64/kvm/arm.c

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1439,11 +1439,28 @@ static int kvm_vm_ioctl_set_device_addr(struct kvm *kvm,
14391439
}
14401440
}
14411441

1442+
static int kvm_vm_has_attr(struct kvm *kvm, struct kvm_device_attr *attr)
1443+
{
1444+
switch (attr->group) {
1445+
default:
1446+
return -ENXIO;
1447+
}
1448+
}
1449+
1450+
static int kvm_vm_set_attr(struct kvm *kvm, struct kvm_device_attr *attr)
1451+
{
1452+
switch (attr->group) {
1453+
default:
1454+
return -ENXIO;
1455+
}
1456+
}
1457+
14421458
long kvm_arch_vm_ioctl(struct file *filp,
14431459
unsigned int ioctl, unsigned long arg)
14441460
{
14451461
struct kvm *kvm = filp->private_data;
14461462
void __user *argp = (void __user *)arg;
1463+
struct kvm_device_attr attr;
14471464

14481465
switch (ioctl) {
14491466
case KVM_CREATE_IRQCHIP: {
@@ -1479,6 +1496,18 @@ long kvm_arch_vm_ioctl(struct file *filp,
14791496
return -EFAULT;
14801497
return kvm_vm_ioctl_mte_copy_tags(kvm, &copy_tags);
14811498
}
1499+
case KVM_HAS_DEVICE_ATTR: {
1500+
if (copy_from_user(&attr, argp, sizeof(attr)))
1501+
return -EFAULT;
1502+
1503+
return kvm_vm_has_attr(kvm, &attr);
1504+
}
1505+
case KVM_SET_DEVICE_ATTR: {
1506+
if (copy_from_user(&attr, argp, sizeof(attr)))
1507+
return -EFAULT;
1508+
1509+
return kvm_vm_set_attr(kvm, &attr);
1510+
}
14821511
default:
14831512
return -EINVAL;
14841513
}

0 commit comments

Comments
 (0)