From: Adam Young <adam@younglogic.com>
To: Sudeep Holla <sudeep.holla@kernel.org>,
Jassi Brar <jassisinghbrar@gmail.com>,
linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: Huisong Li <lihuisong@huawei.com>
Subject: Re: [PATCH v2 2/3] mailbox: pcc: Check shared memory signature on request
Date: Sun, 26 Jul 2026 01:34:02 -0400 [thread overview]
Message-ID: <12ea5f8e-2c05-4499-857a-727e3df1e98f@younglogic.com> (raw)
In-Reply-To: <20260723143928.2625970-3-sudeep.holla@kernel.org>
On 7/23/26 10:39, Sudeep Holla wrote:
> ACPI 6.6 Tables 14.9 and 14.12 define the PCC shared memory
> signature as the bitwise OR of 0x50434300 and the PCC subspace ID.
> They also clarify that the signature is populated by the platform and
> verified by OSPM. The signature is at byte offset 0 in the generic,
> extended and reduced PCC shared memory layouts.
>
> Check the signature when a client requests a PCC mailbox channel,
> after mapping shared memory and before binding the mailbox client.
> This keeps the check in the PCC mailbox controller instead of
> duplicating it in individual clients.
>
> Treat a signature mismatch as a warning rather than rejecting the
> channel request. Making this newly added check fatal could break
> existing systems whose firmware did not populate the signature
> correctly even though PCC communication works. Continue to reject
> shared memory that is too small to contain a signature because it
> cannot be inspected safely.
>
> Cc: Jassi Brar <jassisinghbrar@gmail.com>
> Cc: Huisong Li <lihuisong@huawei.com>
> Signed-off-by: Sudeep Holla <sudeep.holla@kernel.org>
> ---
> drivers/mailbox/pcc.c | 36 +++++++++++++++++++++++++++++++-----
> 1 file changed, 31 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/mailbox/pcc.c b/drivers/mailbox/pcc.c
> index d96b8b54e77e..8dfa80b0a90f 100644
> --- a/drivers/mailbox/pcc.c
> +++ b/drivers/mailbox/pcc.c
> @@ -345,6 +345,26 @@ static irqreturn_t pcc_mbox_irq(int irq, void *p)
> return IRQ_HANDLED;
> }
>
> +static int pcc_mbox_validate_signature(struct pcc_mbox_chan *pcc_mchan,
> + int subspace_id)
> +{
> + u32 expected_signature = PCC_SIGNATURE | subspace_id;
> + u32 signature;
> +
> + if (pcc_mchan->shmem_size < sizeof(signature)) {
> + pr_err("PCC subspace %d shared memory is too small\n",
> + subspace_id);
> + return -EINVAL;
> + }
> +
> + signature = ioread32(pcc_mchan->shmem);
> + if (signature != expected_signature)
> + pr_warn("PCC subspace %d invalid signature %#x expected %#x\n",
> + subspace_id, signature, expected_signature);
> +
> + return 0;
> +}
> +
> /**
> * pcc_mbox_request_channel - PCC clients call this function to
> * request a pointer to their PCC subspace, from which they
> @@ -381,14 +401,20 @@ pcc_mbox_request_channel(struct mbox_client *cl, int subspace_id)
> if (!pcc_mchan->shmem)
> return ERR_PTR(-ENXIO);
>
> + rc = pcc_mbox_validate_signature(pcc_mchan, subspace_id);
> + if (rc)
> + goto err_unmap_shmem;
> +
> rc = mbox_bind_client(chan, cl);
> - if (rc) {
> - iounmap(pcc_mchan->shmem);
> - pcc_mchan->shmem = NULL;
> - return ERR_PTR(rc);
> - }
> + if (rc)
> + goto err_unmap_shmem;
>
> return pcc_mchan;
> +
> +err_unmap_shmem:
> + iounmap(pcc_mchan->shmem);
> + pcc_mchan->shmem = NULL;
> + return ERR_PTR(rc);
> }
> EXPORT_SYMBOL_GPL(pcc_mbox_request_channel);
>
Tested_by: Adam Young <admiyo@os.amperecomputing.com>
next prev parent reply other threads:[~2026-07-26 5:57 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-23 14:39 [PATCH v2 0/3] mailbox: pcc: Improve completion handling and validation Sudeep Holla
2026-07-23 14:39 ` [PATCH v2 1/3] mailbox: pcc: Notify clients on polled completion Sudeep Holla
2026-07-26 5:32 ` Adam Young
2026-07-23 14:39 ` [PATCH v2 2/3] mailbox: pcc: Check shared memory signature on request Sudeep Holla
2026-07-26 5:34 ` Adam Young [this message]
2026-07-23 14:39 ` [PATCH v2 3/3] mailbox: pcc: Fix command timeout due to missed interrupt Sudeep Holla
2026-07-26 5:33 ` Adam Young
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=12ea5f8e-2c05-4499-857a-727e3df1e98f@younglogic.com \
--to=adam@younglogic.com \
--cc=jassisinghbrar@gmail.com \
--cc=lihuisong@huawei.com \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=sudeep.holla@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®