public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/1] kvm: bios: make MMIO address page aligned in guest
@ 2009-02-19  9:23 Han, Weidong
  2009-02-24 10:43 ` Avi Kivity
  0 siblings, 1 reply; 3+ messages in thread
From: Han, Weidong @ 2009-02-19  9:23 UTC (permalink / raw)
  To: 'Avi Kivity'; +Cc: 'kvm@vger.kernel.org', Han, Weidong

[-- Attachment #1: Type: text/plain, Size: 1408 bytes --]

MMIO of some devices are not page aligned, such as some EHCI
controllers and virtual Realtek NIC in guest. Current guest
bios doesn't guarantee the start address of MMIO page aligned.
This may result in failure of device assignment, because KVM
only allow to register page aligned memory slots. For example,
it fails to assign EHCI controller (its MMIO size is 1KB) with
virtual Realtek NIC (its MMIO size is 256Bytes), because MMIO
of virtual Realtek NIC in guest starts from 0xf2001000, MMIO of
the EHCI controller will starts from 0xf2001400.

MMIO addresses in guest are allocated in guest bios. This patch
makes MMIO address page aligned in bios, then fixes the issue.

Signed-off-by: Weidong Han <weidong.han@intel.com>
---
 bios/rombios32.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/bios/rombios32.c b/bios/rombios32.c
index 9d2eaaa..4dea066 100755
--- a/bios/rombios32.c
+++ b/bios/rombios32.c
@@ -967,6 +967,9 @@ static void pci_bios_init_device(PCIDevice *d)
                 *paddr = (*paddr + size - 1) & ~(size - 1);
                 pci_set_io_region_addr(d, i, *paddr);
                 *paddr += size;
+                /* make memory address page aligned */
+                if (!(val & PCI_ADDRESS_SPACE_IO))
+                    *paddr = (*paddr + 0xfff) & 0xfffff000;
             }
         }
         break;
-- 
1.6.0.4

[-- Attachment #2: 0001-kvm-bios-make-MMIO-address-page-aligned-in-guest.patch --]
[-- Type: application/octet-stream, Size: 1599 bytes --]

From 7150a1c3450e68d1587ebbcc9d048fac3d07405e Mon Sep 17 00:00:00 2001
From: Weidong Han <weidong.han@intel.com>
Date: Thu, 19 Feb 2009 17:24:20 +0800
Subject: [PATCH 1/1] kvm: bios: make MMIO address page aligned in guest

MMIO of some devices are not page aligned, such as some EHCI
controllers and virtual Realtek NIC in guest. Current guest
bios doesn't guarantee the start address of MMIO page aligned.
This may result in failure of device assignment, because KVM
only allow to register page aligned memory slots. For example,
it fails to assign EHCI controller (its MMIO size is 1KB) with
virtual Realtek NIC (its MMIO size is 256Bytes), because MMIO
of virtual Realtek NIC in guest starts from 0xf2001000, MMIO of
the EHCI controller will starts from 0xf2001400.

MMIO addresses in guest are allocated in guest bios. This patch
makes MMIO address page aligned in bios, then fixes the issue.

Signed-off-by: Weidong Han <weidong.han@intel.com>
---
 bios/rombios32.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/bios/rombios32.c b/bios/rombios32.c
index 9d2eaaa..4dea066 100755
--- a/bios/rombios32.c
+++ b/bios/rombios32.c
@@ -967,6 +967,9 @@ static void pci_bios_init_device(PCIDevice *d)
                 *paddr = (*paddr + size - 1) & ~(size - 1);
                 pci_set_io_region_addr(d, i, *paddr);
                 *paddr += size;
+                /* make memory address page aligned */
+                if (!(val & PCI_ADDRESS_SPACE_IO))
+                    *paddr = (*paddr + 0xfff) & 0xfffff000;
             }
         }
         break;
-- 
1.6.0.4


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2009-02-24 20:12 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-02-19  9:23 [PATCH 1/1] kvm: bios: make MMIO address page aligned in guest Han, Weidong
2009-02-24 10:43 ` Avi Kivity
2009-02-24 20:11   ` Anthony Liguori

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox