From patchwork Mon Dec 25 20:54:33 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 122701 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp225806qgn; Mon, 25 Dec 2017 12:55:46 -0800 (PST) X-Google-Smtp-Source: ACJfBouQ3HJ7SlTMZF4W4tW5ZpHGZFgd5yRnYJ1MOtFn3CMB3ixIGBM4A7ddN+1s7dbxdo6A2OpT X-Received: by 10.84.218.72 with SMTP id f8mr24053701plm.143.1514235346900; Mon, 25 Dec 2017 12:55:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1514235346; cv=none; d=google.com; s=arc-20160816; b=Avk8vNZWhhtxlYN9xHNz2e9N6RbRsENMvwO3WivcbZ5O1CO5LFyd03Ci4UZ3fNRgdE 86OqvOvzwDmLQikek2hATTZLjDpbNMjoQWnt0Z+x/w1cHUeBZF8INMDs0yDY/e95AWFD M0w+ggE0dmJ09WSm5y3c3vMOZxy/9QipOixr3lO4QbCe5sFvP7dd4Z+bF5KO+q2ZaqDo 7lgNh4GAeMNtIm102b6WIASTS2OB6O+43QTqt2G8N5pdaqQ8UD6fatyHo1PxB6Jqszjz XyphacCHy/M/kvoHMOHH+TuCGcfsZUi2XMqrYb2/Vuq3/Q8BG1sxgx42uSlNG/5cQw4+ nzAg== 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=hET4AABNBeNsSpkOZUI8roSkdCikZPdlup845D/iO+8=; b=lO5+Oebkz5gswdaqKs6p/cE94jC2pITemsqBtPAuWmjAjKEvc3rpvfbackFQXVcGdG JhoBwULKbw6GxVqISK4R9WlMF8ZT3wklQNTR0SZalK6KKBa9xJYi/hsBuipmFUTifoXM dPCtHg86emuGbdrN6kXD13YBNpLaazUaBqDqT4C1tbduumVhD0ntpdagABxU9MiyVET2 XalhGnKa80C32ZoAzl3Kb/hnwZh2JAyJ2MI3jqCzoQAaxL3ADdIdLcQheMMb/LxP5IeO Bgw9pR75NrqQyYf2yS3GwXl8FL2608ESHYxbZ1xlJdxxcN/N4q+WX+sgCpZbVuhZ7tps 95xQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=MUa6lfj1; 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 d12si21505668plo.388.2017.12.25.12.55.46; Mon, 25 Dec 2017 12:55:46 -0800 (PST) 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=MUa6lfj1; 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 S1753206AbdLYUz2 (ORCPT + 28 others); Mon, 25 Dec 2017 15:55:28 -0500 Received: from mail-wr0-f195.google.com ([209.85.128.195]:38452 "EHLO mail-wr0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753144AbdLYUzS (ORCPT ); Mon, 25 Dec 2017 15:55:18 -0500 Received: by mail-wr0-f195.google.com with SMTP id o2so33421660wro.5 for ; Mon, 25 Dec 2017 12:55:18 -0800 (PST) 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=hET4AABNBeNsSpkOZUI8roSkdCikZPdlup845D/iO+8=; b=MUa6lfj1xmy9NUHTWfgLTx9dIhxXCvBfTiW6vaCxnjzQr9QQ4phDFsNkedXUMJ1IBb OF5hdF2K5BhlWykOs1Kln5hjij+9prS1y/WjcxJznYcJvtNPTi1PekFCuaFsCI9uWaC5 Fv+tC4vkFl4/kP7Uw/nGUMmDM7mVZWK7fTOz8= 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=hET4AABNBeNsSpkOZUI8roSkdCikZPdlup845D/iO+8=; b=jLtFGNkihW/oqq+n5/HiHLdFtV7ER+Jl3kYpD5RMQ5ElxaHVBNY/vGyvMXYBqPn20P /j2pSggvbZzjtyCx19zEw6uLKSugZfZw1z07L80s+2An5Nvast1alE12vH9bT8H7cOKv t/YPLeXDhuNroVajMA38xYqp4pYR9qUGlSsQ1aoqTrYBVnqpK6zwxY3eZIGGP3/SJp76 T/4zAnvEA54ky1HuGsbtPNTAhZdpSGZbC0Fe/xKncIIgQdx+ZWQKte3vBhspPumQNh6o 0ZHppwhCJx8KkHQ7vm1vV6mXr7eUW8j4PMn0aC3ZiL7OBc59m1OTfX4DrmtVpQnf5jOC U7RQ== X-Gm-Message-State: AKGB3mIxwoKnXYsQAeOjUfpNpM3q5xee7U09mnng/GVDh66FYQgn2Ggx OObLx102m0eJ/nt4Bk5pPaj0A2cGwZs= X-Received: by 10.223.175.50 with SMTP id z47mr23740531wrc.12.1514235317375; Mon, 25 Dec 2017 12:55:17 -0800 (PST) Received: from localhost.localdomain ([160.171.216.245]) by smtp.gmail.com with ESMTPSA id y42sm39552441wrc.96.2017.12.25.12.55.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 25 Dec 2017 12:55:16 -0800 (PST) From: Ard Biesheuvel To: linux-kernel@vger.kernel.org Cc: Ard Biesheuvel , "H. Peter Anvin" , Ralf Baechle , Arnd Bergmann , Heiko Carstens , Kees Cook , Will Deacon , Michael Ellerman , Thomas Garnier , Thomas Gleixner , "Serge E. Hallyn" , Bjorn Helgaas , Benjamin Herrenschmidt , Russell King , Paul Mackerras , Catalin Marinas , "David S. Miller" , Petr Mladek , Ingo Molnar , James Morris , Andrew Morton , Nicolas Pitre , Josh Poimboeuf , Steven Rostedt , Martin Schwidefsky , Sergey Senozhatsky , Linus Torvalds , Jessica Yu , linux-arm-kernel@lists.infradead.org, linux-mips@linux-mips.org, linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, sparclinux@vger.kernel.org, x86@kernel.org Subject: [PATCH v5 1/8] arch: enable relative relocations for arm64, power, x86, s390 and x86 Date: Mon, 25 Dec 2017 20:54:33 +0000 Message-Id: <20171225205440.14575-2-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171225205440.14575-1-ard.biesheuvel@linaro.org> References: <20171225205440.14575-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 400b9e1b2f27..dbc036a7bd1b 100644 --- a/arch/Kconfig +++ b/arch/Kconfig @@ -959,4 +959,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 c9a7e9e1414f..66c7b9ab2a3d 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -89,6 +89,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 7da3e5c366a0..49ae5b43fe2b 100644 --- a/arch/arm64/kernel/vmlinux.lds.S +++ b/arch/arm64/kernel/vmlinux.lds.S @@ -156,7 +156,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 c51e6ce42e7a..e172478e2ae7 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 ARCH_HAS_STRICT_KERNEL_RWX if ((PPC_BOOK3S_64 || PPC32) && !RELOCATABLE && !HIBERNATION) diff --git a/arch/s390/Kconfig b/arch/s390/Kconfig index 829c67986db7..ed29d1ebecd9 100644 --- a/arch/s390/Kconfig +++ b/arch/s390/Kconfig @@ -129,6 +129,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 d4fc98c50378..9f2bb853aedb 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -115,6 +115,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