Commit e5c30294 authored by Eric Auger's avatar Eric Auger Committed by Christoffer Dall

KVM: arm/arm64: vgic-new: vgic_kvm_device: KVM_DEV_ARM_VGIC_GRP_ADDR

This patch implements the KVM_DEV_ARM_VGIC_GRP_ADDR group which
enables to set the base address of GIC regions as seen by the guest.
Signed-off-by: default avatarEric Auger <eric.auger@linaro.org>
Signed-off-by: default avatarAndre Przywara <andre.przywara@arm.com>
Reviewed-by: default avatarChristoffer Dall <christoffer.dall@linaro.org>
parent e2c1f9ab
...@@ -112,6 +112,17 @@ static int vgic_set_common_attr(struct kvm_device *dev, ...@@ -112,6 +112,17 @@ static int vgic_set_common_attr(struct kvm_device *dev,
int r; int r;
switch (attr->group) { switch (attr->group) {
case KVM_DEV_ARM_VGIC_GRP_ADDR: {
u64 __user *uaddr = (u64 __user *)(long)attr->addr;
u64 addr;
unsigned long type = (unsigned long)attr->attr;
if (copy_from_user(&addr, uaddr, sizeof(addr)))
return -EFAULT;
r = kvm_vgic_addr(dev->kvm, type, &addr, true);
return (r == -ENODEV) ? -ENXIO : r;
}
case KVM_DEV_ARM_VGIC_GRP_NR_IRQS: { case KVM_DEV_ARM_VGIC_GRP_NR_IRQS: {
u32 __user *uaddr = (u32 __user *)(long)attr->addr; u32 __user *uaddr = (u32 __user *)(long)attr->addr;
u32 val; u32 val;
...@@ -164,6 +175,19 @@ static int vgic_get_common_attr(struct kvm_device *dev, ...@@ -164,6 +175,19 @@ static int vgic_get_common_attr(struct kvm_device *dev,
int r = -ENXIO; int r = -ENXIO;
switch (attr->group) { switch (attr->group) {
case KVM_DEV_ARM_VGIC_GRP_ADDR: {
u64 __user *uaddr = (u64 __user *)(long)attr->addr;
u64 addr;
unsigned long type = (unsigned long)attr->attr;
r = kvm_vgic_addr(dev->kvm, type, &addr, false);
if (r)
return (r == -ENODEV) ? -ENXIO : r;
if (copy_to_user(uaddr, &addr, sizeof(addr)))
return -EFAULT;
break;
}
case KVM_DEV_ARM_VGIC_GRP_NR_IRQS: { case KVM_DEV_ARM_VGIC_GRP_NR_IRQS: {
u32 __user *uaddr = (u32 __user *)(long)attr->addr; u32 __user *uaddr = (u32 __user *)(long)attr->addr;
...@@ -227,6 +251,13 @@ static int vgic_v2_has_attr(struct kvm_device *dev, ...@@ -227,6 +251,13 @@ static int vgic_v2_has_attr(struct kvm_device *dev,
struct kvm_device_attr *attr) struct kvm_device_attr *attr)
{ {
switch (attr->group) { switch (attr->group) {
case KVM_DEV_ARM_VGIC_GRP_ADDR:
switch (attr->attr) {
case KVM_VGIC_V2_ADDR_TYPE_DIST:
case KVM_VGIC_V2_ADDR_TYPE_CPU:
return 0;
}
break;
case KVM_DEV_ARM_VGIC_GRP_NR_IRQS: case KVM_DEV_ARM_VGIC_GRP_NR_IRQS:
return 0; return 0;
case KVM_DEV_ARM_VGIC_GRP_CTRL: case KVM_DEV_ARM_VGIC_GRP_CTRL:
...@@ -267,6 +298,13 @@ static int vgic_v3_has_attr(struct kvm_device *dev, ...@@ -267,6 +298,13 @@ static int vgic_v3_has_attr(struct kvm_device *dev,
struct kvm_device_attr *attr) struct kvm_device_attr *attr)
{ {
switch (attr->group) { switch (attr->group) {
case KVM_DEV_ARM_VGIC_GRP_ADDR:
switch (attr->attr) {
case KVM_VGIC_V3_ADDR_TYPE_DIST:
case KVM_VGIC_V3_ADDR_TYPE_REDIST:
return 0;
}
break;
case KVM_DEV_ARM_VGIC_GRP_NR_IRQS: case KVM_DEV_ARM_VGIC_GRP_NR_IRQS:
return 0; return 0;
case KVM_DEV_ARM_VGIC_GRP_CTRL: case KVM_DEV_ARM_VGIC_GRP_CTRL:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment