process.cc revision 13883
1/*
2 * Copyright (c) 2014-2016 Advanced Micro Devices, Inc.
3 * Copyright (c) 2012 ARM Limited
4 * All rights reserved
5 *
6 * The license below extends only to copyright in the software and shall
7 * not be construed as granting a license to any other intellectual
8 * property including but not limited to intellectual property relating
9 * to a hardware implementation of the functionality of the software
10 * licensed hereunder.  You may use the software subject to the license
11 * terms below provided that you ensure that this notice is replicated
12 * unmodified and in its entirety in all distributions of the software,
13 * modified or unmodified, in source code or in binary form.
14 *
15 * Copyright (c) 2001-2005 The Regents of The University of Michigan
16 * All rights reserved.
17 *
18 * Redistribution and use in source and binary forms, with or without
19 * modification, are permitted provided that the following conditions are
20 * met: redistributions of source code must retain the above copyright
21 * notice, this list of conditions and the following disclaimer;
22 * redistributions in binary form must reproduce the above copyright
23 * notice, this list of conditions and the following disclaimer in the
24 * documentation and/or other materials provided with the distribution;
25 * neither the name of the copyright holders nor the names of its
26 * contributors may be used to endorse or promote products derived from
27 * this software without specific prior written permission.
28 *
29 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
30 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
31 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
32 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
33 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
34 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
35 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
36 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
37 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
38 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
39 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
40 *
41 * Authors: Nathan Binkert
42 *          Steve Reinhardt
43 *          Ali Saidi
44 *          Brandon Potter
45 */
46
47#include "sim/process.hh"
48
49#include <fcntl.h>
50#include <unistd.h>
51
52#include <array>
53#include <climits>
54#include <csignal>
55#include <map>
56#include <string>
57#include <vector>
58
59#include "base/intmath.hh"
60#include "base/loader/object_file.hh"
61#include "base/loader/symtab.hh"
62#include "base/statistics.hh"
63#include "config/the_isa.hh"
64#include "cpu/thread_context.hh"
65#include "mem/page_table.hh"
66#include "mem/se_translating_port_proxy.hh"
67#include "params/Process.hh"
68#include "sim/emul_driver.hh"
69#include "sim/fd_array.hh"
70#include "sim/fd_entry.hh"
71#include "sim/redirect_path.hh"
72#include "sim/syscall_desc.hh"
73#include "sim/system.hh"
74
75#if THE_ISA == ALPHA_ISA
76#include "arch/alpha/linux/process.hh"
77
78#elif THE_ISA == SPARC_ISA
79#include "arch/sparc/linux/process.hh"
80#include "arch/sparc/solaris/process.hh"
81
82#elif THE_ISA == MIPS_ISA
83#include "arch/mips/linux/process.hh"
84
85#elif THE_ISA == ARM_ISA
86#include "arch/arm/freebsd/process.hh"
87#include "arch/arm/linux/process.hh"
88
89#elif THE_ISA == X86_ISA
90#include "arch/x86/linux/process.hh"
91
92#elif THE_ISA == POWER_ISA
93#include "arch/power/linux/process.hh"
94
95#elif THE_ISA == RISCV_ISA
96#include "arch/riscv/linux/process.hh"
97
98#else
99#error "THE_ISA not set"
100#endif
101
102
103using namespace std;
104using namespace TheISA;
105
106static std::string
107normalize(std::string& directory)
108{
109    if (directory.back() != '/')
110        directory += '/';
111    return directory;
112}
113
114Process::Process(ProcessParams *params, EmulationPageTable *pTable,
115                 ObjectFile *obj_file)
116    : SimObject(params), system(params->system),
117      useArchPT(params->useArchPT),
118      kvmInSE(params->kvmInSE),
119      useForClone(false),
120      pTable(pTable),
121      initVirtMem(system->getSystemPort(), this,
122                  SETranslatingPortProxy::Always),
123      objFile(obj_file),
124      argv(params->cmd), envp(params->env),
125      executable(params->executable),
126      tgtCwd(normalize(params->cwd)),
127      hostCwd(checkPathRedirect(tgtCwd)),
128      _uid(params->uid), _euid(params->euid),
129      _gid(params->gid), _egid(params->egid),
130      _pid(params->pid), _ppid(params->ppid),
131      _pgid(params->pgid), drivers(params->drivers),
132      fds(make_shared<FDArray>(params->input, params->output, params->errout)),
133      childClearTID(0)
134{
135    if (_pid >= System::maxPID)
136        fatal("_pid is too large: %d", _pid);
137
138    auto ret_pair = system->PIDs.emplace(_pid);
139    if (!ret_pair.second)
140        fatal("_pid %d is already used", _pid);
141
142    /**
143     * Linux bundles together processes into this concept called a thread
144     * group. The thread group is responsible for recording which processes
145     * behave as threads within a process context. The thread group leader
146     * is the process who's tgid is equal to its pid. Other processes which
147     * belong to the thread group, but do not lead the thread group, are
148     * treated as child threads. These threads are created by the clone system
149     * call with options specified to create threads (differing from the
150     * options used to implement a fork). By default, set up the tgid/pid
151     * with a new, equivalent value. If CLONE_THREAD is specified, patch
152     * the tgid value with the old process' value.
153     */
154    _tgid = params->pid;
155
156    exitGroup = new bool();
157    sigchld = new bool();
158
159    if (!debugSymbolTable) {
160        debugSymbolTable = new SymbolTable();
161        if (!objFile->loadGlobalSymbols(debugSymbolTable) ||
162            !objFile->loadLocalSymbols(debugSymbolTable) ||
163            !objFile->loadWeakSymbols(debugSymbolTable)) {
164            delete debugSymbolTable;
165            debugSymbolTable = nullptr;
166        }
167    }
168}
169
170void
171Process::clone(ThreadContext *otc, ThreadContext *ntc,
172               Process *np, RegVal flags)
173{
174#ifndef CLONE_VM
175#define CLONE_VM 0
176#endif
177#ifndef CLONE_FILES
178#define CLONE_FILES 0
179#endif
180#ifndef CLONE_THREAD
181#define CLONE_THREAD 0
182#endif
183    if (CLONE_VM & flags) {
184        /**
185         * Share the process memory address space between the new process
186         * and the old process. Changes in one will be visible in the other
187         * due to the pointer use.
188         */
189        delete np->pTable;
190        np->pTable = pTable;
191        ntc->getMemProxy().setPageTable(np->pTable);
192
193        np->memState = memState;
194    } else {
195        /**
196         * Duplicate the process memory address space. The state needs to be
197         * copied over (rather than using pointers to share everything).
198         */
199        typedef std::vector<pair<Addr,Addr>> MapVec;
200        MapVec mappings;
201        pTable->getMappings(&mappings);
202
203        for (auto map : mappings) {
204            Addr paddr, vaddr = map.first;
205            bool alloc_page = !(np->pTable->translate(vaddr, paddr));
206            np->replicatePage(vaddr, paddr, otc, ntc, alloc_page);
207        }
208
209        *np->memState = *memState;
210    }
211
212    if (CLONE_FILES & flags) {
213        /**
214         * The parent and child file descriptors are shared because the
215         * two FDArray pointers are pointing to the same FDArray. Opening
216         * and closing file descriptors will be visible to both processes.
217         */
218        np->fds = fds;
219    } else {
220        /**
221         * Copy the file descriptors from the old process into the new
222         * child process. The file descriptors entry can be opened and
223         * closed independently of the other process being considered. The
224         * host file descriptors are also dup'd so that the flags for the
225         * host file descriptor is independent of the other process.
226         */
227        for (int tgt_fd = 0; tgt_fd < fds->getSize(); tgt_fd++) {
228            std::shared_ptr<FDArray> nfds = np->fds;
229            std::shared_ptr<FDEntry> this_fde = (*fds)[tgt_fd];
230            if (!this_fde) {
231                nfds->setFDEntry(tgt_fd, nullptr);
232                continue;
233            }
234            nfds->setFDEntry(tgt_fd, this_fde->clone());
235
236            auto this_hbfd = std::dynamic_pointer_cast<HBFDEntry>(this_fde);
237            if (!this_hbfd)
238                continue;
239
240            int this_sim_fd = this_hbfd->getSimFD();
241            if (this_sim_fd <= 2)
242                continue;
243
244            int np_sim_fd = dup(this_sim_fd);
245            assert(np_sim_fd != -1);
246
247            auto nhbfd = std::dynamic_pointer_cast<HBFDEntry>((*nfds)[tgt_fd]);
248            nhbfd->setSimFD(np_sim_fd);
249        }
250    }
251
252    if (CLONE_THREAD & flags) {
253        np->_tgid = _tgid;
254        delete np->exitGroup;
255        np->exitGroup = exitGroup;
256    }
257
258    np->argv.insert(np->argv.end(), argv.begin(), argv.end());
259    np->envp.insert(np->envp.end(), envp.begin(), envp.end());
260}
261
262void
263Process::regStats()
264{
265    SimObject::regStats();
266
267    using namespace Stats;
268
269    numSyscalls
270        .name(name() + ".numSyscalls")
271        .desc("Number of system calls")
272        ;
273}
274
275ThreadContext *
276Process::findFreeContext()
277{
278    for (auto &it : system->threadContexts) {
279        if (ThreadContext::Halted == it->status())
280            return it;
281    }
282    return nullptr;
283}
284
285void
286Process::revokeThreadContext(int context_id)
287{
288    std::vector<ContextID>::iterator it;
289    for (it = contextIds.begin(); it != contextIds.end(); it++) {
290        if (*it == context_id) {
291            contextIds.erase(it);
292            return;
293        }
294    }
295    warn("Unable to find thread context to revoke");
296}
297
298void
299Process::initState()
300{
301    if (contextIds.empty())
302        fatal("Process %s is not associated with any HW contexts!\n", name());
303
304    // first thread context for this process... initialize & enable
305    ThreadContext *tc = system->getThreadContext(contextIds[0]);
306
307    // mark this context as active so it will start ticking.
308    tc->activate();
309
310    pTable->initState(tc);
311}
312
313DrainState
314Process::drain()
315{
316    fds->updateFileOffsets();
317    return DrainState::Drained;
318}
319
320void
321Process::allocateMem(Addr vaddr, int64_t size, bool clobber)
322{
323    int npages = divCeil(size, (int64_t)PageBytes);
324    Addr paddr = system->allocPhysPages(npages);
325    pTable->map(vaddr, paddr, size,
326                clobber ? EmulationPageTable::Clobber :
327                          EmulationPageTable::MappingFlags(0));
328}
329
330void
331Process::replicatePage(Addr vaddr, Addr new_paddr, ThreadContext *old_tc,
332                       ThreadContext *new_tc, bool allocate_page)
333{
334    if (allocate_page)
335        new_paddr = system->allocPhysPages(1);
336
337    // Read from old physical page.
338    uint8_t *buf_p = new uint8_t[PageBytes];
339    old_tc->getMemProxy().readBlob(vaddr, buf_p, PageBytes);
340
341    // Create new mapping in process address space by clobbering existing
342    // mapping (if any existed) and then write to the new physical page.
343    bool clobber = true;
344    pTable->map(vaddr, new_paddr, PageBytes, clobber);
345    new_tc->getMemProxy().writeBlob(vaddr, buf_p, PageBytes);
346    delete[] buf_p;
347}
348
349bool
350Process::fixupStackFault(Addr vaddr)
351{
352    Addr stack_min = memState->getStackMin();
353    Addr stack_base = memState->getStackBase();
354    Addr max_stack_size = memState->getMaxStackSize();
355
356    // Check if this is already on the stack and there's just no page there
357    // yet.
358    if (vaddr >= stack_min && vaddr < stack_base) {
359        allocateMem(roundDown(vaddr, PageBytes), PageBytes);
360        return true;
361    }
362
363    // We've accessed the next page of the stack, so extend it to include
364    // this address.
365    if (vaddr < stack_min && vaddr >= stack_base - max_stack_size) {
366        while (vaddr < stack_min) {
367            stack_min -= TheISA::PageBytes;
368            if (stack_base - stack_min > max_stack_size)
369                fatal("Maximum stack size exceeded\n");
370            allocateMem(stack_min, TheISA::PageBytes);
371            inform("Increasing stack size by one page.");
372        }
373        memState->setStackMin(stack_min);
374        return true;
375    }
376    return false;
377}
378
379void
380Process::serialize(CheckpointOut &cp) const
381{
382    memState->serialize(cp);
383    pTable->serialize(cp);
384    /**
385     * Checkpoints for file descriptors currently do not work. Need to
386     * come back and fix them at a later date.
387     */
388
389    warn("Checkpoints for file descriptors currently do not work.");
390#if 0
391    for (int x = 0; x < fds->getSize(); x++)
392        (*fds)[x].serializeSection(cp, csprintf("FDEntry%d", x));
393#endif
394
395}
396
397void
398Process::unserialize(CheckpointIn &cp)
399{
400    memState->unserialize(cp);
401    pTable->unserialize(cp);
402    /**
403     * Checkpoints for file descriptors currently do not work. Need to
404     * come back and fix them at a later date.
405     */
406    warn("Checkpoints for file descriptors currently do not work.");
407#if 0
408    for (int x = 0; x < fds->getSize(); x++)
409        (*fds)[x]->unserializeSection(cp, csprintf("FDEntry%d", x));
410    fds->restoreFileOffsets();
411#endif
412    // The above returns a bool so that you could do something if you don't
413    // find the param in the checkpoint if you wanted to, like set a default
414    // but in this case we'll just stick with the instantiated value if not
415    // found.
416}
417
418bool
419Process::map(Addr vaddr, Addr paddr, int size, bool cacheable)
420{
421    pTable->map(vaddr, paddr, size,
422                cacheable ? EmulationPageTable::MappingFlags(0) :
423                            EmulationPageTable::Uncacheable);
424    return true;
425}
426
427void
428Process::syscall(int64_t callnum, ThreadContext *tc, Fault *fault)
429{
430    numSyscalls++;
431
432    SyscallDesc *desc = getDesc(callnum);
433    if (desc == nullptr)
434        fatal("Syscall %d out of range", callnum);
435
436    desc->doSyscall(callnum, this, tc, fault);
437}
438
439RegVal
440Process::getSyscallArg(ThreadContext *tc, int &i, int width)
441{
442    return getSyscallArg(tc, i);
443}
444
445EmulatedDriver *
446Process::findDriver(std::string filename)
447{
448    for (EmulatedDriver *d : drivers) {
449        if (d->match(filename))
450            return d;
451    }
452
453    return nullptr;
454}
455
456std::string
457Process::checkPathRedirect(const std::string &filename)
458{
459    // If the input parameter contains a relative path, convert it. Note,
460    // the return value for this method should always return an absolute
461    // path on the host filesystem. The return value will be used to
462    // open and manipulate the path specified by the input parameter. Since
463    // all filesystem handling in syscall mode is passed through to the host,
464    // we deal only with host paths.
465    auto host_fs_abs_path = absolutePath(filename, true);
466
467    for (auto path : system->redirectPaths) {
468        // Search through the redirect paths to see if a starting substring of
469        // our path falls into any buckets which need to redirected.
470        if (startswith(host_fs_abs_path, path->appPath())) {
471            std::string tail = host_fs_abs_path.substr(path->appPath().size());
472
473            // If this path needs to be redirected, search through a list
474            // of targets to see if we can match a valid file (or directory).
475            for (auto host_path : path->hostPaths()) {
476                if (access((host_path + tail).c_str(), R_OK) == 0) {
477                    // Return the valid match.
478                    return host_path + tail;
479                }
480            }
481            // The path needs to be redirected, but the file or directory
482            // does not exist on the host filesystem. Return the first
483            // host path as a default.
484            return path->hostPaths()[0] + tail;
485        }
486    }
487
488    // The path does not need to be redirected.
489    return host_fs_abs_path;
490}
491
492void
493Process::updateBias()
494{
495    ObjectFile *interp = objFile->getInterpreter();
496
497    if (!interp || !interp->relocatable())
498        return;
499
500    // Determine how large the interpreters footprint will be in the process
501    // address space.
502    Addr interp_mapsize = roundUp(interp->mapSize(), TheISA::PageBytes);
503
504    // We are allocating the memory area; set the bias to the lowest address
505    // in the allocated memory region.
506    Addr mmap_end = memState->getMmapEnd();
507    Addr ld_bias = mmapGrowsDown() ? mmap_end - interp_mapsize : mmap_end;
508
509    // Adjust the process mmap area to give the interpreter room; the real
510    // execve system call would just invoke the kernel's internal mmap
511    // functions to make these adjustments.
512    mmap_end = mmapGrowsDown() ? ld_bias : mmap_end + interp_mapsize;
513    memState->setMmapEnd(mmap_end);
514
515    interp->updateBias(ld_bias);
516}
517
518ObjectFile *
519Process::getInterpreter()
520{
521    return objFile->getInterpreter();
522}
523
524Addr
525Process::getBias()
526{
527    ObjectFile *interp = getInterpreter();
528
529    return interp ? interp->bias() : objFile->bias();
530}
531
532Addr
533Process::getStartPC()
534{
535    ObjectFile *interp = getInterpreter();
536
537    return interp ? interp->entryPoint() : objFile->entryPoint();
538}
539
540std::string
541Process::absolutePath(const std::string &filename, bool host_filesystem)
542{
543    if (filename.empty() || startswith(filename, "/"))
544        return filename;
545
546    // Verify that the current working directories are initialized properly.
547    // These members should be set initially via params from 'Process.py',
548    // although they may change over time depending on what the application
549    // does during simulation.
550    assert(!tgtCwd.empty());
551    assert(!hostCwd.empty());
552
553    // Construct the absolute path given the current working directory for
554    // either the host filesystem or target filesystem. The distinction only
555    // matters if filesystem redirection is utilized in the simulation.
556    auto path_base = host_filesystem ? hostCwd : tgtCwd;
557
558    // Add a trailing '/' if the current working directory did not have one.
559    normalize(path_base);
560
561    // Append the filename onto the current working path.
562    auto absolute_path = path_base + filename;
563
564    return absolute_path;
565}
566
567Process *
568ProcessParams::create()
569{
570    Process *process = nullptr;
571
572    // If not specified, set the executable parameter equal to the
573    // simulated system's zeroth command line parameter
574    if (executable == "") {
575        executable = cmd[0];
576    }
577
578    ObjectFile *obj_file = createObjectFile(executable);
579    if (obj_file == nullptr) {
580        fatal("Can't load object file %s", executable);
581    }
582
583#if THE_ISA == ALPHA_ISA
584    if (obj_file->getArch() != ObjectFile::Alpha)
585        fatal("Object file architecture does not match compiled ISA (Alpha).");
586
587    switch (obj_file->getOpSys()) {
588      case ObjectFile::UnknownOpSys:
589        warn("Unknown operating system; assuming Linux.");
590        // fall through
591      case ObjectFile::Linux:
592        process = new AlphaLinuxProcess(this, obj_file);
593        break;
594
595      default:
596        fatal("Unknown/unsupported operating system.");
597    }
598#elif THE_ISA == SPARC_ISA
599    if (obj_file->getArch() != ObjectFile::SPARC64 &&
600        obj_file->getArch() != ObjectFile::SPARC32)
601        fatal("Object file architecture does not match compiled ISA (SPARC).");
602    switch (obj_file->getOpSys()) {
603      case ObjectFile::UnknownOpSys:
604        warn("Unknown operating system; assuming Linux.");
605        // fall through
606      case ObjectFile::Linux:
607        if (obj_file->getArch() == ObjectFile::SPARC64) {
608            process = new Sparc64LinuxProcess(this, obj_file);
609        } else {
610            process = new Sparc32LinuxProcess(this, obj_file);
611        }
612        break;
613
614      case ObjectFile::Solaris:
615        process = new SparcSolarisProcess(this, obj_file);
616        break;
617
618      default:
619        fatal("Unknown/unsupported operating system.");
620    }
621#elif THE_ISA == X86_ISA
622    if (obj_file->getArch() != ObjectFile::X86_64 &&
623        obj_file->getArch() != ObjectFile::I386)
624        fatal("Object file architecture does not match compiled ISA (x86).");
625    switch (obj_file->getOpSys()) {
626      case ObjectFile::UnknownOpSys:
627        warn("Unknown operating system; assuming Linux.");
628        // fall through
629      case ObjectFile::Linux:
630        if (obj_file->getArch() == ObjectFile::X86_64) {
631            process = new X86_64LinuxProcess(this, obj_file);
632        } else {
633            process = new I386LinuxProcess(this, obj_file);
634        }
635        break;
636
637      default:
638        fatal("Unknown/unsupported operating system.");
639    }
640#elif THE_ISA == MIPS_ISA
641    if (obj_file->getArch() != ObjectFile::Mips)
642        fatal("Object file architecture does not match compiled ISA (MIPS).");
643    switch (obj_file->getOpSys()) {
644      case ObjectFile::UnknownOpSys:
645        warn("Unknown operating system; assuming Linux.");
646        // fall through
647      case ObjectFile::Linux:
648        process = new MipsLinuxProcess(this, obj_file);
649        break;
650
651      default:
652        fatal("Unknown/unsupported operating system.");
653    }
654#elif THE_ISA == ARM_ISA
655    ObjectFile::Arch arch = obj_file->getArch();
656    if (arch != ObjectFile::Arm && arch != ObjectFile::Thumb &&
657        arch != ObjectFile::Arm64)
658        fatal("Object file architecture does not match compiled ISA (ARM).");
659    switch (obj_file->getOpSys()) {
660      case ObjectFile::UnknownOpSys:
661        warn("Unknown operating system; assuming Linux.");
662        // fall through
663      case ObjectFile::Linux:
664        if (arch == ObjectFile::Arm64) {
665            process = new ArmLinuxProcess64(this, obj_file,
666                                            obj_file->getArch());
667        } else {
668            process = new ArmLinuxProcess32(this, obj_file,
669                                            obj_file->getArch());
670        }
671        break;
672      case ObjectFile::FreeBSD:
673        if (arch == ObjectFile::Arm64) {
674            process = new ArmFreebsdProcess64(this, obj_file,
675                                              obj_file->getArch());
676        } else {
677            process = new ArmFreebsdProcess32(this, obj_file,
678                                              obj_file->getArch());
679        }
680        break;
681      case ObjectFile::LinuxArmOABI:
682        fatal("M5 does not support ARM OABI binaries. Please recompile with an"
683              " EABI compiler.");
684      default:
685        fatal("Unknown/unsupported operating system.");
686    }
687#elif THE_ISA == POWER_ISA
688    if (obj_file->getArch() != ObjectFile::Power)
689        fatal("Object file architecture does not match compiled ISA (Power).");
690    switch (obj_file->getOpSys()) {
691      case ObjectFile::UnknownOpSys:
692        warn("Unknown operating system; assuming Linux.");
693        // fall through
694      case ObjectFile::Linux:
695        process = new PowerLinuxProcess(this, obj_file);
696        break;
697
698      default:
699        fatal("Unknown/unsupported operating system.");
700    }
701#elif THE_ISA == RISCV_ISA
702    ObjectFile::Arch arch = obj_file->getArch();
703    if (arch != ObjectFile::Riscv64 && arch != ObjectFile::Riscv32)
704        fatal("Object file architecture does not match compiled ISA (RISCV).");
705    switch (obj_file->getOpSys()) {
706      case ObjectFile::UnknownOpSys:
707        warn("Unknown operating system; assuming Linux.");
708        // fall through
709      case ObjectFile::Linux:
710        if (arch == ObjectFile::Riscv64) {
711            process = new RiscvLinuxProcess64(this, obj_file);
712        } else {
713            process = new RiscvLinuxProcess32(this, obj_file);
714        }
715        break;
716      default:
717        fatal("Unknown/unsupported operating system.");
718    }
719#else
720#error "THE_ISA not set"
721#endif
722
723    if (process == nullptr)
724        fatal("Unknown error creating process object.");
725    return process;
726}
727