<!--
{
  "availability" : [
    "macOS: 10.10.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Hypervisor",
  "identifier" : "/documentation/Hypervisor",
  "metadataVersion" : "0.1.0",
  "role" : "Framework",
  "symbol" : {
    "kind" : "Framework",
    "modules" : [
      "Hypervisor"
    ],
    "preciseIdentifier" : "Hypervisor"
  },
  "title" : "Hypervisor"
}
-->

# Hypervisor

Build virtualization solutions on top of a lightweight hypervisor, without third-party kernel extensions.

## Overview

Hypervisor provides C APIs so you can interact with virtualization technologies in user space, without writing kernel extensions (KEXTs). As a result, the apps you create using this framework are suitable for distribution on the [Mac App Store](https://www.appstore.com/).

Use this framework to create and control hardware-facilitated virtual machines and virtual processors (VMs and vCPUs) from your entitled, sandboxed, user-space process. Hypervisor abstracts virtual machines as processes, and virtual processors as threads.

### Requirements

The Hypervisor framework has the following requirements:

- Supported hardware: The Hypervisor framework requires hardware support to virtualize hardware resources. On Apple silicon, that includes the Virtualization Extensions. On Intel-based Mac computers, the framework supports machines with an Intel VT-x feature set that includes Extended Page Tables (EPT) and Unrestricted Mode.

At runtime, determine whether the Hypervisor APIs are available on a particular machine with the sysctl command, passing `kern.hv_support` as an argument.

- Entitlements: All process must have the <doc://com.apple.documentation/documentation/BundleResources/Entitlements/com.apple.security.hypervisor> entitlement to use Hypervisor API.

### Virtual Resource Mapping

A guest is an operating system that runs on top of the virtual hardware. The operating system and processes that run the virtualized hardware are together called the host. Virtual hardware in the guest maps to specific resources on the host.

Each virtual machine corresponds to a process on the host. There can only be one virtual machine at a time per process; the virtual machine creates it with [`hv_vm_create(_:)`](/documentation/Hypervisor/hv_vm_create(_:)).

Virtual CPUs (vCPUs) in a virtual machine map to POSIX threads. Create a new vCPU for the current thread with [`hv_vcpu_create(_:_:_:)`](/documentation/Hypervisor/hv_vcpu_create(_:_:_:)). The vCPU runs when the thread calls [`hv_vcpu_run(_:)`](/documentation/Hypervisor/hv_vcpu_run(_:)).

Hypervisor maps the physical memory in the guest to virtual memory of the host process. Create a new memory mapping with [`hv_vm_map(_:_:_:_:)`](/documentation/Hypervisor/hv_vm_map(_:_:_:_:)). Access to memory outside the mapped range causes [`hv_vcpu_run(_:)`](/documentation/Hypervisor/hv_vcpu_run(_:)) to exit. Emulate memory-mapped hardware by emulating the memory access on exit and re-enter the guest with [`hv_vcpu_run(_:)`](/documentation/Hypervisor/hv_vcpu_run(_:)).

### Example VM Life Cycle

The following figure illustrates a simplified life cycle of creating and running a virtual machine with one or more virtual CPUs using the Hypervisor API.

![A flow diagram that represents the life cycle of a virtual machine.](images/com.apple.hypervisor/media-2916425@2x.png)

At the start of a task:

- Create a VM with [`hv_vm_create(_:)`](/documentation/Hypervisor/hv_vm_create(_:)).
- Map a region in the virtual address space of the current task into the guest physical address space of the VM with [`hv_vm_map(_:_:_:_:)`](/documentation/Hypervisor/hv_vm_map(_:_:_:_:)).
- Create one or more POSIX threads with `pthread_create(_:_:_:_:)`.

In each thread:

- Create a virtual CPU with [`hv_vcpu_create(_:_:_:)`](/documentation/Hypervisor/hv_vcpu_create(_:_:_:)).
- Call [`hv_vcpu_run(_:)`](/documentation/Hypervisor/hv_vcpu_run(_:)) to run the vCPU.

When a thread receives an exit event:

- Handle the event.
- Re-enter the guest with [`hv_vcpu_run(_:)`](/documentation/Hypervisor/hv_vcpu_run(_:)) or destroy the vCPU with [`hv_vcpu_destroy(_:)`](/documentation/Hypervisor/hv_vcpu_destroy(_:)).

After all threads finish:

- Unmap the memory region with [`hv_vm_unmap(_:_:)`](/documentation/Hypervisor/hv_vm_unmap(_:_:)).
- Destroy the VM with [`hv_vm_destroy()`](/documentation/Hypervisor/hv_vm_destroy()).

## Topics

### Platforms

[Apple Silicon](/documentation/Hypervisor/apple-silicon)

Create and run virtual machines on Apple silicon.

[Intel-based Mac](/documentation/Hypervisor/intel-based-mac)

Create and run virtual machines on Intel-based Mac computers.

### Entitlements

  <doc://com.apple.documentation/documentation/BundleResources/Entitlements/com.apple.security.hypervisor>

  <doc://com.apple.documentation/documentation/BundleResources/Entitlements/com.apple.vm.hypervisor>

  <doc://com.apple.documentation/documentation/BundleResources/Entitlements/com.apple.vm.networking>

  <doc://com.apple.documentation/documentation/BundleResources/Entitlements/com.apple.vm.device-access>

### Reference

[Hypervisor Structures](/documentation/Hypervisor/hypervisor-structures)

[Hypervisor Constants](/documentation/Hypervisor/hypervisor-constants)

[Hypervisor Functions](/documentation/Hypervisor/hypervisor-functions)

[Hypervisor Data Types](/documentation/Hypervisor/hypervisor-data-types)

### Structures

[`struct hv_ipa_granule_t`](/documentation/Hypervisor/hv_ipa_granule_t)

[`struct hv_tlbi_op_t`](/documentation/Hypervisor/hv_tlbi_op_t)

### Variables

[`var HV_FEATURE_REG_ID_AA64ISAR2_EL1: hv_feature_reg_t`](/documentation/Hypervisor/HV_FEATURE_REG_ID_AA64ISAR2_EL1)

[`var HV_FEATURE_REG_ID_AA64MMFR3_EL1: hv_feature_reg_t`](/documentation/Hypervisor/HV_FEATURE_REG_ID_AA64MMFR3_EL1)

[`var HV_FEATURE_REG_ID_AA64MMFR4_EL1: hv_feature_reg_t`](/documentation/Hypervisor/HV_FEATURE_REG_ID_AA64MMFR4_EL1)

[`var HV_FEATURE_REG_ID_AA64PFR2_EL1: hv_feature_reg_t`](/documentation/Hypervisor/HV_FEATURE_REG_ID_AA64PFR2_EL1)

[`var HV_IPA_GRANULE_16KB: hv_ipa_granule_t`](/documentation/Hypervisor/HV_IPA_GRANULE_16KB)

[`var HV_IPA_GRANULE_4KB: hv_ipa_granule_t`](/documentation/Hypervisor/HV_IPA_GRANULE_4KB)

[`var HV_SYS_REG_ID_AA64ISAR2_EL1: hv_sys_reg_t`](/documentation/Hypervisor/HV_SYS_REG_ID_AA64ISAR2_EL1)

[`var HV_SYS_REG_ID_AA64MMFR3_EL1: hv_sys_reg_t`](/documentation/Hypervisor/HV_SYS_REG_ID_AA64MMFR3_EL1)

[`var HV_SYS_REG_ID_AA64MMFR4_EL1: hv_sys_reg_t`](/documentation/Hypervisor/HV_SYS_REG_ID_AA64MMFR4_EL1)

[`var HV_SYS_REG_ID_AA64PFR2_EL1: hv_sys_reg_t`](/documentation/Hypervisor/HV_SYS_REG_ID_AA64PFR2_EL1)

[`var HV_TLBI_OP_ASIDE1IS: hv_tlbi_op_t`](/documentation/Hypervisor/HV_TLBI_OP_ASIDE1IS)

[`var HV_TLBI_OP_RVAAE1IS: hv_tlbi_op_t`](/documentation/Hypervisor/HV_TLBI_OP_RVAAE1IS)

[`var HV_TLBI_OP_RVAALE1IS: hv_tlbi_op_t`](/documentation/Hypervisor/HV_TLBI_OP_RVAALE1IS)

[`var HV_TLBI_OP_RVAE1IS: hv_tlbi_op_t`](/documentation/Hypervisor/HV_TLBI_OP_RVAE1IS)

[`var HV_TLBI_OP_RVALE1IS: hv_tlbi_op_t`](/documentation/Hypervisor/HV_TLBI_OP_RVALE1IS)

[`var HV_TLBI_OP_VAAE1IS: hv_tlbi_op_t`](/documentation/Hypervisor/HV_TLBI_OP_VAAE1IS)

[`var HV_TLBI_OP_VAALE1IS: hv_tlbi_op_t`](/documentation/Hypervisor/HV_TLBI_OP_VAALE1IS)

[`var HV_TLBI_OP_VAE1IS: hv_tlbi_op_t`](/documentation/Hypervisor/HV_TLBI_OP_VAE1IS)

[`var HV_TLBI_OP_VALE1IS: hv_tlbi_op_t`](/documentation/Hypervisor/HV_TLBI_OP_VALE1IS)

[`var HV_TLBI_OP_VMALLE1IS: hv_tlbi_op_t`](/documentation/Hypervisor/HV_TLBI_OP_VMALLE1IS)

### Functions

[`func hv_vcpu_get_serror(hv_vcpu_t, UnsafeMutablePointer<Bool>) -> hv_return_t`](/documentation/Hypervisor/hv_vcpu_get_serror(_:_:))

[`func hv_vcpu_get_wait_for_interrupt_time(hv_vcpu_t, UnsafeMutablePointer<UInt64>) -> hv_return_t`](/documentation/Hypervisor/hv_vcpu_get_wait_for_interrupt_time(_:_:))

[`func hv_vcpu_invalidate_tlb(hv_vcpu_t, hv_tlbi_op_t, UInt64) -> hv_return_t`](/documentation/Hypervisor/hv_vcpu_invalidate_tlb(_:_:_:))

[`func hv_vcpu_set_serror(hv_vcpu_t, Bool) -> hv_return_t`](/documentation/Hypervisor/hv_vcpu_set_serror(_:_:))

[`func hv_vm_config_get_default_ipa_granule(UnsafeMutablePointer<hv_ipa_granule_t>) -> hv_return_t`](/documentation/Hypervisor/hv_vm_config_get_default_ipa_granule(_:))

[`func hv_vm_config_get_ipa_granule(hv_vm_config_t, UnsafeMutablePointer<hv_ipa_granule_t>) -> hv_return_t`](/documentation/Hypervisor/hv_vm_config_get_ipa_granule(_:_:))

[`func hv_vm_config_set_ipa_granule(hv_vm_config_t, hv_ipa_granule_t) -> hv_return_t`](/documentation/Hypervisor/hv_vm_config_set_ipa_granule(_:_:))

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)