All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nick Desaulniers via <qemu-devel@nongnu.org>
To: David Hildenbrand <david@redhat.com>
Cc: Jonas Paulsson <paulsson@linux.vnet.ibm.com>,
	Thomas Huth <thuth@redhat.com>,
	Ulrich Weigand <Ulrich.Weigand@de.ibm.com>,
	Vasily Gorbik <gor@linux.ibm.com>,
	clang-built-linux <clang-built-linux@googlegroups.com>,
	Heiko Carstens <hca@linux.ibm.com>,
	Cornelia Huck <cohuck@redhat.com>,
	Richard Henderson <richard.henderson@linaro.org>,
	qemu-devel@nongnu.org,
	Christian Borntraeger <borntraeger@de.ibm.com>,
	qemu-s390x@nongnu.org, David Hildenbrand <dhildenb@redhat.com>,
	Fangrui Song <maskray@google.com>,
	Guenter Roeck <linux@roeck-us.net>
Subject: Re: [PATCH v1] s390x/tcg: Fix RISBHG
Date: Fri, 8 Jan 2021 11:14:32 -0800	[thread overview]
Message-ID: <CAKwvOd=JRRG1XTKKMdNFuuDb_58Q1Kbgi7F+fOsdwy+xpz0UGQ@mail.gmail.com> (raw)
In-Reply-To: <bbdd5d1b-6aa9-cd2c-eb9a-cf0345dbc999@redhat.com>

On Fri, Jan 8, 2021 at 1:45 AM David Hildenbrand <david@redhat.com> wrote:
>
> On 08.01.21 03:20, Nick Desaulniers wrote:
> > On Thu, Jan 7, 2021 at 3:27 PM David Hildenbrand <dhildenb@redhat.com> wrote:
> >>
> >>
> >>> Am 08.01.2021 um 00:21 schrieb Nick Desaulniers <ndesaulniers@google.com>:
> >>>
> >>> On Thu, Jan 7, 2021 at 3:13 PM David Hildenbrand <david@redhat.com> wrote:
> >>>>
> >>>> RISBHG is broken and currently hinders clang builds of upstream kernels
> >>>> from booting: the kernel crashes early, while decompressing the image.
> >>>>
> >>>>  [...]
> >>>>   Kernel fault: interruption code 0005 ilc:2
> >>>>   Kernel random base: 0000000000000000
> >>>>   PSW : 0000200180000000 0000000000017a1e
> >>>>         R:0 T:0 IO:0 EX:0 Key:0 M:0 W:0 P:0 AS:0 CC:2 PM:0 RI:0 EA:3
> >>>>   GPRS: 0000000000000001 0000000c00000000 00000003fffffff4 00000000fffffff0
> >>>>         0000000000000000 00000000fffffff4 000000000000000c 00000000fffffff0
> >>>>         00000000fffffffc 0000000000000000 00000000fffffff8 00000000008e25a8
> >>>>         0000000000000009 0000000000000002 0000000000000008 000000000000bce0
> >>>>
> >>>> One example of a buggy instruction is:
> >>>>
> >>>>    17dde:       ec 1e 00 9f 20 5d       risbhg  %r1,%r14,0,159,32
> >>>>
> >>>> With %r14 = 0x9 and %r1 = 0x7 should result in %r1 = 0x900000007, however,
> >>>> results in %r1 = 0.
> >>>>
> >>>> Let's interpret values of i3/i4 as documented in the PoP and make
> >>>> computation of "mask" only based on i3 and i4 and use "pmask" only at the
> >>>> very end to make sure wrapping is only applied to the high/low doubleword.
> >>>>
> >>>> With this patch, I can successfully boot a v5.10 kernel built with
> >>>> clang, and gcc builds keep on working.
> >>>>
> >>>> Fixes: 2d6a869833d9 ("target-s390: Implement RISBG")
> >>>> Reported-by: Nick Desaulniers <ndesaulniers@google.com>
> >>>> Cc: Guenter Roeck <linux@roeck-us.net>
> >>>> Cc: Christian Borntraeger <borntraeger@de.ibm.com>
> >>>> Signed-off-by: David Hildenbrand <david@redhat.com>
> >>>> ---
> >>>>
> >>>> This BUG was a nightmare to debug and the code a nightmare to understand.
> >>>>
> >>>> To make clang/gcc builds boot, the following fix is required as well on
> >>>> top of current master: "[PATCH] target/s390x: Fix ALGSI"
> >>>> https://lkml.kernel.org/r/20210107202135.52379-1-david@redhat.com
> >>>
> >>> In that case, a huge thank you!!! for this work! ++beers_owed.
> >>>
> >>
> >> :) a kernel build for z13 should work with the (default) „-cpu qemu“ cpu type.
> >
> > Hmm...so I don't think clang can build a Linux kernel image with
> > CONFIG_MARCH_Z13=y just yet; just defconfig.  Otherwise looks like
> > clang barfs on some of the inline asm constraints.
> >
>
> Ah, right. I overwrote my manual config by a temporary defconfig :)
>
>
> So, I'm on x86-64 F33.
>
> clang version 11.0.0 (Fedora 11.0.0-2.fc33)
> LLVM version 11.0.0
>
> I cannot directly use "LLVM=1" for cross-compilation, as I keep getting
> "error: unknown emulation: elf64_s390" from ld.lld and "error: invalid
> output format: 'elf64-s390'" from llvm-objcopy. I assume that's fixed in
> llvm12?

Right, I suspect that even if ld.lld understood that emulation mode
target, it would still fail due to lack of big endian support.  We've
been building with simply `CC=clang` for s390 linux kernels.
Via: https://www.kernel.org/doc/html/latest/kbuild/llvm.html#llvm-utilities
we usually start with `make CC=clang` then work our way up to `make
LLVM=1`.  So you shouldn't need the below patching, just use
`CC=clang`.

>
> 1. I patch around it (strange, I remember CC= .. used to work, but it no
> longer does)
>
> ---
>
> index e30cf02da8b8..89c57062ed5d 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -427,13 +427,13 @@ KBUILD_HOSTLDLIBS   := $(HOST_LFS_LIBS) $(HOSTLDLIBS)
>  CPP            = $(CC) -E
>  ifneq ($(LLVM),)
>  CC             = clang
> -LD             = ld.lld
> -AR             = llvm-ar
> -NM             = llvm-nm
> -OBJCOPY                = llvm-objcopy
> -OBJDUMP                = llvm-objdump
> -READELF                = llvm-readelf
> -STRIP          = llvm-strip
> +LD             = $(CROSS_COMPILE)ld
> +AR             = $(CROSS_COMPILE)ar
> +NM             = $(CROSS_COMPILE)nm
> +OBJCOPY                = $(CROSS_COMPILE)objcopy
> +OBJDUMP                = $(CROSS_COMPILE)objdump
> +READELF                = $(CROSS_COMPILE)readelf
> +STRIP          = $(CROSS_COMPILE)strip
>  else
>  CC             = $(CROSS_COMPILE)gcc
>  LD             = $(CROSS_COMPILE)ld
>
> ---

Pulling from your github branch, everything looks good; buildroot
support looks good. I'll wire this up to our CI so that we can help
report regressions!
-- 
Thanks,
~Nick Desaulniers


      parent reply	other threads:[~2021-01-08 19:23 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-07 23:13 [PATCH v1] s390x/tcg: Fix RISBHG David Hildenbrand
2021-01-07 23:21 ` Nick Desaulniers via
2021-01-07 23:27   ` David Hildenbrand
2021-01-08  2:20     ` Nick Desaulniers via
2021-01-08  9:44       ` David Hildenbrand
2021-01-08 10:19         ` David Hildenbrand
2021-01-08 10:36           ` David Hildenbrand
2021-01-08 19:14         ` Nick Desaulniers via [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAKwvOd=JRRG1XTKKMdNFuuDb_58Q1Kbgi7F+fOsdwy+xpz0UGQ@mail.gmail.com' \
    --to=qemu-devel@nongnu.org \
    --cc=Ulrich.Weigand@de.ibm.com \
    --cc=borntraeger@de.ibm.com \
    --cc=clang-built-linux@googlegroups.com \
    --cc=cohuck@redhat.com \
    --cc=david@redhat.com \
    --cc=dhildenb@redhat.com \
    --cc=gor@linux.ibm.com \
    --cc=hca@linux.ibm.com \
    --cc=linux@roeck-us.net \
    --cc=maskray@google.com \
    --cc=ndesaulniers@google.com \
    --cc=paulsson@linux.vnet.ibm.com \
    --cc=qemu-s390x@nongnu.org \
    --cc=richard.henderson@linaro.org \
    --cc=thuth@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.