[PATCH] Enable Android TLS on ARMv7 target

553 views
Skip to first unread message

Jim Huang

unread,
Nov 13, 2009, 5:50:21 AM11/13/09
to 0xlab...@googlegroups.com
Hello list,

At present, ARM TLS (Thread Local Storage) is turned off, and you can
check the kernel commit log:

commit bd56f9006e21115a5baf3368a5728680f4ddc1e6
Author: Rebecca Schultz Zavin <reb...@android.com>
Date: Wed Mar 11 21:15:03 2009 -0700

HACK: zoom2 turning off TLS reg. doesn't work otherwise, bug in bionic?

Signed-off-by: Rebecca Schultz Zavin <reb...@android.com>

diff --git a/arch/arm/mm/Kconfig b/arch/arm/mm/Kconfig
index d490f37..9a6a482 100644
--- a/arch/arm/mm/Kconfig
+++ b/arch/arm/mm/Kconfig
@@ -667,7 +667,7 @@ config TLS_REG_EMUL
config HAS_TLS_REG
bool
depends on !TLS_REG_EMUL
- default y if SMP || CPU_32v7
+ default n if SMP || CPU_32v7
help
This selects support for the CP15 thread register.
It is defined to be available on some ARMv6 processors (including

If you would like to re-enable, just revert the above change, and
kernel config will now get new entry:
CONFIG_HAS_TLS_REG=y

Rebuild the kernel and apply patch: 'android-enable-tls.patch'

The attached patch contains the experimental changes to enable TLS in
userspace (Android bionic and frameworks/base).

NOTE: It shall be verified fully, and I just attempt to perform
performance tests.

Sincerely,
Jim Huang (jserv)
http://0xlab.org/
android-enable-tls.patch

Thinker Li

unread,
Nov 13, 2009, 8:59:47 PM11/13/09
to 0xlab...@googlegroups.com, js...@0xlab.org
From: Jim Huang <js...@0xlab.org>
Subject: [0xlab-devel] [PATCH] Enable Android TLS on ARMv7 target
Date: Fri, 13 Nov 2009 18:50:21 +0800

> Hello list,
>
> At present, ARM TLS (Thread Local Storage) is turned off, and you can
> check the kernel commit log:
>
> commit bd56f9006e21115a5baf3368a5728680f4ddc1e6
> Author: Rebecca Schultz Zavin <reb...@android.com>
> Date: Wed Mar 11 21:15:03 2009 -0700
>
> HACK: zoom2 turning off TLS reg. doesn't work otherwise, bug in bionic?
>

Weir!! TLS should work. Some applications, include media server, rely
on TLS, and they work. It must be something goes wrong. According
content of attached patch, oringal, __get_tls is pointed to
0xffff0fe0, a fixed address. That address should be a predefined
address in the range of prelinked library or a block managed by
linker. I don't think this bug should be fixed in this way. I will
investigate the issue.

Craig Newell

unread,
Nov 17, 2009, 9:17:35 AM11/17/09
to 0xlab-devel
Hi There,

On Nov 13, 8:59 pm, Thinker Li <thin...@branda.to> wrote:
> Weir!! TLS should work.  Some applications, include media server, rely
> on TLS, and they work.  It must be something goes wrong.  According
> content of attached patch, oringal, __get_tls is pointed to
> 0xffff0fe0, a fixed address.  That address should be a predefined
> address in the range of prelinked library or a block managed by
> linker.  I don't think this bug should be fixed in this way.  I will
> investigate the issue.

Yes ... TLS is working for me by having bionic, etc. always call the
0xffff0fe0 where
the linux kernel places either the mcr instruction for the coprocessor
TLS support or
a software emulation function. That way the user space works no matter
if the kernel
has been compiled with TLS register support or with software TLS.

Thanks,

CraigN
Reply all
Reply to author
Forward
0 new messages