xref: /openbmc/linux/include/linux/secretmem.h (revision 43fad1d0)
11507f512SMike Rapoport /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
21507f512SMike Rapoport #ifndef _LINUX_SECRETMEM_H
31507f512SMike Rapoport #define _LINUX_SECRETMEM_H
41507f512SMike Rapoport 
51507f512SMike Rapoport #ifdef CONFIG_SECRETMEM
61507f512SMike Rapoport 
71507f512SMike Rapoport extern const struct address_space_operations secretmem_aops;
81507f512SMike Rapoport 
folio_is_secretmem(struct folio * folio)98f9ff2deSMatthew Wilcox (Oracle) static inline bool folio_is_secretmem(struct folio *folio)
101507f512SMike Rapoport {
111507f512SMike Rapoport 	struct address_space *mapping;
121507f512SMike Rapoport 
131507f512SMike Rapoport 	/*
148f9ff2deSMatthew Wilcox (Oracle) 	 * Using folio_mapping() is quite slow because of the actual call
158f9ff2deSMatthew Wilcox (Oracle) 	 * instruction.
16*43fad1d0SDavid Hildenbrand 	 * We know that secretmem pages are not compound, so we can
171507f512SMike Rapoport 	 * save a couple of cycles here.
181507f512SMike Rapoport 	 */
19*43fad1d0SDavid Hildenbrand 	if (folio_test_large(folio))
201507f512SMike Rapoport 		return false;
211507f512SMike Rapoport 
221507f512SMike Rapoport 	mapping = (struct address_space *)
238f9ff2deSMatthew Wilcox (Oracle) 		((unsigned long)folio->mapping & ~PAGE_MAPPING_FLAGS);
241507f512SMike Rapoport 
258f9ff2deSMatthew Wilcox (Oracle) 	if (!mapping || mapping != folio->mapping)
261507f512SMike Rapoport 		return false;
271507f512SMike Rapoport 
281507f512SMike Rapoport 	return mapping->a_ops == &secretmem_aops;
291507f512SMike Rapoport }
301507f512SMike Rapoport 
311507f512SMike Rapoport bool vma_is_secretmem(struct vm_area_struct *vma);
329a436f8fSMike Rapoport bool secretmem_active(void);
331507f512SMike Rapoport 
341507f512SMike Rapoport #else
351507f512SMike Rapoport 
vma_is_secretmem(struct vm_area_struct * vma)361507f512SMike Rapoport static inline bool vma_is_secretmem(struct vm_area_struct *vma)
371507f512SMike Rapoport {
381507f512SMike Rapoport 	return false;
391507f512SMike Rapoport }
401507f512SMike Rapoport 
folio_is_secretmem(struct folio * folio)418f9ff2deSMatthew Wilcox (Oracle) static inline bool folio_is_secretmem(struct folio *folio)
421507f512SMike Rapoport {
431507f512SMike Rapoport 	return false;
441507f512SMike Rapoport }
451507f512SMike Rapoport 
secretmem_active(void)469a436f8fSMike Rapoport static inline bool secretmem_active(void)
479a436f8fSMike Rapoport {
489a436f8fSMike Rapoport 	return false;
499a436f8fSMike Rapoport }
509a436f8fSMike Rapoport 
511507f512SMike Rapoport #endif /* CONFIG_SECRETMEM */
521507f512SMike Rapoport 
531507f512SMike Rapoport #endif /* _LINUX_SECRETMEM_H */
54