vm_ctx_init_with_ranges(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’– vm_ctx_init_with_ranges β€” a Kernel API Manual moment πŸ’–

okay so bestie, welcome to vm_ctx_init_with_ranges(9) from the Kernel API Manual β€” yes the whole page is literally named after the function, main character energy fr fr. she's a 9 (kernel API section) and she's here to set up virtual memory for a context. let's get into it ✨


🌸 NAME 🌸

vm_ctx_init_with_ranges β€” initialize virtual memory for context. that's it, that's the vibe πŸ’…


πŸŽ€ SYNOPSIS πŸŽ€

int vm_ctx_init_with_ranges (struct hl_ctx *ctx , u64 host_range_start ,
u64 host_range_end , u32 host_page_size , u64 host_huge_range_start ,
u64 host_huge_range_end , u32 host_huge_page_size , u64 dram_range_start
, u64 dram_range_end , u32 dram_page_size );

look at all those parameters. she's thorough. she's detailed. she does NOT do one-liners 🫢


✨ ARGUMENTS ✨

time to meet the whole cast, no skips:

  • ctx β€” pointer to the habanalabs context structure. the main character, everyone else is supporting πŸ’œ
  • host_range_start β€” host virtual addresses range start. where the host range begins, periodt.
  • host_range_end β€” host virtual addresses range end. where it stops, so you know πŸ¦‹
  • host_page_size β€” host page size. the size. of the host pages. iconic.
  • host_huge_range_start β€” host virtual addresses range start for memory allocated with huge pages. yes, huge. she's big, she's bold, she has her own range 😭
  • host_huge_range_end β€” host virtual addresses range end for memory allocated with huge pages. huge range ends here bestie 🌸
  • host_huge_page_size β€” host huge page size. the size of the huge ones, obviously πŸ’…
  • dram_range_start β€” dram virtual addresses range start. now we're in DRAM territory πŸ”₯
  • dram_range_end β€” dram virtual addresses range end. DRAM range wraps up here.
  • dram_page_size β€” dram page size. last one, and she ate ⭐

πŸ¦‹ DESCRIPTION πŸ¦‹

okay so this function initializes the following, and ngl the list is giving "getting ready for the group chat" energy:

  • MMU for context. she's setting up the memory management unit for the context, as one does πŸ‘‘
  • Virtual address to area descriptor hashtable. hashtable! very organized, very slay 🌈
  • Virtual block list of available virtual memory. cataloging what VM is free, iykyk.

that's literally all three things. no more, no less. she knows her job and she does it πŸ’–


πŸ’€ SEE ALSO πŸ’€

grab a snack, this is a long one β€” but every single reference is here because we do NOT gatekeep:

kernel file: ./drivers/accel/habanalabs/common/memory.c

dma_map_host_va(9), dma_unmap_host_va(9), dram_pg_pool_do_release(9), free_phys_pg_pack(9), free_device_memory(9), clear_va_list_locked(9), print_va_list_locked(9), merge_va_blocks_locked(9), add_va_block_locked(9), add_va_block(9), is_hint_crossing_range(9), get_va_block(9), hl_get_va_range_type(9), hl_unreserve_va_block(9), init_phys_pg_pack_from_userptr(9), map_phys_pg_pack(9), unmap_phys_pg_pack(9), map_device_va(9), unmap_device_va(9), hl_hw_block_mmap(9), export_dmabuf_from_addr(9), allocate_timestamps_buffers(9), hl_pin_host_memory(9), hl_userptr_delete_list(9), hl_userptr_is_pinned(9), va_range_init(9), va_range_fini(9), hl_vm_ctx_fini(9), hl_vm_init(9), hl_vm_fini(9), hl_hw_block_mem_init(9), hl_hw_block_mem_fini(9)

go read them. all of them. I'll wait 🫢


and that's the whole page, bestie ✨ she's sourced from ./drivers/accel/habanalabs/common and dated October 2026 β€” stamped for your reading pleasure by the Kernel API Manual. mwah πŸ’‹

πŸ“¦ where this page comes from