Hi~ I'm working on xv6 and I'm stuck on the validate test in usertests.c
. There is asm code and I'm quite confused about what exactly is going on here. Would you like to explain that for me?
// try to crash the kernel by passing in a badly placed integer
void
validateint(int *p)
{
int res;
printf(stdout,"in validateint\n");
asm("mov %%esp, %%ebx\n\t"
"mov %3, %%esp\n\t"
"int %2\n\t"
"mov %%ebx, %%esp" :
"=a" (res) :
"a" (SYS_sleep), "n" (T_SYSCALL), "c" (p) :
"ebx");
printf(stdout,"%d \n",res);
}
I found that res
is increasing with p
but at some point res
becomes 0 and then it becomes -1. The whole function stucks as long as res
turn to -1. I have no idea what happened here.