Gabe Black has submitted this change. ( 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
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/45907
Maintainer: Bobby R. Bruce <[email protected]>
Tested-by: kokoro <[email protected]>
Reviewed-by: Giacomo Travaglini <[email protected]>
---
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, 213 insertions(+), 141 deletions(-)

Approvals:
  Giacomo Travaglini: Looks good to me, approved
  Bobby R. Bruce: Looks good to me, approved
  kokoro: Regressions pass



diff --git a/src/arch/arm/aapcs32.hh b/src/arch/arm/aapcs32.hh
index d773ad4..84bd5d6 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"

@@ -343,7 +346,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 6a4a62d..542510b 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 gem5
@@ -94,18 +95,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();
     }

@@ -115,11 +118,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 b555ad4..74371b7 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"
@@ -72,10 +73,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[] =
@@ -83,8 +84,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[] =
     {
@@ -97,7 +97,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[] =
     {
@@ -105,7 +105,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 f2d702a..8ca3684 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 gem5
@@ -129,8 +130,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 59ea4aa..fc98d6e 100644
--- a/src/arch/arm/semihosting.cc
+++ b/src/arch/arm/semihosting.cc
@@ -249,6 +249,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)) {
@@ -267,7 +268,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 6b6be0c..473f9b7 100644
--- a/src/arch/arm/tracers/tarmac_parser.cc
+++ b/src/arch/arm/tracers/tarmac_parser.cc
@@ -49,8 +49,12 @@
 #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/cur_tick.hh"
 #include "sim/faults.hh"
+#include "sim/full_system.hh"
 #include "sim/sim_exit.hh"

 namespace gem5
@@ -1310,7 +1314,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 c880d4d..7702f0e 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 gem5
@@ -60,7 +61,7 @@
             return false;
         }

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

         return true;
     }
@@ -94,7 +95,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
@@ -104,7 +105,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
@@ -120,7 +121,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
@@ -138,7 +139,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
@@ -160,7 +161,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;
     }
@@ -178,7 +180,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 d00580f..ae89b37 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"

@@ -59,25 +60,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 88bbaf0..7c1e125 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/se_translating_port_proxy.hh"

 namespace gem5
 {
@@ -105,6 +106,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.");
@@ -122,7 +125,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 a00f2b9..43e712d 100644
--- a/src/arch/x86/linux/se_workload.cc
+++ b/src/arch/x86/linux/se_workload.cc
@@ -48,6 +48,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"
@@ -152,7 +153,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 bd5d571..496a137 100644
--- a/src/arch/x86/linux/syscalls.cc
+++ b/src/arch/x86/linux/syscalls.cc
@@ -33,6 +33,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"
@@ -70,7 +71,7 @@
     };

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

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

     X86Process *x86p = dynamic_cast<X86Process *>(process);
     assert(x86p);
@@ -114,7 +116,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)) {
@@ -166,7 +168,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 e57ded7..3a654b1 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/process.hh"
 #include "sim/system.hh"
@@ -687,8 +689,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) {
@@ -717,8 +719,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 111a58e..88d7703 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"
@@ -106,7 +109,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 92ac641..f7ac5c3 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"

@@ -221,7 +224,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 4841809..3c648f1 100644
--- a/src/kern/linux/helpers.cc
+++ b/src/kern/linux/helpers.cc
@@ -40,6 +40,7 @@
 #include "base/compiler.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"

@@ -97,7 +98,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 e8b26e8..9a5b963 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 gem5
 {
@@ -51,7 +52,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();

@@ -181,7 +183,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>";

@@ -219,7 +221,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 207c275..5b3ab29 100644
--- a/src/sim/process.cc
+++ b/src/sim/process.cc
@@ -339,13 +339,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 4332b16..b3c1f4e 100644
--- a/src/sim/pseudo_inst.cc
+++ b/src/sim/pseudo_inst.cc
@@ -59,7 +59,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"
@@ -259,7 +262,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);

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

     close(fd);
-    tc->getVirtProxy().writeBlob(vaddr, buf, result);
+    (FullSystem ? TranslatingPortProxy(tc) : SETranslatingPortProxy(tc)).
+        writeBlob(vaddr, buf, result);
     delete [] buf;
     return result;
 }
@@ -403,7 +408,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) {
@@ -428,7 +434,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 147cb39..baeaca2 100644
--- a/src/sim/syscall_emul.cc
+++ b/src/sim/syscall_emul.cc
@@ -43,6 +43,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"
@@ -96,7 +97,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.
@@ -320,7 +321,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;
 }

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

@@ -382,7 +383,7 @@
         }
     }

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

     return (result == -1) ? -errno : result;
 }
@@ -394,7 +395,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
@@ -440,7 +441,7 @@
                   (char*)buf.bufferPtr());
     }

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

     return (result == -1) ? -errno : result;
 }
@@ -451,7 +452,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);
@@ -468,7 +469,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))
@@ -489,7 +490,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))
@@ -507,7 +508,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);
@@ -522,12 +523,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
@@ -545,7 +547,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
@@ -576,7 +578,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
@@ -627,7 +629,7 @@
     std::string path;
     auto p = tc->getProcessPtr();

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

     /* XXX endianess */
@@ -840,7 +842,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)
@@ -1000,7 +1002,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
@@ -1016,7 +1018,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);
@@ -1030,7 +1032,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;
@@ -1057,7 +1059,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);
@@ -1104,7 +1106,7 @@
         traversed += host_reclen;
     }

-    buf_arg.copyOut(tc->getVirtProxy());
+    buf_arg.copyOut(SETranslatingPortProxy(tc));
     return status;
 }
 #endif
@@ -1167,7 +1169,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)
@@ -1203,7 +1205,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)
@@ -1232,19 +1234,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;
@@ -1258,20 +1262,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;
@@ -1291,13 +1295,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;
     }
@@ -1338,13 +1342,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();

     /**
@@ -1364,7 +1370,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();
     }

@@ -1384,14 +1390,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();
             }
@@ -1407,7 +1413,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();
     }

@@ -1417,7 +1423,7 @@
         return -errno;

     if (msgHdr->msg_name) {
-        nameBuf->copyOut(tc->getVirtProxy());
+        nameBuf->copyOut(proxy);
         delete(nameBuf);
         msgHdr->msg_name = (void *)msg_name_phold;
     }
@@ -1425,24 +1431,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;
 }
@@ -1458,11 +1464,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());

     /**
@@ -1471,7 +1479,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;

@@ -1491,7 +1499,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();
     }

@@ -1541,15 +1549,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;
 }
@@ -1568,9 +1578,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;
@@ -1582,11 +1594,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;
 }
@@ -1602,8 +1614,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,
@@ -1611,8 +1625,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;
@@ -1626,7 +1640,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 aa02fd6..522fb1b 100644
--- a/src/sim/syscall_emul.hh
+++ b/src/sim/syscall_emul.hh
@@ -97,6 +97,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"
@@ -393,7 +394,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();

         /*
@@ -420,7 +421,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
@@ -453,7 +454,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
@@ -477,7 +478,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;
@@ -702,20 +703,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;
@@ -731,11 +732,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;
           }
         }
@@ -763,7 +764,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__
@@ -981,7 +982,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;
@@ -1008,7 +1009,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
@@ -1068,7 +1069,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;
 }
@@ -1184,7 +1185,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
@@ -1211,7 +1212,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
@@ -1246,7 +1247,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
@@ -1308,7 +1309,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
@@ -1334,7 +1335,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
@@ -1392,7 +1393,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
@@ -1480,7 +1481,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) {
@@ -1503,7 +1504,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)
@@ -1569,7 +1570,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) {
@@ -1606,7 +1607,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;
@@ -1786,7 +1787,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;
 }
@@ -1804,7 +1805,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);

@@ -1946,7 +1947,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];
@@ -1974,7 +1975,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;

@@ -2129,10 +2130,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;
@@ -2217,7 +2218,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;
 }
@@ -2418,7 +2419,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;
 }
@@ -2436,7 +2437,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;
@@ -2512,7 +2513,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();
@@ -2552,14 +2553,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));
     }
@@ -2571,13 +2572,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);
     }

@@ -2623,12 +2624,13 @@
     if (cpusetsize < CPU_ALLOC_SIZE(tc->getSystemPtr()->threads.size()))
         return -EINVAL;

+    SETranslatingPortProxy proxy(tc);
     BufferArg maskBuf(cpu_set_mask, cpusetsize);
-    maskBuf.copyIn(tc->getVirtProxy());
+    maskBuf.copyIn(proxy);
     for (int i = 0; i < tc->getSystemPtr()->threads.size(); i++) {
         CPU_SET(i, (cpu_set_t *)maskBuf.bufferPtr());
     }
-    maskBuf.copyOut(tc->getVirtProxy());
+    maskBuf.copyOut(proxy);
     return CPU_ALLOC_SIZE(tc->getSystemPtr()->threads.size());
 #else
     warnUnsupportedOS("sched_getaffinity");

--
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: 7
Gerrit-Owner: Gabe Black <[email protected]>
Gerrit-Reviewer: Bobby R. Bruce <[email protected]>
Gerrit-Reviewer: Daniel Carvalho <[email protected]>
Gerrit-Reviewer: Gabe Black <[email protected]>
Gerrit-Reviewer: Giacomo Travaglini <[email protected]>
Gerrit-Reviewer: Jason Lowe-Power <[email protected]>
Gerrit-Reviewer: Nikos Nikoleris <[email protected]>
Gerrit-Reviewer: kokoro <[email protected]>
Gerrit-MessageType: merged
_______________________________________________
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