feat: optional x86-64 Steam client (Valve's Linux client under FEX) beside the arm64 one (#152)

An opt-in second Steam client (Steam settings, Steam client: x86-64): Valve's
x86-64 Linux client, unchanged, runs under FEX in its own home with its own
game library and the same sign-in. Linux builds run directly, so titles such
as Team Fortress 2 and Half-Life use their Linux versions; Windows games use
DroidDeck-Proton as on arm64. The arm64 client stays the default.

- droiddeck-steam-x64: FEX and the x86-64 rootfs from DroidDeck-Components
  (sha256-pinned), client install and sync from Valve's CDN, sign-in shared
  with the arm64 client, its web helper on the GPU (ANGLE GL over FEX's GL
  thunk, zink, Turnip), Proton wrappers for the arm64 client's tools,
  DroidDeck direct for Linux builds, SD-card library (x86-64/ beside the
  arm64 one), repair.
- FEX 2610 built by build-fex.yml with thunks and three patches: an openat2
  fallback without openat2 (proot), newer-clang thunkgen, MAP_32BIT
  exhaustion returning ENOMEM. libblsession resolves RESOLVE_IN_ROOT paths
  inside the root.
- Session: x86-64 gating, shortcuts and compatibility tools per client,
  logs from the client that ran.
- App: client setting with the FEX version, an x86-64 chip on the Games
  header, the active client's library, art, storage, downloads, repair,
  Offline Mode, Decky, desktop mode, optional VAC diagnostics; per-client
  state for art, the content log, repair and leftovers.
- Strings in every locale.
- Review fixes: the library cache is saved only by the newest scan; an
  abandoned session's Steam logs come from the client it recorded; distinct
  VAC console names; FEXInterpreter in CPU pinning; clearer VAC hint in
  pl, ru, uk, cs and bg.
This commit is contained in:
The412Banner authored and GitHub committed 2026-10-17 23:57:52 -04:00
1 parent ab799e6938
commit db8d1c9910
125 files changed
+4953 -263

No files matched your search

+70
View File
@@ -0,0 +1,70 @@
#!/usr/bin/bash
# Runs inside an Arch Linux ARM container (menci/archlinuxarm:base-devel) on an arm64 runner. Arch Linux ARM ships
# no FEX package and FEX publishes no Linux binaries.
set -euxo pipefail
VERSION=${FEX_VERSION:-FEX-2610}
WORK=/work
cd "$WORK"
grep -q '^DisableSandbox' /etc/pacman.conf || sed -i 's/^\[options\]/[options]\nDisableSandbox/' /etc/pacman.conf
{ for m in https://ca.us.mirror.archlinuxarm.org https://fl.us.mirror.archlinuxarm.org https://de3.mirror.archlinuxarm.org https://nl.mirror.archlinuxarm.org; do echo "Server = $m/\$arch/\$repo"; done; cat /etc/pacman.d/mirrorlist; } > /etc/pacman.d/mirrorlist.new
mv /etc/pacman.d/mirrorlist.new /etc/pacman.d/mirrorlist
pacman -Syu --noconfirm --needed git zstd binutils cmake ninja clang lld llvm python squashfs-tools file
# The x86 sysroot is Arch x86_64 and multilib i686 packages unpacked by pacman, never run: no scriptlets or signature checks.
THUNKS=${FEX_THUNKS:-0}
X86ROOT=$WORK/x86root
if [ "$THUNKS" = 1 ]; then
pacman -S --noconfirm --needed pkgconf libx11 libxcb libxrandr libxrender libxext xorgproto \
libglvnd mesa wayland libdrm alsa-lib libxshmfence vulkan-headers vulkan-icd-loader
rm -rf "$X86ROOT" && mkdir -p "$X86ROOT/var/lib/pacman" "$WORK/x86-cache"
cat > "$WORK/x86-pacman.conf" <<'CONF'
[options]
Architecture = x86_64
SigLevel = Never
DisableSandbox
[core]
Server = https://geo.mirror.pkgbuild.com/$repo/os/$arch
[extra]
Server = https://geo.mirror.pkgbuild.com/$repo/os/$arch
[multilib]
Server = https://geo.mirror.pkgbuild.com/$repo/os/$arch
CONF
pacman --config "$WORK/x86-pacman.conf" --root "$X86ROOT" --dbpath "$X86ROOT/var/lib/pacman" \
--cachedir "$WORK/x86-cache" --noscriptlet --noconfirm --overwrite '*' -Sy \
glibc linux-api-headers gcc gcc-libs libx11 libxcb xorgproto libxrandr libxrender libxext libxau \
libxdmcp libglvnd mesa wayland libdrm alsa-lib libxshmfence \
lib32-glibc lib32-gcc-libs lib32-libx11 lib32-libxcb lib32-libxrandr lib32-libxrender \
lib32-libxext lib32-libglvnd lib32-mesa lib32-wayland lib32-libdrm lib32-alsa-lib lib32-libxshmfence
ls "$X86ROOT/usr/include" | head -5
fi
rm -rf fex-src out && git clone -q --depth 1 --branch "$VERSION" --recurse-submodules --shallow-submodules https://github.com/FEX-Emu/FEX.git fex-src
for p in tools/fex/patches/*.patch; do patch -d fex-src -p1 --no-backup-if-mismatch < "$p"; done
# FEX's x86 toolchain files assume an x86 build machine; here the guest thunks need the x86 sysroot too.
# Arch's clang adds stack protection; its canary load in a guest thunk's prologue clobbered r11 (the host function).
if [ "$THUNKS" = 1 ]; then
for t in fex-src/Data/CMake/toolchain_x86_64.cmake fex-src/Data/CMake/toolchain_x86_32.cmake; do
printf '\nif (X86_DEV_ROOTFS AND NOT X86_DEV_ROOTFS STREQUAL "/")\n set(CMAKE_SYSROOT "${X86_DEV_ROOTFS}")\nendif()\n' >> "$t"
printf '\nset(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-stack-protector")\nset(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-stack-protector")\n' >> "$t"
done
fi
# TUNE_CPU none: the default (native) would tune for the runner's Neoverse cores, not the device.
cmake -S fex-src -B fex-build -G Ninja \
-DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local \
-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DUSE_LINKER=lld \
-DTUNE_CPU=none -DTUNE_ARCH=armv8-a \
-DBUILD_TESTING=OFF -DBUILD_FEXCONFIG=OFF -DENABLE_ASSERTIONS=OFF \
$( [ "$THUNKS" = 1 ] && echo "-DBUILD_THUNKS=ON -DX86_DEV_ROOTFS=$X86ROOT" || echo "-DBUILD_THUNKS=OFF" ) \
-DENABLE_CCACHE=OFF -DENABLE_OFFLINE_TELEMETRY=OFF \
${FEX_EXTRA_CXXFLAGS:+-DCMAKE_CXX_FLAGS="$FEX_EXTRA_CXXFLAGS"}
ninja -C fex-build
DESTDIR="$WORK/out" ninja -C fex-build install
install -Dm755 /usr/bin/unsquashfs out/usr/local/bin/unsquashfs
# Every NEEDED soname must resolve in a stock guest.
for f in out/usr/local/bin/*; do
file "$f" | grep -q ELF || continue
readelf -d "$f" | awk '/NEEDED/ { gsub(/[\[\]]/, "", $5); print $5 }'
done | sort -u | tee fex-needed.txt
(cd out && find . -type f -o -type l | sort) | tee fex-files.txt
tar -C out -c . | zstd -19 -T0 -o fex.tzst
sha256sum fex.tzst | tee fex.tzst.sha256
@@ -0,0 +1,203 @@
diff --git a/Source/Tools/LinuxEmulation/LinuxSyscalls/FileManagement.cpp b/Source/Tools/LinuxEmulation/LinuxSyscalls/FileManagement.cpp
index 7172460..2c80dca 100644
--- a/Source/Tools/LinuxEmulation/LinuxSyscalls/FileManagement.cpp
+++ b/Source/Tools/LinuxEmulation/LinuxSyscalls/FileManagement.cpp
@@ -29,6 +29,7 @@ $end_info$
#include <algorithm>
#include <errno.h>
#include <cstring>
+#include <linux/magic.h>
#include <linux/openat2.h>
#include <fcntl.h>
#include <filesystem>
@@ -632,6 +633,163 @@ static bool ShouldSkipOpenInEmu(int flags) {
return false;
}
+static bool IsOnProcFS(int DirFD, const char* Pathname) {
+ int FD = ::openat(DirFD, Pathname, O_PATH | O_NOFOLLOW | O_CLOEXEC);
+ if (FD == -1) {
+ return false;
+ }
+
+ struct statfs Buffer {};
+ const bool Result = fstatfs(FD, &Buffer) == 0 && Buffer.f_type == PROC_SUPER_MAGIC;
+ close(FD);
+ return Result;
+}
+
+// openat2() with RESOLVE_IN_ROOT, walked one component at a time: PRoot has no openat2 and fails it with ENOSYS.
+// DirFD is AT_FDCWD only for thunk overlays, which never resolve in the root.
+static int OpenatWithoutOpenat2(int DirFD, const char* Pathname, int Flags, uint32_t Mode) {
+ if (DirFD == AT_FDCWD) {
+ return ::syscall(SYSCALL_DEF(openat), DirFD, Pathname, Flags, Mode);
+ }
+
+ // The kernel's MAXSYMLINKS.
+ constexpr uint32_t MaxSymlinks = 40;
+ uint32_t Symlinks {};
+ std::optional<dev_t> RootDev {};
+
+ // O_NOFOLLOW and O_CREAT | O_EXCL leave a final symlink alone, unless a trailing slash follows it.
+ const bool NoFollow = (Flags & O_NOFOLLOW) || (Flags & (O_CREAT | O_EXCL)) == (O_CREAT | O_EXCL);
+
+ char Resolved[PATH_MAX];
+ size_t ResolvedLen {};
+
+ std::array<char[PATH_MAX], 2> Pending;
+ uint32_t PendingIndex {};
+ const char* Remaining = Pathname;
+
+ for (;;) {
+ while (*Remaining == '/') {
+ ++Remaining;
+ }
+
+ if (*Remaining == 0) {
+ break;
+ }
+
+ const char* Component = Remaining;
+ const char* ComponentEnd = Component;
+ while (*ComponentEnd != 0 && *ComponentEnd != '/') {
+ ++ComponentEnd;
+ }
+ const size_t ComponentLen = ComponentEnd - Component;
+
+ Remaining = ComponentEnd;
+ while (*Remaining == '/') {
+ ++Remaining;
+ }
+ const bool Last = *Remaining == 0;
+ const bool TrailingSlash = Last && Remaining != ComponentEnd;
+
+ if (ComponentLen == 1 && Component[0] == '.') {
+ continue;
+ }
+
+ if (ComponentLen == 2 && Component[0] == '.' && Component[1] == '.') {
+ while (ResolvedLen > 0 && Resolved[ResolvedLen - 1] != '/') {
+ --ResolvedLen;
+ }
+ if (ResolvedLen > 0) {
+ --ResolvedLen;
+ }
+ continue;
+ }
+
+ const size_t Separator = ResolvedLen > 0 ? 1 : 0;
+ const size_t CandidateLen = ResolvedLen + Separator + ComponentLen;
+ if (CandidateLen + 1 >= PATH_MAX) {
+ errno = ENAMETOOLONG;
+ return -1;
+ }
+ if (Separator) {
+ Resolved[ResolvedLen] = '/';
+ }
+ memcpy(&Resolved[ResolvedLen + Separator], Component, ComponentLen);
+ Resolved[CandidateLen] = 0;
+
+ struct stat Buffer {};
+ const bool Follow = !Last || TrailingSlash || !NoFollow;
+ const int StatResult = Follow ? fstatat(DirFD, Resolved, &Buffer, AT_SYMLINK_NOFOLLOW) : -1;
+
+ if (StatResult == 0 && S_ISLNK(Buffer.st_mode)) {
+ if (++Symlinks > MaxSymlinks) {
+ errno = ELOOP;
+ return -1;
+ }
+
+ if (!RootDev) {
+ struct stat Root {};
+ if (fstat(DirFD, &Root) != 0) {
+ return -1;
+ }
+ RootDev = Root.st_dev;
+ }
+
+ if (Buffer.st_dev != *RootDev && IsOnProcFS(DirFD, Resolved)) {
+ // Only procfs has magic links. RESOLVE_IN_ROOT fails them with EXDEV and the callers then open without it.
+ return ::syscall(SYSCALL_DEF(openat), DirFD, Pathname, Flags, Mode);
+ }
+
+ char* Target = Pending[PendingIndex];
+ const ssize_t TargetLen = readlinkat(DirFD, Resolved, Target, PATH_MAX);
+ if (TargetLen <= 0) {
+ if (TargetLen == 0) {
+ errno = ENOENT;
+ }
+ return -1;
+ }
+
+ const size_t RestLen = strlen(ComponentEnd);
+ if (static_cast<size_t>(TargetLen) + RestLen >= PATH_MAX) {
+ errno = ENAMETOOLONG;
+ return -1;
+ }
+ memcpy(&Target[TargetLen], ComponentEnd, RestLen + 1);
+
+ if (Target[0] == '/') {
+ ResolvedLen = 0;
+ }
+ Remaining = Target;
+ PendingIndex ^= 1;
+ continue;
+ }
+
+ if (Last) {
+ // openat reports on the final component, which O_CREAT may create.
+ ResolvedLen = CandidateLen;
+ if (TrailingSlash) {
+ Resolved[ResolvedLen++] = '/';
+ }
+ break;
+ }
+
+ if (StatResult != 0) {
+ return -1;
+ }
+
+ if (!S_ISDIR(Buffer.st_mode)) {
+ errno = ENOTDIR;
+ return -1;
+ }
+ ResolvedLen = CandidateLen;
+ }
+
+ if (ResolvedLen == 0) {
+ Resolved[ResolvedLen++] = '.';
+ }
+ Resolved[ResolvedLen] = 0;
+ return ::syscall(SYSCALL_DEF(openat), DirFD, Resolved, Flags, Mode);
+}
+
bool FileManager::ReplaceEmuFd(int fd, int flags, uint32_t mode) {
char Tmp[PATH_MAX + 1];
@@ -678,6 +836,8 @@ uint64_t FileManager::Open(const char* pathname, int flags, uint32_t mode) {
// This means a magic symlink (/proc/foo) was involved. In this case we
// just punt and do the access without RESOLVE_IN_ROOT.
fd = ::syscall(SYSCALL_DEF(openat), Path.FD, Path.Path, flags, mode);
+ } else if (fd == -1 && errno == ENOSYS) {
+ fd = OpenatWithoutOpenat2(Path.FD, Path.Path, flags, mode);
}
}
@@ -931,6 +1091,8 @@ uint64_t FileManager::Openat([[maybe_unused]] int dirfs, const char* pathname, i
// This means a magic symlink (/proc/foo) was involved. In this case we
// just punt and do the access without RESOLVE_IN_ROOT.
fd = ::syscall(SYSCALL_DEF(openat), Path.FD, Path.Path, flags, mode);
+ } else if (fd == -1 && errno == ENOSYS) {
+ fd = OpenatWithoutOpenat2(Path.FD, Path.Path, flags, mode);
}
}
@@ -967,6 +1129,8 @@ uint64_t FileManager::Openat2(int dirfs, const char* pathname, FEX::HLE::open_ho
// This means a magic symlink (/proc/foo) was involved. In this case we
// just punt and do the access without RESOLVE_IN_ROOT.
fd = ::syscall(SYSCALL_DEF(openat2), Path.FD, Path.Path, how, usize);
+ } else if (fd == -1 && errno == ENOSYS && how->resolve == 0) {
+ fd = OpenatWithoutOpenat2(Path.FD, Path.Path, how->flags, how->mode);
}
}
@@ -0,0 +1,9 @@
--- a/ThunkLibs/Generator/gen.cpp
+++ b/ThunkLibs/Generator/gen.cpp
@@ -840,6 +840,5 @@
const bool Success = Compiler.ExecuteAction(Action);
- Files->clearStatCache();
return Success;
}
@@ -0,0 +1,103 @@
diff --git a/Source/Tools/LinuxEmulation/LinuxSyscalls/LinuxAllocator.cpp b/Source/Tools/LinuxEmulation/LinuxSyscalls/LinuxAllocator.cpp
index 60b0ef1..4a94009 100644
--- a/Source/Tools/LinuxEmulation/LinuxSyscalls/LinuxAllocator.cpp
+++ b/Source/Tools/LinuxEmulation/LinuxSyscalls/LinuxAllocator.cpp
@@ -2,6 +2,7 @@
#include "LinuxSyscalls/LinuxAllocator.h"
#include "LinuxSyscalls/Syscalls.h"
+#include <FEXCore/Utils/Allocator.h>
#include <FEXCore/Utils/MathUtils.h>
#include <FEXCore/Utils/TypeDefines.h>
#include <FEXHeaderUtils/Syscalls.h>
@@ -9,6 +10,7 @@
#include <FEXCore/fextl/memory.h>
#include <bitset>
+#include <fcntl.h>
#include <linux/mman.h>
#include <unistd.h>
#include <sys/user.h>
@@ -82,6 +84,7 @@ private:
std::mutex AllocMutex {};
uint64_t FindPageRange(uint64_t Start, size_t Pages) const;
uint64_t FindPageRange_TopDown(uint64_t Start, size_t Pages) const;
+ bool SetHostMappedPages(uint64_t PageAddr, size_t PagesLength);
using FindHandler = uint64_t (MemAllocator32Bit::*)(uint64_t Start, size_t Pages) const;
FindHandler FindPageRangePtr {};
};
@@ -132,6 +135,37 @@ uint64_t MemAllocator32Bit::FindPageRange_TopDown(uint64_t Start, size_t Pages)
return 0;
}
+// Marks each run of host mappings that overlaps the range as used, in full. Returns false if none overlaps.
+bool MemAllocator32Bit::SetHostMappedPages(uint64_t PageAddr, size_t PagesLength) {
+ const int MapsFD = ::open("/proc/self/maps", O_RDONLY | O_CLOEXEC);
+ if (MapsFD == -1) {
+ return false;
+ }
+
+ const auto Gaps =
+ FEXCore::Allocator::CollectMemoryGaps(BASE_KEY << FEXCore::Utils::FEX_PAGE_SHIFT, TOP_KEY << FEXCore::Utils::FEX_PAGE_SHIFT, MapsFD);
+ close(MapsFD);
+
+ const uint64_t EndPage = PageAddr + PagesLength;
+ uint64_t MappedBegin = BASE_KEY;
+ bool Marked = false;
+ auto MarkIfOverlapping = [&](uint64_t MappedEnd) {
+ if (MappedBegin < MappedEnd && MappedBegin < EndPage && PageAddr < MappedEnd) {
+ SetUsedPages(MappedBegin, MappedEnd - MappedBegin);
+ Marked = true;
+ }
+ };
+
+ for (const auto& Gap : Gaps) {
+ const uintptr_t GapBegin = reinterpret_cast<uintptr_t>(Gap.Ptr);
+ MarkIfOverlapping(GapBegin >> FEXCore::Utils::FEX_PAGE_SHIFT);
+ MappedBegin = (GapBegin + Gap.Size) >> FEXCore::Utils::FEX_PAGE_SHIFT;
+ }
+ MarkIfOverlapping(TOP_KEY);
+
+ return Marked;
+}
+
void* MemAllocator32Bit::Mmap(void* addr, size_t length, int prot, int flags, int fd, off_t offset) {
std::scoped_lock<std::mutex> lk {AllocMutex};
size_t PagesLength = FEXCore::AlignUp(length, FEXCore::Utils::FEX_PAGE_SIZE) >> FEXCore::Utils::FEX_PAGE_SHIFT;
@@ -175,11 +209,17 @@ void* MemAllocator32Bit::Mmap(void* addr, size_t length, int prot, int flags, in
auto AllocateNoHint = [&]() -> void* {
bool Wrapped = false;
+ bool Restarted = false;
uint64_t BottomPage = Map32Bit && (LastScanLocation >= LastKeyLocation32Bit) ? LastKeyLocation32Bit : LastScanLocation;
restart: {
// Linear range scan
uint64_t LowerPage = (this->*FindPageRangePtr)(BottomPage, PagesLength);
if (LowerPage == 0) {
+ // A second scan from the start found nothing either: the range is full, as the kernel would say.
+ if (Restarted) {
+ return reinterpret_cast<void*>(-ENOMEM);
+ }
+ Restarted = true;
// Try again but this time from the start
BottomPage = Map32Bit ? LastKeyLocation32Bit : LastKeyLocation;
LowerPage = (this->*FindPageRangePtr)(BottomPage, PagesLength);
@@ -206,7 +246,17 @@ restart: {
return (void*)(uintptr_t)-errno;
} else {
// Try again
- if (SearchDown) {
+ if (Map32Bit) {
+ // MAP_32BIT from a 64-bit guest, whose other mappings bypass this allocator: once Counter-Strike 2 had reserved the
+ // low 2GB, stepping one page at a time scanned for ever. Record what the host holds there and rescan the range, or
+ // move past it if that mapping is gone.
+ const bool Marked = SetHostMappedPages(LowerPage, PagesLength);
+ if (SearchDown) {
+ BottomPage = Marked ? UpperPage - 1 : LowerPage - 1;
+ } else {
+ BottomPage = Marked ? LowerPage : UpperPage;
+ }
+ } else if (SearchDown) {
--BottomPage;
} else {
++BottomPage;