Skip to contentSkip to conversation

x86/shadow: correct GFN use by sh_unshadow_for_p2m_change()

PATCH In review Jan Beulich 2 participants 2 messages Oct 28, 2020 – Oct 29, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/shadow: correct GFN use by sh_unshadow_for_p2m_change()

Luckily sh_remove_all_mappings()'s use of the parameter is limited to generation of log messages. Nevertheless we'd better pass correct GFNs around:
- the incoming GFN, when replacing a large page, may not be large page aligned,
- incrementing by page-size-scaled values can't be right.

xen/arch/x86/mm/shadow/common.c +3 -2
@@ -3115,6 +3115,8 @@ static void sh_unshadow_for_p2m_change(s
                  && mfn_valid(nmfn) )
                 npte = map_domain_page(nmfn);
 
+            gfn &= ~(L1_PAGETABLE_ENTRIES - 1);
+
             for ( i = 0; i < L1_PAGETABLE_ENTRIES; i++ )
             {
                 if ( !npte
@@ -3123,8 +3125,7 @@ static void sh_unshadow_for_p2m_change(s
                 {
                     /* This GFN->MFN mapping has gone away */
                     sh_remove_all_shadows_and_parents(d, omfn);
-                    if ( sh_remove_all_mappings(d, omfn,
-                                                _gfn(gfn + (i << PAGE_SHIFT))) )
+                    if ( sh_remove_all_mappings(d, omfn, _gfn(gfn + i)) )
                         cpumask_or(&flushmask, &flushmask, d->dirty_cpumask);
                 }
                 omfn = mfn_add(omfn, 1);
Reviewed-by on v1 1/1
#1 lore raw
Quoted 8 lines · Jan Beulich

Luckily sh_remove_all_mappings()'s use of the parameter is limited to generation of log messages. Nevertheless we'd better pass correct GFNs around:
- the incoming GFN, when replacing a large page, may not be large page aligned,
- incrementing by page-size-scaled values can't be right.

Thanks!

Tim.