All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Mukesh R" <mrathor@linux.microsoft.com>, linux-hyperv@vger.kernel.org
Subject: Re: [PATCH V3 4/5] iommu/hyperv: Only call pviommu init on non-root VMs
Date: Tue, 03 Nov 2026 02:57:52 +0000	[thread overview]
Message-ID: <sashiko-outbox-194478@kernel.org> (raw)
In-Reply-To: <20261103025150.3192119-5-mrathor@linux.microsoft.com>

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 <mrathor@linux.microsoft.com>

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/20261103025150.3192119-1-mrathor@linux.microsoft.com?part=4

  reply	other threads:[~2026-11-03  2:57 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-03  2:51 [PATCH V3 0/5] Hyper-V: root VM iommu kernel only driver Mukesh R
2026-11-03  2:51 ` [PATCH V3 1/5] mshv: Add gfp flags to deposit memory logic Mukesh R
2026-11-03  2:51 ` [PATCH V3 2/5] PCI: hv: Export hv_build_devid_type_pci() and change return type Mukesh R
2026-11-03  2:51 ` [PATCH V3 3/5] mshv: Import data structs around device domains from hyperv headers Mukesh R
2026-11-03  3:17   ` Easwar Hariharan
2026-11-03  2:51 ` [PATCH V3 4/5] iommu/hyperv: Only call pviommu init on non-root VMs Mukesh R
2026-11-03  2:57   ` sashiko-bot [this message]
2026-11-03  2:51 ` [PATCH V3 5/5] x86/hyperv: Implement root partition IOMMU kernel only driver Mukesh R
2026-11-03  3:25   ` sashiko-bot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=sashiko-outbox-194478@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-hyperv@vger.kernel.org \
    --cc=mrathor@linux.microsoft.com \
    --cc=sashiko-reviews@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.