linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] elf loader support for auxvec base platform string
@ 2008-07-03 23:41 Nathan Lynch
  2008-07-04  2:19 ` Roland McGrath
  2008-07-04  2:35 ` Mikael Pettersson
  0 siblings, 2 replies; 20+ messages in thread
From: Nathan Lynch @ 2008-07-03 23:41 UTC (permalink / raw)
  To: linux-kernel; +Cc: linuxppc-dev, Paul Mackerras, McGrath, Roland

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+".

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".

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>
---

Next patch implements ELF/AT_BASE_PLATFORM for powerpc.

 fs/binfmt_elf.c |   23 +++++++++++++++++++++++
 1 files changed, 23 insertions(+), 0 deletions(-)

diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
index d48ff5f..834c2c4 100644
--- a/fs/binfmt_elf.c
+++ b/fs/binfmt_elf.c
@@ -131,6 +131,10 @@ static int padzero(unsigned long elf_bss)
 #define STACK_ALLOC(sp, len) ({ sp -= len ; sp; })
 #endif
 
+#ifndef ELF_BASE_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 +146,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 +178,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 */
@@ -208,6 +227,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);
 	}
-- 
1.5.5.1

^ permalink raw reply related	[flat|nested] 20+ messages in thread
* Re: [PATCH 1/2] elf loader support for auxvec base platform string
@ 2008-07-07 15:14 Steven Munroe
  0 siblings, 0 replies; 20+ messages in thread
From: Steven Munroe @ 2008-07-07 15:14 UTC (permalink / raw)
  To: linuxppc-dev

Roland McGrath writes:

> I understand why you think so.  But let's not be too abstract.  The
> purpose of the addition is to drive ld.so's selection of libraries, yes?

The is one possible usage of this AT_BASE_PLATFORM. There is also a
requirement from performance tools and large applications to understand
their environment. As it needs to be a public and durable ABI.

Virtualization and multi-core are only going to make everyones life more
complicated. Applications and performance tools will require more info
about the system to do their jobs. This is the problem I am trying to
solve. And I thought this was the simplest way to solve several use
cases.

I proposes for this and the possible extension to library selection
because it would become part of the ABI and any application could
access it.

So if you want to propose another (Better) mechanism for ld.so library
search shaping I would be glad to discuss it.

But in my mind the requirement for AT_BASE_PLATFORM still stands.

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

end of thread, other threads:[~2008-07-08 18:32 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-07-03 23:41 [PATCH 1/2] elf loader support for auxvec base platform string Nathan Lynch
2008-07-04  2:19 ` Roland McGrath
2008-07-07  5:48   ` Benjamin Herrenschmidt
2008-07-07  6:18     ` Roland McGrath
2008-07-07  6:23       ` Benjamin Herrenschmidt
2008-07-07  6:35         ` Roland McGrath
2008-07-07  6:48           ` Benjamin Herrenschmidt
2008-07-07  7:49           ` Andreas Schwab
2008-07-07  9:31             ` Roland McGrath
2008-07-07 10:01               ` Andreas Schwab
2008-07-07 22:56                 ` Benjamin Herrenschmidt
2008-07-08  0:31                   ` Roland McGrath
2008-07-08  0:48                     ` Benjamin Herrenschmidt
2008-07-08 18:35                       ` Steven Munroe
2008-07-07 16:16       ` Nathan Lynch
2008-07-07 22:17     ` Nathan Lynch
2008-07-07 23:00       ` Benjamin Herrenschmidt
2008-07-04  2:35 ` Mikael Pettersson
2008-07-07 15:55   ` Nathan Lynch
  -- strict thread matches above, loose matches on Subject: below --
2008-07-07 15:14 Steven Munroe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).