hv:Replace dynamic memory allocation for vmcs region
Replace vmcs pointer with static memory for vmcs region inside structure vcpu_arch. Tracked-On: #861 Signed-off-by: Mingqiang Chi <mingqiang.chi@intel.com> Reviewed-by: Anthony Xu <anthony.xu@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
parent
ca75d506b7
commit
eada04b800
|
@ -224,13 +224,6 @@ int create_vcpu(uint16_t pcpu_id, struct vm *vm, struct vcpu **rtn_vcpu_handle)
|
||||||
|
|
||||||
vcpu->arch_vcpu.vpid = allocate_vpid();
|
vcpu->arch_vcpu.vpid = allocate_vpid();
|
||||||
|
|
||||||
/* Allocate VMCS region for this VCPU */
|
|
||||||
vcpu->arch_vcpu.vmcs = alloc_page();
|
|
||||||
ASSERT(vcpu->arch_vcpu.vmcs != NULL, "");
|
|
||||||
|
|
||||||
/* Memset VMCS region for this VCPU */
|
|
||||||
(void)memset(vcpu->arch_vcpu.vmcs, 0U, CPU_PAGE_SIZE);
|
|
||||||
|
|
||||||
/* Initialize exception field in VCPU context */
|
/* Initialize exception field in VCPU context */
|
||||||
vcpu->arch_vcpu.exception_info.exception = VECTOR_INVALID;
|
vcpu->arch_vcpu.exception_info.exception = VECTOR_INVALID;
|
||||||
|
|
||||||
|
@ -384,7 +377,6 @@ void destroy_vcpu(struct vcpu *vcpu)
|
||||||
atomic_dec16(&vcpu->vm->hw.created_vcpus);
|
atomic_dec16(&vcpu->vm->hw.created_vcpus);
|
||||||
|
|
||||||
vlapic_free(vcpu);
|
vlapic_free(vcpu);
|
||||||
free(vcpu->arch_vcpu.vmcs);
|
|
||||||
per_cpu(ever_run_vcpu, vcpu->pcpu_id) = NULL;
|
per_cpu(ever_run_vcpu, vcpu->pcpu_id) = NULL;
|
||||||
free_pcpu(vcpu->pcpu_id);
|
free_pcpu(vcpu->pcpu_id);
|
||||||
free(vcpu);
|
free(vcpu);
|
||||||
|
|
|
@ -164,11 +164,11 @@ struct cpu_context {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct vcpu_arch {
|
struct vcpu_arch {
|
||||||
|
/* vmcs region for this vcpu, MUST be 4KB-aligned */
|
||||||
|
uint8_t vmcs[CPU_PAGE_SIZE];
|
||||||
int cur_context;
|
int cur_context;
|
||||||
struct cpu_context contexts[NR_WORLD];
|
struct cpu_context contexts[NR_WORLD];
|
||||||
|
|
||||||
/* A pointer to the VMCS for this CPU. */
|
|
||||||
void *vmcs;
|
|
||||||
uint16_t vpid;
|
uint16_t vpid;
|
||||||
|
|
||||||
/* Holds the information needed for IRQ/exception handling. */
|
/* Holds the information needed for IRQ/exception handling. */
|
||||||
|
@ -205,14 +205,14 @@ struct vcpu_arch {
|
||||||
|
|
||||||
/* per vcpu lapic */
|
/* per vcpu lapic */
|
||||||
void *vlapic;
|
void *vlapic;
|
||||||
};
|
} __aligned(CPU_PAGE_SIZE);
|
||||||
|
|
||||||
struct vm;
|
struct vm;
|
||||||
struct vcpu {
|
struct vcpu {
|
||||||
|
/* Architecture specific definitions for this VCPU */
|
||||||
|
struct vcpu_arch arch_vcpu;
|
||||||
uint16_t pcpu_id; /* Physical CPU ID of this VCPU */
|
uint16_t pcpu_id; /* Physical CPU ID of this VCPU */
|
||||||
uint16_t vcpu_id; /* virtual identifier for VCPU */
|
uint16_t vcpu_id; /* virtual identifier for VCPU */
|
||||||
struct vcpu_arch arch_vcpu;
|
|
||||||
/* Architecture specific definitions for this VCPU */
|
|
||||||
struct vm *vm; /* Reference to the VM this VCPU belongs to */
|
struct vm *vm; /* Reference to the VM this VCPU belongs to */
|
||||||
void *entry_addr; /* Entry address for this VCPU when first started */
|
void *entry_addr; /* Entry address for this VCPU when first started */
|
||||||
|
|
||||||
|
@ -246,7 +246,7 @@ struct vcpu {
|
||||||
#endif
|
#endif
|
||||||
uint64_t reg_cached;
|
uint64_t reg_cached;
|
||||||
uint64_t reg_updated;
|
uint64_t reg_updated;
|
||||||
};
|
} __aligned(CPU_PAGE_SIZE);
|
||||||
|
|
||||||
struct vcpu_dump {
|
struct vcpu_dump {
|
||||||
struct vcpu *vcpu;
|
struct vcpu *vcpu;
|
||||||
|
|
Loading…
Reference in New Issue