Re: arch/x86/entry/entry: RFC on recent kernels building error with llvm 11.0.2 internal assembler

From: Mauro Rossi
Date: Mon Jun 06 2022 - 17:57:49 EST


On Sat, Jun 4, 2022 at 12:13 AM Nick Desaulniers
<ndesaulniers@xxxxxxxxxx> wrote:
>
> On Wed, Jun 1, 2022 at 5:57 AM Mauro Rossi <issor.oruam@xxxxxxxxx> wrote:
> >
> > On Wed, Jun 1, 2022 at 12:09 AM Nick Desaulniers
> > <ndesaulniers@xxxxxxxxxx> wrote:
> > >
> > > As Nathan noted, I messed up the commit "ANDROID: x86: entry: work
> > > around LLVM_IAS=1 bug in LSL". Please see:
> > > https://android-review.googlesource.com/c/kernel/common/+/1521061
> > > https://android-review.googlesource.com/c/kernel/common/+/1560152/
> > >
> > > If you're using an older toolchain, you'll need just the first. If
> > > you're using a newer toolchain, you'll need BOTH (or none, including
> > > dropping "ANDROID: x86: entry: work around LLVM_IAS=1 bug in LSL").
> >
> > Thanks Nick,
> >
> > I had already applied the squashed commit composed of "ANDROID: x86:
> > entry: work around LLVM_IAS=1 bug in LSL" (the one using .quad) and
> > "ANDROID: x86: entry: fix LSL open coding", so I have already:
> >
> > .macro LOAD_CPU_AND_NODE_SEG_LIMIT reg:req
> > movq $__CPUNODE_SEG, \reg
> > +#ifdef __clang__
> > +.long 0xc0030f48
>
> LGTM
>
> > +#else
> > lsl \reg, \reg
> > +#endif
> > .endm
> >
> >
> > So in principle my kernel image should boot when built with LLVM_IAS=1
> > but to my surprise all my systems (Sony VAIO i7, Intel NUC DN2820FYKH
> > with Celeron D2830, Athlon 200GE) are affected by hard reboot when
> > executing the kernel image
>
> Might need more info. Do they boot when LLVM_IAS=0 is explicitly set
> with your command line invocation of make? i.e. `make LLVM=1
> LLVM_IAS=0 ...`? Can you launch these kernels in qemu?

Yes, kernel 5.17 and 5.18 built with LLVM=1 LLVM_IAS=0 do not cause
instantaneus hard reboot and proceed in the boot stages

The complete list of make variables Ihave used is as follows:

LLVM=1 LLVM_IAS=0 \
CC=$(abspath $(LLVM_PREBUILTS_PATH)/clang) \
LD=$(abspath $(LLVM_PREBUILTS_PATH)/ld.lld) \
AR=$(abspath $(LLVM_PREBUILTS_PATH)/llvm-ar) \
NM=$(abspath $(LLVM_PREBUILTS_PATH)/llvm-nm) \
OBJCOPY=$(abspath $(LLVM_PREBUILTS_PATH)/llvm-objcopy) \
OBJDUMP=$(abspath $(LLVM_PREBUILTS_PATH)/llvm-objdump) \
READELF=$(abspath $(LLVM_PREBUILTS_PATH)/llvm-readelf) \
OBJSIZE=$(abspath $(LLVM_PREBUILTS_PATH)/llvm-size) \
STRIP=$(abspath $(LLVM_PREBUILTS_PATH)/llvm-strip) \
HOSTCC=$(abspath $(LLVM_PREBUILTS_PATH)/clang) \
HOSTCXX=$(abspath $(LLVM_PREBUILTS_PATH)/clang++) \
HOSTLD=$(abspath $(LLVM_PREBUILTS_PATH)/ld.lld) \
HOSTLDFLAGS=-fuse-ld=lld \
HOSTAR=$(abspath $(LLVM_PREBUILTS_PATH)/llvm-ar)

>
> >
> > I'm trying to understand how to build (and boot) with LLVM_IAS=1 and
> > using clang 11.0.2 shipped with AOSP Android 11
>
> I think this combo should work; we are testing x86_64 with mainline
> https://github.com/ClangBuiltLinux/continuous-integration2/blob/95b9a12cad31675118d61c26d0b541fa4e3c8f09/generator.yml#L1694
>
> Could be something in your .config files though.
> --
> Thanks,
> ~Nick Desaulniers