From patchwork Fri Aug 18 11:26:19 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 110372 Delivered-To: patch@linaro.org Received: by 10.140.95.78 with SMTP id h72csp780323qge; Fri, 18 Aug 2017 04:26:55 -0700 (PDT) X-Received: by 10.98.16.14 with SMTP id y14mr8651140pfi.64.1503055615097; Fri, 18 Aug 2017 04:26:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1503055615; cv=none; d=google.com; s=arc-20160816; b=ZaHAHESR05YT4J4wpUn8ouhI46OheuxUEj1To/y/YxTl6GFsfsVXqVErFmZ0SxV1xT Y8nRDnJns8ySQTqDiB+7Ww7ata4baPLKrX+0H9xLI3uM2AAMUKJNicGj6Gx1M4NpOekp vuWiv2uzn9OJYB27Nk/pIOfUlhdRIfpirWLPBBKwE5t4/7cALZbt6PNtEk/MdVh6lvf6 WQpdQGufNZPJLp2qTCn7NkBjGCIFlj6+p5UgD6Wes3wX3kMoJvkyFgVq2+l8SIcYaIWK DwkKzWkz5oshVHKF+szyFlnJPr87nAbkc5O5VfKCGdyx6ZVdpySR5NI01Ck4vlV4I7xp 0iow== 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=WpAB7m7CyEA9tmJ5QoBPu6wS8zGT6hzTjbT0E6oPCtY=; b=Qrqv22ZEcg0yub9/8R1l9QoRrR2Nra85QO61iHX8XDa+XR3E5DNM8h5VJCPUFwfMoQ tDodUgHr7EBYWmgrJhSsHklUy67uFu91my4Iky6gnrM2RgWUxSQdc4aEl1pCnzzeaOe1 UX21tIbs9iz94xgoQCmuTtKO1/oEOMhx3LidSDxIKistczpkgm2K0+081K8o4/qEp9XT afbeaj9jgRhzfCf4T8OIq6qFp0baQpIcBSvauCUVl9H9OQRwLF1BUv0nMaNgLTdC/7JT Ip51i3McjP3PQ/1ymsvlrMz+Tlc5iJyVO5DXfMfQ2y9gkeJF0TSOhFHL5pNHEsxbEnwZ 1bZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=M7YV+VPL; 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 o4si3189095pgq.683.2017.08.18.04.26.54; Fri, 18 Aug 2017 04:26:55 -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=M7YV+VPL; 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 S1751693AbdHRL0v (ORCPT + 26 others); Fri, 18 Aug 2017 07:26:51 -0400 Received: from mail-wr0-f174.google.com ([209.85.128.174]:33207 "EHLO mail-wr0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751045AbdHRL0s (ORCPT ); Fri, 18 Aug 2017 07:26:48 -0400 Received: by mail-wr0-f174.google.com with SMTP id b65so67580745wrd.0 for ; Fri, 18 Aug 2017 04:26:47 -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=WpAB7m7CyEA9tmJ5QoBPu6wS8zGT6hzTjbT0E6oPCtY=; b=M7YV+VPLf+2zy4rnn9XewPaAcF16bB9bQqgdD/i3nwC7O5G5dtOixfEz4nH0TlOkU9 u2o5qI7xdWyilAWVxgFGRFg3jReCh+bN2t8xZisGNWewgmq8Nrj7bSmWyP2ggNoo1kR1 sOOTP0WNlCOTD5AS+FGtWOGGmHhA/pKxeFgsU= 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=WpAB7m7CyEA9tmJ5QoBPu6wS8zGT6hzTjbT0E6oPCtY=; b=t/Ckle/5QY0PvrI8uZYRF7KfHYk4+oJ+aJ6eQMRrDr7U7m8OEcpbtZGjtmM2GQyVNe jOdS9d9weVCFvGT+Q1QqUdnj7CXENKDvEpT3lwm/fsSMaluK9gF1f9wI4bF2xHWa7crz 43PAg1q6c/v4PVmcuIQCMnzeIePsXDIcRnX/EorB5nS4lIWdb6A+vYTY1juafFV5Uuaj jFwGoBbOpSZhJZNgJ5mHe6ZpwdSsm7BtgnCOZ9ajK3BjiRahxkV++8MXzFMLwZ7ZxR2G 3tTyRS4/7Y8t1SYqv7WfFBJP4cxBd6/go8MzHOLUN8i4OeJ9jb84vbsgWQaDAF0HHXtN dFqA== X-Gm-Message-State: AHYfb5hW8dHIfMTzOQoq5LbM3TTjApy36GvAx3JN4WxQTksYIjC6+/1w 038Al89hb1WTpmAOEHvj9Q== X-Received: by 10.28.232.221 with SMTP id f90mr797259wmi.40.1503055606993; Fri, 18 Aug 2017 04:26:46 -0700 (PDT) Received: from localhost.localdomain ([154.146.161.128]) by smtp.gmail.com with ESMTPSA id f4sm1047111wmh.28.2017.08.18.04.26.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 18 Aug 2017 04:26:46 -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 , Joe Perches , Nicolas Pitre , Steven Rostedt , Martin Schwidefsky , Sergey Senozhatsky , Linus Torvalds , Andy Whitcroft , Jessica Yu , x86@kernel.org Subject: [PATCH v2 1/6] arch: enable relative relocations for arm64, power, x86, s390 and x86 Date: Fri, 18 Aug 2017 12:26:19 +0100 Message-Id: <20170818112624.24991-2-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170818112624.24991-1-ard.biesheuvel@linaro.org> References: <20170818112624.24991-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: Martin Schwidefsky Cc: Heiko Carstens Cc: Thomas Gleixner Cc: Ingo Molnar Cc: "H. Peter Anvin" Cc: x86@kernel.org Signed-off-by: Ard Biesheuvel --- 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 + 6 files changed, 15 insertions(+), 1 deletion(-) -- 2.11.0 diff --git a/arch/Kconfig b/arch/Kconfig index 21d0089117fe..4e77d8e8697e 100644 --- a/arch/Kconfig +++ b/arch/Kconfig @@ -940,4 +940,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 dfd908630631..ce05d2d8143e 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -72,6 +72,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_TRACEHOOK select HAVE_ARCH_TRANSPARENT_HUGEPAGE diff --git a/arch/arm64/kernel/vmlinux.lds.S b/arch/arm64/kernel/vmlinux.lds.S index 987a00ee446c..b6d8e6504896 100644 --- a/arch/arm64/kernel/vmlinux.lds.S +++ b/arch/arm64/kernel/vmlinux.lds.S @@ -171,7 +171,7 @@ SECTIONS CON_INITCALL SECURITY_INITCALL INIT_RAM_FS - *(.init.rodata.* .init.bss) /* from the EFI stub */ + *(.init.rodata.* .init.bss .init.discard.*) /* EFI stub */ } .exit.data : { ARM_EXIT_KEEP(EXIT_DATA) diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig index 36f858c37ca7..f7e60ed5bdd0 100644 --- a/arch/powerpc/Kconfig +++ b/arch/powerpc/Kconfig @@ -163,6 +163,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 ARCH_HAS_STRICT_KERNEL_RWX if (PPC_BOOK3S_64 && !RELOCATABLE && !HIBERNATION) diff --git a/arch/s390/Kconfig b/arch/s390/Kconfig index 7eeb75d758c1..1206cc7daa0d 100644 --- a/arch/s390/Kconfig +++ b/arch/s390/Kconfig @@ -127,6 +127,7 @@ config S390 select HAVE_ARCH_AUDITSYSCALL select HAVE_ARCH_JUMP_LABEL select CPU_NO_EFFICIENT_FFS if !HAVE_MARCH_Z9_109_FEATURES + select HAVE_ARCH_PREL32_RELOCATIONS select HAVE_ARCH_SECCOMP_FILTER select HAVE_ARCH_SOFT_DIRTY select HAVE_ARCH_TRACEHOOK diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index 781521b7cf9e..77246125883e 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -112,6 +112,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_TRACEHOOK select HAVE_ARCH_TRANSPARENT_HUGEPAGE