From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KUIGJ-0006bv-67 for qemu-devel@nongnu.org; Sat, 16 Aug 2008 05:39:55 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KUIGH-0006Zc-KS for qemu-devel@nongnu.org; Sat, 16 Aug 2008 05:39:53 -0400 Received: from [199.232.76.173] (port=39144 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KUIGH-0006ZT-2y for qemu-devel@nongnu.org; Sat, 16 Aug 2008 05:39:53 -0400 Received: from fmmailgate02.web.de ([217.72.192.227]:47906) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1KUIGG-0001CC-GZ for qemu-devel@nongnu.org; Sat, 16 Aug 2008 05:39:52 -0400 Received: from smtp06.web.de (fmsmtp06.dlan.cinetic.de [172.20.5.172]) by fmmailgate02.web.de (Postfix) with ESMTP id ED1CCE8ED3F5 for ; Sat, 16 Aug 2008 11:39:51 +0200 (CEST) Received: from [88.64.23.108] (helo=[192.168.1.198]) by smtp06.web.de with asmtp (TLSv1:AES256-SHA:256) (WEB.DE 4.109 #226) id 1KUIGF-0001i5-00 for qemu-devel@nongnu.org; Sat, 16 Aug 2008 11:39:51 +0200 Resent-To: qemu-devel@nongnu.org Resent-Message-Id: <48A6A067.9040605@web.de> Message-ID: <48A69CE9.60900@web.de> Date: Sat, 16 Aug 2008 11:24:57 +0200 From: Jan Kiszka MIME-Version: 1.0 References: <48A69B64.7050001@web.de> In-Reply-To: <48A69B64.7050001@web.de> Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit Sender: jan.kiszka@web.de Subject: [Qemu-devel] [PATCH 1/5] linux-user: Safety belt for h2g Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org 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 --- 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 + /* 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)