hv: add API to get the vcpu mapped to specific pcpu.
Per performance consideration, we don't flush vcpu context when doing vcpu swithing (because it's only swithing between vcpu and idle). But when enter S3, we need to call vmclear against all vcpus attached to APs. We need to know which vcpu is attached with which pcpu. This patch introduced API to get vcpu mapped to specific pcpu. Signed-off-by: Yin Fegnwei <fengwei.yin@intel.com> Acked-by: Eddie Dong <Eddie.dong@intel.com>
This commit is contained in:
parent
2dd4e8f81a
commit
fbeafd500a
|
@ -14,6 +14,11 @@ extern struct efi_ctx* efi_ctx;
|
|||
|
||||
vm_sw_loader_t vm_sw_loader;
|
||||
|
||||
struct vcpu *get_ever_run_vcpu(int pcpu_id)
|
||||
{
|
||||
return per_cpu(ever_run_vcpu, pcpu_id);
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* vcpu_id/pcpu_id mapping table:
|
||||
*
|
||||
|
@ -41,6 +46,7 @@ int create_vcpu(int cpu_id, struct vm *vm, struct vcpu **rtn_vcpu_handle)
|
|||
|
||||
/* Initialize the physical CPU ID for this VCPU */
|
||||
vcpu->pcpu_id = cpu_id;
|
||||
per_cpu(ever_run_vcpu, cpu_id) = vcpu;
|
||||
|
||||
/* Initialize the parent VM reference */
|
||||
vcpu->vm = vm;
|
||||
|
@ -241,6 +247,7 @@ int destroy_vcpu(struct vcpu *vcpu)
|
|||
vlapic_free(vcpu);
|
||||
free(vcpu->arch_vcpu.vmcs);
|
||||
free(vcpu->guest_msrs);
|
||||
per_cpu(ever_run_vcpu, vcpu->pcpu_id) = NULL;
|
||||
free_pcpu(vcpu->pcpu_id);
|
||||
free(vcpu);
|
||||
|
||||
|
|
|
@ -253,6 +253,7 @@ struct vcpu {
|
|||
#define VCPU_RETAIN_RIP(vcpu) ((vcpu)->arch_vcpu.inst_len = 0)
|
||||
|
||||
/* External Interfaces */
|
||||
struct vcpu* get_ever_run_vcpu(int pcpu_id);
|
||||
int create_vcpu(int cpu_id, struct vm *vm, struct vcpu **rtn_vcpu_handle);
|
||||
int start_vcpu(struct vcpu *vcpu);
|
||||
int shutdown_vcpu(struct vcpu *vcpu);
|
||||
|
|
|
@ -21,6 +21,7 @@ struct per_cpu_region {
|
|||
struct dev_handler_node *timer_node;
|
||||
struct shared_buf *earlylog_sbuf;
|
||||
void *vcpu;
|
||||
void *ever_run_vcpu;
|
||||
#ifdef STACK_PROTECTOR
|
||||
struct stack_canary stack_canary;
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue