945302df3d
Parse the device tree for Zkr in the isa string. If Zkr is present, use it to seed the kernel base address. On an ACPI system, as of this commit, there is no easy way to check if Zkr is present. Blindly running the instruction isn't an option as; we have to be able to trust the firmware. Signed-off-by: Jesse Taube <jesse@rivosinc.com> Reviewed-by: Charlie Jenkins <charlie@rivosinc.com> Reviewed-by: Alexandre Ghiti <alexghiti@rivosinc.com> Tested-by: Zong Li <zong.li@sifive.com> Reviewed-by: Conor Dooley <conor.dooley@microchip.com> Link: https://lore.kernel.org/r/20240709173937.510084-5-jesse@rivosinc.com Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
31 lines
599 B
C
31 lines
599 B
C
// SPDX-License-Identifier: GPL-2.0-only
|
|
|
|
#include <asm/csr.h>
|
|
#include <linux/processor.h>
|
|
|
|
#include "pi.h"
|
|
|
|
/*
|
|
* To avoid rewriting code include asm/archrandom.h and create macros
|
|
* for the functions that won't be included.
|
|
*/
|
|
#undef riscv_has_extension_unlikely
|
|
#define riscv_has_extension_likely(...) false
|
|
#undef pr_err_once
|
|
#define pr_err_once(...)
|
|
|
|
#include <asm/archrandom.h>
|
|
|
|
u64 get_kaslr_seed_zkr(const uintptr_t dtb_pa)
|
|
{
|
|
unsigned long seed = 0;
|
|
|
|
if (!fdt_early_match_extension_isa((const void *)dtb_pa, "zkr"))
|
|
return 0;
|
|
|
|
if (!csr_seed_long(&seed))
|
|
return 0;
|
|
|
|
return seed;
|
|
}
|