Skip to content

LATX, fix: Keep optimization configurations buildable - #339

Merged
LaurenIsACoder merged 7 commits into
lat-opensource:masterfrom
LaurenIsACoder:lauren/latx-config-build-guards
Jul 28, 2026
Merged

LATX, fix: Keep optimization configurations buildable#339
LaurenIsACoder merged 7 commits into
lat-opensource:masterfrom
LaurenIsACoder:lauren/latx-config-build-guards

Conversation

@LaurenIsACoder

@LaurenIsACoder LaurenIsACoder commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Summary

  • keep SMC, JRRA/JRRA_STACK, XCOMISX, AOT, and syscall-tunnel code consistent with the O0-O3 and LOW_MEM0-2 compile-time feature matrix
  • update the O3 syscall-tunnel path to the current LoongArch emitter interfaces
  • reject syscall-tunnel table indices outside the 387-entry table and preserve the full 64-bit host TB pointer

Review findings fixed

  • LOW_MEM0 disabled JRRA but left JRRA_STACK enabled
  • O0 referenced XCOMISX-only parameters
  • O0 and LOW_MEM1/2 retained calls to implementations compiled out with CONFIG_LATX_AOT
  • O3 used removed emitter interfaces
  • O3 could index syscall_optimize_confirm out of bounds
  • the traditional syscall path could truncate last_executed_tb for a 32-bit guest

Validation

Rebased without conflicts on master@c8cae544266.

Mac:

  • strict checkpatch: 0 errors, 0 warnings
  • git diff --check: clean
  • Spec review: PASS, no P0-P2
  • Standards review: PASS, no P0-P2

LoongArch host l1, persistent checkout and build directory:

  • deterministic RED/GREEN reproduced for O0 XCOMISX compile failure
  • deterministic RED/GREEN reproduced for O2+LOW_MEM0 JRRA stack field failure
  • deterministic RED/GREEN reproduced for O0 AOT-only undefined references
  • deterministic RED/GREEN reproduced for O3 syscall-tunnel emitter failures
  • x86_64 build matrix: O0-O3 x LOW_MEM0-2, 12/12 links passed after rebase
  • i386 O3 + LOW_MEM0 full latx-i386 link: PASS
  • default O1 ninja latx-x86_64 -j8: PASS
  • default O1 ninja -j8: PASS
  • default O1 test isolation: 0 registered tests and 0 test targets
  • explicit --enable-tests build: PASS
  • meson test --no-rebuild --print-errorlogs: 4/4 PASS
  • restored default O1 configuration: 0 registered tests

ganjue66da and others added 7 commits July 24, 2026 08:15
Signed-off-by: Wenqiang Wei <weiwenqiang@mail.ustc.edu.cn>
CONFIG_LATX_JRRA_STACK depends on the JRRA TranslationBlock fields. LOW_MEM_MODE_0 disabled CONFIG_LATX_JRRA alone, leaving O2 and O3 builds to compile JRRA stack users without those fields.

Disable JRRA stack together with JRRA in low memory mode.

Test: O2 + LOW_MEM_0 aot_link_seg object build (RED before, GREEN after).
Signed-off-by: Hanlu Li <heuleehanlu@gmail.com>
O0 disables CONFIG_LATX_XCOMISX_OPT, so tr_generate_exit_tb has no func or stub parameters. The common exit path still passed those names to set_jmp_reset_offset and failed to compile.

Pass NULL placeholders when XCOMISX optimization is disabled while preserving the common jump-reset offset generation.

Test: O0 + LOW_MEM_0 translate object build (RED before, GREEN after).
Signed-off-by: Hanlu Li <heuleehanlu@gmail.com>
O0 and low-memory configurations can compile out CONFIG_LATX_AOT while the runtime option_aot variable remains available. The SMC reload and pread paths therefore retained references to AOT-only implementations and failed to link.

Compile those call sites only when AOT support is present.

Test: O0 + LOW_MEM_0 latx-x86_64 link (RED before, GREEN after).
Signed-off-by: Hanlu Li <heuleehanlu@gmail.com>
O3 enables CONFIG_LATX_SYSCALL_TUNNEL, whose translation path still used removed address helper names and passed an IR2 operand to la_syscall after its interface changed to an integer immediate.

Use the current 64-bit add, address-sized store, and syscall emitter interfaces.

Test: O3 + LOW_MEM_0 tr-misc object build (RED before, GREEN after).
Signed-off-by: Hanlu Li <heuleehanlu@gmail.com>
The O3 syscall tunnel indexed its optimization table directly with the guest EAX value. Valid i386 syscall numbers above the 387-entry table, as well as arbitrary values, could read past the array and select the wrong path.

Expose the table count, branch out-of-range translated syscalls to the traditional path, and make the C lookup reject invalid indices too.

Test: source-level RED showed no bounds branch; O3 configuration build verifies the emitted guard compiles.
Signed-off-by: Hanlu Li <heuleehanlu@gmail.com>
last_executed_tb stores a host TranslationBlock pointer in a 64-bit virtual-register slot. Using the guest address-sized store would truncate the pointer for a 32-bit guest.

Store the pointer explicitly with la_st_d, matching the slot and host pointer width.

Test: source review RED identified address-sized truncation; O3 configuration build verifies the corrected emitter.
Signed-off-by: Hanlu Li <heuleehanlu@gmail.com>
@LaurenIsACoder
LaurenIsACoder force-pushed the lauren/latx-config-build-guards branch from bdb494e to 695ab19 Compare July 24, 2026 00:27
@LaurenIsACoder
LaurenIsACoder marked this pull request as ready for review July 28, 2026 01:16
@LaurenIsACoder
LaurenIsACoder merged commit 492acc0 into lat-opensource:master Jul 28, 2026
11 checks passed
@LaurenIsACoder
LaurenIsACoder deleted the lauren/latx-config-build-guards branch July 28, 2026 01:16
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