From patchwork Tue Jun 26 18:27:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 10489997 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 799BD60386 for ; Tue, 26 Jun 2018 18:29:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6CAA4285CE for ; Tue, 26 Jun 2018 18:29:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5F3C1285D5; Tue, 26 Jun 2018 18:29:09 +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 026CE285CE for ; Tue, 26 Jun 2018 18:29:08 +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=Cc1ZahUJRVf/zHZnDRVuWligVeSmoWVpC0gwE6yoDGI=; b=gMwE+OKCU1O0+vkfyIFhG78+bD 8y2OCOA+qxzbOg2qRIaZuaER6DNCUdFUO00USB34siUrUlv5q/gEuZ8zqxLr+FiLW+uc4a4bHmqjy OifBM8KtqChtMElRNJKkrXD/VFdagZ0qlQcw+sclbG1dm83lGE32Q15NPyZPpTO+Je5MrbXR9UZOs JVgWgqyUsljVPpU9scZJsak5Os+Kc7xgMhsyiFIvonB09+ftCjaGVtOVt9oDmIaWkGKl5Xih/gz3e x1SV+gdsL6aV5Ue09uqDJ5U6gAVn93FCGT2I8ySEgjDFyYLqRyjFBAkNtIb7Gb043da8rKUKCymMf sOCCZb0g==; 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 1fXsi2-00075h-6g; Tue, 26 Jun 2018 18:28:58 +0000 Received: from mail-wr0-x241.google.com ([2a00:1450:400c:c0c::241]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fXshw-00072s-PU for linux-arm-kernel@lists.infradead.org; Tue, 26 Jun 2018 18:28:54 +0000 Received: by mail-wr0-x241.google.com with SMTP id c5-v6so7056648wrs.10 for ; Tue, 26 Jun 2018 11:28:43 -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=7Pl3hl9dlr/wJP2mnaTAtaT54uoquJiV2t4p4cdOAyg=; b=Q2SuMHmpWc0SFvLy6xXOjfHRMrRsAwFPYNhXwbVsiRG/mDtWiE26DFzdPw657vIUoe CI/gMks+q6ug0i6zfBiWFiiMjsSnnDHmWEh2IFpjvpHAMiLbAOPKwUpMP6oy5HYP6ohH NLRjX3Btm+gWIrQ3cUm9F7iD7Form2lxGBOCI= 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=7Pl3hl9dlr/wJP2mnaTAtaT54uoquJiV2t4p4cdOAyg=; b=FSGxwz0aehOrjE9ynqccxwCSYSWQ8Hr1WfcYiYUlKfI6AST37r2Sd075g4vuuJs2KM AAAp9juCA1d1cPFk8fbKV60Jl5IeXj8fjX9FvLRHYyXIqzLgACF+mzyUgGiwRkG0QLX8 1KIg3nN6Re2WE8AEWjmZlFjcz+nmX65ah27Q7EjuxPzlUyQtRuv1zshL4TZdPHFF3Vb5 ssr2iDUQahjmmqgy6ff1RoYE2a7rhW746s2QzHPYIYKlh2Mw9crkoSOOHzH6E8BwQwLV N1cfg4cCjSjrRIMGHj3iSfBHSUgBsq7w4gyYLy3OHc2No4swie1XqEedLPh3DBwAfFP1 9FSA== X-Gm-Message-State: APt69E2u5ZKyttMEGSWWpcMLG8MC0UO8bS0LNAKemff1IADJDuQXBo6F yYkVksSzwxXAMzI3B8Oo6n19cw== X-Google-Smtp-Source: AAOMgpdp8md12H8lKmG+/g2bfIeTGUEZ5vKZNFc6DOZe0mNzs6xXc9uD89wKFdEr5cBtUmZ7zsgecA== X-Received: by 2002:adf:afd3:: with SMTP id y19-v6mr2601535wrd.176.1530037722557; Tue, 26 Jun 2018 11:28:42 -0700 (PDT) Received: from rev02.home ([2a01:cb1d:112:6f00:d037:e907:f0a2:a5ea]) by smtp.gmail.com with ESMTPSA id s17-v6sm1707664wmc.34.2018.06.26.11.28.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 26 Jun 2018 11:28:41 -0700 (PDT) From: Ard Biesheuvel To: linux-kernel@vger.kernel.org Subject: [PATCH v9 1/6] arch: enable relative relocations for arm64, power and x86 Date: Tue, 26 Jun 2018 20:27:56 +0200 Message-Id: <20180626182802.19932-2-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180626182802.19932-1-ard.biesheuvel@linaro.org> References: <20180626182802.19932-1-ard.biesheuvel@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180626_112852_850467_C6C043AC X-CRM114-Status: GOOD ( 13.34 ) 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. 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(+) 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