[PATCH v8 1/4] platform/x86/amd/hsmp: Recognize Family 1Ah client platforms and hide server-only paths

From: Muralidhara M K

Date: Fri Oct 09 2026 - 02:20:45 EST


Add is_client_platform(), based on the ACPI-reported PM profile and
an AMD vendor check, to detect Family 1Ah client platforms, Models
80h-8Fh and E0h-E3h.

Use is_client_platform() to:

- Hide every ACPI sysfs device attribute except smu_fw_version and
protocol_version on client platforms.
- Hide the metrics_bin sysfs binary attribute on client platforms.
- Skip hsmp_create_sensor() in init_acpi() on client platforms.
- Exclude client platforms from the HSMP_GET_METRIC_TABLE_DRAM_ADDR
lookup in init_acpi().
- Register /dev/hsmp at 0600 on client platforms, 0644 on server.

Signed-off-by: Muralidhara M K <muralidhara.mk@xxxxxxx>
---
drivers/platform/x86/amd/hsmp/acpi.c | 24 +++++++++++++++++++-----
drivers/platform/x86/amd/hsmp/hsmp.c | 8 +++++++-
drivers/platform/x86/amd/hsmp/hsmp.h | 23 +++++++++++++++++++++++
3 files changed, 49 insertions(+), 6 deletions(-)

diff --git a/drivers/platform/x86/amd/hsmp/acpi.c b/drivers/platform/x86/amd/hsmp/acpi.c
index ddd7a04ee753..1e5028aea54b 100644
--- a/drivers/platform/x86/amd/hsmp/acpi.c
+++ b/drivers/platform/x86/amd/hsmp/acpi.c
@@ -300,16 +300,26 @@ static umode_t hsmp_is_sock_attr_visible(struct kobject *kobj,
* so that userspace which expects the file to exist gets a clear
* -EOPNOTSUPP from the read handler instead of -ENOENT, and is
* pointed at HSMP_IOCTL_GET_TELEMETRY_DATA as the supported path.
+ * Hide metrics_bin on client platforms.
*/
- if (hsmp_pdev->proto_ver >= HSMP_PROTO_VER6)
+ if (!is_client_platform() && hsmp_pdev->proto_ver >= HSMP_PROTO_VER6)
return battr->attr.mode;

return 0;
}

+/* Defined below by HSMP_DEV_ATTR() */
+static struct hsmp_sys_attr hattr_smu_fw_version;
+static struct hsmp_sys_attr hattr_protocol_version;
+
static umode_t hsmp_is_sock_dev_attr_visible(struct kobject *kobj,
struct attribute *attr, int id)
{
+ /* Hide every attribute except smu_fw_version and protocol_version on client platforms */
+ if (is_client_platform() && attr != &hattr_smu_fw_version.dattr.attr &&
+ attr != &hattr_protocol_version.dattr.attr)
+ return 0;
+
return attr->mode;
}

@@ -557,15 +567,19 @@ static int init_acpi(struct device *dev)
return ret;
}

- if (hsmp_pdev->proto_ver >= HSMP_PROTO_VER6) {
+ /* Exclude client platforms from the metric table DRAM base lookup */
+ if (!is_client_platform() && hsmp_pdev->proto_ver >= HSMP_PROTO_VER6) {
ret = hsmp_get_tbl_dram_base(sock_ind);
if (ret)
dev_info(dev, "Failed to init metric table\n");
}

- ret = hsmp_create_sensor(dev, sock_ind);
- if (ret)
- dev_info(dev, "Failed to register HSMP sensors with hwmon\n");
+ /* Skip hwmon registration on client platforms */
+ if (!is_client_platform()) {
+ ret = hsmp_create_sensor(dev, sock_ind);
+ if (ret)
+ dev_info(dev, "Failed to register HSMP sensors with hwmon\n");
+ }

dev_set_drvdata(dev, &hsmp_pdev->sock[sock_ind]);

diff --git a/drivers/platform/x86/amd/hsmp/hsmp.c b/drivers/platform/x86/amd/hsmp/hsmp.c
index 5e123a4ecea9..d32d5a907aae 100644
--- a/drivers/platform/x86/amd/hsmp/hsmp.c
+++ b/drivers/platform/x86/amd/hsmp/hsmp.c
@@ -720,7 +720,13 @@ int hsmp_misc_register(struct device *dev)
*/
hsmp_pdev.mdev.parent = dev;
hsmp_pdev.mdev.nodename = HSMP_DEVNODE_NAME;
- hsmp_pdev.mdev.mode = 0644;
+ /*
+ * hsmp_msg_desc_table[] only describes server messages. On client
+ * platforms, msg_id mappings differ, making access checks unreliable.
+ * Restrict /dev/hsmp to root until client-specific validation is
+ * added.
+ */
+ hsmp_pdev.mdev.mode = is_client_platform() ? 0600 : 0644;

return misc_register(&hsmp_pdev.mdev);
}
diff --git a/drivers/platform/x86/amd/hsmp/hsmp.h b/drivers/platform/x86/amd/hsmp/hsmp.h
index 8dbff16a87b1..62ba795dc8c5 100644
--- a/drivers/platform/x86/amd/hsmp/hsmp.h
+++ b/drivers/platform/x86/amd/hsmp/hsmp.h
@@ -10,6 +10,9 @@
#ifndef HSMP_H
#define HSMP_H

+#include <asm/amd/hsmp.h>
+
+#include <linux/acpi.h>
#include <linux/compiler_types.h>
#include <linux/device.h>
#include <linux/hwmon.h>
@@ -17,6 +20,7 @@
#include <linux/miscdevice.h>
#include <linux/mutex.h>
#include <linux/pci.h>
+#include <linux/processor.h>
#include <linux/rwsem.h>
#include <linux/semaphore.h>
#include <linux/sysfs.h>
@@ -32,6 +36,25 @@

#define DRIVER_VERSION "2.6"

+/* True when the ACPI-reported PM profile indicates a client platform */
+static inline bool is_client_platform(void)
+{
+ if (!IS_ENABLED(CONFIG_ACPI))
+ return false;
+
+ if (boot_cpu_data.x86_vendor != X86_VENDOR_AMD)
+ return false;
+
+ switch (acpi_gbl_FADT.preferred_profile) {
+ case PM_DESKTOP:
+ case PM_MOBILE:
+ case PM_TABLET:
+ return true;
+ default:
+ return false;
+ }
+}
+
struct hsmp_mbaddr_info {
u32 base_addr;
u32 msg_id_off;
--
2.34.1