process.cc (11905:4a771f8756ad) | process.cc (11906:4b99c1bb3b72) |
---|---|
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 --- 59 unchanged lines hidden (view full) --- 68 69using namespace std; 70using namespace X86ISA; 71 72static const int ArgumentReg[] = { 73 INTREG_RDI, 74 INTREG_RSI, 75 INTREG_RDX, | 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 --- 59 unchanged lines hidden (view full) --- 68 69using namespace std; 70using namespace X86ISA; 71 72static const int ArgumentReg[] = { 73 INTREG_RDI, 74 INTREG_RSI, 75 INTREG_RDX, |
76 //This argument register is r10 for syscalls and rcx for C. | 76 // This argument register is r10 for syscalls and rcx for C. |
77 INTREG_R10W, | 77 INTREG_R10W, |
78 //INTREG_RCX, | 78 // INTREG_RCX, |
79 INTREG_R8W, 80 INTREG_R9W 81}; 82 83static const int NumArgumentRegs M5_VAR_USED = 84 sizeof(ArgumentReg) / sizeof(const int); 85 86static const int ArgumentReg32[] = { --- 91 unchanged lines hidden (view full) --- 178 179void 180X86_64Process::initState() 181{ 182 X86Process::initState(); 183 184 argsInit(PageBytes); 185 | 79 INTREG_R8W, 80 INTREG_R9W 81}; 82 83static const int NumArgumentRegs M5_VAR_USED = 84 sizeof(ArgumentReg) / sizeof(const int); 85 86static const int ArgumentReg32[] = { --- 91 unchanged lines hidden (view full) --- 178 179void 180X86_64Process::initState() 181{ 182 X86Process::initState(); 183 184 argsInit(PageBytes); 185 |
186 // Set up the vsyscall page for this process. | 186 // Set up the vsyscall page for this process. |
187 allocateMem(vsyscallPage.base, vsyscallPage.size); 188 uint8_t vtimeBlob[] = { 189 0x48,0xc7,0xc0,0xc9,0x00,0x00,0x00, // mov $0xc9,%rax 190 0x0f,0x05, // syscall 191 0xc3 // retq 192 }; 193 initVirtMem.writeBlob(vsyscallPage.base + vsyscallPage.vtimeOffset, 194 vtimeBlob, sizeof(vtimeBlob)); --- 366 unchanged lines hidden (view full) --- 561 dataAttr.granularity = 1; 562 dataAttr.present = 1; 563 dataAttr.type = 3; 564 dataAttr.writable = 1; 565 dataAttr.readable = 1; 566 dataAttr.expandDown = 0; 567 dataAttr.system = 1; 568 | 187 allocateMem(vsyscallPage.base, vsyscallPage.size); 188 uint8_t vtimeBlob[] = { 189 0x48,0xc7,0xc0,0xc9,0x00,0x00,0x00, // mov $0xc9,%rax 190 0x0f,0x05, // syscall 191 0xc3 // retq 192 }; 193 initVirtMem.writeBlob(vsyscallPage.base + vsyscallPage.vtimeOffset, 194 vtimeBlob, sizeof(vtimeBlob)); --- 366 unchanged lines hidden (view full) --- 561 dataAttr.granularity = 1; 562 dataAttr.present = 1; 563 dataAttr.type = 3; 564 dataAttr.writable = 1; 565 dataAttr.readable = 1; 566 dataAttr.expandDown = 0; 567 dataAttr.system = 1; 568 |
569 //Initialize the segment registers. | 569 // Initialize the segment registers. |
570 for (int seg = 0; seg < NUM_SEGMENTREGS; seg++) { 571 tc->setMiscRegNoEffect(MISCREG_SEG_BASE(seg), 0); 572 tc->setMiscRegNoEffect(MISCREG_SEG_EFF_BASE(seg), 0); 573 tc->setMiscRegNoEffect(MISCREG_SEG_ATTR(seg), dataAttr); 574 } 575 576 SegAttr csAttr = 0; 577 csAttr.dpl = 3; --- 15 unchanged lines hidden (view full) --- 593 efer.sce = 1; // Enable system call extensions. 594 efer.lme = 1; // Enable long mode. 595 efer.lma = 1; // Activate long mode. 596 efer.nxe = 1; // Enable nx support. 597 efer.svme = 0; // Disable svm support for now. It isn't implemented. 598 efer.ffxsr = 1; // Turn on fast fxsave and fxrstor. 599 tc->setMiscReg(MISCREG_EFER, efer); 600 | 570 for (int seg = 0; seg < NUM_SEGMENTREGS; seg++) { 571 tc->setMiscRegNoEffect(MISCREG_SEG_BASE(seg), 0); 572 tc->setMiscRegNoEffect(MISCREG_SEG_EFF_BASE(seg), 0); 573 tc->setMiscRegNoEffect(MISCREG_SEG_ATTR(seg), dataAttr); 574 } 575 576 SegAttr csAttr = 0; 577 csAttr.dpl = 3; --- 15 unchanged lines hidden (view full) --- 593 efer.sce = 1; // Enable system call extensions. 594 efer.lme = 1; // Enable long mode. 595 efer.lma = 1; // Activate long mode. 596 efer.nxe = 1; // Enable nx support. 597 efer.svme = 0; // Disable svm support for now. It isn't implemented. 598 efer.ffxsr = 1; // Turn on fast fxsave and fxrstor. 599 tc->setMiscReg(MISCREG_EFER, efer); 600 |
601 //Set up the registers that describe the operating mode. | 601 // Set up the registers that describe the operating mode. |
602 CR0 cr0 = 0; 603 cr0.pg = 1; // Turn on paging. 604 cr0.cd = 0; // Don't disable caching. 605 cr0.nw = 0; // This is bit is defined to be ignored. 606 cr0.am = 0; // No alignment checking 607 cr0.wp = 0; // Supervisor mode can write read only pages 608 cr0.ne = 1; 609 cr0.et = 1; // This should always be 1 --- 62 unchanged lines hidden (view full) --- 672 dataAttr.granularity = 1; 673 dataAttr.present = 1; 674 dataAttr.type = 3; 675 dataAttr.writable = 1; 676 dataAttr.readable = 1; 677 dataAttr.expandDown = 0; 678 dataAttr.system = 1; 679 | 602 CR0 cr0 = 0; 603 cr0.pg = 1; // Turn on paging. 604 cr0.cd = 0; // Don't disable caching. 605 cr0.nw = 0; // This is bit is defined to be ignored. 606 cr0.am = 0; // No alignment checking 607 cr0.wp = 0; // Supervisor mode can write read only pages 608 cr0.ne = 1; 609 cr0.et = 1; // This should always be 1 --- 62 unchanged lines hidden (view full) --- 672 dataAttr.granularity = 1; 673 dataAttr.present = 1; 674 dataAttr.type = 3; 675 dataAttr.writable = 1; 676 dataAttr.readable = 1; 677 dataAttr.expandDown = 0; 678 dataAttr.system = 1; 679 |
680 //Initialize the segment registers. | 680 // Initialize the segment registers. |
681 for (int seg = 0; seg < NUM_SEGMENTREGS; seg++) { 682 tc->setMiscRegNoEffect(MISCREG_SEG_BASE(seg), 0); 683 tc->setMiscRegNoEffect(MISCREG_SEG_EFF_BASE(seg), 0); 684 tc->setMiscRegNoEffect(MISCREG_SEG_ATTR(seg), dataAttr); 685 tc->setMiscRegNoEffect(MISCREG_SEG_SEL(seg), 0xB); 686 tc->setMiscRegNoEffect(MISCREG_SEG_LIMIT(seg), (uint32_t)(-1)); 687 } 688 --- 24 unchanged lines hidden (view full) --- 713 efer.sce = 1; // Enable system call extensions. 714 efer.lme = 1; // Enable long mode. 715 efer.lma = 0; // Deactivate long mode. 716 efer.nxe = 1; // Enable nx support. 717 efer.svme = 0; // Disable svm support for now. It isn't implemented. 718 efer.ffxsr = 1; // Turn on fast fxsave and fxrstor. 719 tc->setMiscReg(MISCREG_EFER, efer); 720 | 681 for (int seg = 0; seg < NUM_SEGMENTREGS; seg++) { 682 tc->setMiscRegNoEffect(MISCREG_SEG_BASE(seg), 0); 683 tc->setMiscRegNoEffect(MISCREG_SEG_EFF_BASE(seg), 0); 684 tc->setMiscRegNoEffect(MISCREG_SEG_ATTR(seg), dataAttr); 685 tc->setMiscRegNoEffect(MISCREG_SEG_SEL(seg), 0xB); 686 tc->setMiscRegNoEffect(MISCREG_SEG_LIMIT(seg), (uint32_t)(-1)); 687 } 688 --- 24 unchanged lines hidden (view full) --- 713 efer.sce = 1; // Enable system call extensions. 714 efer.lme = 1; // Enable long mode. 715 efer.lma = 0; // Deactivate long mode. 716 efer.nxe = 1; // Enable nx support. 717 efer.svme = 0; // Disable svm support for now. It isn't implemented. 718 efer.ffxsr = 1; // Turn on fast fxsave and fxrstor. 719 tc->setMiscReg(MISCREG_EFER, efer); 720 |
721 //Set up the registers that describe the operating mode. | 721 // Set up the registers that describe the operating mode. |
722 CR0 cr0 = 0; 723 cr0.pg = 1; // Turn on paging. 724 cr0.cd = 0; // Don't disable caching. 725 cr0.nw = 0; // This is bit is defined to be ignored. 726 cr0.am = 0; // No alignment checking 727 cr0.wp = 0; // Supervisor mode can write read only pages 728 cr0.ne = 1; 729 cr0.et = 1; // This should always be 1 --- 20 unchanged lines hidden (view full) --- 750 std::vector<auxv_t> auxv = extraAuxvs; 751 752 string filename; 753 if (argv.size() < 1) 754 filename = ""; 755 else 756 filename = argv[0]; 757 | 722 CR0 cr0 = 0; 723 cr0.pg = 1; // Turn on paging. 724 cr0.cd = 0; // Don't disable caching. 725 cr0.nw = 0; // This is bit is defined to be ignored. 726 cr0.am = 0; // No alignment checking 727 cr0.wp = 0; // Supervisor mode can write read only pages 728 cr0.ne = 1; 729 cr0.et = 1; // This should always be 1 --- 20 unchanged lines hidden (view full) --- 750 std::vector<auxv_t> auxv = extraAuxvs; 751 752 string filename; 753 if (argv.size() < 1) 754 filename = ""; 755 else 756 filename = argv[0]; 757 |
758 //We want 16 byte alignment | 758 // We want 16 byte alignment |
759 uint64_t align = 16; 760 761 // Patch the ld_bias for dynamic executables. 762 updateBias(); 763 764 // load object file into target memory 765 objFile->loadSections(initVirtMem); 766 --- 69 unchanged lines hidden (view full) --- 836 X86_StreamingSIMDExtensions | 837 X86_StreamingSIMDExtensions2 | 838// X86_CPUSelfSnoop | 839// X86_HyperThreading | 840// X86_AutomaticClockControl | 841// X86_IA64Processor | 842 0; 843 | 759 uint64_t align = 16; 760 761 // Patch the ld_bias for dynamic executables. 762 updateBias(); 763 764 // load object file into target memory 765 objFile->loadSections(initVirtMem); 766 --- 69 unchanged lines hidden (view full) --- 836 X86_StreamingSIMDExtensions | 837 X86_StreamingSIMDExtensions2 | 838// X86_CPUSelfSnoop | 839// X86_HyperThreading | 840// X86_AutomaticClockControl | 841// X86_IA64Processor | 842 0; 843 |
844 //Bits which describe the system hardware capabilities 845 //XXX Figure out what these should be | 844 // Bits which describe the system hardware capabilities 845 // XXX Figure out what these should be |
846 auxv.push_back(auxv_t(M5_AT_HWCAP, features)); | 846 auxv.push_back(auxv_t(M5_AT_HWCAP, features)); |
847 //The system page size | 847 // The system page size |
848 auxv.push_back(auxv_t(M5_AT_PAGESZ, X86ISA::PageBytes)); | 848 auxv.push_back(auxv_t(M5_AT_PAGESZ, X86ISA::PageBytes)); |
849 //Frequency at which times() increments 850 //Defined to be 100 in the kernel source. | 849 // Frequency at which times() increments 850 // Defined to be 100 in the kernel source. |
851 auxv.push_back(auxv_t(M5_AT_CLKTCK, 100)); 852 // This is the virtual address of the program header tables if they 853 // appear in the executable image. 854 auxv.push_back(auxv_t(M5_AT_PHDR, elfObject->programHeaderTable())); 855 // This is the size of a program header entry from the elf file. 856 auxv.push_back(auxv_t(M5_AT_PHENT, elfObject->programHeaderSize())); 857 // This is the number of program headers from the original elf file. 858 auxv.push_back(auxv_t(M5_AT_PHNUM, elfObject->programHeaderCount())); 859 // This is the base address of the ELF interpreter; it should be 860 // zero for static executables or contain the base address for 861 // dynamic executables. 862 auxv.push_back(auxv_t(M5_AT_BASE, getBias())); | 851 auxv.push_back(auxv_t(M5_AT_CLKTCK, 100)); 852 // This is the virtual address of the program header tables if they 853 // appear in the executable image. 854 auxv.push_back(auxv_t(M5_AT_PHDR, elfObject->programHeaderTable())); 855 // This is the size of a program header entry from the elf file. 856 auxv.push_back(auxv_t(M5_AT_PHENT, elfObject->programHeaderSize())); 857 // This is the number of program headers from the original elf file. 858 auxv.push_back(auxv_t(M5_AT_PHNUM, elfObject->programHeaderCount())); 859 // This is the base address of the ELF interpreter; it should be 860 // zero for static executables or contain the base address for 861 // dynamic executables. 862 auxv.push_back(auxv_t(M5_AT_BASE, getBias())); |
863 //XXX Figure out what this should be. | 863 // XXX Figure out what this should be. |
864 auxv.push_back(auxv_t(M5_AT_FLAGS, 0)); | 864 auxv.push_back(auxv_t(M5_AT_FLAGS, 0)); |
865 //The entry point to the program | 865 // The entry point to the program |
866 auxv.push_back(auxv_t(M5_AT_ENTRY, objFile->entryPoint())); | 866 auxv.push_back(auxv_t(M5_AT_ENTRY, objFile->entryPoint())); |
867 //Different user and group IDs | 867 // Different user and group IDs |
868 auxv.push_back(auxv_t(M5_AT_UID, uid())); 869 auxv.push_back(auxv_t(M5_AT_EUID, euid())); 870 auxv.push_back(auxv_t(M5_AT_GID, gid())); 871 auxv.push_back(auxv_t(M5_AT_EGID, egid())); | 868 auxv.push_back(auxv_t(M5_AT_UID, uid())); 869 auxv.push_back(auxv_t(M5_AT_EUID, euid())); 870 auxv.push_back(auxv_t(M5_AT_GID, gid())); 871 auxv.push_back(auxv_t(M5_AT_EGID, egid())); |
872 //Whether to enable "secure mode" in the executable | 872 // Whether to enable "secure mode" in the executable |
873 auxv.push_back(auxv_t(M5_AT_SECURE, 0)); | 873 auxv.push_back(auxv_t(M5_AT_SECURE, 0)); |
874 //The address of 16 "random" bytes. | 874 // The address of 16 "random" bytes. |
875 auxv.push_back(auxv_t(M5_AT_RANDOM, 0)); | 875 auxv.push_back(auxv_t(M5_AT_RANDOM, 0)); |
876 //The name of the program | 876 // The name of the program |
877 auxv.push_back(auxv_t(M5_AT_EXECFN, 0)); | 877 auxv.push_back(auxv_t(M5_AT_EXECFN, 0)); |
878 //The platform string | 878 // The platform string |
879 auxv.push_back(auxv_t(M5_AT_PLATFORM, 0)); 880 } 881 | 879 auxv.push_back(auxv_t(M5_AT_PLATFORM, 0)); 880 } 881 |
882 //Figure out how big the initial stack needs to be | 882 // Figure out how big the initial stack needs to be |
883 884 // A sentry NULL void pointer at the top of the stack. 885 int sentry_size = intSize; 886 | 883 884 // A sentry NULL void pointer at the top of the stack. 885 int sentry_size = intSize; 886 |
887 //This is the name of the file which is present on the initial stack 888 //It's purpose is to let the user space linker examine the original file. | 887 // This is the name of the file which is present on the initial stack 888 // It's purpose is to let the user space linker examine the original file. |
889 int file_name_size = filename.size() + 1; 890 891 const int numRandomBytes = 16; 892 int aux_data_size = numRandomBytes; 893 894 string platform = "x86_64"; 895 aux_data_size += platform.size() + 1; 896 897 int env_data_size = 0; 898 for (int i = 0; i < envp.size(); ++i) 899 env_data_size += envp[i].size() + 1; 900 int arg_data_size = 0; 901 for (int i = 0; i < argv.size(); ++i) 902 arg_data_size += argv[i].size() + 1; 903 | 889 int file_name_size = filename.size() + 1; 890 891 const int numRandomBytes = 16; 892 int aux_data_size = numRandomBytes; 893 894 string platform = "x86_64"; 895 aux_data_size += platform.size() + 1; 896 897 int env_data_size = 0; 898 for (int i = 0; i < envp.size(); ++i) 899 env_data_size += envp[i].size() + 1; 900 int arg_data_size = 0; 901 for (int i = 0; i < argv.size(); ++i) 902 arg_data_size += argv[i].size() + 1; 903 |
904 //The info_block needs to be padded so it's size is a multiple of the 905 //alignment mask. Also, it appears that there needs to be at least some 906 //padding, so if the size is already a multiple, we need to increase it 907 //anyway. | 904 // The info_block needs to be padded so its size is a multiple of the 905 // alignment mask. Also, it appears that there needs to be at least some 906 // padding, so if the size is already a multiple, we need to increase it 907 // anyway. |
908 int base_info_block_size = 909 sentry_size + file_name_size + env_data_size + arg_data_size; 910 911 int info_block_size = roundUp(base_info_block_size, align); 912 913 int info_block_padding = info_block_size - base_info_block_size; 914 | 908 int base_info_block_size = 909 sentry_size + file_name_size + env_data_size + arg_data_size; 910 911 int info_block_size = roundUp(base_info_block_size, align); 912 913 int info_block_padding = info_block_size - base_info_block_size; 914 |
915 //Each auxilliary vector is two 8 byte words | 915 // Each auxiliary vector is two 8 byte words |
916 int aux_array_size = intSize * 2 * (auxv.size() + 1); 917 918 int envp_array_size = intSize * (envp.size() + 1); 919 int argv_array_size = intSize * (argv.size() + 1); 920 921 int argc_size = intSize; 922 | 916 int aux_array_size = intSize * 2 * (auxv.size() + 1); 917 918 int envp_array_size = intSize * (envp.size() + 1); 919 int argv_array_size = intSize * (argv.size() + 1); 920 921 int argc_size = intSize; 922 |
923 //Figure out the size of the contents of the actual initial frame | 923 // Figure out the size of the contents of the actual initial frame |
924 int frame_size = 925 aux_array_size + 926 envp_array_size + 927 argv_array_size + 928 argc_size; 929 | 924 int frame_size = 925 aux_array_size + 926 envp_array_size + 927 argv_array_size + 928 argc_size; 929 |
930 //There needs to be padding after the auxiliary vector data so that the 931 //very bottom of the stack is aligned properly. | 930 // There needs to be padding after the auxiliary vector data so that the 931 // very bottom of the stack is aligned properly. |
932 int partial_size = frame_size + aux_data_size; 933 int aligned_partial_size = roundUp(partial_size, align); 934 int aux_padding = aligned_partial_size - partial_size; 935 936 int space_needed = 937 info_block_size + 938 aux_data_size + 939 aux_padding + --- 37 unchanged lines hidden (view full) --- 977 DPRINTF(Stack, "0x%x - stack min\n", stack_min); 978 979 // write contents to stack 980 981 // figure out argc 982 IntType argc = argv.size(); 983 IntType guestArgc = X86ISA::htog(argc); 984 | 932 int partial_size = frame_size + aux_data_size; 933 int aligned_partial_size = roundUp(partial_size, align); 934 int aux_padding = aligned_partial_size - partial_size; 935 936 int space_needed = 937 info_block_size + 938 aux_data_size + 939 aux_padding + --- 37 unchanged lines hidden (view full) --- 977 DPRINTF(Stack, "0x%x - stack min\n", stack_min); 978 979 // write contents to stack 980 981 // figure out argc 982 IntType argc = argv.size(); 983 IntType guestArgc = X86ISA::htog(argc); 984 |
985 //Write out the sentry void * | 985 // Write out the sentry void * |
986 IntType sentry_NULL = 0; | 986 IntType sentry_NULL = 0; |
987 initVirtMem.writeBlob(sentry_base, 988 (uint8_t*)&sentry_NULL, sentry_size); | 987 initVirtMem.writeBlob(sentry_base, (uint8_t*)&sentry_NULL, sentry_size); |
989 | 988 |
990 //Write the file name | 989 // Write the file name |
991 initVirtMem.writeString(file_name_base, filename.c_str()); 992 | 990 initVirtMem.writeString(file_name_base, filename.c_str()); 991 |
993 //Fix up the aux vectors which point to data | 992 // Fix up the aux vectors which point to data |
994 assert(auxv[auxv.size() - 3].a_type == M5_AT_RANDOM); 995 auxv[auxv.size() - 3].a_val = aux_data_base; 996 assert(auxv[auxv.size() - 2].a_type == M5_AT_EXECFN); 997 auxv[auxv.size() - 2].a_val = argv_array_base; 998 assert(auxv[auxv.size() - 1].a_type == M5_AT_PLATFORM); 999 auxv[auxv.size() - 1].a_val = aux_data_base + numRandomBytes; 1000 | 993 assert(auxv[auxv.size() - 3].a_type == M5_AT_RANDOM); 994 auxv[auxv.size() - 3].a_val = aux_data_base; 995 assert(auxv[auxv.size() - 2].a_type == M5_AT_EXECFN); 996 auxv[auxv.size() - 2].a_val = argv_array_base; 997 assert(auxv[auxv.size() - 1].a_type == M5_AT_PLATFORM); 998 auxv[auxv.size() - 1].a_val = aux_data_base + numRandomBytes; 999 |
1001 //Copy the aux stuff | 1000 1001 // Copy the aux stuff |
1002 for (int x = 0; x < auxv.size(); x++) { 1003 initVirtMem.writeBlob(auxv_array_base + x * 2 * intSize, 1004 (uint8_t*)&(auxv[x].a_type), intSize); 1005 initVirtMem.writeBlob(auxv_array_base + (x * 2 + 1) * intSize, 1006 (uint8_t*)&(auxv[x].a_val), intSize); 1007 } | 1002 for (int x = 0; x < auxv.size(); x++) { 1003 initVirtMem.writeBlob(auxv_array_base + x * 2 * intSize, 1004 (uint8_t*)&(auxv[x].a_type), intSize); 1005 initVirtMem.writeBlob(auxv_array_base + (x * 2 + 1) * intSize, 1006 (uint8_t*)&(auxv[x].a_val), intSize); 1007 } |
1008 //Write out the terminating zeroed auxilliary vector | 1008 // Write out the terminating zeroed auxiliary vector |
1009 const uint64_t zero = 0; 1010 initVirtMem.writeBlob(auxv_array_base + auxv.size() * 2 * intSize, 1011 (uint8_t*)&zero, intSize); 1012 initVirtMem.writeBlob(auxv_array_base + (auxv.size() * 2 + 1) * intSize, 1013 (uint8_t*)&zero, intSize); 1014 1015 initVirtMem.writeString(aux_data_base, platform.c_str()); 1016 1017 copyStringArray(envp, envp_array_base, env_data_base, initVirtMem); 1018 copyStringArray(argv, argv_array_base, arg_data_base, initVirtMem); 1019 1020 initVirtMem.writeBlob(argc_base, (uint8_t*)&guestArgc, intSize); 1021 1022 ThreadContext *tc = system->getThreadContext(contextIds[0]); | 1009 const uint64_t zero = 0; 1010 initVirtMem.writeBlob(auxv_array_base + auxv.size() * 2 * intSize, 1011 (uint8_t*)&zero, intSize); 1012 initVirtMem.writeBlob(auxv_array_base + (auxv.size() * 2 + 1) * intSize, 1013 (uint8_t*)&zero, intSize); 1014 1015 initVirtMem.writeString(aux_data_base, platform.c_str()); 1016 1017 copyStringArray(envp, envp_array_base, env_data_base, initVirtMem); 1018 copyStringArray(argv, argv_array_base, arg_data_base, initVirtMem); 1019 1020 initVirtMem.writeBlob(argc_base, (uint8_t*)&guestArgc, intSize); 1021 1022 ThreadContext *tc = system->getThreadContext(contextIds[0]); |
1023 //Set the stack pointer register | 1023 // Set the stack pointer register |
1024 tc->setIntReg(StackPointerReg, stack_min); 1025 1026 // There doesn't need to be any segment base added in since we're dealing 1027 // with the flat segmentation model. 1028 tc->pcState(getStartPC()); 1029 | 1024 tc->setIntReg(StackPointerReg, stack_min); 1025 1026 // There doesn't need to be any segment base added in since we're dealing 1027 // with the flat segmentation model. 1028 tc->pcState(getStartPC()); 1029 |
1030 //Align the "stack_min" to a page boundary. | 1030 // Align the "stack_min" to a page boundary. |
1031 memState->setStackMin(roundDown(stack_min, pageSize)); 1032} 1033 1034void 1035X86_64Process::argsInit(int pageSize) 1036{ 1037 std::vector<AuxVector<uint64_t> > extraAuxvs; 1038 extraAuxvs.push_back(AuxVector<uint64_t>(M5_AT_SYSINFO_EHDR, --- 76 unchanged lines hidden --- | 1031 memState->setStackMin(roundDown(stack_min, pageSize)); 1032} 1033 1034void 1035X86_64Process::argsInit(int pageSize) 1036{ 1037 std::vector<AuxVector<uint64_t> > extraAuxvs; 1038 extraAuxvs.push_back(AuxVector<uint64_t>(M5_AT_SYSINFO_EHDR, --- 76 unchanged lines hidden --- |