mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-20 05:16:01 +00:00
Force SSBS for Proton games (libssbs.so), switch under FEX preset (#328)
* Force SSBS for a game's Wine: libssbs.so, opt in per game Wine's arm64 signal code resumes threads from a Windows CONTEXT whose Cpsr never carries PSTATE.SSBS, so every signal return leaves the thread running with speculative store bypass disabled - slower on cores such as Oryon. Bannerlator fixes it in its own Wine builds (force_ssbs.diff, Sonicadvance1) and with an LD_PRELOAD adapter for layers it cannot rebuild. DroidDeck's Protons (Valve, GE, CachyOS ARM64) come prebuilt from Steam but run the same aarch64 Wine signal path, so the adapter applies here: tools/linuxfs/ssbs/ssbs_adapter.c, the same source built for glibc (+ sysv_signal), staged to /usr/local/lib/libssbs.so. droiddeck-game-env preloads it when the game's (or the shared) environment sets DROIDDECK_FORCE_SSBS=1, and only into an ARM64 Proton. Off unless asked for: the gain is unproven on Snapdragon 8 Gen 3. For testing: SSBS_ADAPTER_OBSERVE=1 counts without changing anything (the baseline) and SSBS_ADAPTER_DEBUG=1 logs the fixes; both also count signals that ARRIVE while a thread runs without SSBS, which shows whether anything besides signal returns clears it. Checked on an ARM64 Linux kernel: a handler that clears SSBS left 4 of 5 later signals arriving with it clear; with the adapter, 0 of 5. * Force SSBS: a switch under the FEX preset in Steam settings Steam settings > Games gets "Force SSBS" right under the FEX preset, off unless turned on. Like the preset it goes into the game environment's defaults (DROIDDECK_FORCE_SSBS=1), published at once and read by droiddeck-game-env on the next game launch, so a game's own environment can still set it to 0. Measured on the device with the adapter's counters (AYANEO Pocket FIT, DiRT 3 on GE-Proton11-7-aarch64): observing only, 8192 of 8277 signals found the thread running without SSBS; with the adapter, none did - it keeps the bit set everywhere Wine clears it, as a rebuilt ntdll would. The speed-up itself is reported on Oryon cores and was not measurable on the FIT's 8 Gen 3, hence off by default. --------- Co-authored-by: The412Banner <the412banner@users.noreply.github.com>
This commit is contained in:
1 parent
a1b01a04a8
commit
bc01b77752
13 files changed
+283
-6
No files matched your search
@@ -196,6 +196,30 @@ def without_pack(chosen_env, env):
|
||||
return result
|
||||
|
||||
|
||||
SSBS_LIB = "/usr/local/lib/libssbs.so"
|
||||
|
||||
|
||||
def force_ssbs(command, env):
|
||||
"""DROIDDECK_FORCE_SSBS=1 (a game's or the shared environment): preload libssbs.so into this
|
||||
Proton's Wine, which then keeps PSTATE.SSBS set across signal returns - speculative store
|
||||
bypass stays allowed, as force_ssbs.diff does inside a rebuilt ntdll. ARM64 Protons only: the
|
||||
library is aarch64 and only arm64 Wine has the signal path it fixes."""
|
||||
if env.get("DROIDDECK_FORCE_SSBS", "").lower() not in ("1", "on", "true", "yes"):
|
||||
return env
|
||||
proton = os.path.dirname(command[0]) if command else ""
|
||||
if not os.path.isdir(os.path.join(proton, "files/lib/wine/aarch64-unix")):
|
||||
print("droiddeck-game-env: force SSBS asked for, but this Proton is not an ARM64 one; left off", file=sys.stderr)
|
||||
return env
|
||||
if not os.path.isfile(SSBS_LIB):
|
||||
print("droiddeck-game-env: force SSBS asked for, but %s is missing; left off" % SSBS_LIB, file=sys.stderr)
|
||||
return env
|
||||
parts = [p for p in re.split(r"[:\s]+", env.get("LD_PRELOAD", "")) if p]
|
||||
if SSBS_LIB not in parts:
|
||||
env = dict(env, LD_PRELOAD=":".join(parts + [SSBS_LIB]))
|
||||
print("droiddeck-game-env: force SSBS on (libssbs.so preloaded)", file=sys.stderr)
|
||||
return env
|
||||
|
||||
|
||||
def main():
|
||||
command = sys.argv[1:]
|
||||
if not command:
|
||||
@@ -223,6 +247,7 @@ def main():
|
||||
env = apply_config(env, {"version": 1}, app_id, fixes)
|
||||
except (OSError, ValueError, TypeError, AttributeError):
|
||||
print("droiddeck-game-env: invalid configuration; using inherited environment", file=sys.stderr)
|
||||
env = force_ssbs(command, env)
|
||||
sync = load_sync()
|
||||
launch, launch_env = select_sync(command, env, sync)
|
||||
if launch[0] != command[0]:
|
||||
|
||||
Reference in new issue
Block a user