From patchwork Thu Aug 17 07:23:42 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Pitre X-Patchwork-Id: 9905147 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 99B8760386 for ; Thu, 17 Aug 2017 07:26:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8C47028ABE for ; Thu, 17 Aug 2017 07:26:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8124D28AC2; Thu, 17 Aug 2017 07:26:18 +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.6 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.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 11CFE28ABE for ; Thu, 17 Aug 2017 07:26:18 +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=qKwrRZs/2ELeGrA5NWdRe9eD5XRyc0ziNLmg8PDPDVE=; b=ocY6egm0faO1td7ItWCbUMLehu KSY+gNpC+/M+v1TwMPkY0Jf1Hon0KLdRh6d8JchYfkn9f785SEZdiYUdRZL3hlG+uhKz+ul/UeDkm dIP8Yj9vSI6aF4dSFk1fCqxj4pt/bsXD+UmZvyrVikvAwccskNL2jl+iBl0ohn7P2NioBChlpK8bG Gc2W0NCht+6WN/UVdzkrLDhkm8ppNllPGPS+iHPmOXMDFOSEUdhlxDOevuci3Gklopsao0wzLgEJZ FHq3OJNkX6qeRPV4G1rOaZWXrHqmYZlyEiA5szQM1mLPyse8do8B78oLk9kBoT78znaAxDaMaZMTE wXgzhcBw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1diFC1-0008Br-Fq; Thu, 17 Aug 2017 07:26:13 +0000 Received: from merlin.infradead.org ([205.233.59.134]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1diFAU-0005OC-Qc for linux-arm-kernel@bombadil.infradead.org; Thu, 17 Aug 2017 07:24:38 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.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=qsPmO2i8PtrnKAqpPKEz4SpNpGEY/OgSfzktXov6gug=; b=OFiP/4w7bykiRwXBaKjXBFWNU vbPhlcvQryBdYcq8upf51VwpK+dqIDQPYvI9hSDjH4lzLpil7vzfd3X9k1pkkVhXLhHK4C92aAwGU oJAiMvsbfPmF8XAeoYU16DnNKkXh6NixoVrlt98c4jW68S+GDEA0jLxFaOtn312BDFTwssdV5hERR NEEt0HqKWls1q1cAbrxyt/q4aYgWX1YpMKoQCLi+EI0Orw+wPJE7MTgMAWI60SLLBmQq5X+lYmLMU zABMzFhgwBKRHD6Gq2HxXYWWVM+KtzOZrke0Zv5yaRt0aldNdL4wt9QF/mzV4FFWzp5c5DkW/ETv9 Fs6sq2XIQ==; Received: from pb-smtp2.pobox.com ([64.147.108.71] helo=sasl.smtp.pobox.com) by merlin.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1diFAR-0003FK-1I for linux-arm-kernel@lists.infradead.org; Thu, 17 Aug 2017 07:24:37 +0000 Received: from sasl.smtp.pobox.com (unknown [127.0.0.1]) by pb-smtp2.pobox.com (Postfix) with ESMTP id 4054C9789E; Thu, 17 Aug 2017 03:24:11 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=pobox.com; h=from:to:cc :subject:date:message-id:in-reply-to:references; s=sasl; bh=ZMDc DGcNnXhqdO+RsEqUrcF/joY=; b=rwstq21Wa+GWuPW/n+Li+2rkPAiu+9embodt 4yS347kCZraz8jz0AD5khDkRXBCrlNMvhT2FS6/Mj+gvJ5l1neHtdVeP2G3UMgi5 +U1oP1qnZmFv36mL8J5rYfz7zgleQdEpy8zywUgcBHIncxwGeZp6foRn9XMST6Ik z2y3hKg= Received: from pb-smtp2.nyi.icgroup.com (unknown [127.0.0.1]) by pb-smtp2.pobox.com (Postfix) with ESMTP id 396D397895; Thu, 17 Aug 2017 03:24:10 -0400 (EDT) Received: from yoda.home (unknown [70.80.200.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by pb-smtp2.pobox.com (Postfix) with ESMTPSA id ADA0F97891; Thu, 17 Aug 2017 03:24:09 -0400 (EDT) Received: from xanadu.home (xanadu.home [192.168.2.2]) by yoda.home (Postfix) with ESMTP id DB79D2DA0679; Thu, 17 Aug 2017 03:24:08 -0400 (EDT) From: Nicolas Pitre To: Russell King - ARM Linux , linux-arm-kernel@lists.infradead.org Subject: [PATCH v2 3/8] ARM: start_thread(): don't always clear all regs Date: Thu, 17 Aug 2017 03:23:42 -0400 Message-Id: <20170817072347.19990-4-nicolas.pitre@linaro.org> X-Mailer: git-send-email 2.9.5 In-Reply-To: <20170817072347.19990-1-nicolas.pitre@linaro.org> References: <20170817072347.19990-1-nicolas.pitre@linaro.org> X-Pobox-Relay-ID: 0F9C42F6-831D-11E7-8FD7-9D2B0D78B957-78420484!pb-smtp2.pobox.com 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: "Mickael Guene ." , Alexandre Torgue 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 The elf_fdpic binary format driver has to initialize extra registers beside the stack and program counter as required by the corresponding ABI. So reinstate them after the regs structure has been cleared. While at it let's get rid of start_thread_nommu(). Signed-off-by: Nicolas Pitre Tested-by: Vincent Abriou --- arch/arm/include/asm/processor.h | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/arch/arm/include/asm/processor.h b/arch/arm/include/asm/processor.h index c3d5fc124a..338cbe0a18 100644 --- a/arch/arm/include/asm/processor.h +++ b/arch/arm/include/asm/processor.h @@ -47,15 +47,24 @@ struct thread_struct { #define INIT_THREAD { } -#ifdef CONFIG_MMU -#define nommu_start_thread(regs) do { } while (0) -#else -#define nommu_start_thread(regs) regs->ARM_r10 = current->mm->start_data -#endif - #define start_thread(regs,pc,sp) \ ({ \ + unsigned long r7, r8, r9; \ + \ + if (IS_ENABLED(CONFIG_BINFMT_ELF_FDPIC)) { \ + r7 = regs->ARM_r7; \ + r8 = regs->ARM_r8; \ + r9 = regs->ARM_r9; \ + } \ memset(regs->uregs, 0, sizeof(regs->uregs)); \ + if (IS_ENABLED(CONFIG_BINFMT_ELF_FDPIC) && \ + current->personality & FDPIC_FUNCPTRS) { \ + regs->ARM_r7 = r7; \ + regs->ARM_r8 = r8; \ + regs->ARM_r9 = r9; \ + regs->ARM_r10 = current->mm->start_data; \ + } else if (!IS_ENABLED(CONFIG_MMU)) \ + regs->ARM_r10 = current->mm->start_data; \ if (current->personality & ADDR_LIMIT_32BIT) \ regs->ARM_cpsr = USR_MODE; \ else \ @@ -65,7 +74,6 @@ struct thread_struct { regs->ARM_cpsr |= PSR_ENDSTATE; \ regs->ARM_pc = pc & ~1; /* pc */ \ regs->ARM_sp = sp; /* sp */ \ - nommu_start_thread(regs); \ }) /* Forward declaration, a strange C thing */