Skip to content

Conversation

@rickyzhang82
Copy link
Contributor

@rickyzhang82 rickyzhang82 commented Nov 28, 2020

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

For AARCH64 architecture, Linux doesn't honor MAP_32_BIT parameter in mmap. So we force AARCH64 use virtual addressing (a.k.a memory banks) and bypase the sanity check in mmap.
In fact, the sanity check is not needed for virtual addressing in x86_64 architecture, either.
Signed-off-by: Ricky Zhang <rickyzhang@gmail.com>
@rickyzhang82
Copy link
Contributor Author

rickyzhang82 commented Nov 29, 2020

I also added Travis CI for aarch64 architecture.

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

@rickyzhang82
Copy link
Contributor Author

@asvitkine Any concerns on this PR?

@SegHaxx
Copy link

SegHaxx commented Dec 1, 2020

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
Copy link
Contributor Author

rickyzhang82 commented Dec 1, 2020

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.

#if REAL_ADDRESSING || DIRECT_ADDRESSING
static __inline__ uae_u8 *do_get_real_address(uaecptr addr)
{
return (uae_u8 *)MEMBaseDiff + addr;
}
static __inline__ uae_u32 do_get_virtual_address(uae_u8 *addr)
{
return (uintptr)addr - MEMBaseDiff;
}

@ianfixes
Copy link

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
Copy link
Contributor Author

  • Read my first post. I built an Ubuntu in aarch64 under QEMU to build and test the PR.
  • Travis CI include build in aarch64 Linux
  • No unit test or integration test in BII

@ianfixes
Copy link

ianfixes commented Dec 21, 2020

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
Copy link
Contributor Author

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

@asvitkine asvitkine merged commit 76f8f3c into cebix:master Jun 19, 2021
@rickyzhang82 rickyzhang82 deleted the pr-support-aarch64 branch June 20, 2021 01:05
rakslice pushed a commit to rakslice/macemu that referenced this pull request Dec 31, 2024
Fix Microseconds() implementation for clock_gettime and other posix
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants