arm: simplify MMIO dispatching

Currently we separate any incoming MMIO request into one of the ARM
memory map regions and take care to spare the GIC.
It turns out that this is unnecessary, as we only have one special
region (the IO port area in the first 64 KByte). The MMIO rbtree
takes care about unhandled MMIO ranges, so we can simply drop all the
special range checking (except that for the IO range) in
kvm_cpu__emulate_mmio().
As the GIC is handled in the kernel, a GIC MMIO access should never
reach userland (and we don't know what to do with it anyway).
This lets us delete some more code and simplifies future extensions
(like expanding the GIC regions).
To be in line with the other architectures, move the now simpler
code into a header file.

Signed-off-by: Andre Przywara <andre.przywara@arm.com>
Reviewed-by: Marc Zyngier <marc.zyngier@arm.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
This commit is contained in:
Andre Przywara
2015-07-03 12:26:34 +01:00
committed by Will Deacon
parent b579030279
commit ce6ae1228a
3 changed files with 12 additions and 30 deletions
-12
View File
@@ -45,18 +45,6 @@ static inline bool arm_addr_in_ioport_region(u64 phys_addr)
return phys_addr >= KVM_IOPORT_AREA && phys_addr < limit;
}
static inline bool arm_addr_in_virtio_mmio_region(u64 phys_addr)
{
u64 limit = KVM_VIRTIO_MMIO_AREA + ARM_VIRTIO_MMIO_SIZE;
return phys_addr >= KVM_VIRTIO_MMIO_AREA && phys_addr < limit;
}
static inline bool arm_addr_in_pci_region(u64 phys_addr)
{
u64 limit = KVM_PCI_CFG_AREA + ARM_PCI_CFG_SIZE + ARM_PCI_MMIO_SIZE;
return phys_addr >= KVM_PCI_CFG_AREA && phys_addr < limit;
}
struct kvm_arch {
/*
* We may have to align the guest memory for virtio, so keep the
+12 -2
View File
@@ -44,8 +44,18 @@ static inline bool kvm_cpu__emulate_io(struct kvm_cpu *vcpu, u16 port, void *dat
return false;
}
bool kvm_cpu__emulate_mmio(struct kvm_cpu *vcpu, u64 phys_addr, u8 *data,
u32 len, u8 is_write);
static inline bool kvm_cpu__emulate_mmio(struct kvm_cpu *vcpu, u64 phys_addr,
u8 *data, u32 len, u8 is_write)
{
if (arm_addr_in_ioport_region(phys_addr)) {
int direction = is_write ? KVM_EXIT_IO_OUT : KVM_EXIT_IO_IN;
u16 port = (phys_addr - KVM_IOPORT_AREA) & USHRT_MAX;
return kvm__emulate_io(vcpu, port, data, direction, len, 1);
}
return kvm__emulate_mmio(vcpu, phys_addr, data, len, is_write);
}
unsigned long kvm_cpu__get_vcpu_mpidr(struct kvm_cpu *vcpu);
-16
View File
@@ -139,22 +139,6 @@ bool kvm_cpu__handle_exit(struct kvm_cpu *vcpu)
return false;
}
bool kvm_cpu__emulate_mmio(struct kvm_cpu *vcpu, u64 phys_addr, u8 *data,
u32 len, u8 is_write)
{
if (arm_addr_in_virtio_mmio_region(phys_addr)) {
return kvm__emulate_mmio(vcpu, phys_addr, data, len, is_write);
} else if (arm_addr_in_ioport_region(phys_addr)) {
int direction = is_write ? KVM_EXIT_IO_OUT : KVM_EXIT_IO_IN;
u16 port = (phys_addr - KVM_IOPORT_AREA) & USHRT_MAX;
return kvm__emulate_io(vcpu, port, data, direction, len, 1);
} else if (arm_addr_in_pci_region(phys_addr)) {
return kvm__emulate_mmio(vcpu, phys_addr, data, len, is_write);
}
return false;
}
void kvm_cpu__show_page_tables(struct kvm_cpu *vcpu)
{
}