]> xenbits.xensource.com Git - xen.git/commitdiff
xen/arm: linker: The identitymap check should cover the whole .text.header
authorJulien Grall <jgrall@amazon.com>
Thu, 12 Jan 2023 22:07:42 +0000 (22:07 +0000)
committerJulien Grall <julien@xen.org>
Thu, 12 Jan 2023 22:09:33 +0000 (22:09 +0000)
At the moment, we are only checking that only some part of .text.header
is part of the identity mapping. However, this doesn't take into account
the literal pool which will be located at the end of the section.

While we could try to avoid using a literal pool, in the near future we
will also want to use an identity mapping for switch_ttbr().

Not everything in .text.header requires to be part of the identity
mapping. But it is below a page size (i.e. 4KB) so take a shortcut and
check that .text.header is smaller than a page size.

With that _end_boot can be removed as it is now unused. Take the
opportunity to avoid assuming that a page size is always 4KB in the
error message and comment.

Signed-off-by: Julien Grall <jgrall@amazon.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
xen/arch/arm/arm32/head.S
xen/arch/arm/arm64/head.S
xen/arch/arm/xen.lds.S

index a558c2a6876e8fab51a0c26fb505688e8cf087ef..5c1044710386417f8c59b102134a75160d4ab93a 100644 (file)
@@ -659,8 +659,6 @@ fail:   PRINT("- Boot failed -\r\n")
         b     1b
 ENDPROC(fail)
 
-GLOBAL(_end_boot)
-
 /*
  * Switch TTBR
  * r1:r0       ttbr
index ad014716db6f0767cdf30d6ca174e3dc8f528798..4a3f87117c8308b63ea3999b1928dba26575959b 100644 (file)
@@ -811,8 +811,6 @@ fail:   PRINT("- Boot failed -\r\n")
         b     1b
 ENDPROC(fail)
 
-GLOBAL(_end_boot)
-
 /*
  * Switch TTBR
  *
index ae8c3b4c6c5f2ef18567881b721cf1d850f933cf..3f7ebd19f3ed826a37360b2de678f142da4c07e2 100644 (file)
@@ -32,7 +32,9 @@ SECTIONS
   _start = .;
   .text : {
        _stext = .;             /* Text section */
+       _idmap_start = .;
        *(.text.header)
+       _idmap_end = .;
 
        *(.text.cold)
        *(.text.unlikely .text.*_unlikely .text.unlikely.*)
@@ -225,10 +227,12 @@ SECTIONS
 }
 
 /*
- * 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.
+ * We require that Xen is loaded at a page boundary, so this ensures that any
+ * code running on the identity map cannot cross a section boundary.
  */
-ASSERT( _end_boot - start <= PAGE_SIZE, "Boot code is larger than 4K")
+ASSERT(IS_ALIGNED(_idmap_start, PAGE_SIZE), "_idmap_start should be page-aligned")
+ASSERT(_idmap_end - _idmap_start <= PAGE_SIZE, "Identity mapped code is larger than a page size")
+
 /*
  * __init_[begin|end] MUST be at word size boundary otherwise we cannot
  * write fault instructions in the space properly.