# cxl: platform

---

# ACPI Tables

_Peios Kernel / Hardware and drivers / Driver development / cxl: platform_

> ACPI is the "Advanced Configuration and Power Interface", which is a standard that defines how platforms and OS manage power and configure computer hardware. For the purpose of this theory of operation, when referring to "ACPI" we will…

<a id="rst-acpi-tables"></a>

<!-- SPDX-License-Identifier: GPL-2.0 -->

ACPI is the "Advanced Configuration and Power Interface", which is a standard that defines how platforms and OS manage power and configure computer hardware. For the purpose of this theory of operation, when referring to "ACPI" we will usually refer to "ACPI Tables" - which are the way a platform (BIOS/EFI) communicates static configuration information to the operation system.

The Following ACPI tables contain *static* configuration and performance data about CXL devices.

- [CEDT - CXL Early Discovery Table](</kernel/hardware/driver-api/cxl-platform-acpi/cedt.md>)
- [SRAT - Static Resource Affinity Table](</kernel/hardware/driver-api/cxl-platform-acpi/srat.md>)
- [HMAT - Heterogeneous Memory Attribute Table](</kernel/hardware/driver-api/cxl-platform-acpi/hmat.md>)
- [SLIT - System Locality Information Table](</kernel/hardware/driver-api/cxl-platform-acpi/slit.md>)
- [DSDT - Differentiated system Description Table](</kernel/hardware/driver-api/cxl-platform-acpi/dsdt.md>)

The SRAT table may also contain generic port/initiator content that is intended to describe the generic port, but not information about the rest of the path to the endpoint.

Linux uses these tables to configure kernel resources for statically configured (by BIOS/EFI) CXL devices, such as:

- NUMA nodes

- Memory Tiers

- NUMA Abstract Distances

- SystemRAM Memory Regions

- Weighted Interleave Node Weights

<a id="rst-acpi-debugging"></a>

## ACPI Debugging

The `acpidump -b` command dumps the ACPI tables into binary format.

The `iasl -d` command disassembles the files into human readable format.

Example `acpidump -b && iasl -d cedt.dat`



```text
[000h 0000   4]   Signature : "CEDT"    [CXL Early Discovery Table]
```

<a id="rst-common-issues"></a>

### Common Issues

Most failures described here result in a failure of the driver to surface memory as a DAX device and/or kmem.

- CEDT CFMWS targets list UIDs do not match CEDT CHBS UIDs.

- CEDT CFMWS targets list UIDs do not match DSDT CXL Host Bridge UIDs.

- CEDT CFMWS Restriction Bits are not correct.

- CEDT CFMWS Memory regions are poorly aligned.

- CEDT CFMWS Memory regions spans a platform memory hole.

- CEDT CHBS UIDs do not match DSDT CXL Host Bridge UIDs.

- CEDT CHBS Specification version is incorrect.

- SRAT is missing regions described in CEDT CFMWS.

  - Result: failure to create a NUMA node for the region, or region is placed in wrong node.

- HMAT is missing data for regions described in CEDT CFMWS.

  - Result: NUMA node being placed in the wrong memory tier.

- SLIT has bad data.

  - Result: Lots of performance mechanisms in the kernel will be very unhappy.

All of these issues will appear to users as if the driver is failing to support CXL - when in reality they are all the failure of a platform to configure the ACPI tables correctly.

---

# BIOS/EFI Configuration

_Peios Kernel / Hardware and drivers / Driver development / cxl: platform_

> BIOS and EFI are largely responsible for configuring static information about devices (or potential future devices) such that Linux can build the appropriate logical representations of these devices.

<a id="rst-bios-efi-configuration"></a>

<!-- SPDX-License-Identifier: GPL-2.0 -->

BIOS and EFI are largely responsible for configuring static information about devices (or potential future devices) such that Linux can build the appropriate logical representations of these devices.

At a high level, this is what occurs during this phase of configuration.

- The bootloader starts the BIOS/EFI.

- BIOS/EFI do early device probe to determine static configuration

- BIOS/EFI creates ACPI Tables that describe static config for the OS

- BIOS/EFI create the system memory map (EFI Memory Map, E820, etc)

- BIOS/EFI calls `start_kernel` and begins the Linux Early Boot process.

Much of what this section is concerned with is ACPI Table production and static memory map configuration. More detail on these tables can be found at [ACPI Tables](</kernel/hardware/driver-api/cxl-platform/acpi.md>).

> [!NOTE]
>
> Platform Vendors should read carefully, as this sections has recommendations on physical memory region size and alignment, memory holes, HDM interleave, and what linux expects of HDM decoders trying to work with these features.

<a id="rst-linux-expectations-of-bios-efi-software"></a>

## Linux Expectations of BIOS/EFI Software

Linux expects BIOS/EFI software to construct sufficient ACPI tables (such as CEDT, SRAT, HMAT, etc) and platform-specific configurations (such as HPA spaces and host-bridge interleave configurations) to allow the Linux driver to subsequently configure the devices in the CXL fabric at runtime.

Programming of HDM decoders and switch ports is not required, and may be deferred to the CXL driver based on admin policy (e.g. udev rules).

Some platforms may require pre-programming HDM decoders and locking them due to quirks (see: Zen5 address translation), but this is not the normal, "expected" configuration path.  This should be avoided if possible.

Some platforms may wish to pre-configure these resources to bring memory up without requiring CXL driver support.  These platform vendors should test their configurations with the existing CXL driver and provide driver support for their auto-configurations if features like RAS are required.

Platforms requiring boot-time programming and/or locking of CXL fabric components may prevent features, such as device hot-plug, from working.

<a id="rst-uefi-settings"></a>

## UEFI Settings

If your platform supports it, the `uefisettings` command can be used to read/write EFI settings. Changes will be reflected on the next reboot. Kexec is not a sufficient reboot.

One notable configuration here is the EFI_MEMORY_SP (Specific Purpose) bit. When this is enabled, this bit tells linux to defer management of a memory region to a driver (in this case, the CXL driver). Otherwise, the memory is treated as "normal memory", and is exposed to the page allocator during `__init`.

<a id="rst-uefisettings-examples"></a>

### uefisettings examples

`uefisettings identify`



```text
uefisettings identify

bios_vendor: xxx
bios_version: xxx
bios_release: xxx
bios_date: xxx
product_name: xxx
product_family: xxx
product_version: xxx
```

On some AMD platforms, the `EFI_MEMORY_SP` bit is set via the `CXL Memory Attribute` field.  This may be called something else on your platform.

`uefisettings get "CXL Memory Attribute"`



```text
selector: xxx
...
question: Question {
    name: "CXL Memory Attribute",
    answer: "Enabled",
    ...
}
```

<a id="rst-physical-memory-map"></a>

## Physical Memory Map

<a id="rst-physical-address-region-alignment"></a>

### Physical Address Region Alignment

As of Linux v6.14, the hotplug memory system requires memory regions to be uniform in size and alignment.  While the CXL specification allows for memory regions as small as 256MB, the supported memory block size and alignment for hotplugged memory is architecture-defined.

A Linux memory blocks may be as small as 128MB and increase in powers of two.

- On ARM, the default block size and alignment is either 128MB or 256MB.

- On x86, the default block size is 256MB, and increases to 2GB as the capacity of the system increases up to 64GB.

For best support across versions, platform vendors should place CXL memory at a 2GB aligned base address, and regions should be 2GB aligned.  This also helps prevent the creating thousands of memory devices (one per block).

<a id="rst-memory-holes"></a>

### Memory Holes

Holes in the memory map are tricky.  Consider a 4GB device located at base address 0x100000000, but with the following memory map



```text
---------------------
|    0x100000000    |
|        CXL        |
|    0x1BFFFFFFF    |
---------------------
|    0x1C0000000    |
|    MEMORY HOLE    |
|    0x1FFFFFFFF    |
---------------------
|    0x200000000    |
|     CXL CONT.     |
|    0x23FFFFFFF    |
---------------------
```

There are two issues to consider:

- decoder programming, and

- memory block alignment.

If your architecture requires 2GB uniform size and aligned memory blocks, the only capacity Linux is capable of mapping (as of v6.14) would be the capacity from `0x100000000-0x180000000`.  The remaining capacity will be stranded, as they are not of 2GB aligned length.

Assuming your architecture and memory configuration allows 1GB memory blocks, this memory map is supported and this should be presented as multiple CFMWS in the CEDT that describe each side of the memory hole separately - along with matching decoders.

Multiple decoders can (and should) be used to manage such a memory hole (see below), but each chunk of a memory hole should be aligned to a reasonable block size (larger alignment is always better).  If you intend to have memory holes in the memory map, expect to use one decoder per contiguous chunk of host physical memory.

As of v6.14, Linux does provide support for memory hotplug of multiple physical memory regions separated by a memory hole described by a single HDM decoder.

<a id="rst-decoder-programming"></a>

## Decoder Programming

If BIOS/EFI intends to program the decoders to be statically configured, there are a few things to consider to avoid major pitfalls that will prevent Linux compatibility.  Some of these recommendations are not required "per the specification", but Linux makes no guarantees of support otherwise.

<a id="rst-translation-point"></a>

### Translation Point

Per the specification, the only decoders which **TRANSLATE** Host Physical Address (HPA) to Device Physical Address (DPA) are the **Endpoint Decoders**. All other decoders in the fabric are intended to route accesses without translating the addresses.

This is heavily implied by the specification, see:



```text
CXL Specification 3.1
8.2.4.20: CXL HDM Decoder Capability Structure
- Implementation Note: CXL Host Bridge and Upstream Switch Port Decoder Flow
- Implementation Note: Device Decoder Logic
```

Given this, Linux makes a strong assumption that decoders between CPU and endpoint will all be programmed with addresses ranges that are subsets of their parent decoder.

Due to some ambiguity in how Architecture, ACPI, PCI, and CXL specifications "hand off" responsibility between domains, some early adopting platforms attempted to do translation at the originating memory controller or host bridge.  This configuration requires a platform specific extension to the driver and is not officially endorsed - despite being supported.

It is *highly recommended* **NOT** to do this; otherwise, you are on your own to implement driver support for your platform.

<a id="rst-interleave-and-configuration-flexibility"></a>

### Interleave and Configuration Flexibility

If providing cross-host-bridge interleave, a CFMWS entry in the [CEDT](</kernel/hardware/driver-api/cxl-platform-acpi/cedt.md>) must be presented with target host-bridges for the interleaved device sets (there may be multiple behind each host bridge).

If providing intra-host-bridge interleaving, only 1 CFMWS entry in the CEDT is required for that host bridge - if it covers the entire capacity of the devices behind the host bridge.

If intending to provide users flexibility in programming decoders beyond the root, you may want to provide multiple CFMWS entries in the CEDT intended for different purposes.  For example, you may want to consider adding:

1. A CFMWS entry to cover all interleavable host bridges.

2. A CFMWS entry to cover all devices on a single host bridge.

3. A CFMWS entry to cover each device.

A platform may choose to add all of these, or change the mode based on a BIOS setting.  For each CFMWS entry, Linux expects descriptions of the described memory regions in the [SRAT](</kernel/hardware/driver-api/cxl-platform-acpi/srat.md>) to determine the number of NUMA nodes it should reserve during early boot / init.

As of v6.14, Linux will create a NUMA node for each CEDT CFMWS entry, even if a matching SRAT entry does not exist; however, this is not guaranteed in the future and such a configuration should be avoided.

<a id="rst-memory-holes-1"></a>

### Memory Holes

If your platform includes memory holes interspersed between your CXL memory, it is recommended to utilize multiple decoders to cover these regions of memory, rather than try to program the decoders to accept the entire range and expect Linux to manage the overlap.

For example, consider the Memory Hole described above



```text
---------------------
|    0x100000000    |
|        CXL        |
|    0x1BFFFFFFF    |
---------------------
|    0x1C0000000    |
|    MEMORY HOLE    |
|    0x1FFFFFFFF    |
---------------------
|    0x200000000    |
|     CXL CONT.     |
|    0x23FFFFFFF    |
---------------------
```

Assuming this is provided by a single device attached directly to a host bridge, Linux would expect the following decoder programming



```text
-----------------------   -----------------------
| root-decoder-0      |   | root-decoder-1      |
|   base: 0x100000000 |   |   base: 0x200000000 |
|   size:  0xC0000000 |   |   size:  0x40000000 |
-----------------------   -----------------------
           |                         |
-----------------------   -----------------------
| HB-decoder-0        |   | HB-decoder-1        |
|   base: 0x100000000 |   |   base: 0x200000000 |
|   size:  0xC0000000 |   |   size:  0x40000000 |
-----------------------   -----------------------
           |                         |
-----------------------   -----------------------
| ep-decoder-0        |   | ep-decoder-1        |
|   base: 0x100000000 |   |   base: 0x200000000 |
|   size:  0xC0000000 |   |   size:  0x40000000 |
-----------------------   -----------------------
```

With a CEDT configuration with two CFMWS describing the above root decoders.

Linux makes no guarantee of support for strange memory hole situations.

<a id="rst-multi-media-devices"></a>

### Multi-Media Devices

The CFMWS field of the CEDT has special restriction bits which describe whether the described memory region allows volatile or persistent memory (or both). If the platform intends to support either:

1. A device with multiple medias, or

2. Using a persistent memory device as normal memory

A platform may wish to create multiple CEDT CFMWS entries to describe the same memory, with the intent of allowing the end user flexibility in how that memory is configured. Linux does not presently have strong requirements in this area.

---

# Coherent Device Attribute Table (CDAT)

_Peios Kernel / Hardware and drivers / Driver development / cxl: platform_

> The CDAT provides functional and performance attributes of devices such as CXL accelerators, switches, or endpoints. The table formatting is similar to ACPI tables. CDAT data may be parsed by BIOS at boot or may be enumerated at runtime…

<!-- SPDX-License-Identifier: GPL-2.0 -->

<a id="rst-coherent-device-attribute-table-cdat"></a>

## Coherent Device Attribute Table (CDAT)

The CDAT provides functional and performance attributes of devices such as CXL accelerators, switches, or endpoints.  The table formatting is similar to ACPI tables. CDAT data may be parsed by BIOS at boot or may be enumerated at runtime (after device hotplug, for example).

Terminology: DPA - Device Physical Address, used by the CXL device to denote the address it supports for that device.

DSMADHandle - A device unique handle that is associated with a DPA range defined by the DSMAS table.

<a id="rst-device-scoped-memory-affinity-structure-dsmas"></a>

## Device Scoped Memory Affinity Structure (DSMAS)

The DSMAS contains information such as DSMADHandle, the DPA Base, and DPA Length.

This table is used by Linux in conjunction with the Device Scoped Latency and Bandwidth Information Structure (DSLBIS) to determine the performance attributes of the CXL device itself.

Example



```text
Structure Type : 00 [DSMAS]
      Reserved : 00
        Length : 0018              <- 24d, size of structure
   DSMADHandle : 01
         Flags : 00
      Reserved : 0000
      DPA Base : 0000000040000000  <- 1GiB base
    DPA Length : 0000000080000000  <- 2GiB size
```

<a id="rst-device-scoped-latency-and-bandwidth-information-structure-dslbis"></a>

## Device Scoped Latency and Bandwidth Information Structure (DSLBIS)

This table is used by Linux in conjunction with DSMAS to determine the performance attributes of a CXL device.  The DSLBIS contains latency and bandwidth information based on DSMADHandle matching.

Example



```text
  Structure Type : 01 [DSLBIS]
        Reserved : 00
          Length : 18                     <- 24d, size of structure
          Handle : 0001                   <- DSMAS handle
           Flags : 00                     <- Matches flag field for HMAT SLLBIS
       Data Type : 00                     <- Latency
Entry Basee Unit : 0000000000001000       <- Entry Base Unit field in HMAT SSLBIS
           Entry : 010000000000           <- First byte used here, CXL LTC
        Reserved : 0000

  Structure Type : 01 [DSLBIS]
        Reserved : 00
          Length : 18                     <- 24d, size of structure
          Handle : 0001                   <- DSMAS handle
           Flags : 00                     <- Matches flag field for HMAT SLLBIS
       Data Type : 03                     <- Bandwidth
Entry Basee Unit : 0000000000001000       <- Entry Base Unit field in HMAT SSLBIS
           Entry : 020000000000           <- First byte used here, CXL BW
        Reserved : 0000
```

<a id="rst-switch-scoped-latency-and-bandwidth-information-structure-sslbis"></a>

## Switch Scoped Latency and Bandwidth Information Structure (SSLBIS)

The SSLBIS contains information about the latency and bandwidth of a switch.

The table is used by Linux to compute the performance coordinates of a CXL path from the device to the root port where a switch is part of the path.

Example



```text
 Structure Type : 05 [SSLBIS]
       Reserved : 00
         Length : 20                           <- 32d, length of record, including SSLB entries
      Data Type : 00                           <- Latency
       Reserved : 000000
Entry Base Unit : 00000000000000001000         <- Matches Entry Base Unit in HMAT SSLBIS

                                               <- SSLB Entry 0
      Port X ID : 0100                         <- First port, 0100h represents an upstream port
      Port Y ID : 0000                         <- Second port, downstream port 0
        Latency : 0100                         <- Port latency
       Reserved : 0000
                                               <- SSLB Entry 1
      Port X ID : 0100
      Port Y ID : 0001
        Latency : 0100
       Reserved : 0000


 Structure Type : 05 [SSLBIS]
       Reserved : 00
         Length : 18                           <- 24d, length of record, including SSLB entry
      Data Type : 03                           <- Bandwidth
       Reserved : 000000
Entry Base Unit : 00000000000000001000         <- Matches Entry Base Unit in HMAT SSLBIS

                                               <- SSLB Entry 0
      Port X ID : 0100                         <- First port, 0100h represents an upstream port
      Port Y ID : FFFF                         <- Second port, FFFFh indicates any port
      Bandwidth : 1200                         <- Port bandwidth
       Reserved : 0000
```

The CXL driver uses a combination of CDAT, HMAT, SRAT, and other data to generate "whole path performance" data for a CXL device.

---

# CXL Device Hotplug

_Peios Kernel / Hardware and drivers / Driver development / cxl: platform_

> Device hotplug refers to physical hotplug of a device (addition or removal of a physical device from the machine).

<a id="rst-cxl-device-hotplug"></a>

<!-- SPDX-License-Identifier: GPL-2.0 -->

Device hotplug refers to *physical* hotplug of a device (addition or removal of a physical device from the machine).

BIOS/EFI software is expected to configure sufficient resources **at boot time** to allow hotplugged devices to be configured by software (such as proximity domains, HPA regions, and host-bridge configurations).

BIOS/EFI is not expected (**nor suggested**) to configure hotplugged devices at hotplug time (i.e. HDM decoders should be left unprogrammed).

This document covers some examples of those resources, but should not be considered exhaustive.

<a id="rst-hot-remove"></a>

## Hot-Remove

Hot removal of a device typically requires careful removal of software constructs (memory regions, associated drivers) which manage these devices.

Hard-removing a CXL.mem device without carefully tearing down driver stacks is likely to cause the system to machine-check (or at least SIGBUS if memory access is limited to user space).

<a id="rst-memory-device-hot-add"></a>

## Memory Device Hot-Add

A device present at boot may be associated with a CXL Fixed Memory Window reported in [CEDT](</kernel/hardware/driver-api/cxl-platform-acpi/cedt.md>).  That CFMWS may match the size of the device, but the construction of the CEDT CFMWS is platform-defined.

Hot-adding a memory device requires this pre-defined, **static** CFMWS to have sufficient HPA space to describe that device.

There are a few common scenarios to consider.

<a id="rst-single-endpoint-memory-device-present-at-boot"></a>

### Single-Endpoint Memory Device Present at Boot

A device present at boot likely had its capacity reported in the [CEDT](</kernel/hardware/driver-api/cxl-platform-acpi/cedt.md>).  If a device is removed and a new device hotplugged, the capacity of the new device will be limited to the original CFMWS capacity.

Adding capacity larger than the original device will cause memory region creation to fail if the region size is greater than the CFMWS size.

The CFMWS is **static** and cannot be adjusted.  Platforms which may expect different sized devices to be hotplugged must allocate sufficient CFMWS space **at boot time** to cover all future expected devices.

<a id="rst-multi-endpoint-memory-device-present-at-boot"></a>

### Multi-Endpoint Memory Device Present at Boot

Non-switch-based Multi-Endpoint devices are outside the scope of what the CXL specification describes, but they are technically possible. We describe them here for instructive reasons only - this does not imply Linux support.

A hot-plug capable CXL memory device, such as one which presents multiple expanders as a single large-capacity device, should report the **maximum possible capacity** for the device at boot.



```text
             HB0
             RP0
              |
[Multi-Endpoint Memory Device]
         _____|_____
        |          |
   [Endpoint0]   [Empty]
```

Limiting the size to the capacity preset at boot will limit hot-add support to replacing capacity that was present at boot.

<a id="rst-no-cxl-device-present-at-boot"></a>

### No CXL Device Present at Boot

When no CXL memory device is present on boot, some platforms omit the CFMWS in the [CEDT](</kernel/hardware/driver-api/cxl-platform-acpi/cedt.md>).  When this occurs, hot-add is not possible.

This describes the base case for any given device not being present at boot. If a future possible device is not described in the CEDT at boot, hot-add of that device is either limited or not possible.

For a platform to support hot-add of a full memory device, it must allocate a CEDT CFMWS region with sufficient memory capacity to cover all future potentially added capacity (along with any relevant CEDT CHBS entry).

To support memory hotplug directly on the host bridge/root port, or on a switch downstream of the host bridge, a platform must construct a CEDT CFMWS at boot with sufficient resources to support the max possible (or expected) hotplug memory capacity.



```text
    HB0                 HB1
 RP0    RP1             RP2
  |      |               |
Empty  Empty            USP
                 ________|________
                 |    |    |     |
                DSP  DSP  DSP   DSP
                 |    |    |    |
                    All  Empty
```

For example, a BIOS/EFI may expose an option to configure a CEDT CFMWS with a pre-configured amount of memory capacity (per host bridge, or host bridge interleave set), even if no device is attached to Root Ports or Downstream Ports at boot (as depicted in the figure above).

<a id="rst-interleave-sets"></a>

## Interleave Sets

<a id="rst-host-bridge-interleave"></a>

### Host Bridge Interleave

Host-bridge interleaved memory regions are defined **statically** in the [CEDT](</kernel/hardware/driver-api/cxl-platform-acpi/cedt.md>).  To apply cross-host-bridge interleave, a CFMWS entry describing that interleave must have been provided **at boot**.  Hotplugged devices cannot add host-bridge interleave capabilities at hotplug time.

See the [Flexible CEDT Configuration](</kernel/hardware/driver-api/cxl-platform-example-configurations/flexible.md>) example to see how a platform can provide this kind of flexibility regarding hotplugged memory devices.  BIOS/EFI software should consider options to present flexible CEDT configurations with hotplug support.

<a id="rst-hdm-interleave"></a>

### HDM Interleave

Decoder-applied interleave can flexibly handle hotplugged devices, as decoders can be re-programmed after hotplug.

To add or remove a device to/from an existing HDM-applied interleaved region, that region must be torn down an re-created.

---

# Example Platform Configurations

_Peios Kernel / Hardware and drivers / Driver development / cxl: platform_

> Reference for Example Platform Configurations.

<a id="rst-example-platform-configurations"></a>

<!-- SPDX-License-Identifier: GPL-2.0 -->

**Contents**

- [One Device per Host Bridge](</kernel/hardware/driver-api/cxl-platform-example-configurations/one-dev-per-hb.md>)
- [Multiple Devices per Host Bridge](</kernel/hardware/driver-api/cxl-platform-example-configurations/multi-dev-per-hb.md>)
- [Cross-Host-Bridge Interleave](</kernel/hardware/driver-api/cxl-platform-example-configurations/hb-interleave.md>)
- [Flexible Presentation](</kernel/hardware/driver-api/cxl-platform-example-configurations/flexible.md>)
