1 // © 2021 Qualcomm Innovation Center, Inc. All rights reserved. 2 // 3 // SPDX-License-Identifier: BSD-3-Clause 4 5 // Allocate a contiguous block of virtual memory of at least the specified size. 6 // 7 // The size will be rounded up to the allocation granularity, which is typically 8 // several megabytes. The returned address may be randomised if KASLR is in use 9 // and should not be assumed to be contiguous with any prior allocations for the 10 // same partition. 11 virt_range_result_t 12 hyp_aspace_allocate(size_t min_size); 13 14 // Free a block of virtual memory previously returned by hyp_aspace_allocate(). 15 void 16 hyp_aspace_deallocate(partition_t *partition, virt_range_t virt_range); 17 18 // Create a 1:1 mapping of the given physical address range, accessible by the 19 // hypervisor without calling partition_phys_access_begin. 20 // 21 // This should only be used by platform-specific legacy code that assumes 1:1 22 // mappings. 23 error_t 24 hyp_aspace_map_direct(partition_t *partition, paddr_t phys, size_t size, 25 pgtable_access_t access, pgtable_hyp_memtype_t memtype, 26 vmsa_shareability_t share); 27 28 // Remove a mapping created by hyp_aspace_map_direct(). 29 error_t 30 hyp_aspace_unmap_direct(partition_t *partition, paddr_t phys, size_t size); 31 32 // Check for the existence of any mappings in the hypervisor address space for 33 // the given range. Note that when the kernel is using ARMv8.1-PAN (or an 34 // equivalent), there may be mappings in this range which are accessible only 35 // after calling partition_phys_access_begin(); this function ignores such 36 // mappings. 37 lookup_result_t 38 hyp_aspace_is_mapped(uintptr_t virt, size_t size, pgtable_access_t access); 39 40 error_t 41 hyp_aspace_va_to_pa_el2_read(void *addr, paddr_t *pa, MAIR_ATTR_t *memattr, 42 vmsa_shareability_t *shareability); 43 44 error_t 45 hyp_aspace_va_to_pa_el2_write(void *addr, paddr_t *pa, MAIR_ATTR_t *memattr, 46 vmsa_shareability_t *shareability); 47 48 // Return the offset used for the physaccess mappings. For the CPUs that support 49 // PAN this is a compile-time constant offset, and for the older CPUs it is 50 // randomised on every boot. 51 uintptr_t 52 hyp_aspace_get_physaccess_offset(void); 53 54 // Returns the base of the memory used for virtual address allocation 55 uintptr_t 56 hyp_aspace_get_alloc_base(void); 57