Re: issue about SHRD in Bochs
"Stanislav" <[email protected]> Sat, 11 May 2019 12:18:01 +0300
| Newsgroups | gmane.comp.emulators.bochs.devel |
|---|---|
| Message-ID | <[email protected]> |
This is a multipart message in MIME format. --===============4017866485023797315== Content-Type: multipart/alternative; boundary="----=_NextPart_000_0057_01D507F3.94FD6720" Content-Language: en-il This is a multipart message in MIME format. ------=_NextPart_000_0057_01D507F3.94FD6720 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable I had problems with my Oulook, so some weird reasons it didn=E2=80=99t = sent outside any mail I composed in last few weeks. Now all mails supposed to be delivered, as well as answers to both these = questions. =20 Thanks Stanislav =20 From: ht-lab <[email protected]>=20 Sent: Friday, 10 May 2019 19:36 To: [email protected] Subject: Re: [Bochs-developers] issue about SHRD in Bochs =20 Hi Ross, Why does it matter? the behaviour is undefined so Bochs simply uses the = same code. I suspect the hardware does exactly the same, they use the = same hardware but the results are incorrect, hence undefined.=20 Are you trying to use the undefined behaviour to detect CPU type/make? Regards, Hans www.ht-lab.com <http://www.ht-lab.com>=20 On 10/05/2019 06:53, =E6=B8=A9=E5=86=80=E7=83=A8 via bochs-developers = wrote: Hi guys, This is Ross. I=E2=80=99m an X86 programmer and quite interested in = Bochs .=20 Recent study on Intel SHRD instruction brought me some questions about = how does Bochs emulates the =E2=80=9Cundefined behaviors=E2=80=9D = described in Intel=C2=AE 64 and IA-32 Architectures Software = Developer=E2=80=99s Manual.=20 =20 Follow statement talks that for shifts greater than 1 bit, the OF flag = is undefined.=20 The read lines indicates that Bochs treats the OF flag in other way. So = what=E2=80=99s your comments about? J void BX_CPP_AttrRegparmN(1) BX_CPU_C::SHRD_EqGqR(bxInstruction_c *i) { Bit64u op1_64, op2_64, result_64; unsigned count; unsigned cf, of; =E2=80=A6=20 result_64 =3D (op2_64 << (64 - count)) | (op1_64 >> count); BX_WRITE_64BIT_REG(i->dst(), result_64); SET_FLAGS_OSZAPC_LOGIC_64(result_64); cf =3D (op1_64 >> (count - 1)) & 0x1; of =3D ((result_64 << 1) ^ result_64) >> 63; // of =3D result62 ^ = result63 BX_CPU_THIS_PTR oszapc.set_flags_OxxxxC(of, cf); } BX_NEXT_INSTR(i); } =20 =20 =20 _______________________________________________ bochs-developers mailing list [email protected] = <mailto:[email protected]>=20 https://lists.sourceforge.net/lists/listinfo/bochs-developers =20 ------=_NextPart_000_0057_01D507F3.94FD6720 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable <html xmlns:v=3D"urn:schemas-microsoft-com:vml" = xmlns:o=3D"urn:schemas-microsoft-com:office:office" = xmlns:w=3D"urn:schemas-microsoft-com:office:word" = xmlns:m=3D"http://schemas.microsoft.com/office/2004/12/omml" = xmlns=3D"http://www.w3.org/TR/REC-html40"><head><meta = http-equiv=3DContent-Type content=3D"text/html; charset=3Dutf-8"><meta = name=3DGenerator content=3D"Microsoft Word 15 (filtered medium)"><!--[if = !mso]><style>v\:* {behavior:url(#default#VML);} o\:* {behavior:url(#default#VML);} w\:* {behavior:url(#default#VML);} .shape {behavior:url(#default#VML);} </style><![endif]--><style><!-- /* Font Definitions */ @font-face {font-family:Wingdings; panose-1:5 0 0 0 0 0 0 0 0 0;} @font-face {font-family:SimSun; panose-1:2 1 6 0 3 1 1 1 1 1;} @font-face {font-family:"MS Gothic"; panose-1:2 11 6 9 7 2 5 8 2 4;} @font-face {font-family:"Cambria Math"; panose-1:2 4 5 3 5 4 6 3 2 4;} @font-face {font-family:DengXian; panose-1:2 1 6 0 3 1 1 1 1 1;} @font-face {font-family:Calibri; panose-1:2 15 5 2 2 2 4 3 2 4;} @font-face {font-family:"Microsoft YaHei"; panose-1:2 11 5 3 2 2 4 2 2 4;} @font-face {font-family:Consolas; panose-1:2 11 6 9 2 2 4 3 2 4;} @font-face {font-family:"\@Microsoft YaHei";} @font-face {font-family:"\@MS Gothic"; panose-1:2 11 6 9 7 2 5 8 2 4;} @font-face {font-family:"\@SimSun"; panose-1:2 1 6 0 3 1 1 1 1 1;} @font-face {font-family:"\@DengXian"; panose-1:2 1 6 0 3 1 1 1 1 1;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {margin:0cm; margin-bottom:.0001pt; text-align:justify; font-size:10.5pt; font-family:DengXian; color:black;} a:link, span.MsoHyperlink {mso-style-priority:99; color:blue; text-decoration:underline;} a:visited, span.MsoHyperlinkFollowed {mso-style-priority:99; color:#954F72; text-decoration:underline;} p {mso-style-priority:99; mso-margin-top-alt:auto; margin-right:0cm; mso-margin-bottom-alt:auto; margin-left:0cm; font-size:12.0pt; font-family:"Times New Roman",serif; color:black;} pre {mso-style-priority:99; mso-style-link:"HTML Preformatted Char"; margin:0cm; margin-bottom:.0001pt; font-size:10.0pt; font-family:"Courier New"; color:black;} p.msonormal0, li.msonormal0, div.msonormal0 {mso-style-name:msonormal; mso-margin-top-alt:auto; margin-right:0cm; mso-margin-bottom-alt:auto; margin-left:0cm; font-size:12.0pt; font-family:"Times New Roman",serif; color:black;} span.HTMLPreformattedChar {mso-style-name:"HTML Preformatted Char"; mso-style-priority:99; mso-style-link:"HTML Preformatted"; font-family:Consolas; color:black;} span.EmailStyle21 {mso-style-type:personal-reply; font-family:"Calibri",sans-serif; color:#1F497D;} .MsoChpDefault {mso-style-type:export-only; font-size:10.0pt;} @page WordSection1 {size:612.0pt 792.0pt; margin:72.0pt 90.0pt 72.0pt 90.0pt;} div.WordSection1 {page:WordSection1;} --></style><!--[if gte mso 9]><xml> <o:shapedefaults v:ext=3D"edit" spidmax=3D"1026" /> </xml><![endif]--><!--[if gte mso 9]><xml> <o:shapelayout v:ext=3D"edit"> <o:idmap v:ext=3D"edit" data=3D"1" /> </o:shapelayout></xml><![endif]--></head><body bgcolor=3Dwhite = lang=3DEN-US link=3Dblue vlink=3D"#954F72"><div class=3DWordSection1><p = class=3DMsoNormal><span = style=3D'font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D'= >I had problems with my Oulook, so some weird reasons it didn=E2=80=99t = sent outside any mail I composed in last few = weeks.<o:p></o:p></span></p><p class=3DMsoNormal><span = style=3D'font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D'= >Now all mails supposed to be delivered, as well as answers to both = these questions.<o:p></o:p></span></p><p class=3DMsoNormal><span = style=3D'font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D'= ><o:p> </o:p></span></p><p class=3DMsoNormal><span = style=3D'font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D'= >Thanks<o:p></o:p></span></p><p class=3DMsoNormal><span = style=3D'font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D'= >Stanislav<o:p></o:p></span></p><p class=3DMsoNormal><span = style=3D'font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D'= ><o:p> </o:p></span></p><div><div = style=3D'border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0cm = 0cm 0cm'><p class=3DMsoNormal align=3Dleft = style=3D'text-align:left'><b><span = style=3D'font-size:11.0pt;font-family:"Calibri",sans-serif;color:windowte= xt'>From:</span></b><span = style=3D'font-size:11.0pt;font-family:"Calibri",sans-serif;color:windowte= xt'> ht-lab <[email protected]> <br><b>Sent:</b> Friday, 10 May = 2019 19:36<br><b>To:</b> = [email protected]<br><b>Subject:</b> Re: = [Bochs-developers] issue about SHRD in = Bochs<o:p></o:p></span></p></div></div><p class=3DMsoNormal align=3Dleft = style=3D'text-align:left'><o:p> </o:p></p><div><p = class=3DMsoNormal>Hi Ross,<br><br>Why does it matter? the behaviour is = undefined so Bochs simply uses the same code. I suspect the hardware = does exactly the same, they use the same hardware but the results are = incorrect, hence undefined. <br><br>Are you trying to use the undefined = behaviour to detect CPU type/make?<br><br>Regards,<br>Hans<br><a = href=3D"http://www.ht-lab.com">www.ht-lab.com</a><br><br><br>On = 10/05/2019 06:53, <span style=3D'font-family:"MS = Gothic"'>=E6=B8=A9=E5=86=80</span><span = style=3D'font-family:SimSun'>=E7=83=A8</span> via bochs-developers = wrote:<span = style=3D'font-size:12.0pt'><o:p></o:p></span></p></div><blockquote = style=3D'margin-top:5.0pt;margin-bottom:5.0pt'><p = class=3DMsoNormal><span style=3D'font-size:9.0pt;font-family:"Microsoft = YaHei",sans-serif'>Hi guys,</span><o:p></o:p></p><p><span = style=3D'font-size:9.0pt;font-family:"Microsoft YaHei",sans-serif'>This = is Ross. I=E2=80=99m an X86 programmer and quite interested in Bochs . = </span><o:p></o:p></p><div><div><p class=3DMsoNormal = style=3D'mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span = style=3D'font-size:9.0pt;font-family:"Microsoft = YaHei",sans-serif'>Recent study on Intel SHRD instruction brought me = some questions about how does Bochs emulates the =E2=80=9Cundefined = behaviors=E2=80=9D described in Intel=C2=AE 64 and IA-32 Architectures = Software Developer=E2=80=99s Manual. </span><o:p></o:p></p><p = class=3DMsoNormal = style=3D'mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span = style=3D'font-size:9.0pt;font-family:"Microsoft = YaHei",sans-serif'> </span><o:p></o:p></p><p class=3DMsoNormal = style=3D'mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span = style=3D'font-size:9.0pt;font-family:"Microsoft = YaHei",sans-serif'>Follow statement talks that for shifts greater than 1 = bit, the OF flag is undefined. </span><o:p></o:p></p><p><span = style=3D'font-size:9.0pt;font-family:"Microsoft YaHei",sans-serif'><img = border=3D0 width=3D717 height=3D125 = style=3D'width:7.4687in;height:1.302in' id=3D"_x0000_i1025" = src=3D"cid:[email protected]" = alt=3D"cid:[email protected]"></span><o:p></o:p></p= ><p><span style=3D'font-size:9.0pt;font-family:"Microsoft = YaHei",sans-serif;color:red'>The read lines indicates that Bochs treats = the OF flag in other way. So what=E2=80=99s your comments about? = </span><span = style=3D'font-size:9.0pt;font-family:Wingdings;color:red'>J</span><o:p></= o:p></p><p><i><span style=3D'font-size:9.0pt;font-family:"Microsoft = YaHei",sans-serif'>void BX_CPP_AttrRegparmN(1) = BX_CPU_C::SHRD_EqGqR(bxInstruction_c *i)<br>{<br> Bit64u op1_64, = op2_64, result_64;<br> unsigned count;<br> unsigned cf, = of;<br><br> =E2=80=A6 <br> result_64 =3D (op2_64 = << (64 - count)) | (op1_64 >> count);<br> = BX_WRITE_64BIT_REG(i->dst(), result_64);<br> = SET_FLAGS_OSZAPC_LOGIC_64(result_64);<br><br></span></i><i><span = style=3D'font-size:9.0pt;font-family:"Microsoft = YaHei",sans-serif;color:red'> cf =3D (op1_64 >> = (count - 1)) & 0x1;<br> of =3D ((result_64 = << 1) ^ result_64) >> 63; // of =3D result62 ^ = result63<br> BX_CPU_THIS_PTR = oszapc.set_flags_OxxxxC(of, cf);</span></i><i><span = style=3D'font-size:9.0pt;font-family:"Microsoft = YaHei",sans-serif'><br> }<br><br> = BX_NEXT_INSTR(i);<br>}</span></i><o:p></o:p></p></div></div><p = class=3DMsoNormal><span style=3D'font-family:"Times New = Roman",serif'> </span><o:p></o:p></p><p class=3DMsoNormal><span = style=3D'font-size:12.0pt;font-family:SimSun'> </span><o:p></o:p></p= ><p class=3DMsoNormal><span style=3D'font-family:"Times New = Roman",serif'> </span><o:p></o:p></p><p class=3DMsoNormal = align=3Dleft style=3D'text-align:left'><span = style=3D'font-size:12.0pt;font-family:"Times New = Roman",serif'><br><br><br><o:p></o:p></span></p><pre>____________________= ___________________________<o:p></o:p></pre><pre>bochs-developers = mailing list<o:p></o:p></pre><pre><a = href=3D"mailto:[email protected]">bochs-developers@l= ists.sourceforge.net</a><o:p></o:p></pre><pre><a = href=3D"https://lists.sourceforge.net/lists/listinfo/bochs-developers">ht= tps://lists.sourceforge.net/lists/listinfo/bochs-developers</a><o:p></o:p= ></pre></blockquote><p class=3DMsoNormal align=3Dleft = style=3D'text-align:left'><span = style=3D'font-size:12.0pt;font-family:"Times New = Roman",serif'><o:p> </o:p></span></p></div></body></html> ------=_NextPart_000_0057_01D507F3.94FD6720-- --===============4017866485023797315== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline --===============4017866485023797315== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ bochs-developers mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/bochs-developers --===============4017866485023797315==--