mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andrea Parri <parri.andrea@gmail.com>
To: Alex Williamson <alex@shazbot.org>, Ankit Agrawal <ankita@nvidia.com>
Cc: Andrea Parri <parri.andrea@gmail.com>,
	Jason Gunthorpe <jgg@ziepe.ca>, Yishai Hadas <yishaih@nvidia.com>,
	Shameer Kolothum <skolothumtho@nvidia.com>,
	Kevin Tian <kevin.tian@intel.com>,
	Jiaqi Yan <jiaqiyan@google.com>,
	kvm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] vfio/nvgrace-gpu: Skip PFN registration for empty memory regions
Date: Mon, 12 Oct 2026 15:58:41 +0200	[thread overview]
Message-ID: <20261012135842.152928-1-parri.andrea@gmail.com> (raw)
In-Reply-To: <20261009135203.33f3806d@shazbot.org>

On Fri, Oct 09, 2026 at 01:52:03PM -0600, Alex Williamson wrote:
> It seems to me though that the reason this bug exists is because
> nvgrace_gpu_pci_core_ops.open_device is trying to handle both real
> nvgrace devices, where usemem.memlength cannot be zero, alongside
> non-nvgrace devices where that can easily be forgotten.
>
> The above patches the failure of that model, but maybe the better
> approach is to split them such that the failures like this cannot
> occur, ie. a core-only wrapper that just calls vfio_pci_core_enable()
> and vfio_pci_core_finish_enable(), or some other refactor such that the
> core-only path never handles the nvdev.  Thanks,

Agreed, that's a better fix.  For v2 I have:

  1/2 gives nvgrace_gpu_pci_core_ops its own open_device, which only
      calls vfio_pci_core_enable() and vfio_pci_core_finish_enable(),
      to pair with vfio_pci_core_close_device().  The usemem.memlength
      guards from v1 are gone.

  2/2 drops the remaining usemem.memlength check in
      nvgrace_gpu_open_device(), since only devices with the ACPI
      memory properties reach it now.  Not for stable.

One visible change in fallback mode: open no longer fails when BAR0
cannot be mapped, the same as vfio-pci.  BAR0 was only mapped there for
the readiness check, which fallback mode never runs.  Ankit, please
shout if the fallback path relies on anything else from
nvgrace_gpu_open_device().

With 1/2 the reproducer from v1 (QEMU cxl-type3, fallback mode) no
longer hits the -EBUSY on reopen or the KASAN use-after-free after
unbind.

I'll wait a few days for Ankit's comments before posting v2.

Thanks,
  Andrea

      reply	other threads:[~2026-10-12 13:58 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-25 16:10 Andrea Parri
2026-10-09 19:52 ` Alex Williamson
2026-10-12 13:58   ` Andrea Parri [this message]

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=20261012135842.152928-1-parri.andrea@gmail.com \
    --to=parri.andrea@gmail.com \
    --cc=alex@shazbot.org \
    --cc=ankita@nvidia.com \
    --cc=jgg@ziepe.ca \
    --cc=jiaqiyan@google.com \
    --cc=kevin.tian@intel.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=skolothumtho@nvidia.com \
    --cc=yishaih@nvidia.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®