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

# hv_vcpu_set_vtimer_mask(_:_:)

Sets or clears the virtual timer mask.

```
func hv_vcpu_set_vtimer_mask(_ vcpu: hv_vcpu_t, _ vtimer_is_masked: Bool) -> hv_return_t
```

## Parameters

`vcpu`

The ID of the vCPU instance.

`vtimer_is_masked`

A Boolean value that indicates whether the vTimer has a mask set.

## 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

After [`hv_vcpu_run(_:)`](/documentation/Hypervisor/hv_vcpu_run(_:)) returns with the exit reason `HV_EXIT_REASON_VTIMER_ACTIVATED`, the timer is masked automatically.

The vCPU won’t exit with this reason again until the mask is cleared even when calling hv_vcpu_run() with the vTimer interrupt in a pending state.

After receiving a [`HV_EXIT_REASON_VTIMER_ACTIVATED`](/documentation/Hypervisor/HV_EXIT_REASON_VTIMER_ACTIVATED) exit reason, the caller of `hv_vcpu_run`() needs to make the interrupts to the vTimer pending in the guest’s virtual interrupt controller. It also needs to detect when the guest has serviced this interrupt. For example, call this function when emulating a GIC when deactivating an interrupt whose ID matches that of the vTimer.

---

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)