diff mbox

KVM: x86 emulator: simplify BSF/BSR instruction emulation

Message ID 4C722003.1090401@cn.fujitsu.com (mailing list archive)
State New, archived
Headers show

Commit Message

Wei Yongjun Aug. 23, 2010, 7:15 a.m. UTC
None
diff mbox

Patch

diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
index 7d99cbe..77da7b6 100644
--- a/arch/x86/kvm/emulate.c
+++ b/arch/x86/kvm/emulate.c
@@ -3727,30 +3727,16 @@  twobyte_insn:
 	      btc:		/* btc */
 		emulate_2op_SrcV_nobyte("btc", c->src, c->dst, ctxt->eflags);
 		break;
-	case 0xbc: {		/* bsf */
-		u8 zf;
-		__asm__ ("bsf %2, %0; setz %1"
-			 : "=r"(c->dst.val), "=q"(zf)
-			 : "r"(c->src.val));
-		ctxt->eflags &= ~X86_EFLAGS_ZF;
-		if (zf) {
-			ctxt->eflags |= X86_EFLAGS_ZF;
-			c->dst.type = OP_NONE;	/* Disable writeback. */
-		}
+	case 0xbc:		/* bsf */
+		emulate_2op_SrcV_nobyte("bsf", c->src, c->dst, ctxt->eflags);
+		if (ctxt->eflags & X86_EFLAGS_ZF)
+			c->dst.type = OP_NONE;  /* Disable writeback. */
 		break;
-	}
-	case 0xbd: {		/* bsr */
-		u8 zf;
-		__asm__ ("bsr %2, %0; setz %1"
-			 : "=r"(c->dst.val), "=q"(zf)
-			 : "r"(c->src.val));
-		ctxt->eflags &= ~X86_EFLAGS_ZF;
-		if (zf) {
-			ctxt->eflags |= X86_EFLAGS_ZF;
-			c->dst.type = OP_NONE;	/* Disable writeback. */
-		}
+	case 0xbd:		/* bsr */
+		emulate_2op_SrcV_nobyte("bsr", c->src, c->dst, ctxt->eflags);
+		if (ctxt->eflags & X86_EFLAGS_ZF)
+			c->dst.type = OP_NONE;  /* Disable writeback. */
 		break;
-	}
 	case 0xbe ... 0xbf:	/* movsx */
 		c->dst.bytes = c->op_bytes;
 		c->dst.val = (c->d & ByteOp) ? (s8) c->src.val :