qemu-devel
[Top][All Lists]
Advanced

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

[PATCH v3 0/2] linux-user: fixes for sched_ syscalls


From: Tonis Tiigi
Subject: [PATCH v3 0/2] linux-user: fixes for sched_ syscalls
Date: Wed, 22 Dec 2021 22:47:26 -0800

This patchset improves support for sched_* syscalls under user emulation. The 
first commit adds support for sched_g/setattr that was previously not 
implemented. There is no equivalent for these syscalls in libc, so I needed to 
redefine the struct from kernel. It can't be included directly because of 
conflict with libc sched headers.

The second commit fixes sched_g/setscheduler and sched_g/setparam, when QEMU is 
built with musl. Musl does not implement these due to conflict between what 
these functions should do in syscalls and libc 
https://git.musl-libc.org/cgit/musl/commit/?id=1e21e78bf7a5c24c217446d8760be7b7188711c2
 . I've changed it to call syscall directly what should always be the expected 
behavior for the user.

Via https://github.com/tonistiigi/binfmt/pull/70 with additional tests.

Changes v3->v2:
- Fix wrong property name for sched_flags
- Validate size parameter and handle E2BIG errors same way as kernel does. There
is one case where it can't be done completely correctly but clients should still
be able to handle it: when client sends a bigger non-zero structure than current
kernel definition we will send E2BIG with the struct size known to qemu. If now
the client sends structure with this size it may still get another E2BIG error
from the kernel if kernel is old and doesn't implement util_min/util_max. I 
don't
think this can be handled without making additional syscalls to kernel.

Changes v1->v2:
- Locking guest addresses for sched_attr is now based on size inputs, not local 
struct size. Also did the same for setter where I now read only the size field 
of the struct first.
- Use offsetof() when checking if optional fields are supported.
- `target_sched_attr` now uses aligned types as requested. I didn't quite 
understand why this is needed as I don't see same in kernel headers, but as 
this type uses only constant width fields and is already aligned by default it 
can't break anything.
- Fixed formatting.
- Defined own `target_sched_param` struct as requested.


Tonis Tiigi (2):
  linux-user: add sched_getattr support
  linux-user: call set/getscheduler set/getparam directly

 linux-user/syscall.c      | 134 ++++++++++++++++++++++++++++++++++----
 linux-user/syscall_defs.h |  18 +++++
 2 files changed, 139 insertions(+), 13 deletions(-)

-- 
2.32.0 (Apple Git-132)




reply via email to

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