Skip to content

Commit d9c302b

Browse files
jsun26intelwenlingz
authored andcommitted
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 <victor.sun@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
1 parent b08dbd4 commit d9c302b

File tree

8 files changed

+95
-87
lines changed

8 files changed

+95
-87
lines changed

hypervisor/arch/x86/configs/vm_config.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#include <pgtable.h>
1212
#include <vuart.h>
1313

14-
static uint8_t rtvm_uuid1[16] = RTVM_UUID1;
14+
static uint8_t rtvm_uuid1[16] = POST_RTVM_UUID1;
1515
static uint8_t safety_vm_uuid1[16] = SAFETY_VM_UUID1;
1616

1717
/*

hypervisor/include/arch/x86/vm_config.h

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <pci.h>
1212
#include <boot.h>
1313
#include <acrn_common.h>
14+
#include <vm_uuids.h>
1415
#include <vm_configurations.h>
1516
#include <sgx.h>
1617

@@ -26,11 +27,29 @@
2627
#define PCI_DEV_TYPE_HVEMUL (1U << 1U)
2728
#define PCI_DEV_TYPE_SOSEMUL (1U << 2U)
2829

29-
#define RTVM_UUID1 {0x49U, 0x5aU, 0xe2U, 0xe5U, 0x26U, 0x03U, 0x4dU, 0x64U, \
30-
0xafU, 0x76U, 0xd4U, 0xbcU, 0x5aU, 0x8eU, 0xc0U, 0xe5U}
30+
#define CONFIG_SOS_VM .load_order = SOS_VM, \
31+
.uuid = SOS_VM_UUID, \
32+
.severity = SEVERITY_SOS
3133

32-
#define SAFETY_VM_UUID1 {0xfcU, 0x83U, 0x69U, 0x01U, 0x86U, 0x85U, 0x4bU, 0xc0U, \
33-
0x8bU, 0x71U, 0x6eU, 0x31U, 0xdcU, 0x36U, 0xfaU, 0x47U}
34+
#define CONFIG_SAFETY_VM(idx) .load_order = PRE_LAUNCHED_VM, \
35+
.uuid = SAFETY_VM_UUID##idx, \
36+
.severity = SEVERITY_SAFETY_VM
37+
38+
#define CONFIG_PRE_STD_VM(idx) .load_order = PRE_LAUNCHED_VM, \
39+
.uuid = PRE_STANDARD_VM_UUID##idx, \
40+
.severity = SEVERITY_STANDARD_VM
41+
42+
#define CONFIG_POST_STD_VM(idx) .load_order = POST_LAUNCHED_VM, \
43+
.uuid = POST_STANDARD_VM_UUID##idx, \
44+
.severity = SEVERITY_STANDARD_VM
45+
46+
#define CONFIG_POST_RT_VM(idx) .load_order = POST_LAUNCHED_VM, \
47+
.uuid = POST_RTVM_UUID##idx, \
48+
.severity = SEVERITY_RTVM
49+
50+
#define CONFIG_KATA_VM(idx) .load_order = POST_LAUNCHED_VM, \
51+
.uuid = KATA_VM_UUID##idx, \
52+
.severity = SEVERITY_STANDARD_VM
3453

3554
/*
3655
* PRE_LAUNCHED_VM is launched by ACRN hypervisor, with LAPIC_PT;

hypervisor/include/common/vm_uuids.h

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/*
2+
* Copyright (C) 2020 Intel Corporation. All rights reserved.
3+
*
4+
* SPDX-License-Identifier: BSD-3-Clause
5+
*/
6+
7+
#ifndef VM_UUIDS_H
8+
#define VM_UUIDS_H
9+
10+
/* dbbbd434-7a57-4216-a12c-2201f1ab0240 */
11+
#define SOS_VM_UUID {0xdbU, 0xbbU, 0xd4U, 0x34U, 0x7aU, 0x57U, 0x42U, 0x16U, \
12+
0xa1U, 0x2cU, 0x22U, 0x01U, 0xf1U, 0xabU, 0x02U, 0x40U}
13+
14+
/* fc836901-8685-4bc0-8b71-6e31dc36fa47 */
15+
#define SAFETY_VM_UUID1 {0xfcU, 0x83U, 0x69U, 0x01U, 0x86U, 0x85U, 0x4bU, 0xc0U, \
16+
0x8bU, 0x71U, 0x6eU, 0x31U, 0xdcU, 0x36U, 0xfaU, 0x47U}
17+
18+
/* 26c5e0d8-8f8a-47d8-8109-f201ebd61a5e */
19+
#define PRE_STANDARD_VM_UUID1 {0x26U, 0xc5U, 0xe0U, 0xd8U, 0x8fU, 0x8aU, 0x47U, 0xd8U, \
20+
0x81U, 0x09U, 0xf2U, 0x01U, 0xebU, 0xd6U, 0x1aU, 0x5eU}
21+
22+
/* dd87ce08-66f9-473d-bc58-7605837f935e */
23+
#define PRE_STANDARD_VM_UUID2 {0xddU, 0x87U, 0xceU, 0x08U, 0x66U, 0xf9U, 0x47U, 0x3dU, \
24+
0xbcU, 0x58U, 0x76U, 0x05U, 0x83U, 0x7fU, 0x93U, 0x5eU}
25+
26+
/* d2795438-25d6-11e8-864e-cb7a18b34643 */
27+
#define POST_STANDARD_VM_UUID1 {0xd2U, 0x79U, 0x54U, 0x38U, 0x25U, 0xd6U, 0x11U, 0xe8U, \
28+
0x86U, 0x4eU, 0xcbU, 0x7aU, 0x18U, 0xb3U, 0x46U, 0x43U}
29+
30+
/* 615db82a-e189-4b4f-8dbb-d321343e4ab3 */
31+
#define POST_STANDARD_VM_UUID2 {0x61U, 0x5dU, 0xb8U, 0x2aU, 0xe1U, 0x89U, 0x4bU, 0x4fU, \
32+
0x8dU, 0xbbU, 0xd3U, 0x21U, 0x34U, 0x3eU, 0x4aU, 0xb3U}
33+
34+
/* 38158821-5208-4005-b72a-8a609e4190d0 */
35+
#define POST_STANDARD_VM_UUID3 {0x38U, 0x15U, 0x88U, 0x21U, 0x52U, 0x08U, 0x40U, 0x05U, \
36+
0xb7U, 0x2aU, 0x8aU, 0x60U, 0x9eU, 0x41U, 0x90U, 0xd0U}
37+
38+
/* 495ae2e5-2603-4d64-af76-d4bc5a8ec0e5 */
39+
#define POST_RTVM_UUID1 {0x49U, 0x5aU, 0xe2U, 0xe5U, 0x26U, 0x03U, 0x4dU, 0x64U, \
40+
0xafU, 0x76U, 0xd4U, 0xbcU, 0x5aU, 0x8eU, 0xc0U, 0xe5U}
41+
42+
/* a7ada506-1ab0-4b6b-a0da-e513ca9b8c2f */
43+
#define KATA_VM_UUID1 {0xa7U, 0xadU, 0xa5U, 0x06U, 0x1aU, 0xb0U, 0x4bU, 0x6bU, \
44+
0xa0U, 0xdaU, 0xe5U, 0x13U, 0xcaU, 0x9bU, 0x8cU, 0x2fU}
45+
46+
#endif /* VM_UUIDS_H */

hypervisor/scenarios/hybrid/vm_configurations.c

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,11 @@
1010

1111
struct acrn_vm_config vm_configs[CONFIG_MAX_VM_NUM] = {
1212
{ /* VM0 */
13-
.load_order = PRE_LAUNCHED_VM,
13+
CONFIG_SAFETY_VM(1),
1414
.name = "ACRN PRE-LAUNCHED VM0",
15-
/* fc836901-8685-4bc0-8b71-6e31dc36fa47 */
16-
.uuid = SAFETY_VM_UUID1,
1715
.guest_flags = 0UL,
1816
.vcpu_num = 1U,
1917
.vcpu_affinity = VM0_CONFIG_VCPU_AFFINITY,
20-
.severity = SEVERITY_SAFETY_VM,
2118
.memory = {
2219
.start_hpa = VM0_CONFIG_MEM_START_HPA,
2320
.size = VM0_CONFIG_MEM_SIZE,
@@ -44,14 +41,9 @@ struct acrn_vm_config vm_configs[CONFIG_MAX_VM_NUM] = {
4441
}
4542
},
4643
{ /* VM1 */
47-
.load_order = SOS_VM,
44+
CONFIG_SOS_VM,
4845
.name = "ACRN SOS VM",
49-
.uuid = {0xdbU, 0xbbU, 0xd4U, 0x34U, 0x7aU, 0x57U, 0x42U, 0x16U, \
50-
0xa1U, 0x2cU, 0x22U, 0x01U, 0xf1U, 0xabU, 0x02U, 0x40U},
51-
/* dbbbd434-7a57-4216-a12c-2201f1ab0240 */
52-
5346
.guest_flags = 0UL,
54-
.severity = SEVERITY_SOS,
5547
.memory = {
5648
.start_hpa = 0UL,
5749
.size = CONFIG_SOS_RAM_SIZE,
@@ -78,13 +70,9 @@ struct acrn_vm_config vm_configs[CONFIG_MAX_VM_NUM] = {
7870
.pci_devs = sos_pci_devs,
7971
},
8072
{ /* VM2 */
81-
.load_order = POST_LAUNCHED_VM,
82-
.uuid = {0xd2U, 0x79U, 0x54U, 0x38U, 0x25U, 0xd6U, 0x11U, 0xe8U, \
83-
0x86U, 0x4eU, 0xcbU, 0x7aU, 0x18U, 0xb3U, 0x46U, 0x43U},
84-
/* d2795438-25d6-11e8-864e-cb7a18b34643 */
73+
CONFIG_POST_STD_VM(1),
8574
.vcpu_num = 1U,
8675
.vcpu_affinity = VM2_CONFIG_VCPU_AFFINITY,
87-
.severity = SEVERITY_STANDARD_VM,
8876
.vuart[0] = {
8977
.type = VUART_LEGACY_PIO,
9078
.addr.port_base = COM1_BASE,

hypervisor/scenarios/industry/vm_configurations.c

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,10 @@
99
#include <pci_dev.h>
1010

1111
struct acrn_vm_config vm_configs[CONFIG_MAX_VM_NUM] = {
12-
{
13-
.load_order = SOS_VM,
12+
{ /* VM0 */
13+
CONFIG_SOS_VM,
1414
.name = "ACRN SOS VM",
15-
.uuid = {0xdbU, 0xbbU, 0xd4U, 0x34U, 0x7aU, 0x57U, 0x42U, 0x16U, \
16-
0xa1U, 0x2cU, 0x22U, 0x01U, 0xf1U, 0xabU, 0x02U, 0x40U},
17-
/* dbbbd434-7a57-4216-a12c-2201f1ab0240 */
1815
.guest_flags = 0UL,
19-
.severity = SEVERITY_SOS,
2016
.clos = { 0U },
2117
.memory = {
2218
.start_hpa = 0UL,
@@ -43,14 +39,10 @@ struct acrn_vm_config vm_configs[CONFIG_MAX_VM_NUM] = {
4339
.pci_dev_num = SOS_EMULATED_PCI_DEV_NUM,
4440
.pci_devs = sos_pci_devs,
4541
},
46-
{
47-
.load_order = POST_LAUNCHED_VM,
48-
.uuid = {0xd2U, 0x79U, 0x54U, 0x38U, 0x25U, 0xd6U, 0x11U, 0xe8U, \
49-
0x86U, 0x4eU, 0xcbU, 0x7aU, 0x18U, 0xb3U, 0x46U, 0x43U},
50-
/* d2795438-25d6-11e8-864e-cb7a18b34643 */
42+
{ /* VM1 */
43+
CONFIG_POST_STD_VM(1),
5144
.vcpu_num = 1U,
5245
.vcpu_affinity = VM1_CONFIG_VCPU_AFFINITY,
53-
.severity = SEVERITY_STANDARD_VM,
5446
.vuart[0] = {
5547
.type = VUART_LEGACY_PIO,
5648
.addr.port_base = COM1_BASE,
@@ -62,15 +54,12 @@ struct acrn_vm_config vm_configs[CONFIG_MAX_VM_NUM] = {
6254
}
6355

6456
},
65-
{
66-
.load_order = POST_LAUNCHED_VM,
67-
/* 495ae2e5-2603-4d64-af76-d4bc5a8ec0e5 */
68-
.uuid = RTVM_UUID1,
57+
{ /* VM2 */
58+
CONFIG_POST_RT_VM(1),
6959
/* The hard RTVM must be launched as VM2 */
7060
.guest_flags = 0UL,
7161
.vcpu_num = 2U,
7262
.vcpu_affinity = VM2_CONFIG_VCPU_AFFINITY,
73-
.severity = SEVERITY_RTVM,
7463
.vuart[0] = {
7564
.type = VUART_LEGACY_PIO,
7665
.addr.port_base = COM1_BASE,

hypervisor/scenarios/logical_partition/vm_configurations.c

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,8 @@ extern struct acrn_vm_pci_dev_config vm1_pci_devs[VM1_CONFIG_PCI_DEV_NUM];
1212

1313
struct acrn_vm_config vm_configs[CONFIG_MAX_VM_NUM] = {
1414
{ /* VM0 */
15-
.load_order = PRE_LAUNCHED_VM,
15+
CONFIG_PRE_STD_VM(1),
1616
.name = "ACRN PRE-LAUNCHED VM0",
17-
.uuid = {0x26U, 0xc5U, 0xe0U, 0xd8U, 0x8fU, 0x8aU, 0x47U, 0xd8U, \
18-
0x81U, 0x09U, 0xf2U, 0x01U, 0xebU, 0xd6U, 0x1aU, 0x5eU},
19-
/* 26c5e0d8-8f8a-47d8-8109-f201ebd61a5e */
2017
.vcpu_num = 2U,
2118
.vcpu_affinity = VM0_CONFIG_VCPU_AFFINITY,
2219
.memory = {
@@ -50,11 +47,8 @@ struct acrn_vm_config vm_configs[CONFIG_MAX_VM_NUM] = {
5047
.pci_devs = vm0_pci_devs,
5148
},
5249
{ /* VM1 */
53-
.load_order = PRE_LAUNCHED_VM,
50+
CONFIG_PRE_STD_VM(2),
5451
.name = "ACRN PRE-LAUNCHED VM1",
55-
.uuid = {0xddU, 0x87U, 0xceU, 0x08U, 0x66U, 0xf9U, 0x47U, 0x3dU, \
56-
0xbcU, 0x58U, 0x76U, 0x05U, 0x83U, 0x7fU, 0x93U, 0x5eU},
57-
/* dd87ce08-66f9-473d-bc58-7605837f935e */
5852
.vcpu_num = 2U,
5953
.vcpu_affinity = VM1_CONFIG_VCPU_AFFINITY,
6054
.guest_flags = (GUEST_FLAG_RT | GUEST_FLAG_LAPIC_PASSTHROUGH),

hypervisor/scenarios/sdc/vm_configurations.c

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,12 @@
99
#include <pci_dev.h>
1010

1111
struct acrn_vm_config vm_configs[CONFIG_MAX_VM_NUM] = {
12-
{
13-
.load_order = SOS_VM,
12+
{ /* VM0 */
13+
CONFIG_SOS_VM,
1414
.name = "ACRN SOS VM",
15-
.uuid = {0xdbU, 0xbbU, 0xd4U, 0x34U, 0x7aU, 0x57U, 0x42U, 0x16U, \
16-
0xa1U, 0x2cU, 0x22U, 0x01U, 0xf1U, 0xabU, 0x02U, 0x40U},
17-
/* dbbbd434-7a57-4216-a12c-2201f1ab0240 */
1815

1916
/* Allow SOS to reboot the host since there is supposed to be the highest severity guest */
2017
.guest_flags = 0UL,
21-
.severity = SEVERITY_SOS,
2218
.memory = {
2319
.start_hpa = 0UL,
2420
.size = CONFIG_SOS_RAM_SIZE,
@@ -41,14 +37,10 @@ struct acrn_vm_config vm_configs[CONFIG_MAX_VM_NUM] = {
4137
.pci_dev_num = SOS_EMULATED_PCI_DEV_NUM,
4238
.pci_devs = sos_pci_devs,
4339
},
44-
{
45-
.load_order = POST_LAUNCHED_VM,
46-
.uuid = {0xd2U, 0x79U, 0x54U, 0x38U, 0x25U, 0xd6U, 0x11U, 0xe8U, \
47-
0x86U, 0x4eU, 0xcbU, 0x7aU, 0x18U, 0xb3U, 0x46U, 0x43U},
48-
/* d2795438-25d6-11e8-864e-cb7a18b34643 */
40+
{ /* VM1 */
41+
CONFIG_POST_STD_VM(1),
4942
.vcpu_num = MAX_PCPU_NUM - CONFIG_MAX_KATA_VM_NUM - 1U,
5043
.vcpu_affinity = VM1_CONFIG_VCPU_AFFINITY,
51-
.severity = SEVERITY_STANDARD_VM,
5244
.vuart[0] = {
5345
.type = VUART_LEGACY_PIO,
5446
.addr.port_base = INVALID_COM_BASE,
@@ -60,14 +52,10 @@ struct acrn_vm_config vm_configs[CONFIG_MAX_VM_NUM] = {
6052

6153
},
6254
#if CONFIG_MAX_KATA_VM_NUM > 0
63-
{
64-
.load_order = POST_LAUNCHED_VM,
65-
.uuid = {0xa7U, 0xadU, 0xa5U, 0x06U, 0x1aU, 0xb0U, 0x4bU, 0x6bU, \
66-
0xa0U, 0xdaU, 0xe5U, 0x13U, 0xcaU, 0x9bU, 0x8cU, 0x2fU},
67-
/* a7ada506-1ab0-4b6b-a0da-e513ca9b8c2f */
55+
{ /* VM2 */
56+
CONFIG_KATA_VM(1),
6857
.vcpu_num = 1U,
6958
.vcpu_affinity = VM2_CONFIG_VCPU_AFFINITY,
70-
.severity = SEVERITY_STANDARD_VM,
7159
.vuart[0] = {
7260
.type = VUART_LEGACY_PIO,
7361
.addr.port_base = INVALID_COM_BASE,

hypervisor/scenarios/sdc2/vm_configurations.c

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,12 @@
99
#include <pci_dev.h>
1010

1111
struct acrn_vm_config vm_configs[CONFIG_MAX_VM_NUM] = {
12-
{
13-
.load_order = SOS_VM,
12+
{ /* VM0 */
13+
CONFIG_SOS_VM,
1414
.name = "ACRN SOS VM",
15-
.uuid = {0xdbU, 0xbbU, 0xd4U, 0x34U, 0x7aU, 0x57U, 0x42U, 0x16U, \
16-
0xa1U, 0x2cU, 0x22U, 0x01U, 0xf1U, 0xabU, 0x02U, 0x40U},
17-
/* dbbbd434-7a57-4216-a12c-2201f1ab0240 */
1815

1916
/* Allow SOS to reboot the host since there is supposed to be the highest severity guest */
2017
.guest_flags = 0UL,
21-
.severity = SEVERITY_SOS,
2218
.memory = {
2319
.start_hpa = 0UL,
2420
.size = CONFIG_SOS_RAM_SIZE,
@@ -41,14 +37,10 @@ struct acrn_vm_config vm_configs[CONFIG_MAX_VM_NUM] = {
4137
.pci_dev_num = SOS_EMULATED_PCI_DEV_NUM,
4238
.pci_devs = sos_pci_devs,
4339
},
44-
{
45-
.load_order = POST_LAUNCHED_VM,
46-
.uuid = {0xd2U, 0x79U, 0x54U, 0x38U, 0x25U, 0xd6U, 0x11U, 0xe8U, \
47-
0x86U, 0x4eU, 0xcbU, 0x7aU, 0x18U, 0xb3U, 0x46U, 0x43U},
48-
/* d2795438-25d6-11e8-864e-cb7a18b34643 */
40+
{ /* VM1 */
41+
CONFIG_POST_STD_VM(1),
4942
.vcpu_num = 1U,
5043
.vcpu_affinity = VM1_CONFIG_VCPU_AFFINITY,
51-
.severity = SEVERITY_STANDARD_VM,
5244
.vuart[0] = {
5345
.type = VUART_LEGACY_PIO,
5446
.addr.port_base = INVALID_COM_BASE,
@@ -59,14 +51,10 @@ struct acrn_vm_config vm_configs[CONFIG_MAX_VM_NUM] = {
5951
}
6052

6153
},
62-
{
63-
.load_order = POST_LAUNCHED_VM,
64-
.uuid = {0x61U, 0x5dU, 0xb8U, 0x2aU, 0xe1U, 0x89U, 0x4bU, 0x4fU, \
65-
0x8dU, 0xbbU, 0xd3U, 0x21U, 0x34U, 0x3eU, 0x4aU, 0xb3U},
66-
/* 615db82a-e189-4b4f-8dbb-d321343e4ab3 */
54+
{ /* VM2 */
55+
CONFIG_POST_STD_VM(2),
6756
.vcpu_num = 1U,
6857
.vcpu_affinity = VM2_CONFIG_VCPU_AFFINITY,
69-
.severity = SEVERITY_STANDARD_VM,
7058
.vuart[0] = {
7159
.type = VUART_LEGACY_PIO,
7260
.addr.port_base = INVALID_COM_BASE,
@@ -77,14 +65,10 @@ struct acrn_vm_config vm_configs[CONFIG_MAX_VM_NUM] = {
7765
}
7866

7967
},
80-
{
81-
.load_order = POST_LAUNCHED_VM,
82-
.uuid = {0x38U, 0x15U, 0x88U, 0x21U, 0x52U, 0x08U, 0x40U, 0x05U, \
83-
0xb7U, 0x2aU, 0x8aU, 0x60U, 0x9eU, 0x41U, 0x90U, 0xd0U},
84-
/* 38158821-5208-4005-b72a-8a609e4190d0 */
68+
{ /* VM3 */
69+
CONFIG_POST_STD_VM(3),
8570
.vcpu_num = 1U,
8671
.vcpu_affinity = VM3_CONFIG_VCPU_AFFINITY,
87-
.severity = SEVERITY_STANDARD_VM,
8872
.vuart[0] = {
8973
.type = VUART_LEGACY_PIO,
9074
.addr.port_base = INVALID_COM_BASE,

0 commit comments

Comments
 (0)