Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 #ifndef __KVM_HYP_GFP_H
0003 #define __KVM_HYP_GFP_H
0004 
0005 #include <linux/list.h>
0006 
0007 #include <nvhe/memory.h>
0008 #include <nvhe/spinlock.h>
0009 
0010 #define HYP_NO_ORDER    USHRT_MAX
0011 
0012 struct hyp_pool {
0013     /*
0014      * Spinlock protecting concurrent changes to the memory pool as well as
0015      * the struct hyp_page of the pool's pages until we have a proper atomic
0016      * API at EL2.
0017      */
0018     hyp_spinlock_t lock;
0019     struct list_head free_area[MAX_ORDER];
0020     phys_addr_t range_start;
0021     phys_addr_t range_end;
0022     unsigned short max_order;
0023 };
0024 
0025 /* Allocation */
0026 void *hyp_alloc_pages(struct hyp_pool *pool, unsigned short order);
0027 void hyp_split_page(struct hyp_page *page);
0028 void hyp_get_page(struct hyp_pool *pool, void *addr);
0029 void hyp_put_page(struct hyp_pool *pool, void *addr);
0030 
0031 /* Used pages cannot be freed */
0032 int hyp_pool_init(struct hyp_pool *pool, u64 pfn, unsigned int nr_pages,
0033           unsigned int reserved_pages);
0034 #endif /* __KVM_HYP_GFP_H */