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

Message ID alpine.LFD.2.20.1607221532340.6118@knanqh.ubzr
State New
Headers show

Commit Message

Nicolas Pitre July 22, 2016, 7:45 p.m.
On Fri, 22 Jul 2016, Russell King - ARM Linux wrote:

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


This is almost all generic code changes, hence I didn't want to spam too 
many lists with those patches.

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


Here's the ARM specific part:


rp is a user space reloc pointer therefore it should use user space 
accessors.  That's all there is to the arch specific part.  Pending your 
agreement with the above, everyone is fine with the series.


Nicolas

Patch

diff --git a/arch/arm/include/asm/flat.h b/arch/arm/include/asm/flat.h
index e847d23351..acf1d14b89 100644
--- a/arch/arm/include/asm/flat.h
+++ b/arch/arm/include/asm/flat.h
@@ -8,8 +8,9 @@ 
 #define	flat_argvp_envp_on_stack()		1
 #define	flat_old_ram_flag(flags)		(flags)
 #define	flat_reloc_valid(reloc, size)		((reloc) <= (size))
-#define	flat_get_addr_from_rp(rp, relval, flags, persistent) ((void)persistent,get_unaligned(rp))
-#define	flat_put_addr_at_rp(rp, val, relval)	put_unaligned(val,rp)
+#define	flat_get_addr_from_rp(rp, relval, flags, persistent) \
+	({ unsigned long __val; __get_user_unaligned(__val, rp); __val; })
+#define	flat_put_addr_at_rp(rp, val, relval)	__put_user_unaligned(val, rp)
 #define	flat_get_relocate_addr(rel)		(rel)
 #define	flat_set_persistent(relval, p)		0