mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-09-01 08:56:55 +00:00
hv: return pre-defined vcpu_num from HV to upper layer
There is plan that define each VM configuration statically in HV and let DM just do VM creating and destroying. So DM need get vcpu_num information when VM creating. This patch return the vcpu_num via the API param. And also initial the VMs' cpu_num for existing scenarios. Tracked-On: #3663 Signed-off-by: Jason Chen CJ <jason.cj.chen@intel.com> Signed-off-by: Yu Wang <yu1.wang@intel.com> Signed-off-by: Shuo A Liu <shuo.a.liu@intel.com> Reviewed-by: Yin Fengwei <fengwei.yin@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
committed by
ACRN System Integration
parent
59e39c5fbb
commit
ca2540fe8c
@@ -4,6 +4,7 @@
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
#include <bits.h>
|
||||
#include <vm_config.h>
|
||||
#include <logmsg.h>
|
||||
#include <cat.h>
|
||||
@@ -103,6 +104,7 @@ bool sanitize_vm_config(void)
|
||||
ret = false;
|
||||
} else {
|
||||
vm_config->pcpu_bitmap = sos_pcpu_bitmap;
|
||||
vm_config->vcpu_num = bitmap_weight(sos_pcpu_bitmap);
|
||||
}
|
||||
break;
|
||||
case POST_LAUNCHED_VM:
|
||||
|
@@ -175,10 +175,11 @@ int32_t hcall_create_vm(struct acrn_vm *vm, uint64_t param)
|
||||
} else {
|
||||
/* return a relative vm_id from SOS view */
|
||||
cv.vmid = vmid_2_rel_vmid(vm->vm_id, vm_id);
|
||||
cv.vcpu_num = vm_config->vcpu_num;
|
||||
ret = 0;
|
||||
}
|
||||
|
||||
if (copy_to_gpa(vm, &cv.vmid, param, sizeof(cv.vmid)) != 0) {
|
||||
if (copy_to_gpa(vm, &cv, param, sizeof(cv)) != 0) {
|
||||
pr_err("%s: Unable copy param to vm\n", __func__);
|
||||
ret = -1;
|
||||
}
|
||||
|
@@ -96,6 +96,7 @@ struct acrn_vm_config {
|
||||
char name[MAX_VM_OS_NAME_LEN]; /* VM name identifier, useful for debug. */
|
||||
const uint8_t uuid[16]; /* UUID of the VM */
|
||||
uint64_t pcpu_bitmap; /* from pcpu bitmap, we could know VM core number */
|
||||
uint16_t vcpu_num; /* Number of vCPUs for the VM */
|
||||
uint64_t guest_flags; /* VM flags that we want to configure for guest
|
||||
* Now we have two flags:
|
||||
* GUEST_FLAG_SECURE_WORLD_ENABLED
|
||||
|
@@ -17,6 +17,7 @@ struct acrn_vm_config vm_configs[CONFIG_MAX_VM_NUM] = {
|
||||
/* fc836901-8685-4bc0-8b71-6e31dc36fa47 */
|
||||
.guest_flags = GUEST_FLAG_HIGHEST_SEVERITY,
|
||||
.pcpu_bitmap = VM0_CONFIG_PCPU_BITMAP,
|
||||
.vcpu_num = 1U,
|
||||
.clos = 0U,
|
||||
.memory = {
|
||||
.start_hpa = VM0_CONFIG_MEM_START_HPA,
|
||||
@@ -82,6 +83,7 @@ struct acrn_vm_config vm_configs[CONFIG_MAX_VM_NUM] = {
|
||||
.uuid = {0xd2U, 0x79U, 0x54U, 0x38U, 0x25U, 0xd6U, 0x11U, 0xe8U, \
|
||||
0x86U, 0x4eU, 0xcbU, 0x7aU, 0x18U, 0xb3U, 0x46U, 0x43U},
|
||||
/* d2795438-25d6-11e8-864e-cb7a18b34643 */
|
||||
.vcpu_num = 1U,
|
||||
.vuart[0] = {
|
||||
.type = VUART_LEGACY_PIO,
|
||||
.addr.port_base = COM1_BASE,
|
||||
|
@@ -47,6 +47,7 @@ struct acrn_vm_config vm_configs[CONFIG_MAX_VM_NUM] = {
|
||||
.uuid = {0xd2U, 0x79U, 0x54U, 0x38U, 0x25U, 0xd6U, 0x11U, 0xe8U, \
|
||||
0x86U, 0x4eU, 0xcbU, 0x7aU, 0x18U, 0xb3U, 0x46U, 0x43U},
|
||||
/* d2795438-25d6-11e8-864e-cb7a18b34643 */
|
||||
.vcpu_num = 1U,
|
||||
.vuart[0] = {
|
||||
.type = VUART_LEGACY_PIO,
|
||||
.addr.port_base = COM1_BASE,
|
||||
@@ -66,6 +67,7 @@ struct acrn_vm_config vm_configs[CONFIG_MAX_VM_NUM] = {
|
||||
|
||||
/* The hard RTVM must be launched as VM2 */
|
||||
.guest_flags = GUEST_FLAG_HIGHEST_SEVERITY,
|
||||
.vcpu_num = 1U,
|
||||
.vuart[0] = {
|
||||
.type = VUART_LEGACY_PIO,
|
||||
.addr.port_base = COM1_BASE,
|
||||
@@ -84,6 +86,7 @@ struct acrn_vm_config vm_configs[CONFIG_MAX_VM_NUM] = {
|
||||
.uuid = {0x38U, 0x15U, 0x88U, 0x21U, 0x52U, 0x08U, 0x40U, 0x05U, \
|
||||
0xb7U, 0x2aU, 0x8aU, 0x60U, 0x9eU, 0x41U, 0x90U, 0xd0U},
|
||||
/* 38158821-5208-4005-b72a-8a609e4190d0 */
|
||||
.vcpu_num = 1U,
|
||||
.vuart[0] = {
|
||||
.type = VUART_LEGACY_PIO,
|
||||
.addr.port_base = COM1_BASE,
|
||||
|
@@ -18,6 +18,7 @@ struct acrn_vm_config vm_configs[CONFIG_MAX_VM_NUM] = {
|
||||
0x81U, 0x09U, 0xf2U, 0x01U, 0xebU, 0xd6U, 0x1aU, 0x5eU},
|
||||
/* 26c5e0d8-8f8a-47d8-8109-f201ebd61a5e */
|
||||
.pcpu_bitmap = VM0_CONFIG_PCPU_BITMAP,
|
||||
.vcpu_num = 2U,
|
||||
.clos = 0U,
|
||||
.memory = {
|
||||
.start_hpa = VM0_CONFIG_MEM_START_HPA,
|
||||
@@ -56,6 +57,7 @@ struct acrn_vm_config vm_configs[CONFIG_MAX_VM_NUM] = {
|
||||
0xbcU, 0x58U, 0x76U, 0x05U, 0x83U, 0x7fU, 0x93U, 0x5eU},
|
||||
/* dd87ce08-66f9-473d-bc58-7605837f935e */
|
||||
.pcpu_bitmap = VM1_CONFIG_PCPU_BITMAP,
|
||||
.vcpu_num = 2U,
|
||||
.guest_flags = (GUEST_FLAG_RT | GUEST_FLAG_LAPIC_PASSTHROUGH),
|
||||
.clos = 0U,
|
||||
.memory = {
|
||||
|
@@ -46,6 +46,7 @@ struct acrn_vm_config vm_configs[CONFIG_MAX_VM_NUM] = {
|
||||
.uuid = {0xd2U, 0x79U, 0x54U, 0x38U, 0x25U, 0xd6U, 0x11U, 0xe8U, \
|
||||
0x86U, 0x4eU, 0xcbU, 0x7aU, 0x18U, 0xb3U, 0x46U, 0x43U},
|
||||
/* d2795438-25d6-11e8-864e-cb7a18b34643 */
|
||||
.vcpu_num = CONFIG_MAX_PCPU_NUM - CONFIG_MAX_KATA_VM_NUM - 1U,
|
||||
.vuart[0] = {
|
||||
.type = VUART_LEGACY_PIO,
|
||||
.addr.port_base = INVALID_COM_BASE,
|
||||
@@ -62,6 +63,7 @@ struct acrn_vm_config vm_configs[CONFIG_MAX_VM_NUM] = {
|
||||
.uuid = {0xa7U, 0xadU, 0xa5U, 0x06U, 0x1aU, 0xb0U, 0x4bU, 0x6bU, \
|
||||
0xa0U, 0xdaU, 0xe5U, 0x13U, 0xcaU, 0x9bU, 0x8cU, 0x2fU},
|
||||
/* a7ada506-1ab0-4b6b-a0da-e513ca9b8c2f */
|
||||
.vcpu_num = 1U,
|
||||
.vuart[0] = {
|
||||
.type = VUART_LEGACY_PIO,
|
||||
.addr.port_base = INVALID_COM_BASE,
|
||||
|
@@ -46,6 +46,7 @@ struct acrn_vm_config vm_configs[CONFIG_MAX_VM_NUM] = {
|
||||
.uuid = {0xd2U, 0x79U, 0x54U, 0x38U, 0x25U, 0xd6U, 0x11U, 0xe8U, \
|
||||
0x86U, 0x4eU, 0xcbU, 0x7aU, 0x18U, 0xb3U, 0x46U, 0x43U},
|
||||
/* d2795438-25d6-11e8-864e-cb7a18b34643 */
|
||||
.vcpu_num = 1U,
|
||||
.vuart[0] = {
|
||||
.type = VUART_LEGACY_PIO,
|
||||
.addr.port_base = INVALID_COM_BASE,
|
||||
@@ -61,6 +62,7 @@ struct acrn_vm_config vm_configs[CONFIG_MAX_VM_NUM] = {
|
||||
.uuid = {0x49U, 0x5aU, 0xe2U, 0xe5U, 0x26U, 0x03U, 0x4dU, 0x64U, \
|
||||
0xafU, 0x76U, 0xd4U, 0xbcU, 0x5aU, 0x8eU, 0xc0U, 0xe5U},
|
||||
/* 495ae2e5-2603-4d64-af76-d4bc5a8ec0e5 */
|
||||
.vcpu_num = 1U,
|
||||
.vuart[0] = {
|
||||
.type = VUART_LEGACY_PIO,
|
||||
.addr.port_base = INVALID_COM_BASE,
|
||||
@@ -76,6 +78,7 @@ struct acrn_vm_config vm_configs[CONFIG_MAX_VM_NUM] = {
|
||||
.uuid = {0x38U, 0x15U, 0x88U, 0x21U, 0x52U, 0x08U, 0x40U, 0x05U, \
|
||||
0xb7U, 0x2aU, 0x8aU, 0x60U, 0x9eU, 0x41U, 0x90U, 0xd0U},
|
||||
/* 38158821-5208-4005-b72a-8a609e4190d0 */
|
||||
.vcpu_num = 1U,
|
||||
.vuart[0] = {
|
||||
.type = VUART_LEGACY_PIO,
|
||||
.addr.port_base = INVALID_COM_BASE,
|
||||
|
Reference in New Issue
Block a user