From: Tonis Tiigi <tonistiigi@gmail.com>
To: qemu-devel@nongnu.org
Cc: Tonis Tiigi <tonistiigi@gmail.com>, laurent@vivier.eu
Subject: [PATCH v4 0/2] linux-user: fixes for sched_ syscalls
Date: Tue, 4 Jan 2022 20:18:17 -0800 [thread overview]
Message-ID: <20220105041819.24160-1-tonistiigi@gmail.com> (raw)
This patchset improves support for sched_* syscalls under user emulation.
The first commit adds support for sched_g/setattr that was previously not
implemented. These syscalls are not exposed by glibc. The struct type needs
to be redefined as it can't be included directly before
https://lkml.org/lkml/2020/5/28/810 .
sched_attr type can grow in future kernel versions. When client sends
values that QEMU does not understand it will return E2BIG with same
semantics as old kernel would so client can retry with smaller inputs.
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
https://github.com/tonistiigi/binfmt/pull/73 with additional tests.
Changes v4->v3:
- host `sched_param` type is used for local syscalls
- Added check_zeroed_user() helper. This function takes kernel and userspace size
and checks if the extra padding is empty with same rules as kernel does. I also
tried with only one size parameter but doing all the `size-sizeof()` calculations
on caller side made the function quite useless.
- Defined local host version for `sched_param` so target and host types are defined
separately.
- Moved size type declaration to the beginning of the function.
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 | 157 +++++++++++++++++++++++++++++++++++---
linux-user/syscall_defs.h | 18 +++++
2 files changed, 165 insertions(+), 10 deletions(-)
--
2.32.0 (Apple Git-132)
next reply other threads:[~2022-01-05 4:22 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-05 4:18 Tonis Tiigi [this message]
2022-01-05 4:18 ` [PATCH v4 1/2] linux-user: add sched_getattr support Tonis Tiigi
2022-01-05 10:14 ` Laurent Vivier
2022-01-05 10:16 ` Laurent Vivier
2022-01-05 4:18 ` [PATCH v4 2/2] linux-user: call set/getscheduler set/getparam directly Tonis Tiigi
2022-01-05 10:14 ` Laurent Vivier
2022-01-05 10:16 ` Laurent Vivier
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=20220105041819.24160-1-tonistiigi@gmail.com \
--to=tonistiigi@gmail.com \
--cc=laurent@vivier.eu \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.