From patchwork Sun Mar 11 12:38:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 131343 Delivered-To: patch@linaro.org Received: by 10.46.66.2 with SMTP id p2csp3055504lja; Sun, 11 Mar 2018 05:39:12 -0700 (PDT) X-Google-Smtp-Source: AG47ELsyy/Cue4bCK+n4tjhjqr5IDsTysmqoP/b5nJahHZlrJiWEGz0BfS1VI+qSt9FD1JAE1R7s X-Received: by 2002:a17:902:467:: with SMTP id 94-v6mr4744903ple.57.1520771952058; Sun, 11 Mar 2018 05:39:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1520771952; cv=none; d=google.com; s=arc-20160816; b=uloD54DLysXGeGyjDksfhJy3PGYz/FRXQtJA/51lJO4Btx3ccRMHTXkXEVn1o6+mrn fRZ9O4CDgMafZH6v4lslptOrDm9uqA/zWttoL5u6ICo6Rm6g/mfAcy+Ya+LzRXQaJ1jw 47WulVZV0sZthVKF4gjwKaVbzb77ObUsL1l+cdK+OgG51kcdH5vC55cGCpm2PwrWNhE8 gLlq2rEfnticgaXOhAMGekMzta8A57lFbkF1EXt1b0ep1YmakP38seyioHfyEFwmet73 dEMpSsNHlJSr6Yz9Qw9PNWXeD9NNgRgbGirfTzR1ZktUo/qfcy/FMkVNVGMeKQkTMfdy 956g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=GRMoN92mam/mVPAjYjGRyuEsi/CGFDhSglGru3Ea2sA=; b=j9jm5uzotpPy6Nk2fRNQS7tIvgkdIIJsr0njCcbShWCOHzYlB/471/psTlDj/Kcfgv +2dXTnJPmdW/bE9uYKjU2WYvt5DE5a/XeWBDZRb+aVmSM2q7WnIILlirAniYiTGOCfBd I984L8bLilyjOAn4vzXsjuZuETmzYaKMa9YfCGO40WsxoT/nCPa/gKNwg0Sy83lGWSsW LTm4186uusR4eCmpHEA/TRqUh9jK7MRkgQRpYyllJhByE825bz4Mdq6JeSVDIxcifd8r XyVvJqMF/PZefhmu5vTVTZj1taT0TTLJKNDuXN/+iqR6JcfE6AIZvvRXvRA1uVZL1s9k gm4A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=K8yGCz2Y; 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 x4si3595555pgo.278.2018.03.11.05.39.11; Sun, 11 Mar 2018 05:39:12 -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=K8yGCz2Y; 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 S932240AbeCKMjF (ORCPT + 28 others); Sun, 11 Mar 2018 08:39:05 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:52808 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932126AbeCKMi7 (ORCPT ); Sun, 11 Mar 2018 08:38:59 -0400 Received: by mail-wm0-f66.google.com with SMTP id t3so11440564wmc.2 for ; Sun, 11 Mar 2018 05:38:59 -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:in-reply-to:references; bh=GRMoN92mam/mVPAjYjGRyuEsi/CGFDhSglGru3Ea2sA=; b=K8yGCz2Y2VZYolB8JIt7DSN9hhN8tnUtTlDYlw/21Vwh6F0bwOWPTrbazxtmu1/CjV Mg92M4fhS4NWoqTSNXHqtl1mnh15fbz45amAK4ymmWtfWbB53yhO1M/zjlhHWh0mPYVM m34uvElvZpvKeUt32LzmlPKBKvNgFVcd4X3Oc= 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:in-reply-to :references; bh=GRMoN92mam/mVPAjYjGRyuEsi/CGFDhSglGru3Ea2sA=; b=fFHeWaXIiHOzft2z5PLrzvtDWX7iY+2+CePnAqhvUVgVDGy+gy0u04UNUJ079McaJh +PjkWovRrzg8PMRx4OVcAGSXfBq7QPzzMU4eQfdzpvy1azW3pe8aEKtkekjZiRlxYGsS VFyefTa0QxVWqpRVexroaXvczuAoLXtcPAzMOv/Xi7+D5oqFW22lSebOoQppz/jIMFrJ z0KG9tYyD7tW2aLD56MAKGb9r+MfpXH20kV63y6aQSZ+Pn8fQB8CUMk5oyPaMaVjf4Qs H21qh7+buwZTWyO2axiXvTEW2DFdyogi9tii+6PWsdwHPl8smMq7NPG7GpR4XSVMLPzC k4JQ== X-Gm-Message-State: AElRT7Eqa8N+fR2AX3K+lwHixjCXyhc8GBx8IPldEj//CK1tkWmR4DD3 YVc4JuWKbt7Id7smmhZq6ooXOQ== X-Received: by 10.28.26.202 with SMTP id a193mr3281810wma.138.1520771938386; Sun, 11 Mar 2018 05:38:58 -0700 (PDT) Received: from localhost.localdomain ([105.148.128.186]) by smtp.gmail.com with ESMTPSA id h188sm2569103wmf.37.2018.03.11.05.38.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 11 Mar 2018 05:38:57 -0700 (PDT) From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org Cc: Ard Biesheuvel , Arnd Bergmann , Kees Cook , Will Deacon , Michael Ellerman , Thomas Garnier , Thomas Gleixner , "Serge E. Hallyn" , Bjorn Helgaas , Benjamin Herrenschmidt , Russell King , Paul Mackerras , Catalin Marinas , Petr Mladek , Ingo Molnar , James Morris , Andrew Morton , Nicolas Pitre , Josh Poimboeuf , Steven Rostedt , Sergey Senozhatsky , Linus Torvalds , Jessica Yu , linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, x86@kernel.org Subject: [PATCH v8 1/6] arch: enable relative relocations for arm64, power and x86 Date: Sun, 11 Mar 2018 12:38:10 +0000 Message-Id: <20180311123815.17916-2-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180311123815.17916-1-ard.biesheuvel@linaro.org> References: <20180311123815.17916-1-ard.biesheuvel@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Before updating certain subsystems to use place relative 32-bit relocations in special sections, to save space and reduce the number of absolute relocations that need to be processed at runtime by relocatable kernels, introduce the Kconfig symbol and define it for some architectures that should be able to support and benefit from it. Cc: Catalin Marinas Cc: Will Deacon Cc: Benjamin Herrenschmidt Cc: Paul Mackerras Cc: Michael Ellerman Cc: Thomas Gleixner Cc: Ingo Molnar Cc: x86@kernel.org Signed-off-by: Ard Biesheuvel --- arch/Kconfig | 10 ++++++++++ arch/arm64/Kconfig | 1 + arch/powerpc/Kconfig | 1 + arch/x86/Kconfig | 1 + 4 files changed, 13 insertions(+) -- 2.15.1 diff --git a/arch/Kconfig b/arch/Kconfig index 76c0b54443b1..4e624f75823a 100644 --- a/arch/Kconfig +++ b/arch/Kconfig @@ -975,4 +975,14 @@ config REFCOUNT_FULL against various use-after-free conditions that can be used in security flaw exploits. +config HAVE_ARCH_PREL32_RELOCATIONS + bool + help + May be selected by an architecture if it supports place-relative + 32-bit relocations, both in the toolchain and in the module loader, + in which case relative references can be used in special sections + for PCI fixup, initcalls etc which are only half the size on 64 bit + architectures, and don't require runtime relocation on relocatable + kernels. + source "kernel/gcov/Kconfig" diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index 7381eeb7ef8e..7c543667703e 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -91,6 +91,7 @@ config ARM64 select HAVE_ARCH_KGDB select HAVE_ARCH_MMAP_RND_BITS select HAVE_ARCH_MMAP_RND_COMPAT_BITS if COMPAT + select HAVE_ARCH_PREL32_RELOCATIONS select HAVE_ARCH_SECCOMP_FILTER select HAVE_ARCH_THREAD_STRUCT_WHITELIST select HAVE_ARCH_TRACEHOOK diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig index 73ce5dd07642..21d5ad1608d8 100644 --- a/arch/powerpc/Kconfig +++ b/arch/powerpc/Kconfig @@ -181,6 +181,7 @@ config PPC select HAVE_ARCH_KGDB select HAVE_ARCH_MMAP_RND_BITS select HAVE_ARCH_MMAP_RND_COMPAT_BITS if COMPAT + select HAVE_ARCH_PREL32_RELOCATIONS select HAVE_ARCH_SECCOMP_FILTER select HAVE_ARCH_TRACEHOOK select HAVE_CBPF_JIT if !PPC64 diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index c1236b187824..1c6e2ddd2fdc 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -117,6 +117,7 @@ config X86 select HAVE_ARCH_MMAP_RND_BITS if MMU select HAVE_ARCH_MMAP_RND_COMPAT_BITS if MMU && COMPAT select HAVE_ARCH_COMPAT_MMAP_BASES if MMU && COMPAT + select HAVE_ARCH_PREL32_RELOCATIONS select HAVE_ARCH_SECCOMP_FILTER select HAVE_ARCH_THREAD_STRUCT_WHITELIST select HAVE_ARCH_TRACEHOOK