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
7extern const struct address_space_operations secretmem_aops;
8
9static inline bool folio_is_secretmem(struct folio *folio)
10{
11 struct address_space *mapping;
12
13 /*
14 * Using folio_mapping() is quite slow because of the actual call
15 * instruction.
16 * We know that secretmem pages are not compound and LRU so we can
17 * save a couple of cycles here.
18 */
19 if (folio_test_large(folio) || !folio_test_lru(folio))
20 return false;
21
22 mapping = (struct address_space *)
23 ((unsigned long)folio->mapping & ~PAGE_MAPPING_FLAGS);
24
25 if (!mapping || mapping != folio->mapping)
26 return false;
27
28 return mapping->a_ops == &secretmem_aops;
29}
30
31bool vma_is_secretmem(struct vm_area_struct *vma);
32bool secretmem_active(void);
33
34#else
35
36static inline bool vma_is_secretmem(struct vm_area_struct *vma)
37{
38 return false;
39}
40
41static inline bool folio_is_secretmem(struct folio *folio)
42{
43 return false;
44}
45
46static inline bool secretmem_active(void)
47{
48 return false;
49}
50
51#endif /* CONFIG_SECRETMEM */
52
53#endif /* _LINUX_SECRETMEM_H */
54

source code of linux/include/linux/secretmem.h