xref: /kvm-unit-tests/lib/vmalloc.h (revision b9289d76b946dc45c5221e142c5473ebfff1ca86)
19f0ae301SCornelia Huck #ifndef _VMALLOC_H_
29f0ae301SCornelia Huck #define _VMALLOC_H_
3efd8e5aaSPaolo Bonzini 
4dcda215bSPaolo Bonzini #include <asm/page.h>
5dcda215bSPaolo Bonzini 
6dee4223bSClaudio Imbrenda /* Allocate consecutive virtual pages (without backing) */
7efd8e5aaSPaolo Bonzini extern void *alloc_vpages(ulong nr);
80d622fcbSClaudio Imbrenda /* Allocate consecutive and aligned virtual pages (without backing) */
90d622fcbSClaudio Imbrenda extern void *alloc_vpages_aligned(ulong nr, unsigned int alignment_order);
100d622fcbSClaudio Imbrenda 
11dee4223bSClaudio Imbrenda /* Allocate one virtual page (without backing) */
12efd8e5aaSPaolo Bonzini extern void *alloc_vpage(void);
13dee4223bSClaudio Imbrenda /* Set the top of the virtual address space */
14efd8e5aaSPaolo Bonzini extern void init_alloc_vpage(void *top);
15dee4223bSClaudio Imbrenda /* Set up the virtual allocator; also sets up the page allocator if needed */
16da7eceb3SThomas Huth extern void setup_vm(void);
170a5b31d2SSean Christopherson /* As above, plus passes an opaque value to setup_mmu(). */
180a5b31d2SSean Christopherson extern void __setup_vm(void *opaque);
19937e2392SPaolo Bonzini 
20*b9289d76SNicholas Piggin /* common/ tests must check availability before calling setup_vm() */
21*b9289d76SNicholas Piggin extern bool vm_available(void);
22dee4223bSClaudio Imbrenda /* Set up paging */
230a5b31d2SSean Christopherson extern void *setup_mmu(phys_addr_t top, void *opaque);
24dee4223bSClaudio Imbrenda /* Walk the page table and resolve the virtual address to a physical address */
25c41e032aSPaolo Bonzini extern phys_addr_t virt_to_pte_phys(pgd_t *pgtable, void *virt);
26dee4223bSClaudio Imbrenda /* Map the virtual address to the physical address for the given page tables */
27dcda215bSPaolo Bonzini extern pteval_t *install_page(pgd_t *pgtable, phys_addr_t phys, void *virt);
28dcda215bSPaolo Bonzini 
29dee4223bSClaudio Imbrenda /* Map consecutive physical pages */
30dcda215bSPaolo Bonzini void *vmap(phys_addr_t phys, size_t size);
31efd8e5aaSPaolo Bonzini 
32efd8e5aaSPaolo Bonzini #endif
33