archrandom_early.c 599 B

123456789101112131415161718192021222324252627282930
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. #include <asm/csr.h>
  3. #include <linux/processor.h>
  4. #include "pi.h"
  5. /*
  6. * To avoid rewriting code include asm/archrandom.h and create macros
  7. * for the functions that won't be included.
  8. */
  9. #undef riscv_has_extension_unlikely
  10. #define riscv_has_extension_likely(...) false
  11. #undef pr_err_once
  12. #define pr_err_once(...)
  13. #include <asm/archrandom.h>
  14. u64 get_kaslr_seed_zkr(const uintptr_t dtb_pa)
  15. {
  16. unsigned long seed = 0;
  17. if (!fdt_early_match_extension_isa((const void *)dtb_pa, "zkr"))
  18. return 0;
  19. if (!csr_seed_long(&seed))
  20. return 0;
  21. return seed;
  22. }