get_bar_size(9)
π 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-1was 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:
struct hv_msi_desc(9)struct hv_msi_desc2(9)struct tran_int_desc(9)hv_irq_retarget_interrupt(9)hv_pci_generic_compl(9)devfn_to_wslot(9)wslot_to_devfn(9)_hv_pcifront_read_config(9)_hv_pcifront_write_config(9)hv_pcifront_read_config(9)hv_pcifront_write_config(9)hv_pci_read_config_compl(9)hv_read_config_block(9)hv_pci_write_config_compl(9)hv_write_config_block(9)hv_register_block_invalidate(9)hv_msi_free(9)hv_compose_msi_msg(9)hv_pcie_init_irq_domain(9)survey_child_resources(9)prepopulate_bars(9)create_root_hv_pci_bus(9)q_resource_requirements(9)new_pcichild_device(9)get_pcichild_wslot(9)pci_devices_present_work(9)hv_pci_start_relations_work(9)hv_pci_devices_present(9)hv_pci_devices_present2(9)hv_eject_device_work(9)hv_pci_eject_device(9)hv_pci_onchannelcallback(9)hv_pci_protocol_negotiation(9)hv_pci_free_bridge_windows(9)hv_pci_allocate_bridge_windows(9)hv_allocate_config_window(9)hv_pci_enter_d0(9)hv_pci_query_relations(9)hv_send_resources_allocated(9)hv_send_resources_released(9)hv_pci_probe(9)hv_pci_remove(9)
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
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms