lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
[an error occurred while processing this directive]
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Wed, 11 May 2022 12:54:41 -0700
From:   Nick Desaulniers <ndesaulniers@...gle.com>
To:     Heiko Carstens <hca@...ux.ibm.com>,
        Jonas Paulsson <paulsson@...ux.vnet.ibm.com>
Cc:     Vasily Gorbik <gor@...ux.ibm.com>,
        Alexander Gordeev <agordeev@...ux.ibm.com>,
        Ulrich Weigand <ulrich.weigand@...ibm.com>,
        Masahiro Yamada <masahiroy@...nel.org>,
        Alexander Egorenkov <egorenar@...ux.ibm.com>,
        Sven Schnelle <svens@...ux.ibm.com>,
        Andreas Krebbel <krebbel@...ux.ibm.com>,
        Nathan Chancellor <natechancellor@...il.com>,
        linux-kernel@...r.kernel.org, linux-s390@...r.kernel.org
Subject: Re: [PATCH 5/8] s390/purgatory: workaround llvm's IAS limitations

On Wed, May 11, 2022 at 5:05 AM Heiko Carstens <hca@...ux.ibm.com> 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 <hca@...ux.ibm.com>
> ---
>  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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ