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

swap.h (4180B)


      1/* SPDX-License-Identifier: GPL-2.0 */
      2#ifndef _MM_SWAP_H
      3#define _MM_SWAP_H
      4
      5#ifdef CONFIG_SWAP
      6#include <linux/blk_types.h> /* for bio_end_io_t */
      7
      8/* linux/mm/page_io.c */
      9int sio_pool_init(void);
     10struct swap_iocb;
     11int swap_readpage(struct page *page, bool do_poll,
     12		  struct swap_iocb **plug);
     13void __swap_read_unplug(struct swap_iocb *plug);
     14static inline void swap_read_unplug(struct swap_iocb *plug)
     15{
     16	if (unlikely(plug))
     17		__swap_read_unplug(plug);
     18}
     19void swap_write_unplug(struct swap_iocb *sio);
     20int swap_writepage(struct page *page, struct writeback_control *wbc);
     21void end_swap_bio_write(struct bio *bio);
     22int __swap_writepage(struct page *page, struct writeback_control *wbc,
     23		     bio_end_io_t end_write_func);
     24
     25/* linux/mm/swap_state.c */
     26/* One swap address space for each 64M swap space */
     27#define SWAP_ADDRESS_SPACE_SHIFT	14
     28#define SWAP_ADDRESS_SPACE_PAGES	(1 << SWAP_ADDRESS_SPACE_SHIFT)
     29extern struct address_space *swapper_spaces[];
     30#define swap_address_space(entry)			    \
     31	(&swapper_spaces[swp_type(entry)][swp_offset(entry) \
     32		>> SWAP_ADDRESS_SPACE_SHIFT])
     33
     34void show_swap_cache_info(void);
     35bool add_to_swap(struct folio *folio);
     36void *get_shadow_from_swap_cache(swp_entry_t entry);
     37int add_to_swap_cache(struct page *page, swp_entry_t entry,
     38		      gfp_t gfp, void **shadowp);
     39void __delete_from_swap_cache(struct page *page,
     40			      swp_entry_t entry, void *shadow);
     41void delete_from_swap_cache(struct page *page);
     42void clear_shadow_from_swap_cache(int type, unsigned long begin,
     43				  unsigned long end);
     44void free_swap_cache(struct page *page);
     45struct page *lookup_swap_cache(swp_entry_t entry,
     46			       struct vm_area_struct *vma,
     47			       unsigned long addr);
     48struct page *find_get_incore_page(struct address_space *mapping, pgoff_t index);
     49
     50struct page *read_swap_cache_async(swp_entry_t entry, gfp_t gfp_mask,
     51				   struct vm_area_struct *vma,
     52				   unsigned long addr,
     53				   bool do_poll,
     54				   struct swap_iocb **plug);
     55struct page *__read_swap_cache_async(swp_entry_t entry, gfp_t gfp_mask,
     56				     struct vm_area_struct *vma,
     57				     unsigned long addr,
     58				     bool *new_page_allocated);
     59struct page *swap_cluster_readahead(swp_entry_t entry, gfp_t flag,
     60				    struct vm_fault *vmf);
     61struct page *swapin_readahead(swp_entry_t entry, gfp_t flag,
     62			      struct vm_fault *vmf);
     63
     64static inline unsigned int page_swap_flags(struct page *page)
     65{
     66	return page_swap_info(page)->flags;
     67}
     68#else /* CONFIG_SWAP */
     69struct swap_iocb;
     70static inline int swap_readpage(struct page *page, bool do_poll,
     71				struct swap_iocb **plug)
     72{
     73	return 0;
     74}
     75static inline void swap_write_unplug(struct swap_iocb *sio)
     76{
     77}
     78
     79static inline struct address_space *swap_address_space(swp_entry_t entry)
     80{
     81	return NULL;
     82}
     83
     84static inline void free_swap_cache(struct page *page)
     85{
     86}
     87
     88static inline void show_swap_cache_info(void)
     89{
     90}
     91
     92static inline struct page *swap_cluster_readahead(swp_entry_t entry,
     93				gfp_t gfp_mask, struct vm_fault *vmf)
     94{
     95	return NULL;
     96}
     97
     98static inline struct page *swapin_readahead(swp_entry_t swp, gfp_t gfp_mask,
     99			struct vm_fault *vmf)
    100{
    101	return NULL;
    102}
    103
    104static inline int swap_writepage(struct page *p, struct writeback_control *wbc)
    105{
    106	return 0;
    107}
    108
    109static inline struct page *lookup_swap_cache(swp_entry_t swp,
    110					     struct vm_area_struct *vma,
    111					     unsigned long addr)
    112{
    113	return NULL;
    114}
    115
    116static inline
    117struct page *find_get_incore_page(struct address_space *mapping, pgoff_t index)
    118{
    119	return find_get_page(mapping, index);
    120}
    121
    122static inline bool add_to_swap(struct folio *folio)
    123{
    124	return false;
    125}
    126
    127static inline void *get_shadow_from_swap_cache(swp_entry_t entry)
    128{
    129	return NULL;
    130}
    131
    132static inline int add_to_swap_cache(struct page *page, swp_entry_t entry,
    133					gfp_t gfp_mask, void **shadowp)
    134{
    135	return -1;
    136}
    137
    138static inline void __delete_from_swap_cache(struct page *page,
    139					swp_entry_t entry, void *shadow)
    140{
    141}
    142
    143static inline void delete_from_swap_cache(struct page *page)
    144{
    145}
    146
    147static inline void clear_shadow_from_swap_cache(int type, unsigned long begin,
    148				unsigned long end)
    149{
    150}
    151
    152static inline unsigned int page_swap_flags(struct page *page)
    153{
    154	return 0;
    155}
    156#endif /* CONFIG_SWAP */
    157#endif /* _MM_SWAP_H */