Re: copy to suer space
H. Peter Anvin (hpa@zytor.com)
23 Nov 2001 15:53:54 -0800
Followup to: <200111231440.fANEeh213167@criticalsoftware.com>
By author: Luís Henriques
<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>
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/