mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2026-05-09 21:42:09 +02:00
26f8453288
Use u64 instead of uint64_t to make the KVM selftests code more concise and more similar to the kernel (since selftests are primarily developed by kernel developers). This commit was generated with the following command: git ls-files tools/testing/selftests/kvm | xargs sed -i 's/uint64_t/u64/g' Then by manually adjusting whitespace to make checkpatch.pl happy. Include <linux/types.h> in include/kvm_util_types.h, iinclude/test_util.h, and include/x86/pmu.h to pick up the tools-defined u64. Arguably, all headers (especially kvm_util_types.h) should have already been including stdint.h to get uint64_t from the libc headers, but the missing dependency only rears its head once KVM uses u64 instead of uint64_t. No functional change intended. Signed-off-by: David Matlack <dmatlack@google.com> [sean: rename pread_uint64() => pread_u64, expand on types.h include] Link: https://patch.msgid.link/20260420212004.3938325-5-seanjc@google.com Signed-off-by: Sean Christopherson <seanjc@google.com>
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;
|
|
u64 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, u64 len,
|
|
u64 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
|