]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/blame - include/linux/secretmem.h
Merge tag 'gvt-fixes-2021-09-18' of https://github.com/intel/gvt-linux into drm-intel...
[mirror_ubuntu-jammy-kernel.git] / include / linux / secretmem.h
CommitLineData
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
7extern const struct address_space_operations secretmem_aops;
8
9static inline bool page_is_secretmem(struct page *page)
10{
11 struct address_space *mapping;
12
13 /*
14 * Using page_mapping() is quite slow because of the actual call
15 * instruction and repeated compound_head(page) inside the
16 * page_mapping() function.
17 * We know that secretmem pages are not compound and LRU so we can
18 * save a couple of cycles here.
19 */
20 if (PageCompound(page) || !PageLRU(page))
21 return false;
22
23 mapping = (struct address_space *)
24 ((unsigned long)page->mapping & ~PAGE_MAPPING_FLAGS);
25
26 if (mapping != page->mapping)
27 return false;
28
29 return mapping->a_ops == &secretmem_aops;
30}
31
32bool vma_is_secretmem(struct vm_area_struct *vma);
9a436f8f 33bool secretmem_active(void);
1507f512
MR
34
35#else
36
37static inline bool vma_is_secretmem(struct vm_area_struct *vma)
38{
39 return false;
40}
41
42static inline bool page_is_secretmem(struct page *page)
43{
44 return false;
45}
46
9a436f8f
MR
47static inline bool secretmem_active(void)
48{
49 return false;
50}
51
1507f512
MR
52#endif /* CONFIG_SECRETMEM */
53
54#endif /* _LINUX_SECRETMEM_H */