Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
0002 #ifndef _LINUX_SECRETMEM_H
0003 #define _LINUX_SECRETMEM_H
0004 
0005 #ifdef CONFIG_SECRETMEM
0006 
0007 extern const struct address_space_operations secretmem_aops;
0008 
0009 static inline bool page_is_secretmem(struct page *page)
0010 {
0011     struct address_space *mapping;
0012 
0013     /*
0014      * Using page_mapping() is quite slow because of the actual call
0015      * instruction and repeated compound_head(page) inside the
0016      * page_mapping() function.
0017      * We know that secretmem pages are not compound and LRU so we can
0018      * save a couple of cycles here.
0019      */
0020     if (PageCompound(page) || !PageLRU(page))
0021         return false;
0022 
0023     mapping = (struct address_space *)
0024         ((unsigned long)page->mapping & ~PAGE_MAPPING_FLAGS);
0025 
0026     if (!mapping || mapping != page->mapping)
0027         return false;
0028 
0029     return mapping->a_ops == &secretmem_aops;
0030 }
0031 
0032 bool vma_is_secretmem(struct vm_area_struct *vma);
0033 bool secretmem_active(void);
0034 
0035 #else
0036 
0037 static inline bool vma_is_secretmem(struct vm_area_struct *vma)
0038 {
0039     return false;
0040 }
0041 
0042 static inline bool page_is_secretmem(struct page *page)
0043 {
0044     return false;
0045 }
0046 
0047 static inline bool secretmem_active(void)
0048 {
0049     return false;
0050 }
0051 
0052 #endif /* CONFIG_SECRETMEM */
0053 
0054 #endif /* _LINUX_SECRETMEM_H */