Message ID | 715D42877B251141A38726ABF5CABF2C0195A1FE52@pdsmsx503.ccr.corp.intel.com (mailing list archive) |
---|---|
State | Not Applicable, archived |
Headers | show |
Han, Weidong wrote: > 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. > > Applied, thanks.
Avi Kivity wrote: > Han, Weidong wrote: >> 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. >> >> > > Applied, thanks. I think this patch could also be sent to upstream QEMU/bochs-devel. Even though neither supports device assignment right now, QEMU eventually will and it seems like a sane thing to do anyway. Regards, Anthony Liguori -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
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;
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(-)