[PATCH v2 3/3] firmware: qcom_scm: align PAS resource table retry

From: Mukesh Ojha

Date: Mon Sep 21 2026 - 16:02:36 EST


The initial PAS resource-table buffer can be too small. TrustZone
returns the required size and the wrapper retries the SCM call.
Although qcom_tzmem_alloc() aligns the allocated buffer,
the size passed to TrustZone remained unaligned.

Align the retry size to a page boundary so that both the buffer
and its advertised size satisfy the PAS/TrustZone contract.

Fixes: 8b9d2050cfa0 ("firmware: qcom_scm: Add qcom_scm_pas_get_rsc_table() to get resource table")
Signed-off-by: Mukesh Ojha <mukesh.ojha@xxxxxxxxxxxxxxxx>
---
Changes in v2:
- New change.

drivers/firmware/qcom/qcom_scm.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/firmware/qcom/qcom_scm.c b/drivers/firmware/qcom/qcom_scm.c
index b5959f833dd7..f4442a70e614 100644
--- a/drivers/firmware/qcom/qcom_scm.c
+++ b/drivers/firmware/qcom/qcom_scm.c
@@ -812,12 +812,14 @@ static void *qcom_scm_pas_get_rsc_table(struct device *dev,
output_rt_tzm = __qcom_scm_pas_get_rsc_table(dev, ctx->pas_id,
input_rt_tzm,
input_rt_size, &size);
- if (PTR_ERR(output_rt_tzm) == -EOVERFLOW)
- /* Try again with the size requested by the TZ */
+ if (PTR_ERR(output_rt_tzm) == -EOVERFLOW) {
+ /* Try again with a page-aligned size requested by the TZ. */
+ size = PAGE_ALIGN(size);
output_rt_tzm = __qcom_scm_pas_get_rsc_table(dev, ctx->pas_id,
input_rt_tzm,
input_rt_size,
&size);
+ }
if (IS_ERR(output_rt_tzm)) {
ret = PTR_ERR(output_rt_tzm);
goto free_input_rt;
--
2.55.0