process.cc revision 11785
1/* 2 * Copyright (c) 2014 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 */ 45 46#include <fcntl.h> 47#include <unistd.h> 48 49#include <cstdio> 50#include <map> 51#include <string> 52 53#include "base/loader/object_file.hh" 54#include "base/loader/symtab.hh" 55#include "base/intmath.hh" 56#include "base/statistics.hh" 57#include "config/the_isa.hh" 58#include "cpu/thread_context.hh" 59#include "mem/page_table.hh" 60#include "mem/multi_level_page_table.hh" 61#include "mem/se_translating_port_proxy.hh" 62#include "params/LiveProcess.hh" 63#include "params/Process.hh" 64#include "sim/debug.hh" 65#include "sim/process.hh" 66#include "sim/process_impl.hh" 67#include "sim/stats.hh" 68#include "sim/syscall_emul.hh" 69#include "sim/system.hh" 70 71#if THE_ISA == ALPHA_ISA 72#include "arch/alpha/linux/process.hh" 73#elif THE_ISA == SPARC_ISA 74#include "arch/sparc/linux/process.hh" 75#include "arch/sparc/solaris/process.hh" 76#elif THE_ISA == MIPS_ISA 77#include "arch/mips/linux/process.hh" 78#elif THE_ISA == ARM_ISA 79#include "arch/arm/linux/process.hh" 80#include "arch/arm/freebsd/process.hh" 81#elif THE_ISA == X86_ISA 82#include "arch/x86/linux/process.hh" 83#elif THE_ISA == POWER_ISA 84#include "arch/power/linux/process.hh" 85#elif THE_ISA == RISCV_ISA 86#include "arch/riscv/linux/process.hh" 87#else 88#error "THE_ISA not set" 89#endif 90 91 92using namespace std; 93using namespace TheISA; 94 95// current number of allocated processes 96int num_processes = 0; 97 98template<class IntType> 99 100AuxVector<IntType>::AuxVector(IntType type, IntType val) 101{ 102 a_type = TheISA::htog(type); 103 a_val = TheISA::htog(val); 104} 105 106template struct AuxVector<uint32_t>; 107template struct AuxVector<uint64_t>; 108 109static int 110openFile(const string& filename, int flags, mode_t mode) 111{ 112 int sim_fd = open(filename.c_str(), flags, mode); 113 if (sim_fd != -1) 114 return sim_fd; 115 fatal("Unable to open %s with mode %O", filename, mode); 116} 117 118static int 119openInputFile(const string &filename) 120{ 121 return openFile(filename, O_RDONLY, 0); 122} 123 124static int 125openOutputFile(const string &filename) 126{ 127 return openFile(filename, O_WRONLY | O_CREAT | O_TRUNC, 0664); 128} 129 130Process::Process(ProcessParams * params) 131 : SimObject(params), system(params->system), 132 brk_point(0), stack_base(0), stack_size(0), stack_min(0), 133 max_stack_size(params->max_stack_size), 134 next_thread_stack_base(0), 135 M5_pid(system->allocatePID()), 136 useArchPT(params->useArchPT), 137 kvmInSE(params->kvmInSE), 138 pTable(useArchPT ? 139 static_cast<PageTableBase *>(new ArchPageTable(name(), M5_pid, system)) : 140 static_cast<PageTableBase *>(new FuncPageTable(name(), M5_pid)) ), 141 initVirtMem(system->getSystemPort(), this, 142 SETranslatingPortProxy::Always), 143 fd_array(make_shared<array<FDEntry, NUM_FDS>>()), 144 imap {{"", -1}, 145 {"cin", STDIN_FILENO}, 146 {"stdin", STDIN_FILENO}}, 147 oemap{{"", -1}, 148 {"cout", STDOUT_FILENO}, 149 {"stdout", STDOUT_FILENO}, 150 {"cerr", STDERR_FILENO}, 151 {"stderr", STDERR_FILENO}} 152{ 153 int sim_fd; 154 std::map<string,int>::iterator it; 155 156 // Search through the input options and set fd if match is found; 157 // otherwise, open an input file and seek to location. 158 FDEntry *fde_stdin = getFDEntry(STDIN_FILENO); 159 if ((it = imap.find(params->input)) != imap.end()) 160 sim_fd = it->second; 161 else 162 sim_fd = openInputFile(params->input); 163 fde_stdin->set(sim_fd, params->input, O_RDONLY, -1, false); 164 165 // Search through the output/error options and set fd if match is found; 166 // otherwise, open an output file and seek to location. 167 FDEntry *fde_stdout = getFDEntry(STDOUT_FILENO); 168 if ((it = oemap.find(params->output)) != oemap.end()) 169 sim_fd = it->second; 170 else 171 sim_fd = openOutputFile(params->output); 172 fde_stdout->set(sim_fd, params->output, O_WRONLY | O_CREAT | O_TRUNC, 173 0664, false); 174 175 FDEntry *fde_stderr = getFDEntry(STDERR_FILENO); 176 if (params->output == params->errout) 177 // Reuse the same file descriptor if these match. 178 sim_fd = fde_stdout->fd; 179 else if ((it = oemap.find(params->errout)) != oemap.end()) 180 sim_fd = it->second; 181 else 182 sim_fd = openOutputFile(params->errout); 183 fde_stderr->set(sim_fd, params->errout, O_WRONLY | O_CREAT | O_TRUNC, 184 0664, false); 185 186 mmap_end = 0; 187 nxm_start = nxm_end = 0; 188 // other parameters will be initialized when the program is loaded 189} 190 191 192void 193Process::regStats() 194{ 195 SimObject::regStats(); 196 197 using namespace Stats; 198 199 num_syscalls 200 .name(name() + ".num_syscalls") 201 .desc("Number of system calls") 202 ; 203} 204 205void 206Process::inheritFDArray(Process *p) 207{ 208 fd_array = p->fd_array; 209} 210 211ThreadContext * 212Process::findFreeContext() 213{ 214 for (int id : contextIds) { 215 ThreadContext *tc = system->getThreadContext(id); 216 if (tc->status() == ThreadContext::Halted) 217 return tc; 218 } 219 return NULL; 220} 221 222void 223Process::initState() 224{ 225 if (contextIds.empty()) 226 fatal("Process %s is not associated with any HW contexts!\n", name()); 227 228 // first thread context for this process... initialize & enable 229 ThreadContext *tc = system->getThreadContext(contextIds[0]); 230 231 // mark this context as active so it will start ticking. 232 tc->activate(); 233 234 pTable->initState(tc); 235} 236 237DrainState 238Process::drain() 239{ 240 findFileOffsets(); 241 return DrainState::Drained; 242} 243 244int 245Process::allocFD(int sim_fd, const string& filename, int flags, int mode, 246 bool pipe) 247{ 248 for (int free_fd = 0; free_fd < fd_array->size(); free_fd++) { 249 FDEntry *fde = getFDEntry(free_fd); 250 if (fde->isFree()) { 251 fde->set(sim_fd, filename, flags, mode, pipe); 252 return free_fd; 253 } 254 } 255 256 fatal("Out of target file descriptors"); 257} 258 259void 260Process::resetFDEntry(int tgt_fd) 261{ 262 FDEntry *fde = getFDEntry(tgt_fd); 263 assert(fde->fd > -1); 264 265 fde->reset(); 266} 267 268int 269Process::getSimFD(int tgt_fd) 270{ 271 FDEntry *entry = getFDEntry(tgt_fd); 272 return entry ? entry->fd : -1; 273} 274 275FDEntry * 276Process::getFDEntry(int tgt_fd) 277{ 278 assert(0 <= tgt_fd && tgt_fd < fd_array->size()); 279 return &(*fd_array)[tgt_fd]; 280} 281 282int 283Process::getTgtFD(int sim_fd) 284{ 285 for (int index = 0; index < fd_array->size(); index++) 286 if ((*fd_array)[index].fd == sim_fd) 287 return index; 288 return -1; 289} 290 291void 292Process::allocateMem(Addr vaddr, int64_t size, bool clobber) 293{ 294 int npages = divCeil(size, (int64_t)PageBytes); 295 Addr paddr = system->allocPhysPages(npages); 296 pTable->map(vaddr, paddr, size, 297 clobber ? PageTableBase::Clobber : PageTableBase::Zero); 298} 299 300bool 301Process::fixupStackFault(Addr vaddr) 302{ 303 // Check if this is already on the stack and there's just no page there 304 // yet. 305 if (vaddr >= stack_min && vaddr < stack_base) { 306 allocateMem(roundDown(vaddr, PageBytes), PageBytes); 307 return true; 308 } 309 310 // We've accessed the next page of the stack, so extend it to include 311 // this address. 312 if (vaddr < stack_min && vaddr >= stack_base - max_stack_size) { 313 while (vaddr < stack_min) { 314 stack_min -= TheISA::PageBytes; 315 if (stack_base - stack_min > max_stack_size) 316 fatal("Maximum stack size exceeded\n"); 317 allocateMem(stack_min, TheISA::PageBytes); 318 inform("Increasing stack size by one page."); 319 }; 320 return true; 321 } 322 return false; 323} 324 325void 326Process::fixFileOffsets() 327{ 328 auto seek = [] (FDEntry *fde) 329 { 330 if (lseek(fde->fd, fde->fileOffset, SEEK_SET) < 0) 331 fatal("Unable to see to location in %s", fde->filename); 332 }; 333 334 std::map<string,int>::iterator it; 335 336 // Search through the input options and set fd if match is found; 337 // otherwise, open an input file and seek to location. 338 FDEntry *fde_stdin = getFDEntry(STDIN_FILENO); 339 340 // Check if user has specified a different input file, and if so, use it 341 // instead of the file specified in the checkpoint. This also resets the 342 // file offset from the checkpointed value 343 string new_in = ((ProcessParams*)params())->input; 344 if (new_in != fde_stdin->filename) { 345 warn("Using new input file (%s) rather than checkpointed (%s)\n", 346 new_in, fde_stdin->filename); 347 fde_stdin->filename = new_in; 348 fde_stdin->fileOffset = 0; 349 } 350 351 if ((it = imap.find(fde_stdin->filename)) != imap.end()) { 352 fde_stdin->fd = it->second; 353 } else { 354 fde_stdin->fd = openInputFile(fde_stdin->filename); 355 seek(fde_stdin); 356 } 357 358 // Search through the output/error options and set fd if match is found; 359 // otherwise, open an output file and seek to location. 360 FDEntry *fde_stdout = getFDEntry(STDOUT_FILENO); 361 362 // Check if user has specified a different output file, and if so, use it 363 // instead of the file specified in the checkpoint. This also resets the 364 // file offset from the checkpointed value 365 string new_out = ((ProcessParams*)params())->output; 366 if (new_out != fde_stdout->filename) { 367 warn("Using new output file (%s) rather than checkpointed (%s)\n", 368 new_out, fde_stdout->filename); 369 fde_stdout->filename = new_out; 370 fde_stdout->fileOffset = 0; 371 } 372 373 if ((it = oemap.find(fde_stdout->filename)) != oemap.end()) { 374 fde_stdout->fd = it->second; 375 } else { 376 fde_stdout->fd = openOutputFile(fde_stdout->filename); 377 seek(fde_stdout); 378 } 379 380 FDEntry *fde_stderr = getFDEntry(STDERR_FILENO); 381 382 // Check if user has specified a different error file, and if so, use it 383 // instead of the file specified in the checkpoint. This also resets the 384 // file offset from the checkpointed value 385 string new_err = ((ProcessParams*)params())->errout; 386 if (new_err != fde_stderr->filename) { 387 warn("Using new error file (%s) rather than checkpointed (%s)\n", 388 new_err, fde_stderr->filename); 389 fde_stderr->filename = new_err; 390 fde_stderr->fileOffset = 0; 391 } 392 393 if (fde_stdout->filename == fde_stderr->filename) { 394 // Reuse the same file descriptor if these match. 395 fde_stderr->fd = fde_stdout->fd; 396 } else if ((it = oemap.find(fde_stderr->filename)) != oemap.end()) { 397 fde_stderr->fd = it->second; 398 } else { 399 fde_stderr->fd = openOutputFile(fde_stderr->filename); 400 seek(fde_stderr); 401 } 402 403 for (int tgt_fd = 3; tgt_fd < fd_array->size(); tgt_fd++) { 404 FDEntry *fde = getFDEntry(tgt_fd); 405 if (fde->fd == -1) 406 continue; 407 408 if (fde->isPipe) { 409 if (fde->filename == "PIPE-WRITE") 410 continue; 411 assert(fde->filename == "PIPE-READ"); 412 413 int fds[2]; 414 if (pipe(fds) < 0) 415 fatal("Unable to create new pipe"); 416 417 fde->fd = fds[0]; 418 419 FDEntry *fde_write = getFDEntry(fde->readPipeSource); 420 assert(fde_write->filename == "PIPE-WRITE"); 421 fde_write->fd = fds[1]; 422 } else { 423 fde->fd = openFile(fde->filename.c_str(), fde->flags, fde->mode); 424 seek(fde); 425 } 426 } 427} 428 429void 430Process::findFileOffsets() 431{ 432 for (auto& fde : *fd_array) { 433 if (fde.fd != -1) 434 fde.fileOffset = lseek(fde.fd, 0, SEEK_CUR); 435 } 436} 437 438void 439Process::setReadPipeSource(int read_pipe_fd, int source_fd) 440{ 441 FDEntry *fde = getFDEntry(read_pipe_fd); 442 assert(source_fd >= -1); 443 fde->readPipeSource = source_fd; 444} 445 446void 447Process::serialize(CheckpointOut &cp) const 448{ 449 SERIALIZE_SCALAR(brk_point); 450 SERIALIZE_SCALAR(stack_base); 451 SERIALIZE_SCALAR(stack_size); 452 SERIALIZE_SCALAR(stack_min); 453 SERIALIZE_SCALAR(next_thread_stack_base); 454 SERIALIZE_SCALAR(mmap_end); 455 SERIALIZE_SCALAR(nxm_start); 456 SERIALIZE_SCALAR(nxm_end); 457 pTable->serialize(cp); 458 for (int x = 0; x < fd_array->size(); x++) { 459 (*fd_array)[x].serializeSection(cp, csprintf("FDEntry%d", x)); 460 } 461 SERIALIZE_SCALAR(M5_pid); 462 463} 464 465void 466Process::unserialize(CheckpointIn &cp) 467{ 468 UNSERIALIZE_SCALAR(brk_point); 469 UNSERIALIZE_SCALAR(stack_base); 470 UNSERIALIZE_SCALAR(stack_size); 471 UNSERIALIZE_SCALAR(stack_min); 472 UNSERIALIZE_SCALAR(next_thread_stack_base); 473 UNSERIALIZE_SCALAR(mmap_end); 474 UNSERIALIZE_SCALAR(nxm_start); 475 UNSERIALIZE_SCALAR(nxm_end); 476 pTable->unserialize(cp); 477 for (int x = 0; x < fd_array->size(); x++) { 478 FDEntry *fde = getFDEntry(x); 479 fde->unserializeSection(cp, csprintf("FDEntry%d", x)); 480 } 481 fixFileOffsets(); 482 UNSERIALIZE_OPT_SCALAR(M5_pid); 483 // The above returns a bool so that you could do something if you don't 484 // find the param in the checkpoint if you wanted to, like set a default 485 // but in this case we'll just stick with the instantiated value if not 486 // found. 487} 488 489 490bool 491Process::map(Addr vaddr, Addr paddr, int size, bool cacheable) 492{ 493 pTable->map(vaddr, paddr, size, 494 cacheable ? PageTableBase::Zero : PageTableBase::Uncacheable); 495 return true; 496} 497 498 499//////////////////////////////////////////////////////////////////////// 500// 501// LiveProcess member definitions 502// 503//////////////////////////////////////////////////////////////////////// 504 505 506LiveProcess::LiveProcess(LiveProcessParams *params, ObjectFile *_objFile) 507 : Process(params), objFile(_objFile), 508 argv(params->cmd), envp(params->env), cwd(params->cwd), 509 executable(params->executable), 510 __uid(params->uid), __euid(params->euid), 511 __gid(params->gid), __egid(params->egid), 512 __pid(params->pid), __ppid(params->ppid), 513 drivers(params->drivers) 514{ 515 516 // load up symbols, if any... these may be used for debugging or 517 // profiling. 518 if (!debugSymbolTable) { 519 debugSymbolTable = new SymbolTable(); 520 if (!objFile->loadGlobalSymbols(debugSymbolTable) || 521 !objFile->loadLocalSymbols(debugSymbolTable) || 522 !objFile->loadWeakSymbols(debugSymbolTable)) { 523 // didn't load any symbols 524 delete debugSymbolTable; 525 debugSymbolTable = NULL; 526 } 527 } 528} 529 530void 531LiveProcess::syscall(int64_t callnum, ThreadContext *tc) 532{ 533 num_syscalls++; 534 535 SyscallDesc *desc = getDesc(callnum); 536 if (desc == NULL) 537 fatal("Syscall %d out of range", callnum); 538 539 desc->doSyscall(callnum, this, tc); 540} 541 542IntReg 543LiveProcess::getSyscallArg(ThreadContext *tc, int &i, int width) 544{ 545 return getSyscallArg(tc, i); 546} 547 548 549EmulatedDriver * 550LiveProcess::findDriver(std::string filename) 551{ 552 for (EmulatedDriver *d : drivers) { 553 if (d->match(filename)) 554 return d; 555 } 556 557 return NULL; 558} 559 560void 561LiveProcess::updateBias() 562{ 563 ObjectFile *interp = objFile->getInterpreter(); 564 565 if (!interp || !interp->relocatable()) 566 return; 567 568 // Determine how large the interpreters footprint will be in the process 569 // address space. 570 Addr interp_mapsize = roundUp(interp->mapSize(), TheISA::PageBytes); 571 572 // We are allocating the memory area; set the bias to the lowest address 573 // in the allocated memory region. 574 Addr ld_bias = mmapGrowsDown() ? mmap_end - interp_mapsize : mmap_end; 575 576 // Adjust the process mmap area to give the interpreter room; the real 577 // execve system call would just invoke the kernel's internal mmap 578 // functions to make these adjustments. 579 mmap_end = mmapGrowsDown() ? ld_bias : mmap_end + interp_mapsize; 580 581 interp->updateBias(ld_bias); 582} 583 584 585ObjectFile * 586LiveProcess::getInterpreter() 587{ 588 return objFile->getInterpreter(); 589} 590 591 592Addr 593LiveProcess::getBias() 594{ 595 ObjectFile *interp = getInterpreter(); 596 597 return interp ? interp->bias() : objFile->bias(); 598} 599 600 601Addr 602LiveProcess::getStartPC() 603{ 604 ObjectFile *interp = getInterpreter(); 605 606 return interp ? interp->entryPoint() : objFile->entryPoint(); 607} 608 609 610LiveProcess * 611LiveProcess::create(LiveProcessParams * params) 612{ 613 LiveProcess *process = NULL; 614 615 // If not specified, set the executable parameter equal to the 616 // simulated system's zeroth command line parameter 617 if (params->executable == "") { 618 params->executable = params->cmd[0]; 619 } 620 621 ObjectFile *objFile = createObjectFile(params->executable); 622 if (objFile == NULL) { 623 fatal("Can't load object file %s", params->executable); 624 } 625 626#if THE_ISA == ALPHA_ISA 627 if (objFile->getArch() != ObjectFile::Alpha) 628 fatal("Object file architecture does not match compiled ISA (Alpha)."); 629 630 switch (objFile->getOpSys()) { 631 case ObjectFile::UnknownOpSys: 632 warn("Unknown operating system; assuming Linux."); 633 // fall through 634 case ObjectFile::Linux: 635 process = new AlphaLinuxProcess(params, objFile); 636 break; 637 638 default: 639 fatal("Unknown/unsupported operating system."); 640 } 641#elif THE_ISA == SPARC_ISA 642 if (objFile->getArch() != ObjectFile::SPARC64 && 643 objFile->getArch() != ObjectFile::SPARC32) 644 fatal("Object file architecture does not match compiled ISA (SPARC)."); 645 switch (objFile->getOpSys()) { 646 case ObjectFile::UnknownOpSys: 647 warn("Unknown operating system; assuming Linux."); 648 // fall through 649 case ObjectFile::Linux: 650 if (objFile->getArch() == ObjectFile::SPARC64) { 651 process = new Sparc64LinuxProcess(params, objFile); 652 } else { 653 process = new Sparc32LinuxProcess(params, objFile); 654 } 655 break; 656 657 658 case ObjectFile::Solaris: 659 process = new SparcSolarisProcess(params, objFile); 660 break; 661 662 default: 663 fatal("Unknown/unsupported operating system."); 664 } 665#elif THE_ISA == X86_ISA 666 if (objFile->getArch() != ObjectFile::X86_64 && 667 objFile->getArch() != ObjectFile::I386) 668 fatal("Object file architecture does not match compiled ISA (x86)."); 669 switch (objFile->getOpSys()) { 670 case ObjectFile::UnknownOpSys: 671 warn("Unknown operating system; assuming Linux."); 672 // fall through 673 case ObjectFile::Linux: 674 if (objFile->getArch() == ObjectFile::X86_64) { 675 process = new X86_64LinuxProcess(params, objFile); 676 } else { 677 process = new I386LinuxProcess(params, objFile); 678 } 679 break; 680 681 default: 682 fatal("Unknown/unsupported operating system."); 683 } 684#elif THE_ISA == MIPS_ISA 685 if (objFile->getArch() != ObjectFile::Mips) 686 fatal("Object file architecture does not match compiled ISA (MIPS)."); 687 switch (objFile->getOpSys()) { 688 case ObjectFile::UnknownOpSys: 689 warn("Unknown operating system; assuming Linux."); 690 // fall through 691 case ObjectFile::Linux: 692 process = new MipsLinuxProcess(params, objFile); 693 break; 694 695 default: 696 fatal("Unknown/unsupported operating system."); 697 } 698#elif THE_ISA == ARM_ISA 699 ObjectFile::Arch arch = objFile->getArch(); 700 if (arch != ObjectFile::Arm && arch != ObjectFile::Thumb && 701 arch != ObjectFile::Arm64) 702 fatal("Object file architecture does not match compiled ISA (ARM)."); 703 switch (objFile->getOpSys()) { 704 case ObjectFile::UnknownOpSys: 705 warn("Unknown operating system; assuming Linux."); 706 // fall through 707 case ObjectFile::Linux: 708 if (arch == ObjectFile::Arm64) { 709 process = new ArmLinuxProcess64(params, objFile, 710 objFile->getArch()); 711 } else { 712 process = new ArmLinuxProcess32(params, objFile, 713 objFile->getArch()); 714 } 715 break; 716 case ObjectFile::FreeBSD: 717 if (arch == ObjectFile::Arm64) { 718 process = new ArmFreebsdProcess64(params, objFile, 719 objFile->getArch()); 720 } else { 721 process = new ArmFreebsdProcess32(params, objFile, 722 objFile->getArch()); 723 } 724 break; 725 case ObjectFile::LinuxArmOABI: 726 fatal("M5 does not support ARM OABI binaries. Please recompile with an" 727 " EABI compiler."); 728 default: 729 fatal("Unknown/unsupported operating system."); 730 } 731#elif THE_ISA == POWER_ISA 732 if (objFile->getArch() != ObjectFile::Power) 733 fatal("Object file architecture does not match compiled ISA (Power)."); 734 switch (objFile->getOpSys()) { 735 case ObjectFile::UnknownOpSys: 736 warn("Unknown operating system; assuming Linux."); 737 // fall through 738 case ObjectFile::Linux: 739 process = new PowerLinuxProcess(params, objFile); 740 break; 741 742 default: 743 fatal("Unknown/unsupported operating system."); 744 } 745#elif THE_ISA == RISCV_ISA 746 if (objFile->getArch() != ObjectFile::Riscv) 747 fatal("Object file architecture does not match compiled ISA (RISCV)."); 748 switch (objFile->getOpSys()) { 749 case ObjectFile::UnknownOpSys: 750 warn("Unknown operating system; assuming Linux."); 751 // fall through 752 case ObjectFile::Linux: 753 process = new RiscvLinuxProcess(params, objFile); 754 break; 755 default: 756 fatal("Unknown/unsupported operating system."); 757 } 758#else 759#error "THE_ISA not set" 760#endif 761 762 if (process == NULL) 763 fatal("Unknown error creating process object."); 764 return process; 765} 766 767LiveProcess * 768LiveProcessParams::create() 769{ 770 return LiveProcess::create(this); 771} 772