From patchwork Wed Dec 27 08:50:26 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 122766 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp1921167qgn; Wed, 27 Dec 2017 00:52:53 -0800 (PST) X-Google-Smtp-Source: ACJfBoveFk2q5067bOFdsHK9S/1/GXV9eYo5eSMiZ58M1Olc2AYT0lFvoyqTtCBSGL505iEKWCBl X-Received: by 10.98.35.144 with SMTP id q16mr27743145pfj.13.1514364773659; Wed, 27 Dec 2017 00:52:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1514364773; cv=none; d=google.com; s=arc-20160816; b=J/H03gYB3J8wH3snZ1IGz6W0l/PuTFQmvCCPjprKp3/N8R0maPKVYTHNTZj2zBVvJf Be9GAtVxAQk2KXDvhZzyi1/DZzL1sAFJ2oF7U42OVPWTcp3vw9r4/bsGNunhVELY+VZm FjFozRf7el0o8oeGcNZjBeggjjBSSySryqIjjgYa/Lbazn6g2gJwyBIm0W5MKVktxw2G e1qHttSUIgBwjq9gCBsBoU3mlDKW8qbe3bPJvXT0PhFoJQ2fxqvjr5+Qw20WjcWYcijT sTe1GK16xfPdfLlVNKLYqyYiKyckgQmvU0tzgNum+E31WPebkUTACcVsNv4j/tty38yS pGEQ== 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=zo6FJeZHHB60QMyYP5etywOU+iX+rmZoy5ptOi3AMzBHFSaXkUFZTueJsAIBtYIGi8 Dj4pw3f1u2JuCx+WBY8hGrUbA1Vn7lmG92gdh0lRginzcsCwMz9RPeU35Iynp4SXIdz5 tCZ4YWHTeWVMchT+vf2EvEC2GY/2GIi4LEQYB+fWTnY+ha/QSpsmRPA+vyghgHbFhwsx 38ePem4DdL89dyYqPfwyqIsKs22gXmmKps0JsSfB1Klt9v1h+Ajeb1DGEdFujFgJW4lO LxEcvitPaxG4aPINgra8ZNDALbZ8c0QjgUQE7SW917jipi/tguK4X+msc+2ou8i2gDvY Lceg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=RVum98bZ; 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 f5si4750157pgn.653.2017.12.27.00.52.53; Wed, 27 Dec 2017 00:52:53 -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=RVum98bZ; 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 S1751798AbdL0IvA (ORCPT + 28 others); Wed, 27 Dec 2017 03:51:00 -0500 Received: from mail-wr0-f195.google.com ([209.85.128.195]:40638 "EHLO mail-wr0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751426AbdL0Iuy (ORCPT ); Wed, 27 Dec 2017 03:50:54 -0500 Received: by mail-wr0-f195.google.com with SMTP id p17so12481764wre.7 for ; Wed, 27 Dec 2017 00:50:53 -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=RVum98bZoyQ3h4KK/u30IZ0+svrbkkfzw05MN0fWbBwGf2z0TtCwCLZXsmRTSK2oN9 ibrUYYLKxYBMNZ1xp76hh3n7X2+06M02o2pUswQgzgXY4Y8HhgqogNZjLjmrhYgIX3Sp HJgH8YIhuAmiRCU5ACk0UdxtyspUl40Szk//8= 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=FWoOc3JqoZPPlOQMlzbUTJ5YAz6a1CxgfjP2N3H/kqCo0MQ5gT5ZXB1RGIcCeXzGis nJhMn4Xuyu/6mPBlzdjc9oAT3n26uHvzJ2tl7W7LIOGOKQdHLHeMuujhs03RQfoCb0qA O7NN7Sq46bVfZ+zIRIkZ28Rz5xscCjxYuNbVWrpRcuJ89JhnmEnTCe9oG2VMNpoXeRXf kovD9VvPwYZHram2juEVLiRn22533xMcakiluXg606uzOo5NxlSzNk+NOAuDR0MEKqCB Q32ParBNI1c8XUfBqWM/D6Rwp7q+B3mNKmpIObT+QGOSTNXU0ICCcRr1ZOPWEsEUMJRj 3oiA== X-Gm-Message-State: AKGB3mIFeCLJiCjFhS6wXe/idyKGzH0GxYUD9zpyXDod4LfDvBnQF8Al OG1VtxGzAZlK9k3iIume1FEWLh54K+E= X-Received: by 10.223.169.8 with SMTP id u8mr29546944wrc.232.1514364652850; Wed, 27 Dec 2017 00:50:52 -0800 (PST) Received: from localhost.localdomain ([105.137.110.132]) by smtp.gmail.com with ESMTPSA id q74sm32677226wmg.22.2017.12.27.00.50.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 27 Dec 2017 00:50:52 -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 v6 1/8] arch: enable relative relocations for arm64, power, x86, s390 and x86 Date: Wed, 27 Dec 2017 08:50:26 +0000 Message-Id: <20171227085033.22389-2-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171227085033.22389-1-ard.biesheuvel@linaro.org> References: <20171227085033.22389-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