diff --git a/hypervisor/common/hypercall.c b/hypervisor/common/hypercall.c index 61d0b5156..906a29f00 100644 --- a/hypervisor/common/hypercall.c +++ b/hypervisor/common/hypercall.c @@ -108,13 +108,31 @@ int32_t hcall_get_api_version(struct acrn_vm *vm, uint64_t param) */ int32_t hcall_get_platform_info(struct acrn_vm *vm, uint64_t param) { - struct hc_platform_info platform_info; + struct hc_platform_info pi = { 0 }; + uint32_t entry_size = sizeof(struct acrn_vm_config); + int32_t ret; - platform_info.cpu_num = get_pcpu_nums(); - platform_info.max_vcpus_per_vm = MAX_VCPUS_PER_VM; - platform_info.max_kata_containers = CONFIG_MAX_KATA_VM_NUM; + /* to get the vm_config_info pointer */ + ret = copy_from_gpa(vm, &pi, param, sizeof(pi)); + if (ret == 0) { + pi.cpu_num = get_pcpu_nums(); + pi.version = 0x100; /* version 1.0; byte[1:0] = major:minor version */ + pi.max_vcpus_per_vm = MAX_VCPUS_PER_VM; + pi.max_kata_containers = CONFIG_MAX_KATA_VM_NUM; + pi.max_vms = CONFIG_MAX_VM_NUM; + pi.vm_config_entry_size = entry_size; - return copy_to_gpa(vm, &platform_info, param, sizeof(platform_info)); + /* If it wants to get the vm_configs info */ + if (pi.vm_configs_addr != 0UL) { + ret = copy_to_gpa(vm, (void *)get_vm_config(0U), pi.vm_configs_addr, entry_size * pi.max_vms); + } + + if (ret == 0) { + ret = copy_to_gpa(vm, &pi, param, sizeof(pi)); + } + } + + return ret; } /** diff --git a/hypervisor/include/public/acrn_hv_defs.h b/hypervisor/include/public/acrn_hv_defs.h index 637ffd34b..f69d2786c 100644 --- a/hypervisor/include/public/acrn_hv_defs.h +++ b/hypervisor/include/public/acrn_hv_defs.h @@ -319,8 +319,11 @@ struct hc_platform_info { /** Physical CPU number */ uint16_t cpu_num; + /** version of this structure */ + uint16_t version; + /** Align the size of version & hardware info to 128Bytes. */ - uint8_t reserved0[126]; + uint8_t reserved0[124]; /** Configuration Information */ /** Maximum vCPU number for one VM. */ @@ -329,8 +332,30 @@ struct hc_platform_info { /** Maximum Kata container number in SOS VM */ uint8_t max_kata_containers; + uint8_t reserved1[7]; + + /** Number of configured VMs */ + uint16_t max_vms; + + /** + * The size of acrn_vm_config is various on different platforms. + * This is the size of this struct which is used by the caller + * to parse the vm_configs array. + */ + uint32_t vm_config_entry_size; + + /** + * Address to an array of struct acrn_vm_config, containing all + * the configurations of all VMs. VHM treats it as an opague data + * structure. + * + * The size of one array element is vm_config_entry_size while + * the number of elements is max_vms. + */ + uint64_t vm_configs_addr; + /** Align the size of Configuration info to 128Bytes. */ - uint8_t reserved1[125]; + uint8_t reserved2[104]; } __aligned(8); /**