[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 23/28] target-i386: Rewrite leave
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [PULL 23/28] target-i386: Rewrite leave |
Date: |
Mon, 8 Feb 2016 18:03:14 +0100 |
From: Richard Henderson <address@hidden>
Unify the code across stack pointer widths. Fix the note about
not updating ESP before the potential exception.
Signed-off-by: Richard Henderson <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Paolo Bonzini <address@hidden>
---
target-i386/translate.c | 29 +++++++++++++++--------------
1 file changed, 15 insertions(+), 14 deletions(-)
diff --git a/target-i386/translate.c b/target-i386/translate.c
index b2f8790..6b901b1 100644
--- a/target-i386/translate.c
+++ b/target-i386/translate.c
@@ -2359,6 +2359,20 @@ static void gen_enter(DisasContext *s, int esp_addend,
int level)
gen_op_mov_reg_v(a_ot, R_ESP, cpu_T[1]);
}
+static void gen_leave(DisasContext *s)
+{
+ TCGMemOp d_ot = mo_pushpop(s, s->dflag);
+ TCGMemOp a_ot = mo_stacksize(s);
+
+ gen_lea_v_seg(s, a_ot, cpu_regs[R_EBP], R_SS, -1);
+ gen_op_ld_v(s, d_ot, cpu_T[0], cpu_A0);
+
+ tcg_gen_addi_tl(cpu_T[1], cpu_regs[R_EBP], 1 << d_ot);
+
+ gen_op_mov_reg_v(d_ot, R_EBP, cpu_T[0]);
+ gen_op_mov_reg_v(a_ot, R_ESP, cpu_T[1]);
+}
+
static void gen_exception(DisasContext *s, int trapno, target_ulong cur_eip)
{
gen_update_cc_op(s);
@@ -5114,20 +5128,7 @@ static target_ulong disas_insn(CPUX86State *env,
DisasContext *s,
}
break;
case 0xc9: /* leave */
- /* XXX: exception not precise (ESP is updated before potential
exception) */
- if (CODE64(s)) {
- gen_op_mov_v_reg(MO_64, cpu_T[0], R_EBP);
- gen_op_mov_reg_v(MO_64, R_ESP, cpu_T[0]);
- } else if (s->ss32) {
- gen_op_mov_v_reg(MO_32, cpu_T[0], R_EBP);
- gen_op_mov_reg_v(MO_32, R_ESP, cpu_T[0]);
- } else {
- gen_op_mov_v_reg(MO_16, cpu_T[0], R_EBP);
- gen_op_mov_reg_v(MO_16, R_ESP, cpu_T[0]);
- }
- ot = gen_pop_T0(s);
- gen_op_mov_reg_v(ot, R_EBP, cpu_T[0]);
- gen_pop_update(s, ot);
+ gen_leave(s);
break;
case 0x06: /* push es */
case 0x0e: /* push cs */
--
1.8.3.1
- [Qemu-devel] [PULL 10/28] qemu-nbd: Minor texi updates, (continued)
- [Qemu-devel] [PULL 10/28] qemu-nbd: Minor texi updates, Paolo Bonzini, 2016/02/08
- [Qemu-devel] [PULL 11/28] qemu-nbd: Fix texi sentence capitalisation, Paolo Bonzini, 2016/02/08
- [Qemu-devel] [PULL 13/28] nbd: avoid unaligned uint64_t store, Paolo Bonzini, 2016/02/08
- [Qemu-devel] [PULL 16/28] target-i386: Create gen_lea_v_seg, Paolo Bonzini, 2016/02/08
- [Qemu-devel] [PULL 08/28] hw: Add support for LSI SAS1068 (mptsas) device, Paolo Bonzini, 2016/02/08
- [Qemu-devel] [PULL 20/28] target-i386: Access segs via TCG registers, Paolo Bonzini, 2016/02/08
- [Qemu-devel] [PULL 22/28] target-i386: Rewrite gen_enter inline, Paolo Bonzini, 2016/02/08
- [Qemu-devel] [PULL 21/28] target-i386: Use gen_lea_v_seg in pusha/popa, Paolo Bonzini, 2016/02/08
- [Qemu-devel] [PULL 27/28] ipmi_bmc_sim: Fix off by one in check., Paolo Bonzini, 2016/02/08
- [Qemu-devel] [PULL 24/28] target-i386: Tidy gen_add_A0_im, Paolo Bonzini, 2016/02/08
- [Qemu-devel] [PULL 23/28] target-i386: Rewrite leave,
Paolo Bonzini <=
- [Qemu-devel] [PULL 26/28] ipmi: do not take/drop iothread lock, Paolo Bonzini, 2016/02/08
- [Qemu-devel] [PULL 28/28] ipmi_bmc_sim: Add break to correct watchdog NMI check, Paolo Bonzini, 2016/02/08
- [Qemu-devel] [PULL 25/28] target-i386: Deconstruct the cpu_T array, Paolo Bonzini, 2016/02/08
- Re: [Qemu-devel] [PULL 00/28] Misc changes for 2016-02-08, Peter Maydell, 2016/02/09