Enable Hyper-V enlightenments

Hyper-V enlightenments provide a method for KVM to emulate the Microsoft Hyper-V hypervisor, which improves the performance of Windows virtual machines.

Enable Hyper-V enlightenments on a Windows virtual machine

To improve the performance of a Windows virtual machine (VM) running in a RHEL 10 host, you can use Hyper-V enlightenments.

Procedure

  1. Use the virsh edit command to open the XML configuration of the VM. For example:
    # virsh edit windows-vm
  2. Add the following <hyperv> sub-section to the <features> section of the XML:
    <features>
      [...]
      <hyperv>
        <relaxed state='on'/>
        <vapic state='on'/>
        <spinlocks state='on' retries='8191'/>
        <vendor_id state='on' value='KVM Hv'/>
        <vpindex state='on'/>
        <runtime state='on' />
        <synic state='on'/>
        <stimer state='on'>
          <direct state='on'/>
        </stimer>
        <frequencies state='on'/>
        <reset state='on'/>
        <tlbflush state='on'/>
        <reenlightenment state='on'/>
        <ipi state='on'/>
        <evmcs state='on'/>
      </hyperv>
      [...]
    </features>

    If the XML already contains a <hyperv> sub-section, modify it as shown in the preceding example.

  3. Change the clock section of the configuration as follows:
    <clock offset='localtime'>
      ...
      <timer name='hypervclock' present='yes'/>
    </clock>
  4. Save and exit the XML configuration.
  5. If the VM is running, restart it.

Results

  • Use the virsh dumpxml command to display the XML configuration of the running VM. If it includes the following segments, the Hyper-V enlightenments are enabled on the VM.
    <hyperv>
      <relaxed state='on'/>
      <vapic state='on'/>
      <spinlocks state='on' retries='8191'/>
      <vendor_id state='on' value='KVM Hv'/>
      <vpindex state='on'/>
      <runtime state='on' />
      <synic state='on'/>
      <frequencies state='on'/>
      <reset state='on'/>
      <tlbflush state='on'/>
      <reenlightenment state='on'/>
      <stimer state='on'>
        <direct state='on'/>
      </stimer>
      <ipi state='on'/>
      <evmcs state='on'/>
    </hyperv>
    
    <clock offset='localtime'>
      ...
      <timer name='hypervclock' present='yes'/>
    </clock>

Configurable Hyper-V enlightenments

Hyper-V enlightenments are configurable features that improve the performance of Windows virtual machines on the KVM hypervisor.

The following table provides information about these configurable Hyper-V features and their values.

Table 1. Configurable Hyper-V features
Enlightenment Description Values

evmcs

Implements paravirtualized protocol between L0 (KVM) and L1 (Hyper-V) hypervisors, which enables faster L2 exits to the hypervisor.

Note

This feature is exclusive to Intel processors.

on, off

frequencies

Enables Hyper-V frequency Machine Specific Registers (MSRs).

on, off

ipi

Enables paravirtualized inter processor interrupts (IPI) support.

on, off

reenlightenment

Notifies when there is a time stamp counter (TSC) frequency change which only occurs during migration. It also allows the guest to keep using the old frequency until it is ready to switch to the new one.

on, off

relaxed

Disables a Windows sanity check that commonly results in a BSOD when the VM is running on a heavily loaded host. This is similar to the Linux kernel option no_timer_check, which is automatically enabled when Linux is running on KVM.

on, off

runtime

Sets processor time spent on running the guest code, and on behalf of the guest code.

on, off

spinlocks

  • Used by a VM’s operating system to notify Hyper-V that the calling virtual processor is attempting to acquire a resource that is potentially held by another virtual processor within the same partition.
  • Used by Hyper-V to indicate to the virtual machine’s operating system the number of times a spinlock acquisition must be attempted before indicating an excessive spin situation to Hyper-V.

on, off

stimer

Enables synthetic timers for virtual processors. Note that certain Windows versions revert to using HPET (or even RTC when HPET is unavailable) when this enlightenment is not provided, which can lead to significant CPU consumption, even when the virtual CPU is idle.

on, off

stimer-direct

Enables synthetic timers when an expiration event is delivered through a normal interrupt.

on, off.

synic

Together with stimer, activates the synthetic timer. Windows 8 uses this feature in periodic mode.

on, off

time

Enables the following Hyper-V-specific clock sources available to the VM,

  • MSR-based 82 Hyper-V clock source (HV_X64_MSR_TIME_REF_COUNT, 0x40000020)
  • Reference TSC 83 page which is enabled through MSR (HV_X64_MSR_REFERENCE_TSC, 0x40000021)

on, off

tlbflush

Flushes the TLB of the virtual processors.

on, off

vapic

Enables virtual APIC, which provides accelerated MSR access to the high-usage, memory-mapped Advanced Programmable Interrupt Controller (APIC) registers.

on, off

vendor_id

Sets the Hyper-V vendor id.

  • on, off
  • Id value - string of up to 12 characters

vpindex

Enables virtual processor index.

on, off