Commit 3b22c4707decb706b10ce023534f8b79413ff9fe

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