Fix Basilisk II crash on Linux aarch64 #141
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I just had an... interesting exchange with upstream then discovered the action is over here. But it did improve my understanding of the various addressing modes. So I offer my patch here. :)
Basilisk II fails to start a VM on Debian aarch64, in my case a Raspi4.
Add a printf debug and you can see this is because MAP_BASE defaults to 0x0 which is unavailable for security reasons on recent Linux distributions thus the memory allocator falls back on a standard allocation way up in 64bit address space, which fails the "sanity check" and returns a misleading "not enough memory" error to the user.
There are two fixes for this. Direct addressing mode can be fixed by bumping MAP_BASE up past the security/debug guard. Direct addressing mode is what configure currently defaults to on aarch64.
The other fix is to use banked addressing mode instead. This still requires a fix to not perform the "sanity check" which is not needed in this case.
This patch fixes both addressing modes. The default remains on direct addressing mode.
I have not touched the linux i386|FreeBSD|HAVE_LINKER_SCRIPT case as I assume its working properly but the more I learn the codebase, the more inclined i am to revise that bit as well... :)
This should fix Basilisk II on aarch64 without breaking current cases. I've also tested Linux x86_64. Please test and tell me if it breaks anything. (windows and macOS have their own code paths and should be unaffected)
I have not gotten around to getting SheepShaver running yet so I have not tested it.