aboutsummaryrefslogtreecommitdiffstats
path: root/fs/binfmt_elf_fdpic.c
diff options
context:
space:
mode:
authorPaul Mundt <lethal@linux-sh.org>2008-10-16 01:04:15 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-10-16 14:21:46 -0400
commitec23847d6cfe445ba9a1a5ec513297f4cc0ada53 (patch)
tree3c4dbdec1546023cc87ab058355e01a7c817e1af /fs/binfmt_elf_fdpic.c
parent758222f84261a6a808c4d1dcd443f90c1baaa875 (diff)
binfmt_elf_fdpic: support auxvec base platform string
Commit 483fad1c3fa1060d7e6710e84a065ad514571739 ("ELF loader support for auxvec base platform string") introduced AT_BASE_PLATFORM, but only implemented it for binfmt_elf. Given that AT_VECTOR_SIZE_BASE is unconditionally enlarged for us, and it's only optionally added in for the platforms that set ELF_BASE_PLATFORM, wire it up for binfmt_elf_fdpic, too. Signed-off-by: Paul Mundt <lethal@linux-sh.org> Acked-by: David Howells <dhowells@redhat.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/binfmt_elf_fdpic.c')
-rw-r--r--fs/binfmt_elf_fdpic.c50
1 files changed, 43 insertions, 7 deletions
diff --git a/fs/binfmt_elf_fdpic.c b/fs/binfmt_elf_fdpic.c
index 80c1f952ef78..e4eb472558ca 100644
--- a/fs/binfmt_elf_fdpic.c
+++ b/fs/binfmt_elf_fdpic.c
@@ -455,6 +455,16 @@ error_kill:
455} 455}
456 456
457/*****************************************************************************/ 457/*****************************************************************************/
458
459#ifndef ELF_BASE_PLATFORM
460/*
461 * AT_BASE_PLATFORM indicates the "real" hardware/microarchitecture.
462 * If the arch defines ELF_BASE_PLATFORM (in asm/elf.h), the value
463 * will be copied to the user stack in the same manner as AT_PLATFORM.
464 */
465#define ELF_BASE_PLATFORM NULL
466#endif
467
458/* 468/*
459 * present useful information to the program 469 * present useful information to the program
460 */ 470 */
@@ -466,8 +476,8 @@ static int create_elf_fdpic_tables(struct linux_binprm *bprm,
466 unsigned long sp, csp, nitems; 476 unsigned long sp, csp, nitems;
467 elf_caddr_t __user *argv, *envp; 477 elf_caddr_t __user *argv, *envp;
468 size_t platform_len = 0, len; 478 size_t platform_len = 0, len;
469 char *k_platform; 479 char *k_platform, *k_base_platform;
470 char __user *u_platform, *p; 480 char __user *u_platform, *u_base_platform, *p;
471 long hwcap; 481 long hwcap;
472 int loop; 482 int loop;
473 int nr; /* reset for each csp adjustment */ 483 int nr; /* reset for each csp adjustment */
@@ -483,11 +493,14 @@ static int create_elf_fdpic_tables(struct linux_binprm *bprm,
483 return -EFAULT; 493 return -EFAULT;
484#endif 494#endif
485 495
486 /* get hold of platform and hardware capabilities masks for the machine
487 * we are running on. In some cases (Sparc), this info is impossible
488 * to get, in others (i386) it is merely difficult.
489 */
490 hwcap = ELF_HWCAP; 496 hwcap = ELF_HWCAP;
497
498 /*
499 * If this architecture has a platform capability string, copy it
500 * to userspace. In some cases (Sparc), this info is impossible
501 * for userspace to get any other way, in others (i386) it is
502 * merely difficult.
503 */
491 k_platform = ELF_PLATFORM; 504 k_platform = ELF_PLATFORM;
492 u_platform = NULL; 505 u_platform = NULL;
493 506
@@ -499,6 +512,21 @@ static int create_elf_fdpic_tables(struct linux_binprm *bprm,
499 return -EFAULT; 512 return -EFAULT;
500 } 513 }
501 514
515 /*
516 * If this architecture has a "base" platform capability
517 * string, copy it to userspace.
518 */
519 k_base_platform = ELF_BASE_PLATFORM;
520 u_base_platform = NULL;
521
522 if (k_base_platform) {
523 platform_len = strlen(k_base_platform) + 1;
524 sp -= platform_len;
525 u_base_platform = (char __user *) sp;
526 if (__copy_to_user(u_base_platform, k_base_platform, platform_len) != 0)
527 return -EFAULT;
528 }
529
502#if defined(__i386__) && defined(CONFIG_SMP) 530#if defined(__i386__) && defined(CONFIG_SMP)
503 /* in some cases (e.g. Hyper-Threading), we want to avoid L1 evictions 531 /* in some cases (e.g. Hyper-Threading), we want to avoid L1 evictions
504 * by the processes running on the same package. One thing we can do is 532 * by the processes running on the same package. One thing we can do is
@@ -543,7 +571,8 @@ static int create_elf_fdpic_tables(struct linux_binprm *bprm,
543 /* force 16 byte _final_ alignment here for generality */ 571 /* force 16 byte _final_ alignment here for generality */
544#define DLINFO_ITEMS 13 572#define DLINFO_ITEMS 13
545 573
546 nitems = 1 + DLINFO_ITEMS + (k_platform ? 1 : 0) + AT_VECTOR_SIZE_ARCH; 574 nitems = 1 + DLINFO_ITEMS + (k_platform ? 1 : 0) +
575 (k_base_platform ? 1 : 0) + AT_VECTOR_SIZE_ARCH;
547 576
548 csp = sp; 577 csp = sp;
549 sp -= nitems * 2 * sizeof(unsigned long); 578 sp -= nitems * 2 * sizeof(unsigned long);
@@ -575,6 +604,13 @@ static int create_elf_fdpic_tables(struct linux_binprm *bprm,
575 (elf_addr_t) (unsigned long) u_platform); 604 (elf_addr_t) (unsigned long) u_platform);
576 } 605 }
577 606
607 if (k_base_platform) {
608 nr = 0;
609 csp -= 2 * sizeof(unsigned long);
610 NEW_AUX_ENT(AT_BASE_PLATFORM,
611 (elf_addr_t) (unsigned long) u_base_platform);
612 }
613
578 nr = 0; 614 nr = 0;
579 csp -= DLINFO_ITEMS * 2 * sizeof(unsigned long); 615 csp -= DLINFO_ITEMS * 2 * sizeof(unsigned long);
580 NEW_AUX_ENT(AT_HWCAP, hwcap); 616 NEW_AUX_ENT(AT_HWCAP, hwcap);