Skip to contentSkip to conversation

emulate_instruction() calls now x86_decode_insn() and x86_emulate_insn()

PATCH Superseded Laurent Vivier 1 participant 1 message Aug 29, 2007 KVM

lore
Share & tools
lore
#0 lore raw

PATCH 4/5 emulate_instruction() calls now x86_decode_insn() and x86_emulate_insn()

emulate_instruction() calls now x86_decode_insn() and x86_emulate_insn(). x86_emulate_insn() is x86_emulate_memop() without the decoding part.

drivers/kvm/kvm_main.c +5 -1
Index: kvm/drivers/kvm/kvm_main.c
===================================================================
@@ -1201,9 +1201,13 @@ int emulate_instruction(struct kvm_vcpu 
 	emulate_ctxt.gs_base = get_segment_base(vcpu, VCPU_SREG_GS);
 	emulate_ctxt.fs_base = get_segment_base(vcpu, VCPU_SREG_FS);
 
+	r = x86_decode_insn(&emulate_ctxt, &emulate_ops);
+	if (r)
+		return EMULATE_FAIL;
+
 	vcpu->mmio_is_write = 0;
 	vcpu->pio.string = 0;
-	r = x86_emulate_memop(&emulate_ctxt, &emulate_ops);
+	r = x86_emulate_insn(&emulate_ctxt, &emulate_ops);
 	if (vcpu->pio.string)
 		return EMULATE_DO_MMIO;
 
drivers/kvm/x86_emulate.c +2 -6
Index: kvm/drivers/kvm/x86_emulate.c
===================================================================
@@ -881,19 +881,15 @@ cannot_emulate:
 }
 
 int
-x86_emulate_memop(struct x86_emulate_ctxt *ctxt, struct x86_emulate_ops *ops)
+x86_emulate_insn(struct x86_emulate_ctxt *ctxt, struct x86_emulate_ops *ops)
 {
 	struct decode_cache *decode = &ctxt->decode;
-	int rc;
+	int rc = 0;
 	int mode = ctxt->mode;
 	int no_wb = 0;
 	u64 msr_data;
 	unsigned long _eflags = ctxt->eflags;
 
-	rc = x86_decode_insn(ctxt, ops);
-	if (rc)
-		return rc;
-
 	if (decode->src.type == OP_MEM) {
 		decode->src.ptr = (unsigned long *)ctxt->cr2;
 		if ((rc = ops->read_emulated((unsigned long)decode->src.ptr,
drivers/kvm/x86_emulate.h +3 -6
Index: kvm/drivers/kvm/x86_emulate.h
===================================================================
@@ -178,12 +178,9 @@ struct x86_emulate_ctxt {
 #define X86EMUL_MODE_HOST X86EMUL_MODE_PROT64
 #endif
 
-/*
- * x86_emulate_memop: Emulate an instruction that faulted attempting to
- *                    read/write a 'special' memory area.
- * Returns -1 on failure, 0 on success.
- */
-int x86_emulate_memop(struct x86_emulate_ctxt *ctxt,
+int x86_decode_insn(struct x86_emulate_ctxt *ctxt,
+		    struct x86_emulate_ops *ops);
+int x86_emulate_insn(struct x86_emulate_ctxt *ctxt,
 		      struct x86_emulate_ops *ops);
 
 #endif				/* __X86_EMULATE_H__ */

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/

_______________________________________________
kvm-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/kvm-devel