---
title: "hv_vmx_vcpu_set_apic_address(_:_:)"
framework: Hypervisor
role: symbol
role_heading: Function
platforms: [macOS 10.10+]
path: "hypervisor/hv_vmx_vcpu_set_apic_address(_:_:)"
---

# hv_vmx_vcpu_set_apic_address(_:_:)

Sets the address of the guest Advanced Programmable Interrupt Controller (APIC) for a vCPU in the guest physical address space of the VM.

## Declaration

```swift
func hv_vmx_vcpu_set_apic_address(_ vcpu: hv_vcpuid_t, _ gpa: hv_gpaddr_t) -> hv_return_t
```

## Parameters

- `vcpu`: The ID of the vCPU.
- `gpa`: The address in the guest physical address space. It must be page-aligned.

## Return Value

Return Value HV_SUCCESS if the operation was successful, otherwise an error code specified in hv_return_t.

## Discussion

Discussion important: This function must be called by the owning thread.

## See Also

### Field management

- [Virtual Machine Control Structure (VMCS) Field IDs](hypervisor/virtual-machine-control-structure-vmcs-field-ids.md)
- [hv_vmx_vcpu_read_vmcs(_:_:_:)](hypervisor/hv_vmx_vcpu_read_vmcs(_:_:_:).md)
- [hv_vmx_vcpu_write_vmcs(_:_:_:)](hypervisor/hv_vmx_vcpu_write_vmcs(_:_:_:).md)
- [hv_vmx_vcpu_get_cap_write_vmcs(_:_:_:_:)](hypervisor/hv_vmx_vcpu_get_cap_write_vmcs(_:_:_:_:).md)
- [Virtual Machine control structure (VMCS) Field IDs](hypervisor/1469436-virtual_machine_control_structur-enum.md)
