mirror of
https://github.com/qemu/qemu.git
synced 2025-07-27 03:38:45 +00:00
linux-user: Handle tags in lock_user/unlock_user
Resolve the untagged address once, using thread_cpu. Tidy the DEBUG_REMAP code using glib routines. Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Message-id: 20210212184902.1251044-20-richard.henderson@linaro.org Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
parent
09f679b62d
commit
31c048342d
@ -6,36 +6,37 @@
|
|||||||
|
|
||||||
void *lock_user(int type, abi_ulong guest_addr, size_t len, bool copy)
|
void *lock_user(int type, abi_ulong guest_addr, size_t len, bool copy)
|
||||||
{
|
{
|
||||||
|
void *host_addr;
|
||||||
|
|
||||||
|
guest_addr = cpu_untagged_addr(thread_cpu, guest_addr);
|
||||||
if (!access_ok_untagged(type, guest_addr, len)) {
|
if (!access_ok_untagged(type, guest_addr, len)) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
host_addr = g2h_untagged(guest_addr);
|
||||||
#ifdef DEBUG_REMAP
|
#ifdef DEBUG_REMAP
|
||||||
{
|
|
||||||
void *addr;
|
|
||||||
addr = g_malloc(len);
|
|
||||||
if (copy) {
|
if (copy) {
|
||||||
memcpy(addr, g2h(guest_addr), len);
|
host_addr = g_memdup(host_addr, len);
|
||||||
} else {
|
} else {
|
||||||
memset(addr, 0, len);
|
host_addr = g_malloc0(len);
|
||||||
}
|
}
|
||||||
return addr;
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
return g2h_untagged(guest_addr);
|
|
||||||
#endif
|
#endif
|
||||||
|
return host_addr;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUG_REMAP
|
#ifdef DEBUG_REMAP
|
||||||
void unlock_user(void *host_ptr, abi_ulong guest_addr, size_t len);
|
void unlock_user(void *host_ptr, abi_ulong guest_addr, size_t len);
|
||||||
{
|
{
|
||||||
|
void *host_ptr_conv;
|
||||||
|
|
||||||
if (!host_ptr) {
|
if (!host_ptr) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (host_ptr == g2h_untagged(guest_addr)) {
|
host_ptr_conv = g2h(thread_cpu, guest_addr);
|
||||||
|
if (host_ptr == host_ptr_conv) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (len != 0) {
|
if (len != 0) {
|
||||||
memcpy(g2h_untagged(guest_addr), host_ptr, len);
|
memcpy(host_ptr_conv, host_ptr, len);
|
||||||
}
|
}
|
||||||
g_free(host_ptr);
|
g_free(host_ptr);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user