[PATCH v2 0/2] Support zero-sized HDM decoders

From: Richard Cheng

Date: Tue Jun 02 2026 - 01:42:46 EST


Hello,

This v2 picks up Vishal Aslot's "Support zero-sized decoders" series [1]
and addresses the review feedback, if any SoB or credits have mistake,
please let me know, I'll correct them.

CXL r3.2 §8.2.4.20.12 and §14.13.10 permit committing an HDM decoder
with size 0. BIOS uses this together with LOCK to burn decoder slots so
the OS cannot program new regions through them — e.g. for a Type 3
device in a Trusted Computing Base (TCB) established via the Trusted
Security Protocol (TSP).

init_hdm_decoder() today rejects committed zero-size decoders with
-ENXIO during port enumeration, which aborts the whole port — affected
systems show nothing under 'cxl list'. Patch 1 lets these decoders be
enumerated normally so they appear in topology with their HW-reported
LOCK state. Patch 2 extends cxl_test to inject zero-size + locked
decoders under host-bridge 0 so the new code path has in-tree coverage.

A note on Alison's v1 concern about autoregion teardown being blocked
by locked zero-size decoders sitting above the autoregion: this does
not actually fire with v2's "add to topology" approach. The existing
cxl_decoder_reset() already returns early on CXL_DECODER_F_LOCK and
tolerates out-of-order reset of the unlocked autoregion.
port->commit_end staying at its watermark after teardown
maps to physical reality — the slots above are permanently burned by
the locked decoders. No reset-path patch is therefore needed in v2.

Changes since v1:
- Reorder: implementation patch first, cxl_test patch second
- Patch 1: drop -ENOSPC sentinel and the matching "continue"
in devm_cxl_enumerate_decoders(). The decoder is now added
to the topology so "cxl list" shows it.
Move port->commit_end assignment before the size check so
later contiguous decoders pass the out-of-order check. Add
an early return before devm_cxl_dpa_reserve().
- Patch 2: replace second_decoder() / third_decoder() with a single
match_decoder_by_index() helper. Use CXL_DECODER_STATE_MANUAL
instead of STATE_AUTO. Set CXL_DECODER_F_LOCK on the mock zero-size
decoders to model the BIOS-burns-slots case.

[1]:
https://lore.kernel.org/all/20251015024019.1189713-1-vaslot@xxxxxxxxxx/T/#u

Richard Cheng (2):
cxl/hdm: Allow zero sized HDM decoders
tools/testing/cxl: Enable zero sized decoders under hb0

drivers/cxl/core/hdm.c | 15 ++++---
tools/testing/cxl/test/cxl.c | 79 +++++++++++++++++++++++++++++++-----
2 files changed, 78 insertions(+), 16 deletions(-)


base-commit: eb3f4b7426cfd2b79d65b7d37155480b32259a11
--
2.43.0