diff mbox series

[RFC,1/3] x86/setup: Don't skip 2MiB underneath relocated Xen image

Message ID 20200108172500.1419665-1-dwmw2@infradead.org (mailing list archive)
State New, archived
Headers show
Series Live update boot memory management | expand

Commit Message

David Woodhouse Jan. 8, 2020, 5:24 p.m. UTC
From: David Woodhouse <dwmw@amazon.co.uk>

Set 'e' correctly to reflect the location that Xen is actually relocated
to from its default 2MiB location. Not 2MiB below that.

Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
---
 xen/arch/x86/setup.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Comments

Durrant, Paul Jan. 10, 2020, 11:15 a.m. UTC | #1
> -----Original Message-----
> From: Xen-devel <xen-devel-bounces@lists.xenproject.org> On Behalf Of
> David Woodhouse
> Sent: 08 January 2020 17:25
> To: Xen-devel <xen-devel@lists.xenproject.org>
> Cc: Stefano Stabellini <sstabellini@kernel.org>; Julien Grall
> <julien@xen.org>; Wei Liu <wl@xen.org>; Konrad Rzeszutek Wilk
> <konrad.wilk@oracle.com>; George Dunlap <George.Dunlap@eu.citrix.com>;
> Andrew Cooper <andrew.cooper3@citrix.com>; paul@xen.org; Ian Jackson
> <ian.jackson@eu.citrix.com>; Jan Beulich <jbeulich@suse.com>; Roger Pau
> Monné <roger.pau@citrix.com>
> Subject: [Xen-devel] [RFC PATCH 1/3] x86/setup: Don't skip 2MiB underneath
> relocated Xen image
> 
> From: David Woodhouse <dwmw@amazon.co.uk>
> 
> Set 'e' correctly to reflect the location that Xen is actually relocated
> to from its default 2MiB location. Not 2MiB below that.
> 
> Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
> ---
>  xen/arch/x86/setup.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c
> index 501f3f5e4b..47e065e5fe 100644
> --- a/xen/arch/x86/setup.c
> +++ b/xen/arch/x86/setup.c
> @@ -1077,9 +1077,9 @@ void __init noreturn __start_xen(unsigned long
> mbi_p)
>              unsigned long pte_update_limit;
> 
>              /* Select relocation address. */
> -            e = end - reloc_size;
> -            xen_phys_start = e;
> -            bootsym(trampoline_xen_phys_start) = e;
> +            xen_phys_start = end - reloc_size;
> +            e = xen_phys_start + XEN_IMG_OFFSET;
> +            bootsym(trampoline_xen_phys_start) = xen_phys_start;
> 
>              /*
>               * No PTEs pointing above this address are candidates for
> relocation.

Do you not also need to adjust the setting of pte_update_limit that's just out of context below here?

  Paul
David Woodhouse Jan. 10, 2020, 12:15 p.m. UTC | #2
On Fri, 2020-01-10 at 11:15 +0000, Durrant, Paul wrote:
> > -----Original Message-----
> > From: Xen-devel <xen-devel-bounces@lists.xenproject.org> On Behalf
> > Of
> > David Woodhouse
> > Sent: 08 January 2020 17:25
> > To: Xen-devel <xen-devel@lists.xenproject.org>
> > Cc: Stefano Stabellini <sstabellini@kernel.org>; Julien Grall
> > <julien@xen.org>; Wei Liu <wl@xen.org>; Konrad Rzeszutek Wilk
> > <konrad.wilk@oracle.com>; George Dunlap <
> > George.Dunlap@eu.citrix.com>;
> > Andrew Cooper <andrew.cooper3@citrix.com>; paul@xen.org; Ian
> > Jackson
> > <ian.jackson@eu.citrix.com>; Jan Beulich <jbeulich@suse.com>; Roger
> > Pau
> > Monné <roger.pau@citrix.com>
> > Subject: [Xen-devel] [RFC PATCH 1/3] x86/setup: Don't skip 2MiB
> > underneath
> > relocated Xen image
> > 
> > From: David Woodhouse <dwmw@amazon.co.uk>
> > 
> > Set 'e' correctly to reflect the location that Xen is actually
> > relocated
> > to from its default 2MiB location. Not 2MiB below that.
> > 
> > Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
> > ---
> >  xen/arch/x86/setup.c | 8 ++++----
> >  1 file changed, 4 insertions(+), 4 deletions(-)
> > 
> > diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c
> > index 501f3f5e4b..47e065e5fe 100644
> > --- a/xen/arch/x86/setup.c
> > +++ b/xen/arch/x86/setup.c
> > @@ -1077,9 +1077,9 @@ void __init noreturn __start_xen(unsigned
> > long
> > mbi_p)
> >              unsigned long pte_update_limit;
> > 
> >              /* Select relocation address. */
> > -            e = end - reloc_size;
> > -            xen_phys_start = e;
> > -            bootsym(trampoline_xen_phys_start) = e;
> > +            xen_phys_start = end - reloc_size;
> > +            e = xen_phys_start + XEN_IMG_OFFSET;
> > +            bootsym(trampoline_xen_phys_start) = xen_phys_start;
> > 
> >              /*
> >               * No PTEs pointing above this address are candidates
> > for
> > relocation.
> 
> Do you not also need to adjust the setting of pte_update_limit that's
> just out of context below here?

Yes. I missed that when forward-porting to the master branch. Thanks.
diff mbox series

Patch

diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c
index 501f3f5e4b..47e065e5fe 100644
--- a/xen/arch/x86/setup.c
+++ b/xen/arch/x86/setup.c
@@ -1077,9 +1077,9 @@  void __init noreturn __start_xen(unsigned long mbi_p)
             unsigned long pte_update_limit;
 
             /* Select relocation address. */
-            e = end - reloc_size;
-            xen_phys_start = e;
-            bootsym(trampoline_xen_phys_start) = e;
+            xen_phys_start = end - reloc_size;
+            e = xen_phys_start + XEN_IMG_OFFSET;
+            bootsym(trampoline_xen_phys_start) = xen_phys_start;
 
             /*
              * No PTEs pointing above this address are candidates for relocation.
@@ -1096,7 +1096,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, XEN_IMG_OFFSET, _end - _start, 1);
+            move_memory(e, XEN_IMG_OFFSET, _end - _start, 1);
 
             /* Walk initial pagetables, relocating page directory entries. */
             pl4e = __va(__pa(idle_pg_table));