Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp674903pxb; Wed, 18 Nov 2020 14:13:41 -0800 (PST) X-Google-Smtp-Source: ABdhPJwUgKfDWnMM5Zr2X5DgPstxf0qe8TrGCDCyXc07RAklEoPKFuWyakeZLNhXOIVt7XzzFF+q X-Received: by 2002:a17:906:6dd6:: with SMTP id j22mr16971481ejt.255.1605737621404; Wed, 18 Nov 2020 14:13:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605737621; cv=none; d=google.com; s=arc-20160816; b=Ljnajkwz/5pQHwEI17QjkwlOfc+PLyPIP7EzeQ01ugAylKb6r8nF/Ca6erNe+7mYj0 pOFC/+UH/CX5cWcocOVktYisspdZb2+kF8Tuk+/km5Je30m3fXfSN8XALIZ2sL8Rw1iP 5Uz2bFFlWHAQqKoCPJrKNZ+A4Ta8Jqz8PHHV7QaHDRVvxShzTXSKyXRYjVppryP2/mi4 y4gJr8nrKNl128Pti37/WtH3AB54yacIlYh9gtTX5tgV5ALqeUwwkhkjlJ/thQ9GXFfN ul6VIn8R4bzY5ygl427F3QDInt00/jX3gx04T/W//NGjf/SFyZgAqzh+vpslYK3f8x7n /iYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:references:mime-version :message-id:in-reply-to:date:sender:dkim-signature; bh=bMl2xGwOyye8qFQQO5LhDpDmrDsCMs58eGZcnuWlmjA=; b=Qn73d9sLqAmb1t1pwT7LGMt4diBhxSAW2gJEYcphFT7HN1Z5td610qw5p5AJkLDllh Vo31KZuGKtpYxlY9i9TuJ8Xhu4Fg0rjbv+RCyW5g4LdH0430AMbAGTbiDAA2yT5Lt9mY SIhkpSZW4I6AKkr+9NZmIftwiIiSsVmETO1/0LbOU02yGY5GuSdmKar86HSbFaIJUmJY RPv6fE9KJxmG+Nr7PSNYByf6XV+08d59DtPDlS5832EW0RGw2/7edHyPhVylfBKrDfAw +G66X82saRRhV0/eb5132lWGoYA1w4kWLyJgay2a7GhY+CDSPb0qBP8RjRdf9T5uVv4c sYLw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=Nd7GPjj0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ec18si16193963ejb.679.2020.11.18.14.13.17; Wed, 18 Nov 2020 14:13:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=Nd7GPjj0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727398AbgKRWIe (ORCPT + 99 others); Wed, 18 Nov 2020 17:08:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53846 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727396AbgKRWHx (ORCPT ); Wed, 18 Nov 2020 17:07:53 -0500 Received: from mail-qv1-xf4a.google.com (mail-qv1-xf4a.google.com [IPv6:2607:f8b0:4864:20::f4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CFEAAC061A51 for ; Wed, 18 Nov 2020 14:07:53 -0800 (PST) Received: by mail-qv1-xf4a.google.com with SMTP id 60so2506253qvb.15 for ; Wed, 18 Nov 2020 14:07:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=bMl2xGwOyye8qFQQO5LhDpDmrDsCMs58eGZcnuWlmjA=; b=Nd7GPjj0ywkFIgMBmhds53YYdSle4acSaIFPLbVd61W8stSkNuoz0WxEayV/OD+juR 7iFFwAf5WeBqFMYZtbNZKvYarFFEIh0TRBfk8yozSVYTyizaOQn7nV/yOM5qfxhN6W3x F41WPEwVNkENBqTup7x2SW7FaXclkPY/jek8JoLFOskeSCczH+BvXJtXBg4dfeqkMd7O 5Jgsz0yx51vX7weJ6s9P7KIXrk46KNMTxH11C5CzpPEqWRCRyIwkXB16YTNgAiWSsV8M KuNdy4S5hjgNwFDrtraKFHI+LKTEBWBcWNWdPZnYpkQRqJAXNOz0JKEptCIRYdyLVRVY EmzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=bMl2xGwOyye8qFQQO5LhDpDmrDsCMs58eGZcnuWlmjA=; b=JNt5ey6kXTDDeoTHih6MZksPNNxx/LpGWUjbhEuJmZQDhu/cxdVSQ3I2QsJanDLfHY OOmM7lglvI6bz6Y9fCXoNhL9B9UFbI31a/Il6jAdQP+KWB53YBe4E2aP1zSXNNOMO2TO QLTbK6UpeT6Vwp8m7ntUBTvJeCyn0Z+fXbR9cBiS1yLsEPCcF43Px05GbwuAYFzExgEp OU2/eYmU0nPOhP9pF5FcstcYKHZ4Q8rc36H3XVmFhOApaXkD9LASaivTL/hMFc3q4wAF ZNj8oXzdmfycMqZ8CHu8EJn+M4/EoTqwN+FmInzYAOF8eXK6Yzs4uaWNneYwDQ6OtXPF mv0w== X-Gm-Message-State: AOAM531XVjrdBmL2dnHeRM+wtAKMRblJBuIKHHpas5iL3lFBzD1ccVVJ ehMpkNUrwWL8+hDkZHxNdPLRCKgYpox6YnLoBdY= Sender: "samitolvanen via sendgmr" X-Received: from samitolvanen1.mtv.corp.google.com ([2620:15c:201:2:f693:9fff:fef4:1b6d]) (user=samitolvanen job=sendgmr) by 2002:a0c:a94b:: with SMTP id z11mr3035952qva.24.1605737272927; Wed, 18 Nov 2020 14:07:52 -0800 (PST) Date: Wed, 18 Nov 2020 14:07:23 -0800 In-Reply-To: <20201118220731.925424-1-samitolvanen@google.com> Message-Id: <20201118220731.925424-10-samitolvanen@google.com> Mime-Version: 1.0 References: <20201118220731.925424-1-samitolvanen@google.com> X-Mailer: git-send-email 2.29.2.454.gaff20da3a2-goog Subject: [PATCH v7 09/17] PCI: Fix PREL32 relocations for LTO From: Sami Tolvanen To: Masahiro Yamada , Steven Rostedt , Will Deacon Cc: Josh Poimboeuf , Peter Zijlstra , 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, Sami Tolvanen Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org With Clang's Link Time Optimization (LTO), the compiler can rename static functions to avoid global naming collisions. As PCI fixup functions are typically static, renaming can break references to them in inline assembly. This change adds a global stub to DECLARE_PCI_FIXUP_SECTION to fix the issue when PREL32 relocations are used. Signed-off-by: Sami Tolvanen Acked-by: Bjorn Helgaas Reviewed-by: Kees Cook --- include/linux/pci.h | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/include/linux/pci.h b/include/linux/pci.h index 22207a79762c..5b8505a5ca5f 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -1912,19 +1912,28 @@ enum pci_fixup_pass { }; #ifdef CONFIG_HAVE_ARCH_PREL32_RELOCATIONS -#define __DECLARE_PCI_FIXUP_SECTION(sec, name, vendor, device, class, \ - class_shift, hook) \ - __ADDRESSABLE(hook) \ +#define ___DECLARE_PCI_FIXUP_SECTION(sec, name, vendor, device, class, \ + class_shift, hook, stub) \ + void stub(struct pci_dev *dev); \ + void stub(struct pci_dev *dev) \ + { \ + hook(dev); \ + } \ asm(".section " #sec ", \"a\" \n" \ ".balign 16 \n" \ ".short " #vendor ", " #device " \n" \ ".long " #class ", " #class_shift " \n" \ - ".long " #hook " - . \n" \ + ".long " #stub " - . \n" \ ".previous \n"); + +#define __DECLARE_PCI_FIXUP_SECTION(sec, name, vendor, device, class, \ + class_shift, hook, stub) \ + ___DECLARE_PCI_FIXUP_SECTION(sec, name, vendor, device, class, \ + class_shift, hook, stub) #define DECLARE_PCI_FIXUP_SECTION(sec, name, vendor, device, class, \ class_shift, hook) \ __DECLARE_PCI_FIXUP_SECTION(sec, name, vendor, device, class, \ - class_shift, hook) + class_shift, hook, __UNIQUE_ID(hook)) #else /* Anonymous variables would be nice... */ #define DECLARE_PCI_FIXUP_SECTION(section, name, vendor, device, class, \ -- 2.29.2.299.gdc1121823c-goog