cachepc-linux

Fork of AMDESE/linux with modifications for CachePC side-channel attack
git clone https://git.sinitax.com/sinitax/cachepc-linux
Log | Files | Refs | README | LICENSE | sfeed.txt

secretmem.h (1194B)


      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 || 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);
     33bool secretmem_active(void);
     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
     47static inline bool secretmem_active(void)
     48{
     49	return false;
     50}
     51
     52#endif /* CONFIG_SECRETMEM */
     53
     54#endif /* _LINUX_SECRETMEM_H */