Revision a4c075f1

b/linux-user/elfload.c
867 867

  
868 868
#endif /* TARGET_ALPHA */
869 869

  
870
#ifdef TARGET_S390X
871

  
872
#define ELF_START_MMAP (0x20000000000ULL)
873

  
874
#define elf_check_arch(x) ( (x) == ELF_ARCH )
875

  
876
#define ELF_CLASS	ELFCLASS64
877
#define ELF_DATA	ELFDATA2MSB
878
#define ELF_ARCH	EM_S390
879

  
880
static inline void init_thread(struct target_pt_regs *regs, struct image_info *infop)
881
{
882
    regs->psw.addr = infop->entry;
883
    regs->psw.mask = PSW_MASK_64 | PSW_MASK_32;
884
    regs->gprs[15] = infop->start_stack;
885
}
886

  
887
#endif /* TARGET_S390X */
888

  
870 889
#ifndef ELF_PLATFORM
871 890
#define ELF_PLATFORM (NULL)
872 891
#endif
b/linux-user/main.c
2701 2701
}
2702 2702
#endif /* TARGET_ALPHA */
2703 2703

  
2704
#ifdef TARGET_S390X
2705
void cpu_loop(CPUS390XState *env)
2706
{
2707
    int trapnr;
2708
    target_siginfo_t info;
2709

  
2710
    while (1) {
2711
        trapnr = cpu_s390x_exec (env);
2712

  
2713
        switch (trapnr) {
2714
        case EXCP_INTERRUPT:
2715
            /* just indicate that signals should be handled asap */
2716
            break;
2717
        case EXCP_DEBUG:
2718
            {
2719
                int sig;
2720

  
2721
                sig = gdb_handlesig (env, TARGET_SIGTRAP);
2722
                if (sig) {
2723
                    info.si_signo = sig;
2724
                    info.si_errno = 0;
2725
                    info.si_code = TARGET_TRAP_BRKPT;
2726
                    queue_signal(env, info.si_signo, &info);
2727
                }
2728
            }
2729
            break;
2730
        case EXCP_SVC:
2731
            {
2732
                int n = env->int_svc_code;
2733
                if (!n) {
2734
                    /* syscalls > 255 */
2735
                    n = env->regs[1];
2736
                }
2737
                env->psw.addr += env->int_svc_ilc;
2738
                env->regs[2] = do_syscall(env, n,
2739
                           env->regs[2],
2740
                           env->regs[3],
2741
                           env->regs[4],
2742
                           env->regs[5],
2743
                           env->regs[6],
2744
                           env->regs[7]);
2745
            }
2746
            break;
2747
        case EXCP_ADDR:
2748
            {
2749
                info.si_signo = SIGSEGV;
2750
                info.si_errno = 0;
2751
                /* XXX: check env->error_code */
2752
                info.si_code = TARGET_SEGV_MAPERR;
2753
                info._sifields._sigfault._addr = env->__excp_addr;
2754
                queue_signal(env, info.si_signo, &info);
2755
            }
2756
            break;
2757
        case EXCP_SPEC:
2758
            {
2759
                fprintf(stderr,"specification exception insn 0x%08x%04x\n", ldl(env->psw.addr), lduw(env->psw.addr + 4));
2760
                info.si_signo = SIGILL;
2761
                info.si_errno = 0;
2762
                info.si_code = TARGET_ILL_ILLOPC;
2763
                info._sifields._sigfault._addr = env->__excp_addr;
2764
                queue_signal(env, info.si_signo, &info);
2765
            }
2766
            break;
2767
        default:
2768
            printf ("Unhandled trap: 0x%x\n", trapnr);
2769
            cpu_dump_state(env, stderr, fprintf, 0);
2770
            exit (1);
2771
        }
2772
        process_pending_signals (env);
2773
    }
2774
}
2775

  
2776
#endif /* TARGET_S390X */
2777

  
2704 2778
static void version(void)
2705 2779
{
2706 2780
    printf("qemu-" TARGET_ARCH " version " QEMU_VERSION QEMU_PKGVERSION
......
3450 3524
	    env->regs[15] = regs->acr;	    
3451 3525
	    env->pc = regs->erp;
3452 3526
    }
3527
#elif defined(TARGET_S390X)
3528
    {
3529
            int i;
3530
            for (i = 0; i < 16; i++) {
3531
                env->regs[i] = regs->gprs[i];
3532
            }
3533
            env->psw.mask = regs->psw.mask;
3534
            env->psw.addr = regs->psw.addr;
3535
    }
3453 3536
#else
3454 3537
#error unsupported target CPU
3455 3538
#endif
b/linux-user/s390x/syscall.h
1
/* this typedef defines how a Program Status Word looks like */
2
typedef struct {
3
    abi_ulong mask;
4
    abi_ulong addr;
5
} __attribute__ ((aligned(8))) target_psw_t;
6

  
7
/*
8
 * The pt_regs struct defines the way the registers are stored on
9
 * the stack during a system call.
10
 */
11

  
12
#define TARGET_NUM_GPRS        16
13

  
14
struct target_pt_regs {
15
    abi_ulong args[1];
16
    target_psw_t psw;
17
    abi_ulong gprs[TARGET_NUM_GPRS];
18
    abi_ulong orig_gpr2;
19
    unsigned short ilc;
20
    unsigned short trap;
21
};
22

  
23
#define UNAME_MACHINE "s390x"
b/linux-user/s390x/syscall_nr.h
1
/*
2
 * This file contains the system call numbers.
3
 */
4

  
5
#define TARGET_NR_exit                 1
6
#define TARGET_NR_fork                 2
7
#define TARGET_NR_read                 3
8
#define TARGET_NR_write                4
9
#define TARGET_NR_open                 5
10
#define TARGET_NR_close                6
11
#define TARGET_NR_restart_syscall	  7
12
#define TARGET_NR_creat                8
13
#define TARGET_NR_link                 9
14
#define TARGET_NR_unlink              10
15
#define TARGET_NR_execve              11
16
#define TARGET_NR_chdir               12
17
#define TARGET_NR_mknod               14
18
#define TARGET_NR_chmod               15
19
#define TARGET_NR_lseek               19
20
#define TARGET_NR_getpid              20
21
#define TARGET_NR_mount               21
22
#define TARGET_NR_umount              22
23
#define TARGET_NR_ptrace              26
24
#define TARGET_NR_alarm               27
25
#define TARGET_NR_pause               29
26
#define TARGET_NR_utime               30
27
#define TARGET_NR_access              33
28
#define TARGET_NR_nice                34
29
#define TARGET_NR_sync                36
30
#define TARGET_NR_kill                37
31
#define TARGET_NR_rename              38
32
#define TARGET_NR_mkdir               39
33
#define TARGET_NR_rmdir               40
34
#define TARGET_NR_dup                 41
35
#define TARGET_NR_pipe                42
36
#define TARGET_NR_times               43
37
#define TARGET_NR_brk                 45
38
#define TARGET_NR_signal              48
39
#define TARGET_NR_acct                51
40
#define TARGET_NR_umount2             52
41
#define TARGET_NR_ioctl               54
42
#define TARGET_NR_fcntl               55
43
#define TARGET_NR_setpgid             57
44
#define TARGET_NR_umask               60
45
#define TARGET_NR_chroot              61
46
#define TARGET_NR_ustat               62
47
#define TARGET_NR_dup2                63
48
#define TARGET_NR_getppid             64
49
#define TARGET_NR_getpgrp             65
50
#define TARGET_NR_setsid              66
51
#define TARGET_NR_sigaction           67
52
#define TARGET_NR_sigsuspend          72
53
#define TARGET_NR_sigpending          73
54
#define TARGET_NR_sethostname         74
55
#define TARGET_NR_setrlimit           75
56
#define TARGET_NR_getrusage           77
57
#define TARGET_NR_gettimeofday        78
58
#define TARGET_NR_settimeofday        79
59
#define TARGET_NR_symlink             83
60
#define TARGET_NR_readlink            85
61
#define TARGET_NR_uselib              86
62
#define TARGET_NR_swapon              87
63
#define TARGET_NR_reboot              88
64
#define TARGET_NR_readdir             89
65
#define TARGET_NR_mmap                90
66
#define TARGET_NR_munmap              91
67
#define TARGET_NR_truncate            92
68
#define TARGET_NR_ftruncate           93
69
#define TARGET_NR_fchmod              94
70
#define TARGET_NR_getpriority         96
71
#define TARGET_NR_setpriority         97
72
#define TARGET_NR_statfs              99
73
#define TARGET_NR_fstatfs            100
74
#define TARGET_NR_socketcall         102
75
#define TARGET_NR_syslog             103
76
#define TARGET_NR_setitimer          104
77
#define TARGET_NR_getitimer          105
78
#define TARGET_NR_stat               106
79
#define TARGET_NR_lstat              107
80
#define TARGET_NR_fstat              108
81
#define TARGET_NR_lookup_dcookie     110
82
#define TARGET_NR_vhangup            111
83
#define TARGET_NR_idle               112
84
#define TARGET_NR_wait4              114
85
#define TARGET_NR_swapoff            115
86
#define TARGET_NR_sysinfo            116
87
#define TARGET_NR_ipc                117
88
#define TARGET_NR_fsync              118
89
#define TARGET_NR_sigreturn          119
90
#define TARGET_NR_clone              120
91
#define TARGET_NR_setdomainname      121
92
#define TARGET_NR_uname              122
93
#define TARGET_NR_adjtimex           124
94
#define TARGET_NR_mprotect           125
95
#define TARGET_NR_sigprocmask        126
96
#define TARGET_NR_create_module      127
97
#define TARGET_NR_init_module        128
98
#define TARGET_NR_delete_module      129
99
#define TARGET_NR_get_kernel_syms    130
100
#define TARGET_NR_quotactl           131
101
#define TARGET_NR_getpgid            132
102
#define TARGET_NR_fchdir             133
103
#define TARGET_NR_bdflush            134
104
#define TARGET_NR_sysfs              135
105
#define TARGET_NR_personality        136
106
#define TARGET_NR_afs_syscall        137 /* Syscall for Andrew File System */
107
#define TARGET_NR_getdents           141
108
#define TARGET_NR_flock              143
109
#define TARGET_NR_msync              144
110
#define TARGET_NR_readv              145
111
#define TARGET_NR_writev             146
112
#define TARGET_NR_getsid             147
113
#define TARGET_NR_fdatasync          148
114
#define TARGET_NR__sysctl            149
115
#define TARGET_NR_mlock              150
116
#define TARGET_NR_munlock            151
117
#define TARGET_NR_mlockall           152
118
#define TARGET_NR_munlockall         153
119
#define TARGET_NR_sched_setparam             154
120
#define TARGET_NR_sched_getparam             155
121
#define TARGET_NR_sched_setscheduler         156
122
#define TARGET_NR_sched_getscheduler         157
123
#define TARGET_NR_sched_yield                158
124
#define TARGET_NR_sched_get_priority_max     159
125
#define TARGET_NR_sched_get_priority_min     160
126
#define TARGET_NR_sched_rr_get_interval      161
127
#define TARGET_NR_nanosleep          162
128
#define TARGET_NR_mremap             163
129
#define TARGET_NR_query_module       167
130
#define TARGET_NR_poll               168
131
#define TARGET_NR_nfsservctl         169
132
#define TARGET_NR_prctl              172
133
#define TARGET_NR_rt_sigreturn       173
134
#define TARGET_NR_rt_sigaction       174
135
#define TARGET_NR_rt_sigprocmask     175
136
#define TARGET_NR_rt_sigpending      176
137
#define TARGET_NR_rt_sigtimedwait    177
138
#define TARGET_NR_rt_sigqueueinfo    178
139
#define TARGET_NR_rt_sigsuspend      179
140
#define TARGET_NR_pread64            180
141
#define TARGET_NR_pwrite64           181
142
#define TARGET_NR_getcwd             183
143
#define TARGET_NR_capget             184
144
#define TARGET_NR_capset             185
145
#define TARGET_NR_sigaltstack        186
146
#define TARGET_NR_sendfile           187
147
#define TARGET_NR_getpmsg		188
148
#define TARGET_NR_putpmsg		189
149
#define TARGET_NR_vfork		190
150
#define TARGET_NR_pivot_root         217
151
#define TARGET_NR_mincore            218
152
#define TARGET_NR_madvise            219
153
#define TARGET_NR_getdents64		220
154
#define TARGET_NR_readahead		222
155
#define TARGET_NR_setxattr		224
156
#define TARGET_NR_lsetxattr		225
157
#define TARGET_NR_fsetxattr		226
158
#define TARGET_NR_getxattr		227
159
#define TARGET_NR_lgetxattr		228
160
#define TARGET_NR_fgetxattr		229
161
#define TARGET_NR_listxattr		230
162
#define TARGET_NR_llistxattr		231
163
#define TARGET_NR_flistxattr		232
164
#define TARGET_NR_removexattr	233
165
#define TARGET_NR_lremovexattr	234
166
#define TARGET_NR_fremovexattr	235
167
#define TARGET_NR_gettid		236
168
#define TARGET_NR_tkill		237
169
#define TARGET_NR_futex		238
170
#define TARGET_NR_sched_setaffinity	239
171
#define TARGET_NR_sched_getaffinity	240
172
#define TARGET_NR_tgkill		241
173
/* Number 242 is reserved for tux */
174
#define TARGET_NR_io_setup		243
175
#define TARGET_NR_io_destroy		244
176
#define TARGET_NR_io_getevents	245
177
#define TARGET_NR_io_submit		246
178
#define TARGET_NR_io_cancel		247
179
#define TARGET_NR_exit_group		248
180
#define TARGET_NR_epoll_create	249
181
#define TARGET_NR_epoll_ctl		250
182
#define TARGET_NR_epoll_wait		251
183
#define TARGET_NR_set_tid_address	252
184
#define TARGET_NR_fadvise64		253
185
#define TARGET_NR_timer_create	254
186
#define TARGET_NR_timer_settime	(TARGET_NR_timer_create+1)
187
#define TARGET_NR_timer_gettime	(TARGET_NR_timer_create+2)
188
#define TARGET_NR_timer_getoverrun	(TARGET_NR_timer_create+3)
189
#define TARGET_NR_timer_delete	(TARGET_NR_timer_create+4)
190
#define TARGET_NR_clock_settime	(TARGET_NR_timer_create+5)
191
#define TARGET_NR_clock_gettime	(TARGET_NR_timer_create+6)
192
#define TARGET_NR_clock_getres	(TARGET_NR_timer_create+7)
193
#define TARGET_NR_clock_nanosleep	(TARGET_NR_timer_create+8)
194
/* Number 263 is reserved for vserver */
195
#define TARGET_NR_statfs64		265
196
#define TARGET_NR_fstatfs64		266
197
#define TARGET_NR_remap_file_pages	267
198
/* Number 268 is reserved for new sys_mbind */
199
/* Number 269 is reserved for new sys_get_mempolicy */
200
/* Number 270 is reserved for new sys_set_mempolicy */
201
#define TARGET_NR_mq_open		271
202
#define TARGET_NR_mq_unlink		272
203
#define TARGET_NR_mq_timedsend	273
204
#define TARGET_NR_mq_timedreceive	274
205
#define TARGET_NR_mq_notify		275
206
#define TARGET_NR_mq_getsetattr	276
207
#define TARGET_NR_kexec_load		277
208
#define TARGET_NR_add_key		278
209
#define TARGET_NR_request_key	279
210
#define TARGET_NR_keyctl		280
211
#define TARGET_NR_waitid		281
212
#define TARGET_NR_ioprio_set		282
213
#define TARGET_NR_ioprio_get		283
214
#define TARGET_NR_inotify_init	284
215
#define TARGET_NR_inotify_add_watch	285
216
#define TARGET_NR_inotify_rm_watch	286
217
/* Number 287 is reserved for new sys_migrate_pages */
218
#define TARGET_NR_openat		288
219
#define TARGET_NR_mkdirat		289
220
#define TARGET_NR_mknodat		290
221
#define TARGET_NR_fchownat		291
222
#define TARGET_NR_futimesat		292
223
#define TARGET_NR_unlinkat		294
224
#define TARGET_NR_renameat		295
225
#define TARGET_NR_linkat		296
226
#define TARGET_NR_symlinkat		297
227
#define TARGET_NR_readlinkat		298
228
#define TARGET_NR_fchmodat		299
229
#define TARGET_NR_faccessat		300
230
#define TARGET_NR_pselect6		301
231
#define TARGET_NR_ppoll		302
232
#define TARGET_NR_unshare		303
233
#define TARGET_NR_set_robust_list	304
234
#define TARGET_NR_get_robust_list	305
235
#define TARGET_NR_splice		306
236
#define TARGET_NR_sync_file_range	307
237
#define TARGET_NR_tee		308
238
#define TARGET_NR_vmsplice		309
239
/* Number 310 is reserved for new sys_move_pages */
240
#define TARGET_NR_getcpu		311
241
#define TARGET_NR_epoll_pwait	312
242
#define TARGET_NR_utimes		313
243
#define TARGET_NR_fallocate		314
244
#define TARGET_NR_utimensat		315
245
#define TARGET_NR_signalfd		316
246
#define TARGET_NR_timerfd		317
247
#define TARGET_NR_eventfd		318
248
#define TARGET_NR_timerfd_create	319
249
#define TARGET_NR_timerfd_settime	320
250
#define TARGET_NR_timerfd_gettime	321
251
#define TARGET_NR_signalfd4		322
252
#define TARGET_NR_eventfd2		323
253
#define TARGET_NR_inotify_init1	324
254
#define TARGET_NR_pipe2		325
255
#define TARGET_NR_dup3		326
256
#define TARGET_NR_epoll_create1	327
257
#undef NR_syscalls
258
#define NR_syscalls 328
259

  
260
/*
261
 * There are some system calls that are not present on 64 bit, some
262
 * have a different name although they do the same (e.g. TARGET_NR_chown32
263
 * is TARGET_NR_chown on 64 bit).
264
 */
265
#ifndef TARGET_S390X
266

  
267
#define TARGET_NR_time		 13
268
#define TARGET_NR_lchown		 16
269
#define TARGET_NR_setuid		 23
270
#define TARGET_NR_getuid		 24
271
#define TARGET_NR_stime		 25
272
#define TARGET_NR_setgid		 46
273
#define TARGET_NR_getgid		 47
274
#define TARGET_NR_geteuid		 49
275
#define TARGET_NR_getegid		 50
276
#define TARGET_NR_setreuid		 70
277
#define TARGET_NR_setregid		 71
278
#define TARGET_NR_getrlimit		 76
279
#define TARGET_NR_getgroups		 80
280
#define TARGET_NR_setgroups		 81
281
#define TARGET_NR_fchown		 95
282
#define TARGET_NR_ioperm		101
283
#define TARGET_NR_setfsuid		138
284
#define TARGET_NR_setfsgid		139
285
#define TARGET_NR__llseek		140
286
#define TARGET_NR__newselect 	142
287
#define TARGET_NR_setresuid		164
288
#define TARGET_NR_getresuid		165
289
#define TARGET_NR_setresgid		170
290
#define TARGET_NR_getresgid		171
291
#define TARGET_NR_chown		182
292
#define TARGET_NR_ugetrlimit		191	/* SuS compliant getrlimit */
293
#define TARGET_NR_mmap2		192
294
#define TARGET_NR_truncate64		193
295
#define TARGET_NR_ftruncate64	194
296
#define TARGET_NR_stat64		195
297
#define TARGET_NR_lstat64		196
298
#define TARGET_NR_fstat64		197
299
#define TARGET_NR_lchown32		198
300
#define TARGET_NR_getuid32		199
301
#define TARGET_NR_getgid32		200
302
#define TARGET_NR_geteuid32		201
303
#define TARGET_NR_getegid32		202
304
#define TARGET_NR_setreuid32		203
305
#define TARGET_NR_setregid32		204
306
#define TARGET_NR_getgroups32	205
307
#define TARGET_NR_setgroups32	206
308
#define TARGET_NR_fchown32		207
309
#define TARGET_NR_setresuid32	208
310
#define TARGET_NR_getresuid32	209
311
#define TARGET_NR_setresgid32	210
312
#define TARGET_NR_getresgid32	211
313
#define TARGET_NR_chown32		212
314
#define TARGET_NR_setuid32		213
315
#define TARGET_NR_setgid32		214
316
#define TARGET_NR_setfsuid32		215
317
#define TARGET_NR_setfsgid32		216
318
#define TARGET_NR_fcntl64		221
319
#define TARGET_NR_sendfile64		223
320
#define TARGET_NR_fadvise64_64	264
321
#define TARGET_NR_fstatat64		293
322

  
323
#else
324

  
325
#define TARGET_NR_select		142
326
#define TARGET_NR_getrlimit		191	/* SuS compliant getrlimit */
327
#define TARGET_NR_lchown  		198
328
#define TARGET_NR_getuid  		199
329
#define TARGET_NR_getgid  		200
330
#define TARGET_NR_geteuid  		201
331
#define TARGET_NR_getegid  		202
332
#define TARGET_NR_setreuid  		203
333
#define TARGET_NR_setregid  		204
334
#define TARGET_NR_getgroups  	205
335
#define TARGET_NR_setgroups  	206
336
#define TARGET_NR_fchown  		207
337
#define TARGET_NR_setresuid  	208
338
#define TARGET_NR_getresuid  	209
339
#define TARGET_NR_setresgid  	210
340
#define TARGET_NR_getresgid  	211
341
#define TARGET_NR_chown  		212
342
#define TARGET_NR_setuid  		213
343
#define TARGET_NR_setgid  		214
344
#define TARGET_NR_setfsuid  		215
345
#define TARGET_NR_setfsgid  		216
346
#define TARGET_NR_newfstatat		293
347

  
348
#endif
349

  
b/linux-user/s390x/target_signal.h
1
#ifndef TARGET_SIGNAL_H
2
#define TARGET_SIGNAL_H
3

  
4
#include "cpu.h"
5

  
6
typedef struct target_sigaltstack {
7
    abi_ulong ss_sp;
8
    int ss_flags;
9
    abi_ulong ss_size;
10
} target_stack_t;
11

  
12
/*
13
 * sigaltstack controls
14
 */
15
#define TARGET_SS_ONSTACK      1
16
#define TARGET_SS_DISABLE      2
17

  
18
#define TARGET_MINSIGSTKSZ     2048
19
#define TARGET_SIGSTKSZ        8192
20

  
21
static inline abi_ulong get_sp_from_cpustate(CPUS390XState *state)
22
{
23
   return state->regs[15];
24
}
25

  
26
#endif /* TARGET_SIGNAL_H */
b/linux-user/s390x/termbits.h
1
/*
2
 *  include/asm-s390/termbits.h
3
 *
4
 *  S390 version
5
 *
6
 *  Derived from "include/asm-i386/termbits.h"
7
 */
8

  
9
#define TARGET_NCCS 19
10
struct target_termios {
11
    unsigned int c_iflag;		/* input mode flags */
12
    unsigned int c_oflag;		/* output mode flags */
13
    unsigned int c_cflag;		/* control mode flags */
14
    unsigned int c_lflag;		/* local mode flags */
15
    unsigned char c_line;			/* line discipline */
16
    unsigned char c_cc[TARGET_NCCS];		/* control characters */
17
};
18

  
19
struct target_termios2 {
20
    unsigned int c_iflag;		/* input mode flags */
21
    unsigned int c_oflag;		/* output mode flags */
22
    unsigned int c_cflag;		/* control mode flags */
23
    unsigned int c_lflag;		/* local mode flags */
24
    unsigned char c_line;			/* line discipline */
25
    unsigned char c_cc[TARGET_NCCS];		/* control characters */
26
    unsigned int c_ispeed;		/* input speed */
27
    unsigned int c_ospeed;		/* output speed */
28
};
29

  
30
struct target_ktermios {
31
    unsigned int c_iflag;		/* input mode flags */
32
    unsigned int c_oflag;		/* output mode flags */
33
    unsigned int c_cflag;		/* control mode flags */
34
    unsigned int c_lflag;		/* local mode flags */
35
    unsigned char c_line;			/* line discipline */
36
    unsigned char c_cc[TARGET_NCCS];		/* control characters */
37
    unsigned int c_ispeed;		/* input speed */
38
    unsigned int c_ospeed;		/* output speed */
39
};
40

  
41
/* c_cc characters */
42
#define TARGET_VINTR 0
43
#define TARGET_VQUIT 1
44
#define TARGET_VERASE 2
45
#define TARGET_VKILL 3
46
#define TARGET_VEOF 4
47
#define TARGET_VTIME 5
48
#define TARGET_VMIN 6
49
#define TARGET_VSWTC 7
50
#define TARGET_VSTART 8
51
#define TARGET_VSTOP 9
52
#define TARGET_VSUSP 10
53
#define TARGET_VEOL 11
54
#define TARGET_VREPRINT 12
55
#define TARGET_VDISCARD 13
56
#define TARGET_VWERASE 14
57
#define TARGET_VLNEXT 15
58
#define TARGET_VEOL2 16
59

  
60
/* c_iflag bits */
61
#define TARGET_IGNBRK	0000001
62
#define TARGET_BRKINT	0000002
63
#define TARGET_IGNPAR	0000004
64
#define TARGET_PARMRK	0000010
65
#define TARGET_INPCK	0000020
66
#define TARGET_ISTRIP	0000040
67
#define TARGET_INLCR	0000100
68
#define TARGET_IGNCR	0000200
69
#define TARGET_ICRNL	0000400
70
#define TARGET_IUCLC	0001000
71
#define TARGET_IXON	0002000
72
#define TARGET_IXANY	0004000
73
#define TARGET_IXOFF	0010000
74
#define TARGET_IMAXBEL	0020000
75
#define TARGET_IUTF8	0040000
76

  
77
/* c_oflag bits */
78
#define TARGET_OPOST	0000001
79
#define TARGET_OLCUC	0000002
80
#define TARGET_ONLCR	0000004
81
#define TARGET_OCRNL	0000010
82
#define TARGET_ONOCR	0000020
83
#define TARGET_ONLRET	0000040
84
#define TARGET_OFILL	0000100
85
#define TARGET_OFDEL	0000200
86
#define TARGET_NLDLY	0000400
87
#define TARGET_NL0	0000000
88
#define TARGET_NL1	0000400
89
#define TARGET_CRDLY	0003000
90
#define TARGET_CR0	0000000
91
#define TARGET_CR1	0001000
92
#define TARGET_CR2	0002000
93
#define TARGET_CR3	0003000
94
#define TARGET_TABDLY	0014000
95
#define TARGET_TAB0	0000000
96
#define TARGET_TAB1	0004000
97
#define TARGET_TAB2	0010000
98
#define TARGET_TAB3	0014000
99
#define TARGET_XTABS	0014000
100
#define TARGET_BSDLY	0020000
101
#define TARGET_BS0	0000000
102
#define TARGET_BS1	0020000
103
#define TARGET_VTDLY	0040000
104
#define TARGET_VT0	0000000
105
#define TARGET_VT1	0040000
106
#define TARGET_FFDLY	0100000
107
#define TARGET_FF0	0000000
108
#define TARGET_FF1	0100000
109

  
110
/* c_cflag bit meaning */
111
#define TARGET_CBAUD	0010017
112
#define TARGET_B0	0000000		/* hang up */
113
#define TARGET_B50	0000001
114
#define TARGET_B75	0000002
115
#define TARGET_B110	0000003
116
#define TARGET_B134	0000004
117
#define TARGET_B150	0000005
118
#define TARGET_B200	0000006
119
#define TARGET_B300	0000007
120
#define TARGET_B600	0000010
121
#define TARGET_B1200	0000011
122
#define TARGET_B1800	0000012
123
#define TARGET_B2400	0000013
124
#define TARGET_B4800	0000014
125
#define TARGET_B9600	0000015
126
#define TARGET_B19200	0000016
127
#define TARGET_B38400	0000017
128
#define TARGET_EXTA B19200
129
#define TARGET_EXTB B38400
130
#define TARGET_CSIZE	0000060
131
#define TARGET_CS5	0000000
132
#define TARGET_CS6	0000020
133
#define TARGET_CS7	0000040
134
#define TARGET_CS8	0000060
135
#define TARGET_CSTOPB	0000100
136
#define TARGET_CREAD	0000200
137
#define TARGET_PARENB	0000400
138
#define TARGET_PARODD	0001000
139
#define TARGET_HUPCL	0002000
140
#define TARGET_CLOCAL	0004000
141
#define TARGET_CBAUDEX 0010000
142
#define TARGET_BOTHER  0010000
143
#define TARGET_B57600  0010001
144
#define TARGET_B115200 0010002
145
#define TARGET_B230400 0010003
146
#define TARGET_B460800 0010004
147
#define TARGET_B500000 0010005
148
#define TARGET_B576000 0010006
149
#define TARGET_B921600 0010007
150
#define TARGET_B1000000 0010010
151
#define TARGET_B1152000 0010011
152
#define TARGET_B1500000 0010012
153
#define TARGET_B2000000 0010013
154
#define TARGET_B2500000 0010014
155
#define TARGET_B3000000 0010015
156
#define TARGET_B3500000 0010016
157
#define TARGET_B4000000 0010017
158
#define TARGET_CIBAUD	  002003600000	/* input baud rate */
159
#define TARGET_CMSPAR	  010000000000		/* mark or space (stick) parity */
160
#define TARGET_CRTSCTS	  020000000000		/* flow control */
161

  
162
#define TARGET_IBSHIFT	  16		/* Shift from CBAUD to CIBAUD */
163

  
164
/* c_lflag bits */
165
#define TARGET_ISIG	0000001
166
#define TARGET_ICANON	0000002
167
#define TARGET_XCASE	0000004
168
#define TARGET_ECHO	0000010
169
#define TARGET_ECHOE	0000020
170
#define TARGET_ECHOK	0000040
171
#define TARGET_ECHONL	0000100
172
#define TARGET_NOFLSH	0000200
173
#define TARGET_TOSTOP	0000400
174
#define TARGET_ECHOCTL	0001000
175
#define TARGET_ECHOPRT	0002000
176
#define TARGET_ECHOKE	0004000
177
#define TARGET_FLUSHO	0010000
178
#define TARGET_PENDIN	0040000
179
#define TARGET_IEXTEN	0100000
180

  
181
/* tcflow() and TCXONC use these */
182
#define	TARGET_TCOOFF		0
183
#define	TARGET_TCOON		1
184
#define	TARGET_TCIOFF		2
185
#define	TARGET_TCION		3
186

  
187
/* tcflush() and TCFLSH use these */
188
#define	TARGET_TCIFLUSH	0
189
#define	TARGET_TCOFLUSH	1
190
#define	TARGET_TCIOFLUSH	2
191

  
192
/* tcsetattr uses these */
193
#define	TARGET_TCSANOW		0
194
#define	TARGET_TCSADRAIN	1
195
#define	TARGET_TCSAFLUSH	2
196

  
197
/*
198
 *  include/asm-s390/ioctls.h
199
 *
200
 *  S390 version
201
 *
202
 *  Derived from "include/asm-i386/ioctls.h"
203
 */
204

  
205
/* 0x54 is just a magic number to make these relatively unique ('T') */
206

  
207
#define TARGET_TCGETS		0x5401
208
#define TARGET_TCSETS		0x5402
209
#define TARGET_TCSETSW		0x5403
210
#define TARGET_TCSETSF		0x5404
211
#define TARGET_TCGETA		0x5405
212
#define TARGET_TCSETA		0x5406
213
#define TARGET_TCSETAW		0x5407
214
#define TARGET_TCSETAF		0x5408
215
#define TARGET_TCSBRK		0x5409
216
#define TARGET_TCXONC		0x540A
217
#define TARGET_TCFLSH		0x540B
218
#define TARGET_TIOCEXCL	0x540C
219
#define TARGET_TIOCNXCL	0x540D
220
#define TARGET_TIOCSCTTY	0x540E
221
#define TARGET_TIOCGPGRP	0x540F
222
#define TARGET_TIOCSPGRP	0x5410
223
#define TARGET_TIOCOUTQ	0x5411
224
#define TARGET_TIOCSTI		0x5412
225
#define TARGET_TIOCGWINSZ	0x5413
226
#define TARGET_TIOCSWINSZ	0x5414
227
#define TARGET_TIOCMGET	0x5415
228
#define TARGET_TIOCMBIS	0x5416
229
#define TARGET_TIOCMBIC	0x5417
230
#define TARGET_TIOCMSET	0x5418
231
#define TARGET_TIOCGSOFTCAR	0x5419
232
#define TARGET_TIOCSSOFTCAR	0x541A
233
#define TARGET_FIONREAD	0x541B
234
#define TARGET_TIOCINQ		FIONREAD
235
#define TARGET_TIOCLINUX	0x541C
236
#define TARGET_TIOCCONS	0x541D
237
#define TARGET_TIOCGSERIAL	0x541E
238
#define TARGET_TIOCSSERIAL	0x541F
239
#define TARGET_TIOCPKT		0x5420
240
#define TARGET_FIONBIO		0x5421
241
#define TARGET_TIOCNOTTY	0x5422
242
#define TARGET_TIOCSETD	0x5423
243
#define TARGET_TIOCGETD	0x5424
244
#define TARGET_TCSBRKP		0x5425	/* Needed for POSIX tcsendbreak() */
245
#define TARGET_TIOCSBRK	0x5427  /* BSD compatibility */
246
#define TARGET_TIOCCBRK	0x5428  /* BSD compatibility */
247
#define TARGET_TIOCGSID	0x5429  /* Return the session ID of FD */
248
#define TARGET_TCGETS2		_IOR('T',0x2A, struct termios2)
249
#define TARGET_TCSETS2		_IOW('T',0x2B, struct termios2)
250
#define TARGET_TCSETSW2	_IOW('T',0x2C, struct termios2)
251
#define TARGET_TCSETSF2	_IOW('T',0x2D, struct termios2)
252
#define TARGET_TIOCGPTN	_IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */
253
#define TARGET_TIOCSPTLCK	_IOW('T',0x31, int)  /* Lock/unlock Pty */
254
#define TARGET_TIOCGDEV	_IOR('T',0x32, unsigned int) /* Get real dev no below /dev/console */
255

  
256
#define TARGET_FIONCLEX	0x5450  /* these numbers need to be adjusted. */
257
#define TARGET_FIOCLEX		0x5451
258
#define TARGET_FIOASYNC	0x5452
259
#define TARGET_TIOCSERCONFIG	0x5453
260
#define TARGET_TIOCSERGWILD	0x5454
261
#define TARGET_TIOCSERSWILD	0x5455
262
#define TARGET_TIOCGLCKTRMIOS	0x5456
263
#define TARGET_TIOCSLCKTRMIOS	0x5457
264
#define TARGET_TIOCSERGSTRUCT	0x5458 /* For debugging only */
265
#define TARGET_TIOCSERGETLSR   0x5459 /* Get line status register */
266
#define TARGET_TIOCSERGETMULTI 0x545A /* Get multiport config  */
267
#define TARGET_TIOCSERSETMULTI 0x545B /* Set multiport config */
268

  
269
#define TARGET_TIOCMIWAIT	0x545C	/* wait for a change on serial input line(s) */
270
#define TARGET_TIOCGICOUNT	0x545D	/* read serial port inline interrupt counts */
271
#define TARGET_FIOQSIZE	0x545E
272

  
273
/* Used for packet mode */
274
#define TARGET_TIOCPKT_DATA		 0
275
#define TARGET_TIOCPKT_FLUSHREAD	 1
276
#define TARGET_TIOCPKT_FLUSHWRITE	 2
277
#define TARGET_TIOCPKT_STOP		 4
278
#define TARGET_TIOCPKT_START		 8
279
#define TARGET_TIOCPKT_NOSTOP		16
280
#define TARGET_TIOCPKT_DOSTOP		32
281

  
282
#define TARGET_TIOCSER_TEMT    0x01	/* Transmitter physically empty */
283

  
b/linux-user/signal.c
3614 3614
    return -TARGET_ENOSYS;
3615 3615
}
3616 3616

  
3617
#elif defined(TARGET_S390X)
3618

  
3619
#define __NUM_GPRS 16
3620
#define __NUM_FPRS 16
3621
#define __NUM_ACRS 16
3622

  
3623
#define S390_SYSCALL_SIZE   2
3624
#define __SIGNAL_FRAMESIZE      160 /* FIXME: 31-bit mode -> 96 */
3625

  
3626
#define _SIGCONTEXT_NSIG        64
3627
#define _SIGCONTEXT_NSIG_BPW    64 /* FIXME: 31-bit mode -> 32 */
3628
#define _SIGCONTEXT_NSIG_WORDS  (_SIGCONTEXT_NSIG / _SIGCONTEXT_NSIG_BPW)
3629
#define _SIGMASK_COPY_SIZE    (sizeof(unsigned long)*_SIGCONTEXT_NSIG_WORDS)
3630
#define PSW_ADDR_AMODE            0x0000000000000000UL /* 0x80000000UL for 31-bit */
3631
#define S390_SYSCALL_OPCODE ((uint16_t)0x0a00)
3632

  
3633
typedef struct {
3634
    target_psw_t psw;
3635
    target_ulong gprs[__NUM_GPRS];
3636
    unsigned int acrs[__NUM_ACRS];
3637
} target_s390_regs_common;
3638

  
3639
typedef struct {
3640
    unsigned int fpc;
3641
    double   fprs[__NUM_FPRS];
3642
} target_s390_fp_regs;
3643

  
3644
typedef struct {
3645
    target_s390_regs_common regs;
3646
    target_s390_fp_regs     fpregs;
3647
} target_sigregs;
3648

  
3649
struct target_sigcontext {
3650
    target_ulong   oldmask[_SIGCONTEXT_NSIG_WORDS];
3651
    target_sigregs *sregs;
3652
};
3653

  
3654
typedef struct {
3655
    uint8_t callee_used_stack[__SIGNAL_FRAMESIZE];
3656
    struct target_sigcontext sc;
3657
    target_sigregs sregs;
3658
    int signo;
3659
    uint8_t retcode[S390_SYSCALL_SIZE];
3660
} sigframe;
3661

  
3662
struct target_ucontext {
3663
    target_ulong uc_flags;
3664
    struct target_ucontext *uc_link;
3665
    target_stack_t uc_stack;
3666
    target_sigregs uc_mcontext;
3667
    target_sigset_t uc_sigmask;   /* mask last for extensibility */
3668
};
3669

  
3670
typedef struct {
3671
    uint8_t callee_used_stack[__SIGNAL_FRAMESIZE];
3672
    uint8_t retcode[S390_SYSCALL_SIZE];
3673
    struct target_siginfo info;
3674
    struct target_ucontext uc;
3675
} rt_sigframe;
3676

  
3677
static inline abi_ulong
3678
get_sigframe(struct target_sigaction *ka, CPUState *env, size_t frame_size)
3679
{
3680
    abi_ulong sp;
3681

  
3682
    /* Default to using normal stack */
3683
    sp = env->regs[15];
3684

  
3685
    /* This is the X/Open sanctioned signal stack switching.  */
3686
    if (ka->sa_flags & TARGET_SA_ONSTACK) {
3687
        if (!sas_ss_flags(sp)) {
3688
            sp = target_sigaltstack_used.ss_sp +
3689
                 target_sigaltstack_used.ss_size;
3690
        }
3691
    }
3692

  
3693
    /* This is the legacy signal stack switching. */
3694
    else if (/* FIXME !user_mode(regs) */ 0 &&
3695
             !(ka->sa_flags & TARGET_SA_RESTORER) &&
3696
             ka->sa_restorer) {
3697
        sp = (abi_ulong) ka->sa_restorer;
3698
    }
3699

  
3700
    return (sp - frame_size) & -8ul;
3701
}
3702

  
3703
static void save_sigregs(CPUState *env, target_sigregs *sregs)
3704
{
3705
    int i;
3706
    //save_access_regs(current->thread.acrs); FIXME
3707

  
3708
    /* Copy a 'clean' PSW mask to the user to avoid leaking
3709
       information about whether PER is currently on.  */
3710
    __put_user(env->psw.mask, &sregs->regs.psw.mask);
3711
    __put_user(env->psw.addr, &sregs->regs.psw.addr);
3712
    for (i = 0; i < 16; i++) {
3713
        __put_user(env->regs[i], &sregs->regs.gprs[i]);
3714
    }
3715
    for (i = 0; i < 16; i++) {
3716
        __put_user(env->aregs[i], &sregs->regs.acrs[i]);
3717
    }
3718
    /*
3719
     * We have to store the fp registers to current->thread.fp_regs
3720
     * to merge them with the emulated registers.
3721
     */
3722
    //save_fp_regs(&current->thread.fp_regs); FIXME
3723
    for (i = 0; i < 16; i++) {
3724
        __put_user(env->fregs[i].ll, &sregs->fpregs.fprs[i]);
3725
    }
3726
}
3727

  
3728
static void setup_frame(int sig, struct target_sigaction *ka,
3729
			target_sigset_t *set, CPUState *env)
3730
{
3731
    sigframe *frame;
3732
    abi_ulong frame_addr;
3733

  
3734
    frame_addr = get_sigframe(ka, env, sizeof(*frame));
3735
    qemu_log("%s: frame_addr 0x%llx\n", __FUNCTION__,
3736
             (unsigned long long)frame_addr);
3737
    if (!lock_user_struct(VERIFY_WRITE, frame, frame_addr, 0)) {
3738
            goto give_sigsegv;
3739
    }
3740

  
3741
    qemu_log("%s: 1\n", __FUNCTION__);
3742
    if (__put_user(set->sig[0], &frame->sc.oldmask[0])) {
3743
              goto give_sigsegv;
3744
    }
3745

  
3746
    save_sigregs(env, &frame->sregs);
3747

  
3748
    __put_user((abi_ulong)(unsigned long)&frame->sregs,
3749
               (abi_ulong *)&frame->sc.sregs);
3750

  
3751
    /* Set up to return from userspace.  If provided, use a stub
3752
       already in userspace.  */
3753
    if (ka->sa_flags & TARGET_SA_RESTORER) {
3754
            env->regs[14] = (unsigned long)
3755
                    ka->sa_restorer | PSW_ADDR_AMODE;
3756
    } else {
3757
            env->regs[14] = (unsigned long)
3758
                    frame->retcode | PSW_ADDR_AMODE;
3759
            if (__put_user(S390_SYSCALL_OPCODE | TARGET_NR_sigreturn,
3760
                           (uint16_t *)(frame->retcode)))
3761
                    goto give_sigsegv;
3762
    }
3763

  
3764
    /* Set up backchain. */
3765
    if (__put_user(env->regs[15], (abi_ulong *) frame)) {
3766
            goto give_sigsegv;
3767
    }
3768

  
3769
    /* Set up registers for signal handler */
3770
    env->regs[15] = (target_ulong)(unsigned long) frame;
3771
    env->psw.addr = (target_ulong) ka->_sa_handler | PSW_ADDR_AMODE;
3772

  
3773
    env->regs[2] = sig; //map_signal(sig);
3774
    env->regs[3] = (target_ulong)(unsigned long) &frame->sc;
3775

  
3776
    /* We forgot to include these in the sigcontext.
3777
       To avoid breaking binary compatibility, they are passed as args. */
3778
    env->regs[4] = 0; // FIXME: no clue... current->thread.trap_no;
3779
    env->regs[5] = 0; // FIXME: no clue... current->thread.prot_addr;
3780

  
3781
    /* Place signal number on stack to allow backtrace from handler.  */
3782
    if (__put_user(env->regs[2], (int *) &frame->signo)) {
3783
            goto give_sigsegv;
3784
    }
3785
    unlock_user_struct(frame, frame_addr, 1);
3786
    return;
3787

  
3788
give_sigsegv:
3789
    qemu_log("%s: give_sigsegv\n", __FUNCTION__);
3790
    unlock_user_struct(frame, frame_addr, 1);
3791
    force_sig(TARGET_SIGSEGV);
3792
}
3793

  
3794
static void setup_rt_frame(int sig, struct target_sigaction *ka,
3795
                           target_siginfo_t *info,
3796
                           target_sigset_t *set, CPUState *env)
3797
{
3798
    int i;
3799
    rt_sigframe *frame;
3800
    abi_ulong frame_addr;
3801

  
3802
    frame_addr = get_sigframe(ka, env, sizeof *frame);
3803
    qemu_log("%s: frame_addr 0x%llx\n", __FUNCTION__,
3804
             (unsigned long long)frame_addr);
3805
    if (!lock_user_struct(VERIFY_WRITE, frame, frame_addr, 0)) {
3806
        goto give_sigsegv;
3807
    }
3808

  
3809
    qemu_log("%s: 1\n", __FUNCTION__);
3810
    if (copy_siginfo_to_user(&frame->info, info)) {
3811
        goto give_sigsegv;
3812
    }
3813

  
3814
    /* Create the ucontext.  */
3815
    __put_user(0, &frame->uc.uc_flags);
3816
    __put_user((abi_ulong)0, (abi_ulong *)&frame->uc.uc_link);
3817
    __put_user(target_sigaltstack_used.ss_sp, &frame->uc.uc_stack.ss_sp);
3818
    __put_user(sas_ss_flags(get_sp_from_cpustate(env)),
3819
                      &frame->uc.uc_stack.ss_flags);
3820
    __put_user(target_sigaltstack_used.ss_size, &frame->uc.uc_stack.ss_size);
3821
    save_sigregs(env, &frame->uc.uc_mcontext);
3822
    for (i = 0; i < TARGET_NSIG_WORDS; i++) {
3823
        __put_user((abi_ulong)set->sig[i],
3824
        (abi_ulong *)&frame->uc.uc_sigmask.sig[i]);
3825
    }
3826

  
3827
    /* Set up to return from userspace.  If provided, use a stub
3828
       already in userspace.  */
3829
    if (ka->sa_flags & TARGET_SA_RESTORER) {
3830
        env->regs[14] = (unsigned long) ka->sa_restorer | PSW_ADDR_AMODE;
3831
    } else {
3832
        env->regs[14] = (unsigned long) frame->retcode | PSW_ADDR_AMODE;
3833
        if (__put_user(S390_SYSCALL_OPCODE | TARGET_NR_rt_sigreturn,
3834
                       (uint16_t *)(frame->retcode))) {
3835
            goto give_sigsegv;
3836
        }
3837
    }
3838

  
3839
    /* Set up backchain. */
3840
    if (__put_user(env->regs[15], (abi_ulong *) frame)) {
3841
        goto give_sigsegv;
3842
    }
3843

  
3844
    /* Set up registers for signal handler */
3845
    env->regs[15] = (target_ulong)(unsigned long) frame;
3846
    env->psw.addr = (target_ulong) ka->_sa_handler | PSW_ADDR_AMODE;
3847

  
3848
    env->regs[2] = sig; //map_signal(sig);
3849
    env->regs[3] = (target_ulong)(unsigned long) &frame->info;
3850
    env->regs[4] = (target_ulong)(unsigned long) &frame->uc;
3851
    return;
3852

  
3853
give_sigsegv:
3854
    qemu_log("%s: give_sigsegv\n", __FUNCTION__);
3855
    unlock_user_struct(frame, frame_addr, 1);
3856
    force_sig(TARGET_SIGSEGV);
3857
}
3858

  
3859
static int
3860
restore_sigregs(CPUState *env, target_sigregs *sc)
3861
{
3862
    int err = 0;
3863
    int i;
3864

  
3865
    for (i = 0; i < 16; i++) {
3866
        err |= __get_user(env->regs[i], &sc->regs.gprs[i]);
3867
    }
3868

  
3869
    err |= __get_user(env->psw.mask, &sc->regs.psw.mask);
3870
    qemu_log("%s: sc->regs.psw.addr 0x%llx env->psw.addr 0x%llx\n",
3871
             __FUNCTION__, (unsigned long long)sc->regs.psw.addr,
3872
             (unsigned long long)env->psw.addr);
3873
    err |= __get_user(env->psw.addr, &sc->regs.psw.addr);
3874
    /* FIXME: 31-bit -> | PSW_ADDR_AMODE */
3875

  
3876
    for (i = 0; i < 16; i++) {
3877
        err |= __get_user(env->aregs[i], &sc->regs.acrs[i]);
3878
    }
3879
    for (i = 0; i < 16; i++) {
3880
        err |= __get_user(env->fregs[i].ll, &sc->fpregs.fprs[i]);
3881
    }
3882

  
3883
    return err;
3884
}
3885

  
3886
long do_sigreturn(CPUState *env)
3887
{
3888
    sigframe *frame;
3889
    abi_ulong frame_addr = env->regs[15];
3890
    qemu_log("%s: frame_addr 0x%llx\n", __FUNCTION__,
3891
             (unsigned long long)frame_addr);
3892
    target_sigset_t target_set;
3893
    sigset_t set;
3894

  
3895
    if (!lock_user_struct(VERIFY_READ, frame, frame_addr, 1)) {
3896
        goto badframe;
3897
    }
3898
    if (__get_user(target_set.sig[0], &frame->sc.oldmask[0])) {
3899
        goto badframe;
3900
    }
3901

  
3902
    target_to_host_sigset_internal(&set, &target_set);
3903
    sigprocmask(SIG_SETMASK, &set, NULL); /* ~_BLOCKABLE? */
3904

  
3905
    if (restore_sigregs(env, &frame->sregs)) {
3906
        goto badframe;
3907
    }
3908

  
3909
    unlock_user_struct(frame, frame_addr, 0);
3910
    return env->regs[2];
3911

  
3912
badframe:
3913
    unlock_user_struct(frame, frame_addr, 0);
3914
    force_sig(TARGET_SIGSEGV);
3915
    return 0;
3916
}
3917

  
3918
long do_rt_sigreturn(CPUState *env)
3919
{
3920
    rt_sigframe *frame;
3921
    abi_ulong frame_addr = env->regs[15];
3922
    qemu_log("%s: frame_addr 0x%llx\n", __FUNCTION__,
3923
             (unsigned long long)frame_addr);
3924
    sigset_t set;
3925

  
3926
    if (!lock_user_struct(VERIFY_READ, frame, frame_addr, 1)) {
3927
        goto badframe;
3928
    }
3929
    target_to_host_sigset(&set, &frame->uc.uc_sigmask);
3930

  
3931
    sigprocmask(SIG_SETMASK, &set, NULL); /* ~_BLOCKABLE? */
3932

  
3933
    if (restore_sigregs(env, &frame->uc.uc_mcontext)) {
3934
        goto badframe;
3935
    }
3936

  
3937
    if (do_sigaltstack(frame_addr + offsetof(rt_sigframe, uc.uc_stack), 0,
3938
                       get_sp_from_cpustate(env)) == -EFAULT) {
3939
        goto badframe;
3940
    }
3941
    unlock_user_struct(frame, frame_addr, 0);
3942
    return env->regs[2];
3943

  
3944
badframe:
3945
    unlock_user_struct(frame, frame_addr, 0);
3946
    force_sig(TARGET_SIGSEGV);
3947
    return 0;
3948
}
3949

  
3617 3950
#elif defined(TARGET_PPC) && !defined(TARGET_PPC64)
3618 3951

  
3619 3952
/* FIXME: Many of the structures are defined for both PPC and PPC64, but
b/linux-user/syscall.c
5548 5548
            ret = get_errno(settimeofday(&tv, NULL));
5549 5549
        }
5550 5550
        break;
5551
#ifdef TARGET_NR_select
5551
#if defined(TARGET_NR_select) && !defined(TARGET_S390X) && !defined(TARGET_S390)
5552 5552
    case TARGET_NR_select:
5553 5553
        {
5554 5554
            struct target_sel_arg_struct *sel;
......
5659 5659
#endif
5660 5660
#ifdef TARGET_NR_mmap
5661 5661
    case TARGET_NR_mmap:
5662
#if (defined(TARGET_I386) && defined(TARGET_ABI32)) || defined(TARGET_ARM) || defined(TARGET_M68K) || defined(TARGET_CRIS) || defined(TARGET_MICROBLAZE)
5662
#if (defined(TARGET_I386) && defined(TARGET_ABI32)) || defined(TARGET_ARM) || \
5663
    defined(TARGET_M68K) || defined(TARGET_CRIS) || defined(TARGET_MICROBLAZE) \
5664
    || defined(TARGET_S390X)
5663 5665
        {
5664 5666
            abi_ulong *v;
5665 5667
            abi_ulong v1, v2, v3, v4, v5, v6;
......
6155 6157
        ret = get_errno(do_fork(cpu_env, arg1, arg2, arg3, arg5, arg4));
6156 6158
#elif defined(TARGET_CRIS)
6157 6159
        ret = get_errno(do_fork(cpu_env, arg2, arg1, arg3, arg4, arg5));
6160
#elif defined(TARGET_S390X)
6161
        ret = get_errno(do_fork(cpu_env, arg2, arg1, arg3, arg5, arg4));
6158 6162
#else
6159 6163
        ret = get_errno(do_fork(cpu_env, arg1, arg2, arg3, arg4, arg5));
6160 6164
#endif
......
6363 6367
        }
6364 6368
        break;
6365 6369
#endif /* TARGET_NR_getdents64 */
6366
#ifdef TARGET_NR__newselect
6370
#if defined(TARGET_NR__newselect) || defined(TARGET_S390X)
6371
#ifdef TARGET_S390X
6372
    case TARGET_NR_select:
6373
#else
6367 6374
    case TARGET_NR__newselect:
6375
#endif
6368 6376
        ret = do_select(arg1, arg2, arg3, arg4, arg5);
6369 6377
        break;
6370 6378
#endif
......
6681 6689
    case TARGET_NR_sigaltstack:
6682 6690
#if defined(TARGET_I386) || defined(TARGET_ARM) || defined(TARGET_MIPS) || \
6683 6691
    defined(TARGET_SPARC) || defined(TARGET_PPC) || defined(TARGET_ALPHA) || \
6684
    defined(TARGET_M68K)
6692
    defined(TARGET_M68K) || defined(TARGET_S390X)
6685 6693
        ret = do_sigaltstack(arg1, arg2, get_sp_from_cpustate((CPUState *)cpu_env));
6686 6694
        break;
6687 6695
#else
b/linux-user/syscall_defs.h
58 58
#endif
59 59

  
60 60
#if defined(TARGET_I386) || defined(TARGET_ARM) || defined(TARGET_SH4) \
61
    || defined(TARGET_M68K) || defined(TARGET_CRIS) || defined(TARGET_UNICORE32)
61
    || defined(TARGET_M68K) || defined(TARGET_CRIS) || defined(TARGET_UNICORE32) \
62
    || defined(TARGET_S390X)
62 63

  
63 64
#define TARGET_IOC_SIZEBITS	14
64 65
#define TARGET_IOC_DIRBITS	2
......
321 322
#if defined(TARGET_I386) || defined(TARGET_ARM) || defined(TARGET_SPARC) \
322 323
    || defined(TARGET_PPC) || defined(TARGET_MIPS) || defined(TARGET_SH4) \
323 324
    || defined(TARGET_M68K) || defined(TARGET_ALPHA) || defined(TARGET_CRIS) \
324
    || defined(TARGET_MICROBLAZE) || defined(TARGET_UNICORE32)
325
    || defined(TARGET_MICROBLAZE) || defined(TARGET_UNICORE32) \
326
    || defined(TARGET_S390X)
325 327

  
326 328
#if defined(TARGET_SPARC)
327 329
#define TARGET_SA_NOCLDSTOP    8u
......
1688 1690

  
1689 1691
  	abi_long	__unused[3];
1690 1692
};
1693
#elif defined(TARGET_S390X)
1694
struct target_stat {
1695
    abi_ulong  st_dev;
1696
    abi_ulong  st_ino;
1697
    abi_ulong  st_nlink;
1698
    unsigned int   st_mode;
1699
    unsigned int   st_uid;
1700
    unsigned int   st_gid;
1701
    unsigned int   __pad1;
1702
    abi_ulong  st_rdev;
1703
    abi_ulong  st_size;
1704
    abi_ulong  target_st_atime;
1705
    abi_ulong  target_st_atime_nsec;
1706
    abi_ulong  target_st_mtime;
1707
    abi_ulong  target_st_mtime_nsec;
1708
    abi_ulong  target_st_ctime;
1709
    abi_ulong  target_st_ctime_nsec;
1710
    abi_ulong  st_blksize;
1711
    abi_long       st_blocks;
1712
    abi_ulong  __unused[3];
1713
};
1691 1714
#else
1692 1715
#error unsupported CPU
1693 1716
#endif
......
1774 1797
	abi_long f_frsize;
1775 1798
	abi_long f_spare[5];
1776 1799
};
1800
#elif defined(TARGET_S390X)
1801
struct target_statfs {
1802
    int32_t  f_type;
1803
    int32_t  f_bsize;
1804
    abi_long f_blocks;
1805
    abi_long f_bfree;
1806
    abi_long f_bavail;
1807
    abi_long f_files;
1808
    abi_long f_ffree;
1809
    kernel_fsid_t f_fsid;
1810
    int32_t  f_namelen;
1811
    int32_t  f_frsize;
1812
    int32_t  f_spare[5];
1813
};
1814

  
1815
struct target_statfs64 {
1816
    int32_t  f_type;
1817
    int32_t  f_bsize;
1818
    abi_long f_blocks;
1819
    abi_long f_bfree;
1820
    abi_long f_bavail;
1821
    abi_long f_files;
1822
    abi_long f_ffree;
1823
    kernel_fsid_t f_fsid;
1824
    int32_t  f_namelen;
1825
    int32_t  f_frsize;
1826
    int32_t  f_spare[5];
1827
};
1777 1828
#else
1778 1829
struct target_statfs {
1779 1830
	uint32_t f_type;
b/scripts/qemu-binfmt-conf.sh
1 1
#!/bin/sh
2
# enable automatic i386/ARM/M68K/MIPS/SPARC/PPC program execution by the kernel
2
# enable automatic i386/ARM/M68K/MIPS/SPARC/PPC/s390 program execution by the kernel
3 3

  
4 4
# load the binfmt_misc module
5 5
if [ ! -d /proc/sys/fs/binfmt_misc ]; then
......
63 63
if [ $cpu != "sh" ] ; then
64 64
    echo    ':sh4:M::\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x2a\x00:\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/local/bin/qemu-sh4:' > /proc/sys/fs/binfmt_misc/register
65 65
    echo    ':sh4eb:M::\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x2a:\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff:/usr/local/bin/qemu-sh4eb:' > /proc/sys/fs/binfmt_misc/register
66
if [ $cpu != "s390x" ] ; then
67
    echo   ':s390x:M::\x7fELF\x02\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x16:\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff:/usr/local/bin/qemu-s390x:' > /proc/sys/fs/binfmt_misc/register
66 68
fi

Also available in: Unified diff