From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: Re: [PATCH] KVM: x86 emulator: add bsf/bsr instruction emulation Date: Mon, 09 Aug 2010 23:14:21 -0400 Message-ID: <4C60C40D.7070905@redhat.com> References: <4C5FD1A5.5040805@cn.fujitsu.com> Mime-Version: 1.0 Content-Type: text/plain; charset=GB2312 Content-Transfer-Encoding: 7bit Cc: kvm@vger.kernel.org To: Wei Yongjun Return-path: Received: from mx1.redhat.com ([209.132.183.28]:48510 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755532Ab0HJDOk (ORCPT ); Mon, 9 Aug 2010 23:14:40 -0400 In-Reply-To: <4C5FD1A5.5040805@cn.fujitsu.com> Sender: kvm-owner@vger.kernel.org List-ID: On 08/09/2010 06:00 AM, Wei Yongjun wrote: > Add bsf/bsr instruction emulation (opcode 0x0f 0xbc~0xbd) > > @@ -3464,6 +3464,30 @@ twobyte_insn: > btc: /* btc */ > emulate_2op_SrcV_nobyte("btc", c->src, c->dst, ctxt->eflags); > break; > + case 0xbc: { /* bsf */ > + int zf; > + __asm__ ("bsf %2, %0; setz %b1" > + : "=r"(c->dst.val), "=q"(zf) > + : "r"(c->src.val), "1" (0)); Won't the high bytes of zf remain clear? Please examine the assembly. Declaring it u8 is probably better. -- I have a truly marvellous patch that fixes the bug which this signature is too narrow to contain.