All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] x86/shadow: correct GFN use by sh_unshadow_for_p2m_change()
@ 2020-10-28 15:42 Jan Beulich
  2020-10-29 20:52 ` Tim Deegan
  0 siblings, 1 reply; 2+ messages in thread
From: Jan Beulich @ 2020-10-28 15:42 UTC (permalink / raw)
  To: xen-devel
  Cc: Tim Deegan, George Dunlap, Andrew Cooper, Wei Liu, Roger Pau Monné

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.

Signed-off-by: Jan Beulich <jbeulich@suse.com>

--- a/xen/arch/x86/mm/shadow/common.c
+++ b/xen/arch/x86/mm/shadow/common.c
@@ -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);


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] x86/shadow: correct GFN use by sh_unshadow_for_p2m_change()
  2020-10-28 15:42 [PATCH] x86/shadow: correct GFN use by sh_unshadow_for_p2m_change() Jan Beulich
@ 2020-10-29 20:52 ` Tim Deegan
  0 siblings, 0 replies; 2+ messages in thread
From: Tim Deegan @ 2020-10-29 20:52 UTC (permalink / raw)
  To: Jan Beulich
  Cc: xen-devel, George Dunlap, Andrew Cooper, Wei Liu, Roger Pau Monné

At 16:42 +0100 on 28 Oct (1603903365), Jan Beulich wrote:
> 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.
> 
> Signed-off-by: Jan Beulich <jbeulich@suse.com>

Reviewed-by: Tim Deegan <tim@xen.org>

Thanks!

Tim.


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-10-29 20:52 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-28 15:42 [PATCH] x86/shadow: correct GFN use by sh_unshadow_for_p2m_change() Jan Beulich
2020-10-29 20:52 ` Tim Deegan

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.