int vcpu_vendor_cell_init(struct cell *cell)
{
+ int err = -ENOMEM;
u64 flags;
- int err;
/* allocate iopm (two 4-K pages + 3 bits) */
cell->svm.iopm = page_alloc(&mem_pool, 3);
if (!cell->svm.iopm)
- return -ENOMEM;
+ return err;
/* build root NPT of cell */
cell->svm.npt_structs.root_paging = npt_paging;
cell->svm.npt_structs.root_table = page_alloc(&mem_pool, 1);
if (!cell->svm.npt_structs.root_table)
- return -ENOMEM;
+ goto err_free_iopm;
if (!has_avic) {
/*
flags,
PAGING_NON_COHERENT);
}
+ if (err)
+ goto err_free_root_table;
+
+ return 0;
+
+err_free_root_table:
+ page_free(&mem_pool, cell->svm.npt_structs.root_table, 1);
+err_free_iopm:
+ page_free(&mem_pool, cell->svm.iopm, 3);
return err;
}
int vcpu_vendor_cell_init(struct cell *cell)
{
+ int err = -ENOMEM;
+
/* allocate io_bitmap */
cell->vmx.io_bitmap = page_alloc(&mem_pool, 2);
if (!cell->vmx.io_bitmap)
- return -ENOMEM;
+ return err;
/* build root EPT of cell */
cell->vmx.ept_structs.root_paging = ept_paging;
cell->vmx.ept_structs.root_table = page_alloc(&mem_pool, 1);
if (!cell->vmx.ept_structs.root_table)
- return -ENOMEM;
+ goto err_free_io_bitmap;
+
+ err = paging_create(&cell->vmx.ept_structs,
+ paging_hvirt2phys(apic_access_page),
+ PAGE_SIZE, XAPIC_BASE,
+ EPT_FLAG_READ | EPT_FLAG_WRITE | EPT_FLAG_WB_TYPE,
+ PAGING_NON_COHERENT);
+ if (err)
+ goto err_free_root_table;
+
+ return 0;
+
+err_free_root_table:
+ page_free(&mem_pool, cell->vmx.ept_structs.root_table, 1);
+err_free_io_bitmap:
+ page_free(&mem_pool, cell->vmx.io_bitmap, 2);
- return paging_create(&cell->vmx.ept_structs,
- paging_hvirt2phys(apic_access_page),
- PAGE_SIZE, XAPIC_BASE,
- EPT_FLAG_READ|EPT_FLAG_WRITE|EPT_FLAG_WB_TYPE,
- PAGING_NON_COHERENT);
+ return err;
}
int vcpu_map_memory_region(struct cell *cell,