The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: Alex Williamson <alex@shazbot.org>
Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org
Subject: Re: [PATCH v3] vfio/pci: expose ACPI _ROM through a device region
Date: Thu, 3 Dec 2026 18:06:34 -0500	[thread overview]
Message-ID: <20261203173520-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <20261203145709.29c06f89@shazbot.org>

On Thu, Dec 03, 2026 at 02:57:09PM -0700, Alex Williamson wrote:
> On Thu, 3 Dec 2026 09:35:01 -0500
> "Michael S. Tsirkin" <mst@redhat.com> wrote:
> > +void vfio_pci_register_acpi_rom(struct vfio_pci_core_device *vdev)
> > +{
> > +	acpi_handle handle = ACPI_HANDLE(&vdev->pdev->dev);
> > +	union acpi_object args[] = {
> > +		{ .integer = { .type = ACPI_TYPE_INTEGER } },
> > +		{ .integer = { .type = ACPI_TYPE_INTEGER, .value = SZ_4K } },
> > +	};
> > +	struct acpi_object_list params = { ARRAY_SIZE(args), args };
> > +	size_t size = 0, capacity = 0;
> > +	void *rom = NULL;
> > +	acpi_handle method;
> > +	int ret = -EIO;
> > +
> > +	if (!handle || ACPI_FAILURE(acpi_get_handle(handle, "_ROM", &method)))
> > +		return;
> > +
> > +	/*
> > +	 * Some firmware requires 4 KiB-aligned requests. Snapshot the image
> > +	 * at open so reads never invoke AML and the size and contents agree.
> > +	 */
> 
> Can you cite some firmware that has this requirement?  I don't want to
> come back to this in the future without an example of firmware that
> imposes this requirement.

Yes, it's in nouveau history:

In 2012 Ben Skeggs changed the initial ACPI ROM header probe
from _ROM(0, 3) to _ROM(0, 4096) for firmware compatibility.

https://github.com/torvalds/linux/commit/d1626a965141



> That alone also doesn't feel like it justifies allocating up to 16MB of
> kernel memory and holding it for the whole user session.

16M of virtually contiguos memory a problem?

Well I started with reading exactly what userspace requested.  I then
got a comment that userspace reading byte by byte will invoke 4K ACPI
calls per page. So now I am caching it all.  It is simple, at least.

>  We can
> perform reads with 4K alignment and return short reads to get the user
> onto the alignment we require.
> 
> Sashiko notes a couple issues, particularly in this method of sizing
> the ROM.  Why shouldn't we walk the ROM image chain read through _ROM
> to determine the size, save only that size in the init phase, then do
> aligned reads (if necessary), on demand as the user accesses?

I don't mind, but didn't you worry about malformed firmware earlier?
Something about firmware burners?


> Aside from the alignment, and the device specific region proposed here,
> I basically proposed those mechanics in
> https://lore.kernel.org/all/20261015112719.20d08b4c@shazbot.org/

You actually complained about "letting the user so easily
monopolize the ACPI interpreter lock". If we invoke ACPI
in response to userspace system calls we do exactly that.
Confused.

> Architecturally I'm fine with the device specific region approach.
> 
> > diff --git a/include/uapi/linux/vfio.h b/include/uapi/linux/vfio.h
> > index e41437fa17ad0..0d77f860020e9 100644
> > --- a/include/uapi/linux/vfio.h
> > +++ b/include/uapi/linux/vfio.h
> > @@ -345,6 +345,15 @@ struct vfio_region_info_cap_type {
> >  #define VFIO_REGION_TYPE_GFX                    (1)
> >  #define VFIO_REGION_TYPE_CCW			(2)
> >  #define VFIO_REGION_TYPE_MIGRATION_DEPRECATED   (3)
> > +#define VFIO_REGION_TYPE_ACPI			(4)
> > +
> > +/* sub-types for VFIO_REGION_TYPE_ACPI */
> > +/*
> > + * The device firmware's ACPI _ROM image, when available. The region size is
> > + * the exact image length in bytes. This region supports read() and pread()
> > + * only. It is independent of the PCI expansion ROM region.
> > + */
> > +#define VFIO_REGION_SUBTYPE_ACPI_ROM		(1)
> >  
> >  /* sub-types for VFIO_REGION_TYPE_PCI_* */
> >
> 
> Note that the sub-type definitions are in the same order as the types
> are defined.  This jumps the line.  Thanks,
> 
> Alex

      reply	other threads:[~2026-12-03 23:06 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-03 14:35 [PATCH v3] vfio/pci: expose ACPI _ROM through a device region Michael S. Tsirkin
2026-12-03 21:57 ` Alex Williamson
2026-12-03 23:06   ` Michael S. Tsirkin [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=20261203173520-mutt-send-email-mst@kernel.org \
    --to=mst@redhat.com \
    --cc=alex@shazbot.org \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /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