Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
at v5.11 45 lines 1.5 kB view raw
1/* SPDX-License-Identifier: GPL-2.0-only */ 2/* 3 * Copyright (C) 2019 SiFive 4 */ 5 6#ifndef _ASM_RISCV_SET_MEMORY_H 7#define _ASM_RISCV_SET_MEMORY_H 8 9#ifndef __ASSEMBLY__ 10/* 11 * Functions to change memory attributes. 12 */ 13#ifdef CONFIG_MMU 14int set_memory_ro(unsigned long addr, int numpages); 15int set_memory_rw(unsigned long addr, int numpages); 16int set_memory_x(unsigned long addr, int numpages); 17int set_memory_nx(unsigned long addr, int numpages); 18int set_memory_rw_nx(unsigned long addr, int numpages); 19void protect_kernel_text_data(void); 20#else 21static inline int set_memory_ro(unsigned long addr, int numpages) { return 0; } 22static inline int set_memory_rw(unsigned long addr, int numpages) { return 0; } 23static inline int set_memory_x(unsigned long addr, int numpages) { return 0; } 24static inline int set_memory_nx(unsigned long addr, int numpages) { return 0; } 25static inline void protect_kernel_text_data(void) {}; 26static inline int set_memory_rw_nx(unsigned long addr, int numpages) { return 0; } 27#endif 28 29int set_direct_map_invalid_noflush(struct page *page); 30int set_direct_map_default_noflush(struct page *page); 31bool kernel_page_present(struct page *page); 32 33#endif /* __ASSEMBLY__ */ 34 35#ifdef CONFIG_STRICT_KERNEL_RWX 36#ifdef CONFIG_64BIT 37#define SECTION_ALIGN (1 << 21) 38#else 39#define SECTION_ALIGN (1 << 22) 40#endif 41#else /* !CONFIG_STRICT_KERNEL_RWX */ 42#define SECTION_ALIGN L1_CACHE_BYTES 43#endif /* CONFIG_STRICT_KERNEL_RWX */ 44 45#endif /* _ASM_RISCV_SET_MEMORY_H */