From patchwork Mon Jun 18 15:06:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Salyzyn X-Patchwork-Id: 10472045 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id B00AD6032A for ; Mon, 18 Jun 2018 15:18:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9DD2128BC8 for ; Mon, 18 Jun 2018 15:18:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9249828BCF; Mon, 18 Jun 2018 15:18:15 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 90C5128BC8 for ; Mon, 18 Jun 2018 15:18:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=jtvl7OMNATK81hA9DDsdibjCWpw8zlH50aRGUec8n18=; b=dqjaj7dsPvhRBo/RjdDoayCKq6 TBZcKZWkDBidNR7A+Pd8hF8stcNDUg/4Q6bSj/oO1wMBUujSSzt8whbUMMjoCNhF1nNNNMSYBI5r5 J2d0daEVJII98lWt/E8XMBZcFirz6h6qMp5hWkO8eQ58M3Q8LwzY8OqzZhTHACgMLQ0KzK75vzJj/ RZHEYOzXCfbXID+BaZYEYmwNfK69oX7yfmP6wzTcHo5+RkIG1K92VBfcrsQxNannmJKnyPtoOtP6H ql7jX2w0Y8EXmli9/D5aBoUVAGfH9kiin1NXjQ9f+wHwwDT3LCrRrleHWe/DBitsnuM/arVItOs4M FMcsxaUw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fUvut-0008Ou-71; Mon, 18 Jun 2018 15:18:03 +0000 Received: from casper.infradead.org ([85.118.1.10]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fUvso-00074e-DJ for linux-arm-kernel@bombadil.infradead.org; Mon, 18 Jun 2018 15:15:54 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=2MXq3p35T1+4CmZV9awmDquunefUxpEpZhc9mjTgjHg=; b=MqVpZdE0KEHOWi2mfjuAwIyVS ou3Lrvj33kjG/Em/kbNeF+jlrW1NqCcffFTRV4haVLyVhU5eis8HrS2Sb8qxXiq8coOuyO2vpJiX8 /VOhzsYkQOk1hiN7uEKTEhn70LjgcbMPq/MY+waeYFgz5FJVadKvi16yQJOdB5qEEXJ6I77PFb0BA 7RtnpL2CYEgC9fWaY8FVL0hwphixUJyQD8auct1fwWI1Atba1R+U/y3QvDZeJAEcYIj1xngrZaH61 aZCuysioIKMArlgWqYD22tLQG4ZSsobjgDuxeOWSfpZQcLIgwUxjjCxo1+tPyYCa33nufbfaownwK yMcP9cCDw==; Received: from mail-pf0-x242.google.com ([2607:f8b0:400e:c00::242]) by casper.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fUvng-0006DV-W6 for linux-arm-kernel@lists.infradead.org; Mon, 18 Jun 2018 15:10:39 +0000 Received: by mail-pf0-x242.google.com with SMTP id z24-v6so8324072pfe.7 for ; Mon, 18 Jun 2018 08:10:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=android.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=2MXq3p35T1+4CmZV9awmDquunefUxpEpZhc9mjTgjHg=; b=Rxz7ecyK3t2LeWZnVKzMup8z76WwpnH7omJFTO4GqnNte7tsrLJJ4oCBjIn2xrP6qG 3K0Whwn97svdrejXBhbxIBg+LgXeqyX420F5j7tpwXYgL9+bWzYNZHJxiHG1bS+TY+Hw JOEayVhBXPH74fySXr/ES2jmBqOCvBogl2IfOFATI3gCBNTqrQoSzjKQcostI19093v4 dW4Q8CCeGSBf3uuCwuTTzfx+U9L2Y5kdEixgpZ2JsLPgwzpIFJugLgVupwQEJ58RjwrV Zuv8f64pMvJ6lrUNQQG0yLy/bxobUHOD2g9jIWCb2jYAhEAIVaVVnsxK5xJk9UezGOB3 vfkw== 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=2MXq3p35T1+4CmZV9awmDquunefUxpEpZhc9mjTgjHg=; b=qEoHBaMK0u1Y12RH2YdGg3bPZyiE/piaL5VabG/1/clbvEYo56HbZ5Za7C6y8iPGV2 M2C+3j5KUu5pcl1DYNvLzhbZW6eTSSm2Y/8VinkQ5zY3FVNnzQ3p8O46j0L10OAepgW1 em0dySK2qZdkfvDXw6vJnQzGrtHjqVRYdUEuPYfVarr8eM+VJ9HsmKG9WYnMPVhNSl5j JZbDbllG3yf+s8RZxn+ElvBf5ujQkc2VTbpjl6iwamX1TY6OZO8SOux+QGBTZ+jhojSl 0d//L0HFwBrmiJUo3w608pgTOFK9DI3QDB/Ict1+ZY+fdEwXygKK6PR+9/tlyWDoBd8I FTDQ== X-Gm-Message-State: APt69E108vXbVDLiKBgpRf5sCXUKx4Gu7PoyuEtMqUIxokHm2f/ezx2+ QAQpqbg0mB1NylFHq2/5oCS6+Q== X-Google-Smtp-Source: ADUXVKKYnhGtaxbDhkChbYe+74rPE0X8EiFBUZQgTKCnF3jiQf6y1BxRNhxs+lLRnqBrhy+56COiLw== X-Received: by 2002:a63:b543:: with SMTP id u3-v6mr11460602pgo.365.1529334625370; Mon, 18 Jun 2018 08:10:25 -0700 (PDT) Received: from nebulus.mtv.corp.google.com ([2620:0:1000:1611:6077:8eec:bc7e:d0f4]) by smtp.gmail.com with ESMTPSA id i7-v6sm54830660pfa.34.2018.06.18.08.10.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 18 Jun 2018 08:10:24 -0700 (PDT) From: Mark Salyzyn To: linux-kernel@vger.kernel.org Subject: RESEND [PATCH 6/6] arm64: Wire up and expose the new compat vDSO Date: Mon, 18 Jun 2018 08:06:09 -0700 Message-Id: <20180618150613.10322-24-salyzyn@android.com> X-Mailer: git-send-email 2.18.0.rc1.244.gcf134e6275-goog In-Reply-To: <20180618150613.10322-1-salyzyn@android.com> References: <20180618150613.10322-1-salyzyn@android.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180618_161037_022646_28E8A35A X-CRM114-Status: GOOD ( 29.82 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , Laura Abbott , Kees Cook , Ard Biesheuvel , Marc Zyngier , Catalin Marinas , Kevin Brodsky , Will Deacon , Russell King , Jeremy Linton , Mark Salyzyn , Masahiro Yamada , Greg Kroah-Hartman , James Morse , Andrew Pinski , Dmitry Safonov , Andy Gross , John Stultz , Thomas Gleixner , Andy Lutomirski , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Kevin Brodsky Expose the new compat vDSO via the COMPAT_VDSO config option. The option is not enabled in defconfig because we really need a 32-bit compiler this time, and we rely on the user to provide it themselves by setting CROSS_COMPILE_ARM32. Therefore enabling the option by default would make little sense, since the user must explicitly set a non-standard environment variable anyway. CONFIG_COMPAT_VDSO is not directly used in the code, because we want to ignore it (build as if it were not set) if the user didn't set CROSS_COMPILE_ARM32. If the variable has been set to a valid prefix, CONFIG_VDSO32 will be set; this is the option that the code and Makefiles test. For more flexibility, like CROSS_COMPILE, CROSS_COMPILE_ARM32 can also be set via CONFIG_CROSS_COMPILE_ARM32 (the environment variable overrides the config option, as expected). Signed-off-by: Kevin Brodsky Signed-off-by: Mark Salyzyn Cc: James Morse Cc: Russell King Cc: Catalin Marinas Cc: Will Deacon Cc: Andy Lutomirski Cc: Dmitry Safonov Cc: John Stultz Cc: Mark Rutland Cc: Laura Abbott Cc: Kees Cook Cc: Ard Biesheuvel Cc: Andy Gross Cc: Andrew Pinski Cc: Thomas Gleixner Cc: linux-kernel@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org Cc: Jeremy Linton --- arch/arm64/Kconfig | 24 ++++++++++++++++++++++++ arch/arm64/Makefile | 36 ++++++++++++++++++++++++++++++++++-- arch/arm64/kernel/Makefile | 3 +++ 3 files changed, 61 insertions(+), 2 deletions(-) diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index 11b4c6aef7d7..eb9d3fc45f6b 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -1330,6 +1330,30 @@ config SYSVIPC_COMPAT def_bool y depends on COMPAT && SYSVIPC +config COMPAT_VDSO + bool "32-bit vDSO" + depends on COMPAT + default n + help + Warning: a 32-bit toolchain is necessary to build the vDSO. You + must explicitly define which toolchain should be used by setting + CROSS_COMPILE_ARM32 to the prefix of the 32-bit toolchain (same format + as CROSS_COMPILE). If CROSS_COMPILE_ARM32 is empty, a warning will be + printed and the kernel will be built as if COMPAT_VDSO had not been + set. If CROSS_COMPILE_ARM32 is set to an invalid prefix, compilation + will be aborted. + + Provide a vDSO to 32-bit processes. It includes the symbols provided + by the vDSO from the 32-bit kernel, so that a 32-bit libc can use + the compat vDSO without modification. It also provides sigreturn + trampolines, replacing the sigreturn page. + +config CROSS_COMPILE_ARM32 + string "32-bit toolchain prefix" + help + Same as setting CROSS_COMPILE_ARM32 in the environment, but saved for + future builds. The environment variable overrides this config option. + endmenu menu "Power management options" diff --git a/arch/arm64/Makefile b/arch/arm64/Makefile index 45272266dafb..f548123e1609 100644 --- a/arch/arm64/Makefile +++ b/arch/arm64/Makefile @@ -49,9 +49,39 @@ $(warning Detected assembler with broken .inst; disassembly will be unreliable) endif endif -KBUILD_CFLAGS += -mgeneral-regs-only $(lseinstr) $(brokengasinst) +ifeq ($(CONFIG_COMPAT_VDSO), y) + CROSS_COMPILE_ARM32 ?= $(CONFIG_CROSS_COMPILE_ARM32:"%"=%) + + # Check that the user has provided a valid prefix for the 32-bit toolchain. + # To prevent selecting the system $(cc-name) by default, the prefix is not + # allowed to be empty, unlike CROSS_COMPILE. In the unlikely event that the + # system $(cc-name) is actually the 32-bit ARM compiler to be used, the + # variable can be set to the dirname (e.g. CROSS_COMPILE_ARM32=/usr/bin/). + # Note: this Makefile is read both before and after regenerating the config + # (if needed). Any warning appearing before the config has been regenerated + # should be ignored. If the error is triggered and you set + # CONFIG_CROSS_COMPILE_ARM32, set CROSS_COMPILE_ARM32 to an appropriate value + # when invoking make and fix CONFIG_CROSS_COMPILE_ARM32. + ifeq ($(CROSS_COMPILE_ARM32),) + $(error CROSS_COMPILE_ARM32 not defined or empty, the compat vDSO will not be built) + else ifeq ($(cc-name),clang) + export CLANG_TRIPLE_ARM32 ?= $(CROSS_COMPILE_ARM32) + export CLANG_TARGET_ARM32 := --target=$(notdir $(CLANG_TRIPLE_ARM32:%-=%)) + export CONFIG_VDSO32 := y + vdso32 := -DCONFIG_VDSO32=1 + else ifeq ($(shell which $(CROSS_COMPILE_ARM32)$(cc-name) 2> /dev/null),) + $(error $(CROSS_COMPILE_ARM32)$(cc-name) not found, check CROSS_COMPILE_ARM32) + else + export CROSS_COMPILE_ARM32 + export CONFIG_VDSO32 := y + vdso32 := -DCONFIG_VDSO32=1 + endif +endif + +KBUILD_CFLAGS += -mgeneral-regs-only $(lseinstr) $(brokengasinst) $(vdso32) KBUILD_CFLAGS += -fno-asynchronous-unwind-tables -KBUILD_AFLAGS += $(lseinstr) $(brokengasinst) +KBUILD_CFLAGS += $(call cc-option, -mpc-relative-literal-loads) +KBUILD_AFLAGS += $(lseinstr) $(brokengasinst) $(vdso32) KBUILD_CFLAGS += $(call cc-option,-mabi=lp64) KBUILD_AFLAGS += $(call cc-option,-mabi=lp64) @@ -155,6 +185,8 @@ archclean: prepare: vdso_prepare vdso_prepare: prepare0 $(Q)$(MAKE) $(build)=arch/arm64/kernel/vdso include/generated/vdso-offsets.h + $(if $(CONFIG_VDSO32),$(Q)$(MAKE) $(build)=arch/arm64/kernel/vdso32 \ + include/generated/vdso32-offsets.h) define archhelp echo '* Image.gz - Compressed kernel image (arch/$(ARCH)/boot/Image.gz)' diff --git a/arch/arm64/kernel/Makefile b/arch/arm64/kernel/Makefile index c16be3cf39bf..628d0308d809 100644 --- a/arch/arm64/kernel/Makefile +++ b/arch/arm64/kernel/Makefile @@ -28,7 +28,9 @@ $(obj)/%.stub.o: $(obj)/%.o FORCE arm64-obj-$(CONFIG_COMPAT) += sys32.o signal32.o \ sys_compat.o entry32.o +ifneq ($(CONFIG_VDSO32),y) arm64-obj-$(CONFIG_COMPAT) += sigreturn32.o +endif arm64-obj-$(CONFIG_KUSER_HELPERS) += kuser32.o arm64-obj-$(CONFIG_FUNCTION_TRACER) += ftrace.o entry-ftrace.o arm64-obj-$(CONFIG_MODULES) += arm64ksyms.o module.o @@ -59,6 +61,7 @@ arm64-obj-$(CONFIG_ARM_SDE_INTERFACE) += sdei.o arm64-obj-$(CONFIG_ARM64_SSBD) += ssbd.o obj-y += $(arm64-obj-y) vdso/ probes/ +obj-$(CONFIG_VDSO32) += vdso32/ obj-m += $(arm64-obj-m) head-y := head.o extra-y += $(head-y) vmlinux.lds