aboutsummaryrefslogtreecommitdiffstats
path: root/virt/kvm
diff options
context:
space:
mode:
authorAndre Przywara <andre.przywara@arm.com>2015-03-26 10:39:33 -0400
committerMarc Zyngier <marc.zyngier@arm.com>2015-03-26 17:43:14 -0400
commit9f199d0a0eeb8efb564ff41a6b9f819c4c0285ea (patch)
tree3152ce85a88129a5e29290aefdffc1772553e07d /virt/kvm
parentcf50a1eb43b98daa181714e40e22c8e5ad5007d6 (diff)
KVM: arm/arm64: simplify vgic_find_range() and callers
The vgic_find_range() function in vgic.c takes a struct kvm_exit_mmio argument, but actually only used the length field in there. Since we need to get rid of that structure in that part of the code anyway, let's rework the function (and it's callers) to pass the length argument to the function directly. Signed-off-by: Andre Przywara <andre.przywara@arm.com> Reviewed-by: Christoffer Dall <christoffer.dall@linaro.org> Reviewed-by: Marc Zyngier <marc.zyngier@arm.com> Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
Diffstat (limited to 'virt/kvm')
-rw-r--r--virt/kvm/arm/vgic-v2-emul.c2
-rw-r--r--virt/kvm/arm/vgic.c22
-rw-r--r--virt/kvm/arm/vgic.h3
3 files changed, 10 insertions, 17 deletions
diff --git a/virt/kvm/arm/vgic-v2-emul.c b/virt/kvm/arm/vgic-v2-emul.c
index ddb3135363d8..1dd183ecf96f 100644
--- a/virt/kvm/arm/vgic-v2-emul.c
+++ b/virt/kvm/arm/vgic-v2-emul.c
@@ -715,7 +715,7 @@ static int vgic_attr_regs_access(struct kvm_device *dev,
715 default: 715 default:
716 BUG(); 716 BUG();
717 } 717 }
718 r = vgic_find_range(ranges, &mmio, offset); 718 r = vgic_find_range(ranges, 4, offset);
719 719
720 if (unlikely(!r || !r->handle_mmio)) { 720 if (unlikely(!r || !r->handle_mmio)) {
721 ret = -ENXIO; 721 ret = -ENXIO;
diff --git a/virt/kvm/arm/vgic.c b/virt/kvm/arm/vgic.c
index 21a3550d525c..8802ad73467f 100644
--- a/virt/kvm/arm/vgic.c
+++ b/virt/kvm/arm/vgic.c
@@ -713,16 +713,13 @@ void vgic_unqueue_irqs(struct kvm_vcpu *vcpu)
713 713
714const 714const
715struct vgic_io_range *vgic_find_range(const struct vgic_io_range *ranges, 715struct vgic_io_range *vgic_find_range(const struct vgic_io_range *ranges,
716 struct kvm_exit_mmio *mmio, 716 int len, gpa_t offset)
717 phys_addr_t offset)
718{ 717{
719 const struct vgic_io_range *r = ranges; 718 while (ranges->len) {
720 719 if (offset >= ranges->base &&
721 while (r->len) { 720 (offset + len) <= (ranges->base + ranges->len))
722 if (offset >= r->base && 721 return ranges;
723 (offset + mmio->len) <= (r->base + r->len)) 722 ranges++;
724 return r;
725 r++;
726 } 723 }
727 724
728 return NULL; 725 return NULL;
@@ -813,7 +810,7 @@ bool vgic_handle_mmio_range(struct kvm_vcpu *vcpu, struct kvm_run *run,
813 unsigned long offset; 810 unsigned long offset;
814 811
815 offset = mmio->phys_addr - mmio_base; 812 offset = mmio->phys_addr - mmio_base;
816 range = vgic_find_range(ranges, mmio, offset); 813 range = vgic_find_range(ranges, mmio->len, offset);
817 if (unlikely(!range || !range->handle_mmio)) { 814 if (unlikely(!range || !range->handle_mmio)) {
818 pr_warn("Unhandled access %d %08llx %d\n", 815 pr_warn("Unhandled access %d %08llx %d\n",
819 mmio->is_write, mmio->phys_addr, mmio->len); 816 mmio->is_write, mmio->phys_addr, mmio->len);
@@ -1986,10 +1983,7 @@ int vgic_get_common_attr(struct kvm_device *dev, struct kvm_device_attr *attr)
1986 1983
1987int vgic_has_attr_regs(const struct vgic_io_range *ranges, phys_addr_t offset) 1984int vgic_has_attr_regs(const struct vgic_io_range *ranges, phys_addr_t offset)
1988{ 1985{
1989 struct kvm_exit_mmio dev_attr_mmio; 1986 if (vgic_find_range(ranges, 4, offset))
1990
1991 dev_attr_mmio.len = 4;
1992 if (vgic_find_range(ranges, &dev_attr_mmio, offset))
1993 return 0; 1987 return 0;
1994 else 1988 else
1995 return -ENXIO; 1989 return -ENXIO;
diff --git a/virt/kvm/arm/vgic.h b/virt/kvm/arm/vgic.h
index 6fccb969b169..01aa6228f88b 100644
--- a/virt/kvm/arm/vgic.h
+++ b/virt/kvm/arm/vgic.h
@@ -90,8 +90,7 @@ static inline bool is_in_range(phys_addr_t addr, unsigned long len,
90 90
91const 91const
92struct vgic_io_range *vgic_find_range(const struct vgic_io_range *ranges, 92struct vgic_io_range *vgic_find_range(const struct vgic_io_range *ranges,
93 struct kvm_exit_mmio *mmio, 93 int len, gpa_t offset);
94 phys_addr_t offset);
95 94
96bool vgic_handle_mmio_range(struct kvm_vcpu *vcpu, struct kvm_run *run, 95bool vgic_handle_mmio_range(struct kvm_vcpu *vcpu, struct kvm_run *run,
97 struct kvm_exit_mmio *mmio, 96 struct kvm_exit_mmio *mmio,