[PATCH 17/45] KVM: arm/arm64: vgic-new: Add PRIORITY registers handlers
Andre Przywara
andre.przywara at arm.com
Fri Apr 15 10:11:28 PDT 2016
Signed-off-by: Andre Przywara <andre.przywara at arm.com>
---
virt/kvm/arm/vgic/vgic_mmio.c | 46 ++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 45 insertions(+), 1 deletion(-)
diff --git a/virt/kvm/arm/vgic/vgic_mmio.c b/virt/kvm/arm/vgic/vgic_mmio.c
index 7010b15..8e1e051 100644
--- a/virt/kvm/arm/vgic/vgic_mmio.c
+++ b/virt/kvm/arm/vgic/vgic_mmio.c
@@ -294,6 +294,50 @@ static int vgic_mmio_write_cpending(struct kvm_vcpu *vcpu,
return 0;
}
+static int vgic_mmio_read_priority(struct kvm_vcpu *vcpu,
+ struct kvm_io_device *dev,
+ gpa_t addr, int len, void *val)
+{
+ struct vgic_io_device *iodev = container_of(dev,
+ struct vgic_io_device, dev);
+ u32 intid = addr & 0x3ff;
+ int i;
+
+ if (iodev->redist_vcpu)
+ vcpu = iodev->redist_vcpu;
+
+ for (i = 0; i < len; i++) {
+ struct vgic_irq *irq = vgic_get_irq(vcpu->kvm, vcpu, intid + i);
+
+ ((u8 *)val)[i] = irq->priority;
+ }
+
+ return 0;
+}
+
+static int vgic_mmio_write_priority(struct kvm_vcpu *vcpu,
+ struct kvm_io_device *dev,
+ gpa_t addr, int len, const void *val)
+{
+ struct vgic_io_device *iodev = container_of(dev,
+ struct vgic_io_device, dev);
+ u32 intid = addr & 0x3ff;
+ int i;
+
+ if (iodev->redist_vcpu)
+ vcpu = iodev->redist_vcpu;
+
+ for (i = 0; i < len; i++) {
+ struct vgic_irq *irq = vgic_get_irq(vcpu->kvm, vcpu, intid + i);
+
+ spin_lock(&irq->irq_lock);
+ irq->priority = ((u8 *)val)[i];
+ spin_unlock(&irq->irq_lock);
+ }
+
+ return 0;
+}
+
struct vgic_register_region vgic_v2_dist_registers[] = {
REGISTER_DESC_WITH_LENGTH(GIC_DIST_CTRL,
vgic_mmio_read_v2_misc, vgic_mmio_write_v2_misc, 12),
@@ -312,7 +356,7 @@ struct vgic_register_region vgic_v2_dist_registers[] = {
REGISTER_DESC_WITH_BITS_PER_IRQ(GIC_DIST_ACTIVE_CLEAR,
vgic_mmio_read_nyi, vgic_mmio_write_nyi, 1),
REGISTER_DESC_WITH_BITS_PER_IRQ(GIC_DIST_PRI,
- vgic_mmio_read_nyi, vgic_mmio_write_nyi, 8),
+ vgic_mmio_read_priority, vgic_mmio_write_priority, 8),
REGISTER_DESC_WITH_BITS_PER_IRQ(GIC_DIST_TARGET,
vgic_mmio_read_nyi, vgic_mmio_write_nyi, 8),
REGISTER_DESC_WITH_BITS_PER_IRQ(GIC_DIST_CONFIG,
--
2.7.3
More information about the linux-arm-kernel
mailing list