diff options
-rw-r--r-- | include/exec/cpu-all.h | 8 | ||||
-rw-r--r-- | user-exec.c | 4 |
2 files changed, 10 insertions, 2 deletions
diff --git a/include/exec/cpu-all.h b/include/exec/cpu-all.h index 5084202..f1cde97 100644 --- a/include/exec/cpu-all.h +++ b/include/exec/cpu-all.h @@ -209,11 +209,15 @@ extern unsigned long reserved_va; }) #endif -#define h2g(x) ({ \ +#define h2g_nocheck(x) ({ \ unsigned long __ret = (unsigned long)(x) - GUEST_BASE; \ + (abi_ulong)__ret; \ +}) + +#define h2g(x) ({ \ /* Check if given address fits target address space */ \ assert(h2g_valid(x)); \ - (abi_ulong)__ret; \ + h2g_nocheck(x); \ }) #define saddr(x) g2h(x) diff --git a/user-exec.c b/user-exec.c index d45ca8e..82bfa66 100644 --- a/user-exec.c +++ b/user-exec.c @@ -95,6 +95,10 @@ static inline int handle_cpu_signal(uintptr_t pc, unsigned long address, return 1; } + /* Convert forcefully to guest address space, invalid addresses + are still valid segv ones */ + address = h2g_nocheck(address); + env = current_cpu->env_ptr; /* see if it is an MMU fault */ ret = cpu_handle_mmu_fault(env, address, is_write, MMU_USER_IDX); |