Skip to content

LATX, fix: Avoid invalid IR1 predecessor access - #338

Draft
LaurenIsACoder wants to merge 1 commit into
lat-opensource:masterfrom
LaurenIsACoder:lauren/ir1-predecessor-guard
Draft

LATX, fix: Avoid invalid IR1 predecessor access#338
LaurenIsACoder wants to merge 1 commit into
lat-opensource:masterfrom
LaurenIsACoder:lauren/ir1-predecessor-guard

Conversation

@LaurenIsACoder

Copy link
Copy Markdown
Contributor

Summary

  • Avoid forming ir1_list[-1] when disassembly fails before producing the
    first IR1 instruction.
  • Derive the synthesized invalid instruction address from a predecessor only
    after confirming that one exists.
  • Keep the touched block compliant with the project indentation rules.

Root cause

The failure path formed a pointer to ir1_list[ir1_num - 1] before checking
whether ir1_num was zero. A decode failure on the first instruction therefore
formed an out-of-bounds predecessor pointer even though the zero-instruction
branch did not dereference it.

Validation

Mac:

  • Deterministic RED by temporarily restoring the old hunk: strict checkpatch
    reported 6 errors.
  • GREEN: strict checkpatch reports 0 errors and 0 warnings.
  • git diff --check passes.
  • Standards and specification reviews both pass with no P0-P2 findings.

LoongArch (l1, commit c91ac892ce776d26c2c97fd35c479d5dca1fc16e):

  • Incremental compilation of
    libqemu-x86_64-linux-user.fa.p/target_i386_latx_translator_translate.c.o
    passes.
  • ninja -C build latx-x86_64 -j8 passes.
  • Final ninja -C build -j8 passes.
  • meson test -C build --no-rebuild --print-errorlogs: 4/4 tests pass.

Signed-off-by: Wenqiang Wei weiwenqiang@mail.ustc.edu.cn

QCefViewTest can reach the decode limit before producing an IR1
instruction. Do not form ir1_list[-1] in that case; only derive the next
address from a predecessor after confirming one exists.

Signed-off-by: Wenqiang Wei <weiwenqiang@mail.ustc.edu.cn>
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.

2 participants