aboutsummaryrefslogtreecommitdiff
path: root/linux-user/qemu.h
diff options
context:
space:
mode:
authorRichard Henderson <richard.henderson@linaro.org>2021-02-12 10:48:47 -0800
committerPeter Maydell <peter.maydell@linaro.org>2021-02-16 11:04:53 +0000
commitc7169b022b329a121d0c7acb550a08efa04d816a (patch)
tree44da53572b4e3ee2c859b498a4e67acc643c6ce4 /linux-user/qemu.h
parent46b12f461ca063e2cecc53d5805232f05336f02d (diff)
downloadqemu-c7169b022b329a121d0c7acb550a08efa04d816a.zip
qemu-c7169b022b329a121d0c7acb550a08efa04d816a.tar.gz
qemu-c7169b022b329a121d0c7acb550a08efa04d816a.tar.bz2
linux-user: Use cpu_untagged_addr in access_ok; split out *_untagged
Provide both tagged and untagged versions of access_ok. In a few places use thread_cpu, as the user is several callees removed from do_syscall1. Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Message-id: 20210212184902.1251044-17-richard.henderson@linaro.org Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'linux-user/qemu.h')
-rw-r--r--linux-user/qemu.h11
1 files changed, 9 insertions, 2 deletions
diff --git a/linux-user/qemu.h b/linux-user/qemu.h
index b3ccffb..82eabb7 100644
--- a/linux-user/qemu.h
+++ b/linux-user/qemu.h
@@ -491,7 +491,7 @@ extern unsigned long guest_stack_size;
#define VERIFY_READ PAGE_READ
#define VERIFY_WRITE (PAGE_READ | PAGE_WRITE)
-static inline bool access_ok(int type, abi_ulong addr, abi_ulong size)
+static inline bool access_ok_untagged(int type, abi_ulong addr, abi_ulong size)
{
if (size == 0
? !guest_addr_valid_untagged(addr)
@@ -501,6 +501,12 @@ static inline bool access_ok(int type, abi_ulong addr, abi_ulong size)
return page_check_range((target_ulong)addr, size, type) == 0;
}
+static inline bool access_ok(CPUState *cpu, int type,
+ abi_ulong addr, abi_ulong size)
+{
+ return access_ok_untagged(type, cpu_untagged_addr(cpu, addr), size);
+}
+
/* NOTE __get_user and __put_user use host pointers and don't check access.
These are usually used to access struct data members once the struct has
been locked - usually with lock_user_struct. */
@@ -636,8 +642,9 @@ abi_long copy_to_user(abi_ulong gaddr, void *hptr, size_t len);
host area will have the same contents as the guest. */
static inline void *lock_user(int type, abi_ulong guest_addr, long len, int copy)
{
- if (!access_ok(type, guest_addr, len))
+ if (!access_ok_untagged(type, guest_addr, len)) {
return NULL;
+ }
#ifdef DEBUG_REMAP
{
void *addr;