Linux kernel mirror (for testing)
git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel
os
linux
1/* SPDX-License-Identifier: GPL-2.0-only */
2/*
3 * tools/testing/selftests/kvm/include/x86_64/svm_utils.h
4 * Header for nested SVM testing
5 *
6 * Copyright (C) 2020, Red Hat, Inc.
7 */
8
9#ifndef SELFTEST_KVM_SVM_UTILS_H
10#define SELFTEST_KVM_SVM_UTILS_H
11
12#include <stdint.h>
13#include "svm.h"
14#include "processor.h"
15
16#define SVM_EXIT_EXCP_BASE 0x040
17#define SVM_EXIT_HLT 0x078
18#define SVM_EXIT_MSR 0x07c
19#define SVM_EXIT_VMMCALL 0x081
20
21struct svm_test_data {
22 /* VMCB */
23 struct vmcb *vmcb; /* gva */
24 void *vmcb_hva;
25 uint64_t vmcb_gpa;
26
27 /* host state-save area */
28 struct vmcb_save_area *save_area; /* gva */
29 void *save_area_hva;
30 uint64_t save_area_gpa;
31
32 /* MSR-Bitmap */
33 void *msr; /* gva */
34 void *msr_hva;
35 uint64_t msr_gpa;
36};
37
38#define stgi() \
39 __asm__ __volatile__( \
40 "stgi\n" \
41 )
42
43#define clgi() \
44 __asm__ __volatile__( \
45 "clgi\n" \
46 )
47
48struct svm_test_data *vcpu_alloc_svm(struct kvm_vm *vm, vm_vaddr_t *p_svm_gva);
49void generic_svm_setup(struct svm_test_data *svm, void *guest_rip, void *guest_rsp);
50void run_guest(struct vmcb *vmcb, uint64_t vmcb_gpa);
51
52int open_sev_dev_path_or_exit(void);
53
54#endif /* SELFTEST_KVM_SVM_UTILS_H */