mirror of
https://github.com/raspberrypi/linux.git
synced 2025-12-21 09:12:05 +00:00
Pull kvm fixes from Paolo Bonzini:
"A bit late... I got sidetracked by back-from-vacation routines and
conferences. But most of these patches are already a few weeks old and
things look more calm on the mailing list than what this pull request
would suggest.
x86:
- missing TLB flush
- nested virtualization fixes for SMM (secure boot on nested
hypervisor) and other nested SVM fixes
- syscall fuzzing fixes
- live migration fix for AMD SEV
- mirror VMs now work for SEV-ES too
- fixes for reset
- possible out-of-bounds access in IOAPIC emulation
- fix enlightened VMCS on Windows 2022
ARM:
- Add missing FORCE target when building the EL2 object
- Fix a PMU probe regression on some platforms
Generic:
- KCSAN fixes
selftests:
- random fixes, mostly for clang compilation"
* tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm: (43 commits)
selftests: KVM: Explicitly use movq to read xmm registers
selftests: KVM: Call ucall_init when setting up in rseq_test
KVM: Remove tlbs_dirty
KVM: X86: Synchronize the shadow pagetable before link it
KVM: X86: Fix missed remote tlb flush in rmap_write_protect()
KVM: x86: nSVM: don't copy virt_ext from vmcb12
KVM: x86: nSVM: test eax for 4K alignment for GP errata workaround
KVM: x86: selftests: test simultaneous uses of V_IRQ from L1 and L0
KVM: x86: nSVM: restore int_vector in svm_clear_vintr
kvm: x86: Add AMD PMU MSRs to msrs_to_save_all[]
KVM: x86: nVMX: re-evaluate emulation_required on nested VM exit
KVM: x86: nVMX: don't fail nested VM entry on invalid guest state if !from_vmentry
KVM: x86: VMX: synthesize invalid VM exit when emulating invalid guest state
KVM: x86: nSVM: refactor svm_leave_smm and smm_enter_smm
KVM: x86: SVM: call KVM_REQ_GET_NESTED_STATE_PAGES on exit from SMM mode
KVM: x86: reset pdptrs_from_userspace when exiting smm
KVM: x86: nSVM: restore the L1 host state prior to resuming nested guest on SMM exit
KVM: nVMX: Filter out all unsupported controls when eVMCS was activated
KVM: KVM: Use cpumask_available() to check for NULL cpumask when kicking vCPUs
KVM: Clean up benign vcpu->cpu data races when kicking vCPUs
...
121 lines
3.3 KiB
C
121 lines
3.3 KiB
C
/* SPDX-License-Identifier: GPL-2.0-only */
|
|
/*
|
|
* tools/testing/selftests/kvm/include/test_util.h
|
|
*
|
|
* Copyright (C) 2018, Google LLC.
|
|
*/
|
|
|
|
#ifndef SELFTEST_KVM_TEST_UTIL_H
|
|
#define SELFTEST_KVM_TEST_UTIL_H
|
|
|
|
#include <stdlib.h>
|
|
#include <stdarg.h>
|
|
#include <stdbool.h>
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
#include <inttypes.h>
|
|
#include <errno.h>
|
|
#include <unistd.h>
|
|
#include <fcntl.h>
|
|
#include <sys/mman.h>
|
|
#include "kselftest.h"
|
|
|
|
static inline int _no_printf(const char *format, ...) { return 0; }
|
|
|
|
#ifdef DEBUG
|
|
#define pr_debug(...) printf(__VA_ARGS__)
|
|
#else
|
|
#define pr_debug(...) _no_printf(__VA_ARGS__)
|
|
#endif
|
|
#ifndef QUIET
|
|
#define pr_info(...) printf(__VA_ARGS__)
|
|
#else
|
|
#define pr_info(...) _no_printf(__VA_ARGS__)
|
|
#endif
|
|
|
|
void print_skip(const char *fmt, ...) __attribute__((format(printf, 1, 2)));
|
|
|
|
ssize_t test_write(int fd, const void *buf, size_t count);
|
|
ssize_t test_read(int fd, void *buf, size_t count);
|
|
int test_seq_read(const char *path, char **bufp, size_t *sizep);
|
|
|
|
void test_assert(bool exp, const char *exp_str,
|
|
const char *file, unsigned int line, const char *fmt, ...)
|
|
__attribute__((format(printf, 5, 6)));
|
|
|
|
#define TEST_ASSERT(e, fmt, ...) \
|
|
test_assert((e), #e, __FILE__, __LINE__, fmt, ##__VA_ARGS__)
|
|
|
|
#define ASSERT_EQ(a, b) do { \
|
|
typeof(a) __a = (a); \
|
|
typeof(b) __b = (b); \
|
|
TEST_ASSERT(__a == __b, \
|
|
"ASSERT_EQ(%s, %s) failed.\n" \
|
|
"\t%s is %#lx\n" \
|
|
"\t%s is %#lx", \
|
|
#a, #b, #a, (unsigned long) __a, #b, (unsigned long) __b); \
|
|
} while (0)
|
|
|
|
#define TEST_FAIL(fmt, ...) \
|
|
TEST_ASSERT(false, fmt, ##__VA_ARGS__)
|
|
|
|
size_t parse_size(const char *size);
|
|
|
|
int64_t timespec_to_ns(struct timespec ts);
|
|
struct timespec timespec_add_ns(struct timespec ts, int64_t ns);
|
|
struct timespec timespec_add(struct timespec ts1, struct timespec ts2);
|
|
struct timespec timespec_sub(struct timespec ts1, struct timespec ts2);
|
|
struct timespec timespec_elapsed(struct timespec start);
|
|
struct timespec timespec_div(struct timespec ts, int divisor);
|
|
|
|
enum vm_mem_backing_src_type {
|
|
VM_MEM_SRC_ANONYMOUS,
|
|
VM_MEM_SRC_ANONYMOUS_THP,
|
|
VM_MEM_SRC_ANONYMOUS_HUGETLB,
|
|
VM_MEM_SRC_ANONYMOUS_HUGETLB_16KB,
|
|
VM_MEM_SRC_ANONYMOUS_HUGETLB_64KB,
|
|
VM_MEM_SRC_ANONYMOUS_HUGETLB_512KB,
|
|
VM_MEM_SRC_ANONYMOUS_HUGETLB_1MB,
|
|
VM_MEM_SRC_ANONYMOUS_HUGETLB_2MB,
|
|
VM_MEM_SRC_ANONYMOUS_HUGETLB_8MB,
|
|
VM_MEM_SRC_ANONYMOUS_HUGETLB_16MB,
|
|
VM_MEM_SRC_ANONYMOUS_HUGETLB_32MB,
|
|
VM_MEM_SRC_ANONYMOUS_HUGETLB_256MB,
|
|
VM_MEM_SRC_ANONYMOUS_HUGETLB_512MB,
|
|
VM_MEM_SRC_ANONYMOUS_HUGETLB_1GB,
|
|
VM_MEM_SRC_ANONYMOUS_HUGETLB_2GB,
|
|
VM_MEM_SRC_ANONYMOUS_HUGETLB_16GB,
|
|
VM_MEM_SRC_SHMEM,
|
|
VM_MEM_SRC_SHARED_HUGETLB,
|
|
NUM_SRC_TYPES,
|
|
};
|
|
|
|
#define DEFAULT_VM_MEM_SRC VM_MEM_SRC_ANONYMOUS
|
|
|
|
struct vm_mem_backing_src_alias {
|
|
const char *name;
|
|
uint32_t flag;
|
|
};
|
|
|
|
#define MIN_RUN_DELAY_NS 200000UL
|
|
|
|
bool thp_configured(void);
|
|
size_t get_trans_hugepagesz(void);
|
|
size_t get_def_hugetlb_pagesz(void);
|
|
const struct vm_mem_backing_src_alias *vm_mem_backing_src_alias(uint32_t i);
|
|
size_t get_backing_src_pagesz(uint32_t i);
|
|
void backing_src_help(const char *flag);
|
|
enum vm_mem_backing_src_type parse_backing_src_type(const char *type_name);
|
|
long get_run_delay(void);
|
|
|
|
/*
|
|
* Whether or not the given source type is shared memory (as opposed to
|
|
* anonymous).
|
|
*/
|
|
static inline bool backing_src_is_shared(enum vm_mem_backing_src_type t)
|
|
{
|
|
return vm_mem_backing_src_alias(t)->flag & MAP_SHARED;
|
|
}
|
|
|
|
#endif /* SELFTEST_KVM_TEST_UTIL_H */
|