[vfio-users] How to get Windows 7 to work with hyperv

Laszlo Ersek lersek at redhat.com
Thu Feb 9 20:39:11 UTC 2017


On 02/09/17 20:48, Thomas Lindroth wrote:
> Good news everyone. Everyone who is still using Windows 7 that is. I've got
> win7 to run with hyperv enlightenments enabled.
> 
> The problem with win7 is that it won't boot if you use OVMF, multicore and
> hyperv at the same time. This bug (comment 7) got the details as well as the
> solution. https://bugs.launchpad.net/qemu/+bug/1593605
>

While at it, feel free to read comment 12 as well.

Short summary: this is a Windows 7 bug, which OVMF *could* work around,
but only at the price of punishing other, not buggy (or not that way
buggy) UEFI OSes. That's why upstream OVMF doesn't do it.

(I certainly don't dispute your right to patch OVMF as you see fit, of
course :))

Laszlo

> I did as the comment suggested and built my own patched OVMF binary. You can
> get it here https://github.com/tholin/OVMF-win7-hyperv or you can build it
> yourself with the patch from the description.
> 
> To use the prebuilt version download the binaries and add them to where
> libvirt can read them (/usr/share/OVMF). Then change your libvirt xml to point
> to the new binary.
> <loader readonly='yes' type='pflash'>/usr/share/OVMF/OVMF_win7_code.fd</loader>
> If you disabled the hypervisor cpuflag you have to stop doing that by removing
> this line if you have it.
> <feature policy='disable' name='hypervisor'/>
> 
> Then add the usual hyperv settings.
> <hyperv>
>   <relaxed state='on'/>
>   <vapic state='on'/>
>   <spinlocks state='on' retries='8191'/>
>   <vendor_id state='on' value='SomeString'/>
> </hyperv>
> ...
> <clock offset='localtime'>
>   ...
>   <timer name='hypervclock' present='yes'/>
> </clock>
> 
> To test if hyperv is used start the VM while running this in a terminal.
> "while true; do kvm_stat -1|grep kvm_hv_hypercall;done"
> If the numbers change the guest is using hyperv enlightenments.
> If you don't have kvm_stat installed it's part of the kernel source at
> tools/kvm/kvm_stat/kvm_stat.
> 
> The main benefit of using hyperv for me is access to the hypervclock. A win7
> guest can be configured to use various timing sources. The default if you use
> an unmodified virt-manager generated xml is to use acpi_pm which is a slow
> timer requiring a context switch to qemu in userspace on every access. By
> hiding the hypervisor cpuflag win7 can use the TSC timer which is very fast but
> unfortunately it's not completely stable. Time might sometimes run backwards
> when it's used. Win7 will also fall back on acpi_pm if the guest got too many
> cores. Too many seems to be 6, including HT cores, but I'm not sure if that is
> a hardcoded limit or caused by the environment somehow. In an earlier post to
> the mailing list I said that win7 will revert to acpi_pm when hyperthreading is
> enabled but it looks like the real problem is related to the number of cores,
> not HT specifically.
> 
> Hypervclock triggers a vm-exit on each access so it's not as fast as TSC but it
> should be stable and works with 6 cores. Here is a simple benchmarks using
> passmark's floating point math test and 3 guest cores. The floating point test
> use the timer so much that it's more of a timer overhead test than a floating
> point test.
> 
> acpi_pm     3315 points
> hypervclock 4273 points
> TSC         5578 points
> 
> Hypervclock is disappointingly slow compared to TSC but it's faster than
> acpi_pm and works with more cores. If you use a setup with enough cores to make
> win7 use acpi_pm switching to hypervclock will give better performance but if
> your setup runs fine with TSC you can keep using that.
> 
> _______________________________________________
> vfio-users mailing list
> vfio-users at redhat.com
> https://www.redhat.com/mailman/listinfo/vfio-users
> 




More information about the vfio-users mailing list