• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 #ifndef __KVM_HYP_GFP_H
3 #define __KVM_HYP_GFP_H
4 
5 #include <linux/list.h>
6 
7 #include <nvhe/memory.h>
8 #include <nvhe/spinlock.h>
9 
10 #define HYP_NO_ORDER	0xff
11 
12 struct hyp_pool {
13 	/* lock protecting concurrent changes to the memory pool. */
14 	hyp_spinlock_t lock;
15 	struct list_head free_area[NR_PAGE_ORDERS];
16 	phys_addr_t range_start;
17 	phys_addr_t range_end;
18 	u64 free_pages;
19 	u8 max_order;
20 };
21 
22 /* Allocation */
23 void *hyp_alloc_pages(struct hyp_pool *pool, u8 order);
24 void hyp_split_page(struct hyp_page *page);
25 void hyp_get_page(struct hyp_pool *pool, void *addr);
26 void hyp_put_page(struct hyp_pool *pool, void *addr);
27 
28 u64 hyp_pool_free_pages(struct hyp_pool *pool);
29 
30 /* Used pages cannot be freed */
31 int hyp_pool_init(struct hyp_pool *pool, u64 pfn, unsigned int nr_pages,
32 		  unsigned int reserved_pages);
33 
34 /* Init a pool without initial pages*/
35 int hyp_pool_init_empty(struct hyp_pool *pool, unsigned int nr_pages);
36 #endif /* __KVM_HYP_GFP_H */
37