~ubuntu-branches/ubuntu/vivid/qemu/vivid

« back to all changes in this revision

Viewing changes to linux-user/main.c

  • Committer: Package Import Robot
  • Author(s): Serge Hallyn
  • Date: 2014-02-25 22:31:43 UTC
  • mfrom: (1.8.5)
  • Revision ID: package-import@ubuntu.com-20140225223143-odhqxfc60wxrjl15
Tags: 2.0.0~rc1+dfsg-0ubuntu1
* Merge 2.0.0-rc1
* debian/rules: consolidate ppc filter entries.
* Move qemu-system-arch64 into qemu-system-arm
* debian/patches/define-trusty-machine-type.patch: define a trusty machine
  type, currently the same as pc-i440fx-2.0, to put is in a better position
  to enable live migrations from trusty onward.  (LP: #1294823)
* debian/control: build-dep on libfdt >= 1.4.0  (LP: #1295072)
* Merge latest upstream git to commit dc9528f
* Debian/rules:
  - remove -enable-uname-release=2.6.32
  - don't make the aarch64 target Ubuntu-specific.
* Remove patches which are now upstream:
  - fix-smb-security-share.patch
  - slirp-smb-redirect-port-445-too.patch 
  - linux-user-Implement-sendmmsg-syscall.patch (better version is upstream)
  - signal-added-a-wrapper-for-sigprocmask-function.patch
  - ubuntu/signal-sigsegv-protection-on-do_sigprocmask.patch
  - ubuntu/Don-t-block-SIGSEGV-at-more-places.patch
  - ubuntu/ppc-force-cpu-threads-count-to-be-power-of-2.patch
* add link for /usr/share/qemu/bios-256k.bin
* Remove all linaro patches.
* Remove all arm64/ patches.  Many but not all are upstream.
* Remove CVE-2013-4377.patch which is upstream.
* debian/control-in: don't make qemu-system-aarch64 ubuntu-specific

Show diffs side-by-side

added added

removed removed

Lines of Context:
69
69
static void usage(void);
70
70
 
71
71
static const char *interp_prefix = CONFIG_QEMU_INTERP_PREFIX;
72
 
 
73
 
#ifdef TARGET_AARCH64
74
 
# define UNAME_RELEASE "3.7.0"
75
 
#else
76
 
# define UNAME_RELEASE CONFIG_UNAME_RELEASE
77
 
#endif
78
 
 
79
 
const char *qemu_uname_release = UNAME_RELEASE;
 
72
const char *qemu_uname_release = CONFIG_UNAME_RELEASE;
80
73
 
81
74
/* XXX: on x86 MAP_GROWSDOWN only works if ESP <= address + 32, so
82
75
   we allocate a bigger stack. Need a better solution, for example
692
685
        switch(trapnr) {
693
686
        case EXCP_UDEF:
694
687
            {
695
 
                TaskState *ts = env->opaque;
 
688
                TaskState *ts = cs->opaque;
696
689
                uint32_t opcode;
697
690
                int rc;
698
691
 
960
953
            goto finish;
961
954
        }
962
955
    }
963
 
    val = env->xregs[rt];
 
956
    /* handle the zero register */
 
957
    val = rt == 31 ? 0 : env->xregs[rt];
964
958
    switch (size) {
965
959
    case 0:
966
960
        segv = put_user_u8(val, addr);
979
973
        goto error;
980
974
    }
981
975
    if (is_pair) {
982
 
        val = env->xregs[rt2];
 
976
        /* handle the zero register */
 
977
        val = rt2 == 31 ? 0 : env->xregs[rt2];
983
978
        if (size == 2) {
984
979
            segv = put_user_u32(val, addr + 4);
985
980
        } else {
1497
1492
{
1498
1493
    target_ulong addr;
1499
1494
    target_ulong page_addr;
1500
 
    target_ulong val;
 
1495
    target_ulong val, val2 __attribute__((unused));
1501
1496
    int flags;
1502
1497
    int segv = 0;
1503
1498
 
1520
1515
            case 4: segv = get_user_u32(val, addr); break;
1521
1516
#if defined(TARGET_PPC64)
1522
1517
            case 8: segv = get_user_u64(val, addr); break;
 
1518
            case 16: {
 
1519
                segv = get_user_u64(val, addr);
 
1520
                if (!segv) {
 
1521
                    segv = get_user_u64(val2, addr + 8);
 
1522
                }
 
1523
                break;
 
1524
            }
1523
1525
#endif
1524
1526
            default: abort();
1525
1527
            }
1531
1533
                case 4: segv = put_user_u32(val, addr); break;
1532
1534
#if defined(TARGET_PPC64)
1533
1535
                case 8: segv = put_user_u64(val, addr); break;
 
1536
                case 16: {
 
1537
                    if (val2 == env->reserve_val2) {
 
1538
                        segv = put_user_u64(val, addr);
 
1539
                        if (!segv) {
 
1540
                            segv = put_user_u64(val2, addr + 8);
 
1541
                        }
 
1542
                    }
 
1543
                    break;
 
1544
                }
1534
1545
#endif
1535
1546
                default: abort();
1536
1547
                }
1566
1577
            /* Just go on */
1567
1578
            break;
1568
1579
        case POWERPC_EXCP_CRITICAL: /* Critical input                        */
1569
 
            cpu_abort(env, "Critical interrupt while in user mode. "
 
1580
            cpu_abort(cs, "Critical interrupt while in user mode. "
1570
1581
                      "Aborting\n");
1571
1582
            break;
1572
1583
        case POWERPC_EXCP_MCHECK:   /* Machine check exception               */
1573
 
            cpu_abort(env, "Machine check exception while in user mode. "
 
1584
            cpu_abort(cs, "Machine check exception while in user mode. "
1574
1585
                      "Aborting\n");
1575
1586
            break;
1576
1587
        case POWERPC_EXCP_DSI:      /* Data storage exception                */
1634
1645
            queue_signal(env, info.si_signo, &info);
1635
1646
            break;
1636
1647
        case POWERPC_EXCP_EXTERNAL: /* External input                        */
1637
 
            cpu_abort(env, "External interrupt while in user mode. "
 
1648
            cpu_abort(cs, "External interrupt while in user mode. "
1638
1649
                      "Aborting\n");
1639
1650
            break;
1640
1651
        case POWERPC_EXCP_ALIGN:    /* Alignment exception                   */
1728
1739
                }
1729
1740
                break;
1730
1741
            case POWERPC_EXCP_TRAP:
1731
 
                cpu_abort(env, "Tried to call a TRAP\n");
 
1742
                cpu_abort(cs, "Tried to call a TRAP\n");
1732
1743
                break;
1733
1744
            default:
1734
1745
                /* Should not happen ! */
1735
 
                cpu_abort(env, "Unknown program exception (%02x)\n",
 
1746
                cpu_abort(cs, "Unknown program exception (%02x)\n",
1736
1747
                          env->error_code);
1737
1748
                break;
1738
1749
            }
1748
1759
            queue_signal(env, info.si_signo, &info);
1749
1760
            break;
1750
1761
        case POWERPC_EXCP_SYSCALL:  /* System call exception                 */
1751
 
            cpu_abort(env, "Syscall exception while in user mode. "
 
1762
            cpu_abort(cs, "Syscall exception while in user mode. "
1752
1763
                      "Aborting\n");
1753
1764
            break;
1754
1765
        case POWERPC_EXCP_APU:      /* Auxiliary processor unavailable       */
1760
1771
            queue_signal(env, info.si_signo, &info);
1761
1772
            break;
1762
1773
        case POWERPC_EXCP_DECR:     /* Decrementer exception                 */
1763
 
            cpu_abort(env, "Decrementer interrupt while in user mode. "
 
1774
            cpu_abort(cs, "Decrementer interrupt while in user mode. "
1764
1775
                      "Aborting\n");
1765
1776
            break;
1766
1777
        case POWERPC_EXCP_FIT:      /* Fixed-interval timer interrupt        */
1767
 
            cpu_abort(env, "Fix interval timer interrupt while in user mode. "
 
1778
            cpu_abort(cs, "Fix interval timer interrupt while in user mode. "
1768
1779
                      "Aborting\n");
1769
1780
            break;
1770
1781
        case POWERPC_EXCP_WDT:      /* Watchdog timer interrupt              */
1771
 
            cpu_abort(env, "Watchdog timer interrupt while in user mode. "
 
1782
            cpu_abort(cs, "Watchdog timer interrupt while in user mode. "
1772
1783
                      "Aborting\n");
1773
1784
            break;
1774
1785
        case POWERPC_EXCP_DTLB:     /* Data TLB error                        */
1775
 
            cpu_abort(env, "Data TLB exception while in user mode. "
 
1786
            cpu_abort(cs, "Data TLB exception while in user mode. "
1776
1787
                      "Aborting\n");
1777
1788
            break;
1778
1789
        case POWERPC_EXCP_ITLB:     /* Instruction TLB error                 */
1779
 
            cpu_abort(env, "Instruction TLB exception while in user mode. "
 
1790
            cpu_abort(cs, "Instruction TLB exception while in user mode. "
1780
1791
                      "Aborting\n");
1781
1792
            break;
1782
1793
        case POWERPC_EXCP_SPEU:     /* SPE/embedded floating-point unavail.  */
1788
1799
            queue_signal(env, info.si_signo, &info);
1789
1800
            break;
1790
1801
        case POWERPC_EXCP_EFPDI:    /* Embedded floating-point data IRQ      */
1791
 
            cpu_abort(env, "Embedded floating-point data IRQ not handled\n");
 
1802
            cpu_abort(cs, "Embedded floating-point data IRQ not handled\n");
1792
1803
            break;
1793
1804
        case POWERPC_EXCP_EFPRI:    /* Embedded floating-point round IRQ     */
1794
 
            cpu_abort(env, "Embedded floating-point round IRQ not handled\n");
 
1805
            cpu_abort(cs, "Embedded floating-point round IRQ not handled\n");
1795
1806
            break;
1796
1807
        case POWERPC_EXCP_EPERFM:   /* Embedded performance monitor IRQ      */
1797
 
            cpu_abort(env, "Performance monitor exception not handled\n");
 
1808
            cpu_abort(cs, "Performance monitor exception not handled\n");
1798
1809
            break;
1799
1810
        case POWERPC_EXCP_DOORI:    /* Embedded doorbell interrupt           */
1800
 
            cpu_abort(env, "Doorbell interrupt while in user mode. "
 
1811
            cpu_abort(cs, "Doorbell interrupt while in user mode. "
1801
1812
                       "Aborting\n");
1802
1813
            break;
1803
1814
        case POWERPC_EXCP_DOORCI:   /* Embedded doorbell critical interrupt  */
1804
 
            cpu_abort(env, "Doorbell critical interrupt while in user mode. "
 
1815
            cpu_abort(cs, "Doorbell critical interrupt while in user mode. "
1805
1816
                      "Aborting\n");
1806
1817
            break;
1807
1818
        case POWERPC_EXCP_RESET:    /* System reset exception                */
1808
 
            cpu_abort(env, "Reset interrupt while in user mode. "
 
1819
            cpu_abort(cs, "Reset interrupt while in user mode. "
1809
1820
                      "Aborting\n");
1810
1821
            break;
1811
1822
        case POWERPC_EXCP_DSEG:     /* Data segment exception                */
1812
 
            cpu_abort(env, "Data segment exception while in user mode. "
 
1823
            cpu_abort(cs, "Data segment exception while in user mode. "
1813
1824
                      "Aborting\n");
1814
1825
            break;
1815
1826
        case POWERPC_EXCP_ISEG:     /* Instruction segment exception         */
1816
 
            cpu_abort(env, "Instruction segment exception "
 
1827
            cpu_abort(cs, "Instruction segment exception "
1817
1828
                      "while in user mode. Aborting\n");
1818
1829
            break;
1819
1830
        /* PowerPC 64 with hypervisor mode support */
1820
1831
        case POWERPC_EXCP_HDECR:    /* Hypervisor decrementer exception      */
1821
 
            cpu_abort(env, "Hypervisor decrementer interrupt "
 
1832
            cpu_abort(cs, "Hypervisor decrementer interrupt "
1822
1833
                      "while in user mode. Aborting\n");
1823
1834
            break;
1824
1835
        case POWERPC_EXCP_TRACE:    /* Trace exception                       */
1828
1839
            break;
1829
1840
        /* PowerPC 64 with hypervisor mode support */
1830
1841
        case POWERPC_EXCP_HDSI:     /* Hypervisor data storage exception     */
1831
 
            cpu_abort(env, "Hypervisor data storage exception "
 
1842
            cpu_abort(cs, "Hypervisor data storage exception "
1832
1843
                      "while in user mode. Aborting\n");
1833
1844
            break;
1834
1845
        case POWERPC_EXCP_HISI:     /* Hypervisor instruction storage excp   */
1835
 
            cpu_abort(env, "Hypervisor instruction storage exception "
 
1846
            cpu_abort(cs, "Hypervisor instruction storage exception "
1836
1847
                      "while in user mode. Aborting\n");
1837
1848
            break;
1838
1849
        case POWERPC_EXCP_HDSEG:    /* Hypervisor data segment exception     */
1839
 
            cpu_abort(env, "Hypervisor data segment exception "
 
1850
            cpu_abort(cs, "Hypervisor data segment exception "
1840
1851
                      "while in user mode. Aborting\n");
1841
1852
            break;
1842
1853
        case POWERPC_EXCP_HISEG:    /* Hypervisor instruction segment excp   */
1843
 
            cpu_abort(env, "Hypervisor instruction segment exception "
 
1854
            cpu_abort(cs, "Hypervisor instruction segment exception "
1844
1855
                      "while in user mode. Aborting\n");
1845
1856
            break;
1846
1857
        case POWERPC_EXCP_VPU:      /* Vector unavailable exception          */
1852
1863
            queue_signal(env, info.si_signo, &info);
1853
1864
            break;
1854
1865
        case POWERPC_EXCP_PIT:      /* Programmable interval timer IRQ       */
1855
 
            cpu_abort(env, "Programmable interval timer interrupt "
 
1866
            cpu_abort(cs, "Programmable interval timer interrupt "
1856
1867
                      "while in user mode. Aborting\n");
1857
1868
            break;
1858
1869
        case POWERPC_EXCP_IO:       /* IO error exception                    */
1859
 
            cpu_abort(env, "IO error exception while in user mode. "
 
1870
            cpu_abort(cs, "IO error exception while in user mode. "
1860
1871
                      "Aborting\n");
1861
1872
            break;
1862
1873
        case POWERPC_EXCP_RUNM:     /* Run mode exception                    */
1863
 
            cpu_abort(env, "Run mode exception while in user mode. "
 
1874
            cpu_abort(cs, "Run mode exception while in user mode. "
1864
1875
                      "Aborting\n");
1865
1876
            break;
1866
1877
        case POWERPC_EXCP_EMUL:     /* Emulation trap exception              */
1867
 
            cpu_abort(env, "Emulation trap exception not handled\n");
 
1878
            cpu_abort(cs, "Emulation trap exception not handled\n");
1868
1879
            break;
1869
1880
        case POWERPC_EXCP_IFTLB:    /* Instruction fetch TLB error           */
1870
 
            cpu_abort(env, "Instruction fetch TLB exception "
 
1881
            cpu_abort(cs, "Instruction fetch TLB exception "
1871
1882
                      "while in user-mode. Aborting");
1872
1883
            break;
1873
1884
        case POWERPC_EXCP_DLTLB:    /* Data load TLB miss                    */
1874
 
            cpu_abort(env, "Data load TLB exception while in user-mode. "
 
1885
            cpu_abort(cs, "Data load TLB exception while in user-mode. "
1875
1886
                      "Aborting");
1876
1887
            break;
1877
1888
        case POWERPC_EXCP_DSTLB:    /* Data store TLB miss                   */
1878
 
            cpu_abort(env, "Data store TLB exception while in user-mode. "
 
1889
            cpu_abort(cs, "Data store TLB exception while in user-mode. "
1879
1890
                      "Aborting");
1880
1891
            break;
1881
1892
        case POWERPC_EXCP_FPA:      /* Floating-point assist exception       */
1882
 
            cpu_abort(env, "Floating-point assist exception not handled\n");
 
1893
            cpu_abort(cs, "Floating-point assist exception not handled\n");
1883
1894
            break;
1884
1895
        case POWERPC_EXCP_IABR:     /* Instruction address breakpoint        */
1885
 
            cpu_abort(env, "Instruction address breakpoint exception "
 
1896
            cpu_abort(cs, "Instruction address breakpoint exception "
1886
1897
                      "not handled\n");
1887
1898
            break;
1888
1899
        case POWERPC_EXCP_SMI:      /* System management interrupt           */
1889
 
            cpu_abort(env, "System management interrupt while in user mode. "
 
1900
            cpu_abort(cs, "System management interrupt while in user mode. "
1890
1901
                      "Aborting\n");
1891
1902
            break;
1892
1903
        case POWERPC_EXCP_THERM:    /* Thermal interrupt                     */
1893
 
            cpu_abort(env, "Thermal interrupt interrupt while in user mode. "
 
1904
            cpu_abort(cs, "Thermal interrupt interrupt while in user mode. "
1894
1905
                      "Aborting\n");
1895
1906
            break;
1896
1907
        case POWERPC_EXCP_PERFM:   /* Embedded performance monitor IRQ      */
1897
 
            cpu_abort(env, "Performance monitor exception not handled\n");
 
1908
            cpu_abort(cs, "Performance monitor exception not handled\n");
1898
1909
            break;
1899
1910
        case POWERPC_EXCP_VPUA:     /* Vector assist exception               */
1900
 
            cpu_abort(env, "Vector assist exception not handled\n");
 
1911
            cpu_abort(cs, "Vector assist exception not handled\n");
1901
1912
            break;
1902
1913
        case POWERPC_EXCP_SOFTP:    /* Soft patch exception                  */
1903
 
            cpu_abort(env, "Soft patch exception not handled\n");
 
1914
            cpu_abort(cs, "Soft patch exception not handled\n");
1904
1915
            break;
1905
1916
        case POWERPC_EXCP_MAINT:    /* Maintenance exception                 */
1906
 
            cpu_abort(env, "Maintenance exception while in user mode. "
 
1917
            cpu_abort(cs, "Maintenance exception while in user mode. "
1907
1918
                      "Aborting\n");
1908
1919
            break;
1909
1920
        case POWERPC_EXCP_STOP:     /* stop translation                      */
1959
1970
            /* just indicate that signals should be handled asap */
1960
1971
            break;
1961
1972
        default:
1962
 
            cpu_abort(env, "Unknown exception 0x%d. Aborting\n", trapnr);
 
1973
            cpu_abort(cs, "Unknown exception 0x%d. Aborting\n", trapnr);
1963
1974
            break;
1964
1975
        }
1965
1976
        process_pending_signals(env);
2389
2400
        ret = 0;
2390
2401
        break;
2391
2402
    default:
 
2403
        info->si_signo = TARGET_SIGTRAP;
 
2404
        info->si_errno = 0;
 
2405
        queue_signal(env, info->si_signo, &*info);
 
2406
        ret = 0;
2392
2407
        break;
2393
2408
    }
2394
2409
 
2950
2965
    int trapnr;
2951
2966
    unsigned int n;
2952
2967
    target_siginfo_t info;
2953
 
    TaskState *ts = env->opaque;
 
2968
    TaskState *ts = cs->opaque;
2954
2969
 
2955
2970
    for(;;) {
2956
2971
        trapnr = cpu_m68k_exec(env);
3420
3435
 
3421
3436
CPUArchState *cpu_copy(CPUArchState *env)
3422
3437
{
 
3438
    CPUState *cpu = ENV_GET_CPU(env);
3423
3439
    CPUArchState *new_env = cpu_init(cpu_model);
 
3440
    CPUState *new_cpu = ENV_GET_CPU(new_env);
3424
3441
#if defined(TARGET_HAS_ICE)
3425
3442
    CPUBreakpoint *bp;
3426
3443
    CPUWatchpoint *wp;
3427
3444
#endif
3428
3445
 
3429
3446
    /* Reset non arch specific state */
3430
 
    cpu_reset(ENV_GET_CPU(new_env));
 
3447
    cpu_reset(new_cpu);
3431
3448
 
3432
3449
    memcpy(new_env, env, sizeof(CPUArchState));
3433
3450
 
3434
3451
    /* Clone all break/watchpoints.
3435
3452
       Note: Once we support ptrace with hw-debug register access, make sure
3436
3453
       BP_CPU break/watchpoints are handled correctly on clone. */
3437
 
    QTAILQ_INIT(&env->breakpoints);
3438
 
    QTAILQ_INIT(&env->watchpoints);
 
3454
    QTAILQ_INIT(&cpu->breakpoints);
 
3455
    QTAILQ_INIT(&cpu->watchpoints);
3439
3456
#if defined(TARGET_HAS_ICE)
3440
 
    QTAILQ_FOREACH(bp, &env->breakpoints, entry) {
3441
 
        cpu_breakpoint_insert(new_env, bp->pc, bp->flags, NULL);
 
3457
    QTAILQ_FOREACH(bp, &cpu->breakpoints, entry) {
 
3458
        cpu_breakpoint_insert(new_cpu, bp->pc, bp->flags, NULL);
3442
3459
    }
3443
 
    QTAILQ_FOREACH(wp, &env->watchpoints, entry) {
3444
 
        cpu_watchpoint_insert(new_env, wp->vaddr, (~wp->len_mask) + 1,
 
3460
    QTAILQ_FOREACH(wp, &cpu->watchpoints, entry) {
 
3461
        cpu_watchpoint_insert(new_cpu, wp->vaddr, (~wp->len_mask) + 1,
3445
3462
                              wp->flags, NULL);
3446
3463
    }
3447
3464
#endif
3796
3813
    return optind;
3797
3814
}
3798
3815
 
3799
 
static int get_execfd(char **envp)
3800
 
{
3801
 
    typedef struct {
3802
 
        long a_type;
3803
 
        long a_val;
3804
 
    } auxv_t;
3805
 
    auxv_t *auxv;
3806
 
 
3807
 
    while (*envp++ != NULL) {
3808
 
        ;
3809
 
    }
3810
 
 
3811
 
    for (auxv = (auxv_t *)envp; auxv->a_type != AT_NULL; auxv++) {
3812
 
        if (auxv->a_type == AT_EXECFD) {
3813
 
            return auxv->a_val;
3814
 
        }
3815
 
    }
3816
 
    return -1;
3817
 
}
3818
 
 
3819
3816
int main(int argc, char **argv, char **envp)
3820
3817
{
3821
3818
    struct target_pt_regs regs1, *regs = &regs1;
3834
3831
 
3835
3832
    module_call_init(MODULE_INIT_QOM);
3836
3833
 
3837
 
    qemu_cache_utils_init(envp);
 
3834
    qemu_init_auxval(envp);
 
3835
    qemu_cache_utils_init();
3838
3836
 
3839
3837
    if ((envlist = envlist_create()) == NULL) {
3840
3838
        (void) fprintf(stderr, "Unable to allocate envlist\n");
4005
4003
    /* build Task State */
4006
4004
    ts->info = info;
4007
4005
    ts->bprm = &bprm;
4008
 
    env->opaque = ts;
 
4006
    cpu->opaque = ts;
4009
4007
    task_settid(ts);
4010
4008
 
4011
 
    execfd = get_execfd(envp);
4012
 
    if (execfd < 0) {
 
4009
    execfd = qemu_getauxval(AT_EXECFD);
 
4010
    if (execfd == 0) {
4013
4011
        execfd = open(filename, O_RDONLY);
4014
 
    }
4015
 
    if (execfd < 0) {
4016
 
        printf("Error while loading %s: %s\n", filename, strerror(-execfd));
4017
 
        _exit(1);
 
4012
        if (execfd < 0) {
 
4013
            printf("Error while loading %s: %s\n", filename, strerror(errno));
 
4014
            _exit(1);
 
4015
        }
4018
4016
    }
4019
4017
 
4020
4018
    ret = loader_exec(execfd, filename, target_argv, target_environ, regs,