Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp4109581pxk; Tue, 29 Sep 2020 14:49:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwqEm3BTB26aO2Ug6ToVa48W0JmYNiC+Yr7ke2yvP8c1NcERdDTyRWAoNv8CwnYn1sm2TxM X-Received: by 2002:a50:ce4e:: with SMTP id k14mr5479450edj.177.1601416154188; Tue, 29 Sep 2020 14:49:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601416154; cv=none; d=google.com; s=arc-20160816; b=JNkNp8WujW55ZNfn3mvX6Ihku3QGDDXzAD2ILv2+WW6Te1JhFiDbXLoiPOZ7gLgrWE wb8iUhle6ICD23ICm3fzNxRDdR/CSj8cIkl36lczmXm047zhOQf2P48cPs9djeiqIqn8 m9Y2uH+sP6BAJBcZrcA+MDFJrZJDSz/tpSnp0ZPTgD+yJACLcrKo5R5pjfKwlxa9Ev/u /QTOuQ5jGfMpPjP5/3fxWiFoOLvBBBu9i7AtQYTKs0kLKeXleR6+kPPG/8AZpNtUImuP sGlGskPw+HrgTC/YFJNY2IVtf3OgDHf1d7o/YNjo7kOYA+xBAiaaf93NtQWEp+o13XaV QHlA== 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=5ADrbIYYdkQ2THetWVdXFRMGM/F7dNAyZUNR6Ura+J8=; b=ynqgqaSrfpO/YBNJKco3Qxczir/7+yli5ml5H+ithrBcYGFbu0/hFmFpqPg1vNlw3V 7AwlVuirb7yUIqvtGzaR7RSTBJnPc7HUxSeKANAN7LrECWKEG991fUp5x9C7000aKHmu +5IpwFm8Soq/A0nxY7tyiCy/3IMn4tTFNzBtt3QFNLB42OCmNdMXhBzzyhYoinHtyqe7 gy1rs77V5NCS9mY1Mn+x/qQlhOQdP4Ce+ezR4sHNcXY6EYTDZHDkPQ1j8QajlOCt6G9J Fuv80qVOxClF7GPRrls92hLKHFQe6zWlZF3bT3dPRdxPlnCmsVrb2J2X/yIpCPpuDVqo MT1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=MekhgGdQ; 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 l23si3675324ejn.7.2020.09.29.14.48.50; Tue, 29 Sep 2020 14:49:14 -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=MekhgGdQ; 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 S1729081AbgI2VrZ (ORCPT + 99 others); Tue, 29 Sep 2020 17:47:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48414 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729001AbgI2VrV (ORCPT ); Tue, 29 Sep 2020 17:47:21 -0400 Received: from mail-pg1-x54a.google.com (mail-pg1-x54a.google.com [IPv6:2607:f8b0:4864:20::54a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2521BC0613DA for ; Tue, 29 Sep 2020 14:47:17 -0700 (PDT) Received: by mail-pg1-x54a.google.com with SMTP id t128so4067276pgb.23 for ; Tue, 29 Sep 2020 14:47:17 -0700 (PDT) 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=5ADrbIYYdkQ2THetWVdXFRMGM/F7dNAyZUNR6Ura+J8=; b=MekhgGdQDfVYCDwXqPqLOmRuR7bDrOrx74bKs36BEL9DMLEqc3GHdIW78xNvVW+CXD OBR1TA7PPlKp15z5Yvt6TGU00YrPE6jEVmJU2/BObk6f58edi9mDYneayNLG3BF+85eI JjVCIO2RNOdO/LFMDVGntOPmSZ80VCfWnW6rDxt2eRzeZ6jXgiYTuMIacuHOI7Agk84Q /EqGu8oBcu0EPNuoFAiQuSJKYV61YqkH23yEvB8gadt3EGDYNx7DqA1r7P5qUmqJEEld mLCeOrbo1nSD3wVfre9ST4vF2Q7dHDbNvEpQKR0fdUlOz46fHVxsu7B8etms0FiNNoqi jwIA== 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=5ADrbIYYdkQ2THetWVdXFRMGM/F7dNAyZUNR6Ura+J8=; b=doizqbRoj6sT9IR4Vekzz2QvqYh/QO7PyNJWIRx6FlZfWJrA2LsndZlAgAEaL98K2v odVmLVULKzV1O3UWFGYt7KPClhKiFpCJ1KeYPgfIF50IWgJkuJhKaKuRq9Ys995G/meS HwashOa9jQjZp8nBLft3JXHb3t6pNAyIACes8ooWgVsHd4rQcoS76uiuJ1ssIAwVxnqZ XQzf04tXPPqzQlABKRxGd6ZUvrcJELGlnjH1rg+xi98X7BhEfmkWQTpj3CcGzm+ZnKuy sa0fAEWUghi4sfFc5WQgkBoZJC+r8BJJKPw/FfgWb75t3x7aB9o/wZmLQMMj48JWu2cS JuLA== X-Gm-Message-State: AOAM532V+IzcLNZRQKrck/+8oWYTwRBhoajFgo6+5boX1tqT7qu3Hsn/ L2Rae7g0fC6bnoTatHVbculdmzQcjTCGxFn3ahk= 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:a63:ff63:: with SMTP id s35mr4883241pgk.14.1601416036594; Tue, 29 Sep 2020 14:47:16 -0700 (PDT) Date: Tue, 29 Sep 2020 14:46:21 -0700 In-Reply-To: <20200929214631.3516445-1-samitolvanen@google.com> Message-Id: <20200929214631.3516445-20-samitolvanen@google.com> Mime-Version: 1.0 References: <20200929214631.3516445-1-samitolvanen@google.com> X-Mailer: git-send-email 2.28.0.709.gb0816b6eb0-goog Subject: [PATCH v4 19/29] PCI: Fix PREL32 relocations for LTO From: Sami Tolvanen To: Masahiro Yamada , Will Deacon , Steven Rostedt Cc: 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, x86@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 835530605c0d..4e64421981c7 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -1909,19 +1909,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.28.0.709.gb0816b6eb0-goog