Misc fixes regarding releasing resources on ARM
cover Misc fixes regarding releasing resources on ARM
From: Oleksandr Tyshchenko <[email protected]>
Oleksandr Tyshchenko (2):
xen/arm: vgic: Check for vgic handler to be initialized before
dereferencing it
xen/arm: p2m: Check for p2m->domain to be initialized before releasing
resources
xen/arch/arm/p2m.c | 13 ++++++++++++- xen/arch/arm/vgic.c | 3 ++- 2 files changed, 14 insertions(+), 2 deletions(-)
Signature · 7 lines
2.7.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
PATCH 1/2 xen/arm: vgic: Check for vgic handler to be initialized before dereferencing it
From: Oleksandr Tyshchenko <[email protected]>
Since domain_vgic_free() can be called when the vgic_ops haven't been initialised yet, always check that d->arch.vgic.handler is not a null.
--- xen/arch/arm/vgic.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
xen/arch/arm/vgic.c +2 -1
@@ -187,7 +187,8 @@ void domain_vgic_free(struct domain *d) } } - d->arch.vgic.handler->domain_free (d); +if ( d->arch.vgic.handler ) + d->arch.vgic.handler->domain_free (d);xfree (d->arch.vgic.shared_irqs);xfree (d->arch.vgic.pending_irqs);xfree (d->arch.vgic.allocated_irqs);
Signature · 7 lines
2.7.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [PATCH v1 1/2] xen/arm: vgic: Check for vgic handler to be initialized before dereferencing it
Quoted 6 lines · Oleksandr Tyshchenko
From: Oleksandr Tyshchenko <[email protected]>
Since
domain_vgic_free()can be called when thevgic_opshaven't been initialised yet, always check thatd->arch.vgic.handleris not a null.Signed-off-by Oleksandr Tyshchenko <[email protected]>
There is a code style problem, but I'll fix on commit.
Quoted 21 lines
--- xen/arch/arm/vgic.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)xen/arch/arm/vgic.c +2
-1@@ -187,7 +187,8 @@ void domain_vgic_free(struct domain *d) } } - d->arch.vgic.handler->domain_free (d); +if ( d->arch.vgic.handler ) + d->arch.vgic.handler->domain_free (d);xfree (d->arch.vgic.shared_irqs);xfree (d->arch.vgic.pending_irqs);xfree (d->arch.vgic.allocated_irqs);Signature · 1 line
2.7.4
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
PATCH 2/2 xen/arm: p2m: Check for p2m->domain to be initialized before releasing resources
In reply to Oleksandr TyshchenkoFrom: Oleksandr Tyshchenko <[email protected]>
Since p2m_teardown() can be called when p2m_init() haven't executed yet we might deal with unitialized list "p2m->pages" which leads to crash. To avoid this use back pointer to domain as end-of-initialization indicator.
--- xen/arch/arm/p2m.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)
xen/arch/arm/p2m.c +12 -1
@@ -1219,6 +1219,9 @@ void p2m_teardown(struct domain *d)struct p2m_domain *p2m =p2m_get_hostp2m (d);struct page_info *pg; +if ( !p2m->domain ) +return ; +while ( (pg =page_list_remove_head (&p2m->pages)) )free_domheap_page (pg);
@@ -1230,6 +1233,8 @@ void p2m_teardown(struct domain *d)p2m_free_vmid (d);radix_tree_destroy (&p2m->mem_access_settings,NULL ); + + p2m->domain =NULL ; }int p2m_init (struct domain *d)
@@ -1247,7 +1252,6 @@ int p2m_init(struct domain *d)if ( rc !=0 )return rc; - p2m->domain = d; p2m->max_mapped_gfn =_gfn (0 ); p2m->lowest_mapped_gfn =_gfn (ULONG_MAX );
@@ -1276,6 +1280,13 @@ int p2m_init(struct domain *d)for_each_possible_cpu (cpu) p2m->last_vcpu_ran[cpu] =INVALID_VCPU_ID ; +/* +* Besides getting a domain when we only have the p2m in hand, +* the back pointer to domain is also used in p2m_teardown() +* as an end-of-initialization indicator. +*/ + p2m->domain = d; +return rc; }
Signature · 7 lines
2.7.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [PATCH v1 2/2] xen/arm: p2m: Check for p2m->domain to be initialized before releasing resources
Quoted 16 lines · Oleksandr Tyshchenko
From: Oleksandr Tyshchenko <[email protected]>
Since
p2m_teardown()can be called whenp2m_init()haven't executed yet we might deal with unitialized list "p2m->pages" which leads to crash. To avoid this use back pointer to domain as end-of-initialization indicator.Signed-off-by Oleksandr Tyshchenko <[email protected]>--- xen/arch/arm/p2m.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)xen/arch/arm/p2m.c +0
-0
xen/arch/arm/p2m.c void p2m_teardown(struct domain *d) · line 1220
Quoted 2 lines
xen/arch/arm/p2m.c +0
-0@@ -1219,6 +1219,9 @@ void p2m_teardown(struct domain *d)struct p2m_domain *p2m =p2m_get_hostp2m (d);struct page_info *pg;
The patch looks good. I'll add a comment saying "p2m not actually initialized" here.
Quoted 40 lines
xen/arch/arm/p2m.c +12
-1+if ( !p2m->domain ) +return ; +while ( (pg =page_list_remove_head (&p2m->pages)) )free_domheap_page (pg);@@ -1230,6 +1233,8 @@ void p2m_teardown(struct domain *d)p2m_free_vmid (d);radix_tree_destroy (&p2m->mem_access_settings,NULL ); + + p2m->domain =NULL ; }int p2m_init (struct domain *d)@@ -1247,7 +1252,6 @@ int p2m_init(struct domain *d)if ( rc !=0 )return rc; - p2m->domain = d; p2m->max_mapped_gfn =_gfn (0 ); p2m->lowest_mapped_gfn =_gfn (ULONG_MAX );@@ -1276,6 +1280,13 @@ int p2m_init(struct domain *d)for_each_possible_cpu (cpu) p2m->last_vcpu_ran[cpu] =INVALID_VCPU_ID ; +/* +* Besides getting a domain when we only have the p2m in hand, +* the back pointer to domain is also used in p2m_teardown() +* as an end-of-initialization indicator. +*/ + p2m->domain = d; +return rc; }Signature · 1 line
2.7.4
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
ping
Quoted 15 lines · Oleksandr Tyshchenko
From: Oleksandr Tyshchenko <[email protected]>
Oleksandr Tyshchenko (2):
xen/arm: vgic: Check for vgic handler to be initialized before
dereferencing it
xen/arm: p2m: Check forp2m->domainto be initialized before releasing
resourcesxen/arch/arm/p2m.c | 13 ++++++++++++- xen/arch/arm/vgic.c | 3 ++- 2 files changed, 14 insertions(+), 2 deletions(-)--
2.7.4
Signature · 8 lines
Regards, Oleksandr Tyshchenko _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Hi Oleksandr,
Quoted 1 line · Oleksandr Tyshchenko
ping
Sorry I was on holidays, I will try to have a look today.
Cheers,
Quoted 21 lines
Quoted 15 lines · Oleksandr Tyshchenko
From: Oleksandr Tyshchenko <[email protected]>
Oleksandr Tyshchenko (2):
xen/arm: vgic: Check for vgic handler to be initialized before
dereferencing it
xen/arm: p2m: Check forp2m->domainto be initialized before releasing
resourcesxen/arch/arm/p2m.c | 13 ++++++++++++- xen/arch/arm/vgic.c | 3 ++- 2 files changed, 14 insertions(+), 2 deletions(-)--
2.7.4
Signature · 6 lines
Julien Grall _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Quoted 1 line · Oleksandr Tyshchenko
From: Oleksandr Tyshchenko <[email protected]>
Thanks for the fixes, I committed the two patches.
Quoted 6 lines
Oleksandr Tyshchenko (2):
xen/arm: vgic: Check for vgic handler to be initialized before
dereferencing it
xen/arm: p2m: Check forp2m->domainto be initialized before releasing
resources
Quoted 7 lines
xen/arch/arm/p2m.c | 13 ++++++++++++- xen/arch/arm/vgic.c | 3 ++- 2 files changed, 14 insertions(+), 2 deletions(-)Signature · 1 line
2.7.4
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel