Skip to content

booter: build a self-owned LINEAR TLB for the bootvm ASID#81

Open
stzahi1 wants to merge 1 commit into
masterfrom
booter_linear_tlb
Open

booter: build a self-owned LINEAR TLB for the bootvm ASID#81
stzahi1 wants to merge 1 commit into
masterfrom
booter_linear_tlb

Conversation

@stzahi1

@stzahi1 stzahi1 commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Replace the kernel's OFFSET translation with a LINEAR table the booter builds and installs itself via h2_vmtrap_newmap(), covering its own footprint (image + heap + stack) sized from BOOT_TLB_PGSIZE and PAGE_BITS.

Add a GUEST_WINDOW_PAGES-sized (16M-page) window starting at H2K_GUEST_START, since load_vm() accesses guest physical memory directly through the booter's own map and needs coverage beyond the booter's footprint entries.

@github-actions github-actions Bot added the untested Mark untested PRs label Jul 20, 2026
Replace the kernel's OFFSET translation with a LINEAR table the
booter builds and installs itself via h2_vmtrap_newmap(), covering
its own footprint (image + heap + stack) sized from BOOT_TLB_PGSIZE
and PAGE_BITS.

Add a GUEST_WINDOW_PAGES-sized (16M-page) window starting at
H2K_GUEST_START, since load_vm() accesses guest physical memory
directly through the booter's own map and needs coverage beyond the
booter's footprint entries.

Signed-off-by: Tzahi Sabo <stzahi@qti.qualcomm.com>
@stzahi1
stzahi1 force-pushed the booter_linear_tlb branch from 2ef6dea to e7a876e Compare July 20, 2026 12:45
Comment thread booter/booter.c
Comment on lines +598 to +615
// Guest window: maps H2K_GUEST_START upward in 16M pages so the booter can read/write guest
// physical memory directly (memcpy/read/memset in load_vm()) the same way OFFSET translation
// allowed before this table replaced it.
va = H2K_GUEST_START >> PAGE_BITS;
pa = ((unsigned long long)H2K_GUEST_START + __boot_net_phys_offset__) >> PAGE_BITS;

for (i = 0; i < guest_npages; i++) {
table[npages + i].raw = 0ULL;
table[npages + i].ppn = pa;
table[npages + i].cccc = BOOT_CACHE_ATTR;
table[npages + i].xwru = URWX;
table[npages + i].vpn = va;
table[npages + i].size = SIZE_16M;

va += 1 << (SIZE_16M * 2); // advance by one 16M page's worth of page-numbers
pa += 1 << (SIZE_16M * 2);
}
table[npages + guest_npages].raw = 0ULL; // end marker (zero raw entry terminates the table)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is unnecessary. While loading the guest image these entries will have to be modified and the translations re-registered anyway, so just zero them here.

@stzahi1 stzahi1 Jul 22, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having zero will break the assumption that 0 row indicates last row. Are you suggesting that the entries will not be added to the linear table until the guest image is being koaded?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's exactly the point. 0 is an invalid entry and tells the tlb miss handler to stop searching, which is what you want if the entries are invalid.
As a matter of fact you shouldn't allocate them at all here; just realloc() at the time you need them, i.e. for loading the guest.

Comment thread booter/booter.c
@bryanb-h2

Copy link
Copy Markdown
Contributor

Did you look at add_linear_trans() to see if it could be repurposed for this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

untested Mark untested PRs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants