qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: liushuyu@aosc.io
To: qemu-devel@nongnu.org
Cc: liushuyu011@gmail.com
Subject: [PATCH] linux-user/syscall.c: add translation logic for epoll_pwait2 syscall
Date: Wed, 23 Apr 2025 15:22:05 +0800	[thread overview]
Message-ID: <b4d01956e77d801af6e3d229332a2265@aosc.io> (raw)

Signed-off-by: Zixing Liu <liushuyu@aosc.io>
---
  linux-user/syscall.c | 36 ++++++++++++++++++++++++++++++++----
  1 file changed, 32 insertions(+), 4 deletions(-)

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 8bfe491..6906e7b 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -711,6 +711,11 @@ safe_syscall5(int, ppoll, struct pollfd *, ufds, 
unsigned int, nfds,
  safe_syscall6(int, epoll_pwait, int, epfd, struct epoll_event *, 
events,
                int, maxevents, int, timeout, const sigset_t *, sigmask,
                size_t, sigsetsize)
+#if defined(__NR_epoll_pwait2)
+safe_syscall6(int, epoll_pwait2, int, epfd, struct epoll_event *, 
events,
+              int, maxevents, struct timespec *, timeout, const 
sigset_t *, sigmask,
+              size_t, sigsetsize)
+#endif
  #if defined(__NR_futex)
  safe_syscall6(int,futex,int *,uaddr,int,op,int,val, \
                const struct timespec *,timeout,int *,uaddr2,int,val3)
@@ -13363,19 +13368,22 @@ static abi_long do_syscall1(CPUArchState 
*cpu_env, int num, abi_long arg1,
      }
  #endif

-#if defined(TARGET_NR_epoll_wait) || defined(TARGET_NR_epoll_pwait)
+#if defined(TARGET_NR_epoll_wait) || defined(TARGET_NR_epoll_pwait) || 
defined(TARGET_NR_epoll_pwait2)
  #if defined(TARGET_NR_epoll_wait)
      case TARGET_NR_epoll_wait:
  #endif
  #if defined(TARGET_NR_epoll_pwait)
      case TARGET_NR_epoll_pwait:
+#endif
+#if defined(TARGET_NR_epoll_pwait2)
+    case TARGET_NR_epoll_pwait2:
  #endif
      {
          struct target_epoll_event *target_ep;
          struct epoll_event *ep;
          int epfd = arg1;
          int maxevents = arg3;
-        int timeout = arg4;
+        abi_long timeout = arg4;

          if (maxevents <= 0 || maxevents > TARGET_EP_MAX_EVENTS) {
              return -TARGET_EINVAL;
@@ -13396,6 +13404,9 @@ static abi_long do_syscall1(CPUArchState 
*cpu_env, int num, abi_long arg1,
          switch (num) {
  #if defined(TARGET_NR_epoll_pwait)
          case TARGET_NR_epoll_pwait:
+#if defined(TARGET_NR_epoll_pwait2)
+        case TARGET_NR_epoll_pwait2:
+#endif
          {
              sigset_t *set = NULL;

@@ -13406,8 +13417,25 @@ static abi_long do_syscall1(CPUArchState 
*cpu_env, int num, abi_long arg1,
                  }
              }

-            ret = get_errno(safe_epoll_pwait(epfd, ep, maxevents, 
timeout,
-                                             set, SIGSET_T_SIZE));
+            if (num == TARGET_NR_epoll_pwait) {
+                ret = get_errno(safe_epoll_pwait(epfd, ep, maxevents, 
(int)timeout,
+                                                 set, SIGSET_T_SIZE));
+            } else {
+#if defined(TARGET_NR_epoll_pwait2)
+                struct timespec hspec;
+                struct timespec *ts_arg = NULL;
+                if (timeout) {
+                    if (target_to_host_timespec(&hspec, 
(abi_ulong)timeout)) {
+                        return -TARGET_EFAULT;
+                    }
+                    ts_arg = &hspec;
+                }
+                ret = get_errno(safe_epoll_pwait2(epfd, ep, maxevents, 
ts_arg,
+                                              set, SIGSET_T_SIZE));
+#else
+                return -TARGET_ENOSYS;
+#endif
+            }

              if (set) {
                  finish_sigsuspend_mask(ret);
-- 
2.49.0



             reply	other threads:[~2025-04-23 13:07 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-23  7:22 liushuyu [this message]
  -- strict thread matches above, loose matches on Subject: below --
2025-04-23  7:06 [PATCH] linux-user/syscall.c: add translation logic for epoll_pwait2 syscall Zixing Liu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b4d01956e77d801af6e3d229332a2265@aosc.io \
    --to=liushuyu@aosc.io \
    --cc=liushuyu011@gmail.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).