ia64/xen-unstable

changeset 19599:7d552e56d105

x86 vmx: Ensure debug-mode intercept for int3 and debug exceptions are
reinstated when resetting EXCEPTION_BIRTMAP entry in VMCS after
exiting real mode.

Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Wed May 13 10:39:44 2009 +0100 (2009-05-13)
parents 07fbc48553e8
children 3bac2fcfbafc
files xen/arch/x86/hvm/vmx/vmcs.c xen/arch/x86/hvm/vmx/vmx.c xen/include/asm-x86/hvm/vmx/vmx.h
line diff
     1.1 --- a/xen/arch/x86/hvm/vmx/vmcs.c	Wed May 13 10:28:35 2009 +0100
     1.2 +++ b/xen/arch/x86/hvm/vmx/vmcs.c	Wed May 13 10:39:44 2009 +0100
     1.3 @@ -912,18 +912,8 @@ void vmx_do_resume(struct vcpu *v)
     1.4      debug_state = v->domain->debugger_attached;
     1.5      if ( unlikely(v->arch.hvm_vcpu.debug_state_latch != debug_state) )
     1.6      {
     1.7 -        unsigned long intercepts = __vmread(EXCEPTION_BITMAP);
     1.8 -        unsigned long mask = 1u << TRAP_int3;
     1.9 -
    1.10 -        if ( !cpu_has_monitor_trap_flag )
    1.11 -            mask |= 1u << TRAP_debug;
    1.12 -
    1.13          v->arch.hvm_vcpu.debug_state_latch = debug_state;
    1.14 -        if ( debug_state )
    1.15 -            intercepts |= mask;
    1.16 -        else
    1.17 -            intercepts &= ~mask;
    1.18 -        __vmwrite(EXCEPTION_BITMAP, intercepts);
    1.19 +        vmx_update_debug_state(v);
    1.20      }
    1.21  
    1.22      hvm_do_resume(v);
     2.1 --- a/xen/arch/x86/hvm/vmx/vmx.c	Wed May 13 10:28:35 2009 +0100
     2.2 +++ b/xen/arch/x86/hvm/vmx/vmx.c	Wed May 13 10:39:44 2009 +0100
     2.3 @@ -1035,6 +1035,24 @@ static void vmx_update_host_cr3(struct v
     2.4      vmx_vmcs_exit(v);
     2.5  }
     2.6  
     2.7 +void vmx_update_debug_state(struct vcpu *v)
     2.8 +{
     2.9 +    unsigned long intercepts, mask;
    2.10 +
    2.11 +    ASSERT(v == current);
    2.12 +
    2.13 +    mask = 1u << TRAP_int3;
    2.14 +    if ( !cpu_has_monitor_trap_flag )
    2.15 +        mask |= 1u << TRAP_debug;
    2.16 +
    2.17 +    intercepts = __vmread(EXCEPTION_BITMAP);
    2.18 +    if ( v->arch.hvm_vcpu.debug_state_latch )
    2.19 +        intercepts |= mask;
    2.20 +    else
    2.21 +        intercepts &= ~mask;
    2.22 +    __vmwrite(EXCEPTION_BITMAP, intercepts);
    2.23 +}
    2.24 +
    2.25  static void vmx_update_guest_cr(struct vcpu *v, unsigned int cr)
    2.26  {
    2.27      vmx_vmcs_enter(v);
    2.28 @@ -1107,6 +1125,7 @@ static void vmx_update_guest_cr(struct v
    2.29                            | (paging_mode_hap(v->domain) ?
    2.30                               0 : (1U << TRAP_page_fault))
    2.31                            | (1U << TRAP_no_device));
    2.32 +                vmx_update_debug_state(v);
    2.33              }
    2.34          }
    2.35  
     3.1 --- a/xen/include/asm-x86/hvm/vmx/vmx.h	Wed May 13 10:28:35 2009 +0100
     3.2 +++ b/xen/include/asm-x86/hvm/vmx/vmx.h	Wed May 13 10:39:44 2009 +0100
     3.3 @@ -60,6 +60,7 @@ void vmx_intr_assist(void);
     3.4  void vmx_do_resume(struct vcpu *);
     3.5  void vmx_vlapic_msr_changed(struct vcpu *v);
     3.6  void vmx_realmode(struct cpu_user_regs *regs);
     3.7 +void vmx_update_debug_state(struct vcpu *v);
     3.8  
     3.9  /*
    3.10   * Exit Reasons