From patchwork Mon Aug 14 10:52:26 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 109976 Delivered-To: patch@linaro.org Received: by 10.140.95.78 with SMTP id h72csp4170358qge; Mon, 14 Aug 2017 03:53:05 -0700 (PDT) X-Received: by 10.99.100.134 with SMTP id y128mr23534921pgb.365.1502707985143; Mon, 14 Aug 2017 03:53:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1502707985; cv=none; d=google.com; s=arc-20160816; b=Darq+UGvCwURwrr3M3WVwHxhiAOxGh2FdC+rQJqAWL3/YsT2dIzDEt7nXukDZnYasR C1fdxHwCaqkuBz9GyPm9nn532F+n4LlXP/x9RScp5HbAVvAx4xJn0mcjUu741sehMbCX dUWU+AhsylZoXa3gseACgTruuR93yY5HvtCEPdodCJp6UZ0eJK/SNzte4IRy2OEhqUdL I9PSK/W/MNMSyGYs7EpvbVCB6TZBKntzyLRKPKUb1pl0TNrw/LqGe7i/zf+4/NRRB7vt t5w7euJZ+k3Ud9QQx7YSdc4+i5RG7N0dW2ZA3N60qfJ5HPdH3buAnbTrrOLXOliko/5P i0JA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=f+5y4QROaCyI0q5biFl35WnF56xgn6ZL9v3gucMIeYs=; b=ynTHjMpclrxIdHtJZixNZK9zf8lwykcQv133seOeezlRd1q+k+YSCdVKCe+cIEM454 rCyjm++3VkdbZDKbRLwa5YkgOoDjzNDa+aPoLW+SRiPByESD88EtQHgaLGiHHB9Y2R9D 4mhdKH9VaSO4ugd/A4JUfgCBNglrzurEcYTjd9Iu255h4dU9QIGKqgCUGi3KEB4ZDWPi oPOsDVMq02QemNjHx1E8rYfVS5aAeetQGfAchOMvZ7rTCzMuzEsbnkOMAnp67wcnGJYU Sej9geF5nI0YGxWDroGQMLlvOCU1Ye2E4m6PqLG20DiM35FRldbB66sshqKIjP6DQIcO 4yPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LYfL6ca6; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 68si4514463ple.590.2017.08.14.03.53.04; Mon, 14 Aug 2017 03:53:05 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LYfL6ca6; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752855AbdHNKxB (ORCPT + 25 others); Mon, 14 Aug 2017 06:53:01 -0400 Received: from mail-wr0-f181.google.com ([209.85.128.181]:35257 "EHLO mail-wr0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752748AbdHNKw7 (ORCPT ); Mon, 14 Aug 2017 06:52:59 -0400 Received: by mail-wr0-f181.google.com with SMTP id k71so33208202wrc.2 for ; Mon, 14 Aug 2017 03:52:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=f+5y4QROaCyI0q5biFl35WnF56xgn6ZL9v3gucMIeYs=; b=LYfL6ca60YPxTkMiOCMK7ZPJp4J94zBg+xMC+QsORuzbKIq4BXKtUcumVYpWbIip0w klG1NP3WYPCs3X/z45JtXmJf+5rf+e+f5pMNX2p3EVzrtRL+E7zKEaykGSm3ZYcq5kXz 7rPMuTM5QwGrfElpB0JmCVrQwIfSuG3FF9pwE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=f+5y4QROaCyI0q5biFl35WnF56xgn6ZL9v3gucMIeYs=; b=koENrzL90mQa4zw0Rjbpd7YiRNLS8mb47p0cPpRouwFbhrdfDJzlMWc6p7SrPXKYq9 ANw0Iw+P1TqsSh5bcukZTlqfMGr6yt2j6djU/GBroOrzU9CIH8HOpUs2HLuhu9Z74IAU dq9m9C+5lE4VGUstrCaWpvJr9TZDqWcT2H8s5LSQD7Zi0uPIFyP0vMOnNtFbzJt+cEG0 9xrjEE51/e3DXFkt+RFKRQDm7WgxtuJz9ZCsqxrHaNvn+5zxPu6PC+0mfJEJh1oXN6OE mZUJK087A+xz5hWX5a6FYG57QKQfLQIA6/yAqF0fy81irhKMPnIO2GXosaH+ZuKlP0+o pgXg== X-Gm-Message-State: AHYfb5iv7KGEajpUcNaCe2RAMDMVhFYCcu4TOPj/KCFoP3zYcZJv/aVJ nl8EKqH2g6dxSHrJCPbCog== X-Received: by 10.223.135.211 with SMTP id c19mr2259733wrc.10.1502707977881; Mon, 14 Aug 2017 03:52:57 -0700 (PDT) Received: from localhost.localdomain ([154.146.161.128]) by smtp.gmail.com with ESMTPSA id b15sm1490732wra.68.2017.08.14.03.52.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 14 Aug 2017 03:52:57 -0700 (PDT) From: Ard Biesheuvel To: linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org Cc: Ard Biesheuvel , "H. Peter Anvin" , Arnd Bergmann , Heiko Carstens , Kees Cook , Will Deacon , Michael Ellerman , Thomas Garnier , Thomas Gleixner , "Serge E. Hallyn" , Bjorn Helgaas , Benjamin Herrenschmidt , Paul Mackerras , Catalin Marinas , Petr Mladek , Ingo Molnar , James Morris , Andrew Morton , Nicolas Pitre , Steven Rostedt , Martin Schwidefsky , Sergey Senozhatsky , Jessica Yu Subject: [PATCH 0/5] add support for relative references in special sections Date: Mon, 14 Aug 2017 11:52:26 +0100 Message-Id: <20170814105231.14608-1-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.11.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This adds support for emitting special sections such as initcall arrays, PCI fixups and tracepoints as relative references rather than absolute references. This reduces the size by 50% on 64-bit architectures, but more importantly, it removes the need for carrying relocation metadata for these sections in relocatables kernels (e.g., for KASLR) that need to fix up these absolute references at boot time. On arm64, this reduces the vmlinux footprint of such a reference by 8x (8 byte absolute reference + 24 byte RELA entry vs 4 byte relative reference) Patch #2 was sent out before as a single patch. This series supersedes the previous submission. This version makes relative ksymtab entries dependent on the new Kconfig symbol HAVE_ARCH_PREL32_RELOCATIONS rather than trying to infer from kbuild test robot replies for which architectures it should be blacklisted. Patch #1 introduces the new Kconfig symbol HAVE_ARCH_PREL32_RELOCATIONS, and sets it for the main architectures that are expected to benefit most from this feature, i.e., 64-bit architectures, and ones that use runtime relocation. Patches #3 - #5 implement relative references for initcallls, PCI fixups and tracepoints, respectively, all of which produce sections with order ~1000 entries on an arm64 defconfig kernel with tracing enabled. This means we save about 28 KB of vmlinux space for each of these patches. For the arm64 kernel, all patches combined reduce the size of vmlinux by about 300 KB. Cc: "H. Peter Anvin" Cc: Arnd Bergmann Cc: Heiko Carstens Cc: Kees Cook Cc: Will Deacon Cc: Michael Ellerman Cc: Thomas Garnier Cc: Thomas Gleixner Cc: "Serge E. Hallyn" Cc: Bjorn Helgaas Cc: Benjamin Herrenschmidt Cc: Paul Mackerras Cc: Catalin Marinas Cc: Petr Mladek Cc: Ingo Molnar Cc: James Morris Cc: Andrew Morton Cc: Nicolas Pitre Cc: Steven Rostedt Cc: Martin Schwidefsky Cc: Sergey Senozhatsky Cc: Jessica Yu Ard Biesheuvel (5): arch: enable relative relocations for arm64, power, x86, s390 and x86 module: use relative references for __ksymtab entries init: allow initcall tables to be emitted using relative references drivers: pci: add support for relative addressing in quirk tables kernel: tracepoints: add support for relative references arch/Kconfig | 10 +++++ arch/arm64/Kconfig | 1 + arch/arm64/kernel/vmlinux.lds.S | 2 +- arch/powerpc/Kconfig | 1 + arch/s390/Kconfig | 1 + arch/x86/Kconfig | 1 + arch/x86/include/asm/Kbuild | 1 + arch/x86/include/asm/export.h | 4 -- drivers/pci/quirks.c | 13 ++++-- include/asm-generic/export.h | 12 ++++- include/linux/compiler.h | 11 +++++ include/linux/export.h | 47 +++++++++++++++----- include/linux/init.h | 44 +++++++++++++----- include/linux/pci.h | 20 +++++++++ include/linux/tracepoint.h | 19 ++++++-- init/main.c | 32 ++++++------- kernel/module.c | 33 +++++++++++--- kernel/printk/printk.c | 4 +- kernel/tracepoint.c | 19 +++++--- security/security.c | 4 +- 20 files changed, 212 insertions(+), 67 deletions(-) delete mode 100644 arch/x86/include/asm/export.h -- 2.11.0