From: Jonathan Cameron <Jonathan.Cameron@Huawei.com>
To: Ben Widawsky <ben.widawsky@intel.com>
Cc: Eduardo Habkost <ehabkost@redhat.com>,
"Michael S. Tsirkin" <mst@redhat.com>,
Vishal Verma <vishal.l.verma@intel.com>,
qemu-devel@nongnu.org, Paolo Bonzini <pbonzini@redhat.com>,
Igor Mammedov <imammedo@redhat.com>,
Dan Williams <dan.j.williams@intel.com>,
Richard Henderson <rth@twiddle.net>
Subject: Re: [RFC PATCH 22/25] acpi/cxl: Create the CEDT (9.14.1)
Date: Mon, 16 Nov 2020 17:15:03 +0000 [thread overview]
Message-ID: <20201116171503.00007b4f@Huawei.com> (raw)
In-Reply-To: <20201111054724.794888-23-ben.widawsky@intel.com>
On Tue, 10 Nov 2020 21:47:21 -0800
Ben Widawsky <ben.widawsky@intel.com> wrote:
> The CXL Early Discovery Table is defined in the CXL 2.0 specification as
> a way for the OS to get CXL specific information from the system
> firmware.
>
> As of CXL 2.0 spec, only 1 sub structure is defined, the CXL Host Bridge
> Structure (CHBS) which is primarily useful for telling the OS exactly
> where the MMIO for the host bridge is.
>
> Signed-off-by: Ben Widawsky <ben.widawsky@intel.com>
Trivial comments inline.
Jonathan
> ---
> hw/acpi/cxl.c | 72 +++++++++++++++++++++++++++++
> hw/i386/acpi-build.c | 6 ++-
> hw/pci-bridge/pci_expander_bridge.c | 21 +--------
> include/hw/acpi/cxl.h | 4 ++
> include/hw/pci/pci_bridge.h | 25 ++++++++++
> 5 files changed, 107 insertions(+), 21 deletions(-)
>
> diff --git a/hw/acpi/cxl.c b/hw/acpi/cxl.c
> index 31ceaeecc3..c9631763ad 100644
> --- a/hw/acpi/cxl.c
> +++ b/hw/acpi/cxl.c
> @@ -18,14 +18,86 @@
> */
>
> #include "qemu/osdep.h"
> +#include "hw/sysbus.h"
> +#include "hw/pci/pci_bridge.h"
> +#include "hw/pci/pci_host.h"
> #include "hw/cxl/cxl.h"
> +#include "hw/mem/memory-device.h"
> #include "hw/acpi/acpi.h"
> #include "hw/acpi/aml-build.h"
> #include "hw/acpi/bios-linker-loader.h"
> #include "hw/acpi/cxl.h"
> +#include "hw/acpi/cxl.h"
> #include "qapi/error.h"
> #include "qemu/uuid.h"
>
> +static void cedt_build_chbs(GArray *table_data, PXBDev *cxl)
> +{
> + SysBusDevice *sbd = SYS_BUS_DEVICE(cxl->cxl.cxl_host_bridge);
> + struct MemoryRegion *mr = sbd->mmio[0].memory;
> +
> + /* Type */
> + build_append_int_noprefix(table_data, 0, 1);
> +
> + /* Reserved */
> + build_append_int_noprefix(table_data, 0xff, 1);
Why 0xff rather than 0x00? ACPI uses default of 0 for reserved bits
(5.2.1 in ACPI 6.3 spec)
> +
> + /* Record Length */
> + build_append_int_noprefix(table_data, 32, 2);
> +
> + /* UID */
> + build_append_int_noprefix(table_data, cxl->uid, 4);
> +
> + /* Version */
> + build_append_int_noprefix(table_data, 1, 4);
> +
> + /* Reserved */
> + build_append_int_noprefix(table_data, 0xffffffff, 4);
> +
> + /* Base */
> + build_append_int_noprefix(table_data, mr->addr, 8);
> +
> + /* Length */
> + build_append_int_noprefix(table_data, memory_region_size(mr), 4);
Better to just treat this as a 64 bit field as per the spec, even though
it can only contain 0x10000?
> +
> + /* Reserved */
> + build_append_int_noprefix(table_data, 0xffffffff, 4);
> +}
> +
> +static int cxl_foreach_pxb_hb(Object *obj, void *opaque)
> +{
> + Aml *cedt = opaque;
> +
> + if (object_dynamic_cast(obj, TYPE_PXB_CXL_DEVICE)) {
> + PXBDev *pxb = PXB_CXL_DEV(obj);
> +
> + cedt_build_chbs(cedt->buf, pxb);
> + }
> +
> + return 0;
> +}
> +
> +void cxl_build_cedt(GArray *table_offsets, GArray *table_data,
> + BIOSLinker *linker)
> +{
> + const int cedt_start = table_data->len;
> + Aml *cedt;
> +
> + cedt = init_aml_allocator();
> +
> + /* reserve space for CEDT header */
> + acpi_add_table(table_offsets, table_data);
> + acpi_data_push(cedt->buf, sizeof(AcpiTableHeader));
> +
> + object_child_foreach_recursive(object_get_root(), cxl_foreach_pxb_hb, cedt);
> +
> + /* copy AML table into ACPI tables blob and patch header there */
> + g_array_append_vals(table_data, cedt->buf->data, cedt->buf->len);
> + build_header(linker, table_data, (void *)(table_data->data + cedt_start),
> + "CEDT", table_data->len - cedt_start, 1, NULL, NULL);
> + free_aml_allocator();
> +}
> +
> static Aml *__build_cxl_osc_method(void)
> {
> Aml *method, *if_uuid, *else_uuid, *if_arg1_not_1, *if_cxl, *if_caps_masked;
> diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
> index dd1f8b39d4..eda62dcd6a 100644
> --- a/hw/i386/acpi-build.c
> +++ b/hw/i386/acpi-build.c
> @@ -75,6 +75,8 @@
> #include "hw/acpi/ipmi.h"
> #include "hw/acpi/hmat.h"
>
> +#include "hw/acpi/cxl.h"
> +
> /* These are used to size the ACPI tables for -M pc-i440fx-1.7 and
> * -M pc-i440fx-2.0. Even if the actual amount of AML generated grows
> * a little bit, there should be plenty of free space since the DSDT
> @@ -1662,7 +1664,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
>
> scope = aml_scope("\\_SB");
> if (type == CXL) {
> - dev = aml_device("CXL%.01X", pci_bus_uid(bus));
> + dev = aml_device("CXL%.01X", uid);
> } else {
> dev = aml_device("PC%.02X", bus_num);
> }
> @@ -2568,6 +2570,8 @@ void acpi_build(AcpiBuildTables *tables, MachineState *machine)
> machine->nvdimms_state, machine->ram_slots);
> }
>
> + cxl_build_cedt(table_offsets, tables_blob, tables->linker);
> +
> acpi_add_table(table_offsets, tables_blob);
> build_waet(tables_blob, tables->linker);
>
> diff --git a/hw/pci-bridge/pci_expander_bridge.c b/hw/pci-bridge/pci_expander_bridge.c
> index 75910f5870..b2c1d9056a 100644
> --- a/hw/pci-bridge/pci_expander_bridge.c
> +++ b/hw/pci-bridge/pci_expander_bridge.c
> @@ -57,26 +57,6 @@ DECLARE_INSTANCE_CHECKER(PXBDev, PXB_DEV,
> DECLARE_INSTANCE_CHECKER(PXBDev, PXB_PCIE_DEV,
> TYPE_PXB_PCIE_DEVICE)
>
> -#define TYPE_PXB_CXL_DEVICE "pxb-cxl"
> -DECLARE_INSTANCE_CHECKER(PXBDev, PXB_CXL_DEV,
> - TYPE_PXB_CXL_DEVICE)
> -
> -struct PXBDev {
> - /*< private >*/
> - PCIDevice parent_obj;
> - /*< public >*/
> -
> - uint8_t bus_nr;
> - uint16_t numa_node;
> - int32_t uid;
> - struct cxl_dev {
> - HostMemoryBackend *memory_window[CXL_WINDOW_MAX];
> -
> - uint32_t num_windows;
> - hwaddr *window_base[CXL_WINDOW_MAX];
> - } cxl;
> -};
> -
> typedef struct CXLHost {
> PCIHostState parent_obj;
>
> @@ -351,6 +331,7 @@ static void pxb_dev_realize_common(PCIDevice *dev, enum BusType type,
> bus = pci_root_bus_new(ds, dev_name, NULL, NULL, 0, TYPE_PXB_CXL_BUS);
> bus->flags |= PCI_BUS_CXL;
> PXB_CXL_HOST(ds)->dev = PXB_CXL_DEV(dev);
> + PXB_CXL_DEV(dev)->cxl.cxl_host_bridge = ds;
> } else {
> bus = pci_root_bus_new(ds, "pxb-internal", NULL, NULL, 0, TYPE_PXB_BUS);
> bds = qdev_new("pci-bridge");
> diff --git a/include/hw/acpi/cxl.h b/include/hw/acpi/cxl.h
> index 7b8f3b8a2e..db2063f8c9 100644
> --- a/include/hw/acpi/cxl.h
> +++ b/include/hw/acpi/cxl.h
> @@ -18,6 +18,10 @@
> #ifndef HW_ACPI_CXL_H
> #define HW_ACPI_CXL_H
>
> +#include "hw/acpi/bios-linker-loader.h"
> +
> +void cxl_build_cedt(GArray *table_offsets, GArray *table_data,
> + BIOSLinker *linker);
> void build_cxl_osc_method(Aml *dev);
>
> #endif
> diff --git a/include/hw/pci/pci_bridge.h b/include/hw/pci/pci_bridge.h
> index a94d350034..50dd7fdf33 100644
> --- a/include/hw/pci/pci_bridge.h
> +++ b/include/hw/pci/pci_bridge.h
> @@ -28,6 +28,7 @@
>
> #include "hw/pci/pci.h"
> #include "hw/pci/pci_bus.h"
> +#include "hw/cxl/cxl.h"
> #include "qom/object.h"
>
> typedef struct PCIBridgeWindows PCIBridgeWindows;
> @@ -81,6 +82,30 @@ struct PCIBridge {
> #define PCI_BRIDGE_DEV_PROP_MSI "msi"
> #define PCI_BRIDGE_DEV_PROP_SHPC "shpc"
>
> +struct PXBDev {
> + /*< private >*/
> + PCIDevice parent_obj;
> + /*< public >*/
> +
> + uint8_t bus_nr;
> + uint16_t numa_node;
> + int32_t uid;
> +
> + struct cxl_dev {
> + HostMemoryBackend *memory_window[CXL_WINDOW_MAX];
> +
> + uint32_t num_windows;
> + hwaddr *window_base[CXL_WINDOW_MAX];
> +
> + void *cxl_host_bridge; /* Pointer to a CXLHost */
> + } cxl;
> +};
> +
> +typedef struct PXBDev PXBDev;
> +#define TYPE_PXB_CXL_DEVICE "pxb-cxl"
> +DECLARE_INSTANCE_CHECKER(PXBDev, PXB_CXL_DEV,
> + TYPE_PXB_CXL_DEVICE)
> +
Seems like this could sensibly be on one line?
Could have been in earlier patch as well of course.
> int pci_bridge_ssvid_init(PCIDevice *dev, uint8_t offset,
> uint16_t svid, uint16_t ssid,
> Error **errp);
next prev parent reply other threads:[~2020-11-16 17:17 UTC|newest]
Thread overview: 64+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-11 5:46 [RFC PATCH 00/25] Introduce CXL 2.0 Emulation Ben Widawsky
2020-11-11 5:47 ` [RFC PATCH 01/25] Temp: Add the PCI_EXT_ID_DVSEC definition to the qemu pci_regs.h copy Ben Widawsky
2020-11-11 5:47 ` [RFC PATCH 02/25] hw/pci/cxl: Add a CXL component type (interface) Ben Widawsky
2020-11-11 5:47 ` [RFC PATCH 03/25] hw/cxl/component: Introduce CXL components (8.1.x, 8.2.5) Ben Widawsky
2020-11-16 12:03 ` Jonathan Cameron
2020-11-16 19:19 ` Ben Widawsky
2020-11-17 12:29 ` Jonathan Cameron
2020-11-24 23:09 ` Ben Widawsky
2020-11-11 5:47 ` [RFC PATCH 04/25] hw/cxl/device: Introduce a CXL device (8.2.8) Ben Widawsky
2020-11-16 13:07 ` Jonathan Cameron
2020-11-16 21:11 ` Ben Widawsky
2020-11-17 14:21 ` Jonathan Cameron
2020-11-11 5:47 ` [RFC PATCH 05/25] hw/cxl/device: Implement the CAP array (8.2.8.1-2) Ben Widawsky
2020-11-16 13:11 ` Jonathan Cameron
2020-11-16 18:08 ` Ben Widawsky
2020-11-11 5:47 ` [RFC PATCH 06/25] hw/cxl/device: Add device status (8.2.8.3) Ben Widawsky
2020-11-16 13:16 ` Jonathan Cameron
2020-11-16 21:18 ` Ben Widawsky
2020-11-17 14:24 ` Jonathan Cameron
2020-11-11 5:47 ` [RFC PATCH 07/25] hw/cxl/device: Implement basic mailbox (8.2.8.4) Ben Widawsky
2020-11-16 13:46 ` Jonathan Cameron
2020-11-16 21:42 ` Ben Widawsky
2020-11-11 5:47 ` [RFC PATCH 08/25] hw/cxl/device: Add memory devices (8.2.8.5) Ben Widawsky
2020-11-16 16:37 ` Jonathan Cameron
2020-11-16 21:45 ` Ben Widawsky
2020-11-17 14:31 ` Jonathan Cameron
2020-11-11 5:47 ` [RFC PATCH 09/25] hw/pxb: Use a type for realizing expanders Ben Widawsky
2020-11-11 5:47 ` [RFC PATCH 10/25] hw/pci/cxl: Create a CXL bus type Ben Widawsky
2020-11-11 5:47 ` [RFC PATCH 11/25] hw/pxb: Allow creation of a CXL PXB (host bridge) Ben Widawsky
2020-11-16 16:44 ` Jonathan Cameron
2020-11-16 22:01 ` Ben Widawsky
2020-11-17 14:33 ` Jonathan Cameron
2020-11-11 5:47 ` [RFC PATCH 12/25] acpi/pci: Consolidate host bridge setup Ben Widawsky
2020-11-12 17:46 ` Ben Widawsky
2020-11-16 16:45 ` Jonathan Cameron
2020-11-11 5:47 ` [RFC PATCH 13/25] hw/pci: Plumb _UID through host bridges Ben Widawsky
2020-11-11 5:47 ` [RFC PATCH 14/25] hw/cxl/component: Implement host bridge MMIO (8.2.5, table 142) Ben Widawsky
2020-11-11 5:47 ` [RFC PATCH 15/25] acpi/pxb/cxl: Reserve host bridge MMIO Ben Widawsky
2020-11-16 16:54 ` Jonathan Cameron
2020-11-11 5:47 ` [RFC PATCH 16/25] hw/pxb/cxl: Add "windows" for host bridges Ben Widawsky
2020-11-13 0:49 ` Ben Widawsky
2020-11-23 19:12 ` Philippe Mathieu-Daudé
2020-11-11 5:47 ` [RFC PATCH 17/25] hw/cxl/rp: Add a root port Ben Widawsky
2020-11-11 5:47 ` [RFC PATCH 18/25] hw/cxl/device: Add a memory device (8.2.8.5) Ben Widawsky
2020-11-12 18:37 ` Eric Blake
2020-11-13 7:47 ` Markus Armbruster
2020-11-25 16:53 ` Ben Widawsky
2020-11-26 6:36 ` Markus Armbruster
2020-11-30 17:07 ` Ben Widawsky
2020-12-01 17:06 ` Markus Armbruster
2020-11-11 5:47 ` [RFC PATCH 19/25] hw/cxl/device: Implement MMIO HDM decoding (8.2.5.12) Ben Widawsky
2020-11-11 5:47 ` [RFC PATCH 20/25] acpi/cxl: Add _OSC implementation (9.14.2) Ben Widawsky
2020-11-11 5:47 ` [RFC PATCH 21/25] acpi/cxl: Introduce a compat-driver UUID for CXL _OSC Ben Widawsky
2020-11-11 5:47 ` [RFC PATCH 22/25] acpi/cxl: Create the CEDT (9.14.1) Ben Widawsky
2020-11-16 17:15 ` Jonathan Cameron [this message]
2020-11-16 22:05 ` Ben Widawsky
2020-11-11 5:47 ` [RFC PATCH 23/25] Temp: acpi/cxl: Add ACPI0017 (CEDT awareness) Ben Widawsky
2020-11-11 5:47 ` [RFC PATCH 24/25] WIP: i386/cxl: Initialize a host bridge Ben Widawsky
2020-11-11 5:47 ` [RFC PATCH 25/25] qtest/cxl: Add very basic sanity tests Ben Widawsky
2020-11-16 17:21 ` [RFC PATCH 00/25] Introduce CXL 2.0 Emulation Jonathan Cameron
2020-11-16 18:06 ` Ben Widawsky
2020-11-17 14:09 ` Jonathan Cameron
2020-11-25 18:29 ` Ben Widawsky
2020-12-04 14:27 ` Daniel P. Berrangé
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=20201116171503.00007b4f@Huawei.com \
--to=jonathan.cameron@huawei.com \
--cc=ben.widawsky@intel.com \
--cc=dan.j.williams@intel.com \
--cc=ehabkost@redhat.com \
--cc=imammedo@redhat.com \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=rth@twiddle.net \
--cc=vishal.l.verma@intel.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.