mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Muralidhara M K <muralidhara.mk@amd.com>
To: <ilpo.jarvinen@linux.intel.com>
Cc: <mario.limonciello@amd.com>,
	<platform-driver-x86@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>,
	Muralidhara M K <muralidhara.mk@amd.com>
Subject: [PATCH v3 0/2] platform/x86/amd/hsmp: Validate num_args and Report raw SMU mailbox status
Date: Tue, 1 Dec 2026 16:01:00 +0530	[thread overview]
Message-ID: <20261201103102.601993-1-muralidhara.mk@amd.com> (raw)

This series adds a __u16 smu_response field to struct hsmp_message and
struct hsmp_telemetry_data, so userspace can inspect the raw SMU
mailbox status instead of only the translated errno.

Patch 1 is a preparatory fix: hsmp_ioctl_msg()'s fd-mode gate calls
is_get_msg(), which reads msg.args[0], before checking that num_args
matches the message descriptor, so a request with no args can still
reach that read. Validate num_args first.

Patch 2 adds smu_response to both structs, set from the polled SMU
mailbox status register, and has hsmp_ioctl_msg() always copy the
message struct back to userspace, even on failure, so smu_response is
visible on every call. It also fixes a related copy_to_user()
error-check bug in hsmp_ioctl_get_telemetry() uncovered along the way.

smu_response is __u16, matching the width of existing spare padding
in both structs, so sizeof(struct hsmp_message), sizeof(struct
hsmp_telemetry_data), and the encoded HSMP_IOCTL_CMD command number
are unchanged. HSMP_IOCTL_GET_TELEMETRY_DATA is switched from _IOW to
_IOWR, since the kernel now writes smu_response back into the request
struct.

v3:
  - Reverted smu_response from __u32 back to __u16: the mailbox
    status register is accessed as __u32 purely because that is the
    SMN/MMIO bus access granularity shared by all mailbox registers,
    not because the status value itself needs 32 bits. Every documented
    HSMP status/error code fits in a single byte, so __u16 is lossless
    and avoids the ABI break (struct size / ioctl command number change)
    that __u32 would have introduced.
  - Fixed a redundant whitespace-only diff in
    Documentation/arch/x86/amd_hsmp.rst where the struct hsmp_message
    code block had been reformatted from tabs to spaces; restored the
    original tab alignment so only the smu_response line shows as new.

Each patch builds individually and is clean under checkpatch.pl
--strict.

Muralidhara M K (2):
  platform/x86/amd/hsmp: Validate num_args before the fd-mode gate in
    hsmp_ioctl_msg()
  platform/x86/amd/hsmp: Report raw SMU mailbox status via smu_response

 Documentation/arch/x86/amd_hsmp.rst  |  23 +++++-
 arch/x86/include/uapi/asm/amd_hsmp.h |  25 ++++--
 drivers/platform/x86/amd/hsmp/hsmp.c | 117 +++++++++++++++++----------
 3 files changed, 114 insertions(+), 51 deletions(-)


base-commit: 9437ee8b6cf607e883b36e44bd755968daaebd48
-- 
2.34.1


             reply	other threads:[~2026-12-01 10:31 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-01 10:31 Muralidhara M K [this message]
2026-12-01 10:31 ` [PATCH v3 1/2] platform/x86/amd/hsmp: Validate num_args before the fd-mode gate in hsmp_ioctl_msg() Muralidhara M K
2026-12-01 10:31 ` [PATCH v3 2/2] platform/x86/amd/hsmp: Report raw SMU mailbox status via smu_response Muralidhara M K

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261201103102.601993-1-muralidhara.mk@amd.com \
    --to=muralidhara.mk@amd.com \
    --cc=ilpo.jarvinen@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mario.limonciello@amd.com \
    --cc=platform-driver-x86@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®