From patchwork Tue May 20 21:10:24 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin O'Connor X-Patchwork-Id: 350881 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3EAD914008A for ; Wed, 21 May 2014 07:11:15 +1000 (EST) Received: from localhost ([::1]:55458 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WmrJY-00019B-JO for incoming@patchwork.ozlabs.org; Tue, 20 May 2014 17:11:12 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54129) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WmrIw-0000d8-W0 for qemu-devel@nongnu.org; Tue, 20 May 2014 17:10:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WmrIq-0005dJ-O2 for qemu-devel@nongnu.org; Tue, 20 May 2014 17:10:34 -0400 Received: from mail-pb0-f47.google.com ([209.85.160.47]:47196) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WmrIq-0005d0-JU for qemu-devel@nongnu.org; Tue, 20 May 2014 17:10:28 -0400 Received: by mail-pb0-f47.google.com with SMTP id rp16so681269pbb.34 for ; Tue, 20 May 2014 14:10:27 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:subject:message-id:mime-version :content-type:content-disposition:user-agent; bh=+5FqEXYGlX7RN6x9ZOKnzIVghMLdIRpFsQxlgm09Ixk=; b=m9SkPlIeSy1x8QOZShNjG1m0cmxgcnvAo0107pbKnlDO12OT6L1/E3KWxC7CyXL1Bf hutUlTH+KCroV3JTvAF2b5YeLj+y2wD875IveN9BjStVZLfFvnZHlj9RgzESufJaEz6Z 4ZSp5C5f3iRbpx29ISP5knn3N0SRAFgV8HRdPjXmxqu5iJs0WxFK1lYOzdhxB1ErX4oy gouK8AL0qoO72IEviyMA4YYHOYasBIBgXTTjmhmp/Ae3xYEtjNcylYhBqY+l4d5ZNIRI Wg87CpeNZpUNw0VyP8rptur631r5gYSVubEFBb7ptQ9tZ4N3V2h9FNHNQHpdxb0bMU4X m+Pw== X-Gm-Message-State: ALoCoQnAR1sybcxP2Fxt/X7plsGaCEEPhqTZ3I8p7bps/rGbKWfMxbUciKV+jo6ZzkoOq+78KYsM X-Received: by 10.68.213.97 with SMTP id nr1mr52846933pbc.52.1400620227313; Tue, 20 May 2014 14:10:27 -0700 (PDT) Received: from localhost (207-172-170-53.c3-0.avec-ubr1.nyr-avec.ny.cable.rcn.com. [207.172.170.53]) by mx.google.com with ESMTPSA id ga1sm4636396pbb.82.2014.05.20.14.10.25 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 20 May 2014 14:10:26 -0700 (PDT) Date: Tue, 20 May 2014 17:10:24 -0400 From: Kevin O'Connor To: qemu-devel@nongnu.org, Paolo Bonzini Message-ID: <915eb01bc60e939a0fdad74913f595fdadf5839f.1400620170.git.kevin@koconnor.net> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.85.160.47 Subject: [Qemu-devel] [PATCH] target-i386: Fix vm86 mode regression introduced in fd460606fd6f. X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 --- 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);