llvm's integrated assembler cannot handle immediate values which are
calculated with two local labels:
arch/s390/purgatory/head.S:139:11: error: invalid operand for instruction
aghi %r8,-(.base_crash-purgatory_start)
Workaround this by partially rewriting the code.
Signed-off-by: Heiko Carstens <[email protected]>
---
arch/s390/purgatory/head.S | 29 ++++++++++++++++++++++-------
1 file changed, 22 insertions(+), 7 deletions(-)
diff --git a/arch/s390/purgatory/head.S b/arch/s390/purgatory/head.S
index 3d1c31e0cf3d..ac1a27a20b66 100644
--- a/arch/s390/purgatory/head.S
+++ b/arch/s390/purgatory/head.S
@@ -44,11 +44,14 @@
.endm
.macro MEMSWAP dst,src,buf,len
-10: cghi \len,bufsz
+10: larl %r0,purgatory_end
+ larl %r1,stack
+ slgr %r0,%r1
+ cgr \len,%r0
jh 11f
lgr %r4,\len
j 12f
-11: lghi %r4,bufsz
+11: lgr %r4,%r0
12: MEMCPY \buf,\dst,%r4
MEMCPY \dst,\src,%r4
@@ -135,12 +138,18 @@ ENTRY(purgatory_start)
.start_crash_kernel:
/* Location of purgatory_start in crash memory */
+ larl %r0,.base_crash
+ larl %r1,purgatory_start
+ slgr %r0,%r1
lgr %r8,%r13
- aghi %r8,-(.base_crash-purgatory_start)
+ sgr %r8,%r0
/* Destination for this code i.e. end of memory to be swapped. */
+ larl %r0,purgatory_end
+ larl %r1,purgatory_start
+ slgr %r0,%r1
lg %r9,crash_size-.base_crash(%r13)
- aghi %r9,-(purgatory_end-purgatory_start)
+ sgr %r9,%r0
/* Destination in crash memory, i.e. same as r9 but in crash memory. */
lg %r10,crash_start-.base_crash(%r13)
@@ -149,15 +158,19 @@ ENTRY(purgatory_start)
/* Buffer location (in crash memory) and size. As the purgatory is
* behind the point of no return it can re-use the stack as buffer.
*/
- lghi %r11,bufsz
+ larl %r11,purgatory_end
larl %r12,stack
+ slgr %r11,%r12
MEMCPY %r12,%r9,%r11 /* dst -> (crash) buf */
MEMCPY %r9,%r8,%r11 /* self -> dst */
/* Jump to new location. */
lgr %r7,%r9
- aghi %r7,.jump_to_dst-purgatory_start
+ larl %r0,.jump_to_dst
+ larl %r1,purgatory_start
+ slgr %r0,%r1
+ agr %r7,%r0
br %r7
.jump_to_dst:
@@ -169,7 +182,9 @@ ENTRY(purgatory_start)
/* Load new buffer location after jump */
larl %r7,stack
- aghi %r10,stack-purgatory_start
+ larl %r0,purgatory_start
+ slgrk %r0,%r7,%r0
+ agr %r10,%r0
MEMCPY %r10,%r7,%r11 /* (new) buf -> (crash) buf */
/* Now the code is set up to run from its designated location. Start
--
2.32.0
On Wed, May 11, 2022 at 5:05 AM Heiko Carstens <[email protected]> wrote:
>
> llvm's integrated assembler cannot handle immediate values which are
> calculated with two local labels:
>
> arch/s390/purgatory/head.S:139:11: error: invalid operand for instruction
> aghi %r8,-(.base_crash-purgatory_start)
I thought this was fixed in
https://github.com/ClangBuiltLinux/linux/issues/1420
https://reviews.llvm.org/D113341
(clang-14)
?
>
> Workaround this by partially rewriting the code.
>
> Signed-off-by: Heiko Carstens <[email protected]>
> ---
> arch/s390/purgatory/head.S | 29 ++++++++++++++++++++++-------
> 1 file changed, 22 insertions(+), 7 deletions(-)
>
> diff --git a/arch/s390/purgatory/head.S b/arch/s390/purgatory/head.S
> index 3d1c31e0cf3d..ac1a27a20b66 100644
> --- a/arch/s390/purgatory/head.S
> +++ b/arch/s390/purgatory/head.S
> @@ -44,11 +44,14 @@
> .endm
>
> .macro MEMSWAP dst,src,buf,len
> -10: cghi \len,bufsz
> +10: larl %r0,purgatory_end
> + larl %r1,stack
> + slgr %r0,%r1
> + cgr \len,%r0
> jh 11f
> lgr %r4,\len
> j 12f
> -11: lghi %r4,bufsz
> +11: lgr %r4,%r0
>
> 12: MEMCPY \buf,\dst,%r4
> MEMCPY \dst,\src,%r4
> @@ -135,12 +138,18 @@ ENTRY(purgatory_start)
>
> .start_crash_kernel:
> /* Location of purgatory_start in crash memory */
> + larl %r0,.base_crash
> + larl %r1,purgatory_start
> + slgr %r0,%r1
> lgr %r8,%r13
> - aghi %r8,-(.base_crash-purgatory_start)
> + sgr %r8,%r0
>
> /* Destination for this code i.e. end of memory to be swapped. */
> + larl %r0,purgatory_end
> + larl %r1,purgatory_start
> + slgr %r0,%r1
> lg %r9,crash_size-.base_crash(%r13)
> - aghi %r9,-(purgatory_end-purgatory_start)
> + sgr %r9,%r0
>
> /* Destination in crash memory, i.e. same as r9 but in crash memory. */
> lg %r10,crash_start-.base_crash(%r13)
> @@ -149,15 +158,19 @@ ENTRY(purgatory_start)
> /* Buffer location (in crash memory) and size. As the purgatory is
> * behind the point of no return it can re-use the stack as buffer.
> */
> - lghi %r11,bufsz
> + larl %r11,purgatory_end
> larl %r12,stack
> + slgr %r11,%r12
>
> MEMCPY %r12,%r9,%r11 /* dst -> (crash) buf */
> MEMCPY %r9,%r8,%r11 /* self -> dst */
>
> /* Jump to new location. */
> lgr %r7,%r9
> - aghi %r7,.jump_to_dst-purgatory_start
> + larl %r0,.jump_to_dst
> + larl %r1,purgatory_start
> + slgr %r0,%r1
> + agr %r7,%r0
> br %r7
>
> .jump_to_dst:
> @@ -169,7 +182,9 @@ ENTRY(purgatory_start)
>
> /* Load new buffer location after jump */
> larl %r7,stack
> - aghi %r10,stack-purgatory_start
> + larl %r0,purgatory_start
> + slgrk %r0,%r7,%r0
> + agr %r10,%r0
> MEMCPY %r10,%r7,%r11 /* (new) buf -> (crash) buf */
>
> /* Now the code is set up to run from its designated location. Start
> --
> 2.32.0
>
--
Thanks,
~Nick Desaulniers
On Wed, May 11, 2022 at 12:54:41PM -0700, Nick Desaulniers wrote:
> On Wed, May 11, 2022 at 5:05 AM Heiko Carstens <[email protected]> wrote:
> >
> > llvm's integrated assembler cannot handle immediate values which are
> > calculated with two local labels:
> >
> > arch/s390/purgatory/head.S:139:11: error: invalid operand for instruction
> > aghi %r8,-(.base_crash-purgatory_start)
>
> I thought this was fixed in
> https://github.com/ClangBuiltLinux/linux/issues/1420
> https://reviews.llvm.org/D113341
> (clang-14)
> ?
Looks like the referenced fix only works for displacements, bit not
for immediates.
On Wed, May 11, 2022 at 02:05:29PM +0200, Heiko Carstens wrote:
> llvm's integrated assembler cannot handle immediate values which are
> calculated with two local labels:
>
> arch/s390/purgatory/head.S:139:11: error: invalid operand for instruction
> aghi %r8,-(.base_crash-purgatory_start)
>
> Workaround this by partially rewriting the code.
>
> Signed-off-by: Heiko Carstens <[email protected]>
> ---
> arch/s390/purgatory/head.S | 29 ++++++++++++++++++++++-------
> 1 file changed, 22 insertions(+), 7 deletions(-)
...
> - aghi %r10,stack-purgatory_start
> + larl %r0,purgatory_start
> + slgrk %r0,%r7,%r0
> + agr %r10,%r0
Same problem here: slgrk does not work for MARCH=z10. So new version
looks like:
From 99e011fa48d9fe90f6d3d58cf89f738afddf394f Mon Sep 17 00:00:00 2001
From: Heiko Carstens <[email protected]>
Date: Sat, 7 May 2022 20:08:55 +0200
Subject: [PATCH 4/7] s390/purgatory: workaround llvm's IAS limitations
llvm's integrated assembler cannot handle immediate values which are
calculated with two local labels:
arch/s390/purgatory/head.S:139:11: error: invalid operand for instruction
aghi %r8,-(.base_crash-purgatory_start)
Workaround this by partially rewriting the code.
Signed-off-by: Heiko Carstens <[email protected]>
---
arch/s390/purgatory/head.S | 30 +++++++++++++++++++++++-------
1 file changed, 23 insertions(+), 7 deletions(-)
diff --git a/arch/s390/purgatory/head.S b/arch/s390/purgatory/head.S
index 3d1c31e0cf3d..6f835124ee82 100644
--- a/arch/s390/purgatory/head.S
+++ b/arch/s390/purgatory/head.S
@@ -44,11 +44,14 @@
.endm
.macro MEMSWAP dst,src,buf,len
-10: cghi \len,bufsz
+10: larl %r0,purgatory_end
+ larl %r1,stack
+ slgr %r0,%r1
+ cgr \len,%r0
jh 11f
lgr %r4,\len
j 12f
-11: lghi %r4,bufsz
+11: lgr %r4,%r0
12: MEMCPY \buf,\dst,%r4
MEMCPY \dst,\src,%r4
@@ -135,12 +138,18 @@ ENTRY(purgatory_start)
.start_crash_kernel:
/* Location of purgatory_start in crash memory */
+ larl %r0,.base_crash
+ larl %r1,purgatory_start
+ slgr %r0,%r1
lgr %r8,%r13
- aghi %r8,-(.base_crash-purgatory_start)
+ sgr %r8,%r0
/* Destination for this code i.e. end of memory to be swapped. */
+ larl %r0,purgatory_end
+ larl %r1,purgatory_start
+ slgr %r0,%r1
lg %r9,crash_size-.base_crash(%r13)
- aghi %r9,-(purgatory_end-purgatory_start)
+ sgr %r9,%r0
/* Destination in crash memory, i.e. same as r9 but in crash memory. */
lg %r10,crash_start-.base_crash(%r13)
@@ -149,15 +158,19 @@ ENTRY(purgatory_start)
/* Buffer location (in crash memory) and size. As the purgatory is
* behind the point of no return it can re-use the stack as buffer.
*/
- lghi %r11,bufsz
+ larl %r11,purgatory_end
larl %r12,stack
+ slgr %r11,%r12
MEMCPY %r12,%r9,%r11 /* dst -> (crash) buf */
MEMCPY %r9,%r8,%r11 /* self -> dst */
/* Jump to new location. */
lgr %r7,%r9
- aghi %r7,.jump_to_dst-purgatory_start
+ larl %r0,.jump_to_dst
+ larl %r1,purgatory_start
+ slgr %r0,%r1
+ agr %r7,%r0
br %r7
.jump_to_dst:
@@ -169,7 +182,10 @@ ENTRY(purgatory_start)
/* Load new buffer location after jump */
larl %r7,stack
- aghi %r10,stack-purgatory_start
+ lgr %r0,%r7
+ larl %r1,purgatory_start
+ slgr %r0,%r1
+ agr %r10,%r0
MEMCPY %r10,%r7,%r11 /* (new) buf -> (crash) buf */
/* Now the code is set up to run from its designated location. Start
--
2.32.0