Deleted Added
sdiff udiff text old ( 13867:9b10bbcf0543 ) new ( 13894:8603648c1679 )
full compact
1/*
2 * Copyright (c) 2014 Advanced Micro Devices, Inc.
3 * Copyright (c) 2007 The Hewlett-Packard Development Company
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

--- 748 unchanged lines hidden (view full) ---

757
758template<class IntType>
759void
760X86Process::argsInit(int pageSize,
761 std::vector<AuxVector<IntType> > extraAuxvs)
762{
763 int intSize = sizeof(IntType);
764
765 typedef AuxVector<IntType> auxv_t;
766 std::vector<auxv_t> auxv = extraAuxvs;
767
768 string filename;
769 if (argv.size() < 1)
770 filename = "";
771 else
772 filename = argv[0];
773
774 // We want 16 byte alignment

--- 79 unchanged lines hidden (view full) ---

854// X86_CPUSelfSnoop |
855// X86_HyperThreading |
856// X86_AutomaticClockControl |
857// X86_IA64Processor |
858 0;
859
860 // Bits which describe the system hardware capabilities
861 // XXX Figure out what these should be
862 auxv.push_back(auxv_t(M5_AT_HWCAP, features));
863 // The system page size
864 auxv.push_back(auxv_t(M5_AT_PAGESZ, X86ISA::PageBytes));
865 // Frequency at which times() increments
866 // Defined to be 100 in the kernel source.
867 auxv.push_back(auxv_t(M5_AT_CLKTCK, 100));
868 // This is the virtual address of the program header tables if they
869 // appear in the executable image.
870 auxv.push_back(auxv_t(M5_AT_PHDR, elfObject->programHeaderTable()));
871 // This is the size of a program header entry from the elf file.
872 auxv.push_back(auxv_t(M5_AT_PHENT, elfObject->programHeaderSize()));
873 // This is the number of program headers from the original elf file.
874 auxv.push_back(auxv_t(M5_AT_PHNUM, elfObject->programHeaderCount()));
875 // This is the base address of the ELF interpreter; it should be
876 // zero for static executables or contain the base address for
877 // dynamic executables.
878 auxv.push_back(auxv_t(M5_AT_BASE, getBias()));
879 // XXX Figure out what this should be.
880 auxv.push_back(auxv_t(M5_AT_FLAGS, 0));
881 // The entry point to the program
882 auxv.push_back(auxv_t(M5_AT_ENTRY, objFile->entryPoint()));
883 // Different user and group IDs
884 auxv.push_back(auxv_t(M5_AT_UID, uid()));
885 auxv.push_back(auxv_t(M5_AT_EUID, euid()));
886 auxv.push_back(auxv_t(M5_AT_GID, gid()));
887 auxv.push_back(auxv_t(M5_AT_EGID, egid()));
888 // Whether to enable "secure mode" in the executable
889 auxv.push_back(auxv_t(M5_AT_SECURE, 0));
890 // The address of 16 "random" bytes.
891 auxv.push_back(auxv_t(M5_AT_RANDOM, 0));
892 // The name of the program
893 auxv.push_back(auxv_t(M5_AT_EXECFN, 0));
894 // The platform string
895 auxv.push_back(auxv_t(M5_AT_PLATFORM, 0));
896 }
897
898 // Figure out how big the initial stack needs to be
899
900 // A sentry NULL void pointer at the top of the stack.
901 int sentry_size = intSize;
902
903 // This is the name of the file which is present on the initial stack

--- 97 unchanged lines hidden (view full) ---

1001 // Write out the sentry void *
1002 IntType sentry_NULL = 0;
1003 initVirtMem.writeBlob(sentry_base, (uint8_t*)&sentry_NULL, sentry_size);
1004
1005 // Write the file name
1006 initVirtMem.writeString(file_name_base, filename.c_str());
1007
1008 // Fix up the aux vectors which point to data
1009 assert(auxv[auxv.size() - 3].getHostAuxType() == M5_AT_RANDOM);
1010 auxv[auxv.size() - 3].setAuxVal(aux_data_base);
1011 assert(auxv[auxv.size() - 2].getHostAuxType() == M5_AT_EXECFN);
1012 auxv[auxv.size() - 2].setAuxVal(argv_array_base);
1013 assert(auxv[auxv.size() - 1].getHostAuxType() == M5_AT_PLATFORM);
1014 auxv[auxv.size() - 1].setAuxVal(aux_data_base + numRandomBytes);
1015
1016
1017 // Copy the aux stuff
1018 for (int x = 0; x < auxv.size(); x++) {
1019 initVirtMem.writeBlob(auxv_array_base + x * 2 * intSize,
1020 (uint8_t*)&(auxv[x].getAuxType()),
1021 intSize);
1022 initVirtMem.writeBlob(auxv_array_base + (x * 2 + 1) * intSize,
1023 (uint8_t*)&(auxv[x].getAuxVal()),
1024 intSize);
1025 }
1026 // Write out the terminating zeroed auxiliary vector
1027 const uint64_t zero = 0;
1028 initVirtMem.writeBlob(auxv_array_base + auxv.size() * 2 * intSize,
1029 (uint8_t*)&zero, intSize);
1030 initVirtMem.writeBlob(auxv_array_base + (auxv.size() * 2 + 1) * intSize,
1031 (uint8_t*)&zero, intSize);
1032
1033 initVirtMem.writeString(aux_data_base, platform.c_str());
1034
1035 copyStringArray(envp, envp_array_base, env_data_base, initVirtMem);
1036 copyStringArray(argv, argv_array_base, arg_data_base, initVirtMem);
1037
1038 initVirtMem.writeBlob(argc_base, (uint8_t*)&guestArgc, intSize);
1039

--- 8 unchanged lines hidden (view full) ---

1048 // Align the "stack_min" to a page boundary.
1049 memState->setStackMin(roundDown(stack_min, pageSize));
1050}
1051
1052void
1053X86_64Process::argsInit(int pageSize)
1054{
1055 std::vector<AuxVector<uint64_t> > extraAuxvs;
1056 extraAuxvs.push_back(AuxVector<uint64_t>(M5_AT_SYSINFO_EHDR,
1057 vsyscallPage.base));
1058 X86Process::argsInit<uint64_t>(pageSize, extraAuxvs);
1059}
1060
1061void
1062I386Process::argsInit(int pageSize)
1063{
1064 std::vector<AuxVector<uint32_t> > extraAuxvs;
1065 //Tell the binary where the vsyscall part of the vsyscall page is.
1066 extraAuxvs.push_back(AuxVector<uint32_t>(M5_AT_SYSINFO,
1067 vsyscallPage.base + vsyscallPage.vsyscallOffset));
1068 extraAuxvs.push_back(AuxVector<uint32_t>(M5_AT_SYSINFO_EHDR,
1069 vsyscallPage.base));
1070 X86Process::argsInit<uint32_t>(pageSize, extraAuxvs);
1071}
1072
1073void
1074X86Process::setSyscallReturn(ThreadContext *tc, SyscallReturn retval)
1075{
1076 tc->setIntReg(INTREG_RAX, retval.encodedValue());
1077}

--- 55 unchanged lines hidden ---