From patchwork Thu Jul 21 06:58:12 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Ungerer X-Patchwork-Id: 9240985 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 62668602F0 for ; Thu, 21 Jul 2016 06:57:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 540AA27BFC for ; Thu, 21 Jul 2016 06:57:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 48B1A27D85; Thu, 21 Jul 2016 06:57:33 +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=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ECDFA27BFC for ; Thu, 21 Jul 2016 06:57:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751320AbcGUG5Q (ORCPT ); Thu, 21 Jul 2016 02:57:16 -0400 Received: from icp-osb-irony-out3.external.iinet.net.au ([203.59.1.153]:58139 "EHLO icp-osb-irony-out3.external.iinet.net.au" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750884AbcGUG5Q (ORCPT ); Thu, 21 Jul 2016 02:57:16 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A2BfCABgcZBX/zXSMGcNUBsBAQGEIVKjaAEBAQEBAQaSX4IPgXuGGgKBaRIBAQEBAQEBgU0QAYQKAQEBAQMnUhALDQoBLk8IBgEMBgIBAbcVjk0BAQEBAQEBAQEBAQEBAQEBAQEBAQEchWKCQAiCTYobBYgZhyeJZQGYVIVRkCElBIQwXIV2gWIBAQE X-IPAS-Result: A2BfCABgcZBX/zXSMGcNUBsBAQGEIVKjaAEBAQEBAQaSX4IPgXuGGgKBaRIBAQEBAQEBgU0QAYQKAQEBAQMnUhALDQoBLk8IBgEMBgIBAbcVjk0BAQEBAQEBAQEBAQEBAQEBAQEBAQEchWKCQAiCTYobBYgZhyeJZQGYVIVRkCElBIQwXIV2gWIBAQE X-IronPort-AV: E=Sophos;i="5.28,398,1464624000"; d="scan'208";a="241207168" Received: from unknown (HELO [172.16.0.22]) ([103.48.210.53]) by icp-osb-irony-out3.iinet.net.au with ESMTP; 21 Jul 2016 14:57:13 +0800 Subject: Re: [PATCH v4 00/12] allow BFLT executables on systems with a MMU To: Nicolas Pitre , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org References: <1469042561-7360-1-git-send-email-nicolas.pitre@linaro.org> Cc: Alexander Viro , David Howells From: Greg Ungerer Message-ID: <6d7b45eb-8085-47fa-fc31-5fb26b7dd009@linux-m68k.org> Date: Thu, 21 Jul 2016 16:58:12 +1000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 MIME-Version: 1.0 In-Reply-To: <1469042561-7360-1-git-send-email-nicolas.pitre@linaro.org> Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Hi Nicolas, On 21/07/16 05:22, Nicolas Pitre wrote: > This series provides the necessary changes to allow "flat" executable > binaries meant for no-MMU systems to actually run on systems with a MMU. > Also thrown in are various cleanups to binfmt_flat.c. I got to the bottom of why I couldn't run m68k flat binaries on an MMU enabled m68k system. I had to fix the regs setup, with the patch below. With this I can now run flat binaries on my ColdFire MMU enabled system. This change is completely independent of your patch series so I'll push this separately via the linux-m68k list and my m68knommu git tree. Regards Greg Subject: [PATCH] m68k: fix bFLT executable running on MMU enabled systems Even after recent changes to support running flat format executables on MMU enabled systems (by nicolas.pitre@linaro.org) they still failed to run on m68k/ColdFire MMU enabled systems. On trying to run a flat format binary the application would immediately crash with a SIGSEGV. Code to setup the D5 register with the base of the application data region was only in the non-MMU code path, so it was not being set for the MMU enabled case. Flat binaries on m68k/ColdFire use this to support GOT/PIC flat built application code. Fix this so that D5 is always setup when loading/running a bFLT executable on m68k systems. Signed-off-by: Greg Ungerer --- arch/m68k/include/asm/flat.h | 6 ++++++ arch/m68k/include/asm/processor.h | 2 -- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/arch/m68k/include/asm/flat.h b/arch/m68k/include/asm/flat.h index f3f592d..a97c479 100644 --- a/arch/m68k/include/asm/flat.h +++ b/arch/m68k/include/asm/flat.h @@ -19,4 +19,10 @@ static inline int flat_set_persistent(unsigned long relval, return 0; } +#define FLAT_PLAT_INIT(regs) \ + do { \ + if (current->mm) \ + (regs)->d5 = current->mm->start_data; \ + } while (0) + #endif /* __M68KNOMMU_FLAT_H__ */ diff --git a/arch/m68k/include/asm/processor.h b/arch/m68k/include/asm/processor.h index a6ce2ec..46672d1 100644 --- a/arch/m68k/include/asm/processor.h +++ b/arch/m68k/include/asm/processor.h @@ -131,8 +131,6 @@ extern int handle_kernel_fault(struct pt_regs *regs); do { \ (_regs)->pc = (_pc); \ setframeformat(_regs); \ - if (current->mm) \ - (_regs)->d5 = current->mm->start_data; \ (_regs)->sr &= ~0x2000; \ wrusp(_usp); \ } while(0)