process.cc revision 8229
16691Stjones1@inf.ed.ac.uk/*
26691Stjones1@inf.ed.ac.uk * Copyright (c) 2007-2008 The Florida State University
36691Stjones1@inf.ed.ac.uk * Copyright (c) 2009 The University of Edinburgh
46691Stjones1@inf.ed.ac.uk * All rights reserved.
56691Stjones1@inf.ed.ac.uk *
66691Stjones1@inf.ed.ac.uk * Redistribution and use in source and binary forms, with or without
76691Stjones1@inf.ed.ac.uk * modification, are permitted provided that the following conditions are
86691Stjones1@inf.ed.ac.uk * met: redistributions of source code must retain the above copyright
96691Stjones1@inf.ed.ac.uk * notice, this list of conditions and the following disclaimer;
106691Stjones1@inf.ed.ac.uk * redistributions in binary form must reproduce the above copyright
116691Stjones1@inf.ed.ac.uk * notice, this list of conditions and the following disclaimer in the
126691Stjones1@inf.ed.ac.uk * documentation and/or other materials provided with the distribution;
136691Stjones1@inf.ed.ac.uk * neither the name of the copyright holders nor the names of its
146691Stjones1@inf.ed.ac.uk * contributors may be used to endorse or promote products derived from
156691Stjones1@inf.ed.ac.uk * this software without specific prior written permission.
166691Stjones1@inf.ed.ac.uk *
176691Stjones1@inf.ed.ac.uk * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
186691Stjones1@inf.ed.ac.uk * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
196691Stjones1@inf.ed.ac.uk * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
206691Stjones1@inf.ed.ac.uk * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
216691Stjones1@inf.ed.ac.uk * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
226691Stjones1@inf.ed.ac.uk * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
236691Stjones1@inf.ed.ac.uk * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
246691Stjones1@inf.ed.ac.uk * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
256691Stjones1@inf.ed.ac.uk * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
266691Stjones1@inf.ed.ac.uk * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
276691Stjones1@inf.ed.ac.uk * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
286691Stjones1@inf.ed.ac.uk *
296691Stjones1@inf.ed.ac.uk * Authors: Stephen Hines
306691Stjones1@inf.ed.ac.uk *          Timothy M. Jones
316691Stjones1@inf.ed.ac.uk */
326691Stjones1@inf.ed.ac.uk
336691Stjones1@inf.ed.ac.uk#include "arch/power/isa_traits.hh"
346691Stjones1@inf.ed.ac.uk#include "arch/power/process.hh"
356691Stjones1@inf.ed.ac.uk#include "arch/power/types.hh"
366691Stjones1@inf.ed.ac.uk#include "base/loader/elf_object.hh"
376691Stjones1@inf.ed.ac.uk#include "base/loader/object_file.hh"
386691Stjones1@inf.ed.ac.uk#include "base/misc.hh"
396691Stjones1@inf.ed.ac.uk#include "cpu/thread_context.hh"
406691Stjones1@inf.ed.ac.uk#include "mem/page_table.hh"
416691Stjones1@inf.ed.ac.uk#include "mem/translating_port.hh"
426691Stjones1@inf.ed.ac.uk#include "sim/process_impl.hh"
436691Stjones1@inf.ed.ac.uk#include "sim/system.hh"
446691Stjones1@inf.ed.ac.uk
456691Stjones1@inf.ed.ac.ukusing namespace std;
466691Stjones1@inf.ed.ac.ukusing namespace PowerISA;
476691Stjones1@inf.ed.ac.uk
486691Stjones1@inf.ed.ac.ukPowerLiveProcess::PowerLiveProcess(LiveProcessParams *params,
496691Stjones1@inf.ed.ac.uk        ObjectFile *objFile)
506691Stjones1@inf.ed.ac.uk    : LiveProcess(params, objFile)
516691Stjones1@inf.ed.ac.uk{
526691Stjones1@inf.ed.ac.uk    stack_base = 0xbf000000L;
536691Stjones1@inf.ed.ac.uk
546691Stjones1@inf.ed.ac.uk    // Set pointer for next thread stack.  Reserve 8M for main stack.
556691Stjones1@inf.ed.ac.uk    next_thread_stack_base = stack_base - (8 * 1024 * 1024);
566691Stjones1@inf.ed.ac.uk
576691Stjones1@inf.ed.ac.uk    // Set up break point (Top of Heap)
586691Stjones1@inf.ed.ac.uk    brk_point = objFile->dataBase() + objFile->dataSize() + objFile->bssSize();
596691Stjones1@inf.ed.ac.uk    brk_point = roundUp(brk_point, VMPageSize);
606691Stjones1@inf.ed.ac.uk
616691Stjones1@inf.ed.ac.uk    // Set up region for mmaps. For now, start at bottom of kuseg space.
626691Stjones1@inf.ed.ac.uk    mmap_start = mmap_end = 0x70000000L;
636691Stjones1@inf.ed.ac.uk}
646691Stjones1@inf.ed.ac.uk
656691Stjones1@inf.ed.ac.ukvoid
667532Ssteve.reinhardt@amd.comPowerLiveProcess::initState()
676691Stjones1@inf.ed.ac.uk{
687532Ssteve.reinhardt@amd.com    Process::initState();
697532Ssteve.reinhardt@amd.com
706691Stjones1@inf.ed.ac.uk    argsInit(MachineBytes, VMPageSize);
716691Stjones1@inf.ed.ac.uk}
726691Stjones1@inf.ed.ac.uk
736691Stjones1@inf.ed.ac.ukvoid
746691Stjones1@inf.ed.ac.ukPowerLiveProcess::argsInit(int intSize, int pageSize)
756691Stjones1@inf.ed.ac.uk{
766691Stjones1@inf.ed.ac.uk    typedef AuxVector<uint32_t> auxv_t;
776691Stjones1@inf.ed.ac.uk    std::vector<auxv_t> auxv;
786691Stjones1@inf.ed.ac.uk
796691Stjones1@inf.ed.ac.uk    string filename;
806691Stjones1@inf.ed.ac.uk    if (argv.size() < 1)
816691Stjones1@inf.ed.ac.uk        filename = "";
826691Stjones1@inf.ed.ac.uk    else
836691Stjones1@inf.ed.ac.uk        filename = argv[0];
846691Stjones1@inf.ed.ac.uk
856691Stjones1@inf.ed.ac.uk    //We want 16 byte alignment
866691Stjones1@inf.ed.ac.uk    uint64_t align = 16;
876691Stjones1@inf.ed.ac.uk
886691Stjones1@inf.ed.ac.uk    // load object file into target memory
896691Stjones1@inf.ed.ac.uk    objFile->loadSections(initVirtMem);
906691Stjones1@inf.ed.ac.uk
916691Stjones1@inf.ed.ac.uk    //Setup the auxilliary vectors. These will already have endian conversion.
926691Stjones1@inf.ed.ac.uk    //Auxilliary vectors are loaded only for elf formatted executables.
936691Stjones1@inf.ed.ac.uk    ElfObject * elfObject = dynamic_cast<ElfObject *>(objFile);
946691Stjones1@inf.ed.ac.uk    if (elfObject) {
956691Stjones1@inf.ed.ac.uk        uint32_t features = 0;
966691Stjones1@inf.ed.ac.uk
976691Stjones1@inf.ed.ac.uk        //Bits which describe the system hardware capabilities
986691Stjones1@inf.ed.ac.uk        //XXX Figure out what these should be
996691Stjones1@inf.ed.ac.uk        auxv.push_back(auxv_t(M5_AT_HWCAP, features));
1006691Stjones1@inf.ed.ac.uk        //The system page size
1016691Stjones1@inf.ed.ac.uk        auxv.push_back(auxv_t(M5_AT_PAGESZ, PowerISA::VMPageSize));
1026691Stjones1@inf.ed.ac.uk        //Frequency at which times() increments
1036691Stjones1@inf.ed.ac.uk        auxv.push_back(auxv_t(M5_AT_CLKTCK, 0x64));
1046691Stjones1@inf.ed.ac.uk        // For statically linked executables, this is the virtual address of the
1056691Stjones1@inf.ed.ac.uk        // program header tables if they appear in the executable image
1066691Stjones1@inf.ed.ac.uk        auxv.push_back(auxv_t(M5_AT_PHDR, elfObject->programHeaderTable()));
1076691Stjones1@inf.ed.ac.uk        // This is the size of a program header entry from the elf file.
1086691Stjones1@inf.ed.ac.uk        auxv.push_back(auxv_t(M5_AT_PHENT, elfObject->programHeaderSize()));
1096691Stjones1@inf.ed.ac.uk        // This is the number of program headers from the original elf file.
1106691Stjones1@inf.ed.ac.uk        auxv.push_back(auxv_t(M5_AT_PHNUM, elfObject->programHeaderCount()));
1116691Stjones1@inf.ed.ac.uk        //This is the address of the elf "interpreter", It should be set
1126691Stjones1@inf.ed.ac.uk        //to 0 for regular executables. It should be something else
1136691Stjones1@inf.ed.ac.uk        //(not sure what) for dynamic libraries.
1146691Stjones1@inf.ed.ac.uk        auxv.push_back(auxv_t(M5_AT_BASE, 0));
1156691Stjones1@inf.ed.ac.uk
1166691Stjones1@inf.ed.ac.uk        //XXX Figure out what this should be.
1176691Stjones1@inf.ed.ac.uk        auxv.push_back(auxv_t(M5_AT_FLAGS, 0));
1186691Stjones1@inf.ed.ac.uk        //The entry point to the program
1196691Stjones1@inf.ed.ac.uk        auxv.push_back(auxv_t(M5_AT_ENTRY, objFile->entryPoint()));
1206691Stjones1@inf.ed.ac.uk        //Different user and group IDs
1216691Stjones1@inf.ed.ac.uk        auxv.push_back(auxv_t(M5_AT_UID, uid()));
1226691Stjones1@inf.ed.ac.uk        auxv.push_back(auxv_t(M5_AT_EUID, euid()));
1236691Stjones1@inf.ed.ac.uk        auxv.push_back(auxv_t(M5_AT_GID, gid()));
1246691Stjones1@inf.ed.ac.uk        auxv.push_back(auxv_t(M5_AT_EGID, egid()));
1256691Stjones1@inf.ed.ac.uk        //Whether to enable "secure mode" in the executable
1266691Stjones1@inf.ed.ac.uk        auxv.push_back(auxv_t(M5_AT_SECURE, 0));
1276691Stjones1@inf.ed.ac.uk        //The filename of the program
1286691Stjones1@inf.ed.ac.uk        auxv.push_back(auxv_t(M5_AT_EXECFN, 0));
1296691Stjones1@inf.ed.ac.uk        //The string "v51" with unknown meaning
1306691Stjones1@inf.ed.ac.uk        auxv.push_back(auxv_t(M5_AT_PLATFORM, 0));
1316691Stjones1@inf.ed.ac.uk    }
1326691Stjones1@inf.ed.ac.uk
1336691Stjones1@inf.ed.ac.uk    //Figure out how big the initial stack nedes to be
1346691Stjones1@inf.ed.ac.uk
1356691Stjones1@inf.ed.ac.uk    // A sentry NULL void pointer at the top of the stack.
1366691Stjones1@inf.ed.ac.uk    int sentry_size = intSize;
1376691Stjones1@inf.ed.ac.uk
1386691Stjones1@inf.ed.ac.uk    string platform = "v51";
1396691Stjones1@inf.ed.ac.uk    int platform_size = platform.size() + 1;
1406691Stjones1@inf.ed.ac.uk
1416691Stjones1@inf.ed.ac.uk    // The aux vectors are put on the stack in two groups. The first group are
1426691Stjones1@inf.ed.ac.uk    // the vectors that are generated as the elf is loaded. The second group
1436691Stjones1@inf.ed.ac.uk    // are the ones that were computed ahead of time and include the platform
1446691Stjones1@inf.ed.ac.uk    // string.
1456691Stjones1@inf.ed.ac.uk    int aux_data_size = filename.size() + 1;
1466691Stjones1@inf.ed.ac.uk
1476691Stjones1@inf.ed.ac.uk    int env_data_size = 0;
1486691Stjones1@inf.ed.ac.uk    for (int i = 0; i < envp.size(); ++i) {
1496691Stjones1@inf.ed.ac.uk        env_data_size += envp[i].size() + 1;
1506691Stjones1@inf.ed.ac.uk    }
1516691Stjones1@inf.ed.ac.uk    int arg_data_size = 0;
1526691Stjones1@inf.ed.ac.uk    for (int i = 0; i < argv.size(); ++i) {
1536691Stjones1@inf.ed.ac.uk        arg_data_size += argv[i].size() + 1;
1546691Stjones1@inf.ed.ac.uk    }
1556691Stjones1@inf.ed.ac.uk
1566691Stjones1@inf.ed.ac.uk    int info_block_size =
1576691Stjones1@inf.ed.ac.uk        sentry_size + env_data_size + arg_data_size +
1586691Stjones1@inf.ed.ac.uk        aux_data_size + platform_size;
1596691Stjones1@inf.ed.ac.uk
1606691Stjones1@inf.ed.ac.uk    //Each auxilliary vector is two 4 byte words
1616691Stjones1@inf.ed.ac.uk    int aux_array_size = intSize * 2 * (auxv.size() + 1);
1626691Stjones1@inf.ed.ac.uk
1636691Stjones1@inf.ed.ac.uk    int envp_array_size = intSize * (envp.size() + 1);
1646691Stjones1@inf.ed.ac.uk    int argv_array_size = intSize * (argv.size() + 1);
1656691Stjones1@inf.ed.ac.uk
1666691Stjones1@inf.ed.ac.uk    int argc_size = intSize;
1676691Stjones1@inf.ed.ac.uk
1686691Stjones1@inf.ed.ac.uk    //Figure out the size of the contents of the actual initial frame
1696691Stjones1@inf.ed.ac.uk    int frame_size =
1706691Stjones1@inf.ed.ac.uk        info_block_size +
1716691Stjones1@inf.ed.ac.uk        aux_array_size +
1726691Stjones1@inf.ed.ac.uk        envp_array_size +
1736691Stjones1@inf.ed.ac.uk        argv_array_size +
1746691Stjones1@inf.ed.ac.uk        argc_size;
1756691Stjones1@inf.ed.ac.uk
1766691Stjones1@inf.ed.ac.uk    //There needs to be padding after the auxiliary vector data so that the
1776691Stjones1@inf.ed.ac.uk    //very bottom of the stack is aligned properly.
1786691Stjones1@inf.ed.ac.uk    int partial_size = frame_size;
1796691Stjones1@inf.ed.ac.uk    int aligned_partial_size = roundUp(partial_size, align);
1806691Stjones1@inf.ed.ac.uk    int aux_padding = aligned_partial_size - partial_size;
1816691Stjones1@inf.ed.ac.uk
1826691Stjones1@inf.ed.ac.uk    int space_needed = frame_size + aux_padding;
1836691Stjones1@inf.ed.ac.uk
1846691Stjones1@inf.ed.ac.uk    stack_min = stack_base - space_needed;
1856691Stjones1@inf.ed.ac.uk    stack_min = roundDown(stack_min, align);
1866691Stjones1@inf.ed.ac.uk    stack_size = stack_base - stack_min;
1876691Stjones1@inf.ed.ac.uk
1886691Stjones1@inf.ed.ac.uk    // map memory
1896691Stjones1@inf.ed.ac.uk    pTable->allocate(roundDown(stack_min, pageSize),
1906691Stjones1@inf.ed.ac.uk                     roundUp(stack_size, pageSize));
1916691Stjones1@inf.ed.ac.uk
1926691Stjones1@inf.ed.ac.uk    // map out initial stack contents
1936691Stjones1@inf.ed.ac.uk    uint32_t sentry_base = stack_base - sentry_size;
1946691Stjones1@inf.ed.ac.uk    uint32_t aux_data_base = sentry_base - aux_data_size;
1956691Stjones1@inf.ed.ac.uk    uint32_t env_data_base = aux_data_base - env_data_size;
1966691Stjones1@inf.ed.ac.uk    uint32_t arg_data_base = env_data_base - arg_data_size;
1976691Stjones1@inf.ed.ac.uk    uint32_t platform_base = arg_data_base - platform_size;
1986691Stjones1@inf.ed.ac.uk    uint32_t auxv_array_base = platform_base - aux_array_size - aux_padding;
1996691Stjones1@inf.ed.ac.uk    uint32_t envp_array_base = auxv_array_base - envp_array_size;
2006691Stjones1@inf.ed.ac.uk    uint32_t argv_array_base = envp_array_base - argv_array_size;
2016691Stjones1@inf.ed.ac.uk    uint32_t argc_base = argv_array_base - argc_size;
2026691Stjones1@inf.ed.ac.uk
2036691Stjones1@inf.ed.ac.uk    DPRINTF(Stack, "The addresses of items on the initial stack:\n");
2046691Stjones1@inf.ed.ac.uk    DPRINTF(Stack, "0x%x - aux data\n", aux_data_base);
2056691Stjones1@inf.ed.ac.uk    DPRINTF(Stack, "0x%x - env data\n", env_data_base);
2066691Stjones1@inf.ed.ac.uk    DPRINTF(Stack, "0x%x - arg data\n", arg_data_base);
2076691Stjones1@inf.ed.ac.uk    DPRINTF(Stack, "0x%x - platform base\n", platform_base);
2086691Stjones1@inf.ed.ac.uk    DPRINTF(Stack, "0x%x - auxv array\n", auxv_array_base);
2096691Stjones1@inf.ed.ac.uk    DPRINTF(Stack, "0x%x - envp array\n", envp_array_base);
2106691Stjones1@inf.ed.ac.uk    DPRINTF(Stack, "0x%x - argv array\n", argv_array_base);
2116691Stjones1@inf.ed.ac.uk    DPRINTF(Stack, "0x%x - argc \n", argc_base);
2126691Stjones1@inf.ed.ac.uk    DPRINTF(Stack, "0x%x - stack min\n", stack_min);
2136691Stjones1@inf.ed.ac.uk
2146691Stjones1@inf.ed.ac.uk    // write contents to stack
2156691Stjones1@inf.ed.ac.uk
2166691Stjones1@inf.ed.ac.uk    // figure out argc
2176691Stjones1@inf.ed.ac.uk    uint32_t argc = argv.size();
2186691Stjones1@inf.ed.ac.uk    uint32_t guestArgc = PowerISA::htog(argc);
2196691Stjones1@inf.ed.ac.uk
2206691Stjones1@inf.ed.ac.uk    //Write out the sentry void *
2216691Stjones1@inf.ed.ac.uk    uint32_t sentry_NULL = 0;
2226691Stjones1@inf.ed.ac.uk    initVirtMem->writeBlob(sentry_base,
2236691Stjones1@inf.ed.ac.uk            (uint8_t*)&sentry_NULL, sentry_size);
2246691Stjones1@inf.ed.ac.uk
2256691Stjones1@inf.ed.ac.uk    //Fix up the aux vectors which point to other data
2266691Stjones1@inf.ed.ac.uk    for (int i = auxv.size() - 1; i >= 0; i--) {
2276691Stjones1@inf.ed.ac.uk        if (auxv[i].a_type == M5_AT_PLATFORM) {
2286691Stjones1@inf.ed.ac.uk            auxv[i].a_val = platform_base;
2296691Stjones1@inf.ed.ac.uk            initVirtMem->writeString(platform_base, platform.c_str());
2306691Stjones1@inf.ed.ac.uk        } else if (auxv[i].a_type == M5_AT_EXECFN) {
2316691Stjones1@inf.ed.ac.uk            auxv[i].a_val = aux_data_base;
2326691Stjones1@inf.ed.ac.uk            initVirtMem->writeString(aux_data_base, filename.c_str());
2336691Stjones1@inf.ed.ac.uk        }
2346691Stjones1@inf.ed.ac.uk    }
2356691Stjones1@inf.ed.ac.uk
2366691Stjones1@inf.ed.ac.uk    //Copy the aux stuff
2376691Stjones1@inf.ed.ac.uk    for (int x = 0; x < auxv.size(); x++)
2386691Stjones1@inf.ed.ac.uk    {
2396691Stjones1@inf.ed.ac.uk        initVirtMem->writeBlob(auxv_array_base + x * 2 * intSize,
2406691Stjones1@inf.ed.ac.uk                (uint8_t*)&(auxv[x].a_type), intSize);
2416691Stjones1@inf.ed.ac.uk        initVirtMem->writeBlob(auxv_array_base + (x * 2 + 1) * intSize,
2426691Stjones1@inf.ed.ac.uk                (uint8_t*)&(auxv[x].a_val), intSize);
2436691Stjones1@inf.ed.ac.uk    }
2446691Stjones1@inf.ed.ac.uk    //Write out the terminating zeroed auxilliary vector
2456691Stjones1@inf.ed.ac.uk    const uint64_t zero = 0;
2466691Stjones1@inf.ed.ac.uk    initVirtMem->writeBlob(auxv_array_base + 2 * intSize * auxv.size(),
2476691Stjones1@inf.ed.ac.uk            (uint8_t*)&zero, 2 * intSize);
2486691Stjones1@inf.ed.ac.uk
2496691Stjones1@inf.ed.ac.uk    copyStringArray(envp, envp_array_base, env_data_base, initVirtMem);
2506691Stjones1@inf.ed.ac.uk    copyStringArray(argv, argv_array_base, arg_data_base, initVirtMem);
2516691Stjones1@inf.ed.ac.uk
2526691Stjones1@inf.ed.ac.uk    initVirtMem->writeBlob(argc_base, (uint8_t*)&guestArgc, intSize);
2536691Stjones1@inf.ed.ac.uk
2546691Stjones1@inf.ed.ac.uk    ThreadContext *tc = system->getThreadContext(contextIds[0]);
2556691Stjones1@inf.ed.ac.uk
2566691Stjones1@inf.ed.ac.uk    //Set the stack pointer register
2576691Stjones1@inf.ed.ac.uk    tc->setIntReg(StackPointerReg, stack_min);
2586691Stjones1@inf.ed.ac.uk
2597720Sgblack@eecs.umich.edu    tc->pcState(objFile->entryPoint());
2606691Stjones1@inf.ed.ac.uk
2616691Stjones1@inf.ed.ac.uk    //Align the "stack_min" to a page boundary.
2626691Stjones1@inf.ed.ac.uk    stack_min = roundDown(stack_min, pageSize);
2636691Stjones1@inf.ed.ac.uk}
2646691Stjones1@inf.ed.ac.uk
2656691Stjones1@inf.ed.ac.ukPowerISA::IntReg
2666701Sgblack@eecs.umich.eduPowerLiveProcess::getSyscallArg(ThreadContext *tc, int &i)
2676691Stjones1@inf.ed.ac.uk{
2686691Stjones1@inf.ed.ac.uk    assert(i < 5);
2696701Sgblack@eecs.umich.edu    return tc->readIntReg(ArgumentReg0 + i++);
2706691Stjones1@inf.ed.ac.uk}
2716691Stjones1@inf.ed.ac.uk
2726691Stjones1@inf.ed.ac.ukvoid
2736691Stjones1@inf.ed.ac.ukPowerLiveProcess::setSyscallArg(ThreadContext *tc,
2746691Stjones1@inf.ed.ac.uk        int i, PowerISA::IntReg val)
2756691Stjones1@inf.ed.ac.uk{
2766691Stjones1@inf.ed.ac.uk    assert(i < 5);
2776691Stjones1@inf.ed.ac.uk    tc->setIntReg(ArgumentReg0 + i, val);
2786691Stjones1@inf.ed.ac.uk}
2796691Stjones1@inf.ed.ac.uk
2806691Stjones1@inf.ed.ac.ukvoid
2816691Stjones1@inf.ed.ac.ukPowerLiveProcess::setSyscallReturn(ThreadContext *tc,
2826691Stjones1@inf.ed.ac.uk        SyscallReturn return_value)
2836691Stjones1@inf.ed.ac.uk{
2847512Stjones1@inf.ed.ac.uk    Cr cr = tc->readIntReg(INTREG_CR);
2857512Stjones1@inf.ed.ac.uk    if (return_value.successful()) {
2867512Stjones1@inf.ed.ac.uk        cr.cr0.so = 0;
2877512Stjones1@inf.ed.ac.uk    } else {
2887512Stjones1@inf.ed.ac.uk        cr.cr0.so = 1;
2897512Stjones1@inf.ed.ac.uk    }
2907512Stjones1@inf.ed.ac.uk    tc->setIntReg(INTREG_CR, cr);
2916691Stjones1@inf.ed.ac.uk    tc->setIntReg(ReturnValueReg, return_value.value());
2926691Stjones1@inf.ed.ac.uk}
293