hv: use vcpu_affinity[] in vm_config to support vcpu assignment

Add this vcpu_affinity[] for each VM to indicate the assignment policy.
With it, pcpu_bitmap is not needed, so remove it from vm_config.
Instead, vcpu_affinity is a must for each VM.

This patch also add some sanitize check of vcpu_affinity[]. Here are
some rules:
  1) only one bit can be set for each vcpu_affinity of vcpu.
  2) two vcpus in same VM cannot be set with same vcpu_affinity.
  3) vcpu_affinity cannot be set to the pcpu which used by pre-launched VM.

v4: config SDC with CONFIG_MAX_KATA_VM_NUM
v5: config SDC with CONFIG_MAX_PCPU_NUM

Tracked-On: #3663
Signed-off-by: Jason Chen CJ <jason.cj.chen@intel.com>
Signed-off-by: Yu Wang <yu1.wang@intel.com>
Signed-off-by: Shuo A Liu <shuo.a.liu@intel.com>
This commit is contained in:
Shuo A Liu
2019-05-23 13:57:09 +08:00
committed by ACRN System Integration
parent ca2540fe8c
commit 1c526e6d16
14 changed files with 74 additions and 27 deletions

View File

@@ -15,7 +15,7 @@
#include <vm_configurations.h>
#include <sgx.h>
#define PLUG_CPU(n) (1U << (n))
#define AFFINITY_CPU(n) (1U << (n))
#define MAX_VUART_NUM_PER_VM 2U
#define MAX_VM_OS_NAME_LEN 32U
#define MAX_MOD_TAG_LEN 32U
@@ -95,8 +95,9 @@ struct acrn_vm_config {
enum acrn_vm_load_order load_order; /* specify the load order of VM */
char name[MAX_VM_OS_NAME_LEN]; /* VM name identifier, useful for debug. */
const uint8_t uuid[16]; /* UUID of the VM */
uint64_t pcpu_bitmap; /* from pcpu bitmap, we could know VM core number */
uint16_t vcpu_num; /* Number of vCPUs for the VM */
uint64_t vcpu_affinity[CONFIG_MAX_VCPUS_PER_VM];/* bitmaps for vCPUs' affinity */
uint64_t guest_flags; /* VM flags that we want to configure for guest
* Now we have two flags:
* GUEST_FLAG_SECURE_WORLD_ENABLED