Skip to contentSkip to conversation

(big) real mode emulation - eflags bits manipulating instruction

PATCH Applied Nitin A Kamble 2 participants 3 messages Oct 16, 2007 – Oct 17, 2007 2 messages not in the archive KVM

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 (big) real mode emulation - eflags bits manipulating instruction

Hi Avi,

Attached is the patch implementing these eflags manipulating
instructions:

	  cmc, clc, cli, sti

	opcodes: 0xf5, 0xf8, 0xfa, 0xfb

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 6245c8d7a8878eadc17f5f32eee7e4b61cb83c6b Mon Sep 17 00:00:00 2001
From: Nitin A Kamble <[email protected]>
Date: Tue, 16 Oct 2007 18:23:27 -0700
Subject: [PATCH] Implement emulation of instruction manipulating bits of eflags.

Instruction: cmc, clc, cli, sti
opcodes: 0xf5, 0xf8, 0xfa, 0xfb respectively.

---
 drivers/kvm/x86_emulate.c |   21 +++++++++++++++++++--
 1 files changed, 19 insertions(+), 2 deletions(-)
drivers/kvm/x86_emulate.c +19 -2
index e974ace..e899434 100644
@@ -157,10 +157,10 @@ static u8 opcode_table[256] = {
 	ImplicitOps, SrcImm|ImplicitOps, 0, SrcImmByte|ImplicitOps, 0, 0, 0, 0,
 	/* 0xF0 - 0xF7 */
 	0, 0, 0, 0,
-	ImplicitOps, 0,
+	ImplicitOps, ImplicitOps,
 	ByteOp | DstMem | SrcNone | ModRM, DstMem | SrcNone | ModRM,
 	/* 0xF8 - 0xFF */
-	0, 0, 0, 0,
+	ImplicitOps, 0, ImplicitOps, ImplicitOps,
 	0, 0, ByteOp | DstMem | SrcNone | ModRM, DstMem | SrcNone | ModRM
 };
 
@@ -1451,6 +1451,23 @@ special_insn:
 	case 0xf4:              /* hlt */
 		ctxt->vcpu->halt_request = 1;
 		goto done;
+	case 0xf5:	/* cmc */
+		/* complement carry flag from eflags reg */
+		ctxt->eflags ^= EFLG_CF;
+		c->dst.type = OP_NONE;	/* Disable writeback. */
+		break;
+	case 0xf8: /* clc */
+		ctxt->eflags &= ~EFLG_CF;
+		c->dst.type = OP_NONE;	/* Disable writeback. */
+		break;
+	case 0xfa: /* cli */
+		ctxt->eflags &= ~EFLG_IF;
+		c->dst.type = OP_NONE;	/* Disable writeback. */
+		break;
+	case 0xfb: /* sti */
+		ctxt->eflags |= EFLG_IF;
+		c->dst.type = OP_NONE;	/* Disable writeback. */
+		break;
 	}
 	if (c->rep_prefix) {
 		if (c->regs[VCPU_REGS_RCX] == 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): 1192573324.2488.15.camel-mpPvwfgnXtFHIUuj5cj4Omt3HXsI98Cx0E9HWUfgJXw@public.gmane.org

Applied
#2 lore raw
Quoted 8 lines · Nitin A Kamble

Hi Avi,

Attached is the patch implementing these eflags manipulating
instructions:

	  cmc, clc, cli, sti

	opcodes: 0xf5, 0xf8, 0xfa, 0xfb

Applied, thanks. We'll have to manage the interrupt window during emulation like we do while running native, so there's more work here.

Signature · 8 lines
Do not meddle in the internals of kernels, for they are subtle and quick to panic.


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

A message that is not in the archive (sent off-list or not yet received): 4715E9DC.40408-atKUWr5tajBWk0Htik3J/[email protected]

#4 lore raw
Quoted 3 lines

Applied, thanks. We'll have to manage the interrupt window during emulation like we do while running native, so there's more work here.

I totally agree. So far I don't see any issue ignoring that aspect, so I think no point in holding emulation patch at my end. More can be added to the same "case" statement.

Thanks & Regards,
Nitin
Linux Open Source Technology Center, Intel Corporation
------------------------------------------------------------------------
--------
The Mind is like a parachute; it works much better when it's open.

Signature · 5 lines
-------------------------------------------------------------------------
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/