KVM
Classes | Macros | Enumerations | Functions
vmcs.h File Reference
#include <linux/ktime.h>
#include <linux/list.h>
#include <linux/nospec.h>
#include <asm/kvm.h>
#include <asm/vmx.h>
#include "capabilities.h"
Include dependency graph for vmcs.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  vmcs_hdr
 
struct  vmcs
 
struct  vmcs_host_state
 
struct  vmcs_controls_shadow
 
struct  loaded_vmcs
 

Macros

#define ROL16(val, n)   ((u16)(((u16)(val) << (n)) | ((u16)(val) >> (16 - (n)))))
 
#define VMCS_FIELD_INDEX_SHIFT   (1)
 
#define VMCS_FIELD_INDEX_MASK   GENMASK(9, 1)
 

Enumerations

enum  vmcs_field_width { VMCS_FIELD_WIDTH_U16 = 0 , VMCS_FIELD_WIDTH_U64 = 1 , VMCS_FIELD_WIDTH_U32 = 2 , VMCS_FIELD_WIDTH_NATURAL_WIDTH = 3 }
 

Functions

 DECLARE_PER_CPU (struct vmcs *, current_vmcs)
 
static __always_inline bool is_intr_type (u32 intr_info, u32 type)
 
static bool is_intr_type_n (u32 intr_info, u32 type, u8 vector)
 
static bool is_exception_n (u32 intr_info, u8 vector)
 
static bool is_debug (u32 intr_info)
 
static bool is_breakpoint (u32 intr_info)
 
static bool is_double_fault (u32 intr_info)
 
static bool is_page_fault (u32 intr_info)
 
static bool is_invalid_opcode (u32 intr_info)
 
static bool is_gp_fault (u32 intr_info)
 
static bool is_alignment_check (u32 intr_info)
 
static bool is_machine_check (u32 intr_info)
 
static bool is_nm_fault (u32 intr_info)
 
static bool is_icebp (u32 intr_info)
 
static __always_inline bool is_nmi (u32 intr_info)
 
static bool is_external_intr (u32 intr_info)
 
static bool is_exception_with_error_code (u32 intr_info)
 
static int vmcs_field_width (unsigned long field)
 
static int vmcs_field_readonly (unsigned long field)
 
static unsigned int vmcs_field_index (unsigned long field)
 

Macro Definition Documentation

◆ ROL16

#define ROL16 (   val,
 
)    ((u16)(((u16)(val) << (n)) | ((u16)(val) >> (16 - (n)))))

Definition at line 14 of file vmcs.h.

◆ VMCS_FIELD_INDEX_MASK

#define VMCS_FIELD_INDEX_MASK   GENMASK(9, 1)

Definition at line 186 of file vmcs.h.

◆ VMCS_FIELD_INDEX_SHIFT

#define VMCS_FIELD_INDEX_SHIFT   (1)

Definition at line 185 of file vmcs.h.

Enumeration Type Documentation

◆ vmcs_field_width

Enumerator
VMCS_FIELD_WIDTH_U16 
VMCS_FIELD_WIDTH_U64 
VMCS_FIELD_WIDTH_U32 
VMCS_FIELD_WIDTH_NATURAL_WIDTH 

Definition at line 166 of file vmcs.h.

166  {
171 };
@ VMCS_FIELD_WIDTH_U32
Definition: vmcs.h:169
@ VMCS_FIELD_WIDTH_U16
Definition: vmcs.h:167
@ VMCS_FIELD_WIDTH_NATURAL_WIDTH
Definition: vmcs.h:170
@ VMCS_FIELD_WIDTH_U64
Definition: vmcs.h:168

Function Documentation

◆ DECLARE_PER_CPU()

DECLARE_PER_CPU ( struct vmcs ,
current_vmcs   
)

◆ is_alignment_check()

static bool is_alignment_check ( u32  intr_info)
inlinestatic

Definition at line 128 of file vmcs.h.

129 {
130  return is_exception_n(intr_info, AC_VECTOR);
131 }
static bool is_exception_n(u32 intr_info, u8 vector)
Definition: vmcs.h:93
Here is the call graph for this function:
Here is the caller graph for this function:

◆ is_breakpoint()

static bool is_breakpoint ( u32  intr_info)
inlinestatic

Definition at line 103 of file vmcs.h.

104 {
105  return is_exception_n(intr_info, BP_VECTOR);
106 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ is_debug()

static bool is_debug ( u32  intr_info)
inlinestatic

Definition at line 98 of file vmcs.h.

99 {
100  return is_exception_n(intr_info, DB_VECTOR);
101 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ is_double_fault()

static bool is_double_fault ( u32  intr_info)
inlinestatic

Definition at line 108 of file vmcs.h.

109 {
110  return is_exception_n(intr_info, DF_VECTOR);
111 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ is_exception_n()

static bool is_exception_n ( u32  intr_info,
u8  vector 
)
inlinestatic

Definition at line 93 of file vmcs.h.

94 {
95  return is_intr_type_n(intr_info, INTR_TYPE_HARD_EXCEPTION, vector);
96 }
static bool is_intr_type_n(u32 intr_info, u32 type, u8 vector)
Definition: vmcs.h:85
Here is the call graph for this function:
Here is the caller graph for this function:

◆ is_exception_with_error_code()

static bool is_exception_with_error_code ( u32  intr_info)
inlinestatic

Definition at line 159 of file vmcs.h.

160 {
161  const u32 mask = INTR_INFO_VALID_MASK | INTR_INFO_DELIVER_CODE_MASK;
162 
163  return (intr_info & mask) == mask;
164 }
Here is the caller graph for this function:

◆ is_external_intr()

static bool is_external_intr ( u32  intr_info)
inlinestatic

Definition at line 154 of file vmcs.h.

155 {
156  return is_intr_type(intr_info, INTR_TYPE_EXT_INTR);
157 }
static __always_inline bool is_intr_type(u32 intr_info, u32 type)
Definition: vmcs.h:78
Here is the call graph for this function:
Here is the caller graph for this function:

◆ is_gp_fault()

static bool is_gp_fault ( u32  intr_info)
inlinestatic

Definition at line 123 of file vmcs.h.

124 {
125  return is_exception_n(intr_info, GP_VECTOR);
126 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ is_icebp()

static bool is_icebp ( u32  intr_info)
inlinestatic

Definition at line 144 of file vmcs.h.

145 {
146  return is_intr_type(intr_info, INTR_TYPE_PRIV_SW_EXCEPTION);
147 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ is_intr_type()

static __always_inline bool is_intr_type ( u32  intr_info,
u32  type 
)
static

Definition at line 78 of file vmcs.h.

79 {
80  const u32 mask = INTR_INFO_VALID_MASK | INTR_INFO_INTR_TYPE_MASK;
81 
82  return (intr_info & mask) == (INTR_INFO_VALID_MASK | type);
83 }
Here is the caller graph for this function:

◆ is_intr_type_n()

static bool is_intr_type_n ( u32  intr_info,
u32  type,
u8  vector 
)
inlinestatic

Definition at line 85 of file vmcs.h.

86 {
87  const u32 mask = INTR_INFO_VALID_MASK | INTR_INFO_INTR_TYPE_MASK |
88  INTR_INFO_VECTOR_MASK;
89 
90  return (intr_info & mask) == (INTR_INFO_VALID_MASK | type | vector);
91 }
Here is the caller graph for this function:

◆ is_invalid_opcode()

static bool is_invalid_opcode ( u32  intr_info)
inlinestatic

Definition at line 118 of file vmcs.h.

119 {
120  return is_exception_n(intr_info, UD_VECTOR);
121 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ is_machine_check()

static bool is_machine_check ( u32  intr_info)
inlinestatic

Definition at line 133 of file vmcs.h.

134 {
135  return is_exception_n(intr_info, MC_VECTOR);
136 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ is_nm_fault()

static bool is_nm_fault ( u32  intr_info)
inlinestatic

Definition at line 138 of file vmcs.h.

139 {
140  return is_exception_n(intr_info, NM_VECTOR);
141 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ is_nmi()

static __always_inline bool is_nmi ( u32  intr_info)
static

Definition at line 149 of file vmcs.h.

150 {
151  return is_intr_type(intr_info, INTR_TYPE_NMI_INTR);
152 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ is_page_fault()

static bool is_page_fault ( u32  intr_info)
inlinestatic

Definition at line 113 of file vmcs.h.

114 {
115  return is_exception_n(intr_info, PF_VECTOR);
116 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ vmcs_field_index()

static unsigned int vmcs_field_index ( unsigned long  field)
inlinestatic

Definition at line 188 of file vmcs.h.

189 {
190  return (field & VMCS_FIELD_INDEX_MASK) >> VMCS_FIELD_INDEX_SHIFT;
191 }
#define VMCS_FIELD_INDEX_SHIFT
Definition: vmcs.h:185
#define VMCS_FIELD_INDEX_MASK
Definition: vmcs.h:186
Here is the caller graph for this function:

◆ vmcs_field_readonly()

static int vmcs_field_readonly ( unsigned long  field)
inlinestatic

Definition at line 180 of file vmcs.h.

181 {
182  return (((field >> 10) & 0x3) == 1);
183 }
Here is the caller graph for this function:

◆ vmcs_field_width()

static int vmcs_field_width ( unsigned long  field)
inlinestatic

Definition at line 173 of file vmcs.h.

174 {
175  if (0x1 & field) /* the *_HIGH fields are all 32 bit */
176  return VMCS_FIELD_WIDTH_U32;
177  return (field >> 13) & 0x3;
178 }