]>
git.proxmox.com Git - mirror_qemu.git/blob - linux-user/uaccess.c
1 /* User memory access */
7 /* copy_from_user() and copy_to_user() are usually used to copy data
8 * buffers between the target and host. These internally perform
9 * locking/unlocking of the memory.
11 abi_long
copy_from_user(void *hptr
, abi_ulong gaddr
, size_t len
)
16 if ((ghptr
= lock_user(VERIFY_READ
, gaddr
, len
, 1))) {
17 memcpy(hptr
, ghptr
, len
);
18 unlock_user(ghptr
, gaddr
, 0);
26 abi_long
copy_to_user(abi_ulong gaddr
, void *hptr
, size_t len
)
31 if ((ghptr
= lock_user(VERIFY_WRITE
, gaddr
, len
, 0))) {
32 memcpy(ghptr
, hptr
, len
);
33 unlock_user(ghptr
, gaddr
, len
);
41 /* Return the length of a string in target memory. */
42 /* FIXME - this doesn't check access_ok() - it's rather complicated to
43 * do it correctly because we need to check the bytes in a page and then
44 * skip to the next page and check the bytes there until we find the
45 * terminator. There should be a general function to do this that
46 * can look for any byte terminator in a buffer - not strlen().
48 abi_long
target_strlen(abi_ulong gaddr
)
50 return strlen(g2h(gaddr
));