cachepc-linux

Fork of AMDESE/linux with modifications for CachePC side-channel attack
git clone https://git.sinitax.com/sinitax/cachepc-linux
Log | Files | Refs | README | LICENSE | sfeed.txt

perf_test_util.h (1626B)


      1// SPDX-License-Identifier: GPL-2.0
      2/*
      3 * tools/testing/selftests/kvm/include/perf_test_util.h
      4 *
      5 * Copyright (C) 2020, Google LLC.
      6 */
      7
      8#ifndef SELFTEST_KVM_PERF_TEST_UTIL_H
      9#define SELFTEST_KVM_PERF_TEST_UTIL_H
     10
     11#include <pthread.h>
     12
     13#include "kvm_util.h"
     14
     15/* Default guest test virtual memory offset */
     16#define DEFAULT_GUEST_TEST_MEM		0xc0000000
     17
     18#define DEFAULT_PER_VCPU_MEM_SIZE	(1 << 30) /* 1G */
     19
     20#define PERF_TEST_MEM_SLOT_INDEX	1
     21
     22struct perf_test_vcpu_args {
     23	uint64_t gpa;
     24	uint64_t gva;
     25	uint64_t pages;
     26
     27	/* Only used by the host userspace part of the vCPU thread */
     28	int vcpu_id;
     29};
     30
     31struct perf_test_args {
     32	struct kvm_vm *vm;
     33	/* The starting address and size of the guest test region. */
     34	uint64_t gpa;
     35	uint64_t size;
     36	uint64_t guest_page_size;
     37	int wr_fract;
     38
     39	/* Run vCPUs in L2 instead of L1, if the architecture supports it. */
     40	bool nested;
     41
     42	struct perf_test_vcpu_args vcpu_args[KVM_MAX_VCPUS];
     43};
     44
     45extern struct perf_test_args perf_test_args;
     46
     47struct kvm_vm *perf_test_create_vm(enum vm_guest_mode mode, int vcpus,
     48				   uint64_t vcpu_memory_bytes, int slots,
     49				   enum vm_mem_backing_src_type backing_src,
     50				   bool partition_vcpu_memory_access);
     51void perf_test_destroy_vm(struct kvm_vm *vm);
     52
     53void perf_test_set_wr_fract(struct kvm_vm *vm, int wr_fract);
     54
     55void perf_test_start_vcpu_threads(int vcpus, void (*vcpu_fn)(struct perf_test_vcpu_args *));
     56void perf_test_join_vcpu_threads(int vcpus);
     57void perf_test_guest_code(uint32_t vcpu_id);
     58
     59uint64_t perf_test_nested_pages(int nr_vcpus);
     60void perf_test_setup_nested(struct kvm_vm *vm, int nr_vcpus);
     61
     62#endif /* SELFTEST_KVM_PERF_TEST_UTIL_H */