diff options
author | Keir Fraser <keir.fraser@citrix.com> | 2010-08-13 08:53:26 +0100 |
---|---|---|
committer | Keir Fraser <keir.fraser@citrix.com> | 2010-08-13 08:53:26 +0100 |
commit | 847c5ecffed4c48a2b8fbef6dfb999a474dda5b3 (patch) | |
tree | e65f30d8509e374c047c69e24d14bab37466138a | |
parent | 7427d79dafda4b33d52216ab7332062f4be495c8 (diff) | |
download | xen-847c5ecffed4c48a2b8fbef6dfb999a474dda5b3.tar.gz xen-847c5ecffed4c48a2b8fbef6dfb999a474dda5b3.tar.bz2 xen-847c5ecffed4c48a2b8fbef6dfb999a474dda5b3.zip |
svm: increment RIP over PAUSE instruction when emulating it
Signed-off-by: Christoph Egger <Christoph.Egger@amd.com>
xen-unstable changeset: 31d200e5b922
xen-unstable date: Fri Aug 13 08:31:49 2010 +0100
-rw-r--r-- | xen/arch/x86/hvm/svm/emulate.c | 4 | ||||
-rw-r--r-- | xen/arch/x86/hvm/svm/svm.c | 23 | ||||
-rw-r--r-- | xen/include/asm-x86/hvm/svm/emulate.h | 1 |
3 files changed, 21 insertions, 7 deletions
diff --git a/xen/arch/x86/hvm/svm/emulate.c b/xen/arch/x86/hvm/svm/emulate.c index b92ac06c2b..bae573dca7 100644 --- a/xen/arch/x86/hvm/svm/emulate.c +++ b/xen/arch/x86/hvm/svm/emulate.c @@ -100,6 +100,7 @@ MAKE_INSTR(VMCALL, 3, 0x0f, 0x01, 0xd9); MAKE_INSTR(HLT, 1, 0xf4); MAKE_INSTR(INT3, 1, 0xcc); MAKE_INSTR(RDTSC, 2, 0x0f, 0x31); +MAKE_INSTR(PAUSE, 1, 0x90); static const u8 *opc_bytes[INSTR_MAX_COUNT] = { @@ -111,7 +112,8 @@ static const u8 *opc_bytes[INSTR_MAX_COUNT] = [INSTR_VMCALL] = OPCODE_VMCALL, [INSTR_HLT] = OPCODE_HLT, [INSTR_INT3] = OPCODE_INT3, - [INSTR_RDTSC] = OPCODE_RDTSC + [INSTR_RDTSC] = OPCODE_RDTSC, + [INSTR_PAUSE] = OPCODE_PAUSE, }; 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 723f84a071..f4b3162b8a 100644 --- a/xen/arch/x86/hvm/svm/svm.c +++ b/xen/arch/x86/hvm/svm/svm.c @@ -1220,6 +1220,22 @@ static void svm_vmexit_do_rdtsc(struct cpu_user_regs *regs) hvm_rdtsc_intercept(regs); } +static void svm_vmexit_do_pause(struct cpu_user_regs *regs) +{ + unsigned int inst_len; + + if ( (inst_len = __get_instruction_length(current, INSTR_PAUSE)) == 0 ) + return; + __update_guest_eip(regs, inst_len); + + /* + * The guest is running a contended spinlock and we've detected it. + * Do something useful, like reschedule the guest + */ + perfc_incr(pauseloop_exits); + do_sched_op_compat(SCHEDOP_yield, 0); +} + static void svm_vmexit_ud_intercept(struct cpu_user_regs *regs) { struct hvm_emulate_ctxt ctxt; @@ -1589,12 +1605,7 @@ asmlinkage void svm_vmexit_handler(struct cpu_user_regs *regs) break; case VMEXIT_PAUSE: - /* - * The guest is running a contended spinlock and we've detected it. - * Do something useful, like reschedule the guest - */ - perfc_incr(pauseloop_exits); - do_sched_op_compat(SCHEDOP_yield, 0); + svm_vmexit_do_pause(regs); break; default: diff --git a/xen/include/asm-x86/hvm/svm/emulate.h b/xen/include/asm-x86/hvm/svm/emulate.h index 7f7a67f1db..b06f98e06f 100644 --- a/xen/include/asm-x86/hvm/svm/emulate.h +++ b/xen/include/asm-x86/hvm/svm/emulate.h @@ -31,6 +31,7 @@ enum instruction_index { INSTR_HLT, INSTR_INT3, INSTR_RDTSC, + INSTR_PAUSE, INSTR_MAX_COUNT /* Must be last - Number of instructions supported */ }; |