Skip to contentSkip to conversation

(big) real mode emulation - jb

PATCH In review Nitin A Kamble 2 participants 2 messages Oct 31, 2007 1 message not in the archive KVM

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 (big) real mode emulation - jb

Hi Avi,
Attached is the patch to implement emulation of instruction:

jb (opcode 0xe3)

Please apply.

Signature · 5 lines
Thanks & Regards,
Nitin
Open Source Technology Center, Intel Corporation
-----------------------------------------------------------------
The mind is like a parachute; it works much better when it's open

From 88fddcebf84c6c57c6a789bddeb0aaf41c1c9427 Mon Sep 17 00:00:00 2001
From: Nitin A Kamble <[email protected]>
Date: Tue, 30 Oct 2007 19:41:03 -0800
Subject: [PATCH] Implement emulation of instruction
jb (conditional jump)
opcodes: 0xe3

---
 drivers/kvm/x86_emulate.c |   25 ++++++++++++++++++++++++-
 1 files changed, 24 insertions(+), 1 deletions(-)
drivers/kvm/x86_emulate.c +24 -1
index 579cfcf..1357355 100644
@@ -165,7 +165,7 @@ static u16 opcode_table[256] = {
 	/* 0xD8 - 0xDF */
 	0, 0, 0, 0, 0, 0, 0, 0,
 	/* 0xE0 - 0xE7 */
-	0, 0, 0, 0, 0, 0, 0, 0,
+	0, 0, 0, ImplicitOps, 0, 0, 0, 0,
 	/* 0xE8 - 0xEF */
 	ImplicitOps, SrcImm|ImplicitOps, 0, SrcImmByte|ImplicitOps, 0, 0, 0, 0,
 	/* 0xF0 - 0xF7 */
@@ -1446,6 +1446,29 @@ x86_emulate_insn(struct x86_emulate_ctxt *ctxt, struct x86_emulate_ops *ops)
 		c->src.val = c->regs[VCPU_REGS_RCX];
 		emulate_grp2(ctxt);
 		break;
+	case 0xe3 : /* jb */ {
+		int rel = insn_fetch(s8, 1, c->eip);
+		int condition = 0;
+		if (test_cc(c->b, ctxt->eflags)) {
+			switch (c->op_bytes) {
+			case 2:
+				condition =
+					(0 == *(u16 *) &c->regs[VCPU_REGS_RCX]);
+				break;
+			case 4:
+				condition =
+					(0 == *(u32 *) &c->regs[VCPU_REGS_RCX]);
+				break;
+			case 8:
+				condition =
+					(0 == *(u64 *) &c->regs[VCPU_REGS_RCX]);
+				break;
+			}
+		}
+		if (condition)
+			JMP_REL(rel);
+		break;
+	}
 	case 0xf6 ... 0xf7:	/* Grp3 */
 		rc = emulate_grp3(ctxt, ops);
 		if (rc != 0)
Signature · 1 line
1.5.2.2

-------------------------------------------------------------------------
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

A message that is not in the archive (sent off-list or not yet received): 1193791471.9258.20.camel-mpPvwfgnXtFHIUuj5cj4Omt3HXsI98Cx0E9HWUfgJXw@public.gmane.org

#2 lore raw
Quoted 55 lines · Nitin A Kamble

Hi Avi,
Attached is the patch to implement emulation of instruction:

jb (opcode 0xe3)
[PATCH] Implement emulation of instruction jb (conditional jump)
opcodes: 0xe3
From:
Nitin A Kamble <[email protected]>
To:
Date:
2007-10-31 05:41

---
 drivers/kvm/x86_emulate.c |   25 ++++++++++++++++++++++++-
 1 files changed, 24 insertions(+), 1 deletions(-)
drivers/kvm/x86_emulate.c +1 -1
index 579cfcf..1357355 100644
@@ -165,7 +165,7 @@ static u16 opcode_table[256] = {
        /* 0xD8 - 0xDF */
        0, 0, 0, 0, 0, 0, 0, 0,
        /* 0xE0 - 0xE7 */
-       0, 0, 0, 0, 0, 0, 0, 0,
+       0, 0, 0, ImplicitOps, 0, 0, 0, 0,
        /* 0xE8 - 0xEF */
        ImplicitOps, SrcImm|ImplicitOps, 0, SrcImmByte|ImplicitOps, 0, 
 0, 0, 0,
        /* 0xF0 - 0xF7 */
drivers/kvm/x86_emulate.c +16 -0
@@ -1446,6 +1446,29 @@ x86_emulate_insn(struct x86_emulate_ctxt *ctxt, 
 struct x86_emulate_ops *ops)
                c->src.val = c->regs[VCPU_REGS_RCX];
                emulate_grp2(ctxt);
                break;
+       case 0xe3 : /* jb */ {
+               int rel = insn_fetch(s8, 1, c->eip);
+               int condition = 0;
+               if (test_cc(c->b, ctxt->eflags)) {
+                       switch (c->op_bytes) {
+                       case 2:
+                               condition =
+                                       (0 == *(u16 *) 
 &c->regs[VCPU_REGS_RCX]);
+                               break;
+                       case 4:
+                               condition =
+                                       (0 == *(u32 *) 
 &c->regs[VCPU_REGS_RCX]);
+                               break;
+                       case 8:
+                               condition =
+                                       (0 == *(u64 *) 

&c->regs[VCPU_REGS_RCX]);

drivers/kvm/x86_emulate.c x86_emulate_insn(struct x86_emulate_ctxt *ctxt, struct x86_emulate_ops *ops) · line 1474

Quoted 10 lines
drivers/kvm/x86_emulate.c +7 -0
+                               break;
+                       }
+               }
+               if (condition)
+                       JMP_REL(rel);
+               break;
+       }
        case 0xf6 ... 0xf7:     /* Grp3 */
                rc = emulate_grp3(ctxt, ops);
                if (rc != 0)

This looks more like jcxz?

Signature · 8 lines
Any sufficiently difficult bug is indistinguishable from a feature.


-------------------------------------------------------------------------
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/