Once your host OS has been installed and updated, it’s time to make a kernel compatible with KVM’s more advanced features. Most of these features are already available as modules in the Debian Jessie kernel, however as many others have, I found it was necessary to compile KVM support directly into the kernel for things to work smoothly with PCI passthrough. Kernel recompile, “the Debian way”You can use any compilation and installation method you wish, but this method will give you a set of KVM-ready .deb files which you can install on other (similar) systems. I do not intend this to be a definitive reference for compiling kernels; refer to Debian’s official Compiling a New Kernel guide. Again this guide assumes that you have root access. This is really not the best way to compile the kernel if you’re concerned about security or not hosing the system you’re compiling on. Refer to the guide to see how to use fakeroot to compile instead. Getting and Uncompressing the SourceAny recent kernel should do, but if you wish to duplicate my experience, and especially if you’re using the same hardware, it may be best to fetch the same kernel version I have. Grab and unpack the vanilla kernel from : Configuring the KernelTo configure the vanilla kernel with the same options as the Debian default kernel, simply do: Accept the default configuration options if any are presented. Now to configure the kernel, do: Change the following kernel options and modules to be compiled into the kernel (set them to [*] instead of [M]):
The rest of these are optional (but recommended) performance enhancements you may compile as modules [M]:
And finally these options will enhance performance and responsiveness of your virtual machines:
Make any other changes you need for your hardware, if any. If the default Debian configuration works you probably don’t need to change anything else. Exit, and accept the prompt to save the kernel configuration. Compiling and creating the Debian packageIn Debian, this is one simple step: Note the option –append-to-version – this string will be added to the end of your version to differentiate this kernel from others you install or compile. Set this to something unique. InstallHop up a directory with Further Kernel Configuration for PassthroughIt’s likely you compiled the radeon/noveau driver module during the last steps; if you have an AMD/ATI card that you are planning to use for PCI passthrough, you should blacklist the radeon driver to prevent it being loaded at boot and taking over the card:
IOMMU support must be enabled in the kernel at boot time to be utilized, but we haven’t configured it to do so yet. Assuming you’ve compiled KVM support into the kernel, this should be as simple as adding “iommu=1″ to your kernel arguments. Edit /etc/default/grub and find the line starting
Depending on your hardware, there are likely other boot parameters you will want to use. Unfortunately this seems to be a case-by-case, trial and error endeavor to find your perfect set. Here’s mine; these options may or may not all be necessary but they work for me:
iommu=pt enables “passthrough” for AMD chips. The equivalent option for Intel chipsets is intel_iommu=on. kvm.ignore_msrs=1 prevents a bug with message handling that, reading more into it just now, I don’t think I actually need. I believe I simply picked this up from the ArchLinux KVM/Passthrough guide. I’d leave this off unless you have problems that lead you to specifically enable it, and disabling it seems to make no difference for me. nomodeset I added to prevent Debian’s init scripts from trying a higher resolution console on the host, wherein it might bind the radeon driver to the primary GPU. Since I will almost never see the pretty virtual consoles anyway, it’s an easy call. This also shaves a second or two off boot time as it prevents scanning for all the supported monitor modes. The pci-stub entry I will explain in the next post in this series. Now, update grub to add these parameters: When the machine comes back up, login and check if IOMMU support is enabled and working: If things are working, you should see something like: Congrats! Now you have a PCI-Passthrough compatible kernel. Next I’ll show how to reserve devices at boot time with the pci-stub driver and bind them to the VFIO driver to be used by virtual machines. |
|
来自: 浸心阁 > 《GPU Passthrough Debian》