Hello,

These three patches (one against host kernel, one against kvm.git, one
against kvm-userland.git) forces KVM to map all RAM mapped in the
virtualized e820 map provided to the guest with gfn = hfn. In turn
it's now possible to give direct hardware access to the guest, all DMA
will work fine on the virtualized guest ram.

The bios has to be updated to alter the end of the first ram slot in
the virtualized e820 map. This is unfixable as the address hardcoded
in the current bios is higher than what's marked as ram in my hardware
e820 map.

The only exception where gfn != hfn for ranges included in the
virtualized e820 map is for the magic bios page at host physical
address zero (bytes from 0 to 4096). All linux versions will
definitely never attempt to dma on such a page. If all OS are like
linux there will be no problem and pci passthrough will work
regardless of the guest OS without requiring any paravirtualization,
nor VT-d.

This only implements the memory management side, the logic to map mmio
regions into kvm address space will require further changes. The limit
of the reserved ram is around 1G and it has to be set at compile time,
so the guest will run with no more than 1G of ram (it's fairly easy to
extend it to 2G though). You can't run more than one guest with
-reserved-ram at once or they'll be overwriting themself. You need
access to /dev/mem on the userland side, and CAP_ADMIN on the kernel
side to run this.

I choosed an approach to require the minimal number of changes given
this is a short term approach due the lack of hardware features in
lots of cpus out there.

This is how the memory layout looks like when live guest runs
(physical start set to 512M and kvm -m 300).

7f108d429000-7f108d42b000 rw-p 7f108d429000 00:00 0
7f108d42b000-7f108d4ba000 rw-s 00000000 00:0e 275                        
/dev/mem
7f108d4ba000-7f108d52a000 rw-p 7f108d4ba000 00:00 0
7f108d52a000-7f10a002a000 rw-s 00100000 00:0e 275                        
/dev/mem
7f10a002a000-7f10a142e000 rw-p 7f10a002a000 00:00 0

  PID TTY      STAT   TIME  MAJFL   TRS   DRS   RSS %MEM COMMAND
 5522 ?        SLl    4:06      1  1568 427067 33144  7.0 
bin/x86_64/kvm/bin/qemu-system-x86_64 -hda tmp/vir

RSS isn't including the reserved ram of course.

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel

Reply via email to