diff mbox

[Xen-devel,v2,5/4] xen: arm: ensure that the boot code is <4K in size

Message ID 1405702643.14973.5.camel@kazak.uk.xensource.com
State New
Headers show

Commit Message

Ian Campbell July 18, 2014, 4:57 p.m. UTC
This avoids having to deal with the 1:1 boot mapping crossing a
section or page boundary.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
---
 xen/arch/arm/arm32/head.S |    3 +++
 xen/arch/arm/arm64/head.S |    3 +++
 xen/arch/arm/xen.lds.S    |    6 ++++++
 3 files changed, 12 insertions(+)

Comments

Andrew Cooper July 18, 2014, 5:06 p.m. UTC | #1
On 18/07/14 17:57, Ian Campbell wrote:
> This avoids having to deal with the 1:1 boot mapping crossing a
> section or page boundary.
>
> Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
> ---
>  xen/arch/arm/arm32/head.S |    3 +++
>  xen/arch/arm/arm64/head.S |    3 +++
>  xen/arch/arm/xen.lds.S    |    6 ++++++
>  3 files changed, 12 insertions(+)
>
> diff --git a/xen/arch/arm/arm32/head.S b/xen/arch/arm/arm32/head.S
> index caf7934..b4c3973 100644
> --- a/xen/arch/arm/arm32/head.S
> +++ b/xen/arch/arm/arm32/head.S
> @@ -458,6 +458,9 @@ fail:   PRINT("- Boot failed -\r\n")
>  1:      wfe
>          b     1b
>  
> +.globl _end_boot
> +_end_boot:
> +

GLOBAL() should be in scope (although git grep shows that some use of
.global has slipped back into the arm .S files)

~Andrew

>  /* Copy Xen to new location and switch TTBR
>   * r1:r0       ttbr
>   * r2          source address
> diff --git a/xen/arch/arm/arm64/head.S b/xen/arch/arm/arm64/head.S
> index f28b74a..a52e2e4 100644
> --- a/xen/arch/arm/arm64/head.S
> +++ b/xen/arch/arm/arm64/head.S
> @@ -487,6 +487,9 @@ fail:   PRINT("- Boot failed -\r\n")
>  1:      wfe
>          b     1b
>  
> +.globl _end_boot
> +_end_boot:
> +
>  /* Copy Xen to new location and switch TTBR
>   * x0    ttbr
>   * x1    source address
> diff --git a/xen/arch/arm/xen.lds.S b/xen/arch/arm/xen.lds.S
> index be55dad..079e085 100644
> --- a/xen/arch/arm/xen.lds.S
> +++ b/xen/arch/arm/xen.lds.S
> @@ -178,3 +178,9 @@ SECTIONS
>    .stab.indexstr 0 : { *(.stab.indexstr) }
>    .comment 0 : { *(.comment) }
>  }
> +
> +/*
> + * We require that Xen is loaded at a 4K boundary, so this ensures that any
> + * code running on the boot time identity map cannot cross a section boundary.
> + */
> +ASSERT( _end_boot - start <= PAGE_SIZE, "Boot code is larger than 4K")
Julien Grall July 20, 2014, 9:39 p.m. UTC | #2
Hi Ian,

On 18/07/14 17:57, Ian Campbell wrote:
> This avoids having to deal with the 1:1 boot mapping crossing a
> section or page boundary.

Regardless Andrew's comment:

Acked-by: Julien Grall <julien.grall@linaro.org>

Regards,

> Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
> ---
>   xen/arch/arm/arm32/head.S |    3 +++
>   xen/arch/arm/arm64/head.S |    3 +++
>   xen/arch/arm/xen.lds.S    |    6 ++++++
>   3 files changed, 12 insertions(+)
>
> diff --git a/xen/arch/arm/arm32/head.S b/xen/arch/arm/arm32/head.S
> index caf7934..b4c3973 100644
> --- a/xen/arch/arm/arm32/head.S
> +++ b/xen/arch/arm/arm32/head.S
> @@ -458,6 +458,9 @@ fail:   PRINT("- Boot failed -\r\n")
>   1:      wfe
>           b     1b
>
> +.globl _end_boot
> +_end_boot:
> +
>   /* Copy Xen to new location and switch TTBR
>    * r1:r0       ttbr
>    * r2          source address
> diff --git a/xen/arch/arm/arm64/head.S b/xen/arch/arm/arm64/head.S
> index f28b74a..a52e2e4 100644
> --- a/xen/arch/arm/arm64/head.S
> +++ b/xen/arch/arm/arm64/head.S
> @@ -487,6 +487,9 @@ fail:   PRINT("- Boot failed -\r\n")
>   1:      wfe
>           b     1b
>
> +.globl _end_boot
> +_end_boot:
> +
>   /* Copy Xen to new location and switch TTBR
>    * x0    ttbr
>    * x1    source address
> diff --git a/xen/arch/arm/xen.lds.S b/xen/arch/arm/xen.lds.S
> index be55dad..079e085 100644
> --- a/xen/arch/arm/xen.lds.S
> +++ b/xen/arch/arm/xen.lds.S
> @@ -178,3 +178,9 @@ SECTIONS
>     .stab.indexstr 0 : { *(.stab.indexstr) }
>     .comment 0 : { *(.comment) }
>   }
> +
> +/*
> + * We require that Xen is loaded at a 4K boundary, so this ensures that any
> + * code running on the boot time identity map cannot cross a section boundary.
> + */
> +ASSERT( _end_boot - start <= PAGE_SIZE, "Boot code is larger than 4K")
>
Ian Campbell July 21, 2014, 10:39 a.m. UTC | #3
On Fri, 2014-07-18 at 18:06 +0100, Andrew Cooper wrote:
> On 18/07/14 17:57, Ian Campbell wrote:
> > This avoids having to deal with the 1:1 boot mapping crossing a
> > section or page boundary.
> >
> > Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
> > ---
> >  xen/arch/arm/arm32/head.S |    3 +++
> >  xen/arch/arm/arm64/head.S |    3 +++
> >  xen/arch/arm/xen.lds.S    |    6 ++++++
> >  3 files changed, 12 insertions(+)
> >
> > diff --git a/xen/arch/arm/arm32/head.S b/xen/arch/arm/arm32/head.S
> > index caf7934..b4c3973 100644
> > --- a/xen/arch/arm/arm32/head.S
> > +++ b/xen/arch/arm/arm32/head.S
> > @@ -458,6 +458,9 @@ fail:   PRINT("- Boot failed -\r\n")
> >  1:      wfe
> >          b     1b
> >  
> > +.globl _end_boot
> > +_end_boot:
> > +
> 
> GLOBAL() should be in scope (although git grep shows that some use of
> .global has slipped back into the arm .S files)

Thanks, I only knew about ENTRY which didn't seem appropriate. I don't
think this warrants a resend so I'll do it on commit unless someone
objects to that.

Ian.
Ian Campbell July 21, 2014, 11:21 a.m. UTC | #4
On Mon, 2014-07-21 at 11:39 +0100, Ian Campbell wrote:
> On Fri, 2014-07-18 at 18:06 +0100, Andrew Cooper wrote:
> > On 18/07/14 17:57, Ian Campbell wrote:
> > > This avoids having to deal with the 1:1 boot mapping crossing a
> > > section or page boundary.
> > >
> > > Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
> > > ---
> > >  xen/arch/arm/arm32/head.S |    3 +++
> > >  xen/arch/arm/arm64/head.S |    3 +++
> > >  xen/arch/arm/xen.lds.S    |    6 ++++++
> > >  3 files changed, 12 insertions(+)
> > >
> > > diff --git a/xen/arch/arm/arm32/head.S b/xen/arch/arm/arm32/head.S
> > > index caf7934..b4c3973 100644
> > > --- a/xen/arch/arm/arm32/head.S
> > > +++ b/xen/arch/arm/arm32/head.S
> > > @@ -458,6 +458,9 @@ fail:   PRINT("- Boot failed -\r\n")
> > >  1:      wfe
> > >          b     1b
> > >  
> > > +.globl _end_boot
> > > +_end_boot:
> > > +
> > 
> > GLOBAL() should be in scope (although git grep shows that some use of
> > .global has slipped back into the arm .S files)
> 
> Thanks, I only knew about ENTRY which didn't seem appropriate. I don't
> think this warrants a resend so I'll do it on commit unless someone
> objects to that.

I hadn't spotted Julien's comments on #2, so there will need to be a
respin anyway, I'll fix this for that.

Ian.
diff mbox

Patch

diff --git a/xen/arch/arm/arm32/head.S b/xen/arch/arm/arm32/head.S
index caf7934..b4c3973 100644
--- a/xen/arch/arm/arm32/head.S
+++ b/xen/arch/arm/arm32/head.S
@@ -458,6 +458,9 @@  fail:   PRINT("- Boot failed -\r\n")
 1:      wfe
         b     1b
 
+.globl _end_boot
+_end_boot:
+
 /* Copy Xen to new location and switch TTBR
  * r1:r0       ttbr
  * r2          source address
diff --git a/xen/arch/arm/arm64/head.S b/xen/arch/arm/arm64/head.S
index f28b74a..a52e2e4 100644
--- a/xen/arch/arm/arm64/head.S
+++ b/xen/arch/arm/arm64/head.S
@@ -487,6 +487,9 @@  fail:   PRINT("- Boot failed -\r\n")
 1:      wfe
         b     1b
 
+.globl _end_boot
+_end_boot:
+
 /* Copy Xen to new location and switch TTBR
  * x0    ttbr
  * x1    source address
diff --git a/xen/arch/arm/xen.lds.S b/xen/arch/arm/xen.lds.S
index be55dad..079e085 100644
--- a/xen/arch/arm/xen.lds.S
+++ b/xen/arch/arm/xen.lds.S
@@ -178,3 +178,9 @@  SECTIONS
   .stab.indexstr 0 : { *(.stab.indexstr) }
   .comment 0 : { *(.comment) }
 }
+
+/*
+ * We require that Xen is loaded at a 4K boundary, so this ensures that any
+ * code running on the boot time identity map cannot cross a section boundary.
+ */
+ASSERT( _end_boot - start <= PAGE_SIZE, "Boot code is larger than 4K")