Skip to content

LATX, feat: add steam support - #361

Draft
baibaidashixiong wants to merge 13 commits into
lat-opensource:masterfrom
baibaidashixiong:dev_steam
Draft

LATX, feat: add steam support#361
baibaidashixiong wants to merge 13 commits into
lat-opensource:masterfrom
baibaidashixiong:dev_steam

Conversation

@baibaidashixiong

Copy link
Copy Markdown
Contributor

Summary / 变更说明

添加latx对steam的支持

LoongArch AMCAS overwrites its result register with the observed memory value. Reusing the guest accumulator as that register loses the distinction between the expected value, the loaded value, and the address operand.

Use a dedicated temporary for the AMCAS result, derive EFLAGS from that observed value, and write it back to the guest accumulator. This preserves x86 CMPXCHG register and condition-code semantics for the fast atomic path.

Signed-off-by: zqz <OrzZzznn@gmail.com>
A cache-exit path replaces the temporary destination with the architectural zero register. When the instruction also has an explicit destination adjustment, returning immediately drops that adjustment.

Apply adjust_dest() before returning from the non-segment cache-exit path so address-size handling and destination semantics remain consistent with the normal path.

Signed-off-by: zqz <OrzZzznn@gmail.com>
Older libdrm builds use the pre-timeline GEM_VA request layout for ioctl number 0x48, while current host DRM headers describe the newer layout. Passing the guest buffer through as the current structure corrupts the host request.

Define the legacy target ABI, register it as a special ioctl, and marshal its common GEM_VA fields into the host structure before issuing the host ioctl. Current ABI requests continue to use the existing path.

Signed-off-by: zqz <OrzZzznn@gmail.com>
Some 32-bit launchers invoke their dynamic linker with absolute library names that are absent from the configured runtime prefix, even though matching libraries are located beside the selected PT_INTERP loader.

Record the interpreter code range during ELF loading and only apply a read-only fallback while execution is inside that i386 dynamic linker. The fallback accepts conventional lib*.so names, probes the interpreter directory, and preserves the original error for all other opens.

Signed-off-by: zqz <OrzZzznn@gmail.com>
Several metadata operations bypassed path(), unlike open and related filesystem syscalls. This let a guest inspect or modify host paths instead of the configured x86 runtime tree.

Route faccessat, statx, and extended-attribute path arguments through the existing prefix resolver while preserving the existing guest-buffer lifetime and procfs handling.

Signed-off-by: zqz <OrzZzznn@gmail.com>
Steam-era 32-bit launchers select helper binaries based on uname.machine. Reporting the host architecture prevents them from choosing their x86_64 helper even though LATX can execute it.

For the LATX i386 target, report x86_64 by default and retain LATX_UNAME_MACHINE as an explicit override for callers that need a different compatibility identity.

Signed-off-by: zqz <OrzZzznn@gmail.com>
Steam launches x86 payloads through its native pressure-vessel wrapper. That container does not inherit the host binfmt registration, so attempting to execute the wrapper path directly leaves the payload outside LATX.

Move pressure-vessel handling out of main.c into a dedicated linux-user module. For recognized non-launcher wrap invocations, parse the supported environment and preload options, build runtime library and data paths, and exec the payload through LATX. Keep steamwebhelper_sniper_wrap.sh on its original host environment and fall back to normal wrapper execution when the runtime is incomplete.

Add an integration test through the existing top-level tests/integration/meson.build collection. It uses a temporary runtime and static x86_64 wrapper to cover payload environment propagation, preload precedence, launcher and missing-runtime fallback, WebHelper handling, and both LATX_KZT=0 and LATX_KZT=1.

Signed-off-by: zqz <OrzZzznn@gmail.com>
Guest robust-list registrations cannot be passed to the host kernel because their linked-list pointers live in guest address space. Track the target ABI state per TaskState and answer get_robust_list from the translated task set instead.

Private FUTEX_WAIT and FUTEX_WAIT_BITSET can also return a transient EFAULT on LoongArch despite a valid guest word. Retry only those private wait operations, only while the guest page is valid, and cap retries so all other futex failures remain visible to the guest.

Signed-off-by: zqz <OrzZzznn@gmail.com>
A SIGBUS with SI_KERNEL and a non-null address can already be queued for target handling. Sending it through the host fault interpreter consumes the target signal path and can turn a recoverable guest-visible event into translator failure.

Leave that signal queued by releasing the mmap lock and returning to the normal target signal delivery path. Other SIGBUS faults retain the existing host interpretation flow.

Signed-off-by: zqz <OrzZzznn@gmail.com>
AOT cache validation used substring matching for a fixed footer, allowing unrelated trailing data to be accepted. Cache filenames also did not distinguish target ABI or whether KZT translation was enabled.

Compare the fixed-width version footer exactly and version cache keys with the target name, cache ABI, and KZT mode. Existing incompatible cache files are rejected instead of being reused across translation modes.

Signed-off-by: zqz <OrzZzznn@gmail.com>
KZT ends a translation block at INT3. A raw host BREAK cannot rely on the following host instruction to restore the guest program counter, so an x86 breakpoint can re-enter the same translated BREAK instead of advancing.

Save the required guest state, record the next guest RIP explicitly, and invoke the target interrupt helper for normal KZT INT3 instructions. The existing SC bridge marker continues to take its dedicated bridge path.

Signed-off-by: zqz <OrzZzznn@gmail.com>
The KZT loader observer records pthread_setcanceltype from libc so the callback bridge can dispatch the guest implementation when cancellation state changes.

The original symbol scan compared against malloc, which stored the wrong address and left the cancellation callback unresolved. Match pthread_setcanceltype explicitly while retaining the separate malloc/free/realloc collector.

Signed-off-by: zqz <OrzZzznn@gmail.com>
Guest threads can register, duplicate, close, and query descriptor transforms concurrently. The old resizable global table was accessed without synchronization, so a reader could race a reallocation or observe an entry while it was being replaced.

Move table operations behind a mutex, copy callback pointers while locked before invoking them, and synchronize the lock across fork so both parent and child preserve a valid descriptor-transform state.

Signed-off-by: zqz <OrzZzznn@gmail.com>
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.

1 participant