All of lore.kernel.org
 help / color / mirror / Atom feed
From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
To: Nathan Lynch <ntl@pobox.com>
Cc: John Reiser <jreiser@BitWagon.com>,
	linux-kernel@vger.kernel.org, linuxppc-dev@ozlabs.org,
	Andrew Morton <akpm@linux-foundation.org>,
	torvalds@linux-foundation.org, roland@redhat.com
Subject: Re: [PATCH v4] elf loader support for auxvec base platform string
Date: Tue, 22 Jul 2008 12:03:11 +1000	[thread overview]
Message-ID: <1216692191.11027.177.camel@pasglop> (raw)
In-Reply-To: <20080721184846.GU9594@localdomain>

On Mon, 2008-07-21 at 13:48 -0500, Nathan Lynch wrote:
> Some IBM POWER-based platforms have the ability to run in a
> mode which mostly appears to the OS as a different processor from the
> actual hardware.  For example, a Power6 system may appear to be a
> Power5+, which makes the AT_PLATFORM value "power5+".  This means that
> programs are restricted to the ISA supported by Power5+;
> Power6-specific instructions are treated as illegal.
> 
> However, some applications (virtual machines, optimized libraries) can
> benefit from knowledge of the underlying CPU model.  A new aux vector
> entry, AT_BASE_PLATFORM, will denote the actual hardware.  For
> example, on a Power6 system in Power5+ compatibility mode, AT_PLATFORM
> will be "power5+" and AT_BASE_PLATFORM will be "power6".  The idea is
> that AT_PLATFORM indicates the instruction set supported, while
> AT_BASE_PLATFORM indicates the underlying microarchitecture.
> 
> If the architecture has defined ELF_BASE_PLATFORM, copy that value to
> the user stack in the same manner as ELF_PLATFORM.
> 
> Signed-off-by: Nathan Lynch <ntl@pobox.com>

Andrew, I'll merge that after John patch shows up if you give me your
Ack :-)

Cheers,
Ben.

> ---
> 
> Andrew Morton wrote:
> > OK.
> > 
> > But it conflicts directly with the already-queued
> > execve-filename-document-and-export-via-auxiliary-vector.patch (which
> > various potential reviewers blithely deleted - don't come complaining
> > to me!):
> > 
> 
> Rebased to -mm to resolve conflicts with
> execve-filename-document-and-export-via-auxiliary-vector.patch, and
> changed AT_BASE_PLATFORM to lowest unclaimed value (24).
> 
> 
>  fs/binfmt_elf.c        |   28 ++++++++++++++++++++++++++++
>  include/linux/auxvec.h |    6 +++++-
>  2 files changed, 33 insertions(+), 1 deletions(-)
> 
> diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
> index bad7d87..180f92b 100644
> --- a/fs/binfmt_elf.c
> +++ b/fs/binfmt_elf.c
> @@ -131,6 +131,15 @@ static int padzero(unsigned long elf_bss)
>  #define STACK_ALLOC(sp, len) ({ sp -= len ; sp; })
>  #endif
>  
> +#ifndef ELF_BASE_PLATFORM
> +/*
> + * AT_BASE_PLATFORM indicates the "real" hardware/microarchitecture.
> + * If the arch defines ELF_BASE_PLATFORM (in asm/elf.h), the value
> + * will be copied to the user stack in the same manner as AT_PLATFORM.
> + */
> +#define ELF_BASE_PLATFORM NULL
> +#endif
> +
>  static int
>  create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
>  		unsigned long load_addr, unsigned long interp_load_addr)
> @@ -142,7 +151,9 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
>  	elf_addr_t __user *envp;
>  	elf_addr_t __user *sp;
>  	elf_addr_t __user *u_platform;
> +	elf_addr_t __user *u_base_platform;
>  	const char *k_platform = ELF_PLATFORM;
> +	const char *k_base_platform = ELF_BASE_PLATFORM;
>  	int items;
>  	elf_addr_t *elf_info;
>  	int ei_index = 0;
> @@ -172,6 +183,19 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
>  			return -EFAULT;
>  	}
>  
> +	/*
> +	 * If this architecture has a "base" platform capability
> +	 * string, copy it to userspace.
> +	 */
> +	u_base_platform = NULL;
> +	if (k_base_platform) {
> +		size_t len = strlen(k_base_platform) + 1;
> +
> +		u_base_platform = (elf_addr_t __user *)STACK_ALLOC(p, len);
> +		if (__copy_to_user(u_base_platform, k_base_platform, len))
> +			return -EFAULT;
> +	}
> +
>  	/* Create the ELF interpreter info */
>  	elf_info = (elf_addr_t *)current->mm->saved_auxv;
>  	/* update AT_VECTOR_SIZE_BASE if the number of NEW_AUX_ENT() changes */
> @@ -209,6 +233,10 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
>  		NEW_AUX_ENT(AT_PLATFORM,
>  			    (elf_addr_t)(unsigned long)u_platform);
>  	}
> +	if (k_base_platform) {
> +		NEW_AUX_ENT(AT_BASE_PLATFORM,
> +			    (elf_addr_t)(unsigned long)u_base_platform);
> +	}
>  	if (bprm->interp_flags & BINPRM_FLAGS_EXECFD) {
>  		NEW_AUX_ENT(AT_EXECFD, bprm->interp_data);
>  	}
> diff --git a/include/linux/auxvec.h b/include/linux/auxvec.h
> index 0da17d1..d7afa9d 100644
> --- a/include/linux/auxvec.h
> +++ b/include/linux/auxvec.h
> @@ -26,9 +26,13 @@
>  
>  #define AT_SECURE 23   /* secure mode boolean */
>  
> +#define AT_BASE_PLATFORM 24	/* string identifying real platform, may
> +				 * differ from AT_PLATFORM. */
> +
>  #define AT_EXECFN  31	/* filename of program */
> +
>  #ifdef __KERNEL__
> -#define AT_VECTOR_SIZE_BASE 17 /* NEW_AUX_ENT entries in auxiliary table */
> +#define AT_VECTOR_SIZE_BASE 18 /* NEW_AUX_ENT entries in auxiliary table */
>    /* number of "#define AT_.*" above, minus {AT_NULL, AT_IGNORE, AT_NOTELF} */
>  #endif
>  

WARNING: multiple messages have this Message-ID (diff)
From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
To: Nathan Lynch <ntl@pobox.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	torvalds@linux-foundation.org, linuxppc-dev@ozlabs.org,
	linux-kernel@vger.kernel.org, roland@redhat.com,
	John Reiser <jreiser@BitWagon.com>
Subject: Re: [PATCH v4] elf loader support for auxvec base platform string
Date: Tue, 22 Jul 2008 12:03:11 +1000	[thread overview]
Message-ID: <1216692191.11027.177.camel@pasglop> (raw)
In-Reply-To: <20080721184846.GU9594@localdomain>

On Mon, 2008-07-21 at 13:48 -0500, Nathan Lynch wrote:
> Some IBM POWER-based platforms have the ability to run in a
> mode which mostly appears to the OS as a different processor from the
> actual hardware.  For example, a Power6 system may appear to be a
> Power5+, which makes the AT_PLATFORM value "power5+".  This means that
> programs are restricted to the ISA supported by Power5+;
> Power6-specific instructions are treated as illegal.
> 
> However, some applications (virtual machines, optimized libraries) can
> benefit from knowledge of the underlying CPU model.  A new aux vector
> entry, AT_BASE_PLATFORM, will denote the actual hardware.  For
> example, on a Power6 system in Power5+ compatibility mode, AT_PLATFORM
> will be "power5+" and AT_BASE_PLATFORM will be "power6".  The idea is
> that AT_PLATFORM indicates the instruction set supported, while
> AT_BASE_PLATFORM indicates the underlying microarchitecture.
> 
> If the architecture has defined ELF_BASE_PLATFORM, copy that value to
> the user stack in the same manner as ELF_PLATFORM.
> 
> Signed-off-by: Nathan Lynch <ntl@pobox.com>

Andrew, I'll merge that after John patch shows up if you give me your
Ack :-)

Cheers,
Ben.

> ---
> 
> Andrew Morton wrote:
> > OK.
> > 
> > But it conflicts directly with the already-queued
> > execve-filename-document-and-export-via-auxiliary-vector.patch (which
> > various potential reviewers blithely deleted - don't come complaining
> > to me!):
> > 
> 
> Rebased to -mm to resolve conflicts with
> execve-filename-document-and-export-via-auxiliary-vector.patch, and
> changed AT_BASE_PLATFORM to lowest unclaimed value (24).
> 
> 
>  fs/binfmt_elf.c        |   28 ++++++++++++++++++++++++++++
>  include/linux/auxvec.h |    6 +++++-
>  2 files changed, 33 insertions(+), 1 deletions(-)
> 
> diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
> index bad7d87..180f92b 100644
> --- a/fs/binfmt_elf.c
> +++ b/fs/binfmt_elf.c
> @@ -131,6 +131,15 @@ static int padzero(unsigned long elf_bss)
>  #define STACK_ALLOC(sp, len) ({ sp -= len ; sp; })
>  #endif
>  
> +#ifndef ELF_BASE_PLATFORM
> +/*
> + * AT_BASE_PLATFORM indicates the "real" hardware/microarchitecture.
> + * If the arch defines ELF_BASE_PLATFORM (in asm/elf.h), the value
> + * will be copied to the user stack in the same manner as AT_PLATFORM.
> + */
> +#define ELF_BASE_PLATFORM NULL
> +#endif
> +
>  static int
>  create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
>  		unsigned long load_addr, unsigned long interp_load_addr)
> @@ -142,7 +151,9 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
>  	elf_addr_t __user *envp;
>  	elf_addr_t __user *sp;
>  	elf_addr_t __user *u_platform;
> +	elf_addr_t __user *u_base_platform;
>  	const char *k_platform = ELF_PLATFORM;
> +	const char *k_base_platform = ELF_BASE_PLATFORM;
>  	int items;
>  	elf_addr_t *elf_info;
>  	int ei_index = 0;
> @@ -172,6 +183,19 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
>  			return -EFAULT;
>  	}
>  
> +	/*
> +	 * If this architecture has a "base" platform capability
> +	 * string, copy it to userspace.
> +	 */
> +	u_base_platform = NULL;
> +	if (k_base_platform) {
> +		size_t len = strlen(k_base_platform) + 1;
> +
> +		u_base_platform = (elf_addr_t __user *)STACK_ALLOC(p, len);
> +		if (__copy_to_user(u_base_platform, k_base_platform, len))
> +			return -EFAULT;
> +	}
> +
>  	/* Create the ELF interpreter info */
>  	elf_info = (elf_addr_t *)current->mm->saved_auxv;
>  	/* update AT_VECTOR_SIZE_BASE if the number of NEW_AUX_ENT() changes */
> @@ -209,6 +233,10 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
>  		NEW_AUX_ENT(AT_PLATFORM,
>  			    (elf_addr_t)(unsigned long)u_platform);
>  	}
> +	if (k_base_platform) {
> +		NEW_AUX_ENT(AT_BASE_PLATFORM,
> +			    (elf_addr_t)(unsigned long)u_base_platform);
> +	}
>  	if (bprm->interp_flags & BINPRM_FLAGS_EXECFD) {
>  		NEW_AUX_ENT(AT_EXECFD, bprm->interp_data);
>  	}
> diff --git a/include/linux/auxvec.h b/include/linux/auxvec.h
> index 0da17d1..d7afa9d 100644
> --- a/include/linux/auxvec.h
> +++ b/include/linux/auxvec.h
> @@ -26,9 +26,13 @@
>  
>  #define AT_SECURE 23   /* secure mode boolean */
>  
> +#define AT_BASE_PLATFORM 24	/* string identifying real platform, may
> +				 * differ from AT_PLATFORM. */
> +
>  #define AT_EXECFN  31	/* filename of program */
> +
>  #ifdef __KERNEL__
> -#define AT_VECTOR_SIZE_BASE 17 /* NEW_AUX_ENT entries in auxiliary table */
> +#define AT_VECTOR_SIZE_BASE 18 /* NEW_AUX_ENT entries in auxiliary table */
>    /* number of "#define AT_.*" above, minus {AT_NULL, AT_IGNORE, AT_NOTELF} */
>  #endif
>  


  reply	other threads:[~2008-07-22  2:03 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-07-15 23:58 AT_BASE_PLATFORM (v2) Nathan Lynch
2008-07-15 23:58 ` [PATCH] elf loader support for auxvec base platform string Nathan Lynch
2008-07-17  6:35   ` Benjamin Herrenschmidt
2008-07-17  6:35     ` Benjamin Herrenschmidt
2008-07-17  7:09     ` Andrew Morton
2008-07-17  7:09       ` Andrew Morton
2008-07-17 17:39       ` Nathan Lynch
2008-07-17 17:39         ` Nathan Lynch
2008-07-17 22:19       ` [PATCH v3] " Nathan Lynch
2008-07-17 22:19         ` Nathan Lynch
2008-07-17 22:42         ` Andrew Morton
2008-07-17 22:42           ` Andrew Morton
2008-07-17 23:35           ` John Reiser
2008-07-17 23:35             ` John Reiser
2008-07-18 18:28             ` Nathan Lynch
2008-07-18 18:28               ` Nathan Lynch
2008-07-18 20:31               ` John Reiser
2008-07-18 20:31                 ` John Reiser
2008-07-18 20:52                 ` Andrew Morton
2008-07-18 20:52                   ` Andrew Morton
2008-07-21  3:24               ` Benjamin Herrenschmidt
2008-07-21  3:24                 ` Benjamin Herrenschmidt
2008-07-21  3:40                 ` Andrew Morton
2008-07-21  3:40                   ` Andrew Morton
2008-07-21  9:33                   ` Benjamin Herrenschmidt
2008-07-21  9:33                     ` Benjamin Herrenschmidt
2008-07-21 18:48           ` [PATCH v4] " Nathan Lynch
2008-07-21 18:48             ` Nathan Lynch
2008-07-22  2:03             ` Benjamin Herrenschmidt [this message]
2008-07-22  2:03               ` Benjamin Herrenschmidt
2008-07-17 16:10     ` [PATCH] " Linus Torvalds
2008-07-17 16:10       ` Linus Torvalds
2008-07-17 19:35       ` Nathan Lynch
2008-07-17 19:35         ` Nathan Lynch
2008-07-21  3:19       ` Benjamin Herrenschmidt
2008-07-21  3:19         ` Benjamin Herrenschmidt
2008-07-15 23:58 ` [PATCH] enable AT_BASE_PLATFORM aux vector for powerpc Nathan Lynch

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1216692191.11027.177.camel@pasglop \
    --to=benh@kernel.crashing.org \
    --cc=akpm@linux-foundation.org \
    --cc=jreiser@BitWagon.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@ozlabs.org \
    --cc=ntl@pobox.com \
    --cc=roland@redhat.com \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.