Thank you for your contribution! Sashiko AI review found 1 potential issue(s) 
to consider:
- [High] iommu/hyperv: always-false NULL check on iommu_init in hyperv_init()
--

commit 4f2b2cb5f11d745054ce781b3dfdb1a7f85d3560
Author: Mukesh R <[email protected]>

iommu/hyperv: Only call pviommu init on non-root VMs

This commit renames hv_iommu_init() to hv_pviommu_init() and updates
hyperv_init() so that x86_init.iommu.iommu_init is only assigned on non-root
Hyper-V VMs when x86_init.iommu.iommu_init is not already set.

> diff --git a/arch/x86/hyperv/hv_init.c b/arch/x86/hyperv/hv_init.c
> index b90e6f4875335..18651c38dba3e 100644
> --- a/arch/x86/hyperv/hv_init.c
> +++ b/arch/x86/hyperv/hv_init.c
> @@ -580,7 +580,8 @@ void __init hyperv_init(void)
>       x86_init.timers.setup_percpu_clockev = hv_stimer_setup_percpu_clockev;
>  
>  #ifdef CONFIG_HYPERV_PVIOMMU
> -     x86_init.iommu.iommu_init = hv_iommu_init;
> +     if (!hv_root_partition() && x86_init.iommu.iommu_init == NULL)
> +             x86_init.iommu.iommu_init = hv_pviommu_init;

[Severity: High]
Can x86_init.iommu.iommu_init == NULL ever evaluate to true here?

In arch/x86/kernel/x86_init.c, x86_init.iommu.iommu_init is statically
initialized to iommu_init_noop rather than NULL:

    static int __init iommu_init_noop(void) { return 0; }
    ...
    struct x86_init_ops x86_init __initdata = {
        ...
        .iommu = {
            .iommu_init         = iommu_init_noop,
        },
        ...
    };

And in arch/x86/kernel/pci-dma.c, pci_iommu_init() invokes
x86_init.iommu.iommu_init() unconditionally without a NULL check.

Because x86_init.iommu.iommu_init defaults to iommu_init_noop (or is
overwritten by an earlier hardware IOMMU detector in pci_iommu_alloc()) and
is never set to NULL, doesn't checking x86_init.iommu.iommu_init == NULL in
hyperv_init() prevent hv_pviommu_init from ever being registered on non-root
guest VMs?

-- 
Sashiko AI review ยท 
https://sashiko.dev/#/patchset/[email protected]?part=4

Reply via email to