Gabe Black has uploaded this change for review. ( https://gem5-review.googlesource.com/c/public/gem5/+/45907 )

Change subject: misc: Stop using getVirtProxy.
......................................................................

misc: Stop using getVirtProxy.

The proxies are not used on the critical path, and it's usually implicit
whether they should be the FS or SE version.

Ideally in the future we won't need to worry about which version we need
to use, but the differences haven't quite been abstracted away, and
occasionally we need to decide between the two.

Change-Id: Idb363d6ddc681f7c1ad5e7aba69865f40aa30dc8
---
M src/arch/arm/aapcs32.hh
M src/arch/arm/freebsd/se_workload.cc
M src/arch/arm/linux/process.cc
M src/arch/arm/linux/se_workload.cc
M src/arch/arm/semihosting.cc
M src/arch/arm/tracers/tarmac_parser.cc
M src/arch/generic/linux/threadinfo.hh
M src/arch/sparc/linux/syscalls.cc
M src/arch/sparc/se_workload.cc
M src/arch/x86/linux/se_workload.cc
M src/arch/x86/linux/syscalls.cc
M src/base/remote_gdb.cc
M src/gpu-compute/gpu_command_processor.cc
M src/gpu-compute/gpu_compute_driver.cc
M src/kern/linux/helpers.cc
M src/kern/linux/printk.cc
M src/sim/process.cc
M src/sim/pseudo_inst.cc
M src/sim/syscall_emul.cc
M src/sim/syscall_emul.hh
20 files changed, 209 insertions(+), 139 deletions(-)



diff --git a/src/arch/arm/aapcs32.hh b/src/arch/arm/aapcs32.hh
index e1bd505..eed7519 100644
--- a/src/arch/arm/aapcs32.hh
+++ b/src/arch/arm/aapcs32.hh
@@ -38,6 +38,9 @@
 #include "base/intmath.hh"
 #include "cpu/thread_context.hh"
 #include "mem/port_proxy.hh"
+#include "mem/se_translating_port_proxy.hh"
+#include "mem/translating_port_proxy.hh"
+#include "sim/full_system.hh"
 #include "sim/guest_abi.hh"
 #include "sim/proxy_ptr.hh"

@@ -339,7 +342,9 @@
             }

             if (bytes) {
-                tc->getVirtProxy().readBlob(state.nsaa, buf, bytes);
+                (FullSystem ? TranslatingPortProxy(tc) :
+                    SETranslatingPortProxy(tc)).readBlob(
+                    state.nsaa, buf, bytes);

                 state.stackUsed = true;
                 state.nsaa += roundUp(bytes, 4);
diff --git a/src/arch/arm/freebsd/se_workload.cc b/src/arch/arm/freebsd/se_workload.cc
index 5e52485..a75f1dd 100644
--- a/src/arch/arm/freebsd/se_workload.cc
+++ b/src/arch/arm/freebsd/se_workload.cc
@@ -42,6 +42,7 @@
 #include "base/loader/object_file.hh"
 #include "base/trace.hh"
 #include "cpu/thread_context.hh"
+#include "mem/se_translating_port_proxy.hh"
 #include "sim/syscall_emul.hh"

 namespace
@@ -91,18 +92,20 @@
 {
     uint64_t ret;

+    SETranslatingPortProxy proxy(tc);
+
     BufferArg buf(namep, sizeof(size_t));
     BufferArg buf2(oldp, sizeof(size_t));
     BufferArg buf3(oldlenp, sizeof(size_t));
     BufferArg buf4(newp, sizeof(size_t));

-    buf.copyIn(tc->getVirtProxy());
-    buf2.copyIn(tc->getVirtProxy());
-    buf3.copyIn(tc->getVirtProxy());
+    buf.copyIn(proxy);
+    buf2.copyIn(proxy);
+    buf3.copyIn(proxy);

     void *hnewp = NULL;
     if (newp) {
-        buf4.copyIn(tc->getVirtProxy());
+        buf4.copyIn(proxy);
         hnewp = (void *)buf4.bufferPtr();
     }

@@ -112,11 +115,11 @@

     ret = sysctl((int *)hnamep, nameLen, holdp, holdlenp, hnewp, newlen);

-    buf.copyOut(tc->getVirtProxy());
-    buf2.copyOut(tc->getVirtProxy());
-    buf3.copyOut(tc->getVirtProxy());
+    buf.copyOut(proxy);
+    buf2.copyOut(proxy);
+    buf3.copyOut(proxy);
     if (newp)
-        buf4.copyOut(tc->getVirtProxy());
+        buf4.copyOut(proxy);

     return (ret);
 }
diff --git a/src/arch/arm/linux/process.cc b/src/arch/arm/linux/process.cc
index 8b20e59..505484e 100644
--- a/src/arch/arm/linux/process.cc
+++ b/src/arch/arm/linux/process.cc
@@ -49,6 +49,7 @@
 #include "base/trace.hh"
 #include "cpu/thread_context.hh"
 #include "kern/linux/linux.hh"
+#include "mem/se_translating_port_proxy.hh"
 #include "sim/process.hh"
 #include "sim/syscall_desc.hh"
 #include "sim/syscall_emul.hh"
@@ -69,10 +70,10 @@
         0xff, 0xff, 0xff, 0xef  // swi -1
     };

+    SETranslatingPortProxy proxy(tc);
     // Fill this page with swi -1 so we'll no if we land in it somewhere.
     for (Addr addr = 0; addr < PageBytes; addr += sizeof(swiNeg1)) {
-        tc->getVirtProxy().writeBlob(commPage + addr,
-                                     swiNeg1, sizeof(swiNeg1));
+        proxy.writeBlob(commPage + addr, swiNeg1, sizeof(swiNeg1));
     }

     uint8_t memory_barrier[] =
@@ -80,8 +81,7 @@
         0x5f, 0xf0, 0x7f, 0xf5, // dmb
         0x0e, 0xf0, 0xa0, 0xe1  // return
     };
-    tc->getVirtProxy().writeBlob(commPage + 0x0fa0, memory_barrier,
-                                 sizeof(memory_barrier));
+ proxy.writeBlob(commPage + 0x0fa0, memory_barrier, sizeof(memory_barrier));

     uint8_t cmpxchg[] =
     {
@@ -94,7 +94,7 @@
         0x5f, 0xf0, 0x7f, 0xf5,  // dmb
         0x0e, 0xf0, 0xa0, 0xe1   // return
     };
- tc->getVirtProxy().writeBlob(commPage + 0x0fc0, cmpxchg, sizeof(cmpxchg));
+    proxy.writeBlob(commPage + 0x0fc0, cmpxchg, sizeof(cmpxchg));

     uint8_t get_tls[] =
     {
@@ -102,7 +102,7 @@
         0x70, 0x0f, 0x1d, 0xee, // mrc p15, 0, r0, c13, c0, 3
         0x0e, 0xf0, 0xa0, 0xe1  // return
     };
- tc->getVirtProxy().writeBlob(commPage + 0x0fe0, get_tls, sizeof(get_tls));
+    proxy.writeBlob(commPage + 0x0fe0, get_tls, sizeof(get_tls));
 }

 void
diff --git a/src/arch/arm/linux/se_workload.cc b/src/arch/arm/linux/se_workload.cc
index 8080b2b..ee1ccba 100644
--- a/src/arch/arm/linux/se_workload.cc
+++ b/src/arch/arm/linux/se_workload.cc
@@ -46,6 +46,7 @@
 #include "base/loader/object_file.hh"
 #include "base/trace.hh"
 #include "cpu/thread_context.hh"
+#include "mem/se_translating_port_proxy.hh"
 #include "sim/syscall_emul.hh"

 namespace
@@ -126,8 +127,8 @@
 static SyscallReturn
 setTLSFunc32(SyscallDesc *desc, ThreadContext *tc, uint32_t tlsPtr)
 {
-    tc->getVirtProxy().writeBlob(ArmLinuxProcess32::commPage + 0x0ff0,
-                                &tlsPtr, sizeof(tlsPtr));
+    SETranslatingPortProxy(tc).writeBlob(
+            ArmLinuxProcess32::commPage + 0x0ff0, &tlsPtr, sizeof(tlsPtr));
     tc->setMiscReg(MISCREG_TPIDRURO, tlsPtr);
     return 0;
 }
diff --git a/src/arch/arm/semihosting.cc b/src/arch/arm/semihosting.cc
index 989d74c..ba33241 100644
--- a/src/arch/arm/semihosting.cc
+++ b/src/arch/arm/semihosting.cc
@@ -246,6 +246,7 @@
 ArmSemihosting::portProxy(ThreadContext *tc)
 {
     static std::unique_ptr<PortProxy> port_proxy_s;
+    static std::unique_ptr<PortProxy> port_proxy_ns;
     static System *secure_sys = nullptr;

     if (ArmISA::isSecure(tc)) {
@@ -264,7 +265,15 @@
         secure_sys = sys;
         return *port_proxy_s;
     } else {
-        return tc->getVirtProxy();
+        if (!port_proxy_ns) {
+            if (FullSystem) {
+                port_proxy_ns.reset(new TranslatingPortProxy(tc));
+            } else {
+                port_proxy_ns.reset(new SETranslatingPortProxy(tc));
+            }
+        }
+
+        return *port_proxy_ns;
     }
 }

diff --git a/src/arch/arm/tracers/tarmac_parser.cc b/src/arch/arm/tracers/tarmac_parser.cc
index db9c7e1..ba4801d 100644
--- a/src/arch/arm/tracers/tarmac_parser.cc
+++ b/src/arch/arm/tracers/tarmac_parser.cc
@@ -50,8 +50,11 @@
 #include "cpu/thread_context.hh"
 #include "mem/packet.hh"
 #include "mem/port_proxy.hh"
+#include "mem/se_translating_port_proxy.hh"
+#include "mem/translating_port_proxy.hh"
 #include "sim/core.hh"
 #include "sim/faults.hh"
+#include "sim/full_system.hh"
 #include "sim/sim_exit.hh"

 using namespace ArmISA;
@@ -1308,7 +1311,8 @@
             return false;
         // the translating proxy will perform the virtual to physical
         // translation again
-        thread->getVirtProxy().readBlob(addr, data, size);
+        (FullSystem ? TranslatingPortProxy(thread) :
+         SETranslatingPortProxy(thread)).readBlob(addr, data, size);
     } else {
         return false;
     }
diff --git a/src/arch/generic/linux/threadinfo.hh b/src/arch/generic/linux/threadinfo.hh
index e5ba7e2..ec1d486 100644
--- a/src/arch/generic/linux/threadinfo.hh
+++ b/src/arch/generic/linux/threadinfo.hh
@@ -30,6 +30,7 @@
 #define __ARCH_GENERIC_LINUX_THREADINFO_HH__

 #include "cpu/thread_context.hh"
+#include "mem/translating_port_proxy.hh"
 #include "sim/system.hh"

 namespace Linux {
@@ -55,7 +56,7 @@
             return false;
         }

-        data = tc->getVirtProxy().read<T>(it->address, byteOrder);
+        data = TranslatingPortProxy(tc).read<T>(it->address, byteOrder);

         return true;
     }
@@ -89,7 +90,7 @@
         if (!thread_info)
             thread_info = curThreadInfo();

-        return tc->getVirtProxy().read<Addr>(thread_info + offset);
+        return TranslatingPortProxy(tc).read<Addr>(thread_info + offset);
     }

     int32_t
@@ -99,7 +100,7 @@
         if (!get_data("task_struct_pid", offset))
             return -1;

-        return tc->getVirtProxy().read<int32_t>(task_struct + offset);
+ return TranslatingPortProxy(tc).read<int32_t>(task_struct + offset);
     }

     int32_t
@@ -115,7 +116,7 @@
         if (!get_data("task_struct_tgid", offset))
             return -1;

-        return tc->getVirtProxy().read<int32_t>(task_struct + offset);
+ return TranslatingPortProxy(tc).read<int32_t>(task_struct + offset);
     }

     int32_t
@@ -133,7 +134,7 @@

         // start_time is actually of type timespec, but if we just
         // grab the first long, we'll get the seconds out of it
-        return tc->getVirtProxy().read<int64_t>(task_struct + offset);
+ return TranslatingPortProxy(tc).read<int64_t>(task_struct + offset);
     }

     int64_t
@@ -155,7 +156,8 @@
             return "FailureIn_curTaskName";

         char buffer[size + 1];
-        tc->getVirtProxy().readString(buffer, task_struct + offset, size);
+        TranslatingPortProxy(tc).readString(
+                buffer, task_struct + offset, size);

         return buffer;
     }
@@ -173,7 +175,7 @@
         if (!get_data("task_struct_mm", offset))
             return -1;

-        return tc->getVirtProxy().read<int32_t>(task_struct + offset);
+ return TranslatingPortProxy(tc).read<int32_t>(task_struct + offset);
     }

     int32_t
diff --git a/src/arch/sparc/linux/syscalls.cc b/src/arch/sparc/linux/syscalls.cc
index 17cc705..48af787 100644
--- a/src/arch/sparc/linux/syscalls.cc
+++ b/src/arch/sparc/linux/syscalls.cc
@@ -27,6 +27,7 @@
  */

 #include "arch/sparc/linux/se_workload.hh"
+#include "mem/se_translating_port_proxy.hh"
 #include "sim/syscall_desc.hh"
 #include "sim/syscall_emul.hh"

@@ -56,25 +57,26 @@
 getresuidFunc(SyscallDesc *desc, ThreadContext *tc,
               VPtr<> ruid, VPtr<> euid, VPtr<> suid)
 {
+    SETranslatingPortProxy proxy(tc);
     const uint64_t id = htobe(100);
     // Handle the EFAULT case
     // Set the ruid
     if (ruid) {
         BufferArg ruidBuff(ruid, sizeof(uint64_t));
         memcpy(ruidBuff.bufferPtr(), &id, sizeof(uint64_t));
-        ruidBuff.copyOut(tc->getVirtProxy());
+        ruidBuff.copyOut(proxy);
     }
     // Set the euid
     if (euid) {
         BufferArg euidBuff(euid, sizeof(uint64_t));
         memcpy(euidBuff.bufferPtr(), &id, sizeof(uint64_t));
-        euidBuff.copyOut(tc->getVirtProxy());
+        euidBuff.copyOut(proxy);
     }
     // Set the suid
     if (suid) {
         BufferArg suidBuff(suid, sizeof(uint64_t));
         memcpy(suidBuff.bufferPtr(), &id, sizeof(uint64_t));
-        suidBuff.copyOut(tc->getVirtProxy());
+        suidBuff.copyOut(proxy);
     }
     return 0;
 }
diff --git a/src/arch/sparc/se_workload.cc b/src/arch/sparc/se_workload.cc
index b651b05..1cda081 100644
--- a/src/arch/sparc/se_workload.cc
+++ b/src/arch/sparc/se_workload.cc
@@ -33,6 +33,7 @@
 #include "arch/sparc/types.hh"
 #include "base/logging.hh"
 #include "cpu/thread_context.hh"
+#include "mem/translating_port_proxy.hh"

 namespace SparcISA
 {
@@ -102,6 +103,8 @@
     const size_t reg_bytes = is_64 ? 8 : 4;
     uint8_t bytes[8];

+    SETranslatingPortProxy proxy(tc);
+
     CWP = (CWP + Cansave + 2) % NWindows;
     while (NWindows - 2 - Cansave != 0) {
         panic_if(Otherwin, "Otherwin non-zero.");
@@ -119,7 +122,7 @@
                 uint32_t regVal = htobe<uint32_t>(tc->readIntReg(index));
                 memcpy(bytes, &regVal, reg_bytes);
             }
-            if (!tc->getVirtProxy().tryWriteBlob(addr, bytes, reg_bytes)) {
+            if (!proxy.tryWriteBlob(addr, bytes, reg_bytes)) {
                 warn("Failed to save register to the stack when "
                         "flushing windows.");
             }
diff --git a/src/arch/x86/linux/se_workload.cc b/src/arch/x86/linux/se_workload.cc
index 66e4763..04981d7 100644
--- a/src/arch/x86/linux/se_workload.cc
+++ b/src/arch/x86/linux/se_workload.cc
@@ -47,6 +47,7 @@
 #include "base/trace.hh"
 #include "cpu/thread_context.hh"
 #include "kern/linux/linux.hh"
+#include "mem/se_translating_port_proxy.hh"
 #include "sim/process.hh"
 #include "sim/syscall_desc.hh"
 #include "sim/syscall_emul.hh"
@@ -148,7 +149,7 @@
 {
     Process *p = tc->getProcessPtr();
     if (!p->fixupFault(tc->readMiscReg(MISCREG_CR2))) {
-        PortProxy &proxy = tc->getVirtProxy();
+        SETranslatingPortProxy proxy(tc);
         // at this point we should have 6 values on the interrupt stack
         int size = 6;
         uint64_t is[size];
diff --git a/src/arch/x86/linux/syscalls.cc b/src/arch/x86/linux/syscalls.cc
index b64e4c7..405f676 100644
--- a/src/arch/x86/linux/syscalls.cc
+++ b/src/arch/x86/linux/syscalls.cc
@@ -32,6 +32,7 @@
 #include "base/trace.hh"
 #include "cpu/thread_context.hh"
 #include "kern/linux/linux.hh"
+#include "mem/se_translating_port_proxy.hh"
 #include "sim/process.hh"
 #include "sim/syscall_desc.hh"
 #include "sim/syscall_emul.hh"
@@ -66,7 +67,7 @@
     };

     uint64_t fsBase, gsBase;
-    PortProxy &p = tc->getVirtProxy();
+    SETranslatingPortProxy p(tc);
     switch(code)
     {
       // Each of these valid options should actually check addr.
@@ -100,6 +101,7 @@
     const int maxTLSEntry = minTLSEntry + numTLSEntries - 1;

     auto process = tc->getProcessPtr();
+    SETranslatingPortProxy proxy(tc);

     X86Process *x86p = dynamic_cast<X86Process *>(process);
     assert(x86p);
@@ -110,7 +112,7 @@
         gdt(x86p->gdtStart() + minTLSEntry * sizeof(uint64_t),
             numTLSEntries * sizeof(uint64_t));

-    if (!gdt.copyIn(tc->getVirtProxy()))
+    if (!gdt.copyIn(proxy))
         panic("Failed to copy in GDT for %s.\n", desc->name());

     if (userDesc->entry_number == (uint32_t)(-1)) {
@@ -162,7 +164,7 @@

     gdt[index] = (uint64_t)segDesc;

-    if (!gdt.copyOut(tc->getVirtProxy()))
+    if (!gdt.copyOut(proxy))
         panic("Failed to copy out GDT for %s.\n", desc->name());

     return 0;
diff --git a/src/base/remote_gdb.cc b/src/base/remote_gdb.cc
index 4c54e64..e181fd7 100644
--- a/src/base/remote_gdb.cc
+++ b/src/base/remote_gdb.cc
@@ -152,6 +152,8 @@
 #include "debug/GDBAll.hh"
 #include "mem/port.hh"
 #include "mem/port_proxy.hh"
+#include "mem/se_translating_port_proxy.hh"
+#include "mem/translating_port_proxy.hh"
 #include "sim/full_system.hh"
 #include "sim/system.hh"

@@ -678,8 +680,8 @@
 {
     DPRINTF(GDBRead, "read:  addr=%#x, size=%d", vaddr, size);

-    PortProxy &proxy = tc->getVirtProxy();
-    proxy.readBlob(vaddr, data, size);
+    (FullSystem ? TranslatingPortProxy(tc) : SETranslatingPortProxy(tc)).
+        readBlob(vaddr, data, size);

 #if TRACING_ON
     if (Debug::GDBRead) {
@@ -708,8 +710,8 @@
         } else
             DPRINTFNR("\n");
     }
-    PortProxy &proxy = tc->getVirtProxy();
-    proxy.writeBlob(vaddr, data, size);
+    (FullSystem ? TranslatingPortProxy(tc) : SETranslatingPortProxy(tc)).
+        writeBlob(vaddr, data, size);

     return true;
 }
diff --git a/src/gpu-compute/gpu_command_processor.cc b/src/gpu-compute/gpu_command_processor.cc
index 9bdd0b9..f4b8b4a 100644
--- a/src/gpu-compute/gpu_command_processor.cc
+++ b/src/gpu-compute/gpu_command_processor.cc
@@ -39,7 +39,10 @@
 #include "debug/GPUCommandProc.hh"
 #include "debug/GPUKernelInfo.hh"
 #include "gpu-compute/dispatcher.hh"
+#include "mem/se_translating_port_proxy.hh"
+#include "mem/translating_port_proxy.hh"
 #include "params/GPUCommandProcessor.hh"
+#include "sim/full_system.hh"
 #include "sim/process.hh"
 #include "sim/proxy_ptr.hh"
 #include "sim/syscall_emul_buf.hh"
@@ -143,7 +146,10 @@
      * space to pull out the kernel code descriptor.
      */
     auto *tc = sys->threads[0];
-    auto &virt_proxy = tc->getVirtProxy();
+
+    TranslatingPortProxy fs_proxy(tc);
+    SETranslatingPortProxy se_proxy(tc);
+    PortProxy &virt_proxy = FullSystem ? fs_proxy : se_proxy;

     /**
      * The kernel_object is a pointer to the machine code, whose entry
diff --git a/src/gpu-compute/gpu_compute_driver.cc b/src/gpu-compute/gpu_compute_driver.cc
index cd537c3..2c1bbb2 100644
--- a/src/gpu-compute/gpu_compute_driver.cc
+++ b/src/gpu-compute/gpu_compute_driver.cc
@@ -47,7 +47,10 @@
 #include "gpu-compute/gpu_command_processor.hh"
 #include "gpu-compute/shader.hh"
 #include "mem/port_proxy.hh"
+#include "mem/se_translating_port_proxy.hh"
+#include "mem/translating_port_proxy.hh"
 #include "params/GPUComputeDriver.hh"
+#include "sim/full_system.hh"
 #include "sim/process.hh"
 #include "sim/syscall_emul_buf.hh"

@@ -217,7 +220,9 @@
 int
 GPUComputeDriver::ioctl(ThreadContext *tc, unsigned req, Addr ioc_buf)
 {
-    auto &virt_proxy = tc->getVirtProxy();
+    TranslatingPortProxy fs_proxy(tc);
+    SETranslatingPortProxy se_proxy(tc);
+    PortProxy &virt_proxy = FullSystem ? fs_proxy : se_proxy;
     auto process = tc->getProcessPtr();
     auto mem_state = process->memState;

diff --git a/src/kern/linux/helpers.cc b/src/kern/linux/helpers.cc
index 86a11c7..9b2dd60 100644
--- a/src/kern/linux/helpers.cc
+++ b/src/kern/linux/helpers.cc
@@ -41,6 +41,7 @@
 #include "config/the_isa.hh"
 #include "cpu/thread_context.hh"
 #include "mem/port_proxy.hh"
+#include "mem/translating_port_proxy.hh"
 #include "sim/byteswap.hh"
 #include "sim/system.hh"

@@ -95,7 +96,7 @@
     System *system = tc->getSystemPtr();
     const ByteOrder bo = system->getGuestByteOrder();
     const auto &symtab = system->workload->symtab(tc);
-    PortProxy &proxy = tc->getVirtProxy();
+    TranslatingPortProxy proxy(tc);

     auto lb = symtab.find("__log_buf");
     auto lb_len = symtab.find("log_buf_len");
diff --git a/src/kern/linux/printk.cc b/src/kern/linux/printk.cc
index d2bf414..c50ba9a 100644
--- a/src/kern/linux/printk.cc
+++ b/src/kern/linux/printk.cc
@@ -37,6 +37,7 @@
 #include "base/compiler.hh"
 #include "cpu/thread_context.hh"
 #include "mem/port_proxy.hh"
+#include "mem/translating_port_proxy.hh"

 namespace Linux
 {
@@ -47,7 +48,8 @@
 {
     std::string format;
     std::ostringstream out;
-    tc->getVirtProxy().readString(format, format_ptr);
+    TranslatingPortProxy proxy(tc);
+    proxy.readString(format, format_ptr);

     const char *p = format.c_str();

@@ -177,7 +179,7 @@
                     Addr s_ptr = args.get<Addr>();
                     std::string s;
                     if (s_ptr)
-                        tc->getVirtProxy().readString(s, s_ptr);
+                        proxy.readString(s, s_ptr);
                     else
                         s = "<NULL>";

@@ -215,7 +217,7 @@
                     uint64_t n = args.get<uint64_t>();
                     Addr s_ptr = args.get<Addr>();
                     std::string s;
-                    tc->getVirtProxy().readString(s, s_ptr);
+                    proxy.readString(s, s_ptr);
                     out << s << ": " << n;
                 }
                 break;
diff --git a/src/sim/process.cc b/src/sim/process.cc
index 1e5810e..5310ce0 100644
--- a/src/sim/process.cc
+++ b/src/sim/process.cc
@@ -337,13 +337,13 @@

     // Read from old physical page.
     uint8_t buf_p[pTable->pageSize()];
-    old_tc->getVirtProxy().readBlob(vaddr, buf_p, sizeof(buf_p));
+    SETranslatingPortProxy(old_tc).readBlob(vaddr, buf_p, sizeof(buf_p));

     // Create new mapping in process address space by clobbering existing
     // mapping (if any existed) and then write to the new physical page.
     bool clobber = true;
     pTable->map(vaddr, new_paddr, sizeof(buf_p), clobber);
-    new_tc->getVirtProxy().writeBlob(vaddr, buf_p, sizeof(buf_p));
+    SETranslatingPortProxy(new_tc).writeBlob(vaddr, buf_p, sizeof(buf_p));
 }

 bool
diff --git a/src/sim/pseudo_inst.cc b/src/sim/pseudo_inst.cc
index 7dc0fc0..56ffe8f 100644
--- a/src/sim/pseudo_inst.cc
+++ b/src/sim/pseudo_inst.cc
@@ -60,7 +60,10 @@
 #include "debug/Quiesce.hh"
 #include "debug/WorkItems.hh"
 #include "dev/net/dist_iface.hh"
+#include "mem/se_translating_port_proxy.hh"
+#include "mem/translating_port_proxy.hh"
 #include "params/BaseCPU.hh"
+#include "sim/full_system.hh"
 #include "sim/process.hh"
 #include "sim/serialize.hh"
 #include "sim/sim_events.hh"
@@ -256,7 +259,8 @@
             addr, symbolAddr);

     std::string symbol;
-    tc->getVirtProxy().readString(symbol, symbolAddr);
+    (FullSystem ? TranslatingPortProxy(tc) : SETranslatingPortProxy(tc)).
+        readString(symbol, symbolAddr);

     DPRINTF(Loader, "Loaded symbol: %s @ %#llx\n", symbol, addr);

@@ -385,7 +389,8 @@
     }

     close(fd);
-    tc->getVirtProxy().writeBlob(vaddr, buf, result);
+    (FullSystem ? TranslatingPortProxy(tc) : SETranslatingPortProxy(tc)).
+        writeBlob(vaddr, buf, result);
     delete [] buf;
     return result;
 }
@@ -399,7 +404,8 @@

     // copy out target filename
     std::string filename;
-    tc->getVirtProxy().readString(filename, filename_addr);
+    (FullSystem ? TranslatingPortProxy(tc) : SETranslatingPortProxy(tc)).
+        readString(filename, filename_addr);

     OutputStream *out;
     if (offset == 0) {
@@ -424,7 +430,8 @@

     // copy out data and write to file
     char *buf = new char[len];
-    tc->getVirtProxy().readBlob(vaddr, buf, len);
+    (FullSystem ? TranslatingPortProxy(tc) : SETranslatingPortProxy(tc)).
+        readBlob(vaddr, buf, len);
     os->write(buf, len);
     if (os->fail() || os->bad())
         panic("Error while doing writefile!\n");
diff --git a/src/sim/syscall_emul.cc b/src/sim/syscall_emul.cc
index 291847a..64be402 100644
--- a/src/sim/syscall_emul.cc
+++ b/src/sim/syscall_emul.cc
@@ -44,6 +44,7 @@
 #include "cpu/thread_context.hh"
 #include "dev/net/dist_iface.hh"
 #include "mem/page_table.hh"
+#include "mem/se_translating_port_proxy.hh"
 #include "sim/byteswap.hh"
 #include "sim/process.hh"
 #include "sim/proxy_ptr.hh"
@@ -94,7 +95,7 @@
     BufferArg ctidBuf(addr, sizeof(long));
     long *ctid = (long *)ctidBuf.bufferPtr();
     *ctid = 0;
-    ctidBuf.copyOut(tc->getVirtProxy());
+    ctidBuf.copyOut(SETranslatingPortProxy(tc));

     FutexMap &futex_map = tc->getSystemPtr()->futexMap;
     // Wake one of the waiting threads.
@@ -318,7 +319,7 @@
     // Assuming that the size of loff_t is 64 bits on the target platform
     BufferArg result_buf(result_ptr, sizeof(result));
     std::memcpy(result_buf.bufferPtr(), &result, sizeof(result));
-    result_buf.copyOut(tc->getVirtProxy());
+    result_buf.copyOut(SETranslatingPortProxy(tc));
     return 0;
 }

@@ -351,7 +352,7 @@
 {
     BufferArg name(buf_ptr, name_len);
     strncpy((char *)name.bufferPtr(), hostname, name_len);
-    name.copyOut(tc->getVirtProxy());
+    name.copyOut(SETranslatingPortProxy(tc));
     return 0;
 }

@@ -380,7 +381,7 @@
         }
     }

-    buf.copyOut(tc->getVirtProxy());
+    buf.copyOut(SETranslatingPortProxy(tc));

     return (result == -1) ? -errno : result;
 }
@@ -392,7 +393,7 @@
     std::string path;
     auto p = tc->getProcessPtr();

-    if (!tc->getVirtProxy().tryReadString(path, pathname))
+    if (!SETranslatingPortProxy(tc).tryReadString(path, pathname))
         return -EFAULT;

     // Adjust path for cwd and redirection
@@ -438,7 +439,7 @@
                   (char*)buf.bufferPtr());
     }

-    buf.copyOut(tc->getVirtProxy());
+    buf.copyOut(SETranslatingPortProxy(tc));

     return (result == -1) ? -errno : result;
 }
@@ -449,7 +450,7 @@
     std::string path;
     auto p = tc->getProcessPtr();

-    if (!tc->getVirtProxy().tryReadString(path, pathname))
+    if (!SETranslatingPortProxy(tc).tryReadString(path, pathname))
         return -EFAULT;

     path = p->checkPathRedirect(path);
@@ -466,7 +467,7 @@
     std::string new_path;
     auto p = tc->getProcessPtr();

-    auto &virt_mem = tc->getVirtProxy();
+    SETranslatingPortProxy virt_mem(tc);
     if (!virt_mem.tryReadString(path, pathname))
         return -EFAULT;
     if (!virt_mem.tryReadString(new_path, new_pathname))
@@ -487,7 +488,7 @@
     std::string new_path;
     auto p = tc->getProcessPtr();

-    auto &virt_mem = tc->getVirtProxy();
+    SETranslatingPortProxy virt_mem(tc);
     if (!virt_mem.tryReadString(path, pathname))
         return -EFAULT;
     if (!virt_mem.tryReadString(new_path, new_pathname))
@@ -505,7 +506,7 @@
 {
     auto p = tc->getProcessPtr();
     std::string path;
-    if (!tc->getVirtProxy().tryReadString(path, pathname))
+    if (!SETranslatingPortProxy(tc).tryReadString(path, pathname))
         return -EFAULT;

     path = p->checkPathRedirect(path);
@@ -520,12 +521,13 @@
 {
     auto p = tc->getProcessPtr();

+    SETranslatingPortProxy proxy(tc);
     std::string old_name;
-    if (!tc->getVirtProxy().tryReadString(old_name, oldpath))
+    if (!proxy.tryReadString(old_name, oldpath))
         return -EFAULT;

     std::string new_name;
-    if (!tc->getVirtProxy().tryReadString(new_name, newpath))
+    if (!proxy.tryReadString(new_name, newpath))
         return -EFAULT;

     // Adjust path for cwd and redirection
@@ -543,7 +545,7 @@
     std::string path;
     auto p = tc->getProcessPtr();

-    if (!tc->getVirtProxy().tryReadString(path, pathname))
+    if (!SETranslatingPortProxy(tc).tryReadString(path, pathname))
         return -EFAULT;

     // Adjust path for cwd and redirection
@@ -574,7 +576,7 @@
     auto process = tc->getProcessPtr();
     std::string path;

-    if (!tc->getVirtProxy().tryReadString(path, pathname))
+    if (!SETranslatingPortProxy(tc).tryReadString(path, pathname))
         return -EFAULT;

     // Adjust path for cwd and redirection
@@ -625,7 +627,7 @@
     std::string path;
     auto p = tc->getProcessPtr();

-    if (!tc->getVirtProxy().tryReadString(path, pathname))
+    if (!SETranslatingPortProxy(tc).tryReadString(path, pathname))
         return -EFAULT;

     /* XXX endianess */
@@ -838,7 +840,7 @@
     int *buf_ptr = (int*)tgt_handle.bufferPtr();
     buf_ptr[0] = tgt_fds[0];
     buf_ptr[1] = tgt_fds[1];
-    tgt_handle.copyOut(tc->getVirtProxy());
+    tgt_handle.copyOut(SETranslatingPortProxy(tc));

     if (flags) {
// pipe2 only uses O_NONBLOCK, O_CLOEXEC, and (O_NONBLOCK | O_CLOEXEC)
@@ -998,7 +1000,7 @@
 {
     std::string path;
     auto p = tc->getProcessPtr();
-    if (!tc->getVirtProxy().tryReadString(path, pathname))
+    if (!SETranslatingPortProxy(tc).tryReadString(path, pathname))
         return -EFAULT;

     // Adjust path for cwd and redirection
@@ -1014,7 +1016,7 @@
 {
     auto p = tc->getProcessPtr();
     std::string path;
-    if (!tc->getVirtProxy().tryReadString(path, pathname))
+    if (!SETranslatingPortProxy(tc).tryReadString(path, pathname))
         return -EFAULT;

     path = p->checkPathRedirect(path);
@@ -1028,7 +1030,7 @@
 {
     auto p = tc->getProcessPtr();
     std::string path;
-    if (!tc->getVirtProxy().tryReadString(path, pathname))
+    if (!SETranslatingPortProxy(tc).tryReadString(path, pathname))
         return -EFAULT;

     std::string tgt_cwd;
@@ -1055,7 +1057,7 @@
 {
     auto p = tc->getProcessPtr();
     std::string path;
-    if (!tc->getVirtProxy().tryReadString(path, pathname))
+    if (!SETranslatingPortProxy(tc).tryReadString(path, pathname))
         return -EFAULT;

     path = p->checkPathRedirect(path);
@@ -1102,7 +1104,7 @@
         traversed += host_reclen;
     }

-    buf_arg.copyOut(tc->getVirtProxy());
+    buf_arg.copyOut(SETranslatingPortProxy(tc));
     return status;
 }
 #endif
@@ -1165,7 +1167,7 @@
     auto p = tc->getProcessPtr();

     BufferArg bufSock(buf_ptr, addrlen);
-    bufSock.copyIn(tc->getVirtProxy());
+    bufSock.copyIn(SETranslatingPortProxy(tc));

auto sfdp = std::dynamic_pointer_cast<SocketFDEntry>((*p->fds)[tgt_fd]);
     if (!sfdp)
@@ -1201,7 +1203,7 @@
     auto p = tc->getProcessPtr();

     BufferArg addr(buf_ptr, addrlen);
-    addr.copyIn(tc->getVirtProxy());
+    addr.copyIn(SETranslatingPortProxy(tc));

auto sfdp = std::dynamic_pointer_cast<SocketFDEntry>((*p->fds)[tgt_fd]);
     if (!sfdp)
@@ -1230,19 +1232,21 @@
     // Reserve buffer space.
     BufferArg bufrBuf(bufrPtr, bufrLen);

+    SETranslatingPortProxy proxy(tc);
+
     // Get address length.
     socklen_t addrLen = 0;
     if (addrlenPtr != 0) {
         // Read address length parameter.
         BufferArg addrlenBuf(addrlenPtr, sizeof(socklen_t));
-        addrlenBuf.copyIn(tc->getVirtProxy());
+        addrlenBuf.copyIn(proxy);
         addrLen = *((socklen_t *)addrlenBuf.bufferPtr());
     }

     struct sockaddr sa, *sap = NULL;
     if (addrLen != 0) {
         BufferArg addrBuf(addrPtr, addrLen);
-        addrBuf.copyIn(tc->getVirtProxy());
+        addrBuf.copyIn(proxy);
         memcpy(&sa, (struct sockaddr *)addrBuf.bufferPtr(),
                sizeof(struct sockaddr));
         sap = &sa;
@@ -1256,20 +1260,20 @@
         return -errno;

     // Pass the received data out.
-    bufrBuf.copyOut(tc->getVirtProxy());
+    bufrBuf.copyOut(proxy);

     // Copy address to addrPtr and pass it on.
     if (sap != NULL) {
         BufferArg addrBuf(addrPtr, addrLen);
         memcpy(addrBuf.bufferPtr(), sap, sizeof(sa));
-        addrBuf.copyOut(tc->getVirtProxy());
+        addrBuf.copyOut(proxy);
     }

     // Copy len to addrlenPtr and pass it on.
     if (addrLen != 0) {
         BufferArg addrlenBuf(addrlenPtr, sizeof(socklen_t));
         *(socklen_t *)addrlenBuf.bufferPtr() = addrLen;
-        addrlenBuf.copyOut(tc->getVirtProxy());
+        addrlenBuf.copyOut(proxy);
     }

     return recvd_size;
@@ -1289,13 +1293,13 @@

     // Reserve buffer space.
     BufferArg bufrBuf(bufrPtr, bufrLen);
-    bufrBuf.copyIn(tc->getVirtProxy());
+    bufrBuf.copyIn(SETranslatingPortProxy(tc));

     struct sockaddr sa, *sap = nullptr;
     memset(&sa, 0, sizeof(sockaddr));
     if (addrLen != 0) {
         BufferArg addrBuf(addrPtr, addrLen);
-        addrBuf.copyIn(tc->getVirtProxy());
+        addrBuf.copyIn(SETranslatingPortProxy(tc));
         memcpy(&sa, (sockaddr*)addrBuf.bufferPtr(), addrLen);
         sap = &sa;
     }
@@ -1336,13 +1340,15 @@
       *  };
       */

+    SETranslatingPortProxy proxy(tc);
+
     /**
* The plan with this system call is to replace all of the pointers in the * structure and the substructure with BufferArg class pointers. We will
      * copy every field from the structures into our BufferArg classes.
      */
     BufferArg msgBuf(msgPtr, sizeof(struct msghdr));
-    msgBuf.copyIn(tc->getVirtProxy());
+    msgBuf.copyIn(proxy);
     struct msghdr *msgHdr = (struct msghdr *)msgBuf.bufferPtr();

     /**
@@ -1362,7 +1368,7 @@
     if (msgHdr->msg_name) {
         /*1*/msg_name_phold = (Addr)msgHdr->msg_name;
         /*2*/nameBuf = new BufferArg(msg_name_phold, msgHdr->msg_namelen);
-        /*3*/nameBuf->copyIn(tc->getVirtProxy());
+        /*3*/nameBuf->copyIn(proxy);
         /*4*/msgHdr->msg_name = nameBuf->bufferPtr();
     }

@@ -1382,14 +1388,14 @@
         /*1*/msg_iov_phold = (Addr)msgHdr->msg_iov;
         /*2*/iovBuf = new BufferArg(msg_iov_phold, msgHdr->msg_iovlen *
                                     sizeof(struct iovec));
-        /*3*/iovBuf->copyIn(tc->getVirtProxy());
+        /*3*/iovBuf->copyIn(proxy);
         for (int i = 0; i < msgHdr->msg_iovlen; i++) {
             if (((struct iovec *)iovBuf->bufferPtr())[i].iov_base) {
                 /*1*/iovec_base_phold[i] =
(Addr)((struct iovec *)iovBuf->bufferPtr())[i].iov_base;
                 /*2*/iovecBuf[i] = new BufferArg(iovec_base_phold[i],
                      ((struct iovec *)iovBuf->bufferPtr())[i].iov_len);
-                /*3*/iovecBuf[i]->copyIn(tc->getVirtProxy());
+                /*3*/iovecBuf[i]->copyIn(proxy);
                 /*4*/((struct iovec *)iovBuf->bufferPtr())[i].iov_base =
                      iovecBuf[i]->bufferPtr();
             }
@@ -1405,7 +1411,7 @@
         /*1*/msg_control_phold = (Addr)msgHdr->msg_control;
         /*2*/controlBuf = new BufferArg(msg_control_phold,
CMSG_ALIGN(msgHdr->msg_controllen));
-        /*3*/controlBuf->copyIn(tc->getVirtProxy());
+        /*3*/controlBuf->copyIn(proxy);
         /*4*/msgHdr->msg_control = controlBuf->bufferPtr();
     }

@@ -1415,7 +1421,7 @@
         return -errno;

     if (msgHdr->msg_name) {
-        nameBuf->copyOut(tc->getVirtProxy());
+        nameBuf->copyOut(proxy);
         delete(nameBuf);
         msgHdr->msg_name = (void *)msg_name_phold;
     }
@@ -1423,24 +1429,24 @@
     if (msgHdr->msg_iov) {
         for (int i = 0; i< msgHdr->msg_iovlen; i++) {
             if (((struct iovec *)iovBuf->bufferPtr())[i].iov_base) {
-                iovecBuf[i]->copyOut(tc->getVirtProxy());
+                iovecBuf[i]->copyOut(proxy);
                 delete iovecBuf[i];
                 ((struct iovec *)iovBuf->bufferPtr())[i].iov_base =
                 (void *)iovec_base_phold[i];
             }
         }
-        iovBuf->copyOut(tc->getVirtProxy());
+        iovBuf->copyOut(proxy);
         delete iovBuf;
         msgHdr->msg_iov = (struct iovec *)msg_iov_phold;
     }

     if (msgHdr->msg_control) {
-        controlBuf->copyOut(tc->getVirtProxy());
+        controlBuf->copyOut(proxy);
         delete(controlBuf);
         msgHdr->msg_control = (void *)msg_control_phold;
     }

-    msgBuf.copyOut(tc->getVirtProxy());
+    msgBuf.copyOut(proxy);

     return recvd_size;
 }
@@ -1456,11 +1462,13 @@
         return -EBADF;
     int sim_fd = sfdp->getSimFD();

+    SETranslatingPortProxy proxy(tc);
+
     /**
      * Reserve buffer space.
      */
     BufferArg msgBuf(msgPtr, sizeof(struct msghdr));
-    msgBuf.copyIn(tc->getVirtProxy());
+    msgBuf.copyIn(proxy);
     struct msghdr msgHdr = *((struct msghdr *)msgBuf.bufferPtr());

     /**
@@ -1469,7 +1477,7 @@
      */
     struct iovec *iovPtr = msgHdr.msg_iov;
BufferArg iovBuf((Addr)iovPtr, sizeof(struct iovec) * msgHdr.msg_iovlen);
-    iovBuf.copyIn(tc->getVirtProxy());
+    iovBuf.copyIn(proxy);
     struct iovec *iov = (struct iovec *)iovBuf.bufferPtr();
     msgHdr.msg_iov = iov;

@@ -1489,7 +1497,7 @@
     for (int iovIndex = 0 ; iovIndex < msgHdr.msg_iovlen; iovIndex++) {
         Addr basePtr = (Addr) iov[iovIndex].iov_base;
bufferArray[iovIndex] = new BufferArg(basePtr, iov[iovIndex].iov_len);
-        bufferArray[iovIndex]->copyIn(tc->getVirtProxy());
+        bufferArray[iovIndex]->copyIn(proxy);
         iov[iovIndex].iov_base = bufferArray[iovIndex]->bufferPtr();
     }

@@ -1539,15 +1547,17 @@
     if (status == -1)
         return -errno;

+    SETranslatingPortProxy proxy(tc);
+
     // copy val to valPtr and pass it on
     BufferArg valBuf(valPtr, sizeof(val));
     memcpy(valBuf.bufferPtr(), &val, sizeof(val));
-    valBuf.copyOut(tc->getVirtProxy());
+    valBuf.copyOut(proxy);

     // copy len to lenPtr and pass  it on
     BufferArg lenBuf(lenPtr, sizeof(len));
     memcpy(lenBuf.bufferPtr(), &len, sizeof(len));
-    lenBuf.copyOut(tc->getVirtProxy());
+    lenBuf.copyOut(proxy);

     return status;
 }
@@ -1566,9 +1576,11 @@
     // lenPtr is an in-out paramenter:
     // sending the address length in, conveying the final length out

+    SETranslatingPortProxy proxy(tc);
+
     // Read in the value of len from the passed pointer.
     BufferArg lenBuf(lenPtr, sizeof(socklen_t));
-    lenBuf.copyIn(tc->getVirtProxy());
+    lenBuf.copyIn(proxy);
     socklen_t len = *(socklen_t *)lenBuf.bufferPtr();

     struct sockaddr sa;
@@ -1580,11 +1592,11 @@
     // Copy address to addrPtr and pass it on.
     BufferArg addrBuf(addrPtr, sizeof(sa));
     memcpy(addrBuf.bufferPtr(), &sa, sizeof(sa));
-    addrBuf.copyOut(tc->getVirtProxy());
+    addrBuf.copyOut(proxy);

     // Copy len to lenPtr and pass  it on.
     *(socklen_t *)lenBuf.bufferPtr() = len;
-    lenBuf.copyOut(tc->getVirtProxy());
+    lenBuf.copyOut(proxy);

     return status;
 }
@@ -1600,8 +1612,10 @@
         return -EBADF;
     int sim_fd = sfdp->getSimFD();

+    SETranslatingPortProxy proxy(tc);
+
     BufferArg bufAddrlen(addrlenPtr, sizeof(unsigned));
-    bufAddrlen.copyIn(tc->getVirtProxy());
+    bufAddrlen.copyIn(proxy);
     BufferArg bufSock(sockAddrPtr, *(unsigned *)bufAddrlen.bufferPtr());

     int retval = getpeername(sim_fd,
@@ -1609,8 +1623,8 @@
                              (unsigned *)bufAddrlen.bufferPtr());

     if (retval != -1) {
-        bufSock.copyOut(tc->getVirtProxy());
-        bufAddrlen.copyOut(tc->getVirtProxy());
+        bufSock.copyOut(proxy);
+        bufAddrlen.copyOut(proxy);
     }

     return (retval == -1) ? -errno : retval;
@@ -1624,7 +1638,7 @@
     auto p = tc->getProcessPtr();

     BufferArg valBuf(valPtr, len);
-    valBuf.copyIn(tc->getVirtProxy());
+    valBuf.copyIn(SETranslatingPortProxy(tc));

auto sfdp = std::dynamic_pointer_cast<SocketFDEntry>((*p->fds)[tgt_fd]);
     if (!sfdp)
diff --git a/src/sim/syscall_emul.hh b/src/sim/syscall_emul.hh
index 63a9ea6..247a5ba 100644
--- a/src/sim/syscall_emul.hh
+++ b/src/sim/syscall_emul.hh
@@ -96,6 +96,7 @@
 #include "cpu/thread_context.hh"
 #include "kern/linux/linux.hh"
 #include "mem/page_table.hh"
+#include "mem/se_translating_port_proxy.hh"
 #include "params/Process.hh"
 #include "sim/emul_driver.hh"
 #include "sim/futex_map.hh"
@@ -389,7 +390,7 @@
     if (OS::TGT_FUTEX_WAIT == op || OS::TGT_FUTEX_WAIT_BITSET == op) {
         // Ensure futex system call accessed atomically.
         BufferArg buf(uaddr, sizeof(int));
-        buf.copyIn(tc->getVirtProxy());
+        buf.copyIn(SETranslatingPortProxy(tc));
         int mem_val = *(int*)buf.bufferPtr();

         /*
@@ -416,7 +417,7 @@

         // Ensure futex system call accessed atomically.
         BufferArg buf(uaddr, sizeof(int));
-        buf.copyIn(tc->getVirtProxy());
+        buf.copyIn(SETranslatingPortProxy(tc));
         int mem_val = *(int*)buf.bufferPtr();
         /*
          * For CMP_REQUEUE, the whole operation is only started only if
@@ -449,7 +450,7 @@
          */
         // get value from simulated-space
         BufferArg buf(uaddr2, sizeof(int));
-        buf.copyIn(tc->getVirtProxy());
+        buf.copyIn(SETranslatingPortProxy(tc));
         int oldval = *(int*)buf.bufferPtr();
         int newval = oldval;
         // extract op, oparg, cmp, cmparg from val3
@@ -473,7 +474,7 @@
             newval ^= wake_oparg;
         // copy updated value back to simulated-space
         *(int*)buf.bufferPtr() = newval;
-        buf.copyOut(tc->getVirtProxy());
+        buf.copyOut(SETranslatingPortProxy(tc));
         // perform the first wake-up
         int woken1 = futex_map.wakeup(uaddr, process->tgid(), val);
         int woken2 = 0;
@@ -698,20 +699,20 @@
         switch (req) {
           case SIOCGIFCONF: {
             BufferArg conf_arg(addr, sizeof(ifconf));
-            conf_arg.copyIn(tc->getVirtProxy());
+            conf_arg.copyIn(SETranslatingPortProxy(tc));

             ifconf *conf = (ifconf*)conf_arg.bufferPtr();
             Addr ifc_buf_addr = (Addr)conf->ifc_buf;
             BufferArg ifc_buf_arg(ifc_buf_addr, conf->ifc_len);
-            ifc_buf_arg.copyIn(tc->getVirtProxy());
+            ifc_buf_arg.copyIn(SETranslatingPortProxy(tc));

             conf->ifc_buf = (char*)ifc_buf_arg.bufferPtr();

             status = ioctl(sfdp->getSimFD(), req, conf_arg.bufferPtr());
             if (status != -1) {
                 conf->ifc_buf = (char*)ifc_buf_addr;
-                ifc_buf_arg.copyOut(tc->getVirtProxy());
-                conf_arg.copyOut(tc->getVirtProxy());
+                ifc_buf_arg.copyOut(SETranslatingPortProxy(tc));
+                conf_arg.copyOut(SETranslatingPortProxy(tc));
             }

             return status;
@@ -727,11 +728,11 @@
 #endif
           case SIOCGIFMTU: {
             BufferArg req_arg(addr, sizeof(ifreq));
-            req_arg.copyIn(tc->getVirtProxy());
+            req_arg.copyIn(SETranslatingPortProxy(tc));

             status = ioctl(sfdp->getSimFD(), req, req_arg.bufferPtr());
             if (status != -1)
-                req_arg.copyOut(tc->getVirtProxy());
+                req_arg.copyOut(SETranslatingPortProxy(tc));
             return status;
           }
         }
@@ -759,7 +760,7 @@
      * string from that memory space into the host's working memory space.
      */
     std::string path;
-    if (!tc->getVirtProxy().tryReadString(path, pathname))
+    if (!SETranslatingPortProxy(tc).tryReadString(path, pathname))
         return -EFAULT;

 #ifdef __CYGWIN32__
@@ -976,7 +977,7 @@
     std::string path;
     auto process = tc->getProcessPtr();

-    if (!tc->getVirtProxy().tryReadString(path, pathname))
+    if (!SETranslatingPortProxy(tc).tryReadString(path, pathname))
         return -EFAULT;

     mode_t hostMode = 0;
@@ -1003,7 +1004,7 @@
     auto p = tc->getProcessPtr();

     BufferArg fdsBuf(fdsPtr, sizeof(struct pollfd) * nfds);
-    fdsBuf.copyIn(tc->getVirtProxy());
+    fdsBuf.copyIn(SETranslatingPortProxy(tc));

     /**
      * Record the target file descriptors in a local variable. We need to
@@ -1063,7 +1064,7 @@
      * Copy out the pollfd struct because the host may have updated fields
      * in the structure.
      */
-    fdsBuf.copyOut(tc->getVirtProxy());
+    fdsBuf.copyOut(SETranslatingPortProxy(tc));

     return status;
 }
@@ -1179,7 +1180,7 @@
     std::string path;
     auto process = tc->getProcessPtr();

-    if (!tc->getVirtProxy().tryReadString(path, pathname))
+    if (!SETranslatingPortProxy(tc).tryReadString(path, pathname))
         return -EFAULT;

     // Adjust path for cwd and redirection
@@ -1206,7 +1207,7 @@
     std::string path;
     auto process = tc->getProcessPtr();

-    if (!tc->getVirtProxy().tryReadString(path, pathname))
+    if (!SETranslatingPortProxy(tc).tryReadString(path, pathname))
         return -EFAULT;

     // Adjust path for cwd and redirection
@@ -1241,7 +1242,7 @@
         warn("fstatat64: first argument not AT_FDCWD; unlikely to work");

     std::string path;
-    if (!tc->getVirtProxy().tryReadString(path, pathname))
+    if (!SETranslatingPortProxy(tc).tryReadString(path, pathname))
         return -EFAULT;

     // Adjust path for cwd and redirection
@@ -1303,7 +1304,7 @@
     std::string path;
     auto process = tc->getProcessPtr();

-    if (!tc->getVirtProxy().tryReadString(path, pathname))
+    if (!SETranslatingPortProxy(tc).tryReadString(path, pathname))
         return -EFAULT;

     // Adjust path for cwd and redirection
@@ -1329,7 +1330,7 @@
     std::string path;
     auto process = tc->getProcessPtr();

-    if (!tc->getVirtProxy().tryReadString(path, pathname))
+    if (!SETranslatingPortProxy(tc).tryReadString(path, pathname))
         return -EFAULT;

     // Adjust path for cwd and redirection
@@ -1387,7 +1388,7 @@
     std::string path;
     auto process = tc->getProcessPtr();

-    if (!tc->getVirtProxy().tryReadString(path, pathname))
+    if (!SETranslatingPortProxy(tc).tryReadString(path, pathname))
         return -EFAULT;

     // Adjust path for cwd and redirection
@@ -1475,7 +1476,7 @@
         BufferArg ptidBuf(ptidPtr, sizeof(long));
         long *ptid = (long *)ptidBuf.bufferPtr();
         *ptid = cp->pid();
-        ptidBuf.copyOut(tc->getVirtProxy());
+        ptidBuf.copyOut(SETranslatingPortProxy(tc));
     }

     if (flags & OS::TGT_CLONE_THREAD) {
@@ -1498,7 +1499,7 @@
         BufferArg ctidBuf(ctidPtr, sizeof(long));
         long *ctid = (long *)ctidBuf.bufferPtr();
         *ctid = cp->pid();
-        ctidBuf.copyOut(ctc->getVirtProxy());
+        ctidBuf.copyOut(SETranslatingPortProxy(ctc));
     }

     if (flags & OS::TGT_CLONE_CHILD_CLEARTID)
@@ -1564,7 +1565,7 @@
         return -EBADF;
     int sim_fd = ffdp->getSimFD();

-    PortProxy &prox = tc->getVirtProxy();
+    SETranslatingPortProxy prox(tc);
     typename OS::tgt_iovec tiov[count];
     struct iovec hiov[count];
     for (size_t i = 0; i < count; ++i) {
@@ -1601,7 +1602,7 @@
         return -EBADF;
     int sim_fd = hbfdp->getSimFD();

-    PortProxy &prox = tc->getVirtProxy();
+    SETranslatingPortProxy prox(tc);
     struct iovec hiov[count];
     for (size_t i = 0; i < count; ++i) {
         typename OS::tgt_iovec tiov;
@@ -1781,7 +1782,7 @@

     int bytes_read = pread(sim_fd, bufArg.bufferPtr(), nbytes, offset);

-    bufArg.copyOut(tc->getVirtProxy());
+    bufArg.copyOut(SETranslatingPortProxy(tc));

     return (bytes_read == -1) ? -errno : bytes_read;
 }
@@ -1799,7 +1800,7 @@
     int sim_fd = ffdp->getSimFD();

     BufferArg bufArg(bufPtr, nbytes);
-    bufArg.copyIn(tc->getVirtProxy());
+    bufArg.copyIn(SETranslatingPortProxy(tc));

     int bytes_written = pwrite(sim_fd, bufArg.bufferPtr(), nbytes, offset);

@@ -1941,7 +1942,7 @@
     std::string path;
     auto process = tc->getProcessPtr();

-    if (!tc->getVirtProxy().tryReadString(path, pathname))
+    if (!SETranslatingPortProxy(tc).tryReadString(path, pathname))
         return -EFAULT;

     struct timeval hostTimeval[2];
@@ -1969,7 +1970,7 @@
     auto p = tc->getProcessPtr();

     std::string path;
-    PortProxy & mem_proxy = tc->getVirtProxy();
+    SETranslatingPortProxy mem_proxy(tc);
     if (!mem_proxy.tryReadString(path, pathname))
         return -EFAULT;

@@ -2124,10 +2125,10 @@
     getElapsedTimeMicro(sec, usec);
     sec += seconds_since_epoch;

+    SETranslatingPortProxy p(tc);
     if (taddr != 0) {
         typename OS::time_t t = sec;
         t = htog(t, OS::byteOrder);
-        PortProxy &p = tc->getVirtProxy();
         p.writeBlob(taddr, &t, (int)sizeof(typename OS::time_t));
     }
     return sec;
@@ -2212,7 +2213,7 @@
     fds[0] = p->fds->allocFD(sfdp1);
auto sfdp2 = std::make_shared<SocketFDEntry>(fds[1], domain, type, prot);
     fds[1] = p->fds->allocFD(sfdp2);
-    svBuf.copyOut(tc->getVirtProxy());
+    svBuf.copyOut(SETranslatingPortProxy(tc));

     return status;
 }
@@ -2407,7 +2408,7 @@
     int bytes_read = read(sim_fd, buf_arg.bufferPtr(), nbytes);

     if (bytes_read > 0)
-        buf_arg.copyOut(tc->getVirtProxy());
+        buf_arg.copyOut(SETranslatingPortProxy(tc));

     return (bytes_read == -1) ? -errno : bytes_read;
 }
@@ -2425,7 +2426,7 @@
     int sim_fd = hbfdp->getSimFD();

     BufferArg buf_arg(buf_ptr, nbytes);
-    buf_arg.copyIn(tc->getVirtProxy());
+    buf_arg.copyIn(SETranslatingPortProxy(tc));

     struct pollfd pfd;
     pfd.fd = sim_fd;
@@ -2501,7 +2502,7 @@
     const int EXITED = 0;
     BufferArg statusBuf(statPtr, sizeof(int));
     *(int *)statusBuf.bufferPtr() = EXITED;
-    statusBuf.copyOut(tc->getVirtProxy());
+    statusBuf.copyOut(SETranslatingPortProxy(tc));

     // Return the child PID.
     pid_t retval = iter->sender->pid();
@@ -2541,14 +2542,14 @@

     if (lenPtr) {
         lenBufPtr = new BufferArg(lenPtr, sizeof(socklen_t));
-        lenBufPtr->copyIn(tc->getVirtProxy());
+        lenBufPtr->copyIn(SETranslatingPortProxy(tc));
         memcpy(&addrLen, (socklen_t *)lenBufPtr->bufferPtr(),
                sizeof(socklen_t));
     }

     if (addrPtr) {
         addrBufPtr = new BufferArg(addrPtr, sizeof(struct sockaddr));
-        addrBufPtr->copyIn(tc->getVirtProxy());
+        addrBufPtr->copyIn(SETranslatingPortProxy(tc));
         memcpy(&sa, (struct sockaddr *)addrBufPtr->bufferPtr(),
                sizeof(struct sockaddr));
     }
@@ -2560,13 +2561,13 @@

     if (addrPtr) {
         memcpy(addrBufPtr->bufferPtr(), &sa, sizeof(sa));
-        addrBufPtr->copyOut(tc->getVirtProxy());
+        addrBufPtr->copyOut(SETranslatingPortProxy(tc));
         delete(addrBufPtr);
     }

     if (lenPtr) {
         *(socklen_t *)lenBufPtr->bufferPtr() = addrLen;
-        lenBufPtr->copyOut(tc->getVirtProxy());
+        lenBufPtr->copyOut(SETranslatingPortProxy(tc));
         delete(lenBufPtr);
     }


--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/45907
To unsubscribe, or for help writing mail filters, visit https://gem5-review.googlesource.com/settings

Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: Idb363d6ddc681f7c1ad5e7aba69865f40aa30dc8
Gerrit-Change-Number: 45907
Gerrit-PatchSet: 1
Gerrit-Owner: Gabe Black <[email protected]>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

Reply via email to