Commit | Line | Data |
---|---|---|
1507f512 MR |
1 | /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ |
2 | #ifndef _LINUX_SECRETMEM_H | |
3 | #define _LINUX_SECRETMEM_H | |
4 | ||
5 | #ifdef CONFIG_SECRETMEM | |
6 | ||
7 | extern const struct address_space_operations secretmem_aops; | |
8 | ||
8f9ff2de | 9 | static inline bool folio_is_secretmem(struct folio *folio) |
1507f512 MR |
10 | { |
11 | struct address_space *mapping; | |
12 | ||
13 | /* | |
8f9ff2de MWO |
14 | * Using folio_mapping() is quite slow because of the actual call |
15 | * instruction. | |
1507f512 MR |
16 | * We know that secretmem pages are not compound and LRU so we can |
17 | * save a couple of cycles here. | |
18 | */ | |
8f9ff2de | 19 | if (folio_test_large(folio) || !folio_test_lru(folio)) |
1507f512 MR |
20 | return false; |
21 | ||
22 | mapping = (struct address_space *) | |
8f9ff2de | 23 | ((unsigned long)folio->mapping & ~PAGE_MAPPING_FLAGS); |
1507f512 | 24 | |
8f9ff2de | 25 | if (!mapping || mapping != folio->mapping) |
1507f512 MR |
26 | return false; |
27 | ||
28 | return mapping->a_ops == &secretmem_aops; | |
29 | } | |
30 | ||
31 | bool vma_is_secretmem(struct vm_area_struct *vma); | |
9a436f8f | 32 | bool secretmem_active(void); |
1507f512 MR |
33 | |
34 | #else | |
35 | ||
36 | static inline bool vma_is_secretmem(struct vm_area_struct *vma) | |
37 | { | |
38 | return false; | |
39 | } | |
40 | ||
8f9ff2de | 41 | static inline bool folio_is_secretmem(struct folio *folio) |
1507f512 MR |
42 | { |
43 | return false; | |
44 | } | |
45 | ||
9a436f8f MR |
46 | static inline bool secretmem_active(void) |
47 | { | |
48 | return false; | |
49 | } | |
50 | ||
1507f512 MR |
51 | #endif /* CONFIG_SECRETMEM */ |
52 | ||
53 | #endif /* _LINUX_SECRETMEM_H */ |