* [PATCH] register page alignment memory for MMIO of assigned device
@ 2008-12-03 7:25 Han, Weidong
2008-12-03 13:00 ` Avi Kivity
0 siblings, 1 reply; 2+ messages in thread
From: Han, Weidong @ 2008-12-03 7:25 UTC (permalink / raw)
To: 'Avi Kivity'; +Cc: kvm@vger.kernel.org
[-- Attachment #1: Type: text/plain, Size: 1537 bytes --]
MMIO of assigned device is registered as memory slot. Size of memory slot in KVM must be page size multiple. But MMIO of some devices (e.g. EHCI controller) is not page size mutiple, so it fails to register these MMIOs, thus device assignment fails. In order to solve it, need to register target page alignment memory for these MMIOs.
Signed-off-by: Weidong Han <weidong.han@intel.com>
---
qemu/hw/device-assignment.c | 12 +++++++++---
1 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/qemu/hw/device-assignment.c b/qemu/hw/device-assignment.c
index eaff09e..4a38a22 100644
--- a/qemu/hw/device-assignment.c
+++ b/qemu/hw/device-assignment.c
@@ -157,12 +157,18 @@ static void assigned_dev_iomem_map(PCIDevice *pci_dev, int region_num,
region->e_physbase = e_phys;
region->e_size = e_size;
- if (!first_map)
- kvm_destroy_phys_mem(kvm_context, old_ephys, old_esize);
+ if (!first_map) {
+ int slot = get_slot(old_ephys);
+ if (slot != -1)
+ kvm_destroy_phys_mem(kvm_context, old_ephys,
+ TARGET_PAGE_ALIGN(old_esize));
+ }
if (e_size > 0)
ret = kvm_register_phys_mem(kvm_context, e_phys,
- region->u.r_virtbase, e_size, 0);
+ region->u.r_virtbase,
+ TARGET_PAGE_ALIGN(e_size), 0);
+
if (ret != 0) {
fprintf(stderr, "%s: Error: create new mapping failed\n", __func__);
exit(1);
--
1.5.1
[-- Attachment #2: 0001-register-page-alignment-memory-for-MMIO-of-assigned.patch --]
[-- Type: application/octet-stream, Size: 1730 bytes --]
From 8b124d22f65027a5ad3a0bffcdb6a5439e6410d1 Mon Sep 17 00:00:00 2001
From: Weidong Han <weidong.han@intel.com>
Date: Wed, 3 Dec 2008 14:55:17 +0800
Subject: [PATCH] register page alignment memory for MMIO of assigned device
MMIO of assigned device is registered as memory slot. Size of memory slot in KVM must be page size multiple. But MMIO of some devices (e.g. EHCI controller) is not page size mutiple, so it fails to register these MMIOs, thus device assignment fails. In order to solve it, need to register target page alignment memory for these MMIOs.
Signed-off-by: Weidong Han <weidong.han@intel.com>
---
qemu/hw/device-assignment.c | 12 +++++++++---
1 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/qemu/hw/device-assignment.c b/qemu/hw/device-assignment.c
index eaff09e..4a38a22 100644
--- a/qemu/hw/device-assignment.c
+++ b/qemu/hw/device-assignment.c
@@ -157,12 +157,18 @@ static void assigned_dev_iomem_map(PCIDevice *pci_dev, int region_num,
region->e_physbase = e_phys;
region->e_size = e_size;
- if (!first_map)
- kvm_destroy_phys_mem(kvm_context, old_ephys, old_esize);
+ if (!first_map) {
+ int slot = get_slot(old_ephys);
+ if (slot != -1)
+ kvm_destroy_phys_mem(kvm_context, old_ephys,
+ TARGET_PAGE_ALIGN(old_esize));
+ }
if (e_size > 0)
ret = kvm_register_phys_mem(kvm_context, e_phys,
- region->u.r_virtbase, e_size, 0);
+ region->u.r_virtbase,
+ TARGET_PAGE_ALIGN(e_size), 0);
+
if (ret != 0) {
fprintf(stderr, "%s: Error: create new mapping failed\n", __func__);
exit(1);
--
1.5.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] register page alignment memory for MMIO of assigned device
2008-12-03 7:25 [PATCH] register page alignment memory for MMIO of assigned device Han, Weidong
@ 2008-12-03 13:00 ` Avi Kivity
0 siblings, 0 replies; 2+ messages in thread
From: Avi Kivity @ 2008-12-03 13:00 UTC (permalink / raw)
To: Han, Weidong; +Cc: kvm@vger.kernel.org
Han, Weidong wrote:
> MMIO of assigned device is registered as memory slot. Size of memory slot in KVM must be page size multiple. But MMIO of some devices (e.g. EHCI controller) is not page size mutiple, so it fails to register these MMIOs, thus device assignment fails. In order to solve it, need to register target page alignment memory for these MMIOs.
>
>
Applied, thanks.
--
error compiling committee.c: too many arguments to function
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2008-12-03 13:00 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-12-03 7:25 [PATCH] register page alignment memory for MMIO of assigned device Han, Weidong
2008-12-03 13:00 ` Avi Kivity
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.