<!--
{
  "availability" : [
    "macOS: 11.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Hypervisor",
  "identifier" : "/documentation/Hypervisor/hv_vcpu_run(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Function",
  "symbol" : {
    "kind" : "Function",
    "modules" : [
      "Hypervisor"
    ],
    "preciseIdentifier" : "c:@F@hv_vcpu_run"
  },
  "title" : "hv_vcpu_run(_:)"
}
-->

# hv_vcpu_run(_:)

Starts the execution of a vCPU.

```
func hv_vcpu_run(_ vcpu: hv_vcpu_t) -> hv_return_t
```

## Parameters

`vcpu`

The instance of the vCPU.

## Return Value

[`HV_SUCCESS`](/documentation/Hypervisor/HV_SUCCESS) if the operation was successful, otherwise an error code specified in [`hv_return_t`](/documentation/Hypervisor/hv_return_t).

## Discussion

Call blocks until the next exit of the vCPU. The owning thread must call this function.

On an Apple Silicon, if the exit is of type [`HV_EXIT_REASON_VTIMER_ACTIVATED`](/documentation/Hypervisor/HV_EXIT_REASON_VTIMER_ACTIVATED), the VTimer is automatically masked. As a result, no timer fires until the timer is unmasked with [`hv_vcpu_set_vtimer_mask(_:_:)`](/documentation/Hypervisor/hv_vcpu_set_vtimer_mask(_:_:)).

On an Intel-based Mac, [`hv_vcpu_run(_:)`](/documentation/Hypervisor/hv_vcpu_run(_:)) exits from causes external to the guest. To avoid the overhead of spurious exits use [`hv_vcpu_run_until(_:_:)`](/documentation/Hypervisor/hv_vcpu_run_until(_:_:)) with the deadline [`HV_DEADLINE_FOREVER`](/documentation/Hypervisor/HV_DEADLINE_FOREVER).

---

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)