Re: Fwd: Bochs' "Bus error" in ARM32.

Stanislav Shwartsman <[email protected]> Sat, 9 Oct 2021 16:12:55 +0300
Newsgroups gmane.comp.emulators.bochs.devel
Message-ID <CAAAheh0dK8LedC2yd3WFioLa60Y44C9tkodRGNdos3suhHRQ1Q@mail.gmail.com>
--===============5690280279862881643==
Content-Type: multipart/alternative; boundary="000000000000aa15b605cdeb4169"

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

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

Define it manually in config.h :)
We don't officially support it.

On Fri, Oct 8, 2021 at 7:56 PM =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:

>
> ---------- 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
>> which doesn=E2=80=99t do unaligned access.
>>
>> If your host has problem with any unaligned accesses =E2=80=93 you shoul=
d 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 so=
lve?
>>
>>
>>
>> Screenshot:
>>
>> https://user-images.githubusercontent.com/91898998/135873626-74bd504d-cb=
5a-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::syste=
m_read_qword ( laddr=3D<optimized out>) at access.cc:385 385 Bit64u *hostAd=
dr =3D (Bit64u*) (hostPageAddr | pageOffset);
>>
>> _______________________________________________
>> bochs-developers mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/bochs-developers
>>
>> _______________________________________________
> bochs-developers mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/bochs-developers
>

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

<div dir=3D"ltr">&gt;Postscriptum: How to setting compiler to working with =
ANDROID directive?<br><div><br></div><div>Define it manually in config.h :)=
</div><div>We don&#39;t officially support it.</div></div><br><div class=3D=
"gmail_quote"><div dir=3D"ltr" class=3D"gmail_attr">On Fri, Oct 8, 2021 at =
7:56 PM =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]">gavrilovegor519@gma=
il.com</a>&gt; wrote:<br></div><blockquote class=3D"gmail_quote" style=3D"m=
argin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left=
:1ex"><div dir=3D"auto"></div><br><div class=3D"gmail_quote"><div dir=3D"lt=
r" class=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]" target=3D"_blank">ga=
[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]" target=3D"_blank">[email protected]</a>&gt;=
<br></div><br><br><div>&gt;But be prepared that Bochs will be really terrib=
ly slow (about 2x slower than cheapest Intel Atom based Celeron) with this =
setting.<br></div><div><br></div>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 phon=
e), and 486/Pentium on ARM32 phone with Bochs native app.<div><br></div><di=
v>Postscriptum: How to setting compiler to working 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 Shwartsman &lt;<a href=3D"mailt=
o:[email protected]" rel=3D"noreferrer" target=3D"_blank">[email protected]=
om</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:0px 0px 0px 0.8ex;border-left:1px solid rg=
b(204,204,204);padding-left:1ex"><div lang=3D"EN-US"><div><p class=3D"MsoNo=
rmal">Seems like your host Arm system has problem top execute unaligned mem=
ory access (happened on some old ARM based devices) of certain size.<u></u>=
<u></u></p><p class=3D"MsoNormal">There is workaround for that.<u></u><u></=
u></p><p class=3D"MsoNormal">In misc/bswap.h you may see how ReadHostQWordF=
romLittleEndian is implemented:<u></u><u></u></p><p class=3D"MsoNormal"><u>=
</u>=C2=A0<u></u></p><p class=3D"MsoNormal">BX_CPP_INLINE Bit64u ReadHostQW=
ordFromLittleEndian(Bit64u *hostPtr)<u></u><u></u></p><p class=3D"MsoNormal=
">{<u></u><u></u></p><p class=3D"MsoNormal">#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) ((Bi=
t8u *)(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 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))[5])&lt;&l=
t;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;4=
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))[7])&lt;&lt;56);=
<u></u><u></u></p><p class=3D"MsoNormal">=C2=A0 return nativeVar64;<u></u><=
u></u></p><p class=3D"MsoNormal">#else<u></u><u></u></p><p class=3D"MsoNorm=
al">=C2=A0 return *(hostPtr);<u></u><u></u></p><p class=3D"MsoNormal">#endi=
f<u></u><u></u></p><p class=3D"MsoNormal">}<u></u><u></u></p><p class=3D"Ms=
oNormal"><u></u>=C2=A0<u></u></p><p class=3D"MsoNormal">With #ifdef ANDROID=
 you get slower version of the same 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 accesses =E2=80=93 you should enable similar han=
dling for all methods of reading memory in that file.<u></u><u></u></p><p c=
lass=3D"MsoNormal">If it has problem only with QWord access -&gt; so only R=
eadHostQWordFromLittleEndian 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 be really terribly slow (about 2x slower th=
an cheapest Intel Atom based Celeron) with this setting.<u></u><u></u></p><=
p class=3D"MsoNormal">Better to have capable host hardrware.<u></u><u></u><=
/p><p class=3D"MsoNormal"><u></u>=C2=A0<u></u></p><p class=3D"MsoNormal">Th=
anks<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]=
" rel=3D"noreferrer" target=3D"_blank">[email protected]</a>&gt; wr=
ote:<u></u><u></u></p></div><blockquote style=3D"border-top:none;border-rig=
ht:none;border-bottom:none;border-left:1pt solid rgb(204,204,204);padding:0=
cm 0cm 0cm 6pt;margin-left:4.8pt;margin-right:0cm"><div><div style=3D"borde=
r-top:none;border-right:none;border-bottom:none;border-left:1pt solid rgb(2=
29,229,229);padding:0cm 0cm 0cm 11pt"><pre style=3D"vertical-align:baseline=
;border:none;padding:0cm;outline:0px;background-image:initial;background-re=
peat:initial">I have problem with launch Debian Woody in my ARM32 device an=
d Termux<u></u><u></u></pre><pre style=3D"vertical-align:baseline;border:no=
ne;padding:0cm">enviroment (I am also test in Debian, launched by Proot, an=
d have same<u></u><u></u></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?<u></u><u></u></pre><pre style=3D"vertical-al=
ign:baseline;border:none;padding:0cm"><u></u>=C2=A0<u></u></pre><pre style=
=3D"vertical-align:baseline;border:none;padding:0cm">Screenshot:<u></u><u><=
/u></pre><pre style=3D"vertical-align:baseline;border:none;padding:0cm"><a =
href=3D"https://user-images.githubusercontent.com/91898998/135873626-74bd50=
4d-cb5a-45bd-9c43-91171d6b6dfa.jpg" rel=3D"noreferrer" target=3D"_blank">ht=
tps://user-images.githubusercontent.com/91898998/135873626-74bd504d-cb5a-45=
bd-9c43-91171d6b6dfa.jpg</a><u></u><u></u></pre><pre style=3D"vertical-alig=
n: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:baseline;border:none;padding:0cm=
;outline:0px;background-image:initial;background-repeat:initial">GDB log: <=
u></u><u></u></pre><pre style=3D"vertical-align:baseline;border:none;paddin=
g:0cm;outline:0px;background-image:initial;background-repeat:initial">00000=
004635i[BIOS ] $Revision: 13073 $ $Date: 2017-02-16 22:43:52 +0100 (Do, 16.=
 Feb 2017) $ <u></u><u></u></pre><pre style=3D"vertical-align:baseline;bord=
er: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:0=
px;background-image:initial;background-repeat:initial">Program received sig=
nal 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); <u></u><u></u></pre></div></div><p class=3D"Ms=
oNormal">_______________________________________________<br>bochs-developer=
s mailing list<br><a href=3D"mailto:[email protected]"=
 rel=3D"noreferrer" target=3D"_blank">[email protected]=
t</a><br><a href=3D"https://lists.sourceforge.net/lists/listinfo/bochs-deve=
lopers" rel=3D"noreferrer" target=3D"_blank">https://lists.sourceforge.net/=
lists/listinfo/bochs-developers</a><u></u><u></u></p></blockquote></div></d=
iv></div></blockquote></div>
</div>
_______________________________________________<br>
bochs-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" r=
el=3D"noreferrer" target=3D"_blank">https://lists.sourceforge.net/lists/lis=
tinfo/bochs-developers</a><br>
</blockquote></div>

--000000000000aa15b605cdeb4169--


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


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

--===============5690280279862881643==--