Received: from eggs.gnu.org ([2001:4830:134:3::10]:56265) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ws9FA-0004ue-IO for qemu-devel@nongnu.org; Wed, 04 Jun 2014 07:20:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ws9F1-0005o5-5o for qemu-devel@nongnu.org; Wed, 04 Jun 2014 07:20:31 -0400 Received: from mail-wi0-x230.google.com ([2a00:1450:400c:c05::230]:41698) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ws9F0-0005nq-Ue for qemu-devel@nongnu.org; Wed, 04 Jun 2014 07:20:23 -0400 Received: by mail-wi0-f176.google.com with SMTP id n15so8300708wiw.3 for ; Wed, 04 Jun 2014 04:20:22 -0700 (PDT) Sender: Paolo Bonzini From: Paolo Bonzini Date: Wed, 4 Jun 2014 13:20:04 +0200 Message-Id: <1401880812-818-4-git-send-email-pbonzini@redhat.com> In-Reply-To: <1401880812-818-1-git-send-email-pbonzini@redhat.com> References: <1401880812-818-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PULL 03/11] target-i386: Fix vm86 mode regression introduced in fd460606fd6f. List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Kevin O'Connor From: Kevin O'Connor Commit fd460606fd6f moved setting of eflags above calls to cpu_x86_load_seg_cache() in seg_helper.c. Unfortunately, in do_interrupt_protected() this moved the clearing of VM_MASK above a test for it. Fix this regression by storing the value of VM_MASK at the start of do_interrupt_protected(). Signed-off-by: Kevin O'Connor Signed-off-by: Paolo Bonzini --- target-i386/seg_helper.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/target-i386/seg_helper.c b/target-i386/seg_helper.c index 3cf862e..cc7eadf 100644 --- a/target-i386/seg_helper.c +++ b/target-i386/seg_helper.c @@ -558,6 +558,7 @@ static void do_interrupt_protected(CPUX86State *env, int intno, int is_int, int has_error_code, new_stack, shift; uint32_t e1, e2, offset, ss = 0, esp, ss_e1 = 0, ss_e2 = 0; uint32_t old_eip, sp_mask; + int vm86 = env->eflags & VM_MASK; has_error_code = 0; if (!is_int && !is_hw) { @@ -673,7 +674,7 @@ static void do_interrupt_protected(CPUX86State *env, int intno, int is_int, ssp = get_seg_base(ss_e1, ss_e2); } else if ((e2 & DESC_C_MASK) || dpl == cpl) { /* to same privilege */ - if (env->eflags & VM_MASK) { + if (vm86) { raise_exception_err(env, EXCP0D_GPF, selector & 0xfffc); } new_stack = 0; @@ -694,14 +695,14 @@ static void do_interrupt_protected(CPUX86State *env, int intno, int is_int, #if 0 /* XXX: check that enough room is available */ push_size = 6 + (new_stack << 2) + (has_error_code << 1); - if (env->eflags & VM_MASK) { + if (vm86) { push_size += 8; } push_size <<= shift; #endif if (shift == 1) { if (new_stack) { - if (env->eflags & VM_MASK) { + if (vm86) { PUSHL(ssp, esp, sp_mask, env->segs[R_GS].selector); PUSHL(ssp, esp, sp_mask, env->segs[R_FS].selector); PUSHL(ssp, esp, sp_mask, env->segs[R_DS].selector); @@ -718,7 +719,7 @@ static void do_interrupt_protected(CPUX86State *env, int intno, int is_int, } } else { if (new_stack) { - if (env->eflags & VM_MASK) { + if (vm86) { PUSHW(ssp, esp, sp_mask, env->segs[R_GS].selector); PUSHW(ssp, esp, sp_mask, env->segs[R_FS].selector); PUSHW(ssp, esp, sp_mask, env->segs[R_DS].selector); @@ -742,7 +743,7 @@ static void do_interrupt_protected(CPUX86State *env, int intno, int is_int, env->eflags &= ~(TF_MASK | VM_MASK | RF_MASK | NT_MASK); if (new_stack) { - if (env->eflags & VM_MASK) { + if (vm86) { cpu_x86_load_seg_cache(env, R_ES, 0, 0, 0, 0); cpu_x86_load_seg_cache(env, R_DS, 0, 0, 0, 0); cpu_x86_load_seg_cache(env, R_FS, 0, 0, 0, 0); -- 1.8.3.1