fix(qemu): fix register convention in BL31 for qemu

The commit with Change-Id:Ie417e054a7a4c192024a2679419e99efeded1705
updated the register convention r1/x1 values but missing necessary
changes in BL31.
As a result, a system panic observed during setup for BL32 when
TRANSFER_LIST is enabled due to unexpected arguments.
This patch is to fix this issue for qemu.

Change-Id: I42e581c5026f0f66d3b114204b4dff167a9bc6ae
Signed-off-by: Raymond Mao <raymond.mao@linaro.org>
This commit is contained in:
Raymond Mao 2024-12-27 06:58:24 -08:00
parent c0688c55bb
commit 7ad6775bde

View file

@ -68,6 +68,9 @@ static struct transfer_list_header *bl31_tl;
void bl31_early_platform_setup2(u_register_t arg0, u_register_t arg1, void bl31_early_platform_setup2(u_register_t arg0, u_register_t arg1,
u_register_t arg2, u_register_t arg3) u_register_t arg2, u_register_t arg3)
{ {
bool is64 = false;
uint64_t hval;
/* Initialize the console to provide early debug support */ /* Initialize the console to provide early debug support */
qemu_console_init(); qemu_console_init();
@ -92,6 +95,11 @@ void bl31_early_platform_setup2(u_register_t arg0, u_register_t arg1,
* They are stored in Secure RAM, in BL2's address space. * They are stored in Secure RAM, in BL2's address space.
*/ */
while (bl_params) { while (bl_params) {
#ifdef __aarch64__
if (bl_params->image_id == BL31_IMAGE_ID &&
GET_RW(bl_params->ep_info->spsr) == MODE_RW_64)
is64 = true;
#endif
if (bl_params->image_id == BL32_IMAGE_ID) if (bl_params->image_id == BL32_IMAGE_ID)
bl32_image_ep_info = *bl_params->ep_info; bl32_image_ep_info = *bl_params->ep_info;
@ -113,11 +121,19 @@ void bl31_early_platform_setup2(u_register_t arg0, u_register_t arg1,
panic(); panic();
#endif #endif
if (TRANSFER_LIST && arg1 == (TRANSFER_LIST_SIGNATURE | if (!TRANSFER_LIST ||
REGISTER_CONVENTION_VERSION_MASK) && !transfer_list_check_header((void *)arg3))
transfer_list_check_header((void *)arg3) != TL_OPS_NON) { return;
if (is64)
hval = TRANSFER_LIST_HANDOFF_X1_VALUE(REGISTER_CONVENTION_VERSION);
else
hval = TRANSFER_LIST_HANDOFF_R1_VALUE(REGISTER_CONVENTION_VERSION);
if (arg1 != hval)
return;
bl31_tl = (void *)arg3; /* saved TL address from BL2 */ bl31_tl = (void *)arg3; /* saved TL address from BL2 */
}
} }
#if ENABLE_RME #if ENABLE_RME