Fix incorrect pointer conversion in SMC_UUID_RET()
authorSandrine Bailleux <sandrine.bailleux@arm.com>
Mon, 2 Jul 2018 11:01:16 +0000 (13:01 +0200)
committerSandrine Bailleux <sandrine.bailleux@arm.com>
Tue, 3 Jul 2018 15:35:08 +0000 (17:35 +0200)
commit43b8fa8e981226418b8d0722ba260a7df63638ab
treed7f814a9b2e5426190108c06279f825b470100ab
parenta9c4dde3642a71be377804bec86b2898c2b15d3d
Fix incorrect pointer conversion in SMC_UUID_RET()

Casting a pointer to a struct uuid into a pointer to uint32_t may
result in a pointer that is not correctly aligned, which constitutes
an undefined behaviour. In the case of TF, this also generates a data
abort because alignment fault checking is enabled (through the SCTLR.A
bit).

This patch modifies the SMC_UUID_RET() macro to read the uuid
structure without any pointer aliasing. A helper function then
combines every set of 4 bytes into a 32-bit value suitable to be
returned through the x0-x3 registers.

This fixes a violation of MISRA rule 11.3.

Change-Id: I53ee73bb4cb332f4d8286055ceceb6f347caa080
Signed-off-by: Sandrine Bailleux <sandrine.bailleux@arm.com>
include/lib/aarch32/smccc_helpers.h
include/lib/aarch64/smccc_helpers.h
include/lib/smccc.h