realnc / dosbox-core

A DOSBox core for use in RetroArch and other libretro frontends.
GNU General Public License v2.0
42 stars 16 forks source link

[Raspberry Pi 5] Core segfaults when using dynamic recompiler #57

Open vanfanel opened 8 months ago

vanfanel commented 8 months ago

Hi there,

Just built this core on the latest Raspberry Pi OS on the Pi5, and it segfaults when dosbox_core_core is set to dynamic.

Not much more to say, it seems the ARMV8L dynarec doesn't work on the Pi5.

realnc commented 7 months ago

And I guess it's not a compilation issue. So the pre-compiled core from here:

https://github.com/realnc/dosbox-core/releases/tag/latest_build_linux_arm

Doesn't work either?

vanfanel commented 7 months ago

@realnc No, that doesn't work with the dynamic core, either.

vanfanel commented 7 months ago

Could this be related?

https://github.com/flyinghead/flycast/issues/1288

Apparently, it originates from this Raspberry Pi OS bug:

https://github.com/raspberrypi/bookworm-feedback/issues/107

So, where could I set the page size for the dynarec?

vanfanel commented 7 months ago

I have confirmed that the 16K PageSize is what causes the segfault here, since using kernel=kernel8.img avoids the problem and dynarec works.

vanfanel commented 7 months ago

@realnc It's an easy fix:

src/cpu/core_dynrec.cpp:#define PAGESIZE 4096
src/cpu/core_dynrec.cpp:#define DYN_PAGE_HASH   (4096>>DYN_HASH_SHIFT)
src/cpu/core_dyn_x86.cpp:#define PAGESIZE 4096

You see these 4096? They should be 16384 so dynarec core works on the Pi5. This is because on the Pi5:

root@raspberrypi:~# getconf PAGESIZE
16384

What Flycast did to fix this, is get the PAGE_SIZE at build time: https://github.com/flyinghead/flycast/commit/0f6a92caad25ed65d6b558bb965793ae02c39be1

Would you please add such a fix to this core?

vanfanel commented 6 months ago

Well, made the fix and the corresponding PR. @realnc Please merge https://github.com/realnc/dosbox-core/pull/58