loader: a loop-shaped cmp is the clzero loop only against rax #593
No reviewers
Labels
No labels
AMD
audio
bug
confirmed
crash
cutscene
dlss
documentation
duplicate
enhancement
fixed-on-main
frame-generation
hle
input
INTEL
lighting
linux-proton
memory
MULDER
needs-info
needs-logs
needs-rebase
NVIDIA
performance
post-merge
pr-diagnostics
pr-docs
pre-merge
pr-feature
pr-fix
pr-performance
pr-refactor
pr-tests
question
RAYTRACING
relevance
high
relevance
low
relevance
medium
relevance
very-high
rendering
report
roadmap-proposal
saves
series-s
shaders
startup
status
blocked-by-rework
status
needs-test-report
status
needs-triage
status
ready-for-review
status
stale
status
superseded
status
wip
tools
ui
upstream
wontfix
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
TrustNo1/Darner!593
Loading…
Reference in a new issue
No description provided.
Delete branch "qnjk/Darner:clzero-loop-modrm"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Contributor role (optional)
What it changes
The problem on main: the
clzero-loop recogniser (crates/darner-loader/src/console_insn_decode.rs, around:117-130) matched the four-instruction shapeclzero; add rax, 0x40; cmp rax, <reg>; jb -12by checking the bytes of each instruction but never the ModRM of thecmp. Its comment sayscmp rax, <reg>, i.e. the register form with r/m =rax; the code accepted any ModRM there. A title sequence shaped like the loop but comparing against something else —cmp rbx, rax, orcmp [rax], rax— was therefore decoded asClzeroLoop { end_reg }, and the loader zeroed a whole range[rax..reg)that the title never asked to zero, instead of leaving it as oneclzeroand the title's ownadd/cmp/jb.This change adds the missing condition:
(code[i + 9] & 0xC7) == 0xC0— mod = 3 (register direct), r/m = 0 (rax) — so only the shape the comment describes is taken as the loop.How it was tested
a42ab0a(one commit onc8258f9).cargo test --locked -p darner-loader --lib -- console_insn— 11 passed, 0 failed.console_insn::decode::tests::a_compare_that_is_not_against_rax_is_not_the_loop:clzero; add rax, 0x40; cmp rbx, rax; jbandclzero; add rax, 0x40; cmp [rax], rax; jbmust both decode as oneClzero(3 bytes), not as the loop.mainthe wrong range is zeroed.cargo clippy --locked -p darner-loader --all-targets -- -D warningspasses.cargo clippy --workspace --all-targets --locked -- -D warnings: passes.cargo clippy --workspace --all-targets --all-features --locked -- -D warnings: passes.cargo test --workspace --locked: not run to completion here; the pre-existingdarner-gputest deadlock (#224) anddarner-shaderwaterfall fixture failure (#227) make the whole-workspace run non-green on this machine.darner-loader's suite is green.cmpshaped like that against anything butrax; the tests supply the near-misses.cmpwith a REX prefix of the other group (0x49) and a SIB/displacement form are not.Checklist
main.main.docs/asset-policy.md(cargo xtask policy: 576 files ok).Checked for overlap
crates/darner-loader/src/console_insn_decode.rs(checked against the file list of all 189 open pull requests), and no open or closed issue mentionsclzeroloop recognition.[pr-fix][startup] loader: a loop-shaped cmp is the clzero loop only against raxto loader: a loop-shaped cmp is the clzero loop only against raxTest needed — commit
a42ab0ac; what to check:The problem on main: the
clzero-loop recogniser (crates/darner-loader/src/console_insn_decode.rs, around:117-130) matched the four-instruction shapeclzero; add rax, 0x40; cmp rax, <reg>; jb -12by checking the bytes of each instruction but never the ModRM of thecmp. Its comment sayscmp rax, <reg>, i.e. the register form with r/m =rax; the code accepted any ModRM there. A title sequence shaped like the loop but comparing against something else —cmp rbx, rax, orcmp [rax], rax— was therefore decoded asClzeroLoop { end_reg }, and the loader zeroed a whole range[rax..reg)that the title never asked to zero, instead of leaving it as oneclzeroand the title's ownadd/cmp/jb.This change adds the missing condition:
(code[i + 9] & 0xC7) == 0xC0— mod = 3 (register direct), r/m = 0 (rax) — so only the shape the comment describes is taken as the loop.Evidence to post: card + driver, settings, commit tested, before/after (switch off vs on, two runs each), fps median and p99, and one line saying you looked at the picture.
Reply
testingto take this run; it's free again after 24 h with no results.View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.