fix(libkernel): report Linux file birth times accurately #2115

Closed
STUPIDCONTEM wants to merge 1 commit from upstream-pr/2115 into main
STUPIDCONTEM commented 2026-10-09 09:03:38 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by STUPIDCONTEM on 2026-10-09T09:03:38Z.


Evidence review (2026-10-09)

Closed by maintainer; not ready to reopen. Required evidence: Title ID and a log showing a title reads and requires st_birthtim; justify the extra stat syscall cost.

Game/title ID: none verified. No PS5 title execution is claimed.

What

Report Linux file creation time from statx(STATX_BTIME) instead of copying inode status-change time into guest st_birthtim. The previous value changed when file metadata changed, even though the file had not been recreated.

Path and descriptor probes require birthtime plus matching inode/device identity, so a path replacement cannot attach another inode's timestamp to an earlier stat result. The optional probe preserves errno. A guarded SYS_statx syscall avoids a new glibc statx-symbol dependency; unsupported headers/kernels/filesystems return the unavailable marker {-1, 0}. Other stat fields and non-Linux behavior remain unchanged.

FreeBSD stat(2) distinguishes creation time from status-change time. FreeBSD D31468 documents {VNOVAL, 0} as the unavailable-birthtime convention; VNOVAL is -1. The Linux timestamp comes from the documented statx ABI.

Tested

  • Linux Release / GCC on Ubuntu GitHub Actions: baseline-versus-fixed run 37907712018, exact head d8de5926c522bb9d8aa569b4f14daa4788bdeae7. With unchanged upstream NativeStat.cpp, the new regression fails specifically because path stat birthtime does not match native STATX_BTIME. Restoring the candidate passes all three focused runs (9.07 seconds total). It compares both stat/fstat against the native creation timestamp before and after utimes, checks ctime differs, and checks successful calls preserve errno. This runner exposed birthtime; unsupported-host fallback branches were reviewed but not forced in that run.
  • The first proof attempt failed compiling the test due to a missing utimes declaration; the linked rerun includes that correction. Production and test files in this PR are byte-identical to the successful Linux proof.
  • Windows 10 Pro 19045 / WinLibs GCC 15.2 UCRT, Release: with the separate build repair #2093, default/libs builds and full CTest passed 494/494 in 34.84 seconds, no skips (stack cd54416c). The new syscall and regression are Linux-only; this validates Windows compatibility.
  • Open #1624 adds lstat in the same file but does not implement birthtime. Parent combined exact head 1f5935a40b96b2562ac2faed0008b22ab89040cc with this candidate and retained its author. Its new FillLinkStat call needs an explicit no-follow birthtime probe. A separate local bridge was verified in Linux run 37908275134, head 93643c6deeb2157f1a17e0b086a373dbb431325a: the symlink regression fails before the bridge and passes three times afterward. That dependent lstat adaptation is kept separate from this PR.

No PS5 title or hardware run was performed. Conventions, whitespace and registration checks passed.

Checklist

  • Based on current main 6cc0503d; no other open PR implements Linux birthtime (historical base; current readiness not asserted)
  • One topic per PR
  • No code comments added
  • No silent stubs added
  • No notes, reports or images added to the repository
  • No third-party code added
  • Generic behavior, not title-specific
  • Build dependency: the equivalent repair merged as #2099; #2093 is closed as superseded.
  • AI-assisted: yes; independently reviewed and tested
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4798341499 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2115). Originally posted by [STUPIDCONTEM](https://github.com/STUPIDCONTEM) on 2026-10-09T09:03:38Z. --- ### Evidence review (2026-10-09) Closed by maintainer; not ready to reopen. Required evidence: Title ID and a log showing a title reads and requires st_birthtim; justify the extra stat syscall cost. Game/title ID: **none verified**. No PS5 title execution is claimed. ### What Report Linux file creation time from `statx(STATX_BTIME)` instead of copying inode status-change time into guest `st_birthtim`. The previous value changed when file metadata changed, even though the file had not been recreated. Path and descriptor probes require birthtime plus matching inode/device identity, so a path replacement cannot attach another inode's timestamp to an earlier stat result. The optional probe preserves errno. A guarded `SYS_statx` syscall avoids a new glibc statx-symbol dependency; unsupported headers/kernels/filesystems return the unavailable marker {-1, 0}. Other stat fields and non-Linux behavior remain unchanged. [FreeBSD stat(2)](https://man.freebsd.org/cgi/man.cgi?manpath=FreeBSD+11.1-RELEASE&query=stat&sektion=2) distinguishes creation time from status-change time. [FreeBSD D31468](https://reviews.freebsd.org/D31468) documents {VNOVAL, 0} as the unavailable-birthtime convention; VNOVAL is -1. The Linux timestamp comes from the documented [statx ABI](https://man7.org/linux/man-pages/man2/statx.2.html). ### Tested - Linux Release / GCC on Ubuntu GitHub Actions: [baseline-versus-fixed run 37907712018](https://github.com/STUPIDCONTEM/AnyPS5/actions/runs/37907712018), exact head d8de5926c522bb9d8aa569b4f14daa4788bdeae7. With unchanged upstream NativeStat.cpp, the new regression fails specifically because path stat birthtime does not match native STATX_BTIME. Restoring the candidate passes all three focused runs (9.07 seconds total). It compares both stat/fstat against the native creation timestamp before and after utimes, checks ctime differs, and checks successful calls preserve errno. This runner exposed birthtime; unsupported-host fallback branches were reviewed but not forced in that run. - The first proof attempt failed compiling the test due to a missing utimes declaration; the linked rerun includes that correction. Production and test files in this PR are byte-identical to the successful Linux proof. - Windows 10 Pro 19045 / WinLibs GCC 15.2 UCRT, Release: with the separate build repair #2093, default/libs builds and full CTest passed 494/494 in 34.84 seconds, no skips (stack cd54416c). The new syscall and regression are Linux-only; this validates Windows compatibility. - Open #1624 adds lstat in the same file but does not implement birthtime. Parent combined exact head 1f5935a40b96b2562ac2faed0008b22ab89040cc with this candidate and retained its author. Its new FillLinkStat call needs an explicit no-follow birthtime probe. A separate local bridge was verified in [Linux run 37908275134](https://github.com/STUPIDCONTEM/AnyPS5/actions/runs/37908275134), head 93643c6deeb2157f1a17e0b086a373dbb431325a: the symlink regression fails before the bridge and passes three times afterward. That dependent lstat adaptation is kept separate from this PR. No PS5 title or hardware run was performed. Conventions, whitespace and registration checks passed. ### Checklist - [ ] Based on current main 6cc0503d; no other open PR implements Linux birthtime (historical base; current readiness not asserted) - [x] One topic per PR - [x] No code comments added - [x] No silent stubs added - [x] No notes, reports or images added to the repository - [x] No third-party code added - [x] Generic behavior, not title-specific - [x] Build dependency: the equivalent repair merged as #2099; #2093 is closed as superseded. - [x] AI-assisted: yes; independently reviewed and tested
A-Akhil commented 2026-10-09 17:05:27 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by A-Akhil on 2026-10-09T17:05:27Z.


agc_driver_dcc_keys_first_write (which ctest runs) fails the same way on Linux with NVIDIA's driver, and passes on an Intel GPU in the same machine. It traces to 0e1d25a8.

Arch Linux (kernel 6.18.54-lts), GCC 16.2.1, Release, main 0fdda7be. GTX 1650 Ti (driver 615.71.09) and Intel UHD (CML GT2, Mesa 26.2.3); the GPU picked with ANYPS5_GPU.

GPU write-watch probe at startup result
Intel UHD host imports resolve write protection: yes ... imported ranges are compared pass
GTX 1650 Ti host imports resolve write protection: no ... imported ranges stay watched fails 3/3: an unchanged pending image was uploaded again (DccKeysFirstWrite.cpp:214)

With APS5_NO_HOST_IMPORT=1 the NVIDIA run fails the same way.

  • Bisect: passes at a8b032b2 (0e1d25a8's parent), fails at 0e1d25a8 alone. That check was added in 0e1d25a8, so it's a new expectation that the watched path doesn't meet, not an old test that broke.
  • Experiment, not a proposed fix: moving ++tracker.generation in GuestMemory::MarkWritten back after the watched/covers check gets the NVIDIA run past line 214, but then both GPUs fail a pending GPU store within the comparison epoch was missed. The compare path needs the unconditional bump, and on the watched path the same bump appears to make StorageTexture::Refresh treat an unchanged pending image as changed.

CI probably doesn't see this because its device takes the compared path.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6085553102 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2115#issuecomment-6085553102). Originally posted by [A-Akhil](https://github.com/A-Akhil) on 2026-10-09T17:05:27Z. --- `agc_driver_dcc_keys_first_write` (which ctest runs) fails the same way on Linux with NVIDIA's driver, and passes on an Intel GPU in the same machine. It traces to 0e1d25a8. Arch Linux (kernel 6.18.54-lts), GCC 16.2.1, Release, `main` 0fdda7be. GTX 1650 Ti (driver 615.71.09) and Intel UHD (CML GT2, Mesa 26.2.3); the GPU picked with `ANYPS5_GPU`. | GPU | write-watch probe at startup | result | |---|---|---| | Intel UHD | `host imports resolve write protection: yes ... imported ranges are compared` | pass | | GTX 1650 Ti | `host imports resolve write protection: no ... imported ranges stay watched` | fails 3/3: `an unchanged pending image was uploaded again` (DccKeysFirstWrite.cpp:214) | With `APS5_NO_HOST_IMPORT=1` the NVIDIA run fails the same way. - Bisect: passes at `a8b032b2` (0e1d25a8's parent), fails at 0e1d25a8 alone. That check was added in 0e1d25a8, so it's a new expectation that the watched path doesn't meet, not an old test that broke. - Experiment, not a proposed fix: moving `++tracker.generation` in `GuestMemory::MarkWritten` back after the `watched`/`covers` check gets the NVIDIA run past line 214, but then both GPUs fail `a pending GPU store within the comparison epoch was missed`. The compare path needs the unconditional bump, and on the watched path the same bump appears to make `StorageTexture::Refresh` treat an unchanged pending image as changed. CI probably doesn't see this because its device takes the compared path.
oneandonlydean commented 2026-10-09 20:08:57 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-09T20:08:57Z.


Closing: no title is shown reading st_birthtim, and this adds a second syscall to every stat on Linux to fill it. Please reopen with the title ID and the log line if one depends on it.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6088426460 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2115#issuecomment-6088426460). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-09T20:08:57Z. --- Closing: no title is shown reading `st_birthtim`, and this adds a second syscall to every stat on Linux to fill it. Please reopen with the title ID and the log line if one depends on it.
STUPIDCONTEM commented 2026-10-10 00:40:47 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by STUPIDCONTEM on 2026-10-10T00:40:47Z.


@A-Akhil Thanks for the detailed before/after and NVIDIA-versus-Intel reproduction. This PR changes Linux file timestamps in NativeStat.cpp and does not modify the AGC image/write-tracking paths in your report. Its host tests do not validate that NVIDIA path, and I am not treating the Intel/software-driver passes as evidence against your failure. The report belongs with the DCC/write-tracking changes identified by your bisect; moving the generation increment is not a verified fix given the second failure you observed. This birthtime PR will remain closed pending the maintainer's separate title-evidence request.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6091735796 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2115#issuecomment-6091735796). Originally posted by [STUPIDCONTEM](https://github.com/STUPIDCONTEM) on 2026-10-10T00:40:47Z. --- @A-Akhil Thanks for the detailed before/after and NVIDIA-versus-Intel reproduction. This PR changes Linux file timestamps in NativeStat.cpp and does not modify the AGC image/write-tracking paths in your report. Its host tests do not validate that NVIDIA path, and I am not treating the Intel/software-driver passes as evidence against your failure. The report belongs with the DCC/write-tracking changes identified by your bisect; moving the generation increment is not a verified fix given the second failure you observed. This birthtime PR will remain closed pending the maintainer's separate title-evidence request.

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!2115
No description provided.