The second control transfer instruction following the sti
Posted: Fri Dec 09, 2011 4:53 am
Hi, everyone
I'm writing a toy os and come across a problem. The problem can be reproduced like below.
static inline void my_sti()
{
asm volatile("sti\n\t"
"jmp 1f\n\t"
"1: \n\t"
"jmp 2f\n\t"
"2f"
: : :"memory");
}
I find that the second control transfer instruction following the sti MUST trigger an exception, which in turn loads the cs and eip with garbage values. I've also tried ret and call instead of jmp and met the same abnormal behavior. I have no any idea why this happens. I guess the first control transfer instruction doesn't trigger an exception because of the delays of sti. If it would help, I debug my code using bochs + gdb.
I'm writing a toy os and come across a problem. The problem can be reproduced like below.
static inline void my_sti()
{
asm volatile("sti\n\t"
"jmp 1f\n\t"
"1: \n\t"
"jmp 2f\n\t"
"2f"
: : :"memory");
}
I find that the second control transfer instruction following the sti MUST trigger an exception, which in turn loads the cs and eip with garbage values. I've also tried ret and call instead of jmp and met the same abnormal behavior. I have no any idea why this happens. I guess the first control transfer instruction doesn't trigger an exception because of the delays of sti. If it would help, I debug my code using bochs + gdb.