From 89e6ffd9f03936d9f6f0332426e4a3cf379b90bd Mon Sep 17 00:00:00 2001 From: Greg Ungerer Date: Thu, 21 Jul 2016 16:28:48 +1000 Subject: 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(-) (limited to 'arch/m68k') diff --git a/arch/m68k/include/asm/flat.h b/arch/m68k/include/asm/flat.h index f9454b89a51b..f46c2f044f8c 100644 --- a/arch/m68k/include/asm/flat.h +++ b/arch/m68k/include/asm/flat.h @@ -18,4 +18,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 a6ce2ec8d693..46672d1f4d62 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) -- cgit v1.2.3 From 120c4d95b29d1c60ee8c7b72e4b96098514b2e3c Mon Sep 17 00:00:00 2001 From: Greg Ungerer Date: Thu, 21 Jul 2016 17:05:41 +1000 Subject: m68k: fix file path comment Remove the wrong full path name of this file. Signed-off-by: Greg Ungerer --- arch/m68k/include/asm/flat.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'arch/m68k') diff --git a/arch/m68k/include/asm/flat.h b/arch/m68k/include/asm/flat.h index f46c2f044f8c..8e58d47be90d 100644 --- a/arch/m68k/include/asm/flat.h +++ b/arch/m68k/include/asm/flat.h @@ -1,5 +1,5 @@ /* - * include/asm-m68knommu/flat.h -- uClinux flat-format executables + * flat.h -- uClinux flat-format executables */ #ifndef __M68KNOMMU_FLAT_H__ -- cgit v1.2.3 From f987e5a13c55e65df6a03677dda38c8e5fb47029 Mon Sep 17 00:00:00 2001 From: Greg Ungerer Date: Thu, 21 Jul 2016 17:29:43 +1000 Subject: m68k: use same start_thread() on MMU and no-MMU The MMU and no-MMU versions of start_thread() are now identical, so use the same common code for both. Signed-off-by: Greg Ungerer --- arch/m68k/include/asm/processor.h | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) (limited to 'arch/m68k') diff --git a/arch/m68k/include/asm/processor.h b/arch/m68k/include/asm/processor.h index 46672d1f4d62..c84a2183b3f0 100644 --- a/arch/m68k/include/asm/processor.h +++ b/arch/m68k/include/asm/processor.h @@ -110,7 +110,6 @@ struct thread_struct { #define setframeformat(_regs) do { } while (0) #endif -#ifdef CONFIG_MMU /* * Do necessary setup to start up a newly executed thread. */ @@ -123,24 +122,14 @@ static inline void start_thread(struct pt_regs * regs, unsigned long pc, wrusp(usp); } +#ifdef CONFIG_MMU extern int handle_kernel_fault(struct pt_regs *regs); - #else - -#define start_thread(_regs, _pc, _usp) \ -do { \ - (_regs)->pc = (_pc); \ - setframeformat(_regs); \ - (_regs)->sr &= ~0x2000; \ - wrusp(_usp); \ -} while(0) - static inline int handle_kernel_fault(struct pt_regs *regs) { /* Any fault in kernel is fatal on non-mmu */ return 0; } - #endif /* Forward declaration, a strange C thing */ -- cgit v1.2.3 From 002d2f01f13f1671d771e1493a3405ed4986694d Mon Sep 17 00:00:00 2001 From: Nicolas Pitre Date: Sun, 24 Jul 2016 11:30:28 -0400 Subject: m68k: enable binfmt_flat on systems with an MMU Now that the generic changes are in place, this can be enabled on m68k with the use of proper user space accessors in the flat_get_addr_from_rp() and flat_put_addr_at_rp() handlers as rp actually holds a user space address. Signed-off-by: Nicolas Pitre Signed-off-by: Greg Ungerer --- arch/m68k/include/asm/flat.h | 5 +++-- fs/Kconfig.binfmt | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) (limited to 'arch/m68k') diff --git a/arch/m68k/include/asm/flat.h b/arch/m68k/include/asm/flat.h index 8e58d47be90d..00c392b0cabd 100644 --- a/arch/m68k/include/asm/flat.h +++ b/arch/m68k/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, p) 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, p) \ + ({ 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) static inline int flat_set_persistent(unsigned long relval, diff --git a/fs/Kconfig.binfmt b/fs/Kconfig.binfmt index 72c03354c14b..c7efddf6e038 100644 --- a/fs/Kconfig.binfmt +++ b/fs/Kconfig.binfmt @@ -89,7 +89,8 @@ config BINFMT_SCRIPT config BINFMT_FLAT bool "Kernel support for flat binaries" - depends on !MMU && (!FRV || BROKEN) + depends on !MMU || M68K + depends on !FRV || BROKEN help Support uClinux FLAT format binaries. -- cgit v1.2.3