summaryrefslogtreecommitdiffstats
path: root/virt
diff options
context:
space:
mode:
authorChristoffer Dall <christoffer.dall@linaro.org>2013-09-23 17:55:56 -0400
committerChristoffer Dall <christoffer.dall@linaro.org>2013-12-21 13:01:31 -0500
commit1006e8cb22e861260688917ca4cfe6cde8ad69eb (patch)
tree1d10860aaf8d3a865f3e4c196d0aa8e8999d4d1b /virt
parent0307e1770fdeff2732cf7a35d0f7f49db67c6621 (diff)
KVM: arm-vgic: Make vgic mmio functions more generic
Rename the vgic_ranges array to vgic_dist_ranges to be more specific and to prepare for handling CPU interface register access as well (for save/restore of VGIC state). Pass offset from distributor or interface MMIO base to find_matching_range function instead of the physical address of the access in the VM memory map. This allows other callers unaware of the VM specifics, but with generic VGIC knowledge to reuse the function. Acked-by: Marc Zyngier <marc.zyngier@arm.com> Signed-off-by: Christoffer Dall <christoffer.dall@linaro.org>
Diffstat (limited to 'virt')
-rw-r--r--virt/kvm/arm/vgic.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/virt/kvm/arm/vgic.c b/virt/kvm/arm/vgic.c
index 45db48de4282..e2596f618281 100644
--- a/virt/kvm/arm/vgic.c
+++ b/virt/kvm/arm/vgic.c
@@ -602,7 +602,7 @@ struct mmio_range {
602 phys_addr_t offset); 602 phys_addr_t offset);
603}; 603};
604 604
605static const struct mmio_range vgic_ranges[] = { 605static const struct mmio_range vgic_dist_ranges[] = {
606 { 606 {
607 .base = GIC_DIST_CTRL, 607 .base = GIC_DIST_CTRL,
608 .len = 12, 608 .len = 12,
@@ -669,14 +669,13 @@ static const struct mmio_range vgic_ranges[] = {
669static const 669static const
670struct mmio_range *find_matching_range(const struct mmio_range *ranges, 670struct mmio_range *find_matching_range(const struct mmio_range *ranges,
671 struct kvm_exit_mmio *mmio, 671 struct kvm_exit_mmio *mmio,
672 phys_addr_t base) 672 phys_addr_t offset)
673{ 673{
674 const struct mmio_range *r = ranges; 674 const struct mmio_range *r = ranges;
675 phys_addr_t addr = mmio->phys_addr - base;
676 675
677 while (r->len) { 676 while (r->len) {
678 if (addr >= r->base && 677 if (offset >= r->base &&
679 (addr + mmio->len) <= (r->base + r->len)) 678 (offset + mmio->len) <= (r->base + r->len))
680 return r; 679 return r;
681 r++; 680 r++;
682 } 681 }
@@ -713,7 +712,8 @@ bool vgic_handle_mmio(struct kvm_vcpu *vcpu, struct kvm_run *run,
713 return true; 712 return true;
714 } 713 }
715 714
716 range = find_matching_range(vgic_ranges, mmio, base); 715 offset = mmio->phys_addr - base;
716 range = find_matching_range(vgic_dist_ranges, mmio, offset);
717 if (unlikely(!range || !range->handle_mmio)) { 717 if (unlikely(!range || !range->handle_mmio)) {
718 pr_warn("Unhandled access %d %08llx %d\n", 718 pr_warn("Unhandled access %d %08llx %d\n",
719 mmio->is_write, mmio->phys_addr, mmio->len); 719 mmio->is_write, mmio->phys_addr, mmio->len);