ia64/xen-unstable

changeset 14672:3c0d15279dc7

hvm: Must increment RIP on INT3 instruction in SVM.
Also tighten up checking of valid exception intercepts -- we should
not vmexit on an exception we have not registered an interest in.
Signed-off-by Tom Woller <thomas.woller@amd.com>
Signed-off-by Thomas Friebel <thomas.friebel@amd.com>
Signed-off-by: Keir Fraser <keir@xensource.com>
author Keir Fraser <keir@xensource.com>
date Fri Mar 30 17:02:46 2007 +0100 (2007-03-30)
parents 4a873ab4e261
children d3b1341d83db
files xen/arch/x86/hvm/svm/emulate.c xen/arch/x86/hvm/svm/svm.c xen/arch/x86/hvm/vmx/vmx.c xen/include/asm-x86/hvm/svm/emulate.h
line diff
     1.1 --- a/xen/arch/x86/hvm/svm/emulate.c	Fri Mar 30 14:13:53 2007 +0100
     1.2 +++ b/xen/arch/x86/hvm/svm/emulate.c	Fri Mar 30 17:02:46 2007 +0100
     1.3 @@ -373,6 +373,7 @@ MAKE_INSTR(HLT,    1, 0xf4);
     1.4  MAKE_INSTR(CLTS,   2, 0x0f, 0x06);
     1.5  MAKE_INSTR(LMSW,   3, 0x0f, 0x01, 0x00);
     1.6  MAKE_INSTR(SMSW,   3, 0x0f, 0x01, 0x00);
     1.7 +MAKE_INSTR(INT3,   1, 0xcc);
     1.8  
     1.9  static const u8 *opc_bytes[INSTR_MAX_COUNT] = 
    1.10  {
    1.11 @@ -405,7 +406,8 @@ static const u8 *opc_bytes[INSTR_MAX_COU
    1.12      [INSTR_CLTS]   = OPCODE_CLTS,
    1.13      [INSTR_HLT]    = OPCODE_HLT,
    1.14      [INSTR_LMSW]   = OPCODE_LMSW,
    1.15 -    [INSTR_SMSW]   = OPCODE_SMSW
    1.16 +    [INSTR_SMSW]   = OPCODE_SMSW,
    1.17 +    [INSTR_INT3]   = OPCODE_INT3
    1.18  };
    1.19  
    1.20  /* 
     2.1 --- a/xen/arch/x86/hvm/svm/svm.c	Fri Mar 30 14:13:53 2007 +0100
     2.2 +++ b/xen/arch/x86/hvm/svm/svm.c	Fri Mar 30 17:02:46 2007 +0100
     2.3 @@ -2229,6 +2229,7 @@ asmlinkage void svm_vmexit_handler(struc
     2.4      unsigned long eip;
     2.5      struct vcpu *v = current;
     2.6      struct vmcb_struct *vmcb = v->arch.hvm_svm.vmcb;
     2.7 +    int inst_len;
     2.8  
     2.9      exit_reason = vmcb->exitcode;
    2.10      save_svm_cpu_user_regs(v, regs);
    2.11 @@ -2262,17 +2263,18 @@ asmlinkage void svm_vmexit_handler(struc
    2.12          break;
    2.13  
    2.14      case VMEXIT_EXCEPTION_DB:
    2.15 -        if ( v->domain->debugger_attached )
    2.16 -            domain_pause_for_debugger();
    2.17 -        else 
    2.18 -            svm_inject_exception(v, TRAP_debug, 0, 0);
    2.19 +        if ( !v->domain->debugger_attached )
    2.20 +            goto exit_and_crash;
    2.21 +        domain_pause_for_debugger();
    2.22          break;
    2.23  
    2.24      case VMEXIT_EXCEPTION_BP:
    2.25 -        if ( v->domain->debugger_attached )
    2.26 -            domain_pause_for_debugger();
    2.27 -        else 
    2.28 -            svm_inject_exception(v, TRAP_int3, 0, 0);
    2.29 +        if ( !v->domain->debugger_attached )
    2.30 +            goto exit_and_crash;
    2.31 +        /* AMD Vol2, 15.11: INT3, INTO, BOUND intercepts do not update RIP. */
    2.32 +        inst_len = __get_instruction_length(v, INSTR_INT3, NULL);
    2.33 +        __update_guest_eip(vmcb, inst_len);
    2.34 +        domain_pause_for_debugger();
    2.35          break;
    2.36  
    2.37      case VMEXIT_EXCEPTION_NM:
    2.38 @@ -2332,14 +2334,13 @@ asmlinkage void svm_vmexit_handler(struc
    2.39          svm_handle_invlpg(1, regs);
    2.40          break;
    2.41  
    2.42 -    case VMEXIT_VMMCALL: {
    2.43 -        int inst_len = __get_instruction_length(v, INSTR_VMCALL, NULL);
    2.44 +    case VMEXIT_VMMCALL:
    2.45 +        inst_len = __get_instruction_length(v, INSTR_VMCALL, NULL);
    2.46          ASSERT(inst_len > 0);
    2.47          HVMTRACE_1D(VMMCALL, v, regs->eax);
    2.48          __update_guest_eip(vmcb, inst_len);
    2.49          hvm_do_hypercall(regs);
    2.50          break;
    2.51 -    }
    2.52  
    2.53      case VMEXIT_CR0_READ:
    2.54          svm_cr_access(v, 0, TYPE_MOV_FROM_CR, regs);
     3.1 --- a/xen/arch/x86/hvm/vmx/vmx.c	Fri Mar 30 14:13:53 2007 +0100
     3.2 +++ b/xen/arch/x86/hvm/vmx/vmx.c	Fri Mar 30 17:02:46 2007 +0100
     3.3 @@ -2511,16 +2511,10 @@ asmlinkage void vmx_vmexit_handler(struc
     3.4          switch ( vector )
     3.5          {
     3.6          case TRAP_debug:
     3.7 -            if ( v->domain->debugger_attached )
     3.8 -                domain_pause_for_debugger();
     3.9 -            else
    3.10 -                vmx_reflect_exception(v);
    3.11 -            break;
    3.12          case TRAP_int3:
    3.13 -            if ( v->domain->debugger_attached )
    3.14 -                domain_pause_for_debugger();
    3.15 -            else
    3.16 -                vmx_reflect_exception(v);
    3.17 +            if ( !v->domain->debugger_attached )
    3.18 +                goto exit_and_crash;
    3.19 +            domain_pause_for_debugger();
    3.20              break;
    3.21          case TRAP_no_device:
    3.22              vmx_do_no_device_fault();
    3.23 @@ -2552,8 +2546,7 @@ asmlinkage void vmx_vmexit_handler(struc
    3.24                  vmx_reflect_exception(v);
    3.25              break;
    3.26          default:
    3.27 -            vmx_reflect_exception(v);
    3.28 -            break;
    3.29 +            goto exit_and_crash;
    3.30          }
    3.31          break;
    3.32      }
     4.1 --- a/xen/include/asm-x86/hvm/svm/emulate.h	Fri Mar 30 14:13:53 2007 +0100
     4.2 +++ b/xen/include/asm-x86/hvm/svm/emulate.h	Fri Mar 30 17:02:46 2007 +0100
     4.3 @@ -72,6 +72,7 @@ enum instruction_index {
     4.4      INSTR_CLTS,
     4.5      INSTR_LMSW,
     4.6      INSTR_SMSW,
     4.7 +    INSTR_INT3,
     4.8      INSTR_MAX_COUNT /* Must be last - Number of instructions supported */
     4.9  };
    4.10