Skip to content

LATX, fix: Handle mixed 16K writes for Minke - #425

Open
ganjue66da wants to merge 2 commits into
lat-opensource:masterfrom
ganjue66da:codex/minke-16k-write-checks
Open

LATX, fix: Handle mixed 16K writes for Minke#425
ganjue66da wants to merge 2 commits into
lat-opensource:masterfrom
ganjue66da:codex/minke-16k-write-checks

Conversation

@ganjue66da

Copy link
Copy Markdown
Contributor

Motivation

Minke can issue writes that cross or mix 16K guest-page boundaries. The existing fast checks did not consistently route those writes through the path that maintains translated-code and shadow-memory coherence.

Changes

  • Reduce redundant 16K write checks.
  • Add the missing mixed-16K write handling required by Minke.

Validation

  • ninja -C build32 latx-i386
  • ninja -C build64 latx-x86_64
  • Atomic lock stress test passed in normal mode and with LATX_MT=1.
  • Both runs completed 4000000 operations with the expected counter value.

Scope

The two commits cover the same 16K write-checking path: the first removes redundant checks and the second fixes the Minke boundary case.

The LATX_MT compatibility path walks the page-flags interval tree for
every instrumented memory access.  That is too expensive for
applications which need exact guest 4K write checks on a 16K host.

Allocate compact byte tables for guest 4K writability and mixed host
16K pages only after LATX_MT is enabled.  Generated stores normally
need one table lookup and consult the exact 4K entry only for mixed host
pages.  Disabled configurations retain no large tables or CPU state
pointers and emit no additional guest memory checks.

Do not enable LATX_MT automatically.  Default translations remain
uninstrumented, while affected applications can opt in explicitly.

Tests:
- default and LATX_MT=1 atomic-lock-stress-test
- LATX_MT=1 Minke.MI.Organ.exe reached the rendered login window

Signed-off-by: Wenqiang Wei <weiwenqiang@mail.ustc.edu.cn>
Minke.MI.Organ.exe uses a fixed Wine helper and small generated code
mappings whose stores may cross guest 4K permission boundaries on a
16K host.  Without precise checks, a write can miss the fault needed to
create a shadow page and the application fails during startup.

Add the explicit LATX_MINKE_16K_PAGE_CHECK option.  On a 16K host it is
accepted only for Minke.MI.Organ.exe, allocates the application TB map,
and instruments the fixed helper page and small executable mappings
recorded by mmap and mprotect.  Other applications and disabled
configurations remain on the normal uninstrumented path.

This avoids the global LATX_MT cost while retaining the precise write
fault where the application requires it.

Tests:
- 16K host: selective checks reached the rendered login window with
  LATX_MT=0
- 4K host: default and explicit-option atomic-lock-stress-test

Signed-off-by: Wenqiang Wei <weiwenqiang@mail.ustc.edu.cn>
@ganjue66da
ganjue66da force-pushed the codex/minke-16k-write-checks branch from 9159bd7 to 2ee0fee Compare August 25, 2026 03:55
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.

1 participant