Skip to content

Commit 887ebf0

Browse files
mingqiangchilijinxia
authored andcommitted
hv: Replace dynamic memory allocation for MSR bitmap
Replace pointer with static memory for msr_bitmap inside structure vm_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>
1 parent 02e7edc commit 887ebf0

File tree

3 files changed

+3
-11
lines changed

3 files changed

+3
-11
lines changed

hypervisor/arch/x86/guest/vm.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -292,9 +292,6 @@ int shutdown_vm(struct vm *vm)
292292
/* Free EPT allocated resources assigned to VM */
293293
destroy_ept(vm);
294294

295-
/* Free MSR bitmap */
296-
free(vm->arch_vm.msr_bitmap);
297-
298295
/* TODO: De-initialize I/O Emulation */
299296
free_io_emulation_resource(vm);
300297

hypervisor/arch/x86/guest/vmsr.c

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,20 +55,14 @@ void init_msr_emulation(struct vcpu *vcpu)
5555
{
5656
uint32_t i;
5757
uint32_t msrs_count = ARRAY_SIZE(emulated_msrs);
58-
void *msr_bitmap;
58+
uint8_t *msr_bitmap;
5959
uint64_t value64;
6060

6161
ASSERT(msrs_count == IDX_MAX_MSR,
6262
"MSR ID should be matched with emulated_msrs");
6363

6464
/*msr bitmap, just allocated/init once, and used for all vm's vcpu*/
6565
if (is_vcpu_bsp(vcpu)) {
66-
67-
/* Allocate and initialize memory for MSR bitmap region*/
68-
vcpu->vm->arch_vm.msr_bitmap = alloc_page();
69-
ASSERT(vcpu->vm->arch_vm.msr_bitmap != NULL, "");
70-
(void)memset(vcpu->vm->arch_vm.msr_bitmap, 0x0U, CPU_PAGE_SIZE);
71-
7266
msr_bitmap = vcpu->vm->arch_vm.msr_bitmap;
7367

7468
for (i = 0U; i < msrs_count; i++) {

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@ enum vm_state {
8888
struct vm_arch {
8989
/* I/O bitmaps A and B for this VM, MUST be 4-Kbyte aligned */
9090
uint8_t io_bitmap[CPU_PAGE_SIZE*2];
91+
/* MSR bitmap region for this VM, MUST be 4-Kbyte aligned */
92+
uint8_t msr_bitmap[CPU_PAGE_SIZE];
9193

9294
uint64_t guest_init_pml4;/* Guest init pml4 */
9395
/* EPT hierarchy for Normal World */
@@ -99,7 +101,6 @@ struct vm_arch {
99101
void *sworld_eptp;
100102
void *m2p; /* machine address to guest physical address */
101103
void *tmp_pg_array; /* Page array for tmp guest paging struct */
102-
void *msr_bitmap; /* MSR bitmap page base address for this VM */
103104
struct acrn_vioapic vioapic; /* Virtual IOAPIC base address */
104105
struct acrn_vpic vpic; /* Virtual PIC */
105106
/**

0 commit comments

Comments
 (0)