From: "Michael S. Tsirkin" Subject: [PATCH 2/2] pci-test: allow bar > 4k Date: Thu, 27 Aug 2015 11:52:53 +0300 Message-ID: <1440665434-2893-2-git-send-email-mst@redhat.com> References: <1440665434-2893-1-git-send-email-mst@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: pbonzini@redhat.com, qemu-devel@nongnu.org To: kvm@vger.kernel.org Return-path: Received: from mx1.redhat.com ([209.132.183.28]:39379 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750802AbbH0Iw4 (ORCPT ); Thu, 27 Aug 2015 04:52:56 -0400 Content-Disposition: inline In-Reply-To: <1440665434-2893-1-git-send-email-mst@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: vmexit using test assumes BAR size is exactly 4K. Remove this restriction, allow any BAR size. Signed-off-by: Michael S. Tsirkin --- 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