KVM: x86 emulator: Add std and cld instructions (opcodes 0xfc-0xfd)

Previous thread: KVM: s390: change help text of guest Kconfig by Linux Kernel Mailing List on Thursday, October 16, 2008 - 4:04 pm. (1 message)

Next thread: KVM: ia64: Implement kvm_arch_vcpu_ioctl_{set,get}_mpstate by Linux Kernel Mailing List on Thursday, October 16, 2008 - 4:04 pm. (1 message)
From: Linux Kernel Mailing List
Date: Thursday, October 16, 2008 - 4:04 pm

Gitweb:     http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=fb4616...
Commit:     fb4616f43148c5b3f3e453a47657572d1bda39ee
Parent:     20766c083e6ab3c33125f07c7ffe39914c106d98
Author:     Mohammed Gamal <m.gamal005@gmail.com>
AuthorDate: Mon Sep 1 04:52:24 2008 +0300
Committer:  Avi Kivity <avi@qumranet.com>
CommitDate: Wed Oct 15 10:15:25 2008 +0200

    KVM: x86 emulator: Add std and cld instructions (opcodes 0xfc-0xfd)
    
    This adds the std and cld instructions to the emulator.
    
    Encountered while running the BIOS with invalid guest
    state emulation enabled.
    
    Signed-off-by: Mohammed Gamal <m.gamal005@gmail.com>
    Signed-off-by: Avi Kivity <avi@qumranet.com>
---
 arch/x86/kvm/x86_emulate.c |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/arch/x86/kvm/x86_emulate.c b/arch/x86/kvm/x86_emulate.c
index 66e0bd6..944f1f4 100644
--- a/arch/x86/kvm/x86_emulate.c
+++ b/arch/x86/kvm/x86_emulate.c
@@ -187,7 +187,7 @@ static u16 opcode_table[256] = {
 	ImplicitOps, ImplicitOps, Group | Group3_Byte, Group | Group3,
 	/* 0xF8 - 0xFF */
 	ImplicitOps, 0, ImplicitOps, ImplicitOps,
-	0, 0, Group | Group4, Group | Group5,
+	ImplicitOps, ImplicitOps, Group | Group4, Group | Group5,
 };
 
 static u16 twobyte_table[256] = {
@@ -1762,6 +1762,14 @@ special_insn:
 		ctxt->eflags |= X86_EFLAGS_IF;
 		c->dst.type = OP_NONE;	/* Disable writeback. */
 		break;
+	case 0xfc: /* cld */
+		ctxt->eflags &= ~EFLG_DF;
+		c->dst.type = OP_NONE;	/* Disable writeback. */
+		break;
+	case 0xfd: /* std */
+		ctxt->eflags |= EFLG_DF;
+		c->dst.type = OP_NONE;	/* Disable writeback. */
+		break;
 	case 0xfe ... 0xff:	/* Grp4/Grp5 */
 		rc = emulate_grp45(ctxt, ops);
 		if (rc != 0)
--

Previous thread: KVM: s390: change help text of guest Kconfig by Linux Kernel Mailing List on Thursday, October 16, 2008 - 4:04 pm. (1 message)

Next thread: KVM: ia64: Implement kvm_arch_vcpu_ioctl_{set,get}_mpstate by Linux Kernel Mailing List on Thursday, October 16, 2008 - 4:04 pm. (1 message)