Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp2515412imm; Sat, 12 May 2018 13:30:59 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrc1FjrBwJwBBjq8+EzrqAZq0BCltDb8ax175MJU6RyC0d9lJtc1U+D+c8IgdYPQofvJUwJ X-Received: by 2002:a65:51c4:: with SMTP id i4-v6mr3592985pgq.190.1526157059497; Sat, 12 May 2018 13:30:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526157059; cv=none; d=google.com; s=arc-20160816; b=NTHryvRmYGPpseRmLhCiU6rC4ByEi+8Qm9XLucTM6mRxBQxk00Kjvq31X6blRC89um BSjyDM1B53k8xSyrkQ3822nV/YKmc5iRy5zv3eK1khlJ2F/XsfpxvEibXGxlJ36FDNes VfQAA/kvRAF0a8mIhamce1pfvZdmXHjlWy7UVeh764LwXcf4OR5q1wD5Wgduop0DDef7 7BTNnhn/j3Jso7XS4TVdP5+tTKDCimCD0w+92H4jolurhhpb0k1GO+Rf8Jsuub2FTUl0 udJw5B5BI6usfrDYS++t5vuFSo2W0crihYX1JFixPBiKAkT/AH2fNXkifaWDhYkzhPRB 2l/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date :arc-authentication-results; bh=iE18HeBw23pkIi3PM61vDE3HA7L5qV78OwQj5BMsC3Y=; b=gpzhnHuFnDKs0AMJOEvwyzEFZD1hVurorzNqIMJE0VnSFLDFMjfbZL/TS6wnPY5ktR 28vyeT0Go913rva1SDpyN+G7nPe9ETNr5SPSSl7G4IBJYXR6UEv9nTCiqw3MDFCeFAUq +HuH2buc3AjUTqWo4PWgWbebRik/Cc0vt6+Rxp7fmislofD+0FMhwPlEXO7oOgzwGWj2 nctfzDuMjcN895nmS0NsxhuS2BUGIwIUc7btsrxQenLrkWicaan/ELNDXB3t6qyA0KTe 7x4aIUU5vxVWaqvqAUxoc/twBfQ/SzCGNI0kq55B5WdFy/aSvr0sQog4HK2M6kNxOvTy R3IA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ba9-v6si6118446plb.110.2018.05.12.13.30.44; Sat, 12 May 2018 13:30:59 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751943AbeELUa3 (ORCPT + 99 others); Sat, 12 May 2018 16:30:29 -0400 Received: from Galois.linutronix.de ([146.0.238.70]:47567 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751847AbeELUa1 (ORCPT ); Sat, 12 May 2018 16:30:27 -0400 Received: from p4fea4eb5.dip0.t-ipconnect.de ([79.234.78.181] helo=nanos) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1fHb9X-00060E-BC; Sat, 12 May 2018 22:30:03 +0200 Date: Sat, 12 May 2018 22:30:02 +0200 (CEST) From: Thomas Gleixner To: Alexei Starovoitov cc: Borislav Petkov , Peter Zijlstra , Yonghong Song , Ingo Molnar , Linus Torvalds , Alexei Starovoitov , Daniel Borkmann , LKML , X86 ML , Network Development , Kernel Team Subject: Re: [PATCH bpf v3] x86/cpufeature: bpf hack for clang not supporting asm goto In-Reply-To: Message-ID: References: User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, 12 May 2018, Alexei Starovoitov wrote: > On Thu, May 10, 2018 at 10:58 AM, Alexei Starovoitov > wrote: > > I see no option, but to fix the kernel. > > Regardless whether it's called user space breakage or kernel breakage. There is a big difference. If you are abusing a kernel internal header in a user space tool, then there is absolutely ZERO excuse for requesting that the header in question has to be modified. But yes, the situation is slightly different here because tools which create trace event magic _HAVE_ to pull in kernel headers. At the same time these tools depend on a compiler which failed to implement asm_goto for fricking 8 years. So while Boris is right, that nothing has to fiddle with a kernel only header, I grumpily agree with you that we need a workaround in the kernel for this particular issue. > could you please ack the patch or better yet take it into tip tree > and send to Linus asap ? Nope. The patch is a horrible hack. Why the heck do we need that extra fugly define? That has exactly zero value simply because we already have a define which denotes availablity of ASM GOTO: CC_HAVE_ASM_GOTO. In case of samples/bpf/ and libbcc the compile does not go through the arch/x86 Makefile which stops the build anyway when ASM_GOTO is missing. Those builds merily pull in the headers and have their own build magic, which is broken btw: Changing a kernel header which gets pulled into the build does not rebuild anything in samples/bpf. Qualitee.. So we can just use CC_HAVE_ASM_GOTO and be done with it. But we also want the tools which needs this to be aware of this. Peter requested -D __BPF__ several times which got ignored. It's not too much of a request to add that. Find a patch which deos exactly this for samples/bpf, but also allows other tools to build with a warning emitted so they get fixed. Thanks, tglx 8<---------------- --- a/arch/x86/include/asm/cpufeature.h +++ b/arch/x86/include/asm/cpufeature.h @@ -140,6 +140,20 @@ extern void clear_cpu_cap(struct cpuinfo #define setup_force_cpu_bug(bit) setup_force_cpu_cap(bit) +#ifndef CC_HAVE_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__ +#warning "Compiler lacks ASM_GOTO support. Add -D __BPF__ to your compiler arguments" +#endif + +#define static_cpu_has(bit) boot_cpu_has(bit) + +#else + /* * Static testing of CPU features. Used the same as boot_cpu_has(). * These will statically patch the target code for additional @@ -195,6 +209,7 @@ static __always_inline __pure bool _stat boot_cpu_has(bit) : \ _static_cpu_has(bit) \ ) +#endif #define cpu_has_bug(c, bit) cpu_has(c, (bit)) #define set_cpu_bug(c, bit) set_cpu_cap(c, (bit)) --- a/samples/bpf/Makefile +++ b/samples/bpf/Makefile @@ -255,7 +255,7 @@ verify_target_bpf: verify_cmds $(obj)/%.o: $(src)/%.c $(CLANG) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) $(EXTRA_CFLAGS) -I$(obj) \ -I$(srctree)/tools/testing/selftests/bpf/ \ - -D__KERNEL__ -Wno-unused-value -Wno-pointer-sign \ + -D__KERNEL__ -D__BPF__ -Wno-unused-value -Wno-pointer-sign \ -D__TARGET_ARCH_$(ARCH) -Wno-compare-distinct-pointer-types \ -Wno-gnu-variable-sized-type-not-at-end \ -Wno-address-of-packed-member -Wno-tautological-compare \