qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 2/2] linux-user: call set/getscheduler set/getparam directly


From: Laurent Vivier
Subject: Re: [PATCH 2/2] linux-user: call set/getscheduler set/getparam directly
Date: Sun, 19 Dec 2021 18:19:24 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.3.0

Le 11/12/2021 à 03:27, Tonis Tiigi a écrit :
There seems to be difference in syscall and libc definition of these
methods and therefore musl does not implement them (1e21e78bf7). Call
syscall directly to ensure the behavior of the libc of user application,
not the libc that was used to build QEMU.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
---
  linux-user/syscall.c | 16 ++++++++++++----
  1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 670b61b2ef..263d7fac5e 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -343,6 +343,14 @@ _syscall3(int, sys_sched_setaffinity, pid_t, pid, unsigned 
int, len,
  _syscall4(int, sys_sched_getattr, pid_t, pid, struct sched_attr *, attr, 
unsigned int, size, unsigned int, flags);
  #define __NR_sys_sched_setattr __NR_sched_setattr
  _syscall3(int, sys_sched_setattr, pid_t, pid, struct sched_attr *, attr, 
unsigned int, flags);
+#define __NR_sys_sched_getscheduler __NR_sched_getscheduler
+_syscall1(int, sys_sched_getscheduler, pid_t, pid);
+#define __NR_sys_sched_setscheduler __NR_sched_setscheduler
+_syscall3(int, sys_sched_setscheduler, pid_t, pid, int, policy, const struct 
sched_param *, param);
+#define __NR_sys_sched_getparam __NR_sched_getparam
+_syscall2(int, sys_sched_getparam, pid_t, pid, struct sched_param *, param);
+#define __NR_sys_sched_setparam __NR_sched_setparam
+_syscall2(int, sys_sched_setparam, pid_t, pid, const struct sched_param *, 
param);
  #define __NR_sys_getcpu __NR_getcpu
  _syscall3(int, sys_getcpu, unsigned *, cpu, unsigned *, node, void *, tcache);
  _syscall4(int, reboot, int, magic1, int, magic2, unsigned int, cmd,
@@ -10563,7 +10571,7 @@ static abi_long do_syscall1(void *cpu_env, int num, 
abi_long arg1,
                  return -TARGET_EFAULT;
              schp.sched_priority = tswap32(target_schp->sched_priority);
              unlock_user_struct(target_schp, arg2, 0);
-            return get_errno(sched_setparam(arg1, &schp));
+            return get_errno(sys_sched_setparam(arg1, &schp));
          }
      case TARGET_NR_sched_getparam:
          {
@@ -10573,7 +10581,7 @@ static abi_long do_syscall1(void *cpu_env, int num, 
abi_long arg1,
              if (arg2 == 0) {
                  return -TARGET_EINVAL;
              }
-            ret = get_errno(sched_getparam(arg1, &schp));
+            ret = get_errno(sys_sched_getparam(arg1, &schp));
              if (!is_error(ret)) {
                  if (!lock_user_struct(VERIFY_WRITE, target_schp, arg2, 0))
                      return -TARGET_EFAULT;
@@ -10593,10 +10601,10 @@ static abi_long do_syscall1(void *cpu_env, int num, 
abi_long arg1,
                  return -TARGET_EFAULT;
              schp.sched_priority = tswap32(target_schp->sched_priority);
              unlock_user_struct(target_schp, arg3, 0);
-            return get_errno(sched_setscheduler(arg1, arg2, &schp));
+            return get_errno(sys_sched_setscheduler(arg1, arg2, &schp));
          }
      case TARGET_NR_sched_getscheduler:
-        return get_errno(sched_getscheduler(arg1));
+        return get_errno(sys_sched_getscheduler(arg1));
      case TARGET_NR_sched_getattr:
          {
              struct target_sched_attr *target_scha;


It looks good, but you need to introduce also target_sched_param using abi_int.

Thanks,
Laurent



reply via email to

[Prev in Thread] Current Thread [Next in Thread]