Varun Wadekar | 087190f | 2020-05-16 22:10:09 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2020, NVIDIA Corporation. All rights reserved. |
| 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
| 6 | |
| 7 | #include <stdint.h> |
| 8 | |
| 9 | #include <arch_helpers.h> |
| 10 | #include <lib/mmio.h> |
| 11 | #include <plat/common/platform.h> |
| 12 | #include <platform_def.h> |
| 13 | |
| 14 | u_register_t plat_get_stack_protector_canary(void) |
| 15 | { |
| 16 | u_register_t seed; |
| 17 | |
| 18 | /* |
| 19 | * Ideally, a random number should be returned instead. As the |
| 20 | * platform does not have any random number generator, this is |
| 21 | * better than nothing, but not really secure. |
| 22 | */ |
| 23 | seed = mmio_read_32(TEGRA_MISC_BASE + HARDWARE_REVISION_OFFSET); |
| 24 | seed <<= 32; |
| 25 | seed |= mmio_read_32(TEGRA_TMRUS_BASE); |
| 26 | |
| 27 | return seed ^ read_cntpct_el0(); |
| 28 | } |