Commit Graph

2122 Commits

Author SHA1 Message Date
MechaCat02
0aa3eadca7 [Kernel] Add null-safe XThread::TryGetCurrentThread() accessor
The additive event_log extraction tracer needs a current-thread lookup that
returns nullptr instead of asserting when called from boot code before any
XThread exists (GetCurrentThread asserts on non-guest threads). New read-only
static accessor over the thread-local; no behaviour change. Fixes the native
Linux build of the phase-a args/file.read tracer.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-13 20:42:54 +02:00
MechaCat02
a40bc50159 [Phase A] Port args / file.read extraction tracing onto instrument-current
Bring the cvar-gated JSONL extraction tracer (event_log) forward from the
phase-a-tracing line so args/args_resolved + file.read events are
available alongside the GPU draw logging. Purely additive:

- src/xenia/kernel/event_log.{cc,h}: the tracer (auto-globbed into the
  kernel target). Tier 1 fills kernel.call args (raw r3..r10) +
  args_resolved.path under --phase_a_trace_args; Tier 2 resolves
  NtReadFile handle->path via the object table and emits file.read.
- cpu_flags: phase_a_event_log_path / _mem_writes / _trace_args /
  _hash_probe / kernel_emit_contention (all default-off).
- shim_utils.h: phase_a_bridge decl + EmitImportAndCallWithCtx/EmitReturn
  hooks in the active X::Trampoline, skipped when Enabled() is false.

Deliberately EXCLUDES the Tier-3 hash-probe HIR/emitter trap (the IPFB
name-hash was recovered statically, so the probe is moot). The
phase_a_hash_probe cvar is defined but inert.

Default-off => instrument-current behaviour byte-identical when unused.
Not yet compile-verified against instrument-current's toolchain.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-13 19:13:36 +02:00
MechaCat02
f10484834c [APU] Fix mission-audio silence: ALSA underrun keepalive + guest_audio_flags
Two Linux mission-audio fixes for Project Sylpheed (audio played in
intro/menu but died when a mission finished loading, never returning):

- alsa_audio_driver: when the guest stalls (mission "Preparing for Sortie"
  load) and the ring buffer empties, feed silence to keep the PCM alive
  instead of sleeping. Previously the small buffer drained, XRUN'd, and
  playback never recovered (matches the known "audio muted permanently").
- xconfig: make the guest speaker config a cvar (guest_audio_flags,
  default Digital Stereo) instead of hardcoded Dolby Digital surround.

(The practical fix on this box also needed log_mask=13 to stop kernel log
spam starving the audio pipeline during missions — config, not code.)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-12 16:49:25 +02:00
MechaCat02
07f09f8fe0 [Audit] round 24: signal-path probes (XEvent::Set + IO + NtDuplicateObject)
Adds AUDIT-HLC probes for every path that signals an XEvent or duplicates
its handle, so the round-23 puzzle (waits completing without visible
NtSetEvent/KeSetEvent) can be cross-referenced by underlying X_KEVENT VA
and by primary handle.

  * NtCreateEvent_inner: always log kevent_va for handle/VA cross-ref
  * XEvent::Set: universal hook prints primary handle + kevent_va + LR;
    catches all paths into the event regardless of shim used
  * NtSetEvent: extended with PPC back-chain walk for caller's guest_lr
    (same idiom as the wait probe), so the signaler function is
    immediately identifiable
  * NtReadFile / NtReadFileScatter / NtWriteFile: log when signal_event
    path fires ev->Set() inline at IO completion (bypasses both
    NtSetEvent and KeSetEvent shims)
  * CompleteOverlappedEx (kernel_state.cc): log when overlapped event
    is signaled at completion
  * NtDuplicateObject: log src/dst handle pair (round-24 confirmed silph
    event is dup'd before signaling, explaining the handle-mismatch
    puzzle between NtSetEvent's `handle=` argument and XEvent::Set's
    primary handle())

Result: silph wait at sub_821CB030+0x1B0 on handle F80000A0 is signaled
via NtSetEvent on handle F80000A8 (the duplicate created by sub_8245D9D8
at lr=0x82450DF4 inside the worker chain sub_82450A28 ← 0xA68 ← 0xB68).
Verdict A confirmed: signaler exists and is reachable, but round-17.β
missed it because the search keyed on the wrong handle. No bypass path;
the worker chain is identical between canary and ours-impl, but ours
signals different handles (work-item queue divergence at sub_82452DC0).

Audit-only diagnostic. No semantic changes. Net delta +86 LOC across 7
files. All probes gated on the existing audit_handle_lifecycle cvar
(default off). Tested via Sylpheed boot (35 s, 4 MB log). Audit-handle-
lifecycle-probes branch, local-only.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-07-12 15:43:23 +02:00
MechaCat02
87e4a67b61 [Audit] JIT-prolog: optional audit_jit_prolog_mem_dump chain (3 levels)
Round-14 of AUDIT-2BF (singleton-dump). Pairs with xenia-rs'
--audit-mem-read-hex to emit one comparable XELOGKERNEL line resolving
the bctrl target at sub_822F1AA8+0x90 (PC 0x822F1B4C):

  [0x828E1F08]        -> singleton instance ptr
  [singleton+0]       -> vtable
  [vtable+0]          -> vtable[0]  (= first virtual method, bctrl tgt)
  [vtable+24]         -> vtable[24] (= slot 6, silph chain target)

Two complementary hooks:

1. src/xenia/cpu/backend/x64/x64_emitter.cc: extend
   AuditLogJitPrologArgs. New cvar `audit_jit_prolog_mem_dump` (uint32).
   When non-zero and an `audit_jit_prolog_pc` fire happens, the host
   side dereferences the VA 3 levels deep and emits one
   AUDIT-MEM-READ line in the same format ours emits. Defensive
   per-level null + VA-range checks.

2. src/xenia/kernel/kernel_state.cc: one-shot dump in
   EmulateCPInterruptDPC of the same chain (hard-coded to
   0x828E1F08). Useful when audit_jit_prolog_pc isn't set; fires the
   first time the CP interrupt path runs (after the singleton ctor
   has had time to populate).

Read-only. Both gates default-off; no impact when cvars unset.
~65 LOC total across the two files.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-07-12 15:43:23 +02:00
MechaCat02
1517a63974 [Audit] round 12: ExCreateThread + XThread::Execute probes
Two cvar-gated AUDIT-HLC probes for thread-spawn lineage attribution:

1. ExCreateThread_entry shim logs (start_address, start_context, xapi,
   flags, kernel lr, guest_lr). guest_lr is recovered via the same
   one-frame-up PPC back-chain walk used by the NtWaitForSingleObjectEx
   probe (lr saved at [back2 - 8]).

2. XThread::Execute emits (tid, start_address, start_context, xapi) at
   the very top so each running thread can be matched back to its
   creating ExCreateThread entry by (start_address, start_context).

Gated on the existing cvars::audit_handle_lifecycle; no new cvar.
Pulled in xenia/kernel/kernel_flags.h from xthread.cc to expose the
cvar declaration there.

Used by audit-059 round 12 to enumerate the 23 thread spawns in
canary's 35 s boot, attribute each to its guest_lr caller, and cross-
reference against ours' 10 spawns to identify the 7 missing
spawner functions (including sub_824F7800 which spawns the 4 silph
PKEVENT workers at entry=0x82506528/58/88/B8 via guest_lr=0x824F7B24).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-07-12 15:43:23 +02:00
MechaCat02
35f58b147f [Audit] handle-lifecycle: one-shot silph::WorkerCtx hexdump on first KeSetEvent
Adds a 41-LOC cvar-gated probe (audit_handle_lifecycle) that emits a one-shot
0x300-byte hexdump of the silph::WorkerCtx context the first time KeSetEvent
fires into the silph UI PKEVENT cluster (0xBCE25200..0xBCE25300 in current
builds). Recovers ctx_base by anchoring on the canonical layout (events at
ctx+0x54/+0x64/+0x74/+0x84 with 16-byte stride; ctx_base = ev_addr - (ev_addr
- 0xBCE251C0)). Also emits an explicit per-slot summary of the 8 candidate
KEVENT headers at +0x54..+0xC4 for sanity.

Produces 48 DUMP rows + 8 slot rows in canary.log on the first triggering
KeSetEvent. Guarded by std::atomic_bool so subsequent fires are silent. Used
by iterate 2.BF context-replication in ours: we need the live [ctx+0] vtable
pointer and the 4 quiet/4 active KEVENT slot config to synthesize a matching
WorkerCtx and spawn the four sub_82506xxx entries.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-07-12 15:43:23 +02:00
MechaCat02
3c7aa73512 [Audit] handle-lifecycle: include guest LR + one-frame stack-walk on waits
Extend the AUDIT-HLC probes with guest LR capture:
  - NtCreateEvent, NtSetEvent, KeSetEvent: log immediate guest LR
    (cpu::ThreadState::Get()->context()->lr) so callers can be
    attributed to specific guest functions.
  - NtWaitForSingleObjectEx entry + _done: also walk one PPC stack
    frame up to recover the guest_lr of the wait wrapper's caller
    (Xbox 360 EABI: saved LR at [prev_sp - 8], see xenia-rs's
    walk_guest_back_chain). lr_enter alone gives only the kernel
    wait wrapper return address (e.g. 0x824AC578); guest_lr surfaces
    the actual call site.

Still cvar-gated on audit_handle_lifecycle. Used in audit-059 round 4
to map canary handles F8000xxx to ours' 0x12xx wedges via guest LR
matching against silph::UImpl/GamePart cluster.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-07-12 15:43:22 +02:00
MechaCat02
fea4ef31ec [Audit] handle-lifecycle XELOGKERNEL probes (cvar-gated)
New cvar `audit_handle_lifecycle` (Auditing group, default false).
When enabled, emits one-line XELOGKERNEL traces tagged AUDIT-HLC at:
  NtCreateEvent return, NtSetEvent entry, KeSetEvent entry,
  NtWaitForSingleObjectEx entry + completion,
  EmulateCPInterruptDPC entry.

Observation-only: zero-overhead when cvar off (single branch + flag
read). Intended for handle disambiguation between xenia-rs and
canary under the Wine cross-build oracle.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-07-12 15:43:22 +02:00
Gliniak
22d91c86e8 [Kernel] Restored yield in XAudioGetVoiceCategoryVolumeChangeMask
Thanks to latest change there is no need to use hardcoded nanosleep, so we can go back to previous stuff.
Hopefully it will fix some random issues with audio introduced lately
2026-07-10 22:52:51 +02:00
The-Little-Wolf
d804cf828a [Xam/Locale] - Sketchy Implementation of XamGetLanguageTypefacePatch
- Sketchy Implementation of XamGetLanguageTypefacePatch
2026-07-08 11:44:40 +02:00
The-Little-Wolf
573cce0fe2 [Xam/Locale] - Implement XTLGetLanguageV2
- Implement XTLGetLanguageV2
- Used by Internet Explorer
2026-07-04 20:57:20 +02:00
Gliniak
e45c25c4c9 [XAM] Added check for UserSetting max ID 2026-07-04 20:25:18 +02:00
Adrian
35c513bfa2 [XAM] Fixed UserData reading incorrect variant type 2026-07-04 14:47:33 +02:00
The-Little-Wolf
a421f8da52 [Xam/Info] - Implement XGetOverlappedExtendedError
- Implement XGetOverlappedExtendedError
2026-06-29 09:16:56 +02:00
Adrian
1e7c1f6773 [VFS] Fixed opening files with incompatible access flags on posix 2026-06-27 00:06:24 +02:00
Gliniak
2771366b8b [XAM] Simplified loader_data structure.
- Removed launch_data_present replaced with empty check

Fixed regression introduced in 269ee61845
2026-06-23 20:58:28 +02:00
Gliniak
9c8e34b29e [Kernel] Moved kernel memory allocation to proper location.
- Moved few globals to kernel memory range to prevent overuse of SystemHeapAlloc
2026-06-22 22:34:03 +02:00
Gliniak
b268292046 [Kernel] Use single page to store all Vd pointers and structs
This is to prevent some titles from reaching out of memory crash
2026-06-21 17:52:09 +02:00
Adrian
e7d0e45095 [XAM] Fixed returning error in XamLoaderGetLaunchDataSize 2026-06-19 20:01:08 +02:00
Adrian
269ee61845 [XAM] Fixed returning error in XamLoaderGetLaunchData
Fixed Assassin's Creed switching xex on boot.
2026-06-18 13:25:18 +02:00
The-Little-Wolf
2027f50b6e [Xam/User_profile] - Add missing filenames & device types
- Add missing XTileType filenames
- Add missing device types
- Add XamLoaderLaunchTitle/Ex Flags
- Add ExThreadCreate flags and logging (from nukernel)
- Add more logging to user_module
- Add missing XamReadTileEx param
2026-06-11 20:37:55 +02:00
Gliniak
49c700b9c5 [XMP] Return success for XMPGetMediaSources with 0 sources
- Renamed XMPDashInIt to XMPDashInit
- Added broadcast to XMPDashInit
- Renamed some unknown fields of XMP_SET_MEDIA_SOURCE_WORKSPACE
2026-06-06 10:59:38 +02:00
Gliniak
99fd19d025 [XAM] Limit XContentQueryVolumeDeviceType to XContent packages
Some checks failed
Orchestrator / Commit Message Validation (push) Has been skipped
Orchestrator / Lint (push) Successful in 1m23s
Orchestrator / Windows (x86-64) (push) Failing after 5m18s
Orchestrator / Linux (x86-64) (push) Failing after 22m34s
Orchestrator / Create Release (push) Has been skipped
- Changed mount path for XContent packages from Cdrom to Package_0
Normally it should generate specific value instead of 0, but for now 0 is enough
2026-06-05 16:13:31 +02:00
Gliniak
9478cda5d6 [Kernel] Fixed issue with titles not booting due to lack of title id 2026-06-03 22:45:54 +02:00
Adrian
be6e53e383 [XAM] Fixed missing CreateFolder in XamWriteGamerTile
Fixed Rez HD failing to get past main menus in unlocked state.
2026-06-02 20:36:25 +02:00
The-Little-Wolf
7a5cb96c2e [XAM/INFO] - IPTV Initialization Setting
- Allow for initializing IPTV
- Stub XamGetDvrStorage
- Stub XamSetDvrStorage
2026-05-26 19:36:34 +02:00
Adrian
c48e0f29e5 [XAM] Implemented XUserAwardGamerPicture 2026-05-24 20:18:46 +02:00
The-Little-Wolf
a7e13e195b [Xam/Content] - Implement XamContentResolveInternal
- Implement XamContentResolveInternal
2026-05-23 20:21:55 +02:00
Gliniak
a11908fa76 [XAM] Enable storing IPTV name.
Still needs to be exposed in UI (optional)
2026-05-19 23:31:53 +02:00
Gliniak
072ef7eff7 [XAM] Implemented XamGetOnlineLanguageAndCountry 2026-05-19 22:37:14 +02:00
Gliniak
9ce91e55fe [UI] Listed extended languages 2026-05-19 22:03:54 +02:00
Gliniak
99ea6da18a [XConfig] Implementation of XConfig 2026-05-19 07:50:16 +02:00
The-Little-Wolf
f88bfbe41e [Xam/Content] - Implement XamContentCreateEnumeratorInternal
- Implement XamContentCreateEnumeratorInternal
2026-05-18 20:30:38 +02:00
Gliniak
ef67d1ca3f [SMC] Removed std::bind usage in favor of lambda 2026-05-18 19:52:12 +02:00
Gliniak
482629a3b1 [XAM] Fixed issue with different param count in XamFormatDateString and XamFormatTimeString
In older dashes filetime is in r4 then output buffer in r5
but on newer it's in r3 and r4
2026-05-17 17:34:39 +02:00
Adrian
a261b83def [APP] Flush log & save config on quick exit 2026-05-17 12:05:20 +02:00
Gliniak
4c396fe611 [XAM] Implemented XamGetLanguageLocaleFallbackString and XamGetLanguageTypeface
- Added stub XamGetLanguageTypefacePatch
- Moved locale related calls to xam_locale from xam_info
2026-05-17 10:49:08 +02:00
The-Little-Wolf
dc4db67f9c [Kernel] - Change OddObj to X_DISPATCH_HEADER
- Change OddObj to X_DISPATCH_HEADER
- Add unknown X_KWAIT_REASON flag
- Fixed InitializeGuestObject mistake
- Replaces unknowns in kthread using nukernel as reference
2026-05-16 23:57:19 +02:00
Adrian
6181160ed4 [XAM] Fixed XEX swap failing to remove prefix
Fixed Splinter Cell: Double Agent xex swapping from singleplayer to multiplayer.
2026-05-15 09:42:14 +02:00
Adrian
cebbdb6cac [Kernel] Implemented XeCryptHmacShaInit, XeCryptHmacShaUpdate and XeCryptHmacShaFinal 2026-05-14 23:04:47 +02:00
Gliniak
fdbaaaba21 [Kernel] Replace SHIM version of kernel strings with exports
- Split into header file for usage in other places
- Removed most of define SHIM Utils
2026-05-14 22:11:40 +02:00
Adrian
d1e587617a [UI] Fallback to default button for XamShowMessageBoxUI 2026-05-14 07:20:14 +02:00
Gliniak
331ddf79bf [Kernel] KeGetImagePageTableEntry: Added bit 0 set
According to dashboards 14xxx and higher it is required that
return of this call will have that bit set.
2026-05-13 20:07:46 +02:00
Gliniak
cdb88d0b36 [Kernel] Remove IsQueued check for DPC 2026-05-13 20:02:36 +02:00
Adrian
f4f821215e [XGI] Stubbed XUserAwardAvatarAssets 2026-05-12 13:07:15 +02:00
Adrian
bfdaa41827 [XGI] Cleanup XUserWriteAchievements 2026-05-11 21:03:40 +02:00
Gliniak
74f34818e7 [Lint] Added InsertBraces to linter to unify codebase to one standard 2026-05-08 18:54:50 +02:00
Adrian
2c68a2fc4b [XAM] Fixed XamUserReadProfileSettingsEx setting buffer_size_ptr
Fixes Kinect Dashboard from crashing when selecting Switch Profiles.
2026-05-08 15:02:53 +02:00
Gliniak
80f2b535e9 [Kernel] Added KeSaveFloatingPointState and KeRestoreFloatingPointState from nukernel 2026-05-05 10:45:31 +02:00