diff mbox series

[7/9] xen/arm64: head: Rework PRINT() to work when the string is not withing +/- 1MB

Message ID 20230625204907.57291-8-julien@xen.org (mailing list archive)
State New, archived
Headers show
Series xen/arm: Enable UBSAN support | expand

Commit Message

Julien Grall June 25, 2023, 8:49 p.m. UTC
From: Julien Grall <jgrall@amazon.com>

The instruction ADR is able to load an address of a symbol that is
within the range +/- 1 MB of the instruction.

While today Xen is quite small (~1MB), it could grow up to 2MB in the
current setup. So there is no guarantee that the instruction can
load the string address (stored in rodata).

So replace the instruction ADR with the pseudo-instruction ADR_L
which is able to handle symbol within the range +/- 4GB.

Signed-off-by: Julien Grall <jgrall@amazon.com>
---
 xen/arch/arm/arm64/head.S | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Michal Orzel June 26, 2023, 11:50 a.m. UTC | #1
On 25/06/2023 22:49, Julien Grall wrote:
> 
> 
> From: Julien Grall <jgrall@amazon.com>
> 
> The instruction ADR is able to load an address of a symbol that is
> within the range +/- 1 MB of the instruction.
> 
> While today Xen is quite small (~1MB), it could grow up to 2MB in the
> current setup. So there is no guarantee that the instruction can
> load the string address (stored in rodata).
> 
> So replace the instruction ADR with the pseudo-instruction ADR_L
> which is able to handle symbol within the range +/- 4GB.
> 
> Signed-off-by: Julien Grall <jgrall@amazon.com>
Reviewed-by: Michal Orzel <michal.orzel@amd.com>

~Michal
Henry Wang June 26, 2023, 2:44 p.m. UTC | #2
Hi Julien,

> -----Original Message-----
> Subject: [PATCH 7/9] xen/arm64: head: Rework PRINT() to work when the
> string is not withing +/- 1MB
> 
> From: Julien Grall <jgrall@amazon.com>
> 
> The instruction ADR is able to load an address of a symbol that is
> within the range +/- 1 MB of the instruction.
> 
> While today Xen is quite small (~1MB), it could grow up to 2MB in the
> current setup. So there is no guarantee that the instruction can
> load the string address (stored in rodata).
> 
> So replace the instruction ADR with the pseudo-instruction ADR_L
> which is able to handle symbol within the range +/- 4GB.
> 
> Signed-off-by: Julien Grall <jgrall@amazon.com>

Reviewed-by: Henry Wang <Henry.Wang@arm.com>

Kind regards,
Henry
diff mbox series

Patch

diff --git a/xen/arch/arm/arm64/head.S b/xen/arch/arm/arm64/head.S
index c9e2e36506d9..38f896bdb8e2 100644
--- a/xen/arch/arm/arm64/head.S
+++ b/xen/arch/arm/arm64/head.S
@@ -90,7 +90,7 @@ 
  */
 #define PRINT(_s)          \
         mov   x3, lr ;     \
-        adr   x0, 98f ;    \
+        adr_l x0, 98f ;    \
         bl    puts    ;    \
         mov   lr, x3 ;     \
         RODATA_STR(98, _s)