Fwd: Bochs' "Bus error" in ARM32.

Егор Гаврилов <[email protected]> Fri, 8 Oct 2021 19:55:58 +0300
Newsgroups gmane.comp.emulators.bochs.devel
Message-ID <CAA3UnA7beYCj14Z0gmgYX7Jy6uZY5-Sb2a4MiaqMxzJ11yDyQQ@mail.gmail.com>
--===============8791964751751267106==
Content-Type: multipart/alternative; boundary="000000000000a9032605cdda418a"

--000000000000a9032605cdda418a
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

---------- Forwarded message ---------
=D0=9E=D1=82: =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]>
Date: =D0=BF=D1=82, 8 =D0=BE=D0=BA=D1=82. 2021 =D0=B3., 17:38
Subject: Re: [Bochs-developers] Bochs' "Bus error" in ARM32.
To: Stanislav Shwartsman <[email protected]>


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

This problem have on Termux for Android. I have ARM64 budget phone and
ARM32 budget phone, but Bochs working only on ARM64 phone with Termux.
Perfomance is equaly Pentium MMX/II (on ARM64 phone), and 486/Pentium on
ARM32 phone with Bochs native app.

Postscriptum: How to setting compiler to working with ANDROID directive?

=D0=BF=D1=8F=D1=82=D0=BD=D0=B8=D1=86=D0=B0, 8 =D0=BE=D0=BA=D1=82=D1=8F=D0=
=B1=D1=80=D1=8F 2021 =D0=B3. =D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=
=B0=D1=82=D0=B5=D0=BB=D1=8C Stanislav Shwartsman <
[email protected]> =D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB:

> 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:
>
>
>
> 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
>
> }
>
>
>
> With #ifdef ANDROID you get slower version of the same memory access whic=
h
> 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.
>
>
>
> 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.
>
>
>
> Thanks
>
> Stanislav
>
>
>
> 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]>
> 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 sol=
ve?
>
>
>
> Screenshot:
>
> https://user-images.githubusercontent.com/91898998/135873626-74bd504d-cb5=
a-45bd-9c43-91171d6b6dfa.jpg
>
>
>
> Bochsrc: my attach.
>
> GDB log:
>
> 00000004635i[BIOS ] $Revision: 13073 $ $Date: 2017-02-16 22:43:52 +0100 (=
Do, 16. Feb 2017) $
>
> 00000318039i[KBD ] reset-disable command received
>
> Program received signal SIGBUS, Bus error. 0xaab78640 in BX_CPU_C::system=
_read_qword ( laddr=3D<optimized out>) at access.cc:385 385 Bit64u *hostAdd=
r =3D (Bit64u*) (hostPageAddr | pageOffset);
>
> _______________________________________________
> bochs-developers mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/bochs-developers
>
>

--000000000000a9032605cdda418a
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"auto"></div><br><div class=3D"gmail_quote"><div dir=3D"ltr" cla=
ss=3D"gmail_attr">---------- Forwarded message ---------<br>=D0=9E=D1=82: <=
strong class=3D"gmail_sendername" dir=3D"auto">=D0=95=D0=B3=D0=BE=D1=80 =D0=
=93=D0=B0=D0=B2=D1=80=D0=B8=D0=BB=D0=BE=D0=B2</strong> <span dir=3D"auto">&=
lt;<a href=3D"mailto:[email protected]">[email protected]</=
a>&gt;</span><br>Date: =D0=BF=D1=82, 8 =D0=BE=D0=BA=D1=82. 2021 =D0=B3., 17=
:38<br>Subject: Re: [Bochs-developers] Bochs&#39; &quot;Bus error&quot; in =
ARM32.<br>To: Stanislav Shwartsman &lt;<a href=3D"mailto:[email protected]=
">[email protected]</a>&gt;<br></div><br><br><div>&gt;But be prepared that=
 Bochs will be really terribly slow (about 2x slower than cheapest Intel At=
om based Celeron) with this setting.<br></div><div><br></div>This problem h=
ave on Termux for Android. I have ARM64 budget phone and ARM32 budget phone=
, but Bochs working only on ARM64 phone with Termux. Perfomance is equaly P=
entium MMX/II (on ARM64 phone), and 486/Pentium on ARM32 phone with Bochs n=
ative app.<div><br></div><div>Postscriptum: How to setting compiler to work=
ing with ANDROID directive?<br><br>=D0=BF=D1=8F=D1=82=D0=BD=D0=B8=D1=86=D0=
=B0, 8 =D0=BE=D0=BA=D1=82=D1=8F=D0=B1=D1=80=D1=8F 2021 =D0=B3. =D0=BF=D0=BE=
=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D1=8C Stanislav Shwa=
rtsman &lt;<a href=3D"mailto:[email protected]" target=3D"_blank" rel=3D"n=
oreferrer">[email protected]</a>&gt; =D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=
=D0=BB:<br><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;bor=
der-left:1px #ccc solid;padding-left:1ex"><div lang=3D"EN-US" link=3D"blue"=
 vlink=3D"purple"><div><p class=3D"MsoNormal">Seems like your host Arm syst=
em has problem top execute unaligned memory access (happened on some old AR=
M based devices) of certain size.<u></u><u></u></p><p class=3D"MsoNormal">T=
here is workaround for that.<u></u><u></u></p><p class=3D"MsoNormal">In mis=
c/bswap.h you may see how ReadHostQWordFromLittleEndian is implemented:<u><=
/u><u></u></p><p class=3D"MsoNormal"><u></u>=C2=A0<u></u></p><p class=3D"Ms=
oNormal">BX_CPP_INLINE Bit64u ReadHostQWordFromLittleEndian(Bit64u *hostPtr=
)<u></u><u></u></p><p class=3D"MsoNormal">{<u></u><u></u></p><p class=3D"Ms=
oNormal">#ifdef ANDROID<u></u><u></u></p><p class=3D"MsoNormal">// Resolve =
problems with unaligned access<u></u><u></u></p><p class=3D"MsoNormal">=C2=
=A0 Bit64u nativeVar64 =3D ((Bit64u) ((Bit8u *)(hostPtr))[0]) |<u></u><u></=
u></p><p class=3D"MsoNormal">=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) |<u></u><u></u><=
/p><p class=3D"MsoNormal">=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) |<u></u><u></u></p=
><p class=3D"MsoNormal">=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) |<u></u><u></u></p><p=
 class=3D"MsoNormal">=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) |<u></u><u></u></p><p cl=
ass=3D"MsoNormal">=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) |<u></u><u></u></p><p class=
=3D"MsoNormal">=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) |<u></u><u></u></p><p class=3D=
"MsoNormal">=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 (((Bi=
t64u) ((Bit8u *)(hostPtr))[7])&lt;&lt;56);<u></u><u></u></p><p class=3D"Mso=
Normal">=C2=A0 return nativeVar64;<u></u><u></u></p><p class=3D"MsoNormal">=
#else<u></u><u></u></p><p class=3D"MsoNormal">=C2=A0 return *(hostPtr);<u><=
/u><u></u></p><p class=3D"MsoNormal">#endif<u></u><u></u></p><p class=3D"Ms=
oNormal">}<u></u><u></u></p><p class=3D"MsoNormal"><u></u>=C2=A0<u></u></p>=
<p class=3D"MsoNormal">With #ifdef ANDROID you get slower version of the sa=
me memory access which doesn=E2=80=99t do unaligned access.<u></u><u></u></=
p><p class=3D"MsoNormal">If your host has problem with any unaligned access=
es =E2=80=93 you should enable similar handling for all methods of reading =
memory in that file.<u></u><u></u></p><p class=3D"MsoNormal">If it has prob=
lem only with QWord access -&gt; so only ReadHostQWordFromLittleEndian and =
WriteHostQWordToLittleEndian.<u></u><u></u></p><p class=3D"MsoNormal"><u></=
u>=C2=A0<u></u></p><p class=3D"MsoNormal">But be prepared that Bochs will b=
e really terribly slow (about 2x slower than cheapest Intel Atom based Cele=
ron) with this setting.<u></u><u></u></p><p class=3D"MsoNormal">Better to h=
ave capable host hardrware.<u></u><u></u></p><p class=3D"MsoNormal"><u></u>=
=C2=A0<u></u></p><p class=3D"MsoNormal">Thanks<u></u><u></u></p><p class=3D=
"MsoNormal">Stanislav<u></u><u></u></p><p class=3D"MsoNormal"><u></u>=C2=A0=
<u></u></p><div><div><p class=3D"MsoNormal">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]" target=3D"_blank" rel=3D"noref=
errer">[email protected]</a>&gt; wrote:<u></u><u></u></p></div><blo=
ckquote style=3D"border:none;border-left:solid #cccccc 1.0pt;padding:0cm 0c=
m 0cm 6.0pt;margin-left:4.8pt;margin-right:0cm"><div><div style=3D"border:n=
one;border-left:solid #e5e5e5 1.0pt;padding:0cm 0cm 0cm 11.0pt"><pre style=
=3D"vertical-align:baseline;border:none;padding:0cm;outline:0px;background-=
image:initial;background-repeat:initial">I have problem with launch Debian =
Woody in my ARM32 device and Termux<u></u><u></u></pre><pre style=3D"vertic=
al-align:baseline;border:none;padding:0cm">enviroment (I am also test in De=
bian, launched by Proot, and have same<u></u><u></u></pre><pre style=3D"ver=
tical-align:baseline;border:none;padding:0cm">problem). In launch them in m=
y device I get error &quot;Bus error&quot;. How to solve?<u></u><u></u></pr=
e><pre style=3D"vertical-align:baseline;border:none;padding:0cm"><u></u>=C2=
=A0<u></u></pre><pre style=3D"vertical-align:baseline;border:none;padding:0=
cm">Screenshot:<u></u><u></u></pre><pre style=3D"vertical-align:baseline;bo=
rder:none;padding:0cm"><a href=3D"https://user-images.githubusercontent.com=
/91898998/135873626-74bd504d-cb5a-45bd-9c43-91171d6b6dfa.jpg" target=3D"_bl=
ank" rel=3D"noreferrer">https://user-images.githubusercontent.com/91898998/=
135873626-74bd504d-cb5a-45bd-9c43-91171d6b6dfa.jpg</a><u></u><u></u></pre><=
pre style=3D"vertical-align:baseline;border:none;padding:0cm"><u></u>=C2=A0=
<u></u></pre><pre style=3D"vertical-align:baseline;border:none;padding:0cm"=
>Bochsrc: my attach.<u></u><u></u></pre><pre style=3D"vertical-align:baseli=
ne;border:none;padding:0cm;outline:0px;background-image:initial;background-=
repeat:initial">GDB log: <u></u><u></u></pre><pre style=3D"vertical-align:b=
aseline;border:none;padding:0cm;outline:0px;background-image:initial;backgr=
ound-repeat:initial">00000004635i[BIOS ] $Revision: 13073 $ $Date: 2017-02-=
16 22:43:52 +0100 (Do, 16. Feb 2017) $ <u></u><u></u></pre><pre style=3D"ve=
rtical-align:baseline;border:none;padding:0cm;outline:0px;background-image:=
initial;background-repeat:initial">00000318039i[KBD ] reset-disable command=
 received <u></u><u></u></pre><pre style=3D"vertical-align:baseline;border:=
none;padding:0cm;outline:0px;background-image:initial;background-repeat:ini=
tial">Program received signal SIGBUS, Bus error. 0xaab78640 in BX_CPU_C::sy=
stem_read_qword ( laddr=3D&lt;optimized out&gt;) at access.cc:385 385 Bit64=
u *hostAddr =3D (Bit64u*) (hostPageAddr | pageOffset); <u></u><u></u></pre>=
</div></div><p class=3D"MsoNormal">________________________________________=
_______<br>bochs-developers mailing list<br><a href=3D"mailto:bochs-develop=
[email protected]" target=3D"_blank" rel=3D"noreferrer">bochs-devel=
[email protected]</a><br><a href=3D"https://lists.sourceforge.net=
/lists/listinfo/bochs-developers" target=3D"_blank" rel=3D"noreferrer">http=
s://lists.sourceforge.net/lists/listinfo/bochs-developers</a><u></u><u></u>=
</p></blockquote></div></div></div></blockquote></div>
</div>

--000000000000a9032605cdda418a--


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


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

--===============8791964751751267106==--