]> xenbits.xensource.com Git - xen.git/commitdiff
x86/boot: Simplify address calculations in move_memory()
authorAndrew Cooper <andrew.cooper3@citrix.com>
Tue, 22 Oct 2024 20:08:53 +0000 (21:08 +0100)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Wed, 23 Oct 2024 09:27:36 +0000 (10:27 +0100)
Given that soffs is the offset into the 2M superpage,

  start = (src - soffs) >> PAGE_SIFT

is a complicated expression for the frame address of the containing superpage.
Except, start is converted straight back to a byte address to use, so the
shifting is unnecessary too.

The only thing done with the mapped pointer is to have soffs added back on for
the memmove() call.  bootstrap_map_addr() passes through the offset, so we can
pass src directly in and simplify the memmove() call too.  For the end mapping
address, this simplifies to just src + sz too.

The same reasoning holds for dst and doffs.

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Daniel P. Smith <dpsmith@apertussolutions.com>
xen/arch/x86/setup.c

index 1199df988db3c2f60769cd476f6e9f027769de1f..ce28e77060cfdb9a4b6fc4710a787abe262d2b2a 100644 (file)
@@ -492,31 +492,26 @@ static void __init move_memory(
 
     while ( size )
     {
-        unsigned int start /* frame */;
         unsigned int end   /* mapsz */;
         unsigned int soffs = src & mask;
         unsigned int doffs = dst & mask;
         unsigned int sz;
         void *d, *s;
 
-        start = (src - soffs) >> PAGE_SHIFT;
         end = soffs + size;
         if ( end > blksz )
             end = blksz;
         sz = end - soffs;
-        s = bootstrap_map_addr(pfn_to_paddr(start),
-                               pfn_to_paddr(start) + end);
+        s = bootstrap_map_addr(src, src + sz);
 
-        start = (dst - doffs) >> PAGE_SHIFT;
         end = doffs + size;
         if ( end > blksz )
             end = blksz;
         if ( sz > end - doffs )
             sz = end - doffs;
-        d = bootstrap_map_addr(pfn_to_paddr(start),
-                               pfn_to_paddr(start) + end);
+        d = bootstrap_map_addr(dst, dst + sz);
 
-        memmove(d + doffs, s + soffs, sz);
+        memmove(ds, sz);
 
         dst += sz;
         src += sz;