From: 刘晓建 <zjliu@nudt.edu.cn>
To: "kvm@vger.kernel.org" <kvm@vger.kernel.org>
Subject: [PATCH 2/3] KVM: pci passthrough un-page-aligned mmio device on machines w/o VT-d
Date: Mon, 15 Dec 2008 22:59:42 +0800 [thread overview]
Message-ID: <429353182.11602@nudt.edu.cn> (raw)
KVM doesn't permit the device's iomem size smaller than 1 page. In fact, this is
not necessary. For my via-rhine nic, the size of iomem is only 0x200, but we can
still use pci passthrough.
And, because un-page-aligned iomem is permitted, sanity check should be adjusted
too.
---
diff -uNr kvm-79/kernel/x86/kvm_main.c kvm-79-fixed/kernel/x86/kvm_main.c
--- kvm-79/kernel/x86/kvm_main.c 2008-11-12 20:24:04.000000000 +0800
+++ kvm-79-fixed/kernel/x86/kvm_main.c 2008-12-12 15:56:19.000000000 +0800
@@ -751,13 +750,16 @@
struct kvm_memory_slot old, new;
r = -EINVAL;
- /* General sanity checks */
+#if 0
+ /* For some device, their iomem is not page aligned */
if (mem->memory_size & (PAGE_SIZE - 1))
goto out;
if (mem->guest_phys_addr & (PAGE_SIZE - 1))
goto out;
if (user_alloc && (mem->userspace_addr & (PAGE_SIZE - 1)))
goto out;
+#endif
+ /* General sanity checks */
if (mem->slot >= KVM_MEMORY_SLOTS + KVM_PRIVATE_MEM_SLOTS)
goto out;
if (mem->guest_phys_addr + mem->memory_size < mem->guest_phys_addr)
@@ -765,7 +767,8 @@
memslot = &kvm->memslots[mem->slot];
base_gfn = mem->guest_phys_addr >> PAGE_SHIFT;
- npages = mem->memory_size >> PAGE_SHIFT;
+ npages = ((mem->guest_phys_addr + mem->memory_size + PAGE_SIZE - 1) >>
PAGE_SHIFT)
+ - (mem->guest_phys_addr >> PAGE_SHIFT);
if (!npages)
mem->flags &= ~KVM_MEM_LOG_DIRTY_PAGES;
Xiaojian Liu
reply other threads:[~2008-12-15 15:05 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=429353182.11602@nudt.edu.cn \
--to=zjliu@nudt.edu.cn \
--cc=kvm@vger.kernel.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