From patchwork Mon Aug 14 10:52:27 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 109977 Delivered-To: patch@linaro.org Received: by 10.140.95.78 with SMTP id h72csp4170445qge; Mon, 14 Aug 2017 03:53:12 -0700 (PDT) X-Received: by 10.84.169.3 with SMTP id g3mr26970022plb.136.1502707992710; Mon, 14 Aug 2017 03:53:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1502707992; cv=none; d=google.com; s=arc-20160816; b=iKONShAlC27w5z2ru2ytDQdf8dEoBaXChPgmPx5hU14VNdK3nZBf10OERv7mVa5qF1 99rkdVMWrpok13r7scgd/PCK0e/9zURDJHWPtcrgtxW+V4sP8l/9vEY2+Gq7L5tfcE/w VtiTKfA7eWneKiozC2xP1JEWm2KCqL9eNpLA1YuSA24PHif/+sw4vKGSN8Puo7z64pna zbpGeNNqmrzH8aL7GwvWrfDs5CGo30m8Y8CXe62v4O3diRVOdsHkfzqH0eK0WKELAH13 2p2byKJfXkq+KZ52qRQFjcoch3YGYVoT5nGGd1jYgi9tMja3v/A9u6u6n8kwhC9WsLTS ucMA== 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=E6kGreoUgUe/D9Eg3bcGirQ1NSKJ8qaYFFtGJuuuVEk=; b=BgDb6fqGsT97LVbumIXMK/3mdiapwtQDIoWMDjYLnIsD05LpT5ZWH2GLcxqJPjQvJW qY9BfHQH7n1MtjGJFgMGfeVRihgzw58Xg8yv+Lyef73NjZ29fwy2G814QGCXLoEwN8/c D1CcPlggSh4WbyL0bvP05L9Avmq2hY1qDtWbvq55Tkl7aQCcF3TCsU+ZqvRpJFG9Slfx B2SdIURfJ9scFq/4VaKgxcd0XP/Jam5/MZdUv0sqiYZ0HdPh8prZW9qNS7ACL0AHFv/y nRRva3VtEenBbSwyS8GW4VhV0oJUSpKnee0qRHTdkK5kvMJTIzDNJuQkJglLqkFQvcjU Y9VQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=AJdphfGg; 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 68si4514463ple.590.2017.08.14.03.53.12; Mon, 14 Aug 2017 03:53:12 -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=AJdphfGg; 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 S1752955AbdHNKxJ (ORCPT + 25 others); Mon, 14 Aug 2017 06:53:09 -0400 Received: from mail-wr0-f178.google.com ([209.85.128.178]:37057 "EHLO mail-wr0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752830AbdHNKxE (ORCPT ); Mon, 14 Aug 2017 06:53:04 -0400 Received: by mail-wr0-f178.google.com with SMTP id 33so33154037wrz.4 for ; Mon, 14 Aug 2017 03:53:03 -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=E6kGreoUgUe/D9Eg3bcGirQ1NSKJ8qaYFFtGJuuuVEk=; b=AJdphfGgN2qnullWPSPCBmAhdYqv+yELndCWi4y3jOaqDgb5t4six3fthdGHLwggQh St05w38t/xpcDF41RVqxe0v+pt4IFfiOUdXfmkw9f0QHf2GdG7GqQpglT5bZJCweUXh3 akcV7xdrbj5qGyz4QD9QUbt1ELd6lhMqpQrnQ= 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=E6kGreoUgUe/D9Eg3bcGirQ1NSKJ8qaYFFtGJuuuVEk=; b=RhMxBt4i/gjay77zmwCUugnwQniRYdtTW/xbcAWjMzvxqnfKPDd6HMkn4aa2Iifqn8 PDbqH0SuvhrwaGcIRpDWh/KiiMBoFMNaNyFl8SltHM7dvc5YqgUnbYHqm68vGg5MVvi5 78A7BzvzDuBIALLM4Yg5rgRkAy4OHL3BY33xrDOZt9WKrHo7tKUuBdpH+fja7dlUfkn7 pd3UDVvWEoTcbTGNJzIRu85r2z6kayCRx0WDsTmMl/pZotNwh9csuG+h8YbHVQpaXh8d 7p+FMcGLKbPCaKVZe+sW4bfUjoeyLvX3xfcQW8n8x3bsD83GyVLJgvBqW79IaIsyyte6 9kWA== X-Gm-Message-State: AHYfb5gev5sLEHEF9BEXyFKUbevRMQwkTPthIZROiyhRX2fSE9MC3jom IlyIkTwsiRULMl/crmISAA== X-Received: by 10.223.181.10 with SMTP id a10mr18404032wrd.239.1502707982882; Mon, 14 Aug 2017 03:53:02 -0700 (PDT) Received: from localhost.localdomain ([154.146.161.128]) by smtp.gmail.com with ESMTPSA id b15sm1490732wra.68.2017.08.14.03.52.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 14 Aug 2017 03:53:02 -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 , Jessica Yu , x86@kernel.org Subject: [PATCH 1/5] arch: enable relative relocations for arm64, power, x86, s390 and x86 Date: Mon, 14 Aug 2017 11:52:27 +0100 Message-Id: <20170814105231.14608-2-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170814105231.14608-1-ard.biesheuvel@linaro.org> References: <20170814105231.14608-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 a new 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..5849bd4e2b06 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.*) /* from the 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