Skip to content

Commit 2a184f3

Browse files
shiqingglijinxia
authored andcommitted
hv: code clean up regarding to guest_msrs
Change guest_msrs in vcpu data structure from pointer to array, which could avoid the dynamic memory allocation. v1 -> v2: * Remove the unnecessary initialization for guest_msrs[] since vcpu is allocated by calloc. Tracked-On: #861 Signed-off-by: Shiqing Gao <shiqing.gao@intel.com> Acked-by: Anthony Xu <anthony.xu@intel.com>
1 parent 947e86d commit 2a184f3

File tree

3 files changed

+1
-10
lines changed

3 files changed

+1
-10
lines changed

hypervisor/arch/x86/guest/vcpu.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,6 @@ void destroy_vcpu(struct vcpu *vcpu)
385385

386386
vlapic_free(vcpu);
387387
free(vcpu->arch_vcpu.vmcs);
388-
free(vcpu->guest_msrs);
389388
per_cpu(ever_run_vcpu, vcpu->pcpu_id) = NULL;
390389
free_pcpu(vcpu->pcpu_id);
391390
free(vcpu);

hypervisor/arch/x86/guest/vmsr.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -105,14 +105,6 @@ void init_msr_emulation(struct vcpu *vcpu)
105105
value64 = HVA2HPA(vcpu->vm->arch_vm.msr_bitmap);
106106
exec_vmwrite64(VMX_MSR_BITMAP_FULL, value64);
107107
pr_dbg("VMX_MSR_BITMAP: 0x%016llx ", value64);
108-
109-
if (!vcpu->guest_msrs) {
110-
vcpu->guest_msrs =
111-
(uint64_t *)calloc(msrs_count, sizeof(uint64_t));
112-
}
113-
114-
ASSERT(vcpu->guest_msrs != NULL, "");
115-
(void)memset(vcpu->guest_msrs, 0U, msrs_count * sizeof(uint64_t));
116108
}
117109

118110
int rdmsr_vmexit_handler(struct vcpu *vcpu)

hypervisor/include/arch/x86/guest/vcpu.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ struct vcpu {
240240
* code.
241241
*/
242242
uint64_t msr_tsc_aux_guest;
243-
uint64_t *guest_msrs;
243+
uint64_t guest_msrs[IDX_MAX_MSR];
244244
#ifdef CONFIG_MTRR_ENABLED
245245
struct mtrr_state mtrr;
246246
#endif

0 commit comments

Comments
 (0)