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.0 required=3.0 tests=BAYES_00,INCLUDES_CR_TRAILER, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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 6CC0BC4361B for ; Fri, 4 Dec 2020 14:03:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3DADA22AB9 for ; Fri, 4 Dec 2020 14:03:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387677AbgLDODD (ORCPT ); Fri, 4 Dec 2020 09:03:03 -0500 Received: from mail-lj1-f194.google.com ([209.85.208.194]:40584 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387411AbgLDODD (ORCPT ); Fri, 4 Dec 2020 09:03:03 -0500 Received: by mail-lj1-f194.google.com with SMTP id y10so6726597ljc.7; Fri, 04 Dec 2020 06:02:45 -0800 (PST) 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=SzMGLrWLNHR2uzHXkA7fVFrIiRthHhSpOA3S/SFE9xY=; b=TzUjj/BpaZfivNUeAp7DAG1igfiRj5tHGg5seiN6pCpGZkRlVcT5ZFXJKVFoDwCwkk 6UxTkP5ZJd5zcAk075mbpjnP6tq0Fs992sdW8izzbu99pz/GSyksSXFGJAJPfJ+PktMq 094Y4l2Lh2Kb7WCvbnxdoDfASju6yGjA+/YBSMhPzPo/7oUjZNVXMNE7XiCUyvbmauO+ hEJVT5OSH5PiZBe7kA2WFirXvVbRI3pSDAKwvgQ8LA05SRNHg8uZIKh/85cHsyqInmY0 +RyTIu9efPdgQFJS9WqnB3PEVXqQNqYpeLxAEQ9VE1Uck4G93elfrnpz4Y/UxaMSX94J l9cw== X-Gm-Message-State: AOAM530olr8BrLUT2/YkFKavRDKPF8JRFl5DTIJTBZotoFCRYpV6O19R wf0bfSmxYEfufIs6jE2MfDc= X-Google-Smtp-Source: ABdhPJzinbl8W6GNnuh2d0iNrH45Uu5Od1aTjnKkRJ/b/Lo8Z2zvuOe5aiVnx94/T6QOmdOgJLSiFA== X-Received: by 2002:a2e:5853:: with SMTP id x19mr3739427ljd.232.1607090540012; Fri, 04 Dec 2020 06:02:20 -0800 (PST) Received: from xi.terra (c-beaee455.07-184-6d6c6d4.bbcust.telenor.se. [85.228.174.190]) by smtp.gmail.com with ESMTPSA id r141sm1684042lff.55.2020.12.04.06.02.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Dec 2020 06:02:19 -0800 (PST) Received: from johan by xi.terra with local (Exim 4.93.0.4) (envelope-from ) id 1klBfh-0004K0-Ao; Fri, 04 Dec 2020 15:02:53 +0100 Date: Fri, 4 Dec 2020 15:02:53 +0100 From: Johan Hovold To: Rob Herring , Greg Kroah-Hartman , Jessica Yu , Linus Torvalds Cc: Frank Rowand , Arnd Bergmann , Geert Uytterhoeven , Dmitry Torokhov , David Miller , Jakub Jelinek , Peter Zijlstra , Thomas Gleixner , Steven Rostedt , Daniel Kurtz , linux-arch@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-kernel@vger.kernel.org, Johan Hovold , stable Subject: Re: [PATCH v2 1/8] of: fix linker-section match-table corruption Message-ID: References: <20201123102319.8090-1-johan@kernel.org> <20201123102319.8090-2-johan@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201123102319.8090-2-johan@kernel.org> Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org Rob, On Mon, Nov 23, 2020 at 11:23:12AM +0100, Johan Hovold wrote: > Specify type alignment when declaring linker-section match-table entries > to prevent gcc from increasing alignment and corrupting the various > tables with padding (e.g. timers, irqchips, clocks, reserved memory). > > This is specifically needed on x86 where gcc (typically) aligns larger > objects like struct of_device_id with static extent on 32-byte > boundaries which at best prevents matching on anything but the first > entry. Specifying alignment when declaring variables suppresses this > optimisation. > > Here's a 64-bit example where all entries are corrupt as 16 bytes of > padding has been inserted before the first entry: > > ffffffff8266b4b0 D __clk_of_table > ffffffff8266b4c0 d __of_table_fixed_factor_clk > ffffffff8266b5a0 d __of_table_fixed_clk > ffffffff8266b680 d __clk_of_table_sentinel > > And here's a 32-bit example where the 8-byte-aligned table happens to be > placed on a 32-byte boundary so that all but the first entry are corrupt > due to the 28 bytes of padding inserted between entries: > > 812b3ec0 D __irqchip_of_table > 812b3ec0 d __of_table_irqchip1 > 812b3fa0 d __of_table_irqchip2 > 812b4080 d __of_table_irqchip3 > 812b4160 d irqchip_of_match_end > > Verified on x86 using gcc-9.3 and gcc-4.9 (which uses 64-byte > alignment), and on arm using gcc-7.2. > > Note that there are no in-tree users of these tables on x86 currently > (even if they are included in the image). > > Fixes: 54196ccbe0ba ("of: consolidate linker section OF match table declarations") > Fixes: f6e916b82022 ("irqchip: add basic infrastructure") > Cc: stable # 3.9 > Signed-off-by: Johan Hovold > --- Could you pick this one up for 5.11? Johan