mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-06-23 14:07:42 +00:00
vm: add severity for vm_config
Add severity definitions for different scenarios. The static guest severity is defined according to guest configurations. Also add sanity check to make sure the severity for all guests are correct. Tracked-On: #4270 Signed-off-by: Yin Fengwei <fengwei.yin@intel.com>
This commit is contained in:
parent
f7df43e7cd
commit
e5117bf19a
@ -10,6 +10,9 @@
|
||||
#include <cat.h>
|
||||
#include <pgtable.h>
|
||||
|
||||
static uint8_t rtvm_uuid1[16] = RTVM_UUID1;
|
||||
static uint8_t safety_vm_uuid1[16] = SAFETY_VM_UUID1;
|
||||
|
||||
/*
|
||||
* @pre vm_id < CONFIG_MAX_VM_NUM
|
||||
* @post return != NULL
|
||||
@ -40,6 +43,27 @@ bool vm_has_matched_uuid(uint16_t vmid, const uint8_t *uuid)
|
||||
|
||||
return (uuid_is_equal(vm_config->uuid, uuid));
|
||||
}
|
||||
/**
|
||||
* return true if the input uuid is for RTVM
|
||||
*
|
||||
* @pre vmid < CONFIG_MAX_VM_NUM
|
||||
*/
|
||||
static bool is_safety_vm_uuid(const uint8_t *uuid)
|
||||
{
|
||||
/* TODO: Extend to check more safety VM uuid if we have more than one safety VM. */
|
||||
return uuid_is_equal(uuid, safety_vm_uuid1);
|
||||
}
|
||||
|
||||
/**
|
||||
* return true if the input uuid is for RTVM
|
||||
*
|
||||
* @pre vmid < CONFIG_MAX_VM_NUM
|
||||
*/
|
||||
static bool is_rtvm_uuid(const uint8_t *uuid)
|
||||
{
|
||||
/* TODO: Extend to check more rtvm uuid if we have more than one RTVM. */
|
||||
return uuid_is_equal(uuid, rtvm_uuid1);
|
||||
}
|
||||
|
||||
/**
|
||||
* return true if no UUID collision is found in vm configs array start from vm_configs[vm_id]
|
||||
@ -108,7 +132,9 @@ bool sanitize_vm_config(void)
|
||||
} else if (((vm_config->guest_flags & GUEST_FLAG_LAPIC_PASSTHROUGH) != 0U)
|
||||
&& ((vm_config->guest_flags & GUEST_FLAG_RT) == 0U)) {
|
||||
ret = false;
|
||||
}else if (vm_config->epc.size != 0UL) {
|
||||
} else if (vm_config->epc.size != 0UL) {
|
||||
ret = false;
|
||||
} else if (is_safety_vm_uuid(vm_config->uuid) && (vm_config->severity != (uint8_t)SEVERITY_SAFETY_VM)) {
|
||||
ret = false;
|
||||
} else {
|
||||
pre_launch_pcpu_bitmap |= vm_pcpu_bitmap;
|
||||
@ -119,6 +145,8 @@ bool sanitize_vm_config(void)
|
||||
sos_pcpu_bitmap ^= pre_launch_pcpu_bitmap;
|
||||
if ((sos_pcpu_bitmap == 0U) || ((vm_config->guest_flags & GUEST_FLAG_LAPIC_PASSTHROUGH) != 0U)) {
|
||||
ret = false;
|
||||
} else if (vm_config->severity != (uint8_t)SEVERITY_SOS) {
|
||||
ret = false;
|
||||
} else {
|
||||
vm_config->vcpu_num = bitmap_weight(sos_pcpu_bitmap);
|
||||
for (vcpu_id = 0U; vcpu_id < vm_config->vcpu_num; vcpu_id++) {
|
||||
@ -133,6 +161,22 @@ bool sanitize_vm_config(void)
|
||||
pr_err("%s: Post-launch VM has no pcpus or share pcpu with Pre-launch VM!", __func__);
|
||||
ret = false;
|
||||
}
|
||||
|
||||
if ((vm_config->severity == (uint8_t)SEVERITY_SAFETY_VM) ||
|
||||
(vm_config->severity == (uint8_t)SEVERITY_SOS)) {
|
||||
ret = false;
|
||||
}
|
||||
|
||||
/* VM with RTVM uuid must have RTVM severity */
|
||||
if (is_rtvm_uuid(vm_config->uuid) && (vm_config->severity != (uint8_t)SEVERITY_RTVM)) {
|
||||
ret = false;
|
||||
}
|
||||
|
||||
/* VM WITHOUT RTVM uuid must NOT have RTVM severity */
|
||||
if (!is_rtvm_uuid(vm_config->uuid) && (vm_config->severity == (uint8_t)SEVERITY_RTVM)) {
|
||||
ret = false;
|
||||
}
|
||||
|
||||
break;
|
||||
default:
|
||||
/* Nothing to do for a unknown VM, break directly. */
|
||||
|
@ -24,6 +24,12 @@
|
||||
#define PCI_DEV_TYPE_HVEMUL (1U << 1U)
|
||||
#define PCI_DEV_TYPE_SOSEMUL (1U << 2U)
|
||||
|
||||
#define RTVM_UUID1 {0x49U, 0x5aU, 0xe2U, 0xe5U, 0x26U, 0x03U, 0x4dU, 0x64U, \
|
||||
0xafU, 0x76U, 0xd4U, 0xbcU, 0x5aU, 0x8eU, 0xc0U, 0xe5U}
|
||||
|
||||
#define SAFETY_VM_UUID1 {0xfcU, 0x83U, 0x69U, 0x01U, 0x86U, 0x85U, 0x4bU, 0xc0U, \
|
||||
0x8bU, 0x71U, 0x6eU, 0x31U, 0xdcU, 0x36U, 0xfaU, 0x47U}
|
||||
|
||||
/*
|
||||
* PRE_LAUNCHED_VM is launched by ACRN hypervisor, with LAPIC_PT;
|
||||
* SOS_VM is launched by ACRN hypervisor, without LAPIC_PT;
|
||||
@ -35,6 +41,14 @@ enum acrn_vm_load_order {
|
||||
POST_LAUNCHED_VM /* Launched by Devicemodel in SOS_VM */
|
||||
};
|
||||
|
||||
/* ACRN guest severity */
|
||||
enum acrn_vm_severity {
|
||||
SEVERITY_SAFETY_VM = 0x40U,
|
||||
SEVERITY_RTVM = 0x30U,
|
||||
SEVERITY_SOS = 0x20U,
|
||||
SEVERITY_STANDARD_VM = 0x10U,
|
||||
};
|
||||
|
||||
struct acrn_vm_mem_config {
|
||||
uint64_t start_hpa; /* the start HPA of VM memory configuration, for pre-launched VMs only */
|
||||
uint64_t size; /* VM memory size configuration */
|
||||
@ -99,6 +113,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 */
|
||||
uint16_t vcpu_num; /* Number of vCPUs for the VM */
|
||||
uint8_t severity; /* severity of the VM */
|
||||
|
||||
uint64_t vcpu_affinity[MAX_VCPUS_PER_VM];/* bitmaps for vCPUs' affinity */
|
||||
uint64_t guest_flags; /* VM flags that we want to configure for guest
|
||||
|
@ -12,13 +12,13 @@ struct acrn_vm_config vm_configs[CONFIG_MAX_VM_NUM] = {
|
||||
{ /* VM0 */
|
||||
.load_order = PRE_LAUNCHED_VM,
|
||||
.name = "ACRN PRE-LAUNCHED VM0",
|
||||
.uuid = {0xfcU, 0x83U, 0x69U, 0x01U, 0x86U, 0x85U, 0x4bU, 0xc0U, \
|
||||
0x8bU, 0x71U, 0x6eU, 0x31U, 0xdcU, 0x36U, 0xfaU, 0x47U},
|
||||
/* fc836901-8685-4bc0-8b71-6e31dc36fa47 */
|
||||
.guest_flags = GUEST_FLAG_HIGHEST_SEVERITY,
|
||||
/* fc836901-8685-4bc0-8b71-6e31dc36fa47 */
|
||||
.uuid = SAFETY_VM_UUID1,
|
||||
.guest_flags = 0UL,
|
||||
.vcpu_num = 1U,
|
||||
.vcpu_affinity = VM0_CONFIG_VCPU_AFFINITY,
|
||||
.clos = 0U,
|
||||
.severity = SEVERITY_SAFETY_VM,
|
||||
.memory = {
|
||||
.start_hpa = VM0_CONFIG_MEM_START_HPA,
|
||||
.size = VM0_CONFIG_MEM_SIZE,
|
||||
@ -53,6 +53,7 @@ struct acrn_vm_config vm_configs[CONFIG_MAX_VM_NUM] = {
|
||||
|
||||
.guest_flags = 0UL,
|
||||
.clos = 0U,
|
||||
.severity = SEVERITY_SOS,
|
||||
.memory = {
|
||||
.start_hpa = 0UL,
|
||||
.size = CONFIG_SOS_RAM_SIZE,
|
||||
@ -85,6 +86,7 @@ struct acrn_vm_config vm_configs[CONFIG_MAX_VM_NUM] = {
|
||||
/* d2795438-25d6-11e8-864e-cb7a18b34643 */
|
||||
.vcpu_num = 1U,
|
||||
.vcpu_affinity = VM2_CONFIG_VCPU_AFFINITY,
|
||||
.severity = SEVERITY_STANDARD_VM,
|
||||
.vuart[0] = {
|
||||
.type = VUART_LEGACY_PIO,
|
||||
.addr.port_base = COM1_BASE,
|
||||
|
@ -17,6 +17,7 @@ struct acrn_vm_config vm_configs[CONFIG_MAX_VM_NUM] = {
|
||||
/* dbbbd434-7a57-4216-a12c-2201f1ab0240 */
|
||||
.guest_flags = 0UL,
|
||||
.clos = 0U,
|
||||
.severity = SEVERITY_SOS,
|
||||
.memory = {
|
||||
.start_hpa = 0UL,
|
||||
.size = CONFIG_SOS_RAM_SIZE,
|
||||
@ -49,6 +50,7 @@ struct acrn_vm_config vm_configs[CONFIG_MAX_VM_NUM] = {
|
||||
/* d2795438-25d6-11e8-864e-cb7a18b34643 */
|
||||
.vcpu_num = 1U,
|
||||
.vcpu_affinity = VM1_CONFIG_VCPU_AFFINITY,
|
||||
.severity = SEVERITY_STANDARD_VM,
|
||||
.vuart[0] = {
|
||||
.type = VUART_LEGACY_PIO,
|
||||
.addr.port_base = COM1_BASE,
|
||||
@ -62,14 +64,13 @@ struct acrn_vm_config vm_configs[CONFIG_MAX_VM_NUM] = {
|
||||
},
|
||||
{
|
||||
.load_order = POST_LAUNCHED_VM,
|
||||
.uuid = {0x49U, 0x5aU, 0xe2U, 0xe5U, 0x26U, 0x03U, 0x4dU, 0x64U, \
|
||||
0xafU, 0x76U, 0xd4U, 0xbcU, 0x5aU, 0x8eU, 0xc0U, 0xe5U},
|
||||
/* 495ae2e5-2603-4d64-af76-d4bc5a8ec0e5 */
|
||||
|
||||
/* 495ae2e5-2603-4d64-af76-d4bc5a8ec0e5 */
|
||||
.uuid = RTVM_UUID1,
|
||||
/* The hard RTVM must be launched as VM2 */
|
||||
.guest_flags = GUEST_FLAG_HIGHEST_SEVERITY,
|
||||
.guest_flags = 0UL,
|
||||
.vcpu_num = 2U,
|
||||
.vcpu_affinity = VM2_CONFIG_VCPU_AFFINITY,
|
||||
.severity = SEVERITY_RTVM,
|
||||
.vuart[0] = {
|
||||
.type = VUART_LEGACY_PIO,
|
||||
.addr.port_base = COM1_BASE,
|
||||
|
@ -17,8 +17,9 @@ struct acrn_vm_config vm_configs[CONFIG_MAX_VM_NUM] = {
|
||||
/* dbbbd434-7a57-4216-a12c-2201f1ab0240 */
|
||||
|
||||
/* Allow SOS to reboot the host since there is supposed to be the highest severity guest */
|
||||
.guest_flags = GUEST_FLAG_HIGHEST_SEVERITY,
|
||||
.guest_flags = 0UL,
|
||||
.clos = 0U,
|
||||
.severity = SEVERITY_SOS,
|
||||
.memory = {
|
||||
.start_hpa = 0UL,
|
||||
.size = CONFIG_SOS_RAM_SIZE,
|
||||
@ -48,6 +49,7 @@ struct acrn_vm_config vm_configs[CONFIG_MAX_VM_NUM] = {
|
||||
/* d2795438-25d6-11e8-864e-cb7a18b34643 */
|
||||
.vcpu_num = MAX_PCPU_NUM - CONFIG_MAX_KATA_VM_NUM - 1U,
|
||||
.vcpu_affinity = VM1_CONFIG_VCPU_AFFINITY,
|
||||
.severity = SEVERITY_STANDARD_VM,
|
||||
.vuart[0] = {
|
||||
.type = VUART_LEGACY_PIO,
|
||||
.addr.port_base = INVALID_COM_BASE,
|
||||
@ -66,6 +68,7 @@ struct acrn_vm_config vm_configs[CONFIG_MAX_VM_NUM] = {
|
||||
/* a7ada506-1ab0-4b6b-a0da-e513ca9b8c2f */
|
||||
.vcpu_num = 1U,
|
||||
.vcpu_affinity = VM2_CONFIG_VCPU_AFFINITY,
|
||||
.severity = SEVERITY_STANDARD_VM,
|
||||
.vuart[0] = {
|
||||
.type = VUART_LEGACY_PIO,
|
||||
.addr.port_base = INVALID_COM_BASE,
|
||||
|
@ -17,8 +17,9 @@ struct acrn_vm_config vm_configs[CONFIG_MAX_VM_NUM] = {
|
||||
/* dbbbd434-7a57-4216-a12c-2201f1ab0240 */
|
||||
|
||||
/* Allow SOS to reboot the host since there is supposed to be the highest severity guest */
|
||||
.guest_flags = GUEST_FLAG_HIGHEST_SEVERITY,
|
||||
.guest_flags = 0UL,
|
||||
.clos = 0U,
|
||||
.severity = SEVERITY_SOS,
|
||||
.memory = {
|
||||
.start_hpa = 0UL,
|
||||
.size = CONFIG_SOS_RAM_SIZE,
|
||||
@ -48,6 +49,7 @@ struct acrn_vm_config vm_configs[CONFIG_MAX_VM_NUM] = {
|
||||
/* d2795438-25d6-11e8-864e-cb7a18b34643 */
|
||||
.vcpu_num = 1U,
|
||||
.vcpu_affinity = VM1_CONFIG_VCPU_AFFINITY,
|
||||
.severity = SEVERITY_STANDARD_VM,
|
||||
.vuart[0] = {
|
||||
.type = VUART_LEGACY_PIO,
|
||||
.addr.port_base = INVALID_COM_BASE,
|
||||
@ -65,6 +67,7 @@ struct acrn_vm_config vm_configs[CONFIG_MAX_VM_NUM] = {
|
||||
/* 495ae2e5-2603-4d64-af76-d4bc5a8ec0e5 */
|
||||
.vcpu_num = 1U,
|
||||
.vcpu_affinity = VM2_CONFIG_VCPU_AFFINITY,
|
||||
.severity = SEVERITY_STANDARD_VM,
|
||||
.vuart[0] = {
|
||||
.type = VUART_LEGACY_PIO,
|
||||
.addr.port_base = INVALID_COM_BASE,
|
||||
@ -82,6 +85,7 @@ struct acrn_vm_config vm_configs[CONFIG_MAX_VM_NUM] = {
|
||||
/* 38158821-5208-4005-b72a-8a609e4190d0 */
|
||||
.vcpu_num = 1U,
|
||||
.vcpu_affinity = VM3_CONFIG_VCPU_AFFINITY,
|
||||
.severity = SEVERITY_STANDARD_VM,
|
||||
.vuart[0] = {
|
||||
.type = VUART_LEGACY_PIO,
|
||||
.addr.port_base = INVALID_COM_BASE,
|
||||
|
Loading…
Reference in New Issue
Block a user