mirror of
https://github.com/torvalds/linux.git
synced 2026-05-26 16:12:59 +02:00
riscv/mm: manufacture shadow stack ptes
This patch implements the creation of a shadow stack pte on riscv. Creating shadow stack PTE on riscv means clearing RWX and then setting W=1. Reviewed-by: Alexandre Ghiti <alexghiti@rivosinc.com> Reviewed-by: Zong Li <zong.li@sifive.com> Signed-off-by: Deepak Gupta <debug@rivosinc.com> Tested-by: Andreas Korb <andreas.korb@aisec.fraunhofer.de> # QEMU, custom CVA6 Tested-by: Valentin Haudiquet <valentin.haudiquet@canonical.com> Link: https://patch.msgid.link/20251112-v5_user_cfi_series-v23-7-b55691eacf4f@rivosinc.com [pjw@kernel.org: cleaned up patch description] Signed-off-by: Paul Walmsley <pjw@kernel.org>
This commit is contained in:
parent
6c7559f22b
commit
f56ffb8ada
|
|
@ -456,6 +456,11 @@ static inline pte_t pte_mkwrite_novma(pte_t pte)
|
|||
return __pte(pte_val(pte) | _PAGE_WRITE);
|
||||
}
|
||||
|
||||
static inline pte_t pte_mkwrite_shstk(pte_t pte)
|
||||
{
|
||||
return __pte((pte_val(pte) & ~(_PAGE_LEAF)) | _PAGE_WRITE);
|
||||
}
|
||||
|
||||
/* static inline pte_t pte_mkexec(pte_t pte) */
|
||||
|
||||
static inline pte_t pte_mkdirty(pte_t pte)
|
||||
|
|
@ -839,6 +844,11 @@ static inline pmd_t pmd_mkwrite_novma(pmd_t pmd)
|
|||
return pte_pmd(pte_mkwrite_novma(pmd_pte(pmd)));
|
||||
}
|
||||
|
||||
static inline pmd_t pmd_mkwrite_shstk(pmd_t pte)
|
||||
{
|
||||
return __pmd((pmd_val(pte) & ~(_PAGE_LEAF)) | _PAGE_WRITE);
|
||||
}
|
||||
|
||||
static inline pmd_t pmd_wrprotect(pmd_t pmd)
|
||||
{
|
||||
return pte_pmd(pte_wrprotect(pmd_pte(pmd)));
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user