All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Roger Pau Monné" <roger.pau@citrix.com>
To: Thierry Escande <thierry.escande@vates.tech>
Cc: xen-devel@lists.xenproject.org, Jan Beulich <jbeulich@suse.com>,
	Andrew Cooper <andrew.cooper3@citrix.com>,
	Anthony PERARD <anthony.perard@vates.tech>,
	Alexey Gerasimenko <x1917x@gmail.com>
Subject: Re: [PATCH 03/17] hvmloader: add function to set the emulated machine type (i440/Q35)
Date: Tue, 28 Apr 2026 12:39:07 +0200	[thread overview]
Message-ID: <afCOS0Ufbk790t8J@macbook.local> (raw)
In-Reply-To: <20260313163455.790692-4-thierry.escande@vates.tech>

On Fri, Mar 13, 2026 at 04:35:01PM +0000, Thierry Escande wrote:
> This adds a new function init_pc_machine_type() which allows to
> determine and set the emulated chipset type. Possible values are
> MACHINE_TYPE_I440 and MACHINE_TYPE_Q35 and stored in the global variable
> machine_type.
> 
> The machine_type variable will be used from multiple places in following
> commits.

Is this initialization something that OVMF or SeaBIOS also does?
(maybe not for Xen ATM)

Asking myself because as said earlier we want to possibly get rid of
hvmloader, plus we will want ECAM support in PVH at some point.

> Signed-off-by: Alexey Gerasimenko <x1917x@gmail.com>

Same as previous patch, if the first SoB is from Alexey the From:
(patch author) should also match.

> Signed-off-by: Thierry Escande <thierry.escande@vates.tech>
> ---
>  tools/firmware/hvmloader/hvmloader.c |  2 ++
>  tools/firmware/hvmloader/pci_regs.h  |  4 +++
>  tools/firmware/hvmloader/util.c      | 42 ++++++++++++++++++++++++++++
>  tools/firmware/hvmloader/util.h      | 11 ++++++++
>  4 files changed, 59 insertions(+)
> 
> diff --git a/tools/firmware/hvmloader/hvmloader.c b/tools/firmware/hvmloader/hvmloader.c
> index 6d23150fc9..626cc53649 100644
> --- a/tools/firmware/hvmloader/hvmloader.c
> +++ b/tools/firmware/hvmloader/hvmloader.c
> @@ -332,6 +332,8 @@ int main(void)
>  
>      init_hypercalls();
>  
> +    init_pc_machine_type();
> +
>      memory_map_setup();
>  
>      xenbus_setup();
> diff --git a/tools/firmware/hvmloader/pci_regs.h b/tools/firmware/hvmloader/pci_regs.h
> index 7bf2d873ab..4d4dc0cd01 100644
> --- a/tools/firmware/hvmloader/pci_regs.h
> +++ b/tools/firmware/hvmloader/pci_regs.h
> @@ -107,6 +107,10 @@
>  
>  #define PCI_INTEL_OPREGION 0xfc /* 4 bits */
>  
> +#define PCI_VENDOR_ID_INTEL              0x8086
> +#define PCI_DEVICE_ID_INTEL_82441        0x1237
> +#define PCI_DEVICE_ID_INTEL_Q35_MCH      0x29c0

In Xen we have a separate file for vendor and device IDs, called
pci_ids.h.  Maybe it would be better to use a similar approach in
hvmloader, and keep pci_regs.h only containing PCI register offsets.

> +
>  #endif /* __HVMLOADER_PCI_REGS_H__ */
>  
>  /*
> diff --git a/tools/firmware/hvmloader/util.c b/tools/firmware/hvmloader/util.c
> index f1ed1eb48d..f9116bea4d 100644
> --- a/tools/firmware/hvmloader/util.c
> +++ b/tools/firmware/hvmloader/util.c
> @@ -22,6 +22,7 @@
>  #include "hypercall.h"
>  #include "ctype.h"
>  #include "vnuma.h"
> +#include "pci_regs.h"
>  #include <acpi2_0.h>
>  #include <libacpi.h>
>  #include <stdint.h>
> @@ -648,6 +649,47 @@ void __bug(const char *file, int line)
>      crash();
>  }
>  
> +machine_type_t machine_type;
> +
> +void init_pc_machine_type(void)

Since detection is done based on PCI device IDs, it might be better
placed in pci.c, and so you don't need to include pci_regs.h in
util.c.

> +{
> +    uint16_t vendor_id;
> +    uint16_t device_id;
> +
> +    if ( machine_type != MACHINE_TYPE_UNDEFINED )
> +        return;
> +
> +    vendor_id = pci_readw(0, PCI_VENDOR_ID);
> +    device_id = pci_readw(0, PCI_DEVICE_ID);
> +
> +    /* only Intel platforms are emulated currently */
> +    if ( vendor_id != PCI_VENDOR_ID_INTEL )
> +        goto error;
> +
> +    switch ( device_id )
> +    {
> +    case PCI_DEVICE_ID_INTEL_82441:
> +        machine_type = MACHINE_TYPE_I440;
> +        printf("Detected i440 chipset\n");
> +        break;
> +
> +    case PCI_DEVICE_ID_INTEL_Q35_MCH:
> +        machine_type = MACHINE_TYPE_Q35;
> +        printf("Detected Q35 chipset\n");
> +        break;
> +
> +    default:
> +        goto error;
> +    }
> +
> +    return;
> +
> +error:
> +    printf("Unknown emulated chipset encountered, VID=%04Xh, DID=%04Xh\n",

We don't usually use the h suffix in hex numbers in hvmloader, it's
more common to prefix them with 0x, so I would recommend to use the %#06x
formatter instead.

Thanks, Roger.


  reply	other threads:[~2026-04-28 10:39 UTC|newest]

Thread overview: 59+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-13 16:35 [PATCH 00/17] Q35 initial support for HVM guests Thierry Escande
2026-03-13 16:35 ` [PATCH 01/17] libacpi: Split dsdt.asl file and extract i440 specific parts Thierry Escande
2026-04-28  9:05   ` Roger Pau Monné
2026-05-04 14:34   ` Jan Beulich
2026-05-04 14:35     ` Jan Beulich
2026-03-13 16:35 ` [PATCH 03/17] hvmloader: add function to set the emulated machine type (i440/Q35) Thierry Escande
2026-04-28 10:39   ` Roger Pau Monné [this message]
2026-05-04 10:58     ` Jan Beulich
2026-05-04 14:43   ` Jan Beulich
2026-03-13 16:35 ` [PATCH 05/17] hvmloader: add Q35 DSDT table loading Thierry Escande
2026-04-28 11:08   ` Roger Pau Monné
2026-03-13 16:35 ` [PATCH 02/17] libacpi: new DSDT ACPI table for Q35 Thierry Escande
2026-04-28 10:17   ` Roger Pau Monné
2026-05-04 14:39   ` Jan Beulich
2026-03-13 16:35 ` [PATCH 06/17] hvmloader: Move pci devices setup to a separate function Thierry Escande
2026-04-28 12:48   ` Roger Pau Monné
2026-05-04 14:52   ` Jan Beulich
2026-03-13 16:35 ` [PATCH 10/17] hvmloader: Add support for HVMOP_set|get_ecam_space hypercalls Thierry Escande
2026-04-28 14:14   ` Roger Pau Monné
2026-03-13 16:35 ` [PATCH 07/17] hvmloader: add basic Q35 support Thierry Escande
2026-04-28 13:15   ` Roger Pau Monné
2026-05-10 23:32     ` Alexey G
2026-05-04 14:55   ` Jan Beulich
2026-03-13 16:35 ` [PATCH 08/17] hvmloader: Extend PCI BAR struct Thierry Escande
2026-04-28 13:31   ` Roger Pau Monné
2026-05-04 15:01   ` Jan Beulich
2026-03-13 16:35 ` [PATCH 11/17] hvmloader: allocate MMCONFIG area in the MMIO hole Thierry Escande
2026-04-29  9:29   ` Roger Pau Monné
2026-05-04 11:11     ` Jan Beulich
2026-05-04 12:23       ` Roger Pau Monné
2026-05-04 12:36         ` Jan Beulich
2026-03-13 16:35 ` [PATCH 12/17] libxl: Q35 support (new option device_model_machine) Thierry Escande
2026-04-29 10:01   ` Roger Pau Monné
2026-03-13 16:35 ` [PATCH 13/17] libxl: Add xen-platform device for Q35 machine Thierry Escande
2026-03-13 16:35 ` [PATCH 14/17] libacpi: build ACPI MCFG table if requested Thierry Escande
2026-04-29 10:13   ` Roger Pau Monné
2026-03-13 16:35 ` [PATCH 09/17] xev/hvm: Add HVMOP_get|set_ecam_space hypercalls Thierry Escande
2026-04-28 13:59   ` Roger Pau Monné
2026-05-04 11:09     ` Jan Beulich
2026-05-04 15:12   ` Jan Beulich
2026-03-13 16:35 ` [PATCH 16/17] Handle PCIe ECAM space access from guests Thierry Escande
2026-04-29 12:42   ` Roger Pau Monné
2026-05-04 15:22   ` Jan Beulich
2026-03-13 16:35 ` [PATCH 17/17] docs: provide description for device_model_machine option Thierry Escande
2026-04-29 12:43   ` Roger Pau Monné
2026-03-13 16:35 ` [PATCH 04/17] hvmloader: add ACPI enabling for Q35 Thierry Escande
2026-04-28 10:48   ` Roger Pau Monné
2026-05-05 13:58     ` Alexey G
2026-05-05 14:25       ` Roger Pau Monné
2026-03-13 16:35 ` [PATCH 15/17] hvmloader: Set MCFG in ACPI table Thierry Escande
2026-04-29 12:33   ` Roger Pau Monné
2026-03-15 22:43 ` [PATCH 00/17] Q35 initial support for HVM guests Alexey G
2026-04-28  7:48 ` Roger Pau Monné
2026-05-04 10:45   ` Jan Beulich
2026-05-05  5:48     ` Jan Beulich
2026-05-05  5:49       ` Jan Beulich
2026-05-05 13:29     ` Alexey G
2026-05-05 13:07   ` Alexey G
2026-05-05 14:15     ` Roger Pau Monné

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=afCOS0Ufbk790t8J@macbook.local \
    --to=roger.pau@citrix.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=anthony.perard@vates.tech \
    --cc=jbeulich@suse.com \
    --cc=thierry.escande@vates.tech \
    --cc=x1917x@gmail.com \
    --cc=xen-devel@lists.xenproject.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 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.