1 // © 2021 Qualcomm Innovation Center, Inc. All rights reserved.
2 //
3 // SPDX-License-Identifier: BSD-3-Clause
4 
5 // Copy in or out of VM memory by VA or IPA.
6 //
7 // These functions will all return ERROR_ADDR_INVALID if the specified address
8 // is not mapped in stage 2; ERROR_DENIED if the address is mapped but the
9 // requested access will permission-fault; ERROR_ARGUMENT_SIZE if the source
10 // size is zero or the destination size is smaller than the source size; or OK
11 // if the requested copy was completely successful. In case of errors, the data
12 // may have been partially copied.
13 //
14 // If the force_access argument is true, the copy will ignore the write access
15 // bit in both stages.
16 //
17 // The _va functions will return ERROR_ARGUMENT_INVALID if the access faults in
18 // stage 1. This includes permission faults.
19 //
20 // The _va functions will automatically perform cache maintenance if necessary
21 // to ensure that the access is coherent with the EL1 view of memory at the
22 // specified address (though aliases with different stage 1 attributes may
23 // remain incoherent).
24 //
25 // The _ipa functions will perform cache maintenance if the
26 // force_coherent argument is false and the stage 2 mapping forces a
27 // non-writeback cache attribute, or if the force_coherent argument is true and
28 // the stage 2 mapping does not force a writeback attribute; the latter
29 // behaviour is mostly useful for emulating I/O devices using read-only memory.
30 
31 size_result_t
32 useraccess_copy_from_guest_va(void *hyp_va, size_t hsize, gvaddr_t guest_va,
33 			      size_t gsize);
34 
35 size_result_t
36 useraccess_copy_to_guest_va(gvaddr_t guest_va, size_t gsize, const void *hyp_va,
37 			    size_t hsize, bool force_access);
38 
39 size_result_t
40 useraccess_copy_from_guest_ipa(addrspace_t *addrspace, void *hyp_va,
41 			       size_t hsize, vmaddr_t guest_ipa, size_t gsize,
42 			       bool force_access, bool force_coherent);
43 
44 size_result_t
45 useraccess_copy_to_guest_ipa(addrspace_t *addrspace, vmaddr_t guest_ipa,
46 			     size_t gsize, const void *hyp_va, size_t hsize,
47 			     bool force_access, bool force_coherent);
48