Skip to content

Commit

Permalink
Merge branch 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/…
Browse files Browse the repository at this point in the history
…git/gerg/m68knommu

Pull m68nommu updates from Greg Ungerer:
 "A series of cleanups for the FLAT format binary loader, binfmt_flat,
  from Christoph.

  The end goal is to support no-MMU on RISC-V, and the last patch
  enables that"

* 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/gerg/m68knommu:
  riscv: add binfmt_flat support
  binfmt_flat: don't offset the data start
  binfmt_flat: move the MAX_SHARED_LIBS definition to binfmt_flat.c
  binfmt_flat: remove the persistent argument from flat_get_addr_from_rp
  binfmt_flat: provide an asm-generic/flat.h
  binfmt_flat: make support for old format binaries optional
  binfmt_flat: add a ARCH_HAS_BINFMT_FLAT option
  binfmt_flat: add endianess annotations
  binfmt_flat: use fixed size type for the on-disk format
  binfmt_flat: consolidate two version of flat_v2_reloc_t
  binfmt_flat: remove the unused OLD_FLAT_FLAG_RAM definition
  binfmt_flat: remove the uapi <linux/flat.h> header
  binfmt_flat: replace flat_argvp_envp_on_stack with a Kconfig variable
  binfmt_flat: remove flat_old_ram_flag
  binfmt_flat: provide a default version of flat_get_relocate_addr
  binfmt_flat: remove flat_set_persistent
  binfmt_flat: remove flat_reloc_valid
  • Loading branch information
torvalds committed Jul 11, 2019
2 parents d2b6b4c + ad97f9d commit 398364a
Show file tree
Hide file tree
Showing 21 changed files with 145 additions and 187 deletions.
2 changes: 2 additions & 0 deletions arch/arm/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ config ARM
default y
select ARCH_32BIT_OFF_T
select ARCH_CLOCKSOURCE_DATA
select ARCH_HAS_BINFMT_FLAT
select ARCH_HAS_DEBUG_VIRTUAL if MMU
select ARCH_HAS_DEVMEM_IS_ALLOWED
select ARCH_HAS_ELF_RANDOMIZE
Expand All @@ -30,6 +31,7 @@ config ARM
select ARCH_USE_BUILTIN_BSWAP
select ARCH_USE_CMPXCHG_LOCKREF
select ARCH_WANT_IPC_PARSE_VERSION
select BINFMT_FLAT_ARGVP_ENVP_ON_STACK
select BUILDTIME_EXTABLE_SORT if MMU
select CLONE_BACKWARDS
select CPU_PM if SUSPEND || CPU_IDLE
Expand Down
1 change: 1 addition & 0 deletions arch/arm/include/asm/Kbuild
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ generic-y += early_ioremap.h
generic-y += emergency-restart.h
generic-y += exec.h
generic-y += extable.h
generic-y += flat.h
generic-y += irq_regs.h
generic-y += kdebug.h
generic-y += local.h
Expand Down
1 change: 1 addition & 0 deletions arch/c6x/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
config C6X
def_bool y
select ARCH_32BIT_OFF_T
select ARCH_HAS_BINFMT_FLAT
select ARCH_HAS_SYNC_DMA_FOR_CPU
select ARCH_HAS_SYNC_DMA_FOR_DEVICE
select CLKDEV_LOOKUP
Expand Down
7 changes: 1 addition & 6 deletions arch/c6x/include/asm/flat.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,8 @@

#include <asm/unaligned.h>

#define flat_argvp_envp_on_stack() 0
#define flat_old_ram_flag(flags) (flags)
#define flat_reloc_valid(reloc, size) ((reloc) <= (size))
static inline int flat_get_addr_from_rp(u32 __user *rp, u32 relval, u32 flags,
u32 *addr, u32 *persistent)
u32 *addr)
{
*addr = get_unaligned((__force u32 *)rp);
return 0;
Expand All @@ -18,7 +15,5 @@ static inline int flat_put_addr_at_rp(u32 __user *rp, u32 addr, u32 rel)
put_unaligned(addr, (__force u32 *)rp);
return 0;
}
#define flat_get_relocate_addr(rel) (rel)
#define flat_set_persistent(relval, p) 0

#endif /* __ASM_C6X_FLAT_H */
3 changes: 3 additions & 0 deletions arch/h8300/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
config H8300
def_bool y
select ARCH_32BIT_OFF_T
select ARCH_HAS_BINFMT_FLAT
select BINFMT_FLAT_ARGVP_ENVP_ON_STACK
select BINFMT_FLAT_OLD_ALWAYS_RAM
select GENERIC_ATOMIC64
select HAVE_UID16
select VIRT_TO_BUS
Expand Down
7 changes: 1 addition & 6 deletions arch/h8300/include/asm/flat.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,6 @@

#include <asm/unaligned.h>

#define flat_argvp_envp_on_stack() 1
#define flat_old_ram_flag(flags) 1
#define flat_reloc_valid(reloc, size) ((reloc) <= (size))
#define flat_set_persistent(relval, p) 0

/*
* on the H8 a couple of the relocations have an instruction in the
* top byte. As there can only be 24bits of address space, we just
Expand All @@ -22,7 +17,7 @@

#define flat_get_relocate_addr(rel) (rel & ~0x00000001)
static inline int flat_get_addr_from_rp(u32 __user *rp, u32 relval, u32 flags,
u32 *addr, u32 *persistent)
u32 *addr)
{
u32 val = get_unaligned((__force u32 *)rp);
if (!(flags & FLAT_FLAG_GOTPIC))
Expand Down
2 changes: 2 additions & 0 deletions arch/m68k/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@ config M68K
bool
default y
select ARCH_32BIT_OFF_T
select ARCH_HAS_BINFMT_FLAT
select ARCH_HAS_DMA_MMAP_PGPROT if MMU && !COLDFIRE
select ARCH_HAS_DMA_PREP_COHERENT
select ARCH_HAS_SYNC_DMA_FOR_DEVICE if HAS_DMA
select ARCH_MIGHT_HAVE_PC_PARPORT if ISA
select ARCH_NO_COHERENT_DMA_MMAP if !MMU
select ARCH_NO_PREEMPT if !COLDFIRE
select BINFMT_FLAT_ARGVP_ENVP_ON_STACK
select DMA_DIRECT_REMAP if HAS_DMA && MMU && !COLDFIRE
select HAVE_IDE
select HAVE_AOUT if MMU
Expand Down
30 changes: 1 addition & 29 deletions arch/m68k/include/asm/flat.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,35 +6,7 @@
#ifndef __M68KNOMMU_FLAT_H__
#define __M68KNOMMU_FLAT_H__

#include <linux/uaccess.h>

#define flat_argvp_envp_on_stack() 1
#define flat_old_ram_flag(flags) (flags)
#define flat_reloc_valid(reloc, size) ((reloc) <= (size))
static inline int flat_get_addr_from_rp(u32 __user *rp, u32 relval, u32 flags,
u32 *addr, u32 *persistent)
{
#ifdef CONFIG_CPU_HAS_NO_UNALIGNED
return copy_from_user(addr, rp, 4) ? -EFAULT : 0;
#else
return get_user(*addr, rp);
#endif
}

static inline int flat_put_addr_at_rp(u32 __user *rp, u32 addr, u32 rel)
{
#ifdef CONFIG_CPU_HAS_NO_UNALIGNED
return copy_to_user(rp, &addr, 4) ? -EFAULT : 0;
#else
return put_user(addr, rp);
#endif
}
#define flat_get_relocate_addr(rel) (rel)

static inline int flat_set_persistent(u32 relval, u32 *persistent)
{
return 0;
}
#include <asm-generic/flat.h>

#define FLAT_PLAT_INIT(regs) \
do { \
Expand Down
1 change: 1 addition & 0 deletions arch/microblaze/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ config MICROBLAZE
def_bool y
select ARCH_32BIT_OFF_T
select ARCH_NO_SWAP
select ARCH_HAS_BINFMT_FLAT if !MMU
select ARCH_HAS_DMA_COHERENT_TO_PFN if MMU
select ARCH_HAS_GCOV_PROFILE_ALL
select ARCH_HAS_SYNC_DMA_FOR_CPU
Expand Down
7 changes: 1 addition & 6 deletions arch/microblaze/include/asm/flat.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,6 @@

#include <asm/unaligned.h>

#define flat_argvp_envp_on_stack() 0
#define flat_old_ram_flag(flags) (flags)
#define flat_reloc_valid(reloc, size) ((reloc) <= (size))
#define flat_set_persistent(relval, p) 0

/*
* Microblaze works a little differently from other arches, because
* of the MICROBLAZE_64 reloc type. Here, a 32 bit address is split
Expand All @@ -33,7 +28,7 @@
*/

static inline int flat_get_addr_from_rp(u32 __user *rp, u32 relval, u32 flags,
u32 *addr, u32 *persistent)
u32 *addr)
{
u32 *p = (__force u32 *)rp;

Expand Down
1 change: 1 addition & 0 deletions arch/riscv/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ config RISCV
select OF
select OF_EARLY_FLATTREE
select OF_IRQ
select ARCH_HAS_BINFMT_FLAT
select ARCH_WANT_FRAME_POINTERS
select CLONE_BACKWARDS
select COMMON_CLK
Expand Down
1 change: 1 addition & 0 deletions arch/riscv/include/asm/Kbuild
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ generic-y += compat.h
generic-y += device.h
generic-y += div64.h
generic-y += extable.h
generic-y += flat.h
generic-y += dma.h
generic-y += dma-contiguous.h
generic-y += dma-mapping.h
Expand Down
1 change: 1 addition & 0 deletions arch/sh/Kconfig
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# SPDX-License-Identifier: GPL-2.0
config SUPERH
def_bool y
select ARCH_HAS_BINFMT_FLAT if !MMU
select ARCH_HAS_PTE_SPECIAL
select ARCH_HAS_TICK_BROADCAST if GENERIC_CLOCKEVENTS_BROADCAST
select ARCH_MIGHT_HAVE_PC_PARPORT
Expand Down
7 changes: 1 addition & 6 deletions arch/sh/include/asm/flat.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,8 @@

#include <asm/unaligned.h>

#define flat_argvp_envp_on_stack() 0
#define flat_old_ram_flag(flags) (flags)
#define flat_reloc_valid(reloc, size) ((reloc) <= (size))
static inline int flat_get_addr_from_rp(u32 __user *rp, u32 relval, u32 flags,
u32 *addr, u32 *persistent)
u32 *addr)
{
*addr = get_unaligned((__force u32 *)rp);
return 0;
Expand All @@ -25,8 +22,6 @@ static inline int flat_put_addr_at_rp(u32 __user *rp, u32 addr, u32 rel)
put_unaligned(addr, (__force u32 *)rp);
return 0;
}
#define flat_get_relocate_addr(rel) (rel)
#define flat_set_persistent(relval, p) ({ (void)p; 0; })

#define FLAT_PLAT_INIT(_r) \
do { _r->regs[0]=0; _r->regs[1]=0; _r->regs[2]=0; _r->regs[3]=0; \
Expand Down
1 change: 1 addition & 0 deletions arch/xtensa/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
config XTENSA
def_bool y
select ARCH_32BIT_OFF_T
select ARCH_HAS_BINFMT_FLAT if !MMU
select ARCH_HAS_SYNC_DMA_FOR_CPU
select ARCH_HAS_SYNC_DMA_FOR_DEVICE
select ARCH_NO_COHERENT_DMA_MMAP if !MMU
Expand Down
7 changes: 1 addition & 6 deletions arch/xtensa/include/asm/flat.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,8 @@

#include <asm/unaligned.h>

#define flat_argvp_envp_on_stack() 0
#define flat_old_ram_flag(flags) (flags)
#define flat_reloc_valid(reloc, size) ((reloc) <= (size))
static inline int flat_get_addr_from_rp(u32 __user *rp, u32 relval, u32 flags,
u32 *addr, u32 *persistent)
u32 *addr)
{
*addr = get_unaligned((__force u32 *)rp);
return 0;
Expand All @@ -18,7 +15,5 @@ static inline int flat_put_addr_at_rp(u32 __user *rp, u32 addr, u32 rel)
put_unaligned(addr, (__force u32 *)rp);
return 0;
}
#define flat_get_relocate_addr(rel) (rel)
#define flat_set_persistent(relval, p) 0

#endif /* __ASM_XTENSA_FLAT_H */
18 changes: 17 additions & 1 deletion fs/Kconfig.binfmt
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,28 @@ config BINFMT_SCRIPT

Most systems will not boot if you say M or N here. If unsure, say Y.

config ARCH_HAS_BINFMT_FLAT
bool

config BINFMT_FLAT
bool "Kernel support for flat binaries"
depends on !MMU || ARM || M68K
depends on ARCH_HAS_BINFMT_FLAT
help
Support uClinux FLAT format binaries.

config BINFMT_FLAT_ARGVP_ENVP_ON_STACK
bool

config BINFMT_FLAT_OLD_ALWAYS_RAM
bool

config BINFMT_FLAT_OLD
bool "Enable support for very old legacy flat binaries"
depends on BINFMT_FLAT
help
Support decade old uClinux FLAT format binaries. Unless you know
you have some of those say N here.

config BINFMT_ZFLAT
bool "Enable ZFLAT support"
depends on BINFMT_FLAT
Expand Down
Loading

0 comments on commit 398364a

Please sign in to comment.