<feed xmlns='http://www.w3.org/2005/Atom'>
<title>amd-psp-re.git/fw/decomp/asd_reference_asd2.c, branch main</title>
<subtitle>AMD PSP reverse engineering, emulator and vulnerability research</subtitle>
<id>https://git.sl0p.foo/amd-psp-re.git/atom/fw/decomp/asd_reference_asd2.c?h=main</id>
<link rel='self' href='https://git.sl0p.foo/amd-psp-re.git/atom/fw/decomp/asd_reference_asd2.c?h=main'/>
<link rel='alternate' type='text/html' href='https://git.sl0p.foo/amd-psp-re.git/'/>
<updated>2026-10-01T18:05:33Z</updated>
<entry>
<title>make the artifacts agree with themselves: 1,018 banner/body name mismatches down to 7</title>
<updated>2026-10-01T18:05:33Z</updated>
<author>
<name>user</name>
<email>user@clank</email>
</author>
<published>2026-10-01T18:05:33Z</published>
<link rel='alternate' type='text/html' href='https://git.sl0p.foo/amd-psp-re.git/commit/?id=94bcea2807457eca208c10456d636a00a5df054c'/>
<id>urn:sha1:94bcea2807457eca208c10456d636a00a5df054c</id>
<content type='text'>
The thunk naming in the previous commits set row["name"] in this script's metadata only, never in the
database. So the emitted banner read j_asd_clear_link_outputs while the signature inside the body
still read j_sub_D07E10_16. Checking for it found 1,018 functions disagreeing with their own banner,
most introduced by the earlier repair pass rather than the newest one. A reader who sees the two
differ cannot tell which to trust, which is worse than leaving the function anonymous -- and I had
claimed in the last commit message that no j_sub_ names remained in any artifact, which was false.

ta_re.py now pushes every derived name into the database and re-decompiles whatever still disagrees.
Two details were needed, both found by measuring the result rather than trusting the step:

Names must be uniquified first. Several distinct thunks branch to the same target, so j_&lt;target&gt; is
not unique and a colliding rename is silently refused -- on the ASD reference only 55 of 786
reconciled until duplicates were suffixed. Those suffixes are honest, unlike the address-derived _N
names dropped earlier: these are genuinely separate functions with a shared destination.

And the resolution has to run after address-derived names are dropped, since before that point the
rows still carry a stale j_sub_&lt;addr&gt; label and look named, so the pass skipped all of them.

Regenerated asd, gcp, powerplay, xgmi, wspe and ras. Mismatches 1,018 -&gt; 7 corpus-wide; the 7 are ASD
functions where the decompiler emits no signature line this check can read. Meaningful names hold at
19,038 (65.8%), address-derived 0, field share 75.5%.
</content>
</entry>
<entry>
<title>put the name/readability predicates in one module; stop admitting address defaults as names</title>
<updated>2026-10-01T17:25:41Z</updated>
<author>
<name>user</name>
<email>user@clank</email>
</author>
<published>2026-10-01T17:25:41Z</published>
<link rel='alternate' type='text/html' href='https://git.sl0p.foo/amd-psp-re.git/commit/?id=03788cbf4cb0285c3189cd86d55fb6129369c85d'/>
<id>urn:sha1:03788cbf4cb0285c3189cd86d55fb6129369c85d</id>
<content type='text'>
Four metric-definition errors in four commits, each from re-writing the same predicate at a new use
site and getting it slightly too strict. fw/ta_metrics.py now holds the definitions once -- is_addr_name,
is_meaningful, and a measure() that prints every denominator -- and ta_re.py imports them instead of
carrying its own regexes. All four errors are documented in its docstring with the reported and actual
figures, because the pattern is the useful part.

The root cause was in the pipeline, not just the audit. The decompiler-fallback step accepted any
candidate that did not match ^sub_[0-9A-Fa-f]+$, so sub_D07364_12 was admitted as a real name and
1,852 such entries propagated into the artifacts and into every coverage number I quoted.

ta_re.py now drops them, in an order that matters: a j_sub_* candidate is still kept at the fallback
step, because the re-resolution pass needs its target address to recover a real name from it, and
only what remains address-derived afterwards is dropped. Those rows become anonymous and move to the
.anon.c file rather than inflating the count.

Measured with the shared code: address-derived entries 1,295 -&gt; 0, meaningful names unchanged at
18,129 (62.6%), field share unchanged at 75.6%. The drop removes false coverage without losing a
single real name, which is the point -- the artifacts no longer assert that sub_D07364_12 is a name.
</content>
</entry>
<entry>
<title>the thunk fix missed IDA's collision suffix: 713 more names, and the metric was 6 points high</title>
<updated>2026-10-01T17:18:10Z</updated>
<author>
<name>user</name>
<email>user@clank</email>
</author>
<published>2026-10-01T17:18:10Z</published>
<link rel='alternate' type='text/html' href='https://git.sl0p.foo/amd-psp-re.git/commit/?id=827c8abf2731cb02a9971493e57fae4d0d6c4229'/>
<id>urn:sha1:827c8abf2731cb02a9971493e57fae4d0d6c4229</id>
<content type='text'>
Measuring collision suffixes in the artifacts showed names like j_sub_D07364_0 through
j_sub_D07364_20. My address-derived regex anchored on $ immediately after the hex digits, so none of
the suffixed forms matched it -- and j_sub_D07364_12 is exactly as address-derived as j_sub_D07364.

1,852 ASD functions were being counted as meaningful names on that basis. The honest figure was
60.2%, not the 66.6% reported one commit ago. The repair pass added in that same commit skipped them
for the identical reason, so 713 thunks with properly named targets sat fixable and untouched.

Both regexes now accept the suffix. In the artifacts: 713 more names recovered, address-derived
entries 2,008 -&gt; 1,295, meaningful names 17,416 -&gt; 18,129 (60.2% -&gt; 62.6%). The remaining 1,272
thunks point at targets that are not functions in their own build, so j_sub_* stays, which is
correct.

This is the fourth metric-definition error in four commits and the largest, and it is worse than the
others because I made it in code written immediately after describing the problem it repeats. Finding
one instance of a class of error is not evidence the class is clear. A regex that defines a quality
metric needs the same scrutiny as one that drives a rename: an over-strict pattern inflates the
number and hides the work it should have exposed.
</content>
</entry>
<entry>
<title>re-resolve stale thunk names after their targets get named: +87 real names</title>
<updated>2026-10-01T17:11:09Z</updated>
<author>
<name>user</name>
<email>user@clank</email>
</author>
<published>2026-10-01T17:11:09Z</published>
<link rel='alternate' type='text/html' href='https://git.sl0p.foo/amd-psp-re.git/commit/?id=2f2805dc428be6e16a88ccfdb6bc9a08769fcef8'/>
<id>urn:sha1:2f2805dc428be6e16a88ccfdb6bc9a08769fcef8</id>
<content type='text'>
Correcting the headline count last commit exposed 243 functions whose name field was set to an IDA
address default. Looking at what they actually were, rather than treating them as a rounding error,
found a real defect: 220 were j_sub_&lt;addr&gt; thunk names, and 87 of those pointed at targets that by
now carry a proper name.

The cause is ordering. The j_&lt;target&gt; label comes from whatever Hex-Rays printed in the signature at
the moment that thunk was decompiled, so a thunk decompiled before its target was renamed keeps the
stale address forever. Nothing ever revisited it.

decompile_all now re-resolves them from `assigned` after the naming pass. That keeps it a pure
lookup -- the target name is one the pipeline already decided on, so no new inference enters -- and
thunks whose target is still unnamed keep j_sub_*, which is the honest answer rather than a
cosmetic upgrade.

In the artifacts: 87 names recovered across 5 ASD builds, address-derived entries 243 -&gt; 156,
meaningful names 19,181 -&gt; 19,268 (66.3% -&gt; 66.6%). Names like j_asd_build_link_map_full and
j_asd_clear_link_outputs now appear where j_sub_D06CE4 used to.

Worth recording why this was invisible for so long: these functions were being counted as named, so
every coverage number I looked at said they were fine. The metric correction is what made the defect
visible, which is the one case here where fixing a measurement directly produced real improvement
rather than just a more accurate claim.
</content>
</entry>
<entry>
<title>correct an overclaim: the artifacts are not byte-reproducible, and persist DISPATCH names</title>
<updated>2026-10-01T15:55:43Z</updated>
<author>
<name>user</name>
<email>user@clank</email>
</author>
<published>2026-10-01T15:55:43Z</published>
<link rel='alternate' type='text/html' href='https://git.sl0p.foo/amd-psp-re.git/commit/?id=4d2cd84448bac512546710cb5f80c656072b7b50'/>
<id>urn:sha1:4d2cd84448bac512546710cb5f80c656072b7b50</id>
<content type='text'>
An earlier pass reported that all 99 artifacts regenerate byte-identically. That was true of that
one run and does not hold in general. A full clean regeneration of all sixteen modules changes 220
files, and the cause is IDA's auto-analysis not being identical across fresh databases: AUC's
function count comes back 39 instead of 40, and decompiled text varies cosmetically
("(int)nullsub_3" against "nullsub_3"). The claim is corrected here rather than left standing.

Semantically the drift is small -- 4 names of 19,353 -- but all four were tier DISPATCH, which
exposed a wrong decision. fw/ta_snapshot_names.py excluded DISPATCH on the grounds that
fw/ta_re.py re-derives it every run. It does, but not deterministically: dispatcher recovery
depends on which function Hex-Rays decompiles cleanly on a given analysis, so xgmi_cmd00,
xgmi_cmd04, xgmi_cmd0B and fp_cmd04 simply did not come back. DISPATCH is now persisted, and the
exclusion reasoning in that file is rewritten to say why.

Persisting it still cannot mask a regression: the dispatcher step runs regardless, so where
recovery works the DISPATCH tier wins and where it fails the restored name appears as tier IDA.
The tier difference is itself the signal that recovery failed on that build.

7817 names were recovered from the committed artifacts into fw/cgnames so nothing derived is left
depending on a database that may not reproduce. XGMI came back whole.

The one name that did NOT come back turned out to be a defect being fixed rather than lost. HEAD
had TWO functions called fp_cmd04 -- 0x401334 from the dispatcher and 0x402b4c from byte porting
-- and the current dispatcher map routes command 4 to 0x402b4c, agreeing with the ported name. So
HEAD carried a duplicate, this run does not, and the allow_overwrite=False guard on the re-apply
is what refused to restore the bad one. Worth keeping: a name count going DOWN was the correct
outcome, and reading it as a regression would have reintroduced the duplicate.

Verified state after the clean regeneration: 16/16 gates PASS, 99 builds, 19,349 of 28,945 named
(66.8%), field share 66.4%, 21 decompile failures.
</content>
</entry>
<entry>
<title>correct two mislabelled GCP handlers, and stop emitting stale pseudocode</title>
<updated>2026-10-01T15:35:34Z</updated>
<author>
<name>user</name>
<email>user@clank</email>
</author>
<published>2026-10-01T15:35:34Z</published>
<link rel='alternate' type='text/html' href='https://git.sl0p.foo/amd-psp-re.git/commit/?id=08856659e933722835add5d5aeb8e86aaf60e453'/>
<id>urn:sha1:08856659e933722835add5d5aeb8e86aaf60e453</id>
<content type='text'>
Two GCP handlers were mislabelled in the libdump symbol set and the mislabels had been
propagating into every artifact. The duplicate name was the tell: FE0B and FE0D were both called
DestroyAuthenticatedSession.

The code settles it without needing the documents. gcp_cmdFE0C iterates ctx-&gt;crypto, zero-fills a
0x58 gcp_crypto_session and sets crypto-&gt;state and crypto-&gt;key, so it creates a CRYPTO session.
gcp_cmdFE0D computes "(char *)ctx + 88 * HIBYTE(arg10)" -- stride 88, the crypto array at
ctx+0x800 -- while gcp_cmdFE0B uses stride 80, the auth array at ctx+0x300. AUDIT-NEW-TAS-RE.md
states exactly that split, and the hardware findings agree: FINDING-GCP-ACQUIRE-GATE-BYPASS
records 0xFE0C as CreateCryptoSession.

Worth distinguishing from the FE07 case: that one claimed the wrong COMMAND and the dispatcher
cross-check caught it automatically. These two claim the right command and the wrong SEMANTICS,
so no command-id check can see them -- only reading what the code touches. The corrections are
applied by name through a RENAME_FIX table so they hold for every build.

While verifying them, the dispatcher kept printing the old callee name in four builds after the
rename had demonstrably succeeded. Hex-Rays caches pseudocode per function and
remote_ops.rename refreshes only the function it renamed, never its callers, so a stale cache was
reading as a failed rename. Every function's cached text is now invalidated before the artifacts
are emitted.

That turned out to matter far beyond the two names. Applied TYPES were also being hidden behind
stale text: GCP's field share goes 59% to 83.4%, its typed field accesses 1716 to 3081 and its raw
dereferences 1193 to 612, with no new structure added -- the types had been applied all along and
the emitted artifacts were showing pre-typing output. WSPE lands at 91%, HDCP 70%, XGMI 69%,
POWERPLAY 67%. Corpus field share 65.9% -&gt; 66.4%, held down by ASD, which dominates the corpus and
barely moved.

This is the sixth consecutive pass whose main finding was that something already done was not
visible in the output. The remaining low scores are now informative rather than suspect: merit at
0% and opm at 19% are low because their structures are mostly opaque body arrays, not because
typing failed.
</content>
</entry>
<entry>
<title>fix an arg1 typing path that reported success while applying nothing</title>
<updated>2026-10-01T15:16:49Z</updated>
<author>
<name>user</name>
<email>user@clank</email>
</author>
<published>2026-10-01T15:16:49Z</published>
<link rel='alternate' type='text/html' href='https://git.sl0p.foo/amd-psp-re.git/commit/?id=269b73a1e132443286820143af5febab6fe61f6e'/>
<id>urn:sha1:269b73a1e132443286820143af5febab6fe61f6e</id>
<content type='text'>
The biggest single typing target in the corpus, asd_program_link_by_signal with 504 raw
pointer-arithmetic dereferences, had been counted as typed since the ASD structures were added.
It was not. Re-running the concentration analysis after the naming work -- which moved many
dereference-heavy functions out of ANON and into named groups -- put it straight back at the top
of the list, which is what prompted looking again.

Cause: the name-keyed arg1 block still carried its own inline copy of the prototype rewrite,
written before retype_arg1 was factored out. The inline copy does not strip comment lines before
locating the signature, and fw/ta_re.py applies recorded comments earlier in the same run, so on
any function carrying a comment the head parse ran across the comment text and produced a
declaration IDA rejected. The failure was invisible because the surrounding counter only counted
successes and the missing ones looked like functions absent from the build -- the reference
reported "12/16" for exactly the number of family members it lacks.

Switching that block to the shared helper takes the reference from 12/16 to 16/16 and converts
ASD from 35% to 59.5% field share on its own. Corpus field share goes 59.5% -&gt; 64.6%, with raw
dereferences 8481 -&gt; 7297.

Two avenues were measured and rejected first, so they are not retried: seeding ASD's weaker
builds from its best-named CORPUS build rather than the handover reference yields 1-4 names per
build at a much worse mismatch rate (15-35 against 0-4), because the handover names have already
propagated; and the structural residue is unchanged.

Note the struct-typed signature figure moves DOWN, 6.5% to 4.1%, purely because the denominator
grew: naming added thousands of previously-ANON functions to the emitted set. It is a ratio
artefact, not a regression, and is the clearest demonstration yet of why the field share is the
measure worth tracking.
</content>
</entry>
<entry>
<title>name functions through the call graph, and fix a rename counter that hid every failure</title>
<updated>2026-10-01T14:54:38Z</updated>
<author>
<name>user</name>
<email>user@clank</email>
</author>
<published>2026-10-01T14:54:38Z</published>
<link rel='alternate' type='text/html' href='https://git.sl0p.foo/amd-psp-re.git/commit/?id=4f3bd8d555fa2847ac4cd7854d9b3a8cf4f847e1'/>
<id>urn:sha1:4f3bd8d555fa2847ac4cd7854d9b3a8cf4f847e1</id>
<content type='text'>
Byte and mnemonic porting only names a function whose own body still resembles the reference.
A function's position in the CALL GRAPH is independent evidence: if reference function A matches
target A' and both make the same number of calls, the Nth callee of A' is the Nth callee of A.

fw/ta_cgname.py applies that, with three restrictions chosen because positional alignment is
exactly the sort of heuristic that quietly invents names: the call counts must be EQUAL or the
anchor is skipped entirely rather than aligned partially; every anchor reaching a target must
agree on the name, or it is left alone; and the candidate must be within a factor of two of the
size of the function whose name it is taking. Rounds iterate, so a function named in one round
becomes an anchor in the next.

The anchor mismatch rate is reported as its own control, because a high rate means the builds
have diverged too far for position to mean anything. For ASD it is 4-8% (9-17 mismatched against
63-269 aligned), which is why the result is trustworthy. For RAS the same tool finds only 4-12
usable anchors and produces nothing at all -- its reference shares too little with the corpus
builds, and that is reported rather than worked around.

843 names applied across ASD's 17 non-reference builds, taking ASD from 62.5% to 66.0% named and
the corpus overall past two thirds.

Found and fixed while debugging why the first run applied zero: the rename response is
{"func":[...], "summary":{"ok":N,"failed":M}}, and both this tool and fw/ta_re.py were looking
for a "result" list that does not exist. In ta_re.py that meant the rename-error counter reported
zero unconditionally for the entire effort -- it could never have told me about a failed rename.
Both now read the summary. The symptom was visible only because this tool counted successes
rather than failures; the ta_re.py version failed silently in the safe direction, which is why it
went unnoticed.
</content>
</entry>
<entry>
<title>stop discarding the names the decompiler already knows: 35% -&gt; 63% of functions named</title>
<updated>2026-10-01T14:34:56Z</updated>
<author>
<name>user</name>
<email>user@clank</email>
</author>
<published>2026-10-01T14:34:56Z</published>
<link rel='alternate' type='text/html' href='https://git.sl0p.foo/amd-psp-re.git/commit/?id=19d0927d8095674094f2ecfd98d4ace91209da29'/>
<id>urn:sha1:19d0927d8095674094f2ecfd98d4ace91209da29</id>
<content type='text'>
The artifacts were full of ANON blocks that did not need to be. This pipeline treated a function
as named only if ITS OWN porting had assigned a name, and threw away the name the decompiler
states in the signature. For ASD that was most of the module: 11,737 of its unnamed functions are
4-byte thunks, and Hex-Rays resolves thunks and prints 'j_&lt;target&gt;' in the signature even where
the stored symbol is still sub_*, so 7,812 perfectly good derived names were being written out as
"ANON size=4".

The fix takes the name from the decompiled signature whenever porting produced none and the name
is not a bare sub_*. This is IDA's own thunk resolution rather than an inference, but it is
recorded as a distinct tier -- THUNK for the j_ names, IDA for the rest -- so it never passes for
a ported identity.

Named functions across all 99 builds: 10,259 of 28,945 (35.4%) -&gt; 18,204 of 28,945 (62.9%). ASD
alone goes from 29% to 62%. Tiers: 7508 EXACT, 7812 THUNK, 2269 MNEM, 303 DISPATCH, 179 FUZZY,
133 IDA.

Two measurements on the way that corrected my earlier reasoning about where the naming gap was:

  * the ASD reference has only 46 ambiguous bodies involving 109 functions, not the 677-908 the
    per-build logs report. The per-build figure counts ambiguous TARGETS, and ASD's are
    overwhelmingly tiny identical thunks -- which is also why disambiguating them by address
    order was never worth its 12% error rate. They are now named from their jump targets instead,
    which needs no tiebreak at all.
  * 70% of ASD's reference names embed an address (asd_hdcp1_sub_1144, asd_svc_sub_273E), so they
    carry subsystem information but claim an offset that is wrong in any other build. Worth
    knowing before relying on a ported ASD name.

Log-string naming was also measured as an alternative and is small by comparison: only 98 unnamed
functions across the corpus reference a string literal at all (86 in GCP), and ASD logs numeric
codes rather than names, so the firmware's own log lines cannot name it.
</content>
</entry>
<entry>
<title>cover the later ASD link/caps family members, and retire two exhausted avenues</title>
<updated>2026-10-01T13:48:09Z</updated>
<author>
<name>user</name>
<email>user@clank</email>
</author>
<published>2026-10-01T13:48:09Z</published>
<link rel='alternate' type='text/html' href='https://git.sl0p.foo/amd-psp-re.git/commit/?id=8d29bc3afddcc65d4806b93de1a41aab184e7ed1'/>
<id>urn:sha1:8d29bc3afddcc65d4806b93de1a41aab184e7ed1</id>
<content type='text'>
Two things I proposed last turn turned out to be worth less than claimed, and checking them was
most of this pass.

The first was wrong outright. I said the shared TEE formatting cluster was unnamed in ten modules
and that running the libnames clustering would let one declaration cover them. It would not: the
libnames clusters are ALREADY applied everywhere -- 225 matches across the twelve libdumps with
zero remaining sub_* among them. The formatting cluster simply does not exist outside gcp,
powerplay, wspe, xgmi and ras, so there was nothing to name and nothing to gain.

The second avenue is now measured and exhausted. Of the 55 shared clusters, only three others
dereference a1 at all -- lib_3f07c814_10, lib_78974a43_20, lib_71f66102_20 -- each at a single
offset, 56 dereferences between them. A one-field structure buys no readability, so no more
shared structures are worth declaring.

What did pay was enumerating the ASD link and caps families across all 18 builds rather than
across the reference alone, which found five members the earlier list had missed:
program_link_by_signal_v5, encoder_enable_seq_v2, clear_link_outputs, get_link_caps_full_v4 and
_v5. Each was verified to use only offsets that are a strict SUBSET of the structure it is given,
rather than inferred from its name. asd_topology_update is deliberately excluded: it dereferences
a2 over a different offset set, so neither structure describes it.

Also worth recording from the measurement, because it changes where the remaining work is: ASD's
arg-based dereferences in NAMED functions are now 174, down from 6314. Its remaining 4817 a1
dereferences are in UNNAMED functions, which no structure can reach until the functions
themselves are identified. The residue is a naming problem, not a typing one.

Measured across fw/decomp: typed field accesses 7101 -&gt; 7327, raw dereferences 11849 -&gt; 11753,
field share 37.5% -&gt; 38.4%. Struct-typed signatures unchanged at 5.7%, as expected for a change
that retypes arguments of already-named functions.
</content>
</entry>
</feed>
