189 |
{ |
{ |
190 |
SegmentCache *dt; |
SegmentCache *dt; |
191 |
uint8_t *ptr, *ssp; |
uint8_t *ptr, *ssp; |
192 |
int type, dpl, selector, ss_dpl; |
int type, dpl, selector, ss_dpl, cpl; |
193 |
int has_error_code, new_stack, shift; |
int has_error_code, new_stack, shift; |
194 |
uint32_t e1, e2, offset, ss, esp, ss_e1, ss_e2, push_size; |
uint32_t e1, e2, offset, ss, esp, ss_e1, ss_e2, push_size; |
195 |
uint32_t old_cs, old_ss, old_esp, old_eip; |
uint32_t old_cs, old_ss, old_esp, old_eip; |
216 |
break; |
break; |
217 |
} |
} |
218 |
dpl = (e2 >> DESC_DPL_SHIFT) & 3; |
dpl = (e2 >> DESC_DPL_SHIFT) & 3; |
219 |
|
cpl = env->hflags & HF_CPL_MASK; |
220 |
/* check privledge if software int */ |
/* check privledge if software int */ |
221 |
if (is_int && dpl < env->cpl) |
if (is_int && dpl < cpl) |
222 |
raise_exception_err(EXCP0D_GPF, intno * 8 + 2); |
raise_exception_err(EXCP0D_GPF, intno * 8 + 2); |
223 |
/* check valid bit */ |
/* check valid bit */ |
224 |
if (!(e2 & DESC_P_MASK)) |
if (!(e2 & DESC_P_MASK)) |
233 |
if (!(e2 & DESC_S_MASK) || !(e2 & (DESC_CS_MASK))) |
if (!(e2 & DESC_S_MASK) || !(e2 & (DESC_CS_MASK))) |
234 |
raise_exception_err(EXCP0D_GPF, selector & 0xfffc); |
raise_exception_err(EXCP0D_GPF, selector & 0xfffc); |
235 |
dpl = (e2 >> DESC_DPL_SHIFT) & 3; |
dpl = (e2 >> DESC_DPL_SHIFT) & 3; |
236 |
if (dpl > env->cpl) |
if (dpl > cpl) |
237 |
raise_exception_err(EXCP0D_GPF, selector & 0xfffc); |
raise_exception_err(EXCP0D_GPF, selector & 0xfffc); |
238 |
if (!(e2 & DESC_P_MASK)) |
if (!(e2 & DESC_P_MASK)) |
239 |
raise_exception_err(EXCP0B_NOSEG, selector & 0xfffc); |
raise_exception_err(EXCP0B_NOSEG, selector & 0xfffc); |
240 |
if (!(e2 & DESC_C_MASK) && dpl < env->cpl) { |
if (!(e2 & DESC_C_MASK) && dpl < cpl) { |
241 |
/* to inner priviledge */ |
/* to inner priviledge */ |
242 |
get_ss_esp_from_tss(&ss, &esp, dpl); |
get_ss_esp_from_tss(&ss, &esp, dpl); |
243 |
if ((ss & 0xfffc) == 0) |
if ((ss & 0xfffc) == 0) |
256 |
if (!(ss_e2 & DESC_P_MASK)) |
if (!(ss_e2 & DESC_P_MASK)) |
257 |
raise_exception_err(EXCP0A_TSS, ss & 0xfffc); |
raise_exception_err(EXCP0A_TSS, ss & 0xfffc); |
258 |
new_stack = 1; |
new_stack = 1; |
259 |
} else if ((e2 & DESC_C_MASK) || dpl == env->cpl) { |
} else if ((e2 & DESC_C_MASK) || dpl == cpl) { |
260 |
/* to same priviledge */ |
/* to same priviledge */ |
261 |
new_stack = 0; |
new_stack = 0; |
262 |
} else { |
} else { |
403 |
{ |
{ |
404 |
SegmentCache *dt; |
SegmentCache *dt; |
405 |
uint8_t *ptr; |
uint8_t *ptr; |
406 |
int dpl; |
int dpl, cpl; |
407 |
uint32_t e2; |
uint32_t e2; |
408 |
|
|
409 |
dt = &env->idt; |
dt = &env->idt; |
411 |
e2 = ldl(ptr + 4); |
e2 = ldl(ptr + 4); |
412 |
|
|
413 |
dpl = (e2 >> DESC_DPL_SHIFT) & 3; |
dpl = (e2 >> DESC_DPL_SHIFT) & 3; |
414 |
|
cpl = env->hflags & HF_CPL_MASK; |
415 |
/* check privledge if software int */ |
/* check privledge if software int */ |
416 |
if (is_int && dpl < env->cpl) |
if (is_int && dpl < cpl) |
417 |
raise_exception_err(EXCP0D_GPF, intno * 8 + 2); |
raise_exception_err(EXCP0D_GPF, intno * 8 + 2); |
418 |
|
|
419 |
/* Since we emulate only user space, we cannot do more than |
/* Since we emulate only user space, we cannot do more than |
744 |
raise_exception_err(EXCP0D_GPF, 0); |
raise_exception_err(EXCP0D_GPF, 0); |
745 |
if (load_segment(&e1, &e2, new_cs) != 0) |
if (load_segment(&e1, &e2, new_cs) != 0) |
746 |
raise_exception_err(EXCP0D_GPF, new_cs & 0xfffc); |
raise_exception_err(EXCP0D_GPF, new_cs & 0xfffc); |
747 |
cpl = env->cpl; |
cpl = env->hflags & HF_CPL_MASK; |
748 |
if (e2 & DESC_S_MASK) { |
if (e2 & DESC_S_MASK) { |
749 |
if (!(e2 & DESC_CS_MASK)) |
if (!(e2 & DESC_CS_MASK)) |
750 |
raise_exception_err(EXCP0D_GPF, new_cs & 0xfffc); |
raise_exception_err(EXCP0D_GPF, new_cs & 0xfffc); |
828 |
raise_exception_err(EXCP0D_GPF, 0); |
raise_exception_err(EXCP0D_GPF, 0); |
829 |
if (load_segment(&e1, &e2, new_cs) != 0) |
if (load_segment(&e1, &e2, new_cs) != 0) |
830 |
raise_exception_err(EXCP0D_GPF, new_cs & 0xfffc); |
raise_exception_err(EXCP0D_GPF, new_cs & 0xfffc); |
831 |
cpl = env->cpl; |
cpl = env->hflags & HF_CPL_MASK; |
832 |
if (e2 & DESC_S_MASK) { |
if (e2 & DESC_S_MASK) { |
833 |
if (!(e2 & DESC_CS_MASK)) |
if (!(e2 & DESC_CS_MASK)) |
834 |
raise_exception_err(EXCP0D_GPF, new_cs & 0xfffc); |
raise_exception_err(EXCP0D_GPF, new_cs & 0xfffc); |
1081 |
if (!(e2 & DESC_S_MASK) || |
if (!(e2 & DESC_S_MASK) || |
1082 |
!(e2 & DESC_CS_MASK)) |
!(e2 & DESC_CS_MASK)) |
1083 |
raise_exception_err(EXCP0D_GPF, new_cs & 0xfffc); |
raise_exception_err(EXCP0D_GPF, new_cs & 0xfffc); |
1084 |
cpl = env->cpl; |
cpl = env->hflags & HF_CPL_MASK; |
1085 |
rpl = new_cs & 3; |
rpl = new_cs & 3; |
1086 |
if (rpl < cpl) |
if (rpl < cpl) |
1087 |
raise_exception_err(EXCP0D_GPF, new_cs & 0xfffc); |
raise_exception_err(EXCP0D_GPF, new_cs & 0xfffc); |