Linux CXL
 help / color / mirror / Atom feed
* [PATCH v9 0/3] Support zero-sized HDM decoders
@ 2026-08-05  5:55 Richard Cheng
  2026-08-05  5:55 ` [PATCH v9 1/3] cxl/region: Simplify poison_by_decoder() error handling Richard Cheng
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Richard Cheng @ 2026-08-05  5:55 UTC (permalink / raw)
  To: jic23, dave, dave.jiang, vishal.l.verma, djbw, danwilliams,
	alison.schofield
  Cc: iweiny, ming.li, kaihengf, kobak, vaslot, mochs, newtonl,
	kristinc, linux-cxl, linux-kernel, Richard Cheng

CXL r4.0 §8.2.4.20.12 ("Committing Decoder Programming") and
§14.13.10 ("CXL HDM Decoder Zero Size Commit") permit committing an
HDM decoder with size 0. Firmware may commit and lock such decoders so
the OS cannot program regions through them; this is a platform design
choice rather than a specification requirement.

The kernel currently rejects these decoders with -ENXIO during port
enumeration and aborts enumeration of the entire port. On affected
systems, this prevents the CXL topology from appearing in userspace.

This series enumerates empty committed decoders into the topology while
keeping them out of region assembly.

Patch 1 is a preparatory cleanup with no functional change. In
poison_by_decoder(), "rc" carries both an error code and the loop
control signal for device_for_each_child(), so returning it bare is
misleading, the early guards mean "keep walking", not "no error".
Zeroing "rc" to forgive an -EFAULT on a RAM partition adds to that by
discarding what the device actually returned. Return a literal 0 where
the walk should continue, and test the forgiven case directly instead
of rewriting "rc". Patch 2 extends this function, so cleaning it up
first keeps the functional change free of unrelated churn.

Patch 2 makes zero-size DPA reservations first-class. Since the resource
tree cannot represent an empty range, an empty decoder is backed by a
separately allocated resource. This keeps port->hdm_end, skip handling,
and in-order DPA accounting consistent. Operations requiring non-empty
capacity, including region attachment and poison queries, are guarded
appropriately.

Patch 3 adds the mock_zero_size_decoders cxl_test module parameter,
disabled by default. When enabled, it installs committed, locked,
zero-sized endpoint, switch, and host-bridge decoders under
host-bridge0.

Tested on arm64 with cxl_test and the ndctl unit suite (ndctl
v85), on a kernel built with KASAN and lockdep enabled.

Full cxl suite with mock_zero_size_decoders off:
"""
 1/16 ndctl:cxl / cxl-topology.sh       OK                7.50s
 2/16 ndctl:cxl / cxl-region-sysfs.sh   OK                5.29s
 3/16 ndctl:cxl / cxl-labels.sh         OK                3.44s
 4/16 ndctl:cxl / cxl-create-region.sh  OK                9.97s
 5/16 ndctl:cxl / cxl-xor-region.sh     OK                5.77s
 6/16 ndctl:cxl / cxl-events.sh         OK                2.89s
 7/16 ndctl:cxl / cxl-sanitize.sh       OK                5.74s
 8/16 ndctl:cxl / cxl-destroy-region.sh OK                3.84s
 9/16 ndctl:cxl / cxl-qos-class.sh      OK                3.22s
10/16 ndctl:cxl / cxl-translate.sh      OK                0.95s
11/16 ndctl:cxl / cxl-elc.sh            OK                4.22s
12/16 ndctl:cxl / cxl-dax-hmem.sh       OK                4.60s
13/16 ndctl:cxl / cxl-region-replay.sh  OK                8.74s
14/16 ndctl:cxl / cxl-security.sh       OK                1.83s
15/16 ndctl:cxl / cxl-features.sh       OK                1.45s
16/16 ndctl:cxl / cxl-poison.sh         SKIP             11.66s

Ok:                 15
Expected Fail:      0
Fail:               0
Unexpected Pass:    0
Skipped:            1
Timeout:            0
"""

The reason that cxl-poison.sh is skipped is stated in
https://lore.kernel.org/linux-cxl/anKpY6Y1Sqne1f7Y@MWDK4CY14F/

Both run_poison_test() rounds pass, so everything this series touches is
covered, only the unaligned translation section is unreachable, and the
series does not touch translation.

The core patch was also previously validated on a Montage CXL Type 3
device.

The corresponding ndctl test is attached at
https://lore.kernel.org/linux-cxl/20260709022857.18732-1-icheng@nvidia.com/


Changelog:

v8->v9:
- Patch 1: add a poison_efault_forgiven() helper and use it in
  cxl_get_poison_unmapped() as well.
- Patch 2: rebased on that helper, no functional change.
- Patch 3: no change.
- Fixed the test environment so cxl-security.sh runs and passes; the
  suite is now 15 OK / 1 SKIP. cxl-poison.sh still skips, see above.

v7->v8:
- Split the poison_by_decoder() readability cleanup out of the core
  patch into a new preparatory patch 1.
- cxl_dpa_request_region(): split the declaration from the allocation
  so the allocation and its error check sit together.
- Add the missing blank line between commit message paragraphs in
  patch 2.
- Patch 3 is unchanged.

v6->v7:
- Rebase onto cxl/for-7.3/cxl-type2-test.
- Patch 1 is unchanged.
- Adapt patch 2 to the refactored Type-2/Type-3 decoder initialization
  paths.
- Integrate mock_zero_size_decoders with special-topology parameter
  validation and reject its incompatible use with fail_autoassemble.


Richard Cheng (3):
  cxl/region: Simplify poison_by_decoder() error handling
  cxl/hdm: Allow zero sized HDM decoders
  tools/testing/cxl: Enable zero sized decoders under hb0

 drivers/cxl/core/hdm.c       |  55 ++++++++++++------
 drivers/cxl/core/mbox.c      |   3 +
 drivers/cxl/core/region.c    |  69 ++++++++++++++--------
 drivers/cxl/cxl.h            |  10 ++++
 drivers/cxl/port.c           |   3 +
 tools/testing/cxl/test/cxl.c | 109 ++++++++++++++++++++++++++++++-----
 6 files changed, 193 insertions(+), 56 deletions(-)


base-commit: 1c6b4ceafc3b994871c29340e0c1ddb0af5800e7
-- 
2.43.0


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-08-05  6:09 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-05  5:55 [PATCH v9 0/3] Support zero-sized HDM decoders Richard Cheng
2026-08-05  5:55 ` [PATCH v9 1/3] cxl/region: Simplify poison_by_decoder() error handling Richard Cheng
2026-08-05  6:09   ` sashiko-bot
2026-08-05  5:55 ` [PATCH v9 2/3] cxl/hdm: Allow zero sized HDM decoders Richard Cheng
2026-08-05  6:09   ` sashiko-bot
2026-08-05  5:55 ` [PATCH v9 3/3] tools/testing/cxl: Enable zero sized decoders under hb0 Richard Cheng

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox