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

Change subject: sim,gpu: Make ioctl unconditionally take an address parameter.
......................................................................

sim,gpu: Make ioctl unconditionally take an address parameter.

The definition of ioctl is not actually variadic, it just doesn't
specify what the type of the pointer is that it takes as its third
argument. The man page says that that's because it predates void *
being valid C.

By passing this address around (even if it's unused), we avoid having
to extract system call arguments further down the call stack.

Change-Id: I62541237baafaec30bbe3df06b3284dd286a4051
---
M src/gpu-compute/cl_driver.cc
M src/gpu-compute/cl_driver.hh
M src/sim/emul_driver.hh
M src/sim/syscall_emul.hh
4 files changed, 7 insertions(+), 10 deletions(-)



diff --git a/src/gpu-compute/cl_driver.cc b/src/gpu-compute/cl_driver.cc
index c63856a..d8a4618 100644
--- a/src/gpu-compute/cl_driver.cc
+++ b/src/gpu-compute/cl_driver.cc
@@ -103,11 +103,10 @@
 }

 int
-ClDriver::ioctl(ThreadContext *tc, unsigned req)
+ClDriver::ioctl(ThreadContext *tc, unsigned req, Addr buf_addr)
 {
     int index = 2;
     auto process = tc->getProcessPtr();
-    Addr buf_addr = process->getSyscallArg(tc, index);

     switch (req) {
       case HSA_GET_SIZES:
diff --git a/src/gpu-compute/cl_driver.hh b/src/gpu-compute/cl_driver.hh
index 5dbb27d..bc7b749 100644
--- a/src/gpu-compute/cl_driver.hh
+++ b/src/gpu-compute/cl_driver.hh
@@ -54,7 +54,7 @@
     ClDriver(ClDriverParams *p);
     void handshake(GpuDispatcher *_dispatcher);
     int open(ThreadContext *tc, int mode, int flags);
-    int ioctl(ThreadContext *tc, unsigned req);
+    int ioctl(ThreadContext *tc, unsigned req, Addr buf);
     const char* codeOffToKernelName(uint64_t code_ptr);

   private:
diff --git a/src/sim/emul_driver.hh b/src/sim/emul_driver.hh
index fe13d90..9921d15 100644
--- a/src/sim/emul_driver.hh
+++ b/src/sim/emul_driver.hh
@@ -83,7 +83,7 @@
      * @return The return code for the ioctl, or the negation of the errno
      * (see the SyscallReturn class).
      */
-    virtual int ioctl(ThreadContext *tc, unsigned req) = 0;
+    virtual int ioctl(ThreadContext *tc, unsigned req, Addr buf) = 0;

     /**
      * Virtual method, invoked when the user program calls mmap() on
diff --git a/src/sim/syscall_emul.hh b/src/sim/syscall_emul.hh
index 27b4a43..ad5be4e 100644
--- a/src/sim/syscall_emul.hh
+++ b/src/sim/syscall_emul.hh
@@ -717,7 +717,7 @@
 template <class OS>
 SyscallReturn
 ioctlFunc(SyscallDesc *desc, int callnum, ThreadContext *tc,
-        int tgt_fd, unsigned req, GuestABI::VarArgs<Addr> varargs)
+        int tgt_fd, unsigned req, Addr addr)
 {
     auto p = tc->getProcessPtr();

@@ -730,7 +730,7 @@
     if (dfdp) {
         EmulatedDriver *emul_driver = dfdp->getDriver();
         if (emul_driver)
-            return emul_driver->ioctl(tc, req);
+            return emul_driver->ioctl(tc, req, addr);
     }

auto sfdp = std::dynamic_pointer_cast<SocketFDEntry>((*p->fds)[tgt_fd]);
@@ -739,8 +739,7 @@

         switch (req) {
           case SIOCGIFCONF: {
-            Addr conf_addr = varargs.get<Addr>();
-            BufferArg conf_arg(conf_addr, sizeof(ifconf));
+            BufferArg conf_arg(addr, sizeof(ifconf));
             conf_arg.copyIn(tc->getVirtProxy());

             ifconf *conf = (ifconf*)conf_arg.bufferPtr();
@@ -769,8 +768,7 @@
           case SIOCGIFHWADDR:
 #endif
           case SIOCGIFMTU: {
-            Addr req_addr = varargs.get<Addr>();
-            BufferArg req_arg(req_addr, sizeof(ifreq));
+            BufferArg req_arg(addr, sizeof(ifreq));
             req_arg.copyIn(tc->getVirtProxy());

             status = ioctl(sfdp->getSimFD(), req, req_arg.bufferPtr());

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

Gerrit-Project: public/gem5
Gerrit-Branch: master
Gerrit-Change-Id: I62541237baafaec30bbe3df06b3284dd286a4051
Gerrit-Change-Number: 23456
Gerrit-PatchSet: 1
Gerrit-Owner: Gabe Black <gabebl...@google.com>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list
gem5-dev@gem5.org
http://m5sim.org/mailman/listinfo/gem5-dev

Reply via email to