Skip to content

Commit a8e4f22

Browse files
jsun26intelwenlingz
authored andcommitted
HV: add new acrn_vm_config member and config files
- add new struct member for acrn_vm_config; - add sharing_config.c file with initialized vm_config array; - add SOS VM config header for apl-mrb/apl-nuc/up2 and dnv-cb2 board; - and partition_config.c file with dummy vm_config array; Tracked-On: #2291 Signed-off-by: Victor Sun <victor.sun@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
1 parent c4a230f commit a8e4f22

File tree

10 files changed

+160
-3
lines changed

10 files changed

+160
-3
lines changed

hypervisor/Makefile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ INCLUDE_PATH += include/dm
109109
INCLUDE_PATH += bsp/include
110110
INCLUDE_PATH += boot/include
111111
INCLUDE_PATH += $(HV_OBJDIR)/include
112+
INCLUDE_PATH += arch/x86/configs/$(CONFIG_BOARD)
112113

113114
CC ?= gcc
114115
AS ?= as
@@ -130,6 +131,13 @@ C_SRCS += boot/reloc.c
130131
# initilization component
131132
C_SRCS += arch/x86/init.c
132133

134+
# configuration component
135+
ifeq ($(CONFIG_SHARING_MODE),y)
136+
C_SRCS += arch/x86/configs/sharing_config.c
137+
else ifeq ($(CONFIG_PARTITION_MODE),y)
138+
C_SRCS += arch/x86/configs/partition_config.c
139+
endif
140+
133141
C_SRCS += boot/acpi.c
134142
C_SRCS += boot/dmar_parse.c
135143
S_SRCS += arch/x86/idt.S
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/*
2+
* Copyright (C) 2018 Intel Corporation. All rights reserved.
3+
*
4+
* SPDX-License-Identifier: BSD-3-Clause
5+
*/
6+
7+
#ifndef SOS_VM_CONFIG_H
8+
#define SOS_VM_CONFIG_H
9+
10+
#define SOS_VM_CONFIG_NAME "ACRN SOS VM for APL-MRB"
11+
#define SOS_VM_CONFIG_MEM_SIZE 0x200000000UL
12+
#define SOS_VM_CONFIG_PCPU_BITMAP (PLUG_CPU(0) | PLUG_CPU(1) | PLUG_CPU(2) | PLUG_CPU(3))
13+
#define SOS_VM_CONFIG_GUEST_FLAGS IO_COMPLETION_POLLING
14+
15+
#define SOS_VM_CONFIG_OS_NAME "ClearLinux 26600"
16+
17+
#endif /* SOS_VM_CONFIG_H */

hypervisor/arch/x86/configs/apl-nuc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
nuc6cayh
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/*
2+
* Copyright (C) 2018 Intel Corporation. All rights reserved.
3+
*
4+
* SPDX-License-Identifier: BSD-3-Clause
5+
*/
6+
#ifndef SOS_VM_CONFIG_H
7+
#define SOS_VM_CONFIG_H
8+
9+
#define SOS_VM_CONFIG_NAME "ACRN SOS VM for DNV-CB2"
10+
#define SOS_VM_CONFIG_MEM_SIZE 0x400000000UL
11+
#define SOS_VM_CONFIG_PCPU_BITMAP (PLUG_CPU(0) | PLUG_CPU(1) | PLUG_CPU(2) | PLUG_CPU(3) \
12+
| PLUG_CPU(4) | PLUG_CPU(5) | PLUG_CPU(6) | PLUG_CPU(7))
13+
#define SOS_VM_CONFIG_GUEST_FLAGS IO_COMPLETION_POLLING
14+
15+
#define SOS_VM_CONFIG_OS_NAME "ClearLinux 26600"
16+
17+
#endif /* SOS_VM_CONFIG_H */
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/*
2+
* Copyright (C) 2018 Intel Corporation. All rights reserved.
3+
*
4+
* SPDX-License-Identifier: BSD-3-Clause
5+
*/
6+
#ifndef SOS_VM_CONFIG_H
7+
#define SOS_VM_CONFIG_H
8+
9+
#define SOS_VM_CONFIG_NAME "ACRN SOS VM for APL-NUC"
10+
#define SOS_VM_CONFIG_MEM_SIZE 0x400000000UL
11+
#define SOS_VM_CONFIG_PCPU_BITMAP (PLUG_CPU(0) | PLUG_CPU(1) | PLUG_CPU(2) | PLUG_CPU(3))
12+
#define SOS_VM_CONFIG_GUEST_FLAGS IO_COMPLETION_POLLING
13+
14+
#define SOS_VM_CONFIG_OS_NAME "ClearLinux 26600"
15+
16+
#endif /* SOS_VM_CONFIG_H */
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/*
2+
* Copyright (C) 2018 Intel Corporation. All rights reserved.
3+
*
4+
* SPDX-License-Identifier: BSD-3-Clause
5+
*/
6+
7+
#include <hypervisor.h>
8+
9+
struct acrn_vm_config vm_configs[CONFIG_MAX_VM_NUM] __aligned(PAGE_SIZE) = {
10+
};
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
* Copyright (C) 2018 Intel Corporation. All rights reserved.
3+
*
4+
* SPDX-License-Identifier: BSD-3-Clause
5+
*/
6+
7+
#include <hypervisor.h>
8+
#include <sos_vm.h>
9+
10+
struct acrn_vm_config vm_configs[CONFIG_MAX_VM_NUM] __aligned(PAGE_SIZE) = {
11+
{
12+
.type = SOS_VM,
13+
.name = SOS_VM_CONFIG_NAME,
14+
.pcpu_bitmap = SOS_VM_CONFIG_PCPU_BITMAP,
15+
.guest_flags = SOS_VM_CONFIG_GUEST_FLAGS,
16+
.memory = {
17+
.start_hpa = 0x0UL,
18+
.size = SOS_VM_CONFIG_MEM_SIZE,
19+
},
20+
.os_config = {
21+
.name = SOS_VM_CONFIG_OS_NAME,
22+
},
23+
},
24+
};
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/*
2+
* Copyright (C) 2018 Intel Corporation. All rights reserved.
3+
*
4+
* SPDX-License-Identifier: BSD-3-Clause
5+
*/
6+
7+
#ifndef SOS_VM_CONFIG_H
8+
#define SOS_VM_CONFIG_H
9+
10+
#define SOS_VM_CONFIG_NAME "ACRN SOS VM for APL-UP2"
11+
#define SOS_VM_CONFIG_MEM_SIZE 0x200000000UL
12+
#define SOS_VM_CONFIG_PCPU_BITMAP (PLUG_CPU(0) | PLUG_CPU(1))
13+
#define SOS_VM_CONFIG_GUEST_FLAGS IO_COMPLETION_POLLING
14+
15+
#define SOS_VM_CONFIG_OS_NAME "ClearLinux 26600"
16+
17+
#endif /* SOS_VM_CONFIG_H */

hypervisor/include/arch/x86/guest/vm.h

Lines changed: 47 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ enum vm_privilege_level {
2222

2323
#define INVALID_VM_ID 0xffffU
2424

25+
#define PLUG_CPU(n) (1U << n)
26+
2527
struct vm_hw_info {
2628
/* vcpu array of this VM */
2729
struct acrn_vcpu vcpu_array[CONFIG_MAX_VCPUS_PER_VM];
@@ -172,12 +174,52 @@ struct vpci_vdev_array {
172174
};
173175
#endif
174176

177+
#define MAX_BOOTARGS_SIZE 1024U
178+
#define MAX_CONFIG_NAME_SIZE 32U
179+
180+
enum acrn_vm_type {
181+
UNDEFINED_VM = 0,
182+
PRE_LAUNCHED_VM,
183+
SOS_VM,
184+
NORMAL_VM,
185+
/* PRIVILEGE_VM, */
186+
};
187+
188+
struct acrn_vm_mem_config {
189+
uint64_t start_hpa; /* the start HPA of VM memory configuration, for pre-launched VMs only */
190+
uint64_t size; /* VM memory size configuration */
191+
};
192+
193+
struct acrn_vm_os_config {
194+
char name[MAX_CONFIG_NAME_SIZE]; /* OS name, useful for debug */
195+
char bootargs[MAX_BOOTARGS_SIZE]; /* boot args/cmdline */
196+
} __aligned(8);
197+
198+
struct acrn_vm_pci_ptdev_config {
199+
union pci_bdf vbdf; /* virtual BDF of PCI PT device */
200+
union pci_bdf pbdf; /* physical BDF of PCI PT device */
201+
} __aligned(8);
202+
175203
struct acrn_vm_config {
204+
enum acrn_vm_type type; /* specify the type of VM */
205+
char name[MAX_CONFIG_NAME_SIZE]; /* VM name identifier, useful for debug. */
206+
uint8_t GUID[16]; /* GUID of the VM */
207+
uint64_t pcpu_bitmap; /* from pcpu bitmap, we could know VM core number */
208+
uint64_t guest_flags; /* VM flags that we want to configure for guest
209+
* Now we have two flags:
210+
* SECURE_WORLD_ENABLED
211+
* LAPIC_PASSTHROUGH
212+
* We could add more guest flags in future;
213+
*/
214+
struct acrn_vm_mem_config memory; /* memory configuration of VM */
215+
uint16_t pci_ptdev_num; /* indicate how many PCI PT devices in VM */
216+
struct acrn_vm_pci_ptdev_config *pci_ptdevs; /* point to PCI PT devices BDF list */
217+
struct acrn_vm_os_config os_config; /* OS information the VM */
218+
176219
/* The physical CPU IDs associated with this VM - The first CPU listed
177220
* will be the VM's BSP
178221
*/
179222
uint16_t *vm_pcpu_ids;
180-
uint8_t GUID[16]; /* GUID of the vm will be created */
181223
uint16_t vm_hw_num_cores; /* Number of virtual cores */
182224
/* Whether secure world is supported for current VM. */
183225
bool sworld_supported;
@@ -191,7 +233,8 @@ struct acrn_vm_config {
191233
struct vpci_vdev_array *vpci_vdev_array;
192234
bool lapic_pt;
193235
#endif
194-
};
236+
237+
} __aligned(8);
195238

196239
static inline bool is_vm0(const struct acrn_vm *vm)
197240
{
@@ -271,6 +314,8 @@ int32_t reset_vm(struct acrn_vm *vm);
271314
int32_t create_vm(struct acrn_vm_config *vm_config, struct acrn_vm **rtn_vm);
272315
int32_t prepare_vm(uint16_t pcpu_id);
273316

317+
extern struct acrn_vm_config vm_configs[];
318+
274319
#ifdef CONFIG_PARTITION_MODE
275320
const struct vm_config_arraies *get_vm_config_base(void);
276321
#endif

hypervisor/include/public/acrn_common.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,9 @@
4747
#endif
4848

4949
/* Generic VM flags from guest OS */
50-
#define SECURE_WORLD_ENABLED (1UL << 0U) /* Whether secure world is enabled */
50+
#define SECURE_WORLD_ENABLED (1UL << 0U) /* Whether secure world is enabled */
51+
#define LAPIC_PASSTHROUGH (1UL << 1U) /* Whether LAPIC is passed through */
52+
#define IO_COMPLETION_POLLING (1UL << 2U) /* Whether need hypervisor poll IO completion */
5153

5254
/**
5355
* @brief Hypercall

0 commit comments

Comments
 (0)