Previously we weren't freeing them at all. Additionally, if we failed part of the way through a create_guest_pcore, we'd leak the VMCS we allocated.
Signed-off-by: Barret Rhoden <[email protected]> --- kern/arch/x86/vmm/intel/vmx.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/kern/arch/x86/vmm/intel/vmx.c b/kern/arch/x86/vmm/intel/vmx.c index 485bb272571b..2608e821d293 100644 --- a/kern/arch/x86/vmm/intel/vmx.c +++ b/kern/arch/x86/vmm/intel/vmx.c @@ -720,7 +720,7 @@ vmx_alloc_vmcs(void) static void vmx_free_vmcs(struct vmcs *vmcs) { - //free_pages((unsigned long)vmcs, vmcs_config.order); + free_cont_pages(vmcs, vmcs_config.order); } /* @@ -1124,7 +1124,7 @@ static void vmx_setup_vmcs(struct guest_pcore *gpc) struct guest_pcore *create_guest_pcore(struct proc *p, struct vmm_gpcore_init *gpci) { - ERRSTACK(1); + ERRSTACK(2); struct guest_pcore *gpc = kmalloc(sizeof(struct guest_pcore), MEM_WAIT); if (!gpc) @@ -1140,8 +1140,11 @@ struct guest_pcore *create_guest_pcore(struct proc *p, /* Warning: p here is uncounted (weak) reference */ gpc->proc = p; gpc->vmcs = vmx_alloc_vmcs(); + if (waserror()) { + vmx_free_vmcs(gpc->vmcs); + nexterror(); + } printd("%d: gpc->vmcs is %p\n", core_id(), gpc->vmcs); - gpc->cpu = -1; vmx_load_guest_pcore(gpc); @@ -1152,6 +1155,7 @@ struct guest_pcore *create_guest_pcore(struct proc *p, gpc->posted_irq_desc = gpci->posted_irq_desc; poperror(); + poperror(); return gpc; } -- 2.8.0.rc3.226.g39d4020 -- You received this message because you are subscribed to the Google Groups "Akaros" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. For more options, visit https://groups.google.com/d/optout.
