All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alex Williamson <alex@shazbot.org>
To: Tomita Moeko <tomitamoeko@gmail.com>
Cc: qemu-devel@nongnu.org, "Cédric Le Goater" <clg@redhat.com>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	"K S Maan" <kirandeepmaan45@gmail.com>,
	alex@shazbot.org
Subject: Re: [PATCH v2 2/7] hw/pci: Skip EFI option ROM in pci_patch_ids()
Date: Tue, 9 Jun 2026 09:36:01 -0600	[thread overview]
Message-ID: <20260609093601.59aa6fde@shazbot.org> (raw)
In-Reply-To: <20260608134559.23971-3-tomitamoeko@gmail.com>

On Mon,  8 Jun 2026 21:45:53 +0800
Tomita Moeko <tomitamoeko@gmail.com> wrote:

> pci_patch_ids() patches the checksum at the reserved 0x06 byte, but
> for EFI option ROMs the 32 bits at 0x04 are the EFI signature and
> must be 0x00000EF1. Since OVMF does not check vendor/device IDs in
> the PCIR header or the checksum, skip patching for EFI ROMs.
> 
> Reported-by: K S Maan <kirandeepmaan45@gmail.com>
> Signed-off-by: Tomita Moeko <tomitamoeko@gmail.com>
> ---
>  hw/pci/pci.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/hw/pci/pci.c b/hw/pci/pci.c
> index 742917f79d..eb10e586d5 100644
> --- a/hw/pci/pci.c
> +++ b/hw/pci/pci.c
> @@ -2521,6 +2521,11 @@ static void pci_patch_ids(PCIDevice *pdev, uint8_t *ptr, uint32_t size)
>          return;
>      }
>  
> +    /* OVMF won't check IDs in PCIR header, skip EFI roms */
> +    if (pci_get_byte(ptr + pcir_offset + 0x14) == 0x03) {
> +        return;
> +    }
> +

Just above this we have the sanity testing:

    if (pcir_offset + 8 >= size || memcmp(ptr + pcir_offset, "PCIR", 4)) {
        trace_pci_bad_pcir_offset(pcir_offset);
        return;
    }

+8 covers the vendor and device IDs, but now we're reaching deeper and
should extend the validation to match.  s/8/0x14/  Thanks,

Alex

>      vendor_id = pci_get_word(pdev->config + PCI_VENDOR_ID);
>      device_id = pci_get_word(pdev->config + PCI_DEVICE_ID);
>      rom_vendor_id = pci_get_word(ptr + pcir_offset + 4);



  reply	other threads:[~2026-06-09 15:36 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-08 13:45 [PATCH v2 0/7] vfio/igd: Fix garbled screen on IGD passthrough with legacy VBIOS Tomita Moeko
2026-06-08 13:45 ` [PATCH v2 1/7] hw/pci: Recalculate option ROM checksum before patching ID Tomita Moeko
2026-06-09 15:36   ` Alex Williamson
2026-06-08 13:45 ` [PATCH v2 2/7] hw/pci: Skip EFI option ROM in pci_patch_ids() Tomita Moeko
2026-06-09 15:36   ` Alex Williamson [this message]
2026-06-08 13:45 ` [PATCH v2 3/7] hw/pci: Introduce rom_need_patch_id flag in PCIDevice Tomita Moeko
2026-06-08 13:45 ` [PATCH v2 4/7] hw/pci: Promote pci_patch_ids() to public pci_rom_patch_ids() Tomita Moeko
2026-06-08 13:45 ` [PATCH v2 5/7] vfio/igd: Toggle rom_need_patch_id flag on IGD devices Tomita Moeko
2026-06-08 13:45 ` [PATCH v2 6/7] vfio/pci: Use pci_rom_patch_ids() for IGD ROM ID patching Tomita Moeko
2026-06-08 13:45 ` [PATCH v2 7/7] vfio/igd: Clear saved BDSM in legacy VBIOS ROM at load time Tomita Moeko
2026-06-09  3:05   ` K S Maan
2026-06-09  5:04     ` Cédric Le Goater
2026-06-09 11:55   ` Cédric Le Goater
2026-06-09 15:35   ` Alex Williamson
2026-06-09 15:46     ` Alex Williamson
2026-06-09 11:20 ` [PATCH v2 0/7] vfio/igd: Fix garbled screen on IGD passthrough with legacy VBIOS K S Maan

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=20260609093601.59aa6fde@shazbot.org \
    --to=alex@shazbot.org \
    --cc=clg@redhat.com \
    --cc=kirandeepmaan45@gmail.com \
    --cc=mst@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=tomitamoeko@gmail.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 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.