ia64/xen-unstable

changeset 18332:a1e4279bddee

x86, hvm: Fix softtsc for AMD-V

The softtsc code for AMD does not update the ip; enabling it on AMD-V
results in the domain spinning on the RDTSC instruction. The patch is
against xen-unstable 18331.

Signed-off-by: John Byrne <john.l.byrne@hp.com>
author Keir Fraser <keir.fraser@citrix.com>
date Fri Aug 15 14:59:41 2008 +0100 (2008-08-15)
parents d09404ad5730
children b4dba6a0e97c
files xen/arch/x86/hvm/svm/emulate.c xen/arch/x86/hvm/svm/svm.c xen/include/asm-x86/hvm/svm/emulate.h
line diff
     1.1 --- a/xen/arch/x86/hvm/svm/emulate.c	Thu Aug 14 16:26:06 2008 +0100
     1.2 +++ b/xen/arch/x86/hvm/svm/emulate.c	Fri Aug 15 14:59:41 2008 +0100
     1.3 @@ -71,6 +71,7 @@ MAKE_INSTR(WRMSR,  2, 0x0f, 0x30);
     1.4  MAKE_INSTR(VMCALL, 3, 0x0f, 0x01, 0xd9);
     1.5  MAKE_INSTR(HLT,    1, 0xf4);
     1.6  MAKE_INSTR(INT3,   1, 0xcc);
     1.7 +MAKE_INSTR(RDTSC,  2, 0x0f, 0x31);
     1.8  
     1.9  static const u8 *opc_bytes[INSTR_MAX_COUNT] = 
    1.10  {
    1.11 @@ -81,7 +82,8 @@ static const u8 *opc_bytes[INSTR_MAX_COU
    1.12      [INSTR_WRMSR]  = OPCODE_WRMSR,
    1.13      [INSTR_VMCALL] = OPCODE_VMCALL,
    1.14      [INSTR_HLT]    = OPCODE_HLT,
    1.15 -    [INSTR_INT3]   = OPCODE_INT3
    1.16 +    [INSTR_INT3]   = OPCODE_INT3,
    1.17 +    [INSTR_RDTSC]  = OPCODE_RDTSC
    1.18  };
    1.19  
    1.20  static int fetch(struct vcpu *v, u8 *buf, unsigned long addr, int len)
     2.1 --- a/xen/arch/x86/hvm/svm/svm.c	Thu Aug 14 16:26:06 2008 +0100
     2.2 +++ b/xen/arch/x86/hvm/svm/svm.c	Fri Aug 15 14:59:41 2008 +0100
     2.3 @@ -1128,6 +1128,17 @@ static void svm_vmexit_do_hlt(struct vmc
     2.4      hvm_hlt(regs->eflags);
     2.5  }
     2.6  
     2.7 +static void svm_vmexit_do_rdtsc(struct cpu_user_regs *regs)
     2.8 +{
     2.9 +    unsigned int inst_len;
    2.10 +
    2.11 +    if ( (inst_len = __get_instruction_length(current, INSTR_RDTSC)) == 0 )
    2.12 +        return;
    2.13 +    __update_guest_eip(regs, inst_len);
    2.14 +
    2.15 +    hvm_rdtsc_intercept(regs);
    2.16 +}
    2.17 +
    2.18  static void wbinvd_ipi(void *info)
    2.19  {
    2.20      wbinvd();
    2.21 @@ -1344,7 +1355,7 @@ asmlinkage void svm_vmexit_handler(struc
    2.22          break;
    2.23  
    2.24      case VMEXIT_RDTSC:
    2.25 -        hvm_rdtsc_intercept(regs);
    2.26 +        svm_vmexit_do_rdtsc(regs);
    2.27          break;
    2.28  
    2.29      case VMEXIT_RDTSCP:
     3.1 --- a/xen/include/asm-x86/hvm/svm/emulate.h	Thu Aug 14 16:26:06 2008 +0100
     3.2 +++ b/xen/include/asm-x86/hvm/svm/emulate.h	Fri Aug 15 14:59:41 2008 +0100
     3.3 @@ -30,6 +30,7 @@ enum instruction_index {
     3.4      INSTR_VMCALL,
     3.5      INSTR_HLT,
     3.6      INSTR_INT3,
     3.7 +    INSTR_RDTSC,
     3.8      INSTR_MAX_COUNT /* Must be last - Number of instructions supported */
     3.9  };
    3.10