[PATCH v3 0/5] platform/x86/amd/hsmp: ACPI/platform HSMP concurrency and lifecycle hardening

From: Muralidhara M K

Date: Mon Jul 06 2026 - 10:37:34 EST


This series hardens the AMD HSMP ACPI and platform drivers against
probe/remove concurrency, use-after-free of the per-socket state, and
resource leaks across unbind/rebind cycles.

On multi-socket systems several ACPI platform devices are probed and
removed independently while a single /dev/hsmp (and the hwmon sysfs
attributes) drive a lock-free data plane. The existing code raced the
global is_probed handshake and the one-time socket allocation, freed the
socket array from under in-flight hsmp_send_message() callers, and leaked
metric-table mappings on rebind.

The patches, in order:

1. Serialize ACPI probe/remove/init_acpi() with a dedicated mutex so
the is_probed handshake and the one-time socket allocation cannot
race across per-socket platform devices.
2. Map the metric-table DRAM explicitly and add per-socket mutexes.
3. Add hsmp_sock_rwsem so the lock-free data plane is drained and kept
out while a socket is torn down; wire the non-ACPI platform path
into it.
4. Refcount the ACPI socket platform devices with struct kref and run a
coordinated release on the final put (deregister /dev/hsmp, unmap
metric DRAM, free the socket array); clear the per-socket dev under
the teardown write lock on both remove and probe failure.
5. Drop any stale metric-table mapping before remapping on rebind.

Testing:
- Each patch builds individually (W=1) with no new warnings; the series
is bisectable.
- checkpatch.pl --strict is clean on every patch.

Changes since v2:
- This revision covers only the five ACPI/platform probe, teardown, and
lifecycle patches. The ACPI UID / _DSD mailbox validation and the
sock->dev readiness-gate changes from v2 are accepted in maintainer branch.
- Reworded the teardown rwsem comments in "Serialize the data plane
against socket teardown" so they describe the drain contract in terms
of a generic teardown path (a teardown path takes the write side)
rather than attributing it to the ACPI path, which is wired into the
drain in the following patch.

v2: https://patch.msgid.link/20260625123337.886435-1-muralidhara.mk@xxxxxxx

Muralidhara M K (5):
platform/x86/amd/hsmp: Serialize ACPI HSMP is_probed with a probe
mutex
platform/x86/amd/hsmp: Add explicit metric DRAM mapping and per-socket
mutexes
platform/x86/amd/hsmp: Serialize the data plane against socket
teardown
platform/x86/amd/hsmp: ACPI HSMP refcounted sockets and coordinated
release
platform/x86/amd/hsmp: Drop stale metric table mapping on rebind

drivers/platform/x86/amd/hsmp/acpi.c | 147 ++++++++++++++++++++++++---
drivers/platform/x86/amd/hsmp/hsmp.c | 112 ++++++++++++++++++--
drivers/platform/x86/amd/hsmp/hsmp.h | 11 +-
drivers/platform/x86/amd/hsmp/plat.c | 39 ++++++-
4 files changed, 285 insertions(+), 24 deletions(-)


base-commit: ff7836fa850c2f815bc219f1e48f6ec8699f4ae7
--
2.34.1