Return to Level1Techs.com

AMD: fix for host-passthrough on qemu : 5.0.0 | kernel: 5.6

I have seen that some people have had issues with getting cpu host-passthrough working for libvirt when using qemu 5 and a 5.6 kernel on AMD Ryzen CPUs.

Below I have a quick fix for this that allows you to use libvirt without using qemu:commandline.

Method :

  1. Apply the below patch to : /usr/share/libvirt/cpu_map/x86_features.xml
@@ -480,6 +480,9 @@
   <feature name='ibpb'>
     <cpuid eax_in='0x80000008' ebx='0x00001000'/>
   </feature>
+  <feature name='amd-stibp'>
+    <cpuid eax_in='0x80000008' ebx='0x00008000'/>
+  </feature>
   <feature name='amd-ssbd'>
     <cpuid eax_in='0x80000008' ebx='0x01000000'/>
   </feature>
  1. Add a line to disable amd-stibp on your guest (something like)
  <cpu mode='host-passthrough' check='none'>
    <topology sockets='1' dies='1' cores='4' threads='2'/>
    <feature policy='require' name='topoext'/>
    <feature policy='disable' name='amd-stibp'/>
  </cpu>
  1. May need to restart libvirt services

  2. Start your guest OS

I will probably submit a patch adding that cpu feature to libvirt later if one hasn’t been made already

5 Likes

This worked and let me boot, and my VM is correctly displaying my CPU model now, but I’m getting an awful lot of blue screens of death all of a sudden…

Nope, my issue turns out to have been the LVM snapshot I made of the Windows disk before I implemented your changes. Somehow the performance impact was enough to make Windows regularly crash with blue screens. I have deleted the snapshot and increased my io thread count, and my VM is now buttery smooth and responsive again (and stable), with host-passthrough :grin:

Thanks!

Thank you very much.
After updating my qemu version with buster-backports I was not able to run several vms anymore.
This tweak worked for me with debian buster, Kernel 5.7.0, QEMU emulator version 5.0.0 (Debian 1:5.0-14~bpo10+1)