From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-f67.google.com ([209.85.221.67]:41102 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726911AbeKTVzO (ORCPT ); Tue, 20 Nov 2018 16:55:14 -0500 Received: by mail-wr1-f67.google.com with SMTP id x10so1556735wrs.8 for ; Tue, 20 Nov 2018 03:26:29 -0800 (PST) Date: Tue, 20 Nov 2018 04:26:24 -0700 From: Nathan Chancellor To: Greg KH Cc: Nick Desaulniers , stable@vger.kernel.org, Sandeep Patil , Matthias Kaehlcke , Alistair Strachan Subject: Re: Clang backports for 4.9 and 4.4 Message-ID: <20181120112624.GA12353@flashbox> References: <20181119185213.GA29256@flashbox> <20181119192059.GA31554@flashbox> <20181120074807.GB15276@kroah.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="9jxsPFA5p3P2qPhR" Content-Disposition: inline In-Reply-To: <20181120074807.GB15276@kroah.com> Sender: stable-owner@vger.kernel.org List-ID: --9jxsPFA5p3P2qPhR Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Tue, Nov 20, 2018 at 08:48:07AM +0100, Greg KH wrote: > On Mon, Nov 19, 2018 at 03:13:47PM -0800, Nick Desaulniers wrote: > > On Mon, Nov 19, 2018 at 11:21 AM Nathan Chancellor > > wrote: > > > > > > On Mon, Nov 19, 2018 at 11:17:15AM -0800, Nick Desaulniers wrote: > > > > On Mon, Nov 19, 2018 at 10:52 AM Nathan Chancellor > > > > wrote: > > > > > > > > > > On Mon, Nov 19, 2018 at 10:31:35AM -0800, Nick Desaulniers wrote: > > > > > > Greg, > > > > > > I'm in the process of preparing backports for building 4.9 and 4.4 > > > > > > kernels with Clang. Going off of mka's very helpful: > > > > > > https://lkml.org/lkml/2017/11/22/943, I've prepared the list of SHA's > > > > > > that were marked UPSTREAM (internal convention used to denote patch > > > > > > applies cleanly): > > > > > > https://gist.github.com/nickdesaulniers/fe995f4b7c52af8de1a283c0a53562d9. > > > > > > But it seems that some of these shas no longer apply cleanly. I was > > > > > > thus curious: > > > > > > > > > > > > 1. May I send you a pull request with the patches properly backported? > > > > > > I'm happy to do the work, just want a green light before backporting > > > > > > all of these patches. > > > > > > 2. Should I denote in any way if I had to modify any patch to get it > > > > > > to apply cleanly? This helps in code review, IMO. If so, what > > > > > > convention should I use? > > > > Greg, > > Would you please cherry pick the following 26 patches from mainline to > > 4.9.y stable branch? (applied top to bottom) > > > > I verified that they cherry-pick cleanly, and boot on x86_64 and > > arm64. I will follow up with more patches cleaning up the warnings, > > adding arm 32b support, and the backport patches themselves when they > > do not cherry pick cleanly. > > https://travis-ci.com/nickdesaulniers/continuous-integration/builds/91934518 > > > > 785f11aa595bc3d4e74096cbd598ada54ecc0d81 > > a37c45cd82e62a361706b9688a984a3a63957321 > > ebf003f0cfb3705e60d40dedc3ec949176c741af > > 7dd47b95b0f54f2057d40af6e66d477e3fe95d13 > > cf0c3e68aa81f992b0301f62e341b710d385bf68 > > > > a0ae981eba8f07dbc74bce38fd3a462b69a5bc8e > > c3f0d0bc5b01ad90c45276952802455750444b4f > > 6748cb3c299de1ffbe56733647b01dbcc398c419 > > 433db3e260bc8134d4a46ddf20b3668937e12556 > > 1f318a8bafcfba9f0d623f4870c4e890fd22e659 > > > > 2c4fd1ac3ff167c91272dc43c7bfd2269ef61557 > > fdb2726f4e61c5e3abc052f547d5a5f6c0dc5504 > > 9f3f1fd299768782465cb32cdf0dd4528d11f26b > > 032a2c4f65a2f81c93e161a11197ba19bc14a909 > > d77698df39a512911586834d303275ea5fda74d0 > > > > bfb38988c51e440fd7062ddf3157f7d8b1dd5d70 > > f4857f4c2ee9aa4e2aacac1a845352b00197fb57 > > 18d5e6c34a8eda438d5ad8b3b15f42dab01bf05d > > 760b61d76da6d6a99eb245ab61abf71ca5415cea > > 0426a4e68f18d75515414361de9e3e1445d2644e > > > > 696204faa6e8a318320ebb49d9fa69bc8275644d > > 91ee5b21ee026c49e4e7483de69b55b8b47042be > > 8f91869766c00622b2eaa8ee567db4f333b78c1a > > 9e8730b178a2472fca3123e909d6e69cc8127778 > > 8c97023cf0518f172b8cb7a9fffc28b89401abbf > > > > d135b8b5060ea91dd751ff172d179eb4eab1e966 > > Ok, while I did say having a list of git commit ids was ok, I didn't > realize it was going to be this long :) > > If you do have a tested set of patches like this already in your tree, I > would be more than willing to take a git pull request or a mbox of them > all, and apply them that way. > > As for the format of them, look at how David Miller sends networking > mbox files, with the "upstream commit" line as the first line of the > patch, so that we know where the patch came from. > > Also, it gives me a better way to review them and see if these really > are sane enough for the stable tree. > > For 4.9 I can sort of understand the request, but for 4.4, that is > really old now, and no one should be making new devices with that kernel > release (same for 4.9, but yeah, I know...) So I doubt anyone cares > about clang backports for 4.4 which is why I only accepted a few tiny > patches for that in the past into that tree. > > thanks, > > greg k-h Hi Greg, While the number of commits seems rather high, all together they are a rather small set of changes. It's mostly just shuffling around and extending what is already there. Here is an mbox file with all of the patches properly backported with their respective commit IDs if you would like to do a quick review (and I think I did this right...). We have verified that it allows both an arm64 and an x86_64 kernel to boot in QEMU with Clang. https://travis-ci.com/ClangBuiltLinux/continuous-integration/jobs/159683234 https://travis-ci.com/ClangBuiltLinux/continuous-integration/jobs/159683235 Thanks! Nathan --9jxsPFA5p3P2qPhR Content-Type: application/mbox Content-Disposition: attachment; filename="clang-patches-4.4.mbox" Content-Transfer-Encoding: quoted-printable =46rom 5d5e0e7ffed1761a8b10f90a30563e32eecdc12a Mon Sep 17 00:00:00 2001=0A= =46rom: Behan Webster =0ADate: Fri, 21 Apr 2017 = 11:20:01 -0700=0ASubject: [PATCH 01/32] kbuild: Add better clang cross buil= d support=0AMIME-Version: 1.0=0AContent-Type: text/plain; charset=3DUTF-8= =0AContent-Transfer-Encoding: 8bit=0A=0Acommit 785f11aa595bc3d4e74096cbd598= ada54ecc0d81 upstream.=0A=0AAdd cross target to CC if using clang. Also add= custom gcc toolchain=0Apath for fallback gcc tools.=0A=0AClang will fallba= ck to using things like ld, as, and libgcc if=0A(respectively) one of the l= lvm linkers isn't available, the integrated=0Aassembler is turned off, or a= n appropriately cross-compiled version of=0Acompiler-rt isn't available. To= this end, you can specify the path to=0Athis fallback gcc toolchain with G= CC_TOOLCHAIN.=0A=0ASigned-off-by: Behan Webster = =0AReviewed-by: Jan-Simon M=C3=B6ller =0AReviewed-by: Mark Ch= arlebois =0ASigned-off-by: Greg Hackmann =0ASigned-off-by: Matthias Kaehlcke =0ASigned-off= -by: Masahiro Yamada =0ASigned-off-by: Natha= n Chancellor =0A---=0A Makefile | 9 +++++++++=0A = 1 file changed, 9 insertions(+)=0A=0Adiff --git a/Makefile b/Makefile=0Aind= ex 4e3179768eea..fe94643d247f 100644=0A--- a/Makefile=0A+++ b/Makefile=0A@@= -698,6 +698,15 @@ endif=0A KBUILD_CFLAGS +=3D $(stackp-flag)=0A =0A ifeq (= $(cc-name),clang)=0A+ifneq ($(CROSS_COMPILE),)=0A+CLANG_TARGET :=3D -target= $(notdir $(CROSS_COMPILE:%-=3D%))=0A+GCC_TOOLCHAIN :=3D $(realpath $(dir $= (shell which $(LD)))/..)=0A+endif=0A+ifneq ($(GCC_TOOLCHAIN),)=0A+CLANG_GCC= _TC :=3D -gcc-toolchain $(GCC_TOOLCHAIN)=0A+endif=0A+KBUILD_CFLAGS +=3D $(C= LANG_TARGET) $(CLANG_GCC_TC)=0A+KBUILD_AFLAGS +=3D $(CLANG_TARGET) $(CLANG_= GCC_TC)=0A KBUILD_CPPFLAGS +=3D $(call cc-option,-Qunused-arguments,)=0A KB= UILD_CPPFLAGS +=3D $(call cc-option,-Wno-unknown-warning-option,)=0A KBUILD= _CFLAGS +=3D $(call cc-disable-warning, unused-variable)=0A-- =0A2.20.0.rc0= =0A=0A=0AFrom b13c26e669028ee9c8c3cf4ab2900dcb1e88594d Mon Sep 17 00:00:00 = 2001=0AFrom: Michael Davidson =0ADate: Tue, 25 Apr 2017 15:4= 7:35 -0700=0ASubject: [PATCH 02/32] kbuild: clang: add -no-integrated-as to= =0A KBUILD_[AC]FLAGS=0A=0Acommit a37c45cd82e62a361706b9688a984a3a63957321 u= pstream.=0A=0AThe Linux Kernel relies on GCC's acceptance of inline assembl= y as an=0Aopaque object which will not have any validation performed on the= content.=0AThe current behaviour in LLVM is to perform validation of the c= ontents by=0Ameans of parsing the input if the MC layer can handle it.=0A= =0ADisable clangs integrated assembler and use the GNU assembler instead.= =0A=0AWording-mostly-from: Saleem Abdulrasool =0ASig= ned-off-by: Michael Davidson =0ASigned-off-by: Matthias Kaeh= lcke =0ASigned-off-by: Masahiro Yamada =0ASigned-off-by: Nathan Chancellor = =0A---=0A Makefile | 2 ++=0A 1 file changed, 2 insertions(+)=0A=0Adiff --gi= t a/Makefile b/Makefile=0Aindex fe94643d247f..3713f35f453b 100644=0A--- a/M= akefile=0A+++ b/Makefile=0A@@ -719,6 +719,8 @@ KBUILD_CFLAGS +=3D $(call cc= -disable-warning, tautological-compare)=0A # See modpost pattern 2=0A KBUIL= D_CFLAGS +=3D $(call cc-option, -mno-global-merge,)=0A KBUILD_CFLAGS +=3D $= (call cc-option, -fcatch-undefined-behavior)=0A+KBUILD_CFLAGS +=3D $(call c= c-option, -no-integrated-as)=0A+KBUILD_AFLAGS +=3D $(call cc-option, -no-in= tegrated-as)=0A else=0A =0A # These warnings generated too much noise in a = regular build.=0A-- =0A2.20.0.rc0=0A=0A=0AFrom 3a96172652b58941cd4e1b33abd7= 12e1621be670 Mon Sep 17 00:00:00 2001=0AFrom: Matthias Kaehlcke =0ADate: Wed, 12 Apr 2017 12:43:52 -0700=0ASubject: [PATCH 03/32] kb= uild: Consolidate header generation from ASM offset=0A information=0A=0Acom= mit ebf003f0cfb3705e60d40dedc3ec949176c741af upstream.=0A=0ALargely redunda= nt code is used in different places to generate C headers=0Afrom offset inf= ormation extracted from assembly language output.=0AConsolidate the code in= Makefile.lib and use this instead.=0A=0ASigned-off-by: Matthias Kaehlcke <= mka@chromium.org>=0ASigned-off-by: Masahiro Yamada =0ASigned-off-by: Nathan Chancellor =0A---= =0A Kbuild | 25 -------------------------=0A arch/ia64/k= ernel/Makefile | 26 ++------------------------=0A scripts/Makefile.lib = | 28 ++++++++++++++++++++++++++++=0A scripts/mod/Makefile | 28 ++----= ----------------------=0A 4 files changed, 32 insertions(+), 75 deletions(-= )=0A=0Adiff --git a/Kbuild b/Kbuild=0Aindex f55cefd9bf29..f56ed561a284 1006= 44=0A--- a/Kbuild=0A+++ b/Kbuild=0A@@ -6,31 +6,6 @@=0A # 3) Generate asm-of= fsets.h (may need bounds.h and timeconst.h)=0A # 4) Check for missing syste= m calls=0A =0A-# Default sed regexp - multiline due to syntax constraints= =0A-define sed-y=0A- "/^->/{s:->#\(.*\):/* \1 */:; \=0A- s:^->\([^ ]*\) [\$= $#]*\([-0-9]*\) \(.*\):#define \1 \2 /* \3 */:; \=0A- s:^->\([^ ]*\) [\$$#]= *\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; \=0A- s:->::; p;}"=0A-endef=0A-= =0A-# Use filechk to avoid rebuilds when a header changes, but the resultin= g file=0A-# does not=0A-define filechk_offsets=0A- (set -e; \=0A- echo "#i= fndef $2"; \=0A- echo "#define $2"; \=0A- echo "/*"; \=0A- echo " * DO N= OT MODIFY."; \=0A- echo " *"; \=0A- echo " * This file was generated by K= build"; \=0A- echo " */"; \=0A- echo ""; \=0A- sed -ne $(sed-y); \=0A- = echo ""; \=0A- echo "#endif" )=0A-endef=0A-=0A #####=0A # 1) Generate boun= ds.h=0A =0Adiff --git a/arch/ia64/kernel/Makefile b/arch/ia64/kernel/Makefi= le=0Aindex 3686d6abafde..9edda5466020 100644=0A--- a/arch/ia64/kernel/Makef= ile=0A+++ b/arch/ia64/kernel/Makefile=0A@@ -50,32 +50,10 @@ CFLAGS_traps.o = +=3D -mfixed-range=3Df2-f5,f16-f31=0A # The gate DSO image is built using = a special linker script.=0A include $(src)/Makefile.gate=0A =0A-# Calculate= NR_IRQ =3D max(IA64_NATIVE_NR_IRQS, XEN_NR_IRQS, ...) based on config=0A-d= efine sed-y=0A- "/^->/{s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2= /* \3 */:; s:->::; p;}"=0A-endef=0A-quiet_cmd_nr_irqs =3D GEN $@=0A-de= fine cmd_nr_irqs=0A- (set -e; \=0A- echo "#ifndef __ASM_NR_IRQS_H__"; \=0A= - echo "#define __ASM_NR_IRQS_H__"; \=0A- echo "/*"; \=0A- echo " * DO N= OT MODIFY."; \=0A- echo " *"; \=0A- echo " * This file was generated by K= build"; \=0A- echo " *"; \=0A- echo " */"; \=0A- echo ""; \=0A- sed -ne= $(sed-y) $<; \=0A- echo ""; \=0A- echo "#endif" ) > $@=0A-endef=0A-=0A #= We use internal kbuild rules to avoid the "is up to date" message from mak= e=0A arch/$(SRCARCH)/kernel/nr-irqs.s: arch/$(SRCARCH)/kernel/nr-irqs.c=0A = $(Q)mkdir -p $(dir $@)=0A $(call if_changed_dep,cc_s_c)=0A =0A-include/ge= nerated/nr-irqs.h: arch/$(SRCARCH)/kernel/nr-irqs.s=0A- $(Q)mkdir -p $(dir = $@)=0A- $(call cmd,nr_irqs)=0A+include/generated/nr-irqs.h: arch/$(SRCARCH)= /kernel/nr-irqs.s FORCE=0A+ $(call filechk,offsets,__ASM_NR_IRQS_H__)=0Adif= f --git a/scripts/Makefile.lib b/scripts/Makefile.lib=0Aindex a2d0e6d32659.= =2E18a1c8381ce0 100644=0A--- a/scripts/Makefile.lib=0A+++ b/scripts/Makefil= e.lib=0A@@ -388,3 +388,31 @@ quiet_cmd_xzmisc =3D XZMISC $@=0A cmd_xzmisc = =3D (cat $(filter-out FORCE,$^) | \=0A xz --check=3Dcrc32 --lzma2=3Ddict= =3D1MiB) > $@ || \=0A (rm -f $@ ; false)=0A+=0A+# ASM offsets=0A+# -------= --------------------------------------------------------------------=0A+=0A= +# Default sed regexp - multiline due to syntax constraints=0A+define sed-o= ffsets=0A+ "/^->/{s:->#\(.*\):/* \1 */:; \=0A+ s:^->\([^ ]*\) [\$$#]*\([-0-= 9]*\) \(.*\):#define \1 \2 /* \3 */:; \=0A+ s:^->\([^ ]*\) [\$$#]*\([^ ]*\)= \(.*\):#define \1 \2 /* \3 */:; \=0A+ s:->::; p;}"=0A+endef=0A+=0A+# Use f= ilechk to avoid rebuilds when a header changes, but the resulting file=0A+#= does not=0A+define filechk_offsets=0A+ (set -e; \=0A+ echo "#ifndef $2"; = \=0A+ echo "#define $2"; \=0A+ echo "/*"; \=0A+ echo " * DO NOT MODIFY."= ; \=0A+ echo " *"; \=0A+ echo " * This file was generated by Kbuild"; \= =0A+ echo " */"; \=0A+ echo ""; \=0A+ sed -ne $(sed-offsets); \=0A+ ech= o ""; \=0A+ echo "#endif" )=0A+endef=0Adiff --git a/scripts/mod/Makefile b= /scripts/mod/Makefile=0Aindex c11212ff3510..e0cb2e4a3b15 100644=0A--- a/scr= ipts/mod/Makefile=0A+++ b/scripts/mod/Makefile=0A@@ -5,32 +5,8 @@ modpost-o= bjs :=3D modpost.o file2alias.o sumversion.o=0A =0A devicetable-offsets-fil= e :=3D devicetable-offsets.h=0A =0A-define sed-y=0A- "/^->/{s:->#\(.*\):/* = \1 */:; \=0A- s:^->\([^ ]*\) [\$$#]*\([-0-9]*\) \(.*\):#define \1 \2 /* \3 = */:; \=0A- s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; = \=0A- s:->::; p;}"=0A-endef=0A-=0A-quiet_cmd_offsets =3D GEN $@=0A-defi= ne cmd_offsets=0A- (set -e; \=0A- echo "#ifndef __DEVICETABLE_OFFSETS_H__"= ; \=0A- echo "#define __DEVICETABLE_OFFSETS_H__"; \=0A- echo "/*"; \=0A- = echo " * DO NOT MODIFY."; \=0A- echo " *"; \=0A- echo " * This file was = generated by Kbuild"; \=0A- echo " *"; \=0A- echo " */"; \=0A- echo ""; = \=0A- sed -ne $(sed-y) $<; \=0A- echo ""; \=0A- echo "#endif" ) > $@=0A-= endef=0A-=0A-$(obj)/$(devicetable-offsets-file): $(obj)/devicetable-offsets= =2Es=0A- $(call if_changed,offsets)=0A+$(obj)/$(devicetable-offsets-file): = $(obj)/devicetable-offsets.s FORCE=0A+ $(call filechk,offsets,__DEVICETABLE= _OFFSETS_H__)=0A =0A targets +=3D $(devicetable-offsets-file) devicetable-o= ffsets.s=0A =0A-- =0A2.20.0.rc0=0A=0A=0AFrom e7e611a7d26027e41d449933f7d978= 102726f9ce Mon Sep 17 00:00:00 2001=0AFrom: Masahiro Yamada =0ADate: Fri, 21 Apr 2017 15:21:10 +0900=0ASubject: [PATCH = 04/32] kbuild: consolidate redundant sed script ASM offset=0A generation=0A= =0Acommit 7dd47b95b0f54f2057d40af6e66d477e3fe95d13 upstream.=0A=0AThis part= ended up in redundant code after touched by multiple=0Apeople.=0A=0A[1] Co= mmit 3234282f33b2 ("x86, asm: Fix CFI macro invocations to=0Adeal with shor= tcomings in gas") added parentheses for defined=0Aexpressions to support ol= d gas for x86.=0A=0A[2] Commit a22dcdb0032c ("x86, asm: Fix ancient-GAS wor= karound")=0Asplit the pattern into two to avoid parentheses for non-numeric= =0Aexpressions.=0A=0A[3] Commit 95a2f6f72d37 ("Partially revert patch that = encloses=0Aasm-offset.h numbers in brackets") removed parentheses from nume= ric=0Aexpressions as well because parentheses in MN10300 assembly have a=0A= special meaning (pointer access).=0A=0AApparently, there is a conflict betw= een [1] and [3]. After all,=0A[3] took precedence, and a long time has pas= sed since then.=0A=0ANow, merge the two patterns again because the first on= e is covered=0Aby the other.=0A=0ASigned-off-by: Masahiro Yamada =0AReviewed-by: Matthias Kaehlcke = =0ASigned-off-by: Nathan Chancellor =0A---=0A scr= ipts/Makefile.lib | 1 -=0A 1 file changed, 1 deletion(-)=0A=0Adiff --git a/= scripts/Makefile.lib b/scripts/Makefile.lib=0Aindex 18a1c8381ce0..f2f46d055= f20 100644=0A--- a/scripts/Makefile.lib=0A+++ b/scripts/Makefile.lib=0A@@ -= 395,7 +395,6 @@ cmd_xzmisc =3D (cat $(filter-out FORCE,$^) | \=0A # Default= sed regexp - multiline due to syntax constraints=0A define sed-offsets=0A = "/^->/{s:->#\(.*\):/* \1 */:; \=0A- s:^->\([^ ]*\) [\$$#]*\([-0-9]*\) \(.*= \):#define \1 \2 /* \3 */:; \=0A s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#d= efine \1 \2 /* \3 */:; \=0A s:->::; p;}"=0A endef=0A-- =0A2.20.0.rc0=0A=0A= =0AFrom 0a64c272fdab6e40bf3224db45a239192e7bcc86 Mon Sep 17 00:00:00 2001= =0AFrom: Jeroen Hofstee =0ADate: Fri, 21 Apr 2017 15:= 21:11 +0900=0ASubject: [PATCH 05/32] kbuild: fix asm-offset generation to w= ork with clang=0A=0Acommit cf0c3e68aa81f992b0301f62e341b710d385bf68 upstrea= m.=0A=0AKBuild abuses the asm statement to write to a file and=0Aclang chok= es about these invalid asm statements. Hack it=0Aeven more by fooling this = is actual valid asm code.=0A=0A[masahiro:=0A Import Jeroen's work for U-Boo= t:=0A http://patchwork.ozlabs.org/patch/375026/=0A Tweak sed script a littl= e to avoid garbage '#' for GCC case, like=0A #define NR_PAGEFLAGS 23 /* __N= R_PAGEFLAGS # */ ]=0A=0ASigned-off-by: Jeroen Hofstee =0ASigned-off-by: Masahiro Yamada =0A= Reviewed-by: Matthias Kaehlcke =0ATested-by: Matthias Kae= hlcke =0ASigned-off-by: Nathan Chancellor =0A---=0A include/linux/kbuild.h | 6 +++---=0A scripts/Makefile.= lib | 8 ++++++--=0A 2 files changed, 9 insertions(+), 5 deletions(-)=0A= =0Adiff --git a/include/linux/kbuild.h b/include/linux/kbuild.h=0Aindex 22a= 72198c14b..4e80f3a9ad58 100644=0A--- a/include/linux/kbuild.h=0A+++ b/inclu= de/linux/kbuild.h=0A@@ -2,14 +2,14 @@=0A #define __LINUX_KBUILD_H=0A =0A #d= efine DEFINE(sym, val) \=0A- asm volatile("\n->" #sym " %0 " #val : = : "i" (val))=0A+ asm volatile("\n.ascii \"->" #sym " %0 " #val "\"" : : "i"= (val))=0A =0A-#define BLANK() asm volatile("\n->" : : )=0A+#define BLANK()= asm volatile("\n.ascii \"->\"" : : )=0A =0A #define OFFSET(sym, str, mem) = \=0A DEFINE(sym, offsetof(struct str, mem))=0A =0A #define COMMENT(x) \=0A= - asm volatile("\n->#" x)=0A+ asm volatile("\n.ascii \"->#" x "\"")=0A =0A = #endif=0Adiff --git a/scripts/Makefile.lib b/scripts/Makefile.lib=0Aindex f= 2f46d055f20..27c56b5874f8 100644=0A--- a/scripts/Makefile.lib=0A+++ b/scrip= ts/Makefile.lib=0A@@ -393,10 +393,14 @@ cmd_xzmisc =3D (cat $(filter-out FO= RCE,$^) | \=0A # ----------------------------------------------------------= -----------------=0A =0A # Default sed regexp - multiline due to syntax con= straints=0A+#=0A+# Use [:space:] because LLVM's integrated assembler insert= s around=0A+# the .ascii directive whereas GCC keeps the as-i= s.=0A define sed-offsets=0A- "/^->/{s:->#\(.*\):/* \1 */:; \=0A+ 's:^[[:spa= ce:]]*\.ascii[[:space:]]*"\(.*\)".*:\1:; \=0A+ /^->/{s:->#\(.*\):/* \1 */:;= \=0A s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; \=0A= - s:->::; p;}"=0A+ s:->::; p;}'=0A endef=0A =0A # Use filechk to avoid rebu= ilds when a header changes, but the resulting file=0A-- =0A2.20.0.rc0=0A=0A= =0AFrom d576de2ca84114bb94224bf5d1f2f9f7566c36f5 Mon Sep 17 00:00:00 2001= =0AFrom: Masahiro Yamada =0ADate: Thu, 13 Ap= r 2017 07:25:21 +0900=0ASubject: [PATCH 06/32] kbuild: drop -Wno-unknown-wa= rning-option from clang=0A options=0A=0Acommit a0ae981eba8f07dbc74bce38fd3a= 462b69a5bc8e upstream.=0A=0ASince commit c3f0d0bc5b01 ("kbuild, LLVMLinux: = Add -Werror to=0Acc-option to support clang"), cc-option and friends work n= icely=0Afor clang.=0A=0AHowever, -Wno-unknown-warning-option makes clang ha= ppy with any=0Aunknown warning options even if -Werror is specified.=0A=0AO= nce -Wno-unknown-warning-option is added, any succeeding call of=0Acc-disab= le-warning is evaluated positive, then unknown warning=0Aoptions are accept= ed. This should be dropped.=0A=0ASigned-off-by: Masahiro Yamada =0ASigned-off-by: Nathan Chancellor =0A---=0A Makefile | 1 -=0A scripts/Makefile.extr= awarn | 1 -=0A 2 files changed, 2 deletions(-)=0A=0Adiff --git a/Makefile b= /Makefile=0Aindex 3713f35f453b..b7eed70d6c19 100644=0A--- a/Makefile=0A+++ = b/Makefile=0A@@ -708,7 +708,6 @@ endif=0A KBUILD_CFLAGS +=3D $(CLANG_TARGET= ) $(CLANG_GCC_TC)=0A KBUILD_AFLAGS +=3D $(CLANG_TARGET) $(CLANG_GCC_TC)=0A = KBUILD_CPPFLAGS +=3D $(call cc-option,-Qunused-arguments,)=0A-KBUILD_CPPFLA= GS +=3D $(call cc-option,-Wno-unknown-warning-option,)=0A KBUILD_CFLAGS += =3D $(call cc-disable-warning, unused-variable)=0A KBUILD_CFLAGS +=3D $(cal= l cc-disable-warning, format-invalid-specifier)=0A KBUILD_CFLAGS +=3D $(cal= l cc-disable-warning, gnu)=0Adiff --git a/scripts/Makefile.extrawarn b/scri= pts/Makefile.extrawarn=0Aindex da3386a9d244..abe5f47b1ab0 100644=0A--- a/sc= ripts/Makefile.extrawarn=0A+++ b/scripts/Makefile.extrawarn=0A@@ -61,7 +61,= 6 @@ ifeq ($(cc-name),clang)=0A KBUILD_CFLAGS +=3D $(call cc-disable-warnin= g, initializer-overrides)=0A KBUILD_CFLAGS +=3D $(call cc-disable-warning, = unused-value)=0A KBUILD_CFLAGS +=3D $(call cc-disable-warning, format)=0A-K= BUILD_CFLAGS +=3D $(call cc-disable-warning, unknown-warning-option)=0A KBU= ILD_CFLAGS +=3D $(call cc-disable-warning, sign-compare)=0A KBUILD_CFLAGS += =3D $(call cc-disable-warning, format-zero-length)=0A KBUILD_CFLAGS +=3D $(= call cc-disable-warning, uninitialized)=0A-- =0A2.20.0.rc0=0A=0A=0AFrom 5f0= 5206b4ad37866bc03aedc0c4ce15e212f95cd Mon Sep 17 00:00:00 2001=0AFrom: Mark= Charlebois =0ADate: Fri, 31 Mar 2017 22:38:13 +0200=0A= Subject: [PATCH 07/32] kbuild, LLVMLinux: Add -Werror to cc-option to suppo= rt=0A clang=0AMIME-Version: 1.0=0AContent-Type: text/plain; charset=3DUTF-8= =0AContent-Transfer-Encoding: 8bit=0A=0Acommit c3f0d0bc5b01ad90c45276952802= 455750444b4f upstream.=0A=0AClang will warn about unknown warnings but will= not return false=0Aunless -Werror is set. GCC will return false if an unkn= own=0Awarning is passed.=0A=0AAdding -Werror make both compiler behave the = same.=0A=0A[arnd: it turns out we need the same patch for testing whether -= ffunction-sections=0A works right with gcc. I've build tested extensi= vely with this patch=0A applied, so let's just merge this one now.]= =0A=0ASigned-off-by: Mark Charlebois =0ASigned-off-by: = Behan Webster =0AReviewed-by: Jan-Simon M=C3=B6l= ler =0ASigned-off-by: Arnd Bergmann =0AAcked-b= y: Kees Cook =0ASigned-off-by: Masahiro Yamada =0A[nc: Adjust context due to lack of d26e9414927= 6f]=0ASigned-off-by: Nathan Chancellor =0A---=0A = scripts/Kbuild.include | 6 +++---=0A 1 file changed, 3 insertions(+), 3 del= etions(-)=0A=0Adiff --git a/scripts/Kbuild.include b/scripts/Kbuild.include= =0Aindex 5897fc3857a0..87ee353b8254 100644=0A--- a/scripts/Kbuild.include= =0A+++ b/scripts/Kbuild.include=0A@@ -112,12 +112,12 @@ as-instr =3D $(call= try-run,\=0A # Usage: cflags-y +=3D $(call cc-option,-march=3Dwinchip-c6,-= march=3Di586)=0A =0A cc-option =3D $(call try-run,\=0A- $(CC) $(KBUILD_CPPF= LAGS) $(KBUILD_CFLAGS) $(1) -c -x c /dev/null -o "$$TMP",$(1),$(2))=0A+ $(C= C) -Werror $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) $(1) -c -x c /dev/null -o "$= $TMP",$(1),$(2))=0A =0A # cc-option-yn=0A # Usage: flag :=3D $(call cc-opti= on-yn,-march=3Dwinchip-c6)=0A cc-option-yn =3D $(call try-run,\=0A- $(CC) $= (KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) $(1) -c -x c /dev/null -o "$$TMP",y,n)= =0A+ $(CC) -Werror $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) $(1) -c -x c /dev/nu= ll -o "$$TMP",y,n)=0A =0A # cc-option-align=0A # Prefix align with either -= falign or -malign=0A@@ -127,7 +127,7 @@ cc-option-align =3D $(subst -functi= ons=3D0,,\=0A # cc-disable-warning=0A # Usage: cflags-y +=3D $(call cc-disa= ble-warning,unused-but-set-variable)=0A cc-disable-warning =3D $(call try-r= un,\=0A- $(CC) $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) -W$(strip $(1)) -c -x c = /dev/null -o "$$TMP",-Wno-$(strip $(1)))=0A+ $(CC) -Werror $(KBUILD_CPPFLAG= S) $(KBUILD_CFLAGS) -W$(strip $(1)) -c -x c /dev/null -o "$$TMP",-Wno-$(str= ip $(1)))=0A =0A # cc-name=0A # Expands to either gcc or clang=0A-- =0A2.20= =2E0.rc0=0A=0A=0AFrom ce2a93bcf8c5cde87a15310a35addae19925b7db Mon Sep 17 0= 0:00:00 2001=0AFrom: Behan Webster =0ADate: Mon,= 27 Mar 2017 18:19:09 -0700=0ASubject: [PATCH 08/32] kbuild: use -Oz instea= d of -Os when using clang=0A=0Acommit 6748cb3c299de1ffbe56733647b01dbcc398c= 419 upstream.=0A=0AThis generates smaller resulting object code when compil= ed with clang.=0A=0ASigned-off-by: Behan Webster =0ASigned-off-by: Matthias Kaehlcke =0ASigned-off-by: Ma= sahiro Yamada =0A[nc: Adjust context due to = lack of commit a76bcf557ef4 in linux-4.4.y]=0ASigned-off-by: Nathan Chancel= lor =0A---=0A Makefile | 2 +-=0A 1 file changed, = 1 insertion(+), 1 deletion(-)=0A=0Adiff --git a/Makefile b/Makefile=0Aindex= b7eed70d6c19..7ee534035d84 100644=0A--- a/Makefile=0A+++ b/Makefile=0A@@ -= 628,7 +628,7 @@ KBUILD_CFLAGS +=3D $(call cc-disable-warning, int-in-bool-c= ontext)=0A KBUILD_CFLAGS +=3D $(call cc-disable-warning, attribute-alias)= =0A =0A ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE=0A-KBUILD_CFLAGS +=3D -Os=0A+KBUI= LD_CFLAGS +=3D $(call cc-option,-Oz,-Os)=0A else=0A ifdef CONFIG_PROFILE_AL= L_BRANCHES=0A KBUILD_CFLAGS +=3D -O2=0A-- =0A2.20.0.rc0=0A=0A=0AFrom baca48= ef4318b2f879581b1345a3120b44666c64 Mon Sep 17 00:00:00 2001=0AFrom: =3D?UTF= -8?q?Vin=3DC3=3DADcius=3D20Tinti?=3D =0ADate: Mon,= 24 Apr 2017 13:04:58 -0700=0ASubject: [PATCH 09/32] kbuild: Add support to= generate LLVM assembly files=0AMIME-Version: 1.0=0AContent-Type: text/plai= n; charset=3DUTF-8=0AContent-Transfer-Encoding: 8bit=0A=0Acommit 433db3e260= bc8134d4a46ddf20b3668937e12556 upstream.=0A=0AAdd rules to kbuild in order = to generate LLVM assembly files with the .ll=0Aextension when using clang.= =0A=0A # from c code=0A make CC=3Dclang kernel/pid.ll=0A=0ASigned-off-by:= Vin=C3=ADcius Tinti =0ASigned-off-by: Behan Webst= er =0ASigned-off-by: Matthias Kaehlcke =0ASigned-off-by: Masahiro Yamada = =0A[nc: Fix conflicts due to lack of commit 6b90bd4ba40b3 in linux-4.4.y]= =0ASigned-off-by: Nathan Chancellor =0A---=0A .gi= tignore | 1 +=0A Makefile | 5 +++++=0A scripts/Ma= kefile.build | 8 ++++++++=0A 3 files changed, 14 insertions(+)=0A=0Adiff --= git a/.gitignore b/.gitignore=0Aindex fd3a35592543..34fe1346aa87 100644=0A-= -- a/.gitignore=0A+++ b/.gitignore=0A@@ -33,6 +33,7 @@=0A *.lzo=0A *.patch= =0A *.gcno=0A+*.ll=0A modules.builtin=0A Module.symvers=0A *.dwo=0Adiff --g= it a/Makefile b/Makefile=0Aindex 7ee534035d84..e88d63e4a1a7 100644=0A--- a/= Makefile=0A+++ b/Makefile=0A@@ -1307,6 +1307,8 @@ help:=0A @echo ' = (default: $$(INSTALL_MOD_PATH)/lib/firmware)'=0A @echo ' di= r/ - Build all files in dir and below'=0A @echo ' dir/file.[o= is] - Build specified target only'=0A+ @echo ' dir/file.ll - Build t= he LLVM assembly file'=0A+ @echo ' (requires compiler s= upport for LLVM assembly generation)'=0A @echo ' dir/file.lst - Build= specified mixed source/assembly target only'=0A @echo ' = (requires a recent binutils and recent build (System.map))'=0A @echo '= dir/file.ko - Build module including final link'=0A@@ -1482,6 +1484,7= @@ clean: $(clean-dirs)=0A -o -name '.*.d' -o -name '.*.tmp' -o -name '*= =2Emod.c' \=0A -o -name '*.symtypes' -o -name 'modules.order' \=0A -o -= name modules.builtin -o -name '.tmp_*.o.*' \=0A+ -o -name '*.ll' \=0A -o= -name '*.gcno' \) -type f -print | xargs rm -f=0A =0A # Generate tags for = editors=0A@@ -1585,6 +1588,8 @@ endif=0A $(Q)$(MAKE) $(build)=3D$(build-di= r) $(target-dir)$(notdir $@)=0A %.symtypes: %.c prepare scripts FORCE=0A $= (Q)$(MAKE) $(build)=3D$(build-dir) $(target-dir)$(notdir $@)=0A+%.ll: %.c p= repare scripts FORCE=0A+ $(Q)$(MAKE) $(build)=3D$(build-dir) $(target-dir)$= (notdir $@)=0A =0A # Modules=0A /: prepare scripts FORCE=0Adiff --git a/scr= ipts/Makefile.build b/scripts/Makefile.build=0Aindex 18209917e379..42aef001= dfdd 100644=0A--- a/scripts/Makefile.build=0A+++ b/scripts/Makefile.build= =0A@@ -175,6 +175,14 @@ cmd_cc_symtypes_c =3D = \=0A $(obj)/%.symtypes : $(src)/%.c FORCE=0A $(= call cmd,cc_symtypes_c)=0A =0A+# LLVM assembly=0A+# Generate .ll files from= .c=0A+quiet_cmd_cc_ll_c =3D CC $(quiet_modtag) $@=0A+ cmd_cc_ll_c = =3D $(CC) $(c_flags) -emit-llvm -S -o $@ $<=0A+=0A+$(obj)/%.ll: $(src)/%.c = FORCE=0A+ $(call if_changed_dep,cc_ll_c)=0A+=0A # C (.c) files=0A # The C f= ile is compiled and updated dependency information is generated.=0A # (See = cmd_cc_o_c + relevant part of rule_cc_o_c)=0A-- =0A2.20.0.rc0=0A=0A=0AFrom = e8bd6761b77186c7fdaa0da8e58844e49de80473 Mon Sep 17 00:00:00 2001=0AFrom: A= rnd Bergmann =0ADate: Wed, 1 Feb 2017 18:00:14 +0100=0ASubje= ct: [PATCH 10/32] modules: mark __inittest/__exittest as __maybe_unused=0A= =0Acommit 1f318a8bafcfba9f0d623f4870c4e890fd22e659 upstream.=0A=0Aclang war= ns about unused inline functions by default:=0A=0Aarch/arm/crypto/aes-ciphe= r-glue.c:68:1: warning: unused function '__inittest' [-Wunused-function]=0A= arch/arm/crypto/aes-cipher-glue.c:69:1: warning: unused function '__exittes= t' [-Wunused-function]=0A=0AAs these appear in every single module, let's j= ust disable the warnings by marking the=0Atwo functions as __maybe_unused.= =0A=0ASigned-off-by: Arnd Bergmann =0AReviewed-by: Miroslav = Benes =0AAcked-by: Rusty Russell =0A= Signed-off-by: Jessica Yu =0ASigned-off-by: Nathan Chancel= lor =0A---=0A include/linux/module.h | 4 ++--=0A = 1 file changed, 2 insertions(+), 2 deletions(-)=0A=0Adiff --git a/include/l= inux/module.h b/include/linux/module.h=0Aindex c9f2f85017ad..dfe5c2e25ba1 1= 00644=0A--- a/include/linux/module.h=0A+++ b/include/linux/module.h=0A@@ -1= 25,13 +125,13 @@ extern void cleanup_module(void);=0A =0A /* Each module mu= st use one module_init(). */=0A #define module_init(initfn) \=0A- stati= c inline initcall_t __inittest(void) \=0A+ static inline initcall_t __mayb= e_unused __inittest(void) \=0A { return initfn; } \=0A int init_modu= le(void) __attribute__((alias(#initfn)));=0A =0A /* This is only required i= f you want to be unloadable. */=0A #define module_exit(exitfn) \=0A- st= atic inline exitcall_t __exittest(void) \=0A+ static inline exitcall_t __m= aybe_unused __exittest(void) \=0A { return exitfn; } \=0A void clean= up_module(void) __attribute__((alias(#exitfn)));=0A =0A-- =0A2.20.0.rc0=0A= =0A=0AFrom 98d506e5906a98e894610d52febdf3004d309486 Mon Sep 17 00:00:00 200= 1=0AFrom: Matthias Kaehlcke =0ADate: Fri, 21 Apr 2017 14:= 39:30 -0700=0ASubject: [PATCH 11/32] kbuild: clang: Disable 'address-of-pac= ked-member'=0A warning=0A=0Acommit bfb38988c51e440fd7062ddf3157f7d8b1dd5d70= upstream.=0A=0Aclang generates plenty of these warnings in different parts= of the code,=0Ato an extent that the warnings are little more than noise. = Disable the=0A'address-of-packed-member' warning.=0A=0ASigned-off-by: Matth= ias Kaehlcke =0AReviewed-by: Douglas Anderson =0ASigned-off-by: Masahiro Yamada =0ASigned-off-by: Nathan Chancellor =0A---=0A M= akefile | 1 +=0A 1 file changed, 1 insertion(+)=0A=0Adiff --git a/Makefile = b/Makefile=0Aindex e88d63e4a1a7..b0f480583f0d 100644=0A--- a/Makefile=0A+++= b/Makefile=0A@@ -711,6 +711,7 @@ KBUILD_CPPFLAGS +=3D $(call cc-option,-Qu= nused-arguments,)=0A KBUILD_CFLAGS +=3D $(call cc-disable-warning, unused-v= ariable)=0A KBUILD_CFLAGS +=3D $(call cc-disable-warning, format-invalid-sp= ecifier)=0A KBUILD_CFLAGS +=3D $(call cc-disable-warning, gnu)=0A+KBUILD_CF= LAGS +=3D $(call cc-disable-warning, address-of-packed-member)=0A # Quiet c= lang warning: comparison of unsigned expression < 0 is always false=0A KBUI= LD_CFLAGS +=3D $(call cc-disable-warning, tautological-compare)=0A # CLANG = uses a _MergedGlobals as optimization, but this breaks modpost, as the=0A--= =0A2.20.0.rc0=0A=0A=0AFrom f9008c1ca85f7444df2caee14a122df2218062d8 Mon Se= p 17 00:00:00 2001=0AFrom: Ard Biesheuvel =0ADat= e: Wed, 26 Apr 2017 17:11:32 +0100=0ASubject: [PATCH 12/32] crypto: arm64/s= ha - avoid non-standard inline asm=0A tricks=0A=0Acommit f4857f4c2ee9aa4e2a= acac1a845352b00197fb57 upstream.=0A=0AReplace the inline asm which exports = struct offsets as ELF symbols=0Awith proper const variables exposing the sa= me values. This works=0Aaround an issue with Clang which does not interpret= the "i" (or "I")=0Aconstraints in the same way as GCC.=0A=0ASigned-off-by:= Ard Biesheuvel =0ATested-by: Matthias Kaehlcke = =0ASigned-off-by: Herbert Xu =0ASigned-off-by: Nathan Chancellor =0A---=0A ar= ch/arm64/crypto/sha1-ce-core.S | 6 ++++--=0A arch/arm64/crypto/sha1-ce-glu= e.c | 11 +++--------=0A arch/arm64/crypto/sha2-ce-core.S | 6 ++++--=0A arc= h/arm64/crypto/sha2-ce-glue.c | 13 +++++--------=0A 4 files changed, 16 ins= ertions(+), 20 deletions(-)=0A=0Adiff --git a/arch/arm64/crypto/sha1-ce-cor= e.S b/arch/arm64/crypto/sha1-ce-core.S=0Aindex c98e7e849f06..8550408735a0 1= 00644=0A--- a/arch/arm64/crypto/sha1-ce-core.S=0A+++ b/arch/arm64/crypto/sh= a1-ce-core.S=0A@@ -82,7 +82,8 @@ ENTRY(sha1_ce_transform)=0A ldr dgb, [x0= , #16]=0A =0A /* load sha1_ce_state::finalize */=0A- ldr w4, [x0, #:lo12:= sha1_ce_offsetof_finalize]=0A+ ldr_l w4, sha1_ce_offsetof_finalize, x4=0A+= ldr w4, [x0, x4]=0A =0A /* load input */=0A 0: ld1 {v8.4s-v11.4s}, [x1]= , #64=0A@@ -132,7 +133,8 @@ CPU_LE( rev32 v11.16b, v11.16b )=0A * the pa= dding is handled by the C code in that case.=0A */=0A cbz x4, 3f=0A- ld= r x4, [x0, #:lo12:sha1_ce_offsetof_count]=0A+ ldr_l w4, sha1_ce_offsetof_= count, x4=0A+ ldr x4, [x0, x4]=0A movi v9.2d, #0=0A mov x8, #0x8000000= 0=0A movi v10.2d, #0=0Adiff --git a/arch/arm64/crypto/sha1-ce-glue.c b/ar= ch/arm64/crypto/sha1-ce-glue.c=0Aindex aefda9868627..ea319c055f5d 100644=0A= --- a/arch/arm64/crypto/sha1-ce-glue.c=0A+++ b/arch/arm64/crypto/sha1-ce-gl= ue.c=0A@@ -17,9 +17,6 @@=0A #include =0A #include =0A =0A-#define ASM_EXPORT(sym, val) \=0A- asm(".globl " #sym "; .se= t " #sym ", %0" :: "I"(val));=0A-=0A MODULE_DESCRIPTION("SHA1 secure hash u= sing ARMv8 Crypto Extensions");=0A MODULE_AUTHOR("Ard Biesheuvel ");=0A MODULE_LICENSE("GPL v2");=0A@@ -32,6 +29,9 @@ struc= t sha1_ce_state {=0A asmlinkage void sha1_ce_transform(struct sha1_ce_state= *sst, u8 const *src,=0A int blocks);=0A =0A+const u32 sha1_ce_offset= of_count =3D offsetof(struct sha1_ce_state, sst.count);=0A+const u32 sha1_c= e_offsetof_finalize =3D offsetof(struct sha1_ce_state, finalize);=0A+=0A st= atic int sha1_ce_update(struct shash_desc *desc, const u8 *data,=0A un= signed int len)=0A {=0A@@ -52,11 +52,6 @@ static int sha1_ce_finup(struct s= hash_desc *desc, const u8 *data,=0A struct sha1_ce_state *sctx =3D shash_d= esc_ctx(desc);=0A bool finalize =3D !sctx->sst.count && !(len % SHA1_BLOCK= _SIZE);=0A =0A- ASM_EXPORT(sha1_ce_offsetof_count,=0A- offsetof(struct = sha1_ce_state, sst.count));=0A- ASM_EXPORT(sha1_ce_offsetof_finalize,=0A- = offsetof(struct sha1_ce_state, finalize));=0A-=0A /*=0A * Allow the a= sm code to perform the finalization if there is no=0A * partial data and = the input is a round multiple of the block size.=0Adiff --git a/arch/arm64/= crypto/sha2-ce-core.S b/arch/arm64/crypto/sha2-ce-core.S=0Aindex 01cfee0668= 37..679c6c002f4f 100644=0A--- a/arch/arm64/crypto/sha2-ce-core.S=0A+++ b/ar= ch/arm64/crypto/sha2-ce-core.S=0A@@ -88,7 +88,8 @@ ENTRY(sha2_ce_transform)= =0A ld1 {dgav.4s, dgbv.4s}, [x0]=0A =0A /* load sha256_ce_state::finaliz= e */=0A- ldr w4, [x0, #:lo12:sha256_ce_offsetof_finalize]=0A+ ldr_l w4, s= ha256_ce_offsetof_finalize, x4=0A+ ldr w4, [x0, x4]=0A =0A /* load input = */=0A 0: ld1 {v16.4s-v19.4s}, [x1], #64=0A@@ -136,7 +137,8 @@ CPU_LE( rev3= 2 v19.16b, v19.16b )=0A * the padding is handled by the C code in that c= ase.=0A */=0A cbz x4, 3f=0A- ldr x4, [x0, #:lo12:sha256_ce_offsetof_co= unt]=0A+ ldr_l w4, sha256_ce_offsetof_count, x4=0A+ ldr x4, [x0, x4]=0A = movi v17.2d, #0=0A mov x8, #0x80000000=0A movi v18.2d, #0=0Adiff --git= a/arch/arm64/crypto/sha2-ce-glue.c b/arch/arm64/crypto/sha2-ce-glue.c=0Ain= dex 7cd587564a41..0ed9486f75dd 100644=0A--- a/arch/arm64/crypto/sha2-ce-glu= e.c=0A+++ b/arch/arm64/crypto/sha2-ce-glue.c=0A@@ -17,9 +17,6 @@=0A #includ= e =0A #include =0A =0A-#define ASM_EXPORT(s= ym, val) \=0A- asm(".globl " #sym "; .set " #sym ", %0" :: "I"(val));=0A-= =0A MODULE_DESCRIPTION("SHA-224/SHA-256 secure hash using ARMv8 Crypto Exte= nsions");=0A MODULE_AUTHOR("Ard Biesheuvel ");= =0A MODULE_LICENSE("GPL v2");=0A@@ -32,6 +29,11 @@ struct sha256_ce_state {= =0A asmlinkage void sha2_ce_transform(struct sha256_ce_state *sst, u8 const= *src,=0A int blocks);=0A =0A+const u32 sha256_ce_offsetof_count =3D = offsetof(struct sha256_ce_state,=0A+ sst.count);=0A+const u32 sha= 256_ce_offsetof_finalize =3D offsetof(struct sha256_ce_state,=0A+ fin= alize);=0A+=0A static int sha256_ce_update(struct shash_desc *desc, const u= 8 *data,=0A unsigned int len)=0A {=0A@@ -52,11 +54,6 @@ static int s= ha256_ce_finup(struct shash_desc *desc, const u8 *data,=0A struct sha256_c= e_state *sctx =3D shash_desc_ctx(desc);=0A bool finalize =3D !sctx->sst.co= unt && !(len % SHA256_BLOCK_SIZE);=0A =0A- ASM_EXPORT(sha256_ce_offsetof_co= unt,=0A- offsetof(struct sha256_ce_state, sst.count));=0A- ASM_EXPORT(s= ha256_ce_offsetof_finalize,=0A- offsetof(struct sha256_ce_state, finali= ze));=0A-=0A /*=0A * Allow the asm code to perform the finalization if t= here is no=0A * partial data and the input is a round multiple of the blo= ck size.=0A-- =0A2.20.0.rc0=0A=0A=0AFrom eae68cb36d60fbf7dd4679ab9482292d7b= 7749e5 Mon Sep 17 00:00:00 2001=0AFrom: Ard Biesheuvel =0ADate: Fri, 18 Aug 2017 20:49:36 +0100=0ASubject: [PATCH 13/32] ef= i/libstub/arm64: Force 'hidden' visibility for=0A section markers=0A=0Acomm= it 0426a4e68f18d75515414361de9e3e1445d2644e upstream.=0A=0ATo prevent the c= ompiler from emitting absolute references to the section=0Amarkers when run= ning in PIC mode, override the visibility to 'hidden' for=0Aall contents of= asm/sections.h=0A=0ATested-by: Matthias Kaehlcke =0ASign= ed-off-by: Ard Biesheuvel =0ACc: Linus Torvalds = =0ACc: Matt Fleming =0ACc: Peter Zijlstra =0ACc: Thomas Gleixner =0ACc: linux-efi@vger.kernel.org=0ALink: http://lkml.kernel.o= rg/r/20170818194947.19347-4-ard.biesheuvel@linaro.org=0ASigned-off-by: Ingo= Molnar =0A[nc: Fix conflict due to lack of commit 42b557= 34030c1 in linux-4.4.y]=0ASigned-off-by: Nathan Chancellor =0A---=0A drivers/firmware/efi/libstub/arm64-stub.c | 10 ++++++++= +-=0A 1 file changed, 9 insertions(+), 1 deletion(-)=0A=0Adiff --git a/driv= ers/firmware/efi/libstub/arm64-stub.c b/drivers/firmware/efi/libstub/arm64-= stub.c=0Aindex 78dfbd34b6bf..044efb779ed1 100644=0A--- a/drivers/firmware/e= fi/libstub/arm64-stub.c=0A+++ b/drivers/firmware/efi/libstub/arm64-stub.c= =0A@@ -9,9 +9,17 @@=0A * published by the Free Software Foundation.=0A *= =0A */=0A+=0A+/*=0A+ * To prevent the compiler from emitting GOT-indirecte= d (and thus absolute)=0A+ * references to the section markers, override the= ir visibility as 'hidden'=0A+ */=0A+#pragma GCC visibility push(hidden)=0A+= #include =0A+#pragma GCC visibility pop=0A+=0A #include =0A #include =0A-#include =0A =0A efi_= status_t __init handle_kernel_image(efi_system_table_t *sys_table_arg,=0A = unsigned long *image_addr,=0A-- =0A2.20.0.rc0=0A=0A=0AFrom 5d0a6e964090= 13808b8d7733b55f24a37ab91476 Mon Sep 17 00:00:00 2001=0AFrom: Ard Biesheuve= l =0ADate: Fri, 18 Aug 2017 20:49:37 +0100=0ASub= ject: [PATCH 14/32] efi/libstub/arm64: Set -fpie when building the EFI stub= =0A=0Acommit 91ee5b21ee026c49e4e7483de69b55b8b47042be upstream.=0A=0AClang = may emit absolute symbol references when building in non-PIC mode,=0Aeven w= hen using the default 'small' code model, which is already mostly=0Apositio= n independent to begin with, due to its use of adrp/add pairs=0Athat have a= relative range of +/- 4 GB. The remedy is to pass the -fpie=0Aflag, which = can be done safely now that the code has been updated to avoid=0AGOT indire= ctions (which may be emitted due to the compiler assuming that=0Athe PIC/PI= E code may end up in a shared library that is subject to ELF=0Asymbol preem= ption)=0A=0APassing -fpie when building code that needs to execute at an a = priori=0Aunknown offset is arguably an improvement in any case, and given t= hat=0Athe recent visibility changes allow the PIC build to pass with GCC as= =0Awell, let's add -fpie for all arm64 builds rather than only for Clang.= =0A=0ATested-by: Matthias Kaehlcke =0ASigned-off-by: Ard = Biesheuvel =0ACc: Linus Torvalds =0ACc: Matt Fleming =0ACc: Peter = Zijlstra =0ACc: Thomas Gleixner = =0ACc: linux-efi@vger.kernel.org=0ALink: http://lkml.kernel.org/r/201708181= 94947.19347-5-ard.biesheuvel@linaro.org=0ASigned-off-by: Ingo Molnar =0ASigned-off-by: Nathan Chancellor = =0A---=0A drivers/firmware/efi/libstub/Makefile | 2 +-=0A 1 file changed, 1= insertion(+), 1 deletion(-)=0A=0Adiff --git a/drivers/firmware/efi/libstub= /Makefile b/drivers/firmware/efi/libstub/Makefile=0Aindex 3c0467d3688c..88b= d6829a358 100644=0A--- a/drivers/firmware/efi/libstub/Makefile=0A+++ b/driv= ers/firmware/efi/libstub/Makefile=0A@@ -10,7 +10,7 @@ cflags-$(CONFIG_X86) = +=3D -m$(BITS) -D__KERNEL__ $(LINUX_INCLUDE) -O2 \=0A -fPIC -fno-st= rict-aliasing -mno-red-zone \=0A -mno-mmx -mno-sse -DDISABLE_BRANCH_= PROFILING=0A =0A-cflags-$(CONFIG_ARM64) :=3D $(subst -pg,,$(KBUILD_CFLAGS)= )=0A+cflags-$(CONFIG_ARM64) :=3D $(subst -pg,,$(KBUILD_CFLAGS)) -fpie=0A c= flags-$(CONFIG_ARM) :=3D $(subst -pg,,$(KBUILD_CFLAGS)) \=0A -fno-b= uiltin -fpic -mno-single-pic-base=0A =0A-- =0A2.20.0.rc0=0A=0A=0AFrom ad267= f564720a4690786e85da12cce527fa50890 Mon Sep 17 00:00:00 2001=0AFrom: Nick D= esaulniers =0ADate: Mon, 6 Nov 2017 10:47:54 -0800= =0ASubject: [PATCH 15/32] kbuild: fix linker feature test macros when cross= =0A compiling with Clang=0A=0Acommit 86a9df597cdd564d2d29c65897bcad42519e36= 78 upstream.=0A=0AI was not seeing my linker flags getting added when using= ld-option when=0Across compiling with Clang. Upon investigation, this seem= s to be due to=0Aa difference in how GCC vs Clang handle cross compilation.= =0A=0AGCC is configured at build time to support one backend, that is impli= cit=0Awhen compiling. Clang is explicit via the use of `-target ` = and=0Aships with all supported backends by default.=0A=0AGNU Make feature t= est macros that compile then link will always fail=0Awhen cross compiling w= ith Clang unless Clang's triple is passed along to=0Athe compiler. For exam= ple:=0A=0A$ clang -x c /dev/null -c -o temp.o=0A$ aarch64-linux-android/bin= /ld -E temp.o=0Aaarch64-linux-android/bin/ld:=0Aunknown architecture of inp= ut file `temp.o' is incompatible with=0Aaarch64 output=0Aaarch64-linux-andr= oid/bin/ld:=0Awarning: cannot find entry symbol _start; defaulting to=0A000= 0000000400078=0A$ echo $?=0A1=0A=0A$ clang -target aarch64-linux-android- -= x c /dev/null -c -o temp.o=0A$ aarch64-linux-android/bin/ld -E temp.o=0Aaar= ch64-linux-android/bin/ld:=0Awarning: cannot find entry symbol _start; defa= ulting to 00000000004002e4=0A$ echo $?=0A0=0A=0AThis causes conditional che= cks that invoke $(CC) without the target=0Atriple, then $(LD) on the result= , to always fail.=0A=0ASuggested-by: Masahiro Yamada =0ASigned-off-by: Nick Desaulniers =0ARev= iewed-by: Matthias Kaehlcke =0ASigned-off-by: Masahiro Ya= mada =0A[nc: Fix conflicts due to lack of co= mmit 3298b690b21cd in linux-4.4.y=0A Use KBUILD_CFLAGS instead of CC_OP= TION_FLAGS because commit=0A d26e94149276f that introduced that variabl= e isn't in 4.4 either]=0ASigned-off-by: Nathan Chancellor =0A---=0A scripts/Kbuild.include | 5 +++--=0A 1 file changed, 3 in= sertions(+), 2 deletions(-)=0A=0Adiff --git a/scripts/Kbuild.include b/scri= pts/Kbuild.include=0Aindex 87ee353b8254..9f634b50e57b 100644=0A--- a/script= s/Kbuild.include=0A+++ b/scripts/Kbuild.include=0A@@ -147,12 +147,13 @@ cc-= ifversion =3D $(shell [ $(cc-version) $(1) $(2) ] && echo $(3) || echo $(4)= )=0A # cc-ldoption=0A # Usage: ldflags +=3D $(call cc-ldoption, -Wl$(comma)= --hash-style=3Dboth)=0A cc-ldoption =3D $(call try-run,\=0A- $(CC) $(1) -no= stdlib -x c /dev/null -o "$$TMP",$(1),$(2))=0A+ $(CC) $(1) $(KBUILD_CPPFLAG= S) $(KBUILD_CFLAGS) -nostdlib -x c /dev/null -o "$$TMP",$(1),$(2))=0A =0A #= ld-option=0A # Usage: LDFLAGS +=3D $(call ld-option, -X)=0A ld-option =3D = $(call try-run,\=0A- $(CC) -x c /dev/null -c -o "$$TMPO" ; $(LD) $(1) "$$TM= PO" -o "$$TMP",$(1),$(2))=0A+ $(CC) $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) -x = c /dev/null -c -o "$$TMPO"; \=0A+ $(LD) $(LDFLAGS) $(1) "$$TMPO" -o "$$TMP"= ,$(1),$(2))=0A =0A # ar-option=0A # Usage: KBUILD_ARFLAGS :=3D $(call ar-op= tion,D)=0A-- =0A2.20.0.rc0=0A=0A=0AFrom 9bef97a81a6bc1e074db6b2e75e1d1b60a4= 440bf Mon Sep 17 00:00:00 2001=0AFrom: Chris Fries =0ADa= te: Tue, 7 Nov 2017 11:46:13 -0800=0ASubject: [PATCH 16/32] kbuild: Set KBU= ILD_CFLAGS before incl. arch Makefile=0A=0Acommit ae6b289a37890909fea0e4a16= 66e19377fa0ed2c upstream.=0A=0ASet the clang KBUILD_CFLAGS up before includ= ing arch/ Makefiles,=0Aso that ld-options (etc.) can work correctly.=0A=0AT= his fixes errors with clang such as ld-options trying to CC=0Aagainst your = host architecture, but LD trying to link against=0Ayour target architecture= =2E=0A=0ASigned-off-by: Chris Fries =0ASigned-off-by: Ni= ck Desaulniers =0AReviewed-by: Matthias Kaehlcke <= mka@chromium.org>=0ATested-by: Matthias Kaehlcke =0ASigne= d-off-by: Masahiro Yamada =0A[nc: Adjust con= text]=0ASigned-off-by: Nathan Chancellor =0A---= =0A Makefile | 64 ++++++++++++++++++++++++++++----------------------------= =0A 1 file changed, 32 insertions(+), 32 deletions(-)=0A=0Adiff --git a/Mak= efile b/Makefile=0Aindex b0f480583f0d..3c91be474fec 100644=0A--- a/Makefile= =0A+++ b/Makefile=0A@@ -612,6 +612,38 @@ endif # $(dot-config)=0A # Default= s to vmlinux, but the arch makefile usually adds further targets=0A all: vm= linux=0A =0A+ifeq ($(cc-name),clang)=0A+ifneq ($(CROSS_COMPILE),)=0A+CLANG_= TARGET :=3D -target $(notdir $(CROSS_COMPILE:%-=3D%))=0A+GCC_TOOLCHAIN :=3D= $(realpath $(dir $(shell which $(LD)))/..)=0A+endif=0A+ifneq ($(GCC_TOOLCH= AIN),)=0A+CLANG_GCC_TC :=3D -gcc-toolchain $(GCC_TOOLCHAIN)=0A+endif=0A+KBU= ILD_CFLAGS +=3D $(CLANG_TARGET) $(CLANG_GCC_TC)=0A+KBUILD_AFLAGS +=3D $(CLA= NG_TARGET) $(CLANG_GCC_TC)=0A+KBUILD_CPPFLAGS +=3D $(call cc-option,-Qunuse= d-arguments,)=0A+KBUILD_CFLAGS +=3D $(call cc-disable-warning, unused-varia= ble)=0A+KBUILD_CFLAGS +=3D $(call cc-disable-warning, format-invalid-specif= ier)=0A+KBUILD_CFLAGS +=3D $(call cc-disable-warning, gnu)=0A+KBUILD_CFLAGS= +=3D $(call cc-disable-warning, address-of-packed-member)=0A+# Quiet clang= warning: comparison of unsigned expression < 0 is always false=0A+KBUILD_C= FLAGS +=3D $(call cc-disable-warning, tautological-compare)=0A+# CLANG uses= a _MergedGlobals as optimization, but this breaks modpost, as the=0A+# sou= rce of a reference will be _MergedGlobals and not on of the whitelisted nam= es.=0A+# See modpost pattern 2=0A+KBUILD_CFLAGS +=3D $(call cc-option, -mno= -global-merge,)=0A+KBUILD_CFLAGS +=3D $(call cc-option, -fcatch-undefined-b= ehavior)=0A+KBUILD_CFLAGS +=3D $(call cc-option, -no-integrated-as)=0A+KBUI= LD_AFLAGS +=3D $(call cc-option, -no-integrated-as)=0A+else=0A+=0A+# These = warnings generated too much noise in a regular build.=0A+# Use make W=3D1 t= o enable them (see scripts/Makefile.build)=0A+KBUILD_CFLAGS +=3D $(call cc-= disable-warning, unused-but-set-variable)=0A+KBUILD_CFLAGS +=3D $(call cc-d= isable-warning, unused-const-variable)=0A+endif=0A+=0A # The arch Makefile = can set ARCH_{CPP,A,C}FLAGS to override the default=0A # values of the resp= ective KBUILD_* variables=0A ARCH_CPPFLAGS :=3D=0A@@ -697,38 +729,6 @@ endi= f=0A endif=0A KBUILD_CFLAGS +=3D $(stackp-flag)=0A =0A-ifeq ($(cc-name),cla= ng)=0A-ifneq ($(CROSS_COMPILE),)=0A-CLANG_TARGET :=3D -target $(notdir $(CR= OSS_COMPILE:%-=3D%))=0A-GCC_TOOLCHAIN :=3D $(realpath $(dir $(shell which $= (LD)))/..)=0A-endif=0A-ifneq ($(GCC_TOOLCHAIN),)=0A-CLANG_GCC_TC :=3D -gcc-= toolchain $(GCC_TOOLCHAIN)=0A-endif=0A-KBUILD_CFLAGS +=3D $(CLANG_TARGET) $= (CLANG_GCC_TC)=0A-KBUILD_AFLAGS +=3D $(CLANG_TARGET) $(CLANG_GCC_TC)=0A-KBU= ILD_CPPFLAGS +=3D $(call cc-option,-Qunused-arguments,)=0A-KBUILD_CFLAGS += =3D $(call cc-disable-warning, unused-variable)=0A-KBUILD_CFLAGS +=3D $(cal= l cc-disable-warning, format-invalid-specifier)=0A-KBUILD_CFLAGS +=3D $(cal= l cc-disable-warning, gnu)=0A-KBUILD_CFLAGS +=3D $(call cc-disable-warning,= address-of-packed-member)=0A-# Quiet clang warning: comparison of unsigned= expression < 0 is always false=0A-KBUILD_CFLAGS +=3D $(call cc-disable-war= ning, tautological-compare)=0A-# CLANG uses a _MergedGlobals as optimizatio= n, but this breaks modpost, as the=0A-# source of a reference will be _Merg= edGlobals and not on of the whitelisted names.=0A-# See modpost pattern 2= =0A-KBUILD_CFLAGS +=3D $(call cc-option, -mno-global-merge,)=0A-KBUILD_CFLA= GS +=3D $(call cc-option, -fcatch-undefined-behavior)=0A-KBUILD_CFLAGS +=3D= $(call cc-option, -no-integrated-as)=0A-KBUILD_AFLAGS +=3D $(call cc-optio= n, -no-integrated-as)=0A-else=0A-=0A-# These warnings generated too much no= ise in a regular build.=0A-# Use make W=3D1 to enable them (see scripts/Mak= efile.build)=0A-KBUILD_CFLAGS +=3D $(call cc-disable-warning, unused-but-se= t-variable)=0A-KBUILD_CFLAGS +=3D $(call cc-disable-warning, unused-const-v= ariable)=0A-endif=0A-=0A ifdef CONFIG_FRAME_POINTER=0A KBUILD_CFLAGS +=3D -= fno-omit-frame-pointer -fno-optimize-sibling-calls=0A else=0A-- =0A2.20.0.r= c0=0A=0A=0AFrom e27b141a615c1119322ad71e052eac01a1778c23 Mon Sep 17 00:00:0= 0 2001=0AFrom: Masahiro Yamada =0ADate: Mon,= 27 Nov 2017 21:15:13 +0900=0ASubject: [PATCH 17/32] kbuild: move cc-option= and cc-disable-warning after=0A incl. arch Makefile=0A=0Acommit cfe17c9bbe= 6a673fdafdab179c32b355ed447f66 upstream.=0A=0AGeert reported commit ae6b289= a3789 ("kbuild: Set KBUILD_CFLAGS before=0Aincl. arch Makefile") broke cros= s-compilation using a cross-compiler=0Athat supports less compiler options = than the host compiler.=0A=0AFor example,=0A=0A cc1: error: unrecognized c= ommand line option "-Wno-unused-but-set-variable"=0A=0AThis problem happens= on architectures that setup CROSS_COMPILE in their=0Aarch/*/Makefile.=0A= =0AMove the cc-option and cc-disable-warning back to the original position,= =0Abut keep the Clang target options untouched.=0A=0AFixes: ae6b289a3789 ("= kbuild: Set KBUILD_CFLAGS before incl. arch Makefile")=0AReported-by: Geert= Uytterhoeven =0ASigned-off-by: Masahiro Yamada =0ATested-by: Geert Uytterhoeven =0A[nc: Adjust context]=0ASigned-off-by: Nathan Chancellor =0A---=0A Makefile | 43 +++++++++++++++++++++++------------= --------=0A 1 file changed, 23 insertions(+), 20 deletions(-)=0A=0Adiff --g= it a/Makefile b/Makefile=0Aindex 3c91be474fec..9f9508507a6e 100644=0A--- a/= Makefile=0A+++ b/Makefile=0A@@ -622,26 +622,6 @@ CLANG_GCC_TC :=3D -gcc-too= lchain $(GCC_TOOLCHAIN)=0A endif=0A KBUILD_CFLAGS +=3D $(CLANG_TARGET) $(CL= ANG_GCC_TC)=0A KBUILD_AFLAGS +=3D $(CLANG_TARGET) $(CLANG_GCC_TC)=0A-KBUILD= _CPPFLAGS +=3D $(call cc-option,-Qunused-arguments,)=0A-KBUILD_CFLAGS +=3D = $(call cc-disable-warning, unused-variable)=0A-KBUILD_CFLAGS +=3D $(call cc= -disable-warning, format-invalid-specifier)=0A-KBUILD_CFLAGS +=3D $(call cc= -disable-warning, gnu)=0A-KBUILD_CFLAGS +=3D $(call cc-disable-warning, add= ress-of-packed-member)=0A-# Quiet clang warning: comparison of unsigned exp= ression < 0 is always false=0A-KBUILD_CFLAGS +=3D $(call cc-disable-warning= , tautological-compare)=0A-# CLANG uses a _MergedGlobals as optimization, b= ut this breaks modpost, as the=0A-# source of a reference will be _MergedGl= obals and not on of the whitelisted names.=0A-# See modpost pattern 2=0A-KB= UILD_CFLAGS +=3D $(call cc-option, -mno-global-merge,)=0A-KBUILD_CFLAGS += =3D $(call cc-option, -fcatch-undefined-behavior)=0A-KBUILD_CFLAGS +=3D $(c= all cc-option, -no-integrated-as)=0A-KBUILD_AFLAGS +=3D $(call cc-option, -= no-integrated-as)=0A-else=0A-=0A-# These warnings generated too much noise = in a regular build.=0A-# Use make W=3D1 to enable them (see scripts/Makefil= e.build)=0A-KBUILD_CFLAGS +=3D $(call cc-disable-warning, unused-but-set-va= riable)=0A-KBUILD_CFLAGS +=3D $(call cc-disable-warning, unused-const-varia= ble)=0A endif=0A =0A # The arch Makefile can set ARCH_{CPP,A,C}FLAGS to ove= rride the default=0A@@ -729,6 +709,29 @@ endif=0A endif=0A KBUILD_CFLAGS += =3D $(stackp-flag)=0A =0A+ifeq ($(cc-name),clang)=0A+KBUILD_CPPFLAGS +=3D $= (call cc-option,-Qunused-arguments,)=0A+KBUILD_CFLAGS +=3D $(call cc-disabl= e-warning, unused-variable)=0A+KBUILD_CFLAGS +=3D $(call cc-disable-warning= , format-invalid-specifier)=0A+KBUILD_CFLAGS +=3D $(call cc-disable-warning= , gnu)=0A+KBUILD_CFLAGS +=3D $(call cc-disable-warning, address-of-packed-m= ember)=0A+# Quiet clang warning: comparison of unsigned expression < 0 is a= lways false=0A+KBUILD_CFLAGS +=3D $(call cc-disable-warning, tautological-c= ompare)=0A+# CLANG uses a _MergedGlobals as optimization, but this breaks m= odpost, as the=0A+# source of a reference will be _MergedGlobals and not on= of the whitelisted names.=0A+# See modpost pattern 2=0A+KBUILD_CFLAGS +=3D= $(call cc-option, -mno-global-merge,)=0A+KBUILD_CFLAGS +=3D $(call cc-opti= on, -fcatch-undefined-behavior)=0A+KBUILD_CFLAGS +=3D $(call cc-option, -no= -integrated-as)=0A+KBUILD_AFLAGS +=3D $(call cc-option, -no-integrated-as)= =0A+else=0A+=0A+# These warnings generated too much noise in a regular buil= d.=0A+# Use make W=3D1 to enable them (see scripts/Makefile.extrawarn)=0A+K= BUILD_CFLAGS +=3D $(call cc-disable-warning, unused-but-set-variable)=0A+KB= UILD_CFLAGS +=3D $(call cc-disable-warning, unused-const-variable)=0A+endif= =0A+=0A ifdef CONFIG_FRAME_POINTER=0A KBUILD_CFLAGS +=3D -fno-omit-frame-po= inter -fno-optimize-sibling-calls=0A else=0A-- =0A2.20.0.rc0=0A=0A=0AFrom 0= 9855e138386082cbd89126ab9f4ac6a2bfd3f31 Mon Sep 17 00:00:00 2001=0AFrom: Da= vid Lin =0ADate: Fri, 20 Oct 2017 14:09:13 -0700=0ASubje= ct: [PATCH 18/32] kbuild: clang: fix build failures with sparse check=0A=0A= commit bb3f38c3c5b759163e09b9152629cc789731de47 upstream.=0A=0AWe should av= oid using the space character when passing arguments to=0Aclang, because st= atic code analysis check tool such as sparse may=0Amisinterpret the argumen= ts followed by spaces as build targets hence=0Acause the build to fail.=0A= =0ASigned-off-by: David Lin =0ASigned-off-by: Masahiro Y= amada =0ASigned-off-by: Nathan Chancellor =0A---=0A Makefile | 4 ++--=0A 1 file changed, 2 in= sertions(+), 2 deletions(-)=0A=0Adiff --git a/Makefile b/Makefile=0Aindex 9= f9508507a6e..c68988c63e04 100644=0A--- a/Makefile=0A+++ b/Makefile=0A@@ -61= 4,11 +614,11 @@ all: vmlinux=0A =0A ifeq ($(cc-name),clang)=0A ifneq ($(CRO= SS_COMPILE),)=0A-CLANG_TARGET :=3D -target $(notdir $(CROSS_COMPILE:%-=3D%)= )=0A+CLANG_TARGET :=3D --target=3D$(notdir $(CROSS_COMPILE:%-=3D%))=0A GCC_= TOOLCHAIN :=3D $(realpath $(dir $(shell which $(LD)))/..)=0A endif=0A ifneq= ($(GCC_TOOLCHAIN),)=0A-CLANG_GCC_TC :=3D -gcc-toolchain $(GCC_TOOLCHAIN)= =0A+CLANG_GCC_TC :=3D --gcc-toolchain=3D$(GCC_TOOLCHAIN)=0A endif=0A KBUILD= _CFLAGS +=3D $(CLANG_TARGET) $(CLANG_GCC_TC)=0A KBUILD_AFLAGS +=3D $(CLANG_= TARGET) $(CLANG_GCC_TC)=0A-- =0A2.20.0.rc0=0A=0A=0AFrom 6303b7cd6ca60d16f83= 3181833f652d51849f8ef Mon Sep 17 00:00:00 2001=0AFrom: Nick Desaulniers =0ADate: Sat, 7 Oct 2017 13:23:23 -0700=0ASubject:= [PATCH 19/32] kbuild: clang: remove crufty HOSTCFLAGS=0A=0Acommit df16aaac= 26e92e97ab7234d3f93c953466adc4b5 upstream.=0A=0AWhen compiling with `make C= C=3Dclang HOSTCC=3Dclang`, I was seeing warnings=0Athat clang did not recog= nize -fno-delete-null-pointer-checks for HOSTCC=0Atargets. These were adde= d in commit 61163efae020 ("kbuild: LLVMLinux:=0AAdd Kbuild support for buil= ding kernel with Clang").=0A=0AClang does not support -fno-delete-null-poin= ter-checks, so adding it to=0AHOSTCFLAGS if HOSTCC is clang does not make s= ense.=0A=0AIt's not clear why the other warnings were disabled, and just fo= r=0AHOSTCFLAGS, but I can remove them, add -Werror to HOSTCFLAGS and compil= e=0Awith clang just fine.=0A=0ASuggested-by: Masahiro Yamada =0ASigned-off-by: Nick Desaulniers =0ASigned-off-by: Masahiro Yamada =0A= [nc: Adjust context]=0ASigned-off-by: Nathan Chancellor =0A---=0A Makefile | 5 -----=0A 1 file changed, 5 deletions(-)=0A=0A= diff --git a/Makefile b/Makefile=0Aindex c68988c63e04..75c455fbf3f0 100644= =0A--- a/Makefile=0A+++ b/Makefile=0A@@ -306,11 +306,6 @@ HOSTCXX =3D = g++=0A HOSTCFLAGS =3D -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 = -fomit-frame-pointer -std=3Dgnu89=0A HOSTCXXFLAGS =3D -O2=0A =0A-ifeq ($(sh= ell $(HOSTCC) -v 2>&1 | grep -c "clang version"), 1)=0A-HOSTCFLAGS +=3D -W= no-unused-value -Wno-unused-parameter \=0A- -Wno-missing-field-initializer= s -fno-delete-null-pointer-checks=0A-endif=0A-=0A # Decide whether to build= built-in, modular, or both.=0A # Normally, just do built-in.=0A =0A-- =0A2= =2E20.0.rc0=0A=0A=0AFrom d5c2b0acbc1288377dcde3876e583c0632473842 Mon Sep 1= 7 00:00:00 2001=0AFrom: Sodagudi Prasad =0ADate: T= ue, 6 Feb 2018 15:46:51 -0800=0ASubject: [PATCH 20/32] kbuild: clang: disab= le unused variable warnings only=0A when constant=0A=0Acommit 0a5f41767444c= c3b4fc5573921ab914b4f78baaa upstream.=0A=0ACurrently, GCC disables -Wunused= -const-variable, but not=0A-Wunused-variable, so warns unused variables if = they are=0Anon-constant.=0A=0AWhile, Clang does not warn unused variables a= t all regardless of=0Athe const qualifier because -Wno-unused-const-variabl= e is implied=0Aby the stronger option -Wno-unused-variable.=0A=0ADisable -W= unused-const-variable instead of -Wunused-variable so that=0AGCC and Clang = work in the same way.=0A=0ASigned-off-by: Prasad Sodagudi =0ASigned-off-by: Masahiro Yamada = =0ASigned-off-by: Nathan Chancellor =0A---=0A Mak= efile | 3 +--=0A 1 file changed, 1 insertion(+), 2 deletions(-)=0A=0Adiff -= -git a/Makefile b/Makefile=0Aindex 75c455fbf3f0..665f00421f37 100644=0A--- = a/Makefile=0A+++ b/Makefile=0A@@ -706,7 +706,6 @@ KBUILD_CFLAGS +=3D $(stac= kp-flag)=0A =0A ifeq ($(cc-name),clang)=0A KBUILD_CPPFLAGS +=3D $(call cc-o= ption,-Qunused-arguments,)=0A-KBUILD_CFLAGS +=3D $(call cc-disable-warning,= unused-variable)=0A KBUILD_CFLAGS +=3D $(call cc-disable-warning, format-i= nvalid-specifier)=0A KBUILD_CFLAGS +=3D $(call cc-disable-warning, gnu)=0A = KBUILD_CFLAGS +=3D $(call cc-disable-warning, address-of-packed-member)=0A@= @ -724,9 +723,9 @@ else=0A # These warnings generated too much noise in a r= egular build.=0A # Use make W=3D1 to enable them (see scripts/Makefile.extr= awarn)=0A KBUILD_CFLAGS +=3D $(call cc-disable-warning, unused-but-set-vari= able)=0A-KBUILD_CFLAGS +=3D $(call cc-disable-warning, unused-const-variabl= e)=0A endif=0A =0A+KBUILD_CFLAGS +=3D $(call cc-disable-warning, unused-con= st-variable)=0A ifdef CONFIG_FRAME_POINTER=0A KBUILD_CFLAGS +=3D -fno-omit-= frame-pointer -fno-optimize-sibling-calls=0A else=0A-- =0A2.20.0.rc0=0A=0A= =0AFrom 2723898b6edc4b794b4a87f22c46789700cf1e35 Mon Sep 17 00:00:00 2001= =0AFrom: Stefan Agner =0ADate: Mon, 19 Mar 2018 22:12:53 += 0100=0ASubject: [PATCH 21/32] kbuild: set no-integrated-as before incl. arc= h Makefile=0A=0Acommit 0f0e8de334c54c38818a4a5390a39aa09deff5bf upstream.= =0A=0AIn order to make sure compiler flag detection for ARM works=0Acorrect= ly the no-integrated-as flags need to be set before=0Aincluding the arch sp= ecific Makefile.=0A=0AFixes: cfe17c9bbe6a ("kbuild: move cc-option and cc-d= isable-warning after incl. arch Makefile")=0ASigned-off-by: Stefan Agner =0ASigned-off-by: Masahiro Yamada =0A[nc: Adjust context]=0ASigned-off-by: Nathan Chancellor =0A---=0A Makefile | 4 ++--=0A 1 file changed, 2 insertion= s(+), 2 deletions(-)=0A=0Adiff --git a/Makefile b/Makefile=0Aindex 665f0042= 1f37..1e3648d10ec9 100644=0A--- a/Makefile=0A+++ b/Makefile=0A@@ -617,6 +61= 7,8 @@ CLANG_GCC_TC :=3D --gcc-toolchain=3D$(GCC_TOOLCHAIN)=0A endif=0A KBU= ILD_CFLAGS +=3D $(CLANG_TARGET) $(CLANG_GCC_TC)=0A KBUILD_AFLAGS +=3D $(CLA= NG_TARGET) $(CLANG_GCC_TC)=0A+KBUILD_CFLAGS +=3D $(call cc-option, -no-inte= grated-as)=0A+KBUILD_AFLAGS +=3D $(call cc-option, -no-integrated-as)=0A en= dif=0A =0A # The arch Makefile can set ARCH_{CPP,A,C}FLAGS to override the = default=0A@@ -716,8 +718,6 @@ KBUILD_CFLAGS +=3D $(call cc-disable-warning,= tautological-compare)=0A # See modpost pattern 2=0A KBUILD_CFLAGS +=3D $(c= all cc-option, -mno-global-merge,)=0A KBUILD_CFLAGS +=3D $(call cc-option, = -fcatch-undefined-behavior)=0A-KBUILD_CFLAGS +=3D $(call cc-option, -no-int= egrated-as)=0A-KBUILD_AFLAGS +=3D $(call cc-option, -no-integrated-as)=0A e= lse=0A =0A # These warnings generated too much noise in a regular build.=0A= -- =0A2.20.0.rc0=0A=0A=0AFrom 54ca7b517469feaeef25a0a36af64d91fef42a43 Mon = Sep 17 00:00:00 2001=0AFrom: Stefan Agner =0ADate: Mon, 17= Sep 2018 19:31:57 -0700=0ASubject: [PATCH 22/32] kbuild: allow to use GCC = toolchain not in Clang search=0A path=0A=0Acommit ef8c4ed9db80261f397f0c0bf= 723684601ae3b52 upstream.=0A=0AWhen using a GCC cross toolchain which is no= t in a compiled in=0AClang search path, Clang reverts to the system assembl= er and=0Alinker. This leads to assembler or linker errors, depending on=0Aw= hich tool is first used for a given architecture.=0A=0AIt seems that Clang = is not searching $PATH for a matching=0Aassembler or linker.=0A=0AMake sure= that Clang picks up the correct assembler or linker by=0Apassing the cross= compilers bin directory as search path.=0A=0AThis allows to use Clang prov= ided by distributions with GCC=0Atoolchains not in /usr/bin.=0A=0ALink: htt= ps://github.com/ClangBuiltLinux/linux/issues/78=0ASigned-off-by: Stefan Agn= er =0AReviewed-and-tested-by: Nick Desaulniers =0ASigned-off-by: Masahiro Yamada =0A[nc: Adjust context]=0ASigned-off-by: Nathan Chancellor =0A---=0A Makefile | 8 +++++---=0A 1 file changed, 5 insertio= ns(+), 3 deletions(-)=0A=0Adiff --git a/Makefile b/Makefile=0Aindex 1e3648d= 10ec9..f883862589ba 100644=0A--- a/Makefile=0A+++ b/Makefile=0A@@ -610,13 += 610,15 @@ all: vmlinux=0A ifeq ($(cc-name),clang)=0A ifneq ($(CROSS_COMPILE= ),)=0A CLANG_TARGET :=3D --target=3D$(notdir $(CROSS_COMPILE:%-=3D%))=0A-GC= C_TOOLCHAIN :=3D $(realpath $(dir $(shell which $(LD)))/..)=0A+GCC_TOOLCHAI= N_DIR :=3D $(dir $(shell which $(LD)))=0A+CLANG_PREFIX :=3D --prefix=3D$(GC= C_TOOLCHAIN_DIR)=0A+GCC_TOOLCHAIN :=3D $(realpath $(GCC_TOOLCHAIN_DIR)/..)= =0A endif=0A ifneq ($(GCC_TOOLCHAIN),)=0A CLANG_GCC_TC :=3D --gcc-toolchain= =3D$(GCC_TOOLCHAIN)=0A endif=0A-KBUILD_CFLAGS +=3D $(CLANG_TARGET) $(CLANG_= GCC_TC)=0A-KBUILD_AFLAGS +=3D $(CLANG_TARGET) $(CLANG_GCC_TC)=0A+KBUILD_CFL= AGS +=3D $(CLANG_TARGET) $(CLANG_GCC_TC) $(CLANG_PREFIX)=0A+KBUILD_AFLAGS += =3D $(CLANG_TARGET) $(CLANG_GCC_TC) $(CLANG_PREFIX)=0A KBUILD_CFLAGS +=3D $= (call cc-option, -no-integrated-as)=0A KBUILD_AFLAGS +=3D $(call cc-option,= -no-integrated-as)=0A endif=0A-- =0A2.20.0.rc0=0A=0A=0AFrom a3daa768c9b9b1= e4625444f7226e23499ebe2395 Mon Sep 17 00:00:00 2001=0AFrom: Matthias Kaehlc= ke =0ADate: Fri, 21 Apr 2017 16:00:56 -0700=0ASubject: [P= ATCH 23/32] arm64: Disable asm-operand-width warning for clang=0A=0Aclang r= aises 'asm-operand-widths' warnings in inline assembly code when=0Athe size= of an operand is < 64 bits and the operand width is unspecified.=0AMost wa= rnings are raised in macros, i.e. the datatype of the operand may=0Avary.= =0A=0ASigned-off-by: Matthias Kaehlcke =0A=0Anc: I trimme= d the original commit message since I'm not a part of CrOS=0A and can't = speak on their behalf.=0A=0A To fix these warnings, it requires a fairly= intrusive backport of=0A the sysreg conversion that Mark Rutland did in= 4.9. I think=0A disabling the warning is smarter, similar to commit d41= d0fe374d4=0A ("turn off -Wattribute-alias") in this tree.=0A=0ASigned-of= f-by: Nathan Chancellor =0A---=0A arch/arm64/Make= file | 4 ++++=0A 1 file changed, 4 insertions(+)=0A=0Adiff --git a/arch/arm= 64/Makefile b/arch/arm64/Makefile=0Aindex b6c90e5006e4..c10bb98144b0 100644= =0A--- a/arch/arm64/Makefile=0A+++ b/arch/arm64/Makefile=0A@@ -56,6 +56,10 = @@ else=0A TEXT_OFFSET :=3D 0x00080000=0A endif=0A =0A+ifeq ($(cc-name),cla= ng)=0A+KBUILD_CFLAGS +=3D $(call cc-disable-warning, asm-operand-widths)=0A= +endif=0A+=0A # KASAN_SHADOW_OFFSET =3D VA_START + (1 << (VA_BITS - 3)) - (= 1 << 61)=0A # in 32-bit arithmetic=0A KASAN_SHADOW_OFFSET :=3D $(shell prin= tf "0x%08x00000000\n" $$(( \=0A-- =0A2.20.0.rc0=0A=0A=0AFrom 1a65ed6d82fac3= 75e50497962b67eae50d9c3aef Mon Sep 17 00:00:00 2001=0AFrom: Matthias Kaehlc= ke =0ADate: Thu, 13 Apr 2017 10:26:09 -0700=0ASubject: [P= ATCH 24/32] x86/kbuild: Use cc-option to enable=0A -falign-{jumps/loops}=0A= =0Acommit 2c4fd1ac3ff167c91272dc43c7bfd2269ef61557 upstream.=0A=0Aclang cur= rently does not support these optimizations, only enable them=0Awhen they a= re available.=0A=0ASigned-off-by: Matthias Kaehlcke =0ACc= : Greg Hackmann =0ACc: Linus Torvalds =0ACc: Masahiro Yamada =0ACc= : Michael Davidson =0ACc: Peter Zijlstra =0ACc: Thomas Gleixner =0ACc: grundler@chromium.org= =0ALink: http://lkml.kernel.org/r/20170413172609.118122-1-mka@chromium.org= =0ASigned-off-by: Ingo Molnar =0ASigned-off-by: Nathan Ch= ancellor =0A---=0A arch/x86/Makefile | 4 ++--=0A = 1 file changed, 2 insertions(+), 2 deletions(-)=0A=0Adiff --git a/arch/x86/= Makefile b/arch/x86/Makefile=0Aindex d2c663aeccba..865c465f2881 100644=0A--= - a/arch/x86/Makefile=0A+++ b/arch/x86/Makefile=0A@@ -88,10 +88,10 @@ else= =0A KBUILD_CFLAGS +=3D -m64=0A =0A # Align jump targets to = 1 byte, not the default 16 bytes:=0A- KBUILD_CFLAGS +=3D -falign-jum= ps=3D1=0A+ KBUILD_CFLAGS +=3D $(call cc-option,-falign-jumps=3D1)=0A= =0A # Pack loops tightly as well:=0A- KBUILD_CFLAGS +=3D -f= align-loops=3D1=0A+ KBUILD_CFLAGS +=3D $(call cc-option,-falign-loop= s=3D1)=0A =0A # Don't autogenerate traditional x87 instructions=0A = KBUILD_CFLAGS +=3D $(call cc-option,-mno-80387)=0A-- =0A2.20.0.rc0= =0A=0A=0AFrom cad87c4b846ede38789782262726dde088f797c2 Mon Sep 17 00:00:00 = 2001=0AFrom: Michael Davidson =0ADate: Wed, 15 Mar 2017 15:3= 6:00 -0700=0ASubject: [PATCH 25/32] crypto, x86: aesni - fix token pasting = for clang=0A=0Acommit fdb2726f4e61c5e3abc052f547d5a5f6c0dc5504 upstream.=0A= =0Aaes_ctrby8_avx-x86_64.S uses the C preprocessor for token pasting=0Aof c= haracter sequences that are not valid preprocessor tokens.=0AWhile this is = allowed when preprocessing assembler files it exposes=0Aan incompatibilty b= etween the clang and gcc preprocessors where=0Aclang does not strip leading= white space from macro parameters,=0Aleading to the CONCAT(%xmm, i) macro = expansion on line 96 resulting=0Ain a token with a space character embedded= in it.=0A=0AWhile this could be resolved by deleting the offending space c= haracter,=0Athe assembler is perfectly capable of doing the token pasting c= orrectly=0Afor itself so we can just get rid of the preprocessor macros.=0A= =0ASigned-off-by: Michael Davidson =0ASigned-off-by: Herbert= Xu =0ASigned-off-by: Nathan Chancellor =0A---=0A arch/x86/crypto/aes_ctrby8_avx-x86_64.S | 7 += +-----=0A 1 file changed, 2 insertions(+), 5 deletions(-)=0A=0Adiff --git a= /arch/x86/crypto/aes_ctrby8_avx-x86_64.S b/arch/x86/crypto/aes_ctrby8_avx-x= 86_64.S=0Aindex a916c4a61165..5f6a5af9c489 100644=0A--- a/arch/x86/crypto/a= es_ctrby8_avx-x86_64.S=0A+++ b/arch/x86/crypto/aes_ctrby8_avx-x86_64.S=0A@@= -65,7 +65,6 @@=0A #include =0A #include =0A = =0A-#define CONCAT(a,b) a##b=0A #define VMOVDQ vmovdqu=0A =0A #define xdat= a0 %xmm0=0A@@ -92,8 +91,6 @@=0A #define num_bytes %r8=0A =0A #define tmp = %r10=0A-#define DDQ(i) CONCAT(ddq_add_,i)=0A-#define XMM(i) CONCAT(%xmm, = i)=0A #define DDQ_DATA 0=0A #define XDATA 1=0A #define KEY_128 1=0A@@ -13= 1,12 +128,12 @@ ddq_add_8:=0A /* generate a unique variable for ddq_add_x *= /=0A =0A .macro setddq n=0A- var_ddq_add =3D DDQ(\n)=0A+ var_ddq_add =3D dd= q_add_\n=0A .endm=0A =0A /* generate a unique variable for xmm register */= =0A .macro setxdata n=0A- var_xdata =3D XMM(\n)=0A+ var_xdata =3D %xmm\n=0A= .endm=0A =0A /* club the numeric 'id' to the symbol 'name' */=0A-- =0A2.20= =2E0.rc0=0A=0A=0AFrom 1c18c220ab121e33d5a5590fbb811d71049a5f33 Mon Sep 17 0= 0:00:00 2001=0AFrom: Matthias Kaehlcke =0ADate: Mon, 1 Ma= y 2017 15:47:41 -0700=0ASubject: [PATCH 26/32] x86/mm/kaslr: Use the _ASM_M= UL macro for multiplication=0A to work around Clang incompatibility=0A=0Aco= mmit 121843eb02a6e2fa30aefab64bfe183c97230c75 upstream.=0A=0AThe constraint= "rm" allows the compiler to put mix_const into memory.=0AWhen the input op= erand is a memory location then MUL needs an operand=0Asize suffix, since C= lang can't infer the multiplication width from the=0Aoperand.=0A=0AAdd and = use the _ASM_MUL macro which determines the operand size and=0Aresolves to = the NUL instruction with the corresponding suffix.=0A=0AThis fixes the foll= owing error when building with clang:=0A=0A CC arch/x86/lib/kaslr.o= =0A /tmp/kaslr-dfe1ad.s: Assembler messages:=0A /tmp/kaslr-dfe1ad.s:182: = Error: no instruction mnemonic suffix given and no register operands; can't= size instruction=0A=0ASigned-off-by: Matthias Kaehlcke = =0ACc: Grant Grundler =0ACc: Greg Hackmann =0ACc: Kees Cook =0ACc: Linus Torvalds = =0ACc: Michael Davidson =0ACc= : Peter Zijlstra =0ACc: Thomas Gleixner =0ALink: http://lkml.kernel.org/r/20170501224741.133938-1-mka@chromi= um.org=0ASigned-off-by: Ingo Molnar =0A[nc: Apply to aslr= =2Ec in get_random_long as the kaslr shift didn't happen=0A until 4.8 i= n commit d899a7d146a2]=0ASigned-off-by: Nathan Chancellor =0A---=0A arch/x86/boot/compressed/aslr.c | 3 ++-=0A arch/x86/incl= ude/asm/asm.h | 1 +=0A 2 files changed, 3 insertions(+), 1 deletion(-)= =0A=0Adiff --git a/arch/x86/boot/compressed/aslr.c b/arch/x86/boot/compress= ed/aslr.c=0Aindex 6a9b96b4624d..31dab2135188 100644=0A--- a/arch/x86/boot/c= ompressed/aslr.c=0A+++ b/arch/x86/boot/compressed/aslr.c=0A@@ -1,5 +1,6 @@= =0A #include "misc.h"=0A =0A+#include =0A #include = =0A #include =0A #include =0A@@ -94,7 +95,7 @= @ static unsigned long get_random_long(void)=0A }=0A =0A /* Circular mult= iply for better bit diffusion */=0A- asm("mul %3"=0A+ asm(_ASM_MUL "%3"=0A = : "=3Da" (random), "=3Dd" (raw)=0A : "a" (random), "rm" (mix_cons= t));=0A random +=3D raw;=0Adiff --git a/arch/x86/include/asm/asm.h b/arch/= x86/include/asm/asm.h=0Aindex 21e84a31d211..f3d4f1edc947 100644=0A--- a/arc= h/x86/include/asm/asm.h=0A+++ b/arch/x86/include/asm/asm.h=0A@@ -34,6 +34,7= @@=0A #define _ASM_ADD __ASM_SIZE(add)=0A #define _ASM_SUB __ASM_SIZE(sub)= =0A #define _ASM_XADD __ASM_SIZE(xadd)=0A+#define _ASM_MUL __ASM_SIZE(mul)= =0A =0A #define _ASM_AX __ASM_REG(ax)=0A #define _ASM_BX __ASM_REG(bx)=0A= -- =0A2.20.0.rc0=0A=0A=0AFrom b42e69e2547cffb28f22aaa1d113f4a75f0b4eb7 Mon = Sep 17 00:00:00 2001=0AFrom: Matthias Kaehlcke =0ADate: W= ed, 21 Jun 2017 16:28:03 -0700=0ASubject: [PATCH 27/32] kbuild: Add __cc-op= tion macro=0A=0Acommit 9f3f1fd299768782465cb32cdf0dd4528d11f26b upstream.= =0A=0Acc-option uses KBUILD_CFLAGS and KBUILD_CPPFLAGS when it determines= =0Awhether an option is supported or not. This is fine for options used to= =0Abuild the kernel itself, however some components like the x86 boot code= =0Ause a different set of flags.=0A=0AAdd the new macro __cc-option which i= s a more generic version of=0Acc-option with additional parameters. One par= ameter is the compiler=0Awith which the check should be performed, the othe= r the compiler options=0Ato be used instead KBUILD_C*FLAGS.=0A=0ARefactor c= c-option and hostcc-option to use __cc-option and move=0Ahostcc-option to s= cripts/Kbuild.include.=0A=0ASuggested-by: Arnd Bergmann =0AS= uggested-by: Masahiro Yamada =0ASigned-off-b= y: Matthias Kaehlcke =0AAcked-by: Arnd Bergmann =0AAcked-by: Michal Marek =0ASigned-off-by: Masahiro= Yamada =0A[nc: Fix conflicts due to lack of= CC_OPTION_CFLAGS and hostcc-option=0A wasn't added until v4.8 so no po= int including it in this tree]=0ASigned-off-by: Nathan Chancellor =0A---=0A Makefile | 2 +-=0A scripts/Kbuild.= include | 9 +++++++--=0A 2 files changed, 8 insertions(+), 3 deletions(-)= =0A=0Adiff --git a/Makefile b/Makefile=0Aindex f883862589ba..9cc111d3a0ba 1= 00644=0A--- a/Makefile=0A+++ b/Makefile=0A@@ -303,7 +303,7 @@ CONFIG_SHELL = :=3D $(shell if [ -x "$$BASH" ]; then echo $$BASH; \=0A =0A HOSTCC = =3D gcc=0A HOSTCXX =3D g++=0A-HOSTCFLAGS =3D -Wall -Wmissing-prototy= pes -Wstrict-prototypes -O2 -fomit-frame-pointer -std=3Dgnu89=0A+HOSTCFLAGS= :=3D -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-poi= nter -std=3Dgnu89=0A HOSTCXXFLAGS =3D -O2=0A =0A # Decide whether to build = built-in, modular, or both.=0Adiff --git a/scripts/Kbuild.include b/scripts= /Kbuild.include=0Aindex 9f634b50e57b..5e9cf7d146f0 100644=0A--- a/scripts/K= build.include=0A+++ b/scripts/Kbuild.include=0A@@ -108,11 +108,16 @@ as-opt= ion =3D $(call try-run,\=0A as-instr =3D $(call try-run,\=0A printf "%b\n"= "$(1)" | $(CC) $(KBUILD_AFLAGS) -c -x assembler -o "$$TMP" -,$(2),$(3))=0A= =0A+# __cc-option=0A+# Usage: MY_CFLAGS +=3D $(call __cc-option,$(CC),$(MY= _CFLAGS),-march=3Dwinchip-c6,-march=3Di586)=0A+__cc-option =3D $(call try-r= un,\=0A+ $(1) -Werror $(2) $(3) -c -x c /dev/null -o "$$TMP",$(3),$(4))=0A+= =0A # cc-option=0A # Usage: cflags-y +=3D $(call cc-option,-march=3Dwinchip= -c6,-march=3Di586)=0A =0A-cc-option =3D $(call try-run,\=0A- $(CC) -Werror = $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) $(1) -c -x c /dev/null -o "$$TMP",$(1),= $(2))=0A+cc-option =3D $(call __cc-option, $(CC),\=0A+ $(KBUILD_CPPFLAGS) $= (KBUILD_CFLAGS),$(1),$(2))=0A =0A # cc-option-yn=0A # Usage: flag :=3D $(ca= ll cc-option-yn,-march=3Dwinchip-c6)=0A-- =0A2.20.0.rc0=0A=0A=0AFrom 35093a= c320af90bc28f093c9a942703710adf421 Mon Sep 17 00:00:00 2001=0AFrom: Matthia= s Kaehlcke =0ADate: Wed, 21 Jun 2017 16:28:04 -0700=0ASub= ject: [PATCH 28/32] x86/build: Use __cc-option for boot code compiler=0A op= tions=0A=0Acommit 032a2c4f65a2f81c93e161a11197ba19bc14a909 upstream.=0A=0Ac= c-option is used to enable compiler options for the boot code if they=0Aare= available. The macro uses KBUILD_CFLAGS and KBUILD_CPPFLAGS for the=0Achec= k, however these flags aren't used to build the boot code, in=0Aconsequence= cc-option can yield wrong results. For example=0A-mpreferred-stack-boundar= y=3D2 is never set with a 64-bit compiler,=0Asince the setting is only vali= d for 16 and 32-bit binaries. This=0Ais also the case for 32-bit kernel bui= lds, because the option -m32 is=0Aadded to KBUILD_CFLAGS after the assignme= nt of REALMODE_CFLAGS.=0A=0AUse __cc-option instead of cc-option for the bo= ot mode options.=0AThe macro receives the compiler options as parameter ins= tead of using=0AKBUILD_C*FLAGS, for the boot code we pass REALMODE_CFLAGS.= =0A=0AAlso use separate statements for the __cc-option checks instead=0Aof = performing them in the initial assignment of REALMODE_CFLAGS since=0Athe va= riable is an input of the macro.=0A=0ASigned-off-by: Matthias Kaehlcke =0AAcked-by: Ingo Molnar =0ASigned-off-by: = Masahiro Yamada =0ASigned-off-by: Nathan Cha= ncellor =0A---=0A arch/x86/Makefile | 9 +++++----= =0A 1 file changed, 5 insertions(+), 4 deletions(-)=0A=0Adiff --git a/arch/= x86/Makefile b/arch/x86/Makefile=0Aindex 865c465f2881..be909f26563e 100644= =0A--- a/arch/x86/Makefile=0A+++ b/arch/x86/Makefile=0A@@ -24,10 +24,11 @@ = REALMODE_CFLAGS :=3D $(M16_CFLAGS) -g -Os -D__KERNEL__ \=0A -DDISABLE_= BRANCH_PROFILING \=0A -Wall -Wstrict-prototypes -march=3Di386 -mregpar= m=3D3 \=0A -fno-strict-aliasing -fomit-frame-pointer -fno-pic \=0A- = -mno-mmx -mno-sse \=0A- $(call cc-option, -ffreestanding) \=0A- $= (call cc-option, -fno-stack-protector) \=0A- $(call cc-option, -mprefer= red-stack-boundary=3D2)=0A+ -mno-mmx -mno-sse=0A+=0A+REALMODE_CFLAGS += =3D $(call __cc-option, $(CC), $(REALMODE_CFLAGS), -ffreestanding)=0A+REALM= ODE_CFLAGS +=3D $(call __cc-option, $(CC), $(REALMODE_CFLAGS), -fno-stack-p= rotector)=0A+REALMODE_CFLAGS +=3D $(call __cc-option, $(CC), $(REALMODE_CFL= AGS), -mpreferred-stack-boundary=3D2)=0A export REALMODE_CFLAGS=0A =0A # BI= TS is used as extension for files which are available in a 32 bit=0A-- =0A2= =2E20.0.rc0=0A=0A=0AFrom ef6965f65f04908ee4a4d9f4455e98c2dd23d3c2 Mon Sep 1= 7 00:00:00 2001=0AFrom: Matthias Kaehlcke =0ADate: Wed, 2= 1 Jun 2017 16:28:05 -0700=0ASubject: [PATCH 29/32] x86/build: Specify stack= alignment for clang=0A=0Acommit d77698df39a512911586834d303275ea5fda74d0 u= pstream.=0A=0AFor gcc stack alignment is configured with -mpreferred-stack-= boundary=3DN,=0Aclang has the option -mstack-alignment=3DN for that purpose= =2E Use the same=0Aalignment as with gcc.=0A=0AIf the alignment is not spec= ified clang assumes an alignment of=0A16 bytes, as required by the standard= ABI. However as mentioned in=0Ad9b0cde91c60 ("x86-64, gcc: Use -mpreferred= -stack-boundary=3D3 if=0Asupported") the standard kernel entry on x86-64 le= aves the stack=0Aon an 8-byte boundary, as a consequence clang will keep th= e stack=0Amisaligned.=0A=0ASigned-off-by: Matthias Kaehlcke =0AAcked-by: Ingo Molnar =0ASigned-off-by: Masahiro Ya= mada =0ASigned-off-by: Nathan Chancellor =0A---=0A arch/x86/Makefile | 26 +++++++++++++++++++= ++-----=0A 1 file changed, 21 insertions(+), 5 deletions(-)=0A=0Adiff --git= a/arch/x86/Makefile b/arch/x86/Makefile=0Aindex be909f26563e..914b1e87d1a6= 100644=0A--- a/arch/x86/Makefile=0A+++ b/arch/x86/Makefile=0A@@ -11,6 +11,= 14 @@ else=0A KBUILD_DEFCONFIG :=3D $(ARCH)_defconfig=0A endif=0A = =0A+# For gcc stack alignment is specified with -mpreferred-stack-boundary,= =0A+# clang has the option -mstack-alignment for that purpose.=0A+ifneq ($(= call cc-option, -mpreferred-stack-boundary=3D4),)=0A+ cc_stack_align= _opt :=3D -mpreferred-stack-boundary=0A+else ifneq ($(call cc-option, -msta= ck-alignment=3D4),)=0A+ cc_stack_align_opt :=3D -mstack-alignment=0A= +endif=0A+=0A # How to compile the 16-bit code. Note we always compile for= -march=3Di386;=0A # that way we can complain to the user if the CPU is ins= ufficient.=0A #=0A@@ -28,7 +36,7 @@ REALMODE_CFLAGS :=3D $(M16_CFLAGS) -g -= Os -D__KERNEL__ \=0A =0A REALMODE_CFLAGS +=3D $(call __cc-option, $(CC), $(= REALMODE_CFLAGS), -ffreestanding)=0A REALMODE_CFLAGS +=3D $(call __cc-optio= n, $(CC), $(REALMODE_CFLAGS), -fno-stack-protector)=0A-REALMODE_CFLAGS +=3D= $(call __cc-option, $(CC), $(REALMODE_CFLAGS), -mpreferred-stack-boundary= =3D2)=0A+REALMODE_CFLAGS +=3D $(call __cc-option, $(CC), $(REALMODE_CFLAGS)= , $(cc_stack_align_opt)=3D2)=0A export REALMODE_CFLAGS=0A =0A # BITS is use= d as extension for files which are available in a 32 bit=0A@@ -65,8 +73,10 = @@ ifeq ($(CONFIG_X86_32),y)=0A # with nonstandard options=0A = KBUILD_CFLAGS +=3D -fno-pic=0A =0A- # prevent gcc from keeping th= e stack 16 byte aligned=0A- KBUILD_CFLAGS +=3D $(call cc-option,-mpr= eferred-stack-boundary=3D2)=0A+ # Align the stack to the register wi= dth instead of using the default=0A+ # alignment of 16 bytes. This r= educes stack usage and the number of=0A+ # alignment instructions.= =0A+ KBUILD_CFLAGS +=3D $(call cc-option,$(cc_stack_align_opt)=3D2)= =0A =0A # Disable unit-at-a-time mode on pre-gcc-4.0 compilers, it = makes gcc use=0A # a lot more stack due to the lack of sharing of s= tacklots:=0A@@ -98,8 +108,14 @@ else=0A KBUILD_CFLAGS +=3D $(call c= c-option,-mno-80387)=0A KBUILD_CFLAGS +=3D $(call cc-option,-mno-fp= -ret-in-387)=0A =0A- # Use -mpreferred-stack-boundary=3D3 if supported.=0A-= KBUILD_CFLAGS +=3D $(call cc-option,-mpreferred-stack-boundary=3D3)=0A+ = # By default gcc and clang use a stack alignment of 16 bytes for x86.= =0A+ # However the standard kernel entry on x86-64 leaves the stack = on an=0A+ # 8-byte boundary. If the compiler isn't informed about th= e actual=0A+ # alignment it will generate extra alignment instructio= ns for the=0A+ # default alignment which keep the stack *mis*aligned= =2E=0A+ # Furthermore an alignment to the register width reduces sta= ck usage=0A+ # and the number of alignment instructions.=0A+ = KBUILD_CFLAGS +=3D $(call cc-option,$(cc_stack_align_opt)=3D3)=0A =0A # Us= e -mskip-rax-setup if supported.=0A KBUILD_CFLAGS +=3D $(call cc-option,-m= skip-rax-setup)=0A-- =0A2.20.0.rc0=0A=0A=0AFrom 64bf8cda4b1ba9faa0a660cd458= 18f03d3e5c70a Mon Sep 17 00:00:00 2001=0AFrom: Michael Davidson =0ADate: Mon, 24 Jul 2017 16:51:55 -0700=0ASubject: [PATCH 30/32] x86/b= oot: #undef memcpy() et al in string.c=0A=0Acommit 18d5e6c34a8eda438d5ad8b3= b15f42dab01bf05d upstream.=0A=0Aundef memcpy() and friends in boot/string.c= so that the functions=0Adefined here will have the correct names, otherwis= e we end up=0Aup trying to redefine __builtin_memcpy() etc.=0A=0ASurprising= ly, GCC allows this (and, helpfully, discards the=0A__builtin_ prefix from = the function name when compiling it),=0Abut clang does not.=0A=0AAdding the= se #undef's appears to preserve what I assume was=0Athe original intent of = the code.=0A=0ASigned-off-by: Michael Davidson =0ASigned-off= -by: Matthias Kaehlcke =0AAcked-by: H. Peter Anvin =0ACc: Arnd Bergmann =0ACc: Bernhard.Rosenkranzer@l= inaro.org=0ACc: Greg Hackmann =0ACc: Kees Cook =0ACc: Linus Torvalds =0ACc= : Nick Desaulniers =0ACc: Peter Zijlstra =0ACc: Thomas Gleixner =0ALink: http://lkm= l.kernel.org/r/20170724235155.79255-1-mka@chromium.org=0ASigned-off-by: Ing= o Molnar =0ASigned-off-by: Nathan Chancellor =0A---=0A arch/x86/boot/string.c | 9 +++++++++=0A 1 file chan= ged, 9 insertions(+)=0A=0Adiff --git a/arch/x86/boot/string.c b/arch/x86/bo= ot/string.c=0Aindex 06ceddb3a22e..1d56adea8a7c 100644=0A--- a/arch/x86/boot= /string.c=0A+++ b/arch/x86/boot/string.c=0A@@ -16,6 +16,15 @@=0A #include "= ctype.h"=0A #include "string.h"=0A =0A+/*=0A+ * Undef these macros so that = the functions that we provide=0A+ * here will have the correct names regard= less of how string.h=0A+ * may have chosen to #define them.=0A+ */=0A+#unde= f memcpy=0A+#undef memset=0A+#undef memcmp=0A+=0A int memcmp(const void *s1= , const void *s2, size_t len)=0A {=0A u8 diff;=0A-- =0A2.20.0.rc0=0A=0A=0A= =46rom 191026bf5f61d06411c25c7ca8dc4a33821f30b8 Mon Sep 17 00:00:00 2001=0A= =46rom: Matthias Kaehlcke =0ADate: Wed, 16 Aug 2017 17:47= :40 -0700=0ASubject: [PATCH 31/32] x86/build: Fix stack alignment for CLang= =0A=0Acommit 8f91869766c00622b2eaa8ee567db4f333b78c1a upstream.=0A=0ACommit= :=0A=0A d77698df39a5 ("x86/build: Specify stack alignment for clang")=0A= =0Aintended to use the same stack alignment for clang as with gcc.=0A=0AThe= two compilers use different options to configure the stack alignment=0A(gc= c: -mpreferred-stack-boundary=3Dn, clang: -mstack-alignment=3Dn).=0A=0AThe = above commit assumes that the clang option uses the same parameter=0Atype a= s gcc, i.e. that the alignment is specified as 2^n. However clang=0Ainterpr= ets the value of this option literally to use an alignment of n,=0Ain conse= quence the stack remains misaligned.=0A=0AChange the values used with -msta= ck-alignment to be the actual alignment=0Ainstead of a power of two.=0A=0Ac= c-option isn't used here with the typical pattern of KBUILD_CFLAGS +=3D=0A$= (call cc-option ...). The reason is that older gcc versions don't=0Asupport= the -mpreferred-stack-boundary option, since cc-option doesn't=0Averify wh= ether the alternative option is valid it would incorrectly=0Aselect the cla= ng option -mstack-alignment..=0A=0ASigned-off-by: Matthias Kaehlcke =0ACc: Arnd Bergmann =0ACc: Bernhard.Rosenkranzer= @linaro.org=0ACc: Greg Hackmann =0ACc: Kees Cook =0ACc: Linus Torvalds =0A= Cc: Masahiro Yamada =0ACc: Michael Davidson = =0ACc: Nick Desaulniers =0ACc: Pete= r Zijlstra =0ACc: Stephen Hines = =0ACc: Thomas Gleixner =0ACc: dianders@chromium.org=0AL= ink: http://lkml.kernel.org/r/20170817004740.170588-1-mka@chromium.org=0ASi= gned-off-by: Ingo Molnar =0ASigned-off-by: Nathan Chancel= lor =0A---=0A arch/x86/Makefile | 14 ++++++++----= --=0A 1 file changed, 8 insertions(+), 6 deletions(-)=0A=0Adiff --git a/arc= h/x86/Makefile b/arch/x86/Makefile=0Aindex 914b1e87d1a6..6c698e49dff5 10064= 4=0A--- a/arch/x86/Makefile=0A+++ b/arch/x86/Makefile=0A@@ -14,9 +14,11 @@ = endif=0A # For gcc stack alignment is specified with -mpreferred-stack-boun= dary,=0A # clang has the option -mstack-alignment for that purpose.=0A ifne= q ($(call cc-option, -mpreferred-stack-boundary=3D4),)=0A- cc_stack_= align_opt :=3D -mpreferred-stack-boundary=0A-else ifneq ($(call cc-option, = -mstack-alignment=3D4),)=0A- cc_stack_align_opt :=3D -mstack-alignme= nt=0A+ cc_stack_align4 :=3D -mpreferred-stack-boundary=3D2=0A+ cc= _stack_align8 :=3D -mpreferred-stack-boundary=3D3=0A+else ifneq ($(call cc-= option, -mstack-alignment=3D16),)=0A+ cc_stack_align4 :=3D -mstack-ali= gnment=3D4=0A+ cc_stack_align8 :=3D -mstack-alignment=3D8=0A endif=0A = =0A # How to compile the 16-bit code. Note we always compile for -march=3D= i386;=0A@@ -36,7 +38,7 @@ REALMODE_CFLAGS :=3D $(M16_CFLAGS) -g -Os -D__KER= NEL__ \=0A =0A REALMODE_CFLAGS +=3D $(call __cc-option, $(CC), $(REALMODE_C= FLAGS), -ffreestanding)=0A REALMODE_CFLAGS +=3D $(call __cc-option, $(CC), = $(REALMODE_CFLAGS), -fno-stack-protector)=0A-REALMODE_CFLAGS +=3D $(call __= cc-option, $(CC), $(REALMODE_CFLAGS), $(cc_stack_align_opt)=3D2)=0A+REALMOD= E_CFLAGS +=3D $(cc_stack_align4)=0A export REALMODE_CFLAGS=0A =0A # BITS is= used as extension for files which are available in a 32 bit=0A@@ -76,7 +78= ,7 @@ ifeq ($(CONFIG_X86_32),y)=0A # Align the stack to the registe= r width instead of using the default=0A # alignment of 16 bytes. Th= is reduces stack usage and the number of=0A # alignment instruction= s.=0A- KBUILD_CFLAGS +=3D $(call cc-option,$(cc_stack_align_opt)=3D2= )=0A+ KBUILD_CFLAGS +=3D $(cc_stack_align4)=0A =0A # Disable= unit-at-a-time mode on pre-gcc-4.0 compilers, it makes gcc use=0A = # a lot more stack due to the lack of sharing of stacklots:=0A@@ -115,7 +11= 7,7 @@ else=0A # default alignment which keep the stack *mis*aligne= d.=0A # Furthermore an alignment to the register width reduces stac= k usage=0A # and the number of alignment instructions.=0A- K= BUILD_CFLAGS +=3D $(call cc-option,$(cc_stack_align_opt)=3D3)=0A+ KB= UILD_CFLAGS +=3D $(cc_stack_align8)=0A =0A # Use -mskip-rax-setup if suppo= rted.=0A KBUILD_CFLAGS +=3D $(call cc-option,-mskip-rax-setup)=0A-- =0A2.2= 0.0.rc0=0A=0A=0AFrom 17d7ff66abe0946d8b25061d984ccdff92a3a092 Mon Sep 17 00= :00:00 2001=0AFrom: Matthias Kaehlcke =0ADate: Thu, 17 Au= g 2017 11:20:47 -0700=0ASubject: [PATCH 32/32] x86/build: Use cc-option to = validate stack alignment=0A parameter=0A=0Acommit 9e8730b178a2472fca3123e90= 9d6e69cc8127778 upstream.=0A=0AWith the following commit:=0A=0A 8f91869766= c0 ("x86/build: Fix stack alignment for CLang")=0A=0Acc-option is only used= to determine the name of the stack alignment option=0Asupported by the com= piler, but not to verify that the actual parameter=0A