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
3311793Sbrandon.potter@amd.com#include "arch/power/process.hh"
3411793Sbrandon.potter@amd.com
356691Stjones1@inf.ed.ac.uk#include "arch/power/isa_traits.hh"
366691Stjones1@inf.ed.ac.uk#include "arch/power/types.hh"
376691Stjones1@inf.ed.ac.uk#include "base/loader/elf_object.hh"
386691Stjones1@inf.ed.ac.uk#include "base/loader/object_file.hh"
3912334Sgabeblack@google.com#include "base/logging.hh"
406691Stjones1@inf.ed.ac.uk#include "cpu/thread_context.hh"
418232Snate@binkert.org#include "debug/Stack.hh"
426691Stjones1@inf.ed.ac.uk#include "mem/page_table.hh"
4312431Sgabeblack@google.com#include "params/Process.hh"
4411854Sbrandon.potter@amd.com#include "sim/aux_vector.hh"
456691Stjones1@inf.ed.ac.uk#include "sim/process_impl.hh"
4611800Sbrandon.potter@amd.com#include "sim/syscall_return.hh"
476691Stjones1@inf.ed.ac.uk#include "sim/system.hh"
486691Stjones1@inf.ed.ac.uk
496691Stjones1@inf.ed.ac.ukusing namespace std;
506691Stjones1@inf.ed.ac.ukusing namespace PowerISA;
516691Stjones1@inf.ed.ac.uk
5211851Sbrandon.potter@amd.comPowerProcess::PowerProcess(ProcessParams *params, ObjectFile *objFile)
5312448Sgabeblack@google.com    : Process(params,
5412448Sgabeblack@google.com              new EmulationPageTable(params->name, params->pid, PageBytes),
5512432Sgabeblack@google.com              objFile)
566691Stjones1@inf.ed.ac.uk{
5712441Sgabeblack@google.com    fatal_if(params->useArchPT, "Arch page tables not implemented.");
5811905SBrandon.Potter@amd.com    // Set up break point (Top of Heap)
5911905SBrandon.Potter@amd.com    Addr brk_point = objFile->dataBase() + objFile->dataSize() +
6011905SBrandon.Potter@amd.com                     objFile->bssSize();
6111905SBrandon.Potter@amd.com    brk_point = roundUp(brk_point, PageBytes);
6211905SBrandon.Potter@amd.com
6311905SBrandon.Potter@amd.com    Addr stack_base = 0xbf000000L;
6411905SBrandon.Potter@amd.com
6511905SBrandon.Potter@amd.com    Addr max_stack_size = 8 * 1024 * 1024;
666691Stjones1@inf.ed.ac.uk
676691Stjones1@inf.ed.ac.uk    // Set pointer for next thread stack.  Reserve 8M for main stack.
6811905SBrandon.Potter@amd.com    Addr next_thread_stack_base = stack_base - max_stack_size;
696691Stjones1@inf.ed.ac.uk
706691Stjones1@inf.ed.ac.uk    // Set up region for mmaps. For now, start at bottom of kuseg space.
7111905SBrandon.Potter@amd.com    Addr mmap_end = 0x70000000L;
7211905SBrandon.Potter@amd.com
7311905SBrandon.Potter@amd.com    memState = make_shared<MemState>(brk_point, stack_base, max_stack_size,
7411905SBrandon.Potter@amd.com                                     next_thread_stack_base, mmap_end);
756691Stjones1@inf.ed.ac.uk}
766691Stjones1@inf.ed.ac.uk
776691Stjones1@inf.ed.ac.ukvoid
7811851Sbrandon.potter@amd.comPowerProcess::initState()
796691Stjones1@inf.ed.ac.uk{
807532Ssteve.reinhardt@amd.com    Process::initState();
817532Ssteve.reinhardt@amd.com
8210318Sandreas.hansson@arm.com    argsInit(MachineBytes, PageBytes);
836691Stjones1@inf.ed.ac.uk}
846691Stjones1@inf.ed.ac.uk
856691Stjones1@inf.ed.ac.ukvoid
8611851Sbrandon.potter@amd.comPowerProcess::argsInit(int intSize, int pageSize)
876691Stjones1@inf.ed.ac.uk{
8813894Sgabeblack@google.com    std::vector<AuxVector<uint32_t>> auxv;
896691Stjones1@inf.ed.ac.uk
906691Stjones1@inf.ed.ac.uk    string filename;
916691Stjones1@inf.ed.ac.uk    if (argv.size() < 1)
926691Stjones1@inf.ed.ac.uk        filename = "";
936691Stjones1@inf.ed.ac.uk    else
946691Stjones1@inf.ed.ac.uk        filename = argv[0];
956691Stjones1@inf.ed.ac.uk
966691Stjones1@inf.ed.ac.uk    //We want 16 byte alignment
976691Stjones1@inf.ed.ac.uk    uint64_t align = 16;
986691Stjones1@inf.ed.ac.uk
9911389Sbrandon.potter@amd.com    // Patch the ld_bias for dynamic executables.
10011389Sbrandon.potter@amd.com    updateBias();
10111389Sbrandon.potter@amd.com
1026691Stjones1@inf.ed.ac.uk    // load object file into target memory
1036691Stjones1@inf.ed.ac.uk    objFile->loadSections(initVirtMem);
1046691Stjones1@inf.ed.ac.uk
1056691Stjones1@inf.ed.ac.uk    //Setup the auxilliary vectors. These will already have endian conversion.
1066691Stjones1@inf.ed.ac.uk    //Auxilliary vectors are loaded only for elf formatted executables.
1076691Stjones1@inf.ed.ac.uk    ElfObject * elfObject = dynamic_cast<ElfObject *>(objFile);
1086691Stjones1@inf.ed.ac.uk    if (elfObject) {
1096691Stjones1@inf.ed.ac.uk        uint32_t features = 0;
1106691Stjones1@inf.ed.ac.uk
1116691Stjones1@inf.ed.ac.uk        //Bits which describe the system hardware capabilities
1126691Stjones1@inf.ed.ac.uk        //XXX Figure out what these should be
11313894Sgabeblack@google.com        auxv.emplace_back(M5_AT_HWCAP, features);
1146691Stjones1@inf.ed.ac.uk        //The system page size
11513894Sgabeblack@google.com        auxv.emplace_back(M5_AT_PAGESZ, PowerISA::PageBytes);
1166691Stjones1@inf.ed.ac.uk        //Frequency at which times() increments
11713894Sgabeblack@google.com        auxv.emplace_back(M5_AT_CLKTCK, 0x64);
11813894Sgabeblack@google.com        // For statically linked executables, this is the virtual address of
11913894Sgabeblack@google.com        // the program header tables if they appear in the executable image
12013894Sgabeblack@google.com        auxv.emplace_back(M5_AT_PHDR, elfObject->programHeaderTable());
1216691Stjones1@inf.ed.ac.uk        // This is the size of a program header entry from the elf file.
12213894Sgabeblack@google.com        auxv.emplace_back(M5_AT_PHENT, elfObject->programHeaderSize());
1236691Stjones1@inf.ed.ac.uk        // This is the number of program headers from the original elf file.
12413894Sgabeblack@google.com        auxv.emplace_back(M5_AT_PHNUM, elfObject->programHeaderCount());
12511389Sbrandon.potter@amd.com        // This is the base address of the ELF interpreter; it should be
12611389Sbrandon.potter@amd.com        // zero for static executables or contain the base address for
12711389Sbrandon.potter@amd.com        // dynamic executables.
12813894Sgabeblack@google.com        auxv.emplace_back(M5_AT_BASE, getBias());
1296691Stjones1@inf.ed.ac.uk        //XXX Figure out what this should be.
13013894Sgabeblack@google.com        auxv.emplace_back(M5_AT_FLAGS, 0);
1316691Stjones1@inf.ed.ac.uk        //The entry point to the program
13213894Sgabeblack@google.com        auxv.emplace_back(M5_AT_ENTRY, objFile->entryPoint());
1336691Stjones1@inf.ed.ac.uk        //Different user and group IDs
13413894Sgabeblack@google.com        auxv.emplace_back(M5_AT_UID, uid());
13513894Sgabeblack@google.com        auxv.emplace_back(M5_AT_EUID, euid());
13613894Sgabeblack@google.com        auxv.emplace_back(M5_AT_GID, gid());
13713894Sgabeblack@google.com        auxv.emplace_back(M5_AT_EGID, egid());
1386691Stjones1@inf.ed.ac.uk        //Whether to enable "secure mode" in the executable
13913894Sgabeblack@google.com        auxv.emplace_back(M5_AT_SECURE, 0);
1406691Stjones1@inf.ed.ac.uk        //The filename of the program
14113894Sgabeblack@google.com        auxv.emplace_back(M5_AT_EXECFN, 0);
1426691Stjones1@inf.ed.ac.uk        //The string "v51" with unknown meaning
14313894Sgabeblack@google.com        auxv.emplace_back(M5_AT_PLATFORM, 0);
1446691Stjones1@inf.ed.ac.uk    }
1456691Stjones1@inf.ed.ac.uk
1466691Stjones1@inf.ed.ac.uk    //Figure out how big the initial stack nedes to be
1476691Stjones1@inf.ed.ac.uk
1486691Stjones1@inf.ed.ac.uk    // A sentry NULL void pointer at the top of the stack.
1496691Stjones1@inf.ed.ac.uk    int sentry_size = intSize;
1506691Stjones1@inf.ed.ac.uk
1516691Stjones1@inf.ed.ac.uk    string platform = "v51";
1526691Stjones1@inf.ed.ac.uk    int platform_size = platform.size() + 1;
1536691Stjones1@inf.ed.ac.uk
1546691Stjones1@inf.ed.ac.uk    // The aux vectors are put on the stack in two groups. The first group are
1556691Stjones1@inf.ed.ac.uk    // the vectors that are generated as the elf is loaded. The second group
1566691Stjones1@inf.ed.ac.uk    // are the ones that were computed ahead of time and include the platform
1576691Stjones1@inf.ed.ac.uk    // string.
1586691Stjones1@inf.ed.ac.uk    int aux_data_size = filename.size() + 1;
1596691Stjones1@inf.ed.ac.uk
1606691Stjones1@inf.ed.ac.uk    int env_data_size = 0;
1616691Stjones1@inf.ed.ac.uk    for (int i = 0; i < envp.size(); ++i) {
1626691Stjones1@inf.ed.ac.uk        env_data_size += envp[i].size() + 1;
1636691Stjones1@inf.ed.ac.uk    }
1646691Stjones1@inf.ed.ac.uk    int arg_data_size = 0;
1656691Stjones1@inf.ed.ac.uk    for (int i = 0; i < argv.size(); ++i) {
1666691Stjones1@inf.ed.ac.uk        arg_data_size += argv[i].size() + 1;
1676691Stjones1@inf.ed.ac.uk    }
1686691Stjones1@inf.ed.ac.uk
1696691Stjones1@inf.ed.ac.uk    int info_block_size =
1706691Stjones1@inf.ed.ac.uk        sentry_size + env_data_size + arg_data_size +
1716691Stjones1@inf.ed.ac.uk        aux_data_size + platform_size;
1726691Stjones1@inf.ed.ac.uk
1736691Stjones1@inf.ed.ac.uk    //Each auxilliary vector is two 4 byte words
1746691Stjones1@inf.ed.ac.uk    int aux_array_size = intSize * 2 * (auxv.size() + 1);
1756691Stjones1@inf.ed.ac.uk
1766691Stjones1@inf.ed.ac.uk    int envp_array_size = intSize * (envp.size() + 1);
1776691Stjones1@inf.ed.ac.uk    int argv_array_size = intSize * (argv.size() + 1);
1786691Stjones1@inf.ed.ac.uk
1796691Stjones1@inf.ed.ac.uk    int argc_size = intSize;
1806691Stjones1@inf.ed.ac.uk
1816691Stjones1@inf.ed.ac.uk    //Figure out the size of the contents of the actual initial frame
1826691Stjones1@inf.ed.ac.uk    int frame_size =
1836691Stjones1@inf.ed.ac.uk        info_block_size +
1846691Stjones1@inf.ed.ac.uk        aux_array_size +
1856691Stjones1@inf.ed.ac.uk        envp_array_size +
1866691Stjones1@inf.ed.ac.uk        argv_array_size +
1876691Stjones1@inf.ed.ac.uk        argc_size;
1886691Stjones1@inf.ed.ac.uk
1896691Stjones1@inf.ed.ac.uk    //There needs to be padding after the auxiliary vector data so that the
1906691Stjones1@inf.ed.ac.uk    //very bottom of the stack is aligned properly.
1916691Stjones1@inf.ed.ac.uk    int partial_size = frame_size;
1926691Stjones1@inf.ed.ac.uk    int aligned_partial_size = roundUp(partial_size, align);
1936691Stjones1@inf.ed.ac.uk    int aux_padding = aligned_partial_size - partial_size;
1946691Stjones1@inf.ed.ac.uk
1956691Stjones1@inf.ed.ac.uk    int space_needed = frame_size + aux_padding;
1966691Stjones1@inf.ed.ac.uk
19711905SBrandon.Potter@amd.com    Addr stack_min = memState->getStackBase() - space_needed;
19811905SBrandon.Potter@amd.com    stack_min = roundDown(stack_min, align);
19911905SBrandon.Potter@amd.com
20011905SBrandon.Potter@amd.com    memState->setStackSize(memState->getStackBase() - stack_min);
2016691Stjones1@inf.ed.ac.uk
2026691Stjones1@inf.ed.ac.uk    // map memory
20311905SBrandon.Potter@amd.com    allocateMem(roundDown(stack_min, pageSize),
20411905SBrandon.Potter@amd.com                roundUp(memState->getStackSize(), pageSize));
2056691Stjones1@inf.ed.ac.uk
2066691Stjones1@inf.ed.ac.uk    // map out initial stack contents
20711905SBrandon.Potter@amd.com    uint32_t sentry_base = memState->getStackBase() - sentry_size;
2086691Stjones1@inf.ed.ac.uk    uint32_t aux_data_base = sentry_base - aux_data_size;
2096691Stjones1@inf.ed.ac.uk    uint32_t env_data_base = aux_data_base - env_data_size;
2106691Stjones1@inf.ed.ac.uk    uint32_t arg_data_base = env_data_base - arg_data_size;
2116691Stjones1@inf.ed.ac.uk    uint32_t platform_base = arg_data_base - platform_size;
2126691Stjones1@inf.ed.ac.uk    uint32_t auxv_array_base = platform_base - aux_array_size - aux_padding;
2136691Stjones1@inf.ed.ac.uk    uint32_t envp_array_base = auxv_array_base - envp_array_size;
2146691Stjones1@inf.ed.ac.uk    uint32_t argv_array_base = envp_array_base - argv_array_size;
2156691Stjones1@inf.ed.ac.uk    uint32_t argc_base = argv_array_base - argc_size;
2166691Stjones1@inf.ed.ac.uk
2176691Stjones1@inf.ed.ac.uk    DPRINTF(Stack, "The addresses of items on the initial stack:\n");
2186691Stjones1@inf.ed.ac.uk    DPRINTF(Stack, "0x%x - aux data\n", aux_data_base);
2196691Stjones1@inf.ed.ac.uk    DPRINTF(Stack, "0x%x - env data\n", env_data_base);
2206691Stjones1@inf.ed.ac.uk    DPRINTF(Stack, "0x%x - arg data\n", arg_data_base);
2216691Stjones1@inf.ed.ac.uk    DPRINTF(Stack, "0x%x - platform base\n", platform_base);
2226691Stjones1@inf.ed.ac.uk    DPRINTF(Stack, "0x%x - auxv array\n", auxv_array_base);
2236691Stjones1@inf.ed.ac.uk    DPRINTF(Stack, "0x%x - envp array\n", envp_array_base);
2246691Stjones1@inf.ed.ac.uk    DPRINTF(Stack, "0x%x - argv array\n", argv_array_base);
2256691Stjones1@inf.ed.ac.uk    DPRINTF(Stack, "0x%x - argc \n", argc_base);
22611905SBrandon.Potter@amd.com    DPRINTF(Stack, "0x%x - stack min\n", stack_min);
2276691Stjones1@inf.ed.ac.uk
2286691Stjones1@inf.ed.ac.uk    // write contents to stack
2296691Stjones1@inf.ed.ac.uk
2306691Stjones1@inf.ed.ac.uk    // figure out argc
2316691Stjones1@inf.ed.ac.uk    uint32_t argc = argv.size();
2326691Stjones1@inf.ed.ac.uk    uint32_t guestArgc = PowerISA::htog(argc);
2336691Stjones1@inf.ed.ac.uk
2346691Stjones1@inf.ed.ac.uk    //Write out the sentry void *
2356691Stjones1@inf.ed.ac.uk    uint32_t sentry_NULL = 0;
23614010Sgabeblack@google.com    initVirtMem.writeBlob(sentry_base, &sentry_NULL, sentry_size);
2376691Stjones1@inf.ed.ac.uk
2386691Stjones1@inf.ed.ac.uk    //Fix up the aux vectors which point to other data
2396691Stjones1@inf.ed.ac.uk    for (int i = auxv.size() - 1; i >= 0; i--) {
24013894Sgabeblack@google.com        if (auxv[i].type == M5_AT_PLATFORM) {
24113894Sgabeblack@google.com            auxv[i].val = platform_base;
2428852Sandreas.hansson@arm.com            initVirtMem.writeString(platform_base, platform.c_str());
24313894Sgabeblack@google.com        } else if (auxv[i].type == M5_AT_EXECFN) {
24413894Sgabeblack@google.com            auxv[i].val = aux_data_base;
2458852Sandreas.hansson@arm.com            initVirtMem.writeString(aux_data_base, filename.c_str());
2466691Stjones1@inf.ed.ac.uk        }
2476691Stjones1@inf.ed.ac.uk    }
2486691Stjones1@inf.ed.ac.uk
2496691Stjones1@inf.ed.ac.uk    //Copy the aux stuff
25013894Sgabeblack@google.com    Addr auxv_array_end = auxv_array_base;
25113894Sgabeblack@google.com    for (const auto &aux: auxv) {
25213894Sgabeblack@google.com        initVirtMem.write(auxv_array_end, aux, GuestByteOrder);
25313894Sgabeblack@google.com        auxv_array_end += sizeof(aux);
2546691Stjones1@inf.ed.ac.uk    }
2556691Stjones1@inf.ed.ac.uk    //Write out the terminating zeroed auxilliary vector
25613894Sgabeblack@google.com    const AuxVector<uint64_t> zero(0, 0);
25713894Sgabeblack@google.com    initVirtMem.write(auxv_array_end, zero);
25813894Sgabeblack@google.com    auxv_array_end += sizeof(zero);
2596691Stjones1@inf.ed.ac.uk
2606691Stjones1@inf.ed.ac.uk    copyStringArray(envp, envp_array_base, env_data_base, initVirtMem);
2616691Stjones1@inf.ed.ac.uk    copyStringArray(argv, argv_array_base, arg_data_base, initVirtMem);
2626691Stjones1@inf.ed.ac.uk
26314010Sgabeblack@google.com    initVirtMem.writeBlob(argc_base, &guestArgc, intSize);
2646691Stjones1@inf.ed.ac.uk
2656691Stjones1@inf.ed.ac.uk    ThreadContext *tc = system->getThreadContext(contextIds[0]);
2666691Stjones1@inf.ed.ac.uk
2676691Stjones1@inf.ed.ac.uk    //Set the stack pointer register
26811905SBrandon.Potter@amd.com    tc->setIntReg(StackPointerReg, stack_min);
2696691Stjones1@inf.ed.ac.uk
27011389Sbrandon.potter@amd.com    tc->pcState(getStartPC());
2716691Stjones1@inf.ed.ac.uk
2726691Stjones1@inf.ed.ac.uk    //Align the "stack_min" to a page boundary.
27311905SBrandon.Potter@amd.com    memState->setStackMin(roundDown(stack_min, pageSize));
2746691Stjones1@inf.ed.ac.uk}
2756691Stjones1@inf.ed.ac.uk
27613617Sgabeblack@google.comRegVal
27711851Sbrandon.potter@amd.comPowerProcess::getSyscallArg(ThreadContext *tc, int &i)
2786691Stjones1@inf.ed.ac.uk{
2796691Stjones1@inf.ed.ac.uk    assert(i < 5);
2806701Sgblack@eecs.umich.edu    return tc->readIntReg(ArgumentReg0 + i++);
2816691Stjones1@inf.ed.ac.uk}
2826691Stjones1@inf.ed.ac.uk
2836691Stjones1@inf.ed.ac.ukvoid
28413617Sgabeblack@google.comPowerProcess::setSyscallArg(ThreadContext *tc, int i, RegVal val)
2856691Stjones1@inf.ed.ac.uk{
2866691Stjones1@inf.ed.ac.uk    assert(i < 5);
2876691Stjones1@inf.ed.ac.uk    tc->setIntReg(ArgumentReg0 + i, val);
2886691Stjones1@inf.ed.ac.uk}
2896691Stjones1@inf.ed.ac.uk
2906691Stjones1@inf.ed.ac.ukvoid
29111851Sbrandon.potter@amd.comPowerProcess::setSyscallReturn(ThreadContext *tc, SyscallReturn sysret)
2926691Stjones1@inf.ed.ac.uk{
2937512Stjones1@inf.ed.ac.uk    Cr cr = tc->readIntReg(INTREG_CR);
29410223Ssteve.reinhardt@amd.com    if (sysret.successful()) {
2957512Stjones1@inf.ed.ac.uk        cr.cr0.so = 0;
2967512Stjones1@inf.ed.ac.uk    } else {
2977512Stjones1@inf.ed.ac.uk        cr.cr0.so = 1;
2987512Stjones1@inf.ed.ac.uk    }
2997512Stjones1@inf.ed.ac.uk    tc->setIntReg(INTREG_CR, cr);
30010223Ssteve.reinhardt@amd.com    tc->setIntReg(ReturnValueReg, sysret.encodedValue());
3016691Stjones1@inf.ed.ac.uk}
302