MCPcopy Create free account
hub / github.com/cloud-hypervisor/cloud-hypervisor / create_madt

Method create_madt

vmm/src/cpu.rs:1697–1892  ·  view source on GitHub ↗
(&self, #[cfg(target_arch = "aarch64")] vgic: Arc<Mutex<dyn Vgic>>)

Source from the content-addressed store, hash-verified

1695
1696 #[allow(clippy::needless_pass_by_value)]
1697 pub fn create_madt(&self, #[cfg(target_arch = "aarch64")] vgic: Arc<Mutex<dyn Vgic>>) -> Sdt {
1698 use crate::acpi;
1699 // This is also checked in the commandline parsing.
1700 assert!(self.config.boot_vcpus <= self.config.max_vcpus);
1701
1702 let mut madt = Sdt::new(*b"APIC", 44, 5, *b"CLOUDH", *b"CHMADT ", 1);
1703 #[cfg(target_arch = "x86_64")]
1704 {
1705 madt.write(36, arch::layout::APIC_START.0);
1706
1707 for cpu in 0..self.config.max_vcpus {
1708 let x2apic_id = get_x2apic_id(cpu, self.get_vcpu_topology());
1709
1710 let lapic = LocalX2Apic {
1711 r#type: acpi::ACPI_X2APIC_PROCESSOR,
1712 length: 16,
1713 processor_id: cpu,
1714 apic_id: x2apic_id,
1715 flags: if cpu < self.config.boot_vcpus {
1716 1 << MADT_CPU_ENABLE_FLAG
1717 } else {
1718 0
1719 } | (1 << MADT_CPU_ONLINE_CAPABLE_FLAG),
1720 _reserved: 0,
1721 };
1722 madt.append(lapic);
1723 }
1724
1725 madt.append(Ioapic {
1726 r#type: acpi::ACPI_APIC_IO,
1727 length: 12,
1728 ioapic_id: 0,
1729 apic_address: arch::layout::IOAPIC_START.0 as u32,
1730 gsi_base: 0,
1731 ..Default::default()
1732 });
1733
1734 madt.append(InterruptSourceOverride {
1735 r#type: acpi::ACPI_APIC_XRUPT_OVERRIDE,
1736 length: 10,
1737 bus: 0,
1738 source: 4,
1739 gsi: 4,
1740 flags: 0,
1741 });
1742 }
1743
1744 #[cfg(target_arch = "aarch64")]
1745 {
1746 use arch::layout::{GIC_V2M_COMPATIBLE, GICV2M_SPI_BASE, GICV2M_SPI_NUM};
1747
1748 /* Notes:
1749 * Ignore Local Interrupt Controller Address at byte offset 36 of MADT table.
1750 */
1751
1752 // See section 5.2.12.14 GIC CPU Interface (GICC) Structure in ACPI spec.
1753 for cpu in 0..self.config.boot_vcpus {
1754 let vcpu = &self.vcpus[cpu as usize];

Callers 2

create_acpi_tables_tdxFunction · 0.80

Calls 6

newFunction · 0.85
get_x2apic_idFunction · 0.85
get_vcpu_topologyMethod · 0.80
get_mpidrMethod · 0.80
writeMethod · 0.45
msi_compatibilityMethod · 0.45

Tested by

no test coverage detected