diff --git a/hypervisor/arch/x86/guest/vcpu.c b/hypervisor/arch/x86/guest/vcpu.c index dd024a6c6..28f5c50dc 100644 --- a/hypervisor/arch/x86/guest/vcpu.c +++ b/hypervisor/arch/x86/guest/vcpu.c @@ -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); diff --git a/hypervisor/include/arch/x86/guest/vcpu.h b/hypervisor/include/arch/x86/guest/vcpu.h index da175797e..fe6807036 100644 --- a/hypervisor/include/arch/x86/guest/vcpu.h +++ b/hypervisor/include/arch/x86/guest/vcpu.h @@ -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); diff --git a/hypervisor/include/arch/x86/per_cpu.h b/hypervisor/include/arch/x86/per_cpu.h index ed5183c29..e24294bbb 100644 --- a/hypervisor/include/arch/x86/per_cpu.h +++ b/hypervisor/include/arch/x86/per_cpu.h @@ -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