diff mbox

[v4,00/12] allow BFLT executables on systems with a MMU

Message ID 6d7b45eb-8085-47fa-fc31-5fb26b7dd009@linux-m68k.org (mailing list archive)
State New, archived
Headers show

Commit Message

Greg Ungerer July 21, 2016, 6:58 a.m. UTC
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 <gerg@linux-m68k.org>
---
 arch/m68k/include/asm/flat.h      | 6 ++++++
 arch/m68k/include/asm/processor.h | 2 --
 2 files changed, 6 insertions(+), 2 deletions(-)

Comments

Nicolas Pitre July 21, 2016, 2:48 p.m. UTC | #1
On Thu, 21 Jul 2016, Greg Ungerer wrote:

> 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.

Excellent!

> 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.

OK.

Who should merge my patch series at this point?


Nicolas
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Greg Ungerer July 22, 2016, 7:28 a.m. UTC | #2
On 22/07/16 00:48, Nicolas Pitre wrote:
> On Thu, 21 Jul 2016, Greg Ungerer wrote:
>> 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.
> 
> Excellent!
> 
>> 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.
> 
> OK.
> 
> Who should merge my patch series at this point?

If no-one else wants to carry it I can take it in the m68knommu
git tree. But I would want to be sure everyone is good with it
first.

Alan: are you happy with where this is at?
rmk: ok with the arm flat.h change going via another tree?
Al/David: any comments on this?

(Link to v4 patches here https://lkml.org/lkml/2016/7/20/508 )

Regards
Greg

--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Alan Cox July 22, 2016, 3:06 p.m. UTC | #3
On Fri, 22 Jul 2016 17:28:13 +1000
Greg Ungerer <gerg@linux-m68k.org> wrote:

> On 22/07/16 00:48, Nicolas Pitre wrote:
> > On Thu, 21 Jul 2016, Greg Ungerer wrote:  
> >> 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.  
> > 
> > Excellent!
> >   
> >> 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.  
> > 
> > OK.
> > 
> > Who should merge my patch series at this point?  
> 
> If no-one else wants to carry it I can take it in the m68knommu
> git tree. But I would want to be sure everyone is good with it
> first.
> 
> Alan: are you happy with where this is at?

From a first glance yes. I don't have time right now to give it a more
detailed audit, but with the correct user accessors it looks as if all
the ways you can mess up relocations simply result in faults or running a
nonsense binary and the userspace failing.

Alan
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Russell King (Oracle) July 22, 2016, 7:22 p.m. UTC | #4
On Fri, Jul 22, 2016 at 05:28:13PM +1000, Greg Ungerer wrote:
> On 22/07/16 00:48, Nicolas Pitre wrote:
> > On Thu, 21 Jul 2016, Greg Ungerer wrote:
> >> 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.
> > 
> > Excellent!
> > 
> >> 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.
> > 
> > OK.
> > 
> > Who should merge my patch series at this point?
> 
> If no-one else wants to carry it I can take it in the m68knommu
> git tree. But I would want to be sure everyone is good with it
> first.
> 
> Alan: are you happy with where this is at?
> rmk: ok with the arm flat.h change going via another tree?

I've no idea, sorry.  This is the first I've heard about this as I
haven't been copied with any of the patches, neither has the
linux-arm-kernel mailing list.

> (Link to v4 patches here https://lkml.org/lkml/2016/7/20/508 )

elinks tells me "Unable to retrieve https://lkml.org/lkml/2016/7/20/508:
SSL error" which is a common lkml.org error with elinks.  Also lkml.org
doesn't always work with firefox, especially if you try to follow threads
- I often end up with messages that are missing all content.  Even
openssl s_client gets refused by lkml.org:443 with a fatal SSL error.
(elinks gets "Handshake Failure", openssl gets "Internal Error".)

So, given that no one has seen this on the ARM side, I think there's
a need to post the patches so that it can be reviewed there, especially
so that the wider ARM audience can see what's going on, and ARM64 folk
can see as well.

In any case, I certainly won't be able to review it over this weekend.
diff mbox

Patch

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)