2020-10-27 16:37:29 -07:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
|
|
|
/*
|
2022-10-12 09:57:27 -07:00
|
|
|
* tools/testing/selftests/kvm/include/memstress.h
|
2020-10-27 16:37:29 -07:00
|
|
|
*
|
|
|
|
* Copyright (C) 2020, Google LLC.
|
|
|
|
*/
|
|
|
|
|
2022-10-12 09:57:27 -07:00
|
|
|
#ifndef SELFTEST_KVM_MEMSTRESS_H
|
|
|
|
#define SELFTEST_KVM_MEMSTRESS_H
|
2020-10-27 16:37:29 -07:00
|
|
|
|
2021-11-11 00:12:55 +00:00
|
|
|
#include <pthread.h>
|
|
|
|
|
2020-10-27 16:37:29 -07:00
|
|
|
#include "kvm_util.h"
|
|
|
|
|
|
|
|
/* Default guest test virtual memory offset */
|
|
|
|
#define DEFAULT_GUEST_TEST_MEM 0xc0000000
|
|
|
|
|
2020-11-04 22:23:52 +01:00
|
|
|
#define DEFAULT_PER_VCPU_MEM_SIZE (1 << 30) /* 1G */
|
|
|
|
|
2022-10-12 09:57:29 -07:00
|
|
|
#define MEMSTRESS_MEM_SLOT_INDEX 1
|
2020-11-04 22:23:53 +01:00
|
|
|
|
2022-10-12 09:57:29 -07:00
|
|
|
struct memstress_vcpu_args {
|
2021-11-11 00:03:04 +00:00
|
|
|
uint64_t gpa;
|
2020-10-27 16:37:29 -07:00
|
|
|
uint64_t gva;
|
|
|
|
uint64_t pages;
|
|
|
|
|
|
|
|
/* Only used by the host userspace part of the vCPU thread */
|
2022-02-16 13:38:12 -08:00
|
|
|
struct kvm_vcpu *vcpu;
|
|
|
|
int vcpu_idx;
|
2020-10-27 16:37:29 -07:00
|
|
|
};
|
|
|
|
|
2022-10-12 09:57:29 -07:00
|
|
|
struct memstress_args {
|
2020-10-27 16:37:29 -07:00
|
|
|
struct kvm_vm *vm;
|
2022-05-20 23:32:48 +00:00
|
|
|
/* The starting address and size of the guest test region. */
|
2021-11-11 00:03:06 +00:00
|
|
|
uint64_t gpa;
|
2022-05-20 23:32:48 +00:00
|
|
|
uint64_t size;
|
2020-10-27 16:37:29 -07:00
|
|
|
uint64_t guest_page_size;
|
2022-11-07 18:22:06 +00:00
|
|
|
uint32_t random_seed;
|
2022-11-07 18:22:07 +00:00
|
|
|
uint32_t write_percent;
|
2020-10-27 16:37:29 -07:00
|
|
|
|
2022-05-20 23:32:48 +00:00
|
|
|
/* Run vCPUs in L2 instead of L1, if the architecture supports it. */
|
|
|
|
bool nested;
|
2022-11-07 18:22:08 +00:00
|
|
|
/* Randomize which pages are accessed by the guest. */
|
|
|
|
bool random_access;
|
2022-11-03 12:17:19 -07:00
|
|
|
/* True if all vCPUs are pinned to pCPUs */
|
|
|
|
bool pin_vcpus;
|
|
|
|
/* The vCPU=>pCPU pinning map. Only valid if pin_vcpus is true. */
|
|
|
|
uint32_t vcpu_to_pcpu[KVM_MAX_VCPUS];
|
2022-05-20 23:32:48 +00:00
|
|
|
|
KVM/arm64 updates for 6.2
- Enable the per-vcpu dirty-ring tracking mechanism, together with an
option to keep the good old dirty log around for pages that are
dirtied by something other than a vcpu.
- Switch to the relaxed parallel fault handling, using RCU to delay
page table reclaim and giving better performance under load.
- Relax the MTE ABI, allowing a VMM to use the MAP_SHARED mapping
option, which multi-process VMMs such as crosvm rely on.
- Merge the pKVM shadow vcpu state tracking that allows the hypervisor
to have its own view of a vcpu, keeping that state private.
- Add support for the PMUv3p5 architecture revision, bringing support
for 64bit counters on systems that support it, and fix the
no-quite-compliant CHAIN-ed counter support for the machines that
actually exist out there.
- Fix a handful of minor issues around 52bit VA/PA support (64kB pages
only) as a prefix of the oncoming support for 4kB and 16kB pages.
- Add/Enable/Fix a bunch of selftests covering memslots, breakpoints,
stage-2 faults and access tracking. You name it, we got it, we
probably broke it.
- Pick a small set of documentation and spelling fixes, because no
good merge window would be complete without those.
As a side effect, this tag also drags:
- The 'kvmarm-fixes-6.1-3' tag as a dependency to the dirty-ring
series
- A shared branch with the arm64 tree that repaints all the system
registers to match the ARM ARM's naming, and resulting in
interesting conflicts
-----BEGIN PGP SIGNATURE-----
iQJDBAABCgAtFiEEn9UcU+C1Yxj9lZw9I9DQutE9ekMFAmOODb0PHG1hekBrZXJu
ZWwub3JnAAoJECPQ0LrRPXpDztsQAInRnsgLl57/SpqhZzExNCllN6AT/bdeB3uz
rnw3ScJOV174uNKp8lnPWoTvu2YUGiVtBp6tFHhDI8le7zHX438ZT8KE5mcs8p5i
KfFKnb8SHV2DDpqkcy24c0Xl/6vsg1qkKrdfJb49yl5ZakRITDpynW/7tn6dXsxX
wASeGFdCYeW4g2xMQzsCbtx6LgeQ8uomBmzRfPrOtZHYYxAn6+4Mj4595EC1sWxM
AQnbp8tW3Vw46saEZAQvUEOGOW9q0Nls7G21YqQ52IA+ZVDK1LmAF2b1XY3edjkk
pX8EsXOURfqdasBxfSfF3SgnUazoz9GHpSzp1cTVTktrPp40rrT7Ldtml0ktq69d
1malPj47KVMDsIq0kNJGnMxciXFgAHw+VaCQX+k4zhIatNwviMbSop2fEoxj22jc
4YGgGOxaGrnvmAJhreCIbr4CkZk5CJ8Zvmtfg+QM6npIp8BY8896nvORx/d4i6tT
H4caadd8AAR56ANUyd3+KqF3x0WrkaU0PLHJLy1tKwOXJUUTjcpvIfahBAAeUlSR
qEFrtb+EEMPgAwLfNOICcNkPZR/yyuYvM+FiUQNVy5cNiwFkpztpIctfOFaHySGF
K07O2/a1F6xKL0OKRUg7hGKknF9ecmux4vHhiUMuIk9VOgNTWobHozBDorLKXMzC
aWa6oGVC
=iIPT
-----END PGP SIGNATURE-----
Merge tag 'kvmarm-6.2' of https://git.kernel.org/pub/scm/linux/kernel/git/kvmarm/kvmarm into HEAD
KVM/arm64 updates for 6.2
- Enable the per-vcpu dirty-ring tracking mechanism, together with an
option to keep the good old dirty log around for pages that are
dirtied by something other than a vcpu.
- Switch to the relaxed parallel fault handling, using RCU to delay
page table reclaim and giving better performance under load.
- Relax the MTE ABI, allowing a VMM to use the MAP_SHARED mapping
option, which multi-process VMMs such as crosvm rely on.
- Merge the pKVM shadow vcpu state tracking that allows the hypervisor
to have its own view of a vcpu, keeping that state private.
- Add support for the PMUv3p5 architecture revision, bringing support
for 64bit counters on systems that support it, and fix the
no-quite-compliant CHAIN-ed counter support for the machines that
actually exist out there.
- Fix a handful of minor issues around 52bit VA/PA support (64kB pages
only) as a prefix of the oncoming support for 4kB and 16kB pages.
- Add/Enable/Fix a bunch of selftests covering memslots, breakpoints,
stage-2 faults and access tracking. You name it, we got it, we
probably broke it.
- Pick a small set of documentation and spelling fixes, because no
good merge window would be complete without those.
As a side effect, this tag also drags:
- The 'kvmarm-fixes-6.1-3' tag as a dependency to the dirty-ring
series
- A shared branch with the arm64 tree that repaints all the system
registers to match the ARM ARM's naming, and resulting in
interesting conflicts
2022-12-06 12:27:39 -05:00
|
|
|
/* Test is done, stop running vCPUs. */
|
|
|
|
bool stop_vcpus;
|
|
|
|
|
2022-10-12 09:57:29 -07:00
|
|
|
struct memstress_vcpu_args vcpu_args[KVM_MAX_VCPUS];
|
2020-10-27 16:37:29 -07:00
|
|
|
};
|
|
|
|
|
2022-10-12 09:57:29 -07:00
|
|
|
extern struct memstress_args memstress_args;
|
2020-10-27 16:37:29 -07:00
|
|
|
|
2022-10-12 09:57:29 -07:00
|
|
|
struct kvm_vm *memstress_create_vm(enum vm_guest_mode mode, int nr_vcpus,
|
2021-08-04 22:28:44 +00:00
|
|
|
uint64_t vcpu_memory_bytes, int slots,
|
2021-11-11 00:03:09 +00:00
|
|
|
enum vm_mem_backing_src_type backing_src,
|
|
|
|
bool partition_vcpu_memory_access);
|
2022-10-12 09:57:29 -07:00
|
|
|
void memstress_destroy_vm(struct kvm_vm *vm);
|
2020-10-27 16:37:29 -07:00
|
|
|
|
2022-10-12 09:57:29 -07:00
|
|
|
void memstress_set_write_percent(struct kvm_vm *vm, uint32_t write_percent);
|
|
|
|
void memstress_set_random_access(struct kvm_vm *vm, bool random_access);
|
2021-11-11 00:03:10 +00:00
|
|
|
|
2022-10-12 09:57:29 -07:00
|
|
|
void memstress_start_vcpu_threads(int vcpus, void (*vcpu_fn)(struct memstress_vcpu_args *));
|
|
|
|
void memstress_join_vcpu_threads(int vcpus);
|
|
|
|
void memstress_guest_code(uint32_t vcpu_id);
|
2022-05-20 23:32:48 +00:00
|
|
|
|
2022-10-12 09:57:29 -07:00
|
|
|
uint64_t memstress_nested_pages(int nr_vcpus);
|
|
|
|
void memstress_setup_nested(struct kvm_vm *vm, int nr_vcpus, struct kvm_vcpu *vcpus[]);
|
2021-11-11 00:12:55 +00:00
|
|
|
|
2023-01-31 18:18:19 +00:00
|
|
|
void memstress_enable_dirty_logging(struct kvm_vm *vm, int slots);
|
|
|
|
void memstress_disable_dirty_logging(struct kvm_vm *vm, int slots);
|
|
|
|
void memstress_get_dirty_log(struct kvm_vm *vm, unsigned long *bitmaps[], int slots);
|
|
|
|
void memstress_clear_dirty_log(struct kvm_vm *vm, unsigned long *bitmaps[],
|
|
|
|
int slots, uint64_t pages_per_slot);
|
|
|
|
unsigned long **memstress_alloc_bitmaps(int slots, uint64_t pages_per_slot);
|
|
|
|
void memstress_free_bitmaps(unsigned long *bitmaps[], int slots);
|
|
|
|
|
2022-10-12 09:57:27 -07:00
|
|
|
#endif /* SELFTEST_KVM_MEMSTRESS_H */
|