]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
riscv: mm: implement pgprot_nx
authorJisheng Zhang <jszhang@kernel.org>
Tue, 21 Nov 2023 16:06:37 +0000 (00:06 +0800)
committerPalmer Dabbelt <palmer@rivosinc.com>
Wed, 27 Mar 2024 14:09:06 +0000 (07:09 -0700)
commit cca98e9f8b5e ("mm: enforce that vmap can't map pages
executable") enforces the W^X protection by not allowing remapping
existing pages as executable. Add riscv bits so that riscv can benefit
the same protection.

Signed-off-by: Jisheng Zhang <jszhang@kernel.org>
Reviewed-by: Samuel Holland <samuel.holland@sifive.com>
Tested-by: Samuel Holland <samuel.holland@sifive.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Alexandre Ghiti <alexghiti@rivosinc.com>
Link: https://lore.kernel.org/r/20231121160637.3856-1-jszhang@kernel.org
Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
arch/riscv/include/asm/pgtable.h

index 97fcde30e2477d55f8046d844191a1e4b0ba5e1a..9f8ea0e33eb10424c5a05eb55849eacce627c3c3 100644 (file)
@@ -593,6 +593,12 @@ static inline int ptep_clear_flush_young(struct vm_area_struct *vma,
        return ptep_test_and_clear_young(vma, address, ptep);
 }
 
+#define pgprot_nx pgprot_nx
+static inline pgprot_t pgprot_nx(pgprot_t _prot)
+{
+       return __pgprot(pgprot_val(_prot) & ~_PAGE_EXEC);
+}
+
 #define pgprot_noncached pgprot_noncached
 static inline pgprot_t pgprot_noncached(pgprot_t _prot)
 {