[PATCH] sh: Retrieve SHMLBA value from auxiliary vector
Bernhard Reutner-Fischer
rep.dot.nop at gmail.com
Wed Oct 27 20:08:00 UTC 2010
On Tue, Sep 21, 2010 at 01:09:27PM +0200, Carmelo AMOROSO wrote:
>Due to aliasing issue on SH-4 and SH-3 7705 the SHMLBA was set to be
>4 * pagesize, that is misleading for those SH core variants that are not
>affected by this issue.
>
>Starting from kernel 2.6.25-rc1 for SH cpu, the L1D cache shape info
>is passed to the user space through the auxiliary vector.From the cache shape
>it is possible to decode the dcache way size and compute accurately the value
>for shared memory alignment constraint SHMLBA.
>
>Within the dynamic linker, we don't need to access to the extra entries of the
>auxvect, we do this only into __uClibc_main for those architectures that define
>to have extra entries. When initialising the auxvt, the cache shape is read and
>decoded, through an arch specific macro DL_PLATFORM_AUXV.
>
>Signed-off-by: Salvatore Cro <salvatore.cro at st.com>
>Signed-off-by: Carmelo Amoroso <carmelo.amoroso at st.com>
>---
> Makefile.in | 4 +-
> include/auxvect.h | 18 ++++++++
> ldso/ldso/dl-startup.c | 5 +-
> libc/misc/elf/Makefile.in | 4 ++
> libc/misc/elf/dl-support.c | 23 ++++++++++
> libc/misc/internals/__uClibc_main.c | 30 ++++++------
> libc/sysdeps/linux/common/bits/auxvect.h | 5 ++
> libc/sysdeps/linux/common/bits/kernel-features.h | 5 ++-
> libc/sysdeps/linux/sh/Makefile.arch | 7 +++
> libc/sysdeps/linux/sh/bits/auxvect.h | 6 +++
> libc/sysdeps/linux/sh/bits/shm.h | 12 +++++
> libc/sysdeps/linux/sh/dl-support.c | 52 ++++++++++++++++++++++
> test/Makefile | 1 +
> 13 files changed, 153 insertions(+), 19 deletions(-)
> create mode 100644 include/auxvect.h
> create mode 100644 libc/sysdeps/linux/common/bits/auxvect.h
> create mode 100644 libc/sysdeps/linux/sh/bits/auxvect.h
> create mode 100644 libc/sysdeps/linux/sh/dl-support.c
>
>diff --git a/Makefile.in b/Makefile.in
>index 348bc0c..cedd99b 100644
>--- a/Makefile.in
>+++ b/Makefile.in
>@@ -219,7 +219,9 @@ HEADERS_RM- := \
> tls.h \
> rpc/des_crypt.h \
> rpc/key_prot.h \
>- rpc/rpc_des.h
>+ rpc/rpc_des.h \
>+ auxvect.h \
>+ bits/auxvect.h \
> HEADERS_RM-$(UCLIBC_HAS_UTMPX) += \
> bits/utmpx.h \
> utmpx.h
>diff --git a/include/auxvect.h b/include/auxvect.h
>new file mode 100644
>index 0000000..5e54a1b
>--- /dev/null
>+++ b/include/auxvect.h
>@@ -0,0 +1,18 @@
>+#include <bits/auxvect.h>
>+
>+/* Check for any broken settings, default value are fine anyway */
default value is or default values are
>+#if (!defined AT_BASE_NUM) || (defined AT_BASE_NUM && !AT_BASE_NUM)
>+#error "AT_BASE_NUM must be defined and must be not null"
>+#elif !defined AT_ARCH_EXTRAS
>+#error "AT_ARCH_EXTRAS must be defined, even if 0"
>+#endif
>+
>+
>+#ifdef IS_IN_rtld
>+/* For the ld.so we are interested to fewer entries from the auxvect */
interrested in
>+#define AT_NUM AT_BASE_NUM
>+#elif IS_IN_libc
>+#define AT_NUM (AT_BASE_NUM + AT_ARCH_EXTRAS)
>+#else
>+#error "This header is intended to not be used outside of ld.so or libc"
is not intended to be used outside of ld.so or libc
>+#endif
>diff --git a/ldso/ldso/dl-startup.c b/ldso/ldso/dl-startup.c
>index a51b583..d8f270e 100644
>--- a/ldso/ldso/dl-startup.c
>+++ b/ldso/ldso/dl-startup.c
>@@ -93,6 +93,7 @@
>
> /* Pull in all the arch specific stuff */
> #include "dl-startup.h"
>+#include <auxvect.h>
>
> /* Static declarations */
> static int (*_dl_elf_main) (int, char **, char **);
>@@ -119,7 +120,7 @@ DL_START(unsigned long args)
> ElfW(Ehdr) *header;
> struct elf_resolve tpnt_tmp;
> struct elf_resolve *tpnt = &tpnt_tmp;
>- ElfW(auxv_t) auxvt[AT_EGID + 1];
>+ ElfW(auxv_t) auxvt[AT_NUM];
> ElfW(Dyn) *dpnt;
> uint32_t *p32;
>
>@@ -158,7 +159,7 @@ DL_START(unsigned long args)
> while (*aux_dat) {
> ElfW(auxv_t) *auxv_entry = (ElfW(auxv_t) *) aux_dat;
>
>- if (auxv_entry->a_type <= AT_EGID) {
>+ if (auxv_entry->a_type < AT_NUM) {
> _dl_memcpy(&(auxvt[auxv_entry->a_type]), auxv_entry, sizeof(ElfW(auxv_t)));
> }
> aux_dat += 2;
>diff --git a/libc/misc/elf/Makefile.in b/libc/misc/elf/Makefile.in
>index 1b4bd8b..e803894 100644
>--- a/libc/misc/elf/Makefile.in
>+++ b/libc/misc/elf/Makefile.in
>@@ -10,6 +10,10 @@ libc_a_CSRC = dl-support.c dl-core.c dl-iterate-phdr.c
> CFLAGS-dl-iterate-phdr.c=-D_GNU_SOURCE -I$(top_srcdir)ldso/ldso/$(TARGET_ARCH) -I$(top_srcdir)ldso/include
> CFLAGS-dl-core.c=-I$(top_srcdir)ldso/ldso/$(TARGET_ARCH) -I$(top_srcdir)ldso/include
>
>+ifeq ($(TARGET_ARCH),sh)
>+libc_a_CSRC := $(filter-out dl-support.c,$(libc_a_CSRC))
>+endif
I don't like that conceptionally.
Don't we already prefer arch-specific impls over the common ones, even
in misc/elf?
>+
> MISC_ELF_OUT:=$(top_builddir)libc/misc/elf
> MISC_ELF_OBJ:=$(patsubst %.c,$(MISC_ELF_OUT)/%.o,$(libc_a_CSRC))
>
[]
>diff --git a/libc/sysdeps/linux/common/bits/auxvect.h b/libc/sysdeps/linux/common/bits/auxvect.h
>new file mode 100644
>index 0000000..b027e69
>--- /dev/null
>+++ b/libc/sysdeps/linux/common/bits/auxvect.h
>@@ -0,0 +1,5 @@
>+#include <elf.h>
>+
>+/* Minimum number of AT entries from auxiliar vector */
>+#define AT_BASE_NUM (AT_EGID + 1)
>+#define AT_ARCH_EXTRAS 0
missing copyright info.
>diff --git a/test/Makefile b/test/Makefile
>index 857ac8a..e416e12 100644
>--- a/test/Makefile
>+++ b/test/Makefile
>@@ -42,6 +42,7 @@ ifeq ($(HAS_NO_THREADS),y)
> DIRS := $(filter-out pthread,$(DIRS))
> endif
>
>+DIRS := $(filter-out math,$(DIRS))
unrelated.
More information about the uClibc
mailing list