Skip to content

Traps tlb test kernel page new#32

Open
stzahi1 wants to merge 3 commits into
masterfrom
traps_tlb_test_kernel_page_new
Open

Traps tlb test kernel page new#32
stzahi1 wants to merge 3 commits into
masterfrom
traps_tlb_test_kernel_page_new

Conversation

@stzahi1
Copy link
Copy Markdown
Contributor

@stzahi1 stzahi1 commented May 25, 2026

No description provided.

stzahi1 and others added 3 commits May 25, 2026 04:44
Signed-off-by: Tzahi Sabo <stzahi@qti.qualcomm.com>
scripts/Makefile.coverage extracts the per-ARCHV test list with the
perl filter s/^\s*\#.*//; which only removes comments that start at
the beginning of a line. testlist.v81 line 59 has a trailing comment:

    ./kernel/traps/tlb/test  #FIXME: needs to adapt to ...

so SUBDIRS ended up containing the literal tokens "#FIXME:", "needs",
"to", etc. The colon in "#FIXME:" then leaked through the patsubst
on line 17 into a prerequisite of "tst:", which make parses as a
static-pattern rule and rejects with:

    scripts/Makefile.coverage:27: *** multiple target patterns. Stop.

This broke every target in the file, including \`make clean\` /
\`make covclean\`, because the error fires at parse time.

Drop the ^ anchor so the regex strips inline comments as well as
full-line ones.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Signed-off-by: Tzahi Sabo <stzahi@qti.qualcomm.com>
The test had two latent bugs that the recent V81 enable
(commit 5d13ae7e) exposed.

1. Hardcoded JTLB layout. The test passed last_tlb_index=125 and
   tlb_size=128 to H2K_kg_init, and used 64/63/65 as the allocator
   floor. These values only match a 128-entry JTLB. V81 reports
   tlb_size=192 via CFG_TABLE_JTLB_SIZE, so the synthesized kg state
   diverged from the actual hardware and the allocator's count
   assertion failed.

2. (u32_t)&H2K_KERNEL_NPAGES is meaningless for STANDALONE tests.
   stake/consts.pl computes kernel_npages assuming the ELF is linked
   at H2K_LINK_ADDR (the real kernel layout). For a STANDALONE test
   ELF that lives elsewhere, the formula wraps around -- on V81 it
   produced 0xffffffffffffc043, blowing up any derivation that used
   it.

Fix:

- Read tlb_size at runtime from H2K_cfg_table(CFG_TABLE_JTLB_SIZE).
- Pick a fixed TEST_PINNED_COUNT=2 (synthetic test fixture; the test
  has no kernel image to map, so the production npages+device+angel
  formula doesn't apply). last_tlb_index = tlb_size - 2 - 1.
- Replace every "64" allocator-floor literal with (tlb_size -
  ALLOC_WINDOW), where ALLOC_WINDOW=64 is the architectural width
  of pinned_tlb_mask. Off-by-one neighbors become ALLOC_WINDOW +/- 1.
- Generalize test_readwriteprobe's index range from the hardcoded
  32..96 to (tlb_size - 3*ALLOC_WINDOW/2)..(tlb_size - ALLOC_WINDOW/2).
  This is byte-identical to 32..96 for tlb_size=128 (preserving
  legacy v60/v5/v4 behavior) and now actually crosses the allocator
  boundary on V81.
- Replace the mask-bit-width literal 0x3F with (ALLOC_WINDOW - 1).
- Replace the page-shift literal 12 in VALID_VA with PAGE_BITS.
- Name (32+20) as TLB_ASID_SHIFT 52 with a pointer to tlbfmt.h.
- Promote the pinned-slot marker base 0x01234567cafe0000ULL to
  PINNED_MARKER_BASE.
- Add header comments to TLBCONST, VALID_VPN, ASID, VALID_TLB_ENTRY,
  TEST_PINNED_COUNT, ALLOC_WINDOW explaining what each value
  represents and why it was chosen.
- Drop the now-obsolete FIXME from scripts/testlist.v81 -- the test
  now adapts to any tlb_size, so the "needs to adapt to different
  kernel page size/count" caveat no longer applies.

Include changes:
- Add <cfg_table.h> for H2K_cfg_table and CFG_TABLE_JTLB_SIZE. Skip
  <symbols.h>: it declares H2K_KERNEL_NPAGES (no longer needed) and
  H2K_ALLOC_HEAP_SIZE, the latter of which collides with the test
  build's -DH2K_ALLOC_HEAP_SIZE CFLAG.

Verified: v81/opt and v81/ref both pass 92 tests. The math reduces
to the original 32..96 range for tlb_size=128, so the v60/v5/v4
testlist entries are unaffected.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Signed-off-by: Tzahi Sabo <stzahi@qti.qualcomm.com>
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