lkml.org 
[lkml]   [2019]   [Jan]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Date
SubjectRe: jump_label: move 'asm goto' support test to Kconfig
On Thu, Jan 3, 2019 at 1:36 AM Masahiro Yamada
<yamada.masahiro@socionext.com> wrote:
>
> On Wed, Jan 2, 2019 at 9:14 PM Sedat Dilek <sedat.dilek@gmail.com> wrote:
> >
> > Hi,
> >
> > I was not aware that CONFIG_JUMP_LABEL Kconfig setting depends on the
> > support of asm-goto.
> >
> > Currently, I am doing experiments with clang-7 and a snapshot of
> > clang-8 on Linux/x86.
> > These compilers have no asm-goto support.
> >
> > What is your recommendation for Linux >= v4.20?
> > I am asking as it is possible to set CONFIG_JUMP_LABEL=y when
> > compiling with clang - which has no effect.
> > This is confusing.
> >
> > Thanks, this patch makes things clearer and protects users from
> > setting "wrong" in the sense of non-functional settings.
> >
> > I have tested this against recent Linus tree where kbuild/kconfig Git
> > pulls were latest commits.
> >
> > Tested-by: Sedat Dilek <sedat.dilek@gmail.com> [ x86 with LLVM/Clang
> > v7 and v8 (snapshot) ]
>
>
> Which part was tested?
>
> x86 kernel cannot be compiled with Clang
> since it lacks the asm-goto support.
>
>
> $ make CC=clang
> Compiler lacks asm-goto support.
> arch/x86/Makefile:293: recipe for target 'checkbin' failed
> make: *** [checkbin] Error 1
>

Yes, this needs a workaround (see attachment).

As a base I took kbuid.git#for-next on top of Linux v4.20...

$ git log --oneline -2
58609f06cfb6 (HEAD -> 4.20.0-2-amd64-cbl) x86: Workaround clang does
not support asm-goto
68af7c873957 (for-4.20/kbuild-next-20190103) kbuild: remove
unnecessary stubs for archheader and archscripts

...and includes:

f44251005047 jump_label: move 'asm goto' support test to Kconfig

My compiler is clang-7 from Debian/testing.

$ git log --oneline -2
58609f06cfb6 (HEAD -> 4.20.0-2-amd64-cbl) x86: Workaround clang does
not support asm-goto
68af7c873957 (for-4.20/kbuild-next-20190103) kbuild: remove
unnecessary stubs for archheader and archscripts

It's compile-tested only on Debian/testing AMD64.

I cannot boot into bare metal.

This might have other root causes.

- Sedat -

P.S.: Additional informations

Booting in QEMU 3.1 shows...

$ ./run_qemu.sh
Probing EDD (edd=off to disable)... ok


XZ-compressed data is corrupt

-- System haltedqemu-system-x86_64: terminating on signal 2

$ cat run_qemu.sh
KPATH=$(pwd)

qemu-system-x86_64 -enable-kvm -M pc -kernel $KPATH/bzImage -initrd
$KPATH/initrd.img -m 512 -net none -serial stdio -append
"root=/dev/ram0 console=ttyS0 hung_task_panic=1
earlyprintk=ttyS0,115200"

NOTE: I can boot a Linux v4.20 kernel with this QEMU version.
From 53727072385d3e9327e2f7c466b49078b09286ae Mon Sep 17 00:00:00 2001
From: Sedat Dilek <sedat.dilek@credativ.de>
Date: Thu, 3 Jan 2019 15:03:12 +0100
Subject: [PATCH] x86: Workaround clang does not support asm-goto

Only warn once that Clang does not support asm-goto (see LLVM bug #9295).

Avoid and thus reduce warnings by adding '-D__BPF_TRACING__' argument to KBUILD_CFLAGS where needed (inspired by [1]).

Testing: The patch "jump_label: move 'asm goto' support test to Kconfig" from [2].

[1] https://github.com/ClangBuiltLinux/continuous-integration/blob/master/patches/linux/x86_64/0001-DO-NOT-UPSTREAM-x86-Avoid-warnings-errors-due-to-lac.patch
[2] https://lore.kernel.org/patchwork/patch/1028282/
[3] https://github.com/ClangBuiltLinux/linux/issues/6

---
arch/x86/Makefile | 5 +++--
arch/x86/boot/compressed/Makefile | 4 ++++
arch/x86/include/asm/cpufeature.h | 8 --------
drivers/firmware/efi/libstub/Makefile | 4 ++++
4 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/arch/x86/Makefile b/arch/x86/Makefile
index 9c5a67d1b9c1..ba8ee0de0397 100644
--- a/arch/x86/Makefile
+++ b/arch/x86/Makefile
@@ -290,8 +290,9 @@ vdso_install:
archprepare: checkbin
checkbin:
ifndef CONFIG_CC_HAS_ASM_GOTO
- @echo Compiler lacks asm-goto support.
- @exit 1
+ @echo Warning: Compiler lacks asm-goto support.
+ @exit 0
+KBUILD_CFLAGS += -D__BPF_TRACING__
endif
ifdef CONFIG_RETPOLINE
ifeq ($(RETPOLINE_CFLAGS),)
diff --git a/arch/x86/boot/compressed/Makefile b/arch/x86/boot/compressed/Makefile
index 466f66c8a7f8..bc8991fede60 100644
--- a/arch/x86/boot/compressed/Makefile
+++ b/arch/x86/boot/compressed/Makefile
@@ -39,6 +39,10 @@ KBUILD_CFLAGS += $(call cc-disable-warning, address-of-packed-member)
KBUILD_CFLAGS += $(call cc-disable-warning, gnu)
KBUILD_CFLAGS += -Wno-pointer-sign

+ifndef CONFIG_CC_HAS_ASM_GOTO
+KBUILD_CFLAGS += -D__BPF_TRACING__
+endif
+
KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
GCOV_PROFILE := n
UBSAN_SANITIZE :=n
diff --git a/arch/x86/include/asm/cpufeature.h b/arch/x86/include/asm/cpufeature.h
index ce95b8cbd229..4774fafee82b 100644
--- a/arch/x86/include/asm/cpufeature.h
+++ b/arch/x86/include/asm/cpufeature.h
@@ -142,14 +142,6 @@ extern void clear_cpu_cap(struct cpuinfo_x86 *c, unsigned int bit);

#if defined(__clang__) && !defined(CONFIG_CC_HAS_ASM_GOTO)

-/*
- * Workaround for the sake of BPF compilation which utilizes kernel
- * headers, but clang does not support ASM GOTO and fails the build.
- */
-#ifndef __BPF_TRACING__
-#warning "Compiler lacks ASM_GOTO support. Add -D __BPF_TRACING__ to your compiler arguments"
-#endif
-
#define static_cpu_has(bit) boot_cpu_has(bit)

#else
diff --git a/drivers/firmware/efi/libstub/Makefile b/drivers/firmware/efi/libstub/Makefile
index d9845099635e..68ff33dc075d 100644
--- a/drivers/firmware/efi/libstub/Makefile
+++ b/drivers/firmware/efi/libstub/Makefile
@@ -24,6 +24,10 @@ cflags-$(CONFIG_ARM) := $(subst -pg,,$(KBUILD_CFLAGS)) \

cflags-$(CONFIG_EFI_ARMSTUB) += -I$(srctree)/scripts/dtc/libfdt

+ifndef CONFIG_CC_HAS_ASM_GOTO
+cflags-$(CONFIG_X86) += -D__BPF_TRACING__
+endif
+
KBUILD_CFLAGS := $(cflags-y) -DDISABLE_BRANCH_PROFILING \
-D__NO_FORTIFY \
$(call cc-option,-ffreestanding) \
--
2.20.1
[unhandled content-type:application/octet-stream]
\
 
 \ /
  Last update: 2019-01-04 10:58    [W:0.062 / U:0.092 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site