[PATCH] pmdomain: rockchip: Check if smcc could be handled by TA
Ulf Hansson
ulf.hansson at linaro.org
Wed Feb 19 03:51:15 PST 2025
+ Sudeep
On Wed, 19 Feb 2025 at 10:34, Steven Price <steven.price at arm.com> wrote:
>
> On 19/02/2025 00:58, Shawn Lin wrote:
> > Non-existent trusted-firmware could lead smcc calls into some
> > unset location which breaks the system.
> >
> > Reported-by: Steven Price <steven.price at arm.com>
> > Cc: Steven Price <steven.price at arm.com>
> > Suggested-by: Heiko Stuebner <heiko at sntech.de>
> > Fixes: 58ebba35ddab ("pmdomain: rockchip: Add smc call to inform firmware")
> > Signed-off-by: Shawn Lin <shawn.lin at rock-chips.com>
>
> Tested-by: Steven Price <steven.price at arm.com>
>
> Although one note below...
>
> > ---
> > Hi Ulf, this's a follow-up patch fixing the issue Steven saw.
> >
> > drivers/pmdomain/rockchip/pm-domains.c | 7 ++++---
> > 1 file changed, 4 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/pmdomain/rockchip/pm-domains.c b/drivers/pmdomain/rockchip/pm-domains.c
> > index 49842f1..27a5c68 100644
> > --- a/drivers/pmdomain/rockchip/pm-domains.c
> > +++ b/drivers/pmdomain/rockchip/pm-domains.c
> > @@ -572,9 +572,10 @@ static void rockchip_do_pmu_set_power_domain(struct rockchip_pm_domain *pd,
> > }
> >
> > /* Inform firmware to keep this pd on or off */
> > - arm_smccc_smc(ROCKCHIP_SIP_SUSPEND_MODE, ROCKCHIP_SLEEP_PD_CONFIG,
> > - pmu->info->pwr_offset + pd_pwr_offset,
> > - pd->info->pwr_mask, on, 0, 0, 0, &res);
> > + if (arm_smccc_1_1_get_conduit() != SMCCC_CONDUIT_NONE)
> > + arm_smccc_smc(ROCKCHIP_SIP_SUSPEND_MODE, ROCKCHIP_SLEEP_PD_CONFIG,
> > + pmu->info->pwr_offset + pd_pwr_offset,
> > + pd->info->pwr_mask, on, 0, 0, 0, &res);
>
> Note that if the conduit is SMCCC_CONDUIT_HVC then this will still
> attempt an SMC. I'm not sure if this situation can happen in practice.
>
> There is a (horrifyingly complex) macro arm_smccc_1_1_invoke() which
> will automatically use the correct conduit, and even copes with the
> SMCCC_CONDUIT_NONE case (by simply failing the call).
>
> Steve
Thanks for letting us know!
Note that, arm_smccc_1_1_invoke() is also a bit problematic, as it
doesn't compile with Clang-20 and Thumb2 mode. See commit
885f5669f2ab.
[...]
As the current approach seems fine too, I decided to pick up the
$patch as is and by updating the commit message, according to Sudeep's
comment.
Kind regards
Uffe
More information about the Linux-rockchip
mailing list