accel/tcg: Avoid using lock_user() in cpu_memory_rw_debug()
We checked the page flags with page_get_flags(), so locking the page is superfluous. Remove the lock_user() calls and directly use g2h() in place. Suggested-by: Richard Henderson <richard.henderson@linaro.org> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20250217130610.18313-5-philmd@linaro.org>
This commit is contained in:
parent
964a4f2c29
commit
eacd1f8445
17
cpu-target.c
17
cpu-target.c
@ -374,7 +374,6 @@ int cpu_memory_rw_debug(CPUState *cpu, vaddr addr,
|
|||||||
{
|
{
|
||||||
int flags;
|
int flags;
|
||||||
vaddr l, page;
|
vaddr l, page;
|
||||||
void * p;
|
|
||||||
uint8_t *buf = ptr;
|
uint8_t *buf = ptr;
|
||||||
ssize_t written;
|
ssize_t written;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
@ -393,13 +392,7 @@ int cpu_memory_rw_debug(CPUState *cpu, vaddr addr,
|
|||||||
}
|
}
|
||||||
if (is_write) {
|
if (is_write) {
|
||||||
if (flags & PAGE_WRITE) {
|
if (flags & PAGE_WRITE) {
|
||||||
/* XXX: this code should not depend on lock_user */
|
memcpy(g2h(cpu, addr), buf, l);
|
||||||
p = lock_user(VERIFY_WRITE, addr, l, 0);
|
|
||||||
if (!p) {
|
|
||||||
goto out_close;
|
|
||||||
}
|
|
||||||
memcpy(p, buf, l);
|
|
||||||
unlock_user(p, addr, l);
|
|
||||||
} else {
|
} else {
|
||||||
/* Bypass the host page protection using ptrace. */
|
/* Bypass the host page protection using ptrace. */
|
||||||
if (fd == -1) {
|
if (fd == -1) {
|
||||||
@ -424,13 +417,7 @@ int cpu_memory_rw_debug(CPUState *cpu, vaddr addr,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (flags & PAGE_READ) {
|
} else if (flags & PAGE_READ) {
|
||||||
/* XXX: this code should not depend on lock_user */
|
memcpy(buf, g2h(cpu, addr), l);
|
||||||
p = lock_user(VERIFY_READ, addr, l, 1);
|
|
||||||
if (!p) {
|
|
||||||
goto out_close;
|
|
||||||
}
|
|
||||||
memcpy(buf, p, l);
|
|
||||||
unlock_user(p, addr, 0);
|
|
||||||
} else {
|
} else {
|
||||||
/* Bypass the host page protection using ptrace. */
|
/* Bypass the host page protection using ptrace. */
|
||||||
if (fd == -1) {
|
if (fd == -1) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user