Fix for random Qemu crashes
RFC 1/1 Fix for random Qemu crashes
Here's an updated patch to fix the inlining problems that make some Qemu targets crash randomly.
As we have at least one broken target in the CVS because of this bug (and maybe more), we have an urgent need of a fix. I'll then commit this patch today if there is no other fix proposed that actually solves the problem.
Signature · 2 lines
J. Mayer <[email protected]> Never organized
Index: exec-all.h
===================================================================
RCS file: /sources/qemu/qemu/exec-all.h,v
retrieving revision 1.70
exec-all.h +0 -30
@@ -21,36 +21,6 @@/* allow to see translation results - the slowdown should be negligible, so we leave it */ #define DEBUG_DISAS -#ifndef glue -#define xglue (x, y) x ## y -#define glue (x, y) xglue(x, y) -#define stringify (s) tostring(s) -#define tostring (s) #s -#endif - -#ifndef likely -#if __GNUC__ <3 -#define __builtin_expect (x, n) (x) -#endif - -#define likely (x) __builtin_expect(!!(x), 1) -#define unlikely (x) __builtin_expect(!!(x), 0) -#endif - -#ifndef always_inline -#if (__GNUC__ <3 ) || defined(__APPLE__) -#define always_inline inline -#else -#define always_inline __attribute__ (( always_inline )) inline -#endif -#endif - -#ifdef __i386__ -#define REGPARM (n) __attribute((regparm(n))) -#else -#define REGPARM (n) -#endif -/* is_jmp field values */ #define DISAS_NEXT 0/* next instruction can be analyzed */ #define DISAS_JUMP 1/* only pc was modified dynamically */
Index: osdep.h
===================================================================
RCS file: /sources/qemu/qemu/osdep.h,v
retrieving revision 1.10
osdep.h +38 -0
@@ -3,6 +3,44 @@#include <stdarg.h> +#ifndef glue +#define xglue (x, y) x ## y +#define glue (x, y) xglue(x, y) +#define stringify (s) tostring(s) +#define tostring (s) #s +#endif + +#ifndef likely +#if __GNUC__ <3 +#define __builtin_expect (x, n) (x) +#endif + +#define likely (x) __builtin_expect(!!(x), 1) +#define unlikely (x) __builtin_expect(!!(x), 0) +#endif + +#ifndef MIN +#define MIN (a, b) (((a) < (b)) ? (a) : (b)) +#endif +#ifndef MAX +#define MAX (a, b) (((a) > (b)) ? (a) : (b)) +#endif + +#ifndef always_inline +#if (__GNUC__ <3 ) || defined(__APPLE__) +#define always_inline inline +#else +#define always_inline __attribute__ (( always_inline )) __inline__ +#endif +#endif +#define inline always_inline + +#ifdef __i386__ +#define REGPARM (n) __attribute((regparm(n))) +#else +#define REGPARM (n) +#endif +#define qemu_printf printfvoid *qemu_malloc (size_t size);
Index: qemu-common.h
===================================================================
RCS file: /sources/qemu/qemu/qemu-common.h,v
retrieving revision 1.2
qemu-common.h +0 -31
@@ -62,37 +62,6 @@ static inline char *realpath(const char#endif /* !defined(NEED_CPU_H) */ -#ifndef glue -#define xglue (x, y) x ## y -#define glue (x, y) xglue(x, y) -#define stringify (s) tostring(s) -#define tostring (s) #s -#endif - -#ifndef likely -#if __GNUC__ <3 -#define __builtin_expect (x, n) (x) -#endif - -#define likely (x) __builtin_expect(!!(x), 1) -#define unlikely (x) __builtin_expect(!!(x), 0) -#endif - -#ifndef MIN -#define MIN (a, b) (((a) < (b)) ? (a) : (b)) -#endif -#ifndef MAX -#define MAX (a, b) (((a) > (b)) ? (a) : (b)) -#endif - -#ifndef always_inline -#if (__GNUC__ <3 ) || defined(__APPLE__) -#define always_inline inline -#else -#define always_inline __attribute__ (( always_inline )) inline -#endif -#endif -/* bottom halves */ typedef struct QEMUBH QEMUBH ;
Index: translate-op.c
===================================================================
RCS file: /sources/qemu/qemu/translate-op.c,v
retrieving revision 1.3
translate-op.c +1 -0
@@ -24,6 +24,7 @@#include <inttypes.h> #include "config.h" +#include "osdep.h" enum {#define DEF(s, n, copy_size) INDEX_op_ ## s,
Index: darwin-user/qemu.h
===================================================================
RCS file: /sources/qemu/qemu/darwin-user/qemu.h,v
retrieving revision 1.1
qemu.h +2 -2
@@ -1,13 +1,13 @@#ifndef GEMU_H #define GEMU_H -#include "thunk.h" -#include <signal.h> #include <string.h> #include "cpu.h" +#include "thunk.h" +#include "gdbstub.h" typedef siginfo_t target_siginfo_t ;