From: Suma Hegde <Suma.Hegde@amd.com>
To: Muralidhara M K <muralidhara.mk@amd.com>,
ilpo.jarvinen@linux.intel.com, gregkh@linuxfoundation.org,
rafael@kernel.org
Cc: platform-driver-x86@vger.kernel.org,
linux-kernel@vger.kernel.org, driver-core@lists.linux.dev,
Muthusamy Ramalingam <muthusamy.ramalingam@amd.com>
Subject: Re: [PATCH v2 3/7] platform/x86/amd/hsmp: Unify response_sz validation to an upper-bound check
Date: Fri, 8 May 2026 10:43:06 +0530 [thread overview]
Message-ID: <b8e2bb91-720f-40ca-9fb0-d680ace97272@amd.com> (raw)
In-Reply-To: <20260427155129.545327-4-muralidhara.mk@amd.com>
Reviewed-by: Suma Hegde <suma.hegde@amd.com>
On 4/27/2026 9:21 PM, Muralidhara M K wrote:
> Caution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.
>
>
> The original validate_message() enforced a strict equality check
> (response_sz != table.response_sz) for HSMP_SET and HSMP_GET messages,
> while only HSMP_SET_GET messages used a relaxed upper-bound check.
>
> As HSMP protocol versions increase, existing message IDs may gain
> additional response arguments on newer platforms. The strict equality
> check rejects older userspace callers that were compiled against an
> earlier hsmp_msg_desc_table[] and request fewer response words than the
> current table defines, breaking backward compatibility unnecessarily.
>
> Replace the per-type branching with a single upper-bound check for all
> message types. This allows older userspace to request fewer response
> words while still rejecting any request that exceeds the hardware
> capability defined in the descriptor table.
>
> Co-developed-by: Muthusamy Ramalingam <muthusamy.ramalingam@amd.com>
> Signed-off-by: Muthusamy Ramalingam <muthusamy.ramalingam@amd.com>
> Signed-off-by: Muralidhara M K <muralidhara.mk@amd.com>
> ---
> Change v1->v2: New
>
> drivers/platform/x86/amd/hsmp/hsmp.c | 21 ++++++++-------------
> 1 file changed, 8 insertions(+), 13 deletions(-)
>
> diff --git a/drivers/platform/x86/amd/hsmp/hsmp.c b/drivers/platform/x86/amd/hsmp/hsmp.c
> index 631ffc0978d1..9bad58fef304 100644
> --- a/drivers/platform/x86/amd/hsmp/hsmp.c
> +++ b/drivers/platform/x86/amd/hsmp/hsmp.c
> @@ -182,20 +182,15 @@ static int validate_message(struct hsmp_message *msg)
> return -EINVAL;
>
> /*
> - * Some older HSMP SET messages are updated to add GET in the same message.
> - * In these messages, GET returns the current value and SET also returns
> - * the successfully set value. To support this GET and SET in same message
> - * while maintaining backward compatibility for the HSMP users,
> - * hsmp_msg_desc_table[] indicates only maximum allowed response_sz.
> + * As the HSMP protocol evolves, newer platforms may define more
> + * response arguments for existing messages. Use an upper-bound
> + * check so that older userspace callers requesting fewer response
> + * words than what the current hsmp_msg_desc_table[] defines are
> + * still accepted, while rejecting requests that exceed the
> + * hardware capability.
> */
> - if (hsmp_msg_desc_table[msg->msg_id].type == HSMP_SET_GET) {
> - if (msg->response_sz > hsmp_msg_desc_table[msg->msg_id].response_sz)
> - return -EINVAL;
> - } else {
> - /* only HSMP_SET or HSMP_GET messages go through this strict check */
> - if (msg->response_sz != hsmp_msg_desc_table[msg->msg_id].response_sz)
> - return -EINVAL;
> - }
> + if (msg->response_sz > hsmp_msg_desc_table[msg->msg_id].response_sz)
> + return -EINVAL;
> return 0;
> }
>
> --
> 2.34.1
>
>
next prev parent reply other threads:[~2026-05-08 5:13 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-27 15:51 [PATCH v2 0/7] AMD HSMP: metrics table improvements and Family 1Ah Model 50h-5Fh support Muralidhara M K
2026-04-27 15:51 ` [PATCH v2 1/7] platform/x86/amd/hsmp: Add new HSMP messages for Family 1Ah, Model 50h-5Fh Muralidhara M K
2026-05-11 17:35 ` Ilpo Järvinen
2026-05-12 6:21 ` M K, Muralidhara
2026-04-27 15:51 ` [PATCH v2 2/7] platform/x86/amd/hsmp: Add metrics table support for Family 1Ah " Muralidhara M K
2026-05-08 5:12 ` Suma Hegde
2026-05-11 17:38 ` Ilpo Järvinen
2026-05-12 6:24 ` M K, Muralidhara
2026-04-27 15:51 ` [PATCH v2 3/7] platform/x86/amd/hsmp: Unify response_sz validation to an upper-bound check Muralidhara M K
2026-05-08 5:13 ` Suma Hegde [this message]
2026-04-27 15:51 ` [PATCH v2 4/7] sysfs: Add SYSFS_HUGE_BIN_FILE flag for binary attributes larger than PAGE_SIZE Muralidhara M K
2026-04-28 7:20 ` K Prateek Nayak
2026-05-12 6:28 ` M K, Muralidhara
2026-05-12 11:44 ` Ilpo Järvinen
2026-05-13 3:59 ` K Prateek Nayak
2026-05-12 12:01 ` Greg KH
2026-05-13 4:13 ` K Prateek Nayak
2026-05-13 6:24 ` Greg KH
2026-05-13 6:36 ` K Prateek Nayak
2026-05-13 7:18 ` Greg KH
2026-05-14 14:13 ` M K, Muralidhara
2026-04-27 15:51 ` [PATCH v2 5/7] platform/x86/amd/hsmp: Add dynamic table size for metric table Muralidhara M K
2026-04-27 15:51 ` [PATCH v2 6/7] platform/x86/amd/hsmp: Make metric table read locking use guard(mutex) Muralidhara M K
2026-05-11 17:27 ` Ilpo Järvinen
2026-05-12 6:26 ` M K, Muralidhara
2026-04-27 15:51 ` [PATCH v2 7/7] platform/x86/amd/hsmp: Support SYSFS_HUGE_BIN_FILE for metric table reads Muralidhara M K
2026-05-11 11:20 ` [PATCH v2 0/7] AMD HSMP: metrics table improvements and Family 1Ah Model 50h-5Fh support M K, Muralidhara
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=b8e2bb91-720f-40ca-9fb0-d680ace97272@amd.com \
--to=suma.hegde@amd.com \
--cc=driver-core@lists.linux.dev \
--cc=gregkh@linuxfoundation.org \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=muralidhara.mk@amd.com \
--cc=muthusamy.ramalingam@amd.com \
--cc=platform-driver-x86@vger.kernel.org \
--cc=rafael@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.