From: "Michael S. Tsirkin" <mst@redhat.com>
To: kvm@vger.kernel.org
Cc: pbonzini@redhat.com, qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH 2/2] pci-test: allow bar > 4k
Date: Thu, 27 Aug 2015 11:52:53 +0300 [thread overview]
Message-ID: <1440665434-2893-2-git-send-email-mst@redhat.com> (raw)
In-Reply-To: <1440665434-2893-1-git-send-email-mst@redhat.com>
vmexit using test assumes BAR size is exactly 4K.
Remove this restriction, allow any BAR size.
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
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
prev parent reply other threads:[~2015-08-27 8:52 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-27 8:52 [Qemu-devel] [PATCH 1/2] pci: add bar sizing Michael S. Tsirkin
2015-08-27 8:52 ` Michael S. Tsirkin [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1440665434-2893-2-git-send-email-mst@redhat.com \
--to=mst@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).