[PATCH v2 0/7] platform/x86/amd/hsmp: ACPI/platform HSMP concurrency and lifecycle hardening
From: Muralidhara M K
Date: Thu Jun 25 2026 - 08:35:42 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, published
the per-socket readiness gate before the mailbox was mapped, 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.
2. Validate the ACPI UID and _DSD mailbox package against malformed
firmware before dereferencing them.
3. Map the metric-table DRAM explicitly and add per-socket mutexes.
4. Publish sock->dev last with smp_store_release() and read it with
smp_load_acquire() so a message can never reach a socket still in
bring-up.
5. Add hsmp_sock_rwsem so the lock-free data plane is drained and kept
out while a socket is torn down; wire the platform path into it.
6. 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 per-socket dev under the
teardown write lock on remove and probe failure.
7. 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 v1:
- Split the work into smaller, single-purpose patches for review.
- Added ACPI UID / _DSD mailbox package validation (new patch).
- Replaced the synchronous devm free of the socket array with a kref
based, coordinated release and serialized it against the data plane
via a new rwsem; clear the per-socket dev under the write lock on
both remove and probe-failure paths.
- Added smp_store_release()/smp_load_acquire() ordering on sock->dev so
the readiness gate cannot be observed before the mailbox is mapped.
- Wired the non-ACPI platform path into the same teardown drain and
fixed the metric-table mapping leak on unbind/rebind.
v1: https://lore.kernel.org/platform-driver-x86/eb609912-1c42-6354-22e6-5ffd1f097e9f@xxxxxxxxxxxxxxx/T/#t
Muralidhara M K (7):
platform/x86/amd/hsmp: Serialize ACPI HSMP is_probed with a probe
mutex
platform/x86/amd/hsmp: Validate ACPI UID and _DSD mailbox package
platform/x86/amd/hsmp: Add explicit metric DRAM mapping and per-socket
mutexes
platform/x86/amd/hsmp: Gate the data plane on a fully initialized
socket
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 | 188 +++++++++++++++++++++++----
drivers/platform/x86/amd/hsmp/hsmp.c | 116 ++++++++++++++++-
drivers/platform/x86/amd/hsmp/hsmp.h | 11 +-
drivers/platform/x86/amd/hsmp/plat.c | 39 +++++-
4 files changed, 318 insertions(+), 36 deletions(-)
--
2.43.0