arm: p2m.c bug-fix: hypervisor hang on __p2m_get_mem_access
PATCH v2 1/1 arm: p2m.c bug-fix: hypervisor hang on __p2m_get_mem_access
When __p2m_get_mem_access gets called, the p2m lock is already taken by either get_page_from_gva or p2m_get_mem_access.
Possible code paths:
1) -> get_page_from_gva
-> p2m_mem_access_check_and_get_page -> __p2m_get_mem_access 2) -> p2m_get_mem_access -> __p2m_get_mem_access
In both cases if __p2m_get_mem_access subsequently gets to call p2m_lookup (happens if !radix_tree_lookup(...)), a hypervisor hang will occur, since p2m_lookup also spin-locks on the p2m lock.
This bug-fix simply replaces the p2m_lookup call from __p2m_get_mem_access with a call to __p2m_lookup.
Following Ian's suggestion, we also add an ASSERT to ensure that the p2m lock is taken upon __p2m_get_mem_access entry.
--- xen/arch/arm/p2m.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
xen/arch/arm/p2m.c +3 -1
@@ -468,6 +468,8 @@ static int __p2m_get_mem_access(struct domain *d, gfn_t gfn,#undef ACCESS }; +ASSERT (spin_is_locked (&p2m->lock)); +/* If no setting was ever set, just return rwx. */ if ( !p2m->mem_access_enabled ) {
@@ -490,7 +492,7 @@ static int __p2m_get_mem_access(struct domain *d, gfn_t gfn,* No setting was found in the Radix tree. Check if the * entry exists in the page-tables. */ -paddr_t maddr =p2m_lookup (d,gfn_x (gfn) <<PAGE_SHIFT ,NULL ); +paddr_t maddr =__p2m_lookup (d,gfn_x (gfn) <<PAGE_SHIFT ,NULL );if (INVALID_PADDR == maddr )return -ESRCH ;
Signature · 1 line
2.5.0
Quoted 14 lines · Corneliu ZUZU
When
__p2m_get_mem_accessgets called, the p2m lock is already taken by eitherget_page_from_gvaorp2m_get_mem_access.Possible code paths:
1) ->get_page_from_gva-> p2m_mem_access_check_and_get_page -> __p2m_get_mem_access 2) -> p2m_get_mem_access -> __p2m_get_mem_accessIn both cases if
__p2m_get_mem_accesssubsequently gets to callp2m_lookup(happens if !radix_tree_lookup(...)), a hypervisor hang will occur, sincep2m_lookupalso spin-locks on the p2m lock.
Quoted 8 lines
This bug-fix simply replaces the
p2m_lookupcall from__p2m_get_mem_access
with a call to__p2m_lookup.Following Ian's suggestion, we also add an ASSERT to ensure that the p2m lock is taken upon
__p2m_get_mem_accessentry.Signed-off-by Corneliu ZUZU <[email protected]>
Acked + applied, thanks.
Quoted 19 lines · Ian Campbell
Quoted 18 lines · Corneliu ZUZU
When
__p2m_get_mem_accessgets called, the p2m lock is already taken by eitherget_page_from_gvaorp2m_get_mem_access.Possible code paths:
1) ->get_page_from_gva-> p2m_mem_access_check_and_get_page -> __p2m_get_mem_access 2) -> p2m_get_mem_access -> __p2m_get_mem_accessIn both cases if
__p2m_get_mem_accesssubsequently gets to callp2m_lookup(happens if !radix_tree_lookup(...)), a hypervisor hang will occur, sincep2m_lookupalso spin-locks on the p2m lock.This bug-fix simply replaces the
p2m_lookupcall from__p2m_get_mem_access
with a call to__p2m_lookup.
Quoted 7 lines
Quoted 4 lines
Following Ian's suggestion, we also add an ASSERT to ensure that the p2m lock is taken upon
__p2m_get_mem_accessentry.Signed-off-by Corneliu ZUZU <[email protected]>Acked + applied, thanks.
I thought this mail was not sent properly (didn't find it any longer on the web (?)) and I resent it just earlier. I figured it must've been the fact that I forgot to put a "Changed since v1" section & that I didn't include an "--in-reply-to" option. Apparently it was actually sent correctly.
Sorry, ignore the last one (which contains a "Changed since v1" section).
Corneliu.
Quoted 27 lines · Corneliu ZUZU
Quoted 19 lines · Ian Campbell
Quoted 18 lines · Corneliu ZUZU
When
__p2m_get_mem_accessgets called, the p2m lock is already taken by eitherget_page_from_gvaorp2m_get_mem_access.Possible code paths:
1) ->get_page_from_gva-> p2m_mem_access_check_and_get_page -> __p2m_get_mem_access 2) -> p2m_get_mem_access -> __p2m_get_mem_accessIn both cases if
__p2m_get_mem_accesssubsequently gets to callp2m_lookup(happens if !radix_tree_lookup(...)), a hypervisor hang will occur, sincep2m_lookupalso spin-locks on the p2m lock.This bug-fix simply replaces the
p2m_lookupcall from__p2m_get_mem_access
with a call to__p2m_lookup.Quoted 7 lines
Quoted 4 lines
Following Ian's suggestion, we also add an ASSERT to ensure that the p2m lock is taken upon
__p2m_get_mem_accessentry.Signed-off-by Corneliu ZUZU <[email protected]>Acked + applied, thanks.
Quoted 6 lines
I thought this mail was not sent properly (didn't find it any longer on the web (?)) and I resent it just earlier.
I figured it must've been the fact that I forgot to put a "Changed since v1" section & that I didn't include an
"--in-reply-to" option. Apparently it was actually sent correctly. Sorry, ignore the last one (which contains a "Changed since v1" section).
OK, please check that what is currently in xen.git#staging is what you think should be there.
Ian.
Quoted 11 lines · Ian Campbell
Quoted 6 lines · Corneliu ZUZU
I thought this mail was not sent properly (didn't find it any longer on the web (?)) and I resent it just earlier.
I figured it must've been the fact that I forgot to put a "Changed since v1" section & that I didn't include an
"--in-reply-to" option. Apparently it was actually sent correctly. Sorry, ignore the last one (which contains a "Changed since v1" section).OK, please check that what is currently in xen.git#staging is what you think should be there.
Ian.
Yep, just checked, the changes are there.
Corneliu.