~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/tools/testing/selftests/kvm/include/x86_64/svm_util.h

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  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 <asm/svm.h>
 13 
 14 #include <stdint.h>
 15 #include "svm.h"
 16 #include "processor.h"
 17 
 18 struct svm_test_data {
 19         /* VMCB */
 20         struct vmcb *vmcb; /* gva */
 21         void *vmcb_hva;
 22         uint64_t vmcb_gpa;
 23 
 24         /* host state-save area */
 25         struct vmcb_save_area *save_area; /* gva */
 26         void *save_area_hva;
 27         uint64_t save_area_gpa;
 28 
 29         /* MSR-Bitmap */
 30         void *msr; /* gva */
 31         void *msr_hva;
 32         uint64_t msr_gpa;
 33 };
 34 
 35 static inline void vmmcall(void)
 36 {
 37         /*
 38          * Stuff RAX and RCX with "safe" values to make sure L0 doesn't handle
 39          * it as a valid hypercall (e.g. Hyper-V L2 TLB flush) as the intended
 40          * use of this function is to exit to L1 from L2.  Clobber all other
 41          * GPRs as L1 doesn't correctly preserve them during vmexits.
 42          */
 43         __asm__ __volatile__("push %%rbp; vmmcall; pop %%rbp"
 44                              : : "a"(0xdeadbeef), "c"(0xbeefdead)
 45                              : "rbx", "rdx", "rsi", "rdi", "r8", "r9",
 46                                "r10", "r11", "r12", "r13", "r14", "r15");
 47 }
 48 
 49 #define stgi()                  \
 50         __asm__ __volatile__(   \
 51                 "stgi\n"        \
 52                 )
 53 
 54 #define clgi()                  \
 55         __asm__ __volatile__(   \
 56                 "clgi\n"        \
 57                 )
 58 
 59 struct svm_test_data *vcpu_alloc_svm(struct kvm_vm *vm, vm_vaddr_t *p_svm_gva);
 60 void generic_svm_setup(struct svm_test_data *svm, void *guest_rip, void *guest_rsp);
 61 void run_guest(struct vmcb *vmcb, uint64_t vmcb_gpa);
 62 
 63 int open_sev_dev_path_or_exit(void);
 64 
 65 #endif /* SELFTEST_KVM_SVM_UTILS_H */
 66 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php