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>
This commit is contained in:
Victor Sun 2019-01-17 09:10:10 +08:00 committed by wenlingz
parent c4a230f313
commit a8e4f227ba
10 changed files with 160 additions and 3 deletions

View File

@ -109,6 +109,7 @@ INCLUDE_PATH += include/dm
INCLUDE_PATH += bsp/include
INCLUDE_PATH += boot/include
INCLUDE_PATH += $(HV_OBJDIR)/include
INCLUDE_PATH += arch/x86/configs/$(CONFIG_BOARD)
CC ?= gcc
AS ?= as
@ -130,6 +131,13 @@ C_SRCS += boot/reloc.c
# initilization component
C_SRCS += arch/x86/init.c
# configuration component
ifeq ($(CONFIG_SHARING_MODE),y)
C_SRCS += arch/x86/configs/sharing_config.c
else ifeq ($(CONFIG_PARTITION_MODE),y)
C_SRCS += arch/x86/configs/partition_config.c
endif
C_SRCS += boot/acpi.c
C_SRCS += boot/dmar_parse.c
S_SRCS += arch/x86/idt.S

View File

@ -0,0 +1,17 @@
/*
* Copyright (C) 2018 Intel Corporation. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#ifndef SOS_VM_CONFIG_H
#define SOS_VM_CONFIG_H
#define SOS_VM_CONFIG_NAME "ACRN SOS VM for APL-MRB"
#define SOS_VM_CONFIG_MEM_SIZE 0x200000000UL
#define SOS_VM_CONFIG_PCPU_BITMAP (PLUG_CPU(0) | PLUG_CPU(1) | PLUG_CPU(2) | PLUG_CPU(3))
#define SOS_VM_CONFIG_GUEST_FLAGS IO_COMPLETION_POLLING
#define SOS_VM_CONFIG_OS_NAME "ClearLinux 26600"
#endif /* SOS_VM_CONFIG_H */

View File

@ -0,0 +1 @@
nuc6cayh

View File

@ -0,0 +1,17 @@
/*
* Copyright (C) 2018 Intel Corporation. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#ifndef SOS_VM_CONFIG_H
#define SOS_VM_CONFIG_H
#define SOS_VM_CONFIG_NAME "ACRN SOS VM for DNV-CB2"
#define SOS_VM_CONFIG_MEM_SIZE 0x400000000UL
#define SOS_VM_CONFIG_PCPU_BITMAP (PLUG_CPU(0) | PLUG_CPU(1) | PLUG_CPU(2) | PLUG_CPU(3) \
| PLUG_CPU(4) | PLUG_CPU(5) | PLUG_CPU(6) | PLUG_CPU(7))
#define SOS_VM_CONFIG_GUEST_FLAGS IO_COMPLETION_POLLING
#define SOS_VM_CONFIG_OS_NAME "ClearLinux 26600"
#endif /* SOS_VM_CONFIG_H */

View File

@ -0,0 +1,16 @@
/*
* Copyright (C) 2018 Intel Corporation. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#ifndef SOS_VM_CONFIG_H
#define SOS_VM_CONFIG_H
#define SOS_VM_CONFIG_NAME "ACRN SOS VM for APL-NUC"
#define SOS_VM_CONFIG_MEM_SIZE 0x400000000UL
#define SOS_VM_CONFIG_PCPU_BITMAP (PLUG_CPU(0) | PLUG_CPU(1) | PLUG_CPU(2) | PLUG_CPU(3))
#define SOS_VM_CONFIG_GUEST_FLAGS IO_COMPLETION_POLLING
#define SOS_VM_CONFIG_OS_NAME "ClearLinux 26600"
#endif /* SOS_VM_CONFIG_H */

View File

@ -0,0 +1,10 @@
/*
* Copyright (C) 2018 Intel Corporation. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#include <hypervisor.h>
struct acrn_vm_config vm_configs[CONFIG_MAX_VM_NUM] __aligned(PAGE_SIZE) = {
};

View File

@ -0,0 +1,24 @@
/*
* Copyright (C) 2018 Intel Corporation. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#include <hypervisor.h>
#include <sos_vm.h>
struct acrn_vm_config vm_configs[CONFIG_MAX_VM_NUM] __aligned(PAGE_SIZE) = {
{
.type = SOS_VM,
.name = SOS_VM_CONFIG_NAME,
.pcpu_bitmap = SOS_VM_CONFIG_PCPU_BITMAP,
.guest_flags = SOS_VM_CONFIG_GUEST_FLAGS,
.memory = {
.start_hpa = 0x0UL,
.size = SOS_VM_CONFIG_MEM_SIZE,
},
.os_config = {
.name = SOS_VM_CONFIG_OS_NAME,
},
},
};

View File

@ -0,0 +1,17 @@
/*
* Copyright (C) 2018 Intel Corporation. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#ifndef SOS_VM_CONFIG_H
#define SOS_VM_CONFIG_H
#define SOS_VM_CONFIG_NAME "ACRN SOS VM for APL-UP2"
#define SOS_VM_CONFIG_MEM_SIZE 0x200000000UL
#define SOS_VM_CONFIG_PCPU_BITMAP (PLUG_CPU(0) | PLUG_CPU(1))
#define SOS_VM_CONFIG_GUEST_FLAGS IO_COMPLETION_POLLING
#define SOS_VM_CONFIG_OS_NAME "ClearLinux 26600"
#endif /* SOS_VM_CONFIG_H */

View File

@ -22,6 +22,8 @@ enum vm_privilege_level {
#define INVALID_VM_ID 0xffffU
#define PLUG_CPU(n) (1U << n)
struct vm_hw_info {
/* vcpu array of this VM */
struct acrn_vcpu vcpu_array[CONFIG_MAX_VCPUS_PER_VM];
@ -172,12 +174,52 @@ struct vpci_vdev_array {
};
#endif
#define MAX_BOOTARGS_SIZE 1024U
#define MAX_CONFIG_NAME_SIZE 32U
enum acrn_vm_type {
UNDEFINED_VM = 0,
PRE_LAUNCHED_VM,
SOS_VM,
NORMAL_VM,
/* PRIVILEGE_VM, */
};
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 */
};
struct acrn_vm_os_config {
char name[MAX_CONFIG_NAME_SIZE]; /* OS name, useful for debug */
char bootargs[MAX_BOOTARGS_SIZE]; /* boot args/cmdline */
} __aligned(8);
struct acrn_vm_pci_ptdev_config {
union pci_bdf vbdf; /* virtual BDF of PCI PT device */
union pci_bdf pbdf; /* physical BDF of PCI PT device */
} __aligned(8);
struct acrn_vm_config {
enum acrn_vm_type type; /* specify the type of VM */
char name[MAX_CONFIG_NAME_SIZE]; /* VM name identifier, useful for debug. */
uint8_t GUID[16]; /* GUID of the VM */
uint64_t pcpu_bitmap; /* from pcpu bitmap, we could know VM core number */
uint64_t guest_flags; /* VM flags that we want to configure for guest
* Now we have two flags:
* SECURE_WORLD_ENABLED
* LAPIC_PASSTHROUGH
* We could add more guest flags in future;
*/
struct acrn_vm_mem_config memory; /* memory configuration of VM */
uint16_t pci_ptdev_num; /* indicate how many PCI PT devices in VM */
struct acrn_vm_pci_ptdev_config *pci_ptdevs; /* point to PCI PT devices BDF list */
struct acrn_vm_os_config os_config; /* OS information the VM */
/* The physical CPU IDs associated with this VM - The first CPU listed
* will be the VM's BSP
*/
uint16_t *vm_pcpu_ids;
uint8_t GUID[16]; /* GUID of the vm will be created */
uint16_t vm_hw_num_cores; /* Number of virtual cores */
/* Whether secure world is supported for current VM. */
bool sworld_supported;
@ -191,7 +233,8 @@ struct acrn_vm_config {
struct vpci_vdev_array *vpci_vdev_array;
bool lapic_pt;
#endif
};
} __aligned(8);
static inline bool is_vm0(const struct acrn_vm *vm)
{
@ -271,6 +314,8 @@ int32_t reset_vm(struct acrn_vm *vm);
int32_t create_vm(struct acrn_vm_config *vm_config, struct acrn_vm **rtn_vm);
int32_t prepare_vm(uint16_t pcpu_id);
extern struct acrn_vm_config vm_configs[];
#ifdef CONFIG_PARTITION_MODE
const struct vm_config_arraies *get_vm_config_base(void);
#endif

View File

@ -47,7 +47,9 @@
#endif
/* Generic VM flags from guest OS */
#define SECURE_WORLD_ENABLED (1UL << 0U) /* Whether secure world is enabled */
#define SECURE_WORLD_ENABLED (1UL << 0U) /* Whether secure world is enabled */
#define LAPIC_PASSTHROUGH (1UL << 1U) /* Whether LAPIC is passed through */
#define IO_COMPLETION_POLLING (1UL << 2U) /* Whether need hypervisor poll IO completion */
/**
* @brief Hypercall