cebix / macemu

Basilisk II and SheepShaver Macintosh emulators
1.37k stars 285 forks source link

Added support for AARCH64. #229

Closed rickyzhang82 closed 3 years ago

rickyzhang82 commented 3 years ago

For AARCH64 architecture, Linux doesn't honor MAP_32BIT parameter in mmap. Thus, we can't use direct addressing.

The fix in this PR forces AARCH64 to use virtual addressing (a.k.a memory banks) and bypass the sanity check where allocated memory must be under 4GiB. In fact, the sanity check is unnecessary for virtual addressing in any architecture, either.

Because the base addresses for host RAM, host ROM, host frame buffer are separate when perform address mapping between the host and the guest. But direct addressing requires host RAM, host ROM, host frame buffer are in consecutive memory area.

I also updated the outdated script config.guess and config.sub from GNU FTP. This fixed the road block in configure in AARCH64.

I think this is better fix than another PR for AARCH64. I tested the build and run BII in QEMU. It works fine.

Below is my another repo including script that I use to spin up AARCH 64 QEMU: https://github.com/rickyzhang82/arm64-ubuntu-20.04

rickyzhang82 commented 3 years ago

I also added Travis CI for aarch64 architecture.

See build info: https://travis-ci.org/github/rickyzhang82/macemu/builds/746506426

rickyzhang82 commented 3 years ago

@asvitkine Any concerns on this PR?

SegHaxx commented 3 years ago

Direct addressing works just fine on aarch64 with #225. Any reason you're so opposed to fixing direct addressing? And PPC64 and RISC-V will still be broken as well as any future platform that comes along.

rickyzhang82 commented 3 years ago

Don't take me wrong. I opposed adding the magic number in your PR #225, which forces mmap starts with allocated address at 0x10000.

         #define MAP_BASE   0x00010000

In ASLR, how can you be so sure you don't cause the conflict problem? I'd prefer to let the kernel decide.

Regarding to direct addressing, your PR works by luck. RAM+ROM allocate by mmap and then frame buffer allocate by mmap again. The direct addressing expects they are in contiguous memory and within 4GiB limit, which is not always correct.

The direct address mapping is a simple difference between host and guest.

https://github.com/cebix/macemu/blob/d684527b27ecca9b76a7895abd25b1eba5317a1c/BasiliskII/src/uae_cpu/memory.h#L126-L134

ianfixes commented 3 years ago

Is there a document on using QEMU to test other platforms? I'm curious about setting that up in CI.

Also, is there a way to run tests on the addressing system in an automated way?

rickyzhang82 commented 3 years ago
ianfixes commented 3 years ago

I built an Ubuntu in aarch64 under QEMU to build and test the PR

I am looking for the commands that you use to do this. Can you provide them please, or point me to where they're documented?

rickyzhang82 commented 3 years ago

RTFM: https://github.com/rickyzhang82/arm64-ubuntu-20.04