mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-07-26 20:03:54 -06:00
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>
This commit is contained in:
parent
46b12f461c
commit
c7169b022b
6 changed files with 24 additions and 13 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue