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=-9.6 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FSL_HELO_FAKE, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_IN_DEF_DKIM_WL 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 7E8CAC433E2 for ; Thu, 10 Sep 2020 16:30:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3AE6220C09 for ; Thu, 10 Sep 2020 16:30:04 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="eS8Omoyt" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726935AbgIJQaB (ORCPT ); Thu, 10 Sep 2020 12:30:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46294 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725833AbgIJQ2T (ORCPT ); Thu, 10 Sep 2020 12:28:19 -0400 Received: from mail-pl1-x641.google.com (mail-pl1-x641.google.com [IPv6:2607:f8b0:4864:20::641]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5D7A5C06138B for ; Thu, 10 Sep 2020 08:07:11 -0700 (PDT) Received: by mail-pl1-x641.google.com with SMTP id a8so1057630plm.2 for ; Thu, 10 Sep 2020 08:07:11 -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=CkdZTgPQtli4HqKjoybGJC69i/K2eo+/Y/ueOVTU/uQ=; b=eS8OmoytThC7KUY/Rbjn9+OdhHCTAxZHZhtO9Ll397opaMxtZwThboa+C2O8ZFCyZO 3yO7BFlQAHn+yHQOjTkSFxrGQT55I8zRk+ACqC8mUlAGEgaJBYVxdtDOeJYvRXY7OjD1 qoTqm7lymwBPWk5HvlxgcsMnJSmrWwc/CDEf5vU234aNsYZC/feumKaSOaVQM1oeg2rp 5mn5icPj2L2oVd+okglM+aUogVgHmTvRe+DoweL0N0v4d2/lpxJ7oBj1ZuDkqyJtw+x2 MyX0f8gzheaFJLMAEkWsyGR+2G8QUbr85wv/70bydcasoZ+1oXcDIR0JEbGlmuon6m7C zqwA== 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=CkdZTgPQtli4HqKjoybGJC69i/K2eo+/Y/ueOVTU/uQ=; b=tsO7ep0xWexoaopznKcYzPyhasWh5nU7ythVOQXNr82btDkbPAd6rbIkxNXRZqxdhh 2yRz8R3Dm+5U6roRXn2LiLP0nBfY3jhT1MgO3wwNTWb01bbSidCOZstAPbnmm/5Ai/+S Af6iXZVOgIjLQmoX7My0QwPMe+iLAUMmh8BXiiZNz+lsBL9so0SkPoMfjKGbtO+rrdYh MH2bT/2Vlk92LMfaOejfs/wPebISyJzfM5jMknSj62oXXJOTIwcMupV+OMe09fDq2zhJ Uc8VpS+DMfFyx2+uz97y+T3yV9WSWeP8445KdCKX1MVbWEqMPsNhh1EUQLRuj5vEs9jx 7YDw== X-Gm-Message-State: AOAM530HuKV7/gguy21EpEP56K8DdQF1FGHNRv4gg8WeMvCjBfD/mCtp p3uNJEwSQqW+u140Nx66oXKDTw== X-Google-Smtp-Source: ABdhPJzgkkNJGQRPeFg7lZtu3UZBjQBkf2nGy3Om/c9n+Dj7KFkAAjDpg1xpd04kYgbe9qjhwsW3RQ== X-Received: by 2002:a17:902:82c1:: with SMTP id u1mr6062512plz.38.1599750430560; Thu, 10 Sep 2020 08:07:10 -0700 (PDT) Received: from google.com ([2620:15c:201:2:f693:9fff:fef4:1b6d]) by smtp.gmail.com with ESMTPSA id p5sm5097827pgm.66.2020.09.10.08.07.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2020 08:07:09 -0700 (PDT) Date: Thu, 10 Sep 2020 08:07:04 -0700 From: Sami Tolvanen To: David Woodhouse Cc: Masahiro Yamada , Will Deacon , Peter Zijlstra , Steven Rostedt , Greg Kroah-Hartman , "Paul E. McKenney" , Kees Cook , Nick Desaulniers , clang-built-linux@googlegroups.com, kernel-hardening@lists.openwall.com, linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, x86@kernel.org Subject: Re: [PATCH v2 15/28] init: lto: ensure initcall ordering Message-ID: <20200910150704.GA2041735@google.com> References: <20200624203200.78870-1-samitolvanen@google.com> <20200903203053.3411268-1-samitolvanen@google.com> <20200903203053.3411268-16-samitolvanen@google.com> <5f45f55340cf54f5506a50adf61e49b27b904322.camel@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5f45f55340cf54f5506a50adf61e49b27b904322.camel@infradead.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Sep 10, 2020 at 10:25:40AM +0100, David Woodhouse wrote: > On Thu, 2020-09-03 at 13:30 -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. > > Is this guaranteed to give you the *same* initcall ordering with LTO as > without? Yes. It follows the link order, just like the linker without LTO, and also preserves the order within each file. Sami 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.9 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 21911C433E2 for ; Thu, 10 Sep 2020 15:08:33 +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 A6FE321D79 for ; Thu, 10 Sep 2020 15:08:32 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="MlHiB3iK"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=google.com header.i=@google.com header.b="eS8Omoyt" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A6FE321D79 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=dFxBZt9I5yjjxLdj5jDUnPYlRVjtRMLTwgd9K7daIbQ=; b=MlHiB3iKwFX/1c6WtDm1GSvVP M1dM+2eNOimvtOOl7Z5P+B5vmxzo5f3iVdLrWJM9A0Ff1NnIwVbRDVWt2+sSflcA7IHkUCD2CGMo2 TfKSZANnpp5m2NUInercHRxBQXMCQcnJ8gZ6fXoWuKGTkTLRhF94HW4nxfKyRJghAm5m8ufHb+4ow /yQrML4sX6Z6tePCB7FMNO7+GlhK3acp4Wn5dMep9NP+CkkQnCBzHLJVvba1N4AkBwi0SU7WEC2K2 nfYzBScDtR3xaNVx4y3ODZ+0VXrdIkvIgOwJ1uLRiLmAiNiBiERxgk65JY2SjXXBqm8xgIQ7+6IIh PxbD+YeRw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kGOAP-000852-Mw; Thu, 10 Sep 2020 15:07:17 +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 1kGOAM-00082z-SM for linux-arm-kernel@lists.infradead.org; Thu, 10 Sep 2020 15:07:15 +0000 Received: by mail-pj1-x1042.google.com with SMTP id u3so156444pjr.3 for ; Thu, 10 Sep 2020 08:07:12 -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=CkdZTgPQtli4HqKjoybGJC69i/K2eo+/Y/ueOVTU/uQ=; b=eS8OmoytThC7KUY/Rbjn9+OdhHCTAxZHZhtO9Ll397opaMxtZwThboa+C2O8ZFCyZO 3yO7BFlQAHn+yHQOjTkSFxrGQT55I8zRk+ACqC8mUlAGEgaJBYVxdtDOeJYvRXY7OjD1 qoTqm7lymwBPWk5HvlxgcsMnJSmrWwc/CDEf5vU234aNsYZC/feumKaSOaVQM1oeg2rp 5mn5icPj2L2oVd+okglM+aUogVgHmTvRe+DoweL0N0v4d2/lpxJ7oBj1ZuDkqyJtw+x2 MyX0f8gzheaFJLMAEkWsyGR+2G8QUbr85wv/70bydcasoZ+1oXcDIR0JEbGlmuon6m7C zqwA== 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=CkdZTgPQtli4HqKjoybGJC69i/K2eo+/Y/ueOVTU/uQ=; b=nDW97L9DycY0NF3KAmP+n2ft8b+C/ovCMwAr79UO66/JSauu4vd80ejxTjs4SfFdho R+PD8PgX2skquhVTSEdxwRdNEA6ygmX/3JWnJBK7TO1BkdX/Buh7S9izc+WOSDknU4Hj 8F/X7Qcg3rF3tmruajrBtegq6O/3kMW4iJB9TJnnsYB9HLZj0I1UmIpwzI3On9VdwnQL 4hrWwJzhxkAUSULnI+E0df7hBHKIX8sU32SY0DPP5T2zad1Rl9Y8J6taE8IKn5EcHPzG xZCfxvIunRKZH71IMXs3BMYtXbz/hUIXN0qBNg8k8Kr/9ZDwXpknxgMw3oq8kanGpLYQ Q/nA== X-Gm-Message-State: AOAM532hWmfgSnRWOUJIX5VLftHweEh3UxY9Wtk7MfJRL0m5aX4RwViT H/eaBjW02oYRTqqlcc7FhRBDlA== X-Google-Smtp-Source: ABdhPJzgkkNJGQRPeFg7lZtu3UZBjQBkf2nGy3Om/c9n+Dj7KFkAAjDpg1xpd04kYgbe9qjhwsW3RQ== X-Received: by 2002:a17:902:82c1:: with SMTP id u1mr6062512plz.38.1599750430560; Thu, 10 Sep 2020 08:07:10 -0700 (PDT) Received: from google.com ([2620:15c:201:2:f693:9fff:fef4:1b6d]) by smtp.gmail.com with ESMTPSA id p5sm5097827pgm.66.2020.09.10.08.07.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2020 08:07:09 -0700 (PDT) Date: Thu, 10 Sep 2020 08:07:04 -0700 From: Sami Tolvanen To: David Woodhouse Subject: Re: [PATCH v2 15/28] init: lto: ensure initcall ordering Message-ID: <20200910150704.GA2041735@google.com> References: <20200624203200.78870-1-samitolvanen@google.com> <20200903203053.3411268-1-samitolvanen@google.com> <20200903203053.3411268-16-samitolvanen@google.com> <5f45f55340cf54f5506a50adf61e49b27b904322.camel@infradead.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <5f45f55340cf54f5506a50adf61e49b27b904322.camel@infradead.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200910_110714_939088_78E39D6A X-CRM114-Status: GOOD ( 22.38 ) 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, Kees Cook , "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 10, 2020 at 10:25:40AM +0100, David Woodhouse wrote: > On Thu, 2020-09-03 at 13:30 -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. > > Is this guaranteed to give you the *same* initcall ordering with LTO as > without? Yes. It follows the link order, just like the linker without LTO, and also preserves the order within each file. Sami _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel