Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp878258ybt; Wed, 24 Jun 2020 13:35:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyC8Q5b+itdRSRQrUM7tvkvgU8oz9wQJM2XlGD8o2fjs+HSjjwz5lGnGU2rCebiGZ1tqkn9 X-Received: by 2002:a17:906:c672:: with SMTP id ew18mr27802495ejb.404.1593030940845; Wed, 24 Jun 2020 13:35:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593030940; cv=none; d=google.com; s=arc-20160816; b=BN5WuXFGeIUP9kdiELgYsj0dMKMZ1e2Q9zd+W74ZpN2TXEub542XII2VFqTx2/5B4k ZhJrXfsBrZpz+6YnsoiAhnlnvPI8NOdQzAok9FCQjvxEWD9sx2oUsJYVyhmriOzL9Xz2 MBvaxBrfbUSeZDS4GUjG+irx36PicmIWYp/rJR3sGXkbDAebvQnHcDymFFslf7vdlQfX QVzg+ISib36w29Cuy5BLgp8beEtHkXLD29jQYRUy2V276ClvAIuXV9tJtW3Rx+S8Obkm vjiskQES0aGo6YGr2aVhV4w/XXAcHwKSY42szjHlwSiVFtzQFLxaRC95SgDN6RVIeUa2 QVAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:from:subject:references :mime-version:message-id:in-reply-to:date:dkim-signature; bh=p5Zjwl0fzbxC+wniz47UyXQT+jPezYAnZAW9sm53Gyo=; b=ZFvYmyq4O+vFvVVRg9KrVXCM3wECv6mrg3SiZEou5iY31T+oZNh06IBzHuMREIjSI2 Bp+2jTdVNOl28u7IwfbmqT8YtL2v7lyECYm4KbKHLQDH0ZB30FJ+acKZAuSZ3J4P+qbC bRChBNEGcxeYTSZYpszZsd+3hSfHIigQylq5JjFiMx0QPE8FGJHNFSnQDjqJTsUB3oUb E3lTEEIWHI3UOWxn8oO5onbbLaSr8Tciha+Jupe3cuiR1bMMezHNszOPWN4VjmlrUJmx f0heL2pK2ffaVqpMKtiks+c08aujtBqKGWpduTo2xlYIh59OmoQKpZhakvlTda52h4CW WRxQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=I3ECgl1r; 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 q22si2232574eja.393.2020.06.24.13.35.17; Wed, 24 Jun 2020 13:35:40 -0700 (PDT) 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=I3ECgl1r; 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 S2406504AbgFXUe3 (ORCPT + 99 others); Wed, 24 Jun 2020 16:34:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50578 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2406508AbgFXUdT (ORCPT ); Wed, 24 Jun 2020 16:33:19 -0400 Received: from mail-qt1-x84a.google.com (mail-qt1-x84a.google.com [IPv6:2607:f8b0:4864:20::84a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C93E1C0613ED for ; Wed, 24 Jun 2020 13:33:18 -0700 (PDT) Received: by mail-qt1-x84a.google.com with SMTP id u48so2419412qth.17 for ; Wed, 24 Jun 2020 13:33:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=p5Zjwl0fzbxC+wniz47UyXQT+jPezYAnZAW9sm53Gyo=; b=I3ECgl1rBLWOyBs5RtnQDte2DTgBK8OvV3bMelQO3YzMeXJZPelqzsYzrwhg4KISwq Q8EP/5Rt6Nxpn5jlDw36BbBCGJdZtB2lqDV3jxoCeZsxATVA/6EywW70IFQ8KMkMtwcs 8ERi7Vnp6AvUX047q7Y6jPhoYIU9tYESBFs78HyX/W7KrPxM3sHVTb3fYIZB+7Vx8nAt TaK2/xswynOZBsPbNiwRJQVa2aWgCfk+6/lVEiWQobeXdeiVAy43gwzfUDm/34ApF0Y4 fmT1yzxDDHGNjYUCuAffxFCE77GVNDIobyJaeYAtR60VuSJZiMITgzBrUO93ylah82EN IIkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=p5Zjwl0fzbxC+wniz47UyXQT+jPezYAnZAW9sm53Gyo=; b=h9oWGoAiQzuN/Z93uk01mxU0TmeHKydjuv0PFS+TeVuVO6yj80MT5ZUoGW6IV8F6ok LtVA4AYEXQd36XBVR/NS4JpJq243bSJzyzfoQkpfVPtlQzP3bLgkNDlZvysw56FsqXyZ DGvHTYUO1wAztp+1SNj8Y0oihlBs/eb00GstzjHelSCdOMuawwSUB5Lx18eS6XTs2Jmb R1CZj3K8riTWvgmgb0hZ2+iSTJvKLjZdW/QdnH/LHTzwNFpWwISaFFApmmGPgDT3POMh WFUFJKL2AKs5mwYfGyId8zomAIxxvUMqLc1UtbCRCkX5rk/ng4xBKZlCbvqRSjzXR7Q2 /BXw== X-Gm-Message-State: AOAM531b3VWC+3cSW80NTavWkECXD2TV4pgJKJn4E00XMsE9QniQRtV4 W4XZSy4HRo9Km5c8kZmG8LMnXUplTxsY+d5K9Mg= X-Received: by 2002:ad4:4526:: with SMTP id l6mr8754125qvu.16.1593030798020; Wed, 24 Jun 2020 13:33:18 -0700 (PDT) Date: Wed, 24 Jun 2020 13:31:49 -0700 In-Reply-To: <20200624203200.78870-1-samitolvanen@google.com> Message-Id: <20200624203200.78870-12-samitolvanen@google.com> Mime-Version: 1.0 References: <20200624203200.78870-1-samitolvanen@google.com> X-Mailer: git-send-email 2.27.0.212.ge8ba1cc988-goog Subject: [PATCH 11/22] pci: lto: fix PREL32 relocations From: Sami Tolvanen To: Masahiro Yamada , Will Deacon Cc: 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, Sami Tolvanen Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org With 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 --- include/linux/pci.h | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/include/linux/pci.h b/include/linux/pci.h index c79d83304e52..1e65e16f165a 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -1909,19 +1909,24 @@ 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) { 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.27.0.212.ge8ba1cc988-goog