[PATCH 14/17] kvm tools: ARM: route guest PCI accesses to the emulation layer

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This patch routes guest PCI accesses to kvm__emulate_mmio, rather than
exiting lkvm via a die invocation. The guest command-line is also
updated to prevent the guest from attempting to program the BARs with
new addresses (i.e. probe-only).

Signed-off-by: Will Deacon <will.deacon@xxxxxxx>
---
 tools/kvm/arm/include/arm-common/kvm-arch.h | 6 +++---
 tools/kvm/arm/kvm-cpu.c                     | 4 ++--
 tools/kvm/arm/kvm.c                         | 5 +++++
 3 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/tools/kvm/arm/include/arm-common/kvm-arch.h b/tools/kvm/arm/include/arm-common/kvm-arch.h
index 348e88d00b1c..8adfcd495c03 100644
--- a/tools/kvm/arm/include/arm-common/kvm-arch.h
+++ b/tools/kvm/arm/include/arm-common/kvm-arch.h
@@ -46,10 +46,10 @@ static inline bool arm_addr_in_virtio_mmio_region(u64 phys_addr)
 	return phys_addr >= KVM_VIRTIO_MMIO_AREA && phys_addr < limit;
 }
 
-static inline bool arm_addr_in_pci_mmio_region(u64 phys_addr)
+static inline bool arm_addr_in_pci_region(u64 phys_addr)
 {
-	u64 limit = KVM_PCI_MMIO_AREA + ARM_PCI_MMIO_SIZE;
-	return phys_addr >= KVM_PCI_MMIO_AREA && phys_addr < limit;
+	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 {
diff --git a/tools/kvm/arm/kvm-cpu.c b/tools/kvm/arm/kvm-cpu.c
index d31e7b154ae8..b017994f4014 100644
--- a/tools/kvm/arm/kvm-cpu.c
+++ b/tools/kvm/arm/kvm-cpu.c
@@ -107,8 +107,8 @@ bool kvm_cpu__emulate_mmio(struct kvm *kvm, u64 phys_addr, u8 *data, u32 len,
 		int direction = is_write ? KVM_EXIT_IO_OUT : KVM_EXIT_IO_IN;
 		u16 port = phys_addr & USHRT_MAX;
 		return kvm__emulate_io(kvm, port, data, direction, len, 1);
-	} else if (arm_addr_in_pci_mmio_region(phys_addr)) {
-		die("PCI emulation not supported on ARM!");
+	} else if (arm_addr_in_pci_region(phys_addr)) {
+		return kvm__emulate_mmio(kvm, phys_addr, data, len, is_write);
 	}
 
 	return false;
diff --git a/tools/kvm/arm/kvm.c b/tools/kvm/arm/kvm.c
index 008b7fe75d7d..6db646b4f4fd 100644
--- a/tools/kvm/arm/kvm.c
+++ b/tools/kvm/arm/kvm.c
@@ -56,6 +56,11 @@ void kvm__arch_read_term(struct kvm *kvm)
 
 void kvm__arch_set_cmdline(char *cmdline, bool video)
 {
+	/*
+	 * We don't support movable BARs, so force the guest to use what
+	 * we tell it.
+	 */
+	strcpy(cmdline, "pci=firmware");
 }
 
 void kvm__arch_init(struct kvm *kvm, const char *hugetlbfs_path, u64 ram_size)
-- 
1.8.2.2

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux