diff options
author | Keir Fraser <keir.fraser@citrix.com> | 2008-08-15 14:59:41 +0100 |
---|---|---|
committer | Keir Fraser <keir.fraser@citrix.com> | 2008-08-15 14:59:41 +0100 |
commit | a532271d470630d7d05635ca0333826b0bf90bcf (patch) | |
tree | 19610fdf465057698949d0588a7ef6a16209d984 | |
parent | 202b0e0dc09615fc3dcc619a89a3ca3fc2279812 (diff) | |
download | xen-a532271d470630d7d05635ca0333826b0bf90bcf.tar.gz xen-a532271d470630d7d05635ca0333826b0bf90bcf.tar.bz2 xen-a532271d470630d7d05635ca0333826b0bf90bcf.zip |
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>
-rw-r--r-- | xen/arch/x86/hvm/svm/emulate.c | 4 | ||||
-rw-r--r-- | xen/arch/x86/hvm/svm/svm.c | 13 | ||||
-rw-r--r-- | xen/include/asm-x86/hvm/svm/emulate.h | 1 |
3 files changed, 16 insertions, 2 deletions
diff --git a/xen/arch/x86/hvm/svm/emulate.c b/xen/arch/x86/hvm/svm/emulate.c index 34afb8733d..fe9491bdf3 100644 --- a/xen/arch/x86/hvm/svm/emulate.c +++ b/xen/arch/x86/hvm/svm/emulate.c @@ -71,6 +71,7 @@ MAKE_INSTR(WRMSR, 2, 0x0f, 0x30); MAKE_INSTR(VMCALL, 3, 0x0f, 0x01, 0xd9); MAKE_INSTR(HLT, 1, 0xf4); MAKE_INSTR(INT3, 1, 0xcc); +MAKE_INSTR(RDTSC, 2, 0x0f, 0x31); static const u8 *opc_bytes[INSTR_MAX_COUNT] = { @@ -81,7 +82,8 @@ static const u8 *opc_bytes[INSTR_MAX_COUNT] = [INSTR_WRMSR] = OPCODE_WRMSR, [INSTR_VMCALL] = OPCODE_VMCALL, [INSTR_HLT] = OPCODE_HLT, - [INSTR_INT3] = OPCODE_INT3 + [INSTR_INT3] = OPCODE_INT3, + [INSTR_RDTSC] = OPCODE_RDTSC }; static int fetch(struct vcpu *v, u8 *buf, unsigned long addr, int len) diff --git a/xen/arch/x86/hvm/svm/svm.c b/xen/arch/x86/hvm/svm/svm.c index 9b0b86d426..955f0eca13 100644 --- a/xen/arch/x86/hvm/svm/svm.c +++ b/xen/arch/x86/hvm/svm/svm.c @@ -1128,6 +1128,17 @@ static void svm_vmexit_do_hlt(struct vmcb_struct *vmcb, hvm_hlt(regs->eflags); } +static void svm_vmexit_do_rdtsc(struct cpu_user_regs *regs) +{ + unsigned int inst_len; + + if ( (inst_len = __get_instruction_length(current, INSTR_RDTSC)) == 0 ) + return; + __update_guest_eip(regs, inst_len); + + hvm_rdtsc_intercept(regs); +} + static void wbinvd_ipi(void *info) { wbinvd(); @@ -1344,7 +1355,7 @@ asmlinkage void svm_vmexit_handler(struct cpu_user_regs *regs) break; case VMEXIT_RDTSC: - hvm_rdtsc_intercept(regs); + svm_vmexit_do_rdtsc(regs); break; case VMEXIT_RDTSCP: diff --git a/xen/include/asm-x86/hvm/svm/emulate.h b/xen/include/asm-x86/hvm/svm/emulate.h index eee7831d09..7f7a67f1db 100644 --- a/xen/include/asm-x86/hvm/svm/emulate.h +++ b/xen/include/asm-x86/hvm/svm/emulate.h @@ -30,6 +30,7 @@ enum instruction_index { INSTR_VMCALL, INSTR_HLT, INSTR_INT3, + INSTR_RDTSC, INSTR_MAX_COUNT /* Must be last - Number of instructions supported */ }; |