xen: arm: avoid reusing incorrect mappings when walking the p2m.
PATCH v2 1/1 xen: arm: avoid reusing incorrect mappings when walking the p2m.
When we change which PT page we are mapping at a given level then we need to invalidate any cached mappings further down the tree, otherwise we risk using them because their offset might match but be based on a different offset further up the table.
e.g. when remapping first then cur_first_offset and cur_second_offset (which indicate the currently mapped second and third tables respectively) both become invalid
---
v2: Also invalidate cur_first_offset when changing cur_first_page.
Corrected/clarified commit message, this issue isn't really specific to superpages, they just happen to expose it.
--- xen/arch/arm/p2m.c | 4 ++++ 1 file changed, 4 insertions(+)
xen/arch/arm/p2m.c +4 -0
@@ -743,6 +743,8 @@ static int apply_p2m_changes(struct domain *d, goto out; } cur_first_page =p2m_first_level_index (addr); +/* Any mapping further down is now invalid */ + cur_first_offset = cur_second_offset = ~0 ; }/* We only use a 3 level p2m at the moment, so no level 0,
@@ -765,6 +767,8 @@ static int apply_p2m_changes(struct domain *d,if (second)unmap_domain_page (second); second =map_domain_page (first[first_table_offset (addr)].p2m.base); cur_first_offset =first_table_offset (addr); +/* Any mapping further down is now invalid */ + cur_second_offset = ~0 ; }/* else: second already valid */
Signature · 1 line
1.7.10.4
Hi Ian,
Quoted 10 lines · Ian Campbell
When we change which PT page we are mapping at a given level then we need to invalidate any cached mappings further down the tree, otherwise we risk using them because their offset might match but be based on a different offset further up the table.
e.g. when remapping first then
cur_first_offsetandcur_second_offset(which indicate the currently mapped second and third tables respectively) both become invalidSigned-off-by Ian Campbell <[email protected]>
Regards,
Quoted 31 lines
---
v2: Also invalidatecur_first_offsetwhen changingcur_first_page.
Corrected/clarified commit message, this issue isn't really specific to superpages, they just happen to expose it.--- xen/arch/arm/p2m.c | 4 ++++ 1 file changed, 4 insertions(+)xen/arch/arm/p2m.c +4
-0@@ -743,6 +743,8 @@ static int apply_p2m_changes(struct domain *d, goto out; } cur_first_page =p2m_first_level_index (addr); +/* Any mapping further down is now invalid */ + cur_first_offset = cur_second_offset = ~0 ; }/* We only use a 3 level p2m at the moment, so no level 0, @@ -765,6 +767,8 @@ static int apply_p2m_changes(struct domain *d,if (second)unmap_domain_page (second); second =map_domain_page (first[first_table_offset (addr)].p2m.base); cur_first_offset =first_table_offset (addr); +/* Any mapping further down is now invalid */ + cur_second_offset = ~0 ; }/* else: second already valid */
Signature · 1 line
Julien Grall