From patchwork Wed Jul 4 08:36:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 10506195 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 7084960325 for ; Wed, 4 Jul 2018 08:53:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5892D28D40 for ; Wed, 4 Jul 2018 08:53:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4C6EF28D43; Wed, 4 Jul 2018 08:53:12 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id D6EB128D40 for ; Wed, 4 Jul 2018 08:53:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=eE0Dx9ch9VLkabDfqCMsjCFvOi+BxtSLr9r5beNBt54=; b=GytzSCcRMFwTwzvn8W+GgONWta 5XHu9g2Jrm8PkoGxjVLj49GRMVXiRFXFy6j3zCg7MojBvXjDOPj5NDzIvgk2JYaRL+SXlkhF6TIz7 cGEdn74iKcrLuobROCMozxPCy2GDlNYuhcZbZua+W0m2hUTv+Z/QPMS5HwkAdfKdYHRsRw4BBXx5c Xt646WfFmUf1je+eohMTi8QMeNTA6O26X0l0+ZrSD2Ec+v0zs0qdVEEbZK+qzvARZHMNyhdRfAX8Z SPKgvuaxGVah2RNN77OkGaxSq3sz+MGRTCGNCSYBa+8KXPjyb5Nb+gt03b9p1ke/EoIK+gtQMRaYx ikf+8XLw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fadX5-0008Ck-NO; Wed, 04 Jul 2018 08:53:03 +0000 Received: from mail-ed1-x542.google.com ([2a00:1450:4864:20::542]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fadJT-00077O-I8 for linux-arm-kernel@lists.infradead.org; Wed, 04 Jul 2018 08:39:07 +0000 Received: by mail-ed1-x542.google.com with SMTP id d3-v6so3477373edi.1 for ; Wed, 04 Jul 2018 01:38:49 -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=FvlJovxgJJ+QheLrbv7UTmXIJsBE8E1kyVYaaE1/yZw=; b=SRshl8rhluInJKzqhBxvquTse209GvHLTUrF9aCGlZ6nEHaH1VTiPTbYPXUcbCb+a+ CanuIV+YSPI9fQGaPxCA6y/sZ6A2bNAuuBf8kf+E/rTCjsu7IFInTnKFhmb5fWDdU8AV CMe2EYDfFpFvPQAAN1eCohJQFn7LthzXTVMpY= 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=FvlJovxgJJ+QheLrbv7UTmXIJsBE8E1kyVYaaE1/yZw=; b=bxG1ZhwP8UKqR1ImgRONas5M2QWCIRTDemaG/ISaAWJXu4WY2Z1WOjPmb83wPGMWHl 5cZNv31BgEa/h0Fqp4d90Ss5fMI0KqUA3oK3uJnE00yZq9YI6LsPttngiXpCKWNzB3Ok TtJsHuwO650B0XgCzrKqbHp/FxmqsydfroF4Jz1ymRPQA+TdCKuoFZ/KBEAjJSdyOTtS 3JPgqZ4Vtaf28xgT1ZwvqGilDhxLDN6jOdQEJNVLOOuZ354fNLdYy30+yybFigyeRUCa wgDOByuyXOVbspepe45/4peO7xEHrknU4zyDlPeG/L8s4atm9K6rdnp/erCJrSpgY6e6 BRBA== X-Gm-Message-State: APt69E233UCYPLZa4ceL7/5KWPgpYp1L0H0nb9+qCa+ypodaoO+5aSao FQ5hJaWyn7H58d7MH2EUK2/asg== X-Google-Smtp-Source: AAOMgpefmYphpRfS1iyARbegXECgWnzgz/vzo3BVRM73RgbJqNT8saXU2kyDa0nxqB36ShjrFYp07g== X-Received: by 2002:a50:d9c7:: with SMTP id x7-v6mr1722213edj.95.1530693527904; Wed, 04 Jul 2018 01:38:47 -0700 (PDT) Received: from ards-mac-mini.arnhem.chello.nl (dhcp-077-251-017-237.chello.nl. [77.251.17.237]) by smtp.gmail.com with ESMTPSA id k13-v6sm1821740edj.55.2018.07.04.01.38.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 04 Jul 2018 01:38:47 -0700 (PDT) From: Ard Biesheuvel To: linux-kernel@vger.kernel.org Subject: [PATCH v10 1/6] arch: enable relative relocations for arm64, power and x86 Date: Wed, 4 Jul 2018 10:36:46 +0200 Message-Id: <20180704083651.24360-2-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180704083651.24360-1-ard.biesheuvel@linaro.org> References: <20180704083651.24360-1-ard.biesheuvel@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180704_013859_673640_76196A89 X-CRM114-Status: GOOD ( 12.90 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Catalin Marinas , Will Deacon , James Morris , Paul Mackerras , Nicolas Pitre , Michael Ellerman , x86@kernel.org, Russell King , Ingo Molnar , Benjamin Herrenschmidt , "Serge E. Hallyn" , Petr Mladek , Kees Cook , Arnd Bergmann , Steven Rostedt , Josh Poimboeuf , Bjorn Helgaas , Thomas Gleixner , linux-arm-kernel@lists.infradead.org, Ard Biesheuvel , linuxppc-dev@lists.ozlabs.org, Sergey Senozhatsky , Jessica Yu , Andrew Morton , Linus Torvalds , Thomas Garnier MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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. Acked-by: Michael Ellerman Reviewed-by: Will Deacon Acked-by: Ingo Molnar 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(+) diff --git a/arch/Kconfig b/arch/Kconfig index 1aa59063f1fd..2b8b70820002 100644 --- a/arch/Kconfig +++ b/arch/Kconfig @@ -971,4 +971,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 42c090cf0292..1940c6405d04 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -95,6 +95,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 9f2b75fe2c2d..e4fe19789b8b 100644 --- a/arch/powerpc/Kconfig +++ b/arch/powerpc/Kconfig @@ -177,6 +177,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 f1dbb4ee19d7..e10a3542db7e 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -123,6 +123,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