[PATCH 2/2] pci-test: allow bar > 4k

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

 



vmexit using test assumes BAR size is exactly 4K.
Remove this restriction, allow any BAR size.

Signed-off-by: Michael S. Tsirkin <mst@xxxxxxxxxx>
---
 x86/vmexit.c | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/x86/vmexit.c b/x86/vmexit.c
index 7e9af15..3ff7fbf 100644
--- a/x86/vmexit.c
+++ b/x86/vmexit.c
@@ -407,7 +407,7 @@ bool test_wanted(struct test *test, char *wanted[], int nwanted)
 int main(int ac, char **av)
 {
 	int i;
-	unsigned long membar = 0, base, offset;
+	unsigned long membar = 0, base, offset, size;
 	void *m;
 	pcidevaddr_t pcidev;
 
@@ -425,12 +425,18 @@ int main(int ac, char **av)
 				continue;
 			}
 			if (pci_bar_is_memory(pcidev, i)) {
+				int p;
+
+				size = pci_bar_size(pcidev, i);
 				membar = pci_bar_addr(pcidev, i);
-				base = membar & ~4095;
+				base = membar & ~(size - 1);
 				offset = membar - base;
-				m = alloc_vpages(1);
-				
-				install_page((void *)read_cr3(), base, m);
+				m = alloc_vpages(size / 4096);
+
+				for (p = 0; p < size; p += 4096) {
+				    install_page((void *)read_cr3(), base + p,
+                                                 m + p);
+				}
 				pci_test.memaddr = m + offset;
 			} else {
 				pci_test.iobar = pci_bar_addr(pcidev, i);
-- 
MST

--
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