From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FSL_HELO_FAKE, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 80CE9C433E2 for ; Tue, 8 Sep 2020 21:18:09 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1CF1C20768 for ; Tue, 8 Sep 2020 21:18:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="A1OuiHH4"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=google.com header.i=@google.com header.b="sITCjv2G" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1CF1C20768 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References:Message-ID: Subject:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=VSfdyttBdREY/dkz2NPBzcpNB46UEkZeq4FGnDIHnBo=; b=A1OuiHH424HgvvlavBzg4oHRM 4+0/mrdN3ccHceRIWIK1yQbyuuFO55IITLNoe3a6WMX22h9yUOltkToJnKQ6/nyfjK7tHtKxLOgKW kDcmC8SRM54jE4hwoPbs2kstmRZDbdUr3pcuBxsvhtCeATuf+C0B0lkieyj7pB3GHBDQbXL/5nwSG oh/0t2TmreqnuhIsLYbE6fSUvDydNNWioDLw74OlQlPx307uf/Dc2D3t9Qq40i7HyYgX7hvuLUJDs 8fHLDZIdtC1GbTIEq+3xw6hpvdEongohErApywKNActyk5juc8Uy++n7BFEUKUQnSXJkmPk31Z75T xUWd50cFg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kFkyy-0007yA-FL; Tue, 08 Sep 2020 21:16:52 +0000 Received: from mail-pj1-x1042.google.com ([2607:f8b0:4864:20::1042]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kFkyu-0007wq-Fu for linux-arm-kernel@lists.infradead.org; Tue, 08 Sep 2020 21:16:50 +0000 Received: by mail-pj1-x1042.google.com with SMTP id s2so235297pjr.4 for ; Tue, 08 Sep 2020 14:16:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=2efFs7I/aVceVr/UA1FiVN+0BylwZxjeaszZFFD+TI8=; b=sITCjv2Gw9n5L/AbRCZ60B2tM96FOIAmZJP0xe2pWojsuA5XzhXqrZIsezZXCVNKFJ oTkLfrCwO3b29MBCWYBtrLpvexnpWu8O5O9PQPbfZcg2StDIQ5hvVUVYZF2KMkZQM3jA Y0n9t1cvTsIau5HLXC3w1BW386YBX5etGcBDupIed7NhVvmW3Sze/9BeRrY+3eebmC54 A3rg+0Q2or5ANiemPjDYOHk9RJ87YkzEsypOP9ODMDA2xV0LR5EzXHAisx/02MWDtifr c59B02GuTqOPM7NTMhmOA+z/kS+V8qF7KI7GgYITYiOU1zTcJV35HGMVQ8GGwXhyPLWc L4uQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=2efFs7I/aVceVr/UA1FiVN+0BylwZxjeaszZFFD+TI8=; b=n9ido/134FlPklVEWYI+LGUqtZaNd/6MEk7Ia6hYZCepphl2gKlL2qEm7IujJK7Lub SQ8yvUtPGMd2gr2gTukrzEfbEGJMrOxJ/N0+/SSyxIaZsohVLxySSZOZ6EWoZHLUX9ZI Pfk/pyMz0M/kmXJzxTqbbP3nU6gVpQxuyVHs1qmK3z/Dkum/WLmLNuoYmpf2q5n9N4Rs AB0Qabs9Pl+qmuehXgy8jT5z98fOFE9Uweux+X9pW80+tajM6JRtnZ54fdtPFeRBbu77 tkvzRrfx8wJf9oz6xzKpp7V0S4pwPMmuPoCTPApPfRNIMXudMhdLsMFJqbJoVBAPPFAU 689A== X-Gm-Message-State: AOAM530zpl3fobcfKjBspN7bZ5571w76CvuRW732q8NWNqNxxlOA9T0v AGI6ftUCB396ckmQA5jzVFoqqQ== X-Google-Smtp-Source: ABdhPJyWG8mI3H/BsY+oT/o/ksZJ0zCieLkhk5hIgmn2bkbuRWqCNofmO6IoZa9/Ax5C5W1FdW8cWQ== X-Received: by 2002:a17:90a:f486:: with SMTP id bx6mr641742pjb.130.1599599806032; Tue, 08 Sep 2020 14:16:46 -0700 (PDT) Received: from google.com ([2620:15c:201:2:f693:9fff:fef4:1b6d]) by smtp.gmail.com with ESMTPSA id 137sm315259pfu.149.2020.09.08.14.16.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Sep 2020 14:16:45 -0700 (PDT) Date: Tue, 8 Sep 2020 14:16:38 -0700 From: Sami Tolvanen To: Kees Cook Subject: Re: [PATCH v2 15/28] init: lto: ensure initcall ordering Message-ID: <20200908211638.GC1060586@google.com> References: <20200624203200.78870-1-samitolvanen@google.com> <20200903203053.3411268-1-samitolvanen@google.com> <20200903203053.3411268-16-samitolvanen@google.com> <202009031532.CD2A5F372D@keescook> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <202009031532.CD2A5F372D@keescook> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200908_171649_282773_34F3B171 X-CRM114-Status: GOOD ( 31.81 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arch@vger.kernel.org, x86@kernel.org, "Paul E. McKenney" , kernel-hardening@lists.openwall.com, Peter Zijlstra , Greg Kroah-Hartman , Masahiro Yamada , linux-kbuild@vger.kernel.org, Nick Desaulniers , linux-kernel@vger.kernel.org, Steven Rostedt , clang-built-linux@googlegroups.com, linux-pci@vger.kernel.org, Will Deacon , linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Thu, Sep 03, 2020 at 03:40:31PM -0700, Kees Cook wrote: > On Thu, Sep 03, 2020 at 01:30:40PM -0700, Sami Tolvanen wrote: > > With LTO, the compiler doesn't necessarily obey the link order for > > initcalls, and initcall variables need globally unique names to avoid > > collisions at link time. > > > > This change exports __KBUILD_MODNAME and adds the initcall_id() macro, > > which uses it together with __COUNTER__ and __LINE__ to help ensure > > these variables have unique names, and moves each variable to its own > > section when LTO is enabled, so the correct order can be specified using > > a linker script. > > > > The generate_initcall_ordering.pl script uses nm to find initcalls from > > the object files passed to the linker, and generates a linker script > > that specifies the intended order. With LTO, the script is called in > > link-vmlinux.sh. > > I think I asked before about this being made unconditional, but the hit > on final link time was noticeable. Am I remembering that right? If so, > sure, let's keep it separate. Yes, it was noticeable when compiling on systems with fewer CPU cores, so I would prefer to keep it separate. > > +## forks a child to process each file passed in the command line and collects > > +## the results > > +sub process_files { > > + my $index = 0; > > + my $njobs = get_online_processors(); > > + my $select = IO::Select->new(); > > + > > + while (my $file = shift(@ARGV)) { > > + # fork a child process and read it's stdout > > + my $pid = open(my $fh, '-|'); > > /me makes noises about make -jN and the jobserver and not using all > processors on a machine if we were asked nicely not to. > > I wrote a jobserver aware tool for the documentation builds, but it's in > python (scripts/jobserver-exec). Instead of reinventing that wheel (and > in Perl), we could: > > 1) ignore this problem and assume anyone using LTO is fine with using all CPUs > > 2) implement a jobserver-aware Perl script to do this > > 3) make Python a build dependency of CONFIG_LTO and re-use scripts/jobserver-exec I'm fine with any of these options, although I'm not sure why anyone would want to compile an LTO kernel without using all the available cores... :) Using jobserver-exec seems like the easiest option if we want to limit the number of cores used here. Any preferences? > > # If CONFIG_LTO_CLANG is selected, collect generated symbol versions into > > # .tmp_symversions.lds > > gen_symversions() > > @@ -74,6 +84,9 @@ modpost_link() > > --end-group" > > > > if [ -n "${CONFIG_LTO_CLANG}" ]; then > > + gen_initcalls > > + lds="-T .tmp_initcalls.lds" > > Oh, I think lds should be explicitly a "local" at the start of this > function, perhaps back in the symversions patch that touches this? It's already local, that part is just not visible in this patch. Sami _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel