mirror of
https://github.com/torvalds/linux.git
synced 2026-12-03 20:06:35 +00:00
Add an API that will allow updates of the direct/linear map for a set of physically contiguous pages. It will be used in the following patches. Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Mike Rapoport (Microsoft) <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Reviewed-by: Luis Chamberlain <[email protected]> Tested-by: kdevops <[email protected]> Cc: Andreas Larsson <[email protected]> Cc: Andy Lutomirski <[email protected]> Cc: Ard Biesheuvel <[email protected]> Cc: Arnd Bergmann <[email protected]> Cc: Borislav Petkov (AMD) <[email protected]> Cc: Brian Cain <[email protected]> Cc: Catalin Marinas <[email protected]> Cc: Christophe Leroy <[email protected]> Cc: Dave Hansen <[email protected]> Cc: Dinh Nguyen <[email protected]> Cc: Geert Uytterhoeven <[email protected]> Cc: Guo Ren <[email protected]> Cc: Helge Deller <[email protected]> Cc: Huacai Chen <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Johannes Berg <[email protected]> Cc: John Paul Adrian Glaubitz <[email protected]> Cc: Kent Overstreet <[email protected]> Cc: Liam R. Howlett <[email protected]> Cc: Mark Rutland <[email protected]> Cc: Masami Hiramatsu (Google) <[email protected]> Cc: Matt Turner <[email protected]> Cc: Max Filippov <[email protected]> Cc: Michael Ellerman <[email protected]> Cc: Michal Simek <[email protected]> Cc: Oleg Nesterov <[email protected]> Cc: Palmer Dabbelt <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Richard Weinberger <[email protected]> Cc: Russell King <[email protected]> Cc: Song Liu <[email protected]> Cc: Stafford Horne <[email protected]> Cc: Steven Rostedt (Google) <[email protected]> Cc: Suren Baghdasaryan <[email protected]> Cc: Thomas Bogendoerfer <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: Uladzislau Rezki (Sony) <[email protected]> Cc: Vineet Gupta <[email protected]> Cc: Will Deacon <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
64 lines
2.0 KiB
C
64 lines
2.0 KiB
C
/* SPDX-License-Identifier: GPL-2.0-only */
|
|
/*
|
|
* Copyright (C) 2019 SiFive
|
|
*/
|
|
|
|
#ifndef _ASM_RISCV_SET_MEMORY_H
|
|
#define _ASM_RISCV_SET_MEMORY_H
|
|
|
|
#ifndef __ASSEMBLY__
|
|
/*
|
|
* Functions to change memory attributes.
|
|
*/
|
|
#ifdef CONFIG_MMU
|
|
int set_memory_ro(unsigned long addr, int numpages);
|
|
int set_memory_rw(unsigned long addr, int numpages);
|
|
int set_memory_x(unsigned long addr, int numpages);
|
|
int set_memory_nx(unsigned long addr, int numpages);
|
|
int set_memory_rw_nx(unsigned long addr, int numpages);
|
|
static __always_inline int set_kernel_memory(char *startp, char *endp,
|
|
int (*set_memory)(unsigned long start,
|
|
int num_pages))
|
|
{
|
|
unsigned long start = (unsigned long)startp;
|
|
unsigned long end = (unsigned long)endp;
|
|
int num_pages = PAGE_ALIGN(end - start) >> PAGE_SHIFT;
|
|
|
|
return set_memory(start, num_pages);
|
|
}
|
|
#else
|
|
static inline int set_memory_ro(unsigned long addr, int numpages) { return 0; }
|
|
static inline int set_memory_rw(unsigned long addr, int numpages) { return 0; }
|
|
static inline int set_memory_x(unsigned long addr, int numpages) { return 0; }
|
|
static inline int set_memory_nx(unsigned long addr, int numpages) { return 0; }
|
|
static inline int set_memory_rw_nx(unsigned long addr, int numpages) { return 0; }
|
|
static inline int set_kernel_memory(char *startp, char *endp,
|
|
int (*set_memory)(unsigned long start,
|
|
int num_pages))
|
|
{
|
|
return 0;
|
|
}
|
|
#endif
|
|
|
|
int set_direct_map_invalid_noflush(struct page *page);
|
|
int set_direct_map_default_noflush(struct page *page);
|
|
int set_direct_map_valid_noflush(struct page *page, unsigned nr, bool valid);
|
|
bool kernel_page_present(struct page *page);
|
|
|
|
#endif /* __ASSEMBLY__ */
|
|
|
|
#if defined(CONFIG_STRICT_KERNEL_RWX) || defined(CONFIG_XIP_KERNEL)
|
|
#ifdef CONFIG_64BIT
|
|
#define SECTION_ALIGN (1 << 21)
|
|
#else
|
|
#define SECTION_ALIGN (1 << 22)
|
|
#endif
|
|
#else /* !CONFIG_STRICT_KERNEL_RWX */
|
|
#define SECTION_ALIGN L1_CACHE_BYTES
|
|
#endif /* CONFIG_STRICT_KERNEL_RWX */
|
|
|
|
#define PECOFF_SECTION_ALIGNMENT 0x1000
|
|
#define PECOFF_FILE_ALIGNMENT 0x200
|
|
|
|
#endif /* _ASM_RISCV_SET_MEMORY_H */
|