mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-01-20 13:24:11 +00:00
- Define _GNU_SOURCE for all selftests to fix a warning that was introduced by
a change to kselftest_harness.h late in the 6.9 cycle, and because forcing
every test to #define _GNU_SOURCE is painful.
- Provide a global psuedo-RNG instance for all tests, so that library code can
generate random, but determinstic numbers.
- Use the global pRNG to randomly force emulation of select writes from guest
code on x86, e.g. to help validate KVM's emulation of locked accesses.
- Rename kvm_util_base.h back to kvm_util.h, as the weird layer of indirection
was added purely to avoid manually #including ucall_common.h in a handful of
locations.
- Allocate and initialize x86's GDT, IDT, TSS, segments, and default exception
handlers at VM creation, instead of forcing tests to manually trigger the
related setup.
-----BEGIN PGP SIGNATURE-----
iQIzBAABCgAdFiEEKTobbabEP7vbhhN9OlYIJqCjN/0FAmY+qhoACgkQOlYIJqCj
N/2coRAAicA2485dlMjLbRazrb58dFiT8XheKKTHQwWRZPhxUMI8Rqo9Hp74t2tc
hU1+VXIupzTH4hXxTmqrTtsJsulhdgbQMzxeefK9U8WxS2jsHnC5Ltx9hmGWQG92
FeUhkDka1zc52bhMGOY43A5rNxCfQ0GYCWdHnILw2tqWQhqAvEuma7CwVYm85zTe
gl6Bfe1sokjnx1EIdwC4SyfDAh9DXIah02b7GvbTvkrNcLBpxnRp19mZlmSqSg9L
5VVPup2oSeKZAhXYP3dWgUGGJtT96tpz60QwkmVxcNIqvL41CsmW7wB9ODzYlihQ
uBmlchx9NIR9+ICL2DaZi5UfmrfeRW2sYVH9K0NewDswV8N36/pMabN+gWCKjZ7m
5K99nY6xtVmTkxdgJEQ1n4+oa2VTD68H52/hwvO5e6Kd1yab+SKoBf4LKxXu6gO7
P2hcM+FGwJlSU6gmI7B4+2RNFPurplVgC5MN7cJuEivKXhTXL8GzbOCxsRhCynIk
z+L+nnrSRiXAD45uYon1UIXLszANYfjizx7/fL5hC2mtpARP9S35zIDCCzEBNWWt
VI30/O0GAH/d6p1Rows/DzPmFJKbc+YVHoW9Ck8OP9axQHZuFoj6Qdy8BSwb8O+u
B0rJXUyVFh2jwZ2zkMPDnDS5FOhqmTXxZSNj+i5tX/BZus7Iews=
=vsRz
-----END PGP SIGNATURE-----
Merge tag 'kvm-x86-selftests_utils-6.10' of https://github.com/kvm-x86/linux into HEAD
KVM selftests treewide updates for 6.10:
- Define _GNU_SOURCE for all selftests to fix a warning that was introduced by
a change to kselftest_harness.h late in the 6.9 cycle, and because forcing
every test to #define _GNU_SOURCE is painful.
- Provide a global psuedo-RNG instance for all tests, so that library code can
generate random, but determinstic numbers.
- Use the global pRNG to randomly force emulation of select writes from guest
code on x86, e.g. to help validate KVM's emulation of locked accesses.
- Rename kvm_util_base.h back to kvm_util.h, as the weird layer of indirection
was added purely to avoid manually #including ucall_common.h in a handful of
locations.
- Allocate and initialize x86's GDT, IDT, TSS, segments, and default exception
handlers at VM creation, instead of forcing tests to manually trigger the
related setup.
53 lines
1.2 KiB
C
53 lines
1.2 KiB
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
/*
|
|
* KVM userfaultfd util
|
|
*
|
|
* Copyright (C) 2018, Red Hat, Inc.
|
|
* Copyright (C) 2019-2022 Google LLC
|
|
*/
|
|
#include <inttypes.h>
|
|
#include <time.h>
|
|
#include <pthread.h>
|
|
#include <linux/userfaultfd.h>
|
|
|
|
#include "test_util.h"
|
|
|
|
typedef int (*uffd_handler_t)(int uffd_mode, int uffd, struct uffd_msg *msg);
|
|
|
|
struct uffd_reader_args {
|
|
int uffd_mode;
|
|
int uffd;
|
|
useconds_t delay;
|
|
uffd_handler_t handler;
|
|
/* Holds the read end of the pipe for killing the reader. */
|
|
int pipe;
|
|
};
|
|
|
|
struct uffd_desc {
|
|
int uffd;
|
|
uint64_t num_readers;
|
|
/* Holds the write ends of the pipes for killing the readers. */
|
|
int *pipefds;
|
|
pthread_t *readers;
|
|
struct uffd_reader_args *reader_args;
|
|
};
|
|
|
|
struct uffd_desc *uffd_setup_demand_paging(int uffd_mode, useconds_t delay,
|
|
void *hva, uint64_t len,
|
|
uint64_t num_readers,
|
|
uffd_handler_t handler);
|
|
|
|
void uffd_stop_demand_paging(struct uffd_desc *uffd);
|
|
|
|
#ifdef PRINT_PER_PAGE_UPDATES
|
|
#define PER_PAGE_DEBUG(...) printf(__VA_ARGS__)
|
|
#else
|
|
#define PER_PAGE_DEBUG(...) _no_printf(__VA_ARGS__)
|
|
#endif
|
|
|
|
#ifdef PRINT_PER_VCPU_UPDATES
|
|
#define PER_VCPU_DEBUG(...) printf(__VA_ARGS__)
|
|
#else
|
|
#define PER_VCPU_DEBUG(...) _no_printf(__VA_ARGS__)
|
|
#endif
|