mm.h (1297B)
1/* SPDX-License-Identifier: GPL-2.0-only */ 2#ifndef __KVM_HYP_MM_H 3#define __KVM_HYP_MM_H 4 5#include <asm/kvm_pgtable.h> 6#include <asm/spectre.h> 7#include <linux/memblock.h> 8#include <linux/types.h> 9 10#include <nvhe/memory.h> 11#include <nvhe/spinlock.h> 12 13extern struct kvm_pgtable pkvm_pgtable; 14extern hyp_spinlock_t pkvm_pgd_lock; 15 16int hyp_create_idmap(u32 hyp_va_bits); 17int hyp_map_vectors(void); 18int hyp_back_vmemmap(phys_addr_t phys, unsigned long size, phys_addr_t back); 19int pkvm_cpu_set_vector(enum arm64_hyp_spectre_vector slot); 20int pkvm_create_mappings(void *from, void *to, enum kvm_pgtable_prot prot); 21int pkvm_create_mappings_locked(void *from, void *to, enum kvm_pgtable_prot prot); 22int __pkvm_create_private_mapping(phys_addr_t phys, size_t size, 23 enum kvm_pgtable_prot prot, 24 unsigned long *haddr); 25int pkvm_alloc_private_va_range(size_t size, unsigned long *haddr); 26 27static inline void hyp_vmemmap_range(phys_addr_t phys, unsigned long size, 28 unsigned long *start, unsigned long *end) 29{ 30 unsigned long nr_pages = size >> PAGE_SHIFT; 31 struct hyp_page *p = hyp_phys_to_page(phys); 32 33 *start = (unsigned long)p; 34 *end = *start + nr_pages * sizeof(struct hyp_page); 35 *start = ALIGN_DOWN(*start, PAGE_SIZE); 36 *end = ALIGN(*end, PAGE_SIZE); 37} 38 39#endif /* __KVM_HYP_MM_H */