From mboxrd@z Thu Jan 1 00:00:00 1970 From: Duy Nguyen TN Subject: Re: Emulation failure Date: Tue, 20 Aug 2013 08:26:26 +0700 Message-ID: <1376961986.25492.36.camel@localhost> References: <1376874854.25492.10.camel@localhost> <5211E51D.8080009@redhat.com> Reply-To: duy.nguyen@dektech.com.au Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: kvm@vger.kernel.org To: Paolo Bonzini Return-path: Received: from in1083.dektech.com.au ([59.167.115.83]:35808 "EHLO mail.dektech.com.au" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751619Ab3HTB0d convert rfc822-to-8bit (ORCPT ); Mon, 19 Aug 2013 21:26:33 -0400 In-Reply-To: <5211E51D.8080009@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: V=C3=A0o T2, ng=C3=A0y 19, 08 n=C4=83m 2013 l=C3=BAc 11:27 +0200, Paolo= Bonzini vi=E1=BA=BFt: > > The disassembled code is > >=20 > > 0x1dd10: push %rbx > > 0x1dd11: mov $0x6e,%eax > > 0x1dd16: mov %rdi,%rbx > > 0x1dd19: sub $0x20,%rsp > > 0x1dd1d: test %rdi,%rdi > > 0x1dd20: je 0xb1dd92 > > 0x1dd22: mov 0x4bf1e0(%rip),%eax > > 0x1dd28: cmp $0xffffffff,%eax > > 0x1dd2b: je 0xb1ddd0 > > 0x1dd31: test %eax,%eax > > 0x1dd33: jne 0xb1dd92 > > 0x1dd35: mov 0xe1f55c(%rip),%rax > > 0x1dd3c: cmpq $0x0,0xf0(%rax) > > 0x1dd44: fildll 0xf0(%rax) > > 0x1dd4a: js 0xb1ddf0 > > 0x1dd50: mov 0xe1f54a(%rip),%eax > > 0x1dd56: mov %rax,-0x80(%rsp) > > 0x1dd5b: fildll -0x80(%rsp) > > 0x1dd5f: fmulp %st,%st(1) > >=20 > > Not sure if it helps but rax after 0xb1dd35 contains the pointer to > > mmap'd memory of /dev/hpet >=20 > I think this wouldn't work even with the latest kernel. Emulation of > x87 instructions is not supported yet. I'm confused. How could this program work? It produces similar assembly listing -- 8< -- #include #include uint64_t s_rtcClockPeriod =3D 10; uint64_t mc =3D 3000000000; int main(int ac, char **av) { uint64_t value =3D (uint64_t)((long double)mc *=20 (long double)s_rtcClockPeriod / 1000000000.0L); printf("%lu\n", value); return 0; } -- 8< -- and the assembly I got is -- 8< -- sub $0x18,%rsp cmpq $0x0,0x200adc(%rip) fildll 0x200ad6(%rip) js 0x4005f8 cmpq $0x0,0x200ac0(%rip) fildll 0x200aba(%rip) js 0x400612 fmulp %st,%st(1) fdivs 0x1ac(%rip) flds 0x1aa(%rip) fxch %st(1) fucomi %st(1),%st jae 0x4005c0 fstp %st(1) fnstcw 0x16(%rsp) =2E.. -- 8< --