The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH v2 0/7] platform/x86/amd/hsmp: ACPI/platform HSMP concurrency and lifecycle hardening
@ 2026-06-25 12:33 Muralidhara M K
  2026-06-25 12:33 ` [PATCH v2 1/7] platform/x86/amd/hsmp: Serialize ACPI HSMP is_probed with a probe mutex Muralidhara M K
                   ` (6 more replies)
  0 siblings, 7 replies; 12+ messages in thread
From: Muralidhara M K @ 2026-06-25 12:33 UTC (permalink / raw)
  To: ilpo.jarvinen
  Cc: muthusamy.ramalingam, platform-driver-x86, linux-kernel,
	Muralidhara M K

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@linux.intel.com/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


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

end of thread, other threads:[~2026-07-06 15:29 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-25 12:33 [PATCH v2 0/7] platform/x86/amd/hsmp: ACPI/platform HSMP concurrency and lifecycle hardening Muralidhara M K
2026-06-25 12:33 ` [PATCH v2 1/7] platform/x86/amd/hsmp: Serialize ACPI HSMP is_probed with a probe mutex Muralidhara M K
2026-06-25 12:33 ` [PATCH v2 2/7] platform/x86/amd/hsmp: Validate ACPI UID and _DSD mailbox package Muralidhara M K
2026-06-26 10:03   ` Ilpo Järvinen
2026-06-25 12:33 ` [PATCH v2 3/7] platform/x86/amd/hsmp: Add explicit metric DRAM mapping and per-socket mutexes Muralidhara M K
2026-07-06 11:51   ` Ilpo Järvinen
2026-06-25 12:33 ` [PATCH v2 4/7] platform/x86/amd/hsmp: Gate the data plane on a fully initialized socket Muralidhara M K
2026-06-25 12:33 ` [PATCH v2 5/7] platform/x86/amd/hsmp: Serialize the data plane against socket teardown Muralidhara M K
2026-07-06 11:41   ` Ilpo Järvinen
2026-07-06 15:29     ` M K, Muralidhara
2026-06-25 12:33 ` [PATCH v2 6/7] platform/x86/amd/hsmp: ACPI HSMP refcounted sockets and coordinated release Muralidhara M K
2026-06-25 12:33 ` [PATCH v2 7/7] platform/x86/amd/hsmp: Drop stale metric table mapping on rebind Muralidhara M K

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