Skip to contentSkip to conversation

C6X: add support to build with BINFMT_ELF_FDPIC

PATCH In review Mark Salter 3 participants 7 messages Apr 20, 2012 – Apr 23, 2012

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 C6X: add support to build with BINFMT_ELF_FDPIC

C6x userspace supports a shared library mechanism called DSBT for systems with no MMU. DSBT is similar to FDPIC in allowing shared text segments and private copies of data segments without an MMU. Both methods access data using a base register and offset. With FDPIC, the caller of an external function sets up the base register for the callee. With DSBT, the called function sets up its own base register. Other details differ but both userspaces need the same thing from the kernel loader: a map of where each ELF segment was loaded. The FDPIC loader already provides this, so DSBT just uses it.

This patch enables BINFMT_ELF_FDPIC by default for C6X and provides the necessary architecture hooks for the generic loader.

---
 arch/c6x/include/asm/elf.h    |   12 +++++++++++-
 arch/c6x/include/asm/mmu.h    |    4 ++++
 arch/c6x/include/asm/ptrace.h |    5 +++++
 arch/c6x/kernel/process.c     |    7 +++++++
 fs/Kconfig.binfmt             |    2 +-
 5 files changed, 28 insertions(+), 2 deletions(-)
arch/c6x/include/asm/elf.h +11 -1
index d57865b..6f592a2 100644
@@ -30,7 +30,17 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
  */
 #define elf_check_arch(x) ((x)->e_machine == EM_TI_C6000)
 
-#define elf_check_const_displacement(x) (1)
+#define elf_check_fdpic(x) (1)
+#define elf_check_const_displacement(x) (0)
+
+#define ELF_FDPIC_PLAT_INIT(_regs, _exec_map, _interp_map, _dynamic_addr) \
+do {								\
+	_regs->b4	= (_exec_map);				\
+	_regs->a6	= (_interp_map);			\
+	_regs->b6	= (_dynamic_addr);			\
+} while (0)
+
+#define ELF_FDPIC_CORE_EFLAGS	0
 
 /*
  * These are used to set parameters in the core dumps.
arch/c6x/include/asm/mmu.h +4 -0
index 41592bf..4467e77 100644
@@ -13,6 +13,10 @@
 
 typedef struct {
 	unsigned long		end_brk;
+#ifdef CONFIG_BINFMT_ELF_FDPIC
+	unsigned long	exec_fdpic_loadmap;
+	unsigned long	interp_fdpic_loadmap;
+#endif
 } mm_context_t;
 
 #endif /* _ASM_C6X_MMU_H */
arch/c6x/include/asm/ptrace.h +5 -0
index 21e8d79..b04ff59 100644
@@ -97,6 +97,11 @@
 #define PT_DP	   PT_B14  /* Data Segment Pointer (B14) */
 #define PT_SP	   PT_B15  /* Stack Pointer (B15)  */
 
+#define PTRACE_GETFDPIC		31	/* get the ELF fdpic loadmap address */
+
+#define PTRACE_GETFDPIC_EXEC	0	/* [addr] request the executable loadmap */
+#define PTRACE_GETFDPIC_INTERP	1	/* [addr] request the interpreter loadmap */
+
 #ifndef __ASSEMBLY__
 
 #ifdef _BIG_ENDIAN
arch/c6x/kernel/process.c +7 -0
index 7ca8c41..e12adf0 100644
@@ -263,3 +263,10 @@ unsigned long get_wchan(struct task_struct *p)
 {
 	return p->thread.wchan;
 }
+
+/* Fill in the fpu structure for a core dump. This is easy -- we don't have any */
+int dump_fpu(struct pt_regs *regs, elf_fpregset_t *fpu)
+{
+	/* Not valid */
+	return 0;
+}
fs/Kconfig.binfmt +1 -1
index e95d1b6..e851721 100644
@@ -33,7 +33,7 @@ config ARCH_BINFMT_ELF_RANDOMIZE_PIE
 config BINFMT_ELF_FDPIC
 	bool "Kernel support for FDPIC ELF binaries"
 	default y
-	depends on (FRV || BLACKFIN || (SUPERH32 && !MMU))
+	depends on (FRV || BLACKFIN || (SUPERH32 && !MMU) || TMS320C6X)
 	help
 	  ELF FDPIC binaries are based on ELF, but allow the individual load
 	  segments of a binary to be located in memory independently of each
Signature · 1 line
1.7.9.1
#1 lore raw

arch/c6x/kernel/process.c unsigned long get_wchan(struct task_struct *p) · line 272

Quoted 10 lines · Mark Salter
arch/c6x/kernel/process.c +7 -0
 
+
+/* Fill in the fpu structure for a core dump. This is easy -- we don't have any */
+int dump_fpu(struct pt_regs *regs, elf_fpregset_t *fpu)
+{
+       /* Not valid */
+       return 0;
+}

you could avoid this like Blackfin has:
arch/blackfin/include/asm/elf.h:
#define ELF_CORE_COPY_FPREGS(...) 0 /* Blackfin has no FPU */

Quoted 8 lines
fs/Kconfig.binfmt +0 -0

 config BINFMT_ELF_FDPIC
       bool "Kernel support for FDPIC ELF binaries" default y

-       depends on (FRV || BLACKFIN || (SUPERH32 && !MMU))
+       depends on (FRV || BLACKFIN || (SUPERH32 && !MMU) || TMS320C6X)

shouldn't the main arch symbol be "C6X" to match arch/c6x/ ? -mike
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#2 lore raw
Quoted 4 lines · Mike Frysinger
Quoted 3 lines · Mark Salter
arch/c6x/kernel/process.c +0 -0
Quoted 11 lines

arch/c6x/kernel/process.c unsigned long get_wchan(struct task_struct *p) · line 272

Quoted 7 lines
arch/c6x/kernel/process.c +7 -0
+
+/* Fill in the fpu structure for a core dump. This is easy -- we don't have any */
+int dump_fpu(struct pt_regs *regs, elf_fpregset_t *fpu)
+{
+       /* Not valid */
+       return 0;
+}

you could avoid this like Blackfin has:
arch/blackfin/include/asm/elf.h:
#define ELF_CORE_COPY_FPREGS(...) 0 /* Blackfin has no FPU */

Yes, thanks. That's a better way I missed.

Quoted 11 lines

fs/Kconfig.binfmt config ARCH_BINFMT_ELF_RANDOMIZE_PIE · line 36

Quoted 9 lines
fs/Kconfig.binfmt +1 -1
 
 config BINFMT_ELF_FDPIC
       bool "Kernel support for FDPIC ELF binaries"
       default y
-       depends on (FRV || BLACKFIN || (SUPERH32 && !MMU))
+       depends on (FRV || BLACKFIN || (SUPERH32 && !MMU) || TMS320C6X)

shouldn't the main arch symbol be "C6X" to match arch/c6x/ ?

It probably should have been. Most architectures use that convention but there are notable exceptions like powerpc and sh.

Quoted 1 line

-mike

#3 lore raw
Quoted 12 lines
Quoted 11 lines

fs/Kconfig.binfmt config ARCH_BINFMT_ELF_RANDOMIZE_PIE · line 36

Quoted 9 lines
fs/Kconfig.binfmt +1 -1
 
 config BINFMT_ELF_FDPIC
       bool "Kernel support for FDPIC ELF binaries"
       default y
-       depends on (FRV || BLACKFIN || (SUPERH32 && !MMU))
+       depends on (FRV || BLACKFIN || (SUPERH32 && !MMU) || TMS320C6X)

shouldn't the main arch symbol be "C6X" to match arch/c6x/ ?

Quoted 2 lines

It probably should have been. Most architectures use that convention but there are notable exceptions like powerpc and sh.

Please do not repeat past mistakes.
It should be trivial to fix.

Allow TMS320C6X for a sinel relase along with C6X - and drop it when all users outside your arch has switched over.

Sam

#4 lore raw
Quoted 2 lines · Sam Ravnborg

Allow TMS320C6X for a sinel relase along with C6X - and drop it when all users outside your arch has switched over.

I'm not sure we need to carry TMS320C6X for even a single release. As Mike pointed out, there are few references, actually no references right now, so now would be a good time to correct it. I'll make a patch to do just that.

--Mark

#5 lore raw
Quoted 8 lines · Mark Salter
Quoted 2 lines · Sam Ravnborg

Allow TMS320C6X for a sinel relase along with C6X - and drop it when all users outside your arch has switched over.

I'm not sure we need to carry TMS320C6X for even a single release. As Mike pointed out, there are few references, actually no references right now, so now would be a good time to correct it. I'll make a patch to do just that.

thx!
-mike

#6 lore raw
In reply to Mark Salter
Quoted 13 lines · Mark Salter
Quoted 11 lines · Mike Frysinger
Quoted 8 lines · Mark Salter
fs/Kconfig.binfmt +0 -0

 config BINFMT_ELF_FDPIC
       bool "Kernel support for FDPIC ELF binaries" default y

-       depends on (FRV || BLACKFIN || (SUPERH32 && !MMU))
+       depends on (FRV || BLACKFIN || (SUPERH32 && !MMU) || TMS320C6X)

shouldn't the main arch symbol be "C6X" to match arch/c6x/ ?

Quoted 2 lines

It probably should have been. Most architectures use that convention but there are notable exceptions like powerpc and sh.

seems like it'd be fairly trivial to convert it. there aren't many references in the kernel tree to TMS320C6X.
-mike
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html