forked from torvalds/linux
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge patch series "RISC-V: Parse DT for Zkr to seed KASLR"
Jesse Taube <[email protected]> says: Add functions to pi/fdt_early.c to help parse the FDT to check if the isa string has the Zkr extension. Then use the Zkr extension to seed the KASLR base address. The first two patches fix the visibility of symbols. * b4-shazam-merge: RISC-V: Use Zkr to seed KASLR base address RISC-V: pi: Add kernel/pi/pi.h RISC-V: lib: Add pi aliases for string functions RISC-V: pi: Force hidden visibility for all symbol references Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Palmer Dabbelt <[email protected]>
- Loading branch information
Showing
9 changed files
with
224 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// 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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/* SPDX-License-Identifier: GPL-2.0 */ | ||
#ifndef _RISCV_PI_H_ | ||
#define _RISCV_PI_H_ | ||
|
||
#include <linux/types.h> | ||
|
||
/* | ||
* The following functions are exported (but prefixed). Declare them here so | ||
* that LLVM does not complain it lacks the 'static' keyword (which, if | ||
* added, makes LLVM complain because the function is unused). | ||
*/ | ||
|
||
u64 get_kaslr_seed(uintptr_t dtb_pa); | ||
u64 get_kaslr_seed_zkr(const uintptr_t dtb_pa); | ||
bool set_nokaslr_from_cmdline(uintptr_t dtb_pa); | ||
u64 set_satp_mode_from_cmdline(uintptr_t dtb_pa); | ||
|
||
bool fdt_early_match_extension_isa(const void *fdt, const char *ext_name); | ||
|
||
#endif /* _RISCV_PI_H_ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -120,3 +120,4 @@ strcmp_zbb: | |
.option pop | ||
#endif | ||
SYM_FUNC_END(strcmp) | ||
SYM_FUNC_ALIAS(__pi_strcmp, strcmp) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -136,3 +136,4 @@ strncmp_zbb: | |
.option pop | ||
#endif | ||
SYM_FUNC_END(strncmp) | ||
SYM_FUNC_ALIAS(__pi_strncmp, strncmp) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters