KVM: selftests: Add KVM syscall wrappers for pthread_{g,s}etaffinity_np()

Add and use KVM wrappers for pthread_{g,s}etaffinity_np() so that selftests
don't need to manually assert that the syscalls succeeded, and so that they
don't need to manually pass in sizeof(cpu_set_t) for the size.

Link: https://patch.msgid.link/20260731195612.2697986-12-seanjc@google.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
This commit is contained in:
Sean Christopherson 2026-07-31 12:56:11 -07:00
parent 1039496ae7
commit 83b5065f3e

View File

@ -98,6 +98,22 @@ __KVM_SYSCALL_DEFINE(madvise, 3, void *, addr, size_t, length, int, advice);
__KVM_SYSCALL_DEFINE(sched_getaffinity, 3, pid_t, pid, size_t, cpusetsize, cpu_set_t *, mask);
__KVM_SYSCALL_DEFINE(sched_setaffinity, 3, pid_t, pid, size_t, cpusetsize, cpu_set_t *, mask);
__KVM_SYSCALL_DEFINE(pthread_getaffinity_np, 3, pthread_t, thread,
size_t, cpusetsize, cpu_set_t *, cpuset);
__KVM_SYSCALL_DEFINE(pthread_setaffinity_np, 3, pthread_t, thread,
size_t, cpusetsize, const cpu_set_t *, cpuset);
static inline void kvm_pthread_getaffinity(pthread_t thread, cpu_set_t *cpuset)
{
kvm_pthread_getaffinity_np(thread, sizeof(cpu_set_t), cpuset);
}
static inline void kvm_pthread_setaffinity(pthread_t thread,
const cpu_set_t *cpuset)
{
kvm_pthread_setaffinity_np(thread, sizeof(cpu_set_t), cpuset);
}
typedef void *(*pthread_fn_t)(void *);
__KVM_SYSCALL_DEFINE(pthread_create, 4, pthread_t *, thread,
const pthread_attr_t *, attr, pthread_fn_t, fn, void *, arg);