* some question about LR of task_pt_regs
@ 2015-10-19 9:55 yoma sophian
2015-10-26 10:40 ` Russell King - ARM Linux
0 siblings, 1 reply; 2+ messages in thread
From: yoma sophian @ 2015-10-19 9:55 UTC (permalink / raw)
To: linux-arm-kernel
hi all:
I use linaro toolchain which libc is compile in thumb mode and if any
user mode program call sleep, the lr of its task_pt_regs will be 0, no
matter how many function level I called.
Would anyone let me know where the source code that updates LR of
task_pt_regs in arm?
appreciate your kind help in advancd,
Below are environments and experiments I did:
a. I use below linaro toolchain to compile a user mode program.
https://releases.linaro.org/14.08/components/toolchain/binaries/gcc-linaro-arm-linux-gnueabihf-4.9-2014.08_linux.tar.xz
b. my kerenl is 3.10
c. my cpu is cortexA9 mp core.
I did below things in a simple user mode program:
1. create a child thread
2. both parent and child do the while loop to sleep like below
function call depth
(I purposely use 2 level call function before sleep)
void go_to_sleep_lv2(void)
{
printf( "%s \n",__func__);
while(1) {
sleep(30);
}
}
void go_to_sleep_lv1(void)
{
printf( "%s \n",__func__);
go_to_sleep_lv2();
}
void * simple_thread_1(void * dummy)
{
go_to_sleep_lv1();
return NULL;
}
int main()
{
int error;
pthread_t tid0 = 0;
error = pthread_create(&tid0, 0, &simple_thread_1, 0);
assert(error == 0);
while(1){
go_to_sleep_lv1();
}
error = pthread_join(tid0, NULL);
assert(error == 0);
return 0;
}
I found the lr of parent and child task_pt_regs are all 0 with below
print patch I add in kernel.
diff --git a/kernel/hrtimer.c b/kernel/hrtimer.c
index 3ee4d06..3fff0fe 100644
--- a/kernel/hrtimer.c
+++ b/kernel/hrtimer.c
@@ -1646,7 +1646,10 @@ SYSCALL_DEFINE2(nanosleep, struct timespec
__user *, rqtp,
struct timespec __user *, rmtp)
{
struct timespec tu;
-
+ struct pt_regs *regs;
+ regs = task_pt_regs(current);
+ printk(KERN_ERR"calling %s, current->pid = %d, current->common
=%s regs->ARM_lr= 0x%lx\n", __func__, current->pid,
current->comm,regs->ARM_lr)
if (copy_from_user(&tu, rqtp, sizeof(tu)))
return -EFAULT;
the kernel output like below:
[ 1961.298882] calling SYSC_nanosleep, current->pid = 1248,
current->common =simple.thread regs->ARM_lr= 0x0
I found something instresting:
1. the toolchain's libc is build in thumb mode.
2. if I change while loop like belwo without calling sleep.like below,
the LR of task_pt_regs will be not 0.
void go_to_sleep_lv2(void)
{
printf( "%s \n",__func__);
while(1);
}
^ permalink raw reply related [flat|nested] 2+ messages in thread
* some question about LR of task_pt_regs
2015-10-19 9:55 some question about LR of task_pt_regs yoma sophian
@ 2015-10-26 10:40 ` Russell King - ARM Linux
0 siblings, 0 replies; 2+ messages in thread
From: Russell King - ARM Linux @ 2015-10-26 10:40 UTC (permalink / raw)
To: linux-arm-kernel
On Mon, Oct 19, 2015 at 05:55:29PM +0800, yoma sophian wrote:
> hi all:
> I use linaro toolchain which libc is compile in thumb mode and if any
> user mode program call sleep, the lr of its task_pt_regs will be 0, no
> matter how many function level I called.
It depends on the userspace code at the time that the system call is
made. If it's setting LR to zero, then you'll read zero. I don't
think it has anything to do with the toolchain either. Check the
libc code around the site for the system call.
--
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-10-26 10:40 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-10-19 9:55 some question about LR of task_pt_regs yoma sophian
2015-10-26 10:40 ` Russell King - ARM Linux
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).