From ca352bf22562da8abeea3a807baf0836ed34b6b8 Mon Sep 17 00:00:00 2001 From: MaxsTechReview Date: Tue, 20 Oct 2026 08:52:31 -0400 Subject: [PATCH] fix: RPCS3 opens from the emulator rail again (#1191) RPCS3's AppImage could not start: its own runtime unpacks the image with a dwarfsextract it runs from a memfd, which Android refuses (EACCES), and it has no other way to run it. Emulator AppImages for arm64 now start through the shipped uruntime, which falls back to a file in /tmp. RPCS3 then stopped with "Null object" in utils::shm (errno 13): it reads /proc/sys/vm/overcommit_memory to pick memfd for guest memory, and apps cannot read it. The guest now gets the kernel's default policy (0) there when the real file is unreadable, like file-max. --- README.md | 2 +- .../launcher/runtime/LinuxRuntime.java | 12 +++-- .../runtime/LinuxRuntimeProcFilesTest.kt | 38 ++++++++++++++ .../overlay/usr/local/bin/droiddeck-session | 4 ++ tools/tests/test_session_appimage.py | 49 +++++++++++++++++++ 5 files changed, 101 insertions(+), 4 deletions(-) create mode 100644 app/src/test/java/com/droiddeck/launcher/runtime/LinuxRuntimeProcFilesTest.kt create mode 100644 tools/tests/test_session_appimage.py diff --git a/README.md b/README.md index 25ea3ee8ab..abb3beb3f2 100644 --- a/README.md +++ b/README.md @@ -47,7 +47,7 @@ Compatibility and performance vary by device; hardware validation is limited. De ## Credits and licence -GPL-3.0. Runtime, shim, input, and controller work build on WinNative and Bannerlator (maxjivi05). Epic Games and GOG support build on [Phobos’s](https://github.com/phobos665) adaptation of [Legendary](https://github.com/legendary-gl/legendary) and [gogdl](https://github.com/Heroic-Games-Launcher/heroic-gogdl), respectively. The registry entries a GOG game's install script (`goggame-.script`) sets are read the way [Heroic Games Launcher](https://github.com/Heroic-Games-Launcher/HeroicGamesLauncher)'s GOG setup (GPL-3.0) reads them. LSFG frame generation is from the work of Camille LaVey and the [Eden](https://eden-emu.dev) emulator project, following [lsfg-vk](https://github.com/PancakeTAS/lsfg-vk), ported to WinNative and DroidDeck by [@maxjivi05](https://github.com/maxjivi05); it needs your own copy of [Lossless Scaling](https://store.steampowered.com/app/993090/) and ships none of its shaders. x86 AppImages, and any whose own runtime cannot unpack them, are unpacked with [uruntime](https://github.com/VHSgunzo/uruntime) by VHSgunzo (MIT), shipped unmodified with its licence. The Steam client's audio goes through [@The412Banner](https://github.com/The412Banner)'s [DirectAudio](https://github.com/The412Banner/directaudio) PulseAudio sink (LGPL-2.1-or-later), built from `tools/directaudio/sink` with its request size kept to its ring so clients are not asked to queue 100 ms ahead. mmap ring-buffer controller input was developed by ribbit384 ([WinNative #345](https://github.com/WinNative-Emu/WinNative/pull/345)). Why the x86-64 Steam client refused the arm64 client's sign-in was checked by reading Steam's saved token with the `ConnectCache` format from [deadlock-api-ingest](https://github.com/deadlock-api/deadlock-api-ingest). x86 programs that link OpenSSL 3 under FEX use the copy in the [Steam Linux Runtime 4.0](https://gitlab.steamos.cloud/steamrt/steamrt) platform. Hooks written with `WriteProcessMemory` into code [FEX](https://github.com/FEX-Emu/FEX) has translated go through `/proc//mem` again when the kernel refuses `process_vm_writev`, as [Wine](https://gitlab.winehq.org/wine/wine)'s `server/ptrace.c` wrote them before Wine 11. x86 Linux games under FEX get the same `/etc/asound.conf` that [pressure-vessel](https://gitlab.steamos.cloud/steamrt/steam-runtime-tools) writes into the Steam Linux Runtime, so ALSA plays through PulseAudio. See [LICENSE](LICENSE). Steam and Proton belong to Valve Corporation; this project is not affiliated with Valve. +GPL-3.0. Runtime, shim, input, and controller work build on WinNative and Bannerlator (maxjivi05). Epic Games and GOG support build on [Phobos’s](https://github.com/phobos665) adaptation of [Legendary](https://github.com/legendary-gl/legendary) and [gogdl](https://github.com/Heroic-Games-Launcher/heroic-gogdl), respectively. The registry entries a GOG game's install script (`goggame-.script`) sets are read the way [Heroic Games Launcher](https://github.com/Heroic-Games-Launcher/HeroicGamesLauncher)'s GOG setup (GPL-3.0) reads them. LSFG frame generation is from the work of Camille LaVey and the [Eden](https://eden-emu.dev) emulator project, following [lsfg-vk](https://github.com/PancakeTAS/lsfg-vk), ported to WinNative and DroidDeck by [@maxjivi05](https://github.com/maxjivi05); it needs your own copy of [Lossless Scaling](https://store.steampowered.com/app/993090/) and ships none of its shaders. x86 AppImages, and any whose own runtime cannot unpack them, are unpacked with [uruntime](https://github.com/VHSgunzo/uruntime) by VHSgunzo (MIT), shipped unmodified with its licence, which also starts the arm64 emulator AppImages whose own runtime cannot run its extractor on Android. The Steam client's audio goes through [@The412Banner](https://github.com/The412Banner)'s [DirectAudio](https://github.com/The412Banner/directaudio) PulseAudio sink (LGPL-2.1-or-later), built from `tools/directaudio/sink` with its request size kept to its ring so clients are not asked to queue 100 ms ahead. mmap ring-buffer controller input was developed by ribbit384 ([WinNative #345](https://github.com/WinNative-Emu/WinNative/pull/345)). Why the x86-64 Steam client refused the arm64 client's sign-in was checked by reading Steam's saved token with the `ConnectCache` format from [deadlock-api-ingest](https://github.com/deadlock-api/deadlock-api-ingest). x86 programs that link OpenSSL 3 under FEX use the copy in the [Steam Linux Runtime 4.0](https://gitlab.steamos.cloud/steamrt/steamrt) platform. Hooks written with `WriteProcessMemory` into code [FEX](https://github.com/FEX-Emu/FEX) has translated go through `/proc//mem` again when the kernel refuses `process_vm_writev`, as [Wine](https://gitlab.winehq.org/wine/wine)'s `server/ptrace.c` wrote them before Wine 11. x86 Linux games under FEX get the same `/etc/asound.conf` that [pressure-vessel](https://gitlab.steamos.cloud/steamrt/steam-runtime-tools) writes into the Steam Linux Runtime, so ALSA plays through PulseAudio. See [LICENSE](LICENSE). Steam and Proton belong to Valve Corporation; this project is not affiliated with Valve. XR glasses support builds on WinNative's VITURE glasses work. VITURE protocol details were checked against [XRLinuxDriver](https://github.com/wheaney/XRLinuxDriver) by [@wheaney](https://github.com/wheaney), including the VITURE protocol header it ships, [ar-drivers-rs](https://github.com/badicsalex/ar-drivers-rs) by [@badicsalex](https://github.com/badicsalex) and the [go-macos/iokit VITURE package](https://pkg.go.dev/github.com/go-macos/iokit/viture); the optional VITURE SDK belongs to VITURE and is not included. RayNeo support adapts [@informalTechCode](https://github.com/informalTechCode)'s [RayNeo-Air-Series-3DoF-Scaffold](https://github.com/informalTechCode/RayNeo-Air-Series-3DoF-Scaffold) (Apache-2.0) and references [@verncat](https://github.com/verncat)'s [RayNeo-Air-3S-Pro-OpenVR](https://github.com/verncat/RayNeo-Air-3S-Pro-OpenVR) (MIT) and [Monado](https://gitlab.freedesktop.org/monado/monado) (BSL-1.0); see [docs/third-party/rayneo](docs/third-party/rayneo/README.md). XREAL 1S support references [XRLinuxDriver](https://github.com/wheaney/XRLinuxDriver) and [xrealOneDeviceKit](https://github.com/wheaney/xrealOneDeviceKit) by @wheaney, [xreal_one_driver](https://github.com/rohitsangwan01/xreal_one_driver) by [@rohitsangwan01](https://github.com/rohitsangwan01) (MIT) and [xr-tools](https://github.com/0xcaff/xr-tools) by [@0xcaff](https://github.com/0xcaff). The REDMAGIC glasses-display findings draw on [@mekhontsev](https://github.com/mekhontsev)'s [MagicDesk investigation](https://github.com/mekhontsev/magicdesk/blob/main/docs/xr-resolution-fix.md) and [@Coding-BR](https://github.com/Coding-BR)'s [decompiled Nubia kernel](https://github.com/Coding-BR/android_kernel_nubia_sm8850_qwjujube). VITURE, RayNeo, XREAL and REDMAGIC are trademarks of their owners; this project is not affiliated with them. diff --git a/app/src/main/java/com/droiddeck/launcher/runtime/LinuxRuntime.java b/app/src/main/java/com/droiddeck/launcher/runtime/LinuxRuntime.java index c729850fcd..869a6fdf17 100644 --- a/app/src/main/java/com/droiddeck/launcher/runtime/LinuxRuntime.java +++ b/app/src/main/java/com/droiddeck/launcher/runtime/LinuxRuntime.java @@ -187,10 +187,15 @@ public final class LinuxRuntime { } catch (java.io.IOException e) { } } - File fileMax = new File(fakeProc, "file-max"); - if (!fileMax.isFile()) { + String[][] seeded = { + {"file-max", "9223372036854775807\n"}, + {"overcommit_memory", "0\n"}, + }; + for (String[] entry : seeded) { + File fake = new File(fakeProc, entry[0]); + if (fake.isFile()) continue; try { - Files.write(fileMax.toPath(), "9223372036854775807\n".getBytes(StandardCharsets.US_ASCII)); + Files.write(fake.toPath(), entry[1].getBytes(StandardCharsets.US_ASCII)); } catch (IOException e) { } } @@ -205,6 +210,7 @@ public final class LinuxRuntime { {"overflowuid", "/proc/sys/kernel/overflowuid"}, {"overflowgid", "/proc/sys/kernel/overflowgid"}, {"file-max", "/proc/sys/fs/file-max"}, + {"overcommit_memory", "/proc/sys/vm/overcommit_memory"}, }; for (String[] entry : procFiles) { File fake = new File(fakeProc, entry[0]); diff --git a/app/src/test/java/com/droiddeck/launcher/runtime/LinuxRuntimeProcFilesTest.kt b/app/src/test/java/com/droiddeck/launcher/runtime/LinuxRuntimeProcFilesTest.kt new file mode 100644 index 0000000000..1638132af1 --- /dev/null +++ b/app/src/test/java/com/droiddeck/launcher/runtime/LinuxRuntimeProcFilesTest.kt @@ -0,0 +1,38 @@ +package com.droiddeck.launcher.runtime + +import android.content.ContextWrapper +import java.io.File +import java.nio.file.Files +import org.junit.After +import org.junit.Assert.assertEquals +import org.junit.Test +import org.junit.runner.RunWith +import org.robolectric.RobolectricTestRunner +import org.robolectric.RuntimeEnvironment + +@RunWith(RobolectricTestRunner::class) +class LinuxRuntimeProcFilesTest { + private val root = Files.createTempDirectory("guest-proc-files").toFile() + private val context = object : ContextWrapper(RuntimeEnvironment.getApplication()) { + override fun getFilesDir() = File(root, "files").apply { mkdirs() } + override fun getCacheDir() = File(root, "cache").apply { mkdirs() } + override fun getNoBackupFilesDir() = File(root, "no_backup").apply { mkdirs() } + } + private val fakeProc get() = File(LinuxRuntime.rootDir(context), "etc/droiddeck/proc") + + @After fun tearDown() { + root.deleteRecursively() + } + + @Test fun theGuestGetsAnOvercommitPolicyItCanRead() { + LinuxRuntime.binds(context, null, null, null, null) + assertEquals("0\n", File(fakeProc, "overcommit_memory").readText()) + assertEquals("9223372036854775807\n", File(fakeProc, "file-max").readText()) + } + + @Test fun aSeededFileIsKept() { + File(fakeProc, "overcommit_memory").apply { parentFile!!.mkdirs(); writeText("1\n") } + LinuxRuntime.binds(context, null, null, null, null) + assertEquals("1\n", File(fakeProc, "overcommit_memory").readText()) + } +} diff --git a/tools/linuxfs/overlay/usr/local/bin/droiddeck-session b/tools/linuxfs/overlay/usr/local/bin/droiddeck-session index 1b2ae2f483..9b56c76bcf 100755 --- a/tools/linuxfs/overlay/usr/local/bin/droiddeck-session +++ b/tools/linuxfs/overlay/usr/local/bin/droiddeck-session @@ -331,6 +331,10 @@ case $mode in *.appimage) export APPIMAGE_EXTRACT_AND_RUN=1 chmod +x "$target" 2>/dev/null + if [ ${#fex[@]} -eq 0 ] && [ -x /usr/local/lib/droiddeck/uruntime ]; then + export TARGET_APPIMAGE=$target + run_program /usr/local/lib/droiddeck/uruntime "$@" + fi run_program "${fex[@]}" "$target" "$@" ;; *.sh) diff --git a/tools/tests/test_session_appimage.py b/tools/tests/test_session_appimage.py new file mode 100644 index 0000000000..f1ba2d11af --- /dev/null +++ b/tools/tests/test_session_appimage.py @@ -0,0 +1,49 @@ +import os +import re +import shutil +import subprocess +import tempfile +import unittest +from pathlib import Path + +SESSION = Path(__file__).resolve().parents[1] / "linuxfs/overlay/usr/local/bin/droiddeck-session" +URUNTIME = "/usr/local/lib/droiddeck/uruntime" + + +def target_case(): + match = re.search(r"^ case \$\{target,,\} in\n.*?^ esac\n", SESSION.read_text(), re.M | re.S) + return match.group(0) + + +class SessionAppImageTest(unittest.TestCase): + def setUp(self): + self.dir = Path(tempfile.mkdtemp()) + self.addCleanup(shutil.rmtree, self.dir, True) + self.image = self.dir / "rpcs3.AppImage" + self.image.write_bytes(b"\x7fELF") + self.uruntime = self.dir / "uruntime" + self.uruntime.write_text("#!/bin/sh\n") + self.uruntime.chmod(0o755) + + def launch(self, fex=()): + script = ("set -u\n" + "run_program() { printf '%%s\\n' \"TARGET=${TARGET_APPIMAGE:-} EXTRACT=${APPIMAGE_EXTRACT_AND_RUN:-}\" \"$@\"; exit 0; }\n" + "target=%s\nfex=(%s)\nset -- --no-gui\n" % (self.image, " ".join(fex)) + + target_case().replace(URUNTIME, str(self.uruntime))) + env = {k: v for k, v in os.environ.items() if k not in ("TARGET_APPIMAGE", "APPIMAGE_EXTRACT_AND_RUN")} + return subprocess.run(["bash", "-c", script], env=env, capture_output=True, text=True, timeout=30).stdout.splitlines() + + def test_an_arm64_image_runs_through_the_shipped_runtime(self): + self.assertEqual(["TARGET=%s EXTRACT=1" % self.image, str(self.uruntime), "--no-gui"], self.launch()) + + def test_without_the_shipped_runtime_the_image_runs_itself(self): + self.uruntime.unlink() + self.assertEqual(["TARGET= EXTRACT=1", str(self.image), "--no-gui"], self.launch()) + + def test_an_x86_image_still_starts_under_fex(self): + fex = ("/usr/local/bin/droiddeck-fex", "run", "--mode", "on", "--") + self.assertEqual(["TARGET= EXTRACT=1", *fex, str(self.image), "--no-gui"], self.launch(fex)) + + +if __name__ == "__main__": + unittest.main()