get_bar_size(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… get_bar_size β€” Get the address space consumed by a BAR

okay so bestie, this page is get_bar_size(9) β€” that's the kernel API manual, and yes the manual name is literally get_bar_size too, so we're all caught up πŸ’–. It lives in the kernel API docs and it's honestly kind of a tiny icon.


✨ SYNOPSIS ✨

u64 get_bar_size (u64 bar_val );

that's it. one function, one argument, one u64 coming back at you. obsessed πŸŽ€


🫢 ARGUMENTS 🫢

  • bar_val β€” the value that a BAR handed back at you after -1 was written to it. that's the whole vibe check: write -1, see what it says, pass that in here πŸ¦‹

🌸 DESCRIPTION 🌸

so what this function does is it returns the size of the BAR, rounded up to 1 page. and ngl the rounding-up is not a stylistic choice, it's literally required β€” because the hypervisor's page table entry that maps the BAR into the VM can't specify an offset within a page. like, the hardware said no offsets, and we respect the hardware πŸ’€

and here's the invariant you need to keep in your head, bestie, write it on your hand: the hypervisor must place any BARs of smaller than page length at the beginning of a page. that's the rule. periodt. πŸ‘‘


⭐ RETURN ⭐

size in bytes of the consumed MMIO space. that's the answer, that's the number, that's the tea β˜•


πŸ’œ SEE ALSO πŸ’œ

okay this list is long so buckle up, it's giving "the whole pci-hyperv.c friend group" honestly 😭

kernel file ./drivers/pci/controller/pci-hyperv.c, plus:

like I said. the whole friend group. no cap 🌈


fr fr bestie, if you're poking at BAR sizing in the hv pci frontend, you're in the right neighborhood β€” just remember the page-rounding rule and you're golden πŸ’…βœ¨

and that's the page! πŸ¦‹ this one came out of ./drivers/pci/controller and it's dated October 2026, with the page itself being get_bar_size(9) β€” mwah, go read the rest of the kernel API manual, ily, bye πŸŽ€πŸ’–πŸŒΈ

πŸ“¦ where this page comes from