[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 2/3] x86/boot: Drop move_memory() and use memcpy() directly


  • To: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Tue, 7 Dec 2021 13:03:42 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=xHUAhCeK1kL/kJdsZid52HlaARWOovktGdg7hB6Bpto=; b=nJfNNnzyGRaDlwhjB/dox+Md1i0ix9UEhidcPdVsP3RgeiNFUTypwb65L+x8nlAH6D03rFDxDdttwMJByf2iPVaY/yx+BwnQcFk0jfcdt6dnhKTcjtOQuir9M9C8L6XW/fBCvTN6xggp/RgPFoyi0FoKAxUlUE8kEjI1yNTGc2jCR9mjsjNBUEnHwnHgR40VI6ChtFm6EOfccdNIErOj237EojjKr/DSKEOp/WrOU1Ej5rGRt4Zh1TDSMuJBuhL4UJZ+L16RJ2wxTTWdvsIbD3dyGCIKN9dl4pHz/JqZBEED3ZUOX4Y6WpHCfwcfdR4tLtPyayWlN9gCud0VYJzA8A==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HtqV/VXmU9ObNoycZeqJVmZpGAcHkpxPAkM9uNb0FzKm5DwZLT2VBlm9cCOcBwa1x5BvNj8KOJjKT3Llirvb4Nmya/9y9cp7IiQwcI9zUKQETpzIbmXRDN9QHVyMKMJKsrV8h8o9+8tACningpfO1IPJSw04wPtDKby6pwYbw3/6SYkCfk35sh4nKi1uZCoaPUws1lkF36PGAMEsQgFErPW8oqJKM0Mv/TmSQygehsAj4XFVnlzBVP8YlJLhp0tfkEwN8rXkKb6qPGqJzQ6lEGFysnckIq1rnHEzD9+h3veQ5PL67aopT+W/3YlMM2ME4NbXNawp+qiQspXNOUejQw==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Roger Pau Monné <roger.pau@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Tue, 07 Dec 2021 12:03:58 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 07.12.2021 11:53, Andrew Cooper wrote:
> @@ -1243,7 +1196,7 @@ void __init noreturn __start_xen(unsigned long mbi_p)
>               * data until after we have switched to the relocated pagetables!
>               */
>              barrier();
> -            move_memory(e, XEN_IMG_OFFSET, _end - _start, 1);
> +            memcpy(__va(__pa(_start)), _start, _end - _start);
>  
>              /* Walk idle_pg_table, relocating non-leaf entries. */
>              pl4e = __va(__pa(idle_pg_table));
> @@ -1300,8 +1253,6 @@ void __init noreturn __start_xen(unsigned long mbi_p)
>                     "1" (__va(__pa(cpu0_stack))), "2" (STACK_SIZE / 8)
>                  : "memory" );
>  
> -            bootstrap_map(NULL);
> -
>              printk("New Xen image base address: %#lx\n", xen_phys_start);
>          }

This bootstrap_map() must have been dead code already before, except
for the "keep" argument above needlessly having got passed as 1? Afaict
passing 1 was pointless without using the function's return value.

> @@ -1325,9 +1276,10 @@ void __init noreturn __start_xen(unsigned long mbi_p)
>                   (headroom ||
>                    ((end - size) >> PAGE_SHIFT) > mod[j].mod_start) )
>              {
> -                move_memory(end - size + headroom,
> -                            (uint64_t)mod[j].mod_start << PAGE_SHIFT,
> -                            mod[j].mod_end, 0);
> +                memcpy(__va(end - size + headroom),
> +                       __va((uint64_t)mod[j].mod_start << PAGE_SHIFT),
> +                       mod[j].mod_end);

I'm not convinced this can be memcpy() - consider_modules() specifically
allows for the current module's source and destination areas to overlap.
See also the comment ahead of its invocation a few lines up from here.

I'm also not convinced we have the source range (fully) direct-mapped at
this point. Only full superpages have been mapped so far, and only those
for the current or higher address E820 entries (plus of course the pre-
built mappings of the space below 1Gb [PREBUILT_MAP_LIMIT]) located
below 4Gb.

As to the 2nd argument - if this can indeed be converted in the first
place, may I suggest to also switch to using pfn_to_paddr()?

Jan




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.