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>,
	Anthony PERARD <anthony.perard@vates.tech>,
	Alexey Gerasimenko <x1917x@gmail.com>
Subject: Re: [PATCH 14/17] libacpi: build ACPI MCFG table if requested
Date: Wed, 29 Apr 2026 12:13:15 +0200	[thread overview]
Message-ID: <afHZutWoJGHoKemZ@macbook.local> (raw)
In-Reply-To: <20260313163455.790692-15-thierry.escande@vates.tech>

On Fri, Mar 13, 2026 at 04:35:04PM +0000, Thierry Escande wrote:
> This adds construct_mcfg() function to libacpi which allows to build MCFG
> table for a given mmconfig_addr/mmconfig_len pair if the ACPI_HAS_MCFG
> flag was specified in acpi_config struct.
> 
> The maximum bus number is calculated from mmconfig_size using
> MCFG_SIZE_TO_NUM_BUSES macro (1MByte of MMIO space per bus).
> 
> Signed-off-by: Alexey Gerasimenko <x1917x@gmail.com>
> Signed-off-by: Thierry Escande <thierry.escande@vates.tech>
> ---
>  tools/libacpi/acpi2_0.h | 17 ++++++++++++++++
>  tools/libacpi/build.c   | 43 +++++++++++++++++++++++++++++++++++++++++
>  tools/libacpi/libacpi.h |  6 ++++++
>  3 files changed, 66 insertions(+)
> 
> diff --git a/tools/libacpi/acpi2_0.h b/tools/libacpi/acpi2_0.h
> index 51623e2a8a..2b16bd636a 100644
> --- a/tools/libacpi/acpi2_0.h
> +++ b/tools/libacpi/acpi2_0.h
> @@ -442,6 +442,21 @@ struct acpi_20_slit {
>      uint8_t entry[0];
>  };
>  
> +/*
> + * PCI Express Memory Mapped Configuration Description Table
> + */
> +struct acpi_10_mcfg {
> +    struct acpi_header header;
> +    uint8_t reserved[8];
> +    struct {
> +        uint64_t base_address;
> +        uint16_t pci_segment;
> +        uint8_t  start_pci_bus_num;
> +        uint8_t  end_pci_bus_num;
> +        uint32_t reserved;
> +    } entries[1];
> +};
> +
>  /*
>   * Table Signatures.
>   */
> @@ -457,6 +472,7 @@ struct acpi_20_slit {
>  #define ACPI_2_0_WAET_SIGNATURE ASCII32('W','A','E','T')
>  #define ACPI_2_0_SRAT_SIGNATURE ASCII32('S','R','A','T')
>  #define ACPI_2_0_SLIT_SIGNATURE ASCII32('S','L','I','T')
> +#define ACPI_MCFG_SIGNATURE     ASCII32('M','C','F','G')
>  
>  /*
>   * Table revision numbers.
> @@ -472,6 +488,7 @@ struct acpi_20_slit {
>  #define ACPI_1_0_FADT_REVISION 0x01
>  #define ACPI_2_0_SRAT_REVISION 0x01
>  #define ACPI_2_0_SLIT_REVISION 0x01
> +#define ACPI_1_0_MCFG_REVISION 0x01
>  
>  #pragma pack ()
>  
> diff --git a/tools/libacpi/build.c b/tools/libacpi/build.c
> index 95188e217e..90080c76c4 100644
> --- a/tools/libacpi/build.c
> +++ b/tools/libacpi/build.c
> @@ -295,6 +295,37 @@ static struct acpi_20_slit *construct_slit(struct acpi_ctxt *ctxt,
>      return slit;
>  }
>  
> +static struct acpi_10_mcfg *construct_mcfg(struct acpi_ctxt *ctxt,
> +                                        const struct acpi_config *config)
> +{
> +    struct acpi_10_mcfg *mcfg;
> +
> +    /* Warning: this code expects that we have only one PCI segment */

Not only one PCI segment, but just one ECAM region.  You could in
theory have multiple ECAM regions within a single PCI segment.

> +    mcfg = ctxt->mem_ops.alloc(ctxt, sizeof(*mcfg), 16);
> +    if ( !mcfg )
> +        return NULL;
> +
> +    memset(mcfg, 0, sizeof(*mcfg));
> +    mcfg->header.signature        = ACPI_MCFG_SIGNATURE;
> +    mcfg->header.revision         = ACPI_1_0_MCFG_REVISION;
> +    mcfg->header.creator_id       = ACPI_CREATOR_ID;
> +    mcfg->header.creator_revision = ACPI_CREATOR_REVISION;
> +    mcfg->header.length           = sizeof(*mcfg);
> +    mcfg->header.oem_revision     = ACPI_OEM_REVISION;
> +    fixed_strcpy(mcfg->header.oem_id, ACPI_OEM_ID);
> +    fixed_strcpy(mcfg->header.oem_table_id, ACPI_OEM_TABLE_ID);
> +
> +    mcfg->entries[0].base_address      = config->mmconfig_addr;
> +    mcfg->entries[0].pci_segment       = 0;
> +    mcfg->entries[0].start_pci_bus_num = 0;
> +    mcfg->entries[0].end_pci_bus_num   =
> +        MCFG_SIZE_TO_NUM_BUSES(config->mmconfig_size) - 1;


You might want to check that mmconfig_addr and mmconfig_size are set
ahead of using them?  Just in case some bogus toolstack/hvmloader sets
ACPI_HAS_MCFG without correctly populating the fields?

Thanks, Roger.


  reply	other threads:[~2026-04-29 10:13 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 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 03/17] hvmloader: add function to set the emulated machine type (i440/Q35) Thierry Escande
2026-04-28 10:39   ` Roger Pau Monné
2026-05-04 10:58     ` Jan Beulich
2026-05-04 14:43   ` Jan Beulich
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 05/17] hvmloader: add Q35 DSDT table loading Thierry Escande
2026-04-28 11:08   ` 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 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 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 14/17] libacpi: build ACPI MCFG table if requested Thierry Escande
2026-04-29 10:13   ` Roger Pau Monné [this message]
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 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 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-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-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=afHZutWoJGHoKemZ@macbook.local \
    --to=roger.pau@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.