RE: [PATCH V5 2/3] HYPERV/IOMMU: Add Hyper-V stub IOMMU driver

From: Michael Kelley
Date: Fri Feb 22 2019 - 10:58:50 EST


From: Tianyu.Lan@xxxxxxxxxxxxx <Tianyu.Lan@xxxxxxxxxxxxx> Sent: Friday, February 22, 2019 4:12 AM
>
> On the bare metal, enabling X2APIC mode requires interrupt remapping
> function which helps to deliver irq to cpu with 32-bit APIC ID.
> Hyper-V doesn't provide interrupt remapping function so far and Hyper-V
> MSI protocol already supports to deliver interrupt to the CPU whose
> virtual processor index is more than 255. IO-APIC interrupt still has
> 8-bit APIC ID limitation.
>
> This patch is to add Hyper-V stub IOMMU driver in order to enable
> X2APIC mode successfully in Hyper-V Linux guest. The driver returns X2APIC
> interrupt remapping capability when X2APIC mode is available. Otherwise,
> it creates a Hyper-V irq domain to limit IO-APIC interrupts' affinity
> and make sure cpus assigned with IO-APIC interrupt have 8-bit APIC ID.
>
> Define 24 IO-APIC remapping entries because Hyper-V only expose one
> single IO-APIC and one IO-APIC has 24 pins according IO-APIC spec(
> https://pdos.csail.mit.edu/6.828/2016/readings/ia32/ioapic.pdf).
>
> Signed-off-by: Lan Tianyu <Tianyu.Lan@xxxxxxxxxxxxx>
> ---
> Change since v4:
> - Fix the loop of scan cpu's APIC id
>
> Change since v3:
> - Make Hyper-V IOMMU as Hyper-V default driver
> - Fix hypervisor_is_type() input parameter
> - Check possible cpu numbers during scan 0~255 cpu's apic id.
>
> Change since v2:
> - Improve comment about why save IO-APIC entry in the irq chip data.
> - Some code improvement.
> - Improve statement in the IOMMU Kconfig.
>
> Change since v1:
> - Remove unused pr_fmt
> - Make ioapic_ir_domain as static variable
> - Remove unused variables cfg and entry in the hyperv_irq_remapping_alloc()
> - Fix comments

Reviewed-by: Michael Kelley <mikelley@xxxxxxxxxxxxx>