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
25d583a8
Commit
25d583a8
authored
Feb 13, 2020
by
Alexei Fedorov
Committed by
TrustedFirmware Code Review
Feb 13, 2020
Browse files
Merge "corstone700: adding support for stack protector for the FVP" into integration
parents
ce620fa9
7f0daaa9
Changes
2
Hide whitespace changes
Inline
Side-by-side
plat/arm/board/corstone700/corstone700_stack_protector.c
0 → 100644
View file @
25d583a8
/*
* Copyright (c) 2020, ARM Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#include <stdint.h>
#include <arch_helpers.h>
#include <plat/common/platform.h>
static
uint32_t
plat_generate_random_number
(
void
)
{
uintptr_t
return_addr
=
(
uintptr_t
)
__builtin_return_address
(
0U
);
uintptr_t
frame_addr
=
(
uintptr_t
)
__builtin_frame_address
(
0U
);
uint64_t
cntpct
=
read_cntpct_el0
();
/* Generate 32-bit pattern: saving the 2 least significant bytes
* in random_lo and random_hi
*/
uint16_t
random_lo
=
(
uint16_t
)(
(((
uint64_t
)
return_addr
)
<<
13
)
^
frame_addr
^
cntpct
);
uint16_t
random_hi
=
(
uint16_t
)(
(((
uint64_t
)
frame_addr
)
<<
15
)
^
return_addr
^
cntpct
);
return
(((
uint32_t
)
random_hi
)
<<
16
)
|
random_lo
;
}
u_register_t
plat_get_stack_protector_canary
(
void
)
{
return
plat_generate_random_number
();
/* a 32-bit pattern is returned */
}
plat/arm/board/corstone700/sp_min/sp_min-corstone700.mk
View file @
25d583a8
#
# Copyright (c) 2019, Arm Limited and Contributors. All rights reserved.
# Copyright (c) 2019
-2020
, Arm Limited and Contributors. All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
#
...
...
@@ -15,4 +15,10 @@ BL32_SOURCES += drivers/cfi/v2m/v2m_flash.c \
plat/arm/board/corstone700/sp_min/corstone700_sp_min_setup.c
\
${CORSTONE700_GIC_SOURCES}
ifneq
(${ENABLE_STACK_PROTECTOR},0)
ifneq
(${ENABLE_STACK_PROTECTOR},none)
BL32_SOURCES
+=
plat/arm/board/corstone700/corstone700_stack_protector.c
endif
endif
include
plat/arm/common/sp_min/arm_sp_min.mk
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