cebix / macemu

Basilisk II and SheepShaver Macintosh emulators
1.38k stars 289 forks source link

Manjaro Linux: SheepShaver 2.4 error upon attempting to run. #169

Open Xeddius opened 6 years ago

Xeddius commented 6 years ago

Regardless of settings upon pressing start the following error appears when runing SheepShaver from terminal. (Running outside of terminal the window also disappears so I assume this error isn't terminal related.)

ERROR: Cannot map Low Memory Globals: Operation not permitted

cat7 commented 6 years ago

You might try the SELinux settings required to run SheepShaver documented here: https://www.emaculation.com/doku.php/ubuntu and run SheepShaver as root.

Xeddius commented 6 years ago

@cat7 I'm on Arch/Manjaro linux, it doesn't use SELinux at all. (At least, not unless I manually install it.) The error persists even running SheepShaver as root.

orazioedoardo commented 6 years ago

@Xeddius

First, read the default minimum address that a process can map (remember this value) : cat /proc/sys/vm/mmap_min_addr

Temporarily allow mapping the NULL page with this command: sudo sysctl -w vm.mmap_min_addr="0"

Sheepshaver should now run (even without root).

When you are done, reset the default one with: sudo sysctl -w vm.mmap_min_addr="original value here"

This is a security feature, so I wouldn't make it permanent via sysctl.conf

rickyzhang82 commented 6 years ago

Hey guys, No need to mess around this to enable page 0. Try different addressing mode in Linux.

For technical details, please read my wiki

rickyzhang82 commented 6 years ago

If TLDR, enable direct address in configure. This alone could save you hacking around SELinux and system parm. I don't like enable page 0 in LInux unless you want to open a hole for malicious software.

orazioedoardo commented 6 years ago

Thanks for the heads up, however it crashes when I attempt the emulation. I'm getting segmentation fault right after "Reading ROM file...". I configured it with ./configure --enable-addressing=direct.

rickyzhang82 commented 6 years ago

Sorry, I misread your problem. My code analysis on addressing is based on BII. It might not work for SheepShaver. I apologized for that.

timbomov commented 6 years ago

Have you tried setting "Ignore illegal memory access" to true in the preference file? There's also a "ignore illegal instructions" preference setting too. Is a preference file even created/present when you get this error?

schinkelg commented 3 years ago

I'm having the same issue with Sheepshaver 2.4. The "ignore illegal instructions" setting does not change things. This is on the latest Arch with the latest Sheepshaver source (master).

schinkelg commented 3 years ago

Using direct addressing it segfaults on the memset in line 43 of xpram.cpp, trying to initialize extended parameter RAM.

schinkelg commented 3 years ago

For others who run into this error: it is the page 0 problem as described in the wiki. Running as root is not an option for me. Temporarily lowering system-wide security is also problematic for obvious reasons. My fix was the following:

setcap cap_sys_rawio=ep <location_of_sheepshaver_binary>

Now only the Sheepshaver process has rights (which can be leveraged to root, so take care) to mmap() with address 0.

orazioedoardo commented 3 years ago

Thanks @schinkelg. I've also found a way to give SheepShaver the CAP_SYS_RAWIO capability for a single execution:

sudo -E capsh --user=$USER --inh=cap_sys_rawio --addamb=cap_sys_rawio -- -c <location_of_sheepshaver_binary>

You need root to start however the SheepShaver process will actually run with as unprivileged user.

jacobamills commented 3 years ago

Any chance this is fixable?

Was trying (w/o success) to get SheepShaver running on Chrome OS. But I think the crostini vm is pretty restrictive in what it allows, so neither of the following work:

sudo sysctl -w vm.mmap_min_addr=0

sysctl: permission denied on key 'vm.mmap_min_addr'
setcap cap_sys_rawio=ep <location_of_sheepshaver_binary>

vm.mmap_min_addr=0 also can't be set from /etc/sysctl.conf, nor from /etc/sysctl.d/mmap_min_addr.conf.

I believe this is enforced w/ CONFIG_SECURITY_DEFAULT_MMAP_MIN_ADDR=65536 (https://www.chromium.org/chromium-os/chromiumos-design-docs/system-hardening). Or at least that sets the default, and the crostini vm (running in lxc container) can't override the vm host default (https://itectec.com/ubuntu/ubuntu-modifying-sysctl-values-inside-lxc-container/)?

Also wasn't able to get direct addressing to work.

Is it even possible for SheepShaver to be updated to not require vm.mmap_min_addr=0?

schinkelg commented 2 years ago

@jacobamills I'm not familiar with the inner workings of ChromeOS, but with lxc containers you still need to find a way to configure the running host kernel. Where did you try the sysctl command? It should work if ChromeOS allows it from the host... And yes, unfortunately the memory mapping is a requirement as the emulator needs to present the memory to the emulated software starting at address 0.

@Xeddius You can probably close this issue now?