19c5137aeSShuo Liu /* SPDX-License-Identifier: GPL-2.0 */ 29c5137aeSShuo Liu /* 39c5137aeSShuo Liu * ACRN HSM: hypercalls of ACRN Hypervisor 49c5137aeSShuo Liu */ 59c5137aeSShuo Liu #ifndef __ACRN_HSM_HYPERCALL_H 69c5137aeSShuo Liu #define __ACRN_HSM_HYPERCALL_H 79c5137aeSShuo Liu #include <asm/acrn.h> 89c5137aeSShuo Liu 99c5137aeSShuo Liu /* 109c5137aeSShuo Liu * Hypercall IDs of the ACRN Hypervisor 119c5137aeSShuo Liu */ 129c5137aeSShuo Liu #define _HC_ID(x, y) (((x) << 24) | (y)) 139c5137aeSShuo Liu 149c5137aeSShuo Liu #define HC_ID 0x80UL 159c5137aeSShuo Liu 169c5137aeSShuo Liu #define HC_ID_VM_BASE 0x10UL 179c5137aeSShuo Liu #define HC_CREATE_VM _HC_ID(HC_ID, HC_ID_VM_BASE + 0x00) 189c5137aeSShuo Liu #define HC_DESTROY_VM _HC_ID(HC_ID, HC_ID_VM_BASE + 0x01) 199c5137aeSShuo Liu #define HC_START_VM _HC_ID(HC_ID, HC_ID_VM_BASE + 0x02) 209c5137aeSShuo Liu #define HC_PAUSE_VM _HC_ID(HC_ID, HC_ID_VM_BASE + 0x03) 219c5137aeSShuo Liu #define HC_RESET_VM _HC_ID(HC_ID, HC_ID_VM_BASE + 0x05) 222ad2aaeeSShuo Liu #define HC_SET_VCPU_REGS _HC_ID(HC_ID, HC_ID_VM_BASE + 0x06) 239c5137aeSShuo Liu 24c7cf8d27SShuo Liu #define HC_ID_IRQ_BASE 0x20UL 25c7cf8d27SShuo Liu #define HC_INJECT_MSI _HC_ID(HC_ID, HC_ID_IRQ_BASE + 0x03) 26c7cf8d27SShuo Liu #define HC_VM_INTR_MONITOR _HC_ID(HC_ID, HC_ID_IRQ_BASE + 0x04) 27c7cf8d27SShuo Liu #define HC_SET_IRQLINE _HC_ID(HC_ID, HC_ID_IRQ_BASE + 0x05) 28c7cf8d27SShuo Liu 2972f293deSShuo Liu #define HC_ID_IOREQ_BASE 0x30UL 3072f293deSShuo Liu #define HC_SET_IOREQ_BUFFER _HC_ID(HC_ID, HC_ID_IOREQ_BASE + 0x00) 3172f293deSShuo Liu #define HC_NOTIFY_REQUEST_FINISH _HC_ID(HC_ID, HC_ID_IOREQ_BASE + 0x01) 3272f293deSShuo Liu 3388f537d5SShuo Liu #define HC_ID_MEM_BASE 0x40UL 3488f537d5SShuo Liu #define HC_VM_SET_MEMORY_REGIONS _HC_ID(HC_ID, HC_ID_MEM_BASE + 0x02) 3588f537d5SShuo Liu 36ce011e13SShuo Liu #define HC_ID_PCI_BASE 0x50UL 37ce011e13SShuo Liu #define HC_SET_PTDEV_INTR _HC_ID(HC_ID, HC_ID_PCI_BASE + 0x03) 38ce011e13SShuo Liu #define HC_RESET_PTDEV_INTR _HC_ID(HC_ID, HC_ID_PCI_BASE + 0x04) 39ce011e13SShuo Liu #define HC_ASSIGN_PCIDEV _HC_ID(HC_ID, HC_ID_PCI_BASE + 0x05) 40ce011e13SShuo Liu #define HC_DEASSIGN_PCIDEV _HC_ID(HC_ID, HC_ID_PCI_BASE + 0x06) 41ce011e13SShuo Liu 42*3d679d5aSShuo Liu #define HC_ID_PM_BASE 0x80UL 43*3d679d5aSShuo Liu #define HC_PM_GET_CPU_STATE _HC_ID(HC_ID, HC_ID_PM_BASE + 0x00) 44*3d679d5aSShuo Liu 459c5137aeSShuo Liu /** 469c5137aeSShuo Liu * hcall_create_vm() - Create a User VM 479c5137aeSShuo Liu * @vminfo: Service VM GPA of info of User VM creation 489c5137aeSShuo Liu * 499c5137aeSShuo Liu * Return: 0 on success, <0 on failure 509c5137aeSShuo Liu */ 519c5137aeSShuo Liu static inline long hcall_create_vm(u64 vminfo) 529c5137aeSShuo Liu { 539c5137aeSShuo Liu return acrn_hypercall1(HC_CREATE_VM, vminfo); 549c5137aeSShuo Liu } 559c5137aeSShuo Liu 569c5137aeSShuo Liu /** 579c5137aeSShuo Liu * hcall_start_vm() - Start a User VM 589c5137aeSShuo Liu * @vmid: User VM ID 599c5137aeSShuo Liu * 609c5137aeSShuo Liu * Return: 0 on success, <0 on failure 619c5137aeSShuo Liu */ 629c5137aeSShuo Liu static inline long hcall_start_vm(u64 vmid) 639c5137aeSShuo Liu { 649c5137aeSShuo Liu return acrn_hypercall1(HC_START_VM, vmid); 659c5137aeSShuo Liu } 669c5137aeSShuo Liu 679c5137aeSShuo Liu /** 689c5137aeSShuo Liu * hcall_pause_vm() - Pause a User VM 699c5137aeSShuo Liu * @vmid: User VM ID 709c5137aeSShuo Liu * 719c5137aeSShuo Liu * Return: 0 on success, <0 on failure 729c5137aeSShuo Liu */ 739c5137aeSShuo Liu static inline long hcall_pause_vm(u64 vmid) 749c5137aeSShuo Liu { 759c5137aeSShuo Liu return acrn_hypercall1(HC_PAUSE_VM, vmid); 769c5137aeSShuo Liu } 779c5137aeSShuo Liu 789c5137aeSShuo Liu /** 799c5137aeSShuo Liu * hcall_destroy_vm() - Destroy a User VM 809c5137aeSShuo Liu * @vmid: User VM ID 819c5137aeSShuo Liu * 829c5137aeSShuo Liu * Return: 0 on success, <0 on failure 839c5137aeSShuo Liu */ 849c5137aeSShuo Liu static inline long hcall_destroy_vm(u64 vmid) 859c5137aeSShuo Liu { 869c5137aeSShuo Liu return acrn_hypercall1(HC_DESTROY_VM, vmid); 879c5137aeSShuo Liu } 889c5137aeSShuo Liu 899c5137aeSShuo Liu /** 909c5137aeSShuo Liu * hcall_reset_vm() - Reset a User VM 919c5137aeSShuo Liu * @vmid: User VM ID 929c5137aeSShuo Liu * 939c5137aeSShuo Liu * Return: 0 on success, <0 on failure 949c5137aeSShuo Liu */ 959c5137aeSShuo Liu static inline long hcall_reset_vm(u64 vmid) 969c5137aeSShuo Liu { 979c5137aeSShuo Liu return acrn_hypercall1(HC_RESET_VM, vmid); 989c5137aeSShuo Liu } 999c5137aeSShuo Liu 1002ad2aaeeSShuo Liu /** 1012ad2aaeeSShuo Liu * hcall_set_vcpu_regs() - Set up registers of virtual CPU of a User VM 1022ad2aaeeSShuo Liu * @vmid: User VM ID 1032ad2aaeeSShuo Liu * @regs_state: Service VM GPA of registers state 1042ad2aaeeSShuo Liu * 1052ad2aaeeSShuo Liu * Return: 0 on success, <0 on failure 1062ad2aaeeSShuo Liu */ 1072ad2aaeeSShuo Liu static inline long hcall_set_vcpu_regs(u64 vmid, u64 regs_state) 1082ad2aaeeSShuo Liu { 1092ad2aaeeSShuo Liu return acrn_hypercall2(HC_SET_VCPU_REGS, vmid, regs_state); 1102ad2aaeeSShuo Liu } 1112ad2aaeeSShuo Liu 11288f537d5SShuo Liu /** 113c7cf8d27SShuo Liu * hcall_inject_msi() - Deliver a MSI interrupt to a User VM 114c7cf8d27SShuo Liu * @vmid: User VM ID 115c7cf8d27SShuo Liu * @msi: Service VM GPA of MSI message 116c7cf8d27SShuo Liu * 117c7cf8d27SShuo Liu * Return: 0 on success, <0 on failure 118c7cf8d27SShuo Liu */ 119c7cf8d27SShuo Liu static inline long hcall_inject_msi(u64 vmid, u64 msi) 120c7cf8d27SShuo Liu { 121c7cf8d27SShuo Liu return acrn_hypercall2(HC_INJECT_MSI, vmid, msi); 122c7cf8d27SShuo Liu } 123c7cf8d27SShuo Liu 124c7cf8d27SShuo Liu /** 125c7cf8d27SShuo Liu * hcall_vm_intr_monitor() - Set a shared page for User VM interrupt statistics 126c7cf8d27SShuo Liu * @vmid: User VM ID 127c7cf8d27SShuo Liu * @addr: Service VM GPA of the shared page 128c7cf8d27SShuo Liu * 129c7cf8d27SShuo Liu * Return: 0 on success, <0 on failure 130c7cf8d27SShuo Liu */ 131c7cf8d27SShuo Liu static inline long hcall_vm_intr_monitor(u64 vmid, u64 addr) 132c7cf8d27SShuo Liu { 133c7cf8d27SShuo Liu return acrn_hypercall2(HC_VM_INTR_MONITOR, vmid, addr); 134c7cf8d27SShuo Liu } 135c7cf8d27SShuo Liu 136c7cf8d27SShuo Liu /** 137c7cf8d27SShuo Liu * hcall_set_irqline() - Set or clear an interrupt line 138c7cf8d27SShuo Liu * @vmid: User VM ID 139c7cf8d27SShuo Liu * @op: Service VM GPA of interrupt line operations 140c7cf8d27SShuo Liu * 141c7cf8d27SShuo Liu * Return: 0 on success, <0 on failure 142c7cf8d27SShuo Liu */ 143c7cf8d27SShuo Liu static inline long hcall_set_irqline(u64 vmid, u64 op) 144c7cf8d27SShuo Liu { 145c7cf8d27SShuo Liu return acrn_hypercall2(HC_SET_IRQLINE, vmid, op); 146c7cf8d27SShuo Liu } 147c7cf8d27SShuo Liu 148c7cf8d27SShuo Liu /** 14972f293deSShuo Liu * hcall_set_ioreq_buffer() - Set up the shared buffer for I/O Requests. 15072f293deSShuo Liu * @vmid: User VM ID 15172f293deSShuo Liu * @buffer: Service VM GPA of the shared buffer 15272f293deSShuo Liu * 15372f293deSShuo Liu * Return: 0 on success, <0 on failure 15472f293deSShuo Liu */ 15572f293deSShuo Liu static inline long hcall_set_ioreq_buffer(u64 vmid, u64 buffer) 15672f293deSShuo Liu { 15772f293deSShuo Liu return acrn_hypercall2(HC_SET_IOREQ_BUFFER, vmid, buffer); 15872f293deSShuo Liu } 15972f293deSShuo Liu 16072f293deSShuo Liu /** 16172f293deSShuo Liu * hcall_notify_req_finish() - Notify ACRN Hypervisor of I/O request completion. 16272f293deSShuo Liu * @vmid: User VM ID 16372f293deSShuo Liu * @vcpu: The vCPU which initiated the I/O request 16472f293deSShuo Liu * 16572f293deSShuo Liu * Return: 0 on success, <0 on failure 16672f293deSShuo Liu */ 16772f293deSShuo Liu static inline long hcall_notify_req_finish(u64 vmid, u64 vcpu) 16872f293deSShuo Liu { 16972f293deSShuo Liu return acrn_hypercall2(HC_NOTIFY_REQUEST_FINISH, vmid, vcpu); 17072f293deSShuo Liu } 17172f293deSShuo Liu 17272f293deSShuo Liu /** 17388f537d5SShuo Liu * hcall_set_memory_regions() - Inform the hypervisor to set up EPT mappings 17488f537d5SShuo Liu * @regions_pa: Service VM GPA of &struct vm_memory_region_batch 17588f537d5SShuo Liu * 17688f537d5SShuo Liu * Return: 0 on success, <0 on failure 17788f537d5SShuo Liu */ 17888f537d5SShuo Liu static inline long hcall_set_memory_regions(u64 regions_pa) 17988f537d5SShuo Liu { 18088f537d5SShuo Liu return acrn_hypercall1(HC_VM_SET_MEMORY_REGIONS, regions_pa); 18188f537d5SShuo Liu } 18288f537d5SShuo Liu 183ce011e13SShuo Liu /** 184ce011e13SShuo Liu * hcall_assign_pcidev() - Assign a PCI device to a User VM 185ce011e13SShuo Liu * @vmid: User VM ID 186ce011e13SShuo Liu * @addr: Service VM GPA of the &struct acrn_pcidev 187ce011e13SShuo Liu * 188ce011e13SShuo Liu * Return: 0 on success, <0 on failure 189ce011e13SShuo Liu */ 190ce011e13SShuo Liu static inline long hcall_assign_pcidev(u64 vmid, u64 addr) 191ce011e13SShuo Liu { 192ce011e13SShuo Liu return acrn_hypercall2(HC_ASSIGN_PCIDEV, vmid, addr); 193ce011e13SShuo Liu } 194ce011e13SShuo Liu 195ce011e13SShuo Liu /** 196ce011e13SShuo Liu * hcall_deassign_pcidev() - De-assign a PCI device from a User VM 197ce011e13SShuo Liu * @vmid: User VM ID 198ce011e13SShuo Liu * @addr: Service VM GPA of the &struct acrn_pcidev 199ce011e13SShuo Liu * 200ce011e13SShuo Liu * Return: 0 on success, <0 on failure 201ce011e13SShuo Liu */ 202ce011e13SShuo Liu static inline long hcall_deassign_pcidev(u64 vmid, u64 addr) 203ce011e13SShuo Liu { 204ce011e13SShuo Liu return acrn_hypercall2(HC_DEASSIGN_PCIDEV, vmid, addr); 205ce011e13SShuo Liu } 206ce011e13SShuo Liu 207ce011e13SShuo Liu /** 208ce011e13SShuo Liu * hcall_set_ptdev_intr() - Configure an interrupt for an assigned PCI device. 209ce011e13SShuo Liu * @vmid: User VM ID 210ce011e13SShuo Liu * @irq: Service VM GPA of the &struct acrn_ptdev_irq 211ce011e13SShuo Liu * 212ce011e13SShuo Liu * Return: 0 on success, <0 on failure 213ce011e13SShuo Liu */ 214ce011e13SShuo Liu static inline long hcall_set_ptdev_intr(u64 vmid, u64 irq) 215ce011e13SShuo Liu { 216ce011e13SShuo Liu return acrn_hypercall2(HC_SET_PTDEV_INTR, vmid, irq); 217ce011e13SShuo Liu } 218ce011e13SShuo Liu 219ce011e13SShuo Liu /** 220ce011e13SShuo Liu * hcall_reset_ptdev_intr() - Reset an interrupt for an assigned PCI device. 221ce011e13SShuo Liu * @vmid: User VM ID 222ce011e13SShuo Liu * @irq: Service VM GPA of the &struct acrn_ptdev_irq 223ce011e13SShuo Liu * 224ce011e13SShuo Liu * Return: 0 on success, <0 on failure 225ce011e13SShuo Liu */ 226ce011e13SShuo Liu static inline long hcall_reset_ptdev_intr(u64 vmid, u64 irq) 227ce011e13SShuo Liu { 228ce011e13SShuo Liu return acrn_hypercall2(HC_RESET_PTDEV_INTR, vmid, irq); 229ce011e13SShuo Liu } 230ce011e13SShuo Liu 231*3d679d5aSShuo Liu /* 232*3d679d5aSShuo Liu * hcall_get_cpu_state() - Get P-states and C-states info from the hypervisor 233*3d679d5aSShuo Liu * @state: Service VM GPA of buffer of P-states and C-states 234*3d679d5aSShuo Liu */ 235*3d679d5aSShuo Liu static inline long hcall_get_cpu_state(u64 cmd, u64 state) 236*3d679d5aSShuo Liu { 237*3d679d5aSShuo Liu return acrn_hypercall2(HC_PM_GET_CPU_STATE, cmd, state); 238*3d679d5aSShuo Liu } 239*3d679d5aSShuo Liu 2409c5137aeSShuo Liu #endif /* __ACRN_HSM_HYPERCALL_H */ 241