void test_task_a(void)
{
int i, j, k;
k = 0;
/* Normal: trigger #GP */
/*asm (
"int $32\n\t"
);*/
while(TRUE){
for(i = 0; i < 100; i++){
for(j = 0; j < 10000; j++){} //delay
}
printf("#{A}-> %d", k++);
/* Error: No trigger #GP */
asm (
"int $32\n\t"
);
}
}
`First of all, the function's CPL = 1, the interrupt gate DPL = 0, the interrupt target code segment DPL = 0, when the soft interrupt is called, it does not meet the authority management, and the #GP exception will be triggered under normal circumstances.
The soft interrupt is called from different positions in a function, position 1 is normal, and position 2 returns to real mode from protection mode directly. I deliberately set the register information before calling the soft interrupt in position 2 to be the same as that before calling the soft interrupt in position 1, and still return to the real mode from the protected mode. why is this happening? `