summaryrefslogtreecommitdiff
path: root/emulators/qemu-devel/files/patch-z2b-bsd-user-sson-002b
blob: 799c6e75ee234d8ddad065b5ee6681de9a1988ed (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
diff --git a/bsd-user/signal.c b/bsd-user/signal.c
index 0502a6a..52441c4 100644
--- a/bsd-user/signal.c
+++ b/bsd-user/signal.c
@@ -31,7 +31,7 @@
 #include "qemu.h"
 #include "target_signal.h"
 
-// #define DEBUG_SIGNAL
+//#define DEBUG_SIGNAL
 
 #ifndef _NSIG
 #define _NSIG	128
@@ -441,7 +441,7 @@ host_signal_handler(int host_signum, siginfo_t *info, void *puc)
 	 * we forward to it some signals.
 	 */
 	if ((host_signum == SIGSEGV || host_signum == SIGBUS) &&
-	    info->si_code > 0) {
+	    info->si_code < 0x10000) {
 		if (cpu_signal_handler(host_signum, info, puc))
 			return;
 	}
@@ -1099,6 +1099,7 @@ signal_init(void)
 
 	sigfillset(&act.sa_mask);
 	act.sa_sigaction = host_signal_handler;
+	act.sa_flags = SA_SIGINFO;
 
 	for (i = 1; i <= TARGET_NSIG; i++) {
 		host_sig = target_to_host_signal(i);
diff --git a/bsd-user/syscall.c b/bsd-user/syscall.c
index c627c62..625c3cf 100644
--- a/bsd-user/syscall.c
+++ b/bsd-user/syscall.c
@@ -3544,6 +3544,30 @@ do_stat:
 	 }
 	 break;
 
+#ifdef TARGET_FREEBSD_NR_pdwait4
+    case TARGET_FREEBSD_NR_pdwait4:
+	 {
+		 int status;
+		 abi_long status_ptr = arg2;
+		 struct rusage rusage, *rusage_ptr;
+		 abi_long target_rusage = arg4;
+
+		 if (target_rusage)
+			 rusage_ptr = &rusage;
+		 else
+			 rusage_ptr = NULL;
+		 ret = get_errno(wait4(arg1, &status, arg3, rusage_ptr));
+		 if (!is_error(ret)) {
+			 status = host_to_target_waitstatus(status);
+			 if (put_user_s32(status, status_ptr))
+				 goto efault;
+			 if (target_rusage)
+				 host_to_target_rusage(target_rusage, &rusage);
+		 }
+	 }
+	 break;
+#endif /* TARGET_FREEBSD_NR_pdwait4 */
+
     case TARGET_FREEBSD_NR_accept:
 	 ret = do_accept(arg1, arg2, arg3);
 	 break;
@@ -3803,6 +3827,20 @@ do_stat:
 	 break;
 #endif
 
+    case TARGET_FREEBSD_NR_pdkill:
+	 ret = get_errno(pdkill(arg1, target_to_host_signal(arg2)));
+	 break;
+
+    case TARGET_FREEBSD_NR_pdgetpid:
+	 {
+		 pid_t pid;
+
+		 ret = get_errno(pdgetpid(arg1, &pid));
+		 if (put_user_u32(pid, arg2))
+			 goto efault;
+	 }
+	 break;
+
     case TARGET_FREEBSD_NR_sigaction:
 	 {
 		 struct target_sigaction *old_act, act, oact, *pact;
@@ -4014,27 +4052,88 @@ do_stat:
 
 #ifdef TARGET_FREEBSD_NR_aio_read
     case TARGET_FREEBSD_NR_aio_read:
+	 ret = unimplemented(num);
+	 break;
 #endif
 #ifdef TARGET_FREEBSD_NR_aio_write
     case TARGET_FREEBSD_NR_aio_write:
+	 ret = unimplemented(num);
+	 break;
 #endif
 #ifdef TARGET_FREEBSD_NR_aio_return
     case TARGET_FREEBSD_NR_aio_return:
+	 ret = unimplemented(num);
+	 break;
 #endif
 #ifdef TARGET_FREEBSD_NR_aio_suspend
     case TARGET_FREEBSD_NR_aio_suspend:
+	 ret = unimplemented(num);
+	 break;
 #endif
 #ifdef TARGET_FREEBSD_NR_aio_cancel
     case TARGET_FREEBSD_NR_aio_cancel:
+	 ret = unimplemented(num);
+	 break;
 #endif
 #ifdef TARGET_FREEBSD_NR_aio_error
     case TARGET_FREEBSD_NR_aio_error:
+	 ret = unimplemented(num);
+	 break;
 #endif
 #ifdef TARGET_FREEBSD_NR_aio_waitcomplete
     case TARGET_FREEBSD_NR_aio_waitcomplete:
+	 ret = unimplemented(num);
+	 break;
 #endif
 #ifdef TARGET_FREEBSD_NR_lio_listio
     case TARGET_FREEBSD_NR_lio_listio:
+	 ret = unimplemented(num);
+	 break;
+#endif
+
+#if 0 /* XXX not supported in libc yet, it seems (10.0 addition). */
+    case TARGET_FREEBSD_NR_posix_fadvise:
+	 {
+		 off_t offset = arg2, len = arg3;
+		 int advice = arg4;
+
+#if TARGET_ABI_BITS == 32
+		 if (regpairs_aligned(cpu_env)) {
+			 offset = target_offset64(arg3, arg4);
+			 len = target_offset64(arg5, arg6);
+			 advice = arg7;
+		 } else {
+			 offset = target_offset64(arg2, arg3);
+			 len = target_offset64(arg4, arg5);
+			 advice = arg6;
+		 }
+#endif
+		 ret = get_errno(posix_fadvise(arg1, offset, len, advice));
+	 }
+	 break;
+#endif
+
+    case TARGET_FREEBSD_NR_posix_fallocate:
+	 {
+		 off_t offset = arg2, len = arg3;
+
+#if TARGET_ABI_BITS == 32
+		 if (regpairs_aligned(cpu_env)) {
+			 offset = target_offset64(arg3, arg4);
+			 len = target_offset64(arg5, arg6);
+		 } else {
+			 offset = target_offset64(arg2, arg3);
+			 len = target_offset64(arg4, arg5);
+		 }
+#endif
+		 ret = get_errno(posix_fallocate(arg1, offset, len));
+	 }
+	 break;
+
+#ifdef TARGET_FREEBSD_posix_openpt
+    case TARGET_FREEBSD_posix_openpt:
+	 ret = get_errno(posix_openpt(arg1));
+	 break;
 #endif
 
     case TARGET_FREEBSD_NR_yield:
@@ -4054,9 +4153,6 @@ do_stat:
     case TARGET_FREEBSD_NR_swapon:
     case TARGET_FREEBSD_NR_swapoff:
 
-    case TARGET_FREEBSD_NR_pdkill:
-    case TARGET_FREEBSD_NR_pdgetpid:
-
     case TARGET_FREEBSD_NR_thr_create:
     case TARGET_FREEBSD_NR_thr_exit:
     case TARGET_FREEBSD_NR_thr_self:
@@ -4080,9 +4176,6 @@ do_stat:
     case TARGET_FREEBSD_NR__umtx_lock:
     case TARGET_FREEBSD_NR__umtx_unlock:
 
-    case TARGET_FREEBSD_NR_posix_fadvise:
-    case TARGET_FREEBSD_NR_posix_fallocate:
-
     case TARGET_FREEBSD_NR_rctl_get_racct:
     case TARGET_FREEBSD_NR_rctl_get_rules:
     case TARGET_FREEBSD_NR_rctl_add_rule:
diff --git a/user-exec.c b/user-exec.c
index 9ad4858..bf29e84 100644
--- a/user-exec.c
+++ b/user-exec.c
@@ -38,7 +38,7 @@
 #include <sys/ucontext.h>
 #endif
 
-#define DEBUG_SIGNAL
+//#define DEBUG_SIGNAL
 
 static void exception_action(CPUArchState *env1)
 {
@@ -103,7 +103,7 @@ static inline int handle_cpu_signal(uintptr_t pc, unsigned long address,
     }
 #endif
 #if defined(DEBUG_SIGNAL)
-    qemu_printf("qemu: SIGSEGV pc=0x%08lx address=%08lx w=%d oldset=0x%08lx\n",
+    qemu_printf("qemu: SIGSEGV pc=0x%08lx address=0x%08lx w=%d oldset=0x%08lx\n",
                 pc, address, is_write, *(unsigned long *)old_set);
 #endif
     /* XXX: locking issue */