Commit 3b22c4707decb706b10ce023534f8b79413ff9fe
1 parent
96e6e053
fixed invalid ESP usage (Jon Nall)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@362 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
1 changed file
with
20 additions
and
20 deletions
helper-i386.c
... | ... | @@ -285,13 +285,13 @@ static void do_interrupt_protected(int intno, int is_int, int error_code, |
285 | 285 | |
286 | 286 | /* XXX: check that enough room is available */ |
287 | 287 | if (new_stack) { |
288 | - old_esp = env->regs[R_ESP]; | |
288 | + old_esp = ESP; | |
289 | 289 | old_ss = env->segs[R_SS].selector; |
290 | 290 | load_seg(R_SS, ss, env->eip); |
291 | 291 | } else { |
292 | 292 | old_esp = 0; |
293 | 293 | old_ss = 0; |
294 | - esp = env->regs[R_ESP]; | |
294 | + esp = ESP; | |
295 | 295 | } |
296 | 296 | if (is_int) |
297 | 297 | old_eip = next_eip; |
... | ... | @@ -300,7 +300,7 @@ static void do_interrupt_protected(int intno, int is_int, int error_code, |
300 | 300 | old_cs = env->segs[R_CS].selector; |
301 | 301 | load_seg(R_CS, selector, env->eip); |
302 | 302 | env->eip = offset; |
303 | - env->regs[R_ESP] = esp - push_size; | |
303 | + ESP = esp - push_size; | |
304 | 304 | ssp = env->segs[R_SS].base + esp; |
305 | 305 | if (shift == 1) { |
306 | 306 | int old_eflags; |
... | ... | @@ -374,7 +374,7 @@ static void do_interrupt_real(int intno, int is_int, int error_code, |
374 | 374 | ptr = dt->base + intno * 4; |
375 | 375 | offset = lduw(ptr); |
376 | 376 | selector = lduw(ptr + 2); |
377 | - esp = env->regs[R_ESP]; | |
377 | + esp = ESP; | |
378 | 378 | ssp = env->segs[R_SS].base; |
379 | 379 | if (is_int) |
380 | 380 | old_eip = next_eip; |
... | ... | @@ -389,7 +389,7 @@ static void do_interrupt_real(int intno, int is_int, int error_code, |
389 | 389 | stw(ssp + (esp & 0xffff), old_eip); |
390 | 390 | |
391 | 391 | /* update processor state */ |
392 | - env->regs[R_ESP] = (env->regs[R_ESP] & ~0xffff) | (esp & 0xffff); | |
392 | + ESP = (ESP & ~0xffff) | (esp & 0xffff); | |
393 | 393 | env->eip = offset; |
394 | 394 | env->segs[R_CS].selector = selector; |
395 | 395 | env->segs[R_CS].base = (uint8_t *)(selector << 4); |
... | ... | @@ -784,7 +784,7 @@ void helper_lcall_real_T0_T1(int shift, int next_eip) |
784 | 784 | |
785 | 785 | new_cs = T0; |
786 | 786 | new_eip = T1; |
787 | - esp = env->regs[R_ESP]; | |
787 | + esp = ESP; | |
788 | 788 | esp_mask = 0xffffffff; |
789 | 789 | if (!(env->segs[R_SS].flags & DESC_B_MASK)) |
790 | 790 | esp_mask = 0xffff; |
... | ... | @@ -802,9 +802,9 @@ void helper_lcall_real_T0_T1(int shift, int next_eip) |
802 | 802 | } |
803 | 803 | |
804 | 804 | if (!(env->segs[R_SS].flags & DESC_B_MASK)) |
805 | - env->regs[R_ESP] = (env->regs[R_ESP] & ~0xffff) | (esp & 0xffff); | |
805 | + ESP = (ESP & ~0xffff) | (esp & 0xffff); | |
806 | 806 | else |
807 | - env->regs[R_ESP] = esp; | |
807 | + ESP = esp; | |
808 | 808 | env->eip = new_eip; |
809 | 809 | env->segs[R_CS].selector = new_cs; |
810 | 810 | env->segs[R_CS].base = (uint8_t *)(new_cs << 4); |
... | ... | @@ -846,7 +846,7 @@ void helper_lcall_protected_T0_T1(int shift, int next_eip) |
846 | 846 | if (!(e2 & DESC_P_MASK)) |
847 | 847 | raise_exception_err(EXCP0B_NOSEG, new_cs & 0xfffc); |
848 | 848 | |
849 | - sp = env->regs[R_ESP]; | |
849 | + sp = ESP; | |
850 | 850 | if (!(env->segs[R_SS].flags & DESC_B_MASK)) |
851 | 851 | sp &= 0xffff; |
852 | 852 | ssp = env->segs[R_SS].base + sp; |
... | ... | @@ -868,9 +868,9 @@ void helper_lcall_protected_T0_T1(int shift, int next_eip) |
868 | 868 | raise_exception_err(EXCP0D_GPF, new_cs & 0xfffc); |
869 | 869 | /* from this point, not restartable */ |
870 | 870 | if (!(env->segs[R_SS].flags & DESC_B_MASK)) |
871 | - env->regs[R_ESP] = (env->regs[R_ESP] & 0xffff0000) | (sp & 0xffff); | |
871 | + ESP = (ESP & 0xffff0000) | (sp & 0xffff); | |
872 | 872 | else |
873 | - env->regs[R_ESP] = sp; | |
873 | + ESP = sp; | |
874 | 874 | env->segs[R_CS].base = sc1.base; |
875 | 875 | env->segs[R_CS].limit = sc1.limit; |
876 | 876 | env->segs[R_CS].flags = sc1.flags; |
... | ... | @@ -938,7 +938,7 @@ void helper_lcall_protected_T0_T1(int shift, int next_eip) |
938 | 938 | param_count = e2 & 0x1f; |
939 | 939 | push_size = ((param_count * 2) + 8) << shift; |
940 | 940 | |
941 | - old_esp = env->regs[R_ESP]; | |
941 | + old_esp = ESP; | |
942 | 942 | old_ss = env->segs[R_SS].selector; |
943 | 943 | if (!(env->segs[R_SS].flags & DESC_B_MASK)) |
944 | 944 | old_esp &= 0xffff; |
... | ... | @@ -995,9 +995,9 @@ void helper_lcall_protected_T0_T1(int shift, int next_eip) |
995 | 995 | load_seg(R_CS, selector, env->eip); |
996 | 996 | /* from this point, not restartable if same priviledge */ |
997 | 997 | if (!(env->segs[R_SS].flags & DESC_B_MASK)) |
998 | - env->regs[R_ESP] = (env->regs[R_ESP] & 0xffff0000) | (sp & 0xffff); | |
998 | + ESP = (ESP & 0xffff0000) | (sp & 0xffff); | |
999 | 999 | else |
1000 | - env->regs[R_ESP] = sp; | |
1000 | + ESP = sp; | |
1001 | 1001 | EIP = offset; |
1002 | 1002 | } |
1003 | 1003 | } |
... | ... | @@ -1020,7 +1020,7 @@ void helper_iret_real(int shift) |
1020 | 1020 | uint8_t *ssp; |
1021 | 1021 | int eflags_mask; |
1022 | 1022 | |
1023 | - sp = env->regs[R_ESP] & 0xffff; | |
1023 | + sp = ESP & 0xffff; | |
1024 | 1024 | ssp = env->segs[R_SS].base + sp; |
1025 | 1025 | if (shift == 1) { |
1026 | 1026 | /* 32 bits */ |
... | ... | @@ -1034,7 +1034,7 @@ void helper_iret_real(int shift) |
1034 | 1034 | new_eip = lduw(ssp); |
1035 | 1035 | } |
1036 | 1036 | new_esp = sp + (6 << shift); |
1037 | - env->regs[R_ESP] = (env->regs[R_ESP] & 0xffff0000) | | |
1037 | + ESP = (ESP & 0xffff0000) | | |
1038 | 1038 | (new_esp & 0xffff); |
1039 | 1039 | load_seg_vm(R_CS, new_cs); |
1040 | 1040 | env->eip = new_eip; |
... | ... | @@ -1053,7 +1053,7 @@ static inline void helper_ret_protected(int shift, int is_iret, int addend) |
1053 | 1053 | int cpl, dpl, rpl, eflags_mask; |
1054 | 1054 | uint8_t *ssp; |
1055 | 1055 | |
1056 | - sp = env->regs[R_ESP]; | |
1056 | + sp = ESP; | |
1057 | 1057 | if (!(env->segs[R_SS].flags & DESC_B_MASK)) |
1058 | 1058 | sp &= 0xffff; |
1059 | 1059 | ssp = env->segs[R_SS].base + sp; |
... | ... | @@ -1129,9 +1129,9 @@ static inline void helper_ret_protected(int shift, int is_iret, int addend) |
1129 | 1129 | load_seg(R_SS, new_ss, env->eip); |
1130 | 1130 | } |
1131 | 1131 | if (env->segs[R_SS].flags & DESC_B_MASK) |
1132 | - env->regs[R_ESP] = new_esp; | |
1132 | + ESP = new_esp; | |
1133 | 1133 | else |
1134 | - env->regs[R_ESP] = (env->regs[R_ESP] & 0xffff0000) | | |
1134 | + ESP = (ESP & 0xffff0000) | | |
1135 | 1135 | (new_esp & 0xffff); |
1136 | 1136 | env->eip = new_eip; |
1137 | 1137 | if (is_iret) { |
... | ... | @@ -1164,7 +1164,7 @@ static inline void helper_ret_protected(int shift, int is_iret, int addend) |
1164 | 1164 | load_seg_vm(R_GS, new_gs); |
1165 | 1165 | |
1166 | 1166 | env->eip = new_eip; |
1167 | - env->regs[R_ESP] = new_esp; | |
1167 | + ESP = new_esp; | |
1168 | 1168 | } |
1169 | 1169 | |
1170 | 1170 | void helper_iret_protected(int shift) | ... | ... |