From 5365c18f2e309b54d3e37dc98d8cca20ec9d4219 Mon Sep 17 00:00:00 2001 From: Gabe Black Date: Thu, 2 May 2019 02:16:33 -0700 Subject: [PATCH] arch, base, cpu, gpu, sim: Merge getMemProxy and getVirtProxy. These two functions were performing the same function but had two different names for historical reasons. This change merges them together, keeping the getVirtProxy name to be consistent with the getPhysProxy method used to get a non-translating proxy port. Change-Id: Idd83c6b899f9343795075b030ccbc723a79e52a4 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/18581 Tested-by: kokoro Reviewed-by: Andreas Sandberg Reviewed-by: Jason Lowe-Power Maintainer: Andreas Sandberg --- src/arch/alpha/linux/process.cc | 6 +- src/arch/arm/freebsd/process.cc | 16 ++-- src/arch/arm/linux/process.cc | 18 ++--- src/arch/mips/linux/process.cc | 6 +- src/arch/power/linux/process.cc | 2 +- src/arch/riscv/linux/process.cc | 4 +- src/arch/sparc/linux/syscalls.cc | 8 +- src/arch/sparc/process.cc | 4 +- src/arch/sparc/solaris/process.cc | 2 +- src/arch/x86/linux/process.cc | 12 +-- src/arch/x86/pseudo_inst.cc | 2 +- src/base/remote_gdb.cc | 18 +---- src/cpu/checker/thread_context.hh | 6 -- src/cpu/o3/thread_context.hh | 6 -- src/cpu/simple_thread.hh | 6 -- src/cpu/thread_context.hh | 2 - src/cpu/thread_state.cc | 9 --- src/cpu/thread_state.hh | 2 - src/gpu-compute/cl_driver.cc | 16 ++-- src/sim/process.cc | 6 +- src/sim/syscall_emul.cc | 112 +++++++++++++------------- src/sim/syscall_emul.hh | 128 +++++++++++++++--------------- 22 files changed, 178 insertions(+), 213 deletions(-) diff --git a/src/arch/alpha/linux/process.cc b/src/arch/alpha/linux/process.cc index d342c5d2d..f129b263f 100644 --- a/src/arch/alpha/linux/process.cc +++ b/src/arch/alpha/linux/process.cc @@ -89,7 +89,7 @@ unameFunc(SyscallDesc *desc, int callnum, ThreadContext *tc) strcpy(name->version, "#1 Mon Aug 18 11:32:15 EDT 2003"); strcpy(name->machine, "alpha"); - name.copyOut(tc->getMemProxy()); + name.copyOut(tc->getVirtProxy()); return 0; } @@ -111,7 +111,7 @@ osf_getsysinfoFunc(SyscallDesc *desc, int callnum, ThreadContext *tc) TypedBufferArg fpcr(bufPtr); // I don't think this exactly matches the HW FPCR *fpcr = 0; - fpcr.copyOut(tc->getMemProxy()); + fpcr.copyOut(tc->getVirtProxy()); return 0; } @@ -139,7 +139,7 @@ osf_setsysinfoFunc(SyscallDesc *desc, int callnum, ThreadContext *tc) case 14: { // SSI_IEEE_FP_CONTROL TypedBufferArg fpcr(bufPtr); // I don't think this exactly matches the HW FPCR - fpcr.copyIn(tc->getMemProxy()); + fpcr.copyIn(tc->getVirtProxy()); DPRINTFR(SyscallVerbose, "osf_setsysinfo(SSI_IEEE_FP_CONTROL): " " setting FPCR to 0x%x\n", gtoh(*(uint64_t*)fpcr)); return 0; diff --git a/src/arch/arm/freebsd/process.cc b/src/arch/arm/freebsd/process.cc index 41549eaab..69424c989 100644 --- a/src/arch/arm/freebsd/process.cc +++ b/src/arch/arm/freebsd/process.cc @@ -109,13 +109,13 @@ sysctlFunc(SyscallDesc *desc, int callnum, ThreadContext *tc) BufferArg buf3(oldlenp, sizeof(size_t)); BufferArg buf4(newp, sizeof(size_t)); - buf.copyIn(tc->getMemProxy()); - buf2.copyIn(tc->getMemProxy()); - buf3.copyIn(tc->getMemProxy()); + buf.copyIn(tc->getVirtProxy()); + buf2.copyIn(tc->getVirtProxy()); + buf3.copyIn(tc->getVirtProxy()); void *hnewp = NULL; if (newp) { - buf4.copyIn(tc->getMemProxy()); + buf4.copyIn(tc->getVirtProxy()); hnewp = (void *)buf4.bufferPtr(); } @@ -125,11 +125,11 @@ sysctlFunc(SyscallDesc *desc, int callnum, ThreadContext *tc) ret = sysctl((int *)hnamep, namelen, holdp, holdlenp, hnewp, newlen); - buf.copyOut(tc->getMemProxy()); - buf2.copyOut(tc->getMemProxy()); - buf3.copyOut(tc->getMemProxy()); + buf.copyOut(tc->getVirtProxy()); + buf2.copyOut(tc->getVirtProxy()); + buf3.copyOut(tc->getVirtProxy()); if (newp) - buf4.copyOut(tc->getMemProxy()); + buf4.copyOut(tc->getVirtProxy()); return (ret); } diff --git a/src/arch/arm/linux/process.cc b/src/arch/arm/linux/process.cc index 3fcb01fe7..426f66a55 100644 --- a/src/arch/arm/linux/process.cc +++ b/src/arch/arm/linux/process.cc @@ -117,7 +117,7 @@ unameFunc32(SyscallDesc *desc, int callnum, ThreadContext *tc) strcpy(name->version, "#1 SMP Sat Dec 1 00:00:00 GMT 2012"); strcpy(name->machine, "armv7l"); - name.copyOut(tc->getMemProxy()); + name.copyOut(tc->getVirtProxy()); return 0; } @@ -135,7 +135,7 @@ unameFunc64(SyscallDesc *desc, int callnum, ThreadContext *tc) strcpy(name->version, "#1 SMP Sat Dec 1 00:00:00 GMT 2012"); strcpy(name->machine, "armv8l"); - name.copyOut(tc->getMemProxy()); + name.copyOut(tc->getVirtProxy()); return 0; } @@ -147,7 +147,7 @@ setTLSFunc32(SyscallDesc *desc, int callnum, ThreadContext *tc) auto process = tc->getProcessPtr(); uint32_t tlsPtr = process->getSyscallArg(tc, index); - tc->getMemProxy().writeBlob(ArmLinuxProcess32::commPage + 0x0ff0, + tc->getVirtProxy().writeBlob(ArmLinuxProcess32::commPage + 0x0ff0, &tlsPtr, sizeof(tlsPtr)); tc->setMiscReg(MISCREG_TPIDRURO,tlsPtr); return 0; @@ -1737,8 +1737,8 @@ ArmLinuxProcess32::initState() // 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->getMemProxy().writeBlob(commPage + addr, - swiNeg1, sizeof(swiNeg1)); + tc->getVirtProxy().writeBlob(commPage + addr, + swiNeg1, sizeof(swiNeg1)); } uint8_t memory_barrier[] = @@ -1746,8 +1746,8 @@ ArmLinuxProcess32::initState() 0x5f, 0xf0, 0x7f, 0xf5, // dmb 0x0e, 0xf0, 0xa0, 0xe1 // return }; - tc->getMemProxy().writeBlob(commPage + 0x0fa0, memory_barrier, - sizeof(memory_barrier)); + tc->getVirtProxy().writeBlob(commPage + 0x0fa0, memory_barrier, + sizeof(memory_barrier)); uint8_t cmpxchg[] = { @@ -1760,7 +1760,7 @@ ArmLinuxProcess32::initState() 0x5f, 0xf0, 0x7f, 0xf5, // dmb 0x0e, 0xf0, 0xa0, 0xe1 // return }; - tc->getMemProxy().writeBlob(commPage + 0x0fc0, cmpxchg, sizeof(cmpxchg)); + tc->getVirtProxy().writeBlob(commPage + 0x0fc0, cmpxchg, sizeof(cmpxchg)); uint8_t get_tls[] = { @@ -1768,7 +1768,7 @@ ArmLinuxProcess32::initState() 0x70, 0x0f, 0x1d, 0xee, // mrc p15, 0, r0, c13, c0, 3 0x0e, 0xf0, 0xa0, 0xe1 // return }; - tc->getMemProxy().writeBlob(commPage + 0x0fe0, get_tls, sizeof(get_tls)); + tc->getVirtProxy().writeBlob(commPage + 0x0fe0, get_tls, sizeof(get_tls)); } void diff --git a/src/arch/mips/linux/process.cc b/src/arch/mips/linux/process.cc index 9efaf2624..596f2dda0 100644 --- a/src/arch/mips/linux/process.cc +++ b/src/arch/mips/linux/process.cc @@ -92,7 +92,7 @@ unameFunc(SyscallDesc *desc, int callnum, ThreadContext *tc) strcpy(name->version, "#1 Mon Aug 18 11:32:15 EDT 2003"); strcpy(name->machine, "mips"); - name.copyOut(tc->getMemProxy()); + name.copyOut(tc->getVirtProxy()); return 0; } @@ -115,7 +115,7 @@ sys_getsysinfoFunc(SyscallDesc *desc, int callnum, ThreadContext *tc) TypedBufferArg fpcr(bufPtr); // I don't think this exactly matches the HW FPCR *fpcr = 0; - fpcr.copyOut(tc->getMemProxy()); + fpcr.copyOut(tc->getVirtProxy()); return 0; } default: @@ -144,7 +144,7 @@ sys_setsysinfoFunc(SyscallDesc *desc, int callnum, ThreadContext *tc) // SSI_IEEE_FP_CONTROL TypedBufferArg fpcr(bufPtr); // I don't think this exactly matches the HW FPCR - fpcr.copyIn(tc->getMemProxy()); + fpcr.copyIn(tc->getVirtProxy()); DPRINTFR(SyscallVerbose, "sys_setsysinfo(SSI_IEEE_FP_CONTROL): " " setting FPCR to 0x%x\n", gtoh(*(uint64_t*)fpcr)); return 0; diff --git a/src/arch/power/linux/process.cc b/src/arch/power/linux/process.cc index 8a5cd137c..97032d989 100644 --- a/src/arch/power/linux/process.cc +++ b/src/arch/power/linux/process.cc @@ -92,7 +92,7 @@ unameFunc(SyscallDesc *desc, int callnum, ThreadContext *tc) strcpy(name->version, "#1 Mon Aug 18 11:32:15 EDT 2003"); strcpy(name->machine, "power"); - name.copyOut(tc->getMemProxy()); + name.copyOut(tc->getVirtProxy()); return 0; } diff --git a/src/arch/riscv/linux/process.cc b/src/arch/riscv/linux/process.cc index 8aebd558e..6708e026f 100644 --- a/src/arch/riscv/linux/process.cc +++ b/src/arch/riscv/linux/process.cc @@ -100,7 +100,7 @@ unameFunc64(SyscallDesc *desc, int callnum, ThreadContext *tc) strcpy(name->version, "#1 Mon Aug 18 11:32:15 EDT 2003"); strcpy(name->machine, "riscv64"); - name.copyOut(tc->getMemProxy()); + name.copyOut(tc->getVirtProxy()); return 0; } @@ -118,7 +118,7 @@ unameFunc32(SyscallDesc *desc, int callnum, ThreadContext *tc) strcpy(name->version, "#1 Mon Aug 18 11:32:15 EDT 2003"); strcpy(name->machine, "riscv32"); - name.copyOut(tc->getMemProxy()); + name.copyOut(tc->getVirtProxy()); return 0; } diff --git a/src/arch/sparc/linux/syscalls.cc b/src/arch/sparc/linux/syscalls.cc index 70d1b2af6..1abe2476c 100644 --- a/src/arch/sparc/linux/syscalls.cc +++ b/src/arch/sparc/linux/syscalls.cc @@ -51,7 +51,7 @@ unameFunc(SyscallDesc *desc, int callnum, ThreadContext *tc) strcpy(name->version, "#1 Mon Aug 18 11:32:15 EDT 2003"); strcpy(name->machine, "sparc"); - name.copyOut(tc->getMemProxy()); + name.copyOut(tc->getVirtProxy()); return 0; } @@ -71,19 +71,19 @@ getresuidFunc(SyscallDesc *desc, int num, ThreadContext *tc) if (ruid) { BufferArg ruidBuff(ruid, sizeof(uint64_t)); memcpy(ruidBuff.bufferPtr(), &id, sizeof(uint64_t)); - ruidBuff.copyOut(tc->getMemProxy()); + ruidBuff.copyOut(tc->getVirtProxy()); } // Set the euid if (euid) { BufferArg euidBuff(euid, sizeof(uint64_t)); memcpy(euidBuff.bufferPtr(), &id, sizeof(uint64_t)); - euidBuff.copyOut(tc->getMemProxy()); + euidBuff.copyOut(tc->getVirtProxy()); } // Set the suid if (suid) { BufferArg suidBuff(suid, sizeof(uint64_t)); memcpy(suidBuff.bufferPtr(), &id, sizeof(uint64_t)); - suidBuff.copyOut(tc->getMemProxy()); + suidBuff.copyOut(tc->getVirtProxy()); } return 0; } diff --git a/src/arch/sparc/process.cc b/src/arch/sparc/process.cc index 3bd3ea0bf..d89c606a3 100644 --- a/src/arch/sparc/process.cc +++ b/src/arch/sparc/process.cc @@ -451,7 +451,7 @@ void Sparc32Process::flushWindows(ThreadContext *tc) for (int index = 16; index < 32; index++) { uint32_t regVal = tc->readIntReg(index); regVal = htog(regVal); - if (!tc->getMemProxy().tryWriteBlob( + if (!tc->getVirtProxy().tryWriteBlob( sp + (index - 16) * 4, (uint8_t *)®Val, 4)) { warn("Failed to save register to the stack when " "flushing windows.\n"); @@ -486,7 +486,7 @@ Sparc64Process::flushWindows(ThreadContext *tc) for (int index = 16; index < 32; index++) { RegVal regVal = tc->readIntReg(index); regVal = htog(regVal); - if (!tc->getMemProxy().tryWriteBlob( + if (!tc->getVirtProxy().tryWriteBlob( sp + 2047 + (index - 16) * 8, (uint8_t *)®Val, 8)) { warn("Failed to save register to the stack when " "flushing windows.\n"); diff --git a/src/arch/sparc/solaris/process.cc b/src/arch/sparc/solaris/process.cc index 3a13229ed..fb38c77ee 100644 --- a/src/arch/sparc/solaris/process.cc +++ b/src/arch/sparc/solaris/process.cc @@ -84,7 +84,7 @@ unameFunc(SyscallDesc *desc, int callnum, ThreadContext *tc) strcpy(name->version, "Generic_118558-21"); strcpy(name->machine, "sun4u"); - name.copyOut(tc->getMemProxy()); + name.copyOut(tc->getVirtProxy()); return 0; } diff --git a/src/arch/x86/linux/process.cc b/src/arch/x86/linux/process.cc index 1d8bcbf6c..8a58ee1fe 100644 --- a/src/arch/x86/linux/process.cc +++ b/src/arch/x86/linux/process.cc @@ -103,7 +103,7 @@ unameFunc(SyscallDesc *desc, int callnum, ThreadContext *tc) strcpy(name->version, "#1 Mon Aug 18 11:32:15 EDT 2003"); strcpy(name->machine, "x86_64"); - name.copyOut(tc->getMemProxy()); + name.copyOut(tc->getVirtProxy()); return 0; } @@ -125,7 +125,7 @@ archPrctlFunc(SyscallDesc *desc, int callnum, ThreadContext *tc) int code = process->getSyscallArg(tc, index); uint64_t addr = process->getSyscallArg(tc, index); uint64_t fsBase, gsBase; - PortProxy &p = tc->getMemProxy(); + PortProxy &p = tc->getVirtProxy(); switch(code) { // Each of these valid options should actually check addr. @@ -194,10 +194,10 @@ setThreadArea32Func(SyscallDesc *desc, int callnum, ThreadContext *tc) gdt(x86p->gdtStart() + minTLSEntry * sizeof(uint64_t), numTLSEntries * sizeof(uint64_t)); - if (!userDesc.copyIn(tc->getMemProxy())) + if (!userDesc.copyIn(tc->getVirtProxy())) return -EFAULT; - if (!gdt.copyIn(tc->getMemProxy())) + if (!gdt.copyIn(tc->getVirtProxy())) panic("Failed to copy in GDT for %s.\n", desc->name()); if (userDesc->entry_number == (uint32_t)(-1)) { @@ -249,9 +249,9 @@ setThreadArea32Func(SyscallDesc *desc, int callnum, ThreadContext *tc) gdt[index] = (uint64_t)segDesc; - if (!userDesc.copyOut(tc->getMemProxy())) + if (!userDesc.copyOut(tc->getVirtProxy())) return -EFAULT; - if (!gdt.copyOut(tc->getMemProxy())) + if (!gdt.copyOut(tc->getVirtProxy())) panic("Failed to copy out GDT for %s.\n", desc->name()); return 0; diff --git a/src/arch/x86/pseudo_inst.cc b/src/arch/x86/pseudo_inst.cc index 253c91441..6c1a7f8bf 100644 --- a/src/arch/x86/pseudo_inst.cc +++ b/src/arch/x86/pseudo_inst.cc @@ -68,7 +68,7 @@ m5PageFault(ThreadContext *tc) Process *p = tc->getProcessPtr(); if (!p->fixupStackFault(tc->readMiscReg(MISCREG_CR2))) { - PortProxy &proxy = tc->getMemProxy(); + PortProxy &proxy = tc->getVirtProxy(); // at this point we should have 6 values on the interrupt stack int size = 6; uint64_t is[size]; diff --git a/src/base/remote_gdb.cc b/src/base/remote_gdb.cc index 347345d17..77b3fbc20 100644 --- a/src/base/remote_gdb.cc +++ b/src/base/remote_gdb.cc @@ -624,13 +624,8 @@ BaseRemoteGDB::read(Addr vaddr, size_t size, char *data) DPRINTF(GDBRead, "read: addr=%#x, size=%d", vaddr, size); - if (FullSystem) { - PortProxy &proxy = tc->getVirtProxy(); - proxy.readBlob(vaddr, data, size); - } else { - PortProxy &proxy = tc->getMemProxy(); - proxy.readBlob(vaddr, data, size); - } + PortProxy &proxy = tc->getVirtProxy(); + proxy.readBlob(vaddr, data, size); #if TRACING_ON if (DTRACE(GDBRead)) { @@ -667,13 +662,8 @@ BaseRemoteGDB::write(Addr vaddr, size_t size, const char *data) } else DPRINTFNR("\n"); } - if (FullSystem) { - PortProxy &proxy = tc->getVirtProxy(); - proxy.writeBlob(vaddr, data, size); - } else { - PortProxy &proxy = tc->getMemProxy(); - proxy.writeBlob(vaddr, data, size); - } + PortProxy &proxy = tc->getVirtProxy(); + proxy.writeBlob(vaddr, data, size); return true; } diff --git a/src/cpu/checker/thread_context.hh b/src/cpu/checker/thread_context.hh index 46ade24bb..2e5f31d77 100644 --- a/src/cpu/checker/thread_context.hh +++ b/src/cpu/checker/thread_context.hh @@ -164,12 +164,6 @@ class CheckerThreadContext : public ThreadContext actualTC->connectMemPorts(tc); } - PortProxy & - getMemProxy() override - { - return actualTC->getMemProxy(); - } - /** Executes a syscall in SE mode. */ void syscall(int64_t callnum, Fault *fault) override diff --git a/src/cpu/o3/thread_context.hh b/src/cpu/o3/thread_context.hh index a3698cf2e..9029aba3e 100644 --- a/src/cpu/o3/thread_context.hh +++ b/src/cpu/o3/thread_context.hh @@ -140,12 +140,6 @@ class O3ThreadContext : public ThreadContext thread->initMemProxies(tc); } - PortProxy & - getMemProxy() override - { - return thread->getMemProxy(); - } - /** Returns this thread's status. */ Status status() const override { return thread->status(); } diff --git a/src/cpu/simple_thread.hh b/src/cpu/simple_thread.hh index 991c6bd80..301e18d54 100644 --- a/src/cpu/simple_thread.hh +++ b/src/cpu/simple_thread.hh @@ -223,12 +223,6 @@ class SimpleThread : public ThreadState, public ThreadContext ThreadState::initMemProxies(tc); } - PortProxy & - getMemProxy() override - { - return ThreadState::getMemProxy(); - } - Process *getProcessPtr() override { return ThreadState::getProcessPtr(); } void setProcessPtr(Process *p) override { ThreadState::setProcessPtr(p); } diff --git a/src/cpu/thread_context.hh b/src/cpu/thread_context.hh index f8b69d096..0bd29302b 100644 --- a/src/cpu/thread_context.hh +++ b/src/cpu/thread_context.hh @@ -160,8 +160,6 @@ class ThreadContext */ virtual void initMemProxies(ThreadContext *tc) = 0; - virtual PortProxy &getMemProxy() = 0; - virtual Process *getProcessPtr() = 0; virtual void setProcessPtr(Process *p) = 0; diff --git a/src/cpu/thread_state.cc b/src/cpu/thread_state.cc index 3396c75c7..dc4a624a7 100644 --- a/src/cpu/thread_state.cc +++ b/src/cpu/thread_state.cc @@ -134,15 +134,6 @@ ThreadState::getPhysProxy() PortProxy & ThreadState::getVirtProxy() { - assert(FullSystem); - assert(virtProxy != NULL); - return *virtProxy; -} - -PortProxy & -ThreadState::getMemProxy() -{ - assert(!FullSystem); assert(virtProxy != NULL); return *virtProxy; } diff --git a/src/cpu/thread_state.hh b/src/cpu/thread_state.hh index db4a3f414..3e4b29c91 100644 --- a/src/cpu/thread_state.hh +++ b/src/cpu/thread_state.hh @@ -122,8 +122,6 @@ struct ThreadState : public Serializable { } } - PortProxy &getMemProxy(); - /** Reads the number of instructions functionally executed and * committed. */ diff --git a/src/gpu-compute/cl_driver.cc b/src/gpu-compute/cl_driver.cc index 229734328..c63856a2e 100644 --- a/src/gpu-compute/cl_driver.cc +++ b/src/gpu-compute/cl_driver.cc @@ -137,7 +137,7 @@ ClDriver::ioctl(ThreadContext *tc, unsigned req) k->numInsts() * sizeof(TheGpuISA::RawMachInst); } - sizes.copyOut(tc->getMemProxy()); + sizes.copyOut(tc->getVirtProxy()); } break; @@ -158,7 +158,7 @@ ClDriver::ioctl(ThreadContext *tc, unsigned req) ki->spill_mem_size = kernelInfo[i].spill_mem_size; } - kinfo.copyOut(tc->getMemProxy()); + kinfo.copyOut(tc->getVirtProxy()); } break; @@ -183,7 +183,7 @@ ClDriver::ioctl(ThreadContext *tc, unsigned req) assert(bufp - (char *)buf.bufferPtr() == string_table_size); - buf.copyOut(tc->getMemProxy()); + buf.copyOut(tc->getVirtProxy()); } break; @@ -198,7 +198,7 @@ ClDriver::ioctl(ThreadContext *tc, unsigned req) memcpy(datap, kernels.back()->readonly_data, size); - data.copyOut(tc->getMemProxy()); + data.copyOut(tc->getVirtProxy()); } break; @@ -227,7 +227,7 @@ ClDriver::ioctl(ThreadContext *tc, unsigned req) } } - buf.copyOut(tc->getMemProxy()); + buf.copyOut(tc->getVirtProxy()); } break; @@ -235,7 +235,7 @@ ClDriver::ioctl(ThreadContext *tc, unsigned req) { BufferArg buf(buf_addr, sizeof(uint32_t)); *((uint32_t*)buf.bufferPtr()) = dispatcher->getNumCUs(); - buf.copyOut(tc->getMemProxy()); + buf.copyOut(tc->getVirtProxy()); } break; @@ -243,14 +243,14 @@ ClDriver::ioctl(ThreadContext *tc, unsigned req) { BufferArg buf(buf_addr, sizeof(uint32_t)); *((uint32_t*)buf.bufferPtr()) = dispatcher->wfSize(); - buf.copyOut(tc->getMemProxy()); + buf.copyOut(tc->getVirtProxy()); } break; case HSA_GET_HW_STATIC_CONTEXT_SIZE: { BufferArg buf(buf_addr, sizeof(uint32_t)); *((uint32_t*)buf.bufferPtr()) = dispatcher->getStaticContextSize(); - buf.copyOut(tc->getMemProxy()); + buf.copyOut(tc->getVirtProxy()); } break; diff --git a/src/sim/process.cc b/src/sim/process.cc index 81f2cd6aa..f974fa5ba 100644 --- a/src/sim/process.cc +++ b/src/sim/process.cc @@ -162,7 +162,7 @@ Process::clone(ThreadContext *otc, ThreadContext *ntc, delete np->pTable; np->pTable = pTable; auto &proxy = dynamic_cast( - ntc->getMemProxy()); + ntc->getVirtProxy()); proxy.setPageTable(np->pTable); np->memState = memState; @@ -311,13 +311,13 @@ Process::replicatePage(Addr vaddr, Addr new_paddr, ThreadContext *old_tc, // Read from old physical page. uint8_t *buf_p = new uint8_t[PageBytes]; - old_tc->getMemProxy().readBlob(vaddr, buf_p, PageBytes); + old_tc->getVirtProxy().readBlob(vaddr, buf_p, PageBytes); // 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, PageBytes, clobber); - new_tc->getMemProxy().writeBlob(vaddr, buf_p, PageBytes); + new_tc->getVirtProxy().writeBlob(vaddr, buf_p, PageBytes); delete[] buf_p; } diff --git a/src/sim/syscall_emul.cc b/src/sim/syscall_emul.cc index 7e8f9062a..eaf90ec76 100644 --- a/src/sim/syscall_emul.cc +++ b/src/sim/syscall_emul.cc @@ -90,7 +90,7 @@ exitFutexWake(ThreadContext *tc, Addr addr, uint64_t tgid) BufferArg ctidBuf(addr, sizeof(long)); long *ctid = (long *)ctidBuf.bufferPtr(); *ctid = 0; - ctidBuf.copyOut(tc->getMemProxy()); + ctidBuf.copyOut(tc->getVirtProxy()); FutexMap &futex_map = tc->getSystemPtr()->futexMap; // Wake one of the waiting threads. @@ -265,7 +265,7 @@ brkFunc(SyscallDesc *desc, int num, ThreadContext *tc) // if the address is already there, zero it out else { uint8_t zero = 0; - PortProxy &tp = tc->getMemProxy(); + PortProxy &tp = tc->getVirtProxy(); // split non-page aligned accesses Addr next_page = roundUp(gen.addr(), PageBytes); @@ -354,7 +354,7 @@ _llseekFunc(SyscallDesc *desc, int num, ThreadContext *tc) // Assuming that the size of loff_t is 64 bits on the target platform BufferArg result_buf(result_ptr, sizeof(result)); memcpy(result_buf.bufferPtr(), &result, sizeof(result)); - result_buf.copyOut(tc->getMemProxy()); + result_buf.copyOut(tc->getVirtProxy()); return 0; } @@ -382,7 +382,7 @@ gethostnameFunc(SyscallDesc *desc, int num, ThreadContext *tc) strncpy((char *)name.bufferPtr(), hostname, name_len); - name.copyOut(tc->getMemProxy()); + name.copyOut(tc->getVirtProxy()); return 0; } @@ -414,7 +414,7 @@ getcwdFunc(SyscallDesc *desc, int num, ThreadContext *tc) } } - buf.copyOut(tc->getMemProxy()); + buf.copyOut(tc->getVirtProxy()); return (result == -1) ? -errno : result; } @@ -431,7 +431,7 @@ readlinkFunc(SyscallDesc *desc, int num, ThreadContext *tc, int index) string path; auto p = tc->getProcessPtr(); - if (!tc->getMemProxy().tryReadString(path, p->getSyscallArg(tc, index))) + if (!tc->getVirtProxy().tryReadString(path, p->getSyscallArg(tc, index))) return -EFAULT; // Adjust path for cwd and redirection @@ -480,7 +480,7 @@ readlinkFunc(SyscallDesc *desc, int num, ThreadContext *tc, int index) (char*)buf.bufferPtr()); } - buf.copyOut(tc->getMemProxy()); + buf.copyOut(tc->getVirtProxy()); return (result == -1) ? -errno : result; } @@ -497,7 +497,7 @@ unlinkHelper(SyscallDesc *desc, int num, ThreadContext *tc, int index) string path; auto p = tc->getProcessPtr(); - if (!tc->getMemProxy().tryReadString(path, p->getSyscallArg(tc, index))) + if (!tc->getVirtProxy().tryReadString(path, p->getSyscallArg(tc, index))) return -EFAULT; path = p->checkPathRedirect(path); @@ -514,7 +514,7 @@ linkFunc(SyscallDesc *desc, int num, ThreadContext *tc) auto p = tc->getProcessPtr(); int index = 0; - auto &virt_mem = tc->getMemProxy(); + auto &virt_mem = tc->getVirtProxy(); if (!virt_mem.tryReadString(path, p->getSyscallArg(tc, index))) return -EFAULT; if (!virt_mem.tryReadString(new_path, p->getSyscallArg(tc, index))) @@ -535,7 +535,7 @@ symlinkFunc(SyscallDesc *desc, int num, ThreadContext *tc) auto p = tc->getProcessPtr(); int index = 0; - auto &virt_mem = tc->getMemProxy(); + auto &virt_mem = tc->getVirtProxy(); if (!virt_mem.tryReadString(path, p->getSyscallArg(tc, index))) return -EFAULT; if (!virt_mem.tryReadString(new_path, p->getSyscallArg(tc, index))) @@ -554,7 +554,7 @@ mkdirFunc(SyscallDesc *desc, int num, ThreadContext *tc) auto p = tc->getProcessPtr(); int index = 0; std::string path; - if (!tc->getMemProxy().tryReadString(path, p->getSyscallArg(tc, index))) + if (!tc->getVirtProxy().tryReadString(path, p->getSyscallArg(tc, index))) return -EFAULT; path = p->checkPathRedirect(path); @@ -571,13 +571,17 @@ renameFunc(SyscallDesc *desc, int num, ThreadContext *tc) auto p = tc->getProcessPtr(); int index = 0; - if (!tc->getMemProxy().tryReadString(old_name, p->getSyscallArg(tc, index))) + if (!tc->getVirtProxy().tryReadString( + old_name, p->getSyscallArg(tc, index))) { return -EFAULT; + } string new_name; - if (!tc->getMemProxy().tryReadString(new_name, p->getSyscallArg(tc, index))) + if (!tc->getVirtProxy().tryReadString( + new_name, p->getSyscallArg(tc, index))) { return -EFAULT; + } // Adjust path for cwd and redirection old_name = p->checkPathRedirect(old_name); @@ -594,7 +598,7 @@ truncateFunc(SyscallDesc *desc, int num, ThreadContext *tc) auto p = tc->getProcessPtr(); int index = 0; - if (!tc->getMemProxy().tryReadString(path, p->getSyscallArg(tc, index))) + if (!tc->getVirtProxy().tryReadString(path, p->getSyscallArg(tc, index))) return -EFAULT; off_t length = p->getSyscallArg(tc, index); @@ -630,8 +634,10 @@ truncate64Func(SyscallDesc *desc, int num, ThreadContext *tc) auto process = tc->getProcessPtr(); string path; - if (!tc->getMemProxy().tryReadString(path, process->getSyscallArg(tc, index))) + if (!tc->getVirtProxy().tryReadString( + path, process->getSyscallArg(tc, index))) { return -EFAULT; + } int64_t length = process->getSyscallArg(tc, index, 64); @@ -685,7 +691,7 @@ chownFunc(SyscallDesc *desc, int num, ThreadContext *tc) auto p = tc->getProcessPtr(); int index = 0; - if (!tc->getMemProxy().tryReadString(path, p->getSyscallArg(tc, index))) + if (!tc->getVirtProxy().tryReadString(path, p->getSyscallArg(tc, index))) return -EFAULT; /* XXX endianess */ @@ -903,7 +909,7 @@ pipeImpl(SyscallDesc *desc, int callnum, ThreadContext *tc, bool pseudoPipe) int *buf_ptr = (int*)tgt_handle.bufferPtr(); buf_ptr[0] = tgt_fds[0]; buf_ptr[1] = tgt_fds[1]; - tgt_handle.copyOut(tc->getMemProxy()); + tgt_handle.copyOut(tc->getVirtProxy()); return 0; } @@ -1081,7 +1087,7 @@ accessFunc(SyscallDesc *desc, int callnum, ThreadContext *tc, int index) { string path; auto p = tc->getProcessPtr(); - if (!tc->getMemProxy().tryReadString(path, p->getSyscallArg(tc, index))) + if (!tc->getVirtProxy().tryReadString(path, p->getSyscallArg(tc, index))) return -EFAULT; // Adjust path for cwd and redirection @@ -1105,7 +1111,7 @@ mknodFunc(SyscallDesc *desc, int num, ThreadContext *tc) auto p = tc->getProcessPtr(); int index = 0; std::string path; - if (!tc->getMemProxy().tryReadString(path, p->getSyscallArg(tc, index))) + if (!tc->getVirtProxy().tryReadString(path, p->getSyscallArg(tc, index))) return -EFAULT; path = p->checkPathRedirect(path); @@ -1122,7 +1128,7 @@ chdirFunc(SyscallDesc *desc, int num, ThreadContext *tc) auto p = tc->getProcessPtr(); int index = 0; std::string path; - if (!tc->getMemProxy().tryReadString(path, p->getSyscallArg(tc, index))) + if (!tc->getVirtProxy().tryReadString(path, p->getSyscallArg(tc, index))) return -EFAULT; std::string tgt_cwd; @@ -1150,7 +1156,7 @@ rmdirFunc(SyscallDesc *desc, int num, ThreadContext *tc) auto p = tc->getProcessPtr(); int index = 0; std::string path; - if (!tc->getMemProxy().tryReadString(path, p->getSyscallArg(tc, index))) + if (!tc->getVirtProxy().tryReadString(path, p->getSyscallArg(tc, index))) return -EFAULT; path = p->checkPathRedirect(path); @@ -1199,7 +1205,7 @@ getdentsImpl(SyscallDesc *desc, int callnum, ThreadContext *tc) traversed += host_reclen; } - buf_arg.copyOut(tc->getMemProxy()); + buf_arg.copyOut(tc->getVirtProxy()); return status; } #endif @@ -1262,7 +1268,7 @@ bindFunc(SyscallDesc *desc, int num, ThreadContext *tc) int addrlen = p->getSyscallArg(tc, index); BufferArg bufSock(buf_ptr, addrlen); - bufSock.copyIn(tc->getMemProxy()); + bufSock.copyIn(tc->getVirtProxy()); auto sfdp = std::dynamic_pointer_cast((*p->fds)[tgt_fd]); if (!sfdp) @@ -1304,7 +1310,7 @@ connectFunc(SyscallDesc *desc, int num, ThreadContext *tc) int addrlen = p->getSyscallArg(tc, index); BufferArg addr(buf_ptr, addrlen); - addr.copyIn(tc->getMemProxy()); + addr.copyIn(tc->getVirtProxy()); auto sfdp = std::dynamic_pointer_cast((*p->fds)[tgt_fd]); if (!sfdp) @@ -1343,14 +1349,14 @@ recvfromFunc(SyscallDesc *desc, int num, ThreadContext *tc) if (addrlenPtr != 0) { // Read address length parameter. BufferArg addrlenBuf(addrlenPtr, sizeof(socklen_t)); - addrlenBuf.copyIn(tc->getMemProxy()); + addrlenBuf.copyIn(tc->getVirtProxy()); addrLen = *((socklen_t *)addrlenBuf.bufferPtr()); } struct sockaddr sa, *sap = NULL; if (addrLen != 0) { BufferArg addrBuf(addrPtr, addrLen); - addrBuf.copyIn(tc->getMemProxy()); + addrBuf.copyIn(tc->getVirtProxy()); memcpy(&sa, (struct sockaddr *)addrBuf.bufferPtr(), sizeof(struct sockaddr)); sap = &sa; @@ -1364,20 +1370,20 @@ recvfromFunc(SyscallDesc *desc, int num, ThreadContext *tc) return -errno; // Pass the received data out. - bufrBuf.copyOut(tc->getMemProxy()); + bufrBuf.copyOut(tc->getVirtProxy()); // Copy address to addrPtr and pass it on. if (sap != NULL) { BufferArg addrBuf(addrPtr, addrLen); memcpy(addrBuf.bufferPtr(), sap, sizeof(sa)); - addrBuf.copyOut(tc->getMemProxy()); + addrBuf.copyOut(tc->getVirtProxy()); } // 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->getMemProxy()); + addrlenBuf.copyOut(tc->getVirtProxy()); } return recvd_size; @@ -1402,13 +1408,13 @@ sendtoFunc(SyscallDesc *desc, int num, ThreadContext *tc) // Reserve buffer space. BufferArg bufrBuf(bufrPtr, bufrLen); - bufrBuf.copyIn(tc->getMemProxy()); + bufrBuf.copyIn(tc->getVirtProxy()); struct sockaddr sa, *sap = nullptr; memset(&sa, 0, sizeof(sockaddr)); if (addrLen != 0) { BufferArg addrBuf(addrPtr, addrLen); - addrBuf.copyIn(tc->getMemProxy()); + addrBuf.copyIn(tc->getVirtProxy()); memcpy(&sa, (sockaddr*)addrBuf.bufferPtr(), addrLen); sap = &sa; } @@ -1458,7 +1464,7 @@ recvmsgFunc(SyscallDesc *desc, int num, ThreadContext *tc) * copy every field from the structures into our BufferArg classes. */ BufferArg msgBuf(msgPtr, sizeof(struct msghdr)); - msgBuf.copyIn(tc->getMemProxy()); + msgBuf.copyIn(tc->getVirtProxy()); struct msghdr *msgHdr = (struct msghdr *)msgBuf.bufferPtr(); /** @@ -1478,7 +1484,7 @@ recvmsgFunc(SyscallDesc *desc, int num, ThreadContext *tc) 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->getMemProxy()); + /*3*/nameBuf->copyIn(tc->getVirtProxy()); /*4*/msgHdr->msg_name = nameBuf->bufferPtr(); } @@ -1498,14 +1504,14 @@ recvmsgFunc(SyscallDesc *desc, int num, ThreadContext *tc) /*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->getMemProxy()); + /*3*/iovBuf->copyIn(tc->getVirtProxy()); 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->getMemProxy()); + /*3*/iovecBuf[i]->copyIn(tc->getVirtProxy()); /*4*/((struct iovec *)iovBuf->bufferPtr())[i].iov_base = iovecBuf[i]->bufferPtr(); } @@ -1521,7 +1527,7 @@ recvmsgFunc(SyscallDesc *desc, int num, ThreadContext *tc) /*1*/msg_control_phold = (Addr)msgHdr->msg_control; /*2*/controlBuf = new BufferArg(msg_control_phold, CMSG_ALIGN(msgHdr->msg_controllen)); - /*3*/controlBuf->copyIn(tc->getMemProxy()); + /*3*/controlBuf->copyIn(tc->getVirtProxy()); /*4*/msgHdr->msg_control = controlBuf->bufferPtr(); } @@ -1531,7 +1537,7 @@ recvmsgFunc(SyscallDesc *desc, int num, ThreadContext *tc) return -errno; if (msgHdr->msg_name) { - nameBuf->copyOut(tc->getMemProxy()); + nameBuf->copyOut(tc->getVirtProxy()); delete(nameBuf); msgHdr->msg_name = (void *)msg_name_phold; } @@ -1539,24 +1545,24 @@ recvmsgFunc(SyscallDesc *desc, int num, ThreadContext *tc) 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->getMemProxy()); + iovecBuf[i]->copyOut(tc->getVirtProxy()); delete iovecBuf[i]; ((struct iovec *)iovBuf->bufferPtr())[i].iov_base = (void *)iovec_base_phold[i]; } } - iovBuf->copyOut(tc->getMemProxy()); + iovBuf->copyOut(tc->getVirtProxy()); delete iovBuf; msgHdr->msg_iov = (struct iovec *)msg_iov_phold; } if (msgHdr->msg_control) { - controlBuf->copyOut(tc->getMemProxy()); + controlBuf->copyOut(tc->getVirtProxy()); delete(controlBuf); msgHdr->msg_control = (void *)msg_control_phold; } - msgBuf.copyOut(tc->getMemProxy()); + msgBuf.copyOut(tc->getVirtProxy()); return recvd_size; } @@ -1579,7 +1585,7 @@ sendmsgFunc(SyscallDesc *desc, int num, ThreadContext *tc) * Reserve buffer space. */ BufferArg msgBuf(msgPtr, sizeof(struct msghdr)); - msgBuf.copyIn(tc->getMemProxy()); + msgBuf.copyIn(tc->getVirtProxy()); struct msghdr msgHdr = *((struct msghdr *)msgBuf.bufferPtr()); /** @@ -1588,7 +1594,7 @@ sendmsgFunc(SyscallDesc *desc, int num, ThreadContext *tc) */ struct iovec *iovPtr = msgHdr.msg_iov; BufferArg iovBuf((Addr)iovPtr, sizeof(struct iovec) * msgHdr.msg_iovlen); - iovBuf.copyIn(tc->getMemProxy()); + iovBuf.copyIn(tc->getVirtProxy()); struct iovec *iov = (struct iovec *)iovBuf.bufferPtr(); msgHdr.msg_iov = iov; @@ -1608,7 +1614,7 @@ sendmsgFunc(SyscallDesc *desc, int num, ThreadContext *tc) 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->getMemProxy()); + bufferArray[iovIndex]->copyIn(tc->getVirtProxy()); iov[iovIndex].iov_base = bufferArray[iovIndex]->bufferPtr(); } @@ -1664,12 +1670,12 @@ getsockoptFunc(SyscallDesc *desc, int num, ThreadContext *tc) // copy val to valPtr and pass it on BufferArg valBuf(valPtr, sizeof(val)); memcpy(valBuf.bufferPtr(), &val, sizeof(val)); - valBuf.copyOut(tc->getMemProxy()); + valBuf.copyOut(tc->getVirtProxy()); // copy len to lenPtr and pass it on BufferArg lenBuf(lenPtr, sizeof(len)); memcpy(lenBuf.bufferPtr(), &len, sizeof(len)); - lenBuf.copyOut(tc->getMemProxy()); + lenBuf.copyOut(tc->getVirtProxy()); return status; } @@ -1693,7 +1699,7 @@ getsocknameFunc(SyscallDesc *desc, int num, ThreadContext *tc) // Read in the value of len from the passed pointer. BufferArg lenBuf(lenPtr, sizeof(socklen_t)); - lenBuf.copyIn(tc->getMemProxy()); + lenBuf.copyIn(tc->getVirtProxy()); socklen_t len = *(socklen_t *)lenBuf.bufferPtr(); struct sockaddr sa; @@ -1705,11 +1711,11 @@ getsocknameFunc(SyscallDesc *desc, int num, ThreadContext *tc) // Copy address to addrPtr and pass it on. BufferArg addrBuf(addrPtr, sizeof(sa)); memcpy(addrBuf.bufferPtr(), &sa, sizeof(sa)); - addrBuf.copyOut(tc->getMemProxy()); + addrBuf.copyOut(tc->getVirtProxy()); // Copy len to lenPtr and pass it on. *(socklen_t *)lenBuf.bufferPtr() = len; - lenBuf.copyOut(tc->getMemProxy()); + lenBuf.copyOut(tc->getVirtProxy()); return status; } @@ -1729,7 +1735,7 @@ getpeernameFunc(SyscallDesc *desc, int num, ThreadContext *tc) int sim_fd = sfdp->getSimFD(); BufferArg bufAddrlen(addrlenPtr, sizeof(unsigned)); - bufAddrlen.copyIn(tc->getMemProxy()); + bufAddrlen.copyIn(tc->getVirtProxy()); BufferArg bufSock(sockAddrPtr, *(unsigned *)bufAddrlen.bufferPtr()); int retval = getpeername(sim_fd, @@ -1737,8 +1743,8 @@ getpeernameFunc(SyscallDesc *desc, int num, ThreadContext *tc) (unsigned *)bufAddrlen.bufferPtr()); if (retval != -1) { - bufSock.copyOut(tc->getMemProxy()); - bufAddrlen.copyOut(tc->getMemProxy()); + bufSock.copyOut(tc->getVirtProxy()); + bufAddrlen.copyOut(tc->getVirtProxy()); } return (retval == -1) ? -errno : retval; @@ -1756,7 +1762,7 @@ setsockoptFunc(SyscallDesc *desc, int num, ThreadContext *tc) socklen_t len = p->getSyscallArg(tc, index); BufferArg valBuf(valPtr, len); - valBuf.copyIn(tc->getMemProxy()); + valBuf.copyIn(tc->getVirtProxy()); auto sfdp = std::dynamic_pointer_cast((*p->fds)[tgt_fd]); if (!sfdp) diff --git a/src/sim/syscall_emul.hh b/src/sim/syscall_emul.hh index 4cb93c88f..d8270fb23 100644 --- a/src/sim/syscall_emul.hh +++ b/src/sim/syscall_emul.hh @@ -351,7 +351,7 @@ futexFunc(SyscallDesc *desc, int callnum, ThreadContext *tc) 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->getMemProxy()); + buf.copyIn(tc->getVirtProxy()); int mem_val = *(int*)buf.bufferPtr(); /* @@ -378,7 +378,7 @@ futexFunc(SyscallDesc *desc, int callnum, ThreadContext *tc) // Ensure futex system call accessed atomically. BufferArg buf(uaddr, sizeof(int)); - buf.copyIn(tc->getMemProxy()); + buf.copyIn(tc->getVirtProxy()); int mem_val = *(int*)buf.bufferPtr(); /* * For CMP_REQUEUE, the whole operation is only started only if @@ -411,7 +411,7 @@ futexFunc(SyscallDesc *desc, int callnum, ThreadContext *tc) */ // get value from simulated-space BufferArg buf(uaddr2, sizeof(int)); - buf.copyIn(tc->getMemProxy()); + buf.copyIn(tc->getVirtProxy()); int oldval = *(int*)buf.bufferPtr(); int newval = oldval; // extract op, oparg, cmp, cmparg from val3 @@ -435,7 +435,7 @@ futexFunc(SyscallDesc *desc, int callnum, ThreadContext *tc) newval ^= wake_oparg; // copy updated value back to simulated-space *(int*)buf.bufferPtr() = newval; - buf.copyOut(tc->getMemProxy()); + buf.copyOut(tc->getVirtProxy()); // perform the first wake-up int woken1 = futex_map.wakeup(uaddr, process->tgid(), val); int woken2 = 0; @@ -699,20 +699,20 @@ ioctlFunc(SyscallDesc *desc, int callnum, ThreadContext *tc) case SIOCGIFCONF: { Addr conf_addr = p->getSyscallArg(tc, index); BufferArg conf_arg(conf_addr, sizeof(ifconf)); - conf_arg.copyIn(tc->getMemProxy()); + conf_arg.copyIn(tc->getVirtProxy()); 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->getMemProxy()); + ifc_buf_arg.copyIn(tc->getVirtProxy()); 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->getMemProxy()); - conf_arg.copyOut(tc->getMemProxy()); + ifc_buf_arg.copyOut(tc->getVirtProxy()); + conf_arg.copyOut(tc->getVirtProxy()); } return status; @@ -729,11 +729,11 @@ ioctlFunc(SyscallDesc *desc, int callnum, ThreadContext *tc) case SIOCGIFMTU: { Addr req_addr = p->getSyscallArg(tc, index); BufferArg req_arg(req_addr, sizeof(ifreq)); - req_arg.copyIn(tc->getMemProxy()); + req_arg.copyIn(tc->getVirtProxy()); status = ioctl(sfdp->getSimFD(), req, req_arg.bufferPtr()); if (status != -1) - req_arg.copyOut(tc->getMemProxy()); + req_arg.copyOut(tc->getVirtProxy()); return status; } } @@ -768,7 +768,7 @@ openImpl(SyscallDesc *desc, int callnum, ThreadContext *tc, bool isopenat) * string from that memory space into the host's working memory space. */ std::string path; - if (!tc->getMemProxy().tryReadString(path, p->getSyscallArg(tc, index))) + if (!tc->getVirtProxy().tryReadString(path, p->getSyscallArg(tc, index))) return -EFAULT; #ifdef __CYGWIN32__ @@ -976,7 +976,7 @@ renameatFunc(SyscallDesc *desc, int callnum, ThreadContext *tc) std::string old_name; - if (!tc->getMemProxy().tryReadString(old_name, + if (!tc->getVirtProxy().tryReadString(old_name, process->getSyscallArg(tc, index))) return -EFAULT; @@ -986,7 +986,7 @@ renameatFunc(SyscallDesc *desc, int callnum, ThreadContext *tc) std::string new_name; - if (!tc->getMemProxy().tryReadString(new_name, + if (!tc->getVirtProxy().tryReadString(new_name, process->getSyscallArg(tc, index))) return -EFAULT; @@ -1013,7 +1013,7 @@ sysinfoFunc(SyscallDesc *desc, int callnum, ThreadContext *tc) sysinfo->totalram = process->system->memSize(); sysinfo->mem_unit = 1; - sysinfo.copyOut(tc->getMemProxy()); + sysinfo.copyOut(tc->getVirtProxy()); return 0; } @@ -1027,7 +1027,7 @@ chmodFunc(SyscallDesc *desc, int callnum, ThreadContext *tc) auto process = tc->getProcessPtr(); int index = 0; - if (!tc->getMemProxy().tryReadString(path, + if (!tc->getVirtProxy().tryReadString(path, process->getSyscallArg(tc, index))) { return -EFAULT; } @@ -1060,7 +1060,7 @@ pollFunc(SyscallDesc *desc, int num, ThreadContext *tc) int tmout = p->getSyscallArg(tc, index); BufferArg fdsBuf(fdsPtr, sizeof(struct pollfd) * nfds); - fdsBuf.copyIn(tc->getMemProxy()); + fdsBuf.copyIn(tc->getVirtProxy()); /** * Record the target file descriptors in a local variable. We need to @@ -1120,7 +1120,7 @@ pollFunc(SyscallDesc *desc, int num, ThreadContext *tc) * Copy out the pollfd struct because the host may have updated fields * in the structure. */ - fdsBuf.copyOut(tc->getMemProxy()); + fdsBuf.copyOut(tc->getVirtProxy()); return status; } @@ -1236,7 +1236,7 @@ statFunc(SyscallDesc *desc, int callnum, ThreadContext *tc) auto process = tc->getProcessPtr(); int index = 0; - if (!tc->getMemProxy().tryReadString(path, + if (!tc->getVirtProxy().tryReadString(path, process->getSyscallArg(tc, index))) { return -EFAULT; } @@ -1251,7 +1251,7 @@ statFunc(SyscallDesc *desc, int callnum, ThreadContext *tc) if (result < 0) return -errno; - copyOutStatBuf(tc->getMemProxy(), bufPtr, &hostBuf); + copyOutStatBuf(tc->getVirtProxy(), bufPtr, &hostBuf); return 0; } @@ -1266,7 +1266,7 @@ stat64Func(SyscallDesc *desc, int callnum, ThreadContext *tc) auto process = tc->getProcessPtr(); int index = 0; - if (!tc->getMemProxy().tryReadString(path, + if (!tc->getVirtProxy().tryReadString(path, process->getSyscallArg(tc, index))) return -EFAULT; Addr bufPtr = process->getSyscallArg(tc, index); @@ -1285,7 +1285,7 @@ stat64Func(SyscallDesc *desc, int callnum, ThreadContext *tc) if (result < 0) return -errno; - copyOutStat64Buf(tc->getMemProxy(), bufPtr, &hostBuf); + copyOutStat64Buf(tc->getVirtProxy(), bufPtr, &hostBuf); return 0; } @@ -1303,7 +1303,7 @@ fstatat64Func(SyscallDesc *desc, int callnum, ThreadContext *tc) warn("fstatat64: first argument not AT_FDCWD; unlikely to work"); std::string path; - if (!tc->getMemProxy().tryReadString(path, + if (!tc->getVirtProxy().tryReadString(path, process->getSyscallArg(tc, index))) return -EFAULT; Addr bufPtr = process->getSyscallArg(tc, index); @@ -1322,7 +1322,7 @@ fstatat64Func(SyscallDesc *desc, int callnum, ThreadContext *tc) if (result < 0) return -errno; - copyOutStat64Buf(tc->getMemProxy(), bufPtr, &hostBuf); + copyOutStat64Buf(tc->getVirtProxy(), bufPtr, &hostBuf); return 0; } @@ -1354,7 +1354,7 @@ fstat64Func(SyscallDesc *desc, int callnum, ThreadContext *tc) if (result < 0) return -errno; - copyOutStat64Buf(tc->getMemProxy(), bufPtr, &hostBuf, (sim_fd == 1)); + copyOutStat64Buf(tc->getVirtProxy(), bufPtr, &hostBuf, (sim_fd == 1)); return 0; } @@ -1369,7 +1369,7 @@ lstatFunc(SyscallDesc *desc, int callnum, ThreadContext *tc) auto process = tc->getProcessPtr(); int index = 0; - if (!tc->getMemProxy().tryReadString(path, + if (!tc->getVirtProxy().tryReadString(path, process->getSyscallArg(tc, index))) { return -EFAULT; } @@ -1384,7 +1384,7 @@ lstatFunc(SyscallDesc *desc, int callnum, ThreadContext *tc) if (result < 0) return -errno; - copyOutStatBuf(tc->getMemProxy(), bufPtr, &hostBuf); + copyOutStatBuf(tc->getVirtProxy(), bufPtr, &hostBuf); return 0; } @@ -1398,7 +1398,7 @@ lstat64Func(SyscallDesc *desc, int callnum, ThreadContext *tc) auto process = tc->getProcessPtr(); int index = 0; - if (!tc->getMemProxy().tryReadString(path, + if (!tc->getVirtProxy().tryReadString(path, process->getSyscallArg(tc, index))) { return -EFAULT; } @@ -1418,7 +1418,7 @@ lstat64Func(SyscallDesc *desc, int callnum, ThreadContext *tc) if (result < 0) return -errno; - copyOutStat64Buf(tc->getMemProxy(), bufPtr, &hostBuf); + copyOutStat64Buf(tc->getVirtProxy(), bufPtr, &hostBuf); return 0; } @@ -1446,7 +1446,7 @@ fstatFunc(SyscallDesc *desc, int callnum, ThreadContext *tc) if (result < 0) return -errno; - copyOutStatBuf(tc->getMemProxy(), bufPtr, &hostBuf, (sim_fd == 1)); + copyOutStatBuf(tc->getVirtProxy(), bufPtr, &hostBuf, (sim_fd == 1)); return 0; } @@ -1461,7 +1461,7 @@ statfsFunc(SyscallDesc *desc, int callnum, ThreadContext *tc) auto process = tc->getProcessPtr(); int index = 0; - if (!tc->getMemProxy().tryReadString(path, + if (!tc->getVirtProxy().tryReadString(path, process->getSyscallArg(tc, index))) { return -EFAULT; } @@ -1476,7 +1476,7 @@ statfsFunc(SyscallDesc *desc, int callnum, ThreadContext *tc) if (result < 0) return -errno; - copyOutStatfsBuf(tc->getMemProxy(), bufPtr, &hostBuf); + copyOutStatfsBuf(tc->getVirtProxy(), bufPtr, &hostBuf); return 0; #else warnUnsupportedOS("statfs"); @@ -1567,7 +1567,7 @@ cloneFunc(SyscallDesc *desc, int callnum, ThreadContext *tc) BufferArg ptidBuf(ptidPtr, sizeof(long)); long *ptid = (long *)ptidBuf.bufferPtr(); *ptid = cp->pid(); - ptidBuf.copyOut(tc->getMemProxy()); + ptidBuf.copyOut(tc->getVirtProxy()); } if (flags & OS::TGT_CLONE_THREAD) { @@ -1588,7 +1588,7 @@ cloneFunc(SyscallDesc *desc, int callnum, ThreadContext *tc) BufferArg ctidBuf(ctidPtr, sizeof(long)); long *ctid = (long *)ctidBuf.bufferPtr(); *ctid = cp->pid(); - ctidBuf.copyOut(ctc->getMemProxy()); + ctidBuf.copyOut(ctc->getVirtProxy()); } if (flags & OS::TGT_CLONE_CHILD_CLEARTID) @@ -1644,7 +1644,7 @@ fstatfsFunc(SyscallDesc *desc, int callnum, ThreadContext *tc) if (result < 0) return -errno; - copyOutStatfsBuf(tc->getMemProxy(), bufPtr, &hostBuf); + copyOutStatfsBuf(tc->getVirtProxy(), bufPtr, &hostBuf); return 0; } @@ -1663,7 +1663,7 @@ readvFunc(SyscallDesc *desc, int callnum, ThreadContext *tc) return -EBADF; int sim_fd = ffdp->getSimFD(); - PortProxy &prox = tc->getMemProxy(); + PortProxy &prox = tc->getVirtProxy(); uint64_t tiov_base = p->getSyscallArg(tc, index); size_t count = p->getSyscallArg(tc, index); typename OS::tgt_iovec tiov[count]; @@ -1703,7 +1703,7 @@ writevFunc(SyscallDesc *desc, int callnum, ThreadContext *tc) return -EBADF; int sim_fd = hbfdp->getSimFD(); - PortProxy &prox = tc->getMemProxy(); + PortProxy &prox = tc->getVirtProxy(); uint64_t tiov_base = p->getSyscallArg(tc, index); size_t count = p->getSyscallArg(tc, index); struct iovec hiov[count]; @@ -1841,7 +1841,7 @@ mmapImpl(SyscallDesc *desc, int num, ThreadContext *tc, bool is_mmap2) p->allocateMem(start, length, clobber); // Transfer content into target address space. - PortProxy &tp = tc->getMemProxy(); + PortProxy &tp = tc->getVirtProxy(); if (tgt_flags & OS::TGT_MAP_ANONYMOUS) { // In general, we should zero the mapped area for anonymous mappings, // with something like: @@ -1922,7 +1922,7 @@ pwrite64Func(SyscallDesc *desc, int num, ThreadContext *tc) int sim_fd = ffdp->getSimFD(); BufferArg bufArg(bufPtr, nbytes); - bufArg.copyIn(tc->getMemProxy()); + bufArg.copyIn(tc->getVirtProxy()); int bytes_written = pwrite(sim_fd, bufArg.bufferPtr(), nbytes, offset); @@ -1976,7 +1976,7 @@ getrlimitFunc(SyscallDesc *desc, int callnum, ThreadContext *tc) break; } - rlp.copyOut(tc->getMemProxy()); + rlp.copyOut(tc->getVirtProxy()); return 0; } @@ -2017,7 +2017,7 @@ prlimitFunc(SyscallDesc *desc, int callnum, ThreadContext *tc) return -EINVAL; break; } - rlp.copyOut(tc->getMemProxy()); + rlp.copyOut(tc->getVirtProxy()); } return 0; } @@ -2037,7 +2037,7 @@ clock_gettimeFunc(SyscallDesc *desc, int num, ThreadContext *tc) tp->tv_sec = TheISA::htog(tp->tv_sec); tp->tv_nsec = TheISA::htog(tp->tv_nsec); - tp.copyOut(tc->getMemProxy()); + tp.copyOut(tc->getVirtProxy()); return 0; } @@ -2055,7 +2055,7 @@ clock_getresFunc(SyscallDesc *desc, int num, ThreadContext *tc) tp->tv_sec = 0; tp->tv_nsec = 1; - tp.copyOut(tc->getMemProxy()); + tp.copyOut(tc->getVirtProxy()); return 0; } @@ -2074,7 +2074,7 @@ gettimeofdayFunc(SyscallDesc *desc, int callnum, ThreadContext *tc) tp->tv_sec = TheISA::htog(tp->tv_sec); tp->tv_usec = TheISA::htog(tp->tv_usec); - tp.copyOut(tc->getMemProxy()); + tp.copyOut(tc->getVirtProxy()); return 0; } @@ -2089,14 +2089,14 @@ utimesFunc(SyscallDesc *desc, int callnum, ThreadContext *tc) auto process = tc->getProcessPtr(); int index = 0; - if (!tc->getMemProxy().tryReadString(path, + if (!tc->getVirtProxy().tryReadString(path, process->getSyscallArg(tc, index))) { return -EFAULT; } TypedBufferArg tp(process->getSyscallArg(tc, index)); - tp.copyIn(tc->getMemProxy()); + tp.copyIn(tc->getVirtProxy()); struct timeval hostTimeval[2]; for (int i = 0; i < 2; ++i) { @@ -2124,7 +2124,7 @@ execveFunc(SyscallDesc *desc, int callnum, ThreadContext *tc) int index = 0; std::string path; - PortProxy & mem_proxy = tc->getMemProxy(); + PortProxy & mem_proxy = tc->getVirtProxy(); if (!mem_proxy.tryReadString(path, p->getSyscallArg(tc, index))) return -EFAULT; @@ -2254,7 +2254,7 @@ getrusageFunc(SyscallDesc *desc, int callnum, ThreadContext *tc) who); } - rup.copyOut(tc->getMemProxy()); + rup.copyOut(tc->getVirtProxy()); return 0; } @@ -2279,7 +2279,7 @@ timesFunc(SyscallDesc *desc, int callnum, ThreadContext *tc) bufp->tms_utime = TheISA::htog(bufp->tms_utime); // Write back - bufp.copyOut(tc->getMemProxy()); + bufp.copyOut(tc->getVirtProxy()); // Return clock ticks since system boot return clocks; @@ -2300,7 +2300,7 @@ timeFunc(SyscallDesc *desc, int callnum, ThreadContext *tc) if (taddr != 0) { typename OS::time_t t = sec; t = TheISA::htog(t); - PortProxy &p = tc->getMemProxy(); + PortProxy &p = tc->getVirtProxy(); p.writeBlob(taddr, &t, (int)sizeof(typename OS::time_t)); } return sec; @@ -2398,7 +2398,7 @@ socketpairFunc(SyscallDesc *desc, int num, ThreadContext *tc) fds[0] = p->fds->allocFD(sfdp1); auto sfdp2 = std::make_shared(fds[1], domain, type, prot); fds[1] = p->fds->allocFD(sfdp2); - svBuf.copyOut(tc->getMemProxy()); + svBuf.copyOut(tc->getVirtProxy()); return status; } @@ -2438,11 +2438,11 @@ selectFunc(SyscallDesc *desc, int callnum, ThreadContext *tc) * Copy in the fd_set from the target. */ if (fds_read_ptr) - rd_t.copyIn(tc->getMemProxy()); + rd_t.copyIn(tc->getVirtProxy()); if (fds_writ_ptr) - wr_t.copyIn(tc->getMemProxy()); + wr_t.copyIn(tc->getVirtProxy()); if (fds_excp_ptr) - ex_t.copyIn(tc->getMemProxy()); + ex_t.copyIn(tc->getVirtProxy()); /** * We need to translate the target file descriptor set into a host file @@ -2588,13 +2588,13 @@ selectFunc(SyscallDesc *desc, int callnum, ThreadContext *tc) } if (fds_read_ptr) - rd_t.copyOut(tc->getMemProxy()); + rd_t.copyOut(tc->getVirtProxy()); if (fds_writ_ptr) - wr_t.copyOut(tc->getMemProxy()); + wr_t.copyOut(tc->getVirtProxy()); if (fds_excp_ptr) - ex_t.copyOut(tc->getMemProxy()); + ex_t.copyOut(tc->getVirtProxy()); if (time_val_ptr) - tp.copyOut(tc->getMemProxy()); + tp.copyOut(tc->getVirtProxy()); return retval; } @@ -2625,7 +2625,7 @@ readFunc(SyscallDesc *desc, int num, ThreadContext *tc) int bytes_read = read(sim_fd, buf_arg.bufferPtr(), nbytes); if (bytes_read > 0) - buf_arg.copyOut(tc->getMemProxy()); + buf_arg.copyOut(tc->getVirtProxy()); return (bytes_read == -1) ? -errno : bytes_read; } @@ -2646,7 +2646,7 @@ writeFunc(SyscallDesc *desc, int num, ThreadContext *tc) int sim_fd = hbfdp->getSimFD(); BufferArg buf_arg(buf_ptr, nbytes); - buf_arg.copyIn(tc->getMemProxy()); + buf_arg.copyIn(tc->getVirtProxy()); struct pollfd pfd; pfd.fd = sim_fd; @@ -2726,7 +2726,7 @@ success: const int EXITED = 0; BufferArg statusBuf(statPtr, sizeof(int)); *(int *)statusBuf.bufferPtr() = EXITED; - statusBuf.copyOut(tc->getMemProxy()); + statusBuf.copyOut(tc->getVirtProxy()); // Return the child PID. pid_t retval = iter->sender->pid(); @@ -2770,14 +2770,14 @@ acceptFunc(SyscallDesc *desc, int num, ThreadContext *tc) if (lenPtr) { lenBufPtr = new BufferArg(lenPtr, sizeof(socklen_t)); - lenBufPtr->copyIn(tc->getMemProxy()); + lenBufPtr->copyIn(tc->getVirtProxy()); memcpy(&addrLen, (socklen_t *)lenBufPtr->bufferPtr(), sizeof(socklen_t)); } if (addrPtr) { addrBufPtr = new BufferArg(addrPtr, sizeof(struct sockaddr)); - addrBufPtr->copyIn(tc->getMemProxy()); + addrBufPtr->copyIn(tc->getVirtProxy()); memcpy(&sa, (struct sockaddr *)addrBufPtr->bufferPtr(), sizeof(struct sockaddr)); } @@ -2789,13 +2789,13 @@ acceptFunc(SyscallDesc *desc, int num, ThreadContext *tc) if (addrPtr) { memcpy(addrBufPtr->bufferPtr(), &sa, sizeof(sa)); - addrBufPtr->copyOut(tc->getMemProxy()); + addrBufPtr->copyOut(tc->getVirtProxy()); delete(addrBufPtr); } if (lenPtr) { *(socklen_t *)lenBufPtr->bufferPtr() = addrLen; - lenBufPtr->copyOut(tc->getMemProxy()); + lenBufPtr->copyOut(tc->getVirtProxy()); delete(lenBufPtr); } -- 2.30.2