arch/x86/hyperv/irqdomain.c
Source file repositories/reference/linux-study-clean/arch/x86/hyperv/irqdomain.c
File Facts
- System
- Linux kernel
- Corpus path
arch/x86/hyperv/irqdomain.c- Extension
.c- Size
- 11267 bytes
- Lines
- 429
- Domain
- Architecture Layer
- Bucket
- arch/x86
- Inferred role
- Architecture Layer: exported/initcall integration point
- Status
- integration implementation candidate
Why This File Exists
CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/pci.hlinux/irq.hlinux/export.hlinux/irqchip/irq-msi-lib.hasm/mshyperv.h
Detected Declarations
struct rid_datafunction hv_map_interruptfunction hv_unmap_interruptfunction get_rid_cbfunction hv_build_devid_type_pcifunction hv_map_msi_interruptfunction entry_to_msi_msgfunction hv_irq_compose_msi_msgfunction hv_unmap_msi_interruptfunction hv_teardown_msi_irqfunction hv_init_dev_msi_infofunction hv_msi_domain_allocfunction hv_msi_domain_freefunction hv_create_pci_msi_domainfunction hv_unmap_ioapic_interruptfunction hv_map_ioapic_interruptexport hv_map_msi_interruptexport hv_unmap_ioapic_interruptexport hv_map_ioapic_interrupt
Annotated Snippet
struct rid_data {
struct pci_dev *bridge;
u32 rid;
};
static int get_rid_cb(struct pci_dev *pdev, u16 alias, void *data)
{
struct rid_data *rd = data;
u8 bus = PCI_BUS_NUM(rd->rid);
if (pdev->bus->number != bus || PCI_BUS_NUM(alias) != bus) {
rd->bridge = pdev;
rd->rid = alias;
}
return 0;
}
static union hv_device_id hv_build_devid_type_pci(struct pci_dev *pdev)
{
int pos;
union hv_device_id hv_devid;
struct rid_data data = {
.bridge = NULL,
.rid = PCI_DEVID(pdev->bus->number, pdev->devfn)
};
pci_for_each_dma_alias(pdev, get_rid_cb, &data);
hv_devid.as_uint64 = 0;
hv_devid.device_type = HV_DEVICE_TYPE_PCI;
hv_devid.pci.segment = pci_domain_nr(pdev->bus);
hv_devid.pci.bdf.bus = PCI_BUS_NUM(data.rid);
hv_devid.pci.bdf.device = PCI_SLOT(data.rid);
hv_devid.pci.bdf.function = PCI_FUNC(data.rid);
hv_devid.pci.source_shadow = HV_SOURCE_SHADOW_NONE;
if (data.bridge == NULL)
goto out;
/*
* Microsoft Hypervisor requires a bus range when the bridge is
* running in PCI-X mode.
*
* To distinguish conventional vs PCI-X bridge, we can check
* the bridge's PCI-X Secondary Status Register, Secondary Bus
* Mode and Frequency bits. See PCI Express to PCI/PCI-X Bridge
* Specification Revision 1.0 5.2.2.1.3.
*
* Value zero means it is in conventional mode, otherwise it is
* in PCI-X mode.
*/
pos = pci_find_capability(data.bridge, PCI_CAP_ID_PCIX);
if (pos) {
u16 status;
pci_read_config_word(data.bridge, pos + PCI_X_BRIDGE_SSTATUS,
&status);
if (status & PCI_X_SSTATUS_FREQ) {
/* Non-zero, PCI-X mode */
u8 sec_bus, sub_bus;
hv_devid.pci.source_shadow =
HV_SOURCE_SHADOW_BRIDGE_BUS_RANGE;
pci_read_config_byte(data.bridge, PCI_SECONDARY_BUS,
&sec_bus);
hv_devid.pci.shadow_bus_range.secondary_bus = sec_bus;
pci_read_config_byte(data.bridge, PCI_SUBORDINATE_BUS,
&sub_bus);
hv_devid.pci.shadow_bus_range.subordinate_bus = sub_bus;
}
}
out:
return hv_devid;
}
/*
* hv_map_msi_interrupt() - Map the MSI IRQ in the hypervisor.
* @data: Describes the IRQ
* @out_entry: Hypervisor (MSI) interrupt entry (can be NULL)
*
* Map the IRQ in the hypervisor by issuing a MAP_DEVICE_INTERRUPT hypercall.
*
* Return: 0 on success, -errno on failure
*/
Annotation
- Immediate include surface: `linux/pci.h`, `linux/irq.h`, `linux/export.h`, `linux/irqchip/irq-msi-lib.h`, `asm/mshyperv.h`.
- Detected declarations: `struct rid_data`, `function hv_map_interrupt`, `function hv_unmap_interrupt`, `function get_rid_cb`, `function hv_build_devid_type_pci`, `function hv_map_msi_interrupt`, `function entry_to_msi_msg`, `function hv_irq_compose_msi_msg`, `function hv_unmap_msi_interrupt`, `function hv_teardown_msi_irq`.
- Atlas domain: Architecture Layer / arch/x86.
- Implementation status: integration implementation candidate.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.