Patchwork kvm: x86: Prevent sign extension of DR7 in guest debugging mode

login
register
mail settings
Submitter Jan Kiszka
Date Dec. 27, 2010, 2:58 p.m.
Message ID <4D18A98F.3070303@web.de>
Download mbox | patch
Permalink /patch/76791/
State New
Headers show

Comments

Jan Kiszka - Dec. 27, 2010, 2:58 p.m.
From: Jan Kiszka <jan.kiszka@siemens.com>

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>
---
 target-i386/kvm.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
Avi Kivity - Dec. 27, 2010, 3:38 p.m.
On 12/27/2010 04:58 PM, Jan Kiszka wrote:
> From: Jan Kiszka<jan.kiszka@siemens.com>
>
> 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).

Applied to uq/master, thanks.

Patch

diff --git a/target-i386/kvm.c b/target-i386/kvm.c
index 9a4bf98..218812a 100644
--- a/target-i386/kvm.c
+++ b/target-i386/kvm.c
@@ -1693,7 +1693,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 */