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 24*88f537d5SShuo Liu #define HC_ID_MEM_BASE 0x40UL 25*88f537d5SShuo Liu #define HC_VM_SET_MEMORY_REGIONS _HC_ID(HC_ID, HC_ID_MEM_BASE + 0x02) 26*88f537d5SShuo Liu 279c5137aeSShuo Liu /** 289c5137aeSShuo Liu * hcall_create_vm() - Create a User VM 299c5137aeSShuo Liu * @vminfo: Service VM GPA of info of User VM creation 309c5137aeSShuo Liu * 319c5137aeSShuo Liu * Return: 0 on success, <0 on failure 329c5137aeSShuo Liu */ 339c5137aeSShuo Liu static inline long hcall_create_vm(u64 vminfo) 349c5137aeSShuo Liu { 359c5137aeSShuo Liu return acrn_hypercall1(HC_CREATE_VM, vminfo); 369c5137aeSShuo Liu } 379c5137aeSShuo Liu 389c5137aeSShuo Liu /** 399c5137aeSShuo Liu * hcall_start_vm() - Start a User VM 409c5137aeSShuo Liu * @vmid: User VM ID 419c5137aeSShuo Liu * 429c5137aeSShuo Liu * Return: 0 on success, <0 on failure 439c5137aeSShuo Liu */ 449c5137aeSShuo Liu static inline long hcall_start_vm(u64 vmid) 459c5137aeSShuo Liu { 469c5137aeSShuo Liu return acrn_hypercall1(HC_START_VM, vmid); 479c5137aeSShuo Liu } 489c5137aeSShuo Liu 499c5137aeSShuo Liu /** 509c5137aeSShuo Liu * hcall_pause_vm() - Pause a User VM 519c5137aeSShuo Liu * @vmid: User VM ID 529c5137aeSShuo Liu * 539c5137aeSShuo Liu * Return: 0 on success, <0 on failure 549c5137aeSShuo Liu */ 559c5137aeSShuo Liu static inline long hcall_pause_vm(u64 vmid) 569c5137aeSShuo Liu { 579c5137aeSShuo Liu return acrn_hypercall1(HC_PAUSE_VM, vmid); 589c5137aeSShuo Liu } 599c5137aeSShuo Liu 609c5137aeSShuo Liu /** 619c5137aeSShuo Liu * hcall_destroy_vm() - Destroy a User VM 629c5137aeSShuo Liu * @vmid: User VM ID 639c5137aeSShuo Liu * 649c5137aeSShuo Liu * Return: 0 on success, <0 on failure 659c5137aeSShuo Liu */ 669c5137aeSShuo Liu static inline long hcall_destroy_vm(u64 vmid) 679c5137aeSShuo Liu { 689c5137aeSShuo Liu return acrn_hypercall1(HC_DESTROY_VM, vmid); 699c5137aeSShuo Liu } 709c5137aeSShuo Liu 719c5137aeSShuo Liu /** 729c5137aeSShuo Liu * hcall_reset_vm() - Reset a User VM 739c5137aeSShuo Liu * @vmid: User VM ID 749c5137aeSShuo Liu * 759c5137aeSShuo Liu * Return: 0 on success, <0 on failure 769c5137aeSShuo Liu */ 779c5137aeSShuo Liu static inline long hcall_reset_vm(u64 vmid) 789c5137aeSShuo Liu { 799c5137aeSShuo Liu return acrn_hypercall1(HC_RESET_VM, vmid); 809c5137aeSShuo Liu } 819c5137aeSShuo Liu 822ad2aaeeSShuo Liu /** 832ad2aaeeSShuo Liu * hcall_set_vcpu_regs() - Set up registers of virtual CPU of a User VM 842ad2aaeeSShuo Liu * @vmid: User VM ID 852ad2aaeeSShuo Liu * @regs_state: Service VM GPA of registers state 862ad2aaeeSShuo Liu * 872ad2aaeeSShuo Liu * Return: 0 on success, <0 on failure 882ad2aaeeSShuo Liu */ 892ad2aaeeSShuo Liu static inline long hcall_set_vcpu_regs(u64 vmid, u64 regs_state) 902ad2aaeeSShuo Liu { 912ad2aaeeSShuo Liu return acrn_hypercall2(HC_SET_VCPU_REGS, vmid, regs_state); 922ad2aaeeSShuo Liu } 932ad2aaeeSShuo Liu 94*88f537d5SShuo Liu /** 95*88f537d5SShuo Liu * hcall_set_memory_regions() - Inform the hypervisor to set up EPT mappings 96*88f537d5SShuo Liu * @regions_pa: Service VM GPA of &struct vm_memory_region_batch 97*88f537d5SShuo Liu * 98*88f537d5SShuo Liu * Return: 0 on success, <0 on failure 99*88f537d5SShuo Liu */ 100*88f537d5SShuo Liu static inline long hcall_set_memory_regions(u64 regions_pa) 101*88f537d5SShuo Liu { 102*88f537d5SShuo Liu return acrn_hypercall1(HC_VM_SET_MEMORY_REGIONS, regions_pa); 103*88f537d5SShuo Liu } 104*88f537d5SShuo Liu 1059c5137aeSShuo Liu #endif /* __ACRN_HSM_HYPERCALL_H */ 106