arch,sim: Make copyStringArray take an explicit endianness.
authorGabe Black <gabeblack@google.com>
Tue, 29 Oct 2019 22:59:35 +0000 (15:59 -0700)
committerGabe Black <gabeblack@google.com>
Wed, 30 Oct 2019 22:29:23 +0000 (22:29 +0000)
Change-Id: I5cf4291b19dd2d2bdbbf145ad8e00994fabf5547
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/22366
Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com>
Reviewed-by: Brandon Potter <Brandon.Potter@amd.com>
Maintainer: Gabe Black <gabeblack@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
src/arch/alpha/process.cc
src/arch/arm/process.cc
src/arch/mips/process.cc
src/arch/power/process.cc
src/arch/sparc/process.cc
src/arch/x86/process.cc
src/sim/process_impl.hh

index 9311a6415806a87168ee3bf1cfbaf96a54a76428..11fa187b134c565f1e9cf211398752bae5d7c82f 100644 (file)
@@ -156,8 +156,10 @@ AlphaProcess::argsInit(int intSize, int pageSize)
 
     initVirtMem.writeBlob(memState->getStackMin(), &argc, intSize);
 
-    copyStringArray(argv, argv_array_base, arg_data_base, initVirtMem);
-    copyStringArray(envp, envp_array_base, env_data_base, initVirtMem);
+    copyStringArray(argv, argv_array_base, arg_data_base,
+                    LittleEndianByteOrder, initVirtMem);
+    copyStringArray(envp, envp_array_base, env_data_base,
+                    LittleEndianByteOrder, initVirtMem);
 
     //Copy the aux stuff
     Addr auxv_array_end = auxv_array_base;
index d9b714c4448468e03c561644095bec572657c18c..cacbe3ad56ae8ab2a08e86f9cff1fcb35215d5d5 100644 (file)
@@ -434,8 +434,10 @@ ArmProcess::argsInit(int pageSize, IntRegIndex spIndex)
     initVirtMem.write(auxv_array_end, zero);
     auxv_array_end += sizeof(zero);
 
-    copyStringArray(envp, envp_array_base, env_data_base, initVirtMem);
-    copyStringArray(argv, argv_array_base, arg_data_base, initVirtMem);
+    copyStringArray(envp, envp_array_base, env_data_base,
+                    LittleEndianByteOrder, initVirtMem);
+    copyStringArray(argv, argv_array_base, arg_data_base,
+                    LittleEndianByteOrder, initVirtMem);
 
     initVirtMem.writeBlob(argc_base, &guestArgc, intSize);
 
index 8e1e22b6618ceb6bd92a44f0b1197637d97e1c2f..f5aae732cba8a8321ef6082b103964bf137de7b7 100644 (file)
@@ -165,9 +165,11 @@ MipsProcess::argsInit(int pageSize)
 
     initVirtMem.writeBlob(memState->getStackMin(), &argc, intSize);
 
-    copyStringArray(argv, argv_array_base, arg_data_base, initVirtMem);
+    copyStringArray(argv, argv_array_base, arg_data_base,
+                    LittleEndianByteOrder, initVirtMem);
 
-    copyStringArray(envp, envp_array_base, env_data_base, initVirtMem);
+    copyStringArray(envp, envp_array_base, env_data_base,
+                    LittleEndianByteOrder, initVirtMem);
 
     // Copy the aux vector
     Addr auxv_array_end = auxv_array_base;
index 7b53d70389edbb21c98b4b7ae18345871d555912..30685f0ba15618c23f4940f33caff762d45fc3f9 100644 (file)
@@ -254,8 +254,10 @@ PowerProcess::argsInit(int intSize, int pageSize)
     initVirtMem.write(auxv_array_end, zero);
     auxv_array_end += sizeof(zero);
 
-    copyStringArray(envp, envp_array_base, env_data_base, initVirtMem);
-    copyStringArray(argv, argv_array_base, arg_data_base, initVirtMem);
+    copyStringArray(envp, envp_array_base, env_data_base,
+                    BigEndianByteOrder, initVirtMem);
+    copyStringArray(argv, argv_array_base, arg_data_base,
+                    BigEndianByteOrder, initVirtMem);
 
     initVirtMem.writeBlob(argc_base, &guestArgc, intSize);
 
index 048c7e957d4d5ac272c18cc1c747574e5cb4123f..33ae689758c901ca7a028515bb39ba884bbef075 100644 (file)
@@ -375,8 +375,10 @@ SparcProcess::argsInit(int pageSize)
     initVirtMem.write(auxv_array_end, zero);
     auxv_array_end += sizeof(zero);
 
-    copyStringArray(envp, envp_array_base, env_data_base, initVirtMem);
-    copyStringArray(argv, argv_array_base, arg_data_base, initVirtMem);
+    copyStringArray(envp, envp_array_base, env_data_base,
+                    BigEndianByteOrder, initVirtMem);
+    copyStringArray(argv, argv_array_base, arg_data_base,
+                    BigEndianByteOrder, initVirtMem);
 
     initVirtMem.writeBlob(argc_base, &guestArgc, intSize);
 
index 11b46c8242274182b4cef0badd41d7df48e77baf..f90c764ee40ab934dcce653d5d1eb027cf36a7d7 100644 (file)
@@ -1017,8 +1017,10 @@ X86Process::argsInit(int pageSize,
 
     initVirtMem.writeString(aux_data_base, platform.c_str());
 
-    copyStringArray(envp, envp_array_base, env_data_base, initVirtMem);
-    copyStringArray(argv, argv_array_base, arg_data_base, initVirtMem);
+    copyStringArray(envp, envp_array_base, env_data_base,
+                    LittleEndianByteOrder, initVirtMem);
+    copyStringArray(argv, argv_array_base, arg_data_base,
+                    LittleEndianByteOrder, initVirtMem);
 
     initVirtMem.writeBlob(argc_base, &guestArgc, intSize);
 
index 75134121bcefbd8acc2ffc1786cf499575bbccfc..da51c7f84b4a28581133fb307d610cc927805d88 100644 (file)
@@ -42,11 +42,11 @@ template<class AddrType>
 void
 copyStringArray(std::vector<std::string> &strings,
         AddrType array_ptr, AddrType data_ptr,
-        PortProxy& memProxy)
+        const ByteOrder bo, PortProxy& memProxy)
 {
     AddrType data_ptr_swap;
     for (std::vector<std::string>::size_type i = 0; i < strings.size(); ++i) {
-        data_ptr_swap = TheISA::htog(data_ptr);
+        data_ptr_swap = htog(data_ptr, bo);
         memProxy.writeBlob(array_ptr, &data_ptr_swap, sizeof(AddrType));
         memProxy.writeString(data_ptr, strings[i].c_str());
         array_ptr += sizeof(AddrType);