KVM: x86 emulator: add the assembler code for three operands

Previous thread: KVM: x86 emulator: add a new "implied 1" Src decode type by Linux Kernel Mailing List on Friday, January 2, 2009 - 2:03 pm. (1 message)

Next thread: KVM: x86 emulator: add the emulation of shld and shrd instructions by Linux Kernel Mailing List on Friday, January 2, 2009 - 2:03 pm. (1 message)
From: Linux Kernel Mailing List
Date: Friday, January 2, 2009 - 2:03 pm

Gitweb:     http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=d17522...
Commit:     d175226a5f54817ba427368c6b739aefa7780fb2
Parent:     bfcadf83ec5aafe600e73dd427d997db7bcc1d12
Author:     Guillaume Thouvenin <guillaume.thouvenin@ext.bull.net>
AuthorDate: Thu Dec 4 14:29:00 2008 +0100
Committer:  Avi Kivity <avi@redhat.com>
CommitDate: Wed Dec 31 16:55:42 2008 +0200

    KVM: x86 emulator: add the assembler code for three operands
    
    Add the assembler code for instruction with three operands and one
    operand is stored in ECX register
    
    Signed-off-by: Guillaume Thouvenin <guillaume.thouvenin@ext.bull.net>
    Signed-off-by: Avi Kivity <avi@redhat.com>
---
 arch/x86/kvm/x86_emulate.c |   39 +++++++++++++++++++++++++++++++++++++++
 1 files changed, 39 insertions(+), 0 deletions(-)

diff --git a/arch/x86/kvm/x86_emulate.c b/arch/x86/kvm/x86_emulate.c
index 0c75306..9ae6d5b 100644
--- a/arch/x86/kvm/x86_emulate.c
+++ b/arch/x86/kvm/x86_emulate.c
@@ -431,6 +431,45 @@ static u32 group2_table[] = {
 	__emulate_2op_nobyte(_op, _src, _dst, _eflags,			\
 			     "w", "r", _LO32, "r", "", "r")
 
+/* Instruction has three operands and one operand is stored in ECX register */
+#define __emulate_2op_cl(_op, _cl, _src, _dst, _eflags, _suffix, _type) 	\
+	do {									\
+		unsigned long _tmp;						\
+		_type _clv  = (_cl).val;  					\
+		_type _srcv = (_src).val;    					\
+		_type _dstv = (_dst).val;					\
+										\
+		__asm__ __volatile__ (						\
+			_PRE_EFLAGS("0", "5", "2")				\
+			_op _suffix " %4,%1 \n"					\
+			_POST_EFLAGS("0", "5", "2")				\
+			: "=m" (_eflags), "+r" (_dstv), "=&r" (_tmp)		\
+			: "c" (_clv) , "r" (_srcv), "i" (EFLAGS_MASK)		\
+			); 							\
+										\
+		(_cl).val  = (unsigned long) _clv;				\
+		(_src).val = (unsigned long) _srcv;				\
+		(_dst).val = (unsigned long) _dstv;				\
+	} while (0)
+
+#define emulate_2op_cl(_op, _cl, _src, _dst, _eflags)				\
+	do ...
Previous thread: KVM: x86 emulator: add a new "implied 1" Src decode type by Linux Kernel Mailing List on Friday, January 2, 2009 - 2:03 pm. (1 message)

Next thread: KVM: x86 emulator: add the emulation of shld and shrd instructions by Linux Kernel Mailing List on Friday, January 2, 2009 - 2:03 pm. (1 message)