https://linux-kvm.org/api.php?action=feedcontributions&user=WeidongHan&feedformat=atomKVM - User contributions [en]2024-03-28T20:03:06ZUser contributionsMediaWiki 1.39.5https://linux-kvm.org/index.php?title=How_to_assign_devices_with_VT-d_in_KVM&diff=2375How to assign devices with VT-d in KVM2009-07-10T03:03:22Z<p>WeidongHan: </p>
<hr />
<div>= How to assign devices with VT-d in KVM =<br />
<br />
== Assigning device to guest ==<br />
'''1. Modifying kernel config:'''<br />
* make menuconfig<br />
* set "Bus options (PCI etc.)" -> "Support for DMA Remapping Devices" to "*"<br />
* set "Bus options (PCI etc.)" -> "Enable DMA Remapping Devices" to "*"<br />
* set "Bus options (PCI etc.)" -> "PCI Stub driver" to "*"<br />
* optional setting:<br />
set "Bus options (PCI etc.)" -> "Support for Interrupt Remapping" to "*"<br />
* exit/save<br />
<br />
'''2. build kernel:'''<br />
* make<br />
* make modules_install<br />
* make install<br />
<br />
'''3. reboot'''<br />
<br />
'''4. unbind device from host kernel driver (example PCI device 01:00.0)<br />
'''<br />
* lspci -n<br />
* locate the entry for device 01:00.0 and note down the vendor & device ID 8086:10b9<br />
...<br />
01:00.0 0200: 8086:10b9 (rev 06)<br />
...<br />
<br />
* echo "8086 10b9" > /sys/bus/pci/drivers/pci-stub/new_id<br />
* echo 0000:01:00.0 > /sys/bus/pci/devices/0000:01:00.0/driver/unbind<br />
* echo 0000:01:00.0 > /sys/bus/pci/drivers/pci-stub/bind<br />
<br />
'''5. load KVM modules:'''<br />
* modprobe kvm<br />
* modprobe kvm-intel<br />
<br />
'''6. assign device:'''<br />
* /usr/local/bin/qemu-system-x86_64 -m 512 -boot c -net none -hda /root/ia32e_rhel5u1.img -pcidevice host=01:00.0<br />
<br />
<br />
== VT-d device hotplug ==<br />
KVM also supports hotplug devices with VT-d to guest. In guest command interface (you can press Ctrl+Alt+2 to enter it), you can use following command to hot add/remove devices to/from guest:<br />
* hot add:<br />
pci_add pci_addr=auto host host=01:00.0<br />
* hot remove (e.g bdf is 00:06.0 in guest):<br />
pci_del pci_addr=6<br />
<br />
<br />
== Notes ==<br />
* VT-d spec specifies that all conventional PCI devices behind a PCIe-to-PCI/PCI-X bridge or conventional PCI bridge can only be collectively assigned to the same guest. PCIe devices do not have this restriction.<br />
* If the device doesn't support MSI, and it shares IRQ with other devices, then it cannot be assigned due to host irq sharing for assigned devices is not supported. You will get warning message when you assign it. Notice this also apply to the devices which only support MSI-X.</div>WeidongHanhttps://linux-kvm.org/index.php?title=How_to_assign_devices_with_VT-d_in_KVM&diff=2190How to assign devices with VT-d in KVM2009-03-26T02:43:10Z<p>WeidongHan: </p>
<hr />
<div>= How to assign devices with VT-d in KVM =<br />
<br />
== Assigning device to guest ==<br />
'''1. Modifying kernel config:'''<br />
* make menuconfig<br />
* set "Bus options (PCI etc.)" -> "Support for DMA Remapping Devices" to "*"<br />
* set "Bus options (PCI etc.)" -> "Enable DMA Remapping Devices" to "*"<br />
* set "Bus options (PCI etc.)" -> "Support for Interrupt Remapping" to "*"<br />
* set "Bus options (PCI etc.)" -> "PCI Stub driver" to "*"<br />
* exit/save<br />
<br />
'''2. build kernel:'''<br />
* make<br />
* make modules_install<br />
* make install<br />
<br />
'''3. reboot'''<br />
<br />
'''4. unbind device from host kernel driver (example PCI device 01:00.0)<br />
'''<br />
* lspci -n<br />
* locate the entry for device 01:00.0 and note down the vendor & device ID 8086:10b9<br />
...<br />
01:00.0 0200: 8086:10b9 (rev 06)<br />
...<br />
<br />
* echo "8086 10b9" > /sys/bus/pci/drivers/pci-stub/new_id<br />
* echo 0000:01:00.0 > /sys/bus/pci/devices/0000:01:00.0/driver/unbind<br />
* echo 0000:01:00.0 > /sys/bus/pci/drivers/pci-stub/bind<br />
<br />
'''5. load KVM modules:'''<br />
* modprobe kvm<br />
* modprobe kvm-intel<br />
<br />
'''6. assign device:'''<br />
* /usr/local/bin/qemu-system-x86_64 -m 512 -boot c -net none -hda /root/ia32e_rhel5u1.img -pcidevice host=01:00.0<br />
<br />
<br />
== VT-d device hotplug ==<br />
KVM also supports hotplug devices with VT-d to guest. In guest command interface (you can press Ctrl+Alt+2 to enter it), you can use following command to hot add/remove devices to/from guest:<br />
* hot add:<br />
pci_add pci_addr=auto host host=01:00.0<br />
* hot remove (e.g bdf is 00:06.0 in guest):<br />
pci_del pci_addr=6<br />
<br />
<br />
== Notes: ==<br />
* VT-d spec specifies that all conventional PCI devices behind a PCIe-to-PCI/PCI-X bridge or conventional PCI bridge can only be collectively assigned to the same guest. PCIe devices do not have this restriction.<br />
* If the device doesn't support MSI/MSI-x, and it shares IRQ with other devices, then it cannot be assigned due to host irq sharing for assigned devices is not supported. You will get warning message when you assign it.</div>WeidongHanhttps://linux-kvm.org/index.php?title=HOWTO&diff=2189HOWTO2009-03-26T02:21:15Z<p>WeidongHan: </p>
<hr />
<div>= Howto's =<br />
* [[HOWTO VMGL]] - OpenGL support for Linux guests<br />
* [[HOWTO1 | Getting KVM to run on your machine]]<br />
* [[Networking| Setting guest network]]<br />
* [[NetConsole| set up a network console]]<br />
* [[simple shell script to manage your virtual machine with bridged networking]]<br />
* [[choose the right kvm & kernel version]]<br />
* [[boot from virtio block device]]<br />
* [[Using VirtIO NIC|use virtio_net interface]] in the guest (Debian)<br />
* [[hotadd pci devices]]<br />
* [http://pve.proxmox.com/wiki/Bare-metal_ISO_Installer Bare-metal] installer with KVM<br />
* [[HowToConfigScript|Configuration Script for KVM]] - a complete management utility, configuration file format, and init script.<br />
* [http://www.papercut.com/blog/chris/2008/11/14/using-kvm-to-securely-host-servers-in-a-dmz/ Hosting your VMs in a DMZ] - a management and configuration script to assist with setting up a VM in a semi-secured demilitarized zone.<br />
* [[Enable VT-X on Mac Pro (Early 2008)]] <br />
* [[Running libvirt with KVM]]<br />
* [[How To Migrate From Vmware To KVM]]<br />
* [[How to assign devices with VT-d in KVM]]<br />
<br />
== Ubuntu related ==<br />
* [http://www.howtoforge.com/using-kvm-on-ubuntu-gutsy-gibbon using-kvm-on-ubuntu-gutsy-gibbon]<br />
* [[AnthonyLiguori/Networking| Setting up NAT with KVM in Ubuntu]]<br />
* [https://help.ubuntu.com/community/KVM Running Guest Systems on Ubuntu 7.04 Feisty Fawn]<br />
<br />
== Windows Vista related ==<br />
* [[Vista Networking Workaround]]<br />
<br />
== USB related ==<br />
* [[usb related]]<br />
<br />
== Ethernet related ==<br />
* [[ethernet_related]]</div>WeidongHanhttps://linux-kvm.org/index.php?title=TODO&diff=1619TODO2008-10-09T01:52:55Z<p>WeidongHan: </p>
<hr />
<div>= TODO =<br />
------------------------------------<br />
The following items need some love. Please post to the list if you are interested in helping out: <br />
<br />
* Real mode support: VT support for real mode is terrible, so we need to do it in software. This means extending the x86 emulator (x86_emulate.c) to handle more instructions, and changing the execution loop to call the emulator for real mode (in progress).<br />
* Emulate the architectural performance monitor counters/msrs, for Linux nmi watchdog support.<br />
* Emulate MSR_IA32_DEBUGCTL for guests which use it<br />
* Bring up Windows 95 and Windows 98 guests<br />
* Implement MSR_EFER on i386, on processors which support it<br />
* Add HPET support to qemu and kvm<br />
<br />
The following smaller scale tasks can be a nice entry point to someone wishing to get involved: <br />
<br />
* Store command line options in an empty snapshot in a qcow2 format image file. This allows an image file to be self contained: <code><nowiki>qemu file.img</nowiki></code> should be enough to launch a fully configured virtual machine. (this is probably a bad idea--see qemu-devel/kvm-devel discussion)<br />
* Allow all cpuid features supported by kvm to be passed to the guest; add a command line option to specifiy the cpuid explicitly to allow migration in a heterogeneous server farm. (in progress)<br />
* Add a Unix domain socket device. With this, the guest can talk to a pci device which is connected to a Unix domain socket on the host.<br />
* Add a qemu interface for sharing memory between guests. Using a pci device to expose the shared memory is probably a good starting point. (this should use virtio and probably depends on mmu-notifiers)<br />
* Allow userspace to manage which msrs are emulated as no-ops (read zero, write ignored) to hack support for some guests<br />
* Reduce qemu memory footprint when using kvm<br />
* Avoid taking kvm->lock when issuing mmio. Need to check lapic and ioapic accesses for correctness.<br />
<br />
MMU related:<br />
* Improve mmu page eviction algorithm (currently FIFO, change to approximate LRU).<br />
* Add a read-only memory type.<br />
** possible using mprotect()?<br />
* Implement AM20 for dos and the like.<br />
* Implement direct page tables on paravirt_ops enabled Linux guests<br />
<br />
x86 emulator updates:<br />
* Trap #UD and emulate sysenter/syscall/sysret/sysexit. These instructions don't exist on all cpus in all modes, so they hinder cross-vendor migration (in progress)<br />
* Add a NonPT flag (or maybe its inverse, Paging) to instructions that are never used for page table updates (like add, sub, call). Teach the mmu to unshadow page tables if a NonPT instruction is executed on them.<br />
* Change the emulator initialization sequence not to read all segment registers (this is slow), instead read them on demand. On 64-bit, no segments are usually needed while on 32-bit only cs and ds are commenly required.<br />
<br />
Interactivity improvements:<br />
* If for several frames in a row a large proportion of the framebuffer pages are <br />
changing, then for the next few frames don't bother to get the dirty page log<br />
from kvm, but instead assume that all pages are dirty. This will reduce page<br />
fault overhead on highly interactive workloads.<br />
* When detecting keyboard/video/mouse activity, scale up the frame rate; when<br />
activity dies down, scale it back down (applicable to qemu as well).<br />
<br />
Pass-through/VT-d related:<br />
* Implement an external module for the iommus, so that KVM VT-d works on old kernels.<br />
* Implement Linux pci-stub module to “hide” pass-through device from host kernel’s device driver.<br />
* Enhance KVM QEMU to return error messages if user attempts to pass-through unsupported devices:<br />
** Devices with shared host IOAPIC interrupt<br />
** Conventional PCI devices<br />
** Devices without FLR capability<br />
* QEMU PCI pass-through patch needs to be enhanced to same functionality as corresponding file in Xen<br />
** Remove direct HW access by QEMU for probing PCI BAR size<br />
** PCI handling of various PCI configuration registers<br />
** Other enhancements that was done in Xen<br />
* Host shared interrupt support<br />
* VT-d2 support (WIP in Linux Kernel)<br />
** Queued invalidation<br />
** Interrupt remapping<br />
** ATS<br />
<br />
Bug fixes:<br />
* Less sexy but ever important, fixing bugs is one of the most important contributions<br />
<br />
For the adventurous:<br />
<br />
* Emulate the VT and SVM instructions, so that kvm can run in a virtual machine. Test by running a VM in a VT guest in an SVM guest on VT hardware, as well as running a VM in an SVM guest in a VT guest on SVM hardware.<br />
* Emulate the VT and SVM instruction sets on qemu. This would be very beneficial to debugging kvm.<br />
* Keep this TODO up to date<br />
* Add [http://www.cs.toronto.edu/~andreslc/xen-gl/ vmgl] support to qemu. Port to virtio. Write a Windows driver.<br />
<br />
__NOTOC__</div>WeidongHan