tegra_stack_protector.c 663 B

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