kvm: x86: Prevent sign extension of DR7 in guest debugging mode
authorJan Kiszka <jan.kiszka@siemens.com>
Mon, 27 Dec 2010 14:58:23 +0000 (15:58 +0100)
committerMarcelo Tosatti <mtosatti@redhat.com>
Fri, 21 Jan 2011 16:05:22 +0000 (14:05 -0200)
This unbreaks guest debugging when the 4th hardware breakpoint used for
guest debugging is a watchpoint of 4 or 8 byte lenght. The 31st bit of
DR7 is set in that case and used to cause a sign extension to the high
word which was breaking the guest state (vm entry failure).

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
target-i386/kvm.c

index 7e5982b132fdcc01d3d10b1cc22d62af3f38a246..85edaccad1e0841b11e3cbba8ff4566cd028bdd6 100644 (file)
@@ -1686,7 +1686,7 @@ void kvm_arch_update_guest_debug(CPUState *env, struct kvm_guest_debug *dbg)
             dbg->arch.debugreg[n] = hw_breakpoint[n].addr;
             dbg->arch.debugreg[7] |= (2 << (n * 2)) |
                 (type_code[hw_breakpoint[n].type] << (16 + n*4)) |
-                (len_code[hw_breakpoint[n].len] << (18 + n*4));
+                ((uint32_t)len_code[hw_breakpoint[n].len] << (18 + n*4));
         }
     }
     /* Legal xcr0 for loading */