mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2026-01-05 15:45:05 +00:00
hv:Replace dynamic memory with static for vcpu
-- Replace dynamic memory allocation with static memory -- Remove parameter check if vcpu is NULL Tracked-On: #861 Signed-off-by: Mingqiang Chi <mingqiang.chi@intel.com> Reviewed-by: Li, Fei1 <fei1.li@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
@@ -18,11 +18,11 @@
|
||||
|
||||
#include <mmu.h>
|
||||
|
||||
#define foreach_vcpu(idx, vm, vcpu) \
|
||||
for ((idx) = 0U, vcpu = vm->hw.vcpu_array[(idx)]; \
|
||||
(idx) < vm->hw.num_vcpus; \
|
||||
(idx)++, vcpu = vm->hw.vcpu_array[(idx)]) \
|
||||
if (vcpu != NULL)
|
||||
#define foreach_vcpu(idx, vm, vcpu) \
|
||||
for ((idx) = 0U, vcpu = &(vm->hw.vcpu_array[(idx)]); \
|
||||
(idx) < vm->hw.created_vcpus; \
|
||||
(idx)++, vcpu = &(vm->hw.vcpu_array[(idx)])) \
|
||||
if (vcpu->state != VCPU_OFFLINE)
|
||||
|
||||
/* the index is matched with emulated msrs array*/
|
||||
#define IDX_TSC_DEADLINE 0U
|
||||
|
||||
@@ -53,6 +53,7 @@ enum vcpu_state {
|
||||
VCPU_RUNNING,
|
||||
VCPU_PAUSED,
|
||||
VCPU_ZOMBIE,
|
||||
VCPU_OFFLINE,
|
||||
VCPU_UNKNOWN_STATE,
|
||||
};
|
||||
|
||||
@@ -304,9 +305,15 @@ static inline bool is_pae(struct vcpu *vcpu)
|
||||
|
||||
struct vcpu* get_ever_run_vcpu(uint16_t pcpu_id);
|
||||
int create_vcpu(uint16_t pcpu_id, struct vm *vm, struct vcpu **rtn_vcpu_handle);
|
||||
/*
|
||||
* @pre vcpu != NULL
|
||||
*/
|
||||
int run_vcpu(struct vcpu *vcpu);
|
||||
int shutdown_vcpu(struct vcpu *vcpu);
|
||||
void destroy_vcpu(struct vcpu *vcpu);
|
||||
/*
|
||||
* @pre vcpu != NULL
|
||||
*/
|
||||
void offline_vcpu(struct vcpu *vcpu);
|
||||
|
||||
void reset_vcpu(struct vcpu *vcpu);
|
||||
void pause_vcpu(struct vcpu *vcpu, enum vcpu_state new_state);
|
||||
|
||||
@@ -173,6 +173,9 @@ void vlapic_apicv_batch_set_tmr(struct acrn_vlapic *vlapic);
|
||||
uint32_t vlapic_get_id(struct acrn_vlapic *vlapic);
|
||||
uint8_t vlapic_get_apicid(struct acrn_vlapic *vlapic);
|
||||
int vlapic_create(struct vcpu *vcpu);
|
||||
/*
|
||||
* @pre vcpu != NULL
|
||||
*/
|
||||
void vlapic_free(struct vcpu *vcpu);
|
||||
void vlapic_init(struct acrn_vlapic *vlapic);
|
||||
void vlapic_reset(struct acrn_vlapic *vlapic);
|
||||
|
||||
@@ -21,11 +21,11 @@ enum vm_privilege_level {
|
||||
#define INVALID_VM_ID 0xffffU
|
||||
|
||||
struct vm_hw_info {
|
||||
uint16_t num_vcpus; /* Number of total virtual cores */
|
||||
/* vcpu array of this VM */
|
||||
struct vcpu vcpu_array[CONFIG_MAX_VCPUS_PER_VM];
|
||||
uint16_t created_vcpus; /* Number of created vcpus */
|
||||
struct vcpu **vcpu_array; /* vcpu array of this VM */
|
||||
uint64_t gpa_lowtop; /* top lowmem gpa of this VM */
|
||||
};
|
||||
} __aligned(CPU_PAGE_SIZE);
|
||||
|
||||
struct sw_linux {
|
||||
void *ramdisk_src_addr; /* HVA */
|
||||
@@ -130,10 +130,10 @@ struct vcpuid_entry {
|
||||
|
||||
struct vm {
|
||||
struct vm_arch arch_vm; /* Reference to this VM's arch information */
|
||||
uint16_t vm_id; /* Virtual machine identifier */
|
||||
struct vm_hw_info hw; /* Reference to this VM's HW information */
|
||||
struct vm_sw_info sw; /* Reference to SW associated with this VM */
|
||||
struct vm_pm_info pm; /* Reference to this VM's arch information */
|
||||
uint16_t vm_id; /* Virtual machine identifier */
|
||||
enum vm_state state; /* VM state */
|
||||
struct acrn_vuart vuart; /* Virtual UART */
|
||||
enum vpic_wire_mode wire_mode;
|
||||
|
||||
@@ -126,7 +126,9 @@ void dm_emulate_mmio_post(struct vcpu *vcpu);
|
||||
|
||||
int32_t emulate_io(struct vcpu *vcpu, struct io_request *io_req);
|
||||
void emulate_io_post(struct vcpu *vcpu);
|
||||
|
||||
/*
|
||||
* @pre vcpu != NULL && io_req != NULL
|
||||
*/
|
||||
int32_t acrn_insert_request_wait(struct vcpu *vcpu, struct io_request *io_req);
|
||||
|
||||
#endif /* IOREQ_H */
|
||||
|
||||
@@ -110,7 +110,9 @@ void vcpu_inject_ac(struct vcpu *vcpu);
|
||||
void vcpu_inject_ss(struct vcpu *vcpu);
|
||||
void vcpu_make_request(struct vcpu *vcpu, uint16_t eventid);
|
||||
int vcpu_queue_exception(struct vcpu *vcpu, uint32_t vector, uint32_t err_code);
|
||||
|
||||
/*
|
||||
* @pre vcpu != NULL
|
||||
*/
|
||||
int exception_vmexit_handler(struct vcpu *vcpu);
|
||||
int interrupt_window_vmexit_handler(struct vcpu *vcpu);
|
||||
int external_interrupt_vmexit_handler(struct vcpu *vcpu);
|
||||
|
||||
Reference in New Issue
Block a user