* [Qemu-devel] [PATCH] linux-user: Safety belt for h2g
@ 2008-07-13 20:27 Jan Kiszka
0 siblings, 0 replies; 6+ messages in thread
From: Jan Kiszka @ 2008-07-13 20:27 UTC (permalink / raw)
To: qemu-devel
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 <jan.kiszka@web.de>
---
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)
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Qemu-devel] [PATCH] linux-user: Safety belt for h2g
2008-12-03 11:29 ` [Qemu-devel] [PATCH] Move abi_* typedefs into qemu-types.h Kirill A. Shutemov
@ 2008-12-03 11:29 ` Kirill A. Shutemov
2008-12-06 20:04 ` Edgar E. Iglesias
2008-12-08 18:15 ` Aurelien Jarno
0 siblings, 2 replies; 6+ messages in thread
From: Kirill A. Shutemov @ 2008-12-03 11:29 UTC (permalink / raw)
To: qemu-devel; +Cc: Kirill A. Shutemov, Jan Kiszka
From: Jan Kiszka <jan.kiszka@web.de>
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 <jan.kiszka@web.de>
Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
---
cpu-all.h | 10 +++++++++-
1 files changed, 9 insertions(+), 1 deletions(-)
diff --git a/cpu-all.h b/cpu-all.h
index 73c7b4c..526ace2 100644
--- a/cpu-all.h
+++ b/cpu-all.h
@@ -621,6 +621,9 @@ static inline void stfq_be_p(void *ptr, float64 v)
/* MMU memory access macros */
#if defined(CONFIG_USER_ONLY)
+#include <assert.h>
+#include "qemu-types.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.
*/
@@ -629,7 +632,12 @@ static inline void stfq_be_p(void *ptr, float64 v)
/* 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; \
+ /* Check if given address fits target address space */ \
+ assert(__ret == (abi_ulong)__ret); \
+ (abi_ulong)__ret; \
+})
#define saddr(x) g2h(x)
#define laddr(x) g2h(x)
--
1.6.0.2.GIT
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH] linux-user: Safety belt for h2g
2008-12-03 11:29 ` [Qemu-devel] [PATCH] linux-user: Safety belt for h2g Kirill A. Shutemov
@ 2008-12-06 20:04 ` Edgar E. Iglesias
2008-12-08 18:15 ` Aurelien Jarno
1 sibling, 0 replies; 6+ messages in thread
From: Edgar E. Iglesias @ 2008-12-06 20:04 UTC (permalink / raw)
To: Kirill A. Shutemov; +Cc: Jan Kiszka, qemu-devel
On Wed, Dec 03, 2008 at 01:29:39PM +0200, Kirill A. Shutemov wrote:
> From: Jan Kiszka <jan.kiszka@web.de>
>
> 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 <jan.kiszka@web.de>
> Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
Acked-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
> ---
> cpu-all.h | 10 +++++++++-
> 1 files changed, 9 insertions(+), 1 deletions(-)
>
> diff --git a/cpu-all.h b/cpu-all.h
> index 73c7b4c..526ace2 100644
> --- a/cpu-all.h
> +++ b/cpu-all.h
> @@ -621,6 +621,9 @@ static inline void stfq_be_p(void *ptr, float64 v)
> /* MMU memory access macros */
>
> #if defined(CONFIG_USER_ONLY)
> +#include <assert.h>
> +#include "qemu-types.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.
> */
> @@ -629,7 +632,12 @@ static inline void stfq_be_p(void *ptr, float64 v)
>
> /* 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; \
> + /* Check if given address fits target address space */ \
> + assert(__ret == (abi_ulong)__ret); \
> + (abi_ulong)__ret; \
> +})
>
> #define saddr(x) g2h(x)
> #define laddr(x) g2h(x)
> --
> 1.6.0.2.GIT
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH] linux-user: Safety belt for h2g
2008-12-03 11:29 ` [Qemu-devel] [PATCH] linux-user: Safety belt for h2g Kirill A. Shutemov
2008-12-06 20:04 ` Edgar E. Iglesias
@ 2008-12-08 18:15 ` Aurelien Jarno
2008-12-08 19:25 ` Andreas Färber
2008-12-09 7:34 ` Jan Kiszka
1 sibling, 2 replies; 6+ messages in thread
From: Aurelien Jarno @ 2008-12-08 18:15 UTC (permalink / raw)
To: qemu-devel; +Cc: Kirill A. Shutemov, Jan Kiszka
On Wed, Dec 03, 2008 at 01:29:39PM +0200, Kirill A. Shutemov wrote:
> From: Jan Kiszka <jan.kiszka@web.de>
>
> 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 <jan.kiszka@web.de>
> Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
Applied. I have seen the patch has been modified since Jan Kiszka posted
it to the mailing list. Not sure a Signed-off-by still applies in that
case.
> ---
> cpu-all.h | 10 +++++++++-
> 1 files changed, 9 insertions(+), 1 deletions(-)
>
> diff --git a/cpu-all.h b/cpu-all.h
> index 73c7b4c..526ace2 100644
> --- a/cpu-all.h
> +++ b/cpu-all.h
> @@ -621,6 +621,9 @@ static inline void stfq_be_p(void *ptr, float64 v)
> /* MMU memory access macros */
>
> #if defined(CONFIG_USER_ONLY)
> +#include <assert.h>
> +#include "qemu-types.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.
> */
> @@ -629,7 +632,12 @@ static inline void stfq_be_p(void *ptr, float64 v)
>
> /* 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; \
> + /* Check if given address fits target address space */ \
> + assert(__ret == (abi_ulong)__ret); \
> + (abi_ulong)__ret; \
> +})
>
> #define saddr(x) g2h(x)
> #define laddr(x) g2h(x)
> --
> 1.6.0.2.GIT
>
>
>
>
--
.''`. Aurelien Jarno | GPG: 1024D/F1BCDB73
: :' : Debian developer | Electrical Engineer
`. `' aurel32@debian.org | aurelien@aurel32.net
`- people.debian.org/~aurel32 | www.aurel32.net
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH] linux-user: Safety belt for h2g
2008-12-08 18:15 ` Aurelien Jarno
@ 2008-12-08 19:25 ` Andreas Färber
2008-12-09 7:34 ` Jan Kiszka
1 sibling, 0 replies; 6+ messages in thread
From: Andreas Färber @ 2008-12-08 19:25 UTC (permalink / raw)
To: qemu-devel
Am 08.12.2008 um 19:15 schrieb Aurelien Jarno:
> On Wed, Dec 03, 2008 at 01:29:39PM +0200, Kirill A. Shutemov wrote:
>> From: Jan Kiszka <jan.kiszka@web.de>
>>
>> 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 <jan.kiszka@web.de>
>> Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
>
> Applied. I have seen the patch has been modified since Jan Kiszka
> posted
> it to the mailing list. Not sure a Signed-off-by still applies in that
> case.
Removing a Signed-off-by for code that is kept is a no-go to my
knowledge. It's supposed to track through whom all the code went
copyright- and GPL-wise, according to Kerneltrap.
Andreas
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH] linux-user: Safety belt for h2g
2008-12-08 18:15 ` Aurelien Jarno
2008-12-08 19:25 ` Andreas Färber
@ 2008-12-09 7:34 ` Jan Kiszka
1 sibling, 0 replies; 6+ messages in thread
From: Jan Kiszka @ 2008-12-09 7:34 UTC (permalink / raw)
To: Aurelien Jarno; +Cc: Kirill A. Shutemov, qemu-devel
[-- Attachment #1: Type: text/plain, Size: 2123 bytes --]
Aurelien Jarno wrote:
> On Wed, Dec 03, 2008 at 01:29:39PM +0200, Kirill A. Shutemov wrote:
>> From: Jan Kiszka <jan.kiszka@web.de>
>>
>> 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 <jan.kiszka@web.de>
>> Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
>
> Applied. I have seen the patch has been modified since Jan Kiszka posted
> it to the mailing list. Not sure a Signed-off-by still applies in that
> case.
Kirill correctly pointed out to me that target_ulong should rather be
abi_ulong here and in the other patch.
Good to see these changes finally merged!
Jan
>
>> ---
>> cpu-all.h | 10 +++++++++-
>> 1 files changed, 9 insertions(+), 1 deletions(-)
>>
>> diff --git a/cpu-all.h b/cpu-all.h
>> index 73c7b4c..526ace2 100644
>> --- a/cpu-all.h
>> +++ b/cpu-all.h
>> @@ -621,6 +621,9 @@ static inline void stfq_be_p(void *ptr, float64 v)
>> /* MMU memory access macros */
>>
>> #if defined(CONFIG_USER_ONLY)
>> +#include <assert.h>
>> +#include "qemu-types.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.
>> */
>> @@ -629,7 +632,12 @@ static inline void stfq_be_p(void *ptr, float64 v)
>>
>> /* 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; \
>> + /* Check if given address fits target address space */ \
>> + assert(__ret == (abi_ulong)__ret); \
>> + (abi_ulong)__ret; \
>> +})
>>
>> #define saddr(x) g2h(x)
>> #define laddr(x) g2h(x)
>> --
>> 1.6.0.2.GIT
>>
>>
>>
>>
>
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 258 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2008-12-09 7:35 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-07-13 20:27 [Qemu-devel] [PATCH] linux-user: Safety belt for h2g Jan Kiszka
-- strict thread matches above, loose matches on Subject: below --
2008-12-03 11:29 [Qemu-devel] [PATCH] Introduce --enable-binfmt-misc configure option Kirill A. Shutemov
2008-12-03 11:29 ` [Qemu-devel] [PATCH] Fix fstatat64()/newfstatat() syscall implementation Kirill A. Shutemov
2008-12-03 11:29 ` [Qemu-devel] [PATCH] Move abi_* typedefs into qemu-types.h Kirill A. Shutemov
2008-12-03 11:29 ` [Qemu-devel] [PATCH] linux-user: Safety belt for h2g Kirill A. Shutemov
2008-12-06 20:04 ` Edgar E. Iglesias
2008-12-08 18:15 ` Aurelien Jarno
2008-12-08 19:25 ` Andreas Färber
2008-12-09 7:34 ` Jan Kiszka
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).