From d9c302ba0c8a6167685395b1612d234dbe4ade26 Mon Sep 17 00:00:00 2001 From: Victor Sun Date: Sun, 22 Mar 2020 14:43:01 +0800 Subject: [PATCH] HV: init vm uuid and severity in macro Currently the vm uuid and severity is initilized separately in vm_config struct, developer need to take care both items carefuly otherwise hypervisor would have trouble with the configurations. Given the vm loader_order/uuid and severity are binded tightly, the patch merged these tree settings in one macro so that developer will have a simple interface to configure in vm_config struct. Tracked-On: #4616 Signed-off-by: Victor Sun Acked-by: Eddie Dong --- hypervisor/arch/x86/configs/vm_config.c | 2 +- hypervisor/include/arch/x86/vm_config.h | 27 +++++++++-- hypervisor/include/common/vm_uuids.h | 46 +++++++++++++++++++ .../scenarios/hybrid/vm_configurations.c | 18 ++------ .../scenarios/industry/vm_configurations.c | 23 +++------- .../logical_partition/vm_configurations.c | 10 +--- hypervisor/scenarios/sdc/vm_configurations.c | 24 +++------- hypervisor/scenarios/sdc2/vm_configurations.c | 32 ++++--------- 8 files changed, 95 insertions(+), 87 deletions(-) create mode 100644 hypervisor/include/common/vm_uuids.h diff --git a/hypervisor/arch/x86/configs/vm_config.c b/hypervisor/arch/x86/configs/vm_config.c index 20acdc9a5..dd58e09a1 100644 --- a/hypervisor/arch/x86/configs/vm_config.c +++ b/hypervisor/arch/x86/configs/vm_config.c @@ -11,7 +11,7 @@ #include #include -static uint8_t rtvm_uuid1[16] = RTVM_UUID1; +static uint8_t rtvm_uuid1[16] = POST_RTVM_UUID1; static uint8_t safety_vm_uuid1[16] = SAFETY_VM_UUID1; /* diff --git a/hypervisor/include/arch/x86/vm_config.h b/hypervisor/include/arch/x86/vm_config.h index 0728092ea..37caa7c3b 100644 --- a/hypervisor/include/arch/x86/vm_config.h +++ b/hypervisor/include/arch/x86/vm_config.h @@ -11,6 +11,7 @@ #include #include #include +#include #include #include @@ -26,11 +27,29 @@ #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 CONFIG_SOS_VM .load_order = SOS_VM, \ + .uuid = SOS_VM_UUID, \ + .severity = SEVERITY_SOS -#define SAFETY_VM_UUID1 {0xfcU, 0x83U, 0x69U, 0x01U, 0x86U, 0x85U, 0x4bU, 0xc0U, \ - 0x8bU, 0x71U, 0x6eU, 0x31U, 0xdcU, 0x36U, 0xfaU, 0x47U} +#define CONFIG_SAFETY_VM(idx) .load_order = PRE_LAUNCHED_VM, \ + .uuid = SAFETY_VM_UUID##idx, \ + .severity = SEVERITY_SAFETY_VM + +#define CONFIG_PRE_STD_VM(idx) .load_order = PRE_LAUNCHED_VM, \ + .uuid = PRE_STANDARD_VM_UUID##idx, \ + .severity = SEVERITY_STANDARD_VM + +#define CONFIG_POST_STD_VM(idx) .load_order = POST_LAUNCHED_VM, \ + .uuid = POST_STANDARD_VM_UUID##idx, \ + .severity = SEVERITY_STANDARD_VM + +#define CONFIG_POST_RT_VM(idx) .load_order = POST_LAUNCHED_VM, \ + .uuid = POST_RTVM_UUID##idx, \ + .severity = SEVERITY_RTVM + +#define CONFIG_KATA_VM(idx) .load_order = POST_LAUNCHED_VM, \ + .uuid = KATA_VM_UUID##idx, \ + .severity = SEVERITY_STANDARD_VM /* * PRE_LAUNCHED_VM is launched by ACRN hypervisor, with LAPIC_PT; diff --git a/hypervisor/include/common/vm_uuids.h b/hypervisor/include/common/vm_uuids.h new file mode 100644 index 000000000..8e951bebb --- /dev/null +++ b/hypervisor/include/common/vm_uuids.h @@ -0,0 +1,46 @@ +/* + * Copyright (C) 2020 Intel Corporation. All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#ifndef VM_UUIDS_H +#define VM_UUIDS_H + +/* dbbbd434-7a57-4216-a12c-2201f1ab0240 */ +#define SOS_VM_UUID {0xdbU, 0xbbU, 0xd4U, 0x34U, 0x7aU, 0x57U, 0x42U, 0x16U, \ + 0xa1U, 0x2cU, 0x22U, 0x01U, 0xf1U, 0xabU, 0x02U, 0x40U} + +/* fc836901-8685-4bc0-8b71-6e31dc36fa47 */ +#define SAFETY_VM_UUID1 {0xfcU, 0x83U, 0x69U, 0x01U, 0x86U, 0x85U, 0x4bU, 0xc0U, \ + 0x8bU, 0x71U, 0x6eU, 0x31U, 0xdcU, 0x36U, 0xfaU, 0x47U} + +/* 26c5e0d8-8f8a-47d8-8109-f201ebd61a5e */ +#define PRE_STANDARD_VM_UUID1 {0x26U, 0xc5U, 0xe0U, 0xd8U, 0x8fU, 0x8aU, 0x47U, 0xd8U, \ + 0x81U, 0x09U, 0xf2U, 0x01U, 0xebU, 0xd6U, 0x1aU, 0x5eU} + +/* dd87ce08-66f9-473d-bc58-7605837f935e */ +#define PRE_STANDARD_VM_UUID2 {0xddU, 0x87U, 0xceU, 0x08U, 0x66U, 0xf9U, 0x47U, 0x3dU, \ + 0xbcU, 0x58U, 0x76U, 0x05U, 0x83U, 0x7fU, 0x93U, 0x5eU} + +/* d2795438-25d6-11e8-864e-cb7a18b34643 */ +#define POST_STANDARD_VM_UUID1 {0xd2U, 0x79U, 0x54U, 0x38U, 0x25U, 0xd6U, 0x11U, 0xe8U, \ + 0x86U, 0x4eU, 0xcbU, 0x7aU, 0x18U, 0xb3U, 0x46U, 0x43U} + +/* 615db82a-e189-4b4f-8dbb-d321343e4ab3 */ +#define POST_STANDARD_VM_UUID2 {0x61U, 0x5dU, 0xb8U, 0x2aU, 0xe1U, 0x89U, 0x4bU, 0x4fU, \ + 0x8dU, 0xbbU, 0xd3U, 0x21U, 0x34U, 0x3eU, 0x4aU, 0xb3U} + +/* 38158821-5208-4005-b72a-8a609e4190d0 */ +#define POST_STANDARD_VM_UUID3 {0x38U, 0x15U, 0x88U, 0x21U, 0x52U, 0x08U, 0x40U, 0x05U, \ + 0xb7U, 0x2aU, 0x8aU, 0x60U, 0x9eU, 0x41U, 0x90U, 0xd0U} + +/* 495ae2e5-2603-4d64-af76-d4bc5a8ec0e5 */ +#define POST_RTVM_UUID1 {0x49U, 0x5aU, 0xe2U, 0xe5U, 0x26U, 0x03U, 0x4dU, 0x64U, \ + 0xafU, 0x76U, 0xd4U, 0xbcU, 0x5aU, 0x8eU, 0xc0U, 0xe5U} + +/* a7ada506-1ab0-4b6b-a0da-e513ca9b8c2f */ +#define KATA_VM_UUID1 {0xa7U, 0xadU, 0xa5U, 0x06U, 0x1aU, 0xb0U, 0x4bU, 0x6bU, \ + 0xa0U, 0xdaU, 0xe5U, 0x13U, 0xcaU, 0x9bU, 0x8cU, 0x2fU} + +#endif /* VM_UUIDS_H */ diff --git a/hypervisor/scenarios/hybrid/vm_configurations.c b/hypervisor/scenarios/hybrid/vm_configurations.c index 663285623..54d49eeb7 100644 --- a/hypervisor/scenarios/hybrid/vm_configurations.c +++ b/hypervisor/scenarios/hybrid/vm_configurations.c @@ -10,14 +10,11 @@ struct acrn_vm_config vm_configs[CONFIG_MAX_VM_NUM] = { { /* VM0 */ - .load_order = PRE_LAUNCHED_VM, + CONFIG_SAFETY_VM(1), .name = "ACRN PRE-LAUNCHED VM0", - /* fc836901-8685-4bc0-8b71-6e31dc36fa47 */ - .uuid = SAFETY_VM_UUID1, .guest_flags = 0UL, .vcpu_num = 1U, .vcpu_affinity = VM0_CONFIG_VCPU_AFFINITY, - .severity = SEVERITY_SAFETY_VM, .memory = { .start_hpa = VM0_CONFIG_MEM_START_HPA, .size = VM0_CONFIG_MEM_SIZE, @@ -44,14 +41,9 @@ struct acrn_vm_config vm_configs[CONFIG_MAX_VM_NUM] = { } }, { /* VM1 */ - .load_order = SOS_VM, + CONFIG_SOS_VM, .name = "ACRN SOS VM", - .uuid = {0xdbU, 0xbbU, 0xd4U, 0x34U, 0x7aU, 0x57U, 0x42U, 0x16U, \ - 0xa1U, 0x2cU, 0x22U, 0x01U, 0xf1U, 0xabU, 0x02U, 0x40U}, - /* dbbbd434-7a57-4216-a12c-2201f1ab0240 */ - .guest_flags = 0UL, - .severity = SEVERITY_SOS, .memory = { .start_hpa = 0UL, .size = CONFIG_SOS_RAM_SIZE, @@ -78,13 +70,9 @@ struct acrn_vm_config vm_configs[CONFIG_MAX_VM_NUM] = { .pci_devs = sos_pci_devs, }, { /* VM2 */ - .load_order = POST_LAUNCHED_VM, - .uuid = {0xd2U, 0x79U, 0x54U, 0x38U, 0x25U, 0xd6U, 0x11U, 0xe8U, \ - 0x86U, 0x4eU, 0xcbU, 0x7aU, 0x18U, 0xb3U, 0x46U, 0x43U}, - /* d2795438-25d6-11e8-864e-cb7a18b34643 */ + CONFIG_POST_STD_VM(1), .vcpu_num = 1U, .vcpu_affinity = VM2_CONFIG_VCPU_AFFINITY, - .severity = SEVERITY_STANDARD_VM, .vuart[0] = { .type = VUART_LEGACY_PIO, .addr.port_base = COM1_BASE, diff --git a/hypervisor/scenarios/industry/vm_configurations.c b/hypervisor/scenarios/industry/vm_configurations.c index 5210f43be..df1b921d2 100644 --- a/hypervisor/scenarios/industry/vm_configurations.c +++ b/hypervisor/scenarios/industry/vm_configurations.c @@ -9,14 +9,10 @@ #include struct acrn_vm_config vm_configs[CONFIG_MAX_VM_NUM] = { - { - .load_order = SOS_VM, + { /* VM0 */ + CONFIG_SOS_VM, .name = "ACRN SOS VM", - .uuid = {0xdbU, 0xbbU, 0xd4U, 0x34U, 0x7aU, 0x57U, 0x42U, 0x16U, \ - 0xa1U, 0x2cU, 0x22U, 0x01U, 0xf1U, 0xabU, 0x02U, 0x40U}, - /* dbbbd434-7a57-4216-a12c-2201f1ab0240 */ .guest_flags = 0UL, - .severity = SEVERITY_SOS, .clos = { 0U }, .memory = { .start_hpa = 0UL, @@ -43,14 +39,10 @@ struct acrn_vm_config vm_configs[CONFIG_MAX_VM_NUM] = { .pci_dev_num = SOS_EMULATED_PCI_DEV_NUM, .pci_devs = sos_pci_devs, }, - { - .load_order = POST_LAUNCHED_VM, - .uuid = {0xd2U, 0x79U, 0x54U, 0x38U, 0x25U, 0xd6U, 0x11U, 0xe8U, \ - 0x86U, 0x4eU, 0xcbU, 0x7aU, 0x18U, 0xb3U, 0x46U, 0x43U}, - /* d2795438-25d6-11e8-864e-cb7a18b34643 */ + { /* VM1 */ + CONFIG_POST_STD_VM(1), .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,15 +54,12 @@ struct acrn_vm_config vm_configs[CONFIG_MAX_VM_NUM] = { } }, - { - .load_order = POST_LAUNCHED_VM, - /* 495ae2e5-2603-4d64-af76-d4bc5a8ec0e5 */ - .uuid = RTVM_UUID1, + { /* VM2 */ + CONFIG_POST_RT_VM(1), /* The hard RTVM must be launched as VM2 */ .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, diff --git a/hypervisor/scenarios/logical_partition/vm_configurations.c b/hypervisor/scenarios/logical_partition/vm_configurations.c index 0f3cfb461..6a1b1b101 100644 --- a/hypervisor/scenarios/logical_partition/vm_configurations.c +++ b/hypervisor/scenarios/logical_partition/vm_configurations.c @@ -12,11 +12,8 @@ extern struct acrn_vm_pci_dev_config vm1_pci_devs[VM1_CONFIG_PCI_DEV_NUM]; struct acrn_vm_config vm_configs[CONFIG_MAX_VM_NUM] = { { /* VM0 */ - .load_order = PRE_LAUNCHED_VM, + CONFIG_PRE_STD_VM(1), .name = "ACRN PRE-LAUNCHED VM0", - .uuid = {0x26U, 0xc5U, 0xe0U, 0xd8U, 0x8fU, 0x8aU, 0x47U, 0xd8U, \ - 0x81U, 0x09U, 0xf2U, 0x01U, 0xebU, 0xd6U, 0x1aU, 0x5eU}, - /* 26c5e0d8-8f8a-47d8-8109-f201ebd61a5e */ .vcpu_num = 2U, .vcpu_affinity = VM0_CONFIG_VCPU_AFFINITY, .memory = { @@ -50,11 +47,8 @@ struct acrn_vm_config vm_configs[CONFIG_MAX_VM_NUM] = { .pci_devs = vm0_pci_devs, }, { /* VM1 */ - .load_order = PRE_LAUNCHED_VM, + CONFIG_PRE_STD_VM(2), .name = "ACRN PRE-LAUNCHED VM1", - .uuid = {0xddU, 0x87U, 0xceU, 0x08U, 0x66U, 0xf9U, 0x47U, 0x3dU, \ - 0xbcU, 0x58U, 0x76U, 0x05U, 0x83U, 0x7fU, 0x93U, 0x5eU}, - /* dd87ce08-66f9-473d-bc58-7605837f935e */ .vcpu_num = 2U, .vcpu_affinity = VM1_CONFIG_VCPU_AFFINITY, .guest_flags = (GUEST_FLAG_RT | GUEST_FLAG_LAPIC_PASSTHROUGH), diff --git a/hypervisor/scenarios/sdc/vm_configurations.c b/hypervisor/scenarios/sdc/vm_configurations.c index 56ffa9949..2570c45a1 100644 --- a/hypervisor/scenarios/sdc/vm_configurations.c +++ b/hypervisor/scenarios/sdc/vm_configurations.c @@ -9,16 +9,12 @@ #include struct acrn_vm_config vm_configs[CONFIG_MAX_VM_NUM] = { - { - .load_order = SOS_VM, + { /* VM0 */ + CONFIG_SOS_VM, .name = "ACRN SOS VM", - .uuid = {0xdbU, 0xbbU, 0xd4U, 0x34U, 0x7aU, 0x57U, 0x42U, 0x16U, \ - 0xa1U, 0x2cU, 0x22U, 0x01U, 0xf1U, 0xabU, 0x02U, 0x40U}, - /* dbbbd434-7a57-4216-a12c-2201f1ab0240 */ /* Allow SOS to reboot the host since there is supposed to be the highest severity guest */ .guest_flags = 0UL, - .severity = SEVERITY_SOS, .memory = { .start_hpa = 0UL, .size = CONFIG_SOS_RAM_SIZE, @@ -41,14 +37,10 @@ struct acrn_vm_config vm_configs[CONFIG_MAX_VM_NUM] = { .pci_dev_num = SOS_EMULATED_PCI_DEV_NUM, .pci_devs = sos_pci_devs, }, - { - .load_order = POST_LAUNCHED_VM, - .uuid = {0xd2U, 0x79U, 0x54U, 0x38U, 0x25U, 0xd6U, 0x11U, 0xe8U, \ - 0x86U, 0x4eU, 0xcbU, 0x7aU, 0x18U, 0xb3U, 0x46U, 0x43U}, - /* d2795438-25d6-11e8-864e-cb7a18b34643 */ + { /* VM1 */ + CONFIG_POST_STD_VM(1), .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, @@ -60,14 +52,10 @@ struct acrn_vm_config vm_configs[CONFIG_MAX_VM_NUM] = { }, #if CONFIG_MAX_KATA_VM_NUM > 0 - { - .load_order = POST_LAUNCHED_VM, - .uuid = {0xa7U, 0xadU, 0xa5U, 0x06U, 0x1aU, 0xb0U, 0x4bU, 0x6bU, \ - 0xa0U, 0xdaU, 0xe5U, 0x13U, 0xcaU, 0x9bU, 0x8cU, 0x2fU}, - /* a7ada506-1ab0-4b6b-a0da-e513ca9b8c2f */ + { /* VM2 */ + CONFIG_KATA_VM(1), .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, diff --git a/hypervisor/scenarios/sdc2/vm_configurations.c b/hypervisor/scenarios/sdc2/vm_configurations.c index 28506a42b..38b347e86 100644 --- a/hypervisor/scenarios/sdc2/vm_configurations.c +++ b/hypervisor/scenarios/sdc2/vm_configurations.c @@ -9,16 +9,12 @@ #include struct acrn_vm_config vm_configs[CONFIG_MAX_VM_NUM] = { - { - .load_order = SOS_VM, + { /* VM0 */ + CONFIG_SOS_VM, .name = "ACRN SOS VM", - .uuid = {0xdbU, 0xbbU, 0xd4U, 0x34U, 0x7aU, 0x57U, 0x42U, 0x16U, \ - 0xa1U, 0x2cU, 0x22U, 0x01U, 0xf1U, 0xabU, 0x02U, 0x40U}, - /* dbbbd434-7a57-4216-a12c-2201f1ab0240 */ /* Allow SOS to reboot the host since there is supposed to be the highest severity guest */ .guest_flags = 0UL, - .severity = SEVERITY_SOS, .memory = { .start_hpa = 0UL, .size = CONFIG_SOS_RAM_SIZE, @@ -41,14 +37,10 @@ struct acrn_vm_config vm_configs[CONFIG_MAX_VM_NUM] = { .pci_dev_num = SOS_EMULATED_PCI_DEV_NUM, .pci_devs = sos_pci_devs, }, - { - .load_order = POST_LAUNCHED_VM, - .uuid = {0xd2U, 0x79U, 0x54U, 0x38U, 0x25U, 0xd6U, 0x11U, 0xe8U, \ - 0x86U, 0x4eU, 0xcbU, 0x7aU, 0x18U, 0xb3U, 0x46U, 0x43U}, - /* d2795438-25d6-11e8-864e-cb7a18b34643 */ + { /* VM1 */ + CONFIG_POST_STD_VM(1), .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, @@ -59,14 +51,10 @@ struct acrn_vm_config vm_configs[CONFIG_MAX_VM_NUM] = { } }, - { - .load_order = POST_LAUNCHED_VM, - .uuid = {0x61U, 0x5dU, 0xb8U, 0x2aU, 0xe1U, 0x89U, 0x4bU, 0x4fU, \ - 0x8dU, 0xbbU, 0xd3U, 0x21U, 0x34U, 0x3eU, 0x4aU, 0xb3U}, - /* 615db82a-e189-4b4f-8dbb-d321343e4ab3 */ + { /* VM2 */ + CONFIG_POST_STD_VM(2), .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, @@ -77,14 +65,10 @@ struct acrn_vm_config vm_configs[CONFIG_MAX_VM_NUM] = { } }, - { - .load_order = POST_LAUNCHED_VM, - .uuid = {0x38U, 0x15U, 0x88U, 0x21U, 0x52U, 0x08U, 0x40U, 0x05U, \ - 0xb7U, 0x2aU, 0x8aU, 0x60U, 0x9eU, 0x41U, 0x90U, 0xd0U}, - /* 38158821-5208-4005-b72a-8a609e4190d0 */ + { /* VM3 */ + CONFIG_POST_STD_VM(3), .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,