From patchwork Sat Aug 19 18:10:31 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 110456 Delivered-To: patch@linaro.org Received: by 10.140.95.78 with SMTP id h72csp2383628qge; Sat, 19 Aug 2017 11:11:08 -0700 (PDT) X-Received: by 10.84.132.78 with SMTP id 72mr13373121ple.66.1503166268112; Sat, 19 Aug 2017 11:11:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1503166268; cv=none; d=google.com; s=arc-20160816; b=O5it4+aiWbgptI/mu5CFE9rkKf5Fov9Zw5NtwwWPQOqfOnnEl6KxtWzEN4xaIy2fub a0wOeePvjtfL61/pmhQh2B5fp4BGgKP8imMPuTqvq5XHFb+bbNGSlHbIeeGget852fYJ uKy6udxahYgwA/GP4M39GckXp3gfZjAs2+7Vbrf/aJ9C0GPwwCASYcdpA2K2s4xJI/Ct W7cDX+m2Vx75e2hC0ZHksRQwPx18MtScPGj7VoieOXF+ecOQ6H6jJCYn1cfFR6hQyMfh zj4qIeyHSR0LYHVXumn0ZBn9JZ0YMNcsdsGBNxke8Mp/srOj40wlNwN2byYEUnbDtHqT lBdA== 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=zstPFYViazbVPpAGftTp0jqf4yw+2+sSrmiFUcXZmonePdwyB9QlwpOZ5cKGg1ozaZ e5x+7UgoxrA6KgUPyH6jmjgW2++52Jc7Kbeb4iLpsNCa2YVtzXI4MTSlNAYx0tB3MrR4 +23TIH6gg4Ld56z1+pFzv7Of+yz8ndKR9Gxt44Z0zwhwGqBxGca/YweM1zy2CKmg5lkc Phs+/mLL37WkcKgdsjlBTJ0PTgddg4WIWEuTg5S++yLDpIiOJePmhodU/R0+8Pk8UmkC LNXNF9moau6b2AWHRAkbS/yU0J6cy/UUCsfQS4kQ9HwycXSw3dirkIy53RQxhHReQVSa 0UGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KHnpfLpe; 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 c32si5548733plj.478.2017.08.19.11.11.07; Sat, 19 Aug 2017 11:11:08 -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=KHnpfLpe; 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 S1752195AbdHSSLG (ORCPT + 26 others); Sat, 19 Aug 2017 14:11:06 -0400 Received: from mail-wm0-f45.google.com ([74.125.82.45]:37031 "EHLO mail-wm0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751892AbdHSSLA (ORCPT ); Sat, 19 Aug 2017 14:11:00 -0400 Received: by mail-wm0-f45.google.com with SMTP id i66so20959564wmg.0 for ; Sat, 19 Aug 2017 11:10: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=WpAB7m7CyEA9tmJ5QoBPu6wS8zGT6hzTjbT0E6oPCtY=; b=KHnpfLpe+li4wU6mAvuc/r7y1YnZBd+96XAd0CmIHenutW3hWYusSo52UYQ2kUfDTl cqgJNMn/vFGCTT+hgrwaCNWcv8m0ZJJG0QMNYLt6jM/fkMKVjsKuHYGTu09+zn+A/KGX nQbIj/hGcrTBSITSaJ89gdgOAx+U/fD80Gg60= 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=oU59gWJBtc/CKRre8APTBAXpZImpZ1Z4P5hLSdkNRUuy9fWYGsrk8LXPLMcJcZPIhy LgNDFoWeQ617QOa6YajQ1hdGLm8hbb2Ye22wR60yEeOidpU5ACdf6yZ7AbkyVmaFOWNw S77CwumMBB1cH04E/25ffpUK7vULO6wdTKZQAiRvRxmLM0swqbvpg3IcqP33Mcn7aeL0 BMelU9H5UNyYpaNcIld3n07l3FYU40OdWygFpp+OjKe15e4wAaxYlRShAH4RaXyBcl/q FkisLGdCyxY7eDwIx+ukVctxXRhhUrnqQpJldCsp4yekZ63Ab4VqsMgTUC3gT6aR0wIx 07HQ== X-Gm-Message-State: AHYfb5hbz9xcao8RvFI6cqgQvzhgMpdZfLHQRyJtNfeSomygQUkmh2fx c6uahkIYBU8Yy+f7xM4ayA== X-Received: by 10.28.18.66 with SMTP id 63mr4064584wms.20.1503166258405; Sat, 19 Aug 2017 11:10:58 -0700 (PDT) Received: from localhost.localdomain ([154.146.161.128]) by smtp.gmail.com with ESMTPSA id m127sm4056261wmm.46.2017.08.19.11.10.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 19 Aug 2017 11:10:57 -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 , Nicolas Pitre , Steven Rostedt , Martin Schwidefsky , Sergey Senozhatsky , Linus Torvalds , Jessica Yu , x86@kernel.org Subject: [PATCH v3 1/5] arch: enable relative relocations for arm64, power, x86, s390 and x86 Date: Sat, 19 Aug 2017 19:10:31 +0100 Message-Id: <20170819181035.969-2-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170819181035.969-1-ard.biesheuvel@linaro.org> References: <20170819181035.969-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