Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
adam.huang
Arm Trusted Firmware
Commits
37d56d38
Commit
37d56d38
authored
Apr 04, 2020
by
Mark Dykes
Committed by
TrustedFirmware Code Review
Apr 04, 2020
Browse files
Merge "Fix MISRA C issues in BL1/BL2/BL31" into integration
parents
083e123a
3443a702
Changes
10
Hide whitespace changes
Inline
Side-by-side
bl1/aarch32/bl1_context_mgmt.c
View file @
37d56d38
/*
/*
* Copyright (c) 2016-20
18
, ARM Limited and Contributors. All rights reserved.
* Copyright (c) 2016-20
20
, ARM Limited and Contributors. All rights reserved.
*
*
* SPDX-License-Identifier: BSD-3-Clause
* SPDX-License-Identifier: BSD-3-Clause
*/
*/
...
@@ -53,10 +53,10 @@ void *cm_get_context(uint32_t security_state)
...
@@ -53,10 +53,10 @@ void *cm_get_context(uint32_t security_state)
return
&
bl1_cpu_context
[
security_state
];
return
&
bl1_cpu_context
[
security_state
];
}
}
void
cm_set_next_context
(
void
*
cpu_
context
)
void
cm_set_next_context
(
void
*
context
)
{
{
assert
(
cpu_
context
);
assert
(
context
!=
NULL
);
bl1_next_cpu_context_ptr
=
cpu_
context
;
bl1_next_cpu_context_ptr
=
context
;
}
}
void
*
cm_get_next_context
(
void
)
void
*
cm_get_next_context
(
void
)
...
@@ -103,21 +103,21 @@ static void flush_smc_and_cpu_ctx(void)
...
@@ -103,21 +103,21 @@ static void flush_smc_and_cpu_ctx(void)
void
bl1_prepare_next_image
(
unsigned
int
image_id
)
void
bl1_prepare_next_image
(
unsigned
int
image_id
)
{
{
unsigned
int
security_state
,
mode
=
MODE32_svc
;
unsigned
int
security_state
,
mode
=
MODE32_svc
;
image_desc_t
*
image_
desc
;
image_desc_t
*
desc
;
entry_point_info_t
*
next_bl_ep
;
entry_point_info_t
*
next_bl_ep
;
/* Get the image descriptor. */
/* Get the image descriptor. */
image_
desc
=
bl1_plat_get_image_desc
(
image_id
);
desc
=
bl1_plat_get_image_desc
(
image_id
);
assert
(
image_desc
);
assert
(
desc
!=
NULL
);
/* Get the entry point info. */
/* Get the entry point info. */
next_bl_ep
=
&
image_
desc
->
ep_info
;
next_bl_ep
=
&
desc
->
ep_info
;
/* Get the image security state. */
/* Get the image security state. */
security_state
=
GET_SECURITY_STATE
(
next_bl_ep
->
h
.
attr
);
security_state
=
GET_SECURITY_STATE
(
next_bl_ep
->
h
.
attr
);
/* Prepare the SPSR for the next BL image. */
/* Prepare the SPSR for the next BL image. */
if
((
security_state
!=
SECURE
)
&&
(
GET_VIRT_EXT
(
read_id_pfr1
())))
{
if
((
security_state
!=
SECURE
)
&&
(
GET_VIRT_EXT
(
read_id_pfr1
())
!=
0U
))
{
mode
=
MODE32_hyp
;
mode
=
MODE32_hyp
;
}
}
...
@@ -166,7 +166,7 @@ void bl1_prepare_next_image(unsigned int image_id)
...
@@ -166,7 +166,7 @@ void bl1_prepare_next_image(unsigned int image_id)
flush_smc_and_cpu_ctx
();
flush_smc_and_cpu_ctx
();
/* Indicate that image is in execution state. */
/* Indicate that image is in execution state. */
image_
desc
->
state
=
IMAGE_STATE_EXECUTED
;
desc
->
state
=
IMAGE_STATE_EXECUTED
;
print_entry_point_info
(
next_bl_ep
);
print_entry_point_info
(
next_bl_ep
);
}
}
bl1/aarch64/bl1_context_mgmt.c
View file @
37d56d38
...
@@ -43,7 +43,7 @@ void cm_set_context(void *context, uint32_t security_state)
...
@@ -43,7 +43,7 @@ void cm_set_context(void *context, uint32_t security_state)
void
bl1_prepare_next_image
(
unsigned
int
image_id
)
void
bl1_prepare_next_image
(
unsigned
int
image_id
)
{
{
unsigned
int
security_state
,
mode
=
MODE_EL1
;
unsigned
int
security_state
,
mode
=
MODE_EL1
;
image_desc_t
*
image_
desc
;
image_desc_t
*
desc
;
entry_point_info_t
*
next_bl_ep
;
entry_point_info_t
*
next_bl_ep
;
#if CTX_INCLUDE_AARCH32_REGS
#if CTX_INCLUDE_AARCH32_REGS
...
@@ -59,11 +59,11 @@ void bl1_prepare_next_image(unsigned int image_id)
...
@@ -59,11 +59,11 @@ void bl1_prepare_next_image(unsigned int image_id)
#endif
#endif
/* Get the image descriptor. */
/* Get the image descriptor. */
image_
desc
=
bl1_plat_get_image_desc
(
image_id
);
desc
=
bl1_plat_get_image_desc
(
image_id
);
assert
(
image_desc
);
assert
(
desc
!=
NULL
);
/* Get the entry point info. */
/* Get the entry point info. */
next_bl_ep
=
&
image_
desc
->
ep_info
;
next_bl_ep
=
&
desc
->
ep_info
;
/* Get the image security state. */
/* Get the image security state. */
security_state
=
GET_SECURITY_STATE
(
next_bl_ep
->
h
.
attr
);
security_state
=
GET_SECURITY_STATE
(
next_bl_ep
->
h
.
attr
);
...
@@ -77,7 +77,7 @@ void bl1_prepare_next_image(unsigned int image_id)
...
@@ -77,7 +77,7 @@ void bl1_prepare_next_image(unsigned int image_id)
mode
=
MODE_EL2
;
mode
=
MODE_EL2
;
}
}
next_bl_ep
->
spsr
=
SPSR_64
(
mode
,
MODE_SP_ELX
,
next_bl_ep
->
spsr
=
(
uint32_t
)
SPSR_64
(
mode
,
MODE_SP_ELX
,
DISABLE_ALL_EXCEPTIONS
);
DISABLE_ALL_EXCEPTIONS
);
/* Allow platform to make change */
/* Allow platform to make change */
...
@@ -88,7 +88,7 @@ void bl1_prepare_next_image(unsigned int image_id)
...
@@ -88,7 +88,7 @@ void bl1_prepare_next_image(unsigned int image_id)
cm_prepare_el3_exit
(
security_state
);
cm_prepare_el3_exit
(
security_state
);
/* Indicate that image is in execution state. */
/* Indicate that image is in execution state. */
image_
desc
->
state
=
IMAGE_STATE_EXECUTED
;
desc
->
state
=
IMAGE_STATE_EXECUTED
;
print_entry_point_info
(
next_bl_ep
);
print_entry_point_info
(
next_bl_ep
);
}
}
bl1/bl1_fwu.c
View file @
37d56d38
...
@@ -67,28 +67,32 @@ u_register_t bl1_fwu_smc_handler(unsigned int smc_fid,
...
@@ -67,28 +67,32 @@ u_register_t bl1_fwu_smc_handler(unsigned int smc_fid,
switch
(
smc_fid
)
{
switch
(
smc_fid
)
{
case
FWU_SMC_IMAGE_COPY
:
case
FWU_SMC_IMAGE_COPY
:
SMC_RET1
(
handle
,
bl1_fwu_image_copy
(
x1
,
x2
,
x3
,
x4
,
flags
));
SMC_RET1
(
handle
,
bl1_fwu_image_copy
((
uint32_t
)
x1
,
x2
,
(
uint32_t
)
x3
,
(
uint32_t
)
x4
,
flags
));
case
FWU_SMC_IMAGE_AUTH
:
case
FWU_SMC_IMAGE_AUTH
:
SMC_RET1
(
handle
,
bl1_fwu_image_auth
(
x1
,
x2
,
x3
,
flags
));
SMC_RET1
(
handle
,
bl1_fwu_image_auth
((
uint32_t
)
x1
,
x2
,
(
uint32_t
)
x3
,
flags
));
case
FWU_SMC_IMAGE_EXECUTE
:
case
FWU_SMC_IMAGE_EXECUTE
:
SMC_RET1
(
handle
,
bl1_fwu_image_execute
(
x1
,
&
handle
,
flags
));
SMC_RET1
(
handle
,
bl1_fwu_image_execute
((
uint32_t
)
x1
,
&
handle
,
flags
));
case
FWU_SMC_IMAGE_RESUME
:
case
FWU_SMC_IMAGE_RESUME
:
SMC_RET1
(
handle
,
bl1_fwu_image_resume
((
register_t
)
x1
,
&
handle
,
flags
));
SMC_RET1
(
handle
,
bl1_fwu_image_resume
((
register_t
)
x1
,
&
handle
,
flags
));
case
FWU_SMC_SEC_IMAGE_DONE
:
case
FWU_SMC_SEC_IMAGE_DONE
:
SMC_RET1
(
handle
,
bl1_fwu_sec_image_done
(
&
handle
,
flags
));
SMC_RET1
(
handle
,
bl1_fwu_sec_image_done
(
&
handle
,
flags
));
case
FWU_SMC_IMAGE_RESET
:
case
FWU_SMC_IMAGE_RESET
:
SMC_RET1
(
handle
,
bl1_fwu_image_reset
(
x1
,
flags
));
SMC_RET1
(
handle
,
bl1_fwu_image_reset
(
(
uint32_t
)
x1
,
flags
));
case
FWU_SMC_UPDATE_DONE
:
case
FWU_SMC_UPDATE_DONE
:
bl1_fwu_done
((
void
*
)
x1
,
NULL
);
bl1_fwu_done
((
void
*
)
x1
,
NULL
);
default:
default:
assert
(
0
);
/* Unreachable */
assert
(
false
);
/* Unreachable */
break
;
break
;
}
}
...
@@ -159,14 +163,14 @@ static int bl1_fwu_remove_loaded_id(unsigned int image_id)
...
@@ -159,14 +163,14 @@ static int bl1_fwu_remove_loaded_id(unsigned int image_id)
******************************************************************************/
******************************************************************************/
static
int
bl1_fwu_image_check_overlaps
(
unsigned
int
image_id
)
static
int
bl1_fwu_image_check_overlaps
(
unsigned
int
image_id
)
{
{
const
image_desc_t
*
image_
desc
,
*
checked_
image_
desc
;
const
image_desc_t
*
desc
,
*
checked_desc
;
const
image_info_t
*
info
,
*
checked_info
;
const
image_info_t
*
info
,
*
checked_info
;
uintptr_t
image_base
,
image_end
;
uintptr_t
image_base
,
image_end
;
uintptr_t
checked_image_base
,
checked_image_end
;
uintptr_t
checked_image_base
,
checked_image_end
;
checked_
image_
desc
=
bl1_plat_get_image_desc
(
image_id
);
checked_desc
=
bl1_plat_get_image_desc
(
image_id
);
checked_info
=
&
checked_
image_
desc
->
image_info
;
checked_info
=
&
checked_desc
->
image_info
;
/* Image being checked mustn't be empty. */
/* Image being checked mustn't be empty. */
assert
(
checked_info
->
image_size
!=
0
);
assert
(
checked_info
->
image_size
!=
0
);
...
@@ -182,12 +186,12 @@ static int bl1_fwu_image_check_overlaps(unsigned int image_id)
...
@@ -182,12 +186,12 @@ static int bl1_fwu_image_check_overlaps(unsigned int image_id)
(
bl1_fwu_loaded_ids
[
i
]
==
image_id
))
(
bl1_fwu_loaded_ids
[
i
]
==
image_id
))
continue
;
continue
;
image_
desc
=
bl1_plat_get_image_desc
(
bl1_fwu_loaded_ids
[
i
]);
desc
=
bl1_plat_get_image_desc
(
bl1_fwu_loaded_ids
[
i
]);
/* Only check images that are loaded or being loaded. */
/* Only check images that are loaded or being loaded. */
assert
(
image_desc
&&
image_
desc
->
state
!=
IMAGE_STATE_RESET
);
assert
(
(
desc
!=
NULL
)
&&
(
desc
->
state
!=
IMAGE_STATE_RESET
)
)
;
info
=
&
image_
desc
->
image_info
;
info
=
&
desc
->
image_info
;
/* There cannot be overlaps with an empty image. */
/* There cannot be overlaps with an empty image. */
if
(
info
->
image_size
==
0
)
if
(
info
->
image_size
==
0
)
...
@@ -203,10 +207,10 @@ static int bl1_fwu_image_check_overlaps(unsigned int image_id)
...
@@ -203,10 +207,10 @@ static int bl1_fwu_image_check_overlaps(unsigned int image_id)
assert
(
image_end
>
image_base
);
assert
(
image_end
>
image_base
);
/* Check if there are overlaps. */
/* Check if there are overlaps. */
if
(
!
(
image_end
<
checked_image_base
||
if
(
!
(
(
image_end
<
checked_image_base
)
||
checked_image_end
<
image_base
))
{
(
checked_image_end
<
image_base
))
)
{
VERBOSE
(
"Image with ID %d overlaps existing image with ID %d"
,
VERBOSE
(
"Image with ID %d overlaps existing image with ID %d"
,
checked_
image_
desc
->
image_id
,
image_
desc
->
image_id
);
checked_desc
->
image_id
,
desc
->
image_id
);
return
-
EPERM
;
return
-
EPERM
;
}
}
}
}
...
@@ -225,10 +229,11 @@ static int bl1_fwu_image_copy(unsigned int image_id,
...
@@ -225,10 +229,11 @@ static int bl1_fwu_image_copy(unsigned int image_id,
{
{
uintptr_t
dest_addr
;
uintptr_t
dest_addr
;
unsigned
int
remaining
;
unsigned
int
remaining
;
image_desc_t
*
desc
;
/* Get the image descriptor. */
/* Get the image descriptor. */
image_desc_t
*
image_
desc
=
bl1_plat_get_image_desc
(
image_id
);
desc
=
bl1_plat_get_image_desc
(
image_id
);
if
(
!
image_desc
)
{
if
(
desc
==
NULL
)
{
WARN
(
"BL1-FWU: Invalid image ID %u
\n
"
,
image_id
);
WARN
(
"BL1-FWU: Invalid image ID %u
\n
"
,
image_id
);
return
-
EPERM
;
return
-
EPERM
;
}
}
...
@@ -241,66 +246,66 @@ static int bl1_fwu_image_copy(unsigned int image_id,
...
@@ -241,66 +246,66 @@ static int bl1_fwu_image_copy(unsigned int image_id,
WARN
(
"BL1-FWU: Copy not allowed from secure world.
\n
"
);
WARN
(
"BL1-FWU: Copy not allowed from secure world.
\n
"
);
return
-
EPERM
;
return
-
EPERM
;
}
}
if
(
GET_SECURITY_STATE
(
image_
desc
->
ep_info
.
h
.
attr
)
==
NON_SECURE
)
{
if
(
GET_SECURITY_STATE
(
desc
->
ep_info
.
h
.
attr
)
==
NON_SECURE
)
{
WARN
(
"BL1-FWU: Copy not allowed for non-secure images.
\n
"
);
WARN
(
"BL1-FWU: Copy not allowed for non-secure images.
\n
"
);
return
-
EPERM
;
return
-
EPERM
;
}
}
/* Check whether the FWU state machine is in the correct state. */
/* Check whether the FWU state machine is in the correct state. */
if
((
image_
desc
->
state
!=
IMAGE_STATE_RESET
)
&&
if
((
desc
->
state
!=
IMAGE_STATE_RESET
)
&&
(
image_
desc
->
state
!=
IMAGE_STATE_COPYING
))
{
(
desc
->
state
!=
IMAGE_STATE_COPYING
))
{
WARN
(
"BL1-FWU: Copy not allowed at this point of the FWU"
WARN
(
"BL1-FWU: Copy not allowed at this point of the FWU"
" process.
\n
"
);
" process.
\n
"
);
return
-
EPERM
;
return
-
EPERM
;
}
}
if
((
!
image_src
)
||
(
!
block_size
)
||
if
((
image_src
==
0U
)
||
(
block_size
==
0U
)
||
check_uptr_overflow
(
image_src
,
block_size
-
1
))
{
check_uptr_overflow
(
image_src
,
block_size
-
1
))
{
WARN
(
"BL1-FWU: Copy not allowed due to invalid image source"
WARN
(
"BL1-FWU: Copy not allowed due to invalid image source"
" or block size
\n
"
);
" or block size
\n
"
);
return
-
ENOMEM
;
return
-
ENOMEM
;
}
}
if
(
image_
desc
->
state
==
IMAGE_STATE_COPYING
)
{
if
(
desc
->
state
==
IMAGE_STATE_COPYING
)
{
/*
/*
* There must have been at least 1 copy operation for this image
* There must have been at least 1 copy operation for this image
* previously.
* previously.
*/
*/
assert
(
image_
desc
->
copied_size
!=
0
);
assert
(
desc
->
copied_size
!=
0
U
);
/*
/*
* The image size must have been recorded in the 1st copy
* The image size must have been recorded in the 1st copy
* operation.
* operation.
*/
*/
image_size
=
image_
desc
->
image_info
.
image_size
;
image_size
=
desc
->
image_info
.
image_size
;
assert
(
image_size
!=
0
);
assert
(
image_size
!=
0
);
assert
(
image_
desc
->
copied_size
<
image_size
);
assert
(
desc
->
copied_size
<
image_size
);
INFO
(
"BL1-FWU: Continuing image copy in blocks
\n
"
);
INFO
(
"BL1-FWU: Continuing image copy in blocks
\n
"
);
}
else
{
/*
image_
desc->state == IMAGE_STATE_RESET */
}
else
{
/* desc->state == IMAGE_STATE_RESET */
INFO
(
"BL1-FWU: Initial call to copy an image
\n
"
);
INFO
(
"BL1-FWU: Initial call to copy an image
\n
"
);
/*
/*
* image_size is relevant only for the 1st copy request, it is
* image_size is relevant only for the 1st copy request, it is
* then ignored for subsequent calls for this image.
* then ignored for subsequent calls for this image.
*/
*/
if
(
!
image_size
)
{
if
(
image_size
==
0
)
{
WARN
(
"BL1-FWU: Copy not allowed due to invalid image"
WARN
(
"BL1-FWU: Copy not allowed due to invalid image"
" size
\n
"
);
" size
\n
"
);
return
-
ENOMEM
;
return
-
ENOMEM
;
}
}
/* Check that the image size to load is within limit */
/* Check that the image size to load is within limit */
if
(
image_size
>
image_
desc
->
image_info
.
image_max_size
)
{
if
(
image_size
>
desc
->
image_info
.
image_max_size
)
{
WARN
(
"BL1-FWU: Image size out of bounds
\n
"
);
WARN
(
"BL1-FWU: Image size out of bounds
\n
"
);
return
-
ENOMEM
;
return
-
ENOMEM
;
}
}
/* Save the given image size. */
/* Save the given image size. */
image_
desc
->
image_info
.
image_size
=
image_size
;
desc
->
image_info
.
image_size
=
image_size
;
/* Make sure the image doesn't overlap other images. */
/* Make sure the image doesn't overlap other images. */
if
(
bl1_fwu_image_check_overlaps
(
image_id
))
{
if
(
bl1_fwu_image_check_overlaps
(
image_id
)
!=
0
)
{
image_
desc
->
image_info
.
image_size
=
0
;
desc
->
image_info
.
image_size
=
0
;
WARN
(
"BL1-FWU: This image overlaps another one
\n
"
);
WARN
(
"BL1-FWU: This image overlaps another one
\n
"
);
return
-
EPERM
;
return
-
EPERM
;
}
}
...
@@ -310,32 +315,32 @@ static int bl1_fwu_image_copy(unsigned int image_id,
...
@@ -310,32 +315,32 @@ static int bl1_fwu_image_copy(unsigned int image_id,
* FWU code doesn't necessarily do it when it resets the state
* FWU code doesn't necessarily do it when it resets the state
* machine.
* machine.
*/
*/
image_
desc
->
copied_size
=
0
;
desc
->
copied_size
=
0
;
}
}
/*
/*
* If the given block size is more than the total image size
* If the given block size is more than the total image size
* then clip the former to the latter.
* then clip the former to the latter.
*/
*/
remaining
=
image_size
-
image_
desc
->
copied_size
;
remaining
=
image_size
-
desc
->
copied_size
;
if
(
block_size
>
remaining
)
{
if
(
block_size
>
remaining
)
{
WARN
(
"BL1-FWU: Block size is too big, clipping it.
\n
"
);
WARN
(
"BL1-FWU: Block size is too big, clipping it.
\n
"
);
block_size
=
remaining
;
block_size
=
remaining
;
}
}
/* Make sure the source image is mapped in memory. */
/* Make sure the source image is mapped in memory. */
if
(
bl1_plat_mem_check
(
image_src
,
block_size
,
flags
))
{
if
(
bl1_plat_mem_check
(
image_src
,
block_size
,
flags
)
!=
0
)
{
WARN
(
"BL1-FWU: Source image is not mapped.
\n
"
);
WARN
(
"BL1-FWU: Source image is not mapped.
\n
"
);
return
-
ENOMEM
;
return
-
ENOMEM
;
}
}
if
(
bl1_fwu_add_loaded_id
(
image_id
))
{
if
(
bl1_fwu_add_loaded_id
(
image_id
)
!=
0
)
{
WARN
(
"BL1-FWU: Too many images loaded at the same time.
\n
"
);
WARN
(
"BL1-FWU: Too many images loaded at the same time.
\n
"
);
return
-
ENOMEM
;
return
-
ENOMEM
;
}
}
/* Allow the platform to handle pre-image load before copying */
/* Allow the platform to handle pre-image load before copying */
if
(
image_
desc
->
state
==
IMAGE_STATE_RESET
)
{
if
(
desc
->
state
==
IMAGE_STATE_RESET
)
{
if
(
bl1_plat_handle_pre_image_load
(
image_id
)
!=
0
)
{
if
(
bl1_plat_handle_pre_image_load
(
image_id
)
!=
0
)
{
ERROR
(
"BL1-FWU: Failure in pre-image load of image id %d
\n
"
,
ERROR
(
"BL1-FWU: Failure in pre-image load of image id %d
\n
"
,
image_id
);
image_id
);
...
@@ -344,12 +349,12 @@ static int bl1_fwu_image_copy(unsigned int image_id,
...
@@ -344,12 +349,12 @@ static int bl1_fwu_image_copy(unsigned int image_id,
}
}
/* Everything looks sane. Go ahead and copy the block of data. */
/* Everything looks sane. Go ahead and copy the block of data. */
dest_addr
=
image_
desc
->
image_info
.
image_base
+
image_
desc
->
copied_size
;
dest_addr
=
desc
->
image_info
.
image_base
+
desc
->
copied_size
;
memcpy
((
void
*
)
dest_addr
,
(
const
void
*
)
image_src
,
block_size
);
(
void
)
memcpy
((
void
*
)
dest_addr
,
(
const
void
*
)
image_src
,
block_size
);
flush_dcache_range
(
dest_addr
,
block_size
);
flush_dcache_range
(
dest_addr
,
block_size
);
image_
desc
->
copied_size
+=
block_size
;
desc
->
copied_size
+=
block_size
;
image_
desc
->
state
=
(
block_size
==
remaining
)
?
desc
->
state
=
(
block_size
==
remaining
)
?
IMAGE_STATE_COPIED
:
IMAGE_STATE_COPYING
;
IMAGE_STATE_COPIED
:
IMAGE_STATE_COPYING
;
INFO
(
"BL1-FWU: Copy operation successful.
\n
"
);
INFO
(
"BL1-FWU: Copy operation successful.
\n
"
);
...
@@ -367,27 +372,28 @@ static int bl1_fwu_image_auth(unsigned int image_id,
...
@@ -367,27 +372,28 @@ static int bl1_fwu_image_auth(unsigned int image_id,
int
result
;
int
result
;
uintptr_t
base_addr
;
uintptr_t
base_addr
;
unsigned
int
total_size
;
unsigned
int
total_size
;
image_desc_t
*
desc
;
/* Get the image descriptor. */
/* Get the image descriptor. */
image_desc_t
*
image_
desc
=
bl1_plat_get_image_desc
(
image_id
);
desc
=
bl1_plat_get_image_desc
(
image_id
);
if
(
!
image_desc
)
if
(
desc
==
NULL
)
return
-
EPERM
;
return
-
EPERM
;
if
(
GET_SECURITY_STATE
(
flags
)
==
SECURE
)
{
if
(
GET_SECURITY_STATE
(
flags
)
==
SECURE
)
{
if
(
image_
desc
->
state
!=
IMAGE_STATE_RESET
)
{
if
(
desc
->
state
!=
IMAGE_STATE_RESET
)
{
WARN
(
"BL1-FWU: Authentication from secure world "
WARN
(
"BL1-FWU: Authentication from secure world "
"while in invalid state
\n
"
);
"while in invalid state
\n
"
);
return
-
EPERM
;
return
-
EPERM
;
}
}
}
else
{
}
else
{
if
(
GET_SECURITY_STATE
(
image_
desc
->
ep_info
.
h
.
attr
)
==
SECURE
)
{
if
(
GET_SECURITY_STATE
(
desc
->
ep_info
.
h
.
attr
)
==
SECURE
)
{
if
(
image_
desc
->
state
!=
IMAGE_STATE_COPIED
)
{
if
(
desc
->
state
!=
IMAGE_STATE_COPIED
)
{
WARN
(
"BL1-FWU: Authentication of secure image "
WARN
(
"BL1-FWU: Authentication of secure image "
"from non-secure world while not in copied state
\n
"
);
"from non-secure world while not in copied state
\n
"
);
return
-
EPERM
;
return
-
EPERM
;
}
}
}
else
{
}
else
{
if
(
image_
desc
->
state
!=
IMAGE_STATE_RESET
)
{
if
(
desc
->
state
!=
IMAGE_STATE_RESET
)
{
WARN
(
"BL1-FWU: Authentication of non-secure image "
WARN
(
"BL1-FWU: Authentication of non-secure image "
"from non-secure world while in invalid state
\n
"
);
"from non-secure world while in invalid state
\n
"
);
return
-
EPERM
;
return
-
EPERM
;
...
@@ -395,15 +401,15 @@ static int bl1_fwu_image_auth(unsigned int image_id,
...
@@ -395,15 +401,15 @@ static int bl1_fwu_image_auth(unsigned int image_id,
}
}
}
}
if
(
image_
desc
->
state
==
IMAGE_STATE_COPIED
)
{
if
(
desc
->
state
==
IMAGE_STATE_COPIED
)
{
/*
/*
* Image is in COPIED state.
* Image is in COPIED state.
* Use the stored address and size.
* Use the stored address and size.
*/
*/
base_addr
=
image_
desc
->
image_info
.
image_base
;
base_addr
=
desc
->
image_info
.
image_base
;
total_size
=
image_
desc
->
image_info
.
image_size
;
total_size
=
desc
->
image_info
.
image_size
;
}
else
{
}
else
{
if
((
!
image_src
)
||
(
!
image_size
)
||
if
((
image_src
==
0U
)
||
(
image_size
==
0U
)
||
check_uptr_overflow
(
image_src
,
image_size
-
1
))
{
check_uptr_overflow
(
image_src
,
image_size
-
1
))
{
WARN
(
"BL1-FWU: Auth not allowed due to invalid"
WARN
(
"BL1-FWU: Auth not allowed due to invalid"
" image source/size
\n
"
);
" image source/size
\n
"
);
...
@@ -415,12 +421,12 @@ static int bl1_fwu_image_auth(unsigned int image_id,
...
@@ -415,12 +421,12 @@ static int bl1_fwu_image_auth(unsigned int image_id,
* Check the parameters and authenticate the source image in place.
* Check the parameters and authenticate the source image in place.
*/
*/
if
(
bl1_plat_mem_check
(
image_src
,
image_size
,
\
if
(
bl1_plat_mem_check
(
image_src
,
image_size
,
\
image_
desc
->
ep_info
.
h
.
attr
))
{
desc
->
ep_info
.
h
.
attr
)
!=
0
)
{
WARN
(
"BL1-FWU: Authentication arguments source/size not mapped
\n
"
);
WARN
(
"BL1-FWU: Authentication arguments source/size not mapped
\n
"
);
return
-
ENOMEM
;
return
-
ENOMEM
;
}
}
if
(
bl1_fwu_add_loaded_id
(
image_id
))
{
if
(
bl1_fwu_add_loaded_id
(
image_id
)
!=
0
)
{
WARN
(
"BL1-FWU: Too many images loaded at the same time.
\n
"
);
WARN
(
"BL1-FWU: Too many images loaded at the same time.
\n
"
);
return
-
ENOMEM
;
return
-
ENOMEM
;
}
}
...
@@ -429,7 +435,7 @@ static int bl1_fwu_image_auth(unsigned int image_id,
...
@@ -429,7 +435,7 @@ static int bl1_fwu_image_auth(unsigned int image_id,
total_size
=
image_size
;
total_size
=
image_size
;
/* Update the image size in the descriptor. */
/* Update the image size in the descriptor. */
image_
desc
->
image_info
.
image_size
=
total_size
;
desc
->
image_info
.
image_size
=
total_size
;
}
}
/*
/*
...
@@ -446,13 +452,13 @@ static int bl1_fwu_image_auth(unsigned int image_id,
...
@@ -446,13 +452,13 @@ static int bl1_fwu_image_auth(unsigned int image_id,
* This is to prevent an attack where this contains
* This is to prevent an attack where this contains
* some malicious code that can somehow be executed later.
* some malicious code that can somehow be executed later.
*/
*/
if
(
image_
desc
->
state
==
IMAGE_STATE_COPIED
)
{
if
(
desc
->
state
==
IMAGE_STATE_COPIED
)
{
/* Clear the memory.*/
/* Clear the memory.*/
zero_normalmem
((
void
*
)
base_addr
,
total_size
);
zero_normalmem
((
void
*
)
base_addr
,
total_size
);
flush_dcache_range
(
base_addr
,
total_size
);
flush_dcache_range
(
base_addr
,
total_size
);
/* Indicate that image can be copied again*/
/* Indicate that image can be copied again*/
image_
desc
->
state
=
IMAGE_STATE_RESET
;
desc
->
state
=
IMAGE_STATE_RESET
;
}
}
/*
/*
...
@@ -460,12 +466,12 @@ static int bl1_fwu_image_auth(unsigned int image_id,
...
@@ -460,12 +466,12 @@ static int bl1_fwu_image_auth(unsigned int image_id,
* The image cannot be in RESET state here, it is checked at the
* The image cannot be in RESET state here, it is checked at the
* beginning of the function.
* beginning of the function.
*/
*/
bl1_fwu_remove_loaded_id
(
image_id
);
(
void
)
bl1_fwu_remove_loaded_id
(
image_id
);
return
-
EAUTH
;
return
-
EAUTH
;
}
}
/* Indicate that image is in authenticated state. */
/* Indicate that image is in authenticated state. */
image_
desc
->
state
=
IMAGE_STATE_AUTHENTICATED
;
desc
->
state
=
IMAGE_STATE_AUTHENTICATED
;
/* Allow the platform to handle post-image load */
/* Allow the platform to handle post-image load */
result
=
bl1_plat_handle_post_image_load
(
image_id
);
result
=
bl1_plat_handle_post_image_load
(
image_id
);
...
@@ -483,7 +489,7 @@ static int bl1_fwu_image_auth(unsigned int image_id,
...
@@ -483,7 +489,7 @@ static int bl1_fwu_image_auth(unsigned int image_id,
* Flush image_info to memory so that other
* Flush image_info to memory so that other
* secure world images can see changes.
* secure world images can see changes.
*/
*/
flush_dcache_range
((
uintptr_t
)
&
image_
desc
->
image_info
,
flush_dcache_range
((
uintptr_t
)
&
desc
->
image_info
,
sizeof
(
image_info_t
));
sizeof
(
image_info_t
));
INFO
(
"BL1-FWU: Authentication was successful
\n
"
);
INFO
(
"BL1-FWU: Authentication was successful
\n
"
);
...
@@ -499,7 +505,7 @@ static int bl1_fwu_image_execute(unsigned int image_id,
...
@@ -499,7 +505,7 @@ static int bl1_fwu_image_execute(unsigned int image_id,
unsigned
int
flags
)
unsigned
int
flags
)
{
{
/* Get the image descriptor. */
/* Get the image descriptor. */
image_desc_t
*
image_
desc
=
bl1_plat_get_image_desc
(
image_id
);
image_desc_t
*
desc
=
bl1_plat_get_image_desc
(
image_id
);
/*
/*
* Execution is NOT allowed if:
* Execution is NOT allowed if:
...
@@ -509,11 +515,11 @@ static int bl1_fwu_image_execute(unsigned int image_id,
...
@@ -509,11 +515,11 @@ static int bl1_fwu_image_execute(unsigned int image_id,
* Image is Non-Executable OR
* Image is Non-Executable OR
* Image is NOT in AUTHENTICATED state.
* Image is NOT in AUTHENTICATED state.
*/
*/
if
((
!
image_desc
)
||
if
((
desc
==
NULL
)
||
(
GET_SECURITY_STATE
(
flags
)
==
SECURE
)
||
(
GET_SECURITY_STATE
(
flags
)
==
SECURE
)
||
(
GET_SECURITY_STATE
(
image_
desc
->
ep_info
.
h
.
attr
)
==
NON_SECURE
)
||
(
GET_SECURITY_STATE
(
desc
->
ep_info
.
h
.
attr
)
==
NON_SECURE
)
||
(
EP_GET_EXE
(
image_
desc
->
ep_info
.
h
.
attr
)
==
NON_EXECUTABLE
)
||
(
EP_GET_EXE
(
desc
->
ep_info
.
h
.
attr
)
==
NON_EXECUTABLE
)
||
(
image_
desc
->
state
!=
IMAGE_STATE_AUTHENTICATED
))
{
(
desc
->
state
!=
IMAGE_STATE_AUTHENTICATED
))
{
WARN
(
"BL1-FWU: Execution not allowed due to invalid state/args
\n
"
);
WARN
(
"BL1-FWU: Execution not allowed due to invalid state/args
\n
"
);
return
-
EPERM
;
return
-
EPERM
;
}
}
...
@@ -547,37 +553,37 @@ static register_t bl1_fwu_image_resume(register_t image_param,
...
@@ -547,37 +553,37 @@ static register_t bl1_fwu_image_resume(register_t image_param,
void
**
handle
,
void
**
handle
,
unsigned
int
flags
)
unsigned
int
flags
)
{
{
image_desc_t
*
image_
desc
;
image_desc_t
*
desc
;
unsigned
int
resume_sec_state
;
unsigned
int
resume_sec_state
;
unsigned
int
caller_sec_state
=
GET_SECURITY_STATE
(
flags
);
unsigned
int
caller_sec_state
=
GET_SECURITY_STATE
(
flags
);
/* Get the image descriptor for last executed secure image id. */
/* Get the image descriptor for last executed secure image id. */
image_
desc
=
bl1_plat_get_image_desc
(
sec_exec_image_id
);
desc
=
bl1_plat_get_image_desc
(
sec_exec_image_id
);
if
(
caller_sec_state
==
NON_SECURE
)
{
if
(
caller_sec_state
==
NON_SECURE
)
{
if
(
!
image_desc
)
{
if
(
desc
==
NULL
)
{
WARN
(
"BL1-FWU: Resume not allowed due to no available"
WARN
(
"BL1-FWU: Resume not allowed due to no available"
"secure image
\n
"
);
"secure image
\n
"
);
return
-
EPERM
;
return
-
EPERM
;
}
}
}
else
{
}
else
{
/*
image_
desc must be valid for secure world callers */
/* desc must be valid for secure world callers */
assert
(
image_desc
);
assert
(
desc
!=
NULL
);
}
}
assert
(
GET_SECURITY_STATE
(
image_
desc
->
ep_info
.
h
.
attr
)
==
SECURE
);
assert
(
GET_SECURITY_STATE
(
desc
->
ep_info
.
h
.
attr
)
==
SECURE
);
assert
(
EP_GET_EXE
(
image_
desc
->
ep_info
.
h
.
attr
)
==
EXECUTABLE
);
assert
(
EP_GET_EXE
(
desc
->
ep_info
.
h
.
attr
)
==
EXECUTABLE
);
if
(
caller_sec_state
==
SECURE
)
{
if
(
caller_sec_state
==
SECURE
)
{
assert
(
image_
desc
->
state
==
IMAGE_STATE_EXECUTED
);
assert
(
desc
->
state
==
IMAGE_STATE_EXECUTED
);
/* Update the flags. */
/* Update the flags. */
image_
desc
->
state
=
IMAGE_STATE_INTERRUPTED
;
desc
->
state
=
IMAGE_STATE_INTERRUPTED
;
resume_sec_state
=
NON_SECURE
;
resume_sec_state
=
NON_SECURE
;
}
else
{
}
else
{
assert
(
image_
desc
->
state
==
IMAGE_STATE_INTERRUPTED
);
assert
(
desc
->
state
==
IMAGE_STATE_INTERRUPTED
);
/* Update the flags. */
/* Update the flags. */
image_
desc
->
state
=
IMAGE_STATE_EXECUTED
;
desc
->
state
=
IMAGE_STATE_EXECUTED
;
resume_sec_state
=
SECURE
;
resume_sec_state
=
SECURE
;
}
}
...
@@ -612,7 +618,7 @@ static register_t bl1_fwu_image_resume(register_t image_param,
...
@@ -612,7 +618,7 @@ static register_t bl1_fwu_image_resume(register_t image_param,
******************************************************************************/
******************************************************************************/
static
int
bl1_fwu_sec_image_done
(
void
**
handle
,
unsigned
int
flags
)
static
int
bl1_fwu_sec_image_done
(
void
**
handle
,
unsigned
int
flags
)
{
{
image_desc_t
*
image_
desc
;
image_desc_t
*
desc
;
/* Make sure caller is from the secure world */
/* Make sure caller is from the secure world */
if
(
GET_SECURITY_STATE
(
flags
)
==
NON_SECURE
)
{
if
(
GET_SECURITY_STATE
(
flags
)
==
NON_SECURE
)
{
...
@@ -621,13 +627,13 @@ static int bl1_fwu_sec_image_done(void **handle, unsigned int flags)
...
@@ -621,13 +627,13 @@ static int bl1_fwu_sec_image_done(void **handle, unsigned int flags)
}
}
/* Get the image descriptor for last executed secure image id */
/* Get the image descriptor for last executed secure image id */
image_
desc
=
bl1_plat_get_image_desc
(
sec_exec_image_id
);
desc
=
bl1_plat_get_image_desc
(
sec_exec_image_id
);
/*
image_
desc must correspond to a valid secure executing image */
/* desc must correspond to a valid secure executing image */
assert
(
image_desc
);
assert
(
desc
!=
NULL
);
assert
(
GET_SECURITY_STATE
(
image_
desc
->
ep_info
.
h
.
attr
)
==
SECURE
);
assert
(
GET_SECURITY_STATE
(
desc
->
ep_info
.
h
.
attr
)
==
SECURE
);
assert
(
EP_GET_EXE
(
image_
desc
->
ep_info
.
h
.
attr
)
==
EXECUTABLE
);
assert
(
EP_GET_EXE
(
desc
->
ep_info
.
h
.
attr
)
==
EXECUTABLE
);
assert
(
image_
desc
->
state
==
IMAGE_STATE_EXECUTED
);
assert
(
desc
->
state
==
IMAGE_STATE_EXECUTED
);
#if ENABLE_ASSERTIONS
#if ENABLE_ASSERTIONS
int
rc
=
bl1_fwu_remove_loaded_id
(
sec_exec_image_id
);
int
rc
=
bl1_fwu_remove_loaded_id
(
sec_exec_image_id
);
...
@@ -637,7 +643,7 @@ static int bl1_fwu_sec_image_done(void **handle, unsigned int flags)
...
@@ -637,7 +643,7 @@ static int bl1_fwu_sec_image_done(void **handle, unsigned int flags)
#endif
#endif
/* Update the flags. */
/* Update the flags. */
image_
desc
->
state
=
IMAGE_STATE_RESET
;
desc
->
state
=
IMAGE_STATE_RESET
;
sec_exec_image_id
=
INVALID_IMAGE_ID
;
sec_exec_image_id
=
INVALID_IMAGE_ID
;
INFO
(
"BL1-FWU: Resuming Normal world context
\n
"
);
INFO
(
"BL1-FWU: Resuming Normal world context
\n
"
);
...
@@ -676,7 +682,7 @@ __dead2 static void bl1_fwu_done(void *client_cookie, void *reserved)
...
@@ -676,7 +682,7 @@ __dead2 static void bl1_fwu_done(void *client_cookie, void *reserved)
* Call platform done function.
* Call platform done function.
*/
*/
bl1_plat_fwu_done
(
client_cookie
,
reserved
);
bl1_plat_fwu_done
(
client_cookie
,
reserved
);
assert
(
0
);
assert
(
false
);
}
}
/*******************************************************************************
/*******************************************************************************
...
@@ -685,14 +691,14 @@ __dead2 static void bl1_fwu_done(void *client_cookie, void *reserved)
...
@@ -685,14 +691,14 @@ __dead2 static void bl1_fwu_done(void *client_cookie, void *reserved)
******************************************************************************/
******************************************************************************/
static
int
bl1_fwu_image_reset
(
unsigned
int
image_id
,
unsigned
int
flags
)
static
int
bl1_fwu_image_reset
(
unsigned
int
image_id
,
unsigned
int
flags
)
{
{
image_desc_t
*
image_
desc
=
bl1_plat_get_image_desc
(
image_id
);
image_desc_t
*
desc
=
bl1_plat_get_image_desc
(
image_id
);
if
((
!
image_desc
)
||
(
GET_SECURITY_STATE
(
flags
)
==
SECURE
))
{
if
((
desc
==
NULL
)
||
(
GET_SECURITY_STATE
(
flags
)
==
SECURE
))
{
WARN
(
"BL1-FWU: Reset not allowed due to invalid args
\n
"
);
WARN
(
"BL1-FWU: Reset not allowed due to invalid args
\n
"
);
return
-
EPERM
;
return
-
EPERM
;
}
}
switch
(
image_
desc
->
state
)
{
switch
(
desc
->
state
)
{
case
IMAGE_STATE_RESET
:
case
IMAGE_STATE_RESET
:
/* Nothing to do. */
/* Nothing to do. */
...
@@ -703,25 +709,26 @@ static int bl1_fwu_image_reset(unsigned int image_id, unsigned int flags)
...
@@ -703,25 +709,26 @@ static int bl1_fwu_image_reset(unsigned int image_id, unsigned int flags)
case
IMAGE_STATE_COPIED
:
case
IMAGE_STATE_COPIED
:
case
IMAGE_STATE_COPYING
:
case
IMAGE_STATE_COPYING
:
if
(
bl1_fwu_remove_loaded_id
(
image_id
))
{
if
(
bl1_fwu_remove_loaded_id
(
image_id
)
!=
0
)
{
WARN
(
"BL1-FWU: Image reset couldn't find the image ID
\n
"
);
WARN
(
"BL1-FWU: Image reset couldn't find the image ID
\n
"
);
return
-
EPERM
;
return
-
EPERM
;
}
}
if
(
image_
desc
->
copied_size
)
{
if
(
desc
->
copied_size
!=
0U
)
{
/* Clear the memory if the image is copied */
/* Clear the memory if the image is copied */
assert
(
GET_SECURITY_STATE
(
image_desc
->
ep_info
.
h
.
attr
)
==
SECURE
);
assert
(
GET_SECURITY_STATE
(
desc
->
ep_info
.
h
.
attr
)
==
SECURE
);
zero_normalmem
((
void
*
)
image_
desc
->
image_info
.
image_base
,
zero_normalmem
((
void
*
)
desc
->
image_info
.
image_base
,
image_
desc
->
copied_size
);
desc
->
copied_size
);
flush_dcache_range
(
image_
desc
->
image_info
.
image_base
,
flush_dcache_range
(
desc
->
image_info
.
image_base
,
image_
desc
->
copied_size
);
desc
->
copied_size
);
}
}
/* Reset status variables */
/* Reset status variables */
image_
desc
->
copied_size
=
0
;
desc
->
copied_size
=
0
;
image_
desc
->
image_info
.
image_size
=
0
;
desc
->
image_info
.
image_size
=
0
;
image_
desc
->
state
=
IMAGE_STATE_RESET
;
desc
->
state
=
IMAGE_STATE_RESET
;
/* Clear authentication state */
/* Clear authentication state */
auth_img_flags
[
image_id
]
=
0
;
auth_img_flags
[
image_id
]
=
0
;
...
@@ -730,7 +737,7 @@ static int bl1_fwu_image_reset(unsigned int image_id, unsigned int flags)
...
@@ -730,7 +737,7 @@ static int bl1_fwu_image_reset(unsigned int image_id, unsigned int flags)
case
IMAGE_STATE_EXECUTED
:
case
IMAGE_STATE_EXECUTED
:
default:
default:
assert
(
0
);
/* Unreachable */
assert
(
false
);
/* Unreachable */
break
;
break
;
}
}
...
...
bl1/bl1_main.c
View file @
37d56d38
...
@@ -90,8 +90,7 @@ void bl1_main(void)
...
@@ -90,8 +90,7 @@ void bl1_main(void)
NOTICE
(
"BL1: %s
\n
"
,
version_string
);
NOTICE
(
"BL1: %s
\n
"
,
version_string
);
NOTICE
(
"BL1: %s
\n
"
,
build_message
);
NOTICE
(
"BL1: %s
\n
"
,
build_message
);
INFO
(
"BL1: RAM %p - %p
\n
"
,
(
void
*
)
BL1_RAM_BASE
,
INFO
(
"BL1: RAM %p - %p
\n
"
,
(
void
*
)
BL1_RAM_BASE
,
(
void
*
)
BL1_RAM_LIMIT
);
(
void
*
)
BL1_RAM_LIMIT
);
print_errata_status
();
print_errata_status
();
...
@@ -105,9 +104,9 @@ void bl1_main(void)
...
@@ -105,9 +104,9 @@ void bl1_main(void)
#else
#else
val
=
read_sctlr
();
val
=
read_sctlr
();
#endif
#endif
assert
(
val
&
SCTLR_M_BIT
);
assert
(
(
val
&
SCTLR_M_BIT
)
!=
0
)
;
assert
(
val
&
SCTLR_C_BIT
);
assert
(
(
val
&
SCTLR_C_BIT
)
!=
0
)
;
assert
(
val
&
SCTLR_I_BIT
);
assert
(
(
val
&
SCTLR_I_BIT
)
!=
0
)
;
/*
/*
* Check that Cache Writeback Granule (CWG) in CTR_EL0 matches the
* Check that Cache Writeback Granule (CWG) in CTR_EL0 matches the
* provided platform value
* provided platform value
...
@@ -166,33 +165,33 @@ void bl1_main(void)
...
@@ -166,33 +165,33 @@ void bl1_main(void)
******************************************************************************/
******************************************************************************/
static
void
bl1_load_bl2
(
void
)
static
void
bl1_load_bl2
(
void
)
{
{
image_desc_t
*
image_
desc
;
image_desc_t
*
desc
;
image_info_t
*
image_
info
;
image_info_t
*
info
;
int
err
;
int
err
;
/* Get the image descriptor */
/* Get the image descriptor */
image_
desc
=
bl1_plat_get_image_desc
(
BL2_IMAGE_ID
);
desc
=
bl1_plat_get_image_desc
(
BL2_IMAGE_ID
);
assert
(
image_
desc
!=
NULL
);
assert
(
desc
!=
NULL
);
/* Get the image info */
/* Get the image info */
image_
info
=
&
image_
desc
->
image_info
;
info
=
&
desc
->
image_info
;
INFO
(
"BL1: Loading BL2
\n
"
);
INFO
(
"BL1: Loading BL2
\n
"
);
err
=
bl1_plat_handle_pre_image_load
(
BL2_IMAGE_ID
);
err
=
bl1_plat_handle_pre_image_load
(
BL2_IMAGE_ID
);
if
(
err
)
{
if
(
err
!=
0
)
{
ERROR
(
"Failure in pre image load handling of BL2 (%d)
\n
"
,
err
);
ERROR
(
"Failure in pre image load handling of BL2 (%d)
\n
"
,
err
);
plat_error_handler
(
err
);
plat_error_handler
(
err
);
}
}
err
=
load_auth_image
(
BL2_IMAGE_ID
,
image_
info
);
err
=
load_auth_image
(
BL2_IMAGE_ID
,
info
);
if
(
err
)
{
if
(
err
!=
0
)
{
ERROR
(
"Failed to load BL2 firmware.
\n
"
);
ERROR
(
"Failed to load BL2 firmware.
\n
"
);
plat_error_handler
(
err
);
plat_error_handler
(
err
);
}
}
/* Allow platform to handle image information. */
/* Allow platform to handle image information. */
err
=
bl1_plat_handle_post_image_load
(
BL2_IMAGE_ID
);
err
=
bl1_plat_handle_post_image_load
(
BL2_IMAGE_ID
);
if
(
err
)
{
if
(
err
!=
0
)
{
ERROR
(
"Failure in post image load handling of BL2 (%d)
\n
"
,
err
);
ERROR
(
"Failure in post image load handling of BL2 (%d)
\n
"
,
err
);
plat_error_handler
(
err
);
plat_error_handler
(
err
);
}
}
...
@@ -258,11 +257,9 @@ u_register_t bl1_smc_handler(unsigned int smc_fid,
...
@@ -258,11 +257,9 @@ u_register_t bl1_smc_handler(unsigned int smc_fid,
SMC_RET1
(
handle
,
BL1_SMC_MAJOR_VER
|
BL1_SMC_MINOR_VER
);
SMC_RET1
(
handle
,
BL1_SMC_MAJOR_VER
|
BL1_SMC_MINOR_VER
);
default:
default:
break
;
WARN
(
"Unimplemented BL1 SMC Call: 0x%x
\n
"
,
smc_fid
);
SMC_RET1
(
handle
,
SMC_UNK
);
}
}
WARN
(
"Unimplemented BL1 SMC Call: 0x%x
\n
"
,
smc_fid
);
SMC_RET1
(
handle
,
SMC_UNK
);
}
}
/*******************************************************************************
/*******************************************************************************
...
...
bl2/bl2_image_load_v2.c
View file @
37d56d38
...
@@ -47,8 +47,9 @@ struct entry_point_info *bl2_load_images(void)
...
@@ -47,8 +47,9 @@ struct entry_point_info *bl2_load_images(void)
* if indicated in the image attributes AND if NOT
* if indicated in the image attributes AND if NOT
* already done before.
* already done before.
*/
*/
if
(
bl2_node_info
->
image_info
->
h
.
attr
&
IMAGE_ATTRIB_PLAT_SETUP
)
{
if
((
bl2_node_info
->
image_info
->
h
.
attr
&
if
(
plat_setup_done
)
{
IMAGE_ATTRIB_PLAT_SETUP
)
!=
0U
)
{
if
(
plat_setup_done
!=
0
)
{
WARN
(
"BL2: Platform setup already done!!
\n
"
);
WARN
(
"BL2: Platform setup already done!!
\n
"
);
}
else
{
}
else
{
INFO
(
"BL2: Doing platform setup
\n
"
);
INFO
(
"BL2: Doing platform setup
\n
"
);
...
@@ -58,16 +59,17 @@ struct entry_point_info *bl2_load_images(void)
...
@@ -58,16 +59,17 @@ struct entry_point_info *bl2_load_images(void)
}
}
err
=
bl2_plat_handle_pre_image_load
(
bl2_node_info
->
image_id
);
err
=
bl2_plat_handle_pre_image_load
(
bl2_node_info
->
image_id
);
if
(
err
)
{
if
(
err
!=
0
)
{
ERROR
(
"BL2: Failure in pre image load handling (%i)
\n
"
,
err
);
ERROR
(
"BL2: Failure in pre image load handling (%i)
\n
"
,
err
);
plat_error_handler
(
err
);
plat_error_handler
(
err
);
}
}
if
(
!
(
bl2_node_info
->
image_info
->
h
.
attr
&
IMAGE_ATTRIB_SKIP_LOADING
))
{
if
((
bl2_node_info
->
image_info
->
h
.
attr
&
IMAGE_ATTRIB_SKIP_LOADING
)
==
0U
)
{
INFO
(
"BL2: Loading image id %d
\n
"
,
bl2_node_info
->
image_id
);
INFO
(
"BL2: Loading image id %d
\n
"
,
bl2_node_info
->
image_id
);
err
=
load_auth_image
(
bl2_node_info
->
image_id
,
err
=
load_auth_image
(
bl2_node_info
->
image_id
,
bl2_node_info
->
image_info
);
bl2_node_info
->
image_info
);
if
(
err
)
{
if
(
err
!=
0
)
{
ERROR
(
"BL2: Failed to load image id %d (%i)
\n
"
,
ERROR
(
"BL2: Failed to load image id %d (%i)
\n
"
,
bl2_node_info
->
image_id
,
err
);
bl2_node_info
->
image_id
,
err
);
plat_error_handler
(
err
);
plat_error_handler
(
err
);
...
@@ -78,7 +80,7 @@ struct entry_point_info *bl2_load_images(void)
...
@@ -78,7 +80,7 @@ struct entry_point_info *bl2_load_images(void)
/* Allow platform to handle image information. */
/* Allow platform to handle image information. */
err
=
bl2_plat_handle_post_image_load
(
bl2_node_info
->
image_id
);
err
=
bl2_plat_handle_post_image_load
(
bl2_node_info
->
image_id
);
if
(
err
)
{
if
(
err
!=
0
)
{
ERROR
(
"BL2: Failure in post image load handling (%i)
\n
"
,
err
);
ERROR
(
"BL2: Failure in post image load handling (%i)
\n
"
,
err
);
plat_error_handler
(
err
);
plat_error_handler
(
err
);
}
}
...
...
bl2u/bl2u_main.c
View file @
37d56d38
/*
/*
* Copyright (c) 2015-20
18
, ARM Limited and Contributors. All rights reserved.
* Copyright (c) 2015-20
20
, ARM Limited and Contributors. All rights reserved.
*
*
* SPDX-License-Identifier: BSD-3-Clause
* SPDX-License-Identifier: BSD-3-Clause
*/
*/
...
@@ -34,7 +34,7 @@ void bl2u_main(void)
...
@@ -34,7 +34,7 @@ void bl2u_main(void)
int
rc
;
int
rc
;
/* Load the subsequent bootloader images */
/* Load the subsequent bootloader images */
rc
=
bl2u_plat_handle_scp_bl2u
();
rc
=
bl2u_plat_handle_scp_bl2u
();
if
(
rc
)
{
if
(
rc
!=
0
)
{
ERROR
(
"Failed to load SCP_BL2U (%i)
\n
"
,
rc
);
ERROR
(
"Failed to load SCP_BL2U (%i)
\n
"
,
rc
);
panic
();
panic
();
}
}
...
...
include/arch/aarch32/arch.h
View file @
37d56d38
/*
/*
* Copyright (c) 2016-20
19
, ARM Limited and Contributors. All rights reserved.
* Copyright (c) 2016-20
20
, ARM Limited and Contributors. All rights reserved.
*
*
* SPDX-License-Identifier: BSD-3-Clause
* SPDX-License-Identifier: BSD-3-Clause
*/
*/
...
@@ -388,13 +388,17 @@
...
@@ -388,13 +388,17 @@
#define GET_M32(mode) (((mode) >> MODE32_SHIFT) & MODE32_MASK)
#define GET_M32(mode) (((mode) >> MODE32_SHIFT) & MODE32_MASK)
#define SPSR_MODE32(mode, isa, endian, aif) \
#define SPSR_MODE32(mode, isa, endian, aif) \
((MODE_RW_32 << MODE_RW_SHIFT | \
( \
((mode) & MODE32_MASK) << MODE32_SHIFT | \
( \
((isa) & SPSR_T_MASK) << SPSR_T_SHIFT | \
(MODE_RW_32 << MODE_RW_SHIFT) | \
((endian) & SPSR_E_MASK) << SPSR_E_SHIFT | \
(((mode) & MODE32_MASK) << MODE32_SHIFT) | \
((aif) & SPSR_AIF_MASK) << SPSR_AIF_SHIFT) & \
(((isa) & SPSR_T_MASK) << SPSR_T_SHIFT) | \
(~(SPSR_SSBS_BIT)))
(((endian) & SPSR_E_MASK) << SPSR_E_SHIFT) | \
(((aif) & SPSR_AIF_MASK) << SPSR_AIF_SHIFT) \
) & \
(~(SPSR_SSBS_BIT)) \
)
/*
/*
* TTBR definitions
* TTBR definitions
...
...
include/arch/aarch64/arch.h
View file @
37d56d38
...
@@ -264,8 +264,8 @@
...
@@ -264,8 +264,8 @@
(U(1) << 22) | (U(1) << 18) | (U(1) << 16) | \
(U(1) << 22) | (U(1) << 18) | (U(1) << 16) | \
(U(1) << 11) | (U(1) << 5) | (U(1) << 4))
(U(1) << 11) | (U(1) << 5) | (U(1) << 4))
#define SCTLR_EL1_RES1 ((U(1) << 29) | (U(1) << 28) | (U(1) << 23) | \
#define SCTLR_EL1_RES1 ((U
L
(1) << 29) | (U
L
(1) << 28) | (U
L
(1) << 23) | \
(U(1) << 22) | (U(1) << 20) | (U(1) << 11))
(U
L
(1) << 22) | (U
L
(1) << 20) | (U
L
(1) << 11))
#define SCTLR_AARCH32_EL1_RES1 \
#define SCTLR_AARCH32_EL1_RES1 \
((U(1) << 23) | (U(1) << 22) | (U(1) << 11) | \
((U(1) << 23) | (U(1) << 22) | (U(1) << 11) | \
(U(1) << 4) | (U(1) << 3))
(U(1) << 4) | (U(1) << 3))
...
...
include/lib/smccc.h
View file @
37d56d38
...
@@ -122,18 +122,18 @@
...
@@ -122,18 +122,18 @@
*/
*/
#define DEFINE_SVC_UUID2(_name, _tl, _tm, _th, _cl, _ch, \
#define DEFINE_SVC_UUID2(_name, _tl, _tm, _th, _cl, _ch, \
_n0, _n1, _n2, _n3, _n4, _n5) \
_n0, _n1, _n2, _n3, _n4, _n5) \
CASSERT((uint32_t)(_tl) != (uint32_t)
SMC_UNK, invalid_svc_uuid);\
CASSERT((uint32_t)(_tl) != (uint32_t)SMC_UNK, invalid_svc_uuid);\
static const uuid_t _name = { \
static const uuid_t _name = { \
{(_tl >> 24) & 0xFF, \
{(
(
_tl
)
>> 24) & 0xFF, \
(_tl >> 16) & 0xFF, \
(
(_tl
)
>> 16) & 0xFF, \
(_tl >> 8) & 0xFF, \
(
(_tl
)
>> 8) & 0xFF, \
(_tl & 0xFF)},
\
(
(_tl
)
& 0xFF)}, \
{(_tm >> 8) & 0xFF, \
{(
(
_tm
)
>> 8) & 0xFF, \
(_tm & 0xFF)}, \
(
(_tm
)
& 0xFF)}, \
{(_th >> 8) & 0xFF, \
{(
(
_th
)
>> 8) & 0xFF, \
(_th & 0xFF)},
\
(
(_th
)
& 0xFF)}, \
_cl, _ch, \
(
_cl
)
,
(
_ch
)
, \
{ _n0, _n1, _n2, _n3, _n4, _n5 }
\
{
(
_n0
)
,
(
_n1
)
,
(
_n2
)
,
(
_n3
)
,
(
_n4
)
,
(
_n5
)
} \
}
}
/*
/*
...
...
include/lib/utils_def.h
View file @
37d56d38
/*
/*
* Copyright (c) 2016-20
19
, ARM Limited and Contributors. All rights reserved.
* Copyright (c) 2016-20
20
, ARM Limited and Contributors. All rights reserved.
* Copyright (c) 2020, NVIDIA Corporation. All rights reserved.
* Copyright (c) 2020, NVIDIA Corporation. All rights reserved.
*
*
* SPDX-License-Identifier: BSD-3-Clause
* SPDX-License-Identifier: BSD-3-Clause
...
@@ -17,7 +17,7 @@
...
@@ -17,7 +17,7 @@
#define IS_POWER_OF_TWO(x) \
#define IS_POWER_OF_TWO(x) \
(((x) & ((x) - 1)) == 0)
(((x) & ((x) - 1)) == 0)
#define SIZE_FROM_LOG2_WORDS(n) (
4
<< (n))
#define SIZE_FROM_LOG2_WORDS(n) (
U(4)
<< (n))
#define BIT_32(nr) (U(1) << (nr))
#define BIT_32(nr) (U(1) << (nr))
#define BIT_64(nr) (ULL(1) << (nr))
#define BIT_64(nr) (ULL(1) << (nr))
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment