diff options
author | Peter Maydell <peter.maydell@linaro.org> | 2014-12-11 12:07:53 +0000 |
---|---|---|
committer | Peter Maydell <peter.maydell@linaro.org> | 2014-12-11 12:07:53 +0000 |
commit | 72149414e25784de60b821fe67c56108a5b03ce1 (patch) | |
tree | 19cdf4b7e4e0249d43d1ba578d79aae4a2640eb1 /hw/intc/arm_gic_kvm.c | |
parent | a554ecb49d0021fd8bb0fd4f2f6be807b3c8b54f (diff) | |
download | qemu-72149414e25784de60b821fe67c56108a5b03ce1.tar.gz qemu-72149414e25784de60b821fe67c56108a5b03ce1.tar.bz2 qemu-72149414e25784de60b821fe67c56108a5b03ce1.zip |
arm_gic_kvm: Tell kernel about number of IRQs
Newer kernels support a device attribute on the GIC which allows us to
tell it how many IRQs this GIC instance is configured with; use it, if
it exists.
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Christoffer Dall <christoffer.dall@linaro.org>
Message-id: 1417718679-1071-1-git-send-email-peter.maydell@linaro.org
Diffstat (limited to 'hw/intc/arm_gic_kvm.c')
-rw-r--r-- | hw/intc/arm_gic_kvm.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/hw/intc/arm_gic_kvm.c b/hw/intc/arm_gic_kvm.c index 5038885afd..1ad3eb0ff8 100644 --- a/hw/intc/arm_gic_kvm.c +++ b/hw/intc/arm_gic_kvm.c @@ -92,6 +92,21 @@ static bool kvm_arm_gic_can_save_restore(GICState *s) return s->dev_fd >= 0; } +static bool kvm_gic_supports_attr(GICState *s, int group, int attrnum) +{ + struct kvm_device_attr attr = { + .group = group, + .attr = attrnum, + .flags = 0, + }; + + if (s->dev_fd == -1) { + return false; + } + + return kvm_device_ioctl(s->dev_fd, KVM_HAS_DEVICE_ATTR, &attr) == 0; +} + static void kvm_gic_access(GICState *s, int group, int offset, int cpu, uint32_t *val, bool write) { @@ -553,6 +568,11 @@ static void kvm_arm_gic_realize(DeviceState *dev, Error **errp) return; } + if (kvm_gic_supports_attr(s, KVM_DEV_ARM_VGIC_GRP_NR_IRQS, 0)) { + uint32_t numirqs = s->num_irq; + kvm_gic_access(s, KVM_DEV_ARM_VGIC_GRP_NR_IRQS, 0, 0, &numirqs, 1); + } + /* Distributor */ memory_region_init_reservation(&s->iomem, OBJECT(s), "kvm-gic_dist", 0x1000); |