[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 1/5] linux-user: Safety belt for h2g
From: |
Jan Kiszka |
Subject: |
[Qemu-devel] [PATCH 1/5] linux-user: Safety belt for h2g |
Date: |
Sat, 16 Aug 2008 11:24:57 +0200 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686 (x86_64); de; rv:1.8.1.12) Gecko/20080226 SUSE/2.0.0.12-1.1 Thunderbird/2.0.0.12 Mnenhy/0.7.5.666 |
h2g can only work on 64-bit hosts if the provided address is mappable to
the guest range. Neglecting this was already the source for several
bugs. Instrument the macro so that it will trigger earlier in the
future (at least as long as we have this kind of mapping mechanism).
Signed-off-by: Jan Kiszka <address@hidden>
---
cpu-all.h | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
Index: b/cpu-all.h
===================================================================
--- a/cpu-all.h
+++ b/cpu-all.h
@@ -659,6 +659,8 @@ static inline void stfq_be_p(void *ptr,
/* MMU memory access macros */
#if defined(CONFIG_USER_ONLY)
+#include <assert.h>
+
/* On some host systems the guest address space is reserved on the host.
* This allows the guest address space to be offset to a convenient location.
*/
@@ -667,7 +669,11 @@ static inline void stfq_be_p(void *ptr,
/* All direct uses of g2h and h2g need to go away for usermode softmmu. */
#define g2h(x) ((void *)((unsigned long)(x) + GUEST_BASE))
-#define h2g(x) ((target_ulong)((unsigned long)(x) - GUEST_BASE))
+#define h2g(x) ({ \
+ unsigned long __ret = (unsigned long)(x) - GUEST_BASE; \
+ assert(__ret == (target_ulong)__ret); \
+ __ret; \
+})
#define saddr(x) g2h(x)
#define laddr(x) g2h(x)
- [Qemu-devel] [PATCH 0/5] linux-user: Detect and fix 32-bit guest on 64-bit host issues - v2, Jan Kiszka, 2008/08/16
- [Qemu-devel] [PATCH 1/5] linux-user: Safety belt for h2g,
Jan Kiszka <=
- [Qemu-devel] [PATCH 4/5] linux-user: Introduce h2g_valid, Jan Kiszka, 2008/08/16
- [Qemu-devel] [PATCH 2/5] linux-user: Introduce qemu_vmalloc_guest_safe, Jan Kiszka, 2008/08/16
- [Qemu-devel] [PATCH 3/5] linux-user: Allocate guest-reachable descriptor tables, Jan Kiszka, 2008/08/16
- [Qemu-devel] [PATCH 5/5] linux-user: Fix h2g usage in page_find_alloc, Jan Kiszka, 2008/08/16
- Re: [Qemu-devel] [PATCH 0/5] linux-user: Detect and fix 32-bit guest on 64-bit host issues - v2, Anthony Liguori, 2008/08/21