qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Cc: Kevin O'Connor <kevin@koconnor.net>
Subject: [Qemu-devel] [PULL 03/11] target-i386: Fix vm86 mode regression introduced in fd460606fd6f.
Date: Wed,  4 Jun 2014 13:20:04 +0200	[thread overview]
Message-ID: <1401880812-818-4-git-send-email-pbonzini@redhat.com> (raw)
In-Reply-To: <1401880812-818-1-git-send-email-pbonzini@redhat.com>

From: Kevin O'Connor <kevin@koconnor.net>

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 <kevin@koconnor.net>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 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

  parent reply	other threads:[~2014-06-04 11:20 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-04 11:20 [Qemu-devel] [PULL 00/11] KVM changes for 2014-06-04 Paolo Bonzini
2014-06-04 11:20 ` [Qemu-devel] [PULL 01/11] kvmclock: Ensure time in migration never goes backward Paolo Bonzini
2014-06-04 11:20 ` [Qemu-devel] [PULL 02/11] kvm_stat: allow choosing between tracepoints and old stats Paolo Bonzini
2014-06-04 11:20 ` Paolo Bonzini [this message]
2014-06-04 11:20 ` [Qemu-devel] [PULL 04/11] target-i386: fix segment flags for SMM and VM86 mode Paolo Bonzini
2014-06-04 11:20 ` [Qemu-devel] [PULL 05/11] target-i386: rework CPL checks during task switch, preparing for next patch Paolo Bonzini
2014-06-04 11:20 ` [Qemu-devel] [PULL 06/11] target-i386: get CPL from SS.DPL Paolo Bonzini
2014-06-04 11:20 ` [Qemu-devel] [PULL 07/11] target-i386: set CC_OP to CC_OP_EFLAGS in cpu_load_eflags Paolo Bonzini
2014-06-04 11:20 ` [Qemu-devel] [PULL 08/11] kvm: Ensure negative return value on kvm_init() error handling path Paolo Bonzini
2014-06-04 11:20 ` [Qemu-devel] [PULL 09/11] kvm: Enable -cpu option to hide KVM Paolo Bonzini
2014-06-04 11:20 ` [Qemu-devel] [PULL 10/11] kvmclock: Ensure proper env->tsc value for kvmclock_current_nsec calculation Paolo Bonzini
2014-06-04 11:20 ` [Qemu-devel] [PULL 11/11] kvm: Fix eax for cpuid leaf 0x40000000 Paolo Bonzini
2014-06-05 18:42 ` [Qemu-devel] [PULL 00/11] KVM changes for 2014-06-04 Peter Maydell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1401880812-818-4-git-send-email-pbonzini@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=kevin@koconnor.net \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).