All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] kvm tools: ARM: bring generated pci FDT node in-line with kernel binding
@ 2014-04-17 14:57 Will Deacon
  2014-04-17 14:57 ` [PATCH 2/2] kvm tools: ARM: allow potential relocation of IO port Will Deacon
  0 siblings, 1 reply; 2+ messages in thread
From: Will Deacon @ 2014-04-17 14:57 UTC (permalink / raw)
  To: kvm; +Cc: penberg, Will Deacon

Now that the dust has settled on the devicetree bindings for the generic
PCI host controller in the Linux kernel, update the node generated by
kvmtool to match what mainline kernels will expect.

Signed-off-by: Will Deacon <will.deacon@arm.com>
---
 tools/kvm/arm/fdt.c |  1 +
 tools/kvm/arm/kvm.c |  5 -----
 tools/kvm/arm/pci.c | 25 ++++++++++++-------------
 3 files changed, 13 insertions(+), 18 deletions(-)

diff --git a/tools/kvm/arm/fdt.c b/tools/kvm/arm/fdt.c
index d90fc9e1734f..30cd75ab89d4 100644
--- a/tools/kvm/arm/fdt.c
+++ b/tools/kvm/arm/fdt.c
@@ -114,6 +114,7 @@ static int setup_fdt(struct kvm *kvm)
 
 	/* /chosen */
 	_FDT(fdt_begin_node(fdt, "chosen"));
+	_FDT(fdt_property_cell(fdt, "linux,pci-probe-only", 1));
 	_FDT(fdt_property_string(fdt, "bootargs", kern_cmdline));
 
 	/* Initrd */
diff --git a/tools/kvm/arm/kvm.c b/tools/kvm/arm/kvm.c
index 6db646b4f4fd..008b7fe75d7d 100644
--- a/tools/kvm/arm/kvm.c
+++ b/tools/kvm/arm/kvm.c
@@ -56,11 +56,6 @@ 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)
diff --git a/tools/kvm/arm/pci.c b/tools/kvm/arm/pci.c
index ce1932ecc3ee..9f4dabcd4ed4 100644
--- a/tools/kvm/arm/pci.c
+++ b/tools/kvm/arm/pci.c
@@ -26,19 +26,15 @@ void pci__generate_fdt_nodes(void *fdt, u32 gic_phandle)
 	struct device_header *dev_hdr;
 	struct of_interrupt_map_entry irq_map[OF_PCI_IRQ_MAP_MAX];
 	unsigned nentries = 0;
-	/* Describe the memory ranges (config and memory) */
+	/* Bus range */
+	u32 bus_range[] = { cpu_to_fdt32(0), cpu_to_fdt32(1), };
+	/* Configuration Space */
+	u64 cfg_reg_prop[] = { cpu_to_fdt64(KVM_PCI_CFG_AREA),
+			       cpu_to_fdt64(ARM_PCI_CFG_SIZE), };
+	/* Describe the memory ranges */
 	struct of_pci_ranges_entry ranges[] = {
 		{
 			.pci_addr = {
-				.hi	= cpu_to_fdt32(of_pci_b_ss(OF_PCI_SS_CONFIG)),
-				.mid	= 0,
-				.lo	= 0,
-			},
-			.cpu_addr	= cpu_to_fdt64(KVM_PCI_CFG_AREA),
-			.length		= cpu_to_fdt64(ARM_PCI_CFG_SIZE),
-		},
-		{
-			.pci_addr = {
 				.hi	= cpu_to_fdt32(of_pci_b_ss(OF_PCI_SS_IO)),
 				.mid	= 0,
 				.lo	= 0,
@@ -49,8 +45,8 @@ void pci__generate_fdt_nodes(void *fdt, u32 gic_phandle)
 		{
 			.pci_addr = {
 				.hi	= cpu_to_fdt32(of_pci_b_ss(OF_PCI_SS_M32)),
-				.mid	= 0,
-				.lo	= 0,
+				.mid	= cpu_to_fdt32(KVM_PCI_MMIO_AREA >> 32),
+				.lo	= cpu_to_fdt32(KVM_PCI_MMIO_AREA),
 			},
 			.cpu_addr	= cpu_to_fdt64(KVM_PCI_MMIO_AREA),
 			.length		= cpu_to_fdt64(ARM_PCI_MMIO_SIZE),
@@ -59,11 +55,14 @@ void pci__generate_fdt_nodes(void *fdt, u32 gic_phandle)
 
 	/* Boilerplate PCI properties */
 	_FDT(fdt_begin_node(fdt, "pci"));
+	_FDT(fdt_property_string(fdt, "device_type", "pci"));
 	_FDT(fdt_property_cell(fdt, "#address-cells", 0x3));
 	_FDT(fdt_property_cell(fdt, "#size-cells", 0x2));
 	_FDT(fdt_property_cell(fdt, "#interrupt-cells", 0x1));
-	_FDT(fdt_property_string(fdt, "compatible", "linux,pci-virt"));
+	_FDT(fdt_property_string(fdt, "compatible", "pci-host-cam-generic"));
 
+	_FDT(fdt_property(fdt, "bus-range", bus_range, sizeof(bus_range)));
+	_FDT(fdt_property(fdt, "reg", &cfg_reg_prop, sizeof(cfg_reg_prop)));
 	_FDT(fdt_property(fdt, "ranges", ranges, sizeof(ranges)));
 
 	/* Generate the interrupt map ... */
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [PATCH 2/2] kvm tools: ARM: allow potential relocation of IO port
  2014-04-17 14:57 [PATCH 1/2] kvm tools: ARM: bring generated pci FDT node in-line with kernel binding Will Deacon
@ 2014-04-17 14:57 ` Will Deacon
  0 siblings, 0 replies; 2+ messages in thread
From: Will Deacon @ 2014-04-17 14:57 UTC (permalink / raw)
  To: kvm; +Cc: penberg, Will Deacon

Whilst our IO port is fixed at CPU physical address 0x0, changing
ARM_IOPORT_AREA should be all that's necessary to move it around in CPU
physical space (it will still be at 0x0 in the bus address space).

This patch ensures we subtract KVM_IOPORT_AREA from the faulting CPU
physical address when calculating the port for kvm__emulate_io.

Reported-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Will Deacon <will.deacon@arm.com>
---
 tools/kvm/arm/kvm-cpu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/kvm/arm/kvm-cpu.c b/tools/kvm/arm/kvm-cpu.c
index b017994f4014..9c9616f307a4 100644
--- a/tools/kvm/arm/kvm-cpu.c
+++ b/tools/kvm/arm/kvm-cpu.c
@@ -105,7 +105,7 @@ bool kvm_cpu__emulate_mmio(struct kvm *kvm, u64 phys_addr, u8 *data, u32 len,
 		return kvm__emulate_mmio(kvm, 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 & USHRT_MAX;
+		u16 port = (phys_addr - KVM_IOPORT_AREA) & USHRT_MAX;
 		return kvm__emulate_io(kvm, port, data, direction, len, 1);
 	} else if (arm_addr_in_pci_region(phys_addr)) {
 		return kvm__emulate_mmio(kvm, phys_addr, data, len, is_write);
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-04-17 14:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-04-17 14:57 [PATCH 1/2] kvm tools: ARM: bring generated pci FDT node in-line with kernel binding Will Deacon
2014-04-17 14:57 ` [PATCH 2/2] kvm tools: ARM: allow potential relocation of IO port Will Deacon

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.