s390/purgatory: workaround llvm's IAS limitations
authorHeiko Carstens <hca@linux.ibm.com>
Wed, 11 May 2022 12:05:29 +0000 (14:05 +0200)
committerHeiko Carstens <hca@linux.ibm.com>
Tue, 17 May 2022 13:16:28 +0000 (15:16 +0200)
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.

Link: https://lore.kernel.org/r/20220511120532.2228616-6-hca@linux.ibm.com
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
arch/s390/purgatory/head.S

index 3d1c31e..6f83512 100644 (file)
 .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