BSD support (NetBSD, FreeBSD, Dragonfly)
Hello!
qemu 0.11.0 doesn't build on NetBSD out of the box, it doesn't on FreeBSD and Dragonfly either.
exec.c renamed from exec.c.orig +1 -1
@@ -464,7 +464,7 @@ exit(1); } } -#elif defined(__FreeBSD__) || defined(__DragonFly__) +#elif defined(__FreeBSD__) || defined(__DragonFly__) || defined(__NetBSD__) {int flags;void *addr =NULL ;
osdep.c renamed from osdep.c.orig +2 -2
@@ -110,7 +110,7 @@void *ptr;/* no need (?) for a dummy file on OpenBSD/FreeBSD */ -#if defined(__OpenBSD__) || defined(__FreeBSD__) || defined(__DragonFly__) +#if defined(__OpenBSD__) || defined(__FreeBSD__) || defined(__DragonFly__) || defined(__NetBSD__)int map_anon =MAP_ANON ;#else int map_anon =0 ;
@@ -181,7 +181,7 @@ } size = (size +4095 ) & ~4095 ;ftruncate (phys_ram_fd, phys_ram_size + size); -#endif /* !(__OpenBSD__ || __FreeBSD__ || __DragonFly__) */ +#endif /* !(__OpenBSD__ || __FreeBSD__ || __DragonFly__ || __NetBSD__) */ ptr = mmap(NULL, size, PROT_WRITE | PROT_READ, map_anon | MAP_SHARED,
vl.c renamed from vl.c.orig +2 -2
@@ -567,7 +567,7 @@ { use_rt_clock =0 ;#if defined(__linux__) || (defined(__FreeBSD__) && __FreeBSD_version >=500000 ) \ - || defined(__DragonFly__) + || defined(__DragonFly__) || defined(__NetBSD__) {struct timespec ts;if (clock_gettime (CLOCK_MONOTONIC , &ts) ==0 ) {
@@ -580,7 +580,7 @@static int64_t get_clock (void ) {#if defined(__linux__) || (defined(__FreeBSD__) && __FreeBSD_version >=500000 ) \ - || defined(__DragonFly__) + || defined(__DragonFly__) || defined(__NetBSD__)if (use_rt_clock) {struct timespec ts;clock_gettime (CLOCK_MONOTONIC , &ts);
cpu-exec.c renamed from cpu-exec.c.orig +17 -1
@@ -1247,6 +1247,20 @@# define TRAP_sig (context) ((context)->uc_mcontext->es.trapno)# define ERROR_sig (context) ((context)->uc_mcontext->es.err)# define MASK_sig (context) ((context)->uc_sigmask) +#elif defined (__NetBSD__) +# include <ucontext.h> + +# define EIP_sig (context) ((context)->uc_mcontext.__gregs[_REG_EIP]) +# define TRAP_sig (context) ((context)->uc_mcontext.__gregs[_REG_TRAPNO]) +# define ERROR_sig (context) ((context)->uc_mcontext.__gregs[_REG_ERR]) +# define MASK_sig (context) ((context)->uc_sigmask) +#elif defined (__FreeBSD__) || defined(__DragonFly__) +# include <ucontext.h> + +# define EIP_sig (context) (*((unsigned long*)&(context)->uc_mcontext.mc_eip)) +# define TRAP_sig (context) ((context)->uc_mcontext.mc_trapno) +# define ERROR_sig (context) ((context)->uc_mcontext.mc_err) +# define MASK_sig (context) ((context)->uc_sigmask)#elif defined(__OpenBSD__)# define EIP_sig (context) ((context)->sc_eip)# define TRAP_sig (context) ((context)->sc_trapno)
@@ -1263,7 +1277,9 @@ void *puc) {siginfo_t *info = pinfo; -#if defined(__OpenBSD__) +#if defined(__NetBSD__) || defined (__FreeBSD__) || defined(__DragonFly__) +ucontext_t *uc = puc; +#elif defined(__OpenBSD__)struct sigcontext *uc = puc;#else struct ucontext *uc = puc;
Signature · 1 line
HE CE3OH...
Quoted 1 line · Aleksej Saushev
Hello!
Hi!
Quoted 27 lines
qemu 0.11.0 doesn't build on NetBSD out of the box, it doesn't on FreeBSD and Dragonfly either.
exec.c renamed from exec.c.orig +1
-1@@ -464,7 +464,7 @@ exit(1); } } -#elif defined(__FreeBSD__) || defined(__DragonFly__) +#elif defined(__FreeBSD__) || defined(__DragonFly__) || defined(__NetBSD__) {int flags;void *addr =NULL ;osdep.c renamed from osdep.c.orig +1
-1@@ -110,7 +110,7 @@void *ptr;/* no need (?) for a dummy file on OpenBSD/FreeBSD */ -#if defined(__OpenBSD__) || defined(__FreeBSD__) || defined(__DragonFly__) +#if defined(__OpenBSD__) || defined(__FreeBSD__) || defined(__DragonFly__) || defined(__NetBSD__)int map_anon =MAP_ANON ;#else int map_anon =0 ;
osdep.c line 187
Quoted 8 lines
osdep.c renamed from osdep.c.orig +1
-1@@ -181,7 +181,7 @@ } size = (size +4095 ) & ~4095 ;ftruncate (phys_ram_fd, phys_ram_size + size); -#endif /* !(__OpenBSD__ || __FreeBSD__ || __DragonFly__) */ +#endif /* !(__OpenBSD__ || __FreeBSD__ || __DragonFly__ || __NetBSD__) */ ptr = mmap(NULL, size, PROT_WRITE | PROT_READ, map_anon | MAP_SHARED,
While you are patching this code... There's a bug here that I've
mentioned before: size needs to be rounded up on the BSDs too, at least if you want to use kqemu: (which this oode is for.)
qemu/osdep.c +4 -2
@@ -110,7 +110,7 @@void *ptr;/* no need (?) for a dummy file on OpenBSD/FreeBSD */ -#if defined(__OpenBSD__) || defined(__FreeBSD__) || defined(__DragonFly__) +#if defined(__OpenBSD__) || defined(__FreeBSD__) || defined(__DragonFly__) || defined(__NetBSD__)int map_anon =MAP_ANON ;#else int map_anon =0 ;
@@ -179,9 +179,11 @@ }unlink (phys_ram_file); } +#endif /* !(__OpenBSD__ || __FreeBSD__ || __DragonFly__ || __NetBSD__) */ size = (size +4095 ) & ~4095 ; +#if !defined(__OpenBSD__) && !defined(__FreeBSD__) && !defined(__DragonFly__) || defined(__NetBSD__)ftruncate (phys_ram_fd, phys_ram_size + size); -#endif /* !(__OpenBSD__ || __FreeBSD__ || __DragonFly__) */ +#endif /* !(__OpenBSD__ || __FreeBSD__ || __DragonFly__ || __NetBSD__) */ ptr = mmap(NULL, size, PROT_WRITE | PROT_READ, map_anon | MAP_SHARED,
(Otoh kqemu has been removed in qemu git now so this can't be
committed anyway...)
Quoted 46 lines
vl.c renamed from vl.c.orig +2
-2@@ -567,7 +567,7 @@ { use_rt_clock =0 ;#if defined(__linux__) || (defined(__FreeBSD__) && __FreeBSD_version >=500000 ) \ - || defined(__DragonFly__) + || defined(__DragonFly__) || defined(__NetBSD__) {struct timespec ts;if (clock_gettime (CLOCK_MONOTONIC , &ts) ==0 ) {@@ -580,7 +580,7 @@static int64_t get_clock (void ) {#if defined(__linux__) || (defined(__FreeBSD__) && __FreeBSD_version >=500000 ) \ - || defined(__DragonFly__) + || defined(__DragonFly__) || defined(__NetBSD__)if (use_rt_clock) {struct timespec ts;clock_gettime (CLOCK_MONOTONIC , &ts);cpu-exec.c renamed from cpu-exec.c.orig +14
-0@@ -1247,6 +1247,20 @@# define TRAP_sig (context) ((context)->uc_mcontext->es.trapno)# define ERROR_sig (context) ((context)->uc_mcontext->es.err)# define MASK_sig (context) ((context)->uc_sigmask) +#elif defined (__NetBSD__) +# include <ucontext.h> + +# define EIP_sig (context) ((context)->uc_mcontext.__gregs[_REG_EIP]) +# define TRAP_sig (context) ((context)->uc_mcontext.__gregs[_REG_TRAPNO]) +# define ERROR_sig (context) ((context)->uc_mcontext.__gregs[_REG_ERR]) +# define MASK_sig (context) ((context)->uc_sigmask) +#elif defined (__FreeBSD__) || defined(__DragonFly__) +# include <ucontext.h> + +# define EIP_sig (context) (*((unsigned long*)&(context)->uc_mcontext.mc_eip)) +# define TRAP_sig (context) ((context)->uc_mcontext.mc_trapno) +# define ERROR_sig (context) ((context)->uc_mcontext.mc_err) +# define MASK_sig (context) ((context)->uc_sigmask)#elif defined(__OpenBSD__)# define EIP_sig (context) ((context)->sc_eip)# define TRAP_sig (context) ((context)->sc_trapno)
cpu-exec.c line 1285
Quoted 10 lines
cpu-exec.c renamed from cpu-exec.c.orig +3
-1@@ -1263,7 +1277,9 @@ void *puc) {siginfo_t *info = pinfo; -#if defined(__OpenBSD__) +#if defined(__NetBSD__) || defined (__FreeBSD__) || defined(__DragonFly__) +ucontext_t *uc = puc; +#elif defined(__OpenBSD__)struct sigcontext *uc = puc;#else struct ucontext *uc = puc;
And I had a simpler (FreeBSD-only) version of this diff in my bsd-user
patches [1], so I took yours instead and added amd64 code:
qemu/cpu-exec.c +25 -2
@@ -805,6 +805,20 @@ static inline int handle_cpu_signal(unsi# define TRAP_sig (context) ((context)->uc_mcontext->es.trapno)# define ERROR_sig (context) ((context)->uc_mcontext->es.err)# define MASK_sig (context) ((context)->uc_sigmask) +#elif defined (__NetBSD__) +# include <ucontext.h> + +# define EIP_sig (context) ((context)->uc_mcontext.__gregs[_REG_EIP]) +# define TRAP_sig (context) ((context)->uc_mcontext.__gregs[_REG_TRAPNO]) +# define ERROR_sig (context) ((context)->uc_mcontext.__gregs[_REG_ERR]) +# define MASK_sig (context) ((context)->uc_sigmask) +#elif defined (__FreeBSD__) || defined(__DragonFly__) +# include <ucontext.h> + +# define EIP_sig (context) (*((unsigned long*)&(context)->uc_mcontext.mc_eip)) +# define TRAP_sig (context) ((context)->uc_mcontext.mc_trapno) +# define ERROR_sig (context) ((context)->uc_mcontext.mc_err) +# define MASK_sig (context) ((context)->uc_sigmask)#elif defined(__OpenBSD__)# define EIP_sig (context) ((context)->sc_eip)# define TRAP_sig (context) ((context)->sc_trapno)
@@ -821,7 +835,9 @@ int cpu_signal_handler(int host_signum, void *puc) {siginfo_t *info = pinfo; -#if defined(__OpenBSD__) +#if defined(__NetBSD__) || defined (__FreeBSD__) || defined(__DragonFly__) +ucontext_t *uc = puc; +#elif defined(__OpenBSD__)struct sigcontext *uc = puc;#else struct ucontext *uc = puc;
@@ -855,6 +871,13 @@ int cpu_signal_handler(int host_signum,#define TRAP_sig (context) ((context)->sc_trapno)#define ERROR_sig (context) ((context)->sc_err)#define MASK_sig (context) ((context)->sc_mask) +#elif defined (__FreeBSD__) || defined(__DragonFly__) +#include <ucontext.h> + +#define PC_sig (context) (*((unsigned long*)&(context)->uc_mcontext.mc_rip)) +#define TRAP_sig (context) ((context)->uc_mcontext.mc_trapno) +#define ERROR_sig (context) ((context)->uc_mcontext.mc_err) +#define MASK_sig (context) ((context)->uc_sigmask)#else #define PC_sig (context) ((context)->uc_mcontext.gregs[REG_RIP])#define TRAP_sig (context) ((context)->uc_mcontext.gregs[REG_TRAPNO])
@@ -867,7 +890,7 @@ int cpu_signal_handler(int host_signum, {siginfo_t *info = pinfo;unsigned long pc; -#ifdef __NetBSD__ +#if defined(__NetBSD__) || defined (__FreeBSD__) || defined(__DragonFly__)ucontext_t *uc = puc;#elif defined(__OpenBSD__)struct sigcontext *uc = puc;
(Btw you need to post such a line too when submitting patches, I can't
find the relevant thread from the qemu list now but I found at least this:
http://kerneltrap.org/node/3180
)
Cheers,
Juergen
[1] See this thread:
http://lists.freebsd.org/pipermail/freebsd-emulation/2009-October/006953.html
Hello!
Is there any progress? Anything wrong?
Quoted 88 lines · Aleksej Saushev
qemu 0.11.0 doesn't build on NetBSD out of the box, it doesn't on FreeBSD and Dragonfly either.
exec.c renamed from exec.c.orig +1
-1@@ -464,7 +464,7 @@ exit(1); } } -#elif defined(__FreeBSD__) || defined(__DragonFly__) +#elif defined(__FreeBSD__) || defined(__DragonFly__) || defined(__NetBSD__) {int flags;void *addr =NULL ;osdep.c renamed from osdep.c.orig +2
-2@@ -110,7 +110,7 @@void *ptr;/* no need (?) for a dummy file on OpenBSD/FreeBSD */ -#if defined(__OpenBSD__) || defined(__FreeBSD__) || defined(__DragonFly__) +#if defined(__OpenBSD__) || defined(__FreeBSD__) || defined(__DragonFly__) || defined(__NetBSD__)int map_anon =MAP_ANON ;#else int map_anon =0 ;@@ -181,7 +181,7 @@ } size = (size +4095 ) & ~4095 ;ftruncate (phys_ram_fd, phys_ram_size + size); -#endif /* !(__OpenBSD__ || __FreeBSD__ || __DragonFly__) */ +#endif /* !(__OpenBSD__ || __FreeBSD__ || __DragonFly__ || __NetBSD__) */ ptr = mmap(NULL, size, PROT_WRITE | PROT_READ, map_anon | MAP_SHARED,vl.c renamed from vl.c.orig +2
-2@@ -567,7 +567,7 @@ { use_rt_clock =0 ;#if defined(__linux__) || (defined(__FreeBSD__) && __FreeBSD_version >=500000 ) \ - || defined(__DragonFly__) + || defined(__DragonFly__) || defined(__NetBSD__) {struct timespec ts;if (clock_gettime (CLOCK_MONOTONIC , &ts) ==0 ) {@@ -580,7 +580,7 @@static int64_t get_clock (void ) {#if defined(__linux__) || (defined(__FreeBSD__) && __FreeBSD_version >=500000 ) \ - || defined(__DragonFly__) + || defined(__DragonFly__) || defined(__NetBSD__)if (use_rt_clock) {struct timespec ts;clock_gettime (CLOCK_MONOTONIC , &ts);cpu-exec.c renamed from cpu-exec.c.orig +17
-1@@ -1247,6 +1247,20 @@# define TRAP_sig (context) ((context)->uc_mcontext->es.trapno)# define ERROR_sig (context) ((context)->uc_mcontext->es.err)# define MASK_sig (context) ((context)->uc_sigmask) +#elif defined (__NetBSD__) +# include <ucontext.h> + +# define EIP_sig (context) ((context)->uc_mcontext.__gregs[_REG_EIP]) +# define TRAP_sig (context) ((context)->uc_mcontext.__gregs[_REG_TRAPNO]) +# define ERROR_sig (context) ((context)->uc_mcontext.__gregs[_REG_ERR]) +# define MASK_sig (context) ((context)->uc_sigmask) +#elif defined (__FreeBSD__) || defined(__DragonFly__) +# include <ucontext.h> + +# define EIP_sig (context) (*((unsigned long*)&(context)->uc_mcontext.mc_eip)) +# define TRAP_sig (context) ((context)->uc_mcontext.mc_trapno) +# define ERROR_sig (context) ((context)->uc_mcontext.mc_err) +# define MASK_sig (context) ((context)->uc_sigmask)#elif defined(__OpenBSD__)# define EIP_sig (context) ((context)->sc_eip)# define TRAP_sig (context) ((context)->sc_trapno)@@ -1263,7 +1277,9 @@ void *puc) {siginfo_t *info = pinfo; -#if defined(__OpenBSD__) +#if defined(__NetBSD__) || defined (__FreeBSD__) || defined(__DragonFly__) +ucontext_t *uc = puc; +#elif defined(__OpenBSD__)struct sigcontext *uc = puc;#else struct ucontext *uc = puc;
Signature · 1 line
HE CE3OH...