arm-trusted-firmware/lib/psci
Andre Przywara 8a6d0d262a fix(psci): do not panic on illegal MPIDR
Commit 66327414fb ("fix(psci): potential array overflow with cpu on")
changed an assert in the PSCI library's psci_cpu_on_start() function to
a runtime error message, followed by a panic. This does not seem right
for two reasons:
- We must not panic() triggered by conditions influenced by lower EL
  callers. If non-secure world provides illegal arguments to a PSCI
  call, we can easily detect this and return -PSCI_E_INVALID_PARAMS, as
  the PSCI spec demands. In fact this is done already, which brings us
  to the next reason:
- psci_cpu_on_start() is effectively a function private to the PSCI
  library: its prototype is in psci_private.h. It's just not static
  because it lives in a different code file from the main PSCI code.
  We check for illegal MPID values already in psci_cpu_on(), and return
  an error value to the caller, as we should. This function is the ONLY
  caller of psci_cpu_on_start(), so there is no way we get an illegal
  target_cpu argument into this function. An assert() is thus the proper
  way to check for this.

Mostly revert the patch mentioned above, just extending the assert so
that it does also check for not exceeding the array boundaries.
To harden the code, add a check against PLATFORM_MAX_CORE_COUNT in
psci_validate_mpidr(), and return with the proper PSCI error code if
this number is exceeded.

This also fixes the sun50i_a64 build with DEBUG=1, which exceeded an
SRAM limit due to the error message.

Change-Id: I48fc58d96b0173da5b934750f4cadf7884ef5e42
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
2023-05-03 17:00:31 +01:00
..
aarch32 fix(psci): tighten psci_power_down_wfi behaviour 2023-01-23 17:25:40 +00:00
aarch64 fix(cpus): workaround for Cortex-A510 erratum 2684597 2023-01-25 09:40:33 +00:00
psci_common.c fix(psci): do not panic on illegal MPIDR 2023-05-03 17:00:31 +01:00
psci_lib.mk fix(cpus): workaround for Cortex-A510 erratum 2684597 2023-01-25 09:40:33 +00:00
psci_main.c fix(psci): remove unreachable switch/case blocks 2023-04-04 12:39:36 +02:00
psci_mem_protect.c Sanitise includes across codebase 2019-01-04 10:43:17 +00:00
psci_off.c refactor(psci): move psci_do_pwrdown_sequence() out of private header 2022-09-15 18:09:56 +05:30
psci_on.c fix(psci): do not panic on illegal MPIDR 2023-05-03 17:00:31 +01:00
psci_private.h feat(psci): add support for OS-initiated mode 2023-03-20 22:20:35 -07:00
psci_setup.c feat(psci): add support for PSCI_SET_SUSPEND_MODE 2023-03-20 22:20:35 -07:00
psci_stat.c Unify type of "cpu_idx" across PSCI module. 2020-01-10 17:11:51 +00:00
psci_suspend.c feat(psci): add support for OS-initiated mode 2023-03-20 22:20:35 -07:00
psci_system_off.c Don't return error information from console_flush 2020-10-09 10:21:50 -05:00