arm-trusted-firmware/drivers
Antonio Nino Diaz c2e05bb78c multi console: Assert that consoles aren't registered twice
In the multi console driver, allowing to register the same console more
than once may result in an infinte loop when putc is called.

If, for example, a boot message is trying to be printed, but the
consoles in the loop in the linked list are runtime consoles, putc will
iterate forever looking for a console that can print boot messages (or
a NULL pointer that will never come).

This loop in the linked list can occur after restoring the system from a
system suspend. The boot console is registered during the cold boot in
BL31, but the runtime console is registered even in the warm boot path.
Consoles are always added to the start of the linked list when they are
registered, so this it what should happen if they were actually
different structures:

   console_list -> NULL
   console_list -> BOOT -> NULL
   console_list -> RUNTIME -> BOOT -> NULL
   console_list -> RUNTIME -> RUNTIME -> BOOT -> NULL

In practice, the two runtime consoles are the same one, so they create
this loop:

   console_list -> RUNTIME -.    X -> BOOT -> NULL
                       ^    |
                       `----'

This patch adds an assertion to detect this problem. The assertion will
fail whenever the same structure tries to be registered while being on
the list.

In order to assert this, console_is_registered() has been implemented.
It returns 1 if the specified console is registered, 0 if not.

Change-Id: I922485e743775ca9bd1af9cbd491ddd360526a6d
Signed-off-by: Antonio Nino Diaz <antonio.ninodiaz@arm.com>
2018-05-11 10:39:07 +01:00
..
arm Fix pointer type mismatch of handlers 2018-04-27 18:35:02 +09:00
auth Fix MISRA rule 8.4 Part 4 2018-04-13 14:01:56 +01:00
cadence/uart drivers: cadence: cdns: Update CDNS driver to support MULTI_CONSOLE_API 2018-01-19 15:21:12 -08:00
console multi console: Assert that consoles aren't registered twice 2018-05-11 10:39:07 +01:00
coreboot/cbmem_console/aarch64 coreboot: Add support for CBMEM console 2018-01-19 15:21:12 -08:00
delay_timer Fix MISRA rule 8.3 in common code 2018-02-28 17:18:21 +00:00
emmc emmc: add macros CMD21, BUS_WIDTH_DDR_4 and BUS_WIDTH_DDR_8 2018-01-17 14:14:29 +08:00
gpio Use SPDX license identifiers 2017-05-03 09:39:28 +01:00
io Fix MISRA rule 8.4 in common code 2018-02-28 17:18:46 +00:00
partition Fix order of #includes 2017-07-12 14:45:31 +01:00
synopsys drivers: fix switch statements to comply with MISRA rules 2018-03-26 12:43:05 +01:00
ti/uart drivers: ti: 16550: Implement console flush 2018-03-22 20:13:44 +00:00
ufs drivers: fix switch statements to comply with MISRA rules 2018-03-26 12:43:05 +01:00