From 34a03ba4cc0a0911c8771fc314a9ac70b12606cd Mon Sep 17 00:00:00 2001 From: Gabe Black Date: Mon, 25 May 2020 17:55:59 -0700 Subject: [PATCH] misc: Replace scalar TypedBufferArg with VPtr. Change-Id: Ic8460ad133e3512c103b14820d90ee3df987d78d Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/31755 Maintainer: Gabe Black Tested-by: kokoro Reviewed-by: Ciro Santilli --- src/arch/arm/aapcs32.hh | 11 +++++------ src/arch/arm/aapcs64.hh | 10 ++++------ src/dev/hsa/hsa_driver.cc | 2 +- src/dev/hsa/hsa_packet_processor.cc | 9 +++------ src/kern/linux/events.hh | 1 + src/sim/syscall_emul.cc | 22 +++++++--------------- src/sim/syscall_emul.hh | 9 ++++----- 7 files changed, 25 insertions(+), 39 deletions(-) diff --git a/src/arch/arm/aapcs32.hh b/src/arch/arm/aapcs32.hh index e2e5d09f5..7f40bd39b 100644 --- a/src/arch/arm/aapcs32.hh +++ b/src/arch/arm/aapcs32.hh @@ -37,8 +37,9 @@ #include "arch/arm/utility.hh" #include "base/intmath.hh" #include "cpu/thread_context.hh" +#include "mem/port_proxy.hh" #include "sim/guest_abi.hh" -#include "sim/syscall_emul_buf.hh" +#include "sim/proxy_ptr.hh" class ThreadContext; @@ -113,8 +114,7 @@ struct Aapcs32ArgumentBase state.nsaa = roundUp(state.nsaa, align); // Extract the value from it. - TypedBufferArg val(state.nsaa); - val.copyIn(tc->getVirtProxy()); + ConstVPtr val(state.nsaa, tc); // Move the nsaa past this argument. state.nsaa += size; @@ -284,9 +284,8 @@ struct ResultsetIntReg(ArmISA::INTREG_R0, val); } else { - TypedBufferArg cp(state.retAddr); - cp = htog(composite, ArmISA::byteOrder(tc)); - cp.copyOut(tc->getVirtProxy()); + VPtr cp(state.retAddr, tc); + *cp = htog(composite, ArmISA::byteOrder(tc)); } } diff --git a/src/arch/arm/aapcs64.hh b/src/arch/arm/aapcs64.hh index 30597f59e..0c11215af 100644 --- a/src/arch/arm/aapcs64.hh +++ b/src/arch/arm/aapcs64.hh @@ -38,7 +38,7 @@ #include "base/intmath.hh" #include "cpu/thread_context.hh" #include "sim/guest_abi.hh" -#include "sim/syscall_emul_buf.hh" +#include "sim/proxy_ptr.hh" class ThreadContext; @@ -158,8 +158,7 @@ struct Aapcs64ArgumentBase state.nsaa = roundUp(state.nsaa, align); // Extract the value from it. - TypedBufferArg val(state.nsaa); - val.copyIn(tc->getVirtProxy()); + ConstVPtr val(state.nsaa, tc); // Move the nsaa past this argument. state.nsaa += size; @@ -350,8 +349,7 @@ struct Argument::get(tc, state); - TypedBufferArg composite(addr); - composite.copyIn(tc->getVirtProxy()); + ConstVPtr composite(addr, tc); return gtoh(*composite, ArmISA::byteOrder(tc)); } @@ -393,7 +391,7 @@ struct Result 16) { Addr addr = tc->readIntReg(ArmISA::INTREG_X8); - TypedBufferArg composite(addr); + VPtr composite(addr, tc); *composite = htog(c, ArmISA::byteOrder(tc)); return; } diff --git a/src/dev/hsa/hsa_driver.cc b/src/dev/hsa/hsa_driver.cc index 459043d93..a1215c405 100644 --- a/src/dev/hsa/hsa_driver.cc +++ b/src/dev/hsa/hsa_driver.cc @@ -42,7 +42,7 @@ #include "dev/hsa/kfd_ioctl.h" #include "params/HSADriver.hh" #include "sim/process.hh" -#include "sim/syscall_emul_buf.hh" +#include "sim/proxy_ptr.hh" HSADriver::HSADriver(HSADriverParams *p) : EmulatedDriver(p), device(p->device), queueId(0) diff --git a/src/dev/hsa/hsa_packet_processor.cc b/src/dev/hsa/hsa_packet_processor.cc index 68cdcf438..c31d9f02f 100644 --- a/src/dev/hsa/hsa_packet_processor.cc +++ b/src/dev/hsa/hsa_packet_processor.cc @@ -47,7 +47,7 @@ #include "mem/packet_access.hh" #include "mem/page_table.hh" #include "sim/process.hh" -#include "sim/syscall_emul_buf.hh" +#include "sim/proxy_ptr.hh" #include "sim/system.hh" #define HSAPP_EVENT_DESCRIPTION_GENERATOR(XEVENT) \ @@ -414,13 +414,10 @@ HSAPacketProcessor::processPkt(void* pkt, uint32_t rl_idx, Addr host_pkt_addr) * The reason for this is that the DMASequencer does * not support atomic operations. */ - auto tc = sys->threads[0]; - auto &virt_proxy = tc->getVirtProxy(); - TypedBufferArg prev_signal(signal_addr); - prev_signal.copyIn(virt_proxy); + VPtr prev_signal(signal_addr, sys->threads[0]); hsa_signal_value_t *new_signal = new hsa_signal_value_t; - *new_signal = (hsa_signal_value_t) *prev_signal - 1; + *new_signal = (hsa_signal_value_t)*prev_signal - 1; dmaWriteVirt(signal_addr, sizeof(hsa_signal_value_t), NULL, new_signal, 0); diff --git a/src/kern/linux/events.hh b/src/kern/linux/events.hh index c5a297b4e..2ca97a43b 100644 --- a/src/kern/linux/events.hh +++ b/src/kern/linux/events.hh @@ -48,6 +48,7 @@ #include "debug/DebugPrintf.hh" #include "kern/linux/printk.hh" #include "kern/system_events.hh" +#include "mem/se_translating_port_proxy.hh" #include "sim/guest_abi.hh" class ThreadContext; diff --git a/src/sim/syscall_emul.cc b/src/sim/syscall_emul.cc index 4a4160963..9fd08e893 100644 --- a/src/sim/syscall_emul.cc +++ b/src/sim/syscall_emul.cc @@ -47,6 +47,7 @@ #include "mem/page_table.hh" #include "sim/byteswap.hh" #include "sim/process.hh" +#include "sim/proxy_ptr.hh" #include "sim/sim_exit.hh" #include "sim/syscall_debug_macros.hh" #include "sim/syscall_desc.hh" @@ -1636,24 +1637,15 @@ setsockoptFunc(SyscallDesc *desc, ThreadContext *tc, SyscallReturn getcpuFunc(SyscallDesc *desc, ThreadContext *tc, - Addr cpu_ptr, Addr node_ptr, Addr tcache_ptr) + VPtr cpu, VPtr node, VPtr tcache) { - bool error = false; - // unsigned is the same size (4) on all Linux supported ISAs. - if (cpu_ptr != 0) { - TypedBufferArg result(cpu_ptr); - *result = htog(tc->contextId(), - tc->getSystemPtr()->getGuestByteOrder()); - error |= !result.copyOut(tc->getVirtProxy()); - } + if (cpu) + *cpu = htog(tc->contextId(), tc->getSystemPtr()->getGuestByteOrder()); // Set a fixed NUMA node 0. - if (node_ptr != 0) { - TypedBufferArg result(node_ptr); - *result = 0; - error |= !result.copyOut(tc->getVirtProxy()); - } + if (node) + *node = 0; - return error ? -EFAULT : 0; + return 0; } diff --git a/src/sim/syscall_emul.hh b/src/sim/syscall_emul.hh index f793dfd5e..b23e86010 100644 --- a/src/sim/syscall_emul.hh +++ b/src/sim/syscall_emul.hh @@ -356,7 +356,8 @@ SyscallReturn setsockoptFunc(SyscallDesc *desc, ThreadContext *tc, Addr valPtr, socklen_t len); SyscallReturn getcpuFunc(SyscallDesc *desc, ThreadContext *tc, - Addr cpu_ptr, Addr node_ptr, Addr tcache_ptr); + VPtr cpu, VPtr node, + VPtr tcache); // Target getsockname() handler. SyscallReturn getsocknameFunc(SyscallDesc *desc, ThreadContext *tc, @@ -1933,7 +1934,8 @@ gettimeofdayFunc(SyscallDesc *desc, ThreadContext *tc, /// Target utimes() handler. template SyscallReturn -utimesFunc(SyscallDesc *desc, ThreadContext *tc, Addr pathname, Addr times) +utimesFunc(SyscallDesc *desc, ThreadContext *tc, Addr pathname, + VPtr tp) { std::string path; auto process = tc->getProcessPtr(); @@ -1941,9 +1943,6 @@ utimesFunc(SyscallDesc *desc, ThreadContext *tc, Addr pathname, Addr times) if (!tc->getVirtProxy().tryReadString(path, pathname)) return -EFAULT; - TypedBufferArg tp(times); - tp.copyIn(tc->getVirtProxy()); - struct timeval hostTimeval[2]; for (int i = 0; i < 2; ++i) { hostTimeval[i].tv_sec = gtoh((*tp)[i].tv_sec, OS::byteOrder); -- 2.30.2