* [PATCH 2/3] KVM: pci passthrough un-page-aligned mmio device on machines w/o VT-d
@ 2008-12-15 14:59 刘晓建
0 siblings, 0 replies; only message in thread
From: 刘晓建 @ 2008-12-15 14:59 UTC (permalink / raw)
To: kvm@vger.kernel.org
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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2008-12-15 15:05 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-12-15 14:59 [PATCH 2/3] KVM: pci passthrough un-page-aligned mmio device on machines w/o VT-d 刘晓建
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox