Contents

VMX Capabilities

An enumeration that represents the available VMX capabilities.

Overview

The capabilites available to the hypervisor can vary depending on the specific hardware platform or OS release. Use the hv_vmx_read_capability(_:_:) API at run time to determine the capabilities that can you can select.

The example below demonstrates the process for checking for the availability a specific capability, here checking for the avaiability of timestamp-counter scaling (TSC scaling):

static uint64_t canonicalize(uint64_t ctrl, uint64_t mask) {
    return (ctrl | (mask & 0xffffffff)) & (mask >> 32);
}

main() {
    
    // Fetch the supported capabilities for the PROCBASED2 field
    if (hv_vmx_read_capability(HV_VMX_CAP_PROCBASED2, &proc2_cap) != 0)
        errx(1, "vcpu_read_capability(%u, CAP_VMX_PROCBASED2) failed", vcpu);
    
    // Apply the constraints to our request to use TSC scaling
    const uint64_t newcap = canonicalize(CPU_BASED2_TSC_SCALING, proc2_cap);
    
    // Test to see if that bit is supported on this platform
    if ((newcap & CPU_BASED2_TSC_SCALING) == 0) {
        warnx(“TSC scaling not supported on this platform”);
    }
    
    // Continue, but without TSC scaling ...
    write_vmcs(vcpu, VMCS_CTRL_CPU_BASED2, newcap);

    // ...
}

Topics

Capabilities

See Also

Capabilities