Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp28120imm; Thu, 27 Sep 2018 15:20:02 -0700 (PDT) X-Google-Smtp-Source: ACcGV61G4LeUc0LiVzIMmUCtP8rKMiU5TIUcP7FaghnP75i2pEsMmdk32pMKPHvq4P+19v+Y86Gu X-Received: by 2002:a62:46c8:: with SMTP id o69-v6mr13637010pfi.21.1538086802367; Thu, 27 Sep 2018 15:20:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538086802; cv=none; d=google.com; s=arc-20160816; b=I59BJBTQcCda1+NWZ4bsLKrTxLFddJ6xv4be/+QxPuIn2t0BNFdEvJywJa/arvGw0x W5CNHtSSbLaH4paZcHdf3qgFfEWRtOzCGeqm/SNj5NaG7PlW2VaFSXmKgLTmNoBrTu1N JDaXl3HyAwXw8x7MIPKW9aNhzzWvbsSZ8DwdWEKQyS+aqrGYaaCJe3aLN5I6sqv4Dxik OMYPIj4APxhbbXlNssrACcFlXJ4a0AznFqiLSIft/2NAMMwKxeV55RJKenSW8squbqq6 wTbxdy9z25pndKCUaw1Cuf4ZORVG3FHgNEYHjU+b5yAIopQFu8M17boPwXksJZ/6Zy/q Aoaw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=eSdJ15AqAQ4ze7H3W/naI0ZfU4iBDtCsrCH7owOzOoE=; b=jjUhFE1+sMTJTs/bZAQ56X1ibdgFYCJcy+bBLUgp0m+NeSexKXf96D5bQjVYvCST4f YgcDU8gCwrVlUAFVqA2FZD3HT3QOtI93rHRz0jkGsY0VVh8FSsPTT9NYylYkB1KidX4h eSWQAjLVAgEPAsv/ZGnb6up4qazxmYCSFkkQkrc+sfJ8khxpRetGGQMAeYUkDMDcZAce v+GTDW1fqCte1Xz0JKL0ZdhuxZ3ifrk6J87qgoT587AHr3dSaxbvVmCyX/VWjK6Y6un7 +U/GB7N4Y6SHJCEEIC4QbrsdgnprGuTQFfs0ajqybw+eosrq05C7urBMJI6QusbwlxKV YAoA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=c6+R0IfJ; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y27-v6si3063135pgc.197.2018.09.27.15.19.42; Thu, 27 Sep 2018 15:20:02 -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; dkim=pass header.i=@google.com header.s=20161025 header.b=c6+R0IfJ; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728406AbeI1EiX (ORCPT + 99 others); Fri, 28 Sep 2018 00:38:23 -0400 Received: from mail-pf1-f194.google.com ([209.85.210.194]:41297 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726185AbeI1EiX (ORCPT ); Fri, 28 Sep 2018 00:38:23 -0400 Received: by mail-pf1-f194.google.com with SMTP id m77-v6so2843922pfi.8 for ; Thu, 27 Sep 2018 15:17:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=eSdJ15AqAQ4ze7H3W/naI0ZfU4iBDtCsrCH7owOzOoE=; b=c6+R0IfJ5PBjHo1KoYNXbpReHszZDp5S/uI+/CsAilU60YXvNktNuhDFhi8ukRMWGR NuGYsavAAkBcHdgjqh3y2RVFrkvJjsEFhobtRAVyEvV+vuokhgVJDolgsf7FNZ6YmizP asBeIG7SqJa73H77Wa3Nl2owIMdrQzirDfiN79kI6iG04jfONB30Csx7C66mkKXCqnP5 1mCn7AIqDU4Qj62MP5WA7HTprOddn68VdzGwG6NrySDhH9bQ/RlrLY85SGGZzBBf5YGl gvEB1klOjBVF/WRTQ51sdWK0ESA5rMrPLh6oF+HIRWHq9Ccryg8f4Kj7OS3Iny2gHVZd uWdw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=eSdJ15AqAQ4ze7H3W/naI0ZfU4iBDtCsrCH7owOzOoE=; b=l2THFYQ9nhgnVXDWsLU5JtFgv8goXJttTzLWp9qUqQEjB29DndKSSL+6ky4v+WPLgD GtwFthgSjxZgzcE+xZF+t6PiYADEHeXR6MkZskhY0P1zjedoL/LuAc/xlnslN38o0kOR l7KTCGbJyUoLYs6rCE90EddzTE1Q2HJX4dgDSxh/Cg6LAuWfPik8wVcH2xf53LhmRPVo JBzwy4D0ZnQqpaAzbMjmG6Ay/dA6bLyX9k4Fm2R8RuzTFOHESuMQHlB8retQHLVqNB8e rl+1VUX4U5rv4c0H4W6QKG0OBr+0aPNcvg0atDMvlfw1h/blueXmoAxbz7saNYEaKVaw JoXg== X-Gm-Message-State: ABuFfoiB+iQ3v/lnBj59J+4xwz9AVtZdYWqYn/STRogveqiufvIRmozx Izw2FbADJV5/16wwbG+SvE38nH89+L9FdDkrIrIo/Q== X-Received: by 2002:a63:1921:: with SMTP id z33-v6mr12438282pgl.302.1538086673279; Thu, 27 Sep 2018 15:17:53 -0700 (PDT) MIME-Version: 1.0 References: <20180927204800.32210-1-ndesaulniers@google.com> <20180927215148.GE19687@zn.tnic> In-Reply-To: <20180927215148.GE19687@zn.tnic> From: Nick Desaulniers Date: Thu, 27 Sep 2018 15:17:41 -0700 Message-ID: Subject: Re: [PATCH v2] x86/boot: define CC_HAVE_ASM_GOTO To: bp@alien8.de Cc: mingo@redhat.com, Thomas Gleixner , hpa@zytor.com, x86@kernel.org, "Kirill A . Shutemov" , Masahiro Yamada , Greg KH , Matthias Kaehlcke , Kees Cook , Cao jin , LKML Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Sep 27, 2018 at 2:51 PM Borislav Petkov wrote: > > On Thu, Sep 27, 2018 at 01:47:58PM -0700, ndesaulniers@google.com wrote: > > Early prototypes of Clang with asm goto support produce 6 instances of > > the following warning: > > > > In file included from arch/x86/boot/compressed/misc.h:20: > > In file included from ./include/linux/elf.h:5: > > In file included from ./arch/x86/include/asm/elf.h:8: > > In file included from ./include/linux/thread_info.h:38: > > In file included from ./arch/x86/include/asm/thread_info.h:53: > > ./arch/x86/include/asm/cpufeature.h:150:2: warning: "Compiler lacks > > ASM_GOTO support. Add -D __BPF_TRACING__ to your compiler arguments" > > [-W#warnings] > > your compiler arguments" > > ^ > > > > Since 6 files under arch/x86/boot/compressed/ include > > arch/x86/boot/compressed/misc.h AND > > arch/x86/boot/compressed/Makefile happens to redefine KBUILD_CFLAGS, > > which set these variables in the top level MAKEFILE. > > > > Suggested-by: Borislav Petkov > > Signed-off-by: Nick Desaulniers > > --- > > v1 -> v2: > > Updated commit message to provide more context as per Borislav. > > > > arch/x86/boot/compressed/Makefile | 7 +++++++ > > 1 file changed, 7 insertions(+) > > > > diff --git a/arch/x86/boot/compressed/Makefile b/arch/x86/boot/compressed/Makefile > > index 28764dacf018..158c0b4e178a 100644 > > --- a/arch/x86/boot/compressed/Makefile > > +++ b/arch/x86/boot/compressed/Makefile > > @@ -56,6 +56,13 @@ KBUILD_LDFLAGS += $(shell $(LD) --help 2>&1 | grep -q "\-z noreloc-overflow" \ > > endif > > LDFLAGS_vmlinux := -T > > > > +# check for 'asm goto' > > +ifeq ($(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-goto.sh $(CC) $(KBUILD_CFLAGS)), y) > > + CC_HAVE_ASM_GOTO := 1 > > + KBUILD_CFLAGS += -DCC_HAVE_ASM_GOTO > > + KBUILD_AFLAGS += -DCC_HAVE_ASM_GOTO > > +endif > > I would still like to know why can't we do the -D_SETUP thing here: > https://lkml.kernel.org/r/20180926090841.GC5745@zn.tnic That's another case that I look at and wonder "why does this exist?" The _SETUP guard exists in only one place: $ grep -rP 'ifdef\s+_SETUP' arch/x86/boot/cpucheck.c:#ifdef _SETUP which is already under arch/x86/boot/. arch/x86/boot/Makefile unconditionally sets -D_SETUP, so what/who are we guarding against? Looks like a guard that's ALWAYS true (and thus could be removed). > > instead of polluting this Makefile with defines which are not really > needed in the compressed kernel build, except to silence build warnings. > > I mean, we can perpetuate that ugly hack and do: > > #define __BPF_TRACING__ > > here in arch/x86/boot/compressed/misc.h which we could kill once clang > can do asm goto... Or, or... we don't redefine KBUILD_CFLAGS in arch/x86/boot/Makefile (or any Makefile other than the top level one), and simply filter out the flags we DONT want, a la: drivers/firmware/efi/libstub/Makefile: 16 cflags-$(CONFIG_ARM64) := $(subst -pg,,$(KBUILD_CFLAGS)) ... ie, using Make's subst function to copy KBUILD_CFLAGS, filter out results, then use that for cflags-y. https://www.gnu.org/software/make/manual/html_node/Text-Functions.html I'm curious to know Masahiro's thoughts on this? I can't help but shake the feeling that reassigning KBUILD_CFLAGS should be considered an anti-pattern and warned from checkpatch.pl. For the reasons enumerated above AND in v1: https://lore.kernel.org/lkml/CAKwvOdmLSVH7EVGY1ExU1Fh_hvL=FUzhq-80snDfZ+QhCT2FOA@mail.gmail.com/ (though there may be additional context from hpa answering https://lore.kernel.org/lkml/20180926090841.GC5745@zn.tnic/). Relying on the compiler's default/implicit C standard (which changed in gcc 5) for parts of the kernel but not others I feel like should be a big red flag. Shall I prototype up what such a change might look like (not reassigning KBUILD_CFLAGS in arch/x86/boot/Makefile)? Maybe it's harder/uglier than I imagine? -- Thanks, ~Nick Desaulniers