mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2025-01-17 18:56:24 +00:00
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
This commit is contained in:
parent
de40bb8abb
commit
e0fc6b2161
@ -1439,11 +1439,28 @@ static int kvm_vm_ioctl_set_device_addr(struct kvm *kvm,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int kvm_vm_has_attr(struct kvm *kvm, struct kvm_device_attr *attr)
|
||||||
|
{
|
||||||
|
switch (attr->group) {
|
||||||
|
default:
|
||||||
|
return -ENXIO;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static int kvm_vm_set_attr(struct kvm *kvm, struct kvm_device_attr *attr)
|
||||||
|
{
|
||||||
|
switch (attr->group) {
|
||||||
|
default:
|
||||||
|
return -ENXIO;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
long kvm_arch_vm_ioctl(struct file *filp,
|
long kvm_arch_vm_ioctl(struct file *filp,
|
||||||
unsigned int ioctl, unsigned long arg)
|
unsigned int ioctl, unsigned long arg)
|
||||||
{
|
{
|
||||||
struct kvm *kvm = filp->private_data;
|
struct kvm *kvm = filp->private_data;
|
||||||
void __user *argp = (void __user *)arg;
|
void __user *argp = (void __user *)arg;
|
||||||
|
struct kvm_device_attr attr;
|
||||||
|
|
||||||
switch (ioctl) {
|
switch (ioctl) {
|
||||||
case KVM_CREATE_IRQCHIP: {
|
case KVM_CREATE_IRQCHIP: {
|
||||||
@ -1479,6 +1496,18 @@ long kvm_arch_vm_ioctl(struct file *filp,
|
|||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
return kvm_vm_ioctl_mte_copy_tags(kvm, ©_tags);
|
return kvm_vm_ioctl_mte_copy_tags(kvm, ©_tags);
|
||||||
}
|
}
|
||||||
|
case KVM_HAS_DEVICE_ATTR: {
|
||||||
|
if (copy_from_user(&attr, argp, sizeof(attr)))
|
||||||
|
return -EFAULT;
|
||||||
|
|
||||||
|
return kvm_vm_has_attr(kvm, &attr);
|
||||||
|
}
|
||||||
|
case KVM_SET_DEVICE_ATTR: {
|
||||||
|
if (copy_from_user(&attr, argp, sizeof(attr)))
|
||||||
|
return -EFAULT;
|
||||||
|
|
||||||
|
return kvm_vm_set_attr(kvm, &attr);
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user