All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] C6X: add support to build with BINFMT_ELF_FDPIC
@ 2012-04-20 21:47 Mark Salter
  2012-04-21  5:01   ` Mike Frysinger
  0 siblings, 1 reply; 9+ messages in thread
From: Mark Salter @ 2012-04-20 21:47 UTC (permalink / raw)
  To: linux-kernel
  Cc: linux-fsdevel, Alexander Viro, Aurelien Jacquiot, Arnd Bergmann,
	Mark Salter

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.

Signed-off-by: Mark Salter <msalter@redhat.com>
---
 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(-)

diff --git a/arch/c6x/include/asm/elf.h b/arch/c6x/include/asm/elf.h
index d57865b..6f592a2 100644
--- a/arch/c6x/include/asm/elf.h
+++ b/arch/c6x/include/asm/elf.h
@@ -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.
diff --git a/arch/c6x/include/asm/mmu.h b/arch/c6x/include/asm/mmu.h
index 41592bf..4467e77 100644
--- a/arch/c6x/include/asm/mmu.h
+++ b/arch/c6x/include/asm/mmu.h
@@ -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 */
diff --git a/arch/c6x/include/asm/ptrace.h b/arch/c6x/include/asm/ptrace.h
index 21e8d79..b04ff59 100644
--- a/arch/c6x/include/asm/ptrace.h
+++ b/arch/c6x/include/asm/ptrace.h
@@ -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
diff --git a/arch/c6x/kernel/process.c b/arch/c6x/kernel/process.c
index 7ca8c41..e12adf0 100644
--- a/arch/c6x/kernel/process.c
+++ b/arch/c6x/kernel/process.c
@@ -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;
+}
diff --git a/fs/Kconfig.binfmt b/fs/Kconfig.binfmt
index e95d1b6..e851721 100644
--- a/fs/Kconfig.binfmt
+++ b/fs/Kconfig.binfmt
@@ -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
-- 
1.7.9.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH] C6X: add support to build with BINFMT_ELF_FDPIC
  2012-04-20 21:47 [PATCH] C6X: add support to build with BINFMT_ELF_FDPIC Mark Salter
@ 2012-04-21  5:01   ` Mike Frysinger
  0 siblings, 0 replies; 9+ messages in thread
From: Mike Frysinger @ 2012-04-21  5:01 UTC (permalink / raw)
  To: Mark Salter
  Cc: linux-kernel, linux-fsdevel, Alexander Viro, Aurelien Jacquiot,
	Arnd Bergmann

On Fri, Apr 20, 2012 at 17:47, Mark Salter wrote:
> --- a/arch/c6x/kernel/process.c
> +++ b/arch/c6x/kernel/process.c
>
> +
> +/* 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 */

> --- a/fs/Kconfig.binfmt
> +++ b/fs/Kconfig.binfmt
>
>  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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] C6X: add support to build with BINFMT_ELF_FDPIC
@ 2012-04-21  5:01   ` Mike Frysinger
  0 siblings, 0 replies; 9+ messages in thread
From: Mike Frysinger @ 2012-04-21  5:01 UTC (permalink / raw)
  To: Mark Salter
  Cc: linux-kernel, linux-fsdevel, Alexander Viro, Aurelien Jacquiot,
	Arnd Bergmann

On Fri, Apr 20, 2012 at 17:47, Mark Salter wrote:
> --- a/arch/c6x/kernel/process.c
> +++ b/arch/c6x/kernel/process.c
>
> +
> +/* 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 */

> --- a/fs/Kconfig.binfmt
> +++ b/fs/Kconfig.binfmt
>
>  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 majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] C6X: add support to build with BINFMT_ELF_FDPIC
  2012-04-21  5:01   ` Mike Frysinger
  (?)
@ 2012-04-22 21:21   ` Mark Salter
  2012-04-22 21:35     ` Sam Ravnborg
  2012-04-22 22:09       ` Mike Frysinger
  -1 siblings, 2 replies; 9+ messages in thread
From: Mark Salter @ 2012-04-22 21:21 UTC (permalink / raw)
  To: Mike Frysinger
  Cc: linux-kernel, linux-fsdevel, Alexander Viro, Aurelien Jacquiot,
	Arnd Bergmann

On Sat, 2012-04-21 at 01:01 -0400, Mike Frysinger wrote:
> On Fri, Apr 20, 2012 at 17:47, Mark Salter wrote:
> > --- a/arch/c6x/kernel/process.c
> > +++ b/arch/c6x/kernel/process.c
> >
> > +
> > +/* 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.

> 
> > --- a/fs/Kconfig.binfmt
> > +++ b/fs/Kconfig.binfmt
> >
> >  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.

> -mike



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] C6X: add support to build with BINFMT_ELF_FDPIC
  2012-04-22 21:21   ` Mark Salter
@ 2012-04-22 21:35     ` Sam Ravnborg
  2012-04-23  0:55       ` Mark Salter
  2012-04-22 22:09       ` Mike Frysinger
  1 sibling, 1 reply; 9+ messages in thread
From: Sam Ravnborg @ 2012-04-22 21:35 UTC (permalink / raw)
  To: Mark Salter
  Cc: Mike Frysinger, linux-kernel, linux-fsdevel, Alexander Viro,
	Aurelien Jacquiot, Arnd Bergmann

> > 
> > > --- a/fs/Kconfig.binfmt
> > > +++ b/fs/Kconfig.binfmt
> > >
> > >  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.
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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] C6X: add support to build with BINFMT_ELF_FDPIC
  2012-04-22 21:21   ` Mark Salter
@ 2012-04-22 22:09       ` Mike Frysinger
  2012-04-22 22:09       ` Mike Frysinger
  1 sibling, 0 replies; 9+ messages in thread
From: Mike Frysinger @ 2012-04-22 22:09 UTC (permalink / raw)
  To: Mark Salter
  Cc: linux-kernel, linux-fsdevel, Alexander Viro, Aurelien Jacquiot,
	Arnd Bergmann

On Sun, Apr 22, 2012 at 17:21, Mark Salter wrote:
> On Sat, 2012-04-21 at 01:01 -0400, Mike Frysinger wrote:
>> On Fri, Apr 20, 2012 at 17:47, Mark Salter wrote:
>> > --- a/fs/Kconfig.binfmt
>> > +++ b/fs/Kconfig.binfmt
>> >
>> >  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.

seems like it'd be fairly trivial to convert it.  there aren't many
references in the kernel tree to TMS320C6X.
-mike

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] C6X: add support to build with BINFMT_ELF_FDPIC
@ 2012-04-22 22:09       ` Mike Frysinger
  0 siblings, 0 replies; 9+ messages in thread
From: Mike Frysinger @ 2012-04-22 22:09 UTC (permalink / raw)
  To: Mark Salter
  Cc: linux-kernel, linux-fsdevel, Alexander Viro, Aurelien Jacquiot,
	Arnd Bergmann

On Sun, Apr 22, 2012 at 17:21, Mark Salter wrote:
> On Sat, 2012-04-21 at 01:01 -0400, Mike Frysinger wrote:
>> On Fri, Apr 20, 2012 at 17:47, Mark Salter wrote:
>> > --- a/fs/Kconfig.binfmt
>> > +++ b/fs/Kconfig.binfmt
>> >
>> >  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.

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 majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] C6X: add support to build with BINFMT_ELF_FDPIC
  2012-04-22 21:35     ` Sam Ravnborg
@ 2012-04-23  0:55       ` Mark Salter
  2012-04-23  3:04         ` Mike Frysinger
  0 siblings, 1 reply; 9+ messages in thread
From: Mark Salter @ 2012-04-23  0:55 UTC (permalink / raw)
  To: Sam Ravnborg
  Cc: Mike Frysinger, linux-kernel, linux-fsdevel, Alexander Viro,
	Aurelien Jacquiot, Arnd Bergmann

On Sun, 2012-04-22 at 23:35 +0200, Sam Ravnborg wrote:
> 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



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] C6X: add support to build with BINFMT_ELF_FDPIC
  2012-04-23  0:55       ` Mark Salter
@ 2012-04-23  3:04         ` Mike Frysinger
  0 siblings, 0 replies; 9+ messages in thread
From: Mike Frysinger @ 2012-04-23  3:04 UTC (permalink / raw)
  To: Mark Salter
  Cc: Sam Ravnborg, linux-kernel, linux-fsdevel, Alexander Viro,
	Aurelien Jacquiot, Arnd Bergmann

On Sun, Apr 22, 2012 at 20:55, Mark Salter wrote:
> On Sun, 2012-04-22 at 23:35 +0200, Sam Ravnborg wrote:
>> 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

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2012-04-23  3:05 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-04-20 21:47 [PATCH] C6X: add support to build with BINFMT_ELF_FDPIC Mark Salter
2012-04-21  5:01 ` Mike Frysinger
2012-04-21  5:01   ` Mike Frysinger
2012-04-22 21:21   ` Mark Salter
2012-04-22 21:35     ` Sam Ravnborg
2012-04-23  0:55       ` Mark Salter
2012-04-23  3:04         ` Mike Frysinger
2012-04-22 22:09     ` Mike Frysinger
2012-04-22 22:09       ` Mike Frysinger

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.