~ubuntu-branches/ubuntu/trusty/qemu/trusty

« back to all changes in this revision

Viewing changes to linux-user/main.c

  • Committer: Package Import Robot
  • Author(s): Serge Hallyn
  • Date: 2013-10-22 22:47:07 UTC
  • mfrom: (1.8.3) (10.1.42 sid)
  • Revision ID: package-import@ubuntu.com-20131022224707-1lya34fw3k3f24tv
Tags: 1.6.0+dfsg-2ubuntu1
* Merge 1.6.0~rc0+dfsg-2exp from debian experimental.  Remaining changes:
  - debian/control
    * update maintainer
    * remove libiscsi, usb-redir, vde, vnc-jpeg, and libssh2-1-dev
      from build-deps
    * enable rbd
    * add qemu-system and qemu-common B/R to qemu-keymaps
    * add D:udev, R:qemu, R:qemu-common and B:qemu-common to
      qemu-system-common
    * qemu-system-arm, qemu-system-ppc, qemu-system-sparc:
      - add qemu-kvm to Provides
      - add qemu-common, qemu-kvm, kvm to B/R
      - remove openbios-sparc from qemu-system-sparc D
      - drop openbios-ppc and openhackware Depends to Suggests (for now)
    * qemu-system-x86:
      - add qemu-common to Breaks/Replaces.
      - add cpu-checker to Recommends.
    * qemu-user: add B/R:qemu-kvm
    * qemu-kvm:
      - add armhf armel powerpc sparc to Architecture
      - C/R/P: qemu-kvm-spice
    * add qemu-common package
    * drop qemu-slof which is not packaged in ubuntu
  - add qemu-system-common.links for tap ifup/down scripts and OVMF link.
  - qemu-system-x86.links:
    * remove pxe rom links which are in kvm-ipxe
    * add symlink for kvm.1 manpage
  - debian/rules
    * add kvm-spice symlink to qemu-kvm
    * call dh_installmodules for qemu-system-x86
    * update dh_installinit to install upstart script
    * run dh_installman (Closes: #709241) (cherrypicked from 1.5.0+dfsg-2)
  - Add qemu-utils.links for kvm-* symlinks.
  - Add qemu-system-x86.qemu-kvm.upstart and .default
  - Add qemu-system-x86.modprobe to set nesting=1
  - Add qemu-system-common.preinst to add kvm group
  - qemu-system-common.postinst: remove bad group acl if there, then have
    udev relabel /dev/kvm.
  - New linaro patches from qemu-linaro rebasing branch
  - Dropped patches:
    * xen-simplify-xen_enabled.patch
    * sparc-linux-user-fix-missing-symbols-in-.rel-.rela.plt-sections.patch
    * main_loop-do-not-set-nonblocking-if-xen_enabled.patch
    * xen_machine_pv-do-not-create-a-dummy-CPU-in-machine-.patch
    * virtio-rng-fix-crash
  - Kept patches:
    * expose_vms_qemu64cpu.patch - updated
    * linaro arm patches from qemu-linaro rebasing branch
  - New patches:
    * fix-pci-add: change CONFIG variable in ifdef to make sure that
      pci_add is defined.
* Add linaro patches
* Add experimental mach-virt patches for arm virtualization.
* qemu-system-common.install: add debian/tmp/usr/lib to install the
  qemu-bridge-helper

Show diffs side-by-side

added added

removed removed

Lines of Context:
92
92
}
93
93
#endif
94
94
 
95
 
#if defined(CONFIG_USE_NPTL)
96
95
/***********************************************************/
97
96
/* Helper routines for implementing atomic operations.  */
98
97
 
120
119
    if (child) {
121
120
        /* Child processes created by fork() only have a single thread.
122
121
           Discard information about the parent threads.  */
123
 
        first_cpu = thread_env;
124
 
        thread_env->next_cpu = NULL;
 
122
        first_cpu = thread_cpu;
 
123
        first_cpu->next_cpu = NULL;
125
124
        pending_cpus = 0;
126
125
        pthread_mutex_init(&exclusive_lock, NULL);
127
126
        pthread_mutex_init(&cpu_list_mutex, NULL);
128
127
        pthread_cond_init(&exclusive_cond, NULL);
129
128
        pthread_cond_init(&exclusive_resume, NULL);
130
129
        pthread_mutex_init(&tcg_ctx.tb_ctx.tb_lock, NULL);
131
 
        gdbserver_fork(thread_env);
 
130
        gdbserver_fork((CPUArchState *)thread_cpu->env_ptr);
132
131
    } else {
133
132
        pthread_mutex_unlock(&exclusive_lock);
134
133
        pthread_mutex_unlock(&tcg_ctx.tb_ctx.tb_lock);
148
147
   Must only be called from outside cpu_arm_exec.   */
149
148
static inline void start_exclusive(void)
150
149
{
151
 
    CPUArchState *other;
152
150
    CPUState *other_cpu;
153
151
 
154
152
    pthread_mutex_lock(&exclusive_lock);
156
154
 
157
155
    pending_cpus = 1;
158
156
    /* Make all other cpus stop executing.  */
159
 
    for (other = first_cpu; other; other = other->next_cpu) {
160
 
        other_cpu = ENV_GET_CPU(other);
 
157
    for (other_cpu = first_cpu; other_cpu; other_cpu = other_cpu->next_cpu) {
161
158
        if (other_cpu->running) {
162
159
            pending_cpus++;
163
 
            cpu_exit(other);
 
160
            cpu_exit(other_cpu);
164
161
        }
165
162
    }
166
163
    if (pending_cpus > 1) {
209
206
{
210
207
    pthread_mutex_unlock(&cpu_list_mutex);
211
208
}
212
 
#else /* if !CONFIG_USE_NPTL */
213
 
/* These are no-ops because we are not threadsafe.  */
214
 
static inline void cpu_exec_start(CPUState *cpu)
215
 
{
216
 
}
217
 
 
218
 
static inline void cpu_exec_end(CPUState *cpu)
219
 
{
220
 
}
221
 
 
222
 
static inline void start_exclusive(void)
223
 
{
224
 
}
225
 
 
226
 
static inline void end_exclusive(void)
227
 
{
228
 
}
229
 
 
230
 
void fork_start(void)
231
 
{
232
 
}
233
 
 
234
 
void fork_end(int child)
235
 
{
236
 
    if (child) {
237
 
        gdbserver_fork(thread_env);
238
 
    }
239
 
}
240
 
 
241
 
void cpu_list_lock(void)
242
 
{
243
 
}
244
 
 
245
 
void cpu_list_unlock(void)
246
 
{
247
 
}
248
 
#endif
249
209
 
250
210
 
251
211
#ifdef TARGET_I386
314
274
 
315
275
void cpu_loop(CPUX86State *env)
316
276
{
 
277
    CPUState *cs = CPU(x86_env_get_cpu(env));
317
278
    int trapnr;
318
279
    abi_ulong pc;
319
280
    target_siginfo_t info;
445
406
            {
446
407
                int sig;
447
408
 
448
 
                sig = gdb_handlesig (env, TARGET_SIGTRAP);
 
409
                sig = gdb_handlesig(cs, TARGET_SIGTRAP);
449
410
                if (sig)
450
411
                  {
451
412
                    info.si_signo = sig;
877
838
            {
878
839
                int sig;
879
840
 
880
 
                sig = gdb_handlesig (env, TARGET_SIGTRAP);
 
841
                sig = gdb_handlesig(cs, TARGET_SIGTRAP);
881
842
                if (sig)
882
843
                  {
883
844
                    info.si_signo = sig;
901
862
        error:
902
863
            fprintf(stderr, "qemu: unhandled CPU exception 0x%x - aborting\n",
903
864
                    trapnr);
904
 
            cpu_dump_state(env, stderr, fprintf, 0);
 
865
            cpu_dump_state(cs, stderr, fprintf, 0);
905
866
            abort();
906
867
        }
907
868
        process_pending_signals(env);
968
929
            {
969
930
                int sig;
970
931
 
971
 
                sig = gdb_handlesig(env, TARGET_SIGTRAP);
 
932
                sig = gdb_handlesig(cs, TARGET_SIGTRAP);
972
933
                if (sig) {
973
934
                    info.si_signo = sig;
974
935
                    info.si_errno = 0;
985
946
 
986
947
error:
987
948
    fprintf(stderr, "qemu: unhandled CPU exception 0x%x - aborting\n", trapnr);
988
 
    cpu_dump_state(env, stderr, fprintf, 0);
 
949
    cpu_dump_state(cs, stderr, fprintf, 0);
989
950
    abort();
990
951
}
991
952
#endif
1115
1076
 
1116
1077
void cpu_loop (CPUSPARCState *env)
1117
1078
{
 
1079
    CPUState *cs = CPU(sparc_env_get_cpu(env));
1118
1080
    int trapnr;
1119
1081
    abi_long ret;
1120
1082
    target_siginfo_t info;
1234
1196
            {
1235
1197
                int sig;
1236
1198
 
1237
 
                sig = gdb_handlesig (env, TARGET_SIGTRAP);
 
1199
                sig = gdb_handlesig(cs, TARGET_SIGTRAP);
1238
1200
                if (sig)
1239
1201
                  {
1240
1202
                    info.si_signo = sig;
1246
1208
            break;
1247
1209
        default:
1248
1210
            printf ("Unhandled trap: 0x%x\n", trapnr);
1249
 
            cpu_dump_state(env, stderr, fprintf, 0);
 
1211
            cpu_dump_state(cs, stderr, fprintf, 0);
1250
1212
            exit (1);
1251
1213
        }
1252
1214
        process_pending_signals (env);
1303
1265
 
1304
1266
#define EXCP_DUMP(env, fmt, ...)                                        \
1305
1267
do {                                                                    \
 
1268
    CPUState *cs = ENV_GET_CPU(env);                                    \
1306
1269
    fprintf(stderr, fmt , ## __VA_ARGS__);                              \
1307
 
    cpu_dump_state(env, stderr, fprintf, 0);                            \
 
1270
    cpu_dump_state(cs, stderr, fprintf, 0);                             \
1308
1271
    qemu_log(fmt, ## __VA_ARGS__);                                      \
1309
1272
    if (qemu_log_enabled()) {                                           \
1310
 
        log_cpu_state(env, 0);                                          \
 
1273
        log_cpu_state(cs, 0);                                           \
1311
1274
    }                                                                   \
1312
1275
} while (0)
1313
1276
 
1764
1727
            {
1765
1728
                int sig;
1766
1729
 
1767
 
                sig = gdb_handlesig(env, TARGET_SIGTRAP);
 
1730
                sig = gdb_handlesig(cs, TARGET_SIGTRAP);
1768
1731
                if (sig) {
1769
1732
                    info.si_signo = sig;
1770
1733
                    info.si_errno = 0;
1957
1920
        MIPS_SYS(sys_sched_get_priority_min, 1)
1958
1921
        MIPS_SYS(sys_sched_rr_get_interval, 2)  /* 4165 */
1959
1922
        MIPS_SYS(sys_nanosleep, 2)
1960
 
        MIPS_SYS(sys_mremap     , 4)
 
1923
        MIPS_SYS(sys_mremap     , 5)
1961
1924
        MIPS_SYS(sys_accept     , 3)
1962
1925
        MIPS_SYS(sys_bind       , 3)
1963
1926
        MIPS_SYS(sys_connect    , 3)    /* 4170 */
2028
1991
        MIPS_SYS(sys_fremovexattr, 2)   /* 4235 */
2029
1992
        MIPS_SYS(sys_tkill      , 2)
2030
1993
        MIPS_SYS(sys_sendfile64 , 5)
2031
 
        MIPS_SYS(sys_futex      , 2)
 
1994
        MIPS_SYS(sys_futex      , 6)
2032
1995
        MIPS_SYS(sys_sched_setaffinity, 3)
2033
1996
        MIPS_SYS(sys_sched_getaffinity, 3)      /* 4240 */
2034
1997
        MIPS_SYS(sys_io_setup   , 2)
2094
2057
        MIPS_SYS(sys_pselect6, 6)
2095
2058
        MIPS_SYS(sys_ppoll, 5)
2096
2059
        MIPS_SYS(sys_unshare, 1)
2097
 
        MIPS_SYS(sys_splice, 4)
 
2060
        MIPS_SYS(sys_splice, 6)
2098
2061
        MIPS_SYS(sys_sync_file_range, 7) /* 4305 */
2099
2062
        MIPS_SYS(sys_tee, 4)
2100
2063
        MIPS_SYS(sys_vmsplice, 4)
2315
2278
            {
2316
2279
                int sig;
2317
2280
 
2318
 
                sig = gdb_handlesig (env, TARGET_SIGTRAP);
 
2281
                sig = gdb_handlesig(cs, TARGET_SIGTRAP);
2319
2282
                if (sig)
2320
2283
                  {
2321
2284
                    info.si_signo = sig;
2348
2311
                abi_ulong trap_instr;
2349
2312
                unsigned int code;
2350
2313
 
2351
 
                ret = get_user_ual(trap_instr, env->active_tc.PC);
 
2314
                if (env->hflags & MIPS_HFLAG_M16) {
 
2315
                    if (env->insn_flags & ASE_MICROMIPS) {
 
2316
                        /* microMIPS mode */
 
2317
                        abi_ulong instr[2];
 
2318
 
 
2319
                        ret = get_user_u16(instr[0], env->active_tc.PC) ||
 
2320
                              get_user_u16(instr[1], env->active_tc.PC + 2);
 
2321
 
 
2322
                        trap_instr = (instr[0] << 16) | instr[1];
 
2323
                    } else {
 
2324
                        /* MIPS16e mode */
 
2325
                        ret = get_user_u16(trap_instr, env->active_tc.PC);
 
2326
                        if (ret != 0) {
 
2327
                            goto error;
 
2328
                        }
 
2329
                        code = (trap_instr >> 6) & 0x3f;
 
2330
                        if (do_break(env, &info, code) != 0) {
 
2331
                            goto error;
 
2332
                        }
 
2333
                        break;
 
2334
                    }
 
2335
                } else {
 
2336
                    ret = get_user_ual(trap_instr, env->active_tc.PC);
 
2337
                }
 
2338
 
2352
2339
                if (ret != 0) {
2353
2340
                    goto error;
2354
2341
                }
2372
2359
                abi_ulong trap_instr;
2373
2360
                unsigned int code = 0;
2374
2361
 
2375
 
                ret = get_user_ual(trap_instr, env->active_tc.PC);
 
2362
                if (env->hflags & MIPS_HFLAG_M16) {
 
2363
                    /* microMIPS mode */
 
2364
                    abi_ulong instr[2];
 
2365
 
 
2366
                    ret = get_user_u16(instr[0], env->active_tc.PC) ||
 
2367
                          get_user_u16(instr[1], env->active_tc.PC + 2);
 
2368
 
 
2369
                    trap_instr = (instr[0] << 16) | instr[1];
 
2370
                } else {
 
2371
                    ret = get_user_ual(trap_instr, env->active_tc.PC);
 
2372
                }
 
2373
 
2376
2374
                if (ret != 0) {
2377
2375
                    goto error;
2378
2376
                }
2379
2377
 
2380
2378
                /* The immediate versions don't provide a code.  */
2381
2379
                if (!(trap_instr & 0xFC000000)) {
2382
 
                    code = ((trap_instr >> 6) & ((1 << 10) - 1));
 
2380
                    if (env->hflags & MIPS_HFLAG_M16) {
 
2381
                        /* microMIPS mode */
 
2382
                        code = ((trap_instr >> 12) & ((1 << 4) - 1));
 
2383
                    } else {
 
2384
                        code = ((trap_instr >> 6) & ((1 << 10) - 1));
 
2385
                    }
2383
2386
                }
2384
2387
 
2385
2388
                if (do_break(env, &info, code) != 0) {
2391
2394
error:
2392
2395
            fprintf(stderr, "qemu: unhandled CPU exception 0x%x - aborting\n",
2393
2396
                    trapnr);
2394
 
            cpu_dump_state(env, stderr, fprintf, 0);
 
2397
            cpu_dump_state(cs, stderr, fprintf, 0);
2395
2398
            abort();
2396
2399
        }
2397
2400
        process_pending_signals(env);
2403
2406
 
2404
2407
void cpu_loop(CPUOpenRISCState *env)
2405
2408
{
 
2409
    CPUState *cs = CPU(openrisc_env_get_cpu(env));
2406
2410
    int trapnr, gdbsig;
2407
2411
 
2408
2412
    for (;;) {
2420
2424
            break;
2421
2425
        case EXCP_DPF:
2422
2426
        case EXCP_IPF:
2423
 
            cpu_dump_state(env, stderr, fprintf, 0);
 
2427
            cpu_dump_state(cs, stderr, fprintf, 0);
2424
2428
            gdbsig = TARGET_SIGSEGV;
2425
2429
            break;
2426
2430
        case EXCP_TICK:
2469
2473
        default:
2470
2474
            qemu_log("\nqemu: unhandled CPU exception %#x - aborting\n",
2471
2475
                     trapnr);
2472
 
            cpu_dump_state(env, stderr, fprintf, 0);
 
2476
            cpu_dump_state(cs, stderr, fprintf, 0);
2473
2477
            gdbsig = TARGET_SIGILL;
2474
2478
            break;
2475
2479
        }
2476
2480
        if (gdbsig) {
2477
 
            gdb_handlesig(env, gdbsig);
 
2481
            gdb_handlesig(cs, gdbsig);
2478
2482
            if (gdbsig != TARGET_SIGTRAP) {
2479
2483
                exit(1);
2480
2484
            }
2489
2493
#ifdef TARGET_SH4
2490
2494
void cpu_loop(CPUSH4State *env)
2491
2495
{
 
2496
    CPUState *cs = CPU(sh_env_get_cpu(env));
2492
2497
    int trapnr, ret;
2493
2498
    target_siginfo_t info;
2494
2499
 
2516
2521
            {
2517
2522
                int sig;
2518
2523
 
2519
 
                sig = gdb_handlesig (env, TARGET_SIGTRAP);
 
2524
                sig = gdb_handlesig(cs, TARGET_SIGTRAP);
2520
2525
                if (sig)
2521
2526
                  {
2522
2527
                    info.si_signo = sig;
2537
2542
 
2538
2543
        default:
2539
2544
            printf ("Unhandled trap: 0x%x\n", trapnr);
2540
 
            cpu_dump_state(env, stderr, fprintf, 0);
 
2545
            cpu_dump_state(cs, stderr, fprintf, 0);
2541
2546
            exit (1);
2542
2547
        }
2543
2548
        process_pending_signals (env);
2548
2553
#ifdef TARGET_CRIS
2549
2554
void cpu_loop(CPUCRISState *env)
2550
2555
{
 
2556
    CPUState *cs = CPU(cris_env_get_cpu(env));
2551
2557
    int trapnr, ret;
2552
2558
    target_siginfo_t info;
2553
2559
    
2583
2589
            {
2584
2590
                int sig;
2585
2591
 
2586
 
                sig = gdb_handlesig (env, TARGET_SIGTRAP);
 
2592
                sig = gdb_handlesig(cs, TARGET_SIGTRAP);
2587
2593
                if (sig)
2588
2594
                  {
2589
2595
                    info.si_signo = sig;
2595
2601
            break;
2596
2602
        default:
2597
2603
            printf ("Unhandled trap: 0x%x\n", trapnr);
2598
 
            cpu_dump_state(env, stderr, fprintf, 0);
 
2604
            cpu_dump_state(cs, stderr, fprintf, 0);
2599
2605
            exit (1);
2600
2606
        }
2601
2607
        process_pending_signals (env);
2606
2612
#ifdef TARGET_MICROBLAZE
2607
2613
void cpu_loop(CPUMBState *env)
2608
2614
{
 
2615
    CPUState *cs = CPU(mb_env_get_cpu(env));
2609
2616
    int trapnr, ret;
2610
2617
    target_siginfo_t info;
2611
2618
    
2673
2680
                default:
2674
2681
                    printf ("Unhandled hw-exception: 0x%x\n",
2675
2682
                            env->sregs[SR_ESR] & ESR_EC_MASK);
2676
 
                    cpu_dump_state(env, stderr, fprintf, 0);
 
2683
                    cpu_dump_state(cs, stderr, fprintf, 0);
2677
2684
                    exit (1);
2678
2685
                    break;
2679
2686
            }
2682
2689
            {
2683
2690
                int sig;
2684
2691
 
2685
 
                sig = gdb_handlesig (env, TARGET_SIGTRAP);
 
2692
                sig = gdb_handlesig(cs, TARGET_SIGTRAP);
2686
2693
                if (sig)
2687
2694
                  {
2688
2695
                    info.si_signo = sig;
2694
2701
            break;
2695
2702
        default:
2696
2703
            printf ("Unhandled trap: 0x%x\n", trapnr);
2697
 
            cpu_dump_state(env, stderr, fprintf, 0);
 
2704
            cpu_dump_state(cs, stderr, fprintf, 0);
2698
2705
            exit (1);
2699
2706
        }
2700
2707
        process_pending_signals (env);
2706
2713
 
2707
2714
void cpu_loop(CPUM68KState *env)
2708
2715
{
 
2716
    CPUState *cs = CPU(m68k_env_get_cpu(env));
2709
2717
    int trapnr;
2710
2718
    unsigned int n;
2711
2719
    target_siginfo_t info;
2774
2782
            {
2775
2783
                int sig;
2776
2784
 
2777
 
                sig = gdb_handlesig (env, TARGET_SIGTRAP);
 
2785
                sig = gdb_handlesig(cs, TARGET_SIGTRAP);
2778
2786
                if (sig)
2779
2787
                  {
2780
2788
                    info.si_signo = sig;
2787
2795
        default:
2788
2796
            fprintf(stderr, "qemu: unhandled CPU exception 0x%x - aborting\n",
2789
2797
                    trapnr);
2790
 
            cpu_dump_state(env, stderr, fprintf, 0);
 
2798
            cpu_dump_state(cs, stderr, fprintf, 0);
2791
2799
            abort();
2792
2800
        }
2793
2801
        process_pending_signals(env);
2843
2851
 
2844
2852
void cpu_loop(CPUAlphaState *env)
2845
2853
{
 
2854
    CPUState *cs = CPU(alpha_env_get_cpu(env));
2846
2855
    int trapnr;
2847
2856
    target_siginfo_t info;
2848
2857
    abi_long sysret;
3000
3009
            }
3001
3010
            break;
3002
3011
        case EXCP_DEBUG:
3003
 
            info.si_signo = gdb_handlesig (env, TARGET_SIGTRAP);
 
3012
            info.si_signo = gdb_handlesig(cs, TARGET_SIGTRAP);
3004
3013
            if (info.si_signo) {
3005
3014
                env->lock_addr = -1;
3006
3015
                info.si_errno = 0;
3017
3026
            break;
3018
3027
        default:
3019
3028
            printf ("Unhandled trap: 0x%x\n", trapnr);
3020
 
            cpu_dump_state(env, stderr, fprintf, 0);
 
3029
            cpu_dump_state(cs, stderr, fprintf, 0);
3021
3030
            exit (1);
3022
3031
        }
3023
3032
        process_pending_signals (env);
3028
3037
#ifdef TARGET_S390X
3029
3038
void cpu_loop(CPUS390XState *env)
3030
3039
{
 
3040
    CPUState *cs = CPU(s390_env_get_cpu(env));
3031
3041
    int trapnr, n, sig;
3032
3042
    target_siginfo_t info;
3033
3043
    target_ulong addr;
3052
3062
            break;
3053
3063
 
3054
3064
        case EXCP_DEBUG:
3055
 
            sig = gdb_handlesig(env, TARGET_SIGTRAP);
 
3065
            sig = gdb_handlesig(cs, TARGET_SIGTRAP);
3056
3066
            if (sig) {
3057
3067
                n = TARGET_TRAP_BRKPT;
3058
3068
                goto do_signal_pc;
3118
3128
 
3119
3129
            default:
3120
3130
                fprintf(stderr, "Unhandled program exception: %#x\n", n);
3121
 
                cpu_dump_state(env, stderr, fprintf, 0);
 
3131
                cpu_dump_state(cs, stderr, fprintf, 0);
3122
3132
                exit(1);
3123
3133
            }
3124
3134
            break;
3135
3145
 
3136
3146
        default:
3137
3147
            fprintf(stderr, "Unhandled trap: 0x%x\n", trapnr);
3138
 
            cpu_dump_state(env, stderr, fprintf, 0);
 
3148
            cpu_dump_state(cs, stderr, fprintf, 0);
3139
3149
            exit(1);
3140
3150
        }
3141
3151
        process_pending_signals (env);
3144
3154
 
3145
3155
#endif /* TARGET_S390X */
3146
3156
 
3147
 
THREAD CPUArchState *thread_env;
 
3157
THREAD CPUState *thread_cpu;
3148
3158
 
3149
3159
void task_settid(TaskState *ts)
3150
3160
{
3151
3161
    if (ts->ts_tid == 0) {
3152
 
#ifdef CONFIG_USE_NPTL
3153
3162
        ts->ts_tid = (pid_t)syscall(SYS_gettid);
3154
 
#else
3155
 
        /* when no threads are used, tid becomes pid */
3156
 
        ts->ts_tid = getpid();
3157
 
#endif
3158
3163
    }
3159
3164
}
3160
3165
 
3339
3344
 
3340
3345
static void handle_arg_version(const char *arg)
3341
3346
{
3342
 
    printf("qemu-" TARGET_ARCH " version " QEMU_VERSION QEMU_PKGVERSION
 
3347
    printf("qemu-" TARGET_NAME " version " QEMU_VERSION QEMU_PKGVERSION
3343
3348
           ", Copyright (c) 2003-2008 Fabrice Bellard\n");
3344
3349
    exit(0);
3345
3350
}
3400
3405
    int maxarglen;
3401
3406
    int maxenvlen;
3402
3407
 
3403
 
    printf("usage: qemu-" TARGET_ARCH " [options] program [arguments...]\n"
3404
 
           "Linux CPU emulator (compiled for " TARGET_ARCH " emulation)\n"
 
3408
    printf("usage: qemu-" TARGET_NAME " [options] program [arguments...]\n"
 
3409
           "Linux CPU emulator (compiled for " TARGET_NAME " emulation)\n"
3405
3410
           "\n"
3406
3411
           "Options and associated environment variables:\n"
3407
3412
           "\n");
3534
3539
    struct linux_binprm bprm;
3535
3540
    TaskState *ts;
3536
3541
    CPUArchState *env;
 
3542
    CPUState *cpu;
3537
3543
    int optind;
3538
3544
    char **target_environ, **wrk;
3539
3545
    char **target_argv;
3630
3636
        fprintf(stderr, "Unable to find CPU definition\n");
3631
3637
        exit(1);
3632
3638
    }
3633
 
#if defined(TARGET_SPARC) || defined(TARGET_PPC)
3634
 
    cpu_reset(ENV_GET_CPU(env));
3635
 
#endif
 
3639
    cpu = ENV_GET_CPU(env);
 
3640
    cpu_reset(cpu);
3636
3641
 
3637
 
    thread_env = env;
 
3642
    thread_cpu = cpu;
3638
3643
 
3639
3644
    if (getenv("QEMU_STRACE")) {
3640
3645
        do_strace = 1;
4069
4074
                    gdbstub_port);
4070
4075
            exit(1);
4071
4076
        }
4072
 
        gdb_handlesig(env, 0);
 
4077
        gdb_handlesig(cpu, 0);
4073
4078
    }
4074
4079
    cpu_loop(env);
4075
4080
    /* never exits */