[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen master] xen/arm: vcpu: Correctly release resources when a VCPU fails to initialize
commit 911232f02a637f65726d9f7cf7f480f34786b8e1 Author: Julien Grall <julien.grall@xxxxxxxxxx> AuthorDate: Wed Apr 30 20:15:55 2014 +0100 Commit: Ian Campbell <ian.campbell@xxxxxxxxxx> CommitDate: Mon Jun 2 14:38:12 2014 +0100 xen/arm: vcpu: Correctly release resources when a VCPU fails to initialize While I was adding new failing code at the end of the function, I noticed that the vtimers are not freed which messes up all the timers and will crash Xen quickly when the page s reused. Currently neither vcpu_vgic_init nor vcpu_vtimer_init fails, so we are safe for now. With the new GICv3 code, the former function will be able to fail. This will result in a memory leak. Call vcpu_destroy if the initialization has failed. We also need to add a boolean to know if the vtimers are correctly setup as the timer common code doesn't have any safeguard against removing a non-initialized timer. Signed-off-by: Julien Grall <julien.grall@xxxxxxxxxx> Acked-by: Ian Campbell <ian.campbell@xxxxxxxxxx> --- xen/arch/arm/domain.c | 8 ++++++-- xen/arch/arm/vtimer.c | 5 +++++ xen/include/asm-arm/domain.h | 1 + 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c index 2ae6941..04d0cd0 100644 --- a/xen/arch/arm/domain.c +++ b/xen/arch/arm/domain.c @@ -470,12 +470,16 @@ int vcpu_initialise(struct vcpu *v) processor_vcpu_initialise(v); if ( (rc = vcpu_vgic_init(v)) != 0 ) - return rc; + goto fail; if ( (rc = vcpu_vtimer_init(v)) != 0 ) - return rc; + goto fail; return rc; + +fail: + vcpu_destroy(v); + return rc; } void vcpu_destroy(struct vcpu *v) diff --git a/xen/arch/arm/vtimer.c b/xen/arch/arm/vtimer.c index b93153e..7b50826 100644 --- a/xen/arch/arm/vtimer.c +++ b/xen/arch/arm/vtimer.c @@ -77,11 +77,16 @@ int vcpu_vtimer_init(struct vcpu *v) : GUEST_TIMER_VIRT_PPI; t->v = v; + v->arch.vtimer_initialized = 1; + return 0; } void vcpu_timer_destroy(struct vcpu *v) { + if ( !v->arch.vtimer_initialized ) + return; + kill_timer(&v->arch.virt_timer.timer); kill_timer(&v->arch.phys_timer.timer); } diff --git a/xen/include/asm-arm/domain.h b/xen/include/asm-arm/domain.h index b296923..f6cb1c0 100644 --- a/xen/include/asm-arm/domain.h +++ b/xen/include/asm-arm/domain.h @@ -289,6 +289,7 @@ struct arch_vcpu struct vtimer phys_timer; struct vtimer virt_timer; + bool_t vtimer_initialized; } __cacheline_aligned; void vcpu_show_execution_state(struct vcpu *); -- generated by git-patchbot for /home/xen/git/xen.git#master _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxx http://lists.xensource.com/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |