Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

+6 -6
+6 -6
virt/kvm/arm/vgic.c
··· 602 602 phys_addr_t offset); 603 603 }; 604 604 605 - static const struct mmio_range vgic_ranges[] = { 605 + static const struct mmio_range vgic_dist_ranges[] = { 606 606 { 607 607 .base = GIC_DIST_CTRL, 608 608 .len = 12, ··· 669 669 static const 670 670 struct mmio_range *find_matching_range(const struct mmio_range *ranges, 671 671 struct kvm_exit_mmio *mmio, 672 - phys_addr_t base) 672 + phys_addr_t offset) 673 673 { 674 674 const struct mmio_range *r = ranges; 675 - phys_addr_t addr = mmio->phys_addr - base; 676 675 677 676 while (r->len) { 678 - if (addr >= r->base && 679 - (addr + mmio->len) <= (r->base + r->len)) 677 + if (offset >= r->base && 678 + (offset + mmio->len) <= (r->base + r->len)) 680 679 return r; 681 680 r++; 682 681 } ··· 712 713 return true; 713 714 } 714 715 715 - range = find_matching_range(vgic_ranges, mmio, base); 716 + offset = mmio->phys_addr - base; 717 + range = find_matching_range(vgic_dist_ranges, mmio, offset); 716 718 if (unlikely(!range || !range->handle_mmio)) { 717 719 pr_warn("Unhandled access %d %08llx %d\n", 718 720 mmio->is_write, mmio->phys_addr, mmio->len);