add CONFIG_VM0_DESC support
if defined CONFIG_VM0_DESC, HV will use predefined vm0_desc to config VM0, otherwise, HV will run VM0 with all physical cpus. Signed-off-by: Jason Chen CJ <jason.cj.chen@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
parent
22833787ce
commit
589c72382a
|
@ -29,6 +29,7 @@ static void init_vm(struct vm_description *vm_desc,
|
|||
struct vm *vm_handle)
|
||||
{
|
||||
/* Populate VM attributes from VM description */
|
||||
#ifdef CONFIG_VM0_DESC
|
||||
if (is_vm0(vm_handle)) {
|
||||
/* Allocate all cpus to vm0 at the beginning */
|
||||
vm_handle->hw.num_vcpus = phys_cpu_num;
|
||||
|
@ -37,6 +38,9 @@ static void init_vm(struct vm_description *vm_desc,
|
|||
vm_handle->hw.num_vcpus = vm_desc->vm_hw_num_cores;
|
||||
vm_handle->hw.exp_num_vcpus = vm_desc->vm_hw_num_cores;
|
||||
}
|
||||
#else
|
||||
vm_handle->hw.num_vcpus = vm_desc->vm_hw_num_cores;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* return a pointer to the virtual machine structure associated with
|
||||
|
@ -339,6 +343,10 @@ int prepare_vm0(void)
|
|||
struct vm *vm = NULL;
|
||||
struct vm_description *vm_desc = &vm0_desc;
|
||||
|
||||
#ifndef CONFIG_VM0_DESC
|
||||
vm_desc->vm_hw_num_cores = phys_cpu_num;
|
||||
#endif
|
||||
|
||||
err = create_vm(vm_desc, &vm);
|
||||
if (err != 0) {
|
||||
return err;
|
||||
|
@ -360,6 +368,7 @@ int prepare_vm0(void)
|
|||
return err;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_VM0_DESC
|
||||
static inline bool vcpu_in_vm_desc(struct vcpu *vcpu,
|
||||
struct vm_description *vm_desc)
|
||||
{
|
||||
|
@ -404,3 +413,4 @@ void vm_fixup(struct vm *vm)
|
|||
vm->hw.num_vcpus = vm->hw.exp_num_vcpus;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -39,10 +39,12 @@ int vmcall_vmexit_handler(struct vcpu *vcpu)
|
|||
/* Dispatch the hypercall handler */
|
||||
switch (hypcall_id) {
|
||||
case HC_GET_API_VERSION:
|
||||
#ifdef CONFIG_VM0_DESC
|
||||
/* vm0 will call HC_GET_API_VERSION as first hypercall, fixup
|
||||
* vm0 vcpu here.
|
||||
*/
|
||||
vm_fixup(vm);
|
||||
#endif
|
||||
ret = hcall_get_api_version(vm, param1);
|
||||
break;
|
||||
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
|
||||
#include <hypervisor.h>
|
||||
|
||||
#ifdef CONFIG_VM0_DESC
|
||||
|
||||
/* Number of CPUs in VM0 */
|
||||
#define VM0_NUM_CPUS 1
|
||||
|
||||
|
@ -16,3 +18,9 @@ struct vm_description vm0_desc = {
|
|||
.vm_hw_num_cores = VM0_NUM_CPUS,
|
||||
.vm_pcpu_ids = &VM0_CPUS[0],
|
||||
};
|
||||
|
||||
#else
|
||||
|
||||
struct vm_description vm0_desc;
|
||||
|
||||
#endif // CONFIG_VM0_DESC
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
|
||||
#include <hypervisor.h>
|
||||
|
||||
#ifdef CONFIG_VM0_DESC
|
||||
|
||||
/* Number of CPUs in VM0 */
|
||||
#define VM0_NUM_CPUS 1
|
||||
|
||||
|
@ -16,3 +18,9 @@ struct vm_description vm0_desc = {
|
|||
.vm_hw_num_cores = VM0_NUM_CPUS,
|
||||
.vm_pcpu_ids = &VM0_CPUS[0],
|
||||
};
|
||||
|
||||
#else
|
||||
|
||||
struct vm_description vm0_desc;
|
||||
|
||||
#endif // CONFIG_VM0_DESC
|
||||
|
|
|
@ -104,7 +104,11 @@ void vcpu_thread(struct vcpu *vcpu)
|
|||
|
||||
static bool is_vm0_bsp(uint16_t pcpu_id)
|
||||
{
|
||||
#ifdef CONFIG_VM0_DESC
|
||||
return pcpu_id == vm0_desc.vm_pcpu_ids[0];
|
||||
#else
|
||||
return pcpu_id == BOOT_CPU_ID;
|
||||
#endif
|
||||
}
|
||||
|
||||
int32_t hv_main(uint16_t pcpu_id)
|
||||
|
|
|
@ -175,7 +175,9 @@ void resume_vm_from_s3(struct vm *vm, uint32_t wakeup_vec);
|
|||
int start_vm(struct vm *vm);
|
||||
int create_vm(struct vm_description *vm_desc, struct vm **vm);
|
||||
int prepare_vm0(void);
|
||||
#ifdef CONFIG_VM0_DESC
|
||||
void vm_fixup(struct vm *vm);
|
||||
#endif
|
||||
|
||||
struct vm *get_vm_from_vmid(uint16_t vm_id);
|
||||
|
||||
|
|
Loading…
Reference in New Issue