From patchwork Mon Oct 17 03:57:09 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 9378431 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 5458B60487 for ; Mon, 17 Oct 2016 03:57:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3D6FF28933 for ; Mon, 17 Oct 2016 03:57:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2F3ED28C46; Mon, 17 Oct 2016 03:57:24 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6A96028933 for ; Mon, 17 Oct 2016 03:57:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755445AbcJQD5V (ORCPT ); Sun, 16 Oct 2016 23:57:21 -0400 Received: from mail-pf0-f195.google.com ([209.85.192.195]:34936 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754005AbcJQD5U (ORCPT ); Sun, 16 Oct 2016 23:57:20 -0400 Received: by mail-pf0-f195.google.com with SMTP id s8so11854440pfj.2; Sun, 16 Oct 2016 20:57:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:subject:message-id:in-reply-to:references :organization:mime-version:content-transfer-encoding; bh=Rs/VptywXZAS+lhIvMbBMPVfa6mD7be+Va4f+nrVR08=; b=mj3j6YGMvdeNtuP8N68Y/+o7/s7otyV+zvS6Ed+eQoqYOsL/mpt1WIJjksnaQZXRjW 9LZU+hM0a0cEncN/NNfJ7epCDZ8wXhbQlaCsGdny3luo841P5N2QJ5v3Dc3L+4HtQuWo DAQmQni6uW+2OhD3XBT+NCwXEYXRZXctb6X+YejA7Syq6Ozu/o9sf1gJswxlGKr2cnFZ S5b9F6+hVWZP4wFx0h/j81U8FM/0nd21ppQbHxEdhrIo37FdGzpbqVWkCHz6HcoU2UD3 3cHrwArXQq9FHNLvRKdkqcd7ozQqz5QV2qdOfjHDylF/zFkKv6ly41Kdu18rGqaGyTTJ tCZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:organization:mime-version:content-transfer-encoding; bh=Rs/VptywXZAS+lhIvMbBMPVfa6mD7be+Va4f+nrVR08=; b=Y1CQYc22OBBGlCMfTSTkqqZy3uk7cc7qUlM8wOkMsyxcq+P1XqldyULdfvGtKkfqxh L8E5Zx5VnvP6ZQDUfu+9xCnt7Sph+YSLIp0Br+upKz0xXNPtCLpxFnRrGLeSX7uIB9l4 vWh8YfsUAFzrP9ni1kjrInvDlA9FeocvGqhOFH8RzR/s4JxFlZXUymriPHtc1yMGFyZK bZJfTrZqjfwQ2UUt/2Jg6aTaDDrbMRDAWgqcpcmplndG8mOnayVQ1KK5q5Z/eUTNWi3B KsYYPy4TwP1ro7c/ZsDuVgT0EkPsvi2g6G4jV0PdnWsKvLlOVgoC3zpl7Y+SEnaedaN7 QGsw== X-Gm-Message-State: AA6/9Rl2A9rA26UMp1RHDbdTrRlXPCP9546xhO7//Lxka/goMsLqSKE9Yq9UfcZf1ty+fg== X-Received: by 10.98.13.20 with SMTP id v20mr30342022pfi.80.1476676639498; Sun, 16 Oct 2016 20:57:19 -0700 (PDT) Received: from roar.ozlabs.ibm.com ([122.99.82.10]) by smtp.gmail.com with ESMTPSA id w70sm43462292pfa.89.2016.10.16.20.57.15 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 16 Oct 2016 20:57:18 -0700 (PDT) Date: Mon, 17 Oct 2016 14:57:09 +1100 From: Nicholas Piggin To: Omar Sandoval Cc: Michal Marek , Linus Torvalds , adobriyan@gmail.com, sfr@canb.auug.org.au, viro@zeniv.linux.org.uk, linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [GIT PULL] kbuild changes for v4.9-rc1 Message-ID: <20161017145709.2882f33f@roar.ozlabs.ibm.com> In-Reply-To: <20161016002205.GA9686@vader> References: <20161014201246.GA28782@sepie.suse.cz> <20161016002205.GA9686@vader> Organization: IBM X-Mailer: Claws Mail 3.14.0 (GTK+ 2.24.31; x86_64-pc-linux-gnu) MIME-Version: 1.0 Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Sat, 15 Oct 2016 17:22:05 -0700 Omar Sandoval wrote: > On Fri, Oct 14, 2016 at 10:12:46PM +0200, Michal Marek wrote: > > Hi Linus, > > > > please pull these kbuild changes for v4.9-rc1: > > > > - EXPORT_SYMBOL for asm source by Al Viro. This does bring a regression, > > because genksyms no longer generates checksums for these symbols > > (CONFIG_MODVERSIONS). Nick Piggin is working on a patch to fix this. > > Plus, we are talking about functions like strcpy(), which rarely > > change prototypes. > > So this has broken all module loading for me. I get the following dmesg > spew: > > ... > [ 4.586914] scsi_mod: no symbol version for memset > [ 4.587920] scsi_mod: Unknown symbol memset (err -22) > [ 4.588443] scsi_mod: no symbol version for ___preempt_schedule > [ 4.589026] scsi_mod: Unknown symbol ___preempt_schedule (err -22) > ... > > Reverting 784d5699eddc ("x86: move exports to actual definitions") fixes > it for me. This is with GCC 6.2.1, binutils 2.27, attached config. > Thanks for the report. Could you try this patch and see if it helps? Allow architectures to create asm/asm-prototypes.h file that provides C prototypes for exported asm functions, which enables proper CRC versions to be generated for them. It's done by creating a trivial C program that includes that file and the EXPORT_SYMBOL()s from the .S file, and preprocesses that then sends the result to genksyms. Signed-off-by: Nicholas Piggin --- scripts/Makefile.build | 71 +++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 65 insertions(+), 6 deletions(-) diff --git a/scripts/Makefile.build b/scripts/Makefile.build index de46ab0..edcf876 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -159,7 +159,8 @@ cmd_cpp_i_c = $(CPP) $(c_flags) -o $@ $< $(obj)/%.i: $(src)/%.c FORCE $(call if_changed_dep,cpp_i_c) -cmd_gensymtypes = \ +# These mirror gensymtypes_S and co below, keep them in synch. +cmd_gensymtypes_c = \ $(CPP) -D__GENKSYMS__ $(c_flags) $< | \ $(GENKSYMS) $(if $(1), -T $(2)) \ $(patsubst y,-s _,$(CONFIG_HAVE_UNDERSCORE_SYMBOL_PREFIX)) \ @@ -169,7 +170,7 @@ cmd_gensymtypes = \ quiet_cmd_cc_symtypes_c = SYM $(quiet_modtag) $@ cmd_cc_symtypes_c = \ set -e; \ - $(call cmd_gensymtypes,true,$@) >/dev/null; \ + $(call cmd_gensymtypes_c,true,$@) >/dev/null; \ test -s $@ || rm -f $@ $(obj)/%.symtypes : $(src)/%.c FORCE @@ -198,9 +199,10 @@ else # the actual value of the checksum generated by genksyms cmd_cc_o_c = $(CC) $(c_flags) -c -o $(@D)/.tmp_$(@F) $< -cmd_modversions = \ + +cmd_modversions_c = \ if $(OBJDUMP) -h $(@D)/.tmp_$(@F) | grep -q __ksymtab; then \ - $(call cmd_gensymtypes,$(KBUILD_SYMTYPES),$(@:.o=.symtypes)) \ + $(call cmd_gensymtypes_c,$(KBUILD_SYMTYPES),$(@:.o=.symtypes)) \ > $(@D)/.tmp_$(@F:.o=.ver); \ \ $(LD) $(LDFLAGS) -r -o $@ $(@D)/.tmp_$(@F) \ @@ -268,13 +270,14 @@ endif # CONFIG_STACK_VALIDATION define rule_cc_o_c $(call echo-cmd,checksrc) $(cmd_checksrc) \ $(call cmd_and_fixdep,cc_o_c) \ - $(cmd_modversions) \ + $(cmd_modversions_c) \ $(cmd_objtool) \ $(call echo-cmd,record_mcount) $(cmd_record_mcount) endef define rule_as_o_S $(call cmd_and_fixdep,as_o_S) \ + $(cmd_modversions_S) \ $(cmd_objtool) endef @@ -314,6 +317,32 @@ modkern_aflags := $(KBUILD_AFLAGS_KERNEL) $(AFLAGS_KERNEL) $(real-objs-m) : modkern_aflags := $(KBUILD_AFLAGS_MODULE) $(AFLAGS_MODULE) $(real-objs-m:.o=.s): modkern_aflags := $(KBUILD_AFLAGS_MODULE) $(AFLAGS_MODULE) +# .S file exports must have their C prototypes defined in asm/asm-prototypes.h +# or a file that it includes, in order to get versioned symbols. We build a +# dummy C file that includes asm-prototypes and the EXPORT_SYMBOL lines from +# the .S file (with trailing ';'), and run genksyms on that, to extract vers. +# +# These mirror gensymtypes_c and co above, keep them in synch. +cmd_gensymtypes_S = \ + (echo "\#include " ; \ + echo "\#include " ; \ + grep EXPORT_SYMBOL $< | sed 's/$$/;/' ) | \ + $(CPP) -D__GENKSYMS__ $(c_flags) -xc - | \ + $(GENKSYMS) $(if $(1), -T $(2)) \ + $(patsubst y,-s _,$(CONFIG_HAVE_UNDERSCORE_SYMBOL_PREFIX)) \ + $(if $(KBUILD_PRESERVE),-p) \ + -r $(firstword $(wildcard $(2:.symtypes=.symref) /dev/null)) + +quiet_cmd_cc_symtypes_S = SYM $(quiet_modtag) $@ +cmd_cc_symtypes_S = \ + set -e; \ + $(call cmd_gensymtypes_S,true,$@) >/dev/null; \ + test -s $@ || rm -f $@ + +$(obj)/%.symtypes : $(src)/%.S FORCE + $(call cmd,cc_symtypes_S) + + quiet_cmd_cpp_s_S = CPP $(quiet_modtag) $@ cmd_cpp_s_S = $(CPP) $(a_flags) -o $@ $< @@ -321,7 +350,37 @@ $(obj)/%.s: $(src)/%.S FORCE $(call if_changed_dep,cpp_s_S) quiet_cmd_as_o_S = AS $(quiet_modtag) $@ -cmd_as_o_S = $(CC) $(a_flags) -c -o $@ $< + +ifndef CONFIG_MODVERSIONS +cmd_as_o_S = $(CC) $(a_flags) -c -o $@ $< + +else + +ASM_PROTOTYPES := $(wildcard $(srctree)/arch/$(SRCARCH)/include/asm/asm-prototypes.h) + +ifeq ($(ASM_PROTOTYPES),) +cmd_as_o_S = $(CC) $(a_flags) -c -o $@ $< + +else + +# versioning matches the C process described above, with difference that +# we parse asm-prototypes.h C header to get function definitions. + +cmd_as_o_S = $(CC) $(a_flags) -c -o $(@D)/.tmp_$(@F) $< + +cmd_modversions_S = \ + if $(OBJDUMP) -h $(@D)/.tmp_$(@F) | grep -q __ksymtab; then \ + $(call cmd_gensymtypes_S,$(KBUILD_SYMTYPES),$(@:.o=.symtypes)) \ + > $(@D)/.tmp_$(@F:.o=.ver); \ + \ + $(LD) $(LDFLAGS) -r -o $@ $(@D)/.tmp_$(@F) \ + -T $(@D)/.tmp_$(@F:.o=.ver); \ + rm -f $(@D)/.tmp_$(@F) $(@D)/.tmp_$(@F:.o=.ver); \ + else \ + mv -f $(@D)/.tmp_$(@F) $@; \ + fi; +endif +endif $(obj)/%.o: $(src)/%.S $(objtool_obj) FORCE $(call if_changed_rule,as_o_S)