Re: Bochs' "Bus error" in ARM32.

"Stanislav Shwartsman" <[email protected]> Fri, 8 Oct 2021 12:35:10 +0300
Newsgroups gmane.comp.emulators.bochs.devel
Message-ID <[email protected]>
This is a multipart message in MIME format.

--===============1233832561943353764==
Content-Type: multipart/alternative;
	boundary="----=_NextPart_000_0085_01D7BC40.EFC82880"
Content-Language: en-il

This is a multipart message in MIME format.

------=_NextPart_000_0085_01D7BC40.EFC82880
Content-Type: text/plain;
	charset="utf-8"
Content-Transfer-Encoding: quoted-printable

Seems like your host Arm system has problem top execute unaligned memory =
access (happened on some old ARM based devices) of certain size.

There is workaround for that.

In misc/bswap.h you may see how ReadHostQWordFromLittleEndian is =
implemented:

=20

BX_CPP_INLINE Bit64u ReadHostQWordFromLittleEndian(Bit64u *hostPtr)

{

#ifdef ANDROID

// Resolve problems with unaligned access

  Bit64u nativeVar64 =3D ((Bit64u) ((Bit8u *)(hostPtr))[0]) |

                       (((Bit64u) ((Bit8u *)(hostPtr))[1])<<8) |

                       (((Bit64u) ((Bit8u *)(hostPtr))[2])<<16) |

                       (((Bit64u) ((Bit8u *)(hostPtr))[3])<<24) |

                       (((Bit64u) ((Bit8u *)(hostPtr))[4])<<32) |

                       (((Bit64u) ((Bit8u *)(hostPtr))[5])<<40) |

                       (((Bit64u) ((Bit8u *)(hostPtr))[6])<<48) |

                       (((Bit64u) ((Bit8u *)(hostPtr))[7])<<56);

  return nativeVar64;

#else

  return *(hostPtr);

#endif

}

=20

With #ifdef ANDROID you get slower version of the same memory access =
which doesn=E2=80=99t do unaligned access.

If your host has problem with any unaligned accesses =E2=80=93 you =
should enable similar handling for all methods of reading memory in that =
file.

If it has problem only with QWord access -> so only =
ReadHostQWordFromLittleEndian and WriteHostQWordToLittleEndian.

=20

But be prepared that Bochs will be really terribly slow (about 2x slower =
than cheapest Intel Atom based Celeron) with this setting.

Better to have capable host hardrware.

=20

Thanks

Stanislav

=20

On Fri, Oct 8, 2021, 00:40 =D0=95=D0=B3=D0=BE=D1=80 =
=D0=93=D0=B0=D0=B2=D1=80=D0=B8=D0=BB=D0=BE=D0=B2 =
<[email protected] <mailto:[email protected]> > wrote:

I have problem with launch Debian Woody in my ARM32 device and Termux
enviroment (I am also test in Debian, launched by Proot, and have same
problem). In launch them in my device I get error "Bus error". How to =
solve?
=20
Screenshot:
https://user-images.githubusercontent.com/91898998/135873626-74bd504d-cb5=
a-45bd-9c43-91171d6b6dfa.jpg
=20
Bochsrc: my attach.
GDB log:=20
00000004635i[BIOS ] $Revision: 13073 $ $Date: 2017-02-16 22:43:52 +0100 =
(Do, 16. Feb 2017) $=20
00000318039i[KBD ] reset-disable command received=20
Program received signal SIGBUS, Bus error. 0xaab78640 in =
BX_CPU_C::system_read_qword ( laddr=3D<optimized out>) at access.cc:385 =
385 Bit64u *hostAddr =3D (Bit64u*) (hostPageAddr | pageOffset);=20

_______________________________________________
bochs-developers mailing list
[email protected] =
<mailto:[email protected]>=20
https://lists.sourceforge.net/lists/listinfo/bochs-developers


------=_NextPart_000_0085_01D7BC40.EFC82880
Content-Type: text/html;
	boundary="00000000000062deea05cdd3f350";
	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)"><style><!--
/* Font Definitions */
@font-face
	{font-family:"Cambria Math";
	panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
	{font-family:Calibri;
	panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
	{font-family:Consolas;
	panose-1:2 11 6 9 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
	{margin:0cm;
	margin-bottom:.0001pt;
	font-size:12.0pt;
	font-family:"Times New Roman",serif;}
a:link, span.MsoHyperlink
	{mso-style-priority:99;
	color:blue;
	text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
	{mso-style-priority:99;
	color:purple;
	text-decoration:underline;}
pre
	{mso-style-priority:99;
	mso-style-link:"HTML Preformatted Char";
	margin:0cm;
	margin-bottom:.0001pt;
	font-size:10.0pt;
	font-family:"Courier New";}
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;}
span.HTMLPreformattedChar
	{mso-style-name:"HTML Preformatted Char";
	mso-style-priority:99;
	mso-style-link:"HTML Preformatted";
	font-family:Consolas;}
span.EmailStyle20
	{mso-style-type:personal-compose;}
.MsoChpDefault
	{mso-style-type:export-only;
	font-family:"Calibri",sans-serif;}
@page WordSection1
	{size:612.0pt 792.0pt;
	margin:72.0pt 72.0pt 72.0pt 72.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 lang=3DEN-US link=3Dblue =
vlink=3Dpurple><div class=3DWordSection1><p class=3DMsoNormal>Seems like =
your host Arm system has problem top execute unaligned memory access =
(happened on some old ARM based devices) of certain =
size.<o:p></o:p></p><p class=3DMsoNormal>There is workaround for =
that.<o:p></o:p></p><p class=3DMsoNormal>In misc/bswap.h you may see how =
ReadHostQWordFromLittleEndian is implemented:<o:p></o:p></p><p =
class=3DMsoNormal><o:p>&nbsp;</o:p></p><p =
class=3DMsoNormal>BX_CPP_INLINE Bit64u =
ReadHostQWordFromLittleEndian(Bit64u *hostPtr)<o:p></o:p></p><p =
class=3DMsoNormal>{<o:p></o:p></p><p class=3DMsoNormal>#ifdef =
ANDROID<o:p></o:p></p><p class=3DMsoNormal>// Resolve problems with =
unaligned access<o:p></o:p></p><p class=3DMsoNormal>=C2=A0 Bit64u =
nativeVar64 =3D ((Bit64u) ((Bit8u *)(hostPtr))[0]) |<o:p></o:p></p><p =
class=3DMsoNormal>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
 (((Bit64u) ((Bit8u *)(hostPtr))[1])&lt;&lt;8) |<o:p></o:p></p><p =
class=3DMsoNormal>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
 (((Bit64u) ((Bit8u *)(hostPtr))[2])&lt;&lt;16) |<o:p></o:p></p><p =
class=3DMsoNormal>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
 (((Bit64u) ((Bit8u *)(hostPtr))[3])&lt;&lt;24) |<o:p></o:p></p><p =
class=3DMsoNormal>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
 (((Bit64u) ((Bit8u *)(hostPtr))[4])&lt;&lt;32) |<o:p></o:p></p><p =
class=3DMsoNormal>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
 (((Bit64u) ((Bit8u *)(hostPtr))[5])&lt;&lt;40) |<o:p></o:p></p><p =
class=3DMsoNormal>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
 (((Bit64u) ((Bit8u *)(hostPtr))[6])&lt;&lt;48) |<o:p></o:p></p><p =
class=3DMsoNormal>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
 (((Bit64u) ((Bit8u *)(hostPtr))[7])&lt;&lt;56);<o:p></o:p></p><p =
class=3DMsoNormal>=C2=A0 return nativeVar64;<o:p></o:p></p><p =
class=3DMsoNormal>#else<o:p></o:p></p><p class=3DMsoNormal>=C2=A0 return =
*(hostPtr);<o:p></o:p></p><p class=3DMsoNormal>#endif<o:p></o:p></p><p =
class=3DMsoNormal>}<o:p></o:p></p><p =
class=3DMsoNormal><o:p>&nbsp;</o:p></p><p class=3DMsoNormal>With #ifdef =
ANDROID you get slower version of the same memory access which =
doesn=E2=80=99t do unaligned access.<o:p></o:p></p><p =
class=3DMsoNormal>If your host has problem with any unaligned accesses =
=E2=80=93 you should enable similar handling for all methods of reading =
memory in that file.<o:p></o:p></p><p class=3DMsoNormal>If it has =
problem only with QWord access -&gt; so only =
ReadHostQWordFromLittleEndian and =
WriteHostQWordToLittleEndian.<o:p></o:p></p><p =
class=3DMsoNormal><o:p>&nbsp;</o:p></p><p class=3DMsoNormal>But be =
prepared that Bochs will be really terribly slow (about 2x slower than =
cheapest Intel Atom based Celeron) with this setting.<o:p></o:p></p><p =
class=3DMsoNormal>Better to have capable host =
hardrware.<o:p></o:p></p><p class=3DMsoNormal><o:p>&nbsp;</o:p></p><p =
class=3DMsoNormal>Thanks<o:p></o:p></p><p =
class=3DMsoNormal>Stanislav<o:p></o:p></p><p =
class=3DMsoNormal><o:p>&nbsp;</o:p></p><div><div><p class=3DMsoNormal>On =
Fri, Oct 8, 2021, 00:40 =D0=95=D0=B3=D0=BE=D1=80 =
=D0=93=D0=B0=D0=B2=D1=80=D0=B8=D0=BB=D0=BE=D0=B2 &lt;<a =
href=3D"mailto:[email protected]">[email protected]</a>&g=
t; wrote:<o:p></o:p></p></div><blockquote =
style=3D'border:none;border-left:solid #CCCCCC 1.0pt;padding:0cm 0cm 0cm =
6.0pt;margin-left:4.8pt;margin-right:0cm'><div><div =
style=3D'mso-element:para-border-div;border:none;border-left:solid =
#E5E5E5 1.0pt;padding:0cm 0cm 0cm 11.0pt'><pre =
style=3D'vertical-align:baseline;border:none;padding:0cm;outline:0px;back=
ground-image:initial;background-size:initial;background-repeat:initial;ba=
ckground-origin:initial;background-clip:initial;background-position-x:0px=
;background-position-y:0px'>I have problem with launch Debian Woody in =
my ARM32 device and Termux<o:p></o:p></pre><pre =
style=3D'vertical-align:baseline;border:none;padding:0cm'>enviroment (I =
am also test in Debian, launched by Proot, and have =
same<o:p></o:p></pre><pre =
style=3D'vertical-align:baseline;border:none;padding:0cm'>problem). In =
launch them in my device I get error &quot;Bus error&quot;. How to =
solve?<o:p></o:p></pre><pre =
style=3D'vertical-align:baseline;border:none;padding:0cm'><o:p>&nbsp;</o:=
p></pre><pre =
style=3D'vertical-align:baseline;border:none;padding:0cm'>Screenshot:<o:p=
></o:p></pre><pre =
style=3D'vertical-align:baseline;border:none;padding:0cm'><a =
href=3D"https://user-images.githubusercontent.com/91898998/135873626-74bd=
504d-cb5a-45bd-9c43-91171d6b6dfa.jpg" =
target=3D"_blank">https://user-images.githubusercontent.com/91898998/1358=
73626-74bd504d-cb5a-45bd-9c43-91171d6b6dfa.jpg</a><o:p></o:p></pre><pre =
style=3D'vertical-align:baseline;border:none;padding:0cm'><o:p>&nbsp;</o:=
p></pre><pre =
style=3D'vertical-align:baseline;border:none;padding:0cm'>Bochsrc: my =
attach.<o:p></o:p></pre><pre =
style=3D'vertical-align:baseline;border:none;padding:0cm;outline:0px;back=
ground-image:initial;background-size:initial;background-repeat:initial;ba=
ckground-origin:initial;background-clip:initial;background-position-x:0px=
;background-position-y:0px'>GDB log: <o:p></o:p></pre><pre =
style=3D'vertical-align:baseline;border:none;padding:0cm;outline:0px;back=
ground-image:initial;background-size:initial;background-repeat:initial;ba=
ckground-origin:initial;background-clip:initial;background-position-x:0px=
;background-position-y:0px'>00000004635i[BIOS ] $Revision: 13073 $ =
$Date: 2017-02-16 22:43:52 +0100 (Do, 16. Feb 2017) $ =
<o:p></o:p></pre><pre =
style=3D'vertical-align:baseline;border:none;padding:0cm;outline:0px;back=
ground-image:initial;background-size:initial;background-repeat:initial;ba=
ckground-origin:initial;background-clip:initial;background-position-x:0px=
;background-position-y:0px'>00000318039i[KBD ] reset-disable command =
received <o:p></o:p></pre><pre =
style=3D'vertical-align:baseline;border:none;padding:0cm;outline:0px;back=
ground-image:initial;background-size:initial;background-repeat:initial;ba=
ckground-origin:initial;background-clip:initial;background-position-x:0px=
;background-position-y:0px'>Program received signal SIGBUS, Bus error. =
0xaab78640 in BX_CPU_C::system_read_qword ( laddr=3D&lt;optimized =
out&gt;) at access.cc:385 385 Bit64u *hostAddr =3D (Bit64u*) =
(hostPageAddr | pageOffset); <o:p></o:p></pre></div></div><p =
class=3DMsoNormal>_______________________________________________<br>boch=
s-developers mailing list<br><a =
href=3D"mailto:[email protected]" =
target=3D"_blank">[email protected]</a><br><a =
href=3D"https://lists.sourceforge.net/lists/listinfo/bochs-developers" =
target=3D"_blank">https://lists.sourceforge.net/lists/listinfo/bochs-deve=
lopers</a><o:p></o:p></p></blockquote></div></div></body></html>
------=_NextPart_000_0085_01D7BC40.EFC82880--



--===============1233832561943353764==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline


--===============1233832561943353764==
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

--===============1233832561943353764==--