Re: copy to suer space

H. Peter Anvin
2001-11-23T23:54:45Z

Followup to: <200111231440.fANEeh213167@criticalsoftware.com>
By author: =?iso-8859-1?q?Lu=EDs=20Henriques?=
<lhenriques@criticalsoftware.com>
In newsgroup: linux.dev.kernel
>
> When I read the timestamp («rdtsc»), a value is returned to edx:eax. This
> code works just fine when I put it in the process stack. The problem is when
> I want to compare %edx instead of %eax, that is:
>
> rdtsc
> movl %edx, %ecx
> addl $0x1, %ecx
> loop:
> rdtsc
> cmp %ecx, %edx
> jb loop
>
> This is supposed to take much more time than the other loop. When I write
> this code to the stack of my process, a segmentation fault occurs after some
> time. Why? I'm not changing the stack at any moment! (By the way, the stack
> pointer is pointing to the end of my code...)
>

Did you remember to restore all the registers, including %eax and
%eflags, before you return?

-hpa
--
<hpa@transmeta.com> at work, <hpa@zytor.com> in private!
"Unix gives you enough rope to shoot yourself in the foot."
http://www.zytor.com/~hpa/puzzle.txt <amsp@zytor.com>